bc-telemetry-buddy-mcp 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.0.2] - 2026-02-26
11
+
12
+ ### Fixed
13
+ - **Profile switching in stdio mode**: `detectInitialProfile()`, `switchProfile()`, and `listProfiles()` in `ToolHandlers` (used by Claude Desktop / Claude Code) now respect `configFilePath` instead of hardcoding workspace path discovery — fixing `profileMode: "single"` being returned and profile switching failing when using `--config` with a custom path (PR #99 by @StefanMaron)
14
+
10
15
  ## [3.0.1] - 2026-02-24
11
16
 
12
17
  ### Fixed
package/dist/cli.js CHANGED
@@ -82,7 +82,7 @@ Headers: ${JSON.stringify(r)}`}}return a},this.logUrlWithPiiAwareness=(o,c)=>{if
82
82
  `),new Error("BCTB_WORKSPACE_PATH environment variable is required");return{connectionName:process.env.BCTB_CONNECTION_NAME||"Default",tenantId:process.env.BCTB_TENANT_ID||"",clientId:process.env.BCTB_CLIENT_ID,clientSecret:process.env.BCTB_CLIENT_SECRET,authFlow:process.env.BCTB_AUTH_FLOW||"azure_cli",applicationInsightsAppId:process.env.BCTB_APP_INSIGHTS_ID||"",kustoClusterUrl:process.env.BCTB_KUSTO_URL||"",cacheEnabled:process.env.BCTB_CACHE_ENABLED!=="false",cacheTTLSeconds:parseInt(process.env.BCTB_CACHE_TTL||"3600",10),removePII:process.env.BCTB_REMOVE_PII==="true",port:parseInt(process.env.BCTB_PORT||"52345",10),workspacePath:n,queriesFolder:process.env.BCTB_QUERIES_FOLDER||"queries",references:pcr(process.env.BCTB_REFERENCES||"[]")}}function pcr(n){try{let e=JSON.parse(n);return Array.isArray(e)?e:[]}catch(e){return console.error("Failed to parse references:",e),[]}}function iGe(n,e,i=new Set){if(i.has(e))throw new Error(`Circular profile inheritance detected: ${e}`);i.add(e);let s=n[e];if(!s)throw new Error(`Profile '${e}' not found`);if(!s.extends)return v3(s);let o=iGe(n,s.extends,i),c=oGe(o,s);return delete c.extends,v3(c)}function oGe(n,e){let i={...n};for(let s in e)s!=="extends"&&(typeof e[s]=="object"&&!Array.isArray(e[s])&&e[s]!==null?i[s]=oGe(n[s]||{},e[s]):i[s]=e[s]);return i}function v3(n){let e=Array.isArray(n)?[]:{};for(let i in n){let s=n[i];typeof s=="string"?e[i]=s.replace(/\$\{([^}]+)\}/g,(o,c)=>process.env[c]||""):typeof s=="object"&&s!==null?e[i]=v3(s):e[i]=s}return e}function dcr(n){let e=[];return n.authFlow!=="azure_cli"&&n.authFlow!=="vscode_auth"&&!n.tenantId&&e.push("BCTB_TENANT_ID is required (unless using azure_cli or vscode_auth auth flow)"),n.applicationInsightsAppId||e.push("BCTB_APP_INSIGHTS_ID is required"),n.kustoClusterUrl||e.push("BCTB_KUSTO_URL is required"),n.authFlow==="client_credentials"&&!n.clientId&&e.push("BCTB_CLIENT_ID is required for client_credentials auth flow"),n.authFlow==="client_credentials"&&!n.clientSecret&&e.push("BCTB_CLIENT_SECRET is required for client_credentials auth flow"),e.length>0&&(console.error(`
83
83
  \u26A0\uFE0F Configuration Incomplete:`),e.forEach(i=>console.error(` - ${i}`)),console.error(`
84
84
  Server will start but queries will fail until configuration is complete.`),console.error(`Run "BC Telemetry Buddy: Setup Wizard" from Command Palette to configure.
85
- `)),e}});var b3=f(Ln=>{"use strict";var fcr=Ln&&Ln.__createBinding||(Object.create?(function(n,e,i,s){s===void 0&&(s=i);var o=Object.getOwnPropertyDescriptor(e,i);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(n,s,o)}):(function(n,e,i,s){s===void 0&&(s=i),n[s]=e[i]})),Nd=Ln&&Ln.__exportStar||function(n,e){for(var i in n)i!=="default"&&!Object.prototype.hasOwnProperty.call(e,i)&&fcr(e,n,i)};Object.defineProperty(Ln,"__esModule",{value:!0});Ln.expandEnvironmentVariables=Ln.resolveProfileInheritance=Ln.validateConfig=Ln.loadConfig=Ln.TELEMETRY_CONNECTION_STRING=void 0;Nd(m4e(),Ln);Nd(I6e(),Ln);Nd(C6e(),Ln);Nd(M6e(),Ln);Nd(V6e(),Ln);Nd(H6e(),Ln);Nd(K6e(),Ln);Nd(sle(),Ln);Nd(eGe(),Ln);Nd(rGe(),Ln);var hcr=nGe();Object.defineProperty(Ln,"TELEMETRY_CONNECTION_STRING",{enumerable:!0,get:function(){return hcr.TELEMETRY_CONNECTION_STRING}});var _3=aGe();Object.defineProperty(Ln,"loadConfig",{enumerable:!0,get:function(){return _3.loadConfig}});Object.defineProperty(Ln,"validateConfig",{enumerable:!0,get:function(){return _3.validateConfig}});Object.defineProperty(Ln,"resolveProfileInheritance",{enumerable:!0,get:function(){return _3.resolveProfileInheritance}});Object.defineProperty(Ln,"expandEnvironmentVariables",{enumerable:!0,get:function(){return _3.expandEnvironmentVariables}})});var Io,VC=M(()=>{"use strict";Io="3.0.1"});var Id=f((ABn,lGe)=>{var mcr=require("path").relative;lGe.exports=bcr;var ycr=process.cwd();function cGe(n,e){for(var i=n.split(/[ ,]+/),s=String(e).toLowerCase(),o=0;o<i.length;o++){var c=i[o];if(c&&(c==="*"||c.toLowerCase()===s))return!0}return!1}function gcr(n,e,i){var s=Object.getOwnPropertyDescriptor(n,e),o=s.value;return s.get=function(){return o},s.writable&&(s.set=function(r){return o=r}),delete s.value,delete s.writable,Object.defineProperty(n,e,s),s}function vcr(n){for(var e="",i=0;i<n;i++)e+=", arg"+i;return e.substr(2)}function _cr(n){var e=this.name+": "+this.namespace;this.message&&(e+=" deprecated "+this.message);for(var i=0;i<n.length;i++)e+=`
85
+ `)),e}});var b3=f(Ln=>{"use strict";var fcr=Ln&&Ln.__createBinding||(Object.create?(function(n,e,i,s){s===void 0&&(s=i);var o=Object.getOwnPropertyDescriptor(e,i);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(n,s,o)}):(function(n,e,i,s){s===void 0&&(s=i),n[s]=e[i]})),Nd=Ln&&Ln.__exportStar||function(n,e){for(var i in n)i!=="default"&&!Object.prototype.hasOwnProperty.call(e,i)&&fcr(e,n,i)};Object.defineProperty(Ln,"__esModule",{value:!0});Ln.expandEnvironmentVariables=Ln.resolveProfileInheritance=Ln.validateConfig=Ln.loadConfig=Ln.TELEMETRY_CONNECTION_STRING=void 0;Nd(m4e(),Ln);Nd(I6e(),Ln);Nd(C6e(),Ln);Nd(M6e(),Ln);Nd(V6e(),Ln);Nd(H6e(),Ln);Nd(K6e(),Ln);Nd(sle(),Ln);Nd(eGe(),Ln);Nd(rGe(),Ln);var hcr=nGe();Object.defineProperty(Ln,"TELEMETRY_CONNECTION_STRING",{enumerable:!0,get:function(){return hcr.TELEMETRY_CONNECTION_STRING}});var _3=aGe();Object.defineProperty(Ln,"loadConfig",{enumerable:!0,get:function(){return _3.loadConfig}});Object.defineProperty(Ln,"validateConfig",{enumerable:!0,get:function(){return _3.validateConfig}});Object.defineProperty(Ln,"resolveProfileInheritance",{enumerable:!0,get:function(){return _3.resolveProfileInheritance}});Object.defineProperty(Ln,"expandEnvironmentVariables",{enumerable:!0,get:function(){return _3.expandEnvironmentVariables}})});var Io,VC=M(()=>{"use strict";Io="3.0.2"});var Id=f((ABn,lGe)=>{var mcr=require("path").relative;lGe.exports=bcr;var ycr=process.cwd();function cGe(n,e){for(var i=n.split(/[ ,]+/),s=String(e).toLowerCase(),o=0;o<i.length;o++){var c=i[o];if(c&&(c==="*"||c.toLowerCase()===s))return!0}return!1}function gcr(n,e,i){var s=Object.getOwnPropertyDescriptor(n,e),o=s.value;return s.get=function(){return o},s.writable&&(s.set=function(r){return o=r}),delete s.value,delete s.writable,Object.defineProperty(n,e,s),s}function vcr(n){for(var e="",i=0;i<n;i++)e+=", arg"+i;return e.substr(2)}function _cr(n){var e=this.name+": "+this.namespace;this.message&&(e+=" deprecated "+this.message);for(var i=0;i<n.length;i++)e+=`
86
86
  at `+n[i].toString();return e}function bcr(n){if(!n)throw new TypeError("argument namespace is required");var e=S3(),i=$E(e[1]),s=i[0];function o(c){T3.call(o,c)}return o._file=s,o._ignored=Scr(n),o._namespace=n,o._traced=Ecr(n),o._warned=Object.create(null),o.function=Pcr,o.property=Rcr,o}function Tcr(n,e){var i=typeof n.listenerCount!="function"?n.listeners(e).length:n.listenerCount(e);return i>0}function Scr(n){if(process.noDeprecation)return!0;var e=process.env.NO_DEPRECATION||"";return cGe(e,n)}function Ecr(n){if(process.traceDeprecation)return!0;var e=process.env.TRACE_DEPRECATION||"";return cGe(e,n)}function T3(n,e){var i=Tcr(process,"deprecation");if(!(!i&&this._ignored)){var s,o,c,r,t=0,a=!1,u=S3(),l=this._file;for(e?(r=e,c=$E(u[1]),c.name=r.name,l=c[0]):(t=2,r=$E(u[t]),c=r);t<u.length;t++)if(s=$E(u[t]),o=s[0],o===l)a=!0;else if(o===this._file)l=this._file;else if(a)break;var p=s?r.join(":")+"__"+s.join(":"):void 0;if(!(p!==void 0&&p in this._warned)){this._warned[p]=!0;var d=n;if(d||(d=c===r||!c.name?sGe(r):sGe(c)),i){var h=uGe(this._namespace,d,u.slice(t));process.emit("deprecation",h);return}var m=process.stderr.isTTY?xcr:Ocr,y=m.call(this,d,s,u.slice(t));process.stderr.write(y+`
87
87
  `,"utf8")}}}function $E(n){var e=n.getFileName()||"<anonymous>",i=n.getLineNumber(),s=n.getColumnNumber();n.isEval()&&(e=n.getEvalOrigin()+", "+e);var o=[e,i,s];return o.callSite=n,o.name=n.getFunctionName(),o}function sGe(n){var e=n.callSite,i=n.name;i||(i="<anonymous@"+gle(n)+">");var s=e.getThis(),o=s&&e.getTypeName();return o==="Object"&&(o=void 0),o==="Function"&&(o=s.name||o),o&&e.getMethodName()?o+"."+i:i}function Ocr(n,e,i){var s=new Date().toUTCString(),o=s+" "+this._namespace+" deprecated "+n;if(this._traced){for(var c=0;c<i.length;c++)o+=`
88
88
  at `+i[c].toString();return o}return e&&(o+=" at "+gle(e)),o}function xcr(n,e,i){var s="\x1B[36;1m"+this._namespace+"\x1B[22;39m \x1B[33;1mdeprecated\x1B[22;39m \x1B[0m"+n+"\x1B[39m";if(this._traced){for(var o=0;o<i.length;o++)s+=`
@@ -403,7 +403,7 @@ ${u}
403
403
  , companyName = tostring(customDimensions.companyName)
404
404
  | summarize count() by aadTenantId, companyName
405
405
  | project companyName, aadTenantId, count_`;i&&(s+=`
406
- | where companyName contains "${i}"`);let o=await this.executeQuery(s,!1,!1);if(o.type==="error")throw new Error(o.summary);let c=(o.rows||[]).map(r=>({companyName:r[0],aadTenantId:r[1],occurrences:r[2]}));return{daysBack:e,totalMappings:c.length,mappings:c.sort((r,t)=>t.occurrences-r.occurrences),usage:{summary:`Found ${c.length} company-to-tenant mappings in the last ${e} days`,recommendation:'Use aadTenantId for filtering telemetry queries. Example: | where tostring(customDimensions.aadTenantId) == "{tenantId}"'}}}detectInitialProfile(){let e=require("fs"),i=require("path");try{let s=i.join(this.config.workspacePath,".bctb-config.json");if(!e.existsSync(s))return null;let o=e.readFileSync(s,"utf8"),c=JSON.parse(o);return!c.profiles||Object.keys(c.profiles).length===0?null:process.env.BCTB_PROFILE||c.defaultProfile||"default"}catch{return null}}switchProfile(e){let i=require("fs"),s=require("path");try{let o=s.join(this.config.workspacePath,".bctb-config.json");if(!i.existsSync(o))return{success:!1,error:"No .bctb-config.json found - cannot switch profiles in single-config mode"};let c=i.readFileSync(o,"utf8"),r=JSON.parse(c);if(!r.profiles||Object.keys(r.profiles).length===0)return{success:!1,error:"Config file has no profiles defined - cannot switch profiles"};let t=Object.keys(r.profiles).filter(l=>!l.startsWith("_"));if(!t.includes(e))return{success:!1,error:`Profile '${e}' not found. Available profiles: ${t.join(", ")}`};let a=sp(o,e,this.isStdioMode);if(!a)return{success:!1,error:`Failed to load configuration for profile '${e}'`};a.port=this.config.port;let u=this.activeProfileName||this.config.connectionName;return this.config=a,this.configErrors=ap(this.config),this.activeProfileName=e,this.services.auth=new Ut.AuthService(this.config),this.services.kusto=new Ut.KustoService(this.config.applicationInsightsAppId,this.config.kustoClusterUrl,this.services.usageTelemetry),this.services.cache=new Ut.CacheService(this.config.workspacePath,this.config.cacheTTLSeconds,this.config.cacheEnabled),this.services.queries=new Ut.QueriesService(this.config.workspacePath,this.config.queriesFolder),this.services.references=new Ut.ReferencesService(this.config.references,this.services.cache),this.isStdioMode||(console.error(`[Profile] Switched from '${u}' to '${e}'`),console.error(`[Profile] Connection: ${this.config.connectionName}`),console.error(`[Profile] App Insights ID: ${this.config.applicationInsightsAppId||"(not set)"}`)),{success:!0,previousProfile:u,currentProfile:{name:e,connectionName:this.config.connectionName,applicationInsightsAppId:this.config.applicationInsightsAppId,authFlow:this.config.authFlow},message:`Successfully switched to profile '${e}' (${this.config.connectionName})`,configValid:this.configErrors.length===0,configErrors:this.configErrors.length>0?this.configErrors:void 0}}catch(o){return{success:!1,error:`Failed to switch profile: ${o.message}`}}}listProfiles(){let e=require("fs"),i=require("path");try{let s=i.join(this.config.workspacePath,".bctb-config.json");if(!e.existsSync(s))return{profileMode:"single",currentProfile:{name:"default",connectionName:this.config.connectionName,isActive:!0},availableProfiles:[],message:"Single profile mode - using workspace settings or environment variables"};let o=e.readFileSync(s,"utf8"),c=JSON.parse(o);if(!c.profiles||Object.keys(c.profiles).length===0)return{profileMode:"single",currentProfile:{name:"default",connectionName:c.connectionName||this.config.connectionName,isActive:!0},availableProfiles:[],message:"Single profile mode - config file has no profiles object"};let r=this.activeProfileName||process.env.BCTB_PROFILE||c.defaultProfile||"default",t=Object.entries(c.profiles).filter(([u])=>!u.startsWith("_")).map(([u,l])=>({name:u,connectionName:l.connectionName||u,isActive:u===r,applicationInsightsAppId:l.applicationInsightsAppId,authFlow:l.authFlow,extends:l.extends}));return{profileMode:"multi",currentProfile:t.find(u=>u.isActive)||{name:r,connectionName:this.config.connectionName,isActive:!0},availableProfiles:t.filter(u=>!u.isActive),totalProfiles:t.length,message:`Multi-profile configuration with ${t.length} profile(s). Currently using: ${r}`,usage:{summary:"This workspace has multiple telemetry profiles configured for different customers/environments",switchingInstructions:"To switch profiles, use the switch_profile tool with the profile name. In VS Code, you can also use the status bar or command palette.",noteForQueries:"All queries execute against the currently active profile. Use list_profiles to confirm which profile is active before running queries."}}}catch(s){return{profileMode:"error",error:s.message,currentProfile:{name:"unknown",connectionName:this.config.connectionName,isActive:!0},availableProfiles:[]}}}async generateRecommendations(e,i){let s=[];return e.includes("where")&&!e.includes("| where")&&s.push('Consider using the pipe operator before "where" for better performance'),e.includes("*")&&s.push("Specify explicit columns instead of * for better performance"),e.toLowerCase().includes("ago(")||s.push("Consider adding a time range filter (e.g., | where timestamp > ago(1d))"),i.rows&&i.rows.length>1e4&&s.push('Large result set. Consider adding "| take 100" or similar limit'),s}}});function Aqn(n){switch(n.type){case"string":return n.enum?xn.enum(n.enum).optional():xn.string().optional();case"number":return xn.number().optional();case"boolean":return xn.boolean().optional();case"array":return n.items?.type==="string"?xn.array(xn.string()).optional():xn.array(xn.unknown()).optional();case"object":return xn.record(xn.string(),xn.unknown()).optional();default:return xn.unknown().optional()}}function Pqn(n){switch(n.type){case"string":return n.enum?xn.enum(n.enum):xn.string();case"number":return xn.number();case"boolean":return xn.boolean();case"array":return n.items?.type==="string"?xn.array(xn.string()):xn.array(xn.unknown());case"object":return xn.record(xn.string(),xn.unknown());default:return xn.unknown()}}function Rqn(n){let e={},i=new Set(n.inputSchema.required||[]);for(let[s,o]of Object.entries(n.inputSchema.properties))i.has(s)?e[s]=Pqn(o):e[s]=Aqn(o);return e}function Nqn(n){let e=new Zoe({name:"BC Telemetry Buddy",version:Io},{capabilities:{tools:{listChanged:!0},logging:{}}});for(let i of eae){let s=Rqn(i);e.registerTool(i.name,{description:i.description,inputSchema:s,annotations:i.annotations?{readOnlyHint:i.annotations.readOnlyHint,destructiveHint:i.annotations.destructiveHint,idempotentHint:i.annotations.idempotentHint,openWorldHint:i.annotations.openWorldHint}:void 0},async o=>{try{let c=await n.executeToolCall(i.name,o);return{content:[{type:"text",text:typeof c=="string"?c:JSON.stringify(c,null,2)}]}}catch(c){return{content:[{type:"text",text:`Error: ${c.message}`}],isError:!0}}})}return e}async function wKt(n){console.log=(...a)=>{process.stderr.write("[MCP] "+a.join(" ")+`
406
+ | where companyName contains "${i}"`);let o=await this.executeQuery(s,!1,!1);if(o.type==="error")throw new Error(o.summary);let c=(o.rows||[]).map(r=>({companyName:r[0],aadTenantId:r[1],occurrences:r[2]}));return{daysBack:e,totalMappings:c.length,mappings:c.sort((r,t)=>t.occurrences-r.occurrences),usage:{summary:`Found ${c.length} company-to-tenant mappings in the last ${e} days`,recommendation:'Use aadTenantId for filtering telemetry queries. Example: | where tostring(customDimensions.aadTenantId) == "{tenantId}"'}}}detectInitialProfile(){let e=require("fs"),i=require("path");try{let s=this.config.configFilePath||i.join(this.config.workspacePath,".bctb-config.json");if(!e.existsSync(s))return null;let o=e.readFileSync(s,"utf8"),c=JSON.parse(o);return!c.profiles||Object.keys(c.profiles).length===0?null:process.env.BCTB_PROFILE||c.defaultProfile||"default"}catch{return null}}switchProfile(e){let i=require("fs"),s=require("path");try{let o=this.config.configFilePath||s.join(this.config.workspacePath,".bctb-config.json");if(!i.existsSync(o))return{success:!1,error:"No .bctb-config.json found - cannot switch profiles in single-config mode"};let c=i.readFileSync(o,"utf8"),r=JSON.parse(c);if(!r.profiles||Object.keys(r.profiles).length===0)return{success:!1,error:"Config file has no profiles defined - cannot switch profiles"};let t=Object.keys(r.profiles).filter(l=>!l.startsWith("_"));if(!t.includes(e))return{success:!1,error:`Profile '${e}' not found. Available profiles: ${t.join(", ")}`};let a=sp(o,e,this.isStdioMode);if(!a)return{success:!1,error:`Failed to load configuration for profile '${e}'`};a.port=this.config.port;let u=this.activeProfileName||this.config.connectionName;return this.config=a,this.configErrors=ap(this.config),this.activeProfileName=e,this.services.auth=new Ut.AuthService(this.config),this.services.kusto=new Ut.KustoService(this.config.applicationInsightsAppId,this.config.kustoClusterUrl,this.services.usageTelemetry),this.services.cache=new Ut.CacheService(this.config.workspacePath,this.config.cacheTTLSeconds,this.config.cacheEnabled),this.services.queries=new Ut.QueriesService(this.config.workspacePath,this.config.queriesFolder),this.services.references=new Ut.ReferencesService(this.config.references,this.services.cache),this.isStdioMode||(console.error(`[Profile] Switched from '${u}' to '${e}'`),console.error(`[Profile] Connection: ${this.config.connectionName}`),console.error(`[Profile] App Insights ID: ${this.config.applicationInsightsAppId||"(not set)"}`)),{success:!0,previousProfile:u,currentProfile:{name:e,connectionName:this.config.connectionName,applicationInsightsAppId:this.config.applicationInsightsAppId,authFlow:this.config.authFlow},message:`Successfully switched to profile '${e}' (${this.config.connectionName})`,configValid:this.configErrors.length===0,configErrors:this.configErrors.length>0?this.configErrors:void 0}}catch(o){return{success:!1,error:`Failed to switch profile: ${o.message}`}}}listProfiles(){let e=require("fs"),i=require("path");try{let s=this.config.configFilePath||i.join(this.config.workspacePath,".bctb-config.json");if(!e.existsSync(s))return{profileMode:"single",currentProfile:{name:"default",connectionName:this.config.connectionName,isActive:!0},availableProfiles:[],message:"Single profile mode - using workspace settings or environment variables"};let o=e.readFileSync(s,"utf8"),c=JSON.parse(o);if(!c.profiles||Object.keys(c.profiles).length===0)return{profileMode:"single",currentProfile:{name:"default",connectionName:c.connectionName||this.config.connectionName,isActive:!0},availableProfiles:[],message:"Single profile mode - config file has no profiles object"};let r=this.activeProfileName||process.env.BCTB_PROFILE||c.defaultProfile||"default",t=Object.entries(c.profiles).filter(([u])=>!u.startsWith("_")).map(([u,l])=>({name:u,connectionName:l.connectionName||u,isActive:u===r,applicationInsightsAppId:l.applicationInsightsAppId,authFlow:l.authFlow,extends:l.extends}));return{profileMode:"multi",currentProfile:t.find(u=>u.isActive)||{name:r,connectionName:this.config.connectionName,isActive:!0},availableProfiles:t.filter(u=>!u.isActive),totalProfiles:t.length,message:`Multi-profile configuration with ${t.length} profile(s). Currently using: ${r}`,usage:{summary:"This workspace has multiple telemetry profiles configured for different customers/environments",switchingInstructions:"To switch profiles, use the switch_profile tool with the profile name. In VS Code, you can also use the status bar or command palette.",noteForQueries:"All queries execute against the currently active profile. Use list_profiles to confirm which profile is active before running queries."}}}catch(s){return{profileMode:"error",error:s.message,currentProfile:{name:"unknown",connectionName:this.config.connectionName,isActive:!0},availableProfiles:[]}}}async generateRecommendations(e,i){let s=[];return e.includes("where")&&!e.includes("| where")&&s.push('Consider using the pipe operator before "where" for better performance'),e.includes("*")&&s.push("Specify explicit columns instead of * for better performance"),e.toLowerCase().includes("ago(")||s.push("Consider adding a time range filter (e.g., | where timestamp > ago(1d))"),i.rows&&i.rows.length>1e4&&s.push('Large result set. Consider adding "| take 100" or similar limit'),s}}});function Aqn(n){switch(n.type){case"string":return n.enum?xn.enum(n.enum).optional():xn.string().optional();case"number":return xn.number().optional();case"boolean":return xn.boolean().optional();case"array":return n.items?.type==="string"?xn.array(xn.string()).optional():xn.array(xn.unknown()).optional();case"object":return xn.record(xn.string(),xn.unknown()).optional();default:return xn.unknown().optional()}}function Pqn(n){switch(n.type){case"string":return n.enum?xn.enum(n.enum):xn.string();case"number":return xn.number();case"boolean":return xn.boolean();case"array":return n.items?.type==="string"?xn.array(xn.string()):xn.array(xn.unknown());case"object":return xn.record(xn.string(),xn.unknown());default:return xn.unknown()}}function Rqn(n){let e={},i=new Set(n.inputSchema.required||[]);for(let[s,o]of Object.entries(n.inputSchema.properties))i.has(s)?e[s]=Pqn(o):e[s]=Aqn(o);return e}function Nqn(n){let e=new Zoe({name:"BC Telemetry Buddy",version:Io},{capabilities:{tools:{listChanged:!0},logging:{}}});for(let i of eae){let s=Rqn(i);e.registerTool(i.name,{description:i.description,inputSchema:s,annotations:i.annotations?{readOnlyHint:i.annotations.readOnlyHint,destructiveHint:i.annotations.destructiveHint,idempotentHint:i.annotations.idempotentHint,openWorldHint:i.annotations.openWorldHint}:void 0},async o=>{try{let c=await n.executeToolCall(i.name,o);return{content:[{type:"text",text:typeof c=="string"?c:JSON.stringify(c,null,2)}]}}catch(c){return{content:[{type:"text",text:`Error: ${c.message}`}],isError:!0}}})}return e}async function wKt(n){console.log=(...a)=>{process.stderr.write("[MCP] "+a.join(" ")+`
407
407
  `)},console.error=(...a)=>{process.stderr.write("[MCP] "+a.join(" ")+`
408
408
  `)},console.error(`BC Telemetry Buddy MCP Server v${Io} starting (stdio mode)...`);let e;if(n)e=n;else{let a=sp(void 0,void 0,!0);a?e=a:e=cq()}let i=ap(e),s=IKt(e,!0),o=new tae(e,s,!0,i),c=Nqn(o);if(i.length===0)try{await s.auth.authenticate()}catch{}let r=new Qoe;await c.connect(r);let t=async()=>{await s.usageTelemetry.flush(),await c.close(),process.exit(0)};process.on("SIGINT",t),process.on("SIGTERM",t)}var MKt=M(()=>{"use strict";xKt();RKt();iqe();vN();sqe();CKt();VC()});var kKt={};hn(kKt,{MCPServer:()=>rae,startServer:()=>Cqn});async function Iqn(){return new Promise(n=>{let e=setTimeout(()=>{n()},5e3),s=LKt.request({hostname:"registry.npmjs.org",path:"/bc-telemetry-buddy-mcp/latest",method:"GET",headers:{"User-Agent":"bc-telemetry-buddy-mcp"}},o=>{let c="";o.on("data",r=>{c+=r}),o.on("end",()=>{clearTimeout(e);try{let t=JSON.parse(c).version;t&&t!==Io&&(console.error(`
409
409
  \u26A0\uFE0F \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`),console.error("\u26A0\uFE0F MCP UPDATE AVAILABLE"),console.error("\u26A0\uFE0F \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),console.error(`\u26A0\uFE0F Current version: ${Io}`),console.error(`\u26A0\uFE0F Latest version: ${t}`),console.error("\u26A0\uFE0F"),console.error("\u26A0\uFE0F Update with: npm install -g bc-telemetry-buddy-mcp@latest"),console.error('\u26A0\uFE0F Or use VSCode command: "BC Telemetry Buddy: Check for MCP Updates"'),console.error(`\u26A0\uFE0F \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
package/dist/server.js CHANGED
@@ -251,7 +251,7 @@ Server will start but queries will fail until configuration is complete.`),conso
251
251
  Searched locations:`),process.env.BCTB_WORKSPACE_PATH&&console.error(` - ${md.join(process.env.BCTB_WORKSPACE_PATH,".bctb-config.json")} (workspace)`),console.error(` - ${md.join(sI.homedir(),".bctb","config.json")} (home directory)`),console.error(` - ${md.join(sI.homedir(),".bctb-config.json")} (home directory)`),console.error(`
252
252
  To create a config file, run:
253
253
  node path/to/mcp/dist/cli.js init
254
- `),null;i||(console.error(`\u{1F4C4} Loading config from: ${s}`),console.error(`[Config] BCTB_WORKSPACE_PATH env var = ${process.env.BCTB_WORKSPACE_PATH||"(not set)"}`));let c=Eh.readFileSync(s,"utf-8"),r=JSON.parse(c);if(r.profiles){let a=t||process.env.BCTB_PROFILE||r.defaultProfile;if(!a)throw new Error("No profile specified. Use --profile <name> or set BCTB_PROFILE env var");if(!r.profiles[a])throw new Error(`Profile '${a}' not found in config`);console.error(`\u{1F4CB} Using profile: "${a}"`);let u=I4e(r.profiles,a),l={...u,cacheEnabled:u.cacheEnabled??r.cache?.enabled??!0,cacheTTLSeconds:u.cacheTTLSeconds??r.cache?.ttlSeconds??3600,removePII:u.removePII??r.sanitize?.removePII??!1,references:u.references??r.references??[],port:u.port??52345,workspacePath:u.workspacePath??process.env.BCTB_WORKSPACE_PATH??process.cwd(),queriesFolder:u.queriesFolder??"queries",connectionName:u.connectionName??"Default",tenantId:u.tenantId??"",authFlow:u.authFlow??"azure_cli",applicationInsightsAppId:u.applicationInsightsAppId??"",kustoClusterUrl:u.kustoClusterUrl??"",configFilePath:s};return rj(l)}let e={connectionName:r.connectionName??"Default",tenantId:r.tenantId??"",clientId:r.clientId,clientSecret:r.clientSecret,authFlow:r.authFlow??"azure_cli",applicationInsightsAppId:r.applicationInsightsAppId??"",kustoClusterUrl:r.kustoClusterUrl??"",cacheEnabled:r.cacheEnabled??!0,cacheTTLSeconds:r.cacheTTLSeconds??3600,removePII:r.removePII??!1,port:r.port??52345,workspacePath:r.workspacePath??process.env.BCTB_WORKSPACE_PATH??process.cwd(),queriesFolder:r.queriesFolder??"queries",references:r.references??[],configFilePath:s};return rj(e)}function I4e(n,t,i=new Set){if(i.has(t))throw new Error(`Circular profile inheritance detected: ${t}`);i.add(t);let s=n[t];if(!s)throw new Error(`Profile '${t}' not found`);if(!s.extends)return s;let o=I4e(n,s.extends,i),c=w4e(o,s);return delete c.extends,c}function w4e(n,t){let i={...n};for(let s in t)s!=="extends"&&(typeof t[s]=="object"&&!Array.isArray(t[s])&&t[s]!==null?i[s]=w4e(n[s]||{},t[s]):i[s]=t[s]);return i}function rj(n){if(typeof n=="string")return n.replace(/\$\{([^}]+)\}/g,(t,i)=>{if(i==="workspaceFolder"){let s=process.env.BCTB_WORKSPACE_PATH||process.cwd();return console.error(`[Config] Expanding \${workspaceFolder} to: ${s}`),s}return process.env[i]||""});if(Array.isArray(n))return n.map(t=>rj(t));if(typeof n=="object"&&n!==null){let t={};for(let i in n)t[i]=rj(n[i]);return t}return n}var yr=be($pe());var Ia="3.0.1";var rGt=be(require("https"));var W0=be(Y3t()),is=be(require("fs")),CD=be(require("path")),J3t=be(require("crypto")),Z3t=be(require("os")),BCe=class{client;constructor(t,i,s){W0.setup(t).setAutoCollectRequests(!1).setAutoCollectPerformance(!1,!1).setAutoCollectExceptions(!1).setAutoCollectDependencies(!1).setAutoCollectConsole(!1).setUseDiskRetryCaching(!0),W0.start(),this.client=W0.defaultClient,this.client.commonProperties={installationId:i,version:s,component:"MCP"}}trackEvent(t,i,s){let o={};if(i)for(let[c,r]of Object.entries(i))o[c]=String(r);this.client.trackEvent({name:t,properties:o,measurements:s})}trackException(t,i){this.client.trackException({exception:t,properties:{errorName:t.name,errorMessage:t.message,...i}})}trackDependency(t,i,s,o,c,r){this.client.trackDependency({name:t,data:i,duration:s,success:o,resultCode:c||(o?"200":"500"),dependencyTypeName:"External",properties:r})}trackTrace(t,i){this.client.trackTrace({message:t,properties:i})}async flush(){return new Promise(t=>{this.client.flush(),setTimeout(t,2e3)})}},X3t=".bctb-installation-id",FAn=".bctb",$An="installation-id";function zAn(){let n=Z3t.homedir();return CD.join(n,FAn)}function MD(n){let t=zAn(),i=CD.join(t,$An);try{if(is.existsSync(i)){let c=is.readFileSync(i,"utf8").trim();if(c)return HAn(n),c}}catch{}let s=CD.join(n,X3t);try{if(is.existsSync(s)){let c=is.readFileSync(s,"utf8").trim();if(c)return W3t(t),is.writeFileSync(i,c,"utf8"),is.unlinkSync(s),c}}catch(c){console.error(`Failed to migrate workspace installation ID: ${c}`)}let o=J3t.randomUUID();try{W3t(t),is.writeFileSync(i,o,"utf8")}catch(c){console.error(`Failed to write installation ID file: ${c}`)}return o}function W3t(n){is.existsSync(n)||is.mkdirSync(n,{recursive:!0})}function HAn(n){let t=CD.join(n,X3t);try{is.existsSync(t)&&is.unlinkSync(t)}catch{}}function zee(n,t,i){if(!n||n.trim()==="")return null;try{let s=MD(t);return new BCe(n,s,i)}catch(s){return console.error(`Failed to initialize MCP usage telemetry: ${s}`),null}}var fUe=be(require("crypto"));var Ir;(function(n){n.assertEqual=o=>{};function t(o){}n.assertIs=t;function i(o){throw new Error}n.assertNever=i,n.arrayToEnum=o=>{let c={};for(let r of o)c[r]=r;return c},n.getValidEnumValues=o=>{let c=n.objectKeys(o).filter(e=>typeof o[o[e]]!="number"),r={};for(let e of c)r[e]=o[e];return n.objectValues(r)},n.objectValues=o=>n.objectKeys(o).map(function(c){return o[c]}),n.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let c=[];for(let r in o)Object.prototype.hasOwnProperty.call(o,r)&&c.push(r);return c},n.find=(o,c)=>{for(let r of o)if(c(r))return r},n.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function s(o,c=" | "){return o.map(r=>typeof r=="string"?`'${r}'`:r).join(c)}n.joinValues=s,n.jsonStringifyReplacer=(o,c)=>typeof c=="bigint"?c.toString():c})(Ir||(Ir={}));var Q3t;(function(n){n.mergeShapes=(t,i)=>({...t,...i})})(Q3t||(Q3t={}));var Ze=Ir.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Am=n=>{switch(typeof n){case"undefined":return Ze.undefined;case"string":return Ze.string;case"number":return Number.isNaN(n)?Ze.nan:Ze.number;case"boolean":return Ze.boolean;case"function":return Ze.function;case"bigint":return Ze.bigint;case"symbol":return Ze.symbol;case"object":return Array.isArray(n)?Ze.array:n===null?Ze.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Ze.promise:typeof Map<"u"&&n instanceof Map?Ze.map:typeof Set<"u"&&n instanceof Set?Ze.set:typeof Date<"u"&&n instanceof Date?Ze.date:Ze.object;default:return Ze.unknown}};var Se=Ir.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"]);var cu=class n extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let i=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,i):this.__proto__=i,this.name="ZodError",this.issues=t}format(t){let i=t||function(c){return c.message},s={_errors:[]},o=c=>{for(let r of c.issues)if(r.code==="invalid_union")r.unionErrors.map(o);else if(r.code==="invalid_return_type")o(r.returnTypeError);else if(r.code==="invalid_arguments")o(r.argumentsError);else if(r.path.length===0)s._errors.push(i(r));else{let e=s,a=0;for(;a<r.path.length;){let u=r.path[a];a===r.path.length-1?(e[u]=e[u]||{_errors:[]},e[u]._errors.push(i(r))):e[u]=e[u]||{_errors:[]},e=e[u],a++}}};return o(this),s}static assert(t){if(!(t instanceof n))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ir.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=i=>i.message){let i=Object.create(null),s=[];for(let o of this.issues)if(o.path.length>0){let c=o.path[0];i[c]=i[c]||[],i[c].push(t(o))}else s.push(t(o));return{formErrors:s,fieldErrors:i}}get formErrors(){return this.flatten()}};cu.create=n=>new cu(n);var GAn=(n,t)=>{let i;switch(n.code){case Se.invalid_type:n.received===Ze.undefined?i="Required":i=`Expected ${n.expected}, received ${n.received}`;break;case Se.invalid_literal:i=`Invalid literal value, expected ${JSON.stringify(n.expected,Ir.jsonStringifyReplacer)}`;break;case Se.unrecognized_keys:i=`Unrecognized key(s) in object: ${Ir.joinValues(n.keys,", ")}`;break;case Se.invalid_union:i="Invalid input";break;case Se.invalid_union_discriminator:i=`Invalid discriminator value. Expected ${Ir.joinValues(n.options)}`;break;case Se.invalid_enum_value:i=`Invalid enum value. Expected ${Ir.joinValues(n.options)}, received '${n.received}'`;break;case Se.invalid_arguments:i="Invalid function arguments";break;case Se.invalid_return_type:i="Invalid function return type";break;case Se.invalid_date:i="Invalid date";break;case Se.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(i=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(i=`${i} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?i=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?i=`Invalid input: must end with "${n.validation.endsWith}"`:Ir.assertNever(n.validation):n.validation!=="regex"?i=`Invalid ${n.validation}`:i="Invalid";break;case Se.too_small:n.type==="array"?i=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?i=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?i=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?i=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?i=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:i="Invalid input";break;case Se.too_big:n.type==="array"?i=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?i=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?i=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?i=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?i=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:i="Invalid input";break;case Se.custom:i="Invalid input";break;case Se.invalid_intersection_types:i="Intersection results could not be merged";break;case Se.not_multiple_of:i=`Number must be a multiple of ${n.multipleOf}`;break;case Se.not_finite:i="Number must be finite";break;default:i=t.defaultError,Ir.assertNever(n)}return{message:i}},nv=GAn;var KAn=nv;function LD(){return KAn}var Hee=n=>{let{data:t,path:i,errorMaps:s,issueData:o}=n,c=[...i,...o.path||[]],r={...o,path:c};if(o.message!==void 0)return{...o,path:c,message:o.message};let e="",a=s.filter(u=>!!u).slice().reverse();for(let u of a)e=u(r,{data:t,defaultError:e}).message;return{...o,path:c,message:e}};function Ue(n,t){let i=LD(),s=Hee({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,i,i===nv?void 0:nv].filter(o=>!!o)});n.common.issues.push(s)}var os=class n{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,i){let s=[];for(let o of i){if(o.status==="aborted")return Rt;o.status==="dirty"&&t.dirty(),s.push(o.value)}return{status:t.value,value:s}}static async mergeObjectAsync(t,i){let s=[];for(let o of i){let c=await o.key,r=await o.value;s.push({key:c,value:r})}return n.mergeObjectSync(t,s)}static mergeObjectSync(t,i){let s={};for(let o of i){let{key:c,value:r}=o;if(c.status==="aborted"||r.status==="aborted")return Rt;c.status==="dirty"&&t.dirty(),r.status==="dirty"&&t.dirty(),c.value!=="__proto__"&&(typeof r.value<"u"||o.alwaysSet)&&(s[c.value]=r.value)}return{status:t.value,value:s}}},Rt=Object.freeze({status:"aborted"}),J0=n=>({status:"dirty",value:n}),ws=n=>({status:"valid",value:n}),FCe=n=>n.status==="aborted",$Ce=n=>n.status==="dirty",kT=n=>n.status==="valid",kD=n=>typeof Promise<"u"&&n instanceof Promise;var it;(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t?.message})(it||(it={}));var $l=class{constructor(t,i,s,o){this._cachedPath=[],this.parent=t,this.data=i,this._path=s,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},eBt=(n,t)=>{if(kT(t))return{success:!0,data:t.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let i=new cu(n.common.issues);return this._error=i,this._error}}};function Zt(n){if(!n)return{};let{errorMap:t,invalid_type_error:i,required_error:s,description:o}=n;if(t&&(i||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(r,e)=>{let{message:a}=n;return r.code==="invalid_enum_value"?{message:a??e.defaultError}:typeof e.data>"u"?{message:a??s??e.defaultError}:r.code!=="invalid_type"?{message:e.defaultError}:{message:a??i??e.defaultError}},description:o}}var lr=class{get description(){return this._def.description}_getType(t){return Am(t.data)}_getOrReturnCtx(t,i){return i||{common:t.parent.common,data:t.data,parsedType:Am(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new os,ctx:{common:t.parent.common,data:t.data,parsedType:Am(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let i=this._parse(t);if(kD(i))throw new Error("Synchronous parse encountered promise.");return i}_parseAsync(t){let i=this._parse(t);return Promise.resolve(i)}parse(t,i){let s=this.safeParse(t,i);if(s.success)return s.data;throw s.error}safeParse(t,i){let s={common:{issues:[],async:i?.async??!1,contextualErrorMap:i?.errorMap},path:i?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Am(t)},o=this._parseSync({data:t,path:s.path,parent:s});return eBt(s,o)}"~validate"(t){let i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Am(t)};if(!this["~standard"].async)try{let s=this._parseSync({data:t,path:[],parent:i});return kT(s)?{value:s.value}:{issues:i.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:i}).then(s=>kT(s)?{value:s.value}:{issues:i.common.issues})}async parseAsync(t,i){let s=await this.safeParseAsync(t,i);if(s.success)return s.data;throw s.error}async safeParseAsync(t,i){let s={common:{issues:[],contextualErrorMap:i?.errorMap,async:!0},path:i?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Am(t)},o=this._parse({data:t,path:s.path,parent:s}),c=await(kD(o)?o:Promise.resolve(o));return eBt(s,c)}refine(t,i){let s=o=>typeof i=="string"||typeof i>"u"?{message:i}:typeof i=="function"?i(o):i;return this._refinement((o,c)=>{let r=t(o),e=()=>c.addIssue({code:Se.custom,...s(o)});return typeof Promise<"u"&&r instanceof Promise?r.then(a=>a?!0:(e(),!1)):r?!0:(e(),!1)})}refinement(t,i){return this._refinement((s,o)=>t(s)?!0:(o.addIssue(typeof i=="function"?i(s,o):i),!1))}_refinement(t){return new Kp({schema:this,typeName:Ae.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:i=>this["~validate"](i)}}optional(){return Gp.create(this,this._def)}nullable(){return Nm.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ov.create(this)}promise(){return DT.create(this,this._def)}or(t){return tR.create([this,t],this._def)}and(t){return rR.create(this,t,this._def)}transform(t){return new Kp({...Zt(this._def),schema:this,typeName:Ae.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let i=typeof t=="function"?t:()=>t;return new sR({...Zt(this._def),innerType:this,defaultValue:i,typeName:Ae.ZodDefault})}brand(){return new Gee({typeName:Ae.ZodBranded,type:this,...Zt(this._def)})}catch(t){let i=typeof t=="function"?t:()=>t;return new cR({...Zt(this._def),innerType:this,catchValue:i,typeName:Ae.ZodCatch})}describe(t){let i=this.constructor;return new i({...this._def,description:t})}pipe(t){return Kee.create(this,t)}readonly(){return uR.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},YAn=/^c[^\s-]{8,}$/i,WAn=/^[0-9a-z]+$/,JAn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ZAn=/^[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,XAn=/^[a-z0-9_-]{21}$/i,QAn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ePn=/^[-+]?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)?)??$/,tPn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rPn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",zCe,nPn=/^(?:(?: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])$/,iPn=/^(?:(?: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])$/,oPn=/^(([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]))$/,aPn=/^(([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])$/,sPn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,cPn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,tBt="((\\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])))",uPn=new RegExp(`^${tBt}$`);function rBt(n){let t="[0-5]\\d";n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`);let i=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${i}`}function lPn(n){return new RegExp(`^${rBt(n)}$`)}function pPn(n){let t=`${tBt}T${rBt(n)}`,i=[];return i.push(n.local?"Z?":"Z"),n.offset&&i.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${i.join("|")})`,new RegExp(`^${t}$`)}function dPn(n,t){return!!((t==="v4"||!t)&&nPn.test(n)||(t==="v6"||!t)&&oPn.test(n))}function fPn(n,t){if(!QAn.test(n))return!1;try{let[i]=n.split(".");if(!i)return!1;let s=i.replace(/-/g,"+").replace(/_/g,"/").padEnd(i.length+(4-i.length%4)%4,"="),o=JSON.parse(atob(s));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function hPn(n,t){return!!((t==="v4"||!t)&&iPn.test(n)||(t==="v6"||!t)&&aPn.test(n))}var X0=class n extends lr{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Ze.string){let c=this._getOrReturnCtx(t);return Ue(c,{code:Se.invalid_type,expected:Ze.string,received:c.parsedType}),Rt}let s=new os,o;for(let c of this._def.checks)if(c.kind==="min")t.data.length<c.value&&(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.too_small,minimum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),s.dirty());else if(c.kind==="max")t.data.length>c.value&&(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),s.dirty());else if(c.kind==="length"){let r=t.data.length>c.value,e=t.data.length<c.value;(r||e)&&(o=this._getOrReturnCtx(t,o),r?Ue(o,{code:Se.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!0,message:c.message}):e&&Ue(o,{code:Se.too_small,minimum:c.value,type:"string",inclusive:!0,exact:!0,message:c.message}),s.dirty())}else if(c.kind==="email")tPn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"email",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="emoji")zCe||(zCe=new RegExp(rPn,"u")),zCe.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"emoji",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="uuid")ZAn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"uuid",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="nanoid")XAn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"nanoid",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="cuid")YAn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"cuid",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="cuid2")WAn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"cuid2",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="ulid")JAn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"ulid",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),Ue(o,{validation:"url",code:Se.invalid_string,message:c.message}),s.dirty()}else c.kind==="regex"?(c.regex.lastIndex=0,c.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"regex",code:Se.invalid_string,message:c.message}),s.dirty())):c.kind==="trim"?t.data=t.data.trim():c.kind==="includes"?t.data.includes(c.value,c.position)||(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.invalid_string,validation:{includes:c.value,position:c.position},message:c.message}),s.dirty()):c.kind==="toLowerCase"?t.data=t.data.toLowerCase():c.kind==="toUpperCase"?t.data=t.data.toUpperCase():c.kind==="startsWith"?t.data.startsWith(c.value)||(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.invalid_string,validation:{startsWith:c.value},message:c.message}),s.dirty()):c.kind==="endsWith"?t.data.endsWith(c.value)||(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.invalid_string,validation:{endsWith:c.value},message:c.message}),s.dirty()):c.kind==="datetime"?pPn(c).test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.invalid_string,validation:"datetime",message:c.message}),s.dirty()):c.kind==="date"?uPn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.invalid_string,validation:"date",message:c.message}),s.dirty()):c.kind==="time"?lPn(c).test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.invalid_string,validation:"time",message:c.message}),s.dirty()):c.kind==="duration"?ePn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"duration",code:Se.invalid_string,message:c.message}),s.dirty()):c.kind==="ip"?dPn(t.data,c.version)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"ip",code:Se.invalid_string,message:c.message}),s.dirty()):c.kind==="jwt"?fPn(t.data,c.alg)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"jwt",code:Se.invalid_string,message:c.message}),s.dirty()):c.kind==="cidr"?hPn(t.data,c.version)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"cidr",code:Se.invalid_string,message:c.message}),s.dirty()):c.kind==="base64"?sPn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"base64",code:Se.invalid_string,message:c.message}),s.dirty()):c.kind==="base64url"?cPn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"base64url",code:Se.invalid_string,message:c.message}),s.dirty()):Ir.assertNever(c);return{status:s.value,value:t.data}}_regex(t,i,s){return this.refinement(o=>t.test(o),{validation:i,code:Se.invalid_string,...it.errToObj(s)})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...it.errToObj(t)})}url(t){return this._addCheck({kind:"url",...it.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...it.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...it.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...it.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...it.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...it.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...it.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...it.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...it.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...it.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...it.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...it.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...it.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...it.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...it.errToObj(t)})}regex(t,i){return this._addCheck({kind:"regex",regex:t,...it.errToObj(i)})}includes(t,i){return this._addCheck({kind:"includes",value:t,position:i?.position,...it.errToObj(i?.message)})}startsWith(t,i){return this._addCheck({kind:"startsWith",value:t,...it.errToObj(i)})}endsWith(t,i){return this._addCheck({kind:"endsWith",value:t,...it.errToObj(i)})}min(t,i){return this._addCheck({kind:"min",value:t,...it.errToObj(i)})}max(t,i){return this._addCheck({kind:"max",value:t,...it.errToObj(i)})}length(t,i){return this._addCheck({kind:"length",value:t,...it.errToObj(i)})}nonempty(t){return this.min(1,it.errToObj(t))}trim(){return new n({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let i of this._def.checks)i.kind==="min"&&(t===null||i.value>t)&&(t=i.value);return t}get maxLength(){let t=null;for(let i of this._def.checks)i.kind==="max"&&(t===null||i.value<t)&&(t=i.value);return t}};X0.create=n=>new X0({checks:[],typeName:Ae.ZodString,coerce:n?.coerce??!1,...Zt(n)});function mPn(n,t){let i=(n.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,o=i>s?i:s,c=Number.parseInt(n.toFixed(o).replace(".","")),r=Number.parseInt(t.toFixed(o).replace(".",""));return c%r/10**o}var DD=class n extends lr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Ze.number){let c=this._getOrReturnCtx(t);return Ue(c,{code:Se.invalid_type,expected:Ze.number,received:c.parsedType}),Rt}let s,o=new os;for(let c of this._def.checks)c.kind==="int"?Ir.isInteger(t.data)||(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.invalid_type,expected:"integer",received:"float",message:c.message}),o.dirty()):c.kind==="min"?(c.inclusive?t.data<c.value:t.data<=c.value)&&(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.too_small,minimum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),o.dirty()):c.kind==="max"?(c.inclusive?t.data>c.value:t.data>=c.value)&&(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.too_big,maximum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),o.dirty()):c.kind==="multipleOf"?mPn(t.data,c.value)!==0&&(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.not_multiple_of,multipleOf:c.value,message:c.message}),o.dirty()):c.kind==="finite"?Number.isFinite(t.data)||(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.not_finite,message:c.message}),o.dirty()):Ir.assertNever(c);return{status:o.value,value:t.data}}gte(t,i){return this.setLimit("min",t,!0,it.toString(i))}gt(t,i){return this.setLimit("min",t,!1,it.toString(i))}lte(t,i){return this.setLimit("max",t,!0,it.toString(i))}lt(t,i){return this.setLimit("max",t,!1,it.toString(i))}setLimit(t,i,s,o){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:i,inclusive:s,message:it.toString(o)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:it.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:it.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:it.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:it.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:it.toString(t)})}multipleOf(t,i){return this._addCheck({kind:"multipleOf",value:t,message:it.toString(i)})}finite(t){return this._addCheck({kind:"finite",message:it.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:it.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:it.toString(t)})}get minValue(){let t=null;for(let i of this._def.checks)i.kind==="min"&&(t===null||i.value>t)&&(t=i.value);return t}get maxValue(){let t=null;for(let i of this._def.checks)i.kind==="max"&&(t===null||i.value<t)&&(t=i.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ir.isInteger(t.value))}get isFinite(){let t=null,i=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(i===null||s.value>i)&&(i=s.value):s.kind==="max"&&(t===null||s.value<t)&&(t=s.value)}return Number.isFinite(i)&&Number.isFinite(t)}};DD.create=n=>new DD({checks:[],typeName:Ae.ZodNumber,coerce:n?.coerce||!1,...Zt(n)});var UD=class n extends lr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Ze.bigint)return this._getInvalidInput(t);let s,o=new os;for(let c of this._def.checks)c.kind==="min"?(c.inclusive?t.data<c.value:t.data<=c.value)&&(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.too_small,type:"bigint",minimum:c.value,inclusive:c.inclusive,message:c.message}),o.dirty()):c.kind==="max"?(c.inclusive?t.data>c.value:t.data>=c.value)&&(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.too_big,type:"bigint",maximum:c.value,inclusive:c.inclusive,message:c.message}),o.dirty()):c.kind==="multipleOf"?t.data%c.value!==BigInt(0)&&(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.not_multiple_of,multipleOf:c.value,message:c.message}),o.dirty()):Ir.assertNever(c);return{status:o.value,value:t.data}}_getInvalidInput(t){let i=this._getOrReturnCtx(t);return Ue(i,{code:Se.invalid_type,expected:Ze.bigint,received:i.parsedType}),Rt}gte(t,i){return this.setLimit("min",t,!0,it.toString(i))}gt(t,i){return this.setLimit("min",t,!1,it.toString(i))}lte(t,i){return this.setLimit("max",t,!0,it.toString(i))}lt(t,i){return this.setLimit("max",t,!1,it.toString(i))}setLimit(t,i,s,o){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:i,inclusive:s,message:it.toString(o)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:it.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:it.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:it.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:it.toString(t)})}multipleOf(t,i){return this._addCheck({kind:"multipleOf",value:t,message:it.toString(i)})}get minValue(){let t=null;for(let i of this._def.checks)i.kind==="min"&&(t===null||i.value>t)&&(t=i.value);return t}get maxValue(){let t=null;for(let i of this._def.checks)i.kind==="max"&&(t===null||i.value<t)&&(t=i.value);return t}};UD.create=n=>new UD({checks:[],typeName:Ae.ZodBigInt,coerce:n?.coerce??!1,...Zt(n)});var qD=class extends lr{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Ze.boolean){let s=this._getOrReturnCtx(t);return Ue(s,{code:Se.invalid_type,expected:Ze.boolean,received:s.parsedType}),Rt}return ws(t.data)}};qD.create=n=>new qD({typeName:Ae.ZodBoolean,coerce:n?.coerce||!1,...Zt(n)});var jD=class n extends lr{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Ze.date){let c=this._getOrReturnCtx(t);return Ue(c,{code:Se.invalid_type,expected:Ze.date,received:c.parsedType}),Rt}if(Number.isNaN(t.data.getTime())){let c=this._getOrReturnCtx(t);return Ue(c,{code:Se.invalid_date}),Rt}let s=new os,o;for(let c of this._def.checks)c.kind==="min"?t.data.getTime()<c.value&&(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.too_small,message:c.message,inclusive:!0,exact:!1,minimum:c.value,type:"date"}),s.dirty()):c.kind==="max"?t.data.getTime()>c.value&&(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.too_big,message:c.message,inclusive:!0,exact:!1,maximum:c.value,type:"date"}),s.dirty()):Ir.assertNever(c);return{status:s.value,value:new Date(t.data.getTime())}}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}min(t,i){return this._addCheck({kind:"min",value:t.getTime(),message:it.toString(i)})}max(t,i){return this._addCheck({kind:"max",value:t.getTime(),message:it.toString(i)})}get minDate(){let t=null;for(let i of this._def.checks)i.kind==="min"&&(t===null||i.value>t)&&(t=i.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let i of this._def.checks)i.kind==="max"&&(t===null||i.value<t)&&(t=i.value);return t!=null?new Date(t):null}};jD.create=n=>new jD({checks:[],coerce:n?.coerce||!1,typeName:Ae.ZodDate,...Zt(n)});var VD=class extends lr{_parse(t){if(this._getType(t)!==Ze.symbol){let s=this._getOrReturnCtx(t);return Ue(s,{code:Se.invalid_type,expected:Ze.symbol,received:s.parsedType}),Rt}return ws(t.data)}};VD.create=n=>new VD({typeName:Ae.ZodSymbol,...Zt(n)});var Q0=class extends lr{_parse(t){if(this._getType(t)!==Ze.undefined){let s=this._getOrReturnCtx(t);return Ue(s,{code:Se.invalid_type,expected:Ze.undefined,received:s.parsedType}),Rt}return ws(t.data)}};Q0.create=n=>new Q0({typeName:Ae.ZodUndefined,...Zt(n)});var eR=class extends lr{_parse(t){if(this._getType(t)!==Ze.null){let s=this._getOrReturnCtx(t);return Ue(s,{code:Se.invalid_type,expected:Ze.null,received:s.parsedType}),Rt}return ws(t.data)}};eR.create=n=>new eR({typeName:Ae.ZodNull,...Zt(n)});var BD=class extends lr{constructor(){super(...arguments),this._any=!0}_parse(t){return ws(t.data)}};BD.create=n=>new BD({typeName:Ae.ZodAny,...Zt(n)});var iv=class extends lr{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ws(t.data)}};iv.create=n=>new iv({typeName:Ae.ZodUnknown,...Zt(n)});var lh=class extends lr{_parse(t){let i=this._getOrReturnCtx(t);return Ue(i,{code:Se.invalid_type,expected:Ze.never,received:i.parsedType}),Rt}};lh.create=n=>new lh({typeName:Ae.ZodNever,...Zt(n)});var FD=class extends lr{_parse(t){if(this._getType(t)!==Ze.undefined){let s=this._getOrReturnCtx(t);return Ue(s,{code:Se.invalid_type,expected:Ze.void,received:s.parsedType}),Rt}return ws(t.data)}};FD.create=n=>new FD({typeName:Ae.ZodVoid,...Zt(n)});var ov=class n extends lr{_parse(t){let{ctx:i,status:s}=this._processInputParams(t),o=this._def;if(i.parsedType!==Ze.array)return Ue(i,{code:Se.invalid_type,expected:Ze.array,received:i.parsedType}),Rt;if(o.exactLength!==null){let r=i.data.length>o.exactLength.value,e=i.data.length<o.exactLength.value;(r||e)&&(Ue(i,{code:r?Se.too_big:Se.too_small,minimum:e?o.exactLength.value:void 0,maximum:r?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),s.dirty())}if(o.minLength!==null&&i.data.length<o.minLength.value&&(Ue(i,{code:Se.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),s.dirty()),o.maxLength!==null&&i.data.length>o.maxLength.value&&(Ue(i,{code:Se.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),s.dirty()),i.common.async)return Promise.all([...i.data].map((r,e)=>o.type._parseAsync(new $l(i,r,i.path,e)))).then(r=>os.mergeArray(s,r));let c=[...i.data].map((r,e)=>o.type._parseSync(new $l(i,r,i.path,e)));return os.mergeArray(s,c)}get element(){return this._def.type}min(t,i){return new n({...this._def,minLength:{value:t,message:it.toString(i)}})}max(t,i){return new n({...this._def,maxLength:{value:t,message:it.toString(i)}})}length(t,i){return new n({...this._def,exactLength:{value:t,message:it.toString(i)}})}nonempty(t){return this.min(1,t)}};ov.create=(n,t)=>new ov({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Ae.ZodArray,...Zt(t)});function Z0(n){if(n instanceof uu){let t={};for(let i in n.shape){let s=n.shape[i];t[i]=Gp.create(Z0(s))}return new uu({...n._def,shape:()=>t})}else return n instanceof ov?new ov({...n._def,type:Z0(n.element)}):n instanceof Gp?Gp.create(Z0(n.unwrap())):n instanceof Nm?Nm.create(Z0(n.unwrap())):n instanceof Rm?Rm.create(n.items.map(t=>Z0(t))):n}var uu=class n extends lr{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),i=Ir.objectKeys(t);return this._cached={shape:t,keys:i},this._cached}_parse(t){if(this._getType(t)!==Ze.object){let u=this._getOrReturnCtx(t);return Ue(u,{code:Se.invalid_type,expected:Ze.object,received:u.parsedType}),Rt}let{status:s,ctx:o}=this._processInputParams(t),{shape:c,keys:r}=this._getCached(),e=[];if(!(this._def.catchall instanceof lh&&this._def.unknownKeys==="strip"))for(let u in o.data)r.includes(u)||e.push(u);let a=[];for(let u of r){let l=c[u],p=o.data[u];a.push({key:{status:"valid",value:u},value:l._parse(new $l(o,p,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof lh){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of e)a.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")e.length>0&&(Ue(o,{code:Se.unrecognized_keys,keys:e}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of e){let p=o.data[l];a.push({key:{status:"valid",value:l},value:u._parse(new $l(o,p,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of a){let p=await l.key,d=await l.value;u.push({key:p,value:d,alwaysSet:l.alwaysSet})}return u}).then(u=>os.mergeObjectSync(s,u)):os.mergeObjectSync(s,a)}get shape(){return this._def.shape()}strict(t){return it.errToObj,new n({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(i,s)=>{let o=this._def.errorMap?.(i,s).message??s.defaultError;return i.code==="unrecognized_keys"?{message:it.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new n({...this._def,unknownKeys:"strip"})}passthrough(){return new n({...this._def,unknownKeys:"passthrough"})}extend(t){return new n({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new n({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ae.ZodObject})}setKey(t,i){return this.augment({[t]:i})}catchall(t){return new n({...this._def,catchall:t})}pick(t){let i={};for(let s of Ir.objectKeys(t))t[s]&&this.shape[s]&&(i[s]=this.shape[s]);return new n({...this._def,shape:()=>i})}omit(t){let i={};for(let s of Ir.objectKeys(this.shape))t[s]||(i[s]=this.shape[s]);return new n({...this._def,shape:()=>i})}deepPartial(){return Z0(this)}partial(t){let i={};for(let s of Ir.objectKeys(this.shape)){let o=this.shape[s];t&&!t[s]?i[s]=o:i[s]=o.optional()}return new n({...this._def,shape:()=>i})}required(t){let i={};for(let s of Ir.objectKeys(this.shape))if(t&&!t[s])i[s]=this.shape[s];else{let c=this.shape[s];for(;c instanceof Gp;)c=c._def.innerType;i[s]=c}return new n({...this._def,shape:()=>i})}keyof(){return nBt(Ir.objectKeys(this.shape))}};uu.create=(n,t)=>new uu({shape:()=>n,unknownKeys:"strip",catchall:lh.create(),typeName:Ae.ZodObject,...Zt(t)});uu.strictCreate=(n,t)=>new uu({shape:()=>n,unknownKeys:"strict",catchall:lh.create(),typeName:Ae.ZodObject,...Zt(t)});uu.lazycreate=(n,t)=>new uu({shape:n,unknownKeys:"strip",catchall:lh.create(),typeName:Ae.ZodObject,...Zt(t)});var tR=class extends lr{_parse(t){let{ctx:i}=this._processInputParams(t),s=this._def.options;function o(c){for(let e of c)if(e.result.status==="valid")return e.result;for(let e of c)if(e.result.status==="dirty")return i.common.issues.push(...e.ctx.common.issues),e.result;let r=c.map(e=>new cu(e.ctx.common.issues));return Ue(i,{code:Se.invalid_union,unionErrors:r}),Rt}if(i.common.async)return Promise.all(s.map(async c=>{let r={...i,common:{...i.common,issues:[]},parent:null};return{result:await c._parseAsync({data:i.data,path:i.path,parent:r}),ctx:r}})).then(o);{let c,r=[];for(let a of s){let u={...i,common:{...i.common,issues:[]},parent:null},l=a._parseSync({data:i.data,path:i.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!c&&(c={result:l,ctx:u}),u.common.issues.length&&r.push(u.common.issues)}if(c)return i.common.issues.push(...c.ctx.common.issues),c.result;let e=r.map(a=>new cu(a));return Ue(i,{code:Se.invalid_union,unionErrors:e}),Rt}}get options(){return this._def.options}};tR.create=(n,t)=>new tR({options:n,typeName:Ae.ZodUnion,...Zt(t)});var Pm=n=>n instanceof nR?Pm(n.schema):n instanceof Kp?Pm(n.innerType()):n instanceof iR?[n.value]:n instanceof oR?n.options:n instanceof aR?Ir.objectValues(n.enum):n instanceof sR?Pm(n._def.innerType):n instanceof Q0?[void 0]:n instanceof eR?[null]:n instanceof Gp?[void 0,...Pm(n.unwrap())]:n instanceof Nm?[null,...Pm(n.unwrap())]:n instanceof Gee||n instanceof uR?Pm(n.unwrap()):n instanceof cR?Pm(n._def.innerType):[],HCe=class n extends lr{_parse(t){let{ctx:i}=this._processInputParams(t);if(i.parsedType!==Ze.object)return Ue(i,{code:Se.invalid_type,expected:Ze.object,received:i.parsedType}),Rt;let s=this.discriminator,o=i.data[s],c=this.optionsMap.get(o);return c?i.common.async?c._parseAsync({data:i.data,path:i.path,parent:i}):c._parseSync({data:i.data,path:i.path,parent:i}):(Ue(i,{code:Se.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),Rt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,i,s){let o=new Map;for(let c of i){let r=Pm(c.shape[t]);if(!r.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let e of r){if(o.has(e))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(e)}`);o.set(e,c)}}return new n({typeName:Ae.ZodDiscriminatedUnion,discriminator:t,options:i,optionsMap:o,...Zt(s)})}};function GCe(n,t){let i=Am(n),s=Am(t);if(n===t)return{valid:!0,data:n};if(i===Ze.object&&s===Ze.object){let o=Ir.objectKeys(t),c=Ir.objectKeys(n).filter(e=>o.indexOf(e)!==-1),r={...n,...t};for(let e of c){let a=GCe(n[e],t[e]);if(!a.valid)return{valid:!1};r[e]=a.data}return{valid:!0,data:r}}else if(i===Ze.array&&s===Ze.array){if(n.length!==t.length)return{valid:!1};let o=[];for(let c=0;c<n.length;c++){let r=n[c],e=t[c],a=GCe(r,e);if(!a.valid)return{valid:!1};o.push(a.data)}return{valid:!0,data:o}}else return i===Ze.date&&s===Ze.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}var rR=class extends lr{_parse(t){let{status:i,ctx:s}=this._processInputParams(t),o=(c,r)=>{if(FCe(c)||FCe(r))return Rt;let e=GCe(c.value,r.value);return e.valid?(($Ce(c)||$Ce(r))&&i.dirty(),{status:i.value,value:e.data}):(Ue(s,{code:Se.invalid_intersection_types}),Rt)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([c,r])=>o(c,r)):o(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};rR.create=(n,t,i)=>new rR({left:n,right:t,typeName:Ae.ZodIntersection,...Zt(i)});var Rm=class n extends lr{_parse(t){let{status:i,ctx:s}=this._processInputParams(t);if(s.parsedType!==Ze.array)return Ue(s,{code:Se.invalid_type,expected:Ze.array,received:s.parsedType}),Rt;if(s.data.length<this._def.items.length)return Ue(s,{code:Se.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Rt;!this._def.rest&&s.data.length>this._def.items.length&&(Ue(s,{code:Se.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),i.dirty());let c=[...s.data].map((r,e)=>{let a=this._def.items[e]||this._def.rest;return a?a._parse(new $l(s,r,s.path,e)):null}).filter(r=>!!r);return s.common.async?Promise.all(c).then(r=>os.mergeArray(i,r)):os.mergeArray(i,c)}get items(){return this._def.items}rest(t){return new n({...this._def,rest:t})}};Rm.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Rm({items:n,typeName:Ae.ZodTuple,rest:null,...Zt(t)})};var KCe=class n extends lr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:i,ctx:s}=this._processInputParams(t);if(s.parsedType!==Ze.object)return Ue(s,{code:Se.invalid_type,expected:Ze.object,received:s.parsedType}),Rt;let o=[],c=this._def.keyType,r=this._def.valueType;for(let e in s.data)o.push({key:c._parse(new $l(s,e,s.path,e)),value:r._parse(new $l(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?os.mergeObjectAsync(i,o):os.mergeObjectSync(i,o)}get element(){return this._def.valueType}static create(t,i,s){return i instanceof lr?new n({keyType:t,valueType:i,typeName:Ae.ZodRecord,...Zt(s)}):new n({keyType:X0.create(),valueType:t,typeName:Ae.ZodRecord,...Zt(i)})}},$D=class extends lr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:i,ctx:s}=this._processInputParams(t);if(s.parsedType!==Ze.map)return Ue(s,{code:Se.invalid_type,expected:Ze.map,received:s.parsedType}),Rt;let o=this._def.keyType,c=this._def.valueType,r=[...s.data.entries()].map(([e,a],u)=>({key:o._parse(new $l(s,e,s.path,[u,"key"])),value:c._parse(new $l(s,a,s.path,[u,"value"]))}));if(s.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let a of r){let u=await a.key,l=await a.value;if(u.status==="aborted"||l.status==="aborted")return Rt;(u.status==="dirty"||l.status==="dirty")&&i.dirty(),e.set(u.value,l.value)}return{status:i.value,value:e}})}else{let e=new Map;for(let a of r){let u=a.key,l=a.value;if(u.status==="aborted"||l.status==="aborted")return Rt;(u.status==="dirty"||l.status==="dirty")&&i.dirty(),e.set(u.value,l.value)}return{status:i.value,value:e}}}};$D.create=(n,t,i)=>new $D({valueType:t,keyType:n,typeName:Ae.ZodMap,...Zt(i)});var zD=class n extends lr{_parse(t){let{status:i,ctx:s}=this._processInputParams(t);if(s.parsedType!==Ze.set)return Ue(s,{code:Se.invalid_type,expected:Ze.set,received:s.parsedType}),Rt;let o=this._def;o.minSize!==null&&s.data.size<o.minSize.value&&(Ue(s,{code:Se.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),i.dirty()),o.maxSize!==null&&s.data.size>o.maxSize.value&&(Ue(s,{code:Se.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),i.dirty());let c=this._def.valueType;function r(a){let u=new Set;for(let l of a){if(l.status==="aborted")return Rt;l.status==="dirty"&&i.dirty(),u.add(l.value)}return{status:i.value,value:u}}let e=[...s.data.values()].map((a,u)=>c._parse(new $l(s,a,s.path,u)));return s.common.async?Promise.all(e).then(a=>r(a)):r(e)}min(t,i){return new n({...this._def,minSize:{value:t,message:it.toString(i)}})}max(t,i){return new n({...this._def,maxSize:{value:t,message:it.toString(i)}})}size(t,i){return this.min(t,i).max(t,i)}nonempty(t){return this.min(1,t)}};zD.create=(n,t)=>new zD({valueType:n,minSize:null,maxSize:null,typeName:Ae.ZodSet,...Zt(t)});var YCe=class n extends lr{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:i}=this._processInputParams(t);if(i.parsedType!==Ze.function)return Ue(i,{code:Se.invalid_type,expected:Ze.function,received:i.parsedType}),Rt;function s(e,a){return Hee({data:e,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,LD(),nv].filter(u=>!!u),issueData:{code:Se.invalid_arguments,argumentsError:a}})}function o(e,a){return Hee({data:e,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,LD(),nv].filter(u=>!!u),issueData:{code:Se.invalid_return_type,returnTypeError:a}})}let c={errorMap:i.common.contextualErrorMap},r=i.data;if(this._def.returns instanceof DT){let e=this;return ws(async function(...a){let u=new cu([]),l=await e._def.args.parseAsync(a,c).catch(h=>{throw u.addIssue(s(a,h)),u}),p=await Reflect.apply(r,this,l);return await e._def.returns._def.type.parseAsync(p,c).catch(h=>{throw u.addIssue(o(p,h)),u})})}else{let e=this;return ws(function(...a){let u=e._def.args.safeParse(a,c);if(!u.success)throw new cu([s(a,u.error)]);let l=Reflect.apply(r,this,u.data),p=e._def.returns.safeParse(l,c);if(!p.success)throw new cu([o(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new n({...this._def,args:Rm.create(t).rest(iv.create())})}returns(t){return new n({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,i,s){return new n({args:t||Rm.create([]).rest(iv.create()),returns:i||iv.create(),typeName:Ae.ZodFunction,...Zt(s)})}},nR=class extends lr{get schema(){return this._def.getter()}_parse(t){let{ctx:i}=this._processInputParams(t);return this._def.getter()._parse({data:i.data,path:i.path,parent:i})}};nR.create=(n,t)=>new nR({getter:n,typeName:Ae.ZodLazy,...Zt(t)});var iR=class extends lr{_parse(t){if(t.data!==this._def.value){let i=this._getOrReturnCtx(t);return Ue(i,{received:i.data,code:Se.invalid_literal,expected:this._def.value}),Rt}return{status:"valid",value:t.data}}get value(){return this._def.value}};iR.create=(n,t)=>new iR({value:n,typeName:Ae.ZodLiteral,...Zt(t)});function nBt(n,t){return new oR({values:n,typeName:Ae.ZodEnum,...Zt(t)})}var oR=class n extends lr{_parse(t){if(typeof t.data!="string"){let i=this._getOrReturnCtx(t),s=this._def.values;return Ue(i,{expected:Ir.joinValues(s),received:i.parsedType,code:Se.invalid_type}),Rt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let i=this._getOrReturnCtx(t),s=this._def.values;return Ue(i,{received:i.data,code:Se.invalid_enum_value,options:s}),Rt}return ws(t.data)}get options(){return this._def.values}get enum(){let t={};for(let i of this._def.values)t[i]=i;return t}get Values(){let t={};for(let i of this._def.values)t[i]=i;return t}get Enum(){let t={};for(let i of this._def.values)t[i]=i;return t}extract(t,i=this._def){return n.create(t,{...this._def,...i})}exclude(t,i=this._def){return n.create(this.options.filter(s=>!t.includes(s)),{...this._def,...i})}};oR.create=nBt;var aR=class extends lr{_parse(t){let i=Ir.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(t);if(s.parsedType!==Ze.string&&s.parsedType!==Ze.number){let o=Ir.objectValues(i);return Ue(s,{expected:Ir.joinValues(o),received:s.parsedType,code:Se.invalid_type}),Rt}if(this._cache||(this._cache=new Set(Ir.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let o=Ir.objectValues(i);return Ue(s,{received:s.data,code:Se.invalid_enum_value,options:o}),Rt}return ws(t.data)}get enum(){return this._def.values}};aR.create=(n,t)=>new aR({values:n,typeName:Ae.ZodNativeEnum,...Zt(t)});var DT=class extends lr{unwrap(){return this._def.type}_parse(t){let{ctx:i}=this._processInputParams(t);if(i.parsedType!==Ze.promise&&i.common.async===!1)return Ue(i,{code:Se.invalid_type,expected:Ze.promise,received:i.parsedType}),Rt;let s=i.parsedType===Ze.promise?i.data:Promise.resolve(i.data);return ws(s.then(o=>this._def.type.parseAsync(o,{path:i.path,errorMap:i.common.contextualErrorMap})))}};DT.create=(n,t)=>new DT({type:n,typeName:Ae.ZodPromise,...Zt(t)});var Kp=class extends lr{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ae.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:i,ctx:s}=this._processInputParams(t),o=this._def.effect||null,c={addIssue:r=>{Ue(s,r),r.fatal?i.abort():i.dirty()},get path(){return s.path}};if(c.addIssue=c.addIssue.bind(c),o.type==="preprocess"){let r=o.transform(s.data,c);if(s.common.async)return Promise.resolve(r).then(async e=>{if(i.value==="aborted")return Rt;let a=await this._def.schema._parseAsync({data:e,path:s.path,parent:s});return a.status==="aborted"?Rt:a.status==="dirty"?J0(a.value):i.value==="dirty"?J0(a.value):a});{if(i.value==="aborted")return Rt;let e=this._def.schema._parseSync({data:r,path:s.path,parent:s});return e.status==="aborted"?Rt:e.status==="dirty"?J0(e.value):i.value==="dirty"?J0(e.value):e}}if(o.type==="refinement"){let r=e=>{let a=o.refinement(e,c);if(s.common.async)return Promise.resolve(a);if(a instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(s.common.async===!1){let e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return e.status==="aborted"?Rt:(e.status==="dirty"&&i.dirty(),r(e.value),{status:i.value,value:e.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(e=>e.status==="aborted"?Rt:(e.status==="dirty"&&i.dirty(),r(e.value).then(()=>({status:i.value,value:e.value}))))}if(o.type==="transform")if(s.common.async===!1){let r=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!kT(r))return Rt;let e=o.transform(r.value,c);if(e instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:i.value,value:e}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(r=>kT(r)?Promise.resolve(o.transform(r.value,c)).then(e=>({status:i.value,value:e})):Rt);Ir.assertNever(o)}};Kp.create=(n,t,i)=>new Kp({schema:n,typeName:Ae.ZodEffects,effect:t,...Zt(i)});Kp.createWithPreprocess=(n,t,i)=>new Kp({schema:t,effect:{type:"preprocess",transform:n},typeName:Ae.ZodEffects,...Zt(i)});var Gp=class extends lr{_parse(t){return this._getType(t)===Ze.undefined?ws(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Gp.create=(n,t)=>new Gp({innerType:n,typeName:Ae.ZodOptional,...Zt(t)});var Nm=class extends lr{_parse(t){return this._getType(t)===Ze.null?ws(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Nm.create=(n,t)=>new Nm({innerType:n,typeName:Ae.ZodNullable,...Zt(t)});var sR=class extends lr{_parse(t){let{ctx:i}=this._processInputParams(t),s=i.data;return i.parsedType===Ze.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:i.path,parent:i})}removeDefault(){return this._def.innerType}};sR.create=(n,t)=>new sR({innerType:n,typeName:Ae.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Zt(t)});var cR=class extends lr{_parse(t){let{ctx:i}=this._processInputParams(t),s={...i,common:{...i.common,issues:[]}},o=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return kD(o)?o.then(c=>({status:"valid",value:c.status==="valid"?c.value:this._def.catchValue({get error(){return new cu(s.common.issues)},input:s.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new cu(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};cR.create=(n,t)=>new cR({innerType:n,typeName:Ae.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Zt(t)});var HD=class extends lr{_parse(t){if(this._getType(t)!==Ze.nan){let s=this._getOrReturnCtx(t);return Ue(s,{code:Se.invalid_type,expected:Ze.nan,received:s.parsedType}),Rt}return{status:"valid",value:t.data}}};HD.create=n=>new HD({typeName:Ae.ZodNaN,...Zt(n)});var tfi=Symbol("zod_brand"),Gee=class extends lr{_parse(t){let{ctx:i}=this._processInputParams(t),s=i.data;return this._def.type._parse({data:s,path:i.path,parent:i})}unwrap(){return this._def.type}},Kee=class n extends lr{_parse(t){let{status:i,ctx:s}=this._processInputParams(t);if(s.common.async)return(async()=>{let c=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return c.status==="aborted"?Rt:c.status==="dirty"?(i.dirty(),J0(c.value)):this._def.out._parseAsync({data:c.value,path:s.path,parent:s})})();{let o=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?Rt:o.status==="dirty"?(i.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:s.path,parent:s})}}static create(t,i){return new n({in:t,out:i,typeName:Ae.ZodPipeline})}},uR=class extends lr{_parse(t){let i=this._def.innerType._parse(t),s=o=>(kT(o)&&(o.value=Object.freeze(o.value)),o);return kD(i)?i.then(o=>s(o)):s(i)}unwrap(){return this._def.innerType}};uR.create=(n,t)=>new uR({innerType:n,typeName:Ae.ZodReadonly,...Zt(t)});var rfi={object:uu.lazycreate},Ae;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(Ae||(Ae={}));var nfi=X0.create,ifi=DD.create,ofi=HD.create,afi=UD.create,sfi=qD.create,cfi=jD.create,ufi=VD.create,lfi=Q0.create,pfi=eR.create,dfi=BD.create,ffi=iv.create,hfi=lh.create,mfi=FD.create,yfi=ov.create,iBt=uu.create,gfi=uu.strictCreate,vfi=tR.create,_fi=HCe.create,bfi=rR.create,Tfi=Rm.create,Sfi=KCe.create,Efi=$D.create,Ofi=zD.create,xfi=YCe.create,Afi=nR.create,Pfi=iR.create,Rfi=oR.create,Nfi=aR.create,Ifi=DT.create,wfi=Kp.create,Cfi=Gp.create,Mfi=Nm.create,Lfi=Kp.createWithPreprocess,kfi=Kee.create;var pu={};fn(pu,{$ZodAny:()=>Kte,$ZodArray:()=>Xte,$ZodAsyncError:()=>Yp,$ZodBase64:()=>Ute,$ZodBase64URL:()=>qte,$ZodBigInt:()=>oU,$ZodBigIntFormat:()=>$te,$ZodBoolean:()=>bR,$ZodCIDRv4:()=>kte,$ZodCIDRv6:()=>Dte,$ZodCUID:()=>Ete,$ZodCUID2:()=>Ote,$ZodCatch:()=>yre,$ZodCheck:()=>Tn,$ZodCheckBigIntFormat:()=>L1e,$ZodCheckEndsWith:()=>G1e,$ZodCheckGreaterThan:()=>pte,$ZodCheckIncludes:()=>z1e,$ZodCheckLengthEquals:()=>V1e,$ZodCheckLessThan:()=>lte,$ZodCheckLowerCase:()=>F1e,$ZodCheckMaxLength:()=>q1e,$ZodCheckMaxSize:()=>k1e,$ZodCheckMimeType:()=>Y1e,$ZodCheckMinLength:()=>j1e,$ZodCheckMinSize:()=>D1e,$ZodCheckMultipleOf:()=>C1e,$ZodCheckNumberFormat:()=>M1e,$ZodCheckOverwrite:()=>W1e,$ZodCheckProperty:()=>K1e,$ZodCheckRegex:()=>B1e,$ZodCheckSizeEquals:()=>U1e,$ZodCheckStartsWith:()=>H1e,$ZodCheckStringFormat:()=>_R,$ZodCheckUpperCase:()=>$1e,$ZodCodec:()=>SR,$ZodCustom:()=>Ore,$ZodCustomStringFormat:()=>Bte,$ZodDate:()=>Zte,$ZodDefault:()=>dre,$ZodDiscriminatedUnion:()=>tre,$ZodE164:()=>jte,$ZodEmail:()=>_te,$ZodEmoji:()=>Tte,$ZodEncodeError:()=>av,$ZodEnum:()=>are,$ZodError:()=>eU,$ZodExactOptional:()=>lre,$ZodFile:()=>cre,$ZodFunction:()=>Tre,$ZodGUID:()=>gte,$ZodIPv4:()=>Cte,$ZodIPv6:()=>Mte,$ZodISODate:()=>Nte,$ZodISODateTime:()=>Rte,$ZodISODuration:()=>wte,$ZodISOTime:()=>Ite,$ZodIntersection:()=>rre,$ZodJWT:()=>Vte,$ZodKSUID:()=>Pte,$ZodLazy:()=>Ere,$ZodLiteral:()=>sre,$ZodMAC:()=>Lte,$ZodMap:()=>ire,$ZodNaN:()=>gre,$ZodNanoID:()=>Ste,$ZodNever:()=>Wte,$ZodNonOptional:()=>hre,$ZodNull:()=>Gte,$ZodNullable:()=>pre,$ZodNumber:()=>iU,$ZodNumberFormat:()=>Fte,$ZodObject:()=>Qte,$ZodObjectJIT:()=>Q1e,$ZodOptional:()=>sU,$ZodPipe:()=>vre,$ZodPrefault:()=>fre,$ZodPromise:()=>Sre,$ZodReadonly:()=>_re,$ZodRealError:()=>Nc,$ZodRecord:()=>nre,$ZodRegistry:()=>Rre,$ZodSet:()=>ore,$ZodString:()=>fv,$ZodStringFormat:()=>pn,$ZodSuccess:()=>mre,$ZodSymbol:()=>zte,$ZodTemplateLiteral:()=>bre,$ZodTransform:()=>ure,$ZodTuple:()=>aU,$ZodType:()=>It,$ZodULID:()=>xte,$ZodURL:()=>bte,$ZodUUID:()=>vte,$ZodUndefined:()=>Hte,$ZodUnion:()=>TR,$ZodUnknown:()=>Yte,$ZodVoid:()=>Jte,$ZodXID:()=>Ate,$ZodXor:()=>ere,$brand:()=>KD,$constructor:()=>$,$input:()=>Ire,$output:()=>Nre,Doc:()=>nU,JSONSchema:()=>$Ft,JSONSchemaGenerator:()=>vne,NEVER:()=>Yee,TimePrecision:()=>Lre,_any:()=>tne,_array:()=>eMe,_base64:()=>AU,_base64url:()=>PU,_bigint:()=>Yre,_boolean:()=>Gre,_catch:()=>ERn,_check:()=>FFt,_cidrv4:()=>OU,_cidrv6:()=>xU,_coercedBigint:()=>Wre,_coercedBoolean:()=>Kre,_coercedDate:()=>ane,_coercedNumber:()=>Vre,_coercedString:()=>Cre,_cuid:()=>gU,_cuid2:()=>vU,_custom:()=>une,_date:()=>one,_decode:()=>tte,_decodeAsync:()=>nte,_default:()=>bRn,_discriminatedUnion:()=>cRn,_e164:()=>RU,_email:()=>lU,_emoji:()=>mU,_encode:()=>ete,_encodeAsync:()=>rte,_endsWith:()=>GT,_enum:()=>hRn,_file:()=>cne,_float32:()=>Fre,_float64:()=>$re,_gt:()=>Jp,_gte:()=>ya,_guid:()=>xR,_includes:()=>zT,_int:()=>Bre,_int32:()=>zre,_int64:()=>Jre,_intersection:()=>uRn,_ipv4:()=>SU,_ipv6:()=>EU,_isoDate:()=>Dre,_isoDateTime:()=>kre,_isoDuration:()=>qre,_isoTime:()=>Ure,_jwt:()=>NU,_ksuid:()=>TU,_lazy:()=>PRn,_length:()=>yv,_literal:()=>yRn,_lowercase:()=>FT,_lt:()=>Wp,_lte:()=>Cs,_mac:()=>Mre,_map:()=>dRn,_max:()=>Cs,_maxLength:()=>mv,_maxSize:()=>Cm,_mime:()=>KT,_min:()=>ya,_minLength:()=>ph,_minSize:()=>Zp,_multipleOf:()=>wm,_nan:()=>sne,_nanoid:()=>yU,_nativeEnum:()=>mRn,_negative:()=>wU,_never:()=>nne,_nonnegative:()=>MU,_nonoptional:()=>TRn,_nonpositive:()=>CU,_normalize:()=>YT,_null:()=>ene,_nullable:()=>_Rn,_number:()=>jre,_optional:()=>vRn,_overwrite:()=>Hl,_parse:()=>mR,_parseAsync:()=>yR,_pipe:()=>ORn,_positive:()=>IU,_promise:()=>RRn,_property:()=>LU,_readonly:()=>xRn,_record:()=>pRn,_refine:()=>lne,_regex:()=>BT,_safeDecode:()=>ote,_safeDecodeAsync:()=>ste,_safeEncode:()=>ite,_safeEncodeAsync:()=>ate,_safeParse:()=>gR,_safeParseAsync:()=>vR,_set:()=>fRn,_size:()=>hv,_slugify:()=>PR,_startsWith:()=>HT,_string:()=>wre,_stringFormat:()=>XT,_stringbool:()=>hne,_success:()=>SRn,_superRefine:()=>pne,_symbol:()=>Xre,_templateLiteral:()=>ARn,_toLowerCase:()=>JT,_toUpperCase:()=>ZT,_transform:()=>gRn,_trim:()=>WT,_tuple:()=>lRn,_uint32:()=>Hre,_uint64:()=>Zre,_ulid:()=>_U,_undefined:()=>Qre,_union:()=>aRn,_unknown:()=>rne,_uppercase:()=>$T,_url:()=>AR,_uuid:()=>pU,_uuidv4:()=>dU,_uuidv6:()=>fU,_uuidv7:()=>hU,_void:()=>ine,_xid:()=>bU,_xor:()=>sRn,clone:()=>Xo,config:()=>Ti,createStandardJSONSchemaMethod:()=>RR,createToJSONSchemaMethod:()=>tMe,decode:()=>gBt,decodeAsync:()=>_Bt,describe:()=>dne,encode:()=>yBt,encodeAsync:()=>vBt,extractDefs:()=>vv,finalize:()=>_v,flattenError:()=>fR,formatError:()=>hR,globalConfig:()=>GD,globalRegistry:()=>Qo,initializeContext:()=>gv,isValidBase64:()=>X1e,isValidBase64URL:()=>BBt,isValidJWT:()=>FBt,locales:()=>OR,meta:()=>fne,parse:()=>qT,parseAsync:()=>jT,prettifyError:()=>Qee,process:()=>sn,regexes:()=>Ic,registry:()=>uU,safeDecode:()=>TBt,safeDecodeAsync:()=>EBt,safeEncode:()=>bBt,safeEncodeAsync:()=>SBt,safeParse:()=>pv,safeParseAsync:()=>dv,toDotPath:()=>mBt,toJSONSchema:()=>QT,treeifyError:()=>Xee,util:()=>Ee,version:()=>J1e});var Yee=Object.freeze({status:"aborted"});function $(n,t,i){function s(e,a){if(e._zod||Object.defineProperty(e,"_zod",{value:{def:a,constr:r,traits:new Set},enumerable:!1}),e._zod.traits.has(n))return;e._zod.traits.add(n),t(e,a);let u=r.prototype,l=Object.keys(u);for(let p=0;p<l.length;p++){let d=l[p];d in e||(e[d]=u[d].bind(e))}}let o=i?.Parent??Object;class c extends o{}Object.defineProperty(c,"name",{value:n});function r(e){var a;let u=i?.Parent?new c:this;s(u,e),(a=u._zod).deferred??(a.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(r,"init",{value:s}),Object.defineProperty(r,Symbol.hasInstance,{value:e=>i?.Parent&&e instanceof i.Parent?!0:e?._zod?.traits?.has(n)}),Object.defineProperty(r,"name",{value:n}),r}var KD=Symbol("zod_brand"),Yp=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},av=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},GD={};function Ti(n){return n&&Object.assign(GD,n),GD}var Ee={};fn(Ee,{BIGINT_FORMAT_RANGES:()=>n1e,Class:()=>JCe,NUMBER_FORMAT_RANGES:()=>r1e,aborted:()=>lv,allowsEval:()=>QCe,assert:()=>SPn,assertEqual:()=>vPn,assertIs:()=>bPn,assertNever:()=>TPn,assertNotEqual:()=>_Pn,assignProp:()=>cv,base64ToUint8Array:()=>dBt,base64urlToUint8Array:()=>MPn,cached:()=>pR,captureStackTrace:()=>Jee,cleanEnum:()=>CPn,cleanRegex:()=>JD,clone:()=>Xo,cloneDef:()=>OPn,createTransparentProxy:()=>IPn,defineLazy:()=>Xt,esc:()=>Wee,escapeRegex:()=>zl,extend:()=>cBt,finalizeIssue:()=>Rc,floatSafeRemainder:()=>ZCe,getElementAtPath:()=>xPn,getEnumValues:()=>WD,getLengthableOrigin:()=>QD,getParsedType:()=>NPn,getSizableOrigin:()=>XD,hexToUint8Array:()=>kPn,isObject:()=>UT,isPlainObject:()=>uv,issue:()=>dR,joinValues:()=>te,jsonStringifyReplacer:()=>lR,merge:()=>wPn,mergeDefs:()=>Im,normalizeParams:()=>Pe,nullish:()=>sv,numKeys:()=>RPn,objectClone:()=>EPn,omit:()=>sBt,optionalKeys:()=>t1e,parsedType:()=>Oe,partial:()=>lBt,pick:()=>aBt,prefixIssues:()=>lu,primitiveTypes:()=>e1e,promiseAllObject:()=>APn,propertyKeyTypes:()=>ZD,randomString:()=>PPn,required:()=>pBt,safeExtend:()=>uBt,shallowClone:()=>Zee,slugify:()=>XCe,stringifyPrimitive:()=>Te,uint8ArrayToBase64:()=>fBt,uint8ArrayToBase64url:()=>LPn,uint8ArrayToHex:()=>DPn,unwrapMessage:()=>YD});function vPn(n){return n}function _Pn(n){return n}function bPn(n){}function TPn(n){throw new Error("Unexpected value in exhaustive check")}function SPn(n){}function WD(n){let t=Object.values(n).filter(s=>typeof s=="number");return Object.entries(n).filter(([s,o])=>t.indexOf(+s)===-1).map(([s,o])=>o)}function te(n,t="|"){return n.map(i=>Te(i)).join(t)}function lR(n,t){return typeof t=="bigint"?t.toString():t}function pR(n){return{get value(){{let i=n();return Object.defineProperty(this,"value",{value:i}),i}throw new Error("cached value already set")}}}function sv(n){return n==null}function JD(n){let t=n.startsWith("^")?1:0,i=n.endsWith("$")?n.length-1:n.length;return n.slice(t,i)}function ZCe(n,t){let i=(n.toString().split(".")[1]||"").length,s=t.toString(),o=(s.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(s)){let a=s.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}let c=i>o?i:o,r=Number.parseInt(n.toFixed(c).replace(".","")),e=Number.parseInt(t.toFixed(c).replace(".",""));return r%e/10**c}var oBt=Symbol("evaluating");function Xt(n,t,i){let s;Object.defineProperty(n,t,{get(){if(s!==oBt)return s===void 0&&(s=oBt,s=i()),s},set(o){Object.defineProperty(n,t,{value:o})},configurable:!0})}function EPn(n){return Object.create(Object.getPrototypeOf(n),Object.getOwnPropertyDescriptors(n))}function cv(n,t,i){Object.defineProperty(n,t,{value:i,writable:!0,enumerable:!0,configurable:!0})}function Im(...n){let t={};for(let i of n){let s=Object.getOwnPropertyDescriptors(i);Object.assign(t,s)}return Object.defineProperties({},t)}function OPn(n){return Im(n._zod.def)}function xPn(n,t){return t?t.reduce((i,s)=>i?.[s],n):n}function APn(n){let t=Object.keys(n),i=t.map(s=>n[s]);return Promise.all(i).then(s=>{let o={};for(let c=0;c<t.length;c++)o[t[c]]=s[c];return o})}function PPn(n=10){let t="abcdefghijklmnopqrstuvwxyz",i="";for(let s=0;s<n;s++)i+=t[Math.floor(Math.random()*t.length)];return i}function Wee(n){return JSON.stringify(n)}function XCe(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Jee="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function UT(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var QCe=pR(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});function uv(n){if(UT(n)===!1)return!1;let t=n.constructor;if(t===void 0||typeof t!="function")return!0;let i=t.prototype;return!(UT(i)===!1||Object.prototype.hasOwnProperty.call(i,"isPrototypeOf")===!1)}function Zee(n){return uv(n)?{...n}:Array.isArray(n)?[...n]:n}function RPn(n){let t=0;for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&t++;return t}var NPn=n=>{let t=typeof n;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(n)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(n)?"array":n===null?"null":n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?"promise":typeof Map<"u"&&n instanceof Map?"map":typeof Set<"u"&&n instanceof Set?"set":typeof Date<"u"&&n instanceof Date?"date":typeof File<"u"&&n instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},ZD=new Set(["string","number","symbol"]),e1e=new Set(["string","number","bigint","boolean","symbol","undefined"]);function zl(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xo(n,t,i){let s=new n._zod.constr(t??n._zod.def);return(!t||i?.parent)&&(s._zod.parent=n),s}function Pe(n){let t=n;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function IPn(n){let t;return new Proxy({},{get(i,s,o){return t??(t=n()),Reflect.get(t,s,o)},set(i,s,o,c){return t??(t=n()),Reflect.set(t,s,o,c)},has(i,s){return t??(t=n()),Reflect.has(t,s)},deleteProperty(i,s){return t??(t=n()),Reflect.deleteProperty(t,s)},ownKeys(i){return t??(t=n()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(i,s){return t??(t=n()),Reflect.getOwnPropertyDescriptor(t,s)},defineProperty(i,s,o){return t??(t=n()),Reflect.defineProperty(t,s,o)}})}function Te(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function t1e(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}var r1e={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},n1e={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function aBt(n,t){let i=n._zod.def,s=i.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let c=Im(n._zod.def,{get shape(){let r={};for(let e in t){if(!(e in i.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&(r[e]=i.shape[e])}return cv(this,"shape",r),r},checks:[]});return Xo(n,c)}function sBt(n,t){let i=n._zod.def,s=i.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let c=Im(n._zod.def,{get shape(){let r={...n._zod.def.shape};for(let e in t){if(!(e in i.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return cv(this,"shape",r),r},checks:[]});return Xo(n,c)}function cBt(n,t){if(!uv(t))throw new Error("Invalid input to extend: expected a plain object");let i=n._zod.def.checks;if(i&&i.length>0){let c=n._zod.def.shape;for(let r in t)if(Object.getOwnPropertyDescriptor(c,r)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=Im(n._zod.def,{get shape(){let c={...n._zod.def.shape,...t};return cv(this,"shape",c),c}});return Xo(n,o)}function uBt(n,t){if(!uv(t))throw new Error("Invalid input to safeExtend: expected a plain object");let i=Im(n._zod.def,{get shape(){let s={...n._zod.def.shape,...t};return cv(this,"shape",s),s}});return Xo(n,i)}function wPn(n,t){let i=Im(n._zod.def,{get shape(){let s={...n._zod.def.shape,...t._zod.def.shape};return cv(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:[]});return Xo(n,i)}function lBt(n,t,i){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let r=Im(t._zod.def,{get shape(){let e=t._zod.def.shape,a={...e};if(i)for(let u in i){if(!(u in e))throw new Error(`Unrecognized key: "${u}"`);i[u]&&(a[u]=n?new n({type:"optional",innerType:e[u]}):e[u])}else for(let u in e)a[u]=n?new n({type:"optional",innerType:e[u]}):e[u];return cv(this,"shape",a),a},checks:[]});return Xo(t,r)}function pBt(n,t,i){let s=Im(t._zod.def,{get shape(){let o=t._zod.def.shape,c={...o};if(i)for(let r in i){if(!(r in c))throw new Error(`Unrecognized key: "${r}"`);i[r]&&(c[r]=new n({type:"nonoptional",innerType:o[r]}))}else for(let r in o)c[r]=new n({type:"nonoptional",innerType:o[r]});return cv(this,"shape",c),c}});return Xo(t,s)}function lv(n,t=0){if(n.aborted===!0)return!0;for(let i=t;i<n.issues.length;i++)if(n.issues[i]?.continue!==!0)return!0;return!1}function lu(n,t){return t.map(i=>{var s;return(s=i).path??(s.path=[]),i.path.unshift(n),i})}function YD(n){return typeof n=="string"?n:n?.message}function Rc(n,t,i){let s={...n,path:n.path??[]};if(!n.message){let o=YD(n.inst?._zod.def?.error?.(n))??YD(t?.error?.(n))??YD(i.customError?.(n))??YD(i.localeError?.(n))??"Invalid input";s.message=o}return delete s.inst,delete s.continue,t?.reportInput||delete s.input,s}function XD(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function QD(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Oe(n){let t=typeof n;switch(t){case"number":return Number.isNaN(n)?"nan":"number";case"object":{if(n===null)return"null";if(Array.isArray(n))return"array";let i=n;if(i&&Object.getPrototypeOf(i)!==Object.prototype&&"constructor"in i&&i.constructor)return i.constructor.name}}return t}function dR(...n){let[t,i,s]=n;return typeof t=="string"?{message:t,code:"custom",input:i,inst:s}:{...t}}function CPn(n){return Object.entries(n).filter(([t,i])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function dBt(n){let t=atob(n),i=new Uint8Array(t.length);for(let s=0;s<t.length;s++)i[s]=t.charCodeAt(s);return i}function fBt(n){let t="";for(let i=0;i<n.length;i++)t+=String.fromCharCode(n[i]);return btoa(t)}function MPn(n){let t=n.replace(/-/g,"+").replace(/_/g,"/"),i="=".repeat((4-t.length%4)%4);return dBt(t+i)}function LPn(n){return fBt(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function kPn(n){let t=n.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let i=new Uint8Array(t.length/2);for(let s=0;s<t.length;s+=2)i[s/2]=Number.parseInt(t.slice(s,s+2),16);return i}function DPn(n){return Array.from(n).map(t=>t.toString(16).padStart(2,"0")).join("")}var JCe=class{constructor(...t){}};var hBt=(n,t)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:t,enumerable:!1}),n.message=JSON.stringify(t,lR,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},eU=$("$ZodError",hBt),Nc=$("$ZodError",hBt,{Parent:Error});function fR(n,t=i=>i.message){let i={},s=[];for(let o of n.issues)o.path.length>0?(i[o.path[0]]=i[o.path[0]]||[],i[o.path[0]].push(t(o))):s.push(t(o));return{formErrors:s,fieldErrors:i}}function hR(n,t=i=>i.message){let i={_errors:[]},s=o=>{for(let c of o.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(r=>s({issues:r}));else if(c.code==="invalid_key")s({issues:c.issues});else if(c.code==="invalid_element")s({issues:c.issues});else if(c.path.length===0)i._errors.push(t(c));else{let r=i,e=0;for(;e<c.path.length;){let a=c.path[e];e===c.path.length-1?(r[a]=r[a]||{_errors:[]},r[a]._errors.push(t(c))):r[a]=r[a]||{_errors:[]},r=r[a],e++}}};return s(n),i}function Xee(n,t=i=>i.message){let i={errors:[]},s=(o,c=[])=>{var r,e;for(let a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(u=>s({issues:u},a.path));else if(a.code==="invalid_key")s({issues:a.issues},a.path);else if(a.code==="invalid_element")s({issues:a.issues},a.path);else{let u=[...c,...a.path];if(u.length===0){i.errors.push(t(a));continue}let l=i,p=0;for(;p<u.length;){let d=u[p],h=p===u.length-1;typeof d=="string"?(l.properties??(l.properties={}),(r=l.properties)[d]??(r[d]={errors:[]}),l=l.properties[d]):(l.items??(l.items=[]),(e=l.items)[d]??(e[d]={errors:[]}),l=l.items[d]),h&&l.errors.push(t(a)),p++}}};return s(n),i}function mBt(n){let t=[],i=n.map(s=>typeof s=="object"?s.key:s);for(let s of i)typeof s=="number"?t.push(`[${s}]`):typeof s=="symbol"?t.push(`[${JSON.stringify(String(s))}]`):/[^\w$]/.test(s)?t.push(`[${JSON.stringify(s)}]`):(t.length&&t.push("."),t.push(s));return t.join("")}function Qee(n){let t=[],i=[...n.issues].sort((s,o)=>(s.path??[]).length-(o.path??[]).length);for(let s of i)t.push(`\u2716 ${s.message}`),s.path?.length&&t.push(` \u2192 at ${mBt(s.path)}`);return t.join(`
254
+ `),null;i||(console.error(`\u{1F4C4} Loading config from: ${s}`),console.error(`[Config] BCTB_WORKSPACE_PATH env var = ${process.env.BCTB_WORKSPACE_PATH||"(not set)"}`));let c=Eh.readFileSync(s,"utf-8"),r=JSON.parse(c);if(r.profiles){let a=t||process.env.BCTB_PROFILE||r.defaultProfile;if(!a)throw new Error("No profile specified. Use --profile <name> or set BCTB_PROFILE env var");if(!r.profiles[a])throw new Error(`Profile '${a}' not found in config`);console.error(`\u{1F4CB} Using profile: "${a}"`);let u=I4e(r.profiles,a),l={...u,cacheEnabled:u.cacheEnabled??r.cache?.enabled??!0,cacheTTLSeconds:u.cacheTTLSeconds??r.cache?.ttlSeconds??3600,removePII:u.removePII??r.sanitize?.removePII??!1,references:u.references??r.references??[],port:u.port??52345,workspacePath:u.workspacePath??process.env.BCTB_WORKSPACE_PATH??process.cwd(),queriesFolder:u.queriesFolder??"queries",connectionName:u.connectionName??"Default",tenantId:u.tenantId??"",authFlow:u.authFlow??"azure_cli",applicationInsightsAppId:u.applicationInsightsAppId??"",kustoClusterUrl:u.kustoClusterUrl??"",configFilePath:s};return rj(l)}let e={connectionName:r.connectionName??"Default",tenantId:r.tenantId??"",clientId:r.clientId,clientSecret:r.clientSecret,authFlow:r.authFlow??"azure_cli",applicationInsightsAppId:r.applicationInsightsAppId??"",kustoClusterUrl:r.kustoClusterUrl??"",cacheEnabled:r.cacheEnabled??!0,cacheTTLSeconds:r.cacheTTLSeconds??3600,removePII:r.removePII??!1,port:r.port??52345,workspacePath:r.workspacePath??process.env.BCTB_WORKSPACE_PATH??process.cwd(),queriesFolder:r.queriesFolder??"queries",references:r.references??[],configFilePath:s};return rj(e)}function I4e(n,t,i=new Set){if(i.has(t))throw new Error(`Circular profile inheritance detected: ${t}`);i.add(t);let s=n[t];if(!s)throw new Error(`Profile '${t}' not found`);if(!s.extends)return s;let o=I4e(n,s.extends,i),c=w4e(o,s);return delete c.extends,c}function w4e(n,t){let i={...n};for(let s in t)s!=="extends"&&(typeof t[s]=="object"&&!Array.isArray(t[s])&&t[s]!==null?i[s]=w4e(n[s]||{},t[s]):i[s]=t[s]);return i}function rj(n){if(typeof n=="string")return n.replace(/\$\{([^}]+)\}/g,(t,i)=>{if(i==="workspaceFolder"){let s=process.env.BCTB_WORKSPACE_PATH||process.cwd();return console.error(`[Config] Expanding \${workspaceFolder} to: ${s}`),s}return process.env[i]||""});if(Array.isArray(n))return n.map(t=>rj(t));if(typeof n=="object"&&n!==null){let t={};for(let i in n)t[i]=rj(n[i]);return t}return n}var yr=be($pe());var Ia="3.0.2";var rGt=be(require("https"));var W0=be(Y3t()),is=be(require("fs")),CD=be(require("path")),J3t=be(require("crypto")),Z3t=be(require("os")),BCe=class{client;constructor(t,i,s){W0.setup(t).setAutoCollectRequests(!1).setAutoCollectPerformance(!1,!1).setAutoCollectExceptions(!1).setAutoCollectDependencies(!1).setAutoCollectConsole(!1).setUseDiskRetryCaching(!0),W0.start(),this.client=W0.defaultClient,this.client.commonProperties={installationId:i,version:s,component:"MCP"}}trackEvent(t,i,s){let o={};if(i)for(let[c,r]of Object.entries(i))o[c]=String(r);this.client.trackEvent({name:t,properties:o,measurements:s})}trackException(t,i){this.client.trackException({exception:t,properties:{errorName:t.name,errorMessage:t.message,...i}})}trackDependency(t,i,s,o,c,r){this.client.trackDependency({name:t,data:i,duration:s,success:o,resultCode:c||(o?"200":"500"),dependencyTypeName:"External",properties:r})}trackTrace(t,i){this.client.trackTrace({message:t,properties:i})}async flush(){return new Promise(t=>{this.client.flush(),setTimeout(t,2e3)})}},X3t=".bctb-installation-id",FAn=".bctb",$An="installation-id";function zAn(){let n=Z3t.homedir();return CD.join(n,FAn)}function MD(n){let t=zAn(),i=CD.join(t,$An);try{if(is.existsSync(i)){let c=is.readFileSync(i,"utf8").trim();if(c)return HAn(n),c}}catch{}let s=CD.join(n,X3t);try{if(is.existsSync(s)){let c=is.readFileSync(s,"utf8").trim();if(c)return W3t(t),is.writeFileSync(i,c,"utf8"),is.unlinkSync(s),c}}catch(c){console.error(`Failed to migrate workspace installation ID: ${c}`)}let o=J3t.randomUUID();try{W3t(t),is.writeFileSync(i,o,"utf8")}catch(c){console.error(`Failed to write installation ID file: ${c}`)}return o}function W3t(n){is.existsSync(n)||is.mkdirSync(n,{recursive:!0})}function HAn(n){let t=CD.join(n,X3t);try{is.existsSync(t)&&is.unlinkSync(t)}catch{}}function zee(n,t,i){if(!n||n.trim()==="")return null;try{let s=MD(t);return new BCe(n,s,i)}catch(s){return console.error(`Failed to initialize MCP usage telemetry: ${s}`),null}}var fUe=be(require("crypto"));var Ir;(function(n){n.assertEqual=o=>{};function t(o){}n.assertIs=t;function i(o){throw new Error}n.assertNever=i,n.arrayToEnum=o=>{let c={};for(let r of o)c[r]=r;return c},n.getValidEnumValues=o=>{let c=n.objectKeys(o).filter(e=>typeof o[o[e]]!="number"),r={};for(let e of c)r[e]=o[e];return n.objectValues(r)},n.objectValues=o=>n.objectKeys(o).map(function(c){return o[c]}),n.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let c=[];for(let r in o)Object.prototype.hasOwnProperty.call(o,r)&&c.push(r);return c},n.find=(o,c)=>{for(let r of o)if(c(r))return r},n.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function s(o,c=" | "){return o.map(r=>typeof r=="string"?`'${r}'`:r).join(c)}n.joinValues=s,n.jsonStringifyReplacer=(o,c)=>typeof c=="bigint"?c.toString():c})(Ir||(Ir={}));var Q3t;(function(n){n.mergeShapes=(t,i)=>({...t,...i})})(Q3t||(Q3t={}));var Ze=Ir.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Am=n=>{switch(typeof n){case"undefined":return Ze.undefined;case"string":return Ze.string;case"number":return Number.isNaN(n)?Ze.nan:Ze.number;case"boolean":return Ze.boolean;case"function":return Ze.function;case"bigint":return Ze.bigint;case"symbol":return Ze.symbol;case"object":return Array.isArray(n)?Ze.array:n===null?Ze.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Ze.promise:typeof Map<"u"&&n instanceof Map?Ze.map:typeof Set<"u"&&n instanceof Set?Ze.set:typeof Date<"u"&&n instanceof Date?Ze.date:Ze.object;default:return Ze.unknown}};var Se=Ir.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"]);var cu=class n extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let i=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,i):this.__proto__=i,this.name="ZodError",this.issues=t}format(t){let i=t||function(c){return c.message},s={_errors:[]},o=c=>{for(let r of c.issues)if(r.code==="invalid_union")r.unionErrors.map(o);else if(r.code==="invalid_return_type")o(r.returnTypeError);else if(r.code==="invalid_arguments")o(r.argumentsError);else if(r.path.length===0)s._errors.push(i(r));else{let e=s,a=0;for(;a<r.path.length;){let u=r.path[a];a===r.path.length-1?(e[u]=e[u]||{_errors:[]},e[u]._errors.push(i(r))):e[u]=e[u]||{_errors:[]},e=e[u],a++}}};return o(this),s}static assert(t){if(!(t instanceof n))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ir.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=i=>i.message){let i=Object.create(null),s=[];for(let o of this.issues)if(o.path.length>0){let c=o.path[0];i[c]=i[c]||[],i[c].push(t(o))}else s.push(t(o));return{formErrors:s,fieldErrors:i}}get formErrors(){return this.flatten()}};cu.create=n=>new cu(n);var GAn=(n,t)=>{let i;switch(n.code){case Se.invalid_type:n.received===Ze.undefined?i="Required":i=`Expected ${n.expected}, received ${n.received}`;break;case Se.invalid_literal:i=`Invalid literal value, expected ${JSON.stringify(n.expected,Ir.jsonStringifyReplacer)}`;break;case Se.unrecognized_keys:i=`Unrecognized key(s) in object: ${Ir.joinValues(n.keys,", ")}`;break;case Se.invalid_union:i="Invalid input";break;case Se.invalid_union_discriminator:i=`Invalid discriminator value. Expected ${Ir.joinValues(n.options)}`;break;case Se.invalid_enum_value:i=`Invalid enum value. Expected ${Ir.joinValues(n.options)}, received '${n.received}'`;break;case Se.invalid_arguments:i="Invalid function arguments";break;case Se.invalid_return_type:i="Invalid function return type";break;case Se.invalid_date:i="Invalid date";break;case Se.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(i=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(i=`${i} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?i=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?i=`Invalid input: must end with "${n.validation.endsWith}"`:Ir.assertNever(n.validation):n.validation!=="regex"?i=`Invalid ${n.validation}`:i="Invalid";break;case Se.too_small:n.type==="array"?i=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?i=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?i=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?i=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?i=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:i="Invalid input";break;case Se.too_big:n.type==="array"?i=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?i=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?i=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?i=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?i=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:i="Invalid input";break;case Se.custom:i="Invalid input";break;case Se.invalid_intersection_types:i="Intersection results could not be merged";break;case Se.not_multiple_of:i=`Number must be a multiple of ${n.multipleOf}`;break;case Se.not_finite:i="Number must be finite";break;default:i=t.defaultError,Ir.assertNever(n)}return{message:i}},nv=GAn;var KAn=nv;function LD(){return KAn}var Hee=n=>{let{data:t,path:i,errorMaps:s,issueData:o}=n,c=[...i,...o.path||[]],r={...o,path:c};if(o.message!==void 0)return{...o,path:c,message:o.message};let e="",a=s.filter(u=>!!u).slice().reverse();for(let u of a)e=u(r,{data:t,defaultError:e}).message;return{...o,path:c,message:e}};function Ue(n,t){let i=LD(),s=Hee({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,i,i===nv?void 0:nv].filter(o=>!!o)});n.common.issues.push(s)}var os=class n{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,i){let s=[];for(let o of i){if(o.status==="aborted")return Rt;o.status==="dirty"&&t.dirty(),s.push(o.value)}return{status:t.value,value:s}}static async mergeObjectAsync(t,i){let s=[];for(let o of i){let c=await o.key,r=await o.value;s.push({key:c,value:r})}return n.mergeObjectSync(t,s)}static mergeObjectSync(t,i){let s={};for(let o of i){let{key:c,value:r}=o;if(c.status==="aborted"||r.status==="aborted")return Rt;c.status==="dirty"&&t.dirty(),r.status==="dirty"&&t.dirty(),c.value!=="__proto__"&&(typeof r.value<"u"||o.alwaysSet)&&(s[c.value]=r.value)}return{status:t.value,value:s}}},Rt=Object.freeze({status:"aborted"}),J0=n=>({status:"dirty",value:n}),ws=n=>({status:"valid",value:n}),FCe=n=>n.status==="aborted",$Ce=n=>n.status==="dirty",kT=n=>n.status==="valid",kD=n=>typeof Promise<"u"&&n instanceof Promise;var it;(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t?.message})(it||(it={}));var $l=class{constructor(t,i,s,o){this._cachedPath=[],this.parent=t,this.data=i,this._path=s,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},eBt=(n,t)=>{if(kT(t))return{success:!0,data:t.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let i=new cu(n.common.issues);return this._error=i,this._error}}};function Zt(n){if(!n)return{};let{errorMap:t,invalid_type_error:i,required_error:s,description:o}=n;if(t&&(i||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(r,e)=>{let{message:a}=n;return r.code==="invalid_enum_value"?{message:a??e.defaultError}:typeof e.data>"u"?{message:a??s??e.defaultError}:r.code!=="invalid_type"?{message:e.defaultError}:{message:a??i??e.defaultError}},description:o}}var lr=class{get description(){return this._def.description}_getType(t){return Am(t.data)}_getOrReturnCtx(t,i){return i||{common:t.parent.common,data:t.data,parsedType:Am(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new os,ctx:{common:t.parent.common,data:t.data,parsedType:Am(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let i=this._parse(t);if(kD(i))throw new Error("Synchronous parse encountered promise.");return i}_parseAsync(t){let i=this._parse(t);return Promise.resolve(i)}parse(t,i){let s=this.safeParse(t,i);if(s.success)return s.data;throw s.error}safeParse(t,i){let s={common:{issues:[],async:i?.async??!1,contextualErrorMap:i?.errorMap},path:i?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Am(t)},o=this._parseSync({data:t,path:s.path,parent:s});return eBt(s,o)}"~validate"(t){let i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Am(t)};if(!this["~standard"].async)try{let s=this._parseSync({data:t,path:[],parent:i});return kT(s)?{value:s.value}:{issues:i.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:i}).then(s=>kT(s)?{value:s.value}:{issues:i.common.issues})}async parseAsync(t,i){let s=await this.safeParseAsync(t,i);if(s.success)return s.data;throw s.error}async safeParseAsync(t,i){let s={common:{issues:[],contextualErrorMap:i?.errorMap,async:!0},path:i?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Am(t)},o=this._parse({data:t,path:s.path,parent:s}),c=await(kD(o)?o:Promise.resolve(o));return eBt(s,c)}refine(t,i){let s=o=>typeof i=="string"||typeof i>"u"?{message:i}:typeof i=="function"?i(o):i;return this._refinement((o,c)=>{let r=t(o),e=()=>c.addIssue({code:Se.custom,...s(o)});return typeof Promise<"u"&&r instanceof Promise?r.then(a=>a?!0:(e(),!1)):r?!0:(e(),!1)})}refinement(t,i){return this._refinement((s,o)=>t(s)?!0:(o.addIssue(typeof i=="function"?i(s,o):i),!1))}_refinement(t){return new Kp({schema:this,typeName:Ae.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:i=>this["~validate"](i)}}optional(){return Gp.create(this,this._def)}nullable(){return Nm.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ov.create(this)}promise(){return DT.create(this,this._def)}or(t){return tR.create([this,t],this._def)}and(t){return rR.create(this,t,this._def)}transform(t){return new Kp({...Zt(this._def),schema:this,typeName:Ae.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let i=typeof t=="function"?t:()=>t;return new sR({...Zt(this._def),innerType:this,defaultValue:i,typeName:Ae.ZodDefault})}brand(){return new Gee({typeName:Ae.ZodBranded,type:this,...Zt(this._def)})}catch(t){let i=typeof t=="function"?t:()=>t;return new cR({...Zt(this._def),innerType:this,catchValue:i,typeName:Ae.ZodCatch})}describe(t){let i=this.constructor;return new i({...this._def,description:t})}pipe(t){return Kee.create(this,t)}readonly(){return uR.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},YAn=/^c[^\s-]{8,}$/i,WAn=/^[0-9a-z]+$/,JAn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ZAn=/^[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,XAn=/^[a-z0-9_-]{21}$/i,QAn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ePn=/^[-+]?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)?)??$/,tPn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,rPn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",zCe,nPn=/^(?:(?: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])$/,iPn=/^(?:(?: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])$/,oPn=/^(([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]))$/,aPn=/^(([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])$/,sPn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,cPn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,tBt="((\\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])))",uPn=new RegExp(`^${tBt}$`);function rBt(n){let t="[0-5]\\d";n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`);let i=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${i}`}function lPn(n){return new RegExp(`^${rBt(n)}$`)}function pPn(n){let t=`${tBt}T${rBt(n)}`,i=[];return i.push(n.local?"Z?":"Z"),n.offset&&i.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${i.join("|")})`,new RegExp(`^${t}$`)}function dPn(n,t){return!!((t==="v4"||!t)&&nPn.test(n)||(t==="v6"||!t)&&oPn.test(n))}function fPn(n,t){if(!QAn.test(n))return!1;try{let[i]=n.split(".");if(!i)return!1;let s=i.replace(/-/g,"+").replace(/_/g,"/").padEnd(i.length+(4-i.length%4)%4,"="),o=JSON.parse(atob(s));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function hPn(n,t){return!!((t==="v4"||!t)&&iPn.test(n)||(t==="v6"||!t)&&aPn.test(n))}var X0=class n extends lr{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Ze.string){let c=this._getOrReturnCtx(t);return Ue(c,{code:Se.invalid_type,expected:Ze.string,received:c.parsedType}),Rt}let s=new os,o;for(let c of this._def.checks)if(c.kind==="min")t.data.length<c.value&&(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.too_small,minimum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),s.dirty());else if(c.kind==="max")t.data.length>c.value&&(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),s.dirty());else if(c.kind==="length"){let r=t.data.length>c.value,e=t.data.length<c.value;(r||e)&&(o=this._getOrReturnCtx(t,o),r?Ue(o,{code:Se.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!0,message:c.message}):e&&Ue(o,{code:Se.too_small,minimum:c.value,type:"string",inclusive:!0,exact:!0,message:c.message}),s.dirty())}else if(c.kind==="email")tPn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"email",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="emoji")zCe||(zCe=new RegExp(rPn,"u")),zCe.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"emoji",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="uuid")ZAn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"uuid",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="nanoid")XAn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"nanoid",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="cuid")YAn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"cuid",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="cuid2")WAn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"cuid2",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="ulid")JAn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"ulid",code:Se.invalid_string,message:c.message}),s.dirty());else if(c.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),Ue(o,{validation:"url",code:Se.invalid_string,message:c.message}),s.dirty()}else c.kind==="regex"?(c.regex.lastIndex=0,c.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"regex",code:Se.invalid_string,message:c.message}),s.dirty())):c.kind==="trim"?t.data=t.data.trim():c.kind==="includes"?t.data.includes(c.value,c.position)||(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.invalid_string,validation:{includes:c.value,position:c.position},message:c.message}),s.dirty()):c.kind==="toLowerCase"?t.data=t.data.toLowerCase():c.kind==="toUpperCase"?t.data=t.data.toUpperCase():c.kind==="startsWith"?t.data.startsWith(c.value)||(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.invalid_string,validation:{startsWith:c.value},message:c.message}),s.dirty()):c.kind==="endsWith"?t.data.endsWith(c.value)||(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.invalid_string,validation:{endsWith:c.value},message:c.message}),s.dirty()):c.kind==="datetime"?pPn(c).test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.invalid_string,validation:"datetime",message:c.message}),s.dirty()):c.kind==="date"?uPn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.invalid_string,validation:"date",message:c.message}),s.dirty()):c.kind==="time"?lPn(c).test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.invalid_string,validation:"time",message:c.message}),s.dirty()):c.kind==="duration"?ePn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"duration",code:Se.invalid_string,message:c.message}),s.dirty()):c.kind==="ip"?dPn(t.data,c.version)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"ip",code:Se.invalid_string,message:c.message}),s.dirty()):c.kind==="jwt"?fPn(t.data,c.alg)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"jwt",code:Se.invalid_string,message:c.message}),s.dirty()):c.kind==="cidr"?hPn(t.data,c.version)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"cidr",code:Se.invalid_string,message:c.message}),s.dirty()):c.kind==="base64"?sPn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"base64",code:Se.invalid_string,message:c.message}),s.dirty()):c.kind==="base64url"?cPn.test(t.data)||(o=this._getOrReturnCtx(t,o),Ue(o,{validation:"base64url",code:Se.invalid_string,message:c.message}),s.dirty()):Ir.assertNever(c);return{status:s.value,value:t.data}}_regex(t,i,s){return this.refinement(o=>t.test(o),{validation:i,code:Se.invalid_string,...it.errToObj(s)})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...it.errToObj(t)})}url(t){return this._addCheck({kind:"url",...it.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...it.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...it.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...it.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...it.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...it.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...it.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...it.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...it.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...it.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...it.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...it.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...it.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...it.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...it.errToObj(t)})}regex(t,i){return this._addCheck({kind:"regex",regex:t,...it.errToObj(i)})}includes(t,i){return this._addCheck({kind:"includes",value:t,position:i?.position,...it.errToObj(i?.message)})}startsWith(t,i){return this._addCheck({kind:"startsWith",value:t,...it.errToObj(i)})}endsWith(t,i){return this._addCheck({kind:"endsWith",value:t,...it.errToObj(i)})}min(t,i){return this._addCheck({kind:"min",value:t,...it.errToObj(i)})}max(t,i){return this._addCheck({kind:"max",value:t,...it.errToObj(i)})}length(t,i){return this._addCheck({kind:"length",value:t,...it.errToObj(i)})}nonempty(t){return this.min(1,it.errToObj(t))}trim(){return new n({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let i of this._def.checks)i.kind==="min"&&(t===null||i.value>t)&&(t=i.value);return t}get maxLength(){let t=null;for(let i of this._def.checks)i.kind==="max"&&(t===null||i.value<t)&&(t=i.value);return t}};X0.create=n=>new X0({checks:[],typeName:Ae.ZodString,coerce:n?.coerce??!1,...Zt(n)});function mPn(n,t){let i=(n.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,o=i>s?i:s,c=Number.parseInt(n.toFixed(o).replace(".","")),r=Number.parseInt(t.toFixed(o).replace(".",""));return c%r/10**o}var DD=class n extends lr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Ze.number){let c=this._getOrReturnCtx(t);return Ue(c,{code:Se.invalid_type,expected:Ze.number,received:c.parsedType}),Rt}let s,o=new os;for(let c of this._def.checks)c.kind==="int"?Ir.isInteger(t.data)||(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.invalid_type,expected:"integer",received:"float",message:c.message}),o.dirty()):c.kind==="min"?(c.inclusive?t.data<c.value:t.data<=c.value)&&(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.too_small,minimum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),o.dirty()):c.kind==="max"?(c.inclusive?t.data>c.value:t.data>=c.value)&&(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.too_big,maximum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),o.dirty()):c.kind==="multipleOf"?mPn(t.data,c.value)!==0&&(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.not_multiple_of,multipleOf:c.value,message:c.message}),o.dirty()):c.kind==="finite"?Number.isFinite(t.data)||(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.not_finite,message:c.message}),o.dirty()):Ir.assertNever(c);return{status:o.value,value:t.data}}gte(t,i){return this.setLimit("min",t,!0,it.toString(i))}gt(t,i){return this.setLimit("min",t,!1,it.toString(i))}lte(t,i){return this.setLimit("max",t,!0,it.toString(i))}lt(t,i){return this.setLimit("max",t,!1,it.toString(i))}setLimit(t,i,s,o){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:i,inclusive:s,message:it.toString(o)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:it.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:it.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:it.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:it.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:it.toString(t)})}multipleOf(t,i){return this._addCheck({kind:"multipleOf",value:t,message:it.toString(i)})}finite(t){return this._addCheck({kind:"finite",message:it.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:it.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:it.toString(t)})}get minValue(){let t=null;for(let i of this._def.checks)i.kind==="min"&&(t===null||i.value>t)&&(t=i.value);return t}get maxValue(){let t=null;for(let i of this._def.checks)i.kind==="max"&&(t===null||i.value<t)&&(t=i.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ir.isInteger(t.value))}get isFinite(){let t=null,i=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(i===null||s.value>i)&&(i=s.value):s.kind==="max"&&(t===null||s.value<t)&&(t=s.value)}return Number.isFinite(i)&&Number.isFinite(t)}};DD.create=n=>new DD({checks:[],typeName:Ae.ZodNumber,coerce:n?.coerce||!1,...Zt(n)});var UD=class n extends lr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Ze.bigint)return this._getInvalidInput(t);let s,o=new os;for(let c of this._def.checks)c.kind==="min"?(c.inclusive?t.data<c.value:t.data<=c.value)&&(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.too_small,type:"bigint",minimum:c.value,inclusive:c.inclusive,message:c.message}),o.dirty()):c.kind==="max"?(c.inclusive?t.data>c.value:t.data>=c.value)&&(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.too_big,type:"bigint",maximum:c.value,inclusive:c.inclusive,message:c.message}),o.dirty()):c.kind==="multipleOf"?t.data%c.value!==BigInt(0)&&(s=this._getOrReturnCtx(t,s),Ue(s,{code:Se.not_multiple_of,multipleOf:c.value,message:c.message}),o.dirty()):Ir.assertNever(c);return{status:o.value,value:t.data}}_getInvalidInput(t){let i=this._getOrReturnCtx(t);return Ue(i,{code:Se.invalid_type,expected:Ze.bigint,received:i.parsedType}),Rt}gte(t,i){return this.setLimit("min",t,!0,it.toString(i))}gt(t,i){return this.setLimit("min",t,!1,it.toString(i))}lte(t,i){return this.setLimit("max",t,!0,it.toString(i))}lt(t,i){return this.setLimit("max",t,!1,it.toString(i))}setLimit(t,i,s,o){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:i,inclusive:s,message:it.toString(o)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:it.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:it.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:it.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:it.toString(t)})}multipleOf(t,i){return this._addCheck({kind:"multipleOf",value:t,message:it.toString(i)})}get minValue(){let t=null;for(let i of this._def.checks)i.kind==="min"&&(t===null||i.value>t)&&(t=i.value);return t}get maxValue(){let t=null;for(let i of this._def.checks)i.kind==="max"&&(t===null||i.value<t)&&(t=i.value);return t}};UD.create=n=>new UD({checks:[],typeName:Ae.ZodBigInt,coerce:n?.coerce??!1,...Zt(n)});var qD=class extends lr{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Ze.boolean){let s=this._getOrReturnCtx(t);return Ue(s,{code:Se.invalid_type,expected:Ze.boolean,received:s.parsedType}),Rt}return ws(t.data)}};qD.create=n=>new qD({typeName:Ae.ZodBoolean,coerce:n?.coerce||!1,...Zt(n)});var jD=class n extends lr{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Ze.date){let c=this._getOrReturnCtx(t);return Ue(c,{code:Se.invalid_type,expected:Ze.date,received:c.parsedType}),Rt}if(Number.isNaN(t.data.getTime())){let c=this._getOrReturnCtx(t);return Ue(c,{code:Se.invalid_date}),Rt}let s=new os,o;for(let c of this._def.checks)c.kind==="min"?t.data.getTime()<c.value&&(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.too_small,message:c.message,inclusive:!0,exact:!1,minimum:c.value,type:"date"}),s.dirty()):c.kind==="max"?t.data.getTime()>c.value&&(o=this._getOrReturnCtx(t,o),Ue(o,{code:Se.too_big,message:c.message,inclusive:!0,exact:!1,maximum:c.value,type:"date"}),s.dirty()):Ir.assertNever(c);return{status:s.value,value:new Date(t.data.getTime())}}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}min(t,i){return this._addCheck({kind:"min",value:t.getTime(),message:it.toString(i)})}max(t,i){return this._addCheck({kind:"max",value:t.getTime(),message:it.toString(i)})}get minDate(){let t=null;for(let i of this._def.checks)i.kind==="min"&&(t===null||i.value>t)&&(t=i.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let i of this._def.checks)i.kind==="max"&&(t===null||i.value<t)&&(t=i.value);return t!=null?new Date(t):null}};jD.create=n=>new jD({checks:[],coerce:n?.coerce||!1,typeName:Ae.ZodDate,...Zt(n)});var VD=class extends lr{_parse(t){if(this._getType(t)!==Ze.symbol){let s=this._getOrReturnCtx(t);return Ue(s,{code:Se.invalid_type,expected:Ze.symbol,received:s.parsedType}),Rt}return ws(t.data)}};VD.create=n=>new VD({typeName:Ae.ZodSymbol,...Zt(n)});var Q0=class extends lr{_parse(t){if(this._getType(t)!==Ze.undefined){let s=this._getOrReturnCtx(t);return Ue(s,{code:Se.invalid_type,expected:Ze.undefined,received:s.parsedType}),Rt}return ws(t.data)}};Q0.create=n=>new Q0({typeName:Ae.ZodUndefined,...Zt(n)});var eR=class extends lr{_parse(t){if(this._getType(t)!==Ze.null){let s=this._getOrReturnCtx(t);return Ue(s,{code:Se.invalid_type,expected:Ze.null,received:s.parsedType}),Rt}return ws(t.data)}};eR.create=n=>new eR({typeName:Ae.ZodNull,...Zt(n)});var BD=class extends lr{constructor(){super(...arguments),this._any=!0}_parse(t){return ws(t.data)}};BD.create=n=>new BD({typeName:Ae.ZodAny,...Zt(n)});var iv=class extends lr{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ws(t.data)}};iv.create=n=>new iv({typeName:Ae.ZodUnknown,...Zt(n)});var lh=class extends lr{_parse(t){let i=this._getOrReturnCtx(t);return Ue(i,{code:Se.invalid_type,expected:Ze.never,received:i.parsedType}),Rt}};lh.create=n=>new lh({typeName:Ae.ZodNever,...Zt(n)});var FD=class extends lr{_parse(t){if(this._getType(t)!==Ze.undefined){let s=this._getOrReturnCtx(t);return Ue(s,{code:Se.invalid_type,expected:Ze.void,received:s.parsedType}),Rt}return ws(t.data)}};FD.create=n=>new FD({typeName:Ae.ZodVoid,...Zt(n)});var ov=class n extends lr{_parse(t){let{ctx:i,status:s}=this._processInputParams(t),o=this._def;if(i.parsedType!==Ze.array)return Ue(i,{code:Se.invalid_type,expected:Ze.array,received:i.parsedType}),Rt;if(o.exactLength!==null){let r=i.data.length>o.exactLength.value,e=i.data.length<o.exactLength.value;(r||e)&&(Ue(i,{code:r?Se.too_big:Se.too_small,minimum:e?o.exactLength.value:void 0,maximum:r?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),s.dirty())}if(o.minLength!==null&&i.data.length<o.minLength.value&&(Ue(i,{code:Se.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),s.dirty()),o.maxLength!==null&&i.data.length>o.maxLength.value&&(Ue(i,{code:Se.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),s.dirty()),i.common.async)return Promise.all([...i.data].map((r,e)=>o.type._parseAsync(new $l(i,r,i.path,e)))).then(r=>os.mergeArray(s,r));let c=[...i.data].map((r,e)=>o.type._parseSync(new $l(i,r,i.path,e)));return os.mergeArray(s,c)}get element(){return this._def.type}min(t,i){return new n({...this._def,minLength:{value:t,message:it.toString(i)}})}max(t,i){return new n({...this._def,maxLength:{value:t,message:it.toString(i)}})}length(t,i){return new n({...this._def,exactLength:{value:t,message:it.toString(i)}})}nonempty(t){return this.min(1,t)}};ov.create=(n,t)=>new ov({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Ae.ZodArray,...Zt(t)});function Z0(n){if(n instanceof uu){let t={};for(let i in n.shape){let s=n.shape[i];t[i]=Gp.create(Z0(s))}return new uu({...n._def,shape:()=>t})}else return n instanceof ov?new ov({...n._def,type:Z0(n.element)}):n instanceof Gp?Gp.create(Z0(n.unwrap())):n instanceof Nm?Nm.create(Z0(n.unwrap())):n instanceof Rm?Rm.create(n.items.map(t=>Z0(t))):n}var uu=class n extends lr{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),i=Ir.objectKeys(t);return this._cached={shape:t,keys:i},this._cached}_parse(t){if(this._getType(t)!==Ze.object){let u=this._getOrReturnCtx(t);return Ue(u,{code:Se.invalid_type,expected:Ze.object,received:u.parsedType}),Rt}let{status:s,ctx:o}=this._processInputParams(t),{shape:c,keys:r}=this._getCached(),e=[];if(!(this._def.catchall instanceof lh&&this._def.unknownKeys==="strip"))for(let u in o.data)r.includes(u)||e.push(u);let a=[];for(let u of r){let l=c[u],p=o.data[u];a.push({key:{status:"valid",value:u},value:l._parse(new $l(o,p,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof lh){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of e)a.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")e.length>0&&(Ue(o,{code:Se.unrecognized_keys,keys:e}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of e){let p=o.data[l];a.push({key:{status:"valid",value:l},value:u._parse(new $l(o,p,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of a){let p=await l.key,d=await l.value;u.push({key:p,value:d,alwaysSet:l.alwaysSet})}return u}).then(u=>os.mergeObjectSync(s,u)):os.mergeObjectSync(s,a)}get shape(){return this._def.shape()}strict(t){return it.errToObj,new n({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(i,s)=>{let o=this._def.errorMap?.(i,s).message??s.defaultError;return i.code==="unrecognized_keys"?{message:it.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new n({...this._def,unknownKeys:"strip"})}passthrough(){return new n({...this._def,unknownKeys:"passthrough"})}extend(t){return new n({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new n({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ae.ZodObject})}setKey(t,i){return this.augment({[t]:i})}catchall(t){return new n({...this._def,catchall:t})}pick(t){let i={};for(let s of Ir.objectKeys(t))t[s]&&this.shape[s]&&(i[s]=this.shape[s]);return new n({...this._def,shape:()=>i})}omit(t){let i={};for(let s of Ir.objectKeys(this.shape))t[s]||(i[s]=this.shape[s]);return new n({...this._def,shape:()=>i})}deepPartial(){return Z0(this)}partial(t){let i={};for(let s of Ir.objectKeys(this.shape)){let o=this.shape[s];t&&!t[s]?i[s]=o:i[s]=o.optional()}return new n({...this._def,shape:()=>i})}required(t){let i={};for(let s of Ir.objectKeys(this.shape))if(t&&!t[s])i[s]=this.shape[s];else{let c=this.shape[s];for(;c instanceof Gp;)c=c._def.innerType;i[s]=c}return new n({...this._def,shape:()=>i})}keyof(){return nBt(Ir.objectKeys(this.shape))}};uu.create=(n,t)=>new uu({shape:()=>n,unknownKeys:"strip",catchall:lh.create(),typeName:Ae.ZodObject,...Zt(t)});uu.strictCreate=(n,t)=>new uu({shape:()=>n,unknownKeys:"strict",catchall:lh.create(),typeName:Ae.ZodObject,...Zt(t)});uu.lazycreate=(n,t)=>new uu({shape:n,unknownKeys:"strip",catchall:lh.create(),typeName:Ae.ZodObject,...Zt(t)});var tR=class extends lr{_parse(t){let{ctx:i}=this._processInputParams(t),s=this._def.options;function o(c){for(let e of c)if(e.result.status==="valid")return e.result;for(let e of c)if(e.result.status==="dirty")return i.common.issues.push(...e.ctx.common.issues),e.result;let r=c.map(e=>new cu(e.ctx.common.issues));return Ue(i,{code:Se.invalid_union,unionErrors:r}),Rt}if(i.common.async)return Promise.all(s.map(async c=>{let r={...i,common:{...i.common,issues:[]},parent:null};return{result:await c._parseAsync({data:i.data,path:i.path,parent:r}),ctx:r}})).then(o);{let c,r=[];for(let a of s){let u={...i,common:{...i.common,issues:[]},parent:null},l=a._parseSync({data:i.data,path:i.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!c&&(c={result:l,ctx:u}),u.common.issues.length&&r.push(u.common.issues)}if(c)return i.common.issues.push(...c.ctx.common.issues),c.result;let e=r.map(a=>new cu(a));return Ue(i,{code:Se.invalid_union,unionErrors:e}),Rt}}get options(){return this._def.options}};tR.create=(n,t)=>new tR({options:n,typeName:Ae.ZodUnion,...Zt(t)});var Pm=n=>n instanceof nR?Pm(n.schema):n instanceof Kp?Pm(n.innerType()):n instanceof iR?[n.value]:n instanceof oR?n.options:n instanceof aR?Ir.objectValues(n.enum):n instanceof sR?Pm(n._def.innerType):n instanceof Q0?[void 0]:n instanceof eR?[null]:n instanceof Gp?[void 0,...Pm(n.unwrap())]:n instanceof Nm?[null,...Pm(n.unwrap())]:n instanceof Gee||n instanceof uR?Pm(n.unwrap()):n instanceof cR?Pm(n._def.innerType):[],HCe=class n extends lr{_parse(t){let{ctx:i}=this._processInputParams(t);if(i.parsedType!==Ze.object)return Ue(i,{code:Se.invalid_type,expected:Ze.object,received:i.parsedType}),Rt;let s=this.discriminator,o=i.data[s],c=this.optionsMap.get(o);return c?i.common.async?c._parseAsync({data:i.data,path:i.path,parent:i}):c._parseSync({data:i.data,path:i.path,parent:i}):(Ue(i,{code:Se.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),Rt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,i,s){let o=new Map;for(let c of i){let r=Pm(c.shape[t]);if(!r.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let e of r){if(o.has(e))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(e)}`);o.set(e,c)}}return new n({typeName:Ae.ZodDiscriminatedUnion,discriminator:t,options:i,optionsMap:o,...Zt(s)})}};function GCe(n,t){let i=Am(n),s=Am(t);if(n===t)return{valid:!0,data:n};if(i===Ze.object&&s===Ze.object){let o=Ir.objectKeys(t),c=Ir.objectKeys(n).filter(e=>o.indexOf(e)!==-1),r={...n,...t};for(let e of c){let a=GCe(n[e],t[e]);if(!a.valid)return{valid:!1};r[e]=a.data}return{valid:!0,data:r}}else if(i===Ze.array&&s===Ze.array){if(n.length!==t.length)return{valid:!1};let o=[];for(let c=0;c<n.length;c++){let r=n[c],e=t[c],a=GCe(r,e);if(!a.valid)return{valid:!1};o.push(a.data)}return{valid:!0,data:o}}else return i===Ze.date&&s===Ze.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}var rR=class extends lr{_parse(t){let{status:i,ctx:s}=this._processInputParams(t),o=(c,r)=>{if(FCe(c)||FCe(r))return Rt;let e=GCe(c.value,r.value);return e.valid?(($Ce(c)||$Ce(r))&&i.dirty(),{status:i.value,value:e.data}):(Ue(s,{code:Se.invalid_intersection_types}),Rt)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([c,r])=>o(c,r)):o(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};rR.create=(n,t,i)=>new rR({left:n,right:t,typeName:Ae.ZodIntersection,...Zt(i)});var Rm=class n extends lr{_parse(t){let{status:i,ctx:s}=this._processInputParams(t);if(s.parsedType!==Ze.array)return Ue(s,{code:Se.invalid_type,expected:Ze.array,received:s.parsedType}),Rt;if(s.data.length<this._def.items.length)return Ue(s,{code:Se.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Rt;!this._def.rest&&s.data.length>this._def.items.length&&(Ue(s,{code:Se.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),i.dirty());let c=[...s.data].map((r,e)=>{let a=this._def.items[e]||this._def.rest;return a?a._parse(new $l(s,r,s.path,e)):null}).filter(r=>!!r);return s.common.async?Promise.all(c).then(r=>os.mergeArray(i,r)):os.mergeArray(i,c)}get items(){return this._def.items}rest(t){return new n({...this._def,rest:t})}};Rm.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Rm({items:n,typeName:Ae.ZodTuple,rest:null,...Zt(t)})};var KCe=class n extends lr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:i,ctx:s}=this._processInputParams(t);if(s.parsedType!==Ze.object)return Ue(s,{code:Se.invalid_type,expected:Ze.object,received:s.parsedType}),Rt;let o=[],c=this._def.keyType,r=this._def.valueType;for(let e in s.data)o.push({key:c._parse(new $l(s,e,s.path,e)),value:r._parse(new $l(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?os.mergeObjectAsync(i,o):os.mergeObjectSync(i,o)}get element(){return this._def.valueType}static create(t,i,s){return i instanceof lr?new n({keyType:t,valueType:i,typeName:Ae.ZodRecord,...Zt(s)}):new n({keyType:X0.create(),valueType:t,typeName:Ae.ZodRecord,...Zt(i)})}},$D=class extends lr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:i,ctx:s}=this._processInputParams(t);if(s.parsedType!==Ze.map)return Ue(s,{code:Se.invalid_type,expected:Ze.map,received:s.parsedType}),Rt;let o=this._def.keyType,c=this._def.valueType,r=[...s.data.entries()].map(([e,a],u)=>({key:o._parse(new $l(s,e,s.path,[u,"key"])),value:c._parse(new $l(s,a,s.path,[u,"value"]))}));if(s.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let a of r){let u=await a.key,l=await a.value;if(u.status==="aborted"||l.status==="aborted")return Rt;(u.status==="dirty"||l.status==="dirty")&&i.dirty(),e.set(u.value,l.value)}return{status:i.value,value:e}})}else{let e=new Map;for(let a of r){let u=a.key,l=a.value;if(u.status==="aborted"||l.status==="aborted")return Rt;(u.status==="dirty"||l.status==="dirty")&&i.dirty(),e.set(u.value,l.value)}return{status:i.value,value:e}}}};$D.create=(n,t,i)=>new $D({valueType:t,keyType:n,typeName:Ae.ZodMap,...Zt(i)});var zD=class n extends lr{_parse(t){let{status:i,ctx:s}=this._processInputParams(t);if(s.parsedType!==Ze.set)return Ue(s,{code:Se.invalid_type,expected:Ze.set,received:s.parsedType}),Rt;let o=this._def;o.minSize!==null&&s.data.size<o.minSize.value&&(Ue(s,{code:Se.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),i.dirty()),o.maxSize!==null&&s.data.size>o.maxSize.value&&(Ue(s,{code:Se.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),i.dirty());let c=this._def.valueType;function r(a){let u=new Set;for(let l of a){if(l.status==="aborted")return Rt;l.status==="dirty"&&i.dirty(),u.add(l.value)}return{status:i.value,value:u}}let e=[...s.data.values()].map((a,u)=>c._parse(new $l(s,a,s.path,u)));return s.common.async?Promise.all(e).then(a=>r(a)):r(e)}min(t,i){return new n({...this._def,minSize:{value:t,message:it.toString(i)}})}max(t,i){return new n({...this._def,maxSize:{value:t,message:it.toString(i)}})}size(t,i){return this.min(t,i).max(t,i)}nonempty(t){return this.min(1,t)}};zD.create=(n,t)=>new zD({valueType:n,minSize:null,maxSize:null,typeName:Ae.ZodSet,...Zt(t)});var YCe=class n extends lr{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:i}=this._processInputParams(t);if(i.parsedType!==Ze.function)return Ue(i,{code:Se.invalid_type,expected:Ze.function,received:i.parsedType}),Rt;function s(e,a){return Hee({data:e,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,LD(),nv].filter(u=>!!u),issueData:{code:Se.invalid_arguments,argumentsError:a}})}function o(e,a){return Hee({data:e,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,LD(),nv].filter(u=>!!u),issueData:{code:Se.invalid_return_type,returnTypeError:a}})}let c={errorMap:i.common.contextualErrorMap},r=i.data;if(this._def.returns instanceof DT){let e=this;return ws(async function(...a){let u=new cu([]),l=await e._def.args.parseAsync(a,c).catch(h=>{throw u.addIssue(s(a,h)),u}),p=await Reflect.apply(r,this,l);return await e._def.returns._def.type.parseAsync(p,c).catch(h=>{throw u.addIssue(o(p,h)),u})})}else{let e=this;return ws(function(...a){let u=e._def.args.safeParse(a,c);if(!u.success)throw new cu([s(a,u.error)]);let l=Reflect.apply(r,this,u.data),p=e._def.returns.safeParse(l,c);if(!p.success)throw new cu([o(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new n({...this._def,args:Rm.create(t).rest(iv.create())})}returns(t){return new n({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,i,s){return new n({args:t||Rm.create([]).rest(iv.create()),returns:i||iv.create(),typeName:Ae.ZodFunction,...Zt(s)})}},nR=class extends lr{get schema(){return this._def.getter()}_parse(t){let{ctx:i}=this._processInputParams(t);return this._def.getter()._parse({data:i.data,path:i.path,parent:i})}};nR.create=(n,t)=>new nR({getter:n,typeName:Ae.ZodLazy,...Zt(t)});var iR=class extends lr{_parse(t){if(t.data!==this._def.value){let i=this._getOrReturnCtx(t);return Ue(i,{received:i.data,code:Se.invalid_literal,expected:this._def.value}),Rt}return{status:"valid",value:t.data}}get value(){return this._def.value}};iR.create=(n,t)=>new iR({value:n,typeName:Ae.ZodLiteral,...Zt(t)});function nBt(n,t){return new oR({values:n,typeName:Ae.ZodEnum,...Zt(t)})}var oR=class n extends lr{_parse(t){if(typeof t.data!="string"){let i=this._getOrReturnCtx(t),s=this._def.values;return Ue(i,{expected:Ir.joinValues(s),received:i.parsedType,code:Se.invalid_type}),Rt}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let i=this._getOrReturnCtx(t),s=this._def.values;return Ue(i,{received:i.data,code:Se.invalid_enum_value,options:s}),Rt}return ws(t.data)}get options(){return this._def.values}get enum(){let t={};for(let i of this._def.values)t[i]=i;return t}get Values(){let t={};for(let i of this._def.values)t[i]=i;return t}get Enum(){let t={};for(let i of this._def.values)t[i]=i;return t}extract(t,i=this._def){return n.create(t,{...this._def,...i})}exclude(t,i=this._def){return n.create(this.options.filter(s=>!t.includes(s)),{...this._def,...i})}};oR.create=nBt;var aR=class extends lr{_parse(t){let i=Ir.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(t);if(s.parsedType!==Ze.string&&s.parsedType!==Ze.number){let o=Ir.objectValues(i);return Ue(s,{expected:Ir.joinValues(o),received:s.parsedType,code:Se.invalid_type}),Rt}if(this._cache||(this._cache=new Set(Ir.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let o=Ir.objectValues(i);return Ue(s,{received:s.data,code:Se.invalid_enum_value,options:o}),Rt}return ws(t.data)}get enum(){return this._def.values}};aR.create=(n,t)=>new aR({values:n,typeName:Ae.ZodNativeEnum,...Zt(t)});var DT=class extends lr{unwrap(){return this._def.type}_parse(t){let{ctx:i}=this._processInputParams(t);if(i.parsedType!==Ze.promise&&i.common.async===!1)return Ue(i,{code:Se.invalid_type,expected:Ze.promise,received:i.parsedType}),Rt;let s=i.parsedType===Ze.promise?i.data:Promise.resolve(i.data);return ws(s.then(o=>this._def.type.parseAsync(o,{path:i.path,errorMap:i.common.contextualErrorMap})))}};DT.create=(n,t)=>new DT({type:n,typeName:Ae.ZodPromise,...Zt(t)});var Kp=class extends lr{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ae.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:i,ctx:s}=this._processInputParams(t),o=this._def.effect||null,c={addIssue:r=>{Ue(s,r),r.fatal?i.abort():i.dirty()},get path(){return s.path}};if(c.addIssue=c.addIssue.bind(c),o.type==="preprocess"){let r=o.transform(s.data,c);if(s.common.async)return Promise.resolve(r).then(async e=>{if(i.value==="aborted")return Rt;let a=await this._def.schema._parseAsync({data:e,path:s.path,parent:s});return a.status==="aborted"?Rt:a.status==="dirty"?J0(a.value):i.value==="dirty"?J0(a.value):a});{if(i.value==="aborted")return Rt;let e=this._def.schema._parseSync({data:r,path:s.path,parent:s});return e.status==="aborted"?Rt:e.status==="dirty"?J0(e.value):i.value==="dirty"?J0(e.value):e}}if(o.type==="refinement"){let r=e=>{let a=o.refinement(e,c);if(s.common.async)return Promise.resolve(a);if(a instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(s.common.async===!1){let e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return e.status==="aborted"?Rt:(e.status==="dirty"&&i.dirty(),r(e.value),{status:i.value,value:e.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(e=>e.status==="aborted"?Rt:(e.status==="dirty"&&i.dirty(),r(e.value).then(()=>({status:i.value,value:e.value}))))}if(o.type==="transform")if(s.common.async===!1){let r=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!kT(r))return Rt;let e=o.transform(r.value,c);if(e instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:i.value,value:e}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(r=>kT(r)?Promise.resolve(o.transform(r.value,c)).then(e=>({status:i.value,value:e})):Rt);Ir.assertNever(o)}};Kp.create=(n,t,i)=>new Kp({schema:n,typeName:Ae.ZodEffects,effect:t,...Zt(i)});Kp.createWithPreprocess=(n,t,i)=>new Kp({schema:t,effect:{type:"preprocess",transform:n},typeName:Ae.ZodEffects,...Zt(i)});var Gp=class extends lr{_parse(t){return this._getType(t)===Ze.undefined?ws(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Gp.create=(n,t)=>new Gp({innerType:n,typeName:Ae.ZodOptional,...Zt(t)});var Nm=class extends lr{_parse(t){return this._getType(t)===Ze.null?ws(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Nm.create=(n,t)=>new Nm({innerType:n,typeName:Ae.ZodNullable,...Zt(t)});var sR=class extends lr{_parse(t){let{ctx:i}=this._processInputParams(t),s=i.data;return i.parsedType===Ze.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:i.path,parent:i})}removeDefault(){return this._def.innerType}};sR.create=(n,t)=>new sR({innerType:n,typeName:Ae.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Zt(t)});var cR=class extends lr{_parse(t){let{ctx:i}=this._processInputParams(t),s={...i,common:{...i.common,issues:[]}},o=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return kD(o)?o.then(c=>({status:"valid",value:c.status==="valid"?c.value:this._def.catchValue({get error(){return new cu(s.common.issues)},input:s.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new cu(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};cR.create=(n,t)=>new cR({innerType:n,typeName:Ae.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Zt(t)});var HD=class extends lr{_parse(t){if(this._getType(t)!==Ze.nan){let s=this._getOrReturnCtx(t);return Ue(s,{code:Se.invalid_type,expected:Ze.nan,received:s.parsedType}),Rt}return{status:"valid",value:t.data}}};HD.create=n=>new HD({typeName:Ae.ZodNaN,...Zt(n)});var tfi=Symbol("zod_brand"),Gee=class extends lr{_parse(t){let{ctx:i}=this._processInputParams(t),s=i.data;return this._def.type._parse({data:s,path:i.path,parent:i})}unwrap(){return this._def.type}},Kee=class n extends lr{_parse(t){let{status:i,ctx:s}=this._processInputParams(t);if(s.common.async)return(async()=>{let c=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return c.status==="aborted"?Rt:c.status==="dirty"?(i.dirty(),J0(c.value)):this._def.out._parseAsync({data:c.value,path:s.path,parent:s})})();{let o=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?Rt:o.status==="dirty"?(i.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:s.path,parent:s})}}static create(t,i){return new n({in:t,out:i,typeName:Ae.ZodPipeline})}},uR=class extends lr{_parse(t){let i=this._def.innerType._parse(t),s=o=>(kT(o)&&(o.value=Object.freeze(o.value)),o);return kD(i)?i.then(o=>s(o)):s(i)}unwrap(){return this._def.innerType}};uR.create=(n,t)=>new uR({innerType:n,typeName:Ae.ZodReadonly,...Zt(t)});var rfi={object:uu.lazycreate},Ae;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(Ae||(Ae={}));var nfi=X0.create,ifi=DD.create,ofi=HD.create,afi=UD.create,sfi=qD.create,cfi=jD.create,ufi=VD.create,lfi=Q0.create,pfi=eR.create,dfi=BD.create,ffi=iv.create,hfi=lh.create,mfi=FD.create,yfi=ov.create,iBt=uu.create,gfi=uu.strictCreate,vfi=tR.create,_fi=HCe.create,bfi=rR.create,Tfi=Rm.create,Sfi=KCe.create,Efi=$D.create,Ofi=zD.create,xfi=YCe.create,Afi=nR.create,Pfi=iR.create,Rfi=oR.create,Nfi=aR.create,Ifi=DT.create,wfi=Kp.create,Cfi=Gp.create,Mfi=Nm.create,Lfi=Kp.createWithPreprocess,kfi=Kee.create;var pu={};fn(pu,{$ZodAny:()=>Kte,$ZodArray:()=>Xte,$ZodAsyncError:()=>Yp,$ZodBase64:()=>Ute,$ZodBase64URL:()=>qte,$ZodBigInt:()=>oU,$ZodBigIntFormat:()=>$te,$ZodBoolean:()=>bR,$ZodCIDRv4:()=>kte,$ZodCIDRv6:()=>Dte,$ZodCUID:()=>Ete,$ZodCUID2:()=>Ote,$ZodCatch:()=>yre,$ZodCheck:()=>Tn,$ZodCheckBigIntFormat:()=>L1e,$ZodCheckEndsWith:()=>G1e,$ZodCheckGreaterThan:()=>pte,$ZodCheckIncludes:()=>z1e,$ZodCheckLengthEquals:()=>V1e,$ZodCheckLessThan:()=>lte,$ZodCheckLowerCase:()=>F1e,$ZodCheckMaxLength:()=>q1e,$ZodCheckMaxSize:()=>k1e,$ZodCheckMimeType:()=>Y1e,$ZodCheckMinLength:()=>j1e,$ZodCheckMinSize:()=>D1e,$ZodCheckMultipleOf:()=>C1e,$ZodCheckNumberFormat:()=>M1e,$ZodCheckOverwrite:()=>W1e,$ZodCheckProperty:()=>K1e,$ZodCheckRegex:()=>B1e,$ZodCheckSizeEquals:()=>U1e,$ZodCheckStartsWith:()=>H1e,$ZodCheckStringFormat:()=>_R,$ZodCheckUpperCase:()=>$1e,$ZodCodec:()=>SR,$ZodCustom:()=>Ore,$ZodCustomStringFormat:()=>Bte,$ZodDate:()=>Zte,$ZodDefault:()=>dre,$ZodDiscriminatedUnion:()=>tre,$ZodE164:()=>jte,$ZodEmail:()=>_te,$ZodEmoji:()=>Tte,$ZodEncodeError:()=>av,$ZodEnum:()=>are,$ZodError:()=>eU,$ZodExactOptional:()=>lre,$ZodFile:()=>cre,$ZodFunction:()=>Tre,$ZodGUID:()=>gte,$ZodIPv4:()=>Cte,$ZodIPv6:()=>Mte,$ZodISODate:()=>Nte,$ZodISODateTime:()=>Rte,$ZodISODuration:()=>wte,$ZodISOTime:()=>Ite,$ZodIntersection:()=>rre,$ZodJWT:()=>Vte,$ZodKSUID:()=>Pte,$ZodLazy:()=>Ere,$ZodLiteral:()=>sre,$ZodMAC:()=>Lte,$ZodMap:()=>ire,$ZodNaN:()=>gre,$ZodNanoID:()=>Ste,$ZodNever:()=>Wte,$ZodNonOptional:()=>hre,$ZodNull:()=>Gte,$ZodNullable:()=>pre,$ZodNumber:()=>iU,$ZodNumberFormat:()=>Fte,$ZodObject:()=>Qte,$ZodObjectJIT:()=>Q1e,$ZodOptional:()=>sU,$ZodPipe:()=>vre,$ZodPrefault:()=>fre,$ZodPromise:()=>Sre,$ZodReadonly:()=>_re,$ZodRealError:()=>Nc,$ZodRecord:()=>nre,$ZodRegistry:()=>Rre,$ZodSet:()=>ore,$ZodString:()=>fv,$ZodStringFormat:()=>pn,$ZodSuccess:()=>mre,$ZodSymbol:()=>zte,$ZodTemplateLiteral:()=>bre,$ZodTransform:()=>ure,$ZodTuple:()=>aU,$ZodType:()=>It,$ZodULID:()=>xte,$ZodURL:()=>bte,$ZodUUID:()=>vte,$ZodUndefined:()=>Hte,$ZodUnion:()=>TR,$ZodUnknown:()=>Yte,$ZodVoid:()=>Jte,$ZodXID:()=>Ate,$ZodXor:()=>ere,$brand:()=>KD,$constructor:()=>$,$input:()=>Ire,$output:()=>Nre,Doc:()=>nU,JSONSchema:()=>$Ft,JSONSchemaGenerator:()=>vne,NEVER:()=>Yee,TimePrecision:()=>Lre,_any:()=>tne,_array:()=>eMe,_base64:()=>AU,_base64url:()=>PU,_bigint:()=>Yre,_boolean:()=>Gre,_catch:()=>ERn,_check:()=>FFt,_cidrv4:()=>OU,_cidrv6:()=>xU,_coercedBigint:()=>Wre,_coercedBoolean:()=>Kre,_coercedDate:()=>ane,_coercedNumber:()=>Vre,_coercedString:()=>Cre,_cuid:()=>gU,_cuid2:()=>vU,_custom:()=>une,_date:()=>one,_decode:()=>tte,_decodeAsync:()=>nte,_default:()=>bRn,_discriminatedUnion:()=>cRn,_e164:()=>RU,_email:()=>lU,_emoji:()=>mU,_encode:()=>ete,_encodeAsync:()=>rte,_endsWith:()=>GT,_enum:()=>hRn,_file:()=>cne,_float32:()=>Fre,_float64:()=>$re,_gt:()=>Jp,_gte:()=>ya,_guid:()=>xR,_includes:()=>zT,_int:()=>Bre,_int32:()=>zre,_int64:()=>Jre,_intersection:()=>uRn,_ipv4:()=>SU,_ipv6:()=>EU,_isoDate:()=>Dre,_isoDateTime:()=>kre,_isoDuration:()=>qre,_isoTime:()=>Ure,_jwt:()=>NU,_ksuid:()=>TU,_lazy:()=>PRn,_length:()=>yv,_literal:()=>yRn,_lowercase:()=>FT,_lt:()=>Wp,_lte:()=>Cs,_mac:()=>Mre,_map:()=>dRn,_max:()=>Cs,_maxLength:()=>mv,_maxSize:()=>Cm,_mime:()=>KT,_min:()=>ya,_minLength:()=>ph,_minSize:()=>Zp,_multipleOf:()=>wm,_nan:()=>sne,_nanoid:()=>yU,_nativeEnum:()=>mRn,_negative:()=>wU,_never:()=>nne,_nonnegative:()=>MU,_nonoptional:()=>TRn,_nonpositive:()=>CU,_normalize:()=>YT,_null:()=>ene,_nullable:()=>_Rn,_number:()=>jre,_optional:()=>vRn,_overwrite:()=>Hl,_parse:()=>mR,_parseAsync:()=>yR,_pipe:()=>ORn,_positive:()=>IU,_promise:()=>RRn,_property:()=>LU,_readonly:()=>xRn,_record:()=>pRn,_refine:()=>lne,_regex:()=>BT,_safeDecode:()=>ote,_safeDecodeAsync:()=>ste,_safeEncode:()=>ite,_safeEncodeAsync:()=>ate,_safeParse:()=>gR,_safeParseAsync:()=>vR,_set:()=>fRn,_size:()=>hv,_slugify:()=>PR,_startsWith:()=>HT,_string:()=>wre,_stringFormat:()=>XT,_stringbool:()=>hne,_success:()=>SRn,_superRefine:()=>pne,_symbol:()=>Xre,_templateLiteral:()=>ARn,_toLowerCase:()=>JT,_toUpperCase:()=>ZT,_transform:()=>gRn,_trim:()=>WT,_tuple:()=>lRn,_uint32:()=>Hre,_uint64:()=>Zre,_ulid:()=>_U,_undefined:()=>Qre,_union:()=>aRn,_unknown:()=>rne,_uppercase:()=>$T,_url:()=>AR,_uuid:()=>pU,_uuidv4:()=>dU,_uuidv6:()=>fU,_uuidv7:()=>hU,_void:()=>ine,_xid:()=>bU,_xor:()=>sRn,clone:()=>Xo,config:()=>Ti,createStandardJSONSchemaMethod:()=>RR,createToJSONSchemaMethod:()=>tMe,decode:()=>gBt,decodeAsync:()=>_Bt,describe:()=>dne,encode:()=>yBt,encodeAsync:()=>vBt,extractDefs:()=>vv,finalize:()=>_v,flattenError:()=>fR,formatError:()=>hR,globalConfig:()=>GD,globalRegistry:()=>Qo,initializeContext:()=>gv,isValidBase64:()=>X1e,isValidBase64URL:()=>BBt,isValidJWT:()=>FBt,locales:()=>OR,meta:()=>fne,parse:()=>qT,parseAsync:()=>jT,prettifyError:()=>Qee,process:()=>sn,regexes:()=>Ic,registry:()=>uU,safeDecode:()=>TBt,safeDecodeAsync:()=>EBt,safeEncode:()=>bBt,safeEncodeAsync:()=>SBt,safeParse:()=>pv,safeParseAsync:()=>dv,toDotPath:()=>mBt,toJSONSchema:()=>QT,treeifyError:()=>Xee,util:()=>Ee,version:()=>J1e});var Yee=Object.freeze({status:"aborted"});function $(n,t,i){function s(e,a){if(e._zod||Object.defineProperty(e,"_zod",{value:{def:a,constr:r,traits:new Set},enumerable:!1}),e._zod.traits.has(n))return;e._zod.traits.add(n),t(e,a);let u=r.prototype,l=Object.keys(u);for(let p=0;p<l.length;p++){let d=l[p];d in e||(e[d]=u[d].bind(e))}}let o=i?.Parent??Object;class c extends o{}Object.defineProperty(c,"name",{value:n});function r(e){var a;let u=i?.Parent?new c:this;s(u,e),(a=u._zod).deferred??(a.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(r,"init",{value:s}),Object.defineProperty(r,Symbol.hasInstance,{value:e=>i?.Parent&&e instanceof i.Parent?!0:e?._zod?.traits?.has(n)}),Object.defineProperty(r,"name",{value:n}),r}var KD=Symbol("zod_brand"),Yp=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},av=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},GD={};function Ti(n){return n&&Object.assign(GD,n),GD}var Ee={};fn(Ee,{BIGINT_FORMAT_RANGES:()=>n1e,Class:()=>JCe,NUMBER_FORMAT_RANGES:()=>r1e,aborted:()=>lv,allowsEval:()=>QCe,assert:()=>SPn,assertEqual:()=>vPn,assertIs:()=>bPn,assertNever:()=>TPn,assertNotEqual:()=>_Pn,assignProp:()=>cv,base64ToUint8Array:()=>dBt,base64urlToUint8Array:()=>MPn,cached:()=>pR,captureStackTrace:()=>Jee,cleanEnum:()=>CPn,cleanRegex:()=>JD,clone:()=>Xo,cloneDef:()=>OPn,createTransparentProxy:()=>IPn,defineLazy:()=>Xt,esc:()=>Wee,escapeRegex:()=>zl,extend:()=>cBt,finalizeIssue:()=>Rc,floatSafeRemainder:()=>ZCe,getElementAtPath:()=>xPn,getEnumValues:()=>WD,getLengthableOrigin:()=>QD,getParsedType:()=>NPn,getSizableOrigin:()=>XD,hexToUint8Array:()=>kPn,isObject:()=>UT,isPlainObject:()=>uv,issue:()=>dR,joinValues:()=>te,jsonStringifyReplacer:()=>lR,merge:()=>wPn,mergeDefs:()=>Im,normalizeParams:()=>Pe,nullish:()=>sv,numKeys:()=>RPn,objectClone:()=>EPn,omit:()=>sBt,optionalKeys:()=>t1e,parsedType:()=>Oe,partial:()=>lBt,pick:()=>aBt,prefixIssues:()=>lu,primitiveTypes:()=>e1e,promiseAllObject:()=>APn,propertyKeyTypes:()=>ZD,randomString:()=>PPn,required:()=>pBt,safeExtend:()=>uBt,shallowClone:()=>Zee,slugify:()=>XCe,stringifyPrimitive:()=>Te,uint8ArrayToBase64:()=>fBt,uint8ArrayToBase64url:()=>LPn,uint8ArrayToHex:()=>DPn,unwrapMessage:()=>YD});function vPn(n){return n}function _Pn(n){return n}function bPn(n){}function TPn(n){throw new Error("Unexpected value in exhaustive check")}function SPn(n){}function WD(n){let t=Object.values(n).filter(s=>typeof s=="number");return Object.entries(n).filter(([s,o])=>t.indexOf(+s)===-1).map(([s,o])=>o)}function te(n,t="|"){return n.map(i=>Te(i)).join(t)}function lR(n,t){return typeof t=="bigint"?t.toString():t}function pR(n){return{get value(){{let i=n();return Object.defineProperty(this,"value",{value:i}),i}throw new Error("cached value already set")}}}function sv(n){return n==null}function JD(n){let t=n.startsWith("^")?1:0,i=n.endsWith("$")?n.length-1:n.length;return n.slice(t,i)}function ZCe(n,t){let i=(n.toString().split(".")[1]||"").length,s=t.toString(),o=(s.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(s)){let a=s.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}let c=i>o?i:o,r=Number.parseInt(n.toFixed(c).replace(".","")),e=Number.parseInt(t.toFixed(c).replace(".",""));return r%e/10**c}var oBt=Symbol("evaluating");function Xt(n,t,i){let s;Object.defineProperty(n,t,{get(){if(s!==oBt)return s===void 0&&(s=oBt,s=i()),s},set(o){Object.defineProperty(n,t,{value:o})},configurable:!0})}function EPn(n){return Object.create(Object.getPrototypeOf(n),Object.getOwnPropertyDescriptors(n))}function cv(n,t,i){Object.defineProperty(n,t,{value:i,writable:!0,enumerable:!0,configurable:!0})}function Im(...n){let t={};for(let i of n){let s=Object.getOwnPropertyDescriptors(i);Object.assign(t,s)}return Object.defineProperties({},t)}function OPn(n){return Im(n._zod.def)}function xPn(n,t){return t?t.reduce((i,s)=>i?.[s],n):n}function APn(n){let t=Object.keys(n),i=t.map(s=>n[s]);return Promise.all(i).then(s=>{let o={};for(let c=0;c<t.length;c++)o[t[c]]=s[c];return o})}function PPn(n=10){let t="abcdefghijklmnopqrstuvwxyz",i="";for(let s=0;s<n;s++)i+=t[Math.floor(Math.random()*t.length)];return i}function Wee(n){return JSON.stringify(n)}function XCe(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Jee="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function UT(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var QCe=pR(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});function uv(n){if(UT(n)===!1)return!1;let t=n.constructor;if(t===void 0||typeof t!="function")return!0;let i=t.prototype;return!(UT(i)===!1||Object.prototype.hasOwnProperty.call(i,"isPrototypeOf")===!1)}function Zee(n){return uv(n)?{...n}:Array.isArray(n)?[...n]:n}function RPn(n){let t=0;for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&t++;return t}var NPn=n=>{let t=typeof n;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(n)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(n)?"array":n===null?"null":n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?"promise":typeof Map<"u"&&n instanceof Map?"map":typeof Set<"u"&&n instanceof Set?"set":typeof Date<"u"&&n instanceof Date?"date":typeof File<"u"&&n instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},ZD=new Set(["string","number","symbol"]),e1e=new Set(["string","number","bigint","boolean","symbol","undefined"]);function zl(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xo(n,t,i){let s=new n._zod.constr(t??n._zod.def);return(!t||i?.parent)&&(s._zod.parent=n),s}function Pe(n){let t=n;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function IPn(n){let t;return new Proxy({},{get(i,s,o){return t??(t=n()),Reflect.get(t,s,o)},set(i,s,o,c){return t??(t=n()),Reflect.set(t,s,o,c)},has(i,s){return t??(t=n()),Reflect.has(t,s)},deleteProperty(i,s){return t??(t=n()),Reflect.deleteProperty(t,s)},ownKeys(i){return t??(t=n()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(i,s){return t??(t=n()),Reflect.getOwnPropertyDescriptor(t,s)},defineProperty(i,s,o){return t??(t=n()),Reflect.defineProperty(t,s,o)}})}function Te(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function t1e(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}var r1e={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},n1e={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function aBt(n,t){let i=n._zod.def,s=i.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let c=Im(n._zod.def,{get shape(){let r={};for(let e in t){if(!(e in i.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&(r[e]=i.shape[e])}return cv(this,"shape",r),r},checks:[]});return Xo(n,c)}function sBt(n,t){let i=n._zod.def,s=i.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let c=Im(n._zod.def,{get shape(){let r={...n._zod.def.shape};for(let e in t){if(!(e in i.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return cv(this,"shape",r),r},checks:[]});return Xo(n,c)}function cBt(n,t){if(!uv(t))throw new Error("Invalid input to extend: expected a plain object");let i=n._zod.def.checks;if(i&&i.length>0){let c=n._zod.def.shape;for(let r in t)if(Object.getOwnPropertyDescriptor(c,r)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=Im(n._zod.def,{get shape(){let c={...n._zod.def.shape,...t};return cv(this,"shape",c),c}});return Xo(n,o)}function uBt(n,t){if(!uv(t))throw new Error("Invalid input to safeExtend: expected a plain object");let i=Im(n._zod.def,{get shape(){let s={...n._zod.def.shape,...t};return cv(this,"shape",s),s}});return Xo(n,i)}function wPn(n,t){let i=Im(n._zod.def,{get shape(){let s={...n._zod.def.shape,...t._zod.def.shape};return cv(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:[]});return Xo(n,i)}function lBt(n,t,i){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let r=Im(t._zod.def,{get shape(){let e=t._zod.def.shape,a={...e};if(i)for(let u in i){if(!(u in e))throw new Error(`Unrecognized key: "${u}"`);i[u]&&(a[u]=n?new n({type:"optional",innerType:e[u]}):e[u])}else for(let u in e)a[u]=n?new n({type:"optional",innerType:e[u]}):e[u];return cv(this,"shape",a),a},checks:[]});return Xo(t,r)}function pBt(n,t,i){let s=Im(t._zod.def,{get shape(){let o=t._zod.def.shape,c={...o};if(i)for(let r in i){if(!(r in c))throw new Error(`Unrecognized key: "${r}"`);i[r]&&(c[r]=new n({type:"nonoptional",innerType:o[r]}))}else for(let r in o)c[r]=new n({type:"nonoptional",innerType:o[r]});return cv(this,"shape",c),c}});return Xo(t,s)}function lv(n,t=0){if(n.aborted===!0)return!0;for(let i=t;i<n.issues.length;i++)if(n.issues[i]?.continue!==!0)return!0;return!1}function lu(n,t){return t.map(i=>{var s;return(s=i).path??(s.path=[]),i.path.unshift(n),i})}function YD(n){return typeof n=="string"?n:n?.message}function Rc(n,t,i){let s={...n,path:n.path??[]};if(!n.message){let o=YD(n.inst?._zod.def?.error?.(n))??YD(t?.error?.(n))??YD(i.customError?.(n))??YD(i.localeError?.(n))??"Invalid input";s.message=o}return delete s.inst,delete s.continue,t?.reportInput||delete s.input,s}function XD(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function QD(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Oe(n){let t=typeof n;switch(t){case"number":return Number.isNaN(n)?"nan":"number";case"object":{if(n===null)return"null";if(Array.isArray(n))return"array";let i=n;if(i&&Object.getPrototypeOf(i)!==Object.prototype&&"constructor"in i&&i.constructor)return i.constructor.name}}return t}function dR(...n){let[t,i,s]=n;return typeof t=="string"?{message:t,code:"custom",input:i,inst:s}:{...t}}function CPn(n){return Object.entries(n).filter(([t,i])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function dBt(n){let t=atob(n),i=new Uint8Array(t.length);for(let s=0;s<t.length;s++)i[s]=t.charCodeAt(s);return i}function fBt(n){let t="";for(let i=0;i<n.length;i++)t+=String.fromCharCode(n[i]);return btoa(t)}function MPn(n){let t=n.replace(/-/g,"+").replace(/_/g,"/"),i="=".repeat((4-t.length%4)%4);return dBt(t+i)}function LPn(n){return fBt(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function kPn(n){let t=n.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let i=new Uint8Array(t.length/2);for(let s=0;s<t.length;s+=2)i[s/2]=Number.parseInt(t.slice(s,s+2),16);return i}function DPn(n){return Array.from(n).map(t=>t.toString(16).padStart(2,"0")).join("")}var JCe=class{constructor(...t){}};var hBt=(n,t)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:t,enumerable:!1}),n.message=JSON.stringify(t,lR,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},eU=$("$ZodError",hBt),Nc=$("$ZodError",hBt,{Parent:Error});function fR(n,t=i=>i.message){let i={},s=[];for(let o of n.issues)o.path.length>0?(i[o.path[0]]=i[o.path[0]]||[],i[o.path[0]].push(t(o))):s.push(t(o));return{formErrors:s,fieldErrors:i}}function hR(n,t=i=>i.message){let i={_errors:[]},s=o=>{for(let c of o.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(r=>s({issues:r}));else if(c.code==="invalid_key")s({issues:c.issues});else if(c.code==="invalid_element")s({issues:c.issues});else if(c.path.length===0)i._errors.push(t(c));else{let r=i,e=0;for(;e<c.path.length;){let a=c.path[e];e===c.path.length-1?(r[a]=r[a]||{_errors:[]},r[a]._errors.push(t(c))):r[a]=r[a]||{_errors:[]},r=r[a],e++}}};return s(n),i}function Xee(n,t=i=>i.message){let i={errors:[]},s=(o,c=[])=>{var r,e;for(let a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(u=>s({issues:u},a.path));else if(a.code==="invalid_key")s({issues:a.issues},a.path);else if(a.code==="invalid_element")s({issues:a.issues},a.path);else{let u=[...c,...a.path];if(u.length===0){i.errors.push(t(a));continue}let l=i,p=0;for(;p<u.length;){let d=u[p],h=p===u.length-1;typeof d=="string"?(l.properties??(l.properties={}),(r=l.properties)[d]??(r[d]={errors:[]}),l=l.properties[d]):(l.items??(l.items=[]),(e=l.items)[d]??(e[d]={errors:[]}),l=l.items[d]),h&&l.errors.push(t(a)),p++}}};return s(n),i}function mBt(n){let t=[],i=n.map(s=>typeof s=="object"?s.key:s);for(let s of i)typeof s=="number"?t.push(`[${s}]`):typeof s=="symbol"?t.push(`[${JSON.stringify(String(s))}]`):/[^\w$]/.test(s)?t.push(`[${JSON.stringify(s)}]`):(t.length&&t.push("."),t.push(s));return t.join("")}function Qee(n){let t=[],i=[...n.issues].sort((s,o)=>(s.path??[]).length-(o.path??[]).length);for(let s of i)t.push(`\u2716 ${s.message}`),s.path?.length&&t.push(` \u2192 at ${mBt(s.path)}`);return t.join(`
255
255
  `)}var mR=n=>(t,i,s,o)=>{let c=s?Object.assign(s,{async:!1}):{async:!1},r=t._zod.run({value:i,issues:[]},c);if(r instanceof Promise)throw new Yp;if(r.issues.length){let e=new(o?.Err??n)(r.issues.map(a=>Rc(a,c,Ti())));throw Jee(e,o?.callee),e}return r.value},qT=mR(Nc),yR=n=>async(t,i,s,o)=>{let c=s?Object.assign(s,{async:!0}):{async:!0},r=t._zod.run({value:i,issues:[]},c);if(r instanceof Promise&&(r=await r),r.issues.length){let e=new(o?.Err??n)(r.issues.map(a=>Rc(a,c,Ti())));throw Jee(e,o?.callee),e}return r.value},jT=yR(Nc),gR=n=>(t,i,s)=>{let o=s?{...s,async:!1}:{async:!1},c=t._zod.run({value:i,issues:[]},o);if(c instanceof Promise)throw new Yp;return c.issues.length?{success:!1,error:new(n??eU)(c.issues.map(r=>Rc(r,o,Ti())))}:{success:!0,data:c.value}},pv=gR(Nc),vR=n=>async(t,i,s)=>{let o=s?Object.assign(s,{async:!0}):{async:!0},c=t._zod.run({value:i,issues:[]},o);return c instanceof Promise&&(c=await c),c.issues.length?{success:!1,error:new n(c.issues.map(r=>Rc(r,o,Ti())))}:{success:!0,data:c.value}},dv=vR(Nc),ete=n=>(t,i,s)=>{let o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return mR(n)(t,i,o)},yBt=ete(Nc),tte=n=>(t,i,s)=>mR(n)(t,i,s),gBt=tte(Nc),rte=n=>async(t,i,s)=>{let o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return yR(n)(t,i,o)},vBt=rte(Nc),nte=n=>async(t,i,s)=>yR(n)(t,i,s),_Bt=nte(Nc),ite=n=>(t,i,s)=>{let o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return gR(n)(t,i,o)},bBt=ite(Nc),ote=n=>(t,i,s)=>gR(n)(t,i,s),TBt=ote(Nc),ate=n=>async(t,i,s)=>{let o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return vR(n)(t,i,o)},SBt=ate(Nc),ste=n=>async(t,i,s)=>vR(n)(t,i,s),EBt=ste(Nc);var Ic={};fn(Ic,{base64:()=>_1e,base64url:()=>cte,bigint:()=>x1e,boolean:()=>P1e,browserEmail:()=>HPn,cidrv4:()=>g1e,cidrv6:()=>v1e,cuid:()=>i1e,cuid2:()=>o1e,date:()=>T1e,datetime:()=>E1e,domain:()=>YPn,duration:()=>l1e,e164:()=>b1e,email:()=>d1e,emoji:()=>f1e,extendedDuration:()=>qPn,guid:()=>p1e,hex:()=>WPn,hostname:()=>KPn,html5Email:()=>FPn,idnEmail:()=>zPn,integer:()=>A1e,ipv4:()=>h1e,ipv6:()=>m1e,ksuid:()=>c1e,lowercase:()=>I1e,mac:()=>y1e,md5_base64:()=>ZPn,md5_base64url:()=>XPn,md5_hex:()=>JPn,nanoid:()=>u1e,null:()=>R1e,number:()=>ute,rfc5322Email:()=>$Pn,sha1_base64:()=>e0n,sha1_base64url:()=>t0n,sha1_hex:()=>QPn,sha256_base64:()=>n0n,sha256_base64url:()=>i0n,sha256_hex:()=>r0n,sha384_base64:()=>a0n,sha384_base64url:()=>s0n,sha384_hex:()=>o0n,sha512_base64:()=>u0n,sha512_base64url:()=>l0n,sha512_hex:()=>c0n,string:()=>O1e,time:()=>S1e,ulid:()=>a1e,undefined:()=>N1e,unicodeEmail:()=>OBt,uppercase:()=>w1e,uuid:()=>VT,uuid4:()=>jPn,uuid6:()=>VPn,uuid7:()=>BPn,xid:()=>s1e});var i1e=/^[cC][^\s-]{8,}$/,o1e=/^[0-9a-z]+$/,a1e=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,s1e=/^[0-9a-vA-V]{20}$/,c1e=/^[A-Za-z0-9]{27}$/,u1e=/^[a-zA-Z0-9_-]{21}$/,l1e=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qPn=/^[-+]?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)?)??$/,p1e=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,VT=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,jPn=VT(4),VPn=VT(6),BPn=VT(7),d1e=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,FPn=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,$Pn=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,OBt=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,zPn=OBt,HPn=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,GPn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function f1e(){return new RegExp(GPn,"u")}var h1e=/^(?:(?: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])$/,m1e=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,y1e=n=>{let t=zl(n??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},g1e=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,v1e=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_1e=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,cte=/^[A-Za-z0-9_-]*$/,KPn=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,YPn=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,b1e=/^\+[1-9]\d{6,14}$/,xBt="(?:(?:\\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])))",T1e=new RegExp(`^${xBt}$`);function ABt(n){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${t}`:n.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${n.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function S1e(n){return new RegExp(`^${ABt(n)}$`)}function E1e(n){let t=ABt({precision:n.precision}),i=["Z"];n.local&&i.push(""),n.offset&&i.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let s=`${t}(?:${i.join("|")})`;return new RegExp(`^${xBt}T(?:${s})$`)}var O1e=n=>{let t=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},x1e=/^-?\d+n?$/,A1e=/^-?\d+$/,ute=/^-?\d+(?:\.\d+)?$/,P1e=/^(?:true|false)$/i,R1e=/^null$/i;var N1e=/^undefined$/i;var I1e=/^[^A-Z]*$/,w1e=/^[^a-z]*$/,WPn=/^[0-9a-fA-F]*$/;function tU(n,t){return new RegExp(`^[A-Za-z0-9+/]{${n}}${t}$`)}function rU(n){return new RegExp(`^[A-Za-z0-9_-]{${n}}$`)}var JPn=/^[0-9a-fA-F]{32}$/,ZPn=tU(22,"=="),XPn=rU(22),QPn=/^[0-9a-fA-F]{40}$/,e0n=tU(27,"="),t0n=rU(27),r0n=/^[0-9a-fA-F]{64}$/,n0n=tU(43,"="),i0n=rU(43),o0n=/^[0-9a-fA-F]{96}$/,a0n=tU(64,""),s0n=rU(64),c0n=/^[0-9a-fA-F]{128}$/,u0n=tU(86,"=="),l0n=rU(86);var Tn=$("$ZodCheck",(n,t)=>{var i;n._zod??(n._zod={}),n._zod.def=t,(i=n._zod).onattach??(i.onattach=[])}),RBt={number:"number",bigint:"bigint",object:"date"},lte=$("$ZodCheckLessThan",(n,t)=>{Tn.init(n,t);let i=RBt[typeof t.value];n._zod.onattach.push(s=>{let o=s._zod.bag,c=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<c&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),n._zod.check=s=>{(t.inclusive?s.value<=t.value:s.value<t.value)||s.issues.push({origin:i,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),pte=$("$ZodCheckGreaterThan",(n,t)=>{Tn.init(n,t);let i=RBt[typeof t.value];n._zod.onattach.push(s=>{let o=s._zod.bag,c=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>c&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),n._zod.check=s=>{(t.inclusive?s.value>=t.value:s.value>t.value)||s.issues.push({origin:i,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),C1e=$("$ZodCheckMultipleOf",(n,t)=>{Tn.init(n,t),n._zod.onattach.push(i=>{var s;(s=i._zod.bag).multipleOf??(s.multipleOf=t.value)}),n._zod.check=i=>{if(typeof i.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof i.value=="bigint"?i.value%t.value===BigInt(0):ZCe(i.value,t.value)===0)||i.issues.push({origin:typeof i.value,code:"not_multiple_of",divisor:t.value,input:i.value,inst:n,continue:!t.abort})}}),M1e=$("$ZodCheckNumberFormat",(n,t)=>{Tn.init(n,t),t.format=t.format||"float64";let i=t.format?.includes("int"),s=i?"int":"number",[o,c]=r1e[t.format];n._zod.onattach.push(r=>{let e=r._zod.bag;e.format=t.format,e.minimum=o,e.maximum=c,i&&(e.pattern=A1e)}),n._zod.check=r=>{let e=r.value;if(i){if(!Number.isInteger(e)){r.issues.push({expected:s,format:t.format,code:"invalid_type",continue:!1,input:e,inst:n});return}if(!Number.isSafeInteger(e)){e>0?r.issues.push({input:e,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,inclusive:!0,continue:!t.abort}):r.issues.push({input:e,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,inclusive:!0,continue:!t.abort});return}}e<o&&r.issues.push({origin:"number",input:e,code:"too_small",minimum:o,inclusive:!0,inst:n,continue:!t.abort}),e>c&&r.issues.push({origin:"number",input:e,code:"too_big",maximum:c,inclusive:!0,inst:n,continue:!t.abort})}}),L1e=$("$ZodCheckBigIntFormat",(n,t)=>{Tn.init(n,t);let[i,s]=n1e[t.format];n._zod.onattach.push(o=>{let c=o._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s}),n._zod.check=o=>{let c=o.value;c<i&&o.issues.push({origin:"bigint",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),c>s&&o.issues.push({origin:"bigint",input:c,code:"too_big",maximum:s,inclusive:!0,inst:n,continue:!t.abort})}}),k1e=$("$ZodCheckMaxSize",(n,t)=>{var i;Tn.init(n,t),(i=n._zod.def).when??(i.when=s=>{let o=s.value;return!sv(o)&&o.size!==void 0}),n._zod.onattach.push(s=>{let o=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(s._zod.bag.maximum=t.maximum)}),n._zod.check=s=>{let o=s.value;o.size<=t.maximum||s.issues.push({origin:XD(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:n,continue:!t.abort})}}),D1e=$("$ZodCheckMinSize",(n,t)=>{var i;Tn.init(n,t),(i=n._zod.def).when??(i.when=s=>{let o=s.value;return!sv(o)&&o.size!==void 0}),n._zod.onattach.push(s=>{let o=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(s._zod.bag.minimum=t.minimum)}),n._zod.check=s=>{let o=s.value;o.size>=t.minimum||s.issues.push({origin:XD(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:n,continue:!t.abort})}}),U1e=$("$ZodCheckSizeEquals",(n,t)=>{var i;Tn.init(n,t),(i=n._zod.def).when??(i.when=s=>{let o=s.value;return!sv(o)&&o.size!==void 0}),n._zod.onattach.push(s=>{let o=s._zod.bag;o.minimum=t.size,o.maximum=t.size,o.size=t.size}),n._zod.check=s=>{let o=s.value,c=o.size;if(c===t.size)return;let r=c>t.size;s.issues.push({origin:XD(o),...r?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:s.value,inst:n,continue:!t.abort})}}),q1e=$("$ZodCheckMaxLength",(n,t)=>{var i;Tn.init(n,t),(i=n._zod.def).when??(i.when=s=>{let o=s.value;return!sv(o)&&o.length!==void 0}),n._zod.onattach.push(s=>{let o=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(s._zod.bag.maximum=t.maximum)}),n._zod.check=s=>{let o=s.value;if(o.length<=t.maximum)return;let r=QD(o);s.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:n,continue:!t.abort})}}),j1e=$("$ZodCheckMinLength",(n,t)=>{var i;Tn.init(n,t),(i=n._zod.def).when??(i.when=s=>{let o=s.value;return!sv(o)&&o.length!==void 0}),n._zod.onattach.push(s=>{let o=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(s._zod.bag.minimum=t.minimum)}),n._zod.check=s=>{let o=s.value;if(o.length>=t.minimum)return;let r=QD(o);s.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:n,continue:!t.abort})}}),V1e=$("$ZodCheckLengthEquals",(n,t)=>{var i;Tn.init(n,t),(i=n._zod.def).when??(i.when=s=>{let o=s.value;return!sv(o)&&o.length!==void 0}),n._zod.onattach.push(s=>{let o=s._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),n._zod.check=s=>{let o=s.value,c=o.length;if(c===t.length)return;let r=QD(o),e=c>t.length;s.issues.push({origin:r,...e?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:n,continue:!t.abort})}}),_R=$("$ZodCheckStringFormat",(n,t)=>{var i,s;Tn.init(n,t),n._zod.onattach.push(o=>{let c=o._zod.bag;c.format=t.format,t.pattern&&(c.patterns??(c.patterns=new Set),c.patterns.add(t.pattern))}),t.pattern?(i=n._zod).check??(i.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:n,continue:!t.abort})}):(s=n._zod).check??(s.check=()=>{})}),B1e=$("$ZodCheckRegex",(n,t)=>{_R.init(n,t),n._zod.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:"regex",input:i.value,pattern:t.pattern.toString(),inst:n,continue:!t.abort})}}),F1e=$("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=I1e),_R.init(n,t)}),$1e=$("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=w1e),_R.init(n,t)}),z1e=$("$ZodCheckIncludes",(n,t)=>{Tn.init(n,t);let i=zl(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position}}${i}`:i);t.pattern=s,n._zod.onattach.push(o=>{let c=o._zod.bag;c.patterns??(c.patterns=new Set),c.patterns.add(s)}),n._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:n,continue:!t.abort})}}),H1e=$("$ZodCheckStartsWith",(n,t)=>{Tn.init(n,t);let i=new RegExp(`^${zl(t.prefix)}.*`);t.pattern??(t.pattern=i),n._zod.onattach.push(s=>{let o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),n._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:n,continue:!t.abort})}}),G1e=$("$ZodCheckEndsWith",(n,t)=>{Tn.init(n,t);let i=new RegExp(`.*${zl(t.suffix)}$`);t.pattern??(t.pattern=i),n._zod.onattach.push(s=>{let o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),n._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:n,continue:!t.abort})}});function PBt(n,t,i){n.issues.length&&t.issues.push(...lu(i,n.issues))}var K1e=$("$ZodCheckProperty",(n,t)=>{Tn.init(n,t),n._zod.check=i=>{let s=t.schema._zod.run({value:i.value[t.property],issues:[]},{});if(s instanceof Promise)return s.then(o=>PBt(o,i,t.property));PBt(s,i,t.property)}}),Y1e=$("$ZodCheckMimeType",(n,t)=>{Tn.init(n,t);let i=new Set(t.mime);n._zod.onattach.push(s=>{s._zod.bag.mime=t.mime}),n._zod.check=s=>{i.has(s.value.type)||s.issues.push({code:"invalid_value",values:t.mime,input:s.value.type,inst:n,continue:!t.abort})}}),W1e=$("$ZodCheckOverwrite",(n,t)=>{Tn.init(n,t),n._zod.check=i=>{i.value=t.tx(i.value)}});var nU=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let s=t.split(`
256
256
  `).filter(r=>r),o=Math.min(...s.map(r=>r.length-r.trimStart().length)),c=s.map(r=>r.slice(o)).map(r=>" ".repeat(this.indent*2)+r);for(let r of c)this.content.push(r)}compile(){let t=Function,i=this?.args,o=[...(this?.content??[""]).map(c=>` ${c}`)];return new t(...i,o.join(`
257
257
  `))}};var J1e={major:4,minor:3,patch:6};var It=$("$ZodType",(n,t)=>{var i;n??(n={}),n._zod.def=t,n._zod.bag=n._zod.bag||{},n._zod.version=J1e;let s=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&s.unshift(n);for(let o of s)for(let c of o._zod.onattach)c(n);if(s.length===0)(i=n._zod).deferred??(i.deferred=[]),n._zod.deferred?.push(()=>{n._zod.run=n._zod.parse});else{let o=(r,e,a)=>{let u=lv(r),l;for(let p of e){if(p._zod.def.when){if(!p._zod.def.when(r))continue}else if(u)continue;let d=r.issues.length,h=p._zod.check(r);if(h instanceof Promise&&a?.async===!1)throw new Yp;if(l||h instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await h,r.issues.length!==d&&(u||(u=lv(r,d)))});else{if(r.issues.length===d)continue;u||(u=lv(r,d))}}return l?l.then(()=>r):r},c=(r,e,a)=>{if(lv(r))return r.aborted=!0,r;let u=o(e,s,a);if(u instanceof Promise){if(a.async===!1)throw new Yp;return u.then(l=>n._zod.parse(l,a))}return n._zod.parse(u,a)};n._zod.run=(r,e)=>{if(e.skipChecks)return n._zod.parse(r,e);if(e.direction==="backward"){let u=n._zod.parse({value:r.value,issues:[]},{...e,skipChecks:!0});return u instanceof Promise?u.then(l=>c(l,r,e)):c(u,r,e)}let a=n._zod.parse(r,e);if(a instanceof Promise){if(e.async===!1)throw new Yp;return a.then(u=>o(u,s,e))}return o(a,s,e)}}Xt(n,"~standard",()=>({validate:o=>{try{let c=pv(n,o);return c.success?{value:c.data}:{issues:c.error?.issues}}catch{return dv(n,o).then(r=>r.success?{value:r.data}:{issues:r.error?.issues})}},vendor:"zod",version:1}))}),fv=$("$ZodString",(n,t)=>{It.init(n,t),n._zod.pattern=[...n?._zod.bag?.patterns??[]].pop()??O1e(n._zod.bag),n._zod.parse=(i,s)=>{if(t.coerce)try{i.value=String(i.value)}catch{}return typeof i.value=="string"||i.issues.push({expected:"string",code:"invalid_type",input:i.value,inst:n}),i}}),pn=$("$ZodStringFormat",(n,t)=>{_R.init(n,t),fv.init(n,t)}),gte=$("$ZodGUID",(n,t)=>{t.pattern??(t.pattern=p1e),pn.init(n,t)}),vte=$("$ZodUUID",(n,t)=>{if(t.version){let s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=VT(s))}else t.pattern??(t.pattern=VT());pn.init(n,t)}),_te=$("$ZodEmail",(n,t)=>{t.pattern??(t.pattern=d1e),pn.init(n,t)}),bte=$("$ZodURL",(n,t)=>{pn.init(n,t),n._zod.check=i=>{try{let s=i.value.trim(),o=new URL(s);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||i.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:i.value,inst:n,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||i.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:i.value,inst:n,continue:!t.abort})),t.normalize?i.value=o.href:i.value=s;return}catch{i.issues.push({code:"invalid_format",format:"url",input:i.value,inst:n,continue:!t.abort})}}}),Tte=$("$ZodEmoji",(n,t)=>{t.pattern??(t.pattern=f1e()),pn.init(n,t)}),Ste=$("$ZodNanoID",(n,t)=>{t.pattern??(t.pattern=u1e),pn.init(n,t)}),Ete=$("$ZodCUID",(n,t)=>{t.pattern??(t.pattern=i1e),pn.init(n,t)}),Ote=$("$ZodCUID2",(n,t)=>{t.pattern??(t.pattern=o1e),pn.init(n,t)}),xte=$("$ZodULID",(n,t)=>{t.pattern??(t.pattern=a1e),pn.init(n,t)}),Ate=$("$ZodXID",(n,t)=>{t.pattern??(t.pattern=s1e),pn.init(n,t)}),Pte=$("$ZodKSUID",(n,t)=>{t.pattern??(t.pattern=c1e),pn.init(n,t)}),Rte=$("$ZodISODateTime",(n,t)=>{t.pattern??(t.pattern=E1e(t)),pn.init(n,t)}),Nte=$("$ZodISODate",(n,t)=>{t.pattern??(t.pattern=T1e),pn.init(n,t)}),Ite=$("$ZodISOTime",(n,t)=>{t.pattern??(t.pattern=S1e(t)),pn.init(n,t)}),wte=$("$ZodISODuration",(n,t)=>{t.pattern??(t.pattern=l1e),pn.init(n,t)}),Cte=$("$ZodIPv4",(n,t)=>{t.pattern??(t.pattern=h1e),pn.init(n,t),n._zod.bag.format="ipv4"}),Mte=$("$ZodIPv6",(n,t)=>{t.pattern??(t.pattern=m1e),pn.init(n,t),n._zod.bag.format="ipv6",n._zod.check=i=>{try{new URL(`http://[${i.value}]`)}catch{i.issues.push({code:"invalid_format",format:"ipv6",input:i.value,inst:n,continue:!t.abort})}}}),Lte=$("$ZodMAC",(n,t)=>{t.pattern??(t.pattern=y1e(t.delimiter)),pn.init(n,t),n._zod.bag.format="mac"}),kte=$("$ZodCIDRv4",(n,t)=>{t.pattern??(t.pattern=g1e),pn.init(n,t)}),Dte=$("$ZodCIDRv6",(n,t)=>{t.pattern??(t.pattern=v1e),pn.init(n,t),n._zod.check=i=>{let s=i.value.split("/");try{if(s.length!==2)throw new Error;let[o,c]=s;if(!c)throw new Error;let r=Number(c);if(`${r}`!==c)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${o}]`)}catch{i.issues.push({code:"invalid_format",format:"cidrv6",input:i.value,inst:n,continue:!t.abort})}}});function X1e(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}var Ute=$("$ZodBase64",(n,t)=>{t.pattern??(t.pattern=_1e),pn.init(n,t),n._zod.bag.contentEncoding="base64",n._zod.check=i=>{X1e(i.value)||i.issues.push({code:"invalid_format",format:"base64",input:i.value,inst:n,continue:!t.abort})}});function BBt(n){if(!cte.test(n))return!1;let t=n.replace(/[-_]/g,s=>s==="-"?"+":"/"),i=t.padEnd(Math.ceil(t.length/4)*4,"=");return X1e(i)}var qte=$("$ZodBase64URL",(n,t)=>{t.pattern??(t.pattern=cte),pn.init(n,t),n._zod.bag.contentEncoding="base64url",n._zod.check=i=>{BBt(i.value)||i.issues.push({code:"invalid_format",format:"base64url",input:i.value,inst:n,continue:!t.abort})}}),jte=$("$ZodE164",(n,t)=>{t.pattern??(t.pattern=b1e),pn.init(n,t)});function FBt(n,t=null){try{let i=n.split(".");if(i.length!==3)return!1;let[s]=i;if(!s)return!1;let o=JSON.parse(atob(s));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var Vte=$("$ZodJWT",(n,t)=>{pn.init(n,t),n._zod.check=i=>{FBt(i.value,t.alg)||i.issues.push({code:"invalid_format",format:"jwt",input:i.value,inst:n,continue:!t.abort})}}),Bte=$("$ZodCustomStringFormat",(n,t)=>{pn.init(n,t),n._zod.check=i=>{t.fn(i.value)||i.issues.push({code:"invalid_format",format:t.format,input:i.value,inst:n,continue:!t.abort})}}),iU=$("$ZodNumber",(n,t)=>{It.init(n,t),n._zod.pattern=n._zod.bag.pattern??ute,n._zod.parse=(i,s)=>{if(t.coerce)try{i.value=Number(i.value)}catch{}let o=i.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return i;let c=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return i.issues.push({expected:"number",code:"invalid_type",input:o,inst:n,...c?{received:c}:{}}),i}}),Fte=$("$ZodNumberFormat",(n,t)=>{M1e.init(n,t),iU.init(n,t)}),bR=$("$ZodBoolean",(n,t)=>{It.init(n,t),n._zod.pattern=P1e,n._zod.parse=(i,s)=>{if(t.coerce)try{i.value=!!i.value}catch{}let o=i.value;return typeof o=="boolean"||i.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:n}),i}}),oU=$("$ZodBigInt",(n,t)=>{It.init(n,t),n._zod.pattern=x1e,n._zod.parse=(i,s)=>{if(t.coerce)try{i.value=BigInt(i.value)}catch{}return typeof i.value=="bigint"||i.issues.push({expected:"bigint",code:"invalid_type",input:i.value,inst:n}),i}}),$te=$("$ZodBigIntFormat",(n,t)=>{L1e.init(n,t),oU.init(n,t)}),zte=$("$ZodSymbol",(n,t)=>{It.init(n,t),n._zod.parse=(i,s)=>{let o=i.value;return typeof o=="symbol"||i.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:n}),i}}),Hte=$("$ZodUndefined",(n,t)=>{It.init(n,t),n._zod.pattern=N1e,n._zod.values=new Set([void 0]),n._zod.optin="optional",n._zod.optout="optional",n._zod.parse=(i,s)=>{let o=i.value;return typeof o>"u"||i.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:n}),i}}),Gte=$("$ZodNull",(n,t)=>{It.init(n,t),n._zod.pattern=R1e,n._zod.values=new Set([null]),n._zod.parse=(i,s)=>{let o=i.value;return o===null||i.issues.push({expected:"null",code:"invalid_type",input:o,inst:n}),i}}),Kte=$("$ZodAny",(n,t)=>{It.init(n,t),n._zod.parse=i=>i}),Yte=$("$ZodUnknown",(n,t)=>{It.init(n,t),n._zod.parse=i=>i}),Wte=$("$ZodNever",(n,t)=>{It.init(n,t),n._zod.parse=(i,s)=>(i.issues.push({expected:"never",code:"invalid_type",input:i.value,inst:n}),i)}),Jte=$("$ZodVoid",(n,t)=>{It.init(n,t),n._zod.parse=(i,s)=>{let o=i.value;return typeof o>"u"||i.issues.push({expected:"void",code:"invalid_type",input:o,inst:n}),i}}),Zte=$("$ZodDate",(n,t)=>{It.init(n,t),n._zod.parse=(i,s)=>{if(t.coerce)try{i.value=new Date(i.value)}catch{}let o=i.value,c=o instanceof Date;return c&&!Number.isNaN(o.getTime())||i.issues.push({expected:"date",code:"invalid_type",input:o,...c?{received:"Invalid Date"}:{},inst:n}),i}});function IBt(n,t,i){n.issues.length&&t.issues.push(...lu(i,n.issues)),t.value[i]=n.value}var Xte=$("$ZodArray",(n,t)=>{It.init(n,t),n._zod.parse=(i,s)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({expected:"array",code:"invalid_type",input:o,inst:n}),i;i.value=Array(o.length);let c=[];for(let r=0;r<o.length;r++){let e=o[r],a=t.element._zod.run({value:e,issues:[]},s);a instanceof Promise?c.push(a.then(u=>IBt(u,i,r))):IBt(a,i,r)}return c.length?Promise.all(c).then(()=>i):i}});function yte(n,t,i,s,o){if(n.issues.length){if(o&&!(i in s))return;t.issues.push(...lu(i,n.issues))}n.value===void 0?i in s&&(t.value[i]=void 0):t.value[i]=n.value}function $Bt(n){let t=Object.keys(n.shape);for(let s of t)if(!n.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${s}": expected a Zod schema`);let i=t1e(n.shape);return{...n,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function zBt(n,t,i,s,o,c){let r=[],e=o.keySet,a=o.catchall._zod,u=a.def.type,l=a.optout==="optional";for(let p in t){if(e.has(p))continue;if(u==="never"){r.push(p);continue}let d=a.run({value:t[p],issues:[]},s);d instanceof Promise?n.push(d.then(h=>yte(h,i,p,t,l))):yte(d,i,p,t,l)}return r.length&&i.issues.push({code:"unrecognized_keys",keys:r,input:t,inst:c}),n.length?Promise.all(n).then(()=>i):i}var Qte=$("$ZodObject",(n,t)=>{if(It.init(n,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let a={...e};return Object.defineProperty(t,"shape",{value:a}),a}})}let s=pR(()=>$Bt(t));Xt(n._zod,"propValues",()=>{let e=t.shape,a={};for(let u in e){let l=e[u]._zod;if(l.values){a[u]??(a[u]=new Set);for(let p of l.values)a[u].add(p)}}return a});let o=UT,c=t.catchall,r;n._zod.parse=(e,a)=>{r??(r=s.value);let u=e.value;if(!o(u))return e.issues.push({expected:"object",code:"invalid_type",input:u,inst:n}),e;e.value={};let l=[],p=r.shape;for(let d of r.keys){let h=p[d],m=h._zod.optout==="optional",y=h._zod.run({value:u[d],issues:[]},a);y instanceof Promise?l.push(y.then(g=>yte(g,e,d,u,m))):yte(y,e,d,u,m)}return c?zBt(l,u,e,a,s.value,n):l.length?Promise.all(l).then(()=>e):e}}),Q1e=$("$ZodObjectJIT",(n,t)=>{Qte.init(n,t);let i=n._zod.parse,s=pR(()=>$Bt(t)),o=d=>{let h=new nU(["shape","payload","ctx"]),m=s.value,y=k=>{let U=Wee(k);return`shape[${U}]._zod.run({ value: input[${U}], issues: [] }, ctx)`};h.write("const input = payload.value;");let g=Object.create(null),C=0;for(let k of m.keys)g[k]=`key_${C++}`;h.write("const newResult = {};");for(let k of m.keys){let U=g[k],B=Wee(k),re=d[k]?._zod?.optout==="optional";h.write(`const ${U} = ${y(k)};`),re?h.write(`
@@ -381,7 +381,7 @@ ${u}
381
381
  , companyName = tostring(customDimensions.companyName)
382
382
  | summarize count() by aadTenantId, companyName
383
383
  | project companyName, aadTenantId, count_`;i&&(s+=`
384
- | where companyName contains "${i}"`);let o=await this.executeQuery(s,!1,!1);if(o.type==="error")throw new Error(o.summary);let c=(o.rows||[]).map(r=>({companyName:r[0],aadTenantId:r[1],occurrences:r[2]}));return{daysBack:t,totalMappings:c.length,mappings:c.sort((r,e)=>e.occurrences-r.occurrences),usage:{summary:`Found ${c.length} company-to-tenant mappings in the last ${t} days`,recommendation:'Use aadTenantId for filtering telemetry queries. Example: | where tostring(customDimensions.aadTenantId) == "{tenantId}"'}}}detectInitialProfile(){let t=require("fs"),i=require("path");try{let s=i.join(this.config.workspacePath,".bctb-config.json");if(!t.existsSync(s))return null;let o=t.readFileSync(s,"utf8"),c=JSON.parse(o);return!c.profiles||Object.keys(c.profiles).length===0?null:process.env.BCTB_PROFILE||c.defaultProfile||"default"}catch{return null}}switchProfile(t){let i=require("fs"),s=require("path");try{let o=s.join(this.config.workspacePath,".bctb-config.json");if(!i.existsSync(o))return{success:!1,error:"No .bctb-config.json found - cannot switch profiles in single-config mode"};let c=i.readFileSync(o,"utf8"),r=JSON.parse(c);if(!r.profiles||Object.keys(r.profiles).length===0)return{success:!1,error:"Config file has no profiles defined - cannot switch profiles"};let e=Object.keys(r.profiles).filter(l=>!l.startsWith("_"));if(!e.includes(t))return{success:!1,error:`Profile '${t}' not found. Available profiles: ${e.join(", ")}`};let a=Wv(o,t,this.isStdioMode);if(!a)return{success:!1,error:`Failed to load configuration for profile '${t}'`};a.port=this.config.port;let u=this.activeProfileName||this.config.connectionName;return this.config=a,this.configErrors=Ym(this.config),this.activeProfileName=t,this.services.auth=new Dt.AuthService(this.config),this.services.kusto=new Dt.KustoService(this.config.applicationInsightsAppId,this.config.kustoClusterUrl,this.services.usageTelemetry),this.services.cache=new Dt.CacheService(this.config.workspacePath,this.config.cacheTTLSeconds,this.config.cacheEnabled),this.services.queries=new Dt.QueriesService(this.config.workspacePath,this.config.queriesFolder),this.services.references=new Dt.ReferencesService(this.config.references,this.services.cache),this.isStdioMode||(console.error(`[Profile] Switched from '${u}' to '${t}'`),console.error(`[Profile] Connection: ${this.config.connectionName}`),console.error(`[Profile] App Insights ID: ${this.config.applicationInsightsAppId||"(not set)"}`)),{success:!0,previousProfile:u,currentProfile:{name:t,connectionName:this.config.connectionName,applicationInsightsAppId:this.config.applicationInsightsAppId,authFlow:this.config.authFlow},message:`Successfully switched to profile '${t}' (${this.config.connectionName})`,configValid:this.configErrors.length===0,configErrors:this.configErrors.length>0?this.configErrors:void 0}}catch(o){return{success:!1,error:`Failed to switch profile: ${o.message}`}}}listProfiles(){let t=require("fs"),i=require("path");try{let s=i.join(this.config.workspacePath,".bctb-config.json");if(!t.existsSync(s))return{profileMode:"single",currentProfile:{name:"default",connectionName:this.config.connectionName,isActive:!0},availableProfiles:[],message:"Single profile mode - using workspace settings or environment variables"};let o=t.readFileSync(s,"utf8"),c=JSON.parse(o);if(!c.profiles||Object.keys(c.profiles).length===0)return{profileMode:"single",currentProfile:{name:"default",connectionName:c.connectionName||this.config.connectionName,isActive:!0},availableProfiles:[],message:"Single profile mode - config file has no profiles object"};let r=this.activeProfileName||process.env.BCTB_PROFILE||c.defaultProfile||"default",e=Object.entries(c.profiles).filter(([u])=>!u.startsWith("_")).map(([u,l])=>({name:u,connectionName:l.connectionName||u,isActive:u===r,applicationInsightsAppId:l.applicationInsightsAppId,authFlow:l.authFlow,extends:l.extends}));return{profileMode:"multi",currentProfile:e.find(u=>u.isActive)||{name:r,connectionName:this.config.connectionName,isActive:!0},availableProfiles:e.filter(u=>!u.isActive),totalProfiles:e.length,message:`Multi-profile configuration with ${e.length} profile(s). Currently using: ${r}`,usage:{summary:"This workspace has multiple telemetry profiles configured for different customers/environments",switchingInstructions:"To switch profiles, use the switch_profile tool with the profile name. In VS Code, you can also use the status bar or command palette.",noteForQueries:"All queries execute against the currently active profile. Use list_profiles to confirm which profile is active before running queries."}}}catch(s){return{profileMode:"error",error:s.message,currentProfile:{name:"unknown",connectionName:this.config.connectionName,isActive:!0},availableProfiles:[]}}}async generateRecommendations(t,i){let s=[];return t.includes("where")&&!t.includes("| where")&&s.push('Consider using the pipe operator before "where" for better performance'),t.includes("*")&&s.push("Specify explicit columns instead of * for better performance"),t.toLowerCase().includes("ago(")||s.push("Consider adding a time range filter (e.g., | where timestamp > ago(1d))"),i.rows&&i.rows.length>1e4&&s.push('Large result set. Consider adding "| take 100" or similar limit'),s}};function Ikn(n){switch(n.type){case"string":return n.enum?On.enum(n.enum).optional():On.string().optional();case"number":return On.number().optional();case"boolean":return On.boolean().optional();case"array":return n.items?.type==="string"?On.array(On.string()).optional():On.array(On.unknown()).optional();case"object":return On.record(On.string(),On.unknown()).optional();default:return On.unknown().optional()}}function wkn(n){switch(n.type){case"string":return n.enum?On.enum(n.enum):On.string();case"number":return On.number();case"boolean":return On.boolean();case"array":return n.items?.type==="string"?On.array(On.string()):On.array(On.unknown());case"object":return On.record(On.string(),On.unknown());default:return On.unknown()}}function Ckn(n){let t={},i=new Set(n.inputSchema.required||[]);for(let[s,o]of Object.entries(n.inputSchema.properties))i.has(s)?t[s]=wkn(o):t[s]=Ikn(o);return t}function Mkn(n){let t=new poe({name:"BC Telemetry Buddy",version:Ia},{capabilities:{tools:{listChanged:!0},logging:{}}});for(let i of hoe){let s=Ckn(i);t.registerTool(i.name,{description:i.description,inputSchema:s,annotations:i.annotations?{readOnlyHint:i.annotations.readOnlyHint,destructiveHint:i.annotations.destructiveHint,idempotentHint:i.annotations.idempotentHint,openWorldHint:i.annotations.openWorldHint}:void 0},async o=>{try{let c=await n.executeToolCall(i.name,o);return{content:[{type:"text",text:typeof c=="string"?c:JSON.stringify(c,null,2)}]}}catch(c){return{content:[{type:"text",text:`Error: ${c.message}`}],isError:!0}}})}return t}async function tGt(n){console.log=(...a)=>{process.stderr.write("[MCP] "+a.join(" ")+`
384
+ | where companyName contains "${i}"`);let o=await this.executeQuery(s,!1,!1);if(o.type==="error")throw new Error(o.summary);let c=(o.rows||[]).map(r=>({companyName:r[0],aadTenantId:r[1],occurrences:r[2]}));return{daysBack:t,totalMappings:c.length,mappings:c.sort((r,e)=>e.occurrences-r.occurrences),usage:{summary:`Found ${c.length} company-to-tenant mappings in the last ${t} days`,recommendation:'Use aadTenantId for filtering telemetry queries. Example: | where tostring(customDimensions.aadTenantId) == "{tenantId}"'}}}detectInitialProfile(){let t=require("fs"),i=require("path");try{let s=this.config.configFilePath||i.join(this.config.workspacePath,".bctb-config.json");if(!t.existsSync(s))return null;let o=t.readFileSync(s,"utf8"),c=JSON.parse(o);return!c.profiles||Object.keys(c.profiles).length===0?null:process.env.BCTB_PROFILE||c.defaultProfile||"default"}catch{return null}}switchProfile(t){let i=require("fs"),s=require("path");try{let o=this.config.configFilePath||s.join(this.config.workspacePath,".bctb-config.json");if(!i.existsSync(o))return{success:!1,error:"No .bctb-config.json found - cannot switch profiles in single-config mode"};let c=i.readFileSync(o,"utf8"),r=JSON.parse(c);if(!r.profiles||Object.keys(r.profiles).length===0)return{success:!1,error:"Config file has no profiles defined - cannot switch profiles"};let e=Object.keys(r.profiles).filter(l=>!l.startsWith("_"));if(!e.includes(t))return{success:!1,error:`Profile '${t}' not found. Available profiles: ${e.join(", ")}`};let a=Wv(o,t,this.isStdioMode);if(!a)return{success:!1,error:`Failed to load configuration for profile '${t}'`};a.port=this.config.port;let u=this.activeProfileName||this.config.connectionName;return this.config=a,this.configErrors=Ym(this.config),this.activeProfileName=t,this.services.auth=new Dt.AuthService(this.config),this.services.kusto=new Dt.KustoService(this.config.applicationInsightsAppId,this.config.kustoClusterUrl,this.services.usageTelemetry),this.services.cache=new Dt.CacheService(this.config.workspacePath,this.config.cacheTTLSeconds,this.config.cacheEnabled),this.services.queries=new Dt.QueriesService(this.config.workspacePath,this.config.queriesFolder),this.services.references=new Dt.ReferencesService(this.config.references,this.services.cache),this.isStdioMode||(console.error(`[Profile] Switched from '${u}' to '${t}'`),console.error(`[Profile] Connection: ${this.config.connectionName}`),console.error(`[Profile] App Insights ID: ${this.config.applicationInsightsAppId||"(not set)"}`)),{success:!0,previousProfile:u,currentProfile:{name:t,connectionName:this.config.connectionName,applicationInsightsAppId:this.config.applicationInsightsAppId,authFlow:this.config.authFlow},message:`Successfully switched to profile '${t}' (${this.config.connectionName})`,configValid:this.configErrors.length===0,configErrors:this.configErrors.length>0?this.configErrors:void 0}}catch(o){return{success:!1,error:`Failed to switch profile: ${o.message}`}}}listProfiles(){let t=require("fs"),i=require("path");try{let s=this.config.configFilePath||i.join(this.config.workspacePath,".bctb-config.json");if(!t.existsSync(s))return{profileMode:"single",currentProfile:{name:"default",connectionName:this.config.connectionName,isActive:!0},availableProfiles:[],message:"Single profile mode - using workspace settings or environment variables"};let o=t.readFileSync(s,"utf8"),c=JSON.parse(o);if(!c.profiles||Object.keys(c.profiles).length===0)return{profileMode:"single",currentProfile:{name:"default",connectionName:c.connectionName||this.config.connectionName,isActive:!0},availableProfiles:[],message:"Single profile mode - config file has no profiles object"};let r=this.activeProfileName||process.env.BCTB_PROFILE||c.defaultProfile||"default",e=Object.entries(c.profiles).filter(([u])=>!u.startsWith("_")).map(([u,l])=>({name:u,connectionName:l.connectionName||u,isActive:u===r,applicationInsightsAppId:l.applicationInsightsAppId,authFlow:l.authFlow,extends:l.extends}));return{profileMode:"multi",currentProfile:e.find(u=>u.isActive)||{name:r,connectionName:this.config.connectionName,isActive:!0},availableProfiles:e.filter(u=>!u.isActive),totalProfiles:e.length,message:`Multi-profile configuration with ${e.length} profile(s). Currently using: ${r}`,usage:{summary:"This workspace has multiple telemetry profiles configured for different customers/environments",switchingInstructions:"To switch profiles, use the switch_profile tool with the profile name. In VS Code, you can also use the status bar or command palette.",noteForQueries:"All queries execute against the currently active profile. Use list_profiles to confirm which profile is active before running queries."}}}catch(s){return{profileMode:"error",error:s.message,currentProfile:{name:"unknown",connectionName:this.config.connectionName,isActive:!0},availableProfiles:[]}}}async generateRecommendations(t,i){let s=[];return t.includes("where")&&!t.includes("| where")&&s.push('Consider using the pipe operator before "where" for better performance'),t.includes("*")&&s.push("Specify explicit columns instead of * for better performance"),t.toLowerCase().includes("ago(")||s.push("Consider adding a time range filter (e.g., | where timestamp > ago(1d))"),i.rows&&i.rows.length>1e4&&s.push('Large result set. Consider adding "| take 100" or similar limit'),s}};function Ikn(n){switch(n.type){case"string":return n.enum?On.enum(n.enum).optional():On.string().optional();case"number":return On.number().optional();case"boolean":return On.boolean().optional();case"array":return n.items?.type==="string"?On.array(On.string()).optional():On.array(On.unknown()).optional();case"object":return On.record(On.string(),On.unknown()).optional();default:return On.unknown().optional()}}function wkn(n){switch(n.type){case"string":return n.enum?On.enum(n.enum):On.string();case"number":return On.number();case"boolean":return On.boolean();case"array":return n.items?.type==="string"?On.array(On.string()):On.array(On.unknown());case"object":return On.record(On.string(),On.unknown());default:return On.unknown()}}function Ckn(n){let t={},i=new Set(n.inputSchema.required||[]);for(let[s,o]of Object.entries(n.inputSchema.properties))i.has(s)?t[s]=wkn(o):t[s]=Ikn(o);return t}function Mkn(n){let t=new poe({name:"BC Telemetry Buddy",version:Ia},{capabilities:{tools:{listChanged:!0},logging:{}}});for(let i of hoe){let s=Ckn(i);t.registerTool(i.name,{description:i.description,inputSchema:s,annotations:i.annotations?{readOnlyHint:i.annotations.readOnlyHint,destructiveHint:i.annotations.destructiveHint,idempotentHint:i.annotations.idempotentHint,openWorldHint:i.annotations.openWorldHint}:void 0},async o=>{try{let c=await n.executeToolCall(i.name,o);return{content:[{type:"text",text:typeof c=="string"?c:JSON.stringify(c,null,2)}]}}catch(c){return{content:[{type:"text",text:`Error: ${c.message}`}],isError:!0}}})}return t}async function tGt(n){console.log=(...a)=>{process.stderr.write("[MCP] "+a.join(" ")+`
385
385
  `)},console.error=(...a)=>{process.stderr.write("[MCP] "+a.join(" ")+`
386
386
  `)},console.error(`BC Telemetry Buddy MCP Server v${Ia} starting (stdio mode)...`);let t;if(n)t=n;else{let a=Wv(void 0,void 0,!0);a?t=a:t=nj()}let i=Ym(t),s=eGt(t,!0),o=new moe(t,s,!0,i),c=Mkn(o);if(i.length===0)try{await s.auth.authenticate()}catch{}let r=new foe;await c.connect(r);let e=async()=>{await s.usageTelemetry.flush(),await c.close(),process.exit(0)};process.on("SIGINT",e),process.on("SIGTERM",e)}var yoe=class{app;config;auth;kusto;cache;queries;references;configErrors;usageTelemetry;sessionId;installationId;isStdioMode;activeProfileName=null;constructor(t,i){if(this.app=(0,dUe.default)(),this.isStdioMode=i==="stdio",t)this.config=t;else{let c=Wv(void 0,void 0,this.isStdioMode);c?(this.isStdioMode||console.error("[Config] Using config file (.bctb-config.json)"),this.config=c):(this.isStdioMode||console.error("[Config] No config file found, using environment variables"),this.config=nj())}this.configErrors=Ym(this.config),this.isStdioMode||(console.error("=== BC Telemetry Buddy MCP Server ==="),console.error(`Connection: ${this.config.connectionName}`),console.error(`Workspace: ${this.config.workspacePath}`),console.error(`App Insights ID: ${this.config.applicationInsightsAppId||"(not set)"}`),console.error(`Kusto URL: ${this.config.kustoClusterUrl||"(not set)"}`),console.error(`Auth flow: ${this.config.authFlow}`),console.error(`Cache: ${this.config.cacheEnabled?`enabled (TTL: ${this.config.cacheTTLSeconds}s)`:"disabled"}`),console.error(`PII sanitization: ${this.config.removePII?"enabled":"disabled"}`),console.error(`External references: ${this.config.references.length}`),this.configErrors.length>0?console.error(`\u26A0\uFE0F Configuration incomplete (${this.configErrors.length} issues)`):console.error("\u2705 Configuration valid"),console.error(`=====================================
387
387
  `)),this.sessionId=fUe.randomUUID();let s=yr.TELEMETRY_CONNECTION_STRING;if(s&&!0){let c=zee(s,this.config.workspacePath,Ia);if(c){this.installationId=MD(this.config.workspacePath),this.usageTelemetry=new yr.RateLimitedUsageTelemetry(c,{maxIdenticalErrors:10,maxEventsPerSession:2e3,maxEventsPerMinute:200}),this.isStdioMode||console.error(`\u2713 Usage Telemetry initialized
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bc-telemetry-buddy-mcp",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Model Context Protocol server for Business Central telemetry",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/server.js",