@gram-ai/elements 1.18.1 → 1.18.3
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/ui/button.d.ts +1 -1
- package/dist/components/ui/buttonVariants.d.ts +1 -1
- package/dist/contexts/ElementsProvider.d.ts +6 -1
- package/dist/elements.cjs +50 -50
- package/dist/elements.css +1 -1
- package/dist/elements.js +18734 -18699
- package/dist/hooks/useAuth.d.ts +16 -0
- package/dist/hooks/useMCPTools.d.ts +3 -4
- package/dist/hooks/useSession.d.ts +1 -1
- package/dist/index-Bj7jPiuy.cjs +16 -0
- package/dist/{index-1qi_Rje5.js → index-CJRypLIa.js} +210 -210
- package/dist/index.d.ts +1 -1
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.js +1 -1
- package/dist/types/index.d.ts +40 -32
- package/package.json +1 -1
- package/dist/index-DY3aJC4I.cjs +0 -16
package/dist/elements.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),T=require("./index-
|
|
2
|
-
Error message: ${sn(
|
|
3
|
-
Error message: ${sn(
|
|
4
|
-
`;break;case"id":s=b.includes("\0")?void 0:b;break;case"retry":/^\d+$/.test(b)?o(parseInt(b,10)):
|
|
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
|
|
6
|
-
`,o);let a=-1;if(
|
|
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
|
-
`).filter(a=>a),
|
|
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(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),T=require("./index-Bj7jPiuy.cjs"),D=require("react"),L=require("@assistant-ui/react"),Zt=require("motion/react"),y0=require("motion/react-m"),b0=require("zustand/shallow"),am=require("react-dom"),Ws=require("@assistant-ui/react-markdown"),_0=require("remark-gfm"),w0=require("shiki");function zu(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const _=zu(D),Lt=zu(y0),sm=zu(am);function x0({tools:e}){return m.jsx(m.Fragment,{children:Object.entries(e).map(([,t])=>t({}))})}var um="vercel.ai.error",$0=Symbol.for(um),lm,S0=class cm extends Error{constructor({name:t,message:r,cause:o}){super(r),this[lm]=!0,this.name=t,this.cause=o}static isInstance(t){return cm.hasMarker(t,um)}static hasMarker(t,r){const o=Symbol.for(r);return t!=null&&typeof t=="object"&&o in t&&typeof t[o]=="boolean"&&t[o]===!0}};lm=$0;var Y=S0,dm="AI_APICallError",pm=`vercel.ai.error.${dm}`,I0=Symbol.for(pm),fm,Be=class extends Y{constructor({message:t,url:r,requestBodyValues:o,statusCode:n,responseHeaders:i,responseBody:a,cause:s,isRetryable:l=n!=null&&(n===408||n===409||n===429||n>=500),data:u}){super({name:dm,message:t,cause:s}),this[fm]=!0,this.url=r,this.requestBodyValues=o,this.statusCode=n,this.responseHeaders=i,this.responseBody=a,this.isRetryable=l,this.data=u}static isInstance(t){return Y.hasMarker(t,pm)}};fm=I0;var mm="AI_EmptyResponseBodyError",hm=`vercel.ai.error.${mm}`,k0=Symbol.for(hm),gm,E0=class extends Y{constructor({message:t="Empty response body"}={}){super({name:mm,message:t}),this[gm]=!0}static isInstance(t){return Y.hasMarker(t,hm)}};gm=k0;function sn(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var vm="AI_InvalidArgumentError",ym=`vercel.ai.error.${vm}`,T0=Symbol.for(ym),bm,Vi=class extends Y{constructor({message:t,cause:r,argument:o}){super({name:vm,message:t,cause:r}),this[bm]=!0,this.argument=o}static isInstance(t){return Y.hasMarker(t,ym)}};bm=T0;var _m="AI_InvalidPromptError",wm=`vercel.ai.error.${_m}`,O0=Symbol.for(wm),xm,jr=class extends Y{constructor({prompt:t,message:r,cause:o}){super({name:_m,message:`Invalid prompt: ${r}`,cause:o}),this[xm]=!0,this.prompt=t}static isInstance(t){return Y.hasMarker(t,wm)}};xm=O0;var $m="AI_JSONParseError",Sm=`vercel.ai.error.${$m}`,N0=Symbol.for(Sm),Im,Jr=class extends Y{constructor({text:t,cause:r}){super({name:$m,message:`JSON parsing failed: Text: ${t}.
|
|
2
|
+
Error message: ${sn(r)}`,cause:r}),this[Im]=!0,this.text=t}static isInstance(t){return Y.hasMarker(t,Sm)}};Im=N0;var km="AI_NoSuchModelError",Em=`vercel.ai.error.${km}`,P0=Symbol.for(Em),Tm,C0=class extends Y{constructor({errorName:e=km,modelId:t,modelType:r,message:o=`No such ${r}: ${t}`}){super({name:e,message:o}),this[Tm]=!0,this.modelId=t,this.modelType=r}static isInstance(e){return Y.hasMarker(e,Em)}};Tm=P0;var Om="AI_TypeValidationError",Nm=`vercel.ai.error.${Om}`,j0=Symbol.for(Nm),Pm,A0=class Hs extends Y{constructor({value:t,cause:r}){super({name:Om,message:`Type validation failed: Value: ${JSON.stringify(t)}.
|
|
3
|
+
Error message: ${sn(r)}`,cause:r}),this[Pm]=!0,this.value=t}static isInstance(t){return Y.hasMarker(t,Nm)}static wrap({value:t,cause:r}){return Hs.isInstance(r)&&r.value===t?r:new Hs({value:t,cause:r})}};Pm=j0;var Ft=A0;let Ad=class extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}};function hs(e){}function R0(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:r=hs,onRetry:o=hs,onComment:n}=e;let i="",a=!0,s,l="",u="";function c(h){const b=a?h.replace(/^\xEF\xBB\xBF/,""):h,[y,x]=z0(`${i}${b}`);for(const $ of y)d($);i=x,a=!1}function d(h){if(h===""){p();return}if(h.startsWith(":")){n&&n(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)):r(new Ad(`Invalid \`retry\` value: "${b}"`,{type:"invalid-retry",value:b,line:y}));break;default:r(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 z0(e){const t=[];let r="",o=0;for(;o<e.length;){const n=e.indexOf("\r",o),i=e.indexOf(`
|
|
6
|
+
`,o);let a=-1;if(n!==-1&&i!==-1?a=Math.min(n,i):n!==-1?n===e.length-1?a=-1:a=n:i!==-1&&(a=i),a===-1){r=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,r]}let Pn=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:o}={}){let n;super({start(i){n=R0({onEvent:a=>{i.enqueue(a)},onError(a){t==="terminate"?i.error(a):typeof t=="function"&&t(a)},onRetry:r,onComment:o})},transform(i){n.feed(i)}})}};const Mu=Object.freeze({status:"aborted"});function S(e,t,r){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 n=r?.Parent??Object;class i extends n{}Object.defineProperty(i,"name",{value:e});function a(s){var l;const u=r?.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=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}const Cm=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 li={};function De(e){return e&&Object.assign(li,e),li}function M0(e){return e}function D0(e){return e}function U0(e){}function L0(e){throw new Error("Unexpected value in exhaustive check")}function Z0(e){}function Du(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function j(e,t="|"){return e.map(r=>H(r)).join(t)}function ci(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 Er(e){return e==null}function Ji(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function jm(e,t){const r=(e.toString().split(".")[1]||"").length,o=t.toString();let n=(o.split(".")[1]||"").length;if(n===0&&/\d?e-\d?/.test(o)){const l=o.match(/\d?e-(\d?)/);l?.[1]&&(n=Number.parseInt(l[1]))}const i=r>n?r:n,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,r){let o;Object.defineProperty(e,t,{get(){if(o!==Rd)return o===void 0&&(o=Rd,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function F0(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function cr(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Wt(...e){const t={};for(const r of e){const o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function q0(e){return Wt(e._zod.def)}function V0(e,t){return t?t.reduce((r,o)=>r?.[o],e):e}function B0(e){const t=Object.keys(e),r=t.map(o=>e[o]);return Promise.all(r).then(o=>{const n={};for(let i=0;i<t.length;i++)n[t[i]]=o[i];return n})}function J0(e=10){const t="abcdefghijklmnopqrstuvwxyz";let r="";for(let o=0;o<e;o++)r+=t[Math.floor(Math.random()*t.length)];return r}function Gs(e){return JSON.stringify(e)}function Am(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Uu="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Wr(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 yr(e){if(Wr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Wr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Wi(e){return yr(e)?{...e}:Array.isArray(e)?[...e]:e}function W0(e){let t=0;for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}const H0=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}`)}},di=new Set(["string","number","symbol"]),zm=new Set(["string","number","bigint","boolean","symbol","undefined"]);function qt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dt(e,t,r){const o=new e._zod.constr(t??e._zod.def);return(!t||r?.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 G0(e){let t;return new Proxy({},{get(r,o,n){return t??(t=e()),Reflect.get(t,o,n)},set(r,o,n,i){return t??(t=e()),Reflect.set(t,o,n,i)},has(r,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(r,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(r,o,n){return t??(t=e()),Reflect.defineProperty(t,o,n)}})}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 r=e._zod.def,o=Wt(e._zod.def,{get shape(){const n={};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(n[i]=r.shape[i])}return cr(this,"shape",n),n},checks:[]});return dt(e,o)}function Zm(e,t){const r=e._zod.def,o=Wt(e._zod.def,{get shape(){const n={...e._zod.def.shape};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete n[i]}return cr(this,"shape",n),n},checks:[]});return dt(e,o)}function Fm(e,t){if(!yr(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const n=Wt(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return cr(this,"shape",i),i},checks:[]});return dt(e,n)}function qm(e,t){if(!yr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r={...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,r)}function Vm(e,t){const r=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,r)}function Bm(e,t,r){const o=Wt(t._zod.def,{get shape(){const n=t._zod.def.shape,i={...n};if(r)for(const a in r){if(!(a in n))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=e?new e({type:"optional",innerType:n[a]}):n[a])}else for(const a in n)i[a]=e?new e({type:"optional",innerType:n[a]}):n[a];return cr(this,"shape",i),i},checks:[]});return dt(t,o)}function Jm(e,t,r){const o=Wt(t._zod.def,{get shape(){const n=t._zod.def.shape,i={...n};if(r)for(const a in r){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=new e({type:"nonoptional",innerType:n[a]}))}else for(const a in n)i[a]=new e({type:"nonoptional",innerType:n[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 r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function _t(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function $n(e){return typeof e=="string"?e:e?.message}function ut(e,t,r){const o={...e,path:e.path??[]};if(!e.message){const n=$n(e.inst?._zod.def?.error?.(e))??$n(t?.error?.(e))??$n(r.customError?.(e))??$n(r.localeError?.(e))??"Invalid input";o.message=n}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,r,o]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:o}:{...t}}function K0(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Wm(e){const t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}function Hm(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Y0(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Wm(t+r)}function Q0(e){return Hm(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function X0(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const r=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)r[o/2]=Number.parseInt(t.slice(o,o+2),16);return r}function eI(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class tI{constructor(...t){}}const Gm=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:Um,Class:tI,NUMBER_FORMAT_RANGES:Dm,aborted:mr,allowsEval:Rm,assert:Z0,assertEqual:M0,assertIs:U0,assertNever:L0,assertNotEqual:D0,assignProp:cr,base64ToUint8Array:Wm,base64urlToUint8Array:Y0,cached:Xn,captureStackTrace:Uu,cleanEnum:K0,cleanRegex:Ji,clone:dt,cloneDef:q0,createTransparentProxy:G0,defineLazy:ne,esc:Gs,escapeRegex:qt,extend:Fm,finalizeIssue:ut,floatSafeRemainder:jm,getElementAtPath:V0,getEnumValues:Du,getLengthableOrigin:Gi,getParsedType:H0,getSizableOrigin:Hi,hexToUint8Array:X0,isObject:Wr,isPlainObject:yr,issue:Hr,joinValues:j,jsonStringifyReplacer:ci,merge:Vm,mergeDefs:Wt,normalizeParams:P,nullish:Er,numKeys:W0,objectClone:F0,omit:Zm,optionalKeys:Mm,partial:Bm,pick:Lm,prefixIssues:_t,primitiveTypes:zm,promiseAllObject:B0,propertyKeyTypes:di,randomString:J0,required:Jm,safeExtend:qm,shallowClone:Wi,slugify:Am,stringifyPrimitive:H,uint8ArrayToBase64:Hm,uint8ArrayToBase64url:Q0,uint8ArrayToHex:eI,unwrapMessage:$n},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,ci,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Lu=S("$ZodError",Km),nt=S("$ZodError",Km,{Parent:Error});function Zu(e,t=r=>r.message){const r={},o=[];for(const n of e.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):o.push(t(n));return{formErrors:o,fieldErrors:r}}function Fu(e,t=r=>r.message){const r={_errors:[]},o=n=>{for(const i of n.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)r._errors.push(t(i));else{let a=r,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),r}function Ym(e,t=r=>r.message){const r={errors:[]},o=(n,i=[])=>{var a,s;for(const l of n.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){r.errors.push(t(l));continue}let c=r,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),r}function Qm(e){const t=[],r=e.map(o=>typeof o=="object"?o.key:o);for(const o of r)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=[],r=[...e.issues].sort((o,n)=>(o.path??[]).length-(n.path??[]).length);for(const o of r)t.push(`✖ ${o.message}`),o.path?.length&&t.push(` → at ${Qm(o.path)}`);return t.join(`
|
|
8
|
+
`)}const eo=e=>(t,r,o,n)=>{const i=o?Object.assign(o,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new vr;if(a.issues.length){const s=new(n?.Err??e)(a.issues.map(l=>ut(l,i,De())));throw Uu(s,n?.callee),s}return a.value},Ks=eo(nt),to=e=>async(t,r,o,n)=>{const i=o?Object.assign(o,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const s=new(n?.Err??e)(a.issues.map(l=>ut(l,i,De())));throw Uu(s,n?.callee),s}return a.value},Ys=to(nt),ro=e=>(t,r,o)=>{const n=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new vr;return i.issues.length?{success:!1,error:new(e??Lu)(i.issues.map(a=>ut(a,n,De())))}:{success:!0,data:i.value}},eh=ro(nt),no=e=>async(t,r,o)=>{const n=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},n);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>ut(a,n,De())))}:{success:!0,data:i.value}},th=no(nt),qu=e=>(t,r,o)=>{const n=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return eo(e)(t,r,n)},rI=qu(nt),Vu=e=>(t,r,o)=>eo(e)(t,r,o),nI=Vu(nt),Bu=e=>async(t,r,o)=>{const n=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return to(e)(t,r,n)},oI=Bu(nt),Ju=e=>async(t,r,o)=>to(e)(t,r,o),iI=Ju(nt),Wu=e=>(t,r,o)=>{const n=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ro(e)(t,r,n)},aI=Wu(nt),Hu=e=>(t,r,o)=>ro(e)(t,r,o),sI=Hu(nt),Gu=e=>async(t,r,o)=>{const n=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return no(e)(t,r,n)},uI=Gu(nt),Ku=e=>async(t,r,o)=>no(e)(t,r,o),lI=Ku(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)?)?)$/,cI=/^[-+]?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})$/,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)$/,dI=Gr(4),pI=Gr(6),fI=Gr(7),ch=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,mI=/^[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])?)*$/,hI=/^(([^<>()\[\]\\.,;:\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,gI=dh,vI=/^[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])?)*$/,yI="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ph(){return new RegExp(yI,"u")}const fh=/^(?:(?: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=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}$`)},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}=))?$/,Yu=/^[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}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${r.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}$`)},Th=/^-?\d+n?$/,Oh=/^-?\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 bI=/^[0-9a-fA-F]{32}$/,_I=oo(22,"=="),wI=io(22),xI=/^[0-9a-fA-F]{40}$/,$I=oo(27,"="),SI=io(27),II=/^[0-9a-fA-F]{64}$/,kI=oo(43,"="),EI=io(43),TI=/^[0-9a-fA-F]{96}$/,OI=oo(64,""),NI=io(64),PI=/^[0-9a-fA-F]{128}$/,CI=oo(86,"=="),jI=io(86),Qu=Object.freeze(Object.defineProperty({__proto__:null,base64:yh,base64url:Yu,bigint:Th,boolean:Ph,browserEmail:vI,cidrv4:gh,cidrv6:vh,cuid:rh,cuid2:nh,date:$h,datetime:kh,domain:_h,duration:uh,e164:wh,email:ch,emoji:ph,extendedDuration:cI,guid:lh,hex:zh,hostname:bh,html5Email:mI,idnEmail:gI,integer:Oh,ipv4:fh,ipv6:mh,ksuid:ah,lowercase:Ah,mac:hh,md5_base64:_I,md5_base64url:wI,md5_hex:bI,nanoid:sh,null:Ch,number:Nh,rfc5322Email:hI,sha1_base64:$I,sha1_base64url:SI,sha1_hex:xI,sha256_base64:kI,sha256_base64url:EI,sha256_hex:II,sha384_base64:OI,sha384_base64url:NI,sha384_hex:TI,sha512_base64:CI,sha512_base64url:jI,sha512_hex:PI,string:Eh,time:Ih,ulid:oh,undefined:jh,unicodeEmail:dh,uppercase:Rh,uuid:Gr,uuid4:dI,uuid6:pI,uuid7:fI,xid:ih},Symbol.toStringTag,{value:"Module"})),Se=S("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Mh={number:"number",bigint:"bigint",object:"date"},Xu=S("$ZodCheckLessThan",(e,t)=>{Se.init(e,t);const r=Mh[typeof t.value];e._zod.onattach.push(o=>{const n=o._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:r,code:"too_big",maximum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),el=S("$ZodCheckGreaterThan",(e,t)=>{Se.init(e,t);const r=Mh[typeof t.value];e._zod.onattach.push(o=>{const n=o._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:r,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(r=>{var o;(o=r._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):jm(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Uh=S("$ZodCheckNumberFormat",(e,t)=>{Se.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),o=r?"int":"number",[n,i]=Dm[t.format];e._zod.onattach.push(a=>{const s=a._zod.bag;s.format=t.format,s.minimum=n,s.maximum=i,r&&(s.pattern=Oh)}),e._zod.check=a=>{const s=a.value;if(r){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<n&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:n,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[r,o]=Um[t.format];e._zod.onattach.push(n=>{const i=n._zod.bag;i.format=t.format,i.minimum=r,i.maximum=o}),e._zod.check=n=>{const i=n.value;i<r&&n.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>o&&n.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inst:e})}}),Zh=S("$ZodCheckMaxSize",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.size!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const n=o.value;n.size<=t.maximum||o.issues.push({origin:Hi(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Fh=S("$ZodCheckMinSize",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.size!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const n=o.value;n.size>=t.minimum||o.issues.push({origin:Hi(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),qh=S("$ZodCheckSizeEquals",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.size!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=o=>{const n=o.value,i=n.size;if(i===t.size)return;const a=i>t.size;o.issues.push({origin:Hi(n),...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 r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const n=o.value;if(n.length<=t.maximum)return;const a=Gi(n);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Bh=S("$ZodCheckMinLength",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const n=o.value;if(n.length>=t.minimum)return;const a=Gi(n);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Jh=S("$ZodCheckLengthEquals",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=o=>{const n=o.value,i=n.length;if(i===t.length)return;const a=Gi(n),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 r,o;Se.init(e,t),e._zod.onattach.push(n=>{const i=n._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.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=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.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 r=qt(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=o,e._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Yh=S("$ZodCheckStartsWith",(e,t)=>{Se.init(e,t);const r=new RegExp(`^${qt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{const n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),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 r=new RegExp(`.*${qt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{const n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),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,r){e.issues.length&&t.issues.push(..._t(r,e.issues))}const Xh=S("$ZodCheckProperty",(e,t)=>{Se.init(e,t),e._zod.check=r=>{const o=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(o instanceof Promise)return o.then(n=>zd(n,r,t.property));zd(o,r,t.property)}}),eg=S("$ZodCheckMimeType",(e,t)=>{Se.init(e,t);const r=new Set(t.mime);e._zod.onattach.push(o=>{o._zod.bag.mime=t.mime}),e._zod.check=o=>{r.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=r=>{r.value=t.tx(r.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(`
|
|
9
|
+
`).filter(a=>a),n=Math.min(...o.map(a=>a.length-a.trimStart().length)),i=o.map(a=>a.slice(n)).map(a=>" ".repeat(this.indent*2)+a);for(const a of i)this.content.push(a)}compile(){const t=Function,r=this?.args,n=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...r,n.join(`
|
|
10
|
+
`))}}const ng={major:4,minor:2,patch:1},X=S("$ZodType",(e,t)=>{var r;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 n of o)for(const i of n._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const n=(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=n(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=>n(u,o,s))}return n(l,o,s)}}e["~standard"]={validate:n=>{try{const i=eh(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return th(e,n).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=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ge=S("$ZodStringFormat",(e,t)=>{ao.init(e,t),so.init(e,t)}),og=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=lh),ge.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=Gr(o))}else t.pattern??(t.pattern=Gr());ge.init(e,t)}),ag=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ch),ge.init(e,t)}),sg=S("$ZodURL",(e,t)=>{ge.init(e,t),e._zod.check=r=>{try{const o=r.value.trim(),n=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(n.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=n.href:r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ug=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ph()),ge.init(e,t)}),lg=S("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=sh),ge.init(e,t)}),cg=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=rh),ge.init(e,t)}),dg=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=nh),ge.init(e,t)}),pg=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=oh),ge.init(e,t)}),fg=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ih),ge.init(e,t)}),mg=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ah),ge.init(e,t)}),hg=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=kh(t)),ge.init(e,t)}),gg=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=$h),ge.init(e,t)}),vg=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ih(t)),ge.init(e,t)}),yg=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=uh),ge.init(e,t)}),bg=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=fh),ge.init(e,t),e._zod.bag.format="ipv4"}),_g=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=mh),ge.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),wg=S("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=hh(t.delimiter)),ge.init(e,t),e._zod.bag.format="mac"}),xg=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=gh),ge.init(e,t)}),$g=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=vh),ge.init(e,t),e._zod.check=r=>{const o=r.value.split("/");try{if(o.length!==2)throw new Error;const[n,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://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function tl(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),ge.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{tl(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Ig(e){if(!Yu.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return tl(r)}const kg=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Yu),ge.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{Ig(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Eg=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=wh),ge.init(e,t)});function Tg(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[o]=r;if(!o)return!1;const n=JSON.parse(atob(o));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}const Og=S("$ZodJWT",(e,t)=>{ge.init(e,t),e._zod.check=r=>{Tg(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Ng=S("$ZodCustomStringFormat",(e,t)=>{ge.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),rl=S("$ZodNumber",(e,t)=>{X.init(e,t),e._zod.pattern=e._zod.bag.pattern??Nh,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const n=r.value;if(typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;const i=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),r}}),Pg=S("$ZodNumberFormat",(e,t)=>{Uh.init(e,t),rl.init(e,t)}),nl=S("$ZodBoolean",(e,t)=>{X.init(e,t),e._zod.pattern=Ph,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=!!r.value}catch{}const n=r.value;return typeof n=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),ol=S("$ZodBigInt",(e,t)=>{X.init(e,t),e._zod.pattern=Th,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),Cg=S("$ZodBigIntFormat",(e,t)=>{Lh.init(e,t),ol.init(e,t)}),jg=S("$ZodSymbol",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;return typeof n=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),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=(r,o)=>{const n=r.value;return typeof n>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),Rg=S("$ZodNull",(e,t)=>{X.init(e,t),e._zod.pattern=Ch,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{const n=r.value;return n===null||r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),zg=S("$ZodAny",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),Mg=S("$ZodUnknown",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),Dg=S("$ZodNever",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Ug=S("$ZodVoid",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;return typeof n>"u"||r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),Lg=S("$ZodDate",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}const n=r.value,i=n instanceof Date;return i&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...i?{received:"Invalid Date"}:{},inst:e}),r}});function Md(e,t,r){e.issues.length&&t.issues.push(..._t(r,e.issues)),t.value[r]=e.value}const Zg=S("$ZodArray",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);const i=[];for(let a=0;a<n.length;a++){const s=n[a],l=t.element._zod.run({value:s,issues:[]},o);l instanceof Promise?i.push(l.then(u=>Md(u,r,a))):Md(l,r,a)}return i.length?Promise.all(i).then(()=>r):r}});function pi(e,t,r,o){e.issues.length&&t.issues.push(..._t(r,e.issues)),e.value===void 0?r in o&&(t.value[r]=void 0):t.value[r]=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 r=Mm(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function qg(e,t,r,o,n,i){const a=[],s=n.keySet,l=n.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=>pi(f,r,c,t))):pi(d,r,c,t)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}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 n=Wr,i=t.catchall;let a;e._zod.parse=(s,l)=>{a??(a=o.value);const u=s.value;if(!n(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=>pi(h,s,f,u))):pi(g,s,f,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 r=e._zod.parse,o=Xn(()=>Fg(t)),n=f=>{const p=new rg(["shape","payload","ctx"]),g=o.value,h=$=>{const v=Gs($);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=Gs($);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: ${sn(n)}`,cause:n}),this[Cm]=!0,this.value=t}static isInstance(t)
|
|
|
24
24
|
newResult[${k}] = ${v}.value;
|
|
25
25
|
}
|
|
26
26
|
|
|
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>
|
|
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=!li.jitless,u=s&&Rm.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=n(t.shape)),f=i(f,p),c?qg([],g,f,p,d,e):f):r(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),f)}});function Dd(e,t,r,o){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const n=e.filter(i=>!mr(i));return n.length===1?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,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(n=>n._zod.optin==="optional")?"optional":void 0),ne(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),ne(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),ne(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${n.map(i=>Ji(i.source)).join("|")})$`)}});const r=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(n,i)=>{if(r)return o(n,i);let a=!1;const s=[];for(const l of t.options){const u=l._zod.run({value:n.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,n,e,i)):Dd(s,n,e,i)}});function Ud(e,t,r,o){const n=e.filter(i=>i.issues.length===0);return n.length===1?(t.value=n[0].value,t):(n.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>ut(a,o,De())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}const Jg=S("$ZodXor",(e,t)=>{Ki.init(e,t),t.inclusive=!1;const r=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(n,i)=>{if(r)return o(n,i);let a=!1;const s=[];for(const l of t.options){const u=l._zod.run({value:n.value,issues:[]},i);u instanceof Promise?(s.push(u),a=!0):s.push(u)}return a?Promise.all(s).then(l=>Ud(l,n,e,i)):Ud(s,n,e,i)}}),Wg=S("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ki.init(e,t);const r=e._zod.parse;ne(e._zod,"propValues",()=>{const n={};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)){n[s]||(n[s]=new Set);for(const u of l)n[s].add(u)}}return n});const o=Xn(()=>{const n=t.options,i=new Map;for(const a of n){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=(n,i)=>{const a=n.value;if(!Wr(a))return n.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),n;const s=o.value.get(a?.[t.discriminator]);return s?s._zod.run(n,i):t.unionFallback?r(n,i):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),n)}}),Hg=S("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value,i=t.left._zod.run({value:n,issues:[]},o),a=t.right._zod.run({value:n,issues:[]},o);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([l,u])=>Ld(r,l,u)):Ld(r,i,a)}});function Qs(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 r=Object.keys(t),o=Object.keys(e).filter(i=>r.indexOf(i)!==-1),n={...e,...t};for(const i of o){const a=Qs(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};n[i]=a.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let o=0;o<e.length;o++){const n=e[o],i=t[o],a=Qs(n,i);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Ld(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),mr(e))return e;const o=Qs(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const il=S("$ZodTuple",(e,t)=>{X.init(e,t);const r=t.items;e._zod.parse=(o,n)=>{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=[...r].reverse().findIndex(c=>c._zod.optin!=="optional"),l=s===-1?0:r.length-s;if(!t.rest){const c=i.length>r.length,d=i.length<l-1;if(c||d)return o.issues.push({...c?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},input:i,inst:e,origin:"array"}),o}let u=-1;for(const c of r){if(u++,u>=i.length&&u>=l)continue;const d=c._zod.run({value:i[u],issues:[]},n);d instanceof Promise?a.push(d.then(f=>Uo(f,o,u))):Uo(d,o,u)}if(t.rest){const c=i.slice(r.length);for(const d of c){u++;const f=t.rest._zod.run({value:d,issues:[]},n);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,r){e.issues.length&&t.issues.push(..._t(r,e.issues)),t.value[r]=e.value}const Gg=S("$ZodRecord",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;if(!yr(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;const i=[],a=t.keyType._zod.values;if(a){r.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:n[u],issues:[]},o);c instanceof Promise?i.push(c.then(d=>{d.issues.length&&r.issues.push(..._t(u,d.issues)),r.value[u]=d.value})):(c.issues.length&&r.issues.push(..._t(u,c.issues)),r.value[u]=c.value)}let l;for(const u in n)s.has(u)||(l=l??[],l.push(u));l&&l.length>0&&r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:l})}else{r.value={};for(const s of Reflect.ownKeys(n)){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"?r.value[s]=n[s]:r.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:n[s],issues:[]},o);u instanceof Promise?i.push(u.then(c=>{c.issues.length&&r.issues.push(..._t(s,c.issues)),r.value[l.value]=c.value})):(u.issues.length&&r.issues.push(..._t(s,u.issues)),r.value[l.value]=u.value)}}return i.length?Promise.all(i).then(()=>r):r}}),Kg=S("$ZodMap",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;if(!(n instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),r;const i=[];r.value=new Map;for(const[a,s]of n){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,r,a,n,e,o)})):Zd(l,u,r,a,n,e,o)}return i.length?Promise.all(i).then(()=>r):r}});function Zd(e,t,r,o,n,i,a){e.issues.length&&(di.has(typeof o)?r.issues.push(..._t(o,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:n,inst:i,issues:e.issues.map(s=>ut(s,a,De()))})),t.issues.length&&(di.has(typeof o)?r.issues.push(..._t(o,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:n,inst:i,key:o,issues:t.issues.map(s=>ut(s,a,De()))})),r.value.set(e.value,t.value)}const Yg=S("$ZodSet",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;if(!(n instanceof Set))return r.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),r;const i=[];r.value=new Set;for(const a of n){const s=t.valueType._zod.run({value:a,issues:[]},o);s instanceof Promise?i.push(s.then(l=>Fd(l,r))):Fd(s,r)}return i.length?Promise.all(i).then(()=>r):r}});function Fd(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 r=Du(t.entries),o=new Set(r);e._zod.values=o,e._zod.pattern=new RegExp(`^(${r.filter(n=>di.has(typeof n)).map(n=>typeof n=="string"?qt(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{const a=n.value;return o.has(a)||n.issues.push({code:"invalid_value",values:r,input:a,inst:e}),n}}),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 r=new Set(t.values);e._zod.values=r,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,n)=>{const i=o.value;return r.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=(r,o)=>{const n=r.value;return n instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),tv=S("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Bi(e.constructor.name);const n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then(a=>(r.value=a,r));if(n instanceof Promise)throw new vr;return r.value=n,r}});function qd(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 r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ji(r.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(t.innerType._zod.optin==="optional"){const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>qd(i,r.value)):qd(n,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,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 r=t.innerType._zod.pattern;return r?new RegExp(`^(${Ji(r.source)}|null)$`):void 0}),ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>r.value===null?r:t.innerType._zod.run(r,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=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>Vd(i,t)):Vd(n,t)}});function Vd(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=(r,o)=>(o.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,o))}),av=S("$ZodNonOptional",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,o)=>{const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>Bd(i,e)):Bd(n,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 sv=S("$ZodSuccess",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Bi("ZodSuccess");const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>(r.value=i.issues.length===0,r)):(r.value=n.issues.length===0,r)}}),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=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(a=>ut(a,o,De()))},input:r.value}),r.issues=[]),r)):(r.value=n.value,n.issues.length&&(r.value=t.catchValue({...r,error:{issues:n.issues.map(i=>ut(i,o,De()))},input:r.value}),r.issues=[]),r)}}),lv=S("$ZodNaN",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),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=(r,o)=>{if(o.direction==="backward"){const i=t.out._zod.run(r,o);return i instanceof Promise?i.then(a=>Lo(a,t.in,o)):Lo(i,t.in,o)}const n=t.in._zod.run(r,o);return n instanceof Promise?n.then(i=>Lo(i,t.out,o)):Lo(n,t.out,o)}});function Lo(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const al=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=(r,o)=>{if((o.direction||"forward")==="forward"){const i=t.in._zod.run(r,o);return i instanceof Promise?i.then(a=>Zo(a,t,o)):Zo(i,t,o)}else{const i=t.out._zod.run(r,o);return i instanceof Promise?i.then(a=>Zo(a,t,o)):Zo(i,t,o)}}});function Zo(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){const n=t.transform(e.value,e);return n instanceof Promise?n.then(i=>Fo(e,i,t.out,r)):Fo(e,n,t.out,r)}else{const n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(i=>Fo(e,i,t.in,r)):Fo(e,n,t.in,r)}}function Fo(e,t,r,o){return e.issues.length?(e.aborted=!0,e):r._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=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(Jd):Jd(n)}});function Jd(e){return e.value=Object.freeze(e.value),e}const pv=S("$ZodTemplateLiteral",(e,t)=>{X.init(e,t);const r=[];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 n=o._zod.pattern instanceof RegExp?o._zod.pattern.source:o._zod.pattern;if(!n)throw new Error(`Invalid template literal part: ${o._zod.traits}`);const i=n.startsWith("^")?1:0,a=n.endsWith("$")?n.length-1:n.length;r.push(n.slice(i,a))}else if(o===null||zm.has(typeof o))r.push(qt(`${o}`));else throw new Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(o,n)=>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)}),fv=S("$ZodFunction",(e,t)=>(X.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...o){const n=e._def.input?Ks(e._def.input,o):o,i=Reflect.apply(r,this,n);return e._def.output?Ks(e._def.output,i):i}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...o){const n=e._def.input?await Ys(e._def.input,o):o,i=await Reflect.apply(r,this,n);return e._def.output?await Ys(e._def.output,i):i}},e._zod.parse=(r,o)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{const o=e.constructor;return Array.isArray(r[0])?new o({type:"function",input:new il({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new o({type:"function",input:r[0],output:e._def.output})},e.output=r=>{const o=e.constructor;return new o({type:"function",input:e._def.input,output:r})},e)),mv=S("$ZodPromise",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>Promise.resolve(r.value).then(n=>t.innerType._zod.run({value:n,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=(r,o)=>e._zod.innerType._zod.run(r,o)}),gv=S("$ZodCustom",(e,t)=>{Se.init(e,t),X.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=r=>{const o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then(i=>Wd(i,r,o,e));Wd(n,r,o,e)}});function Wd(e,t,r,o){if(!e){const n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(n.params=o._zod.def.params),t.issues.push(Hr(n))}}const AI=()=>{const e={string:{unit:"حرف",verb:"أن يحوي"},file:{unit:"بايت",verb:"أن يحوي"},array:{unit:"عنصر",verb:"أن يحوي"},set:{unit:"عنصر",verb:"أن يحوي"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`مدخلات غير مقبولة: يفترض إدخال ${n.expected}، ولكن تم إدخال ${r(n.input)}`;case"invalid_value":return n.values.length===1?`مدخلات غير مقبولة: يفترض إدخال ${H(n.values[0])}`:`اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?` أكبر من اللازم: يفترض أن تكون ${n.origin??"القيمة"} ${i} ${n.maximum.toString()} ${a.unit??"عنصر"}`:`أكبر من اللازم: يفترض أن تكون ${n.origin??"القيمة"} ${i} ${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`أصغر من اللازم: يفترض لـ ${n.origin} أن يكون ${i} ${n.minimum.toString()} ${a.unit}`:`أصغر من اللازم: يفترض لـ ${n.origin} أن يكون ${i} ${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`نَص غير مقبول: يجب أن يبدأ بـ "${n.prefix}"`:i.format==="ends_with"?`نَص غير مقبول: يجب أن ينتهي بـ "${i.suffix}"`:i.format==="includes"?`نَص غير مقبول: يجب أن يتضمَّن "${i.includes}"`:i.format==="regex"?`نَص غير مقبول: يجب أن يطابق النمط ${i.pattern}`:`${o[i.format]??n.format} غير مقبول`}case"not_multiple_of":return`رقم غير مقبول: يجب أن يكون من مضاعفات ${n.divisor}`;case"unrecognized_keys":return`معرف${n.keys.length>1?"ات":""} غريب${n.keys.length>1?"ة":""}: ${j(n.keys,"، ")}`;case"invalid_key":return`معرف غير مقبول في ${n.origin}`;case"invalid_union":return"مدخل غير مقبول";case"invalid_element":return`مدخل غير مقبول في ${n.origin}`;default:return"مدخل غير مقبول"}}};function RI(){return{localeError:AI()}}const zI=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Yanlış dəyər: gözlənilən ${n.expected}, daxil olan ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Yanlış dəyər: gözlənilən ${H(n.values[0])}`:`Yanlış seçim: aşağıdakılardan biri olmalıdır: ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Çox böyük: gözlənilən ${n.origin??"dəyər"} ${i}${n.maximum.toString()} ${a.unit??"element"}`:`Çox böyük: gözlənilən ${n.origin??"dəyər"} ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Çox kiçik: gözlənilən ${n.origin} ${i}${n.minimum.toString()} ${a.unit}`:`Çox kiçik: gözlənilən ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Yanlış ədəd: ${n.divisor} ilə bölünə bilən olmalıdır`;case"unrecognized_keys":return`Tanınmayan açar${n.keys.length>1?"lar":""}: ${j(n.keys,", ")}`;case"invalid_key":return`${n.origin} daxilində yanlış açar`;case"invalid_union":return"Yanlış dəyər";case"invalid_element":return`${n.origin} daxilində yanlış dəyər`;default:return"Yanlış dəyər"}}};function MI(){return{localeError:zI()}}function Hd(e,t,r,o){const n=Math.abs(e),i=n%10,a=n%100;return a>=11&&a<=19?o:i===1?t:i>=2&&i<=4?r:o}const DI=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"лік";case"object":{if(Array.isArray(n))return"масіў";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Няправільны ўвод: чакаўся ${n.expected}, атрымана ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Няправільны ўвод: чакалася ${H(n.values[0])}`:`Няправільны варыянт: чакаўся адзін з ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);if(a){const s=Number(n.maximum),l=Hd(s,a.unit.one,a.unit.few,a.unit.many);return`Занадта вялікі: чакалася, што ${n.origin??"значэнне"} павінна ${a.verb} ${i}${n.maximum.toString()} ${l}`}return`Занадта вялікі: чакалася, што ${n.origin??"значэнне"} павінна быць ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);if(a){const s=Number(n.minimum),l=Hd(s,a.unit.one,a.unit.few,a.unit.many);return`Занадта малы: чакалася, што ${n.origin} павінна ${a.verb} ${i}${n.minimum.toString()} ${l}`}return`Занадта малы: чакалася, што ${n.origin} павінна быць ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Няправільны лік: павінен быць кратным ${n.divisor}`;case"unrecognized_keys":return`Нераспазнаны ${n.keys.length>1?"ключы":"ключ"}: ${j(n.keys,", ")}`;case"invalid_key":return`Няправільны ключ у ${n.origin}`;case"invalid_union":return"Няправільны ўвод";case"invalid_element":return`Няправільнае значэнне ў ${n.origin}`;default:return"Няправільны ўвод"}}};function UI(){return{localeError:DI()}}const LI=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},ZI=()=>{const e={string:{unit:"символа",verb:"да съдържа"},file:{unit:"байта",verb:"да съдържа"},array:{unit:"елемента",verb:"да съдържа"},set:{unit:"елемента",verb:"да съдържа"}};function t(o){return e[o]??null}const r={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}, получен ${LI(o.input)}`;case"invalid_value":return o.values.length===1?`Невалиден вход: очакван ${H(o.values[0])}`:`Невалидна опция: очаквано едно от ${j(o.values,"|")}`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Твърде голямо: очаква се ${o.origin??"стойност"} да съдържа ${n}${o.maximum.toString()} ${i.unit??"елемента"}`:`Твърде голямо: очаква се ${o.origin??"стойност"} да бъде ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Твърде малко: очаква се ${o.origin} да съдържа ${n}${o.minimum.toString()} ${i.unit}`:`Твърде малко: очаква се ${o.origin} да бъде ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;if(n.format==="starts_with")return`Невалиден низ: трябва да започва с "${n.prefix}"`;if(n.format==="ends_with")return`Невалиден низ: трябва да завършва с "${n.suffix}"`;if(n.format==="includes")return`Невалиден низ: трябва да включва "${n.includes}"`;if(n.format==="regex")return`Невалиден низ: трябва да съвпада с ${n.pattern}`;let i="Невалиден";return n.format==="emoji"&&(i="Невалидно"),n.format==="datetime"&&(i="Невалидно"),n.format==="date"&&(i="Невалидна"),n.format==="time"&&(i="Невалидно"),n.format==="duration"&&(i="Невалидна"),`${i} ${r[n.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 FI(){return{localeError:ZI()}}const qI=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Tipus invàlid: s'esperava ${n.expected}, s'ha rebut ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Valor invàlid: s'esperava ${H(n.values[0])}`:`Opció invàlida: s'esperava una de ${j(n.values," o ")}`;case"too_big":{const i=n.inclusive?"com a màxim":"menys de",a=t(n.origin);return a?`Massa gran: s'esperava que ${n.origin??"el valor"} contingués ${i} ${n.maximum.toString()} ${a.unit??"elements"}`:`Massa gran: s'esperava que ${n.origin??"el valor"} fos ${i} ${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?"com a mínim":"més de",a=t(n.origin);return a?`Massa petit: s'esperava que ${n.origin} contingués ${i} ${n.minimum.toString()} ${a.unit}`:`Massa petit: s'esperava que ${n.origin} fos ${i} ${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Número invàlid: ha de ser múltiple de ${n.divisor}`;case"unrecognized_keys":return`Clau${n.keys.length>1?"s":""} no reconeguda${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Clau invàlida a ${n.origin}`;case"invalid_union":return"Entrada invàlida";case"invalid_element":return`Element invàlid a ${n.origin}`;default:return"Entrada invàlida"}}};function VI(){return{localeError:qI()}}const BI=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"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(n))return"pole";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Neplatný vstup: očekáváno ${n.expected}, obdrženo ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Neplatný vstup: očekáváno ${H(n.values[0])}`:`Neplatná možnost: očekávána jedna z hodnot ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Hodnota je příliš velká: ${n.origin??"hodnota"} musí mít ${i}${n.maximum.toString()} ${a.unit??"prvků"}`:`Hodnota je příliš velká: ${n.origin??"hodnota"} musí být ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Hodnota je příliš malá: ${n.origin??"hodnota"} musí mít ${i}${n.minimum.toString()} ${a.unit??"prvků"}`:`Hodnota je příliš malá: ${n.origin??"hodnota"} musí být ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Neplatné číslo: musí být násobkem ${n.divisor}`;case"unrecognized_keys":return`Neznámé klíče: ${j(n.keys,", ")}`;case"invalid_key":return`Neplatný klíč v ${n.origin}`;case"invalid_union":return"Neplatný vstup";case"invalid_element":return`Neplatná hodnota v ${n.origin}`;default:return"Neplatný vstup"}}};function JI(){return{localeError:BI()}}const WI=()=>{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 r(a){return e[a]??null}function o(a){return t[a]??a}const n=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(n(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=r(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=r(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 HI(){return{localeError:WI()}}const GI=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"Zahl";case"object":{if(Array.isArray(n))return"Array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Ungültige Eingabe: erwartet ${n.expected}, erhalten ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ungültige Eingabe: erwartet ${H(n.values[0])}`:`Ungültige Option: erwartet eine von ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Zu groß: erwartet, dass ${n.origin??"Wert"} ${i}${n.maximum.toString()} ${a.unit??"Elemente"} hat`:`Zu groß: erwartet, dass ${n.origin??"Wert"} ${i}${n.maximum.toString()} ist`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Zu klein: erwartet, dass ${n.origin} ${i}${n.minimum.toString()} ${a.unit} hat`:`Zu klein: erwartet, dass ${n.origin} ${i}${n.minimum.toString()} ist`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Ungültige Zahl: muss ein Vielfaches von ${n.divisor} sein`;case"unrecognized_keys":return`${n.keys.length>1?"Unbekannte Schlüssel":"Unbekannter Schlüssel"}: ${j(n.keys,", ")}`;case"invalid_key":return`Ungültiger Schlüssel in ${n.origin}`;case"invalid_union":return"Ungültige Eingabe";case"invalid_element":return`Ungültiger Wert in ${n.origin}`;default:return"Ungültige Eingabe"}}};function KI(){return{localeError:GI()}}const YI=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},QI=()=>{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 r={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 ${YI(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 n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${n}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Too small: expected ${o.origin} to have ${n}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Invalid string: must start with "${n.prefix}"`:n.format==="ends_with"?`Invalid string: must end with "${n.suffix}"`:n.format==="includes"?`Invalid string: must include "${n.includes}"`:n.format==="regex"?`Invalid string: must match pattern ${n.pattern}`:`Invalid ${r[n.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:QI()}}const XI=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},ek=()=>{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 r={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 ${XI(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 n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Tro granda: atendiĝis ke ${o.origin??"valoro"} havu ${n}${o.maximum.toString()} ${i.unit??"elementojn"}`:`Tro granda: atendiĝis ke ${o.origin??"valoro"} havu ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Tro malgranda: atendiĝis ke ${o.origin} havu ${n}${o.minimum.toString()} ${i.unit}`:`Tro malgranda: atendiĝis ke ${o.origin} estu ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Nevalida karaktraro: devas komenciĝi per "${n.prefix}"`:n.format==="ends_with"?`Nevalida karaktraro: devas finiĝi per "${n.suffix}"`:n.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${n.includes}"`:n.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${n.pattern}`:`Nevalida ${r[n.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 tk(){return{localeError:ek()}}const rk=()=>{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 r(a){return e[a]??null}function o(a){return t[a]??a}const n=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(n(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=r(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=r(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 nk(){return{localeError:rk()}}const ok=()=>{const e={string:{unit:"کاراکتر",verb:"داشته باشد"},file:{unit:"بایت",verb:"داشته باشد"},array:{unit:"آیتم",verb:"داشته باشد"},set:{unit:"آیتم",verb:"داشته باشد"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"عدد";case"object":{if(Array.isArray(n))return"آرایه";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`ورودی نامعتبر: میبایست ${n.expected} میبود، ${r(n.input)} دریافت شد`;case"invalid_value":return n.values.length===1?`ورودی نامعتبر: میبایست ${H(n.values[0])} میبود`:`گزینه نامعتبر: میبایست یکی از ${j(n.values,"|")} میبود`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`خیلی بزرگ: ${n.origin??"مقدار"} باید ${i}${n.maximum.toString()} ${a.unit??"عنصر"} باشد`:`خیلی بزرگ: ${n.origin??"مقدار"} باید ${i}${n.maximum.toString()} باشد`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`خیلی کوچک: ${n.origin} باید ${i}${n.minimum.toString()} ${a.unit} باشد`:`خیلی کوچک: ${n.origin} باید ${i}${n.minimum.toString()} باشد`}case"invalid_format":{const i=n;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]??n.format} نامعتبر`}case"not_multiple_of":return`عدد نامعتبر: باید مضرب ${n.divisor} باشد`;case"unrecognized_keys":return`کلید${n.keys.length>1?"های":""} ناشناس: ${j(n.keys,", ")}`;case"invalid_key":return`کلید ناشناس در ${n.origin}`;case"invalid_union":return"ورودی نامعتبر";case"invalid_element":return`مقدار نامعتبر در ${n.origin}`;default:return"ورودی نامعتبر"}}};function ik(){return{localeError:ok()}}const ak=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Virheellinen tyyppi: odotettiin ${n.expected}, oli ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Virheellinen syöte: täytyy olla ${H(n.values[0])}`:`Virheellinen valinta: täytyy olla yksi seuraavista: ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Liian suuri: ${a.subject} täytyy olla ${i}${n.maximum.toString()} ${a.unit}`.trim():`Liian suuri: arvon täytyy olla ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Liian pieni: ${a.subject} täytyy olla ${i}${n.minimum.toString()} ${a.unit}`.trim():`Liian pieni: arvon täytyy olla ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Virheellinen luku: täytyy olla luvun ${n.divisor} monikerta`;case"unrecognized_keys":return`${n.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${j(n.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 sk(){return{localeError:ak()}}const uk=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"nombre";case"object":{if(Array.isArray(n))return"tableau";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Entrée invalide : ${n.expected} attendu, ${r(n.input)} reçu`;case"invalid_value":return n.values.length===1?`Entrée invalide : ${H(n.values[0])} attendu`:`Option invalide : une valeur parmi ${j(n.values,"|")} attendue`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Trop grand : ${n.origin??"valeur"} doit ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"élément(s)"}`:`Trop grand : ${n.origin??"valeur"} doit être ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Trop petit : ${n.origin} doit ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Trop petit : ${n.origin} doit être ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit être un multiple de ${n.divisor}`;case"unrecognized_keys":return`Clé${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${j(n.keys,", ")}`;case"invalid_key":return`Clé invalide dans ${n.origin}`;case"invalid_union":return"Entrée invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entrée invalide"}}};function lk(){return{localeError:uk()}}const ck=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Entrée invalide : attendu ${n.expected}, reçu ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Entrée invalide : attendu ${H(n.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"≤":"<",a=t(n.origin);return a?`Trop grand : attendu que ${n.origin??"la valeur"} ait ${i}${n.maximum.toString()} ${a.unit}`:`Trop grand : attendu que ${n.origin??"la valeur"} soit ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?"≥":">",a=t(n.origin);return a?`Trop petit : attendu que ${n.origin} ait ${i}${n.minimum.toString()} ${a.unit}`:`Trop petit : attendu que ${n.origin} soit ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit être un multiple de ${n.divisor}`;case"unrecognized_keys":return`Clé${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${j(n.keys,", ")}`;case"invalid_key":return`Clé invalide dans ${n.origin}`;case"invalid_union":return"Entrée invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entrée invalide"}}};function dk(){return{localeError:ck()}}const pk=()=>{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:"גדול"}},r=u=>u?e[u]:void 0,o=u=>{const c=r(u);return c?c.label:u??e.unknown.label},n=u=>`ה${o(u)}`,i=u=>(r(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=n(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=n(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`ערך לא תקין ב${n(u.origin??"array")}`;default:return"קלט לא תקין"}}};function fk(){return{localeError:pk()}}const mk=()=>{const e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"szám";case"object":{if(Array.isArray(n))return"tömb";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Érvénytelen bemenet: a várt érték ${n.expected}, a kapott érték ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Érvénytelen bemenet: a várt érték ${H(n.values[0])}`:`Érvénytelen opció: valamelyik érték várt ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Túl nagy: ${n.origin??"érték"} mérete túl nagy ${i}${n.maximum.toString()} ${a.unit??"elem"}`:`Túl nagy: a bemeneti érték ${n.origin??"érték"} túl nagy: ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Túl kicsi: a bemeneti érték ${n.origin} mérete túl kicsi ${i}${n.minimum.toString()} ${a.unit}`:`Túl kicsi: a bemeneti érték ${n.origin} túl kicsi ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Érvénytelen szám: ${n.divisor} többszörösének kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Érvénytelen kulcs ${n.origin}`;case"invalid_union":return"Érvénytelen bemenet";case"invalid_element":return`Érvénytelen érték: ${n.origin}`;default:return"Érvénytelen bemenet"}}};function hk(){return{localeError:mk()}}const gk=()=>{const e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Input tidak valid: diharapkan ${n.expected}, diterima ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Input tidak valid: diharapkan ${H(n.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Terlalu besar: diharapkan ${n.origin??"value"} memiliki ${i}${n.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: diharapkan ${n.origin??"value"} menjadi ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Terlalu kecil: diharapkan ${n.origin} memiliki ${i}${n.minimum.toString()} ${a.unit}`:`Terlalu kecil: diharapkan ${n.origin} menjadi ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${n.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${n.origin}`;default:return"Input tidak valid"}}};function vk(){return{localeError:gk()}}const yk=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},bk=()=>{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 r={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 ${yk(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 n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Of stórt: gert er ráð fyrir að ${o.origin??"gildi"} hafi ${n}${o.maximum.toString()} ${i.unit??"hluti"}`:`Of stórt: gert er ráð fyrir að ${o.origin??"gildi"} sé ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Of lítið: gert er ráð fyrir að ${o.origin} hafi ${n}${o.minimum.toString()} ${i.unit}`:`Of lítið: gert er ráð fyrir að ${o.origin} sé ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Ógildur strengur: verður að byrja á "${n.prefix}"`:n.format==="ends_with"?`Ógildur strengur: verður að enda á "${n.suffix}"`:n.format==="includes"?`Ógildur strengur: verður að innihalda "${n.includes}"`:n.format==="regex"?`Ógildur strengur: verður að fylgja mynstri ${n.pattern}`:`Rangt ${r[n.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 _k(){return{localeError:bk()}}const wk=()=>{const e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"numero";case"object":{if(Array.isArray(n))return"vettore";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Input non valido: atteso ${n.expected}, ricevuto ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Input non valido: atteso ${H(n.values[0])}`:`Opzione non valida: atteso uno tra ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Troppo grande: ${n.origin??"valore"} deve avere ${i}${n.maximum.toString()} ${a.unit??"elementi"}`:`Troppo grande: ${n.origin??"valore"} deve essere ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Troppo piccolo: ${n.origin} deve avere ${i}${n.minimum.toString()} ${a.unit}`:`Troppo piccolo: ${n.origin} deve essere ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${n.divisor}`;case"unrecognized_keys":return`Chiav${n.keys.length>1?"i":"e"} non riconosciut${n.keys.length>1?"e":"a"}: ${j(n.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${n.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${n.origin}`;default:return"Input non valido"}}};function xk(){return{localeError:wk()}}const $k=()=>{const e={string:{unit:"文字",verb:"である"},file:{unit:"バイト",verb:"である"},array:{unit:"要素",verb:"である"},set:{unit:"要素",verb:"である"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"数値";case"object":{if(Array.isArray(n))return"配列";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`無効な入力: ${n.expected}が期待されましたが、${r(n.input)}が入力されました`;case"invalid_value":return n.values.length===1?`無効な入力: ${H(n.values[0])}が期待されました`:`無効な選択: ${j(n.values,"、")}のいずれかである必要があります`;case"too_big":{const i=n.inclusive?"以下である":"より小さい",a=t(n.origin);return a?`大きすぎる値: ${n.origin??"値"}は${n.maximum.toString()}${a.unit??"要素"}${i}必要があります`:`大きすぎる値: ${n.origin??"値"}は${n.maximum.toString()}${i}必要があります`}case"too_small":{const i=n.inclusive?"以上である":"より大きい",a=t(n.origin);return a?`小さすぎる値: ${n.origin}は${n.minimum.toString()}${a.unit}${i}必要があります`:`小さすぎる値: ${n.origin}は${n.minimum.toString()}${i}必要があります`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`無効な数値: ${n.divisor}の倍数である必要があります`;case"unrecognized_keys":return`認識されていないキー${n.keys.length>1?"群":""}: ${j(n.keys,"、")}`;case"invalid_key":return`${n.origin}内の無効なキー`;case"invalid_union":return"無効な入力";case"invalid_element":return`${n.origin}内の無効な値`;default:return"無効な入力"}}};function Sk(){return{localeError:$k()}}const Ik=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},kk=()=>{const e={string:{unit:"სიმბოლო",verb:"უნდა შეიცავდეს"},file:{unit:"ბაიტი",verb:"უნდა შეიცავდეს"},array:{unit:"ელემენტი",verb:"უნდა შეიცავდეს"},set:{unit:"ელემენტი",verb:"უნდა შეიცავდეს"}};function t(o){return e[o]??null}const r={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}, მიღებული ${Ik(o.input)}`;case"invalid_value":return o.values.length===1?`არასწორი შეყვანა: მოსალოდნელი ${H(o.values[0])}`:`არასწორი ვარიანტი: მოსალოდნელია ერთ-ერთი ${j(o.values,"|")}-დან`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`ზედმეტად დიდი: მოსალოდნელი ${o.origin??"მნიშვნელობა"} ${i.verb} ${n}${o.maximum.toString()} ${i.unit}`:`ზედმეტად დიდი: მოსალოდნელი ${o.origin??"მნიშვნელობა"} იყოს ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`ზედმეტად პატარა: მოსალოდნელი ${o.origin} ${i.verb} ${n}${o.minimum.toString()} ${i.unit}`:`ზედმეტად პატარა: მოსალოდნელი ${o.origin} იყოს ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`არასწორი სტრინგი: უნდა იწყებოდეს "${n.prefix}"-ით`:n.format==="ends_with"?`არასწორი სტრინგი: უნდა მთავრდებოდეს "${n.suffix}"-ით`:n.format==="includes"?`არასწორი სტრინგი: უნდა შეიცავდეს "${n.includes}"-ს`:n.format==="regex"?`არასწორი სტრინგი: უნდა შეესაბამებოდეს შაბლონს ${n.pattern}`:`არასწორი ${r[n.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 Ek(){return{localeError:kk()}}const Tk=()=>{const e={string:{unit:"តួអក្សរ",verb:"គួរមាន"},file:{unit:"បៃ",verb:"គួរមាន"},array:{unit:"ធាតុ",verb:"គួរមាន"},set:{unit:"ធាតុ",verb:"គួរមាន"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"មិនមែនជាលេខ (NaN)":"លេខ";case"object":{if(Array.isArray(n))return"អារេ (Array)";if(n===null)return"គ្មានតម្លៃ (null)";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${n.expected} ប៉ុន្តែទទួលបាន ${r(n.input)}`;case"invalid_value":return n.values.length===1?`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${H(n.values[0])}`:`ជម្រើសមិនត្រឹមត្រូវ៖ ត្រូវជាមួយក្នុងចំណោម ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`ធំពេក៖ ត្រូវការ ${n.origin??"តម្លៃ"} ${i} ${n.maximum.toString()} ${a.unit??"ធាតុ"}`:`ធំពេក៖ ត្រូវការ ${n.origin??"តម្លៃ"} ${i} ${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`តូចពេក៖ ត្រូវការ ${n.origin} ${i} ${n.minimum.toString()} ${a.unit}`:`តូចពេក៖ ត្រូវការ ${n.origin} ${i} ${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`លេខមិនត្រឹមត្រូវ៖ ត្រូវតែជាពហុគុណនៃ ${n.divisor}`;case"unrecognized_keys":return`រកឃើញសោមិនស្គាល់៖ ${j(n.keys,", ")}`;case"invalid_key":return`សោមិនត្រឹមត្រូវនៅក្នុង ${n.origin}`;case"invalid_union":return"ទិន្នន័យមិនត្រឹមត្រូវ";case"invalid_element":return`ទិន្នន័យមិនត្រឹមត្រូវនៅក្នុង ${n.origin}`;default:return"ទិន្នន័យមិនត្រឹមត្រូវ"}}};function yv(){return{localeError:Tk()}}function Ok(){return yv()}const Nk=()=>{const e={string:{unit:"문자",verb:"to have"},file:{unit:"바이트",verb:"to have"},array:{unit:"개",verb:"to have"},set:{unit:"개",verb:"to have"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`잘못된 입력: 예상 타입은 ${n.expected}, 받은 타입은 ${r(n.input)}입니다`;case"invalid_value":return n.values.length===1?`잘못된 입력: 값은 ${H(n.values[0])} 이어야 합니다`:`잘못된 옵션: ${j(n.values,"또는 ")} 중 하나여야 합니다`;case"too_big":{const i=n.inclusive?"이하":"미만",a=i==="미만"?"이어야 합니다":"여야 합니다",s=t(n.origin),l=s?.unit??"요소";return s?`${n.origin??"값"}이 너무 큽니다: ${n.maximum.toString()}${l} ${i}${a}`:`${n.origin??"값"}이 너무 큽니다: ${n.maximum.toString()} ${i}${a}`}case"too_small":{const i=n.inclusive?"이상":"초과",a=i==="이상"?"이어야 합니다":"여야 합니다",s=t(n.origin),l=s?.unit??"요소";return s?`${n.origin??"값"}이 너무 작습니다: ${n.minimum.toString()}${l} ${i}${a}`:`${n.origin??"값"}이 너무 작습니다: ${n.minimum.toString()} ${i}${a}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`잘못된 숫자: ${n.divisor}의 배수여야 합니다`;case"unrecognized_keys":return`인식할 수 없는 키: ${j(n.keys,", ")}`;case"invalid_key":return`잘못된 키: ${n.origin}`;case"invalid_union":return"잘못된 입력";case"invalid_element":return`잘못된 값: ${n.origin}`;default:return"잘못된 입력"}}};function Pk(){return{localeError:Nk()}}const Ck=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),r=t%10,o=t%100;return o>=11&&o<=19||r===0?"many":r===1?"one":"few"}const jk=()=>{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,n,i,a){const s=e[o]??null;return s===null?s:{unit:s.unit[n],verb:s.verb[a][i?"inclusive":"notInclusive"]}}const r={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 ${Ck(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 n=Sn(o.origin),i=t(o.origin,Gd(Number(o.maximum)),o.inclusive??!1,"smaller");if(i?.verb)return`${bn(n??o.origin??"reikšmė")} ${i.verb} ${o.maximum.toString()} ${i.unit??"elementų"}`;const a=o.inclusive?"ne didesnis kaip":"mažesnis kaip";return`${bn(n??o.origin??"reikšmė")} turi būti ${a} ${o.maximum.toString()} ${i?.unit}`}case"too_small":{const n=Sn(o.origin),i=t(o.origin,Gd(Number(o.minimum)),o.inclusive??!1,"bigger");if(i?.verb)return`${bn(n??o.origin??"reikšmė")} ${i.verb} ${o.minimum.toString()} ${i.unit??"elementų"}`;const a=o.inclusive?"ne mažesnis kaip":"didesnis kaip";return`${bn(n??o.origin??"reikšmė")} turi būti ${a} ${o.minimum.toString()} ${i?.unit}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Eilutė privalo prasidėti "${n.prefix}"`:n.format==="ends_with"?`Eilutė privalo pasibaigti "${n.suffix}"`:n.format==="includes"?`Eilutė privalo įtraukti "${n.includes}"`:n.format==="regex"?`Eilutė privalo atitikti ${n.pattern}`:`Neteisingas ${r[n.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 n=Sn(o.origin);return`${bn(n??o.origin??"reikšmė")} turi klaidingą įvestį`}default:return"Klaidinga įvestis"}}};function Ak(){return{localeError:jk()}}const Rk=()=>{const e={string:{unit:"знаци",verb:"да имаат"},file:{unit:"бајти",verb:"да имаат"},array:{unit:"ставки",verb:"да имаат"},set:{unit:"ставки",verb:"да имаат"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"број";case"object":{if(Array.isArray(n))return"низа";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Грешен внес: се очекува ${n.expected}, примено ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${H(n.values[0])}`:`Грешана опција: се очекува една ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Премногу голем: се очекува ${n.origin??"вредноста"} да има ${i}${n.maximum.toString()} ${a.unit??"елементи"}`:`Премногу голем: се очекува ${n.origin??"вредноста"} да биде ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Премногу мал: се очекува ${n.origin} да има ${i}${n.minimum.toString()} ${a.unit}`:`Премногу мал: се очекува ${n.origin} да биде ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Грешен број: мора да биде делив со ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Непрепознаени клучеви":"Непрепознаен клуч"}: ${j(n.keys,", ")}`;case"invalid_key":return`Грешен клуч во ${n.origin}`;case"invalid_union":return"Грешен внес";case"invalid_element":return`Грешна вредност во ${n.origin}`;default:return"Грешен внес"}}};function zk(){return{localeError:Rk()}}const Mk=()=>{const e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"nombor";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Input tidak sah: dijangka ${n.expected}, diterima ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Input tidak sah: dijangka ${H(n.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Terlalu besar: dijangka ${n.origin??"nilai"} ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: dijangka ${n.origin??"nilai"} adalah ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Terlalu kecil: dijangka ${n.origin} ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Terlalu kecil: dijangka ${n.origin} adalah ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${j(n.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${n.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${n.origin}`;default:return"Input tidak sah"}}};function Dk(){return{localeError:Mk()}}const Uk=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"getal";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Ongeldige invoer: verwacht ${n.expected}, ontving ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ongeldige invoer: verwacht ${H(n.values[0])}`:`Ongeldige optie: verwacht één van ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Te groot: verwacht dat ${n.origin??"waarde"} ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"elementen"}`:`Te groot: verwacht dat ${n.origin??"waarde"} ${i}${n.maximum.toString()} is`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Te klein: verwacht dat ${n.origin} ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Te klein: verwacht dat ${n.origin} ${i}${n.minimum.toString()} is`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${n.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${n.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${n.origin}`;default:return"Ongeldige invoer"}}};function Lk(){return{localeError:Uk()}}const Zk=()=>{const e={string:{unit:"tegn",verb:"å ha"},file:{unit:"bytes",verb:"å ha"},array:{unit:"elementer",verb:"å inneholde"},set:{unit:"elementer",verb:"å inneholde"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"tall";case"object":{if(Array.isArray(n))return"liste";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Ugyldig input: forventet ${n.expected}, fikk ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ugyldig verdi: forventet ${H(n.values[0])}`:`Ugyldig valg: forventet en av ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`For stor(t): forventet ${n.origin??"value"} til å ha ${i}${n.maximum.toString()} ${a.unit??"elementer"}`:`For stor(t): forventet ${n.origin??"value"} til å ha ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`For lite(n): forventet ${n.origin} til å ha ${i}${n.minimum.toString()} ${a.unit}`:`For lite(n): forventet ${n.origin} til å ha ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Ugyldig tall: må være et multiplum av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukjente nøkler":"Ukjent nøkkel"}: ${j(n.keys,", ")}`;case"invalid_key":return`Ugyldig nøkkel i ${n.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${n.origin}`;default:return"Ugyldig input"}}};function Fk(){return{localeError:Zk()}}const qk=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"numara";case"object":{if(Array.isArray(n))return"saf";if(n===null)return"gayb";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Fâsit giren: umulan ${n.expected}, alınan ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Fâsit giren: umulan ${H(n.values[0])}`:`Fâsit tercih: mûteberler ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Fazla büyük: ${n.origin??"value"}, ${i}${n.maximum.toString()} ${a.unit??"elements"} sahip olmalıydı.`:`Fazla büyük: ${n.origin??"value"}, ${i}${n.maximum.toString()} olmalıydı.`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Fazla küçük: ${n.origin}, ${i}${n.minimum.toString()} ${a.unit} sahip olmalıydı.`:`Fazla küçük: ${n.origin}, ${i}${n.minimum.toString()} olmalıydı.`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Fâsit sayı: ${n.divisor} katı olmalıydı.`;case"unrecognized_keys":return`Tanınmayan anahtar ${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`${n.origin} için tanınmayan anahtar var.`;case"invalid_union":return"Giren tanınamadı.";case"invalid_element":return`${n.origin} için tanınmayan kıymet var.`;default:return"Kıymet tanınamadı."}}};function Vk(){return{localeError:qk()}}const Bk=()=>{const e={string:{unit:"توکي",verb:"ولري"},file:{unit:"بایټس",verb:"ولري"},array:{unit:"توکي",verb:"ولري"},set:{unit:"توکي",verb:"ولري"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"عدد";case"object":{if(Array.isArray(n))return"ارې";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`ناسم ورودي: باید ${n.expected} وای, مګر ${r(n.input)} ترلاسه شو`;case"invalid_value":return n.values.length===1?`ناسم ورودي: باید ${H(n.values[0])} وای`:`ناسم انتخاب: باید یو له ${j(n.values,"|")} څخه وای`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`ډیر لوی: ${n.origin??"ارزښت"} باید ${i}${n.maximum.toString()} ${a.unit??"عنصرونه"} ولري`:`ډیر لوی: ${n.origin??"ارزښت"} باید ${i}${n.maximum.toString()} وي`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`ډیر کوچنی: ${n.origin} باید ${i}${n.minimum.toString()} ${a.unit} ولري`:`ډیر کوچنی: ${n.origin} باید ${i}${n.minimum.toString()} وي`}case"invalid_format":{const i=n;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]??n.format} ناسم دی`}case"not_multiple_of":return`ناسم عدد: باید د ${n.divisor} مضرب وي`;case"unrecognized_keys":return`ناسم ${n.keys.length>1?"کلیډونه":"کلیډ"}: ${j(n.keys,", ")}`;case"invalid_key":return`ناسم کلیډ په ${n.origin} کې`;case"invalid_union":return"ناسمه ورودي";case"invalid_element":return`ناسم عنصر په ${n.origin} کې`;default:return"ناسمه ورودي"}}};function Jk(){return{localeError:Bk()}}const Wk=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"liczba";case"object":{if(Array.isArray(n))return"tablica";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Nieprawidłowe dane wejściowe: oczekiwano ${n.expected}, otrzymano ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Nieprawidłowe dane wejściowe: oczekiwano ${H(n.values[0])}`:`Nieprawidłowa opcja: oczekiwano jednej z wartości ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Za duża wartość: oczekiwano, że ${n.origin??"wartość"} będzie mieć ${i}${n.maximum.toString()} ${a.unit??"elementów"}`:`Zbyt duż(y/a/e): oczekiwano, że ${n.origin??"wartość"} będzie wynosić ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Za mała wartość: oczekiwano, że ${n.origin??"wartość"} będzie mieć ${i}${n.minimum.toString()} ${a.unit??"elementów"}`:`Zbyt mał(y/a/e): oczekiwano, że ${n.origin??"wartość"} będzie wynosić ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Nieprawidłowa liczba: musi być wielokrotnością ${n.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Nieprawidłowy klucz w ${n.origin}`;case"invalid_union":return"Nieprawidłowe dane wejściowe";case"invalid_element":return`Nieprawidłowa wartość w ${n.origin}`;default:return"Nieprawidłowe dane wejściowe"}}};function Hk(){return{localeError:Wk()}}const Gk=()=>{const e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"número";case"object":{if(Array.isArray(n))return"array";if(n===null)return"nulo";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Tipo inválido: esperado ${n.expected}, recebido ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Entrada inválida: esperado ${H(n.values[0])}`:`Opção inválida: esperada uma das ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Muito grande: esperado que ${n.origin??"valor"} tivesse ${i}${n.maximum.toString()} ${a.unit??"elementos"}`:`Muito grande: esperado que ${n.origin??"valor"} fosse ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Muito pequeno: esperado que ${n.origin} tivesse ${i}${n.minimum.toString()} ${a.unit}`:`Muito pequeno: esperado que ${n.origin} fosse ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format} inválido`}case"not_multiple_of":return`Número inválido: deve ser múltiplo de ${n.divisor}`;case"unrecognized_keys":return`Chave${n.keys.length>1?"s":""} desconhecida${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Chave inválida em ${n.origin}`;case"invalid_union":return"Entrada inválida";case"invalid_element":return`Valor inválido em ${n.origin}`;default:return"Campo inválido"}}};function Kk(){return{localeError:Gk()}}function Kd(e,t,r,o){const n=Math.abs(e),i=n%10,a=n%100;return a>=11&&a<=19?o:i===1?t:i>=2&&i<=4?r:o}const Yk=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"число";case"object":{if(Array.isArray(n))return"массив";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Неверный ввод: ожидалось ${n.expected}, получено ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Неверный ввод: ожидалось ${H(n.values[0])}`:`Неверный вариант: ожидалось одно из ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);if(a){const s=Number(n.maximum),l=Kd(s,a.unit.one,a.unit.few,a.unit.many);return`Слишком большое значение: ожидалось, что ${n.origin??"значение"} будет иметь ${i}${n.maximum.toString()} ${l}`}return`Слишком большое значение: ожидалось, что ${n.origin??"значение"} будет ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);if(a){const s=Number(n.minimum),l=Kd(s,a.unit.one,a.unit.few,a.unit.many);return`Слишком маленькое значение: ожидалось, что ${n.origin} будет иметь ${i}${n.minimum.toString()} ${l}`}return`Слишком маленькое значение: ожидалось, что ${n.origin} будет ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Неверное число: должно быть кратным ${n.divisor}`;case"unrecognized_keys":return`Нераспознанн${n.keys.length>1?"ые":"ый"} ключ${n.keys.length>1?"и":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Неверный ключ в ${n.origin}`;case"invalid_union":return"Неверные входные данные";case"invalid_element":return`Неверное значение в ${n.origin}`;default:return"Неверные входные данные"}}};function Qk(){return{localeError:Yk()}}const Xk=()=>{const e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"število";case"object":{if(Array.isArray(n))return"tabela";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Neveljaven vnos: pričakovano ${n.expected}, prejeto ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Neveljaven vnos: pričakovano ${H(n.values[0])}`:`Neveljavna možnost: pričakovano eno izmed ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Preveliko: pričakovano, da bo ${n.origin??"vrednost"} imelo ${i}${n.maximum.toString()} ${a.unit??"elementov"}`:`Preveliko: pričakovano, da bo ${n.origin??"vrednost"} ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Premajhno: pričakovano, da bo ${n.origin} imelo ${i}${n.minimum.toString()} ${a.unit}`:`Premajhno: pričakovano, da bo ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Neveljavno število: mora biti večkratnik ${n.divisor}`;case"unrecognized_keys":return`Neprepoznan${n.keys.length>1?"i ključi":" ključ"}: ${j(n.keys,", ")}`;case"invalid_key":return`Neveljaven ključ v ${n.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${n.origin}`;default:return"Neveljaven vnos"}}};function eE(){return{localeError:Xk()}}const tE=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"antal";case"object":{if(Array.isArray(n))return"lista";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Ogiltig inmatning: förväntat ${n.expected}, fick ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ogiltig inmatning: förväntat ${H(n.values[0])}`:`Ogiltigt val: förväntade en av ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`För stor(t): förväntade ${n.origin??"värdet"} att ha ${i}${n.maximum.toString()} ${a.unit??"element"}`:`För stor(t): förväntat ${n.origin??"värdet"} att ha ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`För lite(t): förväntade ${n.origin??"värdet"} att ha ${i}${n.minimum.toString()} ${a.unit}`:`För lite(t): förväntade ${n.origin??"värdet"} att ha ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Ogiltigt tal: måste vara en multipel av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Okända nycklar":"Okänd nyckel"}: ${j(n.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${n.origin??"värdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt värde i ${n.origin??"värdet"}`;default:return"Ogiltig input"}}};function rE(){return{localeError:tE()}}const nE=()=>{const e={string:{unit:"எழுத்துக்கள்",verb:"கொண்டிருக்க வேண்டும்"},file:{unit:"பைட்டுகள்",verb:"கொண்டிருக்க வேண்டும்"},array:{unit:"உறுப்புகள்",verb:"கொண்டிருக்க வேண்டும்"},set:{unit:"உறுப்புகள்",verb:"கொண்டிருக்க வேண்டும்"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"எண் அல்லாதது":"எண்";case"object":{if(Array.isArray(n))return"அணி";if(n===null)return"வெறுமை";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${n.expected}, பெறப்பட்டது ${r(n.input)}`;case"invalid_value":return n.values.length===1?`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${H(n.values[0])}`:`தவறான விருப்பம்: எதிர்பார்க்கப்பட்டது ${j(n.values,"|")} இல் ஒன்று`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`மிக பெரியது: எதிர்பார்க்கப்பட்டது ${n.origin??"மதிப்பு"} ${i}${n.maximum.toString()} ${a.unit??"உறுப்புகள்"} ஆக இருக்க வேண்டும்`:`மிக பெரியது: எதிர்பார்க்கப்பட்டது ${n.origin??"மதிப்பு"} ${i}${n.maximum.toString()} ஆக இருக்க வேண்டும்`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${n.origin} ${i}${n.minimum.toString()} ${a.unit} ஆக இருக்க வேண்டும்`:`மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${n.origin} ${i}${n.minimum.toString()} ஆக இருக்க வேண்டும்`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`தவறான எண்: ${n.divisor} இன் பலமாக இருக்க வேண்டும்`;case"unrecognized_keys":return`அடையாளம் தெரியாத விசை${n.keys.length>1?"கள்":""}: ${j(n.keys,", ")}`;case"invalid_key":return`${n.origin} இல் தவறான விசை`;case"invalid_union":return"தவறான உள்ளீடு";case"invalid_element":return`${n.origin} இல் தவறான மதிப்பு`;default:return"தவறான உள்ளீடு"}}};function oE(){return{localeError:nE()}}const iE=()=>{const e={string:{unit:"ตัวอักษร",verb:"ควรมี"},file:{unit:"ไบต์",verb:"ควรมี"},array:{unit:"รายการ",verb:"ควรมี"},set:{unit:"รายการ",verb:"ควรมี"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"ไม่ใช่ตัวเลข (NaN)":"ตัวเลข";case"object":{if(Array.isArray(n))return"อาร์เรย์ (Array)";if(n===null)return"ไม่มีค่า (null)";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`ประเภทข้อมูลไม่ถูกต้อง: ควรเป็น ${n.expected} แต่ได้รับ ${r(n.input)}`;case"invalid_value":return n.values.length===1?`ค่าไม่ถูกต้อง: ควรเป็น ${H(n.values[0])}`:`ตัวเลือกไม่ถูกต้อง: ควรเป็นหนึ่งใน ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"ไม่เกิน":"น้อยกว่า",a=t(n.origin);return a?`เกินกำหนด: ${n.origin??"ค่า"} ควรมี${i} ${n.maximum.toString()} ${a.unit??"รายการ"}`:`เกินกำหนด: ${n.origin??"ค่า"} ควรมี${i} ${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?"อย่างน้อย":"มากกว่า",a=t(n.origin);return a?`น้อยกว่ากำหนด: ${n.origin} ควรมี${i} ${n.minimum.toString()} ${a.unit}`:`น้อยกว่ากำหนด: ${n.origin} ควรมี${i} ${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`ตัวเลขไม่ถูกต้อง: ต้องเป็นจำนวนที่หารด้วย ${n.divisor} ได้ลงตัว`;case"unrecognized_keys":return`พบคีย์ที่ไม่รู้จัก: ${j(n.keys,", ")}`;case"invalid_key":return`คีย์ไม่ถูกต้องใน ${n.origin}`;case"invalid_union":return"ข้อมูลไม่ถูกต้อง: ไม่ตรงกับรูปแบบยูเนียนที่กำหนดไว้";case"invalid_element":return`ข้อมูลไม่ถูกต้องใน ${n.origin}`;default:return"ข้อมูลไม่ถูกต้อง"}}};function aE(){return{localeError:iE()}}const sE=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},uE=()=>{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 r={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 ${sE(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 n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Çok büyük: beklenen ${o.origin??"değer"} ${n}${o.maximum.toString()} ${i.unit??"öğe"}`:`Çok büyük: beklenen ${o.origin??"değer"} ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Çok küçük: beklenen ${o.origin} ${n}${o.minimum.toString()} ${i.unit}`:`Çok küçük: beklenen ${o.origin} ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Geçersiz metin: "${n.prefix}" ile başlamalı`:n.format==="ends_with"?`Geçersiz metin: "${n.suffix}" ile bitmeli`:n.format==="includes"?`Geçersiz metin: "${n.includes}" içermeli`:n.format==="regex"?`Geçersiz metin: ${n.pattern} desenine uymalı`:`Geçersiz ${r[n.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 lE(){return{localeError:uE()}}const cE=()=>{const e={string:{unit:"символів",verb:"матиме"},file:{unit:"байтів",verb:"матиме"},array:{unit:"елементів",verb:"матиме"},set:{unit:"елементів",verb:"матиме"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"число";case"object":{if(Array.isArray(n))return"масив";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Неправильні вхідні дані: очікується ${n.expected}, отримано ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Неправильні вхідні дані: очікується ${H(n.values[0])}`:`Неправильна опція: очікується одне з ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Занадто велике: очікується, що ${n.origin??"значення"} ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"елементів"}`:`Занадто велике: очікується, що ${n.origin??"значення"} буде ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Занадто мале: очікується, що ${n.origin} ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Занадто мале: очікується, що ${n.origin} буде ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Неправильне число: повинно бути кратним ${n.divisor}`;case"unrecognized_keys":return`Нерозпізнаний ключ${n.keys.length>1?"і":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Неправильний ключ у ${n.origin}`;case"invalid_union":return"Неправильні вхідні дані";case"invalid_element":return`Неправильне значення у ${n.origin}`;default:return"Неправильні вхідні дані"}}};function bv(){return{localeError:cE()}}function dE(){return bv()}const pE=()=>{const e={string:{unit:"حروف",verb:"ہونا"},file:{unit:"بائٹس",verb:"ہونا"},array:{unit:"آئٹمز",verb:"ہونا"},set:{unit:"آئٹمز",verb:"ہونا"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"نمبر";case"object":{if(Array.isArray(n))return"آرے";if(n===null)return"نل";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`غلط ان پٹ: ${n.expected} متوقع تھا، ${r(n.input)} موصول ہوا`;case"invalid_value":return n.values.length===1?`غلط ان پٹ: ${H(n.values[0])} متوقع تھا`:`غلط آپشن: ${j(n.values,"|")} میں سے ایک متوقع تھا`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`بہت بڑا: ${n.origin??"ویلیو"} کے ${i}${n.maximum.toString()} ${a.unit??"عناصر"} ہونے متوقع تھے`:`بہت بڑا: ${n.origin??"ویلیو"} کا ${i}${n.maximum.toString()} ہونا متوقع تھا`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`بہت چھوٹا: ${n.origin} کے ${i}${n.minimum.toString()} ${a.unit} ہونے متوقع تھے`:`بہت چھوٹا: ${n.origin} کا ${i}${n.minimum.toString()} ہونا متوقع تھا`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`غلط نمبر: ${n.divisor} کا مضاعف ہونا چاہیے`;case"unrecognized_keys":return`غیر تسلیم شدہ کی${n.keys.length>1?"ز":""}: ${j(n.keys,"، ")}`;case"invalid_key":return`${n.origin} میں غلط کی`;case"invalid_union":return"غلط ان پٹ";case"invalid_element":return`${n.origin} میں غلط ویلیو`;default:return"غلط ان پٹ"}}};function fE(){return{localeError:pE()}}const mE=()=>{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(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"số";case"object":{if(Array.isArray(n))return"mảng";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Đầu vào không hợp lệ: mong đợi ${n.expected}, nhận được ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Đầu vào không hợp lệ: mong đợi ${H(n.values[0])}`:`Tùy chọn không hợp lệ: mong đợi một trong các giá trị ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Quá lớn: mong đợi ${n.origin??"giá trị"} ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"phần tử"}`:`Quá lớn: mong đợi ${n.origin??"giá trị"} ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Quá nhỏ: mong đợi ${n.origin} ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Quá nhỏ: mong đợi ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.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 ${n.divisor}`;case"unrecognized_keys":return`Khóa không được nhận dạng: ${j(n.keys,", ")}`;case"invalid_key":return`Khóa không hợp lệ trong ${n.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 ${n.origin}`;default:return"Đầu vào không hợp lệ"}}};function hE(){return{localeError:mE()}}const gE=()=>{const e={string:{unit:"字符",verb:"包含"},file:{unit:"字节",verb:"包含"},array:{unit:"项",verb:"包含"},set:{unit:"项",verb:"包含"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"非数字(NaN)":"数字";case"object":{if(Array.isArray(n))return"数组";if(n===null)return"空值(null)";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`无效输入:期望 ${n.expected},实际接收 ${r(n.input)}`;case"invalid_value":return n.values.length===1?`无效输入:期望 ${H(n.values[0])}`:`无效选项:期望以下之一 ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`数值过大:期望 ${n.origin??"值"} ${i}${n.maximum.toString()} ${a.unit??"个元素"}`:`数值过大:期望 ${n.origin??"值"} ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`数值过小:期望 ${n.origin} ${i}${n.minimum.toString()} ${a.unit}`:`数值过小:期望 ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`无效数字:必须是 ${n.divisor} 的倍数`;case"unrecognized_keys":return`出现未知的键(key): ${j(n.keys,", ")}`;case"invalid_key":return`${n.origin} 中的键(key)无效`;case"invalid_union":return"无效输入";case"invalid_element":return`${n.origin} 中包含无效值(value)`;default:return"无效输入"}}};function vE(){return{localeError:gE()}}const yE=()=>{const e={string:{unit:"字元",verb:"擁有"},file:{unit:"位元組",verb:"擁有"},array:{unit:"項目",verb:"擁有"},set:{unit:"項目",verb:"擁有"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`無效的輸入值:預期為 ${n.expected},但收到 ${r(n.input)}`;case"invalid_value":return n.values.length===1?`無效的輸入值:預期為 ${H(n.values[0])}`:`無效的選項:預期為以下其中之一 ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`數值過大:預期 ${n.origin??"值"} 應為 ${i}${n.maximum.toString()} ${a.unit??"個元素"}`:`數值過大:預期 ${n.origin??"值"} 應為 ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`數值過小:預期 ${n.origin} 應為 ${i}${n.minimum.toString()} ${a.unit}`:`數值過小:預期 ${n.origin} 應為 ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`無效的數字:必須為 ${n.divisor} 的倍數`;case"unrecognized_keys":return`無法識別的鍵值${n.keys.length>1?"們":""}:${j(n.keys,"、")}`;case"invalid_key":return`${n.origin} 中有無效的鍵值`;case"invalid_union":return"無效的輸入值";case"invalid_element":return`${n.origin} 中有無效的值`;default:return"無效的輸入值"}}};function bE(){return{localeError:yE()}}const _E=()=>{const e={string:{unit:"àmi",verb:"ní"},file:{unit:"bytes",verb:"ní"},array:{unit:"nkan",verb:"ní"},set:{unit:"nkan",verb:"ní"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"nọ́mbà";case"object":{if(Array.isArray(n))return"akopọ";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.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 n=>{switch(n.code){case"invalid_type":return`Ìbáwọlé aṣìṣe: a ní láti fi ${n.expected}, àmọ̀ a rí ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ìbáwọlé aṣìṣe: a ní láti fi ${H(n.values[0])}`:`Àṣàyàn aṣìṣe: yan ọ̀kan lára ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Tó pọ̀ jù: a ní láti jẹ́ pé ${n.origin??"iye"} ${a.verb} ${i}${n.maximum} ${a.unit}`:`Tó pọ̀ jù: a ní láti jẹ́ ${i}${n.maximum}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Kéré ju: a ní láti jẹ́ pé ${n.origin} ${a.verb} ${i}${n.minimum} ${a.unit}`:`Kéré ju: a ní láti jẹ́ ${i}${n.minimum}`}case"invalid_format":{const i=n;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]??n.format}`}case"not_multiple_of":return`Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${n.divisor}`;case"unrecognized_keys":return`Bọtìnì àìmọ̀: ${j(n.keys,", ")}`;case"invalid_key":return`Bọtìnì aṣìṣe nínú ${n.origin}`;case"invalid_union":return"Ìbáwọlé aṣìṣe";case"invalid_element":return`Iye aṣìṣe nínú ${n.origin}`;default:return"Ìbáwọlé aṣìṣe"}}};function wE(){return{localeError:_E()}}const _v=Object.freeze(Object.defineProperty({__proto__:null,ar:RI,az:MI,be:UI,bg:FI,ca:VI,cs:JI,da:HI,de:KI,en:vv,eo:tk,es:nk,fa:ik,fi:sk,fr:lk,frCA:dk,he:fk,hu:hk,id:vk,is:_k,it:xk,ja:Sk,ka:Ek,kh:Ok,km:yv,ko:Pk,lt:Ak,mk:zk,ms:Dk,nl:Lk,no:Fk,ota:Vk,pl:Hk,ps:Jk,pt:Kk,ru:Qk,sl:eE,sv:rE,ta:oE,th:aE,tr:lE,ua:dE,uk:bv,ur:fE,vi:hE,yo:wE,zhCN:vE,zhTW:bE},Symbol.toStringTag,{value:"Module"}));var Yd;const wv=Symbol("ZodOutput"),xv=Symbol("ZodInput");class $v{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const o=r[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 r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const o={...this.get(r)??{}};delete o.id;const n={...o,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function sl(){return new $v}(Yd=globalThis).__zod_globalRegistry??(Yd.__zod_globalRegistry=sl());const wt=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 ul(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 ll(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function cl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function dl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function pl(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 fl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function ml(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function hl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function gl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function vl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function yl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function bl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function _l(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function wl(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 xl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function $l(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function Sl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function Il(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function kl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function El(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 Tv(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function Ov(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 ir(e,t){return new Xu({check:"less_than",...P(t),value:e,inclusive:!1})}function st(e,t){return new Xu({check:"less_than",...P(t),value:e,inclusive:!0})}function ar(e,t){return new el({check:"greater_than",...P(t),value:e,inclusive:!1})}function We(e,t){return new el({check:"greater_than",...P(t),value:e,inclusive:!0})}function Tl(e){return ar(0,e)}function Ol(e){return ir(0,e)}function Nl(e){return st(0,e)}function Pl(e){return We(0,e)}function Kr(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 Yr(e,t){return new Fh({check:"min_size",...P(t),minimum:e})}function Qi(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 br(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 Xi(e,t){return new Wh({check:"string_format",format:"regex",...P(t),pattern:e})}function ea(e){return new Hh({check:"string_format",format:"lowercase",...P(e)})}function ta(e){return new Gh({check:"string_format",format:"uppercase",...P(e)})}function ra(e,t){return new Kh({check:"string_format",format:"includes",...P(t),includes:e})}function na(e,t){return new Yh({check:"string_format",format:"starts_with",...P(t),prefix:e})}function oa(e,t){return new Qh({check:"string_format",format:"ends_with",...P(t),suffix:e})}function Cl(e,t,r){return new Xh({check:"property",property:e,schema:t,...P(r)})}function ia(e,t){return new eg({check:"mime_type",mime:e,...P(t)})}function Ht(e){return new tg({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=>Am(e))}function ty(e,t,r){return new e({type:"array",element:t,...P(r)})}function xE(e,t,r){return new e({type:"union",options:t,...P(r)})}function $E(e,t,r){return new e({type:"union",options:t,inclusive:!1,...P(r)})}function SE(e,t,r,o){return new e({type:"union",options:r,discriminator:t,...P(o)})}function IE(e,t,r){return new e({type:"intersection",left:t,right:r})}function kE(e,t,r,o){const n=r instanceof X,i=n?o:r,a=n?r:null;return new e({type:"tuple",items:t,rest:a,...P(i)})}function EE(e,t,r,o){return new e({type:"record",keyType:t,valueType:r,...P(o)})}function TE(e,t,r,o){return new e({type:"map",keyType:t,valueType:r,...P(o)})}function OE(e,t,r){return new e({type:"set",valueType:t,...P(r)})}function NE(e,t,r){const o=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:o,...P(r)})}function PE(e,t,r){return new e({type:"enum",entries:t,...P(r)})}function CE(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...P(r)})}function ry(e,t){return new e({type:"file",...P(t)})}function jE(e,t){return new e({type:"transform",transform:t})}function AE(e,t){return new e({type:"optional",innerType:t})}function RE(e,t){return new e({type:"nullable",innerType:t})}function zE(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Wi(r)}})}function ME(e,t,r){return new e({type:"nonoptional",innerType:t,...P(r)})}function DE(e,t){return new e({type:"success",innerType:t})}function UE(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function LE(e,t,r){return new e({type:"pipe",in:t,out:r})}function ZE(e,t){return new e({type:"readonly",innerType:t})}function FE(e,t,r){return new e({type:"template_literal",parts:t,...P(r)})}function qE(e,t){return new e({type:"lazy",getter:t})}function VE(e,t){return new e({type:"promise",innerType:t})}function ny(e,t,r){const o=P(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function oy(e,t,r){return new e({type:"custom",check:"custom",fn:t,...P(r)})}function iy(e){const t=ay(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Hr(o,r.value,t._zod.def));else{const n=o;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=r.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),r.issues.push(Hr(n))}},e(r.value,r)));return t}function ay(e,t){const r=new Se({check:"custom",...P(t)});return r._zod.check=e,r}function sy(e){const t=new Se({check:"describe"});return t._zod.onattach=[r=>{const o=wt.get(r)??{};wt.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function uy(e){const t=new Se({check:"meta"});return t._zod.onattach=[r=>{const o=wt.get(r)??{};wt.add(r,{...o,...e})}],t._zod.check=()=>{},t}function ly(e,t){const r=P(t);let o=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(o=o.map(p=>typeof p=="string"?p.toLowerCase():p),n=n.map(p=>typeof p=="string"?p.toLowerCase():p));const i=new Set(o),a=new Set(n),s=e.Codec??al,l=e.Boolean??nl,u=e.String??so,c=new u({type:"string",error:r.error}),d=new l({type:"boolean",error:r.error}),f=new s({type:"pipe",in:c,out:d,transform:((p,g)=>{let h=p;return r.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":n[0]||"false"),error:r.error});return f}function po(e,t,r,o={}){const n=P(o),i={...P(o),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...n};return r instanceof RegExp&&(i.pattern=r),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,r={path:[],schemaPath:[]}){var o;const n=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const c={...r,schemaPath:[...r.schemaPath,e],path:r.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[n.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.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 r=e.seen.get(t);if(!r)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]===r)return{ref:"#"};const l=`#/${a}/`,u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},n=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 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
|
-
]))`;continue}else if(
|
|
31
|
-
]))`;continue}}if(o.s&&
|
|
32
|
-
`:`[${
|
|
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)}
|
|
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]){n(i);continue}if(e.external){const l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){n(i);continue}}if(e.metadataRegistry.get(i[0])?.id){n(i);continue}if(a.cycle){n(i);continue}if(a.count>1&&e.reused==="ref"){n(i);continue}}}function en(e,t){const r=e.seen.get(t);if(!r)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 n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$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");n.$id=e.external.uri(a)}Object.assign(n,r.def??r.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"?n.$defs=i:n.definitions=i);try{const a=JSON.parse(JSON.stringify(n));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 r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return Ve(o.element,r);if(o.type==="set")return Ve(o.valueType,r);if(o.type==="lazy")return Ve(o.getter(),r);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,r);if(o.type==="intersection")return Ve(o.left,r)||Ve(o.right,r);if(o.type==="record"||o.type==="map")return Ve(o.keyType,r)||Ve(o.valueType,r);if(o.type==="pipe")return Ve(o.in,r)||Ve(o.out,r);if(o.type==="object"){for(const n in o.shape)if(Ve(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(const n of o.options)if(Ve(n,r))return!0;return!1}if(o.type==="tuple"){for(const n of o.items)if(Ve(n,r))return!0;return!!(o.rest&&Ve(o.rest,r))}return!1}const cy=(e,t={})=>r=>{const o=Qr({...r,processors:t});return he(e,o),Xr(o,e),en(o,e)},Cn=(e,t)=>r=>{const{libraryOptions:o,target:n}=r??{},i=Qr({...o??{},target:n,io:t,processors:{}});return he(e,i),Xr(i,e),en(i,e)},BE={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},dy=(e,t,r,o)=>{const n=r;n.type="string";const{minimum:i,maximum:a,format:s,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(n.minLength=i),typeof a=="number"&&(n.maxLength=a),s&&(n.format=BE[s]??s,n.format===""&&delete n.format),u&&(n.contentEncoding=u),l&&l.size>0){const c=[...l];c.length===1?n.pattern=c[0].source:c.length>1&&(n.allOf=[...c.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},py=(e,t,r,o)=>{const n=r,{minimum:i,maximum:a,format:s,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:c}=e._zod.bag;typeof s=="string"&&s.includes("int")?n.type="integer":n.type="number",typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c),typeof i=="number"&&(n.minimum=i,typeof c=="number"&&t.target!=="draft-04"&&(c>=i?delete n.minimum:delete n.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u),typeof a=="number"&&(n.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete n.maximum:delete n.exclusiveMaximum)),typeof l=="number"&&(n.multipleOf=l)},fy=(e,t,r,o)=>{r.type="boolean"},my=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},hy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},gy=(e,t,r,o)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},vy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},yy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},by=(e,t,r,o)=>{r.not={}},_y=(e,t,r,o)=>{},wy=(e,t,r,o)=>{},xy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},$y=(e,t,r,o)=>{const n=e._zod.def,i=Du(n.entries);i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},Sy=(e,t,r,o)=>{const n=e._zod.def,i=[];for(const a of n.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];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},Iy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},ky=(e,t,r,o)=>{const n=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},Ey=(e,t,r,o)=>{const n=r,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(n,i)):n.anyOf=l.map(u=>({...i,contentMediaType:u})):Object.assign(n,i)},Ty=(e,t,r,o)=>{r.type="boolean"},Oy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Ny=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Py=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Cy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},jy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Ay=(e,t,r,o)=>{const n=r,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(n.minItems=a),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=he(i.element,t,{...o,path:[...o.path,"items"]})},Ry=(e,t,r,o)=>{const n=r,i=e._zod.def;n.type="object",n.properties={};const a=i.shape;for(const u in a)n.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&&(n.required=Array.from(l)),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=he(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},jl=(e,t,r,o)=>{const n=e._zod.def,i=n.inclusive===!1,a=n.options.map((s,l)=>he(s,t,{...o,path:[...o.path,i?"oneOf":"anyOf",l]}));i?r.oneOf=a:r.anyOf=a},zy=(e,t,r,o)=>{const n=e._zod.def,i=he(n.left,t,{...o,path:[...o.path,"allOf",0]}),a=he(n.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]];r.allOf=l},My=(e,t,r,o)=>{const n=r,i=e._zod.def;n.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"?(n.prefixItems=l,u&&(n.items=u)):t.target==="openapi-3.0"?(n.items={anyOf:l},u&&n.items.anyOf.push(u),n.minItems=l.length,u||(n.maxItems=l.length)):(n.items=l,u&&(n.additionalItems=u));const{minimum:c,maximum:d}=e._zod.bag;typeof c=="number"&&(n.minItems=c),typeof d=="number"&&(n.maxItems=d)},Dy=(e,t,r,o)=>{const n=r,i=e._zod.def;n.type="object",(t.target==="draft-07"||t.target==="draft-2020-12")&&(n.propertyNames=he(i.keyType,t,{...o,path:[...o.path,"propertyNames"]})),n.additionalProperties=he(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})},Uy=(e,t,r,o)=>{const n=e._zod.def,i=he(n.innerType,t,o),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Ly=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType},Zy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},Fy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},qy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},Vy=(e,t,r,o)=>{const n=e._zod.def,i=t.io==="input"?n.in._zod.def.type==="transform"?n.out:n.in:n.out;he(i,t,o);const a=t.seen.get(e);a.ref=i},By=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},Jy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType},Wy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType},Hy=(e,t,r,o)=>{const n=e._zod.innerType;he(n,t,o);const i=t.seen.get(e);i.ref=n},Xs={string:dy,number:py,boolean:fy,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:Ty,custom:Oy,function:Ny,transform:Py,map:Cy,set:jy,array:Ay,object:Ry,union:jl,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 da(e,t){if("_idmap"in e){const o=e,n=Qr({...t,processors:Xs}),i={};for(const l of o._idmap.entries()){const[u,c]=l;he(c,n)}const a={},s={registry:o,uri:t?.uri,defs:i};n.external=s;for(const l of o._idmap.entries()){const[u,c]=l;Xr(n,c),a[u]=en(n,c)}if(Object.keys(i).length>0){const l=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:i}}return{schemas:a}}const r=Qr({...t,processors:Xs});return he(e,r),Xr(r,e),en(r,e)}class JE{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 r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=Qr({processors:Xs,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return he(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),Xr(this.ctx,t);const o=en(this.ctx,t),{"~standard":n,...i}=o;return i}}const WE=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),HE=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:zg,$ZodArray:Zg,$ZodAsyncError:vr,$ZodBase64:Sg,$ZodBase64URL:kg,$ZodBigInt:ol,$ZodBigIntFormat:Cg,$ZodBoolean:nl,$ZodCIDRv4:xg,$ZodCIDRv6:$g,$ZodCUID:cg,$ZodCUID2:dg,$ZodCatch:uv,$ZodCheck:Se,$ZodCheckBigIntFormat:Lh,$ZodCheckEndsWith:Qh,$ZodCheckGreaterThan:el,$ZodCheckIncludes:Kh,$ZodCheckLengthEquals:Jh,$ZodCheckLessThan:Xu,$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:al,$ZodCustom:gv,$ZodCustomStringFormat:Ng,$ZodDate:Lg,$ZodDefault:ov,$ZodDiscriminatedUnion:Wg,$ZodE164:Eg,$ZodEmail:ag,$ZodEmoji:ug,$ZodEncodeError:Bi,$ZodEnum:Qg,$ZodError:Lu,$ZodFile:ev,$ZodFunction:fv,$ZodGUID:og,$ZodIPv4:bg,$ZodIPv6:_g,$ZodISODate:gg,$ZodISODateTime:hg,$ZodISODuration:yg,$ZodISOTime:vg,$ZodIntersection:Hg,$ZodJWT:Og,$ZodKSUID:mg,$ZodLazy:hv,$ZodLiteral:Xg,$ZodMAC:wg,$ZodMap:Kg,$ZodNaN:lv,$ZodNanoID:lg,$ZodNever:Dg,$ZodNonOptional:av,$ZodNull:Rg,$ZodNullable:nv,$ZodNumber:rl,$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:ge,$ZodSuccess:sv,$ZodSymbol:jg,$ZodTemplateLiteral:pv,$ZodTransform:tv,$ZodTuple:il,$ZodType:X,$ZodULID:pg,$ZodURL:sg,$ZodUUID:ig,$ZodUndefined:Ag,$ZodUnion:Ki,$ZodUnknown:Mg,$ZodVoid:Ug,$ZodXID:fg,$ZodXor:Jg,$brand:Cm,$constructor:S,$input:xv,$output:wv,Doc:rg,JSONSchema:WE,JSONSchemaGenerator:JE,NEVER:Mu,TimePrecision:Ev,_any:Hv,_array:ty,_base64:Sl,_base64url:Il,_bigint:Zv,_boolean:Uv,_catch:UE,_check:ay,_cidrv4:xl,_cidrv6:$l,_coercedBigint:Fv,_coercedBoolean:Lv,_coercedDate:Xv,_coercedNumber:jv,_coercedString:Iv,_cuid:hl,_cuid2:gl,_custom:ny,_date:Qv,_decode:Vu,_decodeAsync:Ju,_default:zE,_discriminatedUnion:SE,_e164:kl,_email:ul,_emoji:fl,_encode:qu,_encodeAsync:Bu,_endsWith:oa,_enum:NE,_file:ry,_float32:Rv,_float64:zv,_gt:ar,_gte:We,_guid:fi,_includes:ra,_int:Av,_int32:Mv,_int64:qv,_intersection:IE,_ipv4:_l,_ipv6:wl,_isoDate:Ov,_isoDateTime:Tv,_isoDuration:Pv,_isoTime:Nv,_jwt:El,_ksuid:bl,_lazy:qE,_length:co,_literal:CE,_lowercase:ea,_lt:ir,_lte:st,_mac:kv,_map:TE,_max:st,_maxLength:lo,_maxSize:uo,_mime:ia,_min:We,_minLength:br,_minSize:Yr,_multipleOf:Kr,_nan:ey,_nanoid:ml,_nativeEnum:PE,_negative:Ol,_never:Kv,_nonnegative:Pl,_nonoptional:ME,_nonpositive:Nl,_normalize:aa,_null:Wv,_nullable:RE,_number:Cv,_optional:AE,_overwrite:Ht,_parse:eo,_parseAsync:to,_pipe:LE,_positive:Tl,_promise:VE,_property:Cl,_readonly:ZE,_record:EE,_refine:oy,_regex:Xi,_safeDecode:Hu,_safeDecodeAsync:Ku,_safeEncode:Wu,_safeEncodeAsync:Gu,_safeParse:ro,_safeParseAsync:no,_set:OE,_size:Qi,_slugify:ca,_startsWith:na,_string:Sv,_stringFormat:po,_stringbool:ly,_success:DE,_superRefine:iy,_symbol:Bv,_templateLiteral:FE,_toLowerCase:ua,_toUpperCase:la,_transform:jE,_trim:sa,_tuple:kE,_uint32:Dv,_uint64:Vv,_ulid:vl,_undefined:Jv,_union:xE,_unknown:Gv,_uppercase:ta,_url:Yi,_uuid:ll,_uuidv4:cl,_uuidv6:dl,_uuidv7:pl,_void:Yv,_xid:yl,_xor:$E,clone:dt,config:De,createStandardJSONSchemaMethod:Cn,createToJSONSchemaMethod:cy,decode:nI,decodeAsync:iI,describe:sy,encode:rI,encodeAsync:oI,extractDefs:Xr,finalize:en,flattenError:Zu,formatError:Fu,globalConfig:li,globalRegistry:wt,initializeContext:Qr,isValidBase64:tl,isValidBase64URL:Ig,isValidJWT:Tg,locales:_v,meta:uy,parse:Ks,parseAsync:Ys,prettifyError:Xm,process:he,regexes:Qu,registry:sl,safeDecode:sI,safeDecodeAsync:lI,safeEncode:aI,safeEncodeAsync:uI,safeParse:eh,safeParseAsync:th,toDotPath:Qm,toJSONSchema:da,treeifyError:Ym,util:Gm,version:ng},Symbol.toStringTag,{value:"Module"})),GE=Object.freeze(Object.defineProperty({__proto__:null,endsWith:oa,gt:ar,gte:We,includes:ra,length:co,lowercase:ea,lt:ir,lte:st,maxLength:lo,maxSize:uo,mime:ia,minLength:br,minSize:Yr,multipleOf:Kr,negative:Ol,nonnegative:Pl,nonpositive:Nl,normalize:aa,overwrite:Ht,positive:Tl,property:Cl,regex:Xi,size:Qi,slugify:ca,startsWith:na,toLowerCase:ua,toUpperCase:la,trim:sa,uppercase:ta},Symbol.toStringTag,{value:"Module"})),Al=S("ZodISODateTime",(e,t)=>{hg.init(e,t),ve.init(e,t)});function Gy(e){return Tv(Al,e)}const Rl=S("ZodISODate",(e,t)=>{gg.init(e,t),ve.init(e,t)});function Ky(e){return Ov(Rl,e)}const zl=S("ZodISOTime",(e,t)=>{vg.init(e,t),ve.init(e,t)});function Yy(e){return Nv(zl,e)}const Ml=S("ZodISODuration",(e,t)=>{yg.init(e,t),ve.init(e,t)});function Qy(e){return Pv(Ml,e)}const Xy=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:Rl,ZodISODateTime:Al,ZodISODuration:Ml,ZodISOTime:zl,date:Ky,datetime:Gy,duration:Qy,time:Yy},Symbol.toStringTag,{value:"Module"})),eb=(e,t)=>{Lu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Fu(e,r)},flatten:{value:r=>Zu(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,ci,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,ci,2)}},isEmpty:{get(){return e.issues.length===0}}})},KE=S("ZodError",eb),ot=S("ZodError",eb,{Parent:Error}),tb=eo(ot),rb=to(ot),nb=ro(ot),pa=no(ot),ob=qu(ot),ib=Vu(ot),ab=Bu(ot),sb=Ju(ot),ub=Wu(ot),lb=Hu(ot),cb=Gu(ot),db=Ku(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=cy(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(Wt(t,{checks:[...t.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]})),e.clone=(r,o)=>dt(e,r,o),e.brand=()=>e,e.register=((r,o)=>(r.add(e,o),e)),e.parse=(r,o)=>tb(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>nb(e,r,o),e.parseAsync=async(r,o)=>rb(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>pa(e,r,o),e.spa=e.safeParseAsync,e.encode=(r,o)=>ob(e,r,o),e.decode=(r,o)=>ib(e,r,o),e.encodeAsync=async(r,o)=>ab(e,r,o),e.decodeAsync=async(r,o)=>sb(e,r,o),e.safeEncode=(r,o)=>ub(e,r,o),e.safeDecode=(r,o)=>lb(e,r,o),e.safeEncodeAsync=async(r,o)=>cb(e,r,o),e.safeDecodeAsync=async(r,o)=>db(e,r,o),e.refine=(r,o)=>e.check(_c(r,o)),e.superRefine=r=>e.check(wc(r)),e.overwrite=r=>e.check(Ht(r)),e.optional=()=>ee(e),e.nullable=()=>An(e),e.nullish=()=>ee(An(e)),e.nonoptional=r=>lc(e,r),e.array=()=>R(e),e.or=r=>G([e,r]),e.and=r=>Kl(e,r),e.transform=r=>Rn(e,Ra(r)),e.default=r=>ac(e,r),e.prefault=r=>uc(e,r),e.catch=r=>pc(e,r),e.pipe=r=>Rn(e,r),e.readonly=()=>hc(e),e.describe=r=>{const o=e.clone();return wt.add(o,{description:r}),o},Object.defineProperty(e,"description",{get(){return wt.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return wt.get(e);const o=e.clone();return wt.add(o,r[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),fa=S("_ZodString",(e,t)=>{so.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>dy(e,o,n);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.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(lo(...o)),e.length=(...o)=>e.check(co(...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())}),fo=S("ZodString",(e,t)=>{so.init(e,t),fa.init(e,t),e.email=r=>e.check(ul(ma,r)),e.url=r=>e.check(Yi(mo,r)),e.jwt=r=>e.check(El(Na,r)),e.emoji=r=>e.check(fl(ha,r)),e.guid=r=>e.check(fi(jn,r)),e.uuid=r=>e.check(ll(Ct,r)),e.uuidv4=r=>e.check(cl(Ct,r)),e.uuidv6=r=>e.check(dl(Ct,r)),e.uuidv7=r=>e.check(pl(Ct,r)),e.nanoid=r=>e.check(ml(ga,r)),e.guid=r=>e.check(fi(jn,r)),e.cuid=r=>e.check(hl(va,r)),e.cuid2=r=>e.check(gl(ya,r)),e.ulid=r=>e.check(vl(ba,r)),e.base64=r=>e.check(Sl(ka,r)),e.base64url=r=>e.check(Il(Ta,r)),e.xid=r=>e.check(yl(_a,r)),e.ksuid=r=>e.check(bl(wa,r)),e.ipv4=r=>e.check(_l(xa,r)),e.ipv6=r=>e.check(wl($a,r)),e.cidrv4=r=>e.check(xl(Sa,r)),e.cidrv6=r=>e.check($l(Ia,r)),e.e164=r=>e.check(kl(Oa,r)),e.datetime=r=>e.check(Gy(r)),e.date=r=>e.check(Ky(r)),e.time=r=>e.check(Yy(r)),e.duration=r=>e.check(Qy(r))});function w(e){return Sv(fo,e)}const ve=S("ZodStringFormat",(e,t)=>{ge.init(e,t),fa.init(e,t)}),ma=S("ZodEmail",(e,t)=>{ag.init(e,t),ve.init(e,t)});function pb(e){return ul(ma,e)}const jn=S("ZodGUID",(e,t)=>{og.init(e,t),ve.init(e,t)});function fb(e){return fi(jn,e)}const Ct=S("ZodUUID",(e,t)=>{ig.init(e,t),ve.init(e,t)});function mb(e){return ll(Ct,e)}function hb(e){return cl(Ct,e)}function gb(e){return dl(Ct,e)}function vb(e){return pl(Ct,e)}const mo=S("ZodURL",(e,t)=>{sg.init(e,t),ve.init(e,t)});function yb(e){return Yi(mo,e)}function bb(e){return Yi(mo,{protocol:/^https?$/,hostname:_h,...P(e)})}const ha=S("ZodEmoji",(e,t)=>{ug.init(e,t),ve.init(e,t)});function _b(e){return fl(ha,e)}const ga=S("ZodNanoID",(e,t)=>{lg.init(e,t),ve.init(e,t)});function wb(e){return ml(ga,e)}const va=S("ZodCUID",(e,t)=>{cg.init(e,t),ve.init(e,t)});function xb(e){return hl(va,e)}const ya=S("ZodCUID2",(e,t)=>{dg.init(e,t),ve.init(e,t)});function $b(e){return gl(ya,e)}const ba=S("ZodULID",(e,t)=>{pg.init(e,t),ve.init(e,t)});function Sb(e){return vl(ba,e)}const _a=S("ZodXID",(e,t)=>{fg.init(e,t),ve.init(e,t)});function Ib(e){return yl(_a,e)}const wa=S("ZodKSUID",(e,t)=>{mg.init(e,t),ve.init(e,t)});function kb(e){return bl(wa,e)}const xa=S("ZodIPv4",(e,t)=>{bg.init(e,t),ve.init(e,t)});function Eb(e){return _l(xa,e)}const Dl=S("ZodMAC",(e,t)=>{wg.init(e,t),ve.init(e,t)});function Tb(e){return kv(Dl,e)}const $a=S("ZodIPv6",(e,t)=>{_g.init(e,t),ve.init(e,t)});function Ob(e){return wl($a,e)}const Sa=S("ZodCIDRv4",(e,t)=>{xg.init(e,t),ve.init(e,t)});function Nb(e){return xl(Sa,e)}const Ia=S("ZodCIDRv6",(e,t)=>{$g.init(e,t),ve.init(e,t)});function Pb(e){return $l(Ia,e)}const ka=S("ZodBase64",(e,t)=>{Sg.init(e,t),ve.init(e,t)});function Ea(e){return Sl(ka,e)}const Ta=S("ZodBase64URL",(e,t)=>{kg.init(e,t),ve.init(e,t)});function Cb(e){return Il(Ta,e)}const Oa=S("ZodE164",(e,t)=>{Eg.init(e,t),ve.init(e,t)});function jb(e){return kl(Oa,e)}const Na=S("ZodJWT",(e,t)=>{Og.init(e,t),ve.init(e,t)});function Ab(e){return El(Na,e)}const un=S("ZodCustomStringFormat",(e,t)=>{Ng.init(e,t),ve.init(e,t)});function Rb(e,t,r={}){return po(un,e,t,r)}function zb(e){return po(un,"hostname",bh,e)}function Mb(e){return po(un,"hex",zh,e)}function Db(e,t){const r=t?.enc??"hex",o=`${e}_${r}`,n=Qu[o];if(!n)throw new Error(`Unrecognized hash format: ${o}`);return po(un,o,n,t)}const ho=S("ZodNumber",(e,t)=>{rl.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>py(e,o,n),e.gt=(o,n)=>e.check(ar(o,n)),e.gte=(o,n)=>e.check(We(o,n)),e.min=(o,n)=>e.check(We(o,n)),e.lt=(o,n)=>e.check(ir(o,n)),e.lte=(o,n)=>e.check(st(o,n)),e.max=(o,n)=>e.check(st(o,n)),e.int=o=>e.check(mi(o)),e.safe=o=>e.check(mi(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,n)=>e.check(Kr(o,n)),e.step=(o,n)=>e.check(Kr(o,n)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function q(e){return Cv(ho,e)}const Tr=S("ZodNumberFormat",(e,t)=>{Pg.init(e,t),ho.init(e,t)});function mi(e){return Av(Tr,e)}function Ub(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)}const go=S("ZodBoolean",(e,t)=>{nl.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>fy(e,r,o)});function pe(e){return Uv(go,e)}const vo=S("ZodBigInt",(e,t)=>{ol.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>my(e,o),e.gte=(o,n)=>e.check(We(o,n)),e.min=(o,n)=>e.check(We(o,n)),e.gt=(o,n)=>e.check(ar(o,n)),e.gte=(o,n)=>e.check(We(o,n)),e.min=(o,n)=>e.check(We(o,n)),e.lt=(o,n)=>e.check(ir(o,n)),e.lte=(o,n)=>e.check(st(o,n)),e.max=(o,n)=>e.check(st(o,n)),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,n)=>e.check(Kr(o,n));const r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function qb(e){return Zv(vo,e)}const Pa=S("ZodBigIntFormat",(e,t)=>{Cg.init(e,t),vo.init(e,t)});function Vb(e){return qv(Pa,e)}function Bb(e){return Vv(Pa,e)}const Ul=S("ZodSymbol",(e,t)=>{jg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>hy(e,r)});function Jb(e){return Bv(Ul,e)}const Ll=S("ZodUndefined",(e,t)=>{Ag.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>vy(e,r)});function Wb(e){return Jv(Ll,e)}const Zl=S("ZodNull",(e,t)=>{Rg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>gy(e,r,o)});function yo(e){return Wv(Zl,e)}const Fl=S("ZodAny",(e,t)=>{zg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>_y()});function Pe(){return Hv(Fl)}const ql=S("ZodUnknown",(e,t)=>{Mg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>wy()});function $e(){return Gv(ql)}const Vl=S("ZodNever",(e,t)=>{Dg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>by(e,r,o)});function Ca(e){return Kv(Vl,e)}const Bl=S("ZodVoid",(e,t)=>{Ug.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>yy(e,r)});function Hb(e){return Yv(Bl,e)}const ja=S("ZodDate",(e,t)=>{Lg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>xy(e,o),e.min=(o,n)=>e.check(We(o,n)),e.max=(o,n)=>e.check(st(o,n));const r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function Gb(e){return Qv(ja,e)}const Jl=S("ZodArray",(e,t)=>{Zg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ay(e,r,o,n),e.element=t.element,e.min=(r,o)=>e.check(br(r,o)),e.nonempty=r=>e.check(br(1,r)),e.max=(r,o)=>e.check(lo(r,o)),e.length=(r,o)=>e.check(co(r,o)),e.unwrap=()=>e.element});function R(e,t){return ty(Jl,e,t)}function Kb(e){const t=e._zod.def.shape;return dr(Object.keys(t))}const bo=S("ZodObject",(e,t)=>{Bg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ry(e,r,o,n),ne(e,"shape",()=>t.shape),e.keyof=()=>dr(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),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=r=>Fm(e,r),e.safeExtend=r=>qm(e,r),e.merge=r=>Vm(e,r),e.pick=r=>Lm(e,r),e.omit=r=>Zm(e,r),e.partial=(...r)=>Bm(za,e,r[0]),e.required=(...r)=>Jm(Ma,e,r[0])});function E(e,t){const r={type:"object",shape:e??{},...P(t)};return new bo(r)}function be(e,t){return new bo({type:"object",shape:e,catchall:Ca(),...P(t)})}function er(e,t){return new bo({type:"object",shape:e,catchall:$e(),...P(t)})}const _o=S("ZodUnion",(e,t)=>{Ki.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>jl(e,r,o,n),e.options=t.options});function G(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=(r,o,n)=>jl(e,r,o,n),e.options=t.options});function Yb(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 Aa(e,t,r){return new Hl({type:"union",options:t,discriminator:e,...P(r)})}const Gl=S("ZodIntersection",(e,t)=>{Hg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>zy(e,r,o,n)});function Kl(e,t){return new Gl({type:"intersection",left:e,right:t})}const Yl=S("ZodTuple",(e,t)=>{il.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>My(e,r,o,n),e.rest=r=>e.clone({...e._zod.def,rest:r})});function Ql(e,t,r){const o=t instanceof X,n=o?r:t,i=o?t:null;return new Yl({type:"tuple",items:e,rest:i,...P(n)})}const wo=S("ZodRecord",(e,t)=>{Gg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Dy(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function Xe(e,t,r){return new wo({type:"record",keyType:e,valueType:t,...P(r)})}function Qb(e,t,r){const o=dt(e);return o._zod.values=void 0,new wo({type:"record",keyType:o,valueType:t,...P(r)})}function Xb(e,t,r){return new wo({type:"record",keyType:e,valueType:t,mode:"loose",...P(r)})}const Xl=S("ZodMap",(e,t)=>{Kg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Cy(e,r),e.keyType=t.keyType,e.valueType=t.valueType});function e_(e,t,r){return new Xl({type:"map",keyType:e,valueType:t,...P(r)})}const ec=S("ZodSet",(e,t)=>{Yg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>jy(e,r),e.min=(...r)=>e.check(Yr(...r)),e.nonempty=r=>e.check(Yr(1,r)),e.max=(...r)=>e.check(uo(...r)),e.size=(...r)=>e.check(Qi(...r))});function t_(e,t){return new ec({type:"set",valueType:e,...P(t)})}const tn=S("ZodEnum",(e,t)=>{Qg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>$y(e,o,n),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{const i={};for(const a of o)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new tn({...t,checks:[],...P(n),entries:i})},e.exclude=(o,n)=>{const i={...t.entries};for(const a of o)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new tn({...t,checks:[],...P(n),entries:i})}});function dr(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new tn({type:"enum",entries:r,...P(t)})}function r_(e,t){return new tn({type:"enum",entries:e,...P(t)})}const tc=S("ZodLiteral",(e,t)=>{Xg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Sy(e,r,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),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ey(e,r,o),e.min=(r,o)=>e.check(Yr(r,o)),e.max=(r,o)=>e.check(uo(r,o)),e.mime=(r,o)=>e.check(ia(Array.isArray(r)?r:[r],o))});function n_(e){return ry(rc,e)}const nc=S("ZodTransform",(e,t)=>{tv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Py(e,r),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Bi(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(Hr(i,r.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(Hr(a))}};const n=t.transform(r.value,r);return n instanceof Promise?n.then(i=>(r.value=i,r)):(r.value=n,r)}});function Ra(e){return new nc({type:"transform",transform:e})}const za=S("ZodOptional",(e,t)=>{rv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function ee(e){return new za({type:"optional",innerType:e})}const oc=S("ZodNullable",(e,t)=>{nv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Uy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function An(e){return new oc({type:"nullable",innerType:e})}function o_(e){return ee(An(e))}const ic=S("ZodDefault",(e,t)=>{ov.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Zy(e,r,o,n),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():Wi(t)}})}const sc=S("ZodPrefault",(e,t)=>{iv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Fy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function uc(e,t){return new sc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Wi(t)}})}const Ma=S("ZodNonOptional",(e,t)=>{av.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ly(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function lc(e,t){return new Ma({type:"nonoptional",innerType:e,...P(t)})}const cc=S("ZodSuccess",(e,t)=>{sv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ty(e,r,o),e.unwrap=()=>e._zod.def.innerType});function i_(e){return new cc({type:"success",innerType:e})}const dc=S("ZodCatch",(e,t)=>{uv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pc(e,t){return new dc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const fc=S("ZodNaN",(e,t)=>{lv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Iy(e,r)});function a_(e){return ey(fc,e)}const Da=S("ZodPipe",(e,t)=>{cv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Vy(e,r,o,n),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),al.init(e,t)});function s_(e,t,r){return new Ua({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}const mc=S("ZodReadonly",(e,t)=>{dv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>By(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function hc(e){return new mc({type:"readonly",innerType:e})}const gc=S("ZodTemplateLiteral",(e,t)=>{pv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ky(e,r,o)});function u_(e,t){return new gc({type:"template_literal",parts:e,...P(t)})}const vc=S("ZodLazy",(e,t)=>{hv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hy(e,r,o,n),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),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function l_(e){return new yc({type:"promise",innerType:e})}const bc=S("ZodFunction",(e,t)=>{fv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ny(e,r)});function hi(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),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Oy(e,r)});function c_(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 d_=sy,p_=uy;function Rt(e,t={error:`Input not instance of ${e.name}`}){const r=new $o({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...P(t)});return r._zod.bag.Class=e,r}const f_=(...e)=>ly({Codec:Ua,Boolean:go,String:fo},...e);function m_(e){const t=xo(()=>G([w(e),q(),pe(),yo(),R(t),Xe(w(),t)]));return t}function h_(e,t){return Rn(Ra(e),t)}const YE=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:Fl,ZodArray:Jl,ZodBase64:ka,ZodBase64URL:Ta,ZodBigInt:vo,ZodBigIntFormat:Pa,ZodBoolean:go,ZodCIDRv4:Sa,ZodCIDRv6:Ia,ZodCUID:va,ZodCUID2:ya,ZodCatch:dc,ZodCodec:Ua,ZodCustom:$o,ZodCustomStringFormat:un,ZodDate:ja,ZodDefault:ic,ZodDiscriminatedUnion:Hl,ZodE164:Oa,ZodEmail:ma,ZodEmoji:ha,ZodEnum:tn,ZodFile:rc,ZodFunction:bc,ZodGUID:jn,ZodIPv4:xa,ZodIPv6:$a,ZodIntersection:Gl,ZodJWT:Na,ZodKSUID:wa,ZodLazy:vc,ZodLiteral:tc,ZodMAC:Dl,ZodMap:Xl,ZodNaN:fc,ZodNanoID:ga,ZodNever:Vl,ZodNonOptional:Ma,ZodNull:Zl,ZodNullable:oc,ZodNumber:ho,ZodNumberFormat:Tr,ZodObject:bo,ZodOptional:za,ZodPipe:Da,ZodPrefault:sc,ZodPromise:yc,ZodReadonly:mc,ZodRecord:wo,ZodSet:ec,ZodString:fo,ZodStringFormat:ve,ZodSuccess:cc,ZodSymbol:Ul,ZodTemplateLiteral:gc,ZodTransform:nc,ZodTuple:Yl,ZodType:re,ZodULID:ba,ZodURL:mo,ZodUUID:Ct,ZodUndefined:Ll,ZodUnion:_o,ZodUnknown:ql,ZodVoid:Bl,ZodXID:_a,ZodXor:Wl,_ZodString:fa,_default:ac,_function:hi,any:Pe,array:R,base64:Ea,base64url:Cb,bigint:qb,boolean:pe,catch:pc,check:c_,cidrv4:Nb,cidrv6:Pb,codec:s_,cuid:xb,cuid2:$b,custom:So,date:Gb,describe:d_,discriminatedUnion:Aa,e164:jb,email:pb,emoji:_b,enum:dr,file:n_,float32:Ub,float64:Lb,function:hi,guid:fb,hash:Db,hex:Mb,hostname:zb,httpUrl:bb,instanceof:Rt,int:mi,int32:Zb,int64:Vb,intersection:Kl,ipv4:Eb,ipv6:Ob,json:m_,jwt:Ab,keyof:Kb,ksuid:kb,lazy:xo,literal:C,looseObject:er,looseRecord:Xb,mac:Tb,map:e_,meta:p_,nan:a_,nanoid:wb,nativeEnum:r_,never:Ca,nonoptional:lc,null:yo,nullable:An,nullish:o_,number:q,object:E,optional:ee,partialRecord:Qb,pipe:Rn,prefault:uc,preprocess:h_,promise:l_,readonly:hc,record:Xe,refine:_c,set:t_,strictObject:be,string:w,stringFormat:Rb,stringbool:f_,success:i_,superRefine:wc,symbol:Jb,templateLiteral:u_,transform:Ra,tuple:Ql,uint32:Fb,uint64:Bb,ulid:Sb,undefined:Wb,union:G,unknown:$e,url:yb,uuid:mb,uuidv4:hb,uuidv6:gb,uuidv7:vb,void:Hb,xid:Ib,xor:Yb},Symbol.toStringTag,{value:"Module"})),g_={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 QE(e){De({customError:e})}function XE(){return De().customError}var eu;eu||(eu={});const M={...YE,...GE,iso:Xy};function eT(e,t){const r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function tT(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");const r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;const o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){const n=r[1];if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function v_(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 n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return M.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);const i=tT(n,t),a=Me(i,t);return t.refs.set(n,a),t.processing.delete(n),a}if(e.enum!==void 0){const n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return M.null();if(n.length===0)return M.never();if(n.length===1)return M.literal(n[0]);if(n.every(a=>typeof a=="string"))return M.enum(n);const i=n.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 r=e.type;if(Array.isArray(r)){const n=r.map(i=>{const a={...e,type:i};return v_(a,t)});return n.length===0?M.never():n.length===1?n[0]:M.union(n)}if(!r)return M.any();let o;switch(r){case"string":{let n=M.string();if(e.format){const i=e.format;i==="email"?n=n.check(M.email()):i==="uri"||i==="uri-reference"?n=n.check(M.url()):i==="uuid"||i==="guid"?n=n.check(M.uuid()):i==="date-time"?n=n.check(M.iso.datetime()):i==="date"?n=n.check(M.iso.date()):i==="time"?n=n.check(M.iso.time()):i==="duration"?n=n.check(M.iso.duration()):i==="ipv4"?n=n.check(M.ipv4()):i==="ipv6"?n=n.check(M.ipv6()):i==="mac"?n=n.check(M.mac()):i==="cidr"?n=n.check(M.cidrv4()):i==="cidr-v6"?n=n.check(M.cidrv6()):i==="base64"?n=n.check(M.base64()):i==="base64url"?n=n.check(M.base64url()):i==="e164"?n=n.check(M.e164()):i==="jwt"?n=n.check(M.jwt()):i==="emoji"?n=n.check(M.emoji()):i==="nanoid"?n=n.check(M.nanoid()):i==="cuid"?n=n.check(M.cuid()):i==="cuid2"?n=n.check(M.cuid2()):i==="ulid"?n=n.check(M.ulid()):i==="xid"?n=n.check(M.xid()):i==="ksuid"&&(n=n.check(M.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),o=n;break}case"number":case"integer":{let n=r==="integer"?M.number().int():M.number();typeof e.minimum=="number"&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),o=n;break}case"boolean":{o=M.boolean();break}case"null":{o=M.null();break}case"object":{const n={},i=e.properties||{},a=new Set(e.required||[]);for(const[l,u]of Object.entries(i)){const c=Me(u,t);n[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(n).length===0){o=M.record(l,u);break}const c=M.object(n).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(n).length>0&&d.push(M.object(n).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(n);e.additionalProperties===!1?o=s.strict():typeof e.additionalProperties=="object"?o=s.catchall(Me(e.additionalProperties,t)):o=s.passthrough();break}case"array":{const n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){const a=n.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: ${r}`)}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 r=v_(e,t);const o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){const n=e.anyOf.map(a=>Me(a,t)),i=M.union(n);r=o?M.intersection(r,i):i}if(e.oneOf&&Array.isArray(e.oneOf)){const n=e.oneOf.map(a=>Me(a,t)),i=M.xor(n);r=o?M.intersection(r,i):i}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:M.any();else{let n=o?r:Me(e.allOf[0],t);const i=o?0:1;for(let a=i;a<e.allOf.length;a++)n=M.intersection(n,Me(e.allOf[a],t));r=n}return e.nullable===!0&&t.version==="openapi-3.0"&&(r=M.nullable(r)),e.readOnly===!0&&(r=M.readonly(r)),r}function rT(e,t){if(typeof e=="boolean")return e?M.any():M.never();const r=eT(e,t?.defaultTarget),o=e.$defs||e.definitions||{};return Me(e,{version:r,defs:o,refs:new Map,processing:new Set,rootSchema:e})}function nT(e){return Iv(fo,e)}function oT(e){return jv(ho,e)}function iT(e){return Lv(go,e)}function aT(e){return Fv(vo,e)}function sT(e){return Xv(ja,e)}const uT=Object.freeze(Object.defineProperty({__proto__:null,bigint:aT,boolean:iT,date:sT,number:oT,string:nT},Symbol.toStringTag,{value:"Module"}));De(vv());const gi=Object.freeze(Object.defineProperty({__proto__:null,$brand:Cm,$input:xv,$output:wv,NEVER:Mu,TimePrecision:Ev,ZodAny:Fl,ZodArray:Jl,ZodBase64:ka,ZodBase64URL:Ta,ZodBigInt:vo,ZodBigIntFormat:Pa,ZodBoolean:go,ZodCIDRv4:Sa,ZodCIDRv6:Ia,ZodCUID:va,ZodCUID2:ya,ZodCatch:dc,ZodCodec:Ua,ZodCustom:$o,ZodCustomStringFormat:un,ZodDate:ja,ZodDefault:ic,ZodDiscriminatedUnion:Hl,ZodE164:Oa,ZodEmail:ma,ZodEmoji:ha,ZodEnum:tn,ZodError:KE,ZodFile:rc,get ZodFirstPartyTypeKind(){return eu},ZodFunction:bc,ZodGUID:jn,ZodIPv4:xa,ZodIPv6:$a,ZodISODate:Rl,ZodISODateTime:Al,ZodISODuration:Ml,ZodISOTime:zl,ZodIntersection:Gl,ZodIssueCode:g_,ZodJWT:Na,ZodKSUID:wa,ZodLazy:vc,ZodLiteral:tc,ZodMAC:Dl,ZodMap:Xl,ZodNaN:fc,ZodNanoID:ga,ZodNever:Vl,ZodNonOptional:Ma,ZodNull:Zl,ZodNullable:oc,ZodNumber:ho,ZodNumberFormat:Tr,ZodObject:bo,ZodOptional:za,ZodPipe:Da,ZodPrefault:sc,ZodPromise:yc,ZodReadonly:mc,ZodRealError:ot,ZodRecord:wo,ZodSet:ec,ZodString:fo,ZodStringFormat:ve,ZodSuccess:cc,ZodSymbol:Ul,ZodTemplateLiteral:gc,ZodTransform:nc,ZodTuple:Yl,ZodType:re,ZodULID:ba,ZodURL:mo,ZodUUID:Ct,ZodUndefined:Ll,ZodUnion:_o,ZodUnknown:ql,ZodVoid:Bl,ZodXID:_a,ZodXor:Wl,_ZodString:fa,_default:ac,_function:hi,any:Pe,array:R,base64:Ea,base64url:Cb,bigint:qb,boolean:pe,catch:pc,check:c_,cidrv4:Nb,cidrv6:Pb,clone:dt,codec:s_,coerce:uT,config:De,core:HE,cuid:xb,cuid2:$b,custom:So,date:Gb,decode:ib,decodeAsync:sb,describe:d_,discriminatedUnion:Aa,e164:jb,email:pb,emoji:_b,encode:ob,encodeAsync:ab,endsWith:oa,enum:dr,file:n_,flattenError:Zu,float32:Ub,float64:Lb,formatError:Fu,fromJSONSchema:rT,function:hi,getErrorMap:XE,globalRegistry:wt,gt:ar,gte:We,guid:fb,hash:Db,hex:Mb,hostname:zb,httpUrl:bb,includes:ra,instanceof:Rt,int:mi,int32:Zb,int64:Vb,intersection:Kl,ipv4:Eb,ipv6:Ob,iso:Xy,json:m_,jwt:Ab,keyof:Kb,ksuid:kb,lazy:xo,length:co,literal:C,locales:_v,looseObject:er,looseRecord:Xb,lowercase:ea,lt:ir,lte:st,mac:Tb,map:e_,maxLength:lo,maxSize:uo,meta:p_,mime:ia,minLength:br,minSize:Yr,multipleOf:Kr,nan:a_,nanoid:wb,nativeEnum:r_,negative:Ol,never:Ca,nonnegative:Pl,nonoptional:lc,nonpositive:Nl,normalize:aa,null:yo,nullable:An,nullish:o_,number:q,object:E,optional:ee,overwrite:Ht,parse:tb,parseAsync:rb,partialRecord:Qb,pipe:Rn,positive:Tl,prefault:uc,preprocess:h_,prettifyError:Xm,promise:l_,property:Cl,readonly:hc,record:Xe,refine:_c,regex:Xi,regexes:Qu,registry:sl,safeDecode:lb,safeDecodeAsync:db,safeEncode:ub,safeEncodeAsync:cb,safeParse:nb,safeParseAsync:pa,set:t_,setErrorMap:QE,size:Qi,slugify:ca,startsWith:na,strictObject:be,string:w,stringFormat:Rb,stringbool:f_,success:i_,superRefine:wc,symbol:Jb,templateLiteral:u_,toJSONSchema:da,toLowerCase:ua,toUpperCase:la,transform:Ra,treeifyError:Ym,trim:sa,tuple:Ql,uint32:Fb,uint64:Bb,ulid:Sb,undefined:Wb,union:G,unknown:$e,uppercase:ta,url:yb,util:Gm,uuid:mb,uuidv4:hb,uuidv6:gb,uuidv7:vb,void:Hb,xid:Ib,xor:Yb},Symbol.toStringTag,{value:"Module"}));var zn;(function(e){e.assertEqual=n=>{};function t(n){}e.assertIs=t;function r(n){throw new Error}e.assertNever=r,e.arrayToEnum=n=>{const i={};for(const a of n)i[a]=a;return i},e.getValidEnumValues=n=>{const i=e.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),a={};for(const s of i)a[s]=n[s];return e.objectValues(a)},e.objectValues=n=>e.objectKeys(n).map(function(i){return n[i]}),e.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const i=[];for(const a in n)Object.prototype.hasOwnProperty.call(n,a)&&i.push(a);return i},e.find=(n,i)=>{for(const a of n)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function o(n,i=" | "){return n.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=o,e.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(zn||(zn={}));var Qd;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(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 vi 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 r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(i){return i.message},o={_errors:[]},n=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)o._errors.push(r(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(r(a))):s[u]=s[u]||{_errors:[]},s=s[u],l++}}};return n(this),o}static assert(t){if(!(t instanceof vi))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=r=>r.message){const r=Object.create(null),o=[];for(const n of this.issues)if(n.path.length>0){const i=n.path[0];r[i]=r[i]||[],r[i].push(t(n))}else o.push(t(n));return{formErrors:o,fieldErrors:r}}get formErrors(){return this.flatten()}}vi.create=e=>new vi(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 lT=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const n=()=>{const i=r.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=r[Math.random()*i|0];return a.join("")};if(e==null)return n;if(r.includes(o))throw new Vi({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${r}".`});return()=>`${e}${o}${n()}`};lT();function y_(e=globalThis){var t,r,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(r=e.process)==null?void 0:r.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function cT(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((r,o)=>{t[o.toLowerCase()]=r});else{Array.isArray(e)||(e=Object.entries(e));for(const[r,o]of e)o!=null&&(t[r.toLowerCase()]=o)}return t}function b_(e,...t){const r=new Headers(cT(e)),o=r.get("user-agent")||"";return r.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}var dT=Symbol.for("vercel.ai.validator");function pT(e){return{...e,type:"dynamic"}}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");var fT=Symbol.for("vercel.ai.schema");function mT(e,{validate:t}={}){return{[fT]:!0,_type:void 0,[dT]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}let xc;xc=globalThis.crypto;async function hT(e){return(await xc).getRandomValues(new Uint8Array(e))}async function gT(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";let r="";const o=await hT(e);for(let n=0;n<e;n++){const i=o[n]%t.length;r+=t[i]}return r}async function vT(e){return await gT(e)}async function yT(e){const t=await(await xc).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function bT(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;const t=await vT(e),r=await yT(t);return{code_verifier:t,code_challenge:r}}var _T="AI_MCPClientError",__=`vercel.ai.error.${_T}`,wT=Symbol.for(__),ep,tp,se=class extends(tp=Y,ep=wT,tp){constructor({name:e="MCPClientError",message:t,cause:r,data:o,code:n}){super({name:e,message:t,cause:r}),this[ep]=!0,this.data=o,this.code=n}static isInstance(e){return Y.hasMarker(e,__)}},ln="2025-06-18",xT=[ln,"2025-03-26","2024-11-05"],$T=er({name:w(),version:w()}),La=er({_meta:ee(E({}).loose())}),Vt=La,w_=E({method:w(),params:ee(La)}),x_=E({applyDefaults:ee(pe())}).loose(),ST=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(x_)});E({elicitation:ee(x_)}).loose();var IT=Vt.extend({protocolVersion:w(),capabilities:ST,serverInfo:$T,instructions:ee(w())}),$c=Vt.extend({nextCursor:ee(w())}),kT=E({name:w(),description:ee(w()),inputSchema:E({type:C("object"),properties:ee(E({}).loose())}).loose()}).loose(),ET=$c.extend({tools:R(kT)}),$_=E({type:C("text"),text:w()}).loose(),S_=E({type:C("image"),data:Ea(),mimeType:w()}).loose(),TT=E({uri:w(),name:w(),title:ee(w()),description:ee(w()),mimeType:ee(w()),size:ee(q())}).loose(),OT=$c.extend({resources:R(TT)}),I_=E({uri:w(),name:ee(w()),title:ee(w()),mimeType:ee(w())}).loose(),k_=I_.extend({text:w()}),E_=I_.extend({blob:Ea()}),T_=E({type:C("resource"),resource:G([k_,E_])}).loose(),NT=Vt.extend({content:R(G([$_,S_,T_])),isError:pe().default(!1).optional()}).or(Vt.extend({toolResult:$e()})),PT=E({uriTemplate:w(),name:w(),title:ee(w()),description:ee(w()),mimeType:ee(w())}).loose(),CT=Vt.extend({resourceTemplates:R(PT)}),jT=Vt.extend({contents:R(G([k_,E_]))}),AT=E({name:w(),description:ee(w()),required:ee(pe())}).loose(),RT=E({name:w(),title:ee(w()),description:ee(w()),arguments:ee(R(AT))}).loose(),zT=$c.extend({prompts:R(RT)}),MT=E({role:G([C("user"),C("assistant")]),content:G([$_,S_,T_])}).loose(),DT=Vt.extend({description:ee(w()),messages:R(MT)}),UT=La.extend({message:w(),requestedSchema:$e()}),rp=w_.extend({method:C("elicitation/create"),params:UT}),LT=Vt.extend({action:G([C("accept"),C("decline"),C("cancel")]),content:ee(Xe(w(),$e()))}),Za="2.0",ZT=E({jsonrpc:C(Za),id:G([w(),q().int()])}).merge(w_).strict(),FT=E({jsonrpc:C(Za),id:G([w(),q().int()]),result:Vt}).strict(),qT=E({jsonrpc:C(Za),id:G([w(),q().int()]),error:E({code:q().int(),message:w(),data:ee($e())})}).strict(),VT=E({jsonrpc:C(Za)}).merge(E({method:w(),params:ee(La)})).strict(),In=G([ZT,VT,FT,qT]),O_=typeof __PACKAGE_VERSION__<"u"?__PACKAGE_VERSION__:"0.0.0-test",N_=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:g_.custom,message:"URL must be parseable",fatal:!0}),Mu}).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"}),BT=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(),P_=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(),JT=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(),WT=JT.merge(P_.pick({code_challenge_methods_supported:!0})),HT=E({client_id:w(),client_secret:w().optional(),client_id_issued_at:q().optional(),client_secret_expires_at:q().optional()}).strip(),GT=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(),KT=E({error:w(),error_description:w().optional(),error_uri:w().optional()}),YT=GT.merge(HT),QT="AI_MCPClientOAuthError",C_=`vercel.ai.error.${QT}`,XT=Symbol.for(C_),np,op,Io=class extends(op=Y,np=XT,op){constructor({name:e="MCPClientOAuthError",message:t,cause:r}){super({name:e,message:t,cause:r}),this[np]=!0}static isInstance(e){return Y.hasMarker(e,C_)}},rn=class extends Io{};rn.errorCode="server_error";var yi=class extends Io{};yi.errorCode="invalid_client";var bi=class extends Io{};bi.errorCode="invalid_grant";var _i=class extends Io{};_i.errorCode="unauthorized_client";var eO={[rn.errorCode]:rn,[yi.errorCode]:yi,[bi.errorCode]:bi,[_i.errorCode]:_i};function tO(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function rO({requestedResource:e,configuredResource:t}){const r=typeof e=="string"?new URL(e):new URL(e.href),o=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==o.origin||r.pathname.length<o.pathname.length)return!1;const n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",i=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return n.startsWith(i)}var wi=class extends Error{constructor(e="Unauthorized"){super(e),this.name="UnauthorizedError"}};function xi(e){var t;const r=(t=e.headers.get("www-authenticate"))!=null?t:e.headers.get("WWW-Authenticate");if(!r)return;const[o,n]=r.split(" ");if(o.toLowerCase()!=="bearer"||!n)return;const i=/resource_metadata="([^"]*)"/,a=r.match(i);if(a)try{return new URL(a[1])}catch{return}}function nO(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function Sc(e,t,r=fetch){try{return await r(e,{headers:t})}catch(o){if(o instanceof TypeError)return t?Sc(e,void 0,r):void 0;throw o}}async function ip(e,t,r=fetch){return await Sc(e,{"MCP-Protocol-Version":t},r)}function oO(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function iO(e,t,r,o){var n,i;const a=new URL(e),s=(n=o?.protocolVersion)!=null?n:ln;let l;if(o?.metadataUrl)l=new URL(o.metadataUrl);else{const c=nO(t,a.pathname);l=new URL(c,(i=o?.metadataServerUrl)!=null?i:a),l.search=a.search}let u=await ip(l,s,r);if(!o?.metadataUrl&&oO(u,a.pathname)){const c=new URL(`/.well-known/${t}`,a);u=await ip(c,s,r)}return u}async function aO(e,t,r=fetch){const o=await iO(e,"oauth-protected-resource",r,{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 BT.parse(await o.json())}function sO(e){const t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",o=[];if(!r)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 n=t.pathname;return n.endsWith("/")&&(n=n.slice(0,-1)),o.push({url:new URL(`/.well-known/oauth-authorization-server${n}`,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${n}`,t.origin),type:"oidc"}),o.push({url:new URL(`${n}/.well-known/openid-configuration`,t.origin),type:"oidc"}),o}async function uO(e,{fetchFn:t=fetch,protocolVersion:r=ln}={}){var o;const n={"MCP-Protocol-Version":r},i=sO(e);for(const{url:a,type:s}of i){const l=await Sc(a,n,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 P_.parse(await l.json());{const u=WT.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 lO(e,{metadata:t,clientInformation:r,redirectUrl:o,scope:n,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 bT(),d=c.code_verifier,f=c.code_challenge;return u.searchParams.set("response_type",s),u.searchParams.set("client_id",r.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),n&&u.searchParams.set("scope",n),n?.includes("offline_access")&&u.searchParams.append("prompt","consent"),a&&u.searchParams.set("resource",a.href),{authorizationUrl:u,codeVerifier:d}}function j_(e,t){const r=e.client_secret!==void 0;return t.length===0?r?"client_secret_post":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}function A_(e,t,r,o){const{client_id:n,client_secret:i}=t;switch(e){case"client_secret_basic":cO(n,i,r);return;case"client_secret_post":dO(n,i,o);return;case"none":pO(n,o);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function cO(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");const o=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${o}`)}function dO(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function pO(e,t){t.set("client_id",e)}async function Ic(e){const t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{const o=KT.parse(JSON.parse(r)),{error:n,error_description:i,error_uri:a}=o,s=eO[n]||rn;return new s({message:i||"",cause:a})}catch(o){const n=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${o}. Raw body: ${r}`;return new rn({message:n})}}async function fO(e,{metadata:t,clientInformation:r,authorizationCode:o,codeVerifier:n,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:n,redirect_uri:String(i)});if(s)s(f,p,e,t);else{const h=(u=t?.token_endpoint_auth_methods_supported)!=null?u:[],b=j_(r,h);A_(b,r,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 Ic(g);return N_.parse(await g.json())}async function mO(e,{metadata:t,clientInformation:r,refreshToken:o,resource:n,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=j_(r,p);A_(g,r,c,d)}n&&d.set("resource",n.href);const f=await(a??fetch)(u,{method:"POST",headers:c,body:d});if(!f.ok)throw await Ic(f);return N_.parse({refresh_token:o,...await f.json()})}async function hO(e,{metadata:t,clientMetadata:r,fetchFn:o}){let n;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");n=new URL(t.registration_endpoint)}else n=new URL("/register",e);const i=await(o??fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok)throw await Ic(i);return YT.parse(await i.json())}async function $i(e,t){var r,o;try{return await gs(e,t)}catch(n){if(n instanceof yi||n instanceof _i)return await((r=e.invalidateCredentials)==null?void 0:r.call(e,"all")),await gs(e,t);if(n instanceof bi)return await((o=e.invalidateCredentials)==null?void 0:o.call(e,"tokens")),await gs(e,t);throw n}}async function gO(e,t,r){const o=tO(e);if(t.validateResourceURL)return await t.validateResourceURL(o,r?.resource);if(r){if(!rO({requestedResource:o,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${o} (or origin)`);return new URL(r.resource)}}async function gs(e,{serverUrl:t,authorizationCode:r,scope:o,resourceMetadataUrl:n,fetchFn:i}){let a,s;try{a=await aO(t,{resourceMetadataUrl:n},i),a.authorization_servers&&a.authorization_servers.length>0&&(s=a.authorization_servers[0])}catch{}s||(s=t);const l=await gO(t,e,a),u=await uO(s,{fetchFn:i});let c=await Promise.resolve(e.clientInformation());if(!c){if(r!==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 hO(s,{metadata:u,clientMetadata:e.clientMetadata,fetchFn:i});await e.saveClientInformation(h),c=h}if(r!==void 0){const h=await e.codeVerifier(),b=await fO(s,{metadata:u,clientInformation:c,authorizationCode:r,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 mO(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 Io)||h instanceof rn))throw h}const f=e.state?await e.state():void 0,{authorizationUrl:p,codeVerifier:g}=await lO(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 vO=class{constructor({url:e,headers:t,authProvider:r}){this.connected=!1,this.url=new URL(e),this.headers=t,this.authProvider=r}async commonHeaders(e){const t={...this.headers,...e,"mcp-protocol-version":ln};if(this.authProvider){const r=await this.authProvider.tokens();r?.access_token&&(t.Authorization=`Bearer ${r.access_token}`)}return b_(t,`ai-sdk/${O_}`,y_())}async start(){return new Promise((e,t)=>{if(this.connected)return e();this.abortController=new AbortController;const r=async(o=!1)=>{var n,i,a,s,l;try{const u=await this.commonHeaders({Accept:"text/event-stream"}),c=await fetch(this.url.href,{headers:u,signal:(n=this.abortController)==null?void 0:n.signal});if(c.status===401&&this.authProvider&&!o){this.resourceMetadataUrl=xi(c);try{if(await $i(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const h=new wi;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 r(!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=In.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)}};r()})}async close(){var e,t,r;this.connected=!1,(e=this.sseConnection)==null||e.close(),(t=this.abortController)==null||t.abort(),(r=this.onclose)==null||r.call(this)}async send(e){if(!this.endpoint||!this.connected)throw new se({message:"MCP SSE Transport Error: Not connected"});const t=this.endpoint,r=async(o=!1)=>{var n,i,a,s,l;try{const c={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json"}),body:JSON.stringify(e),signal:(n=this.abortController)==null?void 0:n.signal},d=await fetch(t,c);if(d.status===401&&this.authProvider&&!o){this.resourceMetadataUrl=xi(d);try{if(await $i(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const p=new wi;(i=this.onerror)==null||i.call(this,p);return}}catch(f){(a=this.onerror)==null||a.call(this,f);return}return r(!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 r()}},yO=class{constructor({url:e,headers:t,authProvider:r}){this.inboundReconnectAttempts=0,this.reconnectionOptions={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},this.url=new URL(e),this.headers=t,this.authProvider=r}async commonHeaders(e){const t={...this.headers,...e,"mcp-protocol-version":ln};if(this.sessionId&&(t["mcp-session-id"]=this.sessionId),this.authProvider){const r=await this.authProvider.tokens();r?.access_token&&(t.Authorization=`Bearer ${r.access_token}`)}return b_(t,`ai-sdk/${O_}`,y_())}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,r;(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(),(r=this.onclose)==null||r.call(this)}async send(e){const t=async(r=!1)=>{var o,n,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&&!r){this.resourceMetadataUrl=xi(f);try{if(await $i(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED")throw new wi}catch(b){throw(n=this.onerror)==null||n.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=>In.parse(x)):[In.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=In.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:r,maxReconnectionDelay:o}=this.reconnectionOptions;return Math.min(t*Math.pow(r,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 r=this.getNextReconnectionDelay(this.inboundReconnectAttempts);this.inboundReconnectAttempts+=1,setTimeout(async()=>{var o;(o=this.abortController)!=null&&o.signal.aborted||await this.openInboundSse(!1,this.lastInboundEventId)},r)}async openInboundSse(e=!1,t){var r,o,n,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:(r=this.abortController)==null?void 0:r.signal}),c=u.headers.get("mcp-session-id");if(c&&(this.sessionId=c),u.status===401&&this.authProvider&&!e){this.resourceMetadataUrl=xi(u);try{if(await $i(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const h=new wi;(o=this.onerror)==null||o.call(this,h);return}}catch(g){(n=this.onerror)==null||n.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=In.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 bO(e){switch(e.type){case"sse":return new vO(e);case"http":return new yO(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 _O(e){return"start"in e&&typeof e.start=="function"&&"send"in e&&typeof e.send=="function"&&"close"in e&&typeof e.close=="function"}var wO="1.0.0";async function xO(e){const t=new $O(e);return await t.init(),t}var $O=class{constructor({transport:e,name:t="ai-sdk-mcp-client",version:r=wO,onUncaughtError:o,capabilities:n}){this.requestMessageId=0,this.responseHandlers=new Map,this.serverCapabilities={},this.isClosed=!0,this.onUncaughtError=o,this.clientCapabilities=n??{},_O(e)?this.transport=e:this.transport=bO(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:r}}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:IT});if(e===void 0)throw new se({message:"Server sent invalid initialize result"});if(!xT.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:r}){return new Promise((o,n)=>{if(this.isClosed)return n(new se({message:"Attempted to send a request from a closed client"}));this.assertCapability(e.method);const i=r?.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 n(new se({message:"Request was aborted",cause:i.reason}));if(u instanceof Error)return n(u);try{const c=t.parse(u.result);o(c)}catch(c){const d=new se({message:"Failed to parse server response",cause:c});n(d)}}),this.transport.send(s).catch(u=>{l(),n(u)})})}async listTools({params:e,options:t}={}){try{return this.request({request:{method:"tools/list",params:e},resultSchema:ET,options:t})}catch(r){throw r}}async callTool({name:e,args:t,options:r}){try{return this.request({request:{method:"tools/call",params:{name:e,arguments:t}},resultSchema:NT,options:{signal:r?.abortSignal}})}catch(o){throw o}}async listResourcesInternal({params:e,options:t}={}){try{return this.request({request:{method:"resources/list",params:e},resultSchema:OT,options:t})}catch(r){throw r}}async readResourceInternal({uri:e,options:t}){try{return this.request({request:{method:"resources/read",params:{uri:e}},resultSchema:jT,options:t})}catch(r){throw r}}async listResourceTemplatesInternal({options:e}={}){try{return this.request({request:{method:"resources/templates/list"},resultSchema:CT,options:e})}catch(t){throw t}}async listPromptsInternal({params:e,options:t}={}){try{return this.request({request:{method:"prompts/list",params:e},resultSchema:zT,options:t})}catch(r){throw r}}async getPromptInternal({name:e,args:t,options:r}){try{return this.request({request:{method:"prompts/get",params:{name:e,arguments:t}},resultSchema:DT,options:r})}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 r={};try{const o=await this.listTools();for(const{name:n,description:i,inputSchema:a}of o.tools){if(e!=="automatic"&&!(n in e))continue;const s=this,l=async(c,d)=>{var f;return(f=d?.abortSignal)==null||f.throwIfAborted(),s.callTool({name:n,args:c,options:d})},u=e==="automatic"?pT({description:i,inputSchema:mT({...a,properties:(t=a.properties)!=null?t:{},additionalProperties:!1}),execute:l}):{description:i,inputSchema:e[n].inputSchema,execute:l};r[n]=u}return r}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:r}){return this.getPromptInternal({name:e,args:t,options:r})}onElicitationRequest(e,t){if(e!==rp)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=rp.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 r=await this.elicitationRequestHandler(t.data),o=LT.parse(r);await this.transport.send({jsonrpc:"2.0",id:e.id,result:o})}catch(r){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32603,message:r instanceof Error?r.message:"Failed to handle elicitation request"}}),this.onError(r)}}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),r=this.responseHandlers.get(t);if(r===void 0)throw new se({message:`Protocol error: Received a response for an unknown message ID: ${JSON.stringify(e)}`});this.responseHandlers.delete(t),r("result"in e?e:new se({message:e.error.message,code:e.error.code,data:e.error.data,cause:e.error}))}},ko=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(){}},SO={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},IO=class{#e=SO;#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 IO;function kO(e){setTimeout(e,0)}var _r=typeof window>"u"||"Deno"in globalThis;function Je(){}function EO(e,t){return typeof e=="function"?e(t):e}function tu(e){return typeof e=="number"&&e>=0&&e!==1/0}function R_(e,t){return Math.max(e+(t||0)-Date.now(),0)}function rr(e,t){return typeof e=="function"?e(t):e}function at(e,t){return typeof e=="function"?e(t):e}function ap(e,t){const{type:r="all",exact:o,fetchStatus:n,predicate:i,queryKey:a,stale:s}=e;if(a){if(o){if(t.queryHash!==kc(a,t.options))return!1}else if(!Dn(t.queryKey,a))return!1}if(r!=="all"){const l=t.isActive();if(r==="active"&&!l||r==="inactive"&&l)return!1}return!(typeof s=="boolean"&&t.isStale()!==s||n&&n!==t.state.fetchStatus||i&&!i(t))}function sp(e,t){const{exact:r,status:o,predicate:n,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(r){if(Mn(t.options.mutationKey)!==Mn(i))return!1}else if(!Dn(t.options.mutationKey,i))return!1}return!(o&&t.state.status!==o||n&&!n(t))}function kc(e,t){return(t?.queryKeyHashFn||Mn)(e)}function Mn(e){return JSON.stringify(e,(t,r)=>ou(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function Dn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Dn(e[r],t[r])):!1}var TO=Object.prototype.hasOwnProperty;function ru(e,t){if(e===t)return e;const r=up(e)&&up(t);if(!r&&!(ou(e)&&ou(t)))return t;const n=(r?e:Object.keys(e)).length,i=r?t:Object.keys(t),a=i.length,s=r?new Array(a):{};let l=0;for(let u=0;u<a;u++){const c=r?u:i[u],d=e[c],f=t[c];if(d===f){s[c]=d,(r?u<n:TO.call(e,c))&&l++;continue}if(d===null||f===null||typeof d!="object"||typeof f!="object"){s[c]=f;continue}const p=ru(d,f);s[c]=p,p===d&&l++}return n===a&&l===n?e:s}function nu(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function up(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ou(e){if(!lp(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!lp(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function lp(e){return Object.prototype.toString.call(e)==="[object Object]"}function OO(e){return new Promise(t=>{hr.setTimeout(t,e)})}function iu(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return ru(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. [${r.queryHash}]: ${o}`),o}return ru(e,t)}return t}function NO(e,t,r=0){const o=[...e,t];return r&&o.length>r?o.slice(1):o}function PO(e,t,r=0){const o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var Si=Symbol();function z_(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Si&&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===Si?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function CO(e,t){return typeof e=="function"?e(...t):!!e}var jO=class extends ko{#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"}},Ec=new jO;function au(){let e,t;const r=new Promise((n,i)=>{e=n,t=i});r.status="pending",r.catch(()=>{});function o(n){Object.assign(r,n),delete r.resolve,delete r.reject}return r.resolve=n=>{o({status:"fulfilled",value:n}),e(n)},r.reject=n=>{o({status:"rejected",reason:n}),t(n)},r}var AO=kO;function RO(){let e=[],t=0,r=s=>{s()},o=s=>{s()},n=AO;const i=s=>{t?e.push(s):n(()=>{r(s)})},a=()=>{const s=e;e=[],s.length&&n(()=>{o(()=>{s.forEach(l=>{r(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=>{r=s},setBatchNotifyFunction:s=>{o=s},setScheduler:s=>{n=s}}}var ze=RO(),zO=class extends ko{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!_r&&window.addEventListener){const t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}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(r=>{r(e)}))}isOnline(){return this.#e}},Ii=new zO;function MO(e){return Math.min(1e3*2**e,3e4)}function M_(e){return(e??"online")==="online"?Ii.isOnline():!0}var su=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function D_(e){let t=!1,r=0,o;const n=au(),i=()=>n.status!=="pending",a=h=>{if(!i()){const b=new su(h);f(b),e.onCancel?.(b)}},s=()=>{t=!0},l=()=>{t=!1},u=()=>Ec.isFocused()&&(e.networkMode==="always"||Ii.isOnline())&&e.canRun(),c=()=>M_(e.networkMode)&&e.canRun(),d=h=>{i()||(o?.(),n.resolve(h))},f=h=>{i()||(o?.(),n.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=r===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??MO,v=typeof $=="function"?$(r,y):$,k=x===!0||typeof x=="number"&&r<x||typeof x=="function"&&x(r,y);if(t||!k){f(y);return}r++,e.onFail?.(r,y),OO(v).then(()=>u()?void 0:p()).then(()=>{t?f(y):g()})})};return{promise:n,status:()=>n.status,cancel:a,continue:()=>(o?.(),n),cancelRetry:s,continueRetry:l,canStart:c,start:()=>(c()?g():p().then(g),n)}}var U_=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),tu(this.gcTime)&&(this.#e=hr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(_r?1/0:300*1e3))}clearGcTimeout(){this.#e&&(hr.clearTimeout(this.#e),this.#e=void 0)}},DO=class extends U_{#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=dp(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=dp(this.options);t.data!==void 0&&(this.setState(cp(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){const r=iu(this.state.data,e,this.options);return this.#i({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}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===Si||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>rr(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:!R_(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 r=new AbortController,o=s=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#a=!0,r.signal)})},n=()=>{const s=z_(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:n};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=D_({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:s=>{s instanceof su&&s.revert&&this.setState({...this.#t,fetchStatus:"idle"}),r.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 su){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=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...L_(r.data,this.options),fetchMeta:e.meta??null};case"success":const o={...r,...cp(e.data,e.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?o:void 0,o;case"error":const n=e.error;return{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),ze.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function L_(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:M_(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function cp(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function dp(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,o=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var UO=class extends ko{constructor(e,t){super(),this.options=t,this.#e=e,this.#i=null,this.#a=au(),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),pp(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return uu(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return uu(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,r=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&&!nu(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const o=this.hasListeners();o&&fp(this.#t,r,this.options,t)&&this.#d(),this.updateResult(),o&&(this.#t!==r||at(this.options.enabled,this.#t)!==at(t.enabled,this.#t)||rr(this.options.staleTime,this.#t)!==rr(t.staleTime,this.#t))&&this.#g();const n=this.#v();o&&(this.#t!==r||at(this.options.enabled,this.#t)!==at(t.enabled,this.#t)||n!==this.#u)&&this.#y(n)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),r=this.createResult(t,e);return ZO(this,r)&&(this.#o=r,this.#s=this.options,this.#n=this.#t.state),r}getCurrentResult(){return this.#o}trackResult(e,t){return new Proxy(e,{get:(r,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(r,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),r=this.#e.getQueryCache().build(this.#e,t);return r.fetch().then(()=>this.createResult(r,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=rr(this.options.staleTime,this.#t);if(_r||this.#o.isStale||!tu(e))return;const r=R_(this.#o.dataUpdatedAt,e)+1;this.#l=hr.setTimeout(()=>{this.#o.isStale||this.updateResult()},r)}#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||!tu(this.#u)||this.#u===0)&&(this.#c=hr.setInterval(()=>{(this.options.refetchIntervalInBackground||Ec.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 r=this.#t,o=this.options,n=this.#o,i=this.#n,a=this.#s,l=e!==r?e.state:this.#r,{state:u}=e;let c={...u},d=!1,f;if(t._optimisticResults){const O=this.hasListeners(),z=!O&&pp(e,t),F=O&&fp(e,r,t,o);(z||F)&&(c={...c,...L_(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;n?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(O=n.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(n?.data,O,t),d=!0)}if(t.select&&f!==void 0&&!b)if(n&&f===i?.data&&t.select===this.#h)f=this.#p;else try{this.#h=t.select,f=t.select(f),f=iu(n?.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:Tc(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=au();O(te)},F=this.#a;switch(F.status){case"pending":e.queryHash===r.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),nu(t,e))return;this.#o=t;const r=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,n=typeof o=="function"?o():o;if(n==="all"||!n&&!this.#m.size)return!0;const i=new Set(n??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:r()})}#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 LO(e,t){return at(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function pp(e,t){return LO(e,t)||e.state.data!==void 0&&uu(e,t,t.refetchOnMount)}function uu(e,t,r){if(at(t.enabled,e)!==!1&&rr(t.staleTime,e)!=="static"){const o=typeof r=="function"?r(e):r;return o==="always"||o!==!1&&Tc(e,t)}return!1}function fp(e,t,r,o){return(e!==t||at(o.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Tc(e,r)}function Tc(e,t){return at(t.enabled,e)!==!1&&e.isStaleByTime(rr(t.staleTime,e))}function ZO(e,t){return!nu(e.getCurrentResult(),t)}function mp(e){return{onFetch:(t,r)=>{const o=t.options,n=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=z_(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?PO:NO;return{pages:k(g.pages,$,v),pageParams:k(g.pageParams,h,v)}};if(n&&i.length){const g=n==="backward",h=g?FO:hp,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:hp(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},r):t.fetchFn=u}}}function hp(e,{pages:t,pageParams:r}){const o=t.length-1;return t.length>0?e.getNextPageParam(t[o],t,r[o],r):void 0}function FO(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var qO=class extends U_{#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||VO(),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"})},r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#o=D_({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):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",n=!this.#o.canStart();try{if(o)t();else{this.#n({type:"pending",variables:e,isPaused:n}),await this.#r.config.onMutate?.(e,this,r);const a=await this.options.onMutate?.(e,r);a!==this.state.context&&this.#n({type:"pending",context:a,variables:e,isPaused:n})}const i=await this.#o.start();return await this.#r.config.onSuccess?.(i,e,this.state.context,this,r),await this.options.onSuccess?.(i,e,this.state.context,r),await this.#r.config.onSettled?.(i,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(i,null,e,this.state.context,r),this.#n({type:"success",data:i}),i}catch(i){try{throw await this.#r.config.onError?.(i,e,this.state.context,this,r),await this.options.onError?.(i,e,this.state.context,r),await this.#r.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(void 0,i,e,this.state.context,r),i}finally{this.#n({type:"error",error:i})}}finally{this.#r.runNext(this)}}#n(e){const t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,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{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),ze.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(e)}),this.#r.notify({mutation:this,type:"updated",action:e})})}};function VO(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var BO=class extends ko{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){const o=new qO({client:e,mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(o),o}add(e){this.#e.add(e);const t=qo(e);if(typeof t=="string"){const r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=qo(e);if(typeof t=="string"){const r=this.#t.get(t);if(r)if(r.length>1){const o=r.indexOf(e);o!==-1&&r.splice(o,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=qo(e);if(typeof t=="string"){const o=this.#t.get(t)?.find(n=>n.state.status==="pending");return!o||o===e}else return!0}runNext(e){const t=qo(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(r=>sp(t,r))}findAll(e={}){return this.getAll().filter(t=>sp(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 qo(e){return e.options.scope?.id}var JO=class extends ko{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){const o=t.queryKey,n=t.queryHash??kc(o,t);let i=this.get(n);return i||(i=new DO({client:e,queryKey:o,queryHash:n,options:e.defaultQueryOptions(t),state:r,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(r=>ap(t,r))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(r=>ap(e,r)):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()})})}},WO=class{#e;#t;#r;#o;#n;#s;#a;#i;constructor(e={}){this.#e=e.queryCache||new JO,this.#t=e.mutationCache||new BO,this.#r=e.defaultOptions||{},this.#o=new Map,this.#n=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#a=Ec.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=Ii.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),r=this.#e.build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(rr(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{const o=r.data;return[t,o]})}setQueryData(e,t,r){const o=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(o.queryHash)?.state.data,a=EO(t,i);if(a!==void 0)return this.#e.build(this,o).setData(a,{...r,manual:!0})}setQueriesData(e,t,r){return ze.batch(()=>this.#e.findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}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(r=>{t.remove(r)})})}resetQueries(e,t){const r=this.#e;return ze.batch(()=>(r.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},o=ze.batch(()=>this.#e.findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(Je).catch(Je)}invalidateQueries(e,t={}){return ze.batch(()=>(this.#e.findAll(e).forEach(r=>{r.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},o=ze.batch(()=>this.#e.findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let i=n.fetch(void 0,r);return r.throwOnError||(i=i.catch(Je)),n.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 r=this.#e.build(this,t);return r.isStaleByTime(rr(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Je).catch(Je)}fetchInfiniteQuery(e){return e.behavior=mp(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Je).catch(Je)}ensureInfiniteQueryData(e){return e.behavior=mp(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Ii.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(Mn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#o.values()],r={};return t.forEach(o=>{Dn(e,o.queryKey)&&Object.assign(r,o.defaultOptions)}),r}setMutationDefaults(e,t){this.#n.set(Mn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#n.values()],r={};return t.forEach(o=>{Dn(e,o.mutationKey)&&Object.assign(r,o.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=kc(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===Si&&(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()}},Z_=_.createContext(void 0),F_=e=>{const t=_.useContext(Z_);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},HO=({client:e,children:t})=>(_.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),m.jsx(Z_.Provider,{value:e,children:t})),q_=_.createContext(!1),GO=()=>_.useContext(q_);q_.Provider;function KO(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var YO=_.createContext(KO()),QO=()=>_.useContext(YO),XO=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},eN=e=>{_.useEffect(()=>{e.clearReset()},[e])},tN=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||CO(r,[e.error,o])),rN=e=>{if(e.suspense){const r=n=>n==="static"?n:Math.max(n??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...n)=>r(o(...n)):r(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},nN=(e,t)=>e.isLoading&&e.isFetching&&!t,oN=(e,t)=>e?.suspense&&t.isPending,gp=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function iN(e,t,r){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=GO(),n=QO(),i=F_(),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",rN(a),XO(a,n),eN(n);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]),oN(a,u))throw gp(a,l,n);if(tN({result:u,errorResetBoundary:n,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&&nN(u,o)&&(s?gp(a,l,n):i.getQueryCache().get(a.queryHash)?.promise)?.catch(Je).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?u:l.trackResult(u)}function V_(e,t){return iN(e,UO)}function aN({auth:e,mcp:t,environment:r}){const o=Object.entries(e.headers??{}).map((i,a)=>`${i}:${a}`);return V_({queryKey:["mcpTools",t,...o],queryFn:async()=>(T.assert(!e.isLoading,"No auth found"),T.assert(t,"No MCP URL found"),await(await xO({name:"gram-elements-mcp-client",transport:{type:"http",url:t,headers:{...sN(r??{}),...e.headers}}})).tools()),enabled:!e.isLoading&&!!t,staleTime:1/0,gcTime:1/0})}const vp="MCP-";function sN(e){return typeof e!="object"||e===null?{}:Object.entries(e).reduce((t,[r,o])=>{const n=r.replace(/_/g,"-"),i=n.startsWith(vp)?n:`${vp}${n}`;return t[i]=o,t},{})}const B_=()=>{const e=D.useContext(T.ToolApprovalContext);if(!e)throw new Error("useToolApproval must be used within a ToolApprovalProvider");return e},Oc=["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"],uN=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r.description?{description:r.description}:void 0,parameters:r.parameters instanceof gi.ZodType?gi.toJSONSchema(r.parameters):r.parameters}])),lN=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>!t.disabled&&t.type!=="backend"));let ki=null;function cN(e,t){ki={helpers:e,toolsRequiringApproval:new Set(t)}}function dN(){ki=null}const pN=(e,t)=>L.makeAssistantTool({...e,execute:async(r,o)=>{if(ki?.toolsRequiringApproval.has(t)){const{helpers:n}=ki,i=o.toolCallId??"";if(!n.isToolApproved(t)&&!await n.requestApproval(t,i,r))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?.(r,o)},toolName:t});function fN(e,t,r){if(!t||t.length===0)return e;const o=new Set(t);return Object.fromEntries(Object.entries(e).map(([n,i])=>{if(!o.has(n))return[n,i];const a=i.execute;return a?[n,{...i,execute:async(s,l)=>{const u=l??{},c=u.toolCallId??"";return r.isToolApproved(n)||await r.requestApproval(n,c,s)?a(s,u):{content:[{type:"text",text:`Tool "${n}" execution was denied by the user. Please acknowledge this and continue without using this tool's result.`}],isError:!0}}}]:[n,i]}))}const mN=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],hN=T.createLucideIcon("arrow-down",mN);const gN=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],vN=T.createLucideIcon("arrow-up",gN);const yN=[["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"}]],bN=T.createLucideIcon("brain",yN);const _N=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],nr=T.createLucideIcon("check",_N);const wN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ei=T.createLucideIcon("chevron-down",wN);const xN=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],$N=T.createLucideIcon("chevron-left",xN);const SN=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],J_=T.createLucideIcon("chevron-right",SN);const IN=[["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"}]],Nc=T.createLucideIcon("copy",IN);const kN=[["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"}]],EN=T.createLucideIcon("file-text",kN);const TN=[["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"}]],lu=T.createLucideIcon("loader",TN);const ON=[["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"}]],NN=T.createLucideIcon("maximize",ON);const PN=[["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"}]],CN=T.createLucideIcon("message-circle",PN);const jN=[["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"}]],AN=T.createLucideIcon("minimize",jN);const RN=[["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"}]],zN=T.createLucideIcon("panel-right-close",RN);const MN=[["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"}]],DN=T.createLucideIcon("panel-right-open",MN);const UN=[["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"}]],LN=T.createLucideIcon("pencil",UN);const ZN=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],FN=T.createLucideIcon("plus",ZN);const qN=[["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"}]],VN=T.createLucideIcon("refresh-cw",qN);const BN=[["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"}]],JN=T.createLucideIcon("settings-2",BN);const WN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],HN=T.createLucideIcon("square",WN);const GN=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Eo=T.createLucideIcon("x",GN);var To=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const n=()=>{const i=r.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=r[Math.random()*i|0];return a.join("")};if(e==null)return n;if(r.includes(o))throw new Vi({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${r}".`});return()=>`${e}${o}${n()}`},W_=To();function yp(e=globalThis){var t,r,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(r=e.process)==null?void 0:r.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((r,o)=>{t[o.toLowerCase()]=r});else{Array.isArray(e)||(e=Object.entries(e));for(const[r,o]of e)o!=null&&(t[r.toLowerCase()]=o)}return t}function bp(e,...t){const r=new Headers(fr(e)),o=r.get("user-agent")||"";return r.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}var KN=/"__proto__"\s*:/,YN=/"constructor"\s*:/;function _p(e){const t=JSON.parse(e);return t===null||typeof t!="object"||KN.test(e)===!1&&YN.test(e)===!1?t:QN(t)}function QN(e){let t=[e];for(;t.length;){const r=t;t=[];for(const o of r){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 n in o){const i=o[n];i&&typeof i=="object"&&t.push(i)}}}return e}function XN(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return _p(e)}try{return _p(e)}finally{Error.stackTraceLimit=t}}var Ti=Symbol.for("vercel.ai.validator");function eP(e){return{[Ti]:!0,validate:e}}function tP(e){return typeof e=="object"&&e!==null&&Ti in e&&e[Ti]===!0&&"validate"in e}function rP(e){let t;return()=>(t==null&&(t=e()),t)}function nP(e){return tP(e)?e:typeof e=="function"?e():oP(e)}function oP(e){return eP(async t=>{const r=await e["~standard"].validate(t);return r.issues==null?{success:!0,value:r.value}:{success:!1,error:new Ft({value:t,cause:r.issues})}})}async function wp({value:e,schema:t}){const r=await Pc({value:e,schema:t});if(!r.success)throw Ft.wrap({value:e,cause:r.error});return r.value}async function Pc({value:e,schema:t}){const r=nP(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};const o=await r.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 Oi({text:e,schema:t}){try{const r=XN(e);return t==null?{success:!0,value:r,rawValue:r}:await Pc({value:r,schema:t})}catch(r){return{success:!1,error:Jr.isInstance(r)?r:new Jr({text:e,cause:r}),rawValue:void 0}}}function iP({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).pipeThrough(new TransformStream({async transform({data:r},o){r!=="[DONE]"&&o.enqueue(await Oi({text:r,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 r in t)t[r]=ti(t[r])}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 aP=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")},sP=Symbol("Let zodToJsonSchema decide on which parser to use"),xp={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"},uP=e=>typeof e=="string"?{...xp,name:e}:{...xp,...e};function et(){return{}}function lP(e,t){var r,o,n;const i={type:"array"};return(r=e.type)!=null&&r._def&&((n=(o=e.type)==null?void 0:o._def)==null?void 0:n.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 cP(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function dP(){return{type:"boolean"}}function H_(e,t){return le(e.type._def,t)}var pP=(e,t)=>le(e.innerType._def,t);function G_(e,t,r){const o=r??t.dateStrategy;if(Array.isArray(o))return{anyOf:o.map((n,i)=>G_(e,t,n))};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 fP(e)}}var fP=e=>{const t={type:"integer",format:"unix-time"};for(const r of e.checks)switch(r.kind){case"min":t.minimum=r.value;break;case"max":t.maximum=r.value;break}return t};function mP(e,t){return{...le(e.innerType._def,t),default:e.defaultValue()}}function hP(e,t){return t.effectStrategy==="input"?le(e.schema._def,t):et()}function gP(e){return{type:"string",enum:Array.from(e.values)}}var vP=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function yP(e,t){const r=[le(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),le(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(n=>!!n),o=[];return r.forEach(n=>{if(vP(n))o.push(...n.allOf);else{let i=n;if("additionalProperties"in n&&n.additionalProperties===!1){const{additionalProperties:a,...s}=n;i=s}o.push(i)}}),o.length?{allOf:o}:void 0}function bP(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 vs=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:()=>(vs===void 0&&(vs=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),vs),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 K_(e,t){const r={type:"string"};if(e.checks)for(const o of e.checks)switch(o.kind){case"min":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,o.value):o.value;break;case"max":r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,o.value):o.value;break;case"email":switch(t.emailStrategy){case"format:email":gt(r,"email",o.message,t);break;case"format:idn-email":gt(r,"idn-email",o.message,t);break;case"pattern:zod":Fe(r,ht.email,o.message,t);break}break;case"url":gt(r,"uri",o.message,t);break;case"uuid":gt(r,"uuid",o.message,t);break;case"regex":Fe(r,o.regex,o.message,t);break;case"cuid":Fe(r,ht.cuid,o.message,t);break;case"cuid2":Fe(r,ht.cuid2,o.message,t);break;case"startsWith":Fe(r,RegExp(`^${ys(o.value,t)}`),o.message,t);break;case"endsWith":Fe(r,RegExp(`${ys(o.value,t)}$`),o.message,t);break;case"datetime":gt(r,"date-time",o.message,t);break;case"date":gt(r,"date",o.message,t);break;case"time":gt(r,"time",o.message,t);break;case"duration":gt(r,"duration",o.message,t);break;case"length":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,o.value):o.value,r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,o.value):o.value;break;case"includes":{Fe(r,RegExp(ys(o.value,t)),o.message,t);break}case"ip":{o.version!=="v6"&>(r,"ipv4",o.message,t),o.version!=="v4"&>(r,"ipv6",o.message,t);break}case"base64url":Fe(r,ht.base64url,o.message,t);break;case"jwt":Fe(r,ht.jwt,o.message,t);break;case"cidr":{o.version!=="v6"&&Fe(r,ht.ipv4Cidr,o.message,t),o.version!=="v4"&&Fe(r,ht.ipv6Cidr,o.message,t);break}case"emoji":Fe(r,ht.emoji(),o.message,t);break;case"ulid":{Fe(r,ht.ulid,o.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{gt(r,"binary",o.message,t);break}case"contentEncoding:base64":{r.contentEncoding="base64";break}case"pattern:zod":{Fe(r,ht.base64,o.message,t);break}}break}case"nanoid":Fe(r,ht.nanoid,o.message,t)}return r}function ys(e,t){return t.patternStrategy==="escape"?wP(e):e}var _P=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function wP(e){let t="";for(let r=0;r<e.length;r++)_P.has(e[r])||(t+="\\"),t+=e[r];return t}function gt(e,t,r,o){var n;e.format||(n=e.anyOf)!=null&&n.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...r&&o.errorMessages&&{errorMessage:{format:r}}})):e.format=t}function Fe(e,t,r,o){var n;e.pattern||(n=e.allOf)!=null&&n.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:$p(t,o),...r&&o.errorMessages&&{errorMessage:{pattern:r}}})):e.pattern=$p(t,o)}function $p(e,t){var r;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")},n=o.i?e.source.toLowerCase():e.source;let i="",a=!1,s=!1,l=!1;for(let u=0;u<n.length;u++){if(a){i+=n[u],a=!1;continue}if(o.i){if(s){if(n[u].match(/[a-z]/)){l?(i+=n[u],i+=`${n[u-2]}-${n[u]}`.toUpperCase(),l=!1):n[u+1]==="-"&&((r=n[u+2])!=null&&r.match(/[a-z]/))?(i+=n[u],l=!0):i+=`${n[u]}${n[u].toUpperCase()}`;continue}}else if(n[u].match(/[a-z]/)){i+=`[${n[u]}${n[u].toUpperCase()}]`;continue}}if(o.m){if(n[u]==="^"){i+=`(^|(?<=[\r
|
|
30
|
+
]))`;continue}else if(n[u]==="$"){i+=`($|(?=[\r
|
|
31
|
+
]))`;continue}}if(o.s&&n[u]==="."){i+=s?`${n[u]}\r
|
|
32
|
+
`:`[${n[u]}\r
|
|
33
|
+
]`;continue}i+=n[u],n[u]==="\\"?a=!0:s&&n[u]==="]"?s=!1:!s&&n[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 Y_(e,t){var r,o,n,i,a,s;const l={type:"object",additionalProperties:(r=le(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?r:t.allowedAdditionalProperties};if(((o=e.keyType)==null?void 0:o._def.typeName)===A.ZodString&&((n=e.keyType._def.checks)!=null&&n.length)){const{type:u,...c}=K_(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}=H_(e.keyType._def,t);return{...l,propertyNames:c}}}return l}function xP(e,t){if(t.mapStrategy==="record")return Y_(e,t);const r=le(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||et(),o=le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||et();return{type:"array",maxItems:125,items:{type:"array",items:[r,o],minItems:2,maxItems:2}}}function $P(e){const t=e.values,o=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),n=Array.from(new Set(o.map(i=>typeof i)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:o}}function SP(){return{not:et()}}function IP(){return{type:"null"}}var cu={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function kP(e,t){const r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(o=>o._def.typeName in cu&&(!o._def.checks||!o._def.checks.length))){const o=r.reduce((n,i)=>{const a=cu[i._def.typeName];return a&&!n.includes(a)?[...n,a]:n},[]);return{type:o.length>1?o:o[0]}}else if(r.every(o=>o._def.typeName==="ZodLiteral"&&!o.description)){const o=r.reduce((n,i)=>{const a=typeof i._def.value;switch(a){case"string":case"number":case"boolean":return[...n,a];case"bigint":return[...n,"integer"];case"object":if(i._def.value===null)return[...n,"null"];case"symbol":case"undefined":case"function":default:return n}},[]);if(o.length===r.length){const n=o.filter((i,a,s)=>s.indexOf(i)===a);return{type:n.length>1?n:n[0],enum:r.reduce((i,a)=>i.includes(a._def.value)?i:[...i,a._def.value],[])}}}else if(r.every(o=>o._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((o,n)=>[...o,...n._def.values.filter(i=>!o.includes(i))],[])};return EP(e,t)}var EP=(e,t)=>{const r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((o,n)=>le(o._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(o=>!!o&&(!t.strictUnions||typeof o=="object"&&Object.keys(o).length>0));return r.length?{anyOf:r}:void 0};function TP(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[cu[e.innerType._def.typeName],"null"]};const r=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function OP(e){const t={type:"number"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"int":t.type="integer";break;case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function NP(e,t){const r={type:"object",properties:{}},o=[],n=e.shape();for(const a in n){let s=n[a];if(s===void 0||s._def===void 0)continue;const l=CP(s),u=le(s._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});u!==void 0&&(r.properties[a]=u,l||o.push(a))}o.length&&(r.required=o);const i=PP(e,t);return i!==void 0&&(r.additionalProperties=i),r}function PP(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 CP(e){try{return e.isOptional()}catch{return!0}}var jP=(e,t)=>{var r;if(t.currentPath.toString()===((r=t.propertyPath)==null?void 0:r.toString()))return le(e.innerType._def,t);const o=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return o?{anyOf:[{not:et()},o]}:et()},AP=(e,t)=>{if(t.pipeStrategy==="input")return le(e.in._def,t);if(t.pipeStrategy==="output")return le(e.out._def,t);const r=le(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),o=le(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,o].filter(n=>n!==void 0)}};function RP(e,t){return le(e.type._def,t)}function zP(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 MP(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,o)=>le(r._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((r,o)=>o===void 0?r:[...r,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((r,o)=>le(r._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((r,o)=>o===void 0?r:[...r,o],[])}}function DP(){return{not:et()}}function UP(){return et()}var LP=(e,t)=>le(e.innerType._def,t),ZP=(e,t,r)=>{switch(t){case A.ZodString:return K_(e,r);case A.ZodNumber:return OP(e);case A.ZodObject:return NP(e,r);case A.ZodBigInt:return cP(e);case A.ZodBoolean:return dP();case A.ZodDate:return G_(e,r);case A.ZodUndefined:return DP();case A.ZodNull:return IP();case A.ZodArray:return lP(e,r);case A.ZodUnion:case A.ZodDiscriminatedUnion:return kP(e,r);case A.ZodIntersection:return yP(e,r);case A.ZodTuple:return MP(e,r);case A.ZodRecord:return Y_(e,r);case A.ZodLiteral:return bP(e);case A.ZodEnum:return gP(e);case A.ZodNativeEnum:return $P(e);case A.ZodNullable:return TP(e,r);case A.ZodOptional:return jP(e,r);case A.ZodMap:return xP(e,r);case A.ZodSet:return zP(e,r);case A.ZodLazy:return()=>e.getter()._def;case A.ZodPromise:return RP(e,r);case A.ZodNaN:case A.ZodNever:return SP();case A.ZodEffects:return hP(e,r);case A.ZodAny:return et();case A.ZodUnknown:return UP();case A.ZodDefault:return mP(e,r);case A.ZodBranded:return H_(e,r);case A.ZodReadonly:return LP(e,r);case A.ZodCatch:return pP(e,r);case A.ZodPipeline:return AP(e,r);case A.ZodFunction:case A.ZodVoid:case A.ZodSymbol:return;default:return(o=>{})()}};function le(e,t,r=!1){var o;const n=t.seen.get(e);if(t.override){const l=(o=t.override)==null?void 0:o.call(t,e,t,n,r);if(l!==sP)return l}if(n&&!r){const l=FP(n,t);if(l!==void 0)return l}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const a=ZP(e,e.typeName,t),s=typeof a=="function"?le(a(),t):a;if(s&&qP(e,t,s),t.postProcess){const l=t.postProcess(s,e,t);return i.jsonSchema=s,l}return i.jsonSchema=s,s}var FP=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:aP(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,o)=>t.currentPath[o]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),et()):t.$refStrategy==="seen"?et():void 0}},qP=(e,t,r)=>(e.description&&(r.description=e.description),r),VP=e=>{const t=uP(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([o,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,o],jsonSchema:void 0}]))}},BP=(e,t)=>{var r;const o=VP(t);let n=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:et()}},{}):void 0;const i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=(r=le(e._def,i===void 0?o:{...o,currentPath:[...o.basePath,o.definitionPath,i]},!1))!=null?r: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?n?{...a,[o.definitionPath]:n}:a:{$ref:[...o.$refStrategy==="relative"?[]:o.basePath,o.definitionPath,i].join("/"),[o.definitionPath]:{...n,[i]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},JP=BP;function WP(e,t){var r;const o=(r=void 0)!=null?r:!1;return Fa(()=>JP(e,{$refStrategy:o?"root":"none"}),{validate:async n=>{const i=await e.safeParseAsync(n);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function HP(e,t){var r;const o=(r=void 0)!=null?r:!1;return Fa(()=>ti(da(e,{target:"draft-7",io:"input",reused:o?"ref":"inline"})),{validate:async n=>{const i=await pa(e,n);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function GP(e){return"_zod"in e}function Q_(e,t){return GP(e)?HP(e):WP(e)}var du=Symbol.for("vercel.ai.schema");function Fa(e,{validate:t}={}){return{[du]:!0,_type:void 0,[Ti]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function KP(e){return typeof e=="object"&&e!==null&&du in e&&e[du]===!0&&"jsonSchema"in e&&"validate"in e}function YP(e){return e==null?Fa({properties:{},additionalProperties:!1}):KP(e)?e:typeof e=="function"?e():Q_(e)}function QP(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var XP=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},gr="1.9.0",Sp=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function eC(e){var t=new Set([e]),r=new Set,o=e.match(Sp);if(!o)return function(){return!1};var n={major:+o[1],minor:+o[2],patch:+o[3],prerelease:o[4]};if(n.prerelease!=null)return function(l){return l===e};function i(s){return r.add(s),!1}function a(s){return t.add(s),!0}return function(l){if(t.has(l))return!0;if(r.has(l))return!1;var u=l.match(Sp);if(!u)return i(l);var c={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return c.prerelease!=null||n.major!==c.major?i(l):n.major===0?n.minor===c.minor&&n.patch<=c.patch?a(l):i(l):n.minor<=c.minor?a(l):i(l)}}var tC=eC(gr),rC=gr.split(".")[0],Un=Symbol.for("opentelemetry.js.api."+rC),Ln=XP;function Cc(e,t,r,o){var n;o===void 0&&(o=!1);var i=Ln[Un]=(n=Ln[Un])!==null&&n!==void 0?n:{version:gr};if(!o&&i[e]){var a=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return r.error(a.stack||a.message),!1}if(i.version!==gr){var a=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+e+" does not match previously registered API v"+gr);return r.error(a.stack||a.message),!1}return i[e]=t,r.debug("@opentelemetry/api: Registered a global for "+e+" v"+gr+"."),!0}function Zn(e){var t,r,o=(t=Ln[Un])===null||t===void 0?void 0:t.version;if(!(!o||!tC(o)))return(r=Ln[Un])===null||r===void 0?void 0:r[e]}function jc(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+gr+".");var r=Ln[Un];r&&delete r[e]}var nC=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],a;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},oC=function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;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))},iC=(function(){function e(t){this._namespace=t.namespace||"DiagComponentLogger"}return e.prototype.debug=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("debug",this._namespace,t)},e.prototype.error=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("error",this._namespace,t)},e.prototype.info=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("info",this._namespace,t)},e.prototype.warn=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("warn",this._namespace,t)},e.prototype.verbose=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("verbose",this._namespace,t)},e})();function _n(e,t,r){var o=Zn("diag");if(o)return r.unshift(t),o[e].apply(o,oC([],nC(r),!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 aC(e,t){e<Ke.NONE?e=Ke.NONE:e>Ke.ALL&&(e=Ke.ALL),t=t||{};function r(o,n){var i=t[o];return typeof i=="function"&&e>=n?i.bind(t):function(){}}return{error:r("error",Ke.ERROR),warn:r("warn",Ke.WARN),info:r("info",Ke.INFO),debug:r("debug",Ke.DEBUG),verbose:r("verbose",Ke.VERBOSE)}}var sC=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],a;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},uC=function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;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))},lC="diag",Ni=(function(){function e(){function t(n){return function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];var s=Zn("diag");if(s)return s[n].apply(s,uC([],sC(i),!1))}}var r=this,o=function(n,i){var a,s,l;if(i===void 0&&(i={logLevel:Ke.INFO}),n===r){var u=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((a=u.stack)!==null&&a!==void 0?a:u.message),!1}typeof i=="number"&&(i={logLevel:i});var c=Zn("diag"),d=aC((s=i.logLevel)!==null&&s!==void 0?s:Ke.INFO,n);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 Cc("diag",d,r,!0)};r.setLogger=o,r.disable=function(){jc(lC,r)},r.createComponentLogger=function(n){return new iC(n)},r.verbose=t("verbose"),r.debug=t("debug"),r.info=t("info"),r.warn=t("warn"),r.error=t("error")}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e})();function cC(e){return Symbol.for(e)}var dC=(function(){function e(t){var r=this;r._currentContext=t?new Map(t):new Map,r.getValue=function(o){return r._currentContext.get(o)},r.setValue=function(o,n){var i=new e(r._currentContext);return i._currentContext.set(o,n),i},r.deleteValue=function(o){var n=new e(r._currentContext);return n._currentContext.delete(o),n}}return e})(),pC=new dC,fC=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],a;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},mC=function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;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))},hC=(function(){function e(){}return e.prototype.active=function(){return pC},e.prototype.with=function(t,r,o){for(var n=[],i=3;i<arguments.length;i++)n[i-3]=arguments[i];return r.call.apply(r,mC([o],fC(n),!1))},e.prototype.bind=function(t,r){return r},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e})(),gC=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],a;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},vC=function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;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))},bs="context",yC=new hC,X_=(function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(t){return Cc(bs,t,Ni.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(t,r,o){for(var n,i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return(n=this._getContextManager()).with.apply(n,vC([t,r,o],gC(i),!1))},e.prototype.bind=function(t,r){return this._getContextManager().bind(t,r)},e.prototype._getContextManager=function(){return Zn(bs)||yC},e.prototype.disable=function(){this._getContextManager().disable(),jc(bs,Ni.instance())},e})(),pu;(function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"})(pu||(pu={}));var ew="0000000000000000",tw="00000000000000000000000000000000",bC={traceId:tw,spanId:ew,traceFlags:pu.NONE},On=(function(){function e(t){t===void 0&&(t=bC),this._spanContext=t}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(t,r){return this},e.prototype.setAttributes=function(t){return this},e.prototype.addEvent=function(t,r){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,r){},e})(),Ac=cC("OpenTelemetry Context Key SPAN");function Rc(e){return e.getValue(Ac)||void 0}function _C(){return Rc(X_.getInstance().active())}function zc(e,t){return e.setValue(Ac,t)}function wC(e){return e.deleteValue(Ac)}function xC(e,t){return zc(e,new On(t))}function rw(e){var t;return(t=Rc(e))===null||t===void 0?void 0:t.spanContext()}var $C=/^([0-9a-f]{32})$/i,SC=/^[0-9a-f]{16}$/i;function IC(e){return $C.test(e)&&e!==tw}function kC(e){return SC.test(e)&&e!==ew}function nw(e){return IC(e.traceId)&&kC(e.spanId)}function EC(e){return new On(e)}var _s=X_.getInstance(),ow=(function(){function e(){}return e.prototype.startSpan=function(t,r,o){o===void 0&&(o=_s.active());var n=!!r?.root;if(n)return new On;var i=o&&rw(o);return TC(i)&&nw(i)?new On(i):new On},e.prototype.startActiveSpan=function(t,r,o,n){var i,a,s;if(!(arguments.length<2)){arguments.length===2?s=r:arguments.length===3?(i=r,s=o):(i=r,a=o,s=n);var l=a??_s.active(),u=this.startSpan(t,i,l),c=zc(l,u);return _s.with(c,s,void 0,u)}},e})();function TC(e){return typeof e=="object"&&typeof e.spanId=="string"&&typeof e.traceId=="string"&&typeof e.traceFlags=="number"}var OC=new ow,NC=(function(){function e(t,r,o,n){this._provider=t,this.name=r,this.version=o,this.options=n}return e.prototype.startSpan=function(t,r,o){return this._getTracer().startSpan(t,r,o)},e.prototype.startActiveSpan=function(t,r,o,n){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):OC},e})(),PC=(function(){function e(){}return e.prototype.getTracer=function(t,r,o){return new ow},e})(),CC=new PC,Ip=(function(){function e(){}return e.prototype.getTracer=function(t,r,o){var n;return(n=this.getDelegateTracer(t,r,o))!==null&&n!==void 0?n:new NC(this,t,r,o)},e.prototype.getDelegate=function(){var t;return(t=this._delegate)!==null&&t!==void 0?t:CC},e.prototype.setDelegate=function(t){this._delegate=t},e.prototype.getDelegateTracer=function(t,r,o){var n;return(n=this._delegate)===null||n===void 0?void 0:n.getTracer(t,r,o)},e})(),Pi;(function(e){e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR"})(Pi||(Pi={}));var ws="trace",jC=(function(){function e(){this._proxyTracerProvider=new Ip,this.wrapSpanContext=EC,this.isSpanContextValid=nw,this.deleteSpan=wC,this.getSpan=Rc,this.getActiveSpan=_C,this.getSpanContext=rw,this.setSpan=zc,this.setSpanContext=xC}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(t){var r=Cc(ws,this._proxyTracerProvider,Ni.instance());return r&&this._proxyTracerProvider.setDelegate(t),r},e.prototype.getTracerProvider=function(){return Zn(ws)||this._proxyTracerProvider},e.prototype.getTracer=function(t,r){return this.getTracerProvider().getTracer(t,r)},e.prototype.disable=function(){jc(ws,Ni.instance()),this._proxyTracerProvider=new Ip},e})(),AC=jC.getInstance(),RC=Object.defineProperty,zC=(e,t)=>{for(var r in t)RC(e,r,{get:t[r],enumerable:!0})},iw="AI_NoObjectGeneratedError",aw=`vercel.ai.error.${iw}`,MC=Symbol.for(aw),sw,kp=class extends Y{constructor({message:t="No object generated.",cause:r,text:o,response:n,usage:i,finishReason:a}){super({name:iw,message:t,cause:r}),this[sw]=!0,this.text=o,this.response=n,this.usage=i,this.finishReason=a}static isInstance(t){return Y.hasMarker(t,aw)}};sw=MC;var Ep="5.0.116",uw=G([w(),Rt(Uint8Array),Rt(ArrayBuffer),So(e=>{var t,r;return(r=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?r:!1},{message:"Must be a Buffer"})]),Fn=xo(()=>G([yo(),w(),q(),pe(),Xe(w(),Fn),R(Fn)])),ke=Xe(w(),Xe(w(),Fn)),lw=E({type:C("text"),text:w(),providerOptions:ke.optional()}),DC=E({type:C("image"),image:G([uw,Rt(URL)]),mediaType:w().optional(),providerOptions:ke.optional()}),cw=E({type:C("file"),data:G([uw,Rt(URL)]),filename:w().optional(),mediaType:w(),providerOptions:ke.optional()}),UC=E({type:C("reasoning"),text:w(),providerOptions:ke.optional()}),LC=E({type:C("tool-call"),toolCallId:w(),toolName:w(),input:$e(),providerOptions:ke.optional(),providerExecuted:pe().optional()}),ZC=Aa("type",[E({type:C("text"),value:w()}),E({type:C("json"),value:Fn}),E({type:C("error-text"),value:w()}),E({type:C("error-json"),value:Fn}),E({type:C("content"),value:R(G([E({type:C("text"),text:w()}),E({type:C("media"),data:w(),mediaType:w()})]))})]),dw=E({type:C("tool-result"),toolCallId:w(),toolName:w(),output:ZC,providerOptions:ke.optional()}),FC=E({role:C("system"),content:w(),providerOptions:ke.optional()}),qC=E({role:C("user"),content:G([w(),R(G([lw,DC,cw]))]),providerOptions:ke.optional()}),VC=E({role:C("assistant"),content:G([w(),R(G([lw,cw,UC,LC,dw]))]),providerOptions:ke.optional()}),BC=E({role:C("tool"),content:R(dw),providerOptions:ke.optional()});G([FC,qC,VC,BC]);To({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 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: ${
|
|
39
|
-
Error message: ${
|
|
40
|
-
`;break;case"id":s=b.includes("\0")?void 0:b;break;case"retry":/^\d+$/.test(b)?o(parseInt(b,10)):
|
|
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
|
|
42
|
-
`,o);let a=-1;if(
|
|
43
|
-
`&&o++}}return[t,
|
|
37
|
+
`)}})}});var JC=rP(()=>Q_(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:So(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 WC(e){return e.type.startsWith("data-")}function pw(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const r={...e};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const n=t[o];if(n===void 0)continue;const i=o in e?e[o]:void 0,a=n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp),s=i!=null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp);a&&s?r[o]=pw(i,n):r[o]=n}return r}function HC(e){const t=["ROOT"];let r=-1,o=null;function n(l,u,c){switch(l){case'"':{r=u,t.pop(),t.push(c),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{r=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":{r=u,t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"{":{r=u,t.pop(),t.push(c),t.push("INSIDE_OBJECT_START");break}case"[":{r=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"}":{r=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":n(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{r=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":{n(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),r=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:r=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{r=l,t.pop();break}default:{r=l,n(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"]":{r=l,t.pop();break}default:{r=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),r=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":{r=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)):r=l;break}}}let s=e.slice(0,r+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 fw(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await Oi({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await Oi({text:HC(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function Zr(e){return e.type.startsWith("tool-")}function GC(e){return e.type==="dynamic-tool"}function Tp(e){return Zr(e)||GC(e)}function Op(e){return e.type.split("-").slice(1).join("-")}function KC({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function YC({stream:e,messageMetadataSchema:t,dataPartSchemas:r,runUpdateMessageJob:o,onError:n,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?pw(u.message.metadata,v):v;t!=null&&await wp({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 fw(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:Op(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:Op(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":{n?.(new Error(s.errorText));break}default:if(WC(s)){r?.[s.type]!=null&&await wp({value:s.data,schema:r[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 QC({stream:e,onError:t}){const r=e.getReader();try{for(;;){const{done:o}=await r.read();if(o)break}}catch(o){t?.(o)}finally{r.releaseLock()}}To({prefix:"aitxt",size:24});To({prefix:"aiobj",size:24});var XC=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,r)=>{this.queue.push(async()=>{try{await e(),t()}catch(o){r(o)}}),this.processQueue()})}};To({prefix:"aiobj",size:24});var ej={};zC(ej,{object:()=>rj,text:()=>tj});var tj=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),rj=({schema:e})=>{const t=YP(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:r}){const o=await fw(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value};default:{const n=o.state;throw new Error(`Unsupported parse state: ${n}`)}}},async parseOutput({text:r},o){const n=await Oi({text:r});if(!n.success)throw new kp({message:"No object generated: could not parse the response.",cause:n.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=await Pc({value:n.value,schema:t});if(!i.success)throw new kp({message:"No object generated: response did not match schema.",cause:i.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.value}}};async function nj(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:r,type:o}=t,n=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:r,url:n}}))}var oj=class{constructor({api:e="/api/chat",credentials:t,headers:r,body:o,fetch:n,prepareSendMessagesRequest:i,prepareReconnectToStreamRequest:a}){this.api=e,this.credentials=t,this.headers=r,this.body=o,this.fetch=n,this.prepareSendMessagesRequest=i,this.prepareReconnectToStreamRequest=a}async sendMessages({abortSignal:e,...t}){var r,o,n,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((r=this.prepareSendMessagesRequest)==null?void 0:r.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=(n=d?.credentials)!=null?n:u,y=await((i=this.fetch)!=null?i:globalThis.fetch)(f,{method:"POST",headers:bp({"Content-Type":"application/json",...p},`ai-sdk/${Ep}`,yp()),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,r,o,n,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=(r=c?.api)!=null?r:`${this.api}/${e.chatId}/stream`,f=c?.headers!==void 0?fr(c.headers):u,p=(o=c?.credentials)!=null?o:l,h=await((n=this.fetch)!=null?n:globalThis.fetch)(d,{method:"GET",headers:bp(f,`ai-sdk/${Ep}`,yp()),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)}},mw=class extends oj{constructor(e={}){super(e)}processResponseStream(e){return iP({stream:e,schema:JC}).pipeThrough(new TransformStream({async transform(t,r){if(!t.success)throw t.error;r.enqueue(t.value)}}))}},ij=class{constructor({generateId:e=W_,id:t=e(),transport:r=new mw,messageMetadataSchema:o,dataPartSchemas:n,state:i,onError:a,onToolCall:s,onFinish:l,onData:u,sendAutomaticallyWhen:c}){this.activeResponse=void 0,this.jobExecutor=new XC,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 nj(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=>Tp(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=>Tp(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=r,this.generateId=e,this.messageMetadataSchema=o,this.dataPartSchemas=n,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:r,body:o,messageId:n}){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:KC({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:r,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:r,body:o,trigger:e,messageId:n});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 QC({stream:YC({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:r,body:o})}};const Np=(e,t)=>{if(t==null)return[];let r=e.findIndex(o=>o.id===t);if(r===-1)throw new Error("useVercelAIThreadState: Message not found. This is likely an internal bug in assistant-ui.");for(;e[r+1]?.role==="assistant";)r++;return e.slice(0,r+1)},Pp=e=>{const r=[...e.content.filter(o=>o.type!=="file"),...e.attachments?.flatMap(o=>o.content.map(n=>({...n,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:r}},aj=e=>new Promise((t,r)=>{const o=new FileReader;o.onload=()=>t(o.result),o.onerror=n=>r(n),o.readAsDataURL(e)}),sj={accept:"image/*, text/plain, text/html, text/markdown, text/csv, text/xml, text/json, text/css",async add({file:e}){return{id:W_(),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 aj(e.file)}]}},async remove(){}},Cp=e=>L.getExternalStoreMessages(e);function uj(e){return e.replace(/[}\]"]+$/,"")}const xs=(e,t)=>!e.parts||e.parts.length===0?[]:e.parts.filter(r=>r.type!=="step-start"&&r.type!=="file").map(r=>{const o=r.type;if(o==="text")return{type:"text",text:r.text};if(o==="reasoning")return{type:"reasoning",text:r.text};if(Zr(r)){const n=o.replace("tool-",""),i=r.toolCallId;let a={},s,l=!1;r.state==="input-streaming"||r.state==="input-available"?a=r.input||{}:r.state==="output-available"?(a=r.input||{},s=r.output):r.state==="output-error"&&(a=r.input||{},l=!0,s={error:r.errorText});let u=JSON.stringify(a);r.state==="input-streaming"&&(u=uj(u));const c=t.toolStatuses?.[i];return{type:"tool-call",toolName:n,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 n=r.toolName,i=r.toolCallId;let a={},s,l=!1;r.state==="input-streaming"||r.state==="input-available"?a=r.input||{}:r.state==="output-available"?(a=r.input||{},s=r.output):r.state==="output-error"&&(a=r.input||{},l=!0,s={error:r.errorText});const u=t.toolStatuses?.[i];return{type:"tool-call",toolName:n,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:r.sourceId,url:r.url,title:r.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:r.data}:(console.warn(`Unsupported message part type: ${o}`),null)}).filter(Boolean),jp=L.unstable_createMessageConverter((e,t)=>{const r=new Date;switch(e.role){case"user":return{role:"user",id:e.id,createdAt:r,content:xs(e,t),attachments:e.parts?.filter(o=>o.type==="file").map((o,n)=>({id:n.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:r,content:xs(e,t)};case"assistant":return{role:"assistant",id:e.id,createdAt:r,content:xs(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}`),[]}}),lj={format:"ai-sdk/v5",encode({message:{id:e,parts:t,...r}}){return{...r,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:cj}=L.INTERNAL,dj=(e,t)=>({headId:t.headId,messages:t.messages.map(r=>{const o=e([r.message])[0];return{...r,message:o}})}),pj=(e,t,r,o,n)=>{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(()=>n);return D.useEffect(()=>{d.current=n}),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=dj(r,p);e.current.thread.import(g);const h=new cj;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,r,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},fj=(e,{adapters:t,toCreateMessage:r,cancelPendingToolCallsOnSend:o=!0}={})=>{const n=L.useRuntimeAdapters(),[i,a]=D.useState({}),s=Object.values(i).some(h=>h?.type==="executing"),l=e.status==="submitted"||e.status==="streaming"||s,u=jp.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=pj(c,t?.history??n?.history,jp.toThreadMessages,lj,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(Cp).filter(Boolean).flat()),onImport:h=>e.setMessages(h.map(Cp).filter(Boolean).flat()),onCancel:async()=>{e.stop(),await d.abort()},onNew:async h=>{await p();const b=(r??Pp)(h);await e.sendMessage(b,{metadata:h.runConfig})},onEdit:async h=>{const b=Np(e.messages,h.parentId);e.setMessages(b);const y=(r??Pp)(h);await e.sendMessage(y,{metadata:h.runConfig})},onReload:async(h,b)=>{const y=Np(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:sj,...n,...t},isLoading:f});return g};var $s,Ap;function mj(){if(Ap)return $s;Ap=1;function e(t,r){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let o,n=0;return function(...a){clearTimeout(o);const s=Date.now(),l=s-n,u=r-l;u<=0?(n=s,t.apply(this,a)):o=setTimeout(()=>{n=Date.now(),t.apply(this,a)},u)}}return $s=e,$s}var hj=mj();const gj=QP(hj);var Vo={exports:{}},Ss={};var Rp;function vj(){if(Rp)return Ss;Rp=1;var e=D;function t(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var r=typeof Object.is=="function"?Object.is:t,o=e.useState,n=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]),n(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!r(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 Ss.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:c,Ss}var Is={};var zp;function yj(){return zp||(zp=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||n.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,r(y)&&x({inst:y})},[p,h,g]),s(function(){return r(y)&&x({inst:y}),p(function(){r(y)&&x({inst:y})})},[p]),u(h),h}function r(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 n=D,i=typeof Object.is=="function"?Object.is:e,a=n.useState,s=n.useEffect,l=n.useLayoutEffect,u=n.useDebugValue,c=!1,d=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:t;Is.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Is}var Mp;function bj(){return Mp||(Mp=1,process.env.NODE_ENV==="production"?Vo.exports=vj():Vo.exports=yj()),Vo.exports}var _j=bj(),hw=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},_e=(e,t,r)=>(hw(e,t,"read from private field"),r?r.call(e):t.get(e)),Ot=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Yt=(e,t,r,o)=>(hw(e,t,"write to private field"),t.set(e,r),r);function wj(e,t){return t!=null?gj(e,t):e}var it,ri,ni,kn,En,Tn,Dr,fu,mu,xj=class{constructor(e=[]){Ot(this,it,void 0),Ot(this,ri,"ready"),Ot(this,ni,void 0),Ot(this,kn,new Set),Ot(this,En,new Set),Ot(this,Tn,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,r)=>{Yt(this,it,[..._e(this,it).slice(0,t),this.snapshot(r),..._e(this,it).slice(t+1)]),_e(this,Dr).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,r)=>{const o=r?wj(t,r):t;return _e(this,kn).add(o),()=>{_e(this,kn).delete(o)}},this["~registerStatusCallback"]=t=>(_e(this,En).add(t),()=>{_e(this,En).delete(t)}),this["~registerErrorCallback"]=t=>(_e(this,Tn).add(t),()=>{_e(this,Tn).delete(t)}),Ot(this,Dr,()=>{_e(this,kn).forEach(t=>t())}),Ot(this,fu,()=>{_e(this,En).forEach(t=>t())}),Ot(this,mu,()=>{_e(this,Tn).forEach(t=>t())}),Yt(this,it,e)}get status(){return _e(this,ri)}set status(e){Yt(this,ri,e),_e(this,fu).call(this)}get error(){return _e(this,ni)}set error(e){Yt(this,ni,e),_e(this,mu).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;kn=new WeakMap;En=new WeakMap;Tn=new WeakMap;Dr=new WeakMap;fu=new WeakMap;mu=new WeakMap;var Ur,Dp=class extends ij{constructor({messages:t,...r}){const o=new xj(t);super({...r,state:o}),Ot(this,Ur,void 0),this["~registerMessagesCallback"]=(n,i)=>_e(this,Ur)["~registerMessagesCallback"](n,i),this["~registerStatusCallback"]=n=>_e(this,Ur)["~registerStatusCallback"](n),this["~registerErrorCallback"]=n=>_e(this,Ur)["~registerErrorCallback"](n),Yt(this,Ur,o)}};Ur=new WeakMap;function $j({experimental_throttle:e,resume:t=!1,...r}={}){const o=D.useRef("chat"in r?r.chat:new Dp(r));("chat"in r&&r.chat!==o.current||"id"in r&&o.current.id!==r.id)&&(o.current="chat"in r?r.chat:new Dp(r));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 Sj=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r.description?{description:r.description}:void 0,parameters:r.parameters instanceof gi.ZodType?gi.toJSONSchema(r.parameters):r.parameters}])),Ij=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>!t.disabled&&t.type!=="backend"));class Up extends mw{runtime;constructor(t){super({...t,prepareSendMessagesRequest:async r=>{const o=this.runtime?.thread.getModelContext(),n=(await this.runtime?.threads.mainItem.initialize())?.remoteId??r.id,i={...r,body:{callSettings:o?.callSettings,system:o?.system,tools:Sj(Ij(o?.tools??{})),...r?.body}},a=await t?.prepareSendMessagesRequest?.(i);return{...a,body:a?.body??{...i.body,id:n,messages:r.messages,trigger:r.trigger,messageId:r.messageId,metadata:r.requestMetadata}}}})}setRuntime(t){this.runtime=t}}const kj=e=>{const t=D.useRef(e);return D.useEffect(()=>{t.current=e}),D.useMemo(()=>new Proxy(t.current,{get(o,n){const i=t.current[n];return typeof i=="function"?i.bind(t.current):i}}),[])},Ej=e=>{const{adapters:t,transport:r,toCreateMessage:o,...n}=e??{},i=kj(r??new Up),a=L.useAssistantState(({threadListItem:u})=>u.id),s=$j({...n,id:a,transport:i}),l=fj(s,{adapters:t,...o&&{toCreateMessage:o}});return i instanceof Up&&i.setRuntime(l),l},Tj=({cloud:e,...t}={})=>{const r=L.unstable_useCloudThreadListAdapter({cloud:e});return L.unstable_useRemoteThreadListRuntime({runtimeHook:function(){return Ej(t)},adapter:r,allowNesting:!0})},Oj=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r.description?{description:r.description}:void 0,inputSchema:Fa(r.parameters)}]));var Nj=Object.defineProperty,Pj=Object.defineProperties,Cj=Object.getOwnPropertyDescriptors,Lp=Object.getOwnPropertySymbols,jj=Object.prototype.hasOwnProperty,Aj=Object.prototype.propertyIsEnumerable,Zp=(e,t,r)=>t in e?Nj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ue=(e,t)=>{for(var r in t||(t={}))jj.call(t,r)&&Zp(e,r,t[r]);if(Lp)for(var r of Lp(t))Aj.call(t,r)&&Zp(e,r,t[r]);return e},Ci=(e,t)=>Pj(e,Cj(t)),gw="vercel.ai.error",Rj=Symbol.for(gw),vw,zj=class yw extends Error{constructor({name:t,message:r,cause:o}){super(r),this[vw]=!0,this.name=t,this.cause=o}static isInstance(t){return yw.hasMarker(t,gw)}static hasMarker(t,r){const o=Symbol.for(r);return t!=null&&typeof t=="object"&&o in t&&typeof t[o]=="boolean"&&t[o]===!0}};vw=Rj;var Ne=zj,bw="AI_APICallError",_w=`vercel.ai.error.${bw}`,Mj=Symbol.for(_w),ww,xt=class extends Ne{constructor({message:e,url:t,requestBodyValues:r,statusCode:o,responseHeaders:n,responseBody:i,cause:a,isRetryable:s=o!=null&&(o===408||o===409||o===429||o>=500),data:l}){super({name:bw,message:e,cause:a}),this[ww]=!0,this.url=t,this.requestBodyValues=r,this.statusCode=o,this.responseHeaders=n,this.responseBody=i,this.isRetryable=s,this.data=l}static isInstance(e){return Ne.hasMarker(e,_w)}};ww=Mj;var xw="AI_EmptyResponseBodyError",$w=`vercel.ai.error.${xw}`,Dj=Symbol.for($w),Sw,Uj=class extends Ne{constructor({message:e="Empty response body"}={}){super({name:xw,message:e}),this[Sw]=!0}static isInstance(e){return Ne.hasMarker(e,$w)}};Sw=Dj;function Iw(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var kw="AI_InvalidArgumentError",Ew=`vercel.ai.error.${kw}`,Lj=Symbol.for(Ew),Tw,Ow=class extends Ne{constructor({message:t,cause:r,argument:o}){super({name:kw,message:t,cause:r}),this[Tw]=!0,this.argument=o}static isInstance(t){return Ne.hasMarker(t,Ew)}};Tw=Lj;var Nw="AI_InvalidPromptError",Pw=`vercel.ai.error.${Nw}`,Zj=Symbol.for(Pw),Cw,Fj=class extends Ne{constructor({prompt:e,message:t,cause:r}){super({name:Nw,message:`Invalid prompt: ${t}`,cause:r}),this[Cw]=!0,this.prompt=e}static isInstance(e){return Ne.hasMarker(e,Pw)}};Cw=Zj;var jw="AI_InvalidResponseDataError",Aw=`vercel.ai.error.${jw}`,qj=Symbol.for(Aw),Rw,wn=class extends Ne{constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:jw,message:t}),this[Rw]=!0,this.data=e}static isInstance(e){return Ne.hasMarker(e,Aw)}};Rw=qj;var zw="AI_JSONParseError",Mw=`vercel.ai.error.${zw}`,Vj=Symbol.for(Mw),Dw,ji=class extends Ne{constructor({text:e,cause:t}){super({name:zw,message:`JSON parsing failed: Text: ${e}.
|
|
38
|
+
Error message: ${Iw(t)}`,cause:t}),this[Dw]=!0,this.text=e}static isInstance(e){return Ne.hasMarker(e,Mw)}};Dw=Vj;var Uw="AI_LoadAPIKeyError",Lw=`vercel.ai.error.${Uw}`,Bj=Symbol.for(Lw),Zw,Bo=class extends Ne{constructor({message:e}){super({name:Uw,message:e}),this[Zw]=!0}static isInstance(e){return Ne.hasMarker(e,Lw)}};Zw=Bj;var Fw="AI_NoContentGeneratedError",qw=`vercel.ai.error.${Fw}`,Jj=Symbol.for(qw),Vw,Bw=class extends Ne{constructor({message:e="No content generated."}={}){super({name:Fw,message:e}),this[Vw]=!0}static isInstance(e){return Ne.hasMarker(e,qw)}};Vw=Jj;var Jw="AI_TypeValidationError",Ww=`vercel.ai.error.${Jw}`,Wj=Symbol.for(Ww),Hw,Hj=class hu extends Ne{constructor({value:t,cause:r}){super({name:Jw,message:`Type validation failed: Value: ${JSON.stringify(t)}.
|
|
39
|
+
Error message: ${Iw(r)}`,cause:r}),this[Hw]=!0,this.value=t}static isInstance(t){return Ne.hasMarker(t,Ww)}static wrap({value:t,cause:r}){return hu.isInstance(r)&&r.value===t?r:new hu({value:t,cause:r})}};Hw=Wj;var qn=Hj,Gw="AI_UnsupportedFunctionalityError",Kw=`vercel.ai.error.${Gw}`,Gj=Symbol.for(Kw),Yw,Xt=class extends Ne{constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:Gw,message:t}),this[Yw]=!0,this.functionality=e}static isInstance(e){return Ne.hasMarker(e,Kw)}};Yw=Gj;var Fp=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 ks(e){}function Kj(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=ks,onError:r=ks,onRetry:o=ks,onComment:n}=e;let i="",a=!0,s,l="",u="";function c(h){const b=a?h.replace(/^\xEF\xBB\xBF/,""):h,[y,x]=Yj(`${i}${b}`);for(const $ of y)d($);i=x,a=!1}function d(h){if(h===""){p();return}if(h.startsWith(":")){n&&n(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)):r(new Fp(`Invalid \`retry\` value: "${b}"`,{type:"invalid-retry",value:b,line:y}));break;default:r(new Fp(`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 Yj(e){const t=[];let r="",o=0;for(;o<e.length;){const n=e.indexOf("\r",o),i=e.indexOf(`
|
|
42
|
+
`,o);let a=-1;if(n!==-1&&i!==-1?a=Math.min(n,i):n!==-1?a=n:i!==-1&&(a=i),a===-1){r=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,r]}var Qj=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:r}={}){let o;super({start(n){o=Kj({onEvent:i=>{n.enqueue(i)},onError(i){e==="terminate"?n.error(i):typeof e=="function"&&e(i)},onRetry:t,onComment:r})},transform(n){o.feed(n)}})}};new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Vn(...e){return e.reduce((t,r)=>ue(ue({},t),r??{}),{})}function qa(e){return Object.fromEntries([...e.headers])}var Xj=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const n=()=>{const i=r.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=r[Math.random()*i|0];return a.join("")};if(e==null)return n;if(r.includes(o))throw new Ow({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${r}".`});return()=>`${e}${o}${n()}`},bt=Xj();function gu(e){return(e instanceof Error||e instanceof DOMException)&&(e.name==="AbortError"||e.name==="ResponseAborted"||e.name==="TimeoutError")}var e1=["fetch failed","failed to fetch"];function t1({error:e,url:t,requestBodyValues:r}){if(gu(e))return e;if(e instanceof TypeError&&e1.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:r,isRetryable:!0})}return e}function r1(e){return Object.fromEntries(Object.entries(e).filter(([t,r])=>r!=null))}function n1({apiKey:e,environmentVariableName:t,apiKeyParameterName:r="apiKey",description:o}){if(typeof e=="string")return e;if(e!=null)throw new Bo({message:`${o} API key must be a string.`});if(typeof process>"u")throw new Bo({message:`${o} API key is missing. Pass it using the '${r}' parameter. Environment variables is not supported in this environment.`});if(e=process.env[t],e==null)throw new Bo({message:`${o} API key is missing. Pass it using the '${r}' parameter or the ${t} environment variable.`});if(typeof e!="string")throw new Bo({message:`${o} API key must be a string. The value of the ${t} environment variable is not a string.`});return e}var o1=/"__proto__"\s*:/,i1=/"constructor"\s*:/;function a1(e){const t=JSON.parse(e);return t===null||typeof t!="object"||o1.test(e)===!1&&i1.test(e)===!1?t:s1(t)}function s1(e){let t=[e];for(;t.length;){const r=t;t=[];for(const o of r){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 n in o){const i=o[n];i&&typeof i=="object"&&t.push(i)}}}return e}function Mc(e){const{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return a1(e)}finally{Error.stackTraceLimit=t}}var vu=Symbol.for("vercel.ai.validator");function u1(e){return{[vu]:!0,validate:e}}function l1(e){return typeof e=="object"&&e!==null&&vu in e&&e[vu]===!0&&"validate"in e}function c1(e){return l1(e)?e:d1(e)}function d1(e){return u1(async t=>{const r=await e["~standard"].validate(t);return r.issues==null?{success:!0,value:r.value}:{success:!1,error:new qn({value:t,cause:r.issues})}})}async function p1({value:e,schema:t}){const r=await Qw({value:e,schema:t});if(!r.success)throw qn.wrap({value:e,cause:r.error});return r.value}async function Qw({value:e,schema:t}){const r=c1(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};const o=await r.validate(e);return o.success?{success:!0,value:o.value,rawValue:e}:{success:!1,error:qn.wrap({value:e,cause:o.error}),rawValue:e}}catch(o){return{success:!1,error:qn.wrap({value:e,cause:o}),rawValue:e}}}async function f1({text:e,schema:t}){try{const r=Mc(e);return t==null?r:p1({value:r,schema:t})}catch(r){throw ji.isInstance(r)||qn.isInstance(r)?r:new ji({text:e,cause:r})}}async function Xw({text:e,schema:t}){try{const r=Mc(e);return t==null?{success:!0,value:r,rawValue:r}:await Qw({value:r,schema:t})}catch(r){return{success:!1,error:ji.isInstance(r)?r:new ji({text:e,cause:r}),rawValue:void 0}}}function Es(e){try{return Mc(e),!0}catch{return!1}}function m1({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Qj).pipeThrough(new TransformStream({async transform({data:r},o){r!=="[DONE]"&&o.enqueue(await Xw({text:r,schema:t}))}}))}var h1=()=>globalThis.fetch,Bn=async({url:e,headers:t,body:r,failedResponseHandler:o,successfulResponseHandler:n,abortSignal:i,fetch:a})=>g1({url:e,headers:ue({"Content-Type":"application/json"},t),body:{content:JSON.stringify(r),values:r},failedResponseHandler:o,successfulResponseHandler:n,abortSignal:i,fetch:a}),g1=async({url:e,headers:t={},body:r,successfulResponseHandler:o,failedResponseHandler:n,abortSignal:i,fetch:a=h1()})=>{try{const s=await a(e,{method:"POST",headers:r1(t),body:r.content,signal:i}),l=qa(s);if(!s.ok){let u;try{u=await n({response:s,url:e,requestBodyValues:r.values})}catch(c){throw gu(c)||xt.isInstance(c)?c:new xt({message:"Failed to process error response",cause:c,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:r.values})}throw u.value}try{return await o({response:s,url:e,requestBodyValues:r.values})}catch(u){throw u instanceof Error&&(gu(u)||xt.isInstance(u))?u:new xt({message:"Failed to process successful response",cause:u,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:r.values})}}catch(s){throw t1({error:s,url:e,requestBodyValues:r.values})}},v1=({errorSchema:e,errorToMessage:t,isRetryable:r})=>async({response:o,url:n,requestBodyValues:i})=>{const a=await o.text(),s=qa(o);if(a.trim()==="")return{responseHeaders:s,value:new xt({message:o.statusText,url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:r?.(o)})};try{const l=await f1({text:a,schema:e});return{responseHeaders:s,value:new xt({message:t(l),url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,data:l,isRetryable:r?.(o,l)})}}catch{return{responseHeaders:s,value:new xt({message:o.statusText,url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:r?.(o)})}}},ex=e=>async({response:t})=>{const r=qa(t);if(t.body==null)throw new Uj({});return{responseHeaders:r,value:m1({stream:t.body,schema:e})}},Dc=e=>async({response:t,url:r,requestBodyValues:o})=>{const n=await t.text(),i=await Xw({text:n,schema:e}),a=qa(t);if(!i.success)throw new xt({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:a,responseBody:n,url:r,requestBodyValues:o});return{responseHeaders:a,value:i.value,rawValue:i.rawValue}},{btoa:y1}=globalThis;function b1(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCodePoint(e[r]);return y1(t)}function _1(e){return e?.replace(/\/$/,"")}function Ts(e){return e!=null}var tx=(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))(tx||{}),Uc=E({id:w().nullish(),format:dr(tx).nullish(),index:q().optional()}).loose(),w1=E({type:C("reasoning.summary"),summary:w()}).extend(Uc.shape),x1=E({type:C("reasoning.encrypted"),data:w()}).extend(Uc.shape),$1=E({type:C("reasoning.text"),text:w().nullish(),signature:w().nullish()}).extend(Uc.shape),Lc=G([w1,x1,$1]),oi=G([Lc,$e().transform(()=>null)]),Zc=R(oi).transform(e=>e.filter(t=>!!t));G([E({delta:E({reasoning_details:R(oi)})}).transform(e=>e.delta.reasoning_details.filter(Ts)),E({message:E({reasoning_details:R(oi)})}).transform(e=>e.message.reasoning_details.filter(Ts)),E({text:w(),reasoning_details:R(oi)}).transform(e=>e.reasoning_details.filter(Ts))]);var Va=E({error:E({code:G([w(),q()]).nullable().optional().default(null),message:w(),type:w().nullable().optional().default(null),param:Pe().nullable().optional().default(null)}).passthrough()}).passthrough(),Jn=v1({errorSchema:Va,errorToMessage:e=>e.error.message}),rx=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()),S1=E({provider:w(),reasoning_details:R(Lc).optional(),annotations:R(rx).optional(),usage:E({promptTokens:q(),promptTokensDetails:E({cachedTokens:q()}).catchall(Pe()).optional(),completionTokens:q(),completionTokensDetails:E({reasoningTokens:q()}).catchall(Pe()).optional(),totalTokens:q(),cost:q().optional(),costDetails:E({upstreamInferenceCost:q()}).catchall(Pe()).optional()}).catchall(Pe())}).catchall(Pe()),qp=E({openrouter:E({reasoning_details:R(Lc).optional(),annotations:R(rx).optional()}).optional()}).optional();function Ai(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 I1=["wav","mp3","aiff","aac","ogg","flac","m4a","pcm16","pcm24"];function Fc({url:e,protocols:t}){try{const r=new URL(e);return t.has(r.protocol)}catch{return!1}}function yu({part:e,defaultMediaType:t}){var r,o;if(e.data instanceof Uint8Array){const i=b1(e.data);return`data:${(r=e.mediaType)!=null?r:t};base64,${i}`}const n=e.data.toString();return Fc({url:n,protocols:new Set(["http:","https:"])})||n.startsWith("data:")?n:`data:${(o=e.mediaType)!=null?o:t};base64,${n}`}function Vp(e,t){var r;const o=e.match(/^data:([^;]+)/);return o&&(r=o[1])!=null?r:t}function bu(e){const t=e.match(/^data:[^;]*;base64,(.+)$/);return t?t[1]:e}var k1={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 E1(e){const t=yu({part:e,defaultMediaType:"audio/mpeg"});if(Fc({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,28 +49,28 @@ 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
|
|
52
|
+
Learn more: https://openrouter.ai/docs/features/multimodal/audio`);const r=bu(t),o=e.mediaType||"audio/mpeg",n=o.replace("audio/",""),i=k1[n];if(i===void 0){const a=I1.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 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}
|
|
56
|
+
Learn more: https://openrouter.ai/docs/features/multimodal/audio`)}return{data:r,format:i}}function Kt(e){var t,r,o;const n=e?.anthropic,i=e?.openrouter;return(o=(r=(t=i?.cacheControl)!=null?t:i?.cache_control)!=null?r:n?.cacheControl)!=null?o:n?.cache_control}function T1(e){var t,r,o,n,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=(r=Kt(g))!=null?r: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:yu({part:y,defaultMediaType:"image/jpeg"})},cache_control:z};if((v=y.mediaType)!=null&&v.startsWith("audio/"))return{type:"input_audio",input_audio:E1(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=yu({part:y,defaultMediaType:"application/pdf"});return Fc({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=qp.safeParse(I.providerOptions);O.success&&((i=(n=O.data)==null?void 0:n.openrouter)!=null&&i.reasoning_details)&&x.push(...O.data.openrouter.reasoning_details);break}}const $=qp.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=O1(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 O1(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 N1(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 Ow({argument:"toolChoice",message:`Invalid tool choice type: ${JSON.stringify(e)}`})}}var P1=E({type:C("image_url"),image_url:E({url:w()}).passthrough()}).passthrough(),C1=G([P1,$e().transform(()=>null)]),nx=R(C1).transform(e=>e.filter(t=>!!t)),ox=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(),j1=G([ox.extend({choices:R(E({message:E({role:C("assistant"),content:w().nullable().optional(),reasoning:w().nullable().optional(),reasoning_details:Zc.nullish(),images:nx.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: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())}),Va.extend({user_id:w().optional()})]),A1=G([ox.extend({choices:R(E({delta:E({role:dr(["assistant"]).optional(),content:w().nullish(),reasoning:w().nullish().optional(),reasoning_details:Zc.nullish(),images:nx.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(G([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())}),Va]),R1=class{constructor(e,t,r){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=r}getArgs({prompt:e,maxOutputTokens:t,temperature:r,topP:o,frequencyPenalty:n,presencePenalty:i,seed:a,stopSequences:s,responseFormat:l,topK:u,tools:c,toolChoice:d}){var f;const p=ue(ue({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:r,top_p:o,frequency_penalty:n,presence_penalty:i,seed:a,stop:s,response_format:l?.type==="json"?l.schema!=null?{type:"json_schema",json_schema:ue({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:T1(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 Ci(ue({},p),{tools:g,tool_choice:d?N1(d):void 0})}return p}async doGenerate(e){var t,r,o,n,i,a,s,l,u,c,d,f,p,g,h,b,y,x,$,v,k,N,I;const z=(e.providerOptions||{}).openrouter||{},F=ue(ue({},this.getArgs(e)),z),{value:te,responseHeaders:ie}=await Bn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Vn(this.config.headers(),e.headers),body:F,failedResponseHandler:Jn,successfulResponseHandler:Dc(j1),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:ie,data:U})}const J=te,V=J.choices[0];if(!V)throw new Bw({message:"No choice in response"});const we=J.usage?{inputTokens:(t=J.usage.prompt_tokens)!=null?t:0,outputTokens:(r=J.usage.completion_tokens)!=null?r:0,totalTokens:((o=J.usage.prompt_tokens)!=null?o:0)+((n=J.usage.completion_tokens)!=null?n:0),reasoningTokens:(a=(i=J.usage.completion_tokens_details)==null?void 0:i.reasoning_tokens)!=null?a:0,cachedInputTokens:(l=(s=J.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:[],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):V.message.reasoning?[{type:"reasoning",text:V.message.reasoning}]:[],K=[];if(K.push(...de),V.message.content&&K.push({type:"text",text:V.message.content}),V.message.tool_calls)for(const U of V.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(V.message.images)for(const U of V.message.images)K.push({type:"file",mediaType:Vp(U.image_url.url,"image/jpeg"),data:bu(U.image_url.url)});if(V.message.annotations)for(const U of V.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=V.message.annotations)==null?void 0:d.filter(U=>U.type==="file"),B=V.message.tool_calls&&V.message.tool_calls.length>0,Ue=oe.some(U=>U.type==="reasoning.encrypted"&&U.data),Le=B&&Ue&&V.finish_reason==="stop"?"tool-calls":Ai(V.finish_reason);return{content:K,finishReason:Le,usage:we,warnings:[],providerMetadata:{openrouter:S1.parse({provider:(f=J.provider)!=null?f:"",reasoning_details:(p=V.message.reasoning_details)!=null?p:[],annotations:fe&&fe.length>0?fe:void 0,usage:ue(ue(ue({promptTokens:(g=we.inputTokens)!=null?g:0,completionTokens:(h=we.outputTokens)!=null?h:0,totalTokens:(b=we.totalTokens)!=null?b:0,cost:(y=J.usage)==null?void 0:y.cost},(($=(x=J.usage)==null?void 0:x.prompt_tokens_details)==null?void 0:$.cached_tokens)!=null?{promptTokensDetails:{cachedTokens:J.usage.prompt_tokens_details.cached_tokens}}:{}),((k=(v=J.usage)==null?void 0:v.completion_tokens_details)==null?void 0:k.reasoning_tokens)!=null?{completionTokensDetails:{reasoningTokens:J.usage.completion_tokens_details.reasoning_tokens}}:{}),((I=(N=J.usage)==null?void 0:N.cost_details)==null?void 0:I.upstream_inference_cost)!=null?{costDetails:{upstreamInferenceCost:J.usage.cost_details.upstream_inference_cost}}:{})})},request:{body:F},response:{id:J.id,modelId:J.model,headers:ie}}}async doStream(e){var t;const o=(e.providerOptions||{}).openrouter||{},n=ue(ue({},this.getArgs(e)),o),{value:i,responseHeaders:a}=await Bn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Vn(this.config.headers(),e.headers),body:Ci(ue({},n),{stream:!0,stream_options:this.config.compatibility==="strict"?ue({include_usage:!0},(t=this.settings.usage)!=null&&t.include?{include_usage:!0}:{}):void 0}),failedResponseHandler:Jn,successfulResponseHandler:ex(A1),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,ie,J,V,we,oe,de,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 U=(I=B.usage.cost_details)==null?void 0:I.upstream_inference_cost;U!=null&&(c.costDetails={upstreamInferenceCost:U})}const Ue=B.choices[0];if(Ue?.finish_reason!=null&&(l=Ai(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(ue({},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&&((ie=xe.function)==null?void 0:ie.arguments)!=null&&Es(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})),((J=U.function)==null?void 0:J.arguments)!=null&&(me.function.arguments+=(we=(V=U.function)==null?void 0:V.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&&Es(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:Vp(U.image_url.url,"image/jpeg"),data:bu(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:Es(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:n},response:{headers:a}}}};function z1({prompt:e,inputFormat:t,user:r="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 n="";e[0]&&e[0].role==="system"&&(n+=`${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 Fj({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("");n+=`${r}:
|
|
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 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("");
|
|
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("");n+=`${o}:
|
|
62
62
|
${s}
|
|
63
63
|
|
|
64
|
-
`;break}case"tool":throw new Xt({functionality:"tool messages"})}return
|
|
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
|
-
]))`;continue}else if(
|
|
67
|
-
]))`;continue}}if(o.s&&
|
|
68
|
-
`:`[${
|
|
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.
|
|
64
|
+
`;break}case"tool":throw new Xt({functionality:"tool messages"})}return n+=`${o}:
|
|
65
|
+
`,{prompt:n}}var Bp=G([E({id:w().optional(),model:w().optional(),choices:R(E({text:w(),reasoning:w().nullish().optional(),reasoning_details:Zc.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(),Va]),M1=class{constructor(e,t,r){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=r}getArgs({prompt:e,maxOutputTokens:t,temperature:r,topP:o,frequencyPenalty:n,presencePenalty:i,seed:a,responseFormat:s,topK:l,stopSequences:u,tools:c,toolChoice:d}){const{prompt:f}=z1({prompt:e,inputFormat:"prompt"});if(c?.length)throw new Xt({functionality:"tools"});if(d)throw new Xt({functionality:"toolChoice"});return ue(ue({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:r,top_p:o,frequency_penalty:n,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,r,o,n,i,a,s,l,u,c,d,f,p,g,h;const y=(e.providerOptions||{}).openrouter||{},x=ue(ue({},this.getArgs(e)),y),{value:$,responseHeaders:v}=await Bn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Vn(this.config.headers(),e.headers),body:x,failedResponseHandler:Jn,successfulResponseHandler:Dc(Bp),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 Bw({message:"No choice in OpenRouter completion response"});return{content:[{type:"text",text:(t=k.text)!=null?t:""}],finishReason:Ai(k.finish_reason),usage:{inputTokens:(o=(r=$.usage)==null?void 0:r.prompt_tokens)!=null?o:0,outputTokens:(i=(n=$.usage)==null?void 0:n.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 r=(e.providerOptions||{}).openrouter||{},o=ue(ue({},this.getArgs(e)),r),{value:n,responseHeaders:i}=await Bn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Vn(this.config.headers(),e.headers),body:Ci(ue({},o),{stream:!0,stream_options:this.config.compatibility==="strict"?{include_usage:!0}:void 0}),failedResponseHandler:Jn,successfulResponseHandler:ex(Bp),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:n.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=Ai(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}}}},D1=E({prompt_tokens:q(),total_tokens:q(),cost:q().optional()}),U1=E({object:C("embedding"),embedding:R(q()),index:q().optional()}),L1=E({id:w().optional(),object:C("list"),data:R(U1),model:w(),usage:D1.optional()}),Z1=class{constructor(e,t,r){this.specificationVersion="v2",this.provider="openrouter",this.maxEmbeddingsPerCall=void 0,this.supportsParallelCalls=!0,this.modelId=e,this.settings=t,this.config=r}async doEmbed(e){var t;const{values:r,abortSignal:o,headers:n}=e,i=ue(ue({model:this.modelId,input:r,user:this.settings.user,provider:this.settings.provider},this.config.extraBody),this.settings.extraBody),{value:a,responseHeaders:s}=await Bn({url:this.config.url({path:"/embeddings",modelId:this.modelId}),headers:Vn(this.config.headers(),n),body:i,failedResponseHandler:Jn,successfulResponseHandler:Dc(L1),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 F1(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==null))}function q1(e,...t){const r=F1(e??{}),n=[r["user-agent"]||"",...t].filter(Boolean).join(" ");return Ci(ue({},r),{"user-agent":n})}var V1="1.5.4";function ix(e={}){var t,r,o;const n=(r=_1((t=e.baseURL)!=null?t:e.baseUrl))!=null?r:"https://openrouter.ai/api/v1",i=(o=e.compatibility)!=null?o:"compatible",a=()=>q1(ue(ue({Authorization:`Bearer ${n1({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/${V1}`),s=(f,p={})=>new R1(f,p,{provider:"openrouter.chat",url:({path:g})=>`${n}${g}`,headers:a,compatibility:i,fetch:e.fetch,extraBody:e.extraBody}),l=(f,p={})=>new M1(f,p,{provider:"openrouter.completion",url:({path:g})=>`${n}${g}`,headers:a,compatibility:i,fetch:e.fetch,extraBody:e.extraBody}),u=(f,p={})=>new Z1(f,p,{provider:"openrouter.embedding",url:({path:g})=>`${n}${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}ix({compatibility:"strict"});function _u(...e){return e.reduce((t,r)=>({...t,...r??{}}),{})}async function ax(e,t){if(e==null)return Promise.resolve();const r=t?.abortSignal;return new Promise((o,n)=>{if(r?.aborted){n(Jp());return}const i=setTimeout(()=>{a(),o()},e),a=()=>{clearTimeout(i),r?.removeEventListener("abort",s)},s=()=>{a(),n(Jp())};r?.addEventListener("abort",s)})}function Jp(){return new DOMException("Delay was aborted","AbortError")}function Oo(e){return Object.fromEntries([...e.headers])}var No=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const n=()=>{const i=r.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=r[Math.random()*i|0];return a.join("")};if(e==null)return n;if(r.includes(o))throw new Vi({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${r}".`});return()=>`${e}${o}${n()}`},B1=No();function sx(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}function wr(e){return(e instanceof Error||e instanceof DOMException)&&(e.name==="AbortError"||e.name==="ResponseAborted"||e.name==="TimeoutError")}var J1=["fetch failed","failed to fetch"];function ux({error:e,url:t,requestBodyValues:r}){if(wr(e))return e;if(e instanceof TypeError&&J1.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:r,isRetryable:!0})}return e}function qc(e=globalThis){var t,r,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(r=e.process)==null?void 0:r.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function W1(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((r,o)=>{t[o.toLowerCase()]=r});else{Array.isArray(e)||(e=Object.entries(e));for(const[r,o]of e)o!=null&&(t[r.toLowerCase()]=o)}return t}function Ba(e,...t){const r=new Headers(W1(e)),o=r.get("user-agent")||"";return r.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}var lx="3.0.16",H1=()=>globalThis.fetch,Wp=async({url:e,headers:t={},successfulResponseHandler:r,failedResponseHandler:o,abortSignal:n,fetch:i=H1()})=>{try{const a=await i(e,{method:"GET",headers:Ba(t,`ai-sdk/provider-utils/${lx}`,qc()),signal:n}),s=Oo(a);if(!a.ok){let l;try{l=await o({response:a,url:e,requestBodyValues:{}})}catch(u){throw wr(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 r({response:a,url:e,requestBodyValues:{}})}catch(l){throw l instanceof Error&&(wr(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 ux({error:a,url:e,requestBodyValues:{}})}};function G1({mediaType:e,url:t,supportedUrls:r}){return t=t.toLowerCase(),e=e.toLowerCase(),Object.entries(r).map(([o,n])=>{const i=o.toLowerCase();return i==="*"||i==="*/*"?{mediaTypePrefix:"",regexes:n}:{mediaTypePrefix:i.replace(/\*/,""),regexes:n}}).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 K1=/"__proto__"\s*:/,Y1=/"constructor"\s*:/;function Q1(e){const t=JSON.parse(e);return t===null||typeof t!="object"||K1.test(e)===!1&&Y1.test(e)===!1?t:X1(t)}function X1(e){let t=[e];for(;t.length;){const r=t;t=[];for(const o of r){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 n in o){const i=o[n];i&&typeof i=="object"&&t.push(i)}}}return e}function cx(e){const{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return Q1(e)}finally{Error.stackTraceLimit=t}}var Ri=Symbol.for("vercel.ai.validator");function eA(e){return{[Ri]:!0,validate:e}}function tA(e){return typeof e=="object"&&e!==null&&Ri in e&&e[Ri]===!0&&"validate"in e}function cn(e){let t;return()=>(t==null&&(t=e()),t)}function rA(e){return tA(e)?e:typeof e=="function"?e():nA(e)}function nA(e){return eA(async t=>{const r=await e["~standard"].validate(t);return r.issues==null?{success:!0,value:r.value}:{success:!1,error:new Ft({value:t,cause:r.issues})}})}async function wu({value:e,schema:t}){const r=await sr({value:e,schema:t});if(!r.success)throw Ft.wrap({value:e,cause:r.error});return r.value}async function sr({value:e,schema:t}){const r=rA(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};const o=await r.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 oA({text:e,schema:t}){try{const r=cx(e);return t==null?r:wu({value:r,schema:t})}catch(r){throw Jr.isInstance(r)||Ft.isInstance(r)?r:new Jr({text:e,cause:r})}}async function xr({text:e,schema:t}){try{const r=cx(e);return t==null?{success:!0,value:r,rawValue:r}:await sr({value:r,schema:t})}catch(r){return{success:!1,error:Jr.isInstance(r)?r:new Jr({text:e,cause:r}),rawValue:void 0}}}function iA({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).pipeThrough(new TransformStream({async transform({data:r},o){r!=="[DONE]"&&o.enqueue(await xr({text:r,schema:t}))}}))}var aA=()=>globalThis.fetch,xu=async({url:e,headers:t,body:r,failedResponseHandler:o,successfulResponseHandler:n,abortSignal:i,fetch:a})=>sA({url:e,headers:{"Content-Type":"application/json",...t},body:{content:JSON.stringify(r),values:r},failedResponseHandler:o,successfulResponseHandler:n,abortSignal:i,fetch:a}),sA=async({url:e,headers:t={},body:r,successfulResponseHandler:o,failedResponseHandler:n,abortSignal:i,fetch:a=aA()})=>{try{const s=await a(e,{method:"POST",headers:Ba(t,`ai-sdk/provider-utils/${lx}`,qc()),body:r.content,signal:i}),l=Oo(s);if(!s.ok){let u;try{u=await n({response:s,url:e,requestBodyValues:r.values})}catch(c){throw wr(c)||Be.isInstance(c)?c:new Be({message:"Failed to process error response",cause:c,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:r.values})}throw u.value}try{return await o({response:s,url:e,requestBodyValues:r.values})}catch(u){throw u instanceof Error&&(wr(u)||Be.isInstance(u))?u:new Be({message:"Failed to process successful response",cause:u,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:r.values})}}catch(s){throw ux({error:s,url:e,requestBodyValues:r.values})}};async function tr(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var Wn=({errorSchema:e,errorToMessage:t,isRetryable:r})=>async({response:o,url:n,requestBodyValues:i})=>{const a=await o.text(),s=Oo(o);if(a.trim()==="")return{responseHeaders:s,value:new Be({message:o.statusText,url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:r?.(o)})};try{const l=await oA({text:a,schema:e});return{responseHeaders:s,value:new Be({message:t(l),url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,data:l,isRetryable:r?.(o,l)})}}catch{return{responseHeaders:s,value:new Be({message:o.statusText,url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:r?.(o)})}}},uA=e=>async({response:t})=>{const r=Oo(t);if(t.body==null)throw new E0({});return{responseHeaders:r,value:iA({stream:t.body,schema:e})}},zi=e=>async({response:t,url:r,requestBodyValues:o})=>{const n=await t.text(),i=await xr({text:n,schema:e}),a=Oo(t);if(!i.success)throw new Be({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:a,responseBody:n,url:r,requestBodyValues:o});return{responseHeaders:a,value:i.value,rawValue:i.rawValue}},lA=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")},cA=Symbol("Let zodToJsonSchema decide on which parser to use"),Hp={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"},dA=e=>typeof e=="string"?{...Hp,name:e}:{...Hp,...e};function tt(){return{}}function pA(e,t){var r,o,n;const i={type:"array"};return(r=e.type)!=null&&r._def&&((n=(o=e.type)==null?void 0:o._def)==null?void 0:n.typeName)!==A.ZodAny&&(i.items=ce(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 fA(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function mA(){return{type:"boolean"}}function dx(e,t){return ce(e.type._def,t)}var hA=(e,t)=>ce(e.innerType._def,t);function px(e,t,r){const o=r??t.dateStrategy;if(Array.isArray(o))return{anyOf:o.map((n,i)=>px(e,t,n))};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 gA(e)}}var gA=e=>{const t={type:"integer",format:"unix-time"};for(const r of e.checks)switch(r.kind){case"min":t.minimum=r.value;break;case"max":t.maximum=r.value;break}return t};function vA(e,t){return{...ce(e.innerType._def,t),default:e.defaultValue()}}function yA(e,t){return t.effectStrategy==="input"?ce(e.schema._def,t):tt()}function bA(e){return{type:"string",enum:Array.from(e.values)}}var _A=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function wA(e,t){const r=[ce(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),ce(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(n=>!!n),o=[];return r.forEach(n=>{if(_A(n))o.push(...n.allOf);else{let i=n;if("additionalProperties"in n&&n.additionalProperties===!1){const{additionalProperties:a,...s}=n;i=s}o.push(i)}}),o.length?{allOf:o}:void 0}function xA(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 Os=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:()=>(Os===void 0&&(Os=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Os),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 fx(e,t){const r={type:"string"};if(e.checks)for(const o of e.checks)switch(o.kind){case"min":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,o.value):o.value;break;case"max":r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,o.value):o.value;break;case"email":switch(t.emailStrategy){case"format:email":yt(r,"email",o.message,t);break;case"format:idn-email":yt(r,"idn-email",o.message,t);break;case"pattern:zod":qe(r,vt.email,o.message,t);break}break;case"url":yt(r,"uri",o.message,t);break;case"uuid":yt(r,"uuid",o.message,t);break;case"regex":qe(r,o.regex,o.message,t);break;case"cuid":qe(r,vt.cuid,o.message,t);break;case"cuid2":qe(r,vt.cuid2,o.message,t);break;case"startsWith":qe(r,RegExp(`^${Ns(o.value,t)}`),o.message,t);break;case"endsWith":qe(r,RegExp(`${Ns(o.value,t)}$`),o.message,t);break;case"datetime":yt(r,"date-time",o.message,t);break;case"date":yt(r,"date",o.message,t);break;case"time":yt(r,"time",o.message,t);break;case"duration":yt(r,"duration",o.message,t);break;case"length":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,o.value):o.value,r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,o.value):o.value;break;case"includes":{qe(r,RegExp(Ns(o.value,t)),o.message,t);break}case"ip":{o.version!=="v6"&&yt(r,"ipv4",o.message,t),o.version!=="v4"&&yt(r,"ipv6",o.message,t);break}case"base64url":qe(r,vt.base64url,o.message,t);break;case"jwt":qe(r,vt.jwt,o.message,t);break;case"cidr":{o.version!=="v6"&&qe(r,vt.ipv4Cidr,o.message,t),o.version!=="v4"&&qe(r,vt.ipv6Cidr,o.message,t);break}case"emoji":qe(r,vt.emoji(),o.message,t);break;case"ulid":{qe(r,vt.ulid,o.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{yt(r,"binary",o.message,t);break}case"contentEncoding:base64":{r.contentEncoding="base64";break}case"pattern:zod":{qe(r,vt.base64,o.message,t);break}}break}case"nanoid":qe(r,vt.nanoid,o.message,t)}return r}function Ns(e,t){return t.patternStrategy==="escape"?SA(e):e}var $A=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function SA(e){let t="";for(let r=0;r<e.length;r++)$A.has(e[r])||(t+="\\"),t+=e[r];return t}function yt(e,t,r,o){var n;e.format||(n=e.anyOf)!=null&&n.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...r&&o.errorMessages&&{errorMessage:{format:r}}})):e.format=t}function qe(e,t,r,o){var n;e.pattern||(n=e.allOf)!=null&&n.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Gp(t,o),...r&&o.errorMessages&&{errorMessage:{pattern:r}}})):e.pattern=Gp(t,o)}function Gp(e,t){var r;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")},n=o.i?e.source.toLowerCase():e.source;let i="",a=!1,s=!1,l=!1;for(let u=0;u<n.length;u++){if(a){i+=n[u],a=!1;continue}if(o.i){if(s){if(n[u].match(/[a-z]/)){l?(i+=n[u],i+=`${n[u-2]}-${n[u]}`.toUpperCase(),l=!1):n[u+1]==="-"&&((r=n[u+2])!=null&&r.match(/[a-z]/))?(i+=n[u],l=!0):i+=`${n[u]}${n[u].toUpperCase()}`;continue}}else if(n[u].match(/[a-z]/)){i+=`[${n[u]}${n[u].toUpperCase()}]`;continue}}if(o.m){if(n[u]==="^"){i+=`(^|(?<=[\r
|
|
66
|
+
]))`;continue}else if(n[u]==="$"){i+=`($|(?=[\r
|
|
67
|
+
]))`;continue}}if(o.s&&n[u]==="."){i+=s?`${n[u]}\r
|
|
68
|
+
`:`[${n[u]}\r
|
|
69
|
+
]`;continue}i+=n[u],n[u]==="\\"?a=!0:s&&n[u]==="]"?s=!1:!s&&n[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 mx(e,t){var r,o,n,i,a,s;const l={type:"object",additionalProperties:(r=ce(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?r:t.allowedAdditionalProperties};if(((o=e.keyType)==null?void 0:o._def.typeName)===A.ZodString&&((n=e.keyType._def.checks)!=null&&n.length)){const{type:u,...c}=fx(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}=dx(e.keyType._def,t);return{...l,propertyNames:c}}}return l}function IA(e,t){if(t.mapStrategy==="record")return mx(e,t);const r=ce(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||tt(),o=ce(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||tt();return{type:"array",maxItems:125,items:{type:"array",items:[r,o],minItems:2,maxItems:2}}}function kA(e){const t=e.values,o=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),n=Array.from(new Set(o.map(i=>typeof i)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:o}}function EA(){return{not:tt()}}function TA(){return{type:"null"}}var $u={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function OA(e,t){const r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(o=>o._def.typeName in $u&&(!o._def.checks||!o._def.checks.length))){const o=r.reduce((n,i)=>{const a=$u[i._def.typeName];return a&&!n.includes(a)?[...n,a]:n},[]);return{type:o.length>1?o:o[0]}}else if(r.every(o=>o._def.typeName==="ZodLiteral"&&!o.description)){const o=r.reduce((n,i)=>{const a=typeof i._def.value;switch(a){case"string":case"number":case"boolean":return[...n,a];case"bigint":return[...n,"integer"];case"object":if(i._def.value===null)return[...n,"null"];case"symbol":case"undefined":case"function":default:return n}},[]);if(o.length===r.length){const n=o.filter((i,a,s)=>s.indexOf(i)===a);return{type:n.length>1?n:n[0],enum:r.reduce((i,a)=>i.includes(a._def.value)?i:[...i,a._def.value],[])}}}else if(r.every(o=>o._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((o,n)=>[...o,...n._def.values.filter(i=>!o.includes(i))],[])};return NA(e,t)}var NA=(e,t)=>{const r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((o,n)=>ce(o._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(o=>!!o&&(!t.strictUnions||typeof o=="object"&&Object.keys(o).length>0));return r.length?{anyOf:r}:void 0};function PA(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[$u[e.innerType._def.typeName],"null"]};const r=ce(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function CA(e){const t={type:"number"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"int":t.type="integer";break;case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function jA(e,t){const r={type:"object",properties:{}},o=[],n=e.shape();for(const a in n){let s=n[a];if(s===void 0||s._def===void 0)continue;const l=RA(s),u=ce(s._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});u!==void 0&&(r.properties[a]=u,l||o.push(a))}o.length&&(r.required=o);const i=AA(e,t);return i!==void 0&&(r.additionalProperties=i),r}function AA(e,t){if(e.catchall._def.typeName!=="ZodNever")return ce(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 RA(e){try{return e.isOptional()}catch{return!0}}var zA=(e,t)=>{var r;if(t.currentPath.toString()===((r=t.propertyPath)==null?void 0:r.toString()))return ce(e.innerType._def,t);const o=ce(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return o?{anyOf:[{not:tt()},o]}:tt()},MA=(e,t)=>{if(t.pipeStrategy==="input")return ce(e.in._def,t);if(t.pipeStrategy==="output")return ce(e.out._def,t);const r=ce(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),o=ce(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,o].filter(n=>n!==void 0)}};function DA(e,t){return ce(e.type._def,t)}function UA(e,t){const o={type:"array",uniqueItems:!0,items:ce(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 LA(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,o)=>ce(r._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((r,o)=>o===void 0?r:[...r,o],[]),additionalItems:ce(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,o)=>ce(r._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((r,o)=>o===void 0?r:[...r,o],[])}}function ZA(){return{not:tt()}}function FA(){return tt()}var qA=(e,t)=>ce(e.innerType._def,t),VA=(e,t,r)=>{switch(t){case A.ZodString:return fx(e,r);case A.ZodNumber:return CA(e);case A.ZodObject:return jA(e,r);case A.ZodBigInt:return fA(e);case A.ZodBoolean:return mA();case A.ZodDate:return px(e,r);case A.ZodUndefined:return ZA();case A.ZodNull:return TA();case A.ZodArray:return pA(e,r);case A.ZodUnion:case A.ZodDiscriminatedUnion:return OA(e,r);case A.ZodIntersection:return wA(e,r);case A.ZodTuple:return LA(e,r);case A.ZodRecord:return mx(e,r);case A.ZodLiteral:return xA(e);case A.ZodEnum:return bA(e);case A.ZodNativeEnum:return kA(e);case A.ZodNullable:return PA(e,r);case A.ZodOptional:return zA(e,r);case A.ZodMap:return IA(e,r);case A.ZodSet:return UA(e,r);case A.ZodLazy:return()=>e.getter()._def;case A.ZodPromise:return DA(e,r);case A.ZodNaN:case A.ZodNever:return EA();case A.ZodEffects:return yA(e,r);case A.ZodAny:return tt();case A.ZodUnknown:return FA();case A.ZodDefault:return vA(e,r);case A.ZodBranded:return dx(e,r);case A.ZodReadonly:return qA(e,r);case A.ZodCatch:return hA(e,r);case A.ZodPipeline:return MA(e,r);case A.ZodFunction:case A.ZodVoid:case A.ZodSymbol:return;default:return(o=>{})()}};function ce(e,t,r=!1){var o;const n=t.seen.get(e);if(t.override){const l=(o=t.override)==null?void 0:o.call(t,e,t,n,r);if(l!==cA)return l}if(n&&!r){const l=BA(n,t);if(l!==void 0)return l}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const a=VA(e,e.typeName,t),s=typeof a=="function"?ce(a(),t):a;if(s&&JA(e,t,s),t.postProcess){const l=t.postProcess(s,e,t);return i.jsonSchema=s,l}return i.jsonSchema=s,s}var BA=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:lA(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,o)=>t.currentPath[o]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),tt()):t.$refStrategy==="seen"?tt():void 0}},JA=(e,t,r)=>(e.description&&(r.description=e.description),r),WA=e=>{const t=dA(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([o,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,o],jsonSchema:void 0}]))}},HA=(e,t)=>{var r;const o=WA(t);let n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,d])=>{var f;return{...u,[c]:(f=ce(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=(r=ce(e._def,i===void 0?o:{...o,currentPath:[...o.basePath,o.definitionPath,i]},!1))!=null?r: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?n?{...a,[o.definitionPath]:n}:a:{$ref:[...o.$refStrategy==="relative"?[]:o.basePath,o.definitionPath,i].join("/"),[o.definitionPath]:{...n,[i]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},GA=HA;function KA(e,t){var r;const o=(r=void 0)!=null?r:!1;return Vc(()=>GA(e,{$refStrategy:o?"root":"none"}),{validate:async n=>{const i=await e.safeParseAsync(n);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function YA(e,t){var r;const o=(r=void 0)!=null?r:!1;return Vc(()=>da(e,{target:"draft-7",io:"output",reused:o?"ref":"inline"}),{validate:async n=>{const i=await pa(e,n);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function QA(e){return"_zod"in e}function Or(e,t){return QA(e)?YA(e):KA(e)}var Su=Symbol.for("vercel.ai.schema");function Vc(e,{validate:t}={}){return{[Su]:!0,_type:void 0,[Ri]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function XA(e){return typeof e=="object"&&e!==null&&Su in e&&e[Su]===!0&&"jsonSchema"in e&&"validate"in e}function Ja(e){return e==null?Vc({properties:{},additionalProperties:!1}):XA(e)?e:typeof e=="function"?e():Or(e)}var{btoa:eR,atob:tR}=globalThis;function Bc(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r=tR(t);return Uint8Array.from(r,o=>o.codePointAt(0))}function Iu(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCodePoint(e[r]);return eR(t)}function rR(e){return e?.replace(/\/$/,"")}function nR(e){return e!=null&&typeof e[Symbol.asyncIterator]=="function"}async function*oR({execute:e,input:t,options:r}){const o=e(t,r);if(nR(o)){let n;for await(const i of o)n=i,yield{type:"preliminary",output:i};yield{type:"final",output:n}}else yield{type:"final",output:await o}}var Ps,Kp;function iR(){if(Kp)return Ps;Kp=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,n=(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 r(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={};n(s,{SYMBOL_FOR_REQ_CONTEXT:()=>l,getContext:()=>u}),Ps=a(s);const l=Symbol.for("@vercel/request-context");function u(){return globalThis[l]?.get?.()??{}}return Ps}var Cs,Yp;function aR(){if(Yp)return Cs;Yp=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,n=(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 r(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={};n(s,{getContext:()=>l.getContext,getVercelOidcToken:()=>u,getVercelOidcTokenSync:()=>c}),Cs=a(s);var l=iR();async function u(){return""}function c(){return""}return Cs}var hx=aR(),sR="vercel.ai.gateway.error",js=Symbol.for(sR),Qp,Xp,rt=class gx extends(Xp=Error,Qp=js,Xp){constructor({message:t,statusCode:r=500,cause:o}){super(t),this[Qp]=!0,this.statusCode=r,this.cause=o}static isInstance(t){return gx.hasMarker(t)}static hasMarker(t){return typeof t=="object"&&t!==null&&js in t&&t[js]===!0}},vx="GatewayAuthenticationError",uR=`vercel.ai.gateway.error.${vx}`,ef=Symbol.for(uR),tf,rf,Jc=class yx extends(rf=rt,tf=ef,rf){constructor({message:t="Authentication failed",statusCode:r=401,cause:o}={}){super({message:t,statusCode:r,cause:o}),this[tf]=!0,this.name=vx,this.type="authentication_error"}static isInstance(t){return rt.hasMarker(t)&&ef in t}static createContextualError({apiKeyProvided:t,oidcTokenProvided:r,message:o="Authentication failed",statusCode:n=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
|
|
|
73
|
-
Provide via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`:
|
|
73
|
+
Provide via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`:r?a=`AI Gateway authentication failed: Invalid OIDC token.
|
|
74
74
|
|
|
75
75
|
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.
|
|
76
76
|
|
|
@@ -81,34 +81,34 @@ 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 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)}
|
|
84
|
+
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,new yx({message:a,statusCode:n,cause:i})}},bx="GatewayInvalidRequestError",lR=`vercel.ai.gateway.error.${bx}`,nf=Symbol.for(lR),of,af,cR=class extends(af=rt,of=nf,af){constructor({message:e="Invalid request",statusCode:t=400,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[of]=!0,this.name=bx,this.type="invalid_request_error"}static isInstance(e){return rt.hasMarker(e)&&nf in e}},_x="GatewayRateLimitError",dR=`vercel.ai.gateway.error.${_x}`,sf=Symbol.for(dR),uf,lf,pR=class extends(lf=rt,uf=sf,lf){constructor({message:e="Rate limit exceeded",statusCode:t=429,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[uf]=!0,this.name=_x,this.type="rate_limit_exceeded"}static isInstance(e){return rt.hasMarker(e)&&sf in e}},wx="GatewayModelNotFoundError",fR=`vercel.ai.gateway.error.${wx}`,cf=Symbol.for(fR),mR=cn(()=>Or(E({modelId:w()}))),df,pf,xx=class extends(pf=rt,df=cf,pf){constructor({message:e="Model not found",statusCode:t=404,modelId:r,cause:o}={}){super({message:e,statusCode:t,cause:o}),this[df]=!0,this.name=wx,this.type="model_not_found",this.modelId=r}static isInstance(e){return rt.hasMarker(e)&&cf in e}},$x="GatewayInternalServerError",hR=`vercel.ai.gateway.error.${$x}`,ff=Symbol.for(hR),mf,hf,gf=class extends(hf=rt,mf=ff,hf){constructor({message:e="Internal server error",statusCode:t=500,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[mf]=!0,this.name=$x,this.type="internal_server_error"}static isInstance(e){return rt.hasMarker(e)&&ff in e}},Sx="GatewayResponseError",gR=`vercel.ai.gateway.error.${Sx}`,vf=Symbol.for(gR),yf,bf,vR=class extends(bf=rt,yf=vf,bf){constructor({message:e="Invalid response from Gateway",statusCode:t=502,response:r,validationError:o,cause:n}={}){super({message:e,statusCode:t,cause:n}),this[yf]=!0,this.name=Sx,this.type="response_error",this.response=r,this.validationError=o}static isInstance(e){return rt.hasMarker(e)&&vf in e}};async function _f({response:e,statusCode:t,defaultMessage:r="Gateway request failed",cause:o,authMethod:n}){const i=await sr({value:e,schema:yR});if(!i.success)return new vR({message:`Invalid error response format: ${r}`,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 Jc.createContextualError({apiKeyProvided:n==="api-key",oidcTokenProvided:n==="oidc",statusCode:t,cause:o});case"invalid_request_error":return new cR({message:l,statusCode:t,cause:o});case"rate_limit_exceeded":return new pR({message:l,statusCode:t,cause:o});case"model_not_found":{const u=await sr({value:a.error.param,schema:mR});return new xx({message:l,statusCode:t,modelId:u.success?u.value.modelId:void 0,cause:o})}case"internal_server_error":return new gf({message:l,statusCode:t,cause:o});default:return new gf({message:l,statusCode:t,cause:o})}}var yR=cn(()=>Or(E({error:E({message:w(),type:w().nullish(),param:$e().nullish(),code:G([w(),q()]).nullish()})})));function $r(e,t){var r;return rt.isInstance(e)?e:Be.isInstance(e)?_f({response:bR(e),statusCode:(r=e.statusCode)!=null?r:500,defaultMessage:"Gateway request failed",cause:e,authMethod:t}):_f({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:"Unknown Gateway error",cause:e,authMethod:t})}function bR(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 Ix="ai-gateway-auth-method";async function Hn(e){const t=await sr({value:e[Ix],schema:_R});return t.success?t.value:void 0}var _R=cn(()=>Or(G([C("api-key"),C("oidc")]))),wf=class{constructor(e){this.config=e}async getAvailableModels(){try{const{value:e}=await Wp({url:`${this.config.baseURL}/config`,headers:await tr(this.config.headers()),successfulResponseHandler:zi(wR),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:t=>t}),fetch:this.config.fetch});return e}catch(e){throw await $r(e)}}async getCredits(){try{const e=new URL(this.config.baseURL),{value:t}=await Wp({url:`${e.origin}/v1/credits`,headers:await tr(this.config.headers()),successfulResponseHandler:zi(xR),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:r=>r}),fetch:this.config.fetch});return t}catch(e){throw await $r(e)}}},wR=cn(()=>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:r,input_cache_write:o})=>({input:e,output:t,...r?{cachedInputTokens:r}:{},...o?{cacheCreationInputTokens:o}:{}})).nullish(),specification:E({specificationVersion:C("v2"),provider:w(),modelId:w()}),modelType:dr(["language","embedding","image"]).nullish()}))}))),xR=cn(()=>Or(E({balance:w(),total_used:w()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t})))),$R=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,...r}=e;return{args:this.maybeEncodeFileParts(r),warnings:[]}}async doGenerate(e){const{args:t,warnings:r}=await this.getArgs(e),{abortSignal:o}=e,n=await tr(this.config.headers());try{const{responseHeaders:i,value:a,rawValue:s}=await xu({url:this.getUrl(),headers:_u(n,e.headers,this.getModelConfigHeaders(this.modelId,!1),await tr(this.config.o11yHeaders)),body:t,successfulResponseHandler:zi(Pe()),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:l=>l}),...o&&{abortSignal:o},fetch:this.config.fetch});return{...a,request:{body:t},response:{headers:i,body:s},warnings:r}}catch(i){throw await $r(i,await Hn(n))}}async doStream(e){const{args:t,warnings:r}=await this.getArgs(e),{abortSignal:o}=e,n=await tr(this.config.headers());try{const{value:i,responseHeaders:a}=await xu({url:this.getUrl(),headers:_u(n,e.headers,this.getModelConfigHeaders(this.modelId,!0),await tr(this.config.o11yHeaders)),body:t,successfulResponseHandler:uA(Pe()),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:s=>s}),...o&&{abortSignal:o},fetch:this.config.fetch});return{stream:i.pipeThrough(new TransformStream({start(s){r.length>0&&s.enqueue({type:"stream-start",warnings:r})},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 $r(i,await Hn(n))}}isFilePart(e){return e&&typeof e=="object"&&"type"in e&&e.type==="file"}maybeEncodeFileParts(e){for(const t of e.prompt)for(const r of t.content)if(this.isFilePart(r)){const o=r;if(o.data instanceof Uint8Array){const n=Uint8Array.from(o.data),i=Buffer.from(n).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)}}},SR=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:r,providerOptions:o}){var n;const i=await tr(this.config.headers());try{const{responseHeaders:a,value:s,rawValue:l}=await xu({url:this.getUrl(),headers:_u(i,t??{},this.getModelConfigHeaders(),await tr(this.config.o11yHeaders)),body:{input:e.length===1?e[0]:e,...o?{providerOptions:o}:{}},successfulResponseHandler:zi(IR),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:u=>u}),...r&&{abortSignal:r},fetch:this.config.fetch});return{embeddings:s.embeddings,usage:(n=s.usage)!=null?n:void 0,providerMetadata:s.providerMetadata,response:{headers:a,body:l}}}catch(a){throw await $r(a,await Hn(i))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":"2","ai-model-id":this.modelId}}},IR=cn(()=>Or(E({embeddings:R(R(q())),usage:E({tokens:q()}).nullish(),providerMetadata:Xe(w(),Xe(w(),$e())).optional()})));async function kR(){var e;return(e=hx.getContext().headers)==null?void 0:e["x-vercel-id"]}var ER="2.0.7",TR="0.0.1";function OR(e={}){var t,r;let o=null,n=null;const i=(t=e.metadataCacheRefreshMillis)!=null?t:1e3*60*5;let a=0;const s=(r=rR(e.baseURL))!=null?r:"https://ai-gateway.vercel.sh/v1/ai",l=async()=>{const g=await PR(e);if(g)return Ba({Authorization:`Bearer ${g.token}`,"ai-gateway-protocol-version":TR,[Ix]:g.authMethod,...e.headers},`ai-sdk/gateway/${ER}`);throw Jc.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 kR();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 $R(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 wf({baseURL:s,headers:l,fetch:e.fetch}).getAvailableModels().then(x=>(n=x,x)).catch(async x=>{throw await $r(x,await Hn(await l()))})),n?Promise.resolve(n):o},f=async()=>new wf({baseURL:s,headers:l,fetch:e.fetch}).getCredits().catch(async g=>{throw await $r(g,await Hn(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 C0({modelId:g,modelType:"imageModel"})},p.languageModel=c,p.textEmbeddingModel=g=>new SR(g,{provider:"gateway",baseURL:s,headers:l,fetch:e.fetch,o11yHeaders:u()}),p}var NR=OR();async function PR(e){const t=ii({settingValue:e.apiKey,environmentVariableName:"AI_GATEWAY_API_KEY"});if(t)return{token:t,authMethod:"api-key"};try{return{token:await hx.getVercelOidcToken(),authMethod:"oidc"}}catch{return null}}var CR=Object.defineProperty,jR=(e,t)=>{for(var r in t)CR(e,r,{get:t[r],enumerable:!0})},kx="AI_NoOutputSpecifiedError",Ex=`vercel.ai.error.${kx}`,AR=Symbol.for(Ex),Tx,RR=class extends Y{constructor({message:e="No output specified."}={}){super({name:kx,message:e}),this[Tx]=!0}static isInstance(e){return Y.hasMarker(e,Ex)}};Tx=AR;function zR(e){const t="AI SDK Warning:";switch(e.type){case"unsupported-setting":{let r=`${t} The "${e.setting}" setting is not supported by this model`;return e.details&&(r+=` - ${e.details}`),r}case"unsupported-tool":{const r="name"in e.tool?e.tool.name:"unknown tool";let o=`${t} The tool "${r}" 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 MR="AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.",xf=!1,DR=e=>{if(e.length===0)return;const t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t=="function"){t(e);return}xf||(xf=!0,console.info(MR));for(const r of e)console.warn(zR(r))}},Ox="AI_InvalidArgumentError",Nx=`vercel.ai.error.${Ox}`,UR=Symbol.for(Nx),Px,Nt=class extends Y{constructor({parameter:e,value:t,message:r}){super({name:Ox,message:`Invalid argument for parameter ${e}: ${r}`}),this[Px]=!0,this.parameter=e,this.value=t}static isInstance(e){return Y.hasMarker(e,Nx)}};Px=UR;var Cx="AI_InvalidToolInputError",jx=`vercel.ai.error.${Cx}`,LR=Symbol.for(jx),Ax,Rx=class extends Y{constructor({toolInput:e,toolName:t,cause:r,message:o=`Invalid input for tool ${t}: ${sn(r)}`}){super({name:Cx,message:o,cause:r}),this[Ax]=!0,this.toolInput=e,this.toolName=t}static isInstance(e){return Y.hasMarker(e,jx)}};Ax=LR;var zx="AI_NoObjectGeneratedError",Mx=`vercel.ai.error.${zx}`,ZR=Symbol.for(Mx),Dx,$f=class extends Y{constructor({message:e="No object generated.",cause:t,text:r,response:o,usage:n,finishReason:i}){super({name:zx,message:e,cause:t}),this[Dx]=!0,this.text=r,this.response=o,this.usage=n,this.finishReason=i}static isInstance(e){return Y.hasMarker(e,Mx)}};Dx=ZR;var Ux="AI_NoOutputGeneratedError",Lx=`vercel.ai.error.${Ux}`,FR=Symbol.for(Lx),Zx,qR=class extends Y{constructor({message:e="No output generated.",cause:t}={}){super({name:Ux,message:e,cause:t}),this[Zx]=!0}static isInstance(e){return Y.hasMarker(e,Lx)}};Zx=FR;var Fx="AI_NoSuchToolError",qx=`vercel.ai.error.${Fx}`,VR=Symbol.for(qx),Vx,ku=class extends Y{constructor({toolName:e,availableTools:t=void 0,message:r=`Model tried to call unavailable tool '${e}'. ${t===void 0?"No tools are available.":`Available tools: ${t.join(", ")}.`}`}){super({name:Fx,message:r}),this[Vx]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return Y.hasMarker(e,qx)}};Vx=VR;var Bx="AI_ToolCallRepairError",Jx=`vercel.ai.error.${Bx}`,BR=Symbol.for(Jx),Wx,JR=class extends Y{constructor({cause:e,originalError:t,message:r=`Error repairing tool call: ${sn(e)}`}){super({name:Bx,message:r,cause:e}),this[Wx]=!0,this.originalError=t}static isInstance(e){return Y.hasMarker(e,Jx)}};Wx=BR;var WR=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}},Hx="AI_InvalidMessageRoleError",Gx=`vercel.ai.error.${Hx}`,HR=Symbol.for(Gx),Kx,GR=class extends Y{constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:Hx,message:t}),this[Kx]=!0,this.role=e}static isInstance(e){return Y.hasMarker(e,Gx)}};Kx=HR;var Yx="AI_MessageConversionError",Qx=`vercel.ai.error.${Yx}`,KR=Symbol.for(Qx),Xx,YR=class extends Y{constructor({originalMessage:e,message:t}){super({name:Yx,message:t}),this[Xx]=!0,this.originalMessage=e}static isInstance(e){return Y.hasMarker(e,Qx)}};Xx=KR;var e$="AI_DownloadError",t$=`vercel.ai.error.${e$}`,QR=Symbol.for(t$),r$,As=class extends Y{constructor({url:e,statusCode:t,statusText:r,cause:o,message:n=o==null?`Failed to download ${e}: ${t} ${r}`:`Failed to download ${e}: ${o}`}){super({name:e$,message:n,cause:o}),this[r$]=!0,this.url=e,this.statusCode=t,this.statusText=r}static isInstance(e){return Y.hasMarker(e,t$)}};r$=QR;var n$="AI_RetryError",o$=`vercel.ai.error.${n$}`,XR=Symbol.for(o$),i$,Sf=class extends Y{constructor({message:e,reason:t,errors:r}){super({name:n$,message:e}),this[i$]=!0,this.reason=t,this.errors=r,this.lastError=r[r.length-1]}static isInstance(e){return Y.hasMarker(e,o$)}};i$=XR;function a$(e){if(typeof e!="string"){if(e.specificationVersion!=="v2")throw new WR({version:e.specificationVersion,provider:e.provider,modelId:e.modelId});return e}return ez().languageModel(e)}function ez(){var e;return(e=globalThis.AI_SDK_DEFAULT_PROVIDER)!=null?e:NR}var tz=[{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]}],rz=e=>{const t=typeof e=="string"?Bc(e):e,r=(t[6]&127)<<21|(t[7]&127)<<14|(t[8]&127)<<7|t[9]&127;return t.slice(r+10)};function nz(e){return typeof e=="string"&&e.startsWith("SUQz")||typeof e!="string"&&e.length>10&&e[0]===73&&e[1]===68&&e[2]===51?rz(e):e}function oz({data:e,signatures:t}){const r=nz(e),o=typeof r=="string"?Bc(r.substring(0,Math.min(r.length,24))):r;for(const n of t)if(o.length>=n.bytesPrefix.length&&n.bytesPrefix.every((i,a)=>i===null||o[a]===i))return n.mediaType}var iz="5.0.90",az=async({url:e})=>{var t;const r=e.toString();try{const o=await fetch(r,{headers:Ba({},`ai-sdk/${iz}`,qc())});if(!o.ok)throw new As({url:r,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 As.isInstance(o)?o:new As({url:r,cause:o})}},sz=(e=az)=>t=>Promise.all(t.map(async r=>r.isUrlSupportedByModel?null:e(r)));function uz(e){try{const[t,r]=e.split(",");return{mediaType:t.split(";")[0].split(":")[1],base64Content:r}}catch{return{mediaType:void 0,base64Content:void 0}}}var s$=G([w(),Rt(Uint8Array),Rt(ArrayBuffer),So(e=>{var t,r;return(r=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?r:!1},{message:"Must be a Buffer"})]);function u$(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:r}=uz(e.toString());if(t==null||r==null)throw new Y({name:"InvalidDataContentError",message:`Invalid data URL format in content ${e.toString()}`});return{data:r,mediaType:t}}return{data:e,mediaType:void 0}}function lz(e){return typeof e=="string"?e:e instanceof ArrayBuffer?Iu(new Uint8Array(e)):Iu(e)}async function cz({prompt:e,supportedUrls:t,download:r=sz()}){const o=await pz(e.messages,r,t);return[...e.system!=null?[{role:"system",content:e.system}]:[],...e.messages.map(n=>dz({message:n,downloadedAssets:o}))]}function dz({message:e,downloadedAssets:t}){const r=e.role;switch(r){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=>fz(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 n=o.providerOptions;switch(o.type){case"file":{const{data:i,mediaType:a}=u$(o.data);return{type:"file",data:i,filename:o.filename,mediaType:a??o.mediaType,providerOptions:n}}case"reasoning":return{type:"reasoning",text:o.text,providerOptions:n};case"text":return{type:"text",text:o.text,providerOptions:n};case"tool-call":return{type:"tool-call",toolCallId:o.toolCallId,toolName:o.toolName,input:o.input,providerExecuted:o.providerExecuted,providerOptions:n};case"tool-result":return{type:"tool-result",toolCallId:o.toolCallId,toolName:o.toolName,output:o.output,providerOptions:n}}}),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=r;throw new GR({role:o})}}}async function pz(e,t,r){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&&G1({url:i.data.toString(),mediaType:i.mediaType,supportedUrls:r})})),n=await t(o);return Object.fromEntries(n.map((i,a)=>i==null?null:[o[a].url.toString(),{data:i.data,mediaType:i.mediaType}]).filter(i=>i!=null))}function fz(e,t){var r;if(e.type==="text")return{type:"text",text:e.text,providerOptions:e.providerOptions};let o;const n=e.type;switch(n){case"image":o=e.image;break;case"file":o=e.data;break;default:throw new Error(`Unsupported part type: ${n}`)}const{data:i,mediaType:a}=u$(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(n){case"image":return(l instanceof Uint8Array||typeof l=="string")&&(s=(r=oz({data:l,signatures:tz}))!=null?r: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 mz({maxOutputTokens:e,temperature:t,topP:r,topK:o,presencePenalty:n,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(r!=null&&typeof r!="number")throw new Nt({parameter:"topP",value:r,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(n!=null&&typeof n!="number")throw new Nt({parameter:"presencePenalty",value:n,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:r,topK:o,presencePenalty:n,frequencyPenalty:i,stopSequences:s,seed:a}}function hz(e){return e!=null&&Object.keys(e).length>0}function gz({tools:e,toolChoice:t,activeTools:r}){return hz(e)?{tools:(r!=null?Object.entries(e).filter(([n])=>r.includes(n)):Object.entries(e)).map(([n,i])=>{const a=i.type;switch(a){case void 0:case"dynamic":case"function":return{type:"function",name:n,description:i.description,inputSchema:Ja(i.inputSchema).jsonSchema,providerOptions:i.providerOptions};case"provider-defined":return{type:"provider-defined",name:n,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 Gn=xo(()=>G([yo(),w(),q(),pe(),Xe(w(),Gn),R(Gn)])),Mt=Xe(w(),Xe(w(),Gn)),l$=E({type:C("text"),text:w(),providerOptions:Mt.optional()}),vz=E({type:C("image"),image:G([s$,Rt(URL)]),mediaType:w().optional(),providerOptions:Mt.optional()}),c$=E({type:C("file"),data:G([s$,Rt(URL)]),filename:w().optional(),mediaType:w(),providerOptions:Mt.optional()}),yz=E({type:C("reasoning"),text:w(),providerOptions:Mt.optional()}),bz=E({type:C("tool-call"),toolCallId:w(),toolName:w(),input:$e(),providerOptions:Mt.optional(),providerExecuted:pe().optional()}),_z=Aa("type",[E({type:C("text"),value:w()}),E({type:C("json"),value:Gn}),E({type:C("error-text"),value:w()}),E({type:C("error-json"),value:Gn}),E({type:C("content"),value:R(G([E({type:C("text"),text:w()}),E({type:C("media"),data:w(),mediaType:w()})]))})]),d$=E({type:C("tool-result"),toolCallId:w(),toolName:w(),output:_z,providerOptions:Mt.optional()}),wz=E({role:C("system"),content:w(),providerOptions:Mt.optional()}),xz=E({role:C("user"),content:G([w(),R(G([l$,vz,c$]))]),providerOptions:Mt.optional()}),$z=E({role:C("assistant"),content:G([w(),R(G([l$,c$,yz,bz,d$]))]),providerOptions:Mt.optional()}),Sz=E({role:C("tool"),content:R(d$),providerOptions:Mt.optional()}),Iz=G([wz,xz,$z,Sz]);async function kz(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 r=await sr({value:t,schema:R(Iz)});if(!r.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:r.error});return{messages:t,system:e.system}}function Ez(e){return Jc.isInstance(e)||xx.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 Eu({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 Tz({model:e,settings:t,telemetry:r,headers:o}){var n;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((n=r?.metadata)!=null?n:{}).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 Oz={startSpan(){return Jo},startActiveSpan(e,t,r,o){if(typeof t=="function")return t(Jo);if(typeof r=="function")return r(Jo);if(typeof o=="function")return o(Jo)}},Jo={spanContext(){return Nz},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}},Nz={traceId:"",spanId:"",traceFlags:0};function Pz({isEnabled:e=!1,tracer:t}={}){return e?t||AC.getTracer("ai"):Oz}function Tu({name:e,tracer:t,attributes:r,fn:o,endWhenDone:n=!0}){return t.startActiveSpan(e,{attributes:r},async i=>{try{const a=await o(i);return n&&i.end(),a}catch(a){try{p$(i,a)}finally{i.end()}throw a}})}function p$(e,t){t instanceof Error?(e.recordException({name:t.name,message:t.message,stack:t.stack}),e.setStatus({code:Pi.ERROR,message:t.message})):e.setStatus({code:Pi.ERROR})}function Lr({telemetry:e,attributes:t}){return e?.isEnabled!==!0?{}:Object.entries(t).reduce((r,[o,n])=>{if(n==null)return r;if(typeof n=="object"&&"input"in n&&typeof n.input=="function"){if(e?.recordInputs===!1)return r;const i=n.input();return i==null?r:{...r,[o]:i}}if(typeof n=="object"&&"output"in n&&typeof n.output=="function"){if(e?.recordOutputs===!1)return r;const i=n.output();return i==null?r:{...r,[o]:i}}return{...r,[o]:n}},{})}function Cz(e){return JSON.stringify(e.map(t=>({...t,content:typeof t.content=="string"?t.content:t.content.map(r=>r.type==="file"?{...r,data:r.data instanceof Uint8Array?lz(r.data):r.data}:r)})))}function jz(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 If(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function Az({error:e,exponentialBackoffDelay:t}){const r=e.responseHeaders;if(!r)return t;let o;const n=r["retry-after-ms"];if(n){const a=parseFloat(n);Number.isNaN(a)||(o=a)}const i=r["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 Rz=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:r=2,abortSignal:o}={})=>async n=>f$(n,{maxRetries:e,delayInMs:t,backoffFactor:r,abortSignal:o});async function f$(e,{maxRetries:t,delayInMs:r,backoffFactor:o,abortSignal:n},i=[]){try{return await e()}catch(a){if(wr(a)||t===0)throw a;const s=sx(a),l=[...i,a],u=l.length;if(u>t)throw new Sf({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 ax(Az({error:a,exponentialBackoffDelay:r}),{abortSignal:n}),f$(e,{maxRetries:t,delayInMs:o*r,backoffFactor:o,abortSignal:n},l);throw u===1?a:new Sf({message:`Failed after ${u} attempts with non-retryable error: '${s}'`,reason:"errorNotRetryable",errors:l})}}function zz({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 r=e??2;return{maxRetries:r,retry:Rz({maxRetries:r,abortSignal:t})}}var Mz=class{constructor({data:e,mediaType:t}){const r=e instanceof Uint8Array;this.base64Data=r?void 0:e,this.uint8ArrayData=r?e:void 0,this.mediaType=t}get base64(){return this.base64Data==null&&(this.base64Data=Iu(this.uint8ArrayData)),this.base64Data}get uint8Array(){return this.uint8ArrayData==null&&(this.uint8ArrayData=Bc(this.base64Data)),this.uint8ArrayData}},Dz=class extends Mz{constructor(e){super(e),this.type="file"}};async function Uz({toolCall:e,tools:t,repairToolCall:r,system:o,messages:n}){try{if(t==null)throw new ku({toolName:e.toolName});try{return await kf({toolCall:e,tools:t})}catch(i){if(r==null||!(ku.isInstance(i)||Rx.isInstance(i)))throw i;let a=null;try{a=await r({toolCall:e,tools:t,inputSchema:({toolName:s})=>{const{inputSchema:l}=t[s];return Ja(l).jsonSchema},system:o,messages:n,error:i})}catch(s){throw new JR({cause:s,originalError:i})}if(a==null)throw i;return await kf({toolCall:a,tools:t})}}catch(i){const a=await xr({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 kf({toolCall:e,tools:t}){const r=e.toolName,o=t[r];if(o==null)throw new ku({toolName:e.toolName,availableTools:Object.keys(t)});const n=Ja(o.inputSchema),i=e.input.trim()===""?await sr({value:{},schema:n}):await xr({text:e.input,schema:n});if(i.success===!1)throw new Rx({toolName:r,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:r,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata}}var Lz=class{constructor({content:e,finishReason:t,usage:r,warnings:o,request:n,response:i,providerMetadata:a}){this.content=e,this.finishReason=t,this.usage=r,this.warnings=o,this.request=n,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 m$(e){return({steps:t})=>t.length===e}async function Zz({stopConditions:e,steps:t}){return(await Promise.all(e.map(r=>r({steps:t})))).some(r=>r)}function Nn({output:e,tool:t,errorMode:r}){return r==="text"?{type:"error-text",value:sn(e)}:r==="json"?{type:"error-json",value:Ef(e)}:t?.toModelOutput?t.toModelOutput(e):typeof e=="string"?{type:"text",value:e}:{type:"json",value:Ef(e)}}function Ef(e){return e===void 0?null:e}function Tf({content:e,tools:t}){const r=[],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&&r.push({role:"assistant",content:o});const n=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 n.length>0&&r.push({role:"tool",content:n}),r}No({prefix:"aitxt",size:24});function Wa(e,t){const r=new Headers(e??{});for(const[o,n]of Object.entries(t))r.has(o)||r.set(o,n);return r}function Fz({status:e,statusText:t,headers:r,textStream:o}){return new Response(o.pipeThrough(new TextEncoderStream),{status:e??200,statusText:t,headers:Wa(r,{"content-type":"text/plain; charset=utf-8"})})}function h$({response:e,status:t,statusText:r,headers:o,stream:n}){e.writeHead(t??200,r,o);const i=n.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 qz({response:e,status:t,statusText:r,headers:o,textStream:n}){h$({response:e,status:t,statusText:r,headers:Object.fromEntries(Wa(o,{"content-type":"text/plain; charset=utf-8"}).entries()),stream:n.pipeThrough(new TextEncoderStream)})}var g$=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
|
-
`)}})}},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
|
-
${
|
|
88
|
+
`)}})}},v$={"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive","x-vercel-ai-ui-message-stream":"v1","x-accel-buffering":"no"};function Vz({status:e,statusText:t,headers:r,stream:o,consumeSseStream:n}){let i=o.pipeThrough(new g$);if(n){const[a,s]=i.tee();i=a,n({stream:s})}return new Response(i.pipeThrough(new TextEncoderStream),{status:e,statusText:t,headers:Wa(r,v$)})}function Bz({originalMessages:e,responseMessageId:t}){if(e==null)return;const r=e[e.length-1];return r?.role==="assistant"?r.id:typeof t=="function"?t():t}function Jz(e){return e.type.startsWith("data-")}function y$(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const r={...e};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const n=t[o];if(n===void 0)continue;const i=o in e?e[o]:void 0,a=n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp),s=i!=null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp);a&&s?r[o]=y$(i,n):r[o]=n}return r}function Wz(e){const t=["ROOT"];let r=-1,o=null;function n(l,u,c){switch(l){case'"':{r=u,t.pop(),t.push(c),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{r=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":{r=u,t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"{":{r=u,t.pop(),t.push(c),t.push("INSIDE_OBJECT_START");break}case"[":{r=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"}":{r=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":n(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{r=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":{n(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),r=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:r=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{r=l,t.pop();break}default:{r=l,n(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"]":{r=l,t.pop();break}default:{r=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),r=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":{r=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)):r=l;break}}}let s=e.slice(0,r+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 b$(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await xr({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await xr({text:Wz(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function Rs(e){return e.type.startsWith("data-")}function zs(e){return e.type==="text"}function Ms(e){return e.type==="file"}function Of(e){return e.type==="reasoning"}function Fr(e){return e.type.startsWith("tool-")}function Wc(e){return e.type==="dynamic-tool"}function Nf(e){return Fr(e)||Wc(e)}function Mi(e){return e.type.split("-").slice(1).join("-")}function Hz(e){return Wc(e)?e.toolName:Mi(e)}function Gz({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function Kz({stream:e,messageMetadataSchema:t,dataPartSchemas:r,runUpdateMessageJob:o,onError:n,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?y$(u.message.metadata,v):v;t!=null&&await wu({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 b$(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:Mi(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:Mi(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":{n?.(new Error(s.errorText));break}default:if(Jz(s)){r?.[s.type]!=null&&await wu({value:s.data,schema:r[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 Yz({messageId:e,originalMessages:t=[],onFinish:r,onError:o,stream:n}){let i=t?.[t.length-1];i?.role!=="assistant"?i=void 0:e=i.id;let a=!1;const s=n.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(r==null)return s;const l=Gz({lastMessage:i?structuredClone(i):void 0,messageId:e??""}),u=async f=>{await f({state:l,write:()=>{}})};let c=!1;const d=async()=>{if(c||!r)return;c=!0;const f=l.message.id===i?.id;await r({isAborted:a,isContinuation:f,responseMessage:l.message,messages:[...f?t.slice(0,-1):t,l.message]})};return Kz({stream:s,runUpdateMessageJob:u,onError:o}).pipeThrough(new TransformStream({transform(f,p){p.enqueue(f)},async cancel(){await d()},async flush(){await d()}}))}function Qz({response:e,status:t,statusText:r,headers:o,stream:n,consumeSseStream:i}){let a=n.pipeThrough(new g$);if(i){const[s,l]=a.tee();a=s,i({stream:l})}h$({response:e,status:t,statusText:r,headers:Object.fromEntries(Wa(o,v$).entries()),stream:a.pipeThrough(new TextEncoderStream)})}function Wo(e){const t=e.pipeThrough(new TransformStream);return t[Symbol.asyncIterator]=function(){const r=this.getReader();let o=!1;async function n(i){var a;o=!0;try{i&&await((a=r.cancel)==null?void 0:a.call(r))}finally{try{r.releaseLock()}catch{}}}return{async next(){if(o)return{done:!0,value:void 0};const{done:i,value:a}=await r.read();return i?(await n(!0),{done:!0,value:void 0}):{done:!1,value:a}},async return(){return await n(!0),{done:!0,value:void 0}},async throw(i){throw await n(!0),i}}},t}async function Xz({stream:e,onError:t}){const r=e.getReader();try{for(;;){const{done:o}=await r.read();if(o)break}}catch(o){t?.(o)}finally{r.releaseLock()}}function Pf(){let e,t;return{promise:new Promise((o,n)=>{e=o,t=n}),resolve:e,reject:t}}function eM(){let e=[],t=null,r=!1,o=Pf();const n=()=>{r=!0,o.resolve(),e.forEach(a=>a.cancel()),e=[],t?.close()},i=async()=>{if(r&&e.length===0){t?.close();return}if(e.length===0)return o=Pf(),await o.promise,i();try{const{value:a,done:s}=await e[0].read();s?(e.shift(),e.length>0?await i():r&&t?.close()):t?.enqueue(a)}catch(a){t?.error(a),e.shift(),n()}};return{stream:new ReadableStream({start(a){t=a},pull:i,async cancel(){for(const a of e)await a.cancel();e=[],r=!0}}),addStream:a=>{if(r)throw new Error("Cannot add inner stream: outer stream is closed");e.push(a.getReader()),o.resolve()},close:()=>{r=!0,o.resolve(),e.length===0&&t?.close()},terminate:n}}var Ho=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 tM(){var e,t;return(t=(e=globalThis?.performance)==null?void 0:e.now())!=null?t:Date.now()}function rM({tools:e,generatorStream:t,tracer:r,telemetry:o,system:n,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 Dz({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 Uz({toolCall:y,tools:e,repairToolCall:s,system:n,messages:i});if(x.enqueue(v),v.invalid){u.enqueue({type:"tool-error",toolCallId:v.toolCallId,toolName:v.toolName,input:v.input,error:sx(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=B1();d.add(N),Tu({name:"ai.toolCall",attributes:Lr({telemetry:o,attributes:{...Eu({operationId:"ai.toolCall",telemetry:o}),"ai.toolCall.name":v.toolName,"ai.toolCall.id":v.toolCallId,"ai.toolCall.args":{output:()=>JSON.stringify(v.input)}}}),tracer:r,fn:async I=>{let O;try{const z=oR({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){p$(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 nM=No({prefix:"aitxt",size:24});function oM({model:e,tools:t,toolChoice:r,system:o,prompt:n,messages:i,maxRetries:a,abortSignal:s,headers:l,stopWhen:u=m$(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:V})=>{console.error(V)},onFinish:N,onAbort:I,onStepFinish:O,experimental_context:z,_internal:{now:F=tM,generateId:te=nM,currentDate:ie=()=>new Date}={},...J}){return new aM({model:a$(e),telemetry:d,headers:l,settings:J,maxRetries:a,abortSignal:s,system:o,prompt:n,messages:i,tools:t,toolChoice:r,transforms:If(y),activeTools:h,repairToolCall:b,stopConditions:If(u),output:c,providerOptions:p,prepareStep:f,includeRawChunks:$,onChunk:v,onError:k,onFinish:N,onAbort:I,onStepFinish:O,now:F,currentDate:ie,generateId:te,experimental_context:z,download:x})}function iM(e){if(!e)return new TransformStream({transform(a,s){s.enqueue({part:a,partialOutput:void 0})}});let t,r="",o="",n="";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}r+=a.text,o+=a.text;const l=await e.parsePartial({text:r});if(l!=null){const u=JSON.stringify(l.partial);u!==n&&(i({controller:s,partialOutput:l.partial}),n=u)}}})}var aM=class{constructor({model:e,telemetry:t,headers:r,settings:o,maxRetries:n,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:ie}){this._totalUsage=new Ho,this._finishReason=new Ho,this._steps=new Ho,this.output=h,this.includeRawChunks=x,this.tools=u;let J,V=[];const we=[];let oe,de,K={},fe=[];const B=[];let Ue,ye={},Le={};const U=new TransformStream({async transform(Ee,Te){var Ae,ae,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:Ez(Z.error)}),Z.type==="text-start"&&(ye[Z.id]={type:"text",text:"",providerMetadata:Z.providerMetadata},V.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=(ae=Z.providerMetadata)!=null?ae:Ie.providerMetadata,delete ye[Z.id]}if(Z.type==="reasoning-start"&&(Le[Z.id]={type:"reasoning",text:"",providerMetadata:Z.providerMetadata},V.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"&&V.push({type:"file",file:Z.file}),Z.type==="source"&&V.push(Z),Z.type==="tool-call"&&V.push(Z),Z.type==="tool-result"&&!Z.preliminary&&V.push(Z),Z.type==="tool-error"&&V.push(Z),Z.type==="start-step"&&(K=Z.request,fe=Z.warnings),Z.type==="finish-step"){const Ie=Tf({content:V,tools:u}),hn=new Lz({content:V,finishReason:Z.finishReason,usage:Z.usage,warnings:fe,request:K,response:{...Z.response,messages:[...we,...Ie]},providerMetadata:Z.providerMetadata});await F?.(hn),DR(fe),B.push(hn),V=[],Le={},ye={},we.push(...Ie),J.resolve()}Z.type==="finish"&&(de=Z.totalUsage,oe=Z.finishReason)},async flush(Ee){try{if(B.length===0){const ft=new qR({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(B);const ae=B[B.length-1];await O?.({finishReason:Te,totalUsage:Ae,usage:ae.usage,content:ae.content,text:ae.text,reasoningText:ae.reasoningText,reasoning:ae.reasoning,files:ae.files,sources:ae.sources,toolCalls:ae.toolCalls,staticToolCalls:ae.staticToolCalls,dynamicToolCalls:ae.dynamicToolCalls,toolResults:ae.toolResults,staticToolResults:ae.staticToolResults,dynamicToolResults:ae.dynamicToolResults,request:ae.request,response:ae.response,warnings:ae.warnings,providerMetadata:ae.providerMetadata,steps:B}),Ue.setAttributes(Lr({telemetry:t,attributes:{"ai.response.finishReason":Te,"ai.response.text":{output:()=>ae.text},"ai.response.toolCalls":{output:()=>{var ft;return(ft=ae.toolCalls)!=null&&ft.length?JSON.stringify(ae.toolCalls):void 0}},"ai.response.providerMetadata":JSON.stringify(ae.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=eM();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:B}),Ee.enqueue({type:"abort"}),Ee.close()}try{const{done:Ae,value:ae}=await me.read();if(Ae){Ee.close();return}if(i?.aborted){Te();return}Ee.enqueue(ae)}catch(Ae){wr(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(iM(h)).pipeThrough(U);const{maxRetries:Ro,retry:ss}=zz({maxRetries:n,abortSignal:i}),fn=Pz(t),pt=mz(o),zo=Tz({model:e,telemetry:t,headers:r,settings:{...pt,maxRetries:Ro}}),je=this;Tu({name:"ai.streamText",attributes:Lr({telemetry:t,attributes:{...Eu({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:ae,usage:ft}){var mn,Z,Ie,hn,Sd;const Id=je.includeRawChunks;J=new Ho;const kd=await kz({system:a,prompt:s,messages:l}),gn=[...kd.messages,...ae],Et=await y?.({model:e,steps:B,stepNumber:B.length,messages:gn}),Nr=a$((mn=Et?.model)!=null?mn:e),Ed=await cz({prompt:{system:(Z=Et?.system)!=null?Z:kd.system,messages:(Ie=Et?.messages)!=null?Ie:gn},supportedUrls:await Nr.supportedUrls,download:ie}),{toolChoice:us,tools:ls}=gz({tools:u,toolChoice:(hn=Et?.toolChoice)!=null?hn:c,activeTools:(Sd=Et?.activeTools)!=null?Sd:f}),{result:{stream:h0,response:Td,request:Od},doStreamSpan:Pr,startTimestampMs:Nd}=await ss(()=>Tu({name:"ai.streamText.doStream",attributes:Lr({telemetry:t,attributes:{...Eu({operationId:"ai.streamText.doStream",telemetry:t}),...zo,"ai.model.provider":Nr.provider,"ai.model.id":Nr.modelId,"ai.prompt.messages":{input:()=>Cz(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:r,includeRawChunks:Id})})})),g0=rM({tools:u,generatorStream:h0,tracer:fn,telemetry:t,system:a,messages:gn,repairToolCall:p,abortSignal:i,experimental_context:te}),v0=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(g0.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:v0,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=jz(ft,mt);await J.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 Zz({stopConditions:g,steps:B})){ae.push(...Tf({content:B[B.length-1].content,tools:u}));try{await Te({currentStep:Ae+1,responseMessages:ae,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 Wo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){e.type==="text-delta"&&t.enqueue(e.text)}})))}get fullStream(){return Wo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){t.enqueue(e)}})))}async consumeStream(e){var t;try{await Xz({stream:this.fullStream,onError:e?.onError})}catch(r){(t=e?.onError)==null||t.call(e,r)}}get experimental_partialOutputStream(){if(this.output==null)throw new RR;return Wo(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:e},t){e!=null&&t.enqueue(e)}})))}toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n=!0,sendSources:i=!1,sendStart:a=!0,sendFinish:s=!0,onError:l=sn}={}){const u=t!=null?Bz({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":{n&&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 Wo(Yz({stream:f,messageId:u??t?.(),originalMessages:e,onFinish:r,onError:l}))}pipeUIMessageStreamToResponse(e,{originalMessages:t,generateMessageId:r,onFinish:o,messageMetadata:n,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u,...c}={}){Qz({response:e,stream:this.toUIMessageStream({originalMessages:t,generateMessageId:r,onFinish:o,messageMetadata:n,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u}),...c})}pipeTextStreamToResponse(e,t){qz({response:e,textStream:this.textStream,...t})}toUIMessageStreamResponse({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n,sendSources:i,sendFinish:a,sendStart:s,onError:l,...u}={}){return Vz({stream:this.toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n,sendSources:i,sendFinish:a,sendStart:s,onError:l}),...u})}toTextStreamResponse(e){return Fz({textStream:this.textStream,...e})}};function sM(e,t){const r=[];t?.ignoreIncompleteToolCalls&&(e=e.map(o=>({...o,parts:o.parts.filter(n=>!Nf(n)||n.state!=="input-streaming"&&n.state!=="input-available")})));for(const o of e)switch(o.role){case"system":{const n=o.parts.filter(a=>a.type==="text"),i=n.reduce((a,s)=>s.providerMetadata!=null?{...a,...s.providerMetadata}:a,{});r.push({role:"system",content:n.map(a=>a.text).join(""),...Object.keys(i).length>0?{providerOptions:i}:{}});break}case"user":{r.push({role:"user",content:o.parts.map(n=>{var i;if(zs(n))return{type:"text",text:n.text,...n.providerMetadata!=null?{providerOptions:n.providerMetadata}:{}};if(Ms(n))return{type:"file",mediaType:n.mediaType,filename:n.filename,data:n.url,...n.providerMetadata!=null?{providerOptions:n.providerMetadata}:{}};if(Rs(n))return(i=t?.convertDataPart)==null?void 0:i.call(t,n)}).filter(n=>n!=null)});break}case"assistant":{if(o.parts!=null){let n=function(){var a,s,l;if(i.length===0)return;const u=[];for(const d of i)if(zs(d))u.push({type:"text",text:d.text,...d.providerMetadata!=null?{providerOptions:d.providerMetadata}:{}});else if(Ms(d))u.push({type:"file",mediaType:d.mediaType,filename:d.filename,data:d.url});else if(Of(d))u.push({type:"reasoning",text:d.text,providerOptions:d.providerMetadata});else if(Wc(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=Mi(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(Rs(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}`)}r.push({role:"assistant",content:u});const c=i.filter(d=>Fr(d)&&d.providerExecuted!==!0||d.type==="dynamic-tool");c.length>0&&r.push({role:"tool",content:c.map(d=>{var f;switch(d.state){case"output-error":case"output-available":{const p=Hz(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)zs(a)||Of(a)||Ms(a)||Nf(a)||Rs(a)?i.push(a):a.type==="step-start"&&n();n();break}break}default:{const n=o.role;throw new YR({originalMessage:o,message:`Unsupported role: ${n}`})}}return r}No({prefix:"aiobj",size:24});No({prefix:"aiobj",size:24});var uM={};jR(uM,{object:()=>cM,text:()=>lM});var lM=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),cM=({schema:e})=>{const t=Ja(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:r}){const o=await b$(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value};default:{const n=o.state;throw new Error(`Unsupported parse state: ${n}`)}}},async parseOutput({text:r},o){const n=await xr({text:r});if(!n.success)throw new $f({message:"No object generated: could not parse the response.",cause:n.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=await sr({value:n.value,schema:t});if(!i.success)throw new $f({message:"No object generated: response did not match schema.",cause:i.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.value}}},dM={word:/\S+\s+/m,line:/\n+/m};function pM({delayInMs:e=10,chunking:t="word",_internal:{delay:r=ax}={}}={}){let o;if(typeof t=="function")o=n=>{const i=t(n);if(i==null)return null;if(!i.length)throw new Error("Chunking function must return a non-empty string.");if(!n.startsWith(i))throw new Error(`Chunking function must return a match that is a prefix of the buffer. Received: "${i}" expected to start with "${n}"`);return i};else{const n=typeof t=="string"?dM[t]:t;if(n==null)throw new Vi({argument:"chunking",message:`Chunking must be "word" or "line" or a RegExp. Received: ${t}`});o=i=>{const a=n.exec(i);return a?i.slice(0,a.index)+a?.[0]:null}}return()=>{let n="",i="";return new TransformStream({async transform(a,s){if(a.type!=="text-delta"){n.length>0&&(s.enqueue({type:"text-delta",text:n,id:i}),n=""),s.enqueue(a);return}a.id!==i&&n.length>0&&(s.enqueue({type:"text-delta",text:n,id:i}),n=""),n+=a.text,i=a.id;let l;for(;(l=o(n))!=null;)s.enqueue({type:"text-delta",text:l,id:i}),n=n.slice(l.length),await r(e)}})}}const fM=({getSession:e,projectSlug:t})=>{const r=F_(),o=["chatSession",t],n=r.getQueryState(o),i=n?.data!==void 0,a=n?.dataUpdatedAt??0,l=i&&Date.now()-a>1/0,u=!i||l,{data:c}=V_({queryKey:o,queryFn:()=>e({projectSlug:t}),enabled:u&&e!==null,staleTime:1/0,gcTime:1/0});return c??null};async function mM(e){return(await(await fetch("/chat/session",{method:"POST",headers:{"Gram-Project":e.projectSlug}})).json()).client_token}const hM=({projectSlug:e,auth:t})=>{let r=t&&"sessionFn"in t?t.sessionFn:null;r===void 0&&(r=mM);const o=fM({getSession:r,projectSlug:e});return t&&"UNSAFE_apiKey"in t?{headers:{"Gram-Project":e,"Gram-Key":t.UNSAFE_apiKey},isLoading:!1}:o?{headers:{"Gram-Project":e,"Gram-Chat-Session":o},isLoading:!1}:{isLoading:!0}};function gM({children:e}){const[t,r]=D.useState(new Map),[o,n]=D.useState(new Set),i=D.useCallback((d,f,p)=>new Promise(g=>{const h={toolCallId:f,toolName:d,args:p,resolve:g};r(b=>{const y=new Map(b);return y.set(f,h),y})}),[]),a=D.useCallback(d=>{n(f=>{const p=new Set(f);return p.add(d),p})},[]),s=D.useCallback(d=>{r(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=>{r(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 vM="You are a helpful assistant that can answer questions and help with tasks.";function yM(e,t){return`
|
|
89
|
+
${vM}
|
|
90
90
|
|
|
91
91
|
User-provided System Prompt:
|
|
92
92
|
${e??"None provided"}
|
|
93
93
|
|
|
94
94
|
Utilities:
|
|
95
|
-
${t.map(
|
|
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(
|
|
95
|
+
${t.map(r=>`- ${r.language}: ${r.prompt}`).join(`
|
|
96
|
+
`)}`}function bM(e){return(e.api?.url||"https://app.getgram.ai").replace(/\/+$/,"")}const _M=({children:e,config:t})=>{const r=bM(t),o=hM({auth:t.api,projectSlug:t.projectSlug}),n=B_(),[i,a]=D.useState(t.model?.defaultModel??Oc[0]),[s,l]=D.useState(t.modal?.defaultExpanded??!1),[u,c]=D.useState(t.modal?.defaultOpen),d=t.plugins??T.recommended,f=yM(t.systemPrompt,d),{data:p,isLoading:g}=aN({auth:o,mcp:t.mcp,environment:t.environment??{}}),h=D.useRef({requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool});h.current={requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool};const b=D.useCallback(()=>({requestApproval:(...$)=>h.current.requestApproval(...$),isToolApproved:(...$)=>h.current.isToolApproved(...$),whitelistTool:(...$)=>h.current.whitelistTool(...$)}),[]);D.useEffect(()=>(t.tools?.toolsRequiringApproval?.length&&cN(b(),t.tools.toolsRequiringApproval),()=>{dN()}),[t.tools?.toolsRequiringApproval,b]);const y=D.useMemo(()=>({sendMessages:async({messages:$,abortSignal:v})=>{const k=!!t.languageModel;if(o.isLoading)throw new Error("Session is laoding");const N=x.thread.getModelContext(),I=uN(lN(N?.tools??{})),O=k?null:ix({baseURL:r,apiKey:"unused, but must be set",headers:o.headers});t.languageModel&&console.log("Using custom language model",t.languageModel);const z={...p,...Oj(I)},F=fN(z,t.tools?.toolsRequiringApproval,b()),te=t.languageModel?t.languageModel:O.chat(i);try{return oM({system:f,model:te,messages:sM($),tools:F,stopWhen:m$(10),experimental_transform:pM({delayInMs:15}),abortSignal:v,onError:({error:J})=>{console.error("Stream error in onError callback:",J)}}).toUIMessageStream()}catch(ie){throw console.error("Error creating stream:",ie),ie}},reconnectToStream:async()=>{throw new Error("Stream reconnection not supported")}}),[t,t.languageModel,i,f,p,g,b,r,o.headers]),x=Tj({transport:y});return m.jsx(L.AssistantRuntimeProvider,{runtime:x,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(x0,{tools:t.tools?.frontendTools??{}})]})})},wM=e=>{const t=new WO;return m.jsx(HO,{client:t,children:m.jsx(gM,{children:m.jsx(_M,{...e})})})};function Oe(e,t,{checkForDefaultPrevented:r=!0}={}){return function(n){if(e?.(n),r===!1||!n.defaultPrevented)return t?.(n)}}function Cf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Hc(...e){return t=>{let r=!1;const o=e.map(n=>{const i=Cf(n,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let n=0;n<o.length;n++){const i=o[n];typeof i=="function"?i():Cf(e[n],null)}}}}function Ge(...e){return _.useCallback(Hc(...e),e)}function xM(e,t){const r=_.createContext(t),o=i=>{const{children:a,...s}=i,l=_.useMemo(()=>s,Object.values(s));return m.jsx(r.Provider,{value:l,children:a})};o.displayName=e+"Provider";function n(i){const a=_.useContext(r);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[o,n]}function Po(e,t=[]){let r=[];function o(i,a){const s=_.createContext(a),l=r.length;r=[...r,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 n=()=>{const i=r.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return n.scopeName=e,[o,$M(n,...t)]}function $M(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(n=>({useScope:n(),scopeName:n.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 r.scopeName=t.scopeName,r}function Gc(e){const t=SM(e),r=_.forwardRef((o,n)=>{const{children:i,...a}=o,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:n,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:n,children:i})});return r.displayName=`${e}.Slot`,r}function SM(e){const t=_.forwardRef((r,o)=>{const{children:n,...i}=r;if(_.isValidElement(n)){const a=TM(n),s=EM(i,n.props);return n.type!==_.Fragment&&(s.ref=o?Hc(o,a):a),_.cloneElement(n,s)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var _$=Symbol("radix.slottable");function IM(e){const t=({children:r})=>m.jsx(m.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=_$,t}function kM(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===_$}function EM(e,t){const r={...t};for(const o in t){const n=e[o],i=t[o];/^on[A-Z]/.test(o)?n&&i?r[o]=(...s)=>{const l=i(...s);return n(...s),l}:n&&(r[o]=n):o==="style"?r[o]={...n,...i}:o==="className"&&(r[o]=[n,i].filter(Boolean).join(" "))}return{...e,...r}}function TM(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var OM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ce=OM.reduce((e,t)=>{const r=Gc(`Primitive.${t}`),o=_.forwardRef((n,i)=>{const{asChild:a,...s}=n,l=a?r: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 NM(e,t){e&&sm.flushSync(()=>e.dispatchEvent(t))}function Sr(e){const t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>(...r)=>t.current?.(...r),[])}function PM(e,t=globalThis?.document){const r=Sr(e);_.useEffect(()=>{const o=n=>{n.key==="Escape"&&r(n)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[r,t])}var CM="DismissableLayer",Ou="dismissableLayer.update",jM="dismissableLayer.pointerDownOutside",AM="dismissableLayer.focusOutside",jf,w$=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ha=_.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:n,onFocusOutside:i,onInteractOutside:a,onDismiss:s,...l}=e,u=_.useContext(w$),[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=MM(I=>{const O=I.target,z=[...u.branches].some(F=>F.contains(O));!v||z||(n?.(I),a?.(I),I.defaultPrevented||s?.())},f),N=DM(I=>{const O=I.target;[...u.branches].some(F=>F.contains(O))||(i?.(I),a?.(I),I.defaultPrevented||s?.())},f);return PM(I=>{x===u.layers.size-1&&(o?.(I),!I.defaultPrevented&&s&&(I.preventDefault(),s()))},f),_.useEffect(()=>{if(c)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(jf=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),Af(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=jf)}},[c,f,r,u]),_.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),Af())},[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=CM;var RM="DismissableLayerBranch",zM=_.forwardRef((e,t)=>{const r=_.useContext(w$),o=_.useRef(null),n=Ge(t,o);return _.useEffect(()=>{const i=o.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),m.jsx(Ce.div,{...e,ref:n})});zM.displayName=RM;function MM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1),n=_.useRef(()=>{});return _.useEffect(()=>{const i=s=>{if(s.target&&!o.current){let l=function(){x$(jM,r,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",n.current),n.current=l,t.addEventListener("click",n.current,{once:!0})):l()}else t.removeEventListener("click",n.current);o.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",n.current)}},[t,r]),{onPointerDownCapture:()=>o.current=!0}}function DM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1);return _.useEffect(()=>{const n=i=>{i.target&&!o.current&&x$(AM,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",n),()=>t.removeEventListener("focusin",n)},[t,r]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Af(){const e=new CustomEvent(Ou);document.dispatchEvent(e)}function x$(e,t,r,{discrete:o}){const n=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),o?NM(n,i):n.dispatchEvent(i)}var lt=globalThis?.document?_.useLayoutEffect:()=>{},UM=_[" useId ".trim().toString()]||(()=>{}),LM=0;function qr(e){const[t,r]=_.useState(UM());return lt(()=>{r(o=>o??String(LM++))},[e]),t?`radix-${t}`:""}const ZM=["top","right","bottom","left"],ur=Math.min,Ye=Math.max,Di=Math.round,Go=Math.floor,At=e=>({x:e,y:e}),FM={left:"right",right:"left",bottom:"top",top:"bottom"},qM={start:"end",end:"start"};function Nu(e,t,r){return Ye(e,ur(t,r))}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 VM=new Set(["top","bottom"]);function jt(e){return VM.has(Jt(e))?"y":"x"}function Qc(e){return Kc(jt(e))}function BM(e,t,r){r===void 0&&(r=!1);const o=dn(e),n=Qc(e),i=Yc(n);let a=n==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Ui(a)),[a,Ui(a)]}function JM(e){const t=Ui(e);return[Pu(e),t,Pu(t)]}function Pu(e){return e.replace(/start|end/g,t=>qM[t])}const Rf=["left","right"],zf=["right","left"],WM=["top","bottom"],HM=["bottom","top"];function GM(e,t,r){switch(e){case"top":case"bottom":return r?t?zf:Rf:t?Rf:zf;case"left":case"right":return t?WM:HM;default:return[]}}function KM(e,t,r,o){const n=dn(e);let i=GM(Jt(e),r==="start",o);return n&&(i=i.map(a=>a+"-"+n),t&&(i=i.concat(i.map(Pu)))),i}function Ui(e){return e.replace(/left|right|bottom|top/g,t=>FM[t])}function YM(e){return{top:0,right:0,bottom:0,left:0,...e}}function $$(e){return typeof e!="number"?YM(e):{top:e,right:e,bottom:e,left:e}}function Li(e){const{x:t,y:r,width:o,height:n}=e;return{width:o,height:n,top:r,left:t,right:t+o,bottom:r+n,x:t,y:r}}function Mf(e,t,r){let{reference:o,floating:n}=e;const i=jt(t),a=Qc(t),s=Yc(a),l=Jt(t),u=i==="y",c=o.x+o.width/2-n.width/2,d=o.y+o.height/2-n.height/2,f=o[s]/2-n[s]/2;let p;switch(l){case"top":p={x:c,y:o.y-n.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-n.width,y:d};break;default:p={x:o.x,y:o.y}}switch(dn(t)){case"start":p[a]-=f*(r&&u?-1:1);break;case"end":p[a]+=f*(r&&u?-1:1);break}return p}const QM=async(e,t,r)=>{const{placement:o="bottom",strategy:n="absolute",middleware:i=[],platform:a}=r,s=i.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:n}),{x:c,y:d}=Mf(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:n,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:n}):k.rects),{x:c,y:d}=Mf(u,f,l)),h=-1)}return{x:c,y:d,placement:f,strategy:n,middlewareData:p}};async function Kn(e,t){var r;t===void 0&&(t={});const{x:o,y:n,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=$$(p),b=s[f?d==="floating"?"reference":"floating":d],y=Li(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(b)))==null||r?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:n,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=Li(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 XM=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:o,placement:n,rects:i,platform:a,elements:s,middlewareData:l}=t,{element:u,padding:c=0}=Bt(e,t)||{};if(u==null)return{};const d=$$(c),f={x:r,y:o},p=Qc(n),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),ie=F,J=I-h[g]-te,V=I/2-h[g]/2+O,we=Nu(ie,V,J),oe=!l.arrow&&dn(n)!=null&&V!==we&&i.reference[g]/2-(V<ie?F:te)-h[g]/2<0,de=oe?V<ie?V-ie:V-J:0;return{[p]:f[p]+de,data:{[p]:we,centerOffset:V-we-de,...oe&&{alignmentOffset:de}},reset:oe}}}),e4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,o;const{placement:n,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((r=i.arrow)!=null&&r.alignmentOffset)return{};const y=Jt(n),x=jt(s),$=Jt(s)===s,v=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=f||($||!h?[Ui(s)]:JM(s)),N=g!=="none";!f&&N&&k.push(...KM(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 V=BM(n,a,v);z.push(O[V[0]],O[V[1]])}if(F=[...F,{placement:n,overflows:z}],!z.every(V=>V<=0)){var te,ie;const V=(((te=i.flip)==null?void 0:te.index)||0)+1,we=I[V];if(we&&(!(d==="alignment"?x!==jt(we):!1)||F.every(K=>jt(K.placement)===x?K.overflows[0]>0:!0)))return{data:{index:V,overflows:F},reset:{placement:we}};let oe=(ie=F.filter(de=>de.overflows[0]<=0).sort((de,K)=>de.overflows[1]-K.overflows[1])[0])==null?void 0:ie.placement;if(!oe)switch(p){case"bestFit":{var J;const de=(J=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,B)=>fe+B,0)]).sort((K,fe)=>K[1]-fe[1])[0])==null?void 0:J[0];de&&(oe=de);break}case"initialPlacement":oe=s;break}if(n!==oe)return{reset:{placement:oe}}}return{}}}};function Df(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Uf(e){return ZM.some(t=>e[t]>=0)}const t4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r}=t,{strategy:o="referenceHidden",...n}=Bt(e,t);switch(o){case"referenceHidden":{const i=await Kn(t,{...n,elementContext:"reference"}),a=Df(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Uf(a)}}}case"escaped":{const i=await Kn(t,{...n,altBoundary:!0}),a=Df(i,r.floating);return{data:{escapedOffsets:a,escaped:Uf(a)}}}default:return{}}}}},S$=new Set(["left","top"]);async function r4(e,t){const{placement:r,platform:o,elements:n}=e,i=await(o.isRTL==null?void 0:o.isRTL(n.floating)),a=Jt(r),s=dn(r),l=jt(r)==="y",u=S$.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 n4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,o;const{x:n,y:i,placement:a,middlewareData:s}=t,l=await r4(t,e);return a===((r=s.offset)==null?void 0:r.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:n+l.x,y:i+l.y,data:{...l,placement:a}}}}},o4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:o,placement:n}=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:r,y:o},c=await Kn(t,l),d=jt(Jt(n)),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-r,y:h.y-o,enabled:{[f]:i,[d]:a}}}}}},i4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:o,placement:n,rects:i,middlewareData:a}=t,{offset:s=0,mainAxis:l=!0,crossAxis:u=!0}=Bt(e,t),c={x:r,y:o},d=jt(n),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=S$.has(Jt(n)),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}}}},a4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,o;const{placement:n,rects:i,platform:a,elements:s}=t,{apply:l=()=>{},...u}=Bt(e,t),c=await Kn(t,u),d=Jt(n),f=dn(n),p=jt(n)==="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((r=t.middlewareData.shift)!=null&&r.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),ie=Ye(c.top,0),J=Ye(c.bottom,0);p?O=g-2*(F!==0||te!==0?F+te:Ye(c.left,c.right)):I=h-2*(ie!==0||J!==0?ie+J: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 I$(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=(I$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function I$(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 Lf(e){return!Ga()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qe(e).ShadowRoot}const s4=new Set(["inline","contents"]);function Co(e){const{overflow:t,overflowX:r,overflowY:o,display:n}=It(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+r)&&!s4.has(n)}const u4=new Set(["table","td","th"]);function l4(e){return u4.has(pn(e))}const c4=[":popover-open",":modal"];function Ka(e){return c4.some(t=>{try{return e.matches(t)}catch{return!1}})}const d4=["transform","translate","scale","rotate","perspective"],p4=["transform","translate","scale","rotate","perspective","filter"],f4=["paint","layout","strict","content"];function Xc(e){const t=ed(),r=St(e)?It(e):e;return d4.some(o=>r[o]?r[o]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||p4.some(o=>(r.willChange||"").includes(o))||f4.some(o=>(r.contain||"").includes(o))}function m4(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 h4=new Set(["html","body","#document"]);function nn(e){return h4.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||Lf(e)&&e.host||Dt(e);return Lf(t)?t.host:t}function k$(e){const t=lr(e);return nn(t)?e.ownerDocument?e.ownerDocument.body:e.body:zt(t)&&Co(t)?t:k$(t)}function Yn(e,t,r){var o;t===void 0&&(t=[]),r===void 0&&(r=!0);const n=k$(e),i=n===((o=e.ownerDocument)==null?void 0:o.body),a=Qe(n);if(i){const s=Cu(a);return t.concat(a,a.visualViewport||[],Co(n)?n:[],s&&r?Yn(s):[])}return t.concat(n,Yn(n,[],r))}function Cu(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function E$(e){const t=It(e);let r=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const n=zt(e),i=n?e.offsetWidth:r,a=n?e.offsetHeight:o,s=Di(r)!==i||Di(o)!==a;return s&&(r=i,o=a),{width:r,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 r=t.getBoundingClientRect(),{width:o,height:n,$:i}=E$(t);let a=(i?Di(r.width):r.width)/o,s=(i?Di(r.height):r.height)/n;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const g4=At(0);function T$(e){const t=Qe(e);return!ed()||!t.visualViewport?g4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function v4(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Qe(e)?!1:t}function Ir(e,t,r,o){t===void 0&&(t=!1),r===void 0&&(r=!1);const n=e.getBoundingClientRect(),i=td(e);let a=At(1);t&&(o?St(o)&&(a=Vr(o)):a=Vr(e));const s=v4(i,r,o)?T$(i):At(0);let l=(n.left+s.x)/a.x,u=(n.top+s.y)/a.y,c=n.width/a.x,d=n.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 Li({width:c,height:d,x:l,y:u})}function rd(e,t){const r=Ya(e).scrollLeft;return t?t.left+r:Ir(Dt(e)).left+r}function O$(e,t,r){r===void 0&&(r=!1);const o=e.getBoundingClientRect(),n=o.left+t.scrollLeft-(r?0:rd(e,o)),i=o.top+t.scrollTop;return{x:n,y:i}}function y4(e){let{elements:t,rect:r,offsetParent:o,strategy:n}=e;const i=n==="fixed",a=Dt(o),s=t?Ka(t.floating):!1;if(o===a||s&&i)return r;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?O$(a,l,!0):At(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-l.scrollLeft*u.x+c.x+f.x,y:r.y*u.y-l.scrollTop*u.y+c.y+f.y}}function b4(e){return Array.from(e.getClientRects())}function _4(e){const t=Dt(e),r=Ya(e),o=e.ownerDocument.body,n=Ye(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),i=Ye(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let a=-r.scrollLeft+rd(e);const s=-r.scrollTop;return It(o).direction==="rtl"&&(a+=Ye(t.clientWidth,o.clientWidth)-n),{width:n,height:i,x:a,y:s}}function w4(e,t){const r=Qe(e),o=Dt(e),n=r.visualViewport;let i=o.clientWidth,a=o.clientHeight,s=0,l=0;if(n){i=n.width,a=n.height;const u=ed();(!u||u&&t==="fixed")&&(s=n.offsetLeft,l=n.offsetTop)}return{width:i,height:a,x:s,y:l}}const x4=new Set(["absolute","fixed"]);function $4(e,t){const r=Ir(e,!0,t==="fixed"),o=r.top+e.clientTop,n=r.left+e.clientLeft,i=zt(e)?Vr(e):At(1),a=e.clientWidth*i.x,s=e.clientHeight*i.y,l=n*i.x,u=o*i.y;return{width:a,height:s,x:l,y:u}}function Zf(e,t,r){let o;if(t==="viewport")o=w4(e,r);else if(t==="document")o=_4(Dt(e));else if(St(t))o=$4(t,r);else{const n=T$(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Li(o)}function N$(e,t){const r=lr(e);return r===t||!St(r)||nn(r)?!1:It(r).position==="fixed"||N$(r,t)}function S4(e,t){const r=t.get(e);if(r)return r;let o=Yn(e,[],!1).filter(s=>St(s)&&pn(s)!=="body"),n=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"&&(n=null),(i?!l&&!n:!l&&s.position==="static"&&!!n&&x4.has(n.position)||Co(a)&&!l&&N$(e,a))?o=o.filter(c=>c!==a):n=s,a=lr(a)}return t.set(e,o),o}function I4(e){let{element:t,boundary:r,rootBoundary:o,strategy:n}=e;const a=[...r==="clippingAncestors"?Ka(t)?[]:S4(t,this._c):[].concat(r),o],s=a[0],l=a.reduce((u,c)=>{const d=Zf(t,c,n);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},Zf(t,s,n));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function k4(e){const{width:t,height:r}=E$(e);return{width:t,height:r}}function E4(e,t,r){const o=zt(t),n=Dt(t),i=r==="fixed",a=Ir(e,!0,i,t);let s={scrollLeft:0,scrollTop:0};const l=At(0);function u(){l.x=rd(n)}if(o||!o&&!i)if((pn(t)!=="body"||Co(n))&&(s=Ya(t)),o){const p=Ir(t,!0,i,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else n&&u();i&&!o&&n&&u();const c=n&&!o&&!i?O$(n,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 Ff(e,t){if(!zt(e)||It(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Dt(e)===r&&(r=r.ownerDocument.body),r}function P$(e,t){const r=Qe(e);if(Ka(e))return r;if(!zt(e)){let n=lr(e);for(;n&&!nn(n);){if(St(n)&&!Ds(n))return n;n=lr(n)}return r}let o=Ff(e,t);for(;o&&l4(o)&&Ds(o);)o=Ff(o,t);return o&&nn(o)&&Ds(o)&&!Xc(o)?r:o||m4(e)||r}const T4=async function(e){const t=this.getOffsetParent||P$,r=this.getDimensions,o=await r(e.floating);return{reference:E4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function O4(e){return It(e).direction==="rtl"}const N4={convertOffsetParentRelativeRectToViewportRelativeRect:y4,getDocumentElement:Dt,getClippingRect:I4,getOffsetParent:P$,getElementRects:T4,getClientRects:b4,getDimensions:k4,getScale:Vr,isElement:St,isRTL:O4};function C$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function P4(e,t){let r=null,o;const n=Dt(e);function i(){var s;clearTimeout(o),(s=r)==null||s.disconnect(),r=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(n.clientWidth-(c+f)),b=Go(n.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&&!C$(u,e.getBoundingClientRect())&&a(),v=!1}try{r=new IntersectionObserver(k,{...$,root:n.ownerDocument})}catch{r=new IntersectionObserver(k,$)}r.observe(e)}return a(!0),i}function C4(e,t,r,o){o===void 0&&(o={});const{ancestorScroll:n=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,u=td(e),c=n||i?[...u?Yn(u):[],...Yn(t)]:[];c.forEach(y=>{n&&y.addEventListener("scroll",r,{passive:!0}),i&&y.addEventListener("resize",r)});const d=u&&s?P4(u,r):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)})),r()}),u&&!l&&p.observe(u),p.observe(t));let g,h=l?Ir(e):null;l&&b();function b(){const y=Ir(e);h&&!C$(h,y)&&r(),h=y,g=requestAnimationFrame(b)}return r(),()=>{var y;c.forEach(x=>{n&&x.removeEventListener("scroll",r),i&&x.removeEventListener("resize",r)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const j4=n4,A4=o4,R4=e4,z4=a4,M4=t4,qf=XM,D4=i4,U4=(e,t,r)=>{const o=new Map,n={platform:N4,...r},i={...n.platform,_c:o};return QM(e,t,{...n,platform:i})};var L4=typeof document<"u",Z4=function(){},ai=L4?D.useLayoutEffect:Z4;function Zi(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 r,o,n;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(o=r;o--!==0;)if(!Zi(e[o],t[o]))return!1;return!0}if(n=Object.keys(e),r=n.length,r!==Object.keys(t).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(t,n[o]))return!1;for(o=r;o--!==0;){const i=n[o];if(!(i==="_owner"&&e.$$typeof)&&!Zi(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function j$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Vf(e,t){const r=j$(e);return Math.round(t*r)/r}function Us(e){const t=_.useRef(e);return ai(()=>{t.current=e}),t}function F4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:o=[],platform:n,elements:{reference:i,floating:a}={},transform:s=!0,whileElementsMounted:l,open:u}=e,[c,d]=_.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=_.useState(o);Zi(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(n),ie=Us(u),J=_.useCallback(()=>{if(!N.current||!I.current)return;const K={placement:t,strategy:r,middleware:f};te.current&&(K.platform=te.current),U4(N.current,I.current,K).then(fe=>{const B={...fe,isPositioned:ie.current!==!1};V.current&&!Zi(O.current,B)&&(O.current=B,sm.flushSync(()=>{d(B)}))})},[f,t,r,te,ie]);ai(()=>{u===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,d(K=>({...K,isPositioned:!1})))},[u]);const V=_.useRef(!1);ai(()=>(V.current=!0,()=>{V.current=!1}),[]),ai(()=>{if(v&&(N.current=v),k&&(I.current=k),v&&k){if(F.current)return F.current(v,k,J);J()}},[v,k,J,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:r,left:0,top:0};if(!oe.floating)return K;const fe=Vf(oe.floating,c.x),B=Vf(oe.floating,c.y);return s?{...K,transform:"translate("+fe+"px, "+B+"px)",...j$(oe.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:fe,top:B}},[r,s,oe.floating,c.x,c.y]);return _.useMemo(()=>({...c,update:J,refs:we,elements:oe,floatingStyles:de}),[c,J,we,oe,de])}const q4=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:o,padding:n}=typeof e=="function"?e(r):e;return o&&t(o)?o.current!=null?qf({element:o.current,padding:n}).fn(r):{}:o?qf({element:o,padding:n}).fn(r):{}}}},V4=(e,t)=>({...j4(e),options:[e,t]}),B4=(e,t)=>({...A4(e),options:[e,t]}),J4=(e,t)=>({...D4(e),options:[e,t]}),W4=(e,t)=>({...R4(e),options:[e,t]}),H4=(e,t)=>({...z4(e),options:[e,t]}),G4=(e,t)=>({...M4(e),options:[e,t]}),K4=(e,t)=>({...q4(e),options:[e,t]});var Y4="Arrow",A$=_.forwardRef((e,t)=>{const{children:r,width:o=10,height:n=5,...i}=e;return m.jsx(Ce.svg,{...i,ref:t,width:o,height:n,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});A$.displayName=Y4;var Q4=A$;function X4(e){const[t,r]=_.useState(void 0);return lt(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(n=>{if(!Array.isArray(n)||!n.length)return;const i=n[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;r({width:a,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else r(void 0)},[e]),t}var nd="Popper",[R$,Qa]=Po(nd),[eD,z$]=R$(nd),M$=e=>{const{__scopePopper:t,children:r}=e,[o,n]=_.useState(null);return m.jsx(eD,{scope:t,anchor:o,onAnchorChange:n,children:r})};M$.displayName=nd;var D$="PopperAnchor",U$=_.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:o,...n}=e,i=z$(D$,r),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,{...n,ref:s})});U$.displayName=D$;var od="PopperContent",[tD,rD]=R$(od),L$=_.forwardRef((e,t)=>{const{__scopePopper:r,side:o="bottom",sideOffset:n=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,r),[y,x]=_.useState(null),$=Ge(t,xe=>x(xe)),[v,k]=_.useState(null),N=X4(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],ie=te.length>0,J={padding:F,boundary:te.filter(oD),altBoundary:ie},{refs:V,floatingStyles:we,placement:oe,isPositioned:de,middlewareData:K}=F4({strategy:"fixed",placement:z,whileElementsMounted:(...xe)=>C4(...xe,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[V4({mainAxis:n+O,alignmentAxis:a}),l&&B4({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?J4():void 0,...J}),l&&W4({...J}),H4({...J,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&&K4({element:v,padding:s}),iD({arrowWidth:I,arrowHeight:O}),f&&G4({strategy:"referenceHidden",...J})]}),[fe,B]=q$(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:V.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(tD,{scope:r,placedSide:fe,onArrowChange:k,arrowX:ye,arrowY:Le,shouldHideArrow:U,children:m.jsx(Ce.div,{"data-side":fe,"data-align":B,...h,ref:$,style:{...h.style,animation:de?void 0:"none"}})})})});L$.displayName=od;var Z$="PopperArrow",nD={top:"bottom",right:"left",bottom:"top",left:"right"},F$=_.forwardRef(function(t,r){const{__scopePopper:o,...n}=t,i=rD(Z$,o),a=nD[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(Q4,{...n,ref:r,style:{...n.style,display:"block"}})})});F$.displayName=Z$;function oD(e){return e!==null}var iD=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:o,middlewareData:n}=t,a=n.arrow?.centerOffset!==0,s=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[u,c]=q$(r),d={start:"0%",center:"50%",end:"100%"}[c],f=(n.arrow?.x??0)+s/2,p=(n.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 q$(e){const[t,r="center"]=e.split("-");return[t,r]}var V$=M$,id=U$,B$=L$,J$=F$,aD="Portal",Xa=_.forwardRef((e,t)=>{const{container:r,...o}=e,[n,i]=_.useState(!1);lt(()=>i(!0),[]);const a=r||n&&globalThis?.document?.body;return a?am.createPortal(m.jsx(Ce.div,{...o,ref:t}),a):null});Xa.displayName=aD;function sD(e,t){return _.useReducer((r,o)=>t[r][o]??r,e)}var Gt=e=>{const{present:t,children:r}=e,o=uD(t),n=typeof r=="function"?r({present:o.isPresent}):_.Children.only(r),i=Ge(o.ref,lD(n));return typeof r=="function"||o.isPresent?_.cloneElement(n,{ref:i}):null};Gt.displayName="Presence";function uD(e){const[t,r]=_.useState(),o=_.useRef(null),n=_.useRef(e),i=_.useRef("none"),a=e?"mounted":"unmounted",[s,l]=sD(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=n.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"),n.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"),!n.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,r(u)},[])}}function Ko(e){return e?.animationName||"none"}function lD(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var cD=_[" useInsertionEffect ".trim().toString()]||lt;function es({prop:e,defaultProp:t,onChange:r=()=>{},caller:o}){const[n,i,a]=dD({defaultProp:t,onChange:r}),s=e!==void 0,l=s?e:n;{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 dD({defaultProp:e,onChange:t}){const[r,o]=_.useState(e),n=_.useRef(r),i=_.useRef(t);return cD(()=>{i.current=t},[t]),_.useEffect(()=>{n.current!==r&&(i.current?.(r),n.current=r)},[r,n]),[r,o,i]}function pD(e){return typeof e=="function"}var fD=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"}),mD="VisuallyHidden",W$=_.forwardRef((e,t)=>m.jsx(Ce.span,{...e,ref:t,style:{...fD,...e.style}}));W$.displayName=mD;var hD=W$,[ts]=Po("Tooltip",[Qa]),rs=Qa(),H$="TooltipProvider",gD=700,ju="tooltip.open",[vD,ad]=ts(H$),G$=e=>{const{__scopeTooltip:t,delayDuration:r=gD,skipDelayDuration:o=300,disableHoverableContent:n=!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(vD,{scope:t,isOpenDelayedRef:a,delayDuration:r,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:n,children:i})};G$.displayName=H$;var Qn="Tooltip",[yD,jo]=ts(Qn),K$=e=>{const{__scopeTooltip:t,children:r,open:o,defaultOpen:n,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:n??!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(V$,{...u,children:m.jsx(yD,{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:r})})};K$.displayName=Qn;var Au="TooltipTrigger",Y$=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=jo(Au,r),i=ad(Au,r),a=rs(r),s=_.useRef(null),l=Ge(t,s,n.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":n.open?n.contentId:void 0,"data-state":n.stateAttribute,...o,ref:l,onPointerMove:Oe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!c.current&&!i.isPointerInTransitRef.current&&(n.onTriggerEnter(),c.current=!0)}),onPointerLeave:Oe(e.onPointerLeave,()=>{n.onTriggerLeave(),c.current=!1}),onPointerDown:Oe(e.onPointerDown,()=>{n.open&&n.onClose(),u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Oe(e.onFocus,()=>{u.current||n.onOpen()}),onBlur:Oe(e.onBlur,n.onClose),onClick:Oe(e.onClick,n.onClose)})})});Y$.displayName=Au;var sd="TooltipPortal",[bD,_D]=ts(sd,{forceMount:void 0}),Q$=e=>{const{__scopeTooltip:t,forceMount:r,children:o,container:n}=e,i=jo(sd,t);return m.jsx(bD,{scope:t,forceMount:r,children:m.jsx(Gt,{present:r||i.open,children:m.jsx(Xa,{asChild:!0,container:n,children:o})})})};Q$.displayName=sd;var on="TooltipContent",X$=_.forwardRef((e,t)=>{const r=_D(on,e.__scopeTooltip),{forceMount:o=r.forceMount,side:n="top",...i}=e,a=jo(on,e.__scopeTooltip);return m.jsx(Gt,{present:o||a.open,children:a.disableHoverableContent?m.jsx(eS,{side:n,...i,ref:t}):m.jsx(wD,{side:n,...i,ref:t})})}),wD=_.forwardRef((e,t)=>{const r=jo(on,e.__scopeTooltip),o=ad(on,e.__scopeTooltip),n=_.useRef(null),i=Ge(t,n),[a,s]=_.useState(null),{trigger:l,onClose:u}=r,c=n.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=ID(y,b.getBoundingClientRect()),$=kD(y,x),v=ED(h.getBoundingClientRect()),k=OD([...$,...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),$=!TD(y,a);x?f():$&&(f(),u())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[l,c,a,u,f]),m.jsx(eS,{...e,ref:i})}),[xD,$D]=ts(Qn,{isInside:!1}),SD=IM("TooltipContent"),eS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,children:o,"aria-label":n,onEscapeKeyDown:i,onPointerDownOutside:a,...s}=e,l=jo(on,r),u=rs(r),{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(B$,{"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(SD,{children:o}),m.jsx(xD,{scope:r,isInside:!0,children:m.jsx(hD,{id:l.contentId,role:"tooltip",children:n||o})})]})})});X$.displayName=on;var tS="TooltipArrow",rS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=rs(r);return $D(tS,r).isInside?null:m.jsx(J$,{...n,...o,ref:t})});rS.displayName=tS;function ID(e,t){const r=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),n=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(r,o,n,i)){case i:return"left";case n:return"right";case r:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function kD(e,t,r=5){const o=[];switch(t){case"top":o.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":o.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":o.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":o.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return o}function ED(e){const{top:t,right:r,bottom:o,left:n}=e;return[{x:n,y:t},{x:r,y:t},{x:r,y:o},{x:n,y:o}]}function TD(e,t){const{x:r,y:o}=e;let n=!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&&r<(d-u)*(o-c)/(f-c)+u&&(n=!n)}return n}function OD(e){const t=e.slice();return t.sort((r,o)=>r.x<o.x?-1:r.x>o.x?1:r.y<o.y?-1:r.y>o.y?1:0),ND(t)}function ND(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const n=e[o];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))t.pop();else break}t.push(n)}t.pop();const r=[];for(let o=e.length-1;o>=0;o--){const n=e[o];for(;r.length>=2;){const i=r[r.length-1],a=r[r.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))r.pop();else break}r.push(n)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var PD=G$,CD=K$,jD=Y$,AD=Q$,RD=X$,zD=rS;function nS({delayDuration:e=0,...t}){return m.jsx(PD,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ud({...e}){return m.jsx(nS,{children:m.jsx(CD,{"data-slot":"tooltip",...e})})}function ld({...e}){return m.jsx(jD,{"data-slot":"tooltip-trigger",...e})}function cd({className:e,sideOffset:t=0,children:r,...o}){return m.jsx(AD,{children:m.jsxs(RD,{"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:[r,m.jsx(zD,{className:"bg-foreground fill-foreground z-20 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]"})]})})}var Ls="focusScope.autoFocusOnMount",Zs="focusScope.autoFocusOnUnmount",Bf={bubbles:!1,cancelable:!0},MD="FocusScope",dd=_.forwardRef((e,t)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:n,onUnmountAutoFocus:i,...a}=e,[s,l]=_.useState(null),u=Sr(n),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){Wf.add(p);const h=document.activeElement;if(!s.contains(h)){const y=new CustomEvent(Ls,Bf);s.addEventListener(Ls,u),s.dispatchEvent(y),y.defaultPrevented||(DD(qD(oS(s)),{select:!0}),document.activeElement===h&&Qt(s))}return()=>{s.removeEventListener(Ls,u),setTimeout(()=>{const y=new CustomEvent(Zs,Bf);s.addEventListener(Zs,c),s.dispatchEvent(y),y.defaultPrevented||Qt(h??document.body,{select:!0}),s.removeEventListener(Zs,c),Wf.remove(p)},0)}}},[s,u,c,p]);const g=_.useCallback(h=>{if(!r&&!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]=UD(x);$&&v?!h.shiftKey&&y===v?(h.preventDefault(),r&&Qt($,{select:!0})):h.shiftKey&&y===$&&(h.preventDefault(),r&&Qt(v,{select:!0})):y===x&&h.preventDefault()}},[r,o,p.paused]);return m.jsx(Ce.div,{tabIndex:-1,...a,ref:f,onKeyDown:g})});dd.displayName=MD;function DD(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(Qt(o,{select:t}),document.activeElement!==r)return}function UD(e){const t=oS(e),r=Jf(t,e),o=Jf(t.reverse(),e);return[r,o]}function oS(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const n=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||n?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function Jf(e,t){for(const r of e)if(!LD(r,{upTo:t}))return r}function LD(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 ZD(e){return e instanceof HTMLInputElement&&"select"in e}function Qt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&ZD(e)&&t&&e.select()}}var Wf=FD();function FD(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Hf(e,t),e.unshift(t)},remove(t){e=Hf(e,t),e[0]?.resume()}}}function Hf(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}function qD(e){return e.filter(t=>t.tagName!=="A")}var Fs=0;function iS(){_.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Gf()),document.body.insertAdjacentElement("beforeend",e[1]??Gf()),Fs++,()=>{Fs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Fs--}},[])}function Gf(){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 Pt=function(){return Pt=Object.assign||function(t){for(var r,o=1,n=arguments.length;o<n;o++){r=arguments[o];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Pt.apply(this,arguments)};function aS(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r}function VD(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;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",BD="with-scroll-bars-hidden",JD="--removed-body-scroll-bar-size";function qs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function WD(e,t){var r=D.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(o){var n=r.value;n!==o&&(r.value=o,r.callback(o,n))}}}})[0];return r.callback=t,r.facade}var HD=typeof window<"u"?_.useLayoutEffect:_.useEffect,Kf=new WeakMap;function GD(e,t){var r=WD(null,function(o){return e.forEach(function(n){return qs(n,o)})});return HD(function(){var o=Kf.get(r);if(o){var n=new Set(o),i=new Set(e),a=r.current;n.forEach(function(s){i.has(s)||qs(s,null)}),i.forEach(function(s){n.has(s)||qs(s,a)})}Kf.set(r,e)},[e]),r}function KD(e){return e}function YD(e,t){t===void 0&&(t=KD);var r=[],o=!1,n={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(i){var a=t(i,o);return r.push(a),function(){r=r.filter(function(s){return s!==a})}},assignSyncMedium:function(i){for(o=!0;r.length;){var a=r;r=[],a.forEach(i)}r={push:function(s){return i(s)},filter:function(){return r}}},assignMedium:function(i){o=!0;var a=[];if(r.length){var s=r;r=[],s.forEach(i),a=r}var l=function(){var c=a;a=[],c.forEach(i)},u=function(){return Promise.resolve().then(l)};u(),r={push:function(c){a.push(c),u()},filter:function(c){return a=a.filter(c),r}}}};return n}function QD(e){e===void 0&&(e={});var t=YD(null);return t.options=Pt({async:!0,ssr:!1},e),t}var sS=function(e){var t=e.sideCar,r=aS(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({},r))};sS.isSideCarExport=!0;function XD(e,t){return e.useMedium(t),sS}var uS=QD(),Vs=function(){},ns=_.forwardRef(function(e,t){var r=_.useRef(null),o=_.useState({onScrollCapture:Vs,onWheelCapture:Vs,onTouchMoveCapture:Vs}),n=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=aS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,N=GD([r,t]),I=Pt(Pt({},v),n);return _.createElement(_.Fragment,null,c&&_.createElement(k,{sideCar:uS,removeScrollBar:u,shards:d,noRelative:p,noIsolation:g,inert:h,setCallbacks:i,allowPinchZoom:!!b,lockRef:r,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 eU=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function tU(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=eU();return t&&e.setAttribute("nonce",t),e}function rU(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function nU(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var oU=function(){var e=0,t=null;return{add:function(r){e==0&&(t=tU())&&(rU(t,r),nU(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},iU=function(){var e=oU();return function(t,r){_.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},lS=function(){var e=iU(),t=function(r){var o=r.styles,n=r.dynamic;return e(o,n),null};return t},aU={left:0,top:0,right:0,gap:0},Bs=function(e){return parseInt(e||"",10)||0},sU=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],n=t[e==="padding"?"paddingRight":"marginRight"];return[Bs(r),Bs(o),Bs(n)]},uU=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return aU;var t=sU(e),r=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-r+t[2]-t[0])}},lU=lS(),Br="data-scroll-locked",cU=function(e,t,r,o){var n=e.left,i=e.top,a=e.right,s=e.gap;return r===void 0&&(r="margin"),`
|
|
97
|
+
.`.concat(BD,` {
|
|
98
98
|
overflow: hidden `).concat(o,`;
|
|
99
99
|
padding-right: `).concat(s,"px ").concat(o,`;
|
|
100
100
|
}
|
|
101
101
|
body[`).concat(Br,`] {
|
|
102
102
|
overflow: hidden `).concat(o,`;
|
|
103
103
|
overscroll-behavior: contain;
|
|
104
|
-
`).concat([t&&"position: relative ".concat(o,";"),
|
|
105
|
-
padding-left: `.concat(
|
|
104
|
+
`).concat([t&&"position: relative ".concat(o,";"),r==="margin"&&`
|
|
105
|
+
padding-left: `.concat(n,`px;
|
|
106
106
|
padding-top: `).concat(i,`px;
|
|
107
107
|
padding-right: `).concat(a,`px;
|
|
108
108
|
margin-left:0;
|
|
109
109
|
margin-top:0;
|
|
110
110
|
margin-right: `).concat(s,"px ").concat(o,`;
|
|
111
|
-
`),
|
|
111
|
+
`),r==="padding"&&"padding-right: ".concat(s,"px ").concat(o,";")].filter(Boolean).join(""),`
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
.`).concat(si,` {
|
|
@@ -128,16 +128,16 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
body[`).concat(Br,`] {
|
|
131
|
-
`).concat(
|
|
131
|
+
`).concat(JD,": ").concat(s,`px;
|
|
132
132
|
}
|
|
133
|
-
`)},
|
|
133
|
+
`)},Yf=function(){var e=parseInt(document.body.getAttribute(Br)||"0",10);return isFinite(e)?e:0},dU=function(){_.useEffect(function(){return document.body.setAttribute(Br,(Yf()+1).toString()),function(){var e=Yf()-1;e<=0?document.body.removeAttribute(Br):document.body.setAttribute(Br,e.toString())}},[])},pU=function(e){var t=e.noRelative,r=e.noImportant,o=e.gapMode,n=o===void 0?"margin":o;dU();var i=_.useMemo(function(){return uU(n)},[n]);return _.createElement(lU,{styles:cU(i,!t,n,r?"":"!important")})},Ru=!1;if(typeof window<"u")try{var Yo=Object.defineProperty({},"passive",{get:function(){return Ru=!0,!0}});window.addEventListener("test",Yo,Yo),window.removeEventListener("test",Yo,Yo)}catch{Ru=!1}var Rr=Ru?{passive:!1}:!1,fU=function(e){return e.tagName==="TEXTAREA"},cS=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!fU(e)&&r[t]==="visible")},mU=function(e){return cS(e,"overflowY")},hU=function(e){return cS(e,"overflowX")},Qf=function(e,t){var r=t.ownerDocument,o=t;do{typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(o=o.host);var n=dS(e,o);if(n){var i=pS(e,o),a=i[1],s=i[2];if(a>s)return!0}o=o.parentNode}while(o&&o!==r.body);return!1},gU=function(e){var t=e.scrollTop,r=e.scrollHeight,o=e.clientHeight;return[t,r,o]},vU=function(e){var t=e.scrollLeft,r=e.scrollWidth,o=e.clientWidth;return[t,r,o]},dS=function(e,t){return e==="v"?mU(t):hU(t)},pS=function(e,t){return e==="v"?gU(t):vU(t)},yU=function(e,t){return e==="h"&&t==="rtl"?-1:1},bU=function(e,t,r,o,n){var i=yU(e,window.getComputedStyle(t).direction),a=i*o,s=r.target,l=t.contains(s),u=!1,c=a>0,d=0,f=0;do{if(!s)break;var p=pS(e,s),g=p[0],h=p[1],b=p[2],y=h-b-i*g;(g||y)&&dS(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},Qo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Xf=function(e){return[e.deltaX,e.deltaY]},em=function(e){return e&&"current"in e?e.current:e},_U=function(e,t){return e[0]===t[0]&&e[1]===t[1]},wU=function(e){return`
|
|
134
134
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
135
135
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
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.
|
|
136
|
+
`)},xU=0,zr=[];function $U(e){var t=_.useRef([]),r=_.useRef([0,0]),o=_.useRef(),n=_.useState(xU++)[0],i=_.useState(lS)[0],a=_.useRef(e);_.useEffect(function(){a.current=e},[e]),_.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(n));var h=VD([e.lockRef.current],(e.shards||[]).map(em),!0).filter(Boolean);return h.forEach(function(b){return b.classList.add("allow-interactivity-".concat(n))}),function(){document.body.classList.remove("block-interactivity-".concat(n)),h.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(n))})}}},[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=Qo(h),x=r.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=Qf(I,N);if(!O)return!0;if(O?k=I:(k=I==="v"?"h":"v",O=Qf(I,N)),!O)return!1;if(!o.current&&"changedTouches"in h&&($||v)&&(o.current=k),!k)return!0;var z=o.current||k;return bU(z,b,h,z==="h"?$:v)},[]),l=_.useCallback(function(h){var b=h;if(!(!zr.length||zr[zr.length-1]!==i)){var y="deltaY"in b?Xf(b):Qo(b),x=t.current.filter(function(k){return k.name===b.type&&(k.target===b.target||b.target===k.shadowParent)&&_U(k.delta,y)})[0];if(x&&x.should){b.cancelable&&b.preventDefault();return}if(!x){var $=(a.current.shards||[]).map(em).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:SU(y)};t.current.push($),setTimeout(function(){t.current=t.current.filter(function(v){return v!==$})},1)},[]),c=_.useCallback(function(h){r.current=Qo(h),o.current=void 0},[]),d=_.useCallback(function(h){u(h.type,Xf(h),h.target,s(h,e.lockRef.current))},[]),f=_.useCallback(function(h){u(h.type,Qo(h),h.target,s(h,e.lockRef.current))},[]);_.useEffect(function(){return zr.push(i),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Rr),document.addEventListener("touchmove",l,Rr),document.addEventListener("touchstart",c,Rr),function(){zr=zr.filter(function(h){return h!==i}),document.removeEventListener("wheel",l,Rr),document.removeEventListener("touchmove",l,Rr),document.removeEventListener("touchstart",c,Rr)}},[]);var p=e.removeScrollBar,g=e.inert;return _.createElement(_.Fragment,null,g?_.createElement(i,{styles:wU(n)}):null,p?_.createElement(pU,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function SU(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const IU=XD(uS,$U);var pd=_.forwardRef(function(e,t){return _.createElement(ns,Pt({},e,{ref:t,sideCar:IU}))});pd.classNames=ns.classNames;var kU=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Mr=new WeakMap,Xo=new WeakMap,ei={},Js=0,fS=function(e){return e&&(e.host||fS(e.parentNode))},EU=function(e,t){return t.map(function(r){if(e.contains(r))return r;var o=fS(r);return o&&e.contains(o)?o:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},TU=function(e,t,r,o){var n=EU(t,Array.isArray(e)?e:[e]);ei[r]||(ei[r]=new WeakMap);var i=ei[r],a=[],s=new Set,l=new Set(n),u=function(d){!d||s.has(d)||(s.add(d),u(d.parentNode))};n.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=(Mr.get(f)||0)+1,b=(i.get(f)||0)+1;Mr.set(f,h),i.set(f,b),a.push(f),h===1&&g&&Xo.set(f,!0),b===1&&f.setAttribute(r,"true"),g||f.setAttribute(o,"true")}catch(y){console.error("aria-hidden: cannot operate on ",f,y)}})};return c(t),s.clear(),Js++,function(){a.forEach(function(d){var f=Mr.get(d)-1,p=i.get(d)-1;Mr.set(d,f),i.set(d,p),f||(Xo.has(d)||d.removeAttribute(o),Xo.delete(d)),p||d.removeAttribute(r)}),Js--,Js||(Mr=new WeakMap,Mr=new WeakMap,Xo=new WeakMap,ei={})}},mS=function(e,t,r){r===void 0&&(r="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),n=kU(e);return n?(o.push.apply(o,Array.from(n.querySelectorAll("[aria-live], script"))),TU(o,n,r,"aria-hidden")):function(){return null}},os="Dialog",[hS]=Po(os),[OU,kt]=hS(os),gS=e=>{const{__scopeDialog:t,children:r,open:o,defaultOpen:n,onOpenChange:i,modal:a=!0}=e,s=_.useRef(null),l=_.useRef(null),[u,c]=es({prop:o,defaultProp:n??!1,onChange:i,caller:os});return m.jsx(OU,{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:r})};gS.displayName=os;var vS="DialogTrigger",yS=_.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,n=kt(vS,r),i=Ge(t,n.triggerRef);return m.jsx(Ce.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":hd(n.open),...o,ref:i,onClick:Oe(e.onClick,n.onOpenToggle)})});yS.displayName=vS;var fd="DialogPortal",[NU,bS]=hS(fd,{forceMount:void 0}),_S=e=>{const{__scopeDialog:t,forceMount:r,children:o,container:n}=e,i=kt(fd,t);return m.jsx(NU,{scope:t,forceMount:r,children:_.Children.map(o,a=>m.jsx(Gt,{present:r||i.open,children:m.jsx(Xa,{asChild:!0,container:n,children:a})}))})};_S.displayName=fd;var Fi="DialogOverlay",wS=_.forwardRef((e,t)=>{const r=bS(Fi,e.__scopeDialog),{forceMount:o=r.forceMount,...n}=e,i=kt(Fi,e.__scopeDialog);return i.modal?m.jsx(Gt,{present:o||i.open,children:m.jsx(CU,{...n,ref:t})}):null});wS.displayName=Fi;var PU=Gc("DialogOverlay.RemoveScroll"),CU=_.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,n=kt(Fi,r);return m.jsx(pd,{as:PU,allowPinchZoom:!0,shards:[n.contentRef],children:m.jsx(Ce.div,{"data-state":hd(n.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),kr="DialogContent",xS=_.forwardRef((e,t)=>{const r=bS(kr,e.__scopeDialog),{forceMount:o=r.forceMount,...n}=e,i=kt(kr,e.__scopeDialog);return m.jsx(Gt,{present:o||i.open,children:i.modal?m.jsx(jU,{...n,ref:t}):m.jsx(AU,{...n,ref:t})})});xS.displayName=kr;var jU=_.forwardRef((e,t)=>{const r=kt(kr,e.__scopeDialog),o=_.useRef(null),n=Ge(t,r.contentRef,o);return _.useEffect(()=>{const i=o.current;if(i)return mS(i)},[]),m.jsx($S,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,i=>{i.preventDefault(),r.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())})}),AU=_.forwardRef((e,t)=>{const r=kt(kr,e.__scopeDialog),o=_.useRef(!1),n=_.useRef(!1);return m.jsx($S,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||r.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,n.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const a=i.target;r.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&n.current&&i.preventDefault()}})}),$S=_.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:o,onOpenAutoFocus:n,onCloseAutoFocus:i,...a}=e,s=kt(kr,r),l=_.useRef(null),u=Ge(t,l);return iS(),m.jsxs(m.Fragment,{children:[m.jsx(dd,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:n,onUnmountAutoFocus:i,children:m.jsx(Ha,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":hd(s.open),...a,ref:u,onDismiss:()=>s.onOpenChange(!1)})}),m.jsxs(m.Fragment,{children:[m.jsx(zU,{titleId:s.titleId}),m.jsx(DU,{contentRef:l,descriptionId:s.descriptionId})]})]})}),md="DialogTitle",SS=_.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,n=kt(md,r);return m.jsx(Ce.h2,{id:n.titleId,...o,ref:t})});SS.displayName=md;var IS="DialogDescription",RU=_.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,n=kt(IS,r);return m.jsx(Ce.p,{id:n.descriptionId,...o,ref:t})});RU.displayName=IS;var kS="DialogClose",ES=_.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,n=kt(kS,r);return m.jsx(Ce.button,{type:"button",...o,ref:t,onClick:Oe(e.onClick,()=>n.onOpenChange(!1))})});ES.displayName=kS;function hd(e){return e?"open":"closed"}var TS="DialogTitleWarning",[W2,OS]=xM(TS,{contentName:kr,titleName:md,docsSlug:"dialog"}),zU=({titleId:e})=>{const t=OS(TS),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
140
137
|
|
|
141
138
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
142
139
|
|
|
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;
|
|
140
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},MU="DialogDescriptionWarning",DU=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${OS(MU).contentName}}.`;return _.useEffect(()=>{const n=e.current?.getAttribute("aria-describedby");t&&n&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},UU=gS,LU=yS,ZU=_S,FU=wS,qU=xS,VU=SS,BU=ES;function JU({...e}){return m.jsx(UU,{"data-slot":"dialog",...e})}function WU({...e}){return m.jsx(LU,{"data-slot":"dialog-trigger",...e})}function HU({...e}){return m.jsx(ZU,{"data-slot":"dialog-portal",...e})}function GU({className:e,...t}){return m.jsx(FU,{"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 KU({className:e,children:t,showCloseButton:r=!0,...o}){return m.jsxs(HU,{"data-slot":"dialog-portal",children:[m.jsx(GU,{}),m.jsxs(qU,{"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,r&&m.jsxs(BU,{"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(Eo,{}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function YU({className:e,...t}){return m.jsx(VU,{"data-slot":"dialog-title",className:T.cn("text-lg leading-none font-semibold",e),...t})}function QU(e,t=[]){let r=[];function o(i,a){const s=_.createContext(a);s.displayName=i+"Context";const l=r.length;r=[...r,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 n=()=>{const i=r.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return n.scopeName=e,[o,XU(n,...t)]}function XU(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(n=>({useScope:n(),scopeName:n.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 r.scopeName=t.scopeName,r}var e6=Symbol.for("react.lazy"),qi=_[" use ".trim().toString()];function t6(e){return typeof e=="object"&&e!==null&&"then"in e}function NS(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===e6&&"_payload"in e&&t6(e._payload)}function PS(e){const t=n6(e),r=_.forwardRef((o,n)=>{let{children:i,...a}=o;NS(i)&&typeof qi=="function"&&(i=qi(i._payload));const s=_.Children.toArray(i),l=s.find(a6);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:n,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:n,children:i})});return r.displayName=`${e}.Slot`,r}var r6=PS("Slot");function n6(e){const t=_.forwardRef((r,o)=>{let{children:n,...i}=r;if(NS(n)&&typeof qi=="function"&&(n=qi(n._payload)),_.isValidElement(n)){const a=u6(n),s=s6(i,n.props);return n.type!==_.Fragment&&(s.ref=o?Hc(o,a):a),_.cloneElement(n,s)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var CS=Symbol("radix.slottable");function o6(e){const t=({children:r})=>m.jsx(m.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=CS,t}var i6=o6("Slottable");function a6(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===CS}function s6(e,t){const r={...t};for(const o in t){const n=e[o],i=t[o];/^on[A-Z]/.test(o)?n&&i?r[o]=(...s)=>{const l=i(...s);return n(...s),l}:n&&(r[o]=n):o==="style"?r[o]={...n,...i}:o==="className"&&(r[o]=[n,i].filter(Boolean).join(" "))}return{...e,...r}}function u6(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var l6=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],gd=l6.reduce((e,t)=>{const r=PS(`Primitive.${t}`),o=_.forwardRef((n,i)=>{const{asChild:a,...s}=n,l=a?r: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 c6(){return _j.useSyncExternalStore(d6,()=>!0,()=>!1)}function d6(){return()=>{}}var vd="Avatar",[p6]=QU(vd),[f6,jS]=p6(vd),AS=_.forwardRef((e,t)=>{const{__scopeAvatar:r,...o}=e,[n,i]=_.useState("idle");return m.jsx(f6,{scope:r,imageLoadingStatus:n,onImageLoadingStatusChange:i,children:m.jsx(gd.span,{...o,ref:t})})});AS.displayName=vd;var RS="AvatarImage",zS=_.forwardRef((e,t)=>{const{__scopeAvatar:r,src:o,onLoadingStatusChange:n=()=>{},...i}=e,a=jS(RS,r),s=m6(o,i),l=Sr(u=>{n(u),a.onImageLoadingStatusChange(u)});return lt(()=>{s!=="idle"&&l(s)},[s,l]),s==="loaded"?m.jsx(gd.img,{...i,ref:t,src:o}):null});zS.displayName=RS;var MS="AvatarFallback",DS=_.forwardRef((e,t)=>{const{__scopeAvatar:r,delayMs:o,...n}=e,i=jS(MS,r),[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(gd.span,{...n,ref:t}):null});DS.displayName=MS;function tm(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function m6(e,{referrerPolicy:t,crossOrigin:r}){const o=c6(),n=_.useRef(null),i=o?(n.current||(n.current=new window.Image),n.current):null,[a,s]=_.useState(()=>tm(i,e));return lt(()=>{s(tm(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 r=="string"&&(i.crossOrigin=r),()=>{i.removeEventListener("load",u),i.removeEventListener("error",c)}},[i,r,t]),a}var h6=AS,g6=zS,v6=DS;function y6({className:e,...t}){return m.jsx(h6,{"data-slot":"avatar",className:T.cn("relative flex size-8 shrink-0 overflow-hidden rounded-full",e),...t})}function b6({className:e,...t}){return m.jsx(g6,{"data-slot":"avatar-image",className:T.cn("aspect-square size-full",e),...t})}function _6({className:e,...t}){return m.jsx(v6,{"data-slot":"avatar-fallback",className:T.cn("bg-muted flex size-full items-center justify-center rounded-full",e),...t})}const rm=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,nm=T.clsx,US=(e,t)=>r=>{var o;if(t?.variants==null)return nm(e,r?.class,r?.className);const{variants:n,defaultVariants:i}=t,a=Object.keys(n).map(u=>{const c=r?.[u],d=i?.[u];if(c===null)return null;const f=rm(c)||rm(d);return n[u][f]}),s=r&&Object.entries(r).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 nm(e,a,l,r?.class,r?.className)},w6=US("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:r,asChild:o=!1,...n},i)=>{const a=o?r6:"button";return m.jsx(a,{"data-slot":"button",className:T.cn(w6({variant:t,size:r,className:e})),ref:i,...n})});$t.displayName="Button";const ct=D.forwardRef(({children:e,tooltip:t,side:r="bottom",align:o="center",className:n,...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",n),ref:a,children:[m.jsx(i6,{children:e}),m.jsx("span",{className:"aui-sr-only sr-only",children:t})]})}),m.jsx(cd,{side:r,align:o,children:t})]}));ct.displayName="TooltipIconButton";const x6=e=>{const[t,r]=D.useState(void 0);return D.useEffect(()=>{if(!e){r(void 0);return}const o=URL.createObjectURL(e);return r(o),()=>{URL.revokeObjectURL(o)}},[e]),t},LS=()=>{const{file:e,src:t}=L.useAssistantState(b0.useShallow(({attachment:r})=>{if(r.type!=="image")return{};if(r.file)return{file:r.file};const o=r.content?.filter(n=>n.type==="image")[0]?.image;return o?{src:o}:{}}));return x6(e)??t},$6=({src:e})=>{const[t,r]=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:()=>r(!0)})},S6=({children:e})=>{const t=LS();return t?m.jsxs(JU,{children:[m.jsx(WU,{className:"aui-attachment-preview-trigger hover:bg-accent/50 cursor-pointer transition-colors",asChild:!0,children:e}),m.jsxs(KU,{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(YU,{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($6,{src:t})})]})]}):e},I6=()=>{const e=L.useAssistantState(({attachment:r})=>r.type==="image"),t=LS();return m.jsxs(y6,{className:"aui-attachment-tile-avatar h-full w-full rounded-none",children:[m.jsx(b6,{src:t,alt:"Attachment preview",className:"aui-attachment-tile-image object-cover"}),m.jsx(_6,{delayMs:e?200:0,children:m.jsx(EN,{className:"aui-attachment-tile-fallback-icon text-muted-foreground size-8"})})]})},ZS=()=>{const t=L.useAssistantApi().attachment.source==="composer",r=L.useAssistantState(({attachment:n})=>n.type==="image"),o=L.useAssistantState(({attachment:n})=>{const i=n.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",r&&"aui-attachment-root-composer only:[&>#attachment-tile]:size-24"),children:[m.jsx(S6,{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(I6,{})})})}),t&&m.jsx(k6,{})]}),m.jsx(cd,{side:"top",children:m.jsx(L.AttachmentPrimitive.Name,{})})]})},k6=()=>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(Eo,{className:"aui-attachment-remove-icon size-3 dark:stroke-[2.5px]"})})}),E6=()=>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:ZS}})}),T6=()=>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:ZS}})}),O6=()=>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(FN,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})});function N6(e){return D.useMemo(()=>e.reduce((t,r)=>(t?.[r.language]&&!r.overrideExisting||(t={...t,[r.language]:{CodeHeader:r.Header??(()=>null),SyntaxHighlighter:r.Component??void 0}}),t),{}),[e])}const P6=()=>{const{plugins:e}=T.useElements(),t=N6(e);return m.jsx(Ws.MarkdownTextPrimitive,{remarkPlugins:[_0],className:"aui-md",components:A6,componentsByLanguage:t})},FS=D.memo(P6),C6=({language:e,code:t})=>{const o=L.useAssistantState(({message:s})=>s).status?.type==="complete",{isCopied:n,copyToClipboard:i}=j6(),a=()=>{!t||n||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:[!n&&m.jsx(Nc,{}),n&&m.jsx(nr,{})]})]}):null},j6=({copiedDuration:e=3e3}={})=>{const[t,r]=D.useState(!1);return{isCopied:t,copyToClipboard:n=>{n&&navigator.clipboard.writeText(n).then(()=>{r(!0),setTimeout(()=>r(!1),e)})}}},A6=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,...r}){const o=Ws.useIsMarkdownCodeBlock();return m.jsx("code",{className:T.cn(!o&&"aui-md-inline-code bg-muted rounded border font-semibold",t),...r})},CodeHeader:C6});var is="Collapsible",[R6]=Po(is),[z6,yd]=R6(is),qS=_.forwardRef((e,t)=>{const{__scopeCollapsible:r,open:o,defaultOpen:n,disabled:i,onOpenChange:a,...s}=e,[l,u]=es({prop:o,defaultProp:n??!1,onChange:a,caller:is});return m.jsx(z6,{scope:r,disabled:i,contentId:qr(),open:l,onOpenToggle:_.useCallback(()=>u(c=>!c),[u]),children:m.jsx(Ce.div,{"data-state":_d(l),"data-disabled":i?"":void 0,...s,ref:t})})});qS.displayName=is;var VS="CollapsibleTrigger",BS=_.forwardRef((e,t)=>{const{__scopeCollapsible:r,...o}=e,n=yd(VS,r);return m.jsx(Ce.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":_d(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...o,ref:t,onClick:Oe(e.onClick,n.onOpenToggle)})});BS.displayName=VS;var bd="CollapsibleContent",JS=_.forwardRef((e,t)=>{const{forceMount:r,...o}=e,n=yd(bd,e.__scopeCollapsible);return m.jsx(Gt,{present:r||n.open,children:({present:i})=>m.jsx(M6,{...o,ref:t,present:i})})});JS.displayName=bd;var M6=_.forwardRef((e,t)=>{const{__scopeCollapsible:r,present:o,children:n,...i}=e,a=yd(bd,r),[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":_d(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&&n})});function _d(e){return e?"open":"closed"}var D6=qS;function U6({...e}){return m.jsx(D6,{"data-slot":"collapsible",...e})}function L6({...e}){return m.jsx(BS,{"data-slot":"collapsible-trigger",...e})}function Z6({...e}){return m.jsx(JS,{"data-slot":"collapsible-content",...e})}const om=200,WS=({className:e,children:t})=>{const r=D.useRef(null),[o,n]=D.useState(!1),i=L.useScrollLock(r,om),a=D.useCallback(s=>{s||i(),n(s)},[i]);return m.jsx(U6,{ref:r,open:o,onOpenChange:a,className:T.cn("aui-reasoning-root mb-4 w-full",e),style:{"--animation-duration":`${om}ms`},children:t})};WS.displayName="ReasoningRoot";const F6=({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)}),q6=({active:e,className:t})=>m.jsxs(L6,{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(bN,{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(Ei,{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")})]}),HS=({className:e,children:t,"aria-busy":r})=>m.jsxs(Z6,{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":r,children:[t,m.jsx(F6,{})]});HS.displayName="ReasoningContent";const GS=({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});GS.displayName="ReasoningText";const V6=()=>m.jsx(FS,{}),B6=({children:e,startIndex:t,endIndex:r})=>{const o=L.useAssistantState(({message:n})=>{if(n.status?.type!=="running")return!1;const i=n.parts.length-1;return i<0||n.parts[i]?.type!=="reasoning"?!1:i>=t&&i<=r});return m.jsxs(WS,{children:[m.jsx(q6,{active:o}),m.jsx(HS,{"aria-busy":o,children:m.jsx(GS,{children:e})})]})},KS=D.memo(V6);KS.displayName="Reasoning";const YS=D.memo(B6);YS.displayName="ReasoningGroup";var as="Popover",[QS]=Po(as,[Qa]),Ao=Qa(),[J6,pr]=QS(as),XS=e=>{const{__scopePopover:t,children:r,open:o,defaultOpen:n,onOpenChange:i,modal:a=!1}=e,s=Ao(t),l=_.useRef(null),[u,c]=_.useState(!1),[d,f]=es({prop:o,defaultProp:n??!1,onChange:i,caller:as});return m.jsx(V$,{...s,children:m.jsx(J6,{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:r})})};XS.displayName=as;var e0="PopoverAnchor",W6=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=pr(e0,r),i=Ao(r),{onCustomAnchorAdd:a,onCustomAnchorRemove:s}=n;return _.useEffect(()=>(a(),()=>s()),[a,s]),m.jsx(id,{...i,...o,ref:t})});W6.displayName=e0;var t0="PopoverTrigger",r0=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=pr(t0,r),i=Ao(r),a=Ge(t,n.triggerRef),s=m.jsx(Ce.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":s0(n.open),...o,ref:a,onClick:Oe(e.onClick,n.onOpenToggle)});return n.hasCustomAnchor?s:m.jsx(id,{asChild:!0,...i,children:s})});r0.displayName=t0;var wd="PopoverPortal",[H6,G6]=QS(wd,{forceMount:void 0}),n0=e=>{const{__scopePopover:t,forceMount:r,children:o,container:n}=e,i=pr(wd,t);return m.jsx(H6,{scope:t,forceMount:r,children:m.jsx(Gt,{present:r||i.open,children:m.jsx(Xa,{asChild:!0,container:n,children:o})})})};n0.displayName=wd;var an="PopoverContent",o0=_.forwardRef((e,t)=>{const r=G6(an,e.__scopePopover),{forceMount:o=r.forceMount,...n}=e,i=pr(an,e.__scopePopover);return m.jsx(Gt,{present:o||i.open,children:i.modal?m.jsx(Y6,{...n,ref:t}):m.jsx(Q6,{...n,ref:t})})});o0.displayName=an;var K6=Gc("PopoverContent.RemoveScroll"),Y6=_.forwardRef((e,t)=>{const r=pr(an,e.__scopePopover),o=_.useRef(null),n=Ge(t,o),i=_.useRef(!1);return _.useEffect(()=>{const a=o.current;if(a)return mS(a)},[]),m.jsx(pd,{as:K6,allowPinchZoom:!0,children:m.jsx(i0,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,a=>{a.preventDefault(),i.current||r.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})})})}),Q6=_.forwardRef((e,t)=>{const r=pr(an,e.__scopePopover),o=_.useRef(!1),n=_.useRef(!1);return m.jsx(i0,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||r.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,n.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const a=i.target;r.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&n.current&&i.preventDefault()}})}),i0=_.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:o,onOpenAutoFocus:n,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:c,...d}=e,f=pr(an,r),p=Ao(r);return iS(),m.jsx(dd,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:n,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(B$,{"data-state":s0(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)"}})})})}),a0="PopoverClose",X6=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=pr(a0,r);return m.jsx(Ce.button,{type:"button",...o,ref:t,onClick:Oe(e.onClick,()=>n.onOpenChange(!1))})});X6.displayName=a0;var e2="PopoverArrow",t2=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=Ao(r);return m.jsx(J$,{...n,...o,ref:t})});t2.displayName=e2;function s0(e){return e?"open":"closed"}var r2=XS,n2=r0,o2=n0,i2=o0;function u0({...e}){return m.jsx(r2,{"data-slot":"popover",...e})}function l0({...e}){return m.jsx(n2,{"data-slot":"popover-trigger",...e})}function c0({className:e,align:t="center",sideOffset:r=4,...o}){return m.jsx(o2,{children:m.jsx(i2,{"data-slot":"popover-content",align:t,sideOffset:r,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 a2=US("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 s2(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 u2(e,t){if(t==="json")try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}return e}function l2(e){return typeof e=="object"&&e!==null&&"content"in e&&Array.isArray(e.content)}function d0({status:e}){return m.jsxs("div",{className:T.cn(a2({status:e})),children:[e==="pending"&&null,e==="running"&&m.jsx(lu,{className:"size-4 animate-spin"}),e==="complete"&&m.jsx(nr,{className:"size-4"}),e==="error"&&m.jsx(Eo,{className:"size-4"}),e==="approval"&&m.jsx(lu,{className:"text-muted-foreground size-4 animate-spin"})]})}function c2({content:e}){const[t,r]=D.useState(!1),o=async n=>{n.stopPropagation(),await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!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(nr,{className:"size-4"}):m.jsx(Nc,{className:"size-4"})})}function p0({text:e,language:t,className:r}){const[o,n]=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(n)},[e,t]),o?m.jsx("div",{className:T.cn("w-full bg-slate-800/90",r),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",r),children:e})}function d2({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%),
|
|
141
|
+
linear-gradient(135deg, #ccc 25%, transparent 25%),
|
|
142
|
+
linear-gradient(45deg, transparent 75%, #ccc 75%),
|
|
143
|
+
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 p2({content:e}){return m.jsx("div",{className:"w-full",children:e.content.map((t,r)=>{switch(t.type){case"text":{const o=s2(t._meta?.["getgram.ai/mime-type"]??"text/plain"),n=u2(t.text,o);return m.jsx(p0,{text:n,language:o},r)}case"image":return m.jsx(d2,{data:t.data},r);default:return m.jsx("pre",{className:"px-4 py-3 text-sm whitespace-pre-wrap",children:JSON.stringify(t,null,2)},r)}})})}function im({title:e,content:t,defaultExpanded:r=!1,highlightSyntax:o=!0,language:n="json"}){const[i,a]=D.useState(r),s=l2(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(c2,{content:l}),m.jsx(J_,{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(p2,{content:t}):o?m.jsx(p0,{text:l,language:n}):m.jsx("pre",{className:"text-foreground overflow-x-auto px-4 py-3 text-sm whitespace-pre-wrap",children:l})})]})}function f2({name:e,icon:t,provider:r,status:o="complete",request:n,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=n!==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:[r&&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:r.charAt(0).toUpperCase()}),m.jsx("span",{className:"text-sm font-medium",children:r})]}),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(d0,{status:o}),m.jsx("span",{className:T.cn("flex-1 text-sm",!r&&d&&"shimmer"),children:e}),g&&m.jsx(Ei,{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:[n!==void 0&&m.jsx(im,{title:"Arguments",content:n,highlightSyntax:!0,language:"json"}),i!==void 0&&m.jsx(im,{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(Eo,{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(nr,{className:"mr-1 size-3"}),m.jsx("span",{className:"min-w-[110px]",children:h==="one-time"?"Approve this time":"Approve always"})]}),m.jsxs(u0,{open:y,onOpenChange:x,children:[m.jsx(l0,{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(Ei,{className:"size-3"})})}),m.jsxs(c0,{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(nr,{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(nr,{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 m2({title:e,icon:t,status:r="complete",defaultExpanded:o=!1,children:n,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(d0,{status:r==="running"?"running":"complete"}),m.jsx("span",{className:T.cn("flex-1 text-sm font-medium",r==="running"&&"shimmer"),children:e}),m.jsx(Ei,{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:n})]})}const h2=({toolName:e,toolCallId:t,status:r,result:o,args:n})=>{const{pendingApprovals:i,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:l}=B_(),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":r.type==="incomplete"?"error":r.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(f2,{name:e,status:b(),request:n,result:y(),onApproveOnce:u?p:void 0,onApproveForSession:u?g:void 0,onDeny:u?h:void 0,className:"rounded-none border-0"})})},xd=()=>{const{config:e}=T.useElements(),t=e.theme??{};return D.useMemo(()=>{const{colorScheme:r="light"}=t;return{className:r==="dark"||r==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":void 0}},[t])},or=[.23,1,.32,1];function g2(e){return e.replace(/[-_]/g," ").split(/(?=[A-Z])/).join(" ").split(/\s+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const v2=({children:e})=>{const t=L.useAssistantState(({message:s})=>s).parts,r=t.filter(s=>s.type==="tool-call"),o=r.some(s=>s.status?.type==="running"),{config:n}=T.useElements(),i=n.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 ${g2(s[0].toolName)}...`:o?`Calling ${s.length} tools...`:`Executed ${s.length} tools`},[t,o]);return n.tools?.components?.[r[0]?.toolName]?e:r.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(m2,{title:a,status:o?"running":"complete",defaultExpanded:i,children:e})})},y2=()=>m.jsxs("div",{className:"m-2 rounded-md border border-amber-500 bg-amber-100 px-4 py-3 text-sm text-amber-800 dark:border-amber-600 dark:bg-amber-900/30 dark:text-amber-200",children:[m.jsx("strong",{children:"Warning:"})," You are using an API key directly in the client. Please"," ",m.jsx("a",{href:"https://github.com/speakeasy-api/gram/tree/main/elements#setting-up-your-backend",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-800 dark:text-amber-300 dark:hover:text-amber-200",children:"set up a session endpoint"})," ","before deploying to production."]}),$d=()=>{const e=xd(),t=T.useDensity(),{config:r}=T.useElements(),o=r.components??{},n=r.api&&"UNSAFE_apiKey"in r.api;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(_2,{})}),n&&m.jsx(y2,{}),m.jsx(L.ThreadPrimitive.Messages,{components:{UserMessage:o.UserMessage??O2,EditComposer:o.EditComposer??P2,AssistantMessage:o.AssistantMessage??k2}}),m.jsx(L.ThreadPrimitive.If,{empty:!1,children:m.jsx("div",{className:"aui-thread-viewport-spacer min-h-8 grow"})}),m.jsx(x2,{})]})})})})},b2=()=>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(hN,{})})}),_2=()=>{const{config:e}=T.useElements(),t=T.useDensity(),{title:r,subtitle:o}=e.welcome??{},n=e.variant==="standalone";return m.jsxs("div",{className:T.cn("aui-thread-welcome-root my-auto flex w-full grow flex-col",n?"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",n?"items-center text-center":"size-full justify-start",t("gap-sm"),!n&&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:r}),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(w2,{})]})},w2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=T.useDensity(),o=e.welcome?.suggestions??[],n=e.variant==="standalone";return o.length===0?null:m.jsx("div",{className:T.cn("aui-thread-welcome-suggestions w-full",r("gap-md"),r("py-lg"),n?"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",!n&&"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",r("text-base"),n?`flex-row items-center ${r("gap-sm")} ${r("px-md")} ${r("py-sm")} ${t("full")}`:`w-full flex-1 flex-col flex-wrap items-start justify-start ${r("gap-sm")} ${r("px-lg")} ${r("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}`))})},x2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=T.useDensity(),o=e.composer??{placeholder:"Send a message...",attachments:!0},n=e.components??{};return n.Composer?m.jsx(n.Composer,{}):m.jsxs("div",{className:T.cn("aui-composer-wrapper bg-background sticky bottom-0 flex w-full flex-col overflow-visible",r("gap-md"),r("py-md"),t("xl")),children:[m.jsx(b2,{}),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(T6,{}),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",r("h-input"),r("text-base")),rows:1,autoFocus:!0,"aria-label":"Message input"}),m.jsx(S2,{})]})]})},$2=()=>{const{model:e,setModel:t}=T.useElements(),[r,o]=D.useState(!1),[n,i]=D.useState(!1),a=D.useRef(null),s=D.useRef(0),l=D.useRef(!1);D.useEffect(()=>{r&&!l.current&&requestAnimationFrame(()=>{const c=a.current;c&&c.scrollHeight>0&&(c.scrollTop=s.current)}),l.current=r},[r]),D.useEffect(()=>{r&&i(!1)},[r]);const u=c=>{s.current=c.currentTarget.scrollTop};return m.jsx(nS,{children:m.jsxs(ud,{open:n&&!r,onOpenChange:i,children:[m.jsxs(u0,{open:r,onOpenChange:o,children:[m.jsx(ld,{asChild:!0,children:m.jsx(l0,{asChild:!0,children:m.jsx($t,{variant:"ghost",size:"icon","data-state":r?"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(JN,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})})}),m.jsx(c0,{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:Oc.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(nr,{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"})]})})},S2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=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:[r.attachments?m.jsx(O6,{}):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(vN,{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(HN,{className:"aui-composer-cancel-icon size-3.5 fill-white dark:fill-black"})})})})]})},I2=()=>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"})})}),k2=()=>{const{config:e}=T.useElements(),t=e.tools??{},r=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:r.Text??FS,Image:r.Image??E2,tools:{by_name:t.components,Fallback:r.ToolFallback??h2},Reasoning:r.Reasoning??KS,ReasoningGroup:r.ReasoningGroup??YS,ToolGroup:r.ToolGroup??v2}}),m.jsx(I2,{})]}),m.jsxs("div",{className:"aui-assistant-message-footer mt-2 ml-2 flex",children:[m.jsx(f0,{}),m.jsx(T2,{})]})]})})},E2=e=>m.jsx("img",{src:e.image}),T2=()=>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(nr,{})}),m.jsx(L.MessagePrimitive.If,{copied:!1,children:m.jsx(Nc,{})})]})}),m.jsx(L.ActionBarPrimitive.Reload,{asChild:!0,children:m.jsx(ct,{tooltip:"Refresh",children:m.jsx(VN,{})})})]}),O2=()=>{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(E6,{}),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(N2,{})})]}),m.jsx(f0,{className:"aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end"})]})})},N2=()=>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(LN,{})})})}),P2=()=>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"})})]})]})}),f0=({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($N,{})})}),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(J_,{})})})]}),m0=()=>{const{config:e,isExpanded:t,setIsExpanded:r}=T.useElements(),o=e.modal?.defaultExpanded??!1;return{expandable:e.modal?.expandable??!1,isExpanded:t,setIsExpanded:r,defaultExpanded:o}},C2={layout:{duration:.25,ease:or}},j2=()=>{const{config:e}=T.useElements(),t=xd(),r=T.useRadius(),o=T.useDensity(),[n,i]=D.useState(e.modal?.defaultOpen??!1),{expandable:a,isExpanded:s,setIsExpanded:l}=m0(),u=e.modal?.title,c=e.modal?.icon,d=e.modal?.position??"bottom-right",f=A2(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:C2,children:m.jsx("div",{className:T.cn("aui-root aui-modal-anchor fixed z-10",f,t.className,r("lg"),n&&"shadow-xl"),children:m.jsx(Zt.AnimatePresence,{mode:"wait",children:n?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",r("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(lu,{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(AN,{strokeWidth:2,className:"size-3.5 rotate-90"}):m.jsx(NN,{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(Eo,{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",r("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(CN,{className:"size-6"})})},"button")})})})})};function A2(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 R2=()=>{const{config:e}=T.useElements(),t=xd(),r=e.sidecar??{},{title:o,dimensions:n}=r,{isExpanded:i,setIsExpanded:a}=m0(),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:n?.default?.width??"400px",height:n?.default?.height??"100vh"},animate:{width:i?n?.expanded?.width??"800px":n?.default?.width??"400px",height:i?n?.expanded?.height??"100%":n?.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(zN,{className:"size-4.5"}):m.jsx(DN,{className:"size-4.5"})})})]}),m.jsx("div",{className:"aui-sidecar-content h-[calc(100%-3.5rem)] overflow-hidden",children:m.jsx($d,{})})]})})},z2=()=>{const{config:e}=T.useElements();switch(e.variant){case"standalone":return m.jsx($d,{});case"sidecar":return m.jsx(R2,{});default:return m.jsx(j2,{})}};exports.useGramElements=T.useElements;exports.Chat=z2;exports.GramElementsProvider=wM;exports.MODELS=Oc;exports.defineFrontendTool=pN;
|