@gram-ai/elements 1.17.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Chat/stories/ColorScheme.stories.d.ts +8 -0
- package/dist/components/Chat/stories/Composer.stories.d.ts +7 -0
- package/dist/components/Chat/stories/Customization.stories.d.ts +8 -0
- package/dist/components/Chat/stories/Density.stories.d.ts +8 -0
- package/dist/components/Chat/stories/FrontendTools.stories.d.ts +6 -0
- package/dist/components/Chat/stories/Modal.stories.d.ts +11 -0
- package/dist/components/Chat/stories/Model.stories.d.ts +6 -0
- package/dist/components/Chat/stories/Plugins.stories.d.ts +6 -0
- package/dist/components/Chat/stories/Radius.stories.d.ts +8 -0
- package/dist/components/Chat/stories/ToolApproval.stories.d.ts +8 -0
- package/dist/components/Chat/stories/Tools.stories.d.ts +6 -0
- package/dist/components/Chat/stories/Variants.stories.d.ts +8 -0
- package/dist/components/Chat/stories/Welcome.stories.d.ts +6 -0
- package/dist/components/assistant-ui/tooltip-icon-button.d.ts +2 -1
- package/dist/components/ui/tool-ui.d.ts +60 -8
- package/dist/components/ui/tool-ui.stories.d.ts +14 -0
- package/dist/contexts/ToolApprovalContext.d.ts +24 -0
- package/dist/contexts/contexts.d.ts +4 -0
- package/dist/elements.cjs +42 -42
- package/dist/elements.css +1 -1
- package/dist/elements.js +8719 -8380
- package/dist/hooks/useMCPTools.d.ts +1 -1
- package/dist/hooks/useToolApproval.d.ts +5 -0
- package/dist/{index-BAP7yZTT.js → index-1qi_Rje5.js} +60 -60
- package/dist/index-DY3aJC4I.cjs +16 -0
- package/dist/index.d.ts +2 -1
- package/dist/lib/tools.d.ts +21 -1
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.js +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +30 -26
- package/dist/types/index.d.ts +28 -10
- package/package.json +5 -9
- package/dist/contexts/elementsContextType.d.ts +0 -2
- package/dist/index-DTl5_PjQ.cjs +0 -16
- package/dist/types/schemas.d.ts +0 -28
package/dist/elements.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
Error message: ${
|
|
3
|
-
Error message: ${
|
|
4
|
-
`;break;case"id":s=b.includes("\0")?void 0:b;break;case"retry":/^\d+$/.test(b)?o(parseInt(b,10)):n(new
|
|
5
|
-
`)?l.slice(0,-1):l}),s=void 0,l="",u=""}function g(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),T=require("./index-DY3aJC4I.cjs"),L=require("@assistant-ui/react"),D=require("react"),Zt=require("motion/react"),b0=require("motion/react-m"),Ws=require("@assistant-ui/react-markdown"),_0=require("remark-gfm"),am=require("react-dom"),w0=require("shiki"),x0=require("zustand/shallow");function zu(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const _=zu(D),Lt=zu(b0),sm=zu(am);function $0({tools:e}){return m.jsx(m.Fragment,{children:Object.entries(e).map(([,t])=>t({}))})}const Mu=["anthropic/claude-sonnet-4.5","anthropic/claude-haiku-4.5","anthropic/claude-sonnet-4","anthropic/claude-opus-4.5","openai/gpt-4o","openai/gpt-4o-mini","openai/gpt-5.1-codex","openai/gpt-5","openai/gpt-5.1","openai/gpt-4.1","anthropic/claude-3.7-sonnet","anthropic/claude-opus-4","google/gemini-2.5-pro-preview","google/gemini-3-pro-preview","moonshotai/kimi-k2","mistralai/mistral-medium-3","mistralai/mistral-medium-3.1","mistralai/codestral-2501"];const S0=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],I0=T.createLucideIcon("arrow-down",S0);const k0=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],E0=T.createLucideIcon("arrow-up",k0);const T0=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],O0=T.createLucideIcon("brain",T0);const N0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],rr=T.createLucideIcon("check",N0);const P0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],li=T.createLucideIcon("chevron-down",P0);const C0=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],j0=T.createLucideIcon("chevron-left",C0);const A0=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],um=T.createLucideIcon("chevron-right",A0);const R0=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Du=T.createLucideIcon("copy",R0);const z0=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],M0=T.createLucideIcon("file-text",z0);const D0=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],Hs=T.createLucideIcon("loader",D0);const U0=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],L0=T.createLucideIcon("maximize",U0);const Z0=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],F0=T.createLucideIcon("message-circle",Z0);const q0=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],V0=T.createLucideIcon("minimize",q0);const B0=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],J0=T.createLucideIcon("panel-right-close",B0);const W0=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],H0=T.createLucideIcon("panel-right-open",W0);const G0=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],K0=T.createLucideIcon("pencil",G0);const Y0=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Q0=T.createLucideIcon("plus",Y0);const X0=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],eI=T.createLucideIcon("refresh-cw",X0);const tI=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],rI=T.createLucideIcon("settings-2",tI);const nI=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],oI=T.createLucideIcon("square",nI);const iI=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Xn=T.createLucideIcon("x",iI);var lm="vercel.ai.error",aI=Symbol.for(lm),cm,sI=class dm extends Error{constructor({name:t,message:n,cause:o}){super(n),this[cm]=!0,this.name=t,this.cause=o}static isInstance(t){return dm.hasMarker(t,lm)}static hasMarker(t,n){const o=Symbol.for(n);return t!=null&&typeof t=="object"&&o in t&&typeof t[o]=="boolean"&&t[o]===!0}};cm=aI;var Y=sI,pm="AI_APICallError",fm=`vercel.ai.error.${pm}`,uI=Symbol.for(fm),mm,Be=class extends Y{constructor({message:t,url:n,requestBodyValues:o,statusCode:r,responseHeaders:i,responseBody:a,cause:s,isRetryable:l=r!=null&&(r===408||r===409||r===429||r>=500),data:u}){super({name:pm,message:t,cause:s}),this[mm]=!0,this.url=n,this.requestBodyValues=o,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=l,this.data=u}static isInstance(t){return Y.hasMarker(t,fm)}};mm=uI;var hm="AI_EmptyResponseBodyError",gm=`vercel.ai.error.${hm}`,lI=Symbol.for(gm),vm,cI=class extends Y{constructor({message:t="Empty response body"}={}){super({name:hm,message:t}),this[vm]=!0}static isInstance(t){return Y.hasMarker(t,gm)}};vm=lI;function sn(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var ym="AI_InvalidArgumentError",bm=`vercel.ai.error.${ym}`,dI=Symbol.for(bm),_m,Vi=class extends Y{constructor({message:t,cause:n,argument:o}){super({name:ym,message:t,cause:n}),this[_m]=!0,this.argument=o}static isInstance(t){return Y.hasMarker(t,bm)}};_m=dI;var wm="AI_InvalidPromptError",xm=`vercel.ai.error.${wm}`,pI=Symbol.for(xm),$m,jr=class extends Y{constructor({prompt:t,message:n,cause:o}){super({name:wm,message:`Invalid prompt: ${n}`,cause:o}),this[$m]=!0,this.prompt=t}static isInstance(t){return Y.hasMarker(t,xm)}};$m=pI;var Sm="AI_JSONParseError",Im=`vercel.ai.error.${Sm}`,fI=Symbol.for(Im),km,Jr=class extends Y{constructor({text:t,cause:n}){super({name:Sm,message:`JSON parsing failed: Text: ${t}.
|
|
2
|
+
Error message: ${sn(n)}`,cause:n}),this[km]=!0,this.text=t}static isInstance(t){return Y.hasMarker(t,Im)}};km=fI;var Em="AI_NoSuchModelError",Tm=`vercel.ai.error.${Em}`,mI=Symbol.for(Tm),Om,hI=class extends Y{constructor({errorName:e=Em,modelId:t,modelType:n,message:o=`No such ${n}: ${t}`}){super({name:e,message:o}),this[Om]=!0,this.modelId=t,this.modelType=n}static isInstance(e){return Y.hasMarker(e,Tm)}};Om=mI;var Nm="AI_TypeValidationError",Pm=`vercel.ai.error.${Nm}`,gI=Symbol.for(Pm),Cm,vI=class Gs extends Y{constructor({value:t,cause:n}){super({name:Nm,message:`Type validation failed: Value: ${JSON.stringify(t)}.
|
|
3
|
+
Error message: ${sn(n)}`,cause:n}),this[Cm]=!0,this.value=t}static isInstance(t){return Y.hasMarker(t,Pm)}static wrap({value:t,cause:n}){return Gs.isInstance(n)&&n.value===t?n:new Gs({value:t,cause:n})}};Cm=gI;var Ft=vI;let Ad=class extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}};function hs(e){}function yI(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=hs,onError:n=hs,onRetry:o=hs,onComment:r}=e;let i="",a=!0,s,l="",u="";function c(h){const b=a?h.replace(/^\xEF\xBB\xBF/,""):h,[y,x]=bI(`${i}${b}`);for(const $ of y)d($);i=x,a=!1}function d(h){if(h===""){p();return}if(h.startsWith(":")){r&&r(h.slice(h.startsWith(": ")?2:1));return}const b=h.indexOf(":");if(b!==-1){const y=h.slice(0,b),x=h[b+1]===" "?2:1,$=h.slice(b+x);f(y,$,h);return}f(h,"",h)}function f(h,b,y){switch(h){case"event":u=b;break;case"data":l=`${l}${b}
|
|
4
|
+
`;break;case"id":s=b.includes("\0")?void 0:b;break;case"retry":/^\d+$/.test(b)?o(parseInt(b,10)):n(new Ad(`Invalid \`retry\` value: "${b}"`,{type:"invalid-retry",value:b,line:y}));break;default:n(new Ad(`Unknown field "${h.length>20?`${h.slice(0,20)}…`:h}"`,{type:"unknown-field",field:h,value:b,line:y}));break}}function p(){l.length>0&&t({id:s,event:u||void 0,data:l.endsWith(`
|
|
5
|
+
`)?l.slice(0,-1):l}),s=void 0,l="",u=""}function g(h={}){i&&h.consume&&d(i),a=!0,s=void 0,l="",u="",i=""}return{feed:c,reset:g}}function bI(e){const t=[];let n="",o=0;for(;o<e.length;){const r=e.indexOf("\r",o),i=e.indexOf(`
|
|
6
6
|
`,o);let a=-1;if(r!==-1&&i!==-1?a=Math.min(r,i):r!==-1?r===e.length-1?a=-1:a=r:i!==-1&&(a=i),a===-1){n=e.slice(o);break}else{const s=e.slice(o,a);t.push(s),o=a+1,e[o-1]==="\r"&&e[o]===`
|
|
7
|
-
`&&o++}}return[t,n]}let Nn=class extends TransformStream{constructor({onError:t,onRetry:n,onComment:o}={}){let r;super({start(i){r=pI({onEvent:a=>{i.enqueue(a)},onError(a){t==="terminate"?i.error(a):typeof t=="function"&&t(a)},onRetry:n,onComment:o})},transform(i){r.feed(i)}})}};const zu=Object.freeze({status:"aborted"});function S(e,t,n){function o(s,l){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,l);const u=a.prototype,c=Object.keys(u);for(let d=0;d<c.length;d++){const p=c[d];p in s||(s[p]=u[p].bind(s))}}const r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function a(s){var l;const u=n?.Parent?new i:this;o(u,s),(l=u._zod).deferred??(l.deferred=[]);for(const c of u._zod.deferred)c();return u}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}const Cm=Symbol("zod_brand");class gr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Fi extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const ui={};function De(e){return e&&Object.assign(ui,e),ui}function hI(e){return e}function gI(e){return e}function vI(e){}function yI(e){throw new Error("Unexpected value in exhaustive check")}function bI(e){}function Mu(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function j(e,t="|"){return e.map(n=>H(n)).join(t)}function li(e,t){return typeof t=="bigint"?t.toString():t}function Xn(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function kr(e){return e==null}function qi(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function jm(e,t){const n=(e.toString().split(".")[1]||"").length,o=t.toString();let r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){const l=o.match(/\d?e-(\d?)/);l?.[1]&&(r=Number.parseInt(l[1]))}const i=n>r?n:r,a=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return a%s/10**i}const jd=Symbol("evaluating");function ne(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==jd)return o===void 0&&(o=jd,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function _I(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function lr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ht(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function wI(e){return Ht(e._zod.def)}function xI(e,t){return t?t.reduce((n,o)=>n?.[o],e):e}function $I(e){const t=Object.keys(e),n=t.map(o=>e[o]);return Promise.all(n).then(o=>{const r={};for(let i=0;i<t.length;i++)r[t[i]]=o[i];return r})}function SI(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let o=0;o<e;o++)n+=t[Math.floor(Math.random()*t.length)];return n}function Js(e){return JSON.stringify(e)}function Am(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Du="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Jr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Rm=Xn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function vr(e){if(Jr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Jr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Vi(e){return vr(e)?{...e}:Array.isArray(e)?[...e]:e}function II(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const kI=e=>{const t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},ci=new Set(["string","number","symbol"]),zm=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Vt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ft(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(o._zod.parent=e),o}function P(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function EI(e){let t;return new Proxy({},{get(n,o,r){return t??(t=e()),Reflect.get(t,o,r)},set(n,o,r,i){return t??(t=e()),Reflect.set(t,o,r,i)},has(n,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(n,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(n,o,r){return t??(t=e()),Reflect.defineProperty(t,o,r)}})}function H(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Mm(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Dm={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Um={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Lm(e,t){const n=e._zod.def,o=Ht(e._zod.def,{get shape(){const r={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=n.shape[i])}return lr(this,"shape",r),r},checks:[]});return ft(e,o)}function Zm(e,t){const n=e._zod.def,o=Ht(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return lr(this,"shape",r),r},checks:[]});return ft(e,o)}function Fm(e,t){if(!vr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const r=Ht(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return lr(this,"shape",i),i},checks:[]});return ft(e,r)}function qm(e,t){if(!vr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const o={...e._zod.def.shape,...t};return lr(this,"shape",o),o},checks:e._zod.def.checks};return ft(e,n)}function Vm(e,t){const n=Ht(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return lr(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return ft(e,n)}function Bm(e,t,n){const o=Ht(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const a in n){if(!(a in r))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=e?new e({type:"optional",innerType:r[a]}):r[a])}else for(const a in r)i[a]=e?new e({type:"optional",innerType:r[a]}):r[a];return lr(this,"shape",i),i},checks:[]});return ft(t,o)}function Jm(e,t,n){const o=Ht(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const a in n){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=new e({type:"nonoptional",innerType:r[a]}))}else for(const a in r)i[a]=new e({type:"nonoptional",innerType:r[a]});return lr(this,"shape",i),i},checks:[]});return ft(t,o)}function pr(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function wt(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function xn(e){return typeof e=="string"?e:e?.message}function lt(e,t,n){const o={...e,path:e.path??[]};if(!e.message){const r=xn(e.inst?._zod.def?.error?.(e))??xn(t?.error?.(e))??xn(n.customError?.(e))??xn(n.localeError?.(e))??"Invalid input";o.message=r}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function Bi(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Ji(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Wr(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}function OI(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Wm(e){const t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}function Hm(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function TI(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return Wm(t+n)}function NI(e){return Hm(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function PI(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const n=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)n[o/2]=Number.parseInt(t.slice(o,o+2),16);return n}function CI(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class jI{constructor(...t){}}const Gm=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:Um,Class:jI,NUMBER_FORMAT_RANGES:Dm,aborted:pr,allowsEval:Rm,assert:bI,assertEqual:hI,assertIs:vI,assertNever:yI,assertNotEqual:gI,assignProp:lr,base64ToUint8Array:Wm,base64urlToUint8Array:TI,cached:Xn,captureStackTrace:Du,cleanEnum:OI,cleanRegex:qi,clone:ft,cloneDef:wI,createTransparentProxy:EI,defineLazy:ne,esc:Js,escapeRegex:Vt,extend:Fm,finalizeIssue:lt,floatSafeRemainder:jm,getElementAtPath:xI,getEnumValues:Mu,getLengthableOrigin:Ji,getParsedType:kI,getSizableOrigin:Bi,hexToUint8Array:PI,isObject:Jr,isPlainObject:vr,issue:Wr,joinValues:j,jsonStringifyReplacer:li,merge:Vm,mergeDefs:Ht,normalizeParams:P,nullish:kr,numKeys:II,objectClone:_I,omit:Zm,optionalKeys:Mm,partial:Bm,pick:Lm,prefixIssues:wt,primitiveTypes:zm,promiseAllObject:$I,propertyKeyTypes:ci,randomString:SI,required:Jm,safeExtend:qm,shallowClone:Vi,slugify:Am,stringifyPrimitive:H,uint8ArrayToBase64:Hm,uint8ArrayToBase64url:NI,uint8ArrayToHex:CI,unwrapMessage:xn},Symbol.toStringTag,{value:"Module"})),Km=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,li,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Uu=S("$ZodError",Km),nt=S("$ZodError",Km,{Parent:Error});function Lu(e,t=n=>n.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function Zu(e,t=n=>n.message){const n={_errors:[]},o=r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let a=n,s=0;for(;s<i.path.length;){const l=i.path[s];s===i.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(i))):a[l]=a[l]||{_errors:[]},a=a[l],s++}}};return o(e),n}function Ym(e,t=n=>n.message){const n={errors:[]},o=(r,i=[])=>{var a,s;for(const l of r.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(u=>o({issues:u},l.path));else if(l.code==="invalid_key")o({issues:l.issues},l.path);else if(l.code==="invalid_element")o({issues:l.issues},l.path);else{const u=[...i,...l.path];if(u.length===0){n.errors.push(t(l));continue}let c=n,d=0;for(;d<u.length;){const p=u[d],f=d===u.length-1;typeof p=="string"?(c.properties??(c.properties={}),(a=c.properties)[p]??(a[p]={errors:[]}),c=c.properties[p]):(c.items??(c.items=[]),(s=c.items)[p]??(s[p]={errors:[]}),c=c.items[p]),f&&c.errors.push(t(l)),d++}}};return o(e),n}function Qm(e){const t=[],n=e.map(o=>typeof o=="object"?o.key:o);for(const o of n)typeof o=="number"?t.push(`[${o}]`):typeof o=="symbol"?t.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?t.push(`[${JSON.stringify(o)}]`):(t.length&&t.push("."),t.push(o));return t.join("")}function Xm(e){const t=[],n=[...e.issues].sort((o,r)=>(o.path??[]).length-(r.path??[]).length);for(const o of n)t.push(`✖ ${o.message}`),o.path?.length&&t.push(` → at ${Qm(o.path)}`);return t.join(`
|
|
8
|
-
`)}const eo=e=>(t,n,o,r)=>{const i=o?Object.assign(o,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new gr;if(a.issues.length){const s=new(r?.Err??e)(a.issues.map(l=>lt(l,i,De())));throw Du(s,r?.callee),s}return a.value},Ws=eo(nt),to=e=>async(t,n,o,r)=>{const i=o?Object.assign(o,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const s=new(r?.Err??e)(a.issues.map(l=>lt(l,i,De())));throw Du(s,r?.callee),s}return a.value},Hs=to(nt),ro=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new gr;return i.issues.length?{success:!1,error:new(e??Uu)(i.issues.map(a=>lt(a,r,De())))}:{success:!0,data:i.value}},eh=ro(nt),no=e=>async(t,n,o)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>lt(a,r,De())))}:{success:!0,data:i.value}},th=no(nt),Fu=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return eo(e)(t,n,r)},AI=Fu(nt),qu=e=>(t,n,o)=>eo(e)(t,n,o),RI=qu(nt),Vu=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return to(e)(t,n,r)},zI=Vu(nt),Bu=e=>async(t,n,o)=>to(e)(t,n,o),MI=Bu(nt),Ju=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ro(e)(t,n,r)},DI=Ju(nt),Wu=e=>(t,n,o)=>ro(e)(t,n,o),UI=Wu(nt),Hu=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return no(e)(t,n,r)},LI=Hu(nt),Gu=e=>async(t,n,o)=>no(e)(t,n,o),ZI=Gu(nt),rh=/^[cC][^\s-]{8,}$/,nh=/^[0-9a-z]+$/,oh=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ih=/^[0-9a-vA-V]{20}$/,ah=/^[A-Za-z0-9]{27}$/,sh=/^[a-zA-Z0-9_-]{21}$/,uh=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,FI=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,lh=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Hr=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,qI=Hr(4),VI=Hr(6),BI=Hr(7),ch=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,JI=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,WI=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,dh=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,HI=dh,GI=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,KI="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function fh(){return new RegExp(KI,"u")}const ph=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,mh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,hh=e=>{const t=Vt(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},gh=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,vh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yh=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ku=/^[A-Za-z0-9_-]*$/,bh=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,_h=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,wh=/^\+(?:[0-9]){6,14}[0-9]$/,xh="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",$h=new RegExp(`^${xh}$`);function Sh(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ih(e){return new RegExp(`^${Sh(e)}$`)}function kh(e){const t=Sh({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${xh}T(?:${o})$`)}const Eh=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Oh=/^-?\d+n?$/,Th=/^-?\d+$/,Nh=/^-?\d+(?:\.\d+)?/,Ph=/^(?:true|false)$/i,Ch=/^null$/i,jh=/^undefined$/i,Ah=/^[^A-Z]*$/,Rh=/^[^a-z]*$/,zh=/^[0-9a-fA-F]*$/;function oo(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function io(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const YI=/^[0-9a-fA-F]{32}$/,QI=oo(22,"=="),XI=io(22),ek=/^[0-9a-fA-F]{40}$/,tk=oo(27,"="),rk=io(27),nk=/^[0-9a-fA-F]{64}$/,ok=oo(43,"="),ik=io(43),ak=/^[0-9a-fA-F]{96}$/,sk=oo(64,""),uk=io(64),lk=/^[0-9a-fA-F]{128}$/,ck=oo(86,"=="),dk=io(86),Yu=Object.freeze(Object.defineProperty({__proto__:null,base64:yh,base64url:Ku,bigint:Oh,boolean:Ph,browserEmail:GI,cidrv4:gh,cidrv6:vh,cuid:rh,cuid2:nh,date:$h,datetime:kh,domain:_h,duration:uh,e164:wh,email:ch,emoji:fh,extendedDuration:FI,guid:lh,hex:zh,hostname:bh,html5Email:JI,idnEmail:HI,integer:Th,ipv4:ph,ipv6:mh,ksuid:ah,lowercase:Ah,mac:hh,md5_base64:QI,md5_base64url:XI,md5_hex:YI,nanoid:sh,null:Ch,number:Nh,rfc5322Email:WI,sha1_base64:tk,sha1_base64url:rk,sha1_hex:ek,sha256_base64:ok,sha256_base64url:ik,sha256_hex:nk,sha384_base64:sk,sha384_base64url:uk,sha384_hex:ak,sha512_base64:ck,sha512_base64url:dk,sha512_hex:lk,string:Eh,time:Ih,ulid:oh,undefined:jh,unicodeEmail:dh,uppercase:Rh,uuid:Hr,uuid4:qI,uuid6:VI,uuid7:BI,xid:ih},Symbol.toStringTag,{value:"Module"})),Se=S("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Mh={number:"number",bigint:"bigint",object:"date"},Qu=S("$ZodCheckLessThan",(e,t)=>{Se.init(e,t);const n=Mh[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Xu=S("$ZodCheckGreaterThan",(e,t)=>{Se.init(e,t);const n=Mh[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Dh=S("$ZodCheckMultipleOf",(e,t)=>{Se.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):jm(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Uh=S("$ZodCheckNumberFormat",(e,t)=>{Se.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[r,i]=Dm[t.format];e._zod.onattach.push(a=>{const s=a._zod.bag;s.format=t.format,s.minimum=r,s.maximum=i,n&&(s.pattern=Th)}),e._zod.check=a=>{const s=a.value;if(n){if(!Number.isInteger(s)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,continue:!t.abort});return}}s<r&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inst:e})}}),Lh=S("$ZodCheckBigIntFormat",(e,t)=>{Se.init(e,t);const[n,o]=Um[t.format];e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,i.minimum=n,i.maximum=o}),e._zod.check=r=>{const i=r.value;i<n&&r.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>o&&r.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inst:e})}}),Zh=S("$ZodCheckMaxSize",(e,t)=>{var n;Se.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!kr(r)&&r.size!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const r=o.value;r.size<=t.maximum||o.issues.push({origin:Bi(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Fh=S("$ZodCheckMinSize",(e,t)=>{var n;Se.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!kr(r)&&r.size!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;r.size>=t.minimum||o.issues.push({origin:Bi(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),qh=S("$ZodCheckSizeEquals",(e,t)=>{var n;Se.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!kr(r)&&r.size!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.size,r.maximum=t.size,r.size=t.size}),e._zod.check=o=>{const r=o.value,i=r.size;if(i===t.size)return;const a=i>t.size;o.issues.push({origin:Bi(r),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Vh=S("$ZodCheckMaxLength",(e,t)=>{var n;Se.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!kr(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const r=o.value;if(r.length<=t.maximum)return;const a=Ji(r);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Bh=S("$ZodCheckMinLength",(e,t)=>{var n;Se.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!kr(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;if(r.length>=t.minimum)return;const a=Ji(r);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Jh=S("$ZodCheckLengthEquals",(e,t)=>{var n;Se.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!kr(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{const r=o.value,i=r.length;if(i===t.length)return;const a=Ji(r),s=i>t.length;o.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),ao=S("$ZodCheckStringFormat",(e,t)=>{var n,o;Se.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Wh=S("$ZodCheckRegex",(e,t)=>{ao.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Hh=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ah),ao.init(e,t)}),Gh=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Rh),ao.init(e,t)}),Kh=S("$ZodCheckIncludes",(e,t)=>{Se.init(e,t);const n=Vt(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Yh=S("$ZodCheckStartsWith",(e,t)=>{Se.init(e,t);const n=new RegExp(`^${Vt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Qh=S("$ZodCheckEndsWith",(e,t)=>{Se.init(e,t);const n=new RegExp(`.*${Vt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});function Ad(e,t,n){e.issues.length&&t.issues.push(...wt(n,e.issues))}const Xh=S("$ZodCheckProperty",(e,t)=>{Se.init(e,t),e._zod.check=n=>{const o=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(o instanceof Promise)return o.then(r=>Ad(r,n,t.property));Ad(o,n,t.property)}}),eg=S("$ZodCheckMimeType",(e,t)=>{Se.init(e,t);const n=new Set(t.mime);e._zod.onattach.push(o=>{o._zod.bag.mime=t.mime}),e._zod.check=o=>{n.has(o.value.type)||o.issues.push({code:"invalid_value",values:t.mime,input:o.value.type,inst:e,continue:!t.abort})}}),tg=S("$ZodCheckOverwrite",(e,t)=>{Se.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class rg{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(`
|
|
7
|
+
`&&o++}}return[t,n]}let Pn=class extends TransformStream{constructor({onError:t,onRetry:n,onComment:o}={}){let r;super({start(i){r=yI({onEvent:a=>{i.enqueue(a)},onError(a){t==="terminate"?i.error(a):typeof t=="function"&&t(a)},onRetry:n,onComment:o})},transform(i){r.feed(i)}})}};const Uu=Object.freeze({status:"aborted"});function S(e,t,n){function o(s,l){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,l);const u=a.prototype,c=Object.keys(u);for(let d=0;d<c.length;d++){const f=c[d];f in s||(s[f]=u[f].bind(s))}}const r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function a(s){var l;const u=n?.Parent?new i:this;o(u,s),(l=u._zod).deferred??(l.deferred=[]);for(const c of u._zod.deferred)c();return u}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}const jm=Symbol("zod_brand");class vr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Bi extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const ci={};function De(e){return e&&Object.assign(ci,e),ci}function _I(e){return e}function wI(e){return e}function xI(e){}function $I(e){throw new Error("Unexpected value in exhaustive check")}function SI(e){}function Lu(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function j(e,t="|"){return e.map(n=>H(n)).join(t)}function di(e,t){return typeof t=="bigint"?t.toString():t}function eo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Er(e){return e==null}function Ji(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Am(e,t){const n=(e.toString().split(".")[1]||"").length,o=t.toString();let r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){const l=o.match(/\d?e-(\d?)/);l?.[1]&&(r=Number.parseInt(l[1]))}const i=n>r?n:r,a=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return a%s/10**i}const Rd=Symbol("evaluating");function ne(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==Rd)return o===void 0&&(o=Rd,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function II(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function cr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Wt(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function kI(e){return Wt(e._zod.def)}function EI(e,t){return t?t.reduce((n,o)=>n?.[o],e):e}function TI(e){const t=Object.keys(e),n=t.map(o=>e[o]);return Promise.all(n).then(o=>{const r={};for(let i=0;i<t.length;i++)r[t[i]]=o[i];return r})}function OI(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let o=0;o<e;o++)n+=t[Math.floor(Math.random()*t.length)];return n}function Ks(e){return JSON.stringify(e)}function Rm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Zu="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Wr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const zm=eo(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function yr(e){if(Wr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Wr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Wi(e){return yr(e)?{...e}:Array.isArray(e)?[...e]:e}function NI(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const PI=e=>{const t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},pi=new Set(["string","number","symbol"]),Mm=new Set(["string","number","bigint","boolean","symbol","undefined"]);function qt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dt(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(o._zod.parent=e),o}function P(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function CI(e){let t;return new Proxy({},{get(n,o,r){return t??(t=e()),Reflect.get(t,o,r)},set(n,o,r,i){return t??(t=e()),Reflect.set(t,o,r,i)},has(n,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(n,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(n,o,r){return t??(t=e()),Reflect.defineProperty(t,o,r)}})}function H(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Dm(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Um={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Lm={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Zm(e,t){const n=e._zod.def,o=Wt(e._zod.def,{get shape(){const r={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=n.shape[i])}return cr(this,"shape",r),r},checks:[]});return dt(e,o)}function Fm(e,t){const n=e._zod.def,o=Wt(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return cr(this,"shape",r),r},checks:[]});return dt(e,o)}function qm(e,t){if(!yr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const r=Wt(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return cr(this,"shape",i),i},checks:[]});return dt(e,r)}function Vm(e,t){if(!yr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const o={...e._zod.def.shape,...t};return cr(this,"shape",o),o},checks:e._zod.def.checks};return dt(e,n)}function Bm(e,t){const n=Wt(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return cr(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return dt(e,n)}function Jm(e,t,n){const o=Wt(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const a in n){if(!(a in r))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=e?new e({type:"optional",innerType:r[a]}):r[a])}else for(const a in r)i[a]=e?new e({type:"optional",innerType:r[a]}):r[a];return cr(this,"shape",i),i},checks:[]});return dt(t,o)}function Wm(e,t,n){const o=Wt(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const a in n){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=new e({type:"nonoptional",innerType:r[a]}))}else for(const a in r)i[a]=new e({type:"nonoptional",innerType:r[a]});return cr(this,"shape",i),i},checks:[]});return dt(t,o)}function mr(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function _t(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function $n(e){return typeof e=="string"?e:e?.message}function ut(e,t,n){const o={...e,path:e.path??[]};if(!e.message){const r=$n(e.inst?._zod.def?.error?.(e))??$n(t?.error?.(e))??$n(n.customError?.(e))??$n(n.localeError?.(e))??"Invalid input";o.message=r}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function Hi(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Gi(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Hr(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}function jI(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Hm(e){const t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}function Gm(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function AI(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return Hm(t+n)}function RI(e){return Gm(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function zI(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const n=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)n[o/2]=Number.parseInt(t.slice(o,o+2),16);return n}function MI(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class DI{constructor(...t){}}const Km=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:Lm,Class:DI,NUMBER_FORMAT_RANGES:Um,aborted:mr,allowsEval:zm,assert:SI,assertEqual:_I,assertIs:xI,assertNever:$I,assertNotEqual:wI,assignProp:cr,base64ToUint8Array:Hm,base64urlToUint8Array:AI,cached:eo,captureStackTrace:Zu,cleanEnum:jI,cleanRegex:Ji,clone:dt,cloneDef:kI,createTransparentProxy:CI,defineLazy:ne,esc:Ks,escapeRegex:qt,extend:qm,finalizeIssue:ut,floatSafeRemainder:Am,getElementAtPath:EI,getEnumValues:Lu,getLengthableOrigin:Gi,getParsedType:PI,getSizableOrigin:Hi,hexToUint8Array:zI,isObject:Wr,isPlainObject:yr,issue:Hr,joinValues:j,jsonStringifyReplacer:di,merge:Bm,mergeDefs:Wt,normalizeParams:P,nullish:Er,numKeys:NI,objectClone:II,omit:Fm,optionalKeys:Dm,partial:Jm,pick:Zm,prefixIssues:_t,primitiveTypes:Mm,promiseAllObject:TI,propertyKeyTypes:pi,randomString:OI,required:Wm,safeExtend:Vm,shallowClone:Wi,slugify:Rm,stringifyPrimitive:H,uint8ArrayToBase64:Gm,uint8ArrayToBase64url:RI,uint8ArrayToHex:MI,unwrapMessage:$n},Symbol.toStringTag,{value:"Module"})),Ym=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,di,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Fu=S("$ZodError",Ym),nt=S("$ZodError",Ym,{Parent:Error});function qu(e,t=n=>n.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function Vu(e,t=n=>n.message){const n={_errors:[]},o=r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let a=n,s=0;for(;s<i.path.length;){const l=i.path[s];s===i.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(i))):a[l]=a[l]||{_errors:[]},a=a[l],s++}}};return o(e),n}function Qm(e,t=n=>n.message){const n={errors:[]},o=(r,i=[])=>{var a,s;for(const l of r.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(u=>o({issues:u},l.path));else if(l.code==="invalid_key")o({issues:l.issues},l.path);else if(l.code==="invalid_element")o({issues:l.issues},l.path);else{const u=[...i,...l.path];if(u.length===0){n.errors.push(t(l));continue}let c=n,d=0;for(;d<u.length;){const f=u[d],p=d===u.length-1;typeof f=="string"?(c.properties??(c.properties={}),(a=c.properties)[f]??(a[f]={errors:[]}),c=c.properties[f]):(c.items??(c.items=[]),(s=c.items)[f]??(s[f]={errors:[]}),c=c.items[f]),p&&c.errors.push(t(l)),d++}}};return o(e),n}function Xm(e){const t=[],n=e.map(o=>typeof o=="object"?o.key:o);for(const o of n)typeof o=="number"?t.push(`[${o}]`):typeof o=="symbol"?t.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?t.push(`[${JSON.stringify(o)}]`):(t.length&&t.push("."),t.push(o));return t.join("")}function eh(e){const t=[],n=[...e.issues].sort((o,r)=>(o.path??[]).length-(r.path??[]).length);for(const o of n)t.push(`✖ ${o.message}`),o.path?.length&&t.push(` → at ${Xm(o.path)}`);return t.join(`
|
|
8
|
+
`)}const to=e=>(t,n,o,r)=>{const i=o?Object.assign(o,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new vr;if(a.issues.length){const s=new(r?.Err??e)(a.issues.map(l=>ut(l,i,De())));throw Zu(s,r?.callee),s}return a.value},Ys=to(nt),ro=e=>async(t,n,o,r)=>{const i=o?Object.assign(o,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const s=new(r?.Err??e)(a.issues.map(l=>ut(l,i,De())));throw Zu(s,r?.callee),s}return a.value},Qs=ro(nt),no=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new vr;return i.issues.length?{success:!1,error:new(e??Fu)(i.issues.map(a=>ut(a,r,De())))}:{success:!0,data:i.value}},th=no(nt),oo=e=>async(t,n,o)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>ut(a,r,De())))}:{success:!0,data:i.value}},rh=oo(nt),Bu=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return to(e)(t,n,r)},UI=Bu(nt),Ju=e=>(t,n,o)=>to(e)(t,n,o),LI=Ju(nt),Wu=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ro(e)(t,n,r)},ZI=Wu(nt),Hu=e=>async(t,n,o)=>ro(e)(t,n,o),FI=Hu(nt),Gu=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return no(e)(t,n,r)},qI=Gu(nt),Ku=e=>(t,n,o)=>no(e)(t,n,o),VI=Ku(nt),Yu=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return oo(e)(t,n,r)},BI=Yu(nt),Qu=e=>async(t,n,o)=>oo(e)(t,n,o),JI=Qu(nt),nh=/^[cC][^\s-]{8,}$/,oh=/^[0-9a-z]+$/,ih=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ah=/^[0-9a-vA-V]{20}$/,sh=/^[A-Za-z0-9]{27}$/,uh=/^[a-zA-Z0-9_-]{21}$/,lh=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,WI=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ch=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Gr=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,HI=Gr(4),GI=Gr(6),KI=Gr(7),dh=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,YI=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,QI=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,ph=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,XI=ph,ek=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,tk="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function fh(){return new RegExp(tk,"u")}const mh=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,hh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,gh=e=>{const t=qt(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},vh=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,yh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,bh=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Xu=/^[A-Za-z0-9_-]*$/,_h=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,wh=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,xh=/^\+(?:[0-9]){6,14}[0-9]$/,$h="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Sh=new RegExp(`^${$h}$`);function Ih(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function kh(e){return new RegExp(`^${Ih(e)}$`)}function Eh(e){const t=Ih({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${$h}T(?:${o})$`)}const Th=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Oh=/^-?\d+n?$/,Nh=/^-?\d+$/,Ph=/^-?\d+(?:\.\d+)?/,Ch=/^(?:true|false)$/i,jh=/^null$/i,Ah=/^undefined$/i,Rh=/^[^A-Z]*$/,zh=/^[^a-z]*$/,Mh=/^[0-9a-fA-F]*$/;function io(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function ao(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const rk=/^[0-9a-fA-F]{32}$/,nk=io(22,"=="),ok=ao(22),ik=/^[0-9a-fA-F]{40}$/,ak=io(27,"="),sk=ao(27),uk=/^[0-9a-fA-F]{64}$/,lk=io(43,"="),ck=ao(43),dk=/^[0-9a-fA-F]{96}$/,pk=io(64,""),fk=ao(64),mk=/^[0-9a-fA-F]{128}$/,hk=io(86,"=="),gk=ao(86),el=Object.freeze(Object.defineProperty({__proto__:null,base64:bh,base64url:Xu,bigint:Oh,boolean:Ch,browserEmail:ek,cidrv4:vh,cidrv6:yh,cuid:nh,cuid2:oh,date:Sh,datetime:Eh,domain:wh,duration:lh,e164:xh,email:dh,emoji:fh,extendedDuration:WI,guid:ch,hex:Mh,hostname:_h,html5Email:YI,idnEmail:XI,integer:Nh,ipv4:mh,ipv6:hh,ksuid:sh,lowercase:Rh,mac:gh,md5_base64:nk,md5_base64url:ok,md5_hex:rk,nanoid:uh,null:jh,number:Ph,rfc5322Email:QI,sha1_base64:ak,sha1_base64url:sk,sha1_hex:ik,sha256_base64:lk,sha256_base64url:ck,sha256_hex:uk,sha384_base64:pk,sha384_base64url:fk,sha384_hex:dk,sha512_base64:hk,sha512_base64url:gk,sha512_hex:mk,string:Th,time:kh,ulid:ih,undefined:Ah,unicodeEmail:ph,uppercase:zh,uuid:Gr,uuid4:HI,uuid6:GI,uuid7:KI,xid:ah},Symbol.toStringTag,{value:"Module"})),Se=S("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Dh={number:"number",bigint:"bigint",object:"date"},tl=S("$ZodCheckLessThan",(e,t)=>{Se.init(e,t);const n=Dh[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rl=S("$ZodCheckGreaterThan",(e,t)=>{Se.init(e,t);const n=Dh[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Uh=S("$ZodCheckMultipleOf",(e,t)=>{Se.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Am(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Lh=S("$ZodCheckNumberFormat",(e,t)=>{Se.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[r,i]=Um[t.format];e._zod.onattach.push(a=>{const s=a._zod.bag;s.format=t.format,s.minimum=r,s.maximum=i,n&&(s.pattern=Nh)}),e._zod.check=a=>{const s=a.value;if(n){if(!Number.isInteger(s)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,continue:!t.abort});return}}s<r&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inst:e})}}),Zh=S("$ZodCheckBigIntFormat",(e,t)=>{Se.init(e,t);const[n,o]=Lm[t.format];e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,i.minimum=n,i.maximum=o}),e._zod.check=r=>{const i=r.value;i<n&&r.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>o&&r.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inst:e})}}),Fh=S("$ZodCheckMaxSize",(e,t)=>{var n;Se.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!Er(r)&&r.size!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const r=o.value;r.size<=t.maximum||o.issues.push({origin:Hi(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),qh=S("$ZodCheckMinSize",(e,t)=>{var n;Se.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!Er(r)&&r.size!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;r.size>=t.minimum||o.issues.push({origin:Hi(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Vh=S("$ZodCheckSizeEquals",(e,t)=>{var n;Se.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!Er(r)&&r.size!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.size,r.maximum=t.size,r.size=t.size}),e._zod.check=o=>{const r=o.value,i=r.size;if(i===t.size)return;const a=i>t.size;o.issues.push({origin:Hi(r),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Bh=S("$ZodCheckMaxLength",(e,t)=>{var n;Se.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!Er(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const r=o.value;if(r.length<=t.maximum)return;const a=Gi(r);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Jh=S("$ZodCheckMinLength",(e,t)=>{var n;Se.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!Er(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;if(r.length>=t.minimum)return;const a=Gi(r);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Wh=S("$ZodCheckLengthEquals",(e,t)=>{var n;Se.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!Er(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{const r=o.value,i=r.length;if(i===t.length)return;const a=Gi(r),s=i>t.length;o.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),so=S("$ZodCheckStringFormat",(e,t)=>{var n,o;Se.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Hh=S("$ZodCheckRegex",(e,t)=>{so.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Gh=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Rh),so.init(e,t)}),Kh=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zh),so.init(e,t)}),Yh=S("$ZodCheckIncludes",(e,t)=>{Se.init(e,t);const n=qt(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Qh=S("$ZodCheckStartsWith",(e,t)=>{Se.init(e,t);const n=new RegExp(`^${qt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Xh=S("$ZodCheckEndsWith",(e,t)=>{Se.init(e,t);const n=new RegExp(`.*${qt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});function zd(e,t,n){e.issues.length&&t.issues.push(..._t(n,e.issues))}const eg=S("$ZodCheckProperty",(e,t)=>{Se.init(e,t),e._zod.check=n=>{const o=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(o instanceof Promise)return o.then(r=>zd(r,n,t.property));zd(o,n,t.property)}}),tg=S("$ZodCheckMimeType",(e,t)=>{Se.init(e,t);const n=new Set(t.mime);e._zod.onattach.push(o=>{o._zod.bag.mime=t.mime}),e._zod.check=o=>{n.has(o.value.type)||o.issues.push({code:"invalid_value",values:t.mime,input:o.value.type,inst:e,continue:!t.abort})}}),rg=S("$ZodCheckOverwrite",(e,t)=>{Se.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class ng{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(`
|
|
9
9
|
`).filter(a=>a),r=Math.min(...o.map(a=>a.length-a.trimStart().length)),i=o.map(a=>a.slice(r)).map(a=>" ".repeat(this.indent*2)+a);for(const a of i)this.content.push(a)}compile(){const t=Function,n=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,r.join(`
|
|
10
|
-
`))}}const ng={major:4,minor:2,patch:1},X=S("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ng;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const r of o)for(const i of r._zod.onattach)i(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(a,s,l)=>{let u=pr(a),c;for(const d of s){if(d._zod.def.when){if(!d._zod.def.when(a))continue}else if(u)continue;const p=a.issues.length,f=d._zod.check(a);if(f instanceof Promise&&l?.async===!1)throw new gr;if(c||f instanceof Promise)c=(c??Promise.resolve()).then(async()=>{await f,a.issues.length!==p&&(u||(u=pr(a,p)))});else{if(a.issues.length===p)continue;u||(u=pr(a,p))}}return c?c.then(()=>a):a},i=(a,s,l)=>{if(pr(a))return a.aborted=!0,a;const u=r(s,o,l);if(u instanceof Promise){if(l.async===!1)throw new gr;return u.then(c=>e._zod.parse(c,l))}return e._zod.parse(u,l)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){const u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(c=>i(c,a,s)):i(u,a,s)}const l=e._zod.parse(a,s);if(l instanceof Promise){if(s.async===!1)throw new gr;return l.then(u=>r(u,o,s))}return r(l,o,s)}}e["~standard"]={validate:r=>{try{const i=eh(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return th(e,r).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}}),so=S("$ZodString",(e,t)=>{X.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Eh(e._zod.bag),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),he=S("$ZodStringFormat",(e,t)=>{ao.init(e,t),so.init(e,t)}),og=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=lh),he.init(e,t)}),ig=S("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Hr(o))}else t.pattern??(t.pattern=Hr());he.init(e,t)}),ag=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ch),he.init(e,t)}),sg=S("$ZodURL",(e,t)=>{he.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),r=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ug=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=fh()),he.init(e,t)}),lg=S("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=sh),he.init(e,t)}),cg=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=rh),he.init(e,t)}),dg=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=nh),he.init(e,t)}),fg=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=oh),he.init(e,t)}),pg=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ih),he.init(e,t)}),mg=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ah),he.init(e,t)}),hg=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=kh(t)),he.init(e,t)}),gg=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=$h),he.init(e,t)}),vg=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ih(t)),he.init(e,t)}),yg=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=uh),he.init(e,t)}),bg=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ph),he.init(e,t),e._zod.bag.format="ipv4"}),_g=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=mh),he.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),wg=S("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=hh(t.delimiter)),he.init(e,t),e._zod.bag.format="mac"}),xg=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=gh),he.init(e,t)}),$g=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=vh),he.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[r,i]=o;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function el(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Sg=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=yh),he.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{el(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Ig(e){if(!Ku.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return el(n)}const kg=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ku),he.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Ig(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Eg=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=wh),he.init(e,t)});function Og(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const Tg=S("$ZodJWT",(e,t)=>{he.init(e,t),e._zod.check=n=>{Og(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Ng=S("$ZodCustomStringFormat",(e,t)=>{he.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),tl=S("$ZodNumber",(e,t)=>{X.init(e,t),e._zod.pattern=e._zod.bag.pattern??Nh,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),Pg=S("$ZodNumberFormat",(e,t)=>{Uh.init(e,t),tl.init(e,t)}),rl=S("$ZodBoolean",(e,t)=>{X.init(e,t),e._zod.pattern=Ph,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),nl=S("$ZodBigInt",(e,t)=>{X.init(e,t),e._zod.pattern=Oh,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),Cg=S("$ZodBigIntFormat",(e,t)=>{Lh.init(e,t),nl.init(e,t)}),jg=S("$ZodSymbol",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),n}}),Ag=S("$ZodUndefined",(e,t)=>{X.init(e,t),e._zod.pattern=jh,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,o)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),Rg=S("$ZodNull",(e,t)=>{X.init(e,t),e._zod.pattern=Ch,e._zod.values=new Set([null]),e._zod.parse=(n,o)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),zg=S("$ZodAny",(e,t)=>{X.init(e,t),e._zod.parse=n=>n}),Mg=S("$ZodUnknown",(e,t)=>{X.init(e,t),e._zod.parse=n=>n}),Dg=S("$ZodNever",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),Ug=S("$ZodVoid",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),n}}),Lg=S("$ZodDate",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}const r=n.value,i=r instanceof Date;return i&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...i?{received:"Invalid Date"}:{},inst:e}),n}});function Rd(e,t,n){e.issues.length&&t.issues.push(...wt(n,e.issues)),t.value[n]=e.value}const Zg=S("$ZodArray",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const i=[];for(let a=0;a<r.length;a++){const s=r[a],l=t.element._zod.run({value:s,issues:[]},o);l instanceof Promise?i.push(l.then(u=>Rd(u,n,a))):Rd(l,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function di(e,t,n,o){e.issues.length&&t.issues.push(...wt(n,e.issues)),e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function Fg(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=Mm(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function qg(e,t,n,o,r,i){const a=[],s=r.keySet,l=r.catchall._zod,u=l.def.type;for(const c in t){if(s.has(c))continue;if(u==="never"){a.push(c);continue}const d=l.run({value:t[c],issues:[]},o);d instanceof Promise?e.push(d.then(p=>di(p,n,c,t))):di(d,n,c,t)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Vg=S("$ZodObject",(e,t)=>{if(X.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...s};return Object.defineProperty(t,"shape",{value:l}),l}})}const o=Xn(()=>Fg(t));ne(e._zod,"propValues",()=>{const s=t.shape,l={};for(const u in s){const c=s[u]._zod;if(c.values){l[u]??(l[u]=new Set);for(const d of c.values)l[u].add(d)}}return l});const r=Jr,i=t.catchall;let a;e._zod.parse=(s,l)=>{a??(a=o.value);const u=s.value;if(!r(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),s;s.value={};const c=[],d=a.shape;for(const p of a.keys){const g=d[p]._zod.run({value:u[p],issues:[]},l);g instanceof Promise?c.push(g.then(m=>di(m,s,p,u))):di(g,s,p,u)}return i?qg(c,u,s,l,o.value,e):c.length?Promise.all(c).then(()=>s):s}}),Bg=S("$ZodObjectJIT",(e,t)=>{Vg.init(e,t);const n=e._zod.parse,o=Xn(()=>Fg(t)),r=p=>{const f=new rg(["shape","payload","ctx"]),g=o.value,m=$=>{const v=Js($);return`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`};f.write("const input = payload.value;");const b=Object.create(null);let y=0;for(const $ of g.keys)b[$]=`key_${y++}`;f.write("const newResult = {};");for(const $ of g.keys){const v=b[$],k=Js($);f.write(`const ${v} = ${m($)};`),f.write(`
|
|
10
|
+
`))}}const og={major:4,minor:2,patch:1},X=S("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=og;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const r of o)for(const i of r._zod.onattach)i(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(a,s,l)=>{let u=mr(a),c;for(const d of s){if(d._zod.def.when){if(!d._zod.def.when(a))continue}else if(u)continue;const f=a.issues.length,p=d._zod.check(a);if(p instanceof Promise&&l?.async===!1)throw new vr;if(c||p instanceof Promise)c=(c??Promise.resolve()).then(async()=>{await p,a.issues.length!==f&&(u||(u=mr(a,f)))});else{if(a.issues.length===f)continue;u||(u=mr(a,f))}}return c?c.then(()=>a):a},i=(a,s,l)=>{if(mr(a))return a.aborted=!0,a;const u=r(s,o,l);if(u instanceof Promise){if(l.async===!1)throw new vr;return u.then(c=>e._zod.parse(c,l))}return e._zod.parse(u,l)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){const u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(c=>i(c,a,s)):i(u,a,s)}const l=e._zod.parse(a,s);if(l instanceof Promise){if(s.async===!1)throw new vr;return l.then(u=>r(u,o,s))}return r(l,o,s)}}e["~standard"]={validate:r=>{try{const i=th(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return rh(e,r).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}}),uo=S("$ZodString",(e,t)=>{X.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Th(e._zod.bag),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),ge=S("$ZodStringFormat",(e,t)=>{so.init(e,t),uo.init(e,t)}),ig=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ch),ge.init(e,t)}),ag=S("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Gr(o))}else t.pattern??(t.pattern=Gr());ge.init(e,t)}),sg=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=dh),ge.init(e,t)}),ug=S("$ZodURL",(e,t)=>{ge.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),r=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),lg=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=fh()),ge.init(e,t)}),cg=S("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=uh),ge.init(e,t)}),dg=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=nh),ge.init(e,t)}),pg=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=oh),ge.init(e,t)}),fg=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ih),ge.init(e,t)}),mg=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ah),ge.init(e,t)}),hg=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=sh),ge.init(e,t)}),gg=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Eh(t)),ge.init(e,t)}),vg=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Sh),ge.init(e,t)}),yg=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=kh(t)),ge.init(e,t)}),bg=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=lh),ge.init(e,t)}),_g=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=mh),ge.init(e,t),e._zod.bag.format="ipv4"}),wg=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=hh),ge.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),xg=S("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=gh(t.delimiter)),ge.init(e,t),e._zod.bag.format="mac"}),$g=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=vh),ge.init(e,t)}),Sg=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=yh),ge.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[r,i]=o;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function nl(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Ig=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=bh),ge.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{nl(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function kg(e){if(!Xu.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return nl(n)}const Eg=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Xu),ge.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{kg(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Tg=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=xh),ge.init(e,t)});function Og(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const Ng=S("$ZodJWT",(e,t)=>{ge.init(e,t),e._zod.check=n=>{Og(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Pg=S("$ZodCustomStringFormat",(e,t)=>{ge.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),ol=S("$ZodNumber",(e,t)=>{X.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ph,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),Cg=S("$ZodNumberFormat",(e,t)=>{Lh.init(e,t),ol.init(e,t)}),il=S("$ZodBoolean",(e,t)=>{X.init(e,t),e._zod.pattern=Ch,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),al=S("$ZodBigInt",(e,t)=>{X.init(e,t),e._zod.pattern=Oh,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),jg=S("$ZodBigIntFormat",(e,t)=>{Zh.init(e,t),al.init(e,t)}),Ag=S("$ZodSymbol",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),n}}),Rg=S("$ZodUndefined",(e,t)=>{X.init(e,t),e._zod.pattern=Ah,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,o)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),zg=S("$ZodNull",(e,t)=>{X.init(e,t),e._zod.pattern=jh,e._zod.values=new Set([null]),e._zod.parse=(n,o)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),Mg=S("$ZodAny",(e,t)=>{X.init(e,t),e._zod.parse=n=>n}),Dg=S("$ZodUnknown",(e,t)=>{X.init(e,t),e._zod.parse=n=>n}),Ug=S("$ZodNever",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),Lg=S("$ZodVoid",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),n}}),Zg=S("$ZodDate",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}const r=n.value,i=r instanceof Date;return i&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...i?{received:"Invalid Date"}:{},inst:e}),n}});function Md(e,t,n){e.issues.length&&t.issues.push(..._t(n,e.issues)),t.value[n]=e.value}const Fg=S("$ZodArray",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const i=[];for(let a=0;a<r.length;a++){const s=r[a],l=t.element._zod.run({value:s,issues:[]},o);l instanceof Promise?i.push(l.then(u=>Md(u,n,a))):Md(l,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function fi(e,t,n,o){e.issues.length&&t.issues.push(..._t(n,e.issues)),e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function qg(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=Dm(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Vg(e,t,n,o,r,i){const a=[],s=r.keySet,l=r.catchall._zod,u=l.def.type;for(const c in t){if(s.has(c))continue;if(u==="never"){a.push(c);continue}const d=l.run({value:t[c],issues:[]},o);d instanceof Promise?e.push(d.then(f=>fi(f,n,c,t))):fi(d,n,c,t)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Bg=S("$ZodObject",(e,t)=>{if(X.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...s};return Object.defineProperty(t,"shape",{value:l}),l}})}const o=eo(()=>qg(t));ne(e._zod,"propValues",()=>{const s=t.shape,l={};for(const u in s){const c=s[u]._zod;if(c.values){l[u]??(l[u]=new Set);for(const d of c.values)l[u].add(d)}}return l});const r=Wr,i=t.catchall;let a;e._zod.parse=(s,l)=>{a??(a=o.value);const u=s.value;if(!r(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),s;s.value={};const c=[],d=a.shape;for(const f of a.keys){const g=d[f]._zod.run({value:u[f],issues:[]},l);g instanceof Promise?c.push(g.then(h=>fi(h,s,f,u))):fi(g,s,f,u)}return i?Vg(c,u,s,l,o.value,e):c.length?Promise.all(c).then(()=>s):s}}),Jg=S("$ZodObjectJIT",(e,t)=>{Bg.init(e,t);const n=e._zod.parse,o=eo(()=>qg(t)),r=f=>{const p=new ng(["shape","payload","ctx"]),g=o.value,h=$=>{const v=Ks($);return`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`};p.write("const input = payload.value;");const b=Object.create(null);let y=0;for(const $ of g.keys)b[$]=`key_${y++}`;p.write("const newResult = {};");for(const $ of g.keys){const v=b[$],k=Ks($);p.write(`const ${v} = ${h($)};`),p.write(`
|
|
11
11
|
if (${v}.issues.length) {
|
|
12
12
|
payload.issues = payload.issues.concat(${v}.issues.map(iss => ({
|
|
13
13
|
...iss,
|
|
@@ -24,23 +24,23 @@ Error message: ${an(n)}`,cause:n}),this[Pm]=!0,this.value=t}static isInstance(t)
|
|
|
24
24
|
newResult[${k}] = ${v}.value;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
`)}f.write("payload.value = newResult;"),f.write("return payload;");const x=f.compile();return($,v)=>x(p,$,v)};let i;const a=Jr,s=!ui.jitless,u=s&&Rm.value,c=t.catchall;let d;e._zod.parse=(p,f)=>{d??(d=o.value);const g=p.value;return a(g)?s&&u&&f?.async===!1&&f.jitless!==!0?(i||(i=r(t.shape)),p=i(p,f),c?qg([],g,p,f,d,e):p):n(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),p)}});function zd(e,t,n,o){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const r=e.filter(i=>!pr(i));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>lt(a,o,De())))}),t)}const Wi=S("$ZodUnion",(e,t)=>{X.init(e,t),ne(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ne(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ne(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),ne(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${r.map(i=>qi(i.source)).join("|")})$`)}});const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,i)=>{if(n)return o(r,i);let a=!1;const s=[];for(const l of t.options){const u=l._zod.run({value:r.value,issues:[]},i);if(u instanceof Promise)s.push(u),a=!0;else{if(u.issues.length===0)return u;s.push(u)}}return a?Promise.all(s).then(l=>zd(l,r,e,i)):zd(s,r,e,i)}});function Md(e,t,n,o){const r=e.filter(i=>i.issues.length===0);return r.length===1?(t.value=r[0].value,t):(r.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>lt(a,o,De())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1}),t)}const Jg=S("$ZodXor",(e,t)=>{Wi.init(e,t),t.inclusive=!1;const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,i)=>{if(n)return o(r,i);let a=!1;const s=[];for(const l of t.options){const u=l._zod.run({value:r.value,issues:[]},i);u instanceof Promise?(s.push(u),a=!0):s.push(u)}return a?Promise.all(s).then(l=>Md(l,r,e,i)):Md(s,r,e,i)}}),Wg=S("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Wi.init(e,t);const n=e._zod.parse;ne(e._zod,"propValues",()=>{const r={};for(const i of t.options){const a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[s,l]of Object.entries(a)){r[s]||(r[s]=new Set);for(const u of l)r[s].add(u)}}return r});const o=Xn(()=>{const r=t.options,i=new Map;for(const a of r){const s=a._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const l of s){if(i.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);i.set(l,a)}}return i});e._zod.parse=(r,i)=>{const a=r.value;if(!Jr(a))return r.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),r;const s=o.value.get(a?.[t.discriminator]);return s?s._zod.run(r,i):t.unionFallback?n(r,i):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),r)}}),Hg=S("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value,i=t.left._zod.run({value:r,issues:[]},o),a=t.right._zod.run({value:r,issues:[]},o);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([l,u])=>Dd(n,l,u)):Dd(n,i,a)}});function Gs(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(vr(e)&&vr(t)){const n=Object.keys(t),o=Object.keys(e).filter(i=>n.indexOf(i)!==-1),r={...e,...t};for(const i of o){const a=Gs(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};r[i]=a.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const r=e[o],i=t[o],a=Gs(r,i);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Dd(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),pr(e))return e;const o=Gs(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const ol=S("$ZodTuple",(e,t)=>{X.init(e,t);const n=t.items;e._zod.parse=(o,r)=>{const i=o.value;if(!Array.isArray(i))return o.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];const a=[],s=[...n].reverse().findIndex(c=>c._zod.optin!=="optional"),l=s===-1?0:n.length-s;if(!t.rest){const c=i.length>n.length,d=i.length<l-1;if(c||d)return o.issues.push({...c?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},input:i,inst:e,origin:"array"}),o}let u=-1;for(const c of n){if(u++,u>=i.length&&u>=l)continue;const d=c._zod.run({value:i[u],issues:[]},r);d instanceof Promise?a.push(d.then(p=>Do(p,o,u))):Do(d,o,u)}if(t.rest){const c=i.slice(n.length);for(const d of c){u++;const p=t.rest._zod.run({value:d,issues:[]},r);p instanceof Promise?a.push(p.then(f=>Do(f,o,u))):Do(p,o,u)}}return a.length?Promise.all(a).then(()=>o):o}});function Do(e,t,n){e.issues.length&&t.issues.push(...wt(n,e.issues)),t.value[n]=e.value}const Gg=S("$ZodRecord",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!vr(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const s=new Set;for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){s.add(typeof u=="number"?u.toString():u);const c=t.valueType._zod.run({value:r[u],issues:[]},o);c instanceof Promise?i.push(c.then(d=>{d.issues.length&&n.issues.push(...wt(u,d.issues)),n.value[u]=d.value})):(c.issues.length&&n.issues.push(...wt(u,c.issues)),n.value[u]=c.value)}let l;for(const u in r)s.has(u)||(l=l??[],l.push(u));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:l})}else{n.value={};for(const s of Reflect.ownKeys(r)){if(s==="__proto__")continue;const l=t.keyType._zod.run({value:s,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){t.mode==="loose"?n.value[s]=r[s]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(c=>lt(c,o,De())),input:s,path:[s],inst:e});continue}const u=t.valueType._zod.run({value:r[s],issues:[]},o);u instanceof Promise?i.push(u.then(c=>{c.issues.length&&n.issues.push(...wt(s,c.issues)),n.value[l.value]=c.value})):(u.issues.length&&n.issues.push(...wt(s,u.issues)),n.value[l.value]=u.value)}}return i.length?Promise.all(i).then(()=>n):n}}),Kg=S("$ZodMap",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!(r instanceof Map))return n.issues.push({expected:"map",code:"invalid_type",input:r,inst:e}),n;const i=[];n.value=new Map;for(const[a,s]of r){const l=t.keyType._zod.run({value:a,issues:[]},o),u=t.valueType._zod.run({value:s,issues:[]},o);l instanceof Promise||u instanceof Promise?i.push(Promise.all([l,u]).then(([c,d])=>{Ud(c,d,n,a,r,e,o)})):Ud(l,u,n,a,r,e,o)}return i.length?Promise.all(i).then(()=>n):n}});function Ud(e,t,n,o,r,i,a){e.issues.length&&(ci.has(typeof o)?n.issues.push(...wt(o,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:r,inst:i,issues:e.issues.map(s=>lt(s,a,De()))})),t.issues.length&&(ci.has(typeof o)?n.issues.push(...wt(o,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:r,inst:i,key:o,issues:t.issues.map(s=>lt(s,a,De()))})),n.value.set(e.value,t.value)}const Yg=S("$ZodSet",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!(r instanceof Set))return n.issues.push({input:r,inst:e,expected:"set",code:"invalid_type"}),n;const i=[];n.value=new Set;for(const a of r){const s=t.valueType._zod.run({value:a,issues:[]},o);s instanceof Promise?i.push(s.then(l=>Ld(l,n))):Ld(s,n)}return i.length?Promise.all(i).then(()=>n):n}});function Ld(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const Qg=S("$ZodEnum",(e,t)=>{X.init(e,t);const n=Mu(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>ci.has(typeof r)).map(r=>typeof r=="string"?Vt(r):r.toString()).join("|")})$`),e._zod.parse=(r,i)=>{const a=r.value;return o.has(a)||r.issues.push({code:"invalid_value",values:n,input:a,inst:e}),r}}),Xg=S("$ZodLiteral",(e,t)=>{if(X.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?Vt(o):o?Vt(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,r)=>{const i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),ev=S("$ZodFile",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;return r instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:r,inst:e}),n}}),tv=S("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Fi(e.constructor.name);const r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(a=>(n.value=a,n));if(r instanceof Promise)throw new gr;return n.value=r,n}});function Zd(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const rv=S("$ZodOptional",(e,t)=>{X.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ne(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${qi(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>Zd(i,n.value)):Zd(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),nv=S("$ZodNullable",(e,t)=>{X.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${qi(n.source)}|null)$`):void 0}),ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),ov=S("$ZodDefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>Fd(i,t)):Fd(r,t)}});function Fd(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const iv=S("$ZodPrefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),av=S("$ZodNonOptional",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>qd(i,e)):qd(r,e)}});function qd(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const sv=S("$ZodSuccess",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Fi("ZodSuccess");const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>(n.value=i.issues.length===0,n)):(n.value=r.issues.length===0,n)}}),uv=S("$ZodCatch",(e,t)=>{X.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(a=>lt(a,o,De()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(i=>lt(i,o,De()))},input:n.value}),n.issues=[]),n)}}),lv=S("$ZodNaN",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),cv=S("$ZodPipe",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>t.in._zod.values),ne(e._zod,"optin",()=>t.in._zod.optin),ne(e._zod,"optout",()=>t.out._zod.optout),ne(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const i=t.out._zod.run(n,o);return i instanceof Promise?i.then(a=>Uo(a,t.in,o)):Uo(i,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(i=>Uo(i,t.out,o)):Uo(r,t.out,o)}});function Uo(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const il=S("$ZodCodec",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>t.in._zod.values),ne(e._zod,"optin",()=>t.in._zod.optin),ne(e._zod,"optout",()=>t.out._zod.optout),ne(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if((o.direction||"forward")==="forward"){const i=t.in._zod.run(n,o);return i instanceof Promise?i.then(a=>Lo(a,t,o)):Lo(i,t,o)}else{const i=t.out._zod.run(n,o);return i instanceof Promise?i.then(a=>Lo(a,t,o)):Lo(i,t,o)}}});function Lo(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){const r=t.transform(e.value,e);return r instanceof Promise?r.then(i=>Zo(e,i,t.out,n)):Zo(e,r,t.out,n)}else{const r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(i=>Zo(e,i,t.in,n)):Zo(e,r,t.in,n)}}function Zo(e,t,n,o){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},o)}const dv=S("$ZodReadonly",(e,t)=>{X.init(e,t),ne(e._zod,"propValues",()=>t.innerType._zod.propValues),ne(e._zod,"values",()=>t.innerType._zod.values),ne(e._zod,"optin",()=>t.innerType?._zod?.optin),ne(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(Vd):Vd(r)}});function Vd(e){return e.value=Object.freeze(e.value),e}const fv=S("$ZodTemplateLiteral",(e,t)=>{X.init(e,t);const n=[];for(const o of t.parts)if(typeof o=="object"&&o!==null){if(!o._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);const r=o._zod.pattern instanceof RegExp?o._zod.pattern.source:o._zod.pattern;if(!r)throw new Error(`Invalid template literal part: ${o._zod.traits}`);const i=r.startsWith("^")?1:0,a=r.endsWith("$")?r.length-1:r.length;n.push(r.slice(i,a))}else if(o===null||zm.has(typeof o))n.push(Vt(`${o}`));else throw new Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(o,r)=>typeof o.value!="string"?(o.issues.push({input:o.value,inst:e,expected:"template_literal",code:"invalid_type"}),o):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(o.value)||o.issues.push({input:o.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),o)}),pv=S("$ZodFunction",(e,t)=>(X.init(e,t),e._def=t,e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return function(...o){const r=e._def.input?Ws(e._def.input,o):o,i=Reflect.apply(n,this,r);return e._def.output?Ws(e._def.output,i):i}},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return async function(...o){const r=e._def.input?await Hs(e._def.input,o):o,i=await Reflect.apply(n,this,r);return e._def.output?await Hs(e._def.output,i):i}},e._zod.parse=(n,o)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{const o=e.constructor;return Array.isArray(n[0])?new o({type:"function",input:new ol({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new o({type:"function",input:n[0],output:e._def.output})},e.output=n=>{const o=e.constructor;return new o({type:"function",input:e._def.input,output:n})},e)),mv=S("$ZodPromise",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>Promise.resolve(n.value).then(r=>t.innerType._zod.run({value:r,issues:[]},o))}),hv=S("$ZodLazy",(e,t)=>{X.init(e,t),ne(e._zod,"innerType",()=>t.getter()),ne(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),ne(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),ne(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),ne(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,o)=>e._zod.innerType._zod.run(n,o)}),gv=S("$ZodCustom",(e,t)=>{Se.init(e,t),X.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then(i=>Bd(i,n,o,e));Bd(r,n,o,e)}});function Bd(e,t,n,o){if(!e){const r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push(Wr(r))}}const fk=()=>{const e={string:{unit:"حرف",verb:"أن يحوي"},file:{unit:"بايت",verb:"أن يحوي"},array:{unit:"عنصر",verb:"أن يحوي"},set:{unit:"عنصر",verb:"أن يحوي"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"مدخل",email:"بريد إلكتروني",url:"رابط",emoji:"إيموجي",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"تاريخ ووقت بمعيار ISO",date:"تاريخ بمعيار ISO",time:"وقت بمعيار ISO",duration:"مدة بمعيار ISO",ipv4:"عنوان IPv4",ipv6:"عنوان IPv6",cidrv4:"مدى عناوين بصيغة IPv4",cidrv6:"مدى عناوين بصيغة IPv6",base64:"نَص بترميز base64-encoded",base64url:"نَص بترميز base64url-encoded",json_string:"نَص على هيئة JSON",e164:"رقم هاتف بمعيار E.164",jwt:"JWT",template_literal:"مدخل"};return r=>{switch(r.code){case"invalid_type":return`مدخلات غير مقبولة: يفترض إدخال ${r.expected}، ولكن تم إدخال ${n(r.input)}`;case"invalid_value":return r.values.length===1?`مدخلات غير مقبولة: يفترض إدخال ${H(r.values[0])}`:`اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?` أكبر من اللازم: يفترض أن تكون ${r.origin??"القيمة"} ${i} ${r.maximum.toString()} ${a.unit??"عنصر"}`:`أكبر من اللازم: يفترض أن تكون ${r.origin??"القيمة"} ${i} ${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`أصغر من اللازم: يفترض لـ ${r.origin} أن يكون ${i} ${r.minimum.toString()} ${a.unit}`:`أصغر من اللازم: يفترض لـ ${r.origin} أن يكون ${i} ${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`نَص غير مقبول: يجب أن يبدأ بـ "${r.prefix}"`:i.format==="ends_with"?`نَص غير مقبول: يجب أن ينتهي بـ "${i.suffix}"`:i.format==="includes"?`نَص غير مقبول: يجب أن يتضمَّن "${i.includes}"`:i.format==="regex"?`نَص غير مقبول: يجب أن يطابق النمط ${i.pattern}`:`${o[i.format]??r.format} غير مقبول`}case"not_multiple_of":return`رقم غير مقبول: يجب أن يكون من مضاعفات ${r.divisor}`;case"unrecognized_keys":return`معرف${r.keys.length>1?"ات":""} غريب${r.keys.length>1?"ة":""}: ${j(r.keys,"، ")}`;case"invalid_key":return`معرف غير مقبول في ${r.origin}`;case"invalid_union":return"مدخل غير مقبول";case"invalid_element":return`مدخل غير مقبول في ${r.origin}`;default:return"مدخل غير مقبول"}}};function pk(){return{localeError:fk()}}const mk=()=>{const e={string:{unit:"simvol",verb:"olmalıdır"},file:{unit:"bayt",verb:"olmalıdır"},array:{unit:"element",verb:"olmalıdır"},set:{unit:"element",verb:"olmalıdır"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Yanlış dəyər: gözlənilən ${r.expected}, daxil olan ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Yanlış dəyər: gözlənilən ${H(r.values[0])}`:`Yanlış seçim: aşağıdakılardan biri olmalıdır: ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Çox böyük: gözlənilən ${r.origin??"dəyər"} ${i}${r.maximum.toString()} ${a.unit??"element"}`:`Çox böyük: gözlənilən ${r.origin??"dəyər"} ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Çox kiçik: gözlənilən ${r.origin} ${i}${r.minimum.toString()} ${a.unit}`:`Çox kiçik: gözlənilən ${r.origin} ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Yanlış mətn: "${i.prefix}" ilə başlamalıdır`:i.format==="ends_with"?`Yanlış mətn: "${i.suffix}" ilə bitməlidir`:i.format==="includes"?`Yanlış mətn: "${i.includes}" daxil olmalıdır`:i.format==="regex"?`Yanlış mətn: ${i.pattern} şablonuna uyğun olmalıdır`:`Yanlış ${o[i.format]??r.format}`}case"not_multiple_of":return`Yanlış ədəd: ${r.divisor} ilə bölünə bilən olmalıdır`;case"unrecognized_keys":return`Tanınmayan açar${r.keys.length>1?"lar":""}: ${j(r.keys,", ")}`;case"invalid_key":return`${r.origin} daxilində yanlış açar`;case"invalid_union":return"Yanlış dəyər";case"invalid_element":return`${r.origin} daxilində yanlış dəyər`;default:return"Yanlış dəyər"}}};function hk(){return{localeError:mk()}}function Jd(e,t,n,o){const r=Math.abs(e),i=r%10,a=r%100;return a>=11&&a<=19?o:i===1?t:i>=2&&i<=4?n:o}const gk=()=>{const e={string:{unit:{one:"сімвал",few:"сімвалы",many:"сімвалаў"},verb:"мець"},array:{unit:{one:"элемент",few:"элементы",many:"элементаў"},verb:"мець"},set:{unit:{one:"элемент",few:"элементы",many:"элементаў"},verb:"мець"},file:{unit:{one:"байт",few:"байты",many:"байтаў"},verb:"мець"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"лік";case"object":{if(Array.isArray(r))return"масіў";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"увод",email:"email адрас",url:"URL",emoji:"эмодзі",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO дата і час",date:"ISO дата",time:"ISO час",duration:"ISO працягласць",ipv4:"IPv4 адрас",ipv6:"IPv6 адрас",cidrv4:"IPv4 дыяпазон",cidrv6:"IPv6 дыяпазон",base64:"радок у фармаце base64",base64url:"радок у фармаце base64url",json_string:"JSON радок",e164:"нумар E.164",jwt:"JWT",template_literal:"увод"};return r=>{switch(r.code){case"invalid_type":return`Няправільны ўвод: чакаўся ${r.expected}, атрымана ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Няправільны ўвод: чакалася ${H(r.values[0])}`:`Няправільны варыянт: чакаўся адзін з ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);if(a){const s=Number(r.maximum),l=Jd(s,a.unit.one,a.unit.few,a.unit.many);return`Занадта вялікі: чакалася, што ${r.origin??"значэнне"} павінна ${a.verb} ${i}${r.maximum.toString()} ${l}`}return`Занадта вялікі: чакалася, што ${r.origin??"значэнне"} павінна быць ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);if(a){const s=Number(r.minimum),l=Jd(s,a.unit.one,a.unit.few,a.unit.many);return`Занадта малы: чакалася, што ${r.origin} павінна ${a.verb} ${i}${r.minimum.toString()} ${l}`}return`Занадта малы: чакалася, што ${r.origin} павінна быць ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Няправільны радок: павінен пачынацца з "${i.prefix}"`:i.format==="ends_with"?`Няправільны радок: павінен заканчвацца на "${i.suffix}"`:i.format==="includes"?`Няправільны радок: павінен змяшчаць "${i.includes}"`:i.format==="regex"?`Няправільны радок: павінен адпавядаць шаблону ${i.pattern}`:`Няправільны ${o[i.format]??r.format}`}case"not_multiple_of":return`Няправільны лік: павінен быць кратным ${r.divisor}`;case"unrecognized_keys":return`Нераспазнаны ${r.keys.length>1?"ключы":"ключ"}: ${j(r.keys,", ")}`;case"invalid_key":return`Няправільны ключ у ${r.origin}`;case"invalid_union":return"Няправільны ўвод";case"invalid_element":return`Няправільнае значэнне ў ${r.origin}`;default:return"Няправільны ўвод"}}};function vk(){return{localeError:gk()}}const yk=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"число";case"object":{if(Array.isArray(e))return"масив";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},bk=()=>{const e={string:{unit:"символа",verb:"да съдържа"},file:{unit:"байта",verb:"да съдържа"},array:{unit:"елемента",verb:"да съдържа"},set:{unit:"елемента",verb:"да съдържа"}};function t(o){return e[o]??null}const n={regex:"вход",email:"имейл адрес",url:"URL",emoji:"емоджи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO време",date:"ISO дата",time:"ISO време",duration:"ISO продължителност",ipv4:"IPv4 адрес",ipv6:"IPv6 адрес",cidrv4:"IPv4 диапазон",cidrv6:"IPv6 диапазон",base64:"base64-кодиран низ",base64url:"base64url-кодиран низ",json_string:"JSON низ",e164:"E.164 номер",jwt:"JWT",template_literal:"вход"};return o=>{switch(o.code){case"invalid_type":return`Невалиден вход: очакван ${o.expected}, получен ${yk(o.input)}`;case"invalid_value":return o.values.length===1?`Невалиден вход: очакван ${H(o.values[0])}`:`Невалидна опция: очаквано едно от ${j(o.values,"|")}`;case"too_big":{const r=o.inclusive?"<=":"<",i=t(o.origin);return i?`Твърде голямо: очаква се ${o.origin??"стойност"} да съдържа ${r}${o.maximum.toString()} ${i.unit??"елемента"}`:`Твърде голямо: очаква се ${o.origin??"стойност"} да бъде ${r}${o.maximum.toString()}`}case"too_small":{const r=o.inclusive?">=":">",i=t(o.origin);return i?`Твърде малко: очаква се ${o.origin} да съдържа ${r}${o.minimum.toString()} ${i.unit}`:`Твърде малко: очаква се ${o.origin} да бъде ${r}${o.minimum.toString()}`}case"invalid_format":{const r=o;if(r.format==="starts_with")return`Невалиден низ: трябва да започва с "${r.prefix}"`;if(r.format==="ends_with")return`Невалиден низ: трябва да завършва с "${r.suffix}"`;if(r.format==="includes")return`Невалиден низ: трябва да включва "${r.includes}"`;if(r.format==="regex")return`Невалиден низ: трябва да съвпада с ${r.pattern}`;let i="Невалиден";return r.format==="emoji"&&(i="Невалидно"),r.format==="datetime"&&(i="Невалидно"),r.format==="date"&&(i="Невалидна"),r.format==="time"&&(i="Невалидно"),r.format==="duration"&&(i="Невалидна"),`${i} ${n[r.format]??o.format}`}case"not_multiple_of":return`Невалидно число: трябва да бъде кратно на ${o.divisor}`;case"unrecognized_keys":return`Неразпознат${o.keys.length>1?"и":""} ключ${o.keys.length>1?"ове":""}: ${j(o.keys,", ")}`;case"invalid_key":return`Невалиден ключ в ${o.origin}`;case"invalid_union":return"Невалиден вход";case"invalid_element":return`Невалидна стойност в ${o.origin}`;default:return"Невалиден вход"}}};function _k(){return{localeError:bk()}}const wk=()=>{const e={string:{unit:"caràcters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"entrada",email:"adreça electrònica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adreça IPv4",ipv6:"adreça IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"};return r=>{switch(r.code){case"invalid_type":return`Tipus invàlid: s'esperava ${r.expected}, s'ha rebut ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Valor invàlid: s'esperava ${H(r.values[0])}`:`Opció invàlida: s'esperava una de ${j(r.values," o ")}`;case"too_big":{const i=r.inclusive?"com a màxim":"menys de",a=t(r.origin);return a?`Massa gran: s'esperava que ${r.origin??"el valor"} contingués ${i} ${r.maximum.toString()} ${a.unit??"elements"}`:`Massa gran: s'esperava que ${r.origin??"el valor"} fos ${i} ${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?"com a mínim":"més de",a=t(r.origin);return a?`Massa petit: s'esperava que ${r.origin} contingués ${i} ${r.minimum.toString()} ${a.unit}`:`Massa petit: s'esperava que ${r.origin} fos ${i} ${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Format invàlid: ha de començar amb "${i.prefix}"`:i.format==="ends_with"?`Format invàlid: ha d'acabar amb "${i.suffix}"`:i.format==="includes"?`Format invàlid: ha d'incloure "${i.includes}"`:i.format==="regex"?`Format invàlid: ha de coincidir amb el patró ${i.pattern}`:`Format invàlid per a ${o[i.format]??r.format}`}case"not_multiple_of":return`Número invàlid: ha de ser múltiple de ${r.divisor}`;case"unrecognized_keys":return`Clau${r.keys.length>1?"s":""} no reconeguda${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Clau invàlida a ${r.origin}`;case"invalid_union":return"Entrada invàlida";case"invalid_element":return`Element invàlid a ${r.origin}`;default:return"Entrada invàlida"}}};function xk(){return{localeError:wk()}}const $k=()=>{const e={string:{unit:"znaků",verb:"mít"},file:{unit:"bajtů",verb:"mít"},array:{unit:"prvků",verb:"mít"},set:{unit:"prvků",verb:"mít"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"číslo";case"string":return"řetězec";case"boolean":return"boolean";case"bigint":return"bigint";case"function":return"funkce";case"symbol":return"symbol";case"undefined":return"undefined";case"object":{if(Array.isArray(r))return"pole";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"regulární výraz",email:"e-mailová adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a čas ve formátu ISO",date:"datum ve formátu ISO",time:"čas ve formátu ISO",duration:"doba trvání ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"řetězec zakódovaný ve formátu base64",base64url:"řetězec zakódovaný ve formátu base64url",json_string:"řetězec ve formátu JSON",e164:"číslo E.164",jwt:"JWT",template_literal:"vstup"};return r=>{switch(r.code){case"invalid_type":return`Neplatný vstup: očekáváno ${r.expected}, obdrženo ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Neplatný vstup: očekáváno ${H(r.values[0])}`:`Neplatná možnost: očekávána jedna z hodnot ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Hodnota je příliš velká: ${r.origin??"hodnota"} musí mít ${i}${r.maximum.toString()} ${a.unit??"prvků"}`:`Hodnota je příliš velká: ${r.origin??"hodnota"} musí být ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Hodnota je příliš malá: ${r.origin??"hodnota"} musí mít ${i}${r.minimum.toString()} ${a.unit??"prvků"}`:`Hodnota je příliš malá: ${r.origin??"hodnota"} musí být ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Neplatný řetězec: musí začínat na "${i.prefix}"`:i.format==="ends_with"?`Neplatný řetězec: musí končit na "${i.suffix}"`:i.format==="includes"?`Neplatný řetězec: musí obsahovat "${i.includes}"`:i.format==="regex"?`Neplatný řetězec: musí odpovídat vzoru ${i.pattern}`:`Neplatný formát ${o[i.format]??r.format}`}case"not_multiple_of":return`Neplatné číslo: musí být násobkem ${r.divisor}`;case"unrecognized_keys":return`Neznámé klíče: ${j(r.keys,", ")}`;case"invalid_key":return`Neplatný klíč v ${r.origin}`;case"invalid_union":return"Neplatný vstup";case"invalid_element":return`Neplatná hodnota v ${r.origin}`;default:return"Neplatný vstup"}}};function Sk(){return{localeError:$k()}}const Ik=()=>{const e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}},t={string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"sæt",file:"fil"};function n(a){return e[a]??null}function o(a){return t[a]??a}const r=a=>{const s=typeof a;switch(s){case"number":return Number.isNaN(a)?"NaN":"tal";case"object":return Array.isArray(a)?"liste":a===null?"null":Object.getPrototypeOf(a)!==Object.prototype&&a.constructor?a.constructor.name:"objekt"}return s},i={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslæt",date:"ISO-dato",time:"ISO-klokkeslæt",duration:"ISO-varighed",ipv4:"IPv4-område",ipv6:"IPv6-område",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"};return a=>{switch(a.code){case"invalid_type":return`Ugyldigt input: forventede ${o(a.expected)}, fik ${o(r(a.input))}`;case"invalid_value":return a.values.length===1?`Ugyldig værdi: forventede ${H(a.values[0])}`:`Ugyldigt valg: forventede en af følgende ${j(a.values,"|")}`;case"too_big":{const s=a.inclusive?"<=":"<",l=n(a.origin),u=o(a.origin);return l?`For stor: forventede ${u??"value"} ${l.verb} ${s} ${a.maximum.toString()} ${l.unit??"elementer"}`:`For stor: forventede ${u??"value"} havde ${s} ${a.maximum.toString()}`}case"too_small":{const s=a.inclusive?">=":">",l=n(a.origin),u=o(a.origin);return l?`For lille: forventede ${u} ${l.verb} ${s} ${a.minimum.toString()} ${l.unit}`:`For lille: forventede ${u} havde ${s} ${a.minimum.toString()}`}case"invalid_format":{const s=a;return s.format==="starts_with"?`Ugyldig streng: skal starte med "${s.prefix}"`:s.format==="ends_with"?`Ugyldig streng: skal ende med "${s.suffix}"`:s.format==="includes"?`Ugyldig streng: skal indeholde "${s.includes}"`:s.format==="regex"?`Ugyldig streng: skal matche mønsteret ${s.pattern}`:`Ugyldig ${i[s.format]??a.format}`}case"not_multiple_of":return`Ugyldigt tal: skal være deleligt med ${a.divisor}`;case"unrecognized_keys":return`${a.keys.length>1?"Ukendte nøgler":"Ukendt nøgle"}: ${j(a.keys,", ")}`;case"invalid_key":return`Ugyldig nøgle i ${a.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig værdi i ${a.origin}`;default:return"Ugyldigt input"}}};function kk(){return{localeError:Ik()}}const Ek=()=>{const e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"Zahl";case"object":{if(Array.isArray(r))return"Array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"};return r=>{switch(r.code){case"invalid_type":return`Ungültige Eingabe: erwartet ${r.expected}, erhalten ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ungültige Eingabe: erwartet ${H(r.values[0])}`:`Ungültige Option: erwartet eine von ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Zu groß: erwartet, dass ${r.origin??"Wert"} ${i}${r.maximum.toString()} ${a.unit??"Elemente"} hat`:`Zu groß: erwartet, dass ${r.origin??"Wert"} ${i}${r.maximum.toString()} ist`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Zu klein: erwartet, dass ${r.origin} ${i}${r.minimum.toString()} ${a.unit} hat`:`Zu klein: erwartet, dass ${r.origin} ${i}${r.minimum.toString()} ist`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Ungültiger String: muss mit "${i.prefix}" beginnen`:i.format==="ends_with"?`Ungültiger String: muss mit "${i.suffix}" enden`:i.format==="includes"?`Ungültiger String: muss "${i.includes}" enthalten`:i.format==="regex"?`Ungültiger String: muss dem Muster ${i.pattern} entsprechen`:`Ungültig: ${o[i.format]??r.format}`}case"not_multiple_of":return`Ungültige Zahl: muss ein Vielfaches von ${r.divisor} sein`;case"unrecognized_keys":return`${r.keys.length>1?"Unbekannte Schlüssel":"Unbekannter Schlüssel"}: ${j(r.keys,", ")}`;case"invalid_key":return`Ungültiger Schlüssel in ${r.origin}`;case"invalid_union":return"Ungültige Eingabe";case"invalid_element":return`Ungültiger Wert in ${r.origin}`;default:return"Ungültige Eingabe"}}};function Ok(){return{localeError:Ek()}}const Tk=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},Nk=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(o){return e[o]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return o=>{switch(o.code){case"invalid_type":return`Invalid input: expected ${o.expected}, received ${Tk(o.input)}`;case"invalid_value":return o.values.length===1?`Invalid input: expected ${H(o.values[0])}`:`Invalid option: expected one of ${j(o.values,"|")}`;case"too_big":{const r=o.inclusive?"<=":"<",i=t(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${r}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${r}${o.maximum.toString()}`}case"too_small":{const r=o.inclusive?">=":">",i=t(o.origin);return i?`Too small: expected ${o.origin} to have ${r}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${r}${o.minimum.toString()}`}case"invalid_format":{const r=o;return r.format==="starts_with"?`Invalid string: must start with "${r.prefix}"`:r.format==="ends_with"?`Invalid string: must end with "${r.suffix}"`:r.format==="includes"?`Invalid string: must include "${r.includes}"`:r.format==="regex"?`Invalid string: must match pattern ${r.pattern}`:`Invalid ${n[r.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${j(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function vv(){return{localeError:Nk()}}const Pk=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"nombro";case"object":{if(Array.isArray(e))return"tabelo";if(e===null)return"senvalora";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},Ck=()=>{const e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(o){return e[o]??null}const n={regex:"enigo",email:"retadreso",url:"URL",emoji:"emoĝio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-daŭro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"};return o=>{switch(o.code){case"invalid_type":return`Nevalida enigo: atendiĝis ${o.expected}, riceviĝis ${Pk(o.input)}`;case"invalid_value":return o.values.length===1?`Nevalida enigo: atendiĝis ${H(o.values[0])}`:`Nevalida opcio: atendiĝis unu el ${j(o.values,"|")}`;case"too_big":{const r=o.inclusive?"<=":"<",i=t(o.origin);return i?`Tro granda: atendiĝis ke ${o.origin??"valoro"} havu ${r}${o.maximum.toString()} ${i.unit??"elementojn"}`:`Tro granda: atendiĝis ke ${o.origin??"valoro"} havu ${r}${o.maximum.toString()}`}case"too_small":{const r=o.inclusive?">=":">",i=t(o.origin);return i?`Tro malgranda: atendiĝis ke ${o.origin} havu ${r}${o.minimum.toString()} ${i.unit}`:`Tro malgranda: atendiĝis ke ${o.origin} estu ${r}${o.minimum.toString()}`}case"invalid_format":{const r=o;return r.format==="starts_with"?`Nevalida karaktraro: devas komenciĝi per "${r.prefix}"`:r.format==="ends_with"?`Nevalida karaktraro: devas finiĝi per "${r.suffix}"`:r.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${r.includes}"`:r.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${r.pattern}`:`Nevalida ${n[r.format]??o.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${o.divisor}`;case"unrecognized_keys":return`Nekonata${o.keys.length>1?"j":""} ŝlosilo${o.keys.length>1?"j":""}: ${j(o.keys,", ")}`;case"invalid_key":return`Nevalida ŝlosilo en ${o.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${o.origin}`;default:return"Nevalida enigo"}}};function jk(){return{localeError:Ck()}}const Ak=()=>{const e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}},t={string:"texto",number:"número",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"número grande",symbol:"símbolo",undefined:"indefinido",null:"nulo",function:"función",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeración",union:"unión",literal:"literal",promise:"promesa",void:"vacío",never:"nunca",unknown:"desconocido",any:"cualquiera"};function n(a){return e[a]??null}function o(a){return t[a]??a}const r=a=>{const s=typeof a;switch(s){case"number":return Number.isNaN(a)?"NaN":"number";case"object":return Array.isArray(a)?"array":a===null?"null":Object.getPrototypeOf(a)!==Object.prototype?a.constructor.name:"object"}return s},i={regex:"entrada",email:"dirección de correo electrónico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duración ISO",ipv4:"dirección IPv4",ipv6:"dirección IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"};return a=>{switch(a.code){case"invalid_type":return`Entrada inválida: se esperaba ${o(a.expected)}, recibido ${o(r(a.input))}`;case"invalid_value":return a.values.length===1?`Entrada inválida: se esperaba ${H(a.values[0])}`:`Opción inválida: se esperaba una de ${j(a.values,"|")}`;case"too_big":{const s=a.inclusive?"<=":"<",l=n(a.origin),u=o(a.origin);return l?`Demasiado grande: se esperaba que ${u??"valor"} tuviera ${s}${a.maximum.toString()} ${l.unit??"elementos"}`:`Demasiado grande: se esperaba que ${u??"valor"} fuera ${s}${a.maximum.toString()}`}case"too_small":{const s=a.inclusive?">=":">",l=n(a.origin),u=o(a.origin);return l?`Demasiado pequeño: se esperaba que ${u} tuviera ${s}${a.minimum.toString()} ${l.unit}`:`Demasiado pequeño: se esperaba que ${u} fuera ${s}${a.minimum.toString()}`}case"invalid_format":{const s=a;return s.format==="starts_with"?`Cadena inválida: debe comenzar con "${s.prefix}"`:s.format==="ends_with"?`Cadena inválida: debe terminar en "${s.suffix}"`:s.format==="includes"?`Cadena inválida: debe incluir "${s.includes}"`:s.format==="regex"?`Cadena inválida: debe coincidir con el patrón ${s.pattern}`:`Inválido ${i[s.format]??a.format}`}case"not_multiple_of":return`Número inválido: debe ser múltiplo de ${a.divisor}`;case"unrecognized_keys":return`Llave${a.keys.length>1?"s":""} desconocida${a.keys.length>1?"s":""}: ${j(a.keys,", ")}`;case"invalid_key":return`Llave inválida en ${o(a.origin)}`;case"invalid_union":return"Entrada inválida";case"invalid_element":return`Valor inválido en ${o(a.origin)}`;default:return"Entrada inválida"}}};function Rk(){return{localeError:Ak()}}const zk=()=>{const e={string:{unit:"کاراکتر",verb:"داشته باشد"},file:{unit:"بایت",verb:"داشته باشد"},array:{unit:"آیتم",verb:"داشته باشد"},set:{unit:"آیتم",verb:"داشته باشد"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"عدد";case"object":{if(Array.isArray(r))return"آرایه";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ورودی",email:"آدرس ایمیل",url:"URL",emoji:"ایموجی",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"تاریخ و زمان ایزو",date:"تاریخ ایزو",time:"زمان ایزو",duration:"مدت زمان ایزو",ipv4:"IPv4 آدرس",ipv6:"IPv6 آدرس",cidrv4:"IPv4 دامنه",cidrv6:"IPv6 دامنه",base64:"base64-encoded رشته",base64url:"base64url-encoded رشته",json_string:"JSON رشته",e164:"E.164 عدد",jwt:"JWT",template_literal:"ورودی"};return r=>{switch(r.code){case"invalid_type":return`ورودی نامعتبر: میبایست ${r.expected} میبود، ${n(r.input)} دریافت شد`;case"invalid_value":return r.values.length===1?`ورودی نامعتبر: میبایست ${H(r.values[0])} میبود`:`گزینه نامعتبر: میبایست یکی از ${j(r.values,"|")} میبود`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`خیلی بزرگ: ${r.origin??"مقدار"} باید ${i}${r.maximum.toString()} ${a.unit??"عنصر"} باشد`:`خیلی بزرگ: ${r.origin??"مقدار"} باید ${i}${r.maximum.toString()} باشد`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`خیلی کوچک: ${r.origin} باید ${i}${r.minimum.toString()} ${a.unit} باشد`:`خیلی کوچک: ${r.origin} باید ${i}${r.minimum.toString()} باشد`}case"invalid_format":{const i=r;return i.format==="starts_with"?`رشته نامعتبر: باید با "${i.prefix}" شروع شود`:i.format==="ends_with"?`رشته نامعتبر: باید با "${i.suffix}" تمام شود`:i.format==="includes"?`رشته نامعتبر: باید شامل "${i.includes}" باشد`:i.format==="regex"?`رشته نامعتبر: باید با الگوی ${i.pattern} مطابقت داشته باشد`:`${o[i.format]??r.format} نامعتبر`}case"not_multiple_of":return`عدد نامعتبر: باید مضرب ${r.divisor} باشد`;case"unrecognized_keys":return`کلید${r.keys.length>1?"های":""} ناشناس: ${j(r.keys,", ")}`;case"invalid_key":return`کلید ناشناس در ${r.origin}`;case"invalid_union":return"ورودی نامعتبر";case"invalid_element":return`مقدار نامعتبر در ${r.origin}`;default:return"ورودی نامعتبر"}}};function Mk(){return{localeError:zk()}}const Dk=()=>{const e={string:{unit:"merkkiä",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"päivämäärän"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"säännöllinen lauseke",email:"sähköpostiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-päivämäärä",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"};return r=>{switch(r.code){case"invalid_type":return`Virheellinen tyyppi: odotettiin ${r.expected}, oli ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Virheellinen syöte: täytyy olla ${H(r.values[0])}`:`Virheellinen valinta: täytyy olla yksi seuraavista: ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Liian suuri: ${a.subject} täytyy olla ${i}${r.maximum.toString()} ${a.unit}`.trim():`Liian suuri: arvon täytyy olla ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Liian pieni: ${a.subject} täytyy olla ${i}${r.minimum.toString()} ${a.unit}`.trim():`Liian pieni: arvon täytyy olla ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Virheellinen syöte: täytyy alkaa "${i.prefix}"`:i.format==="ends_with"?`Virheellinen syöte: täytyy loppua "${i.suffix}"`:i.format==="includes"?`Virheellinen syöte: täytyy sisältää "${i.includes}"`:i.format==="regex"?`Virheellinen syöte: täytyy vastata säännöllistä lauseketta ${i.pattern}`:`Virheellinen ${o[i.format]??r.format}`}case"not_multiple_of":return`Virheellinen luku: täytyy olla luvun ${r.divisor} monikerta`;case"unrecognized_keys":return`${r.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${j(r.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen syöte"}}};function Uk(){return{localeError:Dk()}}const Lk=()=>{const e={string:{unit:"caractères",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"éléments",verb:"avoir"},set:{unit:"éléments",verb:"avoir"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"nombre";case"object":{if(Array.isArray(r))return"tableau";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"entrée",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"durée ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"chaîne encodée en base64",base64url:"chaîne encodée en base64url",json_string:"chaîne JSON",e164:"numéro E.164",jwt:"JWT",template_literal:"entrée"};return r=>{switch(r.code){case"invalid_type":return`Entrée invalide : ${r.expected} attendu, ${n(r.input)} reçu`;case"invalid_value":return r.values.length===1?`Entrée invalide : ${H(r.values[0])} attendu`:`Option invalide : une valeur parmi ${j(r.values,"|")} attendue`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Trop grand : ${r.origin??"valeur"} doit ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"élément(s)"}`:`Trop grand : ${r.origin??"valeur"} doit être ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Trop petit : ${r.origin} doit ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Trop petit : ${r.origin} doit être ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Chaîne invalide : doit commencer par "${i.prefix}"`:i.format==="ends_with"?`Chaîne invalide : doit se terminer par "${i.suffix}"`:i.format==="includes"?`Chaîne invalide : doit inclure "${i.includes}"`:i.format==="regex"?`Chaîne invalide : doit correspondre au modèle ${i.pattern}`:`${o[i.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit être un multiple de ${r.divisor}`;case"unrecognized_keys":return`Clé${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${j(r.keys,", ")}`;case"invalid_key":return`Clé invalide dans ${r.origin}`;case"invalid_union":return"Entrée invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entrée invalide"}}};function Zk(){return{localeError:Lk()}}const Fk=()=>{const e={string:{unit:"caractères",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"éléments",verb:"avoir"},set:{unit:"éléments",verb:"avoir"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"entrée",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"durée ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"chaîne encodée en base64",base64url:"chaîne encodée en base64url",json_string:"chaîne JSON",e164:"numéro E.164",jwt:"JWT",template_literal:"entrée"};return r=>{switch(r.code){case"invalid_type":return`Entrée invalide : attendu ${r.expected}, reçu ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Entrée invalide : attendu ${H(r.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"≤":"<",a=t(r.origin);return a?`Trop grand : attendu que ${r.origin??"la valeur"} ait ${i}${r.maximum.toString()} ${a.unit}`:`Trop grand : attendu que ${r.origin??"la valeur"} soit ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?"≥":">",a=t(r.origin);return a?`Trop petit : attendu que ${r.origin} ait ${i}${r.minimum.toString()} ${a.unit}`:`Trop petit : attendu que ${r.origin} soit ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Chaîne invalide : doit commencer par "${i.prefix}"`:i.format==="ends_with"?`Chaîne invalide : doit se terminer par "${i.suffix}"`:i.format==="includes"?`Chaîne invalide : doit inclure "${i.includes}"`:i.format==="regex"?`Chaîne invalide : doit correspondre au motif ${i.pattern}`:`${o[i.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit être un multiple de ${r.divisor}`;case"unrecognized_keys":return`Clé${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${j(r.keys,", ")}`;case"invalid_key":return`Clé invalide dans ${r.origin}`;case"invalid_union":return"Entrée invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entrée invalide"}}};function qk(){return{localeError:Fk()}}const Vk=()=>{const e={string:{label:"מחרוזת",gender:"f"},number:{label:"מספר",gender:"m"},boolean:{label:"ערך בוליאני",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"תאריך",gender:"m"},array:{label:"מערך",gender:"m"},object:{label:"אובייקט",gender:"m"},null:{label:"ערך ריק (null)",gender:"m"},undefined:{label:"ערך לא מוגדר (undefined)",gender:"m"},symbol:{label:"סימבול (Symbol)",gender:"m"},function:{label:"פונקציה",gender:"f"},map:{label:"מפה (Map)",gender:"f"},set:{label:"קבוצה (Set)",gender:"f"},file:{label:"קובץ",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"ערך לא ידוע",gender:"m"},value:{label:"ערך",gender:"m"}},t={string:{unit:"תווים",shortLabel:"קצר",longLabel:"ארוך"},file:{unit:"בייטים",shortLabel:"קטן",longLabel:"גדול"},array:{unit:"פריטים",shortLabel:"קטן",longLabel:"גדול"},set:{unit:"פריטים",shortLabel:"קטן",longLabel:"גדול"},number:{unit:"",shortLabel:"קטן",longLabel:"גדול"}},n=u=>u?e[u]:void 0,o=u=>{const c=n(u);return c?c.label:u??e.unknown.label},r=u=>`ה${o(u)}`,i=u=>(n(u)?.gender??"m")==="f"?"צריכה להיות":"צריך להיות",a=u=>u?t[u]??null:null,s=u=>{const c=typeof u;switch(c){case"number":return Number.isNaN(u)?"NaN":"number";case"object":return Array.isArray(u)?"array":u===null?"null":Object.getPrototypeOf(u)!==Object.prototype&&u.constructor?u.constructor.name:"object";default:return c}},l={regex:{label:"קלט",gender:"m"},email:{label:"כתובת אימייל",gender:"f"},url:{label:"כתובת רשת",gender:"f"},emoji:{label:"אימוג'י",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"תאריך וזמן ISO",gender:"m"},date:{label:"תאריך ISO",gender:"m"},time:{label:"זמן ISO",gender:"m"},duration:{label:"משך זמן ISO",gender:"m"},ipv4:{label:"כתובת IPv4",gender:"f"},ipv6:{label:"כתובת IPv6",gender:"f"},cidrv4:{label:"טווח IPv4",gender:"m"},cidrv6:{label:"טווח IPv6",gender:"m"},base64:{label:"מחרוזת בבסיס 64",gender:"f"},base64url:{label:"מחרוזת בבסיס 64 לכתובות רשת",gender:"f"},json_string:{label:"מחרוזת JSON",gender:"f"},e164:{label:"מספר E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"קלט",gender:"m"},includes:{label:"קלט",gender:"m"},lowercase:{label:"קלט",gender:"m"},starts_with:{label:"קלט",gender:"m"},uppercase:{label:"קלט",gender:"m"}};return u=>{switch(u.code){case"invalid_type":{const c=u.expected,d=o(c),p=s(u.input),f=e[p]?.label??p;return`קלט לא תקין: צריך להיות ${d}, התקבל ${f}`}case"invalid_value":{if(u.values.length===1)return`ערך לא תקין: הערך חייב להיות ${H(u.values[0])}`;const c=u.values.map(f=>H(f));if(u.values.length===2)return`ערך לא תקין: האפשרויות המתאימות הן ${c[0]} או ${c[1]}`;const d=c[c.length-1];return`ערך לא תקין: האפשרויות המתאימות הן ${c.slice(0,-1).join(", ")} או ${d}`}case"too_big":{const c=a(u.origin),d=r(u.origin??"value");if(u.origin==="string")return`${c?.longLabel??"ארוך"} מדי: ${d} צריכה להכיל ${u.maximum.toString()} ${c?.unit??""} ${u.inclusive?"או פחות":"לכל היותר"}`.trim();if(u.origin==="number"){const g=u.inclusive?`קטן או שווה ל-${u.maximum}`:`קטן מ-${u.maximum}`;return`גדול מדי: ${d} צריך להיות ${g}`}if(u.origin==="array"||u.origin==="set"){const g=u.origin==="set"?"צריכה":"צריך",m=u.inclusive?`${u.maximum} ${c?.unit??""} או פחות`:`פחות מ-${u.maximum} ${c?.unit??""}`;return`גדול מדי: ${d} ${g} להכיל ${m}`.trim()}const p=u.inclusive?"<=":"<",f=i(u.origin??"value");return c?.unit?`${c.longLabel} מדי: ${d} ${f} ${p}${u.maximum.toString()} ${c.unit}`:`${c?.longLabel??"גדול"} מדי: ${d} ${f} ${p}${u.maximum.toString()}`}case"too_small":{const c=a(u.origin),d=r(u.origin??"value");if(u.origin==="string")return`${c?.shortLabel??"קצר"} מדי: ${d} צריכה להכיל ${u.minimum.toString()} ${c?.unit??""} ${u.inclusive?"או יותר":"לפחות"}`.trim();if(u.origin==="number"){const g=u.inclusive?`גדול או שווה ל-${u.minimum}`:`גדול מ-${u.minimum}`;return`קטן מדי: ${d} צריך להיות ${g}`}if(u.origin==="array"||u.origin==="set"){const g=u.origin==="set"?"צריכה":"צריך";if(u.minimum===1&&u.inclusive){const b=(u.origin==="set","לפחות פריט אחד");return`קטן מדי: ${d} ${g} להכיל ${b}`}const m=u.inclusive?`${u.minimum} ${c?.unit??""} או יותר`:`יותר מ-${u.minimum} ${c?.unit??""}`;return`קטן מדי: ${d} ${g} להכיל ${m}`.trim()}const p=u.inclusive?">=":">",f=i(u.origin??"value");return c?.unit?`${c.shortLabel} מדי: ${d} ${f} ${p}${u.minimum.toString()} ${c.unit}`:`${c?.shortLabel??"קטן"} מדי: ${d} ${f} ${p}${u.minimum.toString()}`}case"invalid_format":{const c=u;if(c.format==="starts_with")return`המחרוזת חייבת להתחיל ב "${c.prefix}"`;if(c.format==="ends_with")return`המחרוזת חייבת להסתיים ב "${c.suffix}"`;if(c.format==="includes")return`המחרוזת חייבת לכלול "${c.includes}"`;if(c.format==="regex")return`המחרוזת חייבת להתאים לתבנית ${c.pattern}`;const d=l[c.format],p=d?.label??c.format,g=(d?.gender??"m")==="f"?"תקינה":"תקין";return`${p} לא ${g}`}case"not_multiple_of":return`מספר לא תקין: חייב להיות מכפלה של ${u.divisor}`;case"unrecognized_keys":return`מפתח${u.keys.length>1?"ות":""} לא מזוה${u.keys.length>1?"ים":"ה"}: ${j(u.keys,", ")}`;case"invalid_key":return"שדה לא תקין באובייקט";case"invalid_union":return"קלט לא תקין";case"invalid_element":return`ערך לא תקין ב${r(u.origin??"array")}`;default:return"קלט לא תקין"}}};function Bk(){return{localeError:Vk()}}const Jk=()=>{const e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"szám";case"object":{if(Array.isArray(r))return"tömb";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"bemenet",email:"email cím",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO időbélyeg",date:"ISO dátum",time:"ISO idő",duration:"ISO időintervallum",ipv4:"IPv4 cím",ipv6:"IPv6 cím",cidrv4:"IPv4 tartomány",cidrv6:"IPv6 tartomány",base64:"base64-kódolt string",base64url:"base64url-kódolt string",json_string:"JSON string",e164:"E.164 szám",jwt:"JWT",template_literal:"bemenet"};return r=>{switch(r.code){case"invalid_type":return`Érvénytelen bemenet: a várt érték ${r.expected}, a kapott érték ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Érvénytelen bemenet: a várt érték ${H(r.values[0])}`:`Érvénytelen opció: valamelyik érték várt ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Túl nagy: ${r.origin??"érték"} mérete túl nagy ${i}${r.maximum.toString()} ${a.unit??"elem"}`:`Túl nagy: a bemeneti érték ${r.origin??"érték"} túl nagy: ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Túl kicsi: a bemeneti érték ${r.origin} mérete túl kicsi ${i}${r.minimum.toString()} ${a.unit}`:`Túl kicsi: a bemeneti érték ${r.origin} túl kicsi ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Érvénytelen string: "${i.prefix}" értékkel kell kezdődnie`:i.format==="ends_with"?`Érvénytelen string: "${i.suffix}" értékkel kell végződnie`:i.format==="includes"?`Érvénytelen string: "${i.includes}" értéket kell tartalmaznia`:i.format==="regex"?`Érvénytelen string: ${i.pattern} mintának kell megfelelnie`:`Érvénytelen ${o[i.format]??r.format}`}case"not_multiple_of":return`Érvénytelen szám: ${r.divisor} többszörösének kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Érvénytelen kulcs ${r.origin}`;case"invalid_union":return"Érvénytelen bemenet";case"invalid_element":return`Érvénytelen érték: ${r.origin}`;default:return"Érvénytelen bemenet"}}};function Wk(){return{localeError:Jk()}}const Hk=()=>{const e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Input tidak valid: diharapkan ${r.expected}, diterima ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Input tidak valid: diharapkan ${H(r.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Terlalu besar: diharapkan ${r.origin??"value"} memiliki ${i}${r.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: diharapkan ${r.origin??"value"} menjadi ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Terlalu kecil: diharapkan ${r.origin} memiliki ${i}${r.minimum.toString()} ${a.unit}`:`Terlalu kecil: diharapkan ${r.origin} menjadi ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`String tidak valid: harus dimulai dengan "${i.prefix}"`:i.format==="ends_with"?`String tidak valid: harus berakhir dengan "${i.suffix}"`:i.format==="includes"?`String tidak valid: harus menyertakan "${i.includes}"`:i.format==="regex"?`String tidak valid: harus sesuai pola ${i.pattern}`:`${o[i.format]??r.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${r.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${r.origin}`;default:return"Input tidak valid"}}};function Gk(){return{localeError:Hk()}}const Kk=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"númer";case"object":{if(Array.isArray(e))return"fylki";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},Yk=()=>{const e={string:{unit:"stafi",verb:"að hafa"},file:{unit:"bæti",verb:"að hafa"},array:{unit:"hluti",verb:"að hafa"},set:{unit:"hluti",verb:"að hafa"}};function t(o){return e[o]??null}const n={regex:"gildi",email:"netfang",url:"vefslóð",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og tími",date:"ISO dagsetning",time:"ISO tími",duration:"ISO tímalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 tölugildi",jwt:"JWT",template_literal:"gildi"};return o=>{switch(o.code){case"invalid_type":return`Rangt gildi: Þú slóst inn ${Kk(o.input)} þar sem á að vera ${o.expected}`;case"invalid_value":return o.values.length===1?`Rangt gildi: gert ráð fyrir ${H(o.values[0])}`:`Ógilt val: má vera eitt af eftirfarandi ${j(o.values,"|")}`;case"too_big":{const r=o.inclusive?"<=":"<",i=t(o.origin);return i?`Of stórt: gert er ráð fyrir að ${o.origin??"gildi"} hafi ${r}${o.maximum.toString()} ${i.unit??"hluti"}`:`Of stórt: gert er ráð fyrir að ${o.origin??"gildi"} sé ${r}${o.maximum.toString()}`}case"too_small":{const r=o.inclusive?">=":">",i=t(o.origin);return i?`Of lítið: gert er ráð fyrir að ${o.origin} hafi ${r}${o.minimum.toString()} ${i.unit}`:`Of lítið: gert er ráð fyrir að ${o.origin} sé ${r}${o.minimum.toString()}`}case"invalid_format":{const r=o;return r.format==="starts_with"?`Ógildur strengur: verður að byrja á "${r.prefix}"`:r.format==="ends_with"?`Ógildur strengur: verður að enda á "${r.suffix}"`:r.format==="includes"?`Ógildur strengur: verður að innihalda "${r.includes}"`:r.format==="regex"?`Ógildur strengur: verður að fylgja mynstri ${r.pattern}`:`Rangt ${n[r.format]??o.format}`}case"not_multiple_of":return`Röng tala: verður að vera margfeldi af ${o.divisor}`;case"unrecognized_keys":return`Óþekkt ${o.keys.length>1?"ir lyklar":"ur lykill"}: ${j(o.keys,", ")}`;case"invalid_key":return`Rangur lykill í ${o.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi í ${o.origin}`;default:return"Rangt gildi"}}};function Qk(){return{localeError:Yk()}}const Xk=()=>{const e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"numero";case"object":{if(Array.isArray(r))return"vettore";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Input non valido: atteso ${r.expected}, ricevuto ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Input non valido: atteso ${H(r.values[0])}`:`Opzione non valida: atteso uno tra ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Troppo grande: ${r.origin??"valore"} deve avere ${i}${r.maximum.toString()} ${a.unit??"elementi"}`:`Troppo grande: ${r.origin??"valore"} deve essere ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Troppo piccolo: ${r.origin} deve avere ${i}${r.minimum.toString()} ${a.unit}`:`Troppo piccolo: ${r.origin} deve essere ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Stringa non valida: deve iniziare con "${i.prefix}"`:i.format==="ends_with"?`Stringa non valida: deve terminare con "${i.suffix}"`:i.format==="includes"?`Stringa non valida: deve includere "${i.includes}"`:i.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${i.pattern}`:`Invalid ${o[i.format]??r.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${r.divisor}`;case"unrecognized_keys":return`Chiav${r.keys.length>1?"i":"e"} non riconosciut${r.keys.length>1?"e":"a"}: ${j(r.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${r.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${r.origin}`;default:return"Input non valido"}}};function eE(){return{localeError:Xk()}}const tE=()=>{const e={string:{unit:"文字",verb:"である"},file:{unit:"バイト",verb:"である"},array:{unit:"要素",verb:"である"},set:{unit:"要素",verb:"である"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"数値";case"object":{if(Array.isArray(r))return"配列";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"入力値",email:"メールアドレス",url:"URL",emoji:"絵文字",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO日時",date:"ISO日付",time:"ISO時刻",duration:"ISO期間",ipv4:"IPv4アドレス",ipv6:"IPv6アドレス",cidrv4:"IPv4範囲",cidrv6:"IPv6範囲",base64:"base64エンコード文字列",base64url:"base64urlエンコード文字列",json_string:"JSON文字列",e164:"E.164番号",jwt:"JWT",template_literal:"入力値"};return r=>{switch(r.code){case"invalid_type":return`無効な入力: ${r.expected}が期待されましたが、${n(r.input)}が入力されました`;case"invalid_value":return r.values.length===1?`無効な入力: ${H(r.values[0])}が期待されました`:`無効な選択: ${j(r.values,"、")}のいずれかである必要があります`;case"too_big":{const i=r.inclusive?"以下である":"より小さい",a=t(r.origin);return a?`大きすぎる値: ${r.origin??"値"}は${r.maximum.toString()}${a.unit??"要素"}${i}必要があります`:`大きすぎる値: ${r.origin??"値"}は${r.maximum.toString()}${i}必要があります`}case"too_small":{const i=r.inclusive?"以上である":"より大きい",a=t(r.origin);return a?`小さすぎる値: ${r.origin}は${r.minimum.toString()}${a.unit}${i}必要があります`:`小さすぎる値: ${r.origin}は${r.minimum.toString()}${i}必要があります`}case"invalid_format":{const i=r;return i.format==="starts_with"?`無効な文字列: "${i.prefix}"で始まる必要があります`:i.format==="ends_with"?`無効な文字列: "${i.suffix}"で終わる必要があります`:i.format==="includes"?`無効な文字列: "${i.includes}"を含む必要があります`:i.format==="regex"?`無効な文字列: パターン${i.pattern}に一致する必要があります`:`無効な${o[i.format]??r.format}`}case"not_multiple_of":return`無効な数値: ${r.divisor}の倍数である必要があります`;case"unrecognized_keys":return`認識されていないキー${r.keys.length>1?"群":""}: ${j(r.keys,"、")}`;case"invalid_key":return`${r.origin}内の無効なキー`;case"invalid_union":return"無効な入力";case"invalid_element":return`${r.origin}内の無効な値`;default:return"無効な入力"}}};function rE(){return{localeError:tE()}}const nE=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"რიცხვი";case"object":{if(Array.isArray(e))return"მასივი";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return{string:"სტრინგი",boolean:"ბულეანი",undefined:"undefined",bigint:"bigint",symbol:"symbol",function:"ფუნქცია"}[t]??t},oE=()=>{const e={string:{unit:"სიმბოლო",verb:"უნდა შეიცავდეს"},file:{unit:"ბაიტი",verb:"უნდა შეიცავდეს"},array:{unit:"ელემენტი",verb:"უნდა შეიცავდეს"},set:{unit:"ელემენტი",verb:"უნდა შეიცავდეს"}};function t(o){return e[o]??null}const n={regex:"შეყვანა",email:"ელ-ფოსტის მისამართი",url:"URL",emoji:"ემოჯი",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"თარიღი-დრო",date:"თარიღი",time:"დრო",duration:"ხანგრძლივობა",ipv4:"IPv4 მისამართი",ipv6:"IPv6 მისამართი",cidrv4:"IPv4 დიაპაზონი",cidrv6:"IPv6 დიაპაზონი",base64:"base64-კოდირებული სტრინგი",base64url:"base64url-კოდირებული სტრინგი",json_string:"JSON სტრინგი",e164:"E.164 ნომერი",jwt:"JWT",template_literal:"შეყვანა"};return o=>{switch(o.code){case"invalid_type":return`არასწორი შეყვანა: მოსალოდნელი ${o.expected}, მიღებული ${nE(o.input)}`;case"invalid_value":return o.values.length===1?`არასწორი შეყვანა: მოსალოდნელი ${H(o.values[0])}`:`არასწორი ვარიანტი: მოსალოდნელია ერთ-ერთი ${j(o.values,"|")}-დან`;case"too_big":{const r=o.inclusive?"<=":"<",i=t(o.origin);return i?`ზედმეტად დიდი: მოსალოდნელი ${o.origin??"მნიშვნელობა"} ${i.verb} ${r}${o.maximum.toString()} ${i.unit}`:`ზედმეტად დიდი: მოსალოდნელი ${o.origin??"მნიშვნელობა"} იყოს ${r}${o.maximum.toString()}`}case"too_small":{const r=o.inclusive?">=":">",i=t(o.origin);return i?`ზედმეტად პატარა: მოსალოდნელი ${o.origin} ${i.verb} ${r}${o.minimum.toString()} ${i.unit}`:`ზედმეტად პატარა: მოსალოდნელი ${o.origin} იყოს ${r}${o.minimum.toString()}`}case"invalid_format":{const r=o;return r.format==="starts_with"?`არასწორი სტრინგი: უნდა იწყებოდეს "${r.prefix}"-ით`:r.format==="ends_with"?`არასწორი სტრინგი: უნდა მთავრდებოდეს "${r.suffix}"-ით`:r.format==="includes"?`არასწორი სტრინგი: უნდა შეიცავდეს "${r.includes}"-ს`:r.format==="regex"?`არასწორი სტრინგი: უნდა შეესაბამებოდეს შაბლონს ${r.pattern}`:`არასწორი ${n[r.format]??o.format}`}case"not_multiple_of":return`არასწორი რიცხვი: უნდა იყოს ${o.divisor}-ის ჯერადი`;case"unrecognized_keys":return`უცნობი გასაღებ${o.keys.length>1?"ები":"ი"}: ${j(o.keys,", ")}`;case"invalid_key":return`არასწორი გასაღები ${o.origin}-ში`;case"invalid_union":return"არასწორი შეყვანა";case"invalid_element":return`არასწორი მნიშვნელობა ${o.origin}-ში`;default:return"არასწორი შეყვანა"}}};function iE(){return{localeError:oE()}}const aE=()=>{const e={string:{unit:"តួអក្សរ",verb:"គួរមាន"},file:{unit:"បៃ",verb:"គួរមាន"},array:{unit:"ធាតុ",verb:"គួរមាន"},set:{unit:"ធាតុ",verb:"គួរមាន"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"មិនមែនជាលេខ (NaN)":"លេខ";case"object":{if(Array.isArray(r))return"អារេ (Array)";if(r===null)return"គ្មានតម្លៃ (null)";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ទិន្នន័យបញ្ចូល",email:"អាសយដ្ឋានអ៊ីមែល",url:"URL",emoji:"សញ្ញាអារម្មណ៍",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"កាលបរិច្ឆេទ និងម៉ោង ISO",date:"កាលបរិច្ឆេទ ISO",time:"ម៉ោង ISO",duration:"រយៈពេល ISO",ipv4:"អាសយដ្ឋាន IPv4",ipv6:"អាសយដ្ឋាន IPv6",cidrv4:"ដែនអាសយដ្ឋាន IPv4",cidrv6:"ដែនអាសយដ្ឋាន IPv6",base64:"ខ្សែអក្សរអ៊ិកូដ base64",base64url:"ខ្សែអក្សរអ៊ិកូដ base64url",json_string:"ខ្សែអក្សរ JSON",e164:"លេខ E.164",jwt:"JWT",template_literal:"ទិន្នន័យបញ្ចូល"};return r=>{switch(r.code){case"invalid_type":return`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${r.expected} ប៉ុន្តែទទួលបាន ${n(r.input)}`;case"invalid_value":return r.values.length===1?`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${H(r.values[0])}`:`ជម្រើសមិនត្រឹមត្រូវ៖ ត្រូវជាមួយក្នុងចំណោម ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`ធំពេក៖ ត្រូវការ ${r.origin??"តម្លៃ"} ${i} ${r.maximum.toString()} ${a.unit??"ធាតុ"}`:`ធំពេក៖ ត្រូវការ ${r.origin??"តម្លៃ"} ${i} ${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`តូចពេក៖ ត្រូវការ ${r.origin} ${i} ${r.minimum.toString()} ${a.unit}`:`តូចពេក៖ ត្រូវការ ${r.origin} ${i} ${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវចាប់ផ្តើមដោយ "${i.prefix}"`:i.format==="ends_with"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវបញ្ចប់ដោយ "${i.suffix}"`:i.format==="includes"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវមាន "${i.includes}"`:i.format==="regex"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវតែផ្គូផ្គងនឹងទម្រង់ដែលបានកំណត់ ${i.pattern}`:`មិនត្រឹមត្រូវ៖ ${o[i.format]??r.format}`}case"not_multiple_of":return`លេខមិនត្រឹមត្រូវ៖ ត្រូវតែជាពហុគុណនៃ ${r.divisor}`;case"unrecognized_keys":return`រកឃើញសោមិនស្គាល់៖ ${j(r.keys,", ")}`;case"invalid_key":return`សោមិនត្រឹមត្រូវនៅក្នុង ${r.origin}`;case"invalid_union":return"ទិន្នន័យមិនត្រឹមត្រូវ";case"invalid_element":return`ទិន្នន័យមិនត្រឹមត្រូវនៅក្នុង ${r.origin}`;default:return"ទិន្នន័យមិនត្រឹមត្រូវ"}}};function yv(){return{localeError:aE()}}function sE(){return yv()}const uE=()=>{const e={string:{unit:"문자",verb:"to have"},file:{unit:"바이트",verb:"to have"},array:{unit:"개",verb:"to have"},set:{unit:"개",verb:"to have"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"입력",email:"이메일 주소",url:"URL",emoji:"이모지",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO 날짜시간",date:"ISO 날짜",time:"ISO 시간",duration:"ISO 기간",ipv4:"IPv4 주소",ipv6:"IPv6 주소",cidrv4:"IPv4 범위",cidrv6:"IPv6 범위",base64:"base64 인코딩 문자열",base64url:"base64url 인코딩 문자열",json_string:"JSON 문자열",e164:"E.164 번호",jwt:"JWT",template_literal:"입력"};return r=>{switch(r.code){case"invalid_type":return`잘못된 입력: 예상 타입은 ${r.expected}, 받은 타입은 ${n(r.input)}입니다`;case"invalid_value":return r.values.length===1?`잘못된 입력: 값은 ${H(r.values[0])} 이어야 합니다`:`잘못된 옵션: ${j(r.values,"또는 ")} 중 하나여야 합니다`;case"too_big":{const i=r.inclusive?"이하":"미만",a=i==="미만"?"이어야 합니다":"여야 합니다",s=t(r.origin),l=s?.unit??"요소";return s?`${r.origin??"값"}이 너무 큽니다: ${r.maximum.toString()}${l} ${i}${a}`:`${r.origin??"값"}이 너무 큽니다: ${r.maximum.toString()} ${i}${a}`}case"too_small":{const i=r.inclusive?"이상":"초과",a=i==="이상"?"이어야 합니다":"여야 합니다",s=t(r.origin),l=s?.unit??"요소";return s?`${r.origin??"값"}이 너무 작습니다: ${r.minimum.toString()}${l} ${i}${a}`:`${r.origin??"값"}이 너무 작습니다: ${r.minimum.toString()} ${i}${a}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`잘못된 문자열: "${i.prefix}"(으)로 시작해야 합니다`:i.format==="ends_with"?`잘못된 문자열: "${i.suffix}"(으)로 끝나야 합니다`:i.format==="includes"?`잘못된 문자열: "${i.includes}"을(를) 포함해야 합니다`:i.format==="regex"?`잘못된 문자열: 정규식 ${i.pattern} 패턴과 일치해야 합니다`:`잘못된 ${o[i.format]??r.format}`}case"not_multiple_of":return`잘못된 숫자: ${r.divisor}의 배수여야 합니다`;case"unrecognized_keys":return`인식할 수 없는 키: ${j(r.keys,", ")}`;case"invalid_key":return`잘못된 키: ${r.origin}`;case"invalid_union":return"잘못된 입력";case"invalid_element":return`잘못된 값: ${r.origin}`;default:return"잘못된 입력"}}};function lE(){return{localeError:uE()}}const cE=e=>$n(typeof e,e),$n=(e,t=void 0)=>{switch(e){case"number":return Number.isNaN(t)?"NaN":"skaičius";case"bigint":return"sveikasis skaičius";case"string":return"eilutė";case"boolean":return"loginė reikšmė";case"undefined":case"void":return"neapibrėžta reikšmė";case"function":return"funkcija";case"symbol":return"simbolis";case"object":return t===void 0?"nežinomas objektas":t===null?"nulinė reikšmė":Array.isArray(t)?"masyvas":Object.getPrototypeOf(t)!==Object.prototype&&t.constructor?t.constructor.name:"objektas";case"null":return"nulinė reikšmė"}return e},yn=e=>e.charAt(0).toUpperCase()+e.slice(1);function Wd(e){const t=Math.abs(e),n=t%10,o=t%100;return o>=11&&o<=19||n===0?"many":n===1?"one":"few"}const dE=()=>{const e={string:{unit:{one:"simbolis",few:"simboliai",many:"simbolių"},verb:{smaller:{inclusive:"turi būti ne ilgesnė kaip",notInclusive:"turi būti trumpesnė kaip"},bigger:{inclusive:"turi būti ne trumpesnė kaip",notInclusive:"turi būti ilgesnė kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"baitų"},verb:{smaller:{inclusive:"turi būti ne didesnis kaip",notInclusive:"turi būti mažesnis kaip"},bigger:{inclusive:"turi būti ne mažesnis kaip",notInclusive:"turi būti didesnis kaip"}}},array:{unit:{one:"elementą",few:"elementus",many:"elementų"},verb:{smaller:{inclusive:"turi turėti ne daugiau kaip",notInclusive:"turi turėti mažiau kaip"},bigger:{inclusive:"turi turėti ne mažiau kaip",notInclusive:"turi turėti daugiau kaip"}}},set:{unit:{one:"elementą",few:"elementus",many:"elementų"},verb:{smaller:{inclusive:"turi turėti ne daugiau kaip",notInclusive:"turi turėti mažiau kaip"},bigger:{inclusive:"turi turėti ne mažiau kaip",notInclusive:"turi turėti daugiau kaip"}}}};function t(o,r,i,a){const s=e[o]??null;return s===null?s:{unit:s.unit[r],verb:s.verb[a][i?"inclusive":"notInclusive"]}}const n={regex:"įvestis",email:"el. pašto adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukmė",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 užkoduota eilutė",base64url:"base64url užkoduota eilutė",json_string:"JSON eilutė",e164:"E.164 numeris",jwt:"JWT",template_literal:"įvestis"};return o=>{switch(o.code){case"invalid_type":return`Gautas tipas ${cE(o.input)}, o tikėtasi - ${$n(o.expected)}`;case"invalid_value":return o.values.length===1?`Privalo būti ${H(o.values[0])}`:`Privalo būti vienas iš ${j(o.values,"|")} pasirinkimų`;case"too_big":{const r=$n(o.origin),i=t(o.origin,Wd(Number(o.maximum)),o.inclusive??!1,"smaller");if(i?.verb)return`${yn(r??o.origin??"reikšmė")} ${i.verb} ${o.maximum.toString()} ${i.unit??"elementų"}`;const a=o.inclusive?"ne didesnis kaip":"mažesnis kaip";return`${yn(r??o.origin??"reikšmė")} turi būti ${a} ${o.maximum.toString()} ${i?.unit}`}case"too_small":{const r=$n(o.origin),i=t(o.origin,Wd(Number(o.minimum)),o.inclusive??!1,"bigger");if(i?.verb)return`${yn(r??o.origin??"reikšmė")} ${i.verb} ${o.minimum.toString()} ${i.unit??"elementų"}`;const a=o.inclusive?"ne mažesnis kaip":"didesnis kaip";return`${yn(r??o.origin??"reikšmė")} turi būti ${a} ${o.minimum.toString()} ${i?.unit}`}case"invalid_format":{const r=o;return r.format==="starts_with"?`Eilutė privalo prasidėti "${r.prefix}"`:r.format==="ends_with"?`Eilutė privalo pasibaigti "${r.suffix}"`:r.format==="includes"?`Eilutė privalo įtraukti "${r.includes}"`:r.format==="regex"?`Eilutė privalo atitikti ${r.pattern}`:`Neteisingas ${n[r.format]??o.format}`}case"not_multiple_of":return`Skaičius privalo būti ${o.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpažint${o.keys.length>1?"i":"as"} rakt${o.keys.length>1?"ai":"as"}: ${j(o.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga įvestis";case"invalid_element":{const r=$n(o.origin);return`${yn(r??o.origin??"reikšmė")} turi klaidingą įvestį`}default:return"Klaidinga įvestis"}}};function fE(){return{localeError:dE()}}const pE=()=>{const e={string:{unit:"знаци",verb:"да имаат"},file:{unit:"бајти",verb:"да имаат"},array:{unit:"ставки",verb:"да имаат"},set:{unit:"ставки",verb:"да имаат"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"број";case"object":{if(Array.isArray(r))return"низа";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"внес",email:"адреса на е-пошта",url:"URL",emoji:"емоџи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO датум и време",date:"ISO датум",time:"ISO време",duration:"ISO времетраење",ipv4:"IPv4 адреса",ipv6:"IPv6 адреса",cidrv4:"IPv4 опсег",cidrv6:"IPv6 опсег",base64:"base64-енкодирана низа",base64url:"base64url-енкодирана низа",json_string:"JSON низа",e164:"E.164 број",jwt:"JWT",template_literal:"внес"};return r=>{switch(r.code){case"invalid_type":return`Грешен внес: се очекува ${r.expected}, примено ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Invalid input: expected ${H(r.values[0])}`:`Грешана опција: се очекува една ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Премногу голем: се очекува ${r.origin??"вредноста"} да има ${i}${r.maximum.toString()} ${a.unit??"елементи"}`:`Премногу голем: се очекува ${r.origin??"вредноста"} да биде ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Премногу мал: се очекува ${r.origin} да има ${i}${r.minimum.toString()} ${a.unit}`:`Премногу мал: се очекува ${r.origin} да биде ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Неважечка низа: мора да започнува со "${i.prefix}"`:i.format==="ends_with"?`Неважечка низа: мора да завршува со "${i.suffix}"`:i.format==="includes"?`Неважечка низа: мора да вклучува "${i.includes}"`:i.format==="regex"?`Неважечка низа: мора да одгоара на патернот ${i.pattern}`:`Invalid ${o[i.format]??r.format}`}case"not_multiple_of":return`Грешен број: мора да биде делив со ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Непрепознаени клучеви":"Непрепознаен клуч"}: ${j(r.keys,", ")}`;case"invalid_key":return`Грешен клуч во ${r.origin}`;case"invalid_union":return"Грешен внес";case"invalid_element":return`Грешна вредност во ${r.origin}`;default:return"Грешен внес"}}};function mE(){return{localeError:pE()}}const hE=()=>{const e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"nombor";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Input tidak sah: dijangka ${r.expected}, diterima ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Input tidak sah: dijangka ${H(r.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Terlalu besar: dijangka ${r.origin??"nilai"} ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: dijangka ${r.origin??"nilai"} adalah ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Terlalu kecil: dijangka ${r.origin} ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Terlalu kecil: dijangka ${r.origin} adalah ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`String tidak sah: mesti bermula dengan "${i.prefix}"`:i.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${i.suffix}"`:i.format==="includes"?`String tidak sah: mesti mengandungi "${i.includes}"`:i.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${i.pattern}`:`${o[i.format]??r.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${j(r.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${r.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${r.origin}`;default:return"Input tidak sah"}}};function gE(){return{localeError:hE()}}const vE=()=>{const e={string:{unit:"tekens",verb:"te hebben"},file:{unit:"bytes",verb:"te hebben"},array:{unit:"elementen",verb:"te hebben"},set:{unit:"elementen",verb:"te hebben"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"getal";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"};return r=>{switch(r.code){case"invalid_type":return`Ongeldige invoer: verwacht ${r.expected}, ontving ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ongeldige invoer: verwacht ${H(r.values[0])}`:`Ongeldige optie: verwacht één van ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Te groot: verwacht dat ${r.origin??"waarde"} ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"elementen"}`:`Te groot: verwacht dat ${r.origin??"waarde"} ${i}${r.maximum.toString()} is`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Te klein: verwacht dat ${r.origin} ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Te klein: verwacht dat ${r.origin} ${i}${r.minimum.toString()} is`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Ongeldige tekst: moet met "${i.prefix}" beginnen`:i.format==="ends_with"?`Ongeldige tekst: moet op "${i.suffix}" eindigen`:i.format==="includes"?`Ongeldige tekst: moet "${i.includes}" bevatten`:i.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${i.pattern}`:`Ongeldig: ${o[i.format]??r.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${r.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${r.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${r.origin}`;default:return"Ongeldige invoer"}}};function yE(){return{localeError:vE()}}const bE=()=>{const e={string:{unit:"tegn",verb:"å ha"},file:{unit:"bytes",verb:"å ha"},array:{unit:"elementer",verb:"å inneholde"},set:{unit:"elementer",verb:"å inneholde"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"tall";case"object":{if(Array.isArray(r))return"liste";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-område",ipv6:"IPv6-område",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Ugyldig input: forventet ${r.expected}, fikk ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ugyldig verdi: forventet ${H(r.values[0])}`:`Ugyldig valg: forventet en av ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`For stor(t): forventet ${r.origin??"value"} til å ha ${i}${r.maximum.toString()} ${a.unit??"elementer"}`:`For stor(t): forventet ${r.origin??"value"} til å ha ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`For lite(n): forventet ${r.origin} til å ha ${i}${r.minimum.toString()} ${a.unit}`:`For lite(n): forventet ${r.origin} til å ha ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Ugyldig streng: må starte med "${i.prefix}"`:i.format==="ends_with"?`Ugyldig streng: må ende med "${i.suffix}"`:i.format==="includes"?`Ugyldig streng: må inneholde "${i.includes}"`:i.format==="regex"?`Ugyldig streng: må matche mønsteret ${i.pattern}`:`Ugyldig ${o[i.format]??r.format}`}case"not_multiple_of":return`Ugyldig tall: må være et multiplum av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukjente nøkler":"Ukjent nøkkel"}: ${j(r.keys,", ")}`;case"invalid_key":return`Ugyldig nøkkel i ${r.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${r.origin}`;default:return"Ugyldig input"}}};function _E(){return{localeError:bE()}}const wE=()=>{const e={string:{unit:"harf",verb:"olmalıdır"},file:{unit:"bayt",verb:"olmalıdır"},array:{unit:"unsur",verb:"olmalıdır"},set:{unit:"unsur",verb:"olmalıdır"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"numara";case"object":{if(Array.isArray(r))return"saf";if(r===null)return"gayb";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"giren",email:"epostagâh",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO hengâmı",date:"ISO tarihi",time:"ISO zamanı",duration:"ISO müddeti",ipv4:"IPv4 nişânı",ipv6:"IPv6 nişânı",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-şifreli metin",base64url:"base64url-şifreli metin",json_string:"JSON metin",e164:"E.164 sayısı",jwt:"JWT",template_literal:"giren"};return r=>{switch(r.code){case"invalid_type":return`Fâsit giren: umulan ${r.expected}, alınan ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Fâsit giren: umulan ${H(r.values[0])}`:`Fâsit tercih: mûteberler ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Fazla büyük: ${r.origin??"value"}, ${i}${r.maximum.toString()} ${a.unit??"elements"} sahip olmalıydı.`:`Fazla büyük: ${r.origin??"value"}, ${i}${r.maximum.toString()} olmalıydı.`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Fazla küçük: ${r.origin}, ${i}${r.minimum.toString()} ${a.unit} sahip olmalıydı.`:`Fazla küçük: ${r.origin}, ${i}${r.minimum.toString()} olmalıydı.`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Fâsit metin: "${i.prefix}" ile başlamalı.`:i.format==="ends_with"?`Fâsit metin: "${i.suffix}" ile bitmeli.`:i.format==="includes"?`Fâsit metin: "${i.includes}" ihtivâ etmeli.`:i.format==="regex"?`Fâsit metin: ${i.pattern} nakşına uymalı.`:`Fâsit ${o[i.format]??r.format}`}case"not_multiple_of":return`Fâsit sayı: ${r.divisor} katı olmalıydı.`;case"unrecognized_keys":return`Tanınmayan anahtar ${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`${r.origin} için tanınmayan anahtar var.`;case"invalid_union":return"Giren tanınamadı.";case"invalid_element":return`${r.origin} için tanınmayan kıymet var.`;default:return"Kıymet tanınamadı."}}};function xE(){return{localeError:wE()}}const $E=()=>{const e={string:{unit:"توکي",verb:"ولري"},file:{unit:"بایټس",verb:"ولري"},array:{unit:"توکي",verb:"ولري"},set:{unit:"توکي",verb:"ولري"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"عدد";case"object":{if(Array.isArray(r))return"ارې";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ورودي",email:"بریښنالیک",url:"یو آر ال",emoji:"ایموجي",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"نیټه او وخت",date:"نېټه",time:"وخت",duration:"موده",ipv4:"د IPv4 پته",ipv6:"د IPv6 پته",cidrv4:"د IPv4 ساحه",cidrv6:"د IPv6 ساحه",base64:"base64-encoded متن",base64url:"base64url-encoded متن",json_string:"JSON متن",e164:"د E.164 شمېره",jwt:"JWT",template_literal:"ورودي"};return r=>{switch(r.code){case"invalid_type":return`ناسم ورودي: باید ${r.expected} وای, مګر ${n(r.input)} ترلاسه شو`;case"invalid_value":return r.values.length===1?`ناسم ورودي: باید ${H(r.values[0])} وای`:`ناسم انتخاب: باید یو له ${j(r.values,"|")} څخه وای`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`ډیر لوی: ${r.origin??"ارزښت"} باید ${i}${r.maximum.toString()} ${a.unit??"عنصرونه"} ولري`:`ډیر لوی: ${r.origin??"ارزښت"} باید ${i}${r.maximum.toString()} وي`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`ډیر کوچنی: ${r.origin} باید ${i}${r.minimum.toString()} ${a.unit} ولري`:`ډیر کوچنی: ${r.origin} باید ${i}${r.minimum.toString()} وي`}case"invalid_format":{const i=r;return i.format==="starts_with"?`ناسم متن: باید د "${i.prefix}" سره پیل شي`:i.format==="ends_with"?`ناسم متن: باید د "${i.suffix}" سره پای ته ورسيږي`:i.format==="includes"?`ناسم متن: باید "${i.includes}" ولري`:i.format==="regex"?`ناسم متن: باید د ${i.pattern} سره مطابقت ولري`:`${o[i.format]??r.format} ناسم دی`}case"not_multiple_of":return`ناسم عدد: باید د ${r.divisor} مضرب وي`;case"unrecognized_keys":return`ناسم ${r.keys.length>1?"کلیډونه":"کلیډ"}: ${j(r.keys,", ")}`;case"invalid_key":return`ناسم کلیډ په ${r.origin} کې`;case"invalid_union":return"ناسمه ورودي";case"invalid_element":return`ناسم عنصر په ${r.origin} کې`;default:return"ناسمه ورودي"}}};function SE(){return{localeError:$E()}}const IE=()=>{const e={string:{unit:"znaków",verb:"mieć"},file:{unit:"bajtów",verb:"mieć"},array:{unit:"elementów",verb:"mieć"},set:{unit:"elementów",verb:"mieć"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"liczba";case"object":{if(Array.isArray(r))return"tablica";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"wyrażenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ciąg znaków zakodowany w formacie base64",base64url:"ciąg znaków zakodowany w formacie base64url",json_string:"ciąg znaków w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wejście"};return r=>{switch(r.code){case"invalid_type":return`Nieprawidłowe dane wejściowe: oczekiwano ${r.expected}, otrzymano ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Nieprawidłowe dane wejściowe: oczekiwano ${H(r.values[0])}`:`Nieprawidłowa opcja: oczekiwano jednej z wartości ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Za duża wartość: oczekiwano, że ${r.origin??"wartość"} będzie mieć ${i}${r.maximum.toString()} ${a.unit??"elementów"}`:`Zbyt duż(y/a/e): oczekiwano, że ${r.origin??"wartość"} będzie wynosić ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Za mała wartość: oczekiwano, że ${r.origin??"wartość"} będzie mieć ${i}${r.minimum.toString()} ${a.unit??"elementów"}`:`Zbyt mał(y/a/e): oczekiwano, że ${r.origin??"wartość"} będzie wynosić ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Nieprawidłowy ciąg znaków: musi zaczynać się od "${i.prefix}"`:i.format==="ends_with"?`Nieprawidłowy ciąg znaków: musi kończyć się na "${i.suffix}"`:i.format==="includes"?`Nieprawidłowy ciąg znaków: musi zawierać "${i.includes}"`:i.format==="regex"?`Nieprawidłowy ciąg znaków: musi odpowiadać wzorcowi ${i.pattern}`:`Nieprawidłow(y/a/e) ${o[i.format]??r.format}`}case"not_multiple_of":return`Nieprawidłowa liczba: musi być wielokrotnością ${r.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Nieprawidłowy klucz w ${r.origin}`;case"invalid_union":return"Nieprawidłowe dane wejściowe";case"invalid_element":return`Nieprawidłowa wartość w ${r.origin}`;default:return"Nieprawidłowe dane wejściowe"}}};function kE(){return{localeError:IE()}}const EE=()=>{const e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"número";case"object":{if(Array.isArray(r))return"array";if(r===null)return"nulo";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"padrão",email:"endereço de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"duração ISO",ipv4:"endereço IPv4",ipv6:"endereço IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"};return r=>{switch(r.code){case"invalid_type":return`Tipo inválido: esperado ${r.expected}, recebido ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Entrada inválida: esperado ${H(r.values[0])}`:`Opção inválida: esperada uma das ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Muito grande: esperado que ${r.origin??"valor"} tivesse ${i}${r.maximum.toString()} ${a.unit??"elementos"}`:`Muito grande: esperado que ${r.origin??"valor"} fosse ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Muito pequeno: esperado que ${r.origin} tivesse ${i}${r.minimum.toString()} ${a.unit}`:`Muito pequeno: esperado que ${r.origin} fosse ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Texto inválido: deve começar com "${i.prefix}"`:i.format==="ends_with"?`Texto inválido: deve terminar com "${i.suffix}"`:i.format==="includes"?`Texto inválido: deve incluir "${i.includes}"`:i.format==="regex"?`Texto inválido: deve corresponder ao padrão ${i.pattern}`:`${o[i.format]??r.format} inválido`}case"not_multiple_of":return`Número inválido: deve ser múltiplo de ${r.divisor}`;case"unrecognized_keys":return`Chave${r.keys.length>1?"s":""} desconhecida${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Chave inválida em ${r.origin}`;case"invalid_union":return"Entrada inválida";case"invalid_element":return`Valor inválido em ${r.origin}`;default:return"Campo inválido"}}};function OE(){return{localeError:EE()}}function Hd(e,t,n,o){const r=Math.abs(e),i=r%10,a=r%100;return a>=11&&a<=19?o:i===1?t:i>=2&&i<=4?n:o}const TE=()=>{const e={string:{unit:{one:"символ",few:"символа",many:"символов"},verb:"иметь"},file:{unit:{one:"байт",few:"байта",many:"байт"},verb:"иметь"},array:{unit:{one:"элемент",few:"элемента",many:"элементов"},verb:"иметь"},set:{unit:{one:"элемент",few:"элемента",many:"элементов"},verb:"иметь"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"число";case"object":{if(Array.isArray(r))return"массив";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ввод",email:"email адрес",url:"URL",emoji:"эмодзи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO дата и время",date:"ISO дата",time:"ISO время",duration:"ISO длительность",ipv4:"IPv4 адрес",ipv6:"IPv6 адрес",cidrv4:"IPv4 диапазон",cidrv6:"IPv6 диапазон",base64:"строка в формате base64",base64url:"строка в формате base64url",json_string:"JSON строка",e164:"номер E.164",jwt:"JWT",template_literal:"ввод"};return r=>{switch(r.code){case"invalid_type":return`Неверный ввод: ожидалось ${r.expected}, получено ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Неверный ввод: ожидалось ${H(r.values[0])}`:`Неверный вариант: ожидалось одно из ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);if(a){const s=Number(r.maximum),l=Hd(s,a.unit.one,a.unit.few,a.unit.many);return`Слишком большое значение: ожидалось, что ${r.origin??"значение"} будет иметь ${i}${r.maximum.toString()} ${l}`}return`Слишком большое значение: ожидалось, что ${r.origin??"значение"} будет ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);if(a){const s=Number(r.minimum),l=Hd(s,a.unit.one,a.unit.few,a.unit.many);return`Слишком маленькое значение: ожидалось, что ${r.origin} будет иметь ${i}${r.minimum.toString()} ${l}`}return`Слишком маленькое значение: ожидалось, что ${r.origin} будет ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Неверная строка: должна начинаться с "${i.prefix}"`:i.format==="ends_with"?`Неверная строка: должна заканчиваться на "${i.suffix}"`:i.format==="includes"?`Неверная строка: должна содержать "${i.includes}"`:i.format==="regex"?`Неверная строка: должна соответствовать шаблону ${i.pattern}`:`Неверный ${o[i.format]??r.format}`}case"not_multiple_of":return`Неверное число: должно быть кратным ${r.divisor}`;case"unrecognized_keys":return`Нераспознанн${r.keys.length>1?"ые":"ый"} ключ${r.keys.length>1?"и":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Неверный ключ в ${r.origin}`;case"invalid_union":return"Неверные входные данные";case"invalid_element":return`Неверное значение в ${r.origin}`;default:return"Неверные входные данные"}}};function NE(){return{localeError:TE()}}const PE=()=>{const e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"število";case"object":{if(Array.isArray(r))return"tabela";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"vnos",email:"e-poštni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in čas",date:"ISO datum",time:"ISO čas",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 številka",jwt:"JWT",template_literal:"vnos"};return r=>{switch(r.code){case"invalid_type":return`Neveljaven vnos: pričakovano ${r.expected}, prejeto ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Neveljaven vnos: pričakovano ${H(r.values[0])}`:`Neveljavna možnost: pričakovano eno izmed ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Preveliko: pričakovano, da bo ${r.origin??"vrednost"} imelo ${i}${r.maximum.toString()} ${a.unit??"elementov"}`:`Preveliko: pričakovano, da bo ${r.origin??"vrednost"} ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Premajhno: pričakovano, da bo ${r.origin} imelo ${i}${r.minimum.toString()} ${a.unit}`:`Premajhno: pričakovano, da bo ${r.origin} ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Neveljaven niz: mora se začeti z "${i.prefix}"`:i.format==="ends_with"?`Neveljaven niz: mora se končati z "${i.suffix}"`:i.format==="includes"?`Neveljaven niz: mora vsebovati "${i.includes}"`:i.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${i.pattern}`:`Neveljaven ${o[i.format]??r.format}`}case"not_multiple_of":return`Neveljavno število: mora biti večkratnik ${r.divisor}`;case"unrecognized_keys":return`Neprepoznan${r.keys.length>1?"i ključi":" ključ"}: ${j(r.keys,", ")}`;case"invalid_key":return`Neveljaven ključ v ${r.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${r.origin}`;default:return"Neveljaven vnos"}}};function CE(){return{localeError:PE()}}const jE=()=>{const e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att innehålla"},set:{unit:"objekt",verb:"att innehålla"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"antal";case"object":{if(Array.isArray(r))return"lista";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"reguljärt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad sträng",base64url:"base64url-kodad sträng",json_string:"JSON-sträng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"};return r=>{switch(r.code){case"invalid_type":return`Ogiltig inmatning: förväntat ${r.expected}, fick ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ogiltig inmatning: förväntat ${H(r.values[0])}`:`Ogiltigt val: förväntade en av ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`För stor(t): förväntade ${r.origin??"värdet"} att ha ${i}${r.maximum.toString()} ${a.unit??"element"}`:`För stor(t): förväntat ${r.origin??"värdet"} att ha ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`För lite(t): förväntade ${r.origin??"värdet"} att ha ${i}${r.minimum.toString()} ${a.unit}`:`För lite(t): förväntade ${r.origin??"värdet"} att ha ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Ogiltig sträng: måste börja med "${i.prefix}"`:i.format==="ends_with"?`Ogiltig sträng: måste sluta med "${i.suffix}"`:i.format==="includes"?`Ogiltig sträng: måste innehålla "${i.includes}"`:i.format==="regex"?`Ogiltig sträng: måste matcha mönstret "${i.pattern}"`:`Ogiltig(t) ${o[i.format]??r.format}`}case"not_multiple_of":return`Ogiltigt tal: måste vara en multipel av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Okända nycklar":"Okänd nyckel"}: ${j(r.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${r.origin??"värdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt värde i ${r.origin??"värdet"}`;default:return"Ogiltig input"}}};function AE(){return{localeError:jE()}}const RE=()=>{const e={string:{unit:"எழுத்துக்கள்",verb:"கொண்டிருக்க வேண்டும்"},file:{unit:"பைட்டுகள்",verb:"கொண்டிருக்க வேண்டும்"},array:{unit:"உறுப்புகள்",verb:"கொண்டிருக்க வேண்டும்"},set:{unit:"உறுப்புகள்",verb:"கொண்டிருக்க வேண்டும்"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"எண் அல்லாதது":"எண்";case"object":{if(Array.isArray(r))return"அணி";if(r===null)return"வெறுமை";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"உள்ளீடு",email:"மின்னஞ்சல் முகவரி",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO தேதி நேரம்",date:"ISO தேதி",time:"ISO நேரம்",duration:"ISO கால அளவு",ipv4:"IPv4 முகவரி",ipv6:"IPv6 முகவரி",cidrv4:"IPv4 வரம்பு",cidrv6:"IPv6 வரம்பு",base64:"base64-encoded சரம்",base64url:"base64url-encoded சரம்",json_string:"JSON சரம்",e164:"E.164 எண்",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${r.expected}, பெறப்பட்டது ${n(r.input)}`;case"invalid_value":return r.values.length===1?`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${H(r.values[0])}`:`தவறான விருப்பம்: எதிர்பார்க்கப்பட்டது ${j(r.values,"|")} இல் ஒன்று`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`மிக பெரியது: எதிர்பார்க்கப்பட்டது ${r.origin??"மதிப்பு"} ${i}${r.maximum.toString()} ${a.unit??"உறுப்புகள்"} ஆக இருக்க வேண்டும்`:`மிக பெரியது: எதிர்பார்க்கப்பட்டது ${r.origin??"மதிப்பு"} ${i}${r.maximum.toString()} ஆக இருக்க வேண்டும்`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${r.origin} ${i}${r.minimum.toString()} ${a.unit} ஆக இருக்க வேண்டும்`:`மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${r.origin} ${i}${r.minimum.toString()} ஆக இருக்க வேண்டும்`}case"invalid_format":{const i=r;return i.format==="starts_with"?`தவறான சரம்: "${i.prefix}" இல் தொடங்க வேண்டும்`:i.format==="ends_with"?`தவறான சரம்: "${i.suffix}" இல் முடிவடைய வேண்டும்`:i.format==="includes"?`தவறான சரம்: "${i.includes}" ஐ உள்ளடக்க வேண்டும்`:i.format==="regex"?`தவறான சரம்: ${i.pattern} முறைபாட்டுடன் பொருந்த வேண்டும்`:`தவறான ${o[i.format]??r.format}`}case"not_multiple_of":return`தவறான எண்: ${r.divisor} இன் பலமாக இருக்க வேண்டும்`;case"unrecognized_keys":return`அடையாளம் தெரியாத விசை${r.keys.length>1?"கள்":""}: ${j(r.keys,", ")}`;case"invalid_key":return`${r.origin} இல் தவறான விசை`;case"invalid_union":return"தவறான உள்ளீடு";case"invalid_element":return`${r.origin} இல் தவறான மதிப்பு`;default:return"தவறான உள்ளீடு"}}};function zE(){return{localeError:RE()}}const ME=()=>{const e={string:{unit:"ตัวอักษร",verb:"ควรมี"},file:{unit:"ไบต์",verb:"ควรมี"},array:{unit:"รายการ",verb:"ควรมี"},set:{unit:"รายการ",verb:"ควรมี"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"ไม่ใช่ตัวเลข (NaN)":"ตัวเลข";case"object":{if(Array.isArray(r))return"อาร์เรย์ (Array)";if(r===null)return"ไม่มีค่า (null)";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ข้อมูลที่ป้อน",email:"ที่อยู่อีเมล",url:"URL",emoji:"อิโมจิ",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"วันที่เวลาแบบ ISO",date:"วันที่แบบ ISO",time:"เวลาแบบ ISO",duration:"ช่วงเวลาแบบ ISO",ipv4:"ที่อยู่ IPv4",ipv6:"ที่อยู่ IPv6",cidrv4:"ช่วง IP แบบ IPv4",cidrv6:"ช่วง IP แบบ IPv6",base64:"ข้อความแบบ Base64",base64url:"ข้อความแบบ Base64 สำหรับ URL",json_string:"ข้อความแบบ JSON",e164:"เบอร์โทรศัพท์ระหว่างประเทศ (E.164)",jwt:"โทเคน JWT",template_literal:"ข้อมูลที่ป้อน"};return r=>{switch(r.code){case"invalid_type":return`ประเภทข้อมูลไม่ถูกต้อง: ควรเป็น ${r.expected} แต่ได้รับ ${n(r.input)}`;case"invalid_value":return r.values.length===1?`ค่าไม่ถูกต้อง: ควรเป็น ${H(r.values[0])}`:`ตัวเลือกไม่ถูกต้อง: ควรเป็นหนึ่งใน ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"ไม่เกิน":"น้อยกว่า",a=t(r.origin);return a?`เกินกำหนด: ${r.origin??"ค่า"} ควรมี${i} ${r.maximum.toString()} ${a.unit??"รายการ"}`:`เกินกำหนด: ${r.origin??"ค่า"} ควรมี${i} ${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?"อย่างน้อย":"มากกว่า",a=t(r.origin);return a?`น้อยกว่ากำหนด: ${r.origin} ควรมี${i} ${r.minimum.toString()} ${a.unit}`:`น้อยกว่ากำหนด: ${r.origin} ควรมี${i} ${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`รูปแบบไม่ถูกต้อง: ข้อความต้องขึ้นต้นด้วย "${i.prefix}"`:i.format==="ends_with"?`รูปแบบไม่ถูกต้อง: ข้อความต้องลงท้ายด้วย "${i.suffix}"`:i.format==="includes"?`รูปแบบไม่ถูกต้อง: ข้อความต้องมี "${i.includes}" อยู่ในข้อความ`:i.format==="regex"?`รูปแบบไม่ถูกต้อง: ต้องตรงกับรูปแบบที่กำหนด ${i.pattern}`:`รูปแบบไม่ถูกต้อง: ${o[i.format]??r.format}`}case"not_multiple_of":return`ตัวเลขไม่ถูกต้อง: ต้องเป็นจำนวนที่หารด้วย ${r.divisor} ได้ลงตัว`;case"unrecognized_keys":return`พบคีย์ที่ไม่รู้จัก: ${j(r.keys,", ")}`;case"invalid_key":return`คีย์ไม่ถูกต้องใน ${r.origin}`;case"invalid_union":return"ข้อมูลไม่ถูกต้อง: ไม่ตรงกับรูปแบบยูเนียนที่กำหนดไว้";case"invalid_element":return`ข้อมูลไม่ถูกต้องใน ${r.origin}`;default:return"ข้อมูลไม่ถูกต้อง"}}};function DE(){return{localeError:ME()}}const UE=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},LE=()=>{const e={string:{unit:"karakter",verb:"olmalı"},file:{unit:"bayt",verb:"olmalı"},array:{unit:"öğe",verb:"olmalı"},set:{unit:"öğe",verb:"olmalı"}};function t(o){return e[o]??null}const n={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO süre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aralığı",cidrv6:"IPv6 aralığı",base64:"base64 ile şifrelenmiş metin",base64url:"base64url ile şifrelenmiş metin",json_string:"JSON dizesi",e164:"E.164 sayısı",jwt:"JWT",template_literal:"Şablon dizesi"};return o=>{switch(o.code){case"invalid_type":return`Geçersiz değer: beklenen ${o.expected}, alınan ${UE(o.input)}`;case"invalid_value":return o.values.length===1?`Geçersiz değer: beklenen ${H(o.values[0])}`:`Geçersiz seçenek: aşağıdakilerden biri olmalı: ${j(o.values,"|")}`;case"too_big":{const r=o.inclusive?"<=":"<",i=t(o.origin);return i?`Çok büyük: beklenen ${o.origin??"değer"} ${r}${o.maximum.toString()} ${i.unit??"öğe"}`:`Çok büyük: beklenen ${o.origin??"değer"} ${r}${o.maximum.toString()}`}case"too_small":{const r=o.inclusive?">=":">",i=t(o.origin);return i?`Çok küçük: beklenen ${o.origin} ${r}${o.minimum.toString()} ${i.unit}`:`Çok küçük: beklenen ${o.origin} ${r}${o.minimum.toString()}`}case"invalid_format":{const r=o;return r.format==="starts_with"?`Geçersiz metin: "${r.prefix}" ile başlamalı`:r.format==="ends_with"?`Geçersiz metin: "${r.suffix}" ile bitmeli`:r.format==="includes"?`Geçersiz metin: "${r.includes}" içermeli`:r.format==="regex"?`Geçersiz metin: ${r.pattern} desenine uymalı`:`Geçersiz ${n[r.format]??o.format}`}case"not_multiple_of":return`Geçersiz sayı: ${o.divisor} ile tam bölünebilmeli`;case"unrecognized_keys":return`Tanınmayan anahtar${o.keys.length>1?"lar":""}: ${j(o.keys,", ")}`;case"invalid_key":return`${o.origin} içinde geçersiz anahtar`;case"invalid_union":return"Geçersiz değer";case"invalid_element":return`${o.origin} içinde geçersiz değer`;default:return"Geçersiz değer"}}};function ZE(){return{localeError:LE()}}const FE=()=>{const e={string:{unit:"символів",verb:"матиме"},file:{unit:"байтів",verb:"матиме"},array:{unit:"елементів",verb:"матиме"},set:{unit:"елементів",verb:"матиме"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"число";case"object":{if(Array.isArray(r))return"масив";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"вхідні дані",email:"адреса електронної пошти",url:"URL",emoji:"емодзі",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"дата та час ISO",date:"дата ISO",time:"час ISO",duration:"тривалість ISO",ipv4:"адреса IPv4",ipv6:"адреса IPv6",cidrv4:"діапазон IPv4",cidrv6:"діапазон IPv6",base64:"рядок у кодуванні base64",base64url:"рядок у кодуванні base64url",json_string:"рядок JSON",e164:"номер E.164",jwt:"JWT",template_literal:"вхідні дані"};return r=>{switch(r.code){case"invalid_type":return`Неправильні вхідні дані: очікується ${r.expected}, отримано ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Неправильні вхідні дані: очікується ${H(r.values[0])}`:`Неправильна опція: очікується одне з ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Занадто велике: очікується, що ${r.origin??"значення"} ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"елементів"}`:`Занадто велике: очікується, що ${r.origin??"значення"} буде ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Занадто мале: очікується, що ${r.origin} ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Занадто мале: очікується, що ${r.origin} буде ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Неправильний рядок: повинен починатися з "${i.prefix}"`:i.format==="ends_with"?`Неправильний рядок: повинен закінчуватися на "${i.suffix}"`:i.format==="includes"?`Неправильний рядок: повинен містити "${i.includes}"`:i.format==="regex"?`Неправильний рядок: повинен відповідати шаблону ${i.pattern}`:`Неправильний ${o[i.format]??r.format}`}case"not_multiple_of":return`Неправильне число: повинно бути кратним ${r.divisor}`;case"unrecognized_keys":return`Нерозпізнаний ключ${r.keys.length>1?"і":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Неправильний ключ у ${r.origin}`;case"invalid_union":return"Неправильні вхідні дані";case"invalid_element":return`Неправильне значення у ${r.origin}`;default:return"Неправильні вхідні дані"}}};function bv(){return{localeError:FE()}}function qE(){return bv()}const VE=()=>{const e={string:{unit:"حروف",verb:"ہونا"},file:{unit:"بائٹس",verb:"ہونا"},array:{unit:"آئٹمز",verb:"ہونا"},set:{unit:"آئٹمز",verb:"ہونا"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"نمبر";case"object":{if(Array.isArray(r))return"آرے";if(r===null)return"نل";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ان پٹ",email:"ای میل ایڈریس",url:"یو آر ایل",emoji:"ایموجی",uuid:"یو یو آئی ڈی",uuidv4:"یو یو آئی ڈی وی 4",uuidv6:"یو یو آئی ڈی وی 6",nanoid:"نینو آئی ڈی",guid:"جی یو آئی ڈی",cuid:"سی یو آئی ڈی",cuid2:"سی یو آئی ڈی 2",ulid:"یو ایل آئی ڈی",xid:"ایکس آئی ڈی",ksuid:"کے ایس یو آئی ڈی",datetime:"آئی ایس او ڈیٹ ٹائم",date:"آئی ایس او تاریخ",time:"آئی ایس او وقت",duration:"آئی ایس او مدت",ipv4:"آئی پی وی 4 ایڈریس",ipv6:"آئی پی وی 6 ایڈریس",cidrv4:"آئی پی وی 4 رینج",cidrv6:"آئی پی وی 6 رینج",base64:"بیس 64 ان کوڈڈ سٹرنگ",base64url:"بیس 64 یو آر ایل ان کوڈڈ سٹرنگ",json_string:"جے ایس او این سٹرنگ",e164:"ای 164 نمبر",jwt:"جے ڈبلیو ٹی",template_literal:"ان پٹ"};return r=>{switch(r.code){case"invalid_type":return`غلط ان پٹ: ${r.expected} متوقع تھا، ${n(r.input)} موصول ہوا`;case"invalid_value":return r.values.length===1?`غلط ان پٹ: ${H(r.values[0])} متوقع تھا`:`غلط آپشن: ${j(r.values,"|")} میں سے ایک متوقع تھا`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`بہت بڑا: ${r.origin??"ویلیو"} کے ${i}${r.maximum.toString()} ${a.unit??"عناصر"} ہونے متوقع تھے`:`بہت بڑا: ${r.origin??"ویلیو"} کا ${i}${r.maximum.toString()} ہونا متوقع تھا`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`بہت چھوٹا: ${r.origin} کے ${i}${r.minimum.toString()} ${a.unit} ہونے متوقع تھے`:`بہت چھوٹا: ${r.origin} کا ${i}${r.minimum.toString()} ہونا متوقع تھا`}case"invalid_format":{const i=r;return i.format==="starts_with"?`غلط سٹرنگ: "${i.prefix}" سے شروع ہونا چاہیے`:i.format==="ends_with"?`غلط سٹرنگ: "${i.suffix}" پر ختم ہونا چاہیے`:i.format==="includes"?`غلط سٹرنگ: "${i.includes}" شامل ہونا چاہیے`:i.format==="regex"?`غلط سٹرنگ: پیٹرن ${i.pattern} سے میچ ہونا چاہیے`:`غلط ${o[i.format]??r.format}`}case"not_multiple_of":return`غلط نمبر: ${r.divisor} کا مضاعف ہونا چاہیے`;case"unrecognized_keys":return`غیر تسلیم شدہ کی${r.keys.length>1?"ز":""}: ${j(r.keys,"، ")}`;case"invalid_key":return`${r.origin} میں غلط کی`;case"invalid_union":return"غلط ان پٹ";case"invalid_element":return`${r.origin} میں غلط ویلیو`;default:return"غلط ان پٹ"}}};function BE(){return{localeError:VE()}}const JE=()=>{const e={string:{unit:"ký tự",verb:"có"},file:{unit:"byte",verb:"có"},array:{unit:"phần tử",verb:"có"},set:{unit:"phần tử",verb:"có"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"số";case"object":{if(Array.isArray(r))return"mảng";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"đầu vào",email:"địa chỉ email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ngày giờ ISO",date:"ngày ISO",time:"giờ ISO",duration:"khoảng thời gian ISO",ipv4:"địa chỉ IPv4",ipv6:"địa chỉ IPv6",cidrv4:"dải IPv4",cidrv6:"dải IPv6",base64:"chuỗi mã hóa base64",base64url:"chuỗi mã hóa base64url",json_string:"chuỗi JSON",e164:"số E.164",jwt:"JWT",template_literal:"đầu vào"};return r=>{switch(r.code){case"invalid_type":return`Đầu vào không hợp lệ: mong đợi ${r.expected}, nhận được ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Đầu vào không hợp lệ: mong đợi ${H(r.values[0])}`:`Tùy chọn không hợp lệ: mong đợi một trong các giá trị ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Quá lớn: mong đợi ${r.origin??"giá trị"} ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"phần tử"}`:`Quá lớn: mong đợi ${r.origin??"giá trị"} ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Quá nhỏ: mong đợi ${r.origin} ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Quá nhỏ: mong đợi ${r.origin} ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Chuỗi không hợp lệ: phải bắt đầu bằng "${i.prefix}"`:i.format==="ends_with"?`Chuỗi không hợp lệ: phải kết thúc bằng "${i.suffix}"`:i.format==="includes"?`Chuỗi không hợp lệ: phải bao gồm "${i.includes}"`:i.format==="regex"?`Chuỗi không hợp lệ: phải khớp với mẫu ${i.pattern}`:`${o[i.format]??r.format} không hợp lệ`}case"not_multiple_of":return`Số không hợp lệ: phải là bội số của ${r.divisor}`;case"unrecognized_keys":return`Khóa không được nhận dạng: ${j(r.keys,", ")}`;case"invalid_key":return`Khóa không hợp lệ trong ${r.origin}`;case"invalid_union":return"Đầu vào không hợp lệ";case"invalid_element":return`Giá trị không hợp lệ trong ${r.origin}`;default:return"Đầu vào không hợp lệ"}}};function WE(){return{localeError:JE()}}const HE=()=>{const e={string:{unit:"字符",verb:"包含"},file:{unit:"字节",verb:"包含"},array:{unit:"项",verb:"包含"},set:{unit:"项",verb:"包含"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"非数字(NaN)":"数字";case"object":{if(Array.isArray(r))return"数组";if(r===null)return"空值(null)";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"输入",email:"电子邮件",url:"URL",emoji:"表情符号",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO日期时间",date:"ISO日期",time:"ISO时间",duration:"ISO时长",ipv4:"IPv4地址",ipv6:"IPv6地址",cidrv4:"IPv4网段",cidrv6:"IPv6网段",base64:"base64编码字符串",base64url:"base64url编码字符串",json_string:"JSON字符串",e164:"E.164号码",jwt:"JWT",template_literal:"输入"};return r=>{switch(r.code){case"invalid_type":return`无效输入:期望 ${r.expected},实际接收 ${n(r.input)}`;case"invalid_value":return r.values.length===1?`无效输入:期望 ${H(r.values[0])}`:`无效选项:期望以下之一 ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`数值过大:期望 ${r.origin??"值"} ${i}${r.maximum.toString()} ${a.unit??"个元素"}`:`数值过大:期望 ${r.origin??"值"} ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`数值过小:期望 ${r.origin} ${i}${r.minimum.toString()} ${a.unit}`:`数值过小:期望 ${r.origin} ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`无效字符串:必须以 "${i.prefix}" 开头`:i.format==="ends_with"?`无效字符串:必须以 "${i.suffix}" 结尾`:i.format==="includes"?`无效字符串:必须包含 "${i.includes}"`:i.format==="regex"?`无效字符串:必须满足正则表达式 ${i.pattern}`:`无效${o[i.format]??r.format}`}case"not_multiple_of":return`无效数字:必须是 ${r.divisor} 的倍数`;case"unrecognized_keys":return`出现未知的键(key): ${j(r.keys,", ")}`;case"invalid_key":return`${r.origin} 中的键(key)无效`;case"invalid_union":return"无效输入";case"invalid_element":return`${r.origin} 中包含无效值(value)`;default:return"无效输入"}}};function GE(){return{localeError:HE()}}const KE=()=>{const e={string:{unit:"字元",verb:"擁有"},file:{unit:"位元組",verb:"擁有"},array:{unit:"項目",verb:"擁有"},set:{unit:"項目",verb:"擁有"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"輸入",email:"郵件地址",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO 日期時間",date:"ISO 日期",time:"ISO 時間",duration:"ISO 期間",ipv4:"IPv4 位址",ipv6:"IPv6 位址",cidrv4:"IPv4 範圍",cidrv6:"IPv6 範圍",base64:"base64 編碼字串",base64url:"base64url 編碼字串",json_string:"JSON 字串",e164:"E.164 數值",jwt:"JWT",template_literal:"輸入"};return r=>{switch(r.code){case"invalid_type":return`無效的輸入值:預期為 ${r.expected},但收到 ${n(r.input)}`;case"invalid_value":return r.values.length===1?`無效的輸入值:預期為 ${H(r.values[0])}`:`無效的選項:預期為以下其中之一 ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`數值過大:預期 ${r.origin??"值"} 應為 ${i}${r.maximum.toString()} ${a.unit??"個元素"}`:`數值過大:預期 ${r.origin??"值"} 應為 ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`數值過小:預期 ${r.origin} 應為 ${i}${r.minimum.toString()} ${a.unit}`:`數值過小:預期 ${r.origin} 應為 ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`無效的字串:必須以 "${i.prefix}" 開頭`:i.format==="ends_with"?`無效的字串:必須以 "${i.suffix}" 結尾`:i.format==="includes"?`無效的字串:必須包含 "${i.includes}"`:i.format==="regex"?`無效的字串:必須符合格式 ${i.pattern}`:`無效的 ${o[i.format]??r.format}`}case"not_multiple_of":return`無效的數字:必須為 ${r.divisor} 的倍數`;case"unrecognized_keys":return`無法識別的鍵值${r.keys.length>1?"們":""}:${j(r.keys,"、")}`;case"invalid_key":return`${r.origin} 中有無效的鍵值`;case"invalid_union":return"無效的輸入值";case"invalid_element":return`${r.origin} 中有無效的值`;default:return"無效的輸入值"}}};function YE(){return{localeError:KE()}}const QE=()=>{const e={string:{unit:"àmi",verb:"ní"},file:{unit:"bytes",verb:"ní"},array:{unit:"nkan",verb:"ní"},set:{unit:"nkan",verb:"ní"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"nọ́mbà";case"object":{if(Array.isArray(r))return"akopọ";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ẹ̀rọ ìbáwọlé",email:"àdírẹ́sì ìmẹ́lì",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"àkókò ISO",date:"ọjọ́ ISO",time:"àkókò ISO",duration:"àkókò tó pé ISO",ipv4:"àdírẹ́sì IPv4",ipv6:"àdírẹ́sì IPv6",cidrv4:"àgbègbè IPv4",cidrv6:"àgbègbè IPv6",base64:"ọ̀rọ̀ tí a kọ́ ní base64",base64url:"ọ̀rọ̀ base64url",json_string:"ọ̀rọ̀ JSON",e164:"nọ́mbà E.164",jwt:"JWT",template_literal:"ẹ̀rọ ìbáwọlé"};return r=>{switch(r.code){case"invalid_type":return`Ìbáwọlé aṣìṣe: a ní láti fi ${r.expected}, àmọ̀ a rí ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ìbáwọlé aṣìṣe: a ní láti fi ${H(r.values[0])}`:`Àṣàyàn aṣìṣe: yan ọ̀kan lára ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Tó pọ̀ jù: a ní láti jẹ́ pé ${r.origin??"iye"} ${a.verb} ${i}${r.maximum} ${a.unit}`:`Tó pọ̀ jù: a ní láti jẹ́ ${i}${r.maximum}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Kéré ju: a ní láti jẹ́ pé ${r.origin} ${a.verb} ${i}${r.minimum} ${a.unit}`:`Kéré ju: a ní láti jẹ́ ${i}${r.minimum}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bẹ̀rẹ̀ pẹ̀lú "${i.prefix}"`:i.format==="ends_with"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ parí pẹ̀lú "${i.suffix}"`:i.format==="includes"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ ní "${i.includes}"`:i.format==="regex"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bá àpẹẹrẹ mu ${i.pattern}`:`Aṣìṣe: ${o[i.format]??r.format}`}case"not_multiple_of":return`Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${r.divisor}`;case"unrecognized_keys":return`Bọtìnì àìmọ̀: ${j(r.keys,", ")}`;case"invalid_key":return`Bọtìnì aṣìṣe nínú ${r.origin}`;case"invalid_union":return"Ìbáwọlé aṣìṣe";case"invalid_element":return`Iye aṣìṣe nínú ${r.origin}`;default:return"Ìbáwọlé aṣìṣe"}}};function XE(){return{localeError:QE()}}const _v=Object.freeze(Object.defineProperty({__proto__:null,ar:pk,az:hk,be:vk,bg:_k,ca:xk,cs:Sk,da:kk,de:Ok,en:vv,eo:jk,es:Rk,fa:Mk,fi:Uk,fr:Zk,frCA:qk,he:Bk,hu:Wk,id:Gk,is:Qk,it:eE,ja:rE,ka:iE,kh:sE,km:yv,ko:lE,lt:fE,mk:mE,ms:gE,nl:yE,no:_E,ota:xE,pl:kE,ps:SE,pt:OE,ru:NE,sl:CE,sv:AE,ta:zE,th:DE,tr:ZE,ua:qE,uk:bv,ur:BE,vi:WE,yo:XE,zhCN:GE,zhTW:YE},Symbol.toStringTag,{value:"Module"}));var Gd;const wv=Symbol("ZodOutput"),xv=Symbol("ZodInput");class $v{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];if(this._map.set(t,o),o&&typeof o=="object"&&"id"in o){if(this._idmap.has(o.id))throw new Error(`ID ${o.id} already exists in the registry`);this._idmap.set(o.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const o={...this.get(n)??{}};delete o.id;const r={...o,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function al(){return new $v}(Gd=globalThis).__zod_globalRegistry??(Gd.__zod_globalRegistry=al());const xt=globalThis.__zod_globalRegistry;function Sv(e,t){return new e({type:"string",...P(t)})}function Iv(e,t){return new e({type:"string",coerce:!0,...P(t)})}function sl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...P(t)})}function fi(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...P(t)})}function ul(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function ll(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function cl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function dl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(t)})}function Hi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...P(t)})}function fl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function pl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function ml(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function hl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function gl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function vl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function yl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function bl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function _l(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(t)})}function kv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...P(t)})}function wl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function xl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function $l(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function Sl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function Il(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function kl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...P(t)})}const Ev={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Ov(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function Tv(e,t){return new e({type:"string",format:"date",check:"string_format",...P(t)})}function Nv(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...P(t)})}function Pv(e,t){return new e({type:"string",format:"duration",check:"string_format",...P(t)})}function Cv(e,t){return new e({type:"number",checks:[],...P(t)})}function jv(e,t){return new e({type:"number",coerce:!0,checks:[],...P(t)})}function Av(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...P(t)})}function Rv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...P(t)})}function zv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...P(t)})}function Mv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...P(t)})}function Dv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...P(t)})}function Uv(e,t){return new e({type:"boolean",...P(t)})}function Lv(e,t){return new e({type:"boolean",coerce:!0,...P(t)})}function Zv(e,t){return new e({type:"bigint",...P(t)})}function Fv(e,t){return new e({type:"bigint",coerce:!0,...P(t)})}function qv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...P(t)})}function Vv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...P(t)})}function Bv(e,t){return new e({type:"symbol",...P(t)})}function Jv(e,t){return new e({type:"undefined",...P(t)})}function Wv(e,t){return new e({type:"null",...P(t)})}function Hv(e){return new e({type:"any"})}function Gv(e){return new e({type:"unknown"})}function Kv(e,t){return new e({type:"never",...P(t)})}function Yv(e,t){return new e({type:"void",...P(t)})}function Qv(e,t){return new e({type:"date",...P(t)})}function Xv(e,t){return new e({type:"date",coerce:!0,...P(t)})}function ey(e,t){return new e({type:"nan",...P(t)})}function or(e,t){return new Qu({check:"less_than",...P(t),value:e,inclusive:!1})}function ut(e,t){return new Qu({check:"less_than",...P(t),value:e,inclusive:!0})}function ir(e,t){return new Xu({check:"greater_than",...P(t),value:e,inclusive:!1})}function We(e,t){return new Xu({check:"greater_than",...P(t),value:e,inclusive:!0})}function El(e){return ir(0,e)}function Ol(e){return or(0,e)}function Tl(e){return ut(0,e)}function Nl(e){return We(0,e)}function Gr(e,t){return new Dh({check:"multiple_of",...P(t),value:e})}function uo(e,t){return new Zh({check:"max_size",...P(t),maximum:e})}function Kr(e,t){return new Fh({check:"min_size",...P(t),minimum:e})}function Gi(e,t){return new qh({check:"size_equals",...P(t),size:e})}function lo(e,t){return new Vh({check:"max_length",...P(t),maximum:e})}function yr(e,t){return new Bh({check:"min_length",...P(t),minimum:e})}function co(e,t){return new Jh({check:"length_equals",...P(t),length:e})}function Ki(e,t){return new Wh({check:"string_format",format:"regex",...P(t),pattern:e})}function Yi(e){return new Hh({check:"string_format",format:"lowercase",...P(e)})}function Qi(e){return new Gh({check:"string_format",format:"uppercase",...P(e)})}function Xi(e,t){return new Kh({check:"string_format",format:"includes",...P(t),includes:e})}function ea(e,t){return new Yh({check:"string_format",format:"starts_with",...P(t),prefix:e})}function ta(e,t){return new Qh({check:"string_format",format:"ends_with",...P(t),suffix:e})}function Pl(e,t,n){return new Xh({check:"property",property:e,schema:t,...P(n)})}function ra(e,t){return new eg({check:"mime_type",mime:e,...P(t)})}function Gt(e){return new tg({check:"overwrite",tx:e})}function na(e){return Gt(t=>t.normalize(e))}function oa(){return Gt(e=>e.trim())}function ia(){return Gt(e=>e.toLowerCase())}function aa(){return Gt(e=>e.toUpperCase())}function sa(){return Gt(e=>Am(e))}function ty(e,t,n){return new e({type:"array",element:t,...P(n)})}function eO(e,t,n){return new e({type:"union",options:t,...P(n)})}function tO(e,t,n){return new e({type:"union",options:t,inclusive:!1,...P(n)})}function rO(e,t,n,o){return new e({type:"union",options:n,discriminator:t,...P(o)})}function nO(e,t,n){return new e({type:"intersection",left:t,right:n})}function oO(e,t,n,o){const r=n instanceof X,i=r?o:n,a=r?n:null;return new e({type:"tuple",items:t,rest:a,...P(i)})}function iO(e,t,n,o){return new e({type:"record",keyType:t,valueType:n,...P(o)})}function aO(e,t,n,o){return new e({type:"map",keyType:t,valueType:n,...P(o)})}function sO(e,t,n){return new e({type:"set",valueType:t,...P(n)})}function uO(e,t,n){const o=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new e({type:"enum",entries:o,...P(n)})}function lO(e,t,n){return new e({type:"enum",entries:t,...P(n)})}function cO(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...P(n)})}function ry(e,t){return new e({type:"file",...P(t)})}function dO(e,t){return new e({type:"transform",transform:t})}function fO(e,t){return new e({type:"optional",innerType:t})}function pO(e,t){return new e({type:"nullable",innerType:t})}function mO(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():Vi(n)}})}function hO(e,t,n){return new e({type:"nonoptional",innerType:t,...P(n)})}function gO(e,t){return new e({type:"success",innerType:t})}function vO(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:()=>n})}function yO(e,t,n){return new e({type:"pipe",in:t,out:n})}function bO(e,t){return new e({type:"readonly",innerType:t})}function _O(e,t,n){return new e({type:"template_literal",parts:t,...P(n)})}function wO(e,t){return new e({type:"lazy",getter:t})}function xO(e,t){return new e({type:"promise",innerType:t})}function ny(e,t,n){const o=P(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function oy(e,t,n){return new e({type:"custom",check:"custom",fn:t,...P(n)})}function iy(e){const t=ay(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Wr(o,n.value,t._zod.def));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(Wr(r))}},e(n.value,n)));return t}function ay(e,t){const n=new Se({check:"custom",...P(t)});return n._zod.check=e,n}function sy(e){const t=new Se({check:"describe"});return t._zod.onattach=[n=>{const o=xt.get(n)??{};xt.add(n,{...o,description:e})}],t._zod.check=()=>{},t}function uy(e){const t=new Se({check:"meta"});return t._zod.onattach=[n=>{const o=xt.get(n)??{};xt.add(n,{...o,...e})}],t._zod.check=()=>{},t}function ly(e,t){const n=P(t);let o=n.truthy??["true","1","yes","on","y","enabled"],r=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(o=o.map(f=>typeof f=="string"?f.toLowerCase():f),r=r.map(f=>typeof f=="string"?f.toLowerCase():f));const i=new Set(o),a=new Set(r),s=e.Codec??il,l=e.Boolean??rl,u=e.String??so,c=new u({type:"string",error:n.error}),d=new l({type:"boolean",error:n.error}),p=new s({type:"pipe",in:c,out:d,transform:((f,g)=>{let m=f;return n.case!=="sensitive"&&(m=m.toLowerCase()),i.has(m)?!0:a.has(m)?!1:(g.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...a],input:g.value,inst:p,continue:!1}),{})}),reverseTransform:((f,g)=>f===!0?o[0]||"true":r[0]||"false"),error:n.error});return p}function fo(e,t,n,o={}){const r=P(o),i={...P(o),check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:s=>n.test(s),...r};return n instanceof RegExp&&(i.pattern=n),new e(i)}function Yr(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??xt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function me(e,t,n={path:[],schemaPath:[]}){var o;const r=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const c={...n,schemaPath:[...n.schemaPath,e],path:n.path},d=e._zod.parent;if(d)a.ref=d,me(d,t,c),t.seen.get(d).isParent=!0;else if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,c);else{const p=a.schema,f=t.processors[r.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,p,c)}}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),t.io==="input"&&Ve(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((o=a.schema).default??(o.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Qr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const c=e.external.registry.get(i[0])?.id,d=e.external.uri??(f=>f);if(c)return{ref:d(c)};const p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${d("__shared")}#/${a}/${p}`}}if(i[1]===n)return{ref:"#"};const l=`#/${a}/`,u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},r=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:s,defId:l}=o(i);a.def={...a.schema},l&&(a.defId=l);const u=a.schema;for(const c in u)delete u[c];u.$ref=s};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
27
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");const x=p.compile();return($,v)=>x(f,$,v)};let i;const a=Wr,s=!ci.jitless,u=s&&zm.value,c=t.catchall;let d;e._zod.parse=(f,p)=>{d??(d=o.value);const g=f.value;return a(g)?s&&u&&p?.async===!1&&p.jitless!==!0?(i||(i=r(t.shape)),f=i(f,p),c?Vg([],g,f,p,d,e):f):n(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),f)}});function Dd(e,t,n,o){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const r=e.filter(i=>!mr(i));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>ut(a,o,De())))}),t)}const Ki=S("$ZodUnion",(e,t)=>{X.init(e,t),ne(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ne(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ne(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),ne(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${r.map(i=>Ji(i.source)).join("|")})$`)}});const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,i)=>{if(n)return o(r,i);let a=!1;const s=[];for(const l of t.options){const u=l._zod.run({value:r.value,issues:[]},i);if(u instanceof Promise)s.push(u),a=!0;else{if(u.issues.length===0)return u;s.push(u)}}return a?Promise.all(s).then(l=>Dd(l,r,e,i)):Dd(s,r,e,i)}});function Ud(e,t,n,o){const r=e.filter(i=>i.issues.length===0);return r.length===1?(t.value=r[0].value,t):(r.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>ut(a,o,De())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1}),t)}const Wg=S("$ZodXor",(e,t)=>{Ki.init(e,t),t.inclusive=!1;const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,i)=>{if(n)return o(r,i);let a=!1;const s=[];for(const l of t.options){const u=l._zod.run({value:r.value,issues:[]},i);u instanceof Promise?(s.push(u),a=!0):s.push(u)}return a?Promise.all(s).then(l=>Ud(l,r,e,i)):Ud(s,r,e,i)}}),Hg=S("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ki.init(e,t);const n=e._zod.parse;ne(e._zod,"propValues",()=>{const r={};for(const i of t.options){const a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[s,l]of Object.entries(a)){r[s]||(r[s]=new Set);for(const u of l)r[s].add(u)}}return r});const o=eo(()=>{const r=t.options,i=new Map;for(const a of r){const s=a._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const l of s){if(i.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);i.set(l,a)}}return i});e._zod.parse=(r,i)=>{const a=r.value;if(!Wr(a))return r.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),r;const s=o.value.get(a?.[t.discriminator]);return s?s._zod.run(r,i):t.unionFallback?n(r,i):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),r)}}),Gg=S("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value,i=t.left._zod.run({value:r,issues:[]},o),a=t.right._zod.run({value:r,issues:[]},o);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([l,u])=>Ld(n,l,u)):Ld(n,i,a)}});function Xs(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(yr(e)&&yr(t)){const n=Object.keys(t),o=Object.keys(e).filter(i=>n.indexOf(i)!==-1),r={...e,...t};for(const i of o){const a=Xs(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};r[i]=a.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const r=e[o],i=t[o],a=Xs(r,i);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ld(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),mr(e))return e;const o=Xs(t.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const sl=S("$ZodTuple",(e,t)=>{X.init(e,t);const n=t.items;e._zod.parse=(o,r)=>{const i=o.value;if(!Array.isArray(i))return o.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];const a=[],s=[...n].reverse().findIndex(c=>c._zod.optin!=="optional"),l=s===-1?0:n.length-s;if(!t.rest){const c=i.length>n.length,d=i.length<l-1;if(c||d)return o.issues.push({...c?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},input:i,inst:e,origin:"array"}),o}let u=-1;for(const c of n){if(u++,u>=i.length&&u>=l)continue;const d=c._zod.run({value:i[u],issues:[]},r);d instanceof Promise?a.push(d.then(f=>Uo(f,o,u))):Uo(d,o,u)}if(t.rest){const c=i.slice(n.length);for(const d of c){u++;const f=t.rest._zod.run({value:d,issues:[]},r);f instanceof Promise?a.push(f.then(p=>Uo(p,o,u))):Uo(f,o,u)}}return a.length?Promise.all(a).then(()=>o):o}});function Uo(e,t,n){e.issues.length&&t.issues.push(..._t(n,e.issues)),t.value[n]=e.value}const Kg=S("$ZodRecord",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!yr(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const s=new Set;for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){s.add(typeof u=="number"?u.toString():u);const c=t.valueType._zod.run({value:r[u],issues:[]},o);c instanceof Promise?i.push(c.then(d=>{d.issues.length&&n.issues.push(..._t(u,d.issues)),n.value[u]=d.value})):(c.issues.length&&n.issues.push(..._t(u,c.issues)),n.value[u]=c.value)}let l;for(const u in r)s.has(u)||(l=l??[],l.push(u));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:l})}else{n.value={};for(const s of Reflect.ownKeys(r)){if(s==="__proto__")continue;const l=t.keyType._zod.run({value:s,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){t.mode==="loose"?n.value[s]=r[s]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(c=>ut(c,o,De())),input:s,path:[s],inst:e});continue}const u=t.valueType._zod.run({value:r[s],issues:[]},o);u instanceof Promise?i.push(u.then(c=>{c.issues.length&&n.issues.push(..._t(s,c.issues)),n.value[l.value]=c.value})):(u.issues.length&&n.issues.push(..._t(s,u.issues)),n.value[l.value]=u.value)}}return i.length?Promise.all(i).then(()=>n):n}}),Yg=S("$ZodMap",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!(r instanceof Map))return n.issues.push({expected:"map",code:"invalid_type",input:r,inst:e}),n;const i=[];n.value=new Map;for(const[a,s]of r){const l=t.keyType._zod.run({value:a,issues:[]},o),u=t.valueType._zod.run({value:s,issues:[]},o);l instanceof Promise||u instanceof Promise?i.push(Promise.all([l,u]).then(([c,d])=>{Zd(c,d,n,a,r,e,o)})):Zd(l,u,n,a,r,e,o)}return i.length?Promise.all(i).then(()=>n):n}});function Zd(e,t,n,o,r,i,a){e.issues.length&&(pi.has(typeof o)?n.issues.push(..._t(o,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:r,inst:i,issues:e.issues.map(s=>ut(s,a,De()))})),t.issues.length&&(pi.has(typeof o)?n.issues.push(..._t(o,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:r,inst:i,key:o,issues:t.issues.map(s=>ut(s,a,De()))})),n.value.set(e.value,t.value)}const Qg=S("$ZodSet",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!(r instanceof Set))return n.issues.push({input:r,inst:e,expected:"set",code:"invalid_type"}),n;const i=[];n.value=new Set;for(const a of r){const s=t.valueType._zod.run({value:a,issues:[]},o);s instanceof Promise?i.push(s.then(l=>Fd(l,n))):Fd(s,n)}return i.length?Promise.all(i).then(()=>n):n}});function Fd(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const Xg=S("$ZodEnum",(e,t)=>{X.init(e,t);const n=Lu(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>pi.has(typeof r)).map(r=>typeof r=="string"?qt(r):r.toString()).join("|")})$`),e._zod.parse=(r,i)=>{const a=r.value;return o.has(a)||r.issues.push({code:"invalid_value",values:n,input:a,inst:e}),r}}),ev=S("$ZodLiteral",(e,t)=>{if(X.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?qt(o):o?qt(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,r)=>{const i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),tv=S("$ZodFile",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;return r instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:r,inst:e}),n}}),rv=S("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Bi(e.constructor.name);const r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(a=>(n.value=a,n));if(r instanceof Promise)throw new vr;return n.value=r,n}});function qd(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const nv=S("$ZodOptional",(e,t)=>{X.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ne(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ji(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>qd(i,n.value)):qd(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),ov=S("$ZodNullable",(e,t)=>{X.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ji(n.source)}|null)$`):void 0}),ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),iv=S("$ZodDefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>Vd(i,t)):Vd(r,t)}});function Vd(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const av=S("$ZodPrefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),sv=S("$ZodNonOptional",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>Bd(i,e)):Bd(r,e)}});function Bd(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const uv=S("$ZodSuccess",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Bi("ZodSuccess");const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>(n.value=i.issues.length===0,n)):(n.value=r.issues.length===0,n)}}),lv=S("$ZodCatch",(e,t)=>{X.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(a=>ut(a,o,De()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(i=>ut(i,o,De()))},input:n.value}),n.issues=[]),n)}}),cv=S("$ZodNaN",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),dv=S("$ZodPipe",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>t.in._zod.values),ne(e._zod,"optin",()=>t.in._zod.optin),ne(e._zod,"optout",()=>t.out._zod.optout),ne(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const i=t.out._zod.run(n,o);return i instanceof Promise?i.then(a=>Lo(a,t.in,o)):Lo(i,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(i=>Lo(i,t.out,o)):Lo(r,t.out,o)}});function Lo(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const ul=S("$ZodCodec",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>t.in._zod.values),ne(e._zod,"optin",()=>t.in._zod.optin),ne(e._zod,"optout",()=>t.out._zod.optout),ne(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if((o.direction||"forward")==="forward"){const i=t.in._zod.run(n,o);return i instanceof Promise?i.then(a=>Zo(a,t,o)):Zo(i,t,o)}else{const i=t.out._zod.run(n,o);return i instanceof Promise?i.then(a=>Zo(a,t,o)):Zo(i,t,o)}}});function Zo(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){const r=t.transform(e.value,e);return r instanceof Promise?r.then(i=>Fo(e,i,t.out,n)):Fo(e,r,t.out,n)}else{const r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(i=>Fo(e,i,t.in,n)):Fo(e,r,t.in,n)}}function Fo(e,t,n,o){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},o)}const pv=S("$ZodReadonly",(e,t)=>{X.init(e,t),ne(e._zod,"propValues",()=>t.innerType._zod.propValues),ne(e._zod,"values",()=>t.innerType._zod.values),ne(e._zod,"optin",()=>t.innerType?._zod?.optin),ne(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(Jd):Jd(r)}});function Jd(e){return e.value=Object.freeze(e.value),e}const fv=S("$ZodTemplateLiteral",(e,t)=>{X.init(e,t);const n=[];for(const o of t.parts)if(typeof o=="object"&&o!==null){if(!o._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);const r=o._zod.pattern instanceof RegExp?o._zod.pattern.source:o._zod.pattern;if(!r)throw new Error(`Invalid template literal part: ${o._zod.traits}`);const i=r.startsWith("^")?1:0,a=r.endsWith("$")?r.length-1:r.length;n.push(r.slice(i,a))}else if(o===null||Mm.has(typeof o))n.push(qt(`${o}`));else throw new Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(o,r)=>typeof o.value!="string"?(o.issues.push({input:o.value,inst:e,expected:"template_literal",code:"invalid_type"}),o):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(o.value)||o.issues.push({input:o.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),o)}),mv=S("$ZodFunction",(e,t)=>(X.init(e,t),e._def=t,e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return function(...o){const r=e._def.input?Ys(e._def.input,o):o,i=Reflect.apply(n,this,r);return e._def.output?Ys(e._def.output,i):i}},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return async function(...o){const r=e._def.input?await Qs(e._def.input,o):o,i=await Reflect.apply(n,this,r);return e._def.output?await Qs(e._def.output,i):i}},e._zod.parse=(n,o)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{const o=e.constructor;return Array.isArray(n[0])?new o({type:"function",input:new sl({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new o({type:"function",input:n[0],output:e._def.output})},e.output=n=>{const o=e.constructor;return new o({type:"function",input:e._def.input,output:n})},e)),hv=S("$ZodPromise",(e,t)=>{X.init(e,t),e._zod.parse=(n,o)=>Promise.resolve(n.value).then(r=>t.innerType._zod.run({value:r,issues:[]},o))}),gv=S("$ZodLazy",(e,t)=>{X.init(e,t),ne(e._zod,"innerType",()=>t.getter()),ne(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),ne(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),ne(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),ne(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,o)=>e._zod.innerType._zod.run(n,o)}),vv=S("$ZodCustom",(e,t)=>{Se.init(e,t),X.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then(i=>Wd(i,n,o,e));Wd(r,n,o,e)}});function Wd(e,t,n,o){if(!e){const r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push(Hr(r))}}const vk=()=>{const e={string:{unit:"حرف",verb:"أن يحوي"},file:{unit:"بايت",verb:"أن يحوي"},array:{unit:"عنصر",verb:"أن يحوي"},set:{unit:"عنصر",verb:"أن يحوي"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"مدخل",email:"بريد إلكتروني",url:"رابط",emoji:"إيموجي",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"تاريخ ووقت بمعيار ISO",date:"تاريخ بمعيار ISO",time:"وقت بمعيار ISO",duration:"مدة بمعيار ISO",ipv4:"عنوان IPv4",ipv6:"عنوان IPv6",cidrv4:"مدى عناوين بصيغة IPv4",cidrv6:"مدى عناوين بصيغة IPv6",base64:"نَص بترميز base64-encoded",base64url:"نَص بترميز base64url-encoded",json_string:"نَص على هيئة JSON",e164:"رقم هاتف بمعيار E.164",jwt:"JWT",template_literal:"مدخل"};return r=>{switch(r.code){case"invalid_type":return`مدخلات غير مقبولة: يفترض إدخال ${r.expected}، ولكن تم إدخال ${n(r.input)}`;case"invalid_value":return r.values.length===1?`مدخلات غير مقبولة: يفترض إدخال ${H(r.values[0])}`:`اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?` أكبر من اللازم: يفترض أن تكون ${r.origin??"القيمة"} ${i} ${r.maximum.toString()} ${a.unit??"عنصر"}`:`أكبر من اللازم: يفترض أن تكون ${r.origin??"القيمة"} ${i} ${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`أصغر من اللازم: يفترض لـ ${r.origin} أن يكون ${i} ${r.minimum.toString()} ${a.unit}`:`أصغر من اللازم: يفترض لـ ${r.origin} أن يكون ${i} ${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`نَص غير مقبول: يجب أن يبدأ بـ "${r.prefix}"`:i.format==="ends_with"?`نَص غير مقبول: يجب أن ينتهي بـ "${i.suffix}"`:i.format==="includes"?`نَص غير مقبول: يجب أن يتضمَّن "${i.includes}"`:i.format==="regex"?`نَص غير مقبول: يجب أن يطابق النمط ${i.pattern}`:`${o[i.format]??r.format} غير مقبول`}case"not_multiple_of":return`رقم غير مقبول: يجب أن يكون من مضاعفات ${r.divisor}`;case"unrecognized_keys":return`معرف${r.keys.length>1?"ات":""} غريب${r.keys.length>1?"ة":""}: ${j(r.keys,"، ")}`;case"invalid_key":return`معرف غير مقبول في ${r.origin}`;case"invalid_union":return"مدخل غير مقبول";case"invalid_element":return`مدخل غير مقبول في ${r.origin}`;default:return"مدخل غير مقبول"}}};function yk(){return{localeError:vk()}}const bk=()=>{const e={string:{unit:"simvol",verb:"olmalıdır"},file:{unit:"bayt",verb:"olmalıdır"},array:{unit:"element",verb:"olmalıdır"},set:{unit:"element",verb:"olmalıdır"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Yanlış dəyər: gözlənilən ${r.expected}, daxil olan ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Yanlış dəyər: gözlənilən ${H(r.values[0])}`:`Yanlış seçim: aşağıdakılardan biri olmalıdır: ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Çox böyük: gözlənilən ${r.origin??"dəyər"} ${i}${r.maximum.toString()} ${a.unit??"element"}`:`Çox böyük: gözlənilən ${r.origin??"dəyər"} ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Çox kiçik: gözlənilən ${r.origin} ${i}${r.minimum.toString()} ${a.unit}`:`Çox kiçik: gözlənilən ${r.origin} ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Yanlış mətn: "${i.prefix}" ilə başlamalıdır`:i.format==="ends_with"?`Yanlış mətn: "${i.suffix}" ilə bitməlidir`:i.format==="includes"?`Yanlış mətn: "${i.includes}" daxil olmalıdır`:i.format==="regex"?`Yanlış mətn: ${i.pattern} şablonuna uyğun olmalıdır`:`Yanlış ${o[i.format]??r.format}`}case"not_multiple_of":return`Yanlış ədəd: ${r.divisor} ilə bölünə bilən olmalıdır`;case"unrecognized_keys":return`Tanınmayan açar${r.keys.length>1?"lar":""}: ${j(r.keys,", ")}`;case"invalid_key":return`${r.origin} daxilində yanlış açar`;case"invalid_union":return"Yanlış dəyər";case"invalid_element":return`${r.origin} daxilində yanlış dəyər`;default:return"Yanlış dəyər"}}};function _k(){return{localeError:bk()}}function Hd(e,t,n,o){const r=Math.abs(e),i=r%10,a=r%100;return a>=11&&a<=19?o:i===1?t:i>=2&&i<=4?n:o}const wk=()=>{const e={string:{unit:{one:"сімвал",few:"сімвалы",many:"сімвалаў"},verb:"мець"},array:{unit:{one:"элемент",few:"элементы",many:"элементаў"},verb:"мець"},set:{unit:{one:"элемент",few:"элементы",many:"элементаў"},verb:"мець"},file:{unit:{one:"байт",few:"байты",many:"байтаў"},verb:"мець"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"лік";case"object":{if(Array.isArray(r))return"масіў";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"увод",email:"email адрас",url:"URL",emoji:"эмодзі",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO дата і час",date:"ISO дата",time:"ISO час",duration:"ISO працягласць",ipv4:"IPv4 адрас",ipv6:"IPv6 адрас",cidrv4:"IPv4 дыяпазон",cidrv6:"IPv6 дыяпазон",base64:"радок у фармаце base64",base64url:"радок у фармаце base64url",json_string:"JSON радок",e164:"нумар E.164",jwt:"JWT",template_literal:"увод"};return r=>{switch(r.code){case"invalid_type":return`Няправільны ўвод: чакаўся ${r.expected}, атрымана ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Няправільны ўвод: чакалася ${H(r.values[0])}`:`Няправільны варыянт: чакаўся адзін з ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);if(a){const s=Number(r.maximum),l=Hd(s,a.unit.one,a.unit.few,a.unit.many);return`Занадта вялікі: чакалася, што ${r.origin??"значэнне"} павінна ${a.verb} ${i}${r.maximum.toString()} ${l}`}return`Занадта вялікі: чакалася, што ${r.origin??"значэнне"} павінна быць ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);if(a){const s=Number(r.minimum),l=Hd(s,a.unit.one,a.unit.few,a.unit.many);return`Занадта малы: чакалася, што ${r.origin} павінна ${a.verb} ${i}${r.minimum.toString()} ${l}`}return`Занадта малы: чакалася, што ${r.origin} павінна быць ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Няправільны радок: павінен пачынацца з "${i.prefix}"`:i.format==="ends_with"?`Няправільны радок: павінен заканчвацца на "${i.suffix}"`:i.format==="includes"?`Няправільны радок: павінен змяшчаць "${i.includes}"`:i.format==="regex"?`Няправільны радок: павінен адпавядаць шаблону ${i.pattern}`:`Няправільны ${o[i.format]??r.format}`}case"not_multiple_of":return`Няправільны лік: павінен быць кратным ${r.divisor}`;case"unrecognized_keys":return`Нераспазнаны ${r.keys.length>1?"ключы":"ключ"}: ${j(r.keys,", ")}`;case"invalid_key":return`Няправільны ключ у ${r.origin}`;case"invalid_union":return"Няправільны ўвод";case"invalid_element":return`Няправільнае значэнне ў ${r.origin}`;default:return"Няправільны ўвод"}}};function xk(){return{localeError:wk()}}const $k=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"число";case"object":{if(Array.isArray(e))return"масив";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},Sk=()=>{const e={string:{unit:"символа",verb:"да съдържа"},file:{unit:"байта",verb:"да съдържа"},array:{unit:"елемента",verb:"да съдържа"},set:{unit:"елемента",verb:"да съдържа"}};function t(o){return e[o]??null}const n={regex:"вход",email:"имейл адрес",url:"URL",emoji:"емоджи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO време",date:"ISO дата",time:"ISO време",duration:"ISO продължителност",ipv4:"IPv4 адрес",ipv6:"IPv6 адрес",cidrv4:"IPv4 диапазон",cidrv6:"IPv6 диапазон",base64:"base64-кодиран низ",base64url:"base64url-кодиран низ",json_string:"JSON низ",e164:"E.164 номер",jwt:"JWT",template_literal:"вход"};return o=>{switch(o.code){case"invalid_type":return`Невалиден вход: очакван ${o.expected}, получен ${$k(o.input)}`;case"invalid_value":return o.values.length===1?`Невалиден вход: очакван ${H(o.values[0])}`:`Невалидна опция: очаквано едно от ${j(o.values,"|")}`;case"too_big":{const r=o.inclusive?"<=":"<",i=t(o.origin);return i?`Твърде голямо: очаква се ${o.origin??"стойност"} да съдържа ${r}${o.maximum.toString()} ${i.unit??"елемента"}`:`Твърде голямо: очаква се ${o.origin??"стойност"} да бъде ${r}${o.maximum.toString()}`}case"too_small":{const r=o.inclusive?">=":">",i=t(o.origin);return i?`Твърде малко: очаква се ${o.origin} да съдържа ${r}${o.minimum.toString()} ${i.unit}`:`Твърде малко: очаква се ${o.origin} да бъде ${r}${o.minimum.toString()}`}case"invalid_format":{const r=o;if(r.format==="starts_with")return`Невалиден низ: трябва да започва с "${r.prefix}"`;if(r.format==="ends_with")return`Невалиден низ: трябва да завършва с "${r.suffix}"`;if(r.format==="includes")return`Невалиден низ: трябва да включва "${r.includes}"`;if(r.format==="regex")return`Невалиден низ: трябва да съвпада с ${r.pattern}`;let i="Невалиден";return r.format==="emoji"&&(i="Невалидно"),r.format==="datetime"&&(i="Невалидно"),r.format==="date"&&(i="Невалидна"),r.format==="time"&&(i="Невалидно"),r.format==="duration"&&(i="Невалидна"),`${i} ${n[r.format]??o.format}`}case"not_multiple_of":return`Невалидно число: трябва да бъде кратно на ${o.divisor}`;case"unrecognized_keys":return`Неразпознат${o.keys.length>1?"и":""} ключ${o.keys.length>1?"ове":""}: ${j(o.keys,", ")}`;case"invalid_key":return`Невалиден ключ в ${o.origin}`;case"invalid_union":return"Невалиден вход";case"invalid_element":return`Невалидна стойност в ${o.origin}`;default:return"Невалиден вход"}}};function Ik(){return{localeError:Sk()}}const kk=()=>{const e={string:{unit:"caràcters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"entrada",email:"adreça electrònica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adreça IPv4",ipv6:"adreça IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"};return r=>{switch(r.code){case"invalid_type":return`Tipus invàlid: s'esperava ${r.expected}, s'ha rebut ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Valor invàlid: s'esperava ${H(r.values[0])}`:`Opció invàlida: s'esperava una de ${j(r.values," o ")}`;case"too_big":{const i=r.inclusive?"com a màxim":"menys de",a=t(r.origin);return a?`Massa gran: s'esperava que ${r.origin??"el valor"} contingués ${i} ${r.maximum.toString()} ${a.unit??"elements"}`:`Massa gran: s'esperava que ${r.origin??"el valor"} fos ${i} ${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?"com a mínim":"més de",a=t(r.origin);return a?`Massa petit: s'esperava que ${r.origin} contingués ${i} ${r.minimum.toString()} ${a.unit}`:`Massa petit: s'esperava que ${r.origin} fos ${i} ${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Format invàlid: ha de començar amb "${i.prefix}"`:i.format==="ends_with"?`Format invàlid: ha d'acabar amb "${i.suffix}"`:i.format==="includes"?`Format invàlid: ha d'incloure "${i.includes}"`:i.format==="regex"?`Format invàlid: ha de coincidir amb el patró ${i.pattern}`:`Format invàlid per a ${o[i.format]??r.format}`}case"not_multiple_of":return`Número invàlid: ha de ser múltiple de ${r.divisor}`;case"unrecognized_keys":return`Clau${r.keys.length>1?"s":""} no reconeguda${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Clau invàlida a ${r.origin}`;case"invalid_union":return"Entrada invàlida";case"invalid_element":return`Element invàlid a ${r.origin}`;default:return"Entrada invàlida"}}};function Ek(){return{localeError:kk()}}const Tk=()=>{const e={string:{unit:"znaků",verb:"mít"},file:{unit:"bajtů",verb:"mít"},array:{unit:"prvků",verb:"mít"},set:{unit:"prvků",verb:"mít"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"číslo";case"string":return"řetězec";case"boolean":return"boolean";case"bigint":return"bigint";case"function":return"funkce";case"symbol":return"symbol";case"undefined":return"undefined";case"object":{if(Array.isArray(r))return"pole";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"regulární výraz",email:"e-mailová adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a čas ve formátu ISO",date:"datum ve formátu ISO",time:"čas ve formátu ISO",duration:"doba trvání ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"řetězec zakódovaný ve formátu base64",base64url:"řetězec zakódovaný ve formátu base64url",json_string:"řetězec ve formátu JSON",e164:"číslo E.164",jwt:"JWT",template_literal:"vstup"};return r=>{switch(r.code){case"invalid_type":return`Neplatný vstup: očekáváno ${r.expected}, obdrženo ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Neplatný vstup: očekáváno ${H(r.values[0])}`:`Neplatná možnost: očekávána jedna z hodnot ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Hodnota je příliš velká: ${r.origin??"hodnota"} musí mít ${i}${r.maximum.toString()} ${a.unit??"prvků"}`:`Hodnota je příliš velká: ${r.origin??"hodnota"} musí být ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Hodnota je příliš malá: ${r.origin??"hodnota"} musí mít ${i}${r.minimum.toString()} ${a.unit??"prvků"}`:`Hodnota je příliš malá: ${r.origin??"hodnota"} musí být ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Neplatný řetězec: musí začínat na "${i.prefix}"`:i.format==="ends_with"?`Neplatný řetězec: musí končit na "${i.suffix}"`:i.format==="includes"?`Neplatný řetězec: musí obsahovat "${i.includes}"`:i.format==="regex"?`Neplatný řetězec: musí odpovídat vzoru ${i.pattern}`:`Neplatný formát ${o[i.format]??r.format}`}case"not_multiple_of":return`Neplatné číslo: musí být násobkem ${r.divisor}`;case"unrecognized_keys":return`Neznámé klíče: ${j(r.keys,", ")}`;case"invalid_key":return`Neplatný klíč v ${r.origin}`;case"invalid_union":return"Neplatný vstup";case"invalid_element":return`Neplatná hodnota v ${r.origin}`;default:return"Neplatný vstup"}}};function Ok(){return{localeError:Tk()}}const Nk=()=>{const e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}},t={string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"sæt",file:"fil"};function n(a){return e[a]??null}function o(a){return t[a]??a}const r=a=>{const s=typeof a;switch(s){case"number":return Number.isNaN(a)?"NaN":"tal";case"object":return Array.isArray(a)?"liste":a===null?"null":Object.getPrototypeOf(a)!==Object.prototype&&a.constructor?a.constructor.name:"objekt"}return s},i={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslæt",date:"ISO-dato",time:"ISO-klokkeslæt",duration:"ISO-varighed",ipv4:"IPv4-område",ipv6:"IPv6-område",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"};return a=>{switch(a.code){case"invalid_type":return`Ugyldigt input: forventede ${o(a.expected)}, fik ${o(r(a.input))}`;case"invalid_value":return a.values.length===1?`Ugyldig værdi: forventede ${H(a.values[0])}`:`Ugyldigt valg: forventede en af følgende ${j(a.values,"|")}`;case"too_big":{const s=a.inclusive?"<=":"<",l=n(a.origin),u=o(a.origin);return l?`For stor: forventede ${u??"value"} ${l.verb} ${s} ${a.maximum.toString()} ${l.unit??"elementer"}`:`For stor: forventede ${u??"value"} havde ${s} ${a.maximum.toString()}`}case"too_small":{const s=a.inclusive?">=":">",l=n(a.origin),u=o(a.origin);return l?`For lille: forventede ${u} ${l.verb} ${s} ${a.minimum.toString()} ${l.unit}`:`For lille: forventede ${u} havde ${s} ${a.minimum.toString()}`}case"invalid_format":{const s=a;return s.format==="starts_with"?`Ugyldig streng: skal starte med "${s.prefix}"`:s.format==="ends_with"?`Ugyldig streng: skal ende med "${s.suffix}"`:s.format==="includes"?`Ugyldig streng: skal indeholde "${s.includes}"`:s.format==="regex"?`Ugyldig streng: skal matche mønsteret ${s.pattern}`:`Ugyldig ${i[s.format]??a.format}`}case"not_multiple_of":return`Ugyldigt tal: skal være deleligt med ${a.divisor}`;case"unrecognized_keys":return`${a.keys.length>1?"Ukendte nøgler":"Ukendt nøgle"}: ${j(a.keys,", ")}`;case"invalid_key":return`Ugyldig nøgle i ${a.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig værdi i ${a.origin}`;default:return"Ugyldigt input"}}};function Pk(){return{localeError:Nk()}}const Ck=()=>{const e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"Zahl";case"object":{if(Array.isArray(r))return"Array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"};return r=>{switch(r.code){case"invalid_type":return`Ungültige Eingabe: erwartet ${r.expected}, erhalten ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ungültige Eingabe: erwartet ${H(r.values[0])}`:`Ungültige Option: erwartet eine von ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Zu groß: erwartet, dass ${r.origin??"Wert"} ${i}${r.maximum.toString()} ${a.unit??"Elemente"} hat`:`Zu groß: erwartet, dass ${r.origin??"Wert"} ${i}${r.maximum.toString()} ist`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Zu klein: erwartet, dass ${r.origin} ${i}${r.minimum.toString()} ${a.unit} hat`:`Zu klein: erwartet, dass ${r.origin} ${i}${r.minimum.toString()} ist`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Ungültiger String: muss mit "${i.prefix}" beginnen`:i.format==="ends_with"?`Ungültiger String: muss mit "${i.suffix}" enden`:i.format==="includes"?`Ungültiger String: muss "${i.includes}" enthalten`:i.format==="regex"?`Ungültiger String: muss dem Muster ${i.pattern} entsprechen`:`Ungültig: ${o[i.format]??r.format}`}case"not_multiple_of":return`Ungültige Zahl: muss ein Vielfaches von ${r.divisor} sein`;case"unrecognized_keys":return`${r.keys.length>1?"Unbekannte Schlüssel":"Unbekannter Schlüssel"}: ${j(r.keys,", ")}`;case"invalid_key":return`Ungültiger Schlüssel in ${r.origin}`;case"invalid_union":return"Ungültige Eingabe";case"invalid_element":return`Ungültiger Wert in ${r.origin}`;default:return"Ungültige Eingabe"}}};function jk(){return{localeError:Ck()}}const Ak=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},Rk=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(o){return e[o]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return o=>{switch(o.code){case"invalid_type":return`Invalid input: expected ${o.expected}, received ${Ak(o.input)}`;case"invalid_value":return o.values.length===1?`Invalid input: expected ${H(o.values[0])}`:`Invalid option: expected one of ${j(o.values,"|")}`;case"too_big":{const r=o.inclusive?"<=":"<",i=t(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${r}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${r}${o.maximum.toString()}`}case"too_small":{const r=o.inclusive?">=":">",i=t(o.origin);return i?`Too small: expected ${o.origin} to have ${r}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${r}${o.minimum.toString()}`}case"invalid_format":{const r=o;return r.format==="starts_with"?`Invalid string: must start with "${r.prefix}"`:r.format==="ends_with"?`Invalid string: must end with "${r.suffix}"`:r.format==="includes"?`Invalid string: must include "${r.includes}"`:r.format==="regex"?`Invalid string: must match pattern ${r.pattern}`:`Invalid ${n[r.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${j(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function yv(){return{localeError:Rk()}}const zk=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"nombro";case"object":{if(Array.isArray(e))return"tabelo";if(e===null)return"senvalora";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},Mk=()=>{const e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(o){return e[o]??null}const n={regex:"enigo",email:"retadreso",url:"URL",emoji:"emoĝio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-daŭro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"};return o=>{switch(o.code){case"invalid_type":return`Nevalida enigo: atendiĝis ${o.expected}, riceviĝis ${zk(o.input)}`;case"invalid_value":return o.values.length===1?`Nevalida enigo: atendiĝis ${H(o.values[0])}`:`Nevalida opcio: atendiĝis unu el ${j(o.values,"|")}`;case"too_big":{const r=o.inclusive?"<=":"<",i=t(o.origin);return i?`Tro granda: atendiĝis ke ${o.origin??"valoro"} havu ${r}${o.maximum.toString()} ${i.unit??"elementojn"}`:`Tro granda: atendiĝis ke ${o.origin??"valoro"} havu ${r}${o.maximum.toString()}`}case"too_small":{const r=o.inclusive?">=":">",i=t(o.origin);return i?`Tro malgranda: atendiĝis ke ${o.origin} havu ${r}${o.minimum.toString()} ${i.unit}`:`Tro malgranda: atendiĝis ke ${o.origin} estu ${r}${o.minimum.toString()}`}case"invalid_format":{const r=o;return r.format==="starts_with"?`Nevalida karaktraro: devas komenciĝi per "${r.prefix}"`:r.format==="ends_with"?`Nevalida karaktraro: devas finiĝi per "${r.suffix}"`:r.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${r.includes}"`:r.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${r.pattern}`:`Nevalida ${n[r.format]??o.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${o.divisor}`;case"unrecognized_keys":return`Nekonata${o.keys.length>1?"j":""} ŝlosilo${o.keys.length>1?"j":""}: ${j(o.keys,", ")}`;case"invalid_key":return`Nevalida ŝlosilo en ${o.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${o.origin}`;default:return"Nevalida enigo"}}};function Dk(){return{localeError:Mk()}}const Uk=()=>{const e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}},t={string:"texto",number:"número",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"número grande",symbol:"símbolo",undefined:"indefinido",null:"nulo",function:"función",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeración",union:"unión",literal:"literal",promise:"promesa",void:"vacío",never:"nunca",unknown:"desconocido",any:"cualquiera"};function n(a){return e[a]??null}function o(a){return t[a]??a}const r=a=>{const s=typeof a;switch(s){case"number":return Number.isNaN(a)?"NaN":"number";case"object":return Array.isArray(a)?"array":a===null?"null":Object.getPrototypeOf(a)!==Object.prototype?a.constructor.name:"object"}return s},i={regex:"entrada",email:"dirección de correo electrónico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duración ISO",ipv4:"dirección IPv4",ipv6:"dirección IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"};return a=>{switch(a.code){case"invalid_type":return`Entrada inválida: se esperaba ${o(a.expected)}, recibido ${o(r(a.input))}`;case"invalid_value":return a.values.length===1?`Entrada inválida: se esperaba ${H(a.values[0])}`:`Opción inválida: se esperaba una de ${j(a.values,"|")}`;case"too_big":{const s=a.inclusive?"<=":"<",l=n(a.origin),u=o(a.origin);return l?`Demasiado grande: se esperaba que ${u??"valor"} tuviera ${s}${a.maximum.toString()} ${l.unit??"elementos"}`:`Demasiado grande: se esperaba que ${u??"valor"} fuera ${s}${a.maximum.toString()}`}case"too_small":{const s=a.inclusive?">=":">",l=n(a.origin),u=o(a.origin);return l?`Demasiado pequeño: se esperaba que ${u} tuviera ${s}${a.minimum.toString()} ${l.unit}`:`Demasiado pequeño: se esperaba que ${u} fuera ${s}${a.minimum.toString()}`}case"invalid_format":{const s=a;return s.format==="starts_with"?`Cadena inválida: debe comenzar con "${s.prefix}"`:s.format==="ends_with"?`Cadena inválida: debe terminar en "${s.suffix}"`:s.format==="includes"?`Cadena inválida: debe incluir "${s.includes}"`:s.format==="regex"?`Cadena inválida: debe coincidir con el patrón ${s.pattern}`:`Inválido ${i[s.format]??a.format}`}case"not_multiple_of":return`Número inválido: debe ser múltiplo de ${a.divisor}`;case"unrecognized_keys":return`Llave${a.keys.length>1?"s":""} desconocida${a.keys.length>1?"s":""}: ${j(a.keys,", ")}`;case"invalid_key":return`Llave inválida en ${o(a.origin)}`;case"invalid_union":return"Entrada inválida";case"invalid_element":return`Valor inválido en ${o(a.origin)}`;default:return"Entrada inválida"}}};function Lk(){return{localeError:Uk()}}const Zk=()=>{const e={string:{unit:"کاراکتر",verb:"داشته باشد"},file:{unit:"بایت",verb:"داشته باشد"},array:{unit:"آیتم",verb:"داشته باشد"},set:{unit:"آیتم",verb:"داشته باشد"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"عدد";case"object":{if(Array.isArray(r))return"آرایه";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ورودی",email:"آدرس ایمیل",url:"URL",emoji:"ایموجی",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"تاریخ و زمان ایزو",date:"تاریخ ایزو",time:"زمان ایزو",duration:"مدت زمان ایزو",ipv4:"IPv4 آدرس",ipv6:"IPv6 آدرس",cidrv4:"IPv4 دامنه",cidrv6:"IPv6 دامنه",base64:"base64-encoded رشته",base64url:"base64url-encoded رشته",json_string:"JSON رشته",e164:"E.164 عدد",jwt:"JWT",template_literal:"ورودی"};return r=>{switch(r.code){case"invalid_type":return`ورودی نامعتبر: میبایست ${r.expected} میبود، ${n(r.input)} دریافت شد`;case"invalid_value":return r.values.length===1?`ورودی نامعتبر: میبایست ${H(r.values[0])} میبود`:`گزینه نامعتبر: میبایست یکی از ${j(r.values,"|")} میبود`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`خیلی بزرگ: ${r.origin??"مقدار"} باید ${i}${r.maximum.toString()} ${a.unit??"عنصر"} باشد`:`خیلی بزرگ: ${r.origin??"مقدار"} باید ${i}${r.maximum.toString()} باشد`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`خیلی کوچک: ${r.origin} باید ${i}${r.minimum.toString()} ${a.unit} باشد`:`خیلی کوچک: ${r.origin} باید ${i}${r.minimum.toString()} باشد`}case"invalid_format":{const i=r;return i.format==="starts_with"?`رشته نامعتبر: باید با "${i.prefix}" شروع شود`:i.format==="ends_with"?`رشته نامعتبر: باید با "${i.suffix}" تمام شود`:i.format==="includes"?`رشته نامعتبر: باید شامل "${i.includes}" باشد`:i.format==="regex"?`رشته نامعتبر: باید با الگوی ${i.pattern} مطابقت داشته باشد`:`${o[i.format]??r.format} نامعتبر`}case"not_multiple_of":return`عدد نامعتبر: باید مضرب ${r.divisor} باشد`;case"unrecognized_keys":return`کلید${r.keys.length>1?"های":""} ناشناس: ${j(r.keys,", ")}`;case"invalid_key":return`کلید ناشناس در ${r.origin}`;case"invalid_union":return"ورودی نامعتبر";case"invalid_element":return`مقدار نامعتبر در ${r.origin}`;default:return"ورودی نامعتبر"}}};function Fk(){return{localeError:Zk()}}const qk=()=>{const e={string:{unit:"merkkiä",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"päivämäärän"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"säännöllinen lauseke",email:"sähköpostiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-päivämäärä",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"};return r=>{switch(r.code){case"invalid_type":return`Virheellinen tyyppi: odotettiin ${r.expected}, oli ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Virheellinen syöte: täytyy olla ${H(r.values[0])}`:`Virheellinen valinta: täytyy olla yksi seuraavista: ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Liian suuri: ${a.subject} täytyy olla ${i}${r.maximum.toString()} ${a.unit}`.trim():`Liian suuri: arvon täytyy olla ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Liian pieni: ${a.subject} täytyy olla ${i}${r.minimum.toString()} ${a.unit}`.trim():`Liian pieni: arvon täytyy olla ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Virheellinen syöte: täytyy alkaa "${i.prefix}"`:i.format==="ends_with"?`Virheellinen syöte: täytyy loppua "${i.suffix}"`:i.format==="includes"?`Virheellinen syöte: täytyy sisältää "${i.includes}"`:i.format==="regex"?`Virheellinen syöte: täytyy vastata säännöllistä lauseketta ${i.pattern}`:`Virheellinen ${o[i.format]??r.format}`}case"not_multiple_of":return`Virheellinen luku: täytyy olla luvun ${r.divisor} monikerta`;case"unrecognized_keys":return`${r.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${j(r.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen syöte"}}};function Vk(){return{localeError:qk()}}const Bk=()=>{const e={string:{unit:"caractères",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"éléments",verb:"avoir"},set:{unit:"éléments",verb:"avoir"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"nombre";case"object":{if(Array.isArray(r))return"tableau";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"entrée",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"durée ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"chaîne encodée en base64",base64url:"chaîne encodée en base64url",json_string:"chaîne JSON",e164:"numéro E.164",jwt:"JWT",template_literal:"entrée"};return r=>{switch(r.code){case"invalid_type":return`Entrée invalide : ${r.expected} attendu, ${n(r.input)} reçu`;case"invalid_value":return r.values.length===1?`Entrée invalide : ${H(r.values[0])} attendu`:`Option invalide : une valeur parmi ${j(r.values,"|")} attendue`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Trop grand : ${r.origin??"valeur"} doit ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"élément(s)"}`:`Trop grand : ${r.origin??"valeur"} doit être ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Trop petit : ${r.origin} doit ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Trop petit : ${r.origin} doit être ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Chaîne invalide : doit commencer par "${i.prefix}"`:i.format==="ends_with"?`Chaîne invalide : doit se terminer par "${i.suffix}"`:i.format==="includes"?`Chaîne invalide : doit inclure "${i.includes}"`:i.format==="regex"?`Chaîne invalide : doit correspondre au modèle ${i.pattern}`:`${o[i.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit être un multiple de ${r.divisor}`;case"unrecognized_keys":return`Clé${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${j(r.keys,", ")}`;case"invalid_key":return`Clé invalide dans ${r.origin}`;case"invalid_union":return"Entrée invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entrée invalide"}}};function Jk(){return{localeError:Bk()}}const Wk=()=>{const e={string:{unit:"caractères",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"éléments",verb:"avoir"},set:{unit:"éléments",verb:"avoir"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"entrée",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"durée ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"chaîne encodée en base64",base64url:"chaîne encodée en base64url",json_string:"chaîne JSON",e164:"numéro E.164",jwt:"JWT",template_literal:"entrée"};return r=>{switch(r.code){case"invalid_type":return`Entrée invalide : attendu ${r.expected}, reçu ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Entrée invalide : attendu ${H(r.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"≤":"<",a=t(r.origin);return a?`Trop grand : attendu que ${r.origin??"la valeur"} ait ${i}${r.maximum.toString()} ${a.unit}`:`Trop grand : attendu que ${r.origin??"la valeur"} soit ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?"≥":">",a=t(r.origin);return a?`Trop petit : attendu que ${r.origin} ait ${i}${r.minimum.toString()} ${a.unit}`:`Trop petit : attendu que ${r.origin} soit ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Chaîne invalide : doit commencer par "${i.prefix}"`:i.format==="ends_with"?`Chaîne invalide : doit se terminer par "${i.suffix}"`:i.format==="includes"?`Chaîne invalide : doit inclure "${i.includes}"`:i.format==="regex"?`Chaîne invalide : doit correspondre au motif ${i.pattern}`:`${o[i.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit être un multiple de ${r.divisor}`;case"unrecognized_keys":return`Clé${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${j(r.keys,", ")}`;case"invalid_key":return`Clé invalide dans ${r.origin}`;case"invalid_union":return"Entrée invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entrée invalide"}}};function Hk(){return{localeError:Wk()}}const Gk=()=>{const e={string:{label:"מחרוזת",gender:"f"},number:{label:"מספר",gender:"m"},boolean:{label:"ערך בוליאני",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"תאריך",gender:"m"},array:{label:"מערך",gender:"m"},object:{label:"אובייקט",gender:"m"},null:{label:"ערך ריק (null)",gender:"m"},undefined:{label:"ערך לא מוגדר (undefined)",gender:"m"},symbol:{label:"סימבול (Symbol)",gender:"m"},function:{label:"פונקציה",gender:"f"},map:{label:"מפה (Map)",gender:"f"},set:{label:"קבוצה (Set)",gender:"f"},file:{label:"קובץ",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"ערך לא ידוע",gender:"m"},value:{label:"ערך",gender:"m"}},t={string:{unit:"תווים",shortLabel:"קצר",longLabel:"ארוך"},file:{unit:"בייטים",shortLabel:"קטן",longLabel:"גדול"},array:{unit:"פריטים",shortLabel:"קטן",longLabel:"גדול"},set:{unit:"פריטים",shortLabel:"קטן",longLabel:"גדול"},number:{unit:"",shortLabel:"קטן",longLabel:"גדול"}},n=u=>u?e[u]:void 0,o=u=>{const c=n(u);return c?c.label:u??e.unknown.label},r=u=>`ה${o(u)}`,i=u=>(n(u)?.gender??"m")==="f"?"צריכה להיות":"צריך להיות",a=u=>u?t[u]??null:null,s=u=>{const c=typeof u;switch(c){case"number":return Number.isNaN(u)?"NaN":"number";case"object":return Array.isArray(u)?"array":u===null?"null":Object.getPrototypeOf(u)!==Object.prototype&&u.constructor?u.constructor.name:"object";default:return c}},l={regex:{label:"קלט",gender:"m"},email:{label:"כתובת אימייל",gender:"f"},url:{label:"כתובת רשת",gender:"f"},emoji:{label:"אימוג'י",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"תאריך וזמן ISO",gender:"m"},date:{label:"תאריך ISO",gender:"m"},time:{label:"זמן ISO",gender:"m"},duration:{label:"משך זמן ISO",gender:"m"},ipv4:{label:"כתובת IPv4",gender:"f"},ipv6:{label:"כתובת IPv6",gender:"f"},cidrv4:{label:"טווח IPv4",gender:"m"},cidrv6:{label:"טווח IPv6",gender:"m"},base64:{label:"מחרוזת בבסיס 64",gender:"f"},base64url:{label:"מחרוזת בבסיס 64 לכתובות רשת",gender:"f"},json_string:{label:"מחרוזת JSON",gender:"f"},e164:{label:"מספר E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"קלט",gender:"m"},includes:{label:"קלט",gender:"m"},lowercase:{label:"קלט",gender:"m"},starts_with:{label:"קלט",gender:"m"},uppercase:{label:"קלט",gender:"m"}};return u=>{switch(u.code){case"invalid_type":{const c=u.expected,d=o(c),f=s(u.input),p=e[f]?.label??f;return`קלט לא תקין: צריך להיות ${d}, התקבל ${p}`}case"invalid_value":{if(u.values.length===1)return`ערך לא תקין: הערך חייב להיות ${H(u.values[0])}`;const c=u.values.map(p=>H(p));if(u.values.length===2)return`ערך לא תקין: האפשרויות המתאימות הן ${c[0]} או ${c[1]}`;const d=c[c.length-1];return`ערך לא תקין: האפשרויות המתאימות הן ${c.slice(0,-1).join(", ")} או ${d}`}case"too_big":{const c=a(u.origin),d=r(u.origin??"value");if(u.origin==="string")return`${c?.longLabel??"ארוך"} מדי: ${d} צריכה להכיל ${u.maximum.toString()} ${c?.unit??""} ${u.inclusive?"או פחות":"לכל היותר"}`.trim();if(u.origin==="number"){const g=u.inclusive?`קטן או שווה ל-${u.maximum}`:`קטן מ-${u.maximum}`;return`גדול מדי: ${d} צריך להיות ${g}`}if(u.origin==="array"||u.origin==="set"){const g=u.origin==="set"?"צריכה":"צריך",h=u.inclusive?`${u.maximum} ${c?.unit??""} או פחות`:`פחות מ-${u.maximum} ${c?.unit??""}`;return`גדול מדי: ${d} ${g} להכיל ${h}`.trim()}const f=u.inclusive?"<=":"<",p=i(u.origin??"value");return c?.unit?`${c.longLabel} מדי: ${d} ${p} ${f}${u.maximum.toString()} ${c.unit}`:`${c?.longLabel??"גדול"} מדי: ${d} ${p} ${f}${u.maximum.toString()}`}case"too_small":{const c=a(u.origin),d=r(u.origin??"value");if(u.origin==="string")return`${c?.shortLabel??"קצר"} מדי: ${d} צריכה להכיל ${u.minimum.toString()} ${c?.unit??""} ${u.inclusive?"או יותר":"לפחות"}`.trim();if(u.origin==="number"){const g=u.inclusive?`גדול או שווה ל-${u.minimum}`:`גדול מ-${u.minimum}`;return`קטן מדי: ${d} צריך להיות ${g}`}if(u.origin==="array"||u.origin==="set"){const g=u.origin==="set"?"צריכה":"צריך";if(u.minimum===1&&u.inclusive){const b=(u.origin==="set","לפחות פריט אחד");return`קטן מדי: ${d} ${g} להכיל ${b}`}const h=u.inclusive?`${u.minimum} ${c?.unit??""} או יותר`:`יותר מ-${u.minimum} ${c?.unit??""}`;return`קטן מדי: ${d} ${g} להכיל ${h}`.trim()}const f=u.inclusive?">=":">",p=i(u.origin??"value");return c?.unit?`${c.shortLabel} מדי: ${d} ${p} ${f}${u.minimum.toString()} ${c.unit}`:`${c?.shortLabel??"קטן"} מדי: ${d} ${p} ${f}${u.minimum.toString()}`}case"invalid_format":{const c=u;if(c.format==="starts_with")return`המחרוזת חייבת להתחיל ב "${c.prefix}"`;if(c.format==="ends_with")return`המחרוזת חייבת להסתיים ב "${c.suffix}"`;if(c.format==="includes")return`המחרוזת חייבת לכלול "${c.includes}"`;if(c.format==="regex")return`המחרוזת חייבת להתאים לתבנית ${c.pattern}`;const d=l[c.format],f=d?.label??c.format,g=(d?.gender??"m")==="f"?"תקינה":"תקין";return`${f} לא ${g}`}case"not_multiple_of":return`מספר לא תקין: חייב להיות מכפלה של ${u.divisor}`;case"unrecognized_keys":return`מפתח${u.keys.length>1?"ות":""} לא מזוה${u.keys.length>1?"ים":"ה"}: ${j(u.keys,", ")}`;case"invalid_key":return"שדה לא תקין באובייקט";case"invalid_union":return"קלט לא תקין";case"invalid_element":return`ערך לא תקין ב${r(u.origin??"array")}`;default:return"קלט לא תקין"}}};function Kk(){return{localeError:Gk()}}const Yk=()=>{const e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"szám";case"object":{if(Array.isArray(r))return"tömb";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"bemenet",email:"email cím",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO időbélyeg",date:"ISO dátum",time:"ISO idő",duration:"ISO időintervallum",ipv4:"IPv4 cím",ipv6:"IPv6 cím",cidrv4:"IPv4 tartomány",cidrv6:"IPv6 tartomány",base64:"base64-kódolt string",base64url:"base64url-kódolt string",json_string:"JSON string",e164:"E.164 szám",jwt:"JWT",template_literal:"bemenet"};return r=>{switch(r.code){case"invalid_type":return`Érvénytelen bemenet: a várt érték ${r.expected}, a kapott érték ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Érvénytelen bemenet: a várt érték ${H(r.values[0])}`:`Érvénytelen opció: valamelyik érték várt ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Túl nagy: ${r.origin??"érték"} mérete túl nagy ${i}${r.maximum.toString()} ${a.unit??"elem"}`:`Túl nagy: a bemeneti érték ${r.origin??"érték"} túl nagy: ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Túl kicsi: a bemeneti érték ${r.origin} mérete túl kicsi ${i}${r.minimum.toString()} ${a.unit}`:`Túl kicsi: a bemeneti érték ${r.origin} túl kicsi ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Érvénytelen string: "${i.prefix}" értékkel kell kezdődnie`:i.format==="ends_with"?`Érvénytelen string: "${i.suffix}" értékkel kell végződnie`:i.format==="includes"?`Érvénytelen string: "${i.includes}" értéket kell tartalmaznia`:i.format==="regex"?`Érvénytelen string: ${i.pattern} mintának kell megfelelnie`:`Érvénytelen ${o[i.format]??r.format}`}case"not_multiple_of":return`Érvénytelen szám: ${r.divisor} többszörösének kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Érvénytelen kulcs ${r.origin}`;case"invalid_union":return"Érvénytelen bemenet";case"invalid_element":return`Érvénytelen érték: ${r.origin}`;default:return"Érvénytelen bemenet"}}};function Qk(){return{localeError:Yk()}}const Xk=()=>{const e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Input tidak valid: diharapkan ${r.expected}, diterima ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Input tidak valid: diharapkan ${H(r.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Terlalu besar: diharapkan ${r.origin??"value"} memiliki ${i}${r.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: diharapkan ${r.origin??"value"} menjadi ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Terlalu kecil: diharapkan ${r.origin} memiliki ${i}${r.minimum.toString()} ${a.unit}`:`Terlalu kecil: diharapkan ${r.origin} menjadi ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`String tidak valid: harus dimulai dengan "${i.prefix}"`:i.format==="ends_with"?`String tidak valid: harus berakhir dengan "${i.suffix}"`:i.format==="includes"?`String tidak valid: harus menyertakan "${i.includes}"`:i.format==="regex"?`String tidak valid: harus sesuai pola ${i.pattern}`:`${o[i.format]??r.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${r.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${r.origin}`;default:return"Input tidak valid"}}};function eE(){return{localeError:Xk()}}const tE=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"númer";case"object":{if(Array.isArray(e))return"fylki";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},rE=()=>{const e={string:{unit:"stafi",verb:"að hafa"},file:{unit:"bæti",verb:"að hafa"},array:{unit:"hluti",verb:"að hafa"},set:{unit:"hluti",verb:"að hafa"}};function t(o){return e[o]??null}const n={regex:"gildi",email:"netfang",url:"vefslóð",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og tími",date:"ISO dagsetning",time:"ISO tími",duration:"ISO tímalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 tölugildi",jwt:"JWT",template_literal:"gildi"};return o=>{switch(o.code){case"invalid_type":return`Rangt gildi: Þú slóst inn ${tE(o.input)} þar sem á að vera ${o.expected}`;case"invalid_value":return o.values.length===1?`Rangt gildi: gert ráð fyrir ${H(o.values[0])}`:`Ógilt val: má vera eitt af eftirfarandi ${j(o.values,"|")}`;case"too_big":{const r=o.inclusive?"<=":"<",i=t(o.origin);return i?`Of stórt: gert er ráð fyrir að ${o.origin??"gildi"} hafi ${r}${o.maximum.toString()} ${i.unit??"hluti"}`:`Of stórt: gert er ráð fyrir að ${o.origin??"gildi"} sé ${r}${o.maximum.toString()}`}case"too_small":{const r=o.inclusive?">=":">",i=t(o.origin);return i?`Of lítið: gert er ráð fyrir að ${o.origin} hafi ${r}${o.minimum.toString()} ${i.unit}`:`Of lítið: gert er ráð fyrir að ${o.origin} sé ${r}${o.minimum.toString()}`}case"invalid_format":{const r=o;return r.format==="starts_with"?`Ógildur strengur: verður að byrja á "${r.prefix}"`:r.format==="ends_with"?`Ógildur strengur: verður að enda á "${r.suffix}"`:r.format==="includes"?`Ógildur strengur: verður að innihalda "${r.includes}"`:r.format==="regex"?`Ógildur strengur: verður að fylgja mynstri ${r.pattern}`:`Rangt ${n[r.format]??o.format}`}case"not_multiple_of":return`Röng tala: verður að vera margfeldi af ${o.divisor}`;case"unrecognized_keys":return`Óþekkt ${o.keys.length>1?"ir lyklar":"ur lykill"}: ${j(o.keys,", ")}`;case"invalid_key":return`Rangur lykill í ${o.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi í ${o.origin}`;default:return"Rangt gildi"}}};function nE(){return{localeError:rE()}}const oE=()=>{const e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"numero";case"object":{if(Array.isArray(r))return"vettore";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Input non valido: atteso ${r.expected}, ricevuto ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Input non valido: atteso ${H(r.values[0])}`:`Opzione non valida: atteso uno tra ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Troppo grande: ${r.origin??"valore"} deve avere ${i}${r.maximum.toString()} ${a.unit??"elementi"}`:`Troppo grande: ${r.origin??"valore"} deve essere ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Troppo piccolo: ${r.origin} deve avere ${i}${r.minimum.toString()} ${a.unit}`:`Troppo piccolo: ${r.origin} deve essere ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Stringa non valida: deve iniziare con "${i.prefix}"`:i.format==="ends_with"?`Stringa non valida: deve terminare con "${i.suffix}"`:i.format==="includes"?`Stringa non valida: deve includere "${i.includes}"`:i.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${i.pattern}`:`Invalid ${o[i.format]??r.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${r.divisor}`;case"unrecognized_keys":return`Chiav${r.keys.length>1?"i":"e"} non riconosciut${r.keys.length>1?"e":"a"}: ${j(r.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${r.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${r.origin}`;default:return"Input non valido"}}};function iE(){return{localeError:oE()}}const aE=()=>{const e={string:{unit:"文字",verb:"である"},file:{unit:"バイト",verb:"である"},array:{unit:"要素",verb:"である"},set:{unit:"要素",verb:"である"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"数値";case"object":{if(Array.isArray(r))return"配列";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"入力値",email:"メールアドレス",url:"URL",emoji:"絵文字",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO日時",date:"ISO日付",time:"ISO時刻",duration:"ISO期間",ipv4:"IPv4アドレス",ipv6:"IPv6アドレス",cidrv4:"IPv4範囲",cidrv6:"IPv6範囲",base64:"base64エンコード文字列",base64url:"base64urlエンコード文字列",json_string:"JSON文字列",e164:"E.164番号",jwt:"JWT",template_literal:"入力値"};return r=>{switch(r.code){case"invalid_type":return`無効な入力: ${r.expected}が期待されましたが、${n(r.input)}が入力されました`;case"invalid_value":return r.values.length===1?`無効な入力: ${H(r.values[0])}が期待されました`:`無効な選択: ${j(r.values,"、")}のいずれかである必要があります`;case"too_big":{const i=r.inclusive?"以下である":"より小さい",a=t(r.origin);return a?`大きすぎる値: ${r.origin??"値"}は${r.maximum.toString()}${a.unit??"要素"}${i}必要があります`:`大きすぎる値: ${r.origin??"値"}は${r.maximum.toString()}${i}必要があります`}case"too_small":{const i=r.inclusive?"以上である":"より大きい",a=t(r.origin);return a?`小さすぎる値: ${r.origin}は${r.minimum.toString()}${a.unit}${i}必要があります`:`小さすぎる値: ${r.origin}は${r.minimum.toString()}${i}必要があります`}case"invalid_format":{const i=r;return i.format==="starts_with"?`無効な文字列: "${i.prefix}"で始まる必要があります`:i.format==="ends_with"?`無効な文字列: "${i.suffix}"で終わる必要があります`:i.format==="includes"?`無効な文字列: "${i.includes}"を含む必要があります`:i.format==="regex"?`無効な文字列: パターン${i.pattern}に一致する必要があります`:`無効な${o[i.format]??r.format}`}case"not_multiple_of":return`無効な数値: ${r.divisor}の倍数である必要があります`;case"unrecognized_keys":return`認識されていないキー${r.keys.length>1?"群":""}: ${j(r.keys,"、")}`;case"invalid_key":return`${r.origin}内の無効なキー`;case"invalid_union":return"無効な入力";case"invalid_element":return`${r.origin}内の無効な値`;default:return"無効な入力"}}};function sE(){return{localeError:aE()}}const uE=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"რიცხვი";case"object":{if(Array.isArray(e))return"მასივი";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return{string:"სტრინგი",boolean:"ბულეანი",undefined:"undefined",bigint:"bigint",symbol:"symbol",function:"ფუნქცია"}[t]??t},lE=()=>{const e={string:{unit:"სიმბოლო",verb:"უნდა შეიცავდეს"},file:{unit:"ბაიტი",verb:"უნდა შეიცავდეს"},array:{unit:"ელემენტი",verb:"უნდა შეიცავდეს"},set:{unit:"ელემენტი",verb:"უნდა შეიცავდეს"}};function t(o){return e[o]??null}const n={regex:"შეყვანა",email:"ელ-ფოსტის მისამართი",url:"URL",emoji:"ემოჯი",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"თარიღი-დრო",date:"თარიღი",time:"დრო",duration:"ხანგრძლივობა",ipv4:"IPv4 მისამართი",ipv6:"IPv6 მისამართი",cidrv4:"IPv4 დიაპაზონი",cidrv6:"IPv6 დიაპაზონი",base64:"base64-კოდირებული სტრინგი",base64url:"base64url-კოდირებული სტრინგი",json_string:"JSON სტრინგი",e164:"E.164 ნომერი",jwt:"JWT",template_literal:"შეყვანა"};return o=>{switch(o.code){case"invalid_type":return`არასწორი შეყვანა: მოსალოდნელი ${o.expected}, მიღებული ${uE(o.input)}`;case"invalid_value":return o.values.length===1?`არასწორი შეყვანა: მოსალოდნელი ${H(o.values[0])}`:`არასწორი ვარიანტი: მოსალოდნელია ერთ-ერთი ${j(o.values,"|")}-დან`;case"too_big":{const r=o.inclusive?"<=":"<",i=t(o.origin);return i?`ზედმეტად დიდი: მოსალოდნელი ${o.origin??"მნიშვნელობა"} ${i.verb} ${r}${o.maximum.toString()} ${i.unit}`:`ზედმეტად დიდი: მოსალოდნელი ${o.origin??"მნიშვნელობა"} იყოს ${r}${o.maximum.toString()}`}case"too_small":{const r=o.inclusive?">=":">",i=t(o.origin);return i?`ზედმეტად პატარა: მოსალოდნელი ${o.origin} ${i.verb} ${r}${o.minimum.toString()} ${i.unit}`:`ზედმეტად პატარა: მოსალოდნელი ${o.origin} იყოს ${r}${o.minimum.toString()}`}case"invalid_format":{const r=o;return r.format==="starts_with"?`არასწორი სტრინგი: უნდა იწყებოდეს "${r.prefix}"-ით`:r.format==="ends_with"?`არასწორი სტრინგი: უნდა მთავრდებოდეს "${r.suffix}"-ით`:r.format==="includes"?`არასწორი სტრინგი: უნდა შეიცავდეს "${r.includes}"-ს`:r.format==="regex"?`არასწორი სტრინგი: უნდა შეესაბამებოდეს შაბლონს ${r.pattern}`:`არასწორი ${n[r.format]??o.format}`}case"not_multiple_of":return`არასწორი რიცხვი: უნდა იყოს ${o.divisor}-ის ჯერადი`;case"unrecognized_keys":return`უცნობი გასაღებ${o.keys.length>1?"ები":"ი"}: ${j(o.keys,", ")}`;case"invalid_key":return`არასწორი გასაღები ${o.origin}-ში`;case"invalid_union":return"არასწორი შეყვანა";case"invalid_element":return`არასწორი მნიშვნელობა ${o.origin}-ში`;default:return"არასწორი შეყვანა"}}};function cE(){return{localeError:lE()}}const dE=()=>{const e={string:{unit:"តួអក្សរ",verb:"គួរមាន"},file:{unit:"បៃ",verb:"គួរមាន"},array:{unit:"ធាតុ",verb:"គួរមាន"},set:{unit:"ធាតុ",verb:"គួរមាន"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"មិនមែនជាលេខ (NaN)":"លេខ";case"object":{if(Array.isArray(r))return"អារេ (Array)";if(r===null)return"គ្មានតម្លៃ (null)";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ទិន្នន័យបញ្ចូល",email:"អាសយដ្ឋានអ៊ីមែល",url:"URL",emoji:"សញ្ញាអារម្មណ៍",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"កាលបរិច្ឆេទ និងម៉ោង ISO",date:"កាលបរិច្ឆេទ ISO",time:"ម៉ោង ISO",duration:"រយៈពេល ISO",ipv4:"អាសយដ្ឋាន IPv4",ipv6:"អាសយដ្ឋាន IPv6",cidrv4:"ដែនអាសយដ្ឋាន IPv4",cidrv6:"ដែនអាសយដ្ឋាន IPv6",base64:"ខ្សែអក្សរអ៊ិកូដ base64",base64url:"ខ្សែអក្សរអ៊ិកូដ base64url",json_string:"ខ្សែអក្សរ JSON",e164:"លេខ E.164",jwt:"JWT",template_literal:"ទិន្នន័យបញ្ចូល"};return r=>{switch(r.code){case"invalid_type":return`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${r.expected} ប៉ុន្តែទទួលបាន ${n(r.input)}`;case"invalid_value":return r.values.length===1?`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${H(r.values[0])}`:`ជម្រើសមិនត្រឹមត្រូវ៖ ត្រូវជាមួយក្នុងចំណោម ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`ធំពេក៖ ត្រូវការ ${r.origin??"តម្លៃ"} ${i} ${r.maximum.toString()} ${a.unit??"ធាតុ"}`:`ធំពេក៖ ត្រូវការ ${r.origin??"តម្លៃ"} ${i} ${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`តូចពេក៖ ត្រូវការ ${r.origin} ${i} ${r.minimum.toString()} ${a.unit}`:`តូចពេក៖ ត្រូវការ ${r.origin} ${i} ${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវចាប់ផ្តើមដោយ "${i.prefix}"`:i.format==="ends_with"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវបញ្ចប់ដោយ "${i.suffix}"`:i.format==="includes"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវមាន "${i.includes}"`:i.format==="regex"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវតែផ្គូផ្គងនឹងទម្រង់ដែលបានកំណត់ ${i.pattern}`:`មិនត្រឹមត្រូវ៖ ${o[i.format]??r.format}`}case"not_multiple_of":return`លេខមិនត្រឹមត្រូវ៖ ត្រូវតែជាពហុគុណនៃ ${r.divisor}`;case"unrecognized_keys":return`រកឃើញសោមិនស្គាល់៖ ${j(r.keys,", ")}`;case"invalid_key":return`សោមិនត្រឹមត្រូវនៅក្នុង ${r.origin}`;case"invalid_union":return"ទិន្នន័យមិនត្រឹមត្រូវ";case"invalid_element":return`ទិន្នន័យមិនត្រឹមត្រូវនៅក្នុង ${r.origin}`;default:return"ទិន្នន័យមិនត្រឹមត្រូវ"}}};function bv(){return{localeError:dE()}}function pE(){return bv()}const fE=()=>{const e={string:{unit:"문자",verb:"to have"},file:{unit:"바이트",verb:"to have"},array:{unit:"개",verb:"to have"},set:{unit:"개",verb:"to have"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"입력",email:"이메일 주소",url:"URL",emoji:"이모지",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO 날짜시간",date:"ISO 날짜",time:"ISO 시간",duration:"ISO 기간",ipv4:"IPv4 주소",ipv6:"IPv6 주소",cidrv4:"IPv4 범위",cidrv6:"IPv6 범위",base64:"base64 인코딩 문자열",base64url:"base64url 인코딩 문자열",json_string:"JSON 문자열",e164:"E.164 번호",jwt:"JWT",template_literal:"입력"};return r=>{switch(r.code){case"invalid_type":return`잘못된 입력: 예상 타입은 ${r.expected}, 받은 타입은 ${n(r.input)}입니다`;case"invalid_value":return r.values.length===1?`잘못된 입력: 값은 ${H(r.values[0])} 이어야 합니다`:`잘못된 옵션: ${j(r.values,"또는 ")} 중 하나여야 합니다`;case"too_big":{const i=r.inclusive?"이하":"미만",a=i==="미만"?"이어야 합니다":"여야 합니다",s=t(r.origin),l=s?.unit??"요소";return s?`${r.origin??"값"}이 너무 큽니다: ${r.maximum.toString()}${l} ${i}${a}`:`${r.origin??"값"}이 너무 큽니다: ${r.maximum.toString()} ${i}${a}`}case"too_small":{const i=r.inclusive?"이상":"초과",a=i==="이상"?"이어야 합니다":"여야 합니다",s=t(r.origin),l=s?.unit??"요소";return s?`${r.origin??"값"}이 너무 작습니다: ${r.minimum.toString()}${l} ${i}${a}`:`${r.origin??"값"}이 너무 작습니다: ${r.minimum.toString()} ${i}${a}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`잘못된 문자열: "${i.prefix}"(으)로 시작해야 합니다`:i.format==="ends_with"?`잘못된 문자열: "${i.suffix}"(으)로 끝나야 합니다`:i.format==="includes"?`잘못된 문자열: "${i.includes}"을(를) 포함해야 합니다`:i.format==="regex"?`잘못된 문자열: 정규식 ${i.pattern} 패턴과 일치해야 합니다`:`잘못된 ${o[i.format]??r.format}`}case"not_multiple_of":return`잘못된 숫자: ${r.divisor}의 배수여야 합니다`;case"unrecognized_keys":return`인식할 수 없는 키: ${j(r.keys,", ")}`;case"invalid_key":return`잘못된 키: ${r.origin}`;case"invalid_union":return"잘못된 입력";case"invalid_element":return`잘못된 값: ${r.origin}`;default:return"잘못된 입력"}}};function mE(){return{localeError:fE()}}const hE=e=>Sn(typeof e,e),Sn=(e,t=void 0)=>{switch(e){case"number":return Number.isNaN(t)?"NaN":"skaičius";case"bigint":return"sveikasis skaičius";case"string":return"eilutė";case"boolean":return"loginė reikšmė";case"undefined":case"void":return"neapibrėžta reikšmė";case"function":return"funkcija";case"symbol":return"simbolis";case"object":return t===void 0?"nežinomas objektas":t===null?"nulinė reikšmė":Array.isArray(t)?"masyvas":Object.getPrototypeOf(t)!==Object.prototype&&t.constructor?t.constructor.name:"objektas";case"null":return"nulinė reikšmė"}return e},bn=e=>e.charAt(0).toUpperCase()+e.slice(1);function Gd(e){const t=Math.abs(e),n=t%10,o=t%100;return o>=11&&o<=19||n===0?"many":n===1?"one":"few"}const gE=()=>{const e={string:{unit:{one:"simbolis",few:"simboliai",many:"simbolių"},verb:{smaller:{inclusive:"turi būti ne ilgesnė kaip",notInclusive:"turi būti trumpesnė kaip"},bigger:{inclusive:"turi būti ne trumpesnė kaip",notInclusive:"turi būti ilgesnė kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"baitų"},verb:{smaller:{inclusive:"turi būti ne didesnis kaip",notInclusive:"turi būti mažesnis kaip"},bigger:{inclusive:"turi būti ne mažesnis kaip",notInclusive:"turi būti didesnis kaip"}}},array:{unit:{one:"elementą",few:"elementus",many:"elementų"},verb:{smaller:{inclusive:"turi turėti ne daugiau kaip",notInclusive:"turi turėti mažiau kaip"},bigger:{inclusive:"turi turėti ne mažiau kaip",notInclusive:"turi turėti daugiau kaip"}}},set:{unit:{one:"elementą",few:"elementus",many:"elementų"},verb:{smaller:{inclusive:"turi turėti ne daugiau kaip",notInclusive:"turi turėti mažiau kaip"},bigger:{inclusive:"turi turėti ne mažiau kaip",notInclusive:"turi turėti daugiau kaip"}}}};function t(o,r,i,a){const s=e[o]??null;return s===null?s:{unit:s.unit[r],verb:s.verb[a][i?"inclusive":"notInclusive"]}}const n={regex:"įvestis",email:"el. pašto adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukmė",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 užkoduota eilutė",base64url:"base64url užkoduota eilutė",json_string:"JSON eilutė",e164:"E.164 numeris",jwt:"JWT",template_literal:"įvestis"};return o=>{switch(o.code){case"invalid_type":return`Gautas tipas ${hE(o.input)}, o tikėtasi - ${Sn(o.expected)}`;case"invalid_value":return o.values.length===1?`Privalo būti ${H(o.values[0])}`:`Privalo būti vienas iš ${j(o.values,"|")} pasirinkimų`;case"too_big":{const r=Sn(o.origin),i=t(o.origin,Gd(Number(o.maximum)),o.inclusive??!1,"smaller");if(i?.verb)return`${bn(r??o.origin??"reikšmė")} ${i.verb} ${o.maximum.toString()} ${i.unit??"elementų"}`;const a=o.inclusive?"ne didesnis kaip":"mažesnis kaip";return`${bn(r??o.origin??"reikšmė")} turi būti ${a} ${o.maximum.toString()} ${i?.unit}`}case"too_small":{const r=Sn(o.origin),i=t(o.origin,Gd(Number(o.minimum)),o.inclusive??!1,"bigger");if(i?.verb)return`${bn(r??o.origin??"reikšmė")} ${i.verb} ${o.minimum.toString()} ${i.unit??"elementų"}`;const a=o.inclusive?"ne mažesnis kaip":"didesnis kaip";return`${bn(r??o.origin??"reikšmė")} turi būti ${a} ${o.minimum.toString()} ${i?.unit}`}case"invalid_format":{const r=o;return r.format==="starts_with"?`Eilutė privalo prasidėti "${r.prefix}"`:r.format==="ends_with"?`Eilutė privalo pasibaigti "${r.suffix}"`:r.format==="includes"?`Eilutė privalo įtraukti "${r.includes}"`:r.format==="regex"?`Eilutė privalo atitikti ${r.pattern}`:`Neteisingas ${n[r.format]??o.format}`}case"not_multiple_of":return`Skaičius privalo būti ${o.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpažint${o.keys.length>1?"i":"as"} rakt${o.keys.length>1?"ai":"as"}: ${j(o.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga įvestis";case"invalid_element":{const r=Sn(o.origin);return`${bn(r??o.origin??"reikšmė")} turi klaidingą įvestį`}default:return"Klaidinga įvestis"}}};function vE(){return{localeError:gE()}}const yE=()=>{const e={string:{unit:"знаци",verb:"да имаат"},file:{unit:"бајти",verb:"да имаат"},array:{unit:"ставки",verb:"да имаат"},set:{unit:"ставки",verb:"да имаат"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"број";case"object":{if(Array.isArray(r))return"низа";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"внес",email:"адреса на е-пошта",url:"URL",emoji:"емоџи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO датум и време",date:"ISO датум",time:"ISO време",duration:"ISO времетраење",ipv4:"IPv4 адреса",ipv6:"IPv6 адреса",cidrv4:"IPv4 опсег",cidrv6:"IPv6 опсег",base64:"base64-енкодирана низа",base64url:"base64url-енкодирана низа",json_string:"JSON низа",e164:"E.164 број",jwt:"JWT",template_literal:"внес"};return r=>{switch(r.code){case"invalid_type":return`Грешен внес: се очекува ${r.expected}, примено ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Invalid input: expected ${H(r.values[0])}`:`Грешана опција: се очекува една ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Премногу голем: се очекува ${r.origin??"вредноста"} да има ${i}${r.maximum.toString()} ${a.unit??"елементи"}`:`Премногу голем: се очекува ${r.origin??"вредноста"} да биде ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Премногу мал: се очекува ${r.origin} да има ${i}${r.minimum.toString()} ${a.unit}`:`Премногу мал: се очекува ${r.origin} да биде ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Неважечка низа: мора да започнува со "${i.prefix}"`:i.format==="ends_with"?`Неважечка низа: мора да завршува со "${i.suffix}"`:i.format==="includes"?`Неважечка низа: мора да вклучува "${i.includes}"`:i.format==="regex"?`Неважечка низа: мора да одгоара на патернот ${i.pattern}`:`Invalid ${o[i.format]??r.format}`}case"not_multiple_of":return`Грешен број: мора да биде делив со ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Непрепознаени клучеви":"Непрепознаен клуч"}: ${j(r.keys,", ")}`;case"invalid_key":return`Грешен клуч во ${r.origin}`;case"invalid_union":return"Грешен внес";case"invalid_element":return`Грешна вредност во ${r.origin}`;default:return"Грешен внес"}}};function bE(){return{localeError:yE()}}const _E=()=>{const e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"nombor";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Input tidak sah: dijangka ${r.expected}, diterima ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Input tidak sah: dijangka ${H(r.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Terlalu besar: dijangka ${r.origin??"nilai"} ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: dijangka ${r.origin??"nilai"} adalah ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Terlalu kecil: dijangka ${r.origin} ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Terlalu kecil: dijangka ${r.origin} adalah ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`String tidak sah: mesti bermula dengan "${i.prefix}"`:i.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${i.suffix}"`:i.format==="includes"?`String tidak sah: mesti mengandungi "${i.includes}"`:i.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${i.pattern}`:`${o[i.format]??r.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${j(r.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${r.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${r.origin}`;default:return"Input tidak sah"}}};function wE(){return{localeError:_E()}}const xE=()=>{const e={string:{unit:"tekens",verb:"te hebben"},file:{unit:"bytes",verb:"te hebben"},array:{unit:"elementen",verb:"te hebben"},set:{unit:"elementen",verb:"te hebben"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"getal";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"};return r=>{switch(r.code){case"invalid_type":return`Ongeldige invoer: verwacht ${r.expected}, ontving ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ongeldige invoer: verwacht ${H(r.values[0])}`:`Ongeldige optie: verwacht één van ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Te groot: verwacht dat ${r.origin??"waarde"} ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"elementen"}`:`Te groot: verwacht dat ${r.origin??"waarde"} ${i}${r.maximum.toString()} is`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Te klein: verwacht dat ${r.origin} ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Te klein: verwacht dat ${r.origin} ${i}${r.minimum.toString()} is`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Ongeldige tekst: moet met "${i.prefix}" beginnen`:i.format==="ends_with"?`Ongeldige tekst: moet op "${i.suffix}" eindigen`:i.format==="includes"?`Ongeldige tekst: moet "${i.includes}" bevatten`:i.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${i.pattern}`:`Ongeldig: ${o[i.format]??r.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${r.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${r.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${r.origin}`;default:return"Ongeldige invoer"}}};function $E(){return{localeError:xE()}}const SE=()=>{const e={string:{unit:"tegn",verb:"å ha"},file:{unit:"bytes",verb:"å ha"},array:{unit:"elementer",verb:"å inneholde"},set:{unit:"elementer",verb:"å inneholde"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"tall";case"object":{if(Array.isArray(r))return"liste";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-område",ipv6:"IPv6-område",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`Ugyldig input: forventet ${r.expected}, fikk ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ugyldig verdi: forventet ${H(r.values[0])}`:`Ugyldig valg: forventet en av ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`For stor(t): forventet ${r.origin??"value"} til å ha ${i}${r.maximum.toString()} ${a.unit??"elementer"}`:`For stor(t): forventet ${r.origin??"value"} til å ha ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`For lite(n): forventet ${r.origin} til å ha ${i}${r.minimum.toString()} ${a.unit}`:`For lite(n): forventet ${r.origin} til å ha ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Ugyldig streng: må starte med "${i.prefix}"`:i.format==="ends_with"?`Ugyldig streng: må ende med "${i.suffix}"`:i.format==="includes"?`Ugyldig streng: må inneholde "${i.includes}"`:i.format==="regex"?`Ugyldig streng: må matche mønsteret ${i.pattern}`:`Ugyldig ${o[i.format]??r.format}`}case"not_multiple_of":return`Ugyldig tall: må være et multiplum av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukjente nøkler":"Ukjent nøkkel"}: ${j(r.keys,", ")}`;case"invalid_key":return`Ugyldig nøkkel i ${r.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${r.origin}`;default:return"Ugyldig input"}}};function IE(){return{localeError:SE()}}const kE=()=>{const e={string:{unit:"harf",verb:"olmalıdır"},file:{unit:"bayt",verb:"olmalıdır"},array:{unit:"unsur",verb:"olmalıdır"},set:{unit:"unsur",verb:"olmalıdır"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"numara";case"object":{if(Array.isArray(r))return"saf";if(r===null)return"gayb";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"giren",email:"epostagâh",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO hengâmı",date:"ISO tarihi",time:"ISO zamanı",duration:"ISO müddeti",ipv4:"IPv4 nişânı",ipv6:"IPv6 nişânı",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-şifreli metin",base64url:"base64url-şifreli metin",json_string:"JSON metin",e164:"E.164 sayısı",jwt:"JWT",template_literal:"giren"};return r=>{switch(r.code){case"invalid_type":return`Fâsit giren: umulan ${r.expected}, alınan ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Fâsit giren: umulan ${H(r.values[0])}`:`Fâsit tercih: mûteberler ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Fazla büyük: ${r.origin??"value"}, ${i}${r.maximum.toString()} ${a.unit??"elements"} sahip olmalıydı.`:`Fazla büyük: ${r.origin??"value"}, ${i}${r.maximum.toString()} olmalıydı.`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Fazla küçük: ${r.origin}, ${i}${r.minimum.toString()} ${a.unit} sahip olmalıydı.`:`Fazla küçük: ${r.origin}, ${i}${r.minimum.toString()} olmalıydı.`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Fâsit metin: "${i.prefix}" ile başlamalı.`:i.format==="ends_with"?`Fâsit metin: "${i.suffix}" ile bitmeli.`:i.format==="includes"?`Fâsit metin: "${i.includes}" ihtivâ etmeli.`:i.format==="regex"?`Fâsit metin: ${i.pattern} nakşına uymalı.`:`Fâsit ${o[i.format]??r.format}`}case"not_multiple_of":return`Fâsit sayı: ${r.divisor} katı olmalıydı.`;case"unrecognized_keys":return`Tanınmayan anahtar ${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`${r.origin} için tanınmayan anahtar var.`;case"invalid_union":return"Giren tanınamadı.";case"invalid_element":return`${r.origin} için tanınmayan kıymet var.`;default:return"Kıymet tanınamadı."}}};function EE(){return{localeError:kE()}}const TE=()=>{const e={string:{unit:"توکي",verb:"ولري"},file:{unit:"بایټس",verb:"ولري"},array:{unit:"توکي",verb:"ولري"},set:{unit:"توکي",verb:"ولري"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"عدد";case"object":{if(Array.isArray(r))return"ارې";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ورودي",email:"بریښنالیک",url:"یو آر ال",emoji:"ایموجي",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"نیټه او وخت",date:"نېټه",time:"وخت",duration:"موده",ipv4:"د IPv4 پته",ipv6:"د IPv6 پته",cidrv4:"د IPv4 ساحه",cidrv6:"د IPv6 ساحه",base64:"base64-encoded متن",base64url:"base64url-encoded متن",json_string:"JSON متن",e164:"د E.164 شمېره",jwt:"JWT",template_literal:"ورودي"};return r=>{switch(r.code){case"invalid_type":return`ناسم ورودي: باید ${r.expected} وای, مګر ${n(r.input)} ترلاسه شو`;case"invalid_value":return r.values.length===1?`ناسم ورودي: باید ${H(r.values[0])} وای`:`ناسم انتخاب: باید یو له ${j(r.values,"|")} څخه وای`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`ډیر لوی: ${r.origin??"ارزښت"} باید ${i}${r.maximum.toString()} ${a.unit??"عنصرونه"} ولري`:`ډیر لوی: ${r.origin??"ارزښت"} باید ${i}${r.maximum.toString()} وي`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`ډیر کوچنی: ${r.origin} باید ${i}${r.minimum.toString()} ${a.unit} ولري`:`ډیر کوچنی: ${r.origin} باید ${i}${r.minimum.toString()} وي`}case"invalid_format":{const i=r;return i.format==="starts_with"?`ناسم متن: باید د "${i.prefix}" سره پیل شي`:i.format==="ends_with"?`ناسم متن: باید د "${i.suffix}" سره پای ته ورسيږي`:i.format==="includes"?`ناسم متن: باید "${i.includes}" ولري`:i.format==="regex"?`ناسم متن: باید د ${i.pattern} سره مطابقت ولري`:`${o[i.format]??r.format} ناسم دی`}case"not_multiple_of":return`ناسم عدد: باید د ${r.divisor} مضرب وي`;case"unrecognized_keys":return`ناسم ${r.keys.length>1?"کلیډونه":"کلیډ"}: ${j(r.keys,", ")}`;case"invalid_key":return`ناسم کلیډ په ${r.origin} کې`;case"invalid_union":return"ناسمه ورودي";case"invalid_element":return`ناسم عنصر په ${r.origin} کې`;default:return"ناسمه ورودي"}}};function OE(){return{localeError:TE()}}const NE=()=>{const e={string:{unit:"znaków",verb:"mieć"},file:{unit:"bajtów",verb:"mieć"},array:{unit:"elementów",verb:"mieć"},set:{unit:"elementów",verb:"mieć"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"liczba";case"object":{if(Array.isArray(r))return"tablica";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"wyrażenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ciąg znaków zakodowany w formacie base64",base64url:"ciąg znaków zakodowany w formacie base64url",json_string:"ciąg znaków w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wejście"};return r=>{switch(r.code){case"invalid_type":return`Nieprawidłowe dane wejściowe: oczekiwano ${r.expected}, otrzymano ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Nieprawidłowe dane wejściowe: oczekiwano ${H(r.values[0])}`:`Nieprawidłowa opcja: oczekiwano jednej z wartości ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Za duża wartość: oczekiwano, że ${r.origin??"wartość"} będzie mieć ${i}${r.maximum.toString()} ${a.unit??"elementów"}`:`Zbyt duż(y/a/e): oczekiwano, że ${r.origin??"wartość"} będzie wynosić ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Za mała wartość: oczekiwano, że ${r.origin??"wartość"} będzie mieć ${i}${r.minimum.toString()} ${a.unit??"elementów"}`:`Zbyt mał(y/a/e): oczekiwano, że ${r.origin??"wartość"} będzie wynosić ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Nieprawidłowy ciąg znaków: musi zaczynać się od "${i.prefix}"`:i.format==="ends_with"?`Nieprawidłowy ciąg znaków: musi kończyć się na "${i.suffix}"`:i.format==="includes"?`Nieprawidłowy ciąg znaków: musi zawierać "${i.includes}"`:i.format==="regex"?`Nieprawidłowy ciąg znaków: musi odpowiadać wzorcowi ${i.pattern}`:`Nieprawidłow(y/a/e) ${o[i.format]??r.format}`}case"not_multiple_of":return`Nieprawidłowa liczba: musi być wielokrotnością ${r.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Nieprawidłowy klucz w ${r.origin}`;case"invalid_union":return"Nieprawidłowe dane wejściowe";case"invalid_element":return`Nieprawidłowa wartość w ${r.origin}`;default:return"Nieprawidłowe dane wejściowe"}}};function PE(){return{localeError:NE()}}const CE=()=>{const e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"número";case"object":{if(Array.isArray(r))return"array";if(r===null)return"nulo";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"padrão",email:"endereço de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"duração ISO",ipv4:"endereço IPv4",ipv6:"endereço IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"};return r=>{switch(r.code){case"invalid_type":return`Tipo inválido: esperado ${r.expected}, recebido ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Entrada inválida: esperado ${H(r.values[0])}`:`Opção inválida: esperada uma das ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Muito grande: esperado que ${r.origin??"valor"} tivesse ${i}${r.maximum.toString()} ${a.unit??"elementos"}`:`Muito grande: esperado que ${r.origin??"valor"} fosse ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Muito pequeno: esperado que ${r.origin} tivesse ${i}${r.minimum.toString()} ${a.unit}`:`Muito pequeno: esperado que ${r.origin} fosse ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Texto inválido: deve começar com "${i.prefix}"`:i.format==="ends_with"?`Texto inválido: deve terminar com "${i.suffix}"`:i.format==="includes"?`Texto inválido: deve incluir "${i.includes}"`:i.format==="regex"?`Texto inválido: deve corresponder ao padrão ${i.pattern}`:`${o[i.format]??r.format} inválido`}case"not_multiple_of":return`Número inválido: deve ser múltiplo de ${r.divisor}`;case"unrecognized_keys":return`Chave${r.keys.length>1?"s":""} desconhecida${r.keys.length>1?"s":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Chave inválida em ${r.origin}`;case"invalid_union":return"Entrada inválida";case"invalid_element":return`Valor inválido em ${r.origin}`;default:return"Campo inválido"}}};function jE(){return{localeError:CE()}}function Kd(e,t,n,o){const r=Math.abs(e),i=r%10,a=r%100;return a>=11&&a<=19?o:i===1?t:i>=2&&i<=4?n:o}const AE=()=>{const e={string:{unit:{one:"символ",few:"символа",many:"символов"},verb:"иметь"},file:{unit:{one:"байт",few:"байта",many:"байт"},verb:"иметь"},array:{unit:{one:"элемент",few:"элемента",many:"элементов"},verb:"иметь"},set:{unit:{one:"элемент",few:"элемента",many:"элементов"},verb:"иметь"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"число";case"object":{if(Array.isArray(r))return"массив";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ввод",email:"email адрес",url:"URL",emoji:"эмодзи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO дата и время",date:"ISO дата",time:"ISO время",duration:"ISO длительность",ipv4:"IPv4 адрес",ipv6:"IPv6 адрес",cidrv4:"IPv4 диапазон",cidrv6:"IPv6 диапазон",base64:"строка в формате base64",base64url:"строка в формате base64url",json_string:"JSON строка",e164:"номер E.164",jwt:"JWT",template_literal:"ввод"};return r=>{switch(r.code){case"invalid_type":return`Неверный ввод: ожидалось ${r.expected}, получено ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Неверный ввод: ожидалось ${H(r.values[0])}`:`Неверный вариант: ожидалось одно из ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);if(a){const s=Number(r.maximum),l=Kd(s,a.unit.one,a.unit.few,a.unit.many);return`Слишком большое значение: ожидалось, что ${r.origin??"значение"} будет иметь ${i}${r.maximum.toString()} ${l}`}return`Слишком большое значение: ожидалось, что ${r.origin??"значение"} будет ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);if(a){const s=Number(r.minimum),l=Kd(s,a.unit.one,a.unit.few,a.unit.many);return`Слишком маленькое значение: ожидалось, что ${r.origin} будет иметь ${i}${r.minimum.toString()} ${l}`}return`Слишком маленькое значение: ожидалось, что ${r.origin} будет ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Неверная строка: должна начинаться с "${i.prefix}"`:i.format==="ends_with"?`Неверная строка: должна заканчиваться на "${i.suffix}"`:i.format==="includes"?`Неверная строка: должна содержать "${i.includes}"`:i.format==="regex"?`Неверная строка: должна соответствовать шаблону ${i.pattern}`:`Неверный ${o[i.format]??r.format}`}case"not_multiple_of":return`Неверное число: должно быть кратным ${r.divisor}`;case"unrecognized_keys":return`Нераспознанн${r.keys.length>1?"ые":"ый"} ключ${r.keys.length>1?"и":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Неверный ключ в ${r.origin}`;case"invalid_union":return"Неверные входные данные";case"invalid_element":return`Неверное значение в ${r.origin}`;default:return"Неверные входные данные"}}};function RE(){return{localeError:AE()}}const zE=()=>{const e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"število";case"object":{if(Array.isArray(r))return"tabela";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"vnos",email:"e-poštni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in čas",date:"ISO datum",time:"ISO čas",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 številka",jwt:"JWT",template_literal:"vnos"};return r=>{switch(r.code){case"invalid_type":return`Neveljaven vnos: pričakovano ${r.expected}, prejeto ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Neveljaven vnos: pričakovano ${H(r.values[0])}`:`Neveljavna možnost: pričakovano eno izmed ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Preveliko: pričakovano, da bo ${r.origin??"vrednost"} imelo ${i}${r.maximum.toString()} ${a.unit??"elementov"}`:`Preveliko: pričakovano, da bo ${r.origin??"vrednost"} ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Premajhno: pričakovano, da bo ${r.origin} imelo ${i}${r.minimum.toString()} ${a.unit}`:`Premajhno: pričakovano, da bo ${r.origin} ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Neveljaven niz: mora se začeti z "${i.prefix}"`:i.format==="ends_with"?`Neveljaven niz: mora se končati z "${i.suffix}"`:i.format==="includes"?`Neveljaven niz: mora vsebovati "${i.includes}"`:i.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${i.pattern}`:`Neveljaven ${o[i.format]??r.format}`}case"not_multiple_of":return`Neveljavno število: mora biti večkratnik ${r.divisor}`;case"unrecognized_keys":return`Neprepoznan${r.keys.length>1?"i ključi":" ključ"}: ${j(r.keys,", ")}`;case"invalid_key":return`Neveljaven ključ v ${r.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${r.origin}`;default:return"Neveljaven vnos"}}};function ME(){return{localeError:zE()}}const DE=()=>{const e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att innehålla"},set:{unit:"objekt",verb:"att innehålla"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"antal";case"object":{if(Array.isArray(r))return"lista";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"reguljärt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad sträng",base64url:"base64url-kodad sträng",json_string:"JSON-sträng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"};return r=>{switch(r.code){case"invalid_type":return`Ogiltig inmatning: förväntat ${r.expected}, fick ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ogiltig inmatning: förväntat ${H(r.values[0])}`:`Ogiltigt val: förväntade en av ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`För stor(t): förväntade ${r.origin??"värdet"} att ha ${i}${r.maximum.toString()} ${a.unit??"element"}`:`För stor(t): förväntat ${r.origin??"värdet"} att ha ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`För lite(t): förväntade ${r.origin??"värdet"} att ha ${i}${r.minimum.toString()} ${a.unit}`:`För lite(t): förväntade ${r.origin??"värdet"} att ha ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Ogiltig sträng: måste börja med "${i.prefix}"`:i.format==="ends_with"?`Ogiltig sträng: måste sluta med "${i.suffix}"`:i.format==="includes"?`Ogiltig sträng: måste innehålla "${i.includes}"`:i.format==="regex"?`Ogiltig sträng: måste matcha mönstret "${i.pattern}"`:`Ogiltig(t) ${o[i.format]??r.format}`}case"not_multiple_of":return`Ogiltigt tal: måste vara en multipel av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Okända nycklar":"Okänd nyckel"}: ${j(r.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${r.origin??"värdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt värde i ${r.origin??"värdet"}`;default:return"Ogiltig input"}}};function UE(){return{localeError:DE()}}const LE=()=>{const e={string:{unit:"எழுத்துக்கள்",verb:"கொண்டிருக்க வேண்டும்"},file:{unit:"பைட்டுகள்",verb:"கொண்டிருக்க வேண்டும்"},array:{unit:"உறுப்புகள்",verb:"கொண்டிருக்க வேண்டும்"},set:{unit:"உறுப்புகள்",verb:"கொண்டிருக்க வேண்டும்"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"எண் அல்லாதது":"எண்";case"object":{if(Array.isArray(r))return"அணி";if(r===null)return"வெறுமை";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"உள்ளீடு",email:"மின்னஞ்சல் முகவரி",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO தேதி நேரம்",date:"ISO தேதி",time:"ISO நேரம்",duration:"ISO கால அளவு",ipv4:"IPv4 முகவரி",ipv6:"IPv6 முகவரி",cidrv4:"IPv4 வரம்பு",cidrv6:"IPv6 வரம்பு",base64:"base64-encoded சரம்",base64url:"base64url-encoded சரம்",json_string:"JSON சரம்",e164:"E.164 எண்",jwt:"JWT",template_literal:"input"};return r=>{switch(r.code){case"invalid_type":return`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${r.expected}, பெறப்பட்டது ${n(r.input)}`;case"invalid_value":return r.values.length===1?`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${H(r.values[0])}`:`தவறான விருப்பம்: எதிர்பார்க்கப்பட்டது ${j(r.values,"|")} இல் ஒன்று`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`மிக பெரியது: எதிர்பார்க்கப்பட்டது ${r.origin??"மதிப்பு"} ${i}${r.maximum.toString()} ${a.unit??"உறுப்புகள்"} ஆக இருக்க வேண்டும்`:`மிக பெரியது: எதிர்பார்க்கப்பட்டது ${r.origin??"மதிப்பு"} ${i}${r.maximum.toString()} ஆக இருக்க வேண்டும்`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${r.origin} ${i}${r.minimum.toString()} ${a.unit} ஆக இருக்க வேண்டும்`:`மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${r.origin} ${i}${r.minimum.toString()} ஆக இருக்க வேண்டும்`}case"invalid_format":{const i=r;return i.format==="starts_with"?`தவறான சரம்: "${i.prefix}" இல் தொடங்க வேண்டும்`:i.format==="ends_with"?`தவறான சரம்: "${i.suffix}" இல் முடிவடைய வேண்டும்`:i.format==="includes"?`தவறான சரம்: "${i.includes}" ஐ உள்ளடக்க வேண்டும்`:i.format==="regex"?`தவறான சரம்: ${i.pattern} முறைபாட்டுடன் பொருந்த வேண்டும்`:`தவறான ${o[i.format]??r.format}`}case"not_multiple_of":return`தவறான எண்: ${r.divisor} இன் பலமாக இருக்க வேண்டும்`;case"unrecognized_keys":return`அடையாளம் தெரியாத விசை${r.keys.length>1?"கள்":""}: ${j(r.keys,", ")}`;case"invalid_key":return`${r.origin} இல் தவறான விசை`;case"invalid_union":return"தவறான உள்ளீடு";case"invalid_element":return`${r.origin} இல் தவறான மதிப்பு`;default:return"தவறான உள்ளீடு"}}};function ZE(){return{localeError:LE()}}const FE=()=>{const e={string:{unit:"ตัวอักษร",verb:"ควรมี"},file:{unit:"ไบต์",verb:"ควรมี"},array:{unit:"รายการ",verb:"ควรมี"},set:{unit:"รายการ",verb:"ควรมี"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"ไม่ใช่ตัวเลข (NaN)":"ตัวเลข";case"object":{if(Array.isArray(r))return"อาร์เรย์ (Array)";if(r===null)return"ไม่มีค่า (null)";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ข้อมูลที่ป้อน",email:"ที่อยู่อีเมล",url:"URL",emoji:"อิโมจิ",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"วันที่เวลาแบบ ISO",date:"วันที่แบบ ISO",time:"เวลาแบบ ISO",duration:"ช่วงเวลาแบบ ISO",ipv4:"ที่อยู่ IPv4",ipv6:"ที่อยู่ IPv6",cidrv4:"ช่วง IP แบบ IPv4",cidrv6:"ช่วง IP แบบ IPv6",base64:"ข้อความแบบ Base64",base64url:"ข้อความแบบ Base64 สำหรับ URL",json_string:"ข้อความแบบ JSON",e164:"เบอร์โทรศัพท์ระหว่างประเทศ (E.164)",jwt:"โทเคน JWT",template_literal:"ข้อมูลที่ป้อน"};return r=>{switch(r.code){case"invalid_type":return`ประเภทข้อมูลไม่ถูกต้อง: ควรเป็น ${r.expected} แต่ได้รับ ${n(r.input)}`;case"invalid_value":return r.values.length===1?`ค่าไม่ถูกต้อง: ควรเป็น ${H(r.values[0])}`:`ตัวเลือกไม่ถูกต้อง: ควรเป็นหนึ่งใน ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"ไม่เกิน":"น้อยกว่า",a=t(r.origin);return a?`เกินกำหนด: ${r.origin??"ค่า"} ควรมี${i} ${r.maximum.toString()} ${a.unit??"รายการ"}`:`เกินกำหนด: ${r.origin??"ค่า"} ควรมี${i} ${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?"อย่างน้อย":"มากกว่า",a=t(r.origin);return a?`น้อยกว่ากำหนด: ${r.origin} ควรมี${i} ${r.minimum.toString()} ${a.unit}`:`น้อยกว่ากำหนด: ${r.origin} ควรมี${i} ${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`รูปแบบไม่ถูกต้อง: ข้อความต้องขึ้นต้นด้วย "${i.prefix}"`:i.format==="ends_with"?`รูปแบบไม่ถูกต้อง: ข้อความต้องลงท้ายด้วย "${i.suffix}"`:i.format==="includes"?`รูปแบบไม่ถูกต้อง: ข้อความต้องมี "${i.includes}" อยู่ในข้อความ`:i.format==="regex"?`รูปแบบไม่ถูกต้อง: ต้องตรงกับรูปแบบที่กำหนด ${i.pattern}`:`รูปแบบไม่ถูกต้อง: ${o[i.format]??r.format}`}case"not_multiple_of":return`ตัวเลขไม่ถูกต้อง: ต้องเป็นจำนวนที่หารด้วย ${r.divisor} ได้ลงตัว`;case"unrecognized_keys":return`พบคีย์ที่ไม่รู้จัก: ${j(r.keys,", ")}`;case"invalid_key":return`คีย์ไม่ถูกต้องใน ${r.origin}`;case"invalid_union":return"ข้อมูลไม่ถูกต้อง: ไม่ตรงกับรูปแบบยูเนียนที่กำหนดไว้";case"invalid_element":return`ข้อมูลไม่ถูกต้องใน ${r.origin}`;default:return"ข้อมูลไม่ถูกต้อง"}}};function qE(){return{localeError:FE()}}const VE=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},BE=()=>{const e={string:{unit:"karakter",verb:"olmalı"},file:{unit:"bayt",verb:"olmalı"},array:{unit:"öğe",verb:"olmalı"},set:{unit:"öğe",verb:"olmalı"}};function t(o){return e[o]??null}const n={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO süre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aralığı",cidrv6:"IPv6 aralığı",base64:"base64 ile şifrelenmiş metin",base64url:"base64url ile şifrelenmiş metin",json_string:"JSON dizesi",e164:"E.164 sayısı",jwt:"JWT",template_literal:"Şablon dizesi"};return o=>{switch(o.code){case"invalid_type":return`Geçersiz değer: beklenen ${o.expected}, alınan ${VE(o.input)}`;case"invalid_value":return o.values.length===1?`Geçersiz değer: beklenen ${H(o.values[0])}`:`Geçersiz seçenek: aşağıdakilerden biri olmalı: ${j(o.values,"|")}`;case"too_big":{const r=o.inclusive?"<=":"<",i=t(o.origin);return i?`Çok büyük: beklenen ${o.origin??"değer"} ${r}${o.maximum.toString()} ${i.unit??"öğe"}`:`Çok büyük: beklenen ${o.origin??"değer"} ${r}${o.maximum.toString()}`}case"too_small":{const r=o.inclusive?">=":">",i=t(o.origin);return i?`Çok küçük: beklenen ${o.origin} ${r}${o.minimum.toString()} ${i.unit}`:`Çok küçük: beklenen ${o.origin} ${r}${o.minimum.toString()}`}case"invalid_format":{const r=o;return r.format==="starts_with"?`Geçersiz metin: "${r.prefix}" ile başlamalı`:r.format==="ends_with"?`Geçersiz metin: "${r.suffix}" ile bitmeli`:r.format==="includes"?`Geçersiz metin: "${r.includes}" içermeli`:r.format==="regex"?`Geçersiz metin: ${r.pattern} desenine uymalı`:`Geçersiz ${n[r.format]??o.format}`}case"not_multiple_of":return`Geçersiz sayı: ${o.divisor} ile tam bölünebilmeli`;case"unrecognized_keys":return`Tanınmayan anahtar${o.keys.length>1?"lar":""}: ${j(o.keys,", ")}`;case"invalid_key":return`${o.origin} içinde geçersiz anahtar`;case"invalid_union":return"Geçersiz değer";case"invalid_element":return`${o.origin} içinde geçersiz değer`;default:return"Geçersiz değer"}}};function JE(){return{localeError:BE()}}const WE=()=>{const e={string:{unit:"символів",verb:"матиме"},file:{unit:"байтів",verb:"матиме"},array:{unit:"елементів",verb:"матиме"},set:{unit:"елементів",verb:"матиме"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"число";case"object":{if(Array.isArray(r))return"масив";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"вхідні дані",email:"адреса електронної пошти",url:"URL",emoji:"емодзі",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"дата та час ISO",date:"дата ISO",time:"час ISO",duration:"тривалість ISO",ipv4:"адреса IPv4",ipv6:"адреса IPv6",cidrv4:"діапазон IPv4",cidrv6:"діапазон IPv6",base64:"рядок у кодуванні base64",base64url:"рядок у кодуванні base64url",json_string:"рядок JSON",e164:"номер E.164",jwt:"JWT",template_literal:"вхідні дані"};return r=>{switch(r.code){case"invalid_type":return`Неправильні вхідні дані: очікується ${r.expected}, отримано ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Неправильні вхідні дані: очікується ${H(r.values[0])}`:`Неправильна опція: очікується одне з ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Занадто велике: очікується, що ${r.origin??"значення"} ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"елементів"}`:`Занадто велике: очікується, що ${r.origin??"значення"} буде ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Занадто мале: очікується, що ${r.origin} ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Занадто мале: очікується, що ${r.origin} буде ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Неправильний рядок: повинен починатися з "${i.prefix}"`:i.format==="ends_with"?`Неправильний рядок: повинен закінчуватися на "${i.suffix}"`:i.format==="includes"?`Неправильний рядок: повинен містити "${i.includes}"`:i.format==="regex"?`Неправильний рядок: повинен відповідати шаблону ${i.pattern}`:`Неправильний ${o[i.format]??r.format}`}case"not_multiple_of":return`Неправильне число: повинно бути кратним ${r.divisor}`;case"unrecognized_keys":return`Нерозпізнаний ключ${r.keys.length>1?"і":""}: ${j(r.keys,", ")}`;case"invalid_key":return`Неправильний ключ у ${r.origin}`;case"invalid_union":return"Неправильні вхідні дані";case"invalid_element":return`Неправильне значення у ${r.origin}`;default:return"Неправильні вхідні дані"}}};function _v(){return{localeError:WE()}}function HE(){return _v()}const GE=()=>{const e={string:{unit:"حروف",verb:"ہونا"},file:{unit:"بائٹس",verb:"ہونا"},array:{unit:"آئٹمز",verb:"ہونا"},set:{unit:"آئٹمز",verb:"ہونا"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"نمبر";case"object":{if(Array.isArray(r))return"آرے";if(r===null)return"نل";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ان پٹ",email:"ای میل ایڈریس",url:"یو آر ایل",emoji:"ایموجی",uuid:"یو یو آئی ڈی",uuidv4:"یو یو آئی ڈی وی 4",uuidv6:"یو یو آئی ڈی وی 6",nanoid:"نینو آئی ڈی",guid:"جی یو آئی ڈی",cuid:"سی یو آئی ڈی",cuid2:"سی یو آئی ڈی 2",ulid:"یو ایل آئی ڈی",xid:"ایکس آئی ڈی",ksuid:"کے ایس یو آئی ڈی",datetime:"آئی ایس او ڈیٹ ٹائم",date:"آئی ایس او تاریخ",time:"آئی ایس او وقت",duration:"آئی ایس او مدت",ipv4:"آئی پی وی 4 ایڈریس",ipv6:"آئی پی وی 6 ایڈریس",cidrv4:"آئی پی وی 4 رینج",cidrv6:"آئی پی وی 6 رینج",base64:"بیس 64 ان کوڈڈ سٹرنگ",base64url:"بیس 64 یو آر ایل ان کوڈڈ سٹرنگ",json_string:"جے ایس او این سٹرنگ",e164:"ای 164 نمبر",jwt:"جے ڈبلیو ٹی",template_literal:"ان پٹ"};return r=>{switch(r.code){case"invalid_type":return`غلط ان پٹ: ${r.expected} متوقع تھا، ${n(r.input)} موصول ہوا`;case"invalid_value":return r.values.length===1?`غلط ان پٹ: ${H(r.values[0])} متوقع تھا`:`غلط آپشن: ${j(r.values,"|")} میں سے ایک متوقع تھا`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`بہت بڑا: ${r.origin??"ویلیو"} کے ${i}${r.maximum.toString()} ${a.unit??"عناصر"} ہونے متوقع تھے`:`بہت بڑا: ${r.origin??"ویلیو"} کا ${i}${r.maximum.toString()} ہونا متوقع تھا`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`بہت چھوٹا: ${r.origin} کے ${i}${r.minimum.toString()} ${a.unit} ہونے متوقع تھے`:`بہت چھوٹا: ${r.origin} کا ${i}${r.minimum.toString()} ہونا متوقع تھا`}case"invalid_format":{const i=r;return i.format==="starts_with"?`غلط سٹرنگ: "${i.prefix}" سے شروع ہونا چاہیے`:i.format==="ends_with"?`غلط سٹرنگ: "${i.suffix}" پر ختم ہونا چاہیے`:i.format==="includes"?`غلط سٹرنگ: "${i.includes}" شامل ہونا چاہیے`:i.format==="regex"?`غلط سٹرنگ: پیٹرن ${i.pattern} سے میچ ہونا چاہیے`:`غلط ${o[i.format]??r.format}`}case"not_multiple_of":return`غلط نمبر: ${r.divisor} کا مضاعف ہونا چاہیے`;case"unrecognized_keys":return`غیر تسلیم شدہ کی${r.keys.length>1?"ز":""}: ${j(r.keys,"، ")}`;case"invalid_key":return`${r.origin} میں غلط کی`;case"invalid_union":return"غلط ان پٹ";case"invalid_element":return`${r.origin} میں غلط ویلیو`;default:return"غلط ان پٹ"}}};function KE(){return{localeError:GE()}}const YE=()=>{const e={string:{unit:"ký tự",verb:"có"},file:{unit:"byte",verb:"có"},array:{unit:"phần tử",verb:"có"},set:{unit:"phần tử",verb:"có"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"số";case"object":{if(Array.isArray(r))return"mảng";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"đầu vào",email:"địa chỉ email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ngày giờ ISO",date:"ngày ISO",time:"giờ ISO",duration:"khoảng thời gian ISO",ipv4:"địa chỉ IPv4",ipv6:"địa chỉ IPv6",cidrv4:"dải IPv4",cidrv6:"dải IPv6",base64:"chuỗi mã hóa base64",base64url:"chuỗi mã hóa base64url",json_string:"chuỗi JSON",e164:"số E.164",jwt:"JWT",template_literal:"đầu vào"};return r=>{switch(r.code){case"invalid_type":return`Đầu vào không hợp lệ: mong đợi ${r.expected}, nhận được ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Đầu vào không hợp lệ: mong đợi ${H(r.values[0])}`:`Tùy chọn không hợp lệ: mong đợi một trong các giá trị ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Quá lớn: mong đợi ${r.origin??"giá trị"} ${a.verb} ${i}${r.maximum.toString()} ${a.unit??"phần tử"}`:`Quá lớn: mong đợi ${r.origin??"giá trị"} ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Quá nhỏ: mong đợi ${r.origin} ${a.verb} ${i}${r.minimum.toString()} ${a.unit}`:`Quá nhỏ: mong đợi ${r.origin} ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Chuỗi không hợp lệ: phải bắt đầu bằng "${i.prefix}"`:i.format==="ends_with"?`Chuỗi không hợp lệ: phải kết thúc bằng "${i.suffix}"`:i.format==="includes"?`Chuỗi không hợp lệ: phải bao gồm "${i.includes}"`:i.format==="regex"?`Chuỗi không hợp lệ: phải khớp với mẫu ${i.pattern}`:`${o[i.format]??r.format} không hợp lệ`}case"not_multiple_of":return`Số không hợp lệ: phải là bội số của ${r.divisor}`;case"unrecognized_keys":return`Khóa không được nhận dạng: ${j(r.keys,", ")}`;case"invalid_key":return`Khóa không hợp lệ trong ${r.origin}`;case"invalid_union":return"Đầu vào không hợp lệ";case"invalid_element":return`Giá trị không hợp lệ trong ${r.origin}`;default:return"Đầu vào không hợp lệ"}}};function QE(){return{localeError:YE()}}const XE=()=>{const e={string:{unit:"字符",verb:"包含"},file:{unit:"字节",verb:"包含"},array:{unit:"项",verb:"包含"},set:{unit:"项",verb:"包含"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"非数字(NaN)":"数字";case"object":{if(Array.isArray(r))return"数组";if(r===null)return"空值(null)";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"输入",email:"电子邮件",url:"URL",emoji:"表情符号",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO日期时间",date:"ISO日期",time:"ISO时间",duration:"ISO时长",ipv4:"IPv4地址",ipv6:"IPv6地址",cidrv4:"IPv4网段",cidrv6:"IPv6网段",base64:"base64编码字符串",base64url:"base64url编码字符串",json_string:"JSON字符串",e164:"E.164号码",jwt:"JWT",template_literal:"输入"};return r=>{switch(r.code){case"invalid_type":return`无效输入:期望 ${r.expected},实际接收 ${n(r.input)}`;case"invalid_value":return r.values.length===1?`无效输入:期望 ${H(r.values[0])}`:`无效选项:期望以下之一 ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`数值过大:期望 ${r.origin??"值"} ${i}${r.maximum.toString()} ${a.unit??"个元素"}`:`数值过大:期望 ${r.origin??"值"} ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`数值过小:期望 ${r.origin} ${i}${r.minimum.toString()} ${a.unit}`:`数值过小:期望 ${r.origin} ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`无效字符串:必须以 "${i.prefix}" 开头`:i.format==="ends_with"?`无效字符串:必须以 "${i.suffix}" 结尾`:i.format==="includes"?`无效字符串:必须包含 "${i.includes}"`:i.format==="regex"?`无效字符串:必须满足正则表达式 ${i.pattern}`:`无效${o[i.format]??r.format}`}case"not_multiple_of":return`无效数字:必须是 ${r.divisor} 的倍数`;case"unrecognized_keys":return`出现未知的键(key): ${j(r.keys,", ")}`;case"invalid_key":return`${r.origin} 中的键(key)无效`;case"invalid_union":return"无效输入";case"invalid_element":return`${r.origin} 中包含无效值(value)`;default:return"无效输入"}}};function eT(){return{localeError:XE()}}const tT=()=>{const e={string:{unit:"字元",verb:"擁有"},file:{unit:"位元組",verb:"擁有"},array:{unit:"項目",verb:"擁有"},set:{unit:"項目",verb:"擁有"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"number";case"object":{if(Array.isArray(r))return"array";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"輸入",email:"郵件地址",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO 日期時間",date:"ISO 日期",time:"ISO 時間",duration:"ISO 期間",ipv4:"IPv4 位址",ipv6:"IPv6 位址",cidrv4:"IPv4 範圍",cidrv6:"IPv6 範圍",base64:"base64 編碼字串",base64url:"base64url 編碼字串",json_string:"JSON 字串",e164:"E.164 數值",jwt:"JWT",template_literal:"輸入"};return r=>{switch(r.code){case"invalid_type":return`無效的輸入值:預期為 ${r.expected},但收到 ${n(r.input)}`;case"invalid_value":return r.values.length===1?`無效的輸入值:預期為 ${H(r.values[0])}`:`無效的選項:預期為以下其中之一 ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`數值過大:預期 ${r.origin??"值"} 應為 ${i}${r.maximum.toString()} ${a.unit??"個元素"}`:`數值過大:預期 ${r.origin??"值"} 應為 ${i}${r.maximum.toString()}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`數值過小:預期 ${r.origin} 應為 ${i}${r.minimum.toString()} ${a.unit}`:`數值過小:預期 ${r.origin} 應為 ${i}${r.minimum.toString()}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`無效的字串:必須以 "${i.prefix}" 開頭`:i.format==="ends_with"?`無效的字串:必須以 "${i.suffix}" 結尾`:i.format==="includes"?`無效的字串:必須包含 "${i.includes}"`:i.format==="regex"?`無效的字串:必須符合格式 ${i.pattern}`:`無效的 ${o[i.format]??r.format}`}case"not_multiple_of":return`無效的數字:必須為 ${r.divisor} 的倍數`;case"unrecognized_keys":return`無法識別的鍵值${r.keys.length>1?"們":""}:${j(r.keys,"、")}`;case"invalid_key":return`${r.origin} 中有無效的鍵值`;case"invalid_union":return"無效的輸入值";case"invalid_element":return`${r.origin} 中有無效的值`;default:return"無效的輸入值"}}};function rT(){return{localeError:tT()}}const nT=()=>{const e={string:{unit:"àmi",verb:"ní"},file:{unit:"bytes",verb:"ní"},array:{unit:"nkan",verb:"ní"},set:{unit:"nkan",verb:"ní"}};function t(r){return e[r]??null}const n=r=>{const i=typeof r;switch(i){case"number":return Number.isNaN(r)?"NaN":"nọ́mbà";case"object":{if(Array.isArray(r))return"akopọ";if(r===null)return"null";if(Object.getPrototypeOf(r)!==Object.prototype&&r.constructor)return r.constructor.name}}return i},o={regex:"ẹ̀rọ ìbáwọlé",email:"àdírẹ́sì ìmẹ́lì",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"àkókò ISO",date:"ọjọ́ ISO",time:"àkókò ISO",duration:"àkókò tó pé ISO",ipv4:"àdírẹ́sì IPv4",ipv6:"àdírẹ́sì IPv6",cidrv4:"àgbègbè IPv4",cidrv6:"àgbègbè IPv6",base64:"ọ̀rọ̀ tí a kọ́ ní base64",base64url:"ọ̀rọ̀ base64url",json_string:"ọ̀rọ̀ JSON",e164:"nọ́mbà E.164",jwt:"JWT",template_literal:"ẹ̀rọ ìbáwọlé"};return r=>{switch(r.code){case"invalid_type":return`Ìbáwọlé aṣìṣe: a ní láti fi ${r.expected}, àmọ̀ a rí ${n(r.input)}`;case"invalid_value":return r.values.length===1?`Ìbáwọlé aṣìṣe: a ní láti fi ${H(r.values[0])}`:`Àṣàyàn aṣìṣe: yan ọ̀kan lára ${j(r.values,"|")}`;case"too_big":{const i=r.inclusive?"<=":"<",a=t(r.origin);return a?`Tó pọ̀ jù: a ní láti jẹ́ pé ${r.origin??"iye"} ${a.verb} ${i}${r.maximum} ${a.unit}`:`Tó pọ̀ jù: a ní láti jẹ́ ${i}${r.maximum}`}case"too_small":{const i=r.inclusive?">=":">",a=t(r.origin);return a?`Kéré ju: a ní láti jẹ́ pé ${r.origin} ${a.verb} ${i}${r.minimum} ${a.unit}`:`Kéré ju: a ní láti jẹ́ ${i}${r.minimum}`}case"invalid_format":{const i=r;return i.format==="starts_with"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bẹ̀rẹ̀ pẹ̀lú "${i.prefix}"`:i.format==="ends_with"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ parí pẹ̀lú "${i.suffix}"`:i.format==="includes"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ ní "${i.includes}"`:i.format==="regex"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bá àpẹẹrẹ mu ${i.pattern}`:`Aṣìṣe: ${o[i.format]??r.format}`}case"not_multiple_of":return`Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${r.divisor}`;case"unrecognized_keys":return`Bọtìnì àìmọ̀: ${j(r.keys,", ")}`;case"invalid_key":return`Bọtìnì aṣìṣe nínú ${r.origin}`;case"invalid_union":return"Ìbáwọlé aṣìṣe";case"invalid_element":return`Iye aṣìṣe nínú ${r.origin}`;default:return"Ìbáwọlé aṣìṣe"}}};function oT(){return{localeError:nT()}}const wv=Object.freeze(Object.defineProperty({__proto__:null,ar:yk,az:_k,be:xk,bg:Ik,ca:Ek,cs:Ok,da:Pk,de:jk,en:yv,eo:Dk,es:Lk,fa:Fk,fi:Vk,fr:Jk,frCA:Hk,he:Kk,hu:Qk,id:eE,is:nE,it:iE,ja:sE,ka:cE,kh:pE,km:bv,ko:mE,lt:vE,mk:bE,ms:wE,nl:$E,no:IE,ota:EE,pl:PE,ps:OE,pt:jE,ru:RE,sl:ME,sv:UE,ta:ZE,th:qE,tr:JE,ua:HE,uk:_v,ur:KE,vi:QE,yo:oT,zhCN:eT,zhTW:rT},Symbol.toStringTag,{value:"Module"}));var Yd;const xv=Symbol("ZodOutput"),$v=Symbol("ZodInput");class Sv{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];if(this._map.set(t,o),o&&typeof o=="object"&&"id"in o){if(this._idmap.has(o.id))throw new Error(`ID ${o.id} already exists in the registry`);this._idmap.set(o.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const o={...this.get(n)??{}};delete o.id;const r={...o,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function ll(){return new Sv}(Yd=globalThis).__zod_globalRegistry??(Yd.__zod_globalRegistry=ll());const wt=globalThis.__zod_globalRegistry;function Iv(e,t){return new e({type:"string",...P(t)})}function kv(e,t){return new e({type:"string",coerce:!0,...P(t)})}function cl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...P(t)})}function mi(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...P(t)})}function dl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function pl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function fl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function ml(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(t)})}function Yi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...P(t)})}function hl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function gl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function vl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function yl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function bl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function _l(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function wl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function xl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function $l(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(t)})}function Ev(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...P(t)})}function Sl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function Il(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function kl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function El(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function Tl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function Ol(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...P(t)})}const Tv={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Ov(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function Nv(e,t){return new e({type:"string",format:"date",check:"string_format",...P(t)})}function Pv(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...P(t)})}function Cv(e,t){return new e({type:"string",format:"duration",check:"string_format",...P(t)})}function jv(e,t){return new e({type:"number",checks:[],...P(t)})}function Av(e,t){return new e({type:"number",coerce:!0,checks:[],...P(t)})}function Rv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...P(t)})}function zv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...P(t)})}function Mv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...P(t)})}function Dv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...P(t)})}function Uv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...P(t)})}function Lv(e,t){return new e({type:"boolean",...P(t)})}function Zv(e,t){return new e({type:"boolean",coerce:!0,...P(t)})}function Fv(e,t){return new e({type:"bigint",...P(t)})}function qv(e,t){return new e({type:"bigint",coerce:!0,...P(t)})}function Vv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...P(t)})}function Bv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...P(t)})}function Jv(e,t){return new e({type:"symbol",...P(t)})}function Wv(e,t){return new e({type:"undefined",...P(t)})}function Hv(e,t){return new e({type:"null",...P(t)})}function Gv(e){return new e({type:"any"})}function Kv(e){return new e({type:"unknown"})}function Yv(e,t){return new e({type:"never",...P(t)})}function Qv(e,t){return new e({type:"void",...P(t)})}function Xv(e,t){return new e({type:"date",...P(t)})}function ey(e,t){return new e({type:"date",coerce:!0,...P(t)})}function ty(e,t){return new e({type:"nan",...P(t)})}function ir(e,t){return new tl({check:"less_than",...P(t),value:e,inclusive:!1})}function st(e,t){return new tl({check:"less_than",...P(t),value:e,inclusive:!0})}function ar(e,t){return new rl({check:"greater_than",...P(t),value:e,inclusive:!1})}function We(e,t){return new rl({check:"greater_than",...P(t),value:e,inclusive:!0})}function Nl(e){return ar(0,e)}function Pl(e){return ir(0,e)}function Cl(e){return st(0,e)}function jl(e){return We(0,e)}function Kr(e,t){return new Uh({check:"multiple_of",...P(t),value:e})}function lo(e,t){return new Fh({check:"max_size",...P(t),maximum:e})}function Yr(e,t){return new qh({check:"min_size",...P(t),minimum:e})}function Qi(e,t){return new Vh({check:"size_equals",...P(t),size:e})}function co(e,t){return new Bh({check:"max_length",...P(t),maximum:e})}function br(e,t){return new Jh({check:"min_length",...P(t),minimum:e})}function po(e,t){return new Wh({check:"length_equals",...P(t),length:e})}function Xi(e,t){return new Hh({check:"string_format",format:"regex",...P(t),pattern:e})}function ea(e){return new Gh({check:"string_format",format:"lowercase",...P(e)})}function ta(e){return new Kh({check:"string_format",format:"uppercase",...P(e)})}function ra(e,t){return new Yh({check:"string_format",format:"includes",...P(t),includes:e})}function na(e,t){return new Qh({check:"string_format",format:"starts_with",...P(t),prefix:e})}function oa(e,t){return new Xh({check:"string_format",format:"ends_with",...P(t),suffix:e})}function Al(e,t,n){return new eg({check:"property",property:e,schema:t,...P(n)})}function ia(e,t){return new tg({check:"mime_type",mime:e,...P(t)})}function Ht(e){return new rg({check:"overwrite",tx:e})}function aa(e){return Ht(t=>t.normalize(e))}function sa(){return Ht(e=>e.trim())}function ua(){return Ht(e=>e.toLowerCase())}function la(){return Ht(e=>e.toUpperCase())}function ca(){return Ht(e=>Rm(e))}function ry(e,t,n){return new e({type:"array",element:t,...P(n)})}function iT(e,t,n){return new e({type:"union",options:t,...P(n)})}function aT(e,t,n){return new e({type:"union",options:t,inclusive:!1,...P(n)})}function sT(e,t,n,o){return new e({type:"union",options:n,discriminator:t,...P(o)})}function uT(e,t,n){return new e({type:"intersection",left:t,right:n})}function lT(e,t,n,o){const r=n instanceof X,i=r?o:n,a=r?n:null;return new e({type:"tuple",items:t,rest:a,...P(i)})}function cT(e,t,n,o){return new e({type:"record",keyType:t,valueType:n,...P(o)})}function dT(e,t,n,o){return new e({type:"map",keyType:t,valueType:n,...P(o)})}function pT(e,t,n){return new e({type:"set",valueType:t,...P(n)})}function fT(e,t,n){const o=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new e({type:"enum",entries:o,...P(n)})}function mT(e,t,n){return new e({type:"enum",entries:t,...P(n)})}function hT(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...P(n)})}function ny(e,t){return new e({type:"file",...P(t)})}function gT(e,t){return new e({type:"transform",transform:t})}function vT(e,t){return new e({type:"optional",innerType:t})}function yT(e,t){return new e({type:"nullable",innerType:t})}function bT(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():Wi(n)}})}function _T(e,t,n){return new e({type:"nonoptional",innerType:t,...P(n)})}function wT(e,t){return new e({type:"success",innerType:t})}function xT(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:()=>n})}function $T(e,t,n){return new e({type:"pipe",in:t,out:n})}function ST(e,t){return new e({type:"readonly",innerType:t})}function IT(e,t,n){return new e({type:"template_literal",parts:t,...P(n)})}function kT(e,t){return new e({type:"lazy",getter:t})}function ET(e,t){return new e({type:"promise",innerType:t})}function oy(e,t,n){const o=P(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function iy(e,t,n){return new e({type:"custom",check:"custom",fn:t,...P(n)})}function ay(e){const t=sy(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Hr(o,n.value,t._zod.def));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(Hr(r))}},e(n.value,n)));return t}function sy(e,t){const n=new Se({check:"custom",...P(t)});return n._zod.check=e,n}function uy(e){const t=new Se({check:"describe"});return t._zod.onattach=[n=>{const o=wt.get(n)??{};wt.add(n,{...o,description:e})}],t._zod.check=()=>{},t}function ly(e){const t=new Se({check:"meta"});return t._zod.onattach=[n=>{const o=wt.get(n)??{};wt.add(n,{...o,...e})}],t._zod.check=()=>{},t}function cy(e,t){const n=P(t);let o=n.truthy??["true","1","yes","on","y","enabled"],r=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(o=o.map(p=>typeof p=="string"?p.toLowerCase():p),r=r.map(p=>typeof p=="string"?p.toLowerCase():p));const i=new Set(o),a=new Set(r),s=e.Codec??ul,l=e.Boolean??il,u=e.String??uo,c=new u({type:"string",error:n.error}),d=new l({type:"boolean",error:n.error}),f=new s({type:"pipe",in:c,out:d,transform:((p,g)=>{let h=p;return n.case!=="sensitive"&&(h=h.toLowerCase()),i.has(h)?!0:a.has(h)?!1:(g.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...a],input:g.value,inst:f,continue:!1}),{})}),reverseTransform:((p,g)=>p===!0?o[0]||"true":r[0]||"false"),error:n.error});return f}function fo(e,t,n,o={}){const r=P(o),i={...P(o),check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:s=>n.test(s),...r};return n instanceof RegExp&&(i.pattern=n),new e(i)}function Qr(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??wt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function he(e,t,n={path:[],schemaPath:[]}){var o;const r=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const c={...n,schemaPath:[...n.schemaPath,e],path:n.path},d=e._zod.parent;if(d)a.ref=d,he(d,t,c),t.seen.get(d).isParent=!0;else if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,c);else{const f=a.schema,p=t.processors[r.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);p(e,t,f,c)}}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),t.io==="input"&&Ve(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((o=a.schema).default??(o.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Xr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const c=e.external.registry.get(i[0])?.id,d=e.external.uri??(p=>p);if(c)return{ref:d(c)};const f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${d("__shared")}#/${a}/${f}`}}if(i[1]===n)return{ref:"#"};const l=`#/${a}/`,u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},r=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:s,defId:l}=o(i);a.def={...a.schema},l&&(a.defId=l);const u=a.schema;for(const c in u)delete u[c];u.$ref=s};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
28
28
|
|
|
29
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){r(i);continue}if(e.external){const l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){r(i);continue}}if(e.metadataRegistry.get(i[0])?.id){r(i);continue}if(a.cycle){r(i);continue}if(a.count>1&&e.reused==="ref"){r(i);continue}}}function Xr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=a=>{const s=e.seen.get(a),l=s.def??s.schema,u={...l};if(s.ref===null)return;const c=s.ref;if(s.ref=null,c){o(c);const d=e.seen.get(c).schema;d.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(d)):(Object.assign(l,d),Object.assign(l,u))}s.isParent||e.override({zodSchema:a,jsonSchema:l,path:s.path??[]})};for(const a of[...e.seen.entries()].reverse())o(a[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}Object.assign(r,n.def??n.schema);const i=e.external?.defs??{};for(const a of e.seen.entries()){const s=a[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Pn(t,"input"),output:Pn(t,"output")}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ve(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return Ve(o.element,n);if(o.type==="set")return Ve(o.valueType,n);if(o.type==="lazy")return Ve(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return Ve(o.innerType,n);if(o.type==="intersection")return Ve(o.left,n)||Ve(o.right,n);if(o.type==="record"||o.type==="map")return Ve(o.keyType,n)||Ve(o.valueType,n);if(o.type==="pipe")return Ve(o.in,n)||Ve(o.out,n);if(o.type==="object"){for(const r in o.shape)if(Ve(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(Ve(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(Ve(r,n))return!0;return!!(o.rest&&Ve(o.rest,n))}return!1}const cy=(e,t={})=>n=>{const o=Yr({...n,processors:t});return me(e,o),Qr(o,e),Xr(o,e)},Pn=(e,t)=>n=>{const{libraryOptions:o,target:r}=n??{},i=Yr({...o??{},target:r,io:t,processors:{}});return me(e,i),Qr(i,e),Xr(i,e)},$O={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},dy=(e,t,n,o)=>{const r=n;r.type="string";const{minimum:i,maximum:a,format:s,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(r.minLength=i),typeof a=="number"&&(r.maxLength=a),s&&(r.format=$O[s]??s,r.format===""&&delete r.format),u&&(r.contentEncoding=u),l&&l.size>0){const c=[...l];c.length===1?r.pattern=c[0].source:c.length>1&&(r.allOf=[...c.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},fy=(e,t,n,o)=>{const r=n,{minimum:i,maximum:a,format:s,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:c}=e._zod.bag;typeof s=="string"&&s.includes("int")?r.type="integer":r.type="number",typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=c,r.exclusiveMinimum=!0):r.exclusiveMinimum=c),typeof i=="number"&&(r.minimum=i,typeof c=="number"&&t.target!=="draft-04"&&(c>=i?delete r.minimum:delete r.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=u,r.exclusiveMaximum=!0):r.exclusiveMaximum=u),typeof a=="number"&&(r.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete r.maximum:delete r.exclusiveMaximum)),typeof l=="number"&&(r.multipleOf=l)},py=(e,t,n,o)=>{n.type="boolean"},my=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},hy=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},gy=(e,t,n,o)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},vy=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},yy=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},by=(e,t,n,o)=>{n.not={}},_y=(e,t,n,o)=>{},wy=(e,t,n,o)=>{},xy=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},$y=(e,t,n,o)=>{const r=e._zod.def,i=Mu(r.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},Sy=(e,t,n,o)=>{const r=e._zod.def,i=[];for(const a of r.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),i.every(a=>typeof a=="boolean")&&(n.type="boolean"),i.every(a=>a===null)&&(n.type="null"),n.enum=i},Iy=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},ky=(e,t,n,o)=>{const r=n,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=i.source},Ey=(e,t,n,o)=>{const r=n,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:l}=e._zod.bag;a!==void 0&&(i.minLength=a),s!==void 0&&(i.maxLength=s),l?l.length===1?(i.contentMediaType=l[0],Object.assign(r,i)):r.anyOf=l.map(u=>({...i,contentMediaType:u})):Object.assign(r,i)},Oy=(e,t,n,o)=>{n.type="boolean"},Ty=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Ny=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Py=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Cy=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},jy=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Ay=(e,t,n,o)=>{const r=n,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(r.minItems=a),typeof s=="number"&&(r.maxItems=s),r.type="array",r.items=me(i.element,t,{...o,path:[...o.path,"items"]})},Ry=(e,t,n,o)=>{const r=n,i=e._zod.def;r.type="object",r.properties={};const a=i.shape;for(const u in a)r.properties[u]=me(a[u],t,{...o,path:[...o.path,"properties",u]});const s=new Set(Object.keys(a)),l=new Set([...s].filter(u=>{const c=i.shape[u]._zod;return t.io==="input"?c.optin===void 0:c.optout===void 0}));l.size>0&&(r.required=Array.from(l)),i.catchall?._zod.def.type==="never"?r.additionalProperties=!1:i.catchall?i.catchall&&(r.additionalProperties=me(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},Cl=(e,t,n,o)=>{const r=e._zod.def,i=r.inclusive===!1,a=r.options.map((s,l)=>me(s,t,{...o,path:[...o.path,i?"oneOf":"anyOf",l]}));i?n.oneOf=a:n.anyOf=a},zy=(e,t,n,o)=>{const r=e._zod.def,i=me(r.left,t,{...o,path:[...o.path,"allOf",0]}),a=me(r.right,t,{...o,path:[...o.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,l=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]];n.allOf=l},My=(e,t,n,o)=>{const r=n,i=e._zod.def;r.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=i.items.map((p,f)=>me(p,t,{...o,path:[...o.path,a,f]})),u=i.rest?me(i.rest,t,{...o,path:[...o.path,s,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;t.target==="draft-2020-12"?(r.prefixItems=l,u&&(r.items=u)):t.target==="openapi-3.0"?(r.items={anyOf:l},u&&r.items.anyOf.push(u),r.minItems=l.length,u||(r.maxItems=l.length)):(r.items=l,u&&(r.additionalItems=u));const{minimum:c,maximum:d}=e._zod.bag;typeof c=="number"&&(r.minItems=c),typeof d=="number"&&(r.maxItems=d)},Dy=(e,t,n,o)=>{const r=n,i=e._zod.def;r.type="object",(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=me(i.keyType,t,{...o,path:[...o.path,"propertyNames"]})),r.additionalProperties=me(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})},Uy=(e,t,n,o)=>{const r=e._zod.def,i=me(r.innerType,t,o),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=r.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Ly=(e,t,n,o)=>{const r=e._zod.def;me(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType},Zy=(e,t,n,o)=>{const r=e._zod.def;me(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},Fy=(e,t,n,o)=>{const r=e._zod.def;me(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},qy=(e,t,n,o)=>{const r=e._zod.def;me(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType;let a;try{a=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},Vy=(e,t,n,o)=>{const r=e._zod.def,i=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;me(i,t,o);const a=t.seen.get(e);a.ref=i},By=(e,t,n,o)=>{const r=e._zod.def;me(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType,n.readOnly=!0},Jy=(e,t,n,o)=>{const r=e._zod.def;me(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType},Wy=(e,t,n,o)=>{const r=e._zod.def;me(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType},Hy=(e,t,n,o)=>{const r=e._zod.innerType;me(r,t,o);const i=t.seen.get(e);i.ref=r},Ks={string:dy,number:fy,boolean:py,bigint:my,symbol:hy,null:gy,undefined:vy,void:yy,never:by,any:_y,unknown:wy,date:xy,enum:$y,literal:Sy,nan:Iy,template_literal:ky,file:Ey,success:Oy,custom:Ty,function:Ny,transform:Py,map:Cy,set:jy,array:Ay,object:Ry,union:Cl,intersection:zy,tuple:My,record:Dy,nullable:Uy,nonoptional:Ly,default:Zy,prefault:Fy,catch:qy,pipe:Vy,readonly:By,promise:Jy,optional:Wy,lazy:Hy};function ua(e,t){if("_idmap"in e){const o=e,r=Yr({...t,processors:Ks}),i={};for(const l of o._idmap.entries()){const[u,c]=l;me(c,r)}const a={},s={registry:o,uri:t?.uri,defs:i};r.external=s;for(const l of o._idmap.entries()){const[u,c]=l;Qr(r,c),a[u]=Xr(r,c)}if(Object.keys(i).length>0){const l=r.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:i}}return{schemas:a}}const n=Yr({...t,processors:Ks});return me(e,n),Qr(n,e),Xr(n,e)}class SO{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=Yr({processors:Ks,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return me(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),Qr(this.ctx,t);const o=Xr(this.ctx,t),{"~standard":r,...i}=o;return i}}const IO=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),kO=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:zg,$ZodArray:Zg,$ZodAsyncError:gr,$ZodBase64:Sg,$ZodBase64URL:kg,$ZodBigInt:nl,$ZodBigIntFormat:Cg,$ZodBoolean:rl,$ZodCIDRv4:xg,$ZodCIDRv6:$g,$ZodCUID:cg,$ZodCUID2:dg,$ZodCatch:uv,$ZodCheck:Se,$ZodCheckBigIntFormat:Lh,$ZodCheckEndsWith:Qh,$ZodCheckGreaterThan:Xu,$ZodCheckIncludes:Kh,$ZodCheckLengthEquals:Jh,$ZodCheckLessThan:Qu,$ZodCheckLowerCase:Hh,$ZodCheckMaxLength:Vh,$ZodCheckMaxSize:Zh,$ZodCheckMimeType:eg,$ZodCheckMinLength:Bh,$ZodCheckMinSize:Fh,$ZodCheckMultipleOf:Dh,$ZodCheckNumberFormat:Uh,$ZodCheckOverwrite:tg,$ZodCheckProperty:Xh,$ZodCheckRegex:Wh,$ZodCheckSizeEquals:qh,$ZodCheckStartsWith:Yh,$ZodCheckStringFormat:ao,$ZodCheckUpperCase:Gh,$ZodCodec:il,$ZodCustom:gv,$ZodCustomStringFormat:Ng,$ZodDate:Lg,$ZodDefault:ov,$ZodDiscriminatedUnion:Wg,$ZodE164:Eg,$ZodEmail:ag,$ZodEmoji:ug,$ZodEncodeError:Fi,$ZodEnum:Qg,$ZodError:Uu,$ZodFile:ev,$ZodFunction:pv,$ZodGUID:og,$ZodIPv4:bg,$ZodIPv6:_g,$ZodISODate:gg,$ZodISODateTime:hg,$ZodISODuration:yg,$ZodISOTime:vg,$ZodIntersection:Hg,$ZodJWT:Tg,$ZodKSUID:mg,$ZodLazy:hv,$ZodLiteral:Xg,$ZodMAC:wg,$ZodMap:Kg,$ZodNaN:lv,$ZodNanoID:lg,$ZodNever:Dg,$ZodNonOptional:av,$ZodNull:Rg,$ZodNullable:nv,$ZodNumber:tl,$ZodNumberFormat:Pg,$ZodObject:Vg,$ZodObjectJIT:Bg,$ZodOptional:rv,$ZodPipe:cv,$ZodPrefault:iv,$ZodPromise:mv,$ZodReadonly:dv,$ZodRealError:nt,$ZodRecord:Gg,$ZodRegistry:$v,$ZodSet:Yg,$ZodString:so,$ZodStringFormat:he,$ZodSuccess:sv,$ZodSymbol:jg,$ZodTemplateLiteral:fv,$ZodTransform:tv,$ZodTuple:ol,$ZodType:X,$ZodULID:fg,$ZodURL:sg,$ZodUUID:ig,$ZodUndefined:Ag,$ZodUnion:Wi,$ZodUnknown:Mg,$ZodVoid:Ug,$ZodXID:pg,$ZodXor:Jg,$brand:Cm,$constructor:S,$input:xv,$output:wv,Doc:rg,JSONSchema:IO,JSONSchemaGenerator:SO,NEVER:zu,TimePrecision:Ev,_any:Hv,_array:ty,_base64:$l,_base64url:Sl,_bigint:Zv,_boolean:Uv,_catch:vO,_check:ay,_cidrv4:wl,_cidrv6:xl,_coercedBigint:Fv,_coercedBoolean:Lv,_coercedDate:Xv,_coercedNumber:jv,_coercedString:Iv,_cuid:ml,_cuid2:hl,_custom:ny,_date:Qv,_decode:qu,_decodeAsync:Bu,_default:mO,_discriminatedUnion:rO,_e164:Il,_email:sl,_emoji:fl,_encode:Fu,_encodeAsync:Vu,_endsWith:ta,_enum:uO,_file:ry,_float32:Rv,_float64:zv,_gt:ir,_gte:We,_guid:fi,_includes:Xi,_int:Av,_int32:Mv,_int64:qv,_intersection:nO,_ipv4:bl,_ipv6:_l,_isoDate:Tv,_isoDateTime:Ov,_isoDuration:Pv,_isoTime:Nv,_jwt:kl,_ksuid:yl,_lazy:wO,_length:co,_literal:cO,_lowercase:Yi,_lt:or,_lte:ut,_mac:kv,_map:aO,_max:ut,_maxLength:lo,_maxSize:uo,_mime:ra,_min:We,_minLength:yr,_minSize:Kr,_multipleOf:Gr,_nan:ey,_nanoid:pl,_nativeEnum:lO,_negative:Ol,_never:Kv,_nonnegative:Nl,_nonoptional:hO,_nonpositive:Tl,_normalize:na,_null:Wv,_nullable:pO,_number:Cv,_optional:fO,_overwrite:Gt,_parse:eo,_parseAsync:to,_pipe:yO,_positive:El,_promise:xO,_property:Pl,_readonly:bO,_record:iO,_refine:oy,_regex:Ki,_safeDecode:Wu,_safeDecodeAsync:Gu,_safeEncode:Ju,_safeEncodeAsync:Hu,_safeParse:ro,_safeParseAsync:no,_set:sO,_size:Gi,_slugify:sa,_startsWith:ea,_string:Sv,_stringFormat:fo,_stringbool:ly,_success:gO,_superRefine:iy,_symbol:Bv,_templateLiteral:_O,_toLowerCase:ia,_toUpperCase:aa,_transform:dO,_trim:oa,_tuple:oO,_uint32:Dv,_uint64:Vv,_ulid:gl,_undefined:Jv,_union:eO,_unknown:Gv,_uppercase:Qi,_url:Hi,_uuid:ul,_uuidv4:ll,_uuidv6:cl,_uuidv7:dl,_void:Yv,_xid:vl,_xor:tO,clone:ft,config:De,createStandardJSONSchemaMethod:Pn,createToJSONSchemaMethod:cy,decode:RI,decodeAsync:MI,describe:sy,encode:AI,encodeAsync:zI,extractDefs:Qr,finalize:Xr,flattenError:Lu,formatError:Zu,globalConfig:ui,globalRegistry:xt,initializeContext:Yr,isValidBase64:el,isValidBase64URL:Ig,isValidJWT:Og,locales:_v,meta:uy,parse:Ws,parseAsync:Hs,prettifyError:Xm,process:me,regexes:Yu,registry:al,safeDecode:UI,safeDecodeAsync:ZI,safeEncode:DI,safeEncodeAsync:LI,safeParse:eh,safeParseAsync:th,toDotPath:Qm,toJSONSchema:ua,treeifyError:Ym,util:Gm,version:ng},Symbol.toStringTag,{value:"Module"})),EO=Object.freeze(Object.defineProperty({__proto__:null,endsWith:ta,gt:ir,gte:We,includes:Xi,length:co,lowercase:Yi,lt:or,lte:ut,maxLength:lo,maxSize:uo,mime:ra,minLength:yr,minSize:Kr,multipleOf:Gr,negative:Ol,nonnegative:Nl,nonpositive:Tl,normalize:na,overwrite:Gt,positive:El,property:Pl,regex:Ki,size:Gi,slugify:sa,startsWith:ea,toLowerCase:ia,toUpperCase:aa,trim:oa,uppercase:Qi},Symbol.toStringTag,{value:"Module"})),jl=S("ZodISODateTime",(e,t)=>{hg.init(e,t),ge.init(e,t)});function Gy(e){return Ov(jl,e)}const Al=S("ZodISODate",(e,t)=>{gg.init(e,t),ge.init(e,t)});function Ky(e){return Tv(Al,e)}const Rl=S("ZodISOTime",(e,t)=>{vg.init(e,t),ge.init(e,t)});function Yy(e){return Nv(Rl,e)}const zl=S("ZodISODuration",(e,t)=>{yg.init(e,t),ge.init(e,t)});function Qy(e){return Pv(zl,e)}const Xy=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:Al,ZodISODateTime:jl,ZodISODuration:zl,ZodISOTime:Rl,date:Ky,datetime:Gy,duration:Qy,time:Yy},Symbol.toStringTag,{value:"Module"})),eb=(e,t)=>{Uu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Zu(e,n)},flatten:{value:n=>Lu(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,li,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,li,2)}},isEmpty:{get(){return e.issues.length===0}}})},OO=S("ZodError",eb),ot=S("ZodError",eb,{Parent:Error}),tb=eo(ot),rb=to(ot),nb=ro(ot),la=no(ot),ob=Fu(ot),ib=qu(ot),ab=Vu(ot),sb=Bu(ot),ub=Ju(ot),lb=Wu(ot),cb=Hu(ot),db=Gu(ot),te=S("ZodType",(e,t)=>(X.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Pn(e,"input"),output:Pn(e,"output")}}),e.toJSONSchema=cy(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Ht(t,{checks:[...t.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]})),e.clone=(n,o)=>ft(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>tb(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>nb(e,n,o),e.parseAsync=async(n,o)=>rb(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>la(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>ob(e,n,o),e.decode=(n,o)=>ib(e,n,o),e.encodeAsync=async(n,o)=>ab(e,n,o),e.decodeAsync=async(n,o)=>sb(e,n,o),e.safeEncode=(n,o)=>ub(e,n,o),e.safeDecode=(n,o)=>lb(e,n,o),e.safeEncodeAsync=async(n,o)=>cb(e,n,o),e.safeDecodeAsync=async(n,o)=>db(e,n,o),e.refine=(n,o)=>e.check(_c(n,o)),e.superRefine=n=>e.check(wc(n)),e.overwrite=n=>e.check(Gt(n)),e.optional=()=>ee(e),e.nullable=()=>jn(e),e.nullish=()=>ee(jn(e)),e.nonoptional=n=>lc(e,n),e.array=()=>R(e),e.or=n=>W([e,n]),e.and=n=>Kl(e,n),e.transform=n=>An(e,Ca(n)),e.default=n=>ac(e,n),e.prefault=n=>uc(e,n),e.catch=n=>fc(e,n),e.pipe=n=>An(e,n),e.readonly=()=>hc(e),e.describe=n=>{const o=e.clone();return xt.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return xt.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return xt.get(e);const o=e.clone();return xt.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),ca=S("_ZodString",(e,t)=>{so.init(e,t),te.init(e,t),e._zod.processJSONSchema=(o,r,i)=>dy(e,o,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(Ki(...o)),e.includes=(...o)=>e.check(Xi(...o)),e.startsWith=(...o)=>e.check(ea(...o)),e.endsWith=(...o)=>e.check(ta(...o)),e.min=(...o)=>e.check(yr(...o)),e.max=(...o)=>e.check(lo(...o)),e.length=(...o)=>e.check(co(...o)),e.nonempty=(...o)=>e.check(yr(1,...o)),e.lowercase=o=>e.check(Yi(o)),e.uppercase=o=>e.check(Qi(o)),e.trim=()=>e.check(oa()),e.normalize=(...o)=>e.check(na(...o)),e.toLowerCase=()=>e.check(ia()),e.toUpperCase=()=>e.check(aa()),e.slugify=()=>e.check(sa())}),po=S("ZodString",(e,t)=>{so.init(e,t),ca.init(e,t),e.email=n=>e.check(sl(da,n)),e.url=n=>e.check(Hi(mo,n)),e.jwt=n=>e.check(kl(Ea,n)),e.emoji=n=>e.check(fl(fa,n)),e.guid=n=>e.check(fi(Cn,n)),e.uuid=n=>e.check(ul(jt,n)),e.uuidv4=n=>e.check(ll(jt,n)),e.uuidv6=n=>e.check(cl(jt,n)),e.uuidv7=n=>e.check(dl(jt,n)),e.nanoid=n=>e.check(pl(pa,n)),e.guid=n=>e.check(fi(Cn,n)),e.cuid=n=>e.check(ml(ma,n)),e.cuid2=n=>e.check(hl(ha,n)),e.ulid=n=>e.check(gl(ga,n)),e.base64=n=>e.check($l($a,n)),e.base64url=n=>e.check(Sl(Ia,n)),e.xid=n=>e.check(vl(va,n)),e.ksuid=n=>e.check(yl(ya,n)),e.ipv4=n=>e.check(bl(ba,n)),e.ipv6=n=>e.check(_l(_a,n)),e.cidrv4=n=>e.check(wl(wa,n)),e.cidrv6=n=>e.check(xl(xa,n)),e.e164=n=>e.check(Il(ka,n)),e.datetime=n=>e.check(Gy(n)),e.date=n=>e.check(Ky(n)),e.time=n=>e.check(Yy(n)),e.duration=n=>e.check(Qy(n))});function w(e){return Sv(po,e)}const ge=S("ZodStringFormat",(e,t)=>{he.init(e,t),ca.init(e,t)}),da=S("ZodEmail",(e,t)=>{ag.init(e,t),ge.init(e,t)});function fb(e){return sl(da,e)}const Cn=S("ZodGUID",(e,t)=>{og.init(e,t),ge.init(e,t)});function pb(e){return fi(Cn,e)}const jt=S("ZodUUID",(e,t)=>{ig.init(e,t),ge.init(e,t)});function mb(e){return ul(jt,e)}function hb(e){return ll(jt,e)}function gb(e){return cl(jt,e)}function vb(e){return dl(jt,e)}const mo=S("ZodURL",(e,t)=>{sg.init(e,t),ge.init(e,t)});function yb(e){return Hi(mo,e)}function bb(e){return Hi(mo,{protocol:/^https?$/,hostname:_h,...P(e)})}const fa=S("ZodEmoji",(e,t)=>{ug.init(e,t),ge.init(e,t)});function _b(e){return fl(fa,e)}const pa=S("ZodNanoID",(e,t)=>{lg.init(e,t),ge.init(e,t)});function wb(e){return pl(pa,e)}const ma=S("ZodCUID",(e,t)=>{cg.init(e,t),ge.init(e,t)});function xb(e){return ml(ma,e)}const ha=S("ZodCUID2",(e,t)=>{dg.init(e,t),ge.init(e,t)});function $b(e){return hl(ha,e)}const ga=S("ZodULID",(e,t)=>{fg.init(e,t),ge.init(e,t)});function Sb(e){return gl(ga,e)}const va=S("ZodXID",(e,t)=>{pg.init(e,t),ge.init(e,t)});function Ib(e){return vl(va,e)}const ya=S("ZodKSUID",(e,t)=>{mg.init(e,t),ge.init(e,t)});function kb(e){return yl(ya,e)}const ba=S("ZodIPv4",(e,t)=>{bg.init(e,t),ge.init(e,t)});function Eb(e){return bl(ba,e)}const Ml=S("ZodMAC",(e,t)=>{wg.init(e,t),ge.init(e,t)});function Ob(e){return kv(Ml,e)}const _a=S("ZodIPv6",(e,t)=>{_g.init(e,t),ge.init(e,t)});function Tb(e){return _l(_a,e)}const wa=S("ZodCIDRv4",(e,t)=>{xg.init(e,t),ge.init(e,t)});function Nb(e){return wl(wa,e)}const xa=S("ZodCIDRv6",(e,t)=>{$g.init(e,t),ge.init(e,t)});function Pb(e){return xl(xa,e)}const $a=S("ZodBase64",(e,t)=>{Sg.init(e,t),ge.init(e,t)});function Sa(e){return $l($a,e)}const Ia=S("ZodBase64URL",(e,t)=>{kg.init(e,t),ge.init(e,t)});function Cb(e){return Sl(Ia,e)}const ka=S("ZodE164",(e,t)=>{Eg.init(e,t),ge.init(e,t)});function jb(e){return Il(ka,e)}const Ea=S("ZodJWT",(e,t)=>{Tg.init(e,t),ge.init(e,t)});function Ab(e){return kl(Ea,e)}const sn=S("ZodCustomStringFormat",(e,t)=>{Ng.init(e,t),ge.init(e,t)});function Rb(e,t,n={}){return fo(sn,e,t,n)}function zb(e){return fo(sn,"hostname",bh,e)}function Mb(e){return fo(sn,"hex",zh,e)}function Db(e,t){const n=t?.enc??"hex",o=`${e}_${n}`,r=Yu[o];if(!r)throw new Error(`Unrecognized hash format: ${o}`);return fo(sn,o,r,t)}const ho=S("ZodNumber",(e,t)=>{tl.init(e,t),te.init(e,t),e._zod.processJSONSchema=(o,r,i)=>fy(e,o,r),e.gt=(o,r)=>e.check(ir(o,r)),e.gte=(o,r)=>e.check(We(o,r)),e.min=(o,r)=>e.check(We(o,r)),e.lt=(o,r)=>e.check(or(o,r)),e.lte=(o,r)=>e.check(ut(o,r)),e.max=(o,r)=>e.check(ut(o,r)),e.int=o=>e.check(pi(o)),e.safe=o=>e.check(pi(o)),e.positive=o=>e.check(ir(0,o)),e.nonnegative=o=>e.check(We(0,o)),e.negative=o=>e.check(or(0,o)),e.nonpositive=o=>e.check(ut(0,o)),e.multipleOf=(o,r)=>e.check(Gr(o,r)),e.step=(o,r)=>e.check(Gr(o,r)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function q(e){return Cv(ho,e)}const Er=S("ZodNumberFormat",(e,t)=>{Pg.init(e,t),ho.init(e,t)});function pi(e){return Av(Er,e)}function Ub(e){return Rv(Er,e)}function Lb(e){return zv(Er,e)}function Zb(e){return Mv(Er,e)}function Fb(e){return Dv(Er,e)}const go=S("ZodBoolean",(e,t)=>{rl.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>py(e,n,o)});function de(e){return Uv(go,e)}const vo=S("ZodBigInt",(e,t)=>{nl.init(e,t),te.init(e,t),e._zod.processJSONSchema=(o,r,i)=>my(e,o),e.gte=(o,r)=>e.check(We(o,r)),e.min=(o,r)=>e.check(We(o,r)),e.gt=(o,r)=>e.check(ir(o,r)),e.gte=(o,r)=>e.check(We(o,r)),e.min=(o,r)=>e.check(We(o,r)),e.lt=(o,r)=>e.check(or(o,r)),e.lte=(o,r)=>e.check(ut(o,r)),e.max=(o,r)=>e.check(ut(o,r)),e.positive=o=>e.check(ir(BigInt(0),o)),e.negative=o=>e.check(or(BigInt(0),o)),e.nonpositive=o=>e.check(ut(BigInt(0),o)),e.nonnegative=o=>e.check(We(BigInt(0),o)),e.multipleOf=(o,r)=>e.check(Gr(o,r));const n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function qb(e){return Zv(vo,e)}const Oa=S("ZodBigIntFormat",(e,t)=>{Cg.init(e,t),vo.init(e,t)});function Vb(e){return qv(Oa,e)}function Bb(e){return Vv(Oa,e)}const Dl=S("ZodSymbol",(e,t)=>{jg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>hy(e,n)});function Jb(e){return Bv(Dl,e)}const Ul=S("ZodUndefined",(e,t)=>{Ag.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>vy(e,n)});function Ll(e){return Jv(Ul,e)}const Zl=S("ZodNull",(e,t)=>{Rg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>gy(e,n,o)});function yo(e){return Wv(Zl,e)}const Fl=S("ZodAny",(e,t)=>{zg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>_y()});function Pe(){return Hv(Fl)}const ql=S("ZodUnknown",(e,t)=>{Mg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>wy()});function $e(){return Gv(ql)}const Vl=S("ZodNever",(e,t)=>{Dg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>by(e,n,o)});function Ta(e){return Kv(Vl,e)}const Bl=S("ZodVoid",(e,t)=>{Ug.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>yy(e,n)});function Wb(e){return Yv(Bl,e)}const Na=S("ZodDate",(e,t)=>{Lg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(o,r,i)=>xy(e,o),e.min=(o,r)=>e.check(We(o,r)),e.max=(o,r)=>e.check(ut(o,r));const n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});function Hb(e){return Qv(Na,e)}const Jl=S("ZodArray",(e,t)=>{Zg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ay(e,n,o,r),e.element=t.element,e.min=(n,o)=>e.check(yr(n,o)),e.nonempty=n=>e.check(yr(1,n)),e.max=(n,o)=>e.check(lo(n,o)),e.length=(n,o)=>e.check(co(n,o)),e.unwrap=()=>e.element});function R(e,t){return ty(Jl,e,t)}function Gb(e){const t=e._zod.def.shape;return cr(Object.keys(t))}const bo=S("ZodObject",(e,t)=>{Bg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ry(e,n,o,r),ne(e,"shape",()=>t.shape),e.keyof=()=>cr(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:$e()}),e.loose=()=>e.clone({...e._zod.def,catchall:$e()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ta()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Fm(e,n),e.safeExtend=n=>qm(e,n),e.merge=n=>Vm(e,n),e.pick=n=>Lm(e,n),e.omit=n=>Zm(e,n),e.partial=(...n)=>Bm(ja,e,n[0]),e.required=(...n)=>Jm(Aa,e,n[0])});function E(e,t){const n={type:"object",shape:e??{},...P(t)};return new bo(n)}function be(e,t){return new bo({type:"object",shape:e,catchall:Ta(),...P(t)})}function tr(e,t){return new bo({type:"object",shape:e,catchall:$e(),...P(t)})}const _o=S("ZodUnion",(e,t)=>{Wi.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Cl(e,n,o,r),e.options=t.options});function W(e,t){return new _o({type:"union",options:e,...P(t)})}const Wl=S("ZodXor",(e,t)=>{_o.init(e,t),Jg.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Cl(e,n,o,r),e.options=t.options});function Kb(e,t){return new Wl({type:"union",options:e,inclusive:!1,...P(t)})}const Hl=S("ZodDiscriminatedUnion",(e,t)=>{_o.init(e,t),Wg.init(e,t)});function Pa(e,t,n){return new Hl({type:"union",options:t,discriminator:e,...P(n)})}const Gl=S("ZodIntersection",(e,t)=>{Hg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>zy(e,n,o,r)});function Kl(e,t){return new Gl({type:"intersection",left:e,right:t})}const Yl=S("ZodTuple",(e,t)=>{ol.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>My(e,n,o,r),e.rest=n=>e.clone({...e._zod.def,rest:n})});function Ql(e,t,n){const o=t instanceof X,r=o?n:t,i=o?t:null;return new Yl({type:"tuple",items:e,rest:i,...P(r)})}const wo=S("ZodRecord",(e,t)=>{Gg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Dy(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function Xe(e,t,n){return new wo({type:"record",keyType:e,valueType:t,...P(n)})}function Yb(e,t,n){const o=ft(e);return o._zod.values=void 0,new wo({type:"record",keyType:o,valueType:t,...P(n)})}function Qb(e,t,n){return new wo({type:"record",keyType:e,valueType:t,mode:"loose",...P(n)})}const Xl=S("ZodMap",(e,t)=>{Kg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Cy(e,n),e.keyType=t.keyType,e.valueType=t.valueType});function Xb(e,t,n){return new Xl({type:"map",keyType:e,valueType:t,...P(n)})}const ec=S("ZodSet",(e,t)=>{Yg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>jy(e,n),e.min=(...n)=>e.check(Kr(...n)),e.nonempty=n=>e.check(Kr(1,n)),e.max=(...n)=>e.check(uo(...n)),e.size=(...n)=>e.check(Gi(...n))});function e_(e,t){return new ec({type:"set",valueType:e,...P(t)})}const en=S("ZodEnum",(e,t)=>{Qg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(o,r,i)=>$y(e,o,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{const i={};for(const a of o)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new en({...t,checks:[],...P(r),entries:i})},e.exclude=(o,r)=>{const i={...t.entries};for(const a of o)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new en({...t,checks:[],...P(r),entries:i})}});function cr(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new en({type:"enum",entries:n,...P(t)})}function t_(e,t){return new en({type:"enum",entries:e,...P(t)})}const tc=S("ZodLiteral",(e,t)=>{Xg.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Sy(e,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function C(e,t){return new tc({type:"literal",values:Array.isArray(e)?e:[e],...P(t)})}const rc=S("ZodFile",(e,t)=>{ev.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ey(e,n,o),e.min=(n,o)=>e.check(Kr(n,o)),e.max=(n,o)=>e.check(uo(n,o)),e.mime=(n,o)=>e.check(ra(Array.isArray(n)?n:[n],o))});function r_(e){return ry(rc,e)}const nc=S("ZodTransform",(e,t)=>{tv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Py(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Fi(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Wr(i,n.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(Wr(a))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(i=>(n.value=i,n)):(n.value=r,n)}});function Ca(e){return new nc({type:"transform",transform:e})}const ja=S("ZodOptional",(e,t)=>{rv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Wy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function ee(e){return new ja({type:"optional",innerType:e})}const oc=S("ZodNullable",(e,t)=>{nv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Uy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function jn(e){return new oc({type:"nullable",innerType:e})}function n_(e){return ee(jn(e))}const ic=S("ZodDefault",(e,t)=>{ov.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Zy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ac(e,t){return new ic({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Vi(t)}})}const sc=S("ZodPrefault",(e,t)=>{iv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Fy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function uc(e,t){return new sc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Vi(t)}})}const Aa=S("ZodNonOptional",(e,t)=>{av.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ly(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function lc(e,t){return new Aa({type:"nonoptional",innerType:e,...P(t)})}const cc=S("ZodSuccess",(e,t)=>{sv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Oy(e,n,o),e.unwrap=()=>e._zod.def.innerType});function o_(e){return new cc({type:"success",innerType:e})}const dc=S("ZodCatch",(e,t)=>{uv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>qy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function fc(e,t){return new dc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const pc=S("ZodNaN",(e,t)=>{lv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Iy(e,n)});function i_(e){return ey(pc,e)}const Ra=S("ZodPipe",(e,t)=>{cv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Vy(e,n,o,r),e.in=t.in,e.out=t.out});function An(e,t){return new Ra({type:"pipe",in:e,out:t})}const za=S("ZodCodec",(e,t)=>{Ra.init(e,t),il.init(e,t)});function a_(e,t,n){return new za({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}const mc=S("ZodReadonly",(e,t)=>{dv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>By(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function hc(e){return new mc({type:"readonly",innerType:e})}const gc=S("ZodTemplateLiteral",(e,t)=>{fv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ky(e,n,o)});function s_(e,t){return new gc({type:"template_literal",parts:e,...P(t)})}const vc=S("ZodLazy",(e,t)=>{hv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Hy(e,n,o,r),e.unwrap=()=>e._zod.def.getter()});function xo(e){return new vc({type:"lazy",getter:e})}const yc=S("ZodPromise",(e,t)=>{mv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Jy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function u_(e){return new yc({type:"promise",innerType:e})}const bc=S("ZodFunction",(e,t)=>{pv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ny(e,n)});function mi(e){return new bc({type:"function",input:Array.isArray(e?.input)?Ql(e?.input):e?.input??R($e()),output:e?.output??$e()})}const $o=S("ZodCustom",(e,t)=>{gv.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ty(e,n)});function l_(e){const t=new Se({check:"custom"});return t._zod.check=e,t}function So(e,t){return ny($o,e??(()=>!0),t)}function _c(e,t={}){return oy($o,e,t)}function wc(e){return iy(e)}const c_=sy,d_=uy;function zt(e,t={error:`Input not instance of ${e.name}`}){const n=new $o({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...P(t)});return n._zod.bag.Class=e,n}const f_=(...e)=>ly({Codec:za,Boolean:go,String:po},...e);function p_(e){const t=xo(()=>W([w(e),q(),de(),yo(),R(t),Xe(w(),t)]));return t}function m_(e,t){return An(Ca(e),t)}const TO=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:Fl,ZodArray:Jl,ZodBase64:$a,ZodBase64URL:Ia,ZodBigInt:vo,ZodBigIntFormat:Oa,ZodBoolean:go,ZodCIDRv4:wa,ZodCIDRv6:xa,ZodCUID:ma,ZodCUID2:ha,ZodCatch:dc,ZodCodec:za,ZodCustom:$o,ZodCustomStringFormat:sn,ZodDate:Na,ZodDefault:ic,ZodDiscriminatedUnion:Hl,ZodE164:ka,ZodEmail:da,ZodEmoji:fa,ZodEnum:en,ZodFile:rc,ZodFunction:bc,ZodGUID:Cn,ZodIPv4:ba,ZodIPv6:_a,ZodIntersection:Gl,ZodJWT:Ea,ZodKSUID:ya,ZodLazy:vc,ZodLiteral:tc,ZodMAC:Ml,ZodMap:Xl,ZodNaN:pc,ZodNanoID:pa,ZodNever:Vl,ZodNonOptional:Aa,ZodNull:Zl,ZodNullable:oc,ZodNumber:ho,ZodNumberFormat:Er,ZodObject:bo,ZodOptional:ja,ZodPipe:Ra,ZodPrefault:sc,ZodPromise:yc,ZodReadonly:mc,ZodRecord:wo,ZodSet:ec,ZodString:po,ZodStringFormat:ge,ZodSuccess:cc,ZodSymbol:Dl,ZodTemplateLiteral:gc,ZodTransform:nc,ZodTuple:Yl,ZodType:te,ZodULID:ga,ZodURL:mo,ZodUUID:jt,ZodUndefined:Ul,ZodUnion:_o,ZodUnknown:ql,ZodVoid:Bl,ZodXID:va,ZodXor:Wl,_ZodString:ca,_default:ac,_function:mi,any:Pe,array:R,base64:Sa,base64url:Cb,bigint:qb,boolean:de,catch:fc,check:l_,cidrv4:Nb,cidrv6:Pb,codec:a_,cuid:xb,cuid2:$b,custom:So,date:Hb,describe:c_,discriminatedUnion:Pa,e164:jb,email:fb,emoji:_b,enum:cr,file:r_,float32:Ub,float64:Lb,function:mi,guid:pb,hash:Db,hex:Mb,hostname:zb,httpUrl:bb,instanceof:zt,int:pi,int32:Zb,int64:Vb,intersection:Kl,ipv4:Eb,ipv6:Tb,json:p_,jwt:Ab,keyof:Gb,ksuid:kb,lazy:xo,literal:C,looseObject:tr,looseRecord:Qb,mac:Ob,map:Xb,meta:d_,nan:i_,nanoid:wb,nativeEnum:t_,never:Ta,nonoptional:lc,null:yo,nullable:jn,nullish:n_,number:q,object:E,optional:ee,partialRecord:Yb,pipe:An,prefault:uc,preprocess:m_,promise:u_,readonly:hc,record:Xe,refine:_c,set:e_,strictObject:be,string:w,stringFormat:Rb,stringbool:f_,success:o_,superRefine:wc,symbol:Jb,templateLiteral:s_,transform:Ca,tuple:Ql,uint32:Fb,uint64:Bb,ulid:Sb,undefined:Ll,union:W,unknown:$e,url:yb,uuid:mb,uuidv4:hb,uuidv6:gb,uuidv7:vb,void:Wb,xid:Ib,xor:Kb},Symbol.toStringTag,{value:"Module"})),h_={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function NO(e){De({customError:e})}function PO(){return De().customError}var Ys;Ys||(Ys={});const M={...TO,...EO,iso:Xy};function CO(e,t){const n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function jO(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");const n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;const o=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===o){const r=n[1];if(!r||!t.defs[r])throw new Error(`Reference not found: ${e}`);return t.defs[r]}throw new Error(`Reference not found: ${e}`)}function g_(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return M.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){const r=e.$ref;if(t.refs.has(r))return t.refs.get(r);if(t.processing.has(r))return M.lazy(()=>{if(!t.refs.has(r))throw new Error(`Circular reference not resolved: ${r}`);return t.refs.get(r)});t.processing.add(r);const i=jO(r,t),a=Me(i,t);return t.refs.set(r,a),t.processing.delete(r),a}if(e.enum!==void 0){const r=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&r.length===1&&r[0]===null)return M.null();if(r.length===0)return M.never();if(r.length===1)return M.literal(r[0]);if(r.every(a=>typeof a=="string"))return M.enum(r);const i=r.map(a=>M.literal(a));return i.length<2?i[0]:M.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return M.literal(e.const);const n=e.type;if(Array.isArray(n)){const r=n.map(i=>{const a={...e,type:i};return g_(a,t)});return r.length===0?M.never():r.length===1?r[0]:M.union(r)}if(!n)return M.any();let o;switch(n){case"string":{let r=M.string();if(e.format){const i=e.format;i==="email"?r=r.check(M.email()):i==="uri"||i==="uri-reference"?r=r.check(M.url()):i==="uuid"||i==="guid"?r=r.check(M.uuid()):i==="date-time"?r=r.check(M.iso.datetime()):i==="date"?r=r.check(M.iso.date()):i==="time"?r=r.check(M.iso.time()):i==="duration"?r=r.check(M.iso.duration()):i==="ipv4"?r=r.check(M.ipv4()):i==="ipv6"?r=r.check(M.ipv6()):i==="mac"?r=r.check(M.mac()):i==="cidr"?r=r.check(M.cidrv4()):i==="cidr-v6"?r=r.check(M.cidrv6()):i==="base64"?r=r.check(M.base64()):i==="base64url"?r=r.check(M.base64url()):i==="e164"?r=r.check(M.e164()):i==="jwt"?r=r.check(M.jwt()):i==="emoji"?r=r.check(M.emoji()):i==="nanoid"?r=r.check(M.nanoid()):i==="cuid"?r=r.check(M.cuid()):i==="cuid2"?r=r.check(M.cuid2()):i==="ulid"?r=r.check(M.ulid()):i==="xid"?r=r.check(M.xid()):i==="ksuid"&&(r=r.check(M.ksuid()))}typeof e.minLength=="number"&&(r=r.min(e.minLength)),typeof e.maxLength=="number"&&(r=r.max(e.maxLength)),e.pattern&&(r=r.regex(new RegExp(e.pattern))),o=r;break}case"number":case"integer":{let r=n==="integer"?M.number().int():M.number();typeof e.minimum=="number"&&(r=r.min(e.minimum)),typeof e.maximum=="number"&&(r=r.max(e.maximum)),typeof e.exclusiveMinimum=="number"?r=r.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(r=r.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?r=r.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(r=r.lt(e.maximum)),typeof e.multipleOf=="number"&&(r=r.multipleOf(e.multipleOf)),o=r;break}case"boolean":{o=M.boolean();break}case"null":{o=M.null();break}case"object":{const r={},i=e.properties||{},a=new Set(e.required||[]);for(const[l,u]of Object.entries(i)){const c=Me(u,t);r[l]=a.has(l)?c:c.optional()}if(e.propertyNames){const l=Me(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?Me(e.additionalProperties,t):M.any();if(Object.keys(r).length===0){o=M.record(l,u);break}const c=M.object(r).passthrough(),d=M.looseRecord(l,u);o=M.intersection(c,d);break}if(e.patternProperties){const l=e.patternProperties,u=Object.keys(l),c=[];for(const p of u){const f=Me(l[p],t),g=M.string().regex(new RegExp(p));c.push(M.looseRecord(g,f))}const d=[];if(Object.keys(r).length>0&&d.push(M.object(r).passthrough()),d.push(...c),d.length===0)o=M.object({}).passthrough();else if(d.length===1)o=d[0];else{let p=M.intersection(d[0],d[1]);for(let f=2;f<d.length;f++)p=M.intersection(p,d[f]);o=p}break}const s=M.object(r);e.additionalProperties===!1?o=s.strict():typeof e.additionalProperties=="object"?o=s.catchall(Me(e.additionalProperties,t)):o=s.passthrough();break}case"array":{const r=e.prefixItems,i=e.items;if(r&&Array.isArray(r)){const a=r.map(l=>Me(l,t)),s=i&&typeof i=="object"&&!Array.isArray(i)?Me(i,t):void 0;s?o=M.tuple(a).rest(s):o=M.tuple(a),typeof e.minItems=="number"&&(o=o.check(M.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(M.maxLength(e.maxItems)))}else if(Array.isArray(i)){const a=i.map(l=>Me(l,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?Me(e.additionalItems,t):void 0;s?o=M.tuple(a).rest(s):o=M.tuple(a),typeof e.minItems=="number"&&(o=o.check(M.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(M.maxLength(e.maxItems)))}else if(i!==void 0){const a=Me(i,t);let s=M.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),o=s}else o=M.array(M.any());break}default:throw new Error(`Unsupported type: ${n}`)}return e.description&&(o=o.describe(e.description)),e.default!==void 0&&(o=o.default(e.default)),o}function Me(e,t){if(typeof e=="boolean")return e?M.any():M.never();let n=g_(e,t);const o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){const r=e.anyOf.map(a=>Me(a,t)),i=M.union(r);n=o?M.intersection(n,i):i}if(e.oneOf&&Array.isArray(e.oneOf)){const r=e.oneOf.map(a=>Me(a,t)),i=M.xor(r);n=o?M.intersection(n,i):i}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=o?n:M.any();else{let r=o?n:Me(e.allOf[0],t);const i=o?0:1;for(let a=i;a<e.allOf.length;a++)r=M.intersection(r,Me(e.allOf[a],t));n=r}return e.nullable===!0&&t.version==="openapi-3.0"&&(n=M.nullable(n)),e.readOnly===!0&&(n=M.readonly(n)),n}function AO(e,t){if(typeof e=="boolean")return e?M.any():M.never();const n=CO(e,t?.defaultTarget),o=e.$defs||e.definitions||{};return Me(e,{version:n,defs:o,refs:new Map,processing:new Set,rootSchema:e})}function RO(e){return Iv(po,e)}function zO(e){return jv(ho,e)}function MO(e){return Lv(go,e)}function DO(e){return Fv(vo,e)}function UO(e){return Xv(Na,e)}const LO=Object.freeze(Object.defineProperty({__proto__:null,bigint:DO,boolean:MO,date:UO,number:zO,string:RO},Symbol.toStringTag,{value:"Module"}));De(vv());const hi=Object.freeze(Object.defineProperty({__proto__:null,$brand:Cm,$input:xv,$output:wv,NEVER:zu,TimePrecision:Ev,ZodAny:Fl,ZodArray:Jl,ZodBase64:$a,ZodBase64URL:Ia,ZodBigInt:vo,ZodBigIntFormat:Oa,ZodBoolean:go,ZodCIDRv4:wa,ZodCIDRv6:xa,ZodCUID:ma,ZodCUID2:ha,ZodCatch:dc,ZodCodec:za,ZodCustom:$o,ZodCustomStringFormat:sn,ZodDate:Na,ZodDefault:ic,ZodDiscriminatedUnion:Hl,ZodE164:ka,ZodEmail:da,ZodEmoji:fa,ZodEnum:en,ZodError:OO,ZodFile:rc,get ZodFirstPartyTypeKind(){return Ys},ZodFunction:bc,ZodGUID:Cn,ZodIPv4:ba,ZodIPv6:_a,ZodISODate:Al,ZodISODateTime:jl,ZodISODuration:zl,ZodISOTime:Rl,ZodIntersection:Gl,ZodIssueCode:h_,ZodJWT:Ea,ZodKSUID:ya,ZodLazy:vc,ZodLiteral:tc,ZodMAC:Ml,ZodMap:Xl,ZodNaN:pc,ZodNanoID:pa,ZodNever:Vl,ZodNonOptional:Aa,ZodNull:Zl,ZodNullable:oc,ZodNumber:ho,ZodNumberFormat:Er,ZodObject:bo,ZodOptional:ja,ZodPipe:Ra,ZodPrefault:sc,ZodPromise:yc,ZodReadonly:mc,ZodRealError:ot,ZodRecord:wo,ZodSet:ec,ZodString:po,ZodStringFormat:ge,ZodSuccess:cc,ZodSymbol:Dl,ZodTemplateLiteral:gc,ZodTransform:nc,ZodTuple:Yl,ZodType:te,ZodULID:ga,ZodURL:mo,ZodUUID:jt,ZodUndefined:Ul,ZodUnion:_o,ZodUnknown:ql,ZodVoid:Bl,ZodXID:va,ZodXor:Wl,_ZodString:ca,_default:ac,_function:mi,any:Pe,array:R,base64:Sa,base64url:Cb,bigint:qb,boolean:de,catch:fc,check:l_,cidrv4:Nb,cidrv6:Pb,clone:ft,codec:a_,coerce:LO,config:De,core:kO,cuid:xb,cuid2:$b,custom:So,date:Hb,decode:ib,decodeAsync:sb,describe:c_,discriminatedUnion:Pa,e164:jb,email:fb,emoji:_b,encode:ob,encodeAsync:ab,endsWith:ta,enum:cr,file:r_,flattenError:Lu,float32:Ub,float64:Lb,formatError:Zu,fromJSONSchema:AO,function:mi,getErrorMap:PO,globalRegistry:xt,gt:ir,gte:We,guid:pb,hash:Db,hex:Mb,hostname:zb,httpUrl:bb,includes:Xi,instanceof:zt,int:pi,int32:Zb,int64:Vb,intersection:Kl,ipv4:Eb,ipv6:Tb,iso:Xy,json:p_,jwt:Ab,keyof:Gb,ksuid:kb,lazy:xo,length:co,literal:C,locales:_v,looseObject:tr,looseRecord:Qb,lowercase:Yi,lt:or,lte:ut,mac:Ob,map:Xb,maxLength:lo,maxSize:uo,meta:d_,mime:ra,minLength:yr,minSize:Kr,multipleOf:Gr,nan:i_,nanoid:wb,nativeEnum:t_,negative:Ol,never:Ta,nonnegative:Nl,nonoptional:lc,nonpositive:Tl,normalize:na,null:yo,nullable:jn,nullish:n_,number:q,object:E,optional:ee,overwrite:Gt,parse:tb,parseAsync:rb,partialRecord:Yb,pipe:An,positive:El,prefault:uc,preprocess:m_,prettifyError:Xm,promise:u_,property:Pl,readonly:hc,record:Xe,refine:_c,regex:Ki,regexes:Yu,registry:al,safeDecode:lb,safeDecodeAsync:db,safeEncode:ub,safeEncodeAsync:cb,safeParse:nb,safeParseAsync:la,set:e_,setErrorMap:NO,size:Gi,slugify:sa,startsWith:ea,strictObject:be,string:w,stringFormat:Rb,stringbool:f_,success:o_,superRefine:wc,symbol:Jb,templateLiteral:s_,toJSONSchema:ua,toLowerCase:ia,toUpperCase:aa,transform:Ca,treeifyError:Ym,trim:oa,tuple:Ql,uint32:Fb,uint64:Bb,ulid:Sb,undefined:Ll,union:W,unknown:$e,uppercase:Qi,url:yb,util:Gm,uuid:mb,uuidv4:hb,uuidv6:gb,uuidv7:vb,void:Wb,xid:Ib,xor:Kb},Symbol.toStringTag,{value:"Module"}));var Rn;(function(e){e.assertEqual=r=>{};function t(r){}e.assertIs=t;function n(r){throw new Error}e.assertNever=n,e.arrayToEnum=r=>{const i={};for(const a of r)i[a]=a;return i},e.getValidEnumValues=r=>{const i=e.objectKeys(r).filter(s=>typeof r[r[s]]!="number"),a={};for(const s of i)a[s]=r[s];return e.objectValues(a)},e.objectValues=r=>e.objectKeys(r).map(function(i){return r[i]}),e.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const i=[];for(const a in r)Object.prototype.hasOwnProperty.call(r,a)&&i.push(a);return i},e.find=(r,i)=>{for(const a of r)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function o(r,i=" | "){return r.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=o,e.jsonStringifyReplacer=(r,i)=>typeof i=="bigint"?i.toString():i})(Rn||(Rn={}));var Kd;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Kd||(Kd={}));Rn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Rn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class gi extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},o={_errors:[]},r=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(r);else if(a.code==="invalid_return_type")r(a.returnTypeError);else if(a.code==="invalid_arguments")r(a.argumentsError);else if(a.path.length===0)o._errors.push(n(a));else{let s=o,l=0;for(;l<a.path.length;){const u=a.path[l];l===a.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(n(a))):s[u]=s[u]||{_errors:[]},s=s[u],l++}}};return r(this),o}static assert(t){if(!(t instanceof gi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Rn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n=Object.create(null),o=[];for(const r of this.issues)if(r.path.length>0){const i=r.path[0];n[i]=n[i]||[],n[i].push(t(r))}else o.push(t(r));return{formErrors:o,fieldErrors:n}}get formErrors(){return this.flatten()}}gi.create=e=>new gi(e);var Yd;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(Yd||(Yd={}));var A;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(A||(A={}));var Io=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const r=()=>{const i=n.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=n[Math.random()*i|0];return a.join("")};if(e==null)return r;if(n.includes(o))throw new Zi({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${n}".`});return()=>`${e}${o}${r()}`},v_=Io();function Qd(e=globalThis){var t,n,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(n=e.process)==null?void 0:n.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function fr(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,o)=>{t[o.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,o]of e)o!=null&&(t[n.toLowerCase()]=o)}return t}function Xd(e,...t){const n=new Headers(fr(e)),o=n.get("user-agent")||"";return n.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}var ZO=/"__proto__"\s*:/,FO=/"constructor"\s*:/;function ef(e){const t=JSON.parse(e);return t===null||typeof t!="object"||ZO.test(e)===!1&&FO.test(e)===!1?t:qO(t)}function qO(e){let t=[e];for(;t.length;){const n=t;t=[];for(const o of n){if(Object.prototype.hasOwnProperty.call(o,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(o,"constructor")&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const r in o){const i=o[r];i&&typeof i=="object"&&t.push(i)}}}return e}function VO(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return ef(e)}try{return ef(e)}finally{Error.stackTraceLimit=t}}var vi=Symbol.for("vercel.ai.validator");function BO(e){return{[vi]:!0,validate:e}}function JO(e){return typeof e=="object"&&e!==null&&vi in e&&e[vi]===!0&&"validate"in e}function WO(e){let t;return()=>(t==null&&(t=e()),t)}function HO(e){return JO(e)?e:typeof e=="function"?e():GO(e)}function GO(e){return BO(async t=>{const n=await e["~standard"].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new qt({value:t,cause:n.issues})}})}async function tf({value:e,schema:t}){const n=await xc({value:e,schema:t});if(!n.success)throw qt.wrap({value:e,cause:n.error});return n.value}async function xc({value:e,schema:t}){const n=HO(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};const o=await n.validate(e);return o.success?{success:!0,value:o.value,rawValue:e}:{success:!1,error:qt.wrap({value:e,cause:o.error}),rawValue:e}}catch(o){return{success:!1,error:qt.wrap({value:e,cause:o}),rawValue:e}}}async function yi({text:e,schema:t}){try{const n=VO(e);return t==null?{success:!0,value:n,rawValue:n}:await xc({value:n,schema:t})}catch(n){return{success:!1,error:Br.isInstance(n)?n:new Br({text:e,cause:n}),rawValue:void 0}}}function KO({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Nn).pipeThrough(new TransformStream({async transform({data:n},o){n!=="[DONE]"&&o.enqueue(await yi({text:n,schema:t}))}}))}async function jr(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}function ei(e){if(e.type==="object"){e.additionalProperties=!1;const t=e.properties;if(t!=null)for(const n in t)t[n]=ei(t[n])}return e.type==="array"&&e.items!=null&&(Array.isArray(e.items)?e.items=e.items.map(t=>ei(t)):e.items=ei(e.items)),e}var YO=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")},QO=Symbol("Let zodToJsonSchema decide on which parser to use"),rf={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},XO=e=>typeof e=="string"?{...rf,name:e}:{...rf,...e};function et(){return{}}function eT(e,t){var n,o,r;const i={type:"array"};return(n=e.type)!=null&&n._def&&((r=(o=e.type)==null?void 0:o._def)==null?void 0:r.typeName)!==A.ZodAny&&(i.items=ue(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(i.minItems=e.minLength.value),e.maxLength&&(i.maxItems=e.maxLength.value),e.exactLength&&(i.minItems=e.exactLength.value,i.maxItems=e.exactLength.value),i}function tT(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function rT(){return{type:"boolean"}}function y_(e,t){return ue(e.type._def,t)}var nT=(e,t)=>ue(e.innerType._def,t);function b_(e,t,n){const o=n??t.dateStrategy;if(Array.isArray(o))return{anyOf:o.map((r,i)=>b_(e,t,r))};switch(o){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return oT(e)}}var oT=e=>{const t={type:"integer",format:"unix-time"};for(const n of e.checks)switch(n.kind){case"min":t.minimum=n.value;break;case"max":t.maximum=n.value;break}return t};function iT(e,t){return{...ue(e.innerType._def,t),default:e.defaultValue()}}function aT(e,t){return t.effectStrategy==="input"?ue(e.schema._def,t):et()}function sT(e){return{type:"string",enum:Array.from(e.values)}}var uT=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function lT(e,t){const n=[ue(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),ue(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(r=>!!r),o=[];return n.forEach(r=>{if(uT(r))o.push(...r.allOf);else{let i=r;if("additionalProperties"in r&&r.additionalProperties===!1){const{additionalProperties:a,...s}=r;i=s}o.push(i)}}),o.length?{allOf:o}:void 0}function cT(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var ps=void 0,gt={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:()=>(ps===void 0&&(ps=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ps),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function __(e,t){const n={type:"string"};if(e.checks)for(const o of e.checks)switch(o.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,o.value):o.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,o.value):o.value;break;case"email":switch(t.emailStrategy){case"format:email":vt(n,"email",o.message,t);break;case"format:idn-email":vt(n,"idn-email",o.message,t);break;case"pattern:zod":Fe(n,gt.email,o.message,t);break}break;case"url":vt(n,"uri",o.message,t);break;case"uuid":vt(n,"uuid",o.message,t);break;case"regex":Fe(n,o.regex,o.message,t);break;case"cuid":Fe(n,gt.cuid,o.message,t);break;case"cuid2":Fe(n,gt.cuid2,o.message,t);break;case"startsWith":Fe(n,RegExp(`^${ms(o.value,t)}`),o.message,t);break;case"endsWith":Fe(n,RegExp(`${ms(o.value,t)}$`),o.message,t);break;case"datetime":vt(n,"date-time",o.message,t);break;case"date":vt(n,"date",o.message,t);break;case"time":vt(n,"time",o.message,t);break;case"duration":vt(n,"duration",o.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,o.value):o.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,o.value):o.value;break;case"includes":{Fe(n,RegExp(ms(o.value,t)),o.message,t);break}case"ip":{o.version!=="v6"&&vt(n,"ipv4",o.message,t),o.version!=="v4"&&vt(n,"ipv6",o.message,t);break}case"base64url":Fe(n,gt.base64url,o.message,t);break;case"jwt":Fe(n,gt.jwt,o.message,t);break;case"cidr":{o.version!=="v6"&&Fe(n,gt.ipv4Cidr,o.message,t),o.version!=="v4"&&Fe(n,gt.ipv6Cidr,o.message,t);break}case"emoji":Fe(n,gt.emoji(),o.message,t);break;case"ulid":{Fe(n,gt.ulid,o.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{vt(n,"binary",o.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{Fe(n,gt.base64,o.message,t);break}}break}case"nanoid":Fe(n,gt.nanoid,o.message,t)}return n}function ms(e,t){return t.patternStrategy==="escape"?fT(e):e}var dT=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function fT(e){let t="";for(let n=0;n<e.length;n++)dT.has(e[n])||(t+="\\"),t+=e[n];return t}function vt(e,t,n,o){var r;e.format||(r=e.anyOf)!=null&&r.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&o.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function Fe(e,t,n,o){var r;e.pattern||(r=e.allOf)!=null&&r.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:nf(t,o),...n&&o.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=nf(t,o)}function nf(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const o={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},r=o.i?e.source.toLowerCase():e.source;let i="",a=!1,s=!1,l=!1;for(let u=0;u<r.length;u++){if(a){i+=r[u],a=!1;continue}if(o.i){if(s){if(r[u].match(/[a-z]/)){l?(i+=r[u],i+=`${r[u-2]}-${r[u]}`.toUpperCase(),l=!1):r[u+1]==="-"&&((n=r[u+2])!=null&&n.match(/[a-z]/))?(i+=r[u],l=!0):i+=`${r[u]}${r[u].toUpperCase()}`;continue}}else if(r[u].match(/[a-z]/)){i+=`[${r[u]}${r[u].toUpperCase()}]`;continue}}if(o.m){if(r[u]==="^"){i+=`(^|(?<=[\r
|
|
29
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){r(i);continue}if(e.external){const l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){r(i);continue}}if(e.metadataRegistry.get(i[0])?.id){r(i);continue}if(a.cycle){r(i);continue}if(a.count>1&&e.reused==="ref"){r(i);continue}}}function en(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=a=>{const s=e.seen.get(a),l=s.def??s.schema,u={...l};if(s.ref===null)return;const c=s.ref;if(s.ref=null,c){o(c);const d=e.seen.get(c).schema;d.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(d)):(Object.assign(l,d),Object.assign(l,u))}s.isParent||e.override({zodSchema:a,jsonSchema:l,path:s.path??[]})};for(const a of[...e.seen.entries()].reverse())o(a[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}Object.assign(r,n.def??n.schema);const i=e.external?.defs??{};for(const a of e.seen.entries()){const s=a[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Cn(t,"input"),output:Cn(t,"output")}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ve(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return Ve(o.element,n);if(o.type==="set")return Ve(o.valueType,n);if(o.type==="lazy")return Ve(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return Ve(o.innerType,n);if(o.type==="intersection")return Ve(o.left,n)||Ve(o.right,n);if(o.type==="record"||o.type==="map")return Ve(o.keyType,n)||Ve(o.valueType,n);if(o.type==="pipe")return Ve(o.in,n)||Ve(o.out,n);if(o.type==="object"){for(const r in o.shape)if(Ve(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(Ve(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(Ve(r,n))return!0;return!!(o.rest&&Ve(o.rest,n))}return!1}const dy=(e,t={})=>n=>{const o=Qr({...n,processors:t});return he(e,o),Xr(o,e),en(o,e)},Cn=(e,t)=>n=>{const{libraryOptions:o,target:r}=n??{},i=Qr({...o??{},target:r,io:t,processors:{}});return he(e,i),Xr(i,e),en(i,e)},TT={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},py=(e,t,n,o)=>{const r=n;r.type="string";const{minimum:i,maximum:a,format:s,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(r.minLength=i),typeof a=="number"&&(r.maxLength=a),s&&(r.format=TT[s]??s,r.format===""&&delete r.format),u&&(r.contentEncoding=u),l&&l.size>0){const c=[...l];c.length===1?r.pattern=c[0].source:c.length>1&&(r.allOf=[...c.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},fy=(e,t,n,o)=>{const r=n,{minimum:i,maximum:a,format:s,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:c}=e._zod.bag;typeof s=="string"&&s.includes("int")?r.type="integer":r.type="number",typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=c,r.exclusiveMinimum=!0):r.exclusiveMinimum=c),typeof i=="number"&&(r.minimum=i,typeof c=="number"&&t.target!=="draft-04"&&(c>=i?delete r.minimum:delete r.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=u,r.exclusiveMaximum=!0):r.exclusiveMaximum=u),typeof a=="number"&&(r.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete r.maximum:delete r.exclusiveMaximum)),typeof l=="number"&&(r.multipleOf=l)},my=(e,t,n,o)=>{n.type="boolean"},hy=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},gy=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},vy=(e,t,n,o)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},yy=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},by=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},_y=(e,t,n,o)=>{n.not={}},wy=(e,t,n,o)=>{},xy=(e,t,n,o)=>{},$y=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Sy=(e,t,n,o)=>{const r=e._zod.def,i=Lu(r.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},Iy=(e,t,n,o)=>{const r=e._zod.def,i=[];for(const a of r.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),i.every(a=>typeof a=="boolean")&&(n.type="boolean"),i.every(a=>a===null)&&(n.type="null"),n.enum=i},ky=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},Ey=(e,t,n,o)=>{const r=n,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=i.source},Ty=(e,t,n,o)=>{const r=n,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:l}=e._zod.bag;a!==void 0&&(i.minLength=a),s!==void 0&&(i.maxLength=s),l?l.length===1?(i.contentMediaType=l[0],Object.assign(r,i)):r.anyOf=l.map(u=>({...i,contentMediaType:u})):Object.assign(r,i)},Oy=(e,t,n,o)=>{n.type="boolean"},Ny=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Py=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Cy=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},jy=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Ay=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Ry=(e,t,n,o)=>{const r=n,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(r.minItems=a),typeof s=="number"&&(r.maxItems=s),r.type="array",r.items=he(i.element,t,{...o,path:[...o.path,"items"]})},zy=(e,t,n,o)=>{const r=n,i=e._zod.def;r.type="object",r.properties={};const a=i.shape;for(const u in a)r.properties[u]=he(a[u],t,{...o,path:[...o.path,"properties",u]});const s=new Set(Object.keys(a)),l=new Set([...s].filter(u=>{const c=i.shape[u]._zod;return t.io==="input"?c.optin===void 0:c.optout===void 0}));l.size>0&&(r.required=Array.from(l)),i.catchall?._zod.def.type==="never"?r.additionalProperties=!1:i.catchall?i.catchall&&(r.additionalProperties=he(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},Rl=(e,t,n,o)=>{const r=e._zod.def,i=r.inclusive===!1,a=r.options.map((s,l)=>he(s,t,{...o,path:[...o.path,i?"oneOf":"anyOf",l]}));i?n.oneOf=a:n.anyOf=a},My=(e,t,n,o)=>{const r=e._zod.def,i=he(r.left,t,{...o,path:[...o.path,"allOf",0]}),a=he(r.right,t,{...o,path:[...o.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,l=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]];n.allOf=l},Dy=(e,t,n,o)=>{const r=n,i=e._zod.def;r.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=i.items.map((f,p)=>he(f,t,{...o,path:[...o.path,a,p]})),u=i.rest?he(i.rest,t,{...o,path:[...o.path,s,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;t.target==="draft-2020-12"?(r.prefixItems=l,u&&(r.items=u)):t.target==="openapi-3.0"?(r.items={anyOf:l},u&&r.items.anyOf.push(u),r.minItems=l.length,u||(r.maxItems=l.length)):(r.items=l,u&&(r.additionalItems=u));const{minimum:c,maximum:d}=e._zod.bag;typeof c=="number"&&(r.minItems=c),typeof d=="number"&&(r.maxItems=d)},Uy=(e,t,n,o)=>{const r=n,i=e._zod.def;r.type="object",(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=he(i.keyType,t,{...o,path:[...o.path,"propertyNames"]})),r.additionalProperties=he(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})},Ly=(e,t,n,o)=>{const r=e._zod.def,i=he(r.innerType,t,o),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=r.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Zy=(e,t,n,o)=>{const r=e._zod.def;he(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType},Fy=(e,t,n,o)=>{const r=e._zod.def;he(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},qy=(e,t,n,o)=>{const r=e._zod.def;he(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},Vy=(e,t,n,o)=>{const r=e._zod.def;he(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType;let a;try{a=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},By=(e,t,n,o)=>{const r=e._zod.def,i=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;he(i,t,o);const a=t.seen.get(e);a.ref=i},Jy=(e,t,n,o)=>{const r=e._zod.def;he(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType,n.readOnly=!0},Wy=(e,t,n,o)=>{const r=e._zod.def;he(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType},Hy=(e,t,n,o)=>{const r=e._zod.def;he(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType},Gy=(e,t,n,o)=>{const r=e._zod.innerType;he(r,t,o);const i=t.seen.get(e);i.ref=r},eu={string:py,number:fy,boolean:my,bigint:hy,symbol:gy,null:vy,undefined:yy,void:by,never:_y,any:wy,unknown:xy,date:$y,enum:Sy,literal:Iy,nan:ky,template_literal:Ey,file:Ty,success:Oy,custom:Ny,function:Py,transform:Cy,map:jy,set:Ay,array:Ry,object:zy,union:Rl,intersection:My,tuple:Dy,record:Uy,nullable:Ly,nonoptional:Zy,default:Fy,prefault:qy,catch:Vy,pipe:By,readonly:Jy,promise:Wy,optional:Hy,lazy:Gy};function da(e,t){if("_idmap"in e){const o=e,r=Qr({...t,processors:eu}),i={};for(const l of o._idmap.entries()){const[u,c]=l;he(c,r)}const a={},s={registry:o,uri:t?.uri,defs:i};r.external=s;for(const l of o._idmap.entries()){const[u,c]=l;Xr(r,c),a[u]=en(r,c)}if(Object.keys(i).length>0){const l=r.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:i}}return{schemas:a}}const n=Qr({...t,processors:eu});return he(e,n),Xr(n,e),en(n,e)}class OT{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=Qr({processors:eu,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return he(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),Xr(this.ctx,t);const o=en(this.ctx,t),{"~standard":r,...i}=o;return i}}const NT=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),PT=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:Mg,$ZodArray:Fg,$ZodAsyncError:vr,$ZodBase64:Ig,$ZodBase64URL:Eg,$ZodBigInt:al,$ZodBigIntFormat:jg,$ZodBoolean:il,$ZodCIDRv4:$g,$ZodCIDRv6:Sg,$ZodCUID:dg,$ZodCUID2:pg,$ZodCatch:lv,$ZodCheck:Se,$ZodCheckBigIntFormat:Zh,$ZodCheckEndsWith:Xh,$ZodCheckGreaterThan:rl,$ZodCheckIncludes:Yh,$ZodCheckLengthEquals:Wh,$ZodCheckLessThan:tl,$ZodCheckLowerCase:Gh,$ZodCheckMaxLength:Bh,$ZodCheckMaxSize:Fh,$ZodCheckMimeType:tg,$ZodCheckMinLength:Jh,$ZodCheckMinSize:qh,$ZodCheckMultipleOf:Uh,$ZodCheckNumberFormat:Lh,$ZodCheckOverwrite:rg,$ZodCheckProperty:eg,$ZodCheckRegex:Hh,$ZodCheckSizeEquals:Vh,$ZodCheckStartsWith:Qh,$ZodCheckStringFormat:so,$ZodCheckUpperCase:Kh,$ZodCodec:ul,$ZodCustom:vv,$ZodCustomStringFormat:Pg,$ZodDate:Zg,$ZodDefault:iv,$ZodDiscriminatedUnion:Hg,$ZodE164:Tg,$ZodEmail:sg,$ZodEmoji:lg,$ZodEncodeError:Bi,$ZodEnum:Xg,$ZodError:Fu,$ZodFile:tv,$ZodFunction:mv,$ZodGUID:ig,$ZodIPv4:_g,$ZodIPv6:wg,$ZodISODate:vg,$ZodISODateTime:gg,$ZodISODuration:bg,$ZodISOTime:yg,$ZodIntersection:Gg,$ZodJWT:Ng,$ZodKSUID:hg,$ZodLazy:gv,$ZodLiteral:ev,$ZodMAC:xg,$ZodMap:Yg,$ZodNaN:cv,$ZodNanoID:cg,$ZodNever:Ug,$ZodNonOptional:sv,$ZodNull:zg,$ZodNullable:ov,$ZodNumber:ol,$ZodNumberFormat:Cg,$ZodObject:Bg,$ZodObjectJIT:Jg,$ZodOptional:nv,$ZodPipe:dv,$ZodPrefault:av,$ZodPromise:hv,$ZodReadonly:pv,$ZodRealError:nt,$ZodRecord:Kg,$ZodRegistry:Sv,$ZodSet:Qg,$ZodString:uo,$ZodStringFormat:ge,$ZodSuccess:uv,$ZodSymbol:Ag,$ZodTemplateLiteral:fv,$ZodTransform:rv,$ZodTuple:sl,$ZodType:X,$ZodULID:fg,$ZodURL:ug,$ZodUUID:ag,$ZodUndefined:Rg,$ZodUnion:Ki,$ZodUnknown:Dg,$ZodVoid:Lg,$ZodXID:mg,$ZodXor:Wg,$brand:jm,$constructor:S,$input:$v,$output:xv,Doc:ng,JSONSchema:NT,JSONSchemaGenerator:OT,NEVER:Uu,TimePrecision:Tv,_any:Gv,_array:ry,_base64:kl,_base64url:El,_bigint:Fv,_boolean:Lv,_catch:xT,_check:sy,_cidrv4:Sl,_cidrv6:Il,_coercedBigint:qv,_coercedBoolean:Zv,_coercedDate:ey,_coercedNumber:Av,_coercedString:kv,_cuid:vl,_cuid2:yl,_custom:oy,_date:Xv,_decode:Ju,_decodeAsync:Hu,_default:bT,_discriminatedUnion:sT,_e164:Tl,_email:cl,_emoji:hl,_encode:Bu,_encodeAsync:Wu,_endsWith:oa,_enum:fT,_file:ny,_float32:zv,_float64:Mv,_gt:ar,_gte:We,_guid:mi,_includes:ra,_int:Rv,_int32:Dv,_int64:Vv,_intersection:uT,_ipv4:xl,_ipv6:$l,_isoDate:Nv,_isoDateTime:Ov,_isoDuration:Cv,_isoTime:Pv,_jwt:Ol,_ksuid:wl,_lazy:kT,_length:po,_literal:hT,_lowercase:ea,_lt:ir,_lte:st,_mac:Ev,_map:dT,_max:st,_maxLength:co,_maxSize:lo,_mime:ia,_min:We,_minLength:br,_minSize:Yr,_multipleOf:Kr,_nan:ty,_nanoid:gl,_nativeEnum:mT,_negative:Pl,_never:Yv,_nonnegative:jl,_nonoptional:_T,_nonpositive:Cl,_normalize:aa,_null:Hv,_nullable:yT,_number:jv,_optional:vT,_overwrite:Ht,_parse:to,_parseAsync:ro,_pipe:$T,_positive:Nl,_promise:ET,_property:Al,_readonly:ST,_record:cT,_refine:iy,_regex:Xi,_safeDecode:Ku,_safeDecodeAsync:Qu,_safeEncode:Gu,_safeEncodeAsync:Yu,_safeParse:no,_safeParseAsync:oo,_set:pT,_size:Qi,_slugify:ca,_startsWith:na,_string:Iv,_stringFormat:fo,_stringbool:cy,_success:wT,_superRefine:ay,_symbol:Jv,_templateLiteral:IT,_toLowerCase:ua,_toUpperCase:la,_transform:gT,_trim:sa,_tuple:lT,_uint32:Uv,_uint64:Bv,_ulid:bl,_undefined:Wv,_union:iT,_unknown:Kv,_uppercase:ta,_url:Yi,_uuid:dl,_uuidv4:pl,_uuidv6:fl,_uuidv7:ml,_void:Qv,_xid:_l,_xor:aT,clone:dt,config:De,createStandardJSONSchemaMethod:Cn,createToJSONSchemaMethod:dy,decode:LI,decodeAsync:FI,describe:uy,encode:UI,encodeAsync:ZI,extractDefs:Xr,finalize:en,flattenError:qu,formatError:Vu,globalConfig:ci,globalRegistry:wt,initializeContext:Qr,isValidBase64:nl,isValidBase64URL:kg,isValidJWT:Og,locales:wv,meta:ly,parse:Ys,parseAsync:Qs,prettifyError:eh,process:he,regexes:el,registry:ll,safeDecode:VI,safeDecodeAsync:JI,safeEncode:qI,safeEncodeAsync:BI,safeParse:th,safeParseAsync:rh,toDotPath:Xm,toJSONSchema:da,treeifyError:Qm,util:Km,version:og},Symbol.toStringTag,{value:"Module"})),CT=Object.freeze(Object.defineProperty({__proto__:null,endsWith:oa,gt:ar,gte:We,includes:ra,length:po,lowercase:ea,lt:ir,lte:st,maxLength:co,maxSize:lo,mime:ia,minLength:br,minSize:Yr,multipleOf:Kr,negative:Pl,nonnegative:jl,nonpositive:Cl,normalize:aa,overwrite:Ht,positive:Nl,property:Al,regex:Xi,size:Qi,slugify:ca,startsWith:na,toLowerCase:ua,toUpperCase:la,trim:sa,uppercase:ta},Symbol.toStringTag,{value:"Module"})),zl=S("ZodISODateTime",(e,t)=>{gg.init(e,t),ve.init(e,t)});function Ky(e){return Ov(zl,e)}const Ml=S("ZodISODate",(e,t)=>{vg.init(e,t),ve.init(e,t)});function Yy(e){return Nv(Ml,e)}const Dl=S("ZodISOTime",(e,t)=>{yg.init(e,t),ve.init(e,t)});function Qy(e){return Pv(Dl,e)}const Ul=S("ZodISODuration",(e,t)=>{bg.init(e,t),ve.init(e,t)});function Xy(e){return Cv(Ul,e)}const eb=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:Ml,ZodISODateTime:zl,ZodISODuration:Ul,ZodISOTime:Dl,date:Yy,datetime:Ky,duration:Xy,time:Qy},Symbol.toStringTag,{value:"Module"})),tb=(e,t)=>{Fu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Vu(e,n)},flatten:{value:n=>qu(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,di,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,di,2)}},isEmpty:{get(){return e.issues.length===0}}})},jT=S("ZodError",tb),ot=S("ZodError",tb,{Parent:Error}),rb=to(ot),nb=ro(ot),ob=no(ot),pa=oo(ot),ib=Bu(ot),ab=Ju(ot),sb=Wu(ot),ub=Hu(ot),lb=Gu(ot),cb=Ku(ot),db=Yu(ot),pb=Qu(ot),re=S("ZodType",(e,t)=>(X.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Cn(e,"input"),output:Cn(e,"output")}}),e.toJSONSchema=dy(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Wt(t,{checks:[...t.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]})),e.clone=(n,o)=>dt(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>rb(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>ob(e,n,o),e.parseAsync=async(n,o)=>nb(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>pa(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>ib(e,n,o),e.decode=(n,o)=>ab(e,n,o),e.encodeAsync=async(n,o)=>sb(e,n,o),e.decodeAsync=async(n,o)=>ub(e,n,o),e.safeEncode=(n,o)=>lb(e,n,o),e.safeDecode=(n,o)=>cb(e,n,o),e.safeEncodeAsync=async(n,o)=>db(e,n,o),e.safeDecodeAsync=async(n,o)=>pb(e,n,o),e.refine=(n,o)=>e.check(xc(n,o)),e.superRefine=n=>e.check($c(n)),e.overwrite=n=>e.check(Ht(n)),e.optional=()=>ee(e),e.nullable=()=>An(e),e.nullish=()=>ee(An(e)),e.nonoptional=n=>dc(e,n),e.array=()=>R(e),e.or=n=>G([e,n]),e.and=n=>Ql(e,n),e.transform=n=>Rn(e,Ra(n)),e.default=n=>uc(e,n),e.prefault=n=>cc(e,n),e.catch=n=>mc(e,n),e.pipe=n=>Rn(e,n),e.readonly=()=>vc(e),e.describe=n=>{const o=e.clone();return wt.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return wt.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return wt.get(e);const o=e.clone();return wt.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),fa=S("_ZodString",(e,t)=>{uo.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,r,i)=>py(e,o,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(Xi(...o)),e.includes=(...o)=>e.check(ra(...o)),e.startsWith=(...o)=>e.check(na(...o)),e.endsWith=(...o)=>e.check(oa(...o)),e.min=(...o)=>e.check(br(...o)),e.max=(...o)=>e.check(co(...o)),e.length=(...o)=>e.check(po(...o)),e.nonempty=(...o)=>e.check(br(1,...o)),e.lowercase=o=>e.check(ea(o)),e.uppercase=o=>e.check(ta(o)),e.trim=()=>e.check(sa()),e.normalize=(...o)=>e.check(aa(...o)),e.toLowerCase=()=>e.check(ua()),e.toUpperCase=()=>e.check(la()),e.slugify=()=>e.check(ca())}),mo=S("ZodString",(e,t)=>{uo.init(e,t),fa.init(e,t),e.email=n=>e.check(cl(ma,n)),e.url=n=>e.check(Yi(ho,n)),e.jwt=n=>e.check(Ol(Na,n)),e.emoji=n=>e.check(hl(ha,n)),e.guid=n=>e.check(mi(jn,n)),e.uuid=n=>e.check(dl(Ct,n)),e.uuidv4=n=>e.check(pl(Ct,n)),e.uuidv6=n=>e.check(fl(Ct,n)),e.uuidv7=n=>e.check(ml(Ct,n)),e.nanoid=n=>e.check(gl(ga,n)),e.guid=n=>e.check(mi(jn,n)),e.cuid=n=>e.check(vl(va,n)),e.cuid2=n=>e.check(yl(ya,n)),e.ulid=n=>e.check(bl(ba,n)),e.base64=n=>e.check(kl(ka,n)),e.base64url=n=>e.check(El(Ta,n)),e.xid=n=>e.check(_l(_a,n)),e.ksuid=n=>e.check(wl(wa,n)),e.ipv4=n=>e.check(xl(xa,n)),e.ipv6=n=>e.check($l($a,n)),e.cidrv4=n=>e.check(Sl(Sa,n)),e.cidrv6=n=>e.check(Il(Ia,n)),e.e164=n=>e.check(Tl(Oa,n)),e.datetime=n=>e.check(Ky(n)),e.date=n=>e.check(Yy(n)),e.time=n=>e.check(Qy(n)),e.duration=n=>e.check(Xy(n))});function w(e){return Iv(mo,e)}const ve=S("ZodStringFormat",(e,t)=>{ge.init(e,t),fa.init(e,t)}),ma=S("ZodEmail",(e,t)=>{sg.init(e,t),ve.init(e,t)});function fb(e){return cl(ma,e)}const jn=S("ZodGUID",(e,t)=>{ig.init(e,t),ve.init(e,t)});function mb(e){return mi(jn,e)}const Ct=S("ZodUUID",(e,t)=>{ag.init(e,t),ve.init(e,t)});function hb(e){return dl(Ct,e)}function gb(e){return pl(Ct,e)}function vb(e){return fl(Ct,e)}function yb(e){return ml(Ct,e)}const ho=S("ZodURL",(e,t)=>{ug.init(e,t),ve.init(e,t)});function bb(e){return Yi(ho,e)}function _b(e){return Yi(ho,{protocol:/^https?$/,hostname:wh,...P(e)})}const ha=S("ZodEmoji",(e,t)=>{lg.init(e,t),ve.init(e,t)});function wb(e){return hl(ha,e)}const ga=S("ZodNanoID",(e,t)=>{cg.init(e,t),ve.init(e,t)});function xb(e){return gl(ga,e)}const va=S("ZodCUID",(e,t)=>{dg.init(e,t),ve.init(e,t)});function $b(e){return vl(va,e)}const ya=S("ZodCUID2",(e,t)=>{pg.init(e,t),ve.init(e,t)});function Sb(e){return yl(ya,e)}const ba=S("ZodULID",(e,t)=>{fg.init(e,t),ve.init(e,t)});function Ib(e){return bl(ba,e)}const _a=S("ZodXID",(e,t)=>{mg.init(e,t),ve.init(e,t)});function kb(e){return _l(_a,e)}const wa=S("ZodKSUID",(e,t)=>{hg.init(e,t),ve.init(e,t)});function Eb(e){return wl(wa,e)}const xa=S("ZodIPv4",(e,t)=>{_g.init(e,t),ve.init(e,t)});function Tb(e){return xl(xa,e)}const Ll=S("ZodMAC",(e,t)=>{xg.init(e,t),ve.init(e,t)});function Ob(e){return Ev(Ll,e)}const $a=S("ZodIPv6",(e,t)=>{wg.init(e,t),ve.init(e,t)});function Nb(e){return $l($a,e)}const Sa=S("ZodCIDRv4",(e,t)=>{$g.init(e,t),ve.init(e,t)});function Pb(e){return Sl(Sa,e)}const Ia=S("ZodCIDRv6",(e,t)=>{Sg.init(e,t),ve.init(e,t)});function Cb(e){return Il(Ia,e)}const ka=S("ZodBase64",(e,t)=>{Ig.init(e,t),ve.init(e,t)});function Ea(e){return kl(ka,e)}const Ta=S("ZodBase64URL",(e,t)=>{Eg.init(e,t),ve.init(e,t)});function jb(e){return El(Ta,e)}const Oa=S("ZodE164",(e,t)=>{Tg.init(e,t),ve.init(e,t)});function Ab(e){return Tl(Oa,e)}const Na=S("ZodJWT",(e,t)=>{Ng.init(e,t),ve.init(e,t)});function Rb(e){return Ol(Na,e)}const un=S("ZodCustomStringFormat",(e,t)=>{Pg.init(e,t),ve.init(e,t)});function zb(e,t,n={}){return fo(un,e,t,n)}function Mb(e){return fo(un,"hostname",_h,e)}function Db(e){return fo(un,"hex",Mh,e)}function Ub(e,t){const n=t?.enc??"hex",o=`${e}_${n}`,r=el[o];if(!r)throw new Error(`Unrecognized hash format: ${o}`);return fo(un,o,r,t)}const go=S("ZodNumber",(e,t)=>{ol.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,r,i)=>fy(e,o,r),e.gt=(o,r)=>e.check(ar(o,r)),e.gte=(o,r)=>e.check(We(o,r)),e.min=(o,r)=>e.check(We(o,r)),e.lt=(o,r)=>e.check(ir(o,r)),e.lte=(o,r)=>e.check(st(o,r)),e.max=(o,r)=>e.check(st(o,r)),e.int=o=>e.check(hi(o)),e.safe=o=>e.check(hi(o)),e.positive=o=>e.check(ar(0,o)),e.nonnegative=o=>e.check(We(0,o)),e.negative=o=>e.check(ir(0,o)),e.nonpositive=o=>e.check(st(0,o)),e.multipleOf=(o,r)=>e.check(Kr(o,r)),e.step=(o,r)=>e.check(Kr(o,r)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function V(e){return jv(go,e)}const Tr=S("ZodNumberFormat",(e,t)=>{Cg.init(e,t),go.init(e,t)});function hi(e){return Rv(Tr,e)}function Lb(e){return zv(Tr,e)}function Zb(e){return Mv(Tr,e)}function Fb(e){return Dv(Tr,e)}function qb(e){return Uv(Tr,e)}const vo=S("ZodBoolean",(e,t)=>{il.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>my(e,n,o)});function pe(e){return Lv(vo,e)}const yo=S("ZodBigInt",(e,t)=>{al.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,r,i)=>hy(e,o),e.gte=(o,r)=>e.check(We(o,r)),e.min=(o,r)=>e.check(We(o,r)),e.gt=(o,r)=>e.check(ar(o,r)),e.gte=(o,r)=>e.check(We(o,r)),e.min=(o,r)=>e.check(We(o,r)),e.lt=(o,r)=>e.check(ir(o,r)),e.lte=(o,r)=>e.check(st(o,r)),e.max=(o,r)=>e.check(st(o,r)),e.positive=o=>e.check(ar(BigInt(0),o)),e.negative=o=>e.check(ir(BigInt(0),o)),e.nonpositive=o=>e.check(st(BigInt(0),o)),e.nonnegative=o=>e.check(We(BigInt(0),o)),e.multipleOf=(o,r)=>e.check(Kr(o,r));const n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function Vb(e){return Fv(yo,e)}const Pa=S("ZodBigIntFormat",(e,t)=>{jg.init(e,t),yo.init(e,t)});function Bb(e){return Vv(Pa,e)}function Jb(e){return Bv(Pa,e)}const Zl=S("ZodSymbol",(e,t)=>{Ag.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>gy(e,n)});function Wb(e){return Jv(Zl,e)}const Fl=S("ZodUndefined",(e,t)=>{Rg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>yy(e,n)});function Hb(e){return Wv(Fl,e)}const ql=S("ZodNull",(e,t)=>{zg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>vy(e,n,o)});function bo(e){return Hv(ql,e)}const Vl=S("ZodAny",(e,t)=>{Mg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>wy()});function Pe(){return Gv(Vl)}const Bl=S("ZodUnknown",(e,t)=>{Dg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>xy()});function $e(){return Kv(Bl)}const Jl=S("ZodNever",(e,t)=>{Ug.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>_y(e,n,o)});function Ca(e){return Yv(Jl,e)}const Wl=S("ZodVoid",(e,t)=>{Lg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>by(e,n)});function Gb(e){return Qv(Wl,e)}const ja=S("ZodDate",(e,t)=>{Zg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,r,i)=>$y(e,o),e.min=(o,r)=>e.check(We(o,r)),e.max=(o,r)=>e.check(st(o,r));const n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});function Kb(e){return Xv(ja,e)}const Hl=S("ZodArray",(e,t)=>{Fg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ry(e,n,o,r),e.element=t.element,e.min=(n,o)=>e.check(br(n,o)),e.nonempty=n=>e.check(br(1,n)),e.max=(n,o)=>e.check(co(n,o)),e.length=(n,o)=>e.check(po(n,o)),e.unwrap=()=>e.element});function R(e,t){return ry(Hl,e,t)}function Yb(e){const t=e._zod.def.shape;return dr(Object.keys(t))}const _o=S("ZodObject",(e,t)=>{Jg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>zy(e,n,o,r),ne(e,"shape",()=>t.shape),e.keyof=()=>dr(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:$e()}),e.loose=()=>e.clone({...e._zod.def,catchall:$e()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ca()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>qm(e,n),e.safeExtend=n=>Vm(e,n),e.merge=n=>Bm(e,n),e.pick=n=>Zm(e,n),e.omit=n=>Fm(e,n),e.partial=(...n)=>Jm(za,e,n[0]),e.required=(...n)=>Wm(Ma,e,n[0])});function E(e,t){const n={type:"object",shape:e??{},...P(t)};return new _o(n)}function be(e,t){return new _o({type:"object",shape:e,catchall:Ca(),...P(t)})}function er(e,t){return new _o({type:"object",shape:e,catchall:$e(),...P(t)})}const wo=S("ZodUnion",(e,t)=>{Ki.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Rl(e,n,o,r),e.options=t.options});function G(e,t){return new wo({type:"union",options:e,...P(t)})}const Gl=S("ZodXor",(e,t)=>{wo.init(e,t),Wg.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Rl(e,n,o,r),e.options=t.options});function Qb(e,t){return new Gl({type:"union",options:e,inclusive:!1,...P(t)})}const Kl=S("ZodDiscriminatedUnion",(e,t)=>{wo.init(e,t),Hg.init(e,t)});function Aa(e,t,n){return new Kl({type:"union",options:t,discriminator:e,...P(n)})}const Yl=S("ZodIntersection",(e,t)=>{Gg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>My(e,n,o,r)});function Ql(e,t){return new Yl({type:"intersection",left:e,right:t})}const Xl=S("ZodTuple",(e,t)=>{sl.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Dy(e,n,o,r),e.rest=n=>e.clone({...e._zod.def,rest:n})});function ec(e,t,n){const o=t instanceof X,r=o?n:t,i=o?t:null;return new Xl({type:"tuple",items:e,rest:i,...P(r)})}const xo=S("ZodRecord",(e,t)=>{Kg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Uy(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function Xe(e,t,n){return new xo({type:"record",keyType:e,valueType:t,...P(n)})}function Xb(e,t,n){const o=dt(e);return o._zod.values=void 0,new xo({type:"record",keyType:o,valueType:t,...P(n)})}function e_(e,t,n){return new xo({type:"record",keyType:e,valueType:t,mode:"loose",...P(n)})}const tc=S("ZodMap",(e,t)=>{Yg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>jy(e,n),e.keyType=t.keyType,e.valueType=t.valueType});function t_(e,t,n){return new tc({type:"map",keyType:e,valueType:t,...P(n)})}const rc=S("ZodSet",(e,t)=>{Qg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ay(e,n),e.min=(...n)=>e.check(Yr(...n)),e.nonempty=n=>e.check(Yr(1,n)),e.max=(...n)=>e.check(lo(...n)),e.size=(...n)=>e.check(Qi(...n))});function r_(e,t){return new rc({type:"set",valueType:e,...P(t)})}const tn=S("ZodEnum",(e,t)=>{Xg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,r,i)=>Sy(e,o,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{const i={};for(const a of o)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new tn({...t,checks:[],...P(r),entries:i})},e.exclude=(o,r)=>{const i={...t.entries};for(const a of o)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new tn({...t,checks:[],...P(r),entries:i})}});function dr(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new tn({type:"enum",entries:n,...P(t)})}function n_(e,t){return new tn({type:"enum",entries:e,...P(t)})}const nc=S("ZodLiteral",(e,t)=>{ev.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Iy(e,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function C(e,t){return new nc({type:"literal",values:Array.isArray(e)?e:[e],...P(t)})}const oc=S("ZodFile",(e,t)=>{tv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ty(e,n,o),e.min=(n,o)=>e.check(Yr(n,o)),e.max=(n,o)=>e.check(lo(n,o)),e.mime=(n,o)=>e.check(ia(Array.isArray(n)?n:[n],o))});function o_(e){return ny(oc,e)}const ic=S("ZodTransform",(e,t)=>{rv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Cy(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Bi(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Hr(i,n.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(Hr(a))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(i=>(n.value=i,n)):(n.value=r,n)}});function Ra(e){return new ic({type:"transform",transform:e})}const za=S("ZodOptional",(e,t)=>{nv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Hy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function ee(e){return new za({type:"optional",innerType:e})}const ac=S("ZodNullable",(e,t)=>{ov.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ly(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function An(e){return new ac({type:"nullable",innerType:e})}function i_(e){return ee(An(e))}const sc=S("ZodDefault",(e,t)=>{iv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Fy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function uc(e,t){return new sc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Wi(t)}})}const lc=S("ZodPrefault",(e,t)=>{av.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>qy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function cc(e,t){return new lc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Wi(t)}})}const Ma=S("ZodNonOptional",(e,t)=>{sv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Zy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function dc(e,t){return new Ma({type:"nonoptional",innerType:e,...P(t)})}const pc=S("ZodSuccess",(e,t)=>{uv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Oy(e,n,o),e.unwrap=()=>e._zod.def.innerType});function a_(e){return new pc({type:"success",innerType:e})}const fc=S("ZodCatch",(e,t)=>{lv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Vy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function mc(e,t){return new fc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const hc=S("ZodNaN",(e,t)=>{cv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ky(e,n)});function s_(e){return ty(hc,e)}const Da=S("ZodPipe",(e,t)=>{dv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>By(e,n,o,r),e.in=t.in,e.out=t.out});function Rn(e,t){return new Da({type:"pipe",in:e,out:t})}const Ua=S("ZodCodec",(e,t)=>{Da.init(e,t),ul.init(e,t)});function u_(e,t,n){return new Ua({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}const gc=S("ZodReadonly",(e,t)=>{pv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Jy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function vc(e){return new gc({type:"readonly",innerType:e})}const yc=S("ZodTemplateLiteral",(e,t)=>{fv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ey(e,n,o)});function l_(e,t){return new yc({type:"template_literal",parts:e,...P(t)})}const bc=S("ZodLazy",(e,t)=>{gv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Gy(e,n,o,r),e.unwrap=()=>e._zod.def.getter()});function $o(e){return new bc({type:"lazy",getter:e})}const _c=S("ZodPromise",(e,t)=>{hv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Wy(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function c_(e){return new _c({type:"promise",innerType:e})}const wc=S("ZodFunction",(e,t)=>{mv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Py(e,n)});function gi(e){return new wc({type:"function",input:Array.isArray(e?.input)?ec(e?.input):e?.input??R($e()),output:e?.output??$e()})}const So=S("ZodCustom",(e,t)=>{vv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ny(e,n)});function d_(e){const t=new Se({check:"custom"});return t._zod.check=e,t}function Io(e,t){return oy(So,e??(()=>!0),t)}function xc(e,t={}){return iy(So,e,t)}function $c(e){return ay(e)}const p_=uy,f_=ly;function Rt(e,t={error:`Input not instance of ${e.name}`}){const n=new So({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...P(t)});return n._zod.bag.Class=e,n}const m_=(...e)=>cy({Codec:Ua,Boolean:vo,String:mo},...e);function h_(e){const t=$o(()=>G([w(e),V(),pe(),bo(),R(t),Xe(w(),t)]));return t}function g_(e,t){return Rn(Ra(e),t)}const AT=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:Vl,ZodArray:Hl,ZodBase64:ka,ZodBase64URL:Ta,ZodBigInt:yo,ZodBigIntFormat:Pa,ZodBoolean:vo,ZodCIDRv4:Sa,ZodCIDRv6:Ia,ZodCUID:va,ZodCUID2:ya,ZodCatch:fc,ZodCodec:Ua,ZodCustom:So,ZodCustomStringFormat:un,ZodDate:ja,ZodDefault:sc,ZodDiscriminatedUnion:Kl,ZodE164:Oa,ZodEmail:ma,ZodEmoji:ha,ZodEnum:tn,ZodFile:oc,ZodFunction:wc,ZodGUID:jn,ZodIPv4:xa,ZodIPv6:$a,ZodIntersection:Yl,ZodJWT:Na,ZodKSUID:wa,ZodLazy:bc,ZodLiteral:nc,ZodMAC:Ll,ZodMap:tc,ZodNaN:hc,ZodNanoID:ga,ZodNever:Jl,ZodNonOptional:Ma,ZodNull:ql,ZodNullable:ac,ZodNumber:go,ZodNumberFormat:Tr,ZodObject:_o,ZodOptional:za,ZodPipe:Da,ZodPrefault:lc,ZodPromise:_c,ZodReadonly:gc,ZodRecord:xo,ZodSet:rc,ZodString:mo,ZodStringFormat:ve,ZodSuccess:pc,ZodSymbol:Zl,ZodTemplateLiteral:yc,ZodTransform:ic,ZodTuple:Xl,ZodType:re,ZodULID:ba,ZodURL:ho,ZodUUID:Ct,ZodUndefined:Fl,ZodUnion:wo,ZodUnknown:Bl,ZodVoid:Wl,ZodXID:_a,ZodXor:Gl,_ZodString:fa,_default:uc,_function:gi,any:Pe,array:R,base64:Ea,base64url:jb,bigint:Vb,boolean:pe,catch:mc,check:d_,cidrv4:Pb,cidrv6:Cb,codec:u_,cuid:$b,cuid2:Sb,custom:Io,date:Kb,describe:p_,discriminatedUnion:Aa,e164:Ab,email:fb,emoji:wb,enum:dr,file:o_,float32:Lb,float64:Zb,function:gi,guid:mb,hash:Ub,hex:Db,hostname:Mb,httpUrl:_b,instanceof:Rt,int:hi,int32:Fb,int64:Bb,intersection:Ql,ipv4:Tb,ipv6:Nb,json:h_,jwt:Rb,keyof:Yb,ksuid:Eb,lazy:$o,literal:C,looseObject:er,looseRecord:e_,mac:Ob,map:t_,meta:f_,nan:s_,nanoid:xb,nativeEnum:n_,never:Ca,nonoptional:dc,null:bo,nullable:An,nullish:i_,number:V,object:E,optional:ee,partialRecord:Xb,pipe:Rn,prefault:cc,preprocess:g_,promise:c_,readonly:vc,record:Xe,refine:xc,set:r_,strictObject:be,string:w,stringFormat:zb,stringbool:m_,success:a_,superRefine:$c,symbol:Wb,templateLiteral:l_,transform:Ra,tuple:ec,uint32:qb,uint64:Jb,ulid:Ib,undefined:Hb,union:G,unknown:$e,url:bb,uuid:hb,uuidv4:gb,uuidv6:vb,uuidv7:yb,void:Gb,xid:kb,xor:Qb},Symbol.toStringTag,{value:"Module"})),v_={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function RT(e){De({customError:e})}function zT(){return De().customError}var tu;tu||(tu={});const M={...AT,...CT,iso:eb};function MT(e,t){const n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function DT(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");const n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;const o=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===o){const r=n[1];if(!r||!t.defs[r])throw new Error(`Reference not found: ${e}`);return t.defs[r]}throw new Error(`Reference not found: ${e}`)}function y_(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return M.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){const r=e.$ref;if(t.refs.has(r))return t.refs.get(r);if(t.processing.has(r))return M.lazy(()=>{if(!t.refs.has(r))throw new Error(`Circular reference not resolved: ${r}`);return t.refs.get(r)});t.processing.add(r);const i=DT(r,t),a=Me(i,t);return t.refs.set(r,a),t.processing.delete(r),a}if(e.enum!==void 0){const r=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&r.length===1&&r[0]===null)return M.null();if(r.length===0)return M.never();if(r.length===1)return M.literal(r[0]);if(r.every(a=>typeof a=="string"))return M.enum(r);const i=r.map(a=>M.literal(a));return i.length<2?i[0]:M.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return M.literal(e.const);const n=e.type;if(Array.isArray(n)){const r=n.map(i=>{const a={...e,type:i};return y_(a,t)});return r.length===0?M.never():r.length===1?r[0]:M.union(r)}if(!n)return M.any();let o;switch(n){case"string":{let r=M.string();if(e.format){const i=e.format;i==="email"?r=r.check(M.email()):i==="uri"||i==="uri-reference"?r=r.check(M.url()):i==="uuid"||i==="guid"?r=r.check(M.uuid()):i==="date-time"?r=r.check(M.iso.datetime()):i==="date"?r=r.check(M.iso.date()):i==="time"?r=r.check(M.iso.time()):i==="duration"?r=r.check(M.iso.duration()):i==="ipv4"?r=r.check(M.ipv4()):i==="ipv6"?r=r.check(M.ipv6()):i==="mac"?r=r.check(M.mac()):i==="cidr"?r=r.check(M.cidrv4()):i==="cidr-v6"?r=r.check(M.cidrv6()):i==="base64"?r=r.check(M.base64()):i==="base64url"?r=r.check(M.base64url()):i==="e164"?r=r.check(M.e164()):i==="jwt"?r=r.check(M.jwt()):i==="emoji"?r=r.check(M.emoji()):i==="nanoid"?r=r.check(M.nanoid()):i==="cuid"?r=r.check(M.cuid()):i==="cuid2"?r=r.check(M.cuid2()):i==="ulid"?r=r.check(M.ulid()):i==="xid"?r=r.check(M.xid()):i==="ksuid"&&(r=r.check(M.ksuid()))}typeof e.minLength=="number"&&(r=r.min(e.minLength)),typeof e.maxLength=="number"&&(r=r.max(e.maxLength)),e.pattern&&(r=r.regex(new RegExp(e.pattern))),o=r;break}case"number":case"integer":{let r=n==="integer"?M.number().int():M.number();typeof e.minimum=="number"&&(r=r.min(e.minimum)),typeof e.maximum=="number"&&(r=r.max(e.maximum)),typeof e.exclusiveMinimum=="number"?r=r.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(r=r.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?r=r.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(r=r.lt(e.maximum)),typeof e.multipleOf=="number"&&(r=r.multipleOf(e.multipleOf)),o=r;break}case"boolean":{o=M.boolean();break}case"null":{o=M.null();break}case"object":{const r={},i=e.properties||{},a=new Set(e.required||[]);for(const[l,u]of Object.entries(i)){const c=Me(u,t);r[l]=a.has(l)?c:c.optional()}if(e.propertyNames){const l=Me(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?Me(e.additionalProperties,t):M.any();if(Object.keys(r).length===0){o=M.record(l,u);break}const c=M.object(r).passthrough(),d=M.looseRecord(l,u);o=M.intersection(c,d);break}if(e.patternProperties){const l=e.patternProperties,u=Object.keys(l),c=[];for(const f of u){const p=Me(l[f],t),g=M.string().regex(new RegExp(f));c.push(M.looseRecord(g,p))}const d=[];if(Object.keys(r).length>0&&d.push(M.object(r).passthrough()),d.push(...c),d.length===0)o=M.object({}).passthrough();else if(d.length===1)o=d[0];else{let f=M.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)f=M.intersection(f,d[p]);o=f}break}const s=M.object(r);e.additionalProperties===!1?o=s.strict():typeof e.additionalProperties=="object"?o=s.catchall(Me(e.additionalProperties,t)):o=s.passthrough();break}case"array":{const r=e.prefixItems,i=e.items;if(r&&Array.isArray(r)){const a=r.map(l=>Me(l,t)),s=i&&typeof i=="object"&&!Array.isArray(i)?Me(i,t):void 0;s?o=M.tuple(a).rest(s):o=M.tuple(a),typeof e.minItems=="number"&&(o=o.check(M.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(M.maxLength(e.maxItems)))}else if(Array.isArray(i)){const a=i.map(l=>Me(l,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?Me(e.additionalItems,t):void 0;s?o=M.tuple(a).rest(s):o=M.tuple(a),typeof e.minItems=="number"&&(o=o.check(M.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(M.maxLength(e.maxItems)))}else if(i!==void 0){const a=Me(i,t);let s=M.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),o=s}else o=M.array(M.any());break}default:throw new Error(`Unsupported type: ${n}`)}return e.description&&(o=o.describe(e.description)),e.default!==void 0&&(o=o.default(e.default)),o}function Me(e,t){if(typeof e=="boolean")return e?M.any():M.never();let n=y_(e,t);const o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){const r=e.anyOf.map(a=>Me(a,t)),i=M.union(r);n=o?M.intersection(n,i):i}if(e.oneOf&&Array.isArray(e.oneOf)){const r=e.oneOf.map(a=>Me(a,t)),i=M.xor(r);n=o?M.intersection(n,i):i}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=o?n:M.any();else{let r=o?n:Me(e.allOf[0],t);const i=o?0:1;for(let a=i;a<e.allOf.length;a++)r=M.intersection(r,Me(e.allOf[a],t));n=r}return e.nullable===!0&&t.version==="openapi-3.0"&&(n=M.nullable(n)),e.readOnly===!0&&(n=M.readonly(n)),n}function UT(e,t){if(typeof e=="boolean")return e?M.any():M.never();const n=MT(e,t?.defaultTarget),o=e.$defs||e.definitions||{};return Me(e,{version:n,defs:o,refs:new Map,processing:new Set,rootSchema:e})}function LT(e){return kv(mo,e)}function ZT(e){return Av(go,e)}function FT(e){return Zv(vo,e)}function qT(e){return qv(yo,e)}function VT(e){return ey(ja,e)}const BT=Object.freeze(Object.defineProperty({__proto__:null,bigint:qT,boolean:FT,date:VT,number:ZT,string:LT},Symbol.toStringTag,{value:"Module"}));De(yv());const vi=Object.freeze(Object.defineProperty({__proto__:null,$brand:jm,$input:$v,$output:xv,NEVER:Uu,TimePrecision:Tv,ZodAny:Vl,ZodArray:Hl,ZodBase64:ka,ZodBase64URL:Ta,ZodBigInt:yo,ZodBigIntFormat:Pa,ZodBoolean:vo,ZodCIDRv4:Sa,ZodCIDRv6:Ia,ZodCUID:va,ZodCUID2:ya,ZodCatch:fc,ZodCodec:Ua,ZodCustom:So,ZodCustomStringFormat:un,ZodDate:ja,ZodDefault:sc,ZodDiscriminatedUnion:Kl,ZodE164:Oa,ZodEmail:ma,ZodEmoji:ha,ZodEnum:tn,ZodError:jT,ZodFile:oc,get ZodFirstPartyTypeKind(){return tu},ZodFunction:wc,ZodGUID:jn,ZodIPv4:xa,ZodIPv6:$a,ZodISODate:Ml,ZodISODateTime:zl,ZodISODuration:Ul,ZodISOTime:Dl,ZodIntersection:Yl,ZodIssueCode:v_,ZodJWT:Na,ZodKSUID:wa,ZodLazy:bc,ZodLiteral:nc,ZodMAC:Ll,ZodMap:tc,ZodNaN:hc,ZodNanoID:ga,ZodNever:Jl,ZodNonOptional:Ma,ZodNull:ql,ZodNullable:ac,ZodNumber:go,ZodNumberFormat:Tr,ZodObject:_o,ZodOptional:za,ZodPipe:Da,ZodPrefault:lc,ZodPromise:_c,ZodReadonly:gc,ZodRealError:ot,ZodRecord:xo,ZodSet:rc,ZodString:mo,ZodStringFormat:ve,ZodSuccess:pc,ZodSymbol:Zl,ZodTemplateLiteral:yc,ZodTransform:ic,ZodTuple:Xl,ZodType:re,ZodULID:ba,ZodURL:ho,ZodUUID:Ct,ZodUndefined:Fl,ZodUnion:wo,ZodUnknown:Bl,ZodVoid:Wl,ZodXID:_a,ZodXor:Gl,_ZodString:fa,_default:uc,_function:gi,any:Pe,array:R,base64:Ea,base64url:jb,bigint:Vb,boolean:pe,catch:mc,check:d_,cidrv4:Pb,cidrv6:Cb,clone:dt,codec:u_,coerce:BT,config:De,core:PT,cuid:$b,cuid2:Sb,custom:Io,date:Kb,decode:ab,decodeAsync:ub,describe:p_,discriminatedUnion:Aa,e164:Ab,email:fb,emoji:wb,encode:ib,encodeAsync:sb,endsWith:oa,enum:dr,file:o_,flattenError:qu,float32:Lb,float64:Zb,formatError:Vu,fromJSONSchema:UT,function:gi,getErrorMap:zT,globalRegistry:wt,gt:ar,gte:We,guid:mb,hash:Ub,hex:Db,hostname:Mb,httpUrl:_b,includes:ra,instanceof:Rt,int:hi,int32:Fb,int64:Bb,intersection:Ql,ipv4:Tb,ipv6:Nb,iso:eb,json:h_,jwt:Rb,keyof:Yb,ksuid:Eb,lazy:$o,length:po,literal:C,locales:wv,looseObject:er,looseRecord:e_,lowercase:ea,lt:ir,lte:st,mac:Ob,map:t_,maxLength:co,maxSize:lo,meta:f_,mime:ia,minLength:br,minSize:Yr,multipleOf:Kr,nan:s_,nanoid:xb,nativeEnum:n_,negative:Pl,never:Ca,nonnegative:jl,nonoptional:dc,nonpositive:Cl,normalize:aa,null:bo,nullable:An,nullish:i_,number:V,object:E,optional:ee,overwrite:Ht,parse:rb,parseAsync:nb,partialRecord:Xb,pipe:Rn,positive:Nl,prefault:cc,preprocess:g_,prettifyError:eh,promise:c_,property:Al,readonly:vc,record:Xe,refine:xc,regex:Xi,regexes:el,registry:ll,safeDecode:cb,safeDecodeAsync:pb,safeEncode:lb,safeEncodeAsync:db,safeParse:ob,safeParseAsync:pa,set:r_,setErrorMap:RT,size:Qi,slugify:ca,startsWith:na,strictObject:be,string:w,stringFormat:zb,stringbool:m_,success:a_,superRefine:$c,symbol:Wb,templateLiteral:l_,toJSONSchema:da,toLowerCase:ua,toUpperCase:la,transform:Ra,treeifyError:Qm,trim:sa,tuple:ec,uint32:qb,uint64:Jb,ulid:Ib,undefined:Hb,union:G,unknown:$e,uppercase:ta,url:bb,util:Km,uuid:hb,uuidv4:gb,uuidv6:vb,uuidv7:yb,void:Gb,xid:kb,xor:Qb},Symbol.toStringTag,{value:"Module"}));var zn;(function(e){e.assertEqual=r=>{};function t(r){}e.assertIs=t;function n(r){throw new Error}e.assertNever=n,e.arrayToEnum=r=>{const i={};for(const a of r)i[a]=a;return i},e.getValidEnumValues=r=>{const i=e.objectKeys(r).filter(s=>typeof r[r[s]]!="number"),a={};for(const s of i)a[s]=r[s];return e.objectValues(a)},e.objectValues=r=>e.objectKeys(r).map(function(i){return r[i]}),e.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const i=[];for(const a in r)Object.prototype.hasOwnProperty.call(r,a)&&i.push(a);return i},e.find=(r,i)=>{for(const a of r)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function o(r,i=" | "){return r.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=o,e.jsonStringifyReplacer=(r,i)=>typeof i=="bigint"?i.toString():i})(zn||(zn={}));var Qd;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Qd||(Qd={}));zn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);zn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class yi extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(i){return i.message},o={_errors:[]},r=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(r);else if(a.code==="invalid_return_type")r(a.returnTypeError);else if(a.code==="invalid_arguments")r(a.argumentsError);else if(a.path.length===0)o._errors.push(n(a));else{let s=o,l=0;for(;l<a.path.length;){const u=a.path[l];l===a.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(n(a))):s[u]=s[u]||{_errors:[]},s=s[u],l++}}};return r(this),o}static assert(t){if(!(t instanceof yi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,zn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n=Object.create(null),o=[];for(const r of this.issues)if(r.path.length>0){const i=r.path[0];n[i]=n[i]||[],n[i].push(t(r))}else o.push(t(r));return{formErrors:o,fieldErrors:n}}get formErrors(){return this.flatten()}}yi.create=e=>new yi(e);var Xd;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(Xd||(Xd={}));var A;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(A||(A={}));var ko=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const r=()=>{const i=n.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=n[Math.random()*i|0];return a.join("")};if(e==null)return r;if(n.includes(o))throw new Vi({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${n}".`});return()=>`${e}${o}${r()}`},b_=ko();function ep(e=globalThis){var t,n,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(n=e.process)==null?void 0:n.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function fr(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,o)=>{t[o.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,o]of e)o!=null&&(t[n.toLowerCase()]=o)}return t}function tp(e,...t){const n=new Headers(fr(e)),o=n.get("user-agent")||"";return n.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}var JT=/"__proto__"\s*:/,WT=/"constructor"\s*:/;function rp(e){const t=JSON.parse(e);return t===null||typeof t!="object"||JT.test(e)===!1&&WT.test(e)===!1?t:HT(t)}function HT(e){let t=[e];for(;t.length;){const n=t;t=[];for(const o of n){if(Object.prototype.hasOwnProperty.call(o,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(o,"constructor")&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const r in o){const i=o[r];i&&typeof i=="object"&&t.push(i)}}}return e}function GT(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return rp(e)}try{return rp(e)}finally{Error.stackTraceLimit=t}}var bi=Symbol.for("vercel.ai.validator");function KT(e){return{[bi]:!0,validate:e}}function YT(e){return typeof e=="object"&&e!==null&&bi in e&&e[bi]===!0&&"validate"in e}function QT(e){let t;return()=>(t==null&&(t=e()),t)}function XT(e){return YT(e)?e:typeof e=="function"?e():eO(e)}function eO(e){return KT(async t=>{const n=await e["~standard"].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new Ft({value:t,cause:n.issues})}})}async function np({value:e,schema:t}){const n=await Sc({value:e,schema:t});if(!n.success)throw Ft.wrap({value:e,cause:n.error});return n.value}async function Sc({value:e,schema:t}){const n=XT(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};const o=await n.validate(e);return o.success?{success:!0,value:o.value,rawValue:e}:{success:!1,error:Ft.wrap({value:e,cause:o.error}),rawValue:e}}catch(o){return{success:!1,error:Ft.wrap({value:e,cause:o}),rawValue:e}}}async function _i({text:e,schema:t}){try{const n=GT(e);return t==null?{success:!0,value:n,rawValue:n}:await Sc({value:n,schema:t})}catch(n){return{success:!1,error:Jr.isInstance(n)?n:new Jr({text:e,cause:n}),rawValue:void 0}}}function tO({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).pipeThrough(new TransformStream({async transform({data:n},o){n!=="[DONE]"&&o.enqueue(await _i({text:n,schema:t}))}}))}async function Ar(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}function ti(e){if(e.type==="object"){e.additionalProperties=!1;const t=e.properties;if(t!=null)for(const n in t)t[n]=ti(t[n])}return e.type==="array"&&e.items!=null&&(Array.isArray(e.items)?e.items=e.items.map(t=>ti(t)):e.items=ti(e.items)),e}var rO=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")},nO=Symbol("Let zodToJsonSchema decide on which parser to use"),op={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},oO=e=>typeof e=="string"?{...op,name:e}:{...op,...e};function et(){return{}}function iO(e,t){var n,o,r;const i={type:"array"};return(n=e.type)!=null&&n._def&&((r=(o=e.type)==null?void 0:o._def)==null?void 0:r.typeName)!==A.ZodAny&&(i.items=ue(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(i.minItems=e.minLength.value),e.maxLength&&(i.maxItems=e.maxLength.value),e.exactLength&&(i.minItems=e.exactLength.value,i.maxItems=e.exactLength.value),i}function aO(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function sO(){return{type:"boolean"}}function __(e,t){return ue(e.type._def,t)}var uO=(e,t)=>ue(e.innerType._def,t);function w_(e,t,n){const o=n??t.dateStrategy;if(Array.isArray(o))return{anyOf:o.map((r,i)=>w_(e,t,r))};switch(o){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return lO(e)}}var lO=e=>{const t={type:"integer",format:"unix-time"};for(const n of e.checks)switch(n.kind){case"min":t.minimum=n.value;break;case"max":t.maximum=n.value;break}return t};function cO(e,t){return{...ue(e.innerType._def,t),default:e.defaultValue()}}function dO(e,t){return t.effectStrategy==="input"?ue(e.schema._def,t):et()}function pO(e){return{type:"string",enum:Array.from(e.values)}}var fO=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function mO(e,t){const n=[ue(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),ue(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(r=>!!r),o=[];return n.forEach(r=>{if(fO(r))o.push(...r.allOf);else{let i=r;if("additionalProperties"in r&&r.additionalProperties===!1){const{additionalProperties:a,...s}=r;i=s}o.push(i)}}),o.length?{allOf:o}:void 0}function hO(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var gs=void 0,ht={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:()=>(gs===void 0&&(gs=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),gs),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function x_(e,t){const n={type:"string"};if(e.checks)for(const o of e.checks)switch(o.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,o.value):o.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,o.value):o.value;break;case"email":switch(t.emailStrategy){case"format:email":gt(n,"email",o.message,t);break;case"format:idn-email":gt(n,"idn-email",o.message,t);break;case"pattern:zod":Fe(n,ht.email,o.message,t);break}break;case"url":gt(n,"uri",o.message,t);break;case"uuid":gt(n,"uuid",o.message,t);break;case"regex":Fe(n,o.regex,o.message,t);break;case"cuid":Fe(n,ht.cuid,o.message,t);break;case"cuid2":Fe(n,ht.cuid2,o.message,t);break;case"startsWith":Fe(n,RegExp(`^${vs(o.value,t)}`),o.message,t);break;case"endsWith":Fe(n,RegExp(`${vs(o.value,t)}$`),o.message,t);break;case"datetime":gt(n,"date-time",o.message,t);break;case"date":gt(n,"date",o.message,t);break;case"time":gt(n,"time",o.message,t);break;case"duration":gt(n,"duration",o.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,o.value):o.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,o.value):o.value;break;case"includes":{Fe(n,RegExp(vs(o.value,t)),o.message,t);break}case"ip":{o.version!=="v6"&>(n,"ipv4",o.message,t),o.version!=="v4"&>(n,"ipv6",o.message,t);break}case"base64url":Fe(n,ht.base64url,o.message,t);break;case"jwt":Fe(n,ht.jwt,o.message,t);break;case"cidr":{o.version!=="v6"&&Fe(n,ht.ipv4Cidr,o.message,t),o.version!=="v4"&&Fe(n,ht.ipv6Cidr,o.message,t);break}case"emoji":Fe(n,ht.emoji(),o.message,t);break;case"ulid":{Fe(n,ht.ulid,o.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{gt(n,"binary",o.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{Fe(n,ht.base64,o.message,t);break}}break}case"nanoid":Fe(n,ht.nanoid,o.message,t)}return n}function vs(e,t){return t.patternStrategy==="escape"?vO(e):e}var gO=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function vO(e){let t="";for(let n=0;n<e.length;n++)gO.has(e[n])||(t+="\\"),t+=e[n];return t}function gt(e,t,n,o){var r;e.format||(r=e.anyOf)!=null&&r.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&o.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function Fe(e,t,n,o){var r;e.pattern||(r=e.allOf)!=null&&r.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:ip(t,o),...n&&o.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=ip(t,o)}function ip(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const o={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},r=o.i?e.source.toLowerCase():e.source;let i="",a=!1,s=!1,l=!1;for(let u=0;u<r.length;u++){if(a){i+=r[u],a=!1;continue}if(o.i){if(s){if(r[u].match(/[a-z]/)){l?(i+=r[u],i+=`${r[u-2]}-${r[u]}`.toUpperCase(),l=!1):r[u+1]==="-"&&((n=r[u+2])!=null&&n.match(/[a-z]/))?(i+=r[u],l=!0):i+=`${r[u]}${r[u].toUpperCase()}`;continue}}else if(r[u].match(/[a-z]/)){i+=`[${r[u]}${r[u].toUpperCase()}]`;continue}}if(o.m){if(r[u]==="^"){i+=`(^|(?<=[\r
|
|
30
30
|
]))`;continue}else if(r[u]==="$"){i+=`($|(?=[\r
|
|
31
31
|
]))`;continue}}if(o.s&&r[u]==="."){i+=s?`${r[u]}\r
|
|
32
32
|
`:`[${r[u]}\r
|
|
33
|
-
]`;continue}i+=r[u],r[u]==="\\"?a=!0:s&&r[u]==="]"?s=!1:!s&&r[u]==="["&&(s=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function w_(e,t){var n,o,r,i,a,s;const l={type:"object",additionalProperties:(n=ue(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((o=e.keyType)==null?void 0:o._def.typeName)===A.ZodString&&((r=e.keyType._def.checks)!=null&&r.length)){const{type:u,...c}=__(e.keyType._def,t);return{...l,propertyNames:c}}else{if(((i=e.keyType)==null?void 0:i._def.typeName)===A.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===A.ZodBranded&&e.keyType._def.type._def.typeName===A.ZodString&&((s=e.keyType._def.type._def.checks)!=null&&s.length)){const{type:u,...c}=y_(e.keyType._def,t);return{...l,propertyNames:c}}}return l}function pT(e,t){if(t.mapStrategy==="record")return w_(e,t);const n=ue(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||et(),o=ue(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||et();return{type:"array",maxItems:125,items:{type:"array",items:[n,o],minItems:2,maxItems:2}}}function mT(e){const t=e.values,o=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),r=Array.from(new Set(o.map(i=>typeof i)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:o}}function hT(){return{not:et()}}function gT(){return{type:"null"}}var Qs={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function vT(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(o=>o._def.typeName in Qs&&(!o._def.checks||!o._def.checks.length))){const o=n.reduce((r,i)=>{const a=Qs[i._def.typeName];return a&&!r.includes(a)?[...r,a]:r},[]);return{type:o.length>1?o:o[0]}}else if(n.every(o=>o._def.typeName==="ZodLiteral"&&!o.description)){const o=n.reduce((r,i)=>{const a=typeof i._def.value;switch(a){case"string":case"number":case"boolean":return[...r,a];case"bigint":return[...r,"integer"];case"object":if(i._def.value===null)return[...r,"null"];case"symbol":case"undefined":case"function":default:return r}},[]);if(o.length===n.length){const r=o.filter((i,a,s)=>s.indexOf(i)===a);return{type:r.length>1?r:r[0],enum:n.reduce((i,a)=>i.includes(a._def.value)?i:[...i,a._def.value],[])}}}else if(n.every(o=>o._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((o,r)=>[...o,...r._def.values.filter(i=>!o.includes(i))],[])};return yT(e,t)}var yT=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((o,r)=>ue(o._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(o=>!!o&&(!t.strictUnions||typeof o=="object"&&Object.keys(o).length>0));return n.length?{anyOf:n}:void 0};function bT(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Qs[e.innerType._def.typeName],"null"]};const n=ue(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function _T(e){const t={type:"number"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"int":t.type="integer";break;case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function wT(e,t){const n={type:"object",properties:{}},o=[],r=e.shape();for(const a in r){let s=r[a];if(s===void 0||s._def===void 0)continue;const l=$T(s),u=ue(s._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});u!==void 0&&(n.properties[a]=u,l||o.push(a))}o.length&&(n.required=o);const i=xT(e,t);return i!==void 0&&(n.additionalProperties=i),n}function xT(e,t){if(e.catchall._def.typeName!=="ZodNever")return ue(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function $T(e){try{return e.isOptional()}catch{return!0}}var ST=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return ue(e.innerType._def,t);const o=ue(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return o?{anyOf:[{not:et()},o]}:et()},IT=(e,t)=>{if(t.pipeStrategy==="input")return ue(e.in._def,t);if(t.pipeStrategy==="output")return ue(e.out._def,t);const n=ue(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),o=ue(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,o].filter(r=>r!==void 0)}};function kT(e,t){return ue(e.type._def,t)}function ET(e,t){const o={type:"array",uniqueItems:!0,items:ue(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(o.minItems=e.minSize.value),e.maxSize&&(o.maxItems=e.maxSize.value),o}function OT(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,o)=>ue(n._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((n,o)=>o===void 0?n:[...n,o],[]),additionalItems:ue(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,o)=>ue(n._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((n,o)=>o===void 0?n:[...n,o],[])}}function TT(){return{not:et()}}function NT(){return et()}var PT=(e,t)=>ue(e.innerType._def,t),CT=(e,t,n)=>{switch(t){case A.ZodString:return __(e,n);case A.ZodNumber:return _T(e);case A.ZodObject:return wT(e,n);case A.ZodBigInt:return tT(e);case A.ZodBoolean:return rT();case A.ZodDate:return b_(e,n);case A.ZodUndefined:return TT();case A.ZodNull:return gT();case A.ZodArray:return eT(e,n);case A.ZodUnion:case A.ZodDiscriminatedUnion:return vT(e,n);case A.ZodIntersection:return lT(e,n);case A.ZodTuple:return OT(e,n);case A.ZodRecord:return w_(e,n);case A.ZodLiteral:return cT(e);case A.ZodEnum:return sT(e);case A.ZodNativeEnum:return mT(e);case A.ZodNullable:return bT(e,n);case A.ZodOptional:return ST(e,n);case A.ZodMap:return pT(e,n);case A.ZodSet:return ET(e,n);case A.ZodLazy:return()=>e.getter()._def;case A.ZodPromise:return kT(e,n);case A.ZodNaN:case A.ZodNever:return hT();case A.ZodEffects:return aT(e,n);case A.ZodAny:return et();case A.ZodUnknown:return NT();case A.ZodDefault:return iT(e,n);case A.ZodBranded:return y_(e,n);case A.ZodReadonly:return PT(e,n);case A.ZodCatch:return nT(e,n);case A.ZodPipeline:return IT(e,n);case A.ZodFunction:case A.ZodVoid:case A.ZodSymbol:return;default:return(o=>{})()}};function ue(e,t,n=!1){var o;const r=t.seen.get(e);if(t.override){const l=(o=t.override)==null?void 0:o.call(t,e,t,r,n);if(l!==QO)return l}if(r&&!n){const l=jT(r,t);if(l!==void 0)return l}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const a=CT(e,e.typeName,t),s=typeof a=="function"?ue(a(),t):a;if(s&&AT(e,t,s),t.postProcess){const l=t.postProcess(s,e,t);return i.jsonSchema=s,l}return i.jsonSchema=s,s}var jT=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:YO(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,o)=>t.currentPath[o]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),et()):t.$refStrategy==="seen"?et():void 0}},AT=(e,t,n)=>(e.description&&(n.description=e.description),n),RT=e=>{const t=XO(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([o,r])=>[r._def,{def:r._def,path:[...t.basePath,t.definitionPath,o],jsonSchema:void 0}]))}},zT=(e,t)=>{var n;const o=RT(t);let r=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,d])=>{var p;return{...u,[c]:(p=ue(d._def,{...o,currentPath:[...o.basePath,o.definitionPath,c]},!0))!=null?p:et()}},{}):void 0;const i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=(n=ue(e._def,i===void 0?o:{...o,currentPath:[...o.basePath,o.definitionPath,i]},!1))!=null?n:et(),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(a.title=s);const l=i===void 0?r?{...a,[o.definitionPath]:r}:a:{$ref:[...o.$refStrategy==="relative"?[]:o.basePath,o.definitionPath,i].join("/"),[o.definitionPath]:{...r,[i]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},MT=zT;function DT(e,t){var n;const o=(n=void 0)!=null?n:!1;return Ma(()=>MT(e,{$refStrategy:o?"root":"none"}),{validate:async r=>{const i=await e.safeParseAsync(r);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function UT(e,t){var n;const o=(n=void 0)!=null?n:!1;return Ma(()=>ei(ua(e,{target:"draft-7",io:"input",reused:o?"ref":"inline"})),{validate:async r=>{const i=await la(e,r);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function LT(e){return"_zod"in e}function x_(e,t){return LT(e)?UT(e):DT(e)}var Xs=Symbol.for("vercel.ai.schema");function Ma(e,{validate:t}={}){return{[Xs]:!0,_type:void 0,[vi]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function ZT(e){return typeof e=="object"&&e!==null&&Xs in e&&e[Xs]===!0&&"jsonSchema"in e&&"validate"in e}function FT(e){return e==null?Ma({properties:{},additionalProperties:!1}):ZT(e)?e:typeof e=="function"?e():x_(e)}function qT(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var VT=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},mr="1.9.0",of=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function BT(e){var t=new Set([e]),n=new Set,o=e.match(of);if(!o)return function(){return!1};var r={major:+o[1],minor:+o[2],patch:+o[3],prerelease:o[4]};if(r.prerelease!=null)return function(l){return l===e};function i(s){return n.add(s),!1}function a(s){return t.add(s),!0}return function(l){if(t.has(l))return!0;if(n.has(l))return!1;var u=l.match(of);if(!u)return i(l);var c={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return c.prerelease!=null||r.major!==c.major?i(l):r.major===0?r.minor===c.minor&&r.patch<=c.patch?a(l):i(l):r.minor<=c.minor?a(l):i(l)}}var JT=BT(mr),WT=mr.split(".")[0],zn=Symbol.for("opentelemetry.js.api."+WT),Mn=VT;function $c(e,t,n,o){var r;o===void 0&&(o=!1);var i=Mn[zn]=(r=Mn[zn])!==null&&r!==void 0?r:{version:mr};if(!o&&i[e]){var a=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return n.error(a.stack||a.message),!1}if(i.version!==mr){var a=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+e+" does not match previously registered API v"+mr);return n.error(a.stack||a.message),!1}return i[e]=t,n.debug("@opentelemetry/api: Registered a global for "+e+" v"+mr+"."),!0}function Dn(e){var t,n,o=(t=Mn[zn])===null||t===void 0?void 0:t.version;if(!(!o||!JT(o)))return(n=Mn[zn])===null||n===void 0?void 0:n[e]}function Sc(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+mr+".");var n=Mn[zn];n&&delete n[e]}var HT=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var o=n.call(e),r,i=[],a;try{for(;(t===void 0||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(s){a={error:s}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},GT=function(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,i;o<r;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},KT=(function(){function e(t){this._namespace=t.namespace||"DiagComponentLogger"}return e.prototype.debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return bn("debug",this._namespace,t)},e.prototype.error=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return bn("error",this._namespace,t)},e.prototype.info=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return bn("info",this._namespace,t)},e.prototype.warn=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return bn("warn",this._namespace,t)},e.prototype.verbose=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return bn("verbose",this._namespace,t)},e})();function bn(e,t,n){var o=Dn("diag");if(o)return n.unshift(t),o[e].apply(o,GT([],HT(n),!1))}var Ke;(function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"})(Ke||(Ke={}));function YT(e,t){e<Ke.NONE?e=Ke.NONE:e>Ke.ALL&&(e=Ke.ALL),t=t||{};function n(o,r){var i=t[o];return typeof i=="function"&&e>=r?i.bind(t):function(){}}return{error:n("error",Ke.ERROR),warn:n("warn",Ke.WARN),info:n("info",Ke.INFO),debug:n("debug",Ke.DEBUG),verbose:n("verbose",Ke.VERBOSE)}}var QT=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var o=n.call(e),r,i=[],a;try{for(;(t===void 0||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(s){a={error:s}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},XT=function(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,i;o<r;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},eN="diag",bi=(function(){function e(){function t(r){return function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];var s=Dn("diag");if(s)return s[r].apply(s,XT([],QT(i),!1))}}var n=this,o=function(r,i){var a,s,l;if(i===void 0&&(i={logLevel:Ke.INFO}),r===n){var u=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return n.error((a=u.stack)!==null&&a!==void 0?a:u.message),!1}typeof i=="number"&&(i={logLevel:i});var c=Dn("diag"),d=YT((s=i.logLevel)!==null&&s!==void 0?s:Ke.INFO,r);if(c&&!i.suppressOverrideMessage){var p=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";c.warn("Current logger will be overwritten from "+p),d.warn("Current logger will overwrite one already registered from "+p)}return $c("diag",d,n,!0)};n.setLogger=o,n.disable=function(){Sc(eN,n)},n.createComponentLogger=function(r){return new KT(r)},n.verbose=t("verbose"),n.debug=t("debug"),n.info=t("info"),n.warn=t("warn"),n.error=t("error")}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e})();function tN(e){return Symbol.for(e)}var rN=(function(){function e(t){var n=this;n._currentContext=t?new Map(t):new Map,n.getValue=function(o){return n._currentContext.get(o)},n.setValue=function(o,r){var i=new e(n._currentContext);return i._currentContext.set(o,r),i},n.deleteValue=function(o){var r=new e(n._currentContext);return r._currentContext.delete(o),r}}return e})(),nN=new rN,oN=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var o=n.call(e),r,i=[],a;try{for(;(t===void 0||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(s){a={error:s}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},iN=function(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,i;o<r;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},aN=(function(){function e(){}return e.prototype.active=function(){return nN},e.prototype.with=function(t,n,o){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];return n.call.apply(n,iN([o],oN(r),!1))},e.prototype.bind=function(t,n){return n},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e})(),sN=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var o=n.call(e),r,i=[],a;try{for(;(t===void 0||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(s){a={error:s}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},uN=function(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,i;o<r;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},hs="context",lN=new aN,$_=(function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(t){return $c(hs,t,bi.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(t,n,o){for(var r,i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return(r=this._getContextManager()).with.apply(r,uN([t,n,o],sN(i),!1))},e.prototype.bind=function(t,n){return this._getContextManager().bind(t,n)},e.prototype._getContextManager=function(){return Dn(hs)||lN},e.prototype.disable=function(){this._getContextManager().disable(),Sc(hs,bi.instance())},e})(),eu;(function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"})(eu||(eu={}));var S_="0000000000000000",I_="00000000000000000000000000000000",cN={traceId:I_,spanId:S_,traceFlags:eu.NONE},On=(function(){function e(t){t===void 0&&(t=cN),this._spanContext=t}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(t,n){return this},e.prototype.setAttributes=function(t){return this},e.prototype.addEvent=function(t,n){return this},e.prototype.addLink=function(t){return this},e.prototype.addLinks=function(t){return this},e.prototype.setStatus=function(t){return this},e.prototype.updateName=function(t){return this},e.prototype.end=function(t){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(t,n){},e})(),Ic=tN("OpenTelemetry Context Key SPAN");function kc(e){return e.getValue(Ic)||void 0}function dN(){return kc($_.getInstance().active())}function Ec(e,t){return e.setValue(Ic,t)}function fN(e){return e.deleteValue(Ic)}function pN(e,t){return Ec(e,new On(t))}function k_(e){var t;return(t=kc(e))===null||t===void 0?void 0:t.spanContext()}var mN=/^([0-9a-f]{32})$/i,hN=/^[0-9a-f]{16}$/i;function gN(e){return mN.test(e)&&e!==I_}function vN(e){return hN.test(e)&&e!==S_}function E_(e){return gN(e.traceId)&&vN(e.spanId)}function yN(e){return new On(e)}var gs=$_.getInstance(),O_=(function(){function e(){}return e.prototype.startSpan=function(t,n,o){o===void 0&&(o=gs.active());var r=!!n?.root;if(r)return new On;var i=o&&k_(o);return bN(i)&&E_(i)?new On(i):new On},e.prototype.startActiveSpan=function(t,n,o,r){var i,a,s;if(!(arguments.length<2)){arguments.length===2?s=n:arguments.length===3?(i=n,s=o):(i=n,a=o,s=r);var l=a??gs.active(),u=this.startSpan(t,i,l),c=Ec(l,u);return gs.with(c,s,void 0,u)}},e})();function bN(e){return typeof e=="object"&&typeof e.spanId=="string"&&typeof e.traceId=="string"&&typeof e.traceFlags=="number"}var _N=new O_,wN=(function(){function e(t,n,o,r){this._provider=t,this.name=n,this.version=o,this.options=r}return e.prototype.startSpan=function(t,n,o){return this._getTracer().startSpan(t,n,o)},e.prototype.startActiveSpan=function(t,n,o,r){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):_N},e})(),xN=(function(){function e(){}return e.prototype.getTracer=function(t,n,o){return new O_},e})(),$N=new xN,af=(function(){function e(){}return e.prototype.getTracer=function(t,n,o){var r;return(r=this.getDelegateTracer(t,n,o))!==null&&r!==void 0?r:new wN(this,t,n,o)},e.prototype.getDelegate=function(){var t;return(t=this._delegate)!==null&&t!==void 0?t:$N},e.prototype.setDelegate=function(t){this._delegate=t},e.prototype.getDelegateTracer=function(t,n,o){var r;return(r=this._delegate)===null||r===void 0?void 0:r.getTracer(t,n,o)},e})(),_i;(function(e){e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR"})(_i||(_i={}));var vs="trace",SN=(function(){function e(){this._proxyTracerProvider=new af,this.wrapSpanContext=yN,this.isSpanContextValid=E_,this.deleteSpan=fN,this.getSpan=kc,this.getActiveSpan=dN,this.getSpanContext=k_,this.setSpan=Ec,this.setSpanContext=pN}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(t){var n=$c(vs,this._proxyTracerProvider,bi.instance());return n&&this._proxyTracerProvider.setDelegate(t),n},e.prototype.getTracerProvider=function(){return Dn(vs)||this._proxyTracerProvider},e.prototype.getTracer=function(t,n){return this.getTracerProvider().getTracer(t,n)},e.prototype.disable=function(){Sc(vs,bi.instance()),this._proxyTracerProvider=new af},e})(),IN=SN.getInstance(),kN=Object.defineProperty,EN=(e,t)=>{for(var n in t)kN(e,n,{get:t[n],enumerable:!0})},T_="AI_NoObjectGeneratedError",N_=`vercel.ai.error.${T_}`,ON=Symbol.for(N_),P_,sf=class extends Y{constructor({message:t="No object generated.",cause:n,text:o,response:r,usage:i,finishReason:a}){super({name:T_,message:t,cause:n}),this[P_]=!0,this.text=o,this.response=r,this.usage=i,this.finishReason=a}static isInstance(t){return Y.hasMarker(t,N_)}};P_=ON;var uf="5.0.116",C_=W([w(),zt(Uint8Array),zt(ArrayBuffer),So(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),Un=xo(()=>W([yo(),w(),q(),de(),Xe(w(),Un),R(Un)])),ke=Xe(w(),Xe(w(),Un)),j_=E({type:C("text"),text:w(),providerOptions:ke.optional()}),TN=E({type:C("image"),image:W([C_,zt(URL)]),mediaType:w().optional(),providerOptions:ke.optional()}),A_=E({type:C("file"),data:W([C_,zt(URL)]),filename:w().optional(),mediaType:w(),providerOptions:ke.optional()}),NN=E({type:C("reasoning"),text:w(),providerOptions:ke.optional()}),PN=E({type:C("tool-call"),toolCallId:w(),toolName:w(),input:$e(),providerOptions:ke.optional(),providerExecuted:de().optional()}),CN=Pa("type",[E({type:C("text"),value:w()}),E({type:C("json"),value:Un}),E({type:C("error-text"),value:w()}),E({type:C("error-json"),value:Un}),E({type:C("content"),value:R(W([E({type:C("text"),text:w()}),E({type:C("media"),data:w(),mediaType:w()})]))})]),R_=E({type:C("tool-result"),toolCallId:w(),toolName:w(),output:CN,providerOptions:ke.optional()}),jN=E({role:C("system"),content:w(),providerOptions:ke.optional()}),AN=E({role:C("user"),content:W([w(),R(W([j_,TN,A_]))]),providerOptions:ke.optional()}),RN=E({role:C("assistant"),content:W([w(),R(W([j_,A_,NN,PN,R_]))]),providerOptions:ke.optional()}),zN=E({role:C("tool"),content:R(R_),providerOptions:ke.optional()});W([jN,AN,RN,zN]);Io({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
33
|
+
]`;continue}i+=r[u],r[u]==="\\"?a=!0:s&&r[u]==="]"?s=!1:!s&&r[u]==="["&&(s=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function $_(e,t){var n,o,r,i,a,s;const l={type:"object",additionalProperties:(n=ue(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((o=e.keyType)==null?void 0:o._def.typeName)===A.ZodString&&((r=e.keyType._def.checks)!=null&&r.length)){const{type:u,...c}=x_(e.keyType._def,t);return{...l,propertyNames:c}}else{if(((i=e.keyType)==null?void 0:i._def.typeName)===A.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===A.ZodBranded&&e.keyType._def.type._def.typeName===A.ZodString&&((s=e.keyType._def.type._def.checks)!=null&&s.length)){const{type:u,...c}=__(e.keyType._def,t);return{...l,propertyNames:c}}}return l}function yO(e,t){if(t.mapStrategy==="record")return $_(e,t);const n=ue(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||et(),o=ue(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||et();return{type:"array",maxItems:125,items:{type:"array",items:[n,o],minItems:2,maxItems:2}}}function bO(e){const t=e.values,o=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),r=Array.from(new Set(o.map(i=>typeof i)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:o}}function _O(){return{not:et()}}function wO(){return{type:"null"}}var ru={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function xO(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(o=>o._def.typeName in ru&&(!o._def.checks||!o._def.checks.length))){const o=n.reduce((r,i)=>{const a=ru[i._def.typeName];return a&&!r.includes(a)?[...r,a]:r},[]);return{type:o.length>1?o:o[0]}}else if(n.every(o=>o._def.typeName==="ZodLiteral"&&!o.description)){const o=n.reduce((r,i)=>{const a=typeof i._def.value;switch(a){case"string":case"number":case"boolean":return[...r,a];case"bigint":return[...r,"integer"];case"object":if(i._def.value===null)return[...r,"null"];case"symbol":case"undefined":case"function":default:return r}},[]);if(o.length===n.length){const r=o.filter((i,a,s)=>s.indexOf(i)===a);return{type:r.length>1?r:r[0],enum:n.reduce((i,a)=>i.includes(a._def.value)?i:[...i,a._def.value],[])}}}else if(n.every(o=>o._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((o,r)=>[...o,...r._def.values.filter(i=>!o.includes(i))],[])};return $O(e,t)}var $O=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((o,r)=>ue(o._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(o=>!!o&&(!t.strictUnions||typeof o=="object"&&Object.keys(o).length>0));return n.length?{anyOf:n}:void 0};function SO(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[ru[e.innerType._def.typeName],"null"]};const n=ue(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function IO(e){const t={type:"number"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"int":t.type="integer";break;case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function kO(e,t){const n={type:"object",properties:{}},o=[],r=e.shape();for(const a in r){let s=r[a];if(s===void 0||s._def===void 0)continue;const l=TO(s),u=ue(s._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});u!==void 0&&(n.properties[a]=u,l||o.push(a))}o.length&&(n.required=o);const i=EO(e,t);return i!==void 0&&(n.additionalProperties=i),n}function EO(e,t){if(e.catchall._def.typeName!=="ZodNever")return ue(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function TO(e){try{return e.isOptional()}catch{return!0}}var OO=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return ue(e.innerType._def,t);const o=ue(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return o?{anyOf:[{not:et()},o]}:et()},NO=(e,t)=>{if(t.pipeStrategy==="input")return ue(e.in._def,t);if(t.pipeStrategy==="output")return ue(e.out._def,t);const n=ue(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),o=ue(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,o].filter(r=>r!==void 0)}};function PO(e,t){return ue(e.type._def,t)}function CO(e,t){const o={type:"array",uniqueItems:!0,items:ue(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(o.minItems=e.minSize.value),e.maxSize&&(o.maxItems=e.maxSize.value),o}function jO(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,o)=>ue(n._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((n,o)=>o===void 0?n:[...n,o],[]),additionalItems:ue(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,o)=>ue(n._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((n,o)=>o===void 0?n:[...n,o],[])}}function AO(){return{not:et()}}function RO(){return et()}var zO=(e,t)=>ue(e.innerType._def,t),MO=(e,t,n)=>{switch(t){case A.ZodString:return x_(e,n);case A.ZodNumber:return IO(e);case A.ZodObject:return kO(e,n);case A.ZodBigInt:return aO(e);case A.ZodBoolean:return sO();case A.ZodDate:return w_(e,n);case A.ZodUndefined:return AO();case A.ZodNull:return wO();case A.ZodArray:return iO(e,n);case A.ZodUnion:case A.ZodDiscriminatedUnion:return xO(e,n);case A.ZodIntersection:return mO(e,n);case A.ZodTuple:return jO(e,n);case A.ZodRecord:return $_(e,n);case A.ZodLiteral:return hO(e);case A.ZodEnum:return pO(e);case A.ZodNativeEnum:return bO(e);case A.ZodNullable:return SO(e,n);case A.ZodOptional:return OO(e,n);case A.ZodMap:return yO(e,n);case A.ZodSet:return CO(e,n);case A.ZodLazy:return()=>e.getter()._def;case A.ZodPromise:return PO(e,n);case A.ZodNaN:case A.ZodNever:return _O();case A.ZodEffects:return dO(e,n);case A.ZodAny:return et();case A.ZodUnknown:return RO();case A.ZodDefault:return cO(e,n);case A.ZodBranded:return __(e,n);case A.ZodReadonly:return zO(e,n);case A.ZodCatch:return uO(e,n);case A.ZodPipeline:return NO(e,n);case A.ZodFunction:case A.ZodVoid:case A.ZodSymbol:return;default:return(o=>{})()}};function ue(e,t,n=!1){var o;const r=t.seen.get(e);if(t.override){const l=(o=t.override)==null?void 0:o.call(t,e,t,r,n);if(l!==nO)return l}if(r&&!n){const l=DO(r,t);if(l!==void 0)return l}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const a=MO(e,e.typeName,t),s=typeof a=="function"?ue(a(),t):a;if(s&&UO(e,t,s),t.postProcess){const l=t.postProcess(s,e,t);return i.jsonSchema=s,l}return i.jsonSchema=s,s}var DO=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:rO(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,o)=>t.currentPath[o]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),et()):t.$refStrategy==="seen"?et():void 0}},UO=(e,t,n)=>(e.description&&(n.description=e.description),n),LO=e=>{const t=oO(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([o,r])=>[r._def,{def:r._def,path:[...t.basePath,t.definitionPath,o],jsonSchema:void 0}]))}},ZO=(e,t)=>{var n;const o=LO(t);let r=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,d])=>{var f;return{...u,[c]:(f=ue(d._def,{...o,currentPath:[...o.basePath,o.definitionPath,c]},!0))!=null?f:et()}},{}):void 0;const i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=(n=ue(e._def,i===void 0?o:{...o,currentPath:[...o.basePath,o.definitionPath,i]},!1))!=null?n:et(),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(a.title=s);const l=i===void 0?r?{...a,[o.definitionPath]:r}:a:{$ref:[...o.$refStrategy==="relative"?[]:o.basePath,o.definitionPath,i].join("/"),[o.definitionPath]:{...r,[i]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},FO=ZO;function qO(e,t){var n;const o=(n=void 0)!=null?n:!1;return La(()=>FO(e,{$refStrategy:o?"root":"none"}),{validate:async r=>{const i=await e.safeParseAsync(r);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function VO(e,t){var n;const o=(n=void 0)!=null?n:!1;return La(()=>ti(da(e,{target:"draft-7",io:"input",reused:o?"ref":"inline"})),{validate:async r=>{const i=await pa(e,r);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function BO(e){return"_zod"in e}function S_(e,t){return BO(e)?VO(e):qO(e)}var nu=Symbol.for("vercel.ai.schema");function La(e,{validate:t}={}){return{[nu]:!0,_type:void 0,[bi]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function JO(e){return typeof e=="object"&&e!==null&&nu in e&&e[nu]===!0&&"jsonSchema"in e&&"validate"in e}function WO(e){return e==null?La({properties:{},additionalProperties:!1}):JO(e)?e:typeof e=="function"?e():S_(e)}function HO(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var GO=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},hr="1.9.0",ap=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function KO(e){var t=new Set([e]),n=new Set,o=e.match(ap);if(!o)return function(){return!1};var r={major:+o[1],minor:+o[2],patch:+o[3],prerelease:o[4]};if(r.prerelease!=null)return function(l){return l===e};function i(s){return n.add(s),!1}function a(s){return t.add(s),!0}return function(l){if(t.has(l))return!0;if(n.has(l))return!1;var u=l.match(ap);if(!u)return i(l);var c={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return c.prerelease!=null||r.major!==c.major?i(l):r.major===0?r.minor===c.minor&&r.patch<=c.patch?a(l):i(l):r.minor<=c.minor?a(l):i(l)}}var YO=KO(hr),QO=hr.split(".")[0],Mn=Symbol.for("opentelemetry.js.api."+QO),Dn=GO;function Ic(e,t,n,o){var r;o===void 0&&(o=!1);var i=Dn[Mn]=(r=Dn[Mn])!==null&&r!==void 0?r:{version:hr};if(!o&&i[e]){var a=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return n.error(a.stack||a.message),!1}if(i.version!==hr){var a=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+e+" does not match previously registered API v"+hr);return n.error(a.stack||a.message),!1}return i[e]=t,n.debug("@opentelemetry/api: Registered a global for "+e+" v"+hr+"."),!0}function Un(e){var t,n,o=(t=Dn[Mn])===null||t===void 0?void 0:t.version;if(!(!o||!YO(o)))return(n=Dn[Mn])===null||n===void 0?void 0:n[e]}function kc(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+hr+".");var n=Dn[Mn];n&&delete n[e]}var XO=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var o=n.call(e),r,i=[],a;try{for(;(t===void 0||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(s){a={error:s}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},eN=function(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,i;o<r;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},tN=(function(){function e(t){this._namespace=t.namespace||"DiagComponentLogger"}return e.prototype.debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _n("debug",this._namespace,t)},e.prototype.error=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _n("error",this._namespace,t)},e.prototype.info=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _n("info",this._namespace,t)},e.prototype.warn=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _n("warn",this._namespace,t)},e.prototype.verbose=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _n("verbose",this._namespace,t)},e})();function _n(e,t,n){var o=Un("diag");if(o)return n.unshift(t),o[e].apply(o,eN([],XO(n),!1))}var Ke;(function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"})(Ke||(Ke={}));function rN(e,t){e<Ke.NONE?e=Ke.NONE:e>Ke.ALL&&(e=Ke.ALL),t=t||{};function n(o,r){var i=t[o];return typeof i=="function"&&e>=r?i.bind(t):function(){}}return{error:n("error",Ke.ERROR),warn:n("warn",Ke.WARN),info:n("info",Ke.INFO),debug:n("debug",Ke.DEBUG),verbose:n("verbose",Ke.VERBOSE)}}var nN=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var o=n.call(e),r,i=[],a;try{for(;(t===void 0||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(s){a={error:s}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},oN=function(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,i;o<r;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},iN="diag",wi=(function(){function e(){function t(r){return function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];var s=Un("diag");if(s)return s[r].apply(s,oN([],nN(i),!1))}}var n=this,o=function(r,i){var a,s,l;if(i===void 0&&(i={logLevel:Ke.INFO}),r===n){var u=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return n.error((a=u.stack)!==null&&a!==void 0?a:u.message),!1}typeof i=="number"&&(i={logLevel:i});var c=Un("diag"),d=rN((s=i.logLevel)!==null&&s!==void 0?s:Ke.INFO,r);if(c&&!i.suppressOverrideMessage){var f=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";c.warn("Current logger will be overwritten from "+f),d.warn("Current logger will overwrite one already registered from "+f)}return Ic("diag",d,n,!0)};n.setLogger=o,n.disable=function(){kc(iN,n)},n.createComponentLogger=function(r){return new tN(r)},n.verbose=t("verbose"),n.debug=t("debug"),n.info=t("info"),n.warn=t("warn"),n.error=t("error")}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e})();function aN(e){return Symbol.for(e)}var sN=(function(){function e(t){var n=this;n._currentContext=t?new Map(t):new Map,n.getValue=function(o){return n._currentContext.get(o)},n.setValue=function(o,r){var i=new e(n._currentContext);return i._currentContext.set(o,r),i},n.deleteValue=function(o){var r=new e(n._currentContext);return r._currentContext.delete(o),r}}return e})(),uN=new sN,lN=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var o=n.call(e),r,i=[],a;try{for(;(t===void 0||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(s){a={error:s}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},cN=function(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,i;o<r;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},dN=(function(){function e(){}return e.prototype.active=function(){return uN},e.prototype.with=function(t,n,o){for(var r=[],i=3;i<arguments.length;i++)r[i-3]=arguments[i];return n.call.apply(n,cN([o],lN(r),!1))},e.prototype.bind=function(t,n){return n},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e})(),pN=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var o=n.call(e),r,i=[],a;try{for(;(t===void 0||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(s){a={error:s}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i},fN=function(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,i;o<r;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},ys="context",mN=new dN,I_=(function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(t){return Ic(ys,t,wi.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(t,n,o){for(var r,i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return(r=this._getContextManager()).with.apply(r,fN([t,n,o],pN(i),!1))},e.prototype.bind=function(t,n){return this._getContextManager().bind(t,n)},e.prototype._getContextManager=function(){return Un(ys)||mN},e.prototype.disable=function(){this._getContextManager().disable(),kc(ys,wi.instance())},e})(),ou;(function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"})(ou||(ou={}));var k_="0000000000000000",E_="00000000000000000000000000000000",hN={traceId:E_,spanId:k_,traceFlags:ou.NONE},On=(function(){function e(t){t===void 0&&(t=hN),this._spanContext=t}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(t,n){return this},e.prototype.setAttributes=function(t){return this},e.prototype.addEvent=function(t,n){return this},e.prototype.addLink=function(t){return this},e.prototype.addLinks=function(t){return this},e.prototype.setStatus=function(t){return this},e.prototype.updateName=function(t){return this},e.prototype.end=function(t){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(t,n){},e})(),Ec=aN("OpenTelemetry Context Key SPAN");function Tc(e){return e.getValue(Ec)||void 0}function gN(){return Tc(I_.getInstance().active())}function Oc(e,t){return e.setValue(Ec,t)}function vN(e){return e.deleteValue(Ec)}function yN(e,t){return Oc(e,new On(t))}function T_(e){var t;return(t=Tc(e))===null||t===void 0?void 0:t.spanContext()}var bN=/^([0-9a-f]{32})$/i,_N=/^[0-9a-f]{16}$/i;function wN(e){return bN.test(e)&&e!==E_}function xN(e){return _N.test(e)&&e!==k_}function O_(e){return wN(e.traceId)&&xN(e.spanId)}function $N(e){return new On(e)}var bs=I_.getInstance(),N_=(function(){function e(){}return e.prototype.startSpan=function(t,n,o){o===void 0&&(o=bs.active());var r=!!n?.root;if(r)return new On;var i=o&&T_(o);return SN(i)&&O_(i)?new On(i):new On},e.prototype.startActiveSpan=function(t,n,o,r){var i,a,s;if(!(arguments.length<2)){arguments.length===2?s=n:arguments.length===3?(i=n,s=o):(i=n,a=o,s=r);var l=a??bs.active(),u=this.startSpan(t,i,l),c=Oc(l,u);return bs.with(c,s,void 0,u)}},e})();function SN(e){return typeof e=="object"&&typeof e.spanId=="string"&&typeof e.traceId=="string"&&typeof e.traceFlags=="number"}var IN=new N_,kN=(function(){function e(t,n,o,r){this._provider=t,this.name=n,this.version=o,this.options=r}return e.prototype.startSpan=function(t,n,o){return this._getTracer().startSpan(t,n,o)},e.prototype.startActiveSpan=function(t,n,o,r){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):IN},e})(),EN=(function(){function e(){}return e.prototype.getTracer=function(t,n,o){return new N_},e})(),TN=new EN,sp=(function(){function e(){}return e.prototype.getTracer=function(t,n,o){var r;return(r=this.getDelegateTracer(t,n,o))!==null&&r!==void 0?r:new kN(this,t,n,o)},e.prototype.getDelegate=function(){var t;return(t=this._delegate)!==null&&t!==void 0?t:TN},e.prototype.setDelegate=function(t){this._delegate=t},e.prototype.getDelegateTracer=function(t,n,o){var r;return(r=this._delegate)===null||r===void 0?void 0:r.getTracer(t,n,o)},e})(),xi;(function(e){e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR"})(xi||(xi={}));var _s="trace",ON=(function(){function e(){this._proxyTracerProvider=new sp,this.wrapSpanContext=$N,this.isSpanContextValid=O_,this.deleteSpan=vN,this.getSpan=Tc,this.getActiveSpan=gN,this.getSpanContext=T_,this.setSpan=Oc,this.setSpanContext=yN}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(t){var n=Ic(_s,this._proxyTracerProvider,wi.instance());return n&&this._proxyTracerProvider.setDelegate(t),n},e.prototype.getTracerProvider=function(){return Un(_s)||this._proxyTracerProvider},e.prototype.getTracer=function(t,n){return this.getTracerProvider().getTracer(t,n)},e.prototype.disable=function(){kc(_s,wi.instance()),this._proxyTracerProvider=new sp},e})(),NN=ON.getInstance(),PN=Object.defineProperty,CN=(e,t)=>{for(var n in t)PN(e,n,{get:t[n],enumerable:!0})},P_="AI_NoObjectGeneratedError",C_=`vercel.ai.error.${P_}`,jN=Symbol.for(C_),j_,up=class extends Y{constructor({message:t="No object generated.",cause:n,text:o,response:r,usage:i,finishReason:a}){super({name:P_,message:t,cause:n}),this[j_]=!0,this.text=o,this.response=r,this.usage=i,this.finishReason=a}static isInstance(t){return Y.hasMarker(t,C_)}};j_=jN;var lp="5.0.116",A_=G([w(),Rt(Uint8Array),Rt(ArrayBuffer),Io(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),Ln=$o(()=>G([bo(),w(),V(),pe(),Xe(w(),Ln),R(Ln)])),ke=Xe(w(),Xe(w(),Ln)),R_=E({type:C("text"),text:w(),providerOptions:ke.optional()}),AN=E({type:C("image"),image:G([A_,Rt(URL)]),mediaType:w().optional(),providerOptions:ke.optional()}),z_=E({type:C("file"),data:G([A_,Rt(URL)]),filename:w().optional(),mediaType:w(),providerOptions:ke.optional()}),RN=E({type:C("reasoning"),text:w(),providerOptions:ke.optional()}),zN=E({type:C("tool-call"),toolCallId:w(),toolName:w(),input:$e(),providerOptions:ke.optional(),providerExecuted:pe().optional()}),MN=Aa("type",[E({type:C("text"),value:w()}),E({type:C("json"),value:Ln}),E({type:C("error-text"),value:w()}),E({type:C("error-json"),value:Ln}),E({type:C("content"),value:R(G([E({type:C("text"),text:w()}),E({type:C("media"),data:w(),mediaType:w()})]))})]),M_=E({type:C("tool-result"),toolCallId:w(),toolName:w(),output:MN,providerOptions:ke.optional()}),DN=E({role:C("system"),content:w(),providerOptions:ke.optional()}),UN=E({role:C("user"),content:G([w(),R(G([R_,AN,z_]))]),providerOptions:ke.optional()}),LN=E({role:C("assistant"),content:G([w(),R(G([R_,z_,RN,zN,M_]))]),providerOptions:ke.optional()}),ZN=E({role:C("tool"),content:R(M_),providerOptions:ke.optional()});G([DN,UN,LN,ZN]);ko({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
34
34
|
|
|
35
35
|
`)},flush(e){e.enqueue(`data: [DONE]
|
|
36
36
|
|
|
37
|
-
`)}})}});var MN=WO(()=>x_(W([be({type:C("text-start"),id:w(),providerMetadata:ke.optional()}),be({type:C("text-delta"),id:w(),delta:w(),providerMetadata:ke.optional()}),be({type:C("text-end"),id:w(),providerMetadata:ke.optional()}),be({type:C("error"),errorText:w()}),be({type:C("tool-input-start"),toolCallId:w(),toolName:w(),providerExecuted:de().optional(),dynamic:de().optional()}),be({type:C("tool-input-delta"),toolCallId:w(),inputTextDelta:w()}),be({type:C("tool-input-available"),toolCallId:w(),toolName:w(),input:$e(),providerExecuted:de().optional(),providerMetadata:ke.optional(),dynamic:de().optional()}),be({type:C("tool-input-error"),toolCallId:w(),toolName:w(),input:$e(),providerExecuted:de().optional(),providerMetadata:ke.optional(),dynamic:de().optional(),errorText:w()}),be({type:C("tool-output-available"),toolCallId:w(),output:$e(),providerExecuted:de().optional(),dynamic:de().optional(),preliminary:de().optional()}),be({type:C("tool-output-error"),toolCallId:w(),errorText:w(),providerExecuted:de().optional(),dynamic:de().optional()}),be({type:C("reasoning-start"),id:w(),providerMetadata:ke.optional()}),be({type:C("reasoning-delta"),id:w(),delta:w(),providerMetadata:ke.optional()}),be({type:C("reasoning-end"),id:w(),providerMetadata:ke.optional()}),be({type:C("source-url"),sourceId:w(),url:w(),title:w().optional(),providerMetadata:ke.optional()}),be({type:C("source-document"),sourceId:w(),mediaType:w(),title:w(),filename:w().optional(),providerMetadata:ke.optional()}),be({type:C("file"),url:w(),mediaType:w(),providerMetadata:ke.optional()}),be({type:So(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:w().optional(),data:$e(),transient:de().optional()}),be({type:C("start-step")}),be({type:C("finish-step")}),be({type:C("start"),messageId:w().optional(),messageMetadata:$e().optional()}),be({type:C("finish"),finishReason:cr(["stop","length","content-filter","tool-calls","error","other","unknown"]).optional(),messageMetadata:$e().optional()}),be({type:C("abort")}),be({type:C("message-metadata"),messageMetadata:$e()})])));function DN(e){return e.type.startsWith("data-")}function z_(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const r=t[o];if(r===void 0)continue;const i=o in e?e[o]:void 0,a=r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp),s=i!=null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp);a&&s?n[o]=z_(i,r):n[o]=r}return n}function UN(e){const t=["ROOT"];let n=-1,o=null;function r(l,u,c){switch(l){case'"':{n=u,t.pop(),t.push(c),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=u,o=u,t.pop(),t.push(c),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=u,t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"{":{n=u,t.pop(),t.push(c),t.push("INSIDE_OBJECT_START");break}case"[":{n=u,t.pop(),t.push(c),t.push("INSIDE_ARRAY_START");break}}}function i(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":r(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{r(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),n=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{n=l,t.pop();break}default:{n=l,r(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,t.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{r(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(o,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?i(u,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l)):n=l;break}}}let s=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{s+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{s+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{s+="]";break}case"INSIDE_LITERAL":{const c=e.substring(o,e.length);"true".startsWith(c)?s+="true".slice(c.length):"false".startsWith(c)?s+="false".slice(c.length):"null".startsWith(c)&&(s+="null".slice(c.length))}}return s}async function M_(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await yi({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await yi({text:UN(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function Lr(e){return e.type.startsWith("tool-")}function LN(e){return e.type==="dynamic-tool"}function lf(e){return Lr(e)||LN(e)}function cf(e){return e.type.split("-").slice(1).join("-")}function ZN({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function FN({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:o,onError:r,onToolCall:i,onData:a}){return e.pipeThrough(new TransformStream({async transform(s,l){await o(async({state:u,write:c})=>{var d,p,f,g;function m(v){const N=u.message.parts.filter(Lr).find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function b(v){const N=u.message.parts.filter(I=>I.type==="dynamic-tool").find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function y(v){var k;const N=u.message.parts.find(z=>Lr(z)&&z.toolCallId===v.toolCallId),I=v,T=N;N!=null?(N.state=v.state,T.input=I.input,T.output=I.output,T.errorText=I.errorText,T.rawInput=I.rawInput,T.preliminary=I.preliminary,T.providerExecuted=(k=I.providerExecuted)!=null?k:N.providerExecuted,I.providerMetadata!=null&&N.state==="input-available"&&(N.callProviderMetadata=I.providerMetadata)):u.message.parts.push({type:`tool-${v.toolName}`,toolCallId:v.toolCallId,state:v.state,input:I.input,output:I.output,rawInput:I.rawInput,errorText:I.errorText,providerExecuted:I.providerExecuted,preliminary:I.preliminary,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}function x(v){var k,N;const I=u.message.parts.find(Z=>Z.type==="dynamic-tool"&&Z.toolCallId===v.toolCallId),T=v,z=I;I!=null?(I.state=v.state,z.toolName=v.toolName,z.input=T.input,z.output=T.output,z.errorText=T.errorText,z.rawInput=(k=T.rawInput)!=null?k:z.rawInput,z.preliminary=T.preliminary,z.providerExecuted=(N=T.providerExecuted)!=null?N:I.providerExecuted,T.providerMetadata!=null&&I.state==="input-available"&&(I.callProviderMetadata=T.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:v.toolName,toolCallId:v.toolCallId,state:v.state,input:T.input,output:T.output,errorText:T.errorText,preliminary:T.preliminary,providerExecuted:T.providerExecuted,...T.providerMetadata!=null?{callProviderMetadata:T.providerMetadata}:{}})}async function $(v){if(v!=null){const k=u.message.metadata!=null?z_(u.message.metadata,v):v;t!=null&&await tf({value:k,schema:t}),u.message.metadata=k}}switch(s.type){case"text-start":{const v={type:"text",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeTextParts[s.id]=v,u.message.parts.push(v),c();break}case"text-delta":{const v=u.activeTextParts[s.id];v.text+=s.delta,v.providerMetadata=(d=s.providerMetadata)!=null?d:v.providerMetadata,c();break}case"text-end":{const v=u.activeTextParts[s.id];v.state="done",v.providerMetadata=(p=s.providerMetadata)!=null?p:v.providerMetadata,delete u.activeTextParts[s.id],c();break}case"reasoning-start":{const v={type:"reasoning",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeReasoningParts[s.id]=v,u.message.parts.push(v),c();break}case"reasoning-delta":{const v=u.activeReasoningParts[s.id];v.text+=s.delta,v.providerMetadata=(f=s.providerMetadata)!=null?f:v.providerMetadata,c();break}case"reasoning-end":{const v=u.activeReasoningParts[s.id];v.providerMetadata=(g=s.providerMetadata)!=null?g:v.providerMetadata,v.state="done",delete u.activeReasoningParts[s.id],c();break}case"file":{u.message.parts.push({type:"file",mediaType:s.mediaType,url:s.url}),c();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:s.sourceId,url:s.url,title:s.title,providerMetadata:s.providerMetadata}),c();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:s.sourceId,mediaType:s.mediaType,title:s.title,filename:s.filename,providerMetadata:s.providerMetadata}),c();break}case"tool-input-start":{const v=u.message.parts.filter(Lr);u.partialToolCalls[s.toolCallId]={text:"",toolName:s.toolName,index:v.length,dynamic:s.dynamic},s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}),c();break}case"tool-input-delta":{const v=u.partialToolCalls[s.toolCallId];v.text+=s.inputTextDelta;const{value:k}=await M_(v.text);v.dynamic?x({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}):y({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}),c();break}case"tool-input-available":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c(),i&&!s.providerExecuted&&await i({toolCall:s});break}case"tool-input-error":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:void 0,rawInput:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c();break}case"tool-output-available":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-available",input:v.input,output:s.output,preliminary:s.preliminary})}else{const v=m(s.toolCallId);y({toolCallId:s.toolCallId,toolName:cf(v),state:"output-available",input:v.input,output:s.output,providerExecuted:s.providerExecuted,preliminary:s.preliminary})}c();break}case"tool-output-error":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-error",input:v.input,errorText:s.errorText,providerExecuted:s.providerExecuted})}else{const v=m(s.toolCallId);y({toolCallId:s.toolCallId,toolName:cf(v),state:"output-error",input:v.input,rawInput:v.rawInput,errorText:s.errorText,providerExecuted:s.providerExecuted})}c();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{s.messageId!=null&&(u.message.id=s.messageId),await $(s.messageMetadata),(s.messageId!=null||s.messageMetadata!=null)&&c();break}case"finish":{s.finishReason!=null&&(u.finishReason=s.finishReason),await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"message-metadata":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"error":{r?.(new Error(s.errorText));break}default:if(DN(s)){n?.[s.type]!=null&&await tf({value:s.data,schema:n[s.type]});const v=s;if(v.transient){a?.(v);break}const k=v.id!=null?u.message.parts.find(N=>v.type===N.type&&v.id===N.id):void 0;k!=null?k.data=v.data:u.message.parts.push(v),a?.(v),c()}}l.enqueue(s)})}}))}async function qN({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:o}=await n.read();if(o)break}}catch(o){t?.(o)}finally{n.releaseLock()}}Io({prefix:"aitxt",size:24});Io({prefix:"aiobj",size:24});var VN=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(o){n(o)}}),this.processQueue()})}};Io({prefix:"aiobj",size:24});var BN={};EN(BN,{object:()=>WN,text:()=>JN});var JN=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),WN=({schema:e})=>{const t=FT(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:n}){const o=await M_(n);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value};default:{const r=o.state;throw new Error(`Unsupported parse state: ${r}`)}}},async parseOutput({text:n},o){const r=await yi({text:n});if(!r.success)throw new sf({message:"No object generated: could not parse the response.",cause:r.error,text:n,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=await xc({value:r.value,schema:t});if(!i.success)throw new sf({message:"No object generated: response did not match schema.",cause:i.error,text:n,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.value}}};async function HN(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:o}=t,r=await new Promise((i,a)=>{const s=new FileReader;s.onload=l=>{var u;i((u=l.target)==null?void 0:u.result)},s.onerror=l=>a(l),s.readAsDataURL(t)});return{type:"file",mediaType:o,filename:n,url:r}}))}var GN=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:o,fetch:r,prepareSendMessagesRequest:i,prepareReconnectToStreamRequest:a}){this.api=e,this.credentials=t,this.headers=n,this.body=o,this.fetch=r,this.prepareSendMessagesRequest=i,this.prepareReconnectToStreamRequest=a}async sendMessages({abortSignal:e,...t}){var n,o,r,i,a;const s=await jr(this.body),l=await jr(this.headers),u=await jr(this.credentials),c={...fr(l),...fr(t.headers)},d=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...s,...t.body},headers:c,credentials:u,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),p=(o=d?.api)!=null?o:this.api,f=d?.headers!==void 0?fr(d.headers):c,g=d?.body!==void 0?d.body:{...s,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},m=(r=d?.credentials)!=null?r:u,y=await((i=this.fetch)!=null?i:globalThis.fetch)(p,{method:"POST",headers:Xd({"Content-Type":"application/json",...f},`ai-sdk/${uf}`,Qd()),body:JSON.stringify(g),credentials:m,signal:e});if(!y.ok)throw new Error((a=await y.text())!=null?a:"Failed to fetch the chat response.");if(!y.body)throw new Error("The response body is empty.");return this.processResponseStream(y.body)}async reconnectToStream(e){var t,n,o,r,i;const a=await jr(this.body),s=await jr(this.headers),l=await jr(this.credentials),u={...fr(s),...fr(e.headers)},c=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...a,...e.body},headers:u,credentials:l,requestMetadata:e.metadata})),d=(n=c?.api)!=null?n:`${this.api}/${e.chatId}/stream`,p=c?.headers!==void 0?fr(c.headers):u,f=(o=c?.credentials)!=null?o:l,m=await((r=this.fetch)!=null?r:globalThis.fetch)(d,{method:"GET",headers:Xd(p,`ai-sdk/${uf}`,Qd()),credentials:f});if(m.status===204)return null;if(!m.ok)throw new Error((i=await m.text())!=null?i:"Failed to fetch the chat response.");if(!m.body)throw new Error("The response body is empty.");return this.processResponseStream(m.body)}},D_=class extends GN{constructor(e={}){super(e)}processResponseStream(e){return KO({stream:e,schema:MN}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},KN=class{constructor({generateId:e=v_,id:t=e(),transport:n=new D_,messageMetadataSchema:o,dataPartSchemas:r,state:i,onError:a,onToolCall:s,onFinish:l,onData:u,sendAutomaticallyWhen:c}){this.activeResponse=void 0,this.jobExecutor=new VN,this.sendMessage=async(d,p)=>{var f,g,m,b;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(f=this.lastMessage)==null?void 0:f.id,...p});return}let y;if("text"in d||"files"in d?y={parts:[...Array.isArray(d.files)?d.files:await HN(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:y=d,d.messageId!=null){const x=this.state.messages.findIndex($=>$.id===d.messageId);if(x===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[x].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,x+1),this.state.replaceMessage(x,{...y,id:d.messageId,role:(g=y.role)!=null?g:"user",metadata:d.metadata})}else this.state.pushMessage({...y,id:(m=y.id)!=null?m:this.generateId(),role:(b=y.role)!=null?b:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...p})},this.regenerate=async({messageId:d,...p}={})=>{const f=d==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===d);if(f===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[f].role==="assistant"?f:f+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...p})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolOutput=async({state:d="output-available",tool:p,toolCallId:f,output:g,errorText:m})=>this.jobExecutor.run(async()=>{var b,y;const x=this.state.messages,$=x[x.length-1];this.state.replaceMessage(x.length-1,{...$,parts:$.parts.map(v=>lf(v)&&v.toolCallId===f?{...v,state:d,output:g,errorText:m}:v)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(v=>lf(v)&&v.toolCallId===f?{...v,state:d,output:g,errorText:m}:v)),this.status!=="streaming"&&this.status!=="submitted"&&((b=this.sendAutomaticallyWhen)!=null&&b.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(y=this.lastMessage)==null?void 0:y.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=o,this.dataPartSchemas=r,this.state=i,this.onError=a,this.onToolCall=s,this.onFinish=l,this.onData=u,this.sendAutomaticallyWhen=c}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async makeRequest({trigger:e,metadata:t,headers:n,body:o,messageId:r}){var i,a,s,l;this.setStatus({status:"submitted",error:void 0});const u=this.lastMessage;let c=!1,d=!1,p=!1;try{const f={state:ZN({lastMessage:this.state.snapshot(u),messageId:this.generateId()}),abortController:new AbortController};f.abortController.signal.addEventListener("abort",()=>{c=!0}),this.activeResponse=f;let g;if(e==="resume-stream"){const b=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:o});if(b==null){this.setStatus({status:"ready"});return}g=b}else g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:f.abortController.signal,metadata:t,headers:n,body:o,trigger:e,messageId:r});const m=b=>this.jobExecutor.run(()=>b({state:f.state,write:()=>{var y;this.setStatus({status:"streaming"}),f.state.message.id===((y=this.lastMessage)==null?void 0:y.id)?this.state.replaceMessage(this.state.messages.length-1,f.state.message):this.state.pushMessage(f.state.message)}}));await qN({stream:FN({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:m,onError:b=>{throw b}}),onError:b=>{throw b}}),this.setStatus({status:"ready"})}catch(f){if(c||f.name==="AbortError")return c=!0,this.setStatus({status:"ready"}),null;p=!0,f instanceof TypeError&&(f.message.toLowerCase().includes("fetch")||f.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&f instanceof Error&&this.onError(f),this.setStatus({status:"error",error:f})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:c,isDisconnect:d,isError:p,finishReason:(i=this.activeResponse)==null?void 0:i.state.finishReason})}catch(f){console.error(f)}this.activeResponse=void 0}(s=this.sendAutomaticallyWhen)!=null&&s.call(this,{messages:this.state.messages})&&!p&&await this.makeRequest({trigger:"submit-message",messageId:(l=this.lastMessage)==null?void 0:l.id,metadata:t,headers:n,body:o})}};const df=(e,t)=>{if(t==null)return[];let n=e.findIndex(o=>o.id===t);if(n===-1)throw new Error("useVercelAIThreadState: Message not found. This is likely an internal bug in assistant-ui.");for(;e[n+1]?.role==="assistant";)n++;return e.slice(0,n+1)},ff=e=>{const n=[...e.content.filter(o=>o.type!=="file"),...e.attachments?.flatMap(o=>o.content.map(r=>({...r,filename:o.name})))??[]].map(o=>{switch(o.type){case"text":return{type:"text",text:o.text};case"image":return{type:"file",url:o.image,...o.filename&&{filename:o.filename},mediaType:"image/png"};case"file":return{type:"file",url:o.data,mediaType:o.mimeType,...o.filename&&{filename:o.filename}};default:throw new Error(`Unsupported part type: ${o.type}`)}});return{role:e.role,parts:n}},YN=e=>new Promise((t,n)=>{const o=new FileReader;o.onload=()=>t(o.result),o.onerror=r=>n(r),o.readAsDataURL(e)}),QN={accept:"image/*, text/plain, text/html, text/markdown, text/csv, text/xml, text/json, text/css",async add({file:e}){return{id:v_(),type:e.type.startsWith("image/")?"image":"file",name:e.name,file:e,contentType:e.type,content:[],status:{type:"requires-action",reason:"composer-send"}}},async send(e){return{...e,status:{type:"complete"},content:[{type:"file",mimeType:e.contentType,filename:e.name,data:await YN(e.file)}]}},async remove(){}},pf=e=>U.getExternalStoreMessages(e);function XN(e){return e.replace(/[}\]"]+$/,"")}const ys=(e,t)=>!e.parts||e.parts.length===0?[]:e.parts.filter(n=>n.type!=="step-start"&&n.type!=="file").map(n=>{const o=n.type;if(o==="text")return{type:"text",text:n.text};if(o==="reasoning")return{type:"reasoning",text:n.text};if(Lr(n)){const r=o.replace("tool-",""),i=n.toolCallId;let a={},s,l=!1;n.state==="input-streaming"||n.state==="input-available"?a=n.input||{}:n.state==="output-available"?(a=n.input||{},s=n.output):n.state==="output-error"&&(a=n.input||{},l=!0,s={error:n.errorText});let u=JSON.stringify(a);n.state==="input-streaming"&&(u=XN(u));const c=t.toolStatuses?.[i];return{type:"tool-call",toolName:r,toolCallId:i,argsText:u,args:a,result:s,isError:l,...c?.type==="interrupt"&&{interrupt:c.payload,status:{type:"requires-action",reason:"interrupt"}}}}if(o==="dynamic-tool"){const r=n.toolName,i=n.toolCallId;let a={},s,l=!1;n.state==="input-streaming"||n.state==="input-available"?a=n.input||{}:n.state==="output-available"?(a=n.input||{},s=n.output):n.state==="output-error"&&(a=n.input||{},l=!0,s={error:n.errorText});const u=t.toolStatuses?.[i];return{type:"tool-call",toolName:r,toolCallId:i,argsText:JSON.stringify(a),args:a,result:s,isError:l,...u?.type==="interrupt"&&{interrupt:u.payload,status:{type:"requires-action",reason:"interrupt"}}}}return o==="source-url"?{type:"source",sourceType:"url",id:n.sourceId,url:n.url,title:n.title||""}:o==="source-document"?(console.warn(`Source document part type ${o} is not yet supported in conversion`),null):o.startsWith("data-")?{type:"data",name:o.substring(5),data:n.data}:(console.warn(`Unsupported message part type: ${o}`),null)}).filter(Boolean),mf=U.unstable_createMessageConverter((e,t)=>{const n=new Date;switch(e.role){case"user":return{role:"user",id:e.id,createdAt:n,content:ys(e,t),attachments:e.parts?.filter(o=>o.type==="file").map((o,r)=>({id:r.toString(),type:o.mediaType.startsWith("image/")?"image":"file",name:o.filename??"file",content:[o.mediaType.startsWith("image/")?{type:"image",image:o.url,filename:o.filename}:{type:"file",filename:o.filename,data:o.url,mimeType:o.mediaType}],contentType:o.mediaType??"unknown/unknown",status:{type:"complete"}}))};case"system":return{role:"system",id:e.id,createdAt:n,content:ys(e,t)};case"assistant":return{role:"assistant",id:e.id,createdAt:n,content:ys(e,t),metadata:{unstable_annotations:e.annotations,unstable_data:Array.isArray(e.data)?e.data:e.data?[e.data]:void 0,custom:{}}};default:return console.warn(`Unsupported message role: ${e.role}`),[]}}),eP={format:"ai-sdk/v5",encode({message:{id:e,parts:t,...n}}){return{...n,parts:t.filter(o=>o.type!=="file")}},decode(e){return{parentId:e.parent_id,message:{id:e.id,...e.content}}},getId(e){return e.id}},{MessageRepository:tP}=U.INTERNAL,rP=(e,t)=>({headId:t.headId,messages:t.messages.map(n=>{const o=e([n.message])[0];return{...n,message:o}})}),nP=(e,t,n,o,r)=>{const i=F.useRef(!1),a=U.useAssistantApi(),s=F.useCallback(()=>a.threadListItem.source?a.threadListItem():null,[a]),[l,u]=F.useState(!1),c=F.useRef(new Set),d=F.useRef(()=>r);return F.useEffect(()=>{d.current=r}),F.useEffect(()=>{if(!t||i.current)return;const p=async()=>{u(!0);try{const f=await t.withFormat?.(o).load();if(f&&f.messages.length>0){const g=rP(n,f);e.current.thread.import(g);const m=new tP;m.import(g);const b=m.getMessages();d.current(b.map(U.getExternalStoreMessages).flat()),c.current=new Set(g.messages.map(y=>y.message.id))}}catch(f){console.error("Failed to load message history:",f)}finally{u(!1)}};if(!i.current){if(i.current=!0,!s()?.getState().remoteId){u(!1);return}p()}},[a,t,o,n,e,s]),F.useEffect(()=>e.current.thread.subscribe(async()=>{const{messages:p,isRunning:f}=e.current.thread.getState();if(!f)for(let g=0;g<p.length;g++){const m=p[g];if(m.status===void 0||m.status.type==="complete"||m.status.type==="incomplete"){if(c.current.has(m.id))continue;c.current.add(m.id);const b=g>0?p[g-1].id:null;await t?.withFormat?.(o).append({parentId:b,message:U.getExternalStoreMessages(m)[0]})}}}),[t,o,e]),l},oP=(e,{adapters:t,toCreateMessage:n,cancelPendingToolCallsOnSend:o=!0}={})=>{const r=U.useRuntimeAdapters(),[i,a]=F.useState({}),s=Object.values(i).some(m=>m?.type==="executing"),l=e.status==="submitted"||e.status==="streaming"||s,u=mf.useThreadMessages({isRunning:l,messages:e.messages,metadata:F.useMemo(()=>({toolStatuses:i,...e.error&&{error:e.error.message}}),[i,e.error])}),[c]=F.useState(()=>({get current(){return g}})),d=U.INTERNAL.useToolInvocations({state:{messages:u,isRunning:l},getTools:()=>c.current.thread.getModelContext().tools,onResult:m=>{m.type==="add-tool-result"&&e.addToolResult({tool:m.toolName,toolCallId:m.toolCallId,output:m.result})},setToolStatuses:a}),p=nP(c,t?.history??r?.history,mf.toThreadMessages,eP,m=>{e.setMessages(m)}),f=async()=>{o&&(await d.abort(),e.setMessages(m=>{const b=m.at(-1);if(b?.role!=="assistant")return m;let y=!1;const x=b.parts?.map($=>!Lr($)||$.state==="output-available"||$.state==="output-error"?$:(y=!0,{...$,state:"output-error",errorText:"User cancelled tool call by sending a new message."}));return y?[...m.slice(0,-1),{...b,parts:x}]:m}))},g=U.useExternalStoreRuntime({isRunning:l,messages:u,setMessages:m=>e.setMessages(m.map(pf).filter(Boolean).flat()),onImport:m=>e.setMessages(m.map(pf).filter(Boolean).flat()),onCancel:async()=>{e.stop(),await d.abort()},onNew:async m=>{await f();const b=(n??ff)(m);await e.sendMessage(b,{metadata:m.runConfig})},onEdit:async m=>{const b=df(e.messages,m.parentId);e.setMessages(b);const y=(n??ff)(m);await e.sendMessage(y,{metadata:m.runConfig})},onReload:async(m,b)=>{const y=df(e.messages,m);e.setMessages(y),await e.regenerate({metadata:b.runConfig})},onAddToolResult:({toolCallId:m,result:b,isError:y})=>{y?e.addToolOutput({state:"output-error",tool:m,toolCallId:m,errorText:typeof b=="string"?b:JSON.stringify(b)}):e.addToolOutput({state:"output-available",tool:m,toolCallId:m,output:b})},onResumeToolCall:m=>d.resume(m.toolCallId,m.payload),adapters:{attachments:QN,...r,...t},isLoading:p});return g};var bs,hf;function iP(){if(hf)return bs;hf=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let o,r=0;return function(...a){clearTimeout(o);const s=Date.now(),l=s-r,u=n-l;u<=0?(r=s,t.apply(this,a)):o=setTimeout(()=>{r=Date.now(),t.apply(this,a)},u)}}return bs=e,bs}var aP=iP();const sP=qT(aP);var Fo={exports:{}},_s={};var gf;function uP(){if(gf)return _s;gf=1;var e=F;function t(d,p){return d===p&&(d!==0||1/d===1/p)||d!==d&&p!==p}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function s(d,p){var f=p(),g=o({inst:{value:f,getSnapshot:p}}),m=g[0].inst,b=g[1];return i(function(){m.value=f,m.getSnapshot=p,l(m)&&b({inst:m})},[d,f,p]),r(function(){return l(m)&&b({inst:m}),d(function(){l(m)&&b({inst:m})})},[d]),a(f),f}function l(d){var p=d.getSnapshot;d=d.value;try{var f=p();return!n(d,f)}catch{return!0}}function u(d,p){return p()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:s;return _s.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:c,_s}var ws={};var vf;function lP(){return vf||(vf=1,process.env.NODE_ENV!=="production"&&(function(){function e(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}function t(f,g){c||r.startTransition===void 0||(c=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var m=g();if(!d){var b=g();i(m,b)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}b=a({inst:{value:m,getSnapshot:g}});var y=b[0].inst,x=b[1];return l(function(){y.value=m,y.getSnapshot=g,n(y)&&x({inst:y})},[f,m,g]),s(function(){return n(y)&&x({inst:y}),f(function(){n(y)&&x({inst:y})})},[f]),u(m),m}function n(f){var g=f.getSnapshot;f=f.value;try{var m=g();return!i(f,m)}catch{return!0}}function o(f,g){return g()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var r=F,i=typeof Object.is=="function"?Object.is:e,a=r.useState,s=r.useEffect,l=r.useLayoutEffect,u=r.useDebugValue,c=!1,d=!1,p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:t;ws.useSyncExternalStore=r.useSyncExternalStore!==void 0?r.useSyncExternalStore:p,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),ws}var yf;function cP(){return yf||(yf=1,process.env.NODE_ENV==="production"?Fo.exports=uP():Fo.exports=lP()),Fo.exports}var dP=cP(),U_=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},_e=(e,t,n)=>(U_(e,t,"read from private field"),n?n.call(e):t.get(e)),Tt=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Qt=(e,t,n,o)=>(U_(e,t,"write to private field"),t.set(e,n),n);function fP(e,t){return t!=null?sP(e,t):e}var it,ti,ri,Sn,In,kn,Mr,tu,ru,pP=class{constructor(e=[]){Tt(this,it,void 0),Tt(this,ti,"ready"),Tt(this,ri,void 0),Tt(this,Sn,new Set),Tt(this,In,new Set),Tt(this,kn,new Set),this.pushMessage=t=>{Qt(this,it,_e(this,it).concat(t)),_e(this,Mr).call(this)},this.popMessage=()=>{Qt(this,it,_e(this,it).slice(0,-1)),_e(this,Mr).call(this)},this.replaceMessage=(t,n)=>{Qt(this,it,[..._e(this,it).slice(0,t),this.snapshot(n),..._e(this,it).slice(t+1)]),_e(this,Mr).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const o=n?fP(t,n):t;return _e(this,Sn).add(o),()=>{_e(this,Sn).delete(o)}},this["~registerStatusCallback"]=t=>(_e(this,In).add(t),()=>{_e(this,In).delete(t)}),this["~registerErrorCallback"]=t=>(_e(this,kn).add(t),()=>{_e(this,kn).delete(t)}),Tt(this,Mr,()=>{_e(this,Sn).forEach(t=>t())}),Tt(this,tu,()=>{_e(this,In).forEach(t=>t())}),Tt(this,ru,()=>{_e(this,kn).forEach(t=>t())}),Qt(this,it,e)}get status(){return _e(this,ti)}set status(e){Qt(this,ti,e),_e(this,tu).call(this)}get error(){return _e(this,ri)}set error(e){Qt(this,ri,e),_e(this,ru).call(this)}get messages(){return _e(this,it)}set messages(e){Qt(this,it,[...e]),_e(this,Mr).call(this)}};it=new WeakMap;ti=new WeakMap;ri=new WeakMap;Sn=new WeakMap;In=new WeakMap;kn=new WeakMap;Mr=new WeakMap;tu=new WeakMap;ru=new WeakMap;var Dr,bf=class extends KN{constructor({messages:t,...n}){const o=new pP(t);super({...n,state:o}),Tt(this,Dr,void 0),this["~registerMessagesCallback"]=(r,i)=>_e(this,Dr)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>_e(this,Dr)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>_e(this,Dr)["~registerErrorCallback"](r),Qt(this,Dr,o)}};Dr=new WeakMap;function mP({experimental_throttle:e,resume:t=!1,...n}={}){const o=F.useRef("chat"in n?n.chat:new bf(n));("chat"in n&&n.chat!==o.current||"id"in n&&o.current.id!==n.id)&&(o.current="chat"in n?n.chat:new bf(n));const i=F.useCallback(c=>o.current["~registerMessagesCallback"](c,e),[e,o.current.id]),a=F.useSyncExternalStore(i,()=>o.current.messages,()=>o.current.messages),s=F.useSyncExternalStore(o.current["~registerStatusCallback"],()=>o.current.status,()=>o.current.status),l=F.useSyncExternalStore(o.current["~registerErrorCallback"],()=>o.current.error,()=>o.current.error),u=F.useCallback(c=>{typeof c=="function"&&(c=c(o.current.messages)),o.current.messages=c},[o]);return F.useEffect(()=>{t&&o.current.resumeStream()},[t,o]),{id:o.current.id,messages:a,setMessages:u,sendMessage:o.current.sendMessage,regenerate:o.current.regenerate,clearError:o.current.clearError,stop:o.current.stop,error:l,resumeStream:o.current.resumeStream,status:s,addToolResult:o.current.addToolOutput,addToolOutput:o.current.addToolOutput}}const hP=e=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n.description?{description:n.description}:void 0,parameters:n.parameters instanceof hi.ZodType?hi.toJSONSchema(n.parameters):n.parameters}])),gP=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>!t.disabled&&t.type!=="backend"));class _f extends D_{runtime;constructor(t){super({...t,prepareSendMessagesRequest:async n=>{const o=this.runtime?.thread.getModelContext(),r=(await this.runtime?.threads.mainItem.initialize())?.remoteId??n.id,i={...n,body:{callSettings:o?.callSettings,system:o?.system,tools:hP(gP(o?.tools??{})),...n?.body}},a=await t?.prepareSendMessagesRequest?.(i);return{...a,body:a?.body??{...i.body,id:r,messages:n.messages,trigger:n.trigger,messageId:n.messageId,metadata:n.requestMetadata}}}})}setRuntime(t){this.runtime=t}}const vP=e=>{const t=F.useRef(e);return F.useEffect(()=>{t.current=e}),F.useMemo(()=>new Proxy(t.current,{get(o,r){const i=t.current[r];return typeof i=="function"?i.bind(t.current):i}}),[])},yP=e=>{const{adapters:t,transport:n,toCreateMessage:o,...r}=e??{},i=vP(n??new _f),a=U.useAssistantState(({threadListItem:u})=>u.id),s=mP({...r,id:a,transport:i}),l=oP(s,{adapters:t,...o&&{toCreateMessage:o}});return i instanceof _f&&i.setRuntime(l),l},bP=({cloud:e,...t}={})=>{const n=U.unstable_useCloudThreadListAdapter({cloud:e});return U.unstable_useRemoteThreadListRuntime({runtimeHook:function(){return yP(t)},adapter:n,allowNesting:!0})},_P=e=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n.description?{description:n.description}:void 0,inputSchema:Ma(n.parameters)}]));var wP=Object.defineProperty,xP=Object.defineProperties,$P=Object.getOwnPropertyDescriptors,wf=Object.getOwnPropertySymbols,SP=Object.prototype.hasOwnProperty,IP=Object.prototype.propertyIsEnumerable,xf=(e,t,n)=>t in e?wP(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ae=(e,t)=>{for(var n in t||(t={}))SP.call(t,n)&&xf(e,n,t[n]);if(wf)for(var n of wf(t))IP.call(t,n)&&xf(e,n,t[n]);return e},wi=(e,t)=>xP(e,$P(t)),L_="vercel.ai.error",kP=Symbol.for(L_),Z_,EP=class F_ extends Error{constructor({name:t,message:n,cause:o}){super(n),this[Z_]=!0,this.name=t,this.cause=o}static isInstance(t){return F_.hasMarker(t,L_)}static hasMarker(t,n){const o=Symbol.for(n);return t!=null&&typeof t=="object"&&o in t&&typeof t[o]=="boolean"&&t[o]===!0}};Z_=kP;var Ne=EP,q_="AI_APICallError",V_=`vercel.ai.error.${q_}`,OP=Symbol.for(V_),B_,$t=class extends Ne{constructor({message:e,url:t,requestBodyValues:n,statusCode:o,responseHeaders:r,responseBody:i,cause:a,isRetryable:s=o!=null&&(o===408||o===409||o===429||o>=500),data:l}){super({name:q_,message:e,cause:a}),this[B_]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=o,this.responseHeaders=r,this.responseBody=i,this.isRetryable=s,this.data=l}static isInstance(e){return Ne.hasMarker(e,V_)}};B_=OP;var J_="AI_EmptyResponseBodyError",W_=`vercel.ai.error.${J_}`,TP=Symbol.for(W_),H_,NP=class extends Ne{constructor({message:e="Empty response body"}={}){super({name:J_,message:e}),this[H_]=!0}static isInstance(e){return Ne.hasMarker(e,W_)}};H_=TP;function G_(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var K_="AI_InvalidArgumentError",Y_=`vercel.ai.error.${K_}`,PP=Symbol.for(Y_),Q_,X_=class extends Ne{constructor({message:t,cause:n,argument:o}){super({name:K_,message:t,cause:n}),this[Q_]=!0,this.argument=o}static isInstance(t){return Ne.hasMarker(t,Y_)}};Q_=PP;var ew="AI_InvalidPromptError",tw=`vercel.ai.error.${ew}`,CP=Symbol.for(tw),rw,jP=class extends Ne{constructor({prompt:e,message:t,cause:n}){super({name:ew,message:`Invalid prompt: ${t}`,cause:n}),this[rw]=!0,this.prompt=e}static isInstance(e){return Ne.hasMarker(e,tw)}};rw=CP;var nw="AI_InvalidResponseDataError",ow=`vercel.ai.error.${nw}`,AP=Symbol.for(ow),iw,_n=class extends Ne{constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:nw,message:t}),this[iw]=!0,this.data=e}static isInstance(e){return Ne.hasMarker(e,ow)}};iw=AP;var aw="AI_JSONParseError",sw=`vercel.ai.error.${aw}`,RP=Symbol.for(sw),uw,xi=class extends Ne{constructor({text:e,cause:t}){super({name:aw,message:`JSON parsing failed: Text: ${e}.
|
|
38
|
-
Error message: ${
|
|
39
|
-
Error message: ${
|
|
40
|
-
`;break;case"id":s=b.includes("\0")?void 0:b;break;case"retry":/^\d+$/.test(b)?o(parseInt(b,10)):n(new
|
|
41
|
-
`)?l.slice(0,-1):l}),s=void 0,l="",u=""}function g(
|
|
37
|
+
`)}})}});var FN=QT(()=>S_(G([be({type:C("text-start"),id:w(),providerMetadata:ke.optional()}),be({type:C("text-delta"),id:w(),delta:w(),providerMetadata:ke.optional()}),be({type:C("text-end"),id:w(),providerMetadata:ke.optional()}),be({type:C("error"),errorText:w()}),be({type:C("tool-input-start"),toolCallId:w(),toolName:w(),providerExecuted:pe().optional(),dynamic:pe().optional()}),be({type:C("tool-input-delta"),toolCallId:w(),inputTextDelta:w()}),be({type:C("tool-input-available"),toolCallId:w(),toolName:w(),input:$e(),providerExecuted:pe().optional(),providerMetadata:ke.optional(),dynamic:pe().optional()}),be({type:C("tool-input-error"),toolCallId:w(),toolName:w(),input:$e(),providerExecuted:pe().optional(),providerMetadata:ke.optional(),dynamic:pe().optional(),errorText:w()}),be({type:C("tool-output-available"),toolCallId:w(),output:$e(),providerExecuted:pe().optional(),dynamic:pe().optional(),preliminary:pe().optional()}),be({type:C("tool-output-error"),toolCallId:w(),errorText:w(),providerExecuted:pe().optional(),dynamic:pe().optional()}),be({type:C("reasoning-start"),id:w(),providerMetadata:ke.optional()}),be({type:C("reasoning-delta"),id:w(),delta:w(),providerMetadata:ke.optional()}),be({type:C("reasoning-end"),id:w(),providerMetadata:ke.optional()}),be({type:C("source-url"),sourceId:w(),url:w(),title:w().optional(),providerMetadata:ke.optional()}),be({type:C("source-document"),sourceId:w(),mediaType:w(),title:w(),filename:w().optional(),providerMetadata:ke.optional()}),be({type:C("file"),url:w(),mediaType:w(),providerMetadata:ke.optional()}),be({type:Io(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:w().optional(),data:$e(),transient:pe().optional()}),be({type:C("start-step")}),be({type:C("finish-step")}),be({type:C("start"),messageId:w().optional(),messageMetadata:$e().optional()}),be({type:C("finish"),finishReason:dr(["stop","length","content-filter","tool-calls","error","other","unknown"]).optional(),messageMetadata:$e().optional()}),be({type:C("abort")}),be({type:C("message-metadata"),messageMetadata:$e()})])));function qN(e){return e.type.startsWith("data-")}function D_(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const r=t[o];if(r===void 0)continue;const i=o in e?e[o]:void 0,a=r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp),s=i!=null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp);a&&s?n[o]=D_(i,r):n[o]=r}return n}function VN(e){const t=["ROOT"];let n=-1,o=null;function r(l,u,c){switch(l){case'"':{n=u,t.pop(),t.push(c),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=u,o=u,t.pop(),t.push(c),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=u,t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"{":{n=u,t.pop(),t.push(c),t.push("INSIDE_OBJECT_START");break}case"[":{n=u,t.pop(),t.push(c),t.push("INSIDE_ARRAY_START");break}}}function i(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":r(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{r(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),n=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{n=l,t.pop();break}default:{n=l,r(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,t.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{r(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(o,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?i(u,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l)):n=l;break}}}let s=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{s+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{s+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{s+="]";break}case"INSIDE_LITERAL":{const c=e.substring(o,e.length);"true".startsWith(c)?s+="true".slice(c.length):"false".startsWith(c)?s+="false".slice(c.length):"null".startsWith(c)&&(s+="null".slice(c.length))}}return s}async function U_(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await _i({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await _i({text:VN(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function Zr(e){return e.type.startsWith("tool-")}function BN(e){return e.type==="dynamic-tool"}function cp(e){return Zr(e)||BN(e)}function dp(e){return e.type.split("-").slice(1).join("-")}function JN({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function WN({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:o,onError:r,onToolCall:i,onData:a}){return e.pipeThrough(new TransformStream({async transform(s,l){await o(async({state:u,write:c})=>{var d,f,p,g;function h(v){const N=u.message.parts.filter(Zr).find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function b(v){const N=u.message.parts.filter(I=>I.type==="dynamic-tool").find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function y(v){var k;const N=u.message.parts.find(z=>Zr(z)&&z.toolCallId===v.toolCallId),I=v,O=N;N!=null?(N.state=v.state,O.input=I.input,O.output=I.output,O.errorText=I.errorText,O.rawInput=I.rawInput,O.preliminary=I.preliminary,O.providerExecuted=(k=I.providerExecuted)!=null?k:N.providerExecuted,I.providerMetadata!=null&&N.state==="input-available"&&(N.callProviderMetadata=I.providerMetadata)):u.message.parts.push({type:`tool-${v.toolName}`,toolCallId:v.toolCallId,state:v.state,input:I.input,output:I.output,rawInput:I.rawInput,errorText:I.errorText,providerExecuted:I.providerExecuted,preliminary:I.preliminary,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}function x(v){var k,N;const I=u.message.parts.find(F=>F.type==="dynamic-tool"&&F.toolCallId===v.toolCallId),O=v,z=I;I!=null?(I.state=v.state,z.toolName=v.toolName,z.input=O.input,z.output=O.output,z.errorText=O.errorText,z.rawInput=(k=O.rawInput)!=null?k:z.rawInput,z.preliminary=O.preliminary,z.providerExecuted=(N=O.providerExecuted)!=null?N:I.providerExecuted,O.providerMetadata!=null&&I.state==="input-available"&&(I.callProviderMetadata=O.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:v.toolName,toolCallId:v.toolCallId,state:v.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,...O.providerMetadata!=null?{callProviderMetadata:O.providerMetadata}:{}})}async function $(v){if(v!=null){const k=u.message.metadata!=null?D_(u.message.metadata,v):v;t!=null&&await np({value:k,schema:t}),u.message.metadata=k}}switch(s.type){case"text-start":{const v={type:"text",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeTextParts[s.id]=v,u.message.parts.push(v),c();break}case"text-delta":{const v=u.activeTextParts[s.id];v.text+=s.delta,v.providerMetadata=(d=s.providerMetadata)!=null?d:v.providerMetadata,c();break}case"text-end":{const v=u.activeTextParts[s.id];v.state="done",v.providerMetadata=(f=s.providerMetadata)!=null?f:v.providerMetadata,delete u.activeTextParts[s.id],c();break}case"reasoning-start":{const v={type:"reasoning",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeReasoningParts[s.id]=v,u.message.parts.push(v),c();break}case"reasoning-delta":{const v=u.activeReasoningParts[s.id];v.text+=s.delta,v.providerMetadata=(p=s.providerMetadata)!=null?p:v.providerMetadata,c();break}case"reasoning-end":{const v=u.activeReasoningParts[s.id];v.providerMetadata=(g=s.providerMetadata)!=null?g:v.providerMetadata,v.state="done",delete u.activeReasoningParts[s.id],c();break}case"file":{u.message.parts.push({type:"file",mediaType:s.mediaType,url:s.url}),c();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:s.sourceId,url:s.url,title:s.title,providerMetadata:s.providerMetadata}),c();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:s.sourceId,mediaType:s.mediaType,title:s.title,filename:s.filename,providerMetadata:s.providerMetadata}),c();break}case"tool-input-start":{const v=u.message.parts.filter(Zr);u.partialToolCalls[s.toolCallId]={text:"",toolName:s.toolName,index:v.length,dynamic:s.dynamic},s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}),c();break}case"tool-input-delta":{const v=u.partialToolCalls[s.toolCallId];v.text+=s.inputTextDelta;const{value:k}=await U_(v.text);v.dynamic?x({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}):y({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}),c();break}case"tool-input-available":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c(),i&&!s.providerExecuted&&await i({toolCall:s});break}case"tool-input-error":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:void 0,rawInput:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c();break}case"tool-output-available":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-available",input:v.input,output:s.output,preliminary:s.preliminary})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:dp(v),state:"output-available",input:v.input,output:s.output,providerExecuted:s.providerExecuted,preliminary:s.preliminary})}c();break}case"tool-output-error":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-error",input:v.input,errorText:s.errorText,providerExecuted:s.providerExecuted})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:dp(v),state:"output-error",input:v.input,rawInput:v.rawInput,errorText:s.errorText,providerExecuted:s.providerExecuted})}c();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{s.messageId!=null&&(u.message.id=s.messageId),await $(s.messageMetadata),(s.messageId!=null||s.messageMetadata!=null)&&c();break}case"finish":{s.finishReason!=null&&(u.finishReason=s.finishReason),await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"message-metadata":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"error":{r?.(new Error(s.errorText));break}default:if(qN(s)){n?.[s.type]!=null&&await np({value:s.data,schema:n[s.type]});const v=s;if(v.transient){a?.(v);break}const k=v.id!=null?u.message.parts.find(N=>v.type===N.type&&v.id===N.id):void 0;k!=null?k.data=v.data:u.message.parts.push(v),a?.(v),c()}}l.enqueue(s)})}}))}async function HN({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:o}=await n.read();if(o)break}}catch(o){t?.(o)}finally{n.releaseLock()}}ko({prefix:"aitxt",size:24});ko({prefix:"aiobj",size:24});var GN=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(o){n(o)}}),this.processQueue()})}};ko({prefix:"aiobj",size:24});var KN={};CN(KN,{object:()=>QN,text:()=>YN});var YN=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),QN=({schema:e})=>{const t=WO(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:n}){const o=await U_(n);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value};default:{const r=o.state;throw new Error(`Unsupported parse state: ${r}`)}}},async parseOutput({text:n},o){const r=await _i({text:n});if(!r.success)throw new up({message:"No object generated: could not parse the response.",cause:r.error,text:n,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=await Sc({value:r.value,schema:t});if(!i.success)throw new up({message:"No object generated: response did not match schema.",cause:i.error,text:n,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.value}}};async function XN(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:o}=t,r=await new Promise((i,a)=>{const s=new FileReader;s.onload=l=>{var u;i((u=l.target)==null?void 0:u.result)},s.onerror=l=>a(l),s.readAsDataURL(t)});return{type:"file",mediaType:o,filename:n,url:r}}))}var eP=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:o,fetch:r,prepareSendMessagesRequest:i,prepareReconnectToStreamRequest:a}){this.api=e,this.credentials=t,this.headers=n,this.body=o,this.fetch=r,this.prepareSendMessagesRequest=i,this.prepareReconnectToStreamRequest=a}async sendMessages({abortSignal:e,...t}){var n,o,r,i,a;const s=await Ar(this.body),l=await Ar(this.headers),u=await Ar(this.credentials),c={...fr(l),...fr(t.headers)},d=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...s,...t.body},headers:c,credentials:u,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),f=(o=d?.api)!=null?o:this.api,p=d?.headers!==void 0?fr(d.headers):c,g=d?.body!==void 0?d.body:{...s,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},h=(r=d?.credentials)!=null?r:u,y=await((i=this.fetch)!=null?i:globalThis.fetch)(f,{method:"POST",headers:tp({"Content-Type":"application/json",...p},`ai-sdk/${lp}`,ep()),body:JSON.stringify(g),credentials:h,signal:e});if(!y.ok)throw new Error((a=await y.text())!=null?a:"Failed to fetch the chat response.");if(!y.body)throw new Error("The response body is empty.");return this.processResponseStream(y.body)}async reconnectToStream(e){var t,n,o,r,i;const a=await Ar(this.body),s=await Ar(this.headers),l=await Ar(this.credentials),u={...fr(s),...fr(e.headers)},c=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...a,...e.body},headers:u,credentials:l,requestMetadata:e.metadata})),d=(n=c?.api)!=null?n:`${this.api}/${e.chatId}/stream`,f=c?.headers!==void 0?fr(c.headers):u,p=(o=c?.credentials)!=null?o:l,h=await((r=this.fetch)!=null?r:globalThis.fetch)(d,{method:"GET",headers:tp(f,`ai-sdk/${lp}`,ep()),credentials:p});if(h.status===204)return null;if(!h.ok)throw new Error((i=await h.text())!=null?i:"Failed to fetch the chat response.");if(!h.body)throw new Error("The response body is empty.");return this.processResponseStream(h.body)}},L_=class extends eP{constructor(e={}){super(e)}processResponseStream(e){return tO({stream:e,schema:FN}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},tP=class{constructor({generateId:e=b_,id:t=e(),transport:n=new L_,messageMetadataSchema:o,dataPartSchemas:r,state:i,onError:a,onToolCall:s,onFinish:l,onData:u,sendAutomaticallyWhen:c}){this.activeResponse=void 0,this.jobExecutor=new GN,this.sendMessage=async(d,f)=>{var p,g,h,b;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(p=this.lastMessage)==null?void 0:p.id,...f});return}let y;if("text"in d||"files"in d?y={parts:[...Array.isArray(d.files)?d.files:await XN(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:y=d,d.messageId!=null){const x=this.state.messages.findIndex($=>$.id===d.messageId);if(x===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[x].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,x+1),this.state.replaceMessage(x,{...y,id:d.messageId,role:(g=y.role)!=null?g:"user",metadata:d.metadata})}else this.state.pushMessage({...y,id:(h=y.id)!=null?h:this.generateId(),role:(b=y.role)!=null?b:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...f})},this.regenerate=async({messageId:d,...f}={})=>{const p=d==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===d);if(p===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[p].role==="assistant"?p:p+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...f})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolOutput=async({state:d="output-available",tool:f,toolCallId:p,output:g,errorText:h})=>this.jobExecutor.run(async()=>{var b,y;const x=this.state.messages,$=x[x.length-1];this.state.replaceMessage(x.length-1,{...$,parts:$.parts.map(v=>cp(v)&&v.toolCallId===p?{...v,state:d,output:g,errorText:h}:v)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(v=>cp(v)&&v.toolCallId===p?{...v,state:d,output:g,errorText:h}:v)),this.status!=="streaming"&&this.status!=="submitted"&&((b=this.sendAutomaticallyWhen)!=null&&b.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(y=this.lastMessage)==null?void 0:y.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=o,this.dataPartSchemas=r,this.state=i,this.onError=a,this.onToolCall=s,this.onFinish=l,this.onData=u,this.sendAutomaticallyWhen=c}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async makeRequest({trigger:e,metadata:t,headers:n,body:o,messageId:r}){var i,a,s,l;this.setStatus({status:"submitted",error:void 0});const u=this.lastMessage;let c=!1,d=!1,f=!1;try{const p={state:JN({lastMessage:this.state.snapshot(u),messageId:this.generateId()}),abortController:new AbortController};p.abortController.signal.addEventListener("abort",()=>{c=!0}),this.activeResponse=p;let g;if(e==="resume-stream"){const b=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:o});if(b==null){this.setStatus({status:"ready"});return}g=b}else g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:p.abortController.signal,metadata:t,headers:n,body:o,trigger:e,messageId:r});const h=b=>this.jobExecutor.run(()=>b({state:p.state,write:()=>{var y;this.setStatus({status:"streaming"}),p.state.message.id===((y=this.lastMessage)==null?void 0:y.id)?this.state.replaceMessage(this.state.messages.length-1,p.state.message):this.state.pushMessage(p.state.message)}}));await HN({stream:WN({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:h,onError:b=>{throw b}}),onError:b=>{throw b}}),this.setStatus({status:"ready"})}catch(p){if(c||p.name==="AbortError")return c=!0,this.setStatus({status:"ready"}),null;f=!0,p instanceof TypeError&&(p.message.toLowerCase().includes("fetch")||p.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:c,isDisconnect:d,isError:f,finishReason:(i=this.activeResponse)==null?void 0:i.state.finishReason})}catch(p){console.error(p)}this.activeResponse=void 0}(s=this.sendAutomaticallyWhen)!=null&&s.call(this,{messages:this.state.messages})&&!f&&await this.makeRequest({trigger:"submit-message",messageId:(l=this.lastMessage)==null?void 0:l.id,metadata:t,headers:n,body:o})}};const pp=(e,t)=>{if(t==null)return[];let n=e.findIndex(o=>o.id===t);if(n===-1)throw new Error("useVercelAIThreadState: Message not found. This is likely an internal bug in assistant-ui.");for(;e[n+1]?.role==="assistant";)n++;return e.slice(0,n+1)},fp=e=>{const n=[...e.content.filter(o=>o.type!=="file"),...e.attachments?.flatMap(o=>o.content.map(r=>({...r,filename:o.name})))??[]].map(o=>{switch(o.type){case"text":return{type:"text",text:o.text};case"image":return{type:"file",url:o.image,...o.filename&&{filename:o.filename},mediaType:"image/png"};case"file":return{type:"file",url:o.data,mediaType:o.mimeType,...o.filename&&{filename:o.filename}};default:throw new Error(`Unsupported part type: ${o.type}`)}});return{role:e.role,parts:n}},rP=e=>new Promise((t,n)=>{const o=new FileReader;o.onload=()=>t(o.result),o.onerror=r=>n(r),o.readAsDataURL(e)}),nP={accept:"image/*, text/plain, text/html, text/markdown, text/csv, text/xml, text/json, text/css",async add({file:e}){return{id:b_(),type:e.type.startsWith("image/")?"image":"file",name:e.name,file:e,contentType:e.type,content:[],status:{type:"requires-action",reason:"composer-send"}}},async send(e){return{...e,status:{type:"complete"},content:[{type:"file",mimeType:e.contentType,filename:e.name,data:await rP(e.file)}]}},async remove(){}},mp=e=>L.getExternalStoreMessages(e);function oP(e){return e.replace(/[}\]"]+$/,"")}const ws=(e,t)=>!e.parts||e.parts.length===0?[]:e.parts.filter(n=>n.type!=="step-start"&&n.type!=="file").map(n=>{const o=n.type;if(o==="text")return{type:"text",text:n.text};if(o==="reasoning")return{type:"reasoning",text:n.text};if(Zr(n)){const r=o.replace("tool-",""),i=n.toolCallId;let a={},s,l=!1;n.state==="input-streaming"||n.state==="input-available"?a=n.input||{}:n.state==="output-available"?(a=n.input||{},s=n.output):n.state==="output-error"&&(a=n.input||{},l=!0,s={error:n.errorText});let u=JSON.stringify(a);n.state==="input-streaming"&&(u=oP(u));const c=t.toolStatuses?.[i];return{type:"tool-call",toolName:r,toolCallId:i,argsText:u,args:a,result:s,isError:l,...c?.type==="interrupt"&&{interrupt:c.payload,status:{type:"requires-action",reason:"interrupt"}}}}if(o==="dynamic-tool"){const r=n.toolName,i=n.toolCallId;let a={},s,l=!1;n.state==="input-streaming"||n.state==="input-available"?a=n.input||{}:n.state==="output-available"?(a=n.input||{},s=n.output):n.state==="output-error"&&(a=n.input||{},l=!0,s={error:n.errorText});const u=t.toolStatuses?.[i];return{type:"tool-call",toolName:r,toolCallId:i,argsText:JSON.stringify(a),args:a,result:s,isError:l,...u?.type==="interrupt"&&{interrupt:u.payload,status:{type:"requires-action",reason:"interrupt"}}}}return o==="source-url"?{type:"source",sourceType:"url",id:n.sourceId,url:n.url,title:n.title||""}:o==="source-document"?(console.warn(`Source document part type ${o} is not yet supported in conversion`),null):o.startsWith("data-")?{type:"data",name:o.substring(5),data:n.data}:(console.warn(`Unsupported message part type: ${o}`),null)}).filter(Boolean),hp=L.unstable_createMessageConverter((e,t)=>{const n=new Date;switch(e.role){case"user":return{role:"user",id:e.id,createdAt:n,content:ws(e,t),attachments:e.parts?.filter(o=>o.type==="file").map((o,r)=>({id:r.toString(),type:o.mediaType.startsWith("image/")?"image":"file",name:o.filename??"file",content:[o.mediaType.startsWith("image/")?{type:"image",image:o.url,filename:o.filename}:{type:"file",filename:o.filename,data:o.url,mimeType:o.mediaType}],contentType:o.mediaType??"unknown/unknown",status:{type:"complete"}}))};case"system":return{role:"system",id:e.id,createdAt:n,content:ws(e,t)};case"assistant":return{role:"assistant",id:e.id,createdAt:n,content:ws(e,t),metadata:{unstable_annotations:e.annotations,unstable_data:Array.isArray(e.data)?e.data:e.data?[e.data]:void 0,custom:{}}};default:return console.warn(`Unsupported message role: ${e.role}`),[]}}),iP={format:"ai-sdk/v5",encode({message:{id:e,parts:t,...n}}){return{...n,parts:t.filter(o=>o.type!=="file")}},decode(e){return{parentId:e.parent_id,message:{id:e.id,...e.content}}},getId(e){return e.id}},{MessageRepository:aP}=L.INTERNAL,sP=(e,t)=>({headId:t.headId,messages:t.messages.map(n=>{const o=e([n.message])[0];return{...n,message:o}})}),uP=(e,t,n,o,r)=>{const i=D.useRef(!1),a=L.useAssistantApi(),s=D.useCallback(()=>a.threadListItem.source?a.threadListItem():null,[a]),[l,u]=D.useState(!1),c=D.useRef(new Set),d=D.useRef(()=>r);return D.useEffect(()=>{d.current=r}),D.useEffect(()=>{if(!t||i.current)return;const f=async()=>{u(!0);try{const p=await t.withFormat?.(o).load();if(p&&p.messages.length>0){const g=sP(n,p);e.current.thread.import(g);const h=new aP;h.import(g);const b=h.getMessages();d.current(b.map(L.getExternalStoreMessages).flat()),c.current=new Set(g.messages.map(y=>y.message.id))}}catch(p){console.error("Failed to load message history:",p)}finally{u(!1)}};if(!i.current){if(i.current=!0,!s()?.getState().remoteId){u(!1);return}f()}},[a,t,o,n,e,s]),D.useEffect(()=>e.current.thread.subscribe(async()=>{const{messages:f,isRunning:p}=e.current.thread.getState();if(!p)for(let g=0;g<f.length;g++){const h=f[g];if(h.status===void 0||h.status.type==="complete"||h.status.type==="incomplete"){if(c.current.has(h.id))continue;c.current.add(h.id);const b=g>0?f[g-1].id:null;await t?.withFormat?.(o).append({parentId:b,message:L.getExternalStoreMessages(h)[0]})}}}),[t,o,e]),l},lP=(e,{adapters:t,toCreateMessage:n,cancelPendingToolCallsOnSend:o=!0}={})=>{const r=L.useRuntimeAdapters(),[i,a]=D.useState({}),s=Object.values(i).some(h=>h?.type==="executing"),l=e.status==="submitted"||e.status==="streaming"||s,u=hp.useThreadMessages({isRunning:l,messages:e.messages,metadata:D.useMemo(()=>({toolStatuses:i,...e.error&&{error:e.error.message}}),[i,e.error])}),[c]=D.useState(()=>({get current(){return g}})),d=L.INTERNAL.useToolInvocations({state:{messages:u,isRunning:l},getTools:()=>c.current.thread.getModelContext().tools,onResult:h=>{h.type==="add-tool-result"&&e.addToolResult({tool:h.toolName,toolCallId:h.toolCallId,output:h.result})},setToolStatuses:a}),f=uP(c,t?.history??r?.history,hp.toThreadMessages,iP,h=>{e.setMessages(h)}),p=async()=>{o&&(await d.abort(),e.setMessages(h=>{const b=h.at(-1);if(b?.role!=="assistant")return h;let y=!1;const x=b.parts?.map($=>!Zr($)||$.state==="output-available"||$.state==="output-error"?$:(y=!0,{...$,state:"output-error",errorText:"User cancelled tool call by sending a new message."}));return y?[...h.slice(0,-1),{...b,parts:x}]:h}))},g=L.useExternalStoreRuntime({isRunning:l,messages:u,setMessages:h=>e.setMessages(h.map(mp).filter(Boolean).flat()),onImport:h=>e.setMessages(h.map(mp).filter(Boolean).flat()),onCancel:async()=>{e.stop(),await d.abort()},onNew:async h=>{await p();const b=(n??fp)(h);await e.sendMessage(b,{metadata:h.runConfig})},onEdit:async h=>{const b=pp(e.messages,h.parentId);e.setMessages(b);const y=(n??fp)(h);await e.sendMessage(y,{metadata:h.runConfig})},onReload:async(h,b)=>{const y=pp(e.messages,h);e.setMessages(y),await e.regenerate({metadata:b.runConfig})},onAddToolResult:({toolCallId:h,result:b,isError:y})=>{y?e.addToolOutput({state:"output-error",tool:h,toolCallId:h,errorText:typeof b=="string"?b:JSON.stringify(b)}):e.addToolOutput({state:"output-available",tool:h,toolCallId:h,output:b})},onResumeToolCall:h=>d.resume(h.toolCallId,h.payload),adapters:{attachments:nP,...r,...t},isLoading:f});return g};var xs,gp;function cP(){if(gp)return xs;gp=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let o,r=0;return function(...a){clearTimeout(o);const s=Date.now(),l=s-r,u=n-l;u<=0?(r=s,t.apply(this,a)):o=setTimeout(()=>{r=Date.now(),t.apply(this,a)},u)}}return xs=e,xs}var dP=cP();const pP=HO(dP);var qo={exports:{}},$s={};var vp;function fP(){if(vp)return $s;vp=1;var e=D;function t(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function s(d,f){var p=f(),g=o({inst:{value:p,getSnapshot:f}}),h=g[0].inst,b=g[1];return i(function(){h.value=p,h.getSnapshot=f,l(h)&&b({inst:h})},[d,p,f]),r(function(){return l(h)&&b({inst:h}),d(function(){l(h)&&b({inst:h})})},[d]),a(p),p}function l(d){var f=d.getSnapshot;d=d.value;try{var p=f();return!n(d,p)}catch{return!0}}function u(d,f){return f()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:s;return $s.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:c,$s}var Ss={};var yp;function mP(){return yp||(yp=1,process.env.NODE_ENV!=="production"&&(function(){function e(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}function t(p,g){c||r.startTransition===void 0||(c=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var h=g();if(!d){var b=g();i(h,b)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}b=a({inst:{value:h,getSnapshot:g}});var y=b[0].inst,x=b[1];return l(function(){y.value=h,y.getSnapshot=g,n(y)&&x({inst:y})},[p,h,g]),s(function(){return n(y)&&x({inst:y}),p(function(){n(y)&&x({inst:y})})},[p]),u(h),h}function n(p){var g=p.getSnapshot;p=p.value;try{var h=g();return!i(p,h)}catch{return!0}}function o(p,g){return g()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var r=D,i=typeof Object.is=="function"?Object.is:e,a=r.useState,s=r.useEffect,l=r.useLayoutEffect,u=r.useDebugValue,c=!1,d=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:t;Ss.useSyncExternalStore=r.useSyncExternalStore!==void 0?r.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Ss}var bp;function hP(){return bp||(bp=1,process.env.NODE_ENV==="production"?qo.exports=fP():qo.exports=mP()),qo.exports}var gP=hP(),Z_=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},_e=(e,t,n)=>(Z_(e,t,"read from private field"),n?n.call(e):t.get(e)),Ot=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Yt=(e,t,n,o)=>(Z_(e,t,"write to private field"),t.set(e,n),n);function vP(e,t){return t!=null?pP(e,t):e}var it,ri,ni,In,kn,En,Dr,iu,au,yP=class{constructor(e=[]){Ot(this,it,void 0),Ot(this,ri,"ready"),Ot(this,ni,void 0),Ot(this,In,new Set),Ot(this,kn,new Set),Ot(this,En,new Set),this.pushMessage=t=>{Yt(this,it,_e(this,it).concat(t)),_e(this,Dr).call(this)},this.popMessage=()=>{Yt(this,it,_e(this,it).slice(0,-1)),_e(this,Dr).call(this)},this.replaceMessage=(t,n)=>{Yt(this,it,[..._e(this,it).slice(0,t),this.snapshot(n),..._e(this,it).slice(t+1)]),_e(this,Dr).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const o=n?vP(t,n):t;return _e(this,In).add(o),()=>{_e(this,In).delete(o)}},this["~registerStatusCallback"]=t=>(_e(this,kn).add(t),()=>{_e(this,kn).delete(t)}),this["~registerErrorCallback"]=t=>(_e(this,En).add(t),()=>{_e(this,En).delete(t)}),Ot(this,Dr,()=>{_e(this,In).forEach(t=>t())}),Ot(this,iu,()=>{_e(this,kn).forEach(t=>t())}),Ot(this,au,()=>{_e(this,En).forEach(t=>t())}),Yt(this,it,e)}get status(){return _e(this,ri)}set status(e){Yt(this,ri,e),_e(this,iu).call(this)}get error(){return _e(this,ni)}set error(e){Yt(this,ni,e),_e(this,au).call(this)}get messages(){return _e(this,it)}set messages(e){Yt(this,it,[...e]),_e(this,Dr).call(this)}};it=new WeakMap;ri=new WeakMap;ni=new WeakMap;In=new WeakMap;kn=new WeakMap;En=new WeakMap;Dr=new WeakMap;iu=new WeakMap;au=new WeakMap;var Ur,_p=class extends tP{constructor({messages:t,...n}){const o=new yP(t);super({...n,state:o}),Ot(this,Ur,void 0),this["~registerMessagesCallback"]=(r,i)=>_e(this,Ur)["~registerMessagesCallback"](r,i),this["~registerStatusCallback"]=r=>_e(this,Ur)["~registerStatusCallback"](r),this["~registerErrorCallback"]=r=>_e(this,Ur)["~registerErrorCallback"](r),Yt(this,Ur,o)}};Ur=new WeakMap;function bP({experimental_throttle:e,resume:t=!1,...n}={}){const o=D.useRef("chat"in n?n.chat:new _p(n));("chat"in n&&n.chat!==o.current||"id"in n&&o.current.id!==n.id)&&(o.current="chat"in n?n.chat:new _p(n));const i=D.useCallback(c=>o.current["~registerMessagesCallback"](c,e),[e,o.current.id]),a=D.useSyncExternalStore(i,()=>o.current.messages,()=>o.current.messages),s=D.useSyncExternalStore(o.current["~registerStatusCallback"],()=>o.current.status,()=>o.current.status),l=D.useSyncExternalStore(o.current["~registerErrorCallback"],()=>o.current.error,()=>o.current.error),u=D.useCallback(c=>{typeof c=="function"&&(c=c(o.current.messages)),o.current.messages=c},[o]);return D.useEffect(()=>{t&&o.current.resumeStream()},[t,o]),{id:o.current.id,messages:a,setMessages:u,sendMessage:o.current.sendMessage,regenerate:o.current.regenerate,clearError:o.current.clearError,stop:o.current.stop,error:l,resumeStream:o.current.resumeStream,status:s,addToolResult:o.current.addToolOutput,addToolOutput:o.current.addToolOutput}}const _P=e=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n.description?{description:n.description}:void 0,parameters:n.parameters instanceof vi.ZodType?vi.toJSONSchema(n.parameters):n.parameters}])),wP=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>!t.disabled&&t.type!=="backend"));class wp extends L_{runtime;constructor(t){super({...t,prepareSendMessagesRequest:async n=>{const o=this.runtime?.thread.getModelContext(),r=(await this.runtime?.threads.mainItem.initialize())?.remoteId??n.id,i={...n,body:{callSettings:o?.callSettings,system:o?.system,tools:_P(wP(o?.tools??{})),...n?.body}},a=await t?.prepareSendMessagesRequest?.(i);return{...a,body:a?.body??{...i.body,id:r,messages:n.messages,trigger:n.trigger,messageId:n.messageId,metadata:n.requestMetadata}}}})}setRuntime(t){this.runtime=t}}const xP=e=>{const t=D.useRef(e);return D.useEffect(()=>{t.current=e}),D.useMemo(()=>new Proxy(t.current,{get(o,r){const i=t.current[r];return typeof i=="function"?i.bind(t.current):i}}),[])},$P=e=>{const{adapters:t,transport:n,toCreateMessage:o,...r}=e??{},i=xP(n??new wp),a=L.useAssistantState(({threadListItem:u})=>u.id),s=bP({...r,id:a,transport:i}),l=lP(s,{adapters:t,...o&&{toCreateMessage:o}});return i instanceof wp&&i.setRuntime(l),l},SP=({cloud:e,...t}={})=>{const n=L.unstable_useCloudThreadListAdapter({cloud:e});return L.unstable_useRemoteThreadListRuntime({runtimeHook:function(){return $P(t)},adapter:n,allowNesting:!0})},IP=e=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n.description?{description:n.description}:void 0,inputSchema:La(n.parameters)}]));var kP=Object.defineProperty,EP=Object.defineProperties,TP=Object.getOwnPropertyDescriptors,xp=Object.getOwnPropertySymbols,OP=Object.prototype.hasOwnProperty,NP=Object.prototype.propertyIsEnumerable,$p=(e,t,n)=>t in e?kP(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ae=(e,t)=>{for(var n in t||(t={}))OP.call(t,n)&&$p(e,n,t[n]);if(xp)for(var n of xp(t))NP.call(t,n)&&$p(e,n,t[n]);return e},$i=(e,t)=>EP(e,TP(t)),F_="vercel.ai.error",PP=Symbol.for(F_),q_,CP=class V_ extends Error{constructor({name:t,message:n,cause:o}){super(n),this[q_]=!0,this.name=t,this.cause=o}static isInstance(t){return V_.hasMarker(t,F_)}static hasMarker(t,n){const o=Symbol.for(n);return t!=null&&typeof t=="object"&&o in t&&typeof t[o]=="boolean"&&t[o]===!0}};q_=PP;var Ne=CP,B_="AI_APICallError",J_=`vercel.ai.error.${B_}`,jP=Symbol.for(J_),W_,xt=class extends Ne{constructor({message:e,url:t,requestBodyValues:n,statusCode:o,responseHeaders:r,responseBody:i,cause:a,isRetryable:s=o!=null&&(o===408||o===409||o===429||o>=500),data:l}){super({name:B_,message:e,cause:a}),this[W_]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=o,this.responseHeaders=r,this.responseBody=i,this.isRetryable=s,this.data=l}static isInstance(e){return Ne.hasMarker(e,J_)}};W_=jP;var H_="AI_EmptyResponseBodyError",G_=`vercel.ai.error.${H_}`,AP=Symbol.for(G_),K_,RP=class extends Ne{constructor({message:e="Empty response body"}={}){super({name:H_,message:e}),this[K_]=!0}static isInstance(e){return Ne.hasMarker(e,G_)}};K_=AP;function Y_(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Q_="AI_InvalidArgumentError",X_=`vercel.ai.error.${Q_}`,zP=Symbol.for(X_),ew,tw=class extends Ne{constructor({message:t,cause:n,argument:o}){super({name:Q_,message:t,cause:n}),this[ew]=!0,this.argument=o}static isInstance(t){return Ne.hasMarker(t,X_)}};ew=zP;var rw="AI_InvalidPromptError",nw=`vercel.ai.error.${rw}`,MP=Symbol.for(nw),ow,DP=class extends Ne{constructor({prompt:e,message:t,cause:n}){super({name:rw,message:`Invalid prompt: ${t}`,cause:n}),this[ow]=!0,this.prompt=e}static isInstance(e){return Ne.hasMarker(e,nw)}};ow=MP;var iw="AI_InvalidResponseDataError",aw=`vercel.ai.error.${iw}`,UP=Symbol.for(aw),sw,wn=class extends Ne{constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:iw,message:t}),this[sw]=!0,this.data=e}static isInstance(e){return Ne.hasMarker(e,aw)}};sw=UP;var uw="AI_JSONParseError",lw=`vercel.ai.error.${uw}`,LP=Symbol.for(lw),cw,Si=class extends Ne{constructor({text:e,cause:t}){super({name:uw,message:`JSON parsing failed: Text: ${e}.
|
|
38
|
+
Error message: ${Y_(t)}`,cause:t}),this[cw]=!0,this.text=e}static isInstance(e){return Ne.hasMarker(e,lw)}};cw=LP;var dw="AI_LoadAPIKeyError",pw=`vercel.ai.error.${dw}`,ZP=Symbol.for(pw),fw,Vo=class extends Ne{constructor({message:e}){super({name:dw,message:e}),this[fw]=!0}static isInstance(e){return Ne.hasMarker(e,pw)}};fw=ZP;var mw="AI_NoContentGeneratedError",hw=`vercel.ai.error.${mw}`,FP=Symbol.for(hw),gw,vw=class extends Ne{constructor({message:e="No content generated."}={}){super({name:mw,message:e}),this[gw]=!0}static isInstance(e){return Ne.hasMarker(e,hw)}};gw=FP;var yw="AI_TypeValidationError",bw=`vercel.ai.error.${yw}`,qP=Symbol.for(bw),_w,VP=class su extends Ne{constructor({value:t,cause:n}){super({name:yw,message:`Type validation failed: Value: ${JSON.stringify(t)}.
|
|
39
|
+
Error message: ${Y_(n)}`,cause:n}),this[_w]=!0,this.value=t}static isInstance(t){return Ne.hasMarker(t,bw)}static wrap({value:t,cause:n}){return su.isInstance(n)&&n.value===t?n:new su({value:t,cause:n})}};_w=qP;var Zn=VP,ww="AI_UnsupportedFunctionalityError",xw=`vercel.ai.error.${ww}`,BP=Symbol.for(xw),$w,Xt=class extends Ne{constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:ww,message:t}),this[$w]=!0,this.functionality=e}static isInstance(e){return Ne.hasMarker(e,xw)}};$w=BP;var Sp=class extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function Is(e){}function JP(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=Is,onError:n=Is,onRetry:o=Is,onComment:r}=e;let i="",a=!0,s,l="",u="";function c(h){const b=a?h.replace(/^\xEF\xBB\xBF/,""):h,[y,x]=WP(`${i}${b}`);for(const $ of y)d($);i=x,a=!1}function d(h){if(h===""){p();return}if(h.startsWith(":")){r&&r(h.slice(h.startsWith(": ")?2:1));return}const b=h.indexOf(":");if(b!==-1){const y=h.slice(0,b),x=h[b+1]===" "?2:1,$=h.slice(b+x);f(y,$,h);return}f(h,"",h)}function f(h,b,y){switch(h){case"event":u=b;break;case"data":l=`${l}${b}
|
|
40
|
+
`;break;case"id":s=b.includes("\0")?void 0:b;break;case"retry":/^\d+$/.test(b)?o(parseInt(b,10)):n(new Sp(`Invalid \`retry\` value: "${b}"`,{type:"invalid-retry",value:b,line:y}));break;default:n(new Sp(`Unknown field "${h.length>20?`${h.slice(0,20)}…`:h}"`,{type:"unknown-field",field:h,value:b,line:y}));break}}function p(){l.length>0&&t({id:s,event:u||void 0,data:l.endsWith(`
|
|
41
|
+
`)?l.slice(0,-1):l}),s=void 0,l="",u=""}function g(h={}){i&&h.consume&&d(i),a=!0,s=void 0,l="",u="",i=""}return{feed:c,reset:g}}function WP(e){const t=[];let n="",o=0;for(;o<e.length;){const r=e.indexOf("\r",o),i=e.indexOf(`
|
|
42
42
|
`,o);let a=-1;if(r!==-1&&i!==-1?a=Math.min(r,i):r!==-1?a=r:i!==-1&&(a=i),a===-1){n=e.slice(o);break}else{const s=e.slice(o,a);t.push(s),o=a+1,e[o-1]==="\r"&&e[o]===`
|
|
43
|
-
`&&o++}}return[t,n]}var
|
|
43
|
+
`&&o++}}return[t,n]}var HP=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let o;super({start(r){o=JP({onEvent:i=>{r.enqueue(i)},onError(i){e==="terminate"?r.error(i):typeof e=="function"&&e(i)},onRetry:t,onComment:n})},transform(r){o.feed(r)}})}};new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Fn(...e){return e.reduce((t,n)=>ae(ae({},t),n??{}),{})}function Za(e){return Object.fromEntries([...e.headers])}var GP=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const r=()=>{const i=n.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=n[Math.random()*i|0];return a.join("")};if(e==null)return r;if(n.includes(o))throw new tw({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${n}".`});return()=>`${e}${o}${r()}`},bt=GP();function uu(e){return(e instanceof Error||e instanceof DOMException)&&(e.name==="AbortError"||e.name==="ResponseAborted"||e.name==="TimeoutError")}var KP=["fetch failed","failed to fetch"];function YP({error:e,url:t,requestBodyValues:n}){if(uu(e))return e;if(e instanceof TypeError&&KP.includes(e.message.toLowerCase())){const o=e.cause;if(o!=null)return new xt({message:`Cannot connect to API: ${o.message}`,cause:o,url:t,requestBodyValues:n,isRetryable:!0})}return e}function QP(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!=null))}function XP({apiKey:e,environmentVariableName:t,apiKeyParameterName:n="apiKey",description:o}){if(typeof e=="string")return e;if(e!=null)throw new Vo({message:`${o} API key must be a string.`});if(typeof process>"u")throw new Vo({message:`${o} API key is missing. Pass it using the '${n}' parameter. Environment variables is not supported in this environment.`});if(e=process.env[t],e==null)throw new Vo({message:`${o} API key is missing. Pass it using the '${n}' parameter or the ${t} environment variable.`});if(typeof e!="string")throw new Vo({message:`${o} API key must be a string. The value of the ${t} environment variable is not a string.`});return e}var eC=/"__proto__"\s*:/,tC=/"constructor"\s*:/;function rC(e){const t=JSON.parse(e);return t===null||typeof t!="object"||eC.test(e)===!1&&tC.test(e)===!1?t:nC(t)}function nC(e){let t=[e];for(;t.length;){const n=t;t=[];for(const o of n){if(Object.prototype.hasOwnProperty.call(o,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(o,"constructor")&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const r in o){const i=o[r];i&&typeof i=="object"&&t.push(i)}}}return e}function Nc(e){const{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return rC(e)}finally{Error.stackTraceLimit=t}}var lu=Symbol.for("vercel.ai.validator");function oC(e){return{[lu]:!0,validate:e}}function iC(e){return typeof e=="object"&&e!==null&&lu in e&&e[lu]===!0&&"validate"in e}function aC(e){return iC(e)?e:sC(e)}function sC(e){return oC(async t=>{const n=await e["~standard"].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new Zn({value:t,cause:n.issues})}})}async function uC({value:e,schema:t}){const n=await Sw({value:e,schema:t});if(!n.success)throw Zn.wrap({value:e,cause:n.error});return n.value}async function Sw({value:e,schema:t}){const n=aC(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};const o=await n.validate(e);return o.success?{success:!0,value:o.value,rawValue:e}:{success:!1,error:Zn.wrap({value:e,cause:o.error}),rawValue:e}}catch(o){return{success:!1,error:Zn.wrap({value:e,cause:o}),rawValue:e}}}async function lC({text:e,schema:t}){try{const n=Nc(e);return t==null?n:uC({value:n,schema:t})}catch(n){throw Si.isInstance(n)||Zn.isInstance(n)?n:new Si({text:e,cause:n})}}async function Iw({text:e,schema:t}){try{const n=Nc(e);return t==null?{success:!0,value:n,rawValue:n}:await Sw({value:n,schema:t})}catch(n){return{success:!1,error:Si.isInstance(n)?n:new Si({text:e,cause:n}),rawValue:void 0}}}function ks(e){try{return Nc(e),!0}catch{return!1}}function cC({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new HP).pipeThrough(new TransformStream({async transform({data:n},o){n!=="[DONE]"&&o.enqueue(await Iw({text:n,schema:t}))}}))}var dC=()=>globalThis.fetch,qn=async({url:e,headers:t,body:n,failedResponseHandler:o,successfulResponseHandler:r,abortSignal:i,fetch:a})=>pC({url:e,headers:ae({"Content-Type":"application/json"},t),body:{content:JSON.stringify(n),values:n},failedResponseHandler:o,successfulResponseHandler:r,abortSignal:i,fetch:a}),pC=async({url:e,headers:t={},body:n,successfulResponseHandler:o,failedResponseHandler:r,abortSignal:i,fetch:a=dC()})=>{try{const s=await a(e,{method:"POST",headers:QP(t),body:n.content,signal:i}),l=Za(s);if(!s.ok){let u;try{u=await r({response:s,url:e,requestBodyValues:n.values})}catch(c){throw uu(c)||xt.isInstance(c)?c:new xt({message:"Failed to process error response",cause:c,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:n.values})}throw u.value}try{return await o({response:s,url:e,requestBodyValues:n.values})}catch(u){throw u instanceof Error&&(uu(u)||xt.isInstance(u))?u:new xt({message:"Failed to process successful response",cause:u,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:n.values})}}catch(s){throw YP({error:s,url:e,requestBodyValues:n.values})}},fC=({errorSchema:e,errorToMessage:t,isRetryable:n})=>async({response:o,url:r,requestBodyValues:i})=>{const a=await o.text(),s=Za(o);if(a.trim()==="")return{responseHeaders:s,value:new xt({message:o.statusText,url:r,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:n?.(o)})};try{const l=await lC({text:a,schema:e});return{responseHeaders:s,value:new xt({message:t(l),url:r,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,data:l,isRetryable:n?.(o,l)})}}catch{return{responseHeaders:s,value:new xt({message:o.statusText,url:r,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:n?.(o)})}}},kw=e=>async({response:t})=>{const n=Za(t);if(t.body==null)throw new RP({});return{responseHeaders:n,value:cC({stream:t.body,schema:e})}},Pc=e=>async({response:t,url:n,requestBodyValues:o})=>{const r=await t.text(),i=await Iw({text:r,schema:e}),a=Za(t);if(!i.success)throw new xt({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:a,responseBody:r,url:n,requestBodyValues:o});return{responseHeaders:a,value:i.value,rawValue:i.rawValue}},{btoa:mC}=globalThis;function hC(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return mC(t)}function gC(e){return e?.replace(/\/$/,"")}function Es(e){return e!=null}var Ew=(e=>(e.Unknown="unknown",e.OpenAIResponsesV1="openai-responses-v1",e.XAIResponsesV1="xai-responses-v1",e.AnthropicClaudeV1="anthropic-claude-v1",e.GoogleGeminiV1="google-gemini-v1",e))(Ew||{}),Cc=E({id:w().nullish(),format:dr(Ew).nullish(),index:V().optional()}).loose(),vC=E({type:C("reasoning.summary"),summary:w()}).extend(Cc.shape),yC=E({type:C("reasoning.encrypted"),data:w()}).extend(Cc.shape),bC=E({type:C("reasoning.text"),text:w().nullish(),signature:w().nullish()}).extend(Cc.shape),jc=G([vC,yC,bC]),oi=G([jc,$e().transform(()=>null)]),Ac=R(oi).transform(e=>e.filter(t=>!!t));G([E({delta:E({reasoning_details:R(oi)})}).transform(e=>e.delta.reasoning_details.filter(Es)),E({message:E({reasoning_details:R(oi)})}).transform(e=>e.message.reasoning_details.filter(Es)),E({text:w(),reasoning_details:R(oi)}).transform(e=>e.reasoning_details.filter(Es))]);var Fa=E({error:E({code:G([w(),V()]).nullable().optional().default(null),message:w(),type:w().nullable().optional().default(null),param:Pe().nullable().optional().default(null)}).passthrough()}).passthrough(),Vn=fC({errorSchema:Fa,errorToMessage:e=>e.error.message}),Tw=E({type:C("file"),file:E({hash:w(),name:w(),content:R(E({type:w(),text:w().optional()}).catchall(Pe())).optional()}).catchall(Pe())}).catchall(Pe()),_C=E({provider:w(),reasoning_details:R(jc).optional(),annotations:R(Tw).optional(),usage:E({promptTokens:V(),promptTokensDetails:E({cachedTokens:V()}).catchall(Pe()).optional(),completionTokens:V(),completionTokensDetails:E({reasoningTokens:V()}).catchall(Pe()).optional(),totalTokens:V(),cost:V().optional(),costDetails:E({upstreamInferenceCost:V()}).catchall(Pe()).optional()}).catchall(Pe())}).catchall(Pe()),Ip=E({openrouter:E({reasoning_details:R(jc).optional(),annotations:R(Tw).optional()}).optional()}).optional();function Ii(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}var wC=["wav","mp3","aiff","aac","ogg","flac","m4a","pcm16","pcm24"];function Rc({url:e,protocols:t}){try{const n=new URL(e);return t.has(n.protocol)}catch{return!1}}function cu({part:e,defaultMediaType:t}){var n,o;if(e.data instanceof Uint8Array){const i=hC(e.data);return`data:${(n=e.mediaType)!=null?n:t};base64,${i}`}const r=e.data.toString();return Rc({url:r,protocols:new Set(["http:","https:"])})||r.startsWith("data:")?r:`data:${(o=e.mediaType)!=null?o:t};base64,${r}`}function kp(e,t){var n;const o=e.match(/^data:([^;]+)/);return o&&(n=o[1])!=null?n:t}function du(e){const t=e.match(/^data:[^;]*;base64,(.+)$/);return t?t[1]:e}var xC={mpeg:"mp3",mp3:"mp3","x-wav":"wav",wave:"wav",wav:"wav",ogg:"ogg",vorbis:"ogg",aac:"aac","x-aac":"aac",m4a:"m4a","x-m4a":"m4a",mp4:"m4a",aiff:"aiff","x-aiff":"aiff",flac:"flac","x-flac":"flac",pcm16:"pcm16",pcm24:"pcm24"};function $C(e){const t=cu({part:e,defaultMediaType:"audio/mpeg"});if(Rc({url:t,protocols:new Set(["http:","https:"])}))throw new Error(`Audio files cannot be provided as URLs.
|
|
44
44
|
|
|
45
45
|
OpenRouter requires audio to be base64-encoded. Please:
|
|
46
46
|
1. Download the audio file locally
|
|
@@ -49,24 +49,24 @@ OpenRouter requires audio to be base64-encoded. Please:
|
|
|
49
49
|
|
|
50
50
|
The AI SDK will automatically handle base64 encoding.
|
|
51
51
|
|
|
52
|
-
Learn more: https://openrouter.ai/docs/features/multimodal/audio`);const n=
|
|
52
|
+
Learn more: https://openrouter.ai/docs/features/multimodal/audio`);const n=du(t),o=e.mediaType||"audio/mpeg",r=o.replace("audio/",""),i=xC[r];if(i===void 0){const a=wC.join(", ");throw new Error(`Unsupported audio format: "${o}"
|
|
53
53
|
|
|
54
54
|
OpenRouter supports the following audio formats: ${a}
|
|
55
55
|
|
|
56
|
-
Learn more: https://openrouter.ai/docs/features/multimodal/audio`)}return{data:n,format:i}}function Yt(e){var t,n,o;const r=e?.anthropic,i=e?.openrouter;return(o=(n=(t=i?.cacheControl)!=null?t:i?.cache_control)!=null?n:r?.cacheControl)!=null?o:r?.cache_control}function bC(e){var t,n,o,r,i,a,s,l,u,c;const d=[];for(const{role:p,content:f,providerOptions:g}of e)switch(p){case"system":{d.push({role:"system",content:f,cache_control:Yt(g)});break}case"user":{if(f.length===1&&((t=f[0])==null?void 0:t.type)==="text"){const y=(n=Yt(g))!=null?n:Yt(f[0].providerOptions),x=y?[{type:"text",text:f[0].text,cache_control:y}]:f[0].text;d.push({role:"user",content:x});break}const m=Yt(g),b=f.map(y=>{var x,$,v,k,N,I,T;const z=(x=Yt(y.providerOptions))!=null?x:m;switch(y.type){case"text":return{type:"text",text:y.text,cache_control:z};case"file":{if(($=y.mediaType)!=null&&$.startsWith("image/"))return{type:"image_url",image_url:{url:au({part:y,defaultMediaType:"image/jpeg"})},cache_control:z};if((v=y.mediaType)!=null&&v.startsWith("audio/"))return{type:"input_audio",input_audio:yC(y),cache_control:z};const Z=String((T=(I=(N=(k=y.providerOptions)==null?void 0:k.openrouter)==null?void 0:N.filename)!=null?I:y.filename)!=null?T:""),re=au({part:y,defaultMediaType:"application/pdf"});return jc({url:re,protocols:new Set(["http:","https:"])})?{type:"file",file:{filename:Z,file_data:re}}:{type:"file",file:{filename:Z,file_data:re},cache_control:z}}default:return{type:"text",text:"",cache_control:z}}});d.push({role:"user",content:b});break}case"assistant":{let m="",b="";const y=[],x=[];for(const I of f)switch(I.type){case"text":{m+=I.text;break}case"tool-call":{const T=(o=I.providerOptions)==null?void 0:o.openrouter;T?.reasoning_details&&Array.isArray(T.reasoning_details)&&x.push(...T.reasoning_details),y.push({id:I.toolCallId,type:"function",function:{name:I.toolName,arguments:JSON.stringify(I.input)}});break}case"reasoning":{b+=I.text;const T=Sf.safeParse(I.providerOptions);T.success&&((i=(r=T.data)==null?void 0:r.openrouter)!=null&&i.reasoning_details)&&x.push(...T.data.openrouter.reasoning_details);break}}const $=Sf.safeParse(g),v=$.success?(s=(a=$.data)==null?void 0:a.openrouter)==null?void 0:s.reasoning_details:void 0,k=$.success?(u=(l=$.data)==null?void 0:l.openrouter)==null?void 0:u.annotations:void 0,N=v&&Array.isArray(v)&&v.length>0?v:x.length>0?x:void 0;d.push({role:"assistant",content:m,tool_calls:y.length>0?y:void 0,reasoning:b||void 0,reasoning_details:N,annotations:k,cache_control:Yt(g)});break}case"tool":{for(const m of f){const b=_C(m);d.push({role:"tool",tool_call_id:m.toolCallId,content:b,cache_control:(c=Yt(g))!=null?c:Yt(m.providerOptions)})}break}}return d}function _C(e){return e.output.type==="text"?e.output.value:JSON.stringify(e.output.value)}W([C("auto"),C("none"),C("required"),E({type:C("function"),function:E({name:w()})})]);function wC(e){switch(e.type){case"auto":case"none":case"required":return e.type;case"tool":return{type:"function",function:{name:e.toolName}};default:throw new X_({argument:"toolChoice",message:`Invalid tool choice type: ${JSON.stringify(e)}`})}}var xC=E({type:C("image_url"),image_url:E({url:w()}).passthrough()}).passthrough(),$C=W([xC,$e().transform(()=>null)]),Ew=R($C).transform(e=>e.filter(t=>!!t)),Ow=E({id:w().optional(),model:w().optional(),provider:w().optional(),usage:E({prompt_tokens:q(),prompt_tokens_details:E({cached_tokens:q()}).passthrough().nullish(),completion_tokens:q(),completion_tokens_details:E({reasoning_tokens:q()}).passthrough().nullish(),total_tokens:q(),cost:q().optional(),cost_details:E({upstream_inference_cost:q().nullish()}).passthrough().nullish()}).passthrough().nullish()}).passthrough(),SC=W([Ow.extend({choices:R(E({message:E({role:C("assistant"),content:w().nullable().optional(),reasoning:w().nullable().optional(),reasoning_details:Cc.nullish(),images:Ew.nullish(),tool_calls:R(E({id:w().optional().nullable(),type:C("function"),function:E({name:w(),arguments:w()}).passthrough()}).passthrough()).optional(),annotations:R(W([E({type:C("url_citation"),url_citation:E({end_index:q(),start_index:q(),title:w(),url:w(),content:w().optional()}).passthrough()}).passthrough(),E({type:C("file_annotation"),file_annotation:E({file_id:w(),quote:w().optional()}).passthrough()}).passthrough(),E({type:C("file"),file:E({hash:w(),name:w(),content:R(E({type:w(),text:w().optional()}).passthrough()).optional()}).passthrough()}).passthrough()])).nullish()}).passthrough(),index:q().nullish(),logprobs:E({content:R(E({token:w(),logprob:q(),top_logprobs:R(E({token:w(),logprob:q()}).passthrough())}).passthrough()).nullable()}).passthrough().nullable().optional(),finish_reason:w().optional().nullable()}).passthrough())}),Ua.extend({user_id:w().optional()})]),IC=W([Ow.extend({choices:R(E({delta:E({role:cr(["assistant"]).optional(),content:w().nullish(),reasoning:w().nullish().optional(),reasoning_details:Cc.nullish(),images:Ew.nullish(),tool_calls:R(E({index:q().nullish(),id:w().nullish(),type:C("function").optional(),function:E({name:w().nullish(),arguments:w().nullish()}).passthrough()}).passthrough()).nullish(),annotations:R(W([E({type:C("url_citation"),url_citation:E({end_index:q(),start_index:q(),title:w(),url:w(),content:w().optional()}).passthrough()}).passthrough(),E({type:C("file_annotation"),file_annotation:E({file_id:w(),quote:w().optional()}).passthrough()}).passthrough(),E({type:C("file"),file:E({hash:w(),name:w(),content:R(E({type:w(),text:w().optional()}).passthrough()).optional()}).passthrough()}).passthrough()])).nullish()}).passthrough().nullish(),logprobs:E({content:R(E({token:w(),logprob:q(),top_logprobs:R(E({token:w(),logprob:q()}).passthrough())}).passthrough()).nullable()}).passthrough().nullish(),finish_reason:w().nullable().optional(),index:q().nullish()}).passthrough())}),Ua]),kC=class{constructor(e,t,n){this.specificationVersion="v2",this.provider="openrouter",this.defaultObjectGenerationMode="tool",this.supportsImageUrls=!0,this.supportedUrls={"image/*":[/^data:image\/[a-zA-Z]+;base64,/,/^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)$/i],"application/*":[/^data:application\//,/^https?:\/\/.+$/]},this.modelId=e,this.settings=t,this.config=n}getArgs({prompt:e,maxOutputTokens:t,temperature:n,topP:o,frequencyPenalty:r,presencePenalty:i,seed:a,stopSequences:s,responseFormat:l,topK:u,tools:c,toolChoice:d}){var p;const f=ae(ae({model:this.modelId,models:this.settings.models,logit_bias:this.settings.logitBias,logprobs:this.settings.logprobs===!0||typeof this.settings.logprobs=="number"?!0:void 0,top_logprobs:typeof this.settings.logprobs=="number"?this.settings.logprobs:typeof this.settings.logprobs=="boolean"&&this.settings.logprobs?0:void 0,user:this.settings.user,parallel_tool_calls:this.settings.parallelToolCalls,max_tokens:t,temperature:n,top_p:o,frequency_penalty:r,presence_penalty:i,seed:a,stop:s,response_format:l?.type==="json"?l.schema!=null?{type:"json_schema",json_schema:ae({schema:l.schema,strict:!0,name:(p=l.name)!=null?p:"response"},l.description&&{description:l.description})}:{type:"json_object"}:void 0,top_k:u,messages:bC(e),include_reasoning:this.settings.includeReasoning,reasoning:this.settings.reasoning,usage:this.settings.usage,plugins:this.settings.plugins,web_search_options:this.settings.web_search_options,provider:this.settings.provider,debug:this.settings.debug},this.config.extraBody),this.settings.extraBody);if(c&&c.length>0){const g=c.filter(m=>m.type==="function").map(m=>({type:"function",function:{name:m.name,description:m.description,parameters:m.inputSchema}}));return wi(ae({},f),{tools:g,tool_choice:d?wC(d):void 0})}return f}async doGenerate(e){var t,n,o,r,i,a,s,l,u,c,d,p,f,g,m,b,y,x,$,v,k,N,I;const z=(e.providerOptions||{}).openrouter||{},Z=ae(ae({},this.getArgs(e)),z),{value:re,responseHeaders:ve}=await Fn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Zn(this.config.headers(),e.headers),body:Z,failedResponseHandler:qn,successfulResponseHandler:Tc(SC),abortSignal:e.abortSignal,fetch:this.config.fetch});if("error"in re){const D=re.error;throw new $t({message:D.message,url:this.config.url({path:"/chat/completions",modelId:this.modelId}),requestBodyValues:Z,statusCode:200,responseHeaders:ve,data:D})}const G=re,V=G.choices[0];if(!V)throw new hw({message:"No choice in response"});const we=G.usage?{inputTokens:(t=G.usage.prompt_tokens)!=null?t:0,outputTokens:(n=G.usage.completion_tokens)!=null?n:0,totalTokens:((o=G.usage.prompt_tokens)!=null?o:0)+((r=G.usage.completion_tokens)!=null?r:0),reasoningTokens:(a=(i=G.usage.completion_tokens_details)==null?void 0:i.reasoning_tokens)!=null?a:0,cachedInputTokens:(l=(s=G.usage.prompt_tokens_details)==null?void 0:s.cached_tokens)!=null?l:0}:{inputTokens:0,outputTokens:0,totalTokens:0,reasoningTokens:0,cachedInputTokens:0},oe=(u=V.message.reasoning_details)!=null?u:[],ce=oe.length>0?oe.map(D=>{switch(D.type){case"reasoning.text":{if(D.text)return{type:"reasoning",text:D.text,providerMetadata:{openrouter:{reasoning_details:[D]}}};break}case"reasoning.summary":{if(D.summary)return{type:"reasoning",text:D.summary,providerMetadata:{openrouter:{reasoning_details:[D]}}};break}case"reasoning.encrypted":{if(D.data)return{type:"reasoning",text:"[REDACTED]",providerMetadata:{openrouter:{reasoning_details:[D]}}};break}}return null}).filter(D=>D!==null):V.message.reasoning?[{type:"reasoning",text:V.message.reasoning}]:[],K=[];if(K.push(...ce),V.message.content&&K.push({type:"text",text:V.message.content}),V.message.tool_calls)for(const D of V.message.tool_calls)K.push({type:"tool-call",toolCallId:(c=D.id)!=null?c:_t(),toolName:D.function.name,input:D.function.arguments,providerMetadata:{openrouter:{reasoning_details:oe}}});if(V.message.images)for(const D of V.message.images)K.push({type:"file",mediaType:If(D.image_url.url,"image/jpeg"),data:su(D.image_url.url)});if(V.message.annotations)for(const D of V.message.annotations)D.type==="url_citation"&&K.push({type:"source",sourceType:"url",id:D.url_citation.url,url:D.url_citation.url,title:D.url_citation.title,providerMetadata:{openrouter:{content:D.url_citation.content||""}}});const fe=(d=V.message.annotations)==null?void 0:d.filter(D=>D.type==="file"),B=V.message.tool_calls&&V.message.tool_calls.length>0,Ue=oe.some(D=>D.type==="reasoning.encrypted"&&D.data),Le=B&&Ue&&V.finish_reason==="stop"?"tool-calls":$i(V.finish_reason);return{content:K,finishReason:Le,usage:we,warnings:[],providerMetadata:{openrouter:hC.parse({provider:(p=G.provider)!=null?p:"",reasoning_details:(f=V.message.reasoning_details)!=null?f:[],annotations:fe&&fe.length>0?fe:void 0,usage:ae(ae(ae({promptTokens:(g=we.inputTokens)!=null?g:0,completionTokens:(m=we.outputTokens)!=null?m:0,totalTokens:(b=we.totalTokens)!=null?b:0,cost:(y=G.usage)==null?void 0:y.cost},(($=(x=G.usage)==null?void 0:x.prompt_tokens_details)==null?void 0:$.cached_tokens)!=null?{promptTokensDetails:{cachedTokens:G.usage.prompt_tokens_details.cached_tokens}}:{}),((k=(v=G.usage)==null?void 0:v.completion_tokens_details)==null?void 0:k.reasoning_tokens)!=null?{completionTokensDetails:{reasoningTokens:G.usage.completion_tokens_details.reasoning_tokens}}:{}),((I=(N=G.usage)==null?void 0:N.cost_details)==null?void 0:I.upstream_inference_cost)!=null?{costDetails:{upstreamInferenceCost:G.usage.cost_details.upstream_inference_cost}}:{})})},request:{body:Z},response:{id:G.id,modelId:G.model,headers:ve}}}async doStream(e){var t;const o=(e.providerOptions||{}).openrouter||{},r=ae(ae({},this.getArgs(e)),o),{value:i,responseHeaders:a}=await Fn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Zn(this.config.headers(),e.headers),body:wi(ae({},r),{stream:!0,stream_options:this.config.compatibility==="strict"?ae({include_usage:!0},(t=this.settings.usage)!=null&&t.include?{include_usage:!0}:{}):void 0}),failedResponseHandler:qn,successfulResponseHandler:Sw(IC),abortSignal:e.abortSignal,fetch:this.config.fetch}),s=[];let l="other";const u={inputTokens:Number.NaN,outputTokens:Number.NaN,totalTokens:Number.NaN,reasoningTokens:Number.NaN,cachedInputTokens:Number.NaN},c={},d=[],p=[];let f=!1,g=!1,m,b,y,x;return{stream:i.pipeThrough(new TransformStream({transform($,v){var k,N,I,T,z,Z,re,ve,G,V,we,oe,ce,K,fe;if(!$.success){l="error",v.enqueue({type:"error",error:$.error});return}const B=$.value;if("error"in B){l="error",v.enqueue({type:"error",error:B.error});return}if(B.provider&&(x=B.provider),B.id&&(y=B.id,v.enqueue({type:"response-metadata",id:B.id})),B.model&&v.enqueue({type:"response-metadata",modelId:B.model}),B.usage!=null){if(u.inputTokens=B.usage.prompt_tokens,u.outputTokens=B.usage.completion_tokens,u.totalTokens=B.usage.prompt_tokens+B.usage.completion_tokens,c.promptTokens=B.usage.prompt_tokens,B.usage.prompt_tokens_details){const Q=(k=B.usage.prompt_tokens_details.cached_tokens)!=null?k:0;u.cachedInputTokens=Q,c.promptTokensDetails={cachedTokens:Q}}if(c.completionTokens=B.usage.completion_tokens,B.usage.completion_tokens_details){const Q=(N=B.usage.completion_tokens_details.reasoning_tokens)!=null?N:0;u.reasoningTokens=Q,c.completionTokensDetails={reasoningTokens:Q}}c.cost=B.usage.cost,c.totalTokens=B.usage.total_tokens;const D=(I=B.usage.cost_details)==null?void 0:I.upstream_inference_cost;D!=null&&(c.costDetails={upstreamInferenceCost:D})}const Ue=B.choices[0];if(Ue?.finish_reason!=null&&(l=$i(Ue.finish_reason)),Ue?.delta==null)return;const ye=Ue.delta,Le=(D,Q)=>{g||(b=y||_t(),v.enqueue({providerMetadata:Q,type:"reasoning-start",id:b}),g=!0),v.enqueue({providerMetadata:Q,type:"reasoning-delta",delta:D,id:b||_t()})};if(ye.reasoning_details&&ye.reasoning_details.length>0){for(const Q of ye.reasoning_details)if(Q.type==="reasoning.text"){const pe=d[d.length-1];pe?.type==="reasoning.text"?(pe.text=(pe.text||"")+(Q.text||""),pe.signature=pe.signature||Q.signature,pe.format=pe.format||Q.format):d.push(ae({},Q))}else d.push(Q);const D={openrouter:{reasoning_details:ye.reasoning_details}};for(const Q of ye.reasoning_details)switch(Q.type){case"reasoning.text":{Q.text&&Le(Q.text,D);break}case"reasoning.encrypted":{Q.data&&Le("[REDACTED]",D);break}case"reasoning.summary":{Q.summary&&Le(Q.summary,D);break}}}else ye.reasoning&&Le(ye.reasoning);if(ye.content&&(g&&!f&&(v.enqueue({type:"reasoning-end",id:b||_t()}),g=!1),f||(m=y||_t(),v.enqueue({type:"text-start",id:m}),f=!0),v.enqueue({type:"text-delta",delta:ye.content,id:m||_t()})),ye.annotations){for(const D of ye.annotations)if(D.type==="url_citation")v.enqueue({type:"source",sourceType:"url",id:D.url_citation.url,url:D.url_citation.url,title:D.url_citation.title,providerMetadata:{openrouter:{content:D.url_citation.content||""}}});else if(D.type==="file"){const Q=D.file;Q&&typeof Q=="object"&&"hash"in Q&&"name"in Q&&p.push(D)}}if(ye.tool_calls!=null)for(const D of ye.tool_calls){const Q=(T=D.index)!=null?T:s.length-1;if(s[Q]==null){if(D.type!=="function")throw new _n({data:D,message:"Expected 'function' type."});if(D.id==null)throw new _n({data:D,message:"Expected 'id' to be a string."});if(((z=D.function)==null?void 0:z.name)==null)throw new _n({data:D,message:"Expected 'function.name' to be a string."});s[Q]={id:D.id,type:"function",function:{name:D.function.name,arguments:(Z=D.function.arguments)!=null?Z:""},inputStarted:!1,sent:!1};const xe=s[Q];if(xe==null)throw new _n({data:{index:Q,toolCallsLength:s.length},message:`Tool call at index ${Q} is missing after creation.`});((re=xe.function)==null?void 0:re.name)!=null&&((ve=xe.function)==null?void 0:ve.arguments)!=null&&$s(xe.function.arguments)&&(xe.inputStarted=!0,v.enqueue({type:"tool-input-start",id:xe.id,toolName:xe.function.name}),v.enqueue({type:"tool-input-delta",id:xe.id,delta:xe.function.arguments}),v.enqueue({type:"tool-input-end",id:xe.id}),v.enqueue({type:"tool-call",toolCallId:xe.id,toolName:xe.function.name,input:xe.function.arguments,providerMetadata:{openrouter:{reasoning_details:d}}}),xe.sent=!0);continue}const pe=s[Q];if(pe==null)throw new _n({data:{index:Q,toolCallsLength:s.length,toolCallDelta:D},message:`Tool call at index ${Q} is missing during merge.`});pe.inputStarted||(pe.inputStarted=!0,v.enqueue({type:"tool-input-start",id:pe.id,toolName:pe.function.name})),((G=D.function)==null?void 0:G.arguments)!=null&&(pe.function.arguments+=(we=(V=D.function)==null?void 0:V.arguments)!=null?we:""),v.enqueue({type:"tool-input-delta",id:pe.id,delta:(oe=D.function.arguments)!=null?oe:""}),((ce=pe.function)==null?void 0:ce.name)!=null&&((K=pe.function)==null?void 0:K.arguments)!=null&&$s(pe.function.arguments)&&(v.enqueue({type:"tool-call",toolCallId:(fe=pe.id)!=null?fe:_t(),toolName:pe.function.name,input:pe.function.arguments,providerMetadata:{openrouter:{reasoning_details:d}}}),pe.sent=!0)}if(ye.images!=null)for(const D of ye.images)v.enqueue({type:"file",mediaType:If(D.image_url.url,"image/jpeg"),data:su(D.image_url.url)})},flush($){var v;const k=s.length>0,N=d.some(T=>T.type==="reasoning.encrypted"&&T.data);if(k&&N&&l==="stop"&&(l="tool-calls"),l==="tool-calls")for(const T of s)T&&!T.sent&&($.enqueue({type:"tool-call",toolCallId:(v=T.id)!=null?v:_t(),toolName:T.function.name,input:$s(T.function.arguments)?T.function.arguments:"{}",providerMetadata:{openrouter:{reasoning_details:d}}}),T.sent=!0);g&&$.enqueue({type:"reasoning-end",id:b||_t()}),f&&$.enqueue({type:"text-end",id:m||_t()});const I={usage:c};x!==void 0&&(I.provider=x),d.length>0&&(I.reasoning_details=d),p.length>0&&(I.annotations=p),$.enqueue({type:"finish",finishReason:l,usage:u,providerMetadata:{openrouter:I}})}})),warnings:[],request:{body:r},response:{headers:a}}}};function EC({prompt:e,inputFormat:t,user:n="user",assistant:o="assistant"}){if(e.length===1&&e[0]&&e[0].role==="user"&&e[0].content.length===1&&e[0].content[0]&&e[0].content[0].type==="text")return{prompt:e[0].content[0].text};let r="";e[0]&&e[0].role==="system"&&(r+=`${e[0].content}
|
|
56
|
+
Learn more: https://openrouter.ai/docs/features/multimodal/audio`)}return{data:n,format:i}}function Kt(e){var t,n,o;const r=e?.anthropic,i=e?.openrouter;return(o=(n=(t=i?.cacheControl)!=null?t:i?.cache_control)!=null?n:r?.cacheControl)!=null?o:r?.cache_control}function SC(e){var t,n,o,r,i,a,s,l,u,c;const d=[];for(const{role:f,content:p,providerOptions:g}of e)switch(f){case"system":{d.push({role:"system",content:p,cache_control:Kt(g)});break}case"user":{if(p.length===1&&((t=p[0])==null?void 0:t.type)==="text"){const y=(n=Kt(g))!=null?n:Kt(p[0].providerOptions),x=y?[{type:"text",text:p[0].text,cache_control:y}]:p[0].text;d.push({role:"user",content:x});break}const h=Kt(g),b=p.map(y=>{var x,$,v,k,N,I,O;const z=(x=Kt(y.providerOptions))!=null?x:h;switch(y.type){case"text":return{type:"text",text:y.text,cache_control:z};case"file":{if(($=y.mediaType)!=null&&$.startsWith("image/"))return{type:"image_url",image_url:{url:cu({part:y,defaultMediaType:"image/jpeg"})},cache_control:z};if((v=y.mediaType)!=null&&v.startsWith("audio/"))return{type:"input_audio",input_audio:$C(y),cache_control:z};const F=String((O=(I=(N=(k=y.providerOptions)==null?void 0:k.openrouter)==null?void 0:N.filename)!=null?I:y.filename)!=null?O:""),te=cu({part:y,defaultMediaType:"application/pdf"});return Rc({url:te,protocols:new Set(["http:","https:"])})?{type:"file",file:{filename:F,file_data:te}}:{type:"file",file:{filename:F,file_data:te},cache_control:z}}default:return{type:"text",text:"",cache_control:z}}});d.push({role:"user",content:b});break}case"assistant":{let h="",b="";const y=[],x=[];for(const I of p)switch(I.type){case"text":{h+=I.text;break}case"tool-call":{const O=(o=I.providerOptions)==null?void 0:o.openrouter;O?.reasoning_details&&Array.isArray(O.reasoning_details)&&x.push(...O.reasoning_details),y.push({id:I.toolCallId,type:"function",function:{name:I.toolName,arguments:JSON.stringify(I.input)}});break}case"reasoning":{b+=I.text;const O=Ip.safeParse(I.providerOptions);O.success&&((i=(r=O.data)==null?void 0:r.openrouter)!=null&&i.reasoning_details)&&x.push(...O.data.openrouter.reasoning_details);break}}const $=Ip.safeParse(g),v=$.success?(s=(a=$.data)==null?void 0:a.openrouter)==null?void 0:s.reasoning_details:void 0,k=$.success?(u=(l=$.data)==null?void 0:l.openrouter)==null?void 0:u.annotations:void 0,N=v&&Array.isArray(v)&&v.length>0?v:x.length>0?x:void 0;d.push({role:"assistant",content:h,tool_calls:y.length>0?y:void 0,reasoning:b||void 0,reasoning_details:N,annotations:k,cache_control:Kt(g)});break}case"tool":{for(const h of p){const b=IC(h);d.push({role:"tool",tool_call_id:h.toolCallId,content:b,cache_control:(c=Kt(g))!=null?c:Kt(h.providerOptions)})}break}}return d}function IC(e){return e.output.type==="text"?e.output.value:JSON.stringify(e.output.value)}G([C("auto"),C("none"),C("required"),E({type:C("function"),function:E({name:w()})})]);function kC(e){switch(e.type){case"auto":case"none":case"required":return e.type;case"tool":return{type:"function",function:{name:e.toolName}};default:throw new tw({argument:"toolChoice",message:`Invalid tool choice type: ${JSON.stringify(e)}`})}}var EC=E({type:C("image_url"),image_url:E({url:w()}).passthrough()}).passthrough(),TC=G([EC,$e().transform(()=>null)]),Ow=R(TC).transform(e=>e.filter(t=>!!t)),Nw=E({id:w().optional(),model:w().optional(),provider:w().optional(),usage:E({prompt_tokens:V(),prompt_tokens_details:E({cached_tokens:V()}).passthrough().nullish(),completion_tokens:V(),completion_tokens_details:E({reasoning_tokens:V()}).passthrough().nullish(),total_tokens:V(),cost:V().optional(),cost_details:E({upstream_inference_cost:V().nullish()}).passthrough().nullish()}).passthrough().nullish()}).passthrough(),OC=G([Nw.extend({choices:R(E({message:E({role:C("assistant"),content:w().nullable().optional(),reasoning:w().nullable().optional(),reasoning_details:Ac.nullish(),images:Ow.nullish(),tool_calls:R(E({id:w().optional().nullable(),type:C("function"),function:E({name:w(),arguments:w()}).passthrough()}).passthrough()).optional(),annotations:R(G([E({type:C("url_citation"),url_citation:E({end_index:V(),start_index:V(),title:w(),url:w(),content:w().optional()}).passthrough()}).passthrough(),E({type:C("file_annotation"),file_annotation:E({file_id:w(),quote:w().optional()}).passthrough()}).passthrough(),E({type:C("file"),file:E({hash:w(),name:w(),content:R(E({type:w(),text:w().optional()}).passthrough()).optional()}).passthrough()}).passthrough()])).nullish()}).passthrough(),index:V().nullish(),logprobs:E({content:R(E({token:w(),logprob:V(),top_logprobs:R(E({token:w(),logprob:V()}).passthrough())}).passthrough()).nullable()}).passthrough().nullable().optional(),finish_reason:w().optional().nullable()}).passthrough())}),Fa.extend({user_id:w().optional()})]),NC=G([Nw.extend({choices:R(E({delta:E({role:dr(["assistant"]).optional(),content:w().nullish(),reasoning:w().nullish().optional(),reasoning_details:Ac.nullish(),images:Ow.nullish(),tool_calls:R(E({index:V().nullish(),id:w().nullish(),type:C("function").optional(),function:E({name:w().nullish(),arguments:w().nullish()}).passthrough()}).passthrough()).nullish(),annotations:R(G([E({type:C("url_citation"),url_citation:E({end_index:V(),start_index:V(),title:w(),url:w(),content:w().optional()}).passthrough()}).passthrough(),E({type:C("file_annotation"),file_annotation:E({file_id:w(),quote:w().optional()}).passthrough()}).passthrough(),E({type:C("file"),file:E({hash:w(),name:w(),content:R(E({type:w(),text:w().optional()}).passthrough()).optional()}).passthrough()}).passthrough()])).nullish()}).passthrough().nullish(),logprobs:E({content:R(E({token:w(),logprob:V(),top_logprobs:R(E({token:w(),logprob:V()}).passthrough())}).passthrough()).nullable()}).passthrough().nullish(),finish_reason:w().nullable().optional(),index:V().nullish()}).passthrough())}),Fa]),PC=class{constructor(e,t,n){this.specificationVersion="v2",this.provider="openrouter",this.defaultObjectGenerationMode="tool",this.supportsImageUrls=!0,this.supportedUrls={"image/*":[/^data:image\/[a-zA-Z]+;base64,/,/^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)$/i],"application/*":[/^data:application\//,/^https?:\/\/.+$/]},this.modelId=e,this.settings=t,this.config=n}getArgs({prompt:e,maxOutputTokens:t,temperature:n,topP:o,frequencyPenalty:r,presencePenalty:i,seed:a,stopSequences:s,responseFormat:l,topK:u,tools:c,toolChoice:d}){var f;const p=ae(ae({model:this.modelId,models:this.settings.models,logit_bias:this.settings.logitBias,logprobs:this.settings.logprobs===!0||typeof this.settings.logprobs=="number"?!0:void 0,top_logprobs:typeof this.settings.logprobs=="number"?this.settings.logprobs:typeof this.settings.logprobs=="boolean"&&this.settings.logprobs?0:void 0,user:this.settings.user,parallel_tool_calls:this.settings.parallelToolCalls,max_tokens:t,temperature:n,top_p:o,frequency_penalty:r,presence_penalty:i,seed:a,stop:s,response_format:l?.type==="json"?l.schema!=null?{type:"json_schema",json_schema:ae({schema:l.schema,strict:!0,name:(f=l.name)!=null?f:"response"},l.description&&{description:l.description})}:{type:"json_object"}:void 0,top_k:u,messages:SC(e),include_reasoning:this.settings.includeReasoning,reasoning:this.settings.reasoning,usage:this.settings.usage,plugins:this.settings.plugins,web_search_options:this.settings.web_search_options,provider:this.settings.provider,debug:this.settings.debug},this.config.extraBody),this.settings.extraBody);if(c&&c.length>0){const g=c.filter(h=>h.type==="function").map(h=>({type:"function",function:{name:h.name,description:h.description,parameters:h.inputSchema}}));return $i(ae({},p),{tools:g,tool_choice:d?kC(d):void 0})}return p}async doGenerate(e){var t,n,o,r,i,a,s,l,u,c,d,f,p,g,h,b,y,x,$,v,k,N,I;const z=(e.providerOptions||{}).openrouter||{},F=ae(ae({},this.getArgs(e)),z),{value:te,responseHeaders:ce}=await qn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Fn(this.config.headers(),e.headers),body:F,failedResponseHandler:Vn,successfulResponseHandler:Pc(OC),abortSignal:e.abortSignal,fetch:this.config.fetch});if("error"in te){const U=te.error;throw new xt({message:U.message,url:this.config.url({path:"/chat/completions",modelId:this.modelId}),requestBodyValues:F,statusCode:200,responseHeaders:ce,data:U})}const B=te,q=B.choices[0];if(!q)throw new vw({message:"No choice in response"});const we=B.usage?{inputTokens:(t=B.usage.prompt_tokens)!=null?t:0,outputTokens:(n=B.usage.completion_tokens)!=null?n:0,totalTokens:((o=B.usage.prompt_tokens)!=null?o:0)+((r=B.usage.completion_tokens)!=null?r:0),reasoningTokens:(a=(i=B.usage.completion_tokens_details)==null?void 0:i.reasoning_tokens)!=null?a:0,cachedInputTokens:(l=(s=B.usage.prompt_tokens_details)==null?void 0:s.cached_tokens)!=null?l:0}:{inputTokens:0,outputTokens:0,totalTokens:0,reasoningTokens:0,cachedInputTokens:0},oe=(u=q.message.reasoning_details)!=null?u:[],de=oe.length>0?oe.map(U=>{switch(U.type){case"reasoning.text":{if(U.text)return{type:"reasoning",text:U.text,providerMetadata:{openrouter:{reasoning_details:[U]}}};break}case"reasoning.summary":{if(U.summary)return{type:"reasoning",text:U.summary,providerMetadata:{openrouter:{reasoning_details:[U]}}};break}case"reasoning.encrypted":{if(U.data)return{type:"reasoning",text:"[REDACTED]",providerMetadata:{openrouter:{reasoning_details:[U]}}};break}}return null}).filter(U=>U!==null):q.message.reasoning?[{type:"reasoning",text:q.message.reasoning}]:[],K=[];if(K.push(...de),q.message.content&&K.push({type:"text",text:q.message.content}),q.message.tool_calls)for(const U of q.message.tool_calls)K.push({type:"tool-call",toolCallId:(c=U.id)!=null?c:bt(),toolName:U.function.name,input:U.function.arguments,providerMetadata:{openrouter:{reasoning_details:oe}}});if(q.message.images)for(const U of q.message.images)K.push({type:"file",mediaType:kp(U.image_url.url,"image/jpeg"),data:du(U.image_url.url)});if(q.message.annotations)for(const U of q.message.annotations)U.type==="url_citation"&&K.push({type:"source",sourceType:"url",id:U.url_citation.url,url:U.url_citation.url,title:U.url_citation.title,providerMetadata:{openrouter:{content:U.url_citation.content||""}}});const fe=(d=q.message.annotations)==null?void 0:d.filter(U=>U.type==="file"),J=q.message.tool_calls&&q.message.tool_calls.length>0,Ue=oe.some(U=>U.type==="reasoning.encrypted"&&U.data),Le=J&&Ue&&q.finish_reason==="stop"?"tool-calls":Ii(q.finish_reason);return{content:K,finishReason:Le,usage:we,warnings:[],providerMetadata:{openrouter:_C.parse({provider:(f=B.provider)!=null?f:"",reasoning_details:(p=q.message.reasoning_details)!=null?p:[],annotations:fe&&fe.length>0?fe:void 0,usage:ae(ae(ae({promptTokens:(g=we.inputTokens)!=null?g:0,completionTokens:(h=we.outputTokens)!=null?h:0,totalTokens:(b=we.totalTokens)!=null?b:0,cost:(y=B.usage)==null?void 0:y.cost},(($=(x=B.usage)==null?void 0:x.prompt_tokens_details)==null?void 0:$.cached_tokens)!=null?{promptTokensDetails:{cachedTokens:B.usage.prompt_tokens_details.cached_tokens}}:{}),((k=(v=B.usage)==null?void 0:v.completion_tokens_details)==null?void 0:k.reasoning_tokens)!=null?{completionTokensDetails:{reasoningTokens:B.usage.completion_tokens_details.reasoning_tokens}}:{}),((I=(N=B.usage)==null?void 0:N.cost_details)==null?void 0:I.upstream_inference_cost)!=null?{costDetails:{upstreamInferenceCost:B.usage.cost_details.upstream_inference_cost}}:{})})},request:{body:F},response:{id:B.id,modelId:B.model,headers:ce}}}async doStream(e){var t;const o=(e.providerOptions||{}).openrouter||{},r=ae(ae({},this.getArgs(e)),o),{value:i,responseHeaders:a}=await qn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Fn(this.config.headers(),e.headers),body:$i(ae({},r),{stream:!0,stream_options:this.config.compatibility==="strict"?ae({include_usage:!0},(t=this.settings.usage)!=null&&t.include?{include_usage:!0}:{}):void 0}),failedResponseHandler:Vn,successfulResponseHandler:kw(NC),abortSignal:e.abortSignal,fetch:this.config.fetch}),s=[];let l="other";const u={inputTokens:Number.NaN,outputTokens:Number.NaN,totalTokens:Number.NaN,reasoningTokens:Number.NaN,cachedInputTokens:Number.NaN},c={},d=[],f=[];let p=!1,g=!1,h,b,y,x;return{stream:i.pipeThrough(new TransformStream({transform($,v){var k,N,I,O,z,F,te,ce,B,q,we,oe,de,K,fe;if(!$.success){l="error",v.enqueue({type:"error",error:$.error});return}const J=$.value;if("error"in J){l="error",v.enqueue({type:"error",error:J.error});return}if(J.provider&&(x=J.provider),J.id&&(y=J.id,v.enqueue({type:"response-metadata",id:J.id})),J.model&&v.enqueue({type:"response-metadata",modelId:J.model}),J.usage!=null){if(u.inputTokens=J.usage.prompt_tokens,u.outputTokens=J.usage.completion_tokens,u.totalTokens=J.usage.prompt_tokens+J.usage.completion_tokens,c.promptTokens=J.usage.prompt_tokens,J.usage.prompt_tokens_details){const Q=(k=J.usage.prompt_tokens_details.cached_tokens)!=null?k:0;u.cachedInputTokens=Q,c.promptTokensDetails={cachedTokens:Q}}if(c.completionTokens=J.usage.completion_tokens,J.usage.completion_tokens_details){const Q=(N=J.usage.completion_tokens_details.reasoning_tokens)!=null?N:0;u.reasoningTokens=Q,c.completionTokensDetails={reasoningTokens:Q}}c.cost=J.usage.cost,c.totalTokens=J.usage.total_tokens;const U=(I=J.usage.cost_details)==null?void 0:I.upstream_inference_cost;U!=null&&(c.costDetails={upstreamInferenceCost:U})}const Ue=J.choices[0];if(Ue?.finish_reason!=null&&(l=Ii(Ue.finish_reason)),Ue?.delta==null)return;const ye=Ue.delta,Le=(U,Q)=>{g||(b=y||bt(),v.enqueue({providerMetadata:Q,type:"reasoning-start",id:b}),g=!0),v.enqueue({providerMetadata:Q,type:"reasoning-delta",delta:U,id:b||bt()})};if(ye.reasoning_details&&ye.reasoning_details.length>0){for(const Q of ye.reasoning_details)if(Q.type==="reasoning.text"){const me=d[d.length-1];me?.type==="reasoning.text"?(me.text=(me.text||"")+(Q.text||""),me.signature=me.signature||Q.signature,me.format=me.format||Q.format):d.push(ae({},Q))}else d.push(Q);const U={openrouter:{reasoning_details:ye.reasoning_details}};for(const Q of ye.reasoning_details)switch(Q.type){case"reasoning.text":{Q.text&&Le(Q.text,U);break}case"reasoning.encrypted":{Q.data&&Le("[REDACTED]",U);break}case"reasoning.summary":{Q.summary&&Le(Q.summary,U);break}}}else ye.reasoning&&Le(ye.reasoning);if(ye.content&&(g&&!p&&(v.enqueue({type:"reasoning-end",id:b||bt()}),g=!1),p||(h=y||bt(),v.enqueue({type:"text-start",id:h}),p=!0),v.enqueue({type:"text-delta",delta:ye.content,id:h||bt()})),ye.annotations){for(const U of ye.annotations)if(U.type==="url_citation")v.enqueue({type:"source",sourceType:"url",id:U.url_citation.url,url:U.url_citation.url,title:U.url_citation.title,providerMetadata:{openrouter:{content:U.url_citation.content||""}}});else if(U.type==="file"){const Q=U.file;Q&&typeof Q=="object"&&"hash"in Q&&"name"in Q&&f.push(U)}}if(ye.tool_calls!=null)for(const U of ye.tool_calls){const Q=(O=U.index)!=null?O:s.length-1;if(s[Q]==null){if(U.type!=="function")throw new wn({data:U,message:"Expected 'function' type."});if(U.id==null)throw new wn({data:U,message:"Expected 'id' to be a string."});if(((z=U.function)==null?void 0:z.name)==null)throw new wn({data:U,message:"Expected 'function.name' to be a string."});s[Q]={id:U.id,type:"function",function:{name:U.function.name,arguments:(F=U.function.arguments)!=null?F:""},inputStarted:!1,sent:!1};const xe=s[Q];if(xe==null)throw new wn({data:{index:Q,toolCallsLength:s.length},message:`Tool call at index ${Q} is missing after creation.`});((te=xe.function)==null?void 0:te.name)!=null&&((ce=xe.function)==null?void 0:ce.arguments)!=null&&ks(xe.function.arguments)&&(xe.inputStarted=!0,v.enqueue({type:"tool-input-start",id:xe.id,toolName:xe.function.name}),v.enqueue({type:"tool-input-delta",id:xe.id,delta:xe.function.arguments}),v.enqueue({type:"tool-input-end",id:xe.id}),v.enqueue({type:"tool-call",toolCallId:xe.id,toolName:xe.function.name,input:xe.function.arguments,providerMetadata:{openrouter:{reasoning_details:d}}}),xe.sent=!0);continue}const me=s[Q];if(me==null)throw new wn({data:{index:Q,toolCallsLength:s.length,toolCallDelta:U},message:`Tool call at index ${Q} is missing during merge.`});me.inputStarted||(me.inputStarted=!0,v.enqueue({type:"tool-input-start",id:me.id,toolName:me.function.name})),((B=U.function)==null?void 0:B.arguments)!=null&&(me.function.arguments+=(we=(q=U.function)==null?void 0:q.arguments)!=null?we:""),v.enqueue({type:"tool-input-delta",id:me.id,delta:(oe=U.function.arguments)!=null?oe:""}),((de=me.function)==null?void 0:de.name)!=null&&((K=me.function)==null?void 0:K.arguments)!=null&&ks(me.function.arguments)&&(v.enqueue({type:"tool-call",toolCallId:(fe=me.id)!=null?fe:bt(),toolName:me.function.name,input:me.function.arguments,providerMetadata:{openrouter:{reasoning_details:d}}}),me.sent=!0)}if(ye.images!=null)for(const U of ye.images)v.enqueue({type:"file",mediaType:kp(U.image_url.url,"image/jpeg"),data:du(U.image_url.url)})},flush($){var v;const k=s.length>0,N=d.some(O=>O.type==="reasoning.encrypted"&&O.data);if(k&&N&&l==="stop"&&(l="tool-calls"),l==="tool-calls")for(const O of s)O&&!O.sent&&($.enqueue({type:"tool-call",toolCallId:(v=O.id)!=null?v:bt(),toolName:O.function.name,input:ks(O.function.arguments)?O.function.arguments:"{}",providerMetadata:{openrouter:{reasoning_details:d}}}),O.sent=!0);g&&$.enqueue({type:"reasoning-end",id:b||bt()}),p&&$.enqueue({type:"text-end",id:h||bt()});const I={usage:c};x!==void 0&&(I.provider=x),d.length>0&&(I.reasoning_details=d),f.length>0&&(I.annotations=f),$.enqueue({type:"finish",finishReason:l,usage:u,providerMetadata:{openrouter:I}})}})),warnings:[],request:{body:r},response:{headers:a}}}};function CC({prompt:e,inputFormat:t,user:n="user",assistant:o="assistant"}){if(e.length===1&&e[0]&&e[0].role==="user"&&e[0].content.length===1&&e[0].content[0]&&e[0].content[0].type==="text")return{prompt:e[0].content[0].text};let r="";e[0]&&e[0].role==="system"&&(r+=`${e[0].content}
|
|
57
57
|
|
|
58
|
-
`,e=e.slice(1));for(const{role:i,content:a}of e)switch(i){case"system":throw new
|
|
58
|
+
`,e=e.slice(1));for(const{role:i,content:a}of e)switch(i){case"system":throw new DP({message:`Unexpected system message in prompt: ${a}`,prompt:e});case"user":{const s=a.map(l=>{switch(l.type){case"text":return l.text;case"file":throw new Xt({functionality:"file attachments"});default:return""}}).join("");r+=`${n}:
|
|
59
59
|
${s}
|
|
60
60
|
|
|
61
|
-
`;break}case"assistant":{const s=a.map(l=>{switch(l.type){case"text":return l.text;case"tool-call":throw new
|
|
61
|
+
`;break}case"assistant":{const s=a.map(l=>{switch(l.type){case"text":return l.text;case"tool-call":throw new Xt({functionality:"tool-call messages"});case"tool-result":throw new Xt({functionality:"tool-result messages"});case"reasoning":throw new Xt({functionality:"reasoning messages"});case"file":throw new Xt({functionality:"file attachments"});default:return""}}).join("");r+=`${o}:
|
|
62
62
|
${s}
|
|
63
63
|
|
|
64
|
-
`;break}case"tool":throw new
|
|
65
|
-
`,{prompt:r}}var kf=W([E({id:w().optional(),model:w().optional(),choices:R(E({text:w(),reasoning:w().nullish().optional(),reasoning_details:Cc.nullish(),finish_reason:w().nullish(),index:q().nullish(),logprobs:E({tokens:R(w()),token_logprobs:R(q()),top_logprobs:R(Xe(w(),q())).nullable()}).passthrough().nullable().optional()}).passthrough()),usage:E({prompt_tokens:q(),prompt_tokens_details:E({cached_tokens:q()}).passthrough().nullish(),completion_tokens:q(),completion_tokens_details:E({reasoning_tokens:q()}).passthrough().nullish(),total_tokens:q(),cost:q().optional(),cost_details:E({upstream_inference_cost:q().nullish()}).passthrough().nullish()}).passthrough().nullish()}).passthrough(),Ua]),OC=class{constructor(e,t,n){this.specificationVersion="v2",this.provider="openrouter",this.supportsImageUrls=!0,this.supportedUrls={"image/*":[/^data:image\/[a-zA-Z]+;base64,/,/^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)$/i],"text/*":[/^data:text\//,/^https?:\/\/.+$/],"application/*":[/^data:application\//,/^https?:\/\/.+$/]},this.defaultObjectGenerationMode=void 0,this.modelId=e,this.settings=t,this.config=n}getArgs({prompt:e,maxOutputTokens:t,temperature:n,topP:o,frequencyPenalty:r,presencePenalty:i,seed:a,responseFormat:s,topK:l,stopSequences:u,tools:c,toolChoice:d}){const{prompt:p}=EC({prompt:e,inputFormat:"prompt"});if(c?.length)throw new er({functionality:"tools"});if(d)throw new er({functionality:"toolChoice"});return ae(ae({model:this.modelId,models:this.settings.models,logit_bias:this.settings.logitBias,logprobs:typeof this.settings.logprobs=="number"?this.settings.logprobs:typeof this.settings.logprobs=="boolean"&&this.settings.logprobs?0:void 0,suffix:this.settings.suffix,user:this.settings.user,max_tokens:t,temperature:n,top_p:o,frequency_penalty:r,presence_penalty:i,seed:a,stop:u,response_format:s,top_k:l,prompt:p,include_reasoning:this.settings.includeReasoning,reasoning:this.settings.reasoning},this.config.extraBody),this.settings.extraBody)}async doGenerate(e){var t,n,o,r,i,a,s,l,u,c,d,p,f,g,m;const y=(e.providerOptions||{}).openrouter||{},x=ae(ae({},this.getArgs(e)),y),{value:$,responseHeaders:v}=await Fn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Zn(this.config.headers(),e.headers),body:x,failedResponseHandler:qn,successfulResponseHandler:Tc(kf),abortSignal:e.abortSignal,fetch:this.config.fetch});if("error"in $){const N=$.error;throw new $t({message:N.message,url:this.config.url({path:"/completions",modelId:this.modelId}),requestBodyValues:x,statusCode:200,responseHeaders:v,data:N})}const k=$.choices[0];if(!k)throw new hw({message:"No choice in OpenRouter completion response"});return{content:[{type:"text",text:(t=k.text)!=null?t:""}],finishReason:$i(k.finish_reason),usage:{inputTokens:(o=(n=$.usage)==null?void 0:n.prompt_tokens)!=null?o:0,outputTokens:(i=(r=$.usage)==null?void 0:r.completion_tokens)!=null?i:0,totalTokens:((s=(a=$.usage)==null?void 0:a.prompt_tokens)!=null?s:0)+((u=(l=$.usage)==null?void 0:l.completion_tokens)!=null?u:0),reasoningTokens:(p=(d=(c=$.usage)==null?void 0:c.completion_tokens_details)==null?void 0:d.reasoning_tokens)!=null?p:0,cachedInputTokens:(m=(g=(f=$.usage)==null?void 0:f.prompt_tokens_details)==null?void 0:g.cached_tokens)!=null?m:0},warnings:[],response:{headers:v}}}async doStream(e){const n=(e.providerOptions||{}).openrouter||{},o=ae(ae({},this.getArgs(e)),n),{value:r,responseHeaders:i}=await Fn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Zn(this.config.headers(),e.headers),body:wi(ae({},o),{stream:!0,stream_options:this.config.compatibility==="strict"?{include_usage:!0}:void 0}),failedResponseHandler:qn,successfulResponseHandler:Sw(kf),abortSignal:e.abortSignal,fetch:this.config.fetch});let a="other";const s={inputTokens:Number.NaN,outputTokens:Number.NaN,totalTokens:Number.NaN,reasoningTokens:Number.NaN,cachedInputTokens:Number.NaN},l={};return{stream:r.pipeThrough(new TransformStream({transform(u,c){var d,p,f;if(!u.success){a="error",c.enqueue({type:"error",error:u.error});return}const g=u.value;if("error"in g){a="error",c.enqueue({type:"error",error:g.error});return}if(g.usage!=null){if(s.inputTokens=g.usage.prompt_tokens,s.outputTokens=g.usage.completion_tokens,s.totalTokens=g.usage.prompt_tokens+g.usage.completion_tokens,l.promptTokens=g.usage.prompt_tokens,g.usage.prompt_tokens_details){const y=(d=g.usage.prompt_tokens_details.cached_tokens)!=null?d:0;s.cachedInputTokens=y,l.promptTokensDetails={cachedTokens:y}}if(l.completionTokens=g.usage.completion_tokens,g.usage.completion_tokens_details){const y=(p=g.usage.completion_tokens_details.reasoning_tokens)!=null?p:0;s.reasoningTokens=y,l.completionTokensDetails={reasoningTokens:y}}l.cost=g.usage.cost,l.totalTokens=g.usage.total_tokens;const b=(f=g.usage.cost_details)==null?void 0:f.upstream_inference_cost;b!=null&&(l.costDetails={upstreamInferenceCost:b})}const m=g.choices[0];m?.finish_reason!=null&&(a=$i(m.finish_reason)),m?.text!=null&&c.enqueue({type:"text-delta",delta:m.text,id:_t()})},flush(u){u.enqueue({type:"finish",finishReason:a,usage:s,providerMetadata:{openrouter:{usage:l}}})}})),response:{headers:i}}}},TC=E({prompt_tokens:q(),total_tokens:q(),cost:q().optional()}),NC=E({object:C("embedding"),embedding:R(q()),index:q().optional()}),PC=E({id:w().optional(),object:C("list"),data:R(NC),model:w(),usage:TC.optional()}),CC=class{constructor(e,t,n){this.specificationVersion="v2",this.provider="openrouter",this.maxEmbeddingsPerCall=void 0,this.supportsParallelCalls=!0,this.modelId=e,this.settings=t,this.config=n}async doEmbed(e){var t;const{values:n,abortSignal:o,headers:r}=e,i=ae(ae({model:this.modelId,input:n,user:this.settings.user,provider:this.settings.provider},this.config.extraBody),this.settings.extraBody),{value:a,responseHeaders:s}=await Fn({url:this.config.url({path:"/embeddings",modelId:this.modelId}),headers:Zn(this.config.headers(),r),body:i,failedResponseHandler:qn,successfulResponseHandler:Tc(PC),abortSignal:o,fetch:this.config.fetch});return{embeddings:a.data.map(l=>l.embedding),usage:a.usage?{tokens:a.usage.prompt_tokens}:void 0,providerMetadata:(t=a.usage)!=null&&t.cost?{openrouter:{usage:{cost:a.usage.cost}}}:void 0,response:{headers:s,body:a}}}};function jC(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==null))}function AC(e,...t){const n=jC(e??{}),r=[n["user-agent"]||"",...t].filter(Boolean).join(" ");return wi(ae({},n),{"user-agent":r})}var RC="1.5.4";function Tw(e={}){var t,n,o;const r=(n=dC((t=e.baseURL)!=null?t:e.baseUrl))!=null?n:"https://openrouter.ai/api/v1",i=(o=e.compatibility)!=null?o:"compatible",a=()=>AC(ae(ae({Authorization:`Bearer ${HP({apiKey:e.apiKey,environmentVariableName:"OPENROUTER_API_KEY",description:"OpenRouter"})}`},e.headers),e.api_keys&&Object.keys(e.api_keys).length>0&&{"X-Provider-API-Keys":JSON.stringify(e.api_keys)}),`ai-sdk/openrouter/${RC}`),s=(p,f={})=>new kC(p,f,{provider:"openrouter.chat",url:({path:g})=>`${r}${g}`,headers:a,compatibility:i,fetch:e.fetch,extraBody:e.extraBody}),l=(p,f={})=>new OC(p,f,{provider:"openrouter.completion",url:({path:g})=>`${r}${g}`,headers:a,compatibility:i,fetch:e.fetch,extraBody:e.extraBody}),u=(p,f={})=>new CC(p,f,{provider:"openrouter.embedding",url:({path:g})=>`${r}${g}`,headers:a,fetch:e.fetch,extraBody:e.extraBody}),c=(p,f)=>{if(new.target)throw new Error("The OpenRouter model function cannot be called with the new keyword.");return p==="openai/gpt-3.5-turbo-instruct"?l(p,f):s(p,f)},d=(p,f)=>c(p,f);return d.languageModel=c,d.chat=s,d.completion=l,d.textEmbeddingModel=u,d.embedding=u,d}Tw({compatibility:"strict"});function uu(...e){return e.reduce((t,n)=>({...t,...n??{}}),{})}async function Nw(e,t){if(e==null)return Promise.resolve();const n=t?.abortSignal;return new Promise((o,r)=>{if(n?.aborted){r(Ef());return}const i=setTimeout(()=>{a(),o()},e),a=()=>{clearTimeout(i),n?.removeEventListener("abort",s)},s=()=>{a(),r(Ef())};n?.addEventListener("abort",s)})}function Ef(){return new DOMException("Delay was aborted","AbortError")}function ko(e){return Object.fromEntries([...e.headers])}var Eo=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const r=()=>{const i=n.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=n[Math.random()*i|0];return a.join("")};if(e==null)return r;if(n.includes(o))throw new Zi({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${n}".`});return()=>`${e}${o}${r()}`},zC=Eo();function Pw(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}function br(e){return(e instanceof Error||e instanceof DOMException)&&(e.name==="AbortError"||e.name==="ResponseAborted"||e.name==="TimeoutError")}var MC=["fetch failed","failed to fetch"];function Cw({error:e,url:t,requestBodyValues:n}){if(br(e))return e;if(e instanceof TypeError&&MC.includes(e.message.toLowerCase())){const o=e.cause;if(o!=null)return new Be({message:`Cannot connect to API: ${o.message}`,cause:o,url:t,requestBodyValues:n,isRetryable:!0})}return e}function Ac(e=globalThis){var t,n,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(n=e.process)==null?void 0:n.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function DC(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,o)=>{t[o.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,o]of e)o!=null&&(t[n.toLowerCase()]=o)}return t}function La(e,...t){const n=new Headers(DC(e)),o=n.get("user-agent")||"";return n.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}var jw="3.0.16",UC=()=>globalThis.fetch,Of=async({url:e,headers:t={},successfulResponseHandler:n,failedResponseHandler:o,abortSignal:r,fetch:i=UC()})=>{try{const a=await i(e,{method:"GET",headers:La(t,`ai-sdk/provider-utils/${jw}`,Ac()),signal:r}),s=ko(a);if(!a.ok){let l;try{l=await o({response:a,url:e,requestBodyValues:{}})}catch(u){throw br(u)||Be.isInstance(u)?u:new Be({message:"Failed to process error response",cause:u,statusCode:a.status,url:e,responseHeaders:s,requestBodyValues:{}})}throw l.value}try{return await n({response:a,url:e,requestBodyValues:{}})}catch(l){throw l instanceof Error&&(br(l)||Be.isInstance(l))?l:new Be({message:"Failed to process successful response",cause:l,statusCode:a.status,url:e,responseHeaders:s,requestBodyValues:{}})}}catch(a){throw Cw({error:a,url:e,requestBodyValues:{}})}};function LC({mediaType:e,url:t,supportedUrls:n}){return t=t.toLowerCase(),e=e.toLowerCase(),Object.entries(n).map(([o,r])=>{const i=o.toLowerCase();return i==="*"||i==="*/*"?{mediaTypePrefix:"",regexes:r}:{mediaTypePrefix:i.replace(/\*/,""),regexes:r}}).filter(({mediaTypePrefix:o})=>e.startsWith(o)).flatMap(({regexes:o})=>o).some(o=>o.test(t))}function oi({settingValue:e,environmentVariableName:t}){if(typeof e=="string")return e;if(!(e!=null||typeof process>"u")&&(e=process.env[t],!(e==null||typeof e!="string")))return e}var ZC=/"__proto__"\s*:/,FC=/"constructor"\s*:/;function qC(e){const t=JSON.parse(e);return t===null||typeof t!="object"||ZC.test(e)===!1&&FC.test(e)===!1?t:VC(t)}function VC(e){let t=[e];for(;t.length;){const n=t;t=[];for(const o of n){if(Object.prototype.hasOwnProperty.call(o,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(o,"constructor")&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const r in o){const i=o[r];i&&typeof i=="object"&&t.push(i)}}}return e}function Aw(e){const{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return qC(e)}finally{Error.stackTraceLimit=t}}var Si=Symbol.for("vercel.ai.validator");function BC(e){return{[Si]:!0,validate:e}}function JC(e){return typeof e=="object"&&e!==null&&Si in e&&e[Si]===!0&&"validate"in e}function un(e){let t;return()=>(t==null&&(t=e()),t)}function WC(e){return JC(e)?e:typeof e=="function"?e():HC(e)}function HC(e){return BC(async t=>{const n=await e["~standard"].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new qt({value:t,cause:n.issues})}})}async function lu({value:e,schema:t}){const n=await ar({value:e,schema:t});if(!n.success)throw qt.wrap({value:e,cause:n.error});return n.value}async function ar({value:e,schema:t}){const n=WC(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};const o=await n.validate(e);return o.success?{success:!0,value:o.value,rawValue:e}:{success:!1,error:qt.wrap({value:e,cause:o.error}),rawValue:e}}catch(o){return{success:!1,error:qt.wrap({value:e,cause:o}),rawValue:e}}}async function GC({text:e,schema:t}){try{const n=Aw(e);return t==null?n:lu({value:n,schema:t})}catch(n){throw Br.isInstance(n)||qt.isInstance(n)?n:new Br({text:e,cause:n})}}async function _r({text:e,schema:t}){try{const n=Aw(e);return t==null?{success:!0,value:n,rawValue:n}:await ar({value:n,schema:t})}catch(n){return{success:!1,error:Br.isInstance(n)?n:new Br({text:e,cause:n}),rawValue:void 0}}}function KC({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Nn).pipeThrough(new TransformStream({async transform({data:n},o){n!=="[DONE]"&&o.enqueue(await _r({text:n,schema:t}))}}))}var YC=()=>globalThis.fetch,cu=async({url:e,headers:t,body:n,failedResponseHandler:o,successfulResponseHandler:r,abortSignal:i,fetch:a})=>QC({url:e,headers:{"Content-Type":"application/json",...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:o,successfulResponseHandler:r,abortSignal:i,fetch:a}),QC=async({url:e,headers:t={},body:n,successfulResponseHandler:o,failedResponseHandler:r,abortSignal:i,fetch:a=YC()})=>{try{const s=await a(e,{method:"POST",headers:La(t,`ai-sdk/provider-utils/${jw}`,Ac()),body:n.content,signal:i}),l=ko(s);if(!s.ok){let u;try{u=await r({response:s,url:e,requestBodyValues:n.values})}catch(c){throw br(c)||Be.isInstance(c)?c:new Be({message:"Failed to process error response",cause:c,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:n.values})}throw u.value}try{return await o({response:s,url:e,requestBodyValues:n.values})}catch(u){throw u instanceof Error&&(br(u)||Be.isInstance(u))?u:new Be({message:"Failed to process successful response",cause:u,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:n.values})}}catch(s){throw Cw({error:s,url:e,requestBodyValues:n.values})}};async function rr(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var Vn=({errorSchema:e,errorToMessage:t,isRetryable:n})=>async({response:o,url:r,requestBodyValues:i})=>{const a=await o.text(),s=ko(o);if(a.trim()==="")return{responseHeaders:s,value:new Be({message:o.statusText,url:r,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:n?.(o)})};try{const l=await GC({text:a,schema:e});return{responseHeaders:s,value:new Be({message:t(l),url:r,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,data:l,isRetryable:n?.(o,l)})}}catch{return{responseHeaders:s,value:new Be({message:o.statusText,url:r,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:n?.(o)})}}},XC=e=>async({response:t})=>{const n=ko(t);if(t.body==null)throw new iI({});return{responseHeaders:n,value:KC({stream:t.body,schema:e})}},Ii=e=>async({response:t,url:n,requestBodyValues:o})=>{const r=await t.text(),i=await _r({text:r,schema:e}),a=ko(t);if(!i.success)throw new Be({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:a,responseBody:r,url:n,requestBodyValues:o});return{responseHeaders:a,value:i.value,rawValue:i.rawValue}},e1=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")},t1=Symbol("Let zodToJsonSchema decide on which parser to use"),Tf={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},r1=e=>typeof e=="string"?{...Tf,name:e}:{...Tf,...e};function tt(){return{}}function n1(e,t){var n,o,r;const i={type:"array"};return(n=e.type)!=null&&n._def&&((r=(o=e.type)==null?void 0:o._def)==null?void 0:r.typeName)!==A.ZodAny&&(i.items=le(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(i.minItems=e.minLength.value),e.maxLength&&(i.maxItems=e.maxLength.value),e.exactLength&&(i.minItems=e.exactLength.value,i.maxItems=e.exactLength.value),i}function o1(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function i1(){return{type:"boolean"}}function Rw(e,t){return le(e.type._def,t)}var a1=(e,t)=>le(e.innerType._def,t);function zw(e,t,n){const o=n??t.dateStrategy;if(Array.isArray(o))return{anyOf:o.map((r,i)=>zw(e,t,r))};switch(o){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return s1(e)}}var s1=e=>{const t={type:"integer",format:"unix-time"};for(const n of e.checks)switch(n.kind){case"min":t.minimum=n.value;break;case"max":t.maximum=n.value;break}return t};function u1(e,t){return{...le(e.innerType._def,t),default:e.defaultValue()}}function l1(e,t){return t.effectStrategy==="input"?le(e.schema._def,t):tt()}function c1(e){return{type:"string",enum:Array.from(e.values)}}var d1=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function f1(e,t){const n=[le(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),le(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(r=>!!r),o=[];return n.forEach(r=>{if(d1(r))o.push(...r.allOf);else{let i=r;if("additionalProperties"in r&&r.additionalProperties===!1){const{additionalProperties:a,...s}=r;i=s}o.push(i)}}),o.length?{allOf:o}:void 0}function p1(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var Is=void 0,yt={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:()=>(Is===void 0&&(Is=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Is),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Mw(e,t){const n={type:"string"};if(e.checks)for(const o of e.checks)switch(o.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,o.value):o.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,o.value):o.value;break;case"email":switch(t.emailStrategy){case"format:email":bt(n,"email",o.message,t);break;case"format:idn-email":bt(n,"idn-email",o.message,t);break;case"pattern:zod":qe(n,yt.email,o.message,t);break}break;case"url":bt(n,"uri",o.message,t);break;case"uuid":bt(n,"uuid",o.message,t);break;case"regex":qe(n,o.regex,o.message,t);break;case"cuid":qe(n,yt.cuid,o.message,t);break;case"cuid2":qe(n,yt.cuid2,o.message,t);break;case"startsWith":qe(n,RegExp(`^${ks(o.value,t)}`),o.message,t);break;case"endsWith":qe(n,RegExp(`${ks(o.value,t)}$`),o.message,t);break;case"datetime":bt(n,"date-time",o.message,t);break;case"date":bt(n,"date",o.message,t);break;case"time":bt(n,"time",o.message,t);break;case"duration":bt(n,"duration",o.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,o.value):o.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,o.value):o.value;break;case"includes":{qe(n,RegExp(ks(o.value,t)),o.message,t);break}case"ip":{o.version!=="v6"&&bt(n,"ipv4",o.message,t),o.version!=="v4"&&bt(n,"ipv6",o.message,t);break}case"base64url":qe(n,yt.base64url,o.message,t);break;case"jwt":qe(n,yt.jwt,o.message,t);break;case"cidr":{o.version!=="v6"&&qe(n,yt.ipv4Cidr,o.message,t),o.version!=="v4"&&qe(n,yt.ipv6Cidr,o.message,t);break}case"emoji":qe(n,yt.emoji(),o.message,t);break;case"ulid":{qe(n,yt.ulid,o.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{bt(n,"binary",o.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{qe(n,yt.base64,o.message,t);break}}break}case"nanoid":qe(n,yt.nanoid,o.message,t)}return n}function ks(e,t){return t.patternStrategy==="escape"?h1(e):e}var m1=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function h1(e){let t="";for(let n=0;n<e.length;n++)m1.has(e[n])||(t+="\\"),t+=e[n];return t}function bt(e,t,n,o){var r;e.format||(r=e.anyOf)!=null&&r.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&o.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function qe(e,t,n,o){var r;e.pattern||(r=e.allOf)!=null&&r.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Nf(t,o),...n&&o.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Nf(t,o)}function Nf(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const o={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},r=o.i?e.source.toLowerCase():e.source;let i="",a=!1,s=!1,l=!1;for(let u=0;u<r.length;u++){if(a){i+=r[u],a=!1;continue}if(o.i){if(s){if(r[u].match(/[a-z]/)){l?(i+=r[u],i+=`${r[u-2]}-${r[u]}`.toUpperCase(),l=!1):r[u+1]==="-"&&((n=r[u+2])!=null&&n.match(/[a-z]/))?(i+=r[u],l=!0):i+=`${r[u]}${r[u].toUpperCase()}`;continue}}else if(r[u].match(/[a-z]/)){i+=`[${r[u]}${r[u].toUpperCase()}]`;continue}}if(o.m){if(r[u]==="^"){i+=`(^|(?<=[\r
|
|
64
|
+
`;break}case"tool":throw new Xt({functionality:"tool messages"})}return r+=`${o}:
|
|
65
|
+
`,{prompt:r}}var Ep=G([E({id:w().optional(),model:w().optional(),choices:R(E({text:w(),reasoning:w().nullish().optional(),reasoning_details:Ac.nullish(),finish_reason:w().nullish(),index:V().nullish(),logprobs:E({tokens:R(w()),token_logprobs:R(V()),top_logprobs:R(Xe(w(),V())).nullable()}).passthrough().nullable().optional()}).passthrough()),usage:E({prompt_tokens:V(),prompt_tokens_details:E({cached_tokens:V()}).passthrough().nullish(),completion_tokens:V(),completion_tokens_details:E({reasoning_tokens:V()}).passthrough().nullish(),total_tokens:V(),cost:V().optional(),cost_details:E({upstream_inference_cost:V().nullish()}).passthrough().nullish()}).passthrough().nullish()}).passthrough(),Fa]),jC=class{constructor(e,t,n){this.specificationVersion="v2",this.provider="openrouter",this.supportsImageUrls=!0,this.supportedUrls={"image/*":[/^data:image\/[a-zA-Z]+;base64,/,/^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)$/i],"text/*":[/^data:text\//,/^https?:\/\/.+$/],"application/*":[/^data:application\//,/^https?:\/\/.+$/]},this.defaultObjectGenerationMode=void 0,this.modelId=e,this.settings=t,this.config=n}getArgs({prompt:e,maxOutputTokens:t,temperature:n,topP:o,frequencyPenalty:r,presencePenalty:i,seed:a,responseFormat:s,topK:l,stopSequences:u,tools:c,toolChoice:d}){const{prompt:f}=CC({prompt:e,inputFormat:"prompt"});if(c?.length)throw new Xt({functionality:"tools"});if(d)throw new Xt({functionality:"toolChoice"});return ae(ae({model:this.modelId,models:this.settings.models,logit_bias:this.settings.logitBias,logprobs:typeof this.settings.logprobs=="number"?this.settings.logprobs:typeof this.settings.logprobs=="boolean"&&this.settings.logprobs?0:void 0,suffix:this.settings.suffix,user:this.settings.user,max_tokens:t,temperature:n,top_p:o,frequency_penalty:r,presence_penalty:i,seed:a,stop:u,response_format:s,top_k:l,prompt:f,include_reasoning:this.settings.includeReasoning,reasoning:this.settings.reasoning},this.config.extraBody),this.settings.extraBody)}async doGenerate(e){var t,n,o,r,i,a,s,l,u,c,d,f,p,g,h;const y=(e.providerOptions||{}).openrouter||{},x=ae(ae({},this.getArgs(e)),y),{value:$,responseHeaders:v}=await qn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Fn(this.config.headers(),e.headers),body:x,failedResponseHandler:Vn,successfulResponseHandler:Pc(Ep),abortSignal:e.abortSignal,fetch:this.config.fetch});if("error"in $){const N=$.error;throw new xt({message:N.message,url:this.config.url({path:"/completions",modelId:this.modelId}),requestBodyValues:x,statusCode:200,responseHeaders:v,data:N})}const k=$.choices[0];if(!k)throw new vw({message:"No choice in OpenRouter completion response"});return{content:[{type:"text",text:(t=k.text)!=null?t:""}],finishReason:Ii(k.finish_reason),usage:{inputTokens:(o=(n=$.usage)==null?void 0:n.prompt_tokens)!=null?o:0,outputTokens:(i=(r=$.usage)==null?void 0:r.completion_tokens)!=null?i:0,totalTokens:((s=(a=$.usage)==null?void 0:a.prompt_tokens)!=null?s:0)+((u=(l=$.usage)==null?void 0:l.completion_tokens)!=null?u:0),reasoningTokens:(f=(d=(c=$.usage)==null?void 0:c.completion_tokens_details)==null?void 0:d.reasoning_tokens)!=null?f:0,cachedInputTokens:(h=(g=(p=$.usage)==null?void 0:p.prompt_tokens_details)==null?void 0:g.cached_tokens)!=null?h:0},warnings:[],response:{headers:v}}}async doStream(e){const n=(e.providerOptions||{}).openrouter||{},o=ae(ae({},this.getArgs(e)),n),{value:r,responseHeaders:i}=await qn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Fn(this.config.headers(),e.headers),body:$i(ae({},o),{stream:!0,stream_options:this.config.compatibility==="strict"?{include_usage:!0}:void 0}),failedResponseHandler:Vn,successfulResponseHandler:kw(Ep),abortSignal:e.abortSignal,fetch:this.config.fetch});let a="other";const s={inputTokens:Number.NaN,outputTokens:Number.NaN,totalTokens:Number.NaN,reasoningTokens:Number.NaN,cachedInputTokens:Number.NaN},l={};return{stream:r.pipeThrough(new TransformStream({transform(u,c){var d,f,p;if(!u.success){a="error",c.enqueue({type:"error",error:u.error});return}const g=u.value;if("error"in g){a="error",c.enqueue({type:"error",error:g.error});return}if(g.usage!=null){if(s.inputTokens=g.usage.prompt_tokens,s.outputTokens=g.usage.completion_tokens,s.totalTokens=g.usage.prompt_tokens+g.usage.completion_tokens,l.promptTokens=g.usage.prompt_tokens,g.usage.prompt_tokens_details){const y=(d=g.usage.prompt_tokens_details.cached_tokens)!=null?d:0;s.cachedInputTokens=y,l.promptTokensDetails={cachedTokens:y}}if(l.completionTokens=g.usage.completion_tokens,g.usage.completion_tokens_details){const y=(f=g.usage.completion_tokens_details.reasoning_tokens)!=null?f:0;s.reasoningTokens=y,l.completionTokensDetails={reasoningTokens:y}}l.cost=g.usage.cost,l.totalTokens=g.usage.total_tokens;const b=(p=g.usage.cost_details)==null?void 0:p.upstream_inference_cost;b!=null&&(l.costDetails={upstreamInferenceCost:b})}const h=g.choices[0];h?.finish_reason!=null&&(a=Ii(h.finish_reason)),h?.text!=null&&c.enqueue({type:"text-delta",delta:h.text,id:bt()})},flush(u){u.enqueue({type:"finish",finishReason:a,usage:s,providerMetadata:{openrouter:{usage:l}}})}})),response:{headers:i}}}},AC=E({prompt_tokens:V(),total_tokens:V(),cost:V().optional()}),RC=E({object:C("embedding"),embedding:R(V()),index:V().optional()}),zC=E({id:w().optional(),object:C("list"),data:R(RC),model:w(),usage:AC.optional()}),MC=class{constructor(e,t,n){this.specificationVersion="v2",this.provider="openrouter",this.maxEmbeddingsPerCall=void 0,this.supportsParallelCalls=!0,this.modelId=e,this.settings=t,this.config=n}async doEmbed(e){var t;const{values:n,abortSignal:o,headers:r}=e,i=ae(ae({model:this.modelId,input:n,user:this.settings.user,provider:this.settings.provider},this.config.extraBody),this.settings.extraBody),{value:a,responseHeaders:s}=await qn({url:this.config.url({path:"/embeddings",modelId:this.modelId}),headers:Fn(this.config.headers(),r),body:i,failedResponseHandler:Vn,successfulResponseHandler:Pc(zC),abortSignal:o,fetch:this.config.fetch});return{embeddings:a.data.map(l=>l.embedding),usage:a.usage?{tokens:a.usage.prompt_tokens}:void 0,providerMetadata:(t=a.usage)!=null&&t.cost?{openrouter:{usage:{cost:a.usage.cost}}}:void 0,response:{headers:s,body:a}}}};function DC(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==null))}function UC(e,...t){const n=DC(e??{}),r=[n["user-agent"]||"",...t].filter(Boolean).join(" ");return $i(ae({},n),{"user-agent":r})}var LC="1.5.4";function Pw(e={}){var t,n,o;const r=(n=gC((t=e.baseURL)!=null?t:e.baseUrl))!=null?n:"https://openrouter.ai/api/v1",i=(o=e.compatibility)!=null?o:"compatible",a=()=>UC(ae(ae({Authorization:`Bearer ${XP({apiKey:e.apiKey,environmentVariableName:"OPENROUTER_API_KEY",description:"OpenRouter"})}`},e.headers),e.api_keys&&Object.keys(e.api_keys).length>0&&{"X-Provider-API-Keys":JSON.stringify(e.api_keys)}),`ai-sdk/openrouter/${LC}`),s=(f,p={})=>new PC(f,p,{provider:"openrouter.chat",url:({path:g})=>`${r}${g}`,headers:a,compatibility:i,fetch:e.fetch,extraBody:e.extraBody}),l=(f,p={})=>new jC(f,p,{provider:"openrouter.completion",url:({path:g})=>`${r}${g}`,headers:a,compatibility:i,fetch:e.fetch,extraBody:e.extraBody}),u=(f,p={})=>new MC(f,p,{provider:"openrouter.embedding",url:({path:g})=>`${r}${g}`,headers:a,fetch:e.fetch,extraBody:e.extraBody}),c=(f,p)=>{if(new.target)throw new Error("The OpenRouter model function cannot be called with the new keyword.");return f==="openai/gpt-3.5-turbo-instruct"?l(f,p):s(f,p)},d=(f,p)=>c(f,p);return d.languageModel=c,d.chat=s,d.completion=l,d.textEmbeddingModel=u,d.embedding=u,d}Pw({compatibility:"strict"});function pu(...e){return e.reduce((t,n)=>({...t,...n??{}}),{})}async function Cw(e,t){if(e==null)return Promise.resolve();const n=t?.abortSignal;return new Promise((o,r)=>{if(n?.aborted){r(Tp());return}const i=setTimeout(()=>{a(),o()},e),a=()=>{clearTimeout(i),n?.removeEventListener("abort",s)},s=()=>{a(),r(Tp())};n?.addEventListener("abort",s)})}function Tp(){return new DOMException("Delay was aborted","AbortError")}function Eo(e){return Object.fromEntries([...e.headers])}var To=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const r=()=>{const i=n.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=n[Math.random()*i|0];return a.join("")};if(e==null)return r;if(n.includes(o))throw new Vi({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${n}".`});return()=>`${e}${o}${r()}`},ZC=To();function jw(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}function _r(e){return(e instanceof Error||e instanceof DOMException)&&(e.name==="AbortError"||e.name==="ResponseAborted"||e.name==="TimeoutError")}var FC=["fetch failed","failed to fetch"];function Aw({error:e,url:t,requestBodyValues:n}){if(_r(e))return e;if(e instanceof TypeError&&FC.includes(e.message.toLowerCase())){const o=e.cause;if(o!=null)return new Be({message:`Cannot connect to API: ${o.message}`,cause:o,url:t,requestBodyValues:n,isRetryable:!0})}return e}function zc(e=globalThis){var t,n,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(n=e.process)==null?void 0:n.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function qC(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,o)=>{t[o.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,o]of e)o!=null&&(t[n.toLowerCase()]=o)}return t}function qa(e,...t){const n=new Headers(qC(e)),o=n.get("user-agent")||"";return n.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}var Rw="3.0.16",VC=()=>globalThis.fetch,Op=async({url:e,headers:t={},successfulResponseHandler:n,failedResponseHandler:o,abortSignal:r,fetch:i=VC()})=>{try{const a=await i(e,{method:"GET",headers:qa(t,`ai-sdk/provider-utils/${Rw}`,zc()),signal:r}),s=Eo(a);if(!a.ok){let l;try{l=await o({response:a,url:e,requestBodyValues:{}})}catch(u){throw _r(u)||Be.isInstance(u)?u:new Be({message:"Failed to process error response",cause:u,statusCode:a.status,url:e,responseHeaders:s,requestBodyValues:{}})}throw l.value}try{return await n({response:a,url:e,requestBodyValues:{}})}catch(l){throw l instanceof Error&&(_r(l)||Be.isInstance(l))?l:new Be({message:"Failed to process successful response",cause:l,statusCode:a.status,url:e,responseHeaders:s,requestBodyValues:{}})}}catch(a){throw Aw({error:a,url:e,requestBodyValues:{}})}};function BC({mediaType:e,url:t,supportedUrls:n}){return t=t.toLowerCase(),e=e.toLowerCase(),Object.entries(n).map(([o,r])=>{const i=o.toLowerCase();return i==="*"||i==="*/*"?{mediaTypePrefix:"",regexes:r}:{mediaTypePrefix:i.replace(/\*/,""),regexes:r}}).filter(({mediaTypePrefix:o})=>e.startsWith(o)).flatMap(({regexes:o})=>o).some(o=>o.test(t))}function ii({settingValue:e,environmentVariableName:t}){if(typeof e=="string")return e;if(!(e!=null||typeof process>"u")&&(e=process.env[t],!(e==null||typeof e!="string")))return e}var JC=/"__proto__"\s*:/,WC=/"constructor"\s*:/;function HC(e){const t=JSON.parse(e);return t===null||typeof t!="object"||JC.test(e)===!1&&WC.test(e)===!1?t:GC(t)}function GC(e){let t=[e];for(;t.length;){const n=t;t=[];for(const o of n){if(Object.prototype.hasOwnProperty.call(o,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(o,"constructor")&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const r in o){const i=o[r];i&&typeof i=="object"&&t.push(i)}}}return e}function zw(e){const{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return HC(e)}finally{Error.stackTraceLimit=t}}var ki=Symbol.for("vercel.ai.validator");function KC(e){return{[ki]:!0,validate:e}}function YC(e){return typeof e=="object"&&e!==null&&ki in e&&e[ki]===!0&&"validate"in e}function ln(e){let t;return()=>(t==null&&(t=e()),t)}function QC(e){return YC(e)?e:typeof e=="function"?e():XC(e)}function XC(e){return KC(async t=>{const n=await e["~standard"].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new Ft({value:t,cause:n.issues})}})}async function fu({value:e,schema:t}){const n=await sr({value:e,schema:t});if(!n.success)throw Ft.wrap({value:e,cause:n.error});return n.value}async function sr({value:e,schema:t}){const n=QC(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};const o=await n.validate(e);return o.success?{success:!0,value:o.value,rawValue:e}:{success:!1,error:Ft.wrap({value:e,cause:o.error}),rawValue:e}}catch(o){return{success:!1,error:Ft.wrap({value:e,cause:o}),rawValue:e}}}async function ej({text:e,schema:t}){try{const n=zw(e);return t==null?n:fu({value:n,schema:t})}catch(n){throw Jr.isInstance(n)||Ft.isInstance(n)?n:new Jr({text:e,cause:n})}}async function wr({text:e,schema:t}){try{const n=zw(e);return t==null?{success:!0,value:n,rawValue:n}:await sr({value:n,schema:t})}catch(n){return{success:!1,error:Jr.isInstance(n)?n:new Jr({text:e,cause:n}),rawValue:void 0}}}function tj({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).pipeThrough(new TransformStream({async transform({data:n},o){n!=="[DONE]"&&o.enqueue(await wr({text:n,schema:t}))}}))}var rj=()=>globalThis.fetch,mu=async({url:e,headers:t,body:n,failedResponseHandler:o,successfulResponseHandler:r,abortSignal:i,fetch:a})=>nj({url:e,headers:{"Content-Type":"application/json",...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:o,successfulResponseHandler:r,abortSignal:i,fetch:a}),nj=async({url:e,headers:t={},body:n,successfulResponseHandler:o,failedResponseHandler:r,abortSignal:i,fetch:a=rj()})=>{try{const s=await a(e,{method:"POST",headers:qa(t,`ai-sdk/provider-utils/${Rw}`,zc()),body:n.content,signal:i}),l=Eo(s);if(!s.ok){let u;try{u=await r({response:s,url:e,requestBodyValues:n.values})}catch(c){throw _r(c)||Be.isInstance(c)?c:new Be({message:"Failed to process error response",cause:c,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:n.values})}throw u.value}try{return await o({response:s,url:e,requestBodyValues:n.values})}catch(u){throw u instanceof Error&&(_r(u)||Be.isInstance(u))?u:new Be({message:"Failed to process successful response",cause:u,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:n.values})}}catch(s){throw Aw({error:s,url:e,requestBodyValues:n.values})}};async function tr(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var Bn=({errorSchema:e,errorToMessage:t,isRetryable:n})=>async({response:o,url:r,requestBodyValues:i})=>{const a=await o.text(),s=Eo(o);if(a.trim()==="")return{responseHeaders:s,value:new Be({message:o.statusText,url:r,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:n?.(o)})};try{const l=await ej({text:a,schema:e});return{responseHeaders:s,value:new Be({message:t(l),url:r,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,data:l,isRetryable:n?.(o,l)})}}catch{return{responseHeaders:s,value:new Be({message:o.statusText,url:r,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:n?.(o)})}}},oj=e=>async({response:t})=>{const n=Eo(t);if(t.body==null)throw new cI({});return{responseHeaders:n,value:tj({stream:t.body,schema:e})}},Ei=e=>async({response:t,url:n,requestBodyValues:o})=>{const r=await t.text(),i=await wr({text:r,schema:e}),a=Eo(t);if(!i.success)throw new Be({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:a,responseBody:r,url:n,requestBodyValues:o});return{responseHeaders:a,value:i.value,rawValue:i.rawValue}},ij=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")},aj=Symbol("Let zodToJsonSchema decide on which parser to use"),Np={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},sj=e=>typeof e=="string"?{...Np,name:e}:{...Np,...e};function tt(){return{}}function uj(e,t){var n,o,r;const i={type:"array"};return(n=e.type)!=null&&n._def&&((r=(o=e.type)==null?void 0:o._def)==null?void 0:r.typeName)!==A.ZodAny&&(i.items=le(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(i.minItems=e.minLength.value),e.maxLength&&(i.maxItems=e.maxLength.value),e.exactLength&&(i.minItems=e.exactLength.value,i.maxItems=e.exactLength.value),i}function lj(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function cj(){return{type:"boolean"}}function Mw(e,t){return le(e.type._def,t)}var dj=(e,t)=>le(e.innerType._def,t);function Dw(e,t,n){const o=n??t.dateStrategy;if(Array.isArray(o))return{anyOf:o.map((r,i)=>Dw(e,t,r))};switch(o){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return pj(e)}}var pj=e=>{const t={type:"integer",format:"unix-time"};for(const n of e.checks)switch(n.kind){case"min":t.minimum=n.value;break;case"max":t.maximum=n.value;break}return t};function fj(e,t){return{...le(e.innerType._def,t),default:e.defaultValue()}}function mj(e,t){return t.effectStrategy==="input"?le(e.schema._def,t):tt()}function hj(e){return{type:"string",enum:Array.from(e.values)}}var gj=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function vj(e,t){const n=[le(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),le(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(r=>!!r),o=[];return n.forEach(r=>{if(gj(r))o.push(...r.allOf);else{let i=r;if("additionalProperties"in r&&r.additionalProperties===!1){const{additionalProperties:a,...s}=r;i=s}o.push(i)}}),o.length?{allOf:o}:void 0}function yj(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var Ts=void 0,vt={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:()=>(Ts===void 0&&(Ts=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ts),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Uw(e,t){const n={type:"string"};if(e.checks)for(const o of e.checks)switch(o.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,o.value):o.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,o.value):o.value;break;case"email":switch(t.emailStrategy){case"format:email":yt(n,"email",o.message,t);break;case"format:idn-email":yt(n,"idn-email",o.message,t);break;case"pattern:zod":qe(n,vt.email,o.message,t);break}break;case"url":yt(n,"uri",o.message,t);break;case"uuid":yt(n,"uuid",o.message,t);break;case"regex":qe(n,o.regex,o.message,t);break;case"cuid":qe(n,vt.cuid,o.message,t);break;case"cuid2":qe(n,vt.cuid2,o.message,t);break;case"startsWith":qe(n,RegExp(`^${Os(o.value,t)}`),o.message,t);break;case"endsWith":qe(n,RegExp(`${Os(o.value,t)}$`),o.message,t);break;case"datetime":yt(n,"date-time",o.message,t);break;case"date":yt(n,"date",o.message,t);break;case"time":yt(n,"time",o.message,t);break;case"duration":yt(n,"duration",o.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,o.value):o.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,o.value):o.value;break;case"includes":{qe(n,RegExp(Os(o.value,t)),o.message,t);break}case"ip":{o.version!=="v6"&&yt(n,"ipv4",o.message,t),o.version!=="v4"&&yt(n,"ipv6",o.message,t);break}case"base64url":qe(n,vt.base64url,o.message,t);break;case"jwt":qe(n,vt.jwt,o.message,t);break;case"cidr":{o.version!=="v6"&&qe(n,vt.ipv4Cidr,o.message,t),o.version!=="v4"&&qe(n,vt.ipv6Cidr,o.message,t);break}case"emoji":qe(n,vt.emoji(),o.message,t);break;case"ulid":{qe(n,vt.ulid,o.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{yt(n,"binary",o.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{qe(n,vt.base64,o.message,t);break}}break}case"nanoid":qe(n,vt.nanoid,o.message,t)}return n}function Os(e,t){return t.patternStrategy==="escape"?_j(e):e}var bj=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function _j(e){let t="";for(let n=0;n<e.length;n++)bj.has(e[n])||(t+="\\"),t+=e[n];return t}function yt(e,t,n,o){var r;e.format||(r=e.anyOf)!=null&&r.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&o.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function qe(e,t,n,o){var r;e.pattern||(r=e.allOf)!=null&&r.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Pp(t,o),...n&&o.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Pp(t,o)}function Pp(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const o={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},r=o.i?e.source.toLowerCase():e.source;let i="",a=!1,s=!1,l=!1;for(let u=0;u<r.length;u++){if(a){i+=r[u],a=!1;continue}if(o.i){if(s){if(r[u].match(/[a-z]/)){l?(i+=r[u],i+=`${r[u-2]}-${r[u]}`.toUpperCase(),l=!1):r[u+1]==="-"&&((n=r[u+2])!=null&&n.match(/[a-z]/))?(i+=r[u],l=!0):i+=`${r[u]}${r[u].toUpperCase()}`;continue}}else if(r[u].match(/[a-z]/)){i+=`[${r[u]}${r[u].toUpperCase()}]`;continue}}if(o.m){if(r[u]==="^"){i+=`(^|(?<=[\r
|
|
66
66
|
]))`;continue}else if(r[u]==="$"){i+=`($|(?=[\r
|
|
67
67
|
]))`;continue}}if(o.s&&r[u]==="."){i+=s?`${r[u]}\r
|
|
68
68
|
`:`[${r[u]}\r
|
|
69
|
-
]`;continue}i+=r[u],r[u]==="\\"?a=!0:s&&r[u]==="]"?s=!1:!s&&r[u]==="["&&(s=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Dw(e,t){var n,o,r,i,a,s;const l={type:"object",additionalProperties:(n=le(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((o=e.keyType)==null?void 0:o._def.typeName)===A.ZodString&&((r=e.keyType._def.checks)!=null&&r.length)){const{type:u,...c}=Mw(e.keyType._def,t);return{...l,propertyNames:c}}else{if(((i=e.keyType)==null?void 0:i._def.typeName)===A.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===A.ZodBranded&&e.keyType._def.type._def.typeName===A.ZodString&&((s=e.keyType._def.type._def.checks)!=null&&s.length)){const{type:u,...c}=Rw(e.keyType._def,t);return{...l,propertyNames:c}}}return l}function g1(e,t){if(t.mapStrategy==="record")return Dw(e,t);const n=le(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||tt(),o=le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||tt();return{type:"array",maxItems:125,items:{type:"array",items:[n,o],minItems:2,maxItems:2}}}function v1(e){const t=e.values,o=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),r=Array.from(new Set(o.map(i=>typeof i)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:o}}function y1(){return{not:tt()}}function b1(){return{type:"null"}}var du={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function _1(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(o=>o._def.typeName in du&&(!o._def.checks||!o._def.checks.length))){const o=n.reduce((r,i)=>{const a=du[i._def.typeName];return a&&!r.includes(a)?[...r,a]:r},[]);return{type:o.length>1?o:o[0]}}else if(n.every(o=>o._def.typeName==="ZodLiteral"&&!o.description)){const o=n.reduce((r,i)=>{const a=typeof i._def.value;switch(a){case"string":case"number":case"boolean":return[...r,a];case"bigint":return[...r,"integer"];case"object":if(i._def.value===null)return[...r,"null"];case"symbol":case"undefined":case"function":default:return r}},[]);if(o.length===n.length){const r=o.filter((i,a,s)=>s.indexOf(i)===a);return{type:r.length>1?r:r[0],enum:n.reduce((i,a)=>i.includes(a._def.value)?i:[...i,a._def.value],[])}}}else if(n.every(o=>o._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((o,r)=>[...o,...r._def.values.filter(i=>!o.includes(i))],[])};return w1(e,t)}var w1=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((o,r)=>le(o._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(o=>!!o&&(!t.strictUnions||typeof o=="object"&&Object.keys(o).length>0));return n.length?{anyOf:n}:void 0};function x1(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[du[e.innerType._def.typeName],"null"]};const n=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function $1(e){const t={type:"number"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"int":t.type="integer";break;case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function S1(e,t){const n={type:"object",properties:{}},o=[],r=e.shape();for(const a in r){let s=r[a];if(s===void 0||s._def===void 0)continue;const l=k1(s),u=le(s._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});u!==void 0&&(n.properties[a]=u,l||o.push(a))}o.length&&(n.required=o);const i=I1(e,t);return i!==void 0&&(n.additionalProperties=i),n}function I1(e,t){if(e.catchall._def.typeName!=="ZodNever")return le(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function k1(e){try{return e.isOptional()}catch{return!0}}var E1=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return le(e.innerType._def,t);const o=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return o?{anyOf:[{not:tt()},o]}:tt()},O1=(e,t)=>{if(t.pipeStrategy==="input")return le(e.in._def,t);if(t.pipeStrategy==="output")return le(e.out._def,t);const n=le(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),o=le(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,o].filter(r=>r!==void 0)}};function T1(e,t){return le(e.type._def,t)}function N1(e,t){const o={type:"array",uniqueItems:!0,items:le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(o.minItems=e.minSize.value),e.maxSize&&(o.maxItems=e.maxSize.value),o}function P1(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,o)=>le(n._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((n,o)=>o===void 0?n:[...n,o],[]),additionalItems:le(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,o)=>le(n._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((n,o)=>o===void 0?n:[...n,o],[])}}function C1(){return{not:tt()}}function j1(){return tt()}var A1=(e,t)=>le(e.innerType._def,t),R1=(e,t,n)=>{switch(t){case A.ZodString:return Mw(e,n);case A.ZodNumber:return $1(e);case A.ZodObject:return S1(e,n);case A.ZodBigInt:return o1(e);case A.ZodBoolean:return i1();case A.ZodDate:return zw(e,n);case A.ZodUndefined:return C1();case A.ZodNull:return b1();case A.ZodArray:return n1(e,n);case A.ZodUnion:case A.ZodDiscriminatedUnion:return _1(e,n);case A.ZodIntersection:return f1(e,n);case A.ZodTuple:return P1(e,n);case A.ZodRecord:return Dw(e,n);case A.ZodLiteral:return p1(e);case A.ZodEnum:return c1(e);case A.ZodNativeEnum:return v1(e);case A.ZodNullable:return x1(e,n);case A.ZodOptional:return E1(e,n);case A.ZodMap:return g1(e,n);case A.ZodSet:return N1(e,n);case A.ZodLazy:return()=>e.getter()._def;case A.ZodPromise:return T1(e,n);case A.ZodNaN:case A.ZodNever:return y1();case A.ZodEffects:return l1(e,n);case A.ZodAny:return tt();case A.ZodUnknown:return j1();case A.ZodDefault:return u1(e,n);case A.ZodBranded:return Rw(e,n);case A.ZodReadonly:return A1(e,n);case A.ZodCatch:return a1(e,n);case A.ZodPipeline:return O1(e,n);case A.ZodFunction:case A.ZodVoid:case A.ZodSymbol:return;default:return(o=>{})()}};function le(e,t,n=!1){var o;const r=t.seen.get(e);if(t.override){const l=(o=t.override)==null?void 0:o.call(t,e,t,r,n);if(l!==t1)return l}if(r&&!n){const l=z1(r,t);if(l!==void 0)return l}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const a=R1(e,e.typeName,t),s=typeof a=="function"?le(a(),t):a;if(s&&M1(e,t,s),t.postProcess){const l=t.postProcess(s,e,t);return i.jsonSchema=s,l}return i.jsonSchema=s,s}var z1=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:e1(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,o)=>t.currentPath[o]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),tt()):t.$refStrategy==="seen"?tt():void 0}},M1=(e,t,n)=>(e.description&&(n.description=e.description),n),D1=e=>{const t=r1(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([o,r])=>[r._def,{def:r._def,path:[...t.basePath,t.definitionPath,o],jsonSchema:void 0}]))}},U1=(e,t)=>{var n;const o=D1(t);let r=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,d])=>{var p;return{...u,[c]:(p=le(d._def,{...o,currentPath:[...o.basePath,o.definitionPath,c]},!0))!=null?p:tt()}},{}):void 0;const i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=(n=le(e._def,i===void 0?o:{...o,currentPath:[...o.basePath,o.definitionPath,i]},!1))!=null?n:tt(),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(a.title=s);const l=i===void 0?r?{...a,[o.definitionPath]:r}:a:{$ref:[...o.$refStrategy==="relative"?[]:o.basePath,o.definitionPath,i].join("/"),[o.definitionPath]:{...r,[i]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},L1=U1;function Z1(e,t){var n;const o=(n=void 0)!=null?n:!1;return Rc(()=>L1(e,{$refStrategy:o?"root":"none"}),{validate:async r=>{const i=await e.safeParseAsync(r);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function F1(e,t){var n;const o=(n=void 0)!=null?n:!1;return Rc(()=>ua(e,{target:"draft-7",io:"output",reused:o?"ref":"inline"}),{validate:async r=>{const i=await la(e,r);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function q1(e){return"_zod"in e}function Or(e,t){return q1(e)?F1(e):Z1(e)}var fu=Symbol.for("vercel.ai.schema");function Rc(e,{validate:t}={}){return{[fu]:!0,_type:void 0,[Si]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function V1(e){return typeof e=="object"&&e!==null&&fu in e&&e[fu]===!0&&"jsonSchema"in e&&"validate"in e}function Za(e){return e==null?Rc({properties:{},additionalProperties:!1}):V1(e)?e:typeof e=="function"?e():Or(e)}var{btoa:B1,atob:J1}=globalThis;function zc(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=J1(t);return Uint8Array.from(n,o=>o.codePointAt(0))}function pu(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return B1(t)}function W1(e){return e?.replace(/\/$/,"")}function H1(e){return e!=null&&typeof e[Symbol.asyncIterator]=="function"}async function*G1({execute:e,input:t,options:n}){const o=e(t,n);if(H1(o)){let r;for await(const i of o)r=i,yield{type:"preliminary",output:i};yield{type:"final",output:r}}else yield{type:"final",output:await o}}var Es,Pf;function K1(){if(Pf)return Es;Pf=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r=(c,d)=>{for(var p in d)e(c,p,{get:d[p],enumerable:!0})},i=(c,d,p,f)=>{if(d&&typeof d=="object"||typeof d=="function")for(let g of n(d))!o.call(c,g)&&g!==p&&e(c,g,{get:()=>d[g],enumerable:!(f=t(d,g))||f.enumerable});return c},a=c=>i(e({},"__esModule",{value:!0}),c),s={};r(s,{SYMBOL_FOR_REQ_CONTEXT:()=>l,getContext:()=>u}),Es=a(s);const l=Symbol.for("@vercel/request-context");function u(){return globalThis[l]?.get?.()??{}}return Es}var Os,Cf;function Y1(){if(Cf)return Os;Cf=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r=(d,p)=>{for(var f in p)e(d,f,{get:p[f],enumerable:!0})},i=(d,p,f,g)=>{if(p&&typeof p=="object"||typeof p=="function")for(let m of n(p))!o.call(d,m)&&m!==f&&e(d,m,{get:()=>p[m],enumerable:!(g=t(p,m))||g.enumerable});return d},a=d=>i(e({},"__esModule",{value:!0}),d),s={};r(s,{getContext:()=>l.getContext,getVercelOidcToken:()=>u,getVercelOidcTokenSync:()=>c}),Os=a(s);var l=K1();async function u(){return""}function c(){return""}return Os}var Uw=Y1(),Q1="vercel.ai.gateway.error",Ts=Symbol.for(Q1),jf,Af,rt=class Lw extends(Af=Error,jf=Ts,Af){constructor({message:t,statusCode:n=500,cause:o}){super(t),this[jf]=!0,this.statusCode=n,this.cause=o}static isInstance(t){return Lw.hasMarker(t)}static hasMarker(t){return typeof t=="object"&&t!==null&&Ts in t&&t[Ts]===!0}},Zw="GatewayAuthenticationError",X1=`vercel.ai.gateway.error.${Zw}`,Rf=Symbol.for(X1),zf,Mf,Mc=class Fw extends(Mf=rt,zf=Rf,Mf){constructor({message:t="Authentication failed",statusCode:n=401,cause:o}={}){super({message:t,statusCode:n,cause:o}),this[zf]=!0,this.name=Zw,this.type="authentication_error"}static isInstance(t){return rt.hasMarker(t)&&Rf in t}static createContextualError({apiKeyProvided:t,oidcTokenProvided:n,message:o="Authentication failed",statusCode:r=401,cause:i}){let a;return t?a=`AI Gateway authentication failed: Invalid API key.
|
|
69
|
+
]`;continue}i+=r[u],r[u]==="\\"?a=!0:s&&r[u]==="]"?s=!1:!s&&r[u]==="["&&(s=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Lw(e,t){var n,o,r,i,a,s;const l={type:"object",additionalProperties:(n=le(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((o=e.keyType)==null?void 0:o._def.typeName)===A.ZodString&&((r=e.keyType._def.checks)!=null&&r.length)){const{type:u,...c}=Uw(e.keyType._def,t);return{...l,propertyNames:c}}else{if(((i=e.keyType)==null?void 0:i._def.typeName)===A.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===A.ZodBranded&&e.keyType._def.type._def.typeName===A.ZodString&&((s=e.keyType._def.type._def.checks)!=null&&s.length)){const{type:u,...c}=Mw(e.keyType._def,t);return{...l,propertyNames:c}}}return l}function wj(e,t){if(t.mapStrategy==="record")return Lw(e,t);const n=le(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||tt(),o=le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||tt();return{type:"array",maxItems:125,items:{type:"array",items:[n,o],minItems:2,maxItems:2}}}function xj(e){const t=e.values,o=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),r=Array.from(new Set(o.map(i=>typeof i)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:o}}function $j(){return{not:tt()}}function Sj(){return{type:"null"}}var hu={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Ij(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(o=>o._def.typeName in hu&&(!o._def.checks||!o._def.checks.length))){const o=n.reduce((r,i)=>{const a=hu[i._def.typeName];return a&&!r.includes(a)?[...r,a]:r},[]);return{type:o.length>1?o:o[0]}}else if(n.every(o=>o._def.typeName==="ZodLiteral"&&!o.description)){const o=n.reduce((r,i)=>{const a=typeof i._def.value;switch(a){case"string":case"number":case"boolean":return[...r,a];case"bigint":return[...r,"integer"];case"object":if(i._def.value===null)return[...r,"null"];case"symbol":case"undefined":case"function":default:return r}},[]);if(o.length===n.length){const r=o.filter((i,a,s)=>s.indexOf(i)===a);return{type:r.length>1?r:r[0],enum:n.reduce((i,a)=>i.includes(a._def.value)?i:[...i,a._def.value],[])}}}else if(n.every(o=>o._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((o,r)=>[...o,...r._def.values.filter(i=>!o.includes(i))],[])};return kj(e,t)}var kj=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((o,r)=>le(o._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(o=>!!o&&(!t.strictUnions||typeof o=="object"&&Object.keys(o).length>0));return n.length?{anyOf:n}:void 0};function Ej(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[hu[e.innerType._def.typeName],"null"]};const n=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function Tj(e){const t={type:"number"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"int":t.type="integer";break;case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function Oj(e,t){const n={type:"object",properties:{}},o=[],r=e.shape();for(const a in r){let s=r[a];if(s===void 0||s._def===void 0)continue;const l=Pj(s),u=le(s._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});u!==void 0&&(n.properties[a]=u,l||o.push(a))}o.length&&(n.required=o);const i=Nj(e,t);return i!==void 0&&(n.additionalProperties=i),n}function Nj(e,t){if(e.catchall._def.typeName!=="ZodNever")return le(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function Pj(e){try{return e.isOptional()}catch{return!0}}var Cj=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return le(e.innerType._def,t);const o=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return o?{anyOf:[{not:tt()},o]}:tt()},jj=(e,t)=>{if(t.pipeStrategy==="input")return le(e.in._def,t);if(t.pipeStrategy==="output")return le(e.out._def,t);const n=le(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),o=le(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,o].filter(r=>r!==void 0)}};function Aj(e,t){return le(e.type._def,t)}function Rj(e,t){const o={type:"array",uniqueItems:!0,items:le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(o.minItems=e.minSize.value),e.maxSize&&(o.maxItems=e.maxSize.value),o}function zj(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,o)=>le(n._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((n,o)=>o===void 0?n:[...n,o],[]),additionalItems:le(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,o)=>le(n._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((n,o)=>o===void 0?n:[...n,o],[])}}function Mj(){return{not:tt()}}function Dj(){return tt()}var Uj=(e,t)=>le(e.innerType._def,t),Lj=(e,t,n)=>{switch(t){case A.ZodString:return Uw(e,n);case A.ZodNumber:return Tj(e);case A.ZodObject:return Oj(e,n);case A.ZodBigInt:return lj(e);case A.ZodBoolean:return cj();case A.ZodDate:return Dw(e,n);case A.ZodUndefined:return Mj();case A.ZodNull:return Sj();case A.ZodArray:return uj(e,n);case A.ZodUnion:case A.ZodDiscriminatedUnion:return Ij(e,n);case A.ZodIntersection:return vj(e,n);case A.ZodTuple:return zj(e,n);case A.ZodRecord:return Lw(e,n);case A.ZodLiteral:return yj(e);case A.ZodEnum:return hj(e);case A.ZodNativeEnum:return xj(e);case A.ZodNullable:return Ej(e,n);case A.ZodOptional:return Cj(e,n);case A.ZodMap:return wj(e,n);case A.ZodSet:return Rj(e,n);case A.ZodLazy:return()=>e.getter()._def;case A.ZodPromise:return Aj(e,n);case A.ZodNaN:case A.ZodNever:return $j();case A.ZodEffects:return mj(e,n);case A.ZodAny:return tt();case A.ZodUnknown:return Dj();case A.ZodDefault:return fj(e,n);case A.ZodBranded:return Mw(e,n);case A.ZodReadonly:return Uj(e,n);case A.ZodCatch:return dj(e,n);case A.ZodPipeline:return jj(e,n);case A.ZodFunction:case A.ZodVoid:case A.ZodSymbol:return;default:return(o=>{})()}};function le(e,t,n=!1){var o;const r=t.seen.get(e);if(t.override){const l=(o=t.override)==null?void 0:o.call(t,e,t,r,n);if(l!==aj)return l}if(r&&!n){const l=Zj(r,t);if(l!==void 0)return l}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const a=Lj(e,e.typeName,t),s=typeof a=="function"?le(a(),t):a;if(s&&Fj(e,t,s),t.postProcess){const l=t.postProcess(s,e,t);return i.jsonSchema=s,l}return i.jsonSchema=s,s}var Zj=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:ij(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,o)=>t.currentPath[o]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),tt()):t.$refStrategy==="seen"?tt():void 0}},Fj=(e,t,n)=>(e.description&&(n.description=e.description),n),qj=e=>{const t=sj(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([o,r])=>[r._def,{def:r._def,path:[...t.basePath,t.definitionPath,o],jsonSchema:void 0}]))}},Vj=(e,t)=>{var n;const o=qj(t);let r=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,d])=>{var f;return{...u,[c]:(f=le(d._def,{...o,currentPath:[...o.basePath,o.definitionPath,c]},!0))!=null?f:tt()}},{}):void 0;const i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=(n=le(e._def,i===void 0?o:{...o,currentPath:[...o.basePath,o.definitionPath,i]},!1))!=null?n:tt(),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(a.title=s);const l=i===void 0?r?{...a,[o.definitionPath]:r}:a:{$ref:[...o.$refStrategy==="relative"?[]:o.basePath,o.definitionPath,i].join("/"),[o.definitionPath]:{...r,[i]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},Bj=Vj;function Jj(e,t){var n;const o=(n=void 0)!=null?n:!1;return Mc(()=>Bj(e,{$refStrategy:o?"root":"none"}),{validate:async r=>{const i=await e.safeParseAsync(r);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function Wj(e,t){var n;const o=(n=void 0)!=null?n:!1;return Mc(()=>da(e,{target:"draft-7",io:"output",reused:o?"ref":"inline"}),{validate:async r=>{const i=await pa(e,r);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function Hj(e){return"_zod"in e}function Or(e,t){return Hj(e)?Wj(e):Jj(e)}var gu=Symbol.for("vercel.ai.schema");function Mc(e,{validate:t}={}){return{[gu]:!0,_type:void 0,[ki]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function Gj(e){return typeof e=="object"&&e!==null&&gu in e&&e[gu]===!0&&"jsonSchema"in e&&"validate"in e}function Va(e){return e==null?Mc({properties:{},additionalProperties:!1}):Gj(e)?e:typeof e=="function"?e():Or(e)}var{btoa:Kj,atob:Yj}=globalThis;function Dc(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=Yj(t);return Uint8Array.from(n,o=>o.codePointAt(0))}function vu(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return Kj(t)}function Qj(e){return e?.replace(/\/$/,"")}function Xj(e){return e!=null&&typeof e[Symbol.asyncIterator]=="function"}async function*e1({execute:e,input:t,options:n}){const o=e(t,n);if(Xj(o)){let r;for await(const i of o)r=i,yield{type:"preliminary",output:i};yield{type:"final",output:r}}else yield{type:"final",output:await o}}var Ns,Cp;function t1(){if(Cp)return Ns;Cp=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r=(c,d)=>{for(var f in d)e(c,f,{get:d[f],enumerable:!0})},i=(c,d,f,p)=>{if(d&&typeof d=="object"||typeof d=="function")for(let g of n(d))!o.call(c,g)&&g!==f&&e(c,g,{get:()=>d[g],enumerable:!(p=t(d,g))||p.enumerable});return c},a=c=>i(e({},"__esModule",{value:!0}),c),s={};r(s,{SYMBOL_FOR_REQ_CONTEXT:()=>l,getContext:()=>u}),Ns=a(s);const l=Symbol.for("@vercel/request-context");function u(){return globalThis[l]?.get?.()??{}}return Ns}var Ps,jp;function r1(){if(jp)return Ps;jp=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r=(d,f)=>{for(var p in f)e(d,p,{get:f[p],enumerable:!0})},i=(d,f,p,g)=>{if(f&&typeof f=="object"||typeof f=="function")for(let h of n(f))!o.call(d,h)&&h!==p&&e(d,h,{get:()=>f[h],enumerable:!(g=t(f,h))||g.enumerable});return d},a=d=>i(e({},"__esModule",{value:!0}),d),s={};r(s,{getContext:()=>l.getContext,getVercelOidcToken:()=>u,getVercelOidcTokenSync:()=>c}),Ps=a(s);var l=t1();async function u(){return""}function c(){return""}return Ps}var Zw=r1(),n1="vercel.ai.gateway.error",Cs=Symbol.for(n1),Ap,Rp,rt=class Fw extends(Rp=Error,Ap=Cs,Rp){constructor({message:t,statusCode:n=500,cause:o}){super(t),this[Ap]=!0,this.statusCode=n,this.cause=o}static isInstance(t){return Fw.hasMarker(t)}static hasMarker(t){return typeof t=="object"&&t!==null&&Cs in t&&t[Cs]===!0}},qw="GatewayAuthenticationError",o1=`vercel.ai.gateway.error.${qw}`,zp=Symbol.for(o1),Mp,Dp,Uc=class Vw extends(Dp=rt,Mp=zp,Dp){constructor({message:t="Authentication failed",statusCode:n=401,cause:o}={}){super({message:t,statusCode:n,cause:o}),this[Mp]=!0,this.name=qw,this.type="authentication_error"}static isInstance(t){return rt.hasMarker(t)&&zp in t}static createContextualError({apiKeyProvided:t,oidcTokenProvided:n,message:o="Authentication failed",statusCode:r=401,cause:i}){let a;return t?a=`AI Gateway authentication failed: Invalid API key.
|
|
70
70
|
|
|
71
71
|
Create a new API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
72
72
|
|
|
@@ -81,27 +81,24 @@ Create an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
|
81
81
|
Provide via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.
|
|
82
82
|
|
|
83
83
|
Option 2 - OIDC token:
|
|
84
|
-
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,new Fw({message:a,statusCode:r,cause:i})}},qw="GatewayInvalidRequestError",ej=`vercel.ai.gateway.error.${qw}`,Df=Symbol.for(ej),Uf,Lf,tj=class extends(Lf=rt,Uf=Df,Lf){constructor({message:e="Invalid request",statusCode:t=400,cause:n}={}){super({message:e,statusCode:t,cause:n}),this[Uf]=!0,this.name=qw,this.type="invalid_request_error"}static isInstance(e){return rt.hasMarker(e)&&Df in e}},Vw="GatewayRateLimitError",rj=`vercel.ai.gateway.error.${Vw}`,Zf=Symbol.for(rj),Ff,qf,nj=class extends(qf=rt,Ff=Zf,qf){constructor({message:e="Rate limit exceeded",statusCode:t=429,cause:n}={}){super({message:e,statusCode:t,cause:n}),this[Ff]=!0,this.name=Vw,this.type="rate_limit_exceeded"}static isInstance(e){return rt.hasMarker(e)&&Zf in e}},Bw="GatewayModelNotFoundError",oj=`vercel.ai.gateway.error.${Bw}`,Vf=Symbol.for(oj),ij=un(()=>Or(E({modelId:w()}))),Bf,Jf,Jw=class extends(Jf=rt,Bf=Vf,Jf){constructor({message:e="Model not found",statusCode:t=404,modelId:n,cause:o}={}){super({message:e,statusCode:t,cause:o}),this[Bf]=!0,this.name=Bw,this.type="model_not_found",this.modelId=n}static isInstance(e){return rt.hasMarker(e)&&Vf in e}},Ww="GatewayInternalServerError",aj=`vercel.ai.gateway.error.${Ww}`,Wf=Symbol.for(aj),Hf,Gf,Kf=class extends(Gf=rt,Hf=Wf,Gf){constructor({message:e="Internal server error",statusCode:t=500,cause:n}={}){super({message:e,statusCode:t,cause:n}),this[Hf]=!0,this.name=Ww,this.type="internal_server_error"}static isInstance(e){return rt.hasMarker(e)&&Wf in e}},Hw="GatewayResponseError",sj=`vercel.ai.gateway.error.${Hw}`,Yf=Symbol.for(sj),Qf,Xf,uj=class extends(Xf=rt,Qf=Yf,Xf){constructor({message:e="Invalid response from Gateway",statusCode:t=502,response:n,validationError:o,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[Qf]=!0,this.name=Hw,this.type="response_error",this.response=n,this.validationError=o}static isInstance(e){return rt.hasMarker(e)&&Yf in e}};async function ep({response:e,statusCode:t,defaultMessage:n="Gateway request failed",cause:o,authMethod:r}){const i=await ar({value:e,schema:lj});if(!i.success)return new uj({message:`Invalid error response format: ${n}`,statusCode:t,response:e,validationError:i.error,cause:o});const a=i.value,s=a.error.type,l=a.error.message;switch(s){case"authentication_error":return Mc.createContextualError({apiKeyProvided:r==="api-key",oidcTokenProvided:r==="oidc",statusCode:t,cause:o});case"invalid_request_error":return new tj({message:l,statusCode:t,cause:o});case"rate_limit_exceeded":return new nj({message:l,statusCode:t,cause:o});case"model_not_found":{const u=await ar({value:a.error.param,schema:ij});return new Jw({message:l,statusCode:t,modelId:u.success?u.value.modelId:void 0,cause:o})}case"internal_server_error":return new Kf({message:l,statusCode:t,cause:o});default:return new Kf({message:l,statusCode:t,cause:o})}}var lj=un(()=>Or(E({error:E({message:w(),type:w().nullish(),param:$e().nullish(),code:W([w(),q()]).nullish()})})));function wr(e,t){var n;return rt.isInstance(e)?e:Be.isInstance(e)?ep({response:cj(e),statusCode:(n=e.statusCode)!=null?n:500,defaultMessage:"Gateway request failed",cause:e,authMethod:t}):ep({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:"Unknown Gateway error",cause:e,authMethod:t})}function cj(e){if(e.data!==void 0)return e.data;if(e.responseBody!=null)try{return JSON.parse(e.responseBody)}catch{return e.responseBody}return{}}var Gw="ai-gateway-auth-method";async function Bn(e){const t=await ar({value:e[Gw],schema:dj});return t.success?t.value:void 0}var dj=un(()=>Or(W([C("api-key"),C("oidc")]))),tp=class{constructor(e){this.config=e}async getAvailableModels(){try{const{value:e}=await Of({url:`${this.config.baseURL}/config`,headers:await rr(this.config.headers()),successfulResponseHandler:Ii(fj),failedResponseHandler:Vn({errorSchema:Pe(),errorToMessage:t=>t}),fetch:this.config.fetch});return e}catch(e){throw await wr(e)}}async getCredits(){try{const e=new URL(this.config.baseURL),{value:t}=await Of({url:`${e.origin}/v1/credits`,headers:await rr(this.config.headers()),successfulResponseHandler:Ii(pj),failedResponseHandler:Vn({errorSchema:Pe(),errorToMessage:n=>n}),fetch:this.config.fetch});return t}catch(e){throw await wr(e)}}},fj=un(()=>Or(E({models:R(E({id:w(),name:w(),description:w().nullish(),pricing:E({input:w(),output:w(),input_cache_read:w().nullish(),input_cache_write:w().nullish()}).transform(({input:e,output:t,input_cache_read:n,input_cache_write:o})=>({input:e,output:t,...n?{cachedInputTokens:n}:{},...o?{cacheCreationInputTokens:o}:{}})).nullish(),specification:E({specificationVersion:C("v2"),provider:w(),modelId:w()}),modelType:cr(["language","embedding","image"]).nullish()}))}))),pj=un(()=>Or(E({balance:w(),total_used:w()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t})))),mj=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v2",this.supportedUrls={"*/*":[/.*/]}}get provider(){return this.config.provider}async getArgs(e){const{abortSignal:t,...n}=e;return{args:this.maybeEncodeFileParts(n),warnings:[]}}async doGenerate(e){const{args:t,warnings:n}=await this.getArgs(e),{abortSignal:o}=e,r=await rr(this.config.headers());try{const{responseHeaders:i,value:a,rawValue:s}=await cu({url:this.getUrl(),headers:uu(r,e.headers,this.getModelConfigHeaders(this.modelId,!1),await rr(this.config.o11yHeaders)),body:t,successfulResponseHandler:Ii(Pe()),failedResponseHandler:Vn({errorSchema:Pe(),errorToMessage:l=>l}),...o&&{abortSignal:o},fetch:this.config.fetch});return{...a,request:{body:t},response:{headers:i,body:s},warnings:n}}catch(i){throw await wr(i,await Bn(r))}}async doStream(e){const{args:t,warnings:n}=await this.getArgs(e),{abortSignal:o}=e,r=await rr(this.config.headers());try{const{value:i,responseHeaders:a}=await cu({url:this.getUrl(),headers:uu(r,e.headers,this.getModelConfigHeaders(this.modelId,!0),await rr(this.config.o11yHeaders)),body:t,successfulResponseHandler:XC(Pe()),failedResponseHandler:Vn({errorSchema:Pe(),errorToMessage:s=>s}),...o&&{abortSignal:o},fetch:this.config.fetch});return{stream:i.pipeThrough(new TransformStream({start(s){n.length>0&&s.enqueue({type:"stream-start",warnings:n})},transform(s,l){if(s.success){const u=s.value;if(u.type==="raw"&&!e.includeRawChunks)return;u.type==="response-metadata"&&u.timestamp&&typeof u.timestamp=="string"&&(u.timestamp=new Date(u.timestamp)),l.enqueue(u)}else l.error(s.error)}})),request:{body:t},response:{headers:a}}}catch(i){throw await wr(i,await Bn(r))}}isFilePart(e){return e&&typeof e=="object"&&"type"in e&&e.type==="file"}maybeEncodeFileParts(e){for(const t of e.prompt)for(const n of t.content)if(this.isFilePart(n)){const o=n;if(o.data instanceof Uint8Array){const r=Uint8Array.from(o.data),i=Buffer.from(r).toString("base64");o.data=new URL(`data:${o.mediaType||"application/octet-stream"};base64,${i}`)}}return e}getUrl(){return`${this.config.baseURL}/language-model`}getModelConfigHeaders(e,t){return{"ai-language-model-specification-version":"2","ai-language-model-id":e,"ai-language-model-streaming":String(t)}}},hj=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v2",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0}get provider(){return this.config.provider}async doEmbed({values:e,headers:t,abortSignal:n,providerOptions:o}){var r;const i=await rr(this.config.headers());try{const{responseHeaders:a,value:s,rawValue:l}=await cu({url:this.getUrl(),headers:uu(i,t??{},this.getModelConfigHeaders(),await rr(this.config.o11yHeaders)),body:{input:e.length===1?e[0]:e,...o?{providerOptions:o}:{}},successfulResponseHandler:Ii(gj),failedResponseHandler:Vn({errorSchema:Pe(),errorToMessage:u=>u}),...n&&{abortSignal:n},fetch:this.config.fetch});return{embeddings:s.embeddings,usage:(r=s.usage)!=null?r:void 0,providerMetadata:s.providerMetadata,response:{headers:a,body:l}}}catch(a){throw await wr(a,await Bn(i))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":"2","ai-model-id":this.modelId}}},gj=un(()=>Or(E({embeddings:R(R(q())),usage:E({tokens:q()}).nullish(),providerMetadata:Xe(w(),Xe(w(),$e())).optional()})));async function vj(){var e;return(e=Uw.getContext().headers)==null?void 0:e["x-vercel-id"]}var yj="2.0.7",bj="0.0.1";function _j(e={}){var t,n;let o=null,r=null;const i=(t=e.metadataCacheRefreshMillis)!=null?t:1e3*60*5;let a=0;const s=(n=W1(e.baseURL))!=null?n:"https://ai-gateway.vercel.sh/v1/ai",l=async()=>{const g=await xj(e);if(g)return La({Authorization:`Bearer ${g.token}`,"ai-gateway-protocol-version":bj,[Gw]:g.authMethod,...e.headers},`ai-sdk/gateway/${yj}`);throw Mc.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401})},u=()=>{const g=oi({settingValue:void 0,environmentVariableName:"VERCEL_DEPLOYMENT_ID"}),m=oi({settingValue:void 0,environmentVariableName:"VERCEL_ENV"}),b=oi({settingValue:void 0,environmentVariableName:"VERCEL_REGION"});return async()=>{const y=await vj();return{...g&&{"ai-o11y-deployment-id":g},...m&&{"ai-o11y-environment":m},...b&&{"ai-o11y-region":b},...y&&{"ai-o11y-request-id":y}}}},c=g=>new mj(g,{provider:"gateway",baseURL:s,headers:l,fetch:e.fetch,o11yHeaders:u()}),d=async()=>{var g,m,b;const y=(b=(m=(g=e._internal)==null?void 0:g.currentDate)==null?void 0:m.call(g).getTime())!=null?b:Date.now();return(!o||y-a>i)&&(a=y,o=new tp({baseURL:s,headers:l,fetch:e.fetch}).getAvailableModels().then(x=>(r=x,x)).catch(async x=>{throw await wr(x,await Bn(await l()))})),r?Promise.resolve(r):o},p=async()=>new tp({baseURL:s,headers:l,fetch:e.fetch}).getCredits().catch(async g=>{throw await wr(g,await Bn(await l()))}),f=function(g){if(new.target)throw new Error("The Gateway Provider model function cannot be called with the new keyword.");return c(g)};return f.getAvailableModels=d,f.getCredits=p,f.imageModel=g=>{throw new cI({modelId:g,modelType:"imageModel"})},f.languageModel=c,f.textEmbeddingModel=g=>new hj(g,{provider:"gateway",baseURL:s,headers:l,fetch:e.fetch,o11yHeaders:u()}),f}var wj=_j();async function xj(e){const t=oi({settingValue:e.apiKey,environmentVariableName:"AI_GATEWAY_API_KEY"});if(t)return{token:t,authMethod:"api-key"};try{return{token:await Uw.getVercelOidcToken(),authMethod:"oidc"}}catch{return null}}var $j=Object.defineProperty,Sj=(e,t)=>{for(var n in t)$j(e,n,{get:t[n],enumerable:!0})},Kw="AI_NoOutputSpecifiedError",Yw=`vercel.ai.error.${Kw}`,Ij=Symbol.for(Yw),Qw,kj=class extends Y{constructor({message:e="No output specified."}={}){super({name:Kw,message:e}),this[Qw]=!0}static isInstance(e){return Y.hasMarker(e,Yw)}};Qw=Ij;function Ej(e){const t="AI SDK Warning:";switch(e.type){case"unsupported-setting":{let n=`${t} The "${e.setting}" setting is not supported by this model`;return e.details&&(n+=` - ${e.details}`),n}case"unsupported-tool":{const n="name"in e.tool?e.tool.name:"unknown tool";let o=`${t} The tool "${n}" is not supported by this model`;return e.details&&(o+=` - ${e.details}`),o}case"other":return`${t} ${e.message}`;default:return`${t} ${JSON.stringify(e,null,2)}`}}var Oj="AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.",rp=!1,Tj=e=>{if(e.length===0)return;const t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t=="function"){t(e);return}rp||(rp=!0,console.info(Oj));for(const n of e)console.warn(Ej(n))}},Xw="AI_InvalidArgumentError",ex=`vercel.ai.error.${Xw}`,Nj=Symbol.for(ex),tx,Nt=class extends Y{constructor({parameter:e,value:t,message:n}){super({name:Xw,message:`Invalid argument for parameter ${e}: ${n}`}),this[tx]=!0,this.parameter=e,this.value=t}static isInstance(e){return Y.hasMarker(e,ex)}};tx=Nj;var rx="AI_InvalidToolInputError",nx=`vercel.ai.error.${rx}`,Pj=Symbol.for(nx),ox,ix=class extends Y{constructor({toolInput:e,toolName:t,cause:n,message:o=`Invalid input for tool ${t}: ${an(n)}`}){super({name:rx,message:o,cause:n}),this[ox]=!0,this.toolInput=e,this.toolName=t}static isInstance(e){return Y.hasMarker(e,nx)}};ox=Pj;var ax="AI_NoObjectGeneratedError",sx=`vercel.ai.error.${ax}`,Cj=Symbol.for(sx),ux,np=class extends Y{constructor({message:e="No object generated.",cause:t,text:n,response:o,usage:r,finishReason:i}){super({name:ax,message:e,cause:t}),this[ux]=!0,this.text=n,this.response=o,this.usage=r,this.finishReason=i}static isInstance(e){return Y.hasMarker(e,sx)}};ux=Cj;var lx="AI_NoOutputGeneratedError",cx=`vercel.ai.error.${lx}`,jj=Symbol.for(cx),dx,Aj=class extends Y{constructor({message:e="No output generated.",cause:t}={}){super({name:lx,message:e,cause:t}),this[dx]=!0}static isInstance(e){return Y.hasMarker(e,cx)}};dx=jj;var fx="AI_NoSuchToolError",px=`vercel.ai.error.${fx}`,Rj=Symbol.for(px),mx,mu=class extends Y{constructor({toolName:e,availableTools:t=void 0,message:n=`Model tried to call unavailable tool '${e}'. ${t===void 0?"No tools are available.":`Available tools: ${t.join(", ")}.`}`}){super({name:fx,message:n}),this[mx]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return Y.hasMarker(e,px)}};mx=Rj;var hx="AI_ToolCallRepairError",gx=`vercel.ai.error.${hx}`,zj=Symbol.for(gx),vx,Mj=class extends Y{constructor({cause:e,originalError:t,message:n=`Error repairing tool call: ${an(e)}`}){super({name:hx,message:n,cause:e}),this[vx]=!0,this.originalError=t}static isInstance(e){return Y.hasMarker(e,gx)}};vx=zj;var Dj=class extends Y{constructor(e){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${e.version} for provider "${e.provider}" and model "${e.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=e.version,this.provider=e.provider,this.modelId=e.modelId}},yx="AI_InvalidMessageRoleError",bx=`vercel.ai.error.${yx}`,Uj=Symbol.for(bx),_x,Lj=class extends Y{constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:yx,message:t}),this[_x]=!0,this.role=e}static isInstance(e){return Y.hasMarker(e,bx)}};_x=Uj;var wx="AI_MessageConversionError",xx=`vercel.ai.error.${wx}`,Zj=Symbol.for(xx),$x,Fj=class extends Y{constructor({originalMessage:e,message:t}){super({name:wx,message:t}),this[$x]=!0,this.originalMessage=e}static isInstance(e){return Y.hasMarker(e,xx)}};$x=Zj;var Sx="AI_DownloadError",Ix=`vercel.ai.error.${Sx}`,qj=Symbol.for(Ix),kx,Ns=class extends Y{constructor({url:e,statusCode:t,statusText:n,cause:o,message:r=o==null?`Failed to download ${e}: ${t} ${n}`:`Failed to download ${e}: ${o}`}){super({name:Sx,message:r,cause:o}),this[kx]=!0,this.url=e,this.statusCode=t,this.statusText=n}static isInstance(e){return Y.hasMarker(e,Ix)}};kx=qj;var Ex="AI_RetryError",Ox=`vercel.ai.error.${Ex}`,Vj=Symbol.for(Ox),Tx,op=class extends Y{constructor({message:e,reason:t,errors:n}){super({name:Ex,message:e}),this[Tx]=!0,this.reason=t,this.errors=n,this.lastError=n[n.length-1]}static isInstance(e){return Y.hasMarker(e,Ox)}};Tx=Vj;function Nx(e){if(typeof e!="string"){if(e.specificationVersion!=="v2")throw new Dj({version:e.specificationVersion,provider:e.provider,modelId:e.modelId});return e}return Bj().languageModel(e)}function Bj(){var e;return(e=globalThis.AI_SDK_DEFAULT_PROVIDER)!=null?e:wj}var Jj=[{mediaType:"image/gif",bytesPrefix:[71,73,70]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],Wj=e=>{const t=typeof e=="string"?zc(e):e,n=(t[6]&127)<<21|(t[7]&127)<<14|(t[8]&127)<<7|t[9]&127;return t.slice(n+10)};function Hj(e){return typeof e=="string"&&e.startsWith("SUQz")||typeof e!="string"&&e.length>10&&e[0]===73&&e[1]===68&&e[2]===51?Wj(e):e}function Gj({data:e,signatures:t}){const n=Hj(e),o=typeof n=="string"?zc(n.substring(0,Math.min(n.length,24))):n;for(const r of t)if(o.length>=r.bytesPrefix.length&&r.bytesPrefix.every((i,a)=>i===null||o[a]===i))return r.mediaType}var Kj="5.0.90",Yj=async({url:e})=>{var t;const n=e.toString();try{const o=await fetch(n,{headers:La({},`ai-sdk/${Kj}`,Ac())});if(!o.ok)throw new Ns({url:n,statusCode:o.status,statusText:o.statusText});return{data:new Uint8Array(await o.arrayBuffer()),mediaType:(t=o.headers.get("content-type"))!=null?t:void 0}}catch(o){throw Ns.isInstance(o)?o:new Ns({url:n,cause:o})}},Qj=(e=Yj)=>t=>Promise.all(t.map(async n=>n.isUrlSupportedByModel?null:e(n)));function Xj(e){try{const[t,n]=e.split(",");return{mediaType:t.split(";")[0].split(":")[1],base64Content:n}}catch{return{mediaType:void 0,base64Content:void 0}}}var Px=W([w(),zt(Uint8Array),zt(ArrayBuffer),So(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]);function Cx(e){if(e instanceof Uint8Array)return{data:e,mediaType:void 0};if(e instanceof ArrayBuffer)return{data:new Uint8Array(e),mediaType:void 0};if(typeof e=="string")try{e=new URL(e)}catch{}if(e instanceof URL&&e.protocol==="data:"){const{mediaType:t,base64Content:n}=Xj(e.toString());if(t==null||n==null)throw new Y({name:"InvalidDataContentError",message:`Invalid data URL format in content ${e.toString()}`});return{data:n,mediaType:t}}return{data:e,mediaType:void 0}}function eA(e){return typeof e=="string"?e:e instanceof ArrayBuffer?pu(new Uint8Array(e)):pu(e)}async function tA({prompt:e,supportedUrls:t,download:n=Qj()}){const o=await nA(e.messages,n,t);return[...e.system!=null?[{role:"system",content:e.system}]:[],...e.messages.map(r=>rA({message:r,downloadedAssets:o}))]}function rA({message:e,downloadedAssets:t}){const n=e.role;switch(n){case"system":return{role:"system",content:e.content,providerOptions:e.providerOptions};case"user":return typeof e.content=="string"?{role:"user",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions}:{role:"user",content:e.content.map(o=>oA(o,t)).filter(o=>o.type!=="text"||o.text!==""),providerOptions:e.providerOptions};case"assistant":return typeof e.content=="string"?{role:"assistant",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions}:{role:"assistant",content:e.content.filter(o=>o.type!=="text"||o.text!==""||o.providerOptions!=null).map(o=>{const r=o.providerOptions;switch(o.type){case"file":{const{data:i,mediaType:a}=Cx(o.data);return{type:"file",data:i,filename:o.filename,mediaType:a??o.mediaType,providerOptions:r}}case"reasoning":return{type:"reasoning",text:o.text,providerOptions:r};case"text":return{type:"text",text:o.text,providerOptions:r};case"tool-call":return{type:"tool-call",toolCallId:o.toolCallId,toolName:o.toolName,input:o.input,providerExecuted:o.providerExecuted,providerOptions:r};case"tool-result":return{type:"tool-result",toolCallId:o.toolCallId,toolName:o.toolName,output:o.output,providerOptions:r}}}),providerOptions:e.providerOptions};case"tool":return{role:"tool",content:e.content.map(o=>({type:"tool-result",toolCallId:o.toolCallId,toolName:o.toolName,output:o.output,providerOptions:o.providerOptions})),providerOptions:e.providerOptions};default:{const o=n;throw new Lj({role:o})}}}async function nA(e,t,n){const o=e.filter(i=>i.role==="user").map(i=>i.content).filter(i=>Array.isArray(i)).flat().filter(i=>i.type==="image"||i.type==="file").map(i=>{var a;const s=(a=i.mediaType)!=null?a:i.type==="image"?"image/*":void 0;let l=i.type==="image"?i.image:i.data;if(typeof l=="string")try{l=new URL(l)}catch{}return{mediaType:s,data:l}}).filter(i=>i.data instanceof URL).map(i=>({url:i.data,isUrlSupportedByModel:i.mediaType!=null&&LC({url:i.data.toString(),mediaType:i.mediaType,supportedUrls:n})})),r=await t(o);return Object.fromEntries(r.map((i,a)=>i==null?null:[o[a].url.toString(),{data:i.data,mediaType:i.mediaType}]).filter(i=>i!=null))}function oA(e,t){var n;if(e.type==="text")return{type:"text",text:e.text,providerOptions:e.providerOptions};let o;const r=e.type;switch(r){case"image":o=e.image;break;case"file":o=e.data;break;default:throw new Error(`Unsupported part type: ${r}`)}const{data:i,mediaType:a}=Cx(o);let s=a??e.mediaType,l=i;if(l instanceof URL){const u=t[l.toString()];u&&(l=u.data,s??(s=u.mediaType))}switch(r){case"image":return(l instanceof Uint8Array||typeof l=="string")&&(s=(n=Gj({data:l,signatures:Jj}))!=null?n:s),{type:"file",mediaType:s??"image/*",filename:void 0,data:l,providerOptions:e.providerOptions};case"file":{if(s==null)throw new Error("Media type is missing for file part");return{type:"file",mediaType:s,filename:e.filename,data:l,providerOptions:e.providerOptions}}}}function iA({maxOutputTokens:e,temperature:t,topP:n,topK:o,presencePenalty:r,frequencyPenalty:i,seed:a,stopSequences:s}){if(e!=null){if(!Number.isInteger(e))throw new Nt({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be an integer"});if(e<1)throw new Nt({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be >= 1"})}if(t!=null&&typeof t!="number")throw new Nt({parameter:"temperature",value:t,message:"temperature must be a number"});if(n!=null&&typeof n!="number")throw new Nt({parameter:"topP",value:n,message:"topP must be a number"});if(o!=null&&typeof o!="number")throw new Nt({parameter:"topK",value:o,message:"topK must be a number"});if(r!=null&&typeof r!="number")throw new Nt({parameter:"presencePenalty",value:r,message:"presencePenalty must be a number"});if(i!=null&&typeof i!="number")throw new Nt({parameter:"frequencyPenalty",value:i,message:"frequencyPenalty must be a number"});if(a!=null&&!Number.isInteger(a))throw new Nt({parameter:"seed",value:a,message:"seed must be an integer"});return{maxOutputTokens:e,temperature:t,topP:n,topK:o,presencePenalty:r,frequencyPenalty:i,stopSequences:s,seed:a}}function aA(e){return e!=null&&Object.keys(e).length>0}function sA({tools:e,toolChoice:t,activeTools:n}){return aA(e)?{tools:(n!=null?Object.entries(e).filter(([r])=>n.includes(r)):Object.entries(e)).map(([r,i])=>{const a=i.type;switch(a){case void 0:case"dynamic":case"function":return{type:"function",name:r,description:i.description,inputSchema:Za(i.inputSchema).jsonSchema,providerOptions:i.providerOptions};case"provider-defined":return{type:"provider-defined",name:r,id:i.id,args:i.args};default:{const s=a;throw new Error(`Unsupported tool type: ${s}`)}}}),toolChoice:t==null?{type:"auto"}:typeof t=="string"?{type:t}:{type:"tool",toolName:t.toolName}}:{tools:void 0,toolChoice:void 0}}var Jn=xo(()=>W([yo(),w(),q(),de(),Xe(w(),Jn),R(Jn)])),Ut=Xe(w(),Xe(w(),Jn)),jx=E({type:C("text"),text:w(),providerOptions:Ut.optional()}),uA=E({type:C("image"),image:W([Px,zt(URL)]),mediaType:w().optional(),providerOptions:Ut.optional()}),Ax=E({type:C("file"),data:W([Px,zt(URL)]),filename:w().optional(),mediaType:w(),providerOptions:Ut.optional()}),lA=E({type:C("reasoning"),text:w(),providerOptions:Ut.optional()}),cA=E({type:C("tool-call"),toolCallId:w(),toolName:w(),input:$e(),providerOptions:Ut.optional(),providerExecuted:de().optional()}),dA=Pa("type",[E({type:C("text"),value:w()}),E({type:C("json"),value:Jn}),E({type:C("error-text"),value:w()}),E({type:C("error-json"),value:Jn}),E({type:C("content"),value:R(W([E({type:C("text"),text:w()}),E({type:C("media"),data:w(),mediaType:w()})]))})]),Rx=E({type:C("tool-result"),toolCallId:w(),toolName:w(),output:dA,providerOptions:Ut.optional()}),fA=E({role:C("system"),content:w(),providerOptions:Ut.optional()}),pA=E({role:C("user"),content:W([w(),R(W([jx,uA,Ax]))]),providerOptions:Ut.optional()}),mA=E({role:C("assistant"),content:W([w(),R(W([jx,Ax,lA,cA,Rx]))]),providerOptions:Ut.optional()}),hA=E({role:C("tool"),content:R(Rx),providerOptions:Ut.optional()}),gA=W([fA,pA,mA,hA]);async function vA(e){if(e.prompt==null&&e.messages==null)throw new Cr({prompt:e,message:"prompt or messages must be defined"});if(e.prompt!=null&&e.messages!=null)throw new Cr({prompt:e,message:"prompt and messages cannot be defined at the same time"});if(e.system!=null&&typeof e.system!="string")throw new Cr({prompt:e,message:"system must be a string"});let t;if(e.prompt!=null&&typeof e.prompt=="string")t=[{role:"user",content:e.prompt}];else if(e.prompt!=null&&Array.isArray(e.prompt))t=e.prompt;else if(e.messages!=null)t=e.messages;else throw new Cr({prompt:e,message:"prompt or messages must be defined"});if(t.length===0)throw new Cr({prompt:e,message:"messages must not be empty"});const n=await ar({value:t,schema:R(gA)});if(!n.success)throw new Cr({prompt:e,message:"The messages must be a ModelMessage[]. If you have passed a UIMessage[], you can use convertToModelMessages to convert them.",cause:n.error});return{messages:t,system:e.system}}function yA(e){return Mc.isInstance(e)||Jw.isInstance(e)?new Y({name:"GatewayError",message:"Vercel AI Gateway access failed. If you want to use AI SDK providers directly, use the providers, e.g. @ai-sdk/openai, or register a different global default provider.",cause:e}):e}function hu({operationId:e,telemetry:t}){return{"operation.name":`${e}${t?.functionId!=null?` ${t.functionId}`:""}`,"resource.name":t?.functionId,"ai.operationId":e,"ai.telemetry.functionId":t?.functionId}}function bA({model:e,settings:t,telemetry:n,headers:o}){var r;return{"ai.model.provider":e.provider,"ai.model.id":e.modelId,...Object.entries(t).reduce((i,[a,s])=>(i[`ai.settings.${a}`]=s,i),{}),...Object.entries((r=n?.metadata)!=null?r:{}).reduce((i,[a,s])=>(i[`ai.telemetry.metadata.${a}`]=s,i),{}),...Object.entries(o??{}).reduce((i,[a,s])=>(s!==void 0&&(i[`ai.request.headers.${a}`]=s),i),{})}}var _A={startSpan(){return Vo},startActiveSpan(e,t,n,o){if(typeof t=="function")return t(Vo);if(typeof n=="function")return n(Vo);if(typeof o=="function")return o(Vo)}},Vo={spanContext(){return wA},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this}},wA={traceId:"",spanId:"",traceFlags:0};function xA({isEnabled:e=!1,tracer:t}={}){return e?t||IN.getTracer("ai"):_A}function gu({name:e,tracer:t,attributes:n,fn:o,endWhenDone:r=!0}){return t.startActiveSpan(e,{attributes:n},async i=>{try{const a=await o(i);return r&&i.end(),a}catch(a){try{zx(i,a)}finally{i.end()}throw a}})}function zx(e,t){t instanceof Error?(e.recordException({name:t.name,message:t.message,stack:t.stack}),e.setStatus({code:_i.ERROR,message:t.message})):e.setStatus({code:_i.ERROR})}function Ur({telemetry:e,attributes:t}){return e?.isEnabled!==!0?{}:Object.entries(t).reduce((n,[o,r])=>{if(r==null)return n;if(typeof r=="object"&&"input"in r&&typeof r.input=="function"){if(e?.recordInputs===!1)return n;const i=r.input();return i==null?n:{...n,[o]:i}}if(typeof r=="object"&&"output"in r&&typeof r.output=="function"){if(e?.recordOutputs===!1)return n;const i=r.output();return i==null?n:{...n,[o]:i}}return{...n,[o]:r}},{})}function $A(e){return JSON.stringify(e.map(t=>({...t,content:typeof t.content=="string"?t.content:t.content.map(n=>n.type==="file"?{...n,data:n.data instanceof Uint8Array?eA(n.data):n.data}:n)})))}function SA(e,t){return{inputTokens:wn(e.inputTokens,t.inputTokens),outputTokens:wn(e.outputTokens,t.outputTokens),totalTokens:wn(e.totalTokens,t.totalTokens),reasoningTokens:wn(e.reasoningTokens,t.reasoningTokens),cachedInputTokens:wn(e.cachedInputTokens,t.cachedInputTokens)}}function wn(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}function ip(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function IA({error:e,exponentialBackoffDelay:t}){const n=e.responseHeaders;if(!n)return t;let o;const r=n["retry-after-ms"];if(r){const a=parseFloat(r);Number.isNaN(a)||(o=a)}const i=n["retry-after"];if(i&&o===void 0){const a=parseFloat(i);Number.isNaN(a)?o=Date.parse(i)-Date.now():o=a*1e3}return o!=null&&!Number.isNaN(o)&&0<=o&&(o<60*1e3||o<t)?o:t}var kA=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:n=2,abortSignal:o}={})=>async r=>Mx(r,{maxRetries:e,delayInMs:t,backoffFactor:n,abortSignal:o});async function Mx(e,{maxRetries:t,delayInMs:n,backoffFactor:o,abortSignal:r},i=[]){try{return await e()}catch(a){if(br(a)||t===0)throw a;const s=Pw(a),l=[...i,a],u=l.length;if(u>t)throw new op({message:`Failed after ${u} attempts. Last error: ${s}`,reason:"maxRetriesExceeded",errors:l});if(a instanceof Error&&Be.isInstance(a)&&a.isRetryable===!0&&u<=t)return await Nw(IA({error:a,exponentialBackoffDelay:n}),{abortSignal:r}),Mx(e,{maxRetries:t,delayInMs:o*n,backoffFactor:o,abortSignal:r},l);throw u===1?a:new op({message:`Failed after ${u} attempts with non-retryable error: '${s}'`,reason:"errorNotRetryable",errors:l})}}function EA({maxRetries:e,abortSignal:t}){if(e!=null){if(!Number.isInteger(e))throw new Nt({parameter:"maxRetries",value:e,message:"maxRetries must be an integer"});if(e<0)throw new Nt({parameter:"maxRetries",value:e,message:"maxRetries must be >= 0"})}const n=e??2;return{maxRetries:n,retry:kA({maxRetries:n,abortSignal:t})}}var OA=class{constructor({data:e,mediaType:t}){const n=e instanceof Uint8Array;this.base64Data=n?void 0:e,this.uint8ArrayData=n?e:void 0,this.mediaType=t}get base64(){return this.base64Data==null&&(this.base64Data=pu(this.uint8ArrayData)),this.base64Data}get uint8Array(){return this.uint8ArrayData==null&&(this.uint8ArrayData=zc(this.base64Data)),this.uint8ArrayData}},TA=class extends OA{constructor(e){super(e),this.type="file"}};async function NA({toolCall:e,tools:t,repairToolCall:n,system:o,messages:r}){try{if(t==null)throw new mu({toolName:e.toolName});try{return await ap({toolCall:e,tools:t})}catch(i){if(n==null||!(mu.isInstance(i)||ix.isInstance(i)))throw i;let a=null;try{a=await n({toolCall:e,tools:t,inputSchema:({toolName:s})=>{const{inputSchema:l}=t[s];return Za(l).jsonSchema},system:o,messages:r,error:i})}catch(s){throw new Mj({cause:s,originalError:i})}if(a==null)throw i;return await ap({toolCall:a,tools:t})}}catch(i){const a=await _r({text:e.input}),s=a.success?a.value:e.input;return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:s,dynamic:!0,invalid:!0,error:i}}}async function ap({toolCall:e,tools:t}){const n=e.toolName,o=t[n];if(o==null)throw new mu({toolName:e.toolName,availableTools:Object.keys(t)});const r=Za(o.inputSchema),i=e.input.trim()===""?await ar({value:{},schema:r}):await _r({text:e.input,schema:r});if(i.success===!1)throw new ix({toolName:n,toolInput:e.input,cause:i.error});return o.type==="dynamic"?{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,dynamic:!0}:{type:"tool-call",toolCallId:e.toolCallId,toolName:n,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata}}var PA=class{constructor({content:e,finishReason:t,usage:n,warnings:o,request:r,response:i,providerMetadata:a}){this.content=e,this.finishReason=t,this.usage=n,this.warnings=o,this.request=r,this.response=i,this.providerMetadata=a}get text(){return this.content.filter(e=>e.type==="text").map(e=>e.text).join("")}get reasoning(){return this.content.filter(e=>e.type==="reasoning")}get reasoningText(){return this.reasoning.length===0?void 0:this.reasoning.map(e=>e.text).join("")}get files(){return this.content.filter(e=>e.type==="file").map(e=>e.file)}get sources(){return this.content.filter(e=>e.type==="source")}get toolCalls(){return this.content.filter(e=>e.type==="tool-call")}get staticToolCalls(){return this.toolCalls.filter(e=>e.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(e=>e.dynamic===!0)}get toolResults(){return this.content.filter(e=>e.type==="tool-result")}get staticToolResults(){return this.toolResults.filter(e=>e.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(e=>e.dynamic===!0)}};function Dx(e){return({steps:t})=>t.length===e}async function CA({stopConditions:e,steps:t}){return(await Promise.all(e.map(n=>n({steps:t})))).some(n=>n)}function Tn({output:e,tool:t,errorMode:n}){return n==="text"?{type:"error-text",value:an(e)}:n==="json"?{type:"error-json",value:sp(e)}:t?.toModelOutput?t.toModelOutput(e):typeof e=="string"?{type:"text",value:e}:{type:"json",value:sp(e)}}function sp(e){return e===void 0?null:e}function up({content:e,tools:t}){const n=[],o=e.filter(i=>i.type!=="source").filter(i=>(i.type!=="tool-result"||i.providerExecuted)&&(i.type!=="tool-error"||i.providerExecuted)).filter(i=>i.type!=="text"||i.text.length>0).map(i=>{switch(i.type){case"text":return{type:"text",text:i.text,providerOptions:i.providerMetadata};case"reasoning":return{type:"reasoning",text:i.text,providerOptions:i.providerMetadata};case"file":return{type:"file",data:i.file.base64,mediaType:i.file.mediaType,providerOptions:i.providerMetadata};case"tool-call":return{type:"tool-call",toolCallId:i.toolCallId,toolName:i.toolName,input:i.input,providerExecuted:i.providerExecuted,providerOptions:i.providerMetadata};case"tool-result":return{type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Tn({tool:t?.[i.toolName],output:i.output,errorMode:"none"}),providerExecuted:!0,providerOptions:i.providerMetadata};case"tool-error":return{type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Tn({tool:t?.[i.toolName],output:i.error,errorMode:"json"}),providerOptions:i.providerMetadata}}});o.length>0&&n.push({role:"assistant",content:o});const r=e.filter(i=>i.type==="tool-result"||i.type==="tool-error").filter(i=>!i.providerExecuted).map(i=>({type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Tn({tool:t?.[i.toolName],output:i.type==="tool-result"?i.output:i.error,errorMode:i.type==="tool-error"?"text":"none"})}));return r.length>0&&n.push({role:"tool",content:r}),n}Eo({prefix:"aitxt",size:24});function Fa(e,t){const n=new Headers(e??{});for(const[o,r]of Object.entries(t))n.has(o)||n.set(o,r);return n}function jA({status:e,statusText:t,headers:n,textStream:o}){return new Response(o.pipeThrough(new TextEncoderStream),{status:e??200,statusText:t,headers:Fa(n,{"content-type":"text/plain; charset=utf-8"})})}function Ux({response:e,status:t,statusText:n,headers:o,stream:r}){e.writeHead(t??200,n,o);const i=r.getReader();(async()=>{try{for(;;){const{done:s,value:l}=await i.read();if(s)break;e.write(l)||await new Promise(c=>{e.once("drain",c)})}}catch(s){throw s}finally{e.end()}})()}function AA({response:e,status:t,statusText:n,headers:o,textStream:r}){Ux({response:e,status:t,statusText:n,headers:Object.fromEntries(Fa(o,{"content-type":"text/plain; charset=utf-8"}).entries()),stream:r.pipeThrough(new TextEncoderStream)})}var Lx=class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
84
|
+
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,new Vw({message:a,statusCode:r,cause:i})}},Bw="GatewayInvalidRequestError",i1=`vercel.ai.gateway.error.${Bw}`,Up=Symbol.for(i1),Lp,Zp,a1=class extends(Zp=rt,Lp=Up,Zp){constructor({message:e="Invalid request",statusCode:t=400,cause:n}={}){super({message:e,statusCode:t,cause:n}),this[Lp]=!0,this.name=Bw,this.type="invalid_request_error"}static isInstance(e){return rt.hasMarker(e)&&Up in e}},Jw="GatewayRateLimitError",s1=`vercel.ai.gateway.error.${Jw}`,Fp=Symbol.for(s1),qp,Vp,u1=class extends(Vp=rt,qp=Fp,Vp){constructor({message:e="Rate limit exceeded",statusCode:t=429,cause:n}={}){super({message:e,statusCode:t,cause:n}),this[qp]=!0,this.name=Jw,this.type="rate_limit_exceeded"}static isInstance(e){return rt.hasMarker(e)&&Fp in e}},Ww="GatewayModelNotFoundError",l1=`vercel.ai.gateway.error.${Ww}`,Bp=Symbol.for(l1),c1=ln(()=>Or(E({modelId:w()}))),Jp,Wp,Hw=class extends(Wp=rt,Jp=Bp,Wp){constructor({message:e="Model not found",statusCode:t=404,modelId:n,cause:o}={}){super({message:e,statusCode:t,cause:o}),this[Jp]=!0,this.name=Ww,this.type="model_not_found",this.modelId=n}static isInstance(e){return rt.hasMarker(e)&&Bp in e}},Gw="GatewayInternalServerError",d1=`vercel.ai.gateway.error.${Gw}`,Hp=Symbol.for(d1),Gp,Kp,Yp=class extends(Kp=rt,Gp=Hp,Kp){constructor({message:e="Internal server error",statusCode:t=500,cause:n}={}){super({message:e,statusCode:t,cause:n}),this[Gp]=!0,this.name=Gw,this.type="internal_server_error"}static isInstance(e){return rt.hasMarker(e)&&Hp in e}},Kw="GatewayResponseError",p1=`vercel.ai.gateway.error.${Kw}`,Qp=Symbol.for(p1),Xp,ef,f1=class extends(ef=rt,Xp=Qp,ef){constructor({message:e="Invalid response from Gateway",statusCode:t=502,response:n,validationError:o,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[Xp]=!0,this.name=Kw,this.type="response_error",this.response=n,this.validationError=o}static isInstance(e){return rt.hasMarker(e)&&Qp in e}};async function tf({response:e,statusCode:t,defaultMessage:n="Gateway request failed",cause:o,authMethod:r}){const i=await sr({value:e,schema:m1});if(!i.success)return new f1({message:`Invalid error response format: ${n}`,statusCode:t,response:e,validationError:i.error,cause:o});const a=i.value,s=a.error.type,l=a.error.message;switch(s){case"authentication_error":return Uc.createContextualError({apiKeyProvided:r==="api-key",oidcTokenProvided:r==="oidc",statusCode:t,cause:o});case"invalid_request_error":return new a1({message:l,statusCode:t,cause:o});case"rate_limit_exceeded":return new u1({message:l,statusCode:t,cause:o});case"model_not_found":{const u=await sr({value:a.error.param,schema:c1});return new Hw({message:l,statusCode:t,modelId:u.success?u.value.modelId:void 0,cause:o})}case"internal_server_error":return new Yp({message:l,statusCode:t,cause:o});default:return new Yp({message:l,statusCode:t,cause:o})}}var m1=ln(()=>Or(E({error:E({message:w(),type:w().nullish(),param:$e().nullish(),code:G([w(),V()]).nullish()})})));function xr(e,t){var n;return rt.isInstance(e)?e:Be.isInstance(e)?tf({response:h1(e),statusCode:(n=e.statusCode)!=null?n:500,defaultMessage:"Gateway request failed",cause:e,authMethod:t}):tf({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:"Unknown Gateway error",cause:e,authMethod:t})}function h1(e){if(e.data!==void 0)return e.data;if(e.responseBody!=null)try{return JSON.parse(e.responseBody)}catch{return e.responseBody}return{}}var Yw="ai-gateway-auth-method";async function Jn(e){const t=await sr({value:e[Yw],schema:g1});return t.success?t.value:void 0}var g1=ln(()=>Or(G([C("api-key"),C("oidc")]))),rf=class{constructor(e){this.config=e}async getAvailableModels(){try{const{value:e}=await Op({url:`${this.config.baseURL}/config`,headers:await tr(this.config.headers()),successfulResponseHandler:Ei(v1),failedResponseHandler:Bn({errorSchema:Pe(),errorToMessage:t=>t}),fetch:this.config.fetch});return e}catch(e){throw await xr(e)}}async getCredits(){try{const e=new URL(this.config.baseURL),{value:t}=await Op({url:`${e.origin}/v1/credits`,headers:await tr(this.config.headers()),successfulResponseHandler:Ei(y1),failedResponseHandler:Bn({errorSchema:Pe(),errorToMessage:n=>n}),fetch:this.config.fetch});return t}catch(e){throw await xr(e)}}},v1=ln(()=>Or(E({models:R(E({id:w(),name:w(),description:w().nullish(),pricing:E({input:w(),output:w(),input_cache_read:w().nullish(),input_cache_write:w().nullish()}).transform(({input:e,output:t,input_cache_read:n,input_cache_write:o})=>({input:e,output:t,...n?{cachedInputTokens:n}:{},...o?{cacheCreationInputTokens:o}:{}})).nullish(),specification:E({specificationVersion:C("v2"),provider:w(),modelId:w()}),modelType:dr(["language","embedding","image"]).nullish()}))}))),y1=ln(()=>Or(E({balance:w(),total_used:w()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t})))),b1=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v2",this.supportedUrls={"*/*":[/.*/]}}get provider(){return this.config.provider}async getArgs(e){const{abortSignal:t,...n}=e;return{args:this.maybeEncodeFileParts(n),warnings:[]}}async doGenerate(e){const{args:t,warnings:n}=await this.getArgs(e),{abortSignal:o}=e,r=await tr(this.config.headers());try{const{responseHeaders:i,value:a,rawValue:s}=await mu({url:this.getUrl(),headers:pu(r,e.headers,this.getModelConfigHeaders(this.modelId,!1),await tr(this.config.o11yHeaders)),body:t,successfulResponseHandler:Ei(Pe()),failedResponseHandler:Bn({errorSchema:Pe(),errorToMessage:l=>l}),...o&&{abortSignal:o},fetch:this.config.fetch});return{...a,request:{body:t},response:{headers:i,body:s},warnings:n}}catch(i){throw await xr(i,await Jn(r))}}async doStream(e){const{args:t,warnings:n}=await this.getArgs(e),{abortSignal:o}=e,r=await tr(this.config.headers());try{const{value:i,responseHeaders:a}=await mu({url:this.getUrl(),headers:pu(r,e.headers,this.getModelConfigHeaders(this.modelId,!0),await tr(this.config.o11yHeaders)),body:t,successfulResponseHandler:oj(Pe()),failedResponseHandler:Bn({errorSchema:Pe(),errorToMessage:s=>s}),...o&&{abortSignal:o},fetch:this.config.fetch});return{stream:i.pipeThrough(new TransformStream({start(s){n.length>0&&s.enqueue({type:"stream-start",warnings:n})},transform(s,l){if(s.success){const u=s.value;if(u.type==="raw"&&!e.includeRawChunks)return;u.type==="response-metadata"&&u.timestamp&&typeof u.timestamp=="string"&&(u.timestamp=new Date(u.timestamp)),l.enqueue(u)}else l.error(s.error)}})),request:{body:t},response:{headers:a}}}catch(i){throw await xr(i,await Jn(r))}}isFilePart(e){return e&&typeof e=="object"&&"type"in e&&e.type==="file"}maybeEncodeFileParts(e){for(const t of e.prompt)for(const n of t.content)if(this.isFilePart(n)){const o=n;if(o.data instanceof Uint8Array){const r=Uint8Array.from(o.data),i=Buffer.from(r).toString("base64");o.data=new URL(`data:${o.mediaType||"application/octet-stream"};base64,${i}`)}}return e}getUrl(){return`${this.config.baseURL}/language-model`}getModelConfigHeaders(e,t){return{"ai-language-model-specification-version":"2","ai-language-model-id":e,"ai-language-model-streaming":String(t)}}},_1=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v2",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0}get provider(){return this.config.provider}async doEmbed({values:e,headers:t,abortSignal:n,providerOptions:o}){var r;const i=await tr(this.config.headers());try{const{responseHeaders:a,value:s,rawValue:l}=await mu({url:this.getUrl(),headers:pu(i,t??{},this.getModelConfigHeaders(),await tr(this.config.o11yHeaders)),body:{input:e.length===1?e[0]:e,...o?{providerOptions:o}:{}},successfulResponseHandler:Ei(w1),failedResponseHandler:Bn({errorSchema:Pe(),errorToMessage:u=>u}),...n&&{abortSignal:n},fetch:this.config.fetch});return{embeddings:s.embeddings,usage:(r=s.usage)!=null?r:void 0,providerMetadata:s.providerMetadata,response:{headers:a,body:l}}}catch(a){throw await xr(a,await Jn(i))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":"2","ai-model-id":this.modelId}}},w1=ln(()=>Or(E({embeddings:R(R(V())),usage:E({tokens:V()}).nullish(),providerMetadata:Xe(w(),Xe(w(),$e())).optional()})));async function x1(){var e;return(e=Zw.getContext().headers)==null?void 0:e["x-vercel-id"]}var $1="2.0.7",S1="0.0.1";function I1(e={}){var t,n;let o=null,r=null;const i=(t=e.metadataCacheRefreshMillis)!=null?t:1e3*60*5;let a=0;const s=(n=Qj(e.baseURL))!=null?n:"https://ai-gateway.vercel.sh/v1/ai",l=async()=>{const g=await E1(e);if(g)return qa({Authorization:`Bearer ${g.token}`,"ai-gateway-protocol-version":S1,[Yw]:g.authMethod,...e.headers},`ai-sdk/gateway/${$1}`);throw Uc.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401})},u=()=>{const g=ii({settingValue:void 0,environmentVariableName:"VERCEL_DEPLOYMENT_ID"}),h=ii({settingValue:void 0,environmentVariableName:"VERCEL_ENV"}),b=ii({settingValue:void 0,environmentVariableName:"VERCEL_REGION"});return async()=>{const y=await x1();return{...g&&{"ai-o11y-deployment-id":g},...h&&{"ai-o11y-environment":h},...b&&{"ai-o11y-region":b},...y&&{"ai-o11y-request-id":y}}}},c=g=>new b1(g,{provider:"gateway",baseURL:s,headers:l,fetch:e.fetch,o11yHeaders:u()}),d=async()=>{var g,h,b;const y=(b=(h=(g=e._internal)==null?void 0:g.currentDate)==null?void 0:h.call(g).getTime())!=null?b:Date.now();return(!o||y-a>i)&&(a=y,o=new rf({baseURL:s,headers:l,fetch:e.fetch}).getAvailableModels().then(x=>(r=x,x)).catch(async x=>{throw await xr(x,await Jn(await l()))})),r?Promise.resolve(r):o},f=async()=>new rf({baseURL:s,headers:l,fetch:e.fetch}).getCredits().catch(async g=>{throw await xr(g,await Jn(await l()))}),p=function(g){if(new.target)throw new Error("The Gateway Provider model function cannot be called with the new keyword.");return c(g)};return p.getAvailableModels=d,p.getCredits=f,p.imageModel=g=>{throw new hI({modelId:g,modelType:"imageModel"})},p.languageModel=c,p.textEmbeddingModel=g=>new _1(g,{provider:"gateway",baseURL:s,headers:l,fetch:e.fetch,o11yHeaders:u()}),p}var k1=I1();async function E1(e){const t=ii({settingValue:e.apiKey,environmentVariableName:"AI_GATEWAY_API_KEY"});if(t)return{token:t,authMethod:"api-key"};try{return{token:await Zw.getVercelOidcToken(),authMethod:"oidc"}}catch{return null}}var T1=Object.defineProperty,O1=(e,t)=>{for(var n in t)T1(e,n,{get:t[n],enumerable:!0})},Qw="AI_NoOutputSpecifiedError",Xw=`vercel.ai.error.${Qw}`,N1=Symbol.for(Xw),ex,P1=class extends Y{constructor({message:e="No output specified."}={}){super({name:Qw,message:e}),this[ex]=!0}static isInstance(e){return Y.hasMarker(e,Xw)}};ex=N1;function C1(e){const t="AI SDK Warning:";switch(e.type){case"unsupported-setting":{let n=`${t} The "${e.setting}" setting is not supported by this model`;return e.details&&(n+=` - ${e.details}`),n}case"unsupported-tool":{const n="name"in e.tool?e.tool.name:"unknown tool";let o=`${t} The tool "${n}" is not supported by this model`;return e.details&&(o+=` - ${e.details}`),o}case"other":return`${t} ${e.message}`;default:return`${t} ${JSON.stringify(e,null,2)}`}}var j1="AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.",nf=!1,A1=e=>{if(e.length===0)return;const t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t=="function"){t(e);return}nf||(nf=!0,console.info(j1));for(const n of e)console.warn(C1(n))}},tx="AI_InvalidArgumentError",rx=`vercel.ai.error.${tx}`,R1=Symbol.for(rx),nx,Nt=class extends Y{constructor({parameter:e,value:t,message:n}){super({name:tx,message:`Invalid argument for parameter ${e}: ${n}`}),this[nx]=!0,this.parameter=e,this.value=t}static isInstance(e){return Y.hasMarker(e,rx)}};nx=R1;var ox="AI_InvalidToolInputError",ix=`vercel.ai.error.${ox}`,z1=Symbol.for(ix),ax,sx=class extends Y{constructor({toolInput:e,toolName:t,cause:n,message:o=`Invalid input for tool ${t}: ${sn(n)}`}){super({name:ox,message:o,cause:n}),this[ax]=!0,this.toolInput=e,this.toolName=t}static isInstance(e){return Y.hasMarker(e,ix)}};ax=z1;var ux="AI_NoObjectGeneratedError",lx=`vercel.ai.error.${ux}`,M1=Symbol.for(lx),cx,of=class extends Y{constructor({message:e="No object generated.",cause:t,text:n,response:o,usage:r,finishReason:i}){super({name:ux,message:e,cause:t}),this[cx]=!0,this.text=n,this.response=o,this.usage=r,this.finishReason=i}static isInstance(e){return Y.hasMarker(e,lx)}};cx=M1;var dx="AI_NoOutputGeneratedError",px=`vercel.ai.error.${dx}`,D1=Symbol.for(px),fx,U1=class extends Y{constructor({message:e="No output generated.",cause:t}={}){super({name:dx,message:e,cause:t}),this[fx]=!0}static isInstance(e){return Y.hasMarker(e,px)}};fx=D1;var mx="AI_NoSuchToolError",hx=`vercel.ai.error.${mx}`,L1=Symbol.for(hx),gx,yu=class extends Y{constructor({toolName:e,availableTools:t=void 0,message:n=`Model tried to call unavailable tool '${e}'. ${t===void 0?"No tools are available.":`Available tools: ${t.join(", ")}.`}`}){super({name:mx,message:n}),this[gx]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return Y.hasMarker(e,hx)}};gx=L1;var vx="AI_ToolCallRepairError",yx=`vercel.ai.error.${vx}`,Z1=Symbol.for(yx),bx,F1=class extends Y{constructor({cause:e,originalError:t,message:n=`Error repairing tool call: ${sn(e)}`}){super({name:vx,message:n,cause:e}),this[bx]=!0,this.originalError=t}static isInstance(e){return Y.hasMarker(e,yx)}};bx=Z1;var q1=class extends Y{constructor(e){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${e.version} for provider "${e.provider}" and model "${e.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=e.version,this.provider=e.provider,this.modelId=e.modelId}},_x="AI_InvalidMessageRoleError",wx=`vercel.ai.error.${_x}`,V1=Symbol.for(wx),xx,B1=class extends Y{constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:_x,message:t}),this[xx]=!0,this.role=e}static isInstance(e){return Y.hasMarker(e,wx)}};xx=V1;var $x="AI_MessageConversionError",Sx=`vercel.ai.error.${$x}`,J1=Symbol.for(Sx),Ix,W1=class extends Y{constructor({originalMessage:e,message:t}){super({name:$x,message:t}),this[Ix]=!0,this.originalMessage=e}static isInstance(e){return Y.hasMarker(e,Sx)}};Ix=J1;var kx="AI_DownloadError",Ex=`vercel.ai.error.${kx}`,H1=Symbol.for(Ex),Tx,js=class extends Y{constructor({url:e,statusCode:t,statusText:n,cause:o,message:r=o==null?`Failed to download ${e}: ${t} ${n}`:`Failed to download ${e}: ${o}`}){super({name:kx,message:r,cause:o}),this[Tx]=!0,this.url=e,this.statusCode=t,this.statusText=n}static isInstance(e){return Y.hasMarker(e,Ex)}};Tx=H1;var Ox="AI_RetryError",Nx=`vercel.ai.error.${Ox}`,G1=Symbol.for(Nx),Px,af=class extends Y{constructor({message:e,reason:t,errors:n}){super({name:Ox,message:e}),this[Px]=!0,this.reason=t,this.errors=n,this.lastError=n[n.length-1]}static isInstance(e){return Y.hasMarker(e,Nx)}};Px=G1;function Cx(e){if(typeof e!="string"){if(e.specificationVersion!=="v2")throw new q1({version:e.specificationVersion,provider:e.provider,modelId:e.modelId});return e}return K1().languageModel(e)}function K1(){var e;return(e=globalThis.AI_SDK_DEFAULT_PROVIDER)!=null?e:k1}var Y1=[{mediaType:"image/gif",bytesPrefix:[71,73,70]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],Q1=e=>{const t=typeof e=="string"?Dc(e):e,n=(t[6]&127)<<21|(t[7]&127)<<14|(t[8]&127)<<7|t[9]&127;return t.slice(n+10)};function X1(e){return typeof e=="string"&&e.startsWith("SUQz")||typeof e!="string"&&e.length>10&&e[0]===73&&e[1]===68&&e[2]===51?Q1(e):e}function eA({data:e,signatures:t}){const n=X1(e),o=typeof n=="string"?Dc(n.substring(0,Math.min(n.length,24))):n;for(const r of t)if(o.length>=r.bytesPrefix.length&&r.bytesPrefix.every((i,a)=>i===null||o[a]===i))return r.mediaType}var tA="5.0.90",rA=async({url:e})=>{var t;const n=e.toString();try{const o=await fetch(n,{headers:qa({},`ai-sdk/${tA}`,zc())});if(!o.ok)throw new js({url:n,statusCode:o.status,statusText:o.statusText});return{data:new Uint8Array(await o.arrayBuffer()),mediaType:(t=o.headers.get("content-type"))!=null?t:void 0}}catch(o){throw js.isInstance(o)?o:new js({url:n,cause:o})}},nA=(e=rA)=>t=>Promise.all(t.map(async n=>n.isUrlSupportedByModel?null:e(n)));function oA(e){try{const[t,n]=e.split(",");return{mediaType:t.split(";")[0].split(":")[1],base64Content:n}}catch{return{mediaType:void 0,base64Content:void 0}}}var jx=G([w(),Rt(Uint8Array),Rt(ArrayBuffer),Io(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]);function Ax(e){if(e instanceof Uint8Array)return{data:e,mediaType:void 0};if(e instanceof ArrayBuffer)return{data:new Uint8Array(e),mediaType:void 0};if(typeof e=="string")try{e=new URL(e)}catch{}if(e instanceof URL&&e.protocol==="data:"){const{mediaType:t,base64Content:n}=oA(e.toString());if(t==null||n==null)throw new Y({name:"InvalidDataContentError",message:`Invalid data URL format in content ${e.toString()}`});return{data:n,mediaType:t}}return{data:e,mediaType:void 0}}function iA(e){return typeof e=="string"?e:e instanceof ArrayBuffer?vu(new Uint8Array(e)):vu(e)}async function aA({prompt:e,supportedUrls:t,download:n=nA()}){const o=await uA(e.messages,n,t);return[...e.system!=null?[{role:"system",content:e.system}]:[],...e.messages.map(r=>sA({message:r,downloadedAssets:o}))]}function sA({message:e,downloadedAssets:t}){const n=e.role;switch(n){case"system":return{role:"system",content:e.content,providerOptions:e.providerOptions};case"user":return typeof e.content=="string"?{role:"user",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions}:{role:"user",content:e.content.map(o=>lA(o,t)).filter(o=>o.type!=="text"||o.text!==""),providerOptions:e.providerOptions};case"assistant":return typeof e.content=="string"?{role:"assistant",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions}:{role:"assistant",content:e.content.filter(o=>o.type!=="text"||o.text!==""||o.providerOptions!=null).map(o=>{const r=o.providerOptions;switch(o.type){case"file":{const{data:i,mediaType:a}=Ax(o.data);return{type:"file",data:i,filename:o.filename,mediaType:a??o.mediaType,providerOptions:r}}case"reasoning":return{type:"reasoning",text:o.text,providerOptions:r};case"text":return{type:"text",text:o.text,providerOptions:r};case"tool-call":return{type:"tool-call",toolCallId:o.toolCallId,toolName:o.toolName,input:o.input,providerExecuted:o.providerExecuted,providerOptions:r};case"tool-result":return{type:"tool-result",toolCallId:o.toolCallId,toolName:o.toolName,output:o.output,providerOptions:r}}}),providerOptions:e.providerOptions};case"tool":return{role:"tool",content:e.content.map(o=>({type:"tool-result",toolCallId:o.toolCallId,toolName:o.toolName,output:o.output,providerOptions:o.providerOptions})),providerOptions:e.providerOptions};default:{const o=n;throw new B1({role:o})}}}async function uA(e,t,n){const o=e.filter(i=>i.role==="user").map(i=>i.content).filter(i=>Array.isArray(i)).flat().filter(i=>i.type==="image"||i.type==="file").map(i=>{var a;const s=(a=i.mediaType)!=null?a:i.type==="image"?"image/*":void 0;let l=i.type==="image"?i.image:i.data;if(typeof l=="string")try{l=new URL(l)}catch{}return{mediaType:s,data:l}}).filter(i=>i.data instanceof URL).map(i=>({url:i.data,isUrlSupportedByModel:i.mediaType!=null&&BC({url:i.data.toString(),mediaType:i.mediaType,supportedUrls:n})})),r=await t(o);return Object.fromEntries(r.map((i,a)=>i==null?null:[o[a].url.toString(),{data:i.data,mediaType:i.mediaType}]).filter(i=>i!=null))}function lA(e,t){var n;if(e.type==="text")return{type:"text",text:e.text,providerOptions:e.providerOptions};let o;const r=e.type;switch(r){case"image":o=e.image;break;case"file":o=e.data;break;default:throw new Error(`Unsupported part type: ${r}`)}const{data:i,mediaType:a}=Ax(o);let s=a??e.mediaType,l=i;if(l instanceof URL){const u=t[l.toString()];u&&(l=u.data,s??(s=u.mediaType))}switch(r){case"image":return(l instanceof Uint8Array||typeof l=="string")&&(s=(n=eA({data:l,signatures:Y1}))!=null?n:s),{type:"file",mediaType:s??"image/*",filename:void 0,data:l,providerOptions:e.providerOptions};case"file":{if(s==null)throw new Error("Media type is missing for file part");return{type:"file",mediaType:s,filename:e.filename,data:l,providerOptions:e.providerOptions}}}}function cA({maxOutputTokens:e,temperature:t,topP:n,topK:o,presencePenalty:r,frequencyPenalty:i,seed:a,stopSequences:s}){if(e!=null){if(!Number.isInteger(e))throw new Nt({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be an integer"});if(e<1)throw new Nt({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be >= 1"})}if(t!=null&&typeof t!="number")throw new Nt({parameter:"temperature",value:t,message:"temperature must be a number"});if(n!=null&&typeof n!="number")throw new Nt({parameter:"topP",value:n,message:"topP must be a number"});if(o!=null&&typeof o!="number")throw new Nt({parameter:"topK",value:o,message:"topK must be a number"});if(r!=null&&typeof r!="number")throw new Nt({parameter:"presencePenalty",value:r,message:"presencePenalty must be a number"});if(i!=null&&typeof i!="number")throw new Nt({parameter:"frequencyPenalty",value:i,message:"frequencyPenalty must be a number"});if(a!=null&&!Number.isInteger(a))throw new Nt({parameter:"seed",value:a,message:"seed must be an integer"});return{maxOutputTokens:e,temperature:t,topP:n,topK:o,presencePenalty:r,frequencyPenalty:i,stopSequences:s,seed:a}}function dA(e){return e!=null&&Object.keys(e).length>0}function pA({tools:e,toolChoice:t,activeTools:n}){return dA(e)?{tools:(n!=null?Object.entries(e).filter(([r])=>n.includes(r)):Object.entries(e)).map(([r,i])=>{const a=i.type;switch(a){case void 0:case"dynamic":case"function":return{type:"function",name:r,description:i.description,inputSchema:Va(i.inputSchema).jsonSchema,providerOptions:i.providerOptions};case"provider-defined":return{type:"provider-defined",name:r,id:i.id,args:i.args};default:{const s=a;throw new Error(`Unsupported tool type: ${s}`)}}}),toolChoice:t==null?{type:"auto"}:typeof t=="string"?{type:t}:{type:"tool",toolName:t.toolName}}:{tools:void 0,toolChoice:void 0}}var Wn=$o(()=>G([bo(),w(),V(),pe(),Xe(w(),Wn),R(Wn)])),Mt=Xe(w(),Xe(w(),Wn)),Rx=E({type:C("text"),text:w(),providerOptions:Mt.optional()}),fA=E({type:C("image"),image:G([jx,Rt(URL)]),mediaType:w().optional(),providerOptions:Mt.optional()}),zx=E({type:C("file"),data:G([jx,Rt(URL)]),filename:w().optional(),mediaType:w(),providerOptions:Mt.optional()}),mA=E({type:C("reasoning"),text:w(),providerOptions:Mt.optional()}),hA=E({type:C("tool-call"),toolCallId:w(),toolName:w(),input:$e(),providerOptions:Mt.optional(),providerExecuted:pe().optional()}),gA=Aa("type",[E({type:C("text"),value:w()}),E({type:C("json"),value:Wn}),E({type:C("error-text"),value:w()}),E({type:C("error-json"),value:Wn}),E({type:C("content"),value:R(G([E({type:C("text"),text:w()}),E({type:C("media"),data:w(),mediaType:w()})]))})]),Mx=E({type:C("tool-result"),toolCallId:w(),toolName:w(),output:gA,providerOptions:Mt.optional()}),vA=E({role:C("system"),content:w(),providerOptions:Mt.optional()}),yA=E({role:C("user"),content:G([w(),R(G([Rx,fA,zx]))]),providerOptions:Mt.optional()}),bA=E({role:C("assistant"),content:G([w(),R(G([Rx,zx,mA,hA,Mx]))]),providerOptions:Mt.optional()}),_A=E({role:C("tool"),content:R(Mx),providerOptions:Mt.optional()}),wA=G([vA,yA,bA,_A]);async function xA(e){if(e.prompt==null&&e.messages==null)throw new jr({prompt:e,message:"prompt or messages must be defined"});if(e.prompt!=null&&e.messages!=null)throw new jr({prompt:e,message:"prompt and messages cannot be defined at the same time"});if(e.system!=null&&typeof e.system!="string")throw new jr({prompt:e,message:"system must be a string"});let t;if(e.prompt!=null&&typeof e.prompt=="string")t=[{role:"user",content:e.prompt}];else if(e.prompt!=null&&Array.isArray(e.prompt))t=e.prompt;else if(e.messages!=null)t=e.messages;else throw new jr({prompt:e,message:"prompt or messages must be defined"});if(t.length===0)throw new jr({prompt:e,message:"messages must not be empty"});const n=await sr({value:t,schema:R(wA)});if(!n.success)throw new jr({prompt:e,message:"The messages must be a ModelMessage[]. If you have passed a UIMessage[], you can use convertToModelMessages to convert them.",cause:n.error});return{messages:t,system:e.system}}function $A(e){return Uc.isInstance(e)||Hw.isInstance(e)?new Y({name:"GatewayError",message:"Vercel AI Gateway access failed. If you want to use AI SDK providers directly, use the providers, e.g. @ai-sdk/openai, or register a different global default provider.",cause:e}):e}function bu({operationId:e,telemetry:t}){return{"operation.name":`${e}${t?.functionId!=null?` ${t.functionId}`:""}`,"resource.name":t?.functionId,"ai.operationId":e,"ai.telemetry.functionId":t?.functionId}}function SA({model:e,settings:t,telemetry:n,headers:o}){var r;return{"ai.model.provider":e.provider,"ai.model.id":e.modelId,...Object.entries(t).reduce((i,[a,s])=>(i[`ai.settings.${a}`]=s,i),{}),...Object.entries((r=n?.metadata)!=null?r:{}).reduce((i,[a,s])=>(i[`ai.telemetry.metadata.${a}`]=s,i),{}),...Object.entries(o??{}).reduce((i,[a,s])=>(s!==void 0&&(i[`ai.request.headers.${a}`]=s),i),{})}}var IA={startSpan(){return Bo},startActiveSpan(e,t,n,o){if(typeof t=="function")return t(Bo);if(typeof n=="function")return n(Bo);if(typeof o=="function")return o(Bo)}},Bo={spanContext(){return kA},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this}},kA={traceId:"",spanId:"",traceFlags:0};function EA({isEnabled:e=!1,tracer:t}={}){return e?t||NN.getTracer("ai"):IA}function _u({name:e,tracer:t,attributes:n,fn:o,endWhenDone:r=!0}){return t.startActiveSpan(e,{attributes:n},async i=>{try{const a=await o(i);return r&&i.end(),a}catch(a){try{Dx(i,a)}finally{i.end()}throw a}})}function Dx(e,t){t instanceof Error?(e.recordException({name:t.name,message:t.message,stack:t.stack}),e.setStatus({code:xi.ERROR,message:t.message})):e.setStatus({code:xi.ERROR})}function Lr({telemetry:e,attributes:t}){return e?.isEnabled!==!0?{}:Object.entries(t).reduce((n,[o,r])=>{if(r==null)return n;if(typeof r=="object"&&"input"in r&&typeof r.input=="function"){if(e?.recordInputs===!1)return n;const i=r.input();return i==null?n:{...n,[o]:i}}if(typeof r=="object"&&"output"in r&&typeof r.output=="function"){if(e?.recordOutputs===!1)return n;const i=r.output();return i==null?n:{...n,[o]:i}}return{...n,[o]:r}},{})}function TA(e){return JSON.stringify(e.map(t=>({...t,content:typeof t.content=="string"?t.content:t.content.map(n=>n.type==="file"?{...n,data:n.data instanceof Uint8Array?iA(n.data):n.data}:n)})))}function OA(e,t){return{inputTokens:xn(e.inputTokens,t.inputTokens),outputTokens:xn(e.outputTokens,t.outputTokens),totalTokens:xn(e.totalTokens,t.totalTokens),reasoningTokens:xn(e.reasoningTokens,t.reasoningTokens),cachedInputTokens:xn(e.cachedInputTokens,t.cachedInputTokens)}}function xn(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}function sf(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function NA({error:e,exponentialBackoffDelay:t}){const n=e.responseHeaders;if(!n)return t;let o;const r=n["retry-after-ms"];if(r){const a=parseFloat(r);Number.isNaN(a)||(o=a)}const i=n["retry-after"];if(i&&o===void 0){const a=parseFloat(i);Number.isNaN(a)?o=Date.parse(i)-Date.now():o=a*1e3}return o!=null&&!Number.isNaN(o)&&0<=o&&(o<60*1e3||o<t)?o:t}var PA=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:n=2,abortSignal:o}={})=>async r=>Ux(r,{maxRetries:e,delayInMs:t,backoffFactor:n,abortSignal:o});async function Ux(e,{maxRetries:t,delayInMs:n,backoffFactor:o,abortSignal:r},i=[]){try{return await e()}catch(a){if(_r(a)||t===0)throw a;const s=jw(a),l=[...i,a],u=l.length;if(u>t)throw new af({message:`Failed after ${u} attempts. Last error: ${s}`,reason:"maxRetriesExceeded",errors:l});if(a instanceof Error&&Be.isInstance(a)&&a.isRetryable===!0&&u<=t)return await Cw(NA({error:a,exponentialBackoffDelay:n}),{abortSignal:r}),Ux(e,{maxRetries:t,delayInMs:o*n,backoffFactor:o,abortSignal:r},l);throw u===1?a:new af({message:`Failed after ${u} attempts with non-retryable error: '${s}'`,reason:"errorNotRetryable",errors:l})}}function CA({maxRetries:e,abortSignal:t}){if(e!=null){if(!Number.isInteger(e))throw new Nt({parameter:"maxRetries",value:e,message:"maxRetries must be an integer"});if(e<0)throw new Nt({parameter:"maxRetries",value:e,message:"maxRetries must be >= 0"})}const n=e??2;return{maxRetries:n,retry:PA({maxRetries:n,abortSignal:t})}}var jA=class{constructor({data:e,mediaType:t}){const n=e instanceof Uint8Array;this.base64Data=n?void 0:e,this.uint8ArrayData=n?e:void 0,this.mediaType=t}get base64(){return this.base64Data==null&&(this.base64Data=vu(this.uint8ArrayData)),this.base64Data}get uint8Array(){return this.uint8ArrayData==null&&(this.uint8ArrayData=Dc(this.base64Data)),this.uint8ArrayData}},AA=class extends jA{constructor(e){super(e),this.type="file"}};async function RA({toolCall:e,tools:t,repairToolCall:n,system:o,messages:r}){try{if(t==null)throw new yu({toolName:e.toolName});try{return await uf({toolCall:e,tools:t})}catch(i){if(n==null||!(yu.isInstance(i)||sx.isInstance(i)))throw i;let a=null;try{a=await n({toolCall:e,tools:t,inputSchema:({toolName:s})=>{const{inputSchema:l}=t[s];return Va(l).jsonSchema},system:o,messages:r,error:i})}catch(s){throw new F1({cause:s,originalError:i})}if(a==null)throw i;return await uf({toolCall:a,tools:t})}}catch(i){const a=await wr({text:e.input}),s=a.success?a.value:e.input;return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:s,dynamic:!0,invalid:!0,error:i}}}async function uf({toolCall:e,tools:t}){const n=e.toolName,o=t[n];if(o==null)throw new yu({toolName:e.toolName,availableTools:Object.keys(t)});const r=Va(o.inputSchema),i=e.input.trim()===""?await sr({value:{},schema:r}):await wr({text:e.input,schema:r});if(i.success===!1)throw new sx({toolName:n,toolInput:e.input,cause:i.error});return o.type==="dynamic"?{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,dynamic:!0}:{type:"tool-call",toolCallId:e.toolCallId,toolName:n,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata}}var zA=class{constructor({content:e,finishReason:t,usage:n,warnings:o,request:r,response:i,providerMetadata:a}){this.content=e,this.finishReason=t,this.usage=n,this.warnings=o,this.request=r,this.response=i,this.providerMetadata=a}get text(){return this.content.filter(e=>e.type==="text").map(e=>e.text).join("")}get reasoning(){return this.content.filter(e=>e.type==="reasoning")}get reasoningText(){return this.reasoning.length===0?void 0:this.reasoning.map(e=>e.text).join("")}get files(){return this.content.filter(e=>e.type==="file").map(e=>e.file)}get sources(){return this.content.filter(e=>e.type==="source")}get toolCalls(){return this.content.filter(e=>e.type==="tool-call")}get staticToolCalls(){return this.toolCalls.filter(e=>e.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(e=>e.dynamic===!0)}get toolResults(){return this.content.filter(e=>e.type==="tool-result")}get staticToolResults(){return this.toolResults.filter(e=>e.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(e=>e.dynamic===!0)}};function Lx(e){return({steps:t})=>t.length===e}async function MA({stopConditions:e,steps:t}){return(await Promise.all(e.map(n=>n({steps:t})))).some(n=>n)}function Nn({output:e,tool:t,errorMode:n}){return n==="text"?{type:"error-text",value:sn(e)}:n==="json"?{type:"error-json",value:lf(e)}:t?.toModelOutput?t.toModelOutput(e):typeof e=="string"?{type:"text",value:e}:{type:"json",value:lf(e)}}function lf(e){return e===void 0?null:e}function cf({content:e,tools:t}){const n=[],o=e.filter(i=>i.type!=="source").filter(i=>(i.type!=="tool-result"||i.providerExecuted)&&(i.type!=="tool-error"||i.providerExecuted)).filter(i=>i.type!=="text"||i.text.length>0).map(i=>{switch(i.type){case"text":return{type:"text",text:i.text,providerOptions:i.providerMetadata};case"reasoning":return{type:"reasoning",text:i.text,providerOptions:i.providerMetadata};case"file":return{type:"file",data:i.file.base64,mediaType:i.file.mediaType,providerOptions:i.providerMetadata};case"tool-call":return{type:"tool-call",toolCallId:i.toolCallId,toolName:i.toolName,input:i.input,providerExecuted:i.providerExecuted,providerOptions:i.providerMetadata};case"tool-result":return{type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Nn({tool:t?.[i.toolName],output:i.output,errorMode:"none"}),providerExecuted:!0,providerOptions:i.providerMetadata};case"tool-error":return{type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Nn({tool:t?.[i.toolName],output:i.error,errorMode:"json"}),providerOptions:i.providerMetadata}}});o.length>0&&n.push({role:"assistant",content:o});const r=e.filter(i=>i.type==="tool-result"||i.type==="tool-error").filter(i=>!i.providerExecuted).map(i=>({type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Nn({tool:t?.[i.toolName],output:i.type==="tool-result"?i.output:i.error,errorMode:i.type==="tool-error"?"text":"none"})}));return r.length>0&&n.push({role:"tool",content:r}),n}To({prefix:"aitxt",size:24});function Ba(e,t){const n=new Headers(e??{});for(const[o,r]of Object.entries(t))n.has(o)||n.set(o,r);return n}function DA({status:e,statusText:t,headers:n,textStream:o}){return new Response(o.pipeThrough(new TextEncoderStream),{status:e??200,statusText:t,headers:Ba(n,{"content-type":"text/plain; charset=utf-8"})})}function Zx({response:e,status:t,statusText:n,headers:o,stream:r}){e.writeHead(t??200,n,o);const i=r.getReader();(async()=>{try{for(;;){const{done:s,value:l}=await i.read();if(s)break;e.write(l)||await new Promise(c=>{e.once("drain",c)})}}catch(s){throw s}finally{e.end()}})()}function UA({response:e,status:t,statusText:n,headers:o,textStream:r}){Zx({response:e,status:t,statusText:n,headers:Object.fromEntries(Ba(o,{"content-type":"text/plain; charset=utf-8"}).entries()),stream:r.pipeThrough(new TextEncoderStream)})}var Fx=class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
85
85
|
|
|
86
86
|
`)},flush(e){e.enqueue(`data: [DONE]
|
|
87
87
|
|
|
88
|
-
`)}})}},Zx={"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive","x-vercel-ai-ui-message-stream":"v1","x-accel-buffering":"no"};function RA({status:e,statusText:t,headers:n,stream:o,consumeSseStream:r}){let i=o.pipeThrough(new Lx);if(r){const[a,s]=i.tee();i=a,r({stream:s})}return new Response(i.pipeThrough(new TextEncoderStream),{status:e,statusText:t,headers:Fa(n,Zx)})}function zA({originalMessages:e,responseMessageId:t}){if(e==null)return;const n=e[e.length-1];return n?.role==="assistant"?n.id:typeof t=="function"?t():t}function MA(e){return e.type.startsWith("data-")}function Fx(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const r=t[o];if(r===void 0)continue;const i=o in e?e[o]:void 0,a=r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp),s=i!=null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp);a&&s?n[o]=Fx(i,r):n[o]=r}return n}function DA(e){const t=["ROOT"];let n=-1,o=null;function r(l,u,c){switch(l){case'"':{n=u,t.pop(),t.push(c),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=u,o=u,t.pop(),t.push(c),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=u,t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"{":{n=u,t.pop(),t.push(c),t.push("INSIDE_OBJECT_START");break}case"[":{n=u,t.pop(),t.push(c),t.push("INSIDE_ARRAY_START");break}}}function i(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":r(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{r(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),n=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{n=l,t.pop();break}default:{n=l,r(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,t.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{r(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(o,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?i(u,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l)):n=l;break}}}let s=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{s+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{s+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{s+="]";break}case"INSIDE_LITERAL":{const c=e.substring(o,e.length);"true".startsWith(c)?s+="true".slice(c.length):"false".startsWith(c)?s+="false".slice(c.length):"null".startsWith(c)&&(s+="null".slice(c.length))}}return s}async function qx(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await _r({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await _r({text:DA(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function Ps(e){return e.type.startsWith("data-")}function Cs(e){return e.type==="text"}function js(e){return e.type==="file"}function lp(e){return e.type==="reasoning"}function Zr(e){return e.type.startsWith("tool-")}function Dc(e){return e.type==="dynamic-tool"}function cp(e){return Zr(e)||Dc(e)}function ki(e){return e.type.split("-").slice(1).join("-")}function UA(e){return Dc(e)?e.toolName:ki(e)}function LA({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function ZA({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:o,onError:r,onToolCall:i,onData:a}){return e.pipeThrough(new TransformStream({async transform(s,l){await o(async({state:u,write:c})=>{var d,p,f,g;function m(v){const N=u.message.parts.filter(Zr).find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function b(v){const N=u.message.parts.filter(I=>I.type==="dynamic-tool").find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function y(v){var k;const N=u.message.parts.find(z=>Zr(z)&&z.toolCallId===v.toolCallId),I=v,T=N;N!=null?(N.state=v.state,T.input=I.input,T.output=I.output,T.errorText=I.errorText,T.rawInput=I.rawInput,T.preliminary=I.preliminary,T.providerExecuted=(k=I.providerExecuted)!=null?k:N.providerExecuted,I.providerMetadata!=null&&N.state==="input-available"&&(N.callProviderMetadata=I.providerMetadata)):u.message.parts.push({type:`tool-${v.toolName}`,toolCallId:v.toolCallId,state:v.state,input:I.input,output:I.output,rawInput:I.rawInput,errorText:I.errorText,providerExecuted:I.providerExecuted,preliminary:I.preliminary,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}function x(v){var k,N;const I=u.message.parts.find(Z=>Z.type==="dynamic-tool"&&Z.toolCallId===v.toolCallId),T=v,z=I;I!=null?(I.state=v.state,z.toolName=v.toolName,z.input=T.input,z.output=T.output,z.errorText=T.errorText,z.rawInput=(k=T.rawInput)!=null?k:z.rawInput,z.preliminary=T.preliminary,z.providerExecuted=(N=T.providerExecuted)!=null?N:I.providerExecuted,T.providerMetadata!=null&&I.state==="input-available"&&(I.callProviderMetadata=T.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:v.toolName,toolCallId:v.toolCallId,state:v.state,input:T.input,output:T.output,errorText:T.errorText,preliminary:T.preliminary,providerExecuted:T.providerExecuted,...T.providerMetadata!=null?{callProviderMetadata:T.providerMetadata}:{}})}async function $(v){if(v!=null){const k=u.message.metadata!=null?Fx(u.message.metadata,v):v;t!=null&&await lu({value:k,schema:t}),u.message.metadata=k}}switch(s.type){case"text-start":{const v={type:"text",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeTextParts[s.id]=v,u.message.parts.push(v),c();break}case"text-delta":{const v=u.activeTextParts[s.id];v.text+=s.delta,v.providerMetadata=(d=s.providerMetadata)!=null?d:v.providerMetadata,c();break}case"text-end":{const v=u.activeTextParts[s.id];v.state="done",v.providerMetadata=(p=s.providerMetadata)!=null?p:v.providerMetadata,delete u.activeTextParts[s.id],c();break}case"reasoning-start":{const v={type:"reasoning",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeReasoningParts[s.id]=v,u.message.parts.push(v),c();break}case"reasoning-delta":{const v=u.activeReasoningParts[s.id];v.text+=s.delta,v.providerMetadata=(f=s.providerMetadata)!=null?f:v.providerMetadata,c();break}case"reasoning-end":{const v=u.activeReasoningParts[s.id];v.providerMetadata=(g=s.providerMetadata)!=null?g:v.providerMetadata,v.state="done",delete u.activeReasoningParts[s.id],c();break}case"file":{u.message.parts.push({type:"file",mediaType:s.mediaType,url:s.url}),c();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:s.sourceId,url:s.url,title:s.title,providerMetadata:s.providerMetadata}),c();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:s.sourceId,mediaType:s.mediaType,title:s.title,filename:s.filename,providerMetadata:s.providerMetadata}),c();break}case"tool-input-start":{const v=u.message.parts.filter(Zr);u.partialToolCalls[s.toolCallId]={text:"",toolName:s.toolName,index:v.length,dynamic:s.dynamic},s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}),c();break}case"tool-input-delta":{const v=u.partialToolCalls[s.toolCallId];v.text+=s.inputTextDelta;const{value:k}=await qx(v.text);v.dynamic?x({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}):y({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}),c();break}case"tool-input-available":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c(),i&&!s.providerExecuted&&await i({toolCall:s});break}case"tool-input-error":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:void 0,rawInput:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c();break}case"tool-output-available":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-available",input:v.input,output:s.output,preliminary:s.preliminary})}else{const v=m(s.toolCallId);y({toolCallId:s.toolCallId,toolName:ki(v),state:"output-available",input:v.input,output:s.output,providerExecuted:s.providerExecuted,preliminary:s.preliminary})}c();break}case"tool-output-error":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-error",input:v.input,errorText:s.errorText,providerExecuted:s.providerExecuted})}else{const v=m(s.toolCallId);y({toolCallId:s.toolCallId,toolName:ki(v),state:"output-error",input:v.input,rawInput:v.rawInput,errorText:s.errorText,providerExecuted:s.providerExecuted})}c();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{s.messageId!=null&&(u.message.id=s.messageId),await $(s.messageMetadata),(s.messageId!=null||s.messageMetadata!=null)&&c();break}case"finish":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"message-metadata":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"error":{r?.(new Error(s.errorText));break}default:if(MA(s)){n?.[s.type]!=null&&await lu({value:s.data,schema:n[s.type]});const v=s;if(v.transient){a?.(v);break}const k=v.id!=null?u.message.parts.find(N=>v.type===N.type&&v.id===N.id):void 0;k!=null?k.data=v.data:u.message.parts.push(v),a?.(v),c()}}l.enqueue(s)})}}))}function FA({messageId:e,originalMessages:t=[],onFinish:n,onError:o,stream:r}){let i=t?.[t.length-1];i?.role!=="assistant"?i=void 0:e=i.id;let a=!1;const s=r.pipeThrough(new TransformStream({transform(p,f){if(p.type==="start"){const g=p;g.messageId==null&&e!=null&&(g.messageId=e)}p.type==="abort"&&(a=!0),f.enqueue(p)}}));if(n==null)return s;const l=LA({lastMessage:i?structuredClone(i):void 0,messageId:e??""}),u=async p=>{await p({state:l,write:()=>{}})};let c=!1;const d=async()=>{if(c||!n)return;c=!0;const p=l.message.id===i?.id;await n({isAborted:a,isContinuation:p,responseMessage:l.message,messages:[...p?t.slice(0,-1):t,l.message]})};return ZA({stream:s,runUpdateMessageJob:u,onError:o}).pipeThrough(new TransformStream({transform(p,f){f.enqueue(p)},async cancel(){await d()},async flush(){await d()}}))}function qA({response:e,status:t,statusText:n,headers:o,stream:r,consumeSseStream:i}){let a=r.pipeThrough(new Lx);if(i){const[s,l]=a.tee();a=s,i({stream:l})}Ux({response:e,status:t,statusText:n,headers:Object.fromEntries(Fa(o,Zx).entries()),stream:a.pipeThrough(new TextEncoderStream)})}function Bo(e){const t=e.pipeThrough(new TransformStream);return t[Symbol.asyncIterator]=function(){const n=this.getReader();let o=!1;async function r(i){var a;o=!0;try{i&&await((a=n.cancel)==null?void 0:a.call(n))}finally{try{n.releaseLock()}catch{}}}return{async next(){if(o)return{done:!0,value:void 0};const{done:i,value:a}=await n.read();return i?(await r(!0),{done:!0,value:void 0}):{done:!1,value:a}},async return(){return await r(!0),{done:!0,value:void 0}},async throw(i){throw await r(!0),i}}},t}async function VA({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:o}=await n.read();if(o)break}}catch(o){t?.(o)}finally{n.releaseLock()}}function dp(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function BA(){let e=[],t=null,n=!1,o=dp();const r=()=>{n=!0,o.resolve(),e.forEach(a=>a.cancel()),e=[],t?.close()},i=async()=>{if(n&&e.length===0){t?.close();return}if(e.length===0)return o=dp(),await o.promise,i();try{const{value:a,done:s}=await e[0].read();s?(e.shift(),e.length>0?await i():n&&t?.close()):t?.enqueue(a)}catch(a){t?.error(a),e.shift(),r()}};return{stream:new ReadableStream({start(a){t=a},pull:i,async cancel(){for(const a of e)await a.cancel();e=[],n=!0}}),addStream:a=>{if(n)throw new Error("Cannot add inner stream: outer stream is closed");e.push(a.getReader()),o.resolve()},close:()=>{n=!0,o.resolve(),e.length===0&&t?.close()},terminate:r}}var Jo=class{constructor(){this.status={type:"pending"},this._resolve=void 0,this._reject=void 0}get promise(){return this._promise?this._promise:(this._promise=new Promise((e,t)=>{this.status.type==="resolved"?e(this.status.value):this.status.type==="rejected"&&t(this.status.error),this._resolve=e,this._reject=t}),this._promise)}resolve(e){var t;this.status={type:"resolved",value:e},this._promise&&((t=this._resolve)==null||t.call(this,e))}reject(e){var t;this.status={type:"rejected",error:e},this._promise&&((t=this._reject)==null||t.call(this,e))}};function JA(){var e,t;return(t=(e=globalThis?.performance)==null?void 0:e.now())!=null?t:Date.now()}function WA({tools:e,generatorStream:t,tracer:n,telemetry:o,system:r,messages:i,abortSignal:a,repairToolCall:s,experimental_context:l}){let u=null;const c=new ReadableStream({start(y){u=y}}),d=new Set,p=new Map;let f=!1,g;function m(){f&&d.size===0&&(g!=null&&u.enqueue(g),u.close())}const b=new TransformStream({async transform(y,x){const $=y.type;switch($){case"stream-start":case"text-start":case"text-delta":case"text-end":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"tool-input-start":case"tool-input-delta":case"tool-input-end":case"source":case"response-metadata":case"error":case"raw":{x.enqueue(y);break}case"file":{x.enqueue({type:"file",file:new TA({data:y.data,mediaType:y.mediaType})});break}case"finish":{g={type:"finish",finishReason:y.finishReason,usage:y.usage,providerMetadata:y.providerMetadata};break}case"tool-call":{try{const v=await NA({toolCall:y,tools:e,repairToolCall:s,system:r,messages:i});if(x.enqueue(v),v.invalid){u.enqueue({type:"tool-error",toolCallId:v.toolCallId,toolName:v.toolName,input:v.input,error:Pw(v.error),dynamic:!0});break}const k=e[v.toolName];if(p.set(v.toolCallId,v.input),k.onInputAvailable!=null&&await k.onInputAvailable({input:v.input,toolCallId:v.toolCallId,messages:i,abortSignal:a,experimental_context:l}),k.execute!=null&&v.providerExecuted!==!0){const N=zC();d.add(N),gu({name:"ai.toolCall",attributes:Ur({telemetry:o,attributes:{...hu({operationId:"ai.toolCall",telemetry:o}),"ai.toolCall.name":v.toolName,"ai.toolCall.id":v.toolCallId,"ai.toolCall.args":{output:()=>JSON.stringify(v.input)}}}),tracer:n,fn:async I=>{let T;try{const z=G1({execute:k.execute.bind(k),input:v.input,options:{toolCallId:v.toolCallId,messages:i,abortSignal:a,experimental_context:l}});for await(const Z of z)u.enqueue({...v,type:"tool-result",output:Z.output,...Z.type==="preliminary"&&{preliminary:!0}}),Z.type==="final"&&(T=Z.output)}catch(z){zx(I,z),u.enqueue({...v,type:"tool-error",error:z}),d.delete(N),m();return}d.delete(N),m();try{I.setAttributes(Ur({telemetry:o,attributes:{"ai.toolCall.result":{output:()=>JSON.stringify(T)}}}))}catch{}}})}}catch(v){u.enqueue({type:"error",error:v})}break}case"tool-result":{const v=y.toolName;y.isError?u.enqueue({type:"tool-error",toolCallId:y.toolCallId,toolName:v,input:p.get(y.toolCallId),providerExecuted:y.providerExecuted,error:y.result}):x.enqueue({type:"tool-result",toolCallId:y.toolCallId,toolName:v,input:p.get(y.toolCallId),output:y.result,providerExecuted:y.providerExecuted});break}default:{const v=$;throw new Error(`Unhandled chunk type: ${v}`)}}},flush(){f=!0,m()}});return new ReadableStream({async start(y){return Promise.all([t.pipeThrough(b).pipeTo(new WritableStream({write(x){y.enqueue(x)},close(){}})),c.pipeTo(new WritableStream({write(x){y.enqueue(x)},close(){y.close()}}))])}})}var HA=Eo({prefix:"aitxt",size:24});function GA({model:e,tools:t,toolChoice:n,system:o,prompt:r,messages:i,maxRetries:a,abortSignal:s,headers:l,stopWhen:u=Dx(1),experimental_output:c,experimental_telemetry:d,prepareStep:p,providerOptions:f,experimental_activeTools:g,activeTools:m=g,experimental_repairToolCall:b,experimental_transform:y,experimental_download:x,includeRawChunks:$=!1,onChunk:v,onError:k=({error:V})=>{console.error(V)},onFinish:N,onAbort:I,onStepFinish:T,experimental_context:z,_internal:{now:Z=JA,generateId:re=HA,currentDate:ve=()=>new Date}={},...G}){return new YA({model:Nx(e),telemetry:d,headers:l,settings:G,maxRetries:a,abortSignal:s,system:o,prompt:r,messages:i,tools:t,toolChoice:n,transforms:ip(y),activeTools:m,repairToolCall:b,stopConditions:ip(u),output:c,providerOptions:f,prepareStep:p,includeRawChunks:$,onChunk:v,onError:k,onFinish:N,onAbort:I,onStepFinish:T,now:Z,currentDate:ve,generateId:re,experimental_context:z,download:x})}function KA(e){if(!e)return new TransformStream({transform(a,s){s.enqueue({part:a,partialOutput:void 0})}});let t,n="",o="",r="";function i({controller:a,partialOutput:s=void 0}){a.enqueue({part:{type:"text-delta",id:t,text:o},partialOutput:s}),o=""}return new TransformStream({async transform(a,s){if(a.type==="finish-step"&&o.length>0&&i({controller:s}),a.type!=="text-delta"&&a.type!=="text-start"&&a.type!=="text-end"){s.enqueue({part:a,partialOutput:void 0});return}if(t==null)t=a.id;else if(a.id!==t){s.enqueue({part:a,partialOutput:void 0});return}if(a.type==="text-start"){s.enqueue({part:a,partialOutput:void 0});return}if(a.type==="text-end"){o.length>0&&i({controller:s}),s.enqueue({part:a,partialOutput:void 0});return}n+=a.text,o+=a.text;const l=await e.parsePartial({text:n});if(l!=null){const u=JSON.stringify(l.partial);u!==r&&(i({controller:s,partialOutput:l.partial}),r=u)}}})}var YA=class{constructor({model:e,telemetry:t,headers:n,settings:o,maxRetries:r,abortSignal:i,system:a,prompt:s,messages:l,tools:u,toolChoice:c,transforms:d,activeTools:p,repairToolCall:f,stopConditions:g,output:m,providerOptions:b,prepareStep:y,includeRawChunks:x,now:$,currentDate:v,generateId:k,onChunk:N,onError:I,onFinish:T,onAbort:z,onStepFinish:Z,experimental_context:re,download:ve}){this._totalUsage=new Jo,this._finishReason=new Jo,this._steps=new Jo,this.output=m,this.includeRawChunks=x,this.tools=u;let G,V=[];const we=[];let oe,ce,K={},fe=[];const B=[];let Ue,ye={},Le={};const D=new TransformStream({async transform(Ee,Oe){var Ae,ie,mt,pn;Oe.enqueue(Ee);const{part:L}=Ee;if((L.type==="text-delta"||L.type==="reasoning-delta"||L.type==="source"||L.type==="tool-call"||L.type==="tool-result"||L.type==="tool-input-start"||L.type==="tool-input-delta"||L.type==="raw")&&await N?.({chunk:L}),L.type==="error"&&await I({error:yA(L.error)}),L.type==="text-start"&&(ye[L.id]={type:"text",text:"",providerMetadata:L.providerMetadata},V.push(ye[L.id])),L.type==="text-delta"){const Ie=ye[L.id];if(Ie==null){Oe.enqueue({part:{type:"error",error:`text part ${L.id} not found`},partialOutput:void 0});return}Ie.text+=L.text,Ie.providerMetadata=(Ae=L.providerMetadata)!=null?Ae:Ie.providerMetadata}if(L.type==="text-end"){const Ie=ye[L.id];if(Ie==null){Oe.enqueue({part:{type:"error",error:`text part ${L.id} not found`},partialOutput:void 0});return}Ie.providerMetadata=(ie=L.providerMetadata)!=null?ie:Ie.providerMetadata,delete ye[L.id]}if(L.type==="reasoning-start"&&(Le[L.id]={type:"reasoning",text:"",providerMetadata:L.providerMetadata},V.push(Le[L.id])),L.type==="reasoning-delta"){const Ie=Le[L.id];if(Ie==null){Oe.enqueue({part:{type:"error",error:`reasoning part ${L.id} not found`},partialOutput:void 0});return}Ie.text+=L.text,Ie.providerMetadata=(mt=L.providerMetadata)!=null?mt:Ie.providerMetadata}if(L.type==="reasoning-end"){const Ie=Le[L.id];if(Ie==null){Oe.enqueue({part:{type:"error",error:`reasoning part ${L.id} not found`},partialOutput:void 0});return}Ie.providerMetadata=(pn=L.providerMetadata)!=null?pn:Ie.providerMetadata,delete Le[L.id]}if(L.type==="file"&&V.push({type:"file",file:L.file}),L.type==="source"&&V.push(L),L.type==="tool-call"&&V.push(L),L.type==="tool-result"&&!L.preliminary&&V.push(L),L.type==="tool-error"&&V.push(L),L.type==="start-step"&&(K=L.request,fe=L.warnings),L.type==="finish-step"){const Ie=up({content:V,tools:u}),mn=new PA({content:V,finishReason:L.finishReason,usage:L.usage,warnings:fe,request:K,response:{...L.response,messages:[...we,...Ie]},providerMetadata:L.providerMetadata});await Z?.(mn),Tj(fe),B.push(mn),V=[],Le={},ye={},we.push(...Ie),G.resolve()}L.type==="finish"&&(ce=L.totalUsage,oe=L.finishReason)},async flush(Ee){try{if(B.length===0){const mt=new Aj({message:"No output generated. Check the stream for errors."});je._finishReason.reject(mt),je._totalUsage.reject(mt),je._steps.reject(mt);return}const Oe=oe??"unknown",Ae=ce??{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};je._finishReason.resolve(Oe),je._totalUsage.resolve(Ae),je._steps.resolve(B);const ie=B[B.length-1];await T?.({finishReason:Oe,totalUsage:Ae,usage:ie.usage,content:ie.content,text:ie.text,reasoningText:ie.reasoningText,reasoning:ie.reasoning,files:ie.files,sources:ie.sources,toolCalls:ie.toolCalls,staticToolCalls:ie.staticToolCalls,dynamicToolCalls:ie.dynamicToolCalls,toolResults:ie.toolResults,staticToolResults:ie.staticToolResults,dynamicToolResults:ie.dynamicToolResults,request:ie.request,response:ie.response,warnings:ie.warnings,providerMetadata:ie.providerMetadata,steps:B}),Ue.setAttributes(Ur({telemetry:t,attributes:{"ai.response.finishReason":Oe,"ai.response.text":{output:()=>ie.text},"ai.response.toolCalls":{output:()=>{var mt;return(mt=ie.toolCalls)!=null&&mt.length?JSON.stringify(ie.toolCalls):void 0}},"ai.response.providerMetadata":JSON.stringify(ie.providerMetadata),"ai.usage.inputTokens":Ae.inputTokens,"ai.usage.outputTokens":Ae.outputTokens,"ai.usage.totalTokens":Ae.totalTokens,"ai.usage.reasoningTokens":Ae.reasoningTokens,"ai.usage.cachedInputTokens":Ae.cachedInputTokens}}))}catch(Oe){Ee.error(Oe)}finally{Ue.end()}}}),Q=BA();this.addStream=Q.addStream,this.closeStream=Q.close;const pe=Q.stream.getReader();let xe=new ReadableStream({async start(Ee){Ee.enqueue({type:"start"})},async pull(Ee){function Oe(){z?.({steps:B}),Ee.enqueue({type:"abort"}),Ee.close()}try{const{done:Ae,value:ie}=await pe.read();if(Ae){Ee.close();return}if(i?.aborted){Oe();return}Ee.enqueue(ie)}catch(Ae){br(Ae)&&i?.aborted?Oe():Ee.error(Ae)}},cancel(Ee){return Q.stream.cancel(Ee)}});for(const Ee of d)xe=xe.pipeThrough(Ee({tools:u,stopStream(){Q.terminate()}}));this.baseStream=xe.pipeThrough(KA(m)).pipeThrough(D);const{maxRetries:Ao,retry:os}=EA({maxRetries:r,abortSignal:i}),fn=xA(t),pt=iA(o),Ro=bA({model:e,telemetry:t,headers:n,settings:{...pt,maxRetries:Ao}}),je=this;gu({name:"ai.streamText",attributes:Ur({telemetry:t,attributes:{...hu({operationId:"ai.streamText",telemetry:t}),...Ro,"ai.prompt":{input:()=>JSON.stringify({system:a,prompt:s,messages:l})}}}),tracer:fn,endWhenDone:!1,fn:async Ee=>{Ue=Ee;async function Oe({currentStep:Ae,responseMessages:ie,usage:mt}){var pn,L,Ie,mn,xd;const $d=je.includeRawChunks;G=new Jo;const Sd=await vA({system:a,prompt:s,messages:l}),hn=[...Sd.messages,...ie],Et=await y?.({model:e,steps:B,stepNumber:B.length,messages:hn}),Tr=Nx((pn=Et?.model)!=null?pn:e),Id=await tA({prompt:{system:(L=Et?.system)!=null?L:Sd.system,messages:(Ie=Et?.messages)!=null?Ie:hn},supportedUrls:await Tr.supportedUrls,download:ve}),{toolChoice:is,tools:as}=sA({tools:u,toolChoice:(mn=Et?.toolChoice)!=null?mn:c,activeTools:(xd=Et?.activeTools)!=null?xd:p}),{result:{stream:l0,response:kd,request:Ed},doStreamSpan:Nr,startTimestampMs:Od}=await os(()=>gu({name:"ai.streamText.doStream",attributes:Ur({telemetry:t,attributes:{...hu({operationId:"ai.streamText.doStream",telemetry:t}),...Ro,"ai.model.provider":Tr.provider,"ai.model.id":Tr.modelId,"ai.prompt.messages":{input:()=>$A(Id)},"ai.prompt.tools":{input:()=>as?.map(J=>JSON.stringify(J))},"ai.prompt.toolChoice":{input:()=>is!=null?JSON.stringify(is):void 0},"gen_ai.system":Tr.provider,"gen_ai.request.model":Tr.modelId,"gen_ai.request.frequency_penalty":pt.frequencyPenalty,"gen_ai.request.max_tokens":pt.maxOutputTokens,"gen_ai.request.presence_penalty":pt.presencePenalty,"gen_ai.request.stop_sequences":pt.stopSequences,"gen_ai.request.temperature":pt.temperature,"gen_ai.request.top_k":pt.topK,"gen_ai.request.top_p":pt.topP}}),tracer:fn,endWhenDone:!1,fn:async J=>({startTimestampMs:$(),doStreamSpan:J,result:await Tr.doStream({...pt,tools:as,toolChoice:is,responseFormat:m?.responseFormat,prompt:Id,providerOptions:b,abortSignal:i,headers:n,includeRawChunks:$d})})})),c0=WA({tools:u,generatorStream:l0,tracer:fn,telemetry:t,system:a,messages:hn,repairToolCall:f,abortSignal:i,experimental_context:re}),d0=Ed??{},zo=[],ss=[];let us;const ls={};let Pr="unknown",ht={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},cs,Td=!0,Ot={id:k(),timestamp:v(),modelId:e.modelId},Nd="";je.addStream(c0.pipeThrough(new TransformStream({async transform(J,Re){var gn,vn,Mo,Zt;if(J.type==="stream-start"){us=J.warnings;return}if(Td){const Ze=$()-Od;Td=!1,Nr.addEvent("ai.stream.firstChunk",{"ai.response.msToFirstChunk":Ze}),Nr.setAttributes({"ai.response.msToFirstChunk":Ze}),Re.enqueue({type:"start-step",request:d0,warnings:us??[]})}const Pd=J.type;switch(Pd){case"text-start":case"text-end":{Re.enqueue(J);break}case"text-delta":{J.delta.length>0&&(Re.enqueue({type:"text-delta",id:J.id,text:J.delta,providerMetadata:J.providerMetadata}),Nd+=J.delta);break}case"reasoning-start":case"reasoning-end":{Re.enqueue(J);break}case"reasoning-delta":{Re.enqueue({type:"reasoning-delta",id:J.id,text:J.delta,providerMetadata:J.providerMetadata});break}case"tool-call":{Re.enqueue(J),zo.push(J);break}case"tool-result":{Re.enqueue(J),J.preliminary||ss.push(J);break}case"tool-error":{Re.enqueue(J),ss.push(J);break}case"response-metadata":{Ot={id:(gn=J.id)!=null?gn:Ot.id,timestamp:(vn=J.timestamp)!=null?vn:Ot.timestamp,modelId:(Mo=J.modelId)!=null?Mo:Ot.modelId};break}case"finish":{ht=J.usage,Pr=J.finishReason,cs=J.providerMetadata;const Ze=$()-Od;Nr.addEvent("ai.stream.finish"),Nr.setAttributes({"ai.response.msToFinish":Ze,"ai.response.avgOutputTokensPerSecond":1e3*((Zt=ht.outputTokens)!=null?Zt:0)/Ze});break}case"file":{Re.enqueue(J);break}case"source":{Re.enqueue(J);break}case"tool-input-start":{ls[J.id]=J.toolName;const Ze=u?.[J.toolName];Ze?.onInputStart!=null&&await Ze.onInputStart({toolCallId:J.id,messages:hn,abortSignal:i,experimental_context:re}),Re.enqueue({...J,dynamic:Ze?.type==="dynamic"});break}case"tool-input-end":{delete ls[J.id],Re.enqueue(J);break}case"tool-input-delta":{const Ze=ls[J.id],ds=u?.[Ze];ds?.onInputDelta!=null&&await ds.onInputDelta({inputTextDelta:J.delta,toolCallId:J.id,messages:hn,abortSignal:i,experimental_context:re}),Re.enqueue(J);break}case"error":{Re.enqueue(J),Pr="error";break}case"raw":{$d&&Re.enqueue(J);break}default:{const Ze=Pd;throw new Error(`Unknown chunk type: ${Ze}`)}}},async flush(J){const Re=zo.length>0?JSON.stringify(zo):void 0;try{Nr.setAttributes(Ur({telemetry:t,attributes:{"ai.response.finishReason":Pr,"ai.response.text":{output:()=>Nd},"ai.response.toolCalls":{output:()=>Re},"ai.response.id":Ot.id,"ai.response.model":Ot.modelId,"ai.response.timestamp":Ot.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(cs),"ai.usage.inputTokens":ht.inputTokens,"ai.usage.outputTokens":ht.outputTokens,"ai.usage.totalTokens":ht.totalTokens,"ai.usage.reasoningTokens":ht.reasoningTokens,"ai.usage.cachedInputTokens":ht.cachedInputTokens,"gen_ai.response.finish_reasons":[Pr],"gen_ai.response.id":Ot.id,"gen_ai.response.model":Ot.modelId,"gen_ai.usage.input_tokens":ht.inputTokens,"gen_ai.usage.output_tokens":ht.outputTokens}}))}catch{}finally{Nr.end()}J.enqueue({type:"finish-step",finishReason:Pr,usage:ht,providerMetadata:cs,response:{...Ot,headers:kd?.headers}});const gn=SA(mt,ht);await G.promise;const vn=zo.filter(Zt=>Zt.providerExecuted!==!0),Mo=ss.filter(Zt=>Zt.providerExecuted!==!0);if(vn.length>0&&Mo.length===vn.length&&!await CA({stopConditions:g,steps:B})){ie.push(...up({content:B[B.length-1].content,tools:u}));try{await Oe({currentStep:Ae+1,responseMessages:ie,usage:gn})}catch(Zt){J.enqueue({type:"error",error:Zt}),je.closeStream()}}else J.enqueue({type:"finish",finishReason:Pr,totalUsage:gn}),je.closeStream()}})))}await Oe({currentStep:0,responseMessages:[],usage:{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0}})}}).catch(Ee=>{je.addStream(new ReadableStream({start(Oe){Oe.enqueue({type:"error",error:Ee}),Oe.close()}})),je.closeStream()})}get steps(){return this.consumeStream(),this._steps.promise}get finalStep(){return this.steps.then(e=>e[e.length-1])}get content(){return this.finalStep.then(e=>e.content)}get warnings(){return this.finalStep.then(e=>e.warnings)}get providerMetadata(){return this.finalStep.then(e=>e.providerMetadata)}get text(){return this.finalStep.then(e=>e.text)}get reasoningText(){return this.finalStep.then(e=>e.reasoningText)}get reasoning(){return this.finalStep.then(e=>e.reasoning)}get sources(){return this.finalStep.then(e=>e.sources)}get files(){return this.finalStep.then(e=>e.files)}get toolCalls(){return this.finalStep.then(e=>e.toolCalls)}get staticToolCalls(){return this.finalStep.then(e=>e.staticToolCalls)}get dynamicToolCalls(){return this.finalStep.then(e=>e.dynamicToolCalls)}get toolResults(){return this.finalStep.then(e=>e.toolResults)}get staticToolResults(){return this.finalStep.then(e=>e.staticToolResults)}get dynamicToolResults(){return this.finalStep.then(e=>e.dynamicToolResults)}get usage(){return this.finalStep.then(e=>e.usage)}get request(){return this.finalStep.then(e=>e.request)}get response(){return this.finalStep.then(e=>e.response)}get totalUsage(){return this.consumeStream(),this._totalUsage.promise}get finishReason(){return this.consumeStream(),this._finishReason.promise}teeStream(){const[e,t]=this.baseStream.tee();return this.baseStream=t,e}get textStream(){return Bo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){e.type==="text-delta"&&t.enqueue(e.text)}})))}get fullStream(){return Bo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){t.enqueue(e)}})))}async consumeStream(e){var t;try{await VA({stream:this.fullStream,onError:e?.onError})}catch(n){(t=e?.onError)==null||t.call(e,n)}}get experimental_partialOutputStream(){if(this.output==null)throw new kj;return Bo(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:e},t){e!=null&&t.enqueue(e)}})))}toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:n,messageMetadata:o,sendReasoning:r=!0,sendSources:i=!1,sendStart:a=!0,sendFinish:s=!0,onError:l=an}={}){const u=t!=null?zA({originalMessages:e,responseMessageId:t}):void 0,c={},d=f=>{var g,m;const b=c[f];return((m=(g=this.tools)==null?void 0:g[b])==null?void 0:m.type)==="dynamic"?!0:void 0},p=this.fullStream.pipeThrough(new TransformStream({transform:async(f,g)=>{const m=o?.({part:f}),b=f.type;switch(b){case"text-start":{g.enqueue({type:"text-start",id:f.id,...f.providerMetadata!=null?{providerMetadata:f.providerMetadata}:{}});break}case"text-delta":{g.enqueue({type:"text-delta",id:f.id,delta:f.text,...f.providerMetadata!=null?{providerMetadata:f.providerMetadata}:{}});break}case"text-end":{g.enqueue({type:"text-end",id:f.id,...f.providerMetadata!=null?{providerMetadata:f.providerMetadata}:{}});break}case"reasoning-start":{g.enqueue({type:"reasoning-start",id:f.id,...f.providerMetadata!=null?{providerMetadata:f.providerMetadata}:{}});break}case"reasoning-delta":{r&&g.enqueue({type:"reasoning-delta",id:f.id,delta:f.text,...f.providerMetadata!=null?{providerMetadata:f.providerMetadata}:{}});break}case"reasoning-end":{g.enqueue({type:"reasoning-end",id:f.id,...f.providerMetadata!=null?{providerMetadata:f.providerMetadata}:{}});break}case"file":{g.enqueue({type:"file",mediaType:f.file.mediaType,url:`data:${f.file.mediaType};base64,${f.file.base64}`});break}case"source":{i&&f.sourceType==="url"&&g.enqueue({type:"source-url",sourceId:f.id,url:f.url,title:f.title,...f.providerMetadata!=null?{providerMetadata:f.providerMetadata}:{}}),i&&f.sourceType==="document"&&g.enqueue({type:"source-document",sourceId:f.id,mediaType:f.mediaType,title:f.title,filename:f.filename,...f.providerMetadata!=null?{providerMetadata:f.providerMetadata}:{}});break}case"tool-input-start":{c[f.id]=f.toolName;const y=d(f.id);g.enqueue({type:"tool-input-start",toolCallId:f.id,toolName:f.toolName,...f.providerExecuted!=null?{providerExecuted:f.providerExecuted}:{},...y!=null?{dynamic:y}:{}});break}case"tool-input-delta":{g.enqueue({type:"tool-input-delta",toolCallId:f.id,inputTextDelta:f.delta});break}case"tool-call":{c[f.toolCallId]=f.toolName;const y=d(f.toolCallId);f.invalid?g.enqueue({type:"tool-input-error",toolCallId:f.toolCallId,toolName:f.toolName,input:f.input,...f.providerExecuted!=null?{providerExecuted:f.providerExecuted}:{},...f.providerMetadata!=null?{providerMetadata:f.providerMetadata}:{},...y!=null?{dynamic:y}:{},errorText:l(f.error)}):g.enqueue({type:"tool-input-available",toolCallId:f.toolCallId,toolName:f.toolName,input:f.input,...f.providerExecuted!=null?{providerExecuted:f.providerExecuted}:{},...f.providerMetadata!=null?{providerMetadata:f.providerMetadata}:{},...y!=null?{dynamic:y}:{}});break}case"tool-result":{const y=d(f.toolCallId);g.enqueue({type:"tool-output-available",toolCallId:f.toolCallId,output:f.output,...f.providerExecuted!=null?{providerExecuted:f.providerExecuted}:{},...f.preliminary!=null?{preliminary:f.preliminary}:{},...y!=null?{dynamic:y}:{}});break}case"tool-error":{const y=d(f.toolCallId);g.enqueue({type:"tool-output-error",toolCallId:f.toolCallId,errorText:l(f.error),...f.providerExecuted!=null?{providerExecuted:f.providerExecuted}:{},...y!=null?{dynamic:y}:{}});break}case"error":{g.enqueue({type:"error",errorText:l(f.error)});break}case"start-step":{g.enqueue({type:"start-step"});break}case"finish-step":{g.enqueue({type:"finish-step"});break}case"start":{a&&g.enqueue({type:"start",...m!=null?{messageMetadata:m}:{},...u!=null?{messageId:u}:{}});break}case"finish":{s&&g.enqueue({type:"finish",...m!=null?{messageMetadata:m}:{}});break}case"abort":{g.enqueue(f);break}case"tool-input-end":break;case"raw":break;default:{const y=b;throw new Error(`Unknown chunk type: ${y}`)}}m!=null&&b!=="start"&&b!=="finish"&&g.enqueue({type:"message-metadata",messageMetadata:m})}}));return Bo(FA({stream:p,messageId:u??t?.(),originalMessages:e,onFinish:n,onError:l}))}pipeUIMessageStreamToResponse(e,{originalMessages:t,generateMessageId:n,onFinish:o,messageMetadata:r,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u,...c}={}){qA({response:e,stream:this.toUIMessageStream({originalMessages:t,generateMessageId:n,onFinish:o,messageMetadata:r,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u}),...c})}pipeTextStreamToResponse(e,t){AA({response:e,textStream:this.textStream,...t})}toUIMessageStreamResponse({originalMessages:e,generateMessageId:t,onFinish:n,messageMetadata:o,sendReasoning:r,sendSources:i,sendFinish:a,sendStart:s,onError:l,...u}={}){return RA({stream:this.toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:n,messageMetadata:o,sendReasoning:r,sendSources:i,sendFinish:a,sendStart:s,onError:l}),...u})}toTextStreamResponse(e){return jA({textStream:this.textStream,...e})}};function QA(e,t){const n=[];t?.ignoreIncompleteToolCalls&&(e=e.map(o=>({...o,parts:o.parts.filter(r=>!cp(r)||r.state!=="input-streaming"&&r.state!=="input-available")})));for(const o of e)switch(o.role){case"system":{const r=o.parts.filter(a=>a.type==="text"),i=r.reduce((a,s)=>s.providerMetadata!=null?{...a,...s.providerMetadata}:a,{});n.push({role:"system",content:r.map(a=>a.text).join(""),...Object.keys(i).length>0?{providerOptions:i}:{}});break}case"user":{n.push({role:"user",content:o.parts.map(r=>{var i;if(Cs(r))return{type:"text",text:r.text,...r.providerMetadata!=null?{providerOptions:r.providerMetadata}:{}};if(js(r))return{type:"file",mediaType:r.mediaType,filename:r.filename,data:r.url,...r.providerMetadata!=null?{providerOptions:r.providerMetadata}:{}};if(Ps(r))return(i=t?.convertDataPart)==null?void 0:i.call(t,r)}).filter(r=>r!=null)});break}case"assistant":{if(o.parts!=null){let r=function(){var a,s,l;if(i.length===0)return;const u=[];for(const d of i)if(Cs(d))u.push({type:"text",text:d.text,...d.providerMetadata!=null?{providerOptions:d.providerMetadata}:{}});else if(js(d))u.push({type:"file",mediaType:d.mediaType,filename:d.filename,data:d.url});else if(lp(d))u.push({type:"reasoning",text:d.text,providerOptions:d.providerMetadata});else if(Dc(d)){const p=d.toolName;d.state!=="input-streaming"&&u.push({type:"tool-call",toolCallId:d.toolCallId,toolName:p,input:d.input,...d.callProviderMetadata!=null?{providerOptions:d.callProviderMetadata}:{}})}else if(Zr(d)){const p=ki(d);d.state!=="input-streaming"&&(u.push({type:"tool-call",toolCallId:d.toolCallId,toolName:p,input:d.state==="output-error"?(a=d.input)!=null?a:d.rawInput:d.input,providerExecuted:d.providerExecuted,...d.callProviderMetadata!=null?{providerOptions:d.callProviderMetadata}:{}}),d.providerExecuted===!0&&(d.state==="output-available"||d.state==="output-error")&&u.push({type:"tool-result",toolCallId:d.toolCallId,toolName:p,output:Tn({output:d.state==="output-error"?d.errorText:d.output,tool:(s=t?.tools)==null?void 0:s[p],errorMode:d.state==="output-error"?"json":"none"})}))}else if(Ps(d)){const p=(l=t?.convertDataPart)==null?void 0:l.call(t,d);p!=null&&u.push(p)}else{const p=d;throw new Error(`Unsupported part: ${p}`)}n.push({role:"assistant",content:u});const c=i.filter(d=>Zr(d)&&d.providerExecuted!==!0||d.type==="dynamic-tool");c.length>0&&n.push({role:"tool",content:c.map(d=>{var p;switch(d.state){case"output-error":case"output-available":{const f=UA(d);return{type:"tool-result",toolCallId:d.toolCallId,toolName:f,output:Tn({output:d.state==="output-error"?d.errorText:d.output,tool:(p=t?.tools)==null?void 0:p[f],errorMode:d.state==="output-error"?"text":"none"})}}default:return null}}).filter(d=>d!=null)}),i=[]},i=[];for(const a of o.parts)Cs(a)||lp(a)||js(a)||cp(a)||Ps(a)?i.push(a):a.type==="step-start"&&r();r();break}break}default:{const r=o.role;throw new Fj({originalMessage:o,message:`Unsupported role: ${r}`})}}return n}Eo({prefix:"aiobj",size:24});Eo({prefix:"aiobj",size:24});var XA={};Sj(XA,{object:()=>tR,text:()=>eR});var eR=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),tR=({schema:e})=>{const t=Za(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:n}){const o=await qx(n);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value};default:{const r=o.state;throw new Error(`Unsupported parse state: ${r}`)}}},async parseOutput({text:n},o){const r=await _r({text:n});if(!r.success)throw new np({message:"No object generated: could not parse the response.",cause:r.error,text:n,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=await ar({value:r.value,schema:t});if(!i.success)throw new np({message:"No object generated: response did not match schema.",cause:i.error,text:n,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.value}}},rR={word:/\S+\s+/m,line:/\n+/m};function nR({delayInMs:e=10,chunking:t="word",_internal:{delay:n=Nw}={}}={}){let o;if(typeof t=="function")o=r=>{const i=t(r);if(i==null)return null;if(!i.length)throw new Error("Chunking function must return a non-empty string.");if(!r.startsWith(i))throw new Error(`Chunking function must return a match that is a prefix of the buffer. Received: "${i}" expected to start with "${r}"`);return i};else{const r=typeof t=="string"?rR[t]:t;if(r==null)throw new Zi({argument:"chunking",message:`Chunking must be "word" or "line" or a RegExp. Received: ${t}`});o=i=>{const a=r.exec(i);return a?i.slice(0,a.index)+a?.[0]:null}}return()=>{let r="",i="";return new TransformStream({async transform(a,s){if(a.type!=="text-delta"){r.length>0&&(s.enqueue({type:"text-delta",text:r,id:i}),r=""),s.enqueue(a);return}a.id!==i&&r.length>0&&(s.enqueue({type:"text-delta",text:r,id:i}),r=""),r+=a.text,i=a.id;let l;for(;(l=o(r))!=null;)s.enqueue({type:"text-delta",text:l,id:i}),r=r.slice(l.length),await n(e)}})}}const oR=e=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n.description?{description:n.description}:void 0,parameters:n.parameters instanceof hi.ZodType?hi.toJSONSchema(n.parameters):n.parameters}])),iR=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>!t.disabled&&t.type!=="backend")),aR=(e,t)=>U.makeAssistantTool({...e,toolName:t});var Oo=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},sR={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},uR=class{#e=sR;#t=!1;setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&this.#t&&e!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:e}),this.#e=e,process.env.NODE_ENV!=="production"&&(this.#t=!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},hr=new uR;function lR(e){setTimeout(e,0)}var xr=typeof window>"u"||"Deno"in globalThis;function Je(){}function cR(e,t){return typeof e=="function"?e(t):e}function vu(e){return typeof e=="number"&&e>=0&&e!==1/0}function Vx(e,t){return Math.max(e+(t||0)-Date.now(),0)}function nr(e,t){return typeof e=="function"?e(t):e}function at(e,t){return typeof e=="function"?e(t):e}function fp(e,t){const{type:n="all",exact:o,fetchStatus:r,predicate:i,queryKey:a,stale:s}=e;if(a){if(o){if(t.queryHash!==Uc(a,t.options))return!1}else if(!Hn(t.queryKey,a))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof s=="boolean"&&t.isStale()!==s||r&&r!==t.state.fetchStatus||i&&!i(t))}function pp(e,t){const{exact:n,status:o,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Wn(t.options.mutationKey)!==Wn(i))return!1}else if(!Hn(t.options.mutationKey,i))return!1}return!(o&&t.state.status!==o||r&&!r(t))}function Uc(e,t){return(t?.queryKeyHashFn||Wn)(e)}function Wn(e){return JSON.stringify(e,(t,n)=>_u(n)?Object.keys(n).sort().reduce((o,r)=>(o[r]=n[r],o),{}):n)}function Hn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Hn(e[n],t[n])):!1}var dR=Object.prototype.hasOwnProperty;function yu(e,t){if(e===t)return e;const n=mp(e)&&mp(t);if(!n&&!(_u(e)&&_u(t)))return t;const r=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),a=i.length,s=n?new Array(a):{};let l=0;for(let u=0;u<a;u++){const c=n?u:i[u],d=e[c],p=t[c];if(d===p){s[c]=d,(n?u<r:dR.call(e,c))&&l++;continue}if(d===null||p===null||typeof d!="object"||typeof p!="object"){s[c]=p;continue}const f=yu(d,p);s[c]=f,f===d&&l++}return r===a&&l===r?e:s}function bu(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function mp(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function _u(e){if(!hp(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!hp(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function hp(e){return Object.prototype.toString.call(e)==="[object Object]"}function fR(e){return new Promise(t=>{hr.setTimeout(t,e)})}function wu(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return yu(e,t)}catch(o){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${o}`),o}return yu(e,t)}return t}function pR(e,t,n=0){const o=[...e,t];return n&&o.length>n?o.slice(1):o}function mR(e,t,n=0){const o=[t,...e];return n&&o.length>n?o.slice(0,-1):o}var Ei=Symbol();function Bx(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Ei&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ei?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function hR(e,t){return typeof e=="function"?e(...t):!!e}var gR=class extends Oo{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!xr&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},Lc=new gR;function xu(){let e,t;const n=new Promise((r,i)=>{e=r,t=i});n.status="pending",n.catch(()=>{});function o(r){Object.assign(n,r),delete n.resolve,delete n.reject}return n.resolve=r=>{o({status:"fulfilled",value:r}),e(r)},n.reject=r=>{o({status:"rejected",reason:r}),t(r)},n}var vR=lR;function yR(){let e=[],t=0,n=s=>{s()},o=s=>{s()},r=vR;const i=s=>{t?e.push(s):r(()=>{n(s)})},a=()=>{const s=e;e=[],s.length&&r(()=>{o(()=>{s.forEach(l=>{n(l)})})})};return{batch:s=>{let l;t++;try{l=s()}finally{t--,t||a()}return l},batchCalls:s=>(...l)=>{i(()=>{s(...l)})},schedule:i,setNotifyFunction:s=>{n=s},setBatchNotifyFunction:s=>{o=s},setScheduler:s=>{r=s}}}var ze=yR(),bR=class extends Oo{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!xr&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#e}},Oi=new bR;function _R(e){return Math.min(1e3*2**e,3e4)}function Jx(e){return(e??"online")==="online"?Oi.isOnline():!0}var $u=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Wx(e){let t=!1,n=0,o;const r=xu(),i=()=>r.status!=="pending",a=m=>{if(!i()){const b=new $u(m);p(b),e.onCancel?.(b)}},s=()=>{t=!0},l=()=>{t=!1},u=()=>Lc.isFocused()&&(e.networkMode==="always"||Oi.isOnline())&&e.canRun(),c=()=>Jx(e.networkMode)&&e.canRun(),d=m=>{i()||(o?.(),r.resolve(m))},p=m=>{i()||(o?.(),r.reject(m))},f=()=>new Promise(m=>{o=b=>{(i()||u())&&m(b)},e.onPause?.()}).then(()=>{o=void 0,i()||e.onContinue?.()}),g=()=>{if(i())return;let m;const b=n===0?e.initialPromise:void 0;try{m=b??e.fn()}catch(y){m=Promise.reject(y)}Promise.resolve(m).then(d).catch(y=>{if(i())return;const x=e.retry??(xr?0:3),$=e.retryDelay??_R,v=typeof $=="function"?$(n,y):$,k=x===!0||typeof x=="number"&&n<x||typeof x=="function"&&x(n,y);if(t||!k){p(y);return}n++,e.onFail?.(n,y),fR(v).then(()=>u()?void 0:f()).then(()=>{t?p(y):g()})})};return{promise:r,status:()=>r.status,cancel:a,continue:()=>(o?.(),r),cancelRetry:s,continueRetry:l,canStart:c,start:()=>(c()?g():f().then(g),r)}}var Hx=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),vu(this.gcTime)&&(this.#e=hr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(xr?1/0:300*1e3))}clearGcTimeout(){this.#e&&(hr.clearTimeout(this.#e),this.#e=void 0)}},wR=class extends Hx{#e;#t;#r;#o;#n;#s;#a;constructor(e){super(),this.#a=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#o=e.client,this.#r=this.#o.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=vp(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){if(this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=vp(this.options);t.data!==void 0&&(this.setState(gp(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){const n=wu(this.state.data,e,this.options);return this.#i({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(Je).catch(Je):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>at(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ei||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>nr(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!Vx(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#a?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){const s=this.observers.find(l=>l.options.queryFn);s&&this.setOptions(s.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,o=s=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#a=!0,n.signal)})},r=()=>{const s=Bx(this.options,t),u=(()=>{const c={client:this.#o,queryKey:this.queryKey,meta:this.meta};return o(c),c})();return this.#a=!1,this.options.persister?this.options.persister(s,u,this):s(u)},a=(()=>{const s={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#o,state:this.state,fetchFn:r};return o(s),s})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#i({type:"fetch",meta:a.fetchOptions?.meta}),this.#n=Wx({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:s=>{s instanceof $u&&s.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(s,l)=>{this.#i({type:"failed",failureCount:s,error:l})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const s=await this.#n.start();if(s===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(s),this.#r.config.onSuccess?.(s,this),this.#r.config.onSettled?.(s,this.state.error,this),s}catch(s){if(s instanceof $u){if(s.silent)return this.#n.promise;if(s.revert){if(this.state.data===void 0)throw s;return this.state.data}}throw this.#i({type:"error",error:s}),this.#r.config.onError?.(s,this),this.#r.config.onSettled?.(this.state.data,s,this),s}finally{this.scheduleGc()}}#i(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Gx(n.data,this.options),fetchMeta:e.meta??null};case"success":const o={...n,...gp(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?o:void 0,o;case"error":const r=e.error;return{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),ze.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function Gx(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Jx(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function gp(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function vp(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,o=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var xR=class extends Oo{constructor(e,t){super(),this.options=t,this.#e=e,this.#i=null,this.#a=xu(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#r=void 0;#o=void 0;#n;#s;#a;#i;#h;#f;#p;#l;#c;#u;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),yp(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Su(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Su(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#_(),this.#w(),this.#t.removeObserver(this)}setOptions(e){const t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof at(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#t.setOptions(this.options),t._defaulted&&!bu(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const o=this.hasListeners();o&&bp(this.#t,n,this.options,t)&&this.#d(),this.updateResult(),o&&(this.#t!==n||at(this.options.enabled,this.#t)!==at(t.enabled,this.#t)||nr(this.options.staleTime,this.#t)!==nr(t.staleTime,this.#t))&&this.#g();const r=this.#v();o&&(this.#t!==n||at(this.options.enabled,this.#t)!==at(t.enabled,this.#t)||r!==this.#u)&&this.#y(r)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return SR(this,n)&&(this.#o=n,this.#s=this.options,this.#n=this.#t.state),n}getCurrentResult(){return this.#o}trackResult(e,t){return new Proxy(e,{get:(n,o)=>(this.trackProp(o),t?.(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,o))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#o))}#d(e){this.#x();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Je)),t}#g(){this.#_();const e=nr(this.options.staleTime,this.#t);if(xr||this.#o.isStale||!vu(e))return;const n=Vx(this.#o.dataUpdatedAt,e)+1;this.#l=hr.setTimeout(()=>{this.#o.isStale||this.updateResult()},n)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(e){this.#w(),this.#u=e,!(xr||at(this.options.enabled,this.#t)===!1||!vu(this.#u)||this.#u===0)&&(this.#c=hr.setInterval(()=>{(this.options.refetchIntervalInBackground||Lc.isFocused())&&this.#d()},this.#u))}#b(){this.#g(),this.#y(this.#v())}#_(){this.#l&&(hr.clearTimeout(this.#l),this.#l=void 0)}#w(){this.#c&&(hr.clearInterval(this.#c),this.#c=void 0)}createResult(e,t){const n=this.#t,o=this.options,r=this.#o,i=this.#n,a=this.#s,l=e!==n?e.state:this.#r,{state:u}=e;let c={...u},d=!1,p;if(t._optimisticResults){const T=this.hasListeners(),z=!T&&yp(e,t),Z=T&&bp(e,n,t,o);(z||Z)&&(c={...c,...Gx(u.data,e.options)}),t._optimisticResults==="isRestoring"&&(c.fetchStatus="idle")}let{error:f,errorUpdatedAt:g,status:m}=c;p=c.data;let b=!1;if(t.placeholderData!==void 0&&p===void 0&&m==="pending"){let T;r?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(T=r.data,b=!0):T=typeof t.placeholderData=="function"?t.placeholderData(this.#p?.state.data,this.#p):t.placeholderData,T!==void 0&&(m="success",p=wu(r?.data,T,t),d=!0)}if(t.select&&p!==void 0&&!b)if(r&&p===i?.data&&t.select===this.#h)p=this.#f;else try{this.#h=t.select,p=t.select(p),p=wu(r?.data,p,t),this.#f=p,this.#i=null}catch(T){this.#i=T}this.#i&&(f=this.#i,p=this.#f,g=Date.now(),m="error");const y=c.fetchStatus==="fetching",x=m==="pending",$=m==="error",v=x&&y,k=p!==void 0,I={status:m,fetchStatus:c.fetchStatus,isPending:x,isSuccess:m==="success",isError:$,isInitialLoading:v,isLoading:v,data:p,dataUpdatedAt:c.dataUpdatedAt,error:f,errorUpdatedAt:g,failureCount:c.fetchFailureCount,failureReason:c.fetchFailureReason,errorUpdateCount:c.errorUpdateCount,isFetched:c.dataUpdateCount>0||c.errorUpdateCount>0,isFetchedAfterMount:c.dataUpdateCount>l.dataUpdateCount||c.errorUpdateCount>l.errorUpdateCount,isFetching:y,isRefetching:y&&!x,isLoadingError:$&&!k,isPaused:c.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:$&&k,isStale:Zc(e,t),refetch:this.refetch,promise:this.#a,isEnabled:at(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const T=re=>{I.status==="error"?re.reject(I.error):I.data!==void 0&&re.resolve(I.data)},z=()=>{const re=this.#a=I.promise=xu();T(re)},Z=this.#a;switch(Z.status){case"pending":e.queryHash===n.queryHash&&T(Z);break;case"fulfilled":(I.status==="error"||I.data!==Z.value)&&z();break;case"rejected":(I.status!=="error"||I.error!==Z.reason)&&z();break}}return I}updateResult(){const e=this.#o,t=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#s=this.options,this.#n.data!==void 0&&(this.#p=this.#t),bu(t,e))return;this.#o=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,r=typeof o=="function"?o():o;if(r==="all"||!r&&!this.#m.size)return!0;const i=new Set(r??this.#m);return this.options.throwOnError&&i.add("error"),Object.keys(this.#o).some(a=>{const s=a;return this.#o[s]!==e[s]&&i.has(s)})};this.#$({listeners:n()})}#x(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const t=this.#t;this.#t=e,this.#r=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#$(e){ze.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#o)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function $R(e,t){return at(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function yp(e,t){return $R(e,t)||e.state.data!==void 0&&Su(e,t,t.refetchOnMount)}function Su(e,t,n){if(at(t.enabled,e)!==!1&&nr(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&Zc(e,t)}return!1}function bp(e,t,n,o){return(e!==t||at(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Zc(e,n)}function Zc(e,t){return at(t.enabled,e)!==!1&&e.isStaleByTime(nr(t.staleTime,e))}function SR(e,t){return!bu(e.getCurrentResult(),t)}function _p(e){return{onFetch:(t,n)=>{const o=t.options,r=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let s={pages:[],pageParams:[]},l=0;const u=async()=>{let c=!1;const d=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(t.signal.aborted?c=!0:t.signal.addEventListener("abort",()=>{c=!0}),t.signal)})},p=Bx(t.options,t.fetchOptions),f=async(g,m,b)=>{if(c)return Promise.reject();if(m==null&&g.pages.length)return Promise.resolve(g);const x=(()=>{const N={client:t.client,queryKey:t.queryKey,pageParam:m,direction:b?"backward":"forward",meta:t.options.meta};return d(N),N})(),$=await p(x),{maxPages:v}=t.options,k=b?mR:pR;return{pages:k(g.pages,$,v),pageParams:k(g.pageParams,m,v)}};if(r&&i.length){const g=r==="backward",m=g?IR:wp,b={pages:i,pageParams:a},y=m(o,b);s=await f(b,y,g)}else{const g=e??i.length;do{const m=l===0?a[0]??o.initialPageParam:wp(o,s);if(l>0&&m==null)break;s=await f(s,m),l++}while(l<g)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=u}}}function wp(e,{pages:t,pageParams:n}){const o=t.length-1;return t.length>0?e.getNextPageParam(t[o],t,n[o],n):void 0}function IR(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var kR=class extends Hx{#e;#t;#r;#o;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#r=e.mutationCache,this.#t=[],this.state=e.state||ER(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#o?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#n({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#o=Wx({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),onFail:(i,a)=>{this.#n({type:"failed",failureCount:i,error:a})},onPause:()=>{this.#n({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#r.canRun(this)});const o=this.state.status==="pending",r=!this.#o.canStart();try{if(o)t();else{this.#n({type:"pending",variables:e,isPaused:r}),await this.#r.config.onMutate?.(e,this,n);const a=await this.options.onMutate?.(e,n);a!==this.state.context&&this.#n({type:"pending",context:a,variables:e,isPaused:r})}const i=await this.#o.start();return await this.#r.config.onSuccess?.(i,e,this.state.context,this,n),await this.options.onSuccess?.(i,e,this.state.context,n),await this.#r.config.onSettled?.(i,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(i,null,e,this.state.context,n),this.#n({type:"success",data:i}),i}catch(i){try{throw await this.#r.config.onError?.(i,e,this.state.context,this,n),await this.options.onError?.(i,e,this.state.context,n),await this.#r.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,i,e,this.state.context,n),i}finally{this.#n({type:"error",error:i})}}finally{this.#r.runNext(this)}}#n(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),ze.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#r.notify({mutation:this,type:"updated",action:e})})}};function ER(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var OR=class extends Oo{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,n){const o=new kR({client:e,mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:n});return this.add(o),o}add(e){this.#e.add(e);const t=Wo(e);if(typeof t=="string"){const n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=Wo(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const o=n.indexOf(e);o!==-1&&n.splice(o,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Wo(e);if(typeof t=="string"){const o=this.#t.get(t)?.find(r=>r.state.status==="pending");return!o||o===e}else return!0}runNext(e){const t=Wo(e);return typeof t=="string"?this.#t.get(t)?.find(o=>o!==e&&o.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ze.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>pp(t,n))}findAll(e={}){return this.getAll().filter(t=>pp(e,t))}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return ze.batch(()=>Promise.all(e.map(t=>t.continue().catch(Je))))}};function Wo(e){return e.options.scope?.id}var TR=class extends Oo{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){const o=t.queryKey,r=t.queryHash??Uc(o,t);let i=this.get(r);return i||(i=new wR({client:e,queryKey:o,queryHash:r,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(o)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ze.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>fp(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>fp(e,n)):t}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ze.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ze.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},NR=class{#e;#t;#r;#o;#n;#s;#a;#i;constructor(e={}){this.#e=e.queryCache||new TR,this.#t=e.mutationCache||new OR,this.#r=e.defaultOptions||{},this.#o=new Map,this.#n=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#a=Lc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=Oi.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#a?.(),this.#a=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#e.build(this,t),o=n.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(nr(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>{const o=n.data;return[t,o]})}setQueryData(e,t,n){const o=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(o.queryHash)?.state.data,a=cR(t,i);if(a!==void 0)return this.#e.build(this,o).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ze.batch(()=>this.#e.findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;ze.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return ze.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},o=ze.batch(()=>this.#e.findAll(e).map(r=>r.cancel(n)));return Promise.all(o).then(Je).catch(Je)}invalidateQueries(e,t={}){return ze.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},o=ze.batch(()=>this.#e.findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,n);return n.throwOnError||(i=i.catch(Je)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(o).then(Je)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(nr(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Je).catch(Je)}fetchInfiniteQuery(e){return e.behavior=_p(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Je).catch(Je)}ensureInfiniteQueryData(e){return e.behavior=_p(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Oi.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#o.set(Wn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#o.values()],n={};return t.forEach(o=>{Hn(e,o.queryKey)&&Object.assign(n,o.defaultOptions)}),n}setMutationDefaults(e,t){this.#n.set(Wn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#n.values()],n={};return t.forEach(o=>{Hn(e,o.mutationKey)&&Object.assign(n,o.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Uc(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Ei&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Kx=_.createContext(void 0),Yx=e=>{const t=_.useContext(Kx);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},PR=({client:e,children:t})=>(_.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),h.jsx(Kx.Provider,{value:e,children:t})),Qx=_.createContext(!1),CR=()=>_.useContext(Qx);Qx.Provider;function jR(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var AR=_.createContext(jR()),RR=()=>_.useContext(AR),zR=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},MR=e=>{_.useEffect(()=>{e.clearReset()},[e])},DR=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(r&&e.data===void 0||hR(n,[e.error,o])),UR=e=>{if(e.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...r)=>n(o(...r)):n(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},LR=(e,t)=>e.isLoading&&e.isFetching&&!t,ZR=(e,t)=>e?.suspense&&t.isPending,xp=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function FR(e,t,n){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const o=CR(),r=RR(),i=Yx(),a=i.defaultQueryOptions(e);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a),process.env.NODE_ENV!=="production"&&(a.queryFn||console.error(`[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),a._optimisticResults=o?"isRestoring":"optimistic",UR(a),zR(a,r),MR(r);const s=!i.getQueryCache().get(a.queryHash),[l]=_.useState(()=>new t(i,a)),u=l.getOptimisticResult(a),c=!o&&e.subscribed!==!1;if(_.useSyncExternalStore(_.useCallback(d=>{const p=c?l.subscribe(ze.batchCalls(d)):Je;return l.updateResult(),p},[l,c]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),_.useEffect(()=>{l.setOptions(a)},[a,l]),ZR(a,u))throw xp(a,l,r);if(DR({result:u,errorResetBoundary:r,throwOnError:a.throwOnError,query:i.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw u.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,u),a.experimental_prefetchInRender&&!xr&&LR(u,o)&&(s?xp(a,l,r):i.getQueryCache().get(a.queryHash)?.promise)?.catch(Je).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?u:l.trackResult(u)}function Xx(e,t){return FR(e,xR)}const e$=({getSession:e,projectSlug:t})=>{const n=Yx(),o=["chatSession",t],r=n.getQueryState(o),i=r?.data!==void 0,a=r?.dataUpdatedAt??0,l=i&&Date.now()-a>1/0,u=!i||l,{data:c}=Xx({queryKey:o,queryFn:e,enabled:u,staleTime:1/0,gcTime:1/0});return c??null};var qR=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const r=()=>{const i=n.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=n[Math.random()*i|0];return a.join("")};if(e==null)return r;if(n.includes(o))throw new Zi({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${n}".`});return()=>`${e}${o}${r()}`};qR();function t$(e=globalThis){var t,n,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(n=e.process)==null?void 0:n.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function VR(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,o)=>{t[o.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,o]of e)o!=null&&(t[n.toLowerCase()]=o)}return t}function r$(e,...t){const n=new Headers(VR(e)),o=n.get("user-agent")||"";return n.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}var BR=Symbol.for("vercel.ai.validator");function JR(e){return{...e,type:"dynamic"}}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");var WR=Symbol.for("vercel.ai.schema");function HR(e,{validate:t}={}){return{[WR]:!0,_type:void 0,[BR]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}let Fc;Fc=globalThis.crypto;async function GR(e){return(await Fc).getRandomValues(new Uint8Array(e))}async function KR(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";let n="";const o=await GR(e);for(let r=0;r<e;r++){const i=o[r]%t.length;n+=t[i]}return n}async function YR(e){return await KR(e)}async function QR(e){const t=await(await Fc).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function XR(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;const t=await YR(e),n=await QR(t);return{code_verifier:t,code_challenge:n}}var ez="AI_MCPClientError",n$=`vercel.ai.error.${ez}`,tz=Symbol.for(n$),$p,Sp,se=class extends(Sp=Y,$p=tz,Sp){constructor({name:e="MCPClientError",message:t,cause:n,data:o,code:r}){super({name:e,message:t,cause:n}),this[$p]=!0,this.data=o,this.code=r}static isInstance(e){return Y.hasMarker(e,n$)}},ln="2025-06-18",rz=[ln,"2025-03-26","2024-11-05"],nz=tr({name:w(),version:w()}),qa=tr({_meta:ee(E({}).loose())}),Bt=qa,o$=E({method:w(),params:ee(qa)}),i$=E({applyDefaults:ee(de())}).loose(),oz=tr({experimental:ee(E({}).loose()),logging:ee(E({}).loose()),prompts:ee(tr({listChanged:ee(de())})),resources:ee(tr({subscribe:ee(de()),listChanged:ee(de())})),tools:ee(tr({listChanged:ee(de())})),elicitation:ee(i$)});E({elicitation:ee(i$)}).loose();var iz=Bt.extend({protocolVersion:w(),capabilities:oz,serverInfo:nz,instructions:ee(w())}),qc=Bt.extend({nextCursor:ee(w())}),az=E({name:w(),description:ee(w()),inputSchema:E({type:C("object"),properties:ee(E({}).loose())}).loose()}).loose(),sz=qc.extend({tools:R(az)}),a$=E({type:C("text"),text:w()}).loose(),s$=E({type:C("image"),data:Sa(),mimeType:w()}).loose(),uz=E({uri:w(),name:w(),title:ee(w()),description:ee(w()),mimeType:ee(w()),size:ee(q())}).loose(),lz=qc.extend({resources:R(uz)}),u$=E({uri:w(),name:ee(w()),title:ee(w()),mimeType:ee(w())}).loose(),l$=u$.extend({text:w()}),c$=u$.extend({blob:Sa()}),d$=E({type:C("resource"),resource:W([l$,c$])}).loose(),cz=Bt.extend({content:R(W([a$,s$,d$])),isError:de().default(!1).optional()}).or(Bt.extend({toolResult:$e()})),dz=E({uriTemplate:w(),name:w(),title:ee(w()),description:ee(w()),mimeType:ee(w())}).loose(),fz=Bt.extend({resourceTemplates:R(dz)}),pz=Bt.extend({contents:R(W([l$,c$]))}),mz=E({name:w(),description:ee(w()),required:ee(de())}).loose(),hz=E({name:w(),title:ee(w()),description:ee(w()),arguments:ee(R(mz))}).loose(),gz=qc.extend({prompts:R(hz)}),vz=E({role:W([C("user"),C("assistant")]),content:W([a$,s$,d$])}).loose(),yz=Bt.extend({description:ee(w()),messages:R(vz)}),bz=qa.extend({message:w(),requestedSchema:$e()}),Ip=o$.extend({method:C("elicitation/create"),params:bz}),_z=Bt.extend({action:W([C("accept"),C("decline"),C("cancel")]),content:ee(Xe(w(),$e()))}),Va="2.0",wz=E({jsonrpc:C(Va),id:W([w(),q().int()])}).merge(o$).strict(),xz=E({jsonrpc:C(Va),id:W([w(),q().int()]),result:Bt}).strict(),$z=E({jsonrpc:C(Va),id:W([w(),q().int()]),error:E({code:q().int(),message:w(),data:ee($e())})}).strict(),Sz=E({jsonrpc:C(Va)}).merge(E({method:w(),params:ee(qa)})).strict(),En=W([wz,Sz,xz,$z]),f$=typeof __PACKAGE_VERSION__<"u"?__PACKAGE_VERSION__:"0.0.0-test",p$=E({access_token:w(),id_token:w().optional(),token_type:w(),expires_in:q().optional(),scope:w().optional(),refresh_token:w().optional()}).strip(),He=w().url().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:h_.custom,message:"URL must be parseable",fatal:!0}),zu}).refine(e=>{const t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),Iz=E({resource:w().url(),authorization_servers:R(He).optional(),jwks_uri:w().url().optional(),scopes_supported:R(w()).optional(),bearer_methods_supported:R(w()).optional(),resource_signing_alg_values_supported:R(w()).optional(),resource_name:w().optional(),resource_documentation:w().optional(),resource_policy_uri:w().url().optional(),resource_tos_uri:w().url().optional(),tls_client_certificate_bound_access_tokens:de().optional(),authorization_details_types_supported:R(w()).optional(),dpop_signing_alg_values_supported:R(w()).optional(),dpop_bound_access_tokens_required:de().optional()}).passthrough(),m$=E({issuer:w(),authorization_endpoint:He,token_endpoint:He,registration_endpoint:He.optional(),scopes_supported:R(w()).optional(),response_types_supported:R(w()),grant_types_supported:R(w()).optional(),code_challenge_methods_supported:R(w()),token_endpoint_auth_methods_supported:R(w()).optional(),token_endpoint_auth_signing_alg_values_supported:R(w()).optional()}).passthrough(),kz=E({issuer:w(),authorization_endpoint:He,token_endpoint:He,userinfo_endpoint:He.optional(),jwks_uri:He,registration_endpoint:He.optional(),scopes_supported:R(w()).optional(),response_types_supported:R(w()),grant_types_supported:R(w()).optional(),subject_types_supported:R(w()),id_token_signing_alg_values_supported:R(w()),claims_supported:R(w()).optional(),token_endpoint_auth_methods_supported:R(w()).optional()}).passthrough(),Ez=kz.merge(m$.pick({code_challenge_methods_supported:!0})),Oz=E({client_id:w(),client_secret:w().optional(),client_id_issued_at:q().optional(),client_secret_expires_at:q().optional()}).strip(),Tz=E({redirect_uris:R(He),token_endpoint_auth_method:w().optional(),grant_types:R(w()).optional(),response_types:R(w()).optional(),client_name:w().optional(),client_uri:He.optional(),logo_uri:He.optional(),scope:w().optional(),contacts:R(w()).optional(),tos_uri:He.optional(),policy_uri:w().optional(),jwks_uri:He.optional(),jwks:Pe().optional(),software_id:w().optional(),software_version:w().optional(),software_statement:w().optional()}).strip(),Nz=E({error:w(),error_description:w().optional(),error_uri:w().optional()}),Pz=Tz.merge(Oz),Cz="AI_MCPClientOAuthError",h$=`vercel.ai.error.${Cz}`,jz=Symbol.for(h$),kp,Ep,To=class extends(Ep=Y,kp=jz,Ep){constructor({name:e="MCPClientOAuthError",message:t,cause:n}){super({name:e,message:t,cause:n}),this[kp]=!0}static isInstance(e){return Y.hasMarker(e,h$)}},tn=class extends To{};tn.errorCode="server_error";var Ti=class extends To{};Ti.errorCode="invalid_client";var Ni=class extends To{};Ni.errorCode="invalid_grant";var Pi=class extends To{};Pi.errorCode="unauthorized_client";var Az={[tn.errorCode]:tn,[Ti.errorCode]:Ti,[Ni.errorCode]:Ni,[Pi.errorCode]:Pi};function Rz(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function zz({requestedResource:e,configuredResource:t}){const n=typeof e=="string"?new URL(e):new URL(e.href),o=typeof t=="string"?new URL(t):new URL(t.href);if(n.origin!==o.origin||n.pathname.length<o.pathname.length)return!1;const r=n.pathname.endsWith("/")?n.pathname:n.pathname+"/",i=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return r.startsWith(i)}var Ci=class extends Error{constructor(e="Unauthorized"){super(e),this.name="UnauthorizedError"}};function ji(e){var t;const n=(t=e.headers.get("www-authenticate"))!=null?t:e.headers.get("WWW-Authenticate");if(!n)return;const[o,r]=n.split(" ");if(o.toLowerCase()!=="bearer"||!r)return;const i=/resource_metadata="([^"]*)"/,a=n.match(i);if(a)try{return new URL(a[1])}catch{return}}function Mz(e,t="",n={}){return t.endsWith("/")&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function Vc(e,t,n=fetch){try{return await n(e,{headers:t})}catch(o){if(o instanceof TypeError)return t?Vc(e,void 0,n):void 0;throw o}}async function Op(e,t,n=fetch){return await Vc(e,{"MCP-Protocol-Version":t},n)}function Dz(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function Uz(e,t,n,o){var r,i;const a=new URL(e),s=(r=o?.protocolVersion)!=null?r:ln;let l;if(o?.metadataUrl)l=new URL(o.metadataUrl);else{const c=Mz(t,a.pathname);l=new URL(c,(i=o?.metadataServerUrl)!=null?i:a),l.search=a.search}let u=await Op(l,s,n);if(!o?.metadataUrl&&Dz(u,a.pathname)){const c=new URL(`/.well-known/${t}`,a);u=await Op(c,s,n)}return u}async function Lz(e,t,n=fetch){const o=await Uz(e,"oauth-protected-resource",n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!o||o.status===404)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!o.ok)throw new Error(`HTTP ${o.status} trying to load well-known OAuth protected resource metadata.`);return Iz.parse(await o.json())}function Zz(e){const t=typeof e=="string"?new URL(e):e,n=t.pathname!=="/",o=[];if(!n)return o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),o.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),o;let r=t.pathname;return r.endsWith("/")&&(r=r.slice(0,-1)),o.push({url:new URL(`/.well-known/oauth-authorization-server${r}`,t.origin),type:"oauth"}),o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),o.push({url:new URL(`/.well-known/openid-configuration${r}`,t.origin),type:"oidc"}),o.push({url:new URL(`${r}/.well-known/openid-configuration`,t.origin),type:"oidc"}),o}async function Fz(e,{fetchFn:t=fetch,protocolVersion:n=ln}={}){var o;const r={"MCP-Protocol-Version":n},i=Zz(e);for(const{url:a,type:s}of i){const l=await Vc(a,r,t);if(l){if(!l.ok){if(l.status>=400&&l.status<500)continue;throw new Error(`HTTP ${l.status} trying to load ${s==="oauth"?"OAuth":"OpenID provider"} metadata from ${a}`)}if(s==="oauth")return m$.parse(await l.json());{const u=Ez.parse(await l.json());if(!((o=u.code_challenge_methods_supported)!=null&&o.includes("S256")))throw new Error(`Incompatible OIDC provider at ${a}: does not support S256 code challenge method required by MCP specification`);return u}}}}async function qz(e,{metadata:t,clientInformation:n,redirectUrl:o,scope:r,state:i,resource:a}){const s="code",l="S256";let u;if(t){if(u=new URL(t.authorization_endpoint),!t.response_types_supported.includes(s))throw new Error(`Incompatible auth server: does not support response type ${s}`);if(!t.code_challenge_methods_supported||!t.code_challenge_methods_supported.includes(l))throw new Error(`Incompatible auth server: does not support code challenge method ${l}`)}else u=new URL("/authorize",e);const c=await XR(),d=c.code_verifier,p=c.code_challenge;return u.searchParams.set("response_type",s),u.searchParams.set("client_id",n.client_id),u.searchParams.set("code_challenge",p),u.searchParams.set("code_challenge_method",l),u.searchParams.set("redirect_uri",String(o)),i&&u.searchParams.set("state",i),r&&u.searchParams.set("scope",r),r?.includes("offline_access")&&u.searchParams.append("prompt","consent"),a&&u.searchParams.set("resource",a.href),{authorizationUrl:u,codeVerifier:d}}function g$(e,t){const n=e.client_secret!==void 0;return t.length===0?n?"client_secret_post":"none":n&&t.includes("client_secret_basic")?"client_secret_basic":n&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":n?"client_secret_post":"none"}function v$(e,t,n,o){const{client_id:r,client_secret:i}=t;switch(e){case"client_secret_basic":Vz(r,i,n);return;case"client_secret_post":Bz(r,i,o);return;case"none":Jz(r,o);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function Vz(e,t,n){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");const o=btoa(`${e}:${t}`);n.set("Authorization",`Basic ${o}`)}function Bz(e,t,n){n.set("client_id",e),t&&n.set("client_secret",t)}function Jz(e,t){t.set("client_id",e)}async function Bc(e){const t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{const o=Nz.parse(JSON.parse(n)),{error:r,error_description:i,error_uri:a}=o,s=Az[r]||tn;return new s({message:i||"",cause:a})}catch(o){const r=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${o}. Raw body: ${n}`;return new tn({message:r})}}async function Wz(e,{metadata:t,clientInformation:n,authorizationCode:o,codeVerifier:r,redirectUri:i,resource:a,addClientAuthentication:s,fetchFn:l}){var u;const c="authorization_code",d=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e);if(t?.grant_types_supported&&!t.grant_types_supported.includes(c))throw new Error(`Incompatible auth server: does not support grant type ${c}`);const p=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),f=new URLSearchParams({grant_type:c,code:o,code_verifier:r,redirect_uri:String(i)});if(s)s(p,f,e,t);else{const m=(u=t?.token_endpoint_auth_methods_supported)!=null?u:[],b=g$(n,m);v$(b,n,p,f)}a&&f.set("resource",a.href);const g=await(l??fetch)(d,{method:"POST",headers:p,body:f});if(!g.ok)throw await Bc(g);return p$.parse(await g.json())}async function Hz(e,{metadata:t,clientInformation:n,refreshToken:o,resource:r,addClientAuthentication:i,fetchFn:a}){var s;const l="refresh_token";let u;if(t){if(u=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(l))throw new Error(`Incompatible auth server: does not support grant type ${l}`)}else u=new URL("/token",e);const c=new Headers({"Content-Type":"application/x-www-form-urlencoded"}),d=new URLSearchParams({grant_type:l,refresh_token:o});if(i)i(c,d,e,t);else{const f=(s=t?.token_endpoint_auth_methods_supported)!=null?s:[],g=g$(n,f);v$(g,n,c,d)}r&&d.set("resource",r.href);const p=await(a??fetch)(u,{method:"POST",headers:c,body:d});if(!p.ok)throw await Bc(p);return p$.parse({refresh_token:o,...await p.json()})}async function Gz(e,{metadata:t,clientMetadata:n,fetchFn:o}){let r;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");r=new URL(t.registration_endpoint)}else r=new URL("/register",e);const i=await(o??fetch)(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok)throw await Bc(i);return Pz.parse(await i.json())}async function Ai(e,t){var n,o;try{return await As(e,t)}catch(r){if(r instanceof Ti||r instanceof Pi)return await((n=e.invalidateCredentials)==null?void 0:n.call(e,"all")),await As(e,t);if(r instanceof Ni)return await((o=e.invalidateCredentials)==null?void 0:o.call(e,"tokens")),await As(e,t);throw r}}async function Kz(e,t,n){const o=Rz(e);if(t.validateResourceURL)return await t.validateResourceURL(o,n?.resource);if(n){if(!zz({requestedResource:o,configuredResource:n.resource}))throw new Error(`Protected resource ${n.resource} does not match expected ${o} (or origin)`);return new URL(n.resource)}}async function As(e,{serverUrl:t,authorizationCode:n,scope:o,resourceMetadataUrl:r,fetchFn:i}){let a,s;try{a=await Lz(t,{resourceMetadataUrl:r},i),a.authorization_servers&&a.authorization_servers.length>0&&(s=a.authorization_servers[0])}catch{}s||(s=t);const l=await Kz(t,e,a),u=await Fz(s,{fetchFn:i});let c=await Promise.resolve(e.clientInformation());if(!c){if(n!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const m=await Gz(s,{metadata:u,clientMetadata:e.clientMetadata,fetchFn:i});await e.saveClientInformation(m),c=m}if(n!==void 0){const m=await e.codeVerifier(),b=await Wz(s,{metadata:u,clientInformation:c,authorizationCode:n,codeVerifier:m,redirectUri:e.redirectUrl,resource:l,addClientAuthentication:e.addClientAuthentication,fetchFn:i});return await e.saveTokens(b),"AUTHORIZED"}const d=await e.tokens();if(d?.refresh_token)try{const m=await Hz(s,{metadata:u,clientInformation:c,refreshToken:d.refresh_token,resource:l,addClientAuthentication:e.addClientAuthentication,fetchFn:i});return await e.saveTokens(m),"AUTHORIZED"}catch(m){if(!(!(m instanceof To)||m instanceof tn))throw m}const p=e.state?await e.state():void 0,{authorizationUrl:f,codeVerifier:g}=await qz(s,{metadata:u,clientInformation:c,state:p,redirectUrl:e.redirectUrl,scope:o||e.clientMetadata.scope,resource:l});return await e.saveCodeVerifier(g),await e.redirectToAuthorization(f),"REDIRECT"}var Yz=class{constructor({url:e,headers:t,authProvider:n}){this.connected=!1,this.url=new URL(e),this.headers=t,this.authProvider=n}async commonHeaders(e){const t={...this.headers,...e,"mcp-protocol-version":ln};if(this.authProvider){const n=await this.authProvider.tokens();n?.access_token&&(t.Authorization=`Bearer ${n.access_token}`)}return r$(t,`ai-sdk/${f$}`,t$())}async start(){return new Promise((e,t)=>{if(this.connected)return e();this.abortController=new AbortController;const n=async(o=!1)=>{var r,i,a,s,l;try{const u=await this.commonHeaders({Accept:"text/event-stream"}),c=await fetch(this.url.href,{headers:u,signal:(r=this.abortController)==null?void 0:r.signal});if(c.status===401&&this.authProvider&&!o){this.resourceMetadataUrl=ji(c);try{if(await Ai(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const m=new Ci;return(i=this.onerror)==null||i.call(this,m),t(m)}}catch(g){return(a=this.onerror)==null||a.call(this,g),t(g)}return n(!0)}if(!c.ok||!c.body){let g=`MCP SSE Transport Error: ${c.status} ${c.statusText}`;c.status===405&&(g+=". This server does not support SSE transport. Try using `http` transport instead");const m=new se({message:g});return(s=this.onerror)==null||s.call(this,m),t(m)}const p=c.body.pipeThrough(new TextDecoderStream).pipeThrough(new Nn).getReader(),f=async()=>{var g,m,b;try{for(;;){const{done:y,value:x}=await p.read();if(y){if(this.connected)throw this.connected=!1,new se({message:"MCP SSE Transport Error: Connection closed unexpectedly"});return}const{event:$,data:v}=x;if($==="endpoint"){if(this.endpoint=new URL(v,this.url),this.endpoint.origin!==this.url.origin)throw new se({message:`MCP SSE Transport Error: Endpoint origin does not match connection origin: ${this.endpoint.origin}`});this.connected=!0,e()}else if($==="message")try{const k=En.parse(JSON.parse(v));(g=this.onmessage)==null||g.call(this,k)}catch(k){const N=new se({message:"MCP SSE Transport Error: Failed to parse message",cause:k});(m=this.onerror)==null||m.call(this,N)}}}catch(y){if(y instanceof Error&&y.name==="AbortError")return;(b=this.onerror)==null||b.call(this,y),t(y)}};this.sseConnection={close:()=>p.cancel()},f()}catch(u){if(u instanceof Error&&u.name==="AbortError")return;(l=this.onerror)==null||l.call(this,u),t(u)}};n()})}async close(){var e,t,n;this.connected=!1,(e=this.sseConnection)==null||e.close(),(t=this.abortController)==null||t.abort(),(n=this.onclose)==null||n.call(this)}async send(e){if(!this.endpoint||!this.connected)throw new se({message:"MCP SSE Transport Error: Not connected"});const t=this.endpoint,n=async(o=!1)=>{var r,i,a,s,l;try{const c={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json"}),body:JSON.stringify(e),signal:(r=this.abortController)==null?void 0:r.signal},d=await fetch(t,c);if(d.status===401&&this.authProvider&&!o){this.resourceMetadataUrl=ji(d);try{if(await Ai(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const f=new Ci;(i=this.onerror)==null||i.call(this,f);return}}catch(p){(a=this.onerror)==null||a.call(this,p);return}return n(!0)}if(!d.ok){const p=await d.text().catch(()=>null),f=new se({message:`MCP SSE Transport Error: POSTing to endpoint (HTTP ${d.status}): ${p}`});(s=this.onerror)==null||s.call(this,f);return}}catch(u){(l=this.onerror)==null||l.call(this,u);return}};await n()}},Qz=class{constructor({url:e,headers:t,authProvider:n}){this.inboundReconnectAttempts=0,this.reconnectionOptions={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},this.url=new URL(e),this.headers=t,this.authProvider=n}async commonHeaders(e){const t={...this.headers,...e,"mcp-protocol-version":ln};if(this.sessionId&&(t["mcp-session-id"]=this.sessionId),this.authProvider){const n=await this.authProvider.tokens();n?.access_token&&(t.Authorization=`Bearer ${n.access_token}`)}return r$(t,`ai-sdk/${f$}`,t$())}async start(){if(this.abortController)throw new se({message:"MCP HTTP Transport Error: Transport already started. Note: client.connect() calls start() automatically."});this.abortController=new AbortController,this.openInboundSse()}async close(){var e,t,n;(e=this.inboundSseConnection)==null||e.close();try{if(this.sessionId&&this.abortController&&!this.abortController.signal.aborted){const o=await this.commonHeaders({});await fetch(this.url,{method:"DELETE",headers:o,signal:this.abortController.signal}).catch(()=>{})}}catch{}(t=this.abortController)==null||t.abort(),(n=this.onclose)==null||n.call(this)}async send(e){const t=async(n=!1)=>{var o,r,i,a,s,l,u;try{const d={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json",Accept:"application/json, text/event-stream"}),body:JSON.stringify(e),signal:(o=this.abortController)==null?void 0:o.signal},p=await fetch(this.url,d),f=p.headers.get("mcp-session-id");if(f&&(this.sessionId=f),p.status===401&&this.authProvider&&!n){this.resourceMetadataUrl=ji(p);try{if(await Ai(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED")throw new Ci}catch(b){throw(r=this.onerror)==null||r.call(this,b),b}return t(!0)}if(p.status===202){this.inboundSseConnection||this.openInboundSse();return}if(!p.ok){const b=await p.text().catch(()=>null);let y=`MCP HTTP Transport Error: POSTing to endpoint (HTTP ${p.status}): ${b}`;p.status===404&&(y+=". This server does not support HTTP transport. Try using `sse` transport instead");const x=new se({message:y});throw(i=this.onerror)==null||i.call(this,x),x}const g=p.headers.get("content-type")||"";if(g.includes("application/json")){const b=await p.json(),y=Array.isArray(b)?b.map(x=>En.parse(x)):[En.parse(b)];for(const x of y)(a=this.onmessage)==null||a.call(this,x);return}if(g.includes("text/event-stream")){if(!p.body){const $=new se({message:"MCP HTTP Transport Error: text/event-stream response without body"});throw(s=this.onerror)==null||s.call(this,$),$}const y=p.body.pipeThrough(new TextDecoderStream).pipeThrough(new Nn).getReader();(async()=>{var $,v,k;try{for(;;){const{done:N,value:I}=await y.read();if(N)return;const{event:T,data:z}=I;if(T==="message")try{const Z=En.parse(JSON.parse(z));($=this.onmessage)==null||$.call(this,Z)}catch(Z){const re=new se({message:"MCP HTTP Transport Error: Failed to parse message",cause:Z});(v=this.onerror)==null||v.call(this,re)}}}catch(N){if(N instanceof Error&&N.name==="AbortError")return;(k=this.onerror)==null||k.call(this,N)}})();return}const m=new se({message:`MCP HTTP Transport Error: Unexpected content type: ${g}`});throw(l=this.onerror)==null||l.call(this,m),m}catch(c){throw(u=this.onerror)==null||u.call(this,c),c}};await t()}getNextReconnectionDelay(e){const{initialReconnectionDelay:t,reconnectionDelayGrowFactor:n,maxReconnectionDelay:o}=this.reconnectionOptions;return Math.min(t*Math.pow(n,e),o)}scheduleInboundSseReconnection(){var e;const{maxRetries:t}=this.reconnectionOptions;if(t>0&&this.inboundReconnectAttempts>=t){(e=this.onerror)==null||e.call(this,new se({message:`MCP HTTP Transport Error: Maximum reconnection attempts (${t}) exceeded.`}));return}const n=this.getNextReconnectionDelay(this.inboundReconnectAttempts);this.inboundReconnectAttempts+=1,setTimeout(async()=>{var o;(o=this.abortController)!=null&&o.signal.aborted||await this.openInboundSse(!1,this.lastInboundEventId)},n)}async openInboundSse(e=!1,t){var n,o,r,i,a,s;try{const l=await this.commonHeaders({Accept:"text/event-stream"});t&&(l["last-event-id"]=t);const u=await fetch(this.url.href,{method:"GET",headers:l,signal:(n=this.abortController)==null?void 0:n.signal}),c=u.headers.get("mcp-session-id");if(c&&(this.sessionId=c),u.status===401&&this.authProvider&&!e){this.resourceMetadataUrl=ji(u);try{if(await Ai(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const m=new Ci;(o=this.onerror)==null||o.call(this,m);return}}catch(g){(r=this.onerror)==null||r.call(this,g);return}return this.openInboundSse(!0,t)}if(u.status===405)return;if(!u.ok||!u.body){const g=new se({message:`MCP HTTP Transport Error: GET SSE failed: ${u.status} ${u.statusText}`});(i=this.onerror)==null||i.call(this,g);return}const p=u.body.pipeThrough(new TextDecoderStream).pipeThrough(new Nn).getReader(),f=async()=>{var g,m,b,y;try{for(;;){const{done:x,value:$}=await p.read();if(x)return;const{event:v,data:k,id:N}=$;if(N&&(this.lastInboundEventId=N),v==="message")try{const I=En.parse(JSON.parse(k));(g=this.onmessage)==null||g.call(this,I)}catch(I){const T=new se({message:"MCP HTTP Transport Error: Failed to parse message",cause:I});(m=this.onerror)==null||m.call(this,T)}}}catch(x){if(x instanceof Error&&x.name==="AbortError")return;(b=this.onerror)==null||b.call(this,x),(y=this.abortController)!=null&&y.signal.aborted||this.scheduleInboundSseReconnection()}};this.inboundSseConnection={close:()=>p.cancel()},this.inboundReconnectAttempts=0,f()}catch(l){if(l instanceof Error&&l.name==="AbortError")return;(a=this.onerror)==null||a.call(this,l),(s=this.abortController)!=null&&s.signal.aborted||this.scheduleInboundSseReconnection()}}};function Xz(e){switch(e.type){case"sse":return new Yz(e);case"http":return new Qz(e);default:throw new se({message:"Unsupported or invalid transport configuration. If you are using a custom transport, make sure it implements the MCPTransport interface."})}}function eM(e){return"start"in e&&typeof e.start=="function"&&"send"in e&&typeof e.send=="function"&&"close"in e&&typeof e.close=="function"}var tM="1.0.0";async function rM(e){const t=new nM(e);return await t.init(),t}var nM=class{constructor({transport:e,name:t="ai-sdk-mcp-client",version:n=tM,onUncaughtError:o,capabilities:r}){this.requestMessageId=0,this.responseHandlers=new Map,this.serverCapabilities={},this.isClosed=!0,this.onUncaughtError=o,this.clientCapabilities=r??{},eM(e)?this.transport=e:this.transport=Xz(e),this.transport.onclose=()=>this.onClose(),this.transport.onerror=i=>this.onError(i),this.transport.onmessage=i=>{if("method"in i){"id"in i?this.onRequestMessage(i):this.onError(new se({message:"Unsupported message type"}));return}this.onResponse(i)},this.clientInfo={name:t,version:n}}async init(){try{await this.transport.start(),this.isClosed=!1;const e=await this.request({request:{method:"initialize",params:{protocolVersion:ln,capabilities:this.clientCapabilities,clientInfo:this.clientInfo}},resultSchema:iz});if(e===void 0)throw new se({message:"Server sent invalid initialize result"});if(!rz.includes(e.protocolVersion))throw new se({message:`Server's protocol version is not supported: ${e.protocolVersion}`});return this.serverCapabilities=e.capabilities,await this.notification({method:"notifications/initialized"}),this}catch(e){throw await this.close(),e}}async close(){var e;this.isClosed||(await((e=this.transport)==null?void 0:e.close()),this.onClose())}assertCapability(e){switch(e){case"initialize":break;case"tools/list":case"tools/call":if(!this.serverCapabilities.tools)throw new se({message:"Server does not support tools"});break;case"resources/list":case"resources/read":case"resources/templates/list":if(!this.serverCapabilities.resources)throw new se({message:"Server does not support resources"});break;case"prompts/list":case"prompts/get":if(!this.serverCapabilities.prompts)throw new se({message:"Server does not support prompts"});break;default:throw new se({message:`Unsupported method: ${e}`})}}async request({request:e,resultSchema:t,options:n}){return new Promise((o,r)=>{if(this.isClosed)return r(new se({message:"Attempted to send a request from a closed client"}));this.assertCapability(e.method);const i=n?.signal;i?.throwIfAborted();const a=this.requestMessageId++,s={...e,jsonrpc:"2.0",id:a},l=()=>{this.responseHandlers.delete(a)};this.responseHandlers.set(a,u=>{if(i?.aborted)return r(new se({message:"Request was aborted",cause:i.reason}));if(u instanceof Error)return r(u);try{const c=t.parse(u.result);o(c)}catch(c){const d=new se({message:"Failed to parse server response",cause:c});r(d)}}),this.transport.send(s).catch(u=>{l(),r(u)})})}async listTools({params:e,options:t}={}){try{return this.request({request:{method:"tools/list",params:e},resultSchema:sz,options:t})}catch(n){throw n}}async callTool({name:e,args:t,options:n}){try{return this.request({request:{method:"tools/call",params:{name:e,arguments:t}},resultSchema:cz,options:{signal:n?.abortSignal}})}catch(o){throw o}}async listResourcesInternal({params:e,options:t}={}){try{return this.request({request:{method:"resources/list",params:e},resultSchema:lz,options:t})}catch(n){throw n}}async readResourceInternal({uri:e,options:t}){try{return this.request({request:{method:"resources/read",params:{uri:e}},resultSchema:pz,options:t})}catch(n){throw n}}async listResourceTemplatesInternal({options:e}={}){try{return this.request({request:{method:"resources/templates/list"},resultSchema:fz,options:e})}catch(t){throw t}}async listPromptsInternal({params:e,options:t}={}){try{return this.request({request:{method:"prompts/list",params:e},resultSchema:gz,options:t})}catch(n){throw n}}async getPromptInternal({name:e,args:t,options:n}){try{return this.request({request:{method:"prompts/get",params:{name:e,arguments:t}},resultSchema:yz,options:n})}catch(o){throw o}}async notification(e){const t={...e,jsonrpc:"2.0"};await this.transport.send(t)}async tools({schemas:e="automatic"}={}){var t;const n={};try{const o=await this.listTools();for(const{name:r,description:i,inputSchema:a}of o.tools){if(e!=="automatic"&&!(r in e))continue;const s=this,l=async(c,d)=>{var p;return(p=d?.abortSignal)==null||p.throwIfAborted(),s.callTool({name:r,args:c,options:d})},u=e==="automatic"?JR({description:i,inputSchema:HR({...a,properties:(t=a.properties)!=null?t:{},additionalProperties:!1}),execute:l}):{description:i,inputSchema:e[r].inputSchema,execute:l};n[r]=u}return n}catch(o){throw o}}listResources({params:e,options:t}={}){return this.listResourcesInternal({params:e,options:t})}readResource({uri:e,options:t}){return this.readResourceInternal({uri:e,options:t})}listResourceTemplates({options:e}={}){return this.listResourceTemplatesInternal({options:e})}listPrompts({params:e,options:t}={}){return this.listPromptsInternal({params:e,options:t})}getPrompt({name:e,arguments:t,options:n}){return this.getPromptInternal({name:e,args:t,options:n})}onElicitationRequest(e,t){if(e!==Ip)throw new se({message:"Unsupported request schema. Only ElicitationRequestSchema is supported."});this.elicitationRequestHandler=t}async onRequestMessage(e){try{if(e.method!=="elicitation/create"){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Unsupported request method: ${e.method}`}});return}if(!this.elicitationRequestHandler){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32601,message:"No elicitation handler registered on client"}});return}const t=Ip.safeParse({method:e.method,params:e.params});if(!t.success){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Invalid elicitation request: ${t.error.message}`,data:t.error.issues}});return}try{const n=await this.elicitationRequestHandler(t.data),o=_z.parse(n);await this.transport.send({jsonrpc:"2.0",id:e.id,result:o})}catch(n){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32603,message:n instanceof Error?n.message:"Failed to handle elicitation request"}}),this.onError(n)}}catch(t){this.onError(t)}}onClose(){if(this.isClosed)return;this.isClosed=!0;const e=new se({message:"Connection closed"});for(const t of this.responseHandlers.values())t(e);this.responseHandlers.clear()}onError(e){this.onUncaughtError&&this.onUncaughtError(e)}onResponse(e){const t=Number(e.id),n=this.responseHandlers.get(t);if(n===void 0)throw new se({message:`Protocol error: Received a response for an unknown message ID: ${JSON.stringify(e)}`});this.responseHandlers.delete(t),n("result"in e?e:new se({message:e.error.message,code:e.error.code,data:e.error.data,cause:e.error}))}};function oM({getSession:e,projectSlug:t,mcp:n,environment:o}){const r=e$({getSession:e,projectSlug:t});return Xx({queryKey:["mcpTools",t,n,r],queryFn:async()=>(O.assert(r,"No session found"),await(await rM({name:"gram-elements-mcp-client",transport:{type:"http",url:n,headers:{...iM(o??{}),"Gram-Chat-Session":r}}})).tools()),enabled:!!r,staleTime:1/0,gcTime:1/0})}const Tp="MCP-";function iM(e){return typeof e!="object"||e===null?{}:Object.entries(e).reduce((t,[n,o])=>{const r=n.replace(/_/g,"-"),i=r.startsWith(Tp)?r:`${Tp}${r}`;return t[i]=o,t},{})}const aM="https://app.getgram.ai",sM="You are a helpful assistant that can answer questions and help with tasks.";function uM(e,t){return`
|
|
89
|
-
${
|
|
88
|
+
`)}})}},qx={"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive","x-vercel-ai-ui-message-stream":"v1","x-accel-buffering":"no"};function LA({status:e,statusText:t,headers:n,stream:o,consumeSseStream:r}){let i=o.pipeThrough(new Fx);if(r){const[a,s]=i.tee();i=a,r({stream:s})}return new Response(i.pipeThrough(new TextEncoderStream),{status:e,statusText:t,headers:Ba(n,qx)})}function ZA({originalMessages:e,responseMessageId:t}){if(e==null)return;const n=e[e.length-1];return n?.role==="assistant"?n.id:typeof t=="function"?t():t}function FA(e){return e.type.startsWith("data-")}function Vx(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const r=t[o];if(r===void 0)continue;const i=o in e?e[o]:void 0,a=r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp),s=i!=null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp);a&&s?n[o]=Vx(i,r):n[o]=r}return n}function qA(e){const t=["ROOT"];let n=-1,o=null;function r(l,u,c){switch(l){case'"':{n=u,t.pop(),t.push(c),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=u,o=u,t.pop(),t.push(c),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=u,t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"{":{n=u,t.pop(),t.push(c),t.push("INSIDE_OBJECT_START");break}case"[":{n=u,t.pop(),t.push(c),t.push("INSIDE_ARRAY_START");break}}}function i(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":r(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{r(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),n=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{n=l,t.pop();break}default:{n=l,r(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=l,t.pop();break}default:{n=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{r(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(o,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?i(u,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l)):n=l;break}}}let s=e.slice(0,n+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{s+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{s+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{s+="]";break}case"INSIDE_LITERAL":{const c=e.substring(o,e.length);"true".startsWith(c)?s+="true".slice(c.length):"false".startsWith(c)?s+="false".slice(c.length):"null".startsWith(c)&&(s+="null".slice(c.length))}}return s}async function Bx(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await wr({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await wr({text:qA(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function As(e){return e.type.startsWith("data-")}function Rs(e){return e.type==="text"}function zs(e){return e.type==="file"}function df(e){return e.type==="reasoning"}function Fr(e){return e.type.startsWith("tool-")}function Lc(e){return e.type==="dynamic-tool"}function pf(e){return Fr(e)||Lc(e)}function Ti(e){return e.type.split("-").slice(1).join("-")}function VA(e){return Lc(e)?e.toolName:Ti(e)}function BA({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function JA({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:o,onError:r,onToolCall:i,onData:a}){return e.pipeThrough(new TransformStream({async transform(s,l){await o(async({state:u,write:c})=>{var d,f,p,g;function h(v){const N=u.message.parts.filter(Fr).find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function b(v){const N=u.message.parts.filter(I=>I.type==="dynamic-tool").find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function y(v){var k;const N=u.message.parts.find(z=>Fr(z)&&z.toolCallId===v.toolCallId),I=v,O=N;N!=null?(N.state=v.state,O.input=I.input,O.output=I.output,O.errorText=I.errorText,O.rawInput=I.rawInput,O.preliminary=I.preliminary,O.providerExecuted=(k=I.providerExecuted)!=null?k:N.providerExecuted,I.providerMetadata!=null&&N.state==="input-available"&&(N.callProviderMetadata=I.providerMetadata)):u.message.parts.push({type:`tool-${v.toolName}`,toolCallId:v.toolCallId,state:v.state,input:I.input,output:I.output,rawInput:I.rawInput,errorText:I.errorText,providerExecuted:I.providerExecuted,preliminary:I.preliminary,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}function x(v){var k,N;const I=u.message.parts.find(F=>F.type==="dynamic-tool"&&F.toolCallId===v.toolCallId),O=v,z=I;I!=null?(I.state=v.state,z.toolName=v.toolName,z.input=O.input,z.output=O.output,z.errorText=O.errorText,z.rawInput=(k=O.rawInput)!=null?k:z.rawInput,z.preliminary=O.preliminary,z.providerExecuted=(N=O.providerExecuted)!=null?N:I.providerExecuted,O.providerMetadata!=null&&I.state==="input-available"&&(I.callProviderMetadata=O.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:v.toolName,toolCallId:v.toolCallId,state:v.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,...O.providerMetadata!=null?{callProviderMetadata:O.providerMetadata}:{}})}async function $(v){if(v!=null){const k=u.message.metadata!=null?Vx(u.message.metadata,v):v;t!=null&&await fu({value:k,schema:t}),u.message.metadata=k}}switch(s.type){case"text-start":{const v={type:"text",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeTextParts[s.id]=v,u.message.parts.push(v),c();break}case"text-delta":{const v=u.activeTextParts[s.id];v.text+=s.delta,v.providerMetadata=(d=s.providerMetadata)!=null?d:v.providerMetadata,c();break}case"text-end":{const v=u.activeTextParts[s.id];v.state="done",v.providerMetadata=(f=s.providerMetadata)!=null?f:v.providerMetadata,delete u.activeTextParts[s.id],c();break}case"reasoning-start":{const v={type:"reasoning",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeReasoningParts[s.id]=v,u.message.parts.push(v),c();break}case"reasoning-delta":{const v=u.activeReasoningParts[s.id];v.text+=s.delta,v.providerMetadata=(p=s.providerMetadata)!=null?p:v.providerMetadata,c();break}case"reasoning-end":{const v=u.activeReasoningParts[s.id];v.providerMetadata=(g=s.providerMetadata)!=null?g:v.providerMetadata,v.state="done",delete u.activeReasoningParts[s.id],c();break}case"file":{u.message.parts.push({type:"file",mediaType:s.mediaType,url:s.url}),c();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:s.sourceId,url:s.url,title:s.title,providerMetadata:s.providerMetadata}),c();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:s.sourceId,mediaType:s.mediaType,title:s.title,filename:s.filename,providerMetadata:s.providerMetadata}),c();break}case"tool-input-start":{const v=u.message.parts.filter(Fr);u.partialToolCalls[s.toolCallId]={text:"",toolName:s.toolName,index:v.length,dynamic:s.dynamic},s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}),c();break}case"tool-input-delta":{const v=u.partialToolCalls[s.toolCallId];v.text+=s.inputTextDelta;const{value:k}=await Bx(v.text);v.dynamic?x({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}):y({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}),c();break}case"tool-input-available":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c(),i&&!s.providerExecuted&&await i({toolCall:s});break}case"tool-input-error":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:void 0,rawInput:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c();break}case"tool-output-available":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-available",input:v.input,output:s.output,preliminary:s.preliminary})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Ti(v),state:"output-available",input:v.input,output:s.output,providerExecuted:s.providerExecuted,preliminary:s.preliminary})}c();break}case"tool-output-error":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-error",input:v.input,errorText:s.errorText,providerExecuted:s.providerExecuted})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Ti(v),state:"output-error",input:v.input,rawInput:v.rawInput,errorText:s.errorText,providerExecuted:s.providerExecuted})}c();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{s.messageId!=null&&(u.message.id=s.messageId),await $(s.messageMetadata),(s.messageId!=null||s.messageMetadata!=null)&&c();break}case"finish":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"message-metadata":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"error":{r?.(new Error(s.errorText));break}default:if(FA(s)){n?.[s.type]!=null&&await fu({value:s.data,schema:n[s.type]});const v=s;if(v.transient){a?.(v);break}const k=v.id!=null?u.message.parts.find(N=>v.type===N.type&&v.id===N.id):void 0;k!=null?k.data=v.data:u.message.parts.push(v),a?.(v),c()}}l.enqueue(s)})}}))}function WA({messageId:e,originalMessages:t=[],onFinish:n,onError:o,stream:r}){let i=t?.[t.length-1];i?.role!=="assistant"?i=void 0:e=i.id;let a=!1;const s=r.pipeThrough(new TransformStream({transform(f,p){if(f.type==="start"){const g=f;g.messageId==null&&e!=null&&(g.messageId=e)}f.type==="abort"&&(a=!0),p.enqueue(f)}}));if(n==null)return s;const l=BA({lastMessage:i?structuredClone(i):void 0,messageId:e??""}),u=async f=>{await f({state:l,write:()=>{}})};let c=!1;const d=async()=>{if(c||!n)return;c=!0;const f=l.message.id===i?.id;await n({isAborted:a,isContinuation:f,responseMessage:l.message,messages:[...f?t.slice(0,-1):t,l.message]})};return JA({stream:s,runUpdateMessageJob:u,onError:o}).pipeThrough(new TransformStream({transform(f,p){p.enqueue(f)},async cancel(){await d()},async flush(){await d()}}))}function HA({response:e,status:t,statusText:n,headers:o,stream:r,consumeSseStream:i}){let a=r.pipeThrough(new Fx);if(i){const[s,l]=a.tee();a=s,i({stream:l})}Zx({response:e,status:t,statusText:n,headers:Object.fromEntries(Ba(o,qx).entries()),stream:a.pipeThrough(new TextEncoderStream)})}function Jo(e){const t=e.pipeThrough(new TransformStream);return t[Symbol.asyncIterator]=function(){const n=this.getReader();let o=!1;async function r(i){var a;o=!0;try{i&&await((a=n.cancel)==null?void 0:a.call(n))}finally{try{n.releaseLock()}catch{}}}return{async next(){if(o)return{done:!0,value:void 0};const{done:i,value:a}=await n.read();return i?(await r(!0),{done:!0,value:void 0}):{done:!1,value:a}},async return(){return await r(!0),{done:!0,value:void 0}},async throw(i){throw await r(!0),i}}},t}async function GA({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:o}=await n.read();if(o)break}}catch(o){t?.(o)}finally{n.releaseLock()}}function ff(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function KA(){let e=[],t=null,n=!1,o=ff();const r=()=>{n=!0,o.resolve(),e.forEach(a=>a.cancel()),e=[],t?.close()},i=async()=>{if(n&&e.length===0){t?.close();return}if(e.length===0)return o=ff(),await o.promise,i();try{const{value:a,done:s}=await e[0].read();s?(e.shift(),e.length>0?await i():n&&t?.close()):t?.enqueue(a)}catch(a){t?.error(a),e.shift(),r()}};return{stream:new ReadableStream({start(a){t=a},pull:i,async cancel(){for(const a of e)await a.cancel();e=[],n=!0}}),addStream:a=>{if(n)throw new Error("Cannot add inner stream: outer stream is closed");e.push(a.getReader()),o.resolve()},close:()=>{n=!0,o.resolve(),e.length===0&&t?.close()},terminate:r}}var Wo=class{constructor(){this.status={type:"pending"},this._resolve=void 0,this._reject=void 0}get promise(){return this._promise?this._promise:(this._promise=new Promise((e,t)=>{this.status.type==="resolved"?e(this.status.value):this.status.type==="rejected"&&t(this.status.error),this._resolve=e,this._reject=t}),this._promise)}resolve(e){var t;this.status={type:"resolved",value:e},this._promise&&((t=this._resolve)==null||t.call(this,e))}reject(e){var t;this.status={type:"rejected",error:e},this._promise&&((t=this._reject)==null||t.call(this,e))}};function YA(){var e,t;return(t=(e=globalThis?.performance)==null?void 0:e.now())!=null?t:Date.now()}function QA({tools:e,generatorStream:t,tracer:n,telemetry:o,system:r,messages:i,abortSignal:a,repairToolCall:s,experimental_context:l}){let u=null;const c=new ReadableStream({start(y){u=y}}),d=new Set,f=new Map;let p=!1,g;function h(){p&&d.size===0&&(g!=null&&u.enqueue(g),u.close())}const b=new TransformStream({async transform(y,x){const $=y.type;switch($){case"stream-start":case"text-start":case"text-delta":case"text-end":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"tool-input-start":case"tool-input-delta":case"tool-input-end":case"source":case"response-metadata":case"error":case"raw":{x.enqueue(y);break}case"file":{x.enqueue({type:"file",file:new AA({data:y.data,mediaType:y.mediaType})});break}case"finish":{g={type:"finish",finishReason:y.finishReason,usage:y.usage,providerMetadata:y.providerMetadata};break}case"tool-call":{try{const v=await RA({toolCall:y,tools:e,repairToolCall:s,system:r,messages:i});if(x.enqueue(v),v.invalid){u.enqueue({type:"tool-error",toolCallId:v.toolCallId,toolName:v.toolName,input:v.input,error:jw(v.error),dynamic:!0});break}const k=e[v.toolName];if(f.set(v.toolCallId,v.input),k.onInputAvailable!=null&&await k.onInputAvailable({input:v.input,toolCallId:v.toolCallId,messages:i,abortSignal:a,experimental_context:l}),k.execute!=null&&v.providerExecuted!==!0){const N=ZC();d.add(N),_u({name:"ai.toolCall",attributes:Lr({telemetry:o,attributes:{...bu({operationId:"ai.toolCall",telemetry:o}),"ai.toolCall.name":v.toolName,"ai.toolCall.id":v.toolCallId,"ai.toolCall.args":{output:()=>JSON.stringify(v.input)}}}),tracer:n,fn:async I=>{let O;try{const z=e1({execute:k.execute.bind(k),input:v.input,options:{toolCallId:v.toolCallId,messages:i,abortSignal:a,experimental_context:l}});for await(const F of z)u.enqueue({...v,type:"tool-result",output:F.output,...F.type==="preliminary"&&{preliminary:!0}}),F.type==="final"&&(O=F.output)}catch(z){Dx(I,z),u.enqueue({...v,type:"tool-error",error:z}),d.delete(N),h();return}d.delete(N),h();try{I.setAttributes(Lr({telemetry:o,attributes:{"ai.toolCall.result":{output:()=>JSON.stringify(O)}}}))}catch{}}})}}catch(v){u.enqueue({type:"error",error:v})}break}case"tool-result":{const v=y.toolName;y.isError?u.enqueue({type:"tool-error",toolCallId:y.toolCallId,toolName:v,input:f.get(y.toolCallId),providerExecuted:y.providerExecuted,error:y.result}):x.enqueue({type:"tool-result",toolCallId:y.toolCallId,toolName:v,input:f.get(y.toolCallId),output:y.result,providerExecuted:y.providerExecuted});break}default:{const v=$;throw new Error(`Unhandled chunk type: ${v}`)}}},flush(){p=!0,h()}});return new ReadableStream({async start(y){return Promise.all([t.pipeThrough(b).pipeTo(new WritableStream({write(x){y.enqueue(x)},close(){}})),c.pipeTo(new WritableStream({write(x){y.enqueue(x)},close(){y.close()}}))])}})}var XA=To({prefix:"aitxt",size:24});function eR({model:e,tools:t,toolChoice:n,system:o,prompt:r,messages:i,maxRetries:a,abortSignal:s,headers:l,stopWhen:u=Lx(1),experimental_output:c,experimental_telemetry:d,prepareStep:f,providerOptions:p,experimental_activeTools:g,activeTools:h=g,experimental_repairToolCall:b,experimental_transform:y,experimental_download:x,includeRawChunks:$=!1,onChunk:v,onError:k=({error:q})=>{console.error(q)},onFinish:N,onAbort:I,onStepFinish:O,experimental_context:z,_internal:{now:F=YA,generateId:te=XA,currentDate:ce=()=>new Date}={},...B}){return new rR({model:Cx(e),telemetry:d,headers:l,settings:B,maxRetries:a,abortSignal:s,system:o,prompt:r,messages:i,tools:t,toolChoice:n,transforms:sf(y),activeTools:h,repairToolCall:b,stopConditions:sf(u),output:c,providerOptions:p,prepareStep:f,includeRawChunks:$,onChunk:v,onError:k,onFinish:N,onAbort:I,onStepFinish:O,now:F,currentDate:ce,generateId:te,experimental_context:z,download:x})}function tR(e){if(!e)return new TransformStream({transform(a,s){s.enqueue({part:a,partialOutput:void 0})}});let t,n="",o="",r="";function i({controller:a,partialOutput:s=void 0}){a.enqueue({part:{type:"text-delta",id:t,text:o},partialOutput:s}),o=""}return new TransformStream({async transform(a,s){if(a.type==="finish-step"&&o.length>0&&i({controller:s}),a.type!=="text-delta"&&a.type!=="text-start"&&a.type!=="text-end"){s.enqueue({part:a,partialOutput:void 0});return}if(t==null)t=a.id;else if(a.id!==t){s.enqueue({part:a,partialOutput:void 0});return}if(a.type==="text-start"){s.enqueue({part:a,partialOutput:void 0});return}if(a.type==="text-end"){o.length>0&&i({controller:s}),s.enqueue({part:a,partialOutput:void 0});return}n+=a.text,o+=a.text;const l=await e.parsePartial({text:n});if(l!=null){const u=JSON.stringify(l.partial);u!==r&&(i({controller:s,partialOutput:l.partial}),r=u)}}})}var rR=class{constructor({model:e,telemetry:t,headers:n,settings:o,maxRetries:r,abortSignal:i,system:a,prompt:s,messages:l,tools:u,toolChoice:c,transforms:d,activeTools:f,repairToolCall:p,stopConditions:g,output:h,providerOptions:b,prepareStep:y,includeRawChunks:x,now:$,currentDate:v,generateId:k,onChunk:N,onError:I,onFinish:O,onAbort:z,onStepFinish:F,experimental_context:te,download:ce}){this._totalUsage=new Wo,this._finishReason=new Wo,this._steps=new Wo,this.output=h,this.includeRawChunks=x,this.tools=u;let B,q=[];const we=[];let oe,de,K={},fe=[];const J=[];let Ue,ye={},Le={};const U=new TransformStream({async transform(Ee,Te){var Ae,ie,ft,mn;Te.enqueue(Ee);const{part:Z}=Ee;if((Z.type==="text-delta"||Z.type==="reasoning-delta"||Z.type==="source"||Z.type==="tool-call"||Z.type==="tool-result"||Z.type==="tool-input-start"||Z.type==="tool-input-delta"||Z.type==="raw")&&await N?.({chunk:Z}),Z.type==="error"&&await I({error:$A(Z.error)}),Z.type==="text-start"&&(ye[Z.id]={type:"text",text:"",providerMetadata:Z.providerMetadata},q.push(ye[Z.id])),Z.type==="text-delta"){const Ie=ye[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`text part ${Z.id} not found`},partialOutput:void 0});return}Ie.text+=Z.text,Ie.providerMetadata=(Ae=Z.providerMetadata)!=null?Ae:Ie.providerMetadata}if(Z.type==="text-end"){const Ie=ye[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`text part ${Z.id} not found`},partialOutput:void 0});return}Ie.providerMetadata=(ie=Z.providerMetadata)!=null?ie:Ie.providerMetadata,delete ye[Z.id]}if(Z.type==="reasoning-start"&&(Le[Z.id]={type:"reasoning",text:"",providerMetadata:Z.providerMetadata},q.push(Le[Z.id])),Z.type==="reasoning-delta"){const Ie=Le[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`reasoning part ${Z.id} not found`},partialOutput:void 0});return}Ie.text+=Z.text,Ie.providerMetadata=(ft=Z.providerMetadata)!=null?ft:Ie.providerMetadata}if(Z.type==="reasoning-end"){const Ie=Le[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`reasoning part ${Z.id} not found`},partialOutput:void 0});return}Ie.providerMetadata=(mn=Z.providerMetadata)!=null?mn:Ie.providerMetadata,delete Le[Z.id]}if(Z.type==="file"&&q.push({type:"file",file:Z.file}),Z.type==="source"&&q.push(Z),Z.type==="tool-call"&&q.push(Z),Z.type==="tool-result"&&!Z.preliminary&&q.push(Z),Z.type==="tool-error"&&q.push(Z),Z.type==="start-step"&&(K=Z.request,fe=Z.warnings),Z.type==="finish-step"){const Ie=cf({content:q,tools:u}),hn=new zA({content:q,finishReason:Z.finishReason,usage:Z.usage,warnings:fe,request:K,response:{...Z.response,messages:[...we,...Ie]},providerMetadata:Z.providerMetadata});await F?.(hn),A1(fe),J.push(hn),q=[],Le={},ye={},we.push(...Ie),B.resolve()}Z.type==="finish"&&(de=Z.totalUsage,oe=Z.finishReason)},async flush(Ee){try{if(J.length===0){const ft=new U1({message:"No output generated. Check the stream for errors."});je._finishReason.reject(ft),je._totalUsage.reject(ft),je._steps.reject(ft);return}const Te=oe??"unknown",Ae=de??{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};je._finishReason.resolve(Te),je._totalUsage.resolve(Ae),je._steps.resolve(J);const ie=J[J.length-1];await O?.({finishReason:Te,totalUsage:Ae,usage:ie.usage,content:ie.content,text:ie.text,reasoningText:ie.reasoningText,reasoning:ie.reasoning,files:ie.files,sources:ie.sources,toolCalls:ie.toolCalls,staticToolCalls:ie.staticToolCalls,dynamicToolCalls:ie.dynamicToolCalls,toolResults:ie.toolResults,staticToolResults:ie.staticToolResults,dynamicToolResults:ie.dynamicToolResults,request:ie.request,response:ie.response,warnings:ie.warnings,providerMetadata:ie.providerMetadata,steps:J}),Ue.setAttributes(Lr({telemetry:t,attributes:{"ai.response.finishReason":Te,"ai.response.text":{output:()=>ie.text},"ai.response.toolCalls":{output:()=>{var ft;return(ft=ie.toolCalls)!=null&&ft.length?JSON.stringify(ie.toolCalls):void 0}},"ai.response.providerMetadata":JSON.stringify(ie.providerMetadata),"ai.usage.inputTokens":Ae.inputTokens,"ai.usage.outputTokens":Ae.outputTokens,"ai.usage.totalTokens":Ae.totalTokens,"ai.usage.reasoningTokens":Ae.reasoningTokens,"ai.usage.cachedInputTokens":Ae.cachedInputTokens}}))}catch(Te){Ee.error(Te)}finally{Ue.end()}}}),Q=KA();this.addStream=Q.addStream,this.closeStream=Q.close;const me=Q.stream.getReader();let xe=new ReadableStream({async start(Ee){Ee.enqueue({type:"start"})},async pull(Ee){function Te(){z?.({steps:J}),Ee.enqueue({type:"abort"}),Ee.close()}try{const{done:Ae,value:ie}=await me.read();if(Ae){Ee.close();return}if(i?.aborted){Te();return}Ee.enqueue(ie)}catch(Ae){_r(Ae)&&i?.aborted?Te():Ee.error(Ae)}},cancel(Ee){return Q.stream.cancel(Ee)}});for(const Ee of d)xe=xe.pipeThrough(Ee({tools:u,stopStream(){Q.terminate()}}));this.baseStream=xe.pipeThrough(tR(h)).pipeThrough(U);const{maxRetries:Ro,retry:ss}=CA({maxRetries:r,abortSignal:i}),fn=EA(t),pt=cA(o),zo=SA({model:e,telemetry:t,headers:n,settings:{...pt,maxRetries:Ro}}),je=this;_u({name:"ai.streamText",attributes:Lr({telemetry:t,attributes:{...bu({operationId:"ai.streamText",telemetry:t}),...zo,"ai.prompt":{input:()=>JSON.stringify({system:a,prompt:s,messages:l})}}}),tracer:fn,endWhenDone:!1,fn:async Ee=>{Ue=Ee;async function Te({currentStep:Ae,responseMessages:ie,usage:ft}){var mn,Z,Ie,hn,Sd;const Id=je.includeRawChunks;B=new Wo;const kd=await xA({system:a,prompt:s,messages:l}),gn=[...kd.messages,...ie],Et=await y?.({model:e,steps:J,stepNumber:J.length,messages:gn}),Nr=Cx((mn=Et?.model)!=null?mn:e),Ed=await aA({prompt:{system:(Z=Et?.system)!=null?Z:kd.system,messages:(Ie=Et?.messages)!=null?Ie:gn},supportedUrls:await Nr.supportedUrls,download:ce}),{toolChoice:us,tools:ls}=pA({tools:u,toolChoice:(hn=Et?.toolChoice)!=null?hn:c,activeTools:(Sd=Et?.activeTools)!=null?Sd:f}),{result:{stream:g0,response:Td,request:Od},doStreamSpan:Pr,startTimestampMs:Nd}=await ss(()=>_u({name:"ai.streamText.doStream",attributes:Lr({telemetry:t,attributes:{...bu({operationId:"ai.streamText.doStream",telemetry:t}),...zo,"ai.model.provider":Nr.provider,"ai.model.id":Nr.modelId,"ai.prompt.messages":{input:()=>TA(Ed)},"ai.prompt.tools":{input:()=>ls?.map(W=>JSON.stringify(W))},"ai.prompt.toolChoice":{input:()=>us!=null?JSON.stringify(us):void 0},"gen_ai.system":Nr.provider,"gen_ai.request.model":Nr.modelId,"gen_ai.request.frequency_penalty":pt.frequencyPenalty,"gen_ai.request.max_tokens":pt.maxOutputTokens,"gen_ai.request.presence_penalty":pt.presencePenalty,"gen_ai.request.stop_sequences":pt.stopSequences,"gen_ai.request.temperature":pt.temperature,"gen_ai.request.top_k":pt.topK,"gen_ai.request.top_p":pt.topP}}),tracer:fn,endWhenDone:!1,fn:async W=>({startTimestampMs:$(),doStreamSpan:W,result:await Nr.doStream({...pt,tools:ls,toolChoice:us,responseFormat:h?.responseFormat,prompt:Ed,providerOptions:b,abortSignal:i,headers:n,includeRawChunks:Id})})})),v0=QA({tools:u,generatorStream:g0,tracer:fn,telemetry:t,system:a,messages:gn,repairToolCall:p,abortSignal:i,experimental_context:te}),y0=Od??{},Mo=[],cs=[];let ds;const ps={};let Cr="unknown",mt={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},fs,Pd=!0,Tt={id:k(),timestamp:v(),modelId:e.modelId},Cd="";je.addStream(v0.pipeThrough(new TransformStream({async transform(W,Re){var vn,yn,Do,Ut;if(W.type==="stream-start"){ds=W.warnings;return}if(Pd){const Ze=$()-Nd;Pd=!1,Pr.addEvent("ai.stream.firstChunk",{"ai.response.msToFirstChunk":Ze}),Pr.setAttributes({"ai.response.msToFirstChunk":Ze}),Re.enqueue({type:"start-step",request:y0,warnings:ds??[]})}const jd=W.type;switch(jd){case"text-start":case"text-end":{Re.enqueue(W);break}case"text-delta":{W.delta.length>0&&(Re.enqueue({type:"text-delta",id:W.id,text:W.delta,providerMetadata:W.providerMetadata}),Cd+=W.delta);break}case"reasoning-start":case"reasoning-end":{Re.enqueue(W);break}case"reasoning-delta":{Re.enqueue({type:"reasoning-delta",id:W.id,text:W.delta,providerMetadata:W.providerMetadata});break}case"tool-call":{Re.enqueue(W),Mo.push(W);break}case"tool-result":{Re.enqueue(W),W.preliminary||cs.push(W);break}case"tool-error":{Re.enqueue(W),cs.push(W);break}case"response-metadata":{Tt={id:(vn=W.id)!=null?vn:Tt.id,timestamp:(yn=W.timestamp)!=null?yn:Tt.timestamp,modelId:(Do=W.modelId)!=null?Do:Tt.modelId};break}case"finish":{mt=W.usage,Cr=W.finishReason,fs=W.providerMetadata;const Ze=$()-Nd;Pr.addEvent("ai.stream.finish"),Pr.setAttributes({"ai.response.msToFinish":Ze,"ai.response.avgOutputTokensPerSecond":1e3*((Ut=mt.outputTokens)!=null?Ut:0)/Ze});break}case"file":{Re.enqueue(W);break}case"source":{Re.enqueue(W);break}case"tool-input-start":{ps[W.id]=W.toolName;const Ze=u?.[W.toolName];Ze?.onInputStart!=null&&await Ze.onInputStart({toolCallId:W.id,messages:gn,abortSignal:i,experimental_context:te}),Re.enqueue({...W,dynamic:Ze?.type==="dynamic"});break}case"tool-input-end":{delete ps[W.id],Re.enqueue(W);break}case"tool-input-delta":{const Ze=ps[W.id],ms=u?.[Ze];ms?.onInputDelta!=null&&await ms.onInputDelta({inputTextDelta:W.delta,toolCallId:W.id,messages:gn,abortSignal:i,experimental_context:te}),Re.enqueue(W);break}case"error":{Re.enqueue(W),Cr="error";break}case"raw":{Id&&Re.enqueue(W);break}default:{const Ze=jd;throw new Error(`Unknown chunk type: ${Ze}`)}}},async flush(W){const Re=Mo.length>0?JSON.stringify(Mo):void 0;try{Pr.setAttributes(Lr({telemetry:t,attributes:{"ai.response.finishReason":Cr,"ai.response.text":{output:()=>Cd},"ai.response.toolCalls":{output:()=>Re},"ai.response.id":Tt.id,"ai.response.model":Tt.modelId,"ai.response.timestamp":Tt.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(fs),"ai.usage.inputTokens":mt.inputTokens,"ai.usage.outputTokens":mt.outputTokens,"ai.usage.totalTokens":mt.totalTokens,"ai.usage.reasoningTokens":mt.reasoningTokens,"ai.usage.cachedInputTokens":mt.cachedInputTokens,"gen_ai.response.finish_reasons":[Cr],"gen_ai.response.id":Tt.id,"gen_ai.response.model":Tt.modelId,"gen_ai.usage.input_tokens":mt.inputTokens,"gen_ai.usage.output_tokens":mt.outputTokens}}))}catch{}finally{Pr.end()}W.enqueue({type:"finish-step",finishReason:Cr,usage:mt,providerMetadata:fs,response:{...Tt,headers:Td?.headers}});const vn=OA(ft,mt);await B.promise;const yn=Mo.filter(Ut=>Ut.providerExecuted!==!0),Do=cs.filter(Ut=>Ut.providerExecuted!==!0);if(yn.length>0&&Do.length===yn.length&&!await MA({stopConditions:g,steps:J})){ie.push(...cf({content:J[J.length-1].content,tools:u}));try{await Te({currentStep:Ae+1,responseMessages:ie,usage:vn})}catch(Ut){W.enqueue({type:"error",error:Ut}),je.closeStream()}}else W.enqueue({type:"finish",finishReason:Cr,totalUsage:vn}),je.closeStream()}})))}await Te({currentStep:0,responseMessages:[],usage:{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0}})}}).catch(Ee=>{je.addStream(new ReadableStream({start(Te){Te.enqueue({type:"error",error:Ee}),Te.close()}})),je.closeStream()})}get steps(){return this.consumeStream(),this._steps.promise}get finalStep(){return this.steps.then(e=>e[e.length-1])}get content(){return this.finalStep.then(e=>e.content)}get warnings(){return this.finalStep.then(e=>e.warnings)}get providerMetadata(){return this.finalStep.then(e=>e.providerMetadata)}get text(){return this.finalStep.then(e=>e.text)}get reasoningText(){return this.finalStep.then(e=>e.reasoningText)}get reasoning(){return this.finalStep.then(e=>e.reasoning)}get sources(){return this.finalStep.then(e=>e.sources)}get files(){return this.finalStep.then(e=>e.files)}get toolCalls(){return this.finalStep.then(e=>e.toolCalls)}get staticToolCalls(){return this.finalStep.then(e=>e.staticToolCalls)}get dynamicToolCalls(){return this.finalStep.then(e=>e.dynamicToolCalls)}get toolResults(){return this.finalStep.then(e=>e.toolResults)}get staticToolResults(){return this.finalStep.then(e=>e.staticToolResults)}get dynamicToolResults(){return this.finalStep.then(e=>e.dynamicToolResults)}get usage(){return this.finalStep.then(e=>e.usage)}get request(){return this.finalStep.then(e=>e.request)}get response(){return this.finalStep.then(e=>e.response)}get totalUsage(){return this.consumeStream(),this._totalUsage.promise}get finishReason(){return this.consumeStream(),this._finishReason.promise}teeStream(){const[e,t]=this.baseStream.tee();return this.baseStream=t,e}get textStream(){return Jo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){e.type==="text-delta"&&t.enqueue(e.text)}})))}get fullStream(){return Jo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){t.enqueue(e)}})))}async consumeStream(e){var t;try{await GA({stream:this.fullStream,onError:e?.onError})}catch(n){(t=e?.onError)==null||t.call(e,n)}}get experimental_partialOutputStream(){if(this.output==null)throw new P1;return Jo(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:e},t){e!=null&&t.enqueue(e)}})))}toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:n,messageMetadata:o,sendReasoning:r=!0,sendSources:i=!1,sendStart:a=!0,sendFinish:s=!0,onError:l=sn}={}){const u=t!=null?ZA({originalMessages:e,responseMessageId:t}):void 0,c={},d=p=>{var g,h;const b=c[p];return((h=(g=this.tools)==null?void 0:g[b])==null?void 0:h.type)==="dynamic"?!0:void 0},f=this.fullStream.pipeThrough(new TransformStream({transform:async(p,g)=>{const h=o?.({part:p}),b=p.type;switch(b){case"text-start":{g.enqueue({type:"text-start",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"text-delta":{g.enqueue({type:"text-delta",id:p.id,delta:p.text,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"text-end":{g.enqueue({type:"text-end",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-start":{g.enqueue({type:"reasoning-start",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-delta":{r&&g.enqueue({type:"reasoning-delta",id:p.id,delta:p.text,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-end":{g.enqueue({type:"reasoning-end",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"file":{g.enqueue({type:"file",mediaType:p.file.mediaType,url:`data:${p.file.mediaType};base64,${p.file.base64}`});break}case"source":{i&&p.sourceType==="url"&&g.enqueue({type:"source-url",sourceId:p.id,url:p.url,title:p.title,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}}),i&&p.sourceType==="document"&&g.enqueue({type:"source-document",sourceId:p.id,mediaType:p.mediaType,title:p.title,filename:p.filename,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"tool-input-start":{c[p.id]=p.toolName;const y=d(p.id);g.enqueue({type:"tool-input-start",toolCallId:p.id,toolName:p.toolName,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...y!=null?{dynamic:y}:{}});break}case"tool-input-delta":{g.enqueue({type:"tool-input-delta",toolCallId:p.id,inputTextDelta:p.delta});break}case"tool-call":{c[p.toolCallId]=p.toolName;const y=d(p.toolCallId);p.invalid?g.enqueue({type:"tool-input-error",toolCallId:p.toolCallId,toolName:p.toolName,input:p.input,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{},...y!=null?{dynamic:y}:{},errorText:l(p.error)}):g.enqueue({type:"tool-input-available",toolCallId:p.toolCallId,toolName:p.toolName,input:p.input,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{},...y!=null?{dynamic:y}:{}});break}case"tool-result":{const y=d(p.toolCallId);g.enqueue({type:"tool-output-available",toolCallId:p.toolCallId,output:p.output,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.preliminary!=null?{preliminary:p.preliminary}:{},...y!=null?{dynamic:y}:{}});break}case"tool-error":{const y=d(p.toolCallId);g.enqueue({type:"tool-output-error",toolCallId:p.toolCallId,errorText:l(p.error),...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...y!=null?{dynamic:y}:{}});break}case"error":{g.enqueue({type:"error",errorText:l(p.error)});break}case"start-step":{g.enqueue({type:"start-step"});break}case"finish-step":{g.enqueue({type:"finish-step"});break}case"start":{a&&g.enqueue({type:"start",...h!=null?{messageMetadata:h}:{},...u!=null?{messageId:u}:{}});break}case"finish":{s&&g.enqueue({type:"finish",...h!=null?{messageMetadata:h}:{}});break}case"abort":{g.enqueue(p);break}case"tool-input-end":break;case"raw":break;default:{const y=b;throw new Error(`Unknown chunk type: ${y}`)}}h!=null&&b!=="start"&&b!=="finish"&&g.enqueue({type:"message-metadata",messageMetadata:h})}}));return Jo(WA({stream:f,messageId:u??t?.(),originalMessages:e,onFinish:n,onError:l}))}pipeUIMessageStreamToResponse(e,{originalMessages:t,generateMessageId:n,onFinish:o,messageMetadata:r,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u,...c}={}){HA({response:e,stream:this.toUIMessageStream({originalMessages:t,generateMessageId:n,onFinish:o,messageMetadata:r,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u}),...c})}pipeTextStreamToResponse(e,t){UA({response:e,textStream:this.textStream,...t})}toUIMessageStreamResponse({originalMessages:e,generateMessageId:t,onFinish:n,messageMetadata:o,sendReasoning:r,sendSources:i,sendFinish:a,sendStart:s,onError:l,...u}={}){return LA({stream:this.toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:n,messageMetadata:o,sendReasoning:r,sendSources:i,sendFinish:a,sendStart:s,onError:l}),...u})}toTextStreamResponse(e){return DA({textStream:this.textStream,...e})}};function nR(e,t){const n=[];t?.ignoreIncompleteToolCalls&&(e=e.map(o=>({...o,parts:o.parts.filter(r=>!pf(r)||r.state!=="input-streaming"&&r.state!=="input-available")})));for(const o of e)switch(o.role){case"system":{const r=o.parts.filter(a=>a.type==="text"),i=r.reduce((a,s)=>s.providerMetadata!=null?{...a,...s.providerMetadata}:a,{});n.push({role:"system",content:r.map(a=>a.text).join(""),...Object.keys(i).length>0?{providerOptions:i}:{}});break}case"user":{n.push({role:"user",content:o.parts.map(r=>{var i;if(Rs(r))return{type:"text",text:r.text,...r.providerMetadata!=null?{providerOptions:r.providerMetadata}:{}};if(zs(r))return{type:"file",mediaType:r.mediaType,filename:r.filename,data:r.url,...r.providerMetadata!=null?{providerOptions:r.providerMetadata}:{}};if(As(r))return(i=t?.convertDataPart)==null?void 0:i.call(t,r)}).filter(r=>r!=null)});break}case"assistant":{if(o.parts!=null){let r=function(){var a,s,l;if(i.length===0)return;const u=[];for(const d of i)if(Rs(d))u.push({type:"text",text:d.text,...d.providerMetadata!=null?{providerOptions:d.providerMetadata}:{}});else if(zs(d))u.push({type:"file",mediaType:d.mediaType,filename:d.filename,data:d.url});else if(df(d))u.push({type:"reasoning",text:d.text,providerOptions:d.providerMetadata});else if(Lc(d)){const f=d.toolName;d.state!=="input-streaming"&&u.push({type:"tool-call",toolCallId:d.toolCallId,toolName:f,input:d.input,...d.callProviderMetadata!=null?{providerOptions:d.callProviderMetadata}:{}})}else if(Fr(d)){const f=Ti(d);d.state!=="input-streaming"&&(u.push({type:"tool-call",toolCallId:d.toolCallId,toolName:f,input:d.state==="output-error"?(a=d.input)!=null?a:d.rawInput:d.input,providerExecuted:d.providerExecuted,...d.callProviderMetadata!=null?{providerOptions:d.callProviderMetadata}:{}}),d.providerExecuted===!0&&(d.state==="output-available"||d.state==="output-error")&&u.push({type:"tool-result",toolCallId:d.toolCallId,toolName:f,output:Nn({output:d.state==="output-error"?d.errorText:d.output,tool:(s=t?.tools)==null?void 0:s[f],errorMode:d.state==="output-error"?"json":"none"})}))}else if(As(d)){const f=(l=t?.convertDataPart)==null?void 0:l.call(t,d);f!=null&&u.push(f)}else{const f=d;throw new Error(`Unsupported part: ${f}`)}n.push({role:"assistant",content:u});const c=i.filter(d=>Fr(d)&&d.providerExecuted!==!0||d.type==="dynamic-tool");c.length>0&&n.push({role:"tool",content:c.map(d=>{var f;switch(d.state){case"output-error":case"output-available":{const p=VA(d);return{type:"tool-result",toolCallId:d.toolCallId,toolName:p,output:Nn({output:d.state==="output-error"?d.errorText:d.output,tool:(f=t?.tools)==null?void 0:f[p],errorMode:d.state==="output-error"?"text":"none"})}}default:return null}}).filter(d=>d!=null)}),i=[]},i=[];for(const a of o.parts)Rs(a)||df(a)||zs(a)||pf(a)||As(a)?i.push(a):a.type==="step-start"&&r();r();break}break}default:{const r=o.role;throw new W1({originalMessage:o,message:`Unsupported role: ${r}`})}}return n}To({prefix:"aiobj",size:24});To({prefix:"aiobj",size:24});var oR={};O1(oR,{object:()=>aR,text:()=>iR});var iR=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),aR=({schema:e})=>{const t=Va(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:n}){const o=await Bx(n);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value};default:{const r=o.state;throw new Error(`Unsupported parse state: ${r}`)}}},async parseOutput({text:n},o){const r=await wr({text:n});if(!r.success)throw new of({message:"No object generated: could not parse the response.",cause:r.error,text:n,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=await sr({value:r.value,schema:t});if(!i.success)throw new of({message:"No object generated: response did not match schema.",cause:i.error,text:n,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.value}}},sR={word:/\S+\s+/m,line:/\n+/m};function uR({delayInMs:e=10,chunking:t="word",_internal:{delay:n=Cw}={}}={}){let o;if(typeof t=="function")o=r=>{const i=t(r);if(i==null)return null;if(!i.length)throw new Error("Chunking function must return a non-empty string.");if(!r.startsWith(i))throw new Error(`Chunking function must return a match that is a prefix of the buffer. Received: "${i}" expected to start with "${r}"`);return i};else{const r=typeof t=="string"?sR[t]:t;if(r==null)throw new Vi({argument:"chunking",message:`Chunking must be "word" or "line" or a RegExp. Received: ${t}`});o=i=>{const a=r.exec(i);return a?i.slice(0,a.index)+a?.[0]:null}}return()=>{let r="",i="";return new TransformStream({async transform(a,s){if(a.type!=="text-delta"){r.length>0&&(s.enqueue({type:"text-delta",text:r,id:i}),r=""),s.enqueue(a);return}a.id!==i&&r.length>0&&(s.enqueue({type:"text-delta",text:r,id:i}),r=""),r+=a.text,i=a.id;let l;for(;(l=o(r))!=null;)s.enqueue({type:"text-delta",text:l,id:i}),r=r.slice(l.length),await n(e)}})}}const lR=e=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n.description?{description:n.description}:void 0,parameters:n.parameters instanceof vi.ZodType?vi.toJSONSchema(n.parameters):n.parameters}])),cR=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>!t.disabled&&t.type!=="backend"));let Oi=null;function dR(e,t){Oi={helpers:e,toolsRequiringApproval:new Set(t)}}function pR(){Oi=null}const fR=(e,t)=>L.makeAssistantTool({...e,execute:async(n,o)=>{if(Oi?.toolsRequiringApproval.has(t)){const{helpers:r}=Oi,i=o.toolCallId??"";if(!r.isToolApproved(t)&&!await r.requestApproval(t,i,n))return{content:[{type:"text",text:`Tool "${t}" execution was denied by the user. Please acknowledge this and continue without using this tool's result.`}],isError:!0}}return e.execute?.(n,o)},toolName:t});function mR(e,t,n){if(!t||t.length===0)return e;const o=new Set(t);return Object.fromEntries(Object.entries(e).map(([r,i])=>{if(!o.has(r))return[r,i];const a=i.execute;return a?[r,{...i,execute:async(s,l)=>{const u=l??{},c=u.toolCallId??"";return n.isToolApproved(r)||await n.requestApproval(r,c,s)?a(s,u):{content:[{type:"text",text:`Tool "${r}" execution was denied by the user. Please acknowledge this and continue without using this tool's result.`}],isError:!0}}}]:[r,i]}))}var Oo=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},hR={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},gR=class{#e=hR;#t=!1;setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&this.#t&&e!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:e}),this.#e=e,process.env.NODE_ENV!=="production"&&(this.#t=!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},gr=new gR;function vR(e){setTimeout(e,0)}var $r=typeof window>"u"||"Deno"in globalThis;function Je(){}function yR(e,t){return typeof e=="function"?e(t):e}function wu(e){return typeof e=="number"&&e>=0&&e!==1/0}function Jx(e,t){return Math.max(e+(t||0)-Date.now(),0)}function nr(e,t){return typeof e=="function"?e(t):e}function at(e,t){return typeof e=="function"?e(t):e}function mf(e,t){const{type:n="all",exact:o,fetchStatus:r,predicate:i,queryKey:a,stale:s}=e;if(a){if(o){if(t.queryHash!==Zc(a,t.options))return!1}else if(!Gn(t.queryKey,a))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof s=="boolean"&&t.isStale()!==s||r&&r!==t.state.fetchStatus||i&&!i(t))}function hf(e,t){const{exact:n,status:o,predicate:r,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Hn(t.options.mutationKey)!==Hn(i))return!1}else if(!Gn(t.options.mutationKey,i))return!1}return!(o&&t.state.status!==o||r&&!r(t))}function Zc(e,t){return(t?.queryKeyHashFn||Hn)(e)}function Hn(e){return JSON.stringify(e,(t,n)=>Su(n)?Object.keys(n).sort().reduce((o,r)=>(o[r]=n[r],o),{}):n)}function Gn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Gn(e[n],t[n])):!1}var bR=Object.prototype.hasOwnProperty;function xu(e,t){if(e===t)return e;const n=gf(e)&&gf(t);if(!n&&!(Su(e)&&Su(t)))return t;const r=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),a=i.length,s=n?new Array(a):{};let l=0;for(let u=0;u<a;u++){const c=n?u:i[u],d=e[c],f=t[c];if(d===f){s[c]=d,(n?u<r:bR.call(e,c))&&l++;continue}if(d===null||f===null||typeof d!="object"||typeof f!="object"){s[c]=f;continue}const p=xu(d,f);s[c]=p,p===d&&l++}return r===a&&l===r?e:s}function $u(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function gf(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Su(e){if(!vf(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!vf(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function vf(e){return Object.prototype.toString.call(e)==="[object Object]"}function _R(e){return new Promise(t=>{gr.setTimeout(t,e)})}function Iu(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return xu(e,t)}catch(o){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${o}`),o}return xu(e,t)}return t}function wR(e,t,n=0){const o=[...e,t];return n&&o.length>n?o.slice(1):o}function xR(e,t,n=0){const o=[t,...e];return n&&o.length>n?o.slice(0,-1):o}var Ni=Symbol();function Wx(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Ni&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ni?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function $R(e,t){return typeof e=="function"?e(...t):!!e}var SR=class extends Oo{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!$r&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},Fc=new SR;function ku(){let e,t;const n=new Promise((r,i)=>{e=r,t=i});n.status="pending",n.catch(()=>{});function o(r){Object.assign(n,r),delete n.resolve,delete n.reject}return n.resolve=r=>{o({status:"fulfilled",value:r}),e(r)},n.reject=r=>{o({status:"rejected",reason:r}),t(r)},n}var IR=vR;function kR(){let e=[],t=0,n=s=>{s()},o=s=>{s()},r=IR;const i=s=>{t?e.push(s):r(()=>{n(s)})},a=()=>{const s=e;e=[],s.length&&r(()=>{o(()=>{s.forEach(l=>{n(l)})})})};return{batch:s=>{let l;t++;try{l=s()}finally{t--,t||a()}return l},batchCalls:s=>(...l)=>{i(()=>{s(...l)})},schedule:i,setNotifyFunction:s=>{n=s},setBatchNotifyFunction:s=>{o=s},setScheduler:s=>{r=s}}}var ze=kR(),ER=class extends Oo{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!$r&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#e}},Pi=new ER;function TR(e){return Math.min(1e3*2**e,3e4)}function Hx(e){return(e??"online")==="online"?Pi.isOnline():!0}var Eu=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Gx(e){let t=!1,n=0,o;const r=ku(),i=()=>r.status!=="pending",a=h=>{if(!i()){const b=new Eu(h);f(b),e.onCancel?.(b)}},s=()=>{t=!0},l=()=>{t=!1},u=()=>Fc.isFocused()&&(e.networkMode==="always"||Pi.isOnline())&&e.canRun(),c=()=>Hx(e.networkMode)&&e.canRun(),d=h=>{i()||(o?.(),r.resolve(h))},f=h=>{i()||(o?.(),r.reject(h))},p=()=>new Promise(h=>{o=b=>{(i()||u())&&h(b)},e.onPause?.()}).then(()=>{o=void 0,i()||e.onContinue?.()}),g=()=>{if(i())return;let h;const b=n===0?e.initialPromise:void 0;try{h=b??e.fn()}catch(y){h=Promise.reject(y)}Promise.resolve(h).then(d).catch(y=>{if(i())return;const x=e.retry??($r?0:3),$=e.retryDelay??TR,v=typeof $=="function"?$(n,y):$,k=x===!0||typeof x=="number"&&n<x||typeof x=="function"&&x(n,y);if(t||!k){f(y);return}n++,e.onFail?.(n,y),_R(v).then(()=>u()?void 0:p()).then(()=>{t?f(y):g()})})};return{promise:r,status:()=>r.status,cancel:a,continue:()=>(o?.(),r),cancelRetry:s,continueRetry:l,canStart:c,start:()=>(c()?g():p().then(g),r)}}var Kx=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),wu(this.gcTime)&&(this.#e=gr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??($r?1/0:300*1e3))}clearGcTimeout(){this.#e&&(gr.clearTimeout(this.#e),this.#e=void 0)}},OR=class extends Kx{#e;#t;#r;#o;#n;#s;#a;constructor(e){super(),this.#a=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#o=e.client,this.#r=this.#o.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=bf(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){if(this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=bf(this.options);t.data!==void 0&&(this.setState(yf(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){const n=Iu(this.state.data,e,this.options);return this.#i({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(Je).catch(Je):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>at(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ni||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>nr(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!Jx(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#a?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){const s=this.observers.find(l=>l.options.queryFn);s&&this.setOptions(s.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,o=s=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#a=!0,n.signal)})},r=()=>{const s=Wx(this.options,t),u=(()=>{const c={client:this.#o,queryKey:this.queryKey,meta:this.meta};return o(c),c})();return this.#a=!1,this.options.persister?this.options.persister(s,u,this):s(u)},a=(()=>{const s={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#o,state:this.state,fetchFn:r};return o(s),s})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#i({type:"fetch",meta:a.fetchOptions?.meta}),this.#n=Gx({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:s=>{s instanceof Eu&&s.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(s,l)=>{this.#i({type:"failed",failureCount:s,error:l})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const s=await this.#n.start();if(s===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(s),this.#r.config.onSuccess?.(s,this),this.#r.config.onSettled?.(s,this.state.error,this),s}catch(s){if(s instanceof Eu){if(s.silent)return this.#n.promise;if(s.revert){if(this.state.data===void 0)throw s;return this.state.data}}throw this.#i({type:"error",error:s}),this.#r.config.onError?.(s,this),this.#r.config.onSettled?.(this.state.data,s,this),s}finally{this.scheduleGc()}}#i(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Yx(n.data,this.options),fetchMeta:e.meta??null};case"success":const o={...n,...yf(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?o:void 0,o;case"error":const r=e.error;return{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),ze.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function Yx(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Hx(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function yf(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function bf(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,o=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var NR=class extends Oo{constructor(e,t){super(),this.options=t,this.#e=e,this.#i=null,this.#a=ku(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#r=void 0;#o=void 0;#n;#s;#a;#i;#h;#p;#f;#l;#c;#u;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),_f(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Tu(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Tu(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#_(),this.#w(),this.#t.removeObserver(this)}setOptions(e){const t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof at(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#t.setOptions(this.options),t._defaulted&&!$u(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const o=this.hasListeners();o&&wf(this.#t,n,this.options,t)&&this.#d(),this.updateResult(),o&&(this.#t!==n||at(this.options.enabled,this.#t)!==at(t.enabled,this.#t)||nr(this.options.staleTime,this.#t)!==nr(t.staleTime,this.#t))&&this.#g();const r=this.#v();o&&(this.#t!==n||at(this.options.enabled,this.#t)!==at(t.enabled,this.#t)||r!==this.#u)&&this.#y(r)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return CR(this,n)&&(this.#o=n,this.#s=this.options,this.#n=this.#t.state),n}getCurrentResult(){return this.#o}trackResult(e,t){return new Proxy(e,{get:(n,o)=>(this.trackProp(o),t?.(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,o))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#o))}#d(e){this.#x();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Je)),t}#g(){this.#_();const e=nr(this.options.staleTime,this.#t);if($r||this.#o.isStale||!wu(e))return;const n=Jx(this.#o.dataUpdatedAt,e)+1;this.#l=gr.setTimeout(()=>{this.#o.isStale||this.updateResult()},n)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(e){this.#w(),this.#u=e,!($r||at(this.options.enabled,this.#t)===!1||!wu(this.#u)||this.#u===0)&&(this.#c=gr.setInterval(()=>{(this.options.refetchIntervalInBackground||Fc.isFocused())&&this.#d()},this.#u))}#b(){this.#g(),this.#y(this.#v())}#_(){this.#l&&(gr.clearTimeout(this.#l),this.#l=void 0)}#w(){this.#c&&(gr.clearInterval(this.#c),this.#c=void 0)}createResult(e,t){const n=this.#t,o=this.options,r=this.#o,i=this.#n,a=this.#s,l=e!==n?e.state:this.#r,{state:u}=e;let c={...u},d=!1,f;if(t._optimisticResults){const O=this.hasListeners(),z=!O&&_f(e,t),F=O&&wf(e,n,t,o);(z||F)&&(c={...c,...Yx(u.data,e.options)}),t._optimisticResults==="isRestoring"&&(c.fetchStatus="idle")}let{error:p,errorUpdatedAt:g,status:h}=c;f=c.data;let b=!1;if(t.placeholderData!==void 0&&f===void 0&&h==="pending"){let O;r?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(O=r.data,b=!0):O=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,O!==void 0&&(h="success",f=Iu(r?.data,O,t),d=!0)}if(t.select&&f!==void 0&&!b)if(r&&f===i?.data&&t.select===this.#h)f=this.#p;else try{this.#h=t.select,f=t.select(f),f=Iu(r?.data,f,t),this.#p=f,this.#i=null}catch(O){this.#i=O}this.#i&&(p=this.#i,f=this.#p,g=Date.now(),h="error");const y=c.fetchStatus==="fetching",x=h==="pending",$=h==="error",v=x&&y,k=f!==void 0,I={status:h,fetchStatus:c.fetchStatus,isPending:x,isSuccess:h==="success",isError:$,isInitialLoading:v,isLoading:v,data:f,dataUpdatedAt:c.dataUpdatedAt,error:p,errorUpdatedAt:g,failureCount:c.fetchFailureCount,failureReason:c.fetchFailureReason,errorUpdateCount:c.errorUpdateCount,isFetched:c.dataUpdateCount>0||c.errorUpdateCount>0,isFetchedAfterMount:c.dataUpdateCount>l.dataUpdateCount||c.errorUpdateCount>l.errorUpdateCount,isFetching:y,isRefetching:y&&!x,isLoadingError:$&&!k,isPaused:c.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:$&&k,isStale:qc(e,t),refetch:this.refetch,promise:this.#a,isEnabled:at(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const O=te=>{I.status==="error"?te.reject(I.error):I.data!==void 0&&te.resolve(I.data)},z=()=>{const te=this.#a=I.promise=ku();O(te)},F=this.#a;switch(F.status){case"pending":e.queryHash===n.queryHash&&O(F);break;case"fulfilled":(I.status==="error"||I.data!==F.value)&&z();break;case"rejected":(I.status!=="error"||I.error!==F.reason)&&z();break}}return I}updateResult(){const e=this.#o,t=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#s=this.options,this.#n.data!==void 0&&(this.#f=this.#t),$u(t,e))return;this.#o=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,r=typeof o=="function"?o():o;if(r==="all"||!r&&!this.#m.size)return!0;const i=new Set(r??this.#m);return this.options.throwOnError&&i.add("error"),Object.keys(this.#o).some(a=>{const s=a;return this.#o[s]!==e[s]&&i.has(s)})};this.#$({listeners:n()})}#x(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const t=this.#t;this.#t=e,this.#r=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#$(e){ze.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#o)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function PR(e,t){return at(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function _f(e,t){return PR(e,t)||e.state.data!==void 0&&Tu(e,t,t.refetchOnMount)}function Tu(e,t,n){if(at(t.enabled,e)!==!1&&nr(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&qc(e,t)}return!1}function wf(e,t,n,o){return(e!==t||at(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&qc(e,n)}function qc(e,t){return at(t.enabled,e)!==!1&&e.isStaleByTime(nr(t.staleTime,e))}function CR(e,t){return!$u(e.getCurrentResult(),t)}function xf(e){return{onFetch:(t,n)=>{const o=t.options,r=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let s={pages:[],pageParams:[]},l=0;const u=async()=>{let c=!1;const d=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(t.signal.aborted?c=!0:t.signal.addEventListener("abort",()=>{c=!0}),t.signal)})},f=Wx(t.options,t.fetchOptions),p=async(g,h,b)=>{if(c)return Promise.reject();if(h==null&&g.pages.length)return Promise.resolve(g);const x=(()=>{const N={client:t.client,queryKey:t.queryKey,pageParam:h,direction:b?"backward":"forward",meta:t.options.meta};return d(N),N})(),$=await f(x),{maxPages:v}=t.options,k=b?xR:wR;return{pages:k(g.pages,$,v),pageParams:k(g.pageParams,h,v)}};if(r&&i.length){const g=r==="backward",h=g?jR:$f,b={pages:i,pageParams:a},y=h(o,b);s=await p(b,y,g)}else{const g=e??i.length;do{const h=l===0?a[0]??o.initialPageParam:$f(o,s);if(l>0&&h==null)break;s=await p(s,h),l++}while(l<g)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=u}}}function $f(e,{pages:t,pageParams:n}){const o=t.length-1;return t.length>0?e.getNextPageParam(t[o],t,n[o],n):void 0}function jR(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var AR=class extends Kx{#e;#t;#r;#o;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#r=e.mutationCache,this.#t=[],this.state=e.state||RR(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#o?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#n({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#o=Gx({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),onFail:(i,a)=>{this.#n({type:"failed",failureCount:i,error:a})},onPause:()=>{this.#n({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#r.canRun(this)});const o=this.state.status==="pending",r=!this.#o.canStart();try{if(o)t();else{this.#n({type:"pending",variables:e,isPaused:r}),await this.#r.config.onMutate?.(e,this,n);const a=await this.options.onMutate?.(e,n);a!==this.state.context&&this.#n({type:"pending",context:a,variables:e,isPaused:r})}const i=await this.#o.start();return await this.#r.config.onSuccess?.(i,e,this.state.context,this,n),await this.options.onSuccess?.(i,e,this.state.context,n),await this.#r.config.onSettled?.(i,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(i,null,e,this.state.context,n),this.#n({type:"success",data:i}),i}catch(i){try{throw await this.#r.config.onError?.(i,e,this.state.context,this,n),await this.options.onError?.(i,e,this.state.context,n),await this.#r.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,i,e,this.state.context,n),i}finally{this.#n({type:"error",error:i})}}finally{this.#r.runNext(this)}}#n(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),ze.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#r.notify({mutation:this,type:"updated",action:e})})}};function RR(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var zR=class extends Oo{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,n){const o=new AR({client:e,mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:n});return this.add(o),o}add(e){this.#e.add(e);const t=Ho(e);if(typeof t=="string"){const n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=Ho(e);if(typeof t=="string"){const n=this.#t.get(t);if(n)if(n.length>1){const o=n.indexOf(e);o!==-1&&n.splice(o,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Ho(e);if(typeof t=="string"){const o=this.#t.get(t)?.find(r=>r.state.status==="pending");return!o||o===e}else return!0}runNext(e){const t=Ho(e);return typeof t=="string"?this.#t.get(t)?.find(o=>o!==e&&o.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ze.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>hf(t,n))}findAll(e={}){return this.getAll().filter(t=>hf(e,t))}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return ze.batch(()=>Promise.all(e.map(t=>t.continue().catch(Je))))}};function Ho(e){return e.options.scope?.id}var MR=class extends Oo{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){const o=t.queryKey,r=t.queryHash??Zc(o,t);let i=this.get(r);return i||(i=new OR({client:e,queryKey:o,queryHash:r,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(o)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ze.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>mf(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>mf(e,n)):t}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ze.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ze.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},DR=class{#e;#t;#r;#o;#n;#s;#a;#i;constructor(e={}){this.#e=e.queryCache||new MR,this.#t=e.mutationCache||new zR,this.#r=e.defaultOptions||{},this.#o=new Map,this.#n=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#a=Fc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=Pi.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#a?.(),this.#a=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#e.build(this,t),o=n.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(nr(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>{const o=n.data;return[t,o]})}setQueryData(e,t,n){const o=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(o.queryHash)?.state.data,a=yR(t,i);if(a!==void 0)return this.#e.build(this,o).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ze.batch(()=>this.#e.findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;ze.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#e;return ze.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},o=ze.batch(()=>this.#e.findAll(e).map(r=>r.cancel(n)));return Promise.all(o).then(Je).catch(Je)}invalidateQueries(e,t={}){return ze.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},o=ze.batch(()=>this.#e.findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,n);return n.throwOnError||(i=i.catch(Je)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(o).then(Je)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#e.build(this,t);return n.isStaleByTime(nr(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Je).catch(Je)}fetchInfiniteQuery(e){return e.behavior=xf(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Je).catch(Je)}ensureInfiniteQueryData(e){return e.behavior=xf(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Pi.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#o.set(Hn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#o.values()],n={};return t.forEach(o=>{Gn(e,o.queryKey)&&Object.assign(n,o.defaultOptions)}),n}setMutationDefaults(e,t){this.#n.set(Hn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#n.values()],n={};return t.forEach(o=>{Gn(e,o.mutationKey)&&Object.assign(n,o.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Zc(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Ni&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Qx=_.createContext(void 0),Xx=e=>{const t=_.useContext(Qx);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},UR=({client:e,children:t})=>(_.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),m.jsx(Qx.Provider,{value:e,children:t})),e$=_.createContext(!1),LR=()=>_.useContext(e$);e$.Provider;function ZR(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var FR=_.createContext(ZR()),qR=()=>_.useContext(FR),VR=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},BR=e=>{_.useEffect(()=>{e.clearReset()},[e])},JR=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(r&&e.data===void 0||$R(n,[e.error,o])),WR=e=>{if(e.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...r)=>n(o(...r)):n(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},HR=(e,t)=>e.isLoading&&e.isFetching&&!t,GR=(e,t)=>e?.suspense&&t.isPending,Sf=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function KR(e,t,n){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const o=LR(),r=qR(),i=Xx(),a=i.defaultQueryOptions(e);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a),process.env.NODE_ENV!=="production"&&(a.queryFn||console.error(`[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),a._optimisticResults=o?"isRestoring":"optimistic",WR(a),VR(a,r),BR(r);const s=!i.getQueryCache().get(a.queryHash),[l]=_.useState(()=>new t(i,a)),u=l.getOptimisticResult(a),c=!o&&e.subscribed!==!1;if(_.useSyncExternalStore(_.useCallback(d=>{const f=c?l.subscribe(ze.batchCalls(d)):Je;return l.updateResult(),f},[l,c]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),_.useEffect(()=>{l.setOptions(a)},[a,l]),GR(a,u))throw Sf(a,l,r);if(JR({result:u,errorResetBoundary:r,throwOnError:a.throwOnError,query:i.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw u.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,u),a.experimental_prefetchInRender&&!$r&&HR(u,o)&&(s?Sf(a,l,r):i.getQueryCache().get(a.queryHash)?.promise)?.catch(Je).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?u:l.trackResult(u)}function t$(e,t){return KR(e,NR)}const r$=({getSession:e,projectSlug:t})=>{const n=Xx(),o=["chatSession",t],r=n.getQueryState(o),i=r?.data!==void 0,a=r?.dataUpdatedAt??0,l=i&&Date.now()-a>1/0,u=!i||l,{data:c}=t$({queryKey:o,queryFn:()=>e({projectSlug:t}),enabled:u,staleTime:1/0,gcTime:1/0});return c??null};var YR=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const r=()=>{const i=n.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=n[Math.random()*i|0];return a.join("")};if(e==null)return r;if(n.includes(o))throw new Vi({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${n}".`});return()=>`${e}${o}${r()}`};YR();function n$(e=globalThis){var t,n,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(n=e.process)==null?void 0:n.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function QR(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,o)=>{t[o.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,o]of e)o!=null&&(t[n.toLowerCase()]=o)}return t}function o$(e,...t){const n=new Headers(QR(e)),o=n.get("user-agent")||"";return n.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(n.entries())}var XR=Symbol.for("vercel.ai.validator");function ez(e){return{...e,type:"dynamic"}}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");var tz=Symbol.for("vercel.ai.schema");function rz(e,{validate:t}={}){return{[tz]:!0,_type:void 0,[XR]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}let Vc;Vc=globalThis.crypto;async function nz(e){return(await Vc).getRandomValues(new Uint8Array(e))}async function oz(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";let n="";const o=await nz(e);for(let r=0;r<e;r++){const i=o[r]%t.length;n+=t[i]}return n}async function iz(e){return await oz(e)}async function az(e){const t=await(await Vc).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function sz(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;const t=await iz(e),n=await az(t);return{code_verifier:t,code_challenge:n}}var uz="AI_MCPClientError",i$=`vercel.ai.error.${uz}`,lz=Symbol.for(i$),If,kf,se=class extends(kf=Y,If=lz,kf){constructor({name:e="MCPClientError",message:t,cause:n,data:o,code:r}){super({name:e,message:t,cause:n}),this[If]=!0,this.data=o,this.code=r}static isInstance(e){return Y.hasMarker(e,i$)}},cn="2025-06-18",cz=[cn,"2025-03-26","2024-11-05"],dz=er({name:w(),version:w()}),Ja=er({_meta:ee(E({}).loose())}),Vt=Ja,a$=E({method:w(),params:ee(Ja)}),s$=E({applyDefaults:ee(pe())}).loose(),pz=er({experimental:ee(E({}).loose()),logging:ee(E({}).loose()),prompts:ee(er({listChanged:ee(pe())})),resources:ee(er({subscribe:ee(pe()),listChanged:ee(pe())})),tools:ee(er({listChanged:ee(pe())})),elicitation:ee(s$)});E({elicitation:ee(s$)}).loose();var fz=Vt.extend({protocolVersion:w(),capabilities:pz,serverInfo:dz,instructions:ee(w())}),Bc=Vt.extend({nextCursor:ee(w())}),mz=E({name:w(),description:ee(w()),inputSchema:E({type:C("object"),properties:ee(E({}).loose())}).loose()}).loose(),hz=Bc.extend({tools:R(mz)}),u$=E({type:C("text"),text:w()}).loose(),l$=E({type:C("image"),data:Ea(),mimeType:w()}).loose(),gz=E({uri:w(),name:w(),title:ee(w()),description:ee(w()),mimeType:ee(w()),size:ee(V())}).loose(),vz=Bc.extend({resources:R(gz)}),c$=E({uri:w(),name:ee(w()),title:ee(w()),mimeType:ee(w())}).loose(),d$=c$.extend({text:w()}),p$=c$.extend({blob:Ea()}),f$=E({type:C("resource"),resource:G([d$,p$])}).loose(),yz=Vt.extend({content:R(G([u$,l$,f$])),isError:pe().default(!1).optional()}).or(Vt.extend({toolResult:$e()})),bz=E({uriTemplate:w(),name:w(),title:ee(w()),description:ee(w()),mimeType:ee(w())}).loose(),_z=Vt.extend({resourceTemplates:R(bz)}),wz=Vt.extend({contents:R(G([d$,p$]))}),xz=E({name:w(),description:ee(w()),required:ee(pe())}).loose(),$z=E({name:w(),title:ee(w()),description:ee(w()),arguments:ee(R(xz))}).loose(),Sz=Bc.extend({prompts:R($z)}),Iz=E({role:G([C("user"),C("assistant")]),content:G([u$,l$,f$])}).loose(),kz=Vt.extend({description:ee(w()),messages:R(Iz)}),Ez=Ja.extend({message:w(),requestedSchema:$e()}),Ef=a$.extend({method:C("elicitation/create"),params:Ez}),Tz=Vt.extend({action:G([C("accept"),C("decline"),C("cancel")]),content:ee(Xe(w(),$e()))}),Wa="2.0",Oz=E({jsonrpc:C(Wa),id:G([w(),V().int()])}).merge(a$).strict(),Nz=E({jsonrpc:C(Wa),id:G([w(),V().int()]),result:Vt}).strict(),Pz=E({jsonrpc:C(Wa),id:G([w(),V().int()]),error:E({code:V().int(),message:w(),data:ee($e())})}).strict(),Cz=E({jsonrpc:C(Wa)}).merge(E({method:w(),params:ee(Ja)})).strict(),Tn=G([Oz,Cz,Nz,Pz]),m$=typeof __PACKAGE_VERSION__<"u"?__PACKAGE_VERSION__:"0.0.0-test",h$=E({access_token:w(),id_token:w().optional(),token_type:w(),expires_in:V().optional(),scope:w().optional(),refresh_token:w().optional()}).strip(),He=w().url().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:v_.custom,message:"URL must be parseable",fatal:!0}),Uu}).refine(e=>{const t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),jz=E({resource:w().url(),authorization_servers:R(He).optional(),jwks_uri:w().url().optional(),scopes_supported:R(w()).optional(),bearer_methods_supported:R(w()).optional(),resource_signing_alg_values_supported:R(w()).optional(),resource_name:w().optional(),resource_documentation:w().optional(),resource_policy_uri:w().url().optional(),resource_tos_uri:w().url().optional(),tls_client_certificate_bound_access_tokens:pe().optional(),authorization_details_types_supported:R(w()).optional(),dpop_signing_alg_values_supported:R(w()).optional(),dpop_bound_access_tokens_required:pe().optional()}).passthrough(),g$=E({issuer:w(),authorization_endpoint:He,token_endpoint:He,registration_endpoint:He.optional(),scopes_supported:R(w()).optional(),response_types_supported:R(w()),grant_types_supported:R(w()).optional(),code_challenge_methods_supported:R(w()),token_endpoint_auth_methods_supported:R(w()).optional(),token_endpoint_auth_signing_alg_values_supported:R(w()).optional()}).passthrough(),Az=E({issuer:w(),authorization_endpoint:He,token_endpoint:He,userinfo_endpoint:He.optional(),jwks_uri:He,registration_endpoint:He.optional(),scopes_supported:R(w()).optional(),response_types_supported:R(w()),grant_types_supported:R(w()).optional(),subject_types_supported:R(w()),id_token_signing_alg_values_supported:R(w()),claims_supported:R(w()).optional(),token_endpoint_auth_methods_supported:R(w()).optional()}).passthrough(),Rz=Az.merge(g$.pick({code_challenge_methods_supported:!0})),zz=E({client_id:w(),client_secret:w().optional(),client_id_issued_at:V().optional(),client_secret_expires_at:V().optional()}).strip(),Mz=E({redirect_uris:R(He),token_endpoint_auth_method:w().optional(),grant_types:R(w()).optional(),response_types:R(w()).optional(),client_name:w().optional(),client_uri:He.optional(),logo_uri:He.optional(),scope:w().optional(),contacts:R(w()).optional(),tos_uri:He.optional(),policy_uri:w().optional(),jwks_uri:He.optional(),jwks:Pe().optional(),software_id:w().optional(),software_version:w().optional(),software_statement:w().optional()}).strip(),Dz=E({error:w(),error_description:w().optional(),error_uri:w().optional()}),Uz=Mz.merge(zz),Lz="AI_MCPClientOAuthError",v$=`vercel.ai.error.${Lz}`,Zz=Symbol.for(v$),Tf,Of,No=class extends(Of=Y,Tf=Zz,Of){constructor({name:e="MCPClientOAuthError",message:t,cause:n}){super({name:e,message:t,cause:n}),this[Tf]=!0}static isInstance(e){return Y.hasMarker(e,v$)}},rn=class extends No{};rn.errorCode="server_error";var Ci=class extends No{};Ci.errorCode="invalid_client";var ji=class extends No{};ji.errorCode="invalid_grant";var Ai=class extends No{};Ai.errorCode="unauthorized_client";var Fz={[rn.errorCode]:rn,[Ci.errorCode]:Ci,[ji.errorCode]:ji,[Ai.errorCode]:Ai};function qz(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function Vz({requestedResource:e,configuredResource:t}){const n=typeof e=="string"?new URL(e):new URL(e.href),o=typeof t=="string"?new URL(t):new URL(t.href);if(n.origin!==o.origin||n.pathname.length<o.pathname.length)return!1;const r=n.pathname.endsWith("/")?n.pathname:n.pathname+"/",i=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return r.startsWith(i)}var Ri=class extends Error{constructor(e="Unauthorized"){super(e),this.name="UnauthorizedError"}};function zi(e){var t;const n=(t=e.headers.get("www-authenticate"))!=null?t:e.headers.get("WWW-Authenticate");if(!n)return;const[o,r]=n.split(" ");if(o.toLowerCase()!=="bearer"||!r)return;const i=/resource_metadata="([^"]*)"/,a=n.match(i);if(a)try{return new URL(a[1])}catch{return}}function Bz(e,t="",n={}){return t.endsWith("/")&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function Jc(e,t,n=fetch){try{return await n(e,{headers:t})}catch(o){if(o instanceof TypeError)return t?Jc(e,void 0,n):void 0;throw o}}async function Nf(e,t,n=fetch){return await Jc(e,{"MCP-Protocol-Version":t},n)}function Jz(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function Wz(e,t,n,o){var r,i;const a=new URL(e),s=(r=o?.protocolVersion)!=null?r:cn;let l;if(o?.metadataUrl)l=new URL(o.metadataUrl);else{const c=Bz(t,a.pathname);l=new URL(c,(i=o?.metadataServerUrl)!=null?i:a),l.search=a.search}let u=await Nf(l,s,n);if(!o?.metadataUrl&&Jz(u,a.pathname)){const c=new URL(`/.well-known/${t}`,a);u=await Nf(c,s,n)}return u}async function Hz(e,t,n=fetch){const o=await Wz(e,"oauth-protected-resource",n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!o||o.status===404)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!o.ok)throw new Error(`HTTP ${o.status} trying to load well-known OAuth protected resource metadata.`);return jz.parse(await o.json())}function Gz(e){const t=typeof e=="string"?new URL(e):e,n=t.pathname!=="/",o=[];if(!n)return o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),o.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),o;let r=t.pathname;return r.endsWith("/")&&(r=r.slice(0,-1)),o.push({url:new URL(`/.well-known/oauth-authorization-server${r}`,t.origin),type:"oauth"}),o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),o.push({url:new URL(`/.well-known/openid-configuration${r}`,t.origin),type:"oidc"}),o.push({url:new URL(`${r}/.well-known/openid-configuration`,t.origin),type:"oidc"}),o}async function Kz(e,{fetchFn:t=fetch,protocolVersion:n=cn}={}){var o;const r={"MCP-Protocol-Version":n},i=Gz(e);for(const{url:a,type:s}of i){const l=await Jc(a,r,t);if(l){if(!l.ok){if(l.status>=400&&l.status<500)continue;throw new Error(`HTTP ${l.status} trying to load ${s==="oauth"?"OAuth":"OpenID provider"} metadata from ${a}`)}if(s==="oauth")return g$.parse(await l.json());{const u=Rz.parse(await l.json());if(!((o=u.code_challenge_methods_supported)!=null&&o.includes("S256")))throw new Error(`Incompatible OIDC provider at ${a}: does not support S256 code challenge method required by MCP specification`);return u}}}}async function Yz(e,{metadata:t,clientInformation:n,redirectUrl:o,scope:r,state:i,resource:a}){const s="code",l="S256";let u;if(t){if(u=new URL(t.authorization_endpoint),!t.response_types_supported.includes(s))throw new Error(`Incompatible auth server: does not support response type ${s}`);if(!t.code_challenge_methods_supported||!t.code_challenge_methods_supported.includes(l))throw new Error(`Incompatible auth server: does not support code challenge method ${l}`)}else u=new URL("/authorize",e);const c=await sz(),d=c.code_verifier,f=c.code_challenge;return u.searchParams.set("response_type",s),u.searchParams.set("client_id",n.client_id),u.searchParams.set("code_challenge",f),u.searchParams.set("code_challenge_method",l),u.searchParams.set("redirect_uri",String(o)),i&&u.searchParams.set("state",i),r&&u.searchParams.set("scope",r),r?.includes("offline_access")&&u.searchParams.append("prompt","consent"),a&&u.searchParams.set("resource",a.href),{authorizationUrl:u,codeVerifier:d}}function y$(e,t){const n=e.client_secret!==void 0;return t.length===0?n?"client_secret_post":"none":n&&t.includes("client_secret_basic")?"client_secret_basic":n&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":n?"client_secret_post":"none"}function b$(e,t,n,o){const{client_id:r,client_secret:i}=t;switch(e){case"client_secret_basic":Qz(r,i,n);return;case"client_secret_post":Xz(r,i,o);return;case"none":eM(r,o);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function Qz(e,t,n){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");const o=btoa(`${e}:${t}`);n.set("Authorization",`Basic ${o}`)}function Xz(e,t,n){n.set("client_id",e),t&&n.set("client_secret",t)}function eM(e,t){t.set("client_id",e)}async function Wc(e){const t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{const o=Dz.parse(JSON.parse(n)),{error:r,error_description:i,error_uri:a}=o,s=Fz[r]||rn;return new s({message:i||"",cause:a})}catch(o){const r=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${o}. Raw body: ${n}`;return new rn({message:r})}}async function tM(e,{metadata:t,clientInformation:n,authorizationCode:o,codeVerifier:r,redirectUri:i,resource:a,addClientAuthentication:s,fetchFn:l}){var u;const c="authorization_code",d=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e);if(t?.grant_types_supported&&!t.grant_types_supported.includes(c))throw new Error(`Incompatible auth server: does not support grant type ${c}`);const f=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),p=new URLSearchParams({grant_type:c,code:o,code_verifier:r,redirect_uri:String(i)});if(s)s(f,p,e,t);else{const h=(u=t?.token_endpoint_auth_methods_supported)!=null?u:[],b=y$(n,h);b$(b,n,f,p)}a&&p.set("resource",a.href);const g=await(l??fetch)(d,{method:"POST",headers:f,body:p});if(!g.ok)throw await Wc(g);return h$.parse(await g.json())}async function rM(e,{metadata:t,clientInformation:n,refreshToken:o,resource:r,addClientAuthentication:i,fetchFn:a}){var s;const l="refresh_token";let u;if(t){if(u=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(l))throw new Error(`Incompatible auth server: does not support grant type ${l}`)}else u=new URL("/token",e);const c=new Headers({"Content-Type":"application/x-www-form-urlencoded"}),d=new URLSearchParams({grant_type:l,refresh_token:o});if(i)i(c,d,e,t);else{const p=(s=t?.token_endpoint_auth_methods_supported)!=null?s:[],g=y$(n,p);b$(g,n,c,d)}r&&d.set("resource",r.href);const f=await(a??fetch)(u,{method:"POST",headers:c,body:d});if(!f.ok)throw await Wc(f);return h$.parse({refresh_token:o,...await f.json()})}async function nM(e,{metadata:t,clientMetadata:n,fetchFn:o}){let r;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");r=new URL(t.registration_endpoint)}else r=new URL("/register",e);const i=await(o??fetch)(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok)throw await Wc(i);return Uz.parse(await i.json())}async function Mi(e,t){var n,o;try{return await Ms(e,t)}catch(r){if(r instanceof Ci||r instanceof Ai)return await((n=e.invalidateCredentials)==null?void 0:n.call(e,"all")),await Ms(e,t);if(r instanceof ji)return await((o=e.invalidateCredentials)==null?void 0:o.call(e,"tokens")),await Ms(e,t);throw r}}async function oM(e,t,n){const o=qz(e);if(t.validateResourceURL)return await t.validateResourceURL(o,n?.resource);if(n){if(!Vz({requestedResource:o,configuredResource:n.resource}))throw new Error(`Protected resource ${n.resource} does not match expected ${o} (or origin)`);return new URL(n.resource)}}async function Ms(e,{serverUrl:t,authorizationCode:n,scope:o,resourceMetadataUrl:r,fetchFn:i}){let a,s;try{a=await Hz(t,{resourceMetadataUrl:r},i),a.authorization_servers&&a.authorization_servers.length>0&&(s=a.authorization_servers[0])}catch{}s||(s=t);const l=await oM(t,e,a),u=await Kz(s,{fetchFn:i});let c=await Promise.resolve(e.clientInformation());if(!c){if(n!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const h=await nM(s,{metadata:u,clientMetadata:e.clientMetadata,fetchFn:i});await e.saveClientInformation(h),c=h}if(n!==void 0){const h=await e.codeVerifier(),b=await tM(s,{metadata:u,clientInformation:c,authorizationCode:n,codeVerifier:h,redirectUri:e.redirectUrl,resource:l,addClientAuthentication:e.addClientAuthentication,fetchFn:i});return await e.saveTokens(b),"AUTHORIZED"}const d=await e.tokens();if(d?.refresh_token)try{const h=await rM(s,{metadata:u,clientInformation:c,refreshToken:d.refresh_token,resource:l,addClientAuthentication:e.addClientAuthentication,fetchFn:i});return await e.saveTokens(h),"AUTHORIZED"}catch(h){if(!(!(h instanceof No)||h instanceof rn))throw h}const f=e.state?await e.state():void 0,{authorizationUrl:p,codeVerifier:g}=await Yz(s,{metadata:u,clientInformation:c,state:f,redirectUrl:e.redirectUrl,scope:o||e.clientMetadata.scope,resource:l});return await e.saveCodeVerifier(g),await e.redirectToAuthorization(p),"REDIRECT"}var iM=class{constructor({url:e,headers:t,authProvider:n}){this.connected=!1,this.url=new URL(e),this.headers=t,this.authProvider=n}async commonHeaders(e){const t={...this.headers,...e,"mcp-protocol-version":cn};if(this.authProvider){const n=await this.authProvider.tokens();n?.access_token&&(t.Authorization=`Bearer ${n.access_token}`)}return o$(t,`ai-sdk/${m$}`,n$())}async start(){return new Promise((e,t)=>{if(this.connected)return e();this.abortController=new AbortController;const n=async(o=!1)=>{var r,i,a,s,l;try{const u=await this.commonHeaders({Accept:"text/event-stream"}),c=await fetch(this.url.href,{headers:u,signal:(r=this.abortController)==null?void 0:r.signal});if(c.status===401&&this.authProvider&&!o){this.resourceMetadataUrl=zi(c);try{if(await Mi(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const h=new Ri;return(i=this.onerror)==null||i.call(this,h),t(h)}}catch(g){return(a=this.onerror)==null||a.call(this,g),t(g)}return n(!0)}if(!c.ok||!c.body){let g=`MCP SSE Transport Error: ${c.status} ${c.statusText}`;c.status===405&&(g+=". This server does not support SSE transport. Try using `http` transport instead");const h=new se({message:g});return(s=this.onerror)==null||s.call(this,h),t(h)}const f=c.body.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).getReader(),p=async()=>{var g,h,b;try{for(;;){const{done:y,value:x}=await f.read();if(y){if(this.connected)throw this.connected=!1,new se({message:"MCP SSE Transport Error: Connection closed unexpectedly"});return}const{event:$,data:v}=x;if($==="endpoint"){if(this.endpoint=new URL(v,this.url),this.endpoint.origin!==this.url.origin)throw new se({message:`MCP SSE Transport Error: Endpoint origin does not match connection origin: ${this.endpoint.origin}`});this.connected=!0,e()}else if($==="message")try{const k=Tn.parse(JSON.parse(v));(g=this.onmessage)==null||g.call(this,k)}catch(k){const N=new se({message:"MCP SSE Transport Error: Failed to parse message",cause:k});(h=this.onerror)==null||h.call(this,N)}}}catch(y){if(y instanceof Error&&y.name==="AbortError")return;(b=this.onerror)==null||b.call(this,y),t(y)}};this.sseConnection={close:()=>f.cancel()},p()}catch(u){if(u instanceof Error&&u.name==="AbortError")return;(l=this.onerror)==null||l.call(this,u),t(u)}};n()})}async close(){var e,t,n;this.connected=!1,(e=this.sseConnection)==null||e.close(),(t=this.abortController)==null||t.abort(),(n=this.onclose)==null||n.call(this)}async send(e){if(!this.endpoint||!this.connected)throw new se({message:"MCP SSE Transport Error: Not connected"});const t=this.endpoint,n=async(o=!1)=>{var r,i,a,s,l;try{const c={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json"}),body:JSON.stringify(e),signal:(r=this.abortController)==null?void 0:r.signal},d=await fetch(t,c);if(d.status===401&&this.authProvider&&!o){this.resourceMetadataUrl=zi(d);try{if(await Mi(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const p=new Ri;(i=this.onerror)==null||i.call(this,p);return}}catch(f){(a=this.onerror)==null||a.call(this,f);return}return n(!0)}if(!d.ok){const f=await d.text().catch(()=>null),p=new se({message:`MCP SSE Transport Error: POSTing to endpoint (HTTP ${d.status}): ${f}`});(s=this.onerror)==null||s.call(this,p);return}}catch(u){(l=this.onerror)==null||l.call(this,u);return}};await n()}},aM=class{constructor({url:e,headers:t,authProvider:n}){this.inboundReconnectAttempts=0,this.reconnectionOptions={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},this.url=new URL(e),this.headers=t,this.authProvider=n}async commonHeaders(e){const t={...this.headers,...e,"mcp-protocol-version":cn};if(this.sessionId&&(t["mcp-session-id"]=this.sessionId),this.authProvider){const n=await this.authProvider.tokens();n?.access_token&&(t.Authorization=`Bearer ${n.access_token}`)}return o$(t,`ai-sdk/${m$}`,n$())}async start(){if(this.abortController)throw new se({message:"MCP HTTP Transport Error: Transport already started. Note: client.connect() calls start() automatically."});this.abortController=new AbortController,this.openInboundSse()}async close(){var e,t,n;(e=this.inboundSseConnection)==null||e.close();try{if(this.sessionId&&this.abortController&&!this.abortController.signal.aborted){const o=await this.commonHeaders({});await fetch(this.url,{method:"DELETE",headers:o,signal:this.abortController.signal}).catch(()=>{})}}catch{}(t=this.abortController)==null||t.abort(),(n=this.onclose)==null||n.call(this)}async send(e){const t=async(n=!1)=>{var o,r,i,a,s,l,u;try{const d={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json",Accept:"application/json, text/event-stream"}),body:JSON.stringify(e),signal:(o=this.abortController)==null?void 0:o.signal},f=await fetch(this.url,d),p=f.headers.get("mcp-session-id");if(p&&(this.sessionId=p),f.status===401&&this.authProvider&&!n){this.resourceMetadataUrl=zi(f);try{if(await Mi(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED")throw new Ri}catch(b){throw(r=this.onerror)==null||r.call(this,b),b}return t(!0)}if(f.status===202){this.inboundSseConnection||this.openInboundSse();return}if(!f.ok){const b=await f.text().catch(()=>null);let y=`MCP HTTP Transport Error: POSTing to endpoint (HTTP ${f.status}): ${b}`;f.status===404&&(y+=". This server does not support HTTP transport. Try using `sse` transport instead");const x=new se({message:y});throw(i=this.onerror)==null||i.call(this,x),x}const g=f.headers.get("content-type")||"";if(g.includes("application/json")){const b=await f.json(),y=Array.isArray(b)?b.map(x=>Tn.parse(x)):[Tn.parse(b)];for(const x of y)(a=this.onmessage)==null||a.call(this,x);return}if(g.includes("text/event-stream")){if(!f.body){const $=new se({message:"MCP HTTP Transport Error: text/event-stream response without body"});throw(s=this.onerror)==null||s.call(this,$),$}const y=f.body.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).getReader();(async()=>{var $,v,k;try{for(;;){const{done:N,value:I}=await y.read();if(N)return;const{event:O,data:z}=I;if(O==="message")try{const F=Tn.parse(JSON.parse(z));($=this.onmessage)==null||$.call(this,F)}catch(F){const te=new se({message:"MCP HTTP Transport Error: Failed to parse message",cause:F});(v=this.onerror)==null||v.call(this,te)}}}catch(N){if(N instanceof Error&&N.name==="AbortError")return;(k=this.onerror)==null||k.call(this,N)}})();return}const h=new se({message:`MCP HTTP Transport Error: Unexpected content type: ${g}`});throw(l=this.onerror)==null||l.call(this,h),h}catch(c){throw(u=this.onerror)==null||u.call(this,c),c}};await t()}getNextReconnectionDelay(e){const{initialReconnectionDelay:t,reconnectionDelayGrowFactor:n,maxReconnectionDelay:o}=this.reconnectionOptions;return Math.min(t*Math.pow(n,e),o)}scheduleInboundSseReconnection(){var e;const{maxRetries:t}=this.reconnectionOptions;if(t>0&&this.inboundReconnectAttempts>=t){(e=this.onerror)==null||e.call(this,new se({message:`MCP HTTP Transport Error: Maximum reconnection attempts (${t}) exceeded.`}));return}const n=this.getNextReconnectionDelay(this.inboundReconnectAttempts);this.inboundReconnectAttempts+=1,setTimeout(async()=>{var o;(o=this.abortController)!=null&&o.signal.aborted||await this.openInboundSse(!1,this.lastInboundEventId)},n)}async openInboundSse(e=!1,t){var n,o,r,i,a,s;try{const l=await this.commonHeaders({Accept:"text/event-stream"});t&&(l["last-event-id"]=t);const u=await fetch(this.url.href,{method:"GET",headers:l,signal:(n=this.abortController)==null?void 0:n.signal}),c=u.headers.get("mcp-session-id");if(c&&(this.sessionId=c),u.status===401&&this.authProvider&&!e){this.resourceMetadataUrl=zi(u);try{if(await Mi(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const h=new Ri;(o=this.onerror)==null||o.call(this,h);return}}catch(g){(r=this.onerror)==null||r.call(this,g);return}return this.openInboundSse(!0,t)}if(u.status===405)return;if(!u.ok||!u.body){const g=new se({message:`MCP HTTP Transport Error: GET SSE failed: ${u.status} ${u.statusText}`});(i=this.onerror)==null||i.call(this,g);return}const f=u.body.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).getReader(),p=async()=>{var g,h,b,y;try{for(;;){const{done:x,value:$}=await f.read();if(x)return;const{event:v,data:k,id:N}=$;if(N&&(this.lastInboundEventId=N),v==="message")try{const I=Tn.parse(JSON.parse(k));(g=this.onmessage)==null||g.call(this,I)}catch(I){const O=new se({message:"MCP HTTP Transport Error: Failed to parse message",cause:I});(h=this.onerror)==null||h.call(this,O)}}}catch(x){if(x instanceof Error&&x.name==="AbortError")return;(b=this.onerror)==null||b.call(this,x),(y=this.abortController)!=null&&y.signal.aborted||this.scheduleInboundSseReconnection()}};this.inboundSseConnection={close:()=>f.cancel()},this.inboundReconnectAttempts=0,p()}catch(l){if(l instanceof Error&&l.name==="AbortError")return;(a=this.onerror)==null||a.call(this,l),(s=this.abortController)!=null&&s.signal.aborted||this.scheduleInboundSseReconnection()}}};function sM(e){switch(e.type){case"sse":return new iM(e);case"http":return new aM(e);default:throw new se({message:"Unsupported or invalid transport configuration. If you are using a custom transport, make sure it implements the MCPTransport interface."})}}function uM(e){return"start"in e&&typeof e.start=="function"&&"send"in e&&typeof e.send=="function"&&"close"in e&&typeof e.close=="function"}var lM="1.0.0";async function cM(e){const t=new dM(e);return await t.init(),t}var dM=class{constructor({transport:e,name:t="ai-sdk-mcp-client",version:n=lM,onUncaughtError:o,capabilities:r}){this.requestMessageId=0,this.responseHandlers=new Map,this.serverCapabilities={},this.isClosed=!0,this.onUncaughtError=o,this.clientCapabilities=r??{},uM(e)?this.transport=e:this.transport=sM(e),this.transport.onclose=()=>this.onClose(),this.transport.onerror=i=>this.onError(i),this.transport.onmessage=i=>{if("method"in i){"id"in i?this.onRequestMessage(i):this.onError(new se({message:"Unsupported message type"}));return}this.onResponse(i)},this.clientInfo={name:t,version:n}}async init(){try{await this.transport.start(),this.isClosed=!1;const e=await this.request({request:{method:"initialize",params:{protocolVersion:cn,capabilities:this.clientCapabilities,clientInfo:this.clientInfo}},resultSchema:fz});if(e===void 0)throw new se({message:"Server sent invalid initialize result"});if(!cz.includes(e.protocolVersion))throw new se({message:`Server's protocol version is not supported: ${e.protocolVersion}`});return this.serverCapabilities=e.capabilities,await this.notification({method:"notifications/initialized"}),this}catch(e){throw await this.close(),e}}async close(){var e;this.isClosed||(await((e=this.transport)==null?void 0:e.close()),this.onClose())}assertCapability(e){switch(e){case"initialize":break;case"tools/list":case"tools/call":if(!this.serverCapabilities.tools)throw new se({message:"Server does not support tools"});break;case"resources/list":case"resources/read":case"resources/templates/list":if(!this.serverCapabilities.resources)throw new se({message:"Server does not support resources"});break;case"prompts/list":case"prompts/get":if(!this.serverCapabilities.prompts)throw new se({message:"Server does not support prompts"});break;default:throw new se({message:`Unsupported method: ${e}`})}}async request({request:e,resultSchema:t,options:n}){return new Promise((o,r)=>{if(this.isClosed)return r(new se({message:"Attempted to send a request from a closed client"}));this.assertCapability(e.method);const i=n?.signal;i?.throwIfAborted();const a=this.requestMessageId++,s={...e,jsonrpc:"2.0",id:a},l=()=>{this.responseHandlers.delete(a)};this.responseHandlers.set(a,u=>{if(i?.aborted)return r(new se({message:"Request was aborted",cause:i.reason}));if(u instanceof Error)return r(u);try{const c=t.parse(u.result);o(c)}catch(c){const d=new se({message:"Failed to parse server response",cause:c});r(d)}}),this.transport.send(s).catch(u=>{l(),r(u)})})}async listTools({params:e,options:t}={}){try{return this.request({request:{method:"tools/list",params:e},resultSchema:hz,options:t})}catch(n){throw n}}async callTool({name:e,args:t,options:n}){try{return this.request({request:{method:"tools/call",params:{name:e,arguments:t}},resultSchema:yz,options:{signal:n?.abortSignal}})}catch(o){throw o}}async listResourcesInternal({params:e,options:t}={}){try{return this.request({request:{method:"resources/list",params:e},resultSchema:vz,options:t})}catch(n){throw n}}async readResourceInternal({uri:e,options:t}){try{return this.request({request:{method:"resources/read",params:{uri:e}},resultSchema:wz,options:t})}catch(n){throw n}}async listResourceTemplatesInternal({options:e}={}){try{return this.request({request:{method:"resources/templates/list"},resultSchema:_z,options:e})}catch(t){throw t}}async listPromptsInternal({params:e,options:t}={}){try{return this.request({request:{method:"prompts/list",params:e},resultSchema:Sz,options:t})}catch(n){throw n}}async getPromptInternal({name:e,args:t,options:n}){try{return this.request({request:{method:"prompts/get",params:{name:e,arguments:t}},resultSchema:kz,options:n})}catch(o){throw o}}async notification(e){const t={...e,jsonrpc:"2.0"};await this.transport.send(t)}async tools({schemas:e="automatic"}={}){var t;const n={};try{const o=await this.listTools();for(const{name:r,description:i,inputSchema:a}of o.tools){if(e!=="automatic"&&!(r in e))continue;const s=this,l=async(c,d)=>{var f;return(f=d?.abortSignal)==null||f.throwIfAborted(),s.callTool({name:r,args:c,options:d})},u=e==="automatic"?ez({description:i,inputSchema:rz({...a,properties:(t=a.properties)!=null?t:{},additionalProperties:!1}),execute:l}):{description:i,inputSchema:e[r].inputSchema,execute:l};n[r]=u}return n}catch(o){throw o}}listResources({params:e,options:t}={}){return this.listResourcesInternal({params:e,options:t})}readResource({uri:e,options:t}){return this.readResourceInternal({uri:e,options:t})}listResourceTemplates({options:e}={}){return this.listResourceTemplatesInternal({options:e})}listPrompts({params:e,options:t}={}){return this.listPromptsInternal({params:e,options:t})}getPrompt({name:e,arguments:t,options:n}){return this.getPromptInternal({name:e,args:t,options:n})}onElicitationRequest(e,t){if(e!==Ef)throw new se({message:"Unsupported request schema. Only ElicitationRequestSchema is supported."});this.elicitationRequestHandler=t}async onRequestMessage(e){try{if(e.method!=="elicitation/create"){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Unsupported request method: ${e.method}`}});return}if(!this.elicitationRequestHandler){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32601,message:"No elicitation handler registered on client"}});return}const t=Ef.safeParse({method:e.method,params:e.params});if(!t.success){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Invalid elicitation request: ${t.error.message}`,data:t.error.issues}});return}try{const n=await this.elicitationRequestHandler(t.data),o=Tz.parse(n);await this.transport.send({jsonrpc:"2.0",id:e.id,result:o})}catch(n){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32603,message:n instanceof Error?n.message:"Failed to handle elicitation request"}}),this.onError(n)}}catch(t){this.onError(t)}}onClose(){if(this.isClosed)return;this.isClosed=!0;const e=new se({message:"Connection closed"});for(const t of this.responseHandlers.values())t(e);this.responseHandlers.clear()}onError(e){this.onUncaughtError&&this.onUncaughtError(e)}onResponse(e){const t=Number(e.id),n=this.responseHandlers.get(t);if(n===void 0)throw new se({message:`Protocol error: Received a response for an unknown message ID: ${JSON.stringify(e)}`});this.responseHandlers.delete(t),n("result"in e?e:new se({message:e.error.message,code:e.error.code,data:e.error.data,cause:e.error}))}};function pM({getSession:e,projectSlug:t,mcp:n,environment:o}){const r=r$({getSession:e,projectSlug:t});return t$({queryKey:["mcpTools",t,n,r],queryFn:async()=>(T.assert(r,"No session found"),T.assert(n,"No MCP URL found"),await(await cM({name:"gram-elements-mcp-client",transport:{type:"http",url:n,headers:{...fM(o??{}),"Gram-Chat-Session":r}}})).tools()),enabled:!!r&&!!n,staleTime:1/0,gcTime:1/0})}const Pf="MCP-";function fM(e){return typeof e!="object"||e===null?{}:Object.entries(e).reduce((t,[n,o])=>{const r=n.replace(/_/g,"-"),i=r.startsWith(Pf)?r:`${Pf}${r}`;return t[i]=o,t},{})}function mM({children:e}){const[t,n]=D.useState(new Map),[o,r]=D.useState(new Set),i=D.useCallback((d,f,p)=>new Promise(g=>{const h={toolCallId:f,toolName:d,args:p,resolve:g};n(b=>{const y=new Map(b);return y.set(f,h),y})}),[]),a=D.useCallback(d=>{r(f=>{const p=new Set(f);return p.add(d),p})},[]),s=D.useCallback(d=>{n(f=>{const p=f.get(d);if(p){p.resolve(!0);const g=new Map(f);return g.delete(d),g}return f})},[]),l=D.useCallback(d=>{n(f=>{const p=f.get(d);if(p){p.resolve(!1);const g=new Map(f);return g.delete(d),g}return f})},[]),u=D.useCallback(d=>o.has(d),[o]),c=D.useCallback(d=>t.get(d),[t]);return m.jsx(T.ToolApprovalContext.Provider,{value:{pendingApprovals:t,approvedTools:o,requestApproval:i,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:l,isToolApproved:u,getPendingApproval:c},children:e})}const _$=()=>{const e=D.useContext(T.ToolApprovalContext);if(!e)throw new Error("useToolApproval must be used within a ToolApprovalProvider");return e},hM="You are a helpful assistant that can answer questions and help with tasks.";function gM(e,t){return`
|
|
89
|
+
${hM}
|
|
90
90
|
|
|
91
91
|
User-provided System Prompt:
|
|
92
92
|
${e??"None provided"}
|
|
93
93
|
|
|
94
94
|
Utilities:
|
|
95
95
|
${t.map(n=>`- ${n.language}: ${n.prompt}`).join(`
|
|
96
|
-
`)}`}async function lM(){return(await(await fetch("/chat/session",{method:"POST"})).json()).client_token}const cM=({children:e,config:t,getSession:n=lM})=>{const o=e$({getSession:n,projectSlug:t.projectSlug}),[r,i]=F.useState(t.model?.defaultModel??im[0]),[a,s]=F.useState(t.modal?.defaultExpanded??!1),[l,u]=F.useState(t.modal?.defaultOpen),c=t.plugins??O.recommended,d=uM(t.systemPrompt,c),{data:p,isLoading:f}=oM({getSession:n,projectSlug:t.projectSlug,mcp:t.mcp,environment:t.environment??{}}),g=!p||f,m=F.useMemo(()=>({sendMessages:async({messages:y,abortSignal:x})=>{const $=!!t.languageModel;if(!o)throw new Error("No session found");if(f||!p)throw new Error("MCP tools are still being discovered");const v=b.thread.getModelContext(),k=oR(iR(v?.tools??{})),N=$?null:Tw({baseURL:aM,apiKey:"unused, but must be set",headers:{"Gram-Project":t.projectSlug,"Gram-Chat-Session":o}});t.languageModel&&console.log("Using custom language model",t.languageModel);const I={...p,..._P(k)},T=t.languageModel?t.languageModel:N.chat(r);try{return GA({system:d,model:T,messages:QA(y),tools:I,stopWhen:Dx(10),experimental_transform:nR({delayInMs:15}),abortSignal:x,onError:({error:Z})=>{console.error("Stream error in onError callback:",Z)}}).toUIMessageStream()}catch(z){throw console.error("Error creating stream:",z),z}},reconnectToStream:async()=>{throw new Error("Stream reconnection not supported")}}),[t,t.languageModel,r,d,o,p,f]),b=bP({transport:m});return h.jsx(U.AssistantRuntimeProvider,{runtime:b,children:h.jsxs(O.ElementsContext.Provider,{value:{config:t,setModel:i,model:r,isExpanded:a,setIsExpanded:s,isOpen:l??!1,setIsOpen:u,plugins:c,isLoadingMCPTools:g},children:[e,h.jsx(g0,{tools:t.tools?.frontendTools??{}})]})})},dM=e=>{const t=new NR;return h.jsx(PR,{client:t,children:h.jsx(cM,{...e})})};function Np(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Jc(...e){return t=>{let n=!1;const o=e.map(r=>{const i=Np(r,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let r=0;r<o.length;r++){const i=o[r];typeof i=="function"?i():Np(e[r],null)}}}}function Ge(...e){return _.useCallback(Jc(...e),e)}var fM=Symbol.for("react.lazy"),Ri=_[" use ".trim().toString()];function pM(e){return typeof e=="object"&&e!==null&&"then"in e}function y$(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===fM&&"_payload"in e&&pM(e._payload)}function b$(e){const t=hM(e),n=_.forwardRef((o,r)=>{let{children:i,...a}=o;y$(i)&&typeof Ri=="function"&&(i=Ri(i._payload));const s=_.Children.toArray(i),l=s.find(yM);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return h.jsx(t,{...a,ref:r,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return h.jsx(t,{...a,ref:r,children:i})});return n.displayName=`${e}.Slot`,n}var mM=b$("Slot");function hM(e){const t=_.forwardRef((n,o)=>{let{children:r,...i}=n;if(y$(r)&&typeof Ri=="function"&&(r=Ri(r._payload)),_.isValidElement(r)){const a=_M(r),s=bM(i,r.props);return r.type!==_.Fragment&&(s.ref=o?Jc(o,a):a),_.cloneElement(r,s)}return _.Children.count(r)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var _$=Symbol("radix.slottable");function gM(e){const t=({children:n})=>h.jsx(h.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=_$,t}var vM=gM("Slottable");function yM(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===_$}function bM(e,t){const n={...t};for(const o in t){const r=e[o],i=t[o];/^on[A-Z]/.test(o)?r&&i?n[o]=(...s)=>{const l=i(...s);return r(...s),l}:r&&(n[o]=r):o==="style"?n[o]={...r,...i}:o==="className"&&(n[o]=[r,i].filter(Boolean).join(" "))}return{...e,...n}}function _M(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const Pp=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Cp=O.clsx,wM=(e,t)=>n=>{var o;if(t?.variants==null)return Cp(e,n?.class,n?.className);const{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(u=>{const c=n?.[u],d=i?.[u];if(c===null)return null;const p=Pp(c)||Pp(d);return r[u][p]}),s=n&&Object.entries(n).reduce((u,c)=>{let[d,p]=c;return p===void 0||(u[d]=p),u},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((u,c)=>{let{class:d,className:p,...f}=c;return Object.entries(f).every(g=>{let[m,b]=g;return Array.isArray(b)?b.includes({...i,...s}[m]):{...i,...s}[m]===b})?[...u,d,p]:u},[]);return Cp(e,a,l,n?.class,n?.className)},xM=wM("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),Mt=_.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},i)=>{const a=o?mM:"button";return h.jsx(a,{"data-slot":"button",className:O.cn(xM({variant:t,size:n,className:e})),ref:i,...r})});Mt.displayName="Button";function Te(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function $M(e,t){const n=_.createContext(t),o=i=>{const{children:a,...s}=i,l=_.useMemo(()=>s,Object.values(s));return h.jsx(n.Provider,{value:l,children:a})};o.displayName=e+"Provider";function r(i){const a=_.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[o,r]}function No(e,t=[]){let n=[];function o(i,a){const s=_.createContext(a),l=n.length;n=[...n,a];const u=d=>{const{scope:p,children:f,...g}=d,m=p?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return h.jsx(m.Provider,{value:b,children:f})};u.displayName=i+"Provider";function c(d,p){const f=p?.[e]?.[l]||s,g=_.useContext(f);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const r=()=>{const i=n.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return r.scopeName=e,[o,SM(r,...t)]}function SM(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function Wc(e){const t=IM(e),n=_.forwardRef((o,r)=>{const{children:i,...a}=o,s=_.Children.toArray(i),l=s.find(EM);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return h.jsx(t,{...a,ref:r,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return h.jsx(t,{...a,ref:r,children:i})});return n.displayName=`${e}.Slot`,n}function IM(e){const t=_.forwardRef((n,o)=>{const{children:r,...i}=n;if(_.isValidElement(r)){const a=TM(r),s=OM(i,r.props);return r.type!==_.Fragment&&(s.ref=o?Jc(o,a):a),_.cloneElement(r,s)}return _.Children.count(r)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var w$=Symbol("radix.slottable");function kM(e){const t=({children:n})=>h.jsx(h.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=w$,t}function EM(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===w$}function OM(e,t){const n={...t};for(const o in t){const r=e[o],i=t[o];/^on[A-Z]/.test(o)?r&&i?n[o]=(...s)=>{const l=i(...s);return r(...s),l}:r&&(n[o]=r):o==="style"?n[o]={...r,...i}:o==="className"&&(n[o]=[r,i].filter(Boolean).join(" "))}return{...e,...n}}function TM(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var NM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ce=NM.reduce((e,t)=>{const n=Wc(`Primitive.${t}`),o=_.forwardRef((r,i)=>{const{asChild:a,...s}=r,l=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function PM(e,t){e&&om.flushSync(()=>e.dispatchEvent(t))}function $r(e){const t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>(...n)=>t.current?.(...n),[])}function CM(e,t=globalThis?.document){const n=$r(e);_.useEffect(()=>{const o=r=>{r.key==="Escape"&&n(r)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[n,t])}var jM="DismissableLayer",Iu="dismissableLayer.update",AM="dismissableLayer.pointerDownOutside",RM="dismissableLayer.focusOutside",jp,x$=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ba=_.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:o,onPointerDownOutside:r,onFocusOutside:i,onInteractOutside:a,onDismiss:s,...l}=e,u=_.useContext(x$),[c,d]=_.useState(null),p=c?.ownerDocument??globalThis?.document,[,f]=_.useState({}),g=Ge(t,I=>d(I)),m=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=m.indexOf(b),x=c?m.indexOf(c):-1,$=u.layersWithOutsidePointerEventsDisabled.size>0,v=x>=y,k=DM(I=>{const T=I.target,z=[...u.branches].some(Z=>Z.contains(T));!v||z||(r?.(I),a?.(I),I.defaultPrevented||s?.())},p),N=UM(I=>{const T=I.target;[...u.branches].some(Z=>Z.contains(T))||(i?.(I),a?.(I),I.defaultPrevented||s?.())},p);return CM(I=>{x===u.layers.size-1&&(o?.(I),!I.defaultPrevented&&s&&(I.preventDefault(),s()))},p),_.useEffect(()=>{if(c)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(jp=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),Ap(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=jp)}},[c,p,n,u]),_.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),Ap())},[c,u]),_.useEffect(()=>{const I=()=>f({});return document.addEventListener(Iu,I),()=>document.removeEventListener(Iu,I)},[]),h.jsx(Ce.div,{...l,ref:g,style:{pointerEvents:$?v?"auto":"none":void 0,...e.style},onFocusCapture:Te(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Te(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Te(e.onPointerDownCapture,k.onPointerDownCapture)})});Ba.displayName=jM;var zM="DismissableLayerBranch",MM=_.forwardRef((e,t)=>{const n=_.useContext(x$),o=_.useRef(null),r=Ge(t,o);return _.useEffect(()=>{const i=o.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),h.jsx(Ce.div,{...e,ref:r})});MM.displayName=zM;function DM(e,t=globalThis?.document){const n=$r(e),o=_.useRef(!1),r=_.useRef(()=>{});return _.useEffect(()=>{const i=s=>{if(s.target&&!o.current){let l=function(){$$(AM,n,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",r.current),r.current=l,t.addEventListener("click",r.current,{once:!0})):l()}else t.removeEventListener("click",r.current);o.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",r.current)}},[t,n]),{onPointerDownCapture:()=>o.current=!0}}function UM(e,t=globalThis?.document){const n=$r(e),o=_.useRef(!1);return _.useEffect(()=>{const r=i=>{i.target&&!o.current&&$$(RM,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,n]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Ap(){const e=new CustomEvent(Iu);document.dispatchEvent(e)}function $$(e,t,n,{discrete:o}){const r=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&r.addEventListener(e,t,{once:!0}),o?PM(r,i):r.dispatchEvent(i)}var ct=globalThis?.document?_.useLayoutEffect:()=>{},LM=_[" useId ".trim().toString()]||(()=>{}),ZM=0;function Fr(e){const[t,n]=_.useState(LM());return ct(()=>{n(o=>o??String(ZM++))},[e]),t?`radix-${t}`:""}const FM=["top","right","bottom","left"],sr=Math.min,Ye=Math.max,zi=Math.round,Ho=Math.floor,Rt=e=>({x:e,y:e}),qM={left:"right",right:"left",bottom:"top",top:"bottom"},VM={start:"end",end:"start"};function ku(e,t,n){return Ye(e,sr(t,n))}function Jt(e,t){return typeof e=="function"?e(t):e}function Wt(e){return e.split("-")[0]}function cn(e){return e.split("-")[1]}function Hc(e){return e==="x"?"y":"x"}function Gc(e){return e==="y"?"height":"width"}const BM=new Set(["top","bottom"]);function At(e){return BM.has(Wt(e))?"y":"x"}function Kc(e){return Hc(At(e))}function JM(e,t,n){n===void 0&&(n=!1);const o=cn(e),r=Kc(e),i=Gc(r);let a=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Mi(a)),[a,Mi(a)]}function WM(e){const t=Mi(e);return[Eu(e),t,Eu(t)]}function Eu(e){return e.replace(/start|end/g,t=>VM[t])}const Rp=["left","right"],zp=["right","left"],HM=["top","bottom"],GM=["bottom","top"];function KM(e,t,n){switch(e){case"top":case"bottom":return n?t?zp:Rp:t?Rp:zp;case"left":case"right":return t?HM:GM;default:return[]}}function YM(e,t,n,o){const r=cn(e);let i=KM(Wt(e),n==="start",o);return r&&(i=i.map(a=>a+"-"+r),t&&(i=i.concat(i.map(Eu)))),i}function Mi(e){return e.replace(/left|right|bottom|top/g,t=>qM[t])}function QM(e){return{top:0,right:0,bottom:0,left:0,...e}}function S$(e){return typeof e!="number"?QM(e):{top:e,right:e,bottom:e,left:e}}function Di(e){const{x:t,y:n,width:o,height:r}=e;return{width:o,height:r,top:n,left:t,right:t+o,bottom:n+r,x:t,y:n}}function Mp(e,t,n){let{reference:o,floating:r}=e;const i=At(t),a=Kc(t),s=Gc(a),l=Wt(t),u=i==="y",c=o.x+o.width/2-r.width/2,d=o.y+o.height/2-r.height/2,p=o[s]/2-r[s]/2;let f;switch(l){case"top":f={x:c,y:o.y-r.height};break;case"bottom":f={x:c,y:o.y+o.height};break;case"right":f={x:o.x+o.width,y:d};break;case"left":f={x:o.x-r.width,y:d};break;default:f={x:o.x,y:o.y}}switch(cn(t)){case"start":f[a]-=p*(n&&u?-1:1);break;case"end":f[a]+=p*(n&&u?-1:1);break}return f}const XM=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:a}=n,s=i.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:r}),{x:c,y:d}=Mp(u,o,l),p=o,f={},g=0;for(let m=0;m<s.length;m++){const{name:b,fn:y}=s[m],{x,y:$,data:v,reset:k}=await y({x:c,y:d,initialPlacement:o,placement:p,strategy:r,middlewareData:f,rects:u,platform:a,elements:{reference:e,floating:t}});c=x??c,d=$??d,f={...f,[b]:{...f[b],...v}},k&&g<=50&&(g++,typeof k=="object"&&(k.placement&&(p=k.placement),k.rects&&(u=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:r}):k.rects),{x:c,y:d}=Mp(u,p,l)),m=-1)}return{x:c,y:d,placement:p,strategy:r,middlewareData:f}};async function Gn(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:i,rects:a,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:p=!1,padding:f=0}=Jt(t,e),g=S$(f),b=s[p?d==="floating"?"reference":"floating":d],y=Di(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),x=d==="floating"?{x:o,y:r,width:a.floating.width,height:a.floating.height}:a.reference,$=await(i.getOffsetParent==null?void 0:i.getOffsetParent(s.floating)),v=await(i.isElement==null?void 0:i.isElement($))?await(i.getScale==null?void 0:i.getScale($))||{x:1,y:1}:{x:1,y:1},k=Di(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:x,offsetParent:$,strategy:l}):x);return{top:(y.top-k.top+g.top)/v.y,bottom:(k.bottom-y.bottom+g.bottom)/v.y,left:(y.left-k.left+g.left)/v.x,right:(k.right-y.right+g.right)/v.x}}const e4=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:i,platform:a,elements:s,middlewareData:l}=t,{element:u,padding:c=0}=Jt(e,t)||{};if(u==null)return{};const d=S$(c),p={x:n,y:o},f=Kc(r),g=Gc(f),m=await a.getDimensions(u),b=f==="y",y=b?"top":"left",x=b?"bottom":"right",$=b?"clientHeight":"clientWidth",v=i.reference[g]+i.reference[f]-p[f]-i.floating[g],k=p[f]-i.reference[f],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let I=N?N[$]:0;(!I||!await(a.isElement==null?void 0:a.isElement(N)))&&(I=s.floating[$]||i.floating[g]);const T=v/2-k/2,z=I/2-m[g]/2-1,Z=sr(d[y],z),re=sr(d[x],z),ve=Z,G=I-m[g]-re,V=I/2-m[g]/2+T,we=ku(ve,V,G),oe=!l.arrow&&cn(r)!=null&&V!==we&&i.reference[g]/2-(V<ve?Z:re)-m[g]/2<0,ce=oe?V<ve?V-ve:V-G:0;return{[f]:p[f]+ce,data:{[f]:we,centerOffset:V-we-ce,...oe&&{alignmentOffset:ce}},reset:oe}}}),t4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:r,middlewareData:i,rects:a,initialPlacement:s,platform:l,elements:u}=t,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...b}=Jt(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=Wt(r),x=At(s),$=Wt(s)===s,v=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=p||($||!m?[Mi(s)]:WM(s)),N=g!=="none";!p&&N&&k.push(...YM(s,m,g,v));const I=[s,...k],T=await Gn(t,b),z=[];let Z=((o=i.flip)==null?void 0:o.overflows)||[];if(c&&z.push(T[y]),d){const V=JM(r,a,v);z.push(T[V[0]],T[V[1]])}if(Z=[...Z,{placement:r,overflows:z}],!z.every(V=>V<=0)){var re,ve;const V=(((re=i.flip)==null?void 0:re.index)||0)+1,we=I[V];if(we&&(!(d==="alignment"?x!==At(we):!1)||Z.every(K=>At(K.placement)===x?K.overflows[0]>0:!0)))return{data:{index:V,overflows:Z},reset:{placement:we}};let oe=(ve=Z.filter(ce=>ce.overflows[0]<=0).sort((ce,K)=>ce.overflows[1]-K.overflows[1])[0])==null?void 0:ve.placement;if(!oe)switch(f){case"bestFit":{var G;const ce=(G=Z.filter(K=>{if(N){const fe=At(K.placement);return fe===x||fe==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(fe=>fe>0).reduce((fe,B)=>fe+B,0)]).sort((K,fe)=>K[1]-fe[1])[0])==null?void 0:G[0];ce&&(oe=ce);break}case"initialPlacement":oe=s;break}if(r!==oe)return{reset:{placement:oe}}}return{}}}};function Dp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Up(e){return FM.some(t=>e[t]>=0)}const r4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:o="referenceHidden",...r}=Jt(e,t);switch(o){case"referenceHidden":{const i=await Gn(t,{...r,elementContext:"reference"}),a=Dp(i,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Up(a)}}}case"escaped":{const i=await Gn(t,{...r,altBoundary:!0}),a=Dp(i,n.floating);return{data:{escapedOffsets:a,escaped:Up(a)}}}default:return{}}}}},I$=new Set(["left","top"]);async function n4(e,t){const{placement:n,platform:o,elements:r}=e,i=await(o.isRTL==null?void 0:o.isRTL(r.floating)),a=Wt(n),s=cn(n),l=At(n)==="y",u=I$.has(a)?-1:1,c=i&&l?-1:1,d=Jt(t,e);let{mainAxis:p,crossAxis:f,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof g=="number"&&(f=s==="end"?g*-1:g),l?{x:f*c,y:p*u}:{x:p*u,y:f*c}}const o4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:r,y:i,placement:a,middlewareData:s}=t,l=await n4(t,e);return a===((n=s.offset)==null?void 0:n.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:r+l.x,y:i+l.y,data:{...l,placement:a}}}}},i4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:r}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:s={fn:b=>{let{x:y,y:x}=b;return{x:y,y:x}}},...l}=Jt(e,t),u={x:n,y:o},c=await Gn(t,l),d=At(Wt(r)),p=Hc(d);let f=u[p],g=u[d];if(i){const b=p==="y"?"top":"left",y=p==="y"?"bottom":"right",x=f+c[b],$=f-c[y];f=ku(x,f,$)}if(a){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",x=g+c[b],$=g-c[y];g=ku(x,g,$)}const m=s.fn({...t,[p]:f,[d]:g});return{...m,data:{x:m.x-n,y:m.y-o,enabled:{[p]:i,[d]:a}}}}}},a4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:o,placement:r,rects:i,middlewareData:a}=t,{offset:s=0,mainAxis:l=!0,crossAxis:u=!0}=Jt(e,t),c={x:n,y:o},d=At(r),p=Hc(d);let f=c[p],g=c[d];const m=Jt(s,t),b=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const $=p==="y"?"height":"width",v=i.reference[p]-i.floating[$]+b.mainAxis,k=i.reference[p]+i.reference[$]-b.mainAxis;f<v?f=v:f>k&&(f=k)}if(u){var y,x;const $=p==="y"?"width":"height",v=I$.has(Wt(r)),k=i.reference[d]-i.floating[$]+(v&&((y=a.offset)==null?void 0:y[d])||0)+(v?0:b.crossAxis),N=i.reference[d]+i.reference[$]+(v?0:((x=a.offset)==null?void 0:x[d])||0)-(v?b.crossAxis:0);g<k?g=k:g>N&&(g=N)}return{[p]:f,[d]:g}}}},s4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,o;const{placement:r,rects:i,platform:a,elements:s}=t,{apply:l=()=>{},...u}=Jt(e,t),c=await Gn(t,u),d=Wt(r),p=cn(r),f=At(r)==="y",{width:g,height:m}=i.floating;let b,y;d==="top"||d==="bottom"?(b=d,y=p===(await(a.isRTL==null?void 0:a.isRTL(s.floating))?"start":"end")?"left":"right"):(y=d,b=p==="end"?"top":"bottom");const x=m-c.top-c.bottom,$=g-c.left-c.right,v=sr(m-c[b],x),k=sr(g-c[y],$),N=!t.middlewareData.shift;let I=v,T=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=$),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(I=x),N&&!p){const Z=Ye(c.left,0),re=Ye(c.right,0),ve=Ye(c.top,0),G=Ye(c.bottom,0);f?T=g-2*(Z!==0||re!==0?Z+re:Ye(c.left,c.right)):I=m-2*(ve!==0||G!==0?ve+G:Ye(c.top,c.bottom))}await l({...t,availableWidth:T,availableHeight:I});const z=await a.getDimensions(s.floating);return g!==z.width||m!==z.height?{reset:{rects:!0}}:{}}}};function Ja(){return typeof window<"u"}function dn(e){return k$(e)?(e.nodeName||"").toLowerCase():"#document"}function Qe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Lt(e){var t;return(t=(k$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function k$(e){return Ja()?e instanceof Node||e instanceof Qe(e).Node:!1}function St(e){return Ja()?e instanceof Element||e instanceof Qe(e).Element:!1}function Dt(e){return Ja()?e instanceof HTMLElement||e instanceof Qe(e).HTMLElement:!1}function Lp(e){return!Ja()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qe(e).ShadowRoot}const u4=new Set(["inline","contents"]);function Po(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=It(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!u4.has(r)}const l4=new Set(["table","td","th"]);function c4(e){return l4.has(dn(e))}const d4=[":popover-open",":modal"];function Wa(e){return d4.some(t=>{try{return e.matches(t)}catch{return!1}})}const f4=["transform","translate","scale","rotate","perspective"],p4=["transform","translate","scale","rotate","perspective","filter"],m4=["paint","layout","strict","content"];function Yc(e){const t=Qc(),n=St(e)?It(e):e;return f4.some(o=>n[o]?n[o]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||p4.some(o=>(n.willChange||"").includes(o))||m4.some(o=>(n.contain||"").includes(o))}function h4(e){let t=ur(e);for(;Dt(t)&&!rn(t);){if(Yc(t))return t;if(Wa(t))return null;t=ur(t)}return null}function Qc(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const g4=new Set(["html","body","#document"]);function rn(e){return g4.has(dn(e))}function It(e){return Qe(e).getComputedStyle(e)}function Ha(e){return St(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ur(e){if(dn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Lp(e)&&e.host||Lt(e);return Lp(t)?t.host:t}function E$(e){const t=ur(e);return rn(t)?e.ownerDocument?e.ownerDocument.body:e.body:Dt(t)&&Po(t)?t:E$(t)}function Kn(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=E$(e),i=r===((o=e.ownerDocument)==null?void 0:o.body),a=Qe(r);if(i){const s=Ou(a);return t.concat(a,a.visualViewport||[],Po(r)?r:[],s&&n?Kn(s):[])}return t.concat(r,Kn(r,[],n))}function Ou(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function O$(e){const t=It(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=Dt(e),i=r?e.offsetWidth:n,a=r?e.offsetHeight:o,s=zi(n)!==i||zi(o)!==a;return s&&(n=i,o=a),{width:n,height:o,$:s}}function Xc(e){return St(e)?e:e.contextElement}function qr(e){const t=Xc(e);if(!Dt(t))return Rt(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:i}=O$(t);let a=(i?zi(n.width):n.width)/o,s=(i?zi(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const v4=Rt(0);function T$(e){const t=Qe(e);return!Qc()||!t.visualViewport?v4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function y4(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qe(e)?!1:t}function Sr(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),i=Xc(e);let a=Rt(1);t&&(o?St(o)&&(a=qr(o)):a=qr(e));const s=y4(i,n,o)?T$(i):Rt(0);let l=(r.left+s.x)/a.x,u=(r.top+s.y)/a.y,c=r.width/a.x,d=r.height/a.y;if(i){const p=Qe(i),f=o&&St(o)?Qe(o):o;let g=p,m=Ou(g);for(;m&&o&&f!==g;){const b=qr(m),y=m.getBoundingClientRect(),x=It(m),$=y.left+(m.clientLeft+parseFloat(x.paddingLeft))*b.x,v=y.top+(m.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,u*=b.y,c*=b.x,d*=b.y,l+=$,u+=v,g=Qe(m),m=Ou(g)}}return Di({width:c,height:d,x:l,y:u})}function ed(e,t){const n=Ha(e).scrollLeft;return t?t.left+n:Sr(Lt(e)).left+n}function N$(e,t,n){n===void 0&&(n=!1);const o=e.getBoundingClientRect(),r=o.left+t.scrollLeft-(n?0:ed(e,o)),i=o.top+t.scrollTop;return{x:r,y:i}}function b4(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const i=r==="fixed",a=Lt(o),s=t?Wa(t.floating):!1;if(o===a||s&&i)return n;let l={scrollLeft:0,scrollTop:0},u=Rt(1);const c=Rt(0),d=Dt(o);if((d||!d&&!i)&&((dn(o)!=="body"||Po(a))&&(l=Ha(o)),Dt(o))){const f=Sr(o);u=qr(o),c.x=f.x+o.clientLeft,c.y=f.y+o.clientTop}const p=a&&!d&&!i?N$(a,l,!0):Rt(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+c.x+p.x,y:n.y*u.y-l.scrollTop*u.y+c.y+p.y}}function _4(e){return Array.from(e.getClientRects())}function w4(e){const t=Lt(e),n=Ha(e),o=e.ownerDocument.body,r=Ye(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),i=Ye(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let a=-n.scrollLeft+ed(e);const s=-n.scrollTop;return It(o).direction==="rtl"&&(a+=Ye(t.clientWidth,o.clientWidth)-r),{width:r,height:i,x:a,y:s}}function x4(e,t){const n=Qe(e),o=Lt(e),r=n.visualViewport;let i=o.clientWidth,a=o.clientHeight,s=0,l=0;if(r){i=r.width,a=r.height;const u=Qc();(!u||u&&t==="fixed")&&(s=r.offsetLeft,l=r.offsetTop)}return{width:i,height:a,x:s,y:l}}const $4=new Set(["absolute","fixed"]);function S4(e,t){const n=Sr(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,i=Dt(e)?qr(e):Rt(1),a=e.clientWidth*i.x,s=e.clientHeight*i.y,l=r*i.x,u=o*i.y;return{width:a,height:s,x:l,y:u}}function Zp(e,t,n){let o;if(t==="viewport")o=x4(e,n);else if(t==="document")o=w4(Lt(e));else if(St(t))o=S4(t,n);else{const r=T$(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Di(o)}function P$(e,t){const n=ur(e);return n===t||!St(n)||rn(n)?!1:It(n).position==="fixed"||P$(n,t)}function I4(e,t){const n=t.get(e);if(n)return n;let o=Kn(e,[],!1).filter(s=>St(s)&&dn(s)!=="body"),r=null;const i=It(e).position==="fixed";let a=i?ur(e):e;for(;St(a)&&!rn(a);){const s=It(a),l=Yc(a);!l&&s.position==="fixed"&&(r=null),(i?!l&&!r:!l&&s.position==="static"&&!!r&&$4.has(r.position)||Po(a)&&!l&&P$(e,a))?o=o.filter(c=>c!==a):r=s,a=ur(a)}return t.set(e,o),o}function k4(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const a=[...n==="clippingAncestors"?Wa(t)?[]:I4(t,this._c):[].concat(n),o],s=a[0],l=a.reduce((u,c)=>{const d=Zp(t,c,r);return u.top=Ye(d.top,u.top),u.right=sr(d.right,u.right),u.bottom=sr(d.bottom,u.bottom),u.left=Ye(d.left,u.left),u},Zp(t,s,r));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function E4(e){const{width:t,height:n}=O$(e);return{width:t,height:n}}function O4(e,t,n){const o=Dt(t),r=Lt(t),i=n==="fixed",a=Sr(e,!0,i,t);let s={scrollLeft:0,scrollTop:0};const l=Rt(0);function u(){l.x=ed(r)}if(o||!o&&!i)if((dn(t)!=="body"||Po(r))&&(s=Ha(t)),o){const f=Sr(t,!0,i,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else r&&u();i&&!o&&r&&u();const c=r&&!o&&!i?N$(r,s):Rt(0),d=a.left+s.scrollLeft-l.x-c.x,p=a.top+s.scrollTop-l.y-c.y;return{x:d,y:p,width:a.width,height:a.height}}function Rs(e){return It(e).position==="static"}function Fp(e,t){if(!Dt(e)||It(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Lt(e)===n&&(n=n.ownerDocument.body),n}function C$(e,t){const n=Qe(e);if(Wa(e))return n;if(!Dt(e)){let r=ur(e);for(;r&&!rn(r);){if(St(r)&&!Rs(r))return r;r=ur(r)}return n}let o=Fp(e,t);for(;o&&c4(o)&&Rs(o);)o=Fp(o,t);return o&&rn(o)&&Rs(o)&&!Yc(o)?n:o||h4(e)||n}const T4=async function(e){const t=this.getOffsetParent||C$,n=this.getDimensions,o=await n(e.floating);return{reference:O4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function N4(e){return It(e).direction==="rtl"}const P4={convertOffsetParentRelativeRectToViewportRelativeRect:b4,getDocumentElement:Lt,getClippingRect:k4,getOffsetParent:C$,getElementRects:T4,getClientRects:_4,getDimensions:E4,getScale:qr,isElement:St,isRTL:N4};function j$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function C4(e,t){let n=null,o;const r=Lt(e);function i(){var s;clearTimeout(o),(s=n)==null||s.disconnect(),n=null}function a(s,l){s===void 0&&(s=!1),l===void 0&&(l=1),i();const u=e.getBoundingClientRect(),{left:c,top:d,width:p,height:f}=u;if(s||t(),!p||!f)return;const g=Ho(d),m=Ho(r.clientWidth-(c+p)),b=Ho(r.clientHeight-(d+f)),y=Ho(c),$={rootMargin:-g+"px "+-m+"px "+-b+"px "+-y+"px",threshold:Ye(0,sr(1,l))||1};let v=!0;function k(N){const I=N[0].intersectionRatio;if(I!==l){if(!v)return a();I?a(!1,I):o=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!j$(u,e.getBoundingClientRect())&&a(),v=!1}try{n=new IntersectionObserver(k,{...$,root:r.ownerDocument})}catch{n=new IntersectionObserver(k,$)}n.observe(e)}return a(!0),i}function j4(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,u=Xc(e),c=r||i?[...u?Kn(u):[],...Kn(t)]:[];c.forEach(y=>{r&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const d=u&&s?C4(u,n):null;let p=-1,f=null;a&&(f=new ResizeObserver(y=>{let[x]=y;x&&x.target===u&&f&&(f.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var $;($=f)==null||$.observe(t)})),n()}),u&&!l&&f.observe(u),f.observe(t));let g,m=l?Sr(e):null;l&&b();function b(){const y=Sr(e);m&&!j$(m,y)&&n(),m=y,g=requestAnimationFrame(b)}return n(),()=>{var y;c.forEach(x=>{r&&x.removeEventListener("scroll",n),i&&x.removeEventListener("resize",n)}),d?.(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(g)}}const A4=o4,R4=i4,z4=t4,M4=s4,D4=r4,qp=e4,U4=a4,L4=(e,t,n)=>{const o=new Map,r={platform:P4,...n},i={...r.platform,_c:o};return XM(e,t,{...r,platform:i})};var Z4=typeof document<"u",F4=function(){},ii=Z4?F.useLayoutEffect:F4;function Ui(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!Ui(e[o],t[o]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,r[o]))return!1;for(o=n;o--!==0;){const i=r[o];if(!(i==="_owner"&&e.$$typeof)&&!Ui(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function A$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Vp(e,t){const n=A$(e);return Math.round(t*n)/n}function zs(e){const t=_.useRef(e);return ii(()=>{t.current=e}),t}function q4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:r,elements:{reference:i,floating:a}={},transform:s=!0,whileElementsMounted:l,open:u}=e,[c,d]=_.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,f]=_.useState(o);Ui(p,o)||f(o);const[g,m]=_.useState(null),[b,y]=_.useState(null),x=_.useCallback(K=>{K!==N.current&&(N.current=K,m(K))},[]),$=_.useCallback(K=>{K!==I.current&&(I.current=K,y(K))},[]),v=i||g,k=a||b,N=_.useRef(null),I=_.useRef(null),T=_.useRef(c),z=l!=null,Z=zs(l),re=zs(r),ve=zs(u),G=_.useCallback(()=>{if(!N.current||!I.current)return;const K={placement:t,strategy:n,middleware:p};re.current&&(K.platform=re.current),L4(N.current,I.current,K).then(fe=>{const B={...fe,isPositioned:ve.current!==!1};V.current&&!Ui(T.current,B)&&(T.current=B,om.flushSync(()=>{d(B)}))})},[p,t,n,re,ve]);ii(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(K=>({...K,isPositioned:!1})))},[u]);const V=_.useRef(!1);ii(()=>(V.current=!0,()=>{V.current=!1}),[]),ii(()=>{if(v&&(N.current=v),k&&(I.current=k),v&&k){if(Z.current)return Z.current(v,k,G);G()}},[v,k,G,Z,z]);const we=_.useMemo(()=>({reference:N,floating:I,setReference:x,setFloating:$}),[x,$]),oe=_.useMemo(()=>({reference:v,floating:k}),[v,k]),ce=_.useMemo(()=>{const K={position:n,left:0,top:0};if(!oe.floating)return K;const fe=Vp(oe.floating,c.x),B=Vp(oe.floating,c.y);return s?{...K,transform:"translate("+fe+"px, "+B+"px)",...A$(oe.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:fe,top:B}},[n,s,oe.floating,c.x,c.y]);return _.useMemo(()=>({...c,update:G,refs:we,elements:oe,floatingStyles:ce}),[c,G,we,oe,ce])}const V4=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:o,padding:r}=typeof e=="function"?e(n):e;return o&&t(o)?o.current!=null?qp({element:o.current,padding:r}).fn(n):{}:o?qp({element:o,padding:r}).fn(n):{}}}},B4=(e,t)=>({...A4(e),options:[e,t]}),J4=(e,t)=>({...R4(e),options:[e,t]}),W4=(e,t)=>({...U4(e),options:[e,t]}),H4=(e,t)=>({...z4(e),options:[e,t]}),G4=(e,t)=>({...M4(e),options:[e,t]}),K4=(e,t)=>({...D4(e),options:[e,t]}),Y4=(e,t)=>({...V4(e),options:[e,t]});var Q4="Arrow",R$=_.forwardRef((e,t)=>{const{children:n,width:o=10,height:r=5,...i}=e;return h.jsx(Ce.svg,{...i,ref:t,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});R$.displayName=Q4;var X4=R$;function eD(e){const[t,n]=_.useState(void 0);return ct(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const i=r[0];let a,s;if("borderBoxSize"in i){const l=i.borderBoxSize,u=Array.isArray(l)?l[0]:l;a=u.inlineSize,s=u.blockSize}else a=e.offsetWidth,s=e.offsetHeight;n({width:a,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else n(void 0)},[e]),t}var td="Popper",[z$,Ga]=No(td),[tD,M$]=z$(td),D$=e=>{const{__scopePopper:t,children:n}=e,[o,r]=_.useState(null);return h.jsx(tD,{scope:t,anchor:o,onAnchorChange:r,children:n})};D$.displayName=td;var U$="PopperAnchor",L$=_.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:o,...r}=e,i=M$(U$,n),a=_.useRef(null),s=Ge(t,a),l=_.useRef(null);return _.useEffect(()=>{const u=l.current;l.current=o?.current||a.current,u!==l.current&&i.onAnchorChange(l.current)}),o?null:h.jsx(Ce.div,{...r,ref:s})});L$.displayName=U$;var rd="PopperContent",[rD,nD]=z$(rd),Z$=_.forwardRef((e,t)=>{const{__scopePopper:n,side:o="bottom",sideOffset:r=0,align:i="center",alignOffset:a=0,arrowPadding:s=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:d="partial",hideWhenDetached:p=!1,updatePositionStrategy:f="optimized",onPlaced:g,...m}=e,b=M$(rd,n),[y,x]=_.useState(null),$=Ge(t,xe=>x(xe)),[v,k]=_.useState(null),N=eD(v),I=N?.width??0,T=N?.height??0,z=o+(i!=="center"?"-"+i:""),Z=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},re=Array.isArray(u)?u:[u],ve=re.length>0,G={padding:Z,boundary:re.filter(iD),altBoundary:ve},{refs:V,floatingStyles:we,placement:oe,isPositioned:ce,middlewareData:K}=q4({strategy:"fixed",placement:z,whileElementsMounted:(...xe)=>j4(...xe,{animationFrame:f==="always"}),elements:{reference:b.anchor},middleware:[B4({mainAxis:r+T,alignmentAxis:a}),l&&J4({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?W4():void 0,...G}),l&&H4({...G}),G4({...G,apply:({elements:xe,rects:Ao,availableWidth:os,availableHeight:fn})=>{const{width:pt,height:Ro}=Ao.reference,je=xe.floating.style;je.setProperty("--radix-popper-available-width",`${os}px`),je.setProperty("--radix-popper-available-height",`${fn}px`),je.setProperty("--radix-popper-anchor-width",`${pt}px`),je.setProperty("--radix-popper-anchor-height",`${Ro}px`)}}),v&&Y4({element:v,padding:s}),aD({arrowWidth:I,arrowHeight:T}),p&&K4({strategy:"referenceHidden",...G})]}),[fe,B]=V$(oe),Ue=$r(g);ct(()=>{ce&&Ue?.()},[ce,Ue]);const ye=K.arrow?.x,Le=K.arrow?.y,D=K.arrow?.centerOffset!==0,[Q,pe]=_.useState();return ct(()=>{y&&pe(window.getComputedStyle(y).zIndex)},[y]),h.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...we,transform:ce?we.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[K.transformOrigin?.x,K.transformOrigin?.y].join(" "),...K.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:h.jsx(rD,{scope:n,placedSide:fe,onArrowChange:k,arrowX:ye,arrowY:Le,shouldHideArrow:D,children:h.jsx(Ce.div,{"data-side":fe,"data-align":B,...m,ref:$,style:{...m.style,animation:ce?void 0:"none"}})})})});Z$.displayName=rd;var F$="PopperArrow",oD={top:"bottom",right:"left",bottom:"top",left:"right"},q$=_.forwardRef(function(t,n){const{__scopePopper:o,...r}=t,i=nD(F$,o),a=oD[i.placedSide];return h.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:h.jsx(X4,{...r,ref:n,style:{...r.style,display:"block"}})})});q$.displayName=F$;function iD(e){return e!==null}var aD=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:o,middlewareData:r}=t,a=r.arrow?.centerOffset!==0,s=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[u,c]=V$(n),d={start:"0%",center:"50%",end:"100%"}[c],p=(r.arrow?.x??0)+s/2,f=(r.arrow?.y??0)+l/2;let g="",m="";return u==="bottom"?(g=a?d:`${p}px`,m=`${-l}px`):u==="top"?(g=a?d:`${p}px`,m=`${o.floating.height+l}px`):u==="right"?(g=`${-l}px`,m=a?d:`${f}px`):u==="left"&&(g=`${o.floating.width+l}px`,m=a?d:`${f}px`),{data:{x:g,y:m}}}});function V$(e){const[t,n="center"]=e.split("-");return[t,n]}var B$=D$,nd=L$,J$=Z$,W$=q$,sD="Portal",Ka=_.forwardRef((e,t)=>{const{container:n,...o}=e,[r,i]=_.useState(!1);ct(()=>i(!0),[]);const a=n||r&&globalThis?.document?.body;return a?nm.createPortal(h.jsx(Ce.div,{...o,ref:t}),a):null});Ka.displayName=sD;function uD(e,t){return _.useReducer((n,o)=>t[n][o]??n,e)}var Kt=e=>{const{present:t,children:n}=e,o=lD(t),r=typeof n=="function"?n({present:o.isPresent}):_.Children.only(n),i=Ge(o.ref,cD(r));return typeof n=="function"||o.isPresent?_.cloneElement(r,{ref:i}):null};Kt.displayName="Presence";function lD(e){const[t,n]=_.useState(),o=_.useRef(null),r=_.useRef(e),i=_.useRef("none"),a=e?"mounted":"unmounted",[s,l]=uD(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return _.useEffect(()=>{const u=Go(o.current);i.current=s==="mounted"?u:"none"},[s]),ct(()=>{const u=o.current,c=r.current;if(c!==e){const p=i.current,f=Go(u);e?l("MOUNT"):f==="none"||u?.display==="none"?l("UNMOUNT"):l(c&&p!==f?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,l]),ct(()=>{if(t){let u;const c=t.ownerDocument.defaultView??window,d=f=>{const m=Go(o.current).includes(CSS.escape(f.animationName));if(f.target===t&&m&&(l("ANIMATION_END"),!r.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",u=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},p=f=>{f.target===t&&(i.current=Go(o.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:_.useCallback(u=>{o.current=u?getComputedStyle(u):null,n(u)},[])}}function Go(e){return e?.animationName||"none"}function cD(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var dD=_[" useInsertionEffect ".trim().toString()]||ct;function Ya({prop:e,defaultProp:t,onChange:n=()=>{},caller:o}){const[r,i,a]=fD({defaultProp:t,onChange:n}),s=e!==void 0,l=s?e:r;{const c=_.useRef(e!==void 0);_.useEffect(()=>{const d=c.current;d!==s&&console.warn(`${o} is changing from ${d?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=s},[s,o])}const u=_.useCallback(c=>{if(s){const d=pD(c)?c(e):c;d!==e&&a.current?.(d)}else i(c)},[s,e,i,a]);return[l,u]}function fD({defaultProp:e,onChange:t}){const[n,o]=_.useState(e),r=_.useRef(n),i=_.useRef(t);return dD(()=>{i.current=t},[t]),_.useEffect(()=>{r.current!==n&&(i.current?.(n),r.current=n)},[n,r]),[n,o,i]}function pD(e){return typeof e=="function"}var mD=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),hD="VisuallyHidden",H$=_.forwardRef((e,t)=>h.jsx(Ce.span,{...e,ref:t,style:{...mD,...e.style}}));H$.displayName=hD;var gD=H$,[Qa]=No("Tooltip",[Ga]),Xa=Ga(),G$="TooltipProvider",vD=700,Tu="tooltip.open",[yD,od]=Qa(G$),K$=e=>{const{__scopeTooltip:t,delayDuration:n=vD,skipDelayDuration:o=300,disableHoverableContent:r=!1,children:i}=e,a=_.useRef(!0),s=_.useRef(!1),l=_.useRef(0);return _.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),h.jsx(yD,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:_.useCallback(()=>{window.clearTimeout(l.current),a.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.current=!0,o)},[o]),isPointerInTransitRef:s,onPointerInTransitChange:_.useCallback(u=>{s.current=u},[]),disableHoverableContent:r,children:i})};K$.displayName=G$;var Yn="Tooltip",[bD,Co]=Qa(Yn),Y$=e=>{const{__scopeTooltip:t,children:n,open:o,defaultOpen:r,onOpenChange:i,disableHoverableContent:a,delayDuration:s}=e,l=od(Yn,e.__scopeTooltip),u=Xa(t),[c,d]=_.useState(null),p=Fr(),f=_.useRef(0),g=a??l.disableHoverableContent,m=s??l.delayDuration,b=_.useRef(!1),[y,x]=Ya({prop:o,defaultProp:r??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(Tu))):l.onClose(),i?.(I)},caller:Yn}),$=_.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),v=_.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b.current=!1,x(!0)},[x]),k=_.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x(!1)},[x]),N=_.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{b.current=!0,x(!0),f.current=0},m)},[m,x]);return _.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),h.jsx(B$,{...u,children:h.jsx(bD,{scope:t,contentId:p,open:y,stateAttribute:$,trigger:c,onTriggerChange:d,onTriggerEnter:_.useCallback(()=>{l.isOpenDelayedRef.current?N():v()},[l.isOpenDelayedRef,N,v]),onTriggerLeave:_.useCallback(()=>{g?k():(window.clearTimeout(f.current),f.current=0)},[k,g]),onOpen:v,onClose:k,disableHoverableContent:g,children:n})})};Y$.displayName=Yn;var Nu="TooltipTrigger",Q$=_.forwardRef((e,t)=>{const{__scopeTooltip:n,...o}=e,r=Co(Nu,n),i=od(Nu,n),a=Xa(n),s=_.useRef(null),l=Ge(t,s,r.onTriggerChange),u=_.useRef(!1),c=_.useRef(!1),d=_.useCallback(()=>u.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),h.jsx(nd,{asChild:!0,...a,children:h.jsx(Ce.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...o,ref:l,onPointerMove:Te(e.onPointerMove,p=>{p.pointerType!=="touch"&&!c.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),c.current=!0)}),onPointerLeave:Te(e.onPointerLeave,()=>{r.onTriggerLeave(),c.current=!1}),onPointerDown:Te(e.onPointerDown,()=>{r.open&&r.onClose(),u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Te(e.onFocus,()=>{u.current||r.onOpen()}),onBlur:Te(e.onBlur,r.onClose),onClick:Te(e.onClick,r.onClose)})})});Q$.displayName=Nu;var id="TooltipPortal",[_D,wD]=Qa(id,{forceMount:void 0}),X$=e=>{const{__scopeTooltip:t,forceMount:n,children:o,container:r}=e,i=Co(id,t);return h.jsx(_D,{scope:t,forceMount:n,children:h.jsx(Kt,{present:n||i.open,children:h.jsx(Ka,{asChild:!0,container:r,children:o})})})};X$.displayName=id;var nn="TooltipContent",eS=_.forwardRef((e,t)=>{const n=wD(nn,e.__scopeTooltip),{forceMount:o=n.forceMount,side:r="top",...i}=e,a=Co(nn,e.__scopeTooltip);return h.jsx(Kt,{present:o||a.open,children:a.disableHoverableContent?h.jsx(tS,{side:r,...i,ref:t}):h.jsx(xD,{side:r,...i,ref:t})})}),xD=_.forwardRef((e,t)=>{const n=Co(nn,e.__scopeTooltip),o=od(nn,e.__scopeTooltip),r=_.useRef(null),i=Ge(t,r),[a,s]=_.useState(null),{trigger:l,onClose:u}=n,c=r.current,{onPointerInTransitChange:d}=o,p=_.useCallback(()=>{s(null),d(!1)},[d]),f=_.useCallback((g,m)=>{const b=g.currentTarget,y={x:g.clientX,y:g.clientY},x=kD(y,b.getBoundingClientRect()),$=ED(y,x),v=OD(m.getBoundingClientRect()),k=ND([...$,...v]);s(k),d(!0)},[d]);return _.useEffect(()=>()=>p(),[p]),_.useEffect(()=>{if(l&&c){const g=b=>f(b,c),m=b=>f(b,l);return l.addEventListener("pointerleave",g),c.addEventListener("pointerleave",m),()=>{l.removeEventListener("pointerleave",g),c.removeEventListener("pointerleave",m)}}},[l,c,f,p]),_.useEffect(()=>{if(a){const g=m=>{const b=m.target,y={x:m.clientX,y:m.clientY},x=l?.contains(b)||c?.contains(b),$=!TD(y,a);x?p():$&&(p(),u())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[l,c,a,u,p]),h.jsx(tS,{...e,ref:i})}),[$D,SD]=Qa(Yn,{isInside:!1}),ID=kM("TooltipContent"),tS=_.forwardRef((e,t)=>{const{__scopeTooltip:n,children:o,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:a,...s}=e,l=Co(nn,n),u=Xa(n),{onClose:c}=l;return _.useEffect(()=>(document.addEventListener(Tu,c),()=>document.removeEventListener(Tu,c)),[c]),_.useEffect(()=>{if(l.trigger){const d=p=>{p.target?.contains(l.trigger)&&c()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,c]),h.jsx(Ba,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:d=>d.preventDefault(),onDismiss:c,children:h.jsxs(J$,{"data-state":l.stateAttribute,...u,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(ID,{children:o}),h.jsx($D,{scope:n,isInside:!0,children:h.jsx(gD,{id:l.contentId,role:"tooltip",children:r||o})})]})})});eS.displayName=nn;var rS="TooltipArrow",nS=_.forwardRef((e,t)=>{const{__scopeTooltip:n,...o}=e,r=Xa(n);return SD(rS,n).isInside?null:h.jsx(W$,{...r,...o,ref:t})});nS.displayName=rS;function kD(e,t){const n=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,o,r,i)){case i:return"left";case r:return"right";case n:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function ED(e,t,n=5){const o=[];switch(t){case"top":o.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":o.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":o.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":o.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return o}function OD(e){const{top:t,right:n,bottom:o,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:o},{x:r,y:o}]}function TD(e,t){const{x:n,y:o}=e;let r=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i],l=t[a],u=s.x,c=s.y,d=l.x,p=l.y;c>o!=p>o&&n<(d-u)*(o-c)/(p-c)+u&&(r=!r)}return r}function ND(e){const t=e.slice();return t.sort((n,o)=>n.x<o.x?-1:n.x>o.x?1:n.y<o.y?-1:n.y>o.y?1:0),PD(t)}function PD(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const r=e[o];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(r.y-a.y)>=(i.y-a.y)*(r.x-a.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let o=e.length-1;o>=0;o--){const r=e[o];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(r.y-a.y)>=(i.y-a.y)*(r.x-a.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var CD=K$,jD=Y$,AD=Q$,RD=X$,zD=eS,MD=nS;function oS({delayDuration:e=0,...t}){return h.jsx(CD,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ad({...e}){return h.jsx(oS,{children:h.jsx(jD,{"data-slot":"tooltip",...e})})}function sd({...e}){return h.jsx(AD,{"data-slot":"tooltip-trigger",...e})}function ud({className:e,sideOffset:t=0,children:n,...o}){return h.jsx(RD,{children:h.jsxs(zD,{"data-slot":"tooltip-content",sideOffset:t,className:O.cn("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...o,children:[n,h.jsx(MD,{className:"bg-foreground fill-foreground z-20 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]"})]})})}const dt=F.forwardRef(({children:e,tooltip:t,side:n="bottom",align:o="center",className:r,...i},a)=>h.jsxs(ad,{children:[h.jsx(sd,{asChild:!0,children:h.jsxs(Mt,{variant:"ghost",size:"icon",...i,className:O.cn("aui-button-icon size-6 p-1",r),ref:a,children:[h.jsx(vM,{children:e}),h.jsx("span",{className:"aui-sr-only sr-only",children:t})]})}),h.jsx(ud,{side:n,align:o,children:t})]}));dt.displayName="TooltipIconButton";function DD(e){return F.useMemo(()=>e.reduce((t,n)=>(t?.[n.language]&&!n.overrideExisting||(t={...t,[n.language]:{CodeHeader:n.Header??(()=>null),SyntaxHighlighter:n.Component??void 0}}),t),{}),[e])}const UD=()=>{const{plugins:e}=O.useElements(),t=DD(e);return h.jsx(Vs.MarkdownTextPrimitive,{remarkPlugins:[p0],className:"aui-md",components:FD,componentsByLanguage:t})},iS=F.memo(UD),LD=({language:e,code:t})=>{const o=U.useAssistantState(({message:s})=>s).status?.type==="complete",{isCopied:r,copyToClipboard:i}=ZD(),a=()=>{!t||r||i(t)};return o?h.jsxs("div",{className:"aui-code-header-root bg-muted-foreground/15 text-foreground dark:bg-muted-foreground/20 mt-4 flex items-center justify-between gap-4 rounded-t-lg px-4 py-2 text-sm font-semibold",children:[h.jsx("span",{className:"aui-code-header-language lowercase [&>span]:text-xs",children:e}),h.jsxs(dt,{tooltip:"Copy",onClick:a,children:[!r&&h.jsx(sm,{}),r&&h.jsx(Qn,{})]})]}):null},ZD=({copiedDuration:e=3e3}={})=>{const[t,n]=F.useState(!1);return{isCopied:t,copyToClipboard:r=>{r&&navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),e)})}}},FD=Vs.unstable_memoizeMarkdownComponents({h1:({className:e,...t})=>h.jsx("h1",{className:O.cn("aui-md-h1 mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0",e),...t}),h2:({className:e,...t})=>h.jsx("h2",{className:O.cn("aui-md-h2 mt-8 mb-4 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h3:({className:e,...t})=>h.jsx("h3",{className:O.cn("aui-md-h3 mt-6 mb-4 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h4:({className:e,...t})=>h.jsx("h4",{className:O.cn("aui-md-h4 mt-6 mb-4 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h5:({className:e,...t})=>h.jsx("h5",{className:O.cn("aui-md-h5 my-4 text-lg font-semibold first:mt-0 last:mb-0",e),...t}),h6:({className:e,...t})=>h.jsx("h6",{className:O.cn("aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0",e),...t}),p:({className:e,...t})=>h.jsx("p",{className:O.cn("aui-md-p mt-5 mb-5 leading-7 first:mt-0 last:mb-0",e),...t}),a:({className:e,...t})=>h.jsx("a",{className:O.cn("aui-md-a text-primary font-medium underline underline-offset-4",e),...t}),blockquote:({className:e,...t})=>h.jsx("blockquote",{className:O.cn("aui-md-blockquote border-l-2 pl-6 italic",e),...t}),ul:({className:e,...t})=>h.jsx("ul",{className:O.cn("aui-md-ul my-5 ml-6 list-disc [&>li]:mt-2",e),...t}),ol:({className:e,...t})=>h.jsx("ol",{className:O.cn("aui-md-ol my-5 ml-6 list-decimal [&>li]:mt-2",e),...t}),hr:({className:e,...t})=>h.jsx("hr",{className:O.cn("aui-md-hr my-5 border-b",e),...t}),table:({className:e,...t})=>h.jsx("table",{className:O.cn("aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto",e),...t}),th:({className:e,...t})=>h.jsx("th",{className:O.cn("aui-md-th bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [[align=center]]:text-center [[align=right]]:text-right",e),...t}),td:({className:e,...t})=>h.jsx("td",{className:O.cn("aui-md-td border-b border-l px-4 py-2 text-left last:border-r [[align=center]]:text-center [[align=right]]:text-right",e),...t}),tr:({className:e,...t})=>h.jsx("tr",{className:O.cn("aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",e),...t}),sup:({className:e,...t})=>h.jsx("sup",{className:O.cn("aui-md-sup [&>a]:text-xs [&>a]:no-underline",e),...t}),pre:({className:e,...t})=>h.jsx("pre",{className:O.cn("aui-md-pre text-foreground bg-muted overflow-x-auto rounded-t-none! rounded-b-lg border border-t-0 p-4",e),...t}),code:function({className:t,...n}){const o=Vs.useIsMarkdownCodeBlock();return h.jsx("code",{className:O.cn(!o&&"aui-md-inline-code bg-muted rounded border font-semibold",t),...n})},CodeHeader:LD}),qD=W([E({type:C("text"),text:w()}),E({type:C("image"),data:w()})]).and(E({_meta:E({"getgram.ai/mime-type":w()}).optional()})),VD=E({content:R(qD)}).or(Ll());function aS(e){return e.replace(/[-_]/g," ").split(/(?=[A-Z])/).join(" ").split(/\s+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const BD=({toolName:e,status:t,result:n,args:o})=>{const i=U.useAssistantState(({message:p})=>p).parts.filter(p=>p.type==="tool-call"),a=i.findIndex(p=>p.toolName===e),s=F.useMemo(()=>t.type==="complete"?h.jsx(Qn,{className:"size-4 text-emerald-500"}):t.type==="incomplete"?h.jsx(O.CircleAlert,{className:"size-4 text-rose-500"}):h.jsx(Au,{className:"text-muted-foreground size-4 animate-spin"}),[t]),l=O.useDensity(),[u,c]=F.useState(!1),d=p=>{p.stopPropagation(),c(!u)};return h.jsxs("div",{className:O.cn("aui-tool-fallback-root flex w-full flex-col",a!==-1&&"border-b",a===i.length-1&&"border-b-0"),children:[h.jsxs("button",{className:O.cn("aui-tool-fallback-header flex h-full w-full cursor-pointer items-center",l("py-xs"),l("px-md"),l("gap-md")),onClick:d,children:[h.jsx("div",{children:s}),h.jsx("div",{className:"select-none",children:aS(e)}),h.jsx("div",{className:"ml-auto",children:h.jsx(Mt,{variant:"ghost",size:"icon",className:"cursor-pointer hover:bg-transparent",onClick:d,children:u?h.jsx(am,{className:"size-4"}):h.jsx(ju,{className:"size-4"})})})]}),h.jsx("div",{className:"bg-muted flex overflow-hidden transition-all duration-300 ease-out",style:{maxHeight:u?"1000px":"0"},children:u&&h.jsx(JD,{result:n,args:o})})]})};function JD({result:e,args:t}){const[n,o]=F.useState("result"),r=(i,a)=>{i.stopPropagation(),o(a)};return h.jsxs("div",{className:"flex w-full flex-col border-t",children:[h.jsx(WD,{tabs:[{id:"result",label:"Output"},{id:"args",label:"Arguments"}],activeTab:n,onTabClick:r}),h.jsxs("div",{className:"bg-background relative flex w-full flex-col items-start gap-4 border-t",children:[h.jsx("div",{className:O.cn("w-full transition-opacity",n==="args"?"opacity-100":"pointer-events-none absolute opacity-0"),children:h.jsx(sS,{text:JSON.stringify(t,null,2),language:"json"})}),h.jsx("div",{className:O.cn("w-full transition-opacity",n==="result"?"opacity-100":"pointer-events-none absolute opacity-0"),children:h.jsx(HD,{result:e})})]})]})}function WD({tabs:e,activeTab:t,onTabClick:n}){return h.jsx("div",{className:"bg-muted flex h-full items-center px-3 py-2",children:e.map(o=>h.jsx("button",{onClick:r=>n(r,o.id),className:O.cn("cursor-pointer rounded-md px-3 py-1 text-sm font-medium transition-all",t===o.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:o.label},o.id))})}function HD({result:e,className:t}){const n=VD.parse(e);return h.jsx("div",{className:O.cn("w-full",t),children:n?.content.map((o,r)=>{switch(o.type){case"text":{const i=GD(o._meta?.["getgram.ai/mime-type"]??"text/plain"),a=KD(o.text,i);return h.jsx(sS,{text:a,language:i},o.text)}case"image":{const i=`data:image/png;base64,${o.data}`;return h.jsx("div",{className:"flex items-center justify-center rounded-lg p-5",style:{backgroundImage:`linear-gradient(45deg, #ccc 25%, transparent 25%),
|
|
97
|
-
|
|
98
|
-
linear-gradient(45deg, transparent 75%, #ccc 75%),
|
|
99
|
-
linear-gradient(135deg, transparent 75%, #ccc 75%)`,backgroundSize:"25px 25px",backgroundPosition:"0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px"},children:h.jsx("img",{src:i,className:"max-h-[300px] max-w-full object-contain"})},r)}default:return h.jsx("pre",{className:"aui-tool-fallback-result-content whitespace-pre-wrap",children:JSON.stringify(o,null,2)},r)}})})}function GD(e){let t;switch(e){case"text/markdown":t="markdown";break;case"text/html":t="html";break;case"text/css":t="css";break;case"application/json":t="json";break;case"text/javascript":t="javascript";break;case"text/typescript":t="typescript";break;case"text/python":t="python";break;default:return}return t}function sS({text:e,language:t,className:n}){const[o,r]=F.useState(null);return F.useEffect(()=>{t&&m0.codeToHtml(e,{lang:t,theme:"github-dark-default",rootStyle:"background-color: transparent;",transformers:[{pre(i){i.properties.class="w-full py-3 px-5 max-h-[300px] overflow-y-auto whitespace-pre-wrap text-left"}}]}).then(r)},[e]),o?h.jsx("div",{className:O.cn("aui-tool-fallback-result-content w-full bg-slate-800/90",n),dangerouslySetInnerHTML:{__html:o}}):h.jsx("pre",{className:O.cn("aui-tool-fallback-result-content text-background flex w-full items-start bg-slate-800/90 px-5 py-3 whitespace-normal",n),children:e})}function KD(e,t){if(!t)return e;switch(t){case"json":return JSON.stringify(JSON.parse(e),null,2);default:return e}}var es="Collapsible",[YD]=No(es),[QD,ld]=YD(es),uS=_.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:o,defaultOpen:r,disabled:i,onOpenChange:a,...s}=e,[l,u]=Ya({prop:o,defaultProp:r??!1,onChange:a,caller:es});return h.jsx(QD,{scope:n,disabled:i,contentId:Fr(),open:l,onOpenToggle:_.useCallback(()=>u(c=>!c),[u]),children:h.jsx(Ce.div,{"data-state":dd(l),"data-disabled":i?"":void 0,...s,ref:t})})});uS.displayName=es;var lS="CollapsibleTrigger",cS=_.forwardRef((e,t)=>{const{__scopeCollapsible:n,...o}=e,r=ld(lS,n);return h.jsx(Ce.button,{type:"button","aria-controls":r.contentId,"aria-expanded":r.open||!1,"data-state":dd(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...o,ref:t,onClick:Te(e.onClick,r.onOpenToggle)})});cS.displayName=lS;var cd="CollapsibleContent",dS=_.forwardRef((e,t)=>{const{forceMount:n,...o}=e,r=ld(cd,e.__scopeCollapsible);return h.jsx(Kt,{present:n||r.open,children:({present:i})=>h.jsx(XD,{...o,ref:t,present:i})})});dS.displayName=cd;var XD=_.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:o,children:r,...i}=e,a=ld(cd,n),[s,l]=_.useState(o),u=_.useRef(null),c=Ge(t,u),d=_.useRef(0),p=d.current,f=_.useRef(0),g=f.current,m=a.open||s,b=_.useRef(m),y=_.useRef(void 0);return _.useEffect(()=>{const x=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(x)},[]),ct(()=>{const x=u.current;if(x){y.current=y.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const $=x.getBoundingClientRect();d.current=$.height,f.current=$.width,b.current||(x.style.transitionDuration=y.current.transitionDuration,x.style.animationName=y.current.animationName),l(o)}},[a.open,o]),h.jsx(Ce.div,{"data-state":dd(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!m,...i,ref:c,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:m&&r})});function dd(e){return e?"open":"closed"}var eU=uS;function tU({...e}){return h.jsx(eU,{"data-slot":"collapsible",...e})}function rU({...e}){return h.jsx(cS,{"data-slot":"collapsible-trigger",...e})}function nU({...e}){return h.jsx(dS,{"data-slot":"collapsible-content",...e})}const Bp=200,fS=({className:e,children:t})=>{const n=F.useRef(null),[o,r]=F.useState(!1),i=U.useScrollLock(n,Bp),a=F.useCallback(s=>{s||i(),r(s)},[i]);return h.jsx(tU,{ref:n,open:o,onOpenChange:a,className:O.cn("aui-reasoning-root mb-4 w-full",e),style:{"--animation-duration":`${Bp}ms`},children:t})};fS.displayName="ReasoningRoot";const oU=({className:e})=>h.jsx("div",{className:O.cn("aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-16","bg-[linear-gradient(to_top,var(--color-background),transparent)]","fade-in-0 animate-in","group-data-[state=open]/collapsible-content:animate-out","group-data-[state=open]/collapsible-content:fade-out-0","group-data-[state=open]/collapsible-content:delay-[calc(var(--animation-duration)*0.75)]","group-data-[state=open]/collapsible-content:fill-mode-forwards","duration-(--animation-duration)","group-data-[state=open]/collapsible-content:duration-(--animation-duration)",e)}),iU=({active:e,className:t})=>h.jsxs(rU,{className:O.cn("aui-reasoning-trigger group/trigger text-muted-foreground hover:text-foreground -mb-2 flex max-w-[75%] items-center gap-2 py-2 text-sm transition-colors",t,e&&"shimmer"),children:[h.jsx(x0,{className:"aui-reasoning-trigger-icon size-4 shrink-0"}),h.jsxs("span",{className:"aui-reasoning-trigger-label-wrapper relative inline-block leading-none",children:[h.jsx("span",{children:"Reasoning"}),e?h.jsx("span",{"aria-hidden":!0,className:"aui-reasoning-trigger-shimmer shimmer pointer-events-none absolute inset-0 motion-reduce:animate-none",children:"Reasoning"}):null]}),h.jsx(ju,{className:O.cn("aui-reasoning-trigger-chevron mt-0.5 size-4 shrink-0","transition-transform duration-(--animation-duration) ease-out","group-data-[state=closed]/trigger:-rotate-90","group-data-[state=open]/trigger:rotate-0")})]}),pS=({className:e,children:t,"aria-busy":n})=>h.jsxs(nU,{className:O.cn("aui-reasoning-content text-muted-foreground relative overflow-hidden text-sm outline-none","group/collapsible-content ease-out","data-[state=closed]:animate-collapsible-up","data-[state=open]:animate-collapsible-down","data-[state=closed]:fill-mode-forwards","data-[state=closed]:pointer-events-none","data-[state=open]:duration-(--animation-duration)","data-[state=closed]:duration-(--animation-duration)",e),"aria-busy":n,children:[t,h.jsx(oU,{})]});pS.displayName="ReasoningContent";const mS=({className:e,children:t})=>h.jsx("div",{className:O.cn("aui-reasoning-text relative z-0 space-y-4 pt-4 pl-6 leading-relaxed","transform-gpu transition-[transform,opacity]","group-data-[state=open]/collapsible-content:animate-in","group-data-[state=closed]/collapsible-content:animate-out","group-data-[state=open]/collapsible-content:fade-in-0","group-data-[state=closed]/collapsible-content:fade-out-0","group-data-[state=open]/collapsible-content:slide-in-from-top-4","group-data-[state=closed]/collapsible-content:slide-out-to-top-4","group-data-[state=open]/collapsible-content:duration-(--animation-duration)","group-data-[state=closed]/collapsible-content:duration-(--animation-duration)","[&_p]:-mb-2",e),children:t});mS.displayName="ReasoningText";const aU=()=>h.jsx(iS,{}),sU=({children:e,startIndex:t,endIndex:n})=>{const o=U.useAssistantState(({message:r})=>{if(r.status?.type!=="running")return!1;const i=r.parts.length-1;return i<0||r.parts[i]?.type!=="reasoning"?!1:i>=t&&i<=n});return h.jsxs(fS,{children:[h.jsx(iU,{active:o}),h.jsx(pS,{"aria-busy":o,children:h.jsx(mS,{children:e})})]})},hS=F.memo(aU);hS.displayName="Reasoning";const gS=F.memo(sU);gS.displayName="ReasoningGroup";var Ms="focusScope.autoFocusOnMount",Ds="focusScope.autoFocusOnUnmount",Jp={bubbles:!1,cancelable:!0},uU="FocusScope",fd=_.forwardRef((e,t)=>{const{loop:n=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:i,...a}=e,[s,l]=_.useState(null),u=$r(r),c=$r(i),d=_.useRef(null),p=Ge(t,m=>l(m)),f=_.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_.useEffect(()=>{if(o){let m=function($){if(f.paused||!s)return;const v=$.target;s.contains(v)?d.current=v:Xt(d.current,{select:!0})},b=function($){if(f.paused||!s)return;const v=$.relatedTarget;v!==null&&(s.contains(v)||Xt(d.current,{select:!0}))},y=function($){if(document.activeElement===document.body)for(const k of $)k.removedNodes.length>0&&Xt(s)};document.addEventListener("focusin",m),document.addEventListener("focusout",b);const x=new MutationObserver(y);return s&&x.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",b),x.disconnect()}}},[o,s,f.paused]),_.useEffect(()=>{if(s){Hp.add(f);const m=document.activeElement;if(!s.contains(m)){const y=new CustomEvent(Ms,Jp);s.addEventListener(Ms,u),s.dispatchEvent(y),y.defaultPrevented||(lU(mU(vS(s)),{select:!0}),document.activeElement===m&&Xt(s))}return()=>{s.removeEventListener(Ms,u),setTimeout(()=>{const y=new CustomEvent(Ds,Jp);s.addEventListener(Ds,c),s.dispatchEvent(y),y.defaultPrevented||Xt(m??document.body,{select:!0}),s.removeEventListener(Ds,c),Hp.remove(f)},0)}}},[s,u,c,f]);const g=_.useCallback(m=>{if(!n&&!o||f.paused)return;const b=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,y=document.activeElement;if(b&&y){const x=m.currentTarget,[$,v]=cU(x);$&&v?!m.shiftKey&&y===v?(m.preventDefault(),n&&Xt($,{select:!0})):m.shiftKey&&y===$&&(m.preventDefault(),n&&Xt(v,{select:!0})):y===x&&m.preventDefault()}},[n,o,f.paused]);return h.jsx(Ce.div,{tabIndex:-1,...a,ref:p,onKeyDown:g})});fd.displayName=uU;function lU(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(Xt(o,{select:t}),document.activeElement!==n)return}function cU(e){const t=vS(e),n=Wp(t,e),o=Wp(t.reverse(),e);return[n,o]}function vS(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Wp(e,t){for(const n of e)if(!dU(n,{upTo:t}))return n}function dU(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function fU(e){return e instanceof HTMLInputElement&&"select"in e}function Xt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&fU(e)&&t&&e.select()}}var Hp=pU();function pU(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Gp(e,t),e.unshift(t)},remove(t){e=Gp(e,t),e[0]?.resume()}}}function Gp(e,t){const n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function mU(e){return e.filter(t=>t.tagName!=="A")}var Us=0;function yS(){_.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Kp()),document.body.insertAdjacentElement("beforeend",e[1]??Kp()),Us++,()=>{Us===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Us--}},[])}function Kp(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Ct=function(){return Ct=Object.assign||function(t){for(var n,o=1,r=arguments.length;o<r;o++){n=arguments[o];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Ct.apply(this,arguments)};function bS(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);return n}function hU(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,i;o<r;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}var ai="right-scroll-bar-position",si="width-before-scroll-bar",gU="with-scroll-bars-hidden",vU="--removed-body-scroll-bar-size";function Ls(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function yU(e,t){var n=F.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(o){var r=n.value;r!==o&&(n.value=o,n.callback(o,r))}}}})[0];return n.callback=t,n.facade}var bU=typeof window<"u"?_.useLayoutEffect:_.useEffect,Yp=new WeakMap;function _U(e,t){var n=yU(null,function(o){return e.forEach(function(r){return Ls(r,o)})});return bU(function(){var o=Yp.get(n);if(o){var r=new Set(o),i=new Set(e),a=n.current;r.forEach(function(s){i.has(s)||Ls(s,null)}),i.forEach(function(s){r.has(s)||Ls(s,a)})}Yp.set(n,e)},[e]),n}function wU(e){return e}function xU(e,t){t===void 0&&(t=wU);var n=[],o=!1,r={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var a=t(i,o);return n.push(a),function(){n=n.filter(function(s){return s!==a})}},assignSyncMedium:function(i){for(o=!0;n.length;){var a=n;n=[],a.forEach(i)}n={push:function(s){return i(s)},filter:function(){return n}}},assignMedium:function(i){o=!0;var a=[];if(n.length){var s=n;n=[],s.forEach(i),a=n}var l=function(){var c=a;a=[],c.forEach(i)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(c){a.push(c),u()},filter:function(c){return a=a.filter(c),n}}}};return r}function $U(e){e===void 0&&(e={});var t=xU(null);return t.options=Ct({async:!0,ssr:!1},e),t}var _S=function(e){var t=e.sideCar,n=bS(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return _.createElement(o,Ct({},n))};_S.isSideCarExport=!0;function SU(e,t){return e.useMedium(t),_S}var wS=$U(),Zs=function(){},ts=_.forwardRef(function(e,t){var n=_.useRef(null),o=_.useState({onScrollCapture:Zs,onWheelCapture:Zs,onTouchMoveCapture:Zs}),r=o[0],i=o[1],a=e.forwardProps,s=e.children,l=e.className,u=e.removeScrollBar,c=e.enabled,d=e.shards,p=e.sideCar,f=e.noRelative,g=e.noIsolation,m=e.inert,b=e.allowPinchZoom,y=e.as,x=y===void 0?"div":y,$=e.gapMode,v=bS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=p,N=_U([n,t]),I=Ct(Ct({},v),r);return _.createElement(_.Fragment,null,c&&_.createElement(k,{sideCar:wS,removeScrollBar:u,shards:d,noRelative:f,noIsolation:g,inert:m,setCallbacks:i,allowPinchZoom:!!b,lockRef:n,gapMode:$}),a?_.cloneElement(_.Children.only(s),Ct(Ct({},I),{ref:N})):_.createElement(x,Ct({},I,{className:l,ref:N}),s))});ts.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ts.classNames={fullWidth:si,zeroRight:ai};var IU=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function kU(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=IU();return t&&e.setAttribute("nonce",t),e}function EU(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function OU(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var TU=function(){var e=0,t=null;return{add:function(n){e==0&&(t=kU())&&(EU(t,n),OU(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},NU=function(){var e=TU();return function(t,n){_.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},xS=function(){var e=NU(),t=function(n){var o=n.styles,r=n.dynamic;return e(o,r),null};return t},PU={left:0,top:0,right:0,gap:0},Fs=function(e){return parseInt(e||"",10)||0},CU=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],r=t[e==="padding"?"paddingRight":"marginRight"];return[Fs(n),Fs(o),Fs(r)]},jU=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return PU;var t=CU(e),n=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-n+t[2]-t[0])}},AU=xS(),Vr="data-scroll-locked",RU=function(e,t,n,o){var r=e.left,i=e.top,a=e.right,s=e.gap;return n===void 0&&(n="margin"),`
|
|
100
|
-
.`.concat(gU,` {
|
|
96
|
+
`)}`}async function vM(e){return(await(await fetch("/chat/session",{method:"POST",headers:{"Gram-Project":e.projectSlug}})).json()).client_token}const yM=({children:e,config:t,getSession:n=vM})=>{const o=r$({getSession:n,projectSlug:t.projectSlug}),r=_$(),[i,a]=D.useState(t.model?.defaultModel??Mu[0]),[s,l]=D.useState(t.modal?.defaultExpanded??!1),[u,c]=D.useState(t.modal?.defaultOpen),d=t.plugins??T.recommended,f=gM(t.systemPrompt,d),{data:p,isLoading:g}=pM({getSession:n,projectSlug:t.projectSlug,mcp:t.mcp,environment:t.environment??{}}),h=D.useRef({requestApproval:r.requestApproval,isToolApproved:r.isToolApproved,whitelistTool:r.whitelistTool});h.current={requestApproval:r.requestApproval,isToolApproved:r.isToolApproved,whitelistTool:r.whitelistTool};const b=D.useCallback(()=>({requestApproval:(...v)=>h.current.requestApproval(...v),isToolApproved:(...v)=>h.current.isToolApproved(...v),whitelistTool:(...v)=>h.current.whitelistTool(...v)}),[]);D.useEffect(()=>(t.tools?.toolsRequiringApproval?.length&&dR(b(),t.tools.toolsRequiringApproval),()=>{pR()}),[t.tools?.toolsRequiringApproval,b]);let y="https://localhost:8080";y=y.replace(/\/+$/,"");const x=D.useMemo(()=>({sendMessages:async({messages:v,abortSignal:k})=>{const N=!!t.languageModel;if(!o)throw new Error("No session found");if(g||!p)throw new Error("MCP tools are still being discovered");const I=$.thread.getModelContext(),O=lR(cR(I?.tools??{})),z=N?null:Pw({baseURL:y,apiKey:"unused, but must be set",headers:{"Gram-Project":t.projectSlug,"Gram-Chat-Session":o}});t.languageModel&&console.log("Using custom language model",t.languageModel);const F={...p,...IP(O)},te=mR(F,t.tools?.toolsRequiringApproval,b()),ce=t.languageModel?t.languageModel:z.chat(i);try{return eR({system:f,model:ce,messages:nR(v),tools:te,stopWhen:Lx(10),experimental_transform:uR({delayInMs:15}),abortSignal:k,onError:({error:q})=>{console.error("Stream error in onError callback:",q)}}).toUIMessageStream()}catch(B){throw console.error("Error creating stream:",B),B}},reconnectToStream:async()=>{throw new Error("Stream reconnection not supported")}}),[t,t.languageModel,i,f,o,p,g,b,y]),$=SP({transport:x});return m.jsx(L.AssistantRuntimeProvider,{runtime:$,children:m.jsxs(T.ElementsContext.Provider,{value:{config:t,setModel:a,model:i,isExpanded:s,setIsExpanded:l,isOpen:u??!1,setIsOpen:c,plugins:d},children:[e,m.jsx($0,{tools:t.tools?.frontendTools??{}})]})})},bM=e=>{const t=new DR;return m.jsx(UR,{client:t,children:m.jsx(mM,{children:m.jsx(yM,{...e})})})};function Cf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Hc(...e){return t=>{let n=!1;const o=e.map(r=>{const i=Cf(r,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let r=0;r<o.length;r++){const i=o[r];typeof i=="function"?i():Cf(e[r],null)}}}}function Ge(...e){return _.useCallback(Hc(...e),e)}var _M=Symbol.for("react.lazy"),Di=_[" use ".trim().toString()];function wM(e){return typeof e=="object"&&e!==null&&"then"in e}function w$(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===_M&&"_payload"in e&&wM(e._payload)}function x$(e){const t=$M(e),n=_.forwardRef((o,r)=>{let{children:i,...a}=o;w$(i)&&typeof Di=="function"&&(i=Di(i._payload));const s=_.Children.toArray(i),l=s.find(kM);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return m.jsx(t,{...a,ref:r,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:r,children:i})});return n.displayName=`${e}.Slot`,n}var xM=x$("Slot");function $M(e){const t=_.forwardRef((n,o)=>{let{children:r,...i}=n;if(w$(r)&&typeof Di=="function"&&(r=Di(r._payload)),_.isValidElement(r)){const a=TM(r),s=EM(i,r.props);return r.type!==_.Fragment&&(s.ref=o?Hc(o,a):a),_.cloneElement(r,s)}return _.Children.count(r)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var $$=Symbol("radix.slottable");function SM(e){const t=({children:n})=>m.jsx(m.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=$$,t}var IM=SM("Slottable");function kM(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===$$}function EM(e,t){const n={...t};for(const o in t){const r=e[o],i=t[o];/^on[A-Z]/.test(o)?r&&i?n[o]=(...s)=>{const l=i(...s);return r(...s),l}:r&&(n[o]=r):o==="style"?n[o]={...r,...i}:o==="className"&&(n[o]=[r,i].filter(Boolean).join(" "))}return{...e,...n}}function TM(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const jf=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Af=T.clsx,S$=(e,t)=>n=>{var o;if(t?.variants==null)return Af(e,n?.class,n?.className);const{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(u=>{const c=n?.[u],d=i?.[u];if(c===null)return null;const f=jf(c)||jf(d);return r[u][f]}),s=n&&Object.entries(n).reduce((u,c)=>{let[d,f]=c;return f===void 0||(u[d]=f),u},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((u,c)=>{let{class:d,className:f,...p}=c;return Object.entries(p).every(g=>{let[h,b]=g;return Array.isArray(b)?b.includes({...i,...s}[h]):{...i,...s}[h]===b})?[...u,d,f]:u},[]);return Af(e,a,l,n?.class,n?.className)},OM=S$("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),$t=_.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},i)=>{const a=o?xM:"button";return m.jsx(a,{"data-slot":"button",className:T.cn(OM({variant:t,size:n,className:e})),ref:i,...r})});$t.displayName="Button";function Oe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function NM(e,t){const n=_.createContext(t),o=i=>{const{children:a,...s}=i,l=_.useMemo(()=>s,Object.values(s));return m.jsx(n.Provider,{value:l,children:a})};o.displayName=e+"Provider";function r(i){const a=_.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[o,r]}function Po(e,t=[]){let n=[];function o(i,a){const s=_.createContext(a),l=n.length;n=[...n,a];const u=d=>{const{scope:f,children:p,...g}=d,h=f?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return m.jsx(h.Provider,{value:b,children:p})};u.displayName=i+"Provider";function c(d,f){const p=f?.[e]?.[l]||s,g=_.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const r=()=>{const i=n.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return r.scopeName=e,[o,PM(r,...t)]}function PM(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function Gc(e){const t=CM(e),n=_.forwardRef((o,r)=>{const{children:i,...a}=o,s=_.Children.toArray(i),l=s.find(AM);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return m.jsx(t,{...a,ref:r,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:r,children:i})});return n.displayName=`${e}.Slot`,n}function CM(e){const t=_.forwardRef((n,o)=>{const{children:r,...i}=n;if(_.isValidElement(r)){const a=zM(r),s=RM(i,r.props);return r.type!==_.Fragment&&(s.ref=o?Hc(o,a):a),_.cloneElement(r,s)}return _.Children.count(r)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var I$=Symbol("radix.slottable");function jM(e){const t=({children:n})=>m.jsx(m.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=I$,t}function AM(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===I$}function RM(e,t){const n={...t};for(const o in t){const r=e[o],i=t[o];/^on[A-Z]/.test(o)?r&&i?n[o]=(...s)=>{const l=i(...s);return r(...s),l}:r&&(n[o]=r):o==="style"?n[o]={...r,...i}:o==="className"&&(n[o]=[r,i].filter(Boolean).join(" "))}return{...e,...n}}function zM(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var MM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ce=MM.reduce((e,t)=>{const n=Gc(`Primitive.${t}`),o=_.forwardRef((r,i)=>{const{asChild:a,...s}=r,l=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function DM(e,t){e&&sm.flushSync(()=>e.dispatchEvent(t))}function Sr(e){const t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>(...n)=>t.current?.(...n),[])}function UM(e,t=globalThis?.document){const n=Sr(e);_.useEffect(()=>{const o=r=>{r.key==="Escape"&&n(r)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[n,t])}var LM="DismissableLayer",Ou="dismissableLayer.update",ZM="dismissableLayer.pointerDownOutside",FM="dismissableLayer.focusOutside",Rf,k$=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ha=_.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:o,onPointerDownOutside:r,onFocusOutside:i,onInteractOutside:a,onDismiss:s,...l}=e,u=_.useContext(k$),[c,d]=_.useState(null),f=c?.ownerDocument??globalThis?.document,[,p]=_.useState({}),g=Ge(t,I=>d(I)),h=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=h.indexOf(b),x=c?h.indexOf(c):-1,$=u.layersWithOutsidePointerEventsDisabled.size>0,v=x>=y,k=BM(I=>{const O=I.target,z=[...u.branches].some(F=>F.contains(O));!v||z||(r?.(I),a?.(I),I.defaultPrevented||s?.())},f),N=JM(I=>{const O=I.target;[...u.branches].some(F=>F.contains(O))||(i?.(I),a?.(I),I.defaultPrevented||s?.())},f);return UM(I=>{x===u.layers.size-1&&(o?.(I),!I.defaultPrevented&&s&&(I.preventDefault(),s()))},f),_.useEffect(()=>{if(c)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Rf=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),zf(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Rf)}},[c,f,n,u]),_.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),zf())},[c,u]),_.useEffect(()=>{const I=()=>p({});return document.addEventListener(Ou,I),()=>document.removeEventListener(Ou,I)},[]),m.jsx(Ce.div,{...l,ref:g,style:{pointerEvents:$?v?"auto":"none":void 0,...e.style},onFocusCapture:Oe(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Oe(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Oe(e.onPointerDownCapture,k.onPointerDownCapture)})});Ha.displayName=LM;var qM="DismissableLayerBranch",VM=_.forwardRef((e,t)=>{const n=_.useContext(k$),o=_.useRef(null),r=Ge(t,o);return _.useEffect(()=>{const i=o.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),m.jsx(Ce.div,{...e,ref:r})});VM.displayName=qM;function BM(e,t=globalThis?.document){const n=Sr(e),o=_.useRef(!1),r=_.useRef(()=>{});return _.useEffect(()=>{const i=s=>{if(s.target&&!o.current){let l=function(){E$(ZM,n,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",r.current),r.current=l,t.addEventListener("click",r.current,{once:!0})):l()}else t.removeEventListener("click",r.current);o.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",r.current)}},[t,n]),{onPointerDownCapture:()=>o.current=!0}}function JM(e,t=globalThis?.document){const n=Sr(e),o=_.useRef(!1);return _.useEffect(()=>{const r=i=>{i.target&&!o.current&&E$(FM,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,n]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function zf(){const e=new CustomEvent(Ou);document.dispatchEvent(e)}function E$(e,t,n,{discrete:o}){const r=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&r.addEventListener(e,t,{once:!0}),o?DM(r,i):r.dispatchEvent(i)}var lt=globalThis?.document?_.useLayoutEffect:()=>{},WM=_[" useId ".trim().toString()]||(()=>{}),HM=0;function qr(e){const[t,n]=_.useState(WM());return lt(()=>{n(o=>o??String(HM++))},[e]),t?`radix-${t}`:""}const GM=["top","right","bottom","left"],ur=Math.min,Ye=Math.max,Ui=Math.round,Go=Math.floor,At=e=>({x:e,y:e}),KM={left:"right",right:"left",bottom:"top",top:"bottom"},YM={start:"end",end:"start"};function Nu(e,t,n){return Ye(e,ur(t,n))}function Bt(e,t){return typeof e=="function"?e(t):e}function Jt(e){return e.split("-")[0]}function dn(e){return e.split("-")[1]}function Kc(e){return e==="x"?"y":"x"}function Yc(e){return e==="y"?"height":"width"}const QM=new Set(["top","bottom"]);function jt(e){return QM.has(Jt(e))?"y":"x"}function Qc(e){return Kc(jt(e))}function XM(e,t,n){n===void 0&&(n=!1);const o=dn(e),r=Qc(e),i=Yc(r);let a=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Li(a)),[a,Li(a)]}function e4(e){const t=Li(e);return[Pu(e),t,Pu(t)]}function Pu(e){return e.replace(/start|end/g,t=>YM[t])}const Mf=["left","right"],Df=["right","left"],t4=["top","bottom"],r4=["bottom","top"];function n4(e,t,n){switch(e){case"top":case"bottom":return n?t?Df:Mf:t?Mf:Df;case"left":case"right":return t?t4:r4;default:return[]}}function o4(e,t,n,o){const r=dn(e);let i=n4(Jt(e),n==="start",o);return r&&(i=i.map(a=>a+"-"+r),t&&(i=i.concat(i.map(Pu)))),i}function Li(e){return e.replace(/left|right|bottom|top/g,t=>KM[t])}function i4(e){return{top:0,right:0,bottom:0,left:0,...e}}function T$(e){return typeof e!="number"?i4(e):{top:e,right:e,bottom:e,left:e}}function Zi(e){const{x:t,y:n,width:o,height:r}=e;return{width:o,height:r,top:n,left:t,right:t+o,bottom:n+r,x:t,y:n}}function Uf(e,t,n){let{reference:o,floating:r}=e;const i=jt(t),a=Qc(t),s=Yc(a),l=Jt(t),u=i==="y",c=o.x+o.width/2-r.width/2,d=o.y+o.height/2-r.height/2,f=o[s]/2-r[s]/2;let p;switch(l){case"top":p={x:c,y:o.y-r.height};break;case"bottom":p={x:c,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-r.width,y:d};break;default:p={x:o.x,y:o.y}}switch(dn(t)){case"start":p[a]-=f*(n&&u?-1:1);break;case"end":p[a]+=f*(n&&u?-1:1);break}return p}const a4=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:a}=n,s=i.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:r}),{x:c,y:d}=Uf(u,o,l),f=o,p={},g=0;for(let h=0;h<s.length;h++){const{name:b,fn:y}=s[h],{x,y:$,data:v,reset:k}=await y({x:c,y:d,initialPlacement:o,placement:f,strategy:r,middlewareData:p,rects:u,platform:a,elements:{reference:e,floating:t}});c=x??c,d=$??d,p={...p,[b]:{...p[b],...v}},k&&g<=50&&(g++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(u=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:r}):k.rects),{x:c,y:d}=Uf(u,f,l)),h=-1)}return{x:c,y:d,placement:f,strategy:r,middlewareData:p}};async function Kn(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:i,rects:a,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Bt(t,e),g=T$(p),b=s[f?d==="floating"?"reference":"floating":d],y=Zi(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),x=d==="floating"?{x:o,y:r,width:a.floating.width,height:a.floating.height}:a.reference,$=await(i.getOffsetParent==null?void 0:i.getOffsetParent(s.floating)),v=await(i.isElement==null?void 0:i.isElement($))?await(i.getScale==null?void 0:i.getScale($))||{x:1,y:1}:{x:1,y:1},k=Zi(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:x,offsetParent:$,strategy:l}):x);return{top:(y.top-k.top+g.top)/v.y,bottom:(k.bottom-y.bottom+g.bottom)/v.y,left:(y.left-k.left+g.left)/v.x,right:(k.right-y.right+g.right)/v.x}}const s4=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:i,platform:a,elements:s,middlewareData:l}=t,{element:u,padding:c=0}=Bt(e,t)||{};if(u==null)return{};const d=T$(c),f={x:n,y:o},p=Qc(r),g=Yc(p),h=await a.getDimensions(u),b=p==="y",y=b?"top":"left",x=b?"bottom":"right",$=b?"clientHeight":"clientWidth",v=i.reference[g]+i.reference[p]-f[p]-i.floating[g],k=f[p]-i.reference[p],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let I=N?N[$]:0;(!I||!await(a.isElement==null?void 0:a.isElement(N)))&&(I=s.floating[$]||i.floating[g]);const O=v/2-k/2,z=I/2-h[g]/2-1,F=ur(d[y],z),te=ur(d[x],z),ce=F,B=I-h[g]-te,q=I/2-h[g]/2+O,we=Nu(ce,q,B),oe=!l.arrow&&dn(r)!=null&&q!==we&&i.reference[g]/2-(q<ce?F:te)-h[g]/2<0,de=oe?q<ce?q-ce:q-B:0;return{[p]:f[p]+de,data:{[p]:we,centerOffset:q-we-de,...oe&&{alignmentOffset:de}},reset:oe}}}),u4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:r,middlewareData:i,rects:a,initialPlacement:s,platform:l,elements:u}=t,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...b}=Bt(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=Jt(r),x=jt(s),$=Jt(s)===s,v=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=f||($||!h?[Li(s)]:e4(s)),N=g!=="none";!f&&N&&k.push(...o4(s,h,g,v));const I=[s,...k],O=await Kn(t,b),z=[];let F=((o=i.flip)==null?void 0:o.overflows)||[];if(c&&z.push(O[y]),d){const q=XM(r,a,v);z.push(O[q[0]],O[q[1]])}if(F=[...F,{placement:r,overflows:z}],!z.every(q=>q<=0)){var te,ce;const q=(((te=i.flip)==null?void 0:te.index)||0)+1,we=I[q];if(we&&(!(d==="alignment"?x!==jt(we):!1)||F.every(K=>jt(K.placement)===x?K.overflows[0]>0:!0)))return{data:{index:q,overflows:F},reset:{placement:we}};let oe=(ce=F.filter(de=>de.overflows[0]<=0).sort((de,K)=>de.overflows[1]-K.overflows[1])[0])==null?void 0:ce.placement;if(!oe)switch(p){case"bestFit":{var B;const de=(B=F.filter(K=>{if(N){const fe=jt(K.placement);return fe===x||fe==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(fe=>fe>0).reduce((fe,J)=>fe+J,0)]).sort((K,fe)=>K[1]-fe[1])[0])==null?void 0:B[0];de&&(oe=de);break}case"initialPlacement":oe=s;break}if(r!==oe)return{reset:{placement:oe}}}return{}}}};function Lf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Zf(e){return GM.some(t=>e[t]>=0)}const l4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:o="referenceHidden",...r}=Bt(e,t);switch(o){case"referenceHidden":{const i=await Kn(t,{...r,elementContext:"reference"}),a=Lf(i,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Zf(a)}}}case"escaped":{const i=await Kn(t,{...r,altBoundary:!0}),a=Lf(i,n.floating);return{data:{escapedOffsets:a,escaped:Zf(a)}}}default:return{}}}}},O$=new Set(["left","top"]);async function c4(e,t){const{placement:n,platform:o,elements:r}=e,i=await(o.isRTL==null?void 0:o.isRTL(r.floating)),a=Jt(n),s=dn(n),l=jt(n)==="y",u=O$.has(a)?-1:1,c=i&&l?-1:1,d=Bt(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof g=="number"&&(p=s==="end"?g*-1:g),l?{x:p*c,y:f*u}:{x:f*u,y:p*c}}const d4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:r,y:i,placement:a,middlewareData:s}=t,l=await c4(t,e);return a===((n=s.offset)==null?void 0:n.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:r+l.x,y:i+l.y,data:{...l,placement:a}}}}},p4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:r}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:s={fn:b=>{let{x:y,y:x}=b;return{x:y,y:x}}},...l}=Bt(e,t),u={x:n,y:o},c=await Kn(t,l),d=jt(Jt(r)),f=Kc(d);let p=u[f],g=u[d];if(i){const b=f==="y"?"top":"left",y=f==="y"?"bottom":"right",x=p+c[b],$=p-c[y];p=Nu(x,p,$)}if(a){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",x=g+c[b],$=g-c[y];g=Nu(x,g,$)}const h=s.fn({...t,[f]:p,[d]:g});return{...h,data:{x:h.x-n,y:h.y-o,enabled:{[f]:i,[d]:a}}}}}},f4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:o,placement:r,rects:i,middlewareData:a}=t,{offset:s=0,mainAxis:l=!0,crossAxis:u=!0}=Bt(e,t),c={x:n,y:o},d=jt(r),f=Kc(d);let p=c[f],g=c[d];const h=Bt(s,t),b=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(l){const $=f==="y"?"height":"width",v=i.reference[f]-i.floating[$]+b.mainAxis,k=i.reference[f]+i.reference[$]-b.mainAxis;p<v?p=v:p>k&&(p=k)}if(u){var y,x;const $=f==="y"?"width":"height",v=O$.has(Jt(r)),k=i.reference[d]-i.floating[$]+(v&&((y=a.offset)==null?void 0:y[d])||0)+(v?0:b.crossAxis),N=i.reference[d]+i.reference[$]+(v?0:((x=a.offset)==null?void 0:x[d])||0)-(v?b.crossAxis:0);g<k?g=k:g>N&&(g=N)}return{[f]:p,[d]:g}}}},m4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,o;const{placement:r,rects:i,platform:a,elements:s}=t,{apply:l=()=>{},...u}=Bt(e,t),c=await Kn(t,u),d=Jt(r),f=dn(r),p=jt(r)==="y",{width:g,height:h}=i.floating;let b,y;d==="top"||d==="bottom"?(b=d,y=f===(await(a.isRTL==null?void 0:a.isRTL(s.floating))?"start":"end")?"left":"right"):(y=d,b=f==="end"?"top":"bottom");const x=h-c.top-c.bottom,$=g-c.left-c.right,v=ur(h-c[b],x),k=ur(g-c[y],$),N=!t.middlewareData.shift;let I=v,O=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(O=$),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(I=x),N&&!f){const F=Ye(c.left,0),te=Ye(c.right,0),ce=Ye(c.top,0),B=Ye(c.bottom,0);p?O=g-2*(F!==0||te!==0?F+te:Ye(c.left,c.right)):I=h-2*(ce!==0||B!==0?ce+B:Ye(c.top,c.bottom))}await l({...t,availableWidth:O,availableHeight:I});const z=await a.getDimensions(s.floating);return g!==z.width||h!==z.height?{reset:{rects:!0}}:{}}}};function Ga(){return typeof window<"u"}function pn(e){return N$(e)?(e.nodeName||"").toLowerCase():"#document"}function Qe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Dt(e){var t;return(t=(N$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function N$(e){return Ga()?e instanceof Node||e instanceof Qe(e).Node:!1}function St(e){return Ga()?e instanceof Element||e instanceof Qe(e).Element:!1}function zt(e){return Ga()?e instanceof HTMLElement||e instanceof Qe(e).HTMLElement:!1}function Ff(e){return!Ga()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qe(e).ShadowRoot}const h4=new Set(["inline","contents"]);function Co(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=It(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!h4.has(r)}const g4=new Set(["table","td","th"]);function v4(e){return g4.has(pn(e))}const y4=[":popover-open",":modal"];function Ka(e){return y4.some(t=>{try{return e.matches(t)}catch{return!1}})}const b4=["transform","translate","scale","rotate","perspective"],_4=["transform","translate","scale","rotate","perspective","filter"],w4=["paint","layout","strict","content"];function Xc(e){const t=ed(),n=St(e)?It(e):e;return b4.some(o=>n[o]?n[o]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||_4.some(o=>(n.willChange||"").includes(o))||w4.some(o=>(n.contain||"").includes(o))}function x4(e){let t=lr(e);for(;zt(t)&&!nn(t);){if(Xc(t))return t;if(Ka(t))return null;t=lr(t)}return null}function ed(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const $4=new Set(["html","body","#document"]);function nn(e){return $4.has(pn(e))}function It(e){return Qe(e).getComputedStyle(e)}function Ya(e){return St(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lr(e){if(pn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ff(e)&&e.host||Dt(e);return Ff(t)?t.host:t}function P$(e){const t=lr(e);return nn(t)?e.ownerDocument?e.ownerDocument.body:e.body:zt(t)&&Co(t)?t:P$(t)}function Yn(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=P$(e),i=r===((o=e.ownerDocument)==null?void 0:o.body),a=Qe(r);if(i){const s=Cu(a);return t.concat(a,a.visualViewport||[],Co(r)?r:[],s&&n?Yn(s):[])}return t.concat(r,Yn(r,[],n))}function Cu(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function C$(e){const t=It(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=zt(e),i=r?e.offsetWidth:n,a=r?e.offsetHeight:o,s=Ui(n)!==i||Ui(o)!==a;return s&&(n=i,o=a),{width:n,height:o,$:s}}function td(e){return St(e)?e:e.contextElement}function Vr(e){const t=td(e);if(!zt(t))return At(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:i}=C$(t);let a=(i?Ui(n.width):n.width)/o,s=(i?Ui(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const S4=At(0);function j$(e){const t=Qe(e);return!ed()||!t.visualViewport?S4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function I4(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qe(e)?!1:t}function Ir(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),i=td(e);let a=At(1);t&&(o?St(o)&&(a=Vr(o)):a=Vr(e));const s=I4(i,n,o)?j$(i):At(0);let l=(r.left+s.x)/a.x,u=(r.top+s.y)/a.y,c=r.width/a.x,d=r.height/a.y;if(i){const f=Qe(i),p=o&&St(o)?Qe(o):o;let g=f,h=Cu(g);for(;h&&o&&p!==g;){const b=Vr(h),y=h.getBoundingClientRect(),x=It(h),$=y.left+(h.clientLeft+parseFloat(x.paddingLeft))*b.x,v=y.top+(h.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,u*=b.y,c*=b.x,d*=b.y,l+=$,u+=v,g=Qe(h),h=Cu(g)}}return Zi({width:c,height:d,x:l,y:u})}function rd(e,t){const n=Ya(e).scrollLeft;return t?t.left+n:Ir(Dt(e)).left+n}function A$(e,t,n){n===void 0&&(n=!1);const o=e.getBoundingClientRect(),r=o.left+t.scrollLeft-(n?0:rd(e,o)),i=o.top+t.scrollTop;return{x:r,y:i}}function k4(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const i=r==="fixed",a=Dt(o),s=t?Ka(t.floating):!1;if(o===a||s&&i)return n;let l={scrollLeft:0,scrollTop:0},u=At(1);const c=At(0),d=zt(o);if((d||!d&&!i)&&((pn(o)!=="body"||Co(a))&&(l=Ya(o)),zt(o))){const p=Ir(o);u=Vr(o),c.x=p.x+o.clientLeft,c.y=p.y+o.clientTop}const f=a&&!d&&!i?A$(a,l,!0):At(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+c.x+f.x,y:n.y*u.y-l.scrollTop*u.y+c.y+f.y}}function E4(e){return Array.from(e.getClientRects())}function T4(e){const t=Dt(e),n=Ya(e),o=e.ownerDocument.body,r=Ye(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),i=Ye(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let a=-n.scrollLeft+rd(e);const s=-n.scrollTop;return It(o).direction==="rtl"&&(a+=Ye(t.clientWidth,o.clientWidth)-r),{width:r,height:i,x:a,y:s}}function O4(e,t){const n=Qe(e),o=Dt(e),r=n.visualViewport;let i=o.clientWidth,a=o.clientHeight,s=0,l=0;if(r){i=r.width,a=r.height;const u=ed();(!u||u&&t==="fixed")&&(s=r.offsetLeft,l=r.offsetTop)}return{width:i,height:a,x:s,y:l}}const N4=new Set(["absolute","fixed"]);function P4(e,t){const n=Ir(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,i=zt(e)?Vr(e):At(1),a=e.clientWidth*i.x,s=e.clientHeight*i.y,l=r*i.x,u=o*i.y;return{width:a,height:s,x:l,y:u}}function qf(e,t,n){let o;if(t==="viewport")o=O4(e,n);else if(t==="document")o=T4(Dt(e));else if(St(t))o=P4(t,n);else{const r=j$(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return Zi(o)}function R$(e,t){const n=lr(e);return n===t||!St(n)||nn(n)?!1:It(n).position==="fixed"||R$(n,t)}function C4(e,t){const n=t.get(e);if(n)return n;let o=Yn(e,[],!1).filter(s=>St(s)&&pn(s)!=="body"),r=null;const i=It(e).position==="fixed";let a=i?lr(e):e;for(;St(a)&&!nn(a);){const s=It(a),l=Xc(a);!l&&s.position==="fixed"&&(r=null),(i?!l&&!r:!l&&s.position==="static"&&!!r&&N4.has(r.position)||Co(a)&&!l&&R$(e,a))?o=o.filter(c=>c!==a):r=s,a=lr(a)}return t.set(e,o),o}function j4(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const a=[...n==="clippingAncestors"?Ka(t)?[]:C4(t,this._c):[].concat(n),o],s=a[0],l=a.reduce((u,c)=>{const d=qf(t,c,r);return u.top=Ye(d.top,u.top),u.right=ur(d.right,u.right),u.bottom=ur(d.bottom,u.bottom),u.left=Ye(d.left,u.left),u},qf(t,s,r));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function A4(e){const{width:t,height:n}=C$(e);return{width:t,height:n}}function R4(e,t,n){const o=zt(t),r=Dt(t),i=n==="fixed",a=Ir(e,!0,i,t);let s={scrollLeft:0,scrollTop:0};const l=At(0);function u(){l.x=rd(r)}if(o||!o&&!i)if((pn(t)!=="body"||Co(r))&&(s=Ya(t)),o){const p=Ir(t,!0,i,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else r&&u();i&&!o&&r&&u();const c=r&&!o&&!i?A$(r,s):At(0),d=a.left+s.scrollLeft-l.x-c.x,f=a.top+s.scrollTop-l.y-c.y;return{x:d,y:f,width:a.width,height:a.height}}function Ds(e){return It(e).position==="static"}function Vf(e,t){if(!zt(e)||It(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Dt(e)===n&&(n=n.ownerDocument.body),n}function z$(e,t){const n=Qe(e);if(Ka(e))return n;if(!zt(e)){let r=lr(e);for(;r&&!nn(r);){if(St(r)&&!Ds(r))return r;r=lr(r)}return n}let o=Vf(e,t);for(;o&&v4(o)&&Ds(o);)o=Vf(o,t);return o&&nn(o)&&Ds(o)&&!Xc(o)?n:o||x4(e)||n}const z4=async function(e){const t=this.getOffsetParent||z$,n=this.getDimensions,o=await n(e.floating);return{reference:R4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function M4(e){return It(e).direction==="rtl"}const D4={convertOffsetParentRelativeRectToViewportRelativeRect:k4,getDocumentElement:Dt,getClippingRect:j4,getOffsetParent:z$,getElementRects:z4,getClientRects:E4,getDimensions:A4,getScale:Vr,isElement:St,isRTL:M4};function M$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function U4(e,t){let n=null,o;const r=Dt(e);function i(){var s;clearTimeout(o),(s=n)==null||s.disconnect(),n=null}function a(s,l){s===void 0&&(s=!1),l===void 0&&(l=1),i();const u=e.getBoundingClientRect(),{left:c,top:d,width:f,height:p}=u;if(s||t(),!f||!p)return;const g=Go(d),h=Go(r.clientWidth-(c+f)),b=Go(r.clientHeight-(d+p)),y=Go(c),$={rootMargin:-g+"px "+-h+"px "+-b+"px "+-y+"px",threshold:Ye(0,ur(1,l))||1};let v=!0;function k(N){const I=N[0].intersectionRatio;if(I!==l){if(!v)return a();I?a(!1,I):o=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!M$(u,e.getBoundingClientRect())&&a(),v=!1}try{n=new IntersectionObserver(k,{...$,root:r.ownerDocument})}catch{n=new IntersectionObserver(k,$)}n.observe(e)}return a(!0),i}function L4(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,u=td(e),c=r||i?[...u?Yn(u):[],...Yn(t)]:[];c.forEach(y=>{r&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const d=u&&s?U4(u,n):null;let f=-1,p=null;a&&(p=new ResizeObserver(y=>{let[x]=y;x&&x.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var $;($=p)==null||$.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let g,h=l?Ir(e):null;l&&b();function b(){const y=Ir(e);h&&!M$(h,y)&&n(),h=y,g=requestAnimationFrame(b)}return n(),()=>{var y;c.forEach(x=>{r&&x.removeEventListener("scroll",n),i&&x.removeEventListener("resize",n)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const Z4=d4,F4=p4,q4=u4,V4=m4,B4=l4,Bf=s4,J4=f4,W4=(e,t,n)=>{const o=new Map,r={platform:D4,...n},i={...r.platform,_c:o};return a4(e,t,{...r,platform:i})};var H4=typeof document<"u",G4=function(){},ai=H4?D.useLayoutEffect:G4;function Fi(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!Fi(e[o],t[o]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,r[o]))return!1;for(o=n;o--!==0;){const i=r[o];if(!(i==="_owner"&&e.$$typeof)&&!Fi(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function D$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Jf(e,t){const n=D$(e);return Math.round(t*n)/n}function Us(e){const t=_.useRef(e);return ai(()=>{t.current=e}),t}function K4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:r,elements:{reference:i,floating:a}={},transform:s=!0,whileElementsMounted:l,open:u}=e,[c,d]=_.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=_.useState(o);Fi(f,o)||p(o);const[g,h]=_.useState(null),[b,y]=_.useState(null),x=_.useCallback(K=>{K!==N.current&&(N.current=K,h(K))},[]),$=_.useCallback(K=>{K!==I.current&&(I.current=K,y(K))},[]),v=i||g,k=a||b,N=_.useRef(null),I=_.useRef(null),O=_.useRef(c),z=l!=null,F=Us(l),te=Us(r),ce=Us(u),B=_.useCallback(()=>{if(!N.current||!I.current)return;const K={placement:t,strategy:n,middleware:f};te.current&&(K.platform=te.current),W4(N.current,I.current,K).then(fe=>{const J={...fe,isPositioned:ce.current!==!1};q.current&&!Fi(O.current,J)&&(O.current=J,sm.flushSync(()=>{d(J)}))})},[f,t,n,te,ce]);ai(()=>{u===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,d(K=>({...K,isPositioned:!1})))},[u]);const q=_.useRef(!1);ai(()=>(q.current=!0,()=>{q.current=!1}),[]),ai(()=>{if(v&&(N.current=v),k&&(I.current=k),v&&k){if(F.current)return F.current(v,k,B);B()}},[v,k,B,F,z]);const we=_.useMemo(()=>({reference:N,floating:I,setReference:x,setFloating:$}),[x,$]),oe=_.useMemo(()=>({reference:v,floating:k}),[v,k]),de=_.useMemo(()=>{const K={position:n,left:0,top:0};if(!oe.floating)return K;const fe=Jf(oe.floating,c.x),J=Jf(oe.floating,c.y);return s?{...K,transform:"translate("+fe+"px, "+J+"px)",...D$(oe.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:fe,top:J}},[n,s,oe.floating,c.x,c.y]);return _.useMemo(()=>({...c,update:B,refs:we,elements:oe,floatingStyles:de}),[c,B,we,oe,de])}const Y4=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:o,padding:r}=typeof e=="function"?e(n):e;return o&&t(o)?o.current!=null?Bf({element:o.current,padding:r}).fn(n):{}:o?Bf({element:o,padding:r}).fn(n):{}}}},Q4=(e,t)=>({...Z4(e),options:[e,t]}),X4=(e,t)=>({...F4(e),options:[e,t]}),eD=(e,t)=>({...J4(e),options:[e,t]}),tD=(e,t)=>({...q4(e),options:[e,t]}),rD=(e,t)=>({...V4(e),options:[e,t]}),nD=(e,t)=>({...B4(e),options:[e,t]}),oD=(e,t)=>({...Y4(e),options:[e,t]});var iD="Arrow",U$=_.forwardRef((e,t)=>{const{children:n,width:o=10,height:r=5,...i}=e;return m.jsx(Ce.svg,{...i,ref:t,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});U$.displayName=iD;var aD=U$;function sD(e){const[t,n]=_.useState(void 0);return lt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const i=r[0];let a,s;if("borderBoxSize"in i){const l=i.borderBoxSize,u=Array.isArray(l)?l[0]:l;a=u.inlineSize,s=u.blockSize}else a=e.offsetWidth,s=e.offsetHeight;n({width:a,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else n(void 0)},[e]),t}var nd="Popper",[L$,Qa]=Po(nd),[uD,Z$]=L$(nd),F$=e=>{const{__scopePopper:t,children:n}=e,[o,r]=_.useState(null);return m.jsx(uD,{scope:t,anchor:o,onAnchorChange:r,children:n})};F$.displayName=nd;var q$="PopperAnchor",V$=_.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:o,...r}=e,i=Z$(q$,n),a=_.useRef(null),s=Ge(t,a),l=_.useRef(null);return _.useEffect(()=>{const u=l.current;l.current=o?.current||a.current,u!==l.current&&i.onAnchorChange(l.current)}),o?null:m.jsx(Ce.div,{...r,ref:s})});V$.displayName=q$;var od="PopperContent",[lD,cD]=L$(od),B$=_.forwardRef((e,t)=>{const{__scopePopper:n,side:o="bottom",sideOffset:r=0,align:i="center",alignOffset:a=0,arrowPadding:s=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:g,...h}=e,b=Z$(od,n),[y,x]=_.useState(null),$=Ge(t,xe=>x(xe)),[v,k]=_.useState(null),N=sD(v),I=N?.width??0,O=N?.height??0,z=o+(i!=="center"?"-"+i:""),F=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},te=Array.isArray(u)?u:[u],ce=te.length>0,B={padding:F,boundary:te.filter(pD),altBoundary:ce},{refs:q,floatingStyles:we,placement:oe,isPositioned:de,middlewareData:K}=K4({strategy:"fixed",placement:z,whileElementsMounted:(...xe)=>L4(...xe,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[Q4({mainAxis:r+O,alignmentAxis:a}),l&&X4({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?eD():void 0,...B}),l&&tD({...B}),rD({...B,apply:({elements:xe,rects:Ro,availableWidth:ss,availableHeight:fn})=>{const{width:pt,height:zo}=Ro.reference,je=xe.floating.style;je.setProperty("--radix-popper-available-width",`${ss}px`),je.setProperty("--radix-popper-available-height",`${fn}px`),je.setProperty("--radix-popper-anchor-width",`${pt}px`),je.setProperty("--radix-popper-anchor-height",`${zo}px`)}}),v&&oD({element:v,padding:s}),fD({arrowWidth:I,arrowHeight:O}),f&&nD({strategy:"referenceHidden",...B})]}),[fe,J]=H$(oe),Ue=Sr(g);lt(()=>{de&&Ue?.()},[de,Ue]);const ye=K.arrow?.x,Le=K.arrow?.y,U=K.arrow?.centerOffset!==0,[Q,me]=_.useState();return lt(()=>{y&&me(window.getComputedStyle(y).zIndex)},[y]),m.jsx("div",{ref:q.setFloating,"data-radix-popper-content-wrapper":"",style:{...we,transform:de?we.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[K.transformOrigin?.x,K.transformOrigin?.y].join(" "),...K.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(lD,{scope:n,placedSide:fe,onArrowChange:k,arrowX:ye,arrowY:Le,shouldHideArrow:U,children:m.jsx(Ce.div,{"data-side":fe,"data-align":J,...h,ref:$,style:{...h.style,animation:de?void 0:"none"}})})})});B$.displayName=od;var J$="PopperArrow",dD={top:"bottom",right:"left",bottom:"top",left:"right"},W$=_.forwardRef(function(t,n){const{__scopePopper:o,...r}=t,i=cD(J$,o),a=dD[i.placedSide];return m.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:m.jsx(aD,{...r,ref:n,style:{...r.style,display:"block"}})})});W$.displayName=J$;function pD(e){return e!==null}var fD=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:o,middlewareData:r}=t,a=r.arrow?.centerOffset!==0,s=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[u,c]=H$(n),d={start:"0%",center:"50%",end:"100%"}[c],f=(r.arrow?.x??0)+s/2,p=(r.arrow?.y??0)+l/2;let g="",h="";return u==="bottom"?(g=a?d:`${f}px`,h=`${-l}px`):u==="top"?(g=a?d:`${f}px`,h=`${o.floating.height+l}px`):u==="right"?(g=`${-l}px`,h=a?d:`${p}px`):u==="left"&&(g=`${o.floating.width+l}px`,h=a?d:`${p}px`),{data:{x:g,y:h}}}});function H$(e){const[t,n="center"]=e.split("-");return[t,n]}var G$=F$,id=V$,K$=B$,Y$=W$,mD="Portal",Xa=_.forwardRef((e,t)=>{const{container:n,...o}=e,[r,i]=_.useState(!1);lt(()=>i(!0),[]);const a=n||r&&globalThis?.document?.body;return a?am.createPortal(m.jsx(Ce.div,{...o,ref:t}),a):null});Xa.displayName=mD;function hD(e,t){return _.useReducer((n,o)=>t[n][o]??n,e)}var Gt=e=>{const{present:t,children:n}=e,o=gD(t),r=typeof n=="function"?n({present:o.isPresent}):_.Children.only(n),i=Ge(o.ref,vD(r));return typeof n=="function"||o.isPresent?_.cloneElement(r,{ref:i}):null};Gt.displayName="Presence";function gD(e){const[t,n]=_.useState(),o=_.useRef(null),r=_.useRef(e),i=_.useRef("none"),a=e?"mounted":"unmounted",[s,l]=hD(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return _.useEffect(()=>{const u=Ko(o.current);i.current=s==="mounted"?u:"none"},[s]),lt(()=>{const u=o.current,c=r.current;if(c!==e){const f=i.current,p=Ko(u);e?l("MOUNT"):p==="none"||u?.display==="none"?l("UNMOUNT"):l(c&&f!==p?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,l]),lt(()=>{if(t){let u;const c=t.ownerDocument.defaultView??window,d=p=>{const h=Ko(o.current).includes(CSS.escape(p.animationName));if(p.target===t&&h&&(l("ANIMATION_END"),!r.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",u=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},f=p=>{p.target===t&&(i.current=Ko(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(u),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:_.useCallback(u=>{o.current=u?getComputedStyle(u):null,n(u)},[])}}function Ko(e){return e?.animationName||"none"}function vD(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var yD=_[" useInsertionEffect ".trim().toString()]||lt;function es({prop:e,defaultProp:t,onChange:n=()=>{},caller:o}){const[r,i,a]=bD({defaultProp:t,onChange:n}),s=e!==void 0,l=s?e:r;{const c=_.useRef(e!==void 0);_.useEffect(()=>{const d=c.current;d!==s&&console.warn(`${o} is changing from ${d?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=s},[s,o])}const u=_.useCallback(c=>{if(s){const d=_D(c)?c(e):c;d!==e&&a.current?.(d)}else i(c)},[s,e,i,a]);return[l,u]}function bD({defaultProp:e,onChange:t}){const[n,o]=_.useState(e),r=_.useRef(n),i=_.useRef(t);return yD(()=>{i.current=t},[t]),_.useEffect(()=>{r.current!==n&&(i.current?.(n),r.current=n)},[n,r]),[n,o,i]}function _D(e){return typeof e=="function"}var wD=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),xD="VisuallyHidden",Q$=_.forwardRef((e,t)=>m.jsx(Ce.span,{...e,ref:t,style:{...wD,...e.style}}));Q$.displayName=xD;var $D=Q$,[ts]=Po("Tooltip",[Qa]),rs=Qa(),X$="TooltipProvider",SD=700,ju="tooltip.open",[ID,ad]=ts(X$),eS=e=>{const{__scopeTooltip:t,delayDuration:n=SD,skipDelayDuration:o=300,disableHoverableContent:r=!1,children:i}=e,a=_.useRef(!0),s=_.useRef(!1),l=_.useRef(0);return _.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),m.jsx(ID,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:_.useCallback(()=>{window.clearTimeout(l.current),a.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.current=!0,o)},[o]),isPointerInTransitRef:s,onPointerInTransitChange:_.useCallback(u=>{s.current=u},[]),disableHoverableContent:r,children:i})};eS.displayName=X$;var Qn="Tooltip",[kD,jo]=ts(Qn),tS=e=>{const{__scopeTooltip:t,children:n,open:o,defaultOpen:r,onOpenChange:i,disableHoverableContent:a,delayDuration:s}=e,l=ad(Qn,e.__scopeTooltip),u=rs(t),[c,d]=_.useState(null),f=qr(),p=_.useRef(0),g=a??l.disableHoverableContent,h=s??l.delayDuration,b=_.useRef(!1),[y,x]=es({prop:o,defaultProp:r??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(ju))):l.onClose(),i?.(I)},caller:Qn}),$=_.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),v=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,x(!0)},[x]),k=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),N=_.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,x(!0),p.current=0},h)},[h,x]);return _.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),m.jsx(G$,{...u,children:m.jsx(kD,{scope:t,contentId:f,open:y,stateAttribute:$,trigger:c,onTriggerChange:d,onTriggerEnter:_.useCallback(()=>{l.isOpenDelayedRef.current?N():v()},[l.isOpenDelayedRef,N,v]),onTriggerLeave:_.useCallback(()=>{g?k():(window.clearTimeout(p.current),p.current=0)},[k,g]),onOpen:v,onClose:k,disableHoverableContent:g,children:n})})};tS.displayName=Qn;var Au="TooltipTrigger",rS=_.forwardRef((e,t)=>{const{__scopeTooltip:n,...o}=e,r=jo(Au,n),i=ad(Au,n),a=rs(n),s=_.useRef(null),l=Ge(t,s,r.onTriggerChange),u=_.useRef(!1),c=_.useRef(!1),d=_.useCallback(()=>u.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),m.jsx(id,{asChild:!0,...a,children:m.jsx(Ce.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...o,ref:l,onPointerMove:Oe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!c.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),c.current=!0)}),onPointerLeave:Oe(e.onPointerLeave,()=>{r.onTriggerLeave(),c.current=!1}),onPointerDown:Oe(e.onPointerDown,()=>{r.open&&r.onClose(),u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Oe(e.onFocus,()=>{u.current||r.onOpen()}),onBlur:Oe(e.onBlur,r.onClose),onClick:Oe(e.onClick,r.onClose)})})});rS.displayName=Au;var sd="TooltipPortal",[ED,TD]=ts(sd,{forceMount:void 0}),nS=e=>{const{__scopeTooltip:t,forceMount:n,children:o,container:r}=e,i=jo(sd,t);return m.jsx(ED,{scope:t,forceMount:n,children:m.jsx(Gt,{present:n||i.open,children:m.jsx(Xa,{asChild:!0,container:r,children:o})})})};nS.displayName=sd;var on="TooltipContent",oS=_.forwardRef((e,t)=>{const n=TD(on,e.__scopeTooltip),{forceMount:o=n.forceMount,side:r="top",...i}=e,a=jo(on,e.__scopeTooltip);return m.jsx(Gt,{present:o||a.open,children:a.disableHoverableContent?m.jsx(iS,{side:r,...i,ref:t}):m.jsx(OD,{side:r,...i,ref:t})})}),OD=_.forwardRef((e,t)=>{const n=jo(on,e.__scopeTooltip),o=ad(on,e.__scopeTooltip),r=_.useRef(null),i=Ge(t,r),[a,s]=_.useState(null),{trigger:l,onClose:u}=n,c=r.current,{onPointerInTransitChange:d}=o,f=_.useCallback(()=>{s(null),d(!1)},[d]),p=_.useCallback((g,h)=>{const b=g.currentTarget,y={x:g.clientX,y:g.clientY},x=jD(y,b.getBoundingClientRect()),$=AD(y,x),v=RD(h.getBoundingClientRect()),k=MD([...$,...v]);s(k),d(!0)},[d]);return _.useEffect(()=>()=>f(),[f]),_.useEffect(()=>{if(l&&c){const g=b=>p(b,c),h=b=>p(b,l);return l.addEventListener("pointerleave",g),c.addEventListener("pointerleave",h),()=>{l.removeEventListener("pointerleave",g),c.removeEventListener("pointerleave",h)}}},[l,c,p,f]),_.useEffect(()=>{if(a){const g=h=>{const b=h.target,y={x:h.clientX,y:h.clientY},x=l?.contains(b)||c?.contains(b),$=!zD(y,a);x?f():$&&(f(),u())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[l,c,a,u,f]),m.jsx(iS,{...e,ref:i})}),[ND,PD]=ts(Qn,{isInside:!1}),CD=jM("TooltipContent"),iS=_.forwardRef((e,t)=>{const{__scopeTooltip:n,children:o,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:a,...s}=e,l=jo(on,n),u=rs(n),{onClose:c}=l;return _.useEffect(()=>(document.addEventListener(ju,c),()=>document.removeEventListener(ju,c)),[c]),_.useEffect(()=>{if(l.trigger){const d=f=>{f.target?.contains(l.trigger)&&c()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,c]),m.jsx(Ha,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:d=>d.preventDefault(),onDismiss:c,children:m.jsxs(K$,{"data-state":l.stateAttribute,...u,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(CD,{children:o}),m.jsx(ND,{scope:n,isInside:!0,children:m.jsx($D,{id:l.contentId,role:"tooltip",children:r||o})})]})})});oS.displayName=on;var aS="TooltipArrow",sS=_.forwardRef((e,t)=>{const{__scopeTooltip:n,...o}=e,r=rs(n);return PD(aS,n).isInside?null:m.jsx(Y$,{...r,...o,ref:t})});sS.displayName=aS;function jD(e,t){const n=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,o,r,i)){case i:return"left";case r:return"right";case n:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function AD(e,t,n=5){const o=[];switch(t){case"top":o.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":o.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":o.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":o.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return o}function RD(e){const{top:t,right:n,bottom:o,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:o},{x:r,y:o}]}function zD(e,t){const{x:n,y:o}=e;let r=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i],l=t[a],u=s.x,c=s.y,d=l.x,f=l.y;c>o!=f>o&&n<(d-u)*(o-c)/(f-c)+u&&(r=!r)}return r}function MD(e){const t=e.slice();return t.sort((n,o)=>n.x<o.x?-1:n.x>o.x?1:n.y<o.y?-1:n.y>o.y?1:0),DD(t)}function DD(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const r=e[o];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(r.y-a.y)>=(i.y-a.y)*(r.x-a.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let o=e.length-1;o>=0;o--){const r=e[o];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(r.y-a.y)>=(i.y-a.y)*(r.x-a.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var UD=eS,LD=tS,ZD=rS,FD=nS,qD=oS,VD=sS;function uS({delayDuration:e=0,...t}){return m.jsx(UD,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ud({...e}){return m.jsx(uS,{children:m.jsx(LD,{"data-slot":"tooltip",...e})})}function ld({...e}){return m.jsx(ZD,{"data-slot":"tooltip-trigger",...e})}function cd({className:e,sideOffset:t=0,children:n,...o}){return m.jsx(FD,{children:m.jsxs(qD,{"data-slot":"tooltip-content",sideOffset:t,className:T.cn("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...o,children:[n,m.jsx(VD,{className:"bg-foreground fill-foreground z-20 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]"})]})})}const ct=D.forwardRef(({children:e,tooltip:t,side:n="bottom",align:o="center",className:r,...i},a)=>m.jsxs(ud,{children:[m.jsx(ld,{asChild:!0,children:m.jsxs($t,{variant:"ghost",size:"icon",...i,className:T.cn("aui-button-icon size-6 p-1",r),ref:a,children:[m.jsx(IM,{children:e}),m.jsx("span",{className:"aui-sr-only sr-only",children:t})]})}),m.jsx(cd,{side:n,align:o,children:t})]}));ct.displayName="TooltipIconButton";function BD(e){return D.useMemo(()=>e.reduce((t,n)=>(t?.[n.language]&&!n.overrideExisting||(t={...t,[n.language]:{CodeHeader:n.Header??(()=>null),SyntaxHighlighter:n.Component??void 0}}),t),{}),[e])}const JD=()=>{const{plugins:e}=T.useElements(),t=BD(e);return m.jsx(Ws.MarkdownTextPrimitive,{remarkPlugins:[_0],className:"aui-md",components:GD,componentsByLanguage:t})},lS=D.memo(JD),WD=({language:e,code:t})=>{const o=L.useAssistantState(({message:s})=>s).status?.type==="complete",{isCopied:r,copyToClipboard:i}=HD(),a=()=>{!t||r||i(t)};return o?m.jsxs("div",{className:"aui-code-header-root bg-muted-foreground/15 text-foreground dark:bg-muted-foreground/20 mt-4 flex items-center justify-between gap-4 rounded-t-lg px-4 py-2 text-sm font-semibold",children:[m.jsx("span",{className:"aui-code-header-language lowercase [&>span]:text-xs",children:e}),m.jsxs(ct,{tooltip:"Copy",onClick:a,children:[!r&&m.jsx(Du,{}),r&&m.jsx(rr,{})]})]}):null},HD=({copiedDuration:e=3e3}={})=>{const[t,n]=D.useState(!1);return{isCopied:t,copyToClipboard:r=>{r&&navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),e)})}}},GD=Ws.unstable_memoizeMarkdownComponents({h1:({className:e,...t})=>m.jsx("h1",{className:T.cn("aui-md-h1 mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0",e),...t}),h2:({className:e,...t})=>m.jsx("h2",{className:T.cn("aui-md-h2 mt-8 mb-4 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h3:({className:e,...t})=>m.jsx("h3",{className:T.cn("aui-md-h3 mt-6 mb-4 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h4:({className:e,...t})=>m.jsx("h4",{className:T.cn("aui-md-h4 mt-6 mb-4 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h5:({className:e,...t})=>m.jsx("h5",{className:T.cn("aui-md-h5 my-4 text-lg font-semibold first:mt-0 last:mb-0",e),...t}),h6:({className:e,...t})=>m.jsx("h6",{className:T.cn("aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0",e),...t}),p:({className:e,...t})=>m.jsx("p",{className:T.cn("aui-md-p mt-5 mb-5 leading-7 first:mt-0 last:mb-0",e),...t}),a:({className:e,...t})=>m.jsx("a",{className:T.cn("aui-md-a text-primary font-medium underline underline-offset-4",e),...t}),blockquote:({className:e,...t})=>m.jsx("blockquote",{className:T.cn("aui-md-blockquote border-l-2 pl-6 italic",e),...t}),ul:({className:e,...t})=>m.jsx("ul",{className:T.cn("aui-md-ul my-5 ml-6 list-disc [&>li]:mt-2",e),...t}),ol:({className:e,...t})=>m.jsx("ol",{className:T.cn("aui-md-ol my-5 ml-6 list-decimal [&>li]:mt-2",e),...t}),hr:({className:e,...t})=>m.jsx("hr",{className:T.cn("aui-md-hr my-5 border-b",e),...t}),table:({className:e,...t})=>m.jsx("table",{className:T.cn("aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto",e),...t}),th:({className:e,...t})=>m.jsx("th",{className:T.cn("aui-md-th bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [[align=center]]:text-center [[align=right]]:text-right",e),...t}),td:({className:e,...t})=>m.jsx("td",{className:T.cn("aui-md-td border-b border-l px-4 py-2 text-left last:border-r [[align=center]]:text-center [[align=right]]:text-right",e),...t}),tr:({className:e,...t})=>m.jsx("tr",{className:T.cn("aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",e),...t}),sup:({className:e,...t})=>m.jsx("sup",{className:T.cn("aui-md-sup [&>a]:text-xs [&>a]:no-underline",e),...t}),pre:({className:e,...t})=>m.jsx("pre",{className:T.cn("aui-md-pre text-foreground bg-muted overflow-x-auto rounded-t-none! rounded-b-lg border border-t-0 p-4",e),...t}),code:function({className:t,...n}){const o=Ws.useIsMarkdownCodeBlock();return m.jsx("code",{className:T.cn(!o&&"aui-md-inline-code bg-muted rounded border font-semibold",t),...n})},CodeHeader:WD});var Ls=0;function cS(){_.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Wf()),document.body.insertAdjacentElement("beforeend",e[1]??Wf()),Ls++,()=>{Ls===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ls--}},[])}function Wf(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Zs="focusScope.autoFocusOnMount",Fs="focusScope.autoFocusOnUnmount",Hf={bubbles:!1,cancelable:!0},KD="FocusScope",dd=_.forwardRef((e,t)=>{const{loop:n=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:i,...a}=e,[s,l]=_.useState(null),u=Sr(r),c=Sr(i),d=_.useRef(null),f=Ge(t,h=>l(h)),p=_.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_.useEffect(()=>{if(o){let h=function($){if(p.paused||!s)return;const v=$.target;s.contains(v)?d.current=v:Qt(d.current,{select:!0})},b=function($){if(p.paused||!s)return;const v=$.relatedTarget;v!==null&&(s.contains(v)||Qt(d.current,{select:!0}))},y=function($){if(document.activeElement===document.body)for(const k of $)k.removedNodes.length>0&&Qt(s)};document.addEventListener("focusin",h),document.addEventListener("focusout",b);const x=new MutationObserver(y);return s&&x.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",b),x.disconnect()}}},[o,s,p.paused]),_.useEffect(()=>{if(s){Kf.add(p);const h=document.activeElement;if(!s.contains(h)){const y=new CustomEvent(Zs,Hf);s.addEventListener(Zs,u),s.dispatchEvent(y),y.defaultPrevented||(YD(rU(dS(s)),{select:!0}),document.activeElement===h&&Qt(s))}return()=>{s.removeEventListener(Zs,u),setTimeout(()=>{const y=new CustomEvent(Fs,Hf);s.addEventListener(Fs,c),s.dispatchEvent(y),y.defaultPrevented||Qt(h??document.body,{select:!0}),s.removeEventListener(Fs,c),Kf.remove(p)},0)}}},[s,u,c,p]);const g=_.useCallback(h=>{if(!n&&!o||p.paused)return;const b=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,y=document.activeElement;if(b&&y){const x=h.currentTarget,[$,v]=QD(x);$&&v?!h.shiftKey&&y===v?(h.preventDefault(),n&&Qt($,{select:!0})):h.shiftKey&&y===$&&(h.preventDefault(),n&&Qt(v,{select:!0})):y===x&&h.preventDefault()}},[n,o,p.paused]);return m.jsx(Ce.div,{tabIndex:-1,...a,ref:f,onKeyDown:g})});dd.displayName=KD;function YD(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(Qt(o,{select:t}),document.activeElement!==n)return}function QD(e){const t=dS(e),n=Gf(t,e),o=Gf(t.reverse(),e);return[n,o]}function dS(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Gf(e,t){for(const n of e)if(!XD(n,{upTo:t}))return n}function XD(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function eU(e){return e instanceof HTMLInputElement&&"select"in e}function Qt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&eU(e)&&t&&e.select()}}var Kf=tU();function tU(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Yf(e,t),e.unshift(t)},remove(t){e=Yf(e,t),e[0]?.resume()}}}function Yf(e,t){const n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function rU(e){return e.filter(t=>t.tagName!=="A")}var nU=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Rr=new WeakMap,Yo=new WeakMap,Qo={},qs=0,pS=function(e){return e&&(e.host||pS(e.parentNode))},oU=function(e,t){return t.map(function(n){if(e.contains(n))return n;var o=pS(n);return o&&e.contains(o)?o:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},iU=function(e,t,n,o){var r=oU(t,Array.isArray(e)?e:[e]);Qo[n]||(Qo[n]=new WeakMap);var i=Qo[n],a=[],s=new Set,l=new Set(r),u=function(d){!d||s.has(d)||(s.add(d),u(d.parentNode))};r.forEach(u);var c=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(s.has(f))c(f);else try{var p=f.getAttribute(o),g=p!==null&&p!=="false",h=(Rr.get(f)||0)+1,b=(i.get(f)||0)+1;Rr.set(f,h),i.set(f,b),a.push(f),h===1&&g&&Yo.set(f,!0),b===1&&f.setAttribute(n,"true"),g||f.setAttribute(o,"true")}catch(y){console.error("aria-hidden: cannot operate on ",f,y)}})};return c(t),s.clear(),qs++,function(){a.forEach(function(d){var f=Rr.get(d)-1,p=i.get(d)-1;Rr.set(d,f),i.set(d,p),f||(Yo.has(d)||d.removeAttribute(o),Yo.delete(d)),p||d.removeAttribute(n)}),qs--,qs||(Rr=new WeakMap,Rr=new WeakMap,Yo=new WeakMap,Qo={})}},fS=function(e,t,n){n===void 0&&(n="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=nU(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),iU(o,r,n,"aria-hidden")):function(){return null}},Pt=function(){return Pt=Object.assign||function(t){for(var n,o=1,r=arguments.length;o<r;o++){n=arguments[o];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Pt.apply(this,arguments)};function mS(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);return n}function aU(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,i;o<r;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}var si="right-scroll-bar-position",ui="width-before-scroll-bar",sU="with-scroll-bars-hidden",uU="--removed-body-scroll-bar-size";function Vs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function lU(e,t){var n=D.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(o){var r=n.value;r!==o&&(n.value=o,n.callback(o,r))}}}})[0];return n.callback=t,n.facade}var cU=typeof window<"u"?_.useLayoutEffect:_.useEffect,Qf=new WeakMap;function dU(e,t){var n=lU(null,function(o){return e.forEach(function(r){return Vs(r,o)})});return cU(function(){var o=Qf.get(n);if(o){var r=new Set(o),i=new Set(e),a=n.current;r.forEach(function(s){i.has(s)||Vs(s,null)}),i.forEach(function(s){r.has(s)||Vs(s,a)})}Qf.set(n,e)},[e]),n}function pU(e){return e}function fU(e,t){t===void 0&&(t=pU);var n=[],o=!1,r={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var a=t(i,o);return n.push(a),function(){n=n.filter(function(s){return s!==a})}},assignSyncMedium:function(i){for(o=!0;n.length;){var a=n;n=[],a.forEach(i)}n={push:function(s){return i(s)},filter:function(){return n}}},assignMedium:function(i){o=!0;var a=[];if(n.length){var s=n;n=[],s.forEach(i),a=n}var l=function(){var c=a;a=[],c.forEach(i)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(c){a.push(c),u()},filter:function(c){return a=a.filter(c),n}}}};return r}function mU(e){e===void 0&&(e={});var t=fU(null);return t.options=Pt({async:!0,ssr:!1},e),t}var hS=function(e){var t=e.sideCar,n=mS(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return _.createElement(o,Pt({},n))};hS.isSideCarExport=!0;function hU(e,t){return e.useMedium(t),hS}var gS=mU(),Bs=function(){},ns=_.forwardRef(function(e,t){var n=_.useRef(null),o=_.useState({onScrollCapture:Bs,onWheelCapture:Bs,onTouchMoveCapture:Bs}),r=o[0],i=o[1],a=e.forwardProps,s=e.children,l=e.className,u=e.removeScrollBar,c=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,g=e.noIsolation,h=e.inert,b=e.allowPinchZoom,y=e.as,x=y===void 0?"div":y,$=e.gapMode,v=mS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,N=dU([n,t]),I=Pt(Pt({},v),r);return _.createElement(_.Fragment,null,c&&_.createElement(k,{sideCar:gS,removeScrollBar:u,shards:d,noRelative:p,noIsolation:g,inert:h,setCallbacks:i,allowPinchZoom:!!b,lockRef:n,gapMode:$}),a?_.cloneElement(_.Children.only(s),Pt(Pt({},I),{ref:N})):_.createElement(x,Pt({},I,{className:l,ref:N}),s))});ns.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ns.classNames={fullWidth:ui,zeroRight:si};var gU=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function vU(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=gU();return t&&e.setAttribute("nonce",t),e}function yU(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function bU(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var _U=function(){var e=0,t=null;return{add:function(n){e==0&&(t=vU())&&(yU(t,n),bU(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},wU=function(){var e=_U();return function(t,n){_.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},vS=function(){var e=wU(),t=function(n){var o=n.styles,r=n.dynamic;return e(o,r),null};return t},xU={left:0,top:0,right:0,gap:0},Js=function(e){return parseInt(e||"",10)||0},$U=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],r=t[e==="padding"?"paddingRight":"marginRight"];return[Js(n),Js(o),Js(r)]},SU=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return xU;var t=$U(e),n=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-n+t[2]-t[0])}},IU=vS(),Br="data-scroll-locked",kU=function(e,t,n,o){var r=e.left,i=e.top,a=e.right,s=e.gap;return n===void 0&&(n="margin"),`
|
|
97
|
+
.`.concat(sU,` {
|
|
101
98
|
overflow: hidden `).concat(o,`;
|
|
102
99
|
padding-right: `).concat(s,"px ").concat(o,`;
|
|
103
100
|
}
|
|
104
|
-
body[`).concat(
|
|
101
|
+
body[`).concat(Br,`] {
|
|
105
102
|
overflow: hidden `).concat(o,`;
|
|
106
103
|
overscroll-behavior: contain;
|
|
107
104
|
`).concat([t&&"position: relative ".concat(o,";"),n==="margin"&&`
|
|
@@ -114,30 +111,33 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
114
111
|
`),n==="padding"&&"padding-right: ".concat(s,"px ").concat(o,";")].filter(Boolean).join(""),`
|
|
115
112
|
}
|
|
116
113
|
|
|
117
|
-
.`).concat(
|
|
114
|
+
.`).concat(si,` {
|
|
118
115
|
right: `).concat(s,"px ").concat(o,`;
|
|
119
116
|
}
|
|
120
117
|
|
|
121
|
-
.`).concat(
|
|
118
|
+
.`).concat(ui,` {
|
|
122
119
|
margin-right: `).concat(s,"px ").concat(o,`;
|
|
123
120
|
}
|
|
124
121
|
|
|
125
|
-
.`).concat(
|
|
122
|
+
.`).concat(si," .").concat(si,` {
|
|
126
123
|
right: 0 `).concat(o,`;
|
|
127
124
|
}
|
|
128
125
|
|
|
129
|
-
.`).concat(
|
|
126
|
+
.`).concat(ui," .").concat(ui,` {
|
|
130
127
|
margin-right: 0 `).concat(o,`;
|
|
131
128
|
}
|
|
132
129
|
|
|
133
|
-
body[`).concat(
|
|
134
|
-
`).concat(
|
|
130
|
+
body[`).concat(Br,`] {
|
|
131
|
+
`).concat(uU,": ").concat(s,`px;
|
|
135
132
|
}
|
|
136
|
-
`)},
|
|
133
|
+
`)},Xf=function(){var e=parseInt(document.body.getAttribute(Br)||"0",10);return isFinite(e)?e:0},EU=function(){_.useEffect(function(){return document.body.setAttribute(Br,(Xf()+1).toString()),function(){var e=Xf()-1;e<=0?document.body.removeAttribute(Br):document.body.setAttribute(Br,e.toString())}},[])},TU=function(e){var t=e.noRelative,n=e.noImportant,o=e.gapMode,r=o===void 0?"margin":o;EU();var i=_.useMemo(function(){return SU(r)},[r]);return _.createElement(IU,{styles:kU(i,!t,r,n?"":"!important")})},Ru=!1;if(typeof window<"u")try{var Xo=Object.defineProperty({},"passive",{get:function(){return Ru=!0,!0}});window.addEventListener("test",Xo,Xo),window.removeEventListener("test",Xo,Xo)}catch{Ru=!1}var zr=Ru?{passive:!1}:!1,OU=function(e){return e.tagName==="TEXTAREA"},yS=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!OU(e)&&n[t]==="visible")},NU=function(e){return yS(e,"overflowY")},PU=function(e){return yS(e,"overflowX")},em=function(e,t){var n=t.ownerDocument,o=t;do{typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(o=o.host);var r=bS(e,o);if(r){var i=_S(e,o),a=i[1],s=i[2];if(a>s)return!0}o=o.parentNode}while(o&&o!==n.body);return!1},CU=function(e){var t=e.scrollTop,n=e.scrollHeight,o=e.clientHeight;return[t,n,o]},jU=function(e){var t=e.scrollLeft,n=e.scrollWidth,o=e.clientWidth;return[t,n,o]},bS=function(e,t){return e==="v"?NU(t):PU(t)},_S=function(e,t){return e==="v"?CU(t):jU(t)},AU=function(e,t){return e==="h"&&t==="rtl"?-1:1},RU=function(e,t,n,o,r){var i=AU(e,window.getComputedStyle(t).direction),a=i*o,s=n.target,l=t.contains(s),u=!1,c=a>0,d=0,f=0;do{if(!s)break;var p=_S(e,s),g=p[0],h=p[1],b=p[2],y=h-b-i*g;(g||y)&&bS(e,s)&&(d+=y,f+=g);var x=s.parentNode;s=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}while(!l&&s!==document.body||l&&(t.contains(s)||t===s));return(c&&Math.abs(d)<1||!c&&Math.abs(f)<1)&&(u=!0),u},ei=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},tm=function(e){return[e.deltaX,e.deltaY]},rm=function(e){return e&&"current"in e?e.current:e},zU=function(e,t){return e[0]===t[0]&&e[1]===t[1]},MU=function(e){return`
|
|
137
134
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
138
135
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
139
|
-
`)},WU=0,Rr=[];function HU(e){var t=_.useRef([]),n=_.useRef([0,0]),o=_.useRef(),r=_.useState(WU++)[0],i=_.useState(xS)[0],a=_.useRef(e);_.useEffect(function(){a.current=e},[e]),_.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var m=hU([e.lockRef.current],(e.shards||[]).map(tm),!0).filter(Boolean);return m.forEach(function(b){return b.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),m.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var s=_.useCallback(function(m,b){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!a.current.allowPinchZoom;var y=Yo(m),x=n.current,$="deltaX"in m?m.deltaX:x[0]-y[0],v="deltaY"in m?m.deltaY:x[1]-y[1],k,N=m.target,I=Math.abs($)>Math.abs(v)?"h":"v";if("touches"in m&&I==="h"&&N.type==="range")return!1;var T=Xp(I,N);if(!T)return!0;if(T?k=I:(k=I==="v"?"h":"v",T=Xp(I,N)),!T)return!1;if(!o.current&&"changedTouches"in m&&($||v)&&(o.current=k),!k)return!0;var z=o.current||k;return VU(z,b,m,z==="h"?$:v)},[]),l=_.useCallback(function(m){var b=m;if(!(!Rr.length||Rr[Rr.length-1]!==i)){var y="deltaY"in b?em(b):Yo(b),x=t.current.filter(function(k){return k.name===b.type&&(k.target===b.target||b.target===k.shadowParent)&&BU(k.delta,y)})[0];if(x&&x.should){b.cancelable&&b.preventDefault();return}if(!x){var $=(a.current.shards||[]).map(tm).filter(Boolean).filter(function(k){return k.contains(b.target)}),v=$.length>0?s(b,$[0]):!a.current.noIsolation;v&&b.cancelable&&b.preventDefault()}}},[]),u=_.useCallback(function(m,b,y,x){var $={name:m,delta:b,target:y,should:x,shadowParent:GU(y)};t.current.push($),setTimeout(function(){t.current=t.current.filter(function(v){return v!==$})},1)},[]),c=_.useCallback(function(m){n.current=Yo(m),o.current=void 0},[]),d=_.useCallback(function(m){u(m.type,em(m),m.target,s(m,e.lockRef.current))},[]),p=_.useCallback(function(m){u(m.type,Yo(m),m.target,s(m,e.lockRef.current))},[]);_.useEffect(function(){return Rr.push(i),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:p}),document.addEventListener("wheel",l,Ar),document.addEventListener("touchmove",l,Ar),document.addEventListener("touchstart",c,Ar),function(){Rr=Rr.filter(function(m){return m!==i}),document.removeEventListener("wheel",l,Ar),document.removeEventListener("touchmove",l,Ar),document.removeEventListener("touchstart",c,Ar)}},[]);var f=e.removeScrollBar,g=e.inert;return _.createElement(_.Fragment,null,g?_.createElement(i,{styles:JU(r)}):null,f?_.createElement(MU,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function GU(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const KU=SU(wS,HU);var pd=_.forwardRef(function(e,t){return _.createElement(ts,Ct({},e,{ref:t,sideCar:KU}))});pd.classNames=ts.classNames;var YU=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},zr=new WeakMap,Qo=new WeakMap,Xo={},qs=0,kS=function(e){return e&&(e.host||kS(e.parentNode))},QU=function(e,t){return t.map(function(n){if(e.contains(n))return n;var o=kS(n);return o&&e.contains(o)?o:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},XU=function(e,t,n,o){var r=QU(t,Array.isArray(e)?e:[e]);Xo[n]||(Xo[n]=new WeakMap);var i=Xo[n],a=[],s=new Set,l=new Set(r),u=function(d){!d||s.has(d)||(s.add(d),u(d.parentNode))};r.forEach(u);var c=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(p){if(s.has(p))c(p);else try{var f=p.getAttribute(o),g=f!==null&&f!=="false",m=(zr.get(p)||0)+1,b=(i.get(p)||0)+1;zr.set(p,m),i.set(p,b),a.push(p),m===1&&g&&Qo.set(p,!0),b===1&&p.setAttribute(n,"true"),g||p.setAttribute(o,"true")}catch(y){console.error("aria-hidden: cannot operate on ",p,y)}})};return c(t),s.clear(),qs++,function(){a.forEach(function(d){var p=zr.get(d)-1,f=i.get(d)-1;zr.set(d,p),i.set(d,f),p||(Qo.has(d)||d.removeAttribute(o),Qo.delete(d)),f||d.removeAttribute(n)}),qs--,qs||(zr=new WeakMap,zr=new WeakMap,Qo=new WeakMap,Xo={})}},ES=function(e,t,n){n===void 0&&(n="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=YU(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),XU(o,r,n,"aria-hidden")):function(){return null}},rs="Dialog",[OS]=No(rs),[e6,kt]=OS(rs),TS=e=>{const{__scopeDialog:t,children:n,open:o,defaultOpen:r,onOpenChange:i,modal:a=!0}=e,s=_.useRef(null),l=_.useRef(null),[u,c]=Ya({prop:o,defaultProp:r??!1,onChange:i,caller:rs});return h.jsx(e6,{scope:t,triggerRef:s,contentRef:l,contentId:Fr(),titleId:Fr(),descriptionId:Fr(),open:u,onOpenChange:c,onOpenToggle:_.useCallback(()=>c(d=>!d),[c]),modal:a,children:n})};TS.displayName=rs;var NS="DialogTrigger",PS=_.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=kt(NS,n),i=Ge(t,r.triggerRef);return h.jsx(Ce.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":gd(r.open),...o,ref:i,onClick:Te(e.onClick,r.onOpenToggle)})});PS.displayName=NS;var md="DialogPortal",[t6,CS]=OS(md,{forceMount:void 0}),jS=e=>{const{__scopeDialog:t,forceMount:n,children:o,container:r}=e,i=kt(md,t);return h.jsx(t6,{scope:t,forceMount:n,children:_.Children.map(o,a=>h.jsx(Kt,{present:n||i.open,children:h.jsx(Ka,{asChild:!0,container:r,children:a})}))})};jS.displayName=md;var Li="DialogOverlay",AS=_.forwardRef((e,t)=>{const n=CS(Li,e.__scopeDialog),{forceMount:o=n.forceMount,...r}=e,i=kt(Li,e.__scopeDialog);return i.modal?h.jsx(Kt,{present:o||i.open,children:h.jsx(n6,{...r,ref:t})}):null});AS.displayName=Li;var r6=Wc("DialogOverlay.RemoveScroll"),n6=_.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=kt(Li,n);return h.jsx(pd,{as:r6,allowPinchZoom:!0,shards:[r.contentRef],children:h.jsx(Ce.div,{"data-state":gd(r.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),Ir="DialogContent",RS=_.forwardRef((e,t)=>{const n=CS(Ir,e.__scopeDialog),{forceMount:o=n.forceMount,...r}=e,i=kt(Ir,e.__scopeDialog);return h.jsx(Kt,{present:o||i.open,children:i.modal?h.jsx(o6,{...r,ref:t}):h.jsx(i6,{...r,ref:t})})});RS.displayName=Ir;var o6=_.forwardRef((e,t)=>{const n=kt(Ir,e.__scopeDialog),o=_.useRef(null),r=Ge(t,n.contentRef,o);return _.useEffect(()=>{const i=o.current;if(i)return ES(i)},[]),h.jsx(zS,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Te(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Te(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,s=a.button===0&&a.ctrlKey===!0;(a.button===2||s)&&i.preventDefault()}),onFocusOutside:Te(e.onFocusOutside,i=>i.preventDefault())})}),i6=_.forwardRef((e,t)=>{const n=kt(Ir,e.__scopeDialog),o=_.useRef(!1),r=_.useRef(!1);return h.jsx(zS,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||n.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const a=i.target;n.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),zS=_.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:i,...a}=e,s=kt(Ir,n),l=_.useRef(null),u=Ge(t,l);return yS(),h.jsxs(h.Fragment,{children:[h.jsx(fd,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:i,children:h.jsx(Ba,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":gd(s.open),...a,ref:u,onDismiss:()=>s.onOpenChange(!1)})}),h.jsxs(h.Fragment,{children:[h.jsx(s6,{titleId:s.titleId}),h.jsx(l6,{contentRef:l,descriptionId:s.descriptionId})]})]})}),hd="DialogTitle",MS=_.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=kt(hd,n);return h.jsx(Ce.h2,{id:r.titleId,...o,ref:t})});MS.displayName=hd;var DS="DialogDescription",a6=_.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=kt(DS,n);return h.jsx(Ce.p,{id:r.descriptionId,...o,ref:t})});a6.displayName=DS;var US="DialogClose",LS=_.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=kt(US,n);return h.jsx(Ce.button,{type:"button",...o,ref:t,onClick:Te(e.onClick,()=>r.onOpenChange(!1))})});LS.displayName=US;function gd(e){return e?"open":"closed"}var ZS="DialogTitleWarning",[M2,FS]=$M(ZS,{contentName:Ir,titleName:hd,docsSlug:"dialog"}),s6=({titleId:e})=>{const t=FS(ZS),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
136
|
+
`)},DU=0,Mr=[];function UU(e){var t=_.useRef([]),n=_.useRef([0,0]),o=_.useRef(),r=_.useState(DU++)[0],i=_.useState(vS)[0],a=_.useRef(e);_.useEffect(function(){a.current=e},[e]),_.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var h=aU([e.lockRef.current],(e.shards||[]).map(rm),!0).filter(Boolean);return h.forEach(function(b){return b.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),h.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var s=_.useCallback(function(h,b){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!a.current.allowPinchZoom;var y=ei(h),x=n.current,$="deltaX"in h?h.deltaX:x[0]-y[0],v="deltaY"in h?h.deltaY:x[1]-y[1],k,N=h.target,I=Math.abs($)>Math.abs(v)?"h":"v";if("touches"in h&&I==="h"&&N.type==="range")return!1;var O=em(I,N);if(!O)return!0;if(O?k=I:(k=I==="v"?"h":"v",O=em(I,N)),!O)return!1;if(!o.current&&"changedTouches"in h&&($||v)&&(o.current=k),!k)return!0;var z=o.current||k;return RU(z,b,h,z==="h"?$:v)},[]),l=_.useCallback(function(h){var b=h;if(!(!Mr.length||Mr[Mr.length-1]!==i)){var y="deltaY"in b?tm(b):ei(b),x=t.current.filter(function(k){return k.name===b.type&&(k.target===b.target||b.target===k.shadowParent)&&zU(k.delta,y)})[0];if(x&&x.should){b.cancelable&&b.preventDefault();return}if(!x){var $=(a.current.shards||[]).map(rm).filter(Boolean).filter(function(k){return k.contains(b.target)}),v=$.length>0?s(b,$[0]):!a.current.noIsolation;v&&b.cancelable&&b.preventDefault()}}},[]),u=_.useCallback(function(h,b,y,x){var $={name:h,delta:b,target:y,should:x,shadowParent:LU(y)};t.current.push($),setTimeout(function(){t.current=t.current.filter(function(v){return v!==$})},1)},[]),c=_.useCallback(function(h){n.current=ei(h),o.current=void 0},[]),d=_.useCallback(function(h){u(h.type,tm(h),h.target,s(h,e.lockRef.current))},[]),f=_.useCallback(function(h){u(h.type,ei(h),h.target,s(h,e.lockRef.current))},[]);_.useEffect(function(){return Mr.push(i),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,zr),document.addEventListener("touchmove",l,zr),document.addEventListener("touchstart",c,zr),function(){Mr=Mr.filter(function(h){return h!==i}),document.removeEventListener("wheel",l,zr),document.removeEventListener("touchmove",l,zr),document.removeEventListener("touchstart",c,zr)}},[]);var p=e.removeScrollBar,g=e.inert;return _.createElement(_.Fragment,null,g?_.createElement(i,{styles:MU(r)}):null,p?_.createElement(TU,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function LU(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const ZU=hU(gS,UU);var pd=_.forwardRef(function(e,t){return _.createElement(ns,Pt({},e,{ref:t,sideCar:ZU}))});pd.classNames=ns.classNames;var os="Popover",[wS]=Po(os,[Qa]),Ao=Qa(),[FU,pr]=wS(os),xS=e=>{const{__scopePopover:t,children:n,open:o,defaultOpen:r,onOpenChange:i,modal:a=!1}=e,s=Ao(t),l=_.useRef(null),[u,c]=_.useState(!1),[d,f]=es({prop:o,defaultProp:r??!1,onChange:i,caller:os});return m.jsx(G$,{...s,children:m.jsx(FU,{scope:t,contentId:qr(),triggerRef:l,open:d,onOpenChange:f,onOpenToggle:_.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:u,onCustomAnchorAdd:_.useCallback(()=>c(!0),[]),onCustomAnchorRemove:_.useCallback(()=>c(!1),[]),modal:a,children:n})})};xS.displayName=os;var $S="PopoverAnchor",qU=_.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,r=pr($S,n),i=Ao(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:s}=r;return _.useEffect(()=>(a(),()=>s()),[a,s]),m.jsx(id,{...i,...o,ref:t})});qU.displayName=$S;var SS="PopoverTrigger",IS=_.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,r=pr(SS,n),i=Ao(n),a=Ge(t,r.triggerRef),s=m.jsx(Ce.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":NS(r.open),...o,ref:a,onClick:Oe(e.onClick,r.onOpenToggle)});return r.hasCustomAnchor?s:m.jsx(id,{asChild:!0,...i,children:s})});IS.displayName=SS;var fd="PopoverPortal",[VU,BU]=wS(fd,{forceMount:void 0}),kS=e=>{const{__scopePopover:t,forceMount:n,children:o,container:r}=e,i=pr(fd,t);return m.jsx(VU,{scope:t,forceMount:n,children:m.jsx(Gt,{present:n||i.open,children:m.jsx(Xa,{asChild:!0,container:r,children:o})})})};kS.displayName=fd;var an="PopoverContent",ES=_.forwardRef((e,t)=>{const n=BU(an,e.__scopePopover),{forceMount:o=n.forceMount,...r}=e,i=pr(an,e.__scopePopover);return m.jsx(Gt,{present:o||i.open,children:i.modal?m.jsx(WU,{...r,ref:t}):m.jsx(HU,{...r,ref:t})})});ES.displayName=an;var JU=Gc("PopoverContent.RemoveScroll"),WU=_.forwardRef((e,t)=>{const n=pr(an,e.__scopePopover),o=_.useRef(null),r=Ge(t,o),i=_.useRef(!1);return _.useEffect(()=>{const a=o.current;if(a)return fS(a)},[]),m.jsx(pd,{as:JU,allowPinchZoom:!0,children:m.jsx(TS,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,a=>{a.preventDefault(),i.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Oe(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0,u=s.button===2||l;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Oe(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),HU=_.forwardRef((e,t)=>{const n=pr(an,e.__scopePopover),o=_.useRef(!1),r=_.useRef(!1);return m.jsx(TS,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||n.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const a=i.target;n.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),TS=_.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:c,...d}=e,f=pr(an,n),p=Ao(n);return cS(),m.jsx(dd,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:i,children:m.jsx(Ha,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:c,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>f.onOpenChange(!1),children:m.jsx(K$,{"data-state":NS(f.open),role:"dialog",id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),OS="PopoverClose",GU=_.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,r=pr(OS,n);return m.jsx(Ce.button,{type:"button",...o,ref:t,onClick:Oe(e.onClick,()=>r.onOpenChange(!1))})});GU.displayName=OS;var KU="PopoverArrow",YU=_.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,r=Ao(n);return m.jsx(Y$,{...r,...o,ref:t})});YU.displayName=KU;function NS(e){return e?"open":"closed"}var QU=xS,XU=IS,e6=kS,t6=ES;function PS({...e}){return m.jsx(QU,{"data-slot":"popover",...e})}function CS({...e}){return m.jsx(XU,{"data-slot":"popover-trigger",...e})}function jS({className:e,align:t="center",sideOffset:n=4,...o}){return m.jsx(e6,{children:m.jsx(t6,{"data-slot":"popover-content",align:t,sideOffset:n,className:T.cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...o})})}const r6=S$("flex size-5 items-center justify-center rounded-full",{variants:{status:{pending:"border border-dashed border-muted-foreground/50",running:"text-primary",complete:"text-green-600 dark:text-green-500",error:"text-destructive",approval:"text-amber-500"}},defaultVariants:{status:"pending"}});function n6(e){switch(e){case"text/markdown":return"markdown";case"text/html":return"html";case"text/css":return"css";case"application/json":return"json";case"text/javascript":return"javascript";case"text/typescript":return"typescript";case"text/python":return"python";default:return}}function o6(e,t){if(t==="json")try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}return e}function i6(e){return typeof e=="object"&&e!==null&&"content"in e&&Array.isArray(e.content)}function AS({status:e}){return m.jsxs("div",{className:T.cn(r6({status:e})),children:[e==="pending"&&null,e==="running"&&m.jsx(Hs,{className:"size-4 animate-spin"}),e==="complete"&&m.jsx(rr,{className:"size-4"}),e==="error"&&m.jsx(Xn,{className:"size-4"}),e==="approval"&&m.jsx(Hs,{className:"text-muted-foreground size-4 animate-spin"})]})}function a6({content:e}){const[t,n]=D.useState(!1),o=async r=>{r.stopPropagation(),await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)};return m.jsx("button",{onClick:o,className:"text-muted-foreground hover:bg-accent hover:text-foreground rounded p-1 transition-colors","aria-label":"Copy to clipboard",children:t?m.jsx(rr,{className:"size-4"}):m.jsx(Du,{className:"size-4"})})}function RS({text:e,language:t,className:n}){const[o,r]=D.useState(null);return D.useEffect(()=>{t&&w0.codeToHtml(e,{lang:t,theme:"github-dark-default",rootStyle:"background-color: transparent;",transformers:[{pre(i){i.properties.class="w-full py-3 px-4 max-h-[300px] overflow-y-auto whitespace-pre-wrap text-left text-sm"}}]}).then(r)},[e,t]),o?m.jsx("div",{className:T.cn("w-full bg-slate-800/90",n),dangerouslySetInnerHTML:{__html:o}}):m.jsx("pre",{className:T.cn("w-full bg-slate-800/90 px-4 py-3 text-sm whitespace-pre-wrap text-slate-100",n),children:e})}function s6({data:e}){const t=`data:image/png;base64,${e}`;return m.jsx("div",{className:"flex items-center justify-center rounded-lg p-5",style:{backgroundImage:`linear-gradient(45deg, #ccc 25%, transparent 25%),
|
|
137
|
+
linear-gradient(135deg, #ccc 25%, transparent 25%),
|
|
138
|
+
linear-gradient(45deg, transparent 75%, #ccc 75%),
|
|
139
|
+
linear-gradient(135deg, transparent 75%, #ccc 75%)`,backgroundSize:"25px 25px",backgroundPosition:"0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px"},children:m.jsx("img",{src:t,className:"max-h-[300px] max-w-full object-contain"})})}function u6({content:e}){return m.jsx("div",{className:"w-full",children:e.content.map((t,n)=>{switch(t.type){case"text":{const o=n6(t._meta?.["getgram.ai/mime-type"]??"text/plain"),r=o6(t.text,o);return m.jsx(RS,{text:r,language:o},n)}case"image":return m.jsx(s6,{data:t.data},n);default:return m.jsx("pre",{className:"px-4 py-3 text-sm whitespace-pre-wrap",children:JSON.stringify(t,null,2)},n)}})})}function nm({title:e,content:t,defaultExpanded:n=!1,highlightSyntax:o=!0,language:r="json"}){const[i,a]=D.useState(n),s=i6(t),l=s?JSON.stringify(t,null,2):typeof t=="string"?t:JSON.stringify(t,null,2);return m.jsxs("div",{"data-slot":"tool-ui-section",className:"border-border border-t",children:[m.jsxs("button",{onClick:()=>a(!i),className:"hover:bg-accent/50 flex w-full cursor-pointer items-center justify-between px-4 py-2.5 text-left transition-colors",children:[m.jsx("span",{className:"text-muted-foreground text-sm",children:e}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(a6,{content:l}),m.jsx(um,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",i&&"rotate-90")})]})]}),i&&m.jsx("div",{className:"border-border border-t",children:s?m.jsx(u6,{content:t}):o?m.jsx(RS,{text:l,language:r}):m.jsx("pre",{className:"text-foreground overflow-x-auto px-4 py-3 text-sm whitespace-pre-wrap",children:l})})]})}function l6({name:e,icon:t,provider:n,status:o="complete",request:r,result:i,defaultExpanded:a=!1,className:s,onApproveOnce:l,onApproveForSession:u,onDeny:c}){const d=o==="approval"&&l!==void 0&&c!==void 0,[f,p]=D.useState(a),g=r!==void 0||i!==void 0,[h,b]=D.useState("one-time"),[y,x]=D.useState(!1);D.useEffect(()=>{!d&&f&&!a&&p(!1)},[d]);const $=()=>{h==="for-session"&&u?u():l&&l()};return m.jsxs("div",{"data-slot":"tool-ui",className:T.cn("border-border bg-card overflow-hidden rounded-lg border",s),children:[n&&m.jsxs("div",{"data-slot":"tool-ui-provider",className:T.cn("border-border flex items-center gap-2 border-b px-4 py-2.5"),children:[t?m.jsx("span",{className:"flex size-5 items-center justify-center",children:t}):m.jsx("span",{className:"bg-muted flex size-5 items-center justify-center rounded text-xs font-medium",children:n.charAt(0).toUpperCase()}),m.jsx("span",{className:"text-sm font-medium",children:n})]}),m.jsxs("button",{onClick:()=>g&&p(!f),disabled:!g,className:T.cn("flex w-full items-center gap-2 px-4 py-3 text-left",g&&"hover:bg-accent/50 cursor-pointer transition-colors"),children:[m.jsx(AS,{status:o}),m.jsx("span",{className:T.cn("flex-1 text-sm",!n&&d&&"shimmer"),children:e}),g&&m.jsx(li,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",f&&"rotate-180")})]}),f&&g&&m.jsxs("div",{"data-slot":"tool-ui-content",children:[r!==void 0&&m.jsx(nm,{title:"Arguments",content:r,highlightSyntax:!0,language:"json"}),i!==void 0&&m.jsx(nm,{title:"Output",content:i,highlightSyntax:!0,language:"json"})]}),d&&m.jsxs("div",{"data-slot":"tool-ui-approval-actions",className:"border-border flex items-center justify-end gap-2 border-t px-4 py-3",children:[m.jsx("div",{children:m.jsx("span",{className:"text-muted-foreground text-sm",children:"This tool requires approval"})}),m.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[m.jsxs($t,{variant:"outline",size:"sm",onClick:c,className:"text-destructive hover:bg-destructive/10",children:[m.jsx(Xn,{className:"mr-1 size-3"}),"Deny"]}),m.jsxs("div",{className:"flex items-center",children:[m.jsxs($t,{variant:"default",size:"sm",onClick:$,className:"flex cursor-pointer justify-between gap-1 rounded-r-none bg-emerald-600 hover:bg-emerald-700",children:[m.jsx(rr,{className:"mr-1 size-3"}),m.jsx("span",{className:"min-w-[110px]",children:h==="one-time"?"Approve this time":"Approve always"})]}),m.jsxs(PS,{open:y,onOpenChange:x,children:[m.jsx(CS,{asChild:!0,children:m.jsx($t,{variant:"default",size:"sm",className:"cursor-pointer rounded-l-none border-l border-emerald-700 bg-emerald-600 px-2 hover:bg-emerald-700",children:m.jsx(li,{className:"size-3"})})}),m.jsxs(jS,{align:"end",className:"w-64 p-1",sideOffset:4,children:[m.jsxs("button",{onClick:()=>{b("one-time"),x(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[m.jsx(rr,{className:T.cn("relative top-1 mt-0.5 size-3 shrink-0",h!=="one-time"&&"invisible")}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("span",{className:"text-sm",children:"Approve only once"}),m.jsx("span",{className:"text-muted-foreground text-xs",children:"You'll be asked again next time"})]})]}),u&&m.jsxs("button",{onClick:()=>{b("for-session"),x(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[m.jsx(rr,{className:T.cn("relative top-1 mt-0.5 size-3 shrink-0",h!=="for-session"&&"invisible")}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("span",{className:"text-sm",children:"Approve always"}),m.jsx("span",{className:"text-muted-foreground text-xs",children:"Trust this tool for the session"})]})]})]})]})]})]})]})]})}function c6({title:e,icon:t,status:n="complete",defaultExpanded:o=!1,children:r,className:i}){const[a,s]=D.useState(o);return m.jsxs("div",{"data-slot":"tool-ui-group",className:T.cn("border-border bg-card overflow-hidden rounded-lg border",i),children:[m.jsxs("button",{onClick:()=>s(!a),className:"hover:bg-accent/50 flex w-full items-center gap-2 px-4 py-3 text-left transition-colors",children:[t||m.jsx(AS,{status:n==="running"?"running":"complete"}),m.jsx("span",{className:T.cn("flex-1 text-sm font-medium",n==="running"&&"shimmer"),children:e}),m.jsx(li,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",a&&"rotate-180")})]}),a&&m.jsx("div",{"data-slot":"tool-ui-group-content",className:"border-border border-t",children:r})]})}const d6=({toolName:e,toolCallId:t,status:n,result:o,args:r})=>{const{pendingApprovals:i,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:l}=_$(),u=i.get(t),d=L.useAssistantState(({message:x})=>x).parts.filter(x=>x.type==="tool-call"),f=d.findIndex(x=>x.toolName===e),p=()=>{s(t)},g=()=>{a(e),s(t)},h=()=>{l(t)},b=()=>u?"approval":n.type==="incomplete"?"error":n.type==="complete"?o&&typeof o=="object"&&"isError"in o&&o.isError?"error":"complete":"running",y=()=>{if(o!==void 0)return typeof o=="object"&&o!==null&&"content"in o&&Array.isArray(o.content)||typeof o=="string",o};return m.jsx("div",{className:T.cn("aui-tool-fallback-root flex w-full flex-col",f!==-1&&f!==d.length-1&&"border-b"),children:m.jsx(l6,{name:e,status:b(),request:r,result:y(),onApproveOnce:u?p:void 0,onApproveForSession:u?g:void 0,onDeny:u?h:void 0,className:"rounded-none border-0"})})};var is="Collapsible",[p6]=Po(is),[f6,md]=p6(is),zS=_.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:o,defaultOpen:r,disabled:i,onOpenChange:a,...s}=e,[l,u]=es({prop:o,defaultProp:r??!1,onChange:a,caller:is});return m.jsx(f6,{scope:n,disabled:i,contentId:qr(),open:l,onOpenToggle:_.useCallback(()=>u(c=>!c),[u]),children:m.jsx(Ce.div,{"data-state":gd(l),"data-disabled":i?"":void 0,...s,ref:t})})});zS.displayName=is;var MS="CollapsibleTrigger",DS=_.forwardRef((e,t)=>{const{__scopeCollapsible:n,...o}=e,r=md(MS,n);return m.jsx(Ce.button,{type:"button","aria-controls":r.contentId,"aria-expanded":r.open||!1,"data-state":gd(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...o,ref:t,onClick:Oe(e.onClick,r.onOpenToggle)})});DS.displayName=MS;var hd="CollapsibleContent",US=_.forwardRef((e,t)=>{const{forceMount:n,...o}=e,r=md(hd,e.__scopeCollapsible);return m.jsx(Gt,{present:n||r.open,children:({present:i})=>m.jsx(m6,{...o,ref:t,present:i})})});US.displayName=hd;var m6=_.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:o,children:r,...i}=e,a=md(hd,n),[s,l]=_.useState(o),u=_.useRef(null),c=Ge(t,u),d=_.useRef(0),f=d.current,p=_.useRef(0),g=p.current,h=a.open||s,b=_.useRef(h),y=_.useRef(void 0);return _.useEffect(()=>{const x=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(x)},[]),lt(()=>{const x=u.current;if(x){y.current=y.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const $=x.getBoundingClientRect();d.current=$.height,p.current=$.width,b.current||(x.style.transitionDuration=y.current.transitionDuration,x.style.animationName=y.current.animationName),l(o)}},[a.open,o]),m.jsx(Ce.div,{"data-state":gd(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!h,...i,ref:c,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:h&&r})});function gd(e){return e?"open":"closed"}var h6=zS;function g6({...e}){return m.jsx(h6,{"data-slot":"collapsible",...e})}function v6({...e}){return m.jsx(DS,{"data-slot":"collapsible-trigger",...e})}function y6({...e}){return m.jsx(US,{"data-slot":"collapsible-content",...e})}const om=200,LS=({className:e,children:t})=>{const n=D.useRef(null),[o,r]=D.useState(!1),i=L.useScrollLock(n,om),a=D.useCallback(s=>{s||i(),r(s)},[i]);return m.jsx(g6,{ref:n,open:o,onOpenChange:a,className:T.cn("aui-reasoning-root mb-4 w-full",e),style:{"--animation-duration":`${om}ms`},children:t})};LS.displayName="ReasoningRoot";const b6=({className:e})=>m.jsx("div",{className:T.cn("aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-16","bg-[linear-gradient(to_top,var(--color-background),transparent)]","fade-in-0 animate-in","group-data-[state=open]/collapsible-content:animate-out","group-data-[state=open]/collapsible-content:fade-out-0","group-data-[state=open]/collapsible-content:delay-[calc(var(--animation-duration)*0.75)]","group-data-[state=open]/collapsible-content:fill-mode-forwards","duration-(--animation-duration)","group-data-[state=open]/collapsible-content:duration-(--animation-duration)",e)}),_6=({active:e,className:t})=>m.jsxs(v6,{className:T.cn("aui-reasoning-trigger group/trigger text-muted-foreground hover:text-foreground -mb-2 flex max-w-[75%] items-center gap-2 py-2 text-sm transition-colors",t,e&&"shimmer"),children:[m.jsx(O0,{className:"aui-reasoning-trigger-icon size-4 shrink-0"}),m.jsxs("span",{className:"aui-reasoning-trigger-label-wrapper relative inline-block leading-none",children:[m.jsx("span",{children:"Reasoning"}),e?m.jsx("span",{"aria-hidden":!0,className:"aui-reasoning-trigger-shimmer shimmer pointer-events-none absolute inset-0 motion-reduce:animate-none",children:"Reasoning"}):null]}),m.jsx(li,{className:T.cn("aui-reasoning-trigger-chevron mt-0.5 size-4 shrink-0","transition-transform duration-(--animation-duration) ease-out","group-data-[state=closed]/trigger:-rotate-90","group-data-[state=open]/trigger:rotate-0")})]}),ZS=({className:e,children:t,"aria-busy":n})=>m.jsxs(y6,{className:T.cn("aui-reasoning-content text-muted-foreground relative overflow-hidden text-sm outline-none","group/collapsible-content ease-out","data-[state=closed]:animate-collapsible-up","data-[state=open]:animate-collapsible-down","data-[state=closed]:fill-mode-forwards","data-[state=closed]:pointer-events-none","data-[state=open]:duration-(--animation-duration)","data-[state=closed]:duration-(--animation-duration)",e),"aria-busy":n,children:[t,m.jsx(b6,{})]});ZS.displayName="ReasoningContent";const FS=({className:e,children:t})=>m.jsx("div",{className:T.cn("aui-reasoning-text relative z-0 space-y-4 pt-4 pl-6 leading-relaxed","transform-gpu transition-[transform,opacity]","group-data-[state=open]/collapsible-content:animate-in","group-data-[state=closed]/collapsible-content:animate-out","group-data-[state=open]/collapsible-content:fade-in-0","group-data-[state=closed]/collapsible-content:fade-out-0","group-data-[state=open]/collapsible-content:slide-in-from-top-4","group-data-[state=closed]/collapsible-content:slide-out-to-top-4","group-data-[state=open]/collapsible-content:duration-(--animation-duration)","group-data-[state=closed]/collapsible-content:duration-(--animation-duration)","[&_p]:-mb-2",e),children:t});FS.displayName="ReasoningText";const w6=()=>m.jsx(lS,{}),x6=({children:e,startIndex:t,endIndex:n})=>{const o=L.useAssistantState(({message:r})=>{if(r.status?.type!=="running")return!1;const i=r.parts.length-1;return i<0||r.parts[i]?.type!=="reasoning"?!1:i>=t&&i<=n});return m.jsxs(LS,{children:[m.jsx(_6,{active:o}),m.jsx(ZS,{"aria-busy":o,children:m.jsx(FS,{children:e})})]})},qS=D.memo(w6);qS.displayName="Reasoning";const VS=D.memo(x6);VS.displayName="ReasoningGroup";var as="Dialog",[BS]=Po(as),[$6,kt]=BS(as),JS=e=>{const{__scopeDialog:t,children:n,open:o,defaultOpen:r,onOpenChange:i,modal:a=!0}=e,s=_.useRef(null),l=_.useRef(null),[u,c]=es({prop:o,defaultProp:r??!1,onChange:i,caller:as});return m.jsx($6,{scope:t,triggerRef:s,contentRef:l,contentId:qr(),titleId:qr(),descriptionId:qr(),open:u,onOpenChange:c,onOpenToggle:_.useCallback(()=>c(d=>!d),[c]),modal:a,children:n})};JS.displayName=as;var WS="DialogTrigger",HS=_.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=kt(WS,n),i=Ge(t,r.triggerRef);return m.jsx(Ce.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":bd(r.open),...o,ref:i,onClick:Oe(e.onClick,r.onOpenToggle)})});HS.displayName=WS;var vd="DialogPortal",[S6,GS]=BS(vd,{forceMount:void 0}),KS=e=>{const{__scopeDialog:t,forceMount:n,children:o,container:r}=e,i=kt(vd,t);return m.jsx(S6,{scope:t,forceMount:n,children:_.Children.map(o,a=>m.jsx(Gt,{present:n||i.open,children:m.jsx(Xa,{asChild:!0,container:r,children:a})}))})};KS.displayName=vd;var qi="DialogOverlay",YS=_.forwardRef((e,t)=>{const n=GS(qi,e.__scopeDialog),{forceMount:o=n.forceMount,...r}=e,i=kt(qi,e.__scopeDialog);return i.modal?m.jsx(Gt,{present:o||i.open,children:m.jsx(k6,{...r,ref:t})}):null});YS.displayName=qi;var I6=Gc("DialogOverlay.RemoveScroll"),k6=_.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=kt(qi,n);return m.jsx(pd,{as:I6,allowPinchZoom:!0,shards:[r.contentRef],children:m.jsx(Ce.div,{"data-state":bd(r.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),kr="DialogContent",QS=_.forwardRef((e,t)=>{const n=GS(kr,e.__scopeDialog),{forceMount:o=n.forceMount,...r}=e,i=kt(kr,e.__scopeDialog);return m.jsx(Gt,{present:o||i.open,children:i.modal?m.jsx(E6,{...r,ref:t}):m.jsx(T6,{...r,ref:t})})});QS.displayName=kr;var E6=_.forwardRef((e,t)=>{const n=kt(kr,e.__scopeDialog),o=_.useRef(null),r=Ge(t,n.contentRef,o);return _.useEffect(()=>{const i=o.current;if(i)return fS(i)},[]),m.jsx(XS,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Oe(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,s=a.button===0&&a.ctrlKey===!0;(a.button===2||s)&&i.preventDefault()}),onFocusOutside:Oe(e.onFocusOutside,i=>i.preventDefault())})}),T6=_.forwardRef((e,t)=>{const n=kt(kr,e.__scopeDialog),o=_.useRef(!1),r=_.useRef(!1);return m.jsx(XS,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||n.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const a=i.target;n.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),XS=_.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:i,...a}=e,s=kt(kr,n),l=_.useRef(null),u=Ge(t,l);return cS(),m.jsxs(m.Fragment,{children:[m.jsx(dd,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:i,children:m.jsx(Ha,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":bd(s.open),...a,ref:u,onDismiss:()=>s.onOpenChange(!1)})}),m.jsxs(m.Fragment,{children:[m.jsx(N6,{titleId:s.titleId}),m.jsx(C6,{contentRef:l,descriptionId:s.descriptionId})]})]})}),yd="DialogTitle",e0=_.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=kt(yd,n);return m.jsx(Ce.h2,{id:r.titleId,...o,ref:t})});e0.displayName=yd;var t0="DialogDescription",O6=_.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=kt(t0,n);return m.jsx(Ce.p,{id:r.descriptionId,...o,ref:t})});O6.displayName=t0;var r0="DialogClose",n0=_.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,r=kt(r0,n);return m.jsx(Ce.button,{type:"button",...o,ref:t,onClick:Oe(e.onClick,()=>r.onOpenChange(!1))})});n0.displayName=r0;function bd(e){return e?"open":"closed"}var o0="DialogTitleWarning",[V2,i0]=NM(o0,{contentName:kr,titleName:yd,docsSlug:"dialog"}),N6=({titleId:e})=>{const t=i0(o0),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
140
140
|
|
|
141
141
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
142
142
|
|
|
143
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},u6="DialogDescriptionWarning",l6=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${FS(u6).contentName}}.`;return _.useEffect(()=>{const r=e.current?.getAttribute("aria-describedby");t&&r&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},c6=TS,d6=PS,f6=jS,p6=AS,m6=RS,h6=MS,g6=LS;function v6({...e}){return h.jsx(c6,{"data-slot":"dialog",...e})}function y6({...e}){return h.jsx(d6,{"data-slot":"dialog-trigger",...e})}function b6({...e}){return h.jsx(f6,{"data-slot":"dialog-portal",...e})}function _6({className:e,...t}){return h.jsx(p6,{"data-slot":"dialog-overlay",className:O.cn("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function w6({className:e,children:t,showCloseButton:n=!0,...o}){return h.jsxs(b6,{"data-slot":"dialog-portal",children:[h.jsx(_6,{}),h.jsxs(m6,{"data-slot":"dialog-content",className:O.cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...o,children:[t,n&&h.jsxs(g6,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[h.jsx(Ru,{}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function x6({className:e,...t}){return h.jsx(h6,{"data-slot":"dialog-title",className:O.cn("text-lg leading-none font-semibold",e),...t})}function $6(e,t=[]){let n=[];function o(i,a){const s=_.createContext(a);s.displayName=i+"Context";const l=n.length;n=[...n,a];const u=d=>{const{scope:p,children:f,...g}=d,m=p?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return h.jsx(m.Provider,{value:b,children:f})};u.displayName=i+"Provider";function c(d,p){const f=p?.[e]?.[l]||s,g=_.useContext(f);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const r=()=>{const i=n.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return r.scopeName=e,[o,S6(r,...t)]}function S6(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var I6=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vd=I6.reduce((e,t)=>{const n=b$(`Primitive.${t}`),o=_.forwardRef((r,i)=>{const{asChild:a,...s}=r,l=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function k6(){return dP.useSyncExternalStore(E6,()=>!0,()=>!1)}function E6(){return()=>{}}var yd="Avatar",[O6]=$6(yd),[T6,qS]=O6(yd),VS=_.forwardRef((e,t)=>{const{__scopeAvatar:n,...o}=e,[r,i]=_.useState("idle");return h.jsx(T6,{scope:n,imageLoadingStatus:r,onImageLoadingStatusChange:i,children:h.jsx(vd.span,{...o,ref:t})})});VS.displayName=yd;var BS="AvatarImage",JS=_.forwardRef((e,t)=>{const{__scopeAvatar:n,src:o,onLoadingStatusChange:r=()=>{},...i}=e,a=qS(BS,n),s=N6(o,i),l=$r(u=>{r(u),a.onImageLoadingStatusChange(u)});return ct(()=>{s!=="idle"&&l(s)},[s,l]),s==="loaded"?h.jsx(vd.img,{...i,ref:t,src:o}):null});JS.displayName=BS;var WS="AvatarFallback",HS=_.forwardRef((e,t)=>{const{__scopeAvatar:n,delayMs:o,...r}=e,i=qS(WS,n),[a,s]=_.useState(o===void 0);return _.useEffect(()=>{if(o!==void 0){const l=window.setTimeout(()=>s(!0),o);return()=>window.clearTimeout(l)}},[o]),a&&i.imageLoadingStatus!=="loaded"?h.jsx(vd.span,{...r,ref:t}):null});HS.displayName=WS;function rm(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function N6(e,{referrerPolicy:t,crossOrigin:n}){const o=k6(),r=_.useRef(null),i=o?(r.current||(r.current=new window.Image),r.current):null,[a,s]=_.useState(()=>rm(i,e));return ct(()=>{s(rm(i,e))},[i,e]),ct(()=>{const l=d=>()=>{s(d)};if(!i)return;const u=l("loaded"),c=l("error");return i.addEventListener("load",u),i.addEventListener("error",c),t&&(i.referrerPolicy=t),typeof n=="string"&&(i.crossOrigin=n),()=>{i.removeEventListener("load",u),i.removeEventListener("error",c)}},[i,n,t]),a}var P6=VS,C6=JS,j6=HS;function A6({className:e,...t}){return h.jsx(P6,{"data-slot":"avatar",className:O.cn("relative flex size-8 shrink-0 overflow-hidden rounded-full",e),...t})}function R6({className:e,...t}){return h.jsx(C6,{"data-slot":"avatar-image",className:O.cn("aspect-square size-full",e),...t})}function z6({className:e,...t}){return h.jsx(j6,{"data-slot":"avatar-fallback",className:O.cn("bg-muted flex size-full items-center justify-center rounded-full",e),...t})}const M6=e=>{const[t,n]=F.useState(void 0);return F.useEffect(()=>{if(!e){n(void 0);return}const o=URL.createObjectURL(e);return n(o),()=>{URL.revokeObjectURL(o)}},[e]),t},GS=()=>{const{file:e,src:t}=U.useAssistantState(h0.useShallow(({attachment:n})=>{if(n.type!=="image")return{};if(n.file)return{file:n.file};const o=n.content?.filter(r=>r.type==="image")[0]?.image;return o?{src:o}:{}}));return M6(e)??t},D6=({src:e})=>{const[t,n]=F.useState(!1);return h.jsx("img",{src:e,alt:"Image Preview",className:t?"aui-attachment-preview-image-loaded block h-auto max-h-[80vh] w-auto max-w-full object-contain":"aui-attachment-preview-image-loading hidden",onLoad:()=>n(!0)})},U6=({children:e})=>{const t=GS();return t?h.jsxs(v6,{children:[h.jsx(y6,{className:"aui-attachment-preview-trigger hover:bg-accent/50 cursor-pointer transition-colors",asChild:!0,children:e}),h.jsxs(w6,{className:"aui-attachment-preview-dialog-content [&_svg]:text-background [&>button]:bg-foreground/60 [&>button]:hover:[&_svg]:text-destructive p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:!ring-0",children:[h.jsx(x6,{className:"aui-sr-only sr-only",children:"Image Attachment Preview"}),h.jsx("div",{className:"aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden",children:h.jsx(D6,{src:t})})]})]}):e},L6=()=>{const e=U.useAssistantState(({attachment:n})=>n.type==="image"),t=GS();return h.jsxs(A6,{className:"aui-attachment-tile-avatar h-full w-full rounded-none",children:[h.jsx(R6,{src:t,alt:"Attachment preview",className:"aui-attachment-tile-image object-cover"}),h.jsx(z6,{delayMs:e?200:0,children:h.jsx(C0,{className:"aui-attachment-tile-fallback-icon text-muted-foreground size-8"})})]})},KS=()=>{const t=U.useAssistantApi().attachment.source==="composer",n=U.useAssistantState(({attachment:r})=>r.type==="image"),o=U.useAssistantState(({attachment:r})=>{const i=r.type;switch(i){case"image":return"Image";case"document":return"Document";case"file":return"File";default:{const a=i;throw new Error(`Unknown attachment type: ${a}`)}}});return h.jsxs(ad,{children:[h.jsxs(U.AttachmentPrimitive.Root,{className:O.cn("aui-attachment-root relative",n&&"aui-attachment-root-composer only:[&>#attachment-tile]:size-24"),children:[h.jsx(U6,{children:h.jsx(sd,{asChild:!0,children:h.jsx("div",{className:O.cn("aui-attachment-tile bg-muted size-14 cursor-pointer overflow-hidden rounded-[14px] border transition-opacity hover:opacity-75",t&&"aui-attachment-tile-composer border-foreground/20"),role:"button",id:"attachment-tile","aria-label":`${o} attachment`,children:h.jsx(L6,{})})})}),t&&h.jsx(Z6,{})]}),h.jsx(ud,{side:"top",children:h.jsx(U.AttachmentPrimitive.Name,{})})]})},Z6=()=>h.jsx(U.AttachmentPrimitive.Remove,{asChild:!0,children:h.jsx(dt,{tooltip:"Remove file",className:"aui-attachment-tile-remove text-muted-foreground hover:[&_svg]:text-destructive absolute top-1.5 right-1.5 size-3.5 rounded-full bg-white opacity-100 shadow-sm hover:!bg-white [&_svg]:text-black",side:"top",children:h.jsx(Ru,{className:"aui-attachment-remove-icon size-3 dark:stroke-[2.5px]"})})}),F6=()=>h.jsx("div",{className:"aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2",children:h.jsx(U.MessagePrimitive.Attachments,{components:{Attachment:KS}})}),q6=()=>h.jsx("div",{className:"aui-composer-attachments mb-2 flex w-full flex-row items-center gap-2 overflow-x-auto px-1.5 pt-0.5 pb-1 empty:hidden",children:h.jsx(U.ComposerPrimitive.Attachments,{components:{Attachment:KS}})}),V6=()=>h.jsx(U.ComposerPrimitive.AddAttachment,{asChild:!0,children:h.jsx(dt,{tooltip:"Add Attachment",side:"top",variant:"ghost",size:"icon",align:"start",className:"aui-composer-add-attachment hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-[34px] rounded-full p-1 text-xs font-semibold","aria-label":"Add Attachment",children:h.jsx(W0,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})}),bd=()=>{const{config:e}=O.useElements(),t=e.theme??{};return F.useMemo(()=>{const{colorScheme:n="light"}=t;return{className:n==="dark"||n==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":void 0}},[t])};var ns="Popover",[YS]=No(ns,[Ga]),jo=Ga(),[B6,dr]=YS(ns),QS=e=>{const{__scopePopover:t,children:n,open:o,defaultOpen:r,onOpenChange:i,modal:a=!1}=e,s=jo(t),l=_.useRef(null),[u,c]=_.useState(!1),[d,p]=Ya({prop:o,defaultProp:r??!1,onChange:i,caller:ns});return h.jsx(B$,{...s,children:h.jsx(B6,{scope:t,contentId:Fr(),triggerRef:l,open:d,onOpenChange:p,onOpenToggle:_.useCallback(()=>p(f=>!f),[p]),hasCustomAnchor:u,onCustomAnchorAdd:_.useCallback(()=>c(!0),[]),onCustomAnchorRemove:_.useCallback(()=>c(!1),[]),modal:a,children:n})})};QS.displayName=ns;var XS="PopoverAnchor",J6=_.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,r=dr(XS,n),i=jo(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:s}=r;return _.useEffect(()=>(a(),()=>s()),[a,s]),h.jsx(nd,{...i,...o,ref:t})});J6.displayName=XS;var e0="PopoverTrigger",t0=_.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,r=dr(e0,n),i=jo(n),a=Ge(t,r.triggerRef),s=h.jsx(Ce.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":a0(r.open),...o,ref:a,onClick:Te(e.onClick,r.onOpenToggle)});return r.hasCustomAnchor?s:h.jsx(nd,{asChild:!0,...i,children:s})});t0.displayName=e0;var _d="PopoverPortal",[W6,H6]=YS(_d,{forceMount:void 0}),r0=e=>{const{__scopePopover:t,forceMount:n,children:o,container:r}=e,i=dr(_d,t);return h.jsx(W6,{scope:t,forceMount:n,children:h.jsx(Kt,{present:n||i.open,children:h.jsx(Ka,{asChild:!0,container:r,children:o})})})};r0.displayName=_d;var on="PopoverContent",n0=_.forwardRef((e,t)=>{const n=H6(on,e.__scopePopover),{forceMount:o=n.forceMount,...r}=e,i=dr(on,e.__scopePopover);return h.jsx(Kt,{present:o||i.open,children:i.modal?h.jsx(K6,{...r,ref:t}):h.jsx(Y6,{...r,ref:t})})});n0.displayName=on;var G6=Wc("PopoverContent.RemoveScroll"),K6=_.forwardRef((e,t)=>{const n=dr(on,e.__scopePopover),o=_.useRef(null),r=Ge(t,o),i=_.useRef(!1);return _.useEffect(()=>{const a=o.current;if(a)return ES(a)},[]),h.jsx(pd,{as:G6,allowPinchZoom:!0,children:h.jsx(o0,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Te(e.onCloseAutoFocus,a=>{a.preventDefault(),i.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Te(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0,u=s.button===2||l;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Te(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),Y6=_.forwardRef((e,t)=>{const n=dr(on,e.__scopePopover),o=_.useRef(!1),r=_.useRef(!1);return h.jsx(o0,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||n.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const a=i.target;n.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),o0=_.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:c,...d}=e,p=dr(on,n),f=jo(n);return yS(),h.jsx(fd,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:i,children:h.jsx(Ba,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:c,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:h.jsx(J$,{"data-state":a0(p.open),role:"dialog",id:p.contentId,...f,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),i0="PopoverClose",Q6=_.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,r=dr(i0,n);return h.jsx(Ce.button,{type:"button",...o,ref:t,onClick:Te(e.onClick,()=>r.onOpenChange(!1))})});Q6.displayName=i0;var X6="PopoverArrow",e2=_.forwardRef((e,t)=>{const{__scopePopover:n,...o}=e,r=jo(n);return h.jsx(W$,{...r,...o,ref:t})});e2.displayName=X6;function a0(e){return e?"open":"closed"}var t2=QS,r2=t0,n2=r0,o2=n0;function i2({...e}){return h.jsx(t2,{"data-slot":"popover",...e})}function a2({...e}){return h.jsx(r2,{"data-slot":"popover-trigger",...e})}function s2({className:e,align:t="center",sideOffset:n=4,...o}){return h.jsx(n2,{children:h.jsx(o2,{"data-slot":"popover-content",align:t,sideOffset:n,className:O.cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...o})})}const Ft=[.23,1,.32,1],u2=({children:e})=>{const t=O.useRadius(),n=U.useAssistantState(({message:d})=>d).parts,o=n.filter(d=>d.type==="tool-call"),r=o.some(d=>d.status?.type==="running"),i=F.useMemo(()=>r?h.jsx(Au,{className:"text-muted-foreground size-4 animate-spin"}):h.jsx(Qn,{className:"size-4 text-green-500"}),[r]),{config:a}=O.useElements(),[s,l]=F.useState(a.tools?.expandToolGroupsByDefault??!1),u=O.useDensity(),c=F.useMemo(()=>{const d=n.filter(p=>p.type==="tool-call");return d.length===0?"No tools called":d.length===1?`Calling ${aS(d[0].toolName)}...`:r?`Calling ${d.length} tools...`:`Executed ${d.length} tools`},[n,r]);return a.tools?.components?.[o[0].toolName]?e:h.jsx(st.LazyMotion,{features:st.domAnimation,children:o.length>1?h.jsxs("button",{className:O.cn("group my-4 w-full max-w-xl cursor-pointer border",t("sm")),onClick:()=>l(!s),children:[h.jsxs("div",{className:O.cn("bg-muted/40 flex items-center rounded-b-none!",t("sm"),u("py-xs"),u("gap-md"),u("px-md"),s&&"border-b"),children:[h.jsx("span",{children:i}),h.jsx("span",{className:O.cn("font-semibold",r&&"shimmer"),children:c}),h.jsx("div",{className:"ml-auto",children:h.jsx(Mt,{variant:"ghost",size:"icon",className:"cursor-pointer hover:bg-transparent",onClick:()=>l(!s),children:s?h.jsx(am,{className:"size-4"}):h.jsx(ju,{className:"size-4"})})})]}),h.jsx(st.AnimatePresence,{children:s&&h.jsx(Pt.div,{initial:{height:0,opacity:0,y:-10},animate:{height:"auto",opacity:1,y:0},exit:{height:0,opacity:0,y:-10},transition:{duration:.3,ease:Ft},style:{overflow:"hidden"},children:e})})]}):h.jsx("div",{className:O.cn("bg-muted/40 my-4 flex w-full max-w-xl cursor-pointer items-center rounded-b-none! border"),children:e})})},wd=()=>{const e=bd(),t=O.useDensity(),{config:n}=O.useElements(),o=n.components??{};return h.jsx(st.LazyMotion,{features:st.domAnimation,children:h.jsx(st.MotionConfig,{reducedMotion:"user",children:h.jsx(U.ThreadPrimitive.Root,{className:O.cn("aui-root aui-thread-root bg-background @container flex h-full flex-col",e.className),children:h.jsxs(U.ThreadPrimitive.Viewport,{className:O.cn("aui-thread-viewport relative mx-auto flex w-full flex-1 flex-col overflow-x-auto overflow-y-scroll pb-0!",t("p-lg")),children:[h.jsx(U.ThreadPrimitive.If,{empty:!0,children:o.ThreadWelcome?h.jsx(o.ThreadWelcome,{}):h.jsx(c2,{})}),h.jsx(U.ThreadPrimitive.Messages,{components:{UserMessage:o.UserMessage??b2,EditComposer:o.EditComposer??w2,AssistantMessage:o.AssistantMessage??g2}}),h.jsx(U.ThreadPrimitive.If,{empty:!1,children:h.jsx("div",{className:"aui-thread-viewport-spacer min-h-8 grow"})}),h.jsx(f2,{})]})})})})},l2=()=>h.jsx(U.ThreadPrimitive.ScrollToBottom,{asChild:!0,children:h.jsx(dt,{tooltip:"Scroll to bottom",variant:"outline",className:"aui-thread-scroll-to-bottom dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible",children:h.jsx(y0,{})})}),c2=()=>{const{config:e}=O.useElements(),t=O.useDensity(),{title:n,subtitle:o}=e.welcome??{},r=e.variant==="standalone";return h.jsxs("div",{className:O.cn("aui-thread-welcome-root my-auto flex w-full grow flex-col",r?"items-center justify-center":"",t("gap-lg")),children:[h.jsx("div",{className:O.cn("aui-thread-welcome-center flex w-full grow flex-col items-center justify-start"),children:h.jsxs("div",{className:O.cn("aui-thread-welcome-message flex flex-col",r?"items-center text-center":"size-full justify-start",t("gap-sm"),!r&&t("py-md")),children:[h.jsx(Pt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,ease:Ft},className:O.cn("aui-thread-welcome-message-motion-1 font-semibold",t("text-title")),children:n}),h.jsx(Pt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,delay:.05,ease:Ft},className:O.cn("aui-thread-welcome-message-motion-2 text-muted-foreground/65",t("text-subtitle")),children:o})]})}),h.jsx(d2,{})]})},d2=()=>{const{config:e,isLoadingMCPTools:t}=O.useElements(),n=O.useRadius(),o=O.useDensity(),r=e.welcome?.suggestions??[],i=e.variant==="standalone";return r.length===0?null:h.jsx("div",{className:O.cn("aui-thread-welcome-suggestions w-full",o("gap-md"),o("py-lg"),i?"flex flex-wrap items-center justify-center":r.length===1?"flex":"grid max-w-fit @md:grid-cols-2"),children:r.map((a,s)=>h.jsx(Pt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.25,delay:.03*s,ease:Ft},className:O.cn("aui-thread-welcome-suggestion-display",!i&&"nth-[n+3]:hidden @md:nth-[n+3]:block"),children:h.jsx(U.ThreadPrimitive.Suggestion,{disabled:t,prompt:a.action,send:!0,asChild:!0,children:h.jsxs(Mt,{variant:"ghost",className:O.cn("aui-thread-welcome-suggestion dark:hover:bg-accent/60 h-auto w-full border text-left whitespace-break-spaces",o("text-base"),i?`flex-row items-center ${o("gap-sm")} ${o("px-md")} ${o("py-sm")} ${n("full")}`:`w-full flex-1 flex-col flex-wrap items-start justify-start ${o("gap-sm")} ${o("px-lg")} ${o("py-md")} ${n("xl")}`),"aria-label":a.action,children:[h.jsx("span",{className:"aui-thread-welcome-suggestion-text-1 text-sm font-medium",children:a.title}),h.jsx("span",{className:"aui-thread-welcome-suggestion-text-2 text-muted-foreground text-sm",children:a.label})]})})},`suggested-action-${a.title}-${s}`))})},f2=()=>{const{config:e}=O.useElements(),t=O.useRadius(),n=O.useDensity(),o=e.composer??{placeholder:"Send a message...",attachments:!0},r=e.components??{},{isLoadingMCPTools:i}=O.useElements();return r.Composer?h.jsx(r.Composer,{}):h.jsxs("div",{className:O.cn("aui-composer-wrapper bg-background sticky bottom-0 flex w-full flex-col overflow-visible",n("gap-md"),n("py-md"),t("xl")),children:[h.jsx(l2,{}),h.jsxs(U.ComposerPrimitive.Root,{className:O.cn("aui-composer-root group/input-group border-input bg-background has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-ring/5 dark:bg-background relative flex w-full flex-col border px-1 pt-2 shadow-xs transition-[color,box-shadow] outline-none has-[textarea:focus-visible]:ring-1",t("xl")),children:[o.attachments&&h.jsx(q6,{}),h.jsx(U.ComposerPrimitive.Input,{placeholder:o.placeholder,className:O.cn("aui-composer-input placeholder:text-muted-foreground mb-1 max-h-32 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 outline-none focus-visible:ring-0",n("h-input"),n("text-base")),rows:1,autoFocus:!0,disabled:i,"aria-label":"Message input"}),h.jsx(m2,{})]})]})},p2=()=>{const{model:e,setModel:t}=O.useElements(),[n,o]=F.useState(!1),[r,i]=F.useState(!1),a=F.useRef(null),s=F.useRef(0),l=F.useRef(!1);F.useEffect(()=>{n&&!l.current&&requestAnimationFrame(()=>{const c=a.current;c&&c.scrollHeight>0&&(c.scrollTop=s.current)}),l.current=n},[n]),F.useEffect(()=>{n&&i(!1)},[n]);const u=c=>{s.current=c.currentTarget.scrollTop};return h.jsx(oS,{children:h.jsxs(ad,{open:r&&!n,onOpenChange:i,children:[h.jsxs(i2,{open:n,onOpenChange:o,children:[h.jsx(sd,{asChild:!0,children:h.jsx(a2,{asChild:!0,children:h.jsx(Mt,{variant:"ghost",size:"icon","data-state":n?"open":"closed",className:"aui-composer-model-picker data-[state=open]:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 flex w-fit items-center gap-2 rounded-full px-2.5 py-1 text-xs font-semibold","aria-label":"Model Settings",children:h.jsx(Y0,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})})}),h.jsx(s2,{side:"top",align:"start",className:"w-min p-0 shadow-none",children:h.jsx("div",{ref:a,className:"max-h-48 overflow-y-auto",onScroll:u,children:im.map(c=>h.jsxs(Mt,{onClick:()=>{t(c)},variant:"ghost",className:"w-full justify-start gap-2 rounded-none px-2",children:[c===e?h.jsx("div",{children:h.jsx(Qn,{className:"size-4 text-emerald-500"})}):h.jsx("div",{className:"size-4",children:" "}),c]},c))})})]}),h.jsx(ud,{side:"bottom",align:"start",children:"Model Settings"})]})})},m2=()=>{const{config:e}=O.useElements(),t=O.useRadius(),n=e.composer??{attachments:!0};return h.jsxs("div",{className:"aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between",children:[h.jsxs("div",{className:"aui-composer-action-wrapper-inner flex items-center",children:[n.attachments?h.jsx(V6,{}):h.jsx("div",{className:"aui-composer-add-attachment-placeholder"}),e.model?.showModelPicker&&!e.languageModel&&h.jsx(p2,{})]}),h.jsx(U.ThreadPrimitive.If,{running:!1,children:h.jsx(U.ComposerPrimitive.Send,{asChild:!0,children:h.jsx(dt,{tooltip:"Send message",side:"bottom",type:"submit",variant:"default",size:"icon",className:O.cn("aui-composer-send size-[34px] p-1",t("full")),"aria-label":"Send message",children:h.jsx(_0,{className:"aui-composer-send-icon size-5"})})})}),h.jsx(U.ThreadPrimitive.If,{running:!0,children:h.jsx(U.ComposerPrimitive.Cancel,{asChild:!0,children:h.jsx(Mt,{type:"button",variant:"default",size:"icon",className:O.cn("aui-composer-cancel border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90 size-[34px] border",t("full")),"aria-label":"Stop generating",children:h.jsx(X0,{className:"aui-composer-cancel-icon size-3.5 fill-white dark:fill-black"})})})})]})},h2=()=>h.jsx(U.MessagePrimitive.Error,{children:h.jsx(U.ErrorPrimitive.Root,{className:"aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200",children:h.jsx(U.ErrorPrimitive.Message,{className:"aui-message-error-message line-clamp-2"})})}),g2=()=>{const{config:e}=O.useElements(),t=e.tools??{},n=e.components??{};return h.jsx(U.MessagePrimitive.Root,{asChild:!0,children:h.jsxs("div",{className:"aui-assistant-message-root animate-in fade-in slide-in-from-bottom-1 relative mx-auto w-full py-4 duration-150 ease-out last:mb-24","data-role":"assistant",children:[h.jsxs("div",{className:"aui-assistant-message-content text-foreground mx-2 leading-7 wrap-break-word",children:[h.jsx(U.MessagePrimitive.Parts,{components:{Text:n.Text??iS,Image:n.Image??v2,tools:{by_name:t.components,Fallback:n.ToolFallback??BD},Reasoning:n.Reasoning??hS,ReasoningGroup:n.ReasoningGroup??gS,ToolGroup:n.ToolGroup??u2}}),h.jsx(h2,{})]}),h.jsxs("div",{className:"aui-assistant-message-footer mt-2 ml-2 flex",children:[h.jsx(s0,{}),h.jsx(y2,{})]})]})})},v2=e=>h.jsx("img",{src:e.image}),y2=()=>h.jsxs(U.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",autohideFloat:"single-branch",className:"aui-assistant-action-bar-root text-muted-foreground data-floating:bg-background col-start-3 row-start-2 -ml-1 flex gap-1 data-floating:absolute data-floating:rounded-md data-floating:border data-floating:p-1 data-floating:shadow-sm",children:[h.jsx(U.ActionBarPrimitive.Copy,{asChild:!0,children:h.jsxs(dt,{tooltip:"Copy",children:[h.jsx(U.MessagePrimitive.If,{copied:!0,children:h.jsx(Qn,{})}),h.jsx(U.MessagePrimitive.If,{copied:!1,children:h.jsx(sm,{})})]})}),h.jsx(U.ActionBarPrimitive.Reload,{asChild:!0,children:h.jsx(dt,{tooltip:"Refresh",children:h.jsx(G0,{})})})]}),b2=()=>{const e=O.useRadius();return h.jsx(U.MessagePrimitive.Root,{asChild:!0,children:h.jsxs("div",{className:"aui-user-message-root animate-in fade-in slide-in-from-bottom-1 mx-auto grid w-full auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 px-2 py-4 duration-150 ease-out first:mt-3 last:mb-5 [&:where(>*)]:col-start-2","data-role":"user",children:[h.jsx(F6,{}),h.jsxs("div",{className:"aui-user-message-content-wrapper relative col-start-2 min-w-0",children:[h.jsx("div",{className:O.cn("aui-user-message-content bg-muted text-foreground px-5 py-2.5 wrap-break-word",e("xl")),children:h.jsx(U.MessagePrimitive.Parts,{})}),h.jsx("div",{className:"aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2",children:h.jsx(_2,{})})]}),h.jsx(s0,{className:"aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end"})]})})},_2=()=>h.jsx(U.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",className:"aui-user-action-bar-root flex flex-col items-end",children:h.jsx(U.ActionBarPrimitive.Edit,{asChild:!0,children:h.jsx(dt,{tooltip:"Edit",className:"aui-user-action-edit p-4",children:h.jsx(B0,{})})})}),w2=()=>h.jsx("div",{className:"aui-edit-composer-wrapper mx-auto flex w-full flex-col gap-4 px-2 first:mt-4",children:h.jsxs(U.ComposerPrimitive.Root,{className:"aui-edit-composer-root bg-muted ml-auto flex w-full max-w-7/8 flex-col rounded-xl",children:[h.jsx(U.ComposerPrimitive.Input,{className:"aui-edit-composer-input text-foreground flex min-h-[60px] w-full resize-none bg-transparent p-4 outline-none",autoFocus:!0}),h.jsxs("div",{className:"aui-edit-composer-footer mx-3 mb-3 flex items-center justify-center gap-2 self-end",children:[h.jsx(U.ComposerPrimitive.Cancel,{asChild:!0,children:h.jsx(Mt,{variant:"ghost",size:"sm","aria-label":"Cancel edit",children:"Cancel"})}),h.jsx(U.ComposerPrimitive.Send,{asChild:!0,children:h.jsx(Mt,{size:"sm","aria-label":"Update message",children:"Update"})})]})]})}),s0=({className:e,...t})=>h.jsxs(U.BranchPickerPrimitive.Root,{hideWhenSingleBranch:!0,className:O.cn("aui-branch-picker-root text-muted-foreground mr-2 -ml-2 inline-flex items-center text-xs",e),...t,children:[h.jsx(U.BranchPickerPrimitive.Previous,{asChild:!0,children:h.jsx(dt,{tooltip:"Previous",children:h.jsx(k0,{})})}),h.jsxs("span",{className:"aui-branch-picker-state font-medium",children:[h.jsx(U.BranchPickerPrimitive.Number,{})," / ",h.jsx(U.BranchPickerPrimitive.Count,{})]}),h.jsx(U.BranchPickerPrimitive.Next,{asChild:!0,children:h.jsx(dt,{tooltip:"Next",children:h.jsx(O0,{})})})]}),u0=()=>{const{config:e,isExpanded:t,setIsExpanded:n}=O.useElements(),o=e.modal?.defaultExpanded??!1;return{expandable:e.modal?.expandable??!1,isExpanded:t,setIsExpanded:n,defaultExpanded:o}},x2={layout:{duration:.25,ease:Ft}},$2=()=>{const{config:e}=O.useElements(),t=bd(),n=O.useRadius(),o=O.useDensity(),[r,i]=F.useState(e.modal?.defaultOpen??!1),{expandable:a,isExpanded:s,setIsExpanded:l}=u0(),u=e.modal?.title,c=e.modal?.icon,d=e.modal?.position??"bottom-right",p=S2(d),f=F.useMemo(()=>e.modal?.dimensions?.default??{width:"500px",height:"600px",maxHeight:"95vh"},[e.modal?.dimensions?.default]),g=F.useMemo(()=>e.modal?.dimensions?.expanded??{width:"70vw",height:"90vh"},[e.modal?.dimensions?.expanded]),b=U.useAssistantState(({thread:v})=>v).messages.some(v=>v.status?.type==="running"),y=s?g.width:f.width,x=s?g.height:f.height,$=f.maxHeight;return h.jsx(st.LazyMotion,{features:st.domMax,children:h.jsx(st.MotionConfig,{reducedMotion:"user",transition:x2,children:h.jsx("div",{className:O.cn("aui-root aui-modal-anchor fixed z-10",p,t.className,n("lg"),r&&"shadow-xl"),children:h.jsx(st.AnimatePresence,{mode:"wait",children:r?h.jsxs(Pt.div,{layout:!0,layoutId:"chat-container",className:O.cn("aui-modal-content bg-popover text-popover-foreground flex flex-col overflow-hidden border [&>.aui-thread-root]:bg-inherit",n("lg")),initial:!1,style:{originX:d.includes("left")?0:1,originY:d.includes("top")?0:1,width:y,height:x,maxHeight:$},children:[h.jsxs(Pt.div,{className:O.cn("aui-modal-header flex shrink-0 items-center justify-between border-b",o("h-header"),o("px-lg")),initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1,ease:Ft},children:[h.jsx("div",{className:O.cn("flex min-w-0 items-center"),children:h.jsxs("span",{className:O.cn("text-md flex items-center gap-2 truncate font-medium",b&&"shimmer"),children:[h.jsx("span",{className:"truncate",children:u}),b&&h.jsx(Au,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]})}),h.jsxs("div",{className:"flex flex-row items-center justify-end gap-1",children:[a?h.jsx("button",{type:"button",onClick:()=>l(v=>!v),className:O.cn("text-muted-foreground hover:text-foreground hover:bg-accent flex h-8 cursor-pointer items-center rounded-md px-2 text-xs transition-colors"),"aria-pressed":s,"aria-label":s?"Collapse assistant":"Expand assistant",children:s?h.jsx(U0,{strokeWidth:2,className:"size-3.5 rotate-90"}):h.jsx(R0,{strokeWidth:2,className:"size-3.5 rotate-90"})}):null,h.jsx("button",{onClick:()=>{i(!1),l(!1)},className:"text-muted-foreground hover:text-foreground hover:bg-accent -mr-1 flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors","aria-label":`Close ${u}`,children:h.jsx(Ru,{className:"size-4.5"})})]})]}),h.jsx(Pt.div,{className:"aui-modal-thread w-full flex-1 overflow-hidden",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.05,ease:Ft},children:h.jsx(wd,{})})]},"chat"):h.jsx(Pt.button,{layout:!0,layoutId:"chat-container",onClick:()=>i(!0),className:O.cn("aui-modal-button bg-primary text-primary-foreground flex size-12 cursor-pointer items-center justify-center border shadow-lg transition-shadow hover:shadow-xl",n("full")),initial:!1,"aria-label":`Open ${u}`,style:{originX:1,originY:1},children:h.jsx(Pt.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2,ease:Ft},className:"flex size-full items-center justify-center",children:c?c("closed"):h.jsx(M0,{className:"size-6"})})},"button")})})})})};function S2(e){switch(e){case"bottom-left":return"left-4 bottom-4";case"top-right":return"right-4 top-4";case"top-left":return"left-4 top-4";case"bottom-right":return"right-4 bottom-4";default:O.assertNever(e)}}const I2=()=>{const{config:e}=O.useElements(),t=bd(),n=e.sidecar??{},{title:o,dimensions:r}=n,{isExpanded:i,setIsExpanded:a}=u0(),l=U.useAssistantState(({thread:u})=>u).messages.some(u=>u.status?.type==="running");return h.jsx(st.LazyMotion,{features:st.domMax,children:h.jsxs(Pt.div,{initial:{width:r?.default?.width??"400px",height:r?.default?.height??"100vh"},animate:{width:i?r?.expanded?.width??"800px":r?.default?.width??"400px",height:i?r?.expanded?.height??"100%":r?.default?.height??"100vh"},transition:{duration:.3,ease:Ft},className:O.cn("aui-root aui-sidecar bg-popover text-popover-foreground fixed top-0 right-0 border-l",t.className),children:[h.jsxs("div",{className:"aui-sidecar-header flex h-14 items-center justify-between border-b px-4",children:[h.jsx("span",{className:O.cn("flex items-center gap-2 text-sm font-medium",l&&"shimmer"),children:o}),h.jsx("div",{className:"aui-sidecar-header-actions flex items-center gap-1",children:h.jsx(dt,{tooltip:i?"Collapse":"Pop out",variant:"ghost",className:"aui-sidecar-popout size-8",onClick:()=>a(u=>!u),children:i?h.jsx(Z0,{className:"size-4.5"}):h.jsx(q0,{className:"size-4.5"})})})]}),h.jsx("div",{className:"aui-sidecar-content h-[calc(100%-3.5rem)] overflow-hidden",children:h.jsx(wd,{})})]})})},k2=()=>{const{config:e}=O.useElements();switch(e.variant){case"standalone":return h.jsx(wd,{});case"sidecar":return h.jsx(I2,{});case"widget":return h.jsx($2,{});default:O.assertNever(e.variant)}};exports.useGramElements=O.useElements;exports.Chat=k2;exports.GramElementsProvider=dM;exports.defineFrontendTool=aR;
|
|
143
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},P6="DialogDescriptionWarning",C6=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${i0(P6).contentName}}.`;return _.useEffect(()=>{const r=e.current?.getAttribute("aria-describedby");t&&r&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},j6=JS,A6=HS,R6=KS,z6=YS,M6=QS,D6=e0,U6=n0;function L6({...e}){return m.jsx(j6,{"data-slot":"dialog",...e})}function Z6({...e}){return m.jsx(A6,{"data-slot":"dialog-trigger",...e})}function F6({...e}){return m.jsx(R6,{"data-slot":"dialog-portal",...e})}function q6({className:e,...t}){return m.jsx(z6,{"data-slot":"dialog-overlay",className:T.cn("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function V6({className:e,children:t,showCloseButton:n=!0,...o}){return m.jsxs(F6,{"data-slot":"dialog-portal",children:[m.jsx(q6,{}),m.jsxs(M6,{"data-slot":"dialog-content",className:T.cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...o,children:[t,n&&m.jsxs(U6,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[m.jsx(Xn,{}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function B6({className:e,...t}){return m.jsx(D6,{"data-slot":"dialog-title",className:T.cn("text-lg leading-none font-semibold",e),...t})}function J6(e,t=[]){let n=[];function o(i,a){const s=_.createContext(a);s.displayName=i+"Context";const l=n.length;n=[...n,a];const u=d=>{const{scope:f,children:p,...g}=d,h=f?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return m.jsx(h.Provider,{value:b,children:p})};u.displayName=i+"Provider";function c(d,f){const p=f?.[e]?.[l]||s,g=_.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const r=()=>{const i=n.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return r.scopeName=e,[o,W6(r,...t)]}function W6(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var H6=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_d=H6.reduce((e,t)=>{const n=x$(`Primitive.${t}`),o=_.forwardRef((r,i)=>{const{asChild:a,...s}=r,l=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function G6(){return gP.useSyncExternalStore(K6,()=>!0,()=>!1)}function K6(){return()=>{}}var wd="Avatar",[Y6]=J6(wd),[Q6,a0]=Y6(wd),s0=_.forwardRef((e,t)=>{const{__scopeAvatar:n,...o}=e,[r,i]=_.useState("idle");return m.jsx(Q6,{scope:n,imageLoadingStatus:r,onImageLoadingStatusChange:i,children:m.jsx(_d.span,{...o,ref:t})})});s0.displayName=wd;var u0="AvatarImage",l0=_.forwardRef((e,t)=>{const{__scopeAvatar:n,src:o,onLoadingStatusChange:r=()=>{},...i}=e,a=a0(u0,n),s=X6(o,i),l=Sr(u=>{r(u),a.onImageLoadingStatusChange(u)});return lt(()=>{s!=="idle"&&l(s)},[s,l]),s==="loaded"?m.jsx(_d.img,{...i,ref:t,src:o}):null});l0.displayName=u0;var c0="AvatarFallback",d0=_.forwardRef((e,t)=>{const{__scopeAvatar:n,delayMs:o,...r}=e,i=a0(c0,n),[a,s]=_.useState(o===void 0);return _.useEffect(()=>{if(o!==void 0){const l=window.setTimeout(()=>s(!0),o);return()=>window.clearTimeout(l)}},[o]),a&&i.imageLoadingStatus!=="loaded"?m.jsx(_d.span,{...r,ref:t}):null});d0.displayName=c0;function im(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function X6(e,{referrerPolicy:t,crossOrigin:n}){const o=G6(),r=_.useRef(null),i=o?(r.current||(r.current=new window.Image),r.current):null,[a,s]=_.useState(()=>im(i,e));return lt(()=>{s(im(i,e))},[i,e]),lt(()=>{const l=d=>()=>{s(d)};if(!i)return;const u=l("loaded"),c=l("error");return i.addEventListener("load",u),i.addEventListener("error",c),t&&(i.referrerPolicy=t),typeof n=="string"&&(i.crossOrigin=n),()=>{i.removeEventListener("load",u),i.removeEventListener("error",c)}},[i,n,t]),a}var e2=s0,t2=l0,r2=d0;function n2({className:e,...t}){return m.jsx(e2,{"data-slot":"avatar",className:T.cn("relative flex size-8 shrink-0 overflow-hidden rounded-full",e),...t})}function o2({className:e,...t}){return m.jsx(t2,{"data-slot":"avatar-image",className:T.cn("aspect-square size-full",e),...t})}function i2({className:e,...t}){return m.jsx(r2,{"data-slot":"avatar-fallback",className:T.cn("bg-muted flex size-full items-center justify-center rounded-full",e),...t})}const a2=e=>{const[t,n]=D.useState(void 0);return D.useEffect(()=>{if(!e){n(void 0);return}const o=URL.createObjectURL(e);return n(o),()=>{URL.revokeObjectURL(o)}},[e]),t},p0=()=>{const{file:e,src:t}=L.useAssistantState(x0.useShallow(({attachment:n})=>{if(n.type!=="image")return{};if(n.file)return{file:n.file};const o=n.content?.filter(r=>r.type==="image")[0]?.image;return o?{src:o}:{}}));return a2(e)??t},s2=({src:e})=>{const[t,n]=D.useState(!1);return m.jsx("img",{src:e,alt:"Image Preview",className:t?"aui-attachment-preview-image-loaded block h-auto max-h-[80vh] w-auto max-w-full object-contain":"aui-attachment-preview-image-loading hidden",onLoad:()=>n(!0)})},u2=({children:e})=>{const t=p0();return t?m.jsxs(L6,{children:[m.jsx(Z6,{className:"aui-attachment-preview-trigger hover:bg-accent/50 cursor-pointer transition-colors",asChild:!0,children:e}),m.jsxs(V6,{className:"aui-attachment-preview-dialog-content [&_svg]:text-background [&>button]:bg-foreground/60 [&>button]:hover:[&_svg]:text-destructive p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:!ring-0",children:[m.jsx(B6,{className:"aui-sr-only sr-only",children:"Image Attachment Preview"}),m.jsx("div",{className:"aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden",children:m.jsx(s2,{src:t})})]})]}):e},l2=()=>{const e=L.useAssistantState(({attachment:n})=>n.type==="image"),t=p0();return m.jsxs(n2,{className:"aui-attachment-tile-avatar h-full w-full rounded-none",children:[m.jsx(o2,{src:t,alt:"Attachment preview",className:"aui-attachment-tile-image object-cover"}),m.jsx(i2,{delayMs:e?200:0,children:m.jsx(M0,{className:"aui-attachment-tile-fallback-icon text-muted-foreground size-8"})})]})},f0=()=>{const t=L.useAssistantApi().attachment.source==="composer",n=L.useAssistantState(({attachment:r})=>r.type==="image"),o=L.useAssistantState(({attachment:r})=>{const i=r.type;switch(i){case"image":return"Image";case"document":return"Document";case"file":return"File";default:{const a=i;throw new Error(`Unknown attachment type: ${a}`)}}});return m.jsxs(ud,{children:[m.jsxs(L.AttachmentPrimitive.Root,{className:T.cn("aui-attachment-root relative",n&&"aui-attachment-root-composer only:[&>#attachment-tile]:size-24"),children:[m.jsx(u2,{children:m.jsx(ld,{asChild:!0,children:m.jsx("div",{className:T.cn("aui-attachment-tile bg-muted size-14 cursor-pointer overflow-hidden rounded-[14px] border transition-opacity hover:opacity-75",t&&"aui-attachment-tile-composer border-foreground/20"),role:"button",id:"attachment-tile","aria-label":`${o} attachment`,children:m.jsx(l2,{})})})}),t&&m.jsx(c2,{})]}),m.jsx(cd,{side:"top",children:m.jsx(L.AttachmentPrimitive.Name,{})})]})},c2=()=>m.jsx(L.AttachmentPrimitive.Remove,{asChild:!0,children:m.jsx(ct,{tooltip:"Remove file",className:"aui-attachment-tile-remove text-muted-foreground hover:[&_svg]:text-destructive absolute top-1.5 right-1.5 size-3.5 rounded-full bg-white opacity-100 shadow-sm hover:!bg-white [&_svg]:text-black",side:"top",children:m.jsx(Xn,{className:"aui-attachment-remove-icon size-3 dark:stroke-[2.5px]"})})}),d2=()=>m.jsx("div",{className:"aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2",children:m.jsx(L.MessagePrimitive.Attachments,{components:{Attachment:f0}})}),p2=()=>m.jsx("div",{className:"aui-composer-attachments mb-2 flex w-full flex-row items-center gap-2 overflow-x-auto px-1.5 pt-0.5 pb-1 empty:hidden",children:m.jsx(L.ComposerPrimitive.Attachments,{components:{Attachment:f0}})}),f2=()=>m.jsx(L.ComposerPrimitive.AddAttachment,{asChild:!0,children:m.jsx(ct,{tooltip:"Add Attachment",side:"top",variant:"ghost",size:"icon",align:"start",className:"aui-composer-add-attachment hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-[34px] rounded-full p-1 text-xs font-semibold","aria-label":"Add Attachment",children:m.jsx(Q0,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})}),xd=()=>{const{config:e}=T.useElements(),t=e.theme??{};return D.useMemo(()=>{const{colorScheme:n="light"}=t;return{className:n==="dark"||n==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":void 0}},[t])},or=[.23,1,.32,1];function m2(e){return e.replace(/[-_]/g," ").split(/(?=[A-Z])/).join(" ").split(/\s+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const h2=({children:e})=>{const t=L.useAssistantState(({message:s})=>s).parts,n=t.filter(s=>s.type==="tool-call"),o=n.some(s=>s.status?.type==="running"),{config:r}=T.useElements(),i=r.tools?.expandToolGroupsByDefault??!1,a=D.useMemo(()=>{const s=t.filter(l=>l.type==="tool-call");return s.length===0?"No tools called":s.length===1?`Calling ${m2(s[0].toolName)}...`:o?`Calling ${s.length} tools...`:`Executed ${s.length} tools`},[t,o]);return r.tools?.components?.[n[0]?.toolName]?e:n.length===1?m.jsx("div",{className:T.cn("my-4 w-full max-w-xl"),children:m.jsx("div",{className:"border-border bg-card overflow-hidden rounded-lg border",children:e})}):m.jsx("div",{className:"my-4 w-full max-w-xl",children:m.jsx(c6,{title:a,status:o?"running":"complete",defaultExpanded:i,children:e})})},$d=()=>{const e=xd(),t=T.useDensity(),{config:n}=T.useElements(),o=n.components??{};return m.jsx(Zt.LazyMotion,{features:Zt.domAnimation,children:m.jsx(Zt.MotionConfig,{reducedMotion:"user",children:m.jsx(L.ThreadPrimitive.Root,{className:T.cn("aui-root aui-thread-root bg-background @container flex h-full flex-col",e.className),children:m.jsxs(L.ThreadPrimitive.Viewport,{className:T.cn("aui-thread-viewport relative mx-auto flex w-full flex-1 flex-col overflow-x-auto overflow-y-scroll pb-0!",t("p-lg")),children:[m.jsx(L.ThreadPrimitive.If,{empty:!0,children:o.ThreadWelcome?m.jsx(o.ThreadWelcome,{}):m.jsx(v2,{})}),m.jsx(L.ThreadPrimitive.Messages,{components:{UserMessage:o.UserMessage??k2,EditComposer:o.EditComposer??T2,AssistantMessage:o.AssistantMessage??$2}}),m.jsx(L.ThreadPrimitive.If,{empty:!1,children:m.jsx("div",{className:"aui-thread-viewport-spacer min-h-8 grow"})}),m.jsx(b2,{})]})})})})},g2=()=>m.jsx(L.ThreadPrimitive.ScrollToBottom,{asChild:!0,children:m.jsx(ct,{tooltip:"Scroll to bottom",variant:"outline",className:"aui-thread-scroll-to-bottom dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible",children:m.jsx(I0,{})})}),v2=()=>{const{config:e}=T.useElements(),t=T.useDensity(),{title:n,subtitle:o}=e.welcome??{},r=e.variant==="standalone";return m.jsxs("div",{className:T.cn("aui-thread-welcome-root my-auto flex w-full grow flex-col",r?"items-center justify-center":"",t("gap-lg")),children:[m.jsx("div",{className:T.cn("aui-thread-welcome-center flex w-full grow flex-col items-center justify-start"),children:m.jsxs("div",{className:T.cn("aui-thread-welcome-message flex flex-col",r?"items-center text-center":"size-full justify-start",t("gap-sm"),!r&&t("py-md")),children:[m.jsx(Lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,ease:or},className:T.cn("aui-thread-welcome-message-motion-1 text-foreground font-semibold",t("text-title")),children:n}),m.jsx(Lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,delay:.05,ease:or},className:T.cn("aui-thread-welcome-message-motion-2 text-muted-foreground/65",t("text-subtitle")),children:o})]})}),m.jsx(y2,{})]})},y2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),n=T.useDensity(),o=e.welcome?.suggestions??[],r=e.variant==="standalone";return o.length===0?null:m.jsx("div",{className:T.cn("aui-thread-welcome-suggestions w-full",n("gap-md"),n("py-lg"),r?"flex flex-wrap items-center justify-center":o.length===1?"flex":"grid max-w-fit @md:grid-cols-2"),children:o.map((i,a)=>m.jsx(Lt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.25,delay:.03*a,ease:or},className:T.cn("aui-thread-welcome-suggestion-display",!r&&"nth-[n+3]:hidden @md:nth-[n+3]:block"),children:m.jsx(L.ThreadPrimitive.Suggestion,{prompt:i.action,send:!0,asChild:!0,children:m.jsxs($t,{variant:"ghost",className:T.cn("aui-thread-welcome-suggestion dark:hover:bg-accent/60 h-auto w-full border text-left whitespace-break-spaces",n("text-base"),r?`flex-row items-center ${n("gap-sm")} ${n("px-md")} ${n("py-sm")} ${t("full")}`:`w-full flex-1 flex-col flex-wrap items-start justify-start ${n("gap-sm")} ${n("px-lg")} ${n("py-md")} ${t("xl")}`),"aria-label":i.action,children:[m.jsx("span",{className:"aui-thread-welcome-suggestion-text-1 text-foreground text-sm font-medium",children:i.title}),m.jsx("span",{className:"aui-thread-welcome-suggestion-text-2 text-muted-foreground text-sm",children:i.label})]})})},`suggested-action-${i.title}-${a}`))})},b2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),n=T.useDensity(),o=e.composer??{placeholder:"Send a message...",attachments:!0},r=e.components??{};return r.Composer?m.jsx(r.Composer,{}):m.jsxs("div",{className:T.cn("aui-composer-wrapper bg-background sticky bottom-0 flex w-full flex-col overflow-visible",n("gap-md"),n("py-md"),t("xl")),children:[m.jsx(g2,{}),m.jsxs(L.ComposerPrimitive.Root,{className:T.cn("aui-composer-root group/input-group border-input bg-background has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-ring/5 dark:bg-background relative flex w-full flex-col border px-1 pt-2 shadow-xs transition-[color,box-shadow] outline-none has-[textarea:focus-visible]:ring-1",t("xl")),children:[o.attachments&&m.jsx(p2,{}),m.jsx(L.ComposerPrimitive.Input,{placeholder:o.placeholder,className:T.cn("aui-composer-input placeholder:text-muted-foreground mb-1 max-h-32 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 outline-none focus-visible:ring-0",n("h-input"),n("text-base")),rows:1,autoFocus:!0,"aria-label":"Message input"}),m.jsx(w2,{})]})]})},_2=()=>{const{model:e,setModel:t}=T.useElements(),[n,o]=D.useState(!1),[r,i]=D.useState(!1),a=D.useRef(null),s=D.useRef(0),l=D.useRef(!1);D.useEffect(()=>{n&&!l.current&&requestAnimationFrame(()=>{const c=a.current;c&&c.scrollHeight>0&&(c.scrollTop=s.current)}),l.current=n},[n]),D.useEffect(()=>{n&&i(!1)},[n]);const u=c=>{s.current=c.currentTarget.scrollTop};return m.jsx(uS,{children:m.jsxs(ud,{open:r&&!n,onOpenChange:i,children:[m.jsxs(PS,{open:n,onOpenChange:o,children:[m.jsx(ld,{asChild:!0,children:m.jsx(CS,{asChild:!0,children:m.jsx($t,{variant:"ghost",size:"icon","data-state":n?"open":"closed",className:"aui-composer-model-picker data-[state=open]:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 flex w-fit items-center gap-2 rounded-full px-2.5 py-1 text-xs font-semibold","aria-label":"Model Settings",children:m.jsx(rI,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})})}),m.jsx(jS,{side:"top",align:"start",className:"w-min p-0 shadow-none",children:m.jsx("div",{ref:a,className:"max-h-48 overflow-y-auto",onScroll:u,children:Mu.map(c=>m.jsxs($t,{onClick:()=>{t(c)},variant:"ghost",className:"w-full justify-start gap-2 rounded-none px-2",children:[c===e?m.jsx("div",{children:m.jsx(rr,{className:"size-4 text-emerald-500"})}):m.jsx("div",{className:"size-4",children:" "}),c]},c))})})]}),m.jsx(cd,{side:"bottom",align:"start",children:"Model Settings"})]})})},w2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),n=e.composer??{attachments:!0};return m.jsxs("div",{className:"aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between",children:[m.jsxs("div",{className:"aui-composer-action-wrapper-inner flex items-center",children:[n.attachments?m.jsx(f2,{}):m.jsx("div",{className:"aui-composer-add-attachment-placeholder"}),e.model?.showModelPicker&&!e.languageModel&&m.jsx(_2,{})]}),m.jsx(L.ThreadPrimitive.If,{running:!1,children:m.jsx(L.ComposerPrimitive.Send,{asChild:!0,children:m.jsx(ct,{tooltip:"Send message",side:"bottom",type:"submit",variant:"default",size:"icon",className:T.cn("aui-composer-send size-[34px] p-1",t("full")),"aria-label":"Send message",children:m.jsx(E0,{className:"aui-composer-send-icon size-5"})})})}),m.jsx(L.ThreadPrimitive.If,{running:!0,children:m.jsx(L.ComposerPrimitive.Cancel,{asChild:!0,children:m.jsx($t,{type:"button",variant:"default",size:"icon",className:T.cn("aui-composer-cancel border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90 size-[34px] border",t("full")),"aria-label":"Stop generating",children:m.jsx(oI,{className:"aui-composer-cancel-icon size-3.5 fill-white dark:fill-black"})})})})]})},x2=()=>m.jsx(L.MessagePrimitive.Error,{children:m.jsx(L.ErrorPrimitive.Root,{className:"aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200",children:m.jsx(L.ErrorPrimitive.Message,{className:"aui-message-error-message line-clamp-2"})})}),$2=()=>{const{config:e}=T.useElements(),t=e.tools??{},n=e.components??{};return m.jsx(L.MessagePrimitive.Root,{asChild:!0,children:m.jsxs("div",{className:"aui-assistant-message-root animate-in fade-in slide-in-from-bottom-1 relative mx-auto w-full py-4 duration-150 ease-out last:mb-24","data-role":"assistant",children:[m.jsxs("div",{className:"aui-assistant-message-content text-foreground mx-2 leading-7 wrap-break-word",children:[m.jsx(L.MessagePrimitive.Parts,{components:{Text:n.Text??lS,Image:n.Image??S2,tools:{by_name:t.components,Fallback:n.ToolFallback??d6},Reasoning:n.Reasoning??qS,ReasoningGroup:n.ReasoningGroup??VS,ToolGroup:n.ToolGroup??h2}}),m.jsx(x2,{})]}),m.jsxs("div",{className:"aui-assistant-message-footer mt-2 ml-2 flex",children:[m.jsx(m0,{}),m.jsx(I2,{})]})]})})},S2=e=>m.jsx("img",{src:e.image}),I2=()=>m.jsxs(L.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",autohideFloat:"single-branch",className:"aui-assistant-action-bar-root text-muted-foreground data-floating:bg-background col-start-3 row-start-2 -ml-1 flex gap-1 data-floating:absolute data-floating:rounded-md data-floating:border data-floating:p-1 data-floating:shadow-sm",children:[m.jsx(L.ActionBarPrimitive.Copy,{asChild:!0,children:m.jsxs(ct,{tooltip:"Copy",children:[m.jsx(L.MessagePrimitive.If,{copied:!0,children:m.jsx(rr,{})}),m.jsx(L.MessagePrimitive.If,{copied:!1,children:m.jsx(Du,{})})]})}),m.jsx(L.ActionBarPrimitive.Reload,{asChild:!0,children:m.jsx(ct,{tooltip:"Refresh",children:m.jsx(eI,{})})})]}),k2=()=>{const e=T.useRadius();return m.jsx(L.MessagePrimitive.Root,{asChild:!0,children:m.jsxs("div",{className:"aui-user-message-root animate-in fade-in slide-in-from-bottom-1 mx-auto grid w-full auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 px-2 py-4 duration-150 ease-out first:mt-3 last:mb-5 [&:where(>*)]:col-start-2","data-role":"user",children:[m.jsx(d2,{}),m.jsxs("div",{className:"aui-user-message-content-wrapper relative col-start-2 min-w-0",children:[m.jsx("div",{className:T.cn("aui-user-message-content bg-muted text-foreground px-5 py-2.5 wrap-break-word",e("xl")),children:m.jsx(L.MessagePrimitive.Parts,{})}),m.jsx("div",{className:"aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2",children:m.jsx(E2,{})})]}),m.jsx(m0,{className:"aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end"})]})})},E2=()=>m.jsx(L.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",className:"aui-user-action-bar-root flex flex-col items-end",children:m.jsx(L.ActionBarPrimitive.Edit,{asChild:!0,children:m.jsx(ct,{tooltip:"Edit",className:"aui-user-action-edit p-4",children:m.jsx(K0,{})})})}),T2=()=>m.jsx("div",{className:"aui-edit-composer-wrapper mx-auto flex w-full flex-col gap-4 px-2 first:mt-4",children:m.jsxs(L.ComposerPrimitive.Root,{className:"aui-edit-composer-root bg-muted ml-auto flex w-full max-w-7/8 flex-col rounded-xl",children:[m.jsx(L.ComposerPrimitive.Input,{className:"aui-edit-composer-input text-foreground flex min-h-[60px] w-full resize-none bg-transparent p-4 outline-none",autoFocus:!0}),m.jsxs("div",{className:"aui-edit-composer-footer mx-3 mb-3 flex items-center justify-center gap-2 self-end",children:[m.jsx(L.ComposerPrimitive.Cancel,{asChild:!0,children:m.jsx($t,{variant:"ghost",size:"sm","aria-label":"Cancel edit",children:"Cancel"})}),m.jsx(L.ComposerPrimitive.Send,{asChild:!0,children:m.jsx($t,{size:"sm","aria-label":"Update message",children:"Update"})})]})]})}),m0=({className:e,...t})=>m.jsxs(L.BranchPickerPrimitive.Root,{hideWhenSingleBranch:!0,className:T.cn("aui-branch-picker-root text-muted-foreground mr-2 -ml-2 inline-flex items-center text-xs",e),...t,children:[m.jsx(L.BranchPickerPrimitive.Previous,{asChild:!0,children:m.jsx(ct,{tooltip:"Previous",children:m.jsx(j0,{})})}),m.jsxs("span",{className:"aui-branch-picker-state font-medium",children:[m.jsx(L.BranchPickerPrimitive.Number,{})," / ",m.jsx(L.BranchPickerPrimitive.Count,{})]}),m.jsx(L.BranchPickerPrimitive.Next,{asChild:!0,children:m.jsx(ct,{tooltip:"Next",children:m.jsx(um,{})})})]}),h0=()=>{const{config:e,isExpanded:t,setIsExpanded:n}=T.useElements(),o=e.modal?.defaultExpanded??!1;return{expandable:e.modal?.expandable??!1,isExpanded:t,setIsExpanded:n,defaultExpanded:o}},O2={layout:{duration:.25,ease:or}},N2=()=>{const{config:e}=T.useElements(),t=xd(),n=T.useRadius(),o=T.useDensity(),[r,i]=D.useState(e.modal?.defaultOpen??!1),{expandable:a,isExpanded:s,setIsExpanded:l}=h0(),u=e.modal?.title,c=e.modal?.icon,d=e.modal?.position??"bottom-right",f=P2(d),p=D.useMemo(()=>e.modal?.dimensions?.default??{width:"500px",height:"600px",maxHeight:"95vh"},[e.modal?.dimensions?.default]),g=D.useMemo(()=>e.modal?.dimensions?.expanded??{width:"70vw",height:"90vh"},[e.modal?.dimensions?.expanded]),b=L.useAssistantState(({thread:v})=>v).messages.some(v=>v.status?.type==="running"),y=s?g.width:p.width,x=s?g.height:p.height,$=p.maxHeight;return m.jsx(Zt.LazyMotion,{features:Zt.domMax,children:m.jsx(Zt.MotionConfig,{reducedMotion:"user",transition:O2,children:m.jsx("div",{className:T.cn("aui-root aui-modal-anchor fixed z-10",f,t.className,n("lg"),r&&"shadow-xl"),children:m.jsx(Zt.AnimatePresence,{mode:"wait",children:r?m.jsxs(Lt.div,{layout:!0,layoutId:"chat-container",className:T.cn("aui-modal-content bg-popover text-popover-foreground flex flex-col overflow-hidden border [&>.aui-thread-root]:bg-inherit",n("lg")),initial:!1,style:{originX:d.includes("left")?0:1,originY:d.includes("top")?0:1,width:y,height:x,maxHeight:$},children:[m.jsxs(Lt.div,{className:T.cn("aui-modal-header flex shrink-0 items-center justify-between border-b",o("h-header"),o("px-lg")),initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1,ease:or},children:[m.jsx("div",{className:T.cn("flex min-w-0 items-center"),children:m.jsxs("span",{className:T.cn("text-md flex items-center gap-2 truncate font-medium",b&&"shimmer"),children:[m.jsx("span",{className:"truncate",children:u}),b&&m.jsx(Hs,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]})}),m.jsxs("div",{className:"flex flex-row items-center justify-end gap-1",children:[a?m.jsx("button",{type:"button",onClick:()=>l(v=>!v),className:T.cn("text-muted-foreground hover:text-foreground hover:bg-accent flex h-8 cursor-pointer items-center rounded-md px-2 text-xs transition-colors"),"aria-pressed":s,"aria-label":s?"Collapse assistant":"Expand assistant",children:s?m.jsx(V0,{strokeWidth:2,className:"size-3.5 rotate-90"}):m.jsx(L0,{strokeWidth:2,className:"size-3.5 rotate-90"})}):null,m.jsx("button",{onClick:()=>{i(!1),l(!1)},className:"text-muted-foreground hover:text-foreground hover:bg-accent -mr-1 flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors","aria-label":`Close ${u}`,children:m.jsx(Xn,{className:"size-4.5"})})]})]}),m.jsx(Lt.div,{className:"aui-modal-thread w-full flex-1 overflow-hidden",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.05,ease:or},children:m.jsx($d,{})})]},"chat"):m.jsx(Lt.button,{layout:!0,layoutId:"chat-container",onClick:()=>i(!0),className:T.cn("aui-modal-button bg-primary text-primary-foreground flex size-12 cursor-pointer items-center justify-center border shadow-lg transition-shadow hover:shadow-xl",n("full")),initial:!1,"aria-label":`Open ${u}`,style:{originX:1,originY:1},children:m.jsx(Lt.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2,ease:or},className:"flex size-full items-center justify-center",children:c?c("closed"):m.jsx(F0,{className:"size-6"})})},"button")})})})})};function P2(e){switch(e){case"bottom-left":return"left-4 bottom-4";case"top-right":return"right-4 top-4";case"top-left":return"left-4 top-4";case"bottom-right":return"right-4 bottom-4";default:T.assertNever(e)}}const C2=()=>{const{config:e}=T.useElements(),t=xd(),n=e.sidecar??{},{title:o,dimensions:r}=n,{isExpanded:i,setIsExpanded:a}=h0(),l=L.useAssistantState(({thread:u})=>u).messages.some(u=>u.status?.type==="running");return m.jsx(Zt.LazyMotion,{features:Zt.domMax,children:m.jsxs(Lt.div,{initial:{width:r?.default?.width??"400px",height:r?.default?.height??"100vh"},animate:{width:i?r?.expanded?.width??"800px":r?.default?.width??"400px",height:i?r?.expanded?.height??"100%":r?.default?.height??"100vh"},transition:{duration:.3,ease:or},className:T.cn("aui-root aui-sidecar bg-popover text-popover-foreground fixed top-0 right-0 border-l",t.className),children:[m.jsxs("div",{className:"aui-sidecar-header flex h-14 items-center justify-between border-b px-4",children:[m.jsx("span",{className:T.cn("flex items-center gap-2 text-sm font-medium",l&&"shimmer"),children:o}),m.jsx("div",{className:"aui-sidecar-header-actions flex items-center gap-1",children:m.jsx(ct,{tooltip:i?"Collapse":"Pop out",variant:"ghost",className:"aui-sidecar-popout size-8",onClick:()=>a(u=>!u),children:i?m.jsx(J0,{className:"size-4.5"}):m.jsx(H0,{className:"size-4.5"})})})]}),m.jsx("div",{className:"aui-sidecar-content h-[calc(100%-3.5rem)] overflow-hidden",children:m.jsx($d,{})})]})})},j2=()=>{const{config:e}=T.useElements();switch(e.variant){case"standalone":return m.jsx($d,{});case"sidecar":return m.jsx(C2,{});case"widget":return m.jsx(N2,{});default:T.assertNever(e.variant)}};exports.useGramElements=T.useElements;exports.Chat=j2;exports.GramElementsProvider=bM;exports.MODELS=Mu;exports.defineFrontendTool=fR;
|