yap2app 1.1.4 → 1.1.6

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/bin/cli.bundle.js CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- if(typeof process!=='undefined'&&process.emitWarning){var _ow=process.emitWarning;process.emitWarning=function(w){if(typeof w==='string'&&(w.includes('punycode')||w.includes('ExperimentalWarning')||w.includes('DEP0040')))return;if(w&&typeof w==='object'&&(w.code==='DEP0040'||w.name==='ExperimentalWarning'||String(w.message||'').includes('punycode')))return;return _ow.apply(process,arguments);};}if(typeof globalThis==='undefined'){if(typeof global!=='undefined'){global.globalThis=global;}else if(typeof window!=='undefined'){window.globalThis=window;}else if(typeof self!=='undefined'){self.globalThis=self;}}if(!Object.fromEntries){Object.fromEntries=function(e){if(!e)return{};var o={};var a=Array.isArray(e)?e:Array.from(e);for(var i=0;i<a.length;i++){var p=a[i];if(p&&p.length>=2)o[p[0]]=p[1];}return o;};}if(!Object.hasOwn){Object.hasOwn=function(o,p){return o!=null&&Object.prototype.hasOwnProperty.call(o,p);};}if(!Array.prototype.flat){Array.prototype.flat=function(d){var f=[];var dp=typeof d==='number'?d:1;(function fl(a,cd){for(var i=0;i<a.length;i++){if(Array.isArray(a[i])&&cd>0){fl(a[i],cd-1);}else{f.push(a[i]);}}})(this,dp);return f;};}if(!String.prototype.replaceAll){String.prototype.replaceAll=function(s,r){if(s instanceof RegExp)return this.replace(s,r);return this.split(s).join(r);};}if(!String.prototype.matchAll){String.prototype.matchAll=function(r){var f=r.flags;if(!f.includes('g'))f+='g';var rx=new RegExp(r.source,f);var s=String(this);var m=[];var mt;while((mt=rx.exec(s))!==null){m.push(mt);if(mt.index===rx.lastIndex)rx.lastIndex++;}return m[Symbol.iterator]?m[Symbol.iterator]():m;};}
3
2
  var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -77,12 +76,12 @@ var require_code = __commonJS({
77
76
  return item === "" || item === '""';
78
77
  }
79
78
  get str() {
80
- var _a5;
81
- return (_a5 = this._str) !== null && _a5 !== void 0 ? _a5 : this._str = this._items.reduce((s, c) => `${s}${c}`, "");
79
+ var _a3;
80
+ return (_a3 = this._str) !== null && _a3 !== void 0 ? _a3 : this._str = this._items.reduce((s, c) => `${s}${c}`, "");
82
81
  }
83
82
  get names() {
84
- var _a5;
85
- return (_a5 = this._names) !== null && _a5 !== void 0 ? _a5 : this._names = this._items.reduce((names, c) => {
83
+ var _a3;
84
+ return (_a3 = this._names) !== null && _a3 !== void 0 ? _a3 : this._names = this._items.reduce((names, c) => {
86
85
  if (c instanceof Name)
87
86
  names[c.str] = (names[c.str] || 0) + 1;
88
87
  return names;
@@ -228,8 +227,8 @@ var require_scope = __commonJS({
228
227
  return `${prefix}${ng.index++}`;
229
228
  }
230
229
  _nameGroup(prefix) {
231
- var _a5, _b;
232
- if (((_b = (_a5 = this._parent) === null || _a5 === void 0 ? void 0 : _a5._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) {
230
+ var _a3, _b;
231
+ if (((_b = (_a3 = this._parent) === null || _a3 === void 0 ? void 0 : _a3._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) {
233
232
  throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
234
233
  }
235
234
  return this._names[prefix] = { prefix, index: 0 };
@@ -262,12 +261,12 @@ var require_scope = __commonJS({
262
261
  return new ValueScopeName(prefix, this._newName(prefix));
263
262
  }
264
263
  value(nameOrPrefix, value) {
265
- var _a5;
264
+ var _a3;
266
265
  if (value.ref === void 0)
267
266
  throw new Error("CodeGen: ref must be passed in value");
268
267
  const name = this.toName(nameOrPrefix);
269
268
  const { prefix } = name;
270
- const valueKey = (_a5 = value.key) !== null && _a5 !== void 0 ? _a5 : value.ref;
269
+ const valueKey = (_a3 = value.key) !== null && _a3 !== void 0 ? _a3 : value.ref;
271
270
  let vs = this._values[prefix];
272
271
  if (vs) {
273
272
  const _name = vs.get(valueKey);
@@ -585,8 +584,8 @@ var require_codegen = __commonJS({
585
584
  return this;
586
585
  }
587
586
  optimizeNames(names, constants) {
588
- var _a5;
589
- this.else = (_a5 = this.else) === null || _a5 === void 0 ? void 0 : _a5.optimizeNames(names, constants);
587
+ var _a3;
588
+ this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants);
590
589
  if (!(super.optimizeNames(names, constants) || this.else))
591
590
  return;
592
591
  this.condition = optimizeExpr(this.condition, names, constants);
@@ -690,16 +689,16 @@ var require_codegen = __commonJS({
690
689
  return code;
691
690
  }
692
691
  optimizeNodes() {
693
- var _a5, _b;
692
+ var _a3, _b;
694
693
  super.optimizeNodes();
695
- (_a5 = this.catch) === null || _a5 === void 0 ? void 0 : _a5.optimizeNodes();
694
+ (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNodes();
696
695
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
697
696
  return this;
698
697
  }
699
698
  optimizeNames(names, constants) {
700
- var _a5, _b;
699
+ var _a3, _b;
701
700
  super.optimizeNames(names, constants);
702
- (_a5 = this.catch) === null || _a5 === void 0 ? void 0 : _a5.optimizeNames(names, constants);
701
+ (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants);
703
702
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
704
703
  return this;
705
704
  }
@@ -1479,8 +1478,8 @@ var require_applicability = __commonJS({
1479
1478
  }
1480
1479
  exports2.shouldUseGroup = shouldUseGroup;
1481
1480
  function shouldUseRule(schema, rule) {
1482
- var _a5;
1483
- return schema[rule.keyword] !== void 0 || ((_a5 = rule.definition.implements) === null || _a5 === void 0 ? void 0 : _a5.some((kwd) => schema[kwd] !== void 0));
1481
+ var _a3;
1482
+ return schema[rule.keyword] !== void 0 || ((_a3 = rule.definition.implements) === null || _a3 === void 0 ? void 0 : _a3.some((kwd) => schema[kwd] !== void 0));
1484
1483
  }
1485
1484
  exports2.shouldUseRule = shouldUseRule;
1486
1485
  }
@@ -1868,14 +1867,14 @@ var require_keyword = __commonJS({
1868
1867
  }
1869
1868
  exports2.macroKeywordCode = macroKeywordCode;
1870
1869
  function funcKeywordCode(cxt, def) {
1871
- var _a5;
1870
+ var _a3;
1872
1871
  const { gen, keyword, schema, parentSchema, $data, it } = cxt;
1873
1872
  checkAsyncKeyword(it, def);
1874
1873
  const validate = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate;
1875
1874
  const validateRef = useKeyword(gen, keyword, validate);
1876
1875
  const valid = gen.let("valid");
1877
1876
  cxt.block$data(valid, validateKeyword);
1878
- cxt.ok((_a5 = def.valid) !== null && _a5 !== void 0 ? _a5 : valid);
1877
+ cxt.ok((_a3 = def.valid) !== null && _a3 !== void 0 ? _a3 : valid);
1879
1878
  function validateKeyword() {
1880
1879
  if (def.errors === false) {
1881
1880
  assignValid();
@@ -1906,8 +1905,8 @@ var require_keyword = __commonJS({
1906
1905
  gen.assign(valid, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
1907
1906
  }
1908
1907
  function reportErrs(errors) {
1909
- var _a6;
1910
- gen.if((0, codegen_1.not)((_a6 = def.valid) !== null && _a6 !== void 0 ? _a6 : valid), errors);
1908
+ var _a4;
1909
+ gen.if((0, codegen_1.not)((_a4 = def.valid) !== null && _a4 !== void 0 ? _a4 : valid), errors);
1911
1910
  }
1912
1911
  }
1913
1912
  exports2.funcKeywordCode = funcKeywordCode;
@@ -2875,7 +2874,7 @@ var require_compile = __commonJS({
2875
2874
  var validate_1 = require_validate();
2876
2875
  var SchemaEnv = class {
2877
2876
  constructor(env) {
2878
- var _a5;
2877
+ var _a3;
2879
2878
  this.refs = {};
2880
2879
  this.dynamicAnchors = {};
2881
2880
  let schema;
@@ -2884,7 +2883,7 @@ var require_compile = __commonJS({
2884
2883
  this.schema = env.schema;
2885
2884
  this.schemaId = env.schemaId;
2886
2885
  this.root = env.root || this;
2887
- this.baseId = (_a5 = env.baseId) !== null && _a5 !== void 0 ? _a5 : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]);
2886
+ this.baseId = (_a3 = env.baseId) !== null && _a3 !== void 0 ? _a3 : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]);
2888
2887
  this.schemaPath = env.schemaPath;
2889
2888
  this.localRefs = env.localRefs;
2890
2889
  this.meta = env.meta;
@@ -2980,14 +2979,14 @@ var require_compile = __commonJS({
2980
2979
  }
2981
2980
  exports2.compileSchema = compileSchema;
2982
2981
  function resolveRef(root, baseId, ref) {
2983
- var _a5;
2982
+ var _a3;
2984
2983
  ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
2985
2984
  const schOrFunc = root.refs[ref];
2986
2985
  if (schOrFunc)
2987
2986
  return schOrFunc;
2988
2987
  let _sch = resolve.call(this, root, ref);
2989
2988
  if (_sch === void 0) {
2990
- const schema = (_a5 = root.localRefs) === null || _a5 === void 0 ? void 0 : _a5[ref];
2989
+ const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
2991
2990
  const { schemaId } = this.opts;
2992
2991
  if (schema)
2993
2992
  _sch = new SchemaEnv({ schema, schemaId, root, baseId });
@@ -3056,8 +3055,8 @@ var require_compile = __commonJS({
3056
3055
  "definitions"
3057
3056
  ]);
3058
3057
  function getJsonPointer(parsedRef, { baseId, schema, root }) {
3059
- var _a5;
3060
- if (((_a5 = parsedRef.fragment) === null || _a5 === void 0 ? void 0 : _a5[0]) !== "/")
3058
+ var _a3;
3059
+ if (((_a3 = parsedRef.fragment) === null || _a3 === void 0 ? void 0 : _a3[0]) !== "/")
3061
3060
  return;
3062
3061
  for (const part of parsedRef.fragment.slice(1).split("/")) {
3063
3062
  if (typeof schema === "boolean")
@@ -3552,7 +3551,7 @@ var require_schemes = __commonJS({
3552
3551
  serialize: httpSerialize
3553
3552
  }
3554
3553
  );
3555
- var https = (
3554
+ var https2 = (
3556
3555
  /** @type {SchemeHandler} */
3557
3556
  {
3558
3557
  scheme: "https",
@@ -3601,7 +3600,7 @@ var require_schemes = __commonJS({
3601
3600
  /** @type {Record<SchemeName, SchemeHandler>} */
3602
3601
  {
3603
3602
  http: http2,
3604
- https,
3603
+ https: https2,
3605
3604
  ws,
3606
3605
  wss,
3607
3606
  urn,
@@ -4031,9 +4030,9 @@ var require_core = __commonJS({
4031
4030
  };
4032
4031
  var MAX_EXPRESSION = 200;
4033
4032
  function requiredOptions(o) {
4034
- var _a5, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
4033
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
4035
4034
  const s = o.strict;
4036
- const _optz = (_a5 = o.code) === null || _a5 === void 0 ? void 0 : _a5.optimize;
4035
+ const _optz = (_a3 = o.code) === null || _a3 === void 0 ? void 0 : _a3.optimize;
4037
4036
  const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0;
4038
4037
  const regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp;
4039
4038
  const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default;
@@ -4507,7 +4506,7 @@ var require_core = __commonJS({
4507
4506
  }
4508
4507
  }
4509
4508
  function addRule(keyword, definition, dataType) {
4510
- var _a5;
4509
+ var _a3;
4511
4510
  const post = definition === null || definition === void 0 ? void 0 : definition.post;
4512
4511
  if (dataType && post)
4513
4512
  throw new Error('keyword with "post" flag cannot have "type"');
@@ -4533,7 +4532,7 @@ var require_core = __commonJS({
4533
4532
  else
4534
4533
  ruleGroup.rules.push(rule);
4535
4534
  RULES.all[keyword] = rule;
4536
- (_a5 = definition.implements) === null || _a5 === void 0 ? void 0 : _a5.forEach((kwd) => this.addKeyword(kwd));
4535
+ (_a3 = definition.implements) === null || _a3 === void 0 ? void 0 : _a3.forEach((kwd) => this.addKeyword(kwd));
4537
4536
  }
4538
4537
  function addBeforeRule(ruleGroup, rule, before) {
4539
4538
  const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before);
@@ -4667,10 +4666,10 @@ var require_ref = __commonJS({
4667
4666
  gen.assign(names_1.default.errors, (0, codegen_1._)`${names_1.default.vErrors}.length`);
4668
4667
  }
4669
4668
  function addEvaluatedFrom(source) {
4670
- var _a5;
4669
+ var _a3;
4671
4670
  if (!it.opts.unevaluated)
4672
4671
  return;
4673
- const schEvaluated = (_a5 = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a5 === void 0 ? void 0 : _a5.evaluated;
4672
+ const schEvaluated = (_a3 = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a3 === void 0 ? void 0 : _a3.evaluated;
4674
4673
  if (it.props !== true) {
4675
4674
  if (schEvaluated && !schEvaluated.dynamicProps) {
4676
4675
  if (schEvaluated.props !== void 0) {
@@ -6321,7 +6320,7 @@ var require_discriminator = __commonJS({
6321
6320
  return _valid;
6322
6321
  }
6323
6322
  function getMapping() {
6324
- var _a5;
6323
+ var _a3;
6325
6324
  const oneOfMapping = {};
6326
6325
  const topRequired = hasRequired(parentSchema);
6327
6326
  let tagRequired = true;
@@ -6335,7 +6334,7 @@ var require_discriminator = __commonJS({
6335
6334
  if (sch === void 0)
6336
6335
  throw new ref_error_1.default(it.opts.uriResolver, it.baseId, ref);
6337
6336
  }
6338
- const propSch = (_a5 = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a5 === void 0 ? void 0 : _a5[tagName];
6337
+ const propSch = (_a3 = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a3 === void 0 ? void 0 : _a3[tagName];
6339
6338
  if (typeof propSch != "object") {
6340
6339
  throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"`);
6341
6340
  }
@@ -6904,9 +6903,9 @@ var require_dist = __commonJS({
6904
6903
  return f;
6905
6904
  };
6906
6905
  function addFormats(ajv, list, fs4, exportName) {
6907
- var _a5;
6906
+ var _a3;
6908
6907
  var _b;
6909
- (_a5 = (_b = ajv.opts.code).formats) !== null && _a5 !== void 0 ? _a5 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
6908
+ (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
6910
6909
  for (const f of list)
6911
6910
  ajv.addFormat(f, fs4[f]);
6912
6911
  }
@@ -7026,6 +7025,7 @@ if (!Promise.allSettled) {
7026
7025
 
7027
7026
  // bridge.js
7028
7027
  var import_http = __toESM(require("http"));
7028
+ var import_https = __toESM(require("https"));
7029
7029
  var import_fs2 = __toESM(require("fs"));
7030
7030
  var import_path2 = __toESM(require("path"));
7031
7031
  var import_util2 = __toESM(require("util"));
@@ -7409,12 +7409,11 @@ async function extractComponentSignatures(projectRoot, allFiles) {
7409
7409
  return catalog;
7410
7410
  }
7411
7411
  function extractPathAliases(manifests) {
7412
- var _a5;
7413
7412
  if (manifests["tsconfig.json"]) {
7414
7413
  try {
7415
7414
  const cleaned = manifests["tsconfig.json"].replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
7416
7415
  const parsed = JSON.parse(cleaned);
7417
- const paths = ((_a5 = parsed.compilerOptions) == null ? void 0 : _a5.paths) || {};
7416
+ const paths = parsed.compilerOptions?.paths || {};
7418
7417
  const firstKey = Object.keys(paths)[0];
7419
7418
  if (firstKey) {
7420
7419
  return firstKey.replace("*", "");
@@ -7574,10 +7573,50 @@ var fs2 = import_fs2.default.promises || {
7574
7573
  };
7575
7574
  var PORT = Number(process.env.YAP2APP_PORT) || 10420;
7576
7575
  var PROJECT_ROOT = process.cwd();
7576
+ var CLOUD_RELAY_URL = process.env.YAP2APP_CLOUD_URL || "https://yap2app-dot-cybage-hackathon.uc.r.appspot.com";
7577
+ var PAIR_CODE = (process.env.YAP2APP_PAIR_CODE || "CYB-" + Math.floor(100 + Math.random() * 900)).toUpperCase();
7578
+ function sendCloudRelayRequest(method, endpoint, payload) {
7579
+ return new Promise((resolve) => {
7580
+ try {
7581
+ const url = new URL(`${CLOUD_RELAY_URL}${endpoint}`);
7582
+ const body = payload ? JSON.stringify(payload) : "";
7583
+ const req = import_https.default.request({
7584
+ hostname: url.hostname,
7585
+ port: 443,
7586
+ path: url.pathname + url.search,
7587
+ method,
7588
+ headers: {
7589
+ "Content-Type": "application/json",
7590
+ "Content-Length": Buffer.byteLength(body),
7591
+ "User-Agent": "yap2app-cli/1.1.5"
7592
+ },
7593
+ timeout: 6e3
7594
+ }, (res) => {
7595
+ let respData = "";
7596
+ res.on("data", (chunk) => respData += chunk);
7597
+ res.on("end", () => {
7598
+ try {
7599
+ resolve({ ok: res.statusCode >= 200 && res.statusCode < 300, status: res.statusCode, data: JSON.parse(respData || "{}") });
7600
+ } catch {
7601
+ resolve({ ok: false, status: res.statusCode, data: null });
7602
+ }
7603
+ });
7604
+ });
7605
+ req.on("error", () => resolve({ ok: false, status: 0, data: null }));
7606
+ req.on("timeout", () => {
7607
+ req.destroy();
7608
+ resolve({ ok: false, status: 0, data: null });
7609
+ });
7610
+ if (body) req.write(body);
7611
+ req.end();
7612
+ } catch {
7613
+ resolve({ ok: false, status: 0, data: null });
7614
+ }
7615
+ });
7616
+ }
7577
7617
  function getCorsHeaders(req) {
7578
- var _a5, _b;
7579
- const origin = ((_a5 = req == null ? void 0 : req.headers) == null ? void 0 : _a5.origin) || "*";
7580
- const requestedHeaders = ((_b = req == null ? void 0 : req.headers) == null ? void 0 : _b["access-control-request-headers"]) || "*";
7618
+ const origin = req?.headers?.origin || "*";
7619
+ const requestedHeaders = req?.headers?.["access-control-request-headers"] || "*";
7581
7620
  return {
7582
7621
  "Access-Control-Allow-Origin": origin,
7583
7622
  "Access-Control-Allow-Methods": "GET, POST, OPTIONS, PUT, DELETE, HEAD, PATCH",
@@ -7643,9 +7682,10 @@ var server = import_http.default.createServer(async (req, res) => {
7643
7682
  res.writeHead(200, headers);
7644
7683
  res.end(JSON.stringify({
7645
7684
  status: "healthy",
7646
- service: "Yap2App-Localhost-Bridge",
7647
- version: "1.1.4",
7685
+ service: "yap2app-bridge",
7686
+ version: "1.1.6",
7648
7687
  port: PORT,
7688
+ pair_code: PAIR_CODE,
7649
7689
  project_root: PROJECT_ROOT,
7650
7690
  project_name: import_path2.default.basename(PROJECT_ROOT),
7651
7691
  ready: true
@@ -7655,12 +7695,12 @@ var server = import_http.default.createServer(async (req, res) => {
7655
7695
  if (req.method === "GET" && (pathname === "/api/context" || pathname === "/context")) {
7656
7696
  try {
7657
7697
  const promptQuery = searchParams.get("q") || "";
7658
- console.log(`[Yap2App Bridge] \u{1F50D} Scanning shallow codebase context in: ${PROJECT_ROOT}${promptQuery ? ` (ranking for query: "${promptQuery}")` : ""}`);
7698
+ console.log(` [bridge] Scanning codebase in ${import_path2.default.basename(PROJECT_ROOT)}${promptQuery ? ` (query: "${promptQuery}")` : ""}`);
7659
7699
  const context = await scanCodebase(PROJECT_ROOT, promptQuery);
7660
7700
  res.writeHead(200, headers);
7661
7701
  res.end(JSON.stringify(context));
7662
7702
  } catch (e) {
7663
- console.error("[Yap2App Bridge] Context scan error:", e);
7703
+ console.error(" [bridge] Context scan error:", e.message);
7664
7704
  res.writeHead(500, headers);
7665
7705
  res.end(JSON.stringify({ error: e.message }));
7666
7706
  }
@@ -7699,7 +7739,7 @@ var server = import_http.default.createServer(async (req, res) => {
7699
7739
  diffs: diffResults
7700
7740
  }));
7701
7741
  } catch (e) {
7702
- console.error("[Yap2App Bridge] Diff error:", e);
7742
+ console.error(" [bridge] Diff error:", e.message);
7703
7743
  res.writeHead(500, headers);
7704
7744
  res.end(JSON.stringify({ error: e.message }));
7705
7745
  }
@@ -7718,7 +7758,7 @@ var server = import_http.default.createServer(async (req, res) => {
7718
7758
  const fullPath = import_path2.default.join(PROJECT_ROOT, file.path);
7719
7759
  await fs2.mkdir(import_path2.default.dirname(fullPath), { recursive: true });
7720
7760
  await fs2.writeFile(fullPath, file.content, "utf8");
7721
- console.log(`[Yap2App Bridge] \u270D\uFE0F Successfully wrote: ${file.path}`);
7761
+ console.log(` [bridge] Wrote ${file.path}`);
7722
7762
  written.push(file.path);
7723
7763
  }
7724
7764
  res.writeHead(200, headers);
@@ -7730,7 +7770,7 @@ var server = import_http.default.createServer(async (req, res) => {
7730
7770
  message: `Successfully wrote ${written.length} files to ${import_path2.default.basename(PROJECT_ROOT)}`
7731
7771
  }));
7732
7772
  } catch (e) {
7733
- console.error("[Yap2App Bridge] Write to disk error:", e);
7773
+ console.error(" [bridge] Write error:", e.message);
7734
7774
  res.writeHead(500, headers);
7735
7775
  res.end(JSON.stringify({ error: e.message }));
7736
7776
  }
@@ -7743,29 +7783,76 @@ var server = import_http.default.createServer(async (req, res) => {
7743
7783
  server.on("error", (err) => {
7744
7784
  if (err && err.code === "EADDRINUSE") {
7745
7785
  console.log(`
7746
- ===============================================================`);
7747
- console.log(`\u{1F4E1} Yap2App Localhost Bridge is ALREADY active on port ${PORT}!`);
7748
- console.log(`\u{1F4C1} Active Workspace: ${PROJECT_ROOT}`);
7749
- console.log(`\u{1F310} Ready for 1-click sync from Yap2App Web Studio UI...`);
7750
- console.log(`===============================================================
7786
+ Yap2App Bridge
7787
+ `);
7788
+ console.log(` Port ${PORT} is active. Cloud Relay connected.`);
7789
+ console.log(` Workspace: ${PROJECT_ROOT}`);
7790
+ console.log(` Pair Code: ${PAIR_CODE}`);
7791
+ console.log(` Web Studio: ${CLOUD_RELAY_URL}
7751
7792
  `);
7752
7793
  return;
7753
7794
  }
7754
- console.error("[Yap2App Bridge Error]:", err);
7795
+ console.error(" [bridge] Error:", err.message || err);
7755
7796
  });
7756
- function startBridge(port = PORT) {
7797
+ async function startBridge(port = PORT) {
7757
7798
  server.listen(port, "0.0.0.0", () => {
7758
7799
  console.log(`
7759
- ===============================================================`);
7760
- console.log(`\u{1F680} Yap2App Localhost Bridge & Shallow Scanner is ACTIVE!`);
7761
- console.log(`\u{1F4E1} Listening on: http://127.0.0.1:${port}`);
7762
- console.log(`\u{1F4C1} Active Workspace: ${PROJECT_ROOT}`);
7763
- console.log(`\u{1F6E1}\uFE0F Enterprise Diff & W3C PNA Security Gate Enabled`);
7764
- console.log(`===============================================================
7800
+ Yap2App Bridge v1.1.6
7765
7801
  `);
7766
- console.log(`Ready for 1-click sync from Yap2App Web Studio UI...
7802
+ console.log(` Local: http://127.0.0.1:${port}`);
7803
+ console.log(` Workspace: ${PROJECT_ROOT}`);
7804
+ console.log(` Pair Code: ${PAIR_CODE}`);
7805
+ console.log(` Web Studio: ${CLOUD_RELAY_URL}
7806
+ `);
7807
+ console.log(` Ready for sync.
7767
7808
  `);
7768
7809
  });
7810
+ try {
7811
+ const initialContext = await scanCodebase(PROJECT_ROOT);
7812
+ await sendCloudRelayRequest("POST", "/api/v1/bridge/heartbeat", {
7813
+ pair_code: PAIR_CODE,
7814
+ project_name: import_path2.default.basename(PROJECT_ROOT),
7815
+ project_root: PROJECT_ROOT,
7816
+ framework: initialContext.framework,
7817
+ context: initialContext,
7818
+ version: "1.1.6"
7819
+ });
7820
+ } catch (e) {
7821
+ }
7822
+ setInterval(async () => {
7823
+ try {
7824
+ const context = await scanCodebase(PROJECT_ROOT);
7825
+ const hbResult = await sendCloudRelayRequest("POST", "/api/v1/bridge/heartbeat", {
7826
+ pair_code: PAIR_CODE,
7827
+ project_name: import_path2.default.basename(PROJECT_ROOT),
7828
+ project_root: PROJECT_ROOT,
7829
+ framework: context.framework,
7830
+ context,
7831
+ version: "1.1.6"
7832
+ });
7833
+ if (hbResult && hbResult.data && hbResult.data.pending_writes_count > 0) {
7834
+ const pollResult = await sendCloudRelayRequest("GET", `/api/v1/bridge/poll-writes?pair_code=${PAIR_CODE}`);
7835
+ const tasks = pollResult.data && pollResult.data.pending_tasks || [];
7836
+ for (const task of tasks) {
7837
+ const written = [];
7838
+ for (const file of task.files || []) {
7839
+ const fullPath = import_path2.default.join(PROJECT_ROOT, file.path);
7840
+ await fs2.mkdir(import_path2.default.dirname(fullPath), { recursive: true });
7841
+ await fs2.writeFile(fullPath, file.content, "utf8");
7842
+ console.log(` [bridge] Wrote ${file.path}`);
7843
+ written.push(file.path);
7844
+ }
7845
+ await sendCloudRelayRequest("POST", "/api/v1/bridge/complete-write", {
7846
+ task_id: task.task_id,
7847
+ success: true,
7848
+ written,
7849
+ message: `Wrote ${written.length} file(s) directly to ${import_path2.default.basename(PROJECT_ROOT)}`
7850
+ });
7851
+ }
7852
+ }
7853
+ } catch {
7854
+ }
7855
+ }, 3500);
7769
7856
  }
7770
7857
  var isDirectRun = Boolean(typeof process !== "undefined" && process.argv && process.argv[1] && (process.argv[1].endsWith("bridge.js") || process.argv[1].endsWith("bridge")));
7771
7858
  if (isDirectRun) {
@@ -7776,7 +7863,6 @@ if (isDirectRun) {
7776
7863
  var _a;
7777
7864
  // @__NO_SIDE_EFFECTS__
7778
7865
  function $constructor(name, initializer3, params) {
7779
- var _a5;
7780
7866
  function init(inst, def) {
7781
7867
  if (!inst._zod) {
7782
7868
  Object.defineProperty(inst, "_zod", {
@@ -7802,16 +7888,15 @@ function $constructor(name, initializer3, params) {
7802
7888
  }
7803
7889
  }
7804
7890
  }
7805
- const Parent = (_a5 = params == null ? void 0 : params.Parent) != null ? _a5 : Object;
7891
+ const Parent = params?.Parent ?? Object;
7806
7892
  class Definition extends Parent {
7807
7893
  }
7808
7894
  Object.defineProperty(Definition, "name", { value: name });
7809
7895
  function _(def) {
7810
- var _a7;
7811
- var _a6;
7812
- const inst = (params == null ? void 0 : params.Parent) ? new Definition() : this;
7896
+ var _a3;
7897
+ const inst = params?.Parent ? new Definition() : this;
7813
7898
  init(inst, def);
7814
- (_a7 = (_a6 = inst._zod).deferred) != null ? _a7 : _a6.deferred = [];
7899
+ (_a3 = inst._zod).deferred ?? (_a3.deferred = []);
7815
7900
  for (const fn of inst._zod.deferred) {
7816
7901
  fn();
7817
7902
  }
@@ -7820,10 +7905,9 @@ function $constructor(name, initializer3, params) {
7820
7905
  Object.defineProperty(_, "init", { value: init });
7821
7906
  Object.defineProperty(_, Symbol.hasInstance, {
7822
7907
  value: (inst) => {
7823
- var _a6, _b;
7824
- if ((params == null ? void 0 : params.Parent) && inst instanceof params.Parent)
7908
+ if (params?.Parent && inst instanceof params.Parent)
7825
7909
  return true;
7826
- return (_b = (_a6 = inst == null ? void 0 : inst._zod) == null ? void 0 : _a6.traits) == null ? void 0 : _b.has(name);
7910
+ return inst?._zod?.traits?.has(name);
7827
7911
  }
7828
7912
  });
7829
7913
  Object.defineProperty(_, "name", { value: name });
@@ -7840,8 +7924,7 @@ var $ZodEncodeError = class extends Error {
7840
7924
  this.name = "ZodEncodeError";
7841
7925
  }
7842
7926
  };
7843
- var _a2;
7844
- (_a2 = (_a = globalThis).__zod_globalConfig) != null ? _a2 : _a.__zod_globalConfig = {};
7927
+ (_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
7845
7928
  var globalConfig = globalThis.__zod_globalConfig;
7846
7929
  function config(newConfig) {
7847
7930
  if (newConfig)
@@ -8019,7 +8102,7 @@ function cloneDef(schema) {
8019
8102
  function getElementAtPath(obj, path4) {
8020
8103
  if (!path4)
8021
8104
  return obj;
8022
- return path4.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
8105
+ return path4.reduce((acc, key) => acc?.[key], obj);
8023
8106
  }
8024
8107
  function promiseAllObject(promisesObj) {
8025
8108
  const keys = Object.keys(promisesObj);
@@ -8052,11 +8135,10 @@ function isObject(data) {
8052
8135
  return typeof data === "object" && data !== null && !Array.isArray(data);
8053
8136
  }
8054
8137
  var allowsEval = /* @__PURE__ */ cached(() => {
8055
- var _a5;
8056
8138
  if (globalConfig.jitless) {
8057
8139
  return false;
8058
8140
  }
8059
- if (typeof navigator !== "undefined" && ((_a5 = navigator == null ? void 0 : navigator.userAgent) == null ? void 0 : _a5.includes("Cloudflare"))) {
8141
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
8060
8142
  return false;
8061
8143
  }
8062
8144
  try {
@@ -8160,8 +8242,8 @@ function escapeRegex(str) {
8160
8242
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
8161
8243
  }
8162
8244
  function clone(inst, def, params) {
8163
- const cl = new inst._zod.constr(def != null ? def : inst._zod.def);
8164
- if (!def || (params == null ? void 0 : params.parent))
8245
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
8246
+ if (!def || params?.parent)
8165
8247
  cl._zod.parent = inst;
8166
8248
  return cl;
8167
8249
  }
@@ -8171,8 +8253,8 @@ function normalizeParams(_params) {
8171
8253
  return {};
8172
8254
  if (typeof params === "string")
8173
8255
  return { error: () => params };
8174
- if ((params == null ? void 0 : params.message) !== void 0) {
8175
- if ((params == null ? void 0 : params.error) !== void 0)
8256
+ if (params?.message !== void 0) {
8257
+ if (params?.error !== void 0)
8176
8258
  throw new Error("Cannot specify both `message` and `error` params");
8177
8259
  params.error = params.message;
8178
8260
  }
@@ -8185,31 +8267,31 @@ function createTransparentProxy(getter) {
8185
8267
  let target;
8186
8268
  return new Proxy({}, {
8187
8269
  get(_, prop, receiver) {
8188
- target != null ? target : target = getter();
8270
+ target ?? (target = getter());
8189
8271
  return Reflect.get(target, prop, receiver);
8190
8272
  },
8191
8273
  set(_, prop, value, receiver) {
8192
- target != null ? target : target = getter();
8274
+ target ?? (target = getter());
8193
8275
  return Reflect.set(target, prop, value, receiver);
8194
8276
  },
8195
8277
  has(_, prop) {
8196
- target != null ? target : target = getter();
8278
+ target ?? (target = getter());
8197
8279
  return Reflect.has(target, prop);
8198
8280
  },
8199
8281
  deleteProperty(_, prop) {
8200
- target != null ? target : target = getter();
8282
+ target ?? (target = getter());
8201
8283
  return Reflect.deleteProperty(target, prop);
8202
8284
  },
8203
8285
  ownKeys(_) {
8204
- target != null ? target : target = getter();
8286
+ target ?? (target = getter());
8205
8287
  return Reflect.ownKeys(target);
8206
8288
  },
8207
8289
  getOwnPropertyDescriptor(_, prop) {
8208
- target != null ? target : target = getter();
8290
+ target ?? (target = getter());
8209
8291
  return Reflect.getOwnPropertyDescriptor(target, prop);
8210
8292
  },
8211
8293
  defineProperty(_, prop, descriptor) {
8212
- target != null ? target : target = getter();
8294
+ target ?? (target = getter());
8213
8295
  return Reflect.defineProperty(target, prop, descriptor);
8214
8296
  }
8215
8297
  });
@@ -8324,8 +8406,7 @@ function safeExtend(schema, shape) {
8324
8406
  return clone(schema, def);
8325
8407
  }
8326
8408
  function merge(a, b) {
8327
- var _a5, _b;
8328
- if ((_a5 = a._zod.def.checks) == null ? void 0 : _a5.length) {
8409
+ if (a._zod.def.checks?.length) {
8329
8410
  throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
8330
8411
  }
8331
8412
  const def = mergeDefs(a._zod.def, {
@@ -8337,7 +8418,7 @@ function merge(a, b) {
8337
8418
  get catchall() {
8338
8419
  return b._zod.def.catchall;
8339
8420
  },
8340
- checks: (_b = b._zod.def.checks) != null ? _b : []
8421
+ checks: b._zod.def.checks ?? []
8341
8422
  });
8342
8423
  return clone(a, def);
8343
8424
  }
@@ -8411,22 +8492,20 @@ function required(Class2, schema, mask) {
8411
8492
  return clone(schema, def);
8412
8493
  }
8413
8494
  function aborted(x, startIndex = 0) {
8414
- var _a5;
8415
8495
  if (x.aborted === true)
8416
8496
  return true;
8417
8497
  for (let i = startIndex; i < x.issues.length; i++) {
8418
- if (((_a5 = x.issues[i]) == null ? void 0 : _a5.continue) !== true) {
8498
+ if (x.issues[i]?.continue !== true) {
8419
8499
  return true;
8420
8500
  }
8421
8501
  }
8422
8502
  return false;
8423
8503
  }
8424
8504
  function explicitlyAborted(x, startIndex = 0) {
8425
- var _a5;
8426
8505
  if (x.aborted === true)
8427
8506
  return true;
8428
8507
  for (let i = startIndex; i < x.issues.length; i++) {
8429
- if (((_a5 = x.issues[i]) == null ? void 0 : _a5.continue) === false) {
8508
+ if (x.issues[i]?.continue === false) {
8430
8509
  return true;
8431
8510
  }
8432
8511
  }
@@ -8434,23 +8513,21 @@ function explicitlyAborted(x, startIndex = 0) {
8434
8513
  }
8435
8514
  function prefixIssues(path4, issues) {
8436
8515
  return issues.map((iss) => {
8437
- var _a6;
8438
- var _a5;
8439
- (_a6 = (_a5 = iss).path) != null ? _a6 : _a5.path = [];
8516
+ var _a3;
8517
+ (_a3 = iss).path ?? (_a3.path = []);
8440
8518
  iss.path.unshift(path4);
8441
8519
  return iss;
8442
8520
  });
8443
8521
  }
8444
8522
  function unwrapMessage(message) {
8445
- return typeof message === "string" ? message : message == null ? void 0 : message.message;
8523
+ return typeof message === "string" ? message : message?.message;
8446
8524
  }
8447
8525
  function finalizeIssue(iss, ctx, config2) {
8448
- var _a5, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
8449
- const message = iss.message ? iss.message : (_j = (_i = (_g = (_e = unwrapMessage((_c = (_b = (_a5 = iss.inst) == null ? void 0 : _a5._zod.def) == null ? void 0 : _b.error) == null ? void 0 : _c.call(_b, iss))) != null ? _e : unwrapMessage((_d = ctx == null ? void 0 : ctx.error) == null ? void 0 : _d.call(ctx, iss))) != null ? _g : unwrapMessage((_f = config2.customError) == null ? void 0 : _f.call(config2, iss))) != null ? _i : unwrapMessage((_h = config2.localeError) == null ? void 0 : _h.call(config2, iss))) != null ? _j : "Invalid input";
8526
+ const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
8450
8527
  const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
8451
- (_k = rest.path) != null ? _k : rest.path = [];
8528
+ rest.path ?? (rest.path = []);
8452
8529
  rest.message = message;
8453
- if (ctx == null ? void 0 : ctx.reportInput) {
8530
+ if (ctx?.reportInput) {
8454
8531
  rest.input = _input;
8455
8532
  }
8456
8533
  return rest;
@@ -8622,28 +8699,26 @@ function formatError(error2, mapper = (issue2) => issue2.message) {
8622
8699
 
8623
8700
  // node_modules/zod/v4/core/parse.js
8624
8701
  var _parse = (_Err) => (schema, value, _ctx, _params) => {
8625
- var _a5;
8626
8702
  const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
8627
8703
  const result = schema._zod.run({ value, issues: [] }, ctx);
8628
8704
  if (result instanceof Promise) {
8629
8705
  throw new $ZodAsyncError();
8630
8706
  }
8631
8707
  if (result.issues.length) {
8632
- const e = new ((_a5 = _params == null ? void 0 : _params.Err) != null ? _a5 : _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
8633
- captureStackTrace(e, _params == null ? void 0 : _params.callee);
8708
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
8709
+ captureStackTrace(e, _params?.callee);
8634
8710
  throw e;
8635
8711
  }
8636
8712
  return result.value;
8637
8713
  };
8638
8714
  var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
8639
- var _a5;
8640
8715
  const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
8641
8716
  let result = schema._zod.run({ value, issues: [] }, ctx);
8642
8717
  if (result instanceof Promise)
8643
8718
  result = await result;
8644
8719
  if (result.issues.length) {
8645
- const e = new ((_a5 = params == null ? void 0 : params.Err) != null ? _a5 : _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
8646
- captureStackTrace(e, params == null ? void 0 : params.callee);
8720
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
8721
+ captureStackTrace(e, params?.callee);
8647
8722
  throw e;
8648
8723
  }
8649
8724
  return result.value;
@@ -8656,7 +8731,7 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
8656
8731
  }
8657
8732
  return result.issues.length ? {
8658
8733
  success: false,
8659
- error: new (_Err != null ? _Err : $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
8734
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
8660
8735
  } : { success: true, data: result.value };
8661
8736
  };
8662
8737
  var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
@@ -8748,8 +8823,7 @@ function datetime(args) {
8748
8823
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
8749
8824
  }
8750
8825
  var string = (params) => {
8751
- var _a5, _b;
8752
- const regex = params ? `[\\s\\S]{${(_a5 = params == null ? void 0 : params.minimum) != null ? _a5 : 0},${(_b = params == null ? void 0 : params.maximum) != null ? _b : ""}}` : `[\\s\\S]*`;
8826
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
8753
8827
  return new RegExp(`^${regex}$`);
8754
8828
  };
8755
8829
  var integer = /^-?\d+$/;
@@ -8761,11 +8835,10 @@ var uppercase = /^[^a-z]*$/;
8761
8835
 
8762
8836
  // node_modules/zod/v4/core/checks.js
8763
8837
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
8764
- var _a6, _b;
8765
- var _a5;
8766
- (_a6 = inst._zod) != null ? _a6 : inst._zod = {};
8838
+ var _a3;
8839
+ inst._zod ?? (inst._zod = {});
8767
8840
  inst._zod.def = def;
8768
- (_b = (_a5 = inst._zod).onattach) != null ? _b : _a5.onattach = [];
8841
+ (_a3 = inst._zod).onattach ?? (_a3.onattach = []);
8769
8842
  });
8770
8843
  var numericOriginMap = {
8771
8844
  number: "number",
@@ -8776,9 +8849,8 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
8776
8849
  $ZodCheck.init(inst, def);
8777
8850
  const origin = numericOriginMap[typeof def.value];
8778
8851
  inst._zod.onattach.push((inst2) => {
8779
- var _a5;
8780
8852
  const bag = inst2._zod.bag;
8781
- const curr = (_a5 = def.inclusive ? bag.maximum : bag.exclusiveMaximum) != null ? _a5 : Number.POSITIVE_INFINITY;
8853
+ const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
8782
8854
  if (def.value < curr) {
8783
8855
  if (def.inclusive)
8784
8856
  bag.maximum = def.value;
@@ -8805,9 +8877,8 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
8805
8877
  $ZodCheck.init(inst, def);
8806
8878
  const origin = numericOriginMap[typeof def.value];
8807
8879
  inst._zod.onattach.push((inst2) => {
8808
- var _a5;
8809
8880
  const bag = inst2._zod.bag;
8810
- const curr = (_a5 = def.inclusive ? bag.minimum : bag.exclusiveMinimum) != null ? _a5 : Number.NEGATIVE_INFINITY;
8881
+ const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
8811
8882
  if (def.value > curr) {
8812
8883
  if (def.inclusive)
8813
8884
  bag.minimum = def.value;
@@ -8833,9 +8904,8 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
8833
8904
  var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
8834
8905
  $ZodCheck.init(inst, def);
8835
8906
  inst._zod.onattach.push((inst2) => {
8836
- var _a6;
8837
- var _a5;
8838
- (_a6 = (_a5 = inst2._zod.bag).multipleOf) != null ? _a6 : _a5.multipleOf = def.value;
8907
+ var _a3;
8908
+ (_a3 = inst2._zod.bag).multipleOf ?? (_a3.multipleOf = def.value);
8839
8909
  });
8840
8910
  inst._zod.check = (payload) => {
8841
8911
  if (typeof payload.value !== typeof def.value)
@@ -8854,10 +8924,9 @@ var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (i
8854
8924
  };
8855
8925
  });
8856
8926
  var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
8857
- var _a5;
8858
8927
  $ZodCheck.init(inst, def);
8859
8928
  def.format = def.format || "float64";
8860
- const isInt = (_a5 = def.format) == null ? void 0 : _a5.includes("int");
8929
+ const isInt = def.format?.includes("int");
8861
8930
  const origin = isInt ? "int" : "number";
8862
8931
  const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
8863
8932
  inst._zod.onattach.push((inst2) => {
@@ -8934,16 +9003,14 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
8934
9003
  };
8935
9004
  });
8936
9005
  var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
8937
- var _a6;
8938
- var _a5;
9006
+ var _a3;
8939
9007
  $ZodCheck.init(inst, def);
8940
- (_a6 = (_a5 = inst._zod.def).when) != null ? _a6 : _a5.when = (payload) => {
9008
+ (_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
8941
9009
  const val = payload.value;
8942
9010
  return !nullish(val) && val.length !== void 0;
8943
- };
9011
+ });
8944
9012
  inst._zod.onattach.push((inst2) => {
8945
- var _a7;
8946
- const curr = (_a7 = inst2._zod.bag.maximum) != null ? _a7 : Number.POSITIVE_INFINITY;
9013
+ const curr = inst2._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
8947
9014
  if (def.maximum < curr)
8948
9015
  inst2._zod.bag.maximum = def.maximum;
8949
9016
  });
@@ -8965,16 +9032,14 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
8965
9032
  };
8966
9033
  });
8967
9034
  var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
8968
- var _a6;
8969
- var _a5;
9035
+ var _a3;
8970
9036
  $ZodCheck.init(inst, def);
8971
- (_a6 = (_a5 = inst._zod.def).when) != null ? _a6 : _a5.when = (payload) => {
9037
+ (_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
8972
9038
  const val = payload.value;
8973
9039
  return !nullish(val) && val.length !== void 0;
8974
- };
9040
+ });
8975
9041
  inst._zod.onattach.push((inst2) => {
8976
- var _a7;
8977
- const curr = (_a7 = inst2._zod.bag.minimum) != null ? _a7 : Number.NEGATIVE_INFINITY;
9042
+ const curr = inst2._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
8978
9043
  if (def.minimum > curr)
8979
9044
  inst2._zod.bag.minimum = def.minimum;
8980
9045
  });
@@ -8996,13 +9061,12 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
8996
9061
  };
8997
9062
  });
8998
9063
  var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
8999
- var _a6;
9000
- var _a5;
9064
+ var _a3;
9001
9065
  $ZodCheck.init(inst, def);
9002
- (_a6 = (_a5 = inst._zod.def).when) != null ? _a6 : _a5.when = (payload) => {
9066
+ (_a3 = inst._zod.def).when ?? (_a3.when = (payload) => {
9003
9067
  const val = payload.value;
9004
9068
  return !nullish(val) && val.length !== void 0;
9005
- };
9069
+ });
9006
9070
  inst._zod.onattach.push((inst2) => {
9007
9071
  const bag = inst2._zod.bag;
9008
9072
  bag.minimum = def.length;
@@ -9028,20 +9092,18 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
9028
9092
  };
9029
9093
  });
9030
9094
  var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
9031
- var _a6, _b2;
9032
- var _a5, _b;
9095
+ var _a3, _b;
9033
9096
  $ZodCheck.init(inst, def);
9034
9097
  inst._zod.onattach.push((inst2) => {
9035
- var _a7;
9036
9098
  const bag = inst2._zod.bag;
9037
9099
  bag.format = def.format;
9038
9100
  if (def.pattern) {
9039
- (_a7 = bag.patterns) != null ? _a7 : bag.patterns = /* @__PURE__ */ new Set();
9101
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
9040
9102
  bag.patterns.add(def.pattern);
9041
9103
  }
9042
9104
  });
9043
9105
  if (def.pattern)
9044
- (_a6 = (_a5 = inst._zod).check) != null ? _a6 : _a5.check = (payload) => {
9106
+ (_a3 = inst._zod).check ?? (_a3.check = (payload) => {
9045
9107
  def.pattern.lastIndex = 0;
9046
9108
  if (def.pattern.test(payload.value))
9047
9109
  return;
@@ -9054,10 +9116,10 @@ var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat"
9054
9116
  inst,
9055
9117
  continue: !def.abort
9056
9118
  });
9057
- };
9119
+ });
9058
9120
  else
9059
- (_b2 = (_b = inst._zod).check) != null ? _b2 : _b.check = () => {
9060
- };
9121
+ (_b = inst._zod).check ?? (_b.check = () => {
9122
+ });
9061
9123
  });
9062
9124
  var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
9063
9125
  $ZodCheckStringFormat.init(inst, def);
@@ -9077,13 +9139,11 @@ var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def)
9077
9139
  };
9078
9140
  });
9079
9141
  var $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
9080
- var _a5;
9081
- (_a5 = def.pattern) != null ? _a5 : def.pattern = lowercase;
9142
+ def.pattern ?? (def.pattern = lowercase);
9082
9143
  $ZodCheckStringFormat.init(inst, def);
9083
9144
  });
9084
9145
  var $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
9085
- var _a5;
9086
- (_a5 = def.pattern) != null ? _a5 : def.pattern = uppercase;
9146
+ def.pattern ?? (def.pattern = uppercase);
9087
9147
  $ZodCheckStringFormat.init(inst, def);
9088
9148
  });
9089
9149
  var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
@@ -9092,9 +9152,8 @@ var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst,
9092
9152
  const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
9093
9153
  def.pattern = pattern;
9094
9154
  inst._zod.onattach.push((inst2) => {
9095
- var _a5;
9096
9155
  const bag = inst2._zod.bag;
9097
- (_a5 = bag.patterns) != null ? _a5 : bag.patterns = /* @__PURE__ */ new Set();
9156
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
9098
9157
  bag.patterns.add(pattern);
9099
9158
  });
9100
9159
  inst._zod.check = (payload) => {
@@ -9112,14 +9171,12 @@ var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst,
9112
9171
  };
9113
9172
  });
9114
9173
  var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
9115
- var _a5;
9116
9174
  $ZodCheck.init(inst, def);
9117
9175
  const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
9118
- (_a5 = def.pattern) != null ? _a5 : def.pattern = pattern;
9176
+ def.pattern ?? (def.pattern = pattern);
9119
9177
  inst._zod.onattach.push((inst2) => {
9120
- var _a6;
9121
9178
  const bag = inst2._zod.bag;
9122
- (_a6 = bag.patterns) != null ? _a6 : bag.patterns = /* @__PURE__ */ new Set();
9179
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
9123
9180
  bag.patterns.add(pattern);
9124
9181
  });
9125
9182
  inst._zod.check = (payload) => {
@@ -9137,14 +9194,12 @@ var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (i
9137
9194
  };
9138
9195
  });
9139
9196
  var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
9140
- var _a5;
9141
9197
  $ZodCheck.init(inst, def);
9142
9198
  const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
9143
- (_a5 = def.pattern) != null ? _a5 : def.pattern = pattern;
9199
+ def.pattern ?? (def.pattern = pattern);
9144
9200
  inst._zod.onattach.push((inst2) => {
9145
- var _a6;
9146
9201
  const bag = inst2._zod.bag;
9147
- (_a6 = bag.patterns) != null ? _a6 : bag.patterns = /* @__PURE__ */ new Set();
9202
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
9148
9203
  bag.patterns.add(pattern);
9149
9204
  });
9150
9205
  inst._zod.check = (payload) => {
@@ -9196,10 +9251,9 @@ var Doc = class {
9196
9251
  }
9197
9252
  }
9198
9253
  compile() {
9199
- var _a5;
9200
9254
  const F = Function;
9201
- const args = this == null ? void 0 : this.args;
9202
- const content = (_a5 = this == null ? void 0 : this.content) != null ? _a5 : [``];
9255
+ const args = this?.args;
9256
+ const content = this?.content ?? [``];
9203
9257
  const lines = [...content.map((x) => ` ${x}`)];
9204
9258
  return new F(...args, lines.join("\n"));
9205
9259
  }
@@ -9214,13 +9268,12 @@ var version = {
9214
9268
 
9215
9269
  // node_modules/zod/v4/core/schemas.js
9216
9270
  var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
9217
- var _a6, _b, _c;
9218
- var _a5;
9219
- inst != null ? inst : inst = {};
9271
+ var _a3;
9272
+ inst ?? (inst = {});
9220
9273
  inst._zod.def = def;
9221
9274
  inst._zod.bag = inst._zod.bag || {};
9222
9275
  inst._zod.version = version;
9223
- const checks = [...(_a6 = inst._zod.def.checks) != null ? _a6 : []];
9276
+ const checks = [...inst._zod.def.checks ?? []];
9224
9277
  if (inst._zod.traits.has("$ZodCheck")) {
9225
9278
  checks.unshift(inst);
9226
9279
  }
@@ -9230,8 +9283,8 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
9230
9283
  }
9231
9284
  }
9232
9285
  if (checks.length === 0) {
9233
- (_b = (_a5 = inst._zod).deferred) != null ? _b : _a5.deferred = [];
9234
- (_c = inst._zod.deferred) == null ? void 0 : _c.push(() => {
9286
+ (_a3 = inst._zod).deferred ?? (_a3.deferred = []);
9287
+ inst._zod.deferred?.push(() => {
9235
9288
  inst._zod.run = inst._zod.parse;
9236
9289
  });
9237
9290
  } else {
@@ -9250,11 +9303,11 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
9250
9303
  }
9251
9304
  const currLen = payload.issues.length;
9252
9305
  const _ = ch._zod.check(payload);
9253
- if (_ instanceof Promise && (ctx == null ? void 0 : ctx.async) === false) {
9306
+ if (_ instanceof Promise && ctx?.async === false) {
9254
9307
  throw new $ZodAsyncError();
9255
9308
  }
9256
9309
  if (asyncResult || _ instanceof Promise) {
9257
- asyncResult = (asyncResult != null ? asyncResult : Promise.resolve()).then(async () => {
9310
+ asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
9258
9311
  await _;
9259
9312
  const nextLen = payload.issues.length;
9260
9313
  if (nextLen === currLen)
@@ -9314,15 +9367,11 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
9314
9367
  }
9315
9368
  defineLazy(inst, "~standard", () => ({
9316
9369
  validate: (value) => {
9317
- var _a7;
9318
9370
  try {
9319
9371
  const r = safeParse(inst, value);
9320
- return r.success ? { value: r.data } : { issues: (_a7 = r.error) == null ? void 0 : _a7.issues };
9372
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
9321
9373
  } catch (_) {
9322
- return safeParseAsync(inst, value).then((r) => {
9323
- var _a8;
9324
- return r.success ? { value: r.data } : { issues: (_a8 = r.error) == null ? void 0 : _a8.issues };
9325
- });
9374
+ return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
9326
9375
  }
9327
9376
  },
9328
9377
  vendor: "zod",
@@ -9330,9 +9379,8 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
9330
9379
  }));
9331
9380
  });
9332
9381
  var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
9333
- var _a5, _b, _c;
9334
9382
  $ZodType.init(inst, def);
9335
- inst._zod.pattern = (_c = [...(_b = (_a5 = inst == null ? void 0 : inst._zod.bag) == null ? void 0 : _a5.patterns) != null ? _b : []].pop()) != null ? _c : string(inst._zod.bag);
9383
+ inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
9336
9384
  inst._zod.parse = (payload, _) => {
9337
9385
  if (def.coerce)
9338
9386
  try {
@@ -9355,12 +9403,10 @@ var $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, d
9355
9403
  $ZodString.init(inst, def);
9356
9404
  });
9357
9405
  var $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
9358
- var _a5;
9359
- (_a5 = def.pattern) != null ? _a5 : def.pattern = guid;
9406
+ def.pattern ?? (def.pattern = guid);
9360
9407
  $ZodStringFormat.init(inst, def);
9361
9408
  });
9362
9409
  var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
9363
- var _a5, _b;
9364
9410
  if (def.version) {
9365
9411
  const versionMap = {
9366
9412
  v1: 1,
@@ -9375,23 +9421,21 @@ var $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
9375
9421
  const v = versionMap[def.version];
9376
9422
  if (v === void 0)
9377
9423
  throw new Error(`Invalid UUID version: "${def.version}"`);
9378
- (_a5 = def.pattern) != null ? _a5 : def.pattern = uuid(v);
9424
+ def.pattern ?? (def.pattern = uuid(v));
9379
9425
  } else
9380
- (_b = def.pattern) != null ? _b : def.pattern = uuid();
9426
+ def.pattern ?? (def.pattern = uuid());
9381
9427
  $ZodStringFormat.init(inst, def);
9382
9428
  });
9383
9429
  var $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
9384
- var _a5;
9385
- (_a5 = def.pattern) != null ? _a5 : def.pattern = email;
9430
+ def.pattern ?? (def.pattern = email);
9386
9431
  $ZodStringFormat.init(inst, def);
9387
9432
  });
9388
9433
  var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
9389
9434
  $ZodStringFormat.init(inst, def);
9390
9435
  inst._zod.check = (payload) => {
9391
- var _a5;
9392
9436
  try {
9393
9437
  const trimmed = payload.value.trim();
9394
- if (!def.normalize && ((_a5 = def.protocol) == null ? void 0 : _a5.source) === httpProtocol.source) {
9438
+ if (!def.normalize && def.protocol?.source === httpProtocol.source) {
9395
9439
  if (!/^https?:\/\//i.test(trimmed)) {
9396
9440
  payload.issues.push({
9397
9441
  code: "invalid_format",
@@ -9451,69 +9495,56 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
9451
9495
  };
9452
9496
  });
9453
9497
  var $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
9454
- var _a5;
9455
- (_a5 = def.pattern) != null ? _a5 : def.pattern = emoji();
9498
+ def.pattern ?? (def.pattern = emoji());
9456
9499
  $ZodStringFormat.init(inst, def);
9457
9500
  });
9458
9501
  var $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
9459
- var _a5;
9460
- (_a5 = def.pattern) != null ? _a5 : def.pattern = nanoid;
9502
+ def.pattern ?? (def.pattern = nanoid);
9461
9503
  $ZodStringFormat.init(inst, def);
9462
9504
  });
9463
9505
  var $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
9464
- var _a5;
9465
- (_a5 = def.pattern) != null ? _a5 : def.pattern = cuid;
9506
+ def.pattern ?? (def.pattern = cuid);
9466
9507
  $ZodStringFormat.init(inst, def);
9467
9508
  });
9468
9509
  var $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
9469
- var _a5;
9470
- (_a5 = def.pattern) != null ? _a5 : def.pattern = cuid2;
9510
+ def.pattern ?? (def.pattern = cuid2);
9471
9511
  $ZodStringFormat.init(inst, def);
9472
9512
  });
9473
9513
  var $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
9474
- var _a5;
9475
- (_a5 = def.pattern) != null ? _a5 : def.pattern = ulid;
9514
+ def.pattern ?? (def.pattern = ulid);
9476
9515
  $ZodStringFormat.init(inst, def);
9477
9516
  });
9478
9517
  var $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
9479
- var _a5;
9480
- (_a5 = def.pattern) != null ? _a5 : def.pattern = xid;
9518
+ def.pattern ?? (def.pattern = xid);
9481
9519
  $ZodStringFormat.init(inst, def);
9482
9520
  });
9483
9521
  var $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
9484
- var _a5;
9485
- (_a5 = def.pattern) != null ? _a5 : def.pattern = ksuid;
9522
+ def.pattern ?? (def.pattern = ksuid);
9486
9523
  $ZodStringFormat.init(inst, def);
9487
9524
  });
9488
9525
  var $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
9489
- var _a5;
9490
- (_a5 = def.pattern) != null ? _a5 : def.pattern = datetime(def);
9526
+ def.pattern ?? (def.pattern = datetime(def));
9491
9527
  $ZodStringFormat.init(inst, def);
9492
9528
  });
9493
9529
  var $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
9494
- var _a5;
9495
- (_a5 = def.pattern) != null ? _a5 : def.pattern = date;
9530
+ def.pattern ?? (def.pattern = date);
9496
9531
  $ZodStringFormat.init(inst, def);
9497
9532
  });
9498
9533
  var $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
9499
- var _a5;
9500
- (_a5 = def.pattern) != null ? _a5 : def.pattern = time(def);
9534
+ def.pattern ?? (def.pattern = time(def));
9501
9535
  $ZodStringFormat.init(inst, def);
9502
9536
  });
9503
9537
  var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
9504
- var _a5;
9505
- (_a5 = def.pattern) != null ? _a5 : def.pattern = duration;
9538
+ def.pattern ?? (def.pattern = duration);
9506
9539
  $ZodStringFormat.init(inst, def);
9507
9540
  });
9508
9541
  var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
9509
- var _a5;
9510
- (_a5 = def.pattern) != null ? _a5 : def.pattern = ipv4;
9542
+ def.pattern ?? (def.pattern = ipv4);
9511
9543
  $ZodStringFormat.init(inst, def);
9512
9544
  inst._zod.bag.format = `ipv4`;
9513
9545
  });
9514
9546
  var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
9515
- var _a5;
9516
- (_a5 = def.pattern) != null ? _a5 : def.pattern = ipv6;
9547
+ def.pattern ?? (def.pattern = ipv6);
9517
9548
  $ZodStringFormat.init(inst, def);
9518
9549
  inst._zod.bag.format = `ipv6`;
9519
9550
  inst._zod.check = (payload) => {
@@ -9531,13 +9562,11 @@ var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
9531
9562
  };
9532
9563
  });
9533
9564
  var $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
9534
- var _a5;
9535
- (_a5 = def.pattern) != null ? _a5 : def.pattern = cidrv4;
9565
+ def.pattern ?? (def.pattern = cidrv4);
9536
9566
  $ZodStringFormat.init(inst, def);
9537
9567
  });
9538
9568
  var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
9539
- var _a5;
9540
- (_a5 = def.pattern) != null ? _a5 : def.pattern = cidrv6;
9569
+ def.pattern ?? (def.pattern = cidrv6);
9541
9570
  $ZodStringFormat.init(inst, def);
9542
9571
  inst._zod.check = (payload) => {
9543
9572
  const parts = payload.value.split("/");
@@ -9579,8 +9608,7 @@ function isValidBase64(data) {
9579
9608
  }
9580
9609
  }
9581
9610
  var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
9582
- var _a5;
9583
- (_a5 = def.pattern) != null ? _a5 : def.pattern = base64;
9611
+ def.pattern ?? (def.pattern = base64);
9584
9612
  $ZodStringFormat.init(inst, def);
9585
9613
  inst._zod.bag.contentEncoding = "base64";
9586
9614
  inst._zod.check = (payload) => {
@@ -9603,8 +9631,7 @@ function isValidBase64URL(data) {
9603
9631
  return isValidBase64(padded);
9604
9632
  }
9605
9633
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
9606
- var _a5;
9607
- (_a5 = def.pattern) != null ? _a5 : def.pattern = base64url;
9634
+ def.pattern ?? (def.pattern = base64url);
9608
9635
  $ZodStringFormat.init(inst, def);
9609
9636
  inst._zod.bag.contentEncoding = "base64url";
9610
9637
  inst._zod.check = (payload) => {
@@ -9620,8 +9647,7 @@ var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) =>
9620
9647
  };
9621
9648
  });
9622
9649
  var $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
9623
- var _a5;
9624
- (_a5 = def.pattern) != null ? _a5 : def.pattern = e164;
9650
+ def.pattern ?? (def.pattern = e164);
9625
9651
  $ZodStringFormat.init(inst, def);
9626
9652
  });
9627
9653
  function isValidJWT(token, algorithm = null) {
@@ -9633,7 +9659,7 @@ function isValidJWT(token, algorithm = null) {
9633
9659
  if (!header)
9634
9660
  return false;
9635
9661
  const parsedHeader = JSON.parse(atob(header));
9636
- if ("typ" in parsedHeader && (parsedHeader == null ? void 0 : parsedHeader.typ) !== "JWT")
9662
+ if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
9637
9663
  return false;
9638
9664
  if (!parsedHeader.alg)
9639
9665
  return false;
@@ -9659,9 +9685,8 @@ var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
9659
9685
  };
9660
9686
  });
9661
9687
  var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
9662
- var _a5;
9663
9688
  $ZodType.init(inst, def);
9664
- inst._zod.pattern = (_a5 = inst._zod.bag.pattern) != null ? _a5 : number;
9689
+ inst._zod.pattern = inst._zod.bag.pattern ?? number;
9665
9690
  inst._zod.parse = (payload, _ctx) => {
9666
9691
  if (def.coerce)
9667
9692
  try {
@@ -9808,10 +9833,9 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
9808
9833
  }
9809
9834
  }
9810
9835
  function normalizeDef(def) {
9811
- var _a5, _b, _c, _d;
9812
9836
  const keys = Object.keys(def.shape);
9813
9837
  for (const k of keys) {
9814
- if (!((_d = (_c = (_b = (_a5 = def.shape) == null ? void 0 : _a5[k]) == null ? void 0 : _b._zod) == null ? void 0 : _c.traits) == null ? void 0 : _d.has("$ZodType"))) {
9838
+ if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
9815
9839
  throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
9816
9840
  }
9817
9841
  }
@@ -9864,7 +9888,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
9864
9888
  var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
9865
9889
  $ZodType.init(inst, def);
9866
9890
  const desc = Object.getOwnPropertyDescriptor(def, "shape");
9867
- if (!(desc == null ? void 0 : desc.get)) {
9891
+ if (!desc?.get) {
9868
9892
  const sh = def.shape;
9869
9893
  Object.defineProperty(def, "shape", {
9870
9894
  get: () => {
@@ -9878,13 +9902,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
9878
9902
  }
9879
9903
  const _normalized = cached(() => normalizeDef(def));
9880
9904
  defineLazy(inst._zod, "propValues", () => {
9881
- var _a5;
9882
9905
  const shape = def.shape;
9883
9906
  const propValues = {};
9884
9907
  for (const key in shape) {
9885
9908
  const field = shape[key]._zod;
9886
9909
  if (field.values) {
9887
- (_a5 = propValues[key]) != null ? _a5 : propValues[key] = /* @__PURE__ */ new Set();
9910
+ propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
9888
9911
  for (const v of field.values)
9889
9912
  propValues[key].add(v);
9890
9913
  }
@@ -9895,7 +9918,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
9895
9918
  const catchall = def.catchall;
9896
9919
  let value;
9897
9920
  inst._zod.parse = (payload, ctx) => {
9898
- value != null ? value : value = _normalized.value;
9921
+ value ?? (value = _normalized.value);
9899
9922
  const input = payload.value;
9900
9923
  if (!isObject2(input)) {
9901
9924
  payload.issues.push({
@@ -9931,7 +9954,6 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
9931
9954
  const superParse = inst._zod.parse;
9932
9955
  const _normalized = cached(() => normalizeDef(def));
9933
9956
  const generateFastpass = (shape) => {
9934
- var _a5, _b;
9935
9957
  const doc = new Doc(["shape", "payload", "ctx"]);
9936
9958
  const normalized = _normalized.value;
9937
9959
  const parseStr = (key) => {
@@ -9949,8 +9971,8 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
9949
9971
  const id = ids[key];
9950
9972
  const k = esc(key);
9951
9973
  const schema = shape[key];
9952
- const isOptionalIn = ((_a5 = schema == null ? void 0 : schema._zod) == null ? void 0 : _a5.optin) === "optional";
9953
- const isOptionalOut = ((_b = schema == null ? void 0 : schema._zod) == null ? void 0 : _b.optout) === "optional";
9974
+ const isOptionalIn = schema?._zod?.optin === "optional";
9975
+ const isOptionalOut = schema?._zod?.optout === "optional";
9954
9976
  doc.write(`const ${id} = ${parseStr(key)};`);
9955
9977
  if (isOptionalIn && isOptionalOut) {
9956
9978
  doc.write(`
@@ -10032,7 +10054,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
10032
10054
  const catchall = def.catchall;
10033
10055
  let value;
10034
10056
  inst._zod.parse = (payload, ctx) => {
10035
- value != null ? value : value = _normalized.value;
10057
+ value ?? (value = _normalized.value);
10036
10058
  const input = payload.value;
10037
10059
  if (!isObject2(input)) {
10038
10060
  payload.issues.push({
@@ -10043,7 +10065,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
10043
10065
  });
10044
10066
  return payload;
10045
10067
  }
10046
- if (jit && fastEnabled && (ctx == null ? void 0 : ctx.async) === false && ctx.jitless !== true) {
10068
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
10047
10069
  if (!fastpass)
10048
10070
  fastpass = generateFastpass(def.shape);
10049
10071
  payload = fastpass(payload, ctx);
@@ -10140,11 +10162,10 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
10140
10162
  return propValues;
10141
10163
  });
10142
10164
  const disc = cached(() => {
10143
- var _a5;
10144
10165
  const opts = def.options;
10145
10166
  const map = /* @__PURE__ */ new Map();
10146
10167
  for (const o of opts) {
10147
- const values = (_a5 = o._zod.propValues) == null ? void 0 : _a5[def.discriminator];
10168
+ const values = o._zod.propValues?.[def.discriminator];
10148
10169
  if (!values || values.size === 0)
10149
10170
  throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
10150
10171
  for (const v of values) {
@@ -10167,7 +10188,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
10167
10188
  });
10168
10189
  return payload;
10169
10190
  }
10170
- const opt = disc.value.get(input == null ? void 0 : input[def.discriminator]);
10191
+ const opt = disc.value.get(input?.[def.discriminator]);
10171
10192
  if (opt) {
10172
10193
  return opt._zod.run(payload, ctx);
10173
10194
  }
@@ -10251,7 +10272,7 @@ function handleIntersectionResults(result, left, right) {
10251
10272
  let unrecIssue;
10252
10273
  for (const iss of left.issues) {
10253
10274
  if (iss.code === "unrecognized_keys") {
10254
- unrecIssue != null ? unrecIssue : unrecIssue = iss;
10275
+ unrecIssue ?? (unrecIssue = iss);
10255
10276
  for (const k of iss.keys) {
10256
10277
  if (!unrecKeys.has(k))
10257
10278
  unrecKeys.set(k, {});
@@ -10341,7 +10362,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10341
10362
  let unrecognized;
10342
10363
  for (const key in input) {
10343
10364
  if (!recordKeys.has(key)) {
10344
- unrecognized = unrecognized != null ? unrecognized : [];
10365
+ unrecognized = unrecognized ?? [];
10345
10366
  unrecognized.push(key);
10346
10367
  }
10347
10368
  }
@@ -10674,14 +10695,8 @@ var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
10674
10695
  $ZodType.init(inst, def);
10675
10696
  defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
10676
10697
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
10677
- defineLazy(inst._zod, "optin", () => {
10678
- var _a5, _b;
10679
- return (_b = (_a5 = def.innerType) == null ? void 0 : _a5._zod) == null ? void 0 : _b.optin;
10680
- });
10681
- defineLazy(inst._zod, "optout", () => {
10682
- var _a5, _b;
10683
- return (_b = (_a5 = def.innerType) == null ? void 0 : _a5._zod) == null ? void 0 : _b.optout;
10684
- });
10698
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
10699
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
10685
10700
  inst._zod.parse = (payload, ctx) => {
10686
10701
  if (ctx.direction === "backward") {
10687
10702
  return def.innerType._zod.run(payload, ctx);
@@ -10714,14 +10729,13 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
10714
10729
  };
10715
10730
  });
10716
10731
  function handleRefineResult(result, payload, input, inst) {
10717
- var _a5;
10718
10732
  if (!result) {
10719
10733
  const _iss = {
10720
10734
  code: "custom",
10721
10735
  input,
10722
10736
  inst,
10723
10737
  // incorporates params.error into issue reporting
10724
- path: [...(_a5 = inst._zod.def.path) != null ? _a5 : []],
10738
+ path: [...inst._zod.def.path ?? []],
10725
10739
  // incorporates params.error into issue reporting
10726
10740
  continue: !inst._zod.def.abort
10727
10741
  // params: inst._zod.def.params,
@@ -10742,8 +10756,7 @@ var error = () => {
10742
10756
  map: { unit: "entries", verb: "to have" }
10743
10757
  };
10744
10758
  function getSizing(origin) {
10745
- var _a5;
10746
- return (_a5 = Sizable[origin]) != null ? _a5 : null;
10759
+ return Sizable[origin] ?? null;
10747
10760
  }
10748
10761
  const FormatDictionary = {
10749
10762
  regex: "input",
@@ -10782,12 +10795,11 @@ var error = () => {
10782
10795
  // All other type names omitted - they fall back to raw values via ?? operator
10783
10796
  };
10784
10797
  return (issue2) => {
10785
- var _a5, _b, _c, _d, _e, _f;
10786
10798
  switch (issue2.code) {
10787
10799
  case "invalid_type": {
10788
- const expected = (_a5 = TypeDictionary[issue2.expected]) != null ? _a5 : issue2.expected;
10800
+ const expected = TypeDictionary[issue2.expected] ?? issue2.expected;
10789
10801
  const receivedType = parsedType(issue2.input);
10790
- const received = (_b = TypeDictionary[receivedType]) != null ? _b : receivedType;
10802
+ const received = TypeDictionary[receivedType] ?? receivedType;
10791
10803
  return `Invalid input: expected ${expected}, received ${received}`;
10792
10804
  }
10793
10805
  case "invalid_value":
@@ -10798,8 +10810,8 @@ var error = () => {
10798
10810
  const adj = issue2.inclusive ? "<=" : "<";
10799
10811
  const sizing = getSizing(issue2.origin);
10800
10812
  if (sizing)
10801
- return `Too big: expected ${(_c = issue2.origin) != null ? _c : "value"} to have ${adj}${issue2.maximum.toString()} ${(_d = sizing.unit) != null ? _d : "elements"}`;
10802
- return `Too big: expected ${(_e = issue2.origin) != null ? _e : "value"} to be ${adj}${issue2.maximum.toString()}`;
10813
+ return `Too big: expected ${issue2.origin ?? "value"} to have ${adj}${issue2.maximum.toString()} ${sizing.unit ?? "elements"}`;
10814
+ return `Too big: expected ${issue2.origin ?? "value"} to be ${adj}${issue2.maximum.toString()}`;
10803
10815
  }
10804
10816
  case "too_small": {
10805
10817
  const adj = issue2.inclusive ? ">=" : ">";
@@ -10820,7 +10832,7 @@ var error = () => {
10820
10832
  return `Invalid string: must include "${_issue.includes}"`;
10821
10833
  if (_issue.format === "regex")
10822
10834
  return `Invalid string: must match pattern ${_issue.pattern}`;
10823
- return `Invalid ${(_f = FormatDictionary[_issue.format]) != null ? _f : issue2.format}`;
10835
+ return `Invalid ${FormatDictionary[_issue.format] ?? issue2.format}`;
10824
10836
  }
10825
10837
  case "not_multiple_of":
10826
10838
  return `Invalid number: must be a multiple of ${issue2.divisor}`;
@@ -10848,7 +10860,7 @@ function en_default() {
10848
10860
  }
10849
10861
 
10850
10862
  // node_modules/zod/v4/core/registries.js
10851
- var _a3;
10863
+ var _a2;
10852
10864
  var $ZodRegistry = class {
10853
10865
  constructor() {
10854
10866
  this._map = /* @__PURE__ */ new WeakMap();
@@ -10876,10 +10888,9 @@ var $ZodRegistry = class {
10876
10888
  return this;
10877
10889
  }
10878
10890
  get(schema) {
10879
- var _a5;
10880
10891
  const p = schema._zod.parent;
10881
10892
  if (p) {
10882
- const pm = { ...(_a5 = this.get(p)) != null ? _a5 : {} };
10893
+ const pm = { ...this.get(p) ?? {} };
10883
10894
  delete pm.id;
10884
10895
  const f = { ...pm, ...this._map.get(schema) };
10885
10896
  return Object.keys(f).length ? f : void 0;
@@ -10893,8 +10904,7 @@ var $ZodRegistry = class {
10893
10904
  function registry() {
10894
10905
  return new $ZodRegistry();
10895
10906
  }
10896
- var _a4;
10897
- (_a4 = (_a3 = globalThis).__zod_globalRegistry) != null ? _a4 : _a3.__zod_globalRegistry = registry();
10907
+ (_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
10898
10908
  var globalRegistry = globalThis.__zod_globalRegistry;
10899
10909
 
10900
10910
  // node_modules/zod/v4/core/api.js
@@ -11374,9 +11384,8 @@ function _array(Class2, element, params) {
11374
11384
  }
11375
11385
  // @__NO_SIDE_EFFECTS__
11376
11386
  function _custom(Class2, fn, _params) {
11377
- var _a5;
11378
11387
  const norm = normalizeParams(_params);
11379
- (_a5 = norm.abort) != null ? _a5 : norm.abort = true;
11388
+ norm.abort ?? (norm.abort = true);
11380
11389
  const schema = new Class2({
11381
11390
  type: "custom",
11382
11391
  check: "custom",
@@ -11399,17 +11408,16 @@ function _refine(Class2, fn, _params) {
11399
11408
  function _superRefine(fn, params) {
11400
11409
  const ch = /* @__PURE__ */ _check((payload) => {
11401
11410
  payload.addIssue = (issue2) => {
11402
- var _a5, _b, _c, _d;
11403
11411
  if (typeof issue2 === "string") {
11404
11412
  payload.issues.push(issue(issue2, payload.value, ch._zod.def));
11405
11413
  } else {
11406
11414
  const _issue = issue2;
11407
11415
  if (_issue.fatal)
11408
11416
  _issue.continue = false;
11409
- (_a5 = _issue.code) != null ? _a5 : _issue.code = "custom";
11410
- (_b = _issue.input) != null ? _b : _issue.input = payload.value;
11411
- (_c = _issue.inst) != null ? _c : _issue.inst = ch;
11412
- (_d = _issue.continue) != null ? _d : _issue.continue = !ch._zod.def.abort;
11417
+ _issue.code ?? (_issue.code = "custom");
11418
+ _issue.input ?? (_issue.input = payload.value);
11419
+ _issue.inst ?? (_issue.inst = ch);
11420
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
11413
11421
  payload.issues.push(issue(_issue));
11414
11422
  }
11415
11423
  };
@@ -11429,30 +11437,28 @@ function _check(fn, params) {
11429
11437
 
11430
11438
  // node_modules/zod/v4/core/to-json-schema.js
11431
11439
  function initializeContext(params) {
11432
- var _a5, _b, _c, _d, _e, _f, _g, _h, _i;
11433
- let target = (_a5 = params == null ? void 0 : params.target) != null ? _a5 : "draft-2020-12";
11440
+ let target = params?.target ?? "draft-2020-12";
11434
11441
  if (target === "draft-4")
11435
11442
  target = "draft-04";
11436
11443
  if (target === "draft-7")
11437
11444
  target = "draft-07";
11438
11445
  return {
11439
- processors: (_b = params.processors) != null ? _b : {},
11440
- metadataRegistry: (_c = params == null ? void 0 : params.metadata) != null ? _c : globalRegistry,
11446
+ processors: params.processors ?? {},
11447
+ metadataRegistry: params?.metadata ?? globalRegistry,
11441
11448
  target,
11442
- unrepresentable: (_d = params == null ? void 0 : params.unrepresentable) != null ? _d : "throw",
11443
- override: (_e = params == null ? void 0 : params.override) != null ? _e : (() => {
11449
+ unrepresentable: params?.unrepresentable ?? "throw",
11450
+ override: params?.override ?? (() => {
11444
11451
  }),
11445
- io: (_f = params == null ? void 0 : params.io) != null ? _f : "output",
11452
+ io: params?.io ?? "output",
11446
11453
  counter: 0,
11447
11454
  seen: /* @__PURE__ */ new Map(),
11448
- cycles: (_g = params == null ? void 0 : params.cycles) != null ? _g : "ref",
11449
- reused: (_h = params == null ? void 0 : params.reused) != null ? _h : "inline",
11450
- external: (_i = params == null ? void 0 : params.external) != null ? _i : void 0
11455
+ cycles: params?.cycles ?? "ref",
11456
+ reused: params?.reused ?? "inline",
11457
+ external: params?.external ?? void 0
11451
11458
  };
11452
11459
  }
11453
11460
  function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
11454
- var _a6, _b, _c;
11455
- var _a5;
11461
+ var _a3;
11456
11462
  const def = schema._zod.def;
11457
11463
  const seen = ctx.seen.get(schema);
11458
11464
  if (seen) {
@@ -11465,7 +11471,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
11465
11471
  }
11466
11472
  const result = { schema: {}, count: 1, cycle: void 0, path: _params.path };
11467
11473
  ctx.seen.set(schema, result);
11468
- const overrideSchema = (_b = (_a6 = schema._zod).toJSONSchema) == null ? void 0 : _b.call(_a6);
11474
+ const overrideSchema = schema._zod.toJSONSchema?.();
11469
11475
  if (overrideSchema) {
11470
11476
  result.schema = overrideSchema;
11471
11477
  } else {
@@ -11500,19 +11506,18 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
11500
11506
  delete result.schema.default;
11501
11507
  }
11502
11508
  if (ctx.io === "input" && "_prefault" in result.schema)
11503
- (_c = (_a5 = result.schema).default) != null ? _c : _a5.default = result.schema._prefault;
11509
+ (_a3 = result.schema).default ?? (_a3.default = result.schema._prefault);
11504
11510
  delete result.schema._prefault;
11505
11511
  const _result = ctx.seen.get(schema);
11506
11512
  return _result.schema;
11507
11513
  }
11508
11514
  function extractDefs(ctx, schema) {
11509
- var _a5, _b, _c, _d;
11510
11515
  const root = ctx.seen.get(schema);
11511
11516
  if (!root)
11512
11517
  throw new Error("Unprocessed schema. This is a bug in Zod.");
11513
11518
  const idToSchema = /* @__PURE__ */ new Map();
11514
11519
  for (const entry of ctx.seen.entries()) {
11515
- const id = (_a5 = ctx.metadataRegistry.get(entry[0])) == null ? void 0 : _a5.id;
11520
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
11516
11521
  if (id) {
11517
11522
  const existing = idToSchema.get(id);
11518
11523
  if (existing && existing !== entry[0]) {
@@ -11522,15 +11527,14 @@ function extractDefs(ctx, schema) {
11522
11527
  }
11523
11528
  }
11524
11529
  const makeURI = (entry) => {
11525
- var _a6, _b2, _c2, _d2, _e;
11526
11530
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
11527
11531
  if (ctx.external) {
11528
- const externalId = (_a6 = ctx.external.registry.get(entry[0])) == null ? void 0 : _a6.id;
11529
- const uriGenerator = (_b2 = ctx.external.uri) != null ? _b2 : ((id2) => id2);
11532
+ const externalId = ctx.external.registry.get(entry[0])?.id;
11533
+ const uriGenerator = ctx.external.uri ?? ((id2) => id2);
11530
11534
  if (externalId) {
11531
11535
  return { ref: uriGenerator(externalId) };
11532
11536
  }
11533
- const id = (_d2 = (_c2 = entry[1].defId) != null ? _c2 : entry[1].schema.id) != null ? _d2 : `schema${ctx.counter++}`;
11537
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
11534
11538
  entry[1].defId = id;
11535
11539
  return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
11536
11540
  }
@@ -11539,7 +11543,7 @@ function extractDefs(ctx, schema) {
11539
11543
  }
11540
11544
  const uriPrefix = `#`;
11541
11545
  const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
11542
- const defId = (_e = entry[1].schema.id) != null ? _e : `__schema${ctx.counter++}`;
11546
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
11543
11547
  return { defId, ref: defUriPrefix + defId };
11544
11548
  };
11545
11549
  const extractToDef = (entry) => {
@@ -11561,7 +11565,7 @@ function extractDefs(ctx, schema) {
11561
11565
  for (const entry of ctx.seen.entries()) {
11562
11566
  const seen = entry[1];
11563
11567
  if (seen.cycle) {
11564
- throw new Error(`Cycle detected: #/${(_b = seen.cycle) == null ? void 0 : _b.join("/")}/<root>
11568
+ throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
11565
11569
 
11566
11570
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
11567
11571
  }
@@ -11574,13 +11578,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11574
11578
  continue;
11575
11579
  }
11576
11580
  if (ctx.external) {
11577
- const ext = (_c = ctx.external.registry.get(entry[0])) == null ? void 0 : _c.id;
11581
+ const ext = ctx.external.registry.get(entry[0])?.id;
11578
11582
  if (schema !== entry[0] && ext) {
11579
11583
  extractToDef(entry);
11580
11584
  continue;
11581
11585
  }
11582
11586
  }
11583
- const id = (_d = ctx.metadataRegistry.get(entry[0])) == null ? void 0 : _d.id;
11587
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
11584
11588
  if (id) {
11585
11589
  extractToDef(entry);
11586
11590
  continue;
@@ -11598,16 +11602,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11598
11602
  }
11599
11603
  }
11600
11604
  function finalize(ctx, schema) {
11601
- var _a5, _b, _c, _d, _e, _f;
11602
11605
  const root = ctx.seen.get(schema);
11603
11606
  if (!root)
11604
11607
  throw new Error("Unprocessed schema. This is a bug in Zod.");
11605
11608
  const flattenRef = (zodSchema) => {
11606
- var _a6, _b2, _c2;
11607
11609
  const seen = ctx.seen.get(zodSchema);
11608
11610
  if (seen.ref === null)
11609
11611
  return;
11610
- const schema2 = (_a6 = seen.def) != null ? _a6 : seen.schema;
11612
+ const schema2 = seen.def ?? seen.schema;
11611
11613
  const _cached = { ...schema2 };
11612
11614
  const ref = seen.ref;
11613
11615
  seen.ref = null;
@@ -11616,7 +11618,7 @@ function finalize(ctx, schema) {
11616
11618
  const refSeen = ctx.seen.get(ref);
11617
11619
  const refSchema = refSeen.schema;
11618
11620
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
11619
- schema2.allOf = (_b2 = schema2.allOf) != null ? _b2 : [];
11621
+ schema2.allOf = schema2.allOf ?? [];
11620
11622
  schema2.allOf.push(refSchema);
11621
11623
  } else {
11622
11624
  Object.assign(schema2, refSchema);
@@ -11646,7 +11648,7 @@ function finalize(ctx, schema) {
11646
11648
  if (parent && parent !== ref) {
11647
11649
  flattenRef(parent);
11648
11650
  const parentSeen = ctx.seen.get(parent);
11649
- if (parentSeen == null ? void 0 : parentSeen.schema.$ref) {
11651
+ if (parentSeen?.schema.$ref) {
11650
11652
  schema2.$ref = parentSeen.schema.$ref;
11651
11653
  if (parentSeen.def) {
11652
11654
  for (const key in schema2) {
@@ -11662,7 +11664,7 @@ function finalize(ctx, schema) {
11662
11664
  ctx.override({
11663
11665
  zodSchema,
11664
11666
  jsonSchema: schema2,
11665
- path: (_c2 = seen.path) != null ? _c2 : []
11667
+ path: seen.path ?? []
11666
11668
  });
11667
11669
  };
11668
11670
  for (const entry of [...ctx.seen.entries()].reverse()) {
@@ -11678,17 +11680,17 @@ function finalize(ctx, schema) {
11678
11680
  } else if (ctx.target === "openapi-3.0") {
11679
11681
  } else {
11680
11682
  }
11681
- if ((_a5 = ctx.external) == null ? void 0 : _a5.uri) {
11682
- const id = (_b = ctx.external.registry.get(schema)) == null ? void 0 : _b.id;
11683
+ if (ctx.external?.uri) {
11684
+ const id = ctx.external.registry.get(schema)?.id;
11683
11685
  if (!id)
11684
11686
  throw new Error("Schema is missing an `id` property");
11685
11687
  result.$id = ctx.external.uri(id);
11686
11688
  }
11687
- Object.assign(result, (_c = root.def) != null ? _c : root.schema);
11688
- const rootMetaId = (_d = ctx.metadataRegistry.get(schema)) == null ? void 0 : _d.id;
11689
+ Object.assign(result, root.def ?? root.schema);
11690
+ const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
11689
11691
  if (rootMetaId !== void 0 && result.id === rootMetaId)
11690
11692
  delete result.id;
11691
- const defs = (_f = (_e = ctx.external) == null ? void 0 : _e.defs) != null ? _f : {};
11693
+ const defs = ctx.external?.defs ?? {};
11692
11694
  for (const entry of ctx.seen.entries()) {
11693
11695
  const seen = entry[1];
11694
11696
  if (seen.def && seen.defId) {
@@ -11726,7 +11728,7 @@ function finalize(ctx, schema) {
11726
11728
  }
11727
11729
  }
11728
11730
  function isTransforming(_schema, _ctx) {
11729
- const ctx = _ctx != null ? _ctx : { seen: /* @__PURE__ */ new Set() };
11731
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
11730
11732
  if (ctx.seen.has(_schema))
11731
11733
  return false;
11732
11734
  ctx.seen.add(_schema);
@@ -11785,8 +11787,8 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
11785
11787
  return finalize(ctx, schema);
11786
11788
  };
11787
11789
  var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
11788
- const { libraryOptions, target } = params != null ? params : {};
11789
- const ctx = initializeContext({ ...libraryOptions != null ? libraryOptions : {}, target, io, processors });
11790
+ const { libraryOptions, target } = params ?? {};
11791
+ const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
11790
11792
  process2(schema, ctx);
11791
11793
  extractDefs(ctx, schema);
11792
11794
  return finalize(ctx, schema);
@@ -11802,7 +11804,6 @@ var formatMap = {
11802
11804
  // do not set
11803
11805
  };
11804
11806
  var stringProcessor = (schema, ctx, _json, _params) => {
11805
- var _a5;
11806
11807
  const json = _json;
11807
11808
  json.type = "string";
11808
11809
  const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
@@ -11811,7 +11812,7 @@ var stringProcessor = (schema, ctx, _json, _params) => {
11811
11812
  if (typeof maximum === "number")
11812
11813
  json.maxLength = maximum;
11813
11814
  if (format) {
11814
- json.format = (_a5 = formatMap[format]) != null ? _a5 : format;
11815
+ json.format = formatMap[format] ?? format;
11815
11816
  if (json.format === "")
11816
11817
  delete json.format;
11817
11818
  if (format === "time") {
@@ -11841,8 +11842,8 @@ var numberProcessor = (schema, ctx, _json, _params) => {
11841
11842
  json.type = "integer";
11842
11843
  else
11843
11844
  json.type = "number";
11844
- const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum != null ? minimum : Number.NEGATIVE_INFINITY);
11845
- const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum != null ? maximum : Number.POSITIVE_INFINITY);
11845
+ const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
11846
+ const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
11846
11847
  const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
11847
11848
  if (exMin) {
11848
11849
  if (legacy) {
@@ -11958,7 +11959,6 @@ var arrayProcessor = (schema, ctx, _json, params) => {
11958
11959
  });
11959
11960
  };
11960
11961
  var objectProcessor = (schema, ctx, _json, params) => {
11961
- var _a5;
11962
11962
  const json = _json;
11963
11963
  const def = schema._zod.def;
11964
11964
  json.type = "object";
@@ -11982,7 +11982,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
11982
11982
  if (requiredKeys.size > 0) {
11983
11983
  json.required = Array.from(requiredKeys);
11984
11984
  }
11985
- if (((_a5 = def.catchall) == null ? void 0 : _a5._zod.def.type) === "never") {
11985
+ if (def.catchall?._zod.def.type === "never") {
11986
11986
  json.additionalProperties = false;
11987
11987
  } else if (!def.catchall) {
11988
11988
  if (ctx.io === "output")
@@ -12030,7 +12030,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
12030
12030
  json.type = "object";
12031
12031
  const keyType = def.keyType;
12032
12032
  const keyBag = keyType._zod.bag;
12033
- const patterns = keyBag == null ? void 0 : keyBag.patterns;
12033
+ const patterns = keyBag?.patterns;
12034
12034
  if (def.mode === "loose" && patterns && patterns.size > 0) {
12035
12035
  const valueSchema = process2(def.valueType, ctx, {
12036
12036
  ...params,
@@ -12142,13 +12142,12 @@ function safeParse2(schema, data) {
12142
12142
  return result;
12143
12143
  }
12144
12144
  function getObjectShape(schema) {
12145
- var _a5, _b;
12146
12145
  if (!schema)
12147
12146
  return void 0;
12148
12147
  let rawShape;
12149
12148
  if (isZ4Schema(schema)) {
12150
12149
  const v4Schema = schema;
12151
- rawShape = (_b = (_a5 = v4Schema._zod) == null ? void 0 : _a5.def) == null ? void 0 : _b.shape;
12150
+ rawShape = v4Schema._zod?.def?.shape;
12152
12151
  } else {
12153
12152
  const v3Schema = schema;
12154
12153
  rawShape = v3Schema.shape;
@@ -12165,10 +12164,9 @@ function getObjectShape(schema) {
12165
12164
  return rawShape;
12166
12165
  }
12167
12166
  function getLiteralValue(schema) {
12168
- var _a5;
12169
12167
  if (isZ4Schema(schema)) {
12170
12168
  const v4Schema = schema;
12171
- const def2 = (_a5 = v4Schema._zod) == null ? void 0 : _a5.def;
12169
+ const def2 = v4Schema._zod?.def;
12172
12170
  if (def2) {
12173
12171
  if (def2.value !== void 0)
12174
12172
  return def2.value;
@@ -12351,11 +12349,10 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
12351
12349
  inst.safeDecodeAsync = async (data, params) => safeDecodeAsync2(inst, data, params);
12352
12350
  _installLazyMethods(inst, "ZodType", {
12353
12351
  check(...chks) {
12354
- var _a5;
12355
12352
  const def2 = this.def;
12356
12353
  return this.clone(util_exports.mergeDefs(def2, {
12357
12354
  checks: [
12358
- ...(_a5 = def2.checks) != null ? _a5 : [],
12355
+ ...def2.checks ?? [],
12359
12356
  ...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
12360
12357
  ]
12361
12358
  }), { parent: true });
@@ -12448,22 +12445,20 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
12448
12445
  });
12449
12446
  Object.defineProperty(inst, "description", {
12450
12447
  get() {
12451
- var _a5;
12452
- return (_a5 = globalRegistry.get(inst)) == null ? void 0 : _a5.description;
12448
+ return globalRegistry.get(inst)?.description;
12453
12449
  },
12454
12450
  configurable: true
12455
12451
  });
12456
12452
  return inst;
12457
12453
  });
12458
12454
  var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
12459
- var _a5, _b, _c;
12460
12455
  $ZodString.init(inst, def);
12461
12456
  ZodType.init(inst, def);
12462
12457
  inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
12463
12458
  const bag = inst._zod.bag;
12464
- inst.format = (_a5 = bag.format) != null ? _a5 : null;
12465
- inst.minLength = (_b = bag.minimum) != null ? _b : null;
12466
- inst.maxLength = (_c = bag.maximum) != null ? _c : null;
12459
+ inst.format = bag.format ?? null;
12460
+ inst.minLength = bag.minimum ?? null;
12461
+ inst.maxLength = bag.maximum ?? null;
12467
12462
  _installLazyMethods(inst, "_ZodString", {
12468
12463
  regex(...args) {
12469
12464
  return this.check(_regex(...args));
@@ -12627,7 +12622,6 @@ var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
12627
12622
  ZodStringFormat.init(inst, def);
12628
12623
  });
12629
12624
  var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
12630
- var _a5, _b, _c, _d, _e, _f, _g, _h, _i;
12631
12625
  $ZodNumber.init(inst, def);
12632
12626
  ZodType.init(inst, def);
12633
12627
  inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
@@ -12679,11 +12673,11 @@ var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
12679
12673
  }
12680
12674
  });
12681
12675
  const bag = inst._zod.bag;
12682
- inst.minValue = (_c = Math.max((_a5 = bag.minimum) != null ? _a5 : Number.NEGATIVE_INFINITY, (_b = bag.exclusiveMinimum) != null ? _b : Number.NEGATIVE_INFINITY)) != null ? _c : null;
12683
- inst.maxValue = (_f = Math.min((_d = bag.maximum) != null ? _d : Number.POSITIVE_INFINITY, (_e = bag.exclusiveMaximum) != null ? _e : Number.POSITIVE_INFINITY)) != null ? _f : null;
12684
- inst.isInt = ((_g = bag.format) != null ? _g : "").includes("int") || Number.isSafeInteger((_h = bag.multipleOf) != null ? _h : 0.5);
12676
+ inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
12677
+ inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
12678
+ inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
12685
12679
  inst.isFinite = true;
12686
- inst.format = (_i = bag.format) != null ? _i : null;
12680
+ inst.format = bag.format ?? null;
12687
12681
  });
12688
12682
  function number2(params) {
12689
12683
  return _number(ZodNumber, params);
@@ -12805,7 +12799,7 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
12805
12799
  function object2(shape, params) {
12806
12800
  const def = {
12807
12801
  type: "object",
12808
- shape: shape != null ? shape : {},
12802
+ shape: shape ?? {},
12809
12803
  ...util_exports.normalizeParams(params)
12810
12804
  };
12811
12805
  return new ZodObject(def);
@@ -12954,16 +12948,15 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
12954
12948
  throw new $ZodEncodeError(inst.constructor.name);
12955
12949
  }
12956
12950
  payload.addIssue = (issue2) => {
12957
- var _a5, _b, _c;
12958
12951
  if (typeof issue2 === "string") {
12959
12952
  payload.issues.push(util_exports.issue(issue2, payload.value, def));
12960
12953
  } else {
12961
12954
  const _issue = issue2;
12962
12955
  if (_issue.fatal)
12963
12956
  _issue.continue = false;
12964
- (_a5 = _issue.code) != null ? _a5 : _issue.code = "custom";
12965
- (_b = _issue.input) != null ? _b : _issue.input = payload.value;
12966
- (_c = _issue.inst) != null ? _c : _issue.inst = inst;
12957
+ _issue.code ?? (_issue.code = "custom");
12958
+ _issue.input ?? (_issue.input = payload.value);
12959
+ _issue.inst ?? (_issue.inst = inst);
12967
12960
  payload.issues.push(util_exports.issue(_issue));
12968
12961
  }
12969
12962
  };
@@ -13117,7 +13110,7 @@ var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
13117
13110
  inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
13118
13111
  });
13119
13112
  function custom(fn, _params) {
13120
- return _custom(ZodCustom, fn != null ? fn : (() => true), _params);
13113
+ return _custom(ZodCustom, fn ?? (() => true), _params);
13121
13114
  }
13122
13115
  function refine(fn, _params = {}) {
13123
13116
  return _refine(ZodCustom, fn, _params);
@@ -14651,8 +14644,7 @@ var UrlElicitationRequiredError = class extends McpError {
14651
14644
  });
14652
14645
  }
14653
14646
  get elicitations() {
14654
- var _a5, _b;
14655
- return (_b = (_a5 = this.data) == null ? void 0 : _a5.elicitations) != null ? _b : [];
14647
+ return this.data?.elicitations ?? [];
14656
14648
  }
14657
14649
  };
14658
14650
 
@@ -14667,7 +14659,7 @@ var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0
14667
14659
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
14668
14660
  function getMethodLiteral(schema) {
14669
14661
  const shape = getObjectShape(schema);
14670
- const methodSchema = shape == null ? void 0 : shape.method;
14662
+ const methodSchema = shape?.method;
14671
14663
  if (!methodSchema) {
14672
14664
  throw new Error("Schema is missing a method literal");
14673
14665
  }
@@ -14711,8 +14703,8 @@ var Protocol = class {
14711
14703
  // Automatic pong by default.
14712
14704
  (_request) => ({})
14713
14705
  );
14714
- this._taskStore = _options == null ? void 0 : _options.taskStore;
14715
- this._taskMessageQueue = _options == null ? void 0 : _options.taskMessageQueue;
14706
+ this._taskStore = _options?.taskStore;
14707
+ this._taskMessageQueue = _options?.taskMessageQueue;
14716
14708
  if (this._taskStore) {
14717
14709
  this.setRequestHandler(GetTaskRequestSchema, async (request, extra) => {
14718
14710
  const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
@@ -14725,7 +14717,6 @@ var Protocol = class {
14725
14717
  });
14726
14718
  this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
14727
14719
  const handleTaskResult = async () => {
14728
- var _a5;
14729
14720
  const taskId = request.params.taskId;
14730
14721
  if (this._taskMessageQueue) {
14731
14722
  let queuedMessage;
@@ -14749,7 +14740,7 @@ var Protocol = class {
14749
14740
  }
14750
14741
  continue;
14751
14742
  }
14752
- await ((_a5 = this._transport) == null ? void 0 : _a5.send(queuedMessage.message, { relatedRequestId: extra.requestId }));
14743
+ await this._transport?.send(queuedMessage.message, { relatedRequestId: extra.requestId });
14753
14744
  }
14754
14745
  }
14755
14746
  const task = await this._taskStore.getTask(taskId, extra.sessionId);
@@ -14778,9 +14769,8 @@ var Protocol = class {
14778
14769
  return await handleTaskResult();
14779
14770
  });
14780
14771
  this.setRequestHandler(ListTasksRequestSchema, async (request, extra) => {
14781
- var _a5;
14782
14772
  try {
14783
- const { tasks, nextCursor } = await this._taskStore.listTasks((_a5 = request.params) == null ? void 0 : _a5.cursor, extra.sessionId);
14773
+ const { tasks, nextCursor } = await this._taskStore.listTasks(request.params?.cursor, extra.sessionId);
14784
14774
  return {
14785
14775
  tasks,
14786
14776
  nextCursor,
@@ -14823,7 +14813,7 @@ var Protocol = class {
14823
14813
  return;
14824
14814
  }
14825
14815
  const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
14826
- controller == null ? void 0 : controller.abort(notification.params.reason);
14816
+ controller?.abort(notification.params.reason);
14827
14817
  }
14828
14818
  _setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
14829
14819
  this._timeoutInfo.set(messageId, {
@@ -14864,24 +14854,23 @@ var Protocol = class {
14864
14854
  * The Protocol object assumes ownership of the Transport, replacing any callbacks that have already been set, and expects that it is the only user of the Transport instance going forward.
14865
14855
  */
14866
14856
  async connect(transport) {
14867
- var _a5, _b, _c;
14868
14857
  if (this._transport) {
14869
14858
  throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");
14870
14859
  }
14871
14860
  this._transport = transport;
14872
- const _onclose = (_a5 = this.transport) == null ? void 0 : _a5.onclose;
14861
+ const _onclose = this.transport?.onclose;
14873
14862
  this._transport.onclose = () => {
14874
- _onclose == null ? void 0 : _onclose();
14863
+ _onclose?.();
14875
14864
  this._onclose();
14876
14865
  };
14877
- const _onerror = (_b = this.transport) == null ? void 0 : _b.onerror;
14866
+ const _onerror = this.transport?.onerror;
14878
14867
  this._transport.onerror = (error2) => {
14879
- _onerror == null ? void 0 : _onerror(error2);
14868
+ _onerror?.(error2);
14880
14869
  this._onerror(error2);
14881
14870
  };
14882
- const _onmessage = (_c = this._transport) == null ? void 0 : _c.onmessage;
14871
+ const _onmessage = this._transport?.onmessage;
14883
14872
  this._transport.onmessage = (message, extra) => {
14884
- _onmessage == null ? void 0 : _onmessage(message, extra);
14873
+ _onmessage?.(message, extra);
14885
14874
  if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
14886
14875
  this._onresponse(message);
14887
14876
  } else if (isJSONRPCRequest(message)) {
@@ -14895,7 +14884,6 @@ var Protocol = class {
14895
14884
  await this._transport.start();
14896
14885
  }
14897
14886
  _onclose() {
14898
- var _a5;
14899
14887
  const responseHandlers = this._responseHandlers;
14900
14888
  this._responseHandlers = /* @__PURE__ */ new Map();
14901
14889
  this._progressHandlers.clear();
@@ -14911,28 +14899,25 @@ var Protocol = class {
14911
14899
  this._requestHandlerAbortControllers.clear();
14912
14900
  const error2 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
14913
14901
  this._transport = void 0;
14914
- (_a5 = this.onclose) == null ? void 0 : _a5.call(this);
14902
+ this.onclose?.();
14915
14903
  for (const handler of responseHandlers.values()) {
14916
14904
  handler(error2);
14917
14905
  }
14918
14906
  }
14919
14907
  _onerror(error2) {
14920
- var _a5;
14921
- (_a5 = this.onerror) == null ? void 0 : _a5.call(this, error2);
14908
+ this.onerror?.(error2);
14922
14909
  }
14923
14910
  _onnotification(notification) {
14924
- var _a5;
14925
- const handler = (_a5 = this._notificationHandlers.get(notification.method)) != null ? _a5 : this.fallbackNotificationHandler;
14911
+ const handler = this._notificationHandlers.get(notification.method) ?? this.fallbackNotificationHandler;
14926
14912
  if (handler === void 0) {
14927
14913
  return;
14928
14914
  }
14929
14915
  Promise.resolve().then(() => handler(notification)).catch((error2) => this._onerror(new Error(`Uncaught error in notification handler: ${error2}`)));
14930
14916
  }
14931
14917
  _onrequest(request, extra) {
14932
- var _a5, _b, _c, _d, _e;
14933
- const handler = (_a5 = this._requestHandlers.get(request.method)) != null ? _a5 : this.fallbackRequestHandler;
14918
+ const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
14934
14919
  const capturedTransport = this._transport;
14935
- const relatedTaskId = (_d = (_c = (_b = request.params) == null ? void 0 : _b._meta) == null ? void 0 : _c[RELATED_TASK_META_KEY]) == null ? void 0 : _d.taskId;
14920
+ const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
14936
14921
  if (handler === void 0) {
14937
14922
  const errorResponse = {
14938
14923
  jsonrpc: "2.0",
@@ -14947,20 +14932,20 @@ var Protocol = class {
14947
14932
  type: "error",
14948
14933
  message: errorResponse,
14949
14934
  timestamp: Date.now()
14950
- }, capturedTransport == null ? void 0 : capturedTransport.sessionId).catch((error2) => this._onerror(new Error(`Failed to enqueue error response: ${error2}`)));
14935
+ }, capturedTransport?.sessionId).catch((error2) => this._onerror(new Error(`Failed to enqueue error response: ${error2}`)));
14951
14936
  } else {
14952
- capturedTransport == null ? void 0 : capturedTransport.send(errorResponse).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
14937
+ capturedTransport?.send(errorResponse).catch((error2) => this._onerror(new Error(`Failed to send an error response: ${error2}`)));
14953
14938
  }
14954
14939
  return;
14955
14940
  }
14956
14941
  const abortController = new AbortController();
14957
14942
  this._requestHandlerAbortControllers.set(request.id, abortController);
14958
14943
  const taskCreationParams = isTaskAugmentedRequestParams(request.params) ? request.params.task : void 0;
14959
- const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport == null ? void 0 : capturedTransport.sessionId) : void 0;
14944
+ const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport?.sessionId) : void 0;
14960
14945
  const fullExtra = {
14961
14946
  signal: abortController.signal,
14962
- sessionId: capturedTransport == null ? void 0 : capturedTransport.sessionId,
14963
- _meta: (_e = request.params) == null ? void 0 : _e._meta,
14947
+ sessionId: capturedTransport?.sessionId,
14948
+ _meta: request.params?._meta,
14964
14949
  sendNotification: async (notification) => {
14965
14950
  if (abortController.signal.aborted)
14966
14951
  return;
@@ -14971,7 +14956,6 @@ var Protocol = class {
14971
14956
  await this.notification(notification, notificationOptions);
14972
14957
  },
14973
14958
  sendRequest: async (r, resultSchema, options) => {
14974
- var _a6, _b2;
14975
14959
  if (abortController.signal.aborted) {
14976
14960
  throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
14977
14961
  }
@@ -14979,20 +14963,20 @@ var Protocol = class {
14979
14963
  if (relatedTaskId && !requestOptions.relatedTask) {
14980
14964
  requestOptions.relatedTask = { taskId: relatedTaskId };
14981
14965
  }
14982
- const effectiveTaskId = (_b2 = (_a6 = requestOptions.relatedTask) == null ? void 0 : _a6.taskId) != null ? _b2 : relatedTaskId;
14966
+ const effectiveTaskId = requestOptions.relatedTask?.taskId ?? relatedTaskId;
14983
14967
  if (effectiveTaskId && taskStore) {
14984
14968
  await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
14985
14969
  }
14986
14970
  return await this.request(r, resultSchema, requestOptions);
14987
14971
  },
14988
- authInfo: extra == null ? void 0 : extra.authInfo,
14972
+ authInfo: extra?.authInfo,
14989
14973
  requestId: request.id,
14990
- requestInfo: extra == null ? void 0 : extra.requestInfo,
14974
+ requestInfo: extra?.requestInfo,
14991
14975
  taskId: relatedTaskId,
14992
14976
  taskStore,
14993
- taskRequestedTtl: taskCreationParams == null ? void 0 : taskCreationParams.ttl,
14994
- closeSSEStream: extra == null ? void 0 : extra.closeSSEStream,
14995
- closeStandaloneSSEStream: extra == null ? void 0 : extra.closeStandaloneSSEStream
14977
+ taskRequestedTtl: taskCreationParams?.ttl,
14978
+ closeSSEStream: extra?.closeSSEStream,
14979
+ closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
14996
14980
  };
14997
14981
  Promise.resolve().then(() => {
14998
14982
  if (taskCreationParams) {
@@ -15012,12 +14996,11 @@ var Protocol = class {
15012
14996
  type: "response",
15013
14997
  message: response,
15014
14998
  timestamp: Date.now()
15015
- }, capturedTransport == null ? void 0 : capturedTransport.sessionId);
14999
+ }, capturedTransport?.sessionId);
15016
15000
  } else {
15017
- await (capturedTransport == null ? void 0 : capturedTransport.send(response));
15001
+ await capturedTransport?.send(response);
15018
15002
  }
15019
15003
  }, async (error2) => {
15020
- var _a6;
15021
15004
  if (abortController.signal.aborted) {
15022
15005
  return;
15023
15006
  }
@@ -15026,7 +15009,7 @@ var Protocol = class {
15026
15009
  id: request.id,
15027
15010
  error: {
15028
15011
  code: Number.isSafeInteger(error2["code"]) ? error2["code"] : ErrorCode.InternalError,
15029
- message: (_a6 = error2.message) != null ? _a6 : "Internal error",
15012
+ message: error2.message ?? "Internal error",
15030
15013
  ...error2["data"] !== void 0 && { data: error2["data"] }
15031
15014
  }
15032
15015
  };
@@ -15035,9 +15018,9 @@ var Protocol = class {
15035
15018
  type: "error",
15036
15019
  message: errorResponse,
15037
15020
  timestamp: Date.now()
15038
- }, capturedTransport == null ? void 0 : capturedTransport.sessionId);
15021
+ }, capturedTransport?.sessionId);
15039
15022
  } else {
15040
- await (capturedTransport == null ? void 0 : capturedTransport.send(errorResponse));
15023
+ await capturedTransport?.send(errorResponse);
15041
15024
  }
15042
15025
  }).catch((error2) => this._onerror(new Error(`Failed to send response: ${error2}`))).finally(() => {
15043
15026
  if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
@@ -15116,8 +15099,7 @@ var Protocol = class {
15116
15099
  * Closes the connection.
15117
15100
  */
15118
15101
  async close() {
15119
- var _a5;
15120
- await ((_a5 = this._transport) == null ? void 0 : _a5.close());
15102
+ await this._transport?.close();
15121
15103
  }
15122
15104
  /**
15123
15105
  * Sends a request and returns an AsyncGenerator that yields response messages.
@@ -15147,8 +15129,7 @@ var Protocol = class {
15147
15129
  * @experimental Use `client.experimental.tasks.requestStream()` to access this method.
15148
15130
  */
15149
15131
  async *requestStream(request, resultSchema, options) {
15150
- var _a5, _b, _c, _d;
15151
- const { task } = options != null ? options : {};
15132
+ const { task } = options ?? {};
15152
15133
  if (!task) {
15153
15134
  try {
15154
15135
  const result = await this.request(request, resultSchema, options);
@@ -15195,9 +15176,9 @@ var Protocol = class {
15195
15176
  yield { type: "result", result };
15196
15177
  return;
15197
15178
  }
15198
- const pollInterval = (_c = (_b = task2.pollInterval) != null ? _b : (_a5 = this._options) == null ? void 0 : _a5.defaultTaskPollInterval) != null ? _c : 1e3;
15179
+ const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
15199
15180
  await new Promise((resolve) => setTimeout(resolve, pollInterval));
15200
- (_d = options == null ? void 0 : options.signal) == null ? void 0 : _d.throwIfAborted();
15181
+ options?.signal?.throwIfAborted();
15201
15182
  }
15202
15183
  } catch (error2) {
15203
15184
  yield {
@@ -15212,9 +15193,8 @@ var Protocol = class {
15212
15193
  * Do not use this method to emit notifications! Use notification() instead.
15213
15194
  */
15214
15195
  request(request, resultSchema, options) {
15215
- const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options != null ? options : {};
15196
+ const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
15216
15197
  return new Promise((resolve, reject) => {
15217
- var _a5, _b, _c, _d, _e, _f, _g;
15218
15198
  const earlyReject = (error2) => {
15219
15199
  reject(error2);
15220
15200
  };
@@ -15222,7 +15202,7 @@ var Protocol = class {
15222
15202
  earlyReject(new Error("Not connected"));
15223
15203
  return;
15224
15204
  }
15225
- if (((_a5 = this._options) == null ? void 0 : _a5.enforceStrictCapabilities) === true) {
15205
+ if (this._options?.enforceStrictCapabilities === true) {
15226
15206
  try {
15227
15207
  this.assertCapabilityForMethod(request.method);
15228
15208
  if (task) {
@@ -15233,19 +15213,19 @@ var Protocol = class {
15233
15213
  return;
15234
15214
  }
15235
15215
  }
15236
- (_b = options == null ? void 0 : options.signal) == null ? void 0 : _b.throwIfAborted();
15216
+ options?.signal?.throwIfAborted();
15237
15217
  const messageId = this._requestMessageId++;
15238
15218
  const jsonrpcRequest = {
15239
15219
  ...request,
15240
15220
  jsonrpc: "2.0",
15241
15221
  id: messageId
15242
15222
  };
15243
- if (options == null ? void 0 : options.onprogress) {
15223
+ if (options?.onprogress) {
15244
15224
  this._progressHandlers.set(messageId, options.onprogress);
15245
15225
  jsonrpcRequest.params = {
15246
15226
  ...request.params,
15247
15227
  _meta: {
15248
- ...((_c = request.params) == null ? void 0 : _c._meta) || {},
15228
+ ...request.params?._meta || {},
15249
15229
  progressToken: messageId
15250
15230
  }
15251
15231
  };
@@ -15260,17 +15240,16 @@ var Protocol = class {
15260
15240
  jsonrpcRequest.params = {
15261
15241
  ...jsonrpcRequest.params,
15262
15242
  _meta: {
15263
- ...((_d = jsonrpcRequest.params) == null ? void 0 : _d._meta) || {},
15243
+ ...jsonrpcRequest.params?._meta || {},
15264
15244
  [RELATED_TASK_META_KEY]: relatedTask
15265
15245
  }
15266
15246
  };
15267
15247
  }
15268
15248
  const cancel = (reason) => {
15269
- var _a6;
15270
15249
  this._responseHandlers.delete(messageId);
15271
15250
  this._progressHandlers.delete(messageId);
15272
15251
  this._cleanupTimeout(messageId);
15273
- (_a6 = this._transport) == null ? void 0 : _a6.send({
15252
+ this._transport?.send({
15274
15253
  jsonrpc: "2.0",
15275
15254
  method: "notifications/cancelled",
15276
15255
  params: {
@@ -15282,8 +15261,7 @@ var Protocol = class {
15282
15261
  reject(error2);
15283
15262
  };
15284
15263
  this._responseHandlers.set(messageId, (response) => {
15285
- var _a6;
15286
- if ((_a6 = options == null ? void 0 : options.signal) == null ? void 0 : _a6.aborted) {
15264
+ if (options?.signal?.aborted) {
15287
15265
  return;
15288
15266
  }
15289
15267
  if (response instanceof Error) {
@@ -15300,14 +15278,13 @@ var Protocol = class {
15300
15278
  reject(error2);
15301
15279
  }
15302
15280
  });
15303
- (_e = options == null ? void 0 : options.signal) == null ? void 0 : _e.addEventListener("abort", () => {
15304
- var _a6;
15305
- cancel((_a6 = options == null ? void 0 : options.signal) == null ? void 0 : _a6.reason);
15281
+ options?.signal?.addEventListener("abort", () => {
15282
+ cancel(options?.signal?.reason);
15306
15283
  });
15307
- const timeout = (_f = options == null ? void 0 : options.timeout) != null ? _f : DEFAULT_REQUEST_TIMEOUT_MSEC;
15284
+ const timeout = options?.timeout ?? DEFAULT_REQUEST_TIMEOUT_MSEC;
15308
15285
  const timeoutHandler = () => cancel(McpError.fromError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
15309
- this._setupTimeout(messageId, timeout, options == null ? void 0 : options.maxTotalTimeout, timeoutHandler, (_g = options == null ? void 0 : options.resetTimeoutOnProgress) != null ? _g : false);
15310
- const relatedTaskId = relatedTask == null ? void 0 : relatedTask.taskId;
15286
+ this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler, options?.resetTimeoutOnProgress ?? false);
15287
+ const relatedTaskId = relatedTask?.taskId;
15311
15288
  if (relatedTaskId) {
15312
15289
  const responseResolver = (response) => {
15313
15290
  const handler = this._responseHandlers.get(messageId);
@@ -15370,12 +15347,11 @@ var Protocol = class {
15370
15347
  * Emits a notification, which is a one-way message that does not expect a response.
15371
15348
  */
15372
15349
  async notification(notification, options) {
15373
- var _a5, _b, _c, _d, _e;
15374
15350
  if (!this._transport) {
15375
15351
  throw new Error("Not connected");
15376
15352
  }
15377
15353
  this.assertNotificationCapability(notification.method);
15378
- const relatedTaskId = (_a5 = options == null ? void 0 : options.relatedTask) == null ? void 0 : _a5.taskId;
15354
+ const relatedTaskId = options?.relatedTask?.taskId;
15379
15355
  if (relatedTaskId) {
15380
15356
  const jsonrpcNotification2 = {
15381
15357
  ...notification,
@@ -15383,7 +15359,7 @@ var Protocol = class {
15383
15359
  params: {
15384
15360
  ...notification.params,
15385
15361
  _meta: {
15386
- ...((_b = notification.params) == null ? void 0 : _b._meta) || {},
15362
+ ...notification.params?._meta || {},
15387
15363
  [RELATED_TASK_META_KEY]: options.relatedTask
15388
15364
  }
15389
15365
  }
@@ -15395,15 +15371,14 @@ var Protocol = class {
15395
15371
  });
15396
15372
  return;
15397
15373
  }
15398
- const debouncedMethods = (_d = (_c = this._options) == null ? void 0 : _c.debouncedNotificationMethods) != null ? _d : [];
15399
- const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !(options == null ? void 0 : options.relatedRequestId) && !(options == null ? void 0 : options.relatedTask);
15374
+ const debouncedMethods = this._options?.debouncedNotificationMethods ?? [];
15375
+ const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !options?.relatedRequestId && !options?.relatedTask;
15400
15376
  if (canDebounce) {
15401
15377
  if (this._pendingDebouncedNotifications.has(notification.method)) {
15402
15378
  return;
15403
15379
  }
15404
15380
  this._pendingDebouncedNotifications.add(notification.method);
15405
15381
  Promise.resolve().then(() => {
15406
- var _a6, _b2;
15407
15382
  this._pendingDebouncedNotifications.delete(notification.method);
15408
15383
  if (!this._transport) {
15409
15384
  return;
@@ -15412,19 +15387,19 @@ var Protocol = class {
15412
15387
  ...notification,
15413
15388
  jsonrpc: "2.0"
15414
15389
  };
15415
- if (options == null ? void 0 : options.relatedTask) {
15390
+ if (options?.relatedTask) {
15416
15391
  jsonrpcNotification2 = {
15417
15392
  ...jsonrpcNotification2,
15418
15393
  params: {
15419
15394
  ...jsonrpcNotification2.params,
15420
15395
  _meta: {
15421
- ...((_a6 = jsonrpcNotification2.params) == null ? void 0 : _a6._meta) || {},
15396
+ ...jsonrpcNotification2.params?._meta || {},
15422
15397
  [RELATED_TASK_META_KEY]: options.relatedTask
15423
15398
  }
15424
15399
  }
15425
15400
  };
15426
15401
  }
15427
- (_b2 = this._transport) == null ? void 0 : _b2.send(jsonrpcNotification2, options).catch((error2) => this._onerror(error2));
15402
+ this._transport?.send(jsonrpcNotification2, options).catch((error2) => this._onerror(error2));
15428
15403
  });
15429
15404
  return;
15430
15405
  }
@@ -15432,13 +15407,13 @@ var Protocol = class {
15432
15407
  ...notification,
15433
15408
  jsonrpc: "2.0"
15434
15409
  };
15435
- if (options == null ? void 0 : options.relatedTask) {
15410
+ if (options?.relatedTask) {
15436
15411
  jsonrpcNotification = {
15437
15412
  ...jsonrpcNotification,
15438
15413
  params: {
15439
15414
  ...jsonrpcNotification.params,
15440
15415
  _meta: {
15441
- ...((_e = jsonrpcNotification.params) == null ? void 0 : _e._meta) || {},
15416
+ ...jsonrpcNotification.params?._meta || {},
15442
15417
  [RELATED_TASK_META_KEY]: options.relatedTask
15443
15418
  }
15444
15419
  }
@@ -15514,11 +15489,10 @@ var Protocol = class {
15514
15489
  * simply propagates the error.
15515
15490
  */
15516
15491
  async _enqueueTaskMessage(taskId, message, sessionId) {
15517
- var _a5;
15518
15492
  if (!this._taskStore || !this._taskMessageQueue) {
15519
15493
  throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
15520
15494
  }
15521
- const maxQueueSize = (_a5 = this._options) == null ? void 0 : _a5.maxTaskQueueSize;
15495
+ const maxQueueSize = this._options?.maxTaskQueueSize;
15522
15496
  await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
15523
15497
  }
15524
15498
  /**
@@ -15551,11 +15525,10 @@ var Protocol = class {
15551
15525
  * @returns Promise that resolves when an update occurs or rejects if aborted
15552
15526
  */
15553
15527
  async _waitForTaskUpdate(taskId, signal) {
15554
- var _a5, _b, _c;
15555
- let interval = (_b = (_a5 = this._options) == null ? void 0 : _a5.defaultTaskPollInterval) != null ? _b : 1e3;
15528
+ let interval = this._options?.defaultTaskPollInterval ?? 1e3;
15556
15529
  try {
15557
- const task = await ((_c = this._taskStore) == null ? void 0 : _c.getTask(taskId));
15558
- if (task == null ? void 0 : task.pollInterval) {
15530
+ const task = await this._taskStore?.getTask(taskId);
15531
+ if (task?.pollInterval) {
15559
15532
  interval = task.pollInterval;
15560
15533
  }
15561
15534
  } catch {
@@ -15694,7 +15667,7 @@ var AjvJsonSchemaValidator = class {
15694
15667
  * ```
15695
15668
  */
15696
15669
  constructor(ajv) {
15697
- this._ajv = ajv != null ? ajv : createDefaultAjvInstance();
15670
+ this._ajv = ajv ?? createDefaultAjvInstance();
15698
15671
  }
15699
15672
  /**
15700
15673
  * Create a validator for the given JSON Schema
@@ -15706,8 +15679,7 @@ var AjvJsonSchemaValidator = class {
15706
15679
  * @returns A validator function that validates input data
15707
15680
  */
15708
15681
  getValidator(schema) {
15709
- var _a5;
15710
- const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? (_a5 = this._ajv.getSchema(schema.$id)) != null ? _a5 : this._ajv.compile(schema) : this._ajv.compile(schema);
15682
+ const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? this._ajv.getSchema(schema.$id) ?? this._ajv.compile(schema) : this._ajv.compile(schema);
15711
15683
  return (input) => {
15712
15684
  const valid = ajvValidator(input);
15713
15685
  if (valid) {
@@ -15793,9 +15765,8 @@ var ExperimentalServerTasks = class {
15793
15765
  * @experimental
15794
15766
  */
15795
15767
  createMessageStream(params, options) {
15796
- var _a5;
15797
15768
  const clientCapabilities = this._server.getClientCapabilities();
15798
- if ((params.tools || params.toolChoice) && !((_a5 = clientCapabilities == null ? void 0 : clientCapabilities.sampling) == null ? void 0 : _a5.tools)) {
15769
+ if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
15799
15770
  throw new Error("Client does not support sampling tools capability.");
15800
15771
  }
15801
15772
  if (params.messages.length > 0) {
@@ -15869,18 +15840,17 @@ var ExperimentalServerTasks = class {
15869
15840
  * @experimental
15870
15841
  */
15871
15842
  elicitInputStream(params, options) {
15872
- var _a5, _b, _c;
15873
15843
  const clientCapabilities = this._server.getClientCapabilities();
15874
- const mode = (_a5 = params.mode) != null ? _a5 : "form";
15844
+ const mode = params.mode ?? "form";
15875
15845
  switch (mode) {
15876
15846
  case "url": {
15877
- if (!((_b = clientCapabilities == null ? void 0 : clientCapabilities.elicitation) == null ? void 0 : _b.url)) {
15847
+ if (!clientCapabilities?.elicitation?.url) {
15878
15848
  throw new Error("Client does not support url elicitation.");
15879
15849
  }
15880
15850
  break;
15881
15851
  }
15882
15852
  case "form": {
15883
- if (!((_c = clientCapabilities == null ? void 0 : clientCapabilities.elicitation) == null ? void 0 : _c.form)) {
15853
+ if (!clientCapabilities?.elicitation?.form) {
15884
15854
  throw new Error("Client does not support form elicitation.");
15885
15855
  }
15886
15856
  break;
@@ -15944,13 +15914,12 @@ var ExperimentalServerTasks = class {
15944
15914
 
15945
15915
  // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
15946
15916
  function assertToolsCallTaskCapability(requests, method, entityName) {
15947
- var _a5;
15948
15917
  if (!requests) {
15949
15918
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
15950
15919
  }
15951
15920
  switch (method) {
15952
15921
  case "tools/call":
15953
- if (!((_a5 = requests.tools) == null ? void 0 : _a5.call)) {
15922
+ if (!requests.tools?.call) {
15954
15923
  throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
15955
15924
  }
15956
15925
  break;
@@ -15959,18 +15928,17 @@ function assertToolsCallTaskCapability(requests, method, entityName) {
15959
15928
  }
15960
15929
  }
15961
15930
  function assertClientRequestTaskCapability(requests, method, entityName) {
15962
- var _a5, _b;
15963
15931
  if (!requests) {
15964
15932
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
15965
15933
  }
15966
15934
  switch (method) {
15967
15935
  case "sampling/createMessage":
15968
- if (!((_a5 = requests.sampling) == null ? void 0 : _a5.createMessage)) {
15936
+ if (!requests.sampling?.createMessage) {
15969
15937
  throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
15970
15938
  }
15971
15939
  break;
15972
15940
  case "elicitation/create":
15973
- if (!((_b = requests.elicitation) == null ? void 0 : _b.create)) {
15941
+ if (!requests.elicitation?.create) {
15974
15942
  throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
15975
15943
  }
15976
15944
  break;
@@ -15985,7 +15953,6 @@ var Server = class extends Protocol {
15985
15953
  * Initializes this server with the given name and version information.
15986
15954
  */
15987
15955
  constructor(_serverInfo, options) {
15988
- var _a5, _b;
15989
15956
  super(options);
15990
15957
  this._serverInfo = _serverInfo;
15991
15958
  this._loggingLevels = /* @__PURE__ */ new Map();
@@ -15994,18 +15961,14 @@ var Server = class extends Protocol {
15994
15961
  const currentLevel = this._loggingLevels.get(sessionId);
15995
15962
  return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
15996
15963
  };
15997
- this._capabilities = (_a5 = options == null ? void 0 : options.capabilities) != null ? _a5 : {};
15998
- this._instructions = options == null ? void 0 : options.instructions;
15999
- this._jsonSchemaValidator = (_b = options == null ? void 0 : options.jsonSchemaValidator) != null ? _b : new AjvJsonSchemaValidator();
15964
+ this._capabilities = options?.capabilities ?? {};
15965
+ this._instructions = options?.instructions;
15966
+ this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
16000
15967
  this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
16001
- this.setNotificationHandler(InitializedNotificationSchema, () => {
16002
- var _a6;
16003
- return (_a6 = this.oninitialized) == null ? void 0 : _a6.call(this);
16004
- });
15968
+ this.setNotificationHandler(InitializedNotificationSchema, () => this.oninitialized?.());
16005
15969
  if (this._capabilities.logging) {
16006
15970
  this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
16007
- var _a6;
16008
- const transportSessionId = extra.sessionId || ((_a6 = extra.requestInfo) == null ? void 0 : _a6.headers["mcp-session-id"]) || void 0;
15971
+ const transportSessionId = extra.sessionId || extra.requestInfo?.headers["mcp-session-id"] || void 0;
16009
15972
  const { level } = request.params;
16010
15973
  const parseResult = LoggingLevelSchema.safeParse(level);
16011
15974
  if (parseResult.success) {
@@ -16046,7 +16009,7 @@ var Server = class extends Protocol {
16046
16009
  */
16047
16010
  setRequestHandler(requestSchema, handler) {
16048
16011
  const shape = getObjectShape(requestSchema);
16049
- const methodSchema = shape == null ? void 0 : shape.method;
16012
+ const methodSchema = shape?.method;
16050
16013
  if (!methodSchema) {
16051
16014
  throw new Error("Schema is missing a method literal");
16052
16015
  }
@@ -16084,20 +16047,19 @@ var Server = class extends Protocol {
16084
16047
  return super.setRequestHandler(requestSchema, handler);
16085
16048
  }
16086
16049
  assertCapabilityForMethod(method) {
16087
- var _a5, _b, _c;
16088
16050
  switch (method) {
16089
16051
  case "sampling/createMessage":
16090
- if (!((_a5 = this._clientCapabilities) == null ? void 0 : _a5.sampling)) {
16052
+ if (!this._clientCapabilities?.sampling) {
16091
16053
  throw new Error(`Client does not support sampling (required for ${method})`);
16092
16054
  }
16093
16055
  break;
16094
16056
  case "elicitation/create":
16095
- if (!((_b = this._clientCapabilities) == null ? void 0 : _b.elicitation)) {
16057
+ if (!this._clientCapabilities?.elicitation) {
16096
16058
  throw new Error(`Client does not support elicitation (required for ${method})`);
16097
16059
  }
16098
16060
  break;
16099
16061
  case "roots/list":
16100
- if (!((_c = this._clientCapabilities) == null ? void 0 : _c.roots)) {
16062
+ if (!this._clientCapabilities?.roots) {
16101
16063
  throw new Error(`Client does not support listing roots (required for ${method})`);
16102
16064
  }
16103
16065
  break;
@@ -16106,7 +16068,6 @@ var Server = class extends Protocol {
16106
16068
  }
16107
16069
  }
16108
16070
  assertNotificationCapability(method) {
16109
- var _a5, _b;
16110
16071
  switch (method) {
16111
16072
  case "notifications/message":
16112
16073
  if (!this._capabilities.logging) {
@@ -16130,7 +16091,7 @@ var Server = class extends Protocol {
16130
16091
  }
16131
16092
  break;
16132
16093
  case "notifications/elicitation/complete":
16133
- if (!((_b = (_a5 = this._clientCapabilities) == null ? void 0 : _a5.elicitation) == null ? void 0 : _b.url)) {
16094
+ if (!this._clientCapabilities?.elicitation?.url) {
16134
16095
  throw new Error(`Client does not support URL elicitation (required for ${method})`);
16135
16096
  }
16136
16097
  break;
@@ -16188,15 +16149,13 @@ var Server = class extends Protocol {
16188
16149
  }
16189
16150
  }
16190
16151
  assertTaskCapability(method) {
16191
- var _a5, _b;
16192
- assertClientRequestTaskCapability((_b = (_a5 = this._clientCapabilities) == null ? void 0 : _a5.tasks) == null ? void 0 : _b.requests, method, "Client");
16152
+ assertClientRequestTaskCapability(this._clientCapabilities?.tasks?.requests, method, "Client");
16193
16153
  }
16194
16154
  assertTaskHandlerCapability(method) {
16195
- var _a5;
16196
16155
  if (!this._capabilities) {
16197
16156
  return;
16198
16157
  }
16199
- assertToolsCallTaskCapability((_a5 = this._capabilities.tasks) == null ? void 0 : _a5.requests, method, "Server");
16158
+ assertToolsCallTaskCapability(this._capabilities.tasks?.requests, method, "Server");
16200
16159
  }
16201
16160
  async _oninitialize(request) {
16202
16161
  const requestedVersion = request.params.protocolVersion;
@@ -16230,9 +16189,8 @@ var Server = class extends Protocol {
16230
16189
  }
16231
16190
  // Implementation
16232
16191
  async createMessage(params, options) {
16233
- var _a5, _b;
16234
16192
  if (params.tools || params.toolChoice) {
16235
- if (!((_b = (_a5 = this._clientCapabilities) == null ? void 0 : _a5.sampling) == null ? void 0 : _b.tools)) {
16193
+ if (!this._clientCapabilities?.sampling?.tools) {
16236
16194
  throw new Error("Client does not support sampling tools capability.");
16237
16195
  }
16238
16196
  }
@@ -16272,18 +16230,17 @@ var Server = class extends Protocol {
16272
16230
  * @returns The result of the elicitation request.
16273
16231
  */
16274
16232
  async elicitInput(params, options) {
16275
- var _a5, _b, _c, _d, _e;
16276
- const mode = (_a5 = params.mode) != null ? _a5 : "form";
16233
+ const mode = params.mode ?? "form";
16277
16234
  switch (mode) {
16278
16235
  case "url": {
16279
- if (!((_c = (_b = this._clientCapabilities) == null ? void 0 : _b.elicitation) == null ? void 0 : _c.url)) {
16236
+ if (!this._clientCapabilities?.elicitation?.url) {
16280
16237
  throw new Error("Client does not support url elicitation.");
16281
16238
  }
16282
16239
  const urlParams = params;
16283
16240
  return this.request({ method: "elicitation/create", params: urlParams }, ElicitResultSchema, options);
16284
16241
  }
16285
16242
  case "form": {
16286
- if (!((_e = (_d = this._clientCapabilities) == null ? void 0 : _d.elicitation) == null ? void 0 : _e.form)) {
16243
+ if (!this._clientCapabilities?.elicitation?.form) {
16287
16244
  throw new Error("Client does not support form elicitation.");
16288
16245
  }
16289
16246
  const formParams = params.mode === "form" ? params : { ...params, mode: "form" };
@@ -16315,8 +16272,7 @@ var Server = class extends Protocol {
16315
16272
  * @returns A function that emits the completion notification when awaited.
16316
16273
  */
16317
16274
  createElicitationCompletionNotifier(elicitationId, options) {
16318
- var _a5, _b;
16319
- if (!((_b = (_a5 = this._clientCapabilities) == null ? void 0 : _a5.elicitation) == null ? void 0 : _b.url)) {
16275
+ if (!this._clientCapabilities?.elicitation?.url) {
16320
16276
  throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");
16321
16277
  }
16322
16278
  return () => this.notification({
@@ -16363,18 +16319,16 @@ var Server = class extends Protocol {
16363
16319
  };
16364
16320
 
16365
16321
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
16366
- var import_node_process = __toESM(require("process"), 1);
16322
+ var import_node_process = __toESM(require("node:process"), 1);
16367
16323
 
16368
16324
  // node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
16369
16325
  var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
16370
16326
  var ReadBuffer = class {
16371
16327
  constructor(options) {
16372
- var _a5;
16373
- this._maxBufferSize = (_a5 = options == null ? void 0 : options.maxBufferSize) != null ? _a5 : STDIO_DEFAULT_MAX_BUFFER_SIZE;
16328
+ this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
16374
16329
  }
16375
16330
  append(chunk) {
16376
- var _a5, _b;
16377
- const newSize = ((_b = (_a5 = this._buffer) == null ? void 0 : _a5.length) != null ? _b : 0) + chunk.length;
16331
+ const newSize = (this._buffer?.length ?? 0) + chunk.length;
16378
16332
  if (newSize > this._maxBufferSize) {
16379
16333
  this.clear();
16380
16334
  throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
@@ -16411,21 +16365,19 @@ var StdioServerTransport = class {
16411
16365
  this._stdout = _stdout;
16412
16366
  this._started = false;
16413
16367
  this._ondata = (chunk) => {
16414
- var _a5;
16415
16368
  try {
16416
16369
  this._readBuffer.append(chunk);
16417
16370
  this.processReadBuffer();
16418
16371
  } catch (error2) {
16419
- (_a5 = this.onerror) == null ? void 0 : _a5.call(this, error2);
16372
+ this.onerror?.(error2);
16420
16373
  this.close().catch(() => {
16421
16374
  });
16422
16375
  }
16423
16376
  };
16424
16377
  this._onerror = (error2) => {
16425
- var _a5;
16426
- (_a5 = this.onerror) == null ? void 0 : _a5.call(this, error2);
16378
+ this.onerror?.(error2);
16427
16379
  };
16428
- this._readBuffer = new ReadBuffer({ maxBufferSize: options == null ? void 0 : options.maxBufferSize });
16380
+ this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
16429
16381
  }
16430
16382
  /**
16431
16383
  * Starts listening for messages on stdin.
@@ -16439,21 +16391,19 @@ var StdioServerTransport = class {
16439
16391
  this._stdin.on("error", this._onerror);
16440
16392
  }
16441
16393
  processReadBuffer() {
16442
- var _a5, _b;
16443
16394
  while (true) {
16444
16395
  try {
16445
16396
  const message = this._readBuffer.readMessage();
16446
16397
  if (message === null) {
16447
16398
  break;
16448
16399
  }
16449
- (_a5 = this.onmessage) == null ? void 0 : _a5.call(this, message);
16400
+ this.onmessage?.(message);
16450
16401
  } catch (error2) {
16451
- (_b = this.onerror) == null ? void 0 : _b.call(this, error2);
16402
+ this.onerror?.(error2);
16452
16403
  }
16453
16404
  }
16454
16405
  }
16455
16406
  async close() {
16456
- var _a5;
16457
16407
  this._stdin.off("data", this._ondata);
16458
16408
  this._stdin.off("error", this._onerror);
16459
16409
  const remainingDataListeners = this._stdin.listenerCount("data");
@@ -16461,7 +16411,7 @@ var StdioServerTransport = class {
16461
16411
  this._stdin.pause();
16462
16412
  }
16463
16413
  this._readBuffer.clear();
16464
- (_a5 = this.onclose) == null ? void 0 : _a5.call(this);
16414
+ this.onclose?.();
16465
16415
  }
16466
16416
  send(message) {
16467
16417
  return new Promise((resolve) => {
@@ -16555,8 +16505,8 @@ server2.setRequestHandler(CallToolRequestSchema, async (request) => {
16555
16505
  }
16556
16506
  }
16557
16507
  if (name === "yap2app_suggest_placement") {
16558
- const componentName = (args == null ? void 0 : args.componentName) || "CustomComponent";
16559
- const granularity = (args == null ? void 0 : args.granularity) || "organism";
16508
+ const componentName = args?.componentName || "CustomComponent";
16509
+ const granularity = args?.granularity || "organism";
16560
16510
  let subfolder = "components/organisms";
16561
16511
  if (granularity === "atom") subfolder = "components/ui";
16562
16512
  else if (granularity === "molecule") subfolder = "components/molecules";
@@ -16609,7 +16559,7 @@ server2.setRequestHandler(CallToolRequestSchema, async (request) => {
16609
16559
  async function runMcpServer() {
16610
16560
  const transport = new StdioServerTransport();
16611
16561
  await server2.connect(transport);
16612
- console.error("\u26A1 Yap2App MCP Server running on stdio");
16562
+ console.error("Yap2App MCP Server running on stdio");
16613
16563
  }
16614
16564
  var isDirectRun2 = Boolean(typeof process !== "undefined" && process.argv && process.argv[1] && (process.argv[1].endsWith("mcp.js") || process.argv[1].endsWith("mcp")));
16615
16565
  if (isDirectRun2) {
@@ -16626,32 +16576,29 @@ async function main() {
16626
16576
  await runMcpServer();
16627
16577
  } else if (command === "scan") {
16628
16578
  console.log(`
16629
- \u{1F50D} Yap2App Codebase Context Scanner:`);
16579
+ Yap2App Codebase Context:
16580
+ `);
16630
16581
  const context = await scanCodebase(process.cwd());
16631
- console.log(`
16632
- Project: ${context.project_name}`);
16633
- console.log(`Framework: ${context.framework} (${context.framework_display_name || "Generic"})`);
16634
- console.log(`Path Alias: ${context.path_alias || "@/"}`);
16635
- const depCount = Array.isArray(context.dependencies) ? context.dependencies.length : Object.keys(context.dependencies || {}).length;
16636
- console.log(`Dependencies Detected: ${depCount}`);
16637
- console.log(`UI Components Catalog: ${(context.component_names || []).join(", ") || "None"}`);
16638
- console.log(`
16639
- Full Context JSON:
16640
- `, JSON.stringify(context, null, 2));
16582
+ console.log(` Project: ${context.project_name}`);
16583
+ console.log(` Framework: ${context.framework_display_name || context.framework}`);
16584
+ console.log(` Path Alias: ${context.path_alias || "@/"}`);
16585
+ console.log(` Files: ${context.discovered_files?.length || 0}`);
16586
+ console.log(` Components: ${(context.component_names || []).join(", ") || "None"}
16587
+ `);
16641
16588
  } else if (command === "start" || command === "bridge" || command === "server") {
16642
16589
  startBridge();
16643
16590
  } else if (command === "help" || command === "--help" || command === "-h") {
16644
16591
  console.log(`
16645
- \u26A1 Yap2App CLI & MCP Toolkit \u26A1
16592
+ Yap2App CLI
16646
16593
 
16647
16594
  Usage:
16648
16595
  npx yap2app [command]
16649
16596
 
16650
16597
  Commands:
16651
- start | bridge Start the Localhost Bridge with W3C PNA for 1-click Web Studio Sync (Default)
16652
- mcp Run the Model Context Protocol (MCP) Server over stdio for Cursor/Claude
16653
- scan Run a shallow codebase scan and print detected standards & UI primitives
16654
- help Display this help guide
16598
+ start, bridge Start local bridge for Web Studio sync (default)
16599
+ mcp Run MCP server over stdio for Cursor / Claude
16600
+ scan Scan codebase context and detected components
16601
+ help Show this help message
16655
16602
  `);
16656
16603
  } else {
16657
16604
  startBridge();