derived-mcp-server 0.0.21 → 0.0.23

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 (2) hide show
  1. package/dist/bundle.js +15 -11
  2. package/package.json +1 -1
package/dist/bundle.js CHANGED
@@ -1,22 +1,26 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var _n=Object.create;var Bt=Object.defineProperty;var bn=Object.getOwnPropertyDescriptor;var xn=Object.getOwnPropertyNames;var kn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty;var vt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Sn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of xn(e))!wn.call(r,s)&&s!==t&&Bt(r,s,{get:()=>e[s],enumerable:!(n=bn(e,s))||n.enumerable});return r};var _t=(r,e,t)=>(t=r!=null?_n(kn(r)):{},Sn(e||!r||!r.__esModule?Bt(t,"default",{value:r,enumerable:!0}):t,r));var sn=vt((ol,wa)=>{wa.exports={name:"dotenv",version:"16.4.5",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard","lint-readme":"standard-markdown",pretest:"npm run lint && npm run dts-check",test:"tap tests/*.js --100 -Rspec","test:coverage":"tap --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@definitelytyped/dtslint":"^0.0.133","@types/node":"^18.11.3",decache:"^4.6.1",sinon:"^14.0.1",standard:"^17.0.0","standard-markdown":"^7.1.0","standard-version":"^9.5.0",tap:"^16.3.0",tar:"^6.1.11",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var ln=vt((cl,K)=>{var Zt=require("fs"),Lt=require("path"),Sa=require("os"),Ta=require("crypto"),Ra=sn(),qt=Ra.version,Ea=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Pa(r){let e={},t=r.toString();t=t.replace(/\r\n?/mg,`
3
- `);let n;for(;(n=Ea.exec(t))!=null;){let s=n[1],a=n[2]||"";a=a.trim();let i=a[0];a=a.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),i==='"'&&(a=a.replace(/\\n/g,`
4
- `),a=a.replace(/\\r/g,"\r")),e[s]=a}return e}function Ca(r){let e=cn(r),t=R.configDotenv({path:e});if(!t.parsed){let i=new Error(`MISSING_DATA: Cannot parse ${e} for an unknown reason`);throw i.code="MISSING_DATA",i}let n=on(r).split(","),s=n.length,a;for(let i=0;i<s;i++)try{let c=n[i].trim(),l=ja(t,c);a=R.decrypt(l.ciphertext,l.key);break}catch(c){if(i+1>=s)throw c}return R.parse(a)}function Na(r){console.log(`[dotenv@${qt}][INFO] ${r}`)}function Oa(r){console.log(`[dotenv@${qt}][WARN] ${r}`)}function yt(r){console.log(`[dotenv@${qt}][DEBUG] ${r}`)}function on(r){return r&&r.DOTENV_KEY&&r.DOTENV_KEY.length>0?r.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function ja(r,e){let t;try{t=new URL(e)}catch(c){if(c.code==="ERR_INVALID_URL"){let l=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw l.code="INVALID_DOTENV_KEY",l}throw c}let n=t.password;if(!n){let c=new Error("INVALID_DOTENV_KEY: Missing key part");throw c.code="INVALID_DOTENV_KEY",c}let s=t.searchParams.get("environment");if(!s){let c=new Error("INVALID_DOTENV_KEY: Missing environment part");throw c.code="INVALID_DOTENV_KEY",c}let a=`DOTENV_VAULT_${s.toUpperCase()}`,i=r.parsed[a];if(!i){let c=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw c.code="NOT_FOUND_DOTENV_ENVIRONMENT",c}return{ciphertext:i,key:n}}function cn(r){let e=null;if(r&&r.path&&r.path.length>0)if(Array.isArray(r.path))for(let t of r.path)Zt.existsSync(t)&&(e=t.endsWith(".vault")?t:`${t}.vault`);else e=r.path.endsWith(".vault")?r.path:`${r.path}.vault`;else e=Lt.resolve(process.cwd(),".env.vault");return Zt.existsSync(e)?e:null}function an(r){return r[0]==="~"?Lt.join(Sa.homedir(),r.slice(1)):r}function Ia(r){Na("Loading env from encrypted .env.vault");let e=R._parseVault(r),t=process.env;return r&&r.processEnv!=null&&(t=r.processEnv),R.populate(t,e,r),{parsed:e}}function Aa(r){let e=Lt.resolve(process.cwd(),".env"),t="utf8",n=!!(r&&r.debug);r&&r.encoding?t=r.encoding:n&&yt("No encoding is specified. UTF-8 is used by default");let s=[e];if(r&&r.path)if(!Array.isArray(r.path))s=[an(r.path)];else{s=[];for(let l of r.path)s.push(an(l))}let a,i={};for(let l of s)try{let u=R.parse(Zt.readFileSync(l,{encoding:t}));R.populate(i,u,r)}catch(u){n&&yt(`Failed to load ${l} ${u.message}`),a=u}let c=process.env;return r&&r.processEnv!=null&&(c=r.processEnv),R.populate(c,i,r),a?{parsed:i,error:a}:{parsed:i}}function Da(r){if(on(r).length===0)return R.configDotenv(r);let e=cn(r);return e?R._configVault(r):(Oa(`You set DOTENV_KEY but you are missing a .env.vault file at ${e}. Did you forget to build it?`),R.configDotenv(r))}function Ma(r,e){let t=Buffer.from(e.slice(-64),"hex"),n=Buffer.from(r,"base64"),s=n.subarray(0,12),a=n.subarray(-16);n=n.subarray(12,-16);try{let i=Ta.createDecipheriv("aes-256-gcm",t,s);return i.setAuthTag(a),`${i.update(n)}${i.final()}`}catch(i){let c=i instanceof RangeError,l=i.message==="Invalid key length",u=i.message==="Unsupported state or unable to authenticate data";if(c||l){let m=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw m.code="INVALID_DOTENV_KEY",m}else if(u){let m=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw m.code="DECRYPTION_FAILED",m}else throw i}}function $a(r,e,t={}){let n=!!(t&&t.debug),s=!!(t&&t.override);if(typeof e!="object"){let a=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw a.code="OBJECT_REQUIRED",a}for(let a of Object.keys(e))Object.prototype.hasOwnProperty.call(r,a)?(s===!0&&(r[a]=e[a]),n&&yt(s===!0?`"${a}" is already defined and WAS overwritten`:`"${a}" is already defined and was NOT overwritten`)):r[a]=e[a]}var R={configDotenv:Aa,_configVault:Ia,_parseVault:Ca,config:Da,decrypt:Ma,parse:Pa,populate:$a};K.exports.configDotenv=R.configDotenv;K.exports._configVault=R._configVault;K.exports._parseVault=R._parseVault;K.exports.config=R.config;K.exports.decrypt=R.decrypt;K.exports.parse=R.parse;K.exports.populate=R.populate;K.exports=R});var pn=vt((ll,dn)=>{"use strict";var Vt=Object.defineProperty,Za=Object.getOwnPropertyDescriptor,La=Object.getOwnPropertyNames,qa=Object.prototype.hasOwnProperty,Va=(r,e)=>{for(var t in e)Vt(r,t,{get:e[t],enumerable:!0})},Ha=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of La(e))!qa.call(r,s)&&s!==t&&Vt(r,s,{get:()=>e[s],enumerable:!(n=Za(e,s))||n.enumerable});return r},za=r=>Ha(Vt({},"__esModule",{value:!0}),r),un={};Va(un,{default:()=>Fa});dn.exports=za(un);var Ua=class{baseUrl;defaultHeaders;constructor(r,e={}){this.baseUrl=r,this.defaultHeaders=e}buildUrl(r){return`${this.baseUrl.replace(/\/$/,"")}/${r.replace(/^\//,"")}`}async request(r,e,t,n={}){let s=this.buildUrl(e),a=await fetch(s,{method:r,headers:{"Content-Type":"application/json",...this.defaultHeaders,...n},body:t?JSON.stringify(t):void 0});if(!a.ok){let c=await a.text().catch(()=>"");throw new Error(`HTTP ${a.status} ${a.statusText}: ${c||"Request failed"}`)}let i=await a.text();try{return JSON.parse(i)}catch{return i}}get(r,e){return this.request("GET",r,void 0,e)}post(r,e,t){return this.request("POST",r,e,t)}put(r,e,t){return this.request("PUT",r,e,t)}delete(r,e){return this.request("DELETE",r,void 0,e)}},Me=new Ua("https://api.derived.dev/api/public"),Ba=class{constructor(){}fetchBlock=async r=>Me.get(`/v1/template-group/code/${r}`);getBlockInputFromUserQuery=(r,e)=>Me.post("/v1/template-group/get-block-input-from-user-query",{blockInput:r,query:e});resolveMultipleTemplates=(r,e)=>Me.post("/v1/template-group/resolve-multiple-templates-by-block-code",{blockCode:r,data:e});searchBlocksByName=r=>Me.get(`/v1/template-group/semantic-search?q=${r}&limit=5&threshold=0.5`);fetchProjectBySlug=async r=>Me.get(`/v1/project/detail-by-slug/${r}`)},Fa=Ba});var k;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},r.getValidEnumValues=s=>{let a=r.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),i={};for(let c of a)i[c]=s[c];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(let i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(k||(k={}));var xt;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(xt||(xt={}));var h=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),G=r=>{switch(typeof r){case"undefined":return h.undefined;case"string":return h.string;case"number":return isNaN(r)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(r)?h.array:r===null?h.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?h.promise:typeof Map<"u"&&r instanceof Map?h.map:typeof Set<"u"&&r instanceof Set?h.set:typeof Date<"u"&&r instanceof Date?h.date:h.object;default:return h.unknown}},p=k.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"]),Tn=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),j=class r extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let c=n,l=0;for(;l<i.path.length;){let u=i.path[l];l===i.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(i))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}};return s(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};j.create=r=>new j(r);var be=(r,e)=>{let t;switch(r.code){case p.invalid_type:r.received===h.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case p.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,k.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:t=`Unrecognized key(s) in object: ${k.joinValues(r.keys,", ")}`;break;case p.invalid_union:t="Invalid input";break;case p.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${k.joinValues(r.options)}`;break;case p.invalid_enum_value:t=`Invalid enum value. Expected ${k.joinValues(r.options)}, received '${r.received}'`;break;case p.invalid_arguments:t="Invalid function arguments";break;case p.invalid_return_type:t="Invalid function return type";break;case p.invalid_date:t="Invalid date";break;case p.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:k.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case p.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case p.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case p.custom:t="Invalid input";break;case p.invalid_intersection_types:t="Intersection results could not be merged";break;case p.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case p.not_finite:t="Number must be finite";break;default:t=e.defaultError,k.assertNever(r)}return{message:t}},Wt=be;function Rn(r){Wt=r}function $e(){return Wt}var Ze=r=>{let{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let c="",l=n.filter(u=>!!u).slice().reverse();for(let u of l)c=u(i,{data:e,defaultError:c}).message;return{...s,path:a,message:c}},En=[];function f(r,e){let t=$e(),n=Ze({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===be?void 0:be].filter(s=>!!s)});r.common.issues.push(n)}var E=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let s of t){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let s of t){let a=await s.key,i=await s.value;n.push({key:a,value:i})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return v;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},v=Object.freeze({status:"aborted"}),_e=r=>({status:"dirty",value:r}),P=r=>({status:"valid",value:r}),kt=r=>r.status==="aborted",wt=r=>r.status==="dirty",Ne=r=>r.status==="valid",Oe=r=>typeof Promise<"u"&&r instanceof Promise;function Le(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function Yt(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t}var g;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(g||(g={}));var Pe,Ce,$=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ft=(r,e)=>{if(Ne(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new j(r.common.issues);return this._error=t,this._error}}};function b(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,c)=>{var l,u;let{message:m}=r;return i.code==="invalid_enum_value"?{message:m??c.defaultError}:typeof c.data>"u"?{message:(l=m??n)!==null&&l!==void 0?l:c.defaultError}:i.code!=="invalid_type"?{message:c.defaultError}:{message:(u=m??t)!==null&&u!==void 0?u:c.defaultError}},description:s}}var _=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,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)}get description(){return this._def.description}_getType(e){return G(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:G(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new E,ctx:{common:e.parent.common,data:e.data,parsedType:G(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Oe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let s={common:{issues:[],async:(n=t?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Ft(s,a)}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Oe(s)?s:Promise.resolve(s));return Ft(n,a)}refine(e,t){let n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{let i=e(s),c=()=>a.addIssue({code:p.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(c(),!1)):i?!0:(c(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new I({schema:this,typeName:d.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return N.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Y.create(this,this._def)}promise(){return ee.create(this,this._def)}or(e){return le.create([this,e],this._def)}and(e){return ue.create(this,e,this._def)}transform(e){return new I({...b(this._def),schema:this,typeName:d.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new he({...b(this._def),innerType:this,defaultValue:t,typeName:d.ZodDefault})}brand(){return new je({typeName:d.ZodBranded,type:this,...b(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new ge({...b(this._def),innerType:this,catchValue:t,typeName:d.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ie.create(this,e)}readonly(){return ye.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Pn=/^c[^\s-]{8,}$/i,Cn=/^[0-9a-z]+$/,Nn=/^[0-9A-HJKMNP-TV-Z]{26}$/,On=/^[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,jn=/^[a-z0-9_-]{21}$/i,In=/^[-+]?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)?)??$/,An=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Dn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",bt,Mn=/^(?:(?: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])$/,$n=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Zn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Kt="((\\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])))",Ln=new RegExp(`^${Kt}$`);function Gt(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function qn(r){return new RegExp(`^${Gt(r)}$`)}function Xt(r){let e=`${Kt}T${Gt(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Vn(r,e){return!!((e==="v4"||!e)&&Mn.test(r)||(e==="v6"||!e)&&$n.test(r))}var X=class r extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){let a=this._getOrReturnCtx(e);return f(a,{code:p.invalid_type,expected:h.string,received:a.parsedType}),v}let n=new E,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,c=e.data.length<a.value;(i||c)&&(s=this._getOrReturnCtx(e,s),i?f(s,{code:p.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):c&&f(s,{code:p.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")An.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")bt||(bt=new RegExp(Dn,"u")),bt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")On.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")jn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Pn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Cn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:p.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:p.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Xt(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?qn(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?In.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:p.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Vn(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:p.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Zn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:p.invalid_string,message:a.message}),n.dirty()):k.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:p.invalid_string,...g.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(n=e?.local)!==null&&n!==void 0?n:!1,...g.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...g.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...g.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...g.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...g.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...g.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...g.errToObj(t)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};X.create=r=>{var e;return new X({checks:[],typeName:d.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...b(r)})};function Hn(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}var ne=class r extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){let a=this._getOrReturnCtx(e);return f(a,{code:p.invalid_type,expected:h.number,received:a.parsedType}),v}let n,s=new E;for(let a of this._def.checks)a.kind==="int"?k.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:p.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:p.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:p.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Hn(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:p.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:p.not_finite,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:g.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};ne.create=r=>new ne({checks:[],typeName:d.ZodNumber,coerce:r?.coerce||!1,...b(r)});var se=class r extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==h.bigint){let a=this._getOrReturnCtx(e);return f(a,{code:p.invalid_type,expected:h.bigint,received:a.parsedType}),v}let n,s=new E;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:p.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:p.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:p.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:g.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};se.create=r=>{var e;return new se({checks:[],typeName:d.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...b(r)})};var ae=class extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){let n=this._getOrReturnCtx(e);return f(n,{code:p.invalid_type,expected:h.boolean,received:n.parsedType}),v}return P(e.data)}};ae.create=r=>new ae({typeName:d.ZodBoolean,coerce:r?.coerce||!1,...b(r)});var ie=class r extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){let a=this._getOrReturnCtx(e);return f(a,{code:p.invalid_type,expected:h.date,received:a.parsedType}),v}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return f(a,{code:p.invalid_date}),v}let n=new E,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):k.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};ie.create=r=>new ie({checks:[],coerce:r?.coerce||!1,typeName:d.ZodDate,...b(r)});var xe=class extends _{_parse(e){if(this._getType(e)!==h.symbol){let n=this._getOrReturnCtx(e);return f(n,{code:p.invalid_type,expected:h.symbol,received:n.parsedType}),v}return P(e.data)}};xe.create=r=>new xe({typeName:d.ZodSymbol,...b(r)});var oe=class extends _{_parse(e){if(this._getType(e)!==h.undefined){let n=this._getOrReturnCtx(e);return f(n,{code:p.invalid_type,expected:h.undefined,received:n.parsedType}),v}return P(e.data)}};oe.create=r=>new oe({typeName:d.ZodUndefined,...b(r)});var ce=class extends _{_parse(e){if(this._getType(e)!==h.null){let n=this._getOrReturnCtx(e);return f(n,{code:p.invalid_type,expected:h.null,received:n.parsedType}),v}return P(e.data)}};ce.create=r=>new ce({typeName:d.ZodNull,...b(r)});var Q=class extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}};Q.create=r=>new Q({typeName:d.ZodAny,...b(r)});var W=class extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}};W.create=r=>new W({typeName:d.ZodUnknown,...b(r)});var Z=class extends _{_parse(e){let t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:h.never,received:t.parsedType}),v}};Z.create=r=>new Z({typeName:d.ZodNever,...b(r)});var ke=class extends _{_parse(e){if(this._getType(e)!==h.undefined){let n=this._getOrReturnCtx(e);return f(n,{code:p.invalid_type,expected:h.void,received:n.parsedType}),v}return P(e.data)}};ke.create=r=>new ke({typeName:d.ZodVoid,...b(r)});var Y=class r extends _{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==h.array)return f(t,{code:p.invalid_type,expected:h.array,received:t.parsedType}),v;if(s.exactLength!==null){let i=t.data.length>s.exactLength.value,c=t.data.length<s.exactLength.value;(i||c)&&(f(t,{code:i?p.too_big:p.too_small,minimum:c?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(f(t,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(f(t,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,c)=>s.type._parseAsync(new $(t,i,t.path,c)))).then(i=>E.mergeArray(n,i));let a=[...t.data].map((i,c)=>s.type._parseSync(new $(t,i,t.path,c)));return E.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:g.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:g.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:g.toString(t)}})}nonempty(e){return this.min(1,e)}};Y.create=(r,e)=>new Y({type:r,minLength:null,maxLength:null,exactLength:null,typeName:d.ZodArray,...b(e)});function ve(r){if(r instanceof O){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=N.create(ve(n))}return new O({...r._def,shape:()=>e})}else return r instanceof Y?new Y({...r._def,type:ve(r.element)}):r instanceof N?N.create(ve(r.unwrap())):r instanceof B?B.create(ve(r.unwrap())):r instanceof U?U.create(r.items.map(e=>ve(e))):r}var O=class r extends _{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==h.object){let u=this._getOrReturnCtx(e);return f(u,{code:p.invalid_type,expected:h.object,received:u.parsedType}),v}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),c=[];if(!(this._def.catchall instanceof Z&&this._def.unknownKeys==="strip"))for(let u in s.data)i.includes(u)||c.push(u);let l=[];for(let u of i){let m=a[u],w=s.data[u];l.push({key:{status:"valid",value:u},value:m._parse(new $(s,w,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Z){let u=this._def.unknownKeys;if(u==="passthrough")for(let m of c)l.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(u==="strict")c.length>0&&(f(s,{code:p.unrecognized_keys,keys:c}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let m of c){let w=s.data[m];l.push({key:{status:"valid",value:m},value:u._parse(new $(s,w,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let m of l){let w=await m.key,D=await m.value;u.push({key:w,value:D,alwaysSet:m.alwaysSet})}return u}).then(u=>E.mergeObjectSync(n,u)):E.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,c;let l=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(c=g.errToObj(e).message)!==null&&c!==void 0?c:l}:{message:l}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:d.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};return k.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}omit(e){let t={};return k.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}deepPartial(){return ve(this)}partial(e){let t={};return k.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new r({...this._def,shape:()=>t})}required(e){let t={};return k.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof N;)a=a._def.innerType;t[n]=a}}),new r({...this._def,shape:()=>t})}keyof(){return Qt(k.objectKeys(this.shape))}};O.create=(r,e)=>new O({shape:()=>r,unknownKeys:"strip",catchall:Z.create(),typeName:d.ZodObject,...b(e)});O.strictCreate=(r,e)=>new O({shape:()=>r,unknownKeys:"strict",catchall:Z.create(),typeName:d.ZodObject,...b(e)});O.lazycreate=(r,e)=>new O({shape:r,unknownKeys:"strip",catchall:Z.create(),typeName:d.ZodObject,...b(e)});var le=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(let c of a)if(c.result.status==="valid")return c.result;for(let c of a)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;let i=a.map(c=>new j(c.ctx.common.issues));return f(t,{code:p.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(n.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a,i=[];for(let l of n){let u={...t,common:{...t.common,issues:[]},parent:null},m=l._parseSync({data:t.data,path:t.path,parent:u});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let c=i.map(l=>new j(l));return f(t,{code:p.invalid_union,unionErrors:c}),v}}get options(){return this._def.options}};le.create=(r,e)=>new le({options:r,typeName:d.ZodUnion,...b(e)});var J=r=>r instanceof de?J(r.schema):r instanceof I?J(r.innerType()):r instanceof pe?[r.value]:r instanceof me?r.options:r instanceof fe?k.objectValues(r.enum):r instanceof he?J(r._def.innerType):r instanceof oe?[void 0]:r instanceof ce?[null]:r instanceof N?[void 0,...J(r.unwrap())]:r instanceof B?[null,...J(r.unwrap())]:r instanceof je||r instanceof ye?J(r.unwrap()):r instanceof ge?J(r._def.innerType):[],qe=class r extends _{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return f(t,{code:p.invalid_type,expected:h.object,received:t.parsedType}),v;let n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(f(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let a of t){let i=J(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of i){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,a)}}return new r({typeName:d.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...b(n)})}};function St(r,e){let t=G(r),n=G(e);if(r===e)return{valid:!0,data:r};if(t===h.object&&n===h.object){let s=k.objectKeys(e),a=k.objectKeys(r).filter(c=>s.indexOf(c)!==-1),i={...r,...e};for(let c of a){let l=St(r[c],e[c]);if(!l.valid)return{valid:!1};i[c]=l.data}return{valid:!0,data:i}}else if(t===h.array&&n===h.array){if(r.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<r.length;a++){let i=r[a],c=e[a],l=St(i,c);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return t===h.date&&n===h.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var ue=class extends _{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(kt(a)||kt(i))return v;let c=St(a.value,i.value);return c.valid?((wt(a)||wt(i))&&t.dirty(),{status:t.value,value:c.data}):(f(n,{code:p.invalid_intersection_types}),v)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ue.create=(r,e,t)=>new ue({left:r,right:e,typeName:d.ZodIntersection,...b(t)});var U=class r extends _{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return f(n,{code:p.invalid_type,expected:h.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return f(n,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(f(n,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...n.data].map((i,c)=>{let l=this._def.items[c]||this._def.rest;return l?l._parse(new $(n,i,n.path,c)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>E.mergeArray(t,i)):E.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};U.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new U({items:r,typeName:d.ZodTuple,rest:null,...b(e)})};var Ve=class r extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return f(n,{code:p.invalid_type,expected:h.object,received:n.parsedType}),v;let s=[],a=this._def.keyType,i=this._def.valueType;for(let c in n.data)s.push({key:a._parse(new $(n,c,n.path,c)),value:i._parse(new $(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?E.mergeObjectAsync(t,s):E.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof _?new r({keyType:e,valueType:t,typeName:d.ZodRecord,...b(n)}):new r({keyType:X.create(),valueType:e,typeName:d.ZodRecord,...b(t)})}},we=class extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return f(n,{code:p.invalid_type,expected:h.map,received:n.parsedType}),v;let s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([c,l],u)=>({key:s._parse(new $(n,c,n.path,[u,"key"])),value:a._parse(new $(n,l,n.path,[u,"value"]))}));if(n.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let l of i){let u=await l.key,m=await l.value;if(u.status==="aborted"||m.status==="aborted")return v;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(u.value,m.value)}return{status:t.value,value:c}})}else{let c=new Map;for(let l of i){let u=l.key,m=l.value;if(u.status==="aborted"||m.status==="aborted")return v;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(u.value,m.value)}return{status:t.value,value:c}}}};we.create=(r,e,t)=>new we({valueType:e,keyType:r,typeName:d.ZodMap,...b(t)});var Se=class r extends _{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return f(n,{code:p.invalid_type,expected:h.set,received:n.parsedType}),v;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(f(n,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(f(n,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let a=this._def.valueType;function i(l){let u=new Set;for(let m of l){if(m.status==="aborted")return v;m.status==="dirty"&&t.dirty(),u.add(m.value)}return{status:t.value,value:u}}let c=[...n.data.values()].map((l,u)=>a._parse(new $(n,l,n.path,u)));return n.common.async?Promise.all(c).then(l=>i(l)):i(c)}min(e,t){return new r({...this._def,minSize:{value:e,message:g.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:g.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Se.create=(r,e)=>new Se({valueType:r,minSize:null,maxSize:null,typeName:d.ZodSet,...b(e)});var He=class r extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.function)return f(t,{code:p.invalid_type,expected:h.function,received:t.parsedType}),v;function n(c,l){return Ze({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$e(),be].filter(u=>!!u),issueData:{code:p.invalid_arguments,argumentsError:l}})}function s(c,l){return Ze({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$e(),be].filter(u=>!!u),issueData:{code:p.invalid_return_type,returnTypeError:l}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ee){let c=this;return P(async function(...l){let u=new j([]),m=await c._def.args.parseAsync(l,a).catch(te=>{throw u.addIssue(n(l,te)),u}),w=await Reflect.apply(i,this,m);return await c._def.returns._def.type.parseAsync(w,a).catch(te=>{throw u.addIssue(s(w,te)),u})})}else{let c=this;return P(function(...l){let u=c._def.args.safeParse(l,a);if(!u.success)throw new j([n(l,u.error)]);let m=Reflect.apply(i,this,u.data),w=c._def.returns.safeParse(m,a);if(!w.success)throw new j([s(m,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:U.create(e).rest(W.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||U.create([]).rest(W.create()),returns:t||W.create(),typeName:d.ZodFunction,...b(n)})}},de=class extends _{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};de.create=(r,e)=>new de({getter:r,typeName:d.ZodLazy,...b(e)});var pe=class extends _{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};pe.create=(r,e)=>new pe({value:r,typeName:d.ZodLiteral,...b(e)});function Qt(r,e){return new me({values:r,typeName:d.ZodEnum,...b(e)})}var me=class r extends _{constructor(){super(...arguments),Pe.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{expected:k.joinValues(n),received:t.parsedType,code:p.invalid_type}),v}if(Le(this,Pe,"f")||Yt(this,Pe,new Set(this._def.values),"f"),!Le(this,Pe,"f").has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{received:t.data,code:p.invalid_enum_value,options:n}),v}return P(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Pe=new WeakMap;me.create=Qt;var fe=class extends _{constructor(){super(...arguments),Ce.set(this,void 0)}_parse(e){let t=k.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){let s=k.objectValues(t);return f(n,{expected:k.joinValues(s),received:n.parsedType,code:p.invalid_type}),v}if(Le(this,Ce,"f")||Yt(this,Ce,new Set(k.getValidEnumValues(this._def.values)),"f"),!Le(this,Ce,"f").has(e.data)){let s=k.objectValues(t);return f(n,{received:n.data,code:p.invalid_enum_value,options:s}),v}return P(e.data)}get enum(){return this._def.values}};Ce=new WeakMap;fe.create=(r,e)=>new fe({values:r,typeName:d.ZodNativeEnum,...b(e)});var ee=class extends _{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return f(t,{code:p.invalid_type,expected:h.promise,received:t.parsedType}),v;let n=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return P(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ee.create=(r,e)=>new ee({type:r,typeName:d.ZodPromise,...b(e)});var I=class extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===d.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{f(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async c=>{if(t.value==="aborted")return v;let l=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return l.status==="aborted"?v:l.status==="dirty"||t.value==="dirty"?_e(l.value):l});{if(t.value==="aborted")return v;let c=this._def.schema._parseSync({data:i,path:n.path,parent:n});return c.status==="aborted"?v:c.status==="dirty"||t.value==="dirty"?_e(c.value):c}}if(s.type==="refinement"){let i=c=>{let l=s.refinement(c,a);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){let c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?v:(c.status==="dirty"&&t.dirty(),i(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?v:(c.status==="dirty"&&t.dirty(),i(c.value).then(()=>({status:t.value,value:c.value}))))}if(s.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ne(i))return i;let c=s.transform(i.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Ne(i)?Promise.resolve(s.transform(i.value,a)).then(c=>({status:t.value,value:c})):i);k.assertNever(s)}};I.create=(r,e,t)=>new I({schema:r,typeName:d.ZodEffects,effect:e,...b(t)});I.createWithPreprocess=(r,e,t)=>new I({schema:e,effect:{type:"preprocess",transform:r},typeName:d.ZodEffects,...b(t)});var N=class extends _{_parse(e){return this._getType(e)===h.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};N.create=(r,e)=>new N({innerType:r,typeName:d.ZodOptional,...b(e)});var B=class extends _{_parse(e){return this._getType(e)===h.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};B.create=(r,e)=>new B({innerType:r,typeName:d.ZodNullable,...b(e)});var he=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};he.create=(r,e)=>new he({innerType:r,typeName:d.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});var ge=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Oe(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ge.create=(r,e)=>new ge({innerType:r,typeName:d.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});var Te=class extends _{_parse(e){if(this._getType(e)!==h.nan){let n=this._getOrReturnCtx(e);return f(n,{code:p.invalid_type,expected:h.nan,received:n.parsedType}),v}return{status:"valid",value:e.data}}};Te.create=r=>new Te({typeName:d.ZodNaN,...b(r)});var zn=Symbol("zod_brand"),je=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Ie=class r extends _{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),_e(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:d.ZodPipeline})}},ye=class extends _{_parse(e){let t=this._def.innerType._parse(e),n=s=>(Ne(s)&&(s.value=Object.freeze(s.value)),s);return Oe(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};ye.create=(r,e)=>new ye({innerType:r,typeName:d.ZodReadonly,...b(e)});function er(r,e={},t){return r?Q.create().superRefine((n,s)=>{var a,i;if(!r(n)){let c=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,l=(i=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof c=="string"?{message:c}:c;s.addIssue({code:"custom",...u,fatal:l})}}):Q.create()}var Un={object:O.lazycreate},d;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(d||(d={}));var Bn=(r,e={message:`Input not instance of ${r.name}`})=>er(t=>t instanceof r,e),tr=X.create,rr=ne.create,Fn=Te.create,Jn=se.create,nr=ae.create,Wn=ie.create,Yn=xe.create,Kn=oe.create,Gn=ce.create,Xn=Q.create,Qn=W.create,es=Z.create,ts=ke.create,rs=Y.create,ns=O.create,ss=O.strictCreate,as=le.create,is=qe.create,os=ue.create,cs=U.create,ls=Ve.create,us=we.create,ds=Se.create,ps=He.create,ms=de.create,fs=pe.create,hs=me.create,gs=fe.create,ys=ee.create,Jt=I.create,vs=N.create,_s=B.create,bs=I.createWithPreprocess,xs=Ie.create,ks=()=>tr().optional(),ws=()=>rr().optional(),Ss=()=>nr().optional(),Ts={string:r=>X.create({...r,coerce:!0}),number:r=>ne.create({...r,coerce:!0}),boolean:r=>ae.create({...r,coerce:!0}),bigint:r=>se.create({...r,coerce:!0}),date:r=>ie.create({...r,coerce:!0})},Rs=v,o=Object.freeze({__proto__:null,defaultErrorMap:be,setErrorMap:Rn,getErrorMap:$e,makeIssue:Ze,EMPTY_PATH:En,addIssueToContext:f,ParseStatus:E,INVALID:v,DIRTY:_e,OK:P,isAborted:kt,isDirty:wt,isValid:Ne,isAsync:Oe,get util(){return k},get objectUtil(){return xt},ZodParsedType:h,getParsedType:G,ZodType:_,datetimeRegex:Xt,ZodString:X,ZodNumber:ne,ZodBigInt:se,ZodBoolean:ae,ZodDate:ie,ZodSymbol:xe,ZodUndefined:oe,ZodNull:ce,ZodAny:Q,ZodUnknown:W,ZodNever:Z,ZodVoid:ke,ZodArray:Y,ZodObject:O,ZodUnion:le,ZodDiscriminatedUnion:qe,ZodIntersection:ue,ZodTuple:U,ZodRecord:Ve,ZodMap:we,ZodSet:Se,ZodFunction:He,ZodLazy:de,ZodLiteral:pe,ZodEnum:me,ZodNativeEnum:fe,ZodPromise:ee,ZodEffects:I,ZodTransformer:I,ZodOptional:N,ZodNullable:B,ZodDefault:he,ZodCatch:ge,ZodNaN:Te,BRAND:zn,ZodBranded:je,ZodPipeline:Ie,ZodReadonly:ye,custom:er,Schema:_,ZodSchema:_,late:Un,get ZodFirstPartyTypeKind(){return d},coerce:Ts,any:Xn,array:rs,bigint:Jn,boolean:nr,date:Wn,discriminatedUnion:is,effect:Jt,enum:hs,function:ps,instanceof:Bn,intersection:os,lazy:ms,literal:fs,map:us,nan:Fn,nativeEnum:gs,never:es,null:Gn,nullable:_s,number:rr,object:ns,oboolean:Ss,onumber:ws,optional:vs,ostring:ks,pipeline:xs,preprocess:bs,promise:ys,record:ls,set:ds,strictObject:ss,string:tr,symbol:Yn,transformer:Jt,tuple:cs,undefined:Kn,union:as,unknown:Qn,void:ts,NEVER:Rs,ZodIssueCode:p,quotelessJson:Tn,ZodError:j});var Tt="2025-03-26",sr=[Tt,"2024-11-05","2024-10-07"],ze="2.0",ar=o.union([o.string(),o.number().int()]),ir=o.string(),Es=o.object({progressToken:o.optional(ar)}).passthrough(),L=o.object({_meta:o.optional(Es)}).passthrough(),A=o.object({method:o.string(),params:o.optional(L)}),Ae=o.object({_meta:o.optional(o.object({}).passthrough())}).passthrough(),F=o.object({method:o.string(),params:o.optional(Ae)}),q=o.object({_meta:o.optional(o.object({}).passthrough())}).passthrough(),Ue=o.union([o.string(),o.number().int()]),or=o.object({jsonrpc:o.literal(ze),id:Ue}).merge(A).strict(),cr=r=>or.safeParse(r).success,lr=o.object({jsonrpc:o.literal(ze)}).merge(F).strict(),ur=r=>lr.safeParse(r).success,dr=o.object({jsonrpc:o.literal(ze),id:Ue,result:q}).strict(),Rt=r=>dr.safeParse(r).success,S;(function(r){r[r.ConnectionClosed=-32e3]="ConnectionClosed",r[r.RequestTimeout=-32001]="RequestTimeout",r[r.ParseError=-32700]="ParseError",r[r.InvalidRequest=-32600]="InvalidRequest",r[r.MethodNotFound=-32601]="MethodNotFound",r[r.InvalidParams=-32602]="InvalidParams",r[r.InternalError=-32603]="InternalError"})(S||(S={}));var pr=o.object({jsonrpc:o.literal(ze),id:Ue,error:o.object({code:o.number().int(),message:o.string(),data:o.optional(o.unknown())})}).strict(),mr=r=>pr.safeParse(r).success,fr=o.union([or,lr,dr,pr]),Be=q.strict(),Fe=F.extend({method:o.literal("notifications/cancelled"),params:Ae.extend({requestId:Ue,reason:o.string().optional()})}),hr=o.object({name:o.string(),version:o.string()}).passthrough(),Ps=o.object({experimental:o.optional(o.object({}).passthrough()),sampling:o.optional(o.object({}).passthrough()),roots:o.optional(o.object({listChanged:o.optional(o.boolean())}).passthrough())}).passthrough(),Et=A.extend({method:o.literal("initialize"),params:L.extend({protocolVersion:o.string(),capabilities:Ps,clientInfo:hr})});var Cs=o.object({experimental:o.optional(o.object({}).passthrough()),logging:o.optional(o.object({}).passthrough()),completions:o.optional(o.object({}).passthrough()),prompts:o.optional(o.object({listChanged:o.optional(o.boolean())}).passthrough()),resources:o.optional(o.object({subscribe:o.optional(o.boolean()),listChanged:o.optional(o.boolean())}).passthrough()),tools:o.optional(o.object({listChanged:o.optional(o.boolean())}).passthrough())}).passthrough(),Ns=q.extend({protocolVersion:o.string(),capabilities:Cs,serverInfo:hr,instructions:o.optional(o.string())}),Pt=F.extend({method:o.literal("notifications/initialized")});var Je=A.extend({method:o.literal("ping")}),Os=o.object({progress:o.number(),total:o.optional(o.number())}).passthrough(),We=F.extend({method:o.literal("notifications/progress"),params:Ae.merge(Os).extend({progressToken:ar})}),Ye=A.extend({params:L.extend({cursor:o.optional(ir)}).optional()}),Ke=q.extend({nextCursor:o.optional(ir)}),gr=o.object({uri:o.string(),mimeType:o.optional(o.string())}).passthrough(),yr=gr.extend({text:o.string()}),vr=gr.extend({blob:o.string().base64()}),js=o.object({uri:o.string(),name:o.string(),description:o.optional(o.string()),mimeType:o.optional(o.string())}).passthrough(),Is=o.object({uriTemplate:o.string(),name:o.string(),description:o.optional(o.string()),mimeType:o.optional(o.string())}).passthrough(),Ge=Ye.extend({method:o.literal("resources/list")}),As=Ke.extend({resources:o.array(js)}),Xe=Ye.extend({method:o.literal("resources/templates/list")}),Ds=Ke.extend({resourceTemplates:o.array(Is)}),Qe=A.extend({method:o.literal("resources/read"),params:L.extend({uri:o.string()})}),Ms=q.extend({contents:o.array(o.union([yr,vr]))}),$s=F.extend({method:o.literal("notifications/resources/list_changed")}),Zs=A.extend({method:o.literal("resources/subscribe"),params:L.extend({uri:o.string()})}),Ls=A.extend({method:o.literal("resources/unsubscribe"),params:L.extend({uri:o.string()})}),qs=F.extend({method:o.literal("notifications/resources/updated"),params:Ae.extend({uri:o.string()})}),Vs=o.object({name:o.string(),description:o.optional(o.string()),required:o.optional(o.boolean())}).passthrough(),Hs=o.object({name:o.string(),description:o.optional(o.string()),arguments:o.optional(o.array(Vs))}).passthrough(),et=Ye.extend({method:o.literal("prompts/list")}),zs=Ke.extend({prompts:o.array(Hs)}),tt=A.extend({method:o.literal("prompts/get"),params:L.extend({name:o.string(),arguments:o.optional(o.record(o.string()))})}),rt=o.object({type:o.literal("text"),text:o.string()}).passthrough(),nt=o.object({type:o.literal("image"),data:o.string().base64(),mimeType:o.string()}).passthrough(),st=o.object({type:o.literal("audio"),data:o.string().base64(),mimeType:o.string()}).passthrough(),_r=o.object({type:o.literal("resource"),resource:o.union([yr,vr])}).passthrough(),Us=o.object({role:o.enum(["user","assistant"]),content:o.union([rt,nt,st,_r])}).passthrough(),Bs=q.extend({description:o.optional(o.string()),messages:o.array(Us)}),Fs=F.extend({method:o.literal("notifications/prompts/list_changed")}),Js=o.object({title:o.optional(o.string()),readOnlyHint:o.optional(o.boolean()),destructiveHint:o.optional(o.boolean()),idempotentHint:o.optional(o.boolean()),openWorldHint:o.optional(o.boolean())}).passthrough(),Ws=o.object({name:o.string(),description:o.optional(o.string()),inputSchema:o.object({type:o.literal("object"),properties:o.optional(o.object({}).passthrough())}).passthrough(),annotations:o.optional(Js)}).passthrough(),at=Ye.extend({method:o.literal("tools/list")}),Ys=Ke.extend({tools:o.array(Ws)}),br=q.extend({content:o.array(o.union([rt,nt,st,_r])),isError:o.boolean().default(!1).optional()}),Qa=br.or(q.extend({toolResult:o.unknown()})),it=A.extend({method:o.literal("tools/call"),params:L.extend({name:o.string(),arguments:o.optional(o.record(o.unknown()))})}),Ks=F.extend({method:o.literal("notifications/tools/list_changed")}),xr=o.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),Gs=A.extend({method:o.literal("logging/setLevel"),params:L.extend({level:xr})}),Xs=F.extend({method:o.literal("notifications/message"),params:Ae.extend({level:xr,logger:o.optional(o.string()),data:o.unknown()})}),Qs=o.object({name:o.string().optional()}).passthrough(),ea=o.object({hints:o.optional(o.array(Qs)),costPriority:o.optional(o.number().min(0).max(1)),speedPriority:o.optional(o.number().min(0).max(1)),intelligencePriority:o.optional(o.number().min(0).max(1))}).passthrough(),ta=o.object({role:o.enum(["user","assistant"]),content:o.union([rt,nt,st])}).passthrough(),ra=A.extend({method:o.literal("sampling/createMessage"),params:L.extend({messages:o.array(ta),systemPrompt:o.optional(o.string()),includeContext:o.optional(o.enum(["none","thisServer","allServers"])),temperature:o.optional(o.number()),maxTokens:o.number().int(),stopSequences:o.optional(o.array(o.string())),metadata:o.optional(o.object({}).passthrough()),modelPreferences:o.optional(ea)})}),Ct=q.extend({model:o.string(),stopReason:o.optional(o.enum(["endTurn","stopSequence","maxTokens"]).or(o.string())),role:o.enum(["user","assistant"]),content:o.discriminatedUnion("type",[rt,nt,st])}),na=o.object({type:o.literal("ref/resource"),uri:o.string()}).passthrough(),sa=o.object({type:o.literal("ref/prompt"),name:o.string()}).passthrough(),ot=A.extend({method:o.literal("completion/complete"),params:L.extend({ref:o.union([sa,na]),argument:o.object({name:o.string(),value:o.string()}).passthrough()})}),aa=q.extend({completion:o.object({values:o.array(o.string()).max(100),total:o.optional(o.number().int()),hasMore:o.optional(o.boolean())}).passthrough()}),ia=o.object({uri:o.string().startsWith("file://"),name:o.optional(o.string())}).passthrough(),oa=A.extend({method:o.literal("roots/list")}),Nt=q.extend({roots:o.array(ia)}),ca=F.extend({method:o.literal("notifications/roots/list_changed")}),ei=o.union([Je,Et,ot,Gs,tt,et,Ge,Xe,Qe,Zs,Ls,it,at]),ti=o.union([Fe,We,Pt,ca]),ri=o.union([Be,Ct,Nt]),ni=o.union([Je,ra,oa]),si=o.union([Fe,We,Xs,qs,$s,Ks,Fs]),ai=o.union([Be,Ns,aa,Bs,zs,As,Ds,Ms,br,Ys]),T=class extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name="McpError"}};var la=6e4,ct=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this.setNotificationHandler(Fe,t=>{let n=this._requestHandlerAbortControllers.get(t.params.requestId);n?.abort(t.params.reason)}),this.setNotificationHandler(We,t=>{this._onprogress(t)}),this.setRequestHandler(Je,t=>({}))}_setupTimeout(e,t,n,s,a=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:a,onTimeout:s})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new T(S.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=t=>{this._onerror(t)},this._transport.onmessage=(t,n)=>{Rt(t)||mr(t)?this._onresponse(t):cr(t)?this._onrequest(t,n):ur(t)?this._onnotification(t):this._onerror(new Error(`Unknown message type: ${JSON.stringify(t)}`))},await this._transport.start()}_onclose(){var e;let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);let n=new T(S.ConnectionClosed,"Connection closed");for(let s of t.values())s(n)}_onerror(e){var t;(t=this.onerror)===null||t===void 0||t.call(this,e)}_onnotification(e){var t;let n=(t=this._notificationHandlers.get(e.method))!==null&&t!==void 0?t:this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,t){var n,s,a,i;let c=(n=this._requestHandlers.get(e.method))!==null&&n!==void 0?n:this.fallbackRequestHandler;if(c===void 0){(s=this._transport)===null||s===void 0||s.send({jsonrpc:"2.0",id:e.id,error:{code:S.MethodNotFound,message:"Method not found"}}).catch(m=>this._onerror(new Error(`Failed to send an error response: ${m}`)));return}let l=new AbortController;this._requestHandlerAbortControllers.set(e.id,l);let u={signal:l.signal,sessionId:(a=this._transport)===null||a===void 0?void 0:a.sessionId,_meta:(i=e.params)===null||i===void 0?void 0:i._meta,sendNotification:m=>this.notification(m,{relatedRequestId:e.id}),sendRequest:(m,w,D)=>this.request(m,w,{...D,relatedRequestId:e.id}),authInfo:t?.authInfo,requestId:e.id};Promise.resolve().then(()=>c(e,u)).then(m=>{var w;if(!l.signal.aborted)return(w=this._transport)===null||w===void 0?void 0:w.send({result:m,jsonrpc:"2.0",id:e.id})},m=>{var w,D;if(!l.signal.aborted)return(w=this._transport)===null||w===void 0?void 0:w.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(m.code)?m.code:S.InternalError,message:(D=m.message)!==null&&D!==void 0?D:"Internal error"}})}).catch(m=>this._onerror(new Error(`Failed to send response: ${m}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,s=Number(t),a=this._progressHandlers.get(s);if(!a){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(s),c=this._timeoutInfo.get(s);if(c&&i&&c.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(l){i(l);return}a(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(t),this._progressHandlers.delete(t),this._cleanupTimeout(t),Rt(e))n(e);else{let s=new T(e.error.code,e.error.message,e.error.data);n(s)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,t,n){let{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}=n??{};return new Promise((c,l)=>{var u,m,w,D,te;if(!this._transport){l(new Error("Not connected"));return}((u=this._options)===null||u===void 0?void 0:u.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(m=n?.signal)===null||m===void 0||m.throwIfAborted();let z=this._requestMessageId++,Ht={...e,jsonrpc:"2.0",id:z};n?.onprogress&&(this._progressHandlers.set(z,n.onprogress),Ht.params={...e.params,_meta:{progressToken:z}});let zt=M=>{var re;this._responseHandlers.delete(z),this._progressHandlers.delete(z),this._cleanupTimeout(z),(re=this._transport)===null||re===void 0||re.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:z,reason:String(M)}},{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}).catch(Ee=>this._onerror(new Error(`Failed to send cancellation: ${Ee}`))),l(M)};this._responseHandlers.set(z,M=>{var re;if(!(!((re=n?.signal)===null||re===void 0)&&re.aborted)){if(M instanceof Error)return l(M);try{let Ee=t.parse(M.result);c(Ee)}catch(Ee){l(Ee)}}}),(w=n?.signal)===null||w===void 0||w.addEventListener("abort",()=>{var M;zt((M=n?.signal)===null||M===void 0?void 0:M.reason)});let Ut=(D=n?.timeout)!==null&&D!==void 0?D:la,vn=()=>zt(new T(S.RequestTimeout,"Request timed out",{timeout:Ut}));this._setupTimeout(z,Ut,n?.maxTotalTimeout,vn,(te=n?.resetTimeoutOnProgress)!==null&&te!==void 0?te:!1),this._transport.send(Ht,{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}).catch(M=>{this._cleanupTimeout(z),l(M)})})}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n={...e,jsonrpc:"2.0"};await this._transport.send(n,t)}setRequestHandler(e,t){let n=e.shape.method.value;this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,a)=>Promise.resolve(t(e.parse(s),a)))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){this._notificationHandlers.set(e.shape.method.value,n=>Promise.resolve(t(e.parse(n))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function kr(r,e){return Object.entries(e).reduce((t,[n,s])=>(s&&typeof s=="object"?t[n]=t[n]?{...t[n],...s}:s:t[n]=s,t),{...r})}var lt=class extends ct{constructor(e,t){var n;super(t),this._serverInfo=e,this._capabilities=(n=t?.capabilities)!==null&&n!==void 0?n:{},this._instructions=t?.instructions,this.setRequestHandler(Et,s=>this._oninitialize(s)),this.setNotificationHandler(Pt,()=>{var s;return(s=this.oninitialized)===null||s===void 0?void 0:s.call(this)})}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=kr(this._capabilities,e)}assertCapabilityForMethod(e){var t,n;switch(e){case"sampling/createMessage":if(!(!((t=this._clientCapabilities)===null||t===void 0)&&t.sampling))throw new Error(`Client does not support sampling (required for ${e})`);break;case"roots/list":if(!(!((n=this._clientCapabilities)===null||n===void 0)&&n.roots))throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Server does not support sampling (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"ping":case"initialize":break}}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:sr.includes(t)?t:Tt,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Be)}async createMessage(e,t){return this.request({method:"sampling/createMessage",params:e},Ct,t)}async listRoots(e,t){return this.request({method:"roots/list",params:e},Nt,t)}async sendLoggingMessage(e){return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var Sr=Symbol("Let zodToJsonSchema decide on which parser to use");var wr={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Tr=r=>typeof r=="string"?{...wr,name:r}:{...wr,...r};var Rr=r=>{let e=Tr(r),t=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:t,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function Ot(r,e,t,n){n?.errorMessages&&t&&(r.errorMessage={...r.errorMessage,[e]:t})}function x(r,e,t,n,s){r[e]=t,Ot(r,e,n,s)}function Er(){return{}}function Pr(r,e){let t={type:"array"};return r.type?._def&&r.type?._def?.typeName!==d.ZodAny&&(t.items=y(r.type._def,{...e,currentPath:[...e.currentPath,"items"]})),r.minLength&&x(t,"minItems",r.minLength.value,r.minLength.message,e),r.maxLength&&x(t,"maxItems",r.maxLength.value,r.maxLength.message,e),r.exactLength&&(x(t,"minItems",r.exactLength.value,r.exactLength.message,e),x(t,"maxItems",r.exactLength.value,r.exactLength.message,e)),t}function Cr(r,e){let t={type:"integer",format:"int64"};if(!r.checks)return t;for(let n of r.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?x(t,"minimum",n.value,n.message,e):x(t,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(t.exclusiveMinimum=!0),x(t,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?x(t,"maximum",n.value,n.message,e):x(t,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(t.exclusiveMaximum=!0),x(t,"maximum",n.value,n.message,e));break;case"multipleOf":x(t,"multipleOf",n.value,n.message,e);break}return t}function Nr(){return{type:"boolean"}}function ut(r,e){return y(r.type._def,e)}var Or=(r,e)=>y(r.innerType._def,e);function jt(r,e,t){let n=t??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,a)=>jt(r,e,s))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return ua(r,e)}}var ua=(r,e)=>{let t={type:"integer",format:"unix-time"};if(e.target==="openApi3")return t;for(let n of r.checks)switch(n.kind){case"min":x(t,"minimum",n.value,n.message,e);break;case"max":x(t,"maximum",n.value,n.message,e);break}return t};function jr(r,e){return{...y(r.innerType._def,e),default:r.defaultValue()}}function Ir(r,e){return e.effectStrategy==="input"?y(r.schema._def,e):{}}function Ar(r){return{type:"string",enum:Array.from(r.values)}}var da=r=>"type"in r&&r.type==="string"?!1:"allOf"in r;function Dr(r,e){let t=[y(r.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),y(r.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(a=>!!a),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return t.forEach(a=>{if(da(a))s.push(...a.allOf),a.unevaluatedProperties===void 0&&(n=void 0);else{let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){let{additionalProperties:c,...l}=a;i=l}else n=void 0;s.push(i)}}),s.length?{allOf:s,...n}:void 0}function Mr(r,e){let t=typeof r.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(r.value)?"array":"object"}:e.target==="openApi3"?{type:t==="bigint"?"integer":t,enum:[r.value]}:{type:t==="bigint"?"integer":t,const:r.value}}var It,V={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(It===void 0&&(It=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),It),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function dt(r,e){let t={type:"string"};if(r.checks)for(let n of r.checks)switch(n.kind){case"min":x(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,n.value):n.value,n.message,e);break;case"max":x(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":H(t,"email",n.message,e);break;case"format:idn-email":H(t,"idn-email",n.message,e);break;case"pattern:zod":C(t,V.email,n.message,e);break}break;case"url":H(t,"uri",n.message,e);break;case"uuid":H(t,"uuid",n.message,e);break;case"regex":C(t,n.regex,n.message,e);break;case"cuid":C(t,V.cuid,n.message,e);break;case"cuid2":C(t,V.cuid2,n.message,e);break;case"startsWith":C(t,RegExp(`^${At(n.value,e)}`),n.message,e);break;case"endsWith":C(t,RegExp(`${At(n.value,e)}$`),n.message,e);break;case"datetime":H(t,"date-time",n.message,e);break;case"date":H(t,"date",n.message,e);break;case"time":H(t,"time",n.message,e);break;case"duration":H(t,"duration",n.message,e);break;case"length":x(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,n.value):n.value,n.message,e),x(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,n.value):n.value,n.message,e);break;case"includes":{C(t,RegExp(At(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&H(t,"ipv4",n.message,e),n.version!=="v4"&&H(t,"ipv6",n.message,e);break}case"base64url":C(t,V.base64url,n.message,e);break;case"jwt":C(t,V.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&C(t,V.ipv4Cidr,n.message,e),n.version!=="v4"&&C(t,V.ipv6Cidr,n.message,e);break}case"emoji":C(t,V.emoji(),n.message,e);break;case"ulid":{C(t,V.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{H(t,"binary",n.message,e);break}case"contentEncoding:base64":{x(t,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{C(t,V.base64,n.message,e);break}}break}case"nanoid":C(t,V.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return t}function At(r,e){return e.patternStrategy==="escape"?ma(r):r}var pa=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ma(r){let e="";for(let t=0;t<r.length;t++)pa.has(r[t])||(e+="\\"),e+=r[t];return e}function H(r,e,t,n){r.format||r.anyOf?.some(s=>s.format)?(r.anyOf||(r.anyOf=[]),r.format&&(r.anyOf.push({format:r.format,...r.errorMessage&&n.errorMessages&&{errorMessage:{format:r.errorMessage.format}}}),delete r.format,r.errorMessage&&(delete r.errorMessage.format,Object.keys(r.errorMessage).length===0&&delete r.errorMessage)),r.anyOf.push({format:e,...t&&n.errorMessages&&{errorMessage:{format:t}}})):x(r,"format",e,t,n)}function C(r,e,t,n){r.pattern||r.allOf?.some(s=>s.pattern)?(r.allOf||(r.allOf=[]),r.pattern&&(r.allOf.push({pattern:r.pattern,...r.errorMessage&&n.errorMessages&&{errorMessage:{pattern:r.errorMessage.pattern}}}),delete r.pattern,r.errorMessage&&(delete r.errorMessage.pattern,Object.keys(r.errorMessage).length===0&&delete r.errorMessage)),r.allOf.push({pattern:$r(e,n),...t&&n.errorMessages&&{errorMessage:{pattern:t}}})):x(r,"pattern",$r(e,n),t,n)}function $r(r,e){if(!e.applyRegexFlags||!r.flags)return r.source;let t={i:r.flags.includes("i"),m:r.flags.includes("m"),s:r.flags.includes("s")},n=t.i?r.source.toLowerCase():r.source,s="",a=!1,i=!1,c=!1;for(let l=0;l<n.length;l++){if(a){s+=n[l],a=!1;continue}if(t.i){if(i){if(n[l].match(/[a-z]/)){c?(s+=n[l],s+=`${n[l-2]}-${n[l]}`.toUpperCase(),c=!1):n[l+1]==="-"&&n[l+2]?.match(/[a-z]/)?(s+=n[l],c=!0):s+=`${n[l]}${n[l].toUpperCase()}`;continue}}else if(n[l].match(/[a-z]/)){s+=`[${n[l]}${n[l].toUpperCase()}]`;continue}}if(t.m){if(n[l]==="^"){s+=`(^|(?<=[\r
2
+ "use strict";var bn=Object.create;var Bt=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var kn=Object.getOwnPropertyNames;var wn=Object.getPrototypeOf,Sn=Object.prototype.hasOwnProperty;var vt=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Tn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of kn(e))!Sn.call(r,s)&&s!==t&&Bt(r,s,{get:()=>e[s],enumerable:!(n=xn(e,s))||n.enumerable});return r};var _t=(r,e,t)=>(t=r!=null?bn(wn(r)):{},Tn(e||!r||!r.__esModule?Bt(t,"default",{value:r,enumerable:!0}):t,r));var sn=vt((cl,Sa)=>{Sa.exports={name:"dotenv",version:"16.4.5",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard","lint-readme":"standard-markdown",pretest:"npm run lint && npm run dts-check",test:"tap tests/*.js --100 -Rspec","test:coverage":"tap --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@definitelytyped/dtslint":"^0.0.133","@types/node":"^18.11.3",decache:"^4.6.1",sinon:"^14.0.1",standard:"^17.0.0","standard-markdown":"^7.1.0","standard-version":"^9.5.0",tap:"^16.3.0",tar:"^6.1.11",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var ln=vt((ll,K)=>{var Zt=require("fs"),Lt=require("path"),Ta=require("os"),Ra=require("crypto"),Ea=sn(),qt=Ea.version,Pa=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Ca(r){let e={},t=r.toString();t=t.replace(/\r\n?/mg,`
3
+ `);let n;for(;(n=Pa.exec(t))!=null;){let s=n[1],a=n[2]||"";a=a.trim();let i=a[0];a=a.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),i==='"'&&(a=a.replace(/\\n/g,`
4
+ `),a=a.replace(/\\r/g,"\r")),e[s]=a}return e}function Oa(r){let e=cn(r),t=R.configDotenv({path:e});if(!t.parsed){let i=new Error(`MISSING_DATA: Cannot parse ${e} for an unknown reason`);throw i.code="MISSING_DATA",i}let n=on(r).split(","),s=n.length,a;for(let i=0;i<s;i++)try{let c=n[i].trim(),l=Ia(t,c);a=R.decrypt(l.ciphertext,l.key);break}catch(c){if(i+1>=s)throw c}return R.parse(a)}function Na(r){console.log(`[dotenv@${qt}][INFO] ${r}`)}function ja(r){console.log(`[dotenv@${qt}][WARN] ${r}`)}function yt(r){console.log(`[dotenv@${qt}][DEBUG] ${r}`)}function on(r){return r&&r.DOTENV_KEY&&r.DOTENV_KEY.length>0?r.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function Ia(r,e){let t;try{t=new URL(e)}catch(c){if(c.code==="ERR_INVALID_URL"){let l=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw l.code="INVALID_DOTENV_KEY",l}throw c}let n=t.password;if(!n){let c=new Error("INVALID_DOTENV_KEY: Missing key part");throw c.code="INVALID_DOTENV_KEY",c}let s=t.searchParams.get("environment");if(!s){let c=new Error("INVALID_DOTENV_KEY: Missing environment part");throw c.code="INVALID_DOTENV_KEY",c}let a=`DOTENV_VAULT_${s.toUpperCase()}`,i=r.parsed[a];if(!i){let c=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw c.code="NOT_FOUND_DOTENV_ENVIRONMENT",c}return{ciphertext:i,key:n}}function cn(r){let e=null;if(r&&r.path&&r.path.length>0)if(Array.isArray(r.path))for(let t of r.path)Zt.existsSync(t)&&(e=t.endsWith(".vault")?t:`${t}.vault`);else e=r.path.endsWith(".vault")?r.path:`${r.path}.vault`;else e=Lt.resolve(process.cwd(),".env.vault");return Zt.existsSync(e)?e:null}function an(r){return r[0]==="~"?Lt.join(Ta.homedir(),r.slice(1)):r}function Aa(r){Na("Loading env from encrypted .env.vault");let e=R._parseVault(r),t=process.env;return r&&r.processEnv!=null&&(t=r.processEnv),R.populate(t,e,r),{parsed:e}}function Da(r){let e=Lt.resolve(process.cwd(),".env"),t="utf8",n=!!(r&&r.debug);r&&r.encoding?t=r.encoding:n&&yt("No encoding is specified. UTF-8 is used by default");let s=[e];if(r&&r.path)if(!Array.isArray(r.path))s=[an(r.path)];else{s=[];for(let l of r.path)s.push(an(l))}let a,i={};for(let l of s)try{let u=R.parse(Zt.readFileSync(l,{encoding:t}));R.populate(i,u,r)}catch(u){n&&yt(`Failed to load ${l} ${u.message}`),a=u}let c=process.env;return r&&r.processEnv!=null&&(c=r.processEnv),R.populate(c,i,r),a?{parsed:i,error:a}:{parsed:i}}function Ma(r){if(on(r).length===0)return R.configDotenv(r);let e=cn(r);return e?R._configVault(r):(ja(`You set DOTENV_KEY but you are missing a .env.vault file at ${e}. Did you forget to build it?`),R.configDotenv(r))}function $a(r,e){let t=Buffer.from(e.slice(-64),"hex"),n=Buffer.from(r,"base64"),s=n.subarray(0,12),a=n.subarray(-16);n=n.subarray(12,-16);try{let i=Ra.createDecipheriv("aes-256-gcm",t,s);return i.setAuthTag(a),`${i.update(n)}${i.final()}`}catch(i){let c=i instanceof RangeError,l=i.message==="Invalid key length",u=i.message==="Unsupported state or unable to authenticate data";if(c||l){let m=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw m.code="INVALID_DOTENV_KEY",m}else if(u){let m=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw m.code="DECRYPTION_FAILED",m}else throw i}}function Za(r,e,t={}){let n=!!(t&&t.debug),s=!!(t&&t.override);if(typeof e!="object"){let a=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw a.code="OBJECT_REQUIRED",a}for(let a of Object.keys(e))Object.prototype.hasOwnProperty.call(r,a)?(s===!0&&(r[a]=e[a]),n&&yt(s===!0?`"${a}" is already defined and WAS overwritten`:`"${a}" is already defined and was NOT overwritten`)):r[a]=e[a]}var R={configDotenv:Da,_configVault:Aa,_parseVault:Oa,config:Ma,decrypt:$a,parse:Ca,populate:Za};K.exports.configDotenv=R.configDotenv;K.exports._configVault=R._configVault;K.exports._parseVault=R._parseVault;K.exports.config=R.config;K.exports.decrypt=R.decrypt;K.exports.parse=R.parse;K.exports.populate=R.populate;K.exports=R});var pn=vt((ul,dn)=>{"use strict";var Vt=Object.defineProperty,La=Object.getOwnPropertyDescriptor,qa=Object.getOwnPropertyNames,Va=Object.prototype.hasOwnProperty,Ha=(r,e)=>{for(var t in e)Vt(r,t,{get:e[t],enumerable:!0})},za=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of qa(e))!Va.call(r,s)&&s!==t&&Vt(r,s,{get:()=>e[s],enumerable:!(n=La(e,s))||n.enumerable});return r},Ua=r=>za(Vt({},"__esModule",{value:!0}),r),un={};Ha(un,{default:()=>Ja});dn.exports=Ua(un);var Ba=class{baseUrl;defaultHeaders;constructor(r,e={}){this.baseUrl=r,this.defaultHeaders=e}buildUrl(r){return`${this.baseUrl.replace(/\/$/,"")}/${r.replace(/^\//,"")}`}async request(r,e,t,n={}){let s=this.buildUrl(e),a=await fetch(s,{method:r,headers:{"Content-Type":"application/json",...this.defaultHeaders,...n},body:t?JSON.stringify(t):void 0});if(!a.ok){let c=await a.text().catch(()=>"");throw new Error(`HTTP ${a.status} ${a.statusText}: ${c||"Request failed"}`)}let i=await a.text();try{return JSON.parse(i)}catch{return i}}get(r,e){return this.request("GET",r,void 0,e)}post(r,e,t){return this.request("POST",r,e,t)}put(r,e,t){return this.request("PUT",r,e,t)}delete(r,e){return this.request("DELETE",r,void 0,e)}},Me=new Ba("https://api.derived.dev/api/public"),Fa=class{constructor(){}fetchBlock=async r=>Me.get(`/v1/template-group/code/${r}`);getBlockInputFromUserQuery=(r,e)=>Me.post("/v1/template-group/get-block-input-from-user-query",{blockInput:r,query:e});resolveMultipleTemplates=(r,e)=>Me.post("/v1/template-group/resolve-multiple-templates-by-block-code",{blockCode:r,data:e});searchBlocksByName=r=>Me.get(`/v1/template-group/semantic-search?q=${r}&limit=5&threshold=0.5`);fetchProjectBySlug=async r=>Me.get(`/v1/project/detail-by-slug/${r}`)},Ja=Fa});var k;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},r.getValidEnumValues=s=>{let a=r.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),i={};for(let c of a)i[c]=s[c];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(let i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(k||(k={}));var xt;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(xt||(xt={}));var h=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),G=r=>{switch(typeof r){case"undefined":return h.undefined;case"string":return h.string;case"number":return isNaN(r)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(r)?h.array:r===null?h.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?h.promise:typeof Map<"u"&&r instanceof Map?h.map:typeof Set<"u"&&r instanceof Set?h.set:typeof Date<"u"&&r instanceof Date?h.date:h.object;default:return h.unknown}},p=k.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"]),Rn=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),j=class r extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let c=n,l=0;for(;l<i.path.length;){let u=i.path[l];l===i.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(i))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}};return s(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};j.create=r=>new j(r);var be=(r,e)=>{let t;switch(r.code){case p.invalid_type:r.received===h.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case p.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,k.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:t=`Unrecognized key(s) in object: ${k.joinValues(r.keys,", ")}`;break;case p.invalid_union:t="Invalid input";break;case p.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${k.joinValues(r.options)}`;break;case p.invalid_enum_value:t=`Invalid enum value. Expected ${k.joinValues(r.options)}, received '${r.received}'`;break;case p.invalid_arguments:t="Invalid function arguments";break;case p.invalid_return_type:t="Invalid function return type";break;case p.invalid_date:t="Invalid date";break;case p.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:k.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case p.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case p.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case p.custom:t="Invalid input";break;case p.invalid_intersection_types:t="Intersection results could not be merged";break;case p.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case p.not_finite:t="Number must be finite";break;default:t=e.defaultError,k.assertNever(r)}return{message:t}},Wt=be;function En(r){Wt=r}function $e(){return Wt}var Ze=r=>{let{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let c="",l=n.filter(u=>!!u).slice().reverse();for(let u of l)c=u(i,{data:e,defaultError:c}).message;return{...s,path:a,message:c}},Pn=[];function f(r,e){let t=$e(),n=Ze({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===be?void 0:be].filter(s=>!!s)});r.common.issues.push(n)}var E=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let s of t){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let s of t){let a=await s.key,i=await s.value;n.push({key:a,value:i})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return v;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},v=Object.freeze({status:"aborted"}),_e=r=>({status:"dirty",value:r}),P=r=>({status:"valid",value:r}),kt=r=>r.status==="aborted",wt=r=>r.status==="dirty",Oe=r=>r.status==="valid",Ne=r=>typeof Promise<"u"&&r instanceof Promise;function Le(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function Yt(r,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(r,t):s?s.value=t:e.set(r,t),t}var g;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(g||(g={}));var Pe,Ce,$=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ft=(r,e)=>{if(Oe(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new j(r.common.issues);return this._error=t,this._error}}};function b(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,c)=>{var l,u;let{message:m}=r;return i.code==="invalid_enum_value"?{message:m??c.defaultError}:typeof c.data>"u"?{message:(l=m??n)!==null&&l!==void 0?l:c.defaultError}:i.code!=="invalid_type"?{message:c.defaultError}:{message:(u=m??t)!==null&&u!==void 0?u:c.defaultError}},description:s}}var _=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,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)}get description(){return this._def.description}_getType(e){return G(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:G(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new E,ctx:{common:e.parent.common,data:e.data,parsedType:G(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Ne(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let s={common:{issues:[],async:(n=t?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Ft(s,a)}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Ne(s)?s:Promise.resolve(s));return Ft(n,a)}refine(e,t){let n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{let i=e(s),c=()=>a.addIssue({code:p.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(c(),!1)):i?!0:(c(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new I({schema:this,typeName:d.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return O.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Y.create(this,this._def)}promise(){return ee.create(this,this._def)}or(e){return le.create([this,e],this._def)}and(e){return ue.create(this,e,this._def)}transform(e){return new I({...b(this._def),schema:this,typeName:d.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new he({...b(this._def),innerType:this,defaultValue:t,typeName:d.ZodDefault})}brand(){return new je({typeName:d.ZodBranded,type:this,...b(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new ge({...b(this._def),innerType:this,catchValue:t,typeName:d.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ie.create(this,e)}readonly(){return ye.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Cn=/^c[^\s-]{8,}$/i,On=/^[0-9a-z]+$/,Nn=/^[0-9A-HJKMNP-TV-Z]{26}$/,jn=/^[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,In=/^[a-z0-9_-]{21}$/i,An=/^[-+]?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)?)??$/,Dn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Mn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",bt,$n=/^(?:(?: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])$/,Zn=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ln=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Kt="((\\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])))",qn=new RegExp(`^${Kt}$`);function Gt(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Vn(r){return new RegExp(`^${Gt(r)}$`)}function Xt(r){let e=`${Kt}T${Gt(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Hn(r,e){return!!((e==="v4"||!e)&&$n.test(r)||(e==="v6"||!e)&&Zn.test(r))}var X=class r extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){let a=this._getOrReturnCtx(e);return f(a,{code:p.invalid_type,expected:h.string,received:a.parsedType}),v}let n=new E,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,c=e.data.length<a.value;(i||c)&&(s=this._getOrReturnCtx(e,s),i?f(s,{code:p.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):c&&f(s,{code:p.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Dn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")bt||(bt=new RegExp(Mn,"u")),bt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")jn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")In.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Cn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")On.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:p.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:p.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:p.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Xt(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?qn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Vn(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?An.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:p.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Hn(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:p.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:p.invalid_string,message:a.message}),n.dirty()):k.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:p.invalid_string,...g.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(n=e?.local)!==null&&n!==void 0?n:!1,...g.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...g.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...g.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...g.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...g.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...g.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...g.errToObj(t)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};X.create=r=>{var e;return new X({checks:[],typeName:d.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...b(r)})};function zn(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}var ne=class r extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){let a=this._getOrReturnCtx(e);return f(a,{code:p.invalid_type,expected:h.number,received:a.parsedType}),v}let n,s=new E;for(let a of this._def.checks)a.kind==="int"?k.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:p.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:p.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:p.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?zn(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:p.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:p.not_finite,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:g.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};ne.create=r=>new ne({checks:[],typeName:d.ZodNumber,coerce:r?.coerce||!1,...b(r)});var se=class r extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==h.bigint){let a=this._getOrReturnCtx(e);return f(a,{code:p.invalid_type,expected:h.bigint,received:a.parsedType}),v}let n,s=new E;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:p.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:p.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:p.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:g.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};se.create=r=>{var e;return new se({checks:[],typeName:d.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...b(r)})};var ae=class extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){let n=this._getOrReturnCtx(e);return f(n,{code:p.invalid_type,expected:h.boolean,received:n.parsedType}),v}return P(e.data)}};ae.create=r=>new ae({typeName:d.ZodBoolean,coerce:r?.coerce||!1,...b(r)});var ie=class r extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){let a=this._getOrReturnCtx(e);return f(a,{code:p.invalid_type,expected:h.date,received:a.parsedType}),v}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return f(a,{code:p.invalid_date}),v}let n=new E,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):k.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};ie.create=r=>new ie({checks:[],coerce:r?.coerce||!1,typeName:d.ZodDate,...b(r)});var xe=class extends _{_parse(e){if(this._getType(e)!==h.symbol){let n=this._getOrReturnCtx(e);return f(n,{code:p.invalid_type,expected:h.symbol,received:n.parsedType}),v}return P(e.data)}};xe.create=r=>new xe({typeName:d.ZodSymbol,...b(r)});var oe=class extends _{_parse(e){if(this._getType(e)!==h.undefined){let n=this._getOrReturnCtx(e);return f(n,{code:p.invalid_type,expected:h.undefined,received:n.parsedType}),v}return P(e.data)}};oe.create=r=>new oe({typeName:d.ZodUndefined,...b(r)});var ce=class extends _{_parse(e){if(this._getType(e)!==h.null){let n=this._getOrReturnCtx(e);return f(n,{code:p.invalid_type,expected:h.null,received:n.parsedType}),v}return P(e.data)}};ce.create=r=>new ce({typeName:d.ZodNull,...b(r)});var Q=class extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}};Q.create=r=>new Q({typeName:d.ZodAny,...b(r)});var W=class extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}};W.create=r=>new W({typeName:d.ZodUnknown,...b(r)});var Z=class extends _{_parse(e){let t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:h.never,received:t.parsedType}),v}};Z.create=r=>new Z({typeName:d.ZodNever,...b(r)});var ke=class extends _{_parse(e){if(this._getType(e)!==h.undefined){let n=this._getOrReturnCtx(e);return f(n,{code:p.invalid_type,expected:h.void,received:n.parsedType}),v}return P(e.data)}};ke.create=r=>new ke({typeName:d.ZodVoid,...b(r)});var Y=class r extends _{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==h.array)return f(t,{code:p.invalid_type,expected:h.array,received:t.parsedType}),v;if(s.exactLength!==null){let i=t.data.length>s.exactLength.value,c=t.data.length<s.exactLength.value;(i||c)&&(f(t,{code:i?p.too_big:p.too_small,minimum:c?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(f(t,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(f(t,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,c)=>s.type._parseAsync(new $(t,i,t.path,c)))).then(i=>E.mergeArray(n,i));let a=[...t.data].map((i,c)=>s.type._parseSync(new $(t,i,t.path,c)));return E.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:g.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:g.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:g.toString(t)}})}nonempty(e){return this.min(1,e)}};Y.create=(r,e)=>new Y({type:r,minLength:null,maxLength:null,exactLength:null,typeName:d.ZodArray,...b(e)});function ve(r){if(r instanceof N){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=O.create(ve(n))}return new N({...r._def,shape:()=>e})}else return r instanceof Y?new Y({...r._def,type:ve(r.element)}):r instanceof O?O.create(ve(r.unwrap())):r instanceof B?B.create(ve(r.unwrap())):r instanceof U?U.create(r.items.map(e=>ve(e))):r}var N=class r extends _{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==h.object){let u=this._getOrReturnCtx(e);return f(u,{code:p.invalid_type,expected:h.object,received:u.parsedType}),v}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),c=[];if(!(this._def.catchall instanceof Z&&this._def.unknownKeys==="strip"))for(let u in s.data)i.includes(u)||c.push(u);let l=[];for(let u of i){let m=a[u],w=s.data[u];l.push({key:{status:"valid",value:u},value:m._parse(new $(s,w,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Z){let u=this._def.unknownKeys;if(u==="passthrough")for(let m of c)l.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(u==="strict")c.length>0&&(f(s,{code:p.unrecognized_keys,keys:c}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let m of c){let w=s.data[m];l.push({key:{status:"valid",value:m},value:u._parse(new $(s,w,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let m of l){let w=await m.key,D=await m.value;u.push({key:w,value:D,alwaysSet:m.alwaysSet})}return u}).then(u=>E.mergeObjectSync(n,u)):E.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,c;let l=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(c=g.errToObj(e).message)!==null&&c!==void 0?c:l}:{message:l}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:d.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};return k.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}omit(e){let t={};return k.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new r({...this._def,shape:()=>t})}deepPartial(){return ve(this)}partial(e){let t={};return k.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new r({...this._def,shape:()=>t})}required(e){let t={};return k.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof O;)a=a._def.innerType;t[n]=a}}),new r({...this._def,shape:()=>t})}keyof(){return Qt(k.objectKeys(this.shape))}};N.create=(r,e)=>new N({shape:()=>r,unknownKeys:"strip",catchall:Z.create(),typeName:d.ZodObject,...b(e)});N.strictCreate=(r,e)=>new N({shape:()=>r,unknownKeys:"strict",catchall:Z.create(),typeName:d.ZodObject,...b(e)});N.lazycreate=(r,e)=>new N({shape:r,unknownKeys:"strip",catchall:Z.create(),typeName:d.ZodObject,...b(e)});var le=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(let c of a)if(c.result.status==="valid")return c.result;for(let c of a)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;let i=a.map(c=>new j(c.ctx.common.issues));return f(t,{code:p.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(n.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a,i=[];for(let l of n){let u={...t,common:{...t.common,issues:[]},parent:null},m=l._parseSync({data:t.data,path:t.path,parent:u});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let c=i.map(l=>new j(l));return f(t,{code:p.invalid_union,unionErrors:c}),v}}get options(){return this._def.options}};le.create=(r,e)=>new le({options:r,typeName:d.ZodUnion,...b(e)});var J=r=>r instanceof de?J(r.schema):r instanceof I?J(r.innerType()):r instanceof pe?[r.value]:r instanceof me?r.options:r instanceof fe?k.objectValues(r.enum):r instanceof he?J(r._def.innerType):r instanceof oe?[void 0]:r instanceof ce?[null]:r instanceof O?[void 0,...J(r.unwrap())]:r instanceof B?[null,...J(r.unwrap())]:r instanceof je||r instanceof ye?J(r.unwrap()):r instanceof ge?J(r._def.innerType):[],qe=class r extends _{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return f(t,{code:p.invalid_type,expected:h.object,received:t.parsedType}),v;let n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(f(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let a of t){let i=J(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of i){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,a)}}return new r({typeName:d.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...b(n)})}};function St(r,e){let t=G(r),n=G(e);if(r===e)return{valid:!0,data:r};if(t===h.object&&n===h.object){let s=k.objectKeys(e),a=k.objectKeys(r).filter(c=>s.indexOf(c)!==-1),i={...r,...e};for(let c of a){let l=St(r[c],e[c]);if(!l.valid)return{valid:!1};i[c]=l.data}return{valid:!0,data:i}}else if(t===h.array&&n===h.array){if(r.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<r.length;a++){let i=r[a],c=e[a],l=St(i,c);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return t===h.date&&n===h.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var ue=class extends _{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(kt(a)||kt(i))return v;let c=St(a.value,i.value);return c.valid?((wt(a)||wt(i))&&t.dirty(),{status:t.value,value:c.data}):(f(n,{code:p.invalid_intersection_types}),v)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ue.create=(r,e,t)=>new ue({left:r,right:e,typeName:d.ZodIntersection,...b(t)});var U=class r extends _{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return f(n,{code:p.invalid_type,expected:h.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return f(n,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(f(n,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...n.data].map((i,c)=>{let l=this._def.items[c]||this._def.rest;return l?l._parse(new $(n,i,n.path,c)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>E.mergeArray(t,i)):E.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};U.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new U({items:r,typeName:d.ZodTuple,rest:null,...b(e)})};var Ve=class r extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return f(n,{code:p.invalid_type,expected:h.object,received:n.parsedType}),v;let s=[],a=this._def.keyType,i=this._def.valueType;for(let c in n.data)s.push({key:a._parse(new $(n,c,n.path,c)),value:i._parse(new $(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?E.mergeObjectAsync(t,s):E.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof _?new r({keyType:e,valueType:t,typeName:d.ZodRecord,...b(n)}):new r({keyType:X.create(),valueType:e,typeName:d.ZodRecord,...b(t)})}},we=class extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return f(n,{code:p.invalid_type,expected:h.map,received:n.parsedType}),v;let s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([c,l],u)=>({key:s._parse(new $(n,c,n.path,[u,"key"])),value:a._parse(new $(n,l,n.path,[u,"value"]))}));if(n.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let l of i){let u=await l.key,m=await l.value;if(u.status==="aborted"||m.status==="aborted")return v;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(u.value,m.value)}return{status:t.value,value:c}})}else{let c=new Map;for(let l of i){let u=l.key,m=l.value;if(u.status==="aborted"||m.status==="aborted")return v;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(u.value,m.value)}return{status:t.value,value:c}}}};we.create=(r,e,t)=>new we({valueType:e,keyType:r,typeName:d.ZodMap,...b(t)});var Se=class r extends _{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return f(n,{code:p.invalid_type,expected:h.set,received:n.parsedType}),v;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(f(n,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(f(n,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let a=this._def.valueType;function i(l){let u=new Set;for(let m of l){if(m.status==="aborted")return v;m.status==="dirty"&&t.dirty(),u.add(m.value)}return{status:t.value,value:u}}let c=[...n.data.values()].map((l,u)=>a._parse(new $(n,l,n.path,u)));return n.common.async?Promise.all(c).then(l=>i(l)):i(c)}min(e,t){return new r({...this._def,minSize:{value:e,message:g.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:g.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Se.create=(r,e)=>new Se({valueType:r,minSize:null,maxSize:null,typeName:d.ZodSet,...b(e)});var He=class r extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.function)return f(t,{code:p.invalid_type,expected:h.function,received:t.parsedType}),v;function n(c,l){return Ze({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$e(),be].filter(u=>!!u),issueData:{code:p.invalid_arguments,argumentsError:l}})}function s(c,l){return Ze({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$e(),be].filter(u=>!!u),issueData:{code:p.invalid_return_type,returnTypeError:l}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ee){let c=this;return P(async function(...l){let u=new j([]),m=await c._def.args.parseAsync(l,a).catch(te=>{throw u.addIssue(n(l,te)),u}),w=await Reflect.apply(i,this,m);return await c._def.returns._def.type.parseAsync(w,a).catch(te=>{throw u.addIssue(s(w,te)),u})})}else{let c=this;return P(function(...l){let u=c._def.args.safeParse(l,a);if(!u.success)throw new j([n(l,u.error)]);let m=Reflect.apply(i,this,u.data),w=c._def.returns.safeParse(m,a);if(!w.success)throw new j([s(m,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:U.create(e).rest(W.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||U.create([]).rest(W.create()),returns:t||W.create(),typeName:d.ZodFunction,...b(n)})}},de=class extends _{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};de.create=(r,e)=>new de({getter:r,typeName:d.ZodLazy,...b(e)});var pe=class extends _{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};pe.create=(r,e)=>new pe({value:r,typeName:d.ZodLiteral,...b(e)});function Qt(r,e){return new me({values:r,typeName:d.ZodEnum,...b(e)})}var me=class r extends _{constructor(){super(...arguments),Pe.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{expected:k.joinValues(n),received:t.parsedType,code:p.invalid_type}),v}if(Le(this,Pe,"f")||Yt(this,Pe,new Set(this._def.values),"f"),!Le(this,Pe,"f").has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{received:t.data,code:p.invalid_enum_value,options:n}),v}return P(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Pe=new WeakMap;me.create=Qt;var fe=class extends _{constructor(){super(...arguments),Ce.set(this,void 0)}_parse(e){let t=k.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){let s=k.objectValues(t);return f(n,{expected:k.joinValues(s),received:n.parsedType,code:p.invalid_type}),v}if(Le(this,Ce,"f")||Yt(this,Ce,new Set(k.getValidEnumValues(this._def.values)),"f"),!Le(this,Ce,"f").has(e.data)){let s=k.objectValues(t);return f(n,{received:n.data,code:p.invalid_enum_value,options:s}),v}return P(e.data)}get enum(){return this._def.values}};Ce=new WeakMap;fe.create=(r,e)=>new fe({values:r,typeName:d.ZodNativeEnum,...b(e)});var ee=class extends _{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return f(t,{code:p.invalid_type,expected:h.promise,received:t.parsedType}),v;let n=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return P(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ee.create=(r,e)=>new ee({type:r,typeName:d.ZodPromise,...b(e)});var I=class extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===d.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{f(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async c=>{if(t.value==="aborted")return v;let l=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return l.status==="aborted"?v:l.status==="dirty"||t.value==="dirty"?_e(l.value):l});{if(t.value==="aborted")return v;let c=this._def.schema._parseSync({data:i,path:n.path,parent:n});return c.status==="aborted"?v:c.status==="dirty"||t.value==="dirty"?_e(c.value):c}}if(s.type==="refinement"){let i=c=>{let l=s.refinement(c,a);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){let c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?v:(c.status==="dirty"&&t.dirty(),i(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?v:(c.status==="dirty"&&t.dirty(),i(c.value).then(()=>({status:t.value,value:c.value}))))}if(s.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Oe(i))return i;let c=s.transform(i.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Oe(i)?Promise.resolve(s.transform(i.value,a)).then(c=>({status:t.value,value:c})):i);k.assertNever(s)}};I.create=(r,e,t)=>new I({schema:r,typeName:d.ZodEffects,effect:e,...b(t)});I.createWithPreprocess=(r,e,t)=>new I({schema:e,effect:{type:"preprocess",transform:r},typeName:d.ZodEffects,...b(t)});var O=class extends _{_parse(e){return this._getType(e)===h.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};O.create=(r,e)=>new O({innerType:r,typeName:d.ZodOptional,...b(e)});var B=class extends _{_parse(e){return this._getType(e)===h.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};B.create=(r,e)=>new B({innerType:r,typeName:d.ZodNullable,...b(e)});var he=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};he.create=(r,e)=>new he({innerType:r,typeName:d.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});var ge=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ne(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ge.create=(r,e)=>new ge({innerType:r,typeName:d.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});var Te=class extends _{_parse(e){if(this._getType(e)!==h.nan){let n=this._getOrReturnCtx(e);return f(n,{code:p.invalid_type,expected:h.nan,received:n.parsedType}),v}return{status:"valid",value:e.data}}};Te.create=r=>new Te({typeName:d.ZodNaN,...b(r)});var Un=Symbol("zod_brand"),je=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Ie=class r extends _{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),_e(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:d.ZodPipeline})}},ye=class extends _{_parse(e){let t=this._def.innerType._parse(e),n=s=>(Oe(s)&&(s.value=Object.freeze(s.value)),s);return Ne(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};ye.create=(r,e)=>new ye({innerType:r,typeName:d.ZodReadonly,...b(e)});function er(r,e={},t){return r?Q.create().superRefine((n,s)=>{var a,i;if(!r(n)){let c=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,l=(i=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof c=="string"?{message:c}:c;s.addIssue({code:"custom",...u,fatal:l})}}):Q.create()}var Bn={object:N.lazycreate},d;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(d||(d={}));var Fn=(r,e={message:`Input not instance of ${r.name}`})=>er(t=>t instanceof r,e),tr=X.create,rr=ne.create,Jn=Te.create,Wn=se.create,nr=ae.create,Yn=ie.create,Kn=xe.create,Gn=oe.create,Xn=ce.create,Qn=Q.create,es=W.create,ts=Z.create,rs=ke.create,ns=Y.create,ss=N.create,as=N.strictCreate,is=le.create,os=qe.create,cs=ue.create,ls=U.create,us=Ve.create,ds=we.create,ps=Se.create,ms=He.create,fs=de.create,hs=pe.create,gs=me.create,ys=fe.create,vs=ee.create,Jt=I.create,_s=O.create,bs=B.create,xs=I.createWithPreprocess,ks=Ie.create,ws=()=>tr().optional(),Ss=()=>rr().optional(),Ts=()=>nr().optional(),Rs={string:r=>X.create({...r,coerce:!0}),number:r=>ne.create({...r,coerce:!0}),boolean:r=>ae.create({...r,coerce:!0}),bigint:r=>se.create({...r,coerce:!0}),date:r=>ie.create({...r,coerce:!0})},Es=v,o=Object.freeze({__proto__:null,defaultErrorMap:be,setErrorMap:En,getErrorMap:$e,makeIssue:Ze,EMPTY_PATH:Pn,addIssueToContext:f,ParseStatus:E,INVALID:v,DIRTY:_e,OK:P,isAborted:kt,isDirty:wt,isValid:Oe,isAsync:Ne,get util(){return k},get objectUtil(){return xt},ZodParsedType:h,getParsedType:G,ZodType:_,datetimeRegex:Xt,ZodString:X,ZodNumber:ne,ZodBigInt:se,ZodBoolean:ae,ZodDate:ie,ZodSymbol:xe,ZodUndefined:oe,ZodNull:ce,ZodAny:Q,ZodUnknown:W,ZodNever:Z,ZodVoid:ke,ZodArray:Y,ZodObject:N,ZodUnion:le,ZodDiscriminatedUnion:qe,ZodIntersection:ue,ZodTuple:U,ZodRecord:Ve,ZodMap:we,ZodSet:Se,ZodFunction:He,ZodLazy:de,ZodLiteral:pe,ZodEnum:me,ZodNativeEnum:fe,ZodPromise:ee,ZodEffects:I,ZodTransformer:I,ZodOptional:O,ZodNullable:B,ZodDefault:he,ZodCatch:ge,ZodNaN:Te,BRAND:Un,ZodBranded:je,ZodPipeline:Ie,ZodReadonly:ye,custom:er,Schema:_,ZodSchema:_,late:Bn,get ZodFirstPartyTypeKind(){return d},coerce:Rs,any:Qn,array:ns,bigint:Wn,boolean:nr,date:Yn,discriminatedUnion:os,effect:Jt,enum:gs,function:ms,instanceof:Fn,intersection:cs,lazy:fs,literal:hs,map:ds,nan:Jn,nativeEnum:ys,never:ts,null:Xn,nullable:bs,number:rr,object:ss,oboolean:Ts,onumber:Ss,optional:_s,ostring:ws,pipeline:ks,preprocess:xs,promise:vs,record:us,set:ps,strictObject:as,string:tr,symbol:Kn,transformer:Jt,tuple:ls,undefined:Gn,union:is,unknown:es,void:rs,NEVER:Es,ZodIssueCode:p,quotelessJson:Rn,ZodError:j});var Tt="2025-03-26",sr=[Tt,"2024-11-05","2024-10-07"],ze="2.0",ar=o.union([o.string(),o.number().int()]),ir=o.string(),Ps=o.object({progressToken:o.optional(ar)}).passthrough(),L=o.object({_meta:o.optional(Ps)}).passthrough(),A=o.object({method:o.string(),params:o.optional(L)}),Ae=o.object({_meta:o.optional(o.object({}).passthrough())}).passthrough(),F=o.object({method:o.string(),params:o.optional(Ae)}),q=o.object({_meta:o.optional(o.object({}).passthrough())}).passthrough(),Ue=o.union([o.string(),o.number().int()]),or=o.object({jsonrpc:o.literal(ze),id:Ue}).merge(A).strict(),cr=r=>or.safeParse(r).success,lr=o.object({jsonrpc:o.literal(ze)}).merge(F).strict(),ur=r=>lr.safeParse(r).success,dr=o.object({jsonrpc:o.literal(ze),id:Ue,result:q}).strict(),Rt=r=>dr.safeParse(r).success,S;(function(r){r[r.ConnectionClosed=-32e3]="ConnectionClosed",r[r.RequestTimeout=-32001]="RequestTimeout",r[r.ParseError=-32700]="ParseError",r[r.InvalidRequest=-32600]="InvalidRequest",r[r.MethodNotFound=-32601]="MethodNotFound",r[r.InvalidParams=-32602]="InvalidParams",r[r.InternalError=-32603]="InternalError"})(S||(S={}));var pr=o.object({jsonrpc:o.literal(ze),id:Ue,error:o.object({code:o.number().int(),message:o.string(),data:o.optional(o.unknown())})}).strict(),mr=r=>pr.safeParse(r).success,fr=o.union([or,lr,dr,pr]),Be=q.strict(),Fe=F.extend({method:o.literal("notifications/cancelled"),params:Ae.extend({requestId:Ue,reason:o.string().optional()})}),hr=o.object({name:o.string(),version:o.string()}).passthrough(),Cs=o.object({experimental:o.optional(o.object({}).passthrough()),sampling:o.optional(o.object({}).passthrough()),roots:o.optional(o.object({listChanged:o.optional(o.boolean())}).passthrough())}).passthrough(),Et=A.extend({method:o.literal("initialize"),params:L.extend({protocolVersion:o.string(),capabilities:Cs,clientInfo:hr})});var Os=o.object({experimental:o.optional(o.object({}).passthrough()),logging:o.optional(o.object({}).passthrough()),completions:o.optional(o.object({}).passthrough()),prompts:o.optional(o.object({listChanged:o.optional(o.boolean())}).passthrough()),resources:o.optional(o.object({subscribe:o.optional(o.boolean()),listChanged:o.optional(o.boolean())}).passthrough()),tools:o.optional(o.object({listChanged:o.optional(o.boolean())}).passthrough())}).passthrough(),Ns=q.extend({protocolVersion:o.string(),capabilities:Os,serverInfo:hr,instructions:o.optional(o.string())}),Pt=F.extend({method:o.literal("notifications/initialized")});var Je=A.extend({method:o.literal("ping")}),js=o.object({progress:o.number(),total:o.optional(o.number())}).passthrough(),We=F.extend({method:o.literal("notifications/progress"),params:Ae.merge(js).extend({progressToken:ar})}),Ye=A.extend({params:L.extend({cursor:o.optional(ir)}).optional()}),Ke=q.extend({nextCursor:o.optional(ir)}),gr=o.object({uri:o.string(),mimeType:o.optional(o.string())}).passthrough(),yr=gr.extend({text:o.string()}),vr=gr.extend({blob:o.string().base64()}),Is=o.object({uri:o.string(),name:o.string(),description:o.optional(o.string()),mimeType:o.optional(o.string())}).passthrough(),As=o.object({uriTemplate:o.string(),name:o.string(),description:o.optional(o.string()),mimeType:o.optional(o.string())}).passthrough(),Ge=Ye.extend({method:o.literal("resources/list")}),Ds=Ke.extend({resources:o.array(Is)}),Xe=Ye.extend({method:o.literal("resources/templates/list")}),Ms=Ke.extend({resourceTemplates:o.array(As)}),Qe=A.extend({method:o.literal("resources/read"),params:L.extend({uri:o.string()})}),$s=q.extend({contents:o.array(o.union([yr,vr]))}),Zs=F.extend({method:o.literal("notifications/resources/list_changed")}),Ls=A.extend({method:o.literal("resources/subscribe"),params:L.extend({uri:o.string()})}),qs=A.extend({method:o.literal("resources/unsubscribe"),params:L.extend({uri:o.string()})}),Vs=F.extend({method:o.literal("notifications/resources/updated"),params:Ae.extend({uri:o.string()})}),Hs=o.object({name:o.string(),description:o.optional(o.string()),required:o.optional(o.boolean())}).passthrough(),zs=o.object({name:o.string(),description:o.optional(o.string()),arguments:o.optional(o.array(Hs))}).passthrough(),et=Ye.extend({method:o.literal("prompts/list")}),Us=Ke.extend({prompts:o.array(zs)}),tt=A.extend({method:o.literal("prompts/get"),params:L.extend({name:o.string(),arguments:o.optional(o.record(o.string()))})}),rt=o.object({type:o.literal("text"),text:o.string()}).passthrough(),nt=o.object({type:o.literal("image"),data:o.string().base64(),mimeType:o.string()}).passthrough(),st=o.object({type:o.literal("audio"),data:o.string().base64(),mimeType:o.string()}).passthrough(),_r=o.object({type:o.literal("resource"),resource:o.union([yr,vr])}).passthrough(),Bs=o.object({role:o.enum(["user","assistant"]),content:o.union([rt,nt,st,_r])}).passthrough(),Fs=q.extend({description:o.optional(o.string()),messages:o.array(Bs)}),Js=F.extend({method:o.literal("notifications/prompts/list_changed")}),Ws=o.object({title:o.optional(o.string()),readOnlyHint:o.optional(o.boolean()),destructiveHint:o.optional(o.boolean()),idempotentHint:o.optional(o.boolean()),openWorldHint:o.optional(o.boolean())}).passthrough(),Ys=o.object({name:o.string(),description:o.optional(o.string()),inputSchema:o.object({type:o.literal("object"),properties:o.optional(o.object({}).passthrough())}).passthrough(),annotations:o.optional(Ws)}).passthrough(),at=Ye.extend({method:o.literal("tools/list")}),Ks=Ke.extend({tools:o.array(Ys)}),br=q.extend({content:o.array(o.union([rt,nt,st,_r])),isError:o.boolean().default(!1).optional()}),ei=br.or(q.extend({toolResult:o.unknown()})),it=A.extend({method:o.literal("tools/call"),params:L.extend({name:o.string(),arguments:o.optional(o.record(o.unknown()))})}),Gs=F.extend({method:o.literal("notifications/tools/list_changed")}),xr=o.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),Xs=A.extend({method:o.literal("logging/setLevel"),params:L.extend({level:xr})}),Qs=F.extend({method:o.literal("notifications/message"),params:Ae.extend({level:xr,logger:o.optional(o.string()),data:o.unknown()})}),ea=o.object({name:o.string().optional()}).passthrough(),ta=o.object({hints:o.optional(o.array(ea)),costPriority:o.optional(o.number().min(0).max(1)),speedPriority:o.optional(o.number().min(0).max(1)),intelligencePriority:o.optional(o.number().min(0).max(1))}).passthrough(),ra=o.object({role:o.enum(["user","assistant"]),content:o.union([rt,nt,st])}).passthrough(),na=A.extend({method:o.literal("sampling/createMessage"),params:L.extend({messages:o.array(ra),systemPrompt:o.optional(o.string()),includeContext:o.optional(o.enum(["none","thisServer","allServers"])),temperature:o.optional(o.number()),maxTokens:o.number().int(),stopSequences:o.optional(o.array(o.string())),metadata:o.optional(o.object({}).passthrough()),modelPreferences:o.optional(ta)})}),Ct=q.extend({model:o.string(),stopReason:o.optional(o.enum(["endTurn","stopSequence","maxTokens"]).or(o.string())),role:o.enum(["user","assistant"]),content:o.discriminatedUnion("type",[rt,nt,st])}),sa=o.object({type:o.literal("ref/resource"),uri:o.string()}).passthrough(),aa=o.object({type:o.literal("ref/prompt"),name:o.string()}).passthrough(),ot=A.extend({method:o.literal("completion/complete"),params:L.extend({ref:o.union([aa,sa]),argument:o.object({name:o.string(),value:o.string()}).passthrough()})}),ia=q.extend({completion:o.object({values:o.array(o.string()).max(100),total:o.optional(o.number().int()),hasMore:o.optional(o.boolean())}).passthrough()}),oa=o.object({uri:o.string().startsWith("file://"),name:o.optional(o.string())}).passthrough(),ca=A.extend({method:o.literal("roots/list")}),Ot=q.extend({roots:o.array(oa)}),la=F.extend({method:o.literal("notifications/roots/list_changed")}),ti=o.union([Je,Et,ot,Xs,tt,et,Ge,Xe,Qe,Ls,qs,it,at]),ri=o.union([Fe,We,Pt,la]),ni=o.union([Be,Ct,Ot]),si=o.union([Je,na,ca]),ai=o.union([Fe,We,Qs,Vs,Zs,Gs,Js]),ii=o.union([Be,Ns,ia,Fs,Us,Ds,Ms,$s,br,Ks]),T=class extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name="McpError"}};var ua=6e4,ct=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this.setNotificationHandler(Fe,t=>{let n=this._requestHandlerAbortControllers.get(t.params.requestId);n?.abort(t.params.reason)}),this.setNotificationHandler(We,t=>{this._onprogress(t)}),this.setRequestHandler(Je,t=>({}))}_setupTimeout(e,t,n,s,a=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:a,onTimeout:s})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new T(S.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=t=>{this._onerror(t)},this._transport.onmessage=(t,n)=>{Rt(t)||mr(t)?this._onresponse(t):cr(t)?this._onrequest(t,n):ur(t)?this._onnotification(t):this._onerror(new Error(`Unknown message type: ${JSON.stringify(t)}`))},await this._transport.start()}_onclose(){var e;let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);let n=new T(S.ConnectionClosed,"Connection closed");for(let s of t.values())s(n)}_onerror(e){var t;(t=this.onerror)===null||t===void 0||t.call(this,e)}_onnotification(e){var t;let n=(t=this._notificationHandlers.get(e.method))!==null&&t!==void 0?t:this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,t){var n,s,a,i;let c=(n=this._requestHandlers.get(e.method))!==null&&n!==void 0?n:this.fallbackRequestHandler;if(c===void 0){(s=this._transport)===null||s===void 0||s.send({jsonrpc:"2.0",id:e.id,error:{code:S.MethodNotFound,message:"Method not found"}}).catch(m=>this._onerror(new Error(`Failed to send an error response: ${m}`)));return}let l=new AbortController;this._requestHandlerAbortControllers.set(e.id,l);let u={signal:l.signal,sessionId:(a=this._transport)===null||a===void 0?void 0:a.sessionId,_meta:(i=e.params)===null||i===void 0?void 0:i._meta,sendNotification:m=>this.notification(m,{relatedRequestId:e.id}),sendRequest:(m,w,D)=>this.request(m,w,{...D,relatedRequestId:e.id}),authInfo:t?.authInfo,requestId:e.id};Promise.resolve().then(()=>c(e,u)).then(m=>{var w;if(!l.signal.aborted)return(w=this._transport)===null||w===void 0?void 0:w.send({result:m,jsonrpc:"2.0",id:e.id})},m=>{var w,D;if(!l.signal.aborted)return(w=this._transport)===null||w===void 0?void 0:w.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(m.code)?m.code:S.InternalError,message:(D=m.message)!==null&&D!==void 0?D:"Internal error"}})}).catch(m=>this._onerror(new Error(`Failed to send response: ${m}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,s=Number(t),a=this._progressHandlers.get(s);if(!a){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(s),c=this._timeoutInfo.get(s);if(c&&i&&c.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(l){i(l);return}a(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(t),this._progressHandlers.delete(t),this._cleanupTimeout(t),Rt(e))n(e);else{let s=new T(e.error.code,e.error.message,e.error.data);n(s)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,t,n){let{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}=n??{};return new Promise((c,l)=>{var u,m,w,D,te;if(!this._transport){l(new Error("Not connected"));return}((u=this._options)===null||u===void 0?void 0:u.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(m=n?.signal)===null||m===void 0||m.throwIfAborted();let z=this._requestMessageId++,Ht={...e,jsonrpc:"2.0",id:z};n?.onprogress&&(this._progressHandlers.set(z,n.onprogress),Ht.params={...e.params,_meta:{progressToken:z}});let zt=M=>{var re;this._responseHandlers.delete(z),this._progressHandlers.delete(z),this._cleanupTimeout(z),(re=this._transport)===null||re===void 0||re.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:z,reason:String(M)}},{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}).catch(Ee=>this._onerror(new Error(`Failed to send cancellation: ${Ee}`))),l(M)};this._responseHandlers.set(z,M=>{var re;if(!(!((re=n?.signal)===null||re===void 0)&&re.aborted)){if(M instanceof Error)return l(M);try{let Ee=t.parse(M.result);c(Ee)}catch(Ee){l(Ee)}}}),(w=n?.signal)===null||w===void 0||w.addEventListener("abort",()=>{var M;zt((M=n?.signal)===null||M===void 0?void 0:M.reason)});let Ut=(D=n?.timeout)!==null&&D!==void 0?D:ua,_n=()=>zt(new T(S.RequestTimeout,"Request timed out",{timeout:Ut}));this._setupTimeout(z,Ut,n?.maxTotalTimeout,_n,(te=n?.resetTimeoutOnProgress)!==null&&te!==void 0?te:!1),this._transport.send(Ht,{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}).catch(M=>{this._cleanupTimeout(z),l(M)})})}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n={...e,jsonrpc:"2.0"};await this._transport.send(n,t)}setRequestHandler(e,t){let n=e.shape.method.value;this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,a)=>Promise.resolve(t(e.parse(s),a)))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){this._notificationHandlers.set(e.shape.method.value,n=>Promise.resolve(t(e.parse(n))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function kr(r,e){return Object.entries(e).reduce((t,[n,s])=>(s&&typeof s=="object"?t[n]=t[n]?{...t[n],...s}:s:t[n]=s,t),{...r})}var lt=class extends ct{constructor(e,t){var n;super(t),this._serverInfo=e,this._capabilities=(n=t?.capabilities)!==null&&n!==void 0?n:{},this._instructions=t?.instructions,this.setRequestHandler(Et,s=>this._oninitialize(s)),this.setNotificationHandler(Pt,()=>{var s;return(s=this.oninitialized)===null||s===void 0?void 0:s.call(this)})}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=kr(this._capabilities,e)}assertCapabilityForMethod(e){var t,n;switch(e){case"sampling/createMessage":if(!(!((t=this._clientCapabilities)===null||t===void 0)&&t.sampling))throw new Error(`Client does not support sampling (required for ${e})`);break;case"roots/list":if(!(!((n=this._clientCapabilities)===null||n===void 0)&&n.roots))throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Server does not support sampling (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"ping":case"initialize":break}}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:sr.includes(t)?t:Tt,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Be)}async createMessage(e,t){return this.request({method:"sampling/createMessage",params:e},Ct,t)}async listRoots(e,t){return this.request({method:"roots/list",params:e},Ot,t)}async sendLoggingMessage(e){return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var Sr=Symbol("Let zodToJsonSchema decide on which parser to use");var wr={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Tr=r=>typeof r=="string"?{...wr,name:r}:{...wr,...r};var Rr=r=>{let e=Tr(r),t=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:t,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function Nt(r,e,t,n){n?.errorMessages&&t&&(r.errorMessage={...r.errorMessage,[e]:t})}function x(r,e,t,n,s){r[e]=t,Nt(r,e,n,s)}function Er(){return{}}function Pr(r,e){let t={type:"array"};return r.type?._def&&r.type?._def?.typeName!==d.ZodAny&&(t.items=y(r.type._def,{...e,currentPath:[...e.currentPath,"items"]})),r.minLength&&x(t,"minItems",r.minLength.value,r.minLength.message,e),r.maxLength&&x(t,"maxItems",r.maxLength.value,r.maxLength.message,e),r.exactLength&&(x(t,"minItems",r.exactLength.value,r.exactLength.message,e),x(t,"maxItems",r.exactLength.value,r.exactLength.message,e)),t}function Cr(r,e){let t={type:"integer",format:"int64"};if(!r.checks)return t;for(let n of r.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?x(t,"minimum",n.value,n.message,e):x(t,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(t.exclusiveMinimum=!0),x(t,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?x(t,"maximum",n.value,n.message,e):x(t,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(t.exclusiveMaximum=!0),x(t,"maximum",n.value,n.message,e));break;case"multipleOf":x(t,"multipleOf",n.value,n.message,e);break}return t}function Or(){return{type:"boolean"}}function ut(r,e){return y(r.type._def,e)}var Nr=(r,e)=>y(r.innerType._def,e);function jt(r,e,t){let n=t??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,a)=>jt(r,e,s))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return da(r,e)}}var da=(r,e)=>{let t={type:"integer",format:"unix-time"};if(e.target==="openApi3")return t;for(let n of r.checks)switch(n.kind){case"min":x(t,"minimum",n.value,n.message,e);break;case"max":x(t,"maximum",n.value,n.message,e);break}return t};function jr(r,e){return{...y(r.innerType._def,e),default:r.defaultValue()}}function Ir(r,e){return e.effectStrategy==="input"?y(r.schema._def,e):{}}function Ar(r){return{type:"string",enum:Array.from(r.values)}}var pa=r=>"type"in r&&r.type==="string"?!1:"allOf"in r;function Dr(r,e){let t=[y(r.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),y(r.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(a=>!!a),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return t.forEach(a=>{if(pa(a))s.push(...a.allOf),a.unevaluatedProperties===void 0&&(n=void 0);else{let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){let{additionalProperties:c,...l}=a;i=l}else n=void 0;s.push(i)}}),s.length?{allOf:s,...n}:void 0}function Mr(r,e){let t=typeof r.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(r.value)?"array":"object"}:e.target==="openApi3"?{type:t==="bigint"?"integer":t,enum:[r.value]}:{type:t==="bigint"?"integer":t,const:r.value}}var It,V={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(It===void 0&&(It=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),It),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function dt(r,e){let t={type:"string"};if(r.checks)for(let n of r.checks)switch(n.kind){case"min":x(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,n.value):n.value,n.message,e);break;case"max":x(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":H(t,"email",n.message,e);break;case"format:idn-email":H(t,"idn-email",n.message,e);break;case"pattern:zod":C(t,V.email,n.message,e);break}break;case"url":H(t,"uri",n.message,e);break;case"uuid":H(t,"uuid",n.message,e);break;case"regex":C(t,n.regex,n.message,e);break;case"cuid":C(t,V.cuid,n.message,e);break;case"cuid2":C(t,V.cuid2,n.message,e);break;case"startsWith":C(t,RegExp(`^${At(n.value,e)}`),n.message,e);break;case"endsWith":C(t,RegExp(`${At(n.value,e)}$`),n.message,e);break;case"datetime":H(t,"date-time",n.message,e);break;case"date":H(t,"date",n.message,e);break;case"time":H(t,"time",n.message,e);break;case"duration":H(t,"duration",n.message,e);break;case"length":x(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,n.value):n.value,n.message,e),x(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,n.value):n.value,n.message,e);break;case"includes":{C(t,RegExp(At(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&H(t,"ipv4",n.message,e),n.version!=="v4"&&H(t,"ipv6",n.message,e);break}case"base64url":C(t,V.base64url,n.message,e);break;case"jwt":C(t,V.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&C(t,V.ipv4Cidr,n.message,e),n.version!=="v4"&&C(t,V.ipv6Cidr,n.message,e);break}case"emoji":C(t,V.emoji(),n.message,e);break;case"ulid":{C(t,V.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{H(t,"binary",n.message,e);break}case"contentEncoding:base64":{x(t,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{C(t,V.base64,n.message,e);break}}break}case"nanoid":C(t,V.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return t}function At(r,e){return e.patternStrategy==="escape"?fa(r):r}var ma=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function fa(r){let e="";for(let t=0;t<r.length;t++)ma.has(r[t])||(e+="\\"),e+=r[t];return e}function H(r,e,t,n){r.format||r.anyOf?.some(s=>s.format)?(r.anyOf||(r.anyOf=[]),r.format&&(r.anyOf.push({format:r.format,...r.errorMessage&&n.errorMessages&&{errorMessage:{format:r.errorMessage.format}}}),delete r.format,r.errorMessage&&(delete r.errorMessage.format,Object.keys(r.errorMessage).length===0&&delete r.errorMessage)),r.anyOf.push({format:e,...t&&n.errorMessages&&{errorMessage:{format:t}}})):x(r,"format",e,t,n)}function C(r,e,t,n){r.pattern||r.allOf?.some(s=>s.pattern)?(r.allOf||(r.allOf=[]),r.pattern&&(r.allOf.push({pattern:r.pattern,...r.errorMessage&&n.errorMessages&&{errorMessage:{pattern:r.errorMessage.pattern}}}),delete r.pattern,r.errorMessage&&(delete r.errorMessage.pattern,Object.keys(r.errorMessage).length===0&&delete r.errorMessage)),r.allOf.push({pattern:$r(e,n),...t&&n.errorMessages&&{errorMessage:{pattern:t}}})):x(r,"pattern",$r(e,n),t,n)}function $r(r,e){if(!e.applyRegexFlags||!r.flags)return r.source;let t={i:r.flags.includes("i"),m:r.flags.includes("m"),s:r.flags.includes("s")},n=t.i?r.source.toLowerCase():r.source,s="",a=!1,i=!1,c=!1;for(let l=0;l<n.length;l++){if(a){s+=n[l],a=!1;continue}if(t.i){if(i){if(n[l].match(/[a-z]/)){c?(s+=n[l],s+=`${n[l-2]}-${n[l]}`.toUpperCase(),c=!1):n[l+1]==="-"&&n[l+2]?.match(/[a-z]/)?(s+=n[l],c=!0):s+=`${n[l]}${n[l].toUpperCase()}`;continue}}else if(n[l].match(/[a-z]/)){s+=`[${n[l]}${n[l].toUpperCase()}]`;continue}}if(t.m){if(n[l]==="^"){s+=`(^|(?<=[\r
5
5
  ]))`;continue}else if(n[l]==="$"){s+=`($|(?=[\r
6
6
  ]))`;continue}}if(t.s&&n[l]==="."){s+=i?`${n[l]}\r
7
7
  `:`[${n[l]}\r
8
- ]`;continue}s+=n[l],n[l]==="\\"?a=!0:i&&n[l]==="]"?i=!1:!i&&n[l]==="["&&(i=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),r.source}return s}function pt(r,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&r.keyType?._def.typeName===d.ZodEnum)return{type:"object",required:r.keyType._def.values,properties:r.keyType._def.values.reduce((n,s)=>({...n,[s]:y(r.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??{}}),{}),additionalProperties:e.rejectedAdditionalProperties};let t={type:"object",additionalProperties:y(r.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return t;if(r.keyType?._def.typeName===d.ZodString&&r.keyType._def.checks?.length){let{type:n,...s}=dt(r.keyType._def,e);return{...t,propertyNames:s}}else{if(r.keyType?._def.typeName===d.ZodEnum)return{...t,propertyNames:{enum:r.keyType._def.values}};if(r.keyType?._def.typeName===d.ZodBranded&&r.keyType._def.type._def.typeName===d.ZodString&&r.keyType._def.type._def.checks?.length){let{type:n,...s}=ut(r.keyType._def,e);return{...t,propertyNames:s}}}return t}function Zr(r,e){if(e.mapStrategy==="record")return pt(r,e);let t=y(r.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||{},n=y(r.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[t,n],minItems:2,maxItems:2}}}function Lr(r){let e=r.values,n=Object.keys(r.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),s=Array.from(new Set(n.map(a=>typeof a)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}function qr(){return{not:{}}}function Vr(r){return r.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var De={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function zr(r,e){if(e.target==="openApi3")return Hr(r,e);let t=r.options instanceof Map?Array.from(r.options.values()):r.options;if(t.every(n=>n._def.typeName in De&&(!n._def.checks||!n._def.checks.length))){let n=t.reduce((s,a)=>{let i=De[a._def.typeName];return i&&!s.includes(i)?[...s,i]:s},[]);return{type:n.length>1?n:n[0]}}else if(t.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=t.reduce((s,a)=>{let i=typeof a._def.value;switch(i){case"string":case"number":case"boolean":return[...s,i];case"bigint":return[...s,"integer"];case"object":if(a._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===t.length){let s=n.filter((a,i,c)=>c.indexOf(a)===i);return{type:s.length>1?s:s[0],enum:t.reduce((a,i)=>a.includes(i._def.value)?a:[...a,i._def.value],[])}}}else if(t.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:t.reduce((n,s)=>[...n,...s._def.values.filter(a=>!n.includes(a))],[])};return Hr(r,e)}var Hr=(r,e)=>{let t=(r.options instanceof Map?Array.from(r.options.values()):r.options).map((n,s)=>y(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return t.length?{anyOf:t}:void 0};function Ur(r,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(r.innerType._def.typeName)&&(!r.innerType._def.checks||!r.innerType._def.checks.length))return e.target==="openApi3"?{type:De[r.innerType._def.typeName],nullable:!0}:{type:[De[r.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=y(r.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let t=y(r.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return t&&{anyOf:[t,{type:"null"}]}}function Br(r,e){let t={type:"number"};if(!r.checks)return t;for(let n of r.checks)switch(n.kind){case"int":t.type="integer",Ot(t,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?x(t,"minimum",n.value,n.message,e):x(t,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(t.exclusiveMinimum=!0),x(t,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?x(t,"maximum",n.value,n.message,e):x(t,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(t.exclusiveMaximum=!0),x(t,"maximum",n.value,n.message,e));break;case"multipleOf":x(t,"multipleOf",n.value,n.message,e);break}return t}function Fr(r,e){let t=e.target==="openAi",n={type:"object",properties:{}},s=[],a=r.shape();for(let c in a){let l=a[c];if(l===void 0||l._def===void 0)continue;let u=ha(l);u&&t&&(l instanceof N&&(l=l._def.innerType),l.isNullable()||(l=l.nullable()),u=!1);let m=y(l._def,{...e,currentPath:[...e.currentPath,"properties",c],propertyPath:[...e.currentPath,"properties",c]});m!==void 0&&(n.properties[c]=m,u||s.push(c))}s.length&&(n.required=s);let i=fa(r,e);return i!==void 0&&(n.additionalProperties=i),n}function fa(r,e){if(r.catchall._def.typeName!=="ZodNever")return y(r.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(r.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function ha(r){try{return r.isOptional()}catch{return!0}}var Jr=(r,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return y(r.innerType._def,e);let t=y(r.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return t?{anyOf:[{not:{}},t]}:{}};var Wr=(r,e)=>{if(e.pipeStrategy==="input")return y(r.in._def,e);if(e.pipeStrategy==="output")return y(r.out._def,e);let t=y(r.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=y(r.out._def,{...e,currentPath:[...e.currentPath,"allOf",t?"1":"0"]});return{allOf:[t,n].filter(s=>s!==void 0)}};function Yr(r,e){return y(r.type._def,e)}function Kr(r,e){let n={type:"array",uniqueItems:!0,items:y(r.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return r.minSize&&x(n,"minItems",r.minSize.value,r.minSize.message,e),r.maxSize&&x(n,"maxItems",r.maxSize.value,r.maxSize.message,e),n}function Gr(r,e){return r.rest?{type:"array",minItems:r.items.length,items:r.items.map((t,n)=>y(t._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((t,n)=>n===void 0?t:[...t,n],[]),additionalItems:y(r.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:r.items.length,maxItems:r.items.length,items:r.items.map((t,n)=>y(t._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((t,n)=>n===void 0?t:[...t,n],[])}}function Xr(){return{not:{}}}function Qr(){return{}}var en=(r,e)=>y(r.innerType._def,e);var tn=(r,e,t)=>{switch(e){case d.ZodString:return dt(r,t);case d.ZodNumber:return Br(r,t);case d.ZodObject:return Fr(r,t);case d.ZodBigInt:return Cr(r,t);case d.ZodBoolean:return Nr();case d.ZodDate:return jt(r,t);case d.ZodUndefined:return Xr();case d.ZodNull:return Vr(t);case d.ZodArray:return Pr(r,t);case d.ZodUnion:case d.ZodDiscriminatedUnion:return zr(r,t);case d.ZodIntersection:return Dr(r,t);case d.ZodTuple:return Gr(r,t);case d.ZodRecord:return pt(r,t);case d.ZodLiteral:return Mr(r,t);case d.ZodEnum:return Ar(r);case d.ZodNativeEnum:return Lr(r);case d.ZodNullable:return Ur(r,t);case d.ZodOptional:return Jr(r,t);case d.ZodMap:return Zr(r,t);case d.ZodSet:return Kr(r,t);case d.ZodLazy:return()=>r.getter()._def;case d.ZodPromise:return Yr(r,t);case d.ZodNaN:case d.ZodNever:return qr();case d.ZodEffects:return Ir(r,t);case d.ZodAny:return Er();case d.ZodUnknown:return Qr();case d.ZodDefault:return jr(r,t);case d.ZodBranded:return ut(r,t);case d.ZodReadonly:return en(r,t);case d.ZodCatch:return Or(r,t);case d.ZodPipeline:return Wr(r,t);case d.ZodFunction:case d.ZodVoid:case d.ZodSymbol:return;default:return(n=>{})(e)}};function y(r,e,t=!1){let n=e.seen.get(r);if(e.override){let c=e.override?.(r,e,n,t);if(c!==Sr)return c}if(n&&!t){let c=ga(n,e);if(c!==void 0)return c}let s={def:r,path:e.currentPath,jsonSchema:void 0};e.seen.set(r,s);let a=tn(r,r.typeName,e),i=typeof a=="function"?y(a(),e):a;if(i&&va(r,e,i),e.postProcess){let c=e.postProcess(i,r,e);return s.jsonSchema=i,c}return s.jsonSchema=i,i}var ga=(r,e)=>{switch(e.$refStrategy){case"root":return{$ref:r.path.join("/")};case"relative":return{$ref:ya(e.currentPath,r.path)};case"none":case"seen":return r.path.length<e.currentPath.length&&r.path.every((t,n)=>e.currentPath[n]===t)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},ya=(r,e)=>{let t=0;for(;t<r.length&&t<e.length&&r[t]===e[t];t++);return[(r.length-t).toString(),...e.slice(t)].join("/")},va=(r,e,t)=>(r.description&&(t.description=r.description,e.markdownDescription&&(t.markdownDescription=r.description)),t);var Dt=(r,e)=>{let t=Rr(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[u,m])=>({...l,[u]:y(m._def,{...t,currentPath:[...t.basePath,t.definitionPath,u]},!0)??{}}),{}):void 0,s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,a=y(r._def,s===void 0?t:{...t,currentPath:[...t.basePath,t.definitionPath,s]},!1)??{},i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(a.title=i);let c=s===void 0?n?{...a,[t.definitionPath]:n}:a:{$ref:[...t.$refStrategy==="relative"?[]:t.basePath,t.definitionPath,s].join("/"),[t.definitionPath]:{...n,[s]:a}};return t.target==="jsonSchema7"?c.$schema="http://json-schema.org/draft-07/schema#":(t.target==="jsonSchema2019-09"||t.target==="openAi")&&(c.$schema="https://json-schema.org/draft/2019-09/schema#"),t.target==="openAi"&&("anyOf"in c||"oneOf"in c||"allOf"in c||"type"in c&&Array.isArray(c.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),c};var Mt;(function(r){r.Completable="McpCompletable"})(Mt||(Mt={}));var Re=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}};Re.create=(r,e)=>new Re({type:r,typeName:Mt.Completable,complete:e.complete,..._a(e)});function _a(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,c)=>{var l,u;let{message:m}=r;return i.code==="invalid_enum_value"?{message:m??c.defaultError}:typeof c.data>"u"?{message:(l=m??n)!==null&&l!==void 0?l:c.defaultError}:i.code!=="invalid_type"?{message:c.defaultError}:{message:(u=m??t)!==null&&u!==void 0?u:c.defaultError}},description:s}}var ft=class{constructor(e,t){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new lt(e,t)}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(at.shape.method.value),this.server.assertCanSetRequestHandler(it.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(at,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,description:t.description,inputSchema:t.inputSchema?Dt(t.inputSchema,{strictUnions:!0}):ba,annotations:t.annotations}))})),this.server.setRequestHandler(it,async(e,t)=>{let n=this._registeredTools[e.params.name];if(!n)throw new T(S.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new T(S.InvalidParams,`Tool ${e.params.name} disabled`);if(n.inputSchema){let s=await n.inputSchema.safeParseAsync(e.params.arguments);if(!s.success)throw new T(S.InvalidParams,`Invalid arguments for tool ${e.params.name}: ${s.error.message}`);let a=s.data,i=n.callback;try{return await Promise.resolve(i(a,t))}catch(c){return{content:[{type:"text",text:c instanceof Error?c.message:String(c)}],isError:!0}}}else{let s=n.callback;try{return await Promise.resolve(s(t))}catch(a){return{content:[{type:"text",text:a instanceof Error?a.message:String(a)}],isError:!0}}}}),this._toolHandlersInitialized=!0)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(ot.shape.method.value),this.server.setRequestHandler(ot,async e=>{switch(e.params.ref.type){case"ref/prompt":return this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return this.handleResourceCompletion(e,e.params.ref);default:throw new T(S.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){let n=this._registeredPrompts[t.name];if(!n)throw new T(S.InvalidParams,`Prompt ${t.name} not found`);if(!n.enabled)throw new T(S.InvalidParams,`Prompt ${t.name} disabled`);if(!n.argsSchema)return mt;let s=n.argsSchema.shape[e.params.argument.name];if(!(s instanceof Re))return mt;let i=await s._def.complete(e.params.argument.value);return rn(i)}async handleResourceCompletion(e,t){let n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===t.uri);if(!n){if(this._registeredResources[t.uri])return mt;throw new T(S.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return mt;let a=await s(e.params.argument.value);return rn(a)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Ge.shape.method.value),this.server.assertCanSetRequestHandler(Xe.shape.method.value),this.server.assertCanSetRequestHandler(Qe.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Ge,async(e,t)=>{let n=Object.entries(this._registeredResources).filter(([a,i])=>i.enabled).map(([a,i])=>({uri:a,name:i.name,...i.metadata})),s=[];for(let a of Object.values(this._registeredResourceTemplates)){if(!a.resourceTemplate.listCallback)continue;let i=await a.resourceTemplate.listCallback(t);for(let c of i.resources)s.push({...c,...a.metadata})}return{resources:[...n,...s]}}),this.server.setRequestHandler(Xe,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([t,n])=>({name:t,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Qe,async(e,t)=>{let n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new T(S.InvalidParams,`Resource ${n} disabled`);return s.readCallback(n,t)}for(let a of Object.values(this._registeredResourceTemplates)){let i=a.resourceTemplate.uriTemplate.match(n.toString());if(i)return a.readCallback(n,i,t)}throw new T(S.InvalidParams,`Resource ${n} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(et.shape.method.value),this.server.assertCanSetRequestHandler(tt.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(et,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,description:t.description,arguments:t.argsSchema?xa(t.argsSchema):void 0}))})),this.server.setRequestHandler(tt,async(e,t)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new T(S.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new T(S.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let s=await n.argsSchema.safeParseAsync(e.params.arguments);if(!s.success)throw new T(S.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${s.error.message}`);let a=s.data,i=n.callback;return await Promise.resolve(i(a,t))}else{let s=n.callback;return await Promise.resolve(s(t))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0)}resource(e,t,...n){let s;typeof n[0]=="object"&&(s=n.shift());let a=n[0];if(typeof t=="string"){if(this._registeredResources[t])throw new Error(`Resource ${t} is already registered`);let i={name:e,metadata:s,readCallback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:c=>{typeof c.uri<"u"&&c.uri!==t&&(delete this._registeredResources[t],c.uri&&(this._registeredResources[c.uri]=i)),typeof c.name<"u"&&(i.name=c.name),typeof c.metadata<"u"&&(i.metadata=c.metadata),typeof c.callback<"u"&&(i.readCallback=c.callback),typeof c.enabled<"u"&&(i.enabled=c.enabled),this.sendResourceListChanged()}};return this._registeredResources[t]=i,this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i={resourceTemplate:t,metadata:s,readCallback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==e&&(delete this._registeredResourceTemplates[e],c.name&&(this._registeredResourceTemplates[c.name]=i)),typeof c.template<"u"&&(i.resourceTemplate=c.template),typeof c.metadata<"u"&&(i.metadata=c.metadata),typeof c.callback<"u"&&(i.readCallback=c.callback),typeof c.enabled<"u"&&(i.enabled=c.enabled),this.sendResourceListChanged()}};return this._registeredResourceTemplates[e]=i,this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}tool(e,...t){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n=u=>typeof u!="object"||u===null?!1:Object.values(u).some(m=>m instanceof _),s;typeof t[0]=="string"&&(s=t.shift());let a,i;if(t.length>1){let u=t[0];n(u)?(a=t.shift(),t.length>1&&typeof t[0]=="object"&&t[0]!==null&&!n(t[0])&&(i=t.shift())):typeof u=="object"&&u!==null&&(i=t.shift())}let c=t[0],l={description:s,inputSchema:a===void 0?void 0:o.object(a),annotations:i,callback:c,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredTools[e],u.name&&(this._registeredTools[u.name]=l)),typeof u.description<"u"&&(l.description=u.description),typeof u.paramsSchema<"u"&&(l.inputSchema=o.object(u.paramsSchema)),typeof u.callback<"u"&&(l.callback=u.callback),typeof u.annotations<"u"&&(l.annotations=u.annotations),typeof u.enabled<"u"&&(l.enabled=u.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}prompt(e,...t){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof t[0]=="string"&&(n=t.shift());let s;t.length>1&&(s=t.shift());let a=t[0],i={description:n,argsSchema:s===void 0?void 0:o.object(s),callback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==e&&(delete this._registeredPrompts[e],c.name&&(this._registeredPrompts[c.name]=i)),typeof c.description<"u"&&(i.description=c.description),typeof c.argsSchema<"u"&&(i.argsSchema=o.object(c.argsSchema)),typeof c.callback<"u"&&(i.callback=c.callback),typeof c.enabled<"u"&&(i.enabled=c.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}isConnected(){return this.server.transport!==void 0}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var ba={type:"object"};function xa(r){return Object.entries(r.shape).map(([e,t])=>({name:e,description:t.description,required:!t.isOptional()}))}function rn(r){return{completion:{values:r.slice(0,100),total:r.length,hasMore:r.length>100}}}var mt={completion:{values:[],hasMore:!1}};var $t=_t(require("node:process"),1);var ht=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
9
- `);if(e===-1)return null;let t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),ka(t)}clear(){this._buffer=void 0}};function ka(r){return fr.parse(JSON.parse(r))}function nn(r){return JSON.stringify(r)+`
10
- `}var gt=class{constructor(e=$t.default.stdin,t=$t.default.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new ht,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{var s;(s=this.onerror)===null||s===void 0||s.call(this,n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(var e,t;;)try{let n=this._readBuffer.readMessage();if(n===null)break;(e=this.onmessage)===null||e===void 0||e.call(this,n)}catch(n){(t=this.onerror)===null||t===void 0||t.call(this,n)}}async close(){var e;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),(e=this.onclose)===null||e===void 0||e.call(this)}send(e){return new Promise(t=>{let n=nn(e);this._stdout.write(n)?t():this._stdout.once("drain",t)})}};var gn=_t(ln());var mn=_t(pn()),Ja=new mn.default,Wa=o.object({query:o.string().describe("User request to add, create, build, generate, implement, or develop new features, components, pages, modules, dashboards, or functionality. Trigger words include: 'add', 'create', 'build', 'generate', 'implement', 'develop', 'make', 'setup'. Examples: 'add login page', 'create auth flow', 'build sales dashboard', 'implement user CRUD', 'generate reports module', 'setup payment system'. Use this for new development requests, not for questions or modifications to existing code."),selectedBlockCode:o.string().describe("The Code of the selected block.").optional(),blockInput:o.string().describe("JSON string containing the input data for the block when required by the block's schema.").optional()}),fn=r=>{r.tool("add_block","REQUIRED: Use this tool when users request to add, create, build, or implement new features, components, pages, modules, or functionality in their project. This searches Derived's template library for matching blocks based on semantic similarity to the user's request. Trigger for requests like: 'add login page', 'create auth flow', 'build dashboard', 'implement user CRUD', 'generate reports module'. The tool finds matching blocks, handles user selection for multiple options, and collects required input data.",Wa.shape,async({query:e,selectedBlockCode:t,blockInput:n})=>{console.error("add_block",e,t,n);try{if(t){let i=`npx derived-cli add ${t}`;if(n){let c=Buffer.from(JSON.stringify(n)).toString("base64");i+=` -i ${c}`}return{content:[{type:"text",text:`Run cli command ${i},
8
+ ]`;continue}s+=n[l],n[l]==="\\"?a=!0:i&&n[l]==="]"?i=!1:!i&&n[l]==="["&&(i=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),r.source}return s}function pt(r,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&r.keyType?._def.typeName===d.ZodEnum)return{type:"object",required:r.keyType._def.values,properties:r.keyType._def.values.reduce((n,s)=>({...n,[s]:y(r.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??{}}),{}),additionalProperties:e.rejectedAdditionalProperties};let t={type:"object",additionalProperties:y(r.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return t;if(r.keyType?._def.typeName===d.ZodString&&r.keyType._def.checks?.length){let{type:n,...s}=dt(r.keyType._def,e);return{...t,propertyNames:s}}else{if(r.keyType?._def.typeName===d.ZodEnum)return{...t,propertyNames:{enum:r.keyType._def.values}};if(r.keyType?._def.typeName===d.ZodBranded&&r.keyType._def.type._def.typeName===d.ZodString&&r.keyType._def.type._def.checks?.length){let{type:n,...s}=ut(r.keyType._def,e);return{...t,propertyNames:s}}}return t}function Zr(r,e){if(e.mapStrategy==="record")return pt(r,e);let t=y(r.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||{},n=y(r.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[t,n],minItems:2,maxItems:2}}}function Lr(r){let e=r.values,n=Object.keys(r.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),s=Array.from(new Set(n.map(a=>typeof a)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}function qr(){return{not:{}}}function Vr(r){return r.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var De={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function zr(r,e){if(e.target==="openApi3")return Hr(r,e);let t=r.options instanceof Map?Array.from(r.options.values()):r.options;if(t.every(n=>n._def.typeName in De&&(!n._def.checks||!n._def.checks.length))){let n=t.reduce((s,a)=>{let i=De[a._def.typeName];return i&&!s.includes(i)?[...s,i]:s},[]);return{type:n.length>1?n:n[0]}}else if(t.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=t.reduce((s,a)=>{let i=typeof a._def.value;switch(i){case"string":case"number":case"boolean":return[...s,i];case"bigint":return[...s,"integer"];case"object":if(a._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===t.length){let s=n.filter((a,i,c)=>c.indexOf(a)===i);return{type:s.length>1?s:s[0],enum:t.reduce((a,i)=>a.includes(i._def.value)?a:[...a,i._def.value],[])}}}else if(t.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:t.reduce((n,s)=>[...n,...s._def.values.filter(a=>!n.includes(a))],[])};return Hr(r,e)}var Hr=(r,e)=>{let t=(r.options instanceof Map?Array.from(r.options.values()):r.options).map((n,s)=>y(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return t.length?{anyOf:t}:void 0};function Ur(r,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(r.innerType._def.typeName)&&(!r.innerType._def.checks||!r.innerType._def.checks.length))return e.target==="openApi3"?{type:De[r.innerType._def.typeName],nullable:!0}:{type:[De[r.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=y(r.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let t=y(r.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return t&&{anyOf:[t,{type:"null"}]}}function Br(r,e){let t={type:"number"};if(!r.checks)return t;for(let n of r.checks)switch(n.kind){case"int":t.type="integer",Nt(t,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?x(t,"minimum",n.value,n.message,e):x(t,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(t.exclusiveMinimum=!0),x(t,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?x(t,"maximum",n.value,n.message,e):x(t,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(t.exclusiveMaximum=!0),x(t,"maximum",n.value,n.message,e));break;case"multipleOf":x(t,"multipleOf",n.value,n.message,e);break}return t}function Fr(r,e){let t=e.target==="openAi",n={type:"object",properties:{}},s=[],a=r.shape();for(let c in a){let l=a[c];if(l===void 0||l._def===void 0)continue;let u=ga(l);u&&t&&(l instanceof O&&(l=l._def.innerType),l.isNullable()||(l=l.nullable()),u=!1);let m=y(l._def,{...e,currentPath:[...e.currentPath,"properties",c],propertyPath:[...e.currentPath,"properties",c]});m!==void 0&&(n.properties[c]=m,u||s.push(c))}s.length&&(n.required=s);let i=ha(r,e);return i!==void 0&&(n.additionalProperties=i),n}function ha(r,e){if(r.catchall._def.typeName!=="ZodNever")return y(r.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(r.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function ga(r){try{return r.isOptional()}catch{return!0}}var Jr=(r,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return y(r.innerType._def,e);let t=y(r.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return t?{anyOf:[{not:{}},t]}:{}};var Wr=(r,e)=>{if(e.pipeStrategy==="input")return y(r.in._def,e);if(e.pipeStrategy==="output")return y(r.out._def,e);let t=y(r.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=y(r.out._def,{...e,currentPath:[...e.currentPath,"allOf",t?"1":"0"]});return{allOf:[t,n].filter(s=>s!==void 0)}};function Yr(r,e){return y(r.type._def,e)}function Kr(r,e){let n={type:"array",uniqueItems:!0,items:y(r.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return r.minSize&&x(n,"minItems",r.minSize.value,r.minSize.message,e),r.maxSize&&x(n,"maxItems",r.maxSize.value,r.maxSize.message,e),n}function Gr(r,e){return r.rest?{type:"array",minItems:r.items.length,items:r.items.map((t,n)=>y(t._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((t,n)=>n===void 0?t:[...t,n],[]),additionalItems:y(r.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:r.items.length,maxItems:r.items.length,items:r.items.map((t,n)=>y(t._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((t,n)=>n===void 0?t:[...t,n],[])}}function Xr(){return{not:{}}}function Qr(){return{}}var en=(r,e)=>y(r.innerType._def,e);var tn=(r,e,t)=>{switch(e){case d.ZodString:return dt(r,t);case d.ZodNumber:return Br(r,t);case d.ZodObject:return Fr(r,t);case d.ZodBigInt:return Cr(r,t);case d.ZodBoolean:return Or();case d.ZodDate:return jt(r,t);case d.ZodUndefined:return Xr();case d.ZodNull:return Vr(t);case d.ZodArray:return Pr(r,t);case d.ZodUnion:case d.ZodDiscriminatedUnion:return zr(r,t);case d.ZodIntersection:return Dr(r,t);case d.ZodTuple:return Gr(r,t);case d.ZodRecord:return pt(r,t);case d.ZodLiteral:return Mr(r,t);case d.ZodEnum:return Ar(r);case d.ZodNativeEnum:return Lr(r);case d.ZodNullable:return Ur(r,t);case d.ZodOptional:return Jr(r,t);case d.ZodMap:return Zr(r,t);case d.ZodSet:return Kr(r,t);case d.ZodLazy:return()=>r.getter()._def;case d.ZodPromise:return Yr(r,t);case d.ZodNaN:case d.ZodNever:return qr();case d.ZodEffects:return Ir(r,t);case d.ZodAny:return Er();case d.ZodUnknown:return Qr();case d.ZodDefault:return jr(r,t);case d.ZodBranded:return ut(r,t);case d.ZodReadonly:return en(r,t);case d.ZodCatch:return Nr(r,t);case d.ZodPipeline:return Wr(r,t);case d.ZodFunction:case d.ZodVoid:case d.ZodSymbol:return;default:return(n=>{})(e)}};function y(r,e,t=!1){let n=e.seen.get(r);if(e.override){let c=e.override?.(r,e,n,t);if(c!==Sr)return c}if(n&&!t){let c=ya(n,e);if(c!==void 0)return c}let s={def:r,path:e.currentPath,jsonSchema:void 0};e.seen.set(r,s);let a=tn(r,r.typeName,e),i=typeof a=="function"?y(a(),e):a;if(i&&_a(r,e,i),e.postProcess){let c=e.postProcess(i,r,e);return s.jsonSchema=i,c}return s.jsonSchema=i,i}var ya=(r,e)=>{switch(e.$refStrategy){case"root":return{$ref:r.path.join("/")};case"relative":return{$ref:va(e.currentPath,r.path)};case"none":case"seen":return r.path.length<e.currentPath.length&&r.path.every((t,n)=>e.currentPath[n]===t)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},va=(r,e)=>{let t=0;for(;t<r.length&&t<e.length&&r[t]===e[t];t++);return[(r.length-t).toString(),...e.slice(t)].join("/")},_a=(r,e,t)=>(r.description&&(t.description=r.description,e.markdownDescription&&(t.markdownDescription=r.description)),t);var Dt=(r,e)=>{let t=Rr(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[u,m])=>({...l,[u]:y(m._def,{...t,currentPath:[...t.basePath,t.definitionPath,u]},!0)??{}}),{}):void 0,s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,a=y(r._def,s===void 0?t:{...t,currentPath:[...t.basePath,t.definitionPath,s]},!1)??{},i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(a.title=i);let c=s===void 0?n?{...a,[t.definitionPath]:n}:a:{$ref:[...t.$refStrategy==="relative"?[]:t.basePath,t.definitionPath,s].join("/"),[t.definitionPath]:{...n,[s]:a}};return t.target==="jsonSchema7"?c.$schema="http://json-schema.org/draft-07/schema#":(t.target==="jsonSchema2019-09"||t.target==="openAi")&&(c.$schema="https://json-schema.org/draft/2019-09/schema#"),t.target==="openAi"&&("anyOf"in c||"oneOf"in c||"allOf"in c||"type"in c&&Array.isArray(c.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),c};var Mt;(function(r){r.Completable="McpCompletable"})(Mt||(Mt={}));var Re=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}};Re.create=(r,e)=>new Re({type:r,typeName:Mt.Completable,complete:e.complete,...ba(e)});function ba(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,c)=>{var l,u;let{message:m}=r;return i.code==="invalid_enum_value"?{message:m??c.defaultError}:typeof c.data>"u"?{message:(l=m??n)!==null&&l!==void 0?l:c.defaultError}:i.code!=="invalid_type"?{message:c.defaultError}:{message:(u=m??t)!==null&&u!==void 0?u:c.defaultError}},description:s}}var ft=class{constructor(e,t){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new lt(e,t)}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(at.shape.method.value),this.server.assertCanSetRequestHandler(it.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(at,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,description:t.description,inputSchema:t.inputSchema?Dt(t.inputSchema,{strictUnions:!0}):xa,annotations:t.annotations}))})),this.server.setRequestHandler(it,async(e,t)=>{let n=this._registeredTools[e.params.name];if(!n)throw new T(S.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new T(S.InvalidParams,`Tool ${e.params.name} disabled`);if(n.inputSchema){let s=await n.inputSchema.safeParseAsync(e.params.arguments);if(!s.success)throw new T(S.InvalidParams,`Invalid arguments for tool ${e.params.name}: ${s.error.message}`);let a=s.data,i=n.callback;try{return await Promise.resolve(i(a,t))}catch(c){return{content:[{type:"text",text:c instanceof Error?c.message:String(c)}],isError:!0}}}else{let s=n.callback;try{return await Promise.resolve(s(t))}catch(a){return{content:[{type:"text",text:a instanceof Error?a.message:String(a)}],isError:!0}}}}),this._toolHandlersInitialized=!0)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(ot.shape.method.value),this.server.setRequestHandler(ot,async e=>{switch(e.params.ref.type){case"ref/prompt":return this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return this.handleResourceCompletion(e,e.params.ref);default:throw new T(S.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){let n=this._registeredPrompts[t.name];if(!n)throw new T(S.InvalidParams,`Prompt ${t.name} not found`);if(!n.enabled)throw new T(S.InvalidParams,`Prompt ${t.name} disabled`);if(!n.argsSchema)return mt;let s=n.argsSchema.shape[e.params.argument.name];if(!(s instanceof Re))return mt;let i=await s._def.complete(e.params.argument.value);return rn(i)}async handleResourceCompletion(e,t){let n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===t.uri);if(!n){if(this._registeredResources[t.uri])return mt;throw new T(S.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return mt;let a=await s(e.params.argument.value);return rn(a)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Ge.shape.method.value),this.server.assertCanSetRequestHandler(Xe.shape.method.value),this.server.assertCanSetRequestHandler(Qe.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Ge,async(e,t)=>{let n=Object.entries(this._registeredResources).filter(([a,i])=>i.enabled).map(([a,i])=>({uri:a,name:i.name,...i.metadata})),s=[];for(let a of Object.values(this._registeredResourceTemplates)){if(!a.resourceTemplate.listCallback)continue;let i=await a.resourceTemplate.listCallback(t);for(let c of i.resources)s.push({...c,...a.metadata})}return{resources:[...n,...s]}}),this.server.setRequestHandler(Xe,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([t,n])=>({name:t,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Qe,async(e,t)=>{let n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new T(S.InvalidParams,`Resource ${n} disabled`);return s.readCallback(n,t)}for(let a of Object.values(this._registeredResourceTemplates)){let i=a.resourceTemplate.uriTemplate.match(n.toString());if(i)return a.readCallback(n,i,t)}throw new T(S.InvalidParams,`Resource ${n} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(et.shape.method.value),this.server.assertCanSetRequestHandler(tt.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(et,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,description:t.description,arguments:t.argsSchema?ka(t.argsSchema):void 0}))})),this.server.setRequestHandler(tt,async(e,t)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new T(S.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new T(S.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let s=await n.argsSchema.safeParseAsync(e.params.arguments);if(!s.success)throw new T(S.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${s.error.message}`);let a=s.data,i=n.callback;return await Promise.resolve(i(a,t))}else{let s=n.callback;return await Promise.resolve(s(t))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0)}resource(e,t,...n){let s;typeof n[0]=="object"&&(s=n.shift());let a=n[0];if(typeof t=="string"){if(this._registeredResources[t])throw new Error(`Resource ${t} is already registered`);let i={name:e,metadata:s,readCallback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:c=>{typeof c.uri<"u"&&c.uri!==t&&(delete this._registeredResources[t],c.uri&&(this._registeredResources[c.uri]=i)),typeof c.name<"u"&&(i.name=c.name),typeof c.metadata<"u"&&(i.metadata=c.metadata),typeof c.callback<"u"&&(i.readCallback=c.callback),typeof c.enabled<"u"&&(i.enabled=c.enabled),this.sendResourceListChanged()}};return this._registeredResources[t]=i,this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i={resourceTemplate:t,metadata:s,readCallback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==e&&(delete this._registeredResourceTemplates[e],c.name&&(this._registeredResourceTemplates[c.name]=i)),typeof c.template<"u"&&(i.resourceTemplate=c.template),typeof c.metadata<"u"&&(i.metadata=c.metadata),typeof c.callback<"u"&&(i.readCallback=c.callback),typeof c.enabled<"u"&&(i.enabled=c.enabled),this.sendResourceListChanged()}};return this._registeredResourceTemplates[e]=i,this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}tool(e,...t){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n=u=>typeof u!="object"||u===null?!1:Object.values(u).some(m=>m instanceof _),s;typeof t[0]=="string"&&(s=t.shift());let a,i;if(t.length>1){let u=t[0];n(u)?(a=t.shift(),t.length>1&&typeof t[0]=="object"&&t[0]!==null&&!n(t[0])&&(i=t.shift())):typeof u=="object"&&u!==null&&(i=t.shift())}let c=t[0],l={description:s,inputSchema:a===void 0?void 0:o.object(a),annotations:i,callback:c,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredTools[e],u.name&&(this._registeredTools[u.name]=l)),typeof u.description<"u"&&(l.description=u.description),typeof u.paramsSchema<"u"&&(l.inputSchema=o.object(u.paramsSchema)),typeof u.callback<"u"&&(l.callback=u.callback),typeof u.annotations<"u"&&(l.annotations=u.annotations),typeof u.enabled<"u"&&(l.enabled=u.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}prompt(e,...t){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof t[0]=="string"&&(n=t.shift());let s;t.length>1&&(s=t.shift());let a=t[0],i={description:n,argsSchema:s===void 0?void 0:o.object(s),callback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==e&&(delete this._registeredPrompts[e],c.name&&(this._registeredPrompts[c.name]=i)),typeof c.description<"u"&&(i.description=c.description),typeof c.argsSchema<"u"&&(i.argsSchema=o.object(c.argsSchema)),typeof c.callback<"u"&&(i.callback=c.callback),typeof c.enabled<"u"&&(i.enabled=c.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}isConnected(){return this.server.transport!==void 0}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var xa={type:"object"};function ka(r){return Object.entries(r.shape).map(([e,t])=>({name:e,description:t.description,required:!t.isOptional()}))}function rn(r){return{completion:{values:r.slice(0,100),total:r.length,hasMore:r.length>100}}}var mt={completion:{values:[],hasMore:!1}};var $t=_t(require("node:process"),1);var ht=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
9
+ `);if(e===-1)return null;let t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),wa(t)}clear(){this._buffer=void 0}};function wa(r){return fr.parse(JSON.parse(r))}function nn(r){return JSON.stringify(r)+`
10
+ `}var gt=class{constructor(e=$t.default.stdin,t=$t.default.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new ht,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{var s;(s=this.onerror)===null||s===void 0||s.call(this,n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(var e,t;;)try{let n=this._readBuffer.readMessage();if(n===null)break;(e=this.onmessage)===null||e===void 0||e.call(this,n)}catch(n){(t=this.onerror)===null||t===void 0||t.call(this,n)}}async close(){var e;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),(e=this.onclose)===null||e===void 0||e.call(this)}send(e){return new Promise(t=>{let n=nn(e);this._stdout.write(n)?t():this._stdout.once("drain",t)})}};var yn=_t(ln());var fn=_t(pn());var mn=r=>r==null?!1:typeof r=="string"?r.trim().length>0:Array.isArray(r)?r.length>0:typeof r=="object"?Object.keys(r).length>0:!0;var Wa=new fn.default,Ya=o.object({query:o.string().describe("User request to add, create, build, generate, implement, or develop new features, components, pages, modules, dashboards, or functionality. Trigger words include: 'add', 'create', 'build', 'generate', 'implement', 'develop', 'make', 'setup'. Examples: 'add login page', 'create auth flow', 'build sales dashboard', 'implement user CRUD', 'generate reports module', 'setup payment system'. Use this for new development requests, not for questions or modifications to existing code."),selectedBlockCode:o.string().describe("The Code of the selected block.").optional(),blockInput:o.string().describe("JSON string containing the input data for the block when required by the block's schema.").optional()}),hn=r=>{r.tool("add_block","REQUIRED: Use this tool when users request to add, create, build, or implement new features, components, pages, modules, or functionality in their project. This searches Derived's template library for matching blocks based on semantic similarity to the user's request. Trigger for requests like: 'add login page', 'create auth flow', 'build dashboard', 'implement user CRUD', 'generate reports module'. The tool finds matching blocks, handles user selection for multiple options, and collects required input data.",Ya.shape,async({query:e,selectedBlockCode:t,blockInput:n})=>{console.error("add_block",e,t,n);try{if(t){let i=`npx derived-cli add ${t}`;if(mn(n)){let c=Buffer.from(JSON.stringify(n)).toString("base64");i+=` -i ${c}`}return{content:[{type:"text",text:`Run cli command ${i},
11
11
  cli options
12
12
  "-o, --overwrite", "Automatically overwrite existing files"
13
13
  "-i, --block-input <value>", "Optional block input json schema in base 64 encoded"
14
- `}]}}let a=(await Ja.searchBlocksByName(e)).result;if(!a||a.length===0)return{content:[{type:"text",text:"No blocks found matching."}]};if(a.length>1)return{content:[{type:"text",text:`Found ${a.length} blocks:
14
+ `}]}}let a=(await Wa.searchBlocksByName(e)).result;return!a||a.length===0?{content:[{type:"text",text:"No blocks found matching."}]}:a.length?{content:[{type:"text",text:`Found ${a.length} blocks:
15
15
 
16
16
  ${a.map((i,c)=>`${c+1}. ${i.name}
17
17
  - Code: ${i.code}
18
- - Input Required: ${i.input?"Yes":"No"}`).join(`
19
18
 
20
- `)}.**Please specify which block you'd like to add by providing its code.**`}]};if(a.length){let i=a[0];return i?.input?{content:[{type:"text",text:`Please ask user to provide the inputs.
21
- Follow below structure for input:
22
- ${JSON.stringify(i.input)} and return the input in JSON format with block code: ${i?.code}`}]}:{content:[{type:"text",text:`Found block: ${i?.name}, - Code: ${i?.code}, - Input Required: ${i?.input?"Yes":"No"}, Call add_block tool with the block code: ${i?.code}`}]}}return{content:[{type:"text",text:"No blocks found."}]}}catch(s){return console.error("Error in add_block:",s),{content:[{type:"text",text:`Error occurred while searching for blocks: ${s instanceof Error?s.message:"Unknown error"}. Info user that the block could not be added.`}]}}})};var hn=r=>{fn(r)};gn.default.config();var yn=new ft({name:"Derived",version:"1.0.0"});hn(yn);async function Ya(){let r=new gt;await yn.connect(r),console.error("Derived MCP Server running on stdio")}Ya().catch(r=>{console.error("Fatal error:",r),process.exit(1)});
19
+ - Input Required: ${i.input?"Yes":"No"}
20
+
21
+ - Input Schema: Please ask user to provide the inputs.
22
+ Follow below structure ${i.input?JSON.stringify(i.input):"N/A"}
23
+
24
+ ${a.length>1?"Description: "+i.description:""}`).join(`
25
+
26
+ `)}.**Please specify which block you'd like to add by providing its code. and relevant input**`}]}:{content:[{type:"text",text:"No blocks found."}]}}catch(s){return console.error("Error in add_block:",s),{content:[{type:"text",text:`Error occurred while searching for blocks: ${s instanceof Error?s.message:"Unknown error"}. Info user that the block could not be added.`}]}}})};var gn=r=>{hn(r)};yn.default.config();var vn=new ft({name:"Derived",version:"1.0.0"});gn(vn);async function Ka(){let r=new gt;await vn.connect(r),console.error("Derived MCP Server running on stdio")}Ka().catch(r=>{console.error("Fatal error:",r),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "derived-mcp-server",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "MCP server for Derived",
5
5
  "author": "Derived",
6
6
  "license": "MIT",