@mcp-use/inspector 0.12.6 → 0.13.0-canary.4
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-CUptGe10.js +501 -0
- package/dist/client/assets/{display-A5IEINAP-CKX4vEt9.js → display-A5IEINAP-Bf0dty_m.js} +2 -2
- package/dist/client/assets/{embeddings-_gd8Ybda.js → embeddings-gF1fGTwJ.js} +1 -1
- package/dist/client/assets/{index-Bftz7hAD.js → index-38nMdYYP.js} +1 -1
- package/dist/client/assets/{index-ulBkaOKp.js → index-B4jMgYg_.js} +1 -1
- package/dist/client/assets/index-Bcizt1mg.js +1676 -0
- package/dist/client/assets/{index-BZVDzI3u.js → index-Bd7Gb67Q.js} +1 -1
- package/dist/client/assets/{index-BKbSGlCI.js → index-CTRrwbLC.js} +1 -1
- package/dist/client/assets/{index-36UnVi7B.js → index-CwyFRIs-.js} +1 -1
- package/dist/client/assets/{index-BOguzv_X.js → index-DTN0tvsT.js} +1 -1
- package/dist/client/assets/{index-B8valPom.js → index-DjGzt3Oo.js} +1 -1
- package/dist/client/assets/{index-C9gKZsxC.js → index-Q3yfVkKy.js} +1 -1
- package/dist/client/assets/langfuse-74RGPTAH-nvxjqDwm.js +1 -0
- package/dist/client/assets/path-BfxZTWwj.js +1 -0
- package/dist/client/assets/path-C9nscsYI.js +1 -0
- package/dist/client/assets/{winston-BFsqNemi.js → winston-B5Z_6QN6.js} +15 -15
- package/dist/client/index.html +2 -2
- package/package.json +13 -7
- package/dist/client/assets/__vite-browser-external-D7Ct-6yo.js +0 -1
- package/dist/client/assets/browser-Bok5DFD8.js +0 -408
- package/dist/client/assets/index-ubmd7JRV.js +0 -1676
- package/dist/client/assets/path-C2bN6h38.js +0 -1
|
@@ -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-CTRrwbLC.js","assets/index-Bcizt1mg.js","assets/index-beDRbW3x.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as a,a as k}from"./index-Bcizt1mg.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-CTRrwbLC.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{_ as c,A as d}from"./index-
|
|
1
|
+
import{_ as c,A as d}from"./index-Q3yfVkKy.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 _={};c(_,{Embeddings:()=>h});var h=class{caller;constructor(r){this.caller=new d(r??{})}};export{h as E,l as c,_ as e};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as at,f as rt,g as mt,O as Ct,h as Ot,J as yt,R as G}from"./index-B8valPom.js";import{g as ut,x as It,y as vt,z as _t,B as Et,D as Tt,E as wt,F as St,a as lt,H as Rt,I as At,J as x,i as xt,K as kt,L as Nt}from"./index-C9gKZsxC.js";import"./embeddings-_gd8Ybda.js";import"./index-ubmd7JRV.js";import"./index-DRz5BQNA.js";function I(t){if(typeof t=="object"&&t!==null){const e={...t};"additionalProperties"in e&&delete e.additionalProperties,"$schema"in e&&delete e.$schema,"strict"in e&&delete e.strict;for(const n in e)n in e&&(Array.isArray(e[n])?e[n]=e[n].map(I):typeof e[n]=="object"&&e[n]!==null&&(e[n]=I(e[n])));return e}return t}function N(t){const e=I(ut(t)?It(t):t),{$schema:n,...s}=e;return s}function bt(t){const e=I(t),{$schema:n,...s}=e;return s}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Mt(t,e=0){return(h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]).toLowerCase()}let k;const Dt=new Uint8Array(16);function Gt(){if(!k){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");k=crypto.getRandomValues.bind(crypto)}return k(Dt)}const Ut=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),U={randomUUID:Ut};function ct(t,e,n){if(U.randomUUID&&!t)return U.randomUUID();t=t||{};const s=t.random??t.rng?.()??Gt();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Mt(s)}const b="__gemini_function_call_thought_signatures__",Lt="ErYCCrMCAdHtim9kOoOkrPiCNVsmlpMIKd7ZMxgiFbVQOkgp7nlLcDMzVsZwIzvuT7nQROivoXA72ccC2lSDvR0Gh7dkWaGuj7ctv6t7ZceHnecx0QYa+ix8tYpRfjhyWozQ49lWiws6+YGjCt10KRTyWsZ2h6O7iHTYJwKIRwGUHRKy/qK/6kFxJm5ML00gLq4D8s5Z6DBpp2ZlR+uF4G8jJgeWQgyHWVdx2wGYElaceVAc66tZdPQRdOHpWtgYSI1YdaXgVI8KHY3/EfNc2YqqMIulvkDBAnuMhkAjV9xmBa54Tq+ih3Im4+r3DzqhGqYdsSkhS0kZMwte4Hjs65dZzCw9lANxIqYi1DJ639WNPYihp/DCJCos7o+/EeSPJaio5sgWDyUnMGkY1atsJZ+m7pj7DD5tvQ==",Pt=t=>t();function jt(t){const e=t._getType();return wt.isInstance(t)?t.role:e==="tool"?e:t.name??e}function Ft(t){switch(t){case"supervisor":case"ai":case"model":return"model";case"system":return"system";case"human":return"user";case"tool":case"function":return"function";default:throw new Error(`Unknown / unsupported author: ${t}`)}}function Kt(t){if("mimeType"in t&&"data"in t)return{inlineData:{mimeType:t.mimeType,data:t.data}};if("mimeType"in t&&"fileUri"in t)return{fileData:{mimeType:t.mimeType,fileUri:t.fileUri}};throw new Error("Invalid media content")}function Ht(t,e){return e.map(n=>lt(n)?n.tool_calls??[]:[]).flat().find(n=>n.id===t.tool_call_id)?.name}function $t(t){return{providerName:"Google Gemini",fromStandardTextBlock(n){return{text:n.text}},fromStandardImageBlock(n){if(!t)throw new Error("This model does not support images");if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)},fromStandardAudioBlock(n){if(!t)throw new Error("This model does not support audio");if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)},fromStandardFileBlock(n){if(!t)throw new Error("This model does not support files");if(n.source_type==="text")return{text:n.text};if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)}}}function L(t,e){if(Rt(t))return At(t,$t(e));if(t.type==="text")return{text:t.text};if(t.type==="executableCode")return{executableCode:t.executableCode};if(t.type==="codeExecutionResult")return{codeExecutionResult:t.codeExecutionResult};if(t.type==="image_url"){if(!e)throw new Error("This model does not support images");let n;if(typeof t.image_url=="string")n=t.image_url;else if(typeof t.image_url=="object"&&"url"in t.image_url)n=t.image_url.url;else throw new Error("Please provide image as base64 encoded data URL");const[s,i]=n.split(",");if(!s.startsWith("data:"))throw new Error("Please provide image as base64 encoded data URL");const[o,a]=s.replace(/^data:/,"").split(";");if(a!=="base64")throw new Error("Please provide image as base64 encoded data URL");return{inlineData:{data:i,mimeType:o}}}else{if(t.type==="media")return Kt(t);if(t.type==="tool_use")return{functionCall:{name:t.name,args:t.input}};if(t.type?.includes("/")&&t.type.split("/").length===2&&"data"in t&&typeof t.data=="string")return{inlineData:{mimeType:t.type,data:t.data}};if("functionCall"in t)return;throw"type"in t?new Error(`Unknown content type ${t.type}`):new Error(`Unknown content ${JSON.stringify(t)}`)}}function Yt(t,e,n,s){if(St(t)){const u=t.name??Ht(t,n);if(u===void 0)throw new Error(`Google requires a tool name for each tool call response, and we could not infer a called tool name for ToolMessage "${t.id}" from your passed messages. Please populate a "name" field on that ToolMessage explicitly.`);const c=Array.isArray(t.content)?t.content.map(p=>L(p,e)).filter(p=>p!==void 0):t.content;return t.status==="error"?[{functionResponse:{name:u,response:{error:{details:c}}}}]:[{functionResponse:{name:u,response:{result:c}}}]}let i=[];const o=[];typeof t.content=="string"&&t.content&&o.push({text:t.content}),Array.isArray(t.content)&&o.push(...t.content.map(u=>L(u,e)).filter(u=>u!==void 0));const a=t.additional_kwargs?.[b];return lt(t)&&t.tool_calls?.length&&(i=t.tool_calls.map(u=>{const c=Pt(()=>{if(u.id){const p=a?.[u.id];if(p)return p}return s?.includes("gemini-3")?Lt:""});return{functionCall:{name:u.name,args:u.args},...c?{thoughtSignature:c}:{}}})),[...o,...i]}function P(t,e,n=!1,s){return t.reduce((i,o,a)=>{if(!vt(o))throw new Error("Unsupported message input");const u=jt(o);if(u==="system"&&a!==0)throw new Error("System message should be the first one");const c=Ft(u),p=i.content[i.content.length];if(!i.mergeWithPreviousContent&&p&&p.role===c)throw new Error("Google Generative AI requires alternate messages between authors");const r=Yt(o,e,t.slice(0,a),s);if(i.mergeWithPreviousContent){const d=i.content[i.content.length-1];if(!d)throw new Error("There was a problem parsing your system message. Please try a prompt without one.");return d.parts.push(...r),{mergeWithPreviousContent:!1,content:i.content}}let l=c;(l==="function"||l==="system"&&!n)&&(l="user");const f={role:l,parts:r};return{mergeWithPreviousContent:u==="system"&&!n,content:[...i.content,f]}},{content:[],mergeWithPreviousContent:!1}).content}function Bt(t,e){if(!t.candidates||t.candidates.length===0||!t.candidates[0])return{generations:[],llmOutput:{filters:t.promptFeedback}};const[n]=t.candidates,{content:s,...i}=n,o=s.parts.reduce((r,l)=>("functionCall"in l&&l.functionCall&&r.push({...l,id:"id"in l.functionCall&&typeof l.functionCall.id=="string"?l.functionCall.id:ct()}),r),[]);let a;Array.isArray(s?.parts)&&s.parts.length===1&&s.parts[0].text?a=s.parts[0].text:Array.isArray(s?.parts)&&s.parts.length>0?a=s.parts.map(r=>"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];const u=o?.reduce((r,l)=>("thoughtSignature"in l&&typeof l.thoughtSignature=="string"&&(r[l.id]=l.thoughtSignature),r),{});let c="";return typeof a=="string"?c=a:Array.isArray(a)&&a.length>0&&(c=a.find(l=>"text"in l)?.text??c),{generations:[{text:c,message:new _t({content:a??"",tool_calls:o?.map(r=>({type:"tool_call",id:r.id,name:r.functionCall.name,args:r.functionCall.args})),additional_kwargs:{...i,[b]:u},usage_metadata:e?.usageMetadata}),generationInfo:i}],llmOutput:{tokenUsage:{promptTokens:e?.usageMetadata?.input_tokens,completionTokens:e?.usageMetadata?.output_tokens,totalTokens:e?.usageMetadata?.total_tokens}}}}function qt(t,e){if(!t.candidates||t.candidates.length===0)return null;const[n]=t.candidates,{content:s,...i}=n,o=s.parts.reduce((r,l)=>("functionCall"in l&&l.functionCall&&r.push({...l,id:"id"in l.functionCall&&typeof l.functionCall.id=="string"?l.functionCall.id:ct()}),r),[]);let a;Array.isArray(s?.parts)&&s.parts.every(r=>"text"in r)?a=s.parts.map(r=>r.text).join(""):Array.isArray(s?.parts)?a=s.parts.map(r=>"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];let u="";a&&typeof a=="string"?u=a:Array.isArray(a)&&(u=a.find(l=>"text"in l)?.text??"");const c=[];o&&c.push(...o.map(r=>({type:"tool_call_chunk",id:r.id,name:r.functionCall.name,args:JSON.stringify(r.functionCall.args)})));const p=o?.reduce((r,l)=>("thoughtSignature"in l&&typeof l.thoughtSignature=="string"&&(r[l.id]=l.thoughtSignature),r),{});return new Et({text:u,message:new Tt({content:a||"",name:s?s.role:void 0,tool_call_chunks:c,additional_kwargs:{[b]:p},response_metadata:{model_provider:"google-genai"},usage_metadata:e.usageMetadata}),generationInfo:i})}function Wt(t){return t.every(e=>"functionDeclarations"in e&&Array.isArray(e.functionDeclarations))?t:[{functionDeclarations:t.map(e=>{if(at(e)){const n=N(e.schema);return n.type==="object"&&"properties"in n&&Object.keys(n.properties).length===0?{name:e.name,description:e.description}:{name:e.name,description:e.description,parameters:n}}return rt(e)?{name:e.function.name,description:e.function.description??"A function available to call.",parameters:bt(e.function.parameters)}:e})}]}function j(t,e){const n={input_tokens:t?.promptTokenCount??0,output_tokens:t?.candidatesTokenCount??0,total_tokens:t?.totalTokenCount??0};if(t?.cachedContentTokenCount&&(n.input_token_details??={},n.input_token_details.cache_read=t.cachedContentTokenCount),e==="gemini-3-pro-preview"){const s=Math.max(0,t?.promptTokenCount??-2e5),i=Math.max(0,t?.cachedContentTokenCount??-2e5);s&&(n.input_token_details={...n.input_token_details,over_200k:s}),i&&(n.input_token_details={...n.input_token_details,cache_read_over_200k:i})}return n}var F=class extends mt{static lc_name(){return"GoogleGenerativeAIToolsOutputParser"}lc_namespace=["langchain","google_genai","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){if(this.zodSchema===void 0)return t;const e=await xt(this.zodSchema,t);if(e.success)return e.data;throw new Ct(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(e.error.issues)}`,JSON.stringify(t,null,2))}async parseResult(t){const e=t.flatMap(i=>{const{message:o}=i;return!("tool_calls"in o)||!Array.isArray(o.tool_calls)?[]:o.tool_calls});if(e[0]===void 0)throw new Error("No parseable tool calls provided to GoogleGenerativeAIToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}},K;(function(t){t.STRING="string",t.NUMBER="number",t.INTEGER="integer",t.BOOLEAN="boolean",t.ARRAY="array",t.OBJECT="object"})(K||(K={}));var H;(function(t){t.LANGUAGE_UNSPECIFIED="language_unspecified",t.PYTHON="python"})(H||(H={}));var $;(function(t){t.OUTCOME_UNSPECIFIED="outcome_unspecified",t.OUTCOME_OK="outcome_ok",t.OUTCOME_FAILED="outcome_failed",t.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})($||($={}));const Y=["user","model","function","system"];var B;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(B||(B={}));var q;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(q||(q={}));var W;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(W||(W={}));var V;(function(t){t.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",t.SAFETY="SAFETY",t.OTHER="OTHER"})(V||(V={}));var T;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.OTHER="OTHER"})(T||(T={}));var J;(function(t){t.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",t.RETRIEVAL_QUERY="RETRIEVAL_QUERY",t.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",t.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",t.CLASSIFICATION="CLASSIFICATION",t.CLUSTERING="CLUSTERING"})(J||(J={}));var E;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE"})(E||(E={}));var z;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(z||(z={}));class m extends Error{constructor(e){super(`[GoogleGenerativeAI Error]: ${e}`)}}class _ extends m{constructor(e,n){super(e),this.response=n}}class dt extends m{constructor(e,n,s,i){super(e),this.status=n,this.statusText=s,this.errorDetails=i}}class y extends m{}class ft extends m{}const Vt="https://generativelanguage.googleapis.com",Jt="v1beta",zt="0.24.1",Zt="genai-js";var v;(function(t){t.GENERATE_CONTENT="generateContent",t.STREAM_GENERATE_CONTENT="streamGenerateContent",t.COUNT_TOKENS="countTokens",t.EMBED_CONTENT="embedContent",t.BATCH_EMBED_CONTENTS="batchEmbedContents"})(v||(v={}));class Qt{constructor(e,n,s,i,o){this.model=e,this.task=n,this.apiKey=s,this.stream=i,this.requestOptions=o}toString(){var e,n;const s=((e=this.requestOptions)===null||e===void 0?void 0:e.apiVersion)||Jt;let o=`${((n=this.requestOptions)===null||n===void 0?void 0:n.baseUrl)||Vt}/${s}/${this.model}:${this.task}`;return this.stream&&(o+="?alt=sse"),o}}function Xt(t){const e=[];return t?.apiClient&&e.push(t.apiClient),e.push(`${Zt}/${zt}`),e.join(" ")}async function te(t){var e;const n=new Headers;n.append("Content-Type","application/json"),n.append("x-goog-api-client",Xt(t.requestOptions)),n.append("x-goog-api-key",t.apiKey);let s=(e=t.requestOptions)===null||e===void 0?void 0:e.customHeaders;if(s){if(!(s instanceof Headers))try{s=new Headers(s)}catch(i){throw new y(`unable to convert customHeaders value ${JSON.stringify(s)} to Headers: ${i.message}`)}for(const[i,o]of s.entries()){if(i==="x-goog-api-key")throw new y(`Cannot set reserved header name ${i}`);if(i==="x-goog-api-client")throw new y(`Header name ${i} can only be set using the apiClient field`);n.append(i,o)}}return n}async function ee(t,e,n,s,i,o){const a=new Qt(t,e,n,s,o);return{url:a.toString(),fetchOptions:Object.assign(Object.assign({},oe(o)),{method:"POST",headers:await te(a),body:i})}}async function R(t,e,n,s,i,o={},a=fetch){const{url:u,fetchOptions:c}=await ee(t,e,n,s,i,o);return ne(u,c,a)}async function ne(t,e,n=fetch){let s;try{s=await n(t,e)}catch(i){se(i,t)}return s.ok||await ie(s,t),s}function se(t,e){let n=t;throw n.name==="AbortError"?(n=new ft(`Request aborted when fetching ${e.toString()}: ${t.message}`),n.stack=t.stack):t instanceof dt||t instanceof y||(n=new m(`Error fetching from ${e.toString()}: ${t.message}`),n.stack=t.stack),n}async function ie(t,e){let n="",s;try{const i=await t.json();n=i.error.message,i.error.details&&(n+=` ${JSON.stringify(i.error.details)}`,s=i.error.details)}catch{}throw new dt(`Error fetching from ${e.toString()}: [${t.status} ${t.statusText}] ${n}`,t.status,t.statusText,s)}function oe(t){const e={};if(t?.signal!==void 0||t?.timeout>=0){const n=new AbortController;t?.timeout>=0&&setTimeout(()=>n.abort(),t.timeout),t?.signal&&t.signal.addEventListener("abort",()=>{n.abort()}),e.signal=n.signal}return e}function M(t){return t.text=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return ae(t)}else if(t.promptFeedback)throw new _(`Text not available. ${O(t)}`,t);return""},t.functionCall=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),Z(t)[0]}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t.functionCalls=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return Z(t)}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t}function ae(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)a.text&&o.push(a.text),a.executableCode&&o.push("\n```"+a.executableCode.language+`
|
|
1
|
+
import{e as at,f as rt,g as mt,O as Ct,h as Ot,J as yt,R as G}from"./index-DjGzt3Oo.js";import{g as ut,x as It,y as vt,z as _t,B as Et,D as Tt,E as wt,F as St,a as lt,H as Rt,I as At,J as x,i as xt,K as kt,L as Nt}from"./index-Q3yfVkKy.js";import"./embeddings-gF1fGTwJ.js";import"./index-Bcizt1mg.js";import"./index-DRz5BQNA.js";function I(t){if(typeof t=="object"&&t!==null){const e={...t};"additionalProperties"in e&&delete e.additionalProperties,"$schema"in e&&delete e.$schema,"strict"in e&&delete e.strict;for(const n in e)n in e&&(Array.isArray(e[n])?e[n]=e[n].map(I):typeof e[n]=="object"&&e[n]!==null&&(e[n]=I(e[n])));return e}return t}function N(t){const e=I(ut(t)?It(t):t),{$schema:n,...s}=e;return s}function bt(t){const e=I(t),{$schema:n,...s}=e;return s}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Mt(t,e=0){return(h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]).toLowerCase()}let k;const Dt=new Uint8Array(16);function Gt(){if(!k){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");k=crypto.getRandomValues.bind(crypto)}return k(Dt)}const Ut=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),U={randomUUID:Ut};function ct(t,e,n){if(U.randomUUID&&!t)return U.randomUUID();t=t||{};const s=t.random??t.rng?.()??Gt();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,Mt(s)}const b="__gemini_function_call_thought_signatures__",Lt="ErYCCrMCAdHtim9kOoOkrPiCNVsmlpMIKd7ZMxgiFbVQOkgp7nlLcDMzVsZwIzvuT7nQROivoXA72ccC2lSDvR0Gh7dkWaGuj7ctv6t7ZceHnecx0QYa+ix8tYpRfjhyWozQ49lWiws6+YGjCt10KRTyWsZ2h6O7iHTYJwKIRwGUHRKy/qK/6kFxJm5ML00gLq4D8s5Z6DBpp2ZlR+uF4G8jJgeWQgyHWVdx2wGYElaceVAc66tZdPQRdOHpWtgYSI1YdaXgVI8KHY3/EfNc2YqqMIulvkDBAnuMhkAjV9xmBa54Tq+ih3Im4+r3DzqhGqYdsSkhS0kZMwte4Hjs65dZzCw9lANxIqYi1DJ639WNPYihp/DCJCos7o+/EeSPJaio5sgWDyUnMGkY1atsJZ+m7pj7DD5tvQ==",Pt=t=>t();function jt(t){const e=t._getType();return wt.isInstance(t)?t.role:e==="tool"?e:t.name??e}function Ft(t){switch(t){case"supervisor":case"ai":case"model":return"model";case"system":return"system";case"human":return"user";case"tool":case"function":return"function";default:throw new Error(`Unknown / unsupported author: ${t}`)}}function Kt(t){if("mimeType"in t&&"data"in t)return{inlineData:{mimeType:t.mimeType,data:t.data}};if("mimeType"in t&&"fileUri"in t)return{fileData:{mimeType:t.mimeType,fileUri:t.fileUri}};throw new Error("Invalid media content")}function Ht(t,e){return e.map(n=>lt(n)?n.tool_calls??[]:[]).flat().find(n=>n.id===t.tool_call_id)?.name}function $t(t){return{providerName:"Google Gemini",fromStandardTextBlock(n){return{text:n.text}},fromStandardImageBlock(n){if(!t)throw new Error("This model does not support images");if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)},fromStandardAudioBlock(n){if(!t)throw new Error("This model does not support audio");if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)},fromStandardFileBlock(n){if(!t)throw new Error("This model does not support files");if(n.source_type==="text")return{text:n.text};if(n.source_type==="url"){const s=x({dataUrl:n.url});return s?{inlineData:{mimeType:s.mime_type,data:s.data}}:{fileData:{mimeType:n.mime_type??"",fileUri:n.url}}}if(n.source_type==="base64")return{inlineData:{mimeType:n.mime_type??"",data:n.data}};throw new Error(`Unsupported source type: ${n.source_type}`)}}}function L(t,e){if(Rt(t))return At(t,$t(e));if(t.type==="text")return{text:t.text};if(t.type==="executableCode")return{executableCode:t.executableCode};if(t.type==="codeExecutionResult")return{codeExecutionResult:t.codeExecutionResult};if(t.type==="image_url"){if(!e)throw new Error("This model does not support images");let n;if(typeof t.image_url=="string")n=t.image_url;else if(typeof t.image_url=="object"&&"url"in t.image_url)n=t.image_url.url;else throw new Error("Please provide image as base64 encoded data URL");const[s,i]=n.split(",");if(!s.startsWith("data:"))throw new Error("Please provide image as base64 encoded data URL");const[o,a]=s.replace(/^data:/,"").split(";");if(a!=="base64")throw new Error("Please provide image as base64 encoded data URL");return{inlineData:{data:i,mimeType:o}}}else{if(t.type==="media")return Kt(t);if(t.type==="tool_use")return{functionCall:{name:t.name,args:t.input}};if(t.type?.includes("/")&&t.type.split("/").length===2&&"data"in t&&typeof t.data=="string")return{inlineData:{mimeType:t.type,data:t.data}};if("functionCall"in t)return;throw"type"in t?new Error(`Unknown content type ${t.type}`):new Error(`Unknown content ${JSON.stringify(t)}`)}}function Yt(t,e,n,s){if(St(t)){const u=t.name??Ht(t,n);if(u===void 0)throw new Error(`Google requires a tool name for each tool call response, and we could not infer a called tool name for ToolMessage "${t.id}" from your passed messages. Please populate a "name" field on that ToolMessage explicitly.`);const c=Array.isArray(t.content)?t.content.map(p=>L(p,e)).filter(p=>p!==void 0):t.content;return t.status==="error"?[{functionResponse:{name:u,response:{error:{details:c}}}}]:[{functionResponse:{name:u,response:{result:c}}}]}let i=[];const o=[];typeof t.content=="string"&&t.content&&o.push({text:t.content}),Array.isArray(t.content)&&o.push(...t.content.map(u=>L(u,e)).filter(u=>u!==void 0));const a=t.additional_kwargs?.[b];return lt(t)&&t.tool_calls?.length&&(i=t.tool_calls.map(u=>{const c=Pt(()=>{if(u.id){const p=a?.[u.id];if(p)return p}return s?.includes("gemini-3")?Lt:""});return{functionCall:{name:u.name,args:u.args},...c?{thoughtSignature:c}:{}}})),[...o,...i]}function P(t,e,n=!1,s){return t.reduce((i,o,a)=>{if(!vt(o))throw new Error("Unsupported message input");const u=jt(o);if(u==="system"&&a!==0)throw new Error("System message should be the first one");const c=Ft(u),p=i.content[i.content.length];if(!i.mergeWithPreviousContent&&p&&p.role===c)throw new Error("Google Generative AI requires alternate messages between authors");const r=Yt(o,e,t.slice(0,a),s);if(i.mergeWithPreviousContent){const d=i.content[i.content.length-1];if(!d)throw new Error("There was a problem parsing your system message. Please try a prompt without one.");return d.parts.push(...r),{mergeWithPreviousContent:!1,content:i.content}}let l=c;(l==="function"||l==="system"&&!n)&&(l="user");const f={role:l,parts:r};return{mergeWithPreviousContent:u==="system"&&!n,content:[...i.content,f]}},{content:[],mergeWithPreviousContent:!1}).content}function Bt(t,e){if(!t.candidates||t.candidates.length===0||!t.candidates[0])return{generations:[],llmOutput:{filters:t.promptFeedback}};const[n]=t.candidates,{content:s,...i}=n,o=s.parts.reduce((r,l)=>("functionCall"in l&&l.functionCall&&r.push({...l,id:"id"in l.functionCall&&typeof l.functionCall.id=="string"?l.functionCall.id:ct()}),r),[]);let a;Array.isArray(s?.parts)&&s.parts.length===1&&s.parts[0].text?a=s.parts[0].text:Array.isArray(s?.parts)&&s.parts.length>0?a=s.parts.map(r=>"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];const u=o?.reduce((r,l)=>("thoughtSignature"in l&&typeof l.thoughtSignature=="string"&&(r[l.id]=l.thoughtSignature),r),{});let c="";return typeof a=="string"?c=a:Array.isArray(a)&&a.length>0&&(c=a.find(l=>"text"in l)?.text??c),{generations:[{text:c,message:new _t({content:a??"",tool_calls:o?.map(r=>({type:"tool_call",id:r.id,name:r.functionCall.name,args:r.functionCall.args})),additional_kwargs:{...i,[b]:u},usage_metadata:e?.usageMetadata}),generationInfo:i}],llmOutput:{tokenUsage:{promptTokens:e?.usageMetadata?.input_tokens,completionTokens:e?.usageMetadata?.output_tokens,totalTokens:e?.usageMetadata?.total_tokens}}}}function qt(t,e){if(!t.candidates||t.candidates.length===0)return null;const[n]=t.candidates,{content:s,...i}=n,o=s.parts.reduce((r,l)=>("functionCall"in l&&l.functionCall&&r.push({...l,id:"id"in l.functionCall&&typeof l.functionCall.id=="string"?l.functionCall.id:ct()}),r),[]);let a;Array.isArray(s?.parts)&&s.parts.every(r=>"text"in r)?a=s.parts.map(r=>r.text).join(""):Array.isArray(s?.parts)?a=s.parts.map(r=>"text"in r?{type:"text",text:r.text}:"inlineData"in r?{type:"inlineData",inlineData:r.inlineData}:"functionCall"in r?{type:"functionCall",functionCall:r.functionCall}:"functionResponse"in r?{type:"functionResponse",functionResponse:r.functionResponse}:"fileData"in r?{type:"fileData",fileData:r.fileData}:"executableCode"in r?{type:"executableCode",executableCode:r.executableCode}:"codeExecutionResult"in r?{type:"codeExecutionResult",codeExecutionResult:r.codeExecutionResult}:r):a=[];let u="";a&&typeof a=="string"?u=a:Array.isArray(a)&&(u=a.find(l=>"text"in l)?.text??"");const c=[];o&&c.push(...o.map(r=>({type:"tool_call_chunk",id:r.id,name:r.functionCall.name,args:JSON.stringify(r.functionCall.args)})));const p=o?.reduce((r,l)=>("thoughtSignature"in l&&typeof l.thoughtSignature=="string"&&(r[l.id]=l.thoughtSignature),r),{});return new Et({text:u,message:new Tt({content:a||"",name:s?s.role:void 0,tool_call_chunks:c,additional_kwargs:{[b]:p},response_metadata:{model_provider:"google-genai"},usage_metadata:e.usageMetadata}),generationInfo:i})}function Wt(t){return t.every(e=>"functionDeclarations"in e&&Array.isArray(e.functionDeclarations))?t:[{functionDeclarations:t.map(e=>{if(at(e)){const n=N(e.schema);return n.type==="object"&&"properties"in n&&Object.keys(n.properties).length===0?{name:e.name,description:e.description}:{name:e.name,description:e.description,parameters:n}}return rt(e)?{name:e.function.name,description:e.function.description??"A function available to call.",parameters:bt(e.function.parameters)}:e})}]}function j(t,e){const n={input_tokens:t?.promptTokenCount??0,output_tokens:t?.candidatesTokenCount??0,total_tokens:t?.totalTokenCount??0};if(t?.cachedContentTokenCount&&(n.input_token_details??={},n.input_token_details.cache_read=t.cachedContentTokenCount),e==="gemini-3-pro-preview"){const s=Math.max(0,t?.promptTokenCount??-2e5),i=Math.max(0,t?.cachedContentTokenCount??-2e5);s&&(n.input_token_details={...n.input_token_details,over_200k:s}),i&&(n.input_token_details={...n.input_token_details,cache_read_over_200k:i})}return n}var F=class extends mt{static lc_name(){return"GoogleGenerativeAIToolsOutputParser"}lc_namespace=["langchain","google_genai","output_parsers"];returnId=!1;keyName;returnSingle=!1;zodSchema;constructor(t){super(t),this.keyName=t.keyName,this.returnSingle=t.returnSingle??this.returnSingle,this.zodSchema=t.zodSchema}async _validateResult(t){if(this.zodSchema===void 0)return t;const e=await xt(this.zodSchema,t);if(e.success)return e.data;throw new Ct(`Failed to parse. Text: "${JSON.stringify(t,null,2)}". Error: ${JSON.stringify(e.error.issues)}`,JSON.stringify(t,null,2))}async parseResult(t){const e=t.flatMap(i=>{const{message:o}=i;return!("tool_calls"in o)||!Array.isArray(o.tool_calls)?[]:o.tool_calls});if(e[0]===void 0)throw new Error("No parseable tool calls provided to GoogleGenerativeAIToolsOutputParser.");const[n]=e;return await this._validateResult(n.args)}},K;(function(t){t.STRING="string",t.NUMBER="number",t.INTEGER="integer",t.BOOLEAN="boolean",t.ARRAY="array",t.OBJECT="object"})(K||(K={}));var H;(function(t){t.LANGUAGE_UNSPECIFIED="language_unspecified",t.PYTHON="python"})(H||(H={}));var $;(function(t){t.OUTCOME_UNSPECIFIED="outcome_unspecified",t.OUTCOME_OK="outcome_ok",t.OUTCOME_FAILED="outcome_failed",t.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})($||($={}));const Y=["user","model","function","system"];var B;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(B||(B={}));var q;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(q||(q={}));var W;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(W||(W={}));var V;(function(t){t.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",t.SAFETY="SAFETY",t.OTHER="OTHER"})(V||(V={}));var T;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.OTHER="OTHER"})(T||(T={}));var J;(function(t){t.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",t.RETRIEVAL_QUERY="RETRIEVAL_QUERY",t.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",t.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",t.CLASSIFICATION="CLASSIFICATION",t.CLUSTERING="CLUSTERING"})(J||(J={}));var E;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE"})(E||(E={}));var z;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(z||(z={}));class m extends Error{constructor(e){super(`[GoogleGenerativeAI Error]: ${e}`)}}class _ extends m{constructor(e,n){super(e),this.response=n}}class dt extends m{constructor(e,n,s,i){super(e),this.status=n,this.statusText=s,this.errorDetails=i}}class y extends m{}class ft extends m{}const Vt="https://generativelanguage.googleapis.com",Jt="v1beta",zt="0.24.1",Zt="genai-js";var v;(function(t){t.GENERATE_CONTENT="generateContent",t.STREAM_GENERATE_CONTENT="streamGenerateContent",t.COUNT_TOKENS="countTokens",t.EMBED_CONTENT="embedContent",t.BATCH_EMBED_CONTENTS="batchEmbedContents"})(v||(v={}));class Qt{constructor(e,n,s,i,o){this.model=e,this.task=n,this.apiKey=s,this.stream=i,this.requestOptions=o}toString(){var e,n;const s=((e=this.requestOptions)===null||e===void 0?void 0:e.apiVersion)||Jt;let o=`${((n=this.requestOptions)===null||n===void 0?void 0:n.baseUrl)||Vt}/${s}/${this.model}:${this.task}`;return this.stream&&(o+="?alt=sse"),o}}function Xt(t){const e=[];return t?.apiClient&&e.push(t.apiClient),e.push(`${Zt}/${zt}`),e.join(" ")}async function te(t){var e;const n=new Headers;n.append("Content-Type","application/json"),n.append("x-goog-api-client",Xt(t.requestOptions)),n.append("x-goog-api-key",t.apiKey);let s=(e=t.requestOptions)===null||e===void 0?void 0:e.customHeaders;if(s){if(!(s instanceof Headers))try{s=new Headers(s)}catch(i){throw new y(`unable to convert customHeaders value ${JSON.stringify(s)} to Headers: ${i.message}`)}for(const[i,o]of s.entries()){if(i==="x-goog-api-key")throw new y(`Cannot set reserved header name ${i}`);if(i==="x-goog-api-client")throw new y(`Header name ${i} can only be set using the apiClient field`);n.append(i,o)}}return n}async function ee(t,e,n,s,i,o){const a=new Qt(t,e,n,s,o);return{url:a.toString(),fetchOptions:Object.assign(Object.assign({},oe(o)),{method:"POST",headers:await te(a),body:i})}}async function R(t,e,n,s,i,o={},a=fetch){const{url:u,fetchOptions:c}=await ee(t,e,n,s,i,o);return ne(u,c,a)}async function ne(t,e,n=fetch){let s;try{s=await n(t,e)}catch(i){se(i,t)}return s.ok||await ie(s,t),s}function se(t,e){let n=t;throw n.name==="AbortError"?(n=new ft(`Request aborted when fetching ${e.toString()}: ${t.message}`),n.stack=t.stack):t instanceof dt||t instanceof y||(n=new m(`Error fetching from ${e.toString()}: ${t.message}`),n.stack=t.stack),n}async function ie(t,e){let n="",s;try{const i=await t.json();n=i.error.message,i.error.details&&(n+=` ${JSON.stringify(i.error.details)}`,s=i.error.details)}catch{}throw new dt(`Error fetching from ${e.toString()}: [${t.status} ${t.statusText}] ${n}`,t.status,t.statusText,s)}function oe(t){const e={};if(t?.signal!==void 0||t?.timeout>=0){const n=new AbortController;t?.timeout>=0&&setTimeout(()=>n.abort(),t.timeout),t?.signal&&t.signal.addEventListener("abort",()=>{n.abort()}),e.signal=n.signal}return e}function M(t){return t.text=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return ae(t)}else if(t.promptFeedback)throw new _(`Text not available. ${O(t)}`,t);return""},t.functionCall=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),Z(t)[0]}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t.functionCalls=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),A(t.candidates[0]))throw new _(`${O(t)}`,t);return Z(t)}else if(t.promptFeedback)throw new _(`Function call not available. ${O(t)}`,t)},t}function ae(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)a.text&&o.push(a.text),a.executableCode&&o.push("\n```"+a.executableCode.language+`
|
|
2
2
|
`+a.executableCode.code+"\n```\n"),a.codeExecutionResult&&o.push("\n```\n"+a.codeExecutionResult.output+"\n```\n");return o.length>0?o.join(""):""}function Z(t){var e,n,s,i;const o=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(i=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||i===void 0?void 0:i.parts)a.functionCall&&o.push(a.functionCall);if(o.length>0)return o}const re=[T.RECITATION,T.SAFETY,T.LANGUAGE];function A(t){return!!t.finishReason&&re.includes(t.finishReason)}function O(t){var e,n,s;let i="";if((!t.candidates||t.candidates.length===0)&&t.promptFeedback)i+="Response was blocked",!((e=t.promptFeedback)===null||e===void 0)&&e.blockReason&&(i+=` due to ${t.promptFeedback.blockReason}`),!((n=t.promptFeedback)===null||n===void 0)&&n.blockReasonMessage&&(i+=`: ${t.promptFeedback.blockReasonMessage}`);else if(!((s=t.candidates)===null||s===void 0)&&s[0]){const o=t.candidates[0];A(o)&&(i+=`Candidate was blocked due to ${o.finishReason}`,o.finishMessage&&(i+=`: ${o.finishMessage}`))}return i}function w(t){return this instanceof w?(this.v=t,this):new w(t)}function ue(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=n.apply(t,e||[]),i,o=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(f){s[f]&&(i[f]=function(d){return new Promise(function(g,C){o.push([f,d,g,C])>1||u(f,d)})})}function u(f,d){try{c(s[f](d))}catch(g){l(o[0][3],g)}}function c(f){f.value instanceof w?Promise.resolve(f.value.v).then(p,r):l(o[0][2],f)}function p(f){u("next",f)}function r(f){u("throw",f)}function l(f,d){f(d),o.shift(),o.length&&u(o[0][0],o[0][1])}}const Q=/^data\: (.*)(?:\n\n|\r\r|\r\n\r\n)/;function le(t){const e=t.body.pipeThrough(new TextDecoderStream("utf8",{fatal:!0})),n=fe(e),[s,i]=n.tee();return{stream:de(s),response:ce(i)}}async function ce(t){const e=[],n=t.getReader();for(;;){const{done:s,value:i}=await n.read();if(s)return M(pe(e));e.push(i)}}function de(t){return ue(this,arguments,function*(){const n=t.getReader();for(;;){const{value:s,done:i}=yield w(n.read());if(i)break;yield yield w(M(s))}})}function fe(t){const e=t.getReader();return new ReadableStream({start(s){let i="";return o();function o(){return e.read().then(({value:a,done:u})=>{if(u){if(i.trim()){s.error(new m("Failed to parse stream"));return}s.close();return}i+=a;let c=i.match(Q),p;for(;c;){try{p=JSON.parse(c[1])}catch{s.error(new m(`Error parsing JSON response: "${c[1]}"`));return}s.enqueue(p),i=i.substring(c[0].length),c=i.match(Q)}return o()}).catch(a=>{let u=a;throw u.stack=a.stack,u.name==="AbortError"?u=new ft("Request aborted when reading from the stream"):u=new m("Error reading from the stream"),u})}}})}function pe(t){const e=t[t.length-1],n={promptFeedback:e?.promptFeedback};for(const s of t){if(s.candidates){let i=0;for(const o of s.candidates)if(n.candidates||(n.candidates=[]),n.candidates[i]||(n.candidates[i]={index:i}),n.candidates[i].citationMetadata=o.citationMetadata,n.candidates[i].groundingMetadata=o.groundingMetadata,n.candidates[i].finishReason=o.finishReason,n.candidates[i].finishMessage=o.finishMessage,n.candidates[i].safetyRatings=o.safetyRatings,o.content&&o.content.parts){n.candidates[i].content||(n.candidates[i].content={role:o.content.role||"user",parts:[]});const a={};for(const u of o.content.parts)u.text&&(a.text=u.text),u.functionCall&&(a.functionCall=u.functionCall),u.executableCode&&(a.executableCode=u.executableCode),u.codeExecutionResult&&(a.codeExecutionResult=u.codeExecutionResult),Object.keys(a).length===0&&(a.text=""),n.candidates[i].content.parts.push(a)}i++}s.usageMetadata&&(n.usageMetadata=s.usageMetadata)}return n}async function pt(t,e,n,s){const i=await R(e,v.STREAM_GENERATE_CONTENT,t,!0,JSON.stringify(n),s);return le(i)}async function gt(t,e,n,s){const o=await(await R(e,v.GENERATE_CONTENT,t,!1,JSON.stringify(n),s)).json();return{response:M(o)}}function ht(t){if(t!=null){if(typeof t=="string")return{role:"system",parts:[{text:t}]};if(t.text)return{role:"system",parts:[t]};if(t.parts)return t.role?t:{role:"system",parts:t.parts}}}function S(t){let e=[];if(typeof t=="string")e=[{text:t}];else for(const n of t)typeof n=="string"?e.push({text:n}):e.push(n);return ge(e)}function ge(t){const e={role:"user",parts:[]},n={role:"function",parts:[]};let s=!1,i=!1;for(const o of t)"functionResponse"in o?(n.parts.push(o),i=!0):(e.parts.push(o),s=!0);if(s&&i)throw new m("Within a single message, FunctionResponse cannot be mixed with other type of part in the request for sending chat message.");if(!s&&!i)throw new m("No content is provided for sending chat message.");return s?e:n}function he(t,e){var n;let s={model:e?.model,generationConfig:e?.generationConfig,safetySettings:e?.safetySettings,tools:e?.tools,toolConfig:e?.toolConfig,systemInstruction:e?.systemInstruction,cachedContent:(n=e?.cachedContent)===null||n===void 0?void 0:n.name,contents:[]};const i=t.generateContentRequest!=null;if(t.contents){if(i)throw new y("CountTokensRequest must have one of contents or generateContentRequest, not both.");s.contents=t.contents}else if(i)s=Object.assign(Object.assign({},s),t.generateContentRequest);else{const o=S(t);s.contents=[o]}return{generateContentRequest:s}}function X(t){let e;return t.contents?e=t:e={contents:[S(t)]},t.systemInstruction&&(e.systemInstruction=ht(t.systemInstruction)),e}function me(t){return typeof t=="string"||Array.isArray(t)?{content:S(t)}:t}const tt=["text","inlineData","functionCall","functionResponse","executableCode","codeExecutionResult"],Ce={user:["text","inlineData"],function:["functionResponse"],model:["text","functionCall","executableCode","codeExecutionResult"],system:["text"]};function Oe(t){let e=!1;for(const n of t){const{role:s,parts:i}=n;if(!e&&s!=="user")throw new m(`First content should be with role 'user', got ${s}`);if(!Y.includes(s))throw new m(`Each item should include role field. Got ${s} but valid roles are: ${JSON.stringify(Y)}`);if(!Array.isArray(i))throw new m("Content should have 'parts' property with an array of Parts");if(i.length===0)throw new m("Each Content should have at least one part");const o={text:0,inlineData:0,functionCall:0,functionResponse:0,fileData:0,executableCode:0,codeExecutionResult:0};for(const u of i)for(const c of tt)c in u&&(o[c]+=1);const a=Ce[s];for(const u of tt)if(!a.includes(u)&&o[u]>0)throw new m(`Content with role '${s}' can't contain '${u}' part`);e=!0}}function et(t){var e;if(t.candidates===void 0||t.candidates.length===0)return!1;const n=(e=t.candidates[0])===null||e===void 0?void 0:e.content;if(n===void 0||n.parts===void 0||n.parts.length===0)return!1;for(const s of n.parts)if(s===void 0||Object.keys(s).length===0||s.text!==void 0&&s.text==="")return!1;return!0}const nt="SILENT_ERROR";class ye{constructor(e,n,s,i={}){this.model=n,this.params=s,this._requestOptions=i,this._history=[],this._sendPromise=Promise.resolve(),this._apiKey=e,s?.history&&(Oe(s.history),this._history=s.history)}async getHistory(){return await this._sendPromise,this._history}async sendMessage(e,n={}){var s,i,o,a,u,c;await this._sendPromise;const p=S(e),r={safetySettings:(s=this.params)===null||s===void 0?void 0:s.safetySettings,generationConfig:(i=this.params)===null||i===void 0?void 0:i.generationConfig,tools:(o=this.params)===null||o===void 0?void 0:o.tools,toolConfig:(a=this.params)===null||a===void 0?void 0:a.toolConfig,systemInstruction:(u=this.params)===null||u===void 0?void 0:u.systemInstruction,cachedContent:(c=this.params)===null||c===void 0?void 0:c.cachedContent,contents:[...this._history,p]},l=Object.assign(Object.assign({},this._requestOptions),n);let f;return this._sendPromise=this._sendPromise.then(()=>gt(this._apiKey,this.model,r,l)).then(d=>{var g;if(et(d.response)){this._history.push(p);const C=Object.assign({parts:[],role:"model"},(g=d.response.candidates)===null||g===void 0?void 0:g[0].content);this._history.push(C)}else{const C=O(d.response);C&&console.warn(`sendMessage() was unsuccessful. ${C}. Inspect response object for details.`)}f=d}).catch(d=>{throw this._sendPromise=Promise.resolve(),d}),await this._sendPromise,f}async sendMessageStream(e,n={}){var s,i,o,a,u,c;await this._sendPromise;const p=S(e),r={safetySettings:(s=this.params)===null||s===void 0?void 0:s.safetySettings,generationConfig:(i=this.params)===null||i===void 0?void 0:i.generationConfig,tools:(o=this.params)===null||o===void 0?void 0:o.tools,toolConfig:(a=this.params)===null||a===void 0?void 0:a.toolConfig,systemInstruction:(u=this.params)===null||u===void 0?void 0:u.systemInstruction,cachedContent:(c=this.params)===null||c===void 0?void 0:c.cachedContent,contents:[...this._history,p]},l=Object.assign(Object.assign({},this._requestOptions),n),f=pt(this._apiKey,this.model,r,l);return this._sendPromise=this._sendPromise.then(()=>f).catch(d=>{throw new Error(nt)}).then(d=>d.response).then(d=>{if(et(d)){this._history.push(p);const g=Object.assign({},d.candidates[0].content);g.role||(g.role="model"),this._history.push(g)}else{const g=O(d);g&&console.warn(`sendMessageStream() was unsuccessful. ${g}. Inspect response object for details.`)}}).catch(d=>{d.message!==nt&&console.error(d)}),f}}async function Ie(t,e,n,s){return(await R(e,v.COUNT_TOKENS,t,!1,JSON.stringify(n),s)).json()}async function ve(t,e,n,s){return(await R(e,v.EMBED_CONTENT,t,!1,JSON.stringify(n),s)).json()}async function _e(t,e,n,s){const i=n.requests.map(a=>Object.assign(Object.assign({},a),{model:e}));return(await R(e,v.BATCH_EMBED_CONTENTS,t,!1,JSON.stringify({requests:i}),s)).json()}class st{constructor(e,n,s={}){this.apiKey=e,this._requestOptions=s,n.model.includes("/")?this.model=n.model:this.model=`models/${n.model}`,this.generationConfig=n.generationConfig||{},this.safetySettings=n.safetySettings||[],this.tools=n.tools,this.toolConfig=n.toolConfig,this.systemInstruction=ht(n.systemInstruction),this.cachedContent=n.cachedContent}async generateContent(e,n={}){var s;const i=X(e),o=Object.assign(Object.assign({},this._requestOptions),n);return gt(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(s=this.cachedContent)===null||s===void 0?void 0:s.name},i),o)}async generateContentStream(e,n={}){var s;const i=X(e),o=Object.assign(Object.assign({},this._requestOptions),n);return pt(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(s=this.cachedContent)===null||s===void 0?void 0:s.name},i),o)}startChat(e){var n;return new ye(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(n=this.cachedContent)===null||n===void 0?void 0:n.name},e),this._requestOptions)}async countTokens(e,n={}){const s=he(e,{model:this.model,generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:this.cachedContent}),i=Object.assign(Object.assign({},this._requestOptions),n);return Ie(this.apiKey,this.model,s,i)}async embedContent(e,n={}){const s=me(e),i=Object.assign(Object.assign({},this._requestOptions),n);return ve(this.apiKey,this.model,s,i)}async batchEmbedContents(e,n={}){const s=Object.assign(Object.assign({},this._requestOptions),n);return _e(this.apiKey,this.model,e,s)}}class it{constructor(e){this.apiKey=e}getGenerativeModel(e,n){if(!e.model)throw new m("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new st(this.apiKey,e,n)}getGenerativeModelFromCachedContent(e,n,s){if(!e.name)throw new y("Cached content must contain a `name` field.");if(!e.model)throw new y("Cached content must contain a `model` field.");const i=["model","systemInstruction"];for(const a of i)if(n?.[a]&&e[a]&&n?.[a]!==e[a]){if(a==="model"){const u=n.model.startsWith("models/")?n.model.replace("models/",""):n.model,c=e.model.startsWith("models/")?e.model.replace("models/",""):e.model;if(u===c)continue}throw new y(`Different value for "${a}" specified in modelParams (${n[a]}) and cachedContent (${e[a]})`)}const o=Object.assign(Object.assign({},n),{model:e.model,tools:e.tools,toolConfig:e.toolConfig,systemInstruction:e.systemInstruction,cachedContent:e});return new st(this.apiKey,o,s)}}function ot(t,e){const n=Ee(t),s=we(n,e);return{tools:n,toolConfig:s}}function Ee(t){let e=[];const n=[];return t.forEach(i=>{if(at(i)){const[o]=Wt([i]);o.functionDeclarations&&e.push(...o.functionDeclarations)}else if(rt(i)){const{functionDeclarations:o}=Te(i);if(o)e.push(...o);else throw new Error("Failed to convert OpenAI structured tool to GenerativeAI tool")}else n.push(i)}),n.find(i=>"functionDeclarations"in i)?n.map(i=>{if(e?.length>0&&"functionDeclarations"in i){const o={functionDeclarations:[...i.functionDeclarations||[],...e]};return e=[],o}return i}):[...n,...e.length>0?[{functionDeclarations:e}]:[]]}function Te(t){return{functionDeclarations:[{name:t.function.name,description:t.function.description,parameters:I(t.function.parameters)}]}}function we(t,e){if(!t.length||!e)return;const{toolChoice:n,allowedFunctionNames:s}=e,i={any:E.ANY,auto:E.AUTO,none:E.NONE};if(n&&["any","auto","none"].includes(n))return{functionCallingConfig:{mode:i[n]??"MODE_UNSPECIFIED",allowedFunctionNames:s}};if(typeof n=="string"||s)return{functionCallingConfig:{mode:E.ANY,allowedFunctionNames:[...s??[],...n&&typeof n=="string"?[n]:[]]}}}const Se={"gemini-embedding-001":{maxInputTokens:2048,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:3072,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-image":{maxInputTokens:32768,imageInputs:!0,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!0,imageOutputs:!0,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-preview-05-20":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-flash-lite-latest":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-flash-latest":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-pro-preview-05-06":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-preview-tts":{maxInputTokens:8e3,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:16e3,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.0-flash-lite":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-live-2.5-flash-preview-native-audio":{maxInputTokens:131072,imageInputs:!1,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.0-flash":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-lite":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-pro-preview-06-05":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-live-2.5-flash":{maxInputTokens:128e3,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8e3,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-lite-preview-06-17":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-image-preview":{maxInputTokens:32768,imageInputs:!0,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:32768,reasoningOutput:!0,imageOutputs:!0,audioOutputs:!1,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-flash-preview-09-2025":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-2.5-flash-preview-04-17":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-pro-preview-tts":{maxInputTokens:8e3,imageInputs:!1,audioInputs:!1,pdfInputs:!1,videoInputs:!1,maxOutputTokens:16e3,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!0,videoOutputs:!1,toolCalling:!1,structuredOutput:!1},"gemini-2.5-pro":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-1.5-flash":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-1.5-flash-8b":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1},"gemini-2.5-flash-lite-preview-09-2025":{maxInputTokens:1048576,imageInputs:!0,audioInputs:!0,pdfInputs:!0,videoInputs:!0,maxOutputTokens:65536,reasoningOutput:!0,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!0},"gemini-1.5-pro":{maxInputTokens:1e6,imageInputs:!0,audioInputs:!0,pdfInputs:!1,videoInputs:!0,maxOutputTokens:8192,reasoningOutput:!1,imageOutputs:!1,audioOutputs:!1,videoOutputs:!1,toolCalling:!0,structuredOutput:!1}};var Re=Se,Me=class extends Ot{static lc_name(){return"ChatGoogleGenerativeAI"}lc_serializable=!0;get lc_secrets(){return{apiKey:"GOOGLE_API_KEY"}}lc_namespace=["langchain","chat_models","google_genai"];get lc_aliases(){return{apiKey:"google_api_key"}}model;temperature;maxOutputTokens;topP;topK;stopSequences=[];safetySettings;apiKey;streaming=!1;json;streamUsage=!0;convertSystemMessageToHumanContent;thinkingConfig;client;get _isMultimodalModel(){return this.model.includes("vision")||this.model.startsWith("gemini-1.5")||this.model.startsWith("gemini-2")||this.model.startsWith("gemma-3-")&&!this.model.startsWith("gemma-3-1b")||this.model.startsWith("gemini-3")}constructor(t){if(super(t),this.model=t.model.replace(/^models\//,""),this.maxOutputTokens=t.maxOutputTokens??this.maxOutputTokens,this.maxOutputTokens&&this.maxOutputTokens<0)throw new Error("`maxOutputTokens` must be a positive integer");if(this.temperature=t.temperature??this.temperature,this.temperature&&(this.temperature<0||this.temperature>2))throw new Error("`temperature` must be in the range of [0.0,2.0]");if(this.topP=t.topP??this.topP,this.topP&&this.topP<0)throw new Error("`topP` must be a positive integer");if(this.topP&&this.topP>1)throw new Error("`topP` must be below 1.");if(this.topK=t.topK??this.topK,this.topK&&this.topK<0)throw new Error("`topK` must be a positive integer");if(this.stopSequences=t.stopSequences??this.stopSequences,this.apiKey=t.apiKey??kt("GOOGLE_API_KEY"),!this.apiKey)throw new Error("Please set an API key for Google GenerativeAI in the environment variable GOOGLE_API_KEY or in the `apiKey` field of the ChatGoogleGenerativeAI constructor");if(this.safetySettings=t.safetySettings??this.safetySettings,this.safetySettings&&this.safetySettings.length>0&&new Set(this.safetySettings.map(n=>n.category)).size!==this.safetySettings.length)throw new Error("The categories in `safetySettings` array must be unique");this.streaming=t.streaming??this.streaming,this.json=t.json,this.thinkingConfig=t.thinkingConfig??this.thinkingConfig,this.client=new it(this.apiKey).getGenerativeModel({model:this.model,safetySettings:this.safetySettings,generationConfig:{stopSequences:this.stopSequences,maxOutputTokens:this.maxOutputTokens,temperature:this.temperature,topP:this.topP,topK:this.topK,...this.json?{responseMimeType:"application/json"}:{},...this.thinkingConfig?{thinkingConfig:this.thinkingConfig}:{}}},{apiVersion:t.apiVersion,baseUrl:t.baseUrl}),this.streamUsage=t.streamUsage??this.streamUsage}useCachedContent(t,e,n){this.apiKey&&(this.client=new it(this.apiKey).getGenerativeModelFromCachedContent(t,e,n))}get useSystemInstruction(){return typeof this.convertSystemMessageToHumanContent=="boolean"?!this.convertSystemMessageToHumanContent:this.computeUseSystemInstruction}get computeUseSystemInstruction(){return this.model==="gemini-1.0-pro-001"||this.model.startsWith("gemini-pro-vision")||this.model.startsWith("gemini-1.0-pro-vision")?!1:this.model!=="gemini-pro"}getLsParams(t){return{ls_provider:"google_genai",ls_model_name:this.model,ls_model_type:"chat",ls_temperature:this.client.generationConfig.temperature,ls_max_tokens:this.client.generationConfig.maxOutputTokens,ls_stop:t.stop}}_combineLLMOutput(){return[]}_llmType(){return"googlegenerativeai"}bindTools(t,e){return this.withConfig({tools:ot(t)?.tools,...e})}invocationParams(t){const e=t?.tools?.length?ot(t.tools,{toolChoice:t.tool_choice,allowedFunctionNames:t.allowedFunctionNames}):void 0;return t?.responseSchema?(this.client.generationConfig.responseSchema=t.responseSchema,this.client.generationConfig.responseMimeType="application/json"):(this.client.generationConfig.responseSchema=void 0,this.client.generationConfig.responseMimeType=this.json?"application/json":void 0),{...e?.tools?{tools:e.tools}:{},...e?.toolConfig?{toolConfig:e.toolConfig}:{}}}async _generate(t,e,n){const s=P(t,this._isMultimodalModel,this.useSystemInstruction,this.model);let i=s;if(s[0].role==="system"){const[p]=s;this.client.systemInstruction=p,i=s.slice(1)}const o=this.invocationParams(e);if(this.streaming){const p={},r=this._streamResponseChunks(t,e,n),l={};for await(const d of r){const g=d.generationInfo?.completion??0;l[g]===void 0?l[g]=d:l[g]=l[g].concat(d)}return{generations:Object.entries(l).sort(([d],[g])=>parseInt(d,10)-parseInt(g,10)).map(([d,g])=>g),llmOutput:{estimatedTokenUsage:p}}}const a=await this.completionWithRetry({...o,contents:i});let u;"usageMetadata"in a.response&&(u=j(a.response.usageMetadata,this.model));const c=Bt(a.response,{usageMetadata:u});return c.generations?.length>0&&await n?.handleLLMNewToken(c.generations[0]?.text??""),c}async*_streamResponseChunks(t,e,n){const s=P(t,this._isMultimodalModel,this.useSystemInstruction,this.model);let i=s;if(s[0].role==="system"){const[f]=s;this.client.systemInstruction=f,i=s.slice(1)}const a={...this.invocationParams(e),contents:i},u=await this.caller.callWithOptions({signal:e?.signal},async()=>{const{stream:f}=await this.client.generateContentStream(a);return f});let c,p=0,r=0,l=0;for await(const f of u){if("usageMetadata"in f&&f.usageMetadata!==void 0&&this.streamUsage!==!1&&e.streamUsage!==!1){c=j(f.usageMetadata,this.model);const g=f.usageMetadata.promptTokenCount??0;c.input_tokens=Math.max(0,g-p),p=g;const C=f.usageMetadata.candidatesTokenCount??0;c.output_tokens=Math.max(0,C-r),r=C;const D=f.usageMetadata.totalTokenCount??0;c.total_tokens=Math.max(0,D-l),l=D}const d=qt(f,{usageMetadata:c});d&&(yield d,await n?.handleLLMNewToken(d.text??""))}}async completionWithRetry(t,e){return this.caller.callWithOptions({signal:e?.signal},async()=>{try{return await this.client.generateContent(t)}catch(n){throw n.message?.includes("400 Bad Request")&&(n.status=400),n}})}get profile(){return Re[this.model]??{}}withStructuredOutput(t,e){const n=t,s=e?.name,i=e?.method,o=e?.includeRaw;if(i==="jsonMode")throw new Error('ChatGoogleGenerativeAI only supports "jsonSchema" or "functionCalling" as a method.');let a,u;if(i==="functionCalling"){let l=s??"extract",f;if(ut(n)){const d=N(n);f=[{functionDeclarations:[{name:l,description:d.description??"A function available to call.",parameters:d}]}],u=new F({returnSingle:!0,keyName:l,zodSchema:n})}else{let d;typeof n.name=="string"&&typeof n.parameters=="object"&&n.parameters!=null?(d=n,d.parameters=I(n.parameters),l=n.name):d={name:l,description:n.description??"",parameters:I(n)},f=[{functionDeclarations:[d]}],u=new F({returnSingle:!0,keyName:l})}a=this.bindTools(f).withConfig({allowedFunctionNames:[l]})}else{const l=N(n);a=this.withConfig({responseSchema:l}),u=new yt}if(!o)return a.pipe(u).withConfig({runName:"ChatGoogleGenerativeAIStructuredOutput"});const c=G.assign({parsed:(l,f)=>u.invoke(l.raw,f)}),p=G.assign({parsed:()=>null}),r=c.withFallbacks({fallbacks:[p]});return Nt.from([{raw:a},r]).withConfig({runName:"StructuredOutputRunnable"})}};export{Me as ChatGoogleGenerativeAI};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as d,R as ce,b as Ii,c as Hi}from"./index-ubmd7JRV.js";var Ct={},Ia;function ji(){if(Ia)return Ct;Ia=1,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.parse=i,Ct.serialize=u;const e=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,t=/^[\u0021-\u003A\u003C-\u007E]*$/,r=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,a=/^[\u0020-\u003A\u003D-\u007E]*$/,n=Object.prototype.toString,o=(()=>{const m=function(){};return m.prototype=Object.create(null),m})();function i(m,p){const h=new o,g=m.length;if(g<2)return h;const y=p?.decode||c;let w=0;do{const R=m.indexOf("=",w);if(R===-1)break;const C=m.indexOf(";",w),x=C===-1?g:C;if(R>x){w=m.lastIndexOf(";",R-1)+1;continue}const P=s(m,w,R),D=l(m,R,P),E=m.slice(P,D);if(h[E]===void 0){let F=s(m,R+1,x),T=l(m,x,F);const M=y(m.slice(F,T));h[E]=M}w=x+1}while(w<g);return h}function s(m,p,h){do{const g=m.charCodeAt(p);if(g!==32&&g!==9)return p}while(++p<h);return h}function l(m,p,h){for(;p>h;){const g=m.charCodeAt(--p);if(g!==32&&g!==9)return p+1}return h}function u(m,p,h){const g=h?.encode||encodeURIComponent;if(!e.test(m))throw new TypeError(`argument name is invalid: ${m}`);const y=g(p);if(!t.test(y))throw new TypeError(`argument val is invalid: ${p}`);let w=m+"="+y;if(!h)return w;if(h.maxAge!==void 0){if(!Number.isInteger(h.maxAge))throw new TypeError(`option maxAge is invalid: ${h.maxAge}`);w+="; Max-Age="+h.maxAge}if(h.domain){if(!r.test(h.domain))throw new TypeError(`option domain is invalid: ${h.domain}`);w+="; Domain="+h.domain}if(h.path){if(!a.test(h.path))throw new TypeError(`option path is invalid: ${h.path}`);w+="; Path="+h.path}if(h.expires){if(!f(h.expires)||!Number.isFinite(h.expires.valueOf()))throw new TypeError(`option expires is invalid: ${h.expires}`);w+="; Expires="+h.expires.toUTCString()}if(h.httpOnly&&(w+="; HttpOnly"),h.secure&&(w+="; Secure"),h.partitioned&&(w+="; Partitioned"),h.priority)switch(typeof h.priority=="string"?h.priority.toLowerCase():void 0){case"low":w+="; Priority=Low";break;case"medium":w+="; Priority=Medium";break;case"high":w+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${h.priority}`)}if(h.sameSite)switch(typeof h.sameSite=="string"?h.sameSite.toLowerCase():h.sameSite){case!0:case"strict":w+="; SameSite=Strict";break;case"lax":w+="; SameSite=Lax";break;case"none":w+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${h.sameSite}`)}return w}function c(m){if(m.indexOf("%")===-1)return m;try{return decodeURIComponent(m)}catch{return m}}function f(m){return n.call(m)==="[object Date]"}return Ct}var Ha=ji(),st={exports:{}},ja;function Ui(){if(ja)return st.exports;ja=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),f=c.shift(),m=o(f),p=m.name,h=m.value;if(u=u?Object.assign({},e,u):e,t(p))return null;try{h=u.decodeValues?decodeURIComponent(h):h}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=h,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 x=parseInt(C,10);Number.isNaN(x)||(g.maxAge=x)}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="",f=l.split("=");return f.length>1?(u=f.shift(),c=f.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 f=r();return l.filter(a).reduce(function(m,p){var h=n(p,u);return h&&!t(h.name)&&(m[h.name]=h),m},f)}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,f,m,p,h,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(f=c,g=!1;y();)if(m=l.charAt(c),m===","){for(p=c,c+=1,y(),h=c;c<l.length&&w();)c+=1;c<l.length&&l.charAt(c)==="="?(g=!0,c=h,u.push(l.substring(f,p)),f=c):c=p+1}else c+=1;(!g||c>=l.length)&&u.push(l.substring(f,l.length))}return u}return st.exports=i,st.exports.parse=i,st.exports.parseString=n,st.exports.splitCookiesString=s,st.exports}var zi=Ui();var Pn=e=>{throw TypeError(e)},Bi=(e,t,r)=>t.has(e)||Pn("Cannot "+r),xr=(e,t,r)=>(Bi(e,t,"read from private field"),r?r.call(e):t.get(e)),Wi=(e,t,r)=>t.has(e)?Pn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Vi=(e=>(e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE",e))(Vi||{}),Ua="popstate";function Dn(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:a=!1}=e,n;n=t.map((p,h)=>c(p,typeof p=="string"?null:p.state,h===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,h=null,g){let y=$e(n?u().pathname:"/",p,h,g);return X(y.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(p)}`),y}function f(p){return typeof p=="string"?p:he(p)}return{get index(){return o},get action(){return i},get location(){return u()},createHref:f,createURL(p){return new URL(f(p),"http://localhost")},encodeLocation(p){let h=typeof p=="string"?Pe(p):p;return{pathname:h.pathname||"",search:h.search||"",hash:h.hash||""}},push(p,h){i="PUSH";let g=c(p,h);o+=1,n.splice(o,n.length,g),a&&s&&s({action:i,location:g,delta:1})},replace(p,h){i="REPLACE";let g=c(p,h);n[o]=g,a&&s&&s({action:i,location:g,delta:0})},go(p){i="POP";let h=l(o+p),g=n[h];o=h,s&&s({action:i,location:g,delta:p})},listen(p){return s=p,()=>{s=null}}}}function qr(e={}){function t(a,n){let{pathname:o,search:i,hash:s}=a.location;return $e("",{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 _n(t,r,null,e)}function Ln(e={}){function t(n,o){let{pathname:i="/",search:s="",hash:l=""}=Pe(n.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),$e("",{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){X(n.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return _n(t,r,a,e)}function A(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function X(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Yi(){return Math.random().toString(36).substring(2,10)}function za(e,t){return{usr:e.state,key:e.key,idx:t}}function $e(e,t,r=null,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Pe(t):t,state:r,key:t&&t.key||a||Yi()}}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 Pe(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 _n(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 f(){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=$e(g.location,y,w);r&&r(R,y),u=c()+1;let C=za(R,u),x=g.createHref(R);try{i.pushState(C,"",x)}catch(P){if(P instanceof DOMException&&P.name==="DataCloneError")throw P;n.location.assign(x)}o&&l&&l({action:s,location:g.location,delta:1})}function p(y,w){s="REPLACE";let R=$e(g.location,y,w);r&&r(R,y),u=c();let C=za(R,u),x=g.createHref(R);i.replaceState(C,"",x),o&&l&&l({action:s,location:g.location,delta:0})}function h(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(Ua,f),l=y,()=>{n.removeEventListener(Ua,f),l=null}},createHref(y){return t(n,y)},createURL:h,encodeLocation(y){let w=h(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),A(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 Ec(e){return{defaultValue:e}}var Lt,Ae=class{constructor(e){if(Wi(this,Lt,new Map),e)for(let[t,r]of e)this.set(t,r)}get(e){if(xr(this,Lt).has(e))return xr(this,Lt).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){xr(this,Lt).set(e,t)}};Lt=new WeakMap;var Ji=new Set(["lazy","caseSensitive","path","id","index","children"]);function Ki(e){return Ji.has(e)}var Xi=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function Gi(e){return Xi.has(e)}function Qi(e){return e.index===!0}function Ve(e,t,r=[],a={},n=!1){return e.map((o,i)=>{let s=[...r,String(i)],l=typeof o.id=="string"?o.id:s.join("-");if(A(o.index!==!0||!o.children,"Cannot specify children on an index route"),A(n||!a[l],`Found a route id collision on id "${l}". Route id's must be globally unique within Data Router usages`),Qi(o)){let u={...o,id:l};return a[l]=Ba(u,t(u)),u}else{let u={...o,id:l,children:void 0};return a[l]=Ba(u,t(u)),o.children&&(u.children=Ve(o.children,t,s,a,n)),u}})}function Ba(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function ge(e,t,r="/"){return Jt(e,t,r,!1)}function Jt(e,t,r,a){let n=typeof t=="string"?Pe(t):t,o=ne(n.pathname||"/",r);if(o==null)return null;let i=Fn(e);qi(i);let s=null;for(let l=0;s==null&&l<i.length;++l){let u=Nn(o);s=ll(i[l],u,a)}return s}function Mn(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 Fn(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;A(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 f=Me([a,c.relativePath]),m=r.concat(c);i.children&&i.children.length>0&&(A(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),Fn(i.children,t,m,f,l)),!(i.path==null&&!i.index)&&t.push({path:f,score:ol(f,i.index),routesMeta:m})};return e.forEach((i,s)=>{if(i.path===""||!i.path?.includes("?"))o(i,s);else for(let l of kn(i.path))o(i,s,!0,l)}),t}function kn(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=kn(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 qi(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:il(t.routesMeta.map(a=>a.childrenIndex),r.routesMeta.map(a=>a.childrenIndex)))}var Zi=/^:[\w-]+$/,el=3,tl=2,rl=1,al=10,nl=-2,Wa=e=>e==="*";function ol(e,t){let r=e.split("/"),a=r.length;return r.some(Wa)&&(a+=nl),t&&(a+=tl),r.filter(n=>!Wa(n)).reduce((n,o)=>n+(Zi.test(o)?el:o===""?rl:al),a)}function il(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 ll(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)||"/",f=_t({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},c),m=l.route;if(!f&&u&&r&&!a[a.length-1].route.index&&(f=_t({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},c)),!f)return null;Object.assign(n,f.params),i.push({params:n,pathname:Me([o,f.pathname]),pathnameBase:dl(Me([o,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(o=Me([o,f.pathnameBase]))}return i}function bc(e,t={}){let r=e;r.endsWith("*")&&r!=="*"&&!r.endsWith("/*")&&(X(!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[,f,m]=c;let p=t[f];return A(m==="?"||p!=null,`Missing ":${f}" param`),encodeURIComponent(n(p))}return i.replace(/\?$/g,"")}).filter(i=>!!i);return a+o.join("/")}function _t(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,a]=On(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:f},m)=>{if(c==="*"){let h=s[m]||"";i=o.slice(0,o.length-h.length).replace(/(.)\/+$/,"$1")}const p=s[m];return f&&!p?u[c]=void 0:u[c]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:i,pattern:e}}function On(e,t=!1,r=!0){X(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 Nn(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return X(!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 sl({basename:e,pathname:t}){return t==="/"?e:Me([e,t])}function ul(e,t="/"){let{pathname:r,search:a="",hash:n=""}=typeof e=="string"?Pe(e):e;return{pathname:r?r.startsWith("/")?r:cl(r,t):t,search:fl(a),hash:hl(n)}}function cl(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 Pr(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 An(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function ir(e){let t=An(e);return t.map((r,a)=>a===t.length-1?r.pathname:r.pathnameBase)}function lr(e,t,r,a=!1){let n;typeof e=="string"?n=Pe(e):(n={...e},A(!n.pathname||!n.pathname.includes("?"),Pr("?","pathname","search",n)),A(!n.pathname||!n.pathname.includes("#"),Pr("#","pathname","hash",n)),A(!n.search||!n.search.includes("#"),Pr("#","search","hash",n)));let o=e===""||n.pathname==="",i=o?"/":n.pathname,s;if(i==null)s=r;else{let f=t.length-1;if(!a&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),f-=1;n.pathname=m.join("/")}s=f>=0?t[f]:"/"}let l=ul(n,s),u=i&&i!=="/"&&i.endsWith("/"),c=(o||i===".")&&r.endsWith("/");return!l.pathname.endsWith("/")&&(u||c)&&(l.pathname+="/"),l}var Me=e=>e.join("/").replace(/\/\/+/g,"/"),dl=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),fl=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,hl=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,ml=class{constructor(e,t){this.type="DataWithResponseInit",this.data=e,this.init=t||null}};function pl(e,t){return new ml(e,typeof t=="number"?{status:t}:t)}var sr=(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})},yl=(e,t)=>{let r=sr(e,t);return r.headers.set("X-Remix-Reload-Document","true"),r},vl=(e,t)=>{let r=sr(e,t);return r.headers.set("X-Remix-Replace","true"),r},pe=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 dt(e){return e.filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Ue=Symbol("Uninstrumented");function $n(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=rt(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=rt(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[Ue]??o,s=rt(r[n],i,(...l)=>Va(l[0]));s&&(s[Ue]=i,a[n]=s)}}),t.middleware&&t.middleware.length>0&&r.middleware.length>0&&(a.middleware=t.middleware.map(n=>{let o=n[Ue]??n,i=rt(r.middleware,o,(...s)=>Va(s[0]));return i?(i[Ue]=o,i):n})),a}function gl(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[Ue]??e.navigate,n=rt(r.navigate,a,(...o)=>{let[i,s]=o;return{to:typeof i=="number"||typeof i=="string"?i:i?he(i):".",...Ya(e,s??{})}});n&&(n[Ue]=a,e.navigate=n)}if(r.fetch.length>0){let a=e.fetch[Ue]??e.fetch,n=rt(r.fetch,a,(...o)=>{let[i,,s,l]=o;return{href:s??".",fetcherKey:i,...Ya(e,l??{})}});n&&(n[Ue]=a,e.fetch=n)}return e}function wl(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=rt(r.request,e,(...n)=>{let[o,i]=n;return{request:Hn(o),context:i!=null?jn(i):i}})),a}function rt(e,t,r){return e.length===0?null:async(...a)=>{let n=await In(e,r(...a),()=>t(...a),e.length-1);if(n.type==="error")throw n.value;return n.value}}async function In(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=In(e,t,r,a-1),o=await i,A(o,"Expected a result"),o.type==="error"&&o.value instanceof Error?{status:"error",error:o.value}:{status:"success",error:void 0});try{await n(s,t)}catch(l){console.error("An instrumentation function threw an error:",l)}i||await s(),await i}else try{o={type:"success",value:await r()}}catch(i){o={type:"error",value:i}}return o||{type:"error",value:new Error("No result assigned in instrumentation chain.")}}function Va(e){let{request:t,context:r,params:a,unstable_pattern:n}=e;return{request:Hn(t),params:{...a},unstable_pattern:n,context:jn(r)}}function Ya(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 Hn(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function jn(e){if(El(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var Rl=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function El(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")===Rl}var Un=["POST","PUT","PATCH","DELETE"],bl=new Set(Un),Sl=["GET",...Un],Cl=new Set(Sl),zn=new Set([301,302,303,307,308]),xl=new Set([307,308]),Kt={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Zr={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},tt={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},Pl=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ea=e=>Pl.test(e),Bn=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),Wn="remix-router-transitions",Vn=Symbol("ResetLoaderData");function ur(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";A(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let a=e.hydrationRouteProperties||[],n=e.mapRouteProperties||Bn,o=n;if(e.unstable_instrumentations){let v=e.unstable_instrumentations;o=b=>({...n(b),...$n(v.map(S=>S.route).filter(Boolean),b)})}let i={},s=Ve(e.routes,o,void 0,i),l,u=e.basename||"/";u.startsWith("/")||(u=`/${u}`);let c=e.dataStrategy||Fl,f={...e.future},m=null,p=new Set,h=null,g=null,y=null,w=e.hydrationData!=null,R=ge(s,e.history.location,u),C=!1,x=null,P;if(R==null&&!e.patchRoutesOnNavigation){let v=te(404,{pathname:e.history.location.pathname}),{matches:b,route:S}=ct(s);P=!0,R=b,x={[S.id]:v}}else if(R&&!e.hydrationData&&$t(R,s,e.history.location.pathname).active&&(R=null),R)if(R.some(v=>v.route.lazy))P=!1;else if(!R.some(v=>ta(v.route)))P=!0;else{let v=e.hydrationData?e.hydrationData.loaderData:null,b=e.hydrationData?e.hydrationData.errors:null;if(b){let S=R.findIndex(L=>b[L.route.id]!==void 0);P=R.slice(0,S+1).every(L=>!Ar(L.route,v,b))}else P=R.every(S=>!Ar(S.route,v,b))}else{P=!1,R=[];let v=$t(null,s,e.history.location.pathname);v.active&&v.matches&&(C=!0,R=v.matches)}let D,E={historyAction:e.history.action,location:e.history.location,matches:R,initialized:P,navigation:Kt,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||x,fetchers:new Map,blockers:new Map},F="POP",T=!1,M,N=!1,Y=new Map,G=null,B=!1,K=!1,le=new Set,J=new Map,be=0,ye=-1,De=new Map,ve=new Set,Se=new Map,Le=new Map,_e=new Set,Ke=new Map,Nt,Rt=null;function Ri(){if(m=e.history.listen(({action:v,location:b,delta:S})=>{if(Nt){Nt(),Nt=void 0;return}X(Ke.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 L=Oa({currentLocation:E.location,nextLocation:b,historyAction:v});if(L&&S!=null){let _=new Promise($=>{Nt=$});e.history.go(S*-1),At(L,{state:"blocked",location:b,proceed(){At(L,{state:"proceeding",proceed:void 0,reset:void 0,location:b}),_.then(()=>e.history.go(S))},reset(){let $=new Map(E.blockers);$.set(L,tt),se({blockers:$})}});return}return Xe(v,b)}),r){Hl(t,Y);let v=()=>jl(t,Y);t.addEventListener("pagehide",v),G=()=>t.removeEventListener("pagehide",v)}return E.initialized||Xe("POP",E.location,{initialHydration:!0}),D}function Ei(){m&&m(),G&&G(),p.clear(),M&&M.abort(),E.fetchers.forEach((v,b)=>br(b)),E.blockers.forEach((v,b)=>ka(b))}function bi(v){return p.add(v),()=>p.delete(v)}function se(v,b={}){v.matches&&(v.matches=v.matches.map(_=>{let $=i[_.route.id],H=_.route;return H.element!==$.element||H.errorElement!==$.errorElement||H.hydrateFallbackElement!==$.hydrateFallbackElement?{..._,route:$}:_})),E={...E,...v};let S=[],L=[];E.fetchers.forEach((_,$)=>{_.state==="idle"&&(_e.has($)?S.push($):L.push($))}),_e.forEach(_=>{!E.fetchers.has(_)&&!J.has(_)&&S.push(_)}),[...p].forEach(_=>_(E,{deletedFetchers:S,viewTransitionOpts:b.viewTransitionOpts,flushSync:b.flushSync===!0})),S.forEach(_=>br(_)),L.forEach(_=>E.fetchers.delete(_))}function it(v,b,{flushSync:S}={}){let L=E.actionData!=null&&E.navigation.formMethod!=null&&de(E.navigation.formMethod)&&E.navigation.state==="loading"&&v.state?._isRedirect!==!0,_;b.actionData?Object.keys(b.actionData).length>0?_=b.actionData:_=null:L?_=E.actionData:_=null;let $=b.loaderData?nn(E.loaderData,b.loaderData,b.matches||[],b.errors):E.loaderData,H=E.blockers;H.size>0&&(H=new Map(H),H.forEach((j,I)=>H.set(I,tt)));let O=B?!1:Aa(v,b.matches||E.matches),U=T===!0||E.navigation.formMethod!=null&&de(E.navigation.formMethod)&&v.state?._isRedirect!==!0;l&&(s=l,l=void 0),B||F==="POP"||(F==="PUSH"?e.history.push(v,v.state):F==="REPLACE"&&e.history.replace(v,v.state));let z;if(F==="POP"){let j=Y.get(E.location.pathname);j&&j.has(v.pathname)?z={currentLocation:E.location,nextLocation:v}:Y.has(v.pathname)&&(z={currentLocation:v,nextLocation:E.location})}else if(N){let j=Y.get(E.location.pathname);j?j.add(v.pathname):(j=new Set([v.pathname]),Y.set(E.location.pathname,j)),z={currentLocation:E.location,nextLocation:v}}se({...b,actionData:_,loaderData:$,historyAction:F,location:v,initialized:!0,navigation:Kt,revalidation:"idle",restoreScrollPosition:O,preventScrollReset:U,blockers:H},{viewTransitionOpts:z,flushSync:S===!0}),F="POP",T=!1,N=!1,B=!1,K=!1,Rt?.resolve(),Rt=null}async function Pa(v,b){if(typeof v=="number"){e.history.go(v);return}let S=Nr(E.location,E.matches,u,v,b?.fromRouteId,b?.relative),{path:L,submission:_,error:$}=Ka(!1,S,b),H=E.location,O=$e(E.location,L,b&&b.state);O={...O,...e.history.encodeLocation(O)};let U=b&&b.replace!=null?b.replace:void 0,z="PUSH";U===!0?z="REPLACE":U===!1||_!=null&&de(_.formMethod)&&_.formAction===E.location.pathname+E.location.search&&(z="REPLACE");let j=b&&"preventScrollReset"in b?b.preventScrollReset===!0:void 0,I=(b&&b.flushSync)===!0,W=Oa({currentLocation:H,nextLocation:O,historyAction:z});if(W){At(W,{state:"blocked",location:O,proceed(){At(W,{state:"proceeding",proceed:void 0,reset:void 0,location:O}),Pa(v,b)},reset(){let q=new Map(E.blockers);q.set(W,tt),se({blockers:q})}});return}await Xe(z,O,{submission:_,pendingError:$,preventScrollReset:j,replace:b&&b.replace,enableViewTransition:b&&b.viewTransition,flushSync:I})}function Si(){Rt||(Rt=Ul()),Er(),se({revalidation:"loading"});let v=Rt.promise;return E.navigation.state==="submitting"?v:E.navigation.state==="idle"?(Xe(E.historyAction,E.location,{startUninterruptedRevalidation:!0}),v):(Xe(F||E.historyAction,E.navigation.location,{overrideNavigation:E.navigation,enableViewTransition:N===!0}),v)}async function Xe(v,b,S){M&&M.abort(),M=null,F=v,B=(S&&S.startUninterruptedRevalidation)===!0,Oi(E.location,E.matches),T=(S&&S.preventScrollReset)===!0,N=(S&&S.enableViewTransition)===!0;let L=l||s,_=S&&S.overrideNavigation,$=S?.initialHydration&&E.matches&&E.matches.length>0&&!C?E.matches:ge(L,b,u),H=(S&&S.flushSync)===!0;if($&&E.initialized&&!K&&Ol(E.location,b)&&!(S&&S.submission&&de(S.submission.formMethod))){it(b,{matches:$},{flushSync:H});return}let O=$t($,L,b.pathname);if(O.active&&O.matches&&($=O.matches),!$){let{error:me,notFoundMatches:Z,route:Q}=Sr(b.pathname);it(b,{matches:Z,loaderData:{},errors:{[Q.id]:me}},{flushSync:H});return}M=new AbortController;let U=ut(e.history,b,M.signal,S&&S.submission),z=e.getContext?await e.getContext():new Ae,j;if(S&&S.pendingError)j=[xe($).route.id,{type:"error",error:S.pendingError}];else if(S&&S.submission&&de(S.submission.formMethod)){let me=await Ci(U,b,S.submission,$,z,O.active,S&&S.initialHydration===!0,{replace:S.replace,flushSync:H});if(me.shortCircuited)return;if(me.pendingActionResult){let[Z,Q]=me.pendingActionResult;if(ie(Q)&&re(Q.error)&&Q.error.status===404){M=null,it(b,{matches:me.matches,loaderData:{},errors:{[Z]:Q.error}});return}}$=me.matches||$,j=me.pendingActionResult,_=Dr(b,S.submission),H=!1,O.active=!1,U=ut(e.history,U.url,U.signal)}let{shortCircuited:I,matches:W,loaderData:q,errors:oe}=await xi(U,b,$,z,O.active,_,S&&S.submission,S&&S.fetcherSubmission,S&&S.replace,S&&S.initialHydration===!0,H,j);I||(M=null,it(b,{matches:W||$,...on(j),loaderData:q,errors:oe}))}async function Ci(v,b,S,L,_,$,H,O={}){Er();let U=$l(b,S);if(se({navigation:U},{flushSync:O.flushSync===!0}),$){let I=await It(L,b.pathname,v.signal);if(I.type==="aborted")return{shortCircuited:!0};if(I.type==="error"){if(I.partialMatches.length===0){let{matches:q,route:oe}=ct(s);return{matches:q,pendingActionResult:[oe.id,{type:"error",error:I.error}]}}let W=xe(I.partialMatches).route.id;return{matches:I.partialMatches,pendingActionResult:[W,{type:"error",error:I.error}]}}else if(I.matches)L=I.matches;else{let{notFoundMatches:W,error:q,route:oe}=Sr(b.pathname);return{matches:W,pendingActionResult:[oe.id,{type:"error",error:q}]}}}let z,j=ft(L,b);if(!j.route.action&&!j.route.lazy)z={type:"error",error:te(405,{method:v.method,pathname:b.pathname,routeId:j.route.id})};else{let I=Be(o,i,v,L,j,H?[]:a,_),W=await Et(v,I,_,null);if(z=W[j.route.id],!z){for(let q of L)if(W[q.route.id]){z=W[q.route.id];break}}if(v.signal.aborted)return{shortCircuited:!0}}if(ze(z)){let I;return O&&O.replace!=null?I=O.replace:I=tn(z.response.headers.get("Location"),new URL(v.url),u)===E.location.pathname+E.location.search,await Ge(v,z,!0,{submission:S,replace:I}),{shortCircuited:!0}}if(ie(z)){let I=xe(L,j.route.id);return(O&&O.replace)!==!0&&(F="PUSH"),{matches:L,pendingActionResult:[I.route.id,z,j.route.id]}}return{matches:L,pendingActionResult:[j.route.id,z]}}async function xi(v,b,S,L,_,$,H,O,U,z,j,I){let W=$||Dr(b,H),q=H||O||ln(W),oe=!B&&!z;if(_){if(oe){let ue=Da(I);se({navigation:W,...ue!==void 0?{actionData:ue}:{}},{flushSync:j})}let V=await It(S,b.pathname,v.signal);if(V.type==="aborted")return{shortCircuited:!0};if(V.type==="error"){if(V.partialMatches.length===0){let{matches:lt,route:Ze}=ct(s);return{matches:lt,loaderData:{},errors:{[Ze.id]:V.error}}}let ue=xe(V.partialMatches).route.id;return{matches:V.partialMatches,loaderData:{},errors:{[ue]:V.error}}}else if(V.matches)S=V.matches;else{let{error:ue,notFoundMatches:lt,route:Ze}=Sr(b.pathname);return{matches:lt,loaderData:{},errors:{[Ze.id]:ue}}}}let me=l||s,{dsMatches:Z,revalidatingFetchers:Q}=Xa(v,L,o,i,e.history,E,S,q,b,z?[]:a,z===!0,K,le,_e,Se,ve,me,u,e.patchRoutesOnNavigation!=null,I);if(ye=++be,!e.dataStrategy&&!Z.some(V=>V.shouldLoad)&&!Z.some(V=>V.route.middleware&&V.route.middleware.length>0)&&Q.length===0){let V=Ma();return it(b,{matches:S,loaderData:{},errors:I&&ie(I[1])?{[I[0]]:I[1].error}:null,...on(I),...V?{fetchers:new Map(E.fetchers)}:{}},{flushSync:j}),{shortCircuited:!0}}if(oe){let V={};if(!_){V.navigation=W;let ue=Da(I);ue!==void 0&&(V.actionData=ue)}Q.length>0&&(V.fetchers=Pi(Q)),se(V,{flushSync:j})}Q.forEach(V=>{Oe(V.key),V.controller&&J.set(V.key,V.controller)});let Qe=()=>Q.forEach(V=>Oe(V.key));M&&M.signal.addEventListener("abort",Qe);let{loaderResults:bt,fetcherResults:je}=await La(Z,Q,v,L);if(v.signal.aborted)return{shortCircuited:!0};M&&M.signal.removeEventListener("abort",Qe),Q.forEach(V=>J.delete(V.key));let Te=zt(bt);if(Te)return await Ge(v,Te.result,!0,{replace:U}),{shortCircuited:!0};if(Te=zt(je),Te)return ve.add(Te.key),await Ge(v,Te.result,!0,{replace:U}),{shortCircuited:!0};let{loaderData:Cr,errors:St}=an(E,S,bt,I,Q,je);z&&E.errors&&(St={...E.errors,...St});let qe=Ma(),Ht=Fa(ye),jt=qe||Ht||Q.length>0;return{matches:S,loaderData:Cr,errors:St,...jt?{fetchers:new Map(E.fetchers)}:{}}}function Da(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 Pi(v){return v.forEach(b=>{let S=E.fetchers.get(b.key),L=xt(void 0,S?S.data:void 0);E.fetchers.set(b.key,L)}),new Map(E.fetchers)}async function Di(v,b,S,L){Oe(v);let _=(L&&L.flushSync)===!0,$=l||s,H=Nr(E.location,E.matches,u,S,b,L?.relative),O=ge($,H,u),U=$t(O,$,H);if(U.active&&U.matches&&(O=U.matches),!O){ke(v,b,te(404,{pathname:H}),{flushSync:_});return}let{path:z,submission:j,error:I}=Ka(!0,H,L);if(I){ke(v,b,I,{flushSync:_});return}let W=e.getContext?await e.getContext():new Ae,q=(L&&L.preventScrollReset)===!0;if(j&&de(j.formMethod)){await Li(v,b,z,O,W,U.active,_,q,j);return}Se.set(v,{routeId:b,path:z}),await _i(v,b,z,O,W,U.active,_,q,j)}async function Li(v,b,S,L,_,$,H,O,U){Er(),Se.delete(v);let z=E.fetchers.get(v);Fe(v,Il(U,z),{flushSync:H});let j=new AbortController,I=ut(e.history,S,j.signal,U);if($){let ae=await It(L,new URL(I.url).pathname,I.signal,v);if(ae.type==="aborted")return;if(ae.type==="error"){ke(v,b,ae.error,{flushSync:H});return}else if(ae.matches)L=ae.matches;else{ke(v,b,te(404,{pathname:S}),{flushSync:H});return}}let W=ft(L,S);if(!W.route.action&&!W.route.lazy){let ae=te(405,{method:U.formMethod,pathname:S,routeId:b});ke(v,b,ae,{flushSync:H});return}J.set(v,j);let q=be,oe=Be(o,i,I,L,W,a,_),Z=(await Et(I,oe,_,v))[W.route.id];if(I.signal.aborted){J.get(v)===j&&J.delete(v);return}if(_e.has(v)){if(ze(Z)||ie(Z)){Fe(v,Ne(void 0));return}}else{if(ze(Z))if(J.delete(v),ye>q){Fe(v,Ne(void 0));return}else return ve.add(v),Fe(v,xt(U)),Ge(I,Z,!1,{fetcherSubmission:U,preventScrollReset:O});if(ie(Z)){ke(v,b,Z.error);return}}let Q=E.navigation.location||E.location,Qe=ut(e.history,Q,j.signal),bt=l||s,je=E.navigation.state!=="idle"?ge(bt,E.navigation.location,u):E.matches;A(je,"Didn't find any matches after fetcher action");let Te=++be;De.set(v,Te);let Cr=xt(U,Z.data);E.fetchers.set(v,Cr);let{dsMatches:St,revalidatingFetchers:qe}=Xa(Qe,_,o,i,e.history,E,je,U,Q,a,!1,K,le,_e,Se,ve,bt,u,e.patchRoutesOnNavigation!=null,[W.route.id,Z]);qe.filter(ae=>ae.key!==v).forEach(ae=>{let Ut=ae.key,$a=E.fetchers.get(Ut),$i=xt(void 0,$a?$a.data:void 0);E.fetchers.set(Ut,$i),Oe(Ut),ae.controller&&J.set(Ut,ae.controller)}),se({fetchers:new Map(E.fetchers)});let Ht=()=>qe.forEach(ae=>Oe(ae.key));j.signal.addEventListener("abort",Ht);let{loaderResults:jt,fetcherResults:V}=await La(St,qe,Qe,_);if(j.signal.aborted)return;if(j.signal.removeEventListener("abort",Ht),De.delete(v),J.delete(v),qe.forEach(ae=>J.delete(ae.key)),E.fetchers.has(v)){let ae=Ne(Z.data);E.fetchers.set(v,ae)}let ue=zt(jt);if(ue)return Ge(Qe,ue.result,!1,{preventScrollReset:O});if(ue=zt(V),ue)return ve.add(ue.key),Ge(Qe,ue.result,!1,{preventScrollReset:O});let{loaderData:lt,errors:Ze}=an(E,je,jt,void 0,qe,V);Fa(Te),E.navigation.state==="loading"&&Te>ye?(A(F,"Expected pending action"),M&&M.abort(),it(E.navigation.location,{matches:je,loaderData:lt,errors:Ze,fetchers:new Map(E.fetchers)})):(se({errors:Ze,loaderData:nn(E.loaderData,lt,je,Ze),fetchers:new Map(E.fetchers)}),K=!1)}async function _i(v,b,S,L,_,$,H,O,U){let z=E.fetchers.get(v);Fe(v,xt(U,z?z.data:void 0),{flushSync:H});let j=new AbortController,I=ut(e.history,S,j.signal);if($){let Q=await It(L,new URL(I.url).pathname,I.signal,v);if(Q.type==="aborted")return;if(Q.type==="error"){ke(v,b,Q.error,{flushSync:H});return}else if(Q.matches)L=Q.matches;else{ke(v,b,te(404,{pathname:S}),{flushSync:H});return}}let W=ft(L,S);J.set(v,j);let q=be,oe=Be(o,i,I,L,W,a,_),Z=(await Et(I,oe,_,v))[W.route.id];if(J.get(v)===j&&J.delete(v),!I.signal.aborted){if(_e.has(v)){Fe(v,Ne(void 0));return}if(ze(Z))if(ye>q){Fe(v,Ne(void 0));return}else{ve.add(v),await Ge(I,Z,!1,{preventScrollReset:O});return}if(ie(Z)){ke(v,b,Z.error);return}Fe(v,Ne(Z.data))}}async function Ge(v,b,S,{submission:L,fetcherSubmission:_,preventScrollReset:$,replace:H}={}){b.response.headers.has("X-Remix-Revalidate")&&(K=!0);let O=b.response.headers.get("Location");A(O,"Expected a Location header on the redirect Response"),O=tn(O,new URL(v.url),u);let U=$e(E.location,O,{_isRedirect:!0});if(r){let oe=!1;if(b.response.headers.has("X-Remix-Reload-Document"))oe=!0;else if(ea(O)){const me=Tn(O,!0);oe=me.origin!==t.location.origin||ne(me.pathname,u)==null}if(oe){H?t.location.replace(O):t.location.assign(O);return}}M=null;let z=H===!0||b.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:j,formAction:I,formEncType:W}=E.navigation;!L&&!_&&j&&I&&W&&(L=ln(E.navigation));let q=L||_;if(xl.has(b.response.status)&&q&&de(q.formMethod))await Xe(z,U,{submission:{...q,formAction:O},preventScrollReset:$||T,enableViewTransition:S?N:void 0});else{let oe=Dr(U,L);await Xe(z,U,{overrideNavigation:oe,fetcherSubmission:_,preventScrollReset:$||T,enableViewTransition:S?N:void 0})}}async function Et(v,b,S,L){let _,$={};try{_=await Zn(c,v,b,L,S,!1)}catch(H){return b.filter(O=>O.shouldLoad).forEach(O=>{$[O.route.id]={type:"error",error:H}}),$}if(v.signal.aborted)return $;for(let[H,O]of Object.entries(_))if(io(O)){let U=O.result;$[H]={type:"redirect",response:ro(U,v,H,b,u)}}else $[H]=await to(O);return $}async function La(v,b,S,L){let _=Et(S,v,L,null),$=Promise.all(b.map(async U=>{if(U.matches&&U.match&&U.request&&U.controller){let j=(await Et(U.request,U.matches,L,U.key))[U.match.route.id];return{[U.key]:j}}else return Promise.resolve({[U.key]:{type:"error",error:te(404,{pathname:U.path})}})})),H=await _,O=(await $).reduce((U,z)=>Object.assign(U,z),{});return{loaderResults:H,fetcherResults:O}}function Er(){K=!0,Se.forEach((v,b)=>{J.has(b)&&le.add(b),Oe(b)})}function Fe(v,b,S={}){E.fetchers.set(v,b),se({fetchers:new Map(E.fetchers)},{flushSync:(S&&S.flushSync)===!0})}function ke(v,b,S,L={}){let _=xe(E.matches,b);br(v),se({errors:{[_.route.id]:S},fetchers:new Map(E.fetchers)},{flushSync:(L&&L.flushSync)===!0})}function _a(v){return Le.set(v,(Le.get(v)||0)+1),_e.has(v)&&_e.delete(v),E.fetchers.get(v)||Zr}function Ti(v,b){Oe(v,b?.reason),Fe(v,Ne(null))}function br(v){let b=E.fetchers.get(v);J.has(v)&&!(b&&b.state==="loading"&&De.has(v))&&Oe(v),Se.delete(v),De.delete(v),ve.delete(v),_e.delete(v),le.delete(v),E.fetchers.delete(v)}function Mi(v){let b=(Le.get(v)||0)-1;b<=0?(Le.delete(v),_e.add(v)):Le.set(v,b),se({fetchers:new Map(E.fetchers)})}function Oe(v,b){let S=J.get(v);S&&(S.abort(b),J.delete(v))}function Ta(v){for(let b of v){let S=_a(b),L=Ne(S.data);E.fetchers.set(b,L)}}function Ma(){let v=[],b=!1;for(let S of ve){let L=E.fetchers.get(S);A(L,`Expected fetcher: ${S}`),L.state==="loading"&&(ve.delete(S),v.push(S),b=!0)}return Ta(v),b}function Fa(v){let b=[];for(let[S,L]of De)if(L<v){let _=E.fetchers.get(S);A(_,`Expected fetcher: ${S}`),_.state==="loading"&&(Oe(S),De.delete(S),b.push(S))}return Ta(b),b.length>0}function Fi(v,b){let S=E.blockers.get(v)||tt;return Ke.get(v)!==b&&Ke.set(v,b),S}function ka(v){E.blockers.delete(v),Ke.delete(v)}function At(v,b){let S=E.blockers.get(v)||tt;A(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 L=new Map(E.blockers);L.set(v,b),se({blockers:L})}function Oa({currentLocation:v,nextLocation:b,historyAction:S}){if(Ke.size===0)return;Ke.size>1&&X(!1,"A router only supports one blocker at a time");let L=Array.from(Ke.entries()),[_,$]=L[L.length-1],H=E.blockers.get(_);if(!(H&&H.state==="proceeding")&&$({currentLocation:v,nextLocation:b,historyAction:S}))return _}function Sr(v){let b=te(404,{pathname:v}),S=l||s,{matches:L,route:_}=ct(S);return{notFoundMatches:L,route:_,error:b}}function ki(v,b,S){if(h=v,y=b,g=S||null,!w&&E.navigation===Kt){w=!0;let L=Aa(E.location,E.matches);L!=null&&se({restoreScrollPosition:L})}return()=>{h=null,y=null,g=null}}function Na(v,b){return g&&g(v,b.map(L=>Mn(L,E.loaderData)))||v.key}function Oi(v,b){if(h&&y){let S=Na(v,b);h[S]=y()}}function Aa(v,b){if(h){let S=Na(v,b),L=h[S];if(typeof L=="number")return L}return null}function $t(v,b,S){if(e.patchRoutesOnNavigation)if(v){if(Object.keys(v[0].params).length>0)return{active:!0,matches:Jt(b,S,u,!0)}}else return{active:!0,matches:Jt(b,S,u,!0)||[]};return{active:!1,matches:null}}async function It(v,b,S,L){if(!e.patchRoutesOnNavigation)return{type:"success",matches:v};let _=v;for(;;){let $=l==null,H=l||s,O=i;try{await e.patchRoutesOnNavigation({signal:S,path:b,matches:_,fetcherKey:L,patch:(j,I)=>{S.aborted||Ga(j,I,H,O,o,!1)}})}catch(j){return{type:"error",error:j,partialMatches:_}}finally{$&&!S.aborted&&(s=[...s])}if(S.aborted)return{type:"aborted"};let U=ge(H,b,u);if(U)return{type:"success",matches:U};let z=Jt(H,b,u,!0);if(!z||_.length===z.length&&_.every((j,I)=>j.route.id===z[I].route.id))return{type:"success",matches:null};_=z}}function Ni(v){i={},l=Ve(v,o,void 0,i)}function Ai(v,b,S=!1){let L=l==null;Ga(v,b,l||s,i,o,S),L&&(s=[...s],se({}))}return D={get basename(){return u},get future(){return f},get state(){return E},get routes(){return s},get window(){return t},initialize:Ri,subscribe:bi,enableScrollRestoration:ki,navigate:Pa,fetch:Di,revalidate:Si,createHref:v=>e.history.createHref(v),encodeLocation:v=>e.history.encodeLocation(v),getFetcher:_a,resetFetcher:Ti,deleteFetcher:Mi,dispose:Ei,getBlocker:Fi,deleteBlocker:ka,patchRoutes:Ai,_internalFetchControllers:J,_internalSetRoutes:Ni,_internalSetStateDoNotUseOrYouWillBreakYourApp(v){se(v)}},e.unstable_instrumentations&&(D=gl(D,e.unstable_instrumentations.map(v=>v.router).filter(Boolean))),D}function Yn(e,t){A(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let r={},a=(t?t.basename:null)||"/",n=t?.mapRouteProperties||Bn,o=n;if(t?.unstable_instrumentations){let p=t.unstable_instrumentations;o=h=>({...n(h),...$n(p.map(g=>g.route).filter(Boolean),h)})}let i=Ve(e,o,void 0,r);async function s(p,{requestContext:h,filterMatchesToLoad:g,skipLoaderErrorBubbling:y,skipRevalidation:w,dataStrategy:R,generateMiddlewareResponse:C}={}){let x=new URL(p.url),P=p.method,D=$e("",he(x),null,"default"),E=ge(i,D,a);if(h=h??new Ae,!jr(P)&&P!=="HEAD"){let T=te(405,{method:P}),{matches:M,route:N}=ct(i),Y={basename:a,location:D,matches:M,loaderData:{},actionData:null,errors:{[N.id]:T},statusCode:T.status,loaderHeaders:{},actionHeaders:{}};return C?C(()=>Promise.resolve(Y)):Y}else if(!E){let T=te(404,{pathname:D.pathname}),{matches:M,route:N}=ct(i),Y={basename:a,location:D,matches:M,loaderData:{},actionData:null,errors:{[N.id]:T},statusCode:T.status,loaderHeaders:{},actionHeaders:{}};return C?C(()=>Promise.resolve(Y)):Y}if(C){A(h instanceof Ae,"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`");try{await Za(E,r,o);let T,M=await en({request:p,unstable_pattern:dt(E.map(N=>N.route.path)),matches:E,params:E[0].params,context:h},async()=>await C(async(Y,G={})=>{let B=await u(Y,D,E,h,R||null,y===!0,null,"filterMatchesToLoad"in G?G.filterMatchesToLoad??null:g??null,w===!0);return ee(B)?B:(T={location:D,basename:a,...B},T)}),async(N,Y)=>{if(er(N))return N;if(ee(N))try{N=new pe(N.status,N.statusText,await eo(N))}catch(G){N=G}if(We(N)&&(N=Nl(N)),T){Y in T.loaderData&&(T.loaderData[Y]=void 0);let G=Jn(i,T,N,y?Y:xe(E,Y).route.id);return C(()=>Promise.resolve(G))}else{let G=y?Y:xe(E,E.find(K=>K.route.id===Y||K.route.loader)?.route.id||Y).route.id,B={matches:E,location:D,basename:a,loaderData:{},actionData:null,errors:{[G]:N},statusCode:re(N)?N.status:500,actionHeaders:{},loaderHeaders:{}};return C(()=>Promise.resolve(B))}});return A(ee(M),"Expected a response in query()"),M}catch(T){if(ee(T))return T;throw T}}let F=await u(p,D,E,h,R||null,y===!0,null,g||null,w===!0);return ee(F)?F:{location:D,basename:a,...F}}async function l(p,{routeId:h,requestContext:g,dataStrategy:y,generateMiddlewareResponse:w}={}){let R=new URL(p.url),C=p.method,x=$e("",he(R),null,"default"),P=ge(i,x,a);if(g=g??new Ae,!jr(C)&&C!=="HEAD"&&C!=="OPTIONS")throw te(405,{method:C});if(!P)throw te(404,{pathname:x.pathname});let D=h?P.find(T=>T.route.id===h):ft(P,x);if(h&&!D)throw te(403,{pathname:x.pathname,routeId:h});if(!D)throw te(404,{pathname:x.pathname});if(w)return A(g instanceof Ae,"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"),await Za(P,r,o),await en({request:p,unstable_pattern:dt(P.map(M=>M.route.path)),matches:P,params:P[0].params,context:g},async()=>await w(async N=>{let Y=await u(N,x,P,g,y||null,!1,D,null,!1),G=F(Y);return ee(G)?G:typeof G=="string"?new Response(G):Response.json(G)}),M=>{if(We(M))return Promise.resolve(Hr(M));if(ee(M))return Promise.resolve(M);throw M});let E=await u(p,x,P,g,y||null,!1,D,null,!1);return F(E);function F(T){if(ee(T))return T;let M=T.errors?Object.values(T.errors)[0]:void 0;if(M!==void 0)throw M;if(T.actionData)return Object.values(T.actionData)[0];if(T.loaderData)return Object.values(T.loaderData)[0]}}async function u(p,h,g,y,w,R,C,x,P){A(p.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(de(p.method))return await c(p,g,C||ft(g,h),y,w,R,C!=null,x,P);let D=await f(p,g,y,w,R,C,x);return ee(D)?D:{...D,actionData:null,actionHeaders:{}}}catch(D){if(oo(D)&&ee(D.result)){if(D.type==="error")throw D.result;return D.result}if(er(D))return D;throw D}}async function c(p,h,g,y,w,R,C,x,P){let D;if(!g.route.action&&!g.route.lazy){let T=te(405,{method:p.method,pathname:new URL(p.url).pathname,routeId:g.route.id});if(C)throw T;D={type:"error",error:T}}else{let T=Be(o,r,p,h,g,[],y);D=(await m(p,T,C,y,w))[g.route.id],p.signal.aborted&&Ja(p,C)}if(ze(D))throw new Response(null,{status:D.response.status,headers:{Location:D.response.headers.get("Location")}});if(C){if(ie(D))throw D.error;return{matches:[g],loaderData:{},actionData:{[g.route.id]:D.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(P)if(ie(D)){let T=R?g:xe(h,g.route.id);return{statusCode:re(D.error)?D.error.status:D.statusCode!=null?D.statusCode:500,actionData:null,actionHeaders:{...D.headers?{[g.route.id]:D.headers}:{}},matches:h,loaderData:{},errors:{[T.route.id]:D.error},loaderHeaders:{}}}else return{actionData:{[g.route.id]:D.data},actionHeaders:D.headers?{[g.route.id]:D.headers}:{},matches:h,loaderData:{},errors:null,statusCode:D.statusCode||200,loaderHeaders:{}};let E=new Request(p.url,{headers:p.headers,redirect:p.redirect,signal:p.signal});if(ie(D)){let T=R?g:xe(h,g.route.id);return{...await f(E,h,y,w,R,null,x,[T.route.id,D]),statusCode:re(D.error)?D.error.status:D.statusCode!=null?D.statusCode:500,actionData:null,actionHeaders:{...D.headers?{[g.route.id]:D.headers}:{}}}}return{...await f(E,h,y,w,R,null,x),actionData:{[g.route.id]:D.data},...D.statusCode?{statusCode:D.statusCode}:{},actionHeaders:D.headers?{[g.route.id]:D.headers}:{}}}async function f(p,h,g,y,w,R,C,x){let P=R!=null;if(P&&!R?.route.loader&&!R?.route.lazy)throw te(400,{method:p.method,pathname:new URL(p.url).pathname,routeId:R?.route.id});let D;if(R)D=Be(o,r,p,h,R,[],g);else{let T=x&&ie(x[1])?h.findIndex(N=>N.route.id===x[0])-1:void 0,M=dt(h.map(N=>N.route.path));D=h.map((N,Y)=>T!=null&&Y>T?Tt(o,r,p,M,N,[],g,!1):Tt(o,r,p,M,N,[],g,(N.route.loader||N.route.lazy)!=null&&(!C||C(N))))}if(!y&&!D.some(T=>T.shouldLoad))return{matches:h,loaderData:{},errors:x&&ie(x[1])?{[x[0]]:x[1].error}:null,statusCode:200,loaderHeaders:{}};let E=await m(p,D,P,g,y);return p.signal.aborted&&Ja(p,P),{...ao(h,E,x,!0,w),matches:h}}async function m(p,h,g,y,w){let R=await Zn(w||$r,p,h,null,y,!0),C={};return await Promise.all(h.map(async x=>{if(!(x.route.id in R))return;let P=R[x.route.id];if(io(P)){let D=P.result;throw ro(D,p,x.route.id,h,a)}if(g){if(ee(P.result))throw P;if(We(P.result))throw Hr(P.result)}C[x.route.id]=await to(P)})),C}return{dataRoutes:i,query:s,queryRoute:l}}function Jn(e,t,r,a){let n=a||t._deepestRenderedBoundaryId||e[0].id;return{...t,statusCode:re(r)?r.status:500,errors:{[n]:r}}}function Ja(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 Dl(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function Nr(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=lr(a||".",ir(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=aa(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),f=c.getAll("index");c.delete("index"),f.filter(p=>p).forEach(p=>c.append("index",p));let m=c.toString();l.search=m?`?${m}`:""}}return r!=="/"&&(l.pathname=sl({basename:r,pathname:l.pathname})),he(l)}function Ka(e,t,r){if(!r||!Dl(r))return{path:t};if(r.formMethod&&!jr(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=no(t);if(r.body!==void 0){if(r.formEncType==="text/plain"){if(!de(o))return a();let f=typeof r.body=="string"?r.body:r.body instanceof FormData||r.body instanceof URLSearchParams?Array.from(r.body.entries()).reduce((m,[p,h])=>`${m}${p}=${h}
|
|
1
|
+
import{r as d,R as ce,b as Ii,c as Hi}from"./index-Bcizt1mg.js";var Ct={},Ia;function ji(){if(Ia)return Ct;Ia=1,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.parse=i,Ct.serialize=u;const e=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,t=/^[\u0021-\u003A\u003C-\u007E]*$/,r=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,a=/^[\u0020-\u003A\u003D-\u007E]*$/,n=Object.prototype.toString,o=(()=>{const m=function(){};return m.prototype=Object.create(null),m})();function i(m,p){const h=new o,g=m.length;if(g<2)return h;const y=p?.decode||c;let w=0;do{const R=m.indexOf("=",w);if(R===-1)break;const C=m.indexOf(";",w),x=C===-1?g:C;if(R>x){w=m.lastIndexOf(";",R-1)+1;continue}const P=s(m,w,R),D=l(m,R,P),E=m.slice(P,D);if(h[E]===void 0){let F=s(m,R+1,x),T=l(m,x,F);const M=y(m.slice(F,T));h[E]=M}w=x+1}while(w<g);return h}function s(m,p,h){do{const g=m.charCodeAt(p);if(g!==32&&g!==9)return p}while(++p<h);return h}function l(m,p,h){for(;p>h;){const g=m.charCodeAt(--p);if(g!==32&&g!==9)return p+1}return h}function u(m,p,h){const g=h?.encode||encodeURIComponent;if(!e.test(m))throw new TypeError(`argument name is invalid: ${m}`);const y=g(p);if(!t.test(y))throw new TypeError(`argument val is invalid: ${p}`);let w=m+"="+y;if(!h)return w;if(h.maxAge!==void 0){if(!Number.isInteger(h.maxAge))throw new TypeError(`option maxAge is invalid: ${h.maxAge}`);w+="; Max-Age="+h.maxAge}if(h.domain){if(!r.test(h.domain))throw new TypeError(`option domain is invalid: ${h.domain}`);w+="; Domain="+h.domain}if(h.path){if(!a.test(h.path))throw new TypeError(`option path is invalid: ${h.path}`);w+="; Path="+h.path}if(h.expires){if(!f(h.expires)||!Number.isFinite(h.expires.valueOf()))throw new TypeError(`option expires is invalid: ${h.expires}`);w+="; Expires="+h.expires.toUTCString()}if(h.httpOnly&&(w+="; HttpOnly"),h.secure&&(w+="; Secure"),h.partitioned&&(w+="; Partitioned"),h.priority)switch(typeof h.priority=="string"?h.priority.toLowerCase():void 0){case"low":w+="; Priority=Low";break;case"medium":w+="; Priority=Medium";break;case"high":w+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${h.priority}`)}if(h.sameSite)switch(typeof h.sameSite=="string"?h.sameSite.toLowerCase():h.sameSite){case!0:case"strict":w+="; SameSite=Strict";break;case"lax":w+="; SameSite=Lax";break;case"none":w+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${h.sameSite}`)}return w}function c(m){if(m.indexOf("%")===-1)return m;try{return decodeURIComponent(m)}catch{return m}}function f(m){return n.call(m)==="[object Date]"}return Ct}var Ha=ji(),st={exports:{}},ja;function Ui(){if(ja)return st.exports;ja=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),f=c.shift(),m=o(f),p=m.name,h=m.value;if(u=u?Object.assign({},e,u):e,t(p))return null;try{h=u.decodeValues?decodeURIComponent(h):h}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=h,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 x=parseInt(C,10);Number.isNaN(x)||(g.maxAge=x)}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="",f=l.split("=");return f.length>1?(u=f.shift(),c=f.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 f=r();return l.filter(a).reduce(function(m,p){var h=n(p,u);return h&&!t(h.name)&&(m[h.name]=h),m},f)}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,f,m,p,h,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(f=c,g=!1;y();)if(m=l.charAt(c),m===","){for(p=c,c+=1,y(),h=c;c<l.length&&w();)c+=1;c<l.length&&l.charAt(c)==="="?(g=!0,c=h,u.push(l.substring(f,p)),f=c):c=p+1}else c+=1;(!g||c>=l.length)&&u.push(l.substring(f,l.length))}return u}return st.exports=i,st.exports.parse=i,st.exports.parseString=n,st.exports.splitCookiesString=s,st.exports}var zi=Ui();var Pn=e=>{throw TypeError(e)},Bi=(e,t,r)=>t.has(e)||Pn("Cannot "+r),xr=(e,t,r)=>(Bi(e,t,"read from private field"),r?r.call(e):t.get(e)),Wi=(e,t,r)=>t.has(e)?Pn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Vi=(e=>(e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE",e))(Vi||{}),Ua="popstate";function Dn(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:a=!1}=e,n;n=t.map((p,h)=>c(p,typeof p=="string"?null:p.state,h===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,h=null,g){let y=$e(n?u().pathname:"/",p,h,g);return X(y.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(p)}`),y}function f(p){return typeof p=="string"?p:he(p)}return{get index(){return o},get action(){return i},get location(){return u()},createHref:f,createURL(p){return new URL(f(p),"http://localhost")},encodeLocation(p){let h=typeof p=="string"?Pe(p):p;return{pathname:h.pathname||"",search:h.search||"",hash:h.hash||""}},push(p,h){i="PUSH";let g=c(p,h);o+=1,n.splice(o,n.length,g),a&&s&&s({action:i,location:g,delta:1})},replace(p,h){i="REPLACE";let g=c(p,h);n[o]=g,a&&s&&s({action:i,location:g,delta:0})},go(p){i="POP";let h=l(o+p),g=n[h];o=h,s&&s({action:i,location:g,delta:p})},listen(p){return s=p,()=>{s=null}}}}function qr(e={}){function t(a,n){let{pathname:o,search:i,hash:s}=a.location;return $e("",{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 _n(t,r,null,e)}function Ln(e={}){function t(n,o){let{pathname:i="/",search:s="",hash:l=""}=Pe(n.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),$e("",{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){X(n.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return _n(t,r,a,e)}function A(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function X(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Yi(){return Math.random().toString(36).substring(2,10)}function za(e,t){return{usr:e.state,key:e.key,idx:t}}function $e(e,t,r=null,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Pe(t):t,state:r,key:t&&t.key||a||Yi()}}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 Pe(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 _n(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 f(){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=$e(g.location,y,w);r&&r(R,y),u=c()+1;let C=za(R,u),x=g.createHref(R);try{i.pushState(C,"",x)}catch(P){if(P instanceof DOMException&&P.name==="DataCloneError")throw P;n.location.assign(x)}o&&l&&l({action:s,location:g.location,delta:1})}function p(y,w){s="REPLACE";let R=$e(g.location,y,w);r&&r(R,y),u=c();let C=za(R,u),x=g.createHref(R);i.replaceState(C,"",x),o&&l&&l({action:s,location:g.location,delta:0})}function h(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(Ua,f),l=y,()=>{n.removeEventListener(Ua,f),l=null}},createHref(y){return t(n,y)},createURL:h,encodeLocation(y){let w=h(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),A(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 Ec(e){return{defaultValue:e}}var Lt,Ae=class{constructor(e){if(Wi(this,Lt,new Map),e)for(let[t,r]of e)this.set(t,r)}get(e){if(xr(this,Lt).has(e))return xr(this,Lt).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){xr(this,Lt).set(e,t)}};Lt=new WeakMap;var Ji=new Set(["lazy","caseSensitive","path","id","index","children"]);function Ki(e){return Ji.has(e)}var Xi=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function Gi(e){return Xi.has(e)}function Qi(e){return e.index===!0}function Ve(e,t,r=[],a={},n=!1){return e.map((o,i)=>{let s=[...r,String(i)],l=typeof o.id=="string"?o.id:s.join("-");if(A(o.index!==!0||!o.children,"Cannot specify children on an index route"),A(n||!a[l],`Found a route id collision on id "${l}". Route id's must be globally unique within Data Router usages`),Qi(o)){let u={...o,id:l};return a[l]=Ba(u,t(u)),u}else{let u={...o,id:l,children:void 0};return a[l]=Ba(u,t(u)),o.children&&(u.children=Ve(o.children,t,s,a,n)),u}})}function Ba(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function ge(e,t,r="/"){return Jt(e,t,r,!1)}function Jt(e,t,r,a){let n=typeof t=="string"?Pe(t):t,o=ne(n.pathname||"/",r);if(o==null)return null;let i=Fn(e);qi(i);let s=null;for(let l=0;s==null&&l<i.length;++l){let u=Nn(o);s=ll(i[l],u,a)}return s}function Mn(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 Fn(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;A(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 f=Me([a,c.relativePath]),m=r.concat(c);i.children&&i.children.length>0&&(A(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),Fn(i.children,t,m,f,l)),!(i.path==null&&!i.index)&&t.push({path:f,score:ol(f,i.index),routesMeta:m})};return e.forEach((i,s)=>{if(i.path===""||!i.path?.includes("?"))o(i,s);else for(let l of kn(i.path))o(i,s,!0,l)}),t}function kn(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=kn(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 qi(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:il(t.routesMeta.map(a=>a.childrenIndex),r.routesMeta.map(a=>a.childrenIndex)))}var Zi=/^:[\w-]+$/,el=3,tl=2,rl=1,al=10,nl=-2,Wa=e=>e==="*";function ol(e,t){let r=e.split("/"),a=r.length;return r.some(Wa)&&(a+=nl),t&&(a+=tl),r.filter(n=>!Wa(n)).reduce((n,o)=>n+(Zi.test(o)?el:o===""?rl:al),a)}function il(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 ll(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)||"/",f=_t({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},c),m=l.route;if(!f&&u&&r&&!a[a.length-1].route.index&&(f=_t({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},c)),!f)return null;Object.assign(n,f.params),i.push({params:n,pathname:Me([o,f.pathname]),pathnameBase:dl(Me([o,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(o=Me([o,f.pathnameBase]))}return i}function bc(e,t={}){let r=e;r.endsWith("*")&&r!=="*"&&!r.endsWith("/*")&&(X(!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[,f,m]=c;let p=t[f];return A(m==="?"||p!=null,`Missing ":${f}" param`),encodeURIComponent(n(p))}return i.replace(/\?$/g,"")}).filter(i=>!!i);return a+o.join("/")}function _t(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,a]=On(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:f},m)=>{if(c==="*"){let h=s[m]||"";i=o.slice(0,o.length-h.length).replace(/(.)\/+$/,"$1")}const p=s[m];return f&&!p?u[c]=void 0:u[c]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:i,pattern:e}}function On(e,t=!1,r=!0){X(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 Nn(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return X(!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 sl({basename:e,pathname:t}){return t==="/"?e:Me([e,t])}function ul(e,t="/"){let{pathname:r,search:a="",hash:n=""}=typeof e=="string"?Pe(e):e;return{pathname:r?r.startsWith("/")?r:cl(r,t):t,search:fl(a),hash:hl(n)}}function cl(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 Pr(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 An(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function ir(e){let t=An(e);return t.map((r,a)=>a===t.length-1?r.pathname:r.pathnameBase)}function lr(e,t,r,a=!1){let n;typeof e=="string"?n=Pe(e):(n={...e},A(!n.pathname||!n.pathname.includes("?"),Pr("?","pathname","search",n)),A(!n.pathname||!n.pathname.includes("#"),Pr("#","pathname","hash",n)),A(!n.search||!n.search.includes("#"),Pr("#","search","hash",n)));let o=e===""||n.pathname==="",i=o?"/":n.pathname,s;if(i==null)s=r;else{let f=t.length-1;if(!a&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),f-=1;n.pathname=m.join("/")}s=f>=0?t[f]:"/"}let l=ul(n,s),u=i&&i!=="/"&&i.endsWith("/"),c=(o||i===".")&&r.endsWith("/");return!l.pathname.endsWith("/")&&(u||c)&&(l.pathname+="/"),l}var Me=e=>e.join("/").replace(/\/\/+/g,"/"),dl=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),fl=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,hl=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,ml=class{constructor(e,t){this.type="DataWithResponseInit",this.data=e,this.init=t||null}};function pl(e,t){return new ml(e,typeof t=="number"?{status:t}:t)}var sr=(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})},yl=(e,t)=>{let r=sr(e,t);return r.headers.set("X-Remix-Reload-Document","true"),r},vl=(e,t)=>{let r=sr(e,t);return r.headers.set("X-Remix-Replace","true"),r},pe=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 dt(e){return e.filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Ue=Symbol("Uninstrumented");function $n(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=rt(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=rt(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[Ue]??o,s=rt(r[n],i,(...l)=>Va(l[0]));s&&(s[Ue]=i,a[n]=s)}}),t.middleware&&t.middleware.length>0&&r.middleware.length>0&&(a.middleware=t.middleware.map(n=>{let o=n[Ue]??n,i=rt(r.middleware,o,(...s)=>Va(s[0]));return i?(i[Ue]=o,i):n})),a}function gl(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[Ue]??e.navigate,n=rt(r.navigate,a,(...o)=>{let[i,s]=o;return{to:typeof i=="number"||typeof i=="string"?i:i?he(i):".",...Ya(e,s??{})}});n&&(n[Ue]=a,e.navigate=n)}if(r.fetch.length>0){let a=e.fetch[Ue]??e.fetch,n=rt(r.fetch,a,(...o)=>{let[i,,s,l]=o;return{href:s??".",fetcherKey:i,...Ya(e,l??{})}});n&&(n[Ue]=a,e.fetch=n)}return e}function wl(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=rt(r.request,e,(...n)=>{let[o,i]=n;return{request:Hn(o),context:i!=null?jn(i):i}})),a}function rt(e,t,r){return e.length===0?null:async(...a)=>{let n=await In(e,r(...a),()=>t(...a),e.length-1);if(n.type==="error")throw n.value;return n.value}}async function In(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=In(e,t,r,a-1),o=await i,A(o,"Expected a result"),o.type==="error"&&o.value instanceof Error?{status:"error",error:o.value}:{status:"success",error:void 0});try{await n(s,t)}catch(l){console.error("An instrumentation function threw an error:",l)}i||await s(),await i}else try{o={type:"success",value:await r()}}catch(i){o={type:"error",value:i}}return o||{type:"error",value:new Error("No result assigned in instrumentation chain.")}}function Va(e){let{request:t,context:r,params:a,unstable_pattern:n}=e;return{request:Hn(t),params:{...a},unstable_pattern:n,context:jn(r)}}function Ya(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 Hn(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function jn(e){if(El(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var Rl=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function El(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")===Rl}var Un=["POST","PUT","PATCH","DELETE"],bl=new Set(Un),Sl=["GET",...Un],Cl=new Set(Sl),zn=new Set([301,302,303,307,308]),xl=new Set([307,308]),Kt={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Zr={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},tt={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},Pl=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ea=e=>Pl.test(e),Bn=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),Wn="remix-router-transitions",Vn=Symbol("ResetLoaderData");function ur(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";A(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let a=e.hydrationRouteProperties||[],n=e.mapRouteProperties||Bn,o=n;if(e.unstable_instrumentations){let v=e.unstable_instrumentations;o=b=>({...n(b),...$n(v.map(S=>S.route).filter(Boolean),b)})}let i={},s=Ve(e.routes,o,void 0,i),l,u=e.basename||"/";u.startsWith("/")||(u=`/${u}`);let c=e.dataStrategy||Fl,f={...e.future},m=null,p=new Set,h=null,g=null,y=null,w=e.hydrationData!=null,R=ge(s,e.history.location,u),C=!1,x=null,P;if(R==null&&!e.patchRoutesOnNavigation){let v=te(404,{pathname:e.history.location.pathname}),{matches:b,route:S}=ct(s);P=!0,R=b,x={[S.id]:v}}else if(R&&!e.hydrationData&&$t(R,s,e.history.location.pathname).active&&(R=null),R)if(R.some(v=>v.route.lazy))P=!1;else if(!R.some(v=>ta(v.route)))P=!0;else{let v=e.hydrationData?e.hydrationData.loaderData:null,b=e.hydrationData?e.hydrationData.errors:null;if(b){let S=R.findIndex(L=>b[L.route.id]!==void 0);P=R.slice(0,S+1).every(L=>!Ar(L.route,v,b))}else P=R.every(S=>!Ar(S.route,v,b))}else{P=!1,R=[];let v=$t(null,s,e.history.location.pathname);v.active&&v.matches&&(C=!0,R=v.matches)}let D,E={historyAction:e.history.action,location:e.history.location,matches:R,initialized:P,navigation:Kt,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||x,fetchers:new Map,blockers:new Map},F="POP",T=!1,M,N=!1,Y=new Map,G=null,B=!1,K=!1,le=new Set,J=new Map,be=0,ye=-1,De=new Map,ve=new Set,Se=new Map,Le=new Map,_e=new Set,Ke=new Map,Nt,Rt=null;function Ri(){if(m=e.history.listen(({action:v,location:b,delta:S})=>{if(Nt){Nt(),Nt=void 0;return}X(Ke.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 L=Oa({currentLocation:E.location,nextLocation:b,historyAction:v});if(L&&S!=null){let _=new Promise($=>{Nt=$});e.history.go(S*-1),At(L,{state:"blocked",location:b,proceed(){At(L,{state:"proceeding",proceed:void 0,reset:void 0,location:b}),_.then(()=>e.history.go(S))},reset(){let $=new Map(E.blockers);$.set(L,tt),se({blockers:$})}});return}return Xe(v,b)}),r){Hl(t,Y);let v=()=>jl(t,Y);t.addEventListener("pagehide",v),G=()=>t.removeEventListener("pagehide",v)}return E.initialized||Xe("POP",E.location,{initialHydration:!0}),D}function Ei(){m&&m(),G&&G(),p.clear(),M&&M.abort(),E.fetchers.forEach((v,b)=>br(b)),E.blockers.forEach((v,b)=>ka(b))}function bi(v){return p.add(v),()=>p.delete(v)}function se(v,b={}){v.matches&&(v.matches=v.matches.map(_=>{let $=i[_.route.id],H=_.route;return H.element!==$.element||H.errorElement!==$.errorElement||H.hydrateFallbackElement!==$.hydrateFallbackElement?{..._,route:$}:_})),E={...E,...v};let S=[],L=[];E.fetchers.forEach((_,$)=>{_.state==="idle"&&(_e.has($)?S.push($):L.push($))}),_e.forEach(_=>{!E.fetchers.has(_)&&!J.has(_)&&S.push(_)}),[...p].forEach(_=>_(E,{deletedFetchers:S,viewTransitionOpts:b.viewTransitionOpts,flushSync:b.flushSync===!0})),S.forEach(_=>br(_)),L.forEach(_=>E.fetchers.delete(_))}function it(v,b,{flushSync:S}={}){let L=E.actionData!=null&&E.navigation.formMethod!=null&&de(E.navigation.formMethod)&&E.navigation.state==="loading"&&v.state?._isRedirect!==!0,_;b.actionData?Object.keys(b.actionData).length>0?_=b.actionData:_=null:L?_=E.actionData:_=null;let $=b.loaderData?nn(E.loaderData,b.loaderData,b.matches||[],b.errors):E.loaderData,H=E.blockers;H.size>0&&(H=new Map(H),H.forEach((j,I)=>H.set(I,tt)));let O=B?!1:Aa(v,b.matches||E.matches),U=T===!0||E.navigation.formMethod!=null&&de(E.navigation.formMethod)&&v.state?._isRedirect!==!0;l&&(s=l,l=void 0),B||F==="POP"||(F==="PUSH"?e.history.push(v,v.state):F==="REPLACE"&&e.history.replace(v,v.state));let z;if(F==="POP"){let j=Y.get(E.location.pathname);j&&j.has(v.pathname)?z={currentLocation:E.location,nextLocation:v}:Y.has(v.pathname)&&(z={currentLocation:v,nextLocation:E.location})}else if(N){let j=Y.get(E.location.pathname);j?j.add(v.pathname):(j=new Set([v.pathname]),Y.set(E.location.pathname,j)),z={currentLocation:E.location,nextLocation:v}}se({...b,actionData:_,loaderData:$,historyAction:F,location:v,initialized:!0,navigation:Kt,revalidation:"idle",restoreScrollPosition:O,preventScrollReset:U,blockers:H},{viewTransitionOpts:z,flushSync:S===!0}),F="POP",T=!1,N=!1,B=!1,K=!1,Rt?.resolve(),Rt=null}async function Pa(v,b){if(typeof v=="number"){e.history.go(v);return}let S=Nr(E.location,E.matches,u,v,b?.fromRouteId,b?.relative),{path:L,submission:_,error:$}=Ka(!1,S,b),H=E.location,O=$e(E.location,L,b&&b.state);O={...O,...e.history.encodeLocation(O)};let U=b&&b.replace!=null?b.replace:void 0,z="PUSH";U===!0?z="REPLACE":U===!1||_!=null&&de(_.formMethod)&&_.formAction===E.location.pathname+E.location.search&&(z="REPLACE");let j=b&&"preventScrollReset"in b?b.preventScrollReset===!0:void 0,I=(b&&b.flushSync)===!0,W=Oa({currentLocation:H,nextLocation:O,historyAction:z});if(W){At(W,{state:"blocked",location:O,proceed(){At(W,{state:"proceeding",proceed:void 0,reset:void 0,location:O}),Pa(v,b)},reset(){let q=new Map(E.blockers);q.set(W,tt),se({blockers:q})}});return}await Xe(z,O,{submission:_,pendingError:$,preventScrollReset:j,replace:b&&b.replace,enableViewTransition:b&&b.viewTransition,flushSync:I})}function Si(){Rt||(Rt=Ul()),Er(),se({revalidation:"loading"});let v=Rt.promise;return E.navigation.state==="submitting"?v:E.navigation.state==="idle"?(Xe(E.historyAction,E.location,{startUninterruptedRevalidation:!0}),v):(Xe(F||E.historyAction,E.navigation.location,{overrideNavigation:E.navigation,enableViewTransition:N===!0}),v)}async function Xe(v,b,S){M&&M.abort(),M=null,F=v,B=(S&&S.startUninterruptedRevalidation)===!0,Oi(E.location,E.matches),T=(S&&S.preventScrollReset)===!0,N=(S&&S.enableViewTransition)===!0;let L=l||s,_=S&&S.overrideNavigation,$=S?.initialHydration&&E.matches&&E.matches.length>0&&!C?E.matches:ge(L,b,u),H=(S&&S.flushSync)===!0;if($&&E.initialized&&!K&&Ol(E.location,b)&&!(S&&S.submission&&de(S.submission.formMethod))){it(b,{matches:$},{flushSync:H});return}let O=$t($,L,b.pathname);if(O.active&&O.matches&&($=O.matches),!$){let{error:me,notFoundMatches:Z,route:Q}=Sr(b.pathname);it(b,{matches:Z,loaderData:{},errors:{[Q.id]:me}},{flushSync:H});return}M=new AbortController;let U=ut(e.history,b,M.signal,S&&S.submission),z=e.getContext?await e.getContext():new Ae,j;if(S&&S.pendingError)j=[xe($).route.id,{type:"error",error:S.pendingError}];else if(S&&S.submission&&de(S.submission.formMethod)){let me=await Ci(U,b,S.submission,$,z,O.active,S&&S.initialHydration===!0,{replace:S.replace,flushSync:H});if(me.shortCircuited)return;if(me.pendingActionResult){let[Z,Q]=me.pendingActionResult;if(ie(Q)&&re(Q.error)&&Q.error.status===404){M=null,it(b,{matches:me.matches,loaderData:{},errors:{[Z]:Q.error}});return}}$=me.matches||$,j=me.pendingActionResult,_=Dr(b,S.submission),H=!1,O.active=!1,U=ut(e.history,U.url,U.signal)}let{shortCircuited:I,matches:W,loaderData:q,errors:oe}=await xi(U,b,$,z,O.active,_,S&&S.submission,S&&S.fetcherSubmission,S&&S.replace,S&&S.initialHydration===!0,H,j);I||(M=null,it(b,{matches:W||$,...on(j),loaderData:q,errors:oe}))}async function Ci(v,b,S,L,_,$,H,O={}){Er();let U=$l(b,S);if(se({navigation:U},{flushSync:O.flushSync===!0}),$){let I=await It(L,b.pathname,v.signal);if(I.type==="aborted")return{shortCircuited:!0};if(I.type==="error"){if(I.partialMatches.length===0){let{matches:q,route:oe}=ct(s);return{matches:q,pendingActionResult:[oe.id,{type:"error",error:I.error}]}}let W=xe(I.partialMatches).route.id;return{matches:I.partialMatches,pendingActionResult:[W,{type:"error",error:I.error}]}}else if(I.matches)L=I.matches;else{let{notFoundMatches:W,error:q,route:oe}=Sr(b.pathname);return{matches:W,pendingActionResult:[oe.id,{type:"error",error:q}]}}}let z,j=ft(L,b);if(!j.route.action&&!j.route.lazy)z={type:"error",error:te(405,{method:v.method,pathname:b.pathname,routeId:j.route.id})};else{let I=Be(o,i,v,L,j,H?[]:a,_),W=await Et(v,I,_,null);if(z=W[j.route.id],!z){for(let q of L)if(W[q.route.id]){z=W[q.route.id];break}}if(v.signal.aborted)return{shortCircuited:!0}}if(ze(z)){let I;return O&&O.replace!=null?I=O.replace:I=tn(z.response.headers.get("Location"),new URL(v.url),u)===E.location.pathname+E.location.search,await Ge(v,z,!0,{submission:S,replace:I}),{shortCircuited:!0}}if(ie(z)){let I=xe(L,j.route.id);return(O&&O.replace)!==!0&&(F="PUSH"),{matches:L,pendingActionResult:[I.route.id,z,j.route.id]}}return{matches:L,pendingActionResult:[j.route.id,z]}}async function xi(v,b,S,L,_,$,H,O,U,z,j,I){let W=$||Dr(b,H),q=H||O||ln(W),oe=!B&&!z;if(_){if(oe){let ue=Da(I);se({navigation:W,...ue!==void 0?{actionData:ue}:{}},{flushSync:j})}let V=await It(S,b.pathname,v.signal);if(V.type==="aborted")return{shortCircuited:!0};if(V.type==="error"){if(V.partialMatches.length===0){let{matches:lt,route:Ze}=ct(s);return{matches:lt,loaderData:{},errors:{[Ze.id]:V.error}}}let ue=xe(V.partialMatches).route.id;return{matches:V.partialMatches,loaderData:{},errors:{[ue]:V.error}}}else if(V.matches)S=V.matches;else{let{error:ue,notFoundMatches:lt,route:Ze}=Sr(b.pathname);return{matches:lt,loaderData:{},errors:{[Ze.id]:ue}}}}let me=l||s,{dsMatches:Z,revalidatingFetchers:Q}=Xa(v,L,o,i,e.history,E,S,q,b,z?[]:a,z===!0,K,le,_e,Se,ve,me,u,e.patchRoutesOnNavigation!=null,I);if(ye=++be,!e.dataStrategy&&!Z.some(V=>V.shouldLoad)&&!Z.some(V=>V.route.middleware&&V.route.middleware.length>0)&&Q.length===0){let V=Ma();return it(b,{matches:S,loaderData:{},errors:I&&ie(I[1])?{[I[0]]:I[1].error}:null,...on(I),...V?{fetchers:new Map(E.fetchers)}:{}},{flushSync:j}),{shortCircuited:!0}}if(oe){let V={};if(!_){V.navigation=W;let ue=Da(I);ue!==void 0&&(V.actionData=ue)}Q.length>0&&(V.fetchers=Pi(Q)),se(V,{flushSync:j})}Q.forEach(V=>{Oe(V.key),V.controller&&J.set(V.key,V.controller)});let Qe=()=>Q.forEach(V=>Oe(V.key));M&&M.signal.addEventListener("abort",Qe);let{loaderResults:bt,fetcherResults:je}=await La(Z,Q,v,L);if(v.signal.aborted)return{shortCircuited:!0};M&&M.signal.removeEventListener("abort",Qe),Q.forEach(V=>J.delete(V.key));let Te=zt(bt);if(Te)return await Ge(v,Te.result,!0,{replace:U}),{shortCircuited:!0};if(Te=zt(je),Te)return ve.add(Te.key),await Ge(v,Te.result,!0,{replace:U}),{shortCircuited:!0};let{loaderData:Cr,errors:St}=an(E,S,bt,I,Q,je);z&&E.errors&&(St={...E.errors,...St});let qe=Ma(),Ht=Fa(ye),jt=qe||Ht||Q.length>0;return{matches:S,loaderData:Cr,errors:St,...jt?{fetchers:new Map(E.fetchers)}:{}}}function Da(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 Pi(v){return v.forEach(b=>{let S=E.fetchers.get(b.key),L=xt(void 0,S?S.data:void 0);E.fetchers.set(b.key,L)}),new Map(E.fetchers)}async function Di(v,b,S,L){Oe(v);let _=(L&&L.flushSync)===!0,$=l||s,H=Nr(E.location,E.matches,u,S,b,L?.relative),O=ge($,H,u),U=$t(O,$,H);if(U.active&&U.matches&&(O=U.matches),!O){ke(v,b,te(404,{pathname:H}),{flushSync:_});return}let{path:z,submission:j,error:I}=Ka(!0,H,L);if(I){ke(v,b,I,{flushSync:_});return}let W=e.getContext?await e.getContext():new Ae,q=(L&&L.preventScrollReset)===!0;if(j&&de(j.formMethod)){await Li(v,b,z,O,W,U.active,_,q,j);return}Se.set(v,{routeId:b,path:z}),await _i(v,b,z,O,W,U.active,_,q,j)}async function Li(v,b,S,L,_,$,H,O,U){Er(),Se.delete(v);let z=E.fetchers.get(v);Fe(v,Il(U,z),{flushSync:H});let j=new AbortController,I=ut(e.history,S,j.signal,U);if($){let ae=await It(L,new URL(I.url).pathname,I.signal,v);if(ae.type==="aborted")return;if(ae.type==="error"){ke(v,b,ae.error,{flushSync:H});return}else if(ae.matches)L=ae.matches;else{ke(v,b,te(404,{pathname:S}),{flushSync:H});return}}let W=ft(L,S);if(!W.route.action&&!W.route.lazy){let ae=te(405,{method:U.formMethod,pathname:S,routeId:b});ke(v,b,ae,{flushSync:H});return}J.set(v,j);let q=be,oe=Be(o,i,I,L,W,a,_),Z=(await Et(I,oe,_,v))[W.route.id];if(I.signal.aborted){J.get(v)===j&&J.delete(v);return}if(_e.has(v)){if(ze(Z)||ie(Z)){Fe(v,Ne(void 0));return}}else{if(ze(Z))if(J.delete(v),ye>q){Fe(v,Ne(void 0));return}else return ve.add(v),Fe(v,xt(U)),Ge(I,Z,!1,{fetcherSubmission:U,preventScrollReset:O});if(ie(Z)){ke(v,b,Z.error);return}}let Q=E.navigation.location||E.location,Qe=ut(e.history,Q,j.signal),bt=l||s,je=E.navigation.state!=="idle"?ge(bt,E.navigation.location,u):E.matches;A(je,"Didn't find any matches after fetcher action");let Te=++be;De.set(v,Te);let Cr=xt(U,Z.data);E.fetchers.set(v,Cr);let{dsMatches:St,revalidatingFetchers:qe}=Xa(Qe,_,o,i,e.history,E,je,U,Q,a,!1,K,le,_e,Se,ve,bt,u,e.patchRoutesOnNavigation!=null,[W.route.id,Z]);qe.filter(ae=>ae.key!==v).forEach(ae=>{let Ut=ae.key,$a=E.fetchers.get(Ut),$i=xt(void 0,$a?$a.data:void 0);E.fetchers.set(Ut,$i),Oe(Ut),ae.controller&&J.set(Ut,ae.controller)}),se({fetchers:new Map(E.fetchers)});let Ht=()=>qe.forEach(ae=>Oe(ae.key));j.signal.addEventListener("abort",Ht);let{loaderResults:jt,fetcherResults:V}=await La(St,qe,Qe,_);if(j.signal.aborted)return;if(j.signal.removeEventListener("abort",Ht),De.delete(v),J.delete(v),qe.forEach(ae=>J.delete(ae.key)),E.fetchers.has(v)){let ae=Ne(Z.data);E.fetchers.set(v,ae)}let ue=zt(jt);if(ue)return Ge(Qe,ue.result,!1,{preventScrollReset:O});if(ue=zt(V),ue)return ve.add(ue.key),Ge(Qe,ue.result,!1,{preventScrollReset:O});let{loaderData:lt,errors:Ze}=an(E,je,jt,void 0,qe,V);Fa(Te),E.navigation.state==="loading"&&Te>ye?(A(F,"Expected pending action"),M&&M.abort(),it(E.navigation.location,{matches:je,loaderData:lt,errors:Ze,fetchers:new Map(E.fetchers)})):(se({errors:Ze,loaderData:nn(E.loaderData,lt,je,Ze),fetchers:new Map(E.fetchers)}),K=!1)}async function _i(v,b,S,L,_,$,H,O,U){let z=E.fetchers.get(v);Fe(v,xt(U,z?z.data:void 0),{flushSync:H});let j=new AbortController,I=ut(e.history,S,j.signal);if($){let Q=await It(L,new URL(I.url).pathname,I.signal,v);if(Q.type==="aborted")return;if(Q.type==="error"){ke(v,b,Q.error,{flushSync:H});return}else if(Q.matches)L=Q.matches;else{ke(v,b,te(404,{pathname:S}),{flushSync:H});return}}let W=ft(L,S);J.set(v,j);let q=be,oe=Be(o,i,I,L,W,a,_),Z=(await Et(I,oe,_,v))[W.route.id];if(J.get(v)===j&&J.delete(v),!I.signal.aborted){if(_e.has(v)){Fe(v,Ne(void 0));return}if(ze(Z))if(ye>q){Fe(v,Ne(void 0));return}else{ve.add(v),await Ge(I,Z,!1,{preventScrollReset:O});return}if(ie(Z)){ke(v,b,Z.error);return}Fe(v,Ne(Z.data))}}async function Ge(v,b,S,{submission:L,fetcherSubmission:_,preventScrollReset:$,replace:H}={}){b.response.headers.has("X-Remix-Revalidate")&&(K=!0);let O=b.response.headers.get("Location");A(O,"Expected a Location header on the redirect Response"),O=tn(O,new URL(v.url),u);let U=$e(E.location,O,{_isRedirect:!0});if(r){let oe=!1;if(b.response.headers.has("X-Remix-Reload-Document"))oe=!0;else if(ea(O)){const me=Tn(O,!0);oe=me.origin!==t.location.origin||ne(me.pathname,u)==null}if(oe){H?t.location.replace(O):t.location.assign(O);return}}M=null;let z=H===!0||b.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:j,formAction:I,formEncType:W}=E.navigation;!L&&!_&&j&&I&&W&&(L=ln(E.navigation));let q=L||_;if(xl.has(b.response.status)&&q&&de(q.formMethod))await Xe(z,U,{submission:{...q,formAction:O},preventScrollReset:$||T,enableViewTransition:S?N:void 0});else{let oe=Dr(U,L);await Xe(z,U,{overrideNavigation:oe,fetcherSubmission:_,preventScrollReset:$||T,enableViewTransition:S?N:void 0})}}async function Et(v,b,S,L){let _,$={};try{_=await Zn(c,v,b,L,S,!1)}catch(H){return b.filter(O=>O.shouldLoad).forEach(O=>{$[O.route.id]={type:"error",error:H}}),$}if(v.signal.aborted)return $;for(let[H,O]of Object.entries(_))if(io(O)){let U=O.result;$[H]={type:"redirect",response:ro(U,v,H,b,u)}}else $[H]=await to(O);return $}async function La(v,b,S,L){let _=Et(S,v,L,null),$=Promise.all(b.map(async U=>{if(U.matches&&U.match&&U.request&&U.controller){let j=(await Et(U.request,U.matches,L,U.key))[U.match.route.id];return{[U.key]:j}}else return Promise.resolve({[U.key]:{type:"error",error:te(404,{pathname:U.path})}})})),H=await _,O=(await $).reduce((U,z)=>Object.assign(U,z),{});return{loaderResults:H,fetcherResults:O}}function Er(){K=!0,Se.forEach((v,b)=>{J.has(b)&&le.add(b),Oe(b)})}function Fe(v,b,S={}){E.fetchers.set(v,b),se({fetchers:new Map(E.fetchers)},{flushSync:(S&&S.flushSync)===!0})}function ke(v,b,S,L={}){let _=xe(E.matches,b);br(v),se({errors:{[_.route.id]:S},fetchers:new Map(E.fetchers)},{flushSync:(L&&L.flushSync)===!0})}function _a(v){return Le.set(v,(Le.get(v)||0)+1),_e.has(v)&&_e.delete(v),E.fetchers.get(v)||Zr}function Ti(v,b){Oe(v,b?.reason),Fe(v,Ne(null))}function br(v){let b=E.fetchers.get(v);J.has(v)&&!(b&&b.state==="loading"&&De.has(v))&&Oe(v),Se.delete(v),De.delete(v),ve.delete(v),_e.delete(v),le.delete(v),E.fetchers.delete(v)}function Mi(v){let b=(Le.get(v)||0)-1;b<=0?(Le.delete(v),_e.add(v)):Le.set(v,b),se({fetchers:new Map(E.fetchers)})}function Oe(v,b){let S=J.get(v);S&&(S.abort(b),J.delete(v))}function Ta(v){for(let b of v){let S=_a(b),L=Ne(S.data);E.fetchers.set(b,L)}}function Ma(){let v=[],b=!1;for(let S of ve){let L=E.fetchers.get(S);A(L,`Expected fetcher: ${S}`),L.state==="loading"&&(ve.delete(S),v.push(S),b=!0)}return Ta(v),b}function Fa(v){let b=[];for(let[S,L]of De)if(L<v){let _=E.fetchers.get(S);A(_,`Expected fetcher: ${S}`),_.state==="loading"&&(Oe(S),De.delete(S),b.push(S))}return Ta(b),b.length>0}function Fi(v,b){let S=E.blockers.get(v)||tt;return Ke.get(v)!==b&&Ke.set(v,b),S}function ka(v){E.blockers.delete(v),Ke.delete(v)}function At(v,b){let S=E.blockers.get(v)||tt;A(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 L=new Map(E.blockers);L.set(v,b),se({blockers:L})}function Oa({currentLocation:v,nextLocation:b,historyAction:S}){if(Ke.size===0)return;Ke.size>1&&X(!1,"A router only supports one blocker at a time");let L=Array.from(Ke.entries()),[_,$]=L[L.length-1],H=E.blockers.get(_);if(!(H&&H.state==="proceeding")&&$({currentLocation:v,nextLocation:b,historyAction:S}))return _}function Sr(v){let b=te(404,{pathname:v}),S=l||s,{matches:L,route:_}=ct(S);return{notFoundMatches:L,route:_,error:b}}function ki(v,b,S){if(h=v,y=b,g=S||null,!w&&E.navigation===Kt){w=!0;let L=Aa(E.location,E.matches);L!=null&&se({restoreScrollPosition:L})}return()=>{h=null,y=null,g=null}}function Na(v,b){return g&&g(v,b.map(L=>Mn(L,E.loaderData)))||v.key}function Oi(v,b){if(h&&y){let S=Na(v,b);h[S]=y()}}function Aa(v,b){if(h){let S=Na(v,b),L=h[S];if(typeof L=="number")return L}return null}function $t(v,b,S){if(e.patchRoutesOnNavigation)if(v){if(Object.keys(v[0].params).length>0)return{active:!0,matches:Jt(b,S,u,!0)}}else return{active:!0,matches:Jt(b,S,u,!0)||[]};return{active:!1,matches:null}}async function It(v,b,S,L){if(!e.patchRoutesOnNavigation)return{type:"success",matches:v};let _=v;for(;;){let $=l==null,H=l||s,O=i;try{await e.patchRoutesOnNavigation({signal:S,path:b,matches:_,fetcherKey:L,patch:(j,I)=>{S.aborted||Ga(j,I,H,O,o,!1)}})}catch(j){return{type:"error",error:j,partialMatches:_}}finally{$&&!S.aborted&&(s=[...s])}if(S.aborted)return{type:"aborted"};let U=ge(H,b,u);if(U)return{type:"success",matches:U};let z=Jt(H,b,u,!0);if(!z||_.length===z.length&&_.every((j,I)=>j.route.id===z[I].route.id))return{type:"success",matches:null};_=z}}function Ni(v){i={},l=Ve(v,o,void 0,i)}function Ai(v,b,S=!1){let L=l==null;Ga(v,b,l||s,i,o,S),L&&(s=[...s],se({}))}return D={get basename(){return u},get future(){return f},get state(){return E},get routes(){return s},get window(){return t},initialize:Ri,subscribe:bi,enableScrollRestoration:ki,navigate:Pa,fetch:Di,revalidate:Si,createHref:v=>e.history.createHref(v),encodeLocation:v=>e.history.encodeLocation(v),getFetcher:_a,resetFetcher:Ti,deleteFetcher:Mi,dispose:Ei,getBlocker:Fi,deleteBlocker:ka,patchRoutes:Ai,_internalFetchControllers:J,_internalSetRoutes:Ni,_internalSetStateDoNotUseOrYouWillBreakYourApp(v){se(v)}},e.unstable_instrumentations&&(D=gl(D,e.unstable_instrumentations.map(v=>v.router).filter(Boolean))),D}function Yn(e,t){A(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let r={},a=(t?t.basename:null)||"/",n=t?.mapRouteProperties||Bn,o=n;if(t?.unstable_instrumentations){let p=t.unstable_instrumentations;o=h=>({...n(h),...$n(p.map(g=>g.route).filter(Boolean),h)})}let i=Ve(e,o,void 0,r);async function s(p,{requestContext:h,filterMatchesToLoad:g,skipLoaderErrorBubbling:y,skipRevalidation:w,dataStrategy:R,generateMiddlewareResponse:C}={}){let x=new URL(p.url),P=p.method,D=$e("",he(x),null,"default"),E=ge(i,D,a);if(h=h??new Ae,!jr(P)&&P!=="HEAD"){let T=te(405,{method:P}),{matches:M,route:N}=ct(i),Y={basename:a,location:D,matches:M,loaderData:{},actionData:null,errors:{[N.id]:T},statusCode:T.status,loaderHeaders:{},actionHeaders:{}};return C?C(()=>Promise.resolve(Y)):Y}else if(!E){let T=te(404,{pathname:D.pathname}),{matches:M,route:N}=ct(i),Y={basename:a,location:D,matches:M,loaderData:{},actionData:null,errors:{[N.id]:T},statusCode:T.status,loaderHeaders:{},actionHeaders:{}};return C?C(()=>Promise.resolve(Y)):Y}if(C){A(h instanceof Ae,"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`");try{await Za(E,r,o);let T,M=await en({request:p,unstable_pattern:dt(E.map(N=>N.route.path)),matches:E,params:E[0].params,context:h},async()=>await C(async(Y,G={})=>{let B=await u(Y,D,E,h,R||null,y===!0,null,"filterMatchesToLoad"in G?G.filterMatchesToLoad??null:g??null,w===!0);return ee(B)?B:(T={location:D,basename:a,...B},T)}),async(N,Y)=>{if(er(N))return N;if(ee(N))try{N=new pe(N.status,N.statusText,await eo(N))}catch(G){N=G}if(We(N)&&(N=Nl(N)),T){Y in T.loaderData&&(T.loaderData[Y]=void 0);let G=Jn(i,T,N,y?Y:xe(E,Y).route.id);return C(()=>Promise.resolve(G))}else{let G=y?Y:xe(E,E.find(K=>K.route.id===Y||K.route.loader)?.route.id||Y).route.id,B={matches:E,location:D,basename:a,loaderData:{},actionData:null,errors:{[G]:N},statusCode:re(N)?N.status:500,actionHeaders:{},loaderHeaders:{}};return C(()=>Promise.resolve(B))}});return A(ee(M),"Expected a response in query()"),M}catch(T){if(ee(T))return T;throw T}}let F=await u(p,D,E,h,R||null,y===!0,null,g||null,w===!0);return ee(F)?F:{location:D,basename:a,...F}}async function l(p,{routeId:h,requestContext:g,dataStrategy:y,generateMiddlewareResponse:w}={}){let R=new URL(p.url),C=p.method,x=$e("",he(R),null,"default"),P=ge(i,x,a);if(g=g??new Ae,!jr(C)&&C!=="HEAD"&&C!=="OPTIONS")throw te(405,{method:C});if(!P)throw te(404,{pathname:x.pathname});let D=h?P.find(T=>T.route.id===h):ft(P,x);if(h&&!D)throw te(403,{pathname:x.pathname,routeId:h});if(!D)throw te(404,{pathname:x.pathname});if(w)return A(g instanceof Ae,"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"),await Za(P,r,o),await en({request:p,unstable_pattern:dt(P.map(M=>M.route.path)),matches:P,params:P[0].params,context:g},async()=>await w(async N=>{let Y=await u(N,x,P,g,y||null,!1,D,null,!1),G=F(Y);return ee(G)?G:typeof G=="string"?new Response(G):Response.json(G)}),M=>{if(We(M))return Promise.resolve(Hr(M));if(ee(M))return Promise.resolve(M);throw M});let E=await u(p,x,P,g,y||null,!1,D,null,!1);return F(E);function F(T){if(ee(T))return T;let M=T.errors?Object.values(T.errors)[0]:void 0;if(M!==void 0)throw M;if(T.actionData)return Object.values(T.actionData)[0];if(T.loaderData)return Object.values(T.loaderData)[0]}}async function u(p,h,g,y,w,R,C,x,P){A(p.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(de(p.method))return await c(p,g,C||ft(g,h),y,w,R,C!=null,x,P);let D=await f(p,g,y,w,R,C,x);return ee(D)?D:{...D,actionData:null,actionHeaders:{}}}catch(D){if(oo(D)&&ee(D.result)){if(D.type==="error")throw D.result;return D.result}if(er(D))return D;throw D}}async function c(p,h,g,y,w,R,C,x,P){let D;if(!g.route.action&&!g.route.lazy){let T=te(405,{method:p.method,pathname:new URL(p.url).pathname,routeId:g.route.id});if(C)throw T;D={type:"error",error:T}}else{let T=Be(o,r,p,h,g,[],y);D=(await m(p,T,C,y,w))[g.route.id],p.signal.aborted&&Ja(p,C)}if(ze(D))throw new Response(null,{status:D.response.status,headers:{Location:D.response.headers.get("Location")}});if(C){if(ie(D))throw D.error;return{matches:[g],loaderData:{},actionData:{[g.route.id]:D.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(P)if(ie(D)){let T=R?g:xe(h,g.route.id);return{statusCode:re(D.error)?D.error.status:D.statusCode!=null?D.statusCode:500,actionData:null,actionHeaders:{...D.headers?{[g.route.id]:D.headers}:{}},matches:h,loaderData:{},errors:{[T.route.id]:D.error},loaderHeaders:{}}}else return{actionData:{[g.route.id]:D.data},actionHeaders:D.headers?{[g.route.id]:D.headers}:{},matches:h,loaderData:{},errors:null,statusCode:D.statusCode||200,loaderHeaders:{}};let E=new Request(p.url,{headers:p.headers,redirect:p.redirect,signal:p.signal});if(ie(D)){let T=R?g:xe(h,g.route.id);return{...await f(E,h,y,w,R,null,x,[T.route.id,D]),statusCode:re(D.error)?D.error.status:D.statusCode!=null?D.statusCode:500,actionData:null,actionHeaders:{...D.headers?{[g.route.id]:D.headers}:{}}}}return{...await f(E,h,y,w,R,null,x),actionData:{[g.route.id]:D.data},...D.statusCode?{statusCode:D.statusCode}:{},actionHeaders:D.headers?{[g.route.id]:D.headers}:{}}}async function f(p,h,g,y,w,R,C,x){let P=R!=null;if(P&&!R?.route.loader&&!R?.route.lazy)throw te(400,{method:p.method,pathname:new URL(p.url).pathname,routeId:R?.route.id});let D;if(R)D=Be(o,r,p,h,R,[],g);else{let T=x&&ie(x[1])?h.findIndex(N=>N.route.id===x[0])-1:void 0,M=dt(h.map(N=>N.route.path));D=h.map((N,Y)=>T!=null&&Y>T?Tt(o,r,p,M,N,[],g,!1):Tt(o,r,p,M,N,[],g,(N.route.loader||N.route.lazy)!=null&&(!C||C(N))))}if(!y&&!D.some(T=>T.shouldLoad))return{matches:h,loaderData:{},errors:x&&ie(x[1])?{[x[0]]:x[1].error}:null,statusCode:200,loaderHeaders:{}};let E=await m(p,D,P,g,y);return p.signal.aborted&&Ja(p,P),{...ao(h,E,x,!0,w),matches:h}}async function m(p,h,g,y,w){let R=await Zn(w||$r,p,h,null,y,!0),C={};return await Promise.all(h.map(async x=>{if(!(x.route.id in R))return;let P=R[x.route.id];if(io(P)){let D=P.result;throw ro(D,p,x.route.id,h,a)}if(g){if(ee(P.result))throw P;if(We(P.result))throw Hr(P.result)}C[x.route.id]=await to(P)})),C}return{dataRoutes:i,query:s,queryRoute:l}}function Jn(e,t,r,a){let n=a||t._deepestRenderedBoundaryId||e[0].id;return{...t,statusCode:re(r)?r.status:500,errors:{[n]:r}}}function Ja(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 Dl(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function Nr(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=lr(a||".",ir(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=aa(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),f=c.getAll("index");c.delete("index"),f.filter(p=>p).forEach(p=>c.append("index",p));let m=c.toString();l.search=m?`?${m}`:""}}return r!=="/"&&(l.pathname=sl({basename:r,pathname:l.pathname})),he(l)}function Ka(e,t,r){if(!r||!Dl(r))return{path:t};if(r.formMethod&&!jr(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=no(t);if(r.body!==void 0){if(r.formEncType==="text/plain"){if(!de(o))return a();let f=typeof r.body=="string"?r.body:r.body instanceof FormData||r.body instanceof URLSearchParams?Array.from(r.body.entries()).reduce((m,[p,h])=>`${m}${p}=${h}
|
|
2
2
|
`,""):String(r.body);return{path:t,submission:{formMethod:o,formAction:i,formEncType:r.formEncType,formData:void 0,json:void 0,text:f}}}else if(r.formEncType==="application/json"){if(!de(o))return a();try{let f=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:f,text:void 0}}}catch{return a()}}}A(typeof FormData=="function","FormData is not available in this environment");let s,l;if(r.formData)s=Ir(r.formData),l=r.formData;else if(r.body instanceof FormData)s=Ir(r.body),l=r.body;else if(r.body instanceof URLSearchParams)s=r.body,l=rn(s);else if(r.body==null)s=new URLSearchParams,l=new FormData;else try{s=new URLSearchParams(r.body),l=rn(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=Pe(t);return e&&c.search&&aa(c.search)&&s.append("index",""),c.search=`?${s}`,{path:he(c),submission:u}}function Xa(e,t,r,a,n,o,i,s,l,u,c,f,m,p,h,g,y,w,R,C){let x=C?ie(C[1])?C[1].error:C[1].data:void 0,P=n.createURL(o.location),D=n.createURL(l),E;if(c&&o.errors){let B=Object.keys(o.errors)[0];E=i.findIndex(K=>K.route.id===B)}else if(C&&ie(C[1])){let B=C[0];E=i.findIndex(K=>K.route.id===B)-1}let F=C?C[1].statusCode:void 0,T=F&&F>=400,M={currentUrl:P,currentParams:o.matches[0]?.params||{},nextUrl:D,nextParams:i[0].params,...s,actionResult:x,actionStatus:F},N=dt(i.map(B=>B.route.path)),Y=i.map((B,K)=>{let{route:le}=B,J=null;if(E!=null&&K>E?J=!1:le.lazy?J=!0:ta(le)?c?J=Ar(le,o.loaderData,o.errors):Ll(o.loaderData,o.matches[K],B)&&(J=!0):J=!1,J!==null)return Tt(r,a,e,N,B,u,t,J);let be=T?!1:f||P.pathname+P.search===D.pathname+D.search||P.search!==D.search||_l(o.matches[K],B),ye={...M,defaultShouldRevalidate:be},De=Zt(B,ye);return Tt(r,a,e,N,B,u,t,De,ye)}),G=[];return h.forEach((B,K)=>{if(c||!i.some(Le=>Le.route.id===B.routeId)||p.has(K))return;let le=o.fetchers.get(K),J=le&&le.state!=="idle"&&le.data===void 0,be=ge(y,B.path,w);if(!be){if(R&&J)return;G.push({key:K,routeId:B.routeId,path:B.path,matches:null,match:null,request:null,controller:null});return}if(g.has(K))return;let ye=ft(be,B.path),De=new AbortController,ve=ut(n,B.path,De.signal),Se=null;if(m.has(K))m.delete(K),Se=Be(r,a,ve,be,ye,u,t);else if(J)f&&(Se=Be(r,a,ve,be,ye,u,t));else{let Le={...M,defaultShouldRevalidate:T?!1:f};Zt(ye,Le)&&(Se=Be(r,a,ve,be,ye,u,t,Le))}Se&&G.push({key:K,routeId:B.routeId,path:B.path,matches:Se,match:ye,request:ve,controller:De})}),{dsMatches:Y,revalidatingFetchers:G}}function ta(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function Ar(e,t,r){if(e.lazy)return!0;if(!ta(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 Ll(e,t,r){let a=!t||r.route.id!==t.route.id,n=!e.hasOwnProperty(r.route.id);return a||n}function _l(e,t){let r=e.route.path;return e.pathname!==t.pathname||r!=null&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function Zt(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if(typeof r=="boolean")return r}return t.defaultShouldRevalidate}function Ga(e,t,r,a,n,o){let i;if(e){let u=a[e];A(u,`No route found to patch children into: routeId = ${e}`),u.children||(u.children=[]),i=u.children}else i=r;let s=[],l=[];if(t.forEach(u=>{let c=i.find(f=>Kn(u,f));c?l.push({existingRoute:c,newRoute:u}):s.push(u)}),s.length>0){let u=Ve(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:f}=l[u],m=c,[p]=Ve([f],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 Kn(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=>Kn(r,n))):!1}var Qa=new WeakMap,ra=({key:e,route:t,manifest:r,mapRouteProperties:a})=>{let n=r[t.id];if(A(n,"No route found in manifest"),!n.lazy||typeof n.lazy!="object")return;let o=n.lazy[e];if(!o)return;let i=Qa.get(n);i||(i={},Qa.set(n,i));let s=i[e];if(s)return s;let l=(async()=>{let u=Ki(e),f=n[e]!==void 0&&e!=="hasErrorBoundary";if(u)X(!u,"Route property "+e+" is not a supported lazy route property. This property will be ignored."),i[e]=Promise.resolve();else if(f)X(!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},qa=new WeakMap;function Tl(e,t,r,a,n){let o=r[e.id];if(A(o,"No route found in manifest"),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy=="function"){let c=qa.get(o);if(c)return{lazyRoutePromise:c,lazyHandlerPromise:c};let f=(async()=>{A(typeof e.lazy=="function","No lazy route function found");let m=await e.lazy(),p={};for(let h in m){let g=m[h];if(g===void 0)continue;let y=Gi(h),R=o[h]!==void 0&&h!=="hasErrorBoundary";y?X(!y,"Route property "+h+" is not a supported property to be returned from a lazy route function. This property will be ignored."):R?X(!R,`Route "${o.id}" has a static property "${h}" defined but its lazy function is also returning a value for this property. The lazy route property "${h}" will be ignored.`):p[h]=g}Object.assign(o,p),Object.assign(o,{...a(o),lazy:void 0})})();return qa.set(o,f),f.catch(()=>{}),{lazyRoutePromise:f,lazyHandlerPromise:f}}let i=Object.keys(e.lazy),s=[],l;for(let c of i){if(n&&n.includes(c))continue;let f=ra({key:c,route:e,manifest:r,mapRouteProperties:a});f&&(s.push(f),c===t&&(l=f))}let u=s.length>0?Promise.all(s).then(()=>{}):void 0;return u?.catch(()=>{}),l?.catch(()=>{}),{lazyRoutePromise:u,lazyHandlerPromise:l}}function Ml(e){return e!==void 0}function Za(e,t,r){let a=e.map(({route:n})=>{if(!(typeof n.lazy!="object"||!n.lazy.middleware))return ra({key:"middleware",route:n,manifest:t,mapRouteProperties:r})}).filter(Ml);return a.length>0?Promise.all(a):void 0}async function $r(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 Fl(e){return e.matches.some(t=>t.route.middleware)?Xn(e,()=>$r(e)):$r(e)}function en(e,t,r){return Gn(e,t,a,ee,r);function a(n){return We(n)?Hr(n):n}}function Xn(e,t){return Gn(e,t,a=>a,Al,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=xe(i,i[s].route.id).route.id;return Promise.resolve({[l]:{type:"error",result:a}})}}}async function Gn(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 Qn({request:i,params:s,context:l,unstable_pattern:u},c,t,r,a,n)}async function Qn(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,f,m=async()=>{if(f)throw new Error("You may only call `next()` once per middleware");try{return f={value:await Qn(e,t,r,a,n,o,i+1)},f.value}catch(p){return f={value:await o(p,u,f)},f.value}};try{let p=await c(e,m),h=p!=null?a(p):void 0;return n(h)?h:f?h??f.value:(f={value:await m()},f.value)}catch(p){return await o(p,u,f)}}function qn(e,t,r,a,n){let o=ra({key:"middleware",route:a.route,manifest:t,mapRouteProperties:e}),i=Tl(a.route,de(r.method)?"action":"loader",t,e,n);return{middleware:o,route:i.lazyRoutePromise,handler:i.lazyHandlerPromise}}function Tt(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(f){return u=!0,l?typeof f=="boolean"?Zt(n,{...l,defaultShouldRevalidate:f}):Zt(n,l):s},resolve(f){let{lazy:m,loader:p,middleware:h}=n.route,g=u||s||f&&!de(r.method)&&(m||p),y=h&&h.length>0&&!p&&!m;return g&&(de(r.method)||!y)?kl({request:r,unstable_pattern:a,match:n,lazyHandlerPromise:c?.handler,lazyRoutePromise:c?.route,handlerOverride:f,scopedContext:i}):Promise.resolve({type:"data",result:void 0})}}}function Be(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})}:Tt(e,t,r,dt(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:dt(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 Xn(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 kl({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",f=m=>{let p,h=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,h])};try{let m=u?r.route.action:r.route.loader;if(a||n)if(m){let p,[h]=await Promise.all([f(m).catch(g=>{p=g}),a,n]);if(p!==void 0)throw p;s=h}else{await a;let p=u?r.route.action:r.route.loader;if(p)[s]=await Promise.all([f(p),n]);else if(c==="action"){let h=new URL(e.url),g=h.pathname+h.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 f(m);else{let p=new URL(e.url),h=p.pathname+p.search;throw te(404,{pathname:h})}}catch(m){return{type:"error",result:m}}finally{l&&e.signal.removeEventListener("abort",l)}return s}async function eo(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 to(e){let{result:t,type:r}=e;if(ee(t)){let a;try{a=await eo(t)}catch(n){return{type:"error",error:n}}return r==="error"?{type:"error",error:new pe(t.status,t.statusText,a),statusCode:t.status,headers:t.headers}:{type:"data",data:a,statusCode:t.status,headers:t.headers}}return r==="error"?We(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 pe(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}:We(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 ro(e,t,r,a,n){let o=e.headers.get("Location");if(A(o,"Redirects returned/thrown from loaders/actions must have a Location header"),!ea(o)){let i=a.slice(0,a.findIndex(s=>s.route.id===r)+1);o=Nr(new URL(t.url),i,n,o),e.headers.set("Location",o)}return e}function tn(e,t,r){if(ea(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 ut(e,t,r,a){let n=e.createURL(no(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=Ir(a.formData):o.body=a.formData}return new Request(n,o)}function Ir(e){let t=new URLSearchParams;for(let[r,a]of e.entries())t.append(r,typeof a=="string"?a:a.name);return t}function rn(e){let t=new FormData;for(let[r,a]of e.entries())t.append(r,a);return t}function ao(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(f=>{if(!(f.route.id in t))return;let m=f.route.id,p=t[m];if(A(!ze(p),"Cannot handle redirect results in processLoaderData"),ie(p)){let h=p.error;if(c!==void 0&&(h=c,c=void 0),i=i||{},n)i[m]=h;else{let g=xe(e,m);i[g.route.id]==null&&(i[g.route.id]=h)}a||(o[m]=Vn),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 an(e,t,r,a,n,o){let{loaderData:i,errors:s}=ao(t,r,a);return n.filter(l=>!l.matches||l.matches.some(u=>u.shouldLoad)).forEach(l=>{let{key:u,match:c,controller:f}=l;if(f&&f.signal.aborted)return;let m=o[u];if(A(m,"Did not find corresponding fetcher result"),ie(m)){let p=xe(e.matches,c?.route.id);s&&s[p.route.id]||(s={...s,[p.route.id]:m.error}),e.fetchers.delete(u)}else if(ze(m))A(!1,"Unhandled fetcher revalidation redirect");else{let p=Ne(m.data);e.fetchers.set(u,p)}}),{loaderData:i,errors:s}}function nn(e,t,r,a){let n=Object.entries(t).filter(([,o])=>o!==Vn).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 on(e){return e?ie(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function xe(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 ct(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 pe(e||500,i,new Error(s),!0)}function zt(e){let t=Object.entries(e);for(let r=t.length-1;r>=0;r--){let[a,n]=t[r];if(ze(n))return{key:a,result:n}}}function no(e){let t=typeof e=="string"?Pe(e):e;return he({...t,hash:""})}function Ol(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function Hr(e){return Response.json(e.data,e.init??void 0)}function Nl(e){return new pe(e.init?.status??500,e.init?.statusText??"Internal Server Error",e.data)}function Al(e){return e!=null&&typeof e=="object"&&Object.entries(e).every(([t,r])=>typeof t=="string"&&oo(r))}function oo(e){return e!=null&&typeof e=="object"&&"type"in e&&"result"in e&&(e.type==="data"||e.type==="error")}function io(e){return ee(e.result)&&zn.has(e.result.status)}function ie(e){return e.type==="error"}function ze(e){return(e&&e.type)==="redirect"}function We(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function ee(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function cr(e){return zn.has(e)}function er(e){return ee(e)&&cr(e.status)&&e.headers.has("Location")}function jr(e){return Cl.has(e.toUpperCase())}function de(e){return bl.has(e.toUpperCase())}function aa(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function ft(e,t){let r=typeof t=="string"?Pe(t).search:t.search;if(e[e.length-1].route.index&&aa(r||""))return e[e.length-1];let a=An(e);return a[a.length-1]}function ln(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 Dr(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 $l(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 xt(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 Il(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 Ne(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 Hl(e,t){try{let r=e.sessionStorage.getItem(Wn);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 jl(e,t){if(t.size>0){let r={};for(let[a,n]of t)r[a]=[...n];try{e.sessionStorage.setItem(Wn,JSON.stringify(r))}catch(a){X(!1,`Failed to save applied view transitions in sessionStorage (${a}).`)}}}function Ul(){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 Ie=d.createContext(null);Ie.displayName="DataRouter";var at=d.createContext(null);at.displayName="DataRouterState";var lo=d.createContext(!1);function zl(){return d.useContext(lo)}var dr=d.createContext({isTransitioning:!1});dr.displayName="ViewTransition";var fr=d.createContext(new Map);fr.displayName="Fetchers";var pt=d.createContext(null);pt.displayName="Await";var Sc=e=>d.createElement(pt.Provider,e),we=d.createContext(null);we.displayName="Navigation";var yt=d.createContext(null);yt.displayName="Location";var Re=d.createContext({outlet:null,matches:[],isDataRoute:!1});Re.displayName="Route";var na=d.createContext(null);na.displayName="RouteError";function Bl(e,{relative:t}={}){A(nt(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:a}=d.useContext(we),{hash:n,pathname:o,search:i}=Ot(e,{relative:t}),s=o;return r!=="/"&&(s=o==="/"?r:Me([r,o])),a.createHref({pathname:s,search:i,hash:n})}function nt(){return d.useContext(yt)!=null}function Ee(){return A(nt(),"useLocation() may be used only in the context of a <Router> component."),d.useContext(yt).location}function Cc(){return d.useContext(yt).navigationType}function xc(e){A(nt(),"useMatch() may be used only in the context of a <Router> component.");let{pathname:t}=Ee();return d.useMemo(()=>_t(e,Nn(t)),[t,e])}var so="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function uo(e){d.useContext(we).static||d.useLayoutEffect(e)}function oa(){let{isDataRoute:e}=d.useContext(Re);return e?as():Wl()}function Wl(){A(nt(),"useNavigate() may be used only in the context of a <Router> component.");let e=d.useContext(Ie),{basename:t,navigator:r}=d.useContext(we),{matches:a}=d.useContext(Re),{pathname:n}=Ee(),o=JSON.stringify(ir(a)),i=d.useRef(!1);return uo(()=>{i.current=!0}),d.useCallback((l,u={})=>{if(X(i.current,so),!i.current)return;if(typeof l=="number"){r.go(l);return}let c=lr(l,JSON.parse(o),n,u.relative==="path");e==null&&t!=="/"&&(c.pathname=c.pathname==="/"?t:Me([t,c.pathname])),(u.replace?r.replace:r.push)(c,u.state,u)},[t,r,o,n,e])}var co=d.createContext(null);function Pc(){return d.useContext(co)}function Vl(e){let t=d.useContext(Re).outlet;return d.useMemo(()=>t&&d.createElement(co.Provider,{value:e},t),[t,e])}function ia(){let{matches:e}=d.useContext(Re),t=e[e.length-1];return t?t.params:{}}function Ot(e,{relative:t}={}){let{matches:r}=d.useContext(Re),{pathname:a}=Ee(),n=JSON.stringify(ir(r));return d.useMemo(()=>lr(e,JSON.parse(n),a,t==="path"),[e,n,a,t])}function Yl(e,t){return la(e,t)}function la(e,t,r,a,n){A(nt(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=d.useContext(we),{matches:i}=d.useContext(Re),s=i[i.length-1],l=s?s.params:{},u=s?s.pathname:"/",c=s?s.pathnameBase:"/",f=s&&s.route;{let R=f&&f.path||"";ho(u,!f||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=Ee(),p;if(t){let R=typeof t=="string"?Pe(t):t;A(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 h=p.pathname||"/",g=h;if(c!=="/"){let R=c.replace(/^\//,"").split("/");g="/"+h.replace(/^\//,"").split("/").slice(R.length).join("/")}let y=ge(e,{pathname:g});X(f||y!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),X(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=fo(y&&y.map(R=>Object.assign({},R,{params:Object.assign({},l,R.params),pathname:Me([c,o.encodeLocation?o.encodeLocation(R.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathname]),pathnameBase:R.pathnameBase==="/"?c:Me([c,o.encodeLocation?o.encodeLocation(R.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathnameBase])})),i,r,a,n);return t&&w?d.createElement(yt.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},w):w}function Jl(){let e=hr(),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=d.createElement(d.Fragment,null,d.createElement("p",null,"💿 Hey developer 👋"),d.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",d.createElement("code",{style:o},"ErrorBoundary")," or"," ",d.createElement("code",{style:o},"errorElement")," prop on your route.")),d.createElement(d.Fragment,null,d.createElement("h2",null,"Unexpected Application Error!"),d.createElement("h3",{style:{fontStyle:"italic"}},t),r?d.createElement("pre",{style:n},r):null,i)}var Kl=d.createElement(Jl,null),Xl=class extends d.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.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?d.createElement(Re.Provider,{value:this.props.routeContext},d.createElement(na.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Gl({routeContext:e,match:t,children:r}){let a=d.useContext(Ie);return a&&a.static&&a.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=t.route.id),d.createElement(Re.Provider,{value:e},r)}function fo(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 u=o.findIndex(c=>c.route.id&&i?.[c.route.id]!==void 0);A(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,u+1))}let s=!1,l=-1;if(r)for(let u=0;u<o.length;u++){let c=o[u];if((c.route.HydrateFallback||c.route.hydrateFallbackElement)&&(l=u),c.route.id){let{loaderData:f,errors:m}=r,p=c.route.loader&&!f.hasOwnProperty(c.route.id)&&(!m||m[c.route.id]===void 0);if(c.route.lazy||p){s=!0,l>=0?o=o.slice(0,l+1):o=[o[0]];break}}}return o.reduceRight((u,c,f)=>{let m,p=!1,h=null,g=null;r&&(m=i&&c.route.id?i[c.route.id]:void 0,h=c.route.errorElement||Kl,s&&(l<0&&f===0?(ho("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),p=!0,g=null):l===f&&(p=!0,g=c.route.hydrateFallbackElement||null)));let y=t.concat(o.slice(0,f+1)),w=()=>{let R;return m?R=h:p?R=g:c.route.Component?R=d.createElement(c.route.Component,null):c.route.element?R=c.route.element:R=u,d.createElement(Gl,{match:c,routeContext:{outlet:u,matches:y,isDataRoute:r!=null},children:R})};return r&&(c.route.ErrorBoundary||c.route.errorElement||f===0)?d.createElement(Xl,{location:r.location,revalidation:r.revalidation,component:h,error:m,children:w(),routeContext:{outlet:null,matches:y,isDataRoute:!0},unstable_onError:a}):w()},null)}function sa(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ua(e){let t=d.useContext(Ie);return A(t,sa(e)),t}function He(e){let t=d.useContext(at);return A(t,sa(e)),t}function Ql(e){let t=d.useContext(Re);return A(t,sa(e)),t}function vt(e){let t=Ql(e),r=t.matches[t.matches.length-1];return A(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}function ql(){return vt("useRouteId")}function Zl(){return He("useNavigation").navigation}function Dc(){let e=ua("useRevalidator"),t=He("useRevalidator"),r=d.useCallback(async()=>{await e.router.revalidate()},[e.router]);return d.useMemo(()=>({revalidate:r,state:t.revalidation}),[r,t.revalidation])}function ca(){let{matches:e,loaderData:t}=He("useMatches");return d.useMemo(()=>e.map(r=>Mn(r,t)),[e,t])}function da(){let e=He("useLoaderData"),t=vt("useLoaderData");return e.loaderData[t]}function Lc(e){return He("useRouteLoaderData").loaderData[e]}function fa(){let e=He("useActionData"),t=vt("useLoaderData");return e.actionData?e.actionData[t]:void 0}function hr(){let e=d.useContext(na),t=He("useRouteError"),r=vt("useRouteError");return e!==void 0?e:t.errors?.[r]}function es(){return d.useContext(pt)?._data}function _c(){return d.useContext(pt)?._error}var ts=0;function rs(e){let{router:t,basename:r}=ua("useBlocker"),a=He("useBlocker"),[n,o]=d.useState(""),i=d.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 d.useEffect(()=>{let s=String(++ts);return o(s),()=>t.deleteBlocker(s)},[t]),d.useEffect(()=>{n!==""&&t.getBlocker(n,i)},[t,n,i]),n&&a.blockers.has(n)?a.blockers.get(n):tt}function as(){let{router:e}=ua("useNavigate"),t=vt("useNavigate"),r=d.useRef(!1);return uo(()=>{r.current=!0}),d.useCallback(async(n,o={})=>{X(r.current,so),r.current&&(typeof n=="number"?e.navigate(n):await e.navigate(n,{fromRouteId:t,...o}))},[e,t])}var sn={};function ho(e,t,r){!t&&!sn[e]&&(sn[e]=!0,X(!1,r))}function Tc(...e){const t=vt("useRoute"),r=e[0]??t,a=He("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 un={};function Mt(e,t){!e&&!un[t]&&(un[t]=!0,console.warn(t))}function gt(e){let t={hasErrorBoundary:e.hasErrorBoundary||e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&(e.element&&X(!1,"You should not include both `Component` and `element` on your route - `Component` will be used."),Object.assign(t,{element:d.createElement(e.Component),Component:void 0})),e.HydrateFallback&&(e.hydrateFallbackElement&&X(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."),Object.assign(t,{hydrateFallbackElement:d.createElement(e.HydrateFallback),HydrateFallback:void 0})),e.ErrorBoundary&&(e.errorElement&&X(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."),Object.assign(t,{errorElement:d.createElement(e.ErrorBoundary),ErrorBoundary:void 0})),t}var mr=["HydrateFallback","hydrateFallbackElement"];function ns(e,t){return ur({basename:t?.basename,getContext:t?.getContext,future:t?.future,history:Dn({initialEntries:t?.initialEntries,initialIndex:t?.initialIndex}),hydrationData:t?.hydrationData,routes:e,hydrationRouteProperties:mr,mapRouteProperties:gt,dataStrategy:t?.dataStrategy,patchRoutesOnNavigation:t?.patchRoutesOnNavigation,unstable_instrumentations:t?.unstable_instrumentations}).initialize()}var os=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 mo({router:e,flushSync:t,unstable_onError:r}){let[a,n]=d.useState(e.state),[o,i]=d.useState(),[s,l]=d.useState({isTransitioning:!1}),[u,c]=d.useState(),[f,m]=d.useState(),[p,h]=d.useState(),g=d.useRef(new Map),y=d.useCallback(P=>{n(D=>(P.errors&&r&&Object.entries(P.errors).forEach(([E,F])=>{D.errors?.[E]!==F&&r(F)}),P))},[r]),w=d.useCallback((P,{deletedFetchers:D,flushSync:E,viewTransitionOpts:F})=>{P.fetchers.forEach((M,N)=>{M.data!==void 0&&g.current.set(N,M.data)}),D.forEach(M=>g.current.delete(M)),Mt(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 T=e.window!=null&&e.window.document!=null&&typeof e.window.document.startViewTransition=="function";if(Mt(F==null||T,"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."),!F||!T){t&&E?t(()=>y(P)):d.startTransition(()=>y(P));return}if(t&&E){t(()=>{f&&(u&&u.resolve(),f.skipTransition()),l({isTransitioning:!0,flushSync:!0,currentLocation:F.currentLocation,nextLocation:F.nextLocation})});let M=e.window.document.startViewTransition(()=>{t(()=>y(P))});M.finished.finally(()=>{t(()=>{c(void 0),m(void 0),i(void 0),l({isTransitioning:!1})})}),t(()=>m(M));return}f?(u&&u.resolve(),f.skipTransition(),h({state:P,currentLocation:F.currentLocation,nextLocation:F.nextLocation})):(i(P),l({isTransitioning:!0,flushSync:!1,currentLocation:F.currentLocation,nextLocation:F.nextLocation}))},[e.window,t,f,u,y]);d.useLayoutEffect(()=>e.subscribe(w),[e,w]),d.useEffect(()=>{s.isTransitioning&&!s.flushSync&&c(new os)},[s]),d.useEffect(()=>{if(u&&o&&e.window){let P=o,D=u.promise,E=e.window.document.startViewTransition(async()=>{d.startTransition(()=>y(P)),await D});E.finished.finally(()=>{c(void 0),m(void 0),i(void 0),l({isTransitioning:!1})}),m(E)}},[o,u,e.window,y]),d.useEffect(()=>{u&&o&&a.location.key===o.location.key&&u.resolve()},[u,f,a.location,o]),d.useEffect(()=>{!s.isTransitioning&&p&&(i(p.state),l({isTransitioning:!0,flushSync:!1,currentLocation:p.currentLocation,nextLocation:p.nextLocation}),h(void 0))},[s.isTransitioning,p]);let R=d.useMemo(()=>({createHref:e.createHref,encodeLocation:e.encodeLocation,go:P=>e.navigate(P),push:(P,D,E)=>e.navigate(P,{state:D,preventScrollReset:E?.preventScrollReset}),replace:(P,D,E)=>e.navigate(P,{replace:!0,state:D,preventScrollReset:E?.preventScrollReset})}),[e]),C=e.basename||"/",x=d.useMemo(()=>({router:e,navigator:R,static:!1,basename:C,unstable_onError:r}),[e,R,C,r]);return d.createElement(d.Fragment,null,d.createElement(Ie.Provider,{value:x},d.createElement(at.Provider,{value:a},d.createElement(fr.Provider,{value:g.current},d.createElement(dr.Provider,{value:s},d.createElement(ot,{basename:C,location:a.location,navigationType:a.historyAction,navigator:R},d.createElement(is,{routes:e.routes,future:e.future,state:a,unstable_onError:r})))))),null)}var is=d.memo(ls);function ls({routes:e,future:t,state:r,unstable_onError:a}){return la(e,void 0,r,a,t)}function Mc({basename:e,children:t,initialEntries:r,initialIndex:a}){let n=d.useRef();n.current==null&&(n.current=Dn({initialEntries:r,initialIndex:a,v5Compat:!0}));let o=n.current,[i,s]=d.useState({action:o.action,location:o.location}),l=d.useCallback(u=>{d.startTransition(()=>s(u))},[s]);return d.useLayoutEffect(()=>o.listen(l),[o,l]),d.createElement(ot,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:o})}function Fc({to:e,replace:t,state:r,relative:a}){A(nt(),"<Navigate> may be used only in the context of a <Router> component.");let{static:n}=d.useContext(we);X(!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}=d.useContext(Re),{pathname:i}=Ee(),s=oa(),l=lr(e,ir(o),i,a==="path"),u=JSON.stringify(l);return d.useEffect(()=>{s(JSON.parse(u),{replace:t,state:r,relative:a})},[s,u,a,t,r]),null}function ss(e){return Vl(e.context)}function us(e){A(!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 ot({basename:e="/",children:t=null,location:r,navigationType:a="POP",navigator:n,static:o=!1}){A(!nt(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),s=d.useMemo(()=>({basename:i,navigator:n,static:o,future:{}}),[i,n,o]);typeof r=="string"&&(r=Pe(r));let{pathname:l="/",search:u="",hash:c="",state:f=null,key:m="default"}=r,p=d.useMemo(()=>{let h=ne(l,i);return h==null?null:{location:{pathname:h,search:u,hash:c,state:f,key:m},navigationType:a}},[i,l,u,c,f,m,a]);return X(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:d.createElement(we.Provider,{value:s},d.createElement(yt.Provider,{children:t,value:p}))}function kc({children:e,location:t}){return Yl(tr(e),t)}function Oc({children:e,errorElement:t,resolve:r}){let a=d.useContext(Ie);return d.createElement(cs,{resolve:r,errorElement:t,unstable_onError:a?.unstable_onError},d.createElement(ds,null,e))}var cs=class extends d.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.unstable_onError?this.props.unstable_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.unstable_onError?.(o),Object.defineProperty(r,"_error",{get:()=>o})}));if(n===2&&!t)throw a._error;if(n===2)return d.createElement(pt.Provider,{value:a,children:t});if(n===1)return d.createElement(pt.Provider,{value:a,children:e});throw a}};function ds({children:e}){let t=es(),r=typeof e=="function"?e(t):e;return d.createElement(d.Fragment,null,r)}function tr(e,t=[]){let r=[];return d.Children.forEach(e,(a,n)=>{if(!d.isValidElement(a))return;let o=[...t,n];if(a.type===d.Fragment){r.push.apply(r,tr(a.props.children,o));return}A(a.type===us,`[${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>`),A(!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=tr(a.props.children,o)),r.push(i)}),r}var Nc=tr;function Ac(e){return fo(e)}function po(){return{params:ia(),loaderData:da(),actionData:fa(),matches:ca()}}function $c({children:e}){const t=po();return d.cloneElement(e,t)}function fs(e){return function(){const r=po();return d.createElement(e,r)}}function yo(){return{params:ia(),loaderData:da(),actionData:fa()}}function Ic({children:e}){const t=yo();return d.cloneElement(e,t)}function hs(e){return function(){const r=yo();return d.createElement(e,r)}}function vo(){return{params:ia(),loaderData:da(),actionData:fa(),error:hr()}}function Hc({children:e}){const t=vo();return d.cloneElement(e,t)}function ms(e){return function(){const r=vo();return d.createElement(e,r)}}var Xt="get",Gt="application/x-www-form-urlencoded";function pr(e){return e!=null&&typeof e.tagName=="string"}function ps(e){return pr(e)&&e.tagName.toLowerCase()==="button"}function ys(e){return pr(e)&&e.tagName.toLowerCase()==="form"}function vs(e){return pr(e)&&e.tagName.toLowerCase()==="input"}function gs(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ws(e,t){return e.button===0&&(!t||t==="_self")&&!gs(e)}function Ur(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 Rs(e,t){let r=Ur(e);return t&&t.forEach((a,n)=>{r.has(n)||t.getAll(n).forEach(o=>{r.append(n,o)})}),r}var Bt=null;function Es(){if(Bt===null)try{new FormData(document.createElement("form"),0),Bt=!1}catch{Bt=!0}return Bt}var bs=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Lr(e){return e!=null&&!bs.has(e)?(X(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Gt}"`),null):e}function Ss(e,t){let r,a,n,o,i;if(ys(e)){let s=e.getAttribute("action");a=s?ne(s,t):null,r=e.getAttribute("method")||Xt,n=Lr(e.getAttribute("enctype"))||Gt,o=new FormData(e)}else if(ps(e)||vs(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")||Xt,n=Lr(e.getAttribute("formenctype"))||Lr(s.getAttribute("enctype"))||Gt,o=new FormData(s,e),!Es()){let{name:u,type:c,value:f}=e;if(c==="image"){let m=u?`${u}.`:"";o.append(`${m}x`,"0"),o.append(`${m}y`,"0")}else u&&o.append(u,f)}}else{if(pr(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=Xt,a=null,n=Gt,i=e}return o&&n==="text/plain"&&(i=o,o=void 0),{action:a,method:r.toLowerCase(),encType:n,formData:o,body:i}}var go=-1,wo=-2,Ro=-3,Eo=-4,ha=-5,bo=-6,So=-7,Co="B",xo="D",ht="E",zr="M",Po="N",mt="P",Do="R",Br="S",Lo="Y",_o="U",Wr="Z",To=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}};function Cs(){const e=new TextDecoder;let t="";return new TransformStream({transform(r,a){const n=e.decode(r,{stream:!0}),o=(t+n).split(`
|