apiuikit 1.1.0 → 1.2.0

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 (88) hide show
  1. package/README.md +1 -0
  2. package/dist/CodeSamples-CXtSA6EK.js +4298 -0
  3. package/dist/CodeSamples-D7dq1xEM.cjs +50 -0
  4. package/dist/apiuikit.cjs.js +1 -1
  5. package/dist/apiuikit.es.js +30 -22
  6. package/dist/config/config.d.ts +48 -0
  7. package/dist/contexts/useSpec.d.ts +3 -0
  8. package/dist/helpers/jsonPointer.d.ts +5 -0
  9. package/dist/helpers/llmsTxt.d.ts +51 -0
  10. package/dist/helpers/specAdapters.d.ts +32 -0
  11. package/dist/helpers/toMarkdown.d.ts +5 -6
  12. package/dist/hooks/useDocumentProviderValue.d.ts +3 -1
  13. package/dist/index-BJ0X8yP3.cjs +133 -0
  14. package/dist/{index-DM2MTkYV.js → index-BMRPdMaB.js} +1 -1
  15. package/dist/{index-EeGvEXPN.cjs → index-BoAORjov.cjs} +1 -1
  16. package/dist/{index-B5IBIM-V.cjs → index-CZjVUeK4.cjs} +1 -1
  17. package/dist/index-DCDYBZcY.js +1461 -0
  18. package/dist/index-DwzxTmOd.js +13614 -0
  19. package/dist/index-d8kJa7YD.cjs +4 -0
  20. package/dist/{index-iXpNcBcP.js → index-ib-tk7y5.js} +1 -1
  21. package/dist/index.d.ts +4 -1
  22. package/dist/markdown-assets/protoToJsonSchema-CBPWaboT.js +6193 -0
  23. package/dist/markdown-assets/protoToJsonSchema-CgkcluFJ.js +83 -0
  24. package/dist/markdown.cjs +91 -0
  25. package/dist/markdown.d.ts +8 -0
  26. package/dist/markdown.es.js +2101 -0
  27. package/dist/{protoToJsonSchema-CcEvAEt4.js → protoToJsonSchema-Btyc_WLL.js} +112 -108
  28. package/dist/{protoToJsonSchema-BNZrP3Fa.cjs → protoToJsonSchema-wxazjeYy.cjs} +10 -10
  29. package/dist/{protobufSchemaParser-BaWs_7UI.js → protobufSchemaParser-9KjS7p8W.js} +2 -2
  30. package/dist/{protobufSchemaParser-7sU6XBEb.cjs → protobufSchemaParser-G1NujZ28.cjs} +1 -1
  31. package/dist/shims/utilInspect.d.ts +2 -0
  32. package/package.json +8 -3
  33. package/dist/components/Navigation/tests/spineTicks.test.d.ts +0 -1
  34. package/dist/components/schema/tests/SchemaTab.test.d.ts +0 -1
  35. package/dist/components/schema/tests/schemaUtils.test.d.ts +0 -1
  36. package/dist/components/tests/Authorization.test.d.ts +0 -1
  37. package/dist/components/tests/Bindings.test.d.ts +0 -1
  38. package/dist/components/tests/ChannelAddress.test.d.ts +0 -1
  39. package/dist/components/tests/CodeBlock.test.d.ts +0 -1
  40. package/dist/components/tests/CodeSamples.test.d.ts +0 -1
  41. package/dist/components/tests/CopyMarkdownButton.test.d.ts +0 -1
  42. package/dist/components/tests/ErrorBoundary.test.d.ts +0 -1
  43. package/dist/components/tests/MarkdownExportMenu.test.d.ts +0 -1
  44. package/dist/components/tests/RenderExtensions.test.d.ts +0 -1
  45. package/dist/containers/AsyncAPI/tests/AsyncAPI.test.d.ts +0 -1
  46. package/dist/containers/AsyncAPI/tests/AsyncAPIErrorBoundary.test.d.ts +0 -1
  47. package/dist/containers/AsyncAPI/tests/AsyncAPIRenderer.test.d.ts +0 -1
  48. package/dist/containers/AsyncAPI/tests/searchHighlight.test.d.ts +0 -1
  49. package/dist/containers/OpenAPI/tests/OpenAPI.test.d.ts +0 -1
  50. package/dist/containers/OpenAPI/tests/OpenAPIErrorBoundary.test.d.ts +0 -1
  51. package/dist/containers/OpenAPI/tests/OpenAPIRenderer.test.d.ts +0 -1
  52. package/dist/containers/Path/tests/PathOperation.test.d.ts +0 -1
  53. package/dist/containers/Path/tests/Paths.test.d.ts +0 -1
  54. package/dist/helpers/avro/tests/avroToJsonSchema.test.d.ts +0 -1
  55. package/dist/helpers/protobuf/tests/protoToJsonSchema.test.d.ts +0 -1
  56. package/dist/helpers/protobuf/tests/protobufSchemaParser.test.d.ts +0 -1
  57. package/dist/helpers/tests/codeSamples.test.d.ts +0 -1
  58. package/dist/helpers/tests/exampleSchema.test.d.ts +0 -1
  59. package/dist/helpers/tests/openapiSearchIndex.test.d.ts +0 -1
  60. package/dist/helpers/tests/resolveDocument.test.d.ts +0 -1
  61. package/dist/helpers/tests/schemaFormat.test.d.ts +0 -1
  62. package/dist/helpers/tests/toMarkdown.test.d.ts +0 -1
  63. package/dist/index-BqogUhNO.js +0 -19011
  64. package/dist/index-mYBY1Eu8.cjs +0 -177
  65. package/dist/public/tests/sections.test.d.ts +0 -1
  66. package/dist/stories/AsyncAPI.stories.d.ts +0 -14
  67. package/dist/stories/AsyncAPIRenderer.stories.d.ts +0 -17
  68. package/dist/stories/Authorization.stories.d.ts +0 -13
  69. package/dist/stories/Bindings.stories.d.ts +0 -12
  70. package/dist/stories/ChannelAddress.stories.d.ts +0 -13
  71. package/dist/stories/CodeBlock.stories.d.ts +0 -11
  72. package/dist/stories/Examples.stories.d.ts +0 -11
  73. package/dist/stories/Information.stories.d.ts +0 -9
  74. package/dist/stories/Message.stories.d.ts +0 -11
  75. package/dist/stories/Messages.stories.d.ts +0 -11
  76. package/dist/stories/Operation.stories.d.ts +0 -10
  77. package/dist/stories/Operations.stories.d.ts +0 -16
  78. package/dist/stories/SchemaTab.stories.d.ts +0 -12
  79. package/dist/stories/SchemaTree.stories.d.ts +0 -24
  80. package/dist/stories/SearchPanel.stories.d.ts +0 -16
  81. package/dist/stories/Server.stories.d.ts +0 -12
  82. package/dist/stories/TabToggle.stories.d.ts +0 -10
  83. package/dist/stories/Tabs.stories.d.ts +0 -11
  84. package/dist/stories/documentContextDecorator.d.ts +0 -25
  85. package/dist/stories/noCanvasDocsPage.d.ts +0 -9
  86. package/dist/utils/tests/hasRef.test.d.ts +0 -1
  87. package/dist/utils/tests/theme.test.d.ts +0 -1
  88. package/dist/utils/tests/useElementRect.test.d.ts +0 -1
@@ -0,0 +1,1461 @@
1
+ var we = Object.defineProperty;
2
+ var Oe = (e, t, i) => t in e ? we(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
+ var U = (e, t, i) => Oe(e, typeof t != "symbol" ? t + "" : t, i);
4
+ function je(e) {
5
+ let t = e | 0;
6
+ return () => {
7
+ t = t + 1831565813 | 0;
8
+ let i = Math.imul(t ^ t >>> 15, 1 | t);
9
+ return i = i + Math.imul(i ^ i >>> 7, 61 | i) ^ i, ((i ^ i >>> 14) >>> 0) / 4294967296;
10
+ };
11
+ }
12
+ function se(e) {
13
+ let t = je(e), i = { next() {
14
+ return t();
15
+ }, int(n, r) {
16
+ return n + Math.floor(i.next() * (r - n + 1));
17
+ }, bool(n = 0.5) {
18
+ return i.next() < n;
19
+ }, pick(n) {
20
+ return n[i.int(0, n.length - 1)];
21
+ }, shuffle(n) {
22
+ let r = [...n];
23
+ for (let o = r.length - 1; o > 0; o--) {
24
+ let a = i.int(0, o);
25
+ [r[o], r[a]] = [r[a], r[o]];
26
+ }
27
+ return r;
28
+ }, fork() {
29
+ let n = Math.floor(i.next() * 4294967296);
30
+ return se(n);
31
+ } };
32
+ return i;
33
+ }
34
+ function Me(e) {
35
+ return null;
36
+ }
37
+ function Pe(e) {
38
+ return e.random.bool();
39
+ }
40
+ function fe(e, t, i = !1) {
41
+ let n = -1e3, r = 1e3, o = !1, a = !1;
42
+ if (e.minimum !== void 0 && (n = e.minimum), e.maximum !== void 0 && (r = e.maximum), e.exclusiveMinimum !== void 0 && (n = e.exclusiveMinimum, o = !0), e.exclusiveMaximum !== void 0 && (r = e.exclusiveMaximum, a = !0), e.multipleOf !== void 0) return ke(e.multipleOf, n, r, o, a, t);
43
+ if (i) {
44
+ let c = o ? Math.floor(n) + 1 : Math.ceil(n), g = a ? Math.ceil(r) - 1 : Math.floor(r);
45
+ return t.random.int(c, g);
46
+ }
47
+ let l = o ? n + Number.EPSILON : n, s = a ? r - Number.EPSILON : r;
48
+ return l + t.random.next() * (s - l);
49
+ }
50
+ function ke(e, t, i, n, r, o) {
51
+ let a = Math.ceil(t / e), l = Math.floor(i / e);
52
+ return n && a * e === t && a++, r && l * e === i && l--, a > l ? a * e : o.random.int(a, l) * e;
53
+ }
54
+ function Ie(e, t) {
55
+ if (e.autoIncrement) {
56
+ let i = e.initialOffset ?? 1, n = Je(t.path), r = t.autoIncrementCounters ?? /* @__PURE__ */ new Map(), o = (r.get(n) ?? i - 1) + 1;
57
+ return r.set(n, o), t.autoIncrementCounters && t.autoIncrementCounters.set(n, o), o;
58
+ }
59
+ return fe(e, t, !0);
60
+ }
61
+ function Je(e) {
62
+ return e.split("/").filter((t) => t !== "" && !/^\d+$/.test(t)).join("/");
63
+ }
64
+ function V(e, t) {
65
+ let i = ue(e, 0);
66
+ return N(i.node, t);
67
+ }
68
+ function N(e, t) {
69
+ switch (e.type) {
70
+ case "literal":
71
+ return e.value;
72
+ case "dot":
73
+ return t.pick([..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#%&*()-_=+[]{}|;:',.<>/? "]);
74
+ case "anchor":
75
+ return "";
76
+ case "charClass":
77
+ return De(e, t);
78
+ case "sequence":
79
+ return e.nodes.map((i) => N(i, t)).join("");
80
+ case "alternation":
81
+ return N(t.pick(e.branches), t);
82
+ case "quantifier": {
83
+ let i = t.int(e.min, Math.min(e.max, e.min + 5));
84
+ return Array.from({ length: i }, () => N(e.node, t)).join("");
85
+ }
86
+ case "group":
87
+ return N(e.node, t);
88
+ }
89
+ }
90
+ function De(e, t) {
91
+ if (!e.negated) return t.pick(e.chars);
92
+ let i = new Set(e.chars), n = [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#%&*()-_=+[]{}|;:',.<>/? "].filter((r) => !i.has(r));
93
+ return n.length > 0 ? t.pick(n) : "a";
94
+ }
95
+ function ue(e, t) {
96
+ let i = [], n = [];
97
+ for (; t < e.length; ) {
98
+ let r = e[t];
99
+ if (r === ")") break;
100
+ if (r === "|") {
101
+ i.push(_(n)), n = [], t++;
102
+ continue;
103
+ }
104
+ if (r === "(") {
105
+ let l = t + 1;
106
+ if (e[l] === "?") if (e[l + 1] === ":") l += 2;
107
+ else if (e[l + 1] === "=" || e[l + 1] === "!") {
108
+ let d = 1, w = l;
109
+ for (; w < e.length && d > 0; )
110
+ w++, e[w] === "(" && d++, e[w] === ")" && d--;
111
+ t = w + 1;
112
+ continue;
113
+ } else {
114
+ for (l += 2; l < e.length && e[l] !== ">"; ) l++;
115
+ l++;
116
+ }
117
+ let s = ue(e, l), c = { type: "group", node: s.node };
118
+ t = s.pos + 1;
119
+ let g = Z(e, t, c);
120
+ n.push(g.node), t = g.pos;
121
+ continue;
122
+ }
123
+ if (r === "[") {
124
+ let l = Se(e, t), s = Z(e, l.pos, l.node);
125
+ n.push(s.node), t = s.pos;
126
+ continue;
127
+ }
128
+ if (r === ".") {
129
+ let l = { type: "dot" };
130
+ t++;
131
+ let s = Z(e, t, l);
132
+ n.push(s.node), t = s.pos;
133
+ continue;
134
+ }
135
+ if (r === "^" || r === "$") {
136
+ n.push({ type: "anchor" }), t++;
137
+ continue;
138
+ }
139
+ if (r === "\\") {
140
+ t++;
141
+ let l = Ae(e, t);
142
+ t = l.pos;
143
+ let s = Z(e, t, l.node);
144
+ n.push(s.node), t = s.pos;
145
+ continue;
146
+ }
147
+ let o = { type: "literal", value: r };
148
+ t++;
149
+ let a = Z(e, t, o);
150
+ n.push(a.node), t = a.pos;
151
+ }
152
+ return i.push(_(n)), { node: i.length === 1 ? i[0] : { type: "alternation", branches: i }, pos: t };
153
+ }
154
+ function _(e) {
155
+ return e.length === 0 ? { type: "literal", value: "" } : e.length === 1 ? e[0] : { type: "sequence", nodes: e };
156
+ }
157
+ function Ae(e, t) {
158
+ let i = e[t];
159
+ switch (t++, i) {
160
+ case "d":
161
+ return { node: { type: "charClass", chars: [..."0123456789"], negated: !1 }, pos: t };
162
+ case "D":
163
+ return { node: { type: "charClass", chars: [..."0123456789"], negated: !0 }, pos: t };
164
+ case "w":
165
+ return { node: { type: "charClass", chars: [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"], negated: !1 }, pos: t };
166
+ case "W":
167
+ return { node: { type: "charClass", chars: [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"], negated: !0 }, pos: t };
168
+ case "s":
169
+ return { node: { type: "charClass", chars: [...`
170
+ `], negated: !1 }, pos: t };
171
+ case "S":
172
+ return { node: { type: "charClass", chars: [...`
173
+ `], negated: !0 }, pos: t };
174
+ case "b":
175
+ case "B":
176
+ return { node: { type: "anchor" }, pos: t };
177
+ default:
178
+ return { node: { type: "literal", value: i }, pos: t };
179
+ }
180
+ }
181
+ function Se(e, t) {
182
+ t++;
183
+ let i = !1;
184
+ e[t] === "^" && (i = !0, t++);
185
+ let n = [];
186
+ for (; t < e.length && e[t] !== "]"; ) {
187
+ if (e[t] === "\\" && t + 1 < e.length) {
188
+ t++;
189
+ let r = e[t];
190
+ switch (r) {
191
+ case "d":
192
+ n.push(..."0123456789");
193
+ break;
194
+ case "w":
195
+ n.push(..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");
196
+ break;
197
+ case "s":
198
+ n.push(...`
199
+ `);
200
+ break;
201
+ default:
202
+ n.push(r);
203
+ }
204
+ t++;
205
+ continue;
206
+ }
207
+ if (t + 2 < e.length && e[t + 1] === "-" && e[t + 2] !== "]") {
208
+ let r = e.charCodeAt(t), o = e.charCodeAt(t + 2);
209
+ for (let a = r; a <= o; a++) n.push(String.fromCharCode(a));
210
+ t += 3;
211
+ continue;
212
+ }
213
+ n.push(e[t]), t++;
214
+ }
215
+ return t++, { node: { type: "charClass", chars: n, negated: i }, pos: t };
216
+ }
217
+ function Z(e, t, i) {
218
+ if (t >= e.length) return { node: i, pos: t };
219
+ let n = e[t], r, o;
220
+ switch (n) {
221
+ case "*":
222
+ r = 0, o = 5, t++;
223
+ break;
224
+ case "+":
225
+ r = 1, o = 5, t++;
226
+ break;
227
+ case "?":
228
+ r = 0, o = 1, t++;
229
+ break;
230
+ case "{": {
231
+ let a = Le(e, t);
232
+ if (a) r = a.min, o = a.max, t = a.pos;
233
+ else return { node: i, pos: t };
234
+ break;
235
+ }
236
+ default:
237
+ return { node: i, pos: t };
238
+ }
239
+ return t < e.length && (e[t] === "?" || e[t] === "+") && t++, { node: { type: "quantifier", node: i, min: r, max: o }, pos: t };
240
+ }
241
+ function Le(e, t) {
242
+ let i = e.slice(t).match(/^\{(\d+)(?:,(\d*))?\}/);
243
+ if (!i) return null;
244
+ let n = parseInt(i[1], 10), r;
245
+ return i[2] === void 0 ? r = n : i[2] === "" ? r = n + 5 : r = parseInt(i[2], 10), { min: n, max: r, pos: t + i[0].length };
246
+ }
247
+ function I(e) {
248
+ return e < 10 ? `0${e}` : `${e}`;
249
+ }
250
+ function Ee(e, t) {
251
+ return new Date(e, t, 0).getDate();
252
+ }
253
+ var pe = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
254
+ function Ze(e) {
255
+ return !(e === "^" || e === "$" || e === "^$");
256
+ }
257
+ function Ne(e, t) {
258
+ if (e.format) {
259
+ if (e.format === "date-time" && (t.minDateTime !== void 0 || t.maxDateTime !== void 0)) return Xe(t);
260
+ let a = t.formatRegistry.get(e.format);
261
+ if (a) {
262
+ let l = a(t.random), s = t.minLength ?? e.minLength, c = t.maxLength ?? e.maxLength;
263
+ return s !== void 0 && l.length < s ? T(l, s, t) : c !== void 0 && l.length > c ? l.slice(0, c) : l;
264
+ }
265
+ }
266
+ if (e.pattern) {
267
+ let a = t.minLength ?? e.minLength, l = t.maxLength ?? e.maxLength;
268
+ for (let g = 0; g < 50; g++) {
269
+ let d = V(e.pattern, t.random);
270
+ if (!(a !== void 0 && d.length < a) && !(l !== void 0 && d.length > l))
271
+ return d;
272
+ }
273
+ let s = V(e.pattern, t.random), c = Ze(e.pattern);
274
+ return a !== void 0 && s.length < a && c ? T(s, a, t) : l !== void 0 && s.length > l ? s.slice(0, l) : s;
275
+ }
276
+ let i = e.minLength ?? 0, n = e.maxLength ?? Math.max(i + 10, 10), r = t.random.int(i, n), o = "";
277
+ for (let a = 0; a < r; a++) o += t.random.pick([...pe]);
278
+ return t.maxLength !== void 0 && o.length > t.maxLength && (o = o.slice(0, t.maxLength)), t.minLength !== void 0 && o.length < t.minLength && (o = T(o, t.minLength, t)), o;
279
+ }
280
+ function T(e, t, i) {
281
+ for (; e.length < t; ) e += i.random.pick([...pe]);
282
+ return e;
283
+ }
284
+ function Xe(e) {
285
+ let t = e.minDateTime ? new Date(e.minDateTime) : /* @__PURE__ */ new Date("1970-01-01"), i = e.maxDateTime ? new Date(e.maxDateTime) : /* @__PURE__ */ new Date(), n = t.getTime(), r = i.getTime(), o = n + e.random.next() * (r - n), a = new Date(o), l = a.getFullYear(), s = I(a.getMonth() + 1), c = I(a.getDate());
286
+ return `${l}-${s}-${c}T01:01:01.0Z`;
287
+ }
288
+ function z(e, t) {
289
+ if (e.const !== void 0) return structuredClone(e.const);
290
+ if (e.enum !== void 0 && e.enum.length > 0) {
291
+ let i = e.enum;
292
+ if (e.minimum !== void 0 || e.maximum !== void 0 || e.exclusiveMinimum !== void 0 || e.exclusiveMaximum !== void 0 || e.multipleOf !== void 0) {
293
+ let r = e.exclusiveMinimum ?? e.minimum ?? -1 / 0, o = e.exclusiveMaximum ?? e.maximum ?? 1 / 0, a = e.exclusiveMinimum !== void 0, l = e.exclusiveMaximum !== void 0;
294
+ i = i.filter((s) => {
295
+ if (typeof s != "number") return !0;
296
+ let c = a ? s > r : s >= r, g = l ? s < o : s <= o;
297
+ if (!c || !g) return !1;
298
+ if (e.multipleOf !== void 0) {
299
+ let d = e.multipleOf, w = d.toString().includes(".") ? d.toString().split(".")[1].length : 0, j = Math.pow(10, w), k = Math.round(s * j), E = Math.round(d * j);
300
+ if (k % E !== 0) return !1;
301
+ }
302
+ return !0;
303
+ });
304
+ }
305
+ if (e.minLength !== void 0 || e.maxLength !== void 0) {
306
+ let r = e.minLength ?? 0, o = e.maxLength ?? 1 / 0;
307
+ i = i.filter((a) => typeof a != "string" ? !0 : a.length >= r && a.length <= o);
308
+ }
309
+ if (e.minItems !== void 0 || e.maxItems !== void 0) {
310
+ let r = e.minItems ?? 0, o = e.maxItems ?? 1 / 0;
311
+ i = i.filter((a) => Array.isArray(a) ? a.length >= r && a.length <= o : !0);
312
+ }
313
+ if (e.minProperties !== void 0 || e.maxProperties !== void 0) {
314
+ let r = e.minProperties ?? 0, o = e.maxProperties ?? 1 / 0;
315
+ i = i.filter((a) => typeof a != "object" || a === null || Array.isArray(a) ? !0 : Object.keys(a).length >= r && Object.keys(a).length <= o);
316
+ }
317
+ if (i.length === 0) {
318
+ let r = [];
319
+ throw e.minLength !== void 0 && r.push(`minLength: ${e.minLength}`), e.maxLength !== void 0 && r.push(`maxLength: ${e.maxLength}`), e.minItems !== void 0 && r.push(`minItems: ${e.minItems}`), e.maxItems !== void 0 && r.push(`maxItems: ${e.maxItems}`), e.minProperties !== void 0 && r.push(`minProperties: ${e.minProperties}`), e.maxProperties !== void 0 && r.push(`maxProperties: ${e.maxProperties}`), e.minimum !== void 0 && r.push(`minimum: ${e.minimum}`), e.maximum !== void 0 && r.push(`maximum: ${e.maximum}`), e.exclusiveMinimum !== void 0 && r.push(`exclusiveMinimum: ${e.exclusiveMinimum}`), e.exclusiveMaximum !== void 0 && r.push(`exclusiveMaximum: ${e.exclusiveMaximum}`), e.multipleOf !== void 0 && r.push(`multipleOf: ${e.multipleOf}`), Error(`enum values conflict with constraints [${r.join(", ")}] at ${t.path}`);
320
+ }
321
+ let n = t.random.pick(i);
322
+ return typeof n == "object" && n !== null ? structuredClone(n) : n;
323
+ }
324
+ throw Error(`generateEnumConst called without enum or const at ${t.path}`);
325
+ }
326
+ function J(e) {
327
+ let t = {};
328
+ for (let i of e) {
329
+ if (typeof i == "boolean") {
330
+ if (!i) return { not: {} };
331
+ continue;
332
+ }
333
+ me(t, i);
334
+ }
335
+ return t;
336
+ }
337
+ function ce(e, t) {
338
+ if (typeof e == "boolean" || typeof t == "boolean") return {};
339
+ if (typeof e != "object" || e === null) return typeof t == "object" && t !== null ? t : {};
340
+ if (typeof t != "object" || t === null) return e;
341
+ let i = { ...e };
342
+ return me(i, t), i;
343
+ }
344
+ function me(e, t) {
345
+ if (t.type !== void 0 && (e.type === void 0 ? e.type = t.type : e.type = qe(e.type, t.type)), t.minimum !== void 0 && (e.minimum = e.minimum !== void 0 ? Math.max(e.minimum, t.minimum) : t.minimum), t.maximum !== void 0 && (e.maximum = e.maximum !== void 0 ? Math.min(e.maximum, t.maximum) : t.maximum), t.exclusiveMinimum !== void 0 && (e.exclusiveMinimum = e.exclusiveMinimum !== void 0 ? Math.max(e.exclusiveMinimum, t.exclusiveMinimum) : t.exclusiveMinimum), t.exclusiveMaximum !== void 0 && (e.exclusiveMaximum = e.exclusiveMaximum !== void 0 ? Math.min(e.exclusiveMaximum, t.exclusiveMaximum) : t.exclusiveMaximum), t.multipleOf !== void 0 && (e.multipleOf = t.multipleOf), t.minLength !== void 0 && (e.minLength = e.minLength !== void 0 ? Math.max(e.minLength, t.minLength) : t.minLength), t.maxLength !== void 0 && (e.maxLength = e.maxLength !== void 0 ? Math.min(e.maxLength, t.maxLength) : t.maxLength), t.pattern !== void 0 && (e.pattern = t.pattern), t.format !== void 0 && (e.format = t.format), t.minItems !== void 0 && (e.minItems = e.minItems !== void 0 ? Math.max(e.minItems, t.minItems) : t.minItems), t.maxItems !== void 0 && (e.maxItems = e.maxItems !== void 0 ? Math.min(e.maxItems, t.maxItems) : t.maxItems), t.uniqueItems && (e.uniqueItems = !0), t.items !== void 0 && (e.items = t.items), t.prefixItems !== void 0) if (e.prefixItems === void 0) e.prefixItems = t.prefixItems;
346
+ else {
347
+ let i = [], n = Math.max(e.prefixItems.length, t.prefixItems.length);
348
+ for (let r = 0; r < n; r++) {
349
+ let o = e.prefixItems[r], a = t.prefixItems[r];
350
+ o !== void 0 && a !== void 0 ? i.push(ce(o, a)) : o !== void 0 ? i.push(o) : a !== void 0 && i.push(a);
351
+ }
352
+ e.prefixItems = i;
353
+ }
354
+ if (t.contains !== void 0 && (e.containsAll !== void 0 ? e.containsAll = [...e.containsAll, t.contains] : e.contains !== void 0 ? (e.containsAll = [e.contains, t.contains], delete e.contains) : e.contains = t.contains), t.properties && (e.properties = Qe(e.properties ?? {}, t.properties)), t.required && (e.required = [.../* @__PURE__ */ new Set([...e.required ?? [], ...t.required])]), t.additionalProperties !== void 0 && (e.additionalProperties = t.additionalProperties), t.patternProperties && (e.patternProperties = { ...e.patternProperties ?? {}, ...t.patternProperties }), t.minProperties !== void 0 && (e.minProperties = e.minProperties !== void 0 ? Math.max(e.minProperties, t.minProperties) : t.minProperties), t.maxProperties !== void 0 && (e.maxProperties = e.maxProperties !== void 0 ? Math.min(e.maxProperties, t.maxProperties) : t.maxProperties), t.const !== void 0 && (e.const = t.const), t.enum !== void 0) if (e.enum !== void 0) {
355
+ let i = new Set(t.enum.map((n) => JSON.stringify(n)));
356
+ e.enum = e.enum.filter((n) => i.has(JSON.stringify(n)));
357
+ } else e.enum = t.enum;
358
+ t.$ref && (e.$ref = t.$ref), t.$defs && (e.$defs = { ...e.$defs ?? {}, ...t.$defs }), t.allOf && (e.allOf = [...e.allOf ?? [], ...t.allOf]), t.anyOf && (e.anyOf = t.anyOf), t.oneOf && (e.oneOf = t.oneOf);
359
+ }
360
+ function qe(e, t) {
361
+ let i = Array.isArray(e) ? e : [e], n = Array.isArray(t) ? t : [t], r = i.filter((o) => n.includes(o));
362
+ return r.length === 0 ? i[0] : r.length === 1 ? r[0] : r;
363
+ }
364
+ function Qe(e, t) {
365
+ let i = { ...e };
366
+ for (let [n, r] of Object.entries(t)) {
367
+ let o = e[n];
368
+ o === void 0 ? i[n] = r : typeof o == "object" && typeof r == "object" ? i[n] = ce(o, r) : i[n] = r;
369
+ }
370
+ return i;
371
+ }
372
+ var Q = /* @__PURE__ */ new Set(["$schema", "$id", "$ref", "$defs", "$anchor", "$dynamicRef", "$dynamicAnchor", "$vocabulary", "$comment", "type", "enum", "const", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "multipleOf", "minLength", "maxLength", "pattern", "format", "contentEncoding", "contentMediaType", "contentSchema", "items", "prefixItems", "contains", "minItems", "maxItems", "uniqueItems", "minContains", "maxContains", "properties", "required", "additionalProperties", "patternProperties", "minProperties", "maxProperties", "propertyNames", "dependentRequired", "dependentSchemas", "allOf", "anyOf", "oneOf", "not", "if", "then", "else", "faker", "chance", "jsonPath", "template", "default", "examples", "description", "title", "readOnly", "writeOnly", "deprecated"]);
373
+ function he(e) {
374
+ return typeof e != "object" || e === null ? !1 : Object.keys(e).some((t) => Q.has(t));
375
+ }
376
+ function K(e, t) {
377
+ if (typeof t != "object" || t === null) return !1;
378
+ let i = t;
379
+ return i.const !== void 0 ? e === i.const : i.enum !== void 0 ? i.enum.some((n) => n === e) : !1;
380
+ }
381
+ function Te(e) {
382
+ return typeof e == "boolean" ? !e : typeof e != "object" || e === null ? !1 : e.not === !0 || typeof e.not == "object" && e.not !== null && Object.keys(e.not).length === 0;
383
+ }
384
+ function Re(e) {
385
+ if (e.properties) return e.properties;
386
+ if (e.type === "object" || e.type === void 0) {
387
+ let t = {}, i = !1;
388
+ for (let [n, r] of Object.entries(e))
389
+ Q.has(n) || (he(r) ? (t[n] = r, i = !0) : (t[n] = { const: r }, i = !0));
390
+ if (i) return t;
391
+ }
392
+ return {};
393
+ }
394
+ function Ce(e, t) {
395
+ return e.required ? e.required : e.properties === void 0 && Object.keys(t).length > 0 ? Object.keys(t) : [];
396
+ }
397
+ async function Ye(e, t) {
398
+ var y;
399
+ let i = Re(e), n = Ce(e, i);
400
+ if (t.depth >= t.maxDepth) {
401
+ if (n.length === 0) return {};
402
+ let f = {};
403
+ for (let u of n) {
404
+ let h = i[u];
405
+ if (h && typeof h == "object" && h !== null) {
406
+ let p = h;
407
+ p.const !== void 0 ? f[u] = p.const : p.default !== void 0 ? f[u] = p.default : p.enum !== void 0 && p.enum.length > 0 ? f[u] = p.enum[0] : f[u] = Be(p.type);
408
+ } else f[u] = null;
409
+ }
410
+ return f;
411
+ }
412
+ if (e.additionalProperties === !1) {
413
+ let f = Object.keys(i).length > 0, u = e.patternProperties && Object.keys(e.patternProperties).length > 0, h = new Set(Object.keys(i)), p = [...new Set(n)].filter((m) => !h.has(m));
414
+ if ((e.minProperties ?? 0) > 0 && !f && !u) throw Error(`missing properties for ${e.minProperties} in ${t.path}: additionalProperties is false but no properties or patternProperties defined`);
415
+ if (p.length > 0 && !u && !f) throw Error(`missing properties for ${p.join(", ")} in ${t.path}: additionalProperties is false but required properties not defined in properties`);
416
+ }
417
+ let r = t.path === "/" ? "/properties" : `${t.path}/properties`, o = { ...t, depth: t.depth + 1, path: r }, a = {}, l = /* @__PURE__ */ new Set(), s = new Set(n), c = t.alwaysFakeOptionals ?? !1, g = t.fillProperties ?? !0, d = t.fixedProbabilities ?? !1, w = t.optionalsProbability ?? 0.5, j = Object.keys(i).filter((f) => !s.has(f)), k;
418
+ if (d && !c && j.length > 0) {
419
+ let f = Math.round(j.length * w);
420
+ k = new Set(j.slice(0, f));
421
+ }
422
+ let E = (f) => c ? !0 : k ? k.has(f) : t.random.bool(w);
423
+ if (Object.keys(i).length > 0) for (let [f, u] of Object.entries(i)) {
424
+ if (Te(u)) continue;
425
+ l.add(f);
426
+ let h = S(o, f), p = s.has(f), m = typeof u == "object" && u !== null && u.type === "object", b = u;
427
+ if (e.patternProperties && typeof u == "object" && u !== null) {
428
+ let x = [];
429
+ for (let [O, D] of Object.entries(e.patternProperties)) try {
430
+ new RegExp(O).test(f) && x.push(D);
431
+ } catch {
432
+ }
433
+ x.length > 0 && (b = J([u, ...x]));
434
+ }
435
+ if (p) {
436
+ let x = await v(b, h);
437
+ x !== void 0 && (a[f] = x);
438
+ } else if (E(f)) {
439
+ let x = await v(b, h);
440
+ x !== void 0 && (a[f] = x);
441
+ } else if (m && !g) {
442
+ let x = u.required ?? [];
443
+ if (x.length > 0) {
444
+ let O = {};
445
+ for (let D of x) {
446
+ let xe = (u.properties ?? {})[D] ?? {}, be = S(h, D), B = await v(xe, be);
447
+ B !== void 0 && (O[D] = B);
448
+ }
449
+ a[f] = O;
450
+ }
451
+ }
452
+ }
453
+ for (let f of s)
454
+ if (!(a[f] !== void 0 || l.has(f))) {
455
+ if (e.patternProperties) {
456
+ let u = [];
457
+ for (let [h, p] of Object.entries(e.patternProperties)) new RegExp(h).test(f) && u.push(p);
458
+ if (u.length > 0) {
459
+ let h = u.length === 1 ? u[0] : J(u), p = S(o, f), m = await v(h, p);
460
+ m !== void 0 && (a[f] = m), l.add(f);
461
+ }
462
+ }
463
+ if (!l.has(f)) {
464
+ let u = e.additionalProperties ?? !0;
465
+ if (u !== !1) {
466
+ let h = S(o, f), p = await v(u === !0 ? {} : u, h);
467
+ p !== void 0 && (a[f] = p), l.add(f);
468
+ }
469
+ }
470
+ }
471
+ if (e.dependencies) {
472
+ for (let [f, u] of Object.entries(e.dependencies))
473
+ if (!(typeof u != "object" || u === null || Array.isArray(u)) && a[f] !== void 0 && !l.has(f + "_dep")) {
474
+ l.add(f + "_dep");
475
+ let h = u.oneOf ?? u.anyOf ?? u.allOf ?? [u], p = null;
476
+ for (let m of h) {
477
+ if (typeof m != "object" || m === null) continue;
478
+ let { properties: b, not: x } = m;
479
+ if (b && b[f]) {
480
+ let O = b[f], D = a[f];
481
+ if (K(D, O)) {
482
+ p = m;
483
+ break;
484
+ }
485
+ }
486
+ if (x != null && x.properties) {
487
+ let O = x.properties[f];
488
+ if (O) {
489
+ let D = a[f];
490
+ if (!K(D, O)) {
491
+ p = m;
492
+ break;
493
+ }
494
+ }
495
+ }
496
+ }
497
+ if (!p && h.length > 0 && typeof h[0] == "object" && (p = h[0]), p != null && p.not) {
498
+ let m = p.not;
499
+ if (m.required && Array.isArray(m.required)) for (let b of m.required) delete a[b];
500
+ }
501
+ if (p != null && p.required) for (let m of p.required) {
502
+ if (m === f || a[m] !== void 0) continue;
503
+ let b = ((y = p.properties) == null ? void 0 : y[m]) ?? { type: "object" }, x = S(o, m), O = await v(b, x);
504
+ O !== void 0 && (a[m] = O);
505
+ }
506
+ if (p && p.properties) for (let [m, b] of Object.entries(p.properties)) {
507
+ if (m === f) continue;
508
+ let x = S(o, m), O = await v(b, x);
509
+ O !== void 0 && (a[m] = O);
510
+ }
511
+ }
512
+ }
513
+ let P = e.minProperties ?? 0, A = e.maxProperties;
514
+ if (Object.keys(a).length < P) {
515
+ if (e.patternProperties && Object.keys(e.patternProperties).length > 0) {
516
+ let f = Object.entries(e.patternProperties), u = 0, h = 1e3;
517
+ for (; Object.keys(a).length < P && u < h; ) {
518
+ u++;
519
+ let [p, m] = t.random.pick(f), b = Fe(p, t);
520
+ if (b && !a[b]) {
521
+ let x = S(o, b), O = await v(m, x);
522
+ O !== void 0 && (a[b] = O), l.add(b);
523
+ }
524
+ }
525
+ }
526
+ if (Object.keys(a).length < P) {
527
+ let f = e.additionalProperties, u = f === void 0 || f === !0 ? { type: "string" } : f;
528
+ if (u !== !1) {
529
+ let h = 0, p = 1e3;
530
+ for (; Object.keys(a).length < P && h < p; ) {
531
+ h++;
532
+ let m = `prop${t.random.int(0, 99999)}`;
533
+ if (!a[m]) {
534
+ let b = S(o, m), x = await v(u, b);
535
+ x !== void 0 && (a[m] = x), l.add(m);
536
+ }
537
+ }
538
+ }
539
+ }
540
+ if (Object.keys(a).length < P) {
541
+ let f = Object.keys(i).join(", ");
542
+ throw Error(`properties '${f}' were not found while additionalProperties is false in ${t.path}`);
543
+ }
544
+ }
545
+ if (A !== void 0 && Object.keys(a).length > A) {
546
+ let f = Object.keys(a).filter((u) => !s.has(u));
547
+ for (t.random.shuffle(f); Object.keys(a).length > A && f.length > 0; ) {
548
+ let u = f.pop();
549
+ delete a[u];
550
+ }
551
+ }
552
+ return t.pruneProperties && t.pruneProperties.length > 0 && R(a, t.pruneProperties), He(a, i), a;
553
+ }
554
+ function S(e, t) {
555
+ let i = We(t), n = e.outputPath === "/" ? `/${i}` : `${e.outputPath}/${i}`;
556
+ return { ...e, path: `${e.path}/${t}`, outputPath: n };
557
+ }
558
+ function We(e) {
559
+ return e.replace(/~/g, "~0").replace(/\//g, "~1");
560
+ }
561
+ function He(e, t) {
562
+ for (let [i, n] of Object.entries(t)) {
563
+ if (typeof n != "object" || n === null) continue;
564
+ let r = n;
565
+ if (r.template === void 0) continue;
566
+ let o = r.template;
567
+ if (typeof o != "string") continue;
568
+ let a = o.replace(/#\{(\w+)\}/g, (l, s) => {
569
+ let c = e[s];
570
+ return c !== void 0 ? String(c) : "";
571
+ });
572
+ e[i] = a;
573
+ }
574
+ }
575
+ function Fe(e, t) {
576
+ let i = e.match(/^\^([a-zA-Z]+)(\.\*|\(\?\:.*\))?/);
577
+ if (i) {
578
+ let s = i[1], c = i[2];
579
+ if (c === ".*" || c != null && c.includes("?:")) {
580
+ let g = t.random.int(0, 10), d = "";
581
+ for (let w = 0; w < g; w++) d += t.random.pick("abcdefghijklmnopqrstuvwxyz".split(""));
582
+ return s + d;
583
+ }
584
+ return s;
585
+ }
586
+ let n = e.match(/(.*\*)?([a-zA-Z]+)\$$/);
587
+ if (n) {
588
+ let s = n[2], c = t.random.int(1, 10), g = "";
589
+ for (let d = 0; d < c; d++) g += t.random.pick("abcdefghijklmnopqrstuvwxyz".split(""));
590
+ return g + s;
591
+ }
592
+ let r = e.match(/^\^([a-zA-Z]+)\$$/);
593
+ if (r) return r[1];
594
+ let o = t.random.int(3, 10), a = "abcdefghijklmnopqrstuvwxyz", l = "";
595
+ for (let s = 0; s < o; s++) l += t.random.pick(a.split(""));
596
+ try {
597
+ if (new RegExp(e).test(l)) return l;
598
+ } catch {
599
+ }
600
+ return null;
601
+ }
602
+ function R(e, t) {
603
+ if (typeof e != "object" || e === null) return;
604
+ if (Array.isArray(e)) {
605
+ for (let n of e) R(n, t);
606
+ return;
607
+ }
608
+ let i = e;
609
+ for (let n of Object.keys(i)) t.includes(n) ? delete i[n] : R(i[n], t);
610
+ }
611
+ function Be(e) {
612
+ switch (Array.isArray(e) ? e[0] : e) {
613
+ case "string":
614
+ return "";
615
+ case "number":
616
+ case "integer":
617
+ return 0;
618
+ case "boolean":
619
+ return !1;
620
+ case "null":
621
+ return null;
622
+ case "array":
623
+ return [];
624
+ case "object":
625
+ return {};
626
+ default:
627
+ return null;
628
+ }
629
+ }
630
+ async function Ue(e, t) {
631
+ var A;
632
+ if (t.depth >= t.maxDepth) {
633
+ let y = e.minItems ?? 0;
634
+ return y > 0 ? Array.from({ length: y }, () => null) : [];
635
+ }
636
+ if (t.refDepthReached) {
637
+ let y = e.minItems ?? 0;
638
+ return y > 0 ? Array.from({ length: y }, () => null) : [];
639
+ }
640
+ if (e.items === !1 && (e.minItems ?? 0) > 0) {
641
+ let y = ((A = e.prefixItems) == null ? void 0 : A.length) ?? 0;
642
+ if ((e.minItems ?? 0) > y) throw Error(`missing items for ${e.minItems} in ${t.path}: items is false but minItems (${e.minItems}) exceeds prefixItems count (${y})`);
643
+ }
644
+ let i = t.path === "/" ? "/items" : `${t.path}/items`, n = { ...t, depth: t.depth + 1, path: i }, r = [], o = t.refDepthMax, a = t.minItems ?? e.minItems ?? 0, l = t.maxItems ?? e.maxItems ?? Math.max(a, t.maxDefaultItems);
645
+ e.maxItems !== void 0 && l > e.maxItems && (l = e.maxItems), e.minItems !== void 0 && a < e.minItems && (a = e.minItems), l < a && (e.maxItems !== void 0 ? a = l : l = a), t.alwaysFakeOptionals && (l = Math.max(a, l));
646
+ let s = e.uniqueItems ? /* @__PURE__ */ new Set() : null, c = async (y, f) => {
647
+ let u = await v(y, f);
648
+ if (u === void 0) return "omitted";
649
+ if (s) {
650
+ let h = JSON.stringify(u);
651
+ if (s.has(h)) {
652
+ for (let p = 0; p < 50; p++) {
653
+ if (u = await v(y, L(n, r.length)), u === void 0) continue;
654
+ let m = JSON.stringify(u);
655
+ if (!s.has(m)) return s.add(m), r.push(u), "added";
656
+ }
657
+ return "failed";
658
+ }
659
+ s.add(h);
660
+ }
661
+ return r.push(u), "added";
662
+ };
663
+ if (e.prefixItems) for (let y = 0; y < e.prefixItems.length && r.length < l; y++) {
664
+ let f = L(n, y);
665
+ if (await c(e.prefixItems[y], f) === "failed") break;
666
+ }
667
+ let g;
668
+ if (o !== void 0 && t.refDepth >= o - 1) {
669
+ let y = e.minItems ?? 0;
670
+ return y > 0 ? Array.from({ length: y }, () => null) : [];
671
+ }
672
+ let d = t.alwaysFakeOptionals ?? !1, w = t.fixedProbabilities ?? !1, j = t.optionalsProbability ?? 0.5;
673
+ if (d) g = l;
674
+ else if (w) {
675
+ let y = l - Math.max(a, r.length), f = Math.round(y * j);
676
+ g = Math.max(a, r.length) + f;
677
+ } else g = t.random.int(Math.max(a, r.length), l);
678
+ e.items;
679
+ let k = e.prefixItems !== void 0, E = e.additionalItems !== void 0, P;
680
+ if (k ? E ? P = e.additionalItems : e.items !== void 0 && (P = e.items) : P = e.items, P !== !1 && P !== void 0) {
681
+ let y = P ?? {}, f = 0, u = Math.max(g * 20, 50);
682
+ for (; r.length < g; ) {
683
+ let h = await c(y, L(n, r.length));
684
+ if (h === "added") {
685
+ f = 0;
686
+ continue;
687
+ }
688
+ if (f++, h === "failed" || f >= u) break;
689
+ }
690
+ }
691
+ if (e.contains) {
692
+ let y = e.minContains ?? 1, f = e.maxContains ?? Math.max(y, 1), u = t.random.int(y, f);
693
+ for (let h = 0; h < u; h++) {
694
+ let p = await v(e.contains, L(n, r.length));
695
+ if (p !== void 0) {
696
+ if (s) {
697
+ let m = JSON.stringify(p);
698
+ if (s.has(m)) {
699
+ let b = !1;
700
+ for (let x = 0; x < 50; x++) {
701
+ if (p = await v(e.contains, L(n, r.length)), p === void 0) continue;
702
+ let O = JSON.stringify(p);
703
+ if (!s.has(O)) {
704
+ s.add(O), b = !0;
705
+ break;
706
+ }
707
+ }
708
+ if (!b) continue;
709
+ } else s.add(m);
710
+ }
711
+ if (r.length < l) {
712
+ let m = t.random.int(0, r.length);
713
+ r.splice(m, 0, p);
714
+ } else if (r.length > 0) {
715
+ let m = t.random.int(0, r.length - 1);
716
+ r[m] = p;
717
+ }
718
+ }
719
+ }
720
+ for (; r.length > l; ) r.pop();
721
+ }
722
+ if (e.containsAll) {
723
+ let y = /* @__PURE__ */ new Set();
724
+ for (let f of e.containsAll) {
725
+ let u = await v(f, L(n, r.length));
726
+ if (u !== void 0) {
727
+ if (s) {
728
+ let h = JSON.stringify(u);
729
+ if (s.has(h)) {
730
+ let p = !1;
731
+ for (let m = 0; m < 50; m++) {
732
+ if (u = await v(f, L(n, r.length)), u === void 0) continue;
733
+ let b = JSON.stringify(u);
734
+ if (!s.has(b)) {
735
+ s.add(b), p = !0;
736
+ break;
737
+ }
738
+ }
739
+ if (!p) continue;
740
+ } else s.add(h);
741
+ }
742
+ if (r.length < l) {
743
+ let h = t.random.int(0, r.length);
744
+ r.splice(h, 0, u);
745
+ let p = /* @__PURE__ */ new Set();
746
+ for (let m of y) p.add(m >= h ? m + 1 : m);
747
+ y.clear();
748
+ for (let m of p) y.add(m);
749
+ y.add(h);
750
+ } else if (r.length > 0) {
751
+ let h = Array.from({ length: r.length }, (p, m) => m).filter((p) => !y.has(p));
752
+ if (h.length > 0) {
753
+ let p = h[t.random.int(0, h.length - 1)];
754
+ r[p] = u, y.add(p);
755
+ } else r.push(u), y.add(r.length - 1);
756
+ }
757
+ }
758
+ }
759
+ for (; r.length > l; ) r.pop();
760
+ }
761
+ return e.uniqueItems && r.length > 0 ? Ve(r, e, n, a, l, s) : r;
762
+ }
763
+ async function Ve(e, t, i, n, r, o) {
764
+ let a = t.items ?? {}, l = 0, s = 100;
765
+ for (; e.length < n && l < s; ) {
766
+ l++;
767
+ let c = await v(a, L(i, e.length));
768
+ if (c === void 0) continue;
769
+ let g = JSON.stringify(c);
770
+ o.has(g) || (o.add(g), e.push(c));
771
+ }
772
+ for (; e.length > r; ) e.pop();
773
+ return e;
774
+ }
775
+ function L(e, t) {
776
+ let i = e.outputPath === "/" ? `/${t}` : `${e.outputPath}/${t}`;
777
+ return { ...e, path: `${e.path}/${t}`, outputPath: i };
778
+ }
779
+ function Ct(e = {}) {
780
+ let t = e.cache ?? /* @__PURE__ */ new Map(), i = e.baseUrl;
781
+ return async (n) => {
782
+ let { url: r, fragment: o } = _e(n, i), a;
783
+ if (t.has(r)) a = t.get(r);
784
+ else {
785
+ if (r.startsWith("http://") || r.startsWith("https://")) a = await ze(r, e.fetch);
786
+ else if (r.startsWith("file://")) {
787
+ let l = decodeURIComponent(r.slice(7));
788
+ a = await G(l, e.readFile);
789
+ } else a = await G(r, e.readFile);
790
+ t.set(r, a);
791
+ }
792
+ return a;
793
+ };
794
+ }
795
+ function _e(e, t) {
796
+ let i = e.indexOf("#");
797
+ if (i === -1) return { url: $(e, t), fragment: null };
798
+ let n = e.slice(0, i), r = e.slice(i + 1);
799
+ return { url: $(n || "#", t), fragment: r || null };
800
+ }
801
+ function $(e, t) {
802
+ if (!t || e.startsWith("http://") || e.startsWith("https://") || e.startsWith("file://")) return e === "#" ? t || "#" : e;
803
+ if (t.startsWith("file://")) {
804
+ let i = t.slice(7), n = i.includes("/") ? "/" : "\\", r = i.lastIndexOf(n);
805
+ return (r >= 0 ? i.slice(0, r + 1) : "") + e;
806
+ }
807
+ try {
808
+ return new URL(e, t).href;
809
+ } catch {
810
+ return e;
811
+ }
812
+ }
813
+ async function ze(e, t) {
814
+ let i = t ?? globalThis.fetch;
815
+ if (!i) throw Error(`Cannot fetch ${e}: fetch is not available. Provide a custom fetch function via the 'fetch' option.`);
816
+ let n = await i(e);
817
+ if (!n.ok) throw Error(`Failed to fetch schema from ${e}: ${n.status} ${n.statusText}`);
818
+ if ((n.headers.get("content-type") || "").includes("application/json")) return n.json();
819
+ let r = await n.text();
820
+ try {
821
+ return JSON.parse(r);
822
+ } catch (o) {
823
+ throw Error(`Failed to parse schema from ${e} as JSON: ${o}`);
824
+ }
825
+ }
826
+ async function G(e, t) {
827
+ if (!t) throw Error(`Cannot read file ${e}: readFile is not available. Provide a custom readFile function via the 'readFile' option. In Node.js, import { readFile } from "node:fs/promises" and pass it as an option.`);
828
+ let i = await t(e);
829
+ return JSON.parse(i);
830
+ }
831
+ function ee(e, t) {
832
+ if (!t || t === "") return e;
833
+ if (typeof e != "object" || e === null) throw Error(`Cannot resolve fragment "${t}" in non-object schema`);
834
+ if (t.startsWith("/")) return Ke(e, t);
835
+ throw Error(`Unsupported fragment type: ${t}. Only JSON pointers (starting with /) are supported.`);
836
+ }
837
+ function Ke(e, t) {
838
+ if (t === "" || t === "/") return e;
839
+ let i = t.slice(1).split("/"), n = e;
840
+ for (let r of i) {
841
+ let o = r.replace(/~1/g, "/").replace(/~0/g, "~");
842
+ if (typeof n != "object" || n === null) throw Error(`Cannot resolve JSON pointer "${t}": not an object at "${o}"`);
843
+ if (Array.isArray(n)) {
844
+ let a = parseInt(o, 10);
845
+ if (isNaN(a) || a < 0 || a >= n.length) throw Error(`Cannot resolve JSON pointer "${t}": invalid array index "${o}"`);
846
+ n = n[a];
847
+ } else {
848
+ if (!(o in n)) throw Error(`Cannot resolve JSON pointer "${t}": property "${o}" not found`);
849
+ n = n[o];
850
+ }
851
+ }
852
+ return n;
853
+ }
854
+ function $e(e) {
855
+ let t = /* @__PURE__ */ new Map();
856
+ if (typeof e == "boolean") return t;
857
+ if (e.$id && typeof e == "object") {
858
+ let i = e, n = i.$id, { $id: r, ...o } = i;
859
+ t.set(n, o);
860
+ }
861
+ if (e.$defs) for (let [i, n] of Object.entries(e.$defs)) t.set(`#/$defs/${i}`, n);
862
+ return t;
863
+ }
864
+ async function q(e, t) {
865
+ let i = e.$ref;
866
+ if (!i) return { schema: e, ctx: t };
867
+ let n = t.refDepth + 1;
868
+ if (t.refDepthMax !== void 0 && n >= t.refDepthMax) return { schema: {}, ctx: { ...t, refDepthReached: !0 } };
869
+ if (t.refStack.has(i)) {
870
+ if (t.refDepthMax !== void 0) {
871
+ if (t.refDepth >= t.refDepthMax) return { schema: {}, ctx: { ...t, refDepthReached: !0 } };
872
+ } else if (t.depth >= t.maxDepth) return { schema: { type: "null" }, ctx: t };
873
+ }
874
+ let r, o;
875
+ if (i.startsWith("#/")) {
876
+ if (r = t.refRegistry.get(i), r === void 0 && i.length > 2) {
877
+ let d = t.refRegistry.get("#");
878
+ if (d !== void 0 && typeof d == "object") try {
879
+ r = ee(d, i.slice(1));
880
+ } catch {
881
+ }
882
+ }
883
+ r === void 0 && t.refResolver && (r = await t.refResolver(i), r !== void 0 && t.refRegistry.set(i, r));
884
+ } else if (i === "#") r = t.refRegistry.get("#") ?? {};
885
+ else if (r = t.refRegistry.get(i), r === void 0 && t.refResolver) {
886
+ o = await t.refResolver(i);
887
+ let d = i.indexOf("#");
888
+ if (d !== -1) {
889
+ let w = i.slice(d + 1);
890
+ w ? r = ee(o, w) : r = o;
891
+ } else r = o;
892
+ if (o && typeof o == "object" && o !== null) {
893
+ let w = o;
894
+ if (w.$defs) for (let [j, k] of Object.entries(w.$defs)) t.refRegistry.set(`#/$defs/${j}`, k);
895
+ }
896
+ }
897
+ if (r === void 0) throw Error(`Unresolved $ref: ${i}`);
898
+ let a = /* @__PURE__ */ new Set(["description", "title", "$comment", "readOnly", "writeOnly", "deprecated"]), { $ref: l, ...s } = e, c = Object.fromEntries(Object.entries(s).filter(([d]) => !a.has(d)));
899
+ Object.keys(c).length > 0 && typeof r == "object" && r !== null && (r = { ...r, ...c });
900
+ let g = { ...t, refStack: /* @__PURE__ */ new Set([...t.refStack, i]), refDepth: t.refDepth + 1 };
901
+ return { schema: r, ctx: g };
902
+ }
903
+ function Ge(e, t) {
904
+ typeof e != "boolean" && (t.set("#", e), C(e, "#", t));
905
+ }
906
+ function C(e, t, i) {
907
+ if (e.$id) {
908
+ let { $id: n, ...r } = e;
909
+ i.set(n, r);
910
+ }
911
+ if (e.$defs) for (let [n, r] of Object.entries(e.$defs)) {
912
+ let o = `${t}/$defs/${n}`;
913
+ i.set(o, r), typeof r == "object" && r !== null && C(r, o, i);
914
+ }
915
+ if (e.properties)
916
+ for (let [n, r] of Object.entries(e.properties)) typeof r == "object" && r !== null && C(r, `${t}/properties/${n}`, i);
917
+ }
918
+ async function et(e, t) {
919
+ return e.$ref ? (await q(e, t)).schema : e;
920
+ }
921
+ async function tt(e, t) {
922
+ let i = [];
923
+ for (let n of e) if (typeof n == "object" && n !== null && "$ref" in n) {
924
+ let r = await et(n, t);
925
+ i.push(r);
926
+ } else typeof n == "object" && n !== null && i.push(n);
927
+ return i;
928
+ }
929
+ async function it(e, t) {
930
+ let { allOf: i, anyOf: n, oneOf: r, not: o, if: a, then: l, else: s, ...c } = e;
931
+ if (i) {
932
+ let g = await tt(i, t), d = J([c, ...g]);
933
+ return v(d, t);
934
+ }
935
+ if (r) {
936
+ let g = t.random.shuffle([...r]), d = c.required ?? [];
937
+ for (let f of g) {
938
+ let u = typeof f == "object" && f !== null ? f : {};
939
+ u.$ref && (u = (await q(u, t)).schema);
940
+ let h = u.required ?? [], p = [.../* @__PURE__ */ new Set([...d, ...h])], m = { ...c, required: p }, b = J([m, u]), x = { ...t, optionalsProbability: 0, alwaysFakeOptionals: !1 };
941
+ try {
942
+ return await v(b, x);
943
+ } catch {
944
+ }
945
+ }
946
+ let w = r[0], j = typeof w == "object" && w !== null ? w : {};
947
+ j.$ref && (j = (await q(j, t)).schema);
948
+ let k = j.required ?? [], E = [.../* @__PURE__ */ new Set([...d, ...k])], P = { ...c, required: E }, A = J([P, j]), y = { ...t, optionalsProbability: 0, alwaysFakeOptionals: !1 };
949
+ return v(A, y);
950
+ }
951
+ if (n) {
952
+ let g = t.random.shuffle([...n]);
953
+ for (let j of g) {
954
+ let k = J([c, j]);
955
+ try {
956
+ return await v(k, t);
957
+ } catch {
958
+ }
959
+ }
960
+ let d = n[0], w = J([c, d]);
961
+ return v(w, t);
962
+ }
963
+ return a !== void 0 ? rt(c, a, l, s, t) : o ? nt(c, o, t) : v(c, t);
964
+ }
965
+ async function rt(e, t, i, n, r) {
966
+ if (i !== void 0) {
967
+ let o = J([e, t, i]);
968
+ try {
969
+ return await v(o, r);
970
+ } catch {
971
+ }
972
+ }
973
+ if (n !== void 0) {
974
+ let o = J([e, n]);
975
+ try {
976
+ return await v(o, r);
977
+ } catch {
978
+ }
979
+ }
980
+ return v(e, r);
981
+ }
982
+ async function nt(e, t, i) {
983
+ if (typeof t == "boolean") {
984
+ if (t === !0) throw Error(`Cannot generate value for 'not: true' at ${i.path}`);
985
+ return v(e, i);
986
+ }
987
+ if (t.type && !t.enum && !t.const) {
988
+ let n = Array.isArray(t.type) ? t.type : [t.type], r = ["string", "number", "integer", "boolean", "null", "object", "array"].filter((o) => !n.includes(o));
989
+ if (r.length > 0) {
990
+ let o = i.random.pick(r), a = J([e, { type: o }]);
991
+ return v(a, i);
992
+ }
993
+ }
994
+ if (t.const !== void 0 || t.enum !== void 0) {
995
+ let n = t.enum ?? [t.const], r = new Set(n.map((o) => JSON.stringify(o)));
996
+ for (let o = 0; o < 20; o++) {
997
+ let a = await v(e, i);
998
+ if (!r.has(JSON.stringify(a))) return a;
999
+ }
1000
+ }
1001
+ return v(e, i);
1002
+ }
1003
+ class ot {
1004
+ constructor() {
1005
+ U(this, "extensions", /* @__PURE__ */ new Map());
1006
+ }
1007
+ define(t, i) {
1008
+ this.extensions.set(t, { callback: i, context: {} });
1009
+ }
1010
+ has(t) {
1011
+ return this.extensions.has(t);
1012
+ }
1013
+ reset(t) {
1014
+ if (t) {
1015
+ let i = this.extensions.get(t);
1016
+ i && (i.context = {}, this.extensions.delete(t));
1017
+ } else this.extensions.clear();
1018
+ }
1019
+ keys() {
1020
+ return this.extensions.keys();
1021
+ }
1022
+ generate(t, i) {
1023
+ let n = Object.keys(t);
1024
+ for (let r = n.length - 1; r >= 0; r--) {
1025
+ let o = n[r], a = o.startsWith("x-") ? o.slice(2) : o, l = this.extensions.get(a);
1026
+ if (l) {
1027
+ let s = t[o], c = l.callback.call(l.context, s, t, i);
1028
+ if (c !== void 0) return c;
1029
+ }
1030
+ }
1031
+ }
1032
+ getContext(t) {
1033
+ var i;
1034
+ return (i = this.extensions.get(t)) == null ? void 0 : i.context;
1035
+ }
1036
+ }
1037
+ var H = new ot();
1038
+ function at(e, t) {
1039
+ H.define(e, t);
1040
+ }
1041
+ function lt(e) {
1042
+ H.reset(e);
1043
+ }
1044
+ function st(e, t) {
1045
+ return H.generate(e, t);
1046
+ }
1047
+ var ft = ["string", "number", "integer", "boolean", "null", "object", "array"];
1048
+ function te(e, t, i) {
1049
+ if (e.faker !== void 0 && e.chance !== void 0) throw Error(`ambiguous generator: both faker and chance are defined in ${t.path}`);
1050
+ if (e.faker !== void 0) try {
1051
+ let n = ut(e.faker, t), r = re(n, i ?? e.type, t.path);
1052
+ return typeof r == "string" && e.format ? ie(r, e.format, t) : r;
1053
+ } catch {
1054
+ }
1055
+ if (e.chance !== void 0) try {
1056
+ let n = pt(e.chance, t), r = re(n, i ?? e.type, t.path);
1057
+ return typeof r == "string" && e.format ? ie(r, e.format, t) : r;
1058
+ } catch {
1059
+ }
1060
+ }
1061
+ function ie(e, t, i) {
1062
+ if (t === "date") {
1063
+ let n = typeof e == "string" ? new Date(e) : e;
1064
+ if (n instanceof Date && !isNaN(n.getTime())) {
1065
+ let r = n.getFullYear(), o = I(n.getMonth() + 1), a = I(n.getDate());
1066
+ return `${r}-${o}-${a}`;
1067
+ }
1068
+ if (typeof e == "string") {
1069
+ let r = Date.parse(e);
1070
+ if (!isNaN(r)) {
1071
+ let o = new Date(r), a = o.getFullYear(), l = I(o.getMonth() + 1), s = I(o.getDate());
1072
+ return `${a}-${l}-${s}`;
1073
+ }
1074
+ }
1075
+ }
1076
+ if (t === "date-time") {
1077
+ let n = typeof e == "string" ? new Date(e) : e;
1078
+ if (n instanceof Date && !isNaN(n.getTime())) return n.toISOString();
1079
+ if (typeof e == "string" && Date.parse(e)) return new Date(e).toISOString();
1080
+ }
1081
+ return e;
1082
+ }
1083
+ function re(e, t, i) {
1084
+ if (t === void 0) return e;
1085
+ let n = Array.isArray(t) ? t[0] : t;
1086
+ switch (n) {
1087
+ case "string":
1088
+ return e === null ? "null" : e === void 0 ? "undefined" : String(e);
1089
+ case "number":
1090
+ case "integer":
1091
+ let r = Number(e);
1092
+ return n === "integer" ? Math.floor(r) : r;
1093
+ case "boolean":
1094
+ return !!e;
1095
+ case "null":
1096
+ return null;
1097
+ default:
1098
+ return e;
1099
+ }
1100
+ }
1101
+ function ut(e, t) {
1102
+ var a;
1103
+ if (!((a = t.extensions) != null && a.faker)) {
1104
+ let l = typeof e == "string" ? e : JSON.stringify(e);
1105
+ throw Error(`cannot resolve faker-generator for ${l} in ${t.path}`);
1106
+ }
1107
+ let i, n;
1108
+ if (typeof e == "object" && e !== null) {
1109
+ let l = e, s = Object.keys(l);
1110
+ if (s.length > 0) i = s[0], n = l[i];
1111
+ else throw Error(`cannot resolve faker-generator for ${JSON.stringify(e)} in ${t.path}`);
1112
+ } else i = e;
1113
+ let r = i.split("."), o = t.extensions.faker;
1114
+ for (let l of r) try {
1115
+ o = o[l];
1116
+ } catch {
1117
+ throw Error(`failed to resolve .${l} (${i})`);
1118
+ }
1119
+ if (typeof o == "function") return n ? o(...n) : o();
1120
+ throw Error(`cannot resolve faker-generator for ${i} in ${t.path}`);
1121
+ }
1122
+ function pt(e, t) {
1123
+ var i;
1124
+ if (!((i = t.extensions) != null && i.chance)) {
1125
+ let n = typeof e == "string" ? e : Object.keys(e)[0];
1126
+ throw Error(`cannot resolve chance-generator for ${n} in ${t.path}`);
1127
+ }
1128
+ if (typeof e == "string") {
1129
+ let n = t.extensions.chance[e];
1130
+ if (typeof n == "function") return n.call(t.extensions.chance);
1131
+ throw Error(`cannot resolve chance-generator for ${e} in ${t.path}`);
1132
+ }
1133
+ if (typeof e == "object" && e !== null) {
1134
+ let n = e, r = Object.keys(n)[0], o = n[r], a = t.extensions.chance[r];
1135
+ if (typeof a == "function") return o ? a.call(t.extensions.chance, o) : a.call(t.extensions.chance);
1136
+ }
1137
+ throw Error(`cannot resolve chance-generator in ${t.path}`);
1138
+ }
1139
+ function ct(e, t) {
1140
+ let i = e.path === "/" ? `/${t}` : `${e.path}/${t}`;
1141
+ return { ...e, depth: e.depth + 1, path: i, refDepthReached: e.refDepthReached };
1142
+ }
1143
+ async function M(e, t, i) {
1144
+ return i.outputTransform ? i.outputTransform(e, t, i.outputPath) : e;
1145
+ }
1146
+ async function v(e, t) {
1147
+ if (e === !0) return v({}, t);
1148
+ if (e === !1) throw Error(`Cannot generate value for 'false' schema at ${t.path}`);
1149
+ if (t.propAliases && typeof e == "object" && e !== null) {
1150
+ let o = e, a = null;
1151
+ for (let [l, s] of Object.entries(t.propAliases)) l in o && !(s in o) && (a || (a = { ...o }), a[s] = a[l], delete a[l]);
1152
+ a && (e = a);
1153
+ }
1154
+ let i;
1155
+ if (Array.isArray(e.type)) {
1156
+ let o = e.type;
1157
+ i = t.random.pick(o);
1158
+ let a = { ...t, resolvedType: i }, l = te(e, a, i);
1159
+ if (l !== void 0)
1160
+ return typeof l == "string" && a.maxLength !== void 0 && l.length > a.maxLength ? M(l.slice(0, a.maxLength), e, a) : M(l, e, a);
1161
+ } else {
1162
+ let o = te(e, t, i);
1163
+ if (o !== void 0)
1164
+ return typeof o == "string" && t.maxLength !== void 0 && o.length > t.maxLength ? M(o.slice(0, t.maxLength), e, t) : M(o, e, t);
1165
+ }
1166
+ let n = st(e, t);
1167
+ if (n !== void 0) return M(n, e, t);
1168
+ if (e.$ref) {
1169
+ let o = await q(e, t);
1170
+ return v(o.schema, ct(o.ctx, "$ref"));
1171
+ }
1172
+ if (e.allOf || e.anyOf || e.oneOf || e.not || e.if) return it(e, t);
1173
+ if (e.const !== void 0) return M(z(e, t), e, t);
1174
+ if (t.useDefaultValue && e.default !== void 0) return M(e.default, e, t);
1175
+ if (e.enum !== void 0) return M(z(e, t), e, t);
1176
+ if (t.useExamplesValue) {
1177
+ if (Array.isArray(e.examples) && e.examples.length > 0) return M(t.random.pick(e.examples), e, t);
1178
+ if (e.example !== void 0) return M(e.example, e, t);
1179
+ }
1180
+ let r = mt(e, t);
1181
+ if (r === null) {
1182
+ if (t.failOnInvalidTypes === !1) {
1183
+ if (t.defaultInvalidTypeProduct !== void 0) {
1184
+ let o = t.defaultInvalidTypeProduct;
1185
+ return typeof o == "string" ? dt(o) : o;
1186
+ }
1187
+ return null;
1188
+ }
1189
+ throw Error(`unknown primitive ${e.type} in ${t.path}/type`);
1190
+ }
1191
+ switch (r) {
1192
+ case "null":
1193
+ return M(Me(), e, t);
1194
+ case "boolean":
1195
+ return M(Pe(t), e, t);
1196
+ case "number":
1197
+ return M(fe(e, t), e, t);
1198
+ case "integer":
1199
+ return M(Ie(e, t), e, t);
1200
+ case "string":
1201
+ return M(Ne(e, t), e, t);
1202
+ case "object":
1203
+ return M(await Ye(e, t), e, t);
1204
+ case "array":
1205
+ return M(await Ue(e, t), e, t);
1206
+ default:
1207
+ throw Error(`Unknown type: ${r} at ${t.path}`);
1208
+ }
1209
+ }
1210
+ function mt(e, t) {
1211
+ return t.resolvedType !== void 0 ? t.resolvedType : typeof e.type == "string" ? ["string", "number", "integer", "boolean", "null", "object", "array"].includes(e.type) ? e.type : null : Array.isArray(e.type) ? t.random.pick(e.type) : e.properties || e.required || e.additionalProperties !== void 0 || e.patternProperties || e.minProperties !== void 0 || e.maxProperties !== void 0 || ht(e) ? "object" : e.items || e.prefixItems || e.contains || e.minItems !== void 0 || e.maxItems !== void 0 || e.uniqueItems ? "array" : e.minimum !== void 0 || e.maximum !== void 0 || e.exclusiveMinimum !== void 0 || e.exclusiveMaximum !== void 0 || e.multipleOf !== void 0 ? "number" : e.minLength !== void 0 || e.maxLength !== void 0 || e.pattern || e.format || e.faker !== void 0 || e.chance !== void 0 ? "string" : t.random.pick(ft);
1212
+ }
1213
+ function ht(e) {
1214
+ if (e.properties || e.type === "object" || e.type === "array") return !1;
1215
+ for (let t of Object.keys(e)) {
1216
+ if (Q.has(t)) continue;
1217
+ let i = e[t];
1218
+ if (typeof i == "object" && i !== null && !Array.isArray(i)) return !0;
1219
+ }
1220
+ return !1;
1221
+ }
1222
+ function dt(e, t) {
1223
+ switch (e) {
1224
+ case "string":
1225
+ return "";
1226
+ case "number":
1227
+ case "integer":
1228
+ return 0;
1229
+ case "boolean":
1230
+ return !1;
1231
+ case "null":
1232
+ return null;
1233
+ case "object":
1234
+ return {};
1235
+ case "array":
1236
+ return [];
1237
+ default:
1238
+ return null;
1239
+ }
1240
+ }
1241
+ function gt(e) {
1242
+ let t = de(e), i = ge(e);
1243
+ return `${t}T${i}`;
1244
+ }
1245
+ function de(e) {
1246
+ let t = e.int(2e3, 2030), i = e.int(1, 12), n = Ee(t, i), r = e.int(1, n);
1247
+ return `${t}-${I(i)}-${I(r)}`;
1248
+ }
1249
+ function ge(e) {
1250
+ let t = e.int(0, 23), i = e.int(0, 59), n = e.int(0, 59);
1251
+ return `${I(t)}:${I(i)}:${I(n)}Z`;
1252
+ }
1253
+ var yt = ["alice", "bob", "charlie", "dave", "eve", "frank", "grace", "heidi"], vt = ["example.com", "test.org", "demo.net", "sample.io"];
1254
+ function ne(e) {
1255
+ let t = e.pick(yt), i = e.int(1, 999), n = e.pick(vt);
1256
+ return `${t}${i}@${n}`;
1257
+ }
1258
+ var xt = ["https"], bt = ["example.com", "test.org", "demo.net"], wt = ["api", "v1", "users", "items", "data", "resource"];
1259
+ function X(e) {
1260
+ let t = e.pick(xt), i = e.pick(bt), n = e.int(1, 3), r = [];
1261
+ for (let o = 0; o < n; o++) r.push(e.pick(wt));
1262
+ return `${t}://${i}/${r.join("/")}`;
1263
+ }
1264
+ var Ot = ["alpha", "beta", "gamma", "delta", "echo", "fox", "golf", "hotel"], jt = ["com", "org", "net", "io", "dev"];
1265
+ function oe(e) {
1266
+ let t = e.int(1, 3), i = [];
1267
+ for (let n = 0; n < t; n++) i.push(e.pick(Ot));
1268
+ return i.push(e.pick(jt)), i.join(".");
1269
+ }
1270
+ function Mt(e) {
1271
+ return `${e.int(1, 254)}.${e.int(0, 255)}.${e.int(0, 255)}.${e.int(1, 254)}`;
1272
+ }
1273
+ function Pt(e) {
1274
+ let t = [];
1275
+ for (let i = 0; i < 8; i++) t.push(e.int(0, 65535).toString(16));
1276
+ return t.join(":");
1277
+ }
1278
+ function kt(e) {
1279
+ let t = (i) => {
1280
+ let n = "";
1281
+ for (let r = 0; r < i; r++) n += e.int(0, 15).toString(16);
1282
+ return n;
1283
+ };
1284
+ return `${t(8)}-${t(4)}-4${t(3)}-${["8", "9", "a", "b"][e.int(0, 3)]}${t(3)}-${t(12)}`;
1285
+ }
1286
+ var It = ["foo", "bar", "baz", "items", "0", "1", "2", "name", "value"];
1287
+ function ae(e) {
1288
+ let t = e.int(1, 4), i = [];
1289
+ for (let n = 0; n < t; n++) i.push(e.pick(It));
1290
+ return "/" + i.join("/");
1291
+ }
1292
+ function Jt(e) {
1293
+ let t = ["P"], i = e.bool(), n = e.bool();
1294
+ return i && (e.bool() && t.push(`${e.int(0, 100)}Y`), e.bool() && t.push(`${e.int(0, 12)}M`), e.bool() && t.push(`${e.int(0, 30)}D`)), n && (t.push("T"), e.bool() && t.push(`${e.int(0, 23)}H`), e.bool() && t.push(`${e.int(0, 59)}M`), e.bool() && t.push(`${e.int(0, 59)}S`)), (t.length === 1 || t.length === 2 && t[1] === "T") && t.push("0D"), t.join("");
1295
+ }
1296
+ var Dt = /* @__PURE__ */ new Map([["date-time", gt], ["date", de], ["time", ge], ["duration", Jt], ["email", ne], ["idn-email", ne], ["uri", X], ["uri-reference", X], ["iri", X], ["iri-reference", X], ["hostname", oe], ["idn-hostname", oe], ["ipv4", Mt], ["ipv6", Pt], ["uuid", kt], ["json-pointer", ae], ["relative-json-pointer", (e) => `${e.int(0, 5)}${ae(e)}`]]);
1297
+ function ye(e) {
1298
+ let t = new Map(Dt);
1299
+ if (e) for (let [i, n] of Object.entries(e)) t.set(i, n);
1300
+ return t;
1301
+ }
1302
+ function At(e, t, i) {
1303
+ i.set(e, t);
1304
+ }
1305
+ function St(e, t) {
1306
+ if (!e.startsWith("$")) throw Error(`Invalid JSONPath: ${e} (must start with $)`);
1307
+ let i = e.slice(1).split(/\.|\[(\d+|\*)\]/).filter(Boolean), n = [t];
1308
+ for (let r of i) {
1309
+ if (r === "") continue;
1310
+ let o = [];
1311
+ for (let a of n)
1312
+ if (a != null)
1313
+ if (r === "*")
1314
+ Array.isArray(a) && o.push(...a);
1315
+ else if (/^\d+$/.test(r)) {
1316
+ let l = parseInt(r, 10);
1317
+ Array.isArray(a) && l < a.length && o.push(a[l]);
1318
+ } else r === "" ? Y(a, o) : typeof a == "object" && a !== null && r in a && o.push(a[r]);
1319
+ n = o;
1320
+ }
1321
+ return n;
1322
+ }
1323
+ function Y(e, t) {
1324
+ if (e != null) {
1325
+ if (Array.isArray(e)) for (let i of e) t.push(i), Y(i, t);
1326
+ else if (typeof e == "object") for (let i of Object.values(e)) t.push(i), Y(i, t);
1327
+ }
1328
+ }
1329
+ function Lt(e) {
1330
+ if (e.properties) return e.properties;
1331
+ if (e.type === "object" || e.type === void 0) {
1332
+ let t = {}, i = !1;
1333
+ for (let [n, r] of Object.entries(e))
1334
+ Q.has(n) || (he(r) ? (t[n] = r, i = !0) : (t[n] = { const: r }, i = !0));
1335
+ if (i) return t;
1336
+ }
1337
+ return {};
1338
+ }
1339
+ async function W(e, t, i, n) {
1340
+ if (!i.resolveJsonPath) return e;
1341
+ let r = n ?? e;
1342
+ if (t === !0 || t === !1 || t.$ref) return e;
1343
+ let o = t;
1344
+ if (o.allOf || o.anyOf || o.oneOf) return e;
1345
+ if (typeof e == "object" && e !== null && !Array.isArray(e)) {
1346
+ let a = { ...e }, l = Lt(o);
1347
+ for (let [s, c] of Object.entries(l)) if (s in a) {
1348
+ let g = a[s];
1349
+ if (typeof c == "object" && c !== null && "jsonPath" in c && typeof c.jsonPath == "string") {
1350
+ let d = St(c.jsonPath, r);
1351
+ d.length > 0 && (a[s] = i.random.pick(d));
1352
+ } else {
1353
+ let d = await W(g, c, i, r);
1354
+ a[s] = d;
1355
+ }
1356
+ }
1357
+ return a;
1358
+ }
1359
+ if (Array.isArray(e) && o.items) {
1360
+ let a = [];
1361
+ for (let l of e) {
1362
+ let s = await W(l, o.items, i, r);
1363
+ a.push(s);
1364
+ }
1365
+ return a;
1366
+ }
1367
+ return e;
1368
+ }
1369
+ var ve = ye(), le = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2020-12/schema", "https://json-schema.org/draft/2019-09/schema"]);
1370
+ async function F(e, t) {
1371
+ if ((t == null ? void 0 : t.validateSchemaVersion) === !0 && !(t != null && t.propAliases) && typeof e == "object" && e !== null && "$schema" in e) {
1372
+ let d = e.$schema;
1373
+ if (typeof d == "string" && !le.has(d)) throw Error(`Unsupported JSON Schema version: ${d}. Supported versions: ${[...le].join(", ")}`);
1374
+ }
1375
+ let i = Xt(t), n = se((t == null ? void 0 : t.seed) ?? 1), r = i.propAliases ? Nt(e, i.propAliases) : e, o = $e(r);
1376
+ Ge(r, o);
1377
+ let a = i.formats ? ye(i.formats) : new Map(ve), l = i.refDepthMin ?? i.refDepth, s = i.refDepthMax ?? i.refDepth;
1378
+ if (l !== void 0 && s !== void 0 && l > s) throw Error(`refDepthMin (${l}) cannot be greater than refDepthMax (${s})`);
1379
+ let c = { random: n, maxDepth: i.maxDepth ?? (s ? s + 20 : 5), maxDefaultItems: i.maxDefaultItems ?? 3, optionalsProbability: i.optionalsProbability ?? 0.5, depth: 0, refRegistry: o, refStack: /* @__PURE__ */ new Set(), formatRegistry: a, refResolver: i.refResolver, minItems: i.minItems, maxItems: i.maxItems, minLength: i.minLength, maxLength: i.maxLength, useDefaultValue: i.useDefaultValue, path: "/", outputPath: "/", alwaysFakeOptionals: i.alwaysFakeOptionals, fixedProbabilities: i.fixedProbabilities, fillProperties: i.fillProperties, extensions: i.extensions, resolveJsonPath: i.resolveJsonPath, autoIncrementCounters: /* @__PURE__ */ new Map(), refDepth: 0, refDepthMin: l, refDepthMax: s, useExamplesValue: i.useExamplesValue, pruneProperties: i.pruneProperties, failOnInvalidTypes: i.failOnInvalidTypes, defaultInvalidTypeProduct: i.defaultInvalidTypeProduct, minDateTime: i.minDateTime, maxDateTime: i.maxDateTime, propAliases: i.propAliases, outputTransform: i.outputTransform }, g = await v(r, c);
1380
+ return i.resolveJsonPath ? W(g, e, c, g) : g;
1381
+ }
1382
+ function Yt(e) {
1383
+ let t = { ...e }, i = 0;
1384
+ return { generate(n) {
1385
+ let r = (t.seed ?? 1) + i++;
1386
+ return F(n, { ...t, seed: r });
1387
+ } };
1388
+ }
1389
+ function Wt(e, t) {
1390
+ At(e, t, ve);
1391
+ }
1392
+ function Ht(e, t) {
1393
+ at(e, t);
1394
+ }
1395
+ function Ft(e) {
1396
+ lt(e);
1397
+ }
1398
+ async function Et(e, t) {
1399
+ let i = await F(e, t), n = (t == null ? void 0 : t.pretty) !== !1 ? { space: 2, ...t == null ? void 0 : t.jsonStringifyOptions } : { space: 0, ...t == null ? void 0 : t.jsonStringifyOptions };
1400
+ return JSON.stringify(i, n.replacer, n.space);
1401
+ }
1402
+ function Bt(e) {
1403
+ let t = { ...e }, i = 0;
1404
+ return { generate(n) {
1405
+ let r = (t.seed ?? 1) + i++;
1406
+ return Et(n, { ...t, seed: r });
1407
+ } };
1408
+ }
1409
+ async function Zt(e, t) {
1410
+ var o;
1411
+ let i = (t == null ? void 0 : t.yaml) ?? ((o = t == null ? void 0 : t.extensions) == null ? void 0 : o.yaml);
1412
+ if (!i) throw Error("YAML support requires 'yaml' package. Provide via options.extensions.yaml or options.yaml.");
1413
+ let n = await F(e, t), r = (t == null ? void 0 : t.pretty) !== !1 ? { indent: 2, lineWidth: 0 } : {};
1414
+ return i.stringify(n, r);
1415
+ }
1416
+ function Ut(e) {
1417
+ let t = { ...e }, i = 0;
1418
+ return { generate(n) {
1419
+ let r = (t.seed ?? 1) + i++;
1420
+ return Zt(n, { ...t, seed: r });
1421
+ } };
1422
+ }
1423
+ function Nt(e, t) {
1424
+ if (typeof e != "object" || e === null) return e;
1425
+ let i = e, n = null;
1426
+ for (let [r, o] of Object.entries(t)) r in i && !(o in i) && (n || (n = { ...i }), n[o] = n[r], delete n[r]);
1427
+ return n ?? e;
1428
+ }
1429
+ function Xt(e) {
1430
+ if (!e) return {};
1431
+ let t = e, i = { ...e };
1432
+ return t.requiredOnly === !0 && i.optionalsProbability === void 0 && (i = { ...i, optionalsProbability: 0, alwaysFakeOptionals: !1 }), t.ignoreProperties && t.ignoreProperties.length > 0 && (i = { ...i, outputTransform: qt(i.outputTransform, Qt(t.ignoreProperties)) }), i;
1433
+ }
1434
+ function qt(e, t) {
1435
+ return e ? t ? async (i, n, r) => {
1436
+ let o = await e(i, n, r);
1437
+ return t(o, n, r);
1438
+ } : e : t;
1439
+ }
1440
+ function Qt(e) {
1441
+ return (t, i, n) => {
1442
+ if (n === "/") return t;
1443
+ let r = Tt(n.slice(n.lastIndexOf("/") + 1));
1444
+ return e.some((o) => typeof o == "string" ? o === r : o instanceof RegExp ? o.test(r) : o(i)) ? void 0 : t;
1445
+ };
1446
+ }
1447
+ function Tt(e) {
1448
+ return e.replace(/~1/g, "/").replace(/~0/g, "~");
1449
+ }
1450
+ export {
1451
+ Yt as createGenerator,
1452
+ Bt as createJsonGenerator,
1453
+ Ct as createRemoteResolver,
1454
+ Ut as createYamlGenerator,
1455
+ Ht as define,
1456
+ F as generate,
1457
+ Et as generateJson,
1458
+ Zt as generateYaml,
1459
+ Wt as registerFormat,
1460
+ Ft as reset
1461
+ };