@github/copilot 0.0.343-7 → 0.0.343-8

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/sdk/index.js CHANGED
@@ -303,7 +303,7 @@ Found ${h.length} review comment(s):
303
303
  `}else p+=`
304
304
  No review comments found.`,m.warning&&(p+=`
305
305
 
306
- Note: ${m.warning}`);e.debug(`Code review completed: ${p}`);let u=h.map(W=>W.meta?.queryId).filter(W=>!!W&&W.trim().length>0).sort();return{textResultForLlm:p,resultType:"success",sessionLog:p,toolTelemetry:{properties:{commentQueryNames:u.join(", "),codeReviewResult:"success",codeReviewModel:G},restrictedProperties:{prTitle:s.prTitle,filesReviewed:i.map(W=>W.path).join(", ")},metrics:{reviewedFiles:i.length,commentsGenerated:h.length,commentsExcluded:m.alerts.length-h.length}}}}catch(d){let i=IYe(d),b=i?$Ne:`Error during code review: ${d}`;return e.error(b),{textResultForLlm:b,resultType:"failure",error:b,toolTelemetry:{properties:{codeReviewResult:"failure",codeReviewError:b,codeReviewTimedOut:i?"true":"false",codeReviewModel:G},metrics:{},restrictedProperties:{}}}}finally{n.endJob()}},safeForTelemetry:!0}};function ceI(){return"capi-prod-claude-sonnet-4"}async function reI(t,e,I,l,n){try{let c=I.swebench_base_commit||"HEAD~1",r=[];try{await t.stageChanges(e),r=await t.getChangedPaths(e,c)}catch(a){n.debug(`Could not get diff against ${c}, checking for working directory changes: ${a}`);try{let d=(await l.execReturn("git",["diff","--name-only"],{cwd:e})).stdout.trim().split(`
306
+ Note: ${m.warning}`);e.debug(`Code review completed: ${p}`);let u=h.map(W=>W.meta?.queryId).filter(W=>!!W&&W.trim().length>0).sort();return{textResultForLlm:p,resultType:"success",sessionLog:p,toolTelemetry:{properties:{commentQueryNames:u.join(", "),codeReviewResult:"success",codeReviewModel:G},restrictedProperties:{prTitle:s.prTitle,filesReviewed:i.map(W=>W.path).join(", ")},metrics:{reviewedFiles:i.length,commentsGenerated:h.length,commentsExcluded:m.alerts.length-h.length}}}}catch(d){let i=IYe(d),b=i?$Ne:`Error during code review: ${d}`;return e.error(b),{textResultForLlm:b,resultType:"failure",error:b,toolTelemetry:{properties:{codeReviewResult:"failure",codeReviewError:b,codeReviewTimedOut:i?"true":"false",codeReviewModel:G},metrics:{},restrictedProperties:{}}}}finally{n.endJob()}},safeForTelemetry:!0}};function ceI(){return"capi-prod-claude-sonnet-4"}async function reI(t,e,I,l,n){try{let c=I.swebench_base_commit&&I.swebench_base_commit!=="undefined"?I.swebench_base_commit:"HEAD~1",r=[];try{await t.stageChanges(e),r=await t.getChangedPaths(e,c)}catch(a){n.debug(`Could not get diff against ${c}, checking for working directory changes: ${a}`);try{let d=(await l.execReturn("git",["diff","--name-only"],{cwd:e})).stdout.trim().split(`
307
307
  `).filter(m=>m.length>0),b=(await l.execReturn("git",["diff","--cached","--name-only"],{cwd:e})).stdout.trim().split(`
308
308
  `).filter(m=>m.length>0);if(r=[...new Set([...d,...b])],r.length===0)try{r=(await l.execReturn("git",["diff","--name-only",qNe,"HEAD"],{cwd:e})).stdout.trim().split(`
309
309
  `).filter(h=>h.length>0),c=qNe}catch{return n.debug("Could not compare against empty tree"),[]}}catch(G){return n.error(`Error getting working directory changes: ${G}`),[]}}let s=[];for(let a of r)try{let G="";try{let i=Xp(e,a);G=await _Ne(i,"utf-8")}catch{G=""}let d="";try{d=(await l.execReturn("git",["show",`${c}:${a}`],{cwd:e})).stdout}catch{d=""}s.push({path:a,contents:G,baseContents:d,regions:[[1,Math.max(1,G.split(`
@@ -329,12 +329,12 @@ extensions:
329
329
  `,c=t.map(a=>` - [${HEe.stringify(a.path,{lineWidth:0}).trim()}, ${a.startLine}, ${a.endLine}]
330
330
  `).join("");c||(c=` - ["", 0, 0]
331
331
  `);let r=n+c,s=nce.join(l,"pr-diff-range.yml");return lce.writeFileSync(s,r),I(`Wrote pr-diff-range extension pack to ${s}:
332
- ${r}`,8),l}o();import*as h5 from"os";import*as YM from"fs";var FYI=.05,CEe=1024*1024;function JEe(t){let e=h5.platform(),I=QYI(e,t)/(1024*1024),l=AYI(I,e),n=Math.floor(I-l);return t(`Using ${n} MB for CodeQL, out of ${I} MB total.`,8),n}function AYI(t,e){let I=1024*(e==="win32"?1.5:1),l=FYI*Math.max(t-8*1024,0);return I+l}function QYI(t,e){let I=[h5.totalmem()];return t==="linux"&&I.push(...["/sys/fs/cgroup/memory/memory.limit_in_bytes","/sys/fs/cgroup/memory.max"].map(n=>wYI(n,e)).filter(n=>n!==void 0).map(n=>n)),Math.min(...I)}function wYI(t,e){if(!YM.existsSync(t)){e(`While resolving RAM, did not find a cgroup memory limit at ${t}.`,8);return}let I=Number(YM.readFileSync(t,"utf8"));if(!Number.isInteger(I)){e(`While resolving RAM, ignored the file ${t} that may contain a cgroup memory limit as this file did not contain an integer.`,8);return}let l=`${Math.floor(I/(1024*1024))} MiB`;if(I>h5.totalmem()){e(`While resolving RAM, ignored the file ${t} that may contain a cgroup memory limit as its contents ${l} were greater than the total amount of system memory.`,8);return}if(I<CEe){e(`While resolving RAM, ignored a cgroup limit of ${l} in ${t} as it was below ${CEe/(1024*1024)} MiB.`,8);return}return e(`While resolving RAM, found a cgroup limit of ${l} in ${t}.`,8),I}o();import*as TA from"fs";import*as VM from"os";function LEe(t){let e=[VM.cpus().length];return VM.platform()==="linux"&&(e.push(...["/sys/fs/cgroup/cpuset.cpus.effective","/sys/fs/cgroup/cpuset.cpus"].map(l=>EYI(l,t)).filter(l=>l!==void 0&&l>0).map(l=>l)),e.push(...["/sys/fs/cgroup/cpu.max"].map(l=>XYI(l,t)).filter(l=>l!==void 0&&l>0).map(l=>l))),Math.min(...e)}function XYI(t,e){if(!TA.existsSync(t)){e(`While resolving threads, did not find a cgroup CPU file at ${t}.`,8);return}let l=TA.readFileSync(t,"utf-8").split(" ");if(l.length!==2){e(`While resolving threads, did not use cgroup CPU file at ${t} because it contained ${l.length} value(s) rather than the two expected.`,8);return}let n=l[0];if(n==="max")return;let c=l[1],r=Math.floor(parseInt(n)/parseInt(c));return e(`While resolving threads, found a cgroup CPU file with ${r} CPUs in ${t}.`,8),r}function EYI(t,e){if(!TA.existsSync(t)){e(`While resolving threads, did not find a cgroup CPUs file at ${t}.`,8);return}let I=0,l=TA.readFileSync(t,"utf-8").trim();if(l.length!==0){for(let n of l.split(","))if(!n.includes("-"))++I;else{let c=parseInt(n.split("-")[0]),r=parseInt(n.split("-")[1]);I+=r-c+1}return e(`While resolving threads, found a cgroup CPUs file with ${I} CPUs in ${t}.`,8),I}}var jA=class t{constructor(e,I,l,n,c,r){this.exec=e;this.executablePath=I;this.databaseDir=l;this.settings=n;this.sourceRoot=c;this.progressLogger=r;this.ram=this.resolveRam(),this.threads=this.resolveThreads()}static DIFF_INFORMED_FEATURE_FLAG_NAME="copilot_swe_agent_codeql_diff_informed";ram;repositorySizeCache=new Map;threads;async createDatabase(e,I){let l=`${this.databaseDir}/${I}`,n=this.getBuildMode(I);return await this.execCommand(e,["database","create",this.ram,this.threads,"--no-sublanguage-file-coverage","--no-calculate-baseline","--overwrite","--language",I,"--build-mode",n,"--source-root",this.sourceRoot,l]),l}static AUTOBUILD_ONLY_LANGUAGES=["cpp","go","swift"];getBuildMode(e){return t.AUTOBUILD_ONLY_LANGUAGES.includes(e)?"autobuild":"none"}async analyzeDatabase(e,I,l){let n=[];if(El(this.settings,t.DIFF_INFORMED_FEATURE_FLAG_NAME)){let G=DA.mkdtempSync(p5.join(cce.tmpdir(),"codeql-")),d=vEe(l,G,this.progressLogger);this.progressLogger(`Created diff range data extension pack at ${d}`,8),n=["--additional-packs",d,"--extension-packs","codeql-action/pr-diff-range"]}let c=`${this.databaseDir}/${I}`,r=`${c}/results-${I}.json`;await DA.promises.rm(r,{force:!0}),this.progressLogger(`Analyzing database at ${c} for language ${I}`);let s=["database","analyze",this.ram,this.threads,"--format","sarifv2.1.0","--output",r,...n,c,`codeql/${I}-queries`];return await this.execCommand(e,s),new yO(r,this.progressLogger.bind(this)).summarize(I,l)}async version(e){let I=await this.execCommand(e,["version","--format","json"]);try{return JSON.parse(I).version}catch{throw new Error(`Failed to parse CodeQL version output: ${I}`)}}async getRepositorySize(e){return this.repositorySizeCache.has(e)||this.repositorySizeCache.set(e,await this.computeRepositorySize(e)),this.repositorySizeCache.get(e)}async execCommand(e,I){return this.progressLogger(`Executing CodeQL command: ${I}`),(await this.exec.execReturn(this.executablePath,I,{abortSignal:e})).stdout}resolveRam(){try{return`--ram=${JEe(this.progressLogger)}`}catch(e){return this.progressLogger(`Failed to resolve RAM, not passing --ram flag to CodeQL: ${e}`,2),""}}resolveThreads(){try{return`--threads=${LEe(this.progressLogger)}`}catch(e){return this.progressLogger(`Failed to resolve threads, not passing --threads flag to CodeQL: ${e}`,2),""}}getSccExecutablePath(){let e=p5.dirname(this.executablePath),I;switch(cce.platform()){case"win32":I=p5.join(e,"tools/win64/scc.exe");break;case"darwin":I=p5.join(e,"tools/osx64/scc");break;case"linux":I=p5.join(e,"tools/linux64/scc");break;default:return}if(DA.existsSync(I))return I}async computeRepositorySize(e){let I=this.getSccExecutablePath();if(!I){this.progressLogger(`SCC executable not found for platform: ${cce.platform()}`,2);return}let l=LFe(e);if(!l){this.progressLogger(`No file extensions found for language: ${e}`,2);return}let n=["--exclude-dir",UIe.join(","),"--format","json","--include-ext",l.join(","),"--no-complexity","--no-cocomo"],c=kEe.spawn(I,n,{cwd:this.sourceRoot}),r="",s="";c.stdout.on("data",G=>{r+=G}),c.stderr.on("data",G=>{s+=G});let a=await new Promise(G=>{c.on("close",G)});if(a!==0){this.progressLogger(`SCC failed with exit code ${a}: ${s}`,2);return}try{let d=JSON.parse(r).reduce((i,b)=>i+b.Bytes,0);return this.progressLogger(`SCC output for ${e}: ${d} bytes`,4),d}catch(G){this.progressLogger(`Failed to parse SCC output: ${G}`,2);return}}};var xEe="codeql-bundle-linux64.tar.gz",CYI=new w2;async function JYI(t,e){let n=(await new FS({auth:t}).rest.repos.getLatestRelease({owner:"github",repo:"codeql-action"})).data.assets.find(c=>c.name===xEe);if(n)return e(`CodeQL asset ID: ${n.id}`),n.id;throw new Error("CodeQL asset not found")}async function LYI(t,e,I,l){let n=await fetch(`https://api.github.com/repos/github/codeql-action/releases/assets/${t}`,{headers:{Authorization:`token ${I}`,Accept:"application/octet-stream"},redirect:"follow"});if(!n.ok||!n.body)throw new Error(`Failed to download asset: ${n.statusText}`);let c=KA.join(e,xEe),r=Fm.createWriteStream(c,{flags:"wx"});return await vYI(HYI.fromWeb(n.body).pipe(r)),l(`CodeQL downloaded to ${c}`),c}async function kYI(t,e,I){await Fm.promises.mkdir(e,{recursive:!0});try{return await Yle({file:t,cwd:e}),I(`CodeQL unzipped to ${e}`),UEe(e)}catch(l){throw CYI.error(`Error unzipping CodeQL: ${String(l)}`),l}}async function fYI(t,e,I){let l=process.env.GITHUB_TOKEN||r2(I),n=await JYI(l,e),c=xYI(t);await Fm.promises.mkdir(c,{recursive:!0});let r=await LYI(n,c,l,e);return await kYI(r,t,e),await Fm.promises.rm(r),zEe(t)}async function BEe(t,e,I,l,n){let c=BYI(t);await Fm.promises.mkdir(c,{recursive:!0});let r=await zYI(n);if(r)return new jA(l,r,c,I,e,n);let s=zEe(t);if(await rce(s))return n(`CodeQL already exists at ${s}`),new jA(l,s,c,I,e,n);try{let a=await fYI(t,n,I);return new jA(l,a,c,I,e,n)}catch(a){throw n(`Error ensuring CodeQL: ${String(a)}`,1),a}}function xYI(t){return KA.join(t,"codeql-download")}function zEe(t){return KA.join(UEe(t),"codeql")}function UEe(t){return KA.join(t,"codeql")}function BYI(t){return KA.join(t,"dbs")}async function zYI(t){if(!process.env.RUNNER_TOOL_CACHE)return;let e=RM.findAllVersions("CodeQL");if(!e.length)return;let I=e[0],l=RM.find("CodeQL",I,fEe.arch());if(l){let n=KA.join(l,"codeql","codeql");if(t(`CodeQL directory found in toolcache at '${l}'.`),!await rce(n)){let c;throw await rce(l)?c=Fm.readdirSync(l):c=["path does not exist"],new Error(`CodeQL executable not found at '${n}'. Contents of toolcache: '${c.join(", ")}'.`)}return n}}async function rce(t){try{return await Fm.promises.stat(t),!0}catch{return!1}}var yM=class t{constructor(e,I,l,n,c){this.config=e;this.git=I;this.baseCommit=l;this.settings=n;this.logger=c;this.budgeter=hF.createBudgeter(t.TOOL_NAME,n)}static DEFAULT_MAX_REPO_SIZE_BYTES=1e7;static DEFAULT_TIMEOUT_MS=180*1e3;static TOOL_NAME="codeql_checker";static CODEQL_CHECKER_ENABLED_FF="copilot_swe_agent_enable_security_tool";static CODEQL_CHECKER_DISABLED_FF="copilot_swe_agent_enable_security_tool_disabled";static isEnabled(e){return El(e,t.CODEQL_CHECKER_ENABLED_FF)&&!El(e,t.CODEQL_CHECKER_DISABLED_FF)}executor;budgeter;async getCodeQLCheckerTool(){let e=await this.createCodeQLScratchDir(this.config.location);return this.executor=await BEe(e,this.config.location,this.settings,new oW(this.logger),this.logProgress.bind(this)),{name:t.TOOL_NAME,description:`This is a security tool that discovers vulnerabilities in code using CodeQL. It must always be run when there are code changes.
332
+ ${r}`,8),l}o();import*as h5 from"os";import*as YM from"fs";var FYI=.05,CEe=1024*1024;function JEe(t){let e=h5.platform(),I=QYI(e,t)/(1024*1024),l=AYI(I,e),n=Math.floor(I-l);return t(`Using ${n} MB for CodeQL, out of ${I} MB total.`,8),n}function AYI(t,e){let I=1024*(e==="win32"?1.5:1),l=FYI*Math.max(t-8*1024,0);return I+l}function QYI(t,e){let I=[h5.totalmem()];return t==="linux"&&I.push(...["/sys/fs/cgroup/memory/memory.limit_in_bytes","/sys/fs/cgroup/memory.max"].map(n=>wYI(n,e)).filter(n=>n!==void 0).map(n=>n)),Math.min(...I)}function wYI(t,e){if(!YM.existsSync(t)){e(`While resolving RAM, did not find a cgroup memory limit at ${t}.`,8);return}let I=Number(YM.readFileSync(t,"utf8"));if(!Number.isInteger(I)){e(`While resolving RAM, ignored the file ${t} that may contain a cgroup memory limit as this file did not contain an integer.`,8);return}let l=`${Math.floor(I/(1024*1024))} MiB`;if(I>h5.totalmem()){e(`While resolving RAM, ignored the file ${t} that may contain a cgroup memory limit as its contents ${l} were greater than the total amount of system memory.`,8);return}if(I<CEe){e(`While resolving RAM, ignored a cgroup limit of ${l} in ${t} as it was below ${CEe/(1024*1024)} MiB.`,8);return}return e(`While resolving RAM, found a cgroup limit of ${l} in ${t}.`,8),I}o();import*as TA from"fs";import*as VM from"os";function LEe(t){let e=[VM.cpus().length];return VM.platform()==="linux"&&(e.push(...["/sys/fs/cgroup/cpuset.cpus.effective","/sys/fs/cgroup/cpuset.cpus"].map(l=>EYI(l,t)).filter(l=>l!==void 0&&l>0).map(l=>l)),e.push(...["/sys/fs/cgroup/cpu.max"].map(l=>XYI(l,t)).filter(l=>l!==void 0&&l>0).map(l=>l))),Math.min(...e)}function XYI(t,e){if(!TA.existsSync(t)){e(`While resolving threads, did not find a cgroup CPU file at ${t}.`,8);return}let l=TA.readFileSync(t,"utf-8").split(" ");if(l.length!==2){e(`While resolving threads, did not use cgroup CPU file at ${t} because it contained ${l.length} value(s) rather than the two expected.`,8);return}let n=l[0];if(n==="max")return;let c=l[1],r=Math.floor(parseInt(n)/parseInt(c));return e(`While resolving threads, found a cgroup CPU file with ${r} CPUs in ${t}.`,8),r}function EYI(t,e){if(!TA.existsSync(t)){e(`While resolving threads, did not find a cgroup CPUs file at ${t}.`,8);return}let I=0,l=TA.readFileSync(t,"utf-8").trim();if(l.length!==0){for(let n of l.split(","))if(!n.includes("-"))++I;else{let c=parseInt(n.split("-")[0]),r=parseInt(n.split("-")[1]);I+=r-c+1}return e(`While resolving threads, found a cgroup CPUs file with ${I} CPUs in ${t}.`,8),I}}var jA=class t{constructor(e,I,l,n,c,r){this.exec=e;this.executablePath=I;this.databaseDir=l;this.settings=n;this.sourceRoot=c;this.progressLogger=r;this.ram=this.resolveRam(),this.threads=this.resolveThreads()}static DIFF_INFORMED_FEATURE_FLAG_NAME="copilot_swe_agent_codeql_diff_informed";ram;repositorySizeCache=new Map;threads;async createDatabase(e,I){let l=`${this.databaseDir}/${I}`,n=this.getBuildMode(I);return await this.execCommand(e,["database","create",this.ram,this.threads,"--no-sublanguage-file-coverage","--no-calculate-baseline","--overwrite","--language",I,"--build-mode",n,"--source-root",this.sourceRoot,l]),l}static AUTOBUILD_ONLY_LANGUAGES=["cpp","go","swift"];getBuildMode(e){return t.AUTOBUILD_ONLY_LANGUAGES.includes(e)?"autobuild":"none"}async analyzeDatabase(e,I,l){let n=[];if(El(this.settings,t.DIFF_INFORMED_FEATURE_FLAG_NAME)){let G=DA.mkdtempSync(p5.join(cce.tmpdir(),"codeql-")),d=vEe(l,G,this.progressLogger);this.progressLogger(`Created diff range data extension pack at ${d}`,8),n=["--additional-packs",d,"--extension-packs","codeql-action/pr-diff-range"]}let c=`${this.databaseDir}/${I}`,r=`${c}/results-${I}.json`;await DA.promises.rm(r,{force:!0}),this.progressLogger(`Analyzing database at ${c} for language ${I}`);let s=["database","analyze",this.ram,this.threads,"--format","sarifv2.1.0","--output",r,...n,c,`codeql/${I}-queries`];return await this.execCommand(e,s),new yO(r,this.progressLogger.bind(this)).summarize(I,l)}async version(e){let I=await this.execCommand(e,["version","--format","json"]);try{return JSON.parse(I).version}catch{throw new Error(`Failed to parse CodeQL version output: ${I}`)}}async getRepositorySize(e){return this.repositorySizeCache.has(e)||this.repositorySizeCache.set(e,await this.computeRepositorySize(e)),this.repositorySizeCache.get(e)}async execCommand(e,I){let l=I.filter(Boolean);return this.progressLogger(`Executing CodeQL command: ${l}`),(await this.exec.execReturn(this.executablePath,l,{abortSignal:e})).stdout}resolveRam(){try{return`--ram=${JEe(this.progressLogger)}`}catch(e){return this.progressLogger(`Failed to resolve RAM, not passing --ram flag to CodeQL: ${e}`,2),""}}resolveThreads(){try{return`--threads=${LEe(this.progressLogger)}`}catch(e){return this.progressLogger(`Failed to resolve threads, not passing --threads flag to CodeQL: ${e}`,2),""}}getSccExecutablePath(){let e=p5.dirname(this.executablePath),I;switch(cce.platform()){case"win32":I=p5.join(e,"tools/win64/scc.exe");break;case"darwin":I=p5.join(e,"tools/osx64/scc");break;case"linux":I=p5.join(e,"tools/linux64/scc");break;default:return}if(DA.existsSync(I))return I}async computeRepositorySize(e){let I=this.getSccExecutablePath();if(!I){this.progressLogger(`SCC executable not found for platform: ${cce.platform()}`,2);return}let l=LFe(e);if(!l){this.progressLogger(`No file extensions found for language: ${e}`,2);return}let n=["--exclude-dir",UIe.join(","),"--format","json","--include-ext",l.join(","),"--no-complexity","--no-cocomo"],c=kEe.spawn(I,n,{cwd:this.sourceRoot}),r="",s="";c.stdout.on("data",G=>{r+=G}),c.stderr.on("data",G=>{s+=G});let a=await new Promise(G=>{c.on("close",G)});if(a!==0){this.progressLogger(`SCC failed with exit code ${a}: ${s}`,2);return}try{let d=JSON.parse(r).reduce((i,b)=>i+b.Bytes,0);return this.progressLogger(`SCC output for ${e}: ${d} bytes`,4),d}catch(G){this.progressLogger(`Failed to parse SCC output: ${G}`,2);return}}};var xEe="codeql-bundle-linux64.tar.gz",CYI=new w2;async function JYI(t,e){let n=(await new FS({auth:t}).rest.repos.getLatestRelease({owner:"github",repo:"codeql-action"})).data.assets.find(c=>c.name===xEe);if(n)return e(`CodeQL asset ID: ${n.id}`),n.id;throw new Error("CodeQL asset not found")}async function LYI(t,e,I,l){let n=await fetch(`https://api.github.com/repos/github/codeql-action/releases/assets/${t}`,{headers:{Authorization:`token ${I}`,Accept:"application/octet-stream"},redirect:"follow"});if(!n.ok||!n.body)throw new Error(`Failed to download asset: ${n.statusText}`);let c=KA.join(e,xEe),r=Fm.createWriteStream(c,{flags:"wx"});return await vYI(HYI.fromWeb(n.body).pipe(r)),l(`CodeQL downloaded to ${c}`),c}async function kYI(t,e,I){await Fm.promises.mkdir(e,{recursive:!0});try{return await Yle({file:t,cwd:e}),I(`CodeQL unzipped to ${e}`),UEe(e)}catch(l){throw CYI.error(`Error unzipping CodeQL: ${String(l)}`),l}}async function fYI(t,e,I){let l=process.env.GITHUB_TOKEN||r2(I),n=await JYI(l,e),c=xYI(t);await Fm.promises.mkdir(c,{recursive:!0});let r=await LYI(n,c,l,e);return await kYI(r,t,e),await Fm.promises.rm(r),zEe(t)}async function BEe(t,e,I,l,n){let c=BYI(t);await Fm.promises.mkdir(c,{recursive:!0});let r=await zYI(n);if(r)return new jA(l,r,c,I,e,n);let s=zEe(t);if(await rce(s))return n(`CodeQL already exists at ${s}`),new jA(l,s,c,I,e,n);try{let a=await fYI(t,n,I);return new jA(l,a,c,I,e,n)}catch(a){throw n(`Error ensuring CodeQL: ${String(a)}`,1),a}}function xYI(t){return KA.join(t,"codeql-download")}function zEe(t){return KA.join(UEe(t),"codeql")}function UEe(t){return KA.join(t,"codeql")}function BYI(t){return KA.join(t,"dbs")}async function zYI(t){if(!process.env.RUNNER_TOOL_CACHE)return;let e=RM.findAllVersions("CodeQL");if(!e.length)return;let I=e[0],l=RM.find("CodeQL",I,fEe.arch());if(l){let n=KA.join(l,"codeql","codeql");if(t(`CodeQL directory found in toolcache at '${l}'.`),!await rce(n)){let c;throw await rce(l)?c=Fm.readdirSync(l):c=["path does not exist"],new Error(`CodeQL executable not found at '${n}'. Contents of toolcache: '${c.join(", ")}'.`)}return n}}async function rce(t){try{return await Fm.promises.stat(t),!0}catch{return!1}}var yM=class t{constructor(e,I,l,n,c){this.config=e;this.git=I;this.baseCommit=l;this.settings=n;this.logger=c;this.budgeter=hF.createBudgeter(t.TOOL_NAME,n)}static DEFAULT_MAX_REPO_SIZE_BYTES=1e7;static DEFAULT_TIMEOUT_MS=180*1e3;static TOOL_NAME="codeql_checker";static CODEQL_CHECKER_ENABLED_FF="copilot_swe_agent_enable_security_tool";static CODEQL_CHECKER_DISABLED_FF="copilot_swe_agent_enable_security_tool_disabled";static isEnabled(e){return El(e,t.CODEQL_CHECKER_ENABLED_FF)&&!El(e,t.CODEQL_CHECKER_DISABLED_FF)}executor;budgeter;async getCodeQLCheckerTool(){let e=await this.createCodeQLScratchDir(this.config.location);return this.executor=await BEe(e,this.config.location,this.settings,new oW(this.logger),this.logProgress.bind(this)),{name:t.TOOL_NAME,description:`This is a security tool that discovers vulnerabilities in code using CodeQL. It must always be run when there are code changes.
333
333
  It is run after committing all changed code and before the final verification. Feedback from this tool must be incorporated into
334
- the change and then the tool must be re-run.`,input_schema:{type:"object",properties:{}},callback:this.callback.bind(this),safeForTelemetry:!0}}async callback(){let e={},I="unknown",l=Date.now();try{if(!this.executor)throw new Error("CodeQL Executor is not initialized.");let n=this.budgeter.startJob();n.throwIfAborted(),I=await this.executor.version(n),await this.git.stageChanges(this.config.location);let c=await this.git.getDiffRanges(this.config.location,this.baseCommit),r=JFe(c);r.length>0?this.logProgress(`Languages found to analyze: ${r.join(", ")}`):this.logProgress("No languages found to analyze.");let s=[],a=!0;for(let d of r){if(n.throwIfAborted(),!await this.shouldAnalyzeLanguage(this.executor,d)){e[d]={skipped:!0};continue}let i=Date.now();try{await this.executor.createDatabase(n,d),this.logProgress(`Created database for ${d}.`),e[d]={databaseCreationSuccess:!0,databaseCreationTimeMs:Date.now()-i}}catch(m){this.throwIfAbortError(m),a=!1;let h=`Error creating database for ${d}: ${String(m)}`;this.logProgress(h,1),e[d]={databaseCreationError:m instanceof Error?m:new Error(String(m)),databaseCreationSuccess:!1,databaseCreationTimeMs:Date.now()-i};continue}n.throwIfAborted();let b=Date.now();try{let m=await this.executor.analyzeDatabase(n,d,c);s.push(m);let h=m.alerts.length;this.logProgress(`Completed analysis of ${d}. ${h} ${h===1?"alert":"alerts"} found.`),e[d]={...e[d],analysisSuccess:!0,analysisTimeMs:Date.now()-b,analysisRuleIds:m.alerts.flatMap(p=>p.ruleId?[p.ruleId]:[]),querySuite:`${d}-code-scanning`}}catch(m){this.throwIfAbortError(m),a=!1;let h=`Error analyzing database for ${d}: ${String(m)}`;this.logProgress(h,1),e[d]={...e[d],analysisError:m instanceof Error?m:new Error(String(m)),analysisSuccess:!1,analysisTimeMs:Date.now()-b,analysisRuleIds:[]},s.push({language:d,alerts:[],numFilteredAlerts:0})}}let G=this.generateAnalysisReport(s,e);return{resultType:a?"success":"failure",textResultForLlm:G,sessionLog:G,toolTelemetry:{event:"tool_call_executed",properties:{"codeql.version":I},metrics:{"codeql.languages.count":r.length,"codeql.total.alerts":s.reduce((d,i)=>d+i.alerts.length,0),"codeql.duration.ms":Date.now()-l},restrictedProperties:{}}}}catch(n){let c=this.isAbortError(n)?`Operation cancelled due to timeout. Do not re-run the ${t.TOOL_NAME} tool because it will not complete successfully.`:`Error in CodeQL Checker: '${String(n)}'`;this.logProgress(c,1);let r={event:"tool_call_executed",properties:{"codeql.version":I,"codeql.aborted":this.isAbortError(n)?"true":"false"},metrics:{"codeql.languages.count":0,"codeql.total.alerts":0,"codeql.duration.ms":Date.now()-l},restrictedProperties:{"codeql.stack":n instanceof Error?n.stack??"":""}};return wG({telemetry:r},n,"codeql.error"),{resultType:"failure",textResultForLlm:c,sessionLog:c,toolTelemetry:r}}finally{this.budgeter.endJob();let n=this.createTelemetryByLanguage(e,I);for(let c of n)this.config.callback?.progress({kind:"telemetry",telemetry:c})}}generateAnalysisReport(e,I){let l=e.map(r=>{let s=I[r.language];if(s){if("skipped"in s)return`- ${r.language}: Analysis was skipped because the database size is too large.`;if(s.databaseCreationSuccess){if("analysisSuccess"in s&&!s.analysisSuccess)return`- ${r.language}: Analysis failed.`;if(r.alerts.length===0)return`- ${r.language}: No alerts found.`}else return`- ${r.language}: Database creation failed.`}else return`- ${r.language}: No telemetry data available.`;return`- ${r.language}: \`\`\`${JSON.stringify(r,null,2)}\`\`\``}),n=e.reduce((r,s)=>r+s.alerts.length,0),c=e.map(r=>r.language);return c.length===0?"No code changes detected for languages that CodeQL can analyze, so no analysis was performed.":`Analysis Result for '${c.join(", ")}'. Found ${n} alert(s):
334
+ the change and then the tool must be re-run.`,input_schema:{type:"object",properties:{}},callback:this.callback.bind(this),safeForTelemetry:!0}}async callback(){let e={},I="unknown",l=Date.now();try{if(!this.executor)throw new Error("CodeQL Executor is not initialized.");let n=this.budgeter.startJob();n.throwIfAborted(),I=await this.executor.version(n),await this.git.stageChanges(this.config.location);let c=await this.git.getDiffRanges(this.config.location,this.baseCommit),r=JFe(c);r.length>0?this.logProgress(`Languages found to analyze: ${r.join(", ")}`):this.logProgress("No languages found to analyze.");let s=[],a=!0;for(let d of r){if(n.throwIfAborted(),!await this.shouldAnalyzeLanguage(this.executor,d)){e[d]={skipped:!0};continue}let i=Date.now();try{await this.executor.createDatabase(n,d),this.logProgress(`Created database for ${d}.`),e[d]={databaseCreationSuccess:!0,databaseCreationTimeMs:Date.now()-i}}catch(m){a=!1;let h=`Error creating database for ${d}: ${String(m)}`;if(this.logProgress(h,1),e[d]={databaseCreationError:m instanceof Error?m:new Error(String(m)),databaseCreationSuccess:!1,databaseCreationTimeMs:Date.now()-i},this.isAbortError(m))throw e[d].aborted=!0,m;continue}n.throwIfAborted();let b=Date.now();try{let m=await this.executor.analyzeDatabase(n,d,c);s.push(m);let h=m.alerts.length;this.logProgress(`Completed analysis of ${d}. ${h} ${h===1?"alert":"alerts"} found.`),e[d]={...e[d],analysisSuccess:!0,analysisTimeMs:Date.now()-b,analysisRuleIds:m.alerts.flatMap(p=>p.ruleId?[p.ruleId]:[]),querySuite:`${d}-code-scanning`}}catch(m){if(this.isAbortError(m))throw e[d].aborted=!0,m;a=!1;let h=`Error analyzing database for ${d}: ${String(m)}`;this.logProgress(h,1),e[d]={...e[d],analysisError:m instanceof Error?m:new Error(String(m)),analysisSuccess:!1,analysisTimeMs:Date.now()-b,analysisRuleIds:[]},s.push({language:d,alerts:[],numFilteredAlerts:0})}}let G=this.generateAnalysisReport(s,e);return{resultType:a?"success":"failure",textResultForLlm:G,sessionLog:G,toolTelemetry:{event:"tool_call_executed",properties:{"codeql.version":I},metrics:{"codeql.languages.count":r.length,"codeql.total.alerts":s.reduce((d,i)=>d+i.alerts.length,0),"codeql.duration.ms":Date.now()-l},restrictedProperties:{}}}}catch(n){let c=this.isAbortError(n)?`Operation cancelled due to timeout. Do not re-run the ${t.TOOL_NAME} tool because it will not complete successfully.`:`Error in CodeQL Checker: '${String(n)}'`;this.logProgress(c,1);let r={event:"tool_call_executed",properties:{"codeql.version":I,"codeql.aborted":this.isAbortError(n)?"true":"false"},metrics:{"codeql.languages.count":0,"codeql.total.alerts":0,"codeql.duration.ms":Date.now()-l},restrictedProperties:{"codeql.stack":n instanceof Error?n.stack??"":""}};return wG({telemetry:r},n,"codeql.error"),{resultType:"failure",textResultForLlm:c,sessionLog:c,toolTelemetry:r}}finally{this.budgeter.endJob();let n=this.createTelemetryByLanguage(e,I);for(let c of n)this.config.callback?.progress({kind:"telemetry",telemetry:c})}}generateAnalysisReport(e,I){let l=e.map(r=>{let s=I[r.language];if(s){if("skipped"in s)return`- ${r.language}: Analysis was skipped because the database size is too large.`;if(s.databaseCreationSuccess){if("analysisSuccess"in s&&!s.analysisSuccess)return`- ${r.language}: Analysis failed.`;if(r.alerts.length===0)return`- ${r.language}: No alerts found.`}else return`- ${r.language}: Database creation failed.`}else return`- ${r.language}: No telemetry data available.`;return`- ${r.language}: \`\`\`${JSON.stringify(r,null,2)}\`\`\``}),n=e.reduce((r,s)=>r+s.alerts.length,0),c=e.map(r=>r.language);return c.length===0?"No code changes detected for languages that CodeQL can analyze, so no analysis was performed.":`Analysis Result for '${c.join(", ")}'. Found ${n} alert(s):
335
335
 
336
336
  ${l.join(`
337
- `)}`}isAbortError(e){return e instanceof Error&&(e.name==="TimeoutError"||e.name==="AbortError")}throwIfAbortError(e){if(this.isAbortError(e))throw e}async logProgress(e,I=4,l){switch(l&&this.logger.startGroup(l),I){case 8:this.logger.debug(e);break;case 4:this.logger.info(e);break;case 2:this.logger.warning(e);break;case 1:this.logger.error(e);break;default:this.logger.log(e);break}l&&this.logger.endGroup(),this.config.callback&&await this.config.callback?.progress({kind:"log",message:e})}async createCodeQLScratchDir(e){let I=SEe.normalize(SEe.join(e,"..",".codeql-scratch"));return await OEe.promises.mkdir(I,{recursive:!0}),I}createTelemetryByLanguage(e,I){let l=[];for(let[n,c]of Object.entries(e)){if(vFe(c)){let s={event:"codeql-checker-completion",properties:{"codeql.language":n,"codeql.skipped":"true","codeql.version":I},metrics:{},restrictedProperties:{}};l.push(s);continue}let r={event:"codeql-checker-completion",properties:{"codeql.language":n,"codeql.databaseCreationSuccess":c.databaseCreationSuccess?"true":"false","codeql.analysisRuleIds":iA(c)?c.analysisRuleIds.join(","):"","codeql.version":I,"codeql.querySuite":iA(c)?c.querySuite:void 0},metrics:{"codeql.databaseCreationTimeMs":c.databaseCreationTimeMs,"codeql.analysisTimeMs":iA(c)?c.analysisTimeMs:void 0,"codeql.alertCount":iA(c)?c.analysisRuleIds.length:0},restrictedProperties:{}};c.databaseCreationError&&(wG({telemetry:r},c.databaseCreationError,"codeql.databaseCreationError"),r.restrictedProperties["codeql.databaseCreationStack"]=String(c.databaseCreationError.stack)),iA(c)&&(r.properties["codeql.analysisSuccess"]=c.analysisSuccess?"true":"false",c.analysisError&&(wG({telemetry:r},c.analysisError,"codeql.analysisError"),r.restrictedProperties["codeql.analysisStack"]=String(c.analysisError.stack))),l.push(r)}return l}async shouldAnalyzeLanguage(e,I){if(I=="actions")return!0;let l=await e.getRepositorySize(I);if(l===void 0)return!0;let n=l<=t.DEFAULT_MAX_REPO_SIZE_BYTES;return n||this.logProgress(`Skipping analysis for ${I} because the repository size is ${l} bytes, which exceeds the limit of ${t.DEFAULT_MAX_REPO_SIZE_BYTES} bytes.`,2),n}};o();o();var PA=["actions","composer","erlang","go","maven","npm","nuget","other","pip","pub","rubygems","rust","swift"],UYI={npm_and_yarn:"npm",bundler:"rubygems",pip:"pip",maven:"maven",composer:"composer",go_modules:"go",github_actions:"actions",cargo:"rust",pub:"pub",swift:"swift",nuget:"nuget",gradle:"maven",hex:"erlang",other:"other"};function TEe(t){if(!t)return;let e=t.toLowerCase();return UYI[e]}async function jEe(t,e,I){let l;if(PA.includes(e.ecosystem)?l=e.ecosystem:l=TEe(e.ecosystem),!l)return I?.warning(`Unsupported ecosystem '${e.ecosystem}' for dependency ${e.name}; skipping advisory lookup.`),[];let n={affects:`${e.name}@${e.version}`,ecosystem:l},[c,r,s]=await Promise.all([t.securityAdvisories.listGlobalAdvisories({...n,severity:"high"}),t.securityAdvisories.listGlobalAdvisories({...n,severity:"critical"}),t.securityAdvisories.listGlobalAdvisories({...n,type:"malware"})]);return[...c.data,...r.data,...s.data].flatMap(G=>G.vulnerabilities?.map(d=>({name:e.name,version:e.version,summary:G.summary,ecosystem:d.package?.ecosystem??"unknown",affectedVersions:d.vulnerable_version_range??"",patchedVersion:d.first_patched_version??"not available",severity:G.severity,type:G.type}))??[])}function DEe(t){return t.map(e=>{let I=e.type==="malware"?"is malware":"has a vulnerability";return`Dependency ${e.name} version ${e.version} in ecosystem ${e.ecosystem} ${I}: ${e.summary}. Affected versions: ${e.affectedVersions}. Patched version: ${e.patchedVersion}.`}).join(`
337
+ `)}`}isAbortError(e){return e instanceof Error&&(e.name==="TimeoutError"||e.name==="AbortError")}async logProgress(e,I=4,l){switch(l&&this.logger.startGroup(l),I){case 8:this.logger.debug(e);break;case 4:this.logger.info(e);break;case 2:this.logger.warning(e);break;case 1:this.logger.error(e);break;default:this.logger.log(e);break}l&&this.logger.endGroup(),this.config.callback&&await this.config.callback?.progress({kind:"log",message:e})}async createCodeQLScratchDir(e){let I=SEe.normalize(SEe.join(e,"..",".codeql-scratch"));return await OEe.promises.mkdir(I,{recursive:!0}),I}createTelemetryByLanguage(e,I){let l=[];for(let[n,c]of Object.entries(e)){if(vFe(c)){let s={event:"codeql-checker-completion",properties:{"codeql.language":n,"codeql.skipped":"true","codeql.version":I},metrics:{},restrictedProperties:{}};l.push(s);continue}let r={event:"codeql-checker-completion",properties:{"codeql.language":n,"codeql.databaseCreationSuccess":c.databaseCreationSuccess?"true":"false","codeql.analysisRuleIds":iA(c)?c.analysisRuleIds.join(","):"","codeql.version":I,"codeql.querySuite":iA(c)?c.querySuite:void 0},metrics:{"codeql.databaseCreationTimeMs":c.databaseCreationTimeMs,"codeql.analysisTimeMs":iA(c)?c.analysisTimeMs:void 0,"codeql.alertCount":iA(c)?c.analysisRuleIds.length:0},restrictedProperties:{}};c.aborted&&(r.properties["codeql.aborted"]="true"),c.databaseCreationError&&(wG({telemetry:r},c.databaseCreationError,"codeql.databaseCreationError"),r.restrictedProperties["codeql.databaseCreationStack"]=String(c.databaseCreationError.stack)),iA(c)&&(r.properties["codeql.analysisSuccess"]=c.analysisSuccess?"true":"false",c.analysisError&&(wG({telemetry:r},c.analysisError,"codeql.analysisError"),r.restrictedProperties["codeql.analysisStack"]=String(c.analysisError.stack))),l.push(r)}return l}async shouldAnalyzeLanguage(e,I){if(I=="actions")return!0;let l=await e.getRepositorySize(I);if(l===void 0)return!0;let n=l<=t.DEFAULT_MAX_REPO_SIZE_BYTES;return n||this.logProgress(`Skipping analysis for ${I} because the repository size is ${l} bytes, which exceeds the limit of ${t.DEFAULT_MAX_REPO_SIZE_BYTES} bytes.`,2),n}};o();o();var PA=["actions","composer","erlang","go","maven","npm","nuget","other","pip","pub","rubygems","rust","swift"],UYI={npm_and_yarn:"npm",bundler:"rubygems",pip:"pip",maven:"maven",composer:"composer",go_modules:"go",github_actions:"actions",cargo:"rust",pub:"pub",swift:"swift",nuget:"nuget",gradle:"maven",hex:"erlang",other:"other"};function TEe(t){if(!t)return;let e=t.toLowerCase();return UYI[e]}async function jEe(t,e,I){let l;if(PA.includes(e.ecosystem)?l=e.ecosystem:l=TEe(e.ecosystem),!l)return I?.warning(`Unsupported ecosystem '${e.ecosystem}' for dependency ${e.name}; skipping advisory lookup.`),[];let n={affects:`${e.name}@${e.version}`,ecosystem:l},[c,r,s]=await Promise.all([t.securityAdvisories.listGlobalAdvisories({...n,severity:"high"}),t.securityAdvisories.listGlobalAdvisories({...n,severity:"critical"}),t.securityAdvisories.listGlobalAdvisories({...n,type:"malware"})]);return[...c.data,...r.data,...s.data].flatMap(G=>G.vulnerabilities?.map(d=>({name:e.name,version:e.version,summary:G.summary,ecosystem:d.package?.ecosystem??"unknown",affectedVersions:d.vulnerable_version_range??"",patchedVersion:d.first_patched_version??"not available",severity:G.severity,type:G.type}))??[])}function DEe(t){return t.map(e=>{let I=e.type==="malware"?"is malware":"has a vulnerability";return`Dependency ${e.name} version ${e.version} in ecosystem ${e.ecosystem} ${I}: ${e.summary}. Affected versions: ${e.affectedVersions}. Patched version: ${e.patchedVersion}.`}).join(`
338
338
 
339
339
  `)}function MEe(t){if(!t.trim())return"parameter must be a non-empty string."}function SYI(t){if(!PA.includes(t)&&!TEe(t))return`ecosystem '${t}' is not supported. Supported ecosystems are: ${PA.join(", ")}.`}function KEe(t){let e=[],I=MEe(t.name);I&&e.push(`name: ${I}`);let l=MEe(t.version);l&&e.push(`version: ${l}`);let n=SYI(t.ecosystem);return n&&e.push(`ecosystem: ${n}`),e}var OYI="gh-advisory-database",PEe="copilot_swe_agent_validation_agent_dependencies",MYI="security agent",qEe={name:OYI,description:`Security tool that checks the GitHub advisory DB for vulnerabilities in dependencies. Run this tool ALWAYS before adding new dependencies from these SUPPORTED ecosystems: ${PA.join(", ")}. For ANY other ecosystem (e.g., Haskell/Cabal, C++/vcpkg, Elixir/Hex, etc.), DO NOT call this tool - just proceed with adding the dependency. If you don't know the version number, retrieve that first. Feedback from this tool MUST be incorporated. Re-run the tool as appropriate.`,input_schema:{type:"object",properties:{dependencies:{type:"array",items:{type:"object",properties:{version:{type:"string",description:"The version of the dependency in semver format. Examples: '1.0.0', '2.1.0'."},name:{type:"string",description:"The name of the dependency. Examples: 'express', 'lodash'."},ecosystem:{type:"string",enum:PA,description:"The package ecosystem for the dependency. Must be one of the supported ecosystems. If the dependency's ecosystem is not in the list of supported ecosystems, DO NOT use this tool."}},required:["name","version","ecosystem"]}}},required:["dependencies"]},callback:TYI,safeForTelemetry:{name:!0,inputsNames:!1}};async function TYI({dependencies:t},e){if(!t||t.length===0)return{textResultForLlm:"No dependencies provided for checking.",resultType:"success",sessionLog:"No dependencies provided for checking.",toolTelemetry:{}};let I=[];for(let l of t){let n=KEe(l);if(n.length>0){let c=`Invalid parameters found for dependency ${l.name}: ${n.join(", ")}`;return{textResultForLlm:c,resultType:"failure",sessionLog:c,toolTelemetry:{}}}try{let c=e?r2(e.settings):process.env.GH_TOKEN;if(!c){let s="GitHub token is required to use the dependency checker tool. Please set it in the settings or as the GH_TOKEN environment variable.";return{textResultForLlm:s,resultType:"failure",sessionLog:s,toolTelemetry:{properties:{error:s}}}}let r=new FS({userAgent:MYI,auth:c});I.push(...await jEe(r,l))}catch(c){let r=`Error checking dependency ${l.name}: ${String(c)}`,s=c instanceof Error?c.stack:void 0;return{textResultForLlm:r,resultType:"failure",sessionLog:r,toolTelemetry:{restrictedProperties:{dep:`${l.name}@${l.version}`,error:r,stackTrace:s}}}}}if(I.length===0)return{textResultForLlm:"No vulnerabilities found in the provided dependencies.",resultType:"success",sessionLog:"No vulnerabilities found in the provided dependencies.",toolTelemetry:{}};{let l=DEe(I);return{textResultForLlm:l,resultType:"success",sessionLog:l,toolTelemetry:{restrictedProperties:{vulnerableDeps:I.map(n=>`${n.name}@${n.version}`).join(", ")},metrics:{vulnerableDependencies:I.length}}}}}o();var _Ee="reply_to_comment",$Ee=(t,e)=>({name:_Ee,description:`Reply to new comments. Use when you've completed a meaningful unit of work that specifically addresses the request, question, or feedback in the comment.
340
340
  * Use this tool no more than once per <comment_id>, and only after you have completed meaningful work that specifically addresses the text in the comment.
@@ -1411,7 +1411,7 @@ Pay attention to the following when using it:
1411
1411
  This tool is used to perform a semantic search of the codebase to find relevant information based on the question asked.
1412
1412
  * It leverages advanced AI techniques to understand the context and semantics of the codebase.
1413
1413
  * Use this tool when you need to find information that is not easily accessible through traditional search methods.
1414
- `,input_schema:{type:"object",properties:{question:{type:"string",description:"A question about the codebase. It should reference by name any topics, specific file names, and concepts that are relevant to the question and specify the desired output format."}},required:["question"]},callback:async l=>{let n,c=mz(t),r="",s="",a=c.split("/");if(a.length===2){[r,s]=a,I.info("Searching for repository insights");try{n=await Wpe(l.question,r,s,e,I),I.info(`Blackbird results: ${n}`)}catch(G){I.error(`Error occurred while searching for repository insights: ${G}`)}}return{resultType:"success",textResultForLlm:n??"No results found.",toolTelemetry:{}}}}}async function zKe(t,e,I,l,n,c,r){let s=await MKe(t),a=await lDI(t,I,l),G=xKe(I)?[new Uq(l,I,n,c,t,t.location,AM(),r).getSearch()]:[],d=t.splitEditingTools?mce(t,l,I):[EM(t,l,I)];return[s.shellTool,...s.otherTools??[],...a,...G,...d,lHe(t,e,I,l,n),El(I,b_)?eYe(t,l,n,I):void 0,t?.requireReasoning?pce(t):void 0,El(I,PEe)?qEe:void 0,await nDI(t,I,l,n)].filter(i=>i!==void 0)}async function UKe(t,e){let I=await MKe(t),l=t.splitEditingTools?mce(t,e):[EM(t,e)];return[I.shellTool,...I.otherTools??[],...l,t?.requireReasoning?pce(t):void 0].filter(n=>n!==void 0)}async function tDI(t,e,I,l,n,c,r){return[...await zKe(t,e,I,l,n,c,r),$Ee(t,l)]}var SKe=t=>({...ip,supports:{...ip.supports,reasoning:t?.thinkingMode?!0:ip.supports?.reasoning}}),ip={supports:{tool_choice:!1,reasoning:!0,parallel_tool_calls:!1},createPR:{toolInit:zKe,jitInstructions:upe},prDetails:{},respondToPRComment:{toolInit:tDI,jitInstructions:upe}},OKe=t=>({"sweagent-capi":{"claude-3.5-sonnet":{...ip,supports:{tool_choice:!1,reasoning:!1}},"claude-3.7-sonnet":{...ip,supports:{tool_choice:!1,reasoning:!1,vision:!0}},"claude-sonnet-4":{...ip,supports:{tool_choice:!1,reasoning:!0,parallel_tool_calls:!0,vision:!0},toolConfigOverrides:{splitEditingTools:!0}},"claude-sonnet-4.5":{...ip,supports:{tool_choice:!1,reasoning:!0,parallel_tool_calls:!0,vision:!0},toolConfigOverrides:{splitEditingTools:!0}},oswe:{...ip,supports:{tool_choice:!0,reasoning:!0,vision:!0}},"oswe-prime":{...ip,supports:{tool_choice:!0,reasoning:!0,vision:!0}},"gpt-5":{...ip,supports:{tool_choice:!0,reasoning:!0,parallel_tool_calls:!0,vision:!0,steering:!0},toolConfigOverrides:{splitEditingTools:!0}}}});async function MKe(t){let e=new QP(t);return{shellTool:e.getShellTool(),otherTools:[e.getWriteShellTool(),e.getReadShellTool(),e.getStopShellTool()]}}async function lDI(t,e,I){if(gbe(e,"cloud"))return[new H3(new l6(e,I,void 0)).getStoreMemory()];if(gbe(e,"local")){let l=new H3(new t6(t.location));return[l.getStoreMemory(),l.getReadMemory()]}return[]}async function nDI(t,e,I,l){if(t.includeCodeQLTool){let n=new Go(I,l),c=e.swebench_base_commit??await n.getCurrentCommitHash(t.location);return new yM(t,n,c,e,I).getCodeQLCheckerTool()}}o();import{execFile as cDI}from"node:child_process";import{normalize as rDI}from"node:path";import{promisify as sDI}from"node:util";var aDI=sDI(cDI);async function Vpe(t=process.cwd()){try{let I=(await aDI("git",["rev-parse","--show-toplevel"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576})).stdout.trim();if(I)return{gitRoot:rDI(I),found:!0}}catch{}return{gitRoot:t,found:!1}}o();o();import{Writable as Q$I}from"stream";o();o();o();o();o();var Y={};Pc(Y,{BRAND:()=>CDI,DIRTY:()=>pg,EMPTY_PATH:()=>iDI,INVALID:()=>gI,NEVER:()=>sKI,OK:()=>la,ParseStatus:()=>Rs,Schema:()=>ht,ZodAny:()=>kV,ZodArray:()=>Ku,ZodBigInt:()=>ug,ZodBoolean:()=>Wg,ZodBranded:()=>Sx,ZodCatch:()=>Xg,ZodDate:()=>Ng,ZodDefault:()=>wg,ZodDiscriminatedUnion:()=>Mq,ZodEffects:()=>Ri,ZodEnum:()=>Ag,ZodError:()=>aG,ZodFirstPartyTypeKind:()=>QI,ZodFunction:()=>jq,ZodIntersection:()=>yg,ZodIssueCode:()=>Ve,ZodLazy:()=>gg,ZodLiteral:()=>Fg,ZodMap:()=>F1,ZodNaN:()=>Q1,ZodNativeEnum:()=>Qg,ZodNever:()=>Mb,ZodNull:()=>Vg,ZodNullable:()=>hp,ZodNumber:()=>Zg,ZodObject:()=>oG,ZodOptional:()=>Yi,ZodParsedType:()=>je,ZodPipeline:()=>Ox,ZodPromise:()=>fV,ZodReadonly:()=>Eg,ZodRecord:()=>Tq,ZodSchema:()=>ht,ZodSet:()=>A1,ZodString:()=>LV,ZodSymbol:()=>y1,ZodTransformer:()=>Ri,ZodTuple:()=>mp,ZodType:()=>ht,ZodUndefined:()=>Yg,ZodUnion:()=>Rg,ZodUnknown:()=>Du,ZodVoid:()=>g1,addIssueToContext:()=>xe,any:()=>Fpe,array:()=>ys,bigint:()=>fDI,boolean:()=>bn,coerce:()=>Tx,custom:()=>$Ke,date:()=>xDI,datetimeRegex:()=>qKe,defaultErrorMap:()=>Tu,discriminatedUnion:()=>Mx,effect:()=>$DI,enum:()=>yi,function:()=>KDI,getErrorMap:()=>Y1,getParsedType:()=>bp,instanceof:()=>LDI,intersection:()=>TDI,isAborted:()=>Sq,isAsync:()=>V1,isDirty:()=>Oq,isValid:()=>JV,late:()=>JDI,lazy:()=>PDI,literal:()=>ZI,makeIssue:()=>Ux,map:()=>jDI,nan:()=>kDI,nativeEnum:()=>qDI,never:()=>SDI,null:()=>UDI,nullable:()=>IKI,number:()=>na,object:()=>Ue,objectUtil:()=>Rpe,oboolean:()=>rKI,onumber:()=>cKI,optional:()=>eKI,ostring:()=>nKI,pipeline:()=>lKI,preprocess:()=>tKI,promise:()=>_DI,quotelessJson:()=>oDI,record:()=>w1,set:()=>DDI,setErrorMap:()=>dDI,strictObject:()=>MDI,string:()=>ae,symbol:()=>BDI,transformer:()=>$DI,tuple:()=>Ape,undefined:()=>zDI,union:()=>ca,unknown:()=>pp,util:()=>zt,void:()=>ODI});o();o();o();o();o();var zt;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function I(n){throw new Error}t.assertNever=I,t.arrayToEnum=n=>{let c={};for(let r of n)c[r]=r;return c},t.getValidEnumValues=n=>{let c=t.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),r={};for(let s of c)r[s]=n[s];return t.objectValues(r)},t.objectValues=n=>t.objectKeys(n).map(function(c){return n[c]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let c=[];for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&c.push(r);return c},t.find=(n,c)=>{for(let r of n)if(c(r))return r},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function l(n,c=" | "){return n.map(r=>typeof r=="string"?`'${r}'`:r).join(c)}t.joinValues=l,t.jsonStringifyReplacer=(n,c)=>typeof c=="bigint"?c.toString():c})(zt||(zt={}));var Rpe;(function(t){t.mergeShapes=(e,I)=>({...e,...I})})(Rpe||(Rpe={}));var je=zt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),bp=t=>{switch(typeof t){case"undefined":return je.undefined;case"string":return je.string;case"number":return Number.isNaN(t)?je.nan:je.number;case"boolean":return je.boolean;case"function":return je.function;case"bigint":return je.bigint;case"symbol":return je.symbol;case"object":return Array.isArray(t)?je.array:t===null?je.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?je.promise:typeof Map<"u"&&t instanceof Map?je.map:typeof Set<"u"&&t instanceof Set?je.set:typeof Date<"u"&&t instanceof Date?je.date:je.object;default:return je.unknown}};var Ve=zt.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"]),oDI=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),aG=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=l=>{this.issues=[...this.issues,l]},this.addIssues=(l=[])=>{this.issues=[...this.issues,...l]};let I=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,I):this.__proto__=I,this.name="ZodError",this.issues=e}format(e){let I=e||function(c){return c.message},l={_errors:[]},n=c=>{for(let r of c.issues)if(r.code==="invalid_union")r.unionErrors.map(n);else if(r.code==="invalid_return_type")n(r.returnTypeError);else if(r.code==="invalid_arguments")n(r.argumentsError);else if(r.path.length===0)l._errors.push(I(r));else{let s=l,a=0;for(;a<r.path.length;){let G=r.path[a];a===r.path.length-1?(s[G]=s[G]||{_errors:[]},s[G]._errors.push(I(r))):s[G]=s[G]||{_errors:[]},s=s[G],a++}}};return n(this),l}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,zt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=I=>I.message){let I={},l=[];for(let n of this.issues)if(n.path.length>0){let c=n.path[0];I[c]=I[c]||[],I[c].push(e(n))}else l.push(e(n));return{formErrors:l,fieldErrors:I}}get formErrors(){return this.flatten()}};aG.create=t=>new aG(t);var GDI=(t,e)=>{let I;switch(t.code){case Ve.invalid_type:t.received===je.undefined?I="Required":I=`Expected ${t.expected}, received ${t.received}`;break;case Ve.invalid_literal:I=`Invalid literal value, expected ${JSON.stringify(t.expected,zt.jsonStringifyReplacer)}`;break;case Ve.unrecognized_keys:I=`Unrecognized key(s) in object: ${zt.joinValues(t.keys,", ")}`;break;case Ve.invalid_union:I="Invalid input";break;case Ve.invalid_union_discriminator:I=`Invalid discriminator value. Expected ${zt.joinValues(t.options)}`;break;case Ve.invalid_enum_value:I=`Invalid enum value. Expected ${zt.joinValues(t.options)}, received '${t.received}'`;break;case Ve.invalid_arguments:I="Invalid function arguments";break;case Ve.invalid_return_type:I="Invalid function return type";break;case Ve.invalid_date:I="Invalid date";break;case Ve.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(I=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(I=`${I} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?I=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?I=`Invalid input: must end with "${t.validation.endsWith}"`:zt.assertNever(t.validation):t.validation!=="regex"?I=`Invalid ${t.validation}`:I="Invalid";break;case Ve.too_small:t.type==="array"?I=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?I=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?I=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?I=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?I=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:I="Invalid input";break;case Ve.too_big:t.type==="array"?I=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?I=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?I=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?I=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?I=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:I="Invalid input";break;case Ve.custom:I="Invalid input";break;case Ve.invalid_intersection_types:I="Intersection results could not be merged";break;case Ve.not_multiple_of:I=`Number must be a multiple of ${t.multipleOf}`;break;case Ve.not_finite:I="Number must be finite";break;default:I=e.defaultError,zt.assertNever(t)}return{message:I}},Tu=GDI;var TKe=Tu;function dDI(t){TKe=t}function Y1(){return TKe}o();var Ux=t=>{let{data:e,path:I,errorMaps:l,issueData:n}=t,c=[...I,...n.path||[]],r={...n,path:c};if(n.message!==void 0)return{...n,path:c,message:n.message};let s="",a=l.filter(G=>!!G).slice().reverse();for(let G of a)s=G(r,{data:e,defaultError:s}).message;return{...n,path:c,message:s}},iDI=[];function xe(t,e){let I=Y1(),l=Ux({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,I,I===Tu?void 0:Tu].filter(n=>!!n)});t.common.issues.push(l)}var Rs=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,I){let l=[];for(let n of I){if(n.status==="aborted")return gI;n.status==="dirty"&&e.dirty(),l.push(n.value)}return{status:e.value,value:l}}static async mergeObjectAsync(e,I){let l=[];for(let n of I){let c=await n.key,r=await n.value;l.push({key:c,value:r})}return t.mergeObjectSync(e,l)}static mergeObjectSync(e,I){let l={};for(let n of I){let{key:c,value:r}=n;if(c.status==="aborted"||r.status==="aborted")return gI;c.status==="dirty"&&e.dirty(),r.status==="dirty"&&e.dirty(),c.value!=="__proto__"&&(typeof r.value<"u"||n.alwaysSet)&&(l[c.value]=r.value)}return{status:e.value,value:l}}},gI=Object.freeze({status:"aborted"}),pg=t=>({status:"dirty",value:t}),la=t=>({status:"valid",value:t}),Sq=t=>t.status==="aborted",Oq=t=>t.status==="dirty",JV=t=>t.status==="valid",V1=t=>typeof Promise<"u"&&t instanceof Promise;o();o();var rI;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(rI||(rI={}));var Vi=class{constructor(e,I,l,n){this._cachedPath=[],this.parent=e,this.data=I,this._path=l,this._key=n}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}},jKe=(t,e)=>{if(JV(e))return{success:!0,data:e.value};if(!t.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 aG(t.common.issues);return this._error=I,this._error}}};function rt(t){if(!t)return{};let{errorMap:e,invalid_type_error:I,required_error:l,description:n}=t;if(e&&(I||l))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(r,s)=>{let{message:a}=t;return r.code==="invalid_enum_value"?{message:a??s.defaultError}:typeof s.data>"u"?{message:a??l??s.defaultError}:r.code!=="invalid_type"?{message:s.defaultError}:{message:a??I??s.defaultError}},description:n}}var ht=class{get description(){return this._def.description}_getType(e){return bp(e.data)}_getOrReturnCtx(e,I){return I||{common:e.parent.common,data:e.data,parsedType:bp(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Rs,ctx:{common:e.parent.common,data:e.data,parsedType:bp(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let I=this._parse(e);if(V1(I))throw new Error("Synchronous parse encountered promise.");return I}_parseAsync(e){let I=this._parse(e);return Promise.resolve(I)}parse(e,I){let l=this.safeParse(e,I);if(l.success)return l.data;throw l.error}safeParse(e,I){let l={common:{issues:[],async:I?.async??!1,contextualErrorMap:I?.errorMap},path:I?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bp(e)},n=this._parseSync({data:e,path:l.path,parent:l});return jKe(l,n)}"~validate"(e){let I={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bp(e)};if(!this["~standard"].async)try{let l=this._parseSync({data:e,path:[],parent:I});return JV(l)?{value:l.value}:{issues:I.common.issues}}catch(l){l?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),I.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:I}).then(l=>JV(l)?{value:l.value}:{issues:I.common.issues})}async parseAsync(e,I){let l=await this.safeParseAsync(e,I);if(l.success)return l.data;throw l.error}async safeParseAsync(e,I){let l={common:{issues:[],contextualErrorMap:I?.errorMap,async:!0},path:I?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bp(e)},n=this._parse({data:e,path:l.path,parent:l}),c=await(V1(n)?n:Promise.resolve(n));return jKe(l,c)}refine(e,I){let l=n=>typeof I=="string"||typeof I>"u"?{message:I}:typeof I=="function"?I(n):I;return this._refinement((n,c)=>{let r=e(n),s=()=>c.addIssue({code:Ve.custom,...l(n)});return typeof Promise<"u"&&r instanceof Promise?r.then(a=>a?!0:(s(),!1)):r?!0:(s(),!1)})}refinement(e,I){return this._refinement((l,n)=>e(l)?!0:(n.addIssue(typeof I=="function"?I(l,n):I),!1))}_refinement(e){return new Ri({schema:this,typeName:QI.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:I=>this["~validate"](I)}}optional(){return Yi.create(this,this._def)}nullable(){return hp.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ku.create(this)}promise(){return fV.create(this,this._def)}or(e){return Rg.create([this,e],this._def)}and(e){return yg.create(this,e,this._def)}transform(e){return new Ri({...rt(this._def),schema:this,typeName:QI.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let I=typeof e=="function"?e:()=>e;return new wg({...rt(this._def),innerType:this,defaultValue:I,typeName:QI.ZodDefault})}brand(){return new Sx({typeName:QI.ZodBranded,type:this,...rt(this._def)})}catch(e){let I=typeof e=="function"?e:()=>e;return new Xg({...rt(this._def),innerType:this,catchValue:I,typeName:QI.ZodCatch})}describe(e){let I=this.constructor;return new I({...this._def,description:e})}pipe(e){return Ox.create(this,e)}readonly(){return Eg.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},bDI=/^c[^\s-]{8,}$/i,mDI=/^[0-9a-z]+$/,hDI=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pDI=/^[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,ZDI=/^[a-z0-9_-]{21}$/i,uDI=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,WDI=/^[-+]?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)?)??$/,NDI=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,YDI="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ype,VDI=/^(?:(?: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])$/,RDI=/^(?:(?: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])$/,yDI=/^(([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]))$/,gDI=/^(([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])$/,FDI=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ADI=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,KKe="((\\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])))",QDI=new RegExp(`^${KKe}$`);function PKe(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let I=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${I}`}function wDI(t){return new RegExp(`^${PKe(t)}$`)}function qKe(t){let e=`${KKe}T${PKe(t)}`,I=[];return I.push(t.local?"Z?":"Z"),t.offset&&I.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${I.join("|")})`,new RegExp(`^${e}$`)}function XDI(t,e){return!!((e==="v4"||!e)&&VDI.test(t)||(e==="v6"||!e)&&yDI.test(t))}function EDI(t,e){if(!uDI.test(t))return!1;try{let[I]=t.split(".");if(!I)return!1;let l=I.replace(/-/g,"+").replace(/_/g,"/").padEnd(I.length+(4-I.length%4)%4,"="),n=JSON.parse(atob(l));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function HDI(t,e){return!!((e==="v4"||!e)&&RDI.test(t)||(e==="v6"||!e)&&gDI.test(t))}var LV=class t extends ht{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==je.string){let c=this._getOrReturnCtx(e);return xe(c,{code:Ve.invalid_type,expected:je.string,received:c.parsedType}),gI}let l=new Rs,n;for(let c of this._def.checks)if(c.kind==="min")e.data.length<c.value&&(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.too_small,minimum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),l.dirty());else if(c.kind==="max")e.data.length>c.value&&(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),l.dirty());else if(c.kind==="length"){let r=e.data.length>c.value,s=e.data.length<c.value;(r||s)&&(n=this._getOrReturnCtx(e,n),r?xe(n,{code:Ve.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!0,message:c.message}):s&&xe(n,{code:Ve.too_small,minimum:c.value,type:"string",inclusive:!0,exact:!0,message:c.message}),l.dirty())}else if(c.kind==="email")NDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"email",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="emoji")ype||(ype=new RegExp(YDI,"u")),ype.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"emoji",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="uuid")pDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"uuid",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="nanoid")ZDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"nanoid",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="cuid")bDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"cuid",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="cuid2")mDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"cuid2",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="ulid")hDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"ulid",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),xe(n,{validation:"url",code:Ve.invalid_string,message:c.message}),l.dirty()}else c.kind==="regex"?(c.regex.lastIndex=0,c.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"regex",code:Ve.invalid_string,message:c.message}),l.dirty())):c.kind==="trim"?e.data=e.data.trim():c.kind==="includes"?e.data.includes(c.value,c.position)||(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.invalid_string,validation:{includes:c.value,position:c.position},message:c.message}),l.dirty()):c.kind==="toLowerCase"?e.data=e.data.toLowerCase():c.kind==="toUpperCase"?e.data=e.data.toUpperCase():c.kind==="startsWith"?e.data.startsWith(c.value)||(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.invalid_string,validation:{startsWith:c.value},message:c.message}),l.dirty()):c.kind==="endsWith"?e.data.endsWith(c.value)||(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.invalid_string,validation:{endsWith:c.value},message:c.message}),l.dirty()):c.kind==="datetime"?qKe(c).test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.invalid_string,validation:"datetime",message:c.message}),l.dirty()):c.kind==="date"?QDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.invalid_string,validation:"date",message:c.message}),l.dirty()):c.kind==="time"?wDI(c).test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.invalid_string,validation:"time",message:c.message}),l.dirty()):c.kind==="duration"?WDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"duration",code:Ve.invalid_string,message:c.message}),l.dirty()):c.kind==="ip"?XDI(e.data,c.version)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"ip",code:Ve.invalid_string,message:c.message}),l.dirty()):c.kind==="jwt"?EDI(e.data,c.alg)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"jwt",code:Ve.invalid_string,message:c.message}),l.dirty()):c.kind==="cidr"?HDI(e.data,c.version)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"cidr",code:Ve.invalid_string,message:c.message}),l.dirty()):c.kind==="base64"?FDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"base64",code:Ve.invalid_string,message:c.message}),l.dirty()):c.kind==="base64url"?ADI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"base64url",code:Ve.invalid_string,message:c.message}),l.dirty()):zt.assertNever(c);return{status:l.value,value:e.data}}_regex(e,I,l){return this.refinement(n=>e.test(n),{validation:I,code:Ve.invalid_string,...rI.errToObj(l)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...rI.errToObj(e)})}url(e){return this._addCheck({kind:"url",...rI.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...rI.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...rI.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...rI.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...rI.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...rI.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...rI.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...rI.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...rI.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...rI.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...rI.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...rI.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...rI.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...rI.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...rI.errToObj(e)})}regex(e,I){return this._addCheck({kind:"regex",regex:e,...rI.errToObj(I)})}includes(e,I){return this._addCheck({kind:"includes",value:e,position:I?.position,...rI.errToObj(I?.message)})}startsWith(e,I){return this._addCheck({kind:"startsWith",value:e,...rI.errToObj(I)})}endsWith(e,I){return this._addCheck({kind:"endsWith",value:e,...rI.errToObj(I)})}min(e,I){return this._addCheck({kind:"min",value:e,...rI.errToObj(I)})}max(e,I){return this._addCheck({kind:"max",value:e,...rI.errToObj(I)})}length(e,I){return this._addCheck({kind:"length",value:e,...rI.errToObj(I)})}nonempty(e){return this.min(1,rI.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let I of this._def.checks)I.kind==="min"&&(e===null||I.value>e)&&(e=I.value);return e}get maxLength(){let e=null;for(let I of this._def.checks)I.kind==="max"&&(e===null||I.value<e)&&(e=I.value);return e}};LV.create=t=>new LV({checks:[],typeName:QI.ZodString,coerce:t?.coerce??!1,...rt(t)});function vDI(t,e){let I=(t.toString().split(".")[1]||"").length,l=(e.toString().split(".")[1]||"").length,n=I>l?I:l,c=Number.parseInt(t.toFixed(n).replace(".","")),r=Number.parseInt(e.toFixed(n).replace(".",""));return c%r/10**n}var Zg=class t extends ht{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==je.number){let c=this._getOrReturnCtx(e);return xe(c,{code:Ve.invalid_type,expected:je.number,received:c.parsedType}),gI}let l,n=new Rs;for(let c of this._def.checks)c.kind==="int"?zt.isInteger(e.data)||(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.invalid_type,expected:"integer",received:"float",message:c.message}),n.dirty()):c.kind==="min"?(c.inclusive?e.data<c.value:e.data<=c.value)&&(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.too_small,minimum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),n.dirty()):c.kind==="max"?(c.inclusive?e.data>c.value:e.data>=c.value)&&(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.too_big,maximum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),n.dirty()):c.kind==="multipleOf"?vDI(e.data,c.value)!==0&&(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.not_multiple_of,multipleOf:c.value,message:c.message}),n.dirty()):c.kind==="finite"?Number.isFinite(e.data)||(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.not_finite,message:c.message}),n.dirty()):zt.assertNever(c);return{status:n.value,value:e.data}}gte(e,I){return this.setLimit("min",e,!0,rI.toString(I))}gt(e,I){return this.setLimit("min",e,!1,rI.toString(I))}lte(e,I){return this.setLimit("max",e,!0,rI.toString(I))}lt(e,I){return this.setLimit("max",e,!1,rI.toString(I))}setLimit(e,I,l,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:I,inclusive:l,message:rI.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:rI.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:rI.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:rI.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:rI.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:rI.toString(e)})}multipleOf(e,I){return this._addCheck({kind:"multipleOf",value:e,message:rI.toString(I)})}finite(e){return this._addCheck({kind:"finite",message:rI.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:rI.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:rI.toString(e)})}get minValue(){let e=null;for(let I of this._def.checks)I.kind==="min"&&(e===null||I.value>e)&&(e=I.value);return e}get maxValue(){let e=null;for(let I of this._def.checks)I.kind==="max"&&(e===null||I.value<e)&&(e=I.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&zt.isInteger(e.value))}get isFinite(){let e=null,I=null;for(let l of this._def.checks){if(l.kind==="finite"||l.kind==="int"||l.kind==="multipleOf")return!0;l.kind==="min"?(I===null||l.value>I)&&(I=l.value):l.kind==="max"&&(e===null||l.value<e)&&(e=l.value)}return Number.isFinite(I)&&Number.isFinite(e)}};Zg.create=t=>new Zg({checks:[],typeName:QI.ZodNumber,coerce:t?.coerce||!1,...rt(t)});var ug=class t extends ht{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==je.bigint)return this._getInvalidInput(e);let l,n=new Rs;for(let c of this._def.checks)c.kind==="min"?(c.inclusive?e.data<c.value:e.data<=c.value)&&(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.too_small,type:"bigint",minimum:c.value,inclusive:c.inclusive,message:c.message}),n.dirty()):c.kind==="max"?(c.inclusive?e.data>c.value:e.data>=c.value)&&(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.too_big,type:"bigint",maximum:c.value,inclusive:c.inclusive,message:c.message}),n.dirty()):c.kind==="multipleOf"?e.data%c.value!==BigInt(0)&&(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.not_multiple_of,multipleOf:c.value,message:c.message}),n.dirty()):zt.assertNever(c);return{status:n.value,value:e.data}}_getInvalidInput(e){let I=this._getOrReturnCtx(e);return xe(I,{code:Ve.invalid_type,expected:je.bigint,received:I.parsedType}),gI}gte(e,I){return this.setLimit("min",e,!0,rI.toString(I))}gt(e,I){return this.setLimit("min",e,!1,rI.toString(I))}lte(e,I){return this.setLimit("max",e,!0,rI.toString(I))}lt(e,I){return this.setLimit("max",e,!1,rI.toString(I))}setLimit(e,I,l,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:I,inclusive:l,message:rI.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:rI.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:rI.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:rI.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:rI.toString(e)})}multipleOf(e,I){return this._addCheck({kind:"multipleOf",value:e,message:rI.toString(I)})}get minValue(){let e=null;for(let I of this._def.checks)I.kind==="min"&&(e===null||I.value>e)&&(e=I.value);return e}get maxValue(){let e=null;for(let I of this._def.checks)I.kind==="max"&&(e===null||I.value<e)&&(e=I.value);return e}};ug.create=t=>new ug({checks:[],typeName:QI.ZodBigInt,coerce:t?.coerce??!1,...rt(t)});var Wg=class extends ht{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==je.boolean){let l=this._getOrReturnCtx(e);return xe(l,{code:Ve.invalid_type,expected:je.boolean,received:l.parsedType}),gI}return la(e.data)}};Wg.create=t=>new Wg({typeName:QI.ZodBoolean,coerce:t?.coerce||!1,...rt(t)});var Ng=class t extends ht{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==je.date){let c=this._getOrReturnCtx(e);return xe(c,{code:Ve.invalid_type,expected:je.date,received:c.parsedType}),gI}if(Number.isNaN(e.data.getTime())){let c=this._getOrReturnCtx(e);return xe(c,{code:Ve.invalid_date}),gI}let l=new Rs,n;for(let c of this._def.checks)c.kind==="min"?e.data.getTime()<c.value&&(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.too_small,message:c.message,inclusive:!0,exact:!1,minimum:c.value,type:"date"}),l.dirty()):c.kind==="max"?e.data.getTime()>c.value&&(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.too_big,message:c.message,inclusive:!0,exact:!1,maximum:c.value,type:"date"}),l.dirty()):zt.assertNever(c);return{status:l.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,I){return this._addCheck({kind:"min",value:e.getTime(),message:rI.toString(I)})}max(e,I){return this._addCheck({kind:"max",value:e.getTime(),message:rI.toString(I)})}get minDate(){let e=null;for(let I of this._def.checks)I.kind==="min"&&(e===null||I.value>e)&&(e=I.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let I of this._def.checks)I.kind==="max"&&(e===null||I.value<e)&&(e=I.value);return e!=null?new Date(e):null}};Ng.create=t=>new Ng({checks:[],coerce:t?.coerce||!1,typeName:QI.ZodDate,...rt(t)});var y1=class extends ht{_parse(e){if(this._getType(e)!==je.symbol){let l=this._getOrReturnCtx(e);return xe(l,{code:Ve.invalid_type,expected:je.symbol,received:l.parsedType}),gI}return la(e.data)}};y1.create=t=>new y1({typeName:QI.ZodSymbol,...rt(t)});var Yg=class extends ht{_parse(e){if(this._getType(e)!==je.undefined){let l=this._getOrReturnCtx(e);return xe(l,{code:Ve.invalid_type,expected:je.undefined,received:l.parsedType}),gI}return la(e.data)}};Yg.create=t=>new Yg({typeName:QI.ZodUndefined,...rt(t)});var Vg=class extends ht{_parse(e){if(this._getType(e)!==je.null){let l=this._getOrReturnCtx(e);return xe(l,{code:Ve.invalid_type,expected:je.null,received:l.parsedType}),gI}return la(e.data)}};Vg.create=t=>new Vg({typeName:QI.ZodNull,...rt(t)});var kV=class extends ht{constructor(){super(...arguments),this._any=!0}_parse(e){return la(e.data)}};kV.create=t=>new kV({typeName:QI.ZodAny,...rt(t)});var Du=class extends ht{constructor(){super(...arguments),this._unknown=!0}_parse(e){return la(e.data)}};Du.create=t=>new Du({typeName:QI.ZodUnknown,...rt(t)});var Mb=class extends ht{_parse(e){let I=this._getOrReturnCtx(e);return xe(I,{code:Ve.invalid_type,expected:je.never,received:I.parsedType}),gI}};Mb.create=t=>new Mb({typeName:QI.ZodNever,...rt(t)});var g1=class extends ht{_parse(e){if(this._getType(e)!==je.undefined){let l=this._getOrReturnCtx(e);return xe(l,{code:Ve.invalid_type,expected:je.void,received:l.parsedType}),gI}return la(e.data)}};g1.create=t=>new g1({typeName:QI.ZodVoid,...rt(t)});var Ku=class t extends ht{_parse(e){let{ctx:I,status:l}=this._processInputParams(e),n=this._def;if(I.parsedType!==je.array)return xe(I,{code:Ve.invalid_type,expected:je.array,received:I.parsedType}),gI;if(n.exactLength!==null){let r=I.data.length>n.exactLength.value,s=I.data.length<n.exactLength.value;(r||s)&&(xe(I,{code:r?Ve.too_big:Ve.too_small,minimum:s?n.exactLength.value:void 0,maximum:r?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),l.dirty())}if(n.minLength!==null&&I.data.length<n.minLength.value&&(xe(I,{code:Ve.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),l.dirty()),n.maxLength!==null&&I.data.length>n.maxLength.value&&(xe(I,{code:Ve.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),l.dirty()),I.common.async)return Promise.all([...I.data].map((r,s)=>n.type._parseAsync(new Vi(I,r,I.path,s)))).then(r=>Rs.mergeArray(l,r));let c=[...I.data].map((r,s)=>n.type._parseSync(new Vi(I,r,I.path,s)));return Rs.mergeArray(l,c)}get element(){return this._def.type}min(e,I){return new t({...this._def,minLength:{value:e,message:rI.toString(I)}})}max(e,I){return new t({...this._def,maxLength:{value:e,message:rI.toString(I)}})}length(e,I){return new t({...this._def,exactLength:{value:e,message:rI.toString(I)}})}nonempty(e){return this.min(1,e)}};Ku.create=(t,e)=>new Ku({type:t,minLength:null,maxLength:null,exactLength:null,typeName:QI.ZodArray,...rt(e)});function R1(t){if(t instanceof oG){let e={};for(let I in t.shape){let l=t.shape[I];e[I]=Yi.create(R1(l))}return new oG({...t._def,shape:()=>e})}else return t instanceof Ku?new Ku({...t._def,type:R1(t.element)}):t instanceof Yi?Yi.create(R1(t.unwrap())):t instanceof hp?hp.create(R1(t.unwrap())):t instanceof mp?mp.create(t.items.map(e=>R1(e))):t}var oG=class t extends ht{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),I=zt.objectKeys(e);return this._cached={shape:e,keys:I},this._cached}_parse(e){if(this._getType(e)!==je.object){let G=this._getOrReturnCtx(e);return xe(G,{code:Ve.invalid_type,expected:je.object,received:G.parsedType}),gI}let{status:l,ctx:n}=this._processInputParams(e),{shape:c,keys:r}=this._getCached(),s=[];if(!(this._def.catchall instanceof Mb&&this._def.unknownKeys==="strip"))for(let G in n.data)r.includes(G)||s.push(G);let a=[];for(let G of r){let d=c[G],i=n.data[G];a.push({key:{status:"valid",value:G},value:d._parse(new Vi(n,i,n.path,G)),alwaysSet:G in n.data})}if(this._def.catchall instanceof Mb){let G=this._def.unknownKeys;if(G==="passthrough")for(let d of s)a.push({key:{status:"valid",value:d},value:{status:"valid",value:n.data[d]}});else if(G==="strict")s.length>0&&(xe(n,{code:Ve.unrecognized_keys,keys:s}),l.dirty());else if(G!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let G=this._def.catchall;for(let d of s){let i=n.data[d];a.push({key:{status:"valid",value:d},value:G._parse(new Vi(n,i,n.path,d)),alwaysSet:d in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let G=[];for(let d of a){let i=await d.key,b=await d.value;G.push({key:i,value:b,alwaysSet:d.alwaysSet})}return G}).then(G=>Rs.mergeObjectSync(l,G)):Rs.mergeObjectSync(l,a)}get shape(){return this._def.shape()}strict(e){return rI.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(I,l)=>{let n=this._def.errorMap?.(I,l).message??l.defaultError;return I.code==="unrecognized_keys"?{message:rI.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:QI.ZodObject})}setKey(e,I){return this.augment({[e]:I})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let I={};for(let l of zt.objectKeys(e))e[l]&&this.shape[l]&&(I[l]=this.shape[l]);return new t({...this._def,shape:()=>I})}omit(e){let I={};for(let l of zt.objectKeys(this.shape))e[l]||(I[l]=this.shape[l]);return new t({...this._def,shape:()=>I})}deepPartial(){return R1(this)}partial(e){let I={};for(let l of zt.objectKeys(this.shape)){let n=this.shape[l];e&&!e[l]?I[l]=n:I[l]=n.optional()}return new t({...this._def,shape:()=>I})}required(e){let I={};for(let l of zt.objectKeys(this.shape))if(e&&!e[l])I[l]=this.shape[l];else{let c=this.shape[l];for(;c instanceof Yi;)c=c._def.innerType;I[l]=c}return new t({...this._def,shape:()=>I})}keyof(){return _Ke(zt.objectKeys(this.shape))}};oG.create=(t,e)=>new oG({shape:()=>t,unknownKeys:"strip",catchall:Mb.create(),typeName:QI.ZodObject,...rt(e)});oG.strictCreate=(t,e)=>new oG({shape:()=>t,unknownKeys:"strict",catchall:Mb.create(),typeName:QI.ZodObject,...rt(e)});oG.lazycreate=(t,e)=>new oG({shape:t,unknownKeys:"strip",catchall:Mb.create(),typeName:QI.ZodObject,...rt(e)});var Rg=class extends ht{_parse(e){let{ctx:I}=this._processInputParams(e),l=this._def.options;function n(c){for(let s of c)if(s.result.status==="valid")return s.result;for(let s of c)if(s.result.status==="dirty")return I.common.issues.push(...s.ctx.common.issues),s.result;let r=c.map(s=>new aG(s.ctx.common.issues));return xe(I,{code:Ve.invalid_union,unionErrors:r}),gI}if(I.common.async)return Promise.all(l.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(n);{let c,r=[];for(let a of l){let G={...I,common:{...I.common,issues:[]},parent:null},d=a._parseSync({data:I.data,path:I.path,parent:G});if(d.status==="valid")return d;d.status==="dirty"&&!c&&(c={result:d,ctx:G}),G.common.issues.length&&r.push(G.common.issues)}if(c)return I.common.issues.push(...c.ctx.common.issues),c.result;let s=r.map(a=>new aG(a));return xe(I,{code:Ve.invalid_union,unionErrors:s}),gI}}get options(){return this._def.options}};Rg.create=(t,e)=>new Rg({options:t,typeName:QI.ZodUnion,...rt(e)});var ju=t=>t instanceof gg?ju(t.schema):t instanceof Ri?ju(t.innerType()):t instanceof Fg?[t.value]:t instanceof Ag?t.options:t instanceof Qg?zt.objectValues(t.enum):t instanceof wg?ju(t._def.innerType):t instanceof Yg?[void 0]:t instanceof Vg?[null]:t instanceof Yi?[void 0,...ju(t.unwrap())]:t instanceof hp?[null,...ju(t.unwrap())]:t instanceof Sx||t instanceof Eg?ju(t.unwrap()):t instanceof Xg?ju(t._def.innerType):[],Mq=class t extends ht{_parse(e){let{ctx:I}=this._processInputParams(e);if(I.parsedType!==je.object)return xe(I,{code:Ve.invalid_type,expected:je.object,received:I.parsedType}),gI;let l=this.discriminator,n=I.data[l],c=this.optionsMap.get(n);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}):(xe(I,{code:Ve.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[l]}),gI)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,I,l){let n=new Map;for(let c of I){let r=ju(c.shape[e]);if(!r.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of r){if(n.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);n.set(s,c)}}return new t({typeName:QI.ZodDiscriminatedUnion,discriminator:e,options:I,optionsMap:n,...rt(l)})}};function gpe(t,e){let I=bp(t),l=bp(e);if(t===e)return{valid:!0,data:t};if(I===je.object&&l===je.object){let n=zt.objectKeys(e),c=zt.objectKeys(t).filter(s=>n.indexOf(s)!==-1),r={...t,...e};for(let s of c){let a=gpe(t[s],e[s]);if(!a.valid)return{valid:!1};r[s]=a.data}return{valid:!0,data:r}}else if(I===je.array&&l===je.array){if(t.length!==e.length)return{valid:!1};let n=[];for(let c=0;c<t.length;c++){let r=t[c],s=e[c],a=gpe(r,s);if(!a.valid)return{valid:!1};n.push(a.data)}return{valid:!0,data:n}}else return I===je.date&&l===je.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var yg=class extends ht{_parse(e){let{status:I,ctx:l}=this._processInputParams(e),n=(c,r)=>{if(Sq(c)||Sq(r))return gI;let s=gpe(c.value,r.value);return s.valid?((Oq(c)||Oq(r))&&I.dirty(),{status:I.value,value:s.data}):(xe(l,{code:Ve.invalid_intersection_types}),gI)};return l.common.async?Promise.all([this._def.left._parseAsync({data:l.data,path:l.path,parent:l}),this._def.right._parseAsync({data:l.data,path:l.path,parent:l})]).then(([c,r])=>n(c,r)):n(this._def.left._parseSync({data:l.data,path:l.path,parent:l}),this._def.right._parseSync({data:l.data,path:l.path,parent:l}))}};yg.create=(t,e,I)=>new yg({left:t,right:e,typeName:QI.ZodIntersection,...rt(I)});var mp=class t extends ht{_parse(e){let{status:I,ctx:l}=this._processInputParams(e);if(l.parsedType!==je.array)return xe(l,{code:Ve.invalid_type,expected:je.array,received:l.parsedType}),gI;if(l.data.length<this._def.items.length)return xe(l,{code:Ve.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),gI;!this._def.rest&&l.data.length>this._def.items.length&&(xe(l,{code:Ve.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),I.dirty());let c=[...l.data].map((r,s)=>{let a=this._def.items[s]||this._def.rest;return a?a._parse(new Vi(l,r,l.path,s)):null}).filter(r=>!!r);return l.common.async?Promise.all(c).then(r=>Rs.mergeArray(I,r)):Rs.mergeArray(I,c)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};mp.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new mp({items:t,typeName:QI.ZodTuple,rest:null,...rt(e)})};var Tq=class t extends ht{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:I,ctx:l}=this._processInputParams(e);if(l.parsedType!==je.object)return xe(l,{code:Ve.invalid_type,expected:je.object,received:l.parsedType}),gI;let n=[],c=this._def.keyType,r=this._def.valueType;for(let s in l.data)n.push({key:c._parse(new Vi(l,s,l.path,s)),value:r._parse(new Vi(l,l.data[s],l.path,s)),alwaysSet:s in l.data});return l.common.async?Rs.mergeObjectAsync(I,n):Rs.mergeObjectSync(I,n)}get element(){return this._def.valueType}static create(e,I,l){return I instanceof ht?new t({keyType:e,valueType:I,typeName:QI.ZodRecord,...rt(l)}):new t({keyType:LV.create(),valueType:e,typeName:QI.ZodRecord,...rt(I)})}},F1=class extends ht{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:I,ctx:l}=this._processInputParams(e);if(l.parsedType!==je.map)return xe(l,{code:Ve.invalid_type,expected:je.map,received:l.parsedType}),gI;let n=this._def.keyType,c=this._def.valueType,r=[...l.data.entries()].map(([s,a],G)=>({key:n._parse(new Vi(l,s,l.path,[G,"key"])),value:c._parse(new Vi(l,a,l.path,[G,"value"]))}));if(l.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let a of r){let G=await a.key,d=await a.value;if(G.status==="aborted"||d.status==="aborted")return gI;(G.status==="dirty"||d.status==="dirty")&&I.dirty(),s.set(G.value,d.value)}return{status:I.value,value:s}})}else{let s=new Map;for(let a of r){let G=a.key,d=a.value;if(G.status==="aborted"||d.status==="aborted")return gI;(G.status==="dirty"||d.status==="dirty")&&I.dirty(),s.set(G.value,d.value)}return{status:I.value,value:s}}}};F1.create=(t,e,I)=>new F1({valueType:e,keyType:t,typeName:QI.ZodMap,...rt(I)});var A1=class t extends ht{_parse(e){let{status:I,ctx:l}=this._processInputParams(e);if(l.parsedType!==je.set)return xe(l,{code:Ve.invalid_type,expected:je.set,received:l.parsedType}),gI;let n=this._def;n.minSize!==null&&l.data.size<n.minSize.value&&(xe(l,{code:Ve.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),I.dirty()),n.maxSize!==null&&l.data.size>n.maxSize.value&&(xe(l,{code:Ve.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),I.dirty());let c=this._def.valueType;function r(a){let G=new Set;for(let d of a){if(d.status==="aborted")return gI;d.status==="dirty"&&I.dirty(),G.add(d.value)}return{status:I.value,value:G}}let s=[...l.data.values()].map((a,G)=>c._parse(new Vi(l,a,l.path,G)));return l.common.async?Promise.all(s).then(a=>r(a)):r(s)}min(e,I){return new t({...this._def,minSize:{value:e,message:rI.toString(I)}})}max(e,I){return new t({...this._def,maxSize:{value:e,message:rI.toString(I)}})}size(e,I){return this.min(e,I).max(e,I)}nonempty(e){return this.min(1,e)}};A1.create=(t,e)=>new A1({valueType:t,minSize:null,maxSize:null,typeName:QI.ZodSet,...rt(e)});var jq=class t extends ht{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:I}=this._processInputParams(e);if(I.parsedType!==je.function)return xe(I,{code:Ve.invalid_type,expected:je.function,received:I.parsedType}),gI;function l(s,a){return Ux({data:s,path:I.path,errorMaps:[I.common.contextualErrorMap,I.schemaErrorMap,Y1(),Tu].filter(G=>!!G),issueData:{code:Ve.invalid_arguments,argumentsError:a}})}function n(s,a){return Ux({data:s,path:I.path,errorMaps:[I.common.contextualErrorMap,I.schemaErrorMap,Y1(),Tu].filter(G=>!!G),issueData:{code:Ve.invalid_return_type,returnTypeError:a}})}let c={errorMap:I.common.contextualErrorMap},r=I.data;if(this._def.returns instanceof fV){let s=this;return la(async function(...a){let G=new aG([]),d=await s._def.args.parseAsync(a,c).catch(m=>{throw G.addIssue(l(a,m)),G}),i=await Reflect.apply(r,this,d);return await s._def.returns._def.type.parseAsync(i,c).catch(m=>{throw G.addIssue(n(i,m)),G})})}else{let s=this;return la(function(...a){let G=s._def.args.safeParse(a,c);if(!G.success)throw new aG([l(a,G.error)]);let d=Reflect.apply(r,this,G.data),i=s._def.returns.safeParse(d,c);if(!i.success)throw new aG([n(d,i.error)]);return i.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:mp.create(e).rest(Du.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,I,l){return new t({args:e||mp.create([]).rest(Du.create()),returns:I||Du.create(),typeName:QI.ZodFunction,...rt(l)})}},gg=class extends ht{get schema(){return this._def.getter()}_parse(e){let{ctx:I}=this._processInputParams(e);return this._def.getter()._parse({data:I.data,path:I.path,parent:I})}};gg.create=(t,e)=>new gg({getter:t,typeName:QI.ZodLazy,...rt(e)});var Fg=class extends ht{_parse(e){if(e.data!==this._def.value){let I=this._getOrReturnCtx(e);return xe(I,{received:I.data,code:Ve.invalid_literal,expected:this._def.value}),gI}return{status:"valid",value:e.data}}get value(){return this._def.value}};Fg.create=(t,e)=>new Fg({value:t,typeName:QI.ZodLiteral,...rt(e)});function _Ke(t,e){return new Ag({values:t,typeName:QI.ZodEnum,...rt(e)})}var Ag=class t extends ht{_parse(e){if(typeof e.data!="string"){let I=this._getOrReturnCtx(e),l=this._def.values;return xe(I,{expected:zt.joinValues(l),received:I.parsedType,code:Ve.invalid_type}),gI}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let I=this._getOrReturnCtx(e),l=this._def.values;return xe(I,{received:I.data,code:Ve.invalid_enum_value,options:l}),gI}return la(e.data)}get options(){return this._def.values}get enum(){let e={};for(let I of this._def.values)e[I]=I;return e}get Values(){let e={};for(let I of this._def.values)e[I]=I;return e}get Enum(){let e={};for(let I of this._def.values)e[I]=I;return e}extract(e,I=this._def){return t.create(e,{...this._def,...I})}exclude(e,I=this._def){return t.create(this.options.filter(l=>!e.includes(l)),{...this._def,...I})}};Ag.create=_Ke;var Qg=class extends ht{_parse(e){let I=zt.getValidEnumValues(this._def.values),l=this._getOrReturnCtx(e);if(l.parsedType!==je.string&&l.parsedType!==je.number){let n=zt.objectValues(I);return xe(l,{expected:zt.joinValues(n),received:l.parsedType,code:Ve.invalid_type}),gI}if(this._cache||(this._cache=new Set(zt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=zt.objectValues(I);return xe(l,{received:l.data,code:Ve.invalid_enum_value,options:n}),gI}return la(e.data)}get enum(){return this._def.values}};Qg.create=(t,e)=>new Qg({values:t,typeName:QI.ZodNativeEnum,...rt(e)});var fV=class extends ht{unwrap(){return this._def.type}_parse(e){let{ctx:I}=this._processInputParams(e);if(I.parsedType!==je.promise&&I.common.async===!1)return xe(I,{code:Ve.invalid_type,expected:je.promise,received:I.parsedType}),gI;let l=I.parsedType===je.promise?I.data:Promise.resolve(I.data);return la(l.then(n=>this._def.type.parseAsync(n,{path:I.path,errorMap:I.common.contextualErrorMap})))}};fV.create=(t,e)=>new fV({type:t,typeName:QI.ZodPromise,...rt(e)});var Ri=class extends ht{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===QI.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:I,ctx:l}=this._processInputParams(e),n=this._def.effect||null,c={addIssue:r=>{xe(l,r),r.fatal?I.abort():I.dirty()},get path(){return l.path}};if(c.addIssue=c.addIssue.bind(c),n.type==="preprocess"){let r=n.transform(l.data,c);if(l.common.async)return Promise.resolve(r).then(async s=>{if(I.value==="aborted")return gI;let a=await this._def.schema._parseAsync({data:s,path:l.path,parent:l});return a.status==="aborted"?gI:a.status==="dirty"?pg(a.value):I.value==="dirty"?pg(a.value):a});{if(I.value==="aborted")return gI;let s=this._def.schema._parseSync({data:r,path:l.path,parent:l});return s.status==="aborted"?gI:s.status==="dirty"?pg(s.value):I.value==="dirty"?pg(s.value):s}}if(n.type==="refinement"){let r=s=>{let a=n.refinement(s,c);if(l.common.async)return Promise.resolve(a);if(a instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(l.common.async===!1){let s=this._def.schema._parseSync({data:l.data,path:l.path,parent:l});return s.status==="aborted"?gI:(s.status==="dirty"&&I.dirty(),r(s.value),{status:I.value,value:s.value})}else return this._def.schema._parseAsync({data:l.data,path:l.path,parent:l}).then(s=>s.status==="aborted"?gI:(s.status==="dirty"&&I.dirty(),r(s.value).then(()=>({status:I.value,value:s.value}))))}if(n.type==="transform")if(l.common.async===!1){let r=this._def.schema._parseSync({data:l.data,path:l.path,parent:l});if(!JV(r))return gI;let s=n.transform(r.value,c);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:I.value,value:s}}else return this._def.schema._parseAsync({data:l.data,path:l.path,parent:l}).then(r=>JV(r)?Promise.resolve(n.transform(r.value,c)).then(s=>({status:I.value,value:s})):gI);zt.assertNever(n)}};Ri.create=(t,e,I)=>new Ri({schema:t,typeName:QI.ZodEffects,effect:e,...rt(I)});Ri.createWithPreprocess=(t,e,I)=>new Ri({schema:e,effect:{type:"preprocess",transform:t},typeName:QI.ZodEffects,...rt(I)});var Yi=class extends ht{_parse(e){return this._getType(e)===je.undefined?la(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Yi.create=(t,e)=>new Yi({innerType:t,typeName:QI.ZodOptional,...rt(e)});var hp=class extends ht{_parse(e){return this._getType(e)===je.null?la(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};hp.create=(t,e)=>new hp({innerType:t,typeName:QI.ZodNullable,...rt(e)});var wg=class extends ht{_parse(e){let{ctx:I}=this._processInputParams(e),l=I.data;return I.parsedType===je.undefined&&(l=this._def.defaultValue()),this._def.innerType._parse({data:l,path:I.path,parent:I})}removeDefault(){return this._def.innerType}};wg.create=(t,e)=>new wg({innerType:t,typeName:QI.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...rt(e)});var Xg=class extends ht{_parse(e){let{ctx:I}=this._processInputParams(e),l={...I,common:{...I.common,issues:[]}},n=this._def.innerType._parse({data:l.data,path:l.path,parent:{...l}});return V1(n)?n.then(c=>({status:"valid",value:c.status==="valid"?c.value:this._def.catchValue({get error(){return new aG(l.common.issues)},input:l.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new aG(l.common.issues)},input:l.data})}}removeCatch(){return this._def.innerType}};Xg.create=(t,e)=>new Xg({innerType:t,typeName:QI.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...rt(e)});var Q1=class extends ht{_parse(e){if(this._getType(e)!==je.nan){let l=this._getOrReturnCtx(e);return xe(l,{code:Ve.invalid_type,expected:je.nan,received:l.parsedType}),gI}return{status:"valid",value:e.data}}};Q1.create=t=>new Q1({typeName:QI.ZodNaN,...rt(t)});var CDI=Symbol("zod_brand"),Sx=class extends ht{_parse(e){let{ctx:I}=this._processInputParams(e),l=I.data;return this._def.type._parse({data:l,path:I.path,parent:I})}unwrap(){return this._def.type}},Ox=class t extends ht{_parse(e){let{status:I,ctx:l}=this._processInputParams(e);if(l.common.async)return(async()=>{let c=await this._def.in._parseAsync({data:l.data,path:l.path,parent:l});return c.status==="aborted"?gI:c.status==="dirty"?(I.dirty(),pg(c.value)):this._def.out._parseAsync({data:c.value,path:l.path,parent:l})})();{let n=this._def.in._parseSync({data:l.data,path:l.path,parent:l});return n.status==="aborted"?gI:n.status==="dirty"?(I.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:l.path,parent:l})}}static create(e,I){return new t({in:e,out:I,typeName:QI.ZodPipeline})}},Eg=class extends ht{_parse(e){let I=this._def.innerType._parse(e),l=n=>(JV(n)&&(n.value=Object.freeze(n.value)),n);return V1(I)?I.then(n=>l(n)):l(I)}unwrap(){return this._def.innerType}};Eg.create=(t,e)=>new Eg({innerType:t,typeName:QI.ZodReadonly,...rt(e)});function DKe(t,e){let I=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof I=="string"?{message:I}:I}function $Ke(t,e={},I){return t?kV.create().superRefine((l,n)=>{let c=t(l);if(c instanceof Promise)return c.then(r=>{if(!r){let s=DKe(e,l),a=s.fatal??I??!0;n.addIssue({code:"custom",...s,fatal:a})}});if(!c){let r=DKe(e,l),s=r.fatal??I??!0;n.addIssue({code:"custom",...r,fatal:s})}}):kV.create()}var JDI={object:oG.lazycreate},QI;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(QI||(QI={}));var LDI=(t,e={message:`Input not instance of ${t.name}`})=>$Ke(I=>I instanceof t,e),ae=LV.create,na=Zg.create,kDI=Q1.create,fDI=ug.create,bn=Wg.create,xDI=Ng.create,BDI=y1.create,zDI=Yg.create,UDI=Vg.create,Fpe=kV.create,pp=Du.create,SDI=Mb.create,ODI=g1.create,ys=Ku.create,Ue=oG.create,MDI=oG.strictCreate,ca=Rg.create,Mx=Mq.create,TDI=yg.create,Ape=mp.create,w1=Tq.create,jDI=F1.create,DDI=A1.create,KDI=jq.create,PDI=gg.create,ZI=Fg.create,yi=Ag.create,qDI=Qg.create,_DI=fV.create,$DI=Ri.create,eKI=Yi.create,IKI=hp.create,tKI=Ri.createWithPreprocess,lKI=Ox.create,nKI=()=>ae().optional(),cKI=()=>na().optional(),rKI=()=>bn().optional(),Tx={string:t=>LV.create({...t,coerce:!0}),number:t=>Zg.create({...t,coerce:!0}),boolean:t=>Wg.create({...t,coerce:!0}),bigint:t=>ug.create({...t,coerce:!0}),date:t=>Ng.create({...t,coerce:!0})};var sKI=gI;var X1="2025-06-18";var ePe=[X1,"2025-03-26","2024-11-05","2024-10-07"],Kq="2.0",IPe=Y.union([Y.string(),Y.number().int()]),tPe=Y.string(),aKI=Y.object({progressToken:Y.optional(IPe)}).passthrough(),Ai=Y.object({_meta:Y.optional(aKI)}).passthrough(),GG=Y.object({method:Y.string(),params:Y.optional(Ai)}),jx=Y.object({_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),Zp=Y.object({method:Y.string(),params:Y.optional(jx)}),Qi=Y.object({_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),Pq=Y.union([Y.string(),Y.number().int()]),lPe=Y.object({jsonrpc:Y.literal(Kq),id:Pq}).merge(GG).strict(),qq=t=>lPe.safeParse(t).success,nPe=Y.object({jsonrpc:Y.literal(Kq)}).merge(Zp).strict(),cPe=t=>nPe.safeParse(t).success,rPe=Y.object({jsonrpc:Y.literal(Kq),id:Pq,result:Qi}).strict(),Dx=t=>rPe.safeParse(t).success,gi;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError"})(gi||(gi={}));var sPe=Y.object({jsonrpc:Y.literal(Kq),id:Pq,error:Y.object({code:Y.number().int(),message:Y.string(),data:Y.optional(Y.unknown())})}).strict(),aPe=t=>sPe.safeParse(t).success,xV=Y.union([lPe,nPe,rPe,sPe]),Hg=Qi.strict(),_q=Zp.extend({method:Y.literal("notifications/cancelled"),params:jx.extend({requestId:Pq,reason:Y.string().optional()})}),$q=Y.object({src:Y.string(),mimeType:Y.optional(Y.string()),sizes:Y.optional(Y.string())}).passthrough(),Kx=Y.object({name:Y.string(),title:Y.optional(Y.string())}).passthrough(),oPe=Kx.extend({version:Y.string(),websiteUrl:Y.optional(Y.string()),icons:Y.optional(Y.array($q))}),oKI=Y.object({experimental:Y.optional(Y.object({}).passthrough()),sampling:Y.optional(Y.object({}).passthrough()),elicitation:Y.optional(Y.object({}).passthrough()),roots:Y.optional(Y.object({listChanged:Y.optional(Y.boolean())}).passthrough())}).passthrough(),GKI=GG.extend({method:Y.literal("initialize"),params:Ai.extend({protocolVersion:Y.string(),capabilities:oKI,clientInfo:oPe})});var dKI=Y.object({experimental:Y.optional(Y.object({}).passthrough()),logging:Y.optional(Y.object({}).passthrough()),completions:Y.optional(Y.object({}).passthrough()),prompts:Y.optional(Y.object({listChanged:Y.optional(Y.boolean())}).passthrough()),resources:Y.optional(Y.object({subscribe:Y.optional(Y.boolean()),listChanged:Y.optional(Y.boolean())}).passthrough()),tools:Y.optional(Y.object({listChanged:Y.optional(Y.boolean())}).passthrough())}).passthrough(),Qpe=Qi.extend({protocolVersion:Y.string(),capabilities:dKI,serverInfo:oPe,instructions:Y.optional(Y.string())}),GPe=Zp.extend({method:Y.literal("notifications/initialized")}),dPe=t=>GPe.safeParse(t).success,e8=GG.extend({method:Y.literal("ping")}),iKI=Y.object({progress:Y.number(),total:Y.optional(Y.number()),message:Y.optional(Y.string())}).passthrough(),I8=Zp.extend({method:Y.literal("notifications/progress"),params:jx.merge(iKI).extend({progressToken:IPe})}),t8=GG.extend({params:Ai.extend({cursor:Y.optional(tPe)}).optional()}),l8=Qi.extend({nextCursor:Y.optional(tPe)}),iPe=Y.object({uri:Y.string(),mimeType:Y.optional(Y.string()),_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),bPe=iPe.extend({text:Y.string()}),wpe=Y.string().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),mPe=iPe.extend({blob:wpe}),hPe=Kx.extend({uri:Y.string(),description:Y.optional(Y.string()),mimeType:Y.optional(Y.string()),icons:Y.optional(Y.array($q)),_meta:Y.optional(Y.object({}).passthrough())}),bKI=Kx.extend({uriTemplate:Y.string(),description:Y.optional(Y.string()),mimeType:Y.optional(Y.string()),_meta:Y.optional(Y.object({}).passthrough())}),mKI=t8.extend({method:Y.literal("resources/list")}),Xpe=l8.extend({resources:Y.array(hPe)}),hKI=t8.extend({method:Y.literal("resources/templates/list")}),Epe=l8.extend({resourceTemplates:Y.array(bKI)}),pKI=GG.extend({method:Y.literal("resources/read"),params:Ai.extend({uri:Y.string()})}),Hpe=Qi.extend({contents:Y.array(Y.union([bPe,mPe]))}),ZKI=Zp.extend({method:Y.literal("notifications/resources/list_changed")}),uKI=GG.extend({method:Y.literal("resources/subscribe"),params:Ai.extend({uri:Y.string()})}),WKI=GG.extend({method:Y.literal("resources/unsubscribe"),params:Ai.extend({uri:Y.string()})}),NKI=Zp.extend({method:Y.literal("notifications/resources/updated"),params:jx.extend({uri:Y.string()})}),YKI=Y.object({name:Y.string(),description:Y.optional(Y.string()),required:Y.optional(Y.boolean())}).passthrough(),VKI=Kx.extend({description:Y.optional(Y.string()),arguments:Y.optional(Y.array(YKI)),icons:Y.optional(Y.array($q)),_meta:Y.optional(Y.object({}).passthrough())}),RKI=t8.extend({method:Y.literal("prompts/list")}),vpe=l8.extend({prompts:Y.array(VKI)}),yKI=GG.extend({method:Y.literal("prompts/get"),params:Ai.extend({name:Y.string(),arguments:Y.optional(Y.record(Y.string()))})}),Cpe=Y.object({type:Y.literal("text"),text:Y.string(),_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),Jpe=Y.object({type:Y.literal("image"),data:wpe,mimeType:Y.string(),_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),Lpe=Y.object({type:Y.literal("audio"),data:wpe,mimeType:Y.string(),_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),gKI=Y.object({type:Y.literal("resource"),resource:Y.union([bPe,mPe]),_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),FKI=hPe.extend({type:Y.literal("resource_link")}),pPe=Y.union([Cpe,Jpe,Lpe,FKI,gKI]),AKI=Y.object({role:Y.enum(["user","assistant"]),content:pPe}).passthrough(),kpe=Qi.extend({description:Y.optional(Y.string()),messages:Y.array(AKI)}),QKI=Zp.extend({method:Y.literal("notifications/prompts/list_changed")}),wKI=Y.object({title:Y.optional(Y.string()),readOnlyHint:Y.optional(Y.boolean()),destructiveHint:Y.optional(Y.boolean()),idempotentHint:Y.optional(Y.boolean()),openWorldHint:Y.optional(Y.boolean())}).passthrough(),XKI=Kx.extend({description:Y.optional(Y.string()),inputSchema:Y.object({type:Y.literal("object"),properties:Y.optional(Y.object({}).passthrough()),required:Y.optional(Y.array(Y.string()))}).passthrough(),outputSchema:Y.optional(Y.object({type:Y.literal("object"),properties:Y.optional(Y.object({}).passthrough()),required:Y.optional(Y.array(Y.string()))}).passthrough()),annotations:Y.optional(wKI),icons:Y.optional(Y.array($q)),_meta:Y.optional(Y.object({}).passthrough())}),EKI=t8.extend({method:Y.literal("tools/list")}),fpe=l8.extend({tools:Y.array(XKI)}),n8=Qi.extend({content:Y.array(pPe).default([]),structuredContent:Y.object({}).passthrough().optional(),isError:Y.optional(Y.boolean())}),prn=n8.or(Qi.extend({toolResult:Y.unknown()})),HKI=GG.extend({method:Y.literal("tools/call"),params:Ai.extend({name:Y.string(),arguments:Y.optional(Y.record(Y.unknown()))})}),vKI=Zp.extend({method:Y.literal("notifications/tools/list_changed")}),ZPe=Y.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),CKI=GG.extend({method:Y.literal("logging/setLevel"),params:Ai.extend({level:ZPe})}),JKI=Zp.extend({method:Y.literal("notifications/message"),params:jx.extend({level:ZPe,logger:Y.optional(Y.string()),data:Y.unknown()})}),LKI=Y.object({name:Y.string().optional()}).passthrough(),kKI=Y.object({hints:Y.optional(Y.array(LKI)),costPriority:Y.optional(Y.number().min(0).max(1)),speedPriority:Y.optional(Y.number().min(0).max(1)),intelligencePriority:Y.optional(Y.number().min(0).max(1))}).passthrough(),fKI=Y.object({role:Y.enum(["user","assistant"]),content:Y.union([Cpe,Jpe,Lpe])}).passthrough(),xKI=GG.extend({method:Y.literal("sampling/createMessage"),params:Ai.extend({messages:Y.array(fKI),systemPrompt:Y.optional(Y.string()),includeContext:Y.optional(Y.enum(["none","thisServer","allServers"])),temperature:Y.optional(Y.number()),maxTokens:Y.number().int(),stopSequences:Y.optional(Y.array(Y.string())),metadata:Y.optional(Y.object({}).passthrough()),modelPreferences:Y.optional(kKI)})}),BKI=Qi.extend({model:Y.string(),stopReason:Y.optional(Y.enum(["endTurn","stopSequence","maxTokens"]).or(Y.string())),role:Y.enum(["user","assistant"]),content:Y.discriminatedUnion("type",[Cpe,Jpe,Lpe])}),zKI=Y.object({type:Y.literal("boolean"),title:Y.optional(Y.string()),description:Y.optional(Y.string()),default:Y.optional(Y.boolean())}).passthrough(),UKI=Y.object({type:Y.literal("string"),title:Y.optional(Y.string()),description:Y.optional(Y.string()),minLength:Y.optional(Y.number()),maxLength:Y.optional(Y.number()),format:Y.optional(Y.enum(["email","uri","date","date-time"]))}).passthrough(),SKI=Y.object({type:Y.enum(["number","integer"]),title:Y.optional(Y.string()),description:Y.optional(Y.string()),minimum:Y.optional(Y.number()),maximum:Y.optional(Y.number())}).passthrough(),OKI=Y.object({type:Y.literal("string"),title:Y.optional(Y.string()),description:Y.optional(Y.string()),enum:Y.array(Y.string()),enumNames:Y.optional(Y.array(Y.string()))}).passthrough(),MKI=Y.union([zKI,UKI,SKI,OKI]),TKI=GG.extend({method:Y.literal("elicitation/create"),params:Ai.extend({message:Y.string(),requestedSchema:Y.object({type:Y.literal("object"),properties:Y.record(Y.string(),MKI),required:Y.optional(Y.array(Y.string()))}).passthrough()})}),jKI=Qi.extend({action:Y.enum(["accept","decline","cancel"]),content:Y.optional(Y.record(Y.string(),Y.unknown()))}),DKI=Y.object({type:Y.literal("ref/resource"),uri:Y.string()}).passthrough();var KKI=Y.object({type:Y.literal("ref/prompt"),name:Y.string()}).passthrough(),PKI=GG.extend({method:Y.literal("completion/complete"),params:Ai.extend({ref:Y.union([KKI,DKI]),argument:Y.object({name:Y.string(),value:Y.string()}).passthrough(),context:Y.optional(Y.object({arguments:Y.optional(Y.record(Y.string(),Y.string()))}))})}),xpe=Qi.extend({completion:Y.object({values:Y.array(Y.string()).max(100),total:Y.optional(Y.number().int()),hasMore:Y.optional(Y.boolean())}).passthrough()}),qKI=Y.object({uri:Y.string().startsWith("file://"),name:Y.optional(Y.string()),_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),_KI=GG.extend({method:Y.literal("roots/list")}),$KI=Qi.extend({roots:Y.array(qKI)}),ePI=Zp.extend({method:Y.literal("notifications/roots/list_changed")}),Zrn=Y.union([e8,GKI,PKI,CKI,yKI,RKI,mKI,hKI,pKI,uKI,WKI,HKI,EKI]),urn=Y.union([_q,I8,GPe,ePI]),Wrn=Y.union([Hg,BKI,jKI,$KI]),Nrn=Y.union([e8,xKI,TKI,_KI]),Yrn=Y.union([_q,I8,JKI,NKI,ZKI,vKI,QKI]),Vrn=Y.union([Hg,Qpe,xpe,kpe,vpe,Xpe,Epe,Hpe,n8,fpe]),Fi=class extends Error{constructor(e,I,l){super(`MCP error ${e}: ${I}`),this.code=e,this.data=l,this.name="McpError"}};var IPI=6e4,c8=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this.setNotificationHandler(_q,I=>{let l=this._requestHandlerAbortControllers.get(I.params.requestId);l?.abort(I.params.reason)}),this.setNotificationHandler(I8,I=>{this._onprogress(I)}),this.setRequestHandler(e8,I=>({}))}_setupTimeout(e,I,l,n,c=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,I),startTime:Date.now(),timeout:I,maxTotalTimeout:l,resetTimeoutOnProgress:c,onTimeout:n})}_resetTimeout(e){let I=this._timeoutInfo.get(e);if(!I)return!1;let l=Date.now()-I.startTime;if(I.maxTotalTimeout&&l>=I.maxTotalTimeout)throw this._timeoutInfo.delete(e),new Fi(gi.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:I.maxTotalTimeout,totalElapsed:l});return clearTimeout(I.timeoutId),I.timeoutId=setTimeout(I.onTimeout,I.timeout),!0}_cleanupTimeout(e){let I=this._timeoutInfo.get(e);I&&(clearTimeout(I.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var I,l,n;this._transport=e;let c=(I=this.transport)===null||I===void 0?void 0:I.onclose;this._transport.onclose=()=>{c?.(),this._onclose()};let r=(l=this.transport)===null||l===void 0?void 0:l.onerror;this._transport.onerror=a=>{r?.(a),this._onerror(a)};let s=(n=this._transport)===null||n===void 0?void 0:n.onmessage;this._transport.onmessage=(a,G)=>{s?.(a,G),Dx(a)||aPe(a)?this._onresponse(a):qq(a)?this._onrequest(a,G):cPe(a)?this._onnotification(a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(a)}`))},await this._transport.start()}_onclose(){var e;let I=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);let l=new Fi(gi.ConnectionClosed,"Connection closed");for(let n of I.values())n(l)}_onerror(e){var I;(I=this.onerror)===null||I===void 0||I.call(this,e)}_onnotification(e){var I;let l=(I=this._notificationHandlers.get(e.method))!==null&&I!==void 0?I:this.fallbackNotificationHandler;l!==void 0&&Promise.resolve().then(()=>l(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,I){var l,n;let c=(l=this._requestHandlers.get(e.method))!==null&&l!==void 0?l:this.fallbackRequestHandler,r=this._transport;if(c===void 0){r?.send({jsonrpc:"2.0",id:e.id,error:{code:gi.MethodNotFound,message:"Method not found"}}).catch(G=>this._onerror(new Error(`Failed to send an error response: ${G}`)));return}let s=new AbortController;this._requestHandlerAbortControllers.set(e.id,s);let a={signal:s.signal,sessionId:r?.sessionId,_meta:(n=e.params)===null||n===void 0?void 0:n._meta,sendNotification:G=>this.notification(G,{relatedRequestId:e.id}),sendRequest:(G,d,i)=>this.request(G,d,{...i,relatedRequestId:e.id}),authInfo:I?.authInfo,requestId:e.id,requestInfo:I?.requestInfo};Promise.resolve().then(()=>c(e,a)).then(G=>{if(!s.signal.aborted)return r?.send({result:G,jsonrpc:"2.0",id:e.id})},G=>{var d;if(!s.signal.aborted)return r?.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(G.code)?G.code:gi.InternalError,message:(d=G.message)!==null&&d!==void 0?d:"Internal error"}})}).catch(G=>this._onerror(new Error(`Failed to send response: ${G}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:I,...l}=e.params,n=Number(I),c=this._progressHandlers.get(n);if(!c){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let r=this._responseHandlers.get(n),s=this._timeoutInfo.get(n);if(s&&r&&s.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(a){r(a);return}c(l)}_onresponse(e){let I=Number(e.id),l=this._responseHandlers.get(I);if(l===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(I),this._progressHandlers.delete(I),this._cleanupTimeout(I),Dx(e))l(e);else{let n=new Fi(e.error.code,e.error.message,e.error.data);l(n)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,I,l){let{relatedRequestId:n,resumptionToken:c,onresumptiontoken:r}=l??{};return new Promise((s,a)=>{var G,d,i,b,m,h;if(!this._transport){a(new Error("Not connected"));return}((G=this._options)===null||G===void 0?void 0:G.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(d=l?.signal)===null||d===void 0||d.throwIfAborted();let p=this._requestMessageId++,u={...e,jsonrpc:"2.0",id:p};l?.onprogress&&(this._progressHandlers.set(p,l.onprogress),u.params={...e.params,_meta:{...((i=e.params)===null||i===void 0?void 0:i._meta)||{},progressToken:p}});let W=F=>{var A;this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),(A=this._transport)===null||A===void 0||A.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(F)}},{relatedRequestId:n,resumptionToken:c,onresumptiontoken:r}).catch(k=>this._onerror(new Error(`Failed to send cancellation: ${k}`))),a(F)};this._responseHandlers.set(p,F=>{var A;if(!(!((A=l?.signal)===null||A===void 0)&&A.aborted)){if(F instanceof Error)return a(F);try{let k=I.parse(F.result);s(k)}catch(k){a(k)}}}),(b=l?.signal)===null||b===void 0||b.addEventListener("abort",()=>{var F;W((F=l?.signal)===null||F===void 0?void 0:F.reason)});let V=(m=l?.timeout)!==null&&m!==void 0?m:IPI,g=()=>W(new Fi(gi.RequestTimeout,"Request timed out",{timeout:V}));this._setupTimeout(p,V,l?.maxTotalTimeout,g,(h=l?.resetTimeoutOnProgress)!==null&&h!==void 0?h:!1),this._transport.send(u,{relatedRequestId:n,resumptionToken:c,onresumptiontoken:r}).catch(F=>{this._cleanupTimeout(p),a(F)})})}async notification(e,I){var l,n;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(e.method),((n=(l=this._options)===null||l===void 0?void 0:l.debouncedNotificationMethods)!==null&&n!==void 0?n:[]).includes(e.method)&&!e.params&&!I?.relatedRequestId){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var a;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let G={...e,jsonrpc:"2.0"};(a=this._transport)===null||a===void 0||a.send(G,I).catch(d=>this._onerror(d))});return}let s={...e,jsonrpc:"2.0"};await this._transport.send(s,I)}setRequestHandler(e,I){let l=e.shape.method.value;this.assertRequestHandlerCapability(l),this._requestHandlers.set(l,(n,c)=>Promise.resolve(I(e.parse(n),c)))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,I){this._notificationHandlers.set(e.shape.method.value,l=>Promise.resolve(I(e.parse(l))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function uPe(t,e){return Object.entries(e).reduce((I,[l,n])=>(n&&typeof n=="object"?I[l]=I[l]?{...I[l],...n}:n:I[l]=n,I),{...t})}var _qe=Ml(qqe(),1),B8=class extends c8{constructor(e,I){var l;super(I),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._capabilities=(l=I?.capabilities)!==null&&l!==void 0?l:{},this._ajv=new _qe.default}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=uPe(this._capabilities,e)}assertCapability(e,I){var l;if(!(!((l=this._serverCapabilities)===null||l===void 0)&&l[e]))throw new Error(`Server does not support ${e} (required for ${I})`)}async connect(e,I){if(await super.connect(e),e.sessionId===void 0)try{let l=await this.request({method:"initialize",params:{protocolVersion:X1,capabilities:this._capabilities,clientInfo:this._clientInfo}},Qpe,I);if(l===void 0)throw new Error(`Server sent invalid initialize result: ${l}`);if(!ePe.includes(l.protocolVersion))throw new Error(`Server's protocol version is not supported: ${l.protocolVersion}`);this._serverCapabilities=l.capabilities,this._serverVersion=l.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(l.protocolVersion),this._instructions=l.instructions,await this.notification({method:"notifications/initialized"})}catch(l){throw this.close(),l}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var I,l,n,c,r;switch(e){case"logging/setLevel":if(!(!((I=this._serverCapabilities)===null||I===void 0)&&I.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(!((l=this._serverCapabilities)===null||l===void 0)&&l.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n.resources))throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(!((c=this._serverCapabilities)===null||c===void 0)&&c.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(!((r=this._serverCapabilities)===null||r===void 0)&&r.completions))throw new Error(`Server does not support completions (required for ${e})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){var I;switch(e){case"notifications/roots/list_changed":if(!(!((I=this._capabilities.roots)===null||I===void 0)&&I.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"ping":break}}async ping(e){return this.request({method:"ping"},Hg,e)}async complete(e,I){return this.request({method:"completion/complete",params:e},xpe,I)}async setLoggingLevel(e,I){return this.request({method:"logging/setLevel",params:{level:e}},Hg,I)}async getPrompt(e,I){return this.request({method:"prompts/get",params:e},kpe,I)}async listPrompts(e,I){return this.request({method:"prompts/list",params:e},vpe,I)}async listResources(e,I){return this.request({method:"resources/list",params:e},Xpe,I)}async listResourceTemplates(e,I){return this.request({method:"resources/templates/list",params:e},Epe,I)}async readResource(e,I){return this.request({method:"resources/read",params:e},Hpe,I)}async subscribeResource(e,I){return this.request({method:"resources/subscribe",params:e},Hg,I)}async unsubscribeResource(e,I){return this.request({method:"resources/unsubscribe",params:e},Hg,I)}async callTool(e,I=n8,l){let n=await this.request({method:"tools/call",params:e},I,l),c=this.getToolOutputValidator(e.name);if(c){if(!n.structuredContent&&!n.isError)throw new Fi(gi.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(n.structuredContent)try{if(!c(n.structuredContent))throw new Fi(gi.InvalidParams,`Structured content does not match the tool's output schema: ${this._ajv.errorsText(c.errors)}`)}catch(r){throw r instanceof Fi?r:new Fi(gi.InvalidParams,`Failed to validate structured content: ${r instanceof Error?r.message:String(r)}`)}}return n}cacheToolOutputSchemas(e){this._cachedToolOutputValidators.clear();for(let I of e)if(I.outputSchema)try{let l=this._ajv.compile(I.outputSchema);this._cachedToolOutputValidators.set(I.name,l)}catch{}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,I){let l=await this.request({method:"tools/list",params:e},fpe,I);return this.cacheToolOutputSchemas(l.tools),l}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var z8=class{createClient(e,I){return new B8(e,I)}};o();o();o();o();var U8=class extends Error{constructor(e,I){super(e),this.name="ParseError",this.type=I.type,this.field=I.field,this.value=I.value,this.line=I.line}};function Rue(t){}function S8(t){if(typeof t=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:e=Rue,onError:I=Rue,onRetry:l=Rue,onComment:n}=t,c="",r=!0,s,a="",G="";function d(p){let u=r?p.replace(/^\xEF\xBB\xBF/,""):p,[W,V]=F_I(`${c}${u}`);for(let g of W)i(g);c=V,r=!1}function i(p){if(p===""){m();return}if(p.startsWith(":")){n&&n(p.slice(p.startsWith(": ")?2:1));return}let u=p.indexOf(":");if(u!==-1){let W=p.slice(0,u),V=p[u+1]===" "?2:1,g=p.slice(u+V);b(W,g,p);return}b(p,"",p)}function b(p,u,W){switch(p){case"event":G=u;break;case"data":a=`${a}${u}
1414
+ `,input_schema:{type:"object",properties:{question:{type:"string",description:"A question about the codebase. It should reference by name any topics, specific file names, and concepts that are relevant to the question and specify the desired output format."}},required:["question"]},callback:async l=>{let n,c=mz(t),r="",s="",a=c.split("/");if(a.length===2){[r,s]=a,I.info("Searching for repository insights");try{n=await Wpe(l.question,r,s,e,I),I.info(`Blackbird results: ${n}`)}catch(G){I.error(`Error occurred while searching for repository insights: ${G}`)}}return{resultType:"success",textResultForLlm:n??"No results found.",toolTelemetry:{}}}}}async function zKe(t,e,I,l,n,c,r){let s=await MKe(t),a=await lDI(t,I,l),G=xKe(I)?[new Uq(l,I,n,c,t,t.location,AM(),r).getSearch()]:[],d=t.splitEditingTools?mce(t,l,I):[EM(t,l,I)];return[s.shellTool,...s.otherTools??[],...a,...G,...d,lHe(t,e,I,l,n),El(I,b_)?eYe(t,l,n,I):void 0,t?.requireReasoning?pce(t):void 0,El(I,PEe)?qEe:void 0,await nDI(t,I,l,n)].filter(i=>i!==void 0)}async function UKe(t,e){let I=await MKe(t),l=t.splitEditingTools?mce(t,e):[EM(t,e)];return[I.shellTool,...I.otherTools??[],...l,t?.requireReasoning?pce(t):void 0].filter(n=>n!==void 0)}async function tDI(t,e,I,l,n,c,r){return[...await zKe(t,e,I,l,n,c,r),$Ee(t,l)]}var SKe=t=>({...ip,supports:{...ip.supports,reasoning:t?.thinkingMode?!0:ip.supports?.reasoning}}),ip={supports:{tool_choice:!1,reasoning:!0,parallel_tool_calls:!1},createPR:{toolInit:zKe,jitInstructions:upe},prDetails:{},respondToPRComment:{toolInit:tDI,jitInstructions:upe}},OKe=t=>({"sweagent-capi":{"claude-3.5-sonnet":{...ip,supports:{tool_choice:!1,reasoning:!1}},"claude-3.7-sonnet":{...ip,supports:{tool_choice:!1,reasoning:!1,vision:!0}},"claude-sonnet-4":{...ip,supports:{tool_choice:!1,reasoning:!0,parallel_tool_calls:!0,vision:!0},toolConfigOverrides:{splitEditingTools:!0}},"claude-sonnet-4.5":{...ip,supports:{tool_choice:!1,reasoning:!0,parallel_tool_calls:!0,vision:!0},toolConfigOverrides:{splitEditingTools:!0}},oswe:{...ip,supports:{tool_choice:!0,reasoning:!0,vision:!0}},"oswe-prime":{...ip,supports:{tool_choice:!0,reasoning:!0,vision:!0}},"gpt-5":{...ip,supports:{tool_choice:!0,reasoning:!0,parallel_tool_calls:!0,vision:!0,steering:!0},toolConfigOverrides:{splitEditingTools:!0}}}});async function MKe(t){let e=new QP(t);return{shellTool:e.getShellTool(),otherTools:[e.getWriteShellTool(),e.getReadShellTool(),e.getStopShellTool()]}}async function lDI(t,e,I){if(gbe(e,"cloud"))return[new H3(new l6(e,I,void 0)).getStoreMemory()];if(gbe(e,"local")){let l=new H3(new t6(t.location));return[l.getStoreMemory(),l.getReadMemory()]}return[]}async function nDI(t,e,I,l){if(t.includeCodeQLTool){let n=new Go(I,l),c=e.swebench_base_commit&&e.swebench_base_commit!=="undefined"?e.swebench_base_commit:await n.getCurrentCommitHash(t.location);return new yM(t,n,c,e,I).getCodeQLCheckerTool()}}o();import{execFile as cDI}from"node:child_process";import{normalize as rDI}from"node:path";import{promisify as sDI}from"node:util";var aDI=sDI(cDI);async function Vpe(t=process.cwd()){try{let I=(await aDI("git",["rev-parse","--show-toplevel"],{cwd:t,encoding:"utf8",timeout:5e3,maxBuffer:1048576})).stdout.trim();if(I)return{gitRoot:rDI(I),found:!0}}catch{}return{gitRoot:t,found:!1}}o();o();import{Writable as Q$I}from"stream";o();o();o();o();o();var Y={};Pc(Y,{BRAND:()=>CDI,DIRTY:()=>pg,EMPTY_PATH:()=>iDI,INVALID:()=>gI,NEVER:()=>sKI,OK:()=>la,ParseStatus:()=>Rs,Schema:()=>ht,ZodAny:()=>kV,ZodArray:()=>Ku,ZodBigInt:()=>ug,ZodBoolean:()=>Wg,ZodBranded:()=>Sx,ZodCatch:()=>Xg,ZodDate:()=>Ng,ZodDefault:()=>wg,ZodDiscriminatedUnion:()=>Mq,ZodEffects:()=>Ri,ZodEnum:()=>Ag,ZodError:()=>aG,ZodFirstPartyTypeKind:()=>QI,ZodFunction:()=>jq,ZodIntersection:()=>yg,ZodIssueCode:()=>Ve,ZodLazy:()=>gg,ZodLiteral:()=>Fg,ZodMap:()=>F1,ZodNaN:()=>Q1,ZodNativeEnum:()=>Qg,ZodNever:()=>Mb,ZodNull:()=>Vg,ZodNullable:()=>hp,ZodNumber:()=>Zg,ZodObject:()=>oG,ZodOptional:()=>Yi,ZodParsedType:()=>je,ZodPipeline:()=>Ox,ZodPromise:()=>fV,ZodReadonly:()=>Eg,ZodRecord:()=>Tq,ZodSchema:()=>ht,ZodSet:()=>A1,ZodString:()=>LV,ZodSymbol:()=>y1,ZodTransformer:()=>Ri,ZodTuple:()=>mp,ZodType:()=>ht,ZodUndefined:()=>Yg,ZodUnion:()=>Rg,ZodUnknown:()=>Du,ZodVoid:()=>g1,addIssueToContext:()=>xe,any:()=>Fpe,array:()=>ys,bigint:()=>fDI,boolean:()=>bn,coerce:()=>Tx,custom:()=>$Ke,date:()=>xDI,datetimeRegex:()=>qKe,defaultErrorMap:()=>Tu,discriminatedUnion:()=>Mx,effect:()=>$DI,enum:()=>yi,function:()=>KDI,getErrorMap:()=>Y1,getParsedType:()=>bp,instanceof:()=>LDI,intersection:()=>TDI,isAborted:()=>Sq,isAsync:()=>V1,isDirty:()=>Oq,isValid:()=>JV,late:()=>JDI,lazy:()=>PDI,literal:()=>ZI,makeIssue:()=>Ux,map:()=>jDI,nan:()=>kDI,nativeEnum:()=>qDI,never:()=>SDI,null:()=>UDI,nullable:()=>IKI,number:()=>na,object:()=>Ue,objectUtil:()=>Rpe,oboolean:()=>rKI,onumber:()=>cKI,optional:()=>eKI,ostring:()=>nKI,pipeline:()=>lKI,preprocess:()=>tKI,promise:()=>_DI,quotelessJson:()=>oDI,record:()=>w1,set:()=>DDI,setErrorMap:()=>dDI,strictObject:()=>MDI,string:()=>ae,symbol:()=>BDI,transformer:()=>$DI,tuple:()=>Ape,undefined:()=>zDI,union:()=>ca,unknown:()=>pp,util:()=>zt,void:()=>ODI});o();o();o();o();o();var zt;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function I(n){throw new Error}t.assertNever=I,t.arrayToEnum=n=>{let c={};for(let r of n)c[r]=r;return c},t.getValidEnumValues=n=>{let c=t.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),r={};for(let s of c)r[s]=n[s];return t.objectValues(r)},t.objectValues=n=>t.objectKeys(n).map(function(c){return n[c]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let c=[];for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&c.push(r);return c},t.find=(n,c)=>{for(let r of n)if(c(r))return r},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function l(n,c=" | "){return n.map(r=>typeof r=="string"?`'${r}'`:r).join(c)}t.joinValues=l,t.jsonStringifyReplacer=(n,c)=>typeof c=="bigint"?c.toString():c})(zt||(zt={}));var Rpe;(function(t){t.mergeShapes=(e,I)=>({...e,...I})})(Rpe||(Rpe={}));var je=zt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),bp=t=>{switch(typeof t){case"undefined":return je.undefined;case"string":return je.string;case"number":return Number.isNaN(t)?je.nan:je.number;case"boolean":return je.boolean;case"function":return je.function;case"bigint":return je.bigint;case"symbol":return je.symbol;case"object":return Array.isArray(t)?je.array:t===null?je.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?je.promise:typeof Map<"u"&&t instanceof Map?je.map:typeof Set<"u"&&t instanceof Set?je.set:typeof Date<"u"&&t instanceof Date?je.date:je.object;default:return je.unknown}};var Ve=zt.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"]),oDI=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),aG=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=l=>{this.issues=[...this.issues,l]},this.addIssues=(l=[])=>{this.issues=[...this.issues,...l]};let I=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,I):this.__proto__=I,this.name="ZodError",this.issues=e}format(e){let I=e||function(c){return c.message},l={_errors:[]},n=c=>{for(let r of c.issues)if(r.code==="invalid_union")r.unionErrors.map(n);else if(r.code==="invalid_return_type")n(r.returnTypeError);else if(r.code==="invalid_arguments")n(r.argumentsError);else if(r.path.length===0)l._errors.push(I(r));else{let s=l,a=0;for(;a<r.path.length;){let G=r.path[a];a===r.path.length-1?(s[G]=s[G]||{_errors:[]},s[G]._errors.push(I(r))):s[G]=s[G]||{_errors:[]},s=s[G],a++}}};return n(this),l}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,zt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=I=>I.message){let I={},l=[];for(let n of this.issues)if(n.path.length>0){let c=n.path[0];I[c]=I[c]||[],I[c].push(e(n))}else l.push(e(n));return{formErrors:l,fieldErrors:I}}get formErrors(){return this.flatten()}};aG.create=t=>new aG(t);var GDI=(t,e)=>{let I;switch(t.code){case Ve.invalid_type:t.received===je.undefined?I="Required":I=`Expected ${t.expected}, received ${t.received}`;break;case Ve.invalid_literal:I=`Invalid literal value, expected ${JSON.stringify(t.expected,zt.jsonStringifyReplacer)}`;break;case Ve.unrecognized_keys:I=`Unrecognized key(s) in object: ${zt.joinValues(t.keys,", ")}`;break;case Ve.invalid_union:I="Invalid input";break;case Ve.invalid_union_discriminator:I=`Invalid discriminator value. Expected ${zt.joinValues(t.options)}`;break;case Ve.invalid_enum_value:I=`Invalid enum value. Expected ${zt.joinValues(t.options)}, received '${t.received}'`;break;case Ve.invalid_arguments:I="Invalid function arguments";break;case Ve.invalid_return_type:I="Invalid function return type";break;case Ve.invalid_date:I="Invalid date";break;case Ve.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(I=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(I=`${I} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?I=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?I=`Invalid input: must end with "${t.validation.endsWith}"`:zt.assertNever(t.validation):t.validation!=="regex"?I=`Invalid ${t.validation}`:I="Invalid";break;case Ve.too_small:t.type==="array"?I=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?I=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?I=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?I=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?I=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:I="Invalid input";break;case Ve.too_big:t.type==="array"?I=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?I=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?I=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?I=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?I=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:I="Invalid input";break;case Ve.custom:I="Invalid input";break;case Ve.invalid_intersection_types:I="Intersection results could not be merged";break;case Ve.not_multiple_of:I=`Number must be a multiple of ${t.multipleOf}`;break;case Ve.not_finite:I="Number must be finite";break;default:I=e.defaultError,zt.assertNever(t)}return{message:I}},Tu=GDI;var TKe=Tu;function dDI(t){TKe=t}function Y1(){return TKe}o();var Ux=t=>{let{data:e,path:I,errorMaps:l,issueData:n}=t,c=[...I,...n.path||[]],r={...n,path:c};if(n.message!==void 0)return{...n,path:c,message:n.message};let s="",a=l.filter(G=>!!G).slice().reverse();for(let G of a)s=G(r,{data:e,defaultError:s}).message;return{...n,path:c,message:s}},iDI=[];function xe(t,e){let I=Y1(),l=Ux({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,I,I===Tu?void 0:Tu].filter(n=>!!n)});t.common.issues.push(l)}var Rs=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,I){let l=[];for(let n of I){if(n.status==="aborted")return gI;n.status==="dirty"&&e.dirty(),l.push(n.value)}return{status:e.value,value:l}}static async mergeObjectAsync(e,I){let l=[];for(let n of I){let c=await n.key,r=await n.value;l.push({key:c,value:r})}return t.mergeObjectSync(e,l)}static mergeObjectSync(e,I){let l={};for(let n of I){let{key:c,value:r}=n;if(c.status==="aborted"||r.status==="aborted")return gI;c.status==="dirty"&&e.dirty(),r.status==="dirty"&&e.dirty(),c.value!=="__proto__"&&(typeof r.value<"u"||n.alwaysSet)&&(l[c.value]=r.value)}return{status:e.value,value:l}}},gI=Object.freeze({status:"aborted"}),pg=t=>({status:"dirty",value:t}),la=t=>({status:"valid",value:t}),Sq=t=>t.status==="aborted",Oq=t=>t.status==="dirty",JV=t=>t.status==="valid",V1=t=>typeof Promise<"u"&&t instanceof Promise;o();o();var rI;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(rI||(rI={}));var Vi=class{constructor(e,I,l,n){this._cachedPath=[],this.parent=e,this.data=I,this._path=l,this._key=n}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}},jKe=(t,e)=>{if(JV(e))return{success:!0,data:e.value};if(!t.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 aG(t.common.issues);return this._error=I,this._error}}};function rt(t){if(!t)return{};let{errorMap:e,invalid_type_error:I,required_error:l,description:n}=t;if(e&&(I||l))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(r,s)=>{let{message:a}=t;return r.code==="invalid_enum_value"?{message:a??s.defaultError}:typeof s.data>"u"?{message:a??l??s.defaultError}:r.code!=="invalid_type"?{message:s.defaultError}:{message:a??I??s.defaultError}},description:n}}var ht=class{get description(){return this._def.description}_getType(e){return bp(e.data)}_getOrReturnCtx(e,I){return I||{common:e.parent.common,data:e.data,parsedType:bp(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Rs,ctx:{common:e.parent.common,data:e.data,parsedType:bp(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let I=this._parse(e);if(V1(I))throw new Error("Synchronous parse encountered promise.");return I}_parseAsync(e){let I=this._parse(e);return Promise.resolve(I)}parse(e,I){let l=this.safeParse(e,I);if(l.success)return l.data;throw l.error}safeParse(e,I){let l={common:{issues:[],async:I?.async??!1,contextualErrorMap:I?.errorMap},path:I?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bp(e)},n=this._parseSync({data:e,path:l.path,parent:l});return jKe(l,n)}"~validate"(e){let I={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bp(e)};if(!this["~standard"].async)try{let l=this._parseSync({data:e,path:[],parent:I});return JV(l)?{value:l.value}:{issues:I.common.issues}}catch(l){l?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),I.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:I}).then(l=>JV(l)?{value:l.value}:{issues:I.common.issues})}async parseAsync(e,I){let l=await this.safeParseAsync(e,I);if(l.success)return l.data;throw l.error}async safeParseAsync(e,I){let l={common:{issues:[],contextualErrorMap:I?.errorMap,async:!0},path:I?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bp(e)},n=this._parse({data:e,path:l.path,parent:l}),c=await(V1(n)?n:Promise.resolve(n));return jKe(l,c)}refine(e,I){let l=n=>typeof I=="string"||typeof I>"u"?{message:I}:typeof I=="function"?I(n):I;return this._refinement((n,c)=>{let r=e(n),s=()=>c.addIssue({code:Ve.custom,...l(n)});return typeof Promise<"u"&&r instanceof Promise?r.then(a=>a?!0:(s(),!1)):r?!0:(s(),!1)})}refinement(e,I){return this._refinement((l,n)=>e(l)?!0:(n.addIssue(typeof I=="function"?I(l,n):I),!1))}_refinement(e){return new Ri({schema:this,typeName:QI.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:I=>this["~validate"](I)}}optional(){return Yi.create(this,this._def)}nullable(){return hp.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ku.create(this)}promise(){return fV.create(this,this._def)}or(e){return Rg.create([this,e],this._def)}and(e){return yg.create(this,e,this._def)}transform(e){return new Ri({...rt(this._def),schema:this,typeName:QI.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let I=typeof e=="function"?e:()=>e;return new wg({...rt(this._def),innerType:this,defaultValue:I,typeName:QI.ZodDefault})}brand(){return new Sx({typeName:QI.ZodBranded,type:this,...rt(this._def)})}catch(e){let I=typeof e=="function"?e:()=>e;return new Xg({...rt(this._def),innerType:this,catchValue:I,typeName:QI.ZodCatch})}describe(e){let I=this.constructor;return new I({...this._def,description:e})}pipe(e){return Ox.create(this,e)}readonly(){return Eg.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},bDI=/^c[^\s-]{8,}$/i,mDI=/^[0-9a-z]+$/,hDI=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pDI=/^[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,ZDI=/^[a-z0-9_-]{21}$/i,uDI=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,WDI=/^[-+]?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)?)??$/,NDI=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,YDI="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ype,VDI=/^(?:(?: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])$/,RDI=/^(?:(?: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])$/,yDI=/^(([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]))$/,gDI=/^(([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])$/,FDI=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ADI=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,KKe="((\\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])))",QDI=new RegExp(`^${KKe}$`);function PKe(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let I=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${I}`}function wDI(t){return new RegExp(`^${PKe(t)}$`)}function qKe(t){let e=`${KKe}T${PKe(t)}`,I=[];return I.push(t.local?"Z?":"Z"),t.offset&&I.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${I.join("|")})`,new RegExp(`^${e}$`)}function XDI(t,e){return!!((e==="v4"||!e)&&VDI.test(t)||(e==="v6"||!e)&&yDI.test(t))}function EDI(t,e){if(!uDI.test(t))return!1;try{let[I]=t.split(".");if(!I)return!1;let l=I.replace(/-/g,"+").replace(/_/g,"/").padEnd(I.length+(4-I.length%4)%4,"="),n=JSON.parse(atob(l));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function HDI(t,e){return!!((e==="v4"||!e)&&RDI.test(t)||(e==="v6"||!e)&&gDI.test(t))}var LV=class t extends ht{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==je.string){let c=this._getOrReturnCtx(e);return xe(c,{code:Ve.invalid_type,expected:je.string,received:c.parsedType}),gI}let l=new Rs,n;for(let c of this._def.checks)if(c.kind==="min")e.data.length<c.value&&(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.too_small,minimum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),l.dirty());else if(c.kind==="max")e.data.length>c.value&&(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),l.dirty());else if(c.kind==="length"){let r=e.data.length>c.value,s=e.data.length<c.value;(r||s)&&(n=this._getOrReturnCtx(e,n),r?xe(n,{code:Ve.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!0,message:c.message}):s&&xe(n,{code:Ve.too_small,minimum:c.value,type:"string",inclusive:!0,exact:!0,message:c.message}),l.dirty())}else if(c.kind==="email")NDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"email",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="emoji")ype||(ype=new RegExp(YDI,"u")),ype.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"emoji",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="uuid")pDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"uuid",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="nanoid")ZDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"nanoid",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="cuid")bDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"cuid",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="cuid2")mDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"cuid2",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="ulid")hDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"ulid",code:Ve.invalid_string,message:c.message}),l.dirty());else if(c.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),xe(n,{validation:"url",code:Ve.invalid_string,message:c.message}),l.dirty()}else c.kind==="regex"?(c.regex.lastIndex=0,c.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"regex",code:Ve.invalid_string,message:c.message}),l.dirty())):c.kind==="trim"?e.data=e.data.trim():c.kind==="includes"?e.data.includes(c.value,c.position)||(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.invalid_string,validation:{includes:c.value,position:c.position},message:c.message}),l.dirty()):c.kind==="toLowerCase"?e.data=e.data.toLowerCase():c.kind==="toUpperCase"?e.data=e.data.toUpperCase():c.kind==="startsWith"?e.data.startsWith(c.value)||(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.invalid_string,validation:{startsWith:c.value},message:c.message}),l.dirty()):c.kind==="endsWith"?e.data.endsWith(c.value)||(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.invalid_string,validation:{endsWith:c.value},message:c.message}),l.dirty()):c.kind==="datetime"?qKe(c).test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.invalid_string,validation:"datetime",message:c.message}),l.dirty()):c.kind==="date"?QDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.invalid_string,validation:"date",message:c.message}),l.dirty()):c.kind==="time"?wDI(c).test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.invalid_string,validation:"time",message:c.message}),l.dirty()):c.kind==="duration"?WDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"duration",code:Ve.invalid_string,message:c.message}),l.dirty()):c.kind==="ip"?XDI(e.data,c.version)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"ip",code:Ve.invalid_string,message:c.message}),l.dirty()):c.kind==="jwt"?EDI(e.data,c.alg)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"jwt",code:Ve.invalid_string,message:c.message}),l.dirty()):c.kind==="cidr"?HDI(e.data,c.version)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"cidr",code:Ve.invalid_string,message:c.message}),l.dirty()):c.kind==="base64"?FDI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"base64",code:Ve.invalid_string,message:c.message}),l.dirty()):c.kind==="base64url"?ADI.test(e.data)||(n=this._getOrReturnCtx(e,n),xe(n,{validation:"base64url",code:Ve.invalid_string,message:c.message}),l.dirty()):zt.assertNever(c);return{status:l.value,value:e.data}}_regex(e,I,l){return this.refinement(n=>e.test(n),{validation:I,code:Ve.invalid_string,...rI.errToObj(l)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...rI.errToObj(e)})}url(e){return this._addCheck({kind:"url",...rI.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...rI.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...rI.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...rI.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...rI.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...rI.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...rI.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...rI.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...rI.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...rI.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...rI.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...rI.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...rI.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...rI.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...rI.errToObj(e)})}regex(e,I){return this._addCheck({kind:"regex",regex:e,...rI.errToObj(I)})}includes(e,I){return this._addCheck({kind:"includes",value:e,position:I?.position,...rI.errToObj(I?.message)})}startsWith(e,I){return this._addCheck({kind:"startsWith",value:e,...rI.errToObj(I)})}endsWith(e,I){return this._addCheck({kind:"endsWith",value:e,...rI.errToObj(I)})}min(e,I){return this._addCheck({kind:"min",value:e,...rI.errToObj(I)})}max(e,I){return this._addCheck({kind:"max",value:e,...rI.errToObj(I)})}length(e,I){return this._addCheck({kind:"length",value:e,...rI.errToObj(I)})}nonempty(e){return this.min(1,rI.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let I of this._def.checks)I.kind==="min"&&(e===null||I.value>e)&&(e=I.value);return e}get maxLength(){let e=null;for(let I of this._def.checks)I.kind==="max"&&(e===null||I.value<e)&&(e=I.value);return e}};LV.create=t=>new LV({checks:[],typeName:QI.ZodString,coerce:t?.coerce??!1,...rt(t)});function vDI(t,e){let I=(t.toString().split(".")[1]||"").length,l=(e.toString().split(".")[1]||"").length,n=I>l?I:l,c=Number.parseInt(t.toFixed(n).replace(".","")),r=Number.parseInt(e.toFixed(n).replace(".",""));return c%r/10**n}var Zg=class t extends ht{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==je.number){let c=this._getOrReturnCtx(e);return xe(c,{code:Ve.invalid_type,expected:je.number,received:c.parsedType}),gI}let l,n=new Rs;for(let c of this._def.checks)c.kind==="int"?zt.isInteger(e.data)||(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.invalid_type,expected:"integer",received:"float",message:c.message}),n.dirty()):c.kind==="min"?(c.inclusive?e.data<c.value:e.data<=c.value)&&(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.too_small,minimum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),n.dirty()):c.kind==="max"?(c.inclusive?e.data>c.value:e.data>=c.value)&&(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.too_big,maximum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),n.dirty()):c.kind==="multipleOf"?vDI(e.data,c.value)!==0&&(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.not_multiple_of,multipleOf:c.value,message:c.message}),n.dirty()):c.kind==="finite"?Number.isFinite(e.data)||(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.not_finite,message:c.message}),n.dirty()):zt.assertNever(c);return{status:n.value,value:e.data}}gte(e,I){return this.setLimit("min",e,!0,rI.toString(I))}gt(e,I){return this.setLimit("min",e,!1,rI.toString(I))}lte(e,I){return this.setLimit("max",e,!0,rI.toString(I))}lt(e,I){return this.setLimit("max",e,!1,rI.toString(I))}setLimit(e,I,l,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:I,inclusive:l,message:rI.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:rI.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:rI.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:rI.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:rI.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:rI.toString(e)})}multipleOf(e,I){return this._addCheck({kind:"multipleOf",value:e,message:rI.toString(I)})}finite(e){return this._addCheck({kind:"finite",message:rI.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:rI.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:rI.toString(e)})}get minValue(){let e=null;for(let I of this._def.checks)I.kind==="min"&&(e===null||I.value>e)&&(e=I.value);return e}get maxValue(){let e=null;for(let I of this._def.checks)I.kind==="max"&&(e===null||I.value<e)&&(e=I.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&zt.isInteger(e.value))}get isFinite(){let e=null,I=null;for(let l of this._def.checks){if(l.kind==="finite"||l.kind==="int"||l.kind==="multipleOf")return!0;l.kind==="min"?(I===null||l.value>I)&&(I=l.value):l.kind==="max"&&(e===null||l.value<e)&&(e=l.value)}return Number.isFinite(I)&&Number.isFinite(e)}};Zg.create=t=>new Zg({checks:[],typeName:QI.ZodNumber,coerce:t?.coerce||!1,...rt(t)});var ug=class t extends ht{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==je.bigint)return this._getInvalidInput(e);let l,n=new Rs;for(let c of this._def.checks)c.kind==="min"?(c.inclusive?e.data<c.value:e.data<=c.value)&&(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.too_small,type:"bigint",minimum:c.value,inclusive:c.inclusive,message:c.message}),n.dirty()):c.kind==="max"?(c.inclusive?e.data>c.value:e.data>=c.value)&&(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.too_big,type:"bigint",maximum:c.value,inclusive:c.inclusive,message:c.message}),n.dirty()):c.kind==="multipleOf"?e.data%c.value!==BigInt(0)&&(l=this._getOrReturnCtx(e,l),xe(l,{code:Ve.not_multiple_of,multipleOf:c.value,message:c.message}),n.dirty()):zt.assertNever(c);return{status:n.value,value:e.data}}_getInvalidInput(e){let I=this._getOrReturnCtx(e);return xe(I,{code:Ve.invalid_type,expected:je.bigint,received:I.parsedType}),gI}gte(e,I){return this.setLimit("min",e,!0,rI.toString(I))}gt(e,I){return this.setLimit("min",e,!1,rI.toString(I))}lte(e,I){return this.setLimit("max",e,!0,rI.toString(I))}lt(e,I){return this.setLimit("max",e,!1,rI.toString(I))}setLimit(e,I,l,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:I,inclusive:l,message:rI.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:rI.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:rI.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:rI.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:rI.toString(e)})}multipleOf(e,I){return this._addCheck({kind:"multipleOf",value:e,message:rI.toString(I)})}get minValue(){let e=null;for(let I of this._def.checks)I.kind==="min"&&(e===null||I.value>e)&&(e=I.value);return e}get maxValue(){let e=null;for(let I of this._def.checks)I.kind==="max"&&(e===null||I.value<e)&&(e=I.value);return e}};ug.create=t=>new ug({checks:[],typeName:QI.ZodBigInt,coerce:t?.coerce??!1,...rt(t)});var Wg=class extends ht{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==je.boolean){let l=this._getOrReturnCtx(e);return xe(l,{code:Ve.invalid_type,expected:je.boolean,received:l.parsedType}),gI}return la(e.data)}};Wg.create=t=>new Wg({typeName:QI.ZodBoolean,coerce:t?.coerce||!1,...rt(t)});var Ng=class t extends ht{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==je.date){let c=this._getOrReturnCtx(e);return xe(c,{code:Ve.invalid_type,expected:je.date,received:c.parsedType}),gI}if(Number.isNaN(e.data.getTime())){let c=this._getOrReturnCtx(e);return xe(c,{code:Ve.invalid_date}),gI}let l=new Rs,n;for(let c of this._def.checks)c.kind==="min"?e.data.getTime()<c.value&&(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.too_small,message:c.message,inclusive:!0,exact:!1,minimum:c.value,type:"date"}),l.dirty()):c.kind==="max"?e.data.getTime()>c.value&&(n=this._getOrReturnCtx(e,n),xe(n,{code:Ve.too_big,message:c.message,inclusive:!0,exact:!1,maximum:c.value,type:"date"}),l.dirty()):zt.assertNever(c);return{status:l.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,I){return this._addCheck({kind:"min",value:e.getTime(),message:rI.toString(I)})}max(e,I){return this._addCheck({kind:"max",value:e.getTime(),message:rI.toString(I)})}get minDate(){let e=null;for(let I of this._def.checks)I.kind==="min"&&(e===null||I.value>e)&&(e=I.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let I of this._def.checks)I.kind==="max"&&(e===null||I.value<e)&&(e=I.value);return e!=null?new Date(e):null}};Ng.create=t=>new Ng({checks:[],coerce:t?.coerce||!1,typeName:QI.ZodDate,...rt(t)});var y1=class extends ht{_parse(e){if(this._getType(e)!==je.symbol){let l=this._getOrReturnCtx(e);return xe(l,{code:Ve.invalid_type,expected:je.symbol,received:l.parsedType}),gI}return la(e.data)}};y1.create=t=>new y1({typeName:QI.ZodSymbol,...rt(t)});var Yg=class extends ht{_parse(e){if(this._getType(e)!==je.undefined){let l=this._getOrReturnCtx(e);return xe(l,{code:Ve.invalid_type,expected:je.undefined,received:l.parsedType}),gI}return la(e.data)}};Yg.create=t=>new Yg({typeName:QI.ZodUndefined,...rt(t)});var Vg=class extends ht{_parse(e){if(this._getType(e)!==je.null){let l=this._getOrReturnCtx(e);return xe(l,{code:Ve.invalid_type,expected:je.null,received:l.parsedType}),gI}return la(e.data)}};Vg.create=t=>new Vg({typeName:QI.ZodNull,...rt(t)});var kV=class extends ht{constructor(){super(...arguments),this._any=!0}_parse(e){return la(e.data)}};kV.create=t=>new kV({typeName:QI.ZodAny,...rt(t)});var Du=class extends ht{constructor(){super(...arguments),this._unknown=!0}_parse(e){return la(e.data)}};Du.create=t=>new Du({typeName:QI.ZodUnknown,...rt(t)});var Mb=class extends ht{_parse(e){let I=this._getOrReturnCtx(e);return xe(I,{code:Ve.invalid_type,expected:je.never,received:I.parsedType}),gI}};Mb.create=t=>new Mb({typeName:QI.ZodNever,...rt(t)});var g1=class extends ht{_parse(e){if(this._getType(e)!==je.undefined){let l=this._getOrReturnCtx(e);return xe(l,{code:Ve.invalid_type,expected:je.void,received:l.parsedType}),gI}return la(e.data)}};g1.create=t=>new g1({typeName:QI.ZodVoid,...rt(t)});var Ku=class t extends ht{_parse(e){let{ctx:I,status:l}=this._processInputParams(e),n=this._def;if(I.parsedType!==je.array)return xe(I,{code:Ve.invalid_type,expected:je.array,received:I.parsedType}),gI;if(n.exactLength!==null){let r=I.data.length>n.exactLength.value,s=I.data.length<n.exactLength.value;(r||s)&&(xe(I,{code:r?Ve.too_big:Ve.too_small,minimum:s?n.exactLength.value:void 0,maximum:r?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),l.dirty())}if(n.minLength!==null&&I.data.length<n.minLength.value&&(xe(I,{code:Ve.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),l.dirty()),n.maxLength!==null&&I.data.length>n.maxLength.value&&(xe(I,{code:Ve.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),l.dirty()),I.common.async)return Promise.all([...I.data].map((r,s)=>n.type._parseAsync(new Vi(I,r,I.path,s)))).then(r=>Rs.mergeArray(l,r));let c=[...I.data].map((r,s)=>n.type._parseSync(new Vi(I,r,I.path,s)));return Rs.mergeArray(l,c)}get element(){return this._def.type}min(e,I){return new t({...this._def,minLength:{value:e,message:rI.toString(I)}})}max(e,I){return new t({...this._def,maxLength:{value:e,message:rI.toString(I)}})}length(e,I){return new t({...this._def,exactLength:{value:e,message:rI.toString(I)}})}nonempty(e){return this.min(1,e)}};Ku.create=(t,e)=>new Ku({type:t,minLength:null,maxLength:null,exactLength:null,typeName:QI.ZodArray,...rt(e)});function R1(t){if(t instanceof oG){let e={};for(let I in t.shape){let l=t.shape[I];e[I]=Yi.create(R1(l))}return new oG({...t._def,shape:()=>e})}else return t instanceof Ku?new Ku({...t._def,type:R1(t.element)}):t instanceof Yi?Yi.create(R1(t.unwrap())):t instanceof hp?hp.create(R1(t.unwrap())):t instanceof mp?mp.create(t.items.map(e=>R1(e))):t}var oG=class t extends ht{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),I=zt.objectKeys(e);return this._cached={shape:e,keys:I},this._cached}_parse(e){if(this._getType(e)!==je.object){let G=this._getOrReturnCtx(e);return xe(G,{code:Ve.invalid_type,expected:je.object,received:G.parsedType}),gI}let{status:l,ctx:n}=this._processInputParams(e),{shape:c,keys:r}=this._getCached(),s=[];if(!(this._def.catchall instanceof Mb&&this._def.unknownKeys==="strip"))for(let G in n.data)r.includes(G)||s.push(G);let a=[];for(let G of r){let d=c[G],i=n.data[G];a.push({key:{status:"valid",value:G},value:d._parse(new Vi(n,i,n.path,G)),alwaysSet:G in n.data})}if(this._def.catchall instanceof Mb){let G=this._def.unknownKeys;if(G==="passthrough")for(let d of s)a.push({key:{status:"valid",value:d},value:{status:"valid",value:n.data[d]}});else if(G==="strict")s.length>0&&(xe(n,{code:Ve.unrecognized_keys,keys:s}),l.dirty());else if(G!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let G=this._def.catchall;for(let d of s){let i=n.data[d];a.push({key:{status:"valid",value:d},value:G._parse(new Vi(n,i,n.path,d)),alwaysSet:d in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let G=[];for(let d of a){let i=await d.key,b=await d.value;G.push({key:i,value:b,alwaysSet:d.alwaysSet})}return G}).then(G=>Rs.mergeObjectSync(l,G)):Rs.mergeObjectSync(l,a)}get shape(){return this._def.shape()}strict(e){return rI.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(I,l)=>{let n=this._def.errorMap?.(I,l).message??l.defaultError;return I.code==="unrecognized_keys"?{message:rI.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:QI.ZodObject})}setKey(e,I){return this.augment({[e]:I})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let I={};for(let l of zt.objectKeys(e))e[l]&&this.shape[l]&&(I[l]=this.shape[l]);return new t({...this._def,shape:()=>I})}omit(e){let I={};for(let l of zt.objectKeys(this.shape))e[l]||(I[l]=this.shape[l]);return new t({...this._def,shape:()=>I})}deepPartial(){return R1(this)}partial(e){let I={};for(let l of zt.objectKeys(this.shape)){let n=this.shape[l];e&&!e[l]?I[l]=n:I[l]=n.optional()}return new t({...this._def,shape:()=>I})}required(e){let I={};for(let l of zt.objectKeys(this.shape))if(e&&!e[l])I[l]=this.shape[l];else{let c=this.shape[l];for(;c instanceof Yi;)c=c._def.innerType;I[l]=c}return new t({...this._def,shape:()=>I})}keyof(){return _Ke(zt.objectKeys(this.shape))}};oG.create=(t,e)=>new oG({shape:()=>t,unknownKeys:"strip",catchall:Mb.create(),typeName:QI.ZodObject,...rt(e)});oG.strictCreate=(t,e)=>new oG({shape:()=>t,unknownKeys:"strict",catchall:Mb.create(),typeName:QI.ZodObject,...rt(e)});oG.lazycreate=(t,e)=>new oG({shape:t,unknownKeys:"strip",catchall:Mb.create(),typeName:QI.ZodObject,...rt(e)});var Rg=class extends ht{_parse(e){let{ctx:I}=this._processInputParams(e),l=this._def.options;function n(c){for(let s of c)if(s.result.status==="valid")return s.result;for(let s of c)if(s.result.status==="dirty")return I.common.issues.push(...s.ctx.common.issues),s.result;let r=c.map(s=>new aG(s.ctx.common.issues));return xe(I,{code:Ve.invalid_union,unionErrors:r}),gI}if(I.common.async)return Promise.all(l.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(n);{let c,r=[];for(let a of l){let G={...I,common:{...I.common,issues:[]},parent:null},d=a._parseSync({data:I.data,path:I.path,parent:G});if(d.status==="valid")return d;d.status==="dirty"&&!c&&(c={result:d,ctx:G}),G.common.issues.length&&r.push(G.common.issues)}if(c)return I.common.issues.push(...c.ctx.common.issues),c.result;let s=r.map(a=>new aG(a));return xe(I,{code:Ve.invalid_union,unionErrors:s}),gI}}get options(){return this._def.options}};Rg.create=(t,e)=>new Rg({options:t,typeName:QI.ZodUnion,...rt(e)});var ju=t=>t instanceof gg?ju(t.schema):t instanceof Ri?ju(t.innerType()):t instanceof Fg?[t.value]:t instanceof Ag?t.options:t instanceof Qg?zt.objectValues(t.enum):t instanceof wg?ju(t._def.innerType):t instanceof Yg?[void 0]:t instanceof Vg?[null]:t instanceof Yi?[void 0,...ju(t.unwrap())]:t instanceof hp?[null,...ju(t.unwrap())]:t instanceof Sx||t instanceof Eg?ju(t.unwrap()):t instanceof Xg?ju(t._def.innerType):[],Mq=class t extends ht{_parse(e){let{ctx:I}=this._processInputParams(e);if(I.parsedType!==je.object)return xe(I,{code:Ve.invalid_type,expected:je.object,received:I.parsedType}),gI;let l=this.discriminator,n=I.data[l],c=this.optionsMap.get(n);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}):(xe(I,{code:Ve.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[l]}),gI)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,I,l){let n=new Map;for(let c of I){let r=ju(c.shape[e]);if(!r.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of r){if(n.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);n.set(s,c)}}return new t({typeName:QI.ZodDiscriminatedUnion,discriminator:e,options:I,optionsMap:n,...rt(l)})}};function gpe(t,e){let I=bp(t),l=bp(e);if(t===e)return{valid:!0,data:t};if(I===je.object&&l===je.object){let n=zt.objectKeys(e),c=zt.objectKeys(t).filter(s=>n.indexOf(s)!==-1),r={...t,...e};for(let s of c){let a=gpe(t[s],e[s]);if(!a.valid)return{valid:!1};r[s]=a.data}return{valid:!0,data:r}}else if(I===je.array&&l===je.array){if(t.length!==e.length)return{valid:!1};let n=[];for(let c=0;c<t.length;c++){let r=t[c],s=e[c],a=gpe(r,s);if(!a.valid)return{valid:!1};n.push(a.data)}return{valid:!0,data:n}}else return I===je.date&&l===je.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var yg=class extends ht{_parse(e){let{status:I,ctx:l}=this._processInputParams(e),n=(c,r)=>{if(Sq(c)||Sq(r))return gI;let s=gpe(c.value,r.value);return s.valid?((Oq(c)||Oq(r))&&I.dirty(),{status:I.value,value:s.data}):(xe(l,{code:Ve.invalid_intersection_types}),gI)};return l.common.async?Promise.all([this._def.left._parseAsync({data:l.data,path:l.path,parent:l}),this._def.right._parseAsync({data:l.data,path:l.path,parent:l})]).then(([c,r])=>n(c,r)):n(this._def.left._parseSync({data:l.data,path:l.path,parent:l}),this._def.right._parseSync({data:l.data,path:l.path,parent:l}))}};yg.create=(t,e,I)=>new yg({left:t,right:e,typeName:QI.ZodIntersection,...rt(I)});var mp=class t extends ht{_parse(e){let{status:I,ctx:l}=this._processInputParams(e);if(l.parsedType!==je.array)return xe(l,{code:Ve.invalid_type,expected:je.array,received:l.parsedType}),gI;if(l.data.length<this._def.items.length)return xe(l,{code:Ve.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),gI;!this._def.rest&&l.data.length>this._def.items.length&&(xe(l,{code:Ve.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),I.dirty());let c=[...l.data].map((r,s)=>{let a=this._def.items[s]||this._def.rest;return a?a._parse(new Vi(l,r,l.path,s)):null}).filter(r=>!!r);return l.common.async?Promise.all(c).then(r=>Rs.mergeArray(I,r)):Rs.mergeArray(I,c)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};mp.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new mp({items:t,typeName:QI.ZodTuple,rest:null,...rt(e)})};var Tq=class t extends ht{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:I,ctx:l}=this._processInputParams(e);if(l.parsedType!==je.object)return xe(l,{code:Ve.invalid_type,expected:je.object,received:l.parsedType}),gI;let n=[],c=this._def.keyType,r=this._def.valueType;for(let s in l.data)n.push({key:c._parse(new Vi(l,s,l.path,s)),value:r._parse(new Vi(l,l.data[s],l.path,s)),alwaysSet:s in l.data});return l.common.async?Rs.mergeObjectAsync(I,n):Rs.mergeObjectSync(I,n)}get element(){return this._def.valueType}static create(e,I,l){return I instanceof ht?new t({keyType:e,valueType:I,typeName:QI.ZodRecord,...rt(l)}):new t({keyType:LV.create(),valueType:e,typeName:QI.ZodRecord,...rt(I)})}},F1=class extends ht{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:I,ctx:l}=this._processInputParams(e);if(l.parsedType!==je.map)return xe(l,{code:Ve.invalid_type,expected:je.map,received:l.parsedType}),gI;let n=this._def.keyType,c=this._def.valueType,r=[...l.data.entries()].map(([s,a],G)=>({key:n._parse(new Vi(l,s,l.path,[G,"key"])),value:c._parse(new Vi(l,a,l.path,[G,"value"]))}));if(l.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let a of r){let G=await a.key,d=await a.value;if(G.status==="aborted"||d.status==="aborted")return gI;(G.status==="dirty"||d.status==="dirty")&&I.dirty(),s.set(G.value,d.value)}return{status:I.value,value:s}})}else{let s=new Map;for(let a of r){let G=a.key,d=a.value;if(G.status==="aborted"||d.status==="aborted")return gI;(G.status==="dirty"||d.status==="dirty")&&I.dirty(),s.set(G.value,d.value)}return{status:I.value,value:s}}}};F1.create=(t,e,I)=>new F1({valueType:e,keyType:t,typeName:QI.ZodMap,...rt(I)});var A1=class t extends ht{_parse(e){let{status:I,ctx:l}=this._processInputParams(e);if(l.parsedType!==je.set)return xe(l,{code:Ve.invalid_type,expected:je.set,received:l.parsedType}),gI;let n=this._def;n.minSize!==null&&l.data.size<n.minSize.value&&(xe(l,{code:Ve.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),I.dirty()),n.maxSize!==null&&l.data.size>n.maxSize.value&&(xe(l,{code:Ve.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),I.dirty());let c=this._def.valueType;function r(a){let G=new Set;for(let d of a){if(d.status==="aborted")return gI;d.status==="dirty"&&I.dirty(),G.add(d.value)}return{status:I.value,value:G}}let s=[...l.data.values()].map((a,G)=>c._parse(new Vi(l,a,l.path,G)));return l.common.async?Promise.all(s).then(a=>r(a)):r(s)}min(e,I){return new t({...this._def,minSize:{value:e,message:rI.toString(I)}})}max(e,I){return new t({...this._def,maxSize:{value:e,message:rI.toString(I)}})}size(e,I){return this.min(e,I).max(e,I)}nonempty(e){return this.min(1,e)}};A1.create=(t,e)=>new A1({valueType:t,minSize:null,maxSize:null,typeName:QI.ZodSet,...rt(e)});var jq=class t extends ht{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:I}=this._processInputParams(e);if(I.parsedType!==je.function)return xe(I,{code:Ve.invalid_type,expected:je.function,received:I.parsedType}),gI;function l(s,a){return Ux({data:s,path:I.path,errorMaps:[I.common.contextualErrorMap,I.schemaErrorMap,Y1(),Tu].filter(G=>!!G),issueData:{code:Ve.invalid_arguments,argumentsError:a}})}function n(s,a){return Ux({data:s,path:I.path,errorMaps:[I.common.contextualErrorMap,I.schemaErrorMap,Y1(),Tu].filter(G=>!!G),issueData:{code:Ve.invalid_return_type,returnTypeError:a}})}let c={errorMap:I.common.contextualErrorMap},r=I.data;if(this._def.returns instanceof fV){let s=this;return la(async function(...a){let G=new aG([]),d=await s._def.args.parseAsync(a,c).catch(m=>{throw G.addIssue(l(a,m)),G}),i=await Reflect.apply(r,this,d);return await s._def.returns._def.type.parseAsync(i,c).catch(m=>{throw G.addIssue(n(i,m)),G})})}else{let s=this;return la(function(...a){let G=s._def.args.safeParse(a,c);if(!G.success)throw new aG([l(a,G.error)]);let d=Reflect.apply(r,this,G.data),i=s._def.returns.safeParse(d,c);if(!i.success)throw new aG([n(d,i.error)]);return i.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:mp.create(e).rest(Du.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,I,l){return new t({args:e||mp.create([]).rest(Du.create()),returns:I||Du.create(),typeName:QI.ZodFunction,...rt(l)})}},gg=class extends ht{get schema(){return this._def.getter()}_parse(e){let{ctx:I}=this._processInputParams(e);return this._def.getter()._parse({data:I.data,path:I.path,parent:I})}};gg.create=(t,e)=>new gg({getter:t,typeName:QI.ZodLazy,...rt(e)});var Fg=class extends ht{_parse(e){if(e.data!==this._def.value){let I=this._getOrReturnCtx(e);return xe(I,{received:I.data,code:Ve.invalid_literal,expected:this._def.value}),gI}return{status:"valid",value:e.data}}get value(){return this._def.value}};Fg.create=(t,e)=>new Fg({value:t,typeName:QI.ZodLiteral,...rt(e)});function _Ke(t,e){return new Ag({values:t,typeName:QI.ZodEnum,...rt(e)})}var Ag=class t extends ht{_parse(e){if(typeof e.data!="string"){let I=this._getOrReturnCtx(e),l=this._def.values;return xe(I,{expected:zt.joinValues(l),received:I.parsedType,code:Ve.invalid_type}),gI}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let I=this._getOrReturnCtx(e),l=this._def.values;return xe(I,{received:I.data,code:Ve.invalid_enum_value,options:l}),gI}return la(e.data)}get options(){return this._def.values}get enum(){let e={};for(let I of this._def.values)e[I]=I;return e}get Values(){let e={};for(let I of this._def.values)e[I]=I;return e}get Enum(){let e={};for(let I of this._def.values)e[I]=I;return e}extract(e,I=this._def){return t.create(e,{...this._def,...I})}exclude(e,I=this._def){return t.create(this.options.filter(l=>!e.includes(l)),{...this._def,...I})}};Ag.create=_Ke;var Qg=class extends ht{_parse(e){let I=zt.getValidEnumValues(this._def.values),l=this._getOrReturnCtx(e);if(l.parsedType!==je.string&&l.parsedType!==je.number){let n=zt.objectValues(I);return xe(l,{expected:zt.joinValues(n),received:l.parsedType,code:Ve.invalid_type}),gI}if(this._cache||(this._cache=new Set(zt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=zt.objectValues(I);return xe(l,{received:l.data,code:Ve.invalid_enum_value,options:n}),gI}return la(e.data)}get enum(){return this._def.values}};Qg.create=(t,e)=>new Qg({values:t,typeName:QI.ZodNativeEnum,...rt(e)});var fV=class extends ht{unwrap(){return this._def.type}_parse(e){let{ctx:I}=this._processInputParams(e);if(I.parsedType!==je.promise&&I.common.async===!1)return xe(I,{code:Ve.invalid_type,expected:je.promise,received:I.parsedType}),gI;let l=I.parsedType===je.promise?I.data:Promise.resolve(I.data);return la(l.then(n=>this._def.type.parseAsync(n,{path:I.path,errorMap:I.common.contextualErrorMap})))}};fV.create=(t,e)=>new fV({type:t,typeName:QI.ZodPromise,...rt(e)});var Ri=class extends ht{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===QI.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:I,ctx:l}=this._processInputParams(e),n=this._def.effect||null,c={addIssue:r=>{xe(l,r),r.fatal?I.abort():I.dirty()},get path(){return l.path}};if(c.addIssue=c.addIssue.bind(c),n.type==="preprocess"){let r=n.transform(l.data,c);if(l.common.async)return Promise.resolve(r).then(async s=>{if(I.value==="aborted")return gI;let a=await this._def.schema._parseAsync({data:s,path:l.path,parent:l});return a.status==="aborted"?gI:a.status==="dirty"?pg(a.value):I.value==="dirty"?pg(a.value):a});{if(I.value==="aborted")return gI;let s=this._def.schema._parseSync({data:r,path:l.path,parent:l});return s.status==="aborted"?gI:s.status==="dirty"?pg(s.value):I.value==="dirty"?pg(s.value):s}}if(n.type==="refinement"){let r=s=>{let a=n.refinement(s,c);if(l.common.async)return Promise.resolve(a);if(a instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(l.common.async===!1){let s=this._def.schema._parseSync({data:l.data,path:l.path,parent:l});return s.status==="aborted"?gI:(s.status==="dirty"&&I.dirty(),r(s.value),{status:I.value,value:s.value})}else return this._def.schema._parseAsync({data:l.data,path:l.path,parent:l}).then(s=>s.status==="aborted"?gI:(s.status==="dirty"&&I.dirty(),r(s.value).then(()=>({status:I.value,value:s.value}))))}if(n.type==="transform")if(l.common.async===!1){let r=this._def.schema._parseSync({data:l.data,path:l.path,parent:l});if(!JV(r))return gI;let s=n.transform(r.value,c);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:I.value,value:s}}else return this._def.schema._parseAsync({data:l.data,path:l.path,parent:l}).then(r=>JV(r)?Promise.resolve(n.transform(r.value,c)).then(s=>({status:I.value,value:s})):gI);zt.assertNever(n)}};Ri.create=(t,e,I)=>new Ri({schema:t,typeName:QI.ZodEffects,effect:e,...rt(I)});Ri.createWithPreprocess=(t,e,I)=>new Ri({schema:e,effect:{type:"preprocess",transform:t},typeName:QI.ZodEffects,...rt(I)});var Yi=class extends ht{_parse(e){return this._getType(e)===je.undefined?la(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Yi.create=(t,e)=>new Yi({innerType:t,typeName:QI.ZodOptional,...rt(e)});var hp=class extends ht{_parse(e){return this._getType(e)===je.null?la(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};hp.create=(t,e)=>new hp({innerType:t,typeName:QI.ZodNullable,...rt(e)});var wg=class extends ht{_parse(e){let{ctx:I}=this._processInputParams(e),l=I.data;return I.parsedType===je.undefined&&(l=this._def.defaultValue()),this._def.innerType._parse({data:l,path:I.path,parent:I})}removeDefault(){return this._def.innerType}};wg.create=(t,e)=>new wg({innerType:t,typeName:QI.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...rt(e)});var Xg=class extends ht{_parse(e){let{ctx:I}=this._processInputParams(e),l={...I,common:{...I.common,issues:[]}},n=this._def.innerType._parse({data:l.data,path:l.path,parent:{...l}});return V1(n)?n.then(c=>({status:"valid",value:c.status==="valid"?c.value:this._def.catchValue({get error(){return new aG(l.common.issues)},input:l.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new aG(l.common.issues)},input:l.data})}}removeCatch(){return this._def.innerType}};Xg.create=(t,e)=>new Xg({innerType:t,typeName:QI.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...rt(e)});var Q1=class extends ht{_parse(e){if(this._getType(e)!==je.nan){let l=this._getOrReturnCtx(e);return xe(l,{code:Ve.invalid_type,expected:je.nan,received:l.parsedType}),gI}return{status:"valid",value:e.data}}};Q1.create=t=>new Q1({typeName:QI.ZodNaN,...rt(t)});var CDI=Symbol("zod_brand"),Sx=class extends ht{_parse(e){let{ctx:I}=this._processInputParams(e),l=I.data;return this._def.type._parse({data:l,path:I.path,parent:I})}unwrap(){return this._def.type}},Ox=class t extends ht{_parse(e){let{status:I,ctx:l}=this._processInputParams(e);if(l.common.async)return(async()=>{let c=await this._def.in._parseAsync({data:l.data,path:l.path,parent:l});return c.status==="aborted"?gI:c.status==="dirty"?(I.dirty(),pg(c.value)):this._def.out._parseAsync({data:c.value,path:l.path,parent:l})})();{let n=this._def.in._parseSync({data:l.data,path:l.path,parent:l});return n.status==="aborted"?gI:n.status==="dirty"?(I.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:l.path,parent:l})}}static create(e,I){return new t({in:e,out:I,typeName:QI.ZodPipeline})}},Eg=class extends ht{_parse(e){let I=this._def.innerType._parse(e),l=n=>(JV(n)&&(n.value=Object.freeze(n.value)),n);return V1(I)?I.then(n=>l(n)):l(I)}unwrap(){return this._def.innerType}};Eg.create=(t,e)=>new Eg({innerType:t,typeName:QI.ZodReadonly,...rt(e)});function DKe(t,e){let I=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof I=="string"?{message:I}:I}function $Ke(t,e={},I){return t?kV.create().superRefine((l,n)=>{let c=t(l);if(c instanceof Promise)return c.then(r=>{if(!r){let s=DKe(e,l),a=s.fatal??I??!0;n.addIssue({code:"custom",...s,fatal:a})}});if(!c){let r=DKe(e,l),s=r.fatal??I??!0;n.addIssue({code:"custom",...r,fatal:s})}}):kV.create()}var JDI={object:oG.lazycreate},QI;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(QI||(QI={}));var LDI=(t,e={message:`Input not instance of ${t.name}`})=>$Ke(I=>I instanceof t,e),ae=LV.create,na=Zg.create,kDI=Q1.create,fDI=ug.create,bn=Wg.create,xDI=Ng.create,BDI=y1.create,zDI=Yg.create,UDI=Vg.create,Fpe=kV.create,pp=Du.create,SDI=Mb.create,ODI=g1.create,ys=Ku.create,Ue=oG.create,MDI=oG.strictCreate,ca=Rg.create,Mx=Mq.create,TDI=yg.create,Ape=mp.create,w1=Tq.create,jDI=F1.create,DDI=A1.create,KDI=jq.create,PDI=gg.create,ZI=Fg.create,yi=Ag.create,qDI=Qg.create,_DI=fV.create,$DI=Ri.create,eKI=Yi.create,IKI=hp.create,tKI=Ri.createWithPreprocess,lKI=Ox.create,nKI=()=>ae().optional(),cKI=()=>na().optional(),rKI=()=>bn().optional(),Tx={string:t=>LV.create({...t,coerce:!0}),number:t=>Zg.create({...t,coerce:!0}),boolean:t=>Wg.create({...t,coerce:!0}),bigint:t=>ug.create({...t,coerce:!0}),date:t=>Ng.create({...t,coerce:!0})};var sKI=gI;var X1="2025-06-18";var ePe=[X1,"2025-03-26","2024-11-05","2024-10-07"],Kq="2.0",IPe=Y.union([Y.string(),Y.number().int()]),tPe=Y.string(),aKI=Y.object({progressToken:Y.optional(IPe)}).passthrough(),Ai=Y.object({_meta:Y.optional(aKI)}).passthrough(),GG=Y.object({method:Y.string(),params:Y.optional(Ai)}),jx=Y.object({_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),Zp=Y.object({method:Y.string(),params:Y.optional(jx)}),Qi=Y.object({_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),Pq=Y.union([Y.string(),Y.number().int()]),lPe=Y.object({jsonrpc:Y.literal(Kq),id:Pq}).merge(GG).strict(),qq=t=>lPe.safeParse(t).success,nPe=Y.object({jsonrpc:Y.literal(Kq)}).merge(Zp).strict(),cPe=t=>nPe.safeParse(t).success,rPe=Y.object({jsonrpc:Y.literal(Kq),id:Pq,result:Qi}).strict(),Dx=t=>rPe.safeParse(t).success,gi;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError"})(gi||(gi={}));var sPe=Y.object({jsonrpc:Y.literal(Kq),id:Pq,error:Y.object({code:Y.number().int(),message:Y.string(),data:Y.optional(Y.unknown())})}).strict(),aPe=t=>sPe.safeParse(t).success,xV=Y.union([lPe,nPe,rPe,sPe]),Hg=Qi.strict(),_q=Zp.extend({method:Y.literal("notifications/cancelled"),params:jx.extend({requestId:Pq,reason:Y.string().optional()})}),$q=Y.object({src:Y.string(),mimeType:Y.optional(Y.string()),sizes:Y.optional(Y.string())}).passthrough(),Kx=Y.object({name:Y.string(),title:Y.optional(Y.string())}).passthrough(),oPe=Kx.extend({version:Y.string(),websiteUrl:Y.optional(Y.string()),icons:Y.optional(Y.array($q))}),oKI=Y.object({experimental:Y.optional(Y.object({}).passthrough()),sampling:Y.optional(Y.object({}).passthrough()),elicitation:Y.optional(Y.object({}).passthrough()),roots:Y.optional(Y.object({listChanged:Y.optional(Y.boolean())}).passthrough())}).passthrough(),GKI=GG.extend({method:Y.literal("initialize"),params:Ai.extend({protocolVersion:Y.string(),capabilities:oKI,clientInfo:oPe})});var dKI=Y.object({experimental:Y.optional(Y.object({}).passthrough()),logging:Y.optional(Y.object({}).passthrough()),completions:Y.optional(Y.object({}).passthrough()),prompts:Y.optional(Y.object({listChanged:Y.optional(Y.boolean())}).passthrough()),resources:Y.optional(Y.object({subscribe:Y.optional(Y.boolean()),listChanged:Y.optional(Y.boolean())}).passthrough()),tools:Y.optional(Y.object({listChanged:Y.optional(Y.boolean())}).passthrough())}).passthrough(),Qpe=Qi.extend({protocolVersion:Y.string(),capabilities:dKI,serverInfo:oPe,instructions:Y.optional(Y.string())}),GPe=Zp.extend({method:Y.literal("notifications/initialized")}),dPe=t=>GPe.safeParse(t).success,e8=GG.extend({method:Y.literal("ping")}),iKI=Y.object({progress:Y.number(),total:Y.optional(Y.number()),message:Y.optional(Y.string())}).passthrough(),I8=Zp.extend({method:Y.literal("notifications/progress"),params:jx.merge(iKI).extend({progressToken:IPe})}),t8=GG.extend({params:Ai.extend({cursor:Y.optional(tPe)}).optional()}),l8=Qi.extend({nextCursor:Y.optional(tPe)}),iPe=Y.object({uri:Y.string(),mimeType:Y.optional(Y.string()),_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),bPe=iPe.extend({text:Y.string()}),wpe=Y.string().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),mPe=iPe.extend({blob:wpe}),hPe=Kx.extend({uri:Y.string(),description:Y.optional(Y.string()),mimeType:Y.optional(Y.string()),icons:Y.optional(Y.array($q)),_meta:Y.optional(Y.object({}).passthrough())}),bKI=Kx.extend({uriTemplate:Y.string(),description:Y.optional(Y.string()),mimeType:Y.optional(Y.string()),_meta:Y.optional(Y.object({}).passthrough())}),mKI=t8.extend({method:Y.literal("resources/list")}),Xpe=l8.extend({resources:Y.array(hPe)}),hKI=t8.extend({method:Y.literal("resources/templates/list")}),Epe=l8.extend({resourceTemplates:Y.array(bKI)}),pKI=GG.extend({method:Y.literal("resources/read"),params:Ai.extend({uri:Y.string()})}),Hpe=Qi.extend({contents:Y.array(Y.union([bPe,mPe]))}),ZKI=Zp.extend({method:Y.literal("notifications/resources/list_changed")}),uKI=GG.extend({method:Y.literal("resources/subscribe"),params:Ai.extend({uri:Y.string()})}),WKI=GG.extend({method:Y.literal("resources/unsubscribe"),params:Ai.extend({uri:Y.string()})}),NKI=Zp.extend({method:Y.literal("notifications/resources/updated"),params:jx.extend({uri:Y.string()})}),YKI=Y.object({name:Y.string(),description:Y.optional(Y.string()),required:Y.optional(Y.boolean())}).passthrough(),VKI=Kx.extend({description:Y.optional(Y.string()),arguments:Y.optional(Y.array(YKI)),icons:Y.optional(Y.array($q)),_meta:Y.optional(Y.object({}).passthrough())}),RKI=t8.extend({method:Y.literal("prompts/list")}),vpe=l8.extend({prompts:Y.array(VKI)}),yKI=GG.extend({method:Y.literal("prompts/get"),params:Ai.extend({name:Y.string(),arguments:Y.optional(Y.record(Y.string()))})}),Cpe=Y.object({type:Y.literal("text"),text:Y.string(),_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),Jpe=Y.object({type:Y.literal("image"),data:wpe,mimeType:Y.string(),_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),Lpe=Y.object({type:Y.literal("audio"),data:wpe,mimeType:Y.string(),_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),gKI=Y.object({type:Y.literal("resource"),resource:Y.union([bPe,mPe]),_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),FKI=hPe.extend({type:Y.literal("resource_link")}),pPe=Y.union([Cpe,Jpe,Lpe,FKI,gKI]),AKI=Y.object({role:Y.enum(["user","assistant"]),content:pPe}).passthrough(),kpe=Qi.extend({description:Y.optional(Y.string()),messages:Y.array(AKI)}),QKI=Zp.extend({method:Y.literal("notifications/prompts/list_changed")}),wKI=Y.object({title:Y.optional(Y.string()),readOnlyHint:Y.optional(Y.boolean()),destructiveHint:Y.optional(Y.boolean()),idempotentHint:Y.optional(Y.boolean()),openWorldHint:Y.optional(Y.boolean())}).passthrough(),XKI=Kx.extend({description:Y.optional(Y.string()),inputSchema:Y.object({type:Y.literal("object"),properties:Y.optional(Y.object({}).passthrough()),required:Y.optional(Y.array(Y.string()))}).passthrough(),outputSchema:Y.optional(Y.object({type:Y.literal("object"),properties:Y.optional(Y.object({}).passthrough()),required:Y.optional(Y.array(Y.string()))}).passthrough()),annotations:Y.optional(wKI),icons:Y.optional(Y.array($q)),_meta:Y.optional(Y.object({}).passthrough())}),EKI=t8.extend({method:Y.literal("tools/list")}),fpe=l8.extend({tools:Y.array(XKI)}),n8=Qi.extend({content:Y.array(pPe).default([]),structuredContent:Y.object({}).passthrough().optional(),isError:Y.optional(Y.boolean())}),prn=n8.or(Qi.extend({toolResult:Y.unknown()})),HKI=GG.extend({method:Y.literal("tools/call"),params:Ai.extend({name:Y.string(),arguments:Y.optional(Y.record(Y.unknown()))})}),vKI=Zp.extend({method:Y.literal("notifications/tools/list_changed")}),ZPe=Y.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),CKI=GG.extend({method:Y.literal("logging/setLevel"),params:Ai.extend({level:ZPe})}),JKI=Zp.extend({method:Y.literal("notifications/message"),params:jx.extend({level:ZPe,logger:Y.optional(Y.string()),data:Y.unknown()})}),LKI=Y.object({name:Y.string().optional()}).passthrough(),kKI=Y.object({hints:Y.optional(Y.array(LKI)),costPriority:Y.optional(Y.number().min(0).max(1)),speedPriority:Y.optional(Y.number().min(0).max(1)),intelligencePriority:Y.optional(Y.number().min(0).max(1))}).passthrough(),fKI=Y.object({role:Y.enum(["user","assistant"]),content:Y.union([Cpe,Jpe,Lpe])}).passthrough(),xKI=GG.extend({method:Y.literal("sampling/createMessage"),params:Ai.extend({messages:Y.array(fKI),systemPrompt:Y.optional(Y.string()),includeContext:Y.optional(Y.enum(["none","thisServer","allServers"])),temperature:Y.optional(Y.number()),maxTokens:Y.number().int(),stopSequences:Y.optional(Y.array(Y.string())),metadata:Y.optional(Y.object({}).passthrough()),modelPreferences:Y.optional(kKI)})}),BKI=Qi.extend({model:Y.string(),stopReason:Y.optional(Y.enum(["endTurn","stopSequence","maxTokens"]).or(Y.string())),role:Y.enum(["user","assistant"]),content:Y.discriminatedUnion("type",[Cpe,Jpe,Lpe])}),zKI=Y.object({type:Y.literal("boolean"),title:Y.optional(Y.string()),description:Y.optional(Y.string()),default:Y.optional(Y.boolean())}).passthrough(),UKI=Y.object({type:Y.literal("string"),title:Y.optional(Y.string()),description:Y.optional(Y.string()),minLength:Y.optional(Y.number()),maxLength:Y.optional(Y.number()),format:Y.optional(Y.enum(["email","uri","date","date-time"]))}).passthrough(),SKI=Y.object({type:Y.enum(["number","integer"]),title:Y.optional(Y.string()),description:Y.optional(Y.string()),minimum:Y.optional(Y.number()),maximum:Y.optional(Y.number())}).passthrough(),OKI=Y.object({type:Y.literal("string"),title:Y.optional(Y.string()),description:Y.optional(Y.string()),enum:Y.array(Y.string()),enumNames:Y.optional(Y.array(Y.string()))}).passthrough(),MKI=Y.union([zKI,UKI,SKI,OKI]),TKI=GG.extend({method:Y.literal("elicitation/create"),params:Ai.extend({message:Y.string(),requestedSchema:Y.object({type:Y.literal("object"),properties:Y.record(Y.string(),MKI),required:Y.optional(Y.array(Y.string()))}).passthrough()})}),jKI=Qi.extend({action:Y.enum(["accept","decline","cancel"]),content:Y.optional(Y.record(Y.string(),Y.unknown()))}),DKI=Y.object({type:Y.literal("ref/resource"),uri:Y.string()}).passthrough();var KKI=Y.object({type:Y.literal("ref/prompt"),name:Y.string()}).passthrough(),PKI=GG.extend({method:Y.literal("completion/complete"),params:Ai.extend({ref:Y.union([KKI,DKI]),argument:Y.object({name:Y.string(),value:Y.string()}).passthrough(),context:Y.optional(Y.object({arguments:Y.optional(Y.record(Y.string(),Y.string()))}))})}),xpe=Qi.extend({completion:Y.object({values:Y.array(Y.string()).max(100),total:Y.optional(Y.number().int()),hasMore:Y.optional(Y.boolean())}).passthrough()}),qKI=Y.object({uri:Y.string().startsWith("file://"),name:Y.optional(Y.string()),_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),_KI=GG.extend({method:Y.literal("roots/list")}),$KI=Qi.extend({roots:Y.array(qKI)}),ePI=Zp.extend({method:Y.literal("notifications/roots/list_changed")}),Zrn=Y.union([e8,GKI,PKI,CKI,yKI,RKI,mKI,hKI,pKI,uKI,WKI,HKI,EKI]),urn=Y.union([_q,I8,GPe,ePI]),Wrn=Y.union([Hg,BKI,jKI,$KI]),Nrn=Y.union([e8,xKI,TKI,_KI]),Yrn=Y.union([_q,I8,JKI,NKI,ZKI,vKI,QKI]),Vrn=Y.union([Hg,Qpe,xpe,kpe,vpe,Xpe,Epe,Hpe,n8,fpe]),Fi=class extends Error{constructor(e,I,l){super(`MCP error ${e}: ${I}`),this.code=e,this.data=l,this.name="McpError"}};var IPI=6e4,c8=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this.setNotificationHandler(_q,I=>{let l=this._requestHandlerAbortControllers.get(I.params.requestId);l?.abort(I.params.reason)}),this.setNotificationHandler(I8,I=>{this._onprogress(I)}),this.setRequestHandler(e8,I=>({}))}_setupTimeout(e,I,l,n,c=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,I),startTime:Date.now(),timeout:I,maxTotalTimeout:l,resetTimeoutOnProgress:c,onTimeout:n})}_resetTimeout(e){let I=this._timeoutInfo.get(e);if(!I)return!1;let l=Date.now()-I.startTime;if(I.maxTotalTimeout&&l>=I.maxTotalTimeout)throw this._timeoutInfo.delete(e),new Fi(gi.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:I.maxTotalTimeout,totalElapsed:l});return clearTimeout(I.timeoutId),I.timeoutId=setTimeout(I.onTimeout,I.timeout),!0}_cleanupTimeout(e){let I=this._timeoutInfo.get(e);I&&(clearTimeout(I.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var I,l,n;this._transport=e;let c=(I=this.transport)===null||I===void 0?void 0:I.onclose;this._transport.onclose=()=>{c?.(),this._onclose()};let r=(l=this.transport)===null||l===void 0?void 0:l.onerror;this._transport.onerror=a=>{r?.(a),this._onerror(a)};let s=(n=this._transport)===null||n===void 0?void 0:n.onmessage;this._transport.onmessage=(a,G)=>{s?.(a,G),Dx(a)||aPe(a)?this._onresponse(a):qq(a)?this._onrequest(a,G):cPe(a)?this._onnotification(a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(a)}`))},await this._transport.start()}_onclose(){var e;let I=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);let l=new Fi(gi.ConnectionClosed,"Connection closed");for(let n of I.values())n(l)}_onerror(e){var I;(I=this.onerror)===null||I===void 0||I.call(this,e)}_onnotification(e){var I;let l=(I=this._notificationHandlers.get(e.method))!==null&&I!==void 0?I:this.fallbackNotificationHandler;l!==void 0&&Promise.resolve().then(()=>l(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,I){var l,n;let c=(l=this._requestHandlers.get(e.method))!==null&&l!==void 0?l:this.fallbackRequestHandler,r=this._transport;if(c===void 0){r?.send({jsonrpc:"2.0",id:e.id,error:{code:gi.MethodNotFound,message:"Method not found"}}).catch(G=>this._onerror(new Error(`Failed to send an error response: ${G}`)));return}let s=new AbortController;this._requestHandlerAbortControllers.set(e.id,s);let a={signal:s.signal,sessionId:r?.sessionId,_meta:(n=e.params)===null||n===void 0?void 0:n._meta,sendNotification:G=>this.notification(G,{relatedRequestId:e.id}),sendRequest:(G,d,i)=>this.request(G,d,{...i,relatedRequestId:e.id}),authInfo:I?.authInfo,requestId:e.id,requestInfo:I?.requestInfo};Promise.resolve().then(()=>c(e,a)).then(G=>{if(!s.signal.aborted)return r?.send({result:G,jsonrpc:"2.0",id:e.id})},G=>{var d;if(!s.signal.aborted)return r?.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(G.code)?G.code:gi.InternalError,message:(d=G.message)!==null&&d!==void 0?d:"Internal error"}})}).catch(G=>this._onerror(new Error(`Failed to send response: ${G}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:I,...l}=e.params,n=Number(I),c=this._progressHandlers.get(n);if(!c){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let r=this._responseHandlers.get(n),s=this._timeoutInfo.get(n);if(s&&r&&s.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(a){r(a);return}c(l)}_onresponse(e){let I=Number(e.id),l=this._responseHandlers.get(I);if(l===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(I),this._progressHandlers.delete(I),this._cleanupTimeout(I),Dx(e))l(e);else{let n=new Fi(e.error.code,e.error.message,e.error.data);l(n)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,I,l){let{relatedRequestId:n,resumptionToken:c,onresumptiontoken:r}=l??{};return new Promise((s,a)=>{var G,d,i,b,m,h;if(!this._transport){a(new Error("Not connected"));return}((G=this._options)===null||G===void 0?void 0:G.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(d=l?.signal)===null||d===void 0||d.throwIfAborted();let p=this._requestMessageId++,u={...e,jsonrpc:"2.0",id:p};l?.onprogress&&(this._progressHandlers.set(p,l.onprogress),u.params={...e.params,_meta:{...((i=e.params)===null||i===void 0?void 0:i._meta)||{},progressToken:p}});let W=F=>{var A;this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),(A=this._transport)===null||A===void 0||A.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(F)}},{relatedRequestId:n,resumptionToken:c,onresumptiontoken:r}).catch(k=>this._onerror(new Error(`Failed to send cancellation: ${k}`))),a(F)};this._responseHandlers.set(p,F=>{var A;if(!(!((A=l?.signal)===null||A===void 0)&&A.aborted)){if(F instanceof Error)return a(F);try{let k=I.parse(F.result);s(k)}catch(k){a(k)}}}),(b=l?.signal)===null||b===void 0||b.addEventListener("abort",()=>{var F;W((F=l?.signal)===null||F===void 0?void 0:F.reason)});let V=(m=l?.timeout)!==null&&m!==void 0?m:IPI,g=()=>W(new Fi(gi.RequestTimeout,"Request timed out",{timeout:V}));this._setupTimeout(p,V,l?.maxTotalTimeout,g,(h=l?.resetTimeoutOnProgress)!==null&&h!==void 0?h:!1),this._transport.send(u,{relatedRequestId:n,resumptionToken:c,onresumptiontoken:r}).catch(F=>{this._cleanupTimeout(p),a(F)})})}async notification(e,I){var l,n;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(e.method),((n=(l=this._options)===null||l===void 0?void 0:l.debouncedNotificationMethods)!==null&&n!==void 0?n:[]).includes(e.method)&&!e.params&&!I?.relatedRequestId){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var a;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let G={...e,jsonrpc:"2.0"};(a=this._transport)===null||a===void 0||a.send(G,I).catch(d=>this._onerror(d))});return}let s={...e,jsonrpc:"2.0"};await this._transport.send(s,I)}setRequestHandler(e,I){let l=e.shape.method.value;this.assertRequestHandlerCapability(l),this._requestHandlers.set(l,(n,c)=>Promise.resolve(I(e.parse(n),c)))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,I){this._notificationHandlers.set(e.shape.method.value,l=>Promise.resolve(I(e.parse(l))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function uPe(t,e){return Object.entries(e).reduce((I,[l,n])=>(n&&typeof n=="object"?I[l]=I[l]?{...I[l],...n}:n:I[l]=n,I),{...t})}var _qe=Ml(qqe(),1),B8=class extends c8{constructor(e,I){var l;super(I),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._capabilities=(l=I?.capabilities)!==null&&l!==void 0?l:{},this._ajv=new _qe.default}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=uPe(this._capabilities,e)}assertCapability(e,I){var l;if(!(!((l=this._serverCapabilities)===null||l===void 0)&&l[e]))throw new Error(`Server does not support ${e} (required for ${I})`)}async connect(e,I){if(await super.connect(e),e.sessionId===void 0)try{let l=await this.request({method:"initialize",params:{protocolVersion:X1,capabilities:this._capabilities,clientInfo:this._clientInfo}},Qpe,I);if(l===void 0)throw new Error(`Server sent invalid initialize result: ${l}`);if(!ePe.includes(l.protocolVersion))throw new Error(`Server's protocol version is not supported: ${l.protocolVersion}`);this._serverCapabilities=l.capabilities,this._serverVersion=l.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(l.protocolVersion),this._instructions=l.instructions,await this.notification({method:"notifications/initialized"})}catch(l){throw this.close(),l}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var I,l,n,c,r;switch(e){case"logging/setLevel":if(!(!((I=this._serverCapabilities)===null||I===void 0)&&I.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(!((l=this._serverCapabilities)===null||l===void 0)&&l.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n.resources))throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(!((c=this._serverCapabilities)===null||c===void 0)&&c.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(!((r=this._serverCapabilities)===null||r===void 0)&&r.completions))throw new Error(`Server does not support completions (required for ${e})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){var I;switch(e){case"notifications/roots/list_changed":if(!(!((I=this._capabilities.roots)===null||I===void 0)&&I.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"ping":break}}async ping(e){return this.request({method:"ping"},Hg,e)}async complete(e,I){return this.request({method:"completion/complete",params:e},xpe,I)}async setLoggingLevel(e,I){return this.request({method:"logging/setLevel",params:{level:e}},Hg,I)}async getPrompt(e,I){return this.request({method:"prompts/get",params:e},kpe,I)}async listPrompts(e,I){return this.request({method:"prompts/list",params:e},vpe,I)}async listResources(e,I){return this.request({method:"resources/list",params:e},Xpe,I)}async listResourceTemplates(e,I){return this.request({method:"resources/templates/list",params:e},Epe,I)}async readResource(e,I){return this.request({method:"resources/read",params:e},Hpe,I)}async subscribeResource(e,I){return this.request({method:"resources/subscribe",params:e},Hg,I)}async unsubscribeResource(e,I){return this.request({method:"resources/unsubscribe",params:e},Hg,I)}async callTool(e,I=n8,l){let n=await this.request({method:"tools/call",params:e},I,l),c=this.getToolOutputValidator(e.name);if(c){if(!n.structuredContent&&!n.isError)throw new Fi(gi.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(n.structuredContent)try{if(!c(n.structuredContent))throw new Fi(gi.InvalidParams,`Structured content does not match the tool's output schema: ${this._ajv.errorsText(c.errors)}`)}catch(r){throw r instanceof Fi?r:new Fi(gi.InvalidParams,`Failed to validate structured content: ${r instanceof Error?r.message:String(r)}`)}}return n}cacheToolOutputSchemas(e){this._cachedToolOutputValidators.clear();for(let I of e)if(I.outputSchema)try{let l=this._ajv.compile(I.outputSchema);this._cachedToolOutputValidators.set(I.name,l)}catch{}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,I){let l=await this.request({method:"tools/list",params:e},fpe,I);return this.cacheToolOutputSchemas(l.tools),l}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var z8=class{createClient(e,I){return new B8(e,I)}};o();o();o();o();var U8=class extends Error{constructor(e,I){super(e),this.name="ParseError",this.type=I.type,this.field=I.field,this.value=I.value,this.line=I.line}};function Rue(t){}function S8(t){if(typeof t=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:e=Rue,onError:I=Rue,onRetry:l=Rue,onComment:n}=t,c="",r=!0,s,a="",G="";function d(p){let u=r?p.replace(/^\xEF\xBB\xBF/,""):p,[W,V]=F_I(`${c}${u}`);for(let g of W)i(g);c=V,r=!1}function i(p){if(p===""){m();return}if(p.startsWith(":")){n&&n(p.slice(p.startsWith(": ")?2:1));return}let u=p.indexOf(":");if(u!==-1){let W=p.slice(0,u),V=p[u+1]===" "?2:1,g=p.slice(u+V);b(W,g,p);return}b(p,"",p)}function b(p,u,W){switch(p){case"event":G=u;break;case"data":a=`${a}${u}
1415
1415
  `;break;case"id":s=u.includes("\0")?void 0:u;break;case"retry":/^\d+$/.test(u)?l(parseInt(u,10)):I(new U8(`Invalid \`retry\` value: "${u}"`,{type:"invalid-retry",value:u,line:W}));break;default:I(new U8(`Unknown field "${p.length>20?`${p.slice(0,20)}\u2026`:p}"`,{type:"unknown-field",field:p,value:u,line:W}));break}}function m(){a.length>0&&e({id:s,event:G||void 0,data:a.endsWith(`
1416
1416
  `)?a.slice(0,-1):a}),s=void 0,a="",G=""}function h(p={}){c&&p.consume&&i(c),r=!0,s=void 0,a="",G="",c=""}return{feed:d,reset:h}}function F_I(t){let e=[],I="",l=0;for(;l<t.length;){let n=t.indexOf("\r",l),c=t.indexOf(`
1417
1417
  `,l),r=-1;if(n!==-1&&c!==-1?r=Math.min(n,c):n!==-1?r=n:c!==-1&&(r=c),r===-1){I=t.slice(l);break}else{let s=t.slice(l,r);e.push(s),l=r+1,t[l-1]==="\r"&&t[l]===`