@mcp-use/inspector 0.13.0-canary.6 → 0.13.0-canary.8

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.
Files changed (38) hide show
  1. package/dist/cli.js +11 -3
  2. package/dist/client/assets/{browser-BoLKWpwz.js → browser-C25bUfYp.js} +42 -42
  3. package/dist/client/assets/{display-A5IEINAP-BY84EJZk.js → display-A5IEINAP-ByZ9IIJl.js} +2 -2
  4. package/dist/client/assets/{embeddings-8blUtIbt.js → embeddings-CgzAByVu.js} +1 -1
  5. package/dist/client/assets/index-9hzrT5HP.js +7 -0
  6. package/dist/client/assets/{index-CSlqw8-V.js → index-BRrjjTR6.js} +1 -1
  7. package/dist/client/assets/{index-DPD9iyF6.js → index-CEBAtJQV.js} +1 -1
  8. package/dist/client/assets/{index-DOp47eHE.js → index-DPEqrSDR.js} +1 -1
  9. package/dist/client/assets/{index-BAK37pc4.js → index-DTt5KCEV.js} +1 -1
  10. package/dist/client/assets/{index-olcjmwjt.js → index-Ddy9yyxP.js} +1 -1
  11. package/dist/client/assets/{index-CsvzhAm-.js → index-Dq7UrqnC.js} +1 -1
  12. package/dist/client/assets/index-FyLdp58J.js +1707 -0
  13. package/dist/client/assets/{index-DwpYRN9f.js → index-VOipG1yN.js} +2 -2
  14. package/dist/client/assets/langfuse-74RGPTAH-ThX8caF_.js +1 -0
  15. package/dist/client/assets/{path-B4GZD74M.js → path-C8e-fwNk.js} +1 -1
  16. package/dist/client/assets/{winston-BtMmKlI5.js → winston-7dQlPZMw.js} +1 -1
  17. package/dist/client/index.html +2 -2
  18. package/dist/server/{chunk-V5FEV5SU.js → chunk-67ROKQZG.js} +36 -4
  19. package/dist/server/{chunk-PBQJCPZX.js → chunk-OS2WTNLR.js} +3 -3
  20. package/dist/server/{chunk-XU7SXB3C.js → chunk-WLIY2SQG.js} +1 -1
  21. package/dist/server/{chunk-LNMQYGXR.js → chunk-YLX7JQDX.js} +1 -1
  22. package/dist/server/{chunk-KW44WB52.js → chunk-Z5QIR3IS.js} +11 -3
  23. package/dist/server/cli.js +4 -4
  24. package/dist/server/index.js +5 -5
  25. package/dist/server/middleware.js +5 -5
  26. package/dist/server/server.js +4 -4
  27. package/dist/server/shared-routes.js +2 -2
  28. package/dist/server/shared-static.js +2 -2
  29. package/dist/server/shared-utils-browser.d.ts +1 -0
  30. package/dist/server/shared-utils-browser.d.ts.map +1 -1
  31. package/dist/server/shared-utils-browser.js +1 -1
  32. package/dist/server/shared-utils.d.ts +1 -0
  33. package/dist/server/shared-utils.d.ts.map +1 -1
  34. package/dist/server/shared-utils.js +1 -1
  35. package/package.json +4 -4
  36. package/dist/client/assets/index-BAxAv6UE.js +0 -1676
  37. package/dist/client/assets/index-jb1lbUp7.js +0 -40
  38. package/dist/client/assets/langfuse-74RGPTAH-YjoHS_KH.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BAK37pc4.js","assets/index-BAxAv6UE.js","assets/index-beDRbW3x.css"])))=>i.map(i=>d[i]);
2
- import{_ as a,a as k}from"./index-BAxAv6UE.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-BAK37pc4.js").then(e=>e.i),__vite__mapDeps([0,1,2]))).highlight}catch{}V&&(!y||!L)&&(J||(J=!0,console.warn(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DTt5KCEV.js","assets/index-FyLdp58J.js","assets/index-beDRbW3x.css"])))=>i.map(i=>d[i]);
2
+ import{_ as a,a as k}from"./index-FyLdp58J.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-DTt5KCEV.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-DOp47eHE.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
+ import{_ as c,A as d}from"./index-DPEqrSDR.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};
@@ -0,0 +1,7 @@
1
+ import{c as Ne,s as q,b as he,r as E,F as X,R as Ue,S as pe,d as Le,u as Oe,e as C,E as H,m as me,f as j,h as Ie,i as Be,j as Me,k as ze,l as ye,n as _,w as we,o as je,q as $e,t as Ve,v as We,x as qe,O as Xe,y as Je,z as Ke,A as T,B as Qe,C as Ge,D as Ye,G as N,H as Ze,I as Y,J as et,K as J,L as D,M as tt,N as rt,P as at,Q as nt}from"./index-FyLdp58J.js";import{T as or,U as ir,V as lr,W as ur,X as dr,Y as cr,Z as fr,$ as hr,a0 as pr,a1 as mr,a2 as yr,a3 as wr,a4 as Rr,a5 as gr,a6 as Sr,a7 as vr,a8 as Er,a9 as Cr,aa as br,ab as _r,ac as xr,ad as Dr,ae as Ar,af as kr,ag as Fr,ah as Hr,ai as Tr,aj as Pr,ak as Nr,al as Ur,am as Lr,an as Or,ao as Ir,ap as Br,aq as Mr,ar as zr,as as jr,at as $r,au as Vr,av as Wr,aw as qr,ax as Xr,ay as Jr,az as Kr,aA as Qr,aB as Gr,aC as Yr,aD as Zr,aE as ea,aF as ta,aG as ra,aH as aa,aI as na,aJ as sa,aK as oa,aL as ia,aM as la,aN as ua,aO as da,aP as ca,aQ as fa,aR as ha,aS as pa,aT as ma,aU as ya,aV as wa,aW as Ra,aX as ga,aY as Sa,aZ as va,a_ as Ea,a$ as Ca,b0 as ba,b1 as _a,b2 as xa,b3 as Da,b4 as Aa,b5 as ka,b6 as Fa,b7 as Ha,b8 as Ta,b9 as Pa,ba as Na,bb as Ua,bc as La,bd as Oa,be as Ia,bf as Ba}from"./index-FyLdp58J.js";var F={},Z;function st(){if(Z)return F;Z=1,Object.defineProperty(F,"__esModule",{value:!0}),F.parse=d,F.serialize=i;const e=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,r=/^[\u0021-\u003A\u003C-\u007E]*$/,t=/^([.]?[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]*$/,s=Object.prototype.toString,o=(()=>{const c=function(){};return c.prototype=Object.create(null),c})();function d(c,y){const f=new o,p=c.length;if(p<2)return f;const w=y?.decode||l;let m=0;do{const R=c.indexOf("=",m);if(R===-1)break;const g=c.indexOf(";",m),S=g===-1?p:g;if(R>S){m=c.lastIndexOf(";",R-1)+1;continue}const v=u(c,m,R),G=n(c,R,v),k=c.slice(v,G);if(f[k]===void 0){let b=u(c,R+1,S),Te=n(c,S,b);const Pe=w(c.slice(b,Te));f[k]=Pe}m=S+1}while(m<p);return f}function u(c,y,f){do{const p=c.charCodeAt(y);if(p!==32&&p!==9)return y}while(++y<f);return f}function n(c,y,f){for(;y>f;){const p=c.charCodeAt(--y);if(p!==32&&p!==9)return y+1}return f}function i(c,y,f){const p=f?.encode||encodeURIComponent;if(!e.test(c))throw new TypeError(`argument name is invalid: ${c}`);const w=p(y);if(!r.test(w))throw new TypeError(`argument val is invalid: ${y}`);let m=c+"="+w;if(!f)return m;if(f.maxAge!==void 0){if(!Number.isInteger(f.maxAge))throw new TypeError(`option maxAge is invalid: ${f.maxAge}`);m+="; Max-Age="+f.maxAge}if(f.domain){if(!t.test(f.domain))throw new TypeError(`option domain is invalid: ${f.domain}`);m+="; Domain="+f.domain}if(f.path){if(!a.test(f.path))throw new TypeError(`option path is invalid: ${f.path}`);m+="; Path="+f.path}if(f.expires){if(!h(f.expires)||!Number.isFinite(f.expires.valueOf()))throw new TypeError(`option expires is invalid: ${f.expires}`);m+="; Expires="+f.expires.toUTCString()}if(f.httpOnly&&(m+="; HttpOnly"),f.secure&&(m+="; Secure"),f.partitioned&&(m+="; Partitioned"),f.priority)switch(typeof f.priority=="string"?f.priority.toLowerCase():void 0){case"low":m+="; Priority=Low";break;case"medium":m+="; Priority=Medium";break;case"high":m+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${f.priority}`)}if(f.sameSite)switch(typeof f.sameSite=="string"?f.sameSite.toLowerCase():f.sameSite){case!0:case"strict":m+="; SameSite=Strict";break;case"lax":m+="; SameSite=Lax";break;case"none":m+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${f.sameSite}`)}return m}function l(c){if(c.indexOf("%")===-1)return c;try{return decodeURIComponent(c)}catch{return c}}function h(c){return s.call(c)==="[object Date]"}return F}var ee=st(),A={exports:{}},te;function ot(){if(te)return A.exports;te=1;var e={decodeValues:!0,map:!1,silent:!1};function r(n){return typeof n!="string"||n in{}}function t(){return Object.create(null)}function a(n){return typeof n=="string"&&!!n.trim()}function s(n,i){var l=n.split(";").filter(a),h=l.shift(),c=o(h),y=c.name,f=c.value;if(i=i?Object.assign({},e,i):e,r(y))return null;try{f=i.decodeValues?decodeURIComponent(f):f}catch(w){console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",w)}var p=t();return p.name=y,p.value=f,l.forEach(function(w){var m=w.split("="),R=m.shift().trimLeft().toLowerCase();if(!r(R)){var g=m.join("=");if(R==="expires")p.expires=new Date(g);else if(R==="max-age"){var S=parseInt(g,10);Number.isNaN(S)||(p.maxAge=S)}else R==="secure"?p.secure=!0:R==="httponly"?p.httpOnly=!0:R==="samesite"?p.sameSite=g:R==="partitioned"?p.partitioned=!0:R&&(p[R]=g)}}),p}function o(n){var i="",l="",h=n.split("=");return h.length>1?(i=h.shift(),l=h.join("=")):l=n,{name:i,value:l}}function d(n,i){if(i=i?Object.assign({},e,i):e,!n)return i.map?t():[];if(n.headers)if(typeof n.headers.getSetCookie=="function")n=n.headers.getSetCookie();else if(n.headers["set-cookie"])n=n.headers["set-cookie"];else{var l=n.headers[Object.keys(n.headers).find(function(c){return c.toLowerCase()==="set-cookie"})];!l&&n.headers.cookie&&!i.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."),n=l}if(Array.isArray(n)||(n=[n]),i.map){var h=t();return n.filter(a).reduce(function(c,y){var f=s(y,i);return f&&!r(f.name)&&(c[f.name]=f),c},h)}else return n.filter(a).map(function(c){return s(c,i)}).filter(Boolean)}function u(n){if(Array.isArray(n))return n;if(typeof n!="string")return[];var i=[],l=0,h,c,y,f,p;function w(){for(;l<n.length&&/\s/.test(n.charAt(l));)l+=1;return l<n.length}function m(){return c=n.charAt(l),c!=="="&&c!==";"&&c!==","}for(;l<n.length;){for(h=l,p=!1;w();)if(c=n.charAt(l),c===","){for(y=l,l+=1,w(),f=l;l<n.length&&m();)l+=1;l<n.length&&n.charAt(l)==="="?(p=!0,l=f,i.push(n.substring(h,y)),h=l):l=y+1}else l+=1;(!p||l>=n.length)&&i.push(n.substring(h,n.length))}return i}return A.exports=d,A.exports.parse=d,A.exports.parseString=s,A.exports.splitCookiesString=u,A.exports}var it=ot(),lt={};function Wt({context:e,url:r,nonce:t}){typeof r=="string"&&(r=new URL(r));let{manifest:a,routeModules:s,criticalCss:o,serverHandoffString:d}=e,u=Ne(a.routes,s,e.future,e.isSpaMode);e.staticHandlerContext.loaderData={...e.staticHandlerContext.loaderData};for(let i of e.staticHandlerContext.matches){let l=i.route.id,h=s[l],c=e.manifest.routes[l];h&&c&&q(l,h.clientLoader,c.hasLoader,e.isSpaMode)&&(h.HydrateFallback||!c.hasLoader)&&delete e.staticHandlerContext.loaderData[l]}let n=he(u,e.staticHandlerContext);return E.createElement(E.Fragment,null,E.createElement(X.Provider,{value:{manifest:a,routeModules:s,criticalCss:o,serverHandoffString:d,future:e.future,ssr:e.ssr,isSpaMode:e.isSpaMode,routeDiscovery:e.routeDiscovery,serializeError:e.serializeError,renderMeta:e.renderMeta}},E.createElement(Ue,{location:n.state.location},E.createElement(pe,{router:n,context:e.staticHandlerContext,hydrate:!1}))),e.serverHandoffStream?E.createElement(E.Suspense,null,E.createElement(Le,{context:e,identifier:0,reader:e.serverHandoffStream.getReader(),textDecoder:new TextDecoder,nonce:t})):null)}function qt(e,r){return function({initialEntries:a,initialIndex:s,hydrationData:o,future:d}){let u=E.useRef(),n=E.useRef();if(u.current==null){n.current={future:{unstable_subResourceIntegrity:d?.unstable_subResourceIntegrity===!0,v8_middleware:d?.v8_middleware===!0},manifest:{routes:{},entry:{imports:[],module:""},url:"",version:""},routeModules:{},ssr:!1,isSpaMode:!1,routeDiscovery:{mode:"lazy",manifestPath:"/__manifest"}};let i=Re(Ie(e,l=>l),r!==void 0?r:d?.v8_middleware?new j:{},n.current.manifest,n.current.routeModules);u.current=Be(i,{initialEntries:a,initialIndex:s,hydrationData:o})}return E.createElement(X.Provider,{value:n.current},E.createElement(Me,{router:u.current}))}}function Re(e,r,t,a,s){return e.map(o=>{if(!o.id)throw new Error("Expected a route.id in react-router processRoutes() function");let d={id:o.id,path:o.path,index:o.index,Component:o.Component?qe(o.Component):void 0,HydrateFallback:o.HydrateFallback?We(o.HydrateFallback):void 0,ErrorBoundary:o.ErrorBoundary?Ve(o.ErrorBoundary):void 0,action:o.action?n=>o.action({...n,context:r}):void 0,loader:o.loader?n=>o.loader({...n,context:r}):void 0,middleware:o.middleware?o.middleware.map(n=>(...i)=>n({...i[0],context:r},i[1])):void 0,handle:o.handle,shouldRevalidate:o.shouldRevalidate},u={id:o.id,path:o.path,index:o.index,parentId:s,hasAction:o.action!=null,hasLoader:o.loader!=null,hasClientAction:!1,hasClientLoader:!1,hasClientMiddleware:!1,hasErrorBoundary:o.ErrorBoundary!=null,module:"build/stub-path-to-module.js",clientActionModule:void 0,clientLoaderModule:void 0,clientMiddlewareModule:void 0,hydrateFallbackModule:void 0};return t.routes[d.id]=u,a[o.id]={default:d.Component||Xe,ErrorBoundary:d.ErrorBoundary||void 0,handle:o.handle,links:o.links,meta:o.meta,shouldRevalidate:o.shouldRevalidate},o.children&&(d.children=Re(o.children,r,t,a,d.id)),d})}var K=new TextEncoder,ut=async(e,r)=>{let t=K.encode(e),a=await ge(r,["sign"]),s=await crypto.subtle.sign("HMAC",a,t),o=btoa(String.fromCharCode(...new Uint8Array(s))).replace(/=+$/,"");return e+"."+o},dt=async(e,r)=>{let t=e.lastIndexOf("."),a=e.slice(0,t),s=e.slice(t+1),o=K.encode(a),d=await ge(r,["verify"]);try{let u=ct(atob(s));return await crypto.subtle.verify("HMAC",d,u,o)?a:!1}catch{return!1}},ge=async(e,r)=>crypto.subtle.importKey("raw",K.encode(e),{name:"HMAC",hash:"SHA-256"},!1,r);function ct(e){let r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r}var Se=(e,r={})=>{let{secrets:t=[],...a}={path:"/",sameSite:"lax",...r};return wt(e,a.expires),{get name(){return e},get isSigned(){return t.length>0},get expires(){return typeof a.maxAge<"u"?new Date(Date.now()+a.maxAge*1e3):a.expires},async parse(s,o){if(!s)return null;let d=ee.parse(s,{...a,...o});if(e in d){let u=d[e];return typeof u=="string"&&u!==""?await ht(u,t):""}else return null},async serialize(s,o){return ee.serialize(e,s===""?"":await ft(s,t),{...a,...o})}}},ve=e=>e!=null&&typeof e.name=="string"&&typeof e.isSigned=="boolean"&&typeof e.parse=="function"&&typeof e.serialize=="function";async function ft(e,r){let t=pt(e);return r.length>0&&(t=await ut(t,r[0])),t}async function ht(e,r){if(r.length>0){for(let t of r){let a=await dt(e,t);if(a!==!1)return re(a)}return null}return re(e)}function pt(e){return btoa(yt(encodeURIComponent(JSON.stringify(e))))}function re(e){try{return JSON.parse(decodeURIComponent(mt(atob(e))))}catch{return{}}}function mt(e){let r=e.toString(),t="",a=0,s,o;for(;a<r.length;)s=r.charAt(a++),/[\w*+\-./@]/.exec(s)?t+=s:(o=s.charCodeAt(0),o<256?t+="%"+ae(o,2):t+="%u"+ae(o,4).toUpperCase());return t}function ae(e,r){let t=e.toString(16);for(;t.length<r;)t="0"+t;return t}function yt(e){let r=e.toString(),t="",a=0,s,o;for(;a<r.length;){if(s=r.charAt(a++),s==="%"){if(r.charAt(a)==="u"){if(o=r.slice(a+1,a+5),/^[\da-f]{4}$/i.exec(o)){t+=String.fromCharCode(parseInt(o,16)),a+=5;continue}}else if(o=r.slice(a,a+2),/^[\da-f]{2}$/i.exec(o)){t+=String.fromCharCode(parseInt(o,16)),a+=2;continue}}t+=s}return t}function wt(e,r){we(!r,`The "${e}" cookie has an "expires" property set. This will cause the expires value to not be updated when the session is committed. Instead, you should set the expires value when serializing the cookie. You can use \`commitSession(session, { expires })\` if using a session storage object, or \`cookie.serialize("value", { expires })\` if you're using the cookie directly.`)}function Rt(e){return Object.keys(e).reduce((r,t)=>{let a=e[t];return a&&(r[t]=a.module),r},{})}var gt=(e=>(e.Development="development",e.Production="production",e.Test="test",e))(gt||{});function St(e){return e==="development"||e==="production"||e==="test"}function I(e,r){if(e instanceof Error&&r!=="development"){let t=new Error("Unexpected Server Error");return t.stack=void 0,t}return e}function L(e,r){return Object.entries(e).reduce((t,[a,s])=>Object.assign(t,{[a]:I(s,r)}),{})}function Ee(e,r){let t=I(e,r);return{message:t.message,stack:t.stack}}function ne(e,r){if(!e)return null;let t=Object.entries(e),a={};for(let[s,o]of t)if(_(o))a[s]={...o,__type:"RouteErrorResponse"};else if(o instanceof Error){let d=I(o,r);a[s]={message:d.message,stack:d.stack,__type:"Error",...d.name!=="Error"?{__subType:d.name}:{}}}else a[s]=o;return a}function $(e,r,t){let a=me(e,r,t);return a?a.map(s=>({params:s.params,pathname:s.pathname,route:s.route})):null}async function se(e,r){let t=await e({request:Et(vt(r.request)),params:r.params,context:r.context,unstable_pattern:r.unstable_pattern});if(et(t)&&t.init&&t.init.status&&J(t.init.status))throw new Response(null,t.init);return t}function vt(e){let r=new URL(e.url),t=r.searchParams.getAll("index");r.searchParams.delete("index");let a=[];for(let o of t)o&&a.push(o);for(let o of a)r.searchParams.append("index",o);let s={method:e.method,body:e.body,headers:e.headers,signal:e.signal};return s.body&&(s.duplex="half"),new Request(r.href,s)}function Et(e){let r=new URL(e.url);r.searchParams.delete("_routes");let t={method:e.method,body:e.body,headers:e.headers,signal:e.signal};return t.body&&(t.duplex="half"),new Request(r.href,t)}function U(e,r){if(e===!1||e===null||typeof e>"u")throw console.error("The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"),new Error(r)}var Ce="__reactRouterDevServerHooks";function Xt(e){globalThis[Ce]=e}function B(){return globalThis[Ce]}function be(e,r){if(typeof process<"u")try{if(lt?.IS_RR_BUILD_REQUEST==="yes")return e.headers.get(r)}catch{}return null}function _e(e){let r={};return Object.values(e).forEach(t=>{if(t){let a=t.parentId||"";r[a]||(r[a]=[]),r[a].push(t)}}),r}function xe(e,r="",t=_e(e)){return(t[r]||[]).map(a=>({...a,children:xe(e,a.id,t)}))}function De(e,r,t="",a=_e(e)){return(a[t]||[]).map(s=>{let o={hasErrorBoundary:s.id==="root"||s.module.ErrorBoundary!=null,id:s.id,path:s.path,middleware:s.module.middleware,loader:s.module.loader?async d=>{let u=be(d.request,"X-React-Router-Prerender-Data");if(u!=null){let i=u&&decodeURI(u);U(i,"Missing prerendered data for route");let l=new TextEncoder().encode(i),h=new ReadableStream({start(f){f.enqueue(l),f.close()}}),y=(await Ke(h,globalThis)).value;if(y&&T in y){let f=y[T],p={status:f.status};throw f.reload?Qe(f.redirect,p):f.replace?Ge(f.redirect,p):Ye(f.redirect,p)}else{U(y&&s.id in y,"Unable to decode prerendered data");let f=y[s.id];return U("data"in f,"Unable to process prerendered data"),f.data}}return await se(s.module.loader,d)}:void 0,action:s.module.action?d=>se(s.module.action,d):void 0,handle:s.module.handle};return s.index?{index:!0,...o}:{caseSensitive:s.caseSensitive,children:De(e,r,s.id,a),...o}})}function oe(e){return nt(JSON.stringify(e))}function Q(e,r){return Ct(e,t=>{let a=r.routes[t.route.id];return U(a,`Route with id "${t.route.id}" not found in build`),a.module.headers})}function Ct(e,r,t){let a=e.errors?e.matches.findIndex(u=>e.errors[u.route.id]):-1,s=a>=0?e.matches.slice(0,a+1):e.matches,o;if(a>=0){let{actionHeaders:u,actionData:n,loaderHeaders:i,loaderData:l}=e;e.matches.slice(a).some(h=>{let c=h.route.id;return u[c]&&(!n||!n.hasOwnProperty(c))?o=u[c]:i[c]&&!l.hasOwnProperty(c)&&(o=i[c]),o!=null})}const d=new Headers(t);return s.reduce((u,n,i)=>{let{id:l}=n.route,h=e.loaderHeaders[l]||new Headers,c=e.actionHeaders[l]||new Headers,y=o!=null&&i===s.length-1,f=y&&o!==h&&o!==c,p=r(n);if(p==null){let m=new Headers(u);return f&&x(o,m),x(c,m),x(h,m),m}let w=new Headers(typeof p=="function"?p({loaderHeaders:h,parentHeaders:u,actionHeaders:c,errorHeaders:y?o:void 0}):p);return f&&x(o,w),x(c,w),x(h,w),x(u,w),w},new Headers(d))}function x(e,r){let t=e.get("Set-Cookie");if(t){let a=it.splitCookiesString(t),s=new Set(r.getSetCookie());a.forEach(o=>{s.has(o)||r.append("Set-Cookie",o)})}}var Ae=new Set([...rt,304]);async function bt(e,r,t,a,s,o,d){try{let l=new Request(s,{method:a.method,body:a.body,headers:a.headers,signal:a.signal,...a.body?{duplex:"half"}:void 0}),h=await t.query(l,{requestContext:o,skipLoaderErrorBubbling:!0,skipRevalidation:!0,generateMiddlewareResponse:e.future.v8_middleware?async c=>{try{let y=await c(l);return u(y)}catch(y){return n(y)}}:void 0});return u(h)}catch(l){return n(l)}function u(l){return D(l)?l:i(l)}function n(l){return d(l),P(a,e,r,{result:{error:l},headers:new Headers,status:500})}function i(l){let h=Q(l,e);if(J(l.statusCode)&&h.has("Location"))return new Response(null,{status:l.statusCode,headers:h});l.errors&&(Object.values(l.errors).forEach(y=>{(!_(y)||y.error)&&d(y)}),l.errors=L(l.errors,r));let c;return l.errors?c={error:Object.values(l.errors)[0]}:c={data:Object.values(l.actionData||{})[0]},P(a,e,r,{result:c,headers:h,status:l.statusCode})}}async function _t(e,r,t,a,s,o,d){let u=new URL(a.url).searchParams.get("_routes"),n=u?new Set(u.split(",")):null;try{let c=new Request(s,{headers:a.headers,signal:a.signal}),y=await t.query(c,{requestContext:o,filterMatchesToLoad:f=>!n||n.has(f.route.id),skipLoaderErrorBubbling:!0,generateMiddlewareResponse:e.future.v8_middleware?async f=>{try{let p=await f(c);return i(p)}catch(p){return l(p)}}:void 0});return i(y)}catch(c){return l(c)}function i(c){return D(c)?c:h(c)}function l(c){return d(c),P(a,e,r,{result:{error:c},headers:new Headers,status:500})}function h(c){let y=Q(c,e);if(J(c.statusCode)&&y.has("Location"))return new Response(null,{status:c.statusCode,headers:y});c.errors&&(Object.values(c.errors).forEach(w=>{(!_(w)||w.error)&&d(w)}),c.errors=L(c.errors,r));let f={},p=new Set(c.matches.filter(w=>n?n.has(w.route.id):w.route.loader!=null).map(w=>w.route.id));if(c.errors)for(let[w,m]of Object.entries(c.errors))f[w]={error:m};for(let[w,m]of Object.entries(c.loaderData))!(w in f)&&p.has(w)&&(f[w]={data:m});return P(a,e,r,{result:f,headers:y,status:c.statusCode})}}function P(e,r,t,{result:a,headers:s,status:o}){let d=new Headers(s);return d.set("X-Remix-Response","yes"),Ae.has(o)?new Response(null,{status:o,headers:d}):(d.set("Content-Type","text/x-script"),d.delete("Content-Length"),new Response(V(a,e.signal,r.entry.module.streamTimeout,t),{status:o||200,headers:d}))}function ie(e,r,t,a){let s=xt(e.status,e.headers,t.basename),o=new Headers(e.headers);return o.delete("Location"),o.set("Content-Type","text/x-script"),P(r,t,a,{result:r.method==="GET"?{[T]:s}:s,headers:o,status:ye})}function xt(e,r,t){let a=r.get("Location");return t&&(a=N(a,t)||a),{redirect:a,status:e,revalidate:r.has("X-Remix-Revalidate")||r.has("Set-Cookie"),reload:r.has("X-Remix-Reload-Document"),replace:r.has("X-Remix-Replace")}}function V(e,r,t,a){let s=new AbortController,o=setTimeout(()=>s.abort(new Error("Server Timeout")),typeof t=="number"?t:4950);return r.addEventListener("abort",()=>clearTimeout(o)),at(e,{signal:s.signal,plugins:[d=>{if(d instanceof Error){let{name:u,message:n,stack:i}=a==="production"?I(d,a):d;return["SanitizedError",u,n,i]}if(d instanceof H){let{data:u,status:n,statusText:i}=d;return["ErrorResponse",u,n,i]}if(d&&typeof d=="object"&&T in d)return["SingleFetchRedirect",d[T]]}],postPlugins:[d=>{if(d&&typeof d=="object")return["SingleFetchClassInstance",Object.fromEntries(Object.entries(d))]},()=>["SingleFetchFallback"]]})}function le(e,r){let t=xe(e.routes),a=De(e.routes,e.future),s=St(r)?r:"production",o=je(a,{basename:e.basename,unstable_instrumentations:e.entry.module.unstable_instrumentations}),d=e.entry.module.handleError||((n,{request:i})=>{s!=="test"&&!i.signal.aborted&&console.error(_(n)&&n.error?n.error:n)}),u=async(n,i)=>{let l={},h,c=S=>{r==="development"&&B()?.processRequestError?.(S),d(S,{context:h,params:l,request:n})};if(e.future.v8_middleware){if(i&&!(i instanceof j)){let S=new Error("Invalid `context` value provided to `handleRequest`. When middleware is enabled you must return an instance of `RouterContextProvider` from your `getLoadContext` function.");return c(S),O(S,s)}h=i||new j}else h=i||{};let y=new URL(n.url),f=e.basename||"/",p=y.pathname;N(p,f)==="/_root.data"?p=f:p.endsWith(".data")&&(p=p.replace(/\.data$/,"")),N(p,f)!=="/"&&p.endsWith("/")&&(p=p.slice(0,-1));let w=be(n,"X-React-Router-SPA-Mode")==="yes";if(!e.ssr){let S=decodeURI(p);if(f!=="/"){let v=N(S,f);if(v==null)return d(new H(404,"Not Found",`Refusing to prerender the \`${S}\` path because it does not start with the basename \`${f}\``),{context:h,params:l,request:n}),new Response("Not Found",{status:404,statusText:"Not Found"});S=v}if(e.prerender.length===0)w=!0;else if(!e.prerender.includes(S)&&!e.prerender.includes(S+"/")){if(y.pathname.endsWith(".data"))return d(new H(404,"Not Found",`Refusing to SSR the path \`${S}\` because \`ssr:false\` is set and the path is not included in the \`prerender\` config, so in production the path will be a 404.`),{context:h,params:l,request:n}),new Response("Not Found",{status:404,statusText:"Not Found"});w=!0}}let m=Ze(e.routeDiscovery.manifestPath,f);if(y.pathname===m)try{return await Dt(e,t,y)}catch(S){return c(S),new Response("Unknown Server Error",{status:500})}let R=$(t,p,e.basename);R&&R.length>0&&Object.assign(l,R[0].params);let g;if(y.pathname.endsWith(".data")){let S=new URL(n.url);S.pathname=p;let v=$(t,S.pathname,e.basename);g=await At(s,e,o,n,S,h,c),Y(g)&&(g=ie(g,n,e,s)),e.entry.module.handleDataRequest&&(g=await e.entry.module.handleDataRequest(g,{context:h,params:v?v[0].params:{},request:n}),Y(g)&&(g=ie(g,n,e,s)))}else if(!w&&R&&R[R.length-1].route.module.default==null&&R[R.length-1].route.module.ErrorBoundary==null)g=await Ft(s,e,o,R.slice(-1)[0].route.id,n,h,c);else{let{pathname:S}=y,v;e.unstable_getCriticalCss?v=await e.unstable_getCriticalCss({pathname:S}):r==="development"&&B()?.getCriticalCss&&(v=await B()?.getCriticalCss?.(S)),g=await kt(s,e,o,n,h,c,w,v)}return n.method==="HEAD"?new Response(null,{headers:g.headers,status:g.status,statusText:g.statusText}):g};return e.entry.module.unstable_instrumentations&&(u=$e(u,e.entry.module.unstable_instrumentations.map(n=>n.handler).filter(Boolean))),{routes:t,dataRoutes:a,serverMode:s,staticHandler:o,errorHandler:d,requestHandler:u}}var Jt=(e,r)=>{let t,a,s,o,d,u;return async function(i,l){if(t=typeof e=="function"?await e():e,typeof e=="function"){let h=le(t,r);a=h.routes,s=h.serverMode,o=h.staticHandler,d=h.errorHandler,u=h.requestHandler}else if(!a||!s||!o||!d||!u){let h=le(t,r);a=h.routes,s=h.serverMode,o=h.staticHandler,d=h.errorHandler,u=h.requestHandler}return u(i,l)}};async function Dt(e,r,t){if(e.assets.version!==t.searchParams.get("version"))return new Response(null,{status:204,headers:{"X-Remix-Reload-Document":"true"}});let a={};if(t.searchParams.has("paths")){let s=new Set;(t.searchParams.get("paths")||"").split(",").filter(Boolean).forEach(u=>{u.startsWith("/")||(u=`/${u}`);let n=u.split("/").slice(1);n.forEach((i,l)=>{let h=n.slice(0,l+1).join("/");s.add(`/${h}`)})});for(let u of s){let n=$(r,u,e.basename);if(n)for(let i of n){let l=i.route.id,h=e.assets.routes[l];h&&(a[l]=h)}}return Response.json(a,{headers:{"Cache-Control":"public, max-age=31536000, immutable"}})}return new Response("Invalid Request",{status:400})}async function At(e,r,t,a,s,o,d){return a.method!=="GET"?await bt(r,e,t,a,s,o,d):await _t(r,e,t,a,s,o,d)}async function kt(e,r,t,a,s,o,d,u){try{let i=await t.query(a,{requestContext:s,generateMiddlewareResponse:r.future.v8_middleware?async l=>{try{let h=await l(a);return D(h)||(h=await n(h,d)),h}catch(h){return o(h),new Response(null,{status:500})}}:void 0});return D(i)||(i=await n(i,d)),i}catch(i){return o(i),new Response(null,{status:500})}async function n(i,l){let h=Q(i,r);if(Ae.has(i.statusCode))return new Response(null,{status:i.statusCode,headers:h});i.errors&&(Object.values(i.errors).forEach(w=>{(!_(w)||w.error)&&o(w)}),i.errors=L(i.errors,e));let c={loaderData:i.loaderData,actionData:i.actionData,errors:ne(i.errors,e)},y={basename:r.basename,future:r.future,routeDiscovery:r.routeDiscovery,ssr:r.ssr,isSpaMode:l},f={manifest:r.assets,routeModules:Rt(r.routes),staticHandlerContext:i,criticalCss:u,serverHandoffString:oe({...y,criticalCss:u}),serverHandoffStream:V(c,a.signal,r.entry.module.streamTimeout,e),renderMeta:{},future:r.future,ssr:r.ssr,routeDiscovery:r.routeDiscovery,isSpaMode:l,serializeError:w=>Ee(w,e)},p=r.entry.module.default;try{return await p(a,i.statusCode,h,f,s)}catch(w){o(w);let m=w;if(D(w))try{let g=await Tt(w);m=new H(w.status,w.statusText,g)}catch{}i=tt(t.dataRoutes,i,m),i.errors&&(i.errors=L(i.errors,e));let R={loaderData:i.loaderData,actionData:i.actionData,errors:ne(i.errors,e)};f={...f,staticHandlerContext:i,serverHandoffString:oe(y),serverHandoffStream:V(R,a.signal,r.entry.module.streamTimeout,e),renderMeta:{}};try{return await p(a,i.statusCode,h,f,s)}catch(g){return o(g),O(g,e)}}}}async function Ft(e,r,t,a,s,o,d){try{let i=await t.queryRoute(s,{routeId:a,requestContext:o,generateMiddlewareResponse:r.future.v8_middleware?async l=>{try{let h=await l(s);return u(h)}catch(h){return n(h)}}:void 0});return u(i)}catch(i){return n(i)}function u(i){return D(i)?i:typeof i=="string"?new Response(i):Response.json(i)}function n(i){if(D(i))return i;if(_(i))return d(i),Ht(i,e);if(i instanceof Error&&i.message==="Expected a response from queryRoute"){let l=new Error("Expected a Response to be returned from resource route handler");return d(l),O(l,e)}return d(i),O(i,e)}}function Ht(e,r){return Response.json(Ee(e.error||new Error("Unexpected Server Error"),r),{status:e.status,statusText:e.statusText})}function O(e,r){let t="Unexpected Server Error";return r!=="production"&&(t+=`
2
+
3
+ ${String(e)}`),new Response(t,{status:500,headers:{"Content-Type":"text/plain"}})}function Tt(e){let r=e.headers.get("Content-Type");return r&&/\bapplication\/json\b/.test(r)?e.body==null?null:e.json():e.text()}function M(e){return`__flash_${e}__`}var ke=(e={},r="")=>{let t=new Map(Object.entries(e));return{get id(){return r},get data(){return Object.fromEntries(t)},has(a){return t.has(a)||t.has(M(a))},get(a){if(t.has(a))return t.get(a);let s=M(a);if(t.has(s)){let o=t.get(s);return t.delete(s),o}},set(a,s){t.set(a,s)},flash(a,s){t.set(M(a),s)},unset(a){t.delete(a)}}},Kt=e=>e!=null&&typeof e.id=="string"&&typeof e.data<"u"&&typeof e.has=="function"&&typeof e.get=="function"&&typeof e.set=="function"&&typeof e.flash=="function"&&typeof e.unset=="function";function Pt({cookie:e,createData:r,readData:t,updateData:a,deleteData:s}){let o=ve(e)?e:Se(e?.name||"__session",e);return Fe(o),{async getSession(d,u){let n=d&&await o.parse(d,u),i=n&&await t(n);return ke(i||{},n||"")},async commitSession(d,u){let{id:n,data:i}=d,l=u?.maxAge!=null?new Date(Date.now()+u.maxAge*1e3):u?.expires!=null?u.expires:o.expires;return n?await a(n,i,l):n=await r(i,l),o.serialize(n,u)},async destroySession(d,u){return await s(d.id),o.serialize("",{...u,maxAge:void 0,expires:new Date(0)})}}}function Fe(e){we(e.isSigned,`The "${e.name}" cookie is not signed, but session cookies should be signed to prevent tampering on the client before they are sent back to the server. See https://reactrouter.com/explanation/sessions-and-cookies#signing-cookies for more information.`)}function Qt({cookie:e}={}){let r=ve(e)?e:Se(e?.name||"__session",e);return Fe(r),{async getSession(t,a){return ke(t&&await r.parse(t,a)||{})},async commitSession(t,a){let s=await r.serialize(t.data,a);if(s.length>4096)throw new Error("Cookie length will exceed browser maximum. Length: "+s.length);return s},async destroySession(t,a){return r.serialize("",{...a,maxAge:void 0,expires:new Date(0)})}}}function Gt({cookie:e}={}){let r=new Map;return Pt({cookie:e,async createData(t,a){let s=Math.random().toString(36).substring(2,10);return r.set(s,{data:t,expires:a}),s},async readData(t){if(r.has(t)){let{data:a,expires:s}=r.get(t);if(!s||s>new Date)return a;s&&r.delete(t)}return null},async updateData(t,a,s){r.set(t,{data:a,expires:s})},async deleteData(t){r.delete(t)}})}function Yt(e,...r){let t=r[0],a=e.replace(/\/*\*?$/,"").replace(/\/:([\w-]+)(\?)?/g,(s,o,d)=>{const u=d===void 0,n=t?t[o]:void 0;if(u&&n===void 0)throw new Error(`Path '${e}' requires param '${o}' but it was not provided`);return n===void 0?"":"/"+n});if(e.endsWith("*")){const s=t?t["*"]:void 0;s!==void 0&&(a+="/"+s)}return a||"/"}var W=new TextEncoder,ue="</body></html>";function de(e){let r=new TextDecoder,t,a=new Promise(n=>t=n),s=!1,o=[],d=null;function u(n){for(let i of o){let l=r.decode(i,{stream:!0});l.endsWith(ue)&&(l=l.slice(0,-ue.length)),n.enqueue(W.encode(l))}o.length=0,d=null}return new TransformStream({transform(n,i){o.push(n),!d&&(d=setTimeout(async()=>{u(i),s||(s=!0,Nt(e,i).catch(l=>i.error(l)).then(t))},0))},async flush(n){await a,d&&(clearTimeout(d),u(n)),n.enqueue(W.encode("</body></html>"))}})}async function Nt(e,r){let t=new TextDecoder("utf-8",{fatal:!0});const a=e.getReader();try{let o;for(;(o=await a.read())&&!o.done;){const d=o.value;try{z(JSON.stringify(t.decode(d,{stream:!0})),r)}catch{let n=JSON.stringify(btoa(String.fromCodePoint(...d)));z(`Uint8Array.from(atob(${n}), m => m.codePointAt(0))`,r)}}}finally{a.releaseLock()}let s=t.decode();s.length&&z(JSON.stringify(s),r)}function z(e,r){r.enqueue(W.encode(`<script>${Ut(`(self.__FLIGHT_DATA||=[]).push(${e})`)}<\/script>`))}function Ut(e){return e.replace(/<!--/g,"<\\!--").replace(/<\/(script)/gi,"</\\$1")}var Lt=class extends C.Component{constructor(e){super(e),this.state={error:null,location:e.location}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location?{error:null,location:e.location}:{error:r.error,location:r.location}}render(){return this.state.error?C.createElement(He,{error:this.state.error,renderAppShell:!0}):this.props.children}};function ce({renderAppShell:e,title:r,children:t}){return e?C.createElement("html",{lang:"en"},C.createElement("head",null,C.createElement("meta",{charSet:"utf-8"}),C.createElement("meta",{name:"viewport",content:"width=device-width,initial-scale=1,viewport-fit=cover"}),C.createElement("title",null,r)),C.createElement("body",null,C.createElement("main",{style:{fontFamily:"system-ui, sans-serif",padding:"2rem"}},t))):t}function He({error:e,renderAppShell:r}){console.error(e);let t=C.createElement("script",{dangerouslySetInnerHTML:{__html:`
4
+ console.log(
5
+ "💿 Hey developer 👋. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
6
+ );
7
+ `}});if(_(e))return C.createElement(ce,{renderAppShell:r,title:"Unhandled Thrown Response!"},C.createElement("h1",{style:{fontSize:"24px"}},e.status," ",e.statusText),t);let a;if(e instanceof Error)a=e;else{let s=e==null?"Unknown Error":typeof e=="object"&&"toString"in e?e.toString():JSON.stringify(e);a=new Error(s)}return C.createElement(ce,{renderAppShell:r,title:"Application Error!"},C.createElement("h1",{style:{fontSize:"24px"}},"Application Error"),C.createElement("pre",{style:{padding:"2rem",background:"hsla(10, 50%, 50%, 0.1)",color:"red",overflow:"auto"}},a.stack),t)}function Zt({hasRootLayout:e}){let r=Oe();if(e===void 0)throw new Error("Missing 'hasRootLayout' prop");return C.createElement(He,{renderAppShell:!e,error:r})}function Ot(e){const r={};for(const t of e.matches)It(r,t);return r}function It(e,r){r=Array.isArray(r)?r:[r];for(const t of r)e[t.id]={links:t.links,meta:t.meta,default:Bt}}var Bt=()=>null,Mt="use",fe=Je[Mt];function zt(e){if(fe)return fe(e);throw new Error("React Router v7 requires React 19+ for RSC features.")}async function er({request:e,fetchServer:r,createFromReadableStream:t,renderHTML:a,hydrate:s=!0}){const o=new URL(e.url),u=jt(o)||$t(o)||e.headers.has("rsc-action-id"),n=await r(e);if(u||n.headers.get("React-Router-Resource")==="true")return n;if(!n.body)throw new Error("Missing body in server response");const i=n.clone();let l=null;s&&(l=n.clone());const h=n.body;let c,y=[];const f=()=>c?new ReadableStream({start(m){c.forEach(R=>m.enqueue(R)),y.push(m)}}):(c=[],h.pipeThrough(new TransformStream({transform(m,R){c.push(m),R.enqueue(m),y.forEach(g=>g.enqueue(m))},flush(){y.forEach(m=>m.close()),y=[]}})));let p=null;const w=()=>{const m=Promise.resolve(t(f()));return Object.defineProperties(m,{_deepestRenderedBoundaryId:{get(){return p},set(R){p=R}},formState:{get(){return m.then(R=>R.type==="render"?R.formState:void 0)}}})};try{if(!i.body)throw new Error("Failed to clone server response");const m=await t(i.body);if(n.status===ye&&m.type==="redirect"){const v=new Headers(n.headers);return v.delete("Content-Encoding"),v.delete("Content-Length"),v.delete("Content-Type"),v.delete("X-Remix-Response"),v.set("Location",m.location),new Response(l?.body||"",{headers:v,status:m.status,statusText:n.statusText})}const R=await a(w),g=new Headers(n.headers);if(g.set("Content-Type","text/html; charset=utf-8"),!s)return new Response(R,{status:n.status,headers:g});if(!l?.body)throw new Error("Failed to clone server response");const S=R.pipeThrough(de(l.body));return new Response(S,{status:n.status,headers:g})}catch(m){if(m instanceof Response)return m;try{const R=_(m)?m.status:500,g=await a(()=>{const k=Promise.resolve(t(f())).then(b=>Object.assign(b,{status:R,errors:p?{[p]:m}:{}}));return Object.defineProperties(k,{_deepestRenderedBoundaryId:{get(){return p},set(b){p=b}},formState:{get(){return k.then(b=>b.type==="render"?b.formState:void 0)}}})}),S=new Headers(n.headers);if(S.set("Content-Type","text/html"),!s)return new Response(g,{status:R,headers:S});if(!l?.body)throw new Error("Failed to clone server response");const v=g.pipeThrough(de(l.body));return new Response(v,{status:R,headers:S})}catch{}throw m}}function tr({getPayload:e}){const r=e(),t=zt(r);if(t.type==="redirect")throw new Response(null,{status:t.status,headers:{Location:t.location}});if(t.type!=="render")return null;let a={...t.loaderData};for(const u of t.matches)q(u.id,u.clientLoader,u.hasLoader,!1)&&(u.hydrateFallbackElement||!u.hasLoader)&&delete a[u.id];const s={get _deepestRenderedBoundaryId(){return r._deepestRenderedBoundaryId??null},set _deepestRenderedBoundaryId(u){r._deepestRenderedBoundaryId=u},actionData:t.actionData,actionHeaders:{},basename:t.basename,errors:t.errors,loaderData:a,loaderHeaders:{},location:t.location,statusCode:200,matches:t.matches.map(u=>({params:u.params,pathname:u.pathname,pathnameBase:u.pathnameBase,route:{id:u.id,action:u.hasAction||!!u.clientAction,handle:u.handle,hasErrorBoundary:u.hasErrorBoundary,loader:u.hasLoader||!!u.clientLoader,index:u.index,path:u.path,shouldRevalidate:u.shouldRevalidate}}))},o=he(t.matches.reduceRight((u,n)=>{const i={id:n.id,action:n.hasAction||!!n.clientAction,element:n.element,errorElement:n.errorElement,handle:n.handle,hasErrorBoundary:!!n.errorElement,hydrateFallbackElement:n.hydrateFallbackElement,index:n.index,loader:n.hasLoader||!!n.clientLoader,path:n.path,shouldRevalidate:n.shouldRevalidate};return u.length>0&&(i.children=u),[i]},[]),s),d={future:{v8_middleware:!1,unstable_subResourceIntegrity:!1},isSpaMode:!1,ssr:!0,criticalCss:"",manifest:{routes:{},version:"1",url:"",entry:{module:"",imports:[]}},routeDiscovery:{mode:"lazy",manifestPath:"/__manifest"},routeModules:Ot(t)};return E.createElement(ze.Provider,{value:!0},E.createElement(Lt,{location:t.location},E.createElement(X.Provider,{value:d},E.createElement(pe,{context:s,router:o,hydrate:!1,nonce:t.nonce}))))}function jt(e){return e.pathname.endsWith(".rsc")}function $t(e){return e.pathname.endsWith(".manifest")}function rr(e){if(!e)return null;let r=Object.entries(e),t={};for(let[a,s]of r)if(s&&s.__type==="RouteErrorResponse")t[a]=new H(s.status,s.statusText,s.data,s.internal===!0);else if(s&&s.__type==="Error"){if(s.__subType){let o=window[s.__subType];if(typeof o=="function")try{let d=new o(s.message);d.stack=s.stack,t[a]=d}catch{}}if(t[a]==null){let o=new Error(s.message);o.stack=s.stack,t[a]=o}}else t[a]=s;return t}function ar({state:e,routes:r,getRouteInfo:t,location:a,basename:s,isSpaMode:o}){let d={...e,loaderData:{...e.loaderData}},u=me(r,a,s);if(u)for(let n of u){let i=n.route.id,l=t(i);q(i,l.clientLoader,l.hasLoader,o)&&(l.hasHydrateFallback||!l.hasLoader)?delete d.loaderData[i]:l.hasLoader||(d.loaderData[i]=null)}return d}export{or as Await,ir as BrowserRouter,lr as Form,ur as HashRouter,dr as IDLE_BLOCKER,cr as IDLE_FETCHER,fr as IDLE_NAVIGATION,hr as Link,pr as Links,mr as MemoryRouter,yr as Meta,wr as NavLink,Rr as Navigate,gr as NavigationType,Xe as Outlet,Sr as PrefetchPageLinks,vr as Route,Er as Router,j as RouterContextProvider,Me as RouterProvider,Cr as Routes,br as Scripts,_r as ScrollRestoration,Wt as ServerRouter,xr as StaticRouter,pe as StaticRouterProvider,Dr as UNSAFE_AwaitContextProvider,Ar as UNSAFE_DataRouterContext,kr as UNSAFE_DataRouterStateContext,H as UNSAFE_ErrorResponseImpl,Fr as UNSAFE_FetchersContext,X as UNSAFE_FrameworkContext,Hr as UNSAFE_LocationContext,Tr as UNSAFE_NavigationContext,Zt as UNSAFE_RSCDefaultRootErrorBoundary,Ue as UNSAFE_RemixErrorBoundary,Pr as UNSAFE_RouteContext,gt as UNSAFE_ServerMode,T as UNSAFE_SingleFetchRedirectSymbol,Nr as UNSAFE_ViewTransitionContext,Ur as UNSAFE_WithComponentProps,Lr as UNSAFE_WithErrorBoundaryProps,Or as UNSAFE_WithHydrateFallbackProps,Ir as UNSAFE_createBrowserHistory,Br as UNSAFE_createClientRoutes,Mr as UNSAFE_createClientRoutesWithHMRRevalidationOptOut,zr as UNSAFE_createRouter,Ke as UNSAFE_decodeViaTurboStream,rr as UNSAFE_deserializeErrors,ar as UNSAFE_getHydrationData,jr as UNSAFE_getPatchRoutesOnNavigationFunction,$r as UNSAFE_getTurboStreamSingleFetchDataStrategy,Vr as UNSAFE_hydrationRouteProperties,Wr as UNSAFE_invariant,qr as UNSAFE_mapRouteProperties,q as UNSAFE_shouldHydrateRouteLoader,Xr as UNSAFE_useFogOFWarDiscovery,Jr as UNSAFE_useScrollRestoration,qe as UNSAFE_withComponentProps,Ve as UNSAFE_withErrorBoundaryProps,We as UNSAFE_withHydrateFallbackProps,Kr as createBrowserRouter,Qr as createContext,Se as createCookie,Qt as createCookieSessionStorage,Gr as createHashRouter,Be as createMemoryRouter,Gt as createMemorySessionStorage,Yr as createPath,Jt as createRequestHandler,Zr as createRoutesFromChildren,ea as createRoutesFromElements,qt as createRoutesStub,ta as createSearchParams,ke as createSession,Pt as createSessionStorage,ra as createStaticHandler,he as createStaticRouter,aa as data,na as generatePath,Yt as href,ve as isCookie,_ as isRouteErrorResponse,Kt as isSession,sa as matchPath,me as matchRoutes,oa as parsePath,Ye as redirect,Qe as redirectDocument,ia as renderMatches,Ge as replace,la as resolvePath,ua as unstable_HistoryRouter,tr as unstable_RSCStaticRouter,er as unstable_routeRSCServerRequest,Xt as unstable_setDevServerHooks,da as unstable_usePrompt,ca as unstable_useRoute,fa as useActionData,ha as useAsyncError,pa as useAsyncValue,ma as useBeforeUnload,ya as useBlocker,wa as useFetcher,Ra as useFetchers,ga as useFormAction,Sa as useHref,va as useInRouterContext,Ea as useLinkClickHandler,Ca as useLoaderData,ba as useLocation,_a as useMatch,xa as useMatches,Da as useNavigate,Aa as useNavigation,ka as useNavigationType,Fa as useOutlet,Ha as useOutletContext,Ta as useParams,Pa as useResolvedPath,Na as useRevalidator,Oe as useRouteError,Ua as useRouteLoaderData,La as useRoutes,Oa as useSearchParams,Ia as useSubmit,Ba as useViewTransitionState};
@@ -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-olcjmwjt.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-DOp47eHE.js";import"./embeddings-8blUtIbt.js";import"./index-BAxAv6UE.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-Ddy9yyxP.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-DPEqrSDR.js";import"./embeddings-CgzAByVu.js";import"./index-FyLdp58J.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{E as Ss,aG as S,S as xa,Q as ka,K as jn,g as Ke,x as Ze,a9 as Sa,am as Aa,L as Ca,H as As,I as Cs,z as ke,l as Os,aH as Oa,D as cn,aI as Ln,aJ as Ia,aK as Ta,aL as Ra,J as Dn,aM as Fn,aN as $a,B as Jt,a as Pa}from"./index-DOp47eHE.js";import{e as Ea,j as Ma,h as Na,f as Is,S as Bn,J as Un,R as Wn}from"./index-olcjmwjt.js";import{t as Ts,e as ja}from"./index-BAxAv6UE.js";import{J as qn,c as La,p as Rs,m as Kt}from"./index-DwpYRN9f.js";import"./embeddings-8blUtIbt.js";import"./index-DRz5BQNA.js";const xe=t=>t();function Be(t){return t?!!(/^o\d/.test(t??"")||t.startsWith("gpt-5")&&!t.startsWith("gpt-5-chat")):!1}function Da(t){return t.role!=="system"&&t.role!=="developer"&&t.role!=="assistant"&&t.role!=="user"&&t.role!=="function"&&t.role!=="tool"&&console.warn(`Unknown message role: ${t.role}`),t.role}function Ue(t){const e=t._getType();switch(e){case"system":return"system";case"ai":return"assistant";case"human":return"user";case"function":return"function";case"tool":return"tool";case"generic":if(!Ss.isInstance(t))throw new Error("Invalid generic chat message");return Da(t);default:throw new Error(`Unknown message type: ${e}`)}}function Fa(t){const{azureOpenAIApiDeploymentName:e,azureOpenAIApiInstanceName:n,azureOpenAIApiKey:s,azureOpenAIBasePath:r,baseURL:a,azureADTokenProvider:i,azureOpenAIEndpoint:o}=t;if((s||i)&&r&&e)return`${r}/${e}`;if((s||i)&&o&&e)return`${o}/openai/deployments/${e}`;if(s||i){if(!n)throw new Error("azureOpenAIApiInstanceName is required when using azureOpenAIApiKey");if(!e)throw new Error("azureOpenAIApiDeploymentName is a required parameter when using azureOpenAIApiKey");return`https://${n}.openai.azure.com/openai/deployments/${e}`}return a}function Ba(t,e){let n;return Ea(t)?n=Ma(t):n=t,e?.strict!==void 0&&(n.function.strict=e.strict),n}function Ua(t){return t.anyOf!==void 0&&Array.isArray(t.anyOf)}function Wa(t){const e=["namespace functions {",""];for(const n of t)n.description&&e.push(`// ${n.description}`),Object.keys(n.parameters.properties??{}).length>0?(e.push(`type ${n.name} = (_: {`),e.push($s(n.parameters,0)),e.push("}) => any;")):e.push(`type ${n.name} = () => any;`),e.push("");return e.push("} // namespace functions"),e.join(`
1
+ import{E as Ss,aG as S,S as xa,Q as ka,K as jn,g as Ke,x as Ze,a9 as Sa,am as Aa,L as Ca,H as As,I as Cs,z as ke,l as Os,aH as Oa,D as cn,aI as Ln,aJ as Ia,aK as Ta,aL as Ra,J as Dn,aM as Fn,aN as $a,B as Jt,a as Pa}from"./index-DPEqrSDR.js";import{e as Ea,j as Ma,h as Na,f as Is,S as Bn,J as Un,R as Wn}from"./index-Ddy9yyxP.js";import{bh as Ts,bi as ja}from"./index-FyLdp58J.js";import{J as qn,c as La,p as Rs,m as Kt}from"./index-VOipG1yN.js";import"./embeddings-CgzAByVu.js";import"./index-DRz5BQNA.js";const xe=t=>t();function Be(t){return t?!!(/^o\d/.test(t??"")||t.startsWith("gpt-5")&&!t.startsWith("gpt-5-chat")):!1}function Da(t){return t.role!=="system"&&t.role!=="developer"&&t.role!=="assistant"&&t.role!=="user"&&t.role!=="function"&&t.role!=="tool"&&console.warn(`Unknown message role: ${t.role}`),t.role}function Ue(t){const e=t._getType();switch(e){case"system":return"system";case"ai":return"assistant";case"human":return"user";case"function":return"function";case"tool":return"tool";case"generic":if(!Ss.isInstance(t))throw new Error("Invalid generic chat message");return Da(t);default:throw new Error(`Unknown message type: ${e}`)}}function Fa(t){const{azureOpenAIApiDeploymentName:e,azureOpenAIApiInstanceName:n,azureOpenAIApiKey:s,azureOpenAIBasePath:r,baseURL:a,azureADTokenProvider:i,azureOpenAIEndpoint:o}=t;if((s||i)&&r&&e)return`${r}/${e}`;if((s||i)&&o&&e)return`${o}/openai/deployments/${e}`;if(s||i){if(!n)throw new Error("azureOpenAIApiInstanceName is required when using azureOpenAIApiKey");if(!e)throw new Error("azureOpenAIApiDeploymentName is a required parameter when using azureOpenAIApiKey");return`https://${n}.openai.azure.com/openai/deployments/${e}`}return a}function Ba(t,e){let n;return Ea(t)?n=Ma(t):n=t,e?.strict!==void 0&&(n.function.strict=e.strict),n}function Ua(t){return t.anyOf!==void 0&&Array.isArray(t.anyOf)}function Wa(t){const e=["namespace functions {",""];for(const n of t)n.description&&e.push(`// ${n.description}`),Object.keys(n.parameters.properties??{}).length>0?(e.push(`type ${n.name} = (_: {`),e.push($s(n.parameters,0)),e.push("}) => any;")):e.push(`type ${n.name} = () => any;`),e.push("");return e.push("} // namespace functions"),e.join(`
2
2
  `)}function $s(t,e){const n=[];for(const[s,r]of Object.entries(t.properties??{}))r.description&&e<2&&n.push(`// ${r.description}`),t.required?.includes(s)?n.push(`${s}: ${ut(r,e)},`):n.push(`${s}?: ${ut(r,e)},`);return n.map(s=>" ".repeat(e)+s).join(`
3
3
  `)}function ut(t,e){if(Ua(t))return t.anyOf.map(n=>ut(n,e)).join(" | ");switch(t.type){case"string":return t.enum?t.enum.map(n=>`"${n}"`).join(" | "):"string";case"number":return t.enum?t.enum.map(n=>`${n}`).join(" | "):"number";case"integer":return t.enum?t.enum.map(n=>`${n}`).join(" | "):"number";case"boolean":return"boolean";case"null":return"null";case"object":return["{",$s(t,e+2),"}"].join(`
4
4
  `);case"array":return t.items?`${ut(t.items,e)}[]`:"any[]";default:return""}}function Ps(t){if(t)return t==="any"||t==="required"?"required":t==="auto"?"auto":t==="none"?"none":typeof t=="string"?{type:"function",function:{name:t}}:t}function un(t){return"type"in t&&t.type!=="function"}function qa(t){return t!=null&&typeof t=="object"&&"type"in t&&t.type!=="function"}function dt(t){return typeof t=="object"&&t!==null&&"metadata"in t&&typeof t.metadata=="object"&&t.metadata!==null&&"customTool"in t.metadata&&typeof t.metadata.customTool=="object"&&t.metadata.customTool!==null}function Es(t){return"type"in t&&t.type==="custom"&&"custom"in t&&typeof t.custom=="object"&&t.custom!==null}function Ja(t){if(t.type==="custom_tool_call")return{...t,type:"tool_call",call_id:t.id,id:t.call_id,name:t.name,isCustomTool:!0,args:{input:t.input}}}function Ka(t){return t.type==="tool_call"&&"isCustomTool"in t&&t.isCustomTool===!0}function Za(t){const e=()=>{if(t.custom.format){if(t.custom.format.type==="grammar")return{type:"grammar",definition:t.custom.format.grammar.definition,syntax:t.custom.format.grammar.syntax};if(t.custom.format.type==="text")return{type:"text"}}};return{type:"custom",name:t.custom.name,description:t.custom.description,format:e()}}function za(t){const e=()=>{if(t.format){if(t.format.type==="grammar")return{type:"grammar",grammar:{definition:t.format.definition,syntax:t.format.syntax}};if(t.format.type==="text")return{type:"text"}}};return{type:"custom",custom:{name:t.name,description:t.description,format:e()}}}function Zt(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}const zt=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){const e=new Error(t.message,t.cause?{cause:t.cause}:{});return t.stack&&(e.stack=t.stack),t.cause&&!e.cause&&(e.cause=t.cause),t.name&&(e.name=t.name),e}}catch{}try{return new Error(JSON.stringify(t))}catch{}}return new Error(t)};class x extends Error{}class q extends x{constructor(e,n,s,r){super(`${q.makeMessage(e,n,s)}`),this.status=e,this.headers=r,this.requestID=r?.get("x-request-id"),this.error=n;const a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,n,s){const r=n?.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):s;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||"(no status code or body)"}static generate(e,n,s,r){if(!e||!r)return new kt({message:s,cause:zt(n)});const a=n?.error;return e===400?new Ms(e,a,s,r):e===401?new Ns(e,a,s,r):e===403?new js(e,a,s,r):e===404?new Ls(e,a,s,r):e===409?new Ds(e,a,s,r):e===422?new Fs(e,a,s,r):e===429?new Bs(e,a,s,r):e>=500?new Us(e,a,s,r):new q(e,a,s,r)}}class X extends q{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class kt extends q{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}}class St extends kt{constructor({message:e}={}){super({message:e??"Request timed out."})}}class Ms extends q{}class Ns extends q{}class js extends q{}class Ls extends q{}class Ds extends q{}class Fs extends q{}class Bs extends q{}class Us extends q{}class Ws extends x{constructor(){super("Could not parse response content as the length limit was reached")}}class qs extends x{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class Oe extends Error{constructor(e){super(e)}}function ht(t){return t!==void 0&&"function"in t&&t.function!==void 0}function Ha(t,e){const n={...t};return Object.defineProperties(n,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:e,enumerable:!1}}),n}function dn(t){return t?.$brand==="auto-parseable-response-format"}function We(t){return t?.$brand==="auto-parseable-tool"}function Va(t,e){return!e||!Js(e)?{...t,choices:t.choices.map(n=>(Ks(n.message.tool_calls),{...n,message:{...n.message,parsed:null,...n.message.tool_calls?{tool_calls:n.message.tool_calls}:void 0}}))}:hn(t,e)}function hn(t,e){const n=t.choices.map(s=>{if(s.finish_reason==="length")throw new Ws;if(s.finish_reason==="content_filter")throw new qs;return Ks(s.message.tool_calls),{...s,message:{...s.message,...s.message.tool_calls?{tool_calls:s.message.tool_calls?.map(r=>Ga(e,r))??void 0}:void 0,parsed:s.message.content&&!s.message.refusal?Xa(e,s.message.content):null}}});return{...t,choices:n}}function Xa(t,e){return t.response_format?.type!=="json_schema"?null:t.response_format?.type==="json_schema"?"$parseRaw"in t.response_format?t.response_format.$parseRaw(e):JSON.parse(e):null}function Ga(t,e){const n=t.tools?.find(s=>ht(s)&&s.function?.name===e.function.name);return{...e,function:{...e.function,parsed_arguments:We(n)?n.$parseRaw(e.function.arguments):n?.function.strict?JSON.parse(e.function.arguments):null}}}function Qa(t,e){if(!t||!("tools"in t)||!t.tools)return!1;const n=t.tools?.find(s=>ht(s)&&s.function?.name===e.function.name);return ht(n)&&(We(n)||n?.function.strict||!1)}function Js(t){return dn(t.response_format)?!0:t.tools?.some(e=>We(e)||e.type==="function"&&e.function.strict===!0)??!1}function Ks(t){for(const e of t||[])if(e.type!=="function")throw new x(`Currently only \`function\` tool calls are supported; Received \`${e.type}\``)}function Ya(t){for(const e of t??[]){if(e.type!=="function")throw new x(`Currently only \`function\` tool types support auto-parsing; Received \`${e.type}\``);if(e.function.strict!==!0)throw new x(`The \`${e.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}const ei=Symbol("Let zodToJsonSchema decide on which parser to use"),Jn={name:void 0,$refStrategy:"root",effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",nullableStrategy:"from-target",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},ti=t=>typeof t=="string"?{...Jn,basePath:["#"],definitions:{},name:t}:{...Jn,basePath:["#"],definitions:{},...t},Ht=t=>"_def"in t?t._def:t;function ni(t){if(!t)return!0;for(const e in t)return!1;return!0}const si=t=>{const e=ti(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:n,propertyPath:void 0,seenRefs:new Set,seen:new Map(Object.entries(e.definitions).map(([s,r])=>[Ht(r),{def:Ht(r),path:[...e.basePath,e.definitionPath,s],jsonSchema:void 0}]))}};function Zs(t,e,n,s){s?.errorMessages&&n&&(t.errorMessage={...t.errorMessage,[e]:n})}function T(t,e,n,s,r){t[e]=n,Zs(t,e,s,r)}function ri(){return{}}function ai(t,e){const n={type:"array"};return t.type?._def?.typeName!==S.ZodAny&&(n.items=O(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&T(n,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&T(n,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(T(n,"minItems",t.exactLength.value,t.exactLength.message,e),T(n,"maxItems",t.exactLength.value,t.exactLength.message,e)),n}function ii(t,e){const n={type:"integer",format:"int64"};if(!t.checks)return n;for(const s of t.checks)switch(s.kind){case"min":e.target==="jsonSchema7"?s.inclusive?T(n,"minimum",s.value,s.message,e):T(n,"exclusiveMinimum",s.value,s.message,e):(s.inclusive||(n.exclusiveMinimum=!0),T(n,"minimum",s.value,s.message,e));break;case"max":e.target==="jsonSchema7"?s.inclusive?T(n,"maximum",s.value,s.message,e):T(n,"exclusiveMaximum",s.value,s.message,e):(s.inclusive||(n.exclusiveMaximum=!0),T(n,"maximum",s.value,s.message,e));break;case"multipleOf":T(n,"multipleOf",s.value,s.message,e);break}return n}function oi(){return{type:"boolean"}}function li(t,e){return O(t.type._def,e)}const ci=(t,e)=>O(t.innerType._def,e);function zs(t,e,n){const s=n??e.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((r,a)=>zs(t,e,r))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return ui(t,e)}}const ui=(t,e)=>{const n={type:"integer",format:"unix-time"};if(e.target==="openApi3")return n;for(const s of t.checks)switch(s.kind){case"min":T(n,"minimum",s.value,s.message,e);break;case"max":T(n,"maximum",s.value,s.message,e);break}return n};function di(t,e){return{...O(t.innerType._def,e),default:t.defaultValue()}}function hi(t,e,n){return e.effectStrategy==="input"?O(t.schema._def,e,n):{}}function fi(t){return{type:"string",enum:[...t.values]}}const pi=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function mi(t,e){const n=[O(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),O(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(a=>!!a);let s=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0;const r=[];return n.forEach(a=>{if(pi(a))r.push(...a.allOf),a.unevaluatedProperties===void 0&&(s=void 0);else{let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){const{additionalProperties:o,...c}=a;i=c}else s=void 0;r.push(i)}}),r.length?{allOf:r,...s}:void 0}function _i(t,e){const n=typeof t.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[t.value]}:{type:n==="bigint"?"integer":n,const:t.value}}let Nt;const le={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Nt===void 0&&(Nt=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Nt),base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function Hs(t,e){const n={type:"string"};function s(r){return e.patternStrategy==="escape"?gi(r):r}if(t.checks)for(const r of t.checks)switch(r.kind){case"min":T(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,r.message,e);break;case"max":T(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value,r.message,e);break;case"email":switch(e.emailStrategy){case"format:email":G(n,"email",r.message,e);break;case"format:idn-email":G(n,"idn-email",r.message,e);break;case"pattern:zod":Q(n,le.email,r.message,e);break}break;case"url":G(n,"uri",r.message,e);break;case"uuid":G(n,"uuid",r.message,e);break;case"regex":Q(n,r.regex,r.message,e);break;case"cuid":Q(n,le.cuid,r.message,e);break;case"cuid2":Q(n,le.cuid2,r.message,e);break;case"startsWith":Q(n,RegExp(`^${s(r.value)}`),r.message,e);break;case"endsWith":Q(n,RegExp(`${s(r.value)}$`),r.message,e);break;case"datetime":G(n,"date-time",r.message,e);break;case"date":G(n,"date",r.message,e);break;case"time":G(n,"time",r.message,e);break;case"duration":G(n,"duration",r.message,e);break;case"length":T(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,r.message,e),T(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value,r.message,e);break;case"includes":{Q(n,RegExp(s(r.value)),r.message,e);break}case"ip":{r.version!=="v6"&&G(n,"ipv4",r.message,e),r.version!=="v4"&&G(n,"ipv6",r.message,e);break}case"emoji":Q(n,le.emoji,r.message,e);break;case"ulid":{Q(n,le.ulid,r.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{G(n,"binary",r.message,e);break}case"contentEncoding:base64":{T(n,"contentEncoding","base64",r.message,e);break}case"pattern:zod":{Q(n,le.base64,r.message,e);break}}break}case"nanoid":Q(n,le.nanoid,r.message,e)}return n}const gi=t=>Array.from(t).map(e=>/[a-zA-Z0-9]/.test(e)?e:`\\${e}`).join(""),G=(t,e,n,s)=>{t.format||t.anyOf?.some(r=>r.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&s.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...n&&s.errorMessages&&{errorMessage:{format:n}}})):T(t,"format",e,n,s)},Q=(t,e,n,s)=>{t.pattern||t.allOf?.some(r=>r.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&s.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:Kn(e,s),...n&&s.errorMessages&&{errorMessage:{pattern:n}}})):T(t,"pattern",Kn(e,s),n,s)},Kn=(t,e)=>{const n=typeof t=="function"?t():t;if(!e.applyRegexFlags||!n.flags)return n.source;const s={i:n.flags.includes("i"),m:n.flags.includes("m"),s:n.flags.includes("s")},r=s.i?n.source.toLowerCase():n.source;let a="",i=!1,o=!1,c=!1;for(let l=0;l<r.length;l++){if(i){a+=r[l],i=!1;continue}if(s.i){if(o){if(r[l].match(/[a-z]/)){c?(a+=r[l],a+=`${r[l-2]}-${r[l]}`.toUpperCase(),c=!1):r[l+1]==="-"&&r[l+2]?.match(/[a-z]/)?(a+=r[l],c=!0):a+=`${r[l]}${r[l].toUpperCase()}`;continue}}else if(r[l].match(/[a-z]/)){a+=`[${r[l]}${r[l].toUpperCase()}]`;continue}}if(s.m){if(r[l]==="^"){a+=`(^|(?<=[\r