integration-tour 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +3 -1
  2. package/dist/cli.js +685 -271
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2718,42 +2718,14 @@ var cli_exports = {};
2718
2718
  __export(cli_exports, {
2719
2719
  didYouMean: () => didYouMean,
2720
2720
  main: () => main,
2721
+ oneLine: () => oneLine,
2721
2722
  progressLine: () => progressLine
2722
2723
  });
2723
2724
  module.exports = __toCommonJS(cli_exports);
2724
2725
  var import_promises3 = require("node:fs/promises");
2726
+ var import_promises4 = require("node:readline/promises");
2725
2727
  var import_node_path4 = require("node:path");
2726
2728
 
2727
- // ../../lib/storyboard/timing.ts
2728
- var VOICE_LEAD = 400;
2729
- var VOICE_TAIL = 600;
2730
- function activeScenes(sb) {
2731
- return sb.scenes.filter((s) => sb.settings.showFailure || !s.failurePath);
2732
- }
2733
- function sceneDuration(sb, scene) {
2734
- if (!sb.settings.voiceover || !scene.voiceMs) return scene.duration;
2735
- return Math.max(scene.duration, Math.ceil(VOICE_LEAD + scene.voiceMs + VOICE_TAIL));
2736
- }
2737
- function totalDuration(sb) {
2738
- return activeScenes(sb).reduce((sum, s) => sum + sceneDuration(sb, s), 0);
2739
- }
2740
- function summaryItems(sb) {
2741
- const items = [];
2742
- let failure;
2743
- for (const scene of activeScenes(sb)) {
2744
- if (!scene.summaryLine) continue;
2745
- if (scene.kind === "call" && scene.outcome === "failure") {
2746
- failure = scene.summaryLine;
2747
- continue;
2748
- }
2749
- items.push(scene.summaryLine);
2750
- if (failure) items.push(failure);
2751
- failure = void 0;
2752
- }
2753
- if (failure) items.push(failure);
2754
- return items;
2755
- }
2756
-
2757
2729
  // ../../lib/oas/fit.ts
2758
2730
  var CIRCULAR_TARGET = "x-circular-target";
2759
2731
  function circularTarget(schema2) {
@@ -2909,15 +2881,31 @@ function canonical(value) {
2909
2881
  var REPEATED_GROUP = /\)(?:[*+]|\{\d+,?\d*\})/;
2910
2882
  var compiled = /* @__PURE__ */ new Map();
2911
2883
  function patternVerdict(pattern, value) {
2912
- if (value.length > 40 || REPEATED_GROUP.test(pattern)) return void 0;
2884
+ if (value.length > Math.min(40, quickLength(pattern))) return void 0;
2913
2885
  const re = compiledPattern(pattern);
2914
2886
  return re === null ? void 0 : re.test(value);
2915
2887
  }
2916
2888
  function matchesPattern(pattern, value) {
2917
- if (value.length > 2e3 || REPEATED_GROUP.test(pattern)) return true;
2889
+ if (value.length > Math.min(2e3, quickLength(pattern))) return true;
2918
2890
  const re = compiledPattern(pattern);
2919
2891
  return re === null || re.test(value);
2920
2892
  }
2893
+ var STEP_BUDGET = 1e6;
2894
+ var quickLengths = /* @__PURE__ */ new Map();
2895
+ function quickLength(pattern) {
2896
+ let length = quickLengths.get(pattern);
2897
+ if (length === void 0) {
2898
+ if (REPEATED_GROUP.test(pattern)) length = 0;
2899
+ else {
2900
+ const bare2 = pattern.replace(/\\./g, "x").replace(/\[(?:\\.|[^\]\\])*\]/g, "x");
2901
+ const repeats = (bare2.match(/[*+]|\{\d*,(\d*)\}/g) ?? []).filter((q) => !/,\d{1,2}\}$/.test(q)).length;
2902
+ length = repeats <= 1 ? Infinity : Math.floor(Math.round(STEP_BUDGET ** (1 / repeats) * 1e3) / 1e3);
2903
+ }
2904
+ if (quickLengths.size > 2e3) quickLengths.clear();
2905
+ quickLengths.set(pattern, length);
2906
+ }
2907
+ return length;
2908
+ }
2921
2909
  function compiledPattern(pattern) {
2922
2910
  let re = compiled.get(pattern);
2923
2911
  if (re === void 0) {
@@ -3937,6 +3925,196 @@ function singular(word) {
3937
3925
  return word;
3938
3926
  }
3939
3927
 
3928
+ // ../../lib/text.ts
3929
+ function cut(text3, max) {
3930
+ const end = Math.max(0, max);
3931
+ const last = text3.charCodeAt(end - 1);
3932
+ return text3.slice(0, last >= 55296 && last <= 56319 ? end - 1 : end);
3933
+ }
3934
+ function firstSentence(text3) {
3935
+ if (!text3) return void 0;
3936
+ const plain = text3.replace(/<[^<>]+>/g, "").replace(/\s+/g, " ").trim();
3937
+ const match = plain.match(/^(.{1,90}?[.!?])(\s|$)/);
3938
+ return match ? match[1] : cut(plain, 90);
3939
+ }
3940
+ var HALVES = /[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDFFF]/g;
3941
+ function wellFormed(text3) {
3942
+ return text3.replace(HALVES, (c) => c.length === 2 ? c : "");
3943
+ }
3944
+ function clip(text3, max) {
3945
+ return text3.length > max ? `${cut(text3, max - 1)}\u2026` : text3;
3946
+ }
3947
+ function plainText(markdown) {
3948
+ return markdown.replace(/<[^>]+>/g, " ").replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\*\*|__|`/g, "").replace(/(^|\s)[*_]([^*_\s][^*_]*?)[*_](?=[\s.,;:!?)]|$)/g, "$1$2").replace(/^\s{0,3}(#{1,6}|>)\s+/gm, "").replace(/\s+/g, " ").trim();
3949
+ }
3950
+
3951
+ // ../../lib/oas/secrets.ts
3952
+ var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
3953
+ function secretName(name) {
3954
+ if (/idempotency/i.test(name)) return false;
3955
+ return /secret|passw(or)?d|pwd|token|api[-_]?key|apikey|credential|signature|session|cookie|bearer|jwt|^auth(orization)?$/i.test(name) || /(^|[_-])key$|[a-z0-9]Key$|^key$/i.test(name);
3956
+ }
3957
+ var SECRET_VALUE = /^(sk|rk)_(live|test)_|^whsec_|^gh[pousr]_|^github_pat_|^xox[abposr]-|^(AKIA|ASIA)[0-9A-Z]{12,}|^eyJ[\w-]+\.[\w-]+|^(bearer|basic)\s|^sk-[\w-]{20,}|^AIza[\w-]{30,}|^ya29\.[\w-]{20,}|^SG\.[\w-]{16,}\.[\w-]{16,}|^npm_[A-Za-z0-9]{30,}|^glpat-[\w-]{20,}|^hf_[A-Za-z0-9]{30,}|^shp(at|ss|ca|pa)_[a-fA-F0-9]{32}|^sq0(atp|csp)-[\w-]{20,}|^-----BEGIN [A-Z ]*PRIVATE KEY-----/i;
3958
+ function credentialName(name) {
3959
+ if (/^key$/i.test(name.trim()) || /(type|kind|url|uri|endpoint|expires?(_?(in|at))?|name|count|length|hint|prefix)$/i.test(name)) return false;
3960
+ return secretName(name) || /(^|[^a-z])auth([^a-z]|$)/i.test(name);
3961
+ }
3962
+ var BOT_TOKEN = /^bot\d{5,}:[\w-]{30,}$/;
3963
+ var PREFIXED_ID = /^[a-z]{1,10}_/;
3964
+ function pathSecret(segment) {
3965
+ const s = segment.trim();
3966
+ if (BOT_TOKEN.test(s)) return "bot_token";
3967
+ return SECRET_VALUE.test(s) || randomToken(s) ? "token" : void 0;
3968
+ }
3969
+ function randomToken(value) {
3970
+ const s = value.trim();
3971
+ if (s.length < 24 || s.startsWith("/") || s.includes("://") || !/^[A-Za-z0-9_\-.~:+/=]+$/.test(s)) return false;
3972
+ return /[a-z]/.test(s) && /[A-Z]/.test(s) && /\d/.test(s) && !PREFIXED_ID.test(s);
3973
+ }
3974
+ var SECRET_IN_TEXT = /\b(?:(?:sk|rk)_(?:live|test)_\w+|whsec_\w+|gh[pousr]_\w+|github_pat_\w+|xox[abposr]-[\w-]+|(?:AKIA|ASIA)[0-9A-Z]{12,}|eyJ[\w-]+\.[\w-]+\.[\w-]*|sk-[\w-]{20,}|AIza[\w-]{30,}|ya29\.[\w-]{20,}|SG\.[\w-]{16,}\.[\w-]{16,}|npm_[A-Za-z0-9]{30,}|glpat-[\w-]{20,}|hf_[A-Za-z0-9]{30,}|shp(?:at|ss|ca|pa)_[a-fA-F0-9]{32}|sq0(?:atp|csp)-[\w-]{20,})|-----BEGIN [A-Z ]{0,40}PRIVATE KEY-----[A-Za-z0-9+/=\s\\]{0,20000}(?:-----END [A-Z ]{0,40}PRIVATE KEY-----)?/g;
3975
+ var DOTS = "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
3976
+ var MAX_TEXT_SCAN = 2 * 1024 * 1024;
3977
+ function withoutCredentialsInText(text3, hid) {
3978
+ if (!text3.trim()) return text3;
3979
+ const hide = (name) => {
3980
+ hid.add(name);
3981
+ return DOTS;
3982
+ };
3983
+ const held = (value) => value.trim() !== "" && !value.includes("{{") && value !== DOTS;
3984
+ return withoutKeysInText(
3985
+ cut(text3, MAX_TEXT_SCAN).replace(/<([A-Za-z_][\w.:-]{0,100})((?:\s[^<>]{0,2000})?)>([^<]{1,10000})<\//g, (whole, tag2, attributes, content) => {
3986
+ const local = tag2.slice(tag2.lastIndexOf(":") + 1);
3987
+ return credentialName(local) && held(content) ? `<${tag2}${attributes}>${hide(local)}</` : whole;
3988
+ }).replace(/(?<![\w.-])(["']?)([A-Za-z_][\w.-]{0,100})\1(\s{0,5}[=:]\s{0,5})(?:"((?:[^"\\\n]|\\.){0,10000})"|'((?:[^'\\\n]|\\.){0,10000})')/g, (whole, quote, name, separator, double, single) => {
3989
+ const value = double ?? single ?? "";
3990
+ if (!credentialName(name) || !held(value)) return whole;
3991
+ const around = double !== void 0 ? '"' : "'";
3992
+ return `${quote}${name}${quote}${separator}${around}${hide(name)}${around}`;
3993
+ }).replace(/^([ \t]{0,20})([A-Za-z][\w-]{0,100})([ \t]{0,5}:[ \t]{0,5})([^\r\n]{1,10000})$/gm, (whole, indent, name, separator, value) => {
3994
+ const header = /^(authorization|proxy-authorization|cookie)$/i.test(name);
3995
+ if (!(credentialName(name) || header) || !held(value) || /^["']/.test(value)) return whole;
3996
+ const scheme = /^authorization$/i.test(name) ? value.match(/^([A-Za-z][\w-]*)\s+\S/)?.[1] : void 0;
3997
+ return `${indent}${name}${separator}${scheme ? `${scheme} ` : ""}${hide(name)}`;
3998
+ }).replace(
3999
+ /(^|[\s&?;,{(])([A-Za-z_][\w.-]{0,100})(\s{0,5}[=:]\s{0,5})([^\s&;,"'<>)}]{1,10000})/g,
4000
+ (whole, before, name, separator, value) => credentialName(name) && held(value) && !/^(authorization|proxy-authorization|cookie)$/i.test(name) ? `${before}${name}${separator}${hide(name)}` : whole
4001
+ ),
4002
+ hid
4003
+ );
4004
+ }
4005
+ function withoutKeysInText(text3, hid, name = "a key") {
4006
+ return text3.replace(SECRET_IN_TEXT, () => {
4007
+ hid.add(name);
4008
+ return DOTS;
4009
+ });
4010
+ }
4011
+ function withoutUserinfo(address) {
4012
+ return address.replace(/^([a-z][a-z\d+.-]*:\/\/)?[^/@\s]*@/i, (_, scheme) => scheme ?? "");
4013
+ }
4014
+ function hiddenAs(name) {
4015
+ return /passw(or)?d|pwd/i.test(name) ? DOTS : placeholder(name || "secret");
4016
+ }
4017
+ function secretField(name) {
4018
+ if (/(^|[_-])ids?$|[a-z0-9]Ids?$|(type|kind|url|uri|endpoint|expires?(_?(in|at))?|name|count|length|hint|prefix|method|mode|status|state|scheme|format|version|required|enabled)$/i.test(name)) return false;
4019
+ if (/(next|prev(ious)?|page|continuation|pagination|cursor|sync|resume|start|end|delta|change|watch|version|concurrency|lock)[-_]?token$/i.test(name)) return false;
4020
+ return /(passw(or)?d|passphrase|pwd|secrets?|credentials?|api[-_]?keys?|apikeys?|(private|access|signing|encryption|master|license|integration|consumer|client|app|account|service|auth|routing)[-_]?keys?|token)$/i.test(name) || /password[-_]?confirm(ation)?$|secret[-_]?(access[-_]?)?(key|token|value|string)$|^(authorization|auth|bearer|jwt|cookie)$/i.test(name);
4021
+ }
4022
+ function shownValue(value, name = "", depth = 0) {
4023
+ if (depth > 40) return value;
4024
+ if (typeof value === "string") {
4025
+ const v = value.trim();
4026
+ if (!v || isPlaceholder(v) || v.includes("{{")) return value;
4027
+ if (secretField(name)) return hiddenAs(name);
4028
+ return SECRET_VALUE.test(v) ? DOTS : withoutKeysInText(value, /* @__PURE__ */ new Set());
4029
+ }
4030
+ if (Array.isArray(value)) return value.map((v) => shownValue(v, name, depth + 1));
4031
+ if (isObj(value)) return Object.fromEntries(Object.entries(value).map(([key, v]) => [key, shownValue(v, key, depth + 1)]));
4032
+ return value;
4033
+ }
4034
+ function shownParam(name, value) {
4035
+ const v = value.trim();
4036
+ if (!v || isPlaceholder(v) || v.includes("{{")) return value;
4037
+ if (credentialName(name) || /^(proxy-)?authorization$|^cookie$|^sig$|^key$/i.test(name.trim())) return hiddenAs(name);
4038
+ return SECRET_VALUE.test(v) ? DOTS : withoutKeysInText(value, /* @__PURE__ */ new Set());
4039
+ }
4040
+ function shownQuery(query) {
4041
+ return query.split("&").map((part) => {
4042
+ const eq = part.indexOf("=");
4043
+ if (eq < 0) return withoutKeysInText(part, /* @__PURE__ */ new Set());
4044
+ const value = decoded(part.slice(eq + 1));
4045
+ const shown = shownParam(decoded(part.slice(0, eq)), value);
4046
+ return shown === value ? withoutKeysInText(part, /* @__PURE__ */ new Set()) : `${part.slice(0, eq)}=${shown}`;
4047
+ }).join("&");
4048
+ }
4049
+ function shownAddress(address, random = false) {
4050
+ const at = withoutUserinfo(address.trim());
4051
+ const end = at.search(/[?#]/);
4052
+ const head = end < 0 ? at : at.slice(0, end);
4053
+ const scheme = head.match(/^[a-z][a-z\d+.-]*:\/\/[^/]*/i)?.[0] ?? "";
4054
+ const path = head.slice(scheme.length).split("/").map((segment) => {
4055
+ const s = decoded(segment);
4056
+ if (!s || s.includes("{") || isPlaceholder(s)) return segment;
4057
+ if (BOT_TOKEN.test(s)) return "<bot_token>";
4058
+ if (SECRET_VALUE.test(s) || random && randomToken(s)) return "<token>";
4059
+ return withoutKeysInText(segment, /* @__PURE__ */ new Set());
4060
+ }).join("/");
4061
+ if (end < 0) return scheme + path;
4062
+ const rest = at.slice(end).replace(/([?#])([^?#]*)/g, (_, mark, part) => `${mark}${shownQuery(part)}`);
4063
+ return scheme + path + rest;
4064
+ }
4065
+ function shownCommand(command) {
4066
+ const words2 = command.split(/(\s+)/);
4067
+ let after;
4068
+ return words2.map((word) => {
4069
+ if (/^\s+$/.test(word) || !word) return word;
4070
+ const option = after;
4071
+ after = void 0;
4072
+ if (option !== void 0) return /^-/.test(word) ? word : hiddenAs(option);
4073
+ const set2 = word.match(/^(-{0,2})([A-Za-z_][\w.-]*)=(.+)$/);
4074
+ if (set2 && credentialName(set2[2])) return `${set2[1]}${set2[2]}=${hiddenAs(set2[2])}`;
4075
+ const flag = word.match(/^--?([A-Za-z][\w-]*)$/);
4076
+ if (flag && credentialName(flag[1])) after = flag[1];
4077
+ return SECRET_VALUE.test(word) || randomToken(word) ? DOTS : withoutKeysInText(word, /* @__PURE__ */ new Set());
4078
+ }).join("");
4079
+ }
4080
+ function decoded(text3) {
4081
+ try {
4082
+ return decodeURIComponent(text3.replace(/\+/g, " "));
4083
+ } catch {
4084
+ return text3;
4085
+ }
4086
+ }
4087
+
4088
+ // ../../lib/storyboard/timing.ts
4089
+ var VOICE_LEAD = 400;
4090
+ var VOICE_TAIL = 600;
4091
+ function activeScenes(sb) {
4092
+ return sb.scenes.filter((s) => sb.settings.showFailure || !s.failurePath);
4093
+ }
4094
+ function sceneDuration(sb, scene) {
4095
+ if (!sb.settings.voiceover || !scene.voiceMs) return scene.duration;
4096
+ return Math.max(scene.duration, Math.ceil(VOICE_LEAD + scene.voiceMs + VOICE_TAIL));
4097
+ }
4098
+ function totalDuration(sb) {
4099
+ return activeScenes(sb).reduce((sum, s) => sum + sceneDuration(sb, s), 0);
4100
+ }
4101
+ function summaryItems(sb) {
4102
+ const items = [];
4103
+ let failure;
4104
+ for (const scene of activeScenes(sb)) {
4105
+ if (!scene.summaryLine) continue;
4106
+ if (scene.kind === "call" && scene.outcome === "failure") {
4107
+ failure = scene.summaryLine;
4108
+ continue;
4109
+ }
4110
+ items.push(scene.summaryLine);
4111
+ if (failure) items.push(failure);
4112
+ failure = void 0;
4113
+ }
4114
+ if (failure) items.push(failure);
4115
+ return items;
4116
+ }
4117
+
3940
4118
  // ../../lib/render/code.ts
3941
4119
  function codeRequest(sb, scene) {
3942
4120
  let url = /^[a-z][a-z\d+.-]*:\/\//i.test(scene.path) ? scene.path : `${sb.api.baseUrl}${scene.path}`;
@@ -4314,23 +4492,6 @@ function pretty(value, as, indent) {
4314
4492
  return text3.split("\n").map((line) => line.replace(/("(?:[^"\\]|\\.)*")|\b(true|false|null)\b/g, (_, str2, word) => str2 ?? { true: "True", false: "False", null: "None" }[word]));
4315
4493
  }
4316
4494
 
4317
- // ../../lib/text.ts
4318
- function cut(text3, max) {
4319
- const end = Math.max(0, max);
4320
- const last = text3.charCodeAt(end - 1);
4321
- return text3.slice(0, last >= 55296 && last <= 56319 ? end - 1 : end);
4322
- }
4323
- var HALVES = /[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDFFF]/g;
4324
- function wellFormed(text3) {
4325
- return text3.replace(HALVES, (c) => c.length === 2 ? c : "");
4326
- }
4327
- function clip(text3, max) {
4328
- return text3.length > max ? `${cut(text3, max - 1)}\u2026` : text3;
4329
- }
4330
- function plainText(markdown) {
4331
- return markdown.replace(/<[^>]+>/g, " ").replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\*\*|__|`/g, "").replace(/(^|\s)[*_]([^*_\s][^*_]*?)[*_](?=[\s.,;:!?)]|$)/g, "$1$2").replace(/^\s{0,3}(#{1,6}|>)\s+/gm, "").replace(/\s+/g, " ").trim();
4332
- }
4333
-
4334
4495
  // ../../lib/render/frame.ts
4335
4496
  var WATERMARK = "Made with integrationtour.com";
4336
4497
  var DARK = {
@@ -5259,68 +5420,47 @@ function pointer(root, path) {
5259
5420
  }
5260
5421
 
5261
5422
  // ../../lib/oas/postman.ts
5262
- var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
5423
+ var isObj2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
5263
5424
  var PLACEHOLDER_HOST = "https://api.example.com";
5264
5425
  var SCHEMA_URL = /schema\.(get)?postman\.com\/json\/collection\/v(\d+)\.(\d+)/i;
5265
5426
  function collectionIn(raw) {
5266
- if (!isObj(raw)) return void 0;
5267
- const doc = isObj(raw.collection) ? raw.collection : raw;
5268
- if (!isObj(doc.info) || !Array.isArray(doc.item) || "openapi" in doc || "swagger" in doc) return void 0;
5427
+ if (!isObj2(raw)) return void 0;
5428
+ const doc = isObj2(raw.collection) ? raw.collection : raw;
5429
+ if (!isObj2(doc.info) || !Array.isArray(doc.item) || "openapi" in doc || "swagger" in doc) return void 0;
5269
5430
  return typeof doc.info.name === "string" || typeof doc.info.schema === "string" ? doc : void 0;
5270
5431
  }
5271
5432
  function isPostmanCollection(raw) {
5272
5433
  return collectionIn(raw) !== void 0;
5273
5434
  }
5274
5435
  function isPostmanV1(raw) {
5275
- return isObj(raw) && !isObj(raw.info) && typeof raw.name === "string" && Array.isArray(raw.requests) && (Array.isArray(raw.order) || Array.isArray(raw.folders));
5436
+ return isObj2(raw) && !isObj2(raw.info) && typeof raw.name === "string" && Array.isArray(raw.requests) && (Array.isArray(raw.order) || Array.isArray(raw.folders));
5276
5437
  }
5277
5438
  function isPostmanEnvironment(raw) {
5278
- return isObj(raw) && Array.isArray(raw.values) && (raw._postman_variable_scope === "environment" || raw._postman_variable_scope === "globals");
5279
- }
5280
- function secretName(name) {
5281
- if (/idempotency/i.test(name)) return false;
5282
- return /secret|passw(or)?d|pwd|token|api[-_]?key|apikey|credential|signature|session|cookie|bearer|jwt|^auth(orization)?$/i.test(name) || /(^|[_-])key$|[a-z0-9]Key$|^key$/i.test(name);
5283
- }
5284
- var SECRET_VALUE = /^(sk|rk)_(live|test)_|^whsec_|^gh[pousr]_|^github_pat_|^xox[abposr]-|^(AKIA|ASIA)[0-9A-Z]{12,}|^eyJ[\w-]+\.[\w-]+|^(bearer|basic)\s|^sk-[\w-]{20,}|^AIza[\w-]{30,}|^ya29\.[\w-]{20,}|^SG\.[\w-]{16,}\.[\w-]{16,}|^npm_[A-Za-z0-9]{30,}|^glpat-[\w-]{20,}|^hf_[A-Za-z0-9]{30,}|^shp(at|ss|ca|pa)_[a-fA-F0-9]{32}|^sq0(atp|csp)-[\w-]{20,}|^-----BEGIN [A-Z ]*PRIVATE KEY-----/i;
5285
- function credentialName(name) {
5286
- if (/^key$/i.test(name.trim()) || /(type|kind|url|uri|endpoint|expires?(_?(in|at))?|name|count|length|hint|prefix)$/i.test(name)) return false;
5287
- return secretName(name) || /(^|[^a-z])auth([^a-z]|$)/i.test(name);
5288
- }
5289
- var BOT_TOKEN = /^bot\d{5,}:[\w-]{30,}$/;
5290
- var PREFIXED_ID = /^[a-z]{1,10}_/;
5291
- function pathSecret(segment) {
5292
- const s = segment.trim();
5293
- if (BOT_TOKEN.test(s)) return "bot_token";
5294
- if (SECRET_VALUE.test(s)) return "token";
5295
- const random = s.length >= 24 && /^[A-Za-z0-9_\-.~:]+$/.test(s) && /[a-z]/.test(s) && /[A-Z]/.test(s) && /\d/.test(s);
5296
- return random && !PREFIXED_ID.test(s) ? "token" : void 0;
5297
- }
5298
- function withoutUserinfo(address) {
5299
- return address.replace(/^([a-z][a-z\d+.-]*:\/\/)?[^/@\s]*@/i, (_, scheme) => scheme ?? "");
5300
- }
5301
- function hiddenAs(name) {
5302
- return /passw(or)?d|pwd/i.test(name) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : placeholder(name || "secret");
5439
+ return isObj2(raw) && Array.isArray(raw.values) && (raw._postman_variable_scope === "environment" || raw._postman_variable_scope === "globals");
5303
5440
  }
5304
5441
  function withoutCredential(name, value, hid) {
5305
- if (!given(value) || !(credentialName(name) || SECRET_VALUE.test(value.trim()))) return value;
5306
- hid.add(name || "a value");
5307
- return hiddenAs(name);
5442
+ if (!given(value)) return value;
5443
+ if (credentialName(name) || SECRET_VALUE.test(value.trim())) {
5444
+ hid.add(name || "a value");
5445
+ return credentialName(name) ? hiddenAs(name) : DOTS;
5446
+ }
5447
+ return withoutKeysInText(value, hid, name || "a value");
5308
5448
  }
5309
5449
  function withoutCredentials(value, hid, name = "", depth = 0) {
5310
5450
  if (depth > 40) return value;
5311
5451
  if (typeof value === "string") return withoutCredential(name, value, hid);
5312
5452
  if (Array.isArray(value)) return value.map((v) => withoutCredentials(v, hid, name, depth + 1));
5313
- if (isObj(value)) return Object.fromEntries(Object.entries(value).map(([key, v]) => [key, withoutCredentials(v, hid, key, depth + 1)]));
5453
+ if (isObj2(value)) return Object.fromEntries(Object.entries(value).map(([key, v]) => [key, withoutCredentials(v, hid, key, depth + 1)]));
5314
5454
  return value;
5315
5455
  }
5316
5456
  function readVariables(list7, into) {
5317
5457
  if (!Array.isArray(list7)) return;
5318
5458
  for (const v of list7) {
5319
- if (!isObj(v) || v.disabled === true || v.enabled === false) continue;
5459
+ if (!isObj2(v) || v.disabled === true || v.enabled === false) continue;
5320
5460
  const key = typeof v.key === "string" ? v.key.trim() : typeof v.id === "string" ? v.id.trim() : "";
5321
- const value = typeof v.value === "string" ? v.value : typeof v.value === "number" || typeof v.value === "boolean" ? String(v.value) : isObj(v.value) || Array.isArray(v.value) ? JSON.stringify(v.value) : "";
5461
+ const value = typeof v.value === "string" ? v.value : typeof v.value === "number" || typeof v.value === "boolean" ? String(v.value) : isObj2(v.value) || Array.isArray(v.value) ? JSON.stringify(v.value) : "";
5322
5462
  if (!key || value === "") continue;
5323
- into.set(key, { value, secret: v.type === "secret" || secretName(key) || SECRET_VALUE.test(value.trim()) });
5463
+ into.set(key, { value, secret: v.type === "secret" || secretName(key) || credentialName(key) || SECRET_VALUE.test(value.trim()) || randomToken(value) });
5324
5464
  }
5325
5465
  }
5326
5466
  var VARIABLE = /\{\{([^{}]+)\}\}/g;
@@ -5365,7 +5505,7 @@ var Variables = class {
5365
5505
  }
5366
5506
  };
5367
5507
  function textOf(description) {
5368
- const text3 = typeof description === "string" ? description : isObj(description) && typeof description.content === "string" ? description.content : void 0;
5508
+ const text3 = typeof description === "string" ? description : isObj2(description) && typeof description.content === "string" ? description.content : void 0;
5369
5509
  return text3?.trim() ? text3.trim() : void 0;
5370
5510
  }
5371
5511
  function headerList(raw) {
@@ -5380,7 +5520,7 @@ function headerList(raw) {
5380
5520
  function pairs(raw) {
5381
5521
  if (!Array.isArray(raw)) return [];
5382
5522
  return raw.flatMap((p) => {
5383
- if (!isObj(p) || typeof p.key !== "string" || !p.key.trim()) return [];
5523
+ if (!isObj2(p) || typeof p.key !== "string" || !p.key.trim()) return [];
5384
5524
  const description = textOf(p.description);
5385
5525
  return [{ key: p.key.trim(), value: p.value === void 0 || p.value === null ? "" : String(p.value), disabled: p.disabled === true, ...description ? { description } : {} }];
5386
5526
  });
@@ -5388,11 +5528,11 @@ function pairs(raw) {
5388
5528
  function urlOf(request) {
5389
5529
  const url = request.url;
5390
5530
  if (typeof url === "string") return url.trim() ? parseUrl(url) : void 0;
5391
- if (!isObj(url)) return void 0;
5531
+ if (!isObj2(url)) return void 0;
5392
5532
  const raw = typeof url.raw === "string" && url.raw.trim() ? parseUrl(url.raw) : void 0;
5393
5533
  const host = Array.isArray(url.host) ? url.host.map(String).join(".") : typeof url.host === "string" ? url.host : raw?.host;
5394
5534
  if (host === void 0 && !raw) return void 0;
5395
- const path = Array.isArray(url.path) ? url.path.map((s) => isObj(s) ? String(s.value ?? "") : String(s)) : typeof url.path === "string" ? url.path.split("/") : raw?.path ?? [];
5535
+ const path = Array.isArray(url.path) ? url.path.map((s) => isObj2(s) ? String(s.value ?? "") : String(s)) : typeof url.path === "string" ? url.path.split("/") : raw?.path ?? [];
5396
5536
  const port = typeof url.port === "string" || typeof url.port === "number" ? String(url.port) : raw?.port;
5397
5537
  return {
5398
5538
  protocol: typeof url.protocol === "string" && url.protocol ? url.protocol : raw?.protocol,
@@ -5421,11 +5561,11 @@ function parseUrl(text3) {
5421
5561
  if (port) host = host.slice(0, -port[0].length);
5422
5562
  const query = search.split("&").filter(Boolean).map((pair) => {
5423
5563
  const eq = pair.indexOf("=");
5424
- return { key: decoded(eq < 0 ? pair : pair.slice(0, eq)), value: eq < 0 ? "" : decoded(pair.slice(eq + 1)), disabled: false };
5564
+ return { key: decoded2(eq < 0 ? pair : pair.slice(0, eq)), value: eq < 0 ? "" : decoded2(pair.slice(eq + 1)), disabled: false };
5425
5565
  });
5426
5566
  return { ...protocol ? { protocol: protocol[1] } : {}, host, ...port ? { port: port[1] } : {}, path: slash < 0 ? [] : rest.slice(slash + 1).split("/"), query, variables: [] };
5427
5567
  }
5428
- function decoded(text3) {
5568
+ function decoded2(text3) {
5429
5569
  try {
5430
5570
  return decodeURIComponent(text3.replace(/\+/g, " "));
5431
5571
  } catch {
@@ -5456,10 +5596,10 @@ function pathOf(url, vars, params, hid) {
5456
5596
  const colon = segment.match(/^:([A-Za-z_][\w-]*)(.*)$/);
5457
5597
  if (colon) {
5458
5598
  const [, name, rest] = colon;
5459
- if (!params.has(name)) params.set(name, colonParam(name, url.variables, vars));
5599
+ if (!params.has(name)) params.set(name, colonParam(name, url.variables, vars, hid));
5460
5600
  return `{${name}}${vars.fill(rest, false)}`;
5461
5601
  }
5462
- const secret = segment.includes("{{") ? void 0 : pathSecret(decoded(segment));
5602
+ const secret = segment.includes("{{") ? void 0 : pathSecret(decoded2(segment));
5463
5603
  if (secret) {
5464
5604
  let param = secret;
5465
5605
  for (let n = 2; params.has(param); n++) param = `${secret}_${n}`;
@@ -5479,19 +5619,22 @@ function pathOf(url, vars, params, hid) {
5479
5619
  });
5480
5620
  return `/${out.join("/")}`;
5481
5621
  }
5482
- function colonParam(name, variables, vars) {
5483
- const variable = variables.find((v) => isObj(v) && (v.key === name || v.id === name));
5484
- const value = isObj(variable) && variable.value !== void 0 && variable.value !== null ? vars.fill(String(variable.value), false).trim() : "";
5485
- const description = isObj(variable) ? textOf(variable.description) : void 0;
5486
- return { name, in: "path", required: true, schema: isPlaceholder2(value) ? placeholderSchema(value) : { type: "string" }, ...given(value) ? { example: value } : {}, ...description ? { description } : {} };
5622
+ function colonParam(name, variables, vars, hid) {
5623
+ const variable = variables.find((v) => isObj2(v) && (v.key === name || v.id === name));
5624
+ const value = isObj2(variable) && variable.value !== void 0 && variable.value !== null ? vars.fill(String(variable.value), false).trim() : "";
5625
+ const description = isObj2(variable) ? textOf(variable.description) : void 0;
5626
+ const secret = given(value) && (credentialName(name) || SECRET_VALUE.test(value) || randomToken(value));
5627
+ if (secret) hid.add(name);
5628
+ const example = secret ? placeholder(name) : value;
5629
+ return { name, in: "path", required: true, schema: isPlaceholder2(value) ? placeholderSchema(value) : { type: "string" }, ...given(value) ? { example } : {}, ...description ? { description } : {} };
5487
5630
  }
5488
5631
  function valueOf(value) {
5489
5632
  return isPlaceholder2(value) ? { schema: placeholderSchema(value) } : { schema: { type: "string" }, example: value };
5490
5633
  }
5491
5634
  function settingsOf(auth, type2) {
5492
5635
  const raw = auth[type2];
5493
- if (Array.isArray(raw)) return Object.fromEntries(raw.flatMap((s) => isObj(s) && typeof s.key === "string" ? [[s.key, s.value]] : []));
5494
- return isObj(raw) ? raw : {};
5636
+ if (Array.isArray(raw)) return Object.fromEntries(raw.flatMap((s) => isObj2(s) && typeof s.key === "string" ? [[s.key, s.value]] : []));
5637
+ return isObj2(raw) ? raw : {};
5495
5638
  }
5496
5639
  var SIGNED = {
5497
5640
  oauth1: ["oauth1", "OAuth"],
@@ -5676,7 +5819,7 @@ function holdsPlaceholder(value, depth = 0) {
5676
5819
  if (isPlaceholder2(value)) return true;
5677
5820
  if (depth > 12) return false;
5678
5821
  if (Array.isArray(value)) return value.some((v) => holdsPlaceholder(v, depth + 1));
5679
- return isObj(value) && Object.values(value).some((v) => holdsPlaceholder(v, depth + 1));
5822
+ return isObj2(value) && Object.values(value).some((v) => holdsPlaceholder(v, depth + 1));
5680
5823
  }
5681
5824
  var given = (value) => value.trim() !== "" && !value.includes("{{") && !isPlaceholder2(value);
5682
5825
  function schemaOf(value, options, depth = 0) {
@@ -5686,7 +5829,7 @@ function schemaOf(value, options, depth = 0) {
5686
5829
  const first = value.find((v) => v !== null && v !== void 0);
5687
5830
  return { type: "array", items: first === void 0 ? {} : schemaOf(first, options, depth + 1), ...options.examples && !holdsPlaceholder(value) ? { example: value } : {} };
5688
5831
  }
5689
- if (isObj(value)) {
5832
+ if (isObj2(value)) {
5690
5833
  const keys = Object.keys(value);
5691
5834
  const required = options.required === "all" ? keys : options.required ? keys.filter((k) => !isPlaceholder2(value[k])) : [];
5692
5835
  return { type: "object", properties: Object.fromEntries(keys.map((k) => [k, schemaOf(value[k], options, depth + 1)])), ...required.length ? { required } : {} };
@@ -5702,28 +5845,28 @@ function payloadOf(value, required) {
5702
5845
  return { schema: schemaOf(value, { required }), example: value };
5703
5846
  }
5704
5847
  function bodyOf(raw, contentType, vars, hid) {
5705
- if (!isObj(raw) || raw.disabled === true) return void 0;
5848
+ if (!isObj2(raw) || raw.disabled === true) return void 0;
5706
5849
  const mode = typeof raw.mode === "string" ? raw.mode : "";
5707
5850
  switch (mode) {
5708
5851
  case "raw": {
5709
5852
  const text3 = typeof raw.raw === "string" ? raw.raw : "";
5710
5853
  if (!text3.trim()) return void 0;
5711
- const options = isObj(raw.options) && isObj(raw.options.raw) ? raw.options.raw : {};
5854
+ const options = isObj2(raw.options) && isObj2(raw.options.raw) ? raw.options.raw : {};
5712
5855
  const language = typeof options.language === "string" ? options.language.toLowerCase() : "";
5713
5856
  const type2 = contentType ?? RAW_TYPES[language] ?? (looksJson(text3) ? "application/json" : "text/plain");
5714
5857
  if (/json/i.test(type2)) {
5715
5858
  const value = jsonBody(text3, vars);
5716
5859
  if (value !== void 0) return { media: type2, ...payloadOf(withoutCredentials(value, hid), true) };
5717
- return { media: "text/plain", schema: { type: "string" }, example: vars.fill(text3) };
5860
+ return { media: "text/plain", schema: { type: "string" }, example: withoutCredentialsInText(vars.fill(text3), hid) };
5718
5861
  }
5719
- return { media: type2, schema: { type: "string" }, example: vars.fill(text3) };
5862
+ return { media: type2, schema: { type: "string" }, example: withoutCredentialsInText(vars.fill(text3), hid) };
5720
5863
  }
5721
5864
  case "urlencoded":
5722
5865
  case "formdata": {
5723
5866
  const multipart = mode === "formdata";
5724
5867
  const fields = pairs(raw[mode]);
5725
5868
  if (!fields.length) return void 0;
5726
- const files = new Set(Array.isArray(raw[mode]) ? raw[mode].flatMap((f) => multipart && isObj(f) && f.type === "file" && typeof f.key === "string" ? [f.key.trim()] : []) : []);
5869
+ const files = new Set(Array.isArray(raw[mode]) ? raw[mode].flatMap((f) => multipart && isObj2(f) && f.type === "file" && typeof f.key === "string" ? [f.key.trim()] : []) : []);
5727
5870
  const entries = fields.map((f) => {
5728
5871
  const key = vars.fill(f.key, false);
5729
5872
  return { key, file: files.has(f.key), value: withoutCredential(key, vars.fill(f.value, !f.disabled), hid), field: f };
@@ -5745,10 +5888,10 @@ function bodyOf(raw, contentType, vars, hid) {
5745
5888
  case "file":
5746
5889
  return { media: contentType ?? "application/octet-stream", schema: { type: "string", format: "binary" } };
5747
5890
  case "graphql": {
5748
- const g = isObj(raw.graphql) ? raw.graphql : {};
5749
- const query = typeof g.query === "string" ? vars.fill(g.query) : "";
5891
+ const g = isObj2(raw.graphql) ? raw.graphql : {};
5892
+ const query = typeof g.query === "string" ? withoutCredentialsInText(vars.fill(g.query), hid) : "";
5750
5893
  if (!query.trim()) return void 0;
5751
- const sent = typeof g.variables === "string" && g.variables.trim() ? jsonBody(g.variables, vars) : isObj(g.variables) ? g.variables : void 0;
5894
+ const sent = typeof g.variables === "string" && g.variables.trim() ? jsonBody(g.variables, vars) : isObj2(g.variables) ? g.variables : void 0;
5752
5895
  const variables = sent === void 0 ? void 0 : withoutCredentials(sent, hid);
5753
5896
  const example = { query, ...variables !== void 0 ? { variables } : {} };
5754
5897
  return { media: "application/json", ...payloadOf(example, true) };
@@ -5760,20 +5903,20 @@ function bodyOf(raw, contentType, vars, hid) {
5760
5903
  function responsesOf(saved, requestName, hid) {
5761
5904
  const out = {};
5762
5905
  for (const r of saved) {
5763
- if (!isObj(r)) continue;
5906
+ if (!isObj2(r)) continue;
5764
5907
  const code = typeof r.code === "number" && r.code >= 100 && r.code < 600 ? r.code : 200;
5765
5908
  const status = String(Math.trunc(code));
5766
5909
  if (out[status]) continue;
5767
5910
  const headers = headerList(r.header);
5768
5911
  const type2 = mainType(headers.find((h) => /^content-type$/i.test(h.key))?.value) ?? PREVIEW_TYPES[String(r._postman_previewlanguage)];
5769
- const name = typeof r.name === "string" ? r.name.trim() : "";
5912
+ const name = typeof r.name === "string" ? withoutKeysInText(r.name.trim(), hid) : "";
5770
5913
  const response = { description: (name !== requestName ? name : "") || (typeof r.status === "string" ? r.status.trim() : "") };
5771
5914
  if (headers.some((h) => /^retry-after$/i.test(h.key))) response.headers = { "Retry-After": { schema: { type: "integer" } } };
5772
5915
  const body = typeof r.body === "string" ? r.body : "";
5773
5916
  if (body.trim()) {
5774
5917
  const value = (type2 ? /json/i.test(type2) : looksJson(body)) ? parseJson(body) : void 0;
5775
5918
  if (value !== void 0) response.content = { [type2 ?? "application/json"]: payloadOf(withoutCredentials(value, hid), "all") };
5776
- else response.content = { [type2 && !/json/i.test(type2) ? type2 : "text/plain"]: { schema: { type: "string" }, example: body } };
5919
+ else response.content = { [type2 && !/json/i.test(type2) ? type2 : "text/plain"]: { schema: { type: "string" }, example: withoutCredentialsInText(body, hid) } };
5777
5920
  }
5778
5921
  out[status] = response;
5779
5922
  }
@@ -5799,17 +5942,17 @@ function operationIdFor(name, used) {
5799
5942
  used.add(unique);
5800
5943
  return unique;
5801
5944
  }
5802
- var ownAuth = (auth) => isObj(auth) && auth.type !== "inherit" ? auth : void 0;
5945
+ var ownAuth = (auth) => isObj2(auth) && auth.type !== "inherit" ? auth : void 0;
5803
5946
  function collect(items, folder, auth, out, counts, depth = 0) {
5804
5947
  if (!Array.isArray(items) || depth > 50) return;
5805
5948
  for (const item of items) {
5806
- if (!isObj(item)) continue;
5807
- const name = typeof item.name === "string" ? item.name.trim() : "";
5949
+ if (!isObj2(item)) continue;
5950
+ const name = typeof item.name === "string" ? withoutKeysInText(item.name.trim(), /* @__PURE__ */ new Set()) : "";
5808
5951
  if (Array.isArray(item.item)) {
5809
5952
  collect(item.item, name || folder, ownAuth(item.auth) ?? auth, out, counts, depth + 1);
5810
5953
  continue;
5811
5954
  }
5812
- const request = typeof item.request === "string" ? { method: "GET", url: item.request } : isObj(item.request) ? item.request : void 0;
5955
+ const request = typeof item.request === "string" ? { method: "GET", url: item.request } : isObj2(item.request) ? item.request : void 0;
5813
5956
  if (!request) {
5814
5957
  counts.noRequest++;
5815
5958
  continue;
@@ -5821,7 +5964,7 @@ function collect(items, folder, auth, out, counts, depth = 0) {
5821
5964
  function versionOf(v) {
5822
5965
  if (typeof v === "string") return v.trim();
5823
5966
  if (typeof v === "number") return String(v);
5824
- if (isObj(v) && typeof v.major === "number") return `${v.major}.${Number(v.minor) || 0}.${Number(v.patch) || 0}${typeof v.identifier === "string" && v.identifier ? `-${v.identifier}` : ""}`;
5967
+ if (isObj2(v) && typeof v.major === "number") return `${v.major}.${Number(v.minor) || 0}.${Number(v.patch) || 0}${typeof v.identifier === "string" && v.identifier ? `-${v.identifier}` : ""}`;
5825
5968
  return "";
5826
5969
  }
5827
5970
  var sameRequirement = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
@@ -5894,11 +6037,11 @@ function convertPostman(raw, environments = [], source) {
5894
6037
  } else if (!known) shapes.set(shape, path);
5895
6038
  const item = paths[path] ??= {};
5896
6039
  const slots = FIXED_METHODS.has(method) ? item : item.additionalOperations ??= {};
5897
- const name = bareName(vars.fill(r.name, false));
6040
+ const name = withoutKeysInText(bareName(vars.fill(r.name, false)), hid);
5898
6041
  const responses = responsesOf(r.responses, r.name, hid);
5899
6042
  const success = Object.keys(responses).some((s) => /^2/.test(s));
5900
6043
  const existing = slots[method];
5901
- if (isObj(existing)) {
6044
+ if (isObj2(existing)) {
5902
6045
  const into = existing.responses;
5903
6046
  if (success && into["200"]?.[UNSAVED]) delete into["200"];
5904
6047
  for (const [status, response] of Object.entries(responses)) into[status] ??= response;
@@ -5952,7 +6095,7 @@ function convertPostman(raw, environments = [], source) {
5952
6095
  const op = {
5953
6096
  ...operationId ? { operationId } : {},
5954
6097
  ...namesUrl(name) || !name ? {} : { summary: name },
5955
- ...r.description ? { description: r.description } : {},
6098
+ ...r.description ? { description: withoutKeysInText(r.description, hid) } : {},
5956
6099
  ...r.folder ? { tags: [r.folder] } : {},
5957
6100
  ...parameters.length ? { parameters } : {},
5958
6101
  ...body ? { requestBody: { ...BODILESS.has(lowered) ? {} : { required: true }, content: { [body.media]: { schema: body.schema, ...body.example !== void 0 ? { example: body.example } : {} } } } } : {},
@@ -5995,10 +6138,11 @@ function convertPostman(raw, environments = [], source) {
5995
6138
  if (notes.has("oauth2")) warnings.push("The OAuth 2.0 settings don't give the URLs its grant needs, so the video shows the access token being sent, not fetched.");
5996
6139
  const unknown = [...notes].filter((n) => n !== "oauth2");
5997
6140
  if (unknown.length) warnings.push(`${app}'s ${list2(unknown)} auth can't be shown, so requests that use it show none.`);
5998
- const description = textOf(info.description);
6141
+ const about = textOf(info.description);
6142
+ const description = about && withoutKeysInText(about, /* @__PURE__ */ new Set());
5999
6143
  const doc = {
6000
6144
  openapi: custom ? "3.2.0" : "3.0.3",
6001
- info: { title: typeof info.name === "string" && info.name.trim() ? info.name.trim() : `${app} collection`, version: versionOf(info.version), ...description ? { description } : {} },
6145
+ info: { title: typeof info.name === "string" && info.name.trim() ? withoutKeysInText(info.name.trim(), /* @__PURE__ */ new Set()) : `${app} collection`, version: versionOf(info.version), ...description ? { description } : {} },
6002
6146
  servers: [{ url: top }],
6003
6147
  paths,
6004
6148
  ...Object.keys(schemes.byName).length ? { components: { securitySchemes: schemes.byName } } : {},
@@ -6009,17 +6153,17 @@ function convertPostman(raw, environments = [], source) {
6009
6153
  }
6010
6154
 
6011
6155
  // ../../lib/oas/insomnia.ts
6012
- var isObj2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
6156
+ var isObj3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
6013
6157
  var V5_TYPE = /^(collection|spec|environment|mock|mcpClient)\.insomnia(\.rest)?\/5\.\d+$/;
6014
6158
  var INSOMNIA_IDS = "x-insomnia-requests";
6015
6159
  function insomniaKind(raw) {
6016
- if (!isObj2(raw)) return void 0;
6160
+ if (!isObj3(raw)) return void 0;
6017
6161
  if (typeof raw.type === "string") {
6018
6162
  const kind = raw.type.match(V5_TYPE)?.[1];
6019
6163
  return kind === "spec" ? "design" : kind === "mcpClient" ? "mcp" : kind;
6020
6164
  }
6021
6165
  if (raw._type !== "export" || !Array.isArray(raw.resources)) return void 0;
6022
- const resources = raw.resources.filter(isObj2);
6166
+ const resources = raw.resources.filter(isObj3);
6023
6167
  const workspace = resources.find((r) => r._type === "workspace");
6024
6168
  if (workspace?.scope === "design" || resources.some((r) => r._type === "api_spec" && typeof r.contents === "string" && r.contents.trim())) return "design";
6025
6169
  if (workspace || resources.some((r) => r._type === "request")) return "collection";
@@ -6027,11 +6171,11 @@ function insomniaKind(raw) {
6027
6171
  return "collection";
6028
6172
  }
6029
6173
  function insomniaMcpUrl(raw) {
6030
- const request = isObj2(raw) && isObj2(raw.mcpRequest) ? raw.mcpRequest : void 0;
6174
+ const request = isObj3(raw) && isObj3(raw.mcpRequest) ? raw.mcpRequest : void 0;
6031
6175
  return typeof request?.url === "string" && /^https?:\/\//i.test(request.url.trim()) ? request.url.trim() : void 0;
6032
6176
  }
6033
6177
  function readInsomnia(raw, parseYaml2) {
6034
- if (!isObj2(raw)) throw new Error("Not an Insomnia export.");
6178
+ if (!isObj3(raw)) throw new Error("Not an Insomnia export.");
6035
6179
  const workspace = typeof raw.type === "string" ? fromV5(raw) : fromV4(raw, parseYaml2);
6036
6180
  const notes = [...workspace.notes];
6037
6181
  if (isOpenApi(workspace.spec)) {
@@ -6043,22 +6187,22 @@ function readInsomnia(raw, parseYaml2) {
6043
6187
  return { ...converted, label: `an Insomnia collection (export format ${workspace.format})`, notes: [...notes, ...converted.notes] };
6044
6188
  }
6045
6189
  function isOpenApi(doc) {
6046
- return isObj2(doc) && (doc.openapi !== void 0 || doc.swagger !== void 0);
6190
+ return isObj3(doc) && (doc.openapi !== void 0 || doc.swagger !== void 0);
6047
6191
  }
6048
6192
  var text = (v) => typeof v === "string" ? v : "";
6049
6193
  var textOrUndefined = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
6050
6194
  var sortKey = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
6051
6195
  var bySortKey = (nodes2) => nodes2.map((n, i) => ({ n, i })).sort((a, b) => a.n.sortKey - b.n.sortKey || a.i - b.i).map(({ n }) => n);
6052
6196
  function fromV5(raw) {
6053
- const meta = isObj2(raw.meta) ? raw.meta : {};
6054
- const spec = isObj2(raw.spec) ? raw.spec : void 0;
6055
- const environments = isObj2(raw.environments) ? raw.environments : void 0;
6056
- const subs = Array.isArray(environments?.subEnvironments) ? environments.subEnvironments.filter(isObj2).map(v5Environment) : [];
6197
+ const meta = isObj3(raw.meta) ? raw.meta : {};
6198
+ const spec = isObj3(raw.spec) ? raw.spec : void 0;
6199
+ const environments = isObj3(raw.environments) ? raw.environments : void 0;
6200
+ const subs = Array.isArray(environments?.subEnvironments) ? environments.subEnvironments.filter(isObj3).map(v5Environment) : [];
6057
6201
  return {
6058
6202
  name: textOrUndefined(raw.name) ?? "Insomnia collection",
6059
6203
  ...textOrUndefined(meta.description) ? { description: textOrUndefined(meta.description) } : {},
6060
6204
  format: "5",
6061
- ...spec && isObj2(spec.contents) && Object.keys(spec.contents).length ? { spec: spec.contents } : {},
6205
+ ...spec && isObj3(spec.contents) && Object.keys(spec.contents).length ? { spec: spec.contents } : {},
6062
6206
  ...spec && typeof spec.file === "string" ? { specFile: spec.file } : {},
6063
6207
  items: v5Nodes(raw.collection, 0),
6064
6208
  ...environments ? { base: v5Environment(environments) } : {},
@@ -6067,14 +6211,14 @@ function fromV5(raw) {
6067
6211
  };
6068
6212
  }
6069
6213
  function v5Environment(env) {
6070
- const meta = isObj2(env.meta) ? env.meta : {};
6214
+ const meta = isObj3(env.meta) ? env.meta : {};
6071
6215
  const secret = new Set(Array.isArray(env.confidentialKeys) ? env.confidentialKeys.filter((k) => typeof k === "string") : []);
6072
- return { name: textOrUndefined(env.name) ?? "Environment", data: isObj2(env.data) ? env.data : {}, secret, private: meta.isPrivate === true, sortKey: sortKey(meta.sortKey) };
6216
+ return { name: textOrUndefined(env.name) ?? "Environment", data: isObj3(env.data) ? env.data : {}, secret, private: meta.isPrivate === true, sortKey: sortKey(meta.sortKey) };
6073
6217
  }
6074
6218
  function v5Nodes(list7, depth) {
6075
6219
  if (!Array.isArray(list7) || depth > 50) return [];
6076
- return list7.filter(isObj2).map((item) => {
6077
- const meta = isObj2(item.meta) ? item.meta : {};
6220
+ return list7.filter(isObj3).map((item) => {
6221
+ const meta = isObj3(item.meta) ? item.meta : {};
6078
6222
  const id = text(meta.id);
6079
6223
  const base = { id, name: text(item.name).trim(), ...textOrUndefined(meta.description) ? { description: textOrUndefined(meta.description) } : {}, private: meta.isPrivate === true, sortKey: sortKey(meta.sortKey) };
6080
6224
  if (Array.isArray(item.children) || item.method === void 0 && item.url === void 0) {
@@ -6084,7 +6228,7 @@ function v5Nodes(list7, depth) {
6084
6228
  });
6085
6229
  }
6086
6230
  function fromV4(raw, parseYaml2) {
6087
- const resources = raw.resources.filter(isObj2);
6231
+ const resources = raw.resources.filter(isObj3);
6088
6232
  const notes = [];
6089
6233
  const children = /* @__PURE__ */ new Map();
6090
6234
  for (const r of resources) {
@@ -6125,8 +6269,8 @@ function fromV4(raw, parseYaml2) {
6125
6269
  const base = environments[0];
6126
6270
  const env = (r) => ({
6127
6271
  name: textOrUndefined(r.name) ?? "Environment",
6128
- data: isObj2(r.data) ? r.data : {},
6129
- secret: new Set(Array.isArray(r.kvPairData) ? r.kvPairData.filter((p) => isObj2(p) && (p.type === "secret" || p.isConfidential === true) && typeof p.name === "string").map((p) => String(p.name)) : []),
6272
+ data: isObj3(r.data) ? r.data : {},
6273
+ secret: new Set(Array.isArray(r.kvPairData) ? r.kvPairData.filter((p) => isObj3(p) && (p.type === "secret" || p.isConfidential === true) && typeof p.name === "string").map((p) => String(p.name)) : []),
6130
6274
  private: r.isPrivate === true,
6131
6275
  sortKey: sortKey(r.metaSortKey)
6132
6276
  });
@@ -6149,14 +6293,14 @@ function pickEnvironment(subs) {
6149
6293
  const reachable = usable(subs).filter((s) => !THIS_MACHINE.test(JSON.stringify(s.data)));
6150
6294
  return reachable.find((s) => PUBLIC_ENV.test(s.name)) ?? reachable.find((s) => !LOCAL_ENV.test(s.name)) ?? reachable[0];
6151
6295
  }
6152
- function flatten(data, secret, into, prefix = "", depth = 0) {
6296
+ function flatten(data, secret, into, prefix = "", depth = 0, inside2 = false) {
6153
6297
  if (depth > 10) return;
6154
6298
  for (const [key, value] of Object.entries(data)) {
6155
6299
  const name = prefix ? `${prefix}.${key}` : key;
6156
- const marked = secret.has(name) || secret.has(key);
6157
- if (isObj2(value)) {
6300
+ const marked = inside2 || secret.has(name) || secret.has(key);
6301
+ if (isObj3(value)) {
6158
6302
  into.set(name, { value: JSON.stringify(value), secret: marked });
6159
- flatten(value, secret, into, name, depth + 1);
6303
+ flatten(value, secret, into, name, depth + 1, marked || credentialName(key));
6160
6304
  } else if (Array.isArray(value)) into.set(name, { value: JSON.stringify(value), secret: marked });
6161
6305
  else if (value !== null && value !== void 0) into.set(name, { value: String(value), secret: marked });
6162
6306
  }
@@ -6184,6 +6328,11 @@ function variableName(expression) {
6184
6328
  e = e.replace(/\[\s*(['"])(.*?)\1\s*\]/g, ".$2").replace(/^\./, "");
6185
6329
  return e && !/[{}"']/.test(e) ? e : void 0;
6186
6330
  }
6331
+ function promptDefault(args) {
6332
+ const [title, label, value, , masked] = args;
6333
+ const asks = [label, title].some((t) => typeof t === "string" && credentialName(t.trim().replace(/\s+/g, "_")));
6334
+ return typeof value === "string" && value && masked !== true && !asks ? value : void 0;
6335
+ }
6187
6336
  function tagArgs(source) {
6188
6337
  const out = [];
6189
6338
  for (const m of source.matchAll(/'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)"|(-?\d+(?:\.\d+)?)|\b(true|false)\b/g)) {
@@ -6251,18 +6400,13 @@ function tagValue(tag2, args, names, context) {
6251
6400
  case "response":
6252
6401
  return `{{${unclaimed(responseField(args, context.requests), defined)}}}`;
6253
6402
  case "prompt": {
6254
- const [title, label, value, , masked] = args;
6255
- if (typeof value === "string" && value && masked !== true) return translate(value, names, context);
6256
- return `{{${unclaimed(wordsName(String(label || title || ""), "prompt"), defined)}}}`;
6257
- }
6258
- case "base64": {
6259
- const [action, , value] = args;
6260
- if (action === "encode" && typeof value === "string" && !/[{%]/.test(value)) {
6261
- const bytes = new TextEncoder().encode(value);
6262
- return btoa(String.fromCharCode(...bytes));
6263
- }
6264
- return `{{${unclaimed(tag2, defined)}}}`;
6403
+ const value = promptDefault(args);
6404
+ if (value !== void 0) return translate(value, names, context);
6405
+ return `{{${unclaimed(wordsName(String(args[1] || args[0] || ""), "prompt"), defined)}}}`;
6265
6406
  }
6407
+ // What a base64 tag encodes is nearly always a credential (Basic auth's "user:password"), and
6408
+ // its encoding gives it back to anyone: like a hash, a cookie, another request's field, a
6409
+ // file and a vault's secret, there's nothing to show.
6266
6410
  default:
6267
6411
  return `{{${unclaimed(tag2.replace(/[^\w]+/g, "_"), defined)}}}`;
6268
6412
  }
@@ -6270,14 +6414,14 @@ function tagValue(tag2, args, names, context) {
6270
6414
  var OWN_HEADER = (name, value) => /^user-agent$/i.test(name) && /^insomnia\//i.test(value.trim());
6271
6415
  function pairsOf(list7) {
6272
6416
  if (!Array.isArray(list7)) return [];
6273
- return list7.filter(isObj2).flatMap((p) => {
6417
+ return list7.filter(isObj3).flatMap((p) => {
6274
6418
  const name = text(p.name);
6275
6419
  if (!name.trim()) return [];
6276
6420
  return [{ name, value: typeof p.value === "string" ? p.value : p.value === void 0 || p.value === null ? "" : String(p.value), disabled: p.disabled === true, ...textOrUndefined(p.description) ? { description: textOrUndefined(p.description) } : {} }];
6277
6421
  });
6278
6422
  }
6279
6423
  function ownAuth2(auth) {
6280
- return isObj2(auth) && typeof auth.type === "string" && auth.type !== "none" && auth.disabled !== true ? auth : void 0;
6424
+ return isObj3(auth) && typeof auth.type === "string" && auth.type !== "none" && auth.disabled !== true ? auth : void 0;
6281
6425
  }
6282
6426
  var GRANTS2 = {
6283
6427
  authorization_code: "authorization_code",
@@ -6313,14 +6457,14 @@ function postmanAuth(auth, tr) {
6313
6457
  }
6314
6458
  var JSON_TYPE = /[/+]json$/i;
6315
6459
  function postmanBody(body, tr) {
6316
- if (!isObj2(body)) return {};
6460
+ if (!isObj3(body)) return {};
6317
6461
  const media = text(body.mimeType).trim().toLowerCase();
6318
6462
  const params = pairsOf(body.params);
6319
6463
  if (media === "application/x-www-form-urlencoded") {
6320
6464
  return params.length ? { body: { mode: "urlencoded", urlencoded: params.map((p) => ({ key: tr(p.name), value: tr(p.value), disabled: p.disabled, ...p.description ? { description: p.description } : {} })) }, media } : {};
6321
6465
  }
6322
6466
  if (media.startsWith("multipart/")) {
6323
- const raw = Array.isArray(body.params) ? body.params.filter(isObj2) : [];
6467
+ const raw = Array.isArray(body.params) ? body.params.filter(isObj3) : [];
6324
6468
  const fields = raw.filter((p) => text(p.name).trim());
6325
6469
  return fields.length ? { body: { mode: "formdata", formdata: fields.map((p) => ({ key: tr(text(p.name)), value: tr(text(p.value)), type: p.type === "file" ? "file" : "text", ...text(p.fileName) ? { src: text(p.fileName) } : {}, disabled: p.disabled === true })) }, media: "multipart/form-data" } : {};
6326
6470
  }
@@ -6332,7 +6476,7 @@ function postmanBody(body, tr) {
6332
6476
  } catch {
6333
6477
  parsed = void 0;
6334
6478
  }
6335
- if (isObj2(parsed) && typeof parsed.query === "string" && parsed.query.trim()) {
6479
+ if (isObj3(parsed) && typeof parsed.query === "string" && parsed.query.trim()) {
6336
6480
  return { body: { mode: "graphql", graphql: { query: parsed.query, ...parsed.variables !== void 0 && parsed.variables !== null ? { variables: JSON.stringify(parsed.variables) } : {} } }, media: "application/json" };
6337
6481
  }
6338
6482
  return {};
@@ -6348,9 +6492,9 @@ function folderNames(items, taken, into) {
6348
6492
  if (!node2.children || depth > 50) continue;
6349
6493
  const names = new Map(inherited);
6350
6494
  const env = node2.fields.environment;
6351
- if (isObj2(env) && Object.keys(env).length) {
6495
+ if (isObj3(env) && Object.keys(env).length) {
6352
6496
  const values = /* @__PURE__ */ new Map();
6353
- const secret = new Set([...Array.isArray(node2.fields.confidentialKeys) ? node2.fields.confidentialKeys : [], ...Array.isArray(node2.fields.kvPairData) ? node2.fields.kvPairData.filter((p) => isObj2(p) && p.type === "secret").map((p) => p.name) : []].filter((k) => typeof k === "string"));
6497
+ const secret = new Set([...Array.isArray(node2.fields.confidentialKeys) ? node2.fields.confidentialKeys : [], ...Array.isArray(node2.fields.kvPairData) ? node2.fields.kvPairData.filter((p) => isObj3(p) && p.type === "secret").map((p) => p.name) : []].filter((k) => typeof k === "string"));
6354
6498
  flatten(env, secret, values);
6355
6499
  for (const [name, v] of values) {
6356
6500
  const known = into.get(name) ?? taken.get(name);
@@ -6438,11 +6582,11 @@ function postmanRequest(node2, inheritedHeaders, tr) {
6438
6582
  const query = [
6439
6583
  ...q < 0 ? [] : url.slice(q + 1).split("&").filter(Boolean).map((pair) => {
6440
6584
  const eq = pair.indexOf("=");
6441
- return { key: decoded2(eq < 0 ? pair : pair.slice(0, eq)), value: eq < 0 ? "" : decoded2(pair.slice(eq + 1)) };
6585
+ return { key: decoded3(eq < 0 ? pair : pair.slice(0, eq)), value: eq < 0 ? "" : decoded3(pair.slice(eq + 1)) };
6442
6586
  }),
6443
6587
  ...pairsOf(f.parameters).map((p) => ({ key: tr(p.name), value: tr(p.value), ...p.disabled ? { disabled: true } : {}, ...p.description ? { description: p.description } : {} }))
6444
6588
  ];
6445
- const pathParameters = Array.isArray(f.pathParameters) ? f.pathParameters.filter(isObj2) : [];
6589
+ const pathParameters = Array.isArray(f.pathParameters) ? f.pathParameters.filter(isObj3) : [];
6446
6590
  return {
6447
6591
  id: node2.id,
6448
6592
  name: node2.name,
@@ -6457,7 +6601,7 @@ function postmanRequest(node2, inheritedHeaders, tr) {
6457
6601
  response: []
6458
6602
  };
6459
6603
  }
6460
- function decoded2(value) {
6604
+ function decoded3(value) {
6461
6605
  try {
6462
6606
  return decodeURIComponent(value.replace(/\+/g, " "));
6463
6607
  } catch {
@@ -6466,15 +6610,15 @@ function decoded2(value) {
6466
6610
  }
6467
6611
 
6468
6612
  // ../../lib/oas/swagger1.ts
6469
- var isObj3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
6613
+ var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
6470
6614
  function isSwagger1(doc) {
6471
- return isObj3(doc) && doc.swaggerVersion !== void 0 && doc.swagger === void 0 && doc.openapi === void 0;
6615
+ return isObj4(doc) && doc.swaggerVersion !== void 0 && doc.swagger === void 0 && doc.openapi === void 0;
6472
6616
  }
6473
6617
  function namesDeclarations(doc) {
6474
- return !inline(doc) && arr(doc.apis).some((api) => isObj3(api) && typeof api.path === "string");
6618
+ return !inline(doc) && arr(doc.apis).some((api) => isObj4(api) && typeof api.path === "string");
6475
6619
  }
6476
6620
  function inline(doc) {
6477
- return doc.resourcePath !== void 0 || arr(doc.apis).some((api) => isObj3(api) && api.operations !== void 0);
6621
+ return doc.resourcePath !== void 0 || arr(doc.apis).some((api) => isObj4(api) && api.operations !== void 0);
6478
6622
  }
6479
6623
  function declarationUrls(listing, url) {
6480
6624
  const out = /* @__PURE__ */ new Map();
@@ -6489,7 +6633,7 @@ function declarationUrls(listing, url) {
6489
6633
  }
6490
6634
  if (String(listing.swaggerVersion) === "1.0" && /\.json$/i.test(base.pathname)) base = new URL(".", base);
6491
6635
  for (const api of arr(listing.apis)) {
6492
- if (!isObj3(api) || typeof api.path !== "string" || api.operations !== void 0) continue;
6636
+ if (!isObj4(api) || typeof api.path !== "string" || api.operations !== void 0) continue;
6493
6637
  const path = api.path.replace("{format}", "json");
6494
6638
  try {
6495
6639
  const target = /^[a-z][a-z\d+.-]*:/i.test(path) ? new URL(path) : new URL(`${base.href.replace(/\/$/, "")}/${path.replace(/^\//, "")}`);
@@ -6506,9 +6650,9 @@ function convertSwagger1(root, declaration = () => void 0) {
6506
6650
  if (inline(root)) resources.push({ doc: root });
6507
6651
  else {
6508
6652
  for (const api of arr(root.apis)) {
6509
- if (!isObj3(api) || typeof api.path !== "string") continue;
6653
+ if (!isObj4(api) || typeof api.path !== "string") continue;
6510
6654
  const doc2 = declaration(api.path);
6511
- if (!isObj3(doc2)) {
6655
+ if (!isObj4(doc2)) {
6512
6656
  missing.push(api.path);
6513
6657
  continue;
6514
6658
  }
@@ -6516,13 +6660,13 @@ function convertSwagger1(root, declaration = () => void 0) {
6516
6660
  resources.push({ doc: doc2, tag: name ? { name, ...typeof api.description === "string" ? { description: api.description } : {} } : void 0 });
6517
6661
  }
6518
6662
  }
6519
- const models = new Set(resources.flatMap(({ doc: doc2 }) => isObj3(doc2.models) ? Object.keys(doc2.models) : []));
6663
+ const models = new Set(resources.flatMap(({ doc: doc2 }) => isObj4(doc2.models) ? Object.keys(doc2.models) : []));
6520
6664
  const types2 = new TypeMapper(models);
6521
- const { definitions: securityDefinitions, names: securityNames } = securityDefinitionsOf(isObj3(root.authorizations) ? root.authorizations : {});
6665
+ const { definitions: securityDefinitions, names: securityNames } = securityDefinitionsOf(isObj4(root.authorizations) ? root.authorizations : {});
6522
6666
  const security = (auth) => {
6523
- if (!isObj3(auth)) return void 0;
6667
+ if (!isObj4(auth)) return void 0;
6524
6668
  return Object.entries(auth).flatMap(
6525
- ([name, scopes]) => (securityNames.get(name) ?? [name]).map((n) => ({ [n]: arr(scopes).flatMap((s) => isObj3(s) && typeof s.scope === "string" ? [s.scope] : []) }))
6669
+ ([name, scopes]) => (securityNames.get(name) ?? [name]).map((n) => ({ [n]: arr(scopes).flatMap((s) => isObj4(s) && typeof s.scope === "string" ? [s.scope] : []) }))
6526
6670
  );
6527
6671
  };
6528
6672
  const bases = resources.map(({ doc: doc2 }) => baseOf(doc2.basePath ?? root.basePath, root.basePath));
@@ -6534,7 +6678,7 @@ function convertSwagger1(root, declaration = () => void 0) {
6534
6678
  const definitions = {};
6535
6679
  let anySecurity = false;
6536
6680
  resources.forEach(({ doc: doc2, tag: tag2 }, i) => {
6537
- Object.assign(definitions, definitionsOf(isObj3(doc2.models) ? doc2.models : {}, types2));
6681
+ Object.assign(definitions, definitionsOf(isObj4(doc2.models) ? doc2.models : {}, types2));
6538
6682
  const defaults = {
6539
6683
  produces: strings(doc2.produces),
6540
6684
  consumes: strings(doc2.consumes),
@@ -6542,11 +6686,11 @@ function convertSwagger1(root, declaration = () => void 0) {
6542
6686
  tags: tag2 ? [tag2.name] : void 0
6543
6687
  };
6544
6688
  for (const api of arr(doc2.apis)) {
6545
- if (!isObj3(api) || typeof api.path !== "string" || !Array.isArray(api.operations)) continue;
6689
+ if (!isObj4(api) || typeof api.path !== "string" || !Array.isArray(api.operations)) continue;
6546
6690
  const path = `${prefixes[i].slice(common2.length)}/${api.path.replace(/^\//, "").replace("{format}", "json")}`.replace(/\/$/, "") || "/";
6547
- const item = isObj3(paths[path]) ? paths[path] : paths[path] = {};
6691
+ const item = isObj4(paths[path]) ? paths[path] : paths[path] = {};
6548
6692
  for (const op of api.operations) {
6549
- if (!isObj3(op)) continue;
6693
+ if (!isObj4(op)) continue;
6550
6694
  const method = String(op.method ?? op.httpMethod ?? "get").toLowerCase();
6551
6695
  const opSecurity = security(op.authorizations) ?? defaults.security;
6552
6696
  if (opSecurity?.length) anySecurity = true;
@@ -6558,7 +6702,7 @@ function convertSwagger1(root, declaration = () => void 0) {
6558
6702
  deprecated: lenient(op.deprecated) === true ? true : void 0,
6559
6703
  produces: strings(op.produces) ?? defaults.produces,
6560
6704
  consumes: strings(op.consumes) ?? defaults.consumes,
6561
- parameters: arr(op.parameters).flatMap((p) => isObj3(p) ? [parameterOf(p, types2)] : []),
6705
+ parameters: arr(op.parameters).flatMap((p) => isObj4(p) ? [parameterOf(p, types2)] : []),
6562
6706
  responses: responsesOf2(op, types2),
6563
6707
  security: opSecurity
6564
6708
  });
@@ -6569,7 +6713,7 @@ function convertSwagger1(root, declaration = () => void 0) {
6569
6713
  });
6570
6714
  const firstScheme = Object.keys(securityDefinitions)[0];
6571
6715
  const host = origin && origin !== "null" ? new URL(origin) : void 0;
6572
- const info = isObj3(root.info) ? root.info : {};
6716
+ const info = isObj4(root.info) ? root.info : {};
6573
6717
  const doc = clean({
6574
6718
  swagger: "2.0",
6575
6719
  info: clean({
@@ -6642,11 +6786,11 @@ var TypeMapper = class {
6642
6786
  const out = this.named(old.type ?? old.dataType ?? old.responseClass ?? old.$ref, allowRef);
6643
6787
  if (old.items !== void 0) {
6644
6788
  const items = typeof old.items === "string" ? { type: old.items } : old.items;
6645
- if (isObj3(items)) out.items = this.data(items, allowRef);
6789
+ if (isObj4(items)) out.items = this.data(items, allowRef);
6646
6790
  }
6647
- if (out.type === "array" && !isObj3(out.items)) out.items = {};
6791
+ if (out.type === "array" && !isObj4(out.items)) out.items = {};
6648
6792
  const defaultValue = old.defaultValue ?? old.default;
6649
- const allowable = isObj3(old.allowableValues) ? old.allowableValues : void 0;
6793
+ const allowable = isObj4(old.allowableValues) ? old.allowableValues : void 0;
6650
6794
  const valueType = String(allowable?.valueType ?? "").toUpperCase();
6651
6795
  return clean({
6652
6796
  ...out,
@@ -6696,14 +6840,14 @@ function parameterOf(old, types2) {
6696
6840
  if (where === "body") return { ...base, schema: types2.data(old, true) };
6697
6841
  let schema2 = types2.data(old, false);
6698
6842
  if (schema2.type === void 0 || schema2.$ref !== void 0) schema2 = { ...schema2, $ref: void 0, type: "string" };
6699
- if (schema2.type === "array" && isObj3(schema2.items) && schema2.items.type === void 0) schema2.items = { ...schema2.items, type: "string" };
6843
+ if (schema2.type === "array" && isObj4(schema2.items) && schema2.items.type === void 0) schema2.items = { ...schema2.items, type: "string" };
6700
6844
  if (lenient(old.allowMultiple) === true && schema2.type !== "array") schema2 = { type: "array", items: schema2 };
6701
6845
  return clean({ ...base, ...schema2 });
6702
6846
  }
6703
6847
  function responsesOf2(op, types2) {
6704
6848
  const responses = {};
6705
6849
  for (const r of [...arr(op.responseMessages), ...arr(op.errorResponses)]) {
6706
- if (!isObj3(r) || r.code === void 0) continue;
6850
+ if (!isObj4(r) || r.code === void 0) continue;
6707
6851
  const schema2 = types2.named(r.responseModel, true);
6708
6852
  responses[String(r.code)] = clean({ description: String(r.message ?? r.reason ?? ""), schema: Object.keys(schema2).length ? schema2 : void 0 });
6709
6853
  }
@@ -6715,10 +6859,10 @@ function responsesOf2(op, types2) {
6715
6859
  }
6716
6860
  function definitionsOf(models, types2) {
6717
6861
  const out = {};
6718
- for (const [id, model] of Object.entries(models)) if (isObj3(model)) out[id] = modelOf(model, types2);
6862
+ for (const [id, model] of Object.entries(models)) if (isObj4(model)) out[id] = modelOf(model, types2);
6719
6863
  for (const [id, parent] of Object.entries(models)) {
6720
- for (const child of arr(isObj3(parent) ? parent.subTypes : void 0)) {
6721
- if (typeof child !== "string" || !isObj3(out[child])) continue;
6864
+ for (const child of arr(isObj4(parent) ? parent.subTypes : void 0)) {
6865
+ if (typeof child !== "string" || !isObj4(out[child])) continue;
6722
6866
  const current2 = out[child];
6723
6867
  out[child] = { allOf: [...Array.isArray(current2.allOf) ? current2.allOf : [current2], { $ref: `#/definitions/${id}` }] };
6724
6868
  }
@@ -6728,8 +6872,8 @@ function definitionsOf(models, types2) {
6728
6872
  function modelOf(old, types2) {
6729
6873
  const properties = {};
6730
6874
  const required = Array.isArray(old.required) ? old.required.filter((r) => typeof r === "string") : [];
6731
- for (const [name, prop] of Object.entries(isObj3(old.properties) ? old.properties : {})) {
6732
- if (!isObj3(prop)) continue;
6875
+ for (const [name, prop] of Object.entries(isObj4(old.properties) ? old.properties : {})) {
6876
+ if (!isObj4(prop)) continue;
6733
6877
  if (lenient(prop.required) === true && !required.includes(name)) required.push(name);
6734
6878
  properties[name] = modelOf(prop, types2);
6735
6879
  }
@@ -6741,15 +6885,15 @@ function modelOf(old, types2) {
6741
6885
  properties: Object.keys(properties).length ? properties : void 0,
6742
6886
  discriminator: typeof old.discriminator === "string" ? old.discriminator : void 0,
6743
6887
  example: old.example,
6744
- items: isObj3(old.items) ? modelOf(old.items, types2) : void 0
6888
+ items: isObj4(old.items) ? modelOf(old.items, types2) : void 0
6745
6889
  });
6746
6890
  }
6747
6891
  function securityDefinitionsOf(old) {
6748
6892
  const definitions = {};
6749
6893
  const names = /* @__PURE__ */ new Map();
6750
6894
  for (const [name, auth] of Object.entries(old)) {
6751
- if (!isObj3(auth)) continue;
6752
- const scopes = Object.fromEntries(arr(auth.scopes).flatMap((s) => isObj3(s) && typeof s.scope === "string" ? [[s.scope, typeof s.description === "string" ? s.description : s.scope]] : []));
6895
+ if (!isObj4(auth)) continue;
6896
+ const scopes = Object.fromEntries(arr(auth.scopes).flatMap((s) => isObj4(s) && typeof s.scope === "string" ? [[s.scope, typeof s.description === "string" ? s.description : s.scope]] : []));
6753
6897
  if (auth.type === "basicAuth" || auth.type === "basic") {
6754
6898
  definitions[name] = { type: "basic" };
6755
6899
  names.set(name, [name]);
@@ -6757,11 +6901,11 @@ function securityDefinitionsOf(old) {
6757
6901
  definitions[name] = { type: "apiKey", in: auth.passAs === "query" ? "query" : "header", name: typeof auth.keyname === "string" ? auth.keyname : "api_key" };
6758
6902
  names.set(name, [name]);
6759
6903
  } else if (auth.type === "oauth2") {
6760
- const grants = isObj3(auth.grantTypes) ? Object.entries(auth.grantTypes) : [];
6904
+ const grants = isObj4(auth.grantTypes) ? Object.entries(auth.grantTypes) : [];
6761
6905
  const made = [];
6762
6906
  for (const [grant, detail] of grants) {
6763
- const d = isObj3(detail) ? detail : {};
6764
- const endpoint = (key2) => isObj3(d[key2]) && typeof d[key2].url === "string" ? d[key2].url : void 0;
6907
+ const d = isObj4(detail) ? detail : {};
6908
+ const endpoint = (key2) => isObj4(d[key2]) && typeof d[key2].url === "string" ? d[key2].url : void 0;
6765
6909
  const flow = grant === "implicit" ? clean({ flow: "implicit", authorizationUrl: endpoint("loginEndpoint") }) : grant === "authorization_code" ? clean({ flow: "accessCode", authorizationUrl: endpoint("tokenRequestEndpoint"), tokenUrl: endpoint("tokenEndpoint") }) : void 0;
6766
6910
  if (!flow) continue;
6767
6911
  const key = grants.length > 1 ? `${name}_${flow.flow}` : name;
@@ -6790,7 +6934,7 @@ function clean(obj) {
6790
6934
  for (const [key, value] of Object.entries(obj)) {
6791
6935
  if (value === void 0) continue;
6792
6936
  if (Array.isArray(value) && value.length === 0) continue;
6793
- if (isObj3(value) && Object.keys(value).length === 0 && key !== "paths" && key !== "schema" && key !== "items") continue;
6937
+ if (isObj4(value) && Object.keys(value).length === 0 && key !== "paths" && key !== "schema" && key !== "items") continue;
6794
6938
  out[key] = value;
6795
6939
  }
6796
6940
  return out;
@@ -6803,27 +6947,27 @@ function strings(value) {
6803
6947
  }
6804
6948
 
6805
6949
  // ../../lib/oas/swagger2.ts
6806
- var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
6950
+ var isObj5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
6807
6951
  var SCHEMA_FIELDS = ["type", "format", "items", "enum", "default", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "minLength", "maxLength", "pattern", "minItems", "maxItems", "uniqueItems", "multipleOf"];
6808
6952
  var OAUTH_FLOWS = { implicit: "implicit", password: "password", application: "clientCredentials", accessCode: "authorizationCode" };
6809
6953
  function convertSwagger2(doc) {
6810
6954
  const consumes = strings2(doc.consumes) ?? ["application/json"];
6811
6955
  const produces = strings2(doc.produces) ?? ["application/json"];
6812
- const sharedParams = isObj4(doc.parameters) ? doc.parameters : {};
6956
+ const sharedParams = isObj5(doc.parameters) ? doc.parameters : {};
6813
6957
  const resolveParam = (p) => {
6814
- const ref = isObj4(p) && typeof p.$ref === "string" ? p.$ref.match(/^#\/parameters\/(.+)$/)?.[1] : void 0;
6958
+ const ref = isObj5(p) && typeof p.$ref === "string" ? p.$ref.match(/^#\/parameters\/(.+)$/)?.[1] : void 0;
6815
6959
  return ref !== void 0 ? sharedParams[decodePointer(ref)] : p;
6816
6960
  };
6817
6961
  const paths = {};
6818
- for (const [path, rawItem] of Object.entries(isObj4(doc.paths) ? doc.paths : {})) {
6819
- if (!isObj4(rawItem)) continue;
6962
+ for (const [path, rawItem] of Object.entries(isObj5(doc.paths) ? doc.paths : {})) {
6963
+ if (!isObj5(rawItem)) continue;
6820
6964
  const item = {};
6821
6965
  const pathParams = arr2(rawItem.parameters).map(resolveParam);
6822
- const plain = pathParams.filter((p) => isObj4(p) && p.in !== "body" && p.in !== "formData");
6966
+ const plain = pathParams.filter((p) => isObj5(p) && p.in !== "body" && p.in !== "formData");
6823
6967
  if (plain.length) item.parameters = plain.map(convertParameter);
6824
6968
  for (const method of ["get", "put", "post", "delete", "options", "head", "patch"]) {
6825
6969
  const op = rawItem[method];
6826
- if (!isObj4(op)) continue;
6970
+ if (!isObj5(op)) continue;
6827
6971
  const params = mergeParams(pathParams, arr2(op.parameters).map(resolveParam));
6828
6972
  const out2 = {};
6829
6973
  for (const key of ["operationId", "summary", "description", "tags", "deprecated", "security", "externalDocs"]) if (op[key] !== void 0) out2[key] = op[key];
@@ -6837,9 +6981,9 @@ function convertSwagger2(doc) {
6837
6981
  paths[path] = item;
6838
6982
  }
6839
6983
  const components = {};
6840
- if (isObj4(doc.definitions)) components.schemas = convertSchemas(doc.definitions);
6841
- if (isObj4(doc.responses)) components.responses = Object.fromEntries(Object.entries(doc.responses).map(([k, r]) => [k, convertResponse(r, produces)]));
6842
- if (isObj4(doc.securityDefinitions)) components.securitySchemes = Object.fromEntries(Object.entries(doc.securityDefinitions).map(([k, s]) => [k, convertSecurity(s)]));
6984
+ if (isObj5(doc.definitions)) components.schemas = convertSchemas(doc.definitions);
6985
+ if (isObj5(doc.responses)) components.responses = Object.fromEntries(Object.entries(doc.responses).map(([k, r]) => [k, convertResponse(r, produces)]));
6986
+ if (isObj5(doc.securityDefinitions)) components.securitySchemes = Object.fromEntries(Object.entries(doc.securityDefinitions).map(([k, s]) => [k, convertSecurity(s)]));
6843
6987
  const out = { openapi: "3.0.3", info: doc.info, paths, ...Object.keys(components).length ? { components } : {} };
6844
6988
  const servers = serversOf(doc);
6845
6989
  if (servers.length) out.servers = servers;
@@ -6858,11 +7002,11 @@ function serversOf(doc) {
6858
7002
  }
6859
7003
  function mergeParams(shared, own) {
6860
7004
  const byKey = /* @__PURE__ */ new Map();
6861
- for (const p of [...shared, ...own]) if (isObj4(p) && typeof p.name === "string") byKey.set(`${p.in}:${p.name}`, p);
7005
+ for (const p of [...shared, ...own]) if (isObj5(p) && typeof p.name === "string") byKey.set(`${p.in}:${p.name}`, p);
6862
7006
  return [...byKey.values()];
6863
7007
  }
6864
7008
  function convertParameter(raw) {
6865
- const p = isObj4(raw) ? raw : {};
7009
+ const p = isObj5(raw) ? raw : {};
6866
7010
  const out = { name: p.name, in: p.in };
6867
7011
  for (const key of ["description", "required", "deprecated", "allowEmptyValue"]) if (p[key] !== void 0) out[key] = p[key];
6868
7012
  out.schema = schemaFromFields(p);
@@ -6871,7 +7015,7 @@ function convertParameter(raw) {
6871
7015
  }
6872
7016
  function schemaFromFields(p) {
6873
7017
  const schema2 = {};
6874
- for (const key of SCHEMA_FIELDS) if (p[key] !== void 0) schema2[key] = key === "items" && isObj4(p.items) ? schemaFromFields(p.items) : p[key];
7018
+ for (const key of SCHEMA_FIELDS) if (p[key] !== void 0) schema2[key] = key === "items" && isObj5(p.items) ? schemaFromFields(p.items) : p[key];
6875
7019
  if (schema2.type === "file") return { type: "string", format: "binary" };
6876
7020
  return schema2;
6877
7021
  }
@@ -6893,15 +7037,15 @@ function requestBody(params, consumes) {
6893
7037
  }
6894
7038
  function convertResponses(raw, produces) {
6895
7039
  const out = {};
6896
- for (const [status, response] of Object.entries(isObj4(raw) ? raw : {})) out[status] = convertResponse(response, produces);
7040
+ for (const [status, response] of Object.entries(isObj5(raw) ? raw : {})) out[status] = convertResponse(response, produces);
6897
7041
  return out;
6898
7042
  }
6899
7043
  function convertResponse(raw, produces) {
6900
- const r = isObj4(raw) ? raw : {};
7044
+ const r = isObj5(raw) ? raw : {};
6901
7045
  if (typeof r.$ref === "string") return { $ref: r.$ref };
6902
7046
  const out = { description: typeof r.description === "string" ? r.description : "" };
6903
- if (isObj4(r.headers)) out.headers = Object.fromEntries(Object.entries(r.headers).map(([name, h]) => [name, { ...isObj4(h) && typeof h.description === "string" ? { description: h.description } : {}, schema: schemaFromFields(isObj4(h) ? h : {}) }]));
6904
- const examples = isObj4(r.examples) ? r.examples : {};
7047
+ if (isObj5(r.headers)) out.headers = Object.fromEntries(Object.entries(r.headers).map(([name, h]) => [name, { ...isObj5(h) && typeof h.description === "string" ? { description: h.description } : {}, schema: schemaFromFields(isObj5(h) ? h : {}) }]));
7048
+ const examples = isObj5(r.examples) ? r.examples : {};
6905
7049
  if (r.schema !== void 0 || Object.keys(examples).length) {
6906
7050
  const types2 = [.../* @__PURE__ */ new Set([...produces, ...Object.keys(examples)])];
6907
7051
  out.content = Object.fromEntries(
@@ -6915,7 +7059,7 @@ function convertSchemas(defs) {
6915
7059
  }
6916
7060
  function convertSchema(raw) {
6917
7061
  if (Array.isArray(raw)) return raw.map(convertSchema);
6918
- if (!isObj4(raw)) return raw;
7062
+ if (!isObj5(raw)) return raw;
6919
7063
  const out = {};
6920
7064
  for (const [key, value] of Object.entries(raw)) {
6921
7065
  if (key === "x-nullable") out.nullable = value;
@@ -6929,12 +7073,12 @@ function convertSchema(raw) {
6929
7073
  return out;
6930
7074
  }
6931
7075
  function convertSecurity(raw) {
6932
- const s = isObj4(raw) ? raw : {};
7076
+ const s = isObj5(raw) ? raw : {};
6933
7077
  if (s.type === "basic") return { type: "http", scheme: "basic", ...typeof s.description === "string" ? { description: s.description } : {} };
6934
7078
  if (s.type === "apiKey") return { type: "apiKey", name: s.name, in: s.in };
6935
7079
  if (s.type === "oauth2") {
6936
7080
  const flow = OAUTH_FLOWS[String(s.flow)] ?? "clientCredentials";
6937
- const details = { scopes: isObj4(s.scopes) ? s.scopes : {} };
7081
+ const details = { scopes: isObj5(s.scopes) ? s.scopes : {} };
6938
7082
  if (typeof s.authorizationUrl === "string") details.authorizationUrl = s.authorizationUrl;
6939
7083
  if (typeof s.tokenUrl === "string") details.tokenUrl = s.tokenUrl;
6940
7084
  return { type: "oauth2", flows: { [flow]: details } };
@@ -6943,7 +7087,7 @@ function convertSecurity(raw) {
6943
7087
  }
6944
7088
  function rewriteRefs(node2) {
6945
7089
  if (Array.isArray(node2)) return node2.map(rewriteRefs);
6946
- if (!isObj4(node2)) return node2;
7090
+ if (!isObj5(node2)) return node2;
6947
7091
  const out = {};
6948
7092
  for (const [key, value] of Object.entries(node2)) {
6949
7093
  if (key === "$ref" && typeof value === "string") out[key] = value.replace(/^#\/definitions\//, "#/components/schemas/").replace(/^#\/responses\//, "#/components/responses/");
@@ -6967,12 +7111,12 @@ var HTTP_METHODS = ["get", "post", "put", "patch", "delete", "head", "options",
6967
7111
  var SAFE_METHODS = /* @__PURE__ */ new Set(["get", "head", "options", "trace", "query"]);
6968
7112
  var METHOD_TOKEN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
6969
7113
  function operationsOf(item) {
6970
- if (!isObj5(item)) return [];
7114
+ if (!isObj6(item)) return [];
6971
7115
  const out = [];
6972
- for (const method of HTTP_METHODS) if (isObj5(item[method])) out.push([method, item[method]]);
6973
- if (isObj5(item.additionalOperations)) {
7116
+ for (const method of HTTP_METHODS) if (isObj6(item[method])) out.push([method, item[method]]);
7117
+ if (isObj6(item.additionalOperations)) {
6974
7118
  for (const [method, op] of Object.entries(item.additionalOperations)) {
6975
- if (isObj5(op) && METHOD_TOKEN.test(method) && !HTTP_METHODS.includes(method.toLowerCase())) out.push([method, op]);
7119
+ if (isObj6(op) && METHOD_TOKEN.test(method) && !HTTP_METHODS.includes(method.toLowerCase())) out.push([method, op]);
6976
7120
  }
6977
7121
  }
6978
7122
  return out;
@@ -6980,7 +7124,7 @@ function operationsOf(item) {
6980
7124
  function methodName(method) {
6981
7125
  return HTTP_METHODS.includes(method) ? method.toUpperCase() : method;
6982
7126
  }
6983
- function isObj5(value) {
7127
+ function isObj6(value) {
6984
7128
  return typeof value === "object" && value !== null && !Array.isArray(value);
6985
7129
  }
6986
7130
 
@@ -7801,10 +7945,10 @@ function toolOperation(shape, prefix, idFor, context, requiresAuth, style) {
7801
7945
  id: tool.name,
7802
7946
  method: "tools/call",
7803
7947
  path: tool.name,
7804
- summary: firstSentence(tool.description) ?? tool.title ?? label,
7948
+ summary: firstSentence2(tool.description) ?? tool.title ?? label,
7805
7949
  label,
7806
7950
  tags: [],
7807
- deprecated: [tool.title, firstSentence(tool.description)].some((text3) => typeof text3 === "string" && /\[deprecated\]|\(deprecated\)|^\W*deprecated\b/i.test(text3)),
7951
+ deprecated: [tool.title, firstSentence2(tool.description)].some((text3) => typeof text3 === "string" && /\[deprecated\]|\(deprecated\)|^\W*deprecated\b/i.test(text3)),
7808
7952
  resource: shape.provides ?? shape.noun,
7809
7953
  ...shape.verb ? { action: shape.verb } : {},
7810
7954
  pathParams: [],
@@ -7836,7 +7980,7 @@ function toolOperation(shape, prefix, idFor, context, requiresAuth, style) {
7836
7980
  function toolLabel(shape, prefix) {
7837
7981
  const { tool, verb } = shape;
7838
7982
  if (tool.title && (asLabel(tool.title) || tool.title.length <= 40)) return asLabel(tool.title) ?? (verbOf(tool.title.split(" ")[0]) ? sentenceCase(tool.title) : tool.title);
7839
- if (!verb) return asLabel(firstSentence(tool.description) ?? "") ?? tool.name;
7983
+ if (!verb) return asLabel(firstSentence2(tool.description) ?? "") ?? tool.name;
7840
7984
  const rest = shape.rest.length ? shape.rest.map(written) : prefix ? [capitalize(prefix)] : [];
7841
7985
  return capitalize([verb, ...rest].join(" "));
7842
7986
  }
@@ -7886,7 +8030,7 @@ function listTools(server, requiresAuth, style) {
7886
8030
  }
7887
8031
  function toolsListResult(tools, style) {
7888
8032
  return {
7889
- tools: tools.map((t) => ({ name: t.name, ...t.title ? { title: t.title } : {}, description: clip(firstSentence(t.description) ?? t.title ?? t.name, 90), inputSchema: t.inputSchema ?? { type: "object" } })),
8033
+ tools: tools.map((t) => ({ name: t.name, ...t.title ? { title: t.title } : {}, description: clip(firstSentence2(t.description) ?? t.title ?? t.name, 90), inputSchema: t.inputSchema ?? { type: "object" } })),
7890
8034
  ...resultFields(style, LIST_TTL_MS)
7891
8035
  };
7892
8036
  }
@@ -7908,7 +8052,7 @@ function readOperation(id, uri, name, description, mimeType, params, examples, r
7908
8052
  id,
7909
8053
  method: "resources/read",
7910
8054
  path: uri,
7911
- summary: firstSentence(description) ?? label,
8055
+ summary: firstSentence2(description) ?? label,
7912
8056
  label: clip(label, 60),
7913
8057
  tags: [],
7914
8058
  deprecated: false,
@@ -7933,7 +8077,7 @@ function promptOperation(prompt, requiresAuth, style) {
7933
8077
  id: `prompt:${prompt.name}`,
7934
8078
  method: "prompts/get",
7935
8079
  path: prompt.name,
7936
- summary: firstSentence(prompt.description) ?? label,
8080
+ summary: firstSentence2(prompt.description) ?? label,
7937
8081
  label: clip(label, 60),
7938
8082
  tags: [],
7939
8083
  deprecated: false,
@@ -7945,7 +8089,7 @@ function promptOperation(prompt, requiresAuth, style) {
7945
8089
  request: fixed(values, true),
7946
8090
  success: {
7947
8091
  status: "result",
7948
- payload: fixed({ messages: [{ role: "user", content: { type: "text", text: clip(firstSentence(prompt.description) ?? `${label}.`, 120) } }], ...resultFields(style) }, true)
8092
+ payload: fixed({ messages: [{ role: "user", content: { type: "text", text: clip(firstSentence2(prompt.description) ?? `${label}.`, 120) } }], ...resultFields(style) }, true)
7949
8093
  },
7950
8094
  errors: [],
7951
8095
  callbacks: [],
@@ -7999,7 +8143,7 @@ function objectShape(schema2, depth = 0) {
7999
8143
  if (Array.isArray(schema2.required)) required.push(...schema2.required.filter((r) => typeof r === "string"));
8000
8144
  return { properties, required: [...new Set(required)] };
8001
8145
  }
8002
- function firstSentence(text3) {
8146
+ function firstSentence2(text3) {
8003
8147
  if (!text3) return void 0;
8004
8148
  const plain = text3.replace(/\s+/g, " ").trim();
8005
8149
  if (!plain) return void 0;
@@ -8024,7 +8168,7 @@ function written(word) {
8024
8168
  // ../../lib/oas/model.ts
8025
8169
  var VERSION_SEGMENT = /^(v\d+(\.\d+)*|\d{4}-\d{2}-\d{2}|api|rest)$/i;
8026
8170
  function buildModel(doc) {
8027
- if (doc["x-mcp"]) return mcpModel(doc["x-mcp"]);
8171
+ if (doc["x-mcp"]) return shownModel(mcpModel(doc["x-mcp"]));
8028
8172
  const baseUrl = baseUrlOf(doc);
8029
8173
  const operations = [];
8030
8174
  const seen = /* @__PURE__ */ new Set();
@@ -8043,7 +8187,7 @@ function buildModel(doc) {
8043
8187
  webhooks.push(...webhooksFromPathItem(name, item));
8044
8188
  }
8045
8189
  for (const op of operations) webhooks.push(...op.callbacks);
8046
- return {
8190
+ return shownModel({
8047
8191
  title: doc.info.title,
8048
8192
  version: doc.info.version,
8049
8193
  description: doc.info.description,
@@ -8052,6 +8196,52 @@ function buildModel(doc) {
8052
8196
  auth: authOf2(doc),
8053
8197
  webhooks,
8054
8198
  tags: (Array.isArray(doc.tags) ? doc.tags : []).flatMap((t) => isObject2(t) && typeof t.name === "string" ? [t.name] : [])
8199
+ });
8200
+ }
8201
+ function shownModel(model) {
8202
+ const keys = (text3) => withoutKeysInText(text3, /* @__PURE__ */ new Set());
8203
+ const address = (url) => model.mcp && !/^[a-z][a-z\d+.-]*:\/\//i.test(url) ? shownCommand(url) : shownAddress(url, Boolean(model.mcp));
8204
+ const payload = (p) => {
8205
+ if (!p) return p;
8206
+ let memo;
8207
+ return {
8208
+ contentType: p.contentType,
8209
+ get value() {
8210
+ memo ??= { value: typeof p.value === "string" && isTextKind(mediaKind(p.contentType)) ? withoutCredentialsInText(p.value, /* @__PURE__ */ new Set()) : shownValue(p.value) };
8211
+ return memo.value;
8212
+ },
8213
+ get generated() {
8214
+ return p.generated;
8215
+ },
8216
+ ...p.schema ? { schema: p.schema } : {}
8217
+ };
8218
+ };
8219
+ const hooks = /* @__PURE__ */ new Map();
8220
+ const hook = (w) => {
8221
+ if (!hooks.has(w)) hooks.set(w, { ...w, summary: keys(w.summary), ...w.payload ? { payload: payload(w.payload) } : {} });
8222
+ return hooks.get(w);
8223
+ };
8224
+ return {
8225
+ ...model,
8226
+ title: keys(model.title),
8227
+ ...model.description ? { description: keys(model.description) } : {},
8228
+ baseUrl: address(model.baseUrl),
8229
+ operations: model.operations.map((op) => ({
8230
+ ...op,
8231
+ summary: keys(op.summary),
8232
+ // A label made from a summary that held a key spells the key as words: the summary names the call instead.
8233
+ ...op.label ? keys(op.summary) === op.summary ? { label: keys(op.label) } : { label: void 0 } : {},
8234
+ ...op.baseUrl ? { baseUrl: address(op.baseUrl) } : {},
8235
+ ...op.query ? { query: shownQuery(op.query) } : {},
8236
+ ...op.headers ? { headers: op.headers.map(([name, value]) => [name, shownParam(name, value)]) } : {},
8237
+ ...op.cookies ? { cookies: op.cookies.map(([name, value]) => [name, shownParam(name, value)]) } : {},
8238
+ pathParamExamples: Object.fromEntries(Object.entries(op.pathParamExamples).map(([name, value]) => [name, typeof value === "string" && (secretField(name) || SECRET_VALUE.test(value.trim())) && !isPlaceholder(value) ? placeholder(name) : value])),
8239
+ ...op.request ? { request: payload(op.request) } : {},
8240
+ ...op.success ? { success: { ...op.success, ...op.success.payload ? { payload: payload(op.success.payload) } : {} } } : {},
8241
+ errors: op.errors.map((e) => ({ ...e, ...e.description ? { description: keys(e.description) } : {}, ...e.payload ? { payload: payload(e.payload) } : {} })),
8242
+ callbacks: op.callbacks.map(hook)
8243
+ })),
8244
+ webhooks: model.webhooks.map(hook)
8055
8245
  };
8056
8246
  }
8057
8247
  var PATH_EXTENSION = /\.(json|xml|csv|ya?ml|html?|txt)$/i;
@@ -8074,7 +8264,8 @@ function pathVerb(segment) {
8074
8264
  const first = segment.match(/^[A-Za-z][a-z]*/)?.[0].toLowerCase();
8075
8265
  return first !== void 0 && first !== "file" && LABEL_VERBS.has(first);
8076
8266
  }
8077
- function toOperation(doc, baseUrl, path, method, op, item) {
8267
+ function toOperation(doc, baseUrl, path, method, written2, item) {
8268
+ const op = { ...written2, ...typeof written2.summary === "string" ? { summary: withoutKeysInText(written2.summary, /* @__PURE__ */ new Set()) } : {}, ...typeof written2.description === "string" ? { description: withoutKeysInText(written2.description, /* @__PURE__ */ new Set()) } : {} };
8078
8269
  const segments = routeSegments(path);
8079
8270
  const statics = [];
8080
8271
  segments.forEach((s, index) => {
@@ -8167,7 +8358,7 @@ function toOperation(doc, baseUrl, path, method, op, item) {
8167
8358
  id: said(op.operationId) ?? `${methodName(method)} ${path}`,
8168
8359
  method,
8169
8360
  path,
8170
- summary: (said(op.summary) ?? firstSentence2(op.description) ?? `${methodName(method)} ${path}`).trim(),
8361
+ summary: (said(op.summary) ?? firstSentence(op.description) ?? `${methodName(method)} ${path}`).trim(),
8171
8362
  get label() {
8172
8363
  if (label === null) label = specLabel(op);
8173
8364
  return label;
@@ -8275,7 +8466,7 @@ function webhooksFromPathItem(name, item, sourceOperationId) {
8275
8466
  out.push({
8276
8467
  name,
8277
8468
  method,
8278
- summary: (said(op.summary) ?? firstSentence2(op.description) ?? name).trim(),
8469
+ summary: (said(op.summary) ?? firstSentence(op.description) ?? name).trim(),
8279
8470
  // The API sends webhooks, so their bodies read like responses (no writeOnly fields).
8280
8471
  payload: media ? lazyPayload(type2, media, "response") : void 0,
8281
8472
  ...ack ? { ack: ack.toUpperCase() } : {},
@@ -8506,14 +8697,8 @@ function serverUrl(server) {
8506
8697
  function said(text3) {
8507
8698
  return typeof text3 === "string" && text3.trim() ? text3 : void 0;
8508
8699
  }
8509
- function firstSentence2(text3) {
8510
- if (!text3) return void 0;
8511
- const plain = text3.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim();
8512
- const match = plain.match(/^(.{1,90}?[.!?])(\s|$)/);
8513
- return match ? match[1] : cut(plain, 90);
8514
- }
8515
8700
  function saysDeprecated(op) {
8516
- return [op.summary, firstSentence2(op.description)].some((text3) => typeof text3 === "string" && /\[deprecated\]|\(deprecated\)|^\W*deprecated\b/i.test(text3));
8701
+ return [op.summary, firstSentence(op.description)].some((text3) => typeof text3 === "string" && /\[deprecated\]|\(deprecated\)|^\W*deprecated\b/i.test(text3));
8517
8702
  }
8518
8703
  var PRE_RELEASE = /\b(beta|preview|alpha|experimental)\b/i;
8519
8704
  var STAGE_FIELDS = ["x-release-status", "x-stability", "x-stability-level", "x-maturity", "x-status", "x-lifecycle"];
@@ -8547,7 +8732,7 @@ var QUALIFIER = /^(for|in|from|on|with|to|by|using|via|that|which|when|where|wit
8547
8732
  var LABEL_CUT = 40;
8548
8733
  var LABEL_MAX = 60;
8549
8734
  function specLabel(op) {
8550
- const texts = [op.summary, firstSentence2(op.description)];
8735
+ const texts = [op.summary, firstSentence(op.description)];
8551
8736
  if (!op.summary && !op.description && op.operationId && !/^(post|put|patch|head|options)/i.test(op.operationId)) texts.push(op.operationId);
8552
8737
  for (const text3 of texts) {
8553
8738
  const label = typeof text3 === "string" ? asLabel(text3) : void 0;
@@ -9899,7 +10084,7 @@ var DEFAULT_SETTINGS = { showFailure: false, aspect: "16:9", watermark: true, vo
9899
10084
  var RETRY_NOTE = "The retry succeeds.";
9900
10085
  function buildStoryboard(model, workflow, settings = {}) {
9901
10086
  const config = { ...DEFAULT_SETTINGS, ...settings, watermark: true };
9902
- if (model.mcp) return buildMcpStoryboard(model, workflow, config);
10087
+ if (model.mcp) return shownStoryboard(buildMcpStoryboard(model, workflow, config));
9903
10088
  const byId = new Map(model.operations.map((op) => [op.id, op]));
9904
10089
  const calls = workflow.steps.flatMap((step) => {
9905
10090
  const op = byId.get(step.operationId);
@@ -9971,15 +10156,60 @@ function buildStoryboard(model, workflow, settings = {}) {
9971
10156
  caption: "That's the whole integration."
9972
10157
  });
9973
10158
  const told = coherent(echoedIds(scenes, model), model);
9974
- return {
10159
+ return shownStoryboard({
9975
10160
  version: 1,
9976
10161
  api: { title: apiTitle, version: clip(model.version, 40), baseUrl: clip(model.baseUrl, 300) },
9977
10162
  workflow: { name, source: workflow.source },
9978
10163
  nodes: { client: "Your app", api: apiTitle, webhook: webhook ? "Your server" : void 0 },
9979
10164
  scenes: failure ? failuresAsRetried(told, model, failure.error, callAuth(ops[failure.index], auth)?.kind) : told,
9980
10165
  settings: config
10166
+ });
10167
+ }
10168
+ function shownStoryboard(sb) {
10169
+ const keys = (text3) => withoutKeysInText(text3, /* @__PURE__ */ new Set());
10170
+ const mcp = sb.api.protocol === "mcp";
10171
+ const url = (text3) => /^[a-z][a-z\d+.-]*:\/\//i.test(text3);
10172
+ const endpoint = (text3) => mcp && !url(text3) ? shownCommand(text3) : shownAddress(text3, mcp);
10173
+ const address = (text3) => !mcp || url(text3) ? shownAddress(text3, mcp) : keys(text3);
10174
+ return {
10175
+ ...sb,
10176
+ api: { ...sb.api, title: keys(sb.api.title), baseUrl: endpoint(sb.api.baseUrl) },
10177
+ workflow: { ...sb.workflow, name: keys(sb.workflow.name) },
10178
+ nodes: { ...sb.nodes, client: keys(sb.nodes.client), api: keys(sb.nodes.api) },
10179
+ scenes: sb.scenes.map((scene) => shownScene(scene, address))
9981
10180
  };
9982
10181
  }
10182
+ function shownScene(scene, address) {
10183
+ const keys = (text4) => withoutKeysInText(text4, /* @__PURE__ */ new Set());
10184
+ const payload = (value, type2) => typeof value === "string" && type2 ? withoutCredentialsInText(value, /* @__PURE__ */ new Set()) : shownValue(value);
10185
+ const text3 = { caption: keys(scene.caption), ...scene.speech ? { speech: keys(scene.speech) } : {}, ...scene.summaryLine ? { summaryLine: keys(scene.summaryLine) } : {} };
10186
+ switch (scene.kind) {
10187
+ case "title":
10188
+ return { ...scene, ...text3, title: keys(scene.title), subtitle: keys(scene.subtitle) };
10189
+ case "call":
10190
+ return {
10191
+ ...scene,
10192
+ ...text3,
10193
+ ...address ? { path: address(scene.path) } : {},
10194
+ ...scene.request !== void 0 ? { request: payload(scene.request, scene.requestType) } : {},
10195
+ ...scene.response !== void 0 ? { response: payload(scene.response, scene.responseType) } : {},
10196
+ ...scene.headers ? { headers: scene.headers.map(([name, value]) => [name, shownParam(name, value)]) } : {},
10197
+ ...scene.cookies ? { cookies: scene.cookies.map(([name, value]) => [name, shownParam(name, value)]) } : {},
10198
+ ...scene.recovery ? { recovery: keys(scene.recovery) } : {}
10199
+ };
10200
+ case "webhook":
10201
+ return { ...scene, ...text3, event: keys(scene.event), ...scene.payload !== void 0 ? { payload: payload(scene.payload, scene.payloadType) } : {} };
10202
+ case "auth":
10203
+ return {
10204
+ ...scene,
10205
+ ...text3,
10206
+ ...address && scene.tokenUrl ? { tokenUrl: address(scene.tokenUrl) } : {},
10207
+ ...address && scene.requestLine ? { requestLine: scene.requestLine.replace(/\S+$/, (url) => address(url)) } : {}
10208
+ };
10209
+ default:
10210
+ return { ...scene, ...text3 };
10211
+ }
10212
+ }
9983
10213
  function echoedIds(scenes, model) {
9984
10214
  let before = [];
9985
10215
  let current2 = scenes;
@@ -10132,7 +10362,7 @@ function failureScene(id, base, op, error, sends, fieldNames2 = op.bodyFields) {
10132
10362
  if (error.status === "isError") {
10133
10363
  const missing = invalid ? `the required argument "${invalid.field}" is missing` : void 0;
10134
10364
  const ending = isObject2(error.payload?.value) ? error.payload.value : {};
10135
- return {
10365
+ return shownScene({
10136
10366
  ...base,
10137
10367
  id,
10138
10368
  kind: "call",
@@ -10146,9 +10376,9 @@ function failureScene(id, base, op, error, sends, fieldNames2 = op.bodyFields) {
10146
10376
  recovery: clip(invalid ? `The model adds "${invalid.field}" and calls again` : "The model reads the error and calls again", 160),
10147
10377
  failurePath: true,
10148
10378
  summaryLine: "Recover from a tool error: the model fixes its arguments"
10149
- };
10379
+ });
10150
10380
  }
10151
- return {
10381
+ return shownScene({
10152
10382
  ...base,
10153
10383
  id,
10154
10384
  kind: "call",
@@ -10163,7 +10393,7 @@ function failureScene(id, base, op, error, sends, fieldNames2 = op.bodyFields) {
10163
10393
  recovery: clip(invalid ? `Add "${invalid.field}" and resend` : recoveryFor(error, op, sends), 160),
10164
10394
  failurePath: true,
10165
10395
  summaryLine: `Handle ${statusCode(error.status)}: ${lowerFirst2(recoveryFor(error, op, sends))}`
10166
- };
10396
+ });
10167
10397
  }
10168
10398
  var fieldNames = /* @__PURE__ */ new WeakMap();
10169
10399
  function fieldNamesOf(model) {
@@ -11070,8 +11300,151 @@ function unknownKeys(raw, known, where, problems) {
11070
11300
  for (const key of Object.keys(raw)) if (!known.includes(key)) problems.push(`${where} has \`${key}\`, which a flow file doesn't use there.`);
11071
11301
  }
11072
11302
 
11303
+ // ../../lib/storyboard/review.ts
11304
+ var KIND_WORDS = {
11305
+ email: "an email address",
11306
+ phone: "a phone number",
11307
+ address: "a private network's address",
11308
+ card: "a card number",
11309
+ account: "a bank account",
11310
+ id: "an ID number",
11311
+ key: "may be a key"
11312
+ };
11313
+ function reviewOf(sb) {
11314
+ const found = new Findings();
11315
+ found.address(sb.api.baseUrl, sb.api.protocol === "mcp" ? "the server's address" : "every call's address");
11316
+ for (const scene of sb.scenes) {
11317
+ if (scene.kind === "call") {
11318
+ const where = callName(scene.summaryLine, scene.caption);
11319
+ found.address(scene.path, where);
11320
+ for (const [name, value] of [...scene.headers ?? [], ...scene.cookies ?? []]) found.value(name, value, where, true);
11321
+ found.payload(scene.request, "", where);
11322
+ found.payload(scene.response, "", where);
11323
+ } else if (scene.kind === "webhook") found.payload(scene.payload, "", `the ${scene.event} webhook`);
11324
+ }
11325
+ return found.review();
11326
+ }
11327
+ function mergeReviews(reviews) {
11328
+ const found = new Findings();
11329
+ for (const r of reviews) {
11330
+ for (const name of r.hidden) found.hid(name);
11331
+ for (const f of r.check) found.add(f.kind, f.value, f.where);
11332
+ }
11333
+ return found.review();
11334
+ }
11335
+ function confirmLine(holds, videos = 2) {
11336
+ return `${videos === 1 ? "The video shows" : "The videos show"} what the ${holds} holds. Confirm that everything is correct and it holds no secrets or personal data`;
11337
+ }
11338
+ function reviewLines(review, max = 8) {
11339
+ if (!review.check.length) return [];
11340
+ const lines = ["May be personal or internal:"];
11341
+ for (const f of review.check.slice(0, max)) lines.push(` ${f.value} (${KIND_WORDS[f.kind]}), in ${f.where}`);
11342
+ if (review.check.length > max) lines.push(` \u2026and ${review.check.length - max} more.`);
11343
+ return lines;
11344
+ }
11345
+ function callName(summaryLine, caption) {
11346
+ const name = (summaryLine ?? "").replace(/\s*\([A-Z]+ [^)]*\)$/, "").trim();
11347
+ return name || caption.slice(0, 60);
11348
+ }
11349
+ var isObj7 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
11350
+ var Findings = class {
11351
+ hiddenNames = /* @__PURE__ */ new Set();
11352
+ checks = /* @__PURE__ */ new Map();
11353
+ hid(name) {
11354
+ if (name) this.hiddenNames.add(name);
11355
+ }
11356
+ add(kind, value, where) {
11357
+ const key = `${kind}|${value}`;
11358
+ if (!this.checks.has(key)) this.checks.set(key, { kind, value: value.length > 80 ? `${value.slice(0, 79)}\u2026` : value, where });
11359
+ }
11360
+ /** An address: a host on a private network, a random segment of its path, and its query's values. */
11361
+ address(address, where) {
11362
+ this.text(address, where);
11363
+ const query = address.indexOf("?");
11364
+ for (const segment of (query < 0 ? address : address.slice(0, query)).replace(/^[a-z][a-z\d+.-]*:\/\/[^/]*/i, "").split("/")) {
11365
+ if (/^<(bot_)?token>$/.test(segment)) this.hid("a token in the address");
11366
+ else if (mayBeKey("", segment)) this.add("key", segment, where);
11367
+ }
11368
+ if (query >= 0) {
11369
+ for (const part of address.slice(query + 1).split(/[&#]/)) {
11370
+ const eq = part.indexOf("=");
11371
+ if (eq > 0) this.value(decodeURIComponentSafe(part.slice(0, eq)), decodeURIComponentSafe(part.slice(eq + 1)), where, true);
11372
+ }
11373
+ }
11374
+ }
11375
+ /** A header's, a parameter's, a cookie's (`param`) or a field's value. */
11376
+ value(name, value, where, param) {
11377
+ const v = value.trim();
11378
+ if (!v) return;
11379
+ const secret = param ? credentialName(name) || /^(proxy-)?authorization$|^cookie$|^sig$|^key$/i.test(name.trim()) : secretField(name) || credentialName(name);
11380
+ if (v.includes(DOTS) || secret && (v === hiddenAs(name) || /^[A-Za-z][\w-]*\s+<token>$/.test(v))) {
11381
+ this.hid(name || "a value");
11382
+ return;
11383
+ }
11384
+ if (/^<[\w.-]+>$/.test(v) || v.includes("{{")) return;
11385
+ if (mayBeKey(name, v)) this.add("key", v, where);
11386
+ this.text(v, where);
11387
+ }
11388
+ /** A payload: each value by the field it's in, a text body as text. */
11389
+ payload(value, name, where, depth = 0) {
11390
+ if (depth > 40) return;
11391
+ if (typeof value === "string") this.value(name, value, where, false);
11392
+ else if (Array.isArray(value)) for (const v of value) this.payload(v, name, where, depth + 1);
11393
+ else if (isObj7(value)) for (const [key, v] of Object.entries(value)) this.payload(v, key, where, depth + 1);
11394
+ }
11395
+ /** Any text: the personal and internal values in it. */
11396
+ text(text3, where) {
11397
+ if (text3.length > 2e5) text3 = text3.slice(0, 2e5);
11398
+ for (const [, email, domain] of text3.matchAll(/\b([A-Za-z0-9._%+-]{1,64}@((?:[A-Za-z0-9-]{1,63}\.){1,8}[A-Za-z]{2,24}))\b/g)) if (!RESERVED_DOMAIN.test(domain)) this.add("email", email, where);
11399
+ for (const [phone] of text3.matchAll(/(?<![\w+])\+[1-9]\d{7,14}\b/g)) if (!/^\+1(\d{3}555|555)\d+$/.test(phone)) this.add("phone", phone, where);
11400
+ for (const [host] of text3.matchAll(PRIVATE_HOST)) this.add("address", host, where);
11401
+ for (const [run] of text3.matchAll(/(?<![\w-])(?:\d[ -]?){12,15}\d(?![\w-])/g)) {
11402
+ const digits = run.replace(/[ -]/g, "");
11403
+ if (/^(4\d{12}(\d{3})?|5[1-5]\d{14}|2[2-7]\d{14}|3[47]\d{13}|6(011|5\d\d)\d{12})$/.test(digits) && luhn(digits) && !TEST_CARDS.has(digits)) this.add("card", run, where);
11404
+ }
11405
+ for (const [iban] of text3.matchAll(/\b[A-Z]{2}\d{2}[A-Z0-9]{11,30}\b/g)) if (ibanValid(iban) && !EXAMPLE_IBANS.has(iban)) this.add("account", iban, where);
11406
+ for (const [ssn] of text3.matchAll(/(?<![\d-])(?!000|666|9\d\d)\d{3}-(?!00)\d{2}-(?!0000)\d{4}(?![\d-])/g)) if (ssn !== "123-45-6789" && ssn !== "078-05-1120") this.add("id", ssn, where);
11407
+ }
11408
+ review() {
11409
+ return { hidden: [...this.hiddenNames], check: [...this.checks.values()] };
11410
+ }
11411
+ };
11412
+ function mayBeKey(name, value) {
11413
+ if (/(hash|checksum|digest|md5|sha\d*|etag|fingerprint|gravatar_id|node_id|(next|prev(ious)?|page|continuation|pagination|cursor|sync|resume|start|end|delta|change|watch|version|concurrency|lock)[-_]?token)$/i.test(name) || /^[a-z]{2,12}[-_:]/.test(value)) return false;
11414
+ return /^[a-f0-9]{32}$/i.test(value) || value.length >= 32 && randomToken(value);
11415
+ }
11416
+ var RESERVED_DOMAIN = /(^|\.)(example\.(com|net|org)|example|test|invalid|localhost)$/i;
11417
+ var PRIVATE_HOST = /\b(localhost|127(?:\.\d{1,3}){3}|10(?:\.\d{1,3}){3}|192\.168(?:\.\d{1,3}){2}|172\.(?:1[6-9]|2\d|3[01])(?:\.\d{1,3}){2}|169\.254(?:\.\d{1,3}){2}|[a-z0-9-]{1,63}(?:\.[a-z0-9-]{1,63}){0,8}\.(?:internal|local|localdomain|lan|corp|intranet|home\.arpa))\b/gi;
11418
+ var TEST_CARDS = /* @__PURE__ */ new Set(["4242424242424242", "4000056655665556", "5555555555554444", "2223003122003222", "5200828282828210", "5105105105105100", "378282246310005", "371449635398431", "6011111111111117", "6011000990139424", "4111111111111111", "4012888888881881", "4000000000000002", "4000000000009995", "4000002500003155", "4000000000003220", "4000000000000077", "5454545454545454", "4917610000000000", "4988438843884305", "4166676667666746", "4646464646464644", "4000020000000000", "4111111145551142", "5136333333333335", "2222400070000005"]);
11419
+ var EXAMPLE_IBANS = /* @__PURE__ */ new Set(["GB82WEST12345698765432", "DE89370400440532013000", "GB29NWBK60161331926819", "FR1420041010050500013M02606", "NL91ABNA0417164300", "GB33BUKB20201555555555", "CH9300762011623852957"]);
11420
+ function luhn(digits) {
11421
+ let sum = 0;
11422
+ for (let i = 0; i < digits.length; i++) {
11423
+ let d = Number(digits[digits.length - 1 - i]);
11424
+ if (i % 2) d = d * 2 > 9 ? d * 2 - 9 : d * 2;
11425
+ sum += d;
11426
+ }
11427
+ return sum % 10 === 0;
11428
+ }
11429
+ function ibanValid(iban) {
11430
+ const moved = `${iban.slice(4)}${iban.slice(0, 4)}`;
11431
+ let rest = 0;
11432
+ for (const c of moved) {
11433
+ const n = /\d/.test(c) ? c : String(c.charCodeAt(0) - 55);
11434
+ for (const d of n) rest = (rest * 10 + Number(d)) % 97;
11435
+ }
11436
+ return rest === 1;
11437
+ }
11438
+ function decodeURIComponentSafe(text3) {
11439
+ try {
11440
+ return decodeURIComponent(text3.replace(/\+/g, " "));
11441
+ } catch {
11442
+ return text3;
11443
+ }
11444
+ }
11445
+
11073
11446
  // package.json
11074
- var version = "1.0.9";
11447
+ var version = "1.0.11";
11075
11448
 
11076
11449
  // src/files.ts
11077
11450
  var import_node_fs = require("node:fs");
@@ -14410,7 +14783,8 @@ var MCP_HINT = "If it's an MCP server, open it in MCP Inspector (npx @modelconte
14410
14783
  function specUrl(input, base) {
14411
14784
  const text3 = input.trim();
14412
14785
  if (!text3) throw new SpecError("Enter the URL of an OpenAPI spec.");
14413
- const invalid = new SpecError(`That isn't a valid URL: ${text3.length > 80 ? `${text3.slice(0, 79)}\u2026` : text3}`);
14786
+ const shown = shownAddress(text3, true);
14787
+ const invalid = new SpecError(`That isn't a valid URL: ${shown.length > 80 ? `${shown.slice(0, 79)}\u2026` : shown}`);
14414
14788
  let url;
14415
14789
  try {
14416
14790
  url = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(text3) || text3.startsWith("/") ? text3 : `https://${text3}`, base);
@@ -14992,7 +15366,7 @@ function downloads(own, allowPrivate = false, resolve4 = import_node_dns.lookup)
14992
15366
  return {
14993
15367
  allowed: async (url) => {
14994
15368
  if (open(url)) return void 0;
14995
- if (url.protocol !== "https:" && url.protocol !== "http:") return `${url.href} isn't an http or https address, so it isn't read.`;
15369
+ if (url.protocol !== "https:" && url.protocol !== "http:") return `${shownAddress(url.href, true)} isn't an http or https address, so it isn't read.`;
14996
15370
  return privateHost(url) ? `${url.host} ${REFUSED}` : void 0;
14997
15371
  },
14998
15372
  download: (input, init) => {
@@ -15044,7 +15418,7 @@ function publicLookup(resolve4) {
15044
15418
  }
15045
15419
  function publicFetch(url, init, lookup) {
15046
15420
  if (privateHost(url)) return Promise.reject(new SpecError(`${url.host} ${REFUSED}`));
15047
- if (url.protocol !== "https:" && url.protocol !== "http:") return Promise.reject(new SpecError(`${url.href} isn't an http or https address, so it isn't read.`));
15421
+ if (url.protocol !== "https:" && url.protocol !== "http:") return Promise.reject(new SpecError(`${shownAddress(url.href, true)} isn't an http or https address, so it isn't read.`));
15048
15422
  const send = url.protocol === "https:" ? import_node_https.request : import_node_http.request;
15049
15423
  return new Promise((resolve4, reject) => {
15050
15424
  const request = send(url, {
@@ -15285,7 +15659,7 @@ var import_promises2 = require("node:fs/promises");
15285
15659
  var import_node_path3 = require("node:path");
15286
15660
 
15287
15661
  // ../../lib/embed/playerScript.generated.ts
15288
- var PLAYER_SCRIPT = '(function () {\n"use strict";\nvar defs = {\n"lib/embed/player": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nconst frame_1 = require("../render/frame");\nconst timing_1 = require("../storyboard/timing");\nconst ICONS = {\n play: \'<path d="M8 5.2v13.6a.6.6 0 0 0 .9.5l10.6-6.8a.6.6 0 0 0 0-1L8.9 4.7a.6.6 0 0 0-.9.5z" fill="currentColor"/>\',\n pause: \'<path d="M7 5h3.2v14H7zM13.8 5H17v14h-3.2z" fill="currentColor"/>\',\n replay: \'<path d="M19.5 11.5A7.5 7.5 0 1 0 17.3 17M19.5 5v6.5H13" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n prev: \'<path d="M6.5 5.5v13M17.5 6.2v11.6a.5.5 0 0 1-.8.4l-8.3-5.8a.5.5 0 0 1 0-.8l8.3-5.8a.5.5 0 0 1 .8.4z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n next: \'<path d="M17.5 5.5v13M6.5 6.2v11.6a.5.5 0 0 0 .8.4l8.3-5.8a.5.5 0 0 0 0-.8L7.3 5.8a.5.5 0 0 0-.8.4z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n copy: \'<path d="M9 9.5h9.5v10H9zM6 15.5H5.5v-10h9.5V6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n expand: \'<path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n};\nconst icon = (name) => `<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true">${ICONS[name]}</svg>`;\nfunction fmt(ms) {\n const s = Math.floor(ms / 1000);\n return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;\n}\nfunction button(label, name, className = "") {\n const b = document.createElement("button");\n b.type = "button";\n b.className = className;\n b.setAttribute("aria-label", label);\n b.title = label;\n b.innerHTML = icon(name);\n return b;\n}\nconst SITE = "https://integrationtour.com/";\nfunction credit(aspect) {\n const a = document.createElement("a");\n a.className = "credit";\n a.href = SITE;\n a.target = "_blank";\n a.rel = "noopener";\n a.setAttribute("aria-label", `${frame_1.WATERMARK} (opens in a new tab)`);\n a.addEventListener("click", (e) => e.stopPropagation());\n place(a, aspect, (0, frame_1.watermarkBox)(aspect));\n return a;\n}\nfunction place(link, aspect, box) {\n const size = (0, frame_1.sizeFor)(aspect);\n const pad = 8;\n const share = (value, of) => `${((value / of) * 100).toFixed(3)}%`;\n link.style.left = share(box.x - pad, size.width);\n link.style.top = share(box.y - pad, size.height);\n link.style.width = share(box.w + 2 * pad, size.width);\n link.style.height = share(box.h + 2 * pad, size.height);\n}\nfunction fit(link, frame, aspect) {\n const text = frame.querySelector("svg > text:last-child");\n if (!(text instanceof SVGTextElement) || text.textContent !== frame_1.WATERMARK)\n return false;\n let width = 0;\n try {\n width = text.getComputedTextLength();\n }\n catch {\n }\n if (!(width > 0))\n return false;\n const box = (0, frame_1.watermarkBox)(aspect);\n place(link, aspect, { ...box, x: box.x + box.w - width, w: width });\n return true;\n}\nfunction start(root, sb) {\n const total = (0, timing_1.totalDuration)(sb);\n const starts = (0, frame_1.sceneStarts)(sb);\n let time = 0;\n let playing = false;\n let last = null;\n const stage = document.createElement("div");\n stage.className = `stage ${sb.settings.aspect === "9:16" ? "portrait" : sb.settings.aspect === "1:1" ? "square" : "wide"}`;\n const frame = document.createElement("div");\n frame.setAttribute("role", "img");\n stage.append(frame);\n const link = sb.settings.watermark ? credit(sb.settings.aspect) : undefined;\n if (link)\n stage.append(link);\n let fitted = false;\n const controls = document.createElement("div");\n controls.className = "controls";\n const prev = button("Previous scene", "prev");\n const play = button("Play", "play", "play");\n const next = button("Next scene", "next");\n const seek = document.createElement("input");\n seek.type = "range";\n seek.min = "0";\n seek.max = String(total);\n seek.step = "50";\n seek.setAttribute("aria-label", "Seek");\n const clock = document.createElement("span");\n clock.className = "time";\n const copy = button("Copy this payload as JSON", "copy");\n const full = button("Full screen", "expand");\n controls.append(prev, play, next, seek, clock, copy, full);\n const status = document.createElement("p");\n status.className = "status";\n status.setAttribute("role", "status");\n root.append(stage, controls, status);\n root.tabIndex = 0;\n const draw = () => {\n const at = (0, frame_1.sceneAt)(sb, Math.min(time, total));\n frame.innerHTML = (0, frame_1.renderFrame)(sb, time);\n frame.setAttribute("aria-label", at.scene.caption);\n if (link && !fitted)\n fitted = fit(link, frame, sb.settings.aspect);\n seek.value = String(Math.round(time));\n clock.textContent = `${fmt(time)} / ${fmt(total)} \xB7 ${at.index + 1}/${at.count}`;\n const ended = !playing && time >= total;\n play.innerHTML = icon(playing ? "pause" : ended ? "replay" : "play");\n play.setAttribute("aria-label", playing ? "Pause" : ended ? "Replay" : "Play");\n prev.disabled = at.index === 0;\n next.disabled = at.index === at.count - 1;\n };\n const tick = (now) => {\n if (!playing)\n return;\n time = Math.min(total, time + (last === null ? 0 : now - last));\n last = now;\n if (time >= total)\n playing = false;\n draw();\n if (playing)\n requestAnimationFrame(tick);\n };\n const toggle = () => {\n if (!playing && time >= total)\n time = 0;\n playing = !playing;\n last = null;\n draw();\n if (playing)\n requestAnimationFrame(tick);\n };\n const step = (delta) => {\n const index = Math.max(0, Math.min(starts.length - 1, (0, frame_1.sceneAt)(sb, Math.min(time, total)).index + delta));\n playing = false;\n time = starts[index] + Math.min(900, total - starts[index]);\n draw();\n };\n const payload = () => {\n const { scene, progress } = (0, frame_1.sceneAt)(sb, Math.min(time, total));\n if (scene.kind === "call" || scene.kind === "auth")\n return progress < 0.52 ? scene.request : scene.response;\n return scene.kind === "webhook" ? scene.payload : undefined;\n };\n const say = (text) => {\n status.textContent = text;\n window.setTimeout(() => status.textContent === text && (status.textContent = ""), 2500);\n };\n copy.addEventListener("click", async () => {\n const value = payload();\n if (value === undefined)\n return say("This scene has no payload to copy.");\n const text = typeof value === "string" ? value : JSON.stringify(value, null, 2);\n try {\n await navigator.clipboard.writeText(text);\n }\n catch {\n const area = document.createElement("textarea");\n area.value = text;\n document.body.append(area);\n area.select();\n document.execCommand("copy");\n area.remove();\n }\n say("Copied the payload as JSON.");\n });\n full.addEventListener("click", () => {\n if (document.fullscreenElement)\n void document.exitFullscreen();\n else if (root.requestFullscreen)\n void root.requestFullscreen().catch(() => root.classList.toggle("filled"));\n else\n root.classList.toggle("filled");\n });\n play.addEventListener("click", toggle);\n prev.addEventListener("click", () => step(-1));\n next.addEventListener("click", () => step(1));\n stage.addEventListener("click", toggle);\n seek.addEventListener("input", () => {\n playing = false;\n time = Number(seek.value);\n draw();\n });\n root.addEventListener("keydown", (e) => {\n if (e.target.tagName === "INPUT" && e.key !== " ")\n return;\n if (e.key === " ") {\n e.preventDefault();\n toggle();\n }\n else if (e.key === "ArrowRight")\n step(1);\n else if (e.key === "ArrowLeft")\n step(-1);\n else if (e.key === "f")\n full.click();\n else if (e.key === "Escape")\n root.classList.remove("filled");\n });\n draw();\n}\nconst root = document.getElementById("flow-player");\nconst data = document.getElementById("flow-storyboard");\nif (root && (data === null || data === void 0 ? void 0 : data.textContent))\n start(root, JSON.parse(data.textContent));\n\n}, {"../render/frame":"lib/render/frame","../storyboard/timing":"lib/storyboard/timing"}],\n"lib/render/frame": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.WATERMARK = void 0;\nexports.paletteFor = paletteFor;\nexports.sizeFor = sizeFor;\nexports.outputSize = outputSize;\nexports.sceneAt = sceneAt;\nexports.sceneStarts = sceneStarts;\nexports.renderFrame = renderFrame;\nexports.watermarkBox = watermarkBox;\nexports.jsonLines = jsonLines;\nexports.wrap = wrap;\nexports.esc = esc;\nconst timing_1 = require("../storyboard/timing");\nconst code_1 = require("./code");\nconst text_1 = require("../text");\nexports.WATERMARK = "Made with integrationtour.com";\nconst DARK = {\n bg: "#0b1120",\n panel: "#131c31",\n panelEdge: "#26324d",\n text: "#e6ebf5",\n muted: "#8e9ab3",\n client: "#5cc8ff",\n api: "#a58bff",\n accent: "#5cc8ff",\n ok: "#3ddc97",\n bad: "#ff6b6b",\n hook: "#ffb547",\n key: "#ffd166",\n jsonKey: "#7cc7ff",\n jsonString: "#b8e986",\n jsonOther: "#f7b17a",\n};\nconst LIGHT = {\n bg: "#f5f7fb",\n panel: "#ffffff",\n panelEdge: "#d5dce8",\n text: "#0f172a",\n muted: "#5b6a82",\n client: "#0369a1",\n api: "#6d28d9",\n accent: "#0369a1",\n ok: "#047857",\n bad: "#c81e1e",\n hook: "#b45309",\n key: "#a16207",\n jsonKey: "#0f5f8f",\n jsonString: "#166534",\n jsonOther: "#b4410c",\n};\nconst HEX_COLOR = /^#[0-9a-f]{6}$/i;\nfunction paletteFor(settings) {\n const base = settings.theme === "light" ? LIGHT : DARK;\n return settings.brandColor && HEX_COLOR.test(settings.brandColor) ? { ...base, api: settings.brandColor, accent: settings.brandColor } : base;\n}\nlet C = DARK;\nconst SANS = "Inter, \'Segoe UI\', Roboto, Helvetica, Arial, sans-serif";\nconst MONO = "\'JetBrains Mono\', \'SFMono-Regular\', Menlo, Consolas, monospace";\nfunction sizeFor(aspect) {\n if (aspect === "9:16")\n return { width: 720, height: 1280 };\n return aspect === "1:1" ? { width: 720, height: 720 } : { width: 1280, height: 720 };\n}\nfunction outputSize(settings) {\n var _a;\n const { width, height } = sizeFor(settings.aspect);\n const scale = ((_a = settings.resolution) !== null && _a !== void 0 ? _a : 720) / 720;\n return { width: Math.round(width * scale), height: Math.round(height * scale) };\n}\nfunction layoutFor(aspect) {\n if (aspect === "9:16") {\n const client = { x: 48, y: 290, w: 624, h: 110 };\n const api = { x: 48, y: 1040, w: 624, h: 110 };\n return {\n width: 720,\n height: 1280,\n stacked: true,\n caption: { x: 48, y: 110, width: 624, size: 32, minSize: 26, maxLines: 4 },\n client,\n api,\n webhook: client,\n card: { x: 136, y: 450, w: 536, h: 550 },\n lane: { from: [92, 400], to: [92, 1040] },\n hookLane: { from: [92, 1040], to: [92, 400] },\n monoSize: 16,\n title: { size: 52, logo: 120, subtitle: 26 },\n stepSize: 18,\n summary: { left: 64, top: 360, bottom: 100, size: 26, gap: 64 },\n };\n }\n if (aspect === "1:1") {\n const client = { x: 40, y: 200, w: 240, h: 92 };\n return {\n width: 720,\n height: 720,\n stacked: true,\n caption: { x: 40, y: 72, width: 640, size: 30, minSize: 24, maxLines: 3 },\n client,\n api: { x: 440, y: 200, w: 240, h: 92 },\n webhook: client,\n card: { x: 40, y: 324, w: 640, h: 326 },\n lane: { from: [280, 246], to: [440, 246] },\n hookLane: { from: [440, 246], to: [280, 246] },\n monoSize: 15,\n title: { size: 44, logo: 80, subtitle: 22 },\n stepSize: 16,\n summary: { left: 56, top: 200, bottom: 70, size: 22, gap: 48 },\n };\n }\n const client = { x: 64, y: 250, w: 250, h: 130 };\n const api = { x: 966, y: 250, w: 250, h: 130 };\n const webhook = { x: 64, y: 480, w: 250, h: 110 };\n return {\n width: 1280,\n height: 720,\n stacked: false,\n caption: { x: 64, y: 92, width: 1152, size: 30, minSize: 24, maxLines: 2 },\n client,\n api,\n webhook,\n card: { x: 354, y: 352, w: 572, h: 300 },\n lane: { from: [314, 315], to: [966, 315] },\n hookLane: { from: [966, 380], to: [314, 535] },\n monoSize: 15,\n title: { size: 56, logo: 92, subtitle: 24 },\n stepSize: 15,\n summary: { left: 200, top: 220, bottom: 70, size: 24, gap: 56 },\n };\n}\nfunction sceneAt(sb, t) {\n const scenes = (0, timing_1.activeScenes)(sb);\n let start = 0;\n for (let i = 0; i < scenes.length; i++) {\n const duration = (0, timing_1.sceneDuration)(sb, scenes[i]);\n const end = start + duration;\n if (t < end || i === scenes.length - 1) {\n return { scene: scenes[i], index: i, count: scenes.length, start, duration, progress: clamp01((t - start) / duration) };\n }\n start = end;\n }\n throw new Error("Storyboard has no scenes.");\n}\nfunction sceneStarts(sb) {\n const starts = [];\n let t = 0;\n for (const s of (0, timing_1.activeScenes)(sb)) {\n starts.push(t);\n t += (0, timing_1.sceneDuration)(sb, s);\n }\n return starts;\n}\nfunction renderFrame(sb, t, size) {\n var _a, _b;\n C = paletteFor(sb.settings);\n const L = layoutFor(sb.settings.aspect);\n const total = (0, timing_1.totalDuration)(sb);\n const at = sceneAt(sb, Math.max(0, Math.min(t, total)));\n const fade = at.index === 0 ? 1 : clamp01((at.progress * at.duration) / 300);\n let body;\n switch (at.scene.kind) {\n case "title":\n body = titleScene(L, at.scene, at.progress, sb.settings.logo);\n break;\n case "summary":\n body = summaryScene(L, at.scene, at.progress, (0, timing_1.summaryItems)(sb));\n break;\n case "auth":\n body = authScene(L, sb, at.scene, at.progress);\n break;\n case "webhook":\n body = webhookScene(L, sb, at.scene, at.progress);\n break;\n default:\n body = callScene(L, sb, at.scene, at.progress);\n }\n const parts = [\n `<svg xmlns="http://www.w3.org/2000/svg" width="${(_a = size === null || size === void 0 ? void 0 : size.width) !== null && _a !== void 0 ? _a : L.width}" height="${(_b = size === null || size === void 0 ? void 0 : size.height) !== null && _b !== void 0 ? _b : L.height}" viewBox="0 0 ${L.width} ${L.height}" font-family="${esc(SANS)}">`,\n `<rect width="${L.width}" height="${L.height}" fill="${C.bg}"/>`,\n grid(L),\n `<g opacity="${fade.toFixed(3)}">${body}</g>`,\n progressBar(L, total ? Math.min(t, total) / total : 0),\n sb.settings.watermark ? watermark(L) : "",\n `</svg>`,\n ];\n return parts.join("");\n}\nfunction titleScene(L, scene, p, logo) {\n let size = L.title.size;\n while (size > L.title.size * 0.72 && wrap(scene.title, L.width - 160, size, Infinity).length > 3)\n size -= 2;\n const lines = wrap(scene.title, L.width - 160, size, 3);\n const mark = logo && /^data:image\\/(png|jpeg|gif|webp);base64,[a-z0-9+/=]+$/i.test(logo) ? { h: L.title.logo, gap: 34 } : undefined;\n const top = L.height / 2 - (lines.length * size * 1.15) / 2 + (mark ? (mark.h + mark.gap) / 2 : 0);\n const out = lines.map((line, i) => `<text x="${L.width / 2}" y="${top + i * size * 1.15}" text-anchor="middle" font-size="${size}" font-weight="700" fill="${C.text}">${esc(line)}</text>`);\n const subY = top + lines.length * size * 1.15 + 24;\n out.push(`<text x="${L.width / 2}" y="${subY}" text-anchor="middle" font-size="${L.title.subtitle}" fill="${C.muted}">${esc(fit(scene.subtitle, L.width - 160, L.title.subtitle))}</text>`);\n if (mark) {\n const bottom = top - size * 0.78 - mark.gap;\n out.push(`<image href="${esc(logo)}" x="${L.width / 2 - 200}" y="${(bottom - mark.h).toFixed(1)}" width="400" height="${mark.h}" preserveAspectRatio="xMidYMid meet"/>`);\n }\n const dotsY = subY + 70;\n [C.client, C.api, C.hook].forEach((color, i) => {\n const glow = pulse(p, 0.25 + i * 0.15, 0.55 + i * 0.15);\n const cx = L.width / 2 + (i - 1) * 40;\n if (glow > 0)\n out.push(`<circle cx="${cx}" cy="${dotsY}" r="${(8 + 10 * glow).toFixed(1)}" fill="${color}" opacity="${(0.25 * glow).toFixed(3)}"/>`);\n out.push(`<circle cx="${cx}" cy="${dotsY}" r="8" fill="${color}"/>`);\n });\n return out.join("");\n}\nconst MIN_SUMMARY_GAP = 34;\nconst MIN_SUMMARY_SIZE = 18;\nfunction summaryScene(L, scene, p, items) {\n const out = [captionText(L, scene.caption)];\n const { left, top, bottom, size, gap } = L.summary;\n const textX = left + 44;\n const room = L.height - bottom - top;\n const plan = summaryPlan(items, L.width - textX - 56, room, size, gap);\n const r = Math.min(14, plan.gap * 0.32);\n const stagger = Math.min(0.08, 0.6 / plan.blocks.length);\n let y = top;\n plan.blocks.forEach((lines, i) => {\n const appear = clamp01((p - 0.08 - i * stagger) / 0.12);\n const more = plan.more && i === plan.blocks.length - 1;\n out.push(`<g opacity="${appear.toFixed(3)}">`, more\n ? ""\n : `<circle cx="${left + 14}" cy="${(y - 8).toFixed(1)}" r="${r.toFixed(1)}" fill="${C.ok}" opacity="0.18"/><path d="M${left + 7} ${(y - 8).toFixed(1)} l5 5 l9 -10" stroke="${C.ok}" stroke-width="3" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`, ...lines.map((line, j) => `<text x="${textX}" y="${(y + j * plan.lineHeight).toFixed(1)}" font-size="${plan.size}" fill="${more ? C.muted : C.text}">${esc(line)}</text>`), `</g>`);\n y += plan.gap + (lines.length - 1) * plan.lineHeight;\n });\n return out.join("");\n}\nfunction summaryPlan(items, width, room, baseSize, baseGap) {\n const measure = (size) => {\n const lineHeight = Math.round(size * 1.2);\n const blocks = items.map((item) => wrap(item, width, size, 2));\n const extra = blocks.reduce((n, lines) => n + lines.length - 1, 0) * lineHeight;\n return { blocks, lineHeight, extra, minGap: Math.max(MIN_SUMMARY_GAP, size * 1.45) };\n };\n for (let size = baseSize; size >= MIN_SUMMARY_SIZE; size--) {\n const { blocks, lineHeight, extra, minGap } = measure(size);\n const gaps = Math.max(1, blocks.length - 1);\n if (gaps * minGap + extra <= room)\n return { blocks, size, lineHeight, gap: Math.min(baseGap, (room - extra) / gaps), more: false };\n }\n const { blocks, lineHeight, minGap } = measure(MIN_SUMMARY_SIZE);\n const kept = [];\n let used = 0;\n for (const lines of blocks) {\n const need = (kept.length ? minGap : 0) + (lines.length - 1) * lineHeight;\n if (used + need + minGap > room)\n break;\n kept.push(lines);\n used += need;\n }\n kept.push([`+${items.length - kept.length} more`]);\n return { blocks: kept, size: MIN_SUMMARY_SIZE, lineHeight, gap: minGap, more: true };\n}\nfunction callScene(L, sb, scene, p) {\n var _a;\n const failed = scene.outcome === "failure";\n const responseColor = failed ? C.bad : C.ok;\n const requestPhase = p < 0.52;\n const mcp = sb.api.protocol === "mcp";\n const call = `${scene.method} ${scene.path}`.trim();\n const outcome = outcomeText(scene.status);\n const out = [\n stepLabel(L, `Step ${scene.step} of ${scene.stepCount}${failed ? " \xB7 failure path" : ""}`, failed ? C.bad : C.muted),\n captionText(L, scene.caption),\n ...nodes(L, sb, pulse(p, 0.4, 0.52)),\n lane(L),\n ];\n if (!L.stacked)\n out.push(laneLabel(L, call));\n if (!L.stacked && sb.scenes.some((s) => s.kind === "webhook"))\n out.push(node(L.webhook, "WEBHOOKS", (_a = sb.nodes.webhook) !== null && _a !== void 0 ? _a : "Your server", C.hook, 0, 0.35));\n if (p >= 0.1 && p < 0.4)\n out.push(packet(L.lane.from, L.lane.to, ease((p - 0.1) / 0.3), C.client));\n if (p >= 0.52 && p < 0.8)\n out.push(packet(L.lane.to, L.lane.from, ease((p - 0.52) / 0.28), responseColor));\n const cardIn = clamp01((p - 0.08) / 0.08);\n if (requestPhase) {\n const code = sb.settings.code ? (0, code_1.callCode)(sb, scene, sb.settings.code) : undefined;\n out.push(card(L, call, C.client, scene.request, scene.request === undefined && !code ? (mcp ? "No params" : "No request body") : undefined, cardIn, { code }));\n }\n else {\n out.push(card(L, mcp && failed ? `result \xB7 ${outcome}` : outcome, responseColor, scene.response, scene.response === undefined ? "No response body" : undefined, 1, { fold: mcp ? SCHEMA_KEYS : undefined }));\n }\n if (p >= 0.8) {\n const appear = clamp01((p - 0.8) / 0.06);\n out.push(badge(L.client, outcome, responseColor, appear));\n if (failed && scene.recovery)\n out.push(recoveryNote(L, scene.recovery, appear));\n }\n if (requestPhase ? scene.requestGenerated && p >= 0.08 : scene.responseGenerated) {\n const written = mcp && (requestPhase ? scene.method === "prompts/get" : isRecord(scene.response) && !("structuredContent" in scene.response));\n out.push(`<text x="${L.card.x + L.card.w}" y="${L.card.y + L.card.h + 22}" text-anchor="end" font-size="13" fill="${C.muted}">${written ? "Example text written for the video" : "Example generated from the schema"}</text>`);\n }\n return out.join("");\n}\nfunction nodes(L, sb, glow, clientOpacity = 1) {\n const mcp = sb.api.protocol === "mcp";\n return [node(L.client, mcp ? "MCP CLIENT" : "CLIENT", sb.nodes.client, C.client, 0, clientOpacity), node(L.api, mcp ? "MCP SERVER" : "API", sb.nodes.api, C.api, glow)];\n}\nfunction outcomeText(status) {\n if (status === "result")\n return "result";\n if (status === "isError")\n return "isError: true";\n const why = reason(status);\n return why ? `${status} ${why}` : status;\n}\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction authScene(L, sb, scene, p) {\n var _a;\n const out = [stepLabel(L, `Authentication \xB7 ${scene.scheme}`, C.key), captionText(L, scene.caption), ...nodes(L, sb, pulse(p, 0.4, 0.52)), lane(L)];\n if (scene.requestLine) {\n if (!L.stacked)\n out.push(laneLabel(L, scene.requestLine));\n if (p >= 0.1 && p < 0.4)\n out.push(packet(L.lane.from, L.lane.to, ease((p - 0.1) / 0.3), C.client));\n if (p >= 0.52 && p < 0.8)\n out.push(packet(L.lane.to, L.lane.from, ease((p - 0.52) / 0.28), C.key));\n const code = sb.settings.code && sb.api.protocol !== "mcp" && scene.requestType ? (0, code_1.authCode)(sb, scene, sb.settings.code) : undefined;\n const form = !code && /form-urlencoded/i.test((_a = scene.requestType) !== null && _a !== void 0 ? _a : "") && isRecord(scene.request);\n if (p < 0.52)\n out.push(card(L, scene.requestLine, C.client, form ? formText(scene.request) : scene.request, undefined, clamp01((p - 0.08) / 0.08), { code, form }));\n else\n out.push(card(L, "200 OK \xB7 access token", C.key, scene.response, undefined, 1));\n if (p >= 0.8)\n out.push(badge(L.client, "Token stored", C.key, clamp01((p - 0.8) / 0.06)));\n }\n else {\n if (!L.stacked)\n out.push(laneLabel(L, scene.headerLine.split("\\n")[0]));\n if (p >= 0.2 && p < 0.6)\n out.push(packet(L.lane.from, L.lane.to, ease((p - 0.2) / 0.4), C.key));\n const every = sb.scenes.every((s) => s.kind !== "call" || s.credentials === undefined);\n out.push(card(L, every ? "Sent with every request" : "Sent with each call that needs it", C.key, undefined, scene.headerLine, clamp01((p - 0.08) / 0.08)));\n if (p >= 0.62)\n out.push(badge(L.api, "Authenticated", C.ok, clamp01((p - 0.62) / 0.06)));\n }\n return out.join("");\n}\nfunction webhookScene(L, sb, scene, p) {\n var _a, _b, _c;\n const receiver = L.stacked ? node(L.webhook, "WEBHOOKS", (_a = sb.nodes.webhook) !== null && _a !== void 0 ? _a : "Your server", C.hook, pulse(p, 0.55, 0.7)) : "";\n const out = [\n stepLabel(L, `Webhook \xB7 ${scene.event}`, C.hook),\n captionText(L, scene.caption),\n L.stacked ? receiver : node(L.client, "CLIENT", sb.nodes.client, C.client, 0, 0.45),\n node(L.api, "API", sb.nodes.api, C.api, pulse(p, 0.05, 0.18)),\n ];\n if (!L.stacked)\n out.push(node(L.webhook, "WEBHOOKS", (_b = sb.nodes.webhook) !== null && _b !== void 0 ? _b : "Your server", C.hook, pulse(p, 0.55, 0.7)));\n out.push(`<line x1="${L.hookLane.from[0]}" y1="${L.hookLane.from[1]}" x2="${L.hookLane.to[0]}" y2="${L.hookLane.to[1]}" stroke="${C.hook}" stroke-opacity="0.35" stroke-width="2" stroke-dasharray="6 8"/>`);\n if (p >= 0.18 && p < 0.55)\n out.push(packet(L.hookLane.from, L.hookLane.to, ease((p - 0.18) / 0.37), C.hook));\n out.push(card(L, `${scene.method} ${scene.event}`, C.hook, scene.payload, scene.payload === undefined ? "Event payload" : undefined, clamp01((p - 0.1) / 0.08)));\n if (scene.payloadGenerated && scene.payload !== undefined) {\n out.push(`<text x="${L.card.x + L.card.w}" y="${L.card.y + L.card.h + 22}" text-anchor="end" font-size="13" fill="${C.muted}">Example generated from the schema</text>`);\n }\n if (p >= 0.72) {\n const ack = (_c = scene.ack) !== null && _c !== void 0 ? _c : "2XX";\n const said = `${outcomeText(ack)} \xB7 acknowledged`;\n out.push(badge(L.webhook, said.length <= Math.floor((L.webhook.w - 20) / (15 * 0.6)) ? said : `${ack} \xB7 acknowledged`, C.ok, clamp01((p - 0.72) / 0.06)));\n }\n return out.join("");\n}\nfunction grid(L) {\n const dots = [];\n for (let x = 32; x < L.width; x += 48) {\n for (let y = 32; y < L.height; y += 48)\n dots.push(`M${x} ${y}h1`);\n }\n return `<path d="${dots.join("")}" stroke="${C.panelEdge}" stroke-width="2" stroke-linecap="round" opacity="0.5"/>`;\n}\nfunction stepLabel(L, text, color) {\n return `<text x="${L.caption.x}" y="${L.caption.y - L.caption.size - 10}" font-size="${L.stepSize}" font-weight="600" letter-spacing="1.5" fill="${color}">${esc(text.toUpperCase())}</text>`;\n}\nfunction captionText(L, caption) {\n const { x, y } = L.caption;\n const { size, lines } = fitCaption(L, caption);\n return lines.map((line, i) => `<text x="${x}" y="${y + i * size * 1.25}" font-size="${size}" font-weight="600" fill="${C.text}">${esc(line)}</text>`).join("");\n}\nfunction fitCaption(L, caption) {\n const { width, size, minSize, maxLines } = L.caption;\n const whole = caption.split(/\\s+/).filter(Boolean).join(" ");\n for (const limit of [maxLines, maxLines + 1]) {\n for (let s = size; s >= minSize; s--) {\n const lines = wrap(caption, width, s, Infinity);\n if (lines.length <= limit && lines.join(" ") === whole)\n return { size: s, lines };\n }\n }\n return { size: minSize, lines: wrap(caption, width, minSize, maxLines + 1) };\n}\nfunction node(box, kicker, name, color, glow, opacity = 1) {\n const size = 22;\n return [\n `<g opacity="${opacity}">`,\n glow > 0 ? `<rect x="${box.x - 6}" y="${box.y - 6}" width="${box.w + 12}" height="${box.h + 12}" rx="20" fill="none" stroke="${color}" stroke-width="3" opacity="${(glow * 0.6).toFixed(3)}"/>` : "",\n `<rect x="${box.x}" y="${box.y}" width="${box.w}" height="${box.h}" rx="16" fill="${C.panel}" stroke="${color}" stroke-width="2"/>`,\n `<rect x="${box.x}" y="${box.y}" width="6" height="${box.h}" rx="3" fill="${color}"/>`,\n `<text x="${box.x + 28}" y="${box.y + box.h / 2 - 8}" font-size="13" font-weight="700" letter-spacing="2" fill="${color}">${esc(kicker)}</text>`,\n `<text x="${box.x + 28}" y="${box.y + box.h / 2 + 22}" font-size="${size}" font-weight="600" fill="${C.text}">${esc(fit(name, box.w - 48, size))}</text>`,\n `</g>`,\n ].join("");\n}\nfunction lane(L) {\n const [x1, y1] = L.lane.from;\n const [x2, y2] = L.lane.to;\n return `<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${C.panelEdge}" stroke-width="2" stroke-dasharray="6 8"/>`;\n}\nfunction laneLabel(L, text) {\n const [x1, y1] = L.lane.from;\n const [x2] = L.lane.to;\n return `<text x="${(x1 + x2) / 2}" y="${y1 - 16}" text-anchor="middle" font-family="${esc(MONO)}" font-size="16" fill="${C.muted}">${esc(fit(text, x2 - x1 - 40, 16, true))}</text>`;\n}\nfunction packet(from, to, t, color) {\n const x = from[0] + (to[0] - from[0]) * t;\n const y = from[1] + (to[1] - from[1]) * t;\n return `<circle cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" r="18" fill="${color}" opacity="0.2"/><circle cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" r="9" fill="${color}"/>`;\n}\nconst SCHEMA_KEYS = new Set(["inputSchema", "outputSchema"]);\nfunction card(L, header, color, value, note, opacity, { code, fold, form } = {}) {\n const { x, y, w, h } = L.card;\n const size = code ? L.monoSize - 2 : L.monoSize;\n const lineHeight = Math.round(size * 1.4);\n const maxLines = Math.floor((h - 64) / lineHeight);\n const maxChars = Math.floor((w - 40) / (size * 0.6));\n const out = [\n `<g opacity="${opacity.toFixed(3)}">`,\n `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="14" fill="${C.panel}" stroke="${C.panelEdge}" stroke-width="1.5"/>`,\n `<rect x="${x}" y="${y}" width="${w}" height="44" rx="14" fill="${color}" opacity="0.14"/>`,\n `<text x="${x + 20}" y="${y + 28}" font-family="${esc(MONO)}" font-size="${size}" font-weight="700" fill="${color}">${esc(fit(header, w - 40, size, true))}</text>`,\n ];\n if (note !== undefined) {\n note\n .split("\\n")\n .slice(0, maxLines)\n .forEach((line, i) => out.push(`<text x="${x + 20}" y="${y + 44 + (i + 1) * lineHeight + 4}" font-family="${esc(MONO)}" font-size="${size}" fill="${C.muted}">${esc(fit(line, w - 40, size, true))}</text>`));\n }\n else {\n const lines = code ? codeTspans(code, maxLines, maxChars) : form ? formTspans(String(value), maxLines, maxChars) : jsonLines(value, maxLines, maxChars, fold);\n lines.forEach((line, i) => out.push(`<text x="${x + 20}" y="${y + 44 + (i + 1) * lineHeight + 4}" font-family="${esc(MONO)}" font-size="${size}" xml:space="preserve">${line}</text>`));\n }\n out.push(`</g>`);\n return out.join("");\n}\nfunction badge(box, text, color, opacity) {\n const size = 15;\n const w = Math.min(box.w, textWidth(text, size, true) + 28);\n const x = box.x + box.w - w;\n const y = box.y - 40;\n return `<g opacity="${opacity.toFixed(3)}"><rect x="${x}" y="${y}" width="${w}" height="30" rx="15" fill="${color}" opacity="0.18"/><rect x="${x}" y="${y}" width="${w}" height="30" rx="15" fill="none" stroke="${color}" stroke-width="1.5"/><text x="${x + w / 2}" y="${y + 20}" text-anchor="middle" font-family="${esc(MONO)}" font-size="${size}" font-weight="700" fill="${color}">${esc(fit(text, w - 20, size, true))}</text></g>`;\n}\nfunction recoveryNote(L, text, opacity) {\n const box = L.stacked ? { x: L.card.x, y: L.client.y + L.client.h + 6 } : { x: L.client.x, y: L.client.y + L.client.h + 22 };\n const width = L.stacked ? L.card.w : L.client.w;\n const lines = wrap(`\u21BB ${text}`, width, 17, L.stacked ? 1 : 3);\n return `<g opacity="${opacity.toFixed(3)}">${lines\n .map((line, i) => `<text x="${box.x}" y="${box.y + 18 + i * 22}" font-size="17" font-weight="600" fill="${C.hook}">${esc(line)}</text>`)\n .join("")}</g>`;\n}\nfunction progressBar(L, fraction) {\n return `<rect x="0" y="${L.height - 4}" width="${L.width}" height="4" fill="${C.panelEdge}"/><rect x="0" y="${L.height - 4}" width="${(L.width * clamp01(fraction)).toFixed(1)}" height="4" fill="${C.accent}"/>`;\n}\nconst MARK = { size: 15, right: 24, bottom: 20 };\nfunction watermark(L) {\n return `<text x="${L.width - MARK.right}" y="${L.height - MARK.bottom}" text-anchor="end" font-size="${MARK.size}" font-weight="600" fill="${C.muted}" opacity="0.75">${esc(exports.WATERMARK)}</text>`;\n}\nfunction watermarkBox(aspect) {\n const L = layoutFor(aspect);\n const w = exports.WATERMARK.length * MARK.size * 0.6;\n return { x: L.width - MARK.right - w, y: L.height - MARK.bottom - MARK.size, w, h: MARK.size * 1.3 };\n}\nconst FOLDED = "\\uE000";\nfunction jsonLines(value, maxLines, maxChars, fold) {\n var _a, _b;\n let text;\n try {\n const replacer = fold ? (key, v) => (fold.has(key) && isRecord(v) ? FOLDED : v) : undefined;\n text = typeof value === "string" ? value : ((_b = (_a = JSON.stringify(value, replacer, 2)) === null || _a === void 0 ? void 0 : _a.replace(/"\\uE000"/g, "{ \u2026 }")) !== null && _b !== void 0 ? _b : "");\n }\n catch {\n text = String(value);\n }\n let lines = text.split("\\n");\n if (lines.length > maxLines)\n lines = [...lines.slice(0, Math.max(1, maxLines - 1)), " \u2026"];\n const xml = typeof value === "string" && /^\\s*</.test(value);\n return lines.map((raw) => {\n const line = (0, text_1.clip)(raw, maxChars);\n if (xml)\n return xmlTspans(line);\n const field = typeof value === "string" ? line.match(/^(event|data|id|retry):( ?)(.*)$/) : null;\n if (field)\n return `<tspan fill="${C.jsonKey}">${esc(field[1])}</tspan><tspan fill="${C.muted}">:${field[2]}</tspan>${colorValue(field[3])}`;\n const m = line.match(/^(\\s*)("(?:[^"\\\\]|\\\\.)*")(:\\s?)(.*)$/);\n if (!m)\n return colorValue(line);\n return `<tspan fill="${C.muted}">${esc(m[1])}</tspan><tspan fill="${C.jsonKey}">${esc(m[2])}</tspan><tspan fill="${C.muted}">${esc(m[3])}</tspan>${colorValue(m[4])}`;\n });\n}\nfunction formText(fields) {\n return Object.entries(fields)\n .map(([key, value], i) => `${i ? "&" : ""}${key}=${typeof value === "string" ? value : JSON.stringify(value)}`)\n .join("\\n");\n}\nfunction formTspans(text, maxLines, maxChars) {\n let lines = text.split("\\n");\n if (lines.length > maxLines)\n lines = [...lines.slice(0, Math.max(1, maxLines - 1)), "\u2026"];\n return lines.map((raw) => {\n const line = (0, text_1.clip)(raw, maxChars);\n const m = line.match(/^(&?)([^=]*)(=?)(.*)$/);\n return `<tspan fill="${C.muted}">${esc(m[1])}</tspan><tspan fill="${C.jsonKey}">${esc(m[2])}</tspan><tspan fill="${C.muted}">${esc(m[3])}</tspan><tspan fill="${C.jsonString}">${esc(m[4])}</tspan>`;\n });\n}\nconst XML_TOKEN = /(<\\/?[\\w.:-]+|\\/?>)|("[^"]*"?)|([\\w.:-]+=)/g;\nfunction xmlTspans(line) {\n const out = [];\n let last = 0;\n for (const m of line.matchAll(XML_TOKEN)) {\n if (m.index > last)\n out.push(`<tspan fill="${C.jsonString}">${esc(line.slice(last, m.index))}</tspan>`);\n const [token, tag, str] = m;\n out.push(`<tspan fill="${tag ? C.jsonKey : str ? C.jsonString : C.muted}">${esc(token)}</tspan>`);\n last = m.index + token.length;\n }\n if (last < line.length)\n out.push(`<tspan fill="${C.jsonString}">${esc(line.slice(last))}</tspan>`);\n return out.join("");\n}\nfunction codeTspans(code, maxLines, maxChars) {\n let lines = code.flatMap((line) => softWrap(line, maxChars));\n if (lines.length > maxLines)\n lines = [...lines.slice(0, Math.max(1, maxLines - 1)), " \u2026"];\n return lines.map((line) => {\n const out = [];\n let last = 0;\n for (const m of line.matchAll(CODE_TOKEN)) {\n if (m.index > last)\n out.push(`<tspan fill="${C.text}">${esc(line.slice(last, m.index))}</tspan>`);\n const [token, str, num, word] = m;\n const color = str ? (/^\\s*:/.test(line.slice(m.index + token.length)) ? C.jsonKey : C.jsonString) : num ? C.jsonOther : word ? C.key : m.index === 0 || /\\s/.test(line[m.index - 1]) ? C.client : C.text;\n out.push(`<tspan fill="${color}">${esc(token)}</tspan>`);\n last = m.index + token.length;\n }\n if (last < line.length)\n out.push(`<tspan fill="${C.text}">${esc(line.slice(last))}</tspan>`);\n return out.join("");\n });\n}\nconst CODE_TOKEN = /("(?:[^"\\\\]|\\\\.)*"?|\'(?:[^\'\\\\]|\\\\.)*\'?)|(\\b\\d+(?:\\.\\d+)?\\b)|(\\b(?:curl|await|fetch|requests|new|JSON|FormData|URLSearchParams|open|True|False|None|true|false|null)\\b)|(--?[a-zA-Z][\\w-]*)/g;\nfunction softWrap(line, max) {\n const indent = line.match(/^\\s*/)[0].length + 4;\n const out = [];\n let rest = line;\n while (rest.length > max && out.length < 40) {\n const window = rest.slice(0, max);\n const at = Math.max(window.lastIndexOf("/"), window.lastIndexOf(" "), window.lastIndexOf(","));\n const piece = at > indent ? rest.slice(0, at + 1) : (0, text_1.cut)(rest, max);\n out.push(piece);\n rest = " ".repeat(indent) + rest.slice(piece.length).trimStart();\n }\n return [...out, (0, text_1.clip)(rest, max)];\n}\nfunction colorValue(text) {\n const trimmed = text.trim();\n const color = trimmed.startsWith(\'"\') ? C.jsonString : /^[\\d\\-tfn]/.test(trimmed) ? C.jsonOther : C.muted;\n return `<tspan fill="${color}">${esc(text)}</tspan>`;\n}\nfunction textWidth(text, size, mono = false) {\n return text.length * size * (mono ? 0.6 : 0.54);\n}\nfunction fit(text, width, size, mono = false) {\n const max = Math.floor(width / (size * (mono ? 0.6 : 0.54)));\n return text.length > max ? (0, text_1.cut)(text, Math.max(1, max - 1)) + "\u2026" : text;\n}\nfunction wrap(text, width, size, maxLines) {\n const max = Math.max(8, Math.floor(width / (size * 0.54)));\n const words = text.split(/\\s+/).filter(Boolean);\n const lines = [];\n let current = "";\n for (const word of words) {\n const next = current ? `${current} ${word}` : word;\n if (next.length <= max)\n current = next;\n else {\n if (current)\n lines.push(current);\n current = (0, text_1.clip)(word, max);\n }\n }\n if (current)\n lines.push(current);\n if (lines.length > maxLines) {\n const kept = lines.slice(0, maxLines);\n kept[maxLines - 1] = fit(`${kept[maxLines - 1]} \u2026`, width, size);\n return kept;\n }\n return lines;\n}\nconst NOT_XML = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F\\uD800-\\uDFFF\uFFFE\uFFFF]/g;\nfunction esc(text) {\n return text\n .replace(NOT_XML, (c) => (c.length === 2 ? c : c < " " ? " " : ""))\n .replace(/&/g, "&amp;")\n .replace(/</g, "&lt;")\n .replace(/>/g, "&gt;")\n .replace(/"/g, "&quot;")\n .replace(/\'/g, "&#39;");\n}\nconst REASONS = {\n "200": "OK",\n "201": "Created",\n "202": "Accepted",\n "204": "No Content",\n "206": "Partial Content",\n "301": "Moved Permanently",\n "302": "Found",\n "303": "See Other",\n "304": "Not Modified",\n "307": "Temporary Redirect",\n "308": "Permanent Redirect",\n "400": "Bad Request",\n "401": "Unauthorized",\n "402": "Payment Required",\n "403": "Forbidden",\n "404": "Not Found",\n "405": "Method Not Allowed",\n "409": "Conflict",\n "410": "Gone",\n "412": "Precondition Failed",\n "413": "Content Too Large",\n "422": "Unprocessable",\n "429": "Too Many Requests",\n "500": "Server Error",\n "502": "Bad Gateway",\n "503": "Unavailable",\n "504": "Gateway Timeout",\n};\nfunction reason(status) {\n var _a;\n return (_a = REASONS[status]) !== null && _a !== void 0 ? _a : "";\n}\nfunction clamp01(n) {\n return Math.max(0, Math.min(1, n));\n}\nfunction ease(t) {\n const x = clamp01(t);\n return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;\n}\nfunction pulse(p, a, b) {\n if (p < a || p > b)\n return 0;\n return Math.sin(((p - a) / (b - a)) * Math.PI);\n}\n\n}, {"../storyboard/timing":"lib/storyboard/timing","./code":"lib/render/code","../text":"lib/text"}],\n"lib/storyboard/timing": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.VOICE_LEAD = void 0;\nexports.activeScenes = activeScenes;\nexports.sceneDuration = sceneDuration;\nexports.totalDuration = totalDuration;\nexports.voiceCues = voiceCues;\nexports.summaryItems = summaryItems;\nexports.VOICE_LEAD = 400;\nconst VOICE_TAIL = 600;\nfunction activeScenes(sb) {\n return sb.scenes.filter((s) => sb.settings.showFailure || !s.failurePath);\n}\nfunction sceneDuration(sb, scene) {\n if (!sb.settings.voiceover || !scene.voiceMs)\n return scene.duration;\n return Math.max(scene.duration, Math.ceil(exports.VOICE_LEAD + scene.voiceMs + VOICE_TAIL));\n}\nfunction totalDuration(sb) {\n return activeScenes(sb).reduce((sum, s) => sum + sceneDuration(sb, s), 0);\n}\nfunction voiceCues(sb) {\n if (!sb.settings.voiceover)\n return [];\n const cues = [];\n let t = 0;\n for (const scene of activeScenes(sb)) {\n if (scene.voiceMs)\n cues.push({ sceneId: scene.id, at: t + exports.VOICE_LEAD });\n t += sceneDuration(sb, scene);\n }\n return cues;\n}\nfunction summaryItems(sb) {\n const items = [];\n let failure;\n for (const scene of activeScenes(sb)) {\n if (!scene.summaryLine)\n continue;\n if (scene.kind === "call" && scene.outcome === "failure") {\n failure = scene.summaryLine;\n continue;\n }\n items.push(scene.summaryLine);\n if (failure)\n items.push(failure);\n failure = undefined;\n }\n if (failure)\n items.push(failure);\n return items;\n}\n\n}, {}],\n"lib/render/code": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.CODE_STYLES = void 0;\nexports.codeRequest = codeRequest;\nexports.authCode = authCode;\nexports.callCode = callCode;\nexports.codeLines = codeLines;\nconst examples_1 = require("../oas/examples");\nconst timing_1 = require("../storyboard/timing");\nexports.CODE_STYLES = [\n { style: "curl", label: "curl" },\n { style: "javascript", label: "JavaScript" },\n { style: "python", label: "Python" },\n];\nfunction codeRequest(sb, scene) {\n var _a, _b, _c, _d;\n let url = /^[a-z][a-z\\d+.-]*:\\/\\//i.test(scene.path) ? scene.path : `${sb.api.baseUrl}${scene.path}`;\n const body = /^(GET|HEAD)$/.test(scene.method) && isEmptyValue(scene.request) ? undefined : scene.request;\n const req = { method: scene.method, url, headers: [], body, contentType: scene.requestType, ...(scene.encoding ? { encoding: scene.encoding } : {}) };\n const auth = sb.scenes.find((s) => s.kind === "auth");\n const credentials = (_a = scene.credentials) !== null && _a !== void 0 ? _a : ((auth === null || auth === void 0 ? void 0 : auth.kind) === "auth" ? ((_b = auth.credentials) !== null && _b !== void 0 ? _b : auth.headerLine.split("\\n").map(fromLine)) : []);\n const cookies = ((_c = scene.cookies) !== null && _c !== void 0 ? _c : []).map(([name, value]) => `${name}=${value}`);\n for (const credential of credentials) {\n if (!credential)\n continue;\n const c = { ...credential, value: credential.value.replace(/\u2026/g, "...") };\n if (c.in === "query")\n url += (url.includes("?") ? "&" : "?") + `${c.name}=${c.value}`;\n else if (c.in === "cookie")\n cookies.unshift(`${c.name}=${c.value}`);\n else if (c.in === "certificate")\n req.certificate = { cert: c.name, key: c.value };\n else if (c.in === "digest")\n req.digest = { username: c.name, password: c.value };\n else\n req.headers.push([c.name, c.value]);\n }\n req.headers.push(...((_d = scene.headers) !== null && _d !== void 0 ? _d : []));\n if (cookies.length)\n req.headers.push(["Cookie", cookies.join("; ")]);\n return { ...req, url };\n}\nfunction fromLine(line) {\n if (line.startsWith("?")) {\n const eq = line.indexOf("=");\n return eq > 1 ? { in: "query", name: line.slice(1, eq), value: line.slice(eq + 1) } : undefined;\n }\n const colon = line.indexOf(":");\n return colon > 0 ? { in: "header", name: line.slice(0, colon).trim(), value: line.slice(colon + 1).trim() } : undefined;\n}\nfunction bodyKind(req) {\n var _a, _b;\n const type = (_b = (_a = req.contentType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : "";\n if (req.body === undefined)\n return "none";\n if (type.includes("multipart/form-data") && isObject(req.body))\n return "multipart";\n if (type.includes("x-www-form-urlencoded") && isObject(req.body))\n return "form";\n if (typeof req.body === "string" && req.body === examples_1.BINARY_PLACEHOLDER)\n return "binary";\n if (typeof req.body === "string" && type && !/json/.test(type))\n return "text";\n return "json";\n}\nconst isFile = (value) => value === examples_1.BINARY_PLACEHOLDER;\nfunction fieldText(value) {\n return typeof value === "string" ? value : value === undefined || value === null ? "" : typeof value === "object" ? JSON.stringify(value) : String(value);\n}\nfunction formPairs(body, encoding = {}) {\n var _a, _b, _c, _d;\n const out = [];\n for (const [name, value] of Object.entries(body)) {\n if (value === null || value === undefined)\n continue;\n const style = (_b = (_a = encoding[name]) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : "form";\n const explode = (_d = (_c = encoding[name]) === null || _c === void 0 ? void 0 : _c.explode) !== null && _d !== void 0 ? _d : style === "form";\n if (style === "deepObject" && typeof value === "object" && value !== null)\n out.push(...bracketed(name, value));\n else if (Array.isArray(value)) {\n if (explode && style === "form")\n out.push(...value.map((item) => [name, fieldText(item)]));\n else\n out.push([name, value.map(fieldText).join(style === "spaceDelimited" ? " " : style === "pipeDelimited" ? "|" : ",")]);\n }\n else if (isObject(value)) {\n if (explode)\n out.push(...Object.entries(value).map(([key, v]) => [key, fieldText(v)]));\n else\n out.push([name, Object.entries(value).flatMap(([key, v]) => [key, fieldText(v)]).join(",")]);\n }\n else\n out.push([name, fieldText(value)]);\n }\n return out;\n}\nfunction bracketed(name, value) {\n if (Array.isArray(value))\n return value.flatMap((item, i) => bracketed(`${name}[${i}]`, item));\n if (isObject(value))\n return Object.entries(value).flatMap(([key, v]) => bracketed(`${name}[${key}]`, v));\n return [[name, fieldText(value)]];\n}\nfunction formObject(body) {\n return Object.fromEntries(Object.entries(body).flatMap(([key, value]) => (value === null || value === undefined ? [] : [[key, typeof value === "boolean" ? String(value) : value]])));\n}\nfunction flat(body) {\n return Object.values(body).every((value) => typeof value !== "object" || value === null);\n}\nfunction multipartParts(body, encoding = {}) {\n var _a;\n const parts = [];\n for (const [name, value] of Object.entries(body)) {\n if (value === null || value === undefined)\n continue;\n const type = (_a = encoding[name]) === null || _a === void 0 ? void 0 : _a.contentType;\n const items = Array.isArray(value) && !value.some((v) => typeof v === "object" && v !== null) ? value : [value];\n for (const item of items) {\n if (isFile(item))\n parts.push({ name, file: true });\n else if (typeof item === "object" && item !== null)\n parts.push({ name, text: JSON.stringify(item), type: type !== null && type !== void 0 ? type : "application/json" });\n else\n parts.push({ name, text: fieldText(item), ...(type && !/^text\\/plain\\b/i.test(type) ? { type } : {}) });\n }\n }\n return parts;\n}\nfunction filePath(name) {\n return /^[\\w-]+$/.test(name) ? name : "file";\n}\nfunction isObject(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction isEmptyValue(value) {\n return value === undefined || (typeof value === "object" && value !== null && Object.keys(value).length === 0);\n}\nfunction authCode(sb, scene, style) {\n var _a, _b, _c, _d;\n const target = (_b = (_a = scene.requestLine) === null || _a === void 0 ? void 0 : _a.replace(/^POST\\s+/, "")) !== null && _b !== void 0 ? _b : "";\n const url = (_c = scene.tokenUrl) !== null && _c !== void 0 ? _c : (/^https?:\\/\\//i.test(target) ? target : `${sb.api.baseUrl}${target}`);\n return codeLines({ method: "POST", url, headers: [], body: scene.request, contentType: (_d = scene.requestType) !== null && _d !== void 0 ? _d : "application/x-www-form-urlencoded" }, style);\n}\nfunction callCode(sb, scene, style) {\n return sb.api.protocol === "mcp" ? mcpCode(sb, scene, style) : codeLines(codeRequest(sb, scene), style);\n}\nfunction codeLines(req, style) {\n switch (style) {\n case "curl":\n return curl(req);\n case "javascript":\n return javascript(req);\n default:\n return python(req);\n }\n}\nfunction curl(req) {\n var _a, _b, _c;\n const kind = bodyKind(req);\n const parts = [];\n const method = req.method === "HEAD" ? " -I" : req.method === "GET" || (req.method === "POST" && kind !== "none") ? "" : ` -X ${shellQuote(req.method)}`;\n const glob = /[[\\]{}]/.test(req.url) ? " -g" : "";\n parts.push([`curl${glob}${method} ${shellQuote(req.url, /[?&]/.test(req.url))}`]);\n if (req.certificate)\n parts.push([` --cert ${shellQuote(req.certificate.cert)} --key ${shellQuote(req.certificate.key)}`]);\n if (req.digest)\n parts.push([` --digest -u ${shellQuote(`${req.digest.username}:${req.digest.password}`, true)}`]);\n for (const [name, value] of req.headers)\n parts.push([` -H ${shellQuote(`${name}: ${value}`, true)}`]);\n const body = req.body;\n const contentType = (type) => [` -H ${shellQuote(`Content-Type: ${type}`, true)}`];\n if (kind === "json") {\n parts.push(contentType((_a = req.contentType) !== null && _a !== void 0 ? _a : "application/json"));\n parts.push(quotedData(pretty(body, "json", 2)));\n }\n else if (kind === "form" && isObject(body)) {\n for (const [key, value] of formPairs(body, req.encoding))\n parts.push([` --data-urlencode ${shellQuote(`${key}=${value}`, true)}`]);\n }\n else if (kind === "multipart" && isObject(body)) {\n for (const part of multipartParts(body, req.encoding))\n parts.push([` ${formPart(part)}`]);\n }\n else if (kind === "binary") {\n parts.push(contentType((_b = req.contentType) !== null && _b !== void 0 ? _b : "application/octet-stream"), [" --data-binary @file"]);\n }\n else if (kind === "text") {\n parts.push(contentType((_c = req.contentType) !== null && _c !== void 0 ? _c : "text/plain"), quotedData(String(body).split("\\n")));\n }\n return parts.flatMap((part, p) => part.map((line, i) => (p < parts.length - 1 && i === part.length - 1 ? `${line} \\\\` : line)));\n}\nfunction formPart(part) {\n const value = part.file ? `@${filePath(part.name)}` : part.text;\n if (part.name.includes("="))\n return `--form-string ${shellQuote(`${part.name}=${value}`, true)}`;\n if (part.file)\n return `-F ${shellQuote(`${part.name}=${value}`, true)}`;\n if (part.type) {\n const text = readsMore(value) ? `"${value.replace(/[\\\\"]/g, "\\\\$&")}"` : value;\n return `-F \'${escapeSingle(`${part.name}=${text}${formType(part.type)}`)}\'`;\n }\n return `${readsMore(value) ? "--form-string" : "-F"} ${shellQuote(`${part.name}=${value}`, true)}`;\n}\nfunction formType(type) {\n const [essence, ...params] = type.split(",")[0].split(";").map((s) => s.trim());\n if (!/^[\\w.+*-]+\\/[\\w.+*-]+$/.test(essence))\n return "";\n const kept = params.filter((p) => /^[\\w.+-]+=[^\\s"\\\\]*$/.test(p) && !/^(type|filename|headers|encoder)=/i.test(p));\n return `;type=${[essence, ...kept].join("; ")}`;\n}\nfunction readsMore(text) {\n return /^[@<"\\s]|;|\\s$/.test(text);\n}\nfunction quotedData(lines) {\n const body = lines.map(escapeSingle);\n return body.length === 1 ? [` -d \'${body[0]}\'`] : [` -d \'${body[0]}`, ...body.slice(1, -1).map((l) => ` ${l}`), ` ${body.at(-1)}\'`];\n}\nfunction shellQuote(text, always = false) {\n if (!always && !/[^\\w@%+=:,./-]/.test(text))\n return text;\n return /["\\\\$`!]/.test(text) ? `\'${escapeSingle(text)}\'` : `"${text}"`;\n}\nfunction escapeSingle(text) {\n return text.replace(/\'/g, `\'\\\\\'\'`);\n}\nfunction javascript(req) {\n var _a, _b, _c;\n const kind = bodyKind(req);\n const lines = [];\n const headers = [...req.headers];\n let body = [];\n if (req.certificate)\n lines.push(`// Sent over mutual TLS with ${req.certificate.cert} and ${req.certificate.key}`);\n if (req.digest) {\n lines.push("// Answer the API\'s Digest challenge with your username and password");\n headers.push(["Authorization", `Digest username="${req.digest.username}", nonce="...", response="..."`]);\n }\n if (kind === "json") {\n headers.push(["Content-Type", (_a = req.contentType) !== null && _a !== void 0 ? _a : "application/json"]);\n body = wrapLines("body: JSON.stringify(", pretty(req.body, "json", 2), "),");\n }\n else if (kind === "multipart" && isObject(req.body)) {\n lines.push("const form = new FormData();");\n for (const part of multipartParts(req.body, req.encoding)) {\n const value = part.file ? "file" : part.type ? `new Blob([${jsString(part.text)}], { type: ${jsString(part.type)} })` : jsString(part.text);\n lines.push(`form.append(${jsString(part.name)}, ${value});`);\n }\n body = ["body: form,"];\n }\n else if (kind === "form" && isObject(req.body)) {\n body = flat(req.body) && !req.encoding\n ? wrapLines("body: new URLSearchParams(", pretty(formObject(req.body), "json", 2), "),")\n : ["body: new URLSearchParams([", ...formPairs(req.body, req.encoding).map(([k, v]) => ` [${jsString(k)}, ${jsString(v)}],`), "]),"];\n }\n else if (kind === "binary") {\n headers.push(["Content-Type", (_b = req.contentType) !== null && _b !== void 0 ? _b : "application/octet-stream"]);\n body = ["body: file,"];\n }\n else if (kind === "text") {\n headers.push(["Content-Type", (_c = req.contentType) !== null && _c !== void 0 ? _c : "text/plain"]);\n const text = String(req.body);\n body = text.includes("\\n") ? wrapLines("body: `", text.replace(/[`\\\\]|\\$\\{/g, (m) => `\\\\${m}`).split("\\n"), "`,") : [`body: ${jsString(text)},`];\n }\n const options = [\n ...(req.method === "GET" ? [] : [`method: ${jsString(req.method)},`]),\n ...(headers.length ? ["headers: {", ...headers.map(([n, v]) => ` ${jsString(n)}: ${jsString(v)},`), "},"] : []),\n ...body,\n ];\n if (!options.length)\n return [...lines, `await fetch(${jsString(req.url)});`];\n return [...lines, `await fetch(${jsString(req.url)}, {`, ...options.map((l) => ` ${l}`), "});"];\n}\nfunction jsString(text) {\n return JSON.stringify(text);\n}\nconst PYTHON_METHODS = new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);\nfunction python(req) {\n var _a, _b;\n const kind = bodyKind(req);\n const args = [[`${jsString(req.url)},`]];\n const headers = [...req.headers];\n if (kind === "binary")\n headers.push(["Content-Type", (_a = req.contentType) !== null && _a !== void 0 ? _a : "application/octet-stream"]);\n if (kind === "text")\n headers.push(["Content-Type", (_b = req.contentType) !== null && _b !== void 0 ? _b : "text/plain"]);\n if (headers.length === 1)\n args.push([`headers={${jsString(headers[0][0])}: ${jsString(headers[0][1])}},`]);\n else if (headers.length)\n args.push(["headers={", ...headers.map(([n, v]) => ` ${jsString(n)}: ${jsString(v)},`), "},"]);\n if (req.certificate)\n args.push([`cert=(${jsString(req.certificate.cert)}, ${jsString(req.certificate.key)}),`]);\n if (req.digest)\n args.push([`auth=requests.auth.HTTPDigestAuth(${jsString(req.digest.username)}, ${jsString(req.digest.password)}),`]);\n if (kind === "json")\n args.push(wrapLines("json=", pretty(req.body, "python", 4), ","));\n else if (kind === "form" && isObject(req.body)) {\n if (flat(req.body) && !req.encoding)\n args.push(wrapLines("data=", pretty(formObject(req.body), "python", 4), ","));\n else\n args.push(["data=[", ...formPairs(req.body, req.encoding).map(([k, v]) => ` (${jsString(k)}, ${jsString(v)}),`), "],"]);\n }\n else if (kind === "multipart" && isObject(req.body)) {\n const parts = multipartParts(req.body, req.encoding);\n const typed = parts.filter((p) => p.file || p.type);\n const files = typed.length ? typed : parts;\n const fields = typed.length ? parts.filter((p) => !p.file && !p.type) : [];\n const file = (p) => (p.file ? `open(${jsString(filePath(p.name))}, "rb")` : p.type ? `(None, ${jsString(p.text)}, ${jsString(p.type)})` : `(None, ${jsString(p.text)})`);\n const twice = (list) => new Set(list.map((p) => p.name)).size < list.length;\n if (files.length) {\n args.push(twice(files) ? ["files=[", ...files.map((p) => ` (${jsString(p.name)}, ${file(p)}),`), "],"] : ["files={", ...files.map((p) => ` ${jsString(p.name)}: ${file(p)},`), "},"]);\n }\n if (fields.length) {\n args.push(twice(fields) ? ["data=[", ...fields.map((p) => ` (${jsString(p.name)}, ${jsString(p.text)}),`), "],"] : ["data={", ...fields.map((p) => ` ${jsString(p.name)}: ${jsString(p.text)},`), "},"]);\n }\n }\n else if (kind === "binary")\n args.push([`data=open("file", "rb"),`]);\n else if (kind === "text") {\n const text = String(req.body);\n args.push(text.includes("\\n") ? wrapLines(\'data="""\', text.replace(/\\\\/g, "\\\\\\\\").replace(/"""/g, \'\\\\"\\\\"\\\\"\').split("\\n"), \'""",\') : [`data=${jsString(text)},`]);\n }\n const call = PYTHON_METHODS.has(req.method) ? `requests.${req.method.toLowerCase()}(` : `requests.request(${jsString(req.method)},`;\n return [call, ...args.flat().map((l) => ` ${l}`), ")"];\n}\nconst MCP_VERSION = "2026-07-28";\nconst VERSION_HEADER_SINCE = "2025-06-18";\nconst SESSION_ID = "1868a90c...";\nconst CLIENT_INFO = { name: "your-agent", version: "1.0.0" };\nfunction mcpCode(sb, scene, style) {\n const http = /^https?:\\/\\//i.test(sb.api.baseUrl);\n const auth = sb.scenes.some((s) => s.kind === "auth");\n switch (style) {\n case "curl":\n return mcpWire(sb, scene, http);\n case "javascript":\n return mcpJavaScript(sb, scene, http, auth);\n default:\n return mcpPython(sb, scene, http, auth);\n }\n}\nfunction rpcBody(sb, scene, modern) {\n var _a;\n const meta = { "io.modelcontextprotocol/protocolVersion": MCP_VERSION, "io.modelcontextprotocol/clientInfo": CLIENT_INFO, "io.modelcontextprotocol/clientCapabilities": {} };\n const params = scene.method === "tools/call"\n ? { name: scene.path, arguments: (_a = scene.request) !== null && _a !== void 0 ? _a : {} }\n : scene.method === "resources/read"\n ? { uri: scene.path }\n : scene.method === "prompts/get"\n ? { name: scene.path, ...(scene.request !== undefined ? { arguments: scene.request } : {}) }\n : {};\n if (!modern)\n return { jsonrpc: "2.0", id: rpcId(sb, scene), method: scene.method, ...(Object.keys(params).length ? { params } : {}) };\n return { jsonrpc: "2.0", id: rpcId(sb, scene), method: scene.method, params: { ...params, _meta: meta } };\n}\nfunction rpcId(sb, scene) {\n const index = (0, timing_1.activeScenes)(sb)\n .filter((s) => s.kind === "call")\n .indexOf(scene);\n return index >= 0 ? index + 1 : scene.step;\n}\nfunction mcpWire(sb, scene, http) {\n var _a, _b, _c;\n const revision = (_a = sb.api.revision) !== null && _a !== void 0 ? _a : MCP_VERSION;\n const modern = revision >= MCP_VERSION;\n const body = JSON.stringify(rpcBody(sb, scene, modern));\n if (!http) {\n if (modern)\n return [`echo \'${escapeSingle(body)}\' \\\\`, ` | ${sb.api.baseUrl}`];\n const init = JSON.stringify({ jsonrpc: "2.0", id: 0, method: "initialize", params: { protocolVersion: revision, capabilities: {}, clientInfo: CLIENT_INFO } });\n return [`printf \'%s\\\\n\' \\\\`, ` \'${escapeSingle(init)}\' \\\\`, ` \'{"jsonrpc":"2.0","method":"notifications/initialized"}\' \\\\`, ` \'${escapeSingle(body)}\' \\\\`, ` | ${sb.api.baseUrl}`];\n }\n const headers = [["Accept", "application/json, text/event-stream"]];\n if (modern) {\n headers.push(["MCP-Protocol-Version", MCP_VERSION], ["Mcp-Method", scene.method]);\n if (scene.method !== "tools/list")\n headers.push(["Mcp-Name", headerValue(scene.path)]);\n for (const { name, path } of (_b = scene.paramHeaders) !== null && _b !== void 0 ? _b : []) {\n const value = path.reduce((at, key) => (isObject(at) ? at[key] : undefined), scene.request);\n if (typeof value === "string" || typeof value === "boolean" || (typeof value === "number" && Number.isSafeInteger(value)))\n headers.push([`Mcp-Param-${name}`, headerValue(String(value))]);\n }\n }\n else {\n if (revision >= VERSION_HEADER_SINCE)\n headers.push(["MCP-Protocol-Version", revision]);\n if (sb.api.session !== false)\n headers.push(["Mcp-Session-Id", SESSION_ID]);\n }\n const auth = sb.scenes.find((s) => s.kind === "auth");\n if ((auth === null || auth === void 0 ? void 0 : auth.kind) === "auth")\n for (const c of (_c = auth.credentials) !== null && _c !== void 0 ? _c : [])\n if (c.in === "header")\n headers.push([c.name, c.value.replace(/\u2026/g, "...")]);\n return [`curl ${shellQuote(sb.api.baseUrl)} \\\\`, ...headers.map(([n, v]) => ` -H ${shellQuote(`${n}: ${v}`, true)} \\\\`), ` --json \'${escapeSingle(body)}\'`];\n}\nfunction headerValue(text) {\n const plain = /^[\\x21-\\x7e]([\\x20-\\x7e\\t]*[\\x21-\\x7e])?$/.test(text) && !/^=\\?base64\\?.*\\?=$/.test(text);\n if (plain)\n return text;\n const bytes = new TextEncoder().encode(text);\n let binary = "";\n for (const byte of bytes)\n binary += String.fromCharCode(byte);\n return `=?base64?${btoa(binary)}?=`;\n}\nfunction mcpJavaScript(sb, scene, http, auth) {\n var _a, _b, _c;\n switch (scene.method) {\n case "tools/list": {\n const command = sb.api.baseUrl.split(" ");\n const transport = http\n ? [` new StreamableHTTPClientTransport(new URL(${jsString(sb.api.baseUrl)})${auth ? ", { authProvider }" : ""}),`]\n : [` new StdioClientTransport({ command: ${jsString(command[0])}, args: ${list(command.slice(1))} }),`];\n const negotiate = ((_a = sb.api.revision) !== null && _a !== void 0 ? _a : MCP_VERSION) >= MCP_VERSION ? `, { versionNegotiation: { mode: "auto" } }` : "";\n return [\n `import { Client${http ? ", StreamableHTTPClientTransport" : ""} } from "@modelcontextprotocol/client";`,\n ...(http ? [] : [`import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";`]),\n "",\n `const client = new Client({ name: "your-agent", version: "1.0.0" }${negotiate});`,\n "await client.connect(",\n ...transport,\n ");",\n "const { tools } = await client.listTools();",\n ];\n }\n case "resources/read":\n return [`const { contents } = await client.readResource({ uri: ${jsString(scene.path)} });`];\n case "prompts/get":\n return ["const { messages } = await client.getPrompt({", ` name: ${jsString(scene.path)},`, ...indented(" ", wrapLines("arguments: ", pretty((_b = scene.request) !== null && _b !== void 0 ? _b : {}, "json", 2), ",")), "});"];\n default:\n return ["const result = await client.callTool({", ` name: ${jsString(scene.path)},`, ...indented(" ", wrapLines("arguments: ", pretty((_c = scene.request) !== null && _c !== void 0 ? _c : {}, "json", 2), ",")), "});"];\n }\n}\nfunction mcpPython(sb, scene, http, auth) {\n var _a, _b;\n switch (scene.method) {\n case "tools/list": {\n if (http && auth) {\n return [\n "import httpx2",\n "from mcp import Client",\n "from mcp.client.streamable_http import streamable_http_client",\n "",\n "http = httpx2.AsyncClient(auth=oauth) # an OAuthClientProvider",\n `async with Client(streamable_http_client(${jsString(sb.api.baseUrl)}, http_client=http)) as client:`,\n " result = await client.list_tools()",\n ];\n }\n if (http)\n return ["from mcp import Client", "", `async with Client(${jsString(sb.api.baseUrl)}) as client:`, " result = await client.list_tools()"];\n const [command, ...args] = sb.api.baseUrl.split(" ");\n return [\n "from mcp import Client, StdioServerParameters",\n "",\n `server = StdioServerParameters(command=${jsString(command)}, args=${list(args)})`,\n "async with Client(server) as client:",\n " result = await client.list_tools()",\n ];\n }\n case "resources/read":\n return [`result = await client.read_resource(${jsString(scene.path)})`];\n case "prompts/get":\n return ["result = await client.get_prompt(", ` ${jsString(scene.path)},`, ...indented(" ", wrapLines("", pretty((_a = scene.request) !== null && _a !== void 0 ? _a : {}, "python", 4), ",")), ")"];\n default:\n return ["result = await client.call_tool(", ` ${jsString(scene.path)},`, ...indented(" ", wrapLines("", pretty((_b = scene.request) !== null && _b !== void 0 ? _b : {}, "python", 4), ",")), ")"];\n }\n}\nfunction list(items) {\n return `[${items.map(jsString).join(", ")}]`;\n}\nfunction indented(indent, lines) {\n return lines.map((line) => `${indent}${line}`);\n}\nfunction wrapLines(head, lines, tail) {\n if (lines.length === 1)\n return [`${head}${lines[0]}${tail}`];\n return [`${head}${lines[0]}`, ...lines.slice(1, -1), `${lines.at(-1)}${tail}`];\n}\nfunction pretty(value, as, indent) {\n var _a;\n const text = (_a = JSON.stringify(value, null, indent)) !== null && _a !== void 0 ? _a : "null";\n if (as === "json")\n return text.split("\\n");\n return text.split("\\n").map((line) => line.replace(/("(?:[^"\\\\]|\\\\.)*")|\\b(true|false|null)\\b/g, (_, str, word) => str !== null && str !== void 0 ? str : { true: "True", false: "False", null: "None" }[word]));\n}\n\n}, {"../oas/examples":"lib/oas/examples","../storyboard/timing":"lib/storyboard/timing"}],\n"lib/oas/examples": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.PLACEHOLDER_UUID = exports.BINARY_PLACEHOLDER = void 0;\nexports.mediaKind = mediaKind;\nexports.isTextKind = isTextKind;\nexports.exampleForMedia = exampleForMedia;\nexports.toXml = toXml;\nexports.exampleForParameter = exampleForParameter;\nexports.exampleFromSchema = exampleFromSchema;\nexports.conform = conform;\nexports.placeholder = placeholder;\nexports.isPlaceholder = isPlaceholder;\nexports.patternExample = patternExample;\nexports.isIdName = isIdName;\nexports.idLike = idLike;\nexports.uuidLike = uuidLike;\nexports.singular = singular;\nconst fit_1 = require("./fit");\nexports.BINARY_PLACEHOLDER = "<binary data>";\nconst BINARY_MEDIA = /octet-stream|^(image|audio|video|font)\\/|application\\/(pdf|zip|gzip|x-tar)/i;\nfunction mediaKind(contentType) {\n const type = contentType.toLowerCase().split(";")[0].trim();\n if (/^application\\/(x-)?(ndjson|jsonl|jsonlines|json-lines)$|json-seq$/.test(type))\n return "sequence";\n if (/json/.test(type))\n return "json";\n if (type === "application/x-www-form-urlencoded")\n return "form";\n if (type.startsWith("multipart/"))\n return "multipart";\n if (/[/+]xml$/.test(type))\n return "xml";\n if (type === "text/event-stream")\n return "events";\n if (BINARY_MEDIA.test(type))\n return "binary";\n if (type.startsWith("text/") || /^application\\/(x-)?(yaml|csv|graphql|javascript|sql)$/.test(type))\n return "text";\n return "json";\n}\nfunction isTextKind(kind) {\n return kind === "xml" || kind === "sequence" || kind === "events" || kind === "text";\n}\nfunction exampleForMedia(media, mode = "response", contentType = "", subject) {\n if (!media)\n return { value: undefined, generated: false };\n const kind = mediaKind(contentType);\n const given = documentedExample(media, kind);\n if (given !== undefined && !isTextKind(kind) && media.schema && otherShape(given, media.schema)) {\n return { value: conform(exampleFromSchema(media.schema, "", 0, mode, undefined, subject), media.schema, mode, "", 0, undefined, subject), generated: true };\n }\n if (given !== undefined) {\n if (!isTextKind(kind) && kind !== "binary" && media.schema) {\n const fixed = conform(given, media.schema, mode, "", 0, undefined, subject);\n return { value: fixed, generated: fixed !== given };\n }\n return { value: serialize(given, kind, media, contentType), generated: false };\n }\n if (BINARY_MEDIA.test(contentType) && (!media.schema || media.schema.type === "string" || media.schema.format === "binary")) {\n return { value: exports.BINARY_PLACEHOLDER, generated: true };\n }\n if (isTextKind(kind) && (media.schema || media.itemSchema))\n return { value: textFromSchema(media, kind, mode, contentType), generated: true };\n if (media.schema)\n return { value: conform(exampleFromSchema(media.schema, "", 0, mode, undefined, subject), media.schema, mode, "", 0, undefined, subject), generated: true };\n return { value: undefined, generated: false };\n}\nfunction otherShape(example, schema) {\n if (!isRecord(example) || !Object.keys(example).length)\n return false;\n const names = new Set();\n const patterns = [];\n let open = false;\n const collect = (s, depth) => {\n var _a, _b, _c, _d, _e;\n if (!s || typeof s !== "object" || depth > 6)\n return;\n const target = (0, fit_1.circularTarget)(s);\n if (target)\n return collect(target, depth + 1);\n for (const key of Object.keys((_a = s.properties) !== null && _a !== void 0 ? _a : {}))\n names.add(key);\n patterns.push(...Object.keys((_b = s.patternProperties) !== null && _b !== void 0 ? _b : {}));\n if (isRecord(s.additionalProperties))\n open = true;\n for (const part of [...((_c = s.allOf) !== null && _c !== void 0 ? _c : []), ...((_d = s.oneOf) !== null && _d !== void 0 ? _d : []), ...((_e = s.anyOf) !== null && _e !== void 0 ? _e : [])])\n collect(part, depth + 1);\n };\n collect(schema, 0);\n if (!names.size || open)\n return false;\n return !Object.keys(example).some((key) => names.has(key) || patterns.some((pattern) => (0, fit_1.matchesPattern)(pattern, key)));\n}\nfunction documentedExample(media, kind) {\n var _a;\n if (media.example !== undefined)\n return media.example;\n for (const example of Object.values((_a = media.examples) !== null && _a !== void 0 ? _a : {})) {\n const value = exampleValue(example, isTextKind(kind));\n if (value !== undefined)\n return kind === "json" && (example === null || example === void 0 ? void 0 : example.dataValue) === undefined && (example === null || example === void 0 ? void 0 : example.value) === undefined ? parseJsonText(value) : value;\n }\n return undefined;\n}\nfunction exampleValue(example, text) {\n if (!example || typeof example !== "object")\n return undefined;\n const serialized = typeof example.serializedValue === "string" ? example.serializedValue : undefined;\n if (text && serialized !== undefined)\n return serialized;\n if (example.dataValue !== undefined)\n return example.dataValue;\n return example.value !== undefined ? example.value : serialized;\n}\nfunction parseJsonText(value) {\n if (typeof value !== "string")\n return value;\n try {\n return JSON.parse(value);\n }\n catch {\n return value;\n }\n}\nfunction serialize(value, kind, media, contentType) {\n if (!isTextKind(kind) || typeof value === "string")\n return value;\n switch (kind) {\n case "xml":\n return toXml(value, media.schema);\n case "sequence":\n return (Array.isArray(value) ? value : [value]).map((item) => JSON.stringify(item)).join("\\n");\n case "events":\n return (Array.isArray(value) ? value : [value]).map((event) => toEvent(event, media.itemSchema)).join("\\n\\n");\n default:\n return toText(value, contentType);\n }\n}\nfunction textFromSchema(media, kind, mode, contentType) {\n var _a, _b;\n const schema = (_a = media.schema) !== null && _a !== void 0 ? _a : {};\n const made = (s) => conform(exampleFromSchema(s, "", 0, mode), s, mode);\n if (kind === "xml")\n return toXml(made(schema), schema);\n if (kind === "sequence" || kind === "events") {\n const item = (_b = media.itemSchema) !== null && _b !== void 0 ? _b : (schema.items && (schema.type === "array" || Array.isArray(schema.type)) ? schema.items : schema);\n const value = made(item);\n return kind === "sequence" ? JSON.stringify(value) : toEvent(value, item);\n }\n return toText(made(schema), contentType);\n}\nfunction toEvent(value, schema) {\n var _a, _b, _c;\n const fields = isRecord(value) && "data" in value ? value : { data: value };\n const lines = [];\n for (const key of ["event", "id", "retry"])\n if (fields[key] !== undefined && fields[key] !== null)\n lines.push(`${key}: ${String(fields[key])}`);\n let data = fields.data;\n const dataSchema = (_a = schema === null || schema === void 0 ? void 0 : schema.properties) === null || _a === void 0 ? void 0 : _a.data;\n if (typeof data === "string" && (dataSchema === null || dataSchema === void 0 ? void 0 : dataSchema.contentSchema) && /json/i.test((_b = dataSchema.contentMediaType) !== null && _b !== void 0 ? _b : "json"))\n data = exampleFromSchema(dataSchema.contentSchema, "data");\n for (const line of (typeof data === "string" ? data : (_c = JSON.stringify(data)) !== null && _c !== void 0 ? _c : "").split("\\n"))\n lines.push(`data: ${line}`);\n return lines.join("\\n");\n}\nfunction toText(value, contentType) {\n if (typeof value === "string")\n return value;\n if (/csv/i.test(contentType) && Array.isArray(value) && value.every(isRecord)) {\n const columns = [...new Set(value.flatMap((row) => Object.keys(row)))];\n const cell = (v) => (/[",\\n]/.test(String(v !== null && v !== void 0 ? v : "")) ? `"${String(v).replace(/"/g, \'""\')}"` : String(v !== null && v !== void 0 ? v : ""));\n return [columns.join(","), ...value.map((row) => columns.map((c) => cell(row[c])).join(","))].join("\\n");\n }\n return typeof value === "object" && value !== null ? JSON.stringify(value, null, 2) : String(value);\n}\nfunction toXml(value, schema, name) {\n var _a, _b, _c, _d, _e, _f, _g;\n const lines = [];\n const rootName = (_d = (_c = (_b = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : name) !== null && _c !== void 0 ? _c : schema === null || schema === void 0 ? void 0 : schema.title) !== null && _d !== void 0 ? _d : (Array.isArray(value) ? "items" : "data");\n if (Array.isArray(value)) {\n const items = schema === null || schema === void 0 ? void 0 : schema.items;\n const itemName = (_g = (_f = (_e = items === null || items === void 0 ? void 0 : items.xml) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : items === null || items === void 0 ? void 0 : items.title) !== null && _g !== void 0 ? _g : singular(rootName);\n lines.push(`<${xmlName(rootName, schema)}${namespaceAttr(schema)}>`);\n for (const item of value)\n writeXml(lines, itemName, item, items, 1);\n lines.push(`</${xmlName(rootName, schema)}>`);\n }\n else {\n writeXml(lines, rootName, value, schema, 0, true);\n }\n return lines.join("\\n");\n}\nfunction writeXml(lines, name, value, schema, depth, root = false) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j;\n const pad = " ".repeat(depth);\n const xml = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) !== null && _a !== void 0 ? _a : {};\n const qname = xmlName((_b = xml.name) !== null && _b !== void 0 ? _b : name, schema);\n if (Array.isArray(value)) {\n const items = schema === null || schema === void 0 ? void 0 : schema.items;\n const itemName = (_d = (_c = items === null || items === void 0 ? void 0 : items.xml) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : name;\n if (xml.nodeType === "element" || xml.wrapped === true) {\n lines.push(`${pad}<${qname}${namespaceAttr(schema)}>`);\n for (const item of value)\n writeXml(lines, itemName, item, items, depth + 1);\n lines.push(`${pad}</${qname}>`);\n }\n else {\n for (const item of value)\n writeXml(lines, itemName, item, items, depth);\n }\n return;\n }\n if (value === null || value === undefined) {\n lines.push(`${pad}<${qname} xsi:nil="true"/>`);\n return;\n }\n if (!isRecord(value)) {\n lines.push(`${pad}<${qname}${root ? namespaceAttr(schema) : ""}>${escapeXml(String(value))}</${qname}>`);\n return;\n }\n const properties = propertiesOf(schema);\n const attributes = [];\n const children = [];\n let text;\n for (const [key, child] of Object.entries(value)) {\n const prop = properties[key];\n const nodeType = (_f = (_e = prop === null || prop === void 0 ? void 0 : prop.xml) === null || _e === void 0 ? void 0 : _e.nodeType) !== null && _f !== void 0 ? _f : (((_g = prop === null || prop === void 0 ? void 0 : prop.xml) === null || _g === void 0 ? void 0 : _g.attribute) ? "attribute" : undefined);\n if (nodeType === "attribute") {\n if (child !== null && child !== undefined)\n attributes.push(` ${xmlName((_j = (_h = prop === null || prop === void 0 ? void 0 : prop.xml) === null || _h === void 0 ? void 0 : _h.name) !== null && _j !== void 0 ? _j : key, prop)}="${escapeXml(String(child), true)}"`);\n }\n else if (nodeType === "text" || nodeType === "cdata") {\n text = nodeType === "cdata" ? `<![CDATA[${String(child)}]]>` : escapeXml(String(child));\n }\n else {\n children.push([key, child, prop]);\n }\n }\n const open = `${pad}<${qname}${namespaceAttr(schema)}${attributes.join("")}`;\n if (!children.length) {\n lines.push(text === undefined ? `${open}/>` : `${open}>${text}</${qname}>`);\n return;\n }\n lines.push(`${open}>${text !== null && text !== void 0 ? text : ""}`);\n for (const [key, child, prop] of children)\n writeXml(lines, key, child, prop, depth + 1);\n lines.push(`${pad}</${qname}>`);\n}\nfunction propertiesOf(schema, depth = 0) {\n var _a, _b;\n if (!schema || depth > 4)\n return {};\n const out = {};\n for (const part of (_a = schema.allOf) !== null && _a !== void 0 ? _a : [])\n Object.assign(out, propertiesOf(part, depth + 1));\n return Object.assign(out, (_b = schema.properties) !== null && _b !== void 0 ? _b : {});\n}\nfunction xmlName(name, schema) {\n var _a;\n let clean = name.replace(/[^\\w.:-]/g, "_");\n if (!/^[A-Za-z_]/.test(clean))\n clean = `_${clean}`;\n const prefix = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _a === void 0 ? void 0 : _a.prefix;\n return prefix && !clean.includes(":") ? `${prefix}:${clean}` : clean;\n}\nfunction namespaceAttr(schema) {\n var _a, _b;\n const ns = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _a === void 0 ? void 0 : _a.namespace;\n if (!ns)\n return "";\n return ` xmlns${((_b = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _b === void 0 ? void 0 : _b.prefix) ? `:${schema.xml.prefix}` : ""}="${escapeXml(ns, true)}"`;\n}\nfunction escapeXml(text, attribute = false) {\n if (isPlaceholder(text))\n return `{${text.slice(1, -1)}}`;\n const out = text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");\n return attribute ? out.replace(/"/g, "&quot;") : out;\n}\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction exampleForParameter(param) {\n var _a;\n const typed = (value) => (value === undefined || !param.schema ? value : asType(value, param.schema));\n const given = typed(param.example);\n if (given !== undefined)\n return given;\n for (const example of Object.values((_a = param.examples) !== null && _a !== void 0 ? _a : {})) {\n const value = typed(exampleValue(example, false));\n if (value !== undefined)\n return value;\n }\n const content = param.content && Object.entries(param.content)[0];\n if (content)\n return exampleForMedia(content[1], "request", content[0]).value;\n if (param.schema)\n return exampleFromSchema(param.schema, param.name);\n return idLike(param.name);\n}\nconst MAX_DEPTH = 4;\nconst HARD_DEPTH = 12;\nconst MAX_PROPERTIES = 12;\nconst NODE_BUDGET = 250;\nconst MAX_LIST = 20;\nconst MAX_TRIES = 6;\nfunction exampleFromSchema(schema, name = "", depth = 0, mode = "response", budget = { left: NODE_BUDGET }, owner) {\n var _a;\n if (!schema || typeof schema !== "object")\n return null;\n budget.left--;\n const target = (0, fit_1.circularTarget)(schema);\n if (target)\n return depth >= HARD_DEPTH ? {} : exampleFromSchema(target, name, Math.max(depth + 1, MAX_DEPTH), mode, budget, owner);\n if (schema["x-circular"])\n return depth > 1 ? null : { id: idLike((_a = schema.title) !== null && _a !== void 0 ? _a : name) };\n for (const example of [schema.example, ...(Array.isArray(schema.examples) ? schema.examples.slice(0, 1) : [])]) {\n const value = example === undefined ? undefined : asType(example, schema);\n if (value !== undefined)\n return fitted(value, schema, name, depth, mode, budget, owner);\n }\n if (schema.const !== undefined)\n return schema.const;\n const fallback = schema.default === undefined ? undefined : asType(schema.default, schema);\n if (fallback !== undefined)\n return fitted(fallback, schema, name, depth, mode, budget, owner);\n return fromSchema(schema, name, depth, mode, budget, owner);\n}\nfunction fromSchema(schema, name, depth, mode, budget, owner) {\n var _a, _b;\n if (Array.isArray(schema.enum) && schema.enum.length)\n return enumValue(schema.enum, schema.description);\n if ((_a = schema.allOf) === null || _a === void 0 ? void 0 : _a.length)\n return fromParts(schema, name, depth, mode, budget, owner);\n const variants = ((_b = schema.oneOf) === null || _b === void 0 ? void 0 : _b.length) ? schema.oneOf : schema.anyOf;\n if (variants === null || variants === void 0 ? void 0 : variants.length)\n return fromVariant(schema, variants, name, depth, mode, budget, owner);\n const type = Array.isArray(schema.type) ? schema.type.find((t) => t !== "null") : schema.type;\n const inferred = type !== null && type !== void 0 ? type : (schema.properties ? "object" : schema.items || schema.prefixItems ? "array" : undefined);\n switch (inferred) {\n case "object":\n return objectFor(schema, depth, mode, budget, owner);\n case "array":\n return listFor(schema, name, depth, mode, budget, owner);\n case "integer":\n case "number":\n return numberFor(schema, name, inferred === "integer");\n case "boolean":\n return booleanFor(name);\n case "string":\n return stringFor(schema, name, owner);\n default:\n return null;\n }\n}\nfunction objectFor(schema, depth, mode, budget, owner) {\n var _a, _b;\n const out = {};\n if (depth >= HARD_DEPTH)\n return out;\n const required = new Set(Array.isArray(schema.required) ? schema.required : []);\n let props = Object.entries((_a = schema.properties) !== null && _a !== void 0 ? _a : {}).filter(([, prop]) => !(mode === "request" ? prop === null || prop === void 0 ? void 0 : prop.readOnly : prop === null || prop === void 0 ? void 0 : prop.writeOnly));\n props = props.filter(([key, prop]) => required.has(key) || (prop === null || prop === void 0 ? void 0 : prop.deprecated) !== true);\n const answer = mode === "response" && !budget.full;\n if (answer)\n props = props.filter(([key, prop]) => required.has(key) || ((ID_FIELDS.has(key) || saysSomething(prop)) && !brokenExample(prop, mode)));\n if (depth >= MAX_DEPTH)\n props = props.filter(([key]) => required.has(key));\n props.sort(([a], [b]) => Number(required.has(b)) - Number(required.has(a)));\n if (mode === "request")\n props = telling(props, required);\n for (const [key, prop] of props) {\n if (!required.has(key) && (budget.left <= 0 || Object.keys(out).length >= MAX_PROPERTIES))\n continue;\n if (!required.has(key) && recursive(prop))\n continue;\n const value = fieldValue(prop, key, depth + 1, mode, budget, (_b = schema.title) !== null && _b !== void 0 ? _b : owner);\n if (!required.has(key) && (value === null || (mode === "request" && isEmpty(value))))\n continue;\n out[key] = value;\n }\n return out;\n}\nfunction fieldValue(prop, key, depth, mode, budget, owner) {\n if (mode === "response" && !budget.full && allowsNull(prop) && (!givesValue(prop) || brokenExample(prop, mode)))\n return null;\n return exampleFromSchema(prop, key, depth, mode, budget, owner);\n}\nfunction brokenExample(prop, mode) {\n if (!prop || typeof prop !== "object" || prop.example === undefined || prop.example === null)\n return false;\n if ((0, fit_1.fits)(prop.example, prop, mode))\n return false;\n const typed = asType(prop.example, prop);\n if (typed === undefined)\n return true;\n const plain = (v) => v === null || typeof v !== "object";\n return (plain(typed) || (Array.isArray(typed) && typed.every(plain))) && !(0, fit_1.fits)(typed, prop, mode);\n}\nfunction recursive(schema) {\n const own = (s) => isRecord(s) && s["x-circular"] !== undefined;\n return own(schema) || (isRecord(schema) && own(schema.items));\n}\nconst ID_FIELDS = new Set(["id", "sid", "gid", "uuid"]);\nfunction givesValue(schema, depth = 0) {\n var _a, _b, _c;\n if (!schema || typeof schema !== "object" || depth > 4)\n return false;\n if (schema.example !== undefined || (Array.isArray(schema.examples) && schema.examples.length > 0) || schema.default !== undefined || schema.const !== undefined)\n return true;\n if (Array.isArray(schema.enum) && schema.enum.filter((v) => v !== null).length === 1 && !allowsNull(schema))\n return true;\n const target = (0, fit_1.circularTarget)(schema);\n if (target)\n return givesValue(target, depth + 1);\n const parts = [...((_a = schema.allOf) !== null && _a !== void 0 ? _a : []), ...((_b = schema.oneOf) !== null && _b !== void 0 ? _b : []), ...((_c = schema.anyOf) !== null && _c !== void 0 ? _c : [])];\n return parts.some((part) => part && typeof part === "object" && part.type !== "null" && givesValue(part, depth + 1));\n}\nconst saying = new WeakMap();\nfunction saysSomething(schema, depth = 0) {\n var _a, _b, _c, _d, _e, _f;\n if (!schema || typeof schema !== "object" || depth > 1)\n return false;\n const found = (_a = saying.get(schema)) !== null && _a !== void 0 ? _a : [];\n if (found[depth] !== undefined)\n return found[depth];\n found[depth] = false;\n saying.set(schema, found);\n const target = (0, fit_1.circularTarget)(schema);\n const parts = [...((_b = schema.allOf) !== null && _b !== void 0 ? _b : []), ...((_c = schema.oneOf) !== null && _c !== void 0 ? _c : []), ...((_d = schema.anyOf) !== null && _d !== void 0 ? _d : []), ...(target ? [target] : [])];\n const inside = [...Object.values((_e = schema.properties) !== null && _e !== void 0 ? _e : {}), ...(schema.items && typeof schema.items === "object" ? [schema.items] : []), ...((_f = schema.prefixItems) !== null && _f !== void 0 ? _f : [])];\n const usable = (part) => part && typeof part === "object" && part.type !== "null";\n const own = depth === 0 ? givesValue(schema) : schema.example !== undefined || (Array.isArray(schema.examples) && schema.examples.length > 0);\n const says = own || parts.some((part) => usable(part) && saysSomething(part, depth)) || inside.some((part) => usable(part) && saysSomething(part, depth + 1));\n found[depth] = says;\n return says;\n}\nfunction allowsNull(schema) {\n var _a, _b;\n if (!schema || typeof schema !== "object")\n return false;\n if (schema.nullable === true || (Array.isArray(schema.type) && schema.type.includes("null")) || schema.type === "null")\n return true;\n if (Array.isArray(schema.enum) && schema.enum.includes(null))\n return true;\n const variants = [...((_a = schema.oneOf) !== null && _a !== void 0 ? _a : []), ...((_b = schema.anyOf) !== null && _b !== void 0 ? _b : [])];\n const isNull = (v) => v.type === "null" || (Array.isArray(v.type) && v.type.length === 1 && v.type[0] === "null") || (Array.isArray(v.enum) && v.enum.length === 1 && v.enum[0] === null);\n return variants.some((v) => v && typeof v === "object" && isNull(v));\n}\nfunction listFor(schema, name, depth, mode, budget, owner) {\n var _a;\n const least = Math.min(Math.max(0, typeof schema.minItems === "number" ? schema.minItems : 0), MAX_LIST);\n const most = typeof schema.maxItems === "number" ? Math.max(0, schema.maxItems) : Infinity;\n if (most === 0)\n return [];\n if ((depth >= MAX_DEPTH || budget.left <= 0) && least === 0)\n return [];\n const itemName = singular(name);\n const itemOwner = itemName && !CONTAINERS.test(itemName) ? itemName : owner;\n const prefix = ((_a = schema.prefixItems) !== null && _a !== void 0 ? _a : []).slice(0, most);\n const out = prefix.map((item) => exampleFromSchema(item, itemName, depth + 1, mode, budget, itemOwner));\n const items = isRecord(schema.items) ? schema.items : undefined;\n const answer = mode === "response" && !budget.full;\n const shows = !answer || depth === 0 || (depth === 1 && CONTAINERS.test(name)) || saysSomething(items);\n const want = Math.min(most, Math.max(least, prefix.length ? prefix.length : items && shows ? 1 : 0));\n while (out.length < want) {\n if (!items) {\n out.push(null);\n continue;\n }\n const value = exampleFromSchema(items, itemName, depth + 1, mode, budget, itemOwner);\n if (answer && out.length >= least && isRecord(value) && !Object.keys(value).length)\n break;\n out.push(out.length > prefix.length ? distinct(value, out, items, mode) : value);\n }\n return out;\n}\nconst CONTAINERS = /^(data|items?|results?|list|entr(y|ie)|records?|values?|objects?|nodes?|edges?|elements?|rows?|hits?|match(e)?|contents?|resources?)$/i;\nfunction distinct(value, taken, schema, mode) {\n var _a, _b, _c, _d;\n const n = taken.length + 1;\n const free = (candidate) => !taken.some((t) => (0, fit_1.equal)(t, candidate)) && (0, fit_1.fits)(candidate, schema, mode);\n if (!taken.some((t) => (0, fit_1.equal)(t, value)))\n return value;\n const candidates = [];\n if (Array.isArray(schema.enum))\n candidates.push(...schema.enum);\n if (typeof value === "string" && isPlaceholder(value))\n candidates.push(`${value.slice(0, -1)}_${n}>`);\n if (typeof value === "string") {\n const at = value.indexOf("@");\n if (at > 0)\n candidates.push(`${value.slice(0, at)}+${n}${value.slice(at)}`);\n candidates.push(`${value}_${n}`, `${value}${n}`, `${n}${value.slice(1)}`);\n }\n else if (typeof value === "number")\n candidates.push(value + n - 1, value + (n - 1) * 10, value - (n - 1));\n else if (typeof value === "boolean")\n candidates.push(!value);\n else if (isRecord(value)) {\n const key = (_a = Object.keys(value).find((k) => k === "id" || isIdName(k))) !== null && _a !== void 0 ? _a : Object.keys(value).find((k) => typeof value[k] === "string" || typeof value[k] === "number");\n if (key !== undefined) {\n const inner = (_c = (_b = schema.properties) === null || _b === void 0 ? void 0 : _b[key]) !== null && _c !== void 0 ? _c : {};\n const varied = distinct(value[key], taken.flatMap((t) => (isRecord(t) ? [t[key]] : [])), inner, mode);\n candidates.push({ ...value, [key]: varied });\n }\n }\n return (_d = candidates.find(free)) !== null && _d !== void 0 ? _d : value;\n}\nconst ON_FLAGS = /^(is_?|has_?|can_?)?(enabled|active|verified|valid|available|visible|confirmed|success|successful|ok|allowed|approved|ready|supported)$/i;\nfunction booleanFor(name) {\n return ON_FLAGS.test(name.replace(/-/g, "_"));\n}\nfunction fitted(value, schema, name, depth, mode, budget, owner) {\n return (0, fit_1.fits)(value, schema, mode) ? value : conform(value, schema, mode, name, depth, budget, owner);\n}\nfunction conform(value, schema, mode = "response", name = "", depth = 0, budget = { left: NODE_BUDGET }, owner) {\n var _a, _b, _c;\n if (!schema || typeof schema !== "object" || depth > HARD_DEPTH || (0, fit_1.fits)(value, schema, mode))\n return value;\n const target = (0, fit_1.circularTarget)(schema);\n if (target)\n return conform(value, target, mode, name, depth + 1, budget, owner);\n const fresh = () => fromSchema({ ...schema, example: undefined, examples: undefined, default: undefined }, name, depth, mode, budget, owner);\n const variants = ((_a = schema.oneOf) === null || _a === void 0 ? void 0 : _a.length) ? schema.oneOf : ((_b = schema.anyOf) === null || _b === void 0 ? void 0 : _b.length) ? schema.anyOf : undefined;\n if (variants) {\n const base = { ...schema, oneOf: undefined, anyOf: undefined };\n const ranked = variants\n .filter((v) => isRecord(v))\n .map((v) => ({ v, misses: (0, fit_1.misfits)(value, { allOf: [base, v] }, mode, 40).length }))\n .sort((a, b) => a.misses - b.misses);\n let closest;\n for (const { v } of ranked.slice(0, MAX_TRIES)) {\n const fixed = conform(value, { allOf: [base, v] }, mode, name, depth + 1, budget, owner);\n if ((0, fit_1.fits)(fixed, schema, mode))\n return fixed;\n closest !== null && closest !== void 0 ? closest : (closest = fixed);\n }\n const made = fresh();\n return (0, fit_1.fits)(made, schema, mode) || closest === undefined ? made : closest;\n }\n if ((_c = schema.allOf) === null || _c === void 0 ? void 0 : _c.length) {\n let fixed = value;\n const required = requiredIn(schema);\n for (const part of [...schema.allOf, { ...schema, allOf: undefined }]) {\n if (isRecord(part))\n fixed = conform(fixed, required.length ? { ...part, required: [...new Set([...(Array.isArray(part.required) ? part.required : []), ...required])] } : part, mode, name, depth + 1, budget, owner);\n }\n if ((0, fit_1.fits)(fixed, schema, mode))\n return fixed;\n const made = fresh();\n return (0, fit_1.fits)(made, schema, mode) ? made : fixed;\n }\n return conformOne(value, schema, mode, name, depth, budget, owner);\n}\nfunction conformOne(value, schema, mode, name, depth, budget, owner) {\n var _a, _b, _c, _d, _e;\n if ((0, fit_1.fits)(value, { ...schema, allOf: undefined, oneOf: undefined, anyOf: undefined, not: undefined }, mode))\n return value;\n const fresh = () => fromSchema({ ...schema, example: undefined, examples: undefined, default: undefined }, name, depth, mode, budget, owner);\n const types = typesOf(schema);\n if (types.length && !(value === null && schema.nullable) && !ofType(value, schema)) {\n const typed = asType(value, schema);\n return typed !== undefined && (0, fit_1.fits)(typed, schema, mode) ? typed : fresh();\n }\n if (schema.const !== undefined && !(0, fit_1.equal)(value, schema.const))\n return schema.const;\n if (Array.isArray(schema.enum) && schema.enum.length && !schema.enum.some((e) => (0, fit_1.equal)(e, value)))\n return enumValue(schema.enum, schema.description);\n if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null)\n return fresh();\n if (Array.isArray(value)) {\n const legacy = Array.isArray(schema.items) ? schema.items : undefined;\n const prefix = (_b = (_a = schema.prefixItems) !== null && _a !== void 0 ? _a : legacy) !== null && _b !== void 0 ? _b : [];\n const items = !legacy && isRecord(schema.items) ? schema.items : undefined;\n let out = value.map((item, i) => conform(item, i < prefix.length ? prefix[i] : items, mode, singular(name), depth + 1, budget, singular(name) || owner));\n if (schema.uniqueItems === true)\n out = out.filter((item, i) => out.findIndex((other) => (0, fit_1.equal)(other, item)) === i);\n if (typeof schema.maxItems === "number")\n out = out.slice(0, Math.max(0, schema.maxItems));\n const least = Math.min(typeof schema.minItems === "number" ? schema.minItems : 0, MAX_LIST);\n while (out.length < least) {\n const index = out.length;\n const sub = index < prefix.length ? prefix[index] : items;\n const made = sub ? exampleFromSchema(sub, singular(name), depth + 1, mode, budget, singular(name) || owner) : null;\n out.push(sub ? distinct(made, out, sub, mode) : made);\n }\n return out;\n }\n if (isRecord(value)) {\n const props = (isRecord(schema.properties) ? schema.properties : {});\n const patterns = isRecord(schema.patternProperties) ? Object.entries(schema.patternProperties) : [];\n const extra = schema.additionalProperties;\n const title = (_c = schema.title) !== null && _c !== void 0 ? _c : owner;\n const out = {};\n for (const [key, item] of Object.entries(value)) {\n const prop = Object.prototype.hasOwnProperty.call(props, key) ? props[key] : undefined;\n const matched = (_d = patterns.find(([pattern]) => (0, fit_1.matchesPattern)(pattern, key))) === null || _d === void 0 ? void 0 : _d[1];\n if (!prop && !matched && extra === false)\n continue;\n const sub = (_e = prop !== null && prop !== void 0 ? prop : matched) !== null && _e !== void 0 ? _e : (isRecord(extra) ? extra : undefined);\n const optional = !(Array.isArray(schema.required) && schema.required.includes(key));\n if (item === null && sub && !allowsNull(sub) && optional)\n continue;\n if (mode === "response" && !budget.full && optional && sub && item !== null && typeof item !== "object" && !(0, fit_1.fits)(item, sub, mode)) {\n const typed = asType(item, sub);\n if (typed === undefined || !(0, fit_1.fits)(typed, sub, mode))\n continue;\n }\n setField(out, key, sub ? conform(item, sub, mode, key, depth + 1, budget, title) : item);\n }\n for (const key of Array.isArray(schema.required) ? schema.required : []) {\n if (typeof key !== "string" || key in out)\n continue;\n const prop = props[key];\n if (prop && (mode === "request" ? prop.readOnly : prop.writeOnly))\n continue;\n const sub = prop !== null && prop !== void 0 ? prop : (isRecord(extra) ? extra : undefined);\n setField(out, key, sub ? fieldValue(sub, key, depth + 1, mode, budget, title) : null);\n }\n for (const [key, prop] of Object.entries(props)) {\n if (typeof schema.minProperties !== "number" || Object.keys(out).length >= schema.minProperties)\n break;\n if (!(key in out))\n setField(out, key, exampleFromSchema(prop, key, depth + 1, mode, budget, title));\n }\n return out;\n }\n return fresh();\n}\nfunction setField(out, key, value) {\n if (key === "__proto__")\n Object.defineProperty(out, key, { value, enumerable: true, writable: true, configurable: true });\n else\n out[key] = value;\n}\nfunction asType(value, schema) {\n const types = typesOf(schema);\n if (ofType(value, schema))\n return value;\n if (typeof value === "string" && (types.includes("object") || types.includes("array"))) {\n try {\n const parsed = JSON.parse(value);\n if (ofType(parsed, schema))\n return parsed;\n }\n catch {\n }\n }\n if (types.includes("string") && Array.isArray(value) && value.length && value.every((v) => typeof v === "string" || typeof v === "number"))\n return value.join(",");\n if (types.includes("object") && Array.isArray(value) && value.length === 1 && isRecord(value[0]))\n return value[0];\n if (typeof value === "string" && value.trim() && (types.includes("number") || types.includes("integer")) && ofType(Number(value), schema))\n return Number(value);\n if (typeof value === "string" && types.includes("boolean") && /^(true|false)$/.test(value))\n return value === "true";\n if (typeof value === "number" && types.includes("string") && Number.isFinite(value))\n return String(value);\n return undefined;\n}\nfunction typesOf(schema) {\n return (Array.isArray(schema.type) ? schema.type : [schema.type]).filter((t) => typeof t === "string");\n}\nfunction ofType(value, schema) {\n const types = typesOf(schema);\n if (!types.length || (value === null && schema.nullable))\n return true;\n return types.some((t) => (t === "integer" ? Number.isInteger(value) : t === "number" ? typeof value === "number" : t === "object" ? isRecord(value) : t === "array" ? Array.isArray(value) : t === "null" ? value === null : typeof value === t));\n}\nfunction sharedProperties(parts) {\n const all = new Map();\n const collect = (schema, title, depth) => {\n var _a, _b, _c;\n if (!schema || typeof schema !== "object" || depth > 4)\n return;\n for (const part of (_a = schema.allOf) !== null && _a !== void 0 ? _a : [])\n collect(part, title, depth + 1);\n for (const [key, def] of Object.entries((_b = schema.properties) !== null && _b !== void 0 ? _b : {})) {\n if (!def || typeof def !== "object")\n continue;\n const entry = (_c = all.get(key)) !== null && _c !== void 0 ? _c : { defs: [] };\n if (!entry.defs.includes(def))\n entry.defs.push(def);\n entry.title = title;\n all.set(key, entry);\n }\n };\n for (const part of parts)\n collect(part, part.title, 0);\n return new Map([...all].filter(([, entry]) => entry.defs.length > 1));\n}\nfunction requiredIn(schema, depth = 0) {\n var _a;\n if (!schema || typeof schema !== "object" || depth > 4)\n return [];\n const own = Array.isArray(schema.required) ? schema.required.filter((r) => typeof r === "string") : [];\n return [...new Set([...own, ...((_a = schema.allOf) !== null && _a !== void 0 ? _a : []).flatMap((part) => requiredIn(part, depth + 1))])];\n}\nfunction fromParts(schema, name, depth, mode, budget, owner) {\n var _a, _b, _c;\n const merged = {};\n const plain = [];\n const required = requiredIn(schema);\n const parts = [...((_a = schema.allOf) !== null && _a !== void 0 ? _a : []), ...(schema.properties ? [{ ...schema, allOf: undefined }] : [])].filter((part) => part && typeof part === "object");\n const again = { left: budget.left, full: budget.full };\n for (const part of parts) {\n const whole = { ...part, ...(schema.title ? { title: schema.title } : {}), ...(required.length ? { required: [...new Set([...(Array.isArray(part.required) ? part.required : []), ...required])] } : {}) };\n const value = exampleFromSchema(whole, name, depth, mode, budget, owner);\n if (isRecord(value))\n Object.assign(merged, value);\n else if (value !== null && value !== undefined)\n plain.push(value);\n }\n for (const [key, { defs, title }] of sharedProperties(parts)) {\n if (!(key in merged) || defs.every((def) => (0, fit_1.fits)(merged[key], def, mode)))\n continue;\n const value = exampleFromSchema({ allOf: defs }, key, depth + 1, mode, again, (_c = (_b = schema.title) !== null && _b !== void 0 ? _b : title) !== null && _c !== void 0 ? _c : owner);\n if (value !== null && value !== undefined)\n merged[key] = value;\n }\n if (plain.length && Object.keys(merged).length === 0) {\n const fitting = [...plain].reverse().find((value) => parts.every((part) => (0, fit_1.fits)(value, part, mode)));\n if (fitting !== undefined)\n return fitting;\n for (const variant of parts.flatMap((part) => { var _a, _b; return [...((_a = part.oneOf) !== null && _a !== void 0 ? _a : []), ...((_b = part.anyOf) !== null && _b !== void 0 ? _b : [])]; })) {\n if (!isRecord(variant) || variant.type === "null")\n continue;\n const value = exampleFromSchema(variant, name, depth, mode, again, owner);\n if (value !== null && value !== undefined && parts.every((part) => (0, fit_1.fits)(value, part, mode)))\n return value;\n }\n const items = parts.flatMap((part) => (part.items && typeof part.items === "object" ? [part.items] : []));\n if (items.length > 1 && plain.some(Array.isArray))\n return exampleFromSchema({ type: "array", items: { allOf: items } }, name, depth, mode, again, owner);\n return plain[0];\n }\n return merged;\n}\nconst ENDINGS = /^(cancel+ed|cancel+ing|failed|failure|errored|error|declined|rejected|expired|deleted|voided|void|refunded|disputed|revoked|suspended|blocked|disabled|inactive|abandoned|lost|unpaid|past_due|incomplete_expired)$/i;\nfunction enumValue(values, description) {\n var _a, _b;\n const said = values.filter((v) => v !== "" && v !== null);\n const mentioned = (v) => {\n if (typeof v !== "string" || !description)\n return Infinity;\n const at = description.search(new RegExp(`[\\`\'"]${v.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&")}[\\`\'"]`));\n return at < 0 ? Infinity : at;\n };\n const ordered = said.map((v, i) => ({ v, i, at: mentioned(v) })).sort((a, b) => a.at - b.at || a.i - b.i).map(({ v }) => v);\n return (_b = (_a = ordered.find((v) => typeof v !== "string" || !ENDINGS.test(v))) !== null && _a !== void 0 ? _a : ordered[0]) !== null && _b !== void 0 ? _b : values[0];\n}\nfunction fromVariant(schema, variants, name, depth, mode, budget, owner) {\n var _a;\n const usable = variants.filter((v) => v && typeof v === "object" && v.type !== "null" && Object.keys(v).some((k) => !/^(description|title|nullable)$/.test(k)));\n const first = (schema.properties && usable.find((v) => v.properties || v.type === "object")) || usable[0] || variants[0];\n const exclusive = Boolean((_a = schema.oneOf) === null || _a === void 0 ? void 0 : _a.length);\n let made;\n for (const variant of [first, ...usable.filter((v) => v !== first)].slice(0, MAX_TRIES)) {\n const value = fromOneVariant(schema, variants, variant, exclusive, name, depth, mode, budget, owner);\n if (made === undefined)\n made = value;\n if ((0, fit_1.fits)(value, schema, mode))\n return value;\n }\n if (mode === "response" && !budget.full) {\n const full = { left: budget.left, full: true };\n const value = fromVariant(schema, variants, name, depth, mode, full, owner);\n budget.left = full.left;\n if ((0, fit_1.fits)(value, schema, mode))\n return value;\n }\n return made;\n}\nfunction fromOneVariant(schema, variants, variant, exclusive, name, depth, mode, budget, owner) {\n var _a, _b, _c, _d, _e;\n if (variant && typeof variant === "object" && !describesValue(variant)) {\n const required = [...new Set([...(Array.isArray(schema.required) ? schema.required : []), ...(Array.isArray(variant.required) ? variant.required : [])])];\n const others = exclusive ? new Set(variants.filter((v) => v !== variant && isRecord(v) && Array.isArray(v.required)).flatMap((v) => v.required).filter((k) => !required.includes(k))) : new Set();\n const properties = schema.properties && others.size ? Object.fromEntries(Object.entries(schema.properties).filter(([key]) => !others.has(key))) : schema.properties;\n return exampleFromSchema({ ...schema, oneOf: undefined, anyOf: undefined, ...(properties ? { properties } : {}), ...(required.length ? { required } : {}) }, name, depth, mode, budget, owner);\n }\n const value = exampleFromSchema(variant, name, depth, mode, budget, owner);\n if (!value || typeof value !== "object" || Array.isArray(value))\n return value;\n const out = schema.properties ? { ...exampleFromSchema({ ...schema, oneOf: undefined, anyOf: undefined }, name, depth, mode, budget, owner), ...value } : { ...value };\n const discriminator = schema.discriminator;\n const property = discriminator === null || discriminator === void 0 ? void 0 : discriminator.propertyName;\n const mapping = discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping;\n if (property && isRecord(mapping) && !((_b = (_a = variant.properties) === null || _a === void 0 ? void 0 : _a[property]) === null || _b === void 0 ? void 0 : _b.enum) && ((_d = (_c = variant.properties) === null || _c === void 0 ? void 0 : _c[property]) === null || _d === void 0 ? void 0 : _d.const) === undefined) {\n const entries = Object.entries(mapping);\n const named = entries.find(([, target]) => variant.title && typeof target === "string" && target.split("/").pop() === variant.title);\n const entry = (_e = named !== null && named !== void 0 ? named : entries[variants.indexOf(variant)]) !== null && _e !== void 0 ? _e : entries[0];\n if (entry)\n out[property] = entry[0];\n }\n return out;\n}\nconst VALUE_KEYWORDS = ["type", "properties", "items", "prefixItems", "allOf", "oneOf", "anyOf", "enum", "const", "example", "examples", "default", "format", "pattern", "additionalProperties", "$ref", "x-circular"];\nfunction describesValue(schema) {\n return VALUE_KEYWORDS.some((key) => key in schema);\n}\nconst MAX_OPTIONAL = 3;\nconst TELLING_NAMES = /^(to|from|subject|text|html|body|content|message|title|name|email|description|amount|currency|quantity|customer|price|product|channel|phone|url|\\w+_url)$/i;\nfunction telling(props, required) {\n const must = props.filter(([key]) => required.has(key));\n const rank = ([key, prop]) => (TELLING_NAMES.test(key) || isIdName(key) ? 0 : 2) + (looksReal(key, prop) ? 0 : 1);\n const optional = props\n .filter(([key]) => !required.has(key))\n .map((entry, i) => ({ entry, i, rank: rank(entry) }))\n .sort((a, b) => a.rank - b.rank || a.i - b.i)\n .slice(0, must.length ? MAX_OPTIONAL : MAX_OPTIONAL + 1)\n .sort((a, b) => a.i - b.i);\n return [...must, ...optional.map((o) => o.entry)];\n}\nfunction looksReal(key, prop) {\n if (!prop || typeof prop !== "object")\n return false;\n if (prop.example !== undefined || prop.examples !== undefined || prop.default !== undefined || prop.enum || prop.const !== undefined)\n return true;\n const type = Array.isArray(prop.type) ? prop.type.find((t) => t !== "null") : prop.type;\n if ((type && type !== "string") || prop.format || prop.pattern)\n return true;\n return saysWhatItHolds(key, prop);\n}\nfunction isEmpty(value) {\n return value === undefined || (Array.isArray(value) && value.length === 0) || (isRecord(value) && Object.keys(value).length === 0);\n}\nconst WHOLE_NUMBER = /(^|[_-])(number|num|no|index|idx|page|position|pos|id|count|version|year|port|rank|level|step|line|row|column|col|size)$|[a-z0-9](Number|Num|Index|Page|Position|Id|Count|Version|Year|Port|Rank|Level|Step|Line|Row|Column|Size)$|^(number|num|index|page|position|id|count|version|year|port|rank|level|step|line|row|column|size|offset|depth)$/;\nfunction numberFor(schema, name, integer) {\n const lower = name.toLowerCase();\n const step = integer ? 1 : 0.5;\n let value;\n if (/(created|updated|timestamp|_at$|time)/.test(lower) || /[a-z0-9]At$/.test(name))\n value = 1767225600;\n else if (/(amount|price|total|cost|balance)/.test(lower))\n value = integer ? 2000 : 20.0;\n else if (/(quantity|count|qty)/.test(lower))\n value = 1;\n else if (/(limit|page_size|per_page)/.test(lower))\n value = 10;\n else if (/(retry|seconds|delay)/.test(lower))\n value = 30;\n else\n value = integer || WHOLE_NUMBER.test(name) ? 1 : 1.5;\n if (schema.minimum !== undefined && value < schema.minimum)\n value = schema.minimum;\n if (schema.maximum !== undefined && value > schema.maximum)\n value = schema.maximum;\n const exclusiveMin = typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum : schema.exclusiveMinimum === true ? schema.minimum : undefined;\n const exclusiveMax = typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum : schema.exclusiveMaximum === true ? schema.maximum : undefined;\n if (exclusiveMin !== undefined && value <= exclusiveMin)\n value = exclusiveMin + step;\n if (exclusiveMax !== undefined && value >= exclusiveMax)\n value = exclusiveMax - step;\n return value;\n}\nconst HOOKISH = /(webhook|callback|hook|notif)/i;\nfunction stringFor(schema, name, owner) {\n var _a, _b;\n switch (schema.format) {\n case "date-time":\n return "2026-01-01T12:00:00Z";\n case "date":\n return "2026-01-01";\n case "time":\n return "12:00:00Z";\n case "duration":\n return "PT1H";\n case "email":\n case "idn-email":\n return `${(name.replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[_.-]+|[_.-]+$/g, "") || "email").toLowerCase()}@example.com`;\n case "uri":\n case "url":\n case "iri":\n case "uri-reference":\n case "iri-reference":\n return HOOKISH.test(name) ? "https://example.com/webhooks" : "https://example.com";\n case "uri-template":\n return "https://example.com/{id}";\n case "hostname":\n case "idn-hostname":\n return "example.com";\n case "uuid":\n return name === "id" && owner ? uuidLike(owner) : isIdName(name) ? uuidLike(name) : exports.PLACEHOLDER_UUID;\n case "ipv4":\n return "203.0.113.10";\n case "ipv6":\n return "2001:db8::10";\n case "byte":\n return "aGVsbG8=";\n case "binary":\n return exports.BINARY_PLACEHOLDER;\n case "password":\n return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";\n case "regex":\n return "^[a-z]+$";\n case "json-pointer":\n return "/data";\n }\n if (schema.contentMediaType && !schema.contentEncoding) {\n if (/json/i.test(schema.contentMediaType))\n return JSON.stringify(schema.contentSchema ? exampleFromSchema(schema.contentSchema, name) : {});\n return exports.BINARY_PLACEHOLDER;\n }\n const value = sized((_a = namedValue(name, schema, owner)) !== null && _a !== void 0 ? _a : placeholder(name || "value"), schema);\n const pattern = schema.pattern;\n if (typeof pattern !== "string")\n return value;\n const told = (0, fit_1.patternVerdict)(pattern, value);\n if (told === true)\n return value;\n const patterned = patternExample(pattern);\n if (patterned)\n return patterned;\n const shapes = [idLike(name), "12345678901", "+15555550123", "email@example.com", "https://example.com", "example", "EXAMPLE", "Example", "1", "a", "A1"];\n const fitting = shapes.map((shape) => sized(shape, schema)).find((shape) => (0, fit_1.patternVerdict)(pattern, shape) === true);\n if (fitting !== undefined)\n return fitting;\n return (_b = (told === undefined ? shapeNamed(name, schema) : undefined)) !== null && _b !== void 0 ? _b : value;\n}\nfunction shapeNamed(name, schema) {\n const lower = name.toLowerCase();\n const shape = /phone|fax|mobile|(^|_)tel(_|$)|msisdn/.test(lower) ? "+15555550123" : /e-?mail/.test(lower) ? "email@example.com" : /(^|_)(url|uri|link|href|website)$|[a-z](Url|Uri)$/i.test(name) ? "https://example.com" : undefined;\n return shape === undefined ? undefined : sized(shape, schema);\n}\nfunction sized(value, schema) {\n let out = value;\n const held = isPlaceholder(out);\n if (schema.maxLength !== undefined && out.length > schema.maxLength)\n out = held && schema.maxLength >= 3 ? `${out.slice(0, schema.maxLength - 1)}>` : out.slice(0, schema.maxLength);\n if (schema.minLength !== undefined && out.length < schema.minLength)\n out = held ? `${out.slice(0, -1).padEnd(schema.minLength - 1, "_")}>` : out.padEnd(schema.minLength, "x");\n return out;\n}\nfunction placeholder(name) {\n const clean = name.replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[_.-]+|[_.-]+$/g, "");\n return `<${clean.slice(0, 60) || "value"}>`;\n}\nfunction isPlaceholder(value) {\n return typeof value === "string" && /^<[A-Za-z0-9_.-]{1,64}>$/.test(value);\n}\nexports.PLACEHOLDER_UUID = "00000000-0000-4000-8000-000000000000";\nfunction namedValue(name, schema, owner) {\n var _a, _b;\n const lower = name.toLowerCase().replace(/-/g, "_");\n const about = ((_a = schema.description) !== null && _a !== void 0 ? _a : "").toLowerCase();\n if (lower === "id" && owner)\n return idLike(owner);\n if (isIdName(name) || /\\bID\\b/.test((_b = schema.description) !== null && _b !== void 0 ? _b : ""))\n return idLike(name);\n if ((lower === "object" || lower === "type") && schema.title)\n return schema.title.toLowerCase();\n if ((lower === "name" || lower.endsWith("_name")) && (/\\b(domain|hostname)s?\\b/.test(about) || nounOf(owner) === "domain"))\n return "example.com";\n if (/^(domain|host|hostname)$/.test(lower))\n return "example.com";\n if (/(^|_)password$/.test(lower))\n return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";\n return undefined;\n}\nconst TELLING_FIELD = [\n /^(from|sender|to|recipients?|reply_?to|cc|bcc|subject|title|headline|html|text|body|content|message|comment|notes?|caption|prompt|input|slug|language|lang|locale|tz|locality|date|object|type|domain|host|hostname)$/,\n /email|currency|phone|country|url|uri|status|description/,\n /^(first_?name|given_?name|last_?name|family_?name|surname|company|company_?name|business_?name|organi[sz]ation(_?name)?|user_?name|handle|login|screen_?name)$/,\n /(^|_)(name|date|fax|city|state|province|postal_?code|zip|zip_?code|postcode|street|line_?[12]|address_?(line_?)?[12]|time_?zone|colou?r|password)$/,\n /(_at|_time|^time|timestamp)$/,\n];\nfunction saysWhatItHolds(name, schema) {\n var _a;\n const lower = name.toLowerCase().replace(/-/g, "_");\n return isIdName(name) || /\\bID\\b/.test((_a = schema.description) !== null && _a !== void 0 ? _a : "") || TELLING_FIELD.some((re) => re.test(lower));\n}\nfunction nounOf(owner) {\n const words = (owner !== null && owner !== void 0 ? owner : "")\n .replace(/([a-z0-9])([A-Z])/g, "$1_$2")\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter((w) => w && !/^(create|update|new|send|add|get|list|post|put|patch|set|make|place|request|response|body|input|params|parameters|payload|object|data|schema|model|dto|options?|opts|args|arguments|events?|created|updated|deleted|changed|v\\d+)$/.test(w));\n return words.length ? singular(words.slice(-2).join("_")) : undefined;\n}\nfunction patternExample(pattern) {\n let whole;\n try {\n whole = new RegExp(pattern);\n }\n catch {\n return undefined;\n }\n const readable = [pattern, ...(REPEATED_GROUP.test(pattern) ? [] : [withoutLookarounds(pattern)])];\n for (const text of readable) {\n if (text === undefined)\n continue;\n const node = parsePattern(text);\n if (!node)\n continue;\n const value = sample(node, { next: 0 });\n if (value !== undefined && value.length <= 200 && whole.test(value))\n return value;\n }\n return undefined;\n}\nconst REPEATED_GROUP = /\\)(?:[*+]|\\{\\d+,?\\d*\\})/;\nfunction withoutLookarounds(pattern) {\n if (!/\\(\\?<?[=!]/.test(pattern))\n return undefined;\n let out = "";\n for (let i = 0; i < pattern.length; i++) {\n if (pattern[i] === "\\\\") {\n out += pattern.slice(i, i + 2);\n i++;\n continue;\n }\n if (/^\\(\\?<?[=!]/.test(pattern.slice(i, i + 4))) {\n let depth = 0;\n let j = i;\n for (; j < pattern.length; j++) {\n if (pattern[j] === "\\\\")\n j++;\n else if (pattern[j] === "[") {\n j = pattern.indexOf("]", j + 2);\n if (j < 0)\n return undefined;\n }\n else if (pattern[j] === "(")\n depth++;\n else if (pattern[j] === ")" && --depth === 0)\n break;\n }\n if (j >= pattern.length)\n return undefined;\n i = j;\n continue;\n }\n out += pattern[i];\n }\n return out;\n}\nconst POOLS = [[..."1a2b3c4d5e6f7a8b9c0d"], [..."ABCDEFGHJKxyz_-."], [..."LMNPQRSTUVWXYZghijklmnopqrstuvw+=:/@~!*\'(),;$&? "]];\nconst CONTROL = { t: "\\t", n: "\\n", r: "\\r", v: "\\v", f: "\\f" };\nfunction parsePattern(pattern) {\n let i = 0;\n const fail = () => {\n i = pattern.length + 1;\n return undefined;\n };\n const choice = () => {\n var _a;\n const options = [];\n let parts = [];\n while (i < pattern.length && pattern[i] !== ")") {\n const c = pattern[i];\n if (c === "|") {\n options.push({ kind: "sequence", parts });\n parts = [];\n i++;\n continue;\n }\n let atom;\n if (c === "^" || c === "$") {\n i++;\n continue;\n }\n else if (c === "(") {\n if (pattern.startsWith("(?:", i))\n i += 3;\n else if (pattern[i + 1] === "?")\n return fail();\n else\n i++;\n atom = choice();\n if (pattern[i] !== ")")\n return fail();\n i++;\n }\n else if (c === "[") {\n const close = pattern.indexOf("]", pattern[i + 1] === "]" ? i + 2 : i + 1);\n if (close < 0)\n return fail();\n const text = pattern.slice(i, close + 1);\n i = close + 1;\n let set;\n try {\n set = new RegExp(`^${text}$`);\n }\n catch {\n return fail();\n }\n atom = { kind: "chars", accepts: (ch) => set.test(ch) };\n }\n else if (c === "\\\\") {\n const e = pattern[i + 1];\n i += 2;\n if (e === undefined || /[0-9bBkpPc]/.test(e))\n return fail();\n if (/[dwsDWS]/.test(e)) {\n const set = new RegExp(`^\\\\${e}$`);\n atom = { kind: "chars", accepts: (ch) => set.test(ch) };\n }\n else {\n const code = (e === "x" && pattern.slice(i).match(/^[0-9a-fA-F]{2}/)) || (e === "u" && pattern.slice(i).match(/^[0-9a-fA-F]{4}/));\n if (code)\n i += code[0].length;\n const literal = code ? String.fromCharCode(parseInt(code[0], 16)) : ((_a = CONTROL[e]) !== null && _a !== void 0 ? _a : e);\n atom = { kind: "chars", accepts: (ch) => ch === literal, literal };\n }\n }\n else if (c === ".") {\n i++;\n atom = { kind: "chars", accepts: (ch) => ch !== "\\n", literal: "." };\n }\n else if ("*+?{".includes(c)) {\n return fail();\n }\n else {\n i++;\n atom = { kind: "chars", accepts: (ch) => ch === c, literal: c };\n }\n if (!atom)\n return fail();\n const q = pattern.slice(i).match(/^(\\*|\\+|\\?|\\{(\\d+)(?:(,)(\\d*))?\\})\\??/);\n if (q) {\n i += q[0].length;\n const min = q[2] !== undefined ? Number(q[2]) : q[1] === "+" ? 1 : 0;\n const max = q[2] !== undefined ? (q[3] ? (q[4] ? Number(q[4]) : Infinity) : min) : q[1] === "?" ? 1 : Infinity;\n const count = q[1] === "?" ? 1 : Math.min(Math.max(min, Math.min(10, max)), 64);\n if (count < min)\n return fail();\n atom = { kind: "repeat", node: atom, count };\n }\n parts.push(atom);\n }\n options.push({ kind: "sequence", parts });\n return options.length === 1 ? options[0] : { kind: "choice", options };\n };\n const node = choice();\n return i === pattern.length ? node : undefined;\n}\nfunction sample(node, state) {\n var _a;\n switch (node.kind) {\n case "chars": {\n if (node.literal !== undefined)\n return node.literal;\n for (const pool of POOLS) {\n for (let n = 0; n < pool.length; n++) {\n const ch = pool[(state.next + n) % pool.length];\n if (node.accepts(ch)) {\n state.next = (state.next + n + 1) % pool.length;\n return ch;\n }\n }\n }\n return undefined;\n }\n case "sequence": {\n let out = "";\n for (const part of node.parts) {\n const value = sample(part, state);\n if (value === undefined)\n return undefined;\n out += value;\n }\n return out;\n }\n case "repeat": {\n let out = "";\n for (let n = 0; n < node.count; n++) {\n const value = sample(node.node, state);\n if (value === undefined)\n return undefined;\n out += value;\n }\n return out;\n }\n case "choice": {\n const values = node.options.map((option) => sample(option, { ...state })).filter((v) => v !== undefined);\n return (_a = values.find((v) => v.length > 1)) !== null && _a !== void 0 ? _a : values[0];\n }\n }\n}\nfunction isIdName(name) {\n const lower = name.toLowerCase();\n return lower === "id" || lower.endsWith("_id") || lower.endsWith("-id") || /[a-z0-9]Id$/.test(name);\n}\nconst ID_NOISE = /^(create|update|new|send|add|get|list|post|put|patch|set|make|place|request|response|body|input|output|params|parameters|payload|object|data|schema|model|dto|options?|opts|args|arguments|events?|created|updated|deleted|changed|v\\d+)$/;\nfunction idLike(name) {\n const words = idWords(name);\n return words.length ? `<${words.join("_")}_id>` : "<id>";\n}\nfunction uuidLike(name) {\n const words = idWords(name);\n const n = 1 + (seedHash(`uuid:${words.length ? words.join("_") : "obj"}`) % 9999);\n return `${exports.PLACEHOLDER_UUID.slice(0, -12)}${String(n).padStart(12, "0")}`;\n}\nfunction idWords(name) {\n const all = name\n .replace(/[_-]?(uu|s|g)?id$/i, "")\n .replace(/([a-z0-9])([A-Z])/g, "$1_$2")\n .replace(/([A-Z])([A-Z][a-z])/g, "$1_$2")\n .toLowerCase()\n .split(/[^a-z]+/)\n .filter(Boolean);\n const kept = all.filter((w) => !ID_NOISE.test(w));\n return (kept.length ? kept : all).map((w, i, list) => (i === list.length - 1 ? singular(w) : w));\n}\nfunction seedHash(seed) {\n let h = 2166136261;\n for (let i = 0; i < seed.length; i++)\n h = Math.imul(h ^ seed.charCodeAt(i), 16777619) >>> 0;\n return h || 1;\n}\nfunction singular(word) {\n if (/ies$/i.test(word))\n return word.slice(0, -3) + "y";\n if (/(ses|xes|ches|shes)$/i.test(word))\n return word.slice(0, -2);\n if (/s$/i.test(word) && !/ss$/i.test(word))\n return word.slice(0, -1);\n return word;\n}\n\n}, {"./fit":"lib/oas/fit"}],\n"lib/oas/fit": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.CIRCULAR_TARGET = void 0;\nexports.circularTarget = circularTarget;\nexports.fits = fits;\nexports.misfits = misfits;\nexports.typesOf = typesOf;\nexports.equal = equal;\nexports.patternVerdict = patternVerdict;\nexports.matchesPattern = matchesPattern;\nexports.formatFits = formatFits;\nexports.CIRCULAR_TARGET = "x-circular-target";\nfunction circularTarget(schema) {\n const target = schema[exports.CIRCULAR_TARGET];\n return target && typeof target === "object" ? target : undefined;\n}\nconst MAX_DEPTH = 40;\nconst MAX_STEPS = 50000;\nfunction fits(value, schema, mode = "response") {\n return misfits(value, schema, mode, 1).length === 0;\n}\nfunction misfits(value, schema, mode = "response", limit = 20) {\n const out = [];\n check(value, schema, [], 0, out, { counter: { steps: 0 }, limit, mode });\n return out;\n}\nfunction check(value, schema, path, depth, out, state) {\n var _a, _b, _c;\n if (out.length >= state.limit || schema === undefined || schema === true || depth > MAX_DEPTH || ++state.counter.steps > MAX_STEPS)\n return;\n if (schema === false)\n return void out.push({ path, keyword: "false" });\n if (typeof schema !== "object" || schema === null)\n return;\n const miss = (keyword, at = path) => void out.push({ path: at, keyword });\n const target = circularTarget(schema);\n if (target)\n return check(value, target, path, depth + 1, out, state);\n const nullable = schema.nullable === true;\n const types = typesOf(schema);\n if (value === null && nullable)\n return;\n if (types.length && !types.some((t) => isType(value, t)))\n return miss("type");\n if (schema.const !== undefined && !equal(value, schema.const))\n miss("const");\n if (Array.isArray(schema.enum) && schema.enum.length && !schema.enum.some((e) => equal(e, value)))\n miss("enum");\n if (typeof value === "string") {\n const length = [...value].length;\n if (typeof schema.minLength === "number" && length < schema.minLength)\n miss("minLength");\n if (typeof schema.maxLength === "number" && length > schema.maxLength)\n miss("maxLength");\n if (typeof schema.pattern === "string" && !matchesPattern(schema.pattern, value))\n miss("pattern");\n if (typeof schema.format === "string" && !formatFits(schema.format, value))\n miss("format");\n }\n else if (typeof value === "number") {\n const { minimum, maximum, exclusiveMinimum: exMin, exclusiveMaximum: exMax } = schema;\n if (typeof minimum === "number" && (exMin === true ? value <= minimum : value < minimum))\n miss("minimum");\n if (typeof maximum === "number" && (exMax === true ? value >= maximum : value > maximum))\n miss("maximum");\n if (typeof exMin === "number" && value <= exMin)\n miss("exclusiveMinimum");\n if (typeof exMax === "number" && value >= exMax)\n miss("exclusiveMaximum");\n if (typeof schema.multipleOf === "number" && schema.multipleOf > 0 && !multipleOf(value, schema.multipleOf))\n miss("multipleOf");\n if (schema.format === "int32" && !(Number.isInteger(value) && value >= -(2 ** 31) && value < 2 ** 31))\n miss("format");\n }\n else if (Array.isArray(value)) {\n if (typeof schema.minItems === "number" && value.length < schema.minItems)\n miss("minItems");\n if (typeof schema.maxItems === "number" && value.length > schema.maxItems)\n miss("maxItems");\n if (schema.uniqueItems === true && new Set(value.map((v) => canonical(v))).size < value.length)\n miss("uniqueItems");\n const legacy = Array.isArray(schema.items) ? schema.items : undefined;\n const prefix = (_b = (_a = schema.prefixItems) !== null && _a !== void 0 ? _a : legacy) !== null && _b !== void 0 ? _b : [];\n value.forEach((item, i) => {\n if (i < prefix.length)\n check(item, prefix[i], [...path, i], depth + 1, out, state);\n else if (!legacy && isSchema(schema.items))\n check(item, schema.items, [...path, i], depth + 1, out, state);\n });\n }\n else if (isRecord(value)) {\n const props = isRecord(schema.properties) ? schema.properties : {};\n const omitted = (key) => {\n const prop = props[key];\n return isSchema(prop) && (state.mode === "request" ? prop.readOnly === true : prop.writeOnly === true);\n };\n if (Array.isArray(schema.required))\n for (const key of schema.required)\n if (typeof key === "string" && !(key in value) && !omitted(key))\n miss("required", [...path, key]);\n const count = Object.keys(value).length;\n if (typeof schema.minProperties === "number" && count < schema.minProperties)\n miss("minProperties");\n if (typeof schema.maxProperties === "number" && count > schema.maxProperties)\n miss("maxProperties");\n const patterns = isRecord(schema.patternProperties) ? Object.entries(schema.patternProperties) : [];\n for (const [key, item] of Object.entries(value)) {\n if (out.length >= state.limit)\n break;\n let known = false;\n if (Object.prototype.hasOwnProperty.call(props, key)) {\n known = true;\n check(item, props[key], [...path, key], depth + 1, out, state);\n }\n for (const [pattern, sub] of patterns) {\n if (matchesPattern(pattern, key)) {\n known = true;\n check(item, sub, [...path, key], depth + 1, out, state);\n }\n }\n if (!known) {\n const extra = schema.additionalProperties;\n if (extra === false)\n miss("additionalProperties", [...path, key]);\n else if (isSchema(extra))\n check(item, extra, [...path, key], depth + 1, out, state);\n }\n }\n }\n for (const part of (_c = schema.allOf) !== null && _c !== void 0 ? _c : [])\n if (isSchema(part))\n check(value, part, path, depth + 1, out, state);\n if (Array.isArray(schema.anyOf) && schema.anyOf.length && !schema.anyOf.some((v) => fitsAt(value, v, depth, state)))\n miss("anyOf");\n if (Array.isArray(schema.oneOf) && schema.oneOf.length) {\n const fitting = countIn(value, schema.oneOf, depth, state, 2);\n if (fitting !== 1)\n miss(fitting === 0 ? "oneOf" : "oneOf-many");\n }\n if (isSchema(schema.not) && fitsAt(value, schema.not, depth, state))\n miss("not");\n const conditional = schema;\n if (isSchema(conditional.if)) {\n const branch = fitsAt(value, conditional.if, depth, state) ? conditional.then : conditional.else;\n if (isSchema(branch))\n check(value, branch, path, depth + 1, out, state);\n }\n}\nfunction fitsAt(value, schema, depth, state) {\n const found = [];\n check(value, schema, [], depth + 1, found, { counter: state.counter, limit: 1, mode: state.mode });\n return found.length === 0;\n}\nfunction countIn(value, variants, depth, s, stop) {\n let n = 0;\n for (const v of variants) {\n if (isSchema(v) && fitsAt(value, v, depth, s) && ++n >= stop)\n break;\n }\n return n;\n}\nfunction isSchema(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction typesOf(schema) {\n return (Array.isArray(schema.type) ? schema.type : [schema.type]).filter((t) => typeof t === "string");\n}\nfunction isType(value, type) {\n switch (type) {\n case "integer":\n return typeof value === "number" && Number.isInteger(value);\n case "number":\n return typeof value === "number" && Number.isFinite(value);\n case "string":\n return typeof value === "string";\n case "boolean":\n return typeof value === "boolean";\n case "array":\n return Array.isArray(value);\n case "object":\n return isRecord(value);\n case "null":\n return value === null;\n default:\n return true;\n }\n}\nfunction multipleOf(value, step) {\n const quotient = value / step;\n return Math.abs(quotient - Math.round(quotient)) < 1e-9;\n}\nfunction equal(a, b) {\n return canonical(a) === canonical(b);\n}\nfunction canonical(value) {\n var _a;\n if (Array.isArray(value))\n return `[${value.map(canonical).join(",")}]`;\n if (isRecord(value))\n return `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonical(value[k])}`).join(",")}}`;\n return (_a = JSON.stringify(value)) !== null && _a !== void 0 ? _a : "undefined";\n}\nconst REPEATED_GROUP = /\\)(?:[*+]|\\{\\d+,?\\d*\\})/;\nconst compiled = new Map();\nfunction patternVerdict(pattern, value) {\n if (value.length > 40 || REPEATED_GROUP.test(pattern))\n return undefined;\n const re = compiledPattern(pattern);\n return re === null ? undefined : re.test(value);\n}\nfunction matchesPattern(pattern, value) {\n if (value.length > 2000 || REPEATED_GROUP.test(pattern))\n return true;\n const re = compiledPattern(pattern);\n return re === null || re.test(value);\n}\nfunction compiledPattern(pattern) {\n let re = compiled.get(pattern);\n if (re === undefined) {\n try {\n re = new RegExp(pattern, "u");\n }\n catch {\n try {\n re = new RegExp(pattern);\n }\n catch {\n re = null;\n }\n }\n if (compiled.size > 2000)\n compiled.clear();\n compiled.set(pattern, re);\n }\n return re;\n}\nconst DATE = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\nconst TIME = /^(\\d{2}):(\\d{2}):(\\d{2})(\\.\\d+)?(z|[+-]\\d{2}(:?\\d{2})?)$/i;\nconst FORMATS = {\n "date-time": (text) => {\n const [date, time] = text.split(/t|\\s/i);\n return time !== undefined && FORMATS.date(date) && FORMATS.time(time);\n },\n date: (text) => {\n const m = text.match(DATE);\n if (!m)\n return false;\n const month = Number(m[2]);\n const day = Number(m[3]);\n return month >= 1 && month <= 12 && day >= 1 && day <= new Date(Date.UTC(Number(m[1]), month, 0)).getUTCDate();\n },\n time: (text) => {\n const m = text.match(TIME);\n return Boolean(m) && Number(m[1]) <= 23 && Number(m[2]) <= 59 && Number(m[3]) <= 60;\n },\n email: (text) => /^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(text),\n uri: (text) => /^[a-z][a-z0-9+.-]*:[^\\s]*$/i.test(text) && !/\\s/.test(text),\n url: (text) => /^[a-z][a-z0-9+.-]*:\\/\\/[^\\s]+$/i.test(text),\n "uri-reference": (text) => !/[\\s<>"\\\\^`{}|]/.test(text),\n "uri-template": (text) => !/[\\s<>"\\\\^`|]/.test(text),\n uuid: (text) => /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(text),\n ipv4: (text) => /^((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/.test(text),\n ipv6: (text) => { var _a; return /^[0-9a-f:.]+$/i.test(text) && text.includes(":") && ((_a = text.match(/::/g)) !== null && _a !== void 0 ? _a : []).length <= 1; },\n hostname: (text) => text.length <= 253 && /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*\\.?$/i.test(text),\n byte: (text) => /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(text),\n duration: (text) => /^P(?!$)(\\d+(?:\\.\\d+)?Y)?(\\d+(?:\\.\\d+)?M)?(\\d+(?:\\.\\d+)?W)?(\\d+(?:\\.\\d+)?D)?(T(?=\\d)(\\d+(?:\\.\\d+)?H)?(\\d+(?:\\.\\d+)?M)?(\\d+(?:\\.\\d+)?S)?)?$/.test(text),\n regex: (text) => {\n try {\n new RegExp(text);\n return true;\n }\n catch {\n return false;\n }\n },\n "json-pointer": (text) => /^(?:\\/(?:[^~/]|~0|~1)*)*$/.test(text),\n};\nfunction formatFits(format, text) {\n const test = FORMATS[format];\n return test ? test(text) : true;\n}\n\n}, {}],\n"lib/text": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.cut = cut;\nexports.wellFormed = wellFormed;\nexports.clip = clip;\nexports.plainText = plainText;\nfunction cut(text, max) {\n const end = Math.max(0, max);\n const last = text.charCodeAt(end - 1);\n return text.slice(0, last >= 0xd800 && last <= 0xdbff ? end - 1 : end);\n}\nconst HALVES = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDFFF]/g;\nfunction wellFormed(text) {\n return text.replace(HALVES, (c) => (c.length === 2 ? c : ""));\n}\nfunction clip(text, max) {\n return text.length > max ? `${cut(text, max - 1)}\u2026` : text;\n}\nfunction plainText(markdown) {\n return markdown\n .replace(/<[^>]+>/g, " ")\n .replace(/!\\[([^\\]]*)\\]\\([^)]*\\)/g, "$1")\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, "$1")\n .replace(/\\*\\*|__|`/g, "")\n .replace(/(^|\\s)[*_]([^*_\\s][^*_]*?)[*_](?=[\\s.,;:!?)]|$)/g, "$1$2")\n .replace(/^\\s{0,3}(#{1,6}|>)\\s+/gm, "")\n .replace(/\\s+/g, " ")\n .trim();\n}\n\n}, {}]\n};\nvar cache = {};\nfunction load(id) {\n var m = cache[id];\n if (m) return m.exports;\n m = cache[id] = { exports: {} };\n defs[id][0](m, m.exports, function (spec) { return load(defs[id][1][spec]); });\n return m.exports;\n}\nload("lib/embed/player");\n})();';
15662
+ var PLAYER_SCRIPT = '(function () {\n"use strict";\nvar defs = {\n"lib/embed/player": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nconst frame_1 = require("../render/frame");\nconst timing_1 = require("../storyboard/timing");\nconst ICONS = {\n play: \'<path d="M8 5.2v13.6a.6.6 0 0 0 .9.5l10.6-6.8a.6.6 0 0 0 0-1L8.9 4.7a.6.6 0 0 0-.9.5z" fill="currentColor"/>\',\n pause: \'<path d="M7 5h3.2v14H7zM13.8 5H17v14h-3.2z" fill="currentColor"/>\',\n replay: \'<path d="M19.5 11.5A7.5 7.5 0 1 0 17.3 17M19.5 5v6.5H13" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n prev: \'<path d="M6.5 5.5v13M17.5 6.2v11.6a.5.5 0 0 1-.8.4l-8.3-5.8a.5.5 0 0 1 0-.8l8.3-5.8a.5.5 0 0 1 .8.4z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n next: \'<path d="M17.5 5.5v13M6.5 6.2v11.6a.5.5 0 0 0 .8.4l8.3-5.8a.5.5 0 0 0 0-.8L7.3 5.8a.5.5 0 0 0-.8.4z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n copy: \'<path d="M9 9.5h9.5v10H9zM6 15.5H5.5v-10h9.5V6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n expand: \'<path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n};\nconst icon = (name) => `<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true">${ICONS[name]}</svg>`;\nfunction fmt(ms) {\n const s = Math.floor(ms / 1000);\n return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;\n}\nfunction button(label, name, className = "") {\n const b = document.createElement("button");\n b.type = "button";\n b.className = className;\n b.setAttribute("aria-label", label);\n b.title = label;\n b.innerHTML = icon(name);\n return b;\n}\nconst SITE = "https://integrationtour.com/";\nfunction credit(aspect) {\n const a = document.createElement("a");\n a.className = "credit";\n a.href = SITE;\n a.target = "_blank";\n a.rel = "noopener";\n a.setAttribute("aria-label", `${frame_1.WATERMARK} (opens in a new tab)`);\n a.addEventListener("click", (e) => e.stopPropagation());\n place(a, aspect, (0, frame_1.watermarkBox)(aspect));\n return a;\n}\nfunction place(link, aspect, box) {\n const size = (0, frame_1.sizeFor)(aspect);\n const pad = 8;\n const share = (value, of) => `${((value / of) * 100).toFixed(3)}%`;\n link.style.left = share(box.x - pad, size.width);\n link.style.top = share(box.y - pad, size.height);\n link.style.width = share(box.w + 2 * pad, size.width);\n link.style.height = share(box.h + 2 * pad, size.height);\n}\nfunction fit(link, frame, aspect) {\n const text = frame.querySelector("svg > text:last-child");\n if (!(text instanceof SVGTextElement) || text.textContent !== frame_1.WATERMARK)\n return false;\n let width = 0;\n try {\n width = text.getComputedTextLength();\n }\n catch {\n }\n if (!(width > 0))\n return false;\n const box = (0, frame_1.watermarkBox)(aspect);\n place(link, aspect, { ...box, x: box.x + box.w - width, w: width });\n return true;\n}\nfunction start(root, sb) {\n const total = (0, timing_1.totalDuration)(sb);\n const starts = (0, frame_1.sceneStarts)(sb);\n let time = 0;\n let playing = false;\n let last = null;\n const stage = document.createElement("div");\n stage.className = `stage ${sb.settings.aspect === "9:16" ? "portrait" : sb.settings.aspect === "1:1" ? "square" : "wide"}`;\n const frame = document.createElement("div");\n frame.setAttribute("role", "img");\n stage.append(frame);\n const link = sb.settings.watermark ? credit(sb.settings.aspect) : undefined;\n if (link)\n stage.append(link);\n let fitted = false;\n const controls = document.createElement("div");\n controls.className = "controls";\n const prev = button("Previous scene", "prev");\n const play = button("Play", "play", "play");\n const next = button("Next scene", "next");\n const seek = document.createElement("input");\n seek.type = "range";\n seek.min = "0";\n seek.max = String(total);\n seek.step = "50";\n seek.setAttribute("aria-label", "Seek");\n const clock = document.createElement("span");\n clock.className = "time";\n const copy = button("Copy this payload as JSON", "copy");\n const full = button("Full screen", "expand");\n controls.append(prev, play, next, seek, clock, copy, full);\n const status = document.createElement("p");\n status.className = "status";\n status.setAttribute("role", "status");\n root.append(stage, controls, status);\n root.tabIndex = 0;\n const draw = () => {\n const at = (0, frame_1.sceneAt)(sb, Math.min(time, total));\n frame.innerHTML = (0, frame_1.renderFrame)(sb, time);\n frame.setAttribute("aria-label", at.scene.caption);\n if (link && !fitted)\n fitted = fit(link, frame, sb.settings.aspect);\n seek.value = String(Math.round(time));\n clock.textContent = `${fmt(time)} / ${fmt(total)} \xB7 ${at.index + 1}/${at.count}`;\n const ended = !playing && time >= total;\n play.innerHTML = icon(playing ? "pause" : ended ? "replay" : "play");\n play.setAttribute("aria-label", playing ? "Pause" : ended ? "Replay" : "Play");\n prev.disabled = at.index === 0;\n next.disabled = at.index === at.count - 1;\n };\n const tick = (now) => {\n if (!playing)\n return;\n time = Math.min(total, time + (last === null ? 0 : now - last));\n last = now;\n if (time >= total)\n playing = false;\n draw();\n if (playing)\n requestAnimationFrame(tick);\n };\n const toggle = () => {\n if (!playing && time >= total)\n time = 0;\n playing = !playing;\n last = null;\n draw();\n if (playing)\n requestAnimationFrame(tick);\n };\n const step = (delta) => {\n const index = Math.max(0, Math.min(starts.length - 1, (0, frame_1.sceneAt)(sb, Math.min(time, total)).index + delta));\n playing = false;\n time = starts[index] + Math.min(900, total - starts[index]);\n draw();\n };\n const payload = () => {\n const { scene, progress } = (0, frame_1.sceneAt)(sb, Math.min(time, total));\n if (scene.kind === "call" || scene.kind === "auth")\n return progress < 0.52 ? scene.request : scene.response;\n return scene.kind === "webhook" ? scene.payload : undefined;\n };\n const say = (text) => {\n status.textContent = text;\n window.setTimeout(() => status.textContent === text && (status.textContent = ""), 2500);\n };\n copy.addEventListener("click", async () => {\n const value = payload();\n if (value === undefined)\n return say("This scene has no payload to copy.");\n const text = typeof value === "string" ? value : JSON.stringify(value, null, 2);\n try {\n await navigator.clipboard.writeText(text);\n }\n catch {\n const area = document.createElement("textarea");\n area.value = text;\n document.body.append(area);\n area.select();\n document.execCommand("copy");\n area.remove();\n }\n say("Copied the payload as JSON.");\n });\n full.addEventListener("click", () => {\n if (document.fullscreenElement)\n void document.exitFullscreen();\n else if (root.requestFullscreen)\n void root.requestFullscreen().catch(() => root.classList.toggle("filled"));\n else\n root.classList.toggle("filled");\n });\n play.addEventListener("click", toggle);\n prev.addEventListener("click", () => step(-1));\n next.addEventListener("click", () => step(1));\n stage.addEventListener("click", toggle);\n seek.addEventListener("input", () => {\n playing = false;\n time = Number(seek.value);\n draw();\n });\n root.addEventListener("keydown", (e) => {\n if (e.target.tagName === "INPUT" && e.key !== " ")\n return;\n if (e.key === " ") {\n e.preventDefault();\n toggle();\n }\n else if (e.key === "ArrowRight")\n step(1);\n else if (e.key === "ArrowLeft")\n step(-1);\n else if (e.key === "f")\n full.click();\n else if (e.key === "Escape")\n root.classList.remove("filled");\n });\n draw();\n}\nconst root = document.getElementById("flow-player");\nconst data = document.getElementById("flow-storyboard");\nif (root && (data === null || data === void 0 ? void 0 : data.textContent))\n start(root, JSON.parse(data.textContent));\n\n}, {"../render/frame":"lib/render/frame","../storyboard/timing":"lib/storyboard/timing"}],\n"lib/render/frame": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.WATERMARK = void 0;\nexports.paletteFor = paletteFor;\nexports.sizeFor = sizeFor;\nexports.outputSize = outputSize;\nexports.sceneAt = sceneAt;\nexports.sceneStarts = sceneStarts;\nexports.renderFrame = renderFrame;\nexports.watermarkBox = watermarkBox;\nexports.jsonLines = jsonLines;\nexports.wrap = wrap;\nexports.esc = esc;\nconst timing_1 = require("../storyboard/timing");\nconst code_1 = require("./code");\nconst text_1 = require("../text");\nexports.WATERMARK = "Made with integrationtour.com";\nconst DARK = {\n bg: "#0b1120",\n panel: "#131c31",\n panelEdge: "#26324d",\n text: "#e6ebf5",\n muted: "#8e9ab3",\n client: "#5cc8ff",\n api: "#a58bff",\n accent: "#5cc8ff",\n ok: "#3ddc97",\n bad: "#ff6b6b",\n hook: "#ffb547",\n key: "#ffd166",\n jsonKey: "#7cc7ff",\n jsonString: "#b8e986",\n jsonOther: "#f7b17a",\n};\nconst LIGHT = {\n bg: "#f5f7fb",\n panel: "#ffffff",\n panelEdge: "#d5dce8",\n text: "#0f172a",\n muted: "#5b6a82",\n client: "#0369a1",\n api: "#6d28d9",\n accent: "#0369a1",\n ok: "#047857",\n bad: "#c81e1e",\n hook: "#b45309",\n key: "#a16207",\n jsonKey: "#0f5f8f",\n jsonString: "#166534",\n jsonOther: "#b4410c",\n};\nconst HEX_COLOR = /^#[0-9a-f]{6}$/i;\nfunction paletteFor(settings) {\n const base = settings.theme === "light" ? LIGHT : DARK;\n return settings.brandColor && HEX_COLOR.test(settings.brandColor) ? { ...base, api: settings.brandColor, accent: settings.brandColor } : base;\n}\nlet C = DARK;\nconst SANS = "Inter, \'Segoe UI\', Roboto, Helvetica, Arial, sans-serif";\nconst MONO = "\'JetBrains Mono\', \'SFMono-Regular\', Menlo, Consolas, monospace";\nfunction sizeFor(aspect) {\n if (aspect === "9:16")\n return { width: 720, height: 1280 };\n return aspect === "1:1" ? { width: 720, height: 720 } : { width: 1280, height: 720 };\n}\nfunction outputSize(settings) {\n var _a;\n const { width, height } = sizeFor(settings.aspect);\n const scale = ((_a = settings.resolution) !== null && _a !== void 0 ? _a : 720) / 720;\n return { width: Math.round(width * scale), height: Math.round(height * scale) };\n}\nfunction layoutFor(aspect) {\n if (aspect === "9:16") {\n const client = { x: 48, y: 290, w: 624, h: 110 };\n const api = { x: 48, y: 1040, w: 624, h: 110 };\n return {\n width: 720,\n height: 1280,\n stacked: true,\n caption: { x: 48, y: 110, width: 624, size: 32, minSize: 26, maxLines: 4 },\n client,\n api,\n webhook: client,\n card: { x: 136, y: 450, w: 536, h: 550 },\n lane: { from: [92, 400], to: [92, 1040] },\n hookLane: { from: [92, 1040], to: [92, 400] },\n monoSize: 16,\n title: { size: 52, logo: 120, subtitle: 26 },\n stepSize: 18,\n summary: { left: 64, top: 360, bottom: 100, size: 26, gap: 64 },\n };\n }\n if (aspect === "1:1") {\n const client = { x: 40, y: 200, w: 240, h: 92 };\n return {\n width: 720,\n height: 720,\n stacked: true,\n caption: { x: 40, y: 72, width: 640, size: 30, minSize: 24, maxLines: 3 },\n client,\n api: { x: 440, y: 200, w: 240, h: 92 },\n webhook: client,\n card: { x: 40, y: 324, w: 640, h: 326 },\n lane: { from: [280, 246], to: [440, 246] },\n hookLane: { from: [440, 246], to: [280, 246] },\n monoSize: 15,\n title: { size: 44, logo: 80, subtitle: 22 },\n stepSize: 16,\n summary: { left: 56, top: 200, bottom: 70, size: 22, gap: 48 },\n };\n }\n const client = { x: 64, y: 250, w: 250, h: 130 };\n const api = { x: 966, y: 250, w: 250, h: 130 };\n const webhook = { x: 64, y: 480, w: 250, h: 110 };\n return {\n width: 1280,\n height: 720,\n stacked: false,\n caption: { x: 64, y: 92, width: 1152, size: 30, minSize: 24, maxLines: 2 },\n client,\n api,\n webhook,\n card: { x: 354, y: 352, w: 572, h: 300 },\n lane: { from: [314, 315], to: [966, 315] },\n hookLane: { from: [966, 380], to: [314, 535] },\n monoSize: 15,\n title: { size: 56, logo: 92, subtitle: 24 },\n stepSize: 15,\n summary: { left: 200, top: 220, bottom: 70, size: 24, gap: 56 },\n };\n}\nfunction sceneAt(sb, t) {\n const scenes = (0, timing_1.activeScenes)(sb);\n let start = 0;\n for (let i = 0; i < scenes.length; i++) {\n const duration = (0, timing_1.sceneDuration)(sb, scenes[i]);\n const end = start + duration;\n if (t < end || i === scenes.length - 1) {\n return { scene: scenes[i], index: i, count: scenes.length, start, duration, progress: clamp01((t - start) / duration) };\n }\n start = end;\n }\n throw new Error("Storyboard has no scenes.");\n}\nfunction sceneStarts(sb) {\n const starts = [];\n let t = 0;\n for (const s of (0, timing_1.activeScenes)(sb)) {\n starts.push(t);\n t += (0, timing_1.sceneDuration)(sb, s);\n }\n return starts;\n}\nfunction renderFrame(sb, t, size) {\n var _a, _b;\n C = paletteFor(sb.settings);\n const L = layoutFor(sb.settings.aspect);\n const total = (0, timing_1.totalDuration)(sb);\n const at = sceneAt(sb, Math.max(0, Math.min(t, total)));\n const fade = at.index === 0 ? 1 : clamp01((at.progress * at.duration) / 300);\n let body;\n switch (at.scene.kind) {\n case "title":\n body = titleScene(L, at.scene, at.progress, sb.settings.logo);\n break;\n case "summary":\n body = summaryScene(L, at.scene, at.progress, (0, timing_1.summaryItems)(sb));\n break;\n case "auth":\n body = authScene(L, sb, at.scene, at.progress);\n break;\n case "webhook":\n body = webhookScene(L, sb, at.scene, at.progress);\n break;\n default:\n body = callScene(L, sb, at.scene, at.progress);\n }\n const parts = [\n `<svg xmlns="http://www.w3.org/2000/svg" width="${(_a = size === null || size === void 0 ? void 0 : size.width) !== null && _a !== void 0 ? _a : L.width}" height="${(_b = size === null || size === void 0 ? void 0 : size.height) !== null && _b !== void 0 ? _b : L.height}" viewBox="0 0 ${L.width} ${L.height}" font-family="${esc(SANS)}">`,\n `<rect width="${L.width}" height="${L.height}" fill="${C.bg}"/>`,\n grid(L),\n `<g opacity="${fade.toFixed(3)}">${body}</g>`,\n progressBar(L, total ? Math.min(t, total) / total : 0),\n sb.settings.watermark ? watermark(L) : "",\n `</svg>`,\n ];\n return parts.join("");\n}\nfunction titleScene(L, scene, p, logo) {\n let size = L.title.size;\n while (size > L.title.size * 0.72 && wrap(scene.title, L.width - 160, size, Infinity).length > 3)\n size -= 2;\n const lines = wrap(scene.title, L.width - 160, size, 3);\n const mark = logo && /^data:image\\/(png|jpeg|gif|webp);base64,[a-z0-9+/=]+$/i.test(logo) ? { h: L.title.logo, gap: 34 } : undefined;\n const top = L.height / 2 - (lines.length * size * 1.15) / 2 + (mark ? (mark.h + mark.gap) / 2 : 0);\n const out = lines.map((line, i) => `<text x="${L.width / 2}" y="${top + i * size * 1.15}" text-anchor="middle" font-size="${size}" font-weight="700" fill="${C.text}">${esc(line)}</text>`);\n const subY = top + lines.length * size * 1.15 + 24;\n out.push(`<text x="${L.width / 2}" y="${subY}" text-anchor="middle" font-size="${L.title.subtitle}" fill="${C.muted}">${esc(fit(scene.subtitle, L.width - 160, L.title.subtitle))}</text>`);\n if (mark) {\n const bottom = top - size * 0.78 - mark.gap;\n out.push(`<image href="${esc(logo)}" x="${L.width / 2 - 200}" y="${(bottom - mark.h).toFixed(1)}" width="400" height="${mark.h}" preserveAspectRatio="xMidYMid meet"/>`);\n }\n const dotsY = subY + 70;\n [C.client, C.api, C.hook].forEach((color, i) => {\n const glow = pulse(p, 0.25 + i * 0.15, 0.55 + i * 0.15);\n const cx = L.width / 2 + (i - 1) * 40;\n if (glow > 0)\n out.push(`<circle cx="${cx}" cy="${dotsY}" r="${(8 + 10 * glow).toFixed(1)}" fill="${color}" opacity="${(0.25 * glow).toFixed(3)}"/>`);\n out.push(`<circle cx="${cx}" cy="${dotsY}" r="8" fill="${color}"/>`);\n });\n return out.join("");\n}\nconst MIN_SUMMARY_GAP = 34;\nconst MIN_SUMMARY_SIZE = 18;\nfunction summaryScene(L, scene, p, items) {\n const out = [captionText(L, scene.caption)];\n const { left, top, bottom, size, gap } = L.summary;\n const textX = left + 44;\n const room = L.height - bottom - top;\n const plan = summaryPlan(items, L.width - textX - 56, room, size, gap);\n const r = Math.min(14, plan.gap * 0.32);\n const stagger = Math.min(0.08, 0.6 / plan.blocks.length);\n let y = top;\n plan.blocks.forEach((lines, i) => {\n const appear = clamp01((p - 0.08 - i * stagger) / 0.12);\n const more = plan.more && i === plan.blocks.length - 1;\n out.push(`<g opacity="${appear.toFixed(3)}">`, more\n ? ""\n : `<circle cx="${left + 14}" cy="${(y - 8).toFixed(1)}" r="${r.toFixed(1)}" fill="${C.ok}" opacity="0.18"/><path d="M${left + 7} ${(y - 8).toFixed(1)} l5 5 l9 -10" stroke="${C.ok}" stroke-width="3" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`, ...lines.map((line, j) => `<text x="${textX}" y="${(y + j * plan.lineHeight).toFixed(1)}" font-size="${plan.size}" fill="${more ? C.muted : C.text}">${esc(line)}</text>`), `</g>`);\n y += plan.gap + (lines.length - 1) * plan.lineHeight;\n });\n return out.join("");\n}\nfunction summaryPlan(items, width, room, baseSize, baseGap) {\n const measure = (size) => {\n const lineHeight = Math.round(size * 1.2);\n const blocks = items.map((item) => wrap(item, width, size, 2));\n const extra = blocks.reduce((n, lines) => n + lines.length - 1, 0) * lineHeight;\n return { blocks, lineHeight, extra, minGap: Math.max(MIN_SUMMARY_GAP, size * 1.45) };\n };\n for (let size = baseSize; size >= MIN_SUMMARY_SIZE; size--) {\n const { blocks, lineHeight, extra, minGap } = measure(size);\n const gaps = Math.max(1, blocks.length - 1);\n if (gaps * minGap + extra <= room)\n return { blocks, size, lineHeight, gap: Math.min(baseGap, (room - extra) / gaps), more: false };\n }\n const { blocks, lineHeight, minGap } = measure(MIN_SUMMARY_SIZE);\n const kept = [];\n let used = 0;\n for (const lines of blocks) {\n const need = (kept.length ? minGap : 0) + (lines.length - 1) * lineHeight;\n if (used + need + minGap > room)\n break;\n kept.push(lines);\n used += need;\n }\n kept.push([`+${items.length - kept.length} more`]);\n return { blocks: kept, size: MIN_SUMMARY_SIZE, lineHeight, gap: minGap, more: true };\n}\nfunction callScene(L, sb, scene, p) {\n var _a;\n const failed = scene.outcome === "failure";\n const responseColor = failed ? C.bad : C.ok;\n const requestPhase = p < 0.52;\n const mcp = sb.api.protocol === "mcp";\n const call = `${scene.method} ${scene.path}`.trim();\n const outcome = outcomeText(scene.status);\n const out = [\n stepLabel(L, `Step ${scene.step} of ${scene.stepCount}${failed ? " \xB7 failure path" : ""}`, failed ? C.bad : C.muted),\n captionText(L, scene.caption),\n ...nodes(L, sb, pulse(p, 0.4, 0.52)),\n lane(L),\n ];\n if (!L.stacked)\n out.push(laneLabel(L, call));\n if (!L.stacked && sb.scenes.some((s) => s.kind === "webhook"))\n out.push(node(L.webhook, "WEBHOOKS", (_a = sb.nodes.webhook) !== null && _a !== void 0 ? _a : "Your server", C.hook, 0, 0.35));\n if (p >= 0.1 && p < 0.4)\n out.push(packet(L.lane.from, L.lane.to, ease((p - 0.1) / 0.3), C.client));\n if (p >= 0.52 && p < 0.8)\n out.push(packet(L.lane.to, L.lane.from, ease((p - 0.52) / 0.28), responseColor));\n const cardIn = clamp01((p - 0.08) / 0.08);\n if (requestPhase) {\n const code = sb.settings.code ? (0, code_1.callCode)(sb, scene, sb.settings.code) : undefined;\n out.push(card(L, call, C.client, scene.request, scene.request === undefined && !code ? (mcp ? "No params" : "No request body") : undefined, cardIn, { code }));\n }\n else {\n out.push(card(L, mcp && failed ? `result \xB7 ${outcome}` : outcome, responseColor, scene.response, scene.response === undefined ? "No response body" : undefined, 1, { fold: mcp ? SCHEMA_KEYS : undefined }));\n }\n if (p >= 0.8) {\n const appear = clamp01((p - 0.8) / 0.06);\n out.push(badge(L.client, outcome, responseColor, appear));\n if (failed && scene.recovery)\n out.push(recoveryNote(L, scene.recovery, appear));\n }\n if (requestPhase ? scene.requestGenerated && p >= 0.08 : scene.responseGenerated) {\n const written = mcp && (requestPhase ? scene.method === "prompts/get" : isRecord(scene.response) && !("structuredContent" in scene.response));\n out.push(`<text x="${L.card.x + L.card.w}" y="${L.card.y + L.card.h + 22}" text-anchor="end" font-size="13" fill="${C.muted}">${written ? "Example text written for the video" : "Example generated from the schema"}</text>`);\n }\n return out.join("");\n}\nfunction nodes(L, sb, glow, clientOpacity = 1) {\n const mcp = sb.api.protocol === "mcp";\n return [node(L.client, mcp ? "MCP CLIENT" : "CLIENT", sb.nodes.client, C.client, 0, clientOpacity), node(L.api, mcp ? "MCP SERVER" : "API", sb.nodes.api, C.api, glow)];\n}\nfunction outcomeText(status) {\n if (status === "result")\n return "result";\n if (status === "isError")\n return "isError: true";\n const why = reason(status);\n return why ? `${status} ${why}` : status;\n}\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction authScene(L, sb, scene, p) {\n var _a;\n const out = [stepLabel(L, `Authentication \xB7 ${scene.scheme}`, C.key), captionText(L, scene.caption), ...nodes(L, sb, pulse(p, 0.4, 0.52)), lane(L)];\n if (scene.requestLine) {\n if (!L.stacked)\n out.push(laneLabel(L, scene.requestLine));\n if (p >= 0.1 && p < 0.4)\n out.push(packet(L.lane.from, L.lane.to, ease((p - 0.1) / 0.3), C.client));\n if (p >= 0.52 && p < 0.8)\n out.push(packet(L.lane.to, L.lane.from, ease((p - 0.52) / 0.28), C.key));\n const code = sb.settings.code && sb.api.protocol !== "mcp" && scene.requestType ? (0, code_1.authCode)(sb, scene, sb.settings.code) : undefined;\n const form = !code && /form-urlencoded/i.test((_a = scene.requestType) !== null && _a !== void 0 ? _a : "") && isRecord(scene.request);\n if (p < 0.52)\n out.push(card(L, scene.requestLine, C.client, form ? formText(scene.request) : scene.request, undefined, clamp01((p - 0.08) / 0.08), { code, form }));\n else\n out.push(card(L, "200 OK \xB7 access token", C.key, scene.response, undefined, 1));\n if (p >= 0.8)\n out.push(badge(L.client, "Token stored", C.key, clamp01((p - 0.8) / 0.06)));\n }\n else {\n if (!L.stacked)\n out.push(laneLabel(L, scene.headerLine.split("\\n")[0]));\n if (p >= 0.2 && p < 0.6)\n out.push(packet(L.lane.from, L.lane.to, ease((p - 0.2) / 0.4), C.key));\n const every = sb.scenes.every((s) => s.kind !== "call" || s.credentials === undefined);\n out.push(card(L, every ? "Sent with every request" : "Sent with each call that needs it", C.key, undefined, scene.headerLine, clamp01((p - 0.08) / 0.08)));\n if (p >= 0.62)\n out.push(badge(L.api, "Authenticated", C.ok, clamp01((p - 0.62) / 0.06)));\n }\n return out.join("");\n}\nfunction webhookScene(L, sb, scene, p) {\n var _a, _b, _c;\n const receiver = L.stacked ? node(L.webhook, "WEBHOOKS", (_a = sb.nodes.webhook) !== null && _a !== void 0 ? _a : "Your server", C.hook, pulse(p, 0.55, 0.7)) : "";\n const out = [\n stepLabel(L, `Webhook \xB7 ${scene.event}`, C.hook),\n captionText(L, scene.caption),\n L.stacked ? receiver : node(L.client, "CLIENT", sb.nodes.client, C.client, 0, 0.45),\n node(L.api, "API", sb.nodes.api, C.api, pulse(p, 0.05, 0.18)),\n ];\n if (!L.stacked)\n out.push(node(L.webhook, "WEBHOOKS", (_b = sb.nodes.webhook) !== null && _b !== void 0 ? _b : "Your server", C.hook, pulse(p, 0.55, 0.7)));\n out.push(`<line x1="${L.hookLane.from[0]}" y1="${L.hookLane.from[1]}" x2="${L.hookLane.to[0]}" y2="${L.hookLane.to[1]}" stroke="${C.hook}" stroke-opacity="0.35" stroke-width="2" stroke-dasharray="6 8"/>`);\n if (p >= 0.18 && p < 0.55)\n out.push(packet(L.hookLane.from, L.hookLane.to, ease((p - 0.18) / 0.37), C.hook));\n out.push(card(L, `${scene.method} ${scene.event}`, C.hook, scene.payload, scene.payload === undefined ? "Event payload" : undefined, clamp01((p - 0.1) / 0.08)));\n if (scene.payloadGenerated && scene.payload !== undefined) {\n out.push(`<text x="${L.card.x + L.card.w}" y="${L.card.y + L.card.h + 22}" text-anchor="end" font-size="13" fill="${C.muted}">Example generated from the schema</text>`);\n }\n if (p >= 0.72) {\n const ack = (_c = scene.ack) !== null && _c !== void 0 ? _c : "2XX";\n const said = `${outcomeText(ack)} \xB7 acknowledged`;\n out.push(badge(L.webhook, said.length <= Math.floor((L.webhook.w - 20) / (15 * 0.6)) ? said : `${ack} \xB7 acknowledged`, C.ok, clamp01((p - 0.72) / 0.06)));\n }\n return out.join("");\n}\nfunction grid(L) {\n const dots = [];\n for (let x = 32; x < L.width; x += 48) {\n for (let y = 32; y < L.height; y += 48)\n dots.push(`M${x} ${y}h1`);\n }\n return `<path d="${dots.join("")}" stroke="${C.panelEdge}" stroke-width="2" stroke-linecap="round" opacity="0.5"/>`;\n}\nfunction stepLabel(L, text, color) {\n return `<text x="${L.caption.x}" y="${L.caption.y - L.caption.size - 10}" font-size="${L.stepSize}" font-weight="600" letter-spacing="1.5" fill="${color}">${esc(text.toUpperCase())}</text>`;\n}\nfunction captionText(L, caption) {\n const { x, y } = L.caption;\n const { size, lines } = fitCaption(L, caption);\n return lines.map((line, i) => `<text x="${x}" y="${y + i * size * 1.25}" font-size="${size}" font-weight="600" fill="${C.text}">${esc(line)}</text>`).join("");\n}\nfunction fitCaption(L, caption) {\n const { width, size, minSize, maxLines } = L.caption;\n const whole = caption.split(/\\s+/).filter(Boolean).join(" ");\n for (const limit of [maxLines, maxLines + 1]) {\n for (let s = size; s >= minSize; s--) {\n const lines = wrap(caption, width, s, Infinity);\n if (lines.length <= limit && lines.join(" ") === whole)\n return { size: s, lines };\n }\n }\n return { size: minSize, lines: wrap(caption, width, minSize, maxLines + 1) };\n}\nfunction node(box, kicker, name, color, glow, opacity = 1) {\n const size = 22;\n return [\n `<g opacity="${opacity}">`,\n glow > 0 ? `<rect x="${box.x - 6}" y="${box.y - 6}" width="${box.w + 12}" height="${box.h + 12}" rx="20" fill="none" stroke="${color}" stroke-width="3" opacity="${(glow * 0.6).toFixed(3)}"/>` : "",\n `<rect x="${box.x}" y="${box.y}" width="${box.w}" height="${box.h}" rx="16" fill="${C.panel}" stroke="${color}" stroke-width="2"/>`,\n `<rect x="${box.x}" y="${box.y}" width="6" height="${box.h}" rx="3" fill="${color}"/>`,\n `<text x="${box.x + 28}" y="${box.y + box.h / 2 - 8}" font-size="13" font-weight="700" letter-spacing="2" fill="${color}">${esc(kicker)}</text>`,\n `<text x="${box.x + 28}" y="${box.y + box.h / 2 + 22}" font-size="${size}" font-weight="600" fill="${C.text}">${esc(fit(name, box.w - 48, size))}</text>`,\n `</g>`,\n ].join("");\n}\nfunction lane(L) {\n const [x1, y1] = L.lane.from;\n const [x2, y2] = L.lane.to;\n return `<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${C.panelEdge}" stroke-width="2" stroke-dasharray="6 8"/>`;\n}\nfunction laneLabel(L, text) {\n const [x1, y1] = L.lane.from;\n const [x2] = L.lane.to;\n return `<text x="${(x1 + x2) / 2}" y="${y1 - 16}" text-anchor="middle" font-family="${esc(MONO)}" font-size="16" fill="${C.muted}">${esc(fit(text, x2 - x1 - 40, 16, true))}</text>`;\n}\nfunction packet(from, to, t, color) {\n const x = from[0] + (to[0] - from[0]) * t;\n const y = from[1] + (to[1] - from[1]) * t;\n return `<circle cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" r="18" fill="${color}" opacity="0.2"/><circle cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" r="9" fill="${color}"/>`;\n}\nconst SCHEMA_KEYS = new Set(["inputSchema", "outputSchema"]);\nfunction card(L, header, color, value, note, opacity, { code, fold, form } = {}) {\n const { x, y, w, h } = L.card;\n const size = code ? L.monoSize - 2 : L.monoSize;\n const lineHeight = Math.round(size * 1.4);\n const maxLines = Math.floor((h - 64) / lineHeight);\n const maxChars = Math.floor((w - 40) / (size * 0.6));\n const out = [\n `<g opacity="${opacity.toFixed(3)}">`,\n `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="14" fill="${C.panel}" stroke="${C.panelEdge}" stroke-width="1.5"/>`,\n `<rect x="${x}" y="${y}" width="${w}" height="44" rx="14" fill="${color}" opacity="0.14"/>`,\n `<text x="${x + 20}" y="${y + 28}" font-family="${esc(MONO)}" font-size="${size}" font-weight="700" fill="${color}">${esc(fit(header, w - 40, size, true))}</text>`,\n ];\n if (note !== undefined) {\n note\n .split("\\n")\n .slice(0, maxLines)\n .forEach((line, i) => out.push(`<text x="${x + 20}" y="${y + 44 + (i + 1) * lineHeight + 4}" font-family="${esc(MONO)}" font-size="${size}" fill="${C.muted}">${esc(fit(line, w - 40, size, true))}</text>`));\n }\n else {\n const lines = code ? codeTspans(code, maxLines, maxChars) : form ? formTspans(String(value), maxLines, maxChars) : jsonLines(value, maxLines, maxChars, fold);\n lines.forEach((line, i) => out.push(`<text x="${x + 20}" y="${y + 44 + (i + 1) * lineHeight + 4}" font-family="${esc(MONO)}" font-size="${size}" xml:space="preserve">${line}</text>`));\n }\n out.push(`</g>`);\n return out.join("");\n}\nfunction badge(box, text, color, opacity) {\n const size = 15;\n const w = Math.min(box.w, textWidth(text, size, true) + 28);\n const x = box.x + box.w - w;\n const y = box.y - 40;\n return `<g opacity="${opacity.toFixed(3)}"><rect x="${x}" y="${y}" width="${w}" height="30" rx="15" fill="${color}" opacity="0.18"/><rect x="${x}" y="${y}" width="${w}" height="30" rx="15" fill="none" stroke="${color}" stroke-width="1.5"/><text x="${x + w / 2}" y="${y + 20}" text-anchor="middle" font-family="${esc(MONO)}" font-size="${size}" font-weight="700" fill="${color}">${esc(fit(text, w - 20, size, true))}</text></g>`;\n}\nfunction recoveryNote(L, text, opacity) {\n const box = L.stacked ? { x: L.card.x, y: L.client.y + L.client.h + 6 } : { x: L.client.x, y: L.client.y + L.client.h + 22 };\n const width = L.stacked ? L.card.w : L.client.w;\n const lines = wrap(`\u21BB ${text}`, width, 17, L.stacked ? 1 : 3);\n return `<g opacity="${opacity.toFixed(3)}">${lines\n .map((line, i) => `<text x="${box.x}" y="${box.y + 18 + i * 22}" font-size="17" font-weight="600" fill="${C.hook}">${esc(line)}</text>`)\n .join("")}</g>`;\n}\nfunction progressBar(L, fraction) {\n return `<rect x="0" y="${L.height - 4}" width="${L.width}" height="4" fill="${C.panelEdge}"/><rect x="0" y="${L.height - 4}" width="${(L.width * clamp01(fraction)).toFixed(1)}" height="4" fill="${C.accent}"/>`;\n}\nconst MARK = { size: 15, right: 24, bottom: 20 };\nfunction watermark(L) {\n return `<text x="${L.width - MARK.right}" y="${L.height - MARK.bottom}" text-anchor="end" font-size="${MARK.size}" font-weight="600" fill="${C.muted}" opacity="0.75">${esc(exports.WATERMARK)}</text>`;\n}\nfunction watermarkBox(aspect) {\n const L = layoutFor(aspect);\n const w = exports.WATERMARK.length * MARK.size * 0.6;\n return { x: L.width - MARK.right - w, y: L.height - MARK.bottom - MARK.size, w, h: MARK.size * 1.3 };\n}\nconst FOLDED = "\\uE000";\nfunction jsonLines(value, maxLines, maxChars, fold) {\n var _a, _b;\n let text;\n try {\n const replacer = fold ? (key, v) => (fold.has(key) && isRecord(v) ? FOLDED : v) : undefined;\n text = typeof value === "string" ? value : ((_b = (_a = JSON.stringify(value, replacer, 2)) === null || _a === void 0 ? void 0 : _a.replace(/"\\uE000"/g, "{ \u2026 }")) !== null && _b !== void 0 ? _b : "");\n }\n catch {\n text = String(value);\n }\n let lines = text.split("\\n");\n if (lines.length > maxLines)\n lines = [...lines.slice(0, Math.max(1, maxLines - 1)), " \u2026"];\n const xml = typeof value === "string" && /^\\s*</.test(value);\n return lines.map((raw) => {\n const line = (0, text_1.clip)(raw, maxChars);\n if (xml)\n return xmlTspans(line);\n const field = typeof value === "string" ? line.match(/^(event|data|id|retry):( ?)(.*)$/) : null;\n if (field)\n return `<tspan fill="${C.jsonKey}">${esc(field[1])}</tspan><tspan fill="${C.muted}">:${field[2]}</tspan>${colorValue(field[3])}`;\n const m = line.match(/^(\\s*)("(?:[^"\\\\]|\\\\.)*")(:\\s?)(.*)$/);\n if (!m)\n return colorValue(line);\n return `<tspan fill="${C.muted}">${esc(m[1])}</tspan><tspan fill="${C.jsonKey}">${esc(m[2])}</tspan><tspan fill="${C.muted}">${esc(m[3])}</tspan>${colorValue(m[4])}`;\n });\n}\nfunction formText(fields) {\n return Object.entries(fields)\n .map(([key, value], i) => `${i ? "&" : ""}${key}=${typeof value === "string" ? value : JSON.stringify(value)}`)\n .join("\\n");\n}\nfunction formTspans(text, maxLines, maxChars) {\n let lines = text.split("\\n");\n if (lines.length > maxLines)\n lines = [...lines.slice(0, Math.max(1, maxLines - 1)), "\u2026"];\n return lines.map((raw) => {\n const line = (0, text_1.clip)(raw, maxChars);\n const m = line.match(/^(&?)([^=]*)(=?)(.*)$/);\n return `<tspan fill="${C.muted}">${esc(m[1])}</tspan><tspan fill="${C.jsonKey}">${esc(m[2])}</tspan><tspan fill="${C.muted}">${esc(m[3])}</tspan><tspan fill="${C.jsonString}">${esc(m[4])}</tspan>`;\n });\n}\nconst XML_TOKEN = /(<\\/?[\\w.:-]+|\\/?>)|("[^"]*"?)|([\\w.:-]+=)/g;\nfunction xmlTspans(line) {\n const out = [];\n let last = 0;\n for (const m of line.matchAll(XML_TOKEN)) {\n if (m.index > last)\n out.push(`<tspan fill="${C.jsonString}">${esc(line.slice(last, m.index))}</tspan>`);\n const [token, tag, str] = m;\n out.push(`<tspan fill="${tag ? C.jsonKey : str ? C.jsonString : C.muted}">${esc(token)}</tspan>`);\n last = m.index + token.length;\n }\n if (last < line.length)\n out.push(`<tspan fill="${C.jsonString}">${esc(line.slice(last))}</tspan>`);\n return out.join("");\n}\nfunction codeTspans(code, maxLines, maxChars) {\n let lines = code.flatMap((line) => softWrap(line, maxChars));\n if (lines.length > maxLines)\n lines = [...lines.slice(0, Math.max(1, maxLines - 1)), " \u2026"];\n return lines.map((line) => {\n const out = [];\n let last = 0;\n for (const m of line.matchAll(CODE_TOKEN)) {\n if (m.index > last)\n out.push(`<tspan fill="${C.text}">${esc(line.slice(last, m.index))}</tspan>`);\n const [token, str, num, word] = m;\n const color = str ? (/^\\s*:/.test(line.slice(m.index + token.length)) ? C.jsonKey : C.jsonString) : num ? C.jsonOther : word ? C.key : m.index === 0 || /\\s/.test(line[m.index - 1]) ? C.client : C.text;\n out.push(`<tspan fill="${color}">${esc(token)}</tspan>`);\n last = m.index + token.length;\n }\n if (last < line.length)\n out.push(`<tspan fill="${C.text}">${esc(line.slice(last))}</tspan>`);\n return out.join("");\n });\n}\nconst CODE_TOKEN = /("(?:[^"\\\\]|\\\\.)*"?|\'(?:[^\'\\\\]|\\\\.)*\'?)|(\\b\\d+(?:\\.\\d+)?\\b)|(\\b(?:curl|await|fetch|requests|new|JSON|FormData|URLSearchParams|open|True|False|None|true|false|null)\\b)|(--?[a-zA-Z][\\w-]*)/g;\nfunction softWrap(line, max) {\n const indent = line.match(/^\\s*/)[0].length + 4;\n const out = [];\n let rest = line;\n while (rest.length > max && out.length < 40) {\n const window = rest.slice(0, max);\n const at = Math.max(window.lastIndexOf("/"), window.lastIndexOf(" "), window.lastIndexOf(","));\n const piece = at > indent ? rest.slice(0, at + 1) : (0, text_1.cut)(rest, max);\n out.push(piece);\n rest = " ".repeat(indent) + rest.slice(piece.length).trimStart();\n }\n return [...out, (0, text_1.clip)(rest, max)];\n}\nfunction colorValue(text) {\n const trimmed = text.trim();\n const color = trimmed.startsWith(\'"\') ? C.jsonString : /^[\\d\\-tfn]/.test(trimmed) ? C.jsonOther : C.muted;\n return `<tspan fill="${color}">${esc(text)}</tspan>`;\n}\nfunction textWidth(text, size, mono = false) {\n return text.length * size * (mono ? 0.6 : 0.54);\n}\nfunction fit(text, width, size, mono = false) {\n const max = Math.floor(width / (size * (mono ? 0.6 : 0.54)));\n return text.length > max ? (0, text_1.cut)(text, Math.max(1, max - 1)) + "\u2026" : text;\n}\nfunction wrap(text, width, size, maxLines) {\n const max = Math.max(8, Math.floor(width / (size * 0.54)));\n const words = text.split(/\\s+/).filter(Boolean);\n const lines = [];\n let current = "";\n for (const word of words) {\n const next = current ? `${current} ${word}` : word;\n if (next.length <= max)\n current = next;\n else {\n if (current)\n lines.push(current);\n current = (0, text_1.clip)(word, max);\n }\n }\n if (current)\n lines.push(current);\n if (lines.length > maxLines) {\n const kept = lines.slice(0, maxLines);\n kept[maxLines - 1] = fit(`${kept[maxLines - 1]} \u2026`, width, size);\n return kept;\n }\n return lines;\n}\nconst NOT_XML = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F\\uD800-\\uDFFF\uFFFE\uFFFF]/g;\nfunction esc(text) {\n return text\n .replace(NOT_XML, (c) => (c.length === 2 ? c : c < " " ? " " : ""))\n .replace(/&/g, "&amp;")\n .replace(/</g, "&lt;")\n .replace(/>/g, "&gt;")\n .replace(/"/g, "&quot;")\n .replace(/\'/g, "&#39;");\n}\nconst REASONS = {\n "200": "OK",\n "201": "Created",\n "202": "Accepted",\n "204": "No Content",\n "206": "Partial Content",\n "301": "Moved Permanently",\n "302": "Found",\n "303": "See Other",\n "304": "Not Modified",\n "307": "Temporary Redirect",\n "308": "Permanent Redirect",\n "400": "Bad Request",\n "401": "Unauthorized",\n "402": "Payment Required",\n "403": "Forbidden",\n "404": "Not Found",\n "405": "Method Not Allowed",\n "409": "Conflict",\n "410": "Gone",\n "412": "Precondition Failed",\n "413": "Content Too Large",\n "422": "Unprocessable",\n "429": "Too Many Requests",\n "500": "Server Error",\n "502": "Bad Gateway",\n "503": "Unavailable",\n "504": "Gateway Timeout",\n};\nfunction reason(status) {\n var _a;\n return (_a = REASONS[status]) !== null && _a !== void 0 ? _a : "";\n}\nfunction clamp01(n) {\n return Math.max(0, Math.min(1, n));\n}\nfunction ease(t) {\n const x = clamp01(t);\n return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;\n}\nfunction pulse(p, a, b) {\n if (p < a || p > b)\n return 0;\n return Math.sin(((p - a) / (b - a)) * Math.PI);\n}\n\n}, {"../storyboard/timing":"lib/storyboard/timing","./code":"lib/render/code","../text":"lib/text"}],\n"lib/storyboard/timing": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.VOICE_LEAD = void 0;\nexports.activeScenes = activeScenes;\nexports.sceneDuration = sceneDuration;\nexports.totalDuration = totalDuration;\nexports.voiceCues = voiceCues;\nexports.summaryItems = summaryItems;\nexports.VOICE_LEAD = 400;\nconst VOICE_TAIL = 600;\nfunction activeScenes(sb) {\n return sb.scenes.filter((s) => sb.settings.showFailure || !s.failurePath);\n}\nfunction sceneDuration(sb, scene) {\n if (!sb.settings.voiceover || !scene.voiceMs)\n return scene.duration;\n return Math.max(scene.duration, Math.ceil(exports.VOICE_LEAD + scene.voiceMs + VOICE_TAIL));\n}\nfunction totalDuration(sb) {\n return activeScenes(sb).reduce((sum, s) => sum + sceneDuration(sb, s), 0);\n}\nfunction voiceCues(sb) {\n if (!sb.settings.voiceover)\n return [];\n const cues = [];\n let t = 0;\n for (const scene of activeScenes(sb)) {\n if (scene.voiceMs)\n cues.push({ sceneId: scene.id, at: t + exports.VOICE_LEAD });\n t += sceneDuration(sb, scene);\n }\n return cues;\n}\nfunction summaryItems(sb) {\n const items = [];\n let failure;\n for (const scene of activeScenes(sb)) {\n if (!scene.summaryLine)\n continue;\n if (scene.kind === "call" && scene.outcome === "failure") {\n failure = scene.summaryLine;\n continue;\n }\n items.push(scene.summaryLine);\n if (failure)\n items.push(failure);\n failure = undefined;\n }\n if (failure)\n items.push(failure);\n return items;\n}\n\n}, {}],\n"lib/render/code": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.CODE_STYLES = void 0;\nexports.codeRequest = codeRequest;\nexports.authCode = authCode;\nexports.callCode = callCode;\nexports.codeLines = codeLines;\nconst examples_1 = require("../oas/examples");\nconst timing_1 = require("../storyboard/timing");\nexports.CODE_STYLES = [\n { style: "curl", label: "curl" },\n { style: "javascript", label: "JavaScript" },\n { style: "python", label: "Python" },\n];\nfunction codeRequest(sb, scene) {\n var _a, _b, _c, _d;\n let url = /^[a-z][a-z\\d+.-]*:\\/\\//i.test(scene.path) ? scene.path : `${sb.api.baseUrl}${scene.path}`;\n const body = /^(GET|HEAD)$/.test(scene.method) && isEmptyValue(scene.request) ? undefined : scene.request;\n const req = { method: scene.method, url, headers: [], body, contentType: scene.requestType, ...(scene.encoding ? { encoding: scene.encoding } : {}) };\n const auth = sb.scenes.find((s) => s.kind === "auth");\n const credentials = (_a = scene.credentials) !== null && _a !== void 0 ? _a : ((auth === null || auth === void 0 ? void 0 : auth.kind) === "auth" ? ((_b = auth.credentials) !== null && _b !== void 0 ? _b : auth.headerLine.split("\\n").map(fromLine)) : []);\n const cookies = ((_c = scene.cookies) !== null && _c !== void 0 ? _c : []).map(([name, value]) => `${name}=${value}`);\n for (const credential of credentials) {\n if (!credential)\n continue;\n const c = { ...credential, value: credential.value.replace(/\u2026/g, "...") };\n if (c.in === "query")\n url += (url.includes("?") ? "&" : "?") + `${c.name}=${c.value}`;\n else if (c.in === "cookie")\n cookies.unshift(`${c.name}=${c.value}`);\n else if (c.in === "certificate")\n req.certificate = { cert: c.name, key: c.value };\n else if (c.in === "digest")\n req.digest = { username: c.name, password: c.value };\n else\n req.headers.push([c.name, c.value]);\n }\n req.headers.push(...((_d = scene.headers) !== null && _d !== void 0 ? _d : []));\n if (cookies.length)\n req.headers.push(["Cookie", cookies.join("; ")]);\n return { ...req, url };\n}\nfunction fromLine(line) {\n if (line.startsWith("?")) {\n const eq = line.indexOf("=");\n return eq > 1 ? { in: "query", name: line.slice(1, eq), value: line.slice(eq + 1) } : undefined;\n }\n const colon = line.indexOf(":");\n return colon > 0 ? { in: "header", name: line.slice(0, colon).trim(), value: line.slice(colon + 1).trim() } : undefined;\n}\nfunction bodyKind(req) {\n var _a, _b;\n const type = (_b = (_a = req.contentType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : "";\n if (req.body === undefined)\n return "none";\n if (type.includes("multipart/form-data") && isObject(req.body))\n return "multipart";\n if (type.includes("x-www-form-urlencoded") && isObject(req.body))\n return "form";\n if (typeof req.body === "string" && req.body === examples_1.BINARY_PLACEHOLDER)\n return "binary";\n if (typeof req.body === "string" && type && !/json/.test(type))\n return "text";\n return "json";\n}\nconst isFile = (value) => value === examples_1.BINARY_PLACEHOLDER;\nfunction fieldText(value) {\n return typeof value === "string" ? value : value === undefined || value === null ? "" : typeof value === "object" ? JSON.stringify(value) : String(value);\n}\nfunction formPairs(body, encoding = {}) {\n var _a, _b, _c, _d;\n const out = [];\n for (const [name, value] of Object.entries(body)) {\n if (value === null || value === undefined)\n continue;\n const style = (_b = (_a = encoding[name]) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : "form";\n const explode = (_d = (_c = encoding[name]) === null || _c === void 0 ? void 0 : _c.explode) !== null && _d !== void 0 ? _d : style === "form";\n if (style === "deepObject" && typeof value === "object" && value !== null)\n out.push(...bracketed(name, value));\n else if (Array.isArray(value)) {\n if (explode && style === "form")\n out.push(...value.map((item) => [name, fieldText(item)]));\n else\n out.push([name, value.map(fieldText).join(style === "spaceDelimited" ? " " : style === "pipeDelimited" ? "|" : ",")]);\n }\n else if (isObject(value)) {\n if (explode)\n out.push(...Object.entries(value).map(([key, v]) => [key, fieldText(v)]));\n else\n out.push([name, Object.entries(value).flatMap(([key, v]) => [key, fieldText(v)]).join(",")]);\n }\n else\n out.push([name, fieldText(value)]);\n }\n return out;\n}\nfunction bracketed(name, value) {\n if (Array.isArray(value))\n return value.flatMap((item, i) => bracketed(`${name}[${i}]`, item));\n if (isObject(value))\n return Object.entries(value).flatMap(([key, v]) => bracketed(`${name}[${key}]`, v));\n return [[name, fieldText(value)]];\n}\nfunction formObject(body) {\n return Object.fromEntries(Object.entries(body).flatMap(([key, value]) => (value === null || value === undefined ? [] : [[key, typeof value === "boolean" ? String(value) : value]])));\n}\nfunction flat(body) {\n return Object.values(body).every((value) => typeof value !== "object" || value === null);\n}\nfunction multipartParts(body, encoding = {}) {\n var _a;\n const parts = [];\n for (const [name, value] of Object.entries(body)) {\n if (value === null || value === undefined)\n continue;\n const type = (_a = encoding[name]) === null || _a === void 0 ? void 0 : _a.contentType;\n const items = Array.isArray(value) && !value.some((v) => typeof v === "object" && v !== null) ? value : [value];\n for (const item of items) {\n if (isFile(item))\n parts.push({ name, file: true });\n else if (typeof item === "object" && item !== null)\n parts.push({ name, text: JSON.stringify(item), type: type !== null && type !== void 0 ? type : "application/json" });\n else\n parts.push({ name, text: fieldText(item), ...(type && !/^text\\/plain\\b/i.test(type) ? { type } : {}) });\n }\n }\n return parts;\n}\nfunction filePath(name) {\n return /^[\\w-]+$/.test(name) ? name : "file";\n}\nfunction isObject(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction isEmptyValue(value) {\n return value === undefined || (typeof value === "object" && value !== null && Object.keys(value).length === 0);\n}\nfunction authCode(sb, scene, style) {\n var _a, _b, _c, _d;\n const target = (_b = (_a = scene.requestLine) === null || _a === void 0 ? void 0 : _a.replace(/^POST\\s+/, "")) !== null && _b !== void 0 ? _b : "";\n const url = (_c = scene.tokenUrl) !== null && _c !== void 0 ? _c : (/^https?:\\/\\//i.test(target) ? target : `${sb.api.baseUrl}${target}`);\n return codeLines({ method: "POST", url, headers: [], body: scene.request, contentType: (_d = scene.requestType) !== null && _d !== void 0 ? _d : "application/x-www-form-urlencoded" }, style);\n}\nfunction callCode(sb, scene, style) {\n return sb.api.protocol === "mcp" ? mcpCode(sb, scene, style) : codeLines(codeRequest(sb, scene), style);\n}\nfunction codeLines(req, style) {\n switch (style) {\n case "curl":\n return curl(req);\n case "javascript":\n return javascript(req);\n default:\n return python(req);\n }\n}\nfunction curl(req) {\n var _a, _b, _c;\n const kind = bodyKind(req);\n const parts = [];\n const method = req.method === "HEAD" ? " -I" : req.method === "GET" || (req.method === "POST" && kind !== "none") ? "" : ` -X ${shellQuote(req.method)}`;\n const glob = /[[\\]{}]/.test(req.url) ? " -g" : "";\n parts.push([`curl${glob}${method} ${shellQuote(req.url, /[?&]/.test(req.url))}`]);\n if (req.certificate)\n parts.push([` --cert ${shellQuote(req.certificate.cert)} --key ${shellQuote(req.certificate.key)}`]);\n if (req.digest)\n parts.push([` --digest -u ${shellQuote(`${req.digest.username}:${req.digest.password}`, true)}`]);\n for (const [name, value] of req.headers)\n parts.push([` -H ${shellQuote(`${name}: ${value}`, true)}`]);\n const body = req.body;\n const contentType = (type) => [` -H ${shellQuote(`Content-Type: ${type}`, true)}`];\n if (kind === "json") {\n parts.push(contentType((_a = req.contentType) !== null && _a !== void 0 ? _a : "application/json"));\n parts.push(quotedData(pretty(body, "json", 2)));\n }\n else if (kind === "form" && isObject(body)) {\n for (const [key, value] of formPairs(body, req.encoding))\n parts.push([` --data-urlencode ${shellQuote(`${key}=${value}`, true)}`]);\n }\n else if (kind === "multipart" && isObject(body)) {\n for (const part of multipartParts(body, req.encoding))\n parts.push([` ${formPart(part)}`]);\n }\n else if (kind === "binary") {\n parts.push(contentType((_b = req.contentType) !== null && _b !== void 0 ? _b : "application/octet-stream"), [" --data-binary @file"]);\n }\n else if (kind === "text") {\n parts.push(contentType((_c = req.contentType) !== null && _c !== void 0 ? _c : "text/plain"), quotedData(String(body).split("\\n")));\n }\n return parts.flatMap((part, p) => part.map((line, i) => (p < parts.length - 1 && i === part.length - 1 ? `${line} \\\\` : line)));\n}\nfunction formPart(part) {\n const value = part.file ? `@${filePath(part.name)}` : part.text;\n if (part.name.includes("="))\n return `--form-string ${shellQuote(`${part.name}=${value}`, true)}`;\n if (part.file)\n return `-F ${shellQuote(`${part.name}=${value}`, true)}`;\n if (part.type) {\n const text = readsMore(value) ? `"${value.replace(/[\\\\"]/g, "\\\\$&")}"` : value;\n return `-F \'${escapeSingle(`${part.name}=${text}${formType(part.type)}`)}\'`;\n }\n return `${readsMore(value) ? "--form-string" : "-F"} ${shellQuote(`${part.name}=${value}`, true)}`;\n}\nfunction formType(type) {\n const [essence, ...params] = type.split(",")[0].split(";").map((s) => s.trim());\n if (!/^[\\w.+*-]+\\/[\\w.+*-]+$/.test(essence))\n return "";\n const kept = params.filter((p) => /^[\\w.+-]+=[^\\s"\\\\]*$/.test(p) && !/^(type|filename|headers|encoder)=/i.test(p));\n return `;type=${[essence, ...kept].join("; ")}`;\n}\nfunction readsMore(text) {\n return /^[@<"\\s]|;|\\s$/.test(text);\n}\nfunction quotedData(lines) {\n const body = lines.map(escapeSingle);\n return body.length === 1 ? [` -d \'${body[0]}\'`] : [` -d \'${body[0]}`, ...body.slice(1, -1).map((l) => ` ${l}`), ` ${body.at(-1)}\'`];\n}\nfunction shellQuote(text, always = false) {\n if (!always && !/[^\\w@%+=:,./-]/.test(text))\n return text;\n return /["\\\\$`!]/.test(text) ? `\'${escapeSingle(text)}\'` : `"${text}"`;\n}\nfunction escapeSingle(text) {\n return text.replace(/\'/g, `\'\\\\\'\'`);\n}\nfunction javascript(req) {\n var _a, _b, _c;\n const kind = bodyKind(req);\n const lines = [];\n const headers = [...req.headers];\n let body = [];\n if (req.certificate)\n lines.push(`// Sent over mutual TLS with ${req.certificate.cert} and ${req.certificate.key}`);\n if (req.digest) {\n lines.push("// Answer the API\'s Digest challenge with your username and password");\n headers.push(["Authorization", `Digest username="${req.digest.username}", nonce="...", response="..."`]);\n }\n if (kind === "json") {\n headers.push(["Content-Type", (_a = req.contentType) !== null && _a !== void 0 ? _a : "application/json"]);\n body = wrapLines("body: JSON.stringify(", pretty(req.body, "json", 2), "),");\n }\n else if (kind === "multipart" && isObject(req.body)) {\n lines.push("const form = new FormData();");\n for (const part of multipartParts(req.body, req.encoding)) {\n const value = part.file ? "file" : part.type ? `new Blob([${jsString(part.text)}], { type: ${jsString(part.type)} })` : jsString(part.text);\n lines.push(`form.append(${jsString(part.name)}, ${value});`);\n }\n body = ["body: form,"];\n }\n else if (kind === "form" && isObject(req.body)) {\n body = flat(req.body) && !req.encoding\n ? wrapLines("body: new URLSearchParams(", pretty(formObject(req.body), "json", 2), "),")\n : ["body: new URLSearchParams([", ...formPairs(req.body, req.encoding).map(([k, v]) => ` [${jsString(k)}, ${jsString(v)}],`), "]),"];\n }\n else if (kind === "binary") {\n headers.push(["Content-Type", (_b = req.contentType) !== null && _b !== void 0 ? _b : "application/octet-stream"]);\n body = ["body: file,"];\n }\n else if (kind === "text") {\n headers.push(["Content-Type", (_c = req.contentType) !== null && _c !== void 0 ? _c : "text/plain"]);\n const text = String(req.body);\n body = text.includes("\\n") ? wrapLines("body: `", text.replace(/[`\\\\]|\\$\\{/g, (m) => `\\\\${m}`).split("\\n"), "`,") : [`body: ${jsString(text)},`];\n }\n const options = [\n ...(req.method === "GET" ? [] : [`method: ${jsString(req.method)},`]),\n ...(headers.length ? ["headers: {", ...headers.map(([n, v]) => ` ${jsString(n)}: ${jsString(v)},`), "},"] : []),\n ...body,\n ];\n if (!options.length)\n return [...lines, `await fetch(${jsString(req.url)});`];\n return [...lines, `await fetch(${jsString(req.url)}, {`, ...options.map((l) => ` ${l}`), "});"];\n}\nfunction jsString(text) {\n return JSON.stringify(text);\n}\nconst PYTHON_METHODS = new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);\nfunction python(req) {\n var _a, _b;\n const kind = bodyKind(req);\n const args = [[`${jsString(req.url)},`]];\n const headers = [...req.headers];\n if (kind === "binary")\n headers.push(["Content-Type", (_a = req.contentType) !== null && _a !== void 0 ? _a : "application/octet-stream"]);\n if (kind === "text")\n headers.push(["Content-Type", (_b = req.contentType) !== null && _b !== void 0 ? _b : "text/plain"]);\n if (headers.length === 1)\n args.push([`headers={${jsString(headers[0][0])}: ${jsString(headers[0][1])}},`]);\n else if (headers.length)\n args.push(["headers={", ...headers.map(([n, v]) => ` ${jsString(n)}: ${jsString(v)},`), "},"]);\n if (req.certificate)\n args.push([`cert=(${jsString(req.certificate.cert)}, ${jsString(req.certificate.key)}),`]);\n if (req.digest)\n args.push([`auth=requests.auth.HTTPDigestAuth(${jsString(req.digest.username)}, ${jsString(req.digest.password)}),`]);\n if (kind === "json")\n args.push(wrapLines("json=", pretty(req.body, "python", 4), ","));\n else if (kind === "form" && isObject(req.body)) {\n if (flat(req.body) && !req.encoding)\n args.push(wrapLines("data=", pretty(formObject(req.body), "python", 4), ","));\n else\n args.push(["data=[", ...formPairs(req.body, req.encoding).map(([k, v]) => ` (${jsString(k)}, ${jsString(v)}),`), "],"]);\n }\n else if (kind === "multipart" && isObject(req.body)) {\n const parts = multipartParts(req.body, req.encoding);\n const typed = parts.filter((p) => p.file || p.type);\n const files = typed.length ? typed : parts;\n const fields = typed.length ? parts.filter((p) => !p.file && !p.type) : [];\n const file = (p) => (p.file ? `open(${jsString(filePath(p.name))}, "rb")` : p.type ? `(None, ${jsString(p.text)}, ${jsString(p.type)})` : `(None, ${jsString(p.text)})`);\n const twice = (list) => new Set(list.map((p) => p.name)).size < list.length;\n if (files.length) {\n args.push(twice(files) ? ["files=[", ...files.map((p) => ` (${jsString(p.name)}, ${file(p)}),`), "],"] : ["files={", ...files.map((p) => ` ${jsString(p.name)}: ${file(p)},`), "},"]);\n }\n if (fields.length) {\n args.push(twice(fields) ? ["data=[", ...fields.map((p) => ` (${jsString(p.name)}, ${jsString(p.text)}),`), "],"] : ["data={", ...fields.map((p) => ` ${jsString(p.name)}: ${jsString(p.text)},`), "},"]);\n }\n }\n else if (kind === "binary")\n args.push([`data=open("file", "rb"),`]);\n else if (kind === "text") {\n const text = String(req.body);\n args.push(text.includes("\\n") ? wrapLines(\'data="""\', text.replace(/\\\\/g, "\\\\\\\\").replace(/"""/g, \'\\\\"\\\\"\\\\"\').split("\\n"), \'""",\') : [`data=${jsString(text)},`]);\n }\n const call = PYTHON_METHODS.has(req.method) ? `requests.${req.method.toLowerCase()}(` : `requests.request(${jsString(req.method)},`;\n return [call, ...args.flat().map((l) => ` ${l}`), ")"];\n}\nconst MCP_VERSION = "2026-07-28";\nconst VERSION_HEADER_SINCE = "2025-06-18";\nconst SESSION_ID = "1868a90c...";\nconst CLIENT_INFO = { name: "your-agent", version: "1.0.0" };\nfunction mcpCode(sb, scene, style) {\n const http = /^https?:\\/\\//i.test(sb.api.baseUrl);\n const auth = sb.scenes.some((s) => s.kind === "auth");\n switch (style) {\n case "curl":\n return mcpWire(sb, scene, http);\n case "javascript":\n return mcpJavaScript(sb, scene, http, auth);\n default:\n return mcpPython(sb, scene, http, auth);\n }\n}\nfunction rpcBody(sb, scene, modern) {\n var _a;\n const meta = { "io.modelcontextprotocol/protocolVersion": MCP_VERSION, "io.modelcontextprotocol/clientInfo": CLIENT_INFO, "io.modelcontextprotocol/clientCapabilities": {} };\n const params = scene.method === "tools/call"\n ? { name: scene.path, arguments: (_a = scene.request) !== null && _a !== void 0 ? _a : {} }\n : scene.method === "resources/read"\n ? { uri: scene.path }\n : scene.method === "prompts/get"\n ? { name: scene.path, ...(scene.request !== undefined ? { arguments: scene.request } : {}) }\n : {};\n if (!modern)\n return { jsonrpc: "2.0", id: rpcId(sb, scene), method: scene.method, ...(Object.keys(params).length ? { params } : {}) };\n return { jsonrpc: "2.0", id: rpcId(sb, scene), method: scene.method, params: { ...params, _meta: meta } };\n}\nfunction rpcId(sb, scene) {\n const index = (0, timing_1.activeScenes)(sb)\n .filter((s) => s.kind === "call")\n .indexOf(scene);\n return index >= 0 ? index + 1 : scene.step;\n}\nfunction mcpWire(sb, scene, http) {\n var _a, _b, _c;\n const revision = (_a = sb.api.revision) !== null && _a !== void 0 ? _a : MCP_VERSION;\n const modern = revision >= MCP_VERSION;\n const body = JSON.stringify(rpcBody(sb, scene, modern));\n if (!http) {\n if (modern)\n return [`echo \'${escapeSingle(body)}\' \\\\`, ` | ${sb.api.baseUrl}`];\n const init = JSON.stringify({ jsonrpc: "2.0", id: 0, method: "initialize", params: { protocolVersion: revision, capabilities: {}, clientInfo: CLIENT_INFO } });\n return [`printf \'%s\\\\n\' \\\\`, ` \'${escapeSingle(init)}\' \\\\`, ` \'{"jsonrpc":"2.0","method":"notifications/initialized"}\' \\\\`, ` \'${escapeSingle(body)}\' \\\\`, ` | ${sb.api.baseUrl}`];\n }\n const headers = [["Accept", "application/json, text/event-stream"]];\n if (modern) {\n headers.push(["MCP-Protocol-Version", MCP_VERSION], ["Mcp-Method", scene.method]);\n if (scene.method !== "tools/list")\n headers.push(["Mcp-Name", headerValue(scene.path)]);\n for (const { name, path } of (_b = scene.paramHeaders) !== null && _b !== void 0 ? _b : []) {\n const value = path.reduce((at, key) => (isObject(at) ? at[key] : undefined), scene.request);\n if (typeof value === "string" || typeof value === "boolean" || (typeof value === "number" && Number.isSafeInteger(value)))\n headers.push([`Mcp-Param-${name}`, headerValue(String(value))]);\n }\n }\n else {\n if (revision >= VERSION_HEADER_SINCE)\n headers.push(["MCP-Protocol-Version", revision]);\n if (sb.api.session !== false)\n headers.push(["Mcp-Session-Id", SESSION_ID]);\n }\n const auth = sb.scenes.find((s) => s.kind === "auth");\n if ((auth === null || auth === void 0 ? void 0 : auth.kind) === "auth")\n for (const c of (_c = auth.credentials) !== null && _c !== void 0 ? _c : [])\n if (c.in === "header")\n headers.push([c.name, c.value.replace(/\u2026/g, "...")]);\n return [`curl ${shellQuote(sb.api.baseUrl)} \\\\`, ...headers.map(([n, v]) => ` -H ${shellQuote(`${n}: ${v}`, true)} \\\\`), ` --json \'${escapeSingle(body)}\'`];\n}\nfunction headerValue(text) {\n const plain = /^[\\x21-\\x7e]([\\x20-\\x7e\\t]*[\\x21-\\x7e])?$/.test(text) && !/^=\\?base64\\?.*\\?=$/.test(text);\n if (plain)\n return text;\n const bytes = new TextEncoder().encode(text);\n let binary = "";\n for (const byte of bytes)\n binary += String.fromCharCode(byte);\n return `=?base64?${btoa(binary)}?=`;\n}\nfunction mcpJavaScript(sb, scene, http, auth) {\n var _a, _b, _c;\n switch (scene.method) {\n case "tools/list": {\n const command = sb.api.baseUrl.split(" ");\n const transport = http\n ? [` new StreamableHTTPClientTransport(new URL(${jsString(sb.api.baseUrl)})${auth ? ", { authProvider }" : ""}),`]\n : [` new StdioClientTransport({ command: ${jsString(command[0])}, args: ${list(command.slice(1))} }),`];\n const negotiate = ((_a = sb.api.revision) !== null && _a !== void 0 ? _a : MCP_VERSION) >= MCP_VERSION ? `, { versionNegotiation: { mode: "auto" } }` : "";\n return [\n `import { Client${http ? ", StreamableHTTPClientTransport" : ""} } from "@modelcontextprotocol/client";`,\n ...(http ? [] : [`import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";`]),\n "",\n `const client = new Client({ name: "your-agent", version: "1.0.0" }${negotiate});`,\n "await client.connect(",\n ...transport,\n ");",\n "const { tools } = await client.listTools();",\n ];\n }\n case "resources/read":\n return [`const { contents } = await client.readResource({ uri: ${jsString(scene.path)} });`];\n case "prompts/get":\n return ["const { messages } = await client.getPrompt({", ` name: ${jsString(scene.path)},`, ...indented(" ", wrapLines("arguments: ", pretty((_b = scene.request) !== null && _b !== void 0 ? _b : {}, "json", 2), ",")), "});"];\n default:\n return ["const result = await client.callTool({", ` name: ${jsString(scene.path)},`, ...indented(" ", wrapLines("arguments: ", pretty((_c = scene.request) !== null && _c !== void 0 ? _c : {}, "json", 2), ",")), "});"];\n }\n}\nfunction mcpPython(sb, scene, http, auth) {\n var _a, _b;\n switch (scene.method) {\n case "tools/list": {\n if (http && auth) {\n return [\n "import httpx2",\n "from mcp import Client",\n "from mcp.client.streamable_http import streamable_http_client",\n "",\n "http = httpx2.AsyncClient(auth=oauth) # an OAuthClientProvider",\n `async with Client(streamable_http_client(${jsString(sb.api.baseUrl)}, http_client=http)) as client:`,\n " result = await client.list_tools()",\n ];\n }\n if (http)\n return ["from mcp import Client", "", `async with Client(${jsString(sb.api.baseUrl)}) as client:`, " result = await client.list_tools()"];\n const [command, ...args] = sb.api.baseUrl.split(" ");\n return [\n "from mcp import Client, StdioServerParameters",\n "",\n `server = StdioServerParameters(command=${jsString(command)}, args=${list(args)})`,\n "async with Client(server) as client:",\n " result = await client.list_tools()",\n ];\n }\n case "resources/read":\n return [`result = await client.read_resource(${jsString(scene.path)})`];\n case "prompts/get":\n return ["result = await client.get_prompt(", ` ${jsString(scene.path)},`, ...indented(" ", wrapLines("", pretty((_a = scene.request) !== null && _a !== void 0 ? _a : {}, "python", 4), ",")), ")"];\n default:\n return ["result = await client.call_tool(", ` ${jsString(scene.path)},`, ...indented(" ", wrapLines("", pretty((_b = scene.request) !== null && _b !== void 0 ? _b : {}, "python", 4), ",")), ")"];\n }\n}\nfunction list(items) {\n return `[${items.map(jsString).join(", ")}]`;\n}\nfunction indented(indent, lines) {\n return lines.map((line) => `${indent}${line}`);\n}\nfunction wrapLines(head, lines, tail) {\n if (lines.length === 1)\n return [`${head}${lines[0]}${tail}`];\n return [`${head}${lines[0]}`, ...lines.slice(1, -1), `${lines.at(-1)}${tail}`];\n}\nfunction pretty(value, as, indent) {\n var _a;\n const text = (_a = JSON.stringify(value, null, indent)) !== null && _a !== void 0 ? _a : "null";\n if (as === "json")\n return text.split("\\n");\n return text.split("\\n").map((line) => line.replace(/("(?:[^"\\\\]|\\\\.)*")|\\b(true|false|null)\\b/g, (_, str, word) => str !== null && str !== void 0 ? str : { true: "True", false: "False", null: "None" }[word]));\n}\n\n}, {"../oas/examples":"lib/oas/examples","../storyboard/timing":"lib/storyboard/timing"}],\n"lib/oas/examples": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.PLACEHOLDER_UUID = exports.BINARY_PLACEHOLDER = void 0;\nexports.mediaKind = mediaKind;\nexports.isTextKind = isTextKind;\nexports.exampleForMedia = exampleForMedia;\nexports.toXml = toXml;\nexports.exampleForParameter = exampleForParameter;\nexports.exampleFromSchema = exampleFromSchema;\nexports.conform = conform;\nexports.placeholder = placeholder;\nexports.isPlaceholder = isPlaceholder;\nexports.patternExample = patternExample;\nexports.isIdName = isIdName;\nexports.idLike = idLike;\nexports.uuidLike = uuidLike;\nexports.singular = singular;\nconst fit_1 = require("./fit");\nexports.BINARY_PLACEHOLDER = "<binary data>";\nconst BINARY_MEDIA = /octet-stream|^(image|audio|video|font)\\/|application\\/(pdf|zip|gzip|x-tar)/i;\nfunction mediaKind(contentType) {\n const type = contentType.toLowerCase().split(";")[0].trim();\n if (/^application\\/(x-)?(ndjson|jsonl|jsonlines|json-lines)$|json-seq$/.test(type))\n return "sequence";\n if (/json/.test(type))\n return "json";\n if (type === "application/x-www-form-urlencoded")\n return "form";\n if (type.startsWith("multipart/"))\n return "multipart";\n if (/[/+]xml$/.test(type))\n return "xml";\n if (type === "text/event-stream")\n return "events";\n if (BINARY_MEDIA.test(type))\n return "binary";\n if (type.startsWith("text/") || /^application\\/(x-)?(yaml|csv|graphql|javascript|sql)$/.test(type))\n return "text";\n return "json";\n}\nfunction isTextKind(kind) {\n return kind === "xml" || kind === "sequence" || kind === "events" || kind === "text";\n}\nfunction exampleForMedia(media, mode = "response", contentType = "", subject) {\n if (!media)\n return { value: undefined, generated: false };\n const kind = mediaKind(contentType);\n const given = documentedExample(media, kind);\n if (given !== undefined && !isTextKind(kind) && media.schema && otherShape(given, media.schema)) {\n return { value: conform(exampleFromSchema(media.schema, "", 0, mode, undefined, subject), media.schema, mode, "", 0, undefined, subject), generated: true };\n }\n if (given !== undefined) {\n if (!isTextKind(kind) && kind !== "binary" && media.schema) {\n const fixed = conform(given, media.schema, mode, "", 0, undefined, subject);\n return { value: fixed, generated: fixed !== given };\n }\n return { value: serialize(given, kind, media, contentType), generated: false };\n }\n if (BINARY_MEDIA.test(contentType) && (!media.schema || media.schema.type === "string" || media.schema.format === "binary")) {\n return { value: exports.BINARY_PLACEHOLDER, generated: true };\n }\n if (isTextKind(kind) && (media.schema || media.itemSchema))\n return { value: textFromSchema(media, kind, mode, contentType), generated: true };\n if (media.schema)\n return { value: conform(exampleFromSchema(media.schema, "", 0, mode, undefined, subject), media.schema, mode, "", 0, undefined, subject), generated: true };\n return { value: undefined, generated: false };\n}\nfunction otherShape(example, schema) {\n if (!isRecord(example) || !Object.keys(example).length)\n return false;\n const names = new Set();\n const patterns = [];\n let open = false;\n const collect = (s, depth) => {\n var _a, _b, _c, _d, _e;\n if (!s || typeof s !== "object" || depth > 6)\n return;\n const target = (0, fit_1.circularTarget)(s);\n if (target)\n return collect(target, depth + 1);\n for (const key of Object.keys((_a = s.properties) !== null && _a !== void 0 ? _a : {}))\n names.add(key);\n patterns.push(...Object.keys((_b = s.patternProperties) !== null && _b !== void 0 ? _b : {}));\n if (isRecord(s.additionalProperties))\n open = true;\n for (const part of [...((_c = s.allOf) !== null && _c !== void 0 ? _c : []), ...((_d = s.oneOf) !== null && _d !== void 0 ? _d : []), ...((_e = s.anyOf) !== null && _e !== void 0 ? _e : [])])\n collect(part, depth + 1);\n };\n collect(schema, 0);\n if (!names.size || open)\n return false;\n return !Object.keys(example).some((key) => names.has(key) || patterns.some((pattern) => (0, fit_1.matchesPattern)(pattern, key)));\n}\nfunction documentedExample(media, kind) {\n var _a;\n if (media.example !== undefined)\n return media.example;\n for (const example of Object.values((_a = media.examples) !== null && _a !== void 0 ? _a : {})) {\n const value = exampleValue(example, isTextKind(kind));\n if (value !== undefined)\n return kind === "json" && (example === null || example === void 0 ? void 0 : example.dataValue) === undefined && (example === null || example === void 0 ? void 0 : example.value) === undefined ? parseJsonText(value) : value;\n }\n return undefined;\n}\nfunction exampleValue(example, text) {\n if (!example || typeof example !== "object")\n return undefined;\n const serialized = typeof example.serializedValue === "string" ? example.serializedValue : undefined;\n if (text && serialized !== undefined)\n return serialized;\n if (example.dataValue !== undefined)\n return example.dataValue;\n return example.value !== undefined ? example.value : serialized;\n}\nfunction parseJsonText(value) {\n if (typeof value !== "string")\n return value;\n try {\n return JSON.parse(value);\n }\n catch {\n return value;\n }\n}\nfunction serialize(value, kind, media, contentType) {\n if (!isTextKind(kind) || typeof value === "string")\n return value;\n switch (kind) {\n case "xml":\n return toXml(value, media.schema);\n case "sequence":\n return (Array.isArray(value) ? value : [value]).map((item) => JSON.stringify(item)).join("\\n");\n case "events":\n return (Array.isArray(value) ? value : [value]).map((event) => toEvent(event, media.itemSchema)).join("\\n\\n");\n default:\n return toText(value, contentType);\n }\n}\nfunction textFromSchema(media, kind, mode, contentType) {\n var _a, _b;\n const schema = (_a = media.schema) !== null && _a !== void 0 ? _a : {};\n const made = (s) => conform(exampleFromSchema(s, "", 0, mode), s, mode);\n if (kind === "xml")\n return toXml(made(schema), schema);\n if (kind === "sequence" || kind === "events") {\n const item = (_b = media.itemSchema) !== null && _b !== void 0 ? _b : (schema.items && (schema.type === "array" || Array.isArray(schema.type)) ? schema.items : schema);\n const value = made(item);\n return kind === "sequence" ? JSON.stringify(value) : toEvent(value, item);\n }\n return toText(made(schema), contentType);\n}\nfunction toEvent(value, schema) {\n var _a, _b, _c;\n const fields = isRecord(value) && "data" in value ? value : { data: value };\n const lines = [];\n for (const key of ["event", "id", "retry"])\n if (fields[key] !== undefined && fields[key] !== null)\n lines.push(`${key}: ${String(fields[key])}`);\n let data = fields.data;\n const dataSchema = (_a = schema === null || schema === void 0 ? void 0 : schema.properties) === null || _a === void 0 ? void 0 : _a.data;\n if (typeof data === "string" && (dataSchema === null || dataSchema === void 0 ? void 0 : dataSchema.contentSchema) && /json/i.test((_b = dataSchema.contentMediaType) !== null && _b !== void 0 ? _b : "json"))\n data = exampleFromSchema(dataSchema.contentSchema, "data");\n for (const line of (typeof data === "string" ? data : (_c = JSON.stringify(data)) !== null && _c !== void 0 ? _c : "").split("\\n"))\n lines.push(`data: ${line}`);\n return lines.join("\\n");\n}\nfunction toText(value, contentType) {\n if (typeof value === "string")\n return value;\n if (/csv/i.test(contentType) && Array.isArray(value) && value.every(isRecord)) {\n const columns = [...new Set(value.flatMap((row) => Object.keys(row)))];\n const cell = (v) => (/[",\\n]/.test(String(v !== null && v !== void 0 ? v : "")) ? `"${String(v).replace(/"/g, \'""\')}"` : String(v !== null && v !== void 0 ? v : ""));\n return [columns.join(","), ...value.map((row) => columns.map((c) => cell(row[c])).join(","))].join("\\n");\n }\n return typeof value === "object" && value !== null ? JSON.stringify(value, null, 2) : String(value);\n}\nfunction toXml(value, schema, name) {\n var _a, _b, _c, _d, _e, _f, _g;\n const lines = [];\n const rootName = (_d = (_c = (_b = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : name) !== null && _c !== void 0 ? _c : schema === null || schema === void 0 ? void 0 : schema.title) !== null && _d !== void 0 ? _d : (Array.isArray(value) ? "items" : "data");\n if (Array.isArray(value)) {\n const items = schema === null || schema === void 0 ? void 0 : schema.items;\n const itemName = (_g = (_f = (_e = items === null || items === void 0 ? void 0 : items.xml) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : items === null || items === void 0 ? void 0 : items.title) !== null && _g !== void 0 ? _g : singular(rootName);\n lines.push(`<${xmlName(rootName, schema)}${namespaceAttr(schema)}>`);\n for (const item of value)\n writeXml(lines, itemName, item, items, 1);\n lines.push(`</${xmlName(rootName, schema)}>`);\n }\n else {\n writeXml(lines, rootName, value, schema, 0, true);\n }\n return lines.join("\\n");\n}\nfunction writeXml(lines, name, value, schema, depth, root = false) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j;\n const pad = " ".repeat(depth);\n const xml = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) !== null && _a !== void 0 ? _a : {};\n const qname = xmlName((_b = xml.name) !== null && _b !== void 0 ? _b : name, schema);\n if (Array.isArray(value)) {\n const items = schema === null || schema === void 0 ? void 0 : schema.items;\n const itemName = (_d = (_c = items === null || items === void 0 ? void 0 : items.xml) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : name;\n if (xml.nodeType === "element" || xml.wrapped === true) {\n lines.push(`${pad}<${qname}${namespaceAttr(schema)}>`);\n for (const item of value)\n writeXml(lines, itemName, item, items, depth + 1);\n lines.push(`${pad}</${qname}>`);\n }\n else {\n for (const item of value)\n writeXml(lines, itemName, item, items, depth);\n }\n return;\n }\n if (value === null || value === undefined) {\n lines.push(`${pad}<${qname} xsi:nil="true"/>`);\n return;\n }\n if (!isRecord(value)) {\n lines.push(`${pad}<${qname}${root ? namespaceAttr(schema) : ""}>${escapeXml(String(value))}</${qname}>`);\n return;\n }\n const properties = propertiesOf(schema);\n const attributes = [];\n const children = [];\n let text;\n for (const [key, child] of Object.entries(value)) {\n const prop = properties[key];\n const nodeType = (_f = (_e = prop === null || prop === void 0 ? void 0 : prop.xml) === null || _e === void 0 ? void 0 : _e.nodeType) !== null && _f !== void 0 ? _f : (((_g = prop === null || prop === void 0 ? void 0 : prop.xml) === null || _g === void 0 ? void 0 : _g.attribute) ? "attribute" : undefined);\n if (nodeType === "attribute") {\n if (child !== null && child !== undefined)\n attributes.push(` ${xmlName((_j = (_h = prop === null || prop === void 0 ? void 0 : prop.xml) === null || _h === void 0 ? void 0 : _h.name) !== null && _j !== void 0 ? _j : key, prop)}="${escapeXml(String(child), true)}"`);\n }\n else if (nodeType === "text" || nodeType === "cdata") {\n text = nodeType === "cdata" ? `<![CDATA[${String(child)}]]>` : escapeXml(String(child));\n }\n else {\n children.push([key, child, prop]);\n }\n }\n const open = `${pad}<${qname}${namespaceAttr(schema)}${attributes.join("")}`;\n if (!children.length) {\n lines.push(text === undefined ? `${open}/>` : `${open}>${text}</${qname}>`);\n return;\n }\n lines.push(`${open}>${text !== null && text !== void 0 ? text : ""}`);\n for (const [key, child, prop] of children)\n writeXml(lines, key, child, prop, depth + 1);\n lines.push(`${pad}</${qname}>`);\n}\nfunction propertiesOf(schema, depth = 0) {\n var _a, _b;\n if (!schema || depth > 4)\n return {};\n const out = {};\n for (const part of (_a = schema.allOf) !== null && _a !== void 0 ? _a : [])\n Object.assign(out, propertiesOf(part, depth + 1));\n return Object.assign(out, (_b = schema.properties) !== null && _b !== void 0 ? _b : {});\n}\nfunction xmlName(name, schema) {\n var _a;\n let clean = name.replace(/[^\\w.:-]/g, "_");\n if (!/^[A-Za-z_]/.test(clean))\n clean = `_${clean}`;\n const prefix = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _a === void 0 ? void 0 : _a.prefix;\n return prefix && !clean.includes(":") ? `${prefix}:${clean}` : clean;\n}\nfunction namespaceAttr(schema) {\n var _a, _b;\n const ns = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _a === void 0 ? void 0 : _a.namespace;\n if (!ns)\n return "";\n return ` xmlns${((_b = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _b === void 0 ? void 0 : _b.prefix) ? `:${schema.xml.prefix}` : ""}="${escapeXml(ns, true)}"`;\n}\nfunction escapeXml(text, attribute = false) {\n if (isPlaceholder(text))\n return `{${text.slice(1, -1)}}`;\n const out = text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");\n return attribute ? out.replace(/"/g, "&quot;") : out;\n}\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction exampleForParameter(param) {\n var _a;\n const typed = (value) => (value === undefined || !param.schema ? value : asType(value, param.schema));\n const given = typed(param.example);\n if (given !== undefined)\n return given;\n for (const example of Object.values((_a = param.examples) !== null && _a !== void 0 ? _a : {})) {\n const value = typed(exampleValue(example, false));\n if (value !== undefined)\n return value;\n }\n const content = param.content && Object.entries(param.content)[0];\n if (content)\n return exampleForMedia(content[1], "request", content[0]).value;\n if (param.schema)\n return exampleFromSchema(param.schema, param.name);\n return idLike(param.name);\n}\nconst MAX_DEPTH = 4;\nconst HARD_DEPTH = 12;\nconst MAX_PROPERTIES = 12;\nconst NODE_BUDGET = 250;\nconst MAX_LIST = 20;\nconst MAX_TRIES = 6;\nfunction exampleFromSchema(schema, name = "", depth = 0, mode = "response", budget = { left: NODE_BUDGET }, owner) {\n var _a;\n if (!schema || typeof schema !== "object")\n return null;\n budget.left--;\n const target = (0, fit_1.circularTarget)(schema);\n if (target)\n return depth >= HARD_DEPTH ? {} : exampleFromSchema(target, name, Math.max(depth + 1, MAX_DEPTH), mode, budget, owner);\n if (schema["x-circular"])\n return depth > 1 ? null : { id: idLike((_a = schema.title) !== null && _a !== void 0 ? _a : name) };\n for (const example of [schema.example, ...(Array.isArray(schema.examples) ? schema.examples.slice(0, 1) : [])]) {\n const value = example === undefined ? undefined : asType(example, schema);\n if (value !== undefined)\n return fitted(value, schema, name, depth, mode, budget, owner);\n }\n if (schema.const !== undefined)\n return schema.const;\n const fallback = schema.default === undefined ? undefined : asType(schema.default, schema);\n if (fallback !== undefined)\n return fitted(fallback, schema, name, depth, mode, budget, owner);\n return fromSchema(schema, name, depth, mode, budget, owner);\n}\nfunction fromSchema(schema, name, depth, mode, budget, owner) {\n var _a, _b;\n if (Array.isArray(schema.enum) && schema.enum.length)\n return enumValue(schema.enum, schema.description);\n if ((_a = schema.allOf) === null || _a === void 0 ? void 0 : _a.length)\n return fromParts(schema, name, depth, mode, budget, owner);\n const variants = ((_b = schema.oneOf) === null || _b === void 0 ? void 0 : _b.length) ? schema.oneOf : schema.anyOf;\n if (variants === null || variants === void 0 ? void 0 : variants.length)\n return fromVariant(schema, variants, name, depth, mode, budget, owner);\n const type = Array.isArray(schema.type) ? schema.type.find((t) => t !== "null") : schema.type;\n const inferred = type !== null && type !== void 0 ? type : (schema.properties ? "object" : schema.items || schema.prefixItems ? "array" : undefined);\n switch (inferred) {\n case "object":\n return objectFor(schema, depth, mode, budget, owner);\n case "array":\n return listFor(schema, name, depth, mode, budget, owner);\n case "integer":\n case "number":\n return numberFor(schema, name, inferred === "integer");\n case "boolean":\n return booleanFor(name);\n case "string":\n return stringFor(schema, name, owner);\n default:\n return null;\n }\n}\nfunction objectFor(schema, depth, mode, budget, owner) {\n var _a, _b;\n const out = {};\n if (depth >= HARD_DEPTH)\n return out;\n const required = new Set(Array.isArray(schema.required) ? schema.required : []);\n let props = Object.entries((_a = schema.properties) !== null && _a !== void 0 ? _a : {}).filter(([, prop]) => !(mode === "request" ? prop === null || prop === void 0 ? void 0 : prop.readOnly : prop === null || prop === void 0 ? void 0 : prop.writeOnly));\n props = props.filter(([key, prop]) => required.has(key) || (prop === null || prop === void 0 ? void 0 : prop.deprecated) !== true);\n const answer = mode === "response" && !budget.full;\n if (answer)\n props = props.filter(([key, prop]) => required.has(key) || ((ID_FIELDS.has(key) || saysSomething(prop)) && !brokenExample(prop, mode)));\n if (depth >= MAX_DEPTH)\n props = props.filter(([key]) => required.has(key));\n props.sort(([a], [b]) => Number(required.has(b)) - Number(required.has(a)));\n if (mode === "request")\n props = telling(props, required);\n for (const [key, prop] of props) {\n if (!required.has(key) && (budget.left <= 0 || Object.keys(out).length >= MAX_PROPERTIES))\n continue;\n if (!required.has(key) && recursive(prop))\n continue;\n const value = fieldValue(prop, key, depth + 1, mode, budget, (_b = schema.title) !== null && _b !== void 0 ? _b : owner);\n if (!required.has(key) && (value === null || (mode === "request" && isEmpty(value))))\n continue;\n out[key] = value;\n }\n return out;\n}\nfunction fieldValue(prop, key, depth, mode, budget, owner) {\n if (mode === "response" && !budget.full && allowsNull(prop) && (!givesValue(prop) || brokenExample(prop, mode)))\n return null;\n return exampleFromSchema(prop, key, depth, mode, budget, owner);\n}\nfunction brokenExample(prop, mode) {\n if (!prop || typeof prop !== "object" || prop.example === undefined || prop.example === null)\n return false;\n if ((0, fit_1.fits)(prop.example, prop, mode))\n return false;\n const typed = asType(prop.example, prop);\n if (typed === undefined)\n return true;\n const plain = (v) => v === null || typeof v !== "object";\n return (plain(typed) || (Array.isArray(typed) && typed.every(plain))) && !(0, fit_1.fits)(typed, prop, mode);\n}\nfunction recursive(schema) {\n const own = (s) => isRecord(s) && s["x-circular"] !== undefined;\n return own(schema) || (isRecord(schema) && own(schema.items));\n}\nconst ID_FIELDS = new Set(["id", "sid", "gid", "uuid"]);\nfunction givesValue(schema, depth = 0) {\n var _a, _b, _c;\n if (!schema || typeof schema !== "object" || depth > 4)\n return false;\n if (schema.example !== undefined || (Array.isArray(schema.examples) && schema.examples.length > 0) || schema.default !== undefined || schema.const !== undefined)\n return true;\n if (Array.isArray(schema.enum) && schema.enum.filter((v) => v !== null).length === 1 && !allowsNull(schema))\n return true;\n const target = (0, fit_1.circularTarget)(schema);\n if (target)\n return givesValue(target, depth + 1);\n const parts = [...((_a = schema.allOf) !== null && _a !== void 0 ? _a : []), ...((_b = schema.oneOf) !== null && _b !== void 0 ? _b : []), ...((_c = schema.anyOf) !== null && _c !== void 0 ? _c : [])];\n return parts.some((part) => part && typeof part === "object" && part.type !== "null" && givesValue(part, depth + 1));\n}\nconst saying = new WeakMap();\nfunction saysSomething(schema, depth = 0) {\n var _a, _b, _c, _d, _e, _f;\n if (!schema || typeof schema !== "object" || depth > 1)\n return false;\n const found = (_a = saying.get(schema)) !== null && _a !== void 0 ? _a : [];\n if (found[depth] !== undefined)\n return found[depth];\n found[depth] = false;\n saying.set(schema, found);\n const target = (0, fit_1.circularTarget)(schema);\n const parts = [...((_b = schema.allOf) !== null && _b !== void 0 ? _b : []), ...((_c = schema.oneOf) !== null && _c !== void 0 ? _c : []), ...((_d = schema.anyOf) !== null && _d !== void 0 ? _d : []), ...(target ? [target] : [])];\n const inside = [...Object.values((_e = schema.properties) !== null && _e !== void 0 ? _e : {}), ...(schema.items && typeof schema.items === "object" ? [schema.items] : []), ...((_f = schema.prefixItems) !== null && _f !== void 0 ? _f : [])];\n const usable = (part) => part && typeof part === "object" && part.type !== "null";\n const own = depth === 0 ? givesValue(schema) : schema.example !== undefined || (Array.isArray(schema.examples) && schema.examples.length > 0);\n const says = own || parts.some((part) => usable(part) && saysSomething(part, depth)) || inside.some((part) => usable(part) && saysSomething(part, depth + 1));\n found[depth] = says;\n return says;\n}\nfunction allowsNull(schema) {\n var _a, _b;\n if (!schema || typeof schema !== "object")\n return false;\n if (schema.nullable === true || (Array.isArray(schema.type) && schema.type.includes("null")) || schema.type === "null")\n return true;\n if (Array.isArray(schema.enum) && schema.enum.includes(null))\n return true;\n const variants = [...((_a = schema.oneOf) !== null && _a !== void 0 ? _a : []), ...((_b = schema.anyOf) !== null && _b !== void 0 ? _b : [])];\n const isNull = (v) => v.type === "null" || (Array.isArray(v.type) && v.type.length === 1 && v.type[0] === "null") || (Array.isArray(v.enum) && v.enum.length === 1 && v.enum[0] === null);\n return variants.some((v) => v && typeof v === "object" && isNull(v));\n}\nfunction listFor(schema, name, depth, mode, budget, owner) {\n var _a;\n const least = Math.min(Math.max(0, typeof schema.minItems === "number" ? schema.minItems : 0), MAX_LIST);\n const most = typeof schema.maxItems === "number" ? Math.max(0, schema.maxItems) : Infinity;\n if (most === 0)\n return [];\n if ((depth >= MAX_DEPTH || budget.left <= 0) && least === 0)\n return [];\n const itemName = singular(name);\n const itemOwner = itemName && !CONTAINERS.test(itemName) ? itemName : owner;\n const prefix = ((_a = schema.prefixItems) !== null && _a !== void 0 ? _a : []).slice(0, most);\n const out = prefix.map((item) => exampleFromSchema(item, itemName, depth + 1, mode, budget, itemOwner));\n const items = isRecord(schema.items) ? schema.items : undefined;\n const answer = mode === "response" && !budget.full;\n const shows = !answer || depth === 0 || (depth === 1 && CONTAINERS.test(name)) || saysSomething(items);\n const want = Math.min(most, Math.max(least, prefix.length ? prefix.length : items && shows ? 1 : 0));\n while (out.length < want) {\n if (!items) {\n out.push(null);\n continue;\n }\n const value = exampleFromSchema(items, itemName, depth + 1, mode, budget, itemOwner);\n if (answer && out.length >= least && isRecord(value) && !Object.keys(value).length)\n break;\n out.push(out.length > prefix.length ? distinct(value, out, items, mode) : value);\n }\n return out;\n}\nconst CONTAINERS = /^(data|items?|results?|list|entr(y|ie)|records?|values?|objects?|nodes?|edges?|elements?|rows?|hits?|match(e)?|contents?|resources?)$/i;\nfunction distinct(value, taken, schema, mode) {\n var _a, _b, _c, _d;\n const n = taken.length + 1;\n const free = (candidate) => !taken.some((t) => (0, fit_1.equal)(t, candidate)) && (0, fit_1.fits)(candidate, schema, mode);\n if (!taken.some((t) => (0, fit_1.equal)(t, value)))\n return value;\n const candidates = [];\n if (Array.isArray(schema.enum))\n candidates.push(...schema.enum);\n if (typeof value === "string" && isPlaceholder(value))\n candidates.push(`${value.slice(0, -1)}_${n}>`);\n if (typeof value === "string") {\n const at = value.indexOf("@");\n if (at > 0)\n candidates.push(`${value.slice(0, at)}+${n}${value.slice(at)}`);\n candidates.push(`${value}_${n}`, `${value}${n}`, `${n}${value.slice(1)}`);\n }\n else if (typeof value === "number")\n candidates.push(value + n - 1, value + (n - 1) * 10, value - (n - 1));\n else if (typeof value === "boolean")\n candidates.push(!value);\n else if (isRecord(value)) {\n const key = (_a = Object.keys(value).find((k) => k === "id" || isIdName(k))) !== null && _a !== void 0 ? _a : Object.keys(value).find((k) => typeof value[k] === "string" || typeof value[k] === "number");\n if (key !== undefined) {\n const inner = (_c = (_b = schema.properties) === null || _b === void 0 ? void 0 : _b[key]) !== null && _c !== void 0 ? _c : {};\n const varied = distinct(value[key], taken.flatMap((t) => (isRecord(t) ? [t[key]] : [])), inner, mode);\n candidates.push({ ...value, [key]: varied });\n }\n }\n return (_d = candidates.find(free)) !== null && _d !== void 0 ? _d : value;\n}\nconst ON_FLAGS = /^(is_?|has_?|can_?)?(enabled|active|verified|valid|available|visible|confirmed|success|successful|ok|allowed|approved|ready|supported)$/i;\nfunction booleanFor(name) {\n return ON_FLAGS.test(name.replace(/-/g, "_"));\n}\nfunction fitted(value, schema, name, depth, mode, budget, owner) {\n return (0, fit_1.fits)(value, schema, mode) ? value : conform(value, schema, mode, name, depth, budget, owner);\n}\nfunction conform(value, schema, mode = "response", name = "", depth = 0, budget = { left: NODE_BUDGET }, owner) {\n var _a, _b, _c;\n if (!schema || typeof schema !== "object" || depth > HARD_DEPTH || (0, fit_1.fits)(value, schema, mode))\n return value;\n const target = (0, fit_1.circularTarget)(schema);\n if (target)\n return conform(value, target, mode, name, depth + 1, budget, owner);\n const fresh = () => fromSchema({ ...schema, example: undefined, examples: undefined, default: undefined }, name, depth, mode, budget, owner);\n const variants = ((_a = schema.oneOf) === null || _a === void 0 ? void 0 : _a.length) ? schema.oneOf : ((_b = schema.anyOf) === null || _b === void 0 ? void 0 : _b.length) ? schema.anyOf : undefined;\n if (variants) {\n const base = { ...schema, oneOf: undefined, anyOf: undefined };\n const ranked = variants\n .filter((v) => isRecord(v))\n .map((v) => ({ v, misses: (0, fit_1.misfits)(value, { allOf: [base, v] }, mode, 40).length }))\n .sort((a, b) => a.misses - b.misses);\n let closest;\n for (const { v } of ranked.slice(0, MAX_TRIES)) {\n const fixed = conform(value, { allOf: [base, v] }, mode, name, depth + 1, budget, owner);\n if ((0, fit_1.fits)(fixed, schema, mode))\n return fixed;\n closest !== null && closest !== void 0 ? closest : (closest = fixed);\n }\n const made = fresh();\n return (0, fit_1.fits)(made, schema, mode) || closest === undefined ? made : closest;\n }\n if ((_c = schema.allOf) === null || _c === void 0 ? void 0 : _c.length) {\n let fixed = value;\n const required = requiredIn(schema);\n for (const part of [...schema.allOf, { ...schema, allOf: undefined }]) {\n if (isRecord(part))\n fixed = conform(fixed, required.length ? { ...part, required: [...new Set([...(Array.isArray(part.required) ? part.required : []), ...required])] } : part, mode, name, depth + 1, budget, owner);\n }\n if ((0, fit_1.fits)(fixed, schema, mode))\n return fixed;\n const made = fresh();\n return (0, fit_1.fits)(made, schema, mode) ? made : fixed;\n }\n return conformOne(value, schema, mode, name, depth, budget, owner);\n}\nfunction conformOne(value, schema, mode, name, depth, budget, owner) {\n var _a, _b, _c, _d, _e;\n if ((0, fit_1.fits)(value, { ...schema, allOf: undefined, oneOf: undefined, anyOf: undefined, not: undefined }, mode))\n return value;\n const fresh = () => fromSchema({ ...schema, example: undefined, examples: undefined, default: undefined }, name, depth, mode, budget, owner);\n const types = typesOf(schema);\n if (types.length && !(value === null && schema.nullable) && !ofType(value, schema)) {\n const typed = asType(value, schema);\n return typed !== undefined && (0, fit_1.fits)(typed, schema, mode) ? typed : fresh();\n }\n if (schema.const !== undefined && !(0, fit_1.equal)(value, schema.const))\n return schema.const;\n if (Array.isArray(schema.enum) && schema.enum.length && !schema.enum.some((e) => (0, fit_1.equal)(e, value)))\n return enumValue(schema.enum, schema.description);\n if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null)\n return fresh();\n if (Array.isArray(value)) {\n const legacy = Array.isArray(schema.items) ? schema.items : undefined;\n const prefix = (_b = (_a = schema.prefixItems) !== null && _a !== void 0 ? _a : legacy) !== null && _b !== void 0 ? _b : [];\n const items = !legacy && isRecord(schema.items) ? schema.items : undefined;\n let out = value.map((item, i) => conform(item, i < prefix.length ? prefix[i] : items, mode, singular(name), depth + 1, budget, singular(name) || owner));\n if (schema.uniqueItems === true)\n out = out.filter((item, i) => out.findIndex((other) => (0, fit_1.equal)(other, item)) === i);\n if (typeof schema.maxItems === "number")\n out = out.slice(0, Math.max(0, schema.maxItems));\n const least = Math.min(typeof schema.minItems === "number" ? schema.minItems : 0, MAX_LIST);\n while (out.length < least) {\n const index = out.length;\n const sub = index < prefix.length ? prefix[index] : items;\n const made = sub ? exampleFromSchema(sub, singular(name), depth + 1, mode, budget, singular(name) || owner) : null;\n out.push(sub ? distinct(made, out, sub, mode) : made);\n }\n return out;\n }\n if (isRecord(value)) {\n const props = (isRecord(schema.properties) ? schema.properties : {});\n const patterns = isRecord(schema.patternProperties) ? Object.entries(schema.patternProperties) : [];\n const extra = schema.additionalProperties;\n const title = (_c = schema.title) !== null && _c !== void 0 ? _c : owner;\n const out = {};\n for (const [key, item] of Object.entries(value)) {\n const prop = Object.prototype.hasOwnProperty.call(props, key) ? props[key] : undefined;\n const matched = (_d = patterns.find(([pattern]) => (0, fit_1.matchesPattern)(pattern, key))) === null || _d === void 0 ? void 0 : _d[1];\n if (!prop && !matched && extra === false)\n continue;\n const sub = (_e = prop !== null && prop !== void 0 ? prop : matched) !== null && _e !== void 0 ? _e : (isRecord(extra) ? extra : undefined);\n const optional = !(Array.isArray(schema.required) && schema.required.includes(key));\n if (item === null && sub && !allowsNull(sub) && optional)\n continue;\n if (mode === "response" && !budget.full && optional && sub && item !== null && typeof item !== "object" && !(0, fit_1.fits)(item, sub, mode)) {\n const typed = asType(item, sub);\n if (typed === undefined || !(0, fit_1.fits)(typed, sub, mode))\n continue;\n }\n setField(out, key, sub ? conform(item, sub, mode, key, depth + 1, budget, title) : item);\n }\n for (const key of Array.isArray(schema.required) ? schema.required : []) {\n if (typeof key !== "string" || key in out)\n continue;\n const prop = props[key];\n if (prop && (mode === "request" ? prop.readOnly : prop.writeOnly))\n continue;\n const sub = prop !== null && prop !== void 0 ? prop : (isRecord(extra) ? extra : undefined);\n setField(out, key, sub ? fieldValue(sub, key, depth + 1, mode, budget, title) : null);\n }\n for (const [key, prop] of Object.entries(props)) {\n if (typeof schema.minProperties !== "number" || Object.keys(out).length >= schema.minProperties)\n break;\n if (!(key in out))\n setField(out, key, exampleFromSchema(prop, key, depth + 1, mode, budget, title));\n }\n return out;\n }\n return fresh();\n}\nfunction setField(out, key, value) {\n if (key === "__proto__")\n Object.defineProperty(out, key, { value, enumerable: true, writable: true, configurable: true });\n else\n out[key] = value;\n}\nfunction asType(value, schema) {\n const types = typesOf(schema);\n if (ofType(value, schema))\n return value;\n if (typeof value === "string" && (types.includes("object") || types.includes("array"))) {\n try {\n const parsed = JSON.parse(value);\n if (ofType(parsed, schema))\n return parsed;\n }\n catch {\n }\n }\n if (types.includes("string") && Array.isArray(value) && value.length && value.every((v) => typeof v === "string" || typeof v === "number"))\n return value.join(",");\n if (types.includes("object") && Array.isArray(value) && value.length === 1 && isRecord(value[0]))\n return value[0];\n if (typeof value === "string" && value.trim() && (types.includes("number") || types.includes("integer")) && ofType(Number(value), schema))\n return Number(value);\n if (typeof value === "string" && types.includes("boolean") && /^(true|false)$/.test(value))\n return value === "true";\n if (typeof value === "number" && types.includes("string") && Number.isFinite(value))\n return String(value);\n return undefined;\n}\nfunction typesOf(schema) {\n return (Array.isArray(schema.type) ? schema.type : [schema.type]).filter((t) => typeof t === "string");\n}\nfunction ofType(value, schema) {\n const types = typesOf(schema);\n if (!types.length || (value === null && schema.nullable))\n return true;\n return types.some((t) => (t === "integer" ? Number.isInteger(value) : t === "number" ? typeof value === "number" : t === "object" ? isRecord(value) : t === "array" ? Array.isArray(value) : t === "null" ? value === null : typeof value === t));\n}\nfunction sharedProperties(parts) {\n const all = new Map();\n const collect = (schema, title, depth) => {\n var _a, _b, _c;\n if (!schema || typeof schema !== "object" || depth > 4)\n return;\n for (const part of (_a = schema.allOf) !== null && _a !== void 0 ? _a : [])\n collect(part, title, depth + 1);\n for (const [key, def] of Object.entries((_b = schema.properties) !== null && _b !== void 0 ? _b : {})) {\n if (!def || typeof def !== "object")\n continue;\n const entry = (_c = all.get(key)) !== null && _c !== void 0 ? _c : { defs: [] };\n if (!entry.defs.includes(def))\n entry.defs.push(def);\n entry.title = title;\n all.set(key, entry);\n }\n };\n for (const part of parts)\n collect(part, part.title, 0);\n return new Map([...all].filter(([, entry]) => entry.defs.length > 1));\n}\nfunction requiredIn(schema, depth = 0) {\n var _a;\n if (!schema || typeof schema !== "object" || depth > 4)\n return [];\n const own = Array.isArray(schema.required) ? schema.required.filter((r) => typeof r === "string") : [];\n return [...new Set([...own, ...((_a = schema.allOf) !== null && _a !== void 0 ? _a : []).flatMap((part) => requiredIn(part, depth + 1))])];\n}\nfunction fromParts(schema, name, depth, mode, budget, owner) {\n var _a, _b, _c;\n const merged = {};\n const plain = [];\n const required = requiredIn(schema);\n const parts = [...((_a = schema.allOf) !== null && _a !== void 0 ? _a : []), ...(schema.properties ? [{ ...schema, allOf: undefined }] : [])].filter((part) => part && typeof part === "object");\n const again = { left: budget.left, full: budget.full };\n for (const part of parts) {\n const whole = { ...part, ...(schema.title ? { title: schema.title } : {}), ...(required.length ? { required: [...new Set([...(Array.isArray(part.required) ? part.required : []), ...required])] } : {}) };\n const value = exampleFromSchema(whole, name, depth, mode, budget, owner);\n if (isRecord(value))\n Object.assign(merged, value);\n else if (value !== null && value !== undefined)\n plain.push(value);\n }\n for (const [key, { defs, title }] of sharedProperties(parts)) {\n if (!(key in merged) || defs.every((def) => (0, fit_1.fits)(merged[key], def, mode)))\n continue;\n const value = exampleFromSchema({ allOf: defs }, key, depth + 1, mode, again, (_c = (_b = schema.title) !== null && _b !== void 0 ? _b : title) !== null && _c !== void 0 ? _c : owner);\n if (value !== null && value !== undefined)\n merged[key] = value;\n }\n if (plain.length && Object.keys(merged).length === 0) {\n const fitting = [...plain].reverse().find((value) => parts.every((part) => (0, fit_1.fits)(value, part, mode)));\n if (fitting !== undefined)\n return fitting;\n for (const variant of parts.flatMap((part) => { var _a, _b; return [...((_a = part.oneOf) !== null && _a !== void 0 ? _a : []), ...((_b = part.anyOf) !== null && _b !== void 0 ? _b : [])]; })) {\n if (!isRecord(variant) || variant.type === "null")\n continue;\n const value = exampleFromSchema(variant, name, depth, mode, again, owner);\n if (value !== null && value !== undefined && parts.every((part) => (0, fit_1.fits)(value, part, mode)))\n return value;\n }\n const items = parts.flatMap((part) => (part.items && typeof part.items === "object" ? [part.items] : []));\n if (items.length > 1 && plain.some(Array.isArray))\n return exampleFromSchema({ type: "array", items: { allOf: items } }, name, depth, mode, again, owner);\n return plain[0];\n }\n return merged;\n}\nconst ENDINGS = /^(cancel+ed|cancel+ing|failed|failure|errored|error|declined|rejected|expired|deleted|voided|void|refunded|disputed|revoked|suspended|blocked|disabled|inactive|abandoned|lost|unpaid|past_due|incomplete_expired)$/i;\nfunction enumValue(values, description) {\n var _a, _b;\n const said = values.filter((v) => v !== "" && v !== null);\n const mentioned = (v) => {\n if (typeof v !== "string" || !description)\n return Infinity;\n const at = description.search(new RegExp(`[\\`\'"]${v.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&")}[\\`\'"]`));\n return at < 0 ? Infinity : at;\n };\n const ordered = said.map((v, i) => ({ v, i, at: mentioned(v) })).sort((a, b) => a.at - b.at || a.i - b.i).map(({ v }) => v);\n return (_b = (_a = ordered.find((v) => typeof v !== "string" || !ENDINGS.test(v))) !== null && _a !== void 0 ? _a : ordered[0]) !== null && _b !== void 0 ? _b : values[0];\n}\nfunction fromVariant(schema, variants, name, depth, mode, budget, owner) {\n var _a;\n const usable = variants.filter((v) => v && typeof v === "object" && v.type !== "null" && Object.keys(v).some((k) => !/^(description|title|nullable)$/.test(k)));\n const first = (schema.properties && usable.find((v) => v.properties || v.type === "object")) || usable[0] || variants[0];\n const exclusive = Boolean((_a = schema.oneOf) === null || _a === void 0 ? void 0 : _a.length);\n let made;\n for (const variant of [first, ...usable.filter((v) => v !== first)].slice(0, MAX_TRIES)) {\n const value = fromOneVariant(schema, variants, variant, exclusive, name, depth, mode, budget, owner);\n if (made === undefined)\n made = value;\n if ((0, fit_1.fits)(value, schema, mode))\n return value;\n }\n if (mode === "response" && !budget.full) {\n const full = { left: budget.left, full: true };\n const value = fromVariant(schema, variants, name, depth, mode, full, owner);\n budget.left = full.left;\n if ((0, fit_1.fits)(value, schema, mode))\n return value;\n }\n return made;\n}\nfunction fromOneVariant(schema, variants, variant, exclusive, name, depth, mode, budget, owner) {\n var _a, _b, _c, _d, _e;\n if (variant && typeof variant === "object" && !describesValue(variant)) {\n const required = [...new Set([...(Array.isArray(schema.required) ? schema.required : []), ...(Array.isArray(variant.required) ? variant.required : [])])];\n const others = exclusive ? new Set(variants.filter((v) => v !== variant && isRecord(v) && Array.isArray(v.required)).flatMap((v) => v.required).filter((k) => !required.includes(k))) : new Set();\n const properties = schema.properties && others.size ? Object.fromEntries(Object.entries(schema.properties).filter(([key]) => !others.has(key))) : schema.properties;\n return exampleFromSchema({ ...schema, oneOf: undefined, anyOf: undefined, ...(properties ? { properties } : {}), ...(required.length ? { required } : {}) }, name, depth, mode, budget, owner);\n }\n const value = exampleFromSchema(variant, name, depth, mode, budget, owner);\n if (!value || typeof value !== "object" || Array.isArray(value))\n return value;\n const out = schema.properties ? { ...exampleFromSchema({ ...schema, oneOf: undefined, anyOf: undefined }, name, depth, mode, budget, owner), ...value } : { ...value };\n const discriminator = schema.discriminator;\n const property = discriminator === null || discriminator === void 0 ? void 0 : discriminator.propertyName;\n const mapping = discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping;\n if (property && isRecord(mapping) && !((_b = (_a = variant.properties) === null || _a === void 0 ? void 0 : _a[property]) === null || _b === void 0 ? void 0 : _b.enum) && ((_d = (_c = variant.properties) === null || _c === void 0 ? void 0 : _c[property]) === null || _d === void 0 ? void 0 : _d.const) === undefined) {\n const entries = Object.entries(mapping);\n const named = entries.find(([, target]) => variant.title && typeof target === "string" && target.split("/").pop() === variant.title);\n const entry = (_e = named !== null && named !== void 0 ? named : entries[variants.indexOf(variant)]) !== null && _e !== void 0 ? _e : entries[0];\n if (entry)\n out[property] = entry[0];\n }\n return out;\n}\nconst VALUE_KEYWORDS = ["type", "properties", "items", "prefixItems", "allOf", "oneOf", "anyOf", "enum", "const", "example", "examples", "default", "format", "pattern", "additionalProperties", "$ref", "x-circular"];\nfunction describesValue(schema) {\n return VALUE_KEYWORDS.some((key) => key in schema);\n}\nconst MAX_OPTIONAL = 3;\nconst TELLING_NAMES = /^(to|from|subject|text|html|body|content|message|title|name|email|description|amount|currency|quantity|customer|price|product|channel|phone|url|\\w+_url)$/i;\nfunction telling(props, required) {\n const must = props.filter(([key]) => required.has(key));\n const rank = ([key, prop]) => (TELLING_NAMES.test(key) || isIdName(key) ? 0 : 2) + (looksReal(key, prop) ? 0 : 1);\n const optional = props\n .filter(([key]) => !required.has(key))\n .map((entry, i) => ({ entry, i, rank: rank(entry) }))\n .sort((a, b) => a.rank - b.rank || a.i - b.i)\n .slice(0, must.length ? MAX_OPTIONAL : MAX_OPTIONAL + 1)\n .sort((a, b) => a.i - b.i);\n return [...must, ...optional.map((o) => o.entry)];\n}\nfunction looksReal(key, prop) {\n if (!prop || typeof prop !== "object")\n return false;\n if (prop.example !== undefined || prop.examples !== undefined || prop.default !== undefined || prop.enum || prop.const !== undefined)\n return true;\n const type = Array.isArray(prop.type) ? prop.type.find((t) => t !== "null") : prop.type;\n if ((type && type !== "string") || prop.format || prop.pattern)\n return true;\n return saysWhatItHolds(key, prop);\n}\nfunction isEmpty(value) {\n return value === undefined || (Array.isArray(value) && value.length === 0) || (isRecord(value) && Object.keys(value).length === 0);\n}\nconst WHOLE_NUMBER = /(^|[_-])(number|num|no|index|idx|page|position|pos|id|count|version|year|port|rank|level|step|line|row|column|col|size)$|[a-z0-9](Number|Num|Index|Page|Position|Id|Count|Version|Year|Port|Rank|Level|Step|Line|Row|Column|Size)$|^(number|num|index|page|position|id|count|version|year|port|rank|level|step|line|row|column|size|offset|depth)$/;\nfunction numberFor(schema, name, integer) {\n const lower = name.toLowerCase();\n const step = integer ? 1 : 0.5;\n let value;\n if (/(created|updated|timestamp|_at$|time)/.test(lower) || /[a-z0-9]At$/.test(name))\n value = 1767225600;\n else if (/(amount|price|total|cost|balance)/.test(lower))\n value = integer ? 2000 : 20.0;\n else if (/(quantity|count|qty)/.test(lower))\n value = 1;\n else if (/(limit|page_size|per_page)/.test(lower))\n value = 10;\n else if (/(retry|seconds|delay)/.test(lower))\n value = 30;\n else\n value = integer || WHOLE_NUMBER.test(name) ? 1 : 1.5;\n if (schema.minimum !== undefined && value < schema.minimum)\n value = schema.minimum;\n if (schema.maximum !== undefined && value > schema.maximum)\n value = schema.maximum;\n const exclusiveMin = typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum : schema.exclusiveMinimum === true ? schema.minimum : undefined;\n const exclusiveMax = typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum : schema.exclusiveMaximum === true ? schema.maximum : undefined;\n if (exclusiveMin !== undefined && value <= exclusiveMin)\n value = exclusiveMin + step;\n if (exclusiveMax !== undefined && value >= exclusiveMax)\n value = exclusiveMax - step;\n return value;\n}\nconst HOOKISH = /(webhook|callback|hook|notif)/i;\nfunction stringFor(schema, name, owner) {\n var _a, _b;\n switch (schema.format) {\n case "date-time":\n return "2026-01-01T12:00:00Z";\n case "date":\n return "2026-01-01";\n case "time":\n return "12:00:00Z";\n case "duration":\n return "PT1H";\n case "email":\n case "idn-email":\n return `${(name.replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[_.-]+|[_.-]+$/g, "") || "email").toLowerCase()}@example.com`;\n case "uri":\n case "url":\n case "iri":\n case "uri-reference":\n case "iri-reference":\n return HOOKISH.test(name) ? "https://example.com/webhooks" : "https://example.com";\n case "uri-template":\n return "https://example.com/{id}";\n case "hostname":\n case "idn-hostname":\n return "example.com";\n case "uuid":\n return name === "id" && owner ? uuidLike(owner) : isIdName(name) ? uuidLike(name) : exports.PLACEHOLDER_UUID;\n case "ipv4":\n return "203.0.113.10";\n case "ipv6":\n return "2001:db8::10";\n case "byte":\n return "aGVsbG8=";\n case "binary":\n return exports.BINARY_PLACEHOLDER;\n case "password":\n return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";\n case "regex":\n return "^[a-z]+$";\n case "json-pointer":\n return "/data";\n }\n if (schema.contentMediaType && !schema.contentEncoding) {\n if (/json/i.test(schema.contentMediaType))\n return JSON.stringify(schema.contentSchema ? exampleFromSchema(schema.contentSchema, name) : {});\n return exports.BINARY_PLACEHOLDER;\n }\n const value = sized((_a = namedValue(name, schema, owner)) !== null && _a !== void 0 ? _a : placeholder(name || "value"), schema);\n const pattern = schema.pattern;\n if (typeof pattern !== "string")\n return value;\n const told = (0, fit_1.patternVerdict)(pattern, value);\n if (told === true)\n return value;\n const patterned = patternExample(pattern);\n if (patterned)\n return patterned;\n const shapes = [idLike(name), "12345678901", "+15555550123", "email@example.com", "https://example.com", "example", "EXAMPLE", "Example", "1", "a", "A1"];\n const fitting = shapes.map((shape) => sized(shape, schema)).find((shape) => (0, fit_1.patternVerdict)(pattern, shape) === true);\n if (fitting !== undefined)\n return fitting;\n return (_b = (told === undefined ? shapeNamed(name, schema) : undefined)) !== null && _b !== void 0 ? _b : value;\n}\nfunction shapeNamed(name, schema) {\n const lower = name.toLowerCase();\n const shape = /phone|fax|mobile|(^|_)tel(_|$)|msisdn/.test(lower) ? "+15555550123" : /e-?mail/.test(lower) ? "email@example.com" : /(^|_)(url|uri|link|href|website)$|[a-z](Url|Uri)$/i.test(name) ? "https://example.com" : undefined;\n return shape === undefined ? undefined : sized(shape, schema);\n}\nfunction sized(value, schema) {\n let out = value;\n const held = isPlaceholder(out);\n if (schema.maxLength !== undefined && out.length > schema.maxLength)\n out = held && schema.maxLength >= 3 ? `${out.slice(0, schema.maxLength - 1)}>` : out.slice(0, schema.maxLength);\n if (schema.minLength !== undefined && out.length < schema.minLength)\n out = held ? `${out.slice(0, -1).padEnd(schema.minLength - 1, "_")}>` : out.padEnd(schema.minLength, "x");\n return out;\n}\nfunction placeholder(name) {\n const clean = name.replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[_.-]+|[_.-]+$/g, "");\n return `<${clean.slice(0, 60) || "value"}>`;\n}\nfunction isPlaceholder(value) {\n return typeof value === "string" && /^<[A-Za-z0-9_.-]{1,64}>$/.test(value);\n}\nexports.PLACEHOLDER_UUID = "00000000-0000-4000-8000-000000000000";\nfunction namedValue(name, schema, owner) {\n var _a, _b;\n const lower = name.toLowerCase().replace(/-/g, "_");\n const about = ((_a = schema.description) !== null && _a !== void 0 ? _a : "").toLowerCase();\n if (lower === "id" && owner)\n return idLike(owner);\n if (isIdName(name) || /\\bID\\b/.test((_b = schema.description) !== null && _b !== void 0 ? _b : ""))\n return idLike(name);\n if ((lower === "object" || lower === "type") && schema.title)\n return schema.title.toLowerCase();\n if ((lower === "name" || lower.endsWith("_name")) && (/\\b(domain|hostname)s?\\b/.test(about) || nounOf(owner) === "domain"))\n return "example.com";\n if (/^(domain|host|hostname)$/.test(lower))\n return "example.com";\n if (/(^|_)password$/.test(lower))\n return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";\n return undefined;\n}\nconst TELLING_FIELD = [\n /^(from|sender|to|recipients?|reply_?to|cc|bcc|subject|title|headline|html|text|body|content|message|comment|notes?|caption|prompt|input|slug|language|lang|locale|tz|locality|date|object|type|domain|host|hostname)$/,\n /email|currency|phone|country|url|uri|status|description/,\n /^(first_?name|given_?name|last_?name|family_?name|surname|company|company_?name|business_?name|organi[sz]ation(_?name)?|user_?name|handle|login|screen_?name)$/,\n /(^|_)(name|date|fax|city|state|province|postal_?code|zip|zip_?code|postcode|street|line_?[12]|address_?(line_?)?[12]|time_?zone|colou?r|password)$/,\n /(_at|_time|^time|timestamp)$/,\n];\nfunction saysWhatItHolds(name, schema) {\n var _a;\n const lower = name.toLowerCase().replace(/-/g, "_");\n return isIdName(name) || /\\bID\\b/.test((_a = schema.description) !== null && _a !== void 0 ? _a : "") || TELLING_FIELD.some((re) => re.test(lower));\n}\nfunction nounOf(owner) {\n const words = (owner !== null && owner !== void 0 ? owner : "")\n .replace(/([a-z0-9])([A-Z])/g, "$1_$2")\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter((w) => w && !/^(create|update|new|send|add|get|list|post|put|patch|set|make|place|request|response|body|input|params|parameters|payload|object|data|schema|model|dto|options?|opts|args|arguments|events?|created|updated|deleted|changed|v\\d+)$/.test(w));\n return words.length ? singular(words.slice(-2).join("_")) : undefined;\n}\nfunction patternExample(pattern) {\n let whole;\n try {\n whole = new RegExp(pattern);\n }\n catch {\n return undefined;\n }\n const readable = [pattern, ...(REPEATED_GROUP.test(pattern) ? [] : [withoutLookarounds(pattern)])];\n for (const text of readable) {\n if (text === undefined)\n continue;\n const node = parsePattern(text);\n if (!node)\n continue;\n const value = sample(node, { next: 0 });\n if (value !== undefined && value.length <= 200 && whole.test(value))\n return value;\n }\n return undefined;\n}\nconst REPEATED_GROUP = /\\)(?:[*+]|\\{\\d+,?\\d*\\})/;\nfunction withoutLookarounds(pattern) {\n if (!/\\(\\?<?[=!]/.test(pattern))\n return undefined;\n let out = "";\n for (let i = 0; i < pattern.length; i++) {\n if (pattern[i] === "\\\\") {\n out += pattern.slice(i, i + 2);\n i++;\n continue;\n }\n if (/^\\(\\?<?[=!]/.test(pattern.slice(i, i + 4))) {\n let depth = 0;\n let j = i;\n for (; j < pattern.length; j++) {\n if (pattern[j] === "\\\\")\n j++;\n else if (pattern[j] === "[") {\n j = pattern.indexOf("]", j + 2);\n if (j < 0)\n return undefined;\n }\n else if (pattern[j] === "(")\n depth++;\n else if (pattern[j] === ")" && --depth === 0)\n break;\n }\n if (j >= pattern.length)\n return undefined;\n i = j;\n continue;\n }\n out += pattern[i];\n }\n return out;\n}\nconst POOLS = [[..."1a2b3c4d5e6f7a8b9c0d"], [..."ABCDEFGHJKxyz_-."], [..."LMNPQRSTUVWXYZghijklmnopqrstuvw+=:/@~!*\'(),;$&? "]];\nconst CONTROL = { t: "\\t", n: "\\n", r: "\\r", v: "\\v", f: "\\f" };\nfunction parsePattern(pattern) {\n let i = 0;\n const fail = () => {\n i = pattern.length + 1;\n return undefined;\n };\n const choice = () => {\n var _a;\n const options = [];\n let parts = [];\n while (i < pattern.length && pattern[i] !== ")") {\n const c = pattern[i];\n if (c === "|") {\n options.push({ kind: "sequence", parts });\n parts = [];\n i++;\n continue;\n }\n let atom;\n if (c === "^" || c === "$") {\n i++;\n continue;\n }\n else if (c === "(") {\n if (pattern.startsWith("(?:", i))\n i += 3;\n else if (pattern[i + 1] === "?")\n return fail();\n else\n i++;\n atom = choice();\n if (pattern[i] !== ")")\n return fail();\n i++;\n }\n else if (c === "[") {\n const close = pattern.indexOf("]", pattern[i + 1] === "]" ? i + 2 : i + 1);\n if (close < 0)\n return fail();\n const text = pattern.slice(i, close + 1);\n i = close + 1;\n let set;\n try {\n set = new RegExp(`^${text}$`);\n }\n catch {\n return fail();\n }\n atom = { kind: "chars", accepts: (ch) => set.test(ch) };\n }\n else if (c === "\\\\") {\n const e = pattern[i + 1];\n i += 2;\n if (e === undefined || /[0-9bBkpPc]/.test(e))\n return fail();\n if (/[dwsDWS]/.test(e)) {\n const set = new RegExp(`^\\\\${e}$`);\n atom = { kind: "chars", accepts: (ch) => set.test(ch) };\n }\n else {\n const code = (e === "x" && pattern.slice(i).match(/^[0-9a-fA-F]{2}/)) || (e === "u" && pattern.slice(i).match(/^[0-9a-fA-F]{4}/));\n if (code)\n i += code[0].length;\n const literal = code ? String.fromCharCode(parseInt(code[0], 16)) : ((_a = CONTROL[e]) !== null && _a !== void 0 ? _a : e);\n atom = { kind: "chars", accepts: (ch) => ch === literal, literal };\n }\n }\n else if (c === ".") {\n i++;\n atom = { kind: "chars", accepts: (ch) => ch !== "\\n", literal: "." };\n }\n else if ("*+?{".includes(c)) {\n return fail();\n }\n else {\n i++;\n atom = { kind: "chars", accepts: (ch) => ch === c, literal: c };\n }\n if (!atom)\n return fail();\n const q = pattern.slice(i).match(/^(\\*|\\+|\\?|\\{(\\d+)(?:(,)(\\d*))?\\})\\??/);\n if (q) {\n i += q[0].length;\n const min = q[2] !== undefined ? Number(q[2]) : q[1] === "+" ? 1 : 0;\n const max = q[2] !== undefined ? (q[3] ? (q[4] ? Number(q[4]) : Infinity) : min) : q[1] === "?" ? 1 : Infinity;\n const count = q[1] === "?" ? 1 : Math.min(Math.max(min, Math.min(10, max)), 64);\n if (count < min)\n return fail();\n atom = { kind: "repeat", node: atom, count };\n }\n parts.push(atom);\n }\n options.push({ kind: "sequence", parts });\n return options.length === 1 ? options[0] : { kind: "choice", options };\n };\n const node = choice();\n return i === pattern.length ? node : undefined;\n}\nfunction sample(node, state) {\n var _a;\n switch (node.kind) {\n case "chars": {\n if (node.literal !== undefined)\n return node.literal;\n for (const pool of POOLS) {\n for (let n = 0; n < pool.length; n++) {\n const ch = pool[(state.next + n) % pool.length];\n if (node.accepts(ch)) {\n state.next = (state.next + n + 1) % pool.length;\n return ch;\n }\n }\n }\n return undefined;\n }\n case "sequence": {\n let out = "";\n for (const part of node.parts) {\n const value = sample(part, state);\n if (value === undefined)\n return undefined;\n out += value;\n }\n return out;\n }\n case "repeat": {\n let out = "";\n for (let n = 0; n < node.count; n++) {\n const value = sample(node.node, state);\n if (value === undefined)\n return undefined;\n out += value;\n }\n return out;\n }\n case "choice": {\n const values = node.options.map((option) => sample(option, { ...state })).filter((v) => v !== undefined);\n return (_a = values.find((v) => v.length > 1)) !== null && _a !== void 0 ? _a : values[0];\n }\n }\n}\nfunction isIdName(name) {\n const lower = name.toLowerCase();\n return lower === "id" || lower.endsWith("_id") || lower.endsWith("-id") || /[a-z0-9]Id$/.test(name);\n}\nconst ID_NOISE = /^(create|update|new|send|add|get|list|post|put|patch|set|make|place|request|response|body|input|output|params|parameters|payload|object|data|schema|model|dto|options?|opts|args|arguments|events?|created|updated|deleted|changed|v\\d+)$/;\nfunction idLike(name) {\n const words = idWords(name);\n return words.length ? `<${words.join("_")}_id>` : "<id>";\n}\nfunction uuidLike(name) {\n const words = idWords(name);\n const n = 1 + (seedHash(`uuid:${words.length ? words.join("_") : "obj"}`) % 9999);\n return `${exports.PLACEHOLDER_UUID.slice(0, -12)}${String(n).padStart(12, "0")}`;\n}\nfunction idWords(name) {\n const all = name\n .replace(/[_-]?(uu|s|g)?id$/i, "")\n .replace(/([a-z0-9])([A-Z])/g, "$1_$2")\n .replace(/([A-Z])([A-Z][a-z])/g, "$1_$2")\n .toLowerCase()\n .split(/[^a-z]+/)\n .filter(Boolean);\n const kept = all.filter((w) => !ID_NOISE.test(w));\n return (kept.length ? kept : all).map((w, i, list) => (i === list.length - 1 ? singular(w) : w));\n}\nfunction seedHash(seed) {\n let h = 2166136261;\n for (let i = 0; i < seed.length; i++)\n h = Math.imul(h ^ seed.charCodeAt(i), 16777619) >>> 0;\n return h || 1;\n}\nfunction singular(word) {\n if (/ies$/i.test(word))\n return word.slice(0, -3) + "y";\n if (/(ses|xes|ches|shes)$/i.test(word))\n return word.slice(0, -2);\n if (/s$/i.test(word) && !/ss$/i.test(word))\n return word.slice(0, -1);\n return word;\n}\n\n}, {"./fit":"lib/oas/fit"}],\n"lib/oas/fit": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.CIRCULAR_TARGET = void 0;\nexports.circularTarget = circularTarget;\nexports.fits = fits;\nexports.misfits = misfits;\nexports.typesOf = typesOf;\nexports.equal = equal;\nexports.patternVerdict = patternVerdict;\nexports.matchesPattern = matchesPattern;\nexports.quickLength = quickLength;\nexports.formatFits = formatFits;\nexports.CIRCULAR_TARGET = "x-circular-target";\nfunction circularTarget(schema) {\n const target = schema[exports.CIRCULAR_TARGET];\n return target && typeof target === "object" ? target : undefined;\n}\nconst MAX_DEPTH = 40;\nconst MAX_STEPS = 50000;\nfunction fits(value, schema, mode = "response") {\n return misfits(value, schema, mode, 1).length === 0;\n}\nfunction misfits(value, schema, mode = "response", limit = 20) {\n const out = [];\n check(value, schema, [], 0, out, { counter: { steps: 0 }, limit, mode });\n return out;\n}\nfunction check(value, schema, path, depth, out, state) {\n var _a, _b, _c;\n if (out.length >= state.limit || schema === undefined || schema === true || depth > MAX_DEPTH || ++state.counter.steps > MAX_STEPS)\n return;\n if (schema === false)\n return void out.push({ path, keyword: "false" });\n if (typeof schema !== "object" || schema === null)\n return;\n const miss = (keyword, at = path) => void out.push({ path: at, keyword });\n const target = circularTarget(schema);\n if (target)\n return check(value, target, path, depth + 1, out, state);\n const nullable = schema.nullable === true;\n const types = typesOf(schema);\n if (value === null && nullable)\n return;\n if (types.length && !types.some((t) => isType(value, t)))\n return miss("type");\n if (schema.const !== undefined && !equal(value, schema.const))\n miss("const");\n if (Array.isArray(schema.enum) && schema.enum.length && !schema.enum.some((e) => equal(e, value)))\n miss("enum");\n if (typeof value === "string") {\n const length = [...value].length;\n if (typeof schema.minLength === "number" && length < schema.minLength)\n miss("minLength");\n if (typeof schema.maxLength === "number" && length > schema.maxLength)\n miss("maxLength");\n if (typeof schema.pattern === "string" && !matchesPattern(schema.pattern, value))\n miss("pattern");\n if (typeof schema.format === "string" && !formatFits(schema.format, value))\n miss("format");\n }\n else if (typeof value === "number") {\n const { minimum, maximum, exclusiveMinimum: exMin, exclusiveMaximum: exMax } = schema;\n if (typeof minimum === "number" && (exMin === true ? value <= minimum : value < minimum))\n miss("minimum");\n if (typeof maximum === "number" && (exMax === true ? value >= maximum : value > maximum))\n miss("maximum");\n if (typeof exMin === "number" && value <= exMin)\n miss("exclusiveMinimum");\n if (typeof exMax === "number" && value >= exMax)\n miss("exclusiveMaximum");\n if (typeof schema.multipleOf === "number" && schema.multipleOf > 0 && !multipleOf(value, schema.multipleOf))\n miss("multipleOf");\n if (schema.format === "int32" && !(Number.isInteger(value) && value >= -(2 ** 31) && value < 2 ** 31))\n miss("format");\n }\n else if (Array.isArray(value)) {\n if (typeof schema.minItems === "number" && value.length < schema.minItems)\n miss("minItems");\n if (typeof schema.maxItems === "number" && value.length > schema.maxItems)\n miss("maxItems");\n if (schema.uniqueItems === true && new Set(value.map((v) => canonical(v))).size < value.length)\n miss("uniqueItems");\n const legacy = Array.isArray(schema.items) ? schema.items : undefined;\n const prefix = (_b = (_a = schema.prefixItems) !== null && _a !== void 0 ? _a : legacy) !== null && _b !== void 0 ? _b : [];\n value.forEach((item, i) => {\n if (i < prefix.length)\n check(item, prefix[i], [...path, i], depth + 1, out, state);\n else if (!legacy && isSchema(schema.items))\n check(item, schema.items, [...path, i], depth + 1, out, state);\n });\n }\n else if (isRecord(value)) {\n const props = isRecord(schema.properties) ? schema.properties : {};\n const omitted = (key) => {\n const prop = props[key];\n return isSchema(prop) && (state.mode === "request" ? prop.readOnly === true : prop.writeOnly === true);\n };\n if (Array.isArray(schema.required))\n for (const key of schema.required)\n if (typeof key === "string" && !(key in value) && !omitted(key))\n miss("required", [...path, key]);\n const count = Object.keys(value).length;\n if (typeof schema.minProperties === "number" && count < schema.minProperties)\n miss("minProperties");\n if (typeof schema.maxProperties === "number" && count > schema.maxProperties)\n miss("maxProperties");\n const patterns = isRecord(schema.patternProperties) ? Object.entries(schema.patternProperties) : [];\n for (const [key, item] of Object.entries(value)) {\n if (out.length >= state.limit)\n break;\n let known = false;\n if (Object.prototype.hasOwnProperty.call(props, key)) {\n known = true;\n check(item, props[key], [...path, key], depth + 1, out, state);\n }\n for (const [pattern, sub] of patterns) {\n if (matchesPattern(pattern, key)) {\n known = true;\n check(item, sub, [...path, key], depth + 1, out, state);\n }\n }\n if (!known) {\n const extra = schema.additionalProperties;\n if (extra === false)\n miss("additionalProperties", [...path, key]);\n else if (isSchema(extra))\n check(item, extra, [...path, key], depth + 1, out, state);\n }\n }\n }\n for (const part of (_c = schema.allOf) !== null && _c !== void 0 ? _c : [])\n if (isSchema(part))\n check(value, part, path, depth + 1, out, state);\n if (Array.isArray(schema.anyOf) && schema.anyOf.length && !schema.anyOf.some((v) => fitsAt(value, v, depth, state)))\n miss("anyOf");\n if (Array.isArray(schema.oneOf) && schema.oneOf.length) {\n const fitting = countIn(value, schema.oneOf, depth, state, 2);\n if (fitting !== 1)\n miss(fitting === 0 ? "oneOf" : "oneOf-many");\n }\n if (isSchema(schema.not) && fitsAt(value, schema.not, depth, state))\n miss("not");\n const conditional = schema;\n if (isSchema(conditional.if)) {\n const branch = fitsAt(value, conditional.if, depth, state) ? conditional.then : conditional.else;\n if (isSchema(branch))\n check(value, branch, path, depth + 1, out, state);\n }\n}\nfunction fitsAt(value, schema, depth, state) {\n const found = [];\n check(value, schema, [], depth + 1, found, { counter: state.counter, limit: 1, mode: state.mode });\n return found.length === 0;\n}\nfunction countIn(value, variants, depth, s, stop) {\n let n = 0;\n for (const v of variants) {\n if (isSchema(v) && fitsAt(value, v, depth, s) && ++n >= stop)\n break;\n }\n return n;\n}\nfunction isSchema(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction typesOf(schema) {\n return (Array.isArray(schema.type) ? schema.type : [schema.type]).filter((t) => typeof t === "string");\n}\nfunction isType(value, type) {\n switch (type) {\n case "integer":\n return typeof value === "number" && Number.isInteger(value);\n case "number":\n return typeof value === "number" && Number.isFinite(value);\n case "string":\n return typeof value === "string";\n case "boolean":\n return typeof value === "boolean";\n case "array":\n return Array.isArray(value);\n case "object":\n return isRecord(value);\n case "null":\n return value === null;\n default:\n return true;\n }\n}\nfunction multipleOf(value, step) {\n const quotient = value / step;\n return Math.abs(quotient - Math.round(quotient)) < 1e-9;\n}\nfunction equal(a, b) {\n return canonical(a) === canonical(b);\n}\nfunction canonical(value) {\n var _a;\n if (Array.isArray(value))\n return `[${value.map(canonical).join(",")}]`;\n if (isRecord(value))\n return `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonical(value[k])}`).join(",")}}`;\n return (_a = JSON.stringify(value)) !== null && _a !== void 0 ? _a : "undefined";\n}\nconst REPEATED_GROUP = /\\)(?:[*+]|\\{\\d+,?\\d*\\})/;\nconst compiled = new Map();\nfunction patternVerdict(pattern, value) {\n if (value.length > Math.min(40, quickLength(pattern)))\n return undefined;\n const re = compiledPattern(pattern);\n return re === null ? undefined : re.test(value);\n}\nfunction matchesPattern(pattern, value) {\n if (value.length > Math.min(2000, quickLength(pattern)))\n return true;\n const re = compiledPattern(pattern);\n return re === null || re.test(value);\n}\nconst STEP_BUDGET = 1e6;\nconst quickLengths = new Map();\nfunction quickLength(pattern) {\n var _a;\n let length = quickLengths.get(pattern);\n if (length === undefined) {\n if (REPEATED_GROUP.test(pattern))\n length = 0;\n else {\n const bare = pattern.replace(/\\\\./g, "x").replace(/\\[(?:\\\\.|[^\\]\\\\])*\\]/g, "x");\n const repeats = ((_a = bare.match(/[*+]|\\{\\d*,(\\d*)\\}/g)) !== null && _a !== void 0 ? _a : []).filter((q) => !/,\\d{1,2}\\}$/.test(q)).length;\n length = repeats <= 1 ? Infinity : Math.floor(Math.round(STEP_BUDGET ** (1 / repeats) * 1000) / 1000);\n }\n if (quickLengths.size > 2000)\n quickLengths.clear();\n quickLengths.set(pattern, length);\n }\n return length;\n}\nfunction compiledPattern(pattern) {\n let re = compiled.get(pattern);\n if (re === undefined) {\n try {\n re = new RegExp(pattern, "u");\n }\n catch {\n try {\n re = new RegExp(pattern);\n }\n catch {\n re = null;\n }\n }\n if (compiled.size > 2000)\n compiled.clear();\n compiled.set(pattern, re);\n }\n return re;\n}\nconst DATE = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\nconst TIME = /^(\\d{2}):(\\d{2}):(\\d{2})(\\.\\d+)?(z|[+-]\\d{2}(:?\\d{2})?)$/i;\nconst FORMATS = {\n "date-time": (text) => {\n const [date, time] = text.split(/t|\\s/i);\n return time !== undefined && FORMATS.date(date) && FORMATS.time(time);\n },\n date: (text) => {\n const m = text.match(DATE);\n if (!m)\n return false;\n const month = Number(m[2]);\n const day = Number(m[3]);\n return month >= 1 && month <= 12 && day >= 1 && day <= new Date(Date.UTC(Number(m[1]), month, 0)).getUTCDate();\n },\n time: (text) => {\n const m = text.match(TIME);\n return Boolean(m) && Number(m[1]) <= 23 && Number(m[2]) <= 59 && Number(m[3]) <= 60;\n },\n email: (text) => /^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(text),\n uri: (text) => /^[a-z][a-z0-9+.-]*:[^\\s]*$/i.test(text) && !/\\s/.test(text),\n url: (text) => /^[a-z][a-z0-9+.-]*:\\/\\/[^\\s]+$/i.test(text),\n "uri-reference": (text) => !/[\\s<>"\\\\^`{}|]/.test(text),\n "uri-template": (text) => !/[\\s<>"\\\\^`|]/.test(text),\n uuid: (text) => /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(text),\n ipv4: (text) => /^((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/.test(text),\n ipv6: (text) => { var _a; return /^[0-9a-f:.]+$/i.test(text) && text.includes(":") && ((_a = text.match(/::/g)) !== null && _a !== void 0 ? _a : []).length <= 1; },\n hostname: (text) => text.length <= 253 && /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*\\.?$/i.test(text),\n byte: (text) => /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(text),\n duration: (text) => /^P(?!$)(\\d+(?:\\.\\d+)?Y)?(\\d+(?:\\.\\d+)?M)?(\\d+(?:\\.\\d+)?W)?(\\d+(?:\\.\\d+)?D)?(T(?=\\d)(\\d+(?:\\.\\d+)?H)?(\\d+(?:\\.\\d+)?M)?(\\d+(?:\\.\\d+)?S)?)?$/.test(text),\n regex: (text) => {\n try {\n new RegExp(text);\n return true;\n }\n catch {\n return false;\n }\n },\n "json-pointer": (text) => /^(?:\\/(?:[^~/]|~0|~1)*)*$/.test(text),\n};\nfunction formatFits(format, text) {\n const test = FORMATS[format];\n return test ? test(text) : true;\n}\n\n}, {}],\n"lib/text": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.cut = cut;\nexports.firstSentence = firstSentence;\nexports.wellFormed = wellFormed;\nexports.clip = clip;\nexports.plainText = plainText;\nfunction cut(text, max) {\n const end = Math.max(0, max);\n const last = text.charCodeAt(end - 1);\n return text.slice(0, last >= 0xd800 && last <= 0xdbff ? end - 1 : end);\n}\nfunction firstSentence(text) {\n if (!text)\n return undefined;\n const plain = text.replace(/<[^<>]+>/g, "").replace(/\\s+/g, " ").trim();\n const match = plain.match(/^(.{1,90}?[.!?])(\\s|$)/);\n return match ? match[1] : cut(plain, 90);\n}\nconst HALVES = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDFFF]/g;\nfunction wellFormed(text) {\n return text.replace(HALVES, (c) => (c.length === 2 ? c : ""));\n}\nfunction clip(text, max) {\n return text.length > max ? `${cut(text, max - 1)}\u2026` : text;\n}\nfunction plainText(markdown) {\n return markdown\n .replace(/<[^>]+>/g, " ")\n .replace(/!\\[([^\\]]*)\\]\\([^)]*\\)/g, "$1")\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, "$1")\n .replace(/\\*\\*|__|`/g, "")\n .replace(/(^|\\s)[*_]([^*_\\s][^*_]*?)[*_](?=[\\s.,;:!?)]|$)/g, "$1$2")\n .replace(/^\\s{0,3}(#{1,6}|>)\\s+/gm, "")\n .replace(/\\s+/g, " ")\n .trim();\n}\n\n}, {}]\n};\nvar cache = {};\nfunction load(id) {\n var m = cache[id];\n if (m) return m.exports;\n m = cache[id] = { exports: {} };\n defs[id][0](m, m.exports, function (spec) { return load(defs[id][1][spec]); });\n return m.exports;\n}\nload("lib/embed/player");\n})();';
15289
15663
 
15290
15664
  // ../../lib/embed/exportHtml.ts
15291
15665
  function interactiveHtml(sb, title) {
@@ -16206,7 +16580,7 @@ var USAGE = `integration-tour ${version}: your API's integration videos, built f
16206
16580
 
16207
16581
  Usage:
16208
16582
  integration-tour render <spec file or URL> [--edits <flow files or folder>]
16209
- [--formats mp4,gif,html] [--out <folder>] [--allow-private-refs]
16583
+ [--formats mp4,gif,html] [--out <folder>] [--allow-private-refs] [--yes]
16210
16584
  integration-tour check <spec file or URL> [--edits <flow files or folder>]
16211
16585
  [--allow-private-refs]
16212
16586
 
@@ -16225,6 +16599,10 @@ render Without --edits, makes a video of each of the top three flows the spec s
16225
16599
  check Builds each video, and fails when a spec change lost a call, an edit or the failure
16226
16600
  a flow file shows, so a pull request can't break a video unnoticed.
16227
16601
 
16602
+ In a terminal, render first lists anything the videos show that may be personal or internal,
16603
+ then asks you to confirm that everything is correct and holds no secrets or personal data.
16604
+ --yes confirms, for a script. It never asks in CI, or where nothing can answer.
16605
+
16228
16606
  Files the spec references are read from its repo, and only JSON and YAML files there. URLs it
16229
16607
  references aren't read from this machine or a private network (such as a cloud's metadata
16230
16608
  address), as a spec in a pull request could have the build fetch what only it can reach, but
@@ -16254,8 +16632,8 @@ Without a license key in ${LICENSE_ENV}, the videos carry the "${WATERMARK}"
16254
16632
  watermark. A paid key removes it: ${BUY_URL}`;
16255
16633
  var MAX_NOTES = 10;
16256
16634
  var COMMANDS = ["render", "check"];
16257
- var OPTIONS = ["--edits", "--formats", "--out", "--allow-private-refs", "--help"];
16258
- async function main(argv, env = process.env, fontsDir = (0, import_node_path4.join)(__dirname, "..", "fonts")) {
16635
+ var OPTIONS = ["--edits", "--formats", "--out", "--allow-private-refs", "--yes", "--help"];
16636
+ async function main(argv, env = process.env, fontsDir = (0, import_node_path4.join)(__dirname, "..", "fonts"), ask = terminalQuestion(env)) {
16259
16637
  const [command, ...rest] = argv;
16260
16638
  if (command === "--version" || command === "-v") {
16261
16639
  console.log(version);
@@ -16275,6 +16653,7 @@ async function main(argv, env = process.env, fontsDir = (0, import_node_path4.jo
16275
16653
  let formats = [...DEFAULT_FORMATS];
16276
16654
  let out;
16277
16655
  let allowPrivateRefs = false;
16656
+ let yes = false;
16278
16657
  let editing = false;
16279
16658
  for (let i = 0; i < rest.length; i++) {
16280
16659
  const arg = rest[i];
@@ -16287,6 +16666,9 @@ async function main(argv, env = process.env, fontsDir = (0, import_node_path4.jo
16287
16666
  if (flag === "--allow-private-refs") {
16288
16667
  if (inline2 !== void 0) return usage("--allow-private-refs takes no value.");
16289
16668
  allowPrivateRefs = true;
16669
+ } else if (flag === "--yes") {
16670
+ if (inline2 !== void 0) return usage("--yes takes no value.");
16671
+ yes = true;
16290
16672
  } else if (flag === "--edits") {
16291
16673
  if (inline2) edits.push(inline2);
16292
16674
  else if (inline2 !== void 0 || !rest[i + 1] || rest[i + 1].startsWith("-")) return usage("--edits needs a flow file, or a folder of them.");
@@ -16330,18 +16712,18 @@ async function main(argv, env = process.env, fontsDir = (0, import_node_path4.jo
16330
16712
  progress?.clear();
16331
16713
  failed = true;
16332
16714
  const { message, details } = err;
16333
- console.error(` ${message}`);
16334
- for (const detail of details ?? []) console.error(` ${detail}`);
16715
+ console.error(` ${oneLine(message)}`);
16716
+ for (const detail of details ?? []) console.error(` ${oneLine(detail)}`);
16335
16717
  };
16336
16718
  const madeFor = /* @__PURE__ */ new Map();
16337
16719
  const announce = (total) => {
16338
16720
  const made = command === "render" ? `, as ${list6(formats.map((format) => format.toUpperCase()))}` : "";
16339
16721
  console.log(` ${command === "render" ? "Making" : "Checking"} ${total} video${total === 1 ? "" : "s"}${made}:`);
16340
16722
  };
16341
- const heading = (n, total, label) => ` Video ${n} of ${total} \xB7 ${label}`;
16723
+ const heading = (n, total, label) => ` Video ${n} of ${total} \xB7 ${oneLine(label)}`;
16342
16724
  const make = async (built, from, folder, edited, n, total) => {
16343
16725
  console.log(heading(n, total, `${edited ? from : built.name}: ${built.flow}`));
16344
- for (const line of reportLines(built.report)) console.log(` ${line}`);
16726
+ for (const line of reportLines(built.report)) console.log(` ${oneLine(line)}`);
16345
16727
  if (command === "check") {
16346
16728
  if (lostSomething(built.report)) failed = true;
16347
16729
  else console.log(` ${edited ? "Every call and edit still fits." : "It builds."}`);
@@ -16362,7 +16744,7 @@ async function main(argv, env = process.env, fontsDir = (0, import_node_path4.jo
16362
16744
  console.log(` Wrote ${(0, import_node_path4.relative)(process.cwd(), written2.path)} (${size(written2.bytes)})`);
16363
16745
  }
16364
16746
  };
16365
- console.log(spec);
16747
+ console.log(isUrl(spec) ? shownAddress(spec, true) : spec);
16366
16748
  let opened;
16367
16749
  try {
16368
16750
  opened = await openSpec(spec, { allowPrivateRefs });
@@ -16370,15 +16752,31 @@ async function main(argv, env = process.env, fontsDir = (0, import_node_path4.jo
16370
16752
  fail(err);
16371
16753
  return 1;
16372
16754
  }
16373
- for (const note of opened.notes.slice(0, MAX_NOTES)) console.log(` Note: ${note}`);
16755
+ for (const note of opened.notes.slice(0, MAX_NOTES)) console.log(` Note: ${oneLine(note)}`);
16374
16756
  if (opened.notes.length > MAX_NOTES) console.log(` \u2026and ${opened.notes.length - MAX_NOTES} more notes.`);
16757
+ const cleared = async (videos) => {
16758
+ if (command !== "render" || yes || !ask || !videos.length) return true;
16759
+ for (const line of reviewLines(mergeReviews(videos.map((v) => reviewOf(v.storyboard))))) console.log(` ${oneLine(line)}`);
16760
+ const answer = (await ask(` ${confirmLine("spec or collection", videos.length)} (y/N) `)).trim().toLowerCase();
16761
+ if (answer === "y" || answer === "yes") return true;
16762
+ console.log(" Nothing was written. Fix the spec or flow file, or run it again with --yes once you've checked it.");
16763
+ return false;
16764
+ };
16375
16765
  if (flowFiles.length) {
16376
16766
  const files = [...new Set(flowFiles)];
16377
- announce(files.length);
16378
- for (const [i, file] of files.entries()) {
16767
+ const built = [];
16768
+ for (const file of files) {
16379
16769
  try {
16380
- await make(await editedVideo(opened, file, fonts), file, out ?? (0, import_node_path4.dirname)(file), true, i + 1, files.length);
16770
+ built.push({ file, video: await editedVideo(opened, file, fonts) });
16381
16771
  } catch (err) {
16772
+ built.push({ file, err });
16773
+ }
16774
+ }
16775
+ if (!await cleared(built.flatMap((b) => b.video ? [b.video] : []))) return 1;
16776
+ announce(files.length);
16777
+ for (const [i, { file, video, err }] of built.entries()) {
16778
+ if (video) await make(video, file, out ?? (0, import_node_path4.dirname)(file), true, i + 1, files.length);
16779
+ else {
16382
16780
  console.log(heading(i + 1, files.length, file));
16383
16781
  fail(err);
16384
16782
  }
@@ -16386,6 +16784,7 @@ async function main(argv, env = process.env, fontsDir = (0, import_node_path4.jo
16386
16784
  } else {
16387
16785
  try {
16388
16786
  const videos = suggestedVideos(opened);
16787
+ if (!await cleared(videos)) return 1;
16389
16788
  announce(videos.length);
16390
16789
  for (const [i, built] of videos.entries()) await make(built, spec, out ?? (isUrl(spec) ? "." : (0, import_node_path4.dirname)(spec)), false, i + 1, videos.length);
16391
16790
  } catch (err) {
@@ -16394,6 +16793,17 @@ async function main(argv, env = process.env, fontsDir = (0, import_node_path4.jo
16394
16793
  }
16395
16794
  return failed ? 1 : 0;
16396
16795
  }
16796
+ function terminalQuestion(env) {
16797
+ if (!process.stdin.isTTY || !process.stdout.isTTY || env.CI) return void 0;
16798
+ return async (question) => {
16799
+ const terminal = (0, import_promises4.createInterface)({ input: process.stdin, output: process.stdout });
16800
+ try {
16801
+ return await terminal.question(question);
16802
+ } finally {
16803
+ terminal.close();
16804
+ }
16805
+ };
16806
+ }
16397
16807
  async function keyIsGood(key) {
16398
16808
  if (!key?.trim()) {
16399
16809
  console.log(`No license key in ${LICENSE_ENV}, so the videos carry the watermark. A paid key removes it: ${BUY_URL}`);
@@ -16426,6 +16836,9 @@ function progressLine(stream, env) {
16426
16836
  }
16427
16837
  };
16428
16838
  }
16839
+ function oneLine(text3) {
16840
+ return String(text3).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u202a-\u202e\u2066-\u2069]+/g, " ");
16841
+ }
16429
16842
  function usage(problem) {
16430
16843
  console.error(`${problem}
16431
16844
 
@@ -16465,5 +16878,6 @@ if (require.main === module) {
16465
16878
  0 && (module.exports = {
16466
16879
  didYouMean,
16467
16880
  main,
16881
+ oneLine,
16468
16882
  progressLine
16469
16883
  });