@t-req/core 0.2.2 → 0.2.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.
Files changed (45) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +37 -2
  3. package/dist/config/index.js +6 -6
  4. package/dist/config/index.js.map +5 -5
  5. package/dist/engine/compile-request.d.ts +19 -0
  6. package/dist/engine/compile-request.d.ts.map +1 -0
  7. package/dist/engine/engine-utils.d.ts +13 -0
  8. package/dist/engine/engine-utils.d.ts.map +1 -0
  9. package/dist/engine/engine.d.ts +11 -1
  10. package/dist/engine/engine.d.ts.map +1 -1
  11. package/dist/engine/index.js +6 -4
  12. package/dist/engine/index.js.map +12 -6
  13. package/dist/engine/request-pipeline.d.ts +22 -0
  14. package/dist/engine/request-pipeline.d.ts.map +1 -0
  15. package/dist/index.d.ts +5 -3
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +9 -7
  18. package/dist/index.js.map +16 -10
  19. package/dist/parser.d.ts +17 -1
  20. package/dist/parser.d.ts.map +1 -1
  21. package/dist/plugin/define.d.ts +3 -1
  22. package/dist/plugin/define.d.ts.map +1 -1
  23. package/dist/plugin/index.d.ts +1 -1
  24. package/dist/plugin/index.d.ts.map +1 -1
  25. package/dist/plugin/index.js +4 -4
  26. package/dist/plugin/index.js.map +5 -5
  27. package/dist/plugin/loader.d.ts.map +1 -1
  28. package/dist/plugin/manager.d.ts +29 -1
  29. package/dist/plugin/manager.d.ts.map +1 -1
  30. package/dist/plugin/types.d.ts +84 -0
  31. package/dist/plugin/types.d.ts.map +1 -1
  32. package/dist/protocols/http.d.ts +7 -0
  33. package/dist/protocols/http.d.ts.map +1 -0
  34. package/dist/protocols/index.d.ts +6 -0
  35. package/dist/protocols/index.d.ts.map +1 -0
  36. package/dist/protocols/registry.d.ts +24 -0
  37. package/dist/protocols/registry.d.ts.map +1 -0
  38. package/dist/protocols/sse.d.ts +26 -0
  39. package/dist/protocols/sse.d.ts.map +1 -0
  40. package/dist/protocols/types.d.ts +33 -0
  41. package/dist/protocols/types.d.ts.map +1 -0
  42. package/dist/server-client.d.ts.map +1 -1
  43. package/dist/types.d.ts +92 -1
  44. package/dist/types.d.ts.map +1 -1
  45. package/package.json +1 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026
3
+ Copyright (c) 2026 tensorix labs
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -25,6 +25,7 @@ See the [documentation](https://t-req.io) for the full overview.
25
25
  - **Native fetch Response** - Returns standard `Response` objects, no wrapper
26
26
  - **Cookie management** - Automatic cookie jar with RFC 6265 compliance
27
27
  - **Timeout & cancellation** - Built-in timeout and AbortSignal support
28
+ - **SSE streaming** - Server-Sent Events with `@sse` directive and async iteration
28
29
  - **TypeScript first** - Full type definitions included
29
30
 
30
31
  ## Philosophy
@@ -134,7 +135,7 @@ const client = createClient({
134
135
 
135
136
  // Connect to TUI/server for observability (optional)
136
137
  // Auto-detected from TREQ_SERVER env var when run from TUI
137
- server: 'http://localhost:4096',
138
+ server: 'http://localhost:4097',
138
139
 
139
140
  // Optional auth token for server mode
140
141
  serverToken: process.env.TREQ_TOKEN,
@@ -211,7 +212,7 @@ work without any code changes.
211
212
 
212
213
  ```typescript
213
214
  const client = createClient({
214
- server: 'http://localhost:4096', // or set TREQ_SERVER env var
215
+ server: 'http://localhost:4097', // or set TREQ_SERVER env var
215
216
  variables: { ... }
216
217
  });
217
218
  ```
@@ -389,6 +390,34 @@ const engine = createEngine({
389
390
  await engine.runString('GET https://example.com\n');
390
391
  ```
391
392
 
393
+ ### SSE Streaming
394
+
395
+ Stream Server-Sent Events using the `@sse` directive or `Accept: text/event-stream` header:
396
+
397
+ ```typescript
398
+ import { createEngine } from '@t-req/core';
399
+ import { createFetchTransport } from '@t-req/core/runtime';
400
+
401
+ const engine = createEngine({
402
+ transport: createFetchTransport(fetch),
403
+ });
404
+
405
+ const stream = await engine.streamString(`
406
+ # @sse
407
+ GET https://api.example.com/events
408
+ Authorization: Bearer my-token
409
+ `);
410
+
411
+ for await (const message of stream) {
412
+ console.log(message.event, message.data);
413
+ }
414
+
415
+ // Clean up when done
416
+ stream.close();
417
+ ```
418
+
419
+ The stream returns `SSEMessage` objects with `id`, `event`, `data`, and `retry` fields.
420
+
392
421
  ## Config (JSON/JSONC-first)
393
422
 
394
423
  The CLI/server config system is **JSON/JSONC-first**:
@@ -678,6 +707,12 @@ import type {
678
707
 
679
708
  // Form data building
680
709
  BuildFormDataOptions,
710
+
711
+ // SSE / Streaming
712
+ SSEMessage,
713
+ SSEResponse,
714
+ StreamResponse,
715
+ Protocol,
681
716
  } from '@t-req/core';
682
717
  ```
683
718
 
@@ -1,11 +1,11 @@
1
- import{createRequire as lq}from"node:module";var gq=Object.defineProperty;var mq=($,q)=>{for(var Q in q)gq($,Q,{get:q[Q],enumerable:!0,configurable:!0,set:(G)=>q[Q]=()=>G})};var G$=lq(import.meta.url);var A$={};mq(A$,{void:()=>N3,util:()=>U,unknown:()=>D3,union:()=>C3,undefined:()=>K3,tuple:()=>T3,transformer:()=>c3,symbol:()=>A3,string:()=>Lq,strictObject:()=>v3,setErrorMap:()=>pq,set:()=>h3,record:()=>P3,quotelessJson:()=>cq,promise:()=>l3,preprocess:()=>n3,pipeline:()=>d3,ostring:()=>r3,optional:()=>u3,onumber:()=>i3,oboolean:()=>o3,objectUtil:()=>p$,object:()=>b3,number:()=>Uq,nullable:()=>p3,null:()=>O3,never:()=>j3,nativeEnum:()=>m3,nan:()=>E3,map:()=>f3,makeIssue:()=>R$,literal:()=>Z3,lazy:()=>y3,late:()=>w3,isValid:()=>d,isDirty:()=>f$,isAsync:()=>H$,isAborted:()=>P$,intersection:()=>k3,instanceof:()=>S3,getParsedType:()=>g,getErrorMap:()=>X$,function:()=>x3,enum:()=>g3,effect:()=>c3,discriminatedUnion:()=>I3,defaultErrorMap:()=>c,datetimeRegex:()=>wq,date:()=>U3,custom:()=>Eq,coerce:()=>a3,boolean:()=>Aq,bigint:()=>L3,array:()=>F3,any:()=>R3,addIssueToContext:()=>M,ZodVoid:()=>j$,ZodUnknown:()=>r,ZodUnion:()=>z$,ZodUndefined:()=>B$,ZodType:()=>L,ZodTuple:()=>l,ZodTransformer:()=>P,ZodSymbol:()=>D$,ZodString:()=>C,ZodSet:()=>q$,ZodSchema:()=>L,ZodRecord:()=>N$,ZodReadonly:()=>U$,ZodPromise:()=>Q$,ZodPipeline:()=>v$,ZodParsedType:()=>z,ZodOptional:()=>k,ZodObject:()=>O,ZodNumber:()=>i,ZodNullable:()=>p,ZodNull:()=>_$,ZodNever:()=>m,ZodNativeEnum:()=>S$,ZodNaN:()=>b$,ZodMap:()=>F$,ZodLiteral:()=>w$,ZodLazy:()=>V$,ZodIssueCode:()=>_,ZodIntersection:()=>M$,ZodFunction:()=>Y$,ZodFirstPartyTypeKind:()=>S,ZodError:()=>F,ZodEnum:()=>a,ZodEffects:()=>P,ZodDiscriminatedUnion:()=>h$,ZodDefault:()=>E$,ZodDate:()=>e,ZodCatch:()=>L$,ZodBranded:()=>x$,ZodBoolean:()=>W$,ZodBigInt:()=>o,ZodArray:()=>I,ZodAny:()=>$$,Schema:()=>L,ParseStatus:()=>R,OK:()=>D,NEVER:()=>s3,INVALID:()=>w,EMPTY_PATH:()=>nq,DIRTY:()=>t,BRAND:()=>V3});var U;(function($){$.assertEqual=(X)=>{};function q(X){}$.assertIs=q;function Q(X){throw Error()}$.assertNever=Q,$.arrayToEnum=(X)=>{let J={};for(let H of X)J[H]=H;return J},$.getValidEnumValues=(X)=>{let J=$.objectKeys(X).filter((Y)=>typeof X[X[Y]]!=="number"),H={};for(let Y of J)H[Y]=X[Y];return $.objectValues(H)},$.objectValues=(X)=>{return $.objectKeys(X).map(function(J){return X[J]})},$.objectKeys=typeof Object.keys==="function"?(X)=>Object.keys(X):(X)=>{let J=[];for(let H in X)if(Object.prototype.hasOwnProperty.call(X,H))J.push(H);return J},$.find=(X,J)=>{for(let H of X)if(J(H))return H;return},$.isInteger=typeof Number.isInteger==="function"?(X)=>Number.isInteger(X):(X)=>typeof X==="number"&&Number.isFinite(X)&&Math.floor(X)===X;function G(X,J=" | "){return X.map((H)=>typeof H==="string"?`'${H}'`:H).join(J)}$.joinValues=G,$.jsonStringifyReplacer=(X,J)=>{if(typeof J==="bigint")return J.toString();return J}})(U||(U={}));var p$;(function($){$.mergeShapes=(q,Q)=>{return{...q,...Q}}})(p$||(p$={}));var z=U.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),g=($)=>{switch(typeof $){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN($)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":if(Array.isArray($))return z.array;if($===null)return z.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return z.promise;if(typeof Map<"u"&&$ instanceof Map)return z.map;if(typeof Set<"u"&&$ instanceof Set)return z.set;if(typeof Date<"u"&&$ instanceof Date)return z.date;return z.object;default:return z.unknown}};var _=U.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"]),cq=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class F extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(Q)=>{this.issues=[...this.issues,Q]},this.addIssues=(Q=[])=>{this.issues=[...this.issues,...Q]};let q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,q);else this.__proto__=q;this.name="ZodError",this.issues=$}format($){let q=$||function(X){return X.message},Q={_errors:[]},G=(X)=>{for(let J of X.issues)if(J.code==="invalid_union")J.unionErrors.map(G);else if(J.code==="invalid_return_type")G(J.returnTypeError);else if(J.code==="invalid_arguments")G(J.argumentsError);else if(J.path.length===0)Q._errors.push(q(J));else{let H=Q,Y=0;while(Y<J.path.length){let W=J.path[Y];if(Y!==J.path.length-1)H[W]=H[W]||{_errors:[]};else H[W]=H[W]||{_errors:[]},H[W]._errors.push(q(J));H=H[W],Y++}}};return G(this),Q}static assert($){if(!($ instanceof F))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,U.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(q)=>q.message){let q={},Q=[];for(let G of this.issues)if(G.path.length>0){let X=G.path[0];q[X]=q[X]||[],q[X].push($(G))}else Q.push($(G));return{formErrors:Q,fieldErrors:q}}get formErrors(){return this.flatten()}}F.create=($)=>{return new F($)};var uq=($,q)=>{let Q;switch($.code){case _.invalid_type:if($.received===z.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case _.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,U.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:Q=`Unrecognized key(s) in object: ${U.joinValues($.keys,", ")}`;break;case _.invalid_union:Q="Invalid input";break;case _.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${U.joinValues($.options)}`;break;case _.invalid_enum_value:Q=`Invalid enum value. Expected ${U.joinValues($.options)}, received '${$.received}'`;break;case _.invalid_arguments:Q="Invalid function arguments";break;case _.invalid_return_type:Q="Invalid function return type";break;case _.invalid_date:Q="Invalid date";break;case _.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(Q=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")Q=`${Q} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)Q=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)Q=`Invalid input: must end with "${$.validation.endsWith}"`;else U.assertNever($.validation);else if($.validation!=="regex")Q=`Invalid ${$.validation}`;else Q="Invalid";break;case _.too_small:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else Q="Invalid input";break;case _.too_big:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")Q=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else Q="Invalid input";break;case _.custom:Q="Invalid input";break;case _.invalid_intersection_types:Q="Intersection results could not be merged";break;case _.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case _.not_finite:Q="Number must be finite";break;default:Q=q.defaultError,U.assertNever($)}return{message:Q}},c=uq;var Bq=c;function pq($){Bq=$}function X$(){return Bq}var R$=($)=>{let{data:q,path:Q,errorMaps:G,issueData:X}=$,J=[...Q,...X.path||[]],H={...X,path:J};if(X.message!==void 0)return{...X,path:J,message:X.message};let Y="",W=G.filter((B)=>!!B).slice().reverse();for(let B of W)Y=B(H,{data:q,defaultError:Y}).message;return{...X,path:J,message:Y}},nq=[];function M($,q){let Q=X$(),G=R$({issueData:q,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===c?void 0:c].filter((X)=>!!X)});$.common.issues.push(G)}class R{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,q){let Q=[];for(let G of q){if(G.status==="aborted")return w;if(G.status==="dirty")$.dirty();Q.push(G.value)}return{status:$.value,value:Q}}static async mergeObjectAsync($,q){let Q=[];for(let G of q){let X=await G.key,J=await G.value;Q.push({key:X,value:J})}return R.mergeObjectSync($,Q)}static mergeObjectSync($,q){let Q={};for(let G of q){let{key:X,value:J}=G;if(X.status==="aborted")return w;if(J.status==="aborted")return w;if(X.status==="dirty")$.dirty();if(J.status==="dirty")$.dirty();if(X.value!=="__proto__"&&(typeof J.value<"u"||G.alwaysSet))Q[X.value]=J.value}return{status:$.value,value:Q}}}var w=Object.freeze({status:"aborted"}),t=($)=>({status:"dirty",value:$}),D=($)=>({status:"valid",value:$}),P$=($)=>$.status==="aborted",f$=($)=>$.status==="dirty",d=($)=>$.status==="valid",H$=($)=>typeof Promise<"u"&&$ instanceof Promise;var V;(function($){$.errToObj=(q)=>typeof q==="string"?{message:q}:q||{},$.toString=(q)=>typeof q==="string"?q:q?.message})(V||(V={}));class T{constructor($,q,Q,G){this._cachedPath=[],this.parent=$,this.data=q,this._path=Q,this._key=G}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var _q=($,q)=>{if(d(q))return{success:!0,data:q.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let Q=new F($.common.issues);return this._error=Q,this._error}}}};function E($){if(!$)return{};let{errorMap:q,invalid_type_error:Q,required_error:G,description:X}=$;if(q&&(Q||G))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(q)return{errorMap:q,description:X};return{errorMap:(H,Y)=>{let{message:W}=$;if(H.code==="invalid_enum_value")return{message:W??Y.defaultError};if(typeof Y.data>"u")return{message:W??G??Y.defaultError};if(H.code!=="invalid_type")return{message:Y.defaultError};return{message:W??Q??Y.defaultError}},description:X}}class L{get description(){return this._def.description}_getType($){return g($.data)}_getOrReturnCtx($,q){return q||{common:$.parent.common,data:$.data,parsedType:g($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new R,ctx:{common:$.parent.common,data:$.data,parsedType:g($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let q=this._parse($);if(H$(q))throw Error("Synchronous parse encountered promise.");return q}_parseAsync($){let q=this._parse($);return Promise.resolve(q)}parse($,q){let Q=this.safeParse($,q);if(Q.success)return Q.data;throw Q.error}safeParse($,q){let Q={common:{issues:[],async:q?.async??!1,contextualErrorMap:q?.errorMap},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:g($)},G=this._parseSync({data:$,path:Q.path,parent:Q});return _q(Q,G)}"~validate"($){let q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:g($)};if(!this["~standard"].async)try{let Q=this._parseSync({data:$,path:[],parent:q});return d(Q)?{value:Q.value}:{issues:q.common.issues}}catch(Q){if(Q?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;q.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:q}).then((Q)=>d(Q)?{value:Q.value}:{issues:q.common.issues})}async parseAsync($,q){let Q=await this.safeParseAsync($,q);if(Q.success)return Q.data;throw Q.error}async safeParseAsync($,q){let Q={common:{issues:[],contextualErrorMap:q?.errorMap,async:!0},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:g($)},G=this._parse({data:$,path:Q.path,parent:Q}),X=await(H$(G)?G:Promise.resolve(G));return _q(Q,X)}refine($,q){let Q=(G)=>{if(typeof q==="string"||typeof q>"u")return{message:q};else if(typeof q==="function")return q(G);else return q};return this._refinement((G,X)=>{let J=$(G),H=()=>X.addIssue({code:_.custom,...Q(G)});if(typeof Promise<"u"&&J instanceof Promise)return J.then((Y)=>{if(!Y)return H(),!1;else return!0});if(!J)return H(),!1;else return!0})}refinement($,q){return this._refinement((Q,G)=>{if(!$(Q))return G.addIssue(typeof q==="function"?q(Q,G):q),!1;else return!0})}_refinement($){return new P({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(q)=>this["~validate"](q)}}optional(){return k.create(this,this._def)}nullable(){return p.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return I.create(this)}promise(){return Q$.create(this,this._def)}or($){return z$.create([this,$],this._def)}and($){return M$.create(this,$,this._def)}transform($){return new P({...E(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:$}})}default($){let q=typeof $==="function"?$:()=>$;return new E$({...E(this._def),innerType:this,defaultValue:q,typeName:S.ZodDefault})}brand(){return new x$({typeName:S.ZodBranded,type:this,...E(this._def)})}catch($){let q=typeof $==="function"?$:()=>$;return new L$({...E(this._def),innerType:this,catchValue:q,typeName:S.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return v$.create(this,$)}readonly(){return U$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var dq=/^c[^\s-]{8,}$/i,rq=/^[0-9a-z]+$/,iq=/^[0-9A-HJKMNP-TV-Z]{26}$/i,oq=/^[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}$/i,aq=/^[a-z0-9_-]{21}$/i,sq=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,tq=/^[-+]?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)?)??$/,eq=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$3="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",n$,q3=/^(?:(?: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])$/,Q3=/^(?:(?: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])$/,G3=/^(([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]))$/,X3=/^(([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])$/,H3=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,J3=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mq="((\\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])))",Y3=new RegExp(`^${Mq}$`);function Vq($){let q="[0-5]\\d";if($.precision)q=`${q}\\.\\d{${$.precision}}`;else if($.precision==null)q=`${q}(\\.\\d+)?`;let Q=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${q})${Q}`}function W3($){return new RegExp(`^${Vq($)}$`)}function wq($){let q=`${Mq}T${Vq($)}`,Q=[];if(Q.push($.local?"Z?":"Z"),$.offset)Q.push("([+-]\\d{2}:?\\d{2})");return q=`${q}(${Q.join("|")})`,new RegExp(`^${q}$`)}function B3($,q){if((q==="v4"||!q)&&q3.test($))return!0;if((q==="v6"||!q)&&G3.test($))return!0;return!1}function _3($,q){if(!sq.test($))return!1;try{let[Q]=$.split(".");if(!Q)return!1;let G=Q.replace(/-/g,"+").replace(/_/g,"/").padEnd(Q.length+(4-Q.length%4)%4,"="),X=JSON.parse(atob(G));if(typeof X!=="object"||X===null)return!1;if("typ"in X&&X?.typ!=="JWT")return!1;if(!X.alg)return!1;if(q&&X.alg!==q)return!1;return!0}catch{return!1}}function z3($,q){if((q==="v4"||!q)&&Q3.test($))return!0;if((q==="v6"||!q)&&X3.test($))return!0;return!1}class C extends L{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==z.string){let X=this._getOrReturnCtx($);return M(X,{code:_.invalid_type,expected:z.string,received:X.parsedType}),w}let Q=new R,G=void 0;for(let X of this._def.checks)if(X.kind==="min"){if($.data.length<X.value)G=this._getOrReturnCtx($,G),M(G,{code:_.too_small,minimum:X.value,type:"string",inclusive:!0,exact:!1,message:X.message}),Q.dirty()}else if(X.kind==="max"){if($.data.length>X.value)G=this._getOrReturnCtx($,G),M(G,{code:_.too_big,maximum:X.value,type:"string",inclusive:!0,exact:!1,message:X.message}),Q.dirty()}else if(X.kind==="length"){let J=$.data.length>X.value,H=$.data.length<X.value;if(J||H){if(G=this._getOrReturnCtx($,G),J)M(G,{code:_.too_big,maximum:X.value,type:"string",inclusive:!0,exact:!0,message:X.message});else if(H)M(G,{code:_.too_small,minimum:X.value,type:"string",inclusive:!0,exact:!0,message:X.message});Q.dirty()}}else if(X.kind==="email"){if(!eq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"email",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="emoji"){if(!n$)n$=new RegExp($3,"u");if(!n$.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"emoji",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="uuid"){if(!oq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"uuid",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="nanoid"){if(!aq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"nanoid",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="cuid"){if(!dq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"cuid",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="cuid2"){if(!rq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"cuid2",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="ulid"){if(!iq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"ulid",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="url")try{new URL($.data)}catch{G=this._getOrReturnCtx($,G),M(G,{validation:"url",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="regex"){if(X.regex.lastIndex=0,!X.regex.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"regex",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="trim")$.data=$.data.trim();else if(X.kind==="includes"){if(!$.data.includes(X.value,X.position))G=this._getOrReturnCtx($,G),M(G,{code:_.invalid_string,validation:{includes:X.value,position:X.position},message:X.message}),Q.dirty()}else if(X.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(X.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(X.kind==="startsWith"){if(!$.data.startsWith(X.value))G=this._getOrReturnCtx($,G),M(G,{code:_.invalid_string,validation:{startsWith:X.value},message:X.message}),Q.dirty()}else if(X.kind==="endsWith"){if(!$.data.endsWith(X.value))G=this._getOrReturnCtx($,G),M(G,{code:_.invalid_string,validation:{endsWith:X.value},message:X.message}),Q.dirty()}else if(X.kind==="datetime"){if(!wq(X).test($.data))G=this._getOrReturnCtx($,G),M(G,{code:_.invalid_string,validation:"datetime",message:X.message}),Q.dirty()}else if(X.kind==="date"){if(!Y3.test($.data))G=this._getOrReturnCtx($,G),M(G,{code:_.invalid_string,validation:"date",message:X.message}),Q.dirty()}else if(X.kind==="time"){if(!W3(X).test($.data))G=this._getOrReturnCtx($,G),M(G,{code:_.invalid_string,validation:"time",message:X.message}),Q.dirty()}else if(X.kind==="duration"){if(!tq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"duration",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="ip"){if(!B3($.data,X.version))G=this._getOrReturnCtx($,G),M(G,{validation:"ip",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="jwt"){if(!_3($.data,X.alg))G=this._getOrReturnCtx($,G),M(G,{validation:"jwt",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="cidr"){if(!z3($.data,X.version))G=this._getOrReturnCtx($,G),M(G,{validation:"cidr",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="base64"){if(!H3.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"base64",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="base64url"){if(!J3.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"base64url",code:_.invalid_string,message:X.message}),Q.dirty()}else U.assertNever(X);return{status:Q.value,value:$.data}}_regex($,q,Q){return this.refinement((G)=>$.test(G),{validation:q,code:_.invalid_string,...V.errToObj(Q)})}_addCheck($){return new C({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...V.errToObj($)})}url($){return this._addCheck({kind:"url",...V.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...V.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...V.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...V.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...V.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...V.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...V.errToObj($)})}base64($){return this._addCheck({kind:"base64",...V.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...V.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...V.errToObj($)})}ip($){return this._addCheck({kind:"ip",...V.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...V.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...V.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...V.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...V.errToObj($)})}regex($,q){return this._addCheck({kind:"regex",regex:$,...V.errToObj(q)})}includes($,q){return this._addCheck({kind:"includes",value:$,position:q?.position,...V.errToObj(q?.message)})}startsWith($,q){return this._addCheck({kind:"startsWith",value:$,...V.errToObj(q)})}endsWith($,q){return this._addCheck({kind:"endsWith",value:$,...V.errToObj(q)})}min($,q){return this._addCheck({kind:"min",value:$,...V.errToObj(q)})}max($,q){return this._addCheck({kind:"max",value:$,...V.errToObj(q)})}length($,q){return this._addCheck({kind:"length",value:$,...V.errToObj(q)})}nonempty($){return this.min(1,V.errToObj($))}trim(){return new C({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new C({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new C({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxLength(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}C.create=($)=>{return new C({checks:[],typeName:S.ZodString,coerce:$?.coerce??!1,...E($)})};function M3($,q){let Q=($.toString().split(".")[1]||"").length,G=(q.toString().split(".")[1]||"").length,X=Q>G?Q:G,J=Number.parseInt($.toFixed(X).replace(".","")),H=Number.parseInt(q.toFixed(X).replace(".",""));return J%H/10**X}class i extends L{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==z.number){let X=this._getOrReturnCtx($);return M(X,{code:_.invalid_type,expected:z.number,received:X.parsedType}),w}let Q=void 0,G=new R;for(let X of this._def.checks)if(X.kind==="int"){if(!U.isInteger($.data))Q=this._getOrReturnCtx($,Q),M(Q,{code:_.invalid_type,expected:"integer",received:"float",message:X.message}),G.dirty()}else if(X.kind==="min"){if(X.inclusive?$.data<X.value:$.data<=X.value)Q=this._getOrReturnCtx($,Q),M(Q,{code:_.too_small,minimum:X.value,type:"number",inclusive:X.inclusive,exact:!1,message:X.message}),G.dirty()}else if(X.kind==="max"){if(X.inclusive?$.data>X.value:$.data>=X.value)Q=this._getOrReturnCtx($,Q),M(Q,{code:_.too_big,maximum:X.value,type:"number",inclusive:X.inclusive,exact:!1,message:X.message}),G.dirty()}else if(X.kind==="multipleOf"){if(M3($.data,X.value)!==0)Q=this._getOrReturnCtx($,Q),M(Q,{code:_.not_multiple_of,multipleOf:X.value,message:X.message}),G.dirty()}else if(X.kind==="finite"){if(!Number.isFinite($.data))Q=this._getOrReturnCtx($,Q),M(Q,{code:_.not_finite,message:X.message}),G.dirty()}else U.assertNever(X);return{status:G.value,value:$.data}}gte($,q){return this.setLimit("min",$,!0,V.toString(q))}gt($,q){return this.setLimit("min",$,!1,V.toString(q))}lte($,q){return this.setLimit("max",$,!0,V.toString(q))}lt($,q){return this.setLimit("max",$,!1,V.toString(q))}setLimit($,q,Q,G){return new i({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:Q,message:V.toString(G)}]})}_addCheck($){return new i({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:V.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:V.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:V.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:V.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:V.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:V.toString(q)})}finite($){return this._addCheck({kind:"finite",message:V.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:V.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:V.toString($)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&U.isInteger($.value))}get isFinite(){let $=null,q=null;for(let Q of this._def.checks)if(Q.kind==="finite"||Q.kind==="int"||Q.kind==="multipleOf")return!0;else if(Q.kind==="min"){if(q===null||Q.value>q)q=Q.value}else if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return Number.isFinite(q)&&Number.isFinite($)}}i.create=($)=>{return new i({checks:[],typeName:S.ZodNumber,coerce:$?.coerce||!1,...E($)})};class o extends L{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==z.bigint)return this._getInvalidInput($);let Q=void 0,G=new R;for(let X of this._def.checks)if(X.kind==="min"){if(X.inclusive?$.data<X.value:$.data<=X.value)Q=this._getOrReturnCtx($,Q),M(Q,{code:_.too_small,type:"bigint",minimum:X.value,inclusive:X.inclusive,message:X.message}),G.dirty()}else if(X.kind==="max"){if(X.inclusive?$.data>X.value:$.data>=X.value)Q=this._getOrReturnCtx($,Q),M(Q,{code:_.too_big,type:"bigint",maximum:X.value,inclusive:X.inclusive,message:X.message}),G.dirty()}else if(X.kind==="multipleOf"){if($.data%X.value!==BigInt(0))Q=this._getOrReturnCtx($,Q),M(Q,{code:_.not_multiple_of,multipleOf:X.value,message:X.message}),G.dirty()}else U.assertNever(X);return{status:G.value,value:$.data}}_getInvalidInput($){let q=this._getOrReturnCtx($);return M(q,{code:_.invalid_type,expected:z.bigint,received:q.parsedType}),w}gte($,q){return this.setLimit("min",$,!0,V.toString(q))}gt($,q){return this.setLimit("min",$,!1,V.toString(q))}lte($,q){return this.setLimit("max",$,!0,V.toString(q))}lt($,q){return this.setLimit("max",$,!1,V.toString(q))}setLimit($,q,Q,G){return new o({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:Q,message:V.toString(G)}]})}_addCheck($){return new o({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:V.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:V.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:V.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:V.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:V.toString(q)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}o.create=($)=>{return new o({checks:[],typeName:S.ZodBigInt,coerce:$?.coerce??!1,...E($)})};class W$ extends L{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==z.boolean){let Q=this._getOrReturnCtx($);return M(Q,{code:_.invalid_type,expected:z.boolean,received:Q.parsedType}),w}return D($.data)}}W$.create=($)=>{return new W$({typeName:S.ZodBoolean,coerce:$?.coerce||!1,...E($)})};class e extends L{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==z.date){let X=this._getOrReturnCtx($);return M(X,{code:_.invalid_type,expected:z.date,received:X.parsedType}),w}if(Number.isNaN($.data.getTime())){let X=this._getOrReturnCtx($);return M(X,{code:_.invalid_date}),w}let Q=new R,G=void 0;for(let X of this._def.checks)if(X.kind==="min"){if($.data.getTime()<X.value)G=this._getOrReturnCtx($,G),M(G,{code:_.too_small,message:X.message,inclusive:!0,exact:!1,minimum:X.value,type:"date"}),Q.dirty()}else if(X.kind==="max"){if($.data.getTime()>X.value)G=this._getOrReturnCtx($,G),M(G,{code:_.too_big,message:X.message,inclusive:!0,exact:!1,maximum:X.value,type:"date"}),Q.dirty()}else U.assertNever(X);return{status:Q.value,value:new Date($.data.getTime())}}_addCheck($){return new e({...this._def,checks:[...this._def.checks,$]})}min($,q){return this._addCheck({kind:"min",value:$.getTime(),message:V.toString(q)})}max($,q){return this._addCheck({kind:"max",value:$.getTime(),message:V.toString(q)})}get minDate(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $!=null?new Date($):null}}e.create=($)=>{return new e({checks:[],coerce:$?.coerce||!1,typeName:S.ZodDate,...E($)})};class D$ extends L{_parse($){if(this._getType($)!==z.symbol){let Q=this._getOrReturnCtx($);return M(Q,{code:_.invalid_type,expected:z.symbol,received:Q.parsedType}),w}return D($.data)}}D$.create=($)=>{return new D$({typeName:S.ZodSymbol,...E($)})};class B$ extends L{_parse($){if(this._getType($)!==z.undefined){let Q=this._getOrReturnCtx($);return M(Q,{code:_.invalid_type,expected:z.undefined,received:Q.parsedType}),w}return D($.data)}}B$.create=($)=>{return new B$({typeName:S.ZodUndefined,...E($)})};class _$ extends L{_parse($){if(this._getType($)!==z.null){let Q=this._getOrReturnCtx($);return M(Q,{code:_.invalid_type,expected:z.null,received:Q.parsedType}),w}return D($.data)}}_$.create=($)=>{return new _$({typeName:S.ZodNull,...E($)})};class $$ extends L{constructor(){super(...arguments);this._any=!0}_parse($){return D($.data)}}$$.create=($)=>{return new $$({typeName:S.ZodAny,...E($)})};class r extends L{constructor(){super(...arguments);this._unknown=!0}_parse($){return D($.data)}}r.create=($)=>{return new r({typeName:S.ZodUnknown,...E($)})};class m extends L{_parse($){let q=this._getOrReturnCtx($);return M(q,{code:_.invalid_type,expected:z.never,received:q.parsedType}),w}}m.create=($)=>{return new m({typeName:S.ZodNever,...E($)})};class j$ extends L{_parse($){if(this._getType($)!==z.undefined){let Q=this._getOrReturnCtx($);return M(Q,{code:_.invalid_type,expected:z.void,received:Q.parsedType}),w}return D($.data)}}j$.create=($)=>{return new j$({typeName:S.ZodVoid,...E($)})};class I extends L{_parse($){let{ctx:q,status:Q}=this._processInputParams($),G=this._def;if(q.parsedType!==z.array)return M(q,{code:_.invalid_type,expected:z.array,received:q.parsedType}),w;if(G.exactLength!==null){let J=q.data.length>G.exactLength.value,H=q.data.length<G.exactLength.value;if(J||H)M(q,{code:J?_.too_big:_.too_small,minimum:H?G.exactLength.value:void 0,maximum:J?G.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:G.exactLength.message}),Q.dirty()}if(G.minLength!==null){if(q.data.length<G.minLength.value)M(q,{code:_.too_small,minimum:G.minLength.value,type:"array",inclusive:!0,exact:!1,message:G.minLength.message}),Q.dirty()}if(G.maxLength!==null){if(q.data.length>G.maxLength.value)M(q,{code:_.too_big,maximum:G.maxLength.value,type:"array",inclusive:!0,exact:!1,message:G.maxLength.message}),Q.dirty()}if(q.common.async)return Promise.all([...q.data].map((J,H)=>{return G.type._parseAsync(new T(q,J,q.path,H))})).then((J)=>{return R.mergeArray(Q,J)});let X=[...q.data].map((J,H)=>{return G.type._parseSync(new T(q,J,q.path,H))});return R.mergeArray(Q,X)}get element(){return this._def.type}min($,q){return new I({...this._def,minLength:{value:$,message:V.toString(q)}})}max($,q){return new I({...this._def,maxLength:{value:$,message:V.toString(q)}})}length($,q){return new I({...this._def,exactLength:{value:$,message:V.toString(q)}})}nonempty($){return this.min(1,$)}}I.create=($,q)=>{return new I({type:$,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...E(q)})};function J$($){if($ instanceof O){let q={};for(let Q in $.shape){let G=$.shape[Q];q[Q]=k.create(J$(G))}return new O({...$._def,shape:()=>q})}else if($ instanceof I)return new I({...$._def,type:J$($.element)});else if($ instanceof k)return k.create(J$($.unwrap()));else if($ instanceof p)return p.create(J$($.unwrap()));else if($ instanceof l)return l.create($.items.map((q)=>J$(q)));else return $}class O extends L{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),q=U.objectKeys($);return this._cached={shape:$,keys:q},this._cached}_parse($){if(this._getType($)!==z.object){let W=this._getOrReturnCtx($);return M(W,{code:_.invalid_type,expected:z.object,received:W.parsedType}),w}let{status:Q,ctx:G}=this._processInputParams($),{shape:X,keys:J}=this._getCached(),H=[];if(!(this._def.catchall instanceof m&&this._def.unknownKeys==="strip")){for(let W in G.data)if(!J.includes(W))H.push(W)}let Y=[];for(let W of J){let B=X[W],A=G.data[W];Y.push({key:{status:"valid",value:W},value:B._parse(new T(G,A,G.path,W)),alwaysSet:W in G.data})}if(this._def.catchall instanceof m){let W=this._def.unknownKeys;if(W==="passthrough")for(let B of H)Y.push({key:{status:"valid",value:B},value:{status:"valid",value:G.data[B]}});else if(W==="strict"){if(H.length>0)M(G,{code:_.unrecognized_keys,keys:H}),Q.dirty()}else if(W==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let W=this._def.catchall;for(let B of H){let A=G.data[B];Y.push({key:{status:"valid",value:B},value:W._parse(new T(G,A,G.path,B)),alwaysSet:B in G.data})}}if(G.common.async)return Promise.resolve().then(async()=>{let W=[];for(let B of Y){let A=await B.key,K=await B.value;W.push({key:A,value:K,alwaysSet:B.alwaysSet})}return W}).then((W)=>{return R.mergeObjectSync(Q,W)});else return R.mergeObjectSync(Q,Y)}get shape(){return this._def.shape()}strict($){return V.errToObj,new O({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(q,Q)=>{let G=this._def.errorMap?.(q,Q).message??Q.defaultError;if(q.code==="unrecognized_keys")return{message:V.errToObj($).message??G};return{message:G}}}:{}})}strip(){return new O({...this._def,unknownKeys:"strip"})}passthrough(){return new O({...this._def,unknownKeys:"passthrough"})}extend($){return new O({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new O({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:S.ZodObject})}setKey($,q){return this.augment({[$]:q})}catchall($){return new O({...this._def,catchall:$})}pick($){let q={};for(let Q of U.objectKeys($))if($[Q]&&this.shape[Q])q[Q]=this.shape[Q];return new O({...this._def,shape:()=>q})}omit($){let q={};for(let Q of U.objectKeys(this.shape))if(!$[Q])q[Q]=this.shape[Q];return new O({...this._def,shape:()=>q})}deepPartial(){return J$(this)}partial($){let q={};for(let Q of U.objectKeys(this.shape)){let G=this.shape[Q];if($&&!$[Q])q[Q]=G;else q[Q]=G.optional()}return new O({...this._def,shape:()=>q})}required($){let q={};for(let Q of U.objectKeys(this.shape))if($&&!$[Q])q[Q]=this.shape[Q];else{let X=this.shape[Q];while(X instanceof k)X=X._def.innerType;q[Q]=X}return new O({...this._def,shape:()=>q})}keyof(){return Sq(U.objectKeys(this.shape))}}O.create=($,q)=>{return new O({shape:()=>$,unknownKeys:"strip",catchall:m.create(),typeName:S.ZodObject,...E(q)})};O.strictCreate=($,q)=>{return new O({shape:()=>$,unknownKeys:"strict",catchall:m.create(),typeName:S.ZodObject,...E(q)})};O.lazycreate=($,q)=>{return new O({shape:$,unknownKeys:"strip",catchall:m.create(),typeName:S.ZodObject,...E(q)})};class z$ extends L{_parse($){let{ctx:q}=this._processInputParams($),Q=this._def.options;function G(X){for(let H of X)if(H.result.status==="valid")return H.result;for(let H of X)if(H.result.status==="dirty")return q.common.issues.push(...H.ctx.common.issues),H.result;let J=X.map((H)=>new F(H.ctx.common.issues));return M(q,{code:_.invalid_union,unionErrors:J}),w}if(q.common.async)return Promise.all(Q.map(async(X)=>{let J={...q,common:{...q.common,issues:[]},parent:null};return{result:await X._parseAsync({data:q.data,path:q.path,parent:J}),ctx:J}})).then(G);else{let X=void 0,J=[];for(let Y of Q){let W={...q,common:{...q.common,issues:[]},parent:null},B=Y._parseSync({data:q.data,path:q.path,parent:W});if(B.status==="valid")return B;else if(B.status==="dirty"&&!X)X={result:B,ctx:W};if(W.common.issues.length)J.push(W.common.issues)}if(X)return q.common.issues.push(...X.ctx.common.issues),X.result;let H=J.map((Y)=>new F(Y));return M(q,{code:_.invalid_union,unionErrors:H}),w}}get options(){return this._def.options}}z$.create=($,q)=>{return new z$({options:$,typeName:S.ZodUnion,...E(q)})};var u=($)=>{if($ instanceof V$)return u($.schema);else if($ instanceof P)return u($.innerType());else if($ instanceof w$)return[$.value];else if($ instanceof a)return $.options;else if($ instanceof S$)return U.objectValues($.enum);else if($ instanceof E$)return u($._def.innerType);else if($ instanceof B$)return[void 0];else if($ instanceof _$)return[null];else if($ instanceof k)return[void 0,...u($.unwrap())];else if($ instanceof p)return[null,...u($.unwrap())];else if($ instanceof x$)return u($.unwrap());else if($ instanceof U$)return u($.unwrap());else if($ instanceof L$)return u($._def.innerType);else return[]};class h$ extends L{_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==z.object)return M(q,{code:_.invalid_type,expected:z.object,received:q.parsedType}),w;let Q=this.discriminator,G=q.data[Q],X=this.optionsMap.get(G);if(!X)return M(q,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),w;if(q.common.async)return X._parseAsync({data:q.data,path:q.path,parent:q});else return X._parseSync({data:q.data,path:q.path,parent:q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,q,Q){let G=new Map;for(let X of q){let J=u(X.shape[$]);if(!J.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let H of J){if(G.has(H))throw Error(`Discriminator property ${String($)} has duplicate value ${String(H)}`);G.set(H,X)}}return new h$({typeName:S.ZodDiscriminatedUnion,discriminator:$,options:q,optionsMap:G,...E(Q)})}}function d$($,q){let Q=g($),G=g(q);if($===q)return{valid:!0,data:$};else if(Q===z.object&&G===z.object){let X=U.objectKeys(q),J=U.objectKeys($).filter((Y)=>X.indexOf(Y)!==-1),H={...$,...q};for(let Y of J){let W=d$($[Y],q[Y]);if(!W.valid)return{valid:!1};H[Y]=W.data}return{valid:!0,data:H}}else if(Q===z.array&&G===z.array){if($.length!==q.length)return{valid:!1};let X=[];for(let J=0;J<$.length;J++){let H=$[J],Y=q[J],W=d$(H,Y);if(!W.valid)return{valid:!1};X.push(W.data)}return{valid:!0,data:X}}else if(Q===z.date&&G===z.date&&+$===+q)return{valid:!0,data:$};else return{valid:!1}}class M$ extends L{_parse($){let{status:q,ctx:Q}=this._processInputParams($),G=(X,J)=>{if(P$(X)||P$(J))return w;let H=d$(X.value,J.value);if(!H.valid)return M(Q,{code:_.invalid_intersection_types}),w;if(f$(X)||f$(J))q.dirty();return{status:q.value,value:H.data}};if(Q.common.async)return Promise.all([this._def.left._parseAsync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseAsync({data:Q.data,path:Q.path,parent:Q})]).then(([X,J])=>G(X,J));else return G(this._def.left._parseSync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseSync({data:Q.data,path:Q.path,parent:Q}))}}M$.create=($,q,Q)=>{return new M$({left:$,right:q,typeName:S.ZodIntersection,...E(Q)})};class l extends L{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.array)return M(Q,{code:_.invalid_type,expected:z.array,received:Q.parsedType}),w;if(Q.data.length<this._def.items.length)return M(Q,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),w;if(!this._def.rest&&Q.data.length>this._def.items.length)M(Q,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),q.dirty();let X=[...Q.data].map((J,H)=>{let Y=this._def.items[H]||this._def.rest;if(!Y)return null;return Y._parse(new T(Q,J,Q.path,H))}).filter((J)=>!!J);if(Q.common.async)return Promise.all(X).then((J)=>{return R.mergeArray(q,J)});else return R.mergeArray(q,X)}get items(){return this._def.items}rest($){return new l({...this._def,rest:$})}}l.create=($,q)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new l({items:$,typeName:S.ZodTuple,rest:null,...E(q)})};class N$ extends L{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.object)return M(Q,{code:_.invalid_type,expected:z.object,received:Q.parsedType}),w;let G=[],X=this._def.keyType,J=this._def.valueType;for(let H in Q.data)G.push({key:X._parse(new T(Q,H,Q.path,H)),value:J._parse(new T(Q,Q.data[H],Q.path,H)),alwaysSet:H in Q.data});if(Q.common.async)return R.mergeObjectAsync(q,G);else return R.mergeObjectSync(q,G)}get element(){return this._def.valueType}static create($,q,Q){if(q instanceof L)return new N$({keyType:$,valueType:q,typeName:S.ZodRecord,...E(Q)});return new N$({keyType:C.create(),valueType:$,typeName:S.ZodRecord,...E(q)})}}class F$ extends L{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.map)return M(Q,{code:_.invalid_type,expected:z.map,received:Q.parsedType}),w;let G=this._def.keyType,X=this._def.valueType,J=[...Q.data.entries()].map(([H,Y],W)=>{return{key:G._parse(new T(Q,H,Q.path,[W,"key"])),value:X._parse(new T(Q,Y,Q.path,[W,"value"]))}});if(Q.common.async){let H=new Map;return Promise.resolve().then(async()=>{for(let Y of J){let W=await Y.key,B=await Y.value;if(W.status==="aborted"||B.status==="aborted")return w;if(W.status==="dirty"||B.status==="dirty")q.dirty();H.set(W.value,B.value)}return{status:q.value,value:H}})}else{let H=new Map;for(let Y of J){let{key:W,value:B}=Y;if(W.status==="aborted"||B.status==="aborted")return w;if(W.status==="dirty"||B.status==="dirty")q.dirty();H.set(W.value,B.value)}return{status:q.value,value:H}}}}F$.create=($,q,Q)=>{return new F$({valueType:q,keyType:$,typeName:S.ZodMap,...E(Q)})};class q$ extends L{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.set)return M(Q,{code:_.invalid_type,expected:z.set,received:Q.parsedType}),w;let G=this._def;if(G.minSize!==null){if(Q.data.size<G.minSize.value)M(Q,{code:_.too_small,minimum:G.minSize.value,type:"set",inclusive:!0,exact:!1,message:G.minSize.message}),q.dirty()}if(G.maxSize!==null){if(Q.data.size>G.maxSize.value)M(Q,{code:_.too_big,maximum:G.maxSize.value,type:"set",inclusive:!0,exact:!1,message:G.maxSize.message}),q.dirty()}let X=this._def.valueType;function J(Y){let W=new Set;for(let B of Y){if(B.status==="aborted")return w;if(B.status==="dirty")q.dirty();W.add(B.value)}return{status:q.value,value:W}}let H=[...Q.data.values()].map((Y,W)=>X._parse(new T(Q,Y,Q.path,W)));if(Q.common.async)return Promise.all(H).then((Y)=>J(Y));else return J(H)}min($,q){return new q$({...this._def,minSize:{value:$,message:V.toString(q)}})}max($,q){return new q$({...this._def,maxSize:{value:$,message:V.toString(q)}})}size($,q){return this.min($,q).max($,q)}nonempty($){return this.min(1,$)}}q$.create=($,q)=>{return new q$({valueType:$,minSize:null,maxSize:null,typeName:S.ZodSet,...E(q)})};class Y$ extends L{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==z.function)return M(q,{code:_.invalid_type,expected:z.function,received:q.parsedType}),w;function Q(H,Y){return R$({data:H,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,X$(),c].filter((W)=>!!W),issueData:{code:_.invalid_arguments,argumentsError:Y}})}function G(H,Y){return R$({data:H,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,X$(),c].filter((W)=>!!W),issueData:{code:_.invalid_return_type,returnTypeError:Y}})}let X={errorMap:q.common.contextualErrorMap},J=q.data;if(this._def.returns instanceof Q$){let H=this;return D(async function(...Y){let W=new F([]),B=await H._def.args.parseAsync(Y,X).catch((N)=>{throw W.addIssue(Q(Y,N)),W}),A=await Reflect.apply(J,this,B);return await H._def.returns._def.type.parseAsync(A,X).catch((N)=>{throw W.addIssue(G(A,N)),W})})}else{let H=this;return D(function(...Y){let W=H._def.args.safeParse(Y,X);if(!W.success)throw new F([Q(Y,W.error)]);let B=Reflect.apply(J,this,W.data),A=H._def.returns.safeParse(B,X);if(!A.success)throw new F([G(B,A.error)]);return A.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new Y$({...this._def,args:l.create($).rest(r.create())})}returns($){return new Y$({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,q,Q){return new Y$({args:$?$:l.create([]).rest(r.create()),returns:q||r.create(),typeName:S.ZodFunction,...E(Q)})}}class V$ extends L{get schema(){return this._def.getter()}_parse($){let{ctx:q}=this._processInputParams($);return this._def.getter()._parse({data:q.data,path:q.path,parent:q})}}V$.create=($,q)=>{return new V$({getter:$,typeName:S.ZodLazy,...E(q)})};class w$ extends L{_parse($){if($.data!==this._def.value){let q=this._getOrReturnCtx($);return M(q,{received:q.data,code:_.invalid_literal,expected:this._def.value}),w}return{status:"valid",value:$.data}}get value(){return this._def.value}}w$.create=($,q)=>{return new w$({value:$,typeName:S.ZodLiteral,...E(q)})};function Sq($,q){return new a({values:$,typeName:S.ZodEnum,...E(q)})}class a extends L{_parse($){if(typeof $.data!=="string"){let q=this._getOrReturnCtx($),Q=this._def.values;return M(q,{expected:U.joinValues(Q),received:q.parsedType,code:_.invalid_type}),w}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let q=this._getOrReturnCtx($),Q=this._def.values;return M(q,{received:q.data,code:_.invalid_enum_value,options:Q}),w}return D($.data)}get options(){return this._def.values}get enum(){let $={};for(let q of this._def.values)$[q]=q;return $}get Values(){let $={};for(let q of this._def.values)$[q]=q;return $}get Enum(){let $={};for(let q of this._def.values)$[q]=q;return $}extract($,q=this._def){return a.create($,{...this._def,...q})}exclude($,q=this._def){return a.create(this.options.filter((Q)=>!$.includes(Q)),{...this._def,...q})}}a.create=Sq;class S$ extends L{_parse($){let q=U.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==z.string&&Q.parsedType!==z.number){let G=U.objectValues(q);return M(Q,{expected:U.joinValues(G),received:Q.parsedType,code:_.invalid_type}),w}if(!this._cache)this._cache=new Set(U.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let G=U.objectValues(q);return M(Q,{received:Q.data,code:_.invalid_enum_value,options:G}),w}return D($.data)}get enum(){return this._def.values}}S$.create=($,q)=>{return new S$({values:$,typeName:S.ZodNativeEnum,...E(q)})};class Q$ extends L{unwrap(){return this._def.type}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==z.promise&&q.common.async===!1)return M(q,{code:_.invalid_type,expected:z.promise,received:q.parsedType}),w;let Q=q.parsedType===z.promise?q.data:Promise.resolve(q.data);return D(Q.then((G)=>{return this._def.type.parseAsync(G,{path:q.path,errorMap:q.common.contextualErrorMap})}))}}Q$.create=($,q)=>{return new Q$({type:$,typeName:S.ZodPromise,...E(q)})};class P extends L{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:q,ctx:Q}=this._processInputParams($),G=this._def.effect||null,X={addIssue:(J)=>{if(M(Q,J),J.fatal)q.abort();else q.dirty()},get path(){return Q.path}};if(X.addIssue=X.addIssue.bind(X),G.type==="preprocess"){let J=G.transform(Q.data,X);if(Q.common.async)return Promise.resolve(J).then(async(H)=>{if(q.value==="aborted")return w;let Y=await this._def.schema._parseAsync({data:H,path:Q.path,parent:Q});if(Y.status==="aborted")return w;if(Y.status==="dirty")return t(Y.value);if(q.value==="dirty")return t(Y.value);return Y});else{if(q.value==="aborted")return w;let H=this._def.schema._parseSync({data:J,path:Q.path,parent:Q});if(H.status==="aborted")return w;if(H.status==="dirty")return t(H.value);if(q.value==="dirty")return t(H.value);return H}}if(G.type==="refinement"){let J=(H)=>{let Y=G.refinement(H,X);if(Q.common.async)return Promise.resolve(Y);if(Y instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return H};if(Q.common.async===!1){let H=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(H.status==="aborted")return w;if(H.status==="dirty")q.dirty();return J(H.value),{status:q.value,value:H.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((H)=>{if(H.status==="aborted")return w;if(H.status==="dirty")q.dirty();return J(H.value).then(()=>{return{status:q.value,value:H.value}})})}if(G.type==="transform")if(Q.common.async===!1){let J=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!d(J))return w;let H=G.transform(J.value,X);if(H instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:q.value,value:H}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((J)=>{if(!d(J))return w;return Promise.resolve(G.transform(J.value,X)).then((H)=>({status:q.value,value:H}))});U.assertNever(G)}}P.create=($,q,Q)=>{return new P({schema:$,typeName:S.ZodEffects,effect:q,...E(Q)})};P.createWithPreprocess=($,q,Q)=>{return new P({schema:q,effect:{type:"preprocess",transform:$},typeName:S.ZodEffects,...E(Q)})};class k extends L{_parse($){if(this._getType($)===z.undefined)return D(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}k.create=($,q)=>{return new k({innerType:$,typeName:S.ZodOptional,...E(q)})};class p extends L{_parse($){if(this._getType($)===z.null)return D(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}p.create=($,q)=>{return new p({innerType:$,typeName:S.ZodNullable,...E(q)})};class E$ extends L{_parse($){let{ctx:q}=this._processInputParams($),Q=q.data;if(q.parsedType===z.undefined)Q=this._def.defaultValue();return this._def.innerType._parse({data:Q,path:q.path,parent:q})}removeDefault(){return this._def.innerType}}E$.create=($,q)=>{return new E$({innerType:$,typeName:S.ZodDefault,defaultValue:typeof q.default==="function"?q.default:()=>q.default,...E(q)})};class L$ extends L{_parse($){let{ctx:q}=this._processInputParams($),Q={...q,common:{...q.common,issues:[]}},G=this._def.innerType._parse({data:Q.data,path:Q.path,parent:{...Q}});if(H$(G))return G.then((X)=>{return{status:"valid",value:X.status==="valid"?X.value:this._def.catchValue({get error(){return new F(Q.common.issues)},input:Q.data})}});else return{status:"valid",value:G.status==="valid"?G.value:this._def.catchValue({get error(){return new F(Q.common.issues)},input:Q.data})}}removeCatch(){return this._def.innerType}}L$.create=($,q)=>{return new L$({innerType:$,typeName:S.ZodCatch,catchValue:typeof q.catch==="function"?q.catch:()=>q.catch,...E(q)})};class b$ extends L{_parse($){if(this._getType($)!==z.nan){let Q=this._getOrReturnCtx($);return M(Q,{code:_.invalid_type,expected:z.nan,received:Q.parsedType}),w}return{status:"valid",value:$.data}}}b$.create=($)=>{return new b$({typeName:S.ZodNaN,...E($)})};var V3=Symbol("zod_brand");class x$ extends L{_parse($){let{ctx:q}=this._processInputParams($),Q=q.data;return this._def.type._parse({data:Q,path:q.path,parent:q})}unwrap(){return this._def.type}}class v$ extends L{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.common.async)return(async()=>{let X=await this._def.in._parseAsync({data:Q.data,path:Q.path,parent:Q});if(X.status==="aborted")return w;if(X.status==="dirty")return q.dirty(),t(X.value);else return this._def.out._parseAsync({data:X.value,path:Q.path,parent:Q})})();else{let G=this._def.in._parseSync({data:Q.data,path:Q.path,parent:Q});if(G.status==="aborted")return w;if(G.status==="dirty")return q.dirty(),{status:"dirty",value:G.value};else return this._def.out._parseSync({data:G.value,path:Q.path,parent:Q})}}static create($,q){return new v$({in:$,out:q,typeName:S.ZodPipeline})}}class U$ extends L{_parse($){let q=this._def.innerType._parse($),Q=(G)=>{if(d(G))G.value=Object.freeze(G.value);return G};return H$(q)?q.then((G)=>Q(G)):Q(q)}unwrap(){return this._def.innerType}}U$.create=($,q)=>{return new U$({innerType:$,typeName:S.ZodReadonly,...E(q)})};function zq($,q){let Q=typeof $==="function"?$(q):typeof $==="string"?{message:$}:$;return typeof Q==="string"?{message:Q}:Q}function Eq($,q={},Q){if($)return $$.create().superRefine((G,X)=>{let J=$(G);if(J instanceof Promise)return J.then((H)=>{if(!H){let Y=zq(q,G),W=Y.fatal??Q??!0;X.addIssue({code:"custom",...Y,fatal:W})}});if(!J){let H=zq(q,G),Y=H.fatal??Q??!0;X.addIssue({code:"custom",...H,fatal:Y})}return});return $$.create()}var w3={object:O.lazycreate},S;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(S||(S={}));var S3=($,q={message:`Input not instance of ${$.name}`})=>Eq((Q)=>Q instanceof $,q),Lq=C.create,Uq=i.create,E3=b$.create,L3=o.create,Aq=W$.create,U3=e.create,A3=D$.create,K3=B$.create,O3=_$.create,R3=$$.create,D3=r.create,j3=m.create,N3=j$.create,F3=I.create,b3=O.create,v3=O.strictCreate,C3=z$.create,I3=h$.create,k3=M$.create,T3=l.create,P3=N$.create,f3=F$.create,h3=q$.create,x3=Y$.create,y3=V$.create,Z3=w$.create,g3=a.create,m3=S$.create,l3=Q$.create,c3=P.create,u3=k.create,p3=p.create,n3=P.createWithPreprocess,d3=v$.create,r3=()=>Lq().optional(),i3=()=>Uq().optional(),o3=()=>Aq().optional(),a3={string:($)=>C.create({...$,coerce:!0}),number:($)=>i.create({...$,coerce:!0}),boolean:($)=>W$.create({...$,coerce:!0}),bigint:($)=>o.create({...$,coerce:!0}),date:($)=>e.create({...$,coerce:!0})};var s3=w;function t3($){if(!$.name)throw Error("Plugin must have a name");if(typeof $.name!=="string"||$.name.trim()==="")throw Error("Plugin name must be a non-empty string");if($.instanceId!==void 0&&typeof $.instanceId!=="string")throw Error("Plugin instanceId must be a string");if($.version!==void 0&&typeof $.version!=="string")throw Error("Plugin version must be a string");if($.permissions!==void 0){if(!Array.isArray($.permissions))throw Error("Plugin permissions must be an array");let q=["secrets","network","filesystem","env","subprocess","enterprise"];for(let Q of $.permissions)if(!q.includes(Q))throw Error(`Invalid permission: ${Q}. Valid permissions are: ${q.join(", ")}`)}if($.resolvers!==void 0){if(typeof $.resolvers!=="object"||$.resolvers===null)throw Error("Plugin resolvers must be an object");for(let[q,Q]of Object.entries($.resolvers)){if(!q.startsWith("$"))throw Error(`Resolver name "${q}" must start with $ (e.g., "$${q}")`);if(typeof Q!=="function")throw Error(`Resolver "${q}" must be a function`)}}if($.hooks!==void 0){if(typeof $.hooks!=="object"||$.hooks===null)throw Error("Plugin hooks must be an object");let q=["parse.after","request.before","request.compiled","request.after","response.after","error"];for(let[Q,G]of Object.entries($.hooks)){if(!q.includes(Q))throw Error(`Invalid hook: "${Q}". Valid hooks are: ${q.join(", ")}`);if(typeof G!=="function")throw Error(`Hook "${Q}" must be a function`)}}if($.commands!==void 0){if(typeof $.commands!=="object"||$.commands===null)throw Error("Plugin commands must be an object");for(let[q,Q]of Object.entries($.commands))if(typeof Q!=="function")throw Error(`Command "${q}" must be a function`)}if($.middleware!==void 0){if(!Array.isArray($.middleware))throw Error("Plugin middleware must be an array");for(let q=0;q<$.middleware.length;q++)if(typeof $.middleware[q]!=="function")throw Error(`Middleware at index ${q} must be a function`)}if($.tools!==void 0){if(typeof $.tools!=="object"||$.tools===null)throw Error("Plugin tools must be an object");for(let[q,Q]of Object.entries($.tools)){if(typeof Q.description!=="string")throw Error(`Tool "${q}" must have a description`);if(typeof Q.args!=="object"||Q.args===null)throw Error(`Tool "${q}" must have args schema`);if(typeof Q.execute!=="function")throw Error(`Tool "${q}" must have an execute function`)}}if($.event!==void 0&&typeof $.event!=="function")throw Error("Plugin event handler must be a function");if($.setup!==void 0&&typeof $.setup!=="function")throw Error("Plugin setup must be a function");if($.teardown!==void 0&&typeof $.teardown!=="function")throw Error("Plugin teardown must be a function");return{...$,instanceId:$.instanceId??"default"}}function e3($){let q=A$.object($.args);return{description:$.description,args:q,execute:async(Q,G)=>{let X=q.parse(Q);return await $.execute(X,G)}}}function C$($){return`${$.name}#${$.instanceId??"default"}`}function $0($){let q=$.indexOf("#");if(q===-1)return{name:$,instanceId:"default"};return{name:$.slice(0,q),instanceId:$.slice(q+1)}}function r$($){return typeof $==="object"&&$!==null&&!Array.isArray($)&&"command"in $&&Array.isArray($.command)}function Kq($){return typeof $==="object"&&$!==null&&!Array.isArray($)&&"name"in $&&typeof $.name==="string"&&!("command"in $)}function q0($){if(typeof $==="string")return $.startsWith("file://");if(Array.isArray($)&&typeof $[0]==="string")return $[0].startsWith("file://");return!1}function Q0($){if(typeof $==="string")return!$.startsWith("file://")&&!r$($);if(Array.isArray($)&&typeof $[0]==="string")return!$[0].startsWith("file://");return!1}function Oq($,q){let Q=G$("node:path"),G=Q.relative(q,$);return!G.startsWith("..")&&!Q.isAbsolute(G)}function Rq($,q,Q){if(!$.startsWith("file://"))throw Error(`Invalid file URL: ${$}`);let G=G$("node:path"),X=$.slice(7),J;if(X.startsWith("/"))J=G.normalize(X);else if(X.startsWith("./")||X.startsWith("../"))J=G.resolve(q,X);else throw Error(`Invalid file plugin path: ${$}. Use file://./relative/path.ts or file:///absolute/path.ts`);if(!Q&&!Oq(J,q))throw Error(`Plugin path "${$}" resolves outside project root. Set security.allowPluginsOutsideProject: true to allow.`);return J}async function G0($,q,Q){let G=G$("node:fs/promises");if(Q)return $;try{let X=await G.realpath($);if(!Oq(X,q))throw Error(`Plugin path "${$}" resolves to "${X}" which is outside project root. Symlinks pointing outside the project are not allowed. Set security.allowPluginsOutsideProject: true to allow.`);return X}catch(X){if(X.code==="ENOENT")return $;throw X}}function y$($,q,Q){let G=$.permissions??[],X=q?.[$.name];if(X!==void 0){for(let H of G)if(!X.includes(H))Q.push(`Plugin '${$.name}' requires '${H}' permission but it was denied. Some features may not work. Add to security.pluginPermissions to enable.`);return X}let J=q?.default;if(J!==void 0){let H=G.filter((Y)=>J.includes(Y));for(let Y of G)if(!J.includes(Y))Q.push(`Plugin '${$.name}' requires '${Y}' permission but it was denied by default. Some features may not work. Add to security.pluginPermissions to enable.`);return H}return G}async function i$($){let{projectRoot:q,plugins:Q,security:G,pluginPermissions:X}=$,J=$.warnings??[],H=[],Y=new Map;for(let W of Q)try{let B=await X0(W,{projectRoot:q,allowOutsideProject:G?.allowPluginsOutsideProject??!1,warnings:J,...X!==void 0?{pluginPermissions:X}:{}});if(!B)continue;let A=C$(B.plugin),K=Y.get(A);if(K!==void 0)H[K]=B;else Y.set(A,H.length),H.push(B)}catch(B){let A=B instanceof Error?B.message:String(B);J.push(`Failed to load plugin: ${A}`)}return{plugins:H,warnings:J}}async function X0($,q){let{projectRoot:Q,allowOutsideProject:G,pluginPermissions:X,warnings:J}=q;if(Kq($)){let W=y$($,X,J);return{plugin:{...$,instanceId:$.instanceId??"default"},id:C$($),source:"inline",permissions:W,initialized:!1}}if(r$($))return{plugin:{name:`subprocess:${$.command.join(" ")}`,instanceId:"default"},id:`subprocess:${$.command.join(" ")}#default`,source:"subprocess",permissions:[],initialized:!1,_subprocessConfig:$};let H,Y;if(Array.isArray($))H=$[0],Y=$[1];else H=$;if(H.startsWith("file://")){let W=Rq(H,Q,G);return await H0(W,Y,X,J,Q,G)}return await J0(H,Y,X,J)}async function H0($,q,Q,G,X,J){try{let H=$;if(X!==void 0)H=await G0($,X,J??!1);let Y=await import(H),W=Y.default??Y,B;if(typeof W==="function")B=q?W(q):W();else if(typeof W==="object"&&W!==null)B=W;else throw Error(`File "${$}" does not export a valid plugin`);if(B={...B,instanceId:B.instanceId??"default"},q&&typeof q.instanceId==="string")B={...B,instanceId:q.instanceId};let A=y$(B,Q,G);return{plugin:B,id:C$(B),source:"file",permissions:A,initialized:!1}}catch(H){throw Error(`Failed to load plugin from "${$}": ${H instanceof Error?H.message:String(H)}`)}}async function J0($,q,Q,G){try{let X=$,J=$.lastIndexOf("@");if(J>0)X=$.slice(0,J);let H=await import(X),Y=H.default??H,W;if(typeof Y==="function")W=q?Y(q):Y();else if(typeof Y==="object"&&Y!==null)W=Y;else throw Error(`Package "${X}" does not export a valid plugin`);if(W={...W,instanceId:W.instanceId??"default"},q&&typeof q.instanceId==="string")W={...W,instanceId:q.instanceId};let B=y$(W,Q,G);return{plugin:W,id:C$(W),source:"npm",permissions:B,initialized:!1}}catch(X){throw Error(`Failed to load plugin "${$}": ${X instanceof Error?X.message:String(X)}`)}}function o$($,q){return[...$,...q]}class a$ extends Error{permission;pluginName;constructor($,q){super(`Plugin "${q}" does not have "${$}" permission`);this.permission=$;this.pluginName=q;this.name="PermissionDeniedError"}}class Dq{secrets=new Map;constructor($){if($)for(let[q,Q]of Object.entries($))this.secrets.set(q,Q)}async get($){return this.secrets.get($)}set($,q){this.secrets.set($,q)}}function Z$($,q,Q){let G=Q.relative(q,$);return!G.startsWith("..")&&!Q.isAbsolute(G)}function Y0($,q){let Q=G$("node:fs/promises"),G=G$("node:path"),X=async(H)=>{let Y=G.resolve($,H);if(!q&&!Z$(Y,$,G))throw Error(`Path "${H}" is outside project root. Plugins need "filesystem" permission to access files outside project.`);if(!q)try{let W=await Q.realpath(Y);if(!Z$(W,$,G))throw Error(`Path "${H}" resolves to "${W}" which is outside project root. Symlinks pointing outside the project are not allowed.`);return W}catch(W){if(W.code==="ENOENT")return Y;throw W}return Y},J=async(H)=>{let Y=G.resolve($,H);if(!q&&!Z$(Y,$,G))throw Error(`Path "${H}" is outside project root. Plugins need "filesystem" permission to access files outside project.`);if(!q){let W=G.dirname(Y);try{let B=await Q.realpath(W);if(!Z$(B,$,G))throw Error(`Path "${H}" parent directory resolves to "${B}" which is outside project root. Symlinks pointing outside the project are not allowed.`)}catch(B){if(B.code!=="ENOENT")throw B}}return Y};return{async readFile(H){let Y=await X(H);return await Q.readFile(Y,"utf-8")},async writeFile(H,Y){let W=await J(H);await Q.writeFile(W,Y,"utf-8")}}}function W0($){let q=G$("node:child_process");return async(Q,G)=>{return new Promise((X,J)=>{let H=q.spawn(Q,G,{cwd:$,stdio:["pipe","pipe","pipe"]}),Y="",W="";H.stdout?.on("data",(B)=>{Y+=B.toString("utf-8")}),H.stderr?.on("data",(B)=>{W+=B.toString("utf-8")}),H.on("close",(B)=>{if(B===0)X({stdout:Y,stderr:W});else J(Error(`Command failed with code ${B}: ${W}`))}),H.on("error",(B)=>{J(B)})})}}function B0($){let q=`[plugin:${$}]`;return{debug:(Q)=>{if(process.env.DEBUG)console.debug(`${q} ${Q}`)},info:(Q)=>{console.info(`${q} ${Q}`)},warn:(Q)=>{console.warn(`${q} ${Q}`)},error:(Q)=>{console.error(`${q} ${Q}`)}}}function s$($){let{plugin:q,permissions:Q,config:G,enterprise:X,secrets:J}=$,H=q.name,Y={projectRoot:G.projectRoot,config:G,log:B0(H)};if(Q.includes("secrets"))Y.secrets=new Dq(J);if(Q.includes("network"))Y.fetch=globalThis.fetch;if(Q.includes("filesystem"))Y.fs=Y0(G.projectRoot,G.security.allowPluginsOutsideProject);if(Q.includes("env"))Y.env=process.env;if(Q.includes("subprocess"))Y.spawn=W0(G.projectRoot);if(Q.includes("enterprise")&&X)Y.enterprise=X;return Y}function _0($,q,Q){let G=[];for(let X of Q)if(!q.includes(X))G.push(`Plugin "${$.name}" requires "${X}" permission but it was denied.`);return G}function jq($,q){return $.includes(q)}function z0($,q,Q){if(!jq($,q))throw new a$(q,Q)}import{spawn as M0}from"node:child_process";function g$($){let q={...$},Q={when(G,X){if(G)q={...q,...X};return Q},ifDefined(G,X){if(X!==void 0)q={...q,[G]:X};return Q},build(){return q}};return Q}var t$=1,V0=5000,w0=1e4,Nq=3,S0=500,E0=10485760;class e${config;projectRoot;process=null;requestId=0;pendingRequests=new Map;buffer="";initialized=!1;restartCount=0;capabilities={hooks:[],resolvers:[],commands:[]};pluginInfo={name:"unknown"};constructor($,q){this.config=$;this.projectRoot=q}async start(){await this.spawn(),await this.initialize()}async spawn(){let[$,...q]=this.config.command;if(!$)throw Error("Subprocess plugin has empty command");this.process=M0($,q,{cwd:this.projectRoot,stdio:["pipe","pipe","pipe"],env:this.config.env??{}}),this.process.stdout?.on("data",(Q)=>{this.handleStdout(Q)}),this.process.stderr?.on("data",(Q)=>{let G=Q.toString("utf-8").trim();if(G)console.error(`[subprocess:${this.pluginInfo.name}] ${G}`)}),this.process.on("close",(Q,G)=>{this.handleClose(Q,G)}),this.process.on("error",(Q)=>{this.handleError(Q)})}async initialize(){let $=this.config.startupTimeoutMs??w0,q=await this.sendRequest({id:this.nextId(),type:"init",protocolVersion:t$,config:this.config.config??{},projectRoot:this.projectRoot},$);if(q.type==="error")throw Error(`Plugin init failed: ${q.error.message}`);let G=q.result;if(G.protocolVersion>t$)throw Error(`Plugin requires protocol version ${G.protocolVersion}, but t-req supports version ${t$}`);this.pluginInfo=g$({name:G.name}).ifDefined("version",G.version).ifDefined("permissions",G.permissions).build(),this.capabilities={hooks:G.hooks??[],resolvers:G.resolvers??[],commands:G.commands??[]},this.initialized=!0}handleStdout($){if(this.buffer.length+$.length>E0){this.buffer="",console.error(`[subprocess:${this.pluginInfo.name}] stdout buffer exceeded, clearing`);return}this.buffer+=$.toString("utf-8");let q=this.buffer.split(`
2
- `);this.buffer=q.pop()??"";for(let Q of q){let G=Q.trim();if(!G)continue;try{let X=JSON.parse(G);this.handleResponse(X)}catch{console.error(`[subprocess:${this.pluginInfo.name}] Invalid JSON: ${G.slice(0,100)}`)}}}handleResponse($){let q=this.pendingRequests.get($.id);if(!q){console.error(`[subprocess:${this.pluginInfo.name}] Unknown response ID: ${$.id}`);return}clearTimeout(q.timeout),this.pendingRequests.delete($.id),q.resolve($)}handleClose($,q){this.process=null;for(let[Q,G]of this.pendingRequests)clearTimeout(G.timeout),G.reject(Error(`Plugin process exited with code ${$}, signal ${q}`));if(this.pendingRequests.clear(),this.initialized&&this.restartCount<(this.config.maxRestarts??Nq))this.restartCount++,console.warn(`[subprocess:${this.pluginInfo.name}] Process crashed, restarting (${this.restartCount}/${this.config.maxRestarts??Nq})`),this.spawn().then(()=>this.initialize()).catch((Q)=>{console.error(`[subprocess:${this.pluginInfo.name}] Restart failed: ${Q.message}`)})}handleError($){console.error(`[subprocess:${this.pluginInfo.name}] Process error: ${$.message}`);for(let[q,Q]of this.pendingRequests)clearTimeout(Q.timeout),Q.reject($);this.pendingRequests.clear()}nextId(){return String(++this.requestId)}async sendRequest($,q=this.config.timeoutMs??V0){if(!this.process?.stdin)throw Error("Plugin process not running");return new Promise((Q,G)=>{let X=setTimeout(()=>{this.pendingRequests.delete($.id),G(Error(`Request timed out after ${q}ms`))},q);this.pendingRequests.set($.id,{resolve:Q,reject:G,timeout:X});let J=`${JSON.stringify($)}
1
+ import{createRequire as lq}from"node:module";var gq=Object.defineProperty;var mq=($,q)=>{for(var Q in q)gq($,Q,{get:q[Q],enumerable:!0,configurable:!0,set:(G)=>q[Q]=()=>G})};var i=lq(import.meta.url);var K$={};mq(K$,{void:()=>R3,util:()=>U,unknown:()=>N3,union:()=>C3,undefined:()=>K3,tuple:()=>T3,transformer:()=>c3,symbol:()=>A3,string:()=>Lq,strictObject:()=>v3,setErrorMap:()=>pq,set:()=>h3,record:()=>P3,quotelessJson:()=>cq,promise:()=>l3,preprocess:()=>n3,pipeline:()=>d3,ostring:()=>i3,optional:()=>u3,onumber:()=>r3,oboolean:()=>a3,objectUtil:()=>p$,object:()=>b3,number:()=>Uq,nullable:()=>p3,null:()=>O3,never:()=>j3,nativeEnum:()=>m3,nan:()=>E3,map:()=>f3,makeIssue:()=>D$,literal:()=>Z3,lazy:()=>y3,late:()=>w3,isValid:()=>r,isDirty:()=>f$,isAsync:()=>J$,isAborted:()=>P$,intersection:()=>k3,instanceof:()=>S3,getParsedType:()=>g,getErrorMap:()=>H$,function:()=>x3,enum:()=>g3,effect:()=>c3,discriminatedUnion:()=>I3,defaultErrorMap:()=>u,datetimeRegex:()=>wq,date:()=>U3,custom:()=>Eq,coerce:()=>o3,boolean:()=>Aq,bigint:()=>L3,array:()=>F3,any:()=>D3,addIssueToContext:()=>M,ZodVoid:()=>j$,ZodUnknown:()=>a,ZodUnion:()=>M$,ZodUndefined:()=>_$,ZodType:()=>L,ZodTuple:()=>l,ZodTransformer:()=>P,ZodSymbol:()=>N$,ZodString:()=>C,ZodSet:()=>G$,ZodSchema:()=>L,ZodRecord:()=>R$,ZodReadonly:()=>A$,ZodPromise:()=>X$,ZodPipeline:()=>v$,ZodParsedType:()=>z,ZodOptional:()=>k,ZodObject:()=>N,ZodNumber:()=>o,ZodNullable:()=>n,ZodNull:()=>z$,ZodNever:()=>m,ZodNativeEnum:()=>E$,ZodNaN:()=>b$,ZodMap:()=>F$,ZodLiteral:()=>S$,ZodLazy:()=>w$,ZodIssueCode:()=>_,ZodIntersection:()=>V$,ZodFunction:()=>W$,ZodFirstPartyTypeKind:()=>S,ZodError:()=>b,ZodEnum:()=>t,ZodEffects:()=>P,ZodDiscriminatedUnion:()=>h$,ZodDefault:()=>L$,ZodDate:()=>q$,ZodCatch:()=>U$,ZodBranded:()=>x$,ZodBoolean:()=>B$,ZodBigInt:()=>s,ZodArray:()=>I,ZodAny:()=>Q$,Schema:()=>L,ParseStatus:()=>j,OK:()=>R,NEVER:()=>s3,INVALID:()=>w,EMPTY_PATH:()=>nq,DIRTY:()=>$$,BRAND:()=>V3});var U;(function($){$.assertEqual=(X)=>{};function q(X){}$.assertIs=q;function Q(X){throw Error()}$.assertNever=Q,$.arrayToEnum=(X)=>{let J={};for(let H of X)J[H]=H;return J},$.getValidEnumValues=(X)=>{let J=$.objectKeys(X).filter((Y)=>typeof X[X[Y]]!=="number"),H={};for(let Y of J)H[Y]=X[Y];return $.objectValues(H)},$.objectValues=(X)=>{return $.objectKeys(X).map(function(J){return X[J]})},$.objectKeys=typeof Object.keys==="function"?(X)=>Object.keys(X):(X)=>{let J=[];for(let H in X)if(Object.prototype.hasOwnProperty.call(X,H))J.push(H);return J},$.find=(X,J)=>{for(let H of X)if(J(H))return H;return},$.isInteger=typeof Number.isInteger==="function"?(X)=>Number.isInteger(X):(X)=>typeof X==="number"&&Number.isFinite(X)&&Math.floor(X)===X;function G(X,J=" | "){return X.map((H)=>typeof H==="string"?`'${H}'`:H).join(J)}$.joinValues=G,$.jsonStringifyReplacer=(X,J)=>{if(typeof J==="bigint")return J.toString();return J}})(U||(U={}));var p$;(function($){$.mergeShapes=(q,Q)=>{return{...q,...Q}}})(p$||(p$={}));var z=U.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),g=($)=>{switch(typeof $){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN($)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":if(Array.isArray($))return z.array;if($===null)return z.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return z.promise;if(typeof Map<"u"&&$ instanceof Map)return z.map;if(typeof Set<"u"&&$ instanceof Set)return z.set;if(typeof Date<"u"&&$ instanceof Date)return z.date;return z.object;default:return z.unknown}};var _=U.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"]),cq=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class b extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(Q)=>{this.issues=[...this.issues,Q]},this.addIssues=(Q=[])=>{this.issues=[...this.issues,...Q]};let q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,q);else this.__proto__=q;this.name="ZodError",this.issues=$}format($){let q=$||function(X){return X.message},Q={_errors:[]},G=(X)=>{for(let J of X.issues)if(J.code==="invalid_union")J.unionErrors.map(G);else if(J.code==="invalid_return_type")G(J.returnTypeError);else if(J.code==="invalid_arguments")G(J.argumentsError);else if(J.path.length===0)Q._errors.push(q(J));else{let H=Q,Y=0;while(Y<J.path.length){let W=J.path[Y];if(Y!==J.path.length-1)H[W]=H[W]||{_errors:[]};else H[W]=H[W]||{_errors:[]},H[W]._errors.push(q(J));H=H[W],Y++}}};return G(this),Q}static assert($){if(!($ instanceof b))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,U.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(q)=>q.message){let q={},Q=[];for(let G of this.issues)if(G.path.length>0){let X=G.path[0];q[X]=q[X]||[],q[X].push($(G))}else Q.push($(G));return{formErrors:Q,fieldErrors:q}}get formErrors(){return this.flatten()}}b.create=($)=>{return new b($)};var uq=($,q)=>{let Q;switch($.code){case _.invalid_type:if($.received===z.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case _.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,U.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:Q=`Unrecognized key(s) in object: ${U.joinValues($.keys,", ")}`;break;case _.invalid_union:Q="Invalid input";break;case _.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${U.joinValues($.options)}`;break;case _.invalid_enum_value:Q=`Invalid enum value. Expected ${U.joinValues($.options)}, received '${$.received}'`;break;case _.invalid_arguments:Q="Invalid function arguments";break;case _.invalid_return_type:Q="Invalid function return type";break;case _.invalid_date:Q="Invalid date";break;case _.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(Q=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")Q=`${Q} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)Q=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)Q=`Invalid input: must end with "${$.validation.endsWith}"`;else U.assertNever($.validation);else if($.validation!=="regex")Q=`Invalid ${$.validation}`;else Q="Invalid";break;case _.too_small:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else Q="Invalid input";break;case _.too_big:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")Q=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else Q="Invalid input";break;case _.custom:Q="Invalid input";break;case _.invalid_intersection_types:Q="Intersection results could not be merged";break;case _.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case _.not_finite:Q="Number must be finite";break;default:Q=q.defaultError,U.assertNever($)}return{message:Q}},u=uq;var Bq=u;function pq($){Bq=$}function H$(){return Bq}var D$=($)=>{let{data:q,path:Q,errorMaps:G,issueData:X}=$,J=[...Q,...X.path||[]],H={...X,path:J};if(X.message!==void 0)return{...X,path:J,message:X.message};let Y="",W=G.filter((B)=>!!B).slice().reverse();for(let B of W)Y=B(H,{data:q,defaultError:Y}).message;return{...X,path:J,message:Y}},nq=[];function M($,q){let Q=H$(),G=D$({issueData:q,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===u?void 0:u].filter((X)=>!!X)});$.common.issues.push(G)}class j{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,q){let Q=[];for(let G of q){if(G.status==="aborted")return w;if(G.status==="dirty")$.dirty();Q.push(G.value)}return{status:$.value,value:Q}}static async mergeObjectAsync($,q){let Q=[];for(let G of q){let X=await G.key,J=await G.value;Q.push({key:X,value:J})}return j.mergeObjectSync($,Q)}static mergeObjectSync($,q){let Q={};for(let G of q){let{key:X,value:J}=G;if(X.status==="aborted")return w;if(J.status==="aborted")return w;if(X.status==="dirty")$.dirty();if(J.status==="dirty")$.dirty();if(X.value!=="__proto__"&&(typeof J.value<"u"||G.alwaysSet))Q[X.value]=J.value}return{status:$.value,value:Q}}}var w=Object.freeze({status:"aborted"}),$$=($)=>({status:"dirty",value:$}),R=($)=>({status:"valid",value:$}),P$=($)=>$.status==="aborted",f$=($)=>$.status==="dirty",r=($)=>$.status==="valid",J$=($)=>typeof Promise<"u"&&$ instanceof Promise;var V;(function($){$.errToObj=(q)=>typeof q==="string"?{message:q}:q||{},$.toString=(q)=>typeof q==="string"?q:q?.message})(V||(V={}));class T{constructor($,q,Q,G){this._cachedPath=[],this.parent=$,this.data=q,this._path=Q,this._key=G}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var _q=($,q)=>{if(r(q))return{success:!0,data:q.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let Q=new b($.common.issues);return this._error=Q,this._error}}}};function E($){if(!$)return{};let{errorMap:q,invalid_type_error:Q,required_error:G,description:X}=$;if(q&&(Q||G))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(q)return{errorMap:q,description:X};return{errorMap:(H,Y)=>{let{message:W}=$;if(H.code==="invalid_enum_value")return{message:W??Y.defaultError};if(typeof Y.data>"u")return{message:W??G??Y.defaultError};if(H.code!=="invalid_type")return{message:Y.defaultError};return{message:W??Q??Y.defaultError}},description:X}}class L{get description(){return this._def.description}_getType($){return g($.data)}_getOrReturnCtx($,q){return q||{common:$.parent.common,data:$.data,parsedType:g($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new j,ctx:{common:$.parent.common,data:$.data,parsedType:g($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let q=this._parse($);if(J$(q))throw Error("Synchronous parse encountered promise.");return q}_parseAsync($){let q=this._parse($);return Promise.resolve(q)}parse($,q){let Q=this.safeParse($,q);if(Q.success)return Q.data;throw Q.error}safeParse($,q){let Q={common:{issues:[],async:q?.async??!1,contextualErrorMap:q?.errorMap},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:g($)},G=this._parseSync({data:$,path:Q.path,parent:Q});return _q(Q,G)}"~validate"($){let q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:g($)};if(!this["~standard"].async)try{let Q=this._parseSync({data:$,path:[],parent:q});return r(Q)?{value:Q.value}:{issues:q.common.issues}}catch(Q){if(Q?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;q.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:q}).then((Q)=>r(Q)?{value:Q.value}:{issues:q.common.issues})}async parseAsync($,q){let Q=await this.safeParseAsync($,q);if(Q.success)return Q.data;throw Q.error}async safeParseAsync($,q){let Q={common:{issues:[],contextualErrorMap:q?.errorMap,async:!0},path:q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:g($)},G=this._parse({data:$,path:Q.path,parent:Q}),X=await(J$(G)?G:Promise.resolve(G));return _q(Q,X)}refine($,q){let Q=(G)=>{if(typeof q==="string"||typeof q>"u")return{message:q};else if(typeof q==="function")return q(G);else return q};return this._refinement((G,X)=>{let J=$(G),H=()=>X.addIssue({code:_.custom,...Q(G)});if(typeof Promise<"u"&&J instanceof Promise)return J.then((Y)=>{if(!Y)return H(),!1;else return!0});if(!J)return H(),!1;else return!0})}refinement($,q){return this._refinement((Q,G)=>{if(!$(Q))return G.addIssue(typeof q==="function"?q(Q,G):q),!1;else return!0})}_refinement($){return new P({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(q)=>this["~validate"](q)}}optional(){return k.create(this,this._def)}nullable(){return n.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return I.create(this)}promise(){return X$.create(this,this._def)}or($){return M$.create([this,$],this._def)}and($){return V$.create(this,$,this._def)}transform($){return new P({...E(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:$}})}default($){let q=typeof $==="function"?$:()=>$;return new L$({...E(this._def),innerType:this,defaultValue:q,typeName:S.ZodDefault})}brand(){return new x$({typeName:S.ZodBranded,type:this,...E(this._def)})}catch($){let q=typeof $==="function"?$:()=>$;return new U$({...E(this._def),innerType:this,catchValue:q,typeName:S.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return v$.create(this,$)}readonly(){return A$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var dq=/^c[^\s-]{8,}$/i,iq=/^[0-9a-z]+$/,rq=/^[0-9A-HJKMNP-TV-Z]{26}$/i,aq=/^[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}$/i,oq=/^[a-z0-9_-]{21}$/i,sq=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,tq=/^[-+]?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)?)??$/,eq=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,$3="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",n$,q3=/^(?:(?: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])$/,Q3=/^(?:(?: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])$/,G3=/^(([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]))$/,X3=/^(([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])$/,H3=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,J3=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mq="((\\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])))",Y3=new RegExp(`^${Mq}$`);function Vq($){let q="[0-5]\\d";if($.precision)q=`${q}\\.\\d{${$.precision}}`;else if($.precision==null)q=`${q}(\\.\\d+)?`;let Q=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${q})${Q}`}function W3($){return new RegExp(`^${Vq($)}$`)}function wq($){let q=`${Mq}T${Vq($)}`,Q=[];if(Q.push($.local?"Z?":"Z"),$.offset)Q.push("([+-]\\d{2}:?\\d{2})");return q=`${q}(${Q.join("|")})`,new RegExp(`^${q}$`)}function B3($,q){if((q==="v4"||!q)&&q3.test($))return!0;if((q==="v6"||!q)&&G3.test($))return!0;return!1}function _3($,q){if(!sq.test($))return!1;try{let[Q]=$.split(".");if(!Q)return!1;let G=Q.replace(/-/g,"+").replace(/_/g,"/").padEnd(Q.length+(4-Q.length%4)%4,"="),X=JSON.parse(atob(G));if(typeof X!=="object"||X===null)return!1;if("typ"in X&&X?.typ!=="JWT")return!1;if(!X.alg)return!1;if(q&&X.alg!==q)return!1;return!0}catch{return!1}}function z3($,q){if((q==="v4"||!q)&&Q3.test($))return!0;if((q==="v6"||!q)&&X3.test($))return!0;return!1}class C extends L{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==z.string){let X=this._getOrReturnCtx($);return M(X,{code:_.invalid_type,expected:z.string,received:X.parsedType}),w}let Q=new j,G=void 0;for(let X of this._def.checks)if(X.kind==="min"){if($.data.length<X.value)G=this._getOrReturnCtx($,G),M(G,{code:_.too_small,minimum:X.value,type:"string",inclusive:!0,exact:!1,message:X.message}),Q.dirty()}else if(X.kind==="max"){if($.data.length>X.value)G=this._getOrReturnCtx($,G),M(G,{code:_.too_big,maximum:X.value,type:"string",inclusive:!0,exact:!1,message:X.message}),Q.dirty()}else if(X.kind==="length"){let J=$.data.length>X.value,H=$.data.length<X.value;if(J||H){if(G=this._getOrReturnCtx($,G),J)M(G,{code:_.too_big,maximum:X.value,type:"string",inclusive:!0,exact:!0,message:X.message});else if(H)M(G,{code:_.too_small,minimum:X.value,type:"string",inclusive:!0,exact:!0,message:X.message});Q.dirty()}}else if(X.kind==="email"){if(!eq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"email",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="emoji"){if(!n$)n$=new RegExp($3,"u");if(!n$.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"emoji",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="uuid"){if(!aq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"uuid",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="nanoid"){if(!oq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"nanoid",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="cuid"){if(!dq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"cuid",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="cuid2"){if(!iq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"cuid2",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="ulid"){if(!rq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"ulid",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="url")try{new URL($.data)}catch{G=this._getOrReturnCtx($,G),M(G,{validation:"url",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="regex"){if(X.regex.lastIndex=0,!X.regex.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"regex",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="trim")$.data=$.data.trim();else if(X.kind==="includes"){if(!$.data.includes(X.value,X.position))G=this._getOrReturnCtx($,G),M(G,{code:_.invalid_string,validation:{includes:X.value,position:X.position},message:X.message}),Q.dirty()}else if(X.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(X.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(X.kind==="startsWith"){if(!$.data.startsWith(X.value))G=this._getOrReturnCtx($,G),M(G,{code:_.invalid_string,validation:{startsWith:X.value},message:X.message}),Q.dirty()}else if(X.kind==="endsWith"){if(!$.data.endsWith(X.value))G=this._getOrReturnCtx($,G),M(G,{code:_.invalid_string,validation:{endsWith:X.value},message:X.message}),Q.dirty()}else if(X.kind==="datetime"){if(!wq(X).test($.data))G=this._getOrReturnCtx($,G),M(G,{code:_.invalid_string,validation:"datetime",message:X.message}),Q.dirty()}else if(X.kind==="date"){if(!Y3.test($.data))G=this._getOrReturnCtx($,G),M(G,{code:_.invalid_string,validation:"date",message:X.message}),Q.dirty()}else if(X.kind==="time"){if(!W3(X).test($.data))G=this._getOrReturnCtx($,G),M(G,{code:_.invalid_string,validation:"time",message:X.message}),Q.dirty()}else if(X.kind==="duration"){if(!tq.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"duration",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="ip"){if(!B3($.data,X.version))G=this._getOrReturnCtx($,G),M(G,{validation:"ip",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="jwt"){if(!_3($.data,X.alg))G=this._getOrReturnCtx($,G),M(G,{validation:"jwt",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="cidr"){if(!z3($.data,X.version))G=this._getOrReturnCtx($,G),M(G,{validation:"cidr",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="base64"){if(!H3.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"base64",code:_.invalid_string,message:X.message}),Q.dirty()}else if(X.kind==="base64url"){if(!J3.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"base64url",code:_.invalid_string,message:X.message}),Q.dirty()}else U.assertNever(X);return{status:Q.value,value:$.data}}_regex($,q,Q){return this.refinement((G)=>$.test(G),{validation:q,code:_.invalid_string,...V.errToObj(Q)})}_addCheck($){return new C({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...V.errToObj($)})}url($){return this._addCheck({kind:"url",...V.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...V.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...V.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...V.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...V.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...V.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...V.errToObj($)})}base64($){return this._addCheck({kind:"base64",...V.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...V.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...V.errToObj($)})}ip($){return this._addCheck({kind:"ip",...V.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...V.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...V.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...V.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...V.errToObj($)})}regex($,q){return this._addCheck({kind:"regex",regex:$,...V.errToObj(q)})}includes($,q){return this._addCheck({kind:"includes",value:$,position:q?.position,...V.errToObj(q?.message)})}startsWith($,q){return this._addCheck({kind:"startsWith",value:$,...V.errToObj(q)})}endsWith($,q){return this._addCheck({kind:"endsWith",value:$,...V.errToObj(q)})}min($,q){return this._addCheck({kind:"min",value:$,...V.errToObj(q)})}max($,q){return this._addCheck({kind:"max",value:$,...V.errToObj(q)})}length($,q){return this._addCheck({kind:"length",value:$,...V.errToObj(q)})}nonempty($){return this.min(1,V.errToObj($))}trim(){return new C({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new C({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new C({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxLength(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}C.create=($)=>{return new C({checks:[],typeName:S.ZodString,coerce:$?.coerce??!1,...E($)})};function M3($,q){let Q=($.toString().split(".")[1]||"").length,G=(q.toString().split(".")[1]||"").length,X=Q>G?Q:G,J=Number.parseInt($.toFixed(X).replace(".","")),H=Number.parseInt(q.toFixed(X).replace(".",""));return J%H/10**X}class o extends L{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==z.number){let X=this._getOrReturnCtx($);return M(X,{code:_.invalid_type,expected:z.number,received:X.parsedType}),w}let Q=void 0,G=new j;for(let X of this._def.checks)if(X.kind==="int"){if(!U.isInteger($.data))Q=this._getOrReturnCtx($,Q),M(Q,{code:_.invalid_type,expected:"integer",received:"float",message:X.message}),G.dirty()}else if(X.kind==="min"){if(X.inclusive?$.data<X.value:$.data<=X.value)Q=this._getOrReturnCtx($,Q),M(Q,{code:_.too_small,minimum:X.value,type:"number",inclusive:X.inclusive,exact:!1,message:X.message}),G.dirty()}else if(X.kind==="max"){if(X.inclusive?$.data>X.value:$.data>=X.value)Q=this._getOrReturnCtx($,Q),M(Q,{code:_.too_big,maximum:X.value,type:"number",inclusive:X.inclusive,exact:!1,message:X.message}),G.dirty()}else if(X.kind==="multipleOf"){if(M3($.data,X.value)!==0)Q=this._getOrReturnCtx($,Q),M(Q,{code:_.not_multiple_of,multipleOf:X.value,message:X.message}),G.dirty()}else if(X.kind==="finite"){if(!Number.isFinite($.data))Q=this._getOrReturnCtx($,Q),M(Q,{code:_.not_finite,message:X.message}),G.dirty()}else U.assertNever(X);return{status:G.value,value:$.data}}gte($,q){return this.setLimit("min",$,!0,V.toString(q))}gt($,q){return this.setLimit("min",$,!1,V.toString(q))}lte($,q){return this.setLimit("max",$,!0,V.toString(q))}lt($,q){return this.setLimit("max",$,!1,V.toString(q))}setLimit($,q,Q,G){return new o({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:Q,message:V.toString(G)}]})}_addCheck($){return new o({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:V.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:V.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:V.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:V.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:V.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:V.toString(q)})}finite($){return this._addCheck({kind:"finite",message:V.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:V.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:V.toString($)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&U.isInteger($.value))}get isFinite(){let $=null,q=null;for(let Q of this._def.checks)if(Q.kind==="finite"||Q.kind==="int"||Q.kind==="multipleOf")return!0;else if(Q.kind==="min"){if(q===null||Q.value>q)q=Q.value}else if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return Number.isFinite(q)&&Number.isFinite($)}}o.create=($)=>{return new o({checks:[],typeName:S.ZodNumber,coerce:$?.coerce||!1,...E($)})};class s extends L{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==z.bigint)return this._getInvalidInput($);let Q=void 0,G=new j;for(let X of this._def.checks)if(X.kind==="min"){if(X.inclusive?$.data<X.value:$.data<=X.value)Q=this._getOrReturnCtx($,Q),M(Q,{code:_.too_small,type:"bigint",minimum:X.value,inclusive:X.inclusive,message:X.message}),G.dirty()}else if(X.kind==="max"){if(X.inclusive?$.data>X.value:$.data>=X.value)Q=this._getOrReturnCtx($,Q),M(Q,{code:_.too_big,type:"bigint",maximum:X.value,inclusive:X.inclusive,message:X.message}),G.dirty()}else if(X.kind==="multipleOf"){if($.data%X.value!==BigInt(0))Q=this._getOrReturnCtx($,Q),M(Q,{code:_.not_multiple_of,multipleOf:X.value,message:X.message}),G.dirty()}else U.assertNever(X);return{status:G.value,value:$.data}}_getInvalidInput($){let q=this._getOrReturnCtx($);return M(q,{code:_.invalid_type,expected:z.bigint,received:q.parsedType}),w}gte($,q){return this.setLimit("min",$,!0,V.toString(q))}gt($,q){return this.setLimit("min",$,!1,V.toString(q))}lte($,q){return this.setLimit("max",$,!0,V.toString(q))}lt($,q){return this.setLimit("max",$,!1,V.toString(q))}setLimit($,q,Q,G){return new s({...this._def,checks:[...this._def.checks,{kind:$,value:q,inclusive:Q,message:V.toString(G)}]})}_addCheck($){return new s({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:V.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:V.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:V.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:V.toString($)})}multipleOf($,q){return this._addCheck({kind:"multipleOf",value:$,message:V.toString(q)})}get minValue(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $}get maxValue(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $}}s.create=($)=>{return new s({checks:[],typeName:S.ZodBigInt,coerce:$?.coerce??!1,...E($)})};class B$ extends L{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==z.boolean){let Q=this._getOrReturnCtx($);return M(Q,{code:_.invalid_type,expected:z.boolean,received:Q.parsedType}),w}return R($.data)}}B$.create=($)=>{return new B$({typeName:S.ZodBoolean,coerce:$?.coerce||!1,...E($)})};class q$ extends L{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==z.date){let X=this._getOrReturnCtx($);return M(X,{code:_.invalid_type,expected:z.date,received:X.parsedType}),w}if(Number.isNaN($.data.getTime())){let X=this._getOrReturnCtx($);return M(X,{code:_.invalid_date}),w}let Q=new j,G=void 0;for(let X of this._def.checks)if(X.kind==="min"){if($.data.getTime()<X.value)G=this._getOrReturnCtx($,G),M(G,{code:_.too_small,message:X.message,inclusive:!0,exact:!1,minimum:X.value,type:"date"}),Q.dirty()}else if(X.kind==="max"){if($.data.getTime()>X.value)G=this._getOrReturnCtx($,G),M(G,{code:_.too_big,message:X.message,inclusive:!0,exact:!1,maximum:X.value,type:"date"}),Q.dirty()}else U.assertNever(X);return{status:Q.value,value:new Date($.data.getTime())}}_addCheck($){return new q$({...this._def,checks:[...this._def.checks,$]})}min($,q){return this._addCheck({kind:"min",value:$.getTime(),message:V.toString(q)})}max($,q){return this._addCheck({kind:"max",value:$.getTime(),message:V.toString(q)})}get minDate(){let $=null;for(let q of this._def.checks)if(q.kind==="min"){if($===null||q.value>$)$=q.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let q of this._def.checks)if(q.kind==="max"){if($===null||q.value<$)$=q.value}return $!=null?new Date($):null}}q$.create=($)=>{return new q$({checks:[],coerce:$?.coerce||!1,typeName:S.ZodDate,...E($)})};class N$ extends L{_parse($){if(this._getType($)!==z.symbol){let Q=this._getOrReturnCtx($);return M(Q,{code:_.invalid_type,expected:z.symbol,received:Q.parsedType}),w}return R($.data)}}N$.create=($)=>{return new N$({typeName:S.ZodSymbol,...E($)})};class _$ extends L{_parse($){if(this._getType($)!==z.undefined){let Q=this._getOrReturnCtx($);return M(Q,{code:_.invalid_type,expected:z.undefined,received:Q.parsedType}),w}return R($.data)}}_$.create=($)=>{return new _$({typeName:S.ZodUndefined,...E($)})};class z$ extends L{_parse($){if(this._getType($)!==z.null){let Q=this._getOrReturnCtx($);return M(Q,{code:_.invalid_type,expected:z.null,received:Q.parsedType}),w}return R($.data)}}z$.create=($)=>{return new z$({typeName:S.ZodNull,...E($)})};class Q$ extends L{constructor(){super(...arguments);this._any=!0}_parse($){return R($.data)}}Q$.create=($)=>{return new Q$({typeName:S.ZodAny,...E($)})};class a extends L{constructor(){super(...arguments);this._unknown=!0}_parse($){return R($.data)}}a.create=($)=>{return new a({typeName:S.ZodUnknown,...E($)})};class m extends L{_parse($){let q=this._getOrReturnCtx($);return M(q,{code:_.invalid_type,expected:z.never,received:q.parsedType}),w}}m.create=($)=>{return new m({typeName:S.ZodNever,...E($)})};class j$ extends L{_parse($){if(this._getType($)!==z.undefined){let Q=this._getOrReturnCtx($);return M(Q,{code:_.invalid_type,expected:z.void,received:Q.parsedType}),w}return R($.data)}}j$.create=($)=>{return new j$({typeName:S.ZodVoid,...E($)})};class I extends L{_parse($){let{ctx:q,status:Q}=this._processInputParams($),G=this._def;if(q.parsedType!==z.array)return M(q,{code:_.invalid_type,expected:z.array,received:q.parsedType}),w;if(G.exactLength!==null){let J=q.data.length>G.exactLength.value,H=q.data.length<G.exactLength.value;if(J||H)M(q,{code:J?_.too_big:_.too_small,minimum:H?G.exactLength.value:void 0,maximum:J?G.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:G.exactLength.message}),Q.dirty()}if(G.minLength!==null){if(q.data.length<G.minLength.value)M(q,{code:_.too_small,minimum:G.minLength.value,type:"array",inclusive:!0,exact:!1,message:G.minLength.message}),Q.dirty()}if(G.maxLength!==null){if(q.data.length>G.maxLength.value)M(q,{code:_.too_big,maximum:G.maxLength.value,type:"array",inclusive:!0,exact:!1,message:G.maxLength.message}),Q.dirty()}if(q.common.async)return Promise.all([...q.data].map((J,H)=>{return G.type._parseAsync(new T(q,J,q.path,H))})).then((J)=>{return j.mergeArray(Q,J)});let X=[...q.data].map((J,H)=>{return G.type._parseSync(new T(q,J,q.path,H))});return j.mergeArray(Q,X)}get element(){return this._def.type}min($,q){return new I({...this._def,minLength:{value:$,message:V.toString(q)}})}max($,q){return new I({...this._def,maxLength:{value:$,message:V.toString(q)}})}length($,q){return new I({...this._def,exactLength:{value:$,message:V.toString(q)}})}nonempty($){return this.min(1,$)}}I.create=($,q)=>{return new I({type:$,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...E(q)})};function Y$($){if($ instanceof N){let q={};for(let Q in $.shape){let G=$.shape[Q];q[Q]=k.create(Y$(G))}return new N({...$._def,shape:()=>q})}else if($ instanceof I)return new I({...$._def,type:Y$($.element)});else if($ instanceof k)return k.create(Y$($.unwrap()));else if($ instanceof n)return n.create(Y$($.unwrap()));else if($ instanceof l)return l.create($.items.map((q)=>Y$(q)));else return $}class N extends L{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),q=U.objectKeys($);return this._cached={shape:$,keys:q},this._cached}_parse($){if(this._getType($)!==z.object){let W=this._getOrReturnCtx($);return M(W,{code:_.invalid_type,expected:z.object,received:W.parsedType}),w}let{status:Q,ctx:G}=this._processInputParams($),{shape:X,keys:J}=this._getCached(),H=[];if(!(this._def.catchall instanceof m&&this._def.unknownKeys==="strip")){for(let W in G.data)if(!J.includes(W))H.push(W)}let Y=[];for(let W of J){let B=X[W],A=G.data[W];Y.push({key:{status:"valid",value:W},value:B._parse(new T(G,A,G.path,W)),alwaysSet:W in G.data})}if(this._def.catchall instanceof m){let W=this._def.unknownKeys;if(W==="passthrough")for(let B of H)Y.push({key:{status:"valid",value:B},value:{status:"valid",value:G.data[B]}});else if(W==="strict"){if(H.length>0)M(G,{code:_.unrecognized_keys,keys:H}),Q.dirty()}else if(W==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let W=this._def.catchall;for(let B of H){let A=G.data[B];Y.push({key:{status:"valid",value:B},value:W._parse(new T(G,A,G.path,B)),alwaysSet:B in G.data})}}if(G.common.async)return Promise.resolve().then(async()=>{let W=[];for(let B of Y){let A=await B.key,K=await B.value;W.push({key:A,value:K,alwaysSet:B.alwaysSet})}return W}).then((W)=>{return j.mergeObjectSync(Q,W)});else return j.mergeObjectSync(Q,Y)}get shape(){return this._def.shape()}strict($){return V.errToObj,new N({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(q,Q)=>{let G=this._def.errorMap?.(q,Q).message??Q.defaultError;if(q.code==="unrecognized_keys")return{message:V.errToObj($).message??G};return{message:G}}}:{}})}strip(){return new N({...this._def,unknownKeys:"strip"})}passthrough(){return new N({...this._def,unknownKeys:"passthrough"})}extend($){return new N({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new N({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:S.ZodObject})}setKey($,q){return this.augment({[$]:q})}catchall($){return new N({...this._def,catchall:$})}pick($){let q={};for(let Q of U.objectKeys($))if($[Q]&&this.shape[Q])q[Q]=this.shape[Q];return new N({...this._def,shape:()=>q})}omit($){let q={};for(let Q of U.objectKeys(this.shape))if(!$[Q])q[Q]=this.shape[Q];return new N({...this._def,shape:()=>q})}deepPartial(){return Y$(this)}partial($){let q={};for(let Q of U.objectKeys(this.shape)){let G=this.shape[Q];if($&&!$[Q])q[Q]=G;else q[Q]=G.optional()}return new N({...this._def,shape:()=>q})}required($){let q={};for(let Q of U.objectKeys(this.shape))if($&&!$[Q])q[Q]=this.shape[Q];else{let X=this.shape[Q];while(X instanceof k)X=X._def.innerType;q[Q]=X}return new N({...this._def,shape:()=>q})}keyof(){return Sq(U.objectKeys(this.shape))}}N.create=($,q)=>{return new N({shape:()=>$,unknownKeys:"strip",catchall:m.create(),typeName:S.ZodObject,...E(q)})};N.strictCreate=($,q)=>{return new N({shape:()=>$,unknownKeys:"strict",catchall:m.create(),typeName:S.ZodObject,...E(q)})};N.lazycreate=($,q)=>{return new N({shape:$,unknownKeys:"strip",catchall:m.create(),typeName:S.ZodObject,...E(q)})};class M$ extends L{_parse($){let{ctx:q}=this._processInputParams($),Q=this._def.options;function G(X){for(let H of X)if(H.result.status==="valid")return H.result;for(let H of X)if(H.result.status==="dirty")return q.common.issues.push(...H.ctx.common.issues),H.result;let J=X.map((H)=>new b(H.ctx.common.issues));return M(q,{code:_.invalid_union,unionErrors:J}),w}if(q.common.async)return Promise.all(Q.map(async(X)=>{let J={...q,common:{...q.common,issues:[]},parent:null};return{result:await X._parseAsync({data:q.data,path:q.path,parent:J}),ctx:J}})).then(G);else{let X=void 0,J=[];for(let Y of Q){let W={...q,common:{...q.common,issues:[]},parent:null},B=Y._parseSync({data:q.data,path:q.path,parent:W});if(B.status==="valid")return B;else if(B.status==="dirty"&&!X)X={result:B,ctx:W};if(W.common.issues.length)J.push(W.common.issues)}if(X)return q.common.issues.push(...X.ctx.common.issues),X.result;let H=J.map((Y)=>new b(Y));return M(q,{code:_.invalid_union,unionErrors:H}),w}}get options(){return this._def.options}}M$.create=($,q)=>{return new M$({options:$,typeName:S.ZodUnion,...E(q)})};var p=($)=>{if($ instanceof w$)return p($.schema);else if($ instanceof P)return p($.innerType());else if($ instanceof S$)return[$.value];else if($ instanceof t)return $.options;else if($ instanceof E$)return U.objectValues($.enum);else if($ instanceof L$)return p($._def.innerType);else if($ instanceof _$)return[void 0];else if($ instanceof z$)return[null];else if($ instanceof k)return[void 0,...p($.unwrap())];else if($ instanceof n)return[null,...p($.unwrap())];else if($ instanceof x$)return p($.unwrap());else if($ instanceof A$)return p($.unwrap());else if($ instanceof U$)return p($._def.innerType);else return[]};class h$ extends L{_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==z.object)return M(q,{code:_.invalid_type,expected:z.object,received:q.parsedType}),w;let Q=this.discriminator,G=q.data[Q],X=this.optionsMap.get(G);if(!X)return M(q,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),w;if(q.common.async)return X._parseAsync({data:q.data,path:q.path,parent:q});else return X._parseSync({data:q.data,path:q.path,parent:q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,q,Q){let G=new Map;for(let X of q){let J=p(X.shape[$]);if(!J.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let H of J){if(G.has(H))throw Error(`Discriminator property ${String($)} has duplicate value ${String(H)}`);G.set(H,X)}}return new h$({typeName:S.ZodDiscriminatedUnion,discriminator:$,options:q,optionsMap:G,...E(Q)})}}function d$($,q){let Q=g($),G=g(q);if($===q)return{valid:!0,data:$};else if(Q===z.object&&G===z.object){let X=U.objectKeys(q),J=U.objectKeys($).filter((Y)=>X.indexOf(Y)!==-1),H={...$,...q};for(let Y of J){let W=d$($[Y],q[Y]);if(!W.valid)return{valid:!1};H[Y]=W.data}return{valid:!0,data:H}}else if(Q===z.array&&G===z.array){if($.length!==q.length)return{valid:!1};let X=[];for(let J=0;J<$.length;J++){let H=$[J],Y=q[J],W=d$(H,Y);if(!W.valid)return{valid:!1};X.push(W.data)}return{valid:!0,data:X}}else if(Q===z.date&&G===z.date&&+$===+q)return{valid:!0,data:$};else return{valid:!1}}class V$ extends L{_parse($){let{status:q,ctx:Q}=this._processInputParams($),G=(X,J)=>{if(P$(X)||P$(J))return w;let H=d$(X.value,J.value);if(!H.valid)return M(Q,{code:_.invalid_intersection_types}),w;if(f$(X)||f$(J))q.dirty();return{status:q.value,value:H.data}};if(Q.common.async)return Promise.all([this._def.left._parseAsync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseAsync({data:Q.data,path:Q.path,parent:Q})]).then(([X,J])=>G(X,J));else return G(this._def.left._parseSync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseSync({data:Q.data,path:Q.path,parent:Q}))}}V$.create=($,q,Q)=>{return new V$({left:$,right:q,typeName:S.ZodIntersection,...E(Q)})};class l extends L{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.array)return M(Q,{code:_.invalid_type,expected:z.array,received:Q.parsedType}),w;if(Q.data.length<this._def.items.length)return M(Q,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),w;if(!this._def.rest&&Q.data.length>this._def.items.length)M(Q,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),q.dirty();let X=[...Q.data].map((J,H)=>{let Y=this._def.items[H]||this._def.rest;if(!Y)return null;return Y._parse(new T(Q,J,Q.path,H))}).filter((J)=>!!J);if(Q.common.async)return Promise.all(X).then((J)=>{return j.mergeArray(q,J)});else return j.mergeArray(q,X)}get items(){return this._def.items}rest($){return new l({...this._def,rest:$})}}l.create=($,q)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new l({items:$,typeName:S.ZodTuple,rest:null,...E(q)})};class R$ extends L{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.object)return M(Q,{code:_.invalid_type,expected:z.object,received:Q.parsedType}),w;let G=[],X=this._def.keyType,J=this._def.valueType;for(let H in Q.data)G.push({key:X._parse(new T(Q,H,Q.path,H)),value:J._parse(new T(Q,Q.data[H],Q.path,H)),alwaysSet:H in Q.data});if(Q.common.async)return j.mergeObjectAsync(q,G);else return j.mergeObjectSync(q,G)}get element(){return this._def.valueType}static create($,q,Q){if(q instanceof L)return new R$({keyType:$,valueType:q,typeName:S.ZodRecord,...E(Q)});return new R$({keyType:C.create(),valueType:$,typeName:S.ZodRecord,...E(q)})}}class F$ extends L{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.map)return M(Q,{code:_.invalid_type,expected:z.map,received:Q.parsedType}),w;let G=this._def.keyType,X=this._def.valueType,J=[...Q.data.entries()].map(([H,Y],W)=>{return{key:G._parse(new T(Q,H,Q.path,[W,"key"])),value:X._parse(new T(Q,Y,Q.path,[W,"value"]))}});if(Q.common.async){let H=new Map;return Promise.resolve().then(async()=>{for(let Y of J){let W=await Y.key,B=await Y.value;if(W.status==="aborted"||B.status==="aborted")return w;if(W.status==="dirty"||B.status==="dirty")q.dirty();H.set(W.value,B.value)}return{status:q.value,value:H}})}else{let H=new Map;for(let Y of J){let{key:W,value:B}=Y;if(W.status==="aborted"||B.status==="aborted")return w;if(W.status==="dirty"||B.status==="dirty")q.dirty();H.set(W.value,B.value)}return{status:q.value,value:H}}}}F$.create=($,q,Q)=>{return new F$({valueType:q,keyType:$,typeName:S.ZodMap,...E(Q)})};class G$ extends L{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.set)return M(Q,{code:_.invalid_type,expected:z.set,received:Q.parsedType}),w;let G=this._def;if(G.minSize!==null){if(Q.data.size<G.minSize.value)M(Q,{code:_.too_small,minimum:G.minSize.value,type:"set",inclusive:!0,exact:!1,message:G.minSize.message}),q.dirty()}if(G.maxSize!==null){if(Q.data.size>G.maxSize.value)M(Q,{code:_.too_big,maximum:G.maxSize.value,type:"set",inclusive:!0,exact:!1,message:G.maxSize.message}),q.dirty()}let X=this._def.valueType;function J(Y){let W=new Set;for(let B of Y){if(B.status==="aborted")return w;if(B.status==="dirty")q.dirty();W.add(B.value)}return{status:q.value,value:W}}let H=[...Q.data.values()].map((Y,W)=>X._parse(new T(Q,Y,Q.path,W)));if(Q.common.async)return Promise.all(H).then((Y)=>J(Y));else return J(H)}min($,q){return new G$({...this._def,minSize:{value:$,message:V.toString(q)}})}max($,q){return new G$({...this._def,maxSize:{value:$,message:V.toString(q)}})}size($,q){return this.min($,q).max($,q)}nonempty($){return this.min(1,$)}}G$.create=($,q)=>{return new G$({valueType:$,minSize:null,maxSize:null,typeName:S.ZodSet,...E(q)})};class W$ extends L{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==z.function)return M(q,{code:_.invalid_type,expected:z.function,received:q.parsedType}),w;function Q(H,Y){return D$({data:H,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,H$(),u].filter((W)=>!!W),issueData:{code:_.invalid_arguments,argumentsError:Y}})}function G(H,Y){return D$({data:H,path:q.path,errorMaps:[q.common.contextualErrorMap,q.schemaErrorMap,H$(),u].filter((W)=>!!W),issueData:{code:_.invalid_return_type,returnTypeError:Y}})}let X={errorMap:q.common.contextualErrorMap},J=q.data;if(this._def.returns instanceof X$){let H=this;return R(async function(...Y){let W=new b([]),B=await H._def.args.parseAsync(Y,X).catch((D)=>{throw W.addIssue(Q(Y,D)),W}),A=await Reflect.apply(J,this,B);return await H._def.returns._def.type.parseAsync(A,X).catch((D)=>{throw W.addIssue(G(A,D)),W})})}else{let H=this;return R(function(...Y){let W=H._def.args.safeParse(Y,X);if(!W.success)throw new b([Q(Y,W.error)]);let B=Reflect.apply(J,this,W.data),A=H._def.returns.safeParse(B,X);if(!A.success)throw new b([G(B,A.error)]);return A.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new W$({...this._def,args:l.create($).rest(a.create())})}returns($){return new W$({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,q,Q){return new W$({args:$?$:l.create([]).rest(a.create()),returns:q||a.create(),typeName:S.ZodFunction,...E(Q)})}}class w$ extends L{get schema(){return this._def.getter()}_parse($){let{ctx:q}=this._processInputParams($);return this._def.getter()._parse({data:q.data,path:q.path,parent:q})}}w$.create=($,q)=>{return new w$({getter:$,typeName:S.ZodLazy,...E(q)})};class S$ extends L{_parse($){if($.data!==this._def.value){let q=this._getOrReturnCtx($);return M(q,{received:q.data,code:_.invalid_literal,expected:this._def.value}),w}return{status:"valid",value:$.data}}get value(){return this._def.value}}S$.create=($,q)=>{return new S$({value:$,typeName:S.ZodLiteral,...E(q)})};function Sq($,q){return new t({values:$,typeName:S.ZodEnum,...E(q)})}class t extends L{_parse($){if(typeof $.data!=="string"){let q=this._getOrReturnCtx($),Q=this._def.values;return M(q,{expected:U.joinValues(Q),received:q.parsedType,code:_.invalid_type}),w}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let q=this._getOrReturnCtx($),Q=this._def.values;return M(q,{received:q.data,code:_.invalid_enum_value,options:Q}),w}return R($.data)}get options(){return this._def.values}get enum(){let $={};for(let q of this._def.values)$[q]=q;return $}get Values(){let $={};for(let q of this._def.values)$[q]=q;return $}get Enum(){let $={};for(let q of this._def.values)$[q]=q;return $}extract($,q=this._def){return t.create($,{...this._def,...q})}exclude($,q=this._def){return t.create(this.options.filter((Q)=>!$.includes(Q)),{...this._def,...q})}}t.create=Sq;class E$ extends L{_parse($){let q=U.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==z.string&&Q.parsedType!==z.number){let G=U.objectValues(q);return M(Q,{expected:U.joinValues(G),received:Q.parsedType,code:_.invalid_type}),w}if(!this._cache)this._cache=new Set(U.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let G=U.objectValues(q);return M(Q,{received:Q.data,code:_.invalid_enum_value,options:G}),w}return R($.data)}get enum(){return this._def.values}}E$.create=($,q)=>{return new E$({values:$,typeName:S.ZodNativeEnum,...E(q)})};class X$ extends L{unwrap(){return this._def.type}_parse($){let{ctx:q}=this._processInputParams($);if(q.parsedType!==z.promise&&q.common.async===!1)return M(q,{code:_.invalid_type,expected:z.promise,received:q.parsedType}),w;let Q=q.parsedType===z.promise?q.data:Promise.resolve(q.data);return R(Q.then((G)=>{return this._def.type.parseAsync(G,{path:q.path,errorMap:q.common.contextualErrorMap})}))}}X$.create=($,q)=>{return new X$({type:$,typeName:S.ZodPromise,...E(q)})};class P extends L{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:q,ctx:Q}=this._processInputParams($),G=this._def.effect||null,X={addIssue:(J)=>{if(M(Q,J),J.fatal)q.abort();else q.dirty()},get path(){return Q.path}};if(X.addIssue=X.addIssue.bind(X),G.type==="preprocess"){let J=G.transform(Q.data,X);if(Q.common.async)return Promise.resolve(J).then(async(H)=>{if(q.value==="aborted")return w;let Y=await this._def.schema._parseAsync({data:H,path:Q.path,parent:Q});if(Y.status==="aborted")return w;if(Y.status==="dirty")return $$(Y.value);if(q.value==="dirty")return $$(Y.value);return Y});else{if(q.value==="aborted")return w;let H=this._def.schema._parseSync({data:J,path:Q.path,parent:Q});if(H.status==="aborted")return w;if(H.status==="dirty")return $$(H.value);if(q.value==="dirty")return $$(H.value);return H}}if(G.type==="refinement"){let J=(H)=>{let Y=G.refinement(H,X);if(Q.common.async)return Promise.resolve(Y);if(Y instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return H};if(Q.common.async===!1){let H=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(H.status==="aborted")return w;if(H.status==="dirty")q.dirty();return J(H.value),{status:q.value,value:H.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((H)=>{if(H.status==="aborted")return w;if(H.status==="dirty")q.dirty();return J(H.value).then(()=>{return{status:q.value,value:H.value}})})}if(G.type==="transform")if(Q.common.async===!1){let J=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!r(J))return w;let H=G.transform(J.value,X);if(H instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:q.value,value:H}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((J)=>{if(!r(J))return w;return Promise.resolve(G.transform(J.value,X)).then((H)=>({status:q.value,value:H}))});U.assertNever(G)}}P.create=($,q,Q)=>{return new P({schema:$,typeName:S.ZodEffects,effect:q,...E(Q)})};P.createWithPreprocess=($,q,Q)=>{return new P({schema:q,effect:{type:"preprocess",transform:$},typeName:S.ZodEffects,...E(Q)})};class k extends L{_parse($){if(this._getType($)===z.undefined)return R(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}k.create=($,q)=>{return new k({innerType:$,typeName:S.ZodOptional,...E(q)})};class n extends L{_parse($){if(this._getType($)===z.null)return R(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}n.create=($,q)=>{return new n({innerType:$,typeName:S.ZodNullable,...E(q)})};class L$ extends L{_parse($){let{ctx:q}=this._processInputParams($),Q=q.data;if(q.parsedType===z.undefined)Q=this._def.defaultValue();return this._def.innerType._parse({data:Q,path:q.path,parent:q})}removeDefault(){return this._def.innerType}}L$.create=($,q)=>{return new L$({innerType:$,typeName:S.ZodDefault,defaultValue:typeof q.default==="function"?q.default:()=>q.default,...E(q)})};class U$ extends L{_parse($){let{ctx:q}=this._processInputParams($),Q={...q,common:{...q.common,issues:[]}},G=this._def.innerType._parse({data:Q.data,path:Q.path,parent:{...Q}});if(J$(G))return G.then((X)=>{return{status:"valid",value:X.status==="valid"?X.value:this._def.catchValue({get error(){return new b(Q.common.issues)},input:Q.data})}});else return{status:"valid",value:G.status==="valid"?G.value:this._def.catchValue({get error(){return new b(Q.common.issues)},input:Q.data})}}removeCatch(){return this._def.innerType}}U$.create=($,q)=>{return new U$({innerType:$,typeName:S.ZodCatch,catchValue:typeof q.catch==="function"?q.catch:()=>q.catch,...E(q)})};class b$ extends L{_parse($){if(this._getType($)!==z.nan){let Q=this._getOrReturnCtx($);return M(Q,{code:_.invalid_type,expected:z.nan,received:Q.parsedType}),w}return{status:"valid",value:$.data}}}b$.create=($)=>{return new b$({typeName:S.ZodNaN,...E($)})};var V3=Symbol("zod_brand");class x$ extends L{_parse($){let{ctx:q}=this._processInputParams($),Q=q.data;return this._def.type._parse({data:Q,path:q.path,parent:q})}unwrap(){return this._def.type}}class v$ extends L{_parse($){let{status:q,ctx:Q}=this._processInputParams($);if(Q.common.async)return(async()=>{let X=await this._def.in._parseAsync({data:Q.data,path:Q.path,parent:Q});if(X.status==="aborted")return w;if(X.status==="dirty")return q.dirty(),$$(X.value);else return this._def.out._parseAsync({data:X.value,path:Q.path,parent:Q})})();else{let G=this._def.in._parseSync({data:Q.data,path:Q.path,parent:Q});if(G.status==="aborted")return w;if(G.status==="dirty")return q.dirty(),{status:"dirty",value:G.value};else return this._def.out._parseSync({data:G.value,path:Q.path,parent:Q})}}static create($,q){return new v$({in:$,out:q,typeName:S.ZodPipeline})}}class A$ extends L{_parse($){let q=this._def.innerType._parse($),Q=(G)=>{if(r(G))G.value=Object.freeze(G.value);return G};return J$(q)?q.then((G)=>Q(G)):Q(q)}unwrap(){return this._def.innerType}}A$.create=($,q)=>{return new A$({innerType:$,typeName:S.ZodReadonly,...E(q)})};function zq($,q){let Q=typeof $==="function"?$(q):typeof $==="string"?{message:$}:$;return typeof Q==="string"?{message:Q}:Q}function Eq($,q={},Q){if($)return Q$.create().superRefine((G,X)=>{let J=$(G);if(J instanceof Promise)return J.then((H)=>{if(!H){let Y=zq(q,G),W=Y.fatal??Q??!0;X.addIssue({code:"custom",...Y,fatal:W})}});if(!J){let H=zq(q,G),Y=H.fatal??Q??!0;X.addIssue({code:"custom",...H,fatal:Y})}return});return Q$.create()}var w3={object:N.lazycreate},S;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(S||(S={}));var S3=($,q={message:`Input not instance of ${$.name}`})=>Eq((Q)=>Q instanceof $,q),Lq=C.create,Uq=o.create,E3=b$.create,L3=s.create,Aq=B$.create,U3=q$.create,A3=N$.create,K3=_$.create,O3=z$.create,D3=Q$.create,N3=a.create,j3=m.create,R3=j$.create,F3=I.create,b3=N.create,v3=N.strictCreate,C3=M$.create,I3=h$.create,k3=V$.create,T3=l.create,P3=R$.create,f3=F$.create,h3=G$.create,x3=W$.create,y3=w$.create,Z3=S$.create,g3=t.create,m3=E$.create,l3=X$.create,c3=P.create,u3=k.create,p3=n.create,n3=P.createWithPreprocess,d3=v$.create,i3=()=>Lq().optional(),r3=()=>Uq().optional(),a3=()=>Aq().optional(),o3={string:($)=>C.create({...$,coerce:!0}),number:($)=>o.create({...$,coerce:!0}),boolean:($)=>B$.create({...$,coerce:!0}),bigint:($)=>s.create({...$,coerce:!0}),date:($)=>q$.create({...$,coerce:!0})};var s3=w;function t3($){if(!$.name)throw Error("Plugin must have a name");if(typeof $.name!=="string"||$.name.trim()==="")throw Error("Plugin name must be a non-empty string");if($.instanceId!==void 0&&typeof $.instanceId!=="string")throw Error("Plugin instanceId must be a string");if($.version!==void 0&&typeof $.version!=="string")throw Error("Plugin version must be a string");if($.permissions!==void 0){if(!Array.isArray($.permissions))throw Error("Plugin permissions must be an array");let q=["secrets","network","filesystem","env","subprocess","enterprise"];for(let Q of $.permissions)if(!q.includes(Q))throw Error(`Invalid permission: ${Q}. Valid permissions are: ${q.join(", ")}`)}if($.resolvers!==void 0){if(typeof $.resolvers!=="object"||$.resolvers===null)throw Error("Plugin resolvers must be an object");for(let[q,Q]of Object.entries($.resolvers)){if(!q.startsWith("$"))throw Error(`Resolver name "${q}" must start with $ (e.g., "$${q}")`);if(typeof Q!=="function")throw Error(`Resolver "${q}" must be a function`)}}if($.hooks!==void 0){if(typeof $.hooks!=="object"||$.hooks===null)throw Error("Plugin hooks must be an object");let q=["parse.after","request.before","request.compiled","request.after","response.after","error","validate"];for(let[Q,G]of Object.entries($.hooks)){if(!q.includes(Q))throw Error(`Invalid hook: "${Q}". Valid hooks are: ${q.join(", ")}`);if(typeof G!=="function")throw Error(`Hook "${Q}" must be a function`)}}if($.commands!==void 0){if(typeof $.commands!=="object"||$.commands===null)throw Error("Plugin commands must be an object");for(let[q,Q]of Object.entries($.commands))if(typeof Q!=="function")throw Error(`Command "${q}" must be a function`)}if($.middleware!==void 0){if(!Array.isArray($.middleware))throw Error("Plugin middleware must be an array");for(let q=0;q<$.middleware.length;q++)if(typeof $.middleware[q]!=="function")throw Error(`Middleware at index ${q} must be a function`)}if($.tools!==void 0){if(typeof $.tools!=="object"||$.tools===null)throw Error("Plugin tools must be an object");for(let[q,Q]of Object.entries($.tools)){if(typeof Q.description!=="string")throw Error(`Tool "${q}" must have a description`);if(typeof Q.args!=="object"||Q.args===null)throw Error(`Tool "${q}" must have args schema`);if(typeof Q.execute!=="function")throw Error(`Tool "${q}" must have an execute function`)}}if($.event!==void 0&&typeof $.event!=="function")throw Error("Plugin event handler must be a function");if($.setup!==void 0&&typeof $.setup!=="function")throw Error("Plugin setup must be a function");if($.teardown!==void 0&&typeof $.teardown!=="function")throw Error("Plugin teardown must be a function");return{...$,instanceId:$.instanceId??"default"}}function e3($){let q=K$.object($.args);return{description:$.description,args:q,execute:async(Q,G)=>{let X=q.parse(Q);return await $.execute(X,G)}}}function C$($){return`${$.name}#${$.instanceId??"default"}`}function $0($){let q=$.indexOf("#");if(q===-1)return{name:$,instanceId:"default"};return{name:$.slice(0,q),instanceId:$.slice(q+1)}}function i$($){return typeof $==="object"&&$!==null&&!Array.isArray($)&&"command"in $&&Array.isArray($.command)}function Kq($){return typeof $==="object"&&$!==null&&!Array.isArray($)&&"name"in $&&typeof $.name==="string"&&!("command"in $)}function q0($){if(typeof $==="string")return $.startsWith("file://");if(Array.isArray($)&&typeof $[0]==="string")return $[0].startsWith("file://");return!1}function Q0($){if(typeof $==="string")return!$.startsWith("file://")&&!i$($);if(Array.isArray($)&&typeof $[0]==="string")return!$[0].startsWith("file://");return!1}function Oq($,q){let Q=i("node:path"),G=Q.relative(q,$);return!G.startsWith("..")&&!Q.isAbsolute(G)}function Dq($,q,Q){if(!$.startsWith("file://"))throw Error(`Invalid file URL: ${$}`);let G=i("node:path"),X=$.slice(7),J;if(X.startsWith("/"))J=G.normalize(X);else if(X.startsWith("./")||X.startsWith("../"))J=G.resolve(q,X);else throw Error(`Invalid file plugin path: ${$}. Use file://./relative/path.ts or file:///absolute/path.ts`);if(!Q&&!Oq(J,q))throw Error(`Plugin path "${$}" resolves outside project root. Set security.allowPluginsOutsideProject: true to allow.`);return J}async function G0($,q,Q){let G=i("node:fs/promises");if(Q)return $;try{let X=await G.realpath($);if(!Oq(X,q))throw Error(`Plugin path "${$}" resolves to "${X}" which is outside project root. Symlinks pointing outside the project are not allowed. Set security.allowPluginsOutsideProject: true to allow.`);return X}catch(X){if(X.code==="ENOENT")return $;throw X}}function y$($,q,Q){let G=$.permissions??[],X=q?.[$.name];if(X!==void 0){for(let H of G)if(!X.includes(H))Q.push(`Plugin '${$.name}' requires '${H}' permission but it was denied. Some features may not work. Add to security.pluginPermissions to enable.`);return X}let J=q?.default;if(J!==void 0){let H=G.filter((Y)=>J.includes(Y));for(let Y of G)if(!J.includes(Y))Q.push(`Plugin '${$.name}' requires '${Y}' permission but it was denied by default. Some features may not work. Add to security.pluginPermissions to enable.`);return H}return G}async function r$($){let{projectRoot:q,plugins:Q,security:G,pluginPermissions:X}=$,J=$.warnings??[],H=[],Y=new Map;for(let W of Q)try{let B=await X0(W,{projectRoot:q,allowOutsideProject:G?.allowPluginsOutsideProject??!1,warnings:J,...X!==void 0?{pluginPermissions:X}:{}});if(!B)continue;let A=C$(B.plugin),K=Y.get(A);if(K!==void 0)H[K]=B;else Y.set(A,H.length),H.push(B)}catch(B){let A=B instanceof Error?B.message:String(B);J.push(`Failed to load plugin: ${A}`)}return{plugins:H,warnings:J}}async function X0($,q){let{projectRoot:Q,allowOutsideProject:G,pluginPermissions:X,warnings:J}=q;if(Kq($)){let W=y$($,X,J);return{plugin:{...$,instanceId:$.instanceId??"default"},id:C$($),source:"inline",permissions:W,initialized:!1}}if(i$($))return{plugin:{name:`subprocess:${$.command.join(" ")}`,instanceId:"default"},id:`subprocess:${$.command.join(" ")}#default`,source:"subprocess",permissions:[],initialized:!1,_subprocessConfig:$};let H,Y;if(Array.isArray($))H=$[0],Y=$[1];else H=$;if(H.startsWith("file://")){let W=Dq(H,Q,G);return await H0(W,Y,X,J,Q,G)}return await J0(H,Q,Y,X,J)}async function H0($,q,Q,G,X,J){try{let H=$;if(X!==void 0)H=await G0($,X,J??!1);let Y=await import(H),W=Y.default??Y,B;if(typeof W==="function")B=q?W(q):W();else if(typeof W==="object"&&W!==null)B=W;else throw Error(`File "${$}" does not export a valid plugin`);if(B={...B,instanceId:B.instanceId??"default"},q&&typeof q.instanceId==="string")B={...B,instanceId:q.instanceId};let A=y$(B,Q,G);return{plugin:B,id:C$(B),source:"file",permissions:A,initialized:!1}}catch(H){throw Error(`Failed to load plugin from "${$}": ${H instanceof Error?H.message:String(H)}`)}}async function J0($,q,Q,G,X){try{let J=$,H=$.lastIndexOf("@");if(H>0)J=$.slice(0,H);let Y=i("node:path"),{createRequire:W}=i("node:module"),K=await import(W(Y.join(q,"package.json")).resolve(J)),D=K.default??K,O;if(typeof D==="function")O=Q?D(Q):D();else if(typeof D==="object"&&D!==null)O=D;else throw Error(`Package "${J}" does not export a valid plugin`);if(O={...O,instanceId:O.instanceId??"default"},Q&&typeof Q.instanceId==="string")O={...O,instanceId:Q.instanceId};let c=y$(O,G,X);return{plugin:O,id:C$(O),source:"npm",permissions:c,initialized:!1}}catch(J){throw Error(`Failed to load plugin "${$}" from project "${q}": ${J instanceof Error?J.message:String(J)}`)}}function a$($,q){return[...$,...q]}class o$ extends Error{permission;pluginName;constructor($,q){super(`Plugin "${q}" does not have "${$}" permission`);this.permission=$;this.pluginName=q;this.name="PermissionDeniedError"}}class Nq{secrets=new Map;constructor($){if($)for(let[q,Q]of Object.entries($))this.secrets.set(q,Q)}async get($){return this.secrets.get($)}set($,q){this.secrets.set($,q)}}function Z$($,q,Q){let G=Q.relative(q,$);return!G.startsWith("..")&&!Q.isAbsolute(G)}function Y0($,q){let Q=i("node:fs/promises"),G=i("node:path"),X=async(H)=>{let Y=G.resolve($,H);if(!q&&!Z$(Y,$,G))throw Error(`Path "${H}" is outside project root. Plugins need "filesystem" permission to access files outside project.`);if(!q)try{let W=await Q.realpath(Y);if(!Z$(W,$,G))throw Error(`Path "${H}" resolves to "${W}" which is outside project root. Symlinks pointing outside the project are not allowed.`);return W}catch(W){if(W.code==="ENOENT")return Y;throw W}return Y},J=async(H)=>{let Y=G.resolve($,H);if(!q&&!Z$(Y,$,G))throw Error(`Path "${H}" is outside project root. Plugins need "filesystem" permission to access files outside project.`);if(!q){let W=G.dirname(Y);try{let B=await Q.realpath(W);if(!Z$(B,$,G))throw Error(`Path "${H}" parent directory resolves to "${B}" which is outside project root. Symlinks pointing outside the project are not allowed.`)}catch(B){if(B.code!=="ENOENT")throw B}}return Y};return{async readFile(H){let Y=await X(H);return await Q.readFile(Y,"utf-8")},async writeFile(H,Y){let W=await J(H);await Q.writeFile(W,Y,"utf-8")}}}function W0($){let q=i("node:child_process");return async(Q,G)=>{return new Promise((X,J)=>{let H=q.spawn(Q,G,{cwd:$,stdio:["pipe","pipe","pipe"]}),Y="",W="";H.stdout?.on("data",(B)=>{Y+=B.toString("utf-8")}),H.stderr?.on("data",(B)=>{W+=B.toString("utf-8")}),H.on("close",(B)=>{if(B===0)X({stdout:Y,stderr:W});else J(Error(`Command failed with code ${B}: ${W}`))}),H.on("error",(B)=>{J(B)})})}}function B0($){let q=`[plugin:${$}]`;return{debug:(Q)=>{if(process.env.DEBUG)console.debug(`${q} ${Q}`)},info:(Q)=>{console.info(`${q} ${Q}`)},warn:(Q)=>{console.warn(`${q} ${Q}`)},error:(Q)=>{console.error(`${q} ${Q}`)}}}function s$($){let{plugin:q,permissions:Q,config:G,enterprise:X,secrets:J}=$,H=q.name,Y={projectRoot:G.projectRoot,config:G,log:B0(H)};if(Q.includes("secrets"))Y.secrets=new Nq(J);if(Q.includes("network"))Y.fetch=globalThis.fetch;if(Q.includes("filesystem"))Y.fs=Y0(G.projectRoot,G.security.allowPluginsOutsideProject);if(Q.includes("env"))Y.env=process.env;if(Q.includes("subprocess"))Y.spawn=W0(G.projectRoot);if(Q.includes("enterprise")&&X)Y.enterprise=X;return Y}function _0($,q,Q){let G=[];for(let X of Q)if(!q.includes(X))G.push(`Plugin "${$.name}" requires "${X}" permission but it was denied.`);return G}function jq($,q){return $.includes(q)}function z0($,q,Q){if(!jq($,q))throw new o$(q,Q)}import{spawn as M0}from"node:child_process";function g$($){let q={...$},Q={when(G,X){if(G)q={...q,...X};return Q},ifDefined(G,X){if(X!==void 0)q={...q,[G]:X};return Q},build(){return q}};return Q}var t$=1,V0=5000,w0=1e4,Rq=3,S0=500,E0=10485760;class e${config;projectRoot;process=null;requestId=0;pendingRequests=new Map;buffer="";initialized=!1;restartCount=0;capabilities={hooks:[],resolvers:[],commands:[]};pluginInfo={name:"unknown"};constructor($,q){this.config=$;this.projectRoot=q}async start(){await this.spawn(),await this.initialize()}async spawn(){let[$,...q]=this.config.command;if(!$)throw Error("Subprocess plugin has empty command");this.process=M0($,q,{cwd:this.projectRoot,stdio:["pipe","pipe","pipe"],env:this.config.env??{}}),this.process.stdout?.on("data",(Q)=>{this.handleStdout(Q)}),this.process.stderr?.on("data",(Q)=>{let G=Q.toString("utf-8").trim();if(G)console.error(`[subprocess:${this.pluginInfo.name}] ${G}`)}),this.process.on("close",(Q,G)=>{this.handleClose(Q,G)}),this.process.on("error",(Q)=>{this.handleError(Q)})}async initialize(){let $=this.config.startupTimeoutMs??w0,q=await this.sendRequest({id:this.nextId(),type:"init",protocolVersion:t$,config:this.config.config??{},projectRoot:this.projectRoot},$);if(q.type==="error")throw Error(`Plugin init failed: ${q.error.message}`);let G=q.result;if(G.protocolVersion>t$)throw Error(`Plugin requires protocol version ${G.protocolVersion}, but t-req supports version ${t$}`);this.pluginInfo=g$({name:G.name}).ifDefined("version",G.version).ifDefined("permissions",G.permissions).build(),this.capabilities={hooks:G.hooks??[],resolvers:G.resolvers??[],commands:G.commands??[]},this.initialized=!0}handleStdout($){if(this.buffer.length+$.length>E0){this.buffer="",console.error(`[subprocess:${this.pluginInfo.name}] stdout buffer exceeded, clearing`);return}this.buffer+=$.toString("utf-8");let q=this.buffer.split(`
2
+ `);this.buffer=q.pop()??"";for(let Q of q){let G=Q.trim();if(!G)continue;try{let X=JSON.parse(G);this.handleResponse(X)}catch{console.error(`[subprocess:${this.pluginInfo.name}] Invalid JSON: ${G.slice(0,100)}`)}}}handleResponse($){let q=this.pendingRequests.get($.id);if(!q){console.error(`[subprocess:${this.pluginInfo.name}] Unknown response ID: ${$.id}`);return}clearTimeout(q.timeout),this.pendingRequests.delete($.id),q.resolve($)}handleClose($,q){this.process=null;for(let[Q,G]of this.pendingRequests)clearTimeout(G.timeout),G.reject(Error(`Plugin process exited with code ${$}, signal ${q}`));if(this.pendingRequests.clear(),this.initialized&&this.restartCount<(this.config.maxRestarts??Rq))this.restartCount++,console.warn(`[subprocess:${this.pluginInfo.name}] Process crashed, restarting (${this.restartCount}/${this.config.maxRestarts??Rq})`),this.spawn().then(()=>this.initialize()).catch((Q)=>{console.error(`[subprocess:${this.pluginInfo.name}] Restart failed: ${Q.message}`)})}handleError($){console.error(`[subprocess:${this.pluginInfo.name}] Process error: ${$.message}`);for(let[q,Q]of this.pendingRequests)clearTimeout(Q.timeout),Q.reject($);this.pendingRequests.clear()}nextId(){return String(++this.requestId)}async sendRequest($,q=this.config.timeoutMs??V0){if(!this.process?.stdin)throw Error("Plugin process not running");return new Promise((Q,G)=>{let X=setTimeout(()=>{this.pendingRequests.delete($.id),G(Error(`Request timed out after ${q}ms`))},q);this.pendingRequests.set($.id,{resolve:Q,reject:G,timeout:X});let J=`${JSON.stringify($)}
3
3
  `;this.process?.stdin?.write(J)})}sendEvent($){if(!this.process?.stdin)return;let q=JSON.stringify({type:"event",event:$});this.process.stdin.write(`${q}
4
4
  `)}async callResolver($,q){if(!this.capabilities.resolvers.includes($))throw Error(`Resolver "${$}" not supported by plugin`);let Q={id:this.nextId(),type:"resolver",name:$,args:q},G=await this.sendRequest(Q);if(G.type==="error")throw Error(G.error.message);return G.result.value}async callHook($,q,Q){if(!this.capabilities.hooks.includes($))return Q;let G={id:this.nextId(),type:"hook",name:$,input:q,output:Q},X=await this.sendRequest(G);if(X.type==="error")throw Error(X.error.message);return X.result.output}async shutdown(){if(!this.process)return;try{this.process.stdin?.write(`${JSON.stringify({type:"shutdown"})}
5
- `)}catch{}let $=this.config.gracePeriodMs??S0;await new Promise((q)=>{let Q=setTimeout(()=>{if(this.process)this.process.kill("SIGKILL");q()},$);this.process?.on("close",()=>{clearTimeout(Q),q()})}),this.process=null}getPluginInfo(){return this.pluginInfo}getCapabilities(){return this.capabilities}isInitialized(){return this.initialized}}function Fq($){let q=$.getPluginInfo(),Q=$.getCapabilities(),G={};for(let H of Q.resolvers)G[H]=async(...Y)=>{return await $.callResolver(H,Y)};let X={};if(Q.hooks.includes("parse.after"))X["parse.after"]=async(H,Y)=>{let W=await $.callHook("parse.after",{file:H.file,path:H.path},{file:Y.file});if(W.file)Y.file=W.file};if(Q.hooks.includes("request.before"))X["request.before"]=async(H,Y)=>{let W=await $.callHook("request.before",{request:H.request,variables:H.variables,ctx:I$(H.ctx)},{request:Y.request});if(W.request)Y.request=W.request;let B=W.skip;if(typeof B==="boolean")Y.skip=B};if(Q.hooks.includes("request.compiled"))X["request.compiled"]=async(H,Y)=>{let W=await $.callHook("request.compiled",{request:H.request,variables:H.variables,ctx:I$(H.ctx)},{request:Y.request});if(W.request)Y.request=W.request};if(Q.hooks.includes("request.after"))X["request.after"]=async(H)=>{await $.callHook("request.after",{request:H.request,ctx:I$(H.ctx)},{})};if(Q.hooks.includes("response.after"))X["response.after"]=async(H,Y)=>{let W={status:H.response.status,statusText:H.response.statusText,headers:Object.fromEntries(H.response.headers.entries())},B=await $.callHook("response.after",{request:H.request,response:W,timing:H.timing,ctx:I$(H.ctx)},{}),A=B.status,K=B.statusText,N=B.headers,b=B.retry;if(typeof A==="number")Y.status=A;if(typeof K==="string")Y.statusText=K;if(N&&typeof N==="object")Y.headers=N;if(b&&typeof b==="object")Y.retry=b};if(Q.hooks.includes("error"))X.error=async(H,Y)=>{let W=await $.callHook("error",{request:H.request,error:{message:H.error.message,code:H.error.code},ctx:I$(H.ctx)},{}),B=W.error,A=W.retry,K=W.suppress;if(B&&typeof B==="object"&&"message"in B)Y.error=Error(B.message);if(A&&typeof A==="object")Y.retry=A;if(typeof K==="boolean")Y.suppress=K};let J=Q.hooks.length>0?async({event:H})=>{$.sendEvent(H)}:void 0;return g$({name:q.name,instanceId:"default",teardown:async()=>{await $.shutdown()}}).ifDefined("version",q.version).ifDefined("permissions",q.permissions).ifDefined("resolvers",Object.keys(G).length>0?G:void 0).ifDefined("hooks",Object.keys(X).length>0?X:void 0).ifDefined("event",J).build()}function I$($){return g$({retries:$.retries,maxRetries:$.maxRetries,session:{id:$.session.id,variables:$.session.variables},variables:$.variables,config:{projectRoot:$.config.projectRoot,variables:$.config.variables,security:$.config.security},projectRoot:$.projectRoot}).ifDefined("enterprise",$.enterprise?{org:$.enterprise.org,user:$.enterprise.user,team:$.enterprise.team,session:{id:$.enterprise.session.id,startedAt:$.enterprise.session.startedAt.toISOString(),source:$.enterprise.session.source,token:$.enterprise.session.token}}:void 0).build()}async function $q($,q){let Q=new e$($,q);await Q.start();let G=Q.getPluginInfo();return{plugin:Fq(Q),id:`${G.name}#default`,source:"subprocess",permissions:G.permissions??[],initialized:!0}}var m$=30000;async function bq($,q,Q){let G,X=new Promise((J,H)=>{G=setTimeout(()=>H(Error(Q)),q)});try{return await Promise.race([$,X])}finally{if(G!==void 0)clearTimeout(G)}}class qq{options;plugins=[];resolvers={};commands={};middleware=[];tools={};warnings=[];initialized=!1;config;onEvent;enterprise;secrets;session;constructor($){this.options=$;if(this.config={projectRoot:$.projectRoot,variables:{},security:{allowExternalFiles:!1,allowPluginsOutsideProject:$.security?.allowPluginsOutsideProject??!1}},$.onEvent!==void 0)this.onEvent=$.onEvent;if($.enterprise!==void 0)this.enterprise=$.enterprise;if($.secrets!==void 0)this.secrets=$.secrets;this.session={id:crypto.randomUUID(),variables:{}}}setEventSink($){this.onEvent=$}async initialize(){if(this.initialized)return;let $=this.options.plugins??[],q=await i$({projectRoot:this.options.projectRoot,plugins:$,warnings:this.warnings,...this.options.security!==void 0?{security:this.options.security}:{},...this.options.pluginPermissions!==void 0?{pluginPermissions:this.options.pluginPermissions}:{}});for(let Q of q.plugins)await this.initializePlugin(Q);this.initialized=!0}async initializePlugin($){let q=Date.now();try{if($.source==="subprocess"&&"_subprocessConfig"in $){let X=$._subprocessConfig,J=await $q(X,this.options.projectRoot);$.plugin=J.plugin,$.permissions=J.permissions,$.id=J.id}this.emitPluginEvent({type:"pluginLoaded",name:$.plugin.name,source:$.source,...$.plugin.version!==void 0?{version:$.plugin.version}:{}});let Q=s$({plugin:$.plugin,permissions:$.permissions,config:this.config,...this.enterprise!==void 0?{enterprise:this.enterprise}:{},...this.secrets!==void 0?{secrets:this.secrets}:{}});if($.plugin.setup)await $.plugin.setup(Q);$.initialized=!0,this.registerPluginContributions($);let G=Date.now()-q;this.emitPluginEvent({type:"pluginInitialized",name:$.plugin.name,durationMs:G}),this.plugins.push($)}catch(Q){let G=Q instanceof Error?Q.message:String(Q);this.warnings.push(`Plugin "${$.plugin.name}" setup failed: ${G}`),this.emitPluginEvent({type:"pluginError",name:$.plugin.name,stage:"setup",message:G,recoverable:!0})}}registerPluginContributions($){let q=$.plugin;if(q.resolvers)for(let[Q,G]of Object.entries(q.resolvers)){if(this.resolvers[Q])this.warnings.push(`Resolver "${Q}" from "${q.name}" shadows existing resolver`);this.resolvers[Q]=G}if(q.commands)for(let[Q,G]of Object.entries(q.commands)){if(this.commands[Q]){this.warnings.push(`Command "${Q}" from "${q.name}" shadows same command from "${this.commands[Q].pluginName}" (loaded first, takes precedence)`);continue}this.commands[Q]={handler:G,pluginName:q.name}}if(q.middleware)for(let Q of q.middleware)this.middleware.push({fn:Q,pluginName:q.name});if(q.tools)for(let[Q,G]of Object.entries(q.tools)){if(this.tools[Q])this.warnings.push(`Tool "${Q}" from "${q.name}" shadows existing tool`);this.tools[Q]={definition:G,pluginName:q.name}}}async teardown(){for(let $=this.plugins.length-1;$>=0;$--){let q=this.plugins[$];if(!q)continue;try{if(q.plugin.teardown)await q.plugin.teardown();this.emitPluginEvent({type:"pluginTeardown",name:q.plugin.name})}catch(Q){let G=Q instanceof Error?Q.message:String(Q);this.warnings.push(`Plugin "${q.plugin.name}" teardown failed: ${G}`),this.emitPluginEvent({type:"pluginError",name:q.plugin.name,stage:"teardown",message:G,recoverable:!0})}}this.plugins=[],this.initialized=!1}createHookContext($){return{retries:$.retries??0,maxRetries:$.maxRetries??3,session:this.session,variables:$.variables??{},config:this.config,projectRoot:this.options.projectRoot,...this.enterprise!==void 0?{enterprise:this.enterprise}:{}}}async triggerParseAfter($,q){return await this.executeHook("parse.after",$,q)}async triggerRequestBefore($,q){let Q=await this.executeHook("request.before",$,q);return{...Q,...Q.output.skip!==void 0?{skip:Q.output.skip}:{}}}async triggerRequestCompiled($,q){return await this.executeHook("request.compiled",$,q)}async triggerRequestAfter($){await this.executeReadOnlyHook("request.after",$)}async triggerResponseAfter($,q){let Q=await this.executeHook("response.after",$,q);return{...Q,...Q.output.retry!==void 0?{retry:Q.output.retry}:{}}}async triggerError($,q){let Q=await this.executeHook("error",$,q);return{...Q,...Q.output.retry!==void 0?{retry:Q.output.retry}:{}}}async executeHook($,q,Q){let G=!1,X="ctx"in q?q.ctx:this.createHookContext({});for(let J of this.plugins){let H=J.plugin.hooks?.[$];if(!H)continue;let Y=Date.now(),W=JSON.stringify(Q);this.emitPluginEvent({type:"pluginHookStarted",name:J.plugin.name,hook:$,ctx:X});try{let B=Promise.resolve(H(q,Q));await bq(B,m$,`Hook "${$}" in "${J.plugin.name}" timed out after ${m$}ms`);let A=JSON.stringify(Q),K=W!==A;if(K)G=!0;let N=Date.now()-Y;this.emitPluginEvent({type:"pluginHookFinished",name:J.plugin.name,hook:$,durationMs:N,modified:K,ctx:X})}catch(B){let A=B instanceof Error?B.message:String(B);this.warnings.push(`Hook "${$}" in "${J.plugin.name}" failed: ${A}`),this.emitPluginEvent({type:"pluginError",name:J.plugin.name,stage:"hook",hook:$,message:A,recoverable:!0})}}return{output:Q,modified:G}}async executeReadOnlyHook($,q){let Q="ctx"in q?q.ctx:this.createHookContext({});for(let G of this.plugins){let X=G.plugin.hooks?.[$];if(!X)continue;let J=Date.now();this.emitPluginEvent({type:"pluginHookStarted",name:G.plugin.name,hook:$,ctx:Q});try{let H=Promise.resolve(X(q));await bq(H,m$,`Hook "${$}" in "${G.plugin.name}" timed out after ${m$}ms`);let Y=Date.now()-J;this.emitPluginEvent({type:"pluginHookFinished",name:G.plugin.name,hook:$,durationMs:Y,modified:!1,ctx:Q})}catch(H){let Y=H instanceof Error?H.message:String(H);this.warnings.push(`Hook "${$}" in "${G.plugin.name}" failed: ${Y}`),this.emitPluginEvent({type:"pluginError",name:G.plugin.name,stage:"hook",hook:$,message:Y,recoverable:!0})}}}emitPluginEvent($){this.onEvent?.($);for(let q of this.plugins)if(q.plugin.event&&$.type!=="pluginLoaded");}emitEngineEvent($){this.onEvent?.($);for(let q of this.plugins)if(q.plugin.event)try{q.plugin.event({event:$})}catch{}}getResolvers(){return{...this.resolvers}}getResolver($){return this.resolvers[$]}async callResolver($,q){let Q=this.resolvers[$];if(!Q)return`{{${$}:ERROR}}`;let G=Date.now();try{let X=await Q(...q),J=Date.now()-G;return this.emitPluginEvent({type:"pluginResolverCalled",name:$,resolver:$,durationMs:J}),X}catch(X){let J=X instanceof Error?X.message:String(X);return this.warnings.push(`Resolver "${$}" failed: ${J}`),this.emitPluginEvent({type:"pluginError",name:"resolver",stage:"resolver",message:J,recoverable:!0}),`{{${$}:ERROR}}`}}getCommands(){let $={};for(let[q,{handler:Q}]of Object.entries(this.commands))$[q]=Q;return $}getCommand($){return this.commands[$]?.handler}getMiddleware(){return this.middleware.map(($)=>$.fn)}getTools(){let $={};for(let[q,{definition:Q}]of Object.entries(this.tools))$[q]=Q;return $}getPlugins(){return[...this.plugins]}getWarnings(){return[...this.warnings]}hasPlugins(){return this.plugins.length>0}getPlugin($){return this.plugins.find((q)=>q.plugin.name===$)}getPluginInfo(){return this.plugins.map(($)=>({name:$.plugin.name,source:$.source,permissions:$.permissions,...$.plugin.version!==void 0?{version:$.plugin.version}:{}}))}setSessionVariable($,q){this.session.variables[$]=q}getSessionVariables(){return{...this.session.variables}}}function Qq($){return new qq($)}function L0($){return $}function U0($){let{config:q,cookieStore:Q,onEvent:G}=$,X={};if(q.cookies.enabled&&Q)X.cookieStore=Q;if(X.headerDefaults=q.defaults.headers,X.resolvers=q.resolvers,G)X.onEvent=G;if(q.pluginManager){if(X.pluginManager=q.pluginManager,G)q.pluginManager.setEventSink(G)}let J={timeoutMs:q.defaults.timeoutMs,followRedirects:q.defaults.followRedirects,validateSSL:q.defaults.validateSSL};if(q.defaults.proxy)J.proxy=q.defaults.proxy;return{engineOptions:X,requestDefaults:J}}function vq($){let q=[],Q="code",G=0,X=()=>{while(q.length>0){let J=q[q.length-1];if(J===" "||J==="\t"){q.pop();continue}break}};while(G<$.length){let J=$.charAt(G),H=$[G+1];switch(Q){case"code":if(J==='"')q.push(J),Q="string",G++;else if(J==="/"&&H==="/")X(),Q="line-comment",G+=2;else if(J==="/"&&H==="*")Q="block-comment",G+=2;else q.push(J),G++;break;case"string":if(q.push(J),J==="\\"&&H!==void 0)q.push(H),G+=2;else if(J==='"')Q="code",G++;else G++;break;case"line-comment":if(J===`
5
+ `)}catch{}let $=this.config.gracePeriodMs??S0;await new Promise((q)=>{let Q=setTimeout(()=>{if(this.process)this.process.kill("SIGKILL");q()},$);this.process?.on("close",()=>{clearTimeout(Q),q()})}),this.process=null}getPluginInfo(){return this.pluginInfo}getCapabilities(){return this.capabilities}isInitialized(){return this.initialized}}function Fq($){let q=$.getPluginInfo(),Q=$.getCapabilities(),G={};for(let H of Q.resolvers)G[H]=async(...Y)=>{return await $.callResolver(H,Y)};let X={};if(Q.hooks.includes("parse.after"))X["parse.after"]=async(H,Y)=>{let W=await $.callHook("parse.after",{file:H.file,path:H.path},{file:Y.file});if(W.file)Y.file=W.file};if(Q.hooks.includes("request.before"))X["request.before"]=async(H,Y)=>{let W=await $.callHook("request.before",{request:H.request,variables:H.variables,ctx:I$(H.ctx)},{request:Y.request});if(W.request)Y.request=W.request;let B=W.skip;if(typeof B==="boolean")Y.skip=B};if(Q.hooks.includes("request.compiled"))X["request.compiled"]=async(H,Y)=>{let W=await $.callHook("request.compiled",{request:H.request,variables:H.variables,ctx:I$(H.ctx)},{request:Y.request});if(W.request)Y.request=W.request};if(Q.hooks.includes("request.after"))X["request.after"]=async(H)=>{await $.callHook("request.after",{request:H.request,ctx:I$(H.ctx)},{})};if(Q.hooks.includes("response.after"))X["response.after"]=async(H,Y)=>{let W={status:H.response.status,statusText:H.response.statusText,headers:Object.fromEntries(H.response.headers.entries())},B=await $.callHook("response.after",{request:H.request,response:W,timing:H.timing,ctx:I$(H.ctx)},{}),A=B.status,K=B.statusText,D=B.headers,O=B.retry;if(typeof A==="number")Y.status=A;if(typeof K==="string")Y.statusText=K;if(D&&typeof D==="object")Y.headers=D;if(O&&typeof O==="object")Y.retry=O};if(Q.hooks.includes("error"))X.error=async(H,Y)=>{let W=await $.callHook("error",{request:H.request,error:{message:H.error.message,code:H.error.code},ctx:I$(H.ctx)},{}),B=W.error,A=W.retry,K=W.suppress;if(B&&typeof B==="object"&&"message"in B)Y.error=Error(B.message);if(A&&typeof A==="object")Y.retry=A;if(typeof K==="boolean")Y.suppress=K};let J=Q.hooks.length>0?async({event:H})=>{$.sendEvent(H)}:void 0;return g$({name:q.name,instanceId:"default",teardown:async()=>{await $.shutdown()}}).ifDefined("version",q.version).ifDefined("permissions",q.permissions).ifDefined("resolvers",Object.keys(G).length>0?G:void 0).ifDefined("hooks",Object.keys(X).length>0?X:void 0).ifDefined("event",J).build()}function I$($){return g$({retries:$.retries,maxRetries:$.maxRetries,session:{id:$.session.id,variables:$.session.variables},variables:$.variables,config:{projectRoot:$.config.projectRoot,variables:$.config.variables,security:$.config.security},projectRoot:$.projectRoot}).ifDefined("enterprise",$.enterprise?{org:$.enterprise.org,user:$.enterprise.user,team:$.enterprise.team,session:{id:$.enterprise.session.id,startedAt:$.enterprise.session.startedAt.toISOString(),source:$.enterprise.session.source,token:$.enterprise.session.token}}:void 0).build()}async function $q($,q){let Q=new e$($,q);await Q.start();let G=Q.getPluginInfo();return{plugin:Fq(Q),id:`${G.name}#default`,source:"subprocess",permissions:G.permissions??[],initialized:!0}}var m$=30000;async function bq($,q,Q){let G,X=new Promise((J,H)=>{G=setTimeout(()=>H(Error(Q)),q)});try{return await Promise.race([$,X])}finally{if(G!==void 0)clearTimeout(G)}}class qq{options;plugins=[];resolvers={};commands={};middleware=[];tools={};warnings=[];initialized=!1;config;onEvent;enterprise;secrets;session;executionContext;reportSeq=0;reportScopeKey;constructor($){this.options=$;if(this.config={projectRoot:$.projectRoot,variables:{},security:{allowExternalFiles:!1,allowPluginsOutsideProject:$.security?.allowPluginsOutsideProject??!1}},$.onEvent!==void 0)this.onEvent=$.onEvent;if($.enterprise!==void 0)this.enterprise=$.enterprise;if($.secrets!==void 0)this.secrets=$.secrets;this.session={id:crypto.randomUUID(),variables:{},reports:[]},this.executionContext={runId:this.createRunId()},this.reportScopeKey=`run:${this.executionContext.runId}`}setEventSink($){this.onEvent=$}setExecutionContext($){let q=$.runId??this.executionContext.runId??this.createRunId(),Q=$.flowId?`flow:${$.flowId}`:`run:${q}`;if(Q!==this.reportScopeKey)this.reportScopeKey=Q,this.reportSeq=0;this.executionContext={runId:q,...$.flowId!==void 0?{flowId:$.flowId}:{},...$.reqExecId!==void 0?{reqExecId:$.reqExecId}:{},...$.now!==void 0?{now:$.now}:{},...$.nextSeq!==void 0?{nextSeq:$.nextSeq}:{}}}async initialize(){if(this.initialized)return;let $=this.options.plugins??[],q=await r$({projectRoot:this.options.projectRoot,plugins:$,warnings:this.warnings,...this.options.security!==void 0?{security:this.options.security}:{},...this.options.pluginPermissions!==void 0?{pluginPermissions:this.options.pluginPermissions}:{}});for(let Q of q.plugins)await this.initializePlugin(Q);this.initialized=!0}async initializePlugin($){let q=Date.now();try{if($.source==="subprocess"&&"_subprocessConfig"in $){let X=$._subprocessConfig,J=await $q(X,this.options.projectRoot);$.plugin=J.plugin,$.permissions=J.permissions,$.id=J.id}this.emitPluginEvent({type:"pluginLoaded",name:$.plugin.name,source:$.source,...$.plugin.version!==void 0?{version:$.plugin.version}:{}});let Q=s$({plugin:$.plugin,permissions:$.permissions,config:this.config,...this.enterprise!==void 0?{enterprise:this.enterprise}:{},...this.secrets!==void 0?{secrets:this.secrets}:{}});if($.plugin.setup)await $.plugin.setup(Q);$.initialized=!0,this.registerPluginContributions($);let G=Date.now()-q;this.emitPluginEvent({type:"pluginInitialized",name:$.plugin.name,durationMs:G}),this.plugins.push($)}catch(Q){let G=Q instanceof Error?Q.message:String(Q);this.warnings.push(`Plugin "${$.plugin.name}" setup failed: ${G}`),this.emitPluginEvent({type:"pluginError",name:$.plugin.name,stage:"setup",message:G,recoverable:!0})}}registerPluginContributions($){let q=$.plugin;if(q.resolvers)for(let[Q,G]of Object.entries(q.resolvers)){if(this.resolvers[Q])this.warnings.push(`Resolver "${Q}" from "${q.name}" shadows existing resolver`);this.resolvers[Q]=G}if(q.commands)for(let[Q,G]of Object.entries(q.commands)){if(this.commands[Q]){this.warnings.push(`Command "${Q}" from "${q.name}" shadows same command from "${this.commands[Q].pluginName}" (loaded first, takes precedence)`);continue}this.commands[Q]={handler:G,pluginName:q.name}}if(q.middleware)for(let Q of q.middleware)this.middleware.push({fn:Q,pluginName:q.name});if(q.tools)for(let[Q,G]of Object.entries(q.tools)){if(this.tools[Q])this.warnings.push(`Tool "${Q}" from "${q.name}" shadows existing tool`);this.tools[Q]={definition:G,pluginName:q.name}}}async teardown(){for(let $=this.plugins.length-1;$>=0;$--){let q=this.plugins[$];if(!q)continue;try{if(q.plugin.teardown)await q.plugin.teardown();this.emitPluginEvent({type:"pluginTeardown",name:q.plugin.name})}catch(Q){let G=Q instanceof Error?Q.message:String(Q);this.warnings.push(`Plugin "${q.plugin.name}" teardown failed: ${G}`),this.emitPluginEvent({type:"pluginError",name:q.plugin.name,stage:"teardown",message:G,recoverable:!0})}}this.plugins=[],this.initialized=!1}createHookContext($){let q=this.session;return{retries:$.retries??0,maxRetries:$.maxRetries??3,session:q,variables:$.variables??{},config:this.config,projectRoot:this.options.projectRoot,...this.enterprise!==void 0?{enterprise:this.enterprise}:{},report:(Q)=>{this.emitReport({pluginName:$.pluginName??"unknown",...$.requestName!==void 0?{requestName:$.requestName}:{},data:Q})}}}getReports(){return this.session.reports}createRunId(){return`run-${crypto.randomUUID()}`}nextSeq(){if(this.executionContext.nextSeq)return this.executionContext.nextSeq();return this.reportSeq+=1,this.reportSeq}now(){return this.executionContext.now?this.executionContext.now():Date.now()}emitReport($){try{JSON.stringify($.data)}catch{throw Error("Plugin report data must be JSON-serializable")}let q={pluginName:$.pluginName,runId:this.executionContext.runId??this.createRunId(),...this.executionContext.flowId!==void 0?{flowId:this.executionContext.flowId}:{},...this.executionContext.reqExecId!==void 0?{reqExecId:this.executionContext.reqExecId}:{},...$.requestName!==void 0?{requestName:$.requestName}:{},ts:this.now(),seq:this.nextSeq(),data:$.data};this.session.reports.push(q),this.emitPluginEvent({type:"pluginReport",report:q})}async triggerParseAfter($,q){return await this.executeHook("parse.after",$,q)}async triggerValidate($,q){return await this.executeHook("validate",$,q)}async triggerRequestBefore($,q){let Q=await this.executeHook("request.before",$,q);return{...Q,...Q.output.skip!==void 0?{skip:Q.output.skip}:{}}}async triggerRequestCompiled($,q){return await this.executeHook("request.compiled",$,q)}async triggerRequestAfter($){await this.executeReadOnlyHook("request.after",$)}async triggerResponseAfter($,q){let Q=await this.executeHook("response.after",$,q);return{...Q,...Q.output.retry!==void 0?{retry:Q.output.retry}:{}}}async triggerError($,q){let Q=await this.executeHook("error",$,q);return{...Q,...Q.output.retry!==void 0?{retry:Q.output.retry}:{}}}async executeHook($,q,Q){let G=!1,X="ctx"in q?q.ctx:this.createHookContext({}),J=q,H=J.request&&typeof J.request==="object"&&J.request!==null&&"name"in J.request?J.request.name??void 0:void 0;for(let Y of this.plugins){let W=Y.plugin.hooks?.[$];if(!W)continue;X.report=(K)=>{this.emitReport({pluginName:Y.plugin.name,...H!==void 0?{requestName:H}:{},data:K})};let B=Date.now(),A=JSON.stringify(Q);this.emitPluginEvent({type:"pluginHookStarted",name:Y.plugin.name,hook:$,ctx:X});try{let K=Promise.resolve(W(q,Q));await bq(K,m$,`Hook "${$}" in "${Y.plugin.name}" timed out after ${m$}ms`);let D=JSON.stringify(Q),O=A!==D;if(O)G=!0;let c=Date.now()-B;this.emitPluginEvent({type:"pluginHookFinished",name:Y.plugin.name,hook:$,durationMs:c,modified:O,ctx:X})}catch(K){let D=K instanceof Error?K.message:String(K);this.warnings.push(`Hook "${$}" in "${Y.plugin.name}" failed: ${D}`),this.emitPluginEvent({type:"pluginError",name:Y.plugin.name,stage:"hook",hook:$,message:D,recoverable:!0})}}return{output:Q,modified:G}}async executeReadOnlyHook($,q){let Q="ctx"in q?q.ctx:this.createHookContext({}),G=q,X=G.request&&typeof G.request==="object"&&G.request!==null&&"name"in G.request?G.request.name??void 0:void 0;for(let J of this.plugins){let H=J.plugin.hooks?.[$];if(!H)continue;Q.report=(W)=>{this.emitReport({pluginName:J.plugin.name,...X!==void 0?{requestName:X}:{},data:W})};let Y=Date.now();this.emitPluginEvent({type:"pluginHookStarted",name:J.plugin.name,hook:$,ctx:Q});try{let W=Promise.resolve(H(q));await bq(W,m$,`Hook "${$}" in "${J.plugin.name}" timed out after ${m$}ms`);let B=Date.now()-Y;this.emitPluginEvent({type:"pluginHookFinished",name:J.plugin.name,hook:$,durationMs:B,modified:!1,ctx:Q})}catch(W){let B=W instanceof Error?W.message:String(W);this.warnings.push(`Hook "${$}" in "${J.plugin.name}" failed: ${B}`),this.emitPluginEvent({type:"pluginError",name:J.plugin.name,stage:"hook",hook:$,message:B,recoverable:!0})}}}emitPluginEvent($){this.onEvent?.($);for(let q of this.plugins)if(q.plugin.event&&$.type!=="pluginLoaded");}emitEngineEvent($){this.onEvent?.($);for(let q of this.plugins)if(q.plugin.event)try{q.plugin.event({event:$})}catch{}}getResolvers(){return{...this.resolvers}}getResolver($){return this.resolvers[$]}async callResolver($,q){let Q=this.resolvers[$];if(!Q)return`{{${$}:ERROR}}`;let G=Date.now();try{let X=await Q(...q),J=Date.now()-G;return this.emitPluginEvent({type:"pluginResolverCalled",name:$,resolver:$,durationMs:J}),X}catch(X){let J=X instanceof Error?X.message:String(X);return this.warnings.push(`Resolver "${$}" failed: ${J}`),this.emitPluginEvent({type:"pluginError",name:"resolver",stage:"resolver",message:J,recoverable:!0}),`{{${$}:ERROR}}`}}getCommands(){let $={};for(let[q,{handler:Q}]of Object.entries(this.commands))$[q]=Q;return $}getCommand($){return this.commands[$]?.handler}getMiddleware(){return this.middleware.map(($)=>$.fn)}getTools(){let $={};for(let[q,{definition:Q}]of Object.entries(this.tools))$[q]=Q;return $}getPlugins(){return[...this.plugins]}getWarnings(){return[...this.warnings]}hasPlugins(){return this.plugins.length>0}getPlugin($){return this.plugins.find((q)=>q.plugin.name===$)}getPluginInfo(){return this.plugins.map(($)=>({name:$.plugin.name,source:$.source,permissions:$.permissions,...$.plugin.version!==void 0?{version:$.plugin.version}:{}}))}setSessionVariable($,q){this.session.variables[$]=q}getSessionVariables(){return{...this.session.variables}}}function Qq($){return new qq($)}function L0($){return $}function U0($){let{config:q,cookieStore:Q,onEvent:G}=$,X={};if(q.cookies.enabled&&Q)X.cookieStore=Q;if(X.headerDefaults=q.defaults.headers,X.resolvers=q.resolvers,G)X.onEvent=G;if(q.pluginManager){if(X.pluginManager=q.pluginManager,G)q.pluginManager.setEventSink(G)}let J={timeoutMs:q.defaults.timeoutMs,followRedirects:q.defaults.followRedirects,validateSSL:q.defaults.validateSSL};if(q.defaults.proxy)J.proxy=q.defaults.proxy;return{engineOptions:X,requestDefaults:J}}function vq($){let q=[],Q="code",G=0,X=()=>{while(q.length>0){let J=q[q.length-1];if(J===" "||J==="\t"){q.pop();continue}break}};while(G<$.length){let J=$.charAt(G),H=$[G+1];switch(Q){case"code":if(J==='"')q.push(J),Q="string",G++;else if(J==="/"&&H==="/")X(),Q="line-comment",G+=2;else if(J==="/"&&H==="*")Q="block-comment",G+=2;else q.push(J),G++;break;case"string":if(q.push(J),J==="\\"&&H!==void 0)q.push(H),G+=2;else if(J==='"')Q="code",G++;else G++;break;case"line-comment":if(J===`
6
6
  `||J==="\r")q.push(J),Q="code";G++;break;case"block-comment":if(J==="*"&&H==="/")Q="code",G+=2;else{if(J===`
7
- `||J==="\r")q.push(J);G++}break}}return q.join("")}function Gq($){let q=vq($);try{return JSON.parse(q)}catch(Q){if(Q instanceof SyntaxError)throw SyntaxError(`Invalid JSONC: ${Q.message}`);throw Q}}import{access as A0,readFile as Cq}from"node:fs/promises";import*as f from"node:path";import{pathToFileURL as K0}from"node:url";var O0=[{filename:"treq.jsonc",format:"jsonc"},{filename:"treq.json",format:"json"},{filename:"treq.config.ts",format:"ts"},{filename:"treq.config.js",format:"js"},{filename:"treq.config.mjs",format:"mjs"}];async function Xq($){try{return await A0($),!0}catch{return!1}}async function R0($,q,Q){let G=f.resolve($),X=Q?f.resolve(Q):void 0;while(!0){if(q){let H=f.join(G,q);if(await Xq(H)){let Y=Iq(q);return{path:H,format:Y}}}else for(let{filename:H,format:Y}of O0){let W=f.join(G,H);if(await Xq(W))return{path:W,format:Y}}if(X&&G===X)return;let J=f.dirname(G);if(J===G)return;G=J}}function Iq($){if($.endsWith(".jsonc"))return"jsonc";if($.endsWith(".json"))return"json";if($.endsWith(".ts"))return"ts";if($.endsWith(".mjs"))return"mjs";if($.endsWith(".js"))return"js";return"json"}function D0($){let q=f.basename($);return Iq(q)}async function j0($){let G=(await import(K0($).href)).default;if(!G||typeof G!=="object")throw Error(`Invalid config export from ${$}. Expected default object export.`);return G}async function N0($){let q=await Cq($,"utf-8"),Q=Gq(q);if(!Q||typeof Q!=="object")throw Error(`Invalid JSONC config at ${$}. Expected object.`);return Q}async function F0($){let q=await Cq($,"utf-8"),Q=JSON.parse(q);if(!Q||typeof Q!=="object")throw Error(`Invalid JSON config at ${$}. Expected object.`);return Q}async function b0($,q){switch(q){case"jsonc":return await N0($);case"json":return await F0($);case"ts":case"js":case"mjs":return await j0($);default:throw Error(`Unknown config format: ${q}`)}}async function Hq($){let q="filename"in $&&$.filename?$.filename:void 0,Q,G;if("path"in $){if(Q=f.resolve($.path),G=D0(Q),!await Xq(Q))return{config:{}}}else{let J=await R0($.startDir,q,$.stopDir);if(!J)return{config:{}};Q=J.path,G=J.format}let X=await b0(Q,G);return{path:Q,config:X,format:G}}function Jq($){return $==="ts"||$==="js"||$==="mjs"}function v0($,q){if(!$&&!q)return;if(!$)return q;if(!q)return $;return{...$,...q,headers:{...$.headers??{},...q.headers??{}}}}function l$($,q){let Q={},G={...$.variables??{},...q.variables??{}};if(Object.keys(G).length>0)Q.variables=G;let X={...$.resolvers??{},...q.resolvers??{}};if(Object.keys(X).length>0)Q.resolvers=X;let J=v0($.defaults,q.defaults);if(J)Q.defaults=J;let H={...$.cookies??{},...q.cookies??{}};if(Object.keys(H).length>0)Q.cookies=H;let Y={...$.security??{},...q.security??{}};if(Object.keys(Y).length>0)Q.security=Y;if($.profiles)Q.profiles=$.profiles;return Q}function c$($){let q={};if($.defaults)q=l$(q,$.defaults);if($.file)q=l$(q,$.file);if($.overrides)q=l$(q,$.overrides);return q}function Yq($,q){if(!q)return $;let Q=$.profiles??{},G=Q[q];if(!G){let J=Object.keys(Q),H=J.length>0?` Available profiles: ${J.join(", ")}`:"";throw Error(`Profile "${q}" not found.${H}`)}let X={};if($.variables)X.variables=$.variables;if($.defaults)X.defaults=$.defaults;if($.cookies)X.cookies=$.cookies;if($.resolvers)X.resolvers=$.resolvers;if($.security)X.security=$.security;return l$(X,G)}function C0($){let q=$.profiles??{};return Object.keys(q).sort()}import{existsSync as r0}from"node:fs";import*as j from"node:path";import{spawn as I0}from"node:child_process";var k0=2000,T0=500,P0=1048576,f0=65536;async function h0($,q,Q,G){let X=$.timeoutMs??k0;if($.command.length===0)throw Error(`Resolver "${q}" has empty command array`);let[J,...H]=$.command;if(!J)throw Error(`Resolver "${q}" has empty command`);return new Promise((Y,W)=>{let B=I0(J,H,{cwd:G,stdio:["pipe","pipe","pipe"],env:process.env}),A="",K="",N=0,b=0,K$=!1,n=!1,h=!1,O$=!1,T$=setTimeout(()=>{O$=!0,B.kill("SIGTERM"),setTimeout(()=>{if(!h)B.kill("SIGKILL")},T0)},X);B.stdout?.on("data",(x)=>{let y=P0-N;if(y>0){let Z=x.slice(0,y);if(A+=Z.toString("utf-8"),N+=Z.length,Z.length<x.length)K$=!0}else K$=!0}),B.stderr?.on("data",(x)=>{let y=f0-b;if(y>0){let Z=x.slice(0,y);if(K+=Z.toString("utf-8"),b+=Z.length,Z.length<x.length)n=!0}else n=!0}),B.on("close",(x,y)=>{if(clearTimeout(T$),h=!0,O$){W(Error(`Resolver "${q}" timed out after ${X}ms${K?`: ${K}`:""}`));return}if(x!==0){let s=y?`killed by signal ${y}`:`exit code ${x}`;W(Error(`Resolver "${q}" failed (${s})${K?`: ${K}`:""}`));return}let Z=A.trim();if(!Z){W(Error(`Resolver "${q}" returned no output`));return}let Wq=Z.split(/\r?\n/).map((s)=>s.trim()).find((s)=>s.length>0)??"",u$;try{u$=JSON.parse(Wq)}catch{let s=K$?" (stdout exceeded 1MB limit and was truncated)":"";W(Error(`Resolver "${q}" returned invalid JSON: ${Wq.slice(0,100)}${s}`));return}if(typeof u$.value!=="string"){W(Error(`Resolver "${q}" returned no value (expected { "value": "..." })`));return}Y(u$.value)}),B.on("error",(x)=>{clearTimeout(T$);let y=n?" (stderr exceeded 64KB limit and was truncated)":"";W(Error(`Resolver "${q}" failed to execute: ${x.message}${y}`))});let Zq={resolver:q,args:Q};B.stdin?.write(`${JSON.stringify(Zq)}
8
- `),B.stdin?.end()})}function kq($,q,Q){let G=Q??"$command";return async(...X)=>{return await h0($,G,X,q)}}function Tq($){if(!$||typeof $!=="object")return!1;let q=$;return q.type==="command"&&Array.isArray(q.command)}import{accessSync as x0,readFileSync as y0,realpathSync as Z0}from"node:fs";import*as fq from"node:os";import*as v from"node:path";var g0=/\{env:([^}]+)\}/g,m0=/\{file:([^}]+)\}/g;function l0($){if($.startsWith("~/")||$==="~")return v.join(fq.homedir(),$.slice(1));return $}function c0($,q){let Q=v.resolve($),G=v.resolve(q),X=v.relative(G,Q);if(X==="")return!0;if(v.isAbsolute(X))return!1;if(X.startsWith(".."))return!1;return!0}function Pq($){try{return Z0($)}catch{return v.resolve($)}}function u0($){try{return x0($),!0}catch{return!1}}function p0($){return $.replace(g0,(q,Q)=>{return process.env[Q]??""})}function n0($,q){return $.replace(m0,(Q,G)=>{let X=l0(G.trim());if(!v.isAbsolute(X))X=v.resolve(q.configDir,X);if(!u0(X))throw Error(`Config substitution failed: {file:${G}} not found at ${X}`);let J=Pq(q.workspaceRoot),H=Pq(X);if(!q.allowExternalFiles){if(!c0(H,J))throw Error(`Config substitution failed: {file:${G}} outside workspace (use security.allowExternalFiles to allow)`)}try{return y0(H,"utf-8").trimEnd()}catch(Y){throw Error(`Config substitution failed: {file:${G}} could not be read: ${Y instanceof Error?Y.message:String(Y)}`)}})}function d0($,q){let Q=p0($);return Q=n0(Q,q),Q}function k$($,q){if($===null||$===void 0)return $;if(typeof $==="string")return d0($,q);if(Array.isArray($))return $.map((Q)=>k$(Q,q));if(typeof $==="object"){let Q={};for(let[G,X]of Object.entries($))Q[G]=k$(X,q);return Q}return $}var hq=30000,xq=!0,yq=!0;function i0($,q){let Q=j.resolve($),G=q?j.resolve(q):void 0,{root:X}=j.parse(Q);while(!0){let J=j.join(Q,".git");if(r0(J))return Q;if(G&&Q===G)return;if(Q===X)return;let H=j.dirname(Q);if(H===Q)return;Q=H}}function o0($,q,Q){if($)return j.dirname($);let G=Q?j.resolve(Q):void 0;return i0(q,G)??G??j.resolve(q)}function a0($){let q=$?.enabled!==!1,Q=$?.jarPath,G;if(!q)G="disabled";else if(Q)G="persistent";else G="memory";let X={enabled:q,mode:G};if(Q)X.jarPath=Q;return X}function s0($){let q={timeoutMs:$?.timeoutMs??hq,followRedirects:$?.followRedirects??xq,validateSSL:$?.validateSSL??yq,headers:$?.headers??{}};if($?.proxy)q.proxy=$.proxy;return q}function t0($,q){if(!$)return{};let Q={};for(let[G,X]of Object.entries($))if(typeof X==="function")Q[G]=X;else if(Tq(X))Q[G]=kq(X,q,G);else throw Error(`Unknown resolver type for "${G}". Expected function or { type: "command", command: [...] }`);return Q}async function e0($){let q=[],Q=[],G={startDir:$.startDir};if($.stopDir)G.stopDir=$.stopDir;let X=await Hq(G),J=$.stopDir?j.resolve($.stopDir):void 0,H=o0(X.path,$.startDir,J);if(X.path&&Jq(X.format))q.push(`${j.basename(X.path)} is deprecated; migrate to treq.jsonc`);let Y={};if(X.config&&Object.keys(X.config).length>0)Q.push("file"),Y=X.config;if($.profile)Y=Yq(Y,$.profile),Q.push(`profile:${$.profile}`);for(let h of $.overrideLayers??[]){if(!h||!h.overrides||Object.keys(h.overrides).length===0)continue;Y=c$({file:Y,overrides:h.overrides}),Q.push(h.name)}if($.overrides&&Object.keys($.overrides).length>0)Y=c$({file:Y,overrides:$.overrides}),Q.push($.overridesLayerName??"overrides");let W=J??H,B=X.path?j.dirname(X.path):H,A=Y.security?.allowExternalFiles??!1;Y=k$(Y,{configDir:B,workspaceRoot:W,allowExternalFiles:A});let K=t0(Y.resolvers,H),N=$1(X.config?.plugins,$.profile?X.config?.profiles?.[$.profile]?.plugins:void 0),b;if(N.length>0){b=Qq({projectRoot:H,plugins:N,security:{allowPluginsOutsideProject:Y.security?.allowPluginsOutsideProject??!1},...Y.security?.pluginPermissions!==void 0?{pluginPermissions:Y.security.pluginPermissions}:{}}),await b.initialize();let h=b.getResolvers();for(let[O$,T$]of Object.entries(h))if(!K[O$])K[O$]=T$;q.push(...b.getWarnings())}let K$={projectRoot:H,variables:Y.variables??{},defaults:s0(Y.defaults),cookies:a0(Y.cookies),resolvers:K,security:{allowExternalFiles:Y.security?.allowExternalFiles??!1,allowPluginsOutsideProject:Y.security?.allowPluginsOutsideProject??!1,...Y.security?.pluginPermissions!==void 0?{pluginPermissions:Y.security.pluginPermissions}:{}},...b!==void 0?{pluginManager:b}:{}},n={projectRoot:H,layersApplied:Q,warnings:q};if(X.path)n.configPath=X.path;if(X.format)n.format=X.format;if($.profile)n.profile=$.profile;return{config:K$,meta:n}}function $1($,q){if(!$&&!q)return[];if(!$)return q??[];if(!q)return $;return o$($,q)}export{vq as stripJsonComments,e0 as resolveProjectConfig,Gq as parseJsonc,c$ as mergeConfig,Hq as loadConfig,C0 as listProfiles,Jq as isLegacyFormat,L0 as defineConfig,U0 as buildEngineOptions,k$ as applySubstitutions,Yq as applyProfile,yq as DEFAULT_VALIDATE_SSL,hq as DEFAULT_TIMEOUT_MS,xq as DEFAULT_FOLLOW_REDIRECTS};
7
+ `||J==="\r")q.push(J);G++}break}}return q.join("")}function Gq($){let q=vq($);try{return JSON.parse(q)}catch(Q){if(Q instanceof SyntaxError)throw SyntaxError(`Invalid JSONC: ${Q.message}`);throw Q}}import{access as A0,readFile as Cq}from"node:fs/promises";import*as f from"node:path";import{pathToFileURL as K0}from"node:url";var O0=[{filename:"treq.jsonc",format:"jsonc"},{filename:"treq.json",format:"json"},{filename:"treq.config.ts",format:"ts"},{filename:"treq.config.js",format:"js"},{filename:"treq.config.mjs",format:"mjs"}];async function Xq($){try{return await A0($),!0}catch{return!1}}async function D0($,q,Q){let G=f.resolve($),X=Q?f.resolve(Q):void 0;while(!0){if(q){let H=f.join(G,q);if(await Xq(H)){let Y=Iq(q);return{path:H,format:Y}}}else for(let{filename:H,format:Y}of O0){let W=f.join(G,H);if(await Xq(W))return{path:W,format:Y}}if(X&&G===X)return;let J=f.dirname(G);if(J===G)return;G=J}}function Iq($){if($.endsWith(".jsonc"))return"jsonc";if($.endsWith(".json"))return"json";if($.endsWith(".ts"))return"ts";if($.endsWith(".mjs"))return"mjs";if($.endsWith(".js"))return"js";return"json"}function N0($){let q=f.basename($);return Iq(q)}async function j0($){let G=(await import(K0($).href)).default;if(!G||typeof G!=="object")throw Error(`Invalid config export from ${$}. Expected default object export.`);return G}async function R0($){let q=await Cq($,"utf-8"),Q=Gq(q);if(!Q||typeof Q!=="object")throw Error(`Invalid JSONC config at ${$}. Expected object.`);return Q}async function F0($){let q=await Cq($,"utf-8"),Q=JSON.parse(q);if(!Q||typeof Q!=="object")throw Error(`Invalid JSON config at ${$}. Expected object.`);return Q}async function b0($,q){switch(q){case"jsonc":return await R0($);case"json":return await F0($);case"ts":case"js":case"mjs":return await j0($);default:throw Error(`Unknown config format: ${q}`)}}async function Hq($){let q="filename"in $&&$.filename?$.filename:void 0,Q,G;if("path"in $){if(Q=f.resolve($.path),G=N0(Q),!await Xq(Q))return{config:{}}}else{let J=await D0($.startDir,q,$.stopDir);if(!J)return{config:{}};Q=J.path,G=J.format}let X=await b0(Q,G);return{path:Q,config:X,format:G}}function Jq($){return $==="ts"||$==="js"||$==="mjs"}function v0($,q){if(!$&&!q)return;if(!$)return q;if(!q)return $;return{...$,...q,headers:{...$.headers??{},...q.headers??{}}}}function l$($,q){let Q={},G={...$.variables??{},...q.variables??{}};if(Object.keys(G).length>0)Q.variables=G;let X={...$.resolvers??{},...q.resolvers??{}};if(Object.keys(X).length>0)Q.resolvers=X;let J=v0($.defaults,q.defaults);if(J)Q.defaults=J;let H={...$.cookies??{},...q.cookies??{}};if(Object.keys(H).length>0)Q.cookies=H;let Y={...$.security??{},...q.security??{}};if(Object.keys(Y).length>0)Q.security=Y;if($.profiles)Q.profiles=$.profiles;return Q}function c$($){let q={};if($.defaults)q=l$(q,$.defaults);if($.file)q=l$(q,$.file);if($.overrides)q=l$(q,$.overrides);return q}function Yq($,q){if(!q)return $;let Q=$.profiles??{},G=Q[q];if(!G){let J=Object.keys(Q),H=J.length>0?` Available profiles: ${J.join(", ")}`:"";throw Error(`Profile "${q}" not found.${H}`)}let X={};if($.variables)X.variables=$.variables;if($.defaults)X.defaults=$.defaults;if($.cookies)X.cookies=$.cookies;if($.resolvers)X.resolvers=$.resolvers;if($.security)X.security=$.security;return l$(X,G)}function C0($){let q=$.profiles??{};return Object.keys(q).sort()}import{existsSync as i0}from"node:fs";import*as F from"node:path";import{spawn as I0}from"node:child_process";var k0=2000,T0=500,P0=1048576,f0=65536;async function h0($,q,Q,G){let X=$.timeoutMs??k0;if($.command.length===0)throw Error(`Resolver "${q}" has empty command array`);let[J,...H]=$.command;if(!J)throw Error(`Resolver "${q}" has empty command`);return new Promise((Y,W)=>{let B=I0(J,H,{cwd:G,stdio:["pipe","pipe","pipe"],env:process.env}),A="",K="",D=0,O=0,c=!1,d=!1,h=!1,O$=!1,T$=setTimeout(()=>{O$=!0,B.kill("SIGTERM"),setTimeout(()=>{if(!h)B.kill("SIGKILL")},T0)},X);B.stdout?.on("data",(x)=>{let y=P0-D;if(y>0){let Z=x.slice(0,y);if(A+=Z.toString("utf-8"),D+=Z.length,Z.length<x.length)c=!0}else c=!0}),B.stderr?.on("data",(x)=>{let y=f0-O;if(y>0){let Z=x.slice(0,y);if(K+=Z.toString("utf-8"),O+=Z.length,Z.length<x.length)d=!0}else d=!0}),B.on("close",(x,y)=>{if(clearTimeout(T$),h=!0,O$){W(Error(`Resolver "${q}" timed out after ${X}ms${K?`: ${K}`:""}`));return}if(x!==0){let e=y?`killed by signal ${y}`:`exit code ${x}`;W(Error(`Resolver "${q}" failed (${e})${K?`: ${K}`:""}`));return}let Z=A.trim();if(!Z){W(Error(`Resolver "${q}" returned no output`));return}let Wq=Z.split(/\r?\n/).map((e)=>e.trim()).find((e)=>e.length>0)??"",u$;try{u$=JSON.parse(Wq)}catch{let e=c?" (stdout exceeded 1MB limit and was truncated)":"";W(Error(`Resolver "${q}" returned invalid JSON: ${Wq.slice(0,100)}${e}`));return}if(typeof u$.value!=="string"){W(Error(`Resolver "${q}" returned no value (expected { "value": "..." })`));return}Y(u$.value)}),B.on("error",(x)=>{clearTimeout(T$);let y=d?" (stderr exceeded 64KB limit and was truncated)":"";W(Error(`Resolver "${q}" failed to execute: ${x.message}${y}`))});let Zq={resolver:q,args:Q};B.stdin?.write(`${JSON.stringify(Zq)}
8
+ `),B.stdin?.end()})}function kq($,q,Q){let G=Q??"$command";return async(...X)=>{return await h0($,G,X,q)}}function Tq($){if(!$||typeof $!=="object")return!1;let q=$;return q.type==="command"&&Array.isArray(q.command)}import{accessSync as x0,readFileSync as y0,realpathSync as Z0}from"node:fs";import*as fq from"node:os";import*as v from"node:path";var g0=/\{env:([^}]+)\}/g,m0=/\{file:([^}]+)\}/g;function l0($){if($.startsWith("~/")||$==="~")return v.join(fq.homedir(),$.slice(1));return $}function c0($,q){let Q=v.resolve($),G=v.resolve(q),X=v.relative(G,Q);if(X==="")return!0;if(v.isAbsolute(X))return!1;if(X.startsWith(".."))return!1;return!0}function Pq($){try{return Z0($)}catch{return v.resolve($)}}function u0($){try{return x0($),!0}catch{return!1}}function p0($){return $.replace(g0,(q,Q)=>{return process.env[Q]??""})}function n0($,q){return $.replace(m0,(Q,G)=>{let X=l0(G.trim());if(!v.isAbsolute(X))X=v.resolve(q.configDir,X);if(!u0(X))throw Error(`Config substitution failed: {file:${G}} not found at ${X}`);let J=Pq(q.workspaceRoot),H=Pq(X);if(!q.allowExternalFiles){if(!c0(H,J))throw Error(`Config substitution failed: {file:${G}} outside workspace (use security.allowExternalFiles to allow)`)}try{return y0(H,"utf-8").trimEnd()}catch(Y){throw Error(`Config substitution failed: {file:${G}} could not be read: ${Y instanceof Error?Y.message:String(Y)}`)}})}function d0($,q){let Q=p0($);return Q=n0(Q,q),Q}function k$($,q){if($===null||$===void 0)return $;if(typeof $==="string")return d0($,q);if(Array.isArray($))return $.map((Q)=>k$(Q,q));if(typeof $==="object"){let Q={};for(let[G,X]of Object.entries($))Q[G]=k$(X,q);return Q}return $}var hq=30000,xq=!0,yq=!0;function r0($,q){let Q=F.resolve($),G=q?F.resolve(q):void 0,{root:X}=F.parse(Q);while(!0){let J=F.join(Q,".git");if(i0(J))return Q;if(G&&Q===G)return;if(Q===X)return;let H=F.dirname(Q);if(H===Q)return;Q=H}}function a0($,q,Q){if($)return F.dirname($);let G=Q?F.resolve(Q):void 0;return r0(q,G)??G??F.resolve(q)}function o0($){let q=$?.enabled!==!1,Q=$?.jarPath,G;if(!q)G="disabled";else if(Q)G="persistent";else G="memory";let X={enabled:q,mode:G};if(Q)X.jarPath=Q;return X}function s0($){let q={timeoutMs:$?.timeoutMs??hq,followRedirects:$?.followRedirects??xq,validateSSL:$?.validateSSL??yq,headers:$?.headers??{}};if($?.proxy)q.proxy=$.proxy;return q}function t0($,q){if(!$)return{};let Q={};for(let[G,X]of Object.entries($))if(typeof X==="function")Q[G]=X;else if(Tq(X))Q[G]=kq(X,q,G);else throw Error(`Unknown resolver type for "${G}". Expected function or { type: "command", command: [...] }`);return Q}async function e0($){let q=[],Q=[],G={startDir:$.startDir};if($.stopDir)G.stopDir=$.stopDir;let X=await Hq(G),J=$.stopDir?F.resolve($.stopDir):void 0,H=a0(X.path,$.startDir,J);if(X.path&&Jq(X.format))q.push(`${F.basename(X.path)} is deprecated; migrate to treq.jsonc`);let Y={};if(X.config&&Object.keys(X.config).length>0)Q.push("file"),Y=X.config;if($.profile)Y=Yq(Y,$.profile),Q.push(`profile:${$.profile}`);for(let h of $.overrideLayers??[]){if(!h||!h.overrides||Object.keys(h.overrides).length===0)continue;Y=c$({file:Y,overrides:h.overrides}),Q.push(h.name)}if($.overrides&&Object.keys($.overrides).length>0)Y=c$({file:Y,overrides:$.overrides}),Q.push($.overridesLayerName??"overrides");let W=J??H,B=X.path?F.dirname(X.path):H,A=Y.security?.allowExternalFiles??!1;Y=k$(Y,{configDir:B,workspaceRoot:W,allowExternalFiles:A});let K=t0(Y.resolvers,H),D=$1(X.config?.plugins,$.profile?X.config?.profiles?.[$.profile]?.plugins:void 0),O;if(D.length>0){O=Qq({projectRoot:H,plugins:D,security:{allowPluginsOutsideProject:Y.security?.allowPluginsOutsideProject??!1},...Y.security?.pluginPermissions!==void 0?{pluginPermissions:Y.security.pluginPermissions}:{}}),await O.initialize();let h=O.getResolvers();for(let[O$,T$]of Object.entries(h))if(!K[O$])K[O$]=T$;q.push(...O.getWarnings())}let c={projectRoot:H,variables:Y.variables??{},defaults:s0(Y.defaults),cookies:o0(Y.cookies),resolvers:K,security:{allowExternalFiles:Y.security?.allowExternalFiles??!1,allowPluginsOutsideProject:Y.security?.allowPluginsOutsideProject??!1,...Y.security?.pluginPermissions!==void 0?{pluginPermissions:Y.security.pluginPermissions}:{}},...O!==void 0?{pluginManager:O}:{}},d={projectRoot:H,layersApplied:Q,warnings:q};if(X.path)d.configPath=X.path;if(X.format)d.format=X.format;if($.profile)d.profile=$.profile;return{config:c,meta:d}}function $1($,q){if(!$&&!q)return[];if(!$)return q??[];if(!q)return $;return a$($,q)}export{vq as stripJsonComments,e0 as resolveProjectConfig,Gq as parseJsonc,c$ as mergeConfig,Hq as loadConfig,C0 as listProfiles,Jq as isLegacyFormat,L0 as defineConfig,U0 as buildEngineOptions,k$ as applySubstitutions,Yq as applyProfile,yq as DEFAULT_VALIDATE_SSL,hq as DEFAULT_TIMEOUT_MS,xq as DEFAULT_FOLLOW_REDIRECTS};
9
9
 
10
- //# debugId=2013DC71184054E564756E2164756E21
10
+ //# debugId=21B4C0DDC9180CED64756E2164756E21
11
11
  //# sourceMappingURL=index.js.map