@ng-openapi/http-resource 0.0.2-pr-9-feature-http-resource-e6134bb.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 (6) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +226 -0
  3. package/index.cjs +3788 -0
  4. package/index.d.ts +221 -0
  5. package/index.js +3749 -0
  6. package/package.json +88 -0
package/index.js ADDED
@@ -0,0 +1,3749 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/lib/http-resource.generator.ts
5
+ import { Scope } from "ts-morph";
6
+
7
+ // ../../shared/src/utils/string.utils.ts
8
+ function camelCase(str2) {
9
+ const cleaned = str2.replace(/[-_](\w)/g, (_, c) => c.toUpperCase());
10
+ return cleaned.charAt(0).toLowerCase() + cleaned.slice(1);
11
+ }
12
+ __name(camelCase, "camelCase");
13
+ function pascalCase(str2) {
14
+ return str2.replace(/(?:^|[-_])([a-z])/g, (_, char) => char.toUpperCase());
15
+ }
16
+ __name(pascalCase, "pascalCase");
17
+
18
+ // ../../shared/src/utils/type.utils.ts
19
+ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, context = "type") {
20
+ let schema2;
21
+ let nullable;
22
+ if (typeof schemaOrType === "string" || schemaOrType === void 0) {
23
+ schema2 = {
24
+ type: schemaOrType,
25
+ format: typeof formatOrNullable === "string" ? formatOrNullable : void 0
26
+ };
27
+ nullable = typeof formatOrNullable === "boolean" ? formatOrNullable : isNullable;
28
+ } else {
29
+ schema2 = schemaOrType;
30
+ nullable = typeof formatOrNullable === "boolean" ? formatOrNullable : schema2.nullable;
31
+ }
32
+ if (!schema2) {
33
+ return "any";
34
+ }
35
+ if (schema2.$ref) {
36
+ const refName = schema2.$ref.split("/").pop();
37
+ return nullableType(pascalCase(refName), nullable);
38
+ }
39
+ if (schema2.type === "array") {
40
+ const itemType = schema2.items ? getTypeScriptType(schema2.items, config, void 0, void 0, context) : "unknown";
41
+ return nullable ? `(${itemType}[] | null)` : `${itemType}[]`;
42
+ }
43
+ switch (schema2.type) {
44
+ case "string":
45
+ if (schema2.enum) {
46
+ return schema2.enum.map((value) => typeof value === "string" ? `'${escapeString(value)}'` : String(value)).join(" | ");
47
+ }
48
+ if (schema2.format === "date" || schema2.format === "date-time") {
49
+ const dateType = config.options.dateType === "Date" ? "Date" : "string";
50
+ return nullableType(dateType, nullable);
51
+ }
52
+ if (schema2.format === "binary") {
53
+ const binaryType = context === "type" ? "Blob" : "File";
54
+ return nullableType(binaryType, nullable);
55
+ }
56
+ if (schema2.format === "uuid" || schema2.format === "email" || schema2.format === "uri" || schema2.format === "hostname" || schema2.format === "ipv4" || schema2.format === "ipv6") {
57
+ return nullableType("string", nullable);
58
+ }
59
+ return nullableType("string", nullable);
60
+ case "number":
61
+ case "integer":
62
+ return nullableType("number", nullable);
63
+ case "boolean":
64
+ return nullableType("boolean", nullable);
65
+ case "object":
66
+ return nullableType(context === "type" ? "Record<string, unknown>" : "any", nullable);
67
+ case "null":
68
+ return "null";
69
+ default:
70
+ console.warn(`Unknown swagger type: ${schema2.type}`);
71
+ return nullableType("any", nullable);
72
+ }
73
+ }
74
+ __name(getTypeScriptType, "getTypeScriptType");
75
+ function nullableType(type2, isNullable) {
76
+ return type2 + (isNullable ? " | null" : "");
77
+ }
78
+ __name(nullableType, "nullableType");
79
+ function escapeString(str2) {
80
+ return str2.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
81
+ }
82
+ __name(escapeString, "escapeString");
83
+
84
+ // ../../shared/src/utils/functions/collect-used-types.ts
85
+ function collectUsedTypes(operations) {
86
+ const usedTypes = /* @__PURE__ */ new Set();
87
+ operations.forEach((operation) => {
88
+ operation.parameters?.forEach((param) => {
89
+ collectTypesFromSchema(param.schema || param, usedTypes);
90
+ });
91
+ if (operation.requestBody) {
92
+ collectTypesFromRequestBody(operation.requestBody, usedTypes);
93
+ }
94
+ if (operation.responses) {
95
+ Object.values(operation.responses).forEach((response) => {
96
+ collectTypesFromResponse(response, usedTypes);
97
+ });
98
+ }
99
+ });
100
+ return usedTypes;
101
+ }
102
+ __name(collectUsedTypes, "collectUsedTypes");
103
+ function collectTypesFromSchema(schema2, usedTypes) {
104
+ if (!schema2) return;
105
+ if (schema2.$ref) {
106
+ const refName = schema2.$ref.split("/").pop();
107
+ if (refName) {
108
+ usedTypes.add(pascalCase(refName));
109
+ }
110
+ }
111
+ if (schema2.type === "array" && schema2.items) {
112
+ collectTypesFromSchema(schema2.items, usedTypes);
113
+ }
114
+ if (schema2.type === "object" && schema2.properties) {
115
+ Object.values(schema2.properties).forEach((prop) => {
116
+ collectTypesFromSchema(prop, usedTypes);
117
+ });
118
+ }
119
+ if (schema2.allOf) {
120
+ schema2.allOf.forEach((subSchema) => {
121
+ collectTypesFromSchema(subSchema, usedTypes);
122
+ });
123
+ }
124
+ if (schema2.oneOf) {
125
+ schema2.oneOf.forEach((subSchema) => {
126
+ collectTypesFromSchema(subSchema, usedTypes);
127
+ });
128
+ }
129
+ if (schema2.anyOf) {
130
+ schema2.anyOf.forEach((subSchema) => {
131
+ collectTypesFromSchema(subSchema, usedTypes);
132
+ });
133
+ }
134
+ }
135
+ __name(collectTypesFromSchema, "collectTypesFromSchema");
136
+ function collectTypesFromRequestBody(requestBody, usedTypes) {
137
+ const content = requestBody.content || {};
138
+ Object.values(content).forEach((mediaType) => {
139
+ if (mediaType.schema) {
140
+ collectTypesFromSchema(mediaType.schema, usedTypes);
141
+ }
142
+ });
143
+ }
144
+ __name(collectTypesFromRequestBody, "collectTypesFromRequestBody");
145
+ function collectTypesFromResponse(response, usedTypes) {
146
+ const content = response.content || {};
147
+ Object.values(content).forEach((mediaType) => {
148
+ if (mediaType.schema) {
149
+ collectTypesFromSchema(mediaType.schema, usedTypes);
150
+ }
151
+ });
152
+ }
153
+ __name(collectTypesFromResponse, "collectTypesFromResponse");
154
+
155
+ // ../../shared/src/utils/functions/token-names.ts
156
+ function getClientContextTokenName(clientName = "default") {
157
+ const clientSuffix = clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
158
+ return `CLIENT_CONTEXT_TOKEN_${clientSuffix}`;
159
+ }
160
+ __name(getClientContextTokenName, "getClientContextTokenName");
161
+ function getBasePathTokenName(clientName = "default") {
162
+ const clientSuffix = clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
163
+ return `BASE_PATH_${clientSuffix}`;
164
+ }
165
+ __name(getBasePathTokenName, "getBasePathTokenName");
166
+
167
+ // ../../shared/src/utils/functions/duplicate-function-name.ts
168
+ function hasDuplicateFunctionNames(arr) {
169
+ return new Set(arr.map((fn) => fn.getName())).size !== arr.length;
170
+ }
171
+ __name(hasDuplicateFunctionNames, "hasDuplicateFunctionNames");
172
+
173
+ // ../../shared/src/utils/functions/extract-paths.ts
174
+ function extractPaths(swaggerPaths = {}, methods = [
175
+ "get",
176
+ "post",
177
+ "put",
178
+ "patch",
179
+ "delete",
180
+ "options",
181
+ "head"
182
+ ]) {
183
+ const paths = [];
184
+ Object.entries(swaggerPaths).forEach(([path4, pathItem]) => {
185
+ methods.forEach((method) => {
186
+ if (pathItem[method]) {
187
+ const operation = pathItem[method];
188
+ paths.push({
189
+ path: path4,
190
+ method: method.toUpperCase(),
191
+ operationId: operation.operationId,
192
+ summary: operation.summary,
193
+ description: operation.description,
194
+ tags: operation.tags || [],
195
+ parameters: parseParameters(operation.parameters || [], pathItem.parameters || []),
196
+ requestBody: operation.requestBody,
197
+ responses: operation.responses || {}
198
+ });
199
+ }
200
+ });
201
+ });
202
+ return paths;
203
+ }
204
+ __name(extractPaths, "extractPaths");
205
+ function parseParameters(operationParams, pathParams) {
206
+ const allParams = [
207
+ ...pathParams,
208
+ ...operationParams
209
+ ];
210
+ return allParams.map((param) => ({
211
+ name: param.name,
212
+ in: param.in,
213
+ required: param.required || param.in === "path",
214
+ schema: param.schema,
215
+ type: param.type,
216
+ format: param.format,
217
+ description: param.description
218
+ }));
219
+ }
220
+ __name(parseParameters, "parseParameters");
221
+
222
+ // ../../shared/src/utils/functions/extract-swagger-response-type.ts
223
+ function getResponseTypeFromResponse(response, responseTypeMapping) {
224
+ const content = response.content || {};
225
+ if (Object.keys(content).length === 0) {
226
+ return "json";
227
+ }
228
+ const responseTypes = [];
229
+ for (const [contentType, mediaType] of Object.entries(content)) {
230
+ const schema2 = mediaType?.schema;
231
+ const mapping = responseTypeMapping || {};
232
+ if (mapping[contentType]) {
233
+ responseTypes.push({
234
+ type: mapping[contentType],
235
+ priority: 1,
236
+ contentType
237
+ });
238
+ continue;
239
+ }
240
+ if (schema2?.format === "binary" || schema2?.format === "byte") {
241
+ responseTypes.push({
242
+ type: "blob",
243
+ priority: 2,
244
+ contentType
245
+ });
246
+ continue;
247
+ }
248
+ if (schema2?.type === "string" && (schema2?.format === "binary" || schema2?.format === "byte")) {
249
+ responseTypes.push({
250
+ type: "blob",
251
+ priority: 2,
252
+ contentType
253
+ });
254
+ continue;
255
+ }
256
+ const isPrimitive = isPrimitiveType(schema2);
257
+ const inferredType = inferResponseTypeFromContentType(contentType);
258
+ let priority = 3;
259
+ let finalType = inferredType;
260
+ if (inferredType === "json" && isPrimitive) {
261
+ finalType = "text";
262
+ priority = 2;
263
+ } else if (inferredType === "json") {
264
+ priority = 2;
265
+ }
266
+ responseTypes.push({
267
+ type: finalType,
268
+ priority,
269
+ contentType,
270
+ isPrimitive
271
+ });
272
+ }
273
+ responseTypes.sort((a, b) => a.priority - b.priority);
274
+ return responseTypes[0]?.type || "json";
275
+ }
276
+ __name(getResponseTypeFromResponse, "getResponseTypeFromResponse");
277
+ function isPrimitiveType(schema2) {
278
+ if (!schema2) return false;
279
+ const primitiveTypes = [
280
+ "string",
281
+ "number",
282
+ "integer",
283
+ "boolean"
284
+ ];
285
+ if (primitiveTypes.includes(schema2.type)) {
286
+ return true;
287
+ }
288
+ if (schema2.type === "array") {
289
+ return false;
290
+ }
291
+ if (schema2.type === "object" || schema2.properties) {
292
+ return false;
293
+ }
294
+ if (schema2.$ref) {
295
+ return false;
296
+ }
297
+ if (schema2.allOf || schema2.oneOf || schema2.anyOf) {
298
+ return false;
299
+ }
300
+ return false;
301
+ }
302
+ __name(isPrimitiveType, "isPrimitiveType");
303
+ function inferResponseTypeFromContentType(contentType) {
304
+ const normalizedType = contentType.split(";")[0].trim().toLowerCase();
305
+ if (normalizedType.includes("json") || normalizedType === "application/ld+json" || normalizedType === "application/hal+json" || normalizedType === "application/vnd.api+json") {
306
+ return "json";
307
+ }
308
+ if (normalizedType.includes("xml") || normalizedType === "application/soap+xml" || normalizedType === "application/atom+xml" || normalizedType === "application/rss+xml") {
309
+ return "text";
310
+ }
311
+ if (normalizedType.startsWith("text/")) {
312
+ const binaryTextTypes = [
313
+ "text/rtf",
314
+ "text/cache-manifest",
315
+ "text/vcard",
316
+ "text/calendar"
317
+ ];
318
+ if (binaryTextTypes.includes(normalizedType)) {
319
+ return "blob";
320
+ }
321
+ return "text";
322
+ }
323
+ if (normalizedType === "application/x-www-form-urlencoded" || normalizedType === "multipart/form-data") {
324
+ return "text";
325
+ }
326
+ if (normalizedType === "application/javascript" || normalizedType === "application/typescript" || normalizedType === "application/css" || normalizedType === "application/yaml" || normalizedType === "application/x-yaml" || normalizedType === "application/toml") {
327
+ return "text";
328
+ }
329
+ if (normalizedType.startsWith("image/") || normalizedType.startsWith("audio/") || normalizedType.startsWith("video/") || normalizedType === "application/pdf" || normalizedType === "application/zip" || normalizedType.includes("octet-stream")) {
330
+ return "arraybuffer";
331
+ }
332
+ return "blob";
333
+ }
334
+ __name(inferResponseTypeFromContentType, "inferResponseTypeFromContentType");
335
+ function getResponseType(response, config) {
336
+ const responseType = getResponseTypeFromResponse(response);
337
+ switch (responseType) {
338
+ case "blob":
339
+ return "Blob";
340
+ case "arraybuffer":
341
+ return "ArrayBuffer";
342
+ case "text":
343
+ return "string";
344
+ case "json": {
345
+ const content = response.content || {};
346
+ for (const [contentType, mediaType] of Object.entries(content)) {
347
+ if (inferResponseTypeFromContentType(contentType) === "json" && mediaType?.schema) {
348
+ return getTypeScriptType(mediaType.schema, config, mediaType.schema.nullable);
349
+ }
350
+ }
351
+ return "any";
352
+ }
353
+ default:
354
+ return "any";
355
+ }
356
+ }
357
+ __name(getResponseType, "getResponseType");
358
+
359
+ // ../../shared/src/config/constants.ts
360
+ var disableLinting = `/* @ts-nocheck */
361
+ /* eslint-disable */
362
+ /* @noformat */
363
+ /* @formatter:off */
364
+ `;
365
+ var authorComment = `/**
366
+ * Generated by ng-openapi
367
+ `;
368
+ var defaultHeaderComment = disableLinting + authorComment;
369
+ var TYPE_GENERATOR_HEADER_COMMENT = defaultHeaderComment + `* Generated TypeScript interfaces from Swagger specification
370
+ * Do not edit this file manually
371
+ */
372
+ `;
373
+ var SERVICE_INDEX_GENERATOR_HEADER_COMMENT = defaultHeaderComment + `* Generated service exports
374
+ * Do not edit this file manually
375
+ */
376
+ `;
377
+ var MAIN_INDEX_GENERATOR_HEADER_COMMENT = defaultHeaderComment + `* Entrypoint for the client
378
+ * Do not edit this file manually
379
+ */
380
+ `;
381
+ var PROVIDER_GENERATOR_HEADER_COMMENT = defaultHeaderComment + `* Generated provider functions for easy setup
382
+ * Do not edit this file manually
383
+ */
384
+ `;
385
+ var HTTP_RESOURCE_GENERATOR_HEADER_COMMENT = /* @__PURE__ */ __name((resourceName) => defaultHeaderComment + `* \`httpResource\` is still an experimental feature - NOT PRODUCTION READY
386
+ * Generated Angular service for ${resourceName}
387
+ * Do not edit this file manually
388
+ */
389
+ `, "HTTP_RESOURCE_GENERATOR_HEADER_COMMENT");
390
+
391
+ // ../../shared/src/core/swagger-parser.ts
392
+ import * as fs from "fs";
393
+ import * as path from "path";
394
+
395
+ // ../../../node_modules/js-yaml/dist/js-yaml.mjs
396
+ function isNothing(subject) {
397
+ return typeof subject === "undefined" || subject === null;
398
+ }
399
+ __name(isNothing, "isNothing");
400
+ function isObject(subject) {
401
+ return typeof subject === "object" && subject !== null;
402
+ }
403
+ __name(isObject, "isObject");
404
+ function toArray(sequence) {
405
+ if (Array.isArray(sequence)) return sequence;
406
+ else if (isNothing(sequence)) return [];
407
+ return [sequence];
408
+ }
409
+ __name(toArray, "toArray");
410
+ function extend(target, source) {
411
+ var index, length, key, sourceKeys;
412
+ if (source) {
413
+ sourceKeys = Object.keys(source);
414
+ for (index = 0, length = sourceKeys.length; index < length; index += 1) {
415
+ key = sourceKeys[index];
416
+ target[key] = source[key];
417
+ }
418
+ }
419
+ return target;
420
+ }
421
+ __name(extend, "extend");
422
+ function repeat(string, count) {
423
+ var result = "", cycle;
424
+ for (cycle = 0; cycle < count; cycle += 1) {
425
+ result += string;
426
+ }
427
+ return result;
428
+ }
429
+ __name(repeat, "repeat");
430
+ function isNegativeZero(number) {
431
+ return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
432
+ }
433
+ __name(isNegativeZero, "isNegativeZero");
434
+ var isNothing_1 = isNothing;
435
+ var isObject_1 = isObject;
436
+ var toArray_1 = toArray;
437
+ var repeat_1 = repeat;
438
+ var isNegativeZero_1 = isNegativeZero;
439
+ var extend_1 = extend;
440
+ var common = {
441
+ isNothing: isNothing_1,
442
+ isObject: isObject_1,
443
+ toArray: toArray_1,
444
+ repeat: repeat_1,
445
+ isNegativeZero: isNegativeZero_1,
446
+ extend: extend_1
447
+ };
448
+ function formatError(exception2, compact) {
449
+ var where = "", message = exception2.reason || "(unknown reason)";
450
+ if (!exception2.mark) return message;
451
+ if (exception2.mark.name) {
452
+ where += 'in "' + exception2.mark.name + '" ';
453
+ }
454
+ where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
455
+ if (!compact && exception2.mark.snippet) {
456
+ where += "\n\n" + exception2.mark.snippet;
457
+ }
458
+ return message + " " + where;
459
+ }
460
+ __name(formatError, "formatError");
461
+ function YAMLException$1(reason, mark) {
462
+ Error.call(this);
463
+ this.name = "YAMLException";
464
+ this.reason = reason;
465
+ this.mark = mark;
466
+ this.message = formatError(this, false);
467
+ if (Error.captureStackTrace) {
468
+ Error.captureStackTrace(this, this.constructor);
469
+ } else {
470
+ this.stack = new Error().stack || "";
471
+ }
472
+ }
473
+ __name(YAMLException$1, "YAMLException$1");
474
+ YAMLException$1.prototype = Object.create(Error.prototype);
475
+ YAMLException$1.prototype.constructor = YAMLException$1;
476
+ YAMLException$1.prototype.toString = /* @__PURE__ */ __name(function toString(compact) {
477
+ return this.name + ": " + formatError(this, compact);
478
+ }, "toString");
479
+ var exception = YAMLException$1;
480
+ function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
481
+ var head = "";
482
+ var tail = "";
483
+ var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
484
+ if (position - lineStart > maxHalfLength) {
485
+ head = " ... ";
486
+ lineStart = position - maxHalfLength + head.length;
487
+ }
488
+ if (lineEnd - position > maxHalfLength) {
489
+ tail = " ...";
490
+ lineEnd = position + maxHalfLength - tail.length;
491
+ }
492
+ return {
493
+ str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
494
+ pos: position - lineStart + head.length
495
+ // relative position
496
+ };
497
+ }
498
+ __name(getLine, "getLine");
499
+ function padStart(string, max) {
500
+ return common.repeat(" ", max - string.length) + string;
501
+ }
502
+ __name(padStart, "padStart");
503
+ function makeSnippet(mark, options) {
504
+ options = Object.create(options || null);
505
+ if (!mark.buffer) return null;
506
+ if (!options.maxLength) options.maxLength = 79;
507
+ if (typeof options.indent !== "number") options.indent = 1;
508
+ if (typeof options.linesBefore !== "number") options.linesBefore = 3;
509
+ if (typeof options.linesAfter !== "number") options.linesAfter = 2;
510
+ var re = /\r?\n|\r|\0/g;
511
+ var lineStarts = [0];
512
+ var lineEnds = [];
513
+ var match;
514
+ var foundLineNo = -1;
515
+ while (match = re.exec(mark.buffer)) {
516
+ lineEnds.push(match.index);
517
+ lineStarts.push(match.index + match[0].length);
518
+ if (mark.position <= match.index && foundLineNo < 0) {
519
+ foundLineNo = lineStarts.length - 2;
520
+ }
521
+ }
522
+ if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
523
+ var result = "", i, line;
524
+ var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
525
+ var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
526
+ for (i = 1; i <= options.linesBefore; i++) {
527
+ if (foundLineNo - i < 0) break;
528
+ line = getLine(
529
+ mark.buffer,
530
+ lineStarts[foundLineNo - i],
531
+ lineEnds[foundLineNo - i],
532
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
533
+ maxLineLength
534
+ );
535
+ result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
536
+ }
537
+ line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
538
+ result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
539
+ result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
540
+ for (i = 1; i <= options.linesAfter; i++) {
541
+ if (foundLineNo + i >= lineEnds.length) break;
542
+ line = getLine(
543
+ mark.buffer,
544
+ lineStarts[foundLineNo + i],
545
+ lineEnds[foundLineNo + i],
546
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
547
+ maxLineLength
548
+ );
549
+ result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
550
+ }
551
+ return result.replace(/\n$/, "");
552
+ }
553
+ __name(makeSnippet, "makeSnippet");
554
+ var snippet = makeSnippet;
555
+ var TYPE_CONSTRUCTOR_OPTIONS = [
556
+ "kind",
557
+ "multi",
558
+ "resolve",
559
+ "construct",
560
+ "instanceOf",
561
+ "predicate",
562
+ "represent",
563
+ "representName",
564
+ "defaultStyle",
565
+ "styleAliases"
566
+ ];
567
+ var YAML_NODE_KINDS = [
568
+ "scalar",
569
+ "sequence",
570
+ "mapping"
571
+ ];
572
+ function compileStyleAliases(map2) {
573
+ var result = {};
574
+ if (map2 !== null) {
575
+ Object.keys(map2).forEach(function(style) {
576
+ map2[style].forEach(function(alias) {
577
+ result[String(alias)] = style;
578
+ });
579
+ });
580
+ }
581
+ return result;
582
+ }
583
+ __name(compileStyleAliases, "compileStyleAliases");
584
+ function Type$1(tag, options) {
585
+ options = options || {};
586
+ Object.keys(options).forEach(function(name) {
587
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
588
+ throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
589
+ }
590
+ });
591
+ this.options = options;
592
+ this.tag = tag;
593
+ this.kind = options["kind"] || null;
594
+ this.resolve = options["resolve"] || function() {
595
+ return true;
596
+ };
597
+ this.construct = options["construct"] || function(data) {
598
+ return data;
599
+ };
600
+ this.instanceOf = options["instanceOf"] || null;
601
+ this.predicate = options["predicate"] || null;
602
+ this.represent = options["represent"] || null;
603
+ this.representName = options["representName"] || null;
604
+ this.defaultStyle = options["defaultStyle"] || null;
605
+ this.multi = options["multi"] || false;
606
+ this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
607
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
608
+ throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
609
+ }
610
+ }
611
+ __name(Type$1, "Type$1");
612
+ var type = Type$1;
613
+ function compileList(schema2, name) {
614
+ var result = [];
615
+ schema2[name].forEach(function(currentType) {
616
+ var newIndex = result.length;
617
+ result.forEach(function(previousType, previousIndex) {
618
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
619
+ newIndex = previousIndex;
620
+ }
621
+ });
622
+ result[newIndex] = currentType;
623
+ });
624
+ return result;
625
+ }
626
+ __name(compileList, "compileList");
627
+ function compileMap() {
628
+ var result = {
629
+ scalar: {},
630
+ sequence: {},
631
+ mapping: {},
632
+ fallback: {},
633
+ multi: {
634
+ scalar: [],
635
+ sequence: [],
636
+ mapping: [],
637
+ fallback: []
638
+ }
639
+ }, index, length;
640
+ function collectType(type2) {
641
+ if (type2.multi) {
642
+ result.multi[type2.kind].push(type2);
643
+ result.multi["fallback"].push(type2);
644
+ } else {
645
+ result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
646
+ }
647
+ }
648
+ __name(collectType, "collectType");
649
+ for (index = 0, length = arguments.length; index < length; index += 1) {
650
+ arguments[index].forEach(collectType);
651
+ }
652
+ return result;
653
+ }
654
+ __name(compileMap, "compileMap");
655
+ function Schema$1(definition) {
656
+ return this.extend(definition);
657
+ }
658
+ __name(Schema$1, "Schema$1");
659
+ Schema$1.prototype.extend = /* @__PURE__ */ __name(function extend2(definition) {
660
+ var implicit = [];
661
+ var explicit = [];
662
+ if (definition instanceof type) {
663
+ explicit.push(definition);
664
+ } else if (Array.isArray(definition)) {
665
+ explicit = explicit.concat(definition);
666
+ } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
667
+ if (definition.implicit) implicit = implicit.concat(definition.implicit);
668
+ if (definition.explicit) explicit = explicit.concat(definition.explicit);
669
+ } else {
670
+ throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
671
+ }
672
+ implicit.forEach(function(type$1) {
673
+ if (!(type$1 instanceof type)) {
674
+ throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
675
+ }
676
+ if (type$1.loadKind && type$1.loadKind !== "scalar") {
677
+ throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
678
+ }
679
+ if (type$1.multi) {
680
+ throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
681
+ }
682
+ });
683
+ explicit.forEach(function(type$1) {
684
+ if (!(type$1 instanceof type)) {
685
+ throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
686
+ }
687
+ });
688
+ var result = Object.create(Schema$1.prototype);
689
+ result.implicit = (this.implicit || []).concat(implicit);
690
+ result.explicit = (this.explicit || []).concat(explicit);
691
+ result.compiledImplicit = compileList(result, "implicit");
692
+ result.compiledExplicit = compileList(result, "explicit");
693
+ result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
694
+ return result;
695
+ }, "extend");
696
+ var schema = Schema$1;
697
+ var str = new type("tag:yaml.org,2002:str", {
698
+ kind: "scalar",
699
+ construct: /* @__PURE__ */ __name(function(data) {
700
+ return data !== null ? data : "";
701
+ }, "construct")
702
+ });
703
+ var seq = new type("tag:yaml.org,2002:seq", {
704
+ kind: "sequence",
705
+ construct: /* @__PURE__ */ __name(function(data) {
706
+ return data !== null ? data : [];
707
+ }, "construct")
708
+ });
709
+ var map = new type("tag:yaml.org,2002:map", {
710
+ kind: "mapping",
711
+ construct: /* @__PURE__ */ __name(function(data) {
712
+ return data !== null ? data : {};
713
+ }, "construct")
714
+ });
715
+ var failsafe = new schema({
716
+ explicit: [
717
+ str,
718
+ seq,
719
+ map
720
+ ]
721
+ });
722
+ function resolveYamlNull(data) {
723
+ if (data === null) return true;
724
+ var max = data.length;
725
+ return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
726
+ }
727
+ __name(resolveYamlNull, "resolveYamlNull");
728
+ function constructYamlNull() {
729
+ return null;
730
+ }
731
+ __name(constructYamlNull, "constructYamlNull");
732
+ function isNull(object) {
733
+ return object === null;
734
+ }
735
+ __name(isNull, "isNull");
736
+ var _null = new type("tag:yaml.org,2002:null", {
737
+ kind: "scalar",
738
+ resolve: resolveYamlNull,
739
+ construct: constructYamlNull,
740
+ predicate: isNull,
741
+ represent: {
742
+ canonical: /* @__PURE__ */ __name(function() {
743
+ return "~";
744
+ }, "canonical"),
745
+ lowercase: /* @__PURE__ */ __name(function() {
746
+ return "null";
747
+ }, "lowercase"),
748
+ uppercase: /* @__PURE__ */ __name(function() {
749
+ return "NULL";
750
+ }, "uppercase"),
751
+ camelcase: /* @__PURE__ */ __name(function() {
752
+ return "Null";
753
+ }, "camelcase"),
754
+ empty: /* @__PURE__ */ __name(function() {
755
+ return "";
756
+ }, "empty")
757
+ },
758
+ defaultStyle: "lowercase"
759
+ });
760
+ function resolveYamlBoolean(data) {
761
+ if (data === null) return false;
762
+ var max = data.length;
763
+ return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
764
+ }
765
+ __name(resolveYamlBoolean, "resolveYamlBoolean");
766
+ function constructYamlBoolean(data) {
767
+ return data === "true" || data === "True" || data === "TRUE";
768
+ }
769
+ __name(constructYamlBoolean, "constructYamlBoolean");
770
+ function isBoolean(object) {
771
+ return Object.prototype.toString.call(object) === "[object Boolean]";
772
+ }
773
+ __name(isBoolean, "isBoolean");
774
+ var bool = new type("tag:yaml.org,2002:bool", {
775
+ kind: "scalar",
776
+ resolve: resolveYamlBoolean,
777
+ construct: constructYamlBoolean,
778
+ predicate: isBoolean,
779
+ represent: {
780
+ lowercase: /* @__PURE__ */ __name(function(object) {
781
+ return object ? "true" : "false";
782
+ }, "lowercase"),
783
+ uppercase: /* @__PURE__ */ __name(function(object) {
784
+ return object ? "TRUE" : "FALSE";
785
+ }, "uppercase"),
786
+ camelcase: /* @__PURE__ */ __name(function(object) {
787
+ return object ? "True" : "False";
788
+ }, "camelcase")
789
+ },
790
+ defaultStyle: "lowercase"
791
+ });
792
+ function isHexCode(c) {
793
+ return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
794
+ }
795
+ __name(isHexCode, "isHexCode");
796
+ function isOctCode(c) {
797
+ return 48 <= c && c <= 55;
798
+ }
799
+ __name(isOctCode, "isOctCode");
800
+ function isDecCode(c) {
801
+ return 48 <= c && c <= 57;
802
+ }
803
+ __name(isDecCode, "isDecCode");
804
+ function resolveYamlInteger(data) {
805
+ if (data === null) return false;
806
+ var max = data.length, index = 0, hasDigits = false, ch;
807
+ if (!max) return false;
808
+ ch = data[index];
809
+ if (ch === "-" || ch === "+") {
810
+ ch = data[++index];
811
+ }
812
+ if (ch === "0") {
813
+ if (index + 1 === max) return true;
814
+ ch = data[++index];
815
+ if (ch === "b") {
816
+ index++;
817
+ for (; index < max; index++) {
818
+ ch = data[index];
819
+ if (ch === "_") continue;
820
+ if (ch !== "0" && ch !== "1") return false;
821
+ hasDigits = true;
822
+ }
823
+ return hasDigits && ch !== "_";
824
+ }
825
+ if (ch === "x") {
826
+ index++;
827
+ for (; index < max; index++) {
828
+ ch = data[index];
829
+ if (ch === "_") continue;
830
+ if (!isHexCode(data.charCodeAt(index))) return false;
831
+ hasDigits = true;
832
+ }
833
+ return hasDigits && ch !== "_";
834
+ }
835
+ if (ch === "o") {
836
+ index++;
837
+ for (; index < max; index++) {
838
+ ch = data[index];
839
+ if (ch === "_") continue;
840
+ if (!isOctCode(data.charCodeAt(index))) return false;
841
+ hasDigits = true;
842
+ }
843
+ return hasDigits && ch !== "_";
844
+ }
845
+ }
846
+ if (ch === "_") return false;
847
+ for (; index < max; index++) {
848
+ ch = data[index];
849
+ if (ch === "_") continue;
850
+ if (!isDecCode(data.charCodeAt(index))) {
851
+ return false;
852
+ }
853
+ hasDigits = true;
854
+ }
855
+ if (!hasDigits || ch === "_") return false;
856
+ return true;
857
+ }
858
+ __name(resolveYamlInteger, "resolveYamlInteger");
859
+ function constructYamlInteger(data) {
860
+ var value = data, sign = 1, ch;
861
+ if (value.indexOf("_") !== -1) {
862
+ value = value.replace(/_/g, "");
863
+ }
864
+ ch = value[0];
865
+ if (ch === "-" || ch === "+") {
866
+ if (ch === "-") sign = -1;
867
+ value = value.slice(1);
868
+ ch = value[0];
869
+ }
870
+ if (value === "0") return 0;
871
+ if (ch === "0") {
872
+ if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
873
+ if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
874
+ if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
875
+ }
876
+ return sign * parseInt(value, 10);
877
+ }
878
+ __name(constructYamlInteger, "constructYamlInteger");
879
+ function isInteger(object) {
880
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
881
+ }
882
+ __name(isInteger, "isInteger");
883
+ var int = new type("tag:yaml.org,2002:int", {
884
+ kind: "scalar",
885
+ resolve: resolveYamlInteger,
886
+ construct: constructYamlInteger,
887
+ predicate: isInteger,
888
+ represent: {
889
+ binary: /* @__PURE__ */ __name(function(obj) {
890
+ return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
891
+ }, "binary"),
892
+ octal: /* @__PURE__ */ __name(function(obj) {
893
+ return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
894
+ }, "octal"),
895
+ decimal: /* @__PURE__ */ __name(function(obj) {
896
+ return obj.toString(10);
897
+ }, "decimal"),
898
+ /* eslint-disable max-len */
899
+ hexadecimal: /* @__PURE__ */ __name(function(obj) {
900
+ return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
901
+ }, "hexadecimal")
902
+ },
903
+ defaultStyle: "decimal",
904
+ styleAliases: {
905
+ binary: [2, "bin"],
906
+ octal: [8, "oct"],
907
+ decimal: [10, "dec"],
908
+ hexadecimal: [16, "hex"]
909
+ }
910
+ });
911
+ var YAML_FLOAT_PATTERN = new RegExp(
912
+ // 2.5e4, 2.5 and integers
913
+ "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
914
+ );
915
+ function resolveYamlFloat(data) {
916
+ if (data === null) return false;
917
+ if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
918
+ // Probably should update regexp & check speed
919
+ data[data.length - 1] === "_") {
920
+ return false;
921
+ }
922
+ return true;
923
+ }
924
+ __name(resolveYamlFloat, "resolveYamlFloat");
925
+ function constructYamlFloat(data) {
926
+ var value, sign;
927
+ value = data.replace(/_/g, "").toLowerCase();
928
+ sign = value[0] === "-" ? -1 : 1;
929
+ if ("+-".indexOf(value[0]) >= 0) {
930
+ value = value.slice(1);
931
+ }
932
+ if (value === ".inf") {
933
+ return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
934
+ } else if (value === ".nan") {
935
+ return NaN;
936
+ }
937
+ return sign * parseFloat(value, 10);
938
+ }
939
+ __name(constructYamlFloat, "constructYamlFloat");
940
+ var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
941
+ function representYamlFloat(object, style) {
942
+ var res;
943
+ if (isNaN(object)) {
944
+ switch (style) {
945
+ case "lowercase":
946
+ return ".nan";
947
+ case "uppercase":
948
+ return ".NAN";
949
+ case "camelcase":
950
+ return ".NaN";
951
+ }
952
+ } else if (Number.POSITIVE_INFINITY === object) {
953
+ switch (style) {
954
+ case "lowercase":
955
+ return ".inf";
956
+ case "uppercase":
957
+ return ".INF";
958
+ case "camelcase":
959
+ return ".Inf";
960
+ }
961
+ } else if (Number.NEGATIVE_INFINITY === object) {
962
+ switch (style) {
963
+ case "lowercase":
964
+ return "-.inf";
965
+ case "uppercase":
966
+ return "-.INF";
967
+ case "camelcase":
968
+ return "-.Inf";
969
+ }
970
+ } else if (common.isNegativeZero(object)) {
971
+ return "-0.0";
972
+ }
973
+ res = object.toString(10);
974
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
975
+ }
976
+ __name(representYamlFloat, "representYamlFloat");
977
+ function isFloat(object) {
978
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
979
+ }
980
+ __name(isFloat, "isFloat");
981
+ var float = new type("tag:yaml.org,2002:float", {
982
+ kind: "scalar",
983
+ resolve: resolveYamlFloat,
984
+ construct: constructYamlFloat,
985
+ predicate: isFloat,
986
+ represent: representYamlFloat,
987
+ defaultStyle: "lowercase"
988
+ });
989
+ var json = failsafe.extend({
990
+ implicit: [
991
+ _null,
992
+ bool,
993
+ int,
994
+ float
995
+ ]
996
+ });
997
+ var core = json;
998
+ var YAML_DATE_REGEXP = new RegExp(
999
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
1000
+ );
1001
+ var YAML_TIMESTAMP_REGEXP = new RegExp(
1002
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"
1003
+ );
1004
+ function resolveYamlTimestamp(data) {
1005
+ if (data === null) return false;
1006
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
1007
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
1008
+ return false;
1009
+ }
1010
+ __name(resolveYamlTimestamp, "resolveYamlTimestamp");
1011
+ function constructYamlTimestamp(data) {
1012
+ var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
1013
+ match = YAML_DATE_REGEXP.exec(data);
1014
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
1015
+ if (match === null) throw new Error("Date resolve error");
1016
+ year = +match[1];
1017
+ month = +match[2] - 1;
1018
+ day = +match[3];
1019
+ if (!match[4]) {
1020
+ return new Date(Date.UTC(year, month, day));
1021
+ }
1022
+ hour = +match[4];
1023
+ minute = +match[5];
1024
+ second = +match[6];
1025
+ if (match[7]) {
1026
+ fraction = match[7].slice(0, 3);
1027
+ while (fraction.length < 3) {
1028
+ fraction += "0";
1029
+ }
1030
+ fraction = +fraction;
1031
+ }
1032
+ if (match[9]) {
1033
+ tz_hour = +match[10];
1034
+ tz_minute = +(match[11] || 0);
1035
+ delta = (tz_hour * 60 + tz_minute) * 6e4;
1036
+ if (match[9] === "-") delta = -delta;
1037
+ }
1038
+ date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
1039
+ if (delta) date.setTime(date.getTime() - delta);
1040
+ return date;
1041
+ }
1042
+ __name(constructYamlTimestamp, "constructYamlTimestamp");
1043
+ function representYamlTimestamp(object) {
1044
+ return object.toISOString();
1045
+ }
1046
+ __name(representYamlTimestamp, "representYamlTimestamp");
1047
+ var timestamp = new type("tag:yaml.org,2002:timestamp", {
1048
+ kind: "scalar",
1049
+ resolve: resolveYamlTimestamp,
1050
+ construct: constructYamlTimestamp,
1051
+ instanceOf: Date,
1052
+ represent: representYamlTimestamp
1053
+ });
1054
+ function resolveYamlMerge(data) {
1055
+ return data === "<<" || data === null;
1056
+ }
1057
+ __name(resolveYamlMerge, "resolveYamlMerge");
1058
+ var merge = new type("tag:yaml.org,2002:merge", {
1059
+ kind: "scalar",
1060
+ resolve: resolveYamlMerge
1061
+ });
1062
+ var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
1063
+ function resolveYamlBinary(data) {
1064
+ if (data === null) return false;
1065
+ var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
1066
+ for (idx = 0; idx < max; idx++) {
1067
+ code = map2.indexOf(data.charAt(idx));
1068
+ if (code > 64) continue;
1069
+ if (code < 0) return false;
1070
+ bitlen += 6;
1071
+ }
1072
+ return bitlen % 8 === 0;
1073
+ }
1074
+ __name(resolveYamlBinary, "resolveYamlBinary");
1075
+ function constructYamlBinary(data) {
1076
+ var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
1077
+ for (idx = 0; idx < max; idx++) {
1078
+ if (idx % 4 === 0 && idx) {
1079
+ result.push(bits >> 16 & 255);
1080
+ result.push(bits >> 8 & 255);
1081
+ result.push(bits & 255);
1082
+ }
1083
+ bits = bits << 6 | map2.indexOf(input.charAt(idx));
1084
+ }
1085
+ tailbits = max % 4 * 6;
1086
+ if (tailbits === 0) {
1087
+ result.push(bits >> 16 & 255);
1088
+ result.push(bits >> 8 & 255);
1089
+ result.push(bits & 255);
1090
+ } else if (tailbits === 18) {
1091
+ result.push(bits >> 10 & 255);
1092
+ result.push(bits >> 2 & 255);
1093
+ } else if (tailbits === 12) {
1094
+ result.push(bits >> 4 & 255);
1095
+ }
1096
+ return new Uint8Array(result);
1097
+ }
1098
+ __name(constructYamlBinary, "constructYamlBinary");
1099
+ function representYamlBinary(object) {
1100
+ var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
1101
+ for (idx = 0; idx < max; idx++) {
1102
+ if (idx % 3 === 0 && idx) {
1103
+ result += map2[bits >> 18 & 63];
1104
+ result += map2[bits >> 12 & 63];
1105
+ result += map2[bits >> 6 & 63];
1106
+ result += map2[bits & 63];
1107
+ }
1108
+ bits = (bits << 8) + object[idx];
1109
+ }
1110
+ tail = max % 3;
1111
+ if (tail === 0) {
1112
+ result += map2[bits >> 18 & 63];
1113
+ result += map2[bits >> 12 & 63];
1114
+ result += map2[bits >> 6 & 63];
1115
+ result += map2[bits & 63];
1116
+ } else if (tail === 2) {
1117
+ result += map2[bits >> 10 & 63];
1118
+ result += map2[bits >> 4 & 63];
1119
+ result += map2[bits << 2 & 63];
1120
+ result += map2[64];
1121
+ } else if (tail === 1) {
1122
+ result += map2[bits >> 2 & 63];
1123
+ result += map2[bits << 4 & 63];
1124
+ result += map2[64];
1125
+ result += map2[64];
1126
+ }
1127
+ return result;
1128
+ }
1129
+ __name(representYamlBinary, "representYamlBinary");
1130
+ function isBinary(obj) {
1131
+ return Object.prototype.toString.call(obj) === "[object Uint8Array]";
1132
+ }
1133
+ __name(isBinary, "isBinary");
1134
+ var binary = new type("tag:yaml.org,2002:binary", {
1135
+ kind: "scalar",
1136
+ resolve: resolveYamlBinary,
1137
+ construct: constructYamlBinary,
1138
+ predicate: isBinary,
1139
+ represent: representYamlBinary
1140
+ });
1141
+ var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
1142
+ var _toString$2 = Object.prototype.toString;
1143
+ function resolveYamlOmap(data) {
1144
+ if (data === null) return true;
1145
+ var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
1146
+ for (index = 0, length = object.length; index < length; index += 1) {
1147
+ pair = object[index];
1148
+ pairHasKey = false;
1149
+ if (_toString$2.call(pair) !== "[object Object]") return false;
1150
+ for (pairKey in pair) {
1151
+ if (_hasOwnProperty$3.call(pair, pairKey)) {
1152
+ if (!pairHasKey) pairHasKey = true;
1153
+ else return false;
1154
+ }
1155
+ }
1156
+ if (!pairHasKey) return false;
1157
+ if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
1158
+ else return false;
1159
+ }
1160
+ return true;
1161
+ }
1162
+ __name(resolveYamlOmap, "resolveYamlOmap");
1163
+ function constructYamlOmap(data) {
1164
+ return data !== null ? data : [];
1165
+ }
1166
+ __name(constructYamlOmap, "constructYamlOmap");
1167
+ var omap = new type("tag:yaml.org,2002:omap", {
1168
+ kind: "sequence",
1169
+ resolve: resolveYamlOmap,
1170
+ construct: constructYamlOmap
1171
+ });
1172
+ var _toString$1 = Object.prototype.toString;
1173
+ function resolveYamlPairs(data) {
1174
+ if (data === null) return true;
1175
+ var index, length, pair, keys, result, object = data;
1176
+ result = new Array(object.length);
1177
+ for (index = 0, length = object.length; index < length; index += 1) {
1178
+ pair = object[index];
1179
+ if (_toString$1.call(pair) !== "[object Object]") return false;
1180
+ keys = Object.keys(pair);
1181
+ if (keys.length !== 1) return false;
1182
+ result[index] = [keys[0], pair[keys[0]]];
1183
+ }
1184
+ return true;
1185
+ }
1186
+ __name(resolveYamlPairs, "resolveYamlPairs");
1187
+ function constructYamlPairs(data) {
1188
+ if (data === null) return [];
1189
+ var index, length, pair, keys, result, object = data;
1190
+ result = new Array(object.length);
1191
+ for (index = 0, length = object.length; index < length; index += 1) {
1192
+ pair = object[index];
1193
+ keys = Object.keys(pair);
1194
+ result[index] = [keys[0], pair[keys[0]]];
1195
+ }
1196
+ return result;
1197
+ }
1198
+ __name(constructYamlPairs, "constructYamlPairs");
1199
+ var pairs = new type("tag:yaml.org,2002:pairs", {
1200
+ kind: "sequence",
1201
+ resolve: resolveYamlPairs,
1202
+ construct: constructYamlPairs
1203
+ });
1204
+ var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1205
+ function resolveYamlSet(data) {
1206
+ if (data === null) return true;
1207
+ var key, object = data;
1208
+ for (key in object) {
1209
+ if (_hasOwnProperty$2.call(object, key)) {
1210
+ if (object[key] !== null) return false;
1211
+ }
1212
+ }
1213
+ return true;
1214
+ }
1215
+ __name(resolveYamlSet, "resolveYamlSet");
1216
+ function constructYamlSet(data) {
1217
+ return data !== null ? data : {};
1218
+ }
1219
+ __name(constructYamlSet, "constructYamlSet");
1220
+ var set = new type("tag:yaml.org,2002:set", {
1221
+ kind: "mapping",
1222
+ resolve: resolveYamlSet,
1223
+ construct: constructYamlSet
1224
+ });
1225
+ var _default = core.extend({
1226
+ implicit: [
1227
+ timestamp,
1228
+ merge
1229
+ ],
1230
+ explicit: [
1231
+ binary,
1232
+ omap,
1233
+ pairs,
1234
+ set
1235
+ ]
1236
+ });
1237
+ var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1238
+ var CONTEXT_FLOW_IN = 1;
1239
+ var CONTEXT_FLOW_OUT = 2;
1240
+ var CONTEXT_BLOCK_IN = 3;
1241
+ var CONTEXT_BLOCK_OUT = 4;
1242
+ var CHOMPING_CLIP = 1;
1243
+ var CHOMPING_STRIP = 2;
1244
+ var CHOMPING_KEEP = 3;
1245
+ var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
1246
+ var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
1247
+ var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
1248
+ var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
1249
+ var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
1250
+ function _class(obj) {
1251
+ return Object.prototype.toString.call(obj);
1252
+ }
1253
+ __name(_class, "_class");
1254
+ function is_EOL(c) {
1255
+ return c === 10 || c === 13;
1256
+ }
1257
+ __name(is_EOL, "is_EOL");
1258
+ function is_WHITE_SPACE(c) {
1259
+ return c === 9 || c === 32;
1260
+ }
1261
+ __name(is_WHITE_SPACE, "is_WHITE_SPACE");
1262
+ function is_WS_OR_EOL(c) {
1263
+ return c === 9 || c === 32 || c === 10 || c === 13;
1264
+ }
1265
+ __name(is_WS_OR_EOL, "is_WS_OR_EOL");
1266
+ function is_FLOW_INDICATOR(c) {
1267
+ return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
1268
+ }
1269
+ __name(is_FLOW_INDICATOR, "is_FLOW_INDICATOR");
1270
+ function fromHexCode(c) {
1271
+ var lc;
1272
+ if (48 <= c && c <= 57) {
1273
+ return c - 48;
1274
+ }
1275
+ lc = c | 32;
1276
+ if (97 <= lc && lc <= 102) {
1277
+ return lc - 97 + 10;
1278
+ }
1279
+ return -1;
1280
+ }
1281
+ __name(fromHexCode, "fromHexCode");
1282
+ function escapedHexLen(c) {
1283
+ if (c === 120) {
1284
+ return 2;
1285
+ }
1286
+ if (c === 117) {
1287
+ return 4;
1288
+ }
1289
+ if (c === 85) {
1290
+ return 8;
1291
+ }
1292
+ return 0;
1293
+ }
1294
+ __name(escapedHexLen, "escapedHexLen");
1295
+ function fromDecimalCode(c) {
1296
+ if (48 <= c && c <= 57) {
1297
+ return c - 48;
1298
+ }
1299
+ return -1;
1300
+ }
1301
+ __name(fromDecimalCode, "fromDecimalCode");
1302
+ function simpleEscapeSequence(c) {
1303
+ return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
1304
+ }
1305
+ __name(simpleEscapeSequence, "simpleEscapeSequence");
1306
+ function charFromCodepoint(c) {
1307
+ if (c <= 65535) {
1308
+ return String.fromCharCode(c);
1309
+ }
1310
+ return String.fromCharCode(
1311
+ (c - 65536 >> 10) + 55296,
1312
+ (c - 65536 & 1023) + 56320
1313
+ );
1314
+ }
1315
+ __name(charFromCodepoint, "charFromCodepoint");
1316
+ var simpleEscapeCheck = new Array(256);
1317
+ var simpleEscapeMap = new Array(256);
1318
+ for (i = 0; i < 256; i++) {
1319
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
1320
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
1321
+ }
1322
+ var i;
1323
+ function State$1(input, options) {
1324
+ this.input = input;
1325
+ this.filename = options["filename"] || null;
1326
+ this.schema = options["schema"] || _default;
1327
+ this.onWarning = options["onWarning"] || null;
1328
+ this.legacy = options["legacy"] || false;
1329
+ this.json = options["json"] || false;
1330
+ this.listener = options["listener"] || null;
1331
+ this.implicitTypes = this.schema.compiledImplicit;
1332
+ this.typeMap = this.schema.compiledTypeMap;
1333
+ this.length = input.length;
1334
+ this.position = 0;
1335
+ this.line = 0;
1336
+ this.lineStart = 0;
1337
+ this.lineIndent = 0;
1338
+ this.firstTabInLine = -1;
1339
+ this.documents = [];
1340
+ }
1341
+ __name(State$1, "State$1");
1342
+ function generateError(state, message) {
1343
+ var mark = {
1344
+ name: state.filename,
1345
+ buffer: state.input.slice(0, -1),
1346
+ // omit trailing \0
1347
+ position: state.position,
1348
+ line: state.line,
1349
+ column: state.position - state.lineStart
1350
+ };
1351
+ mark.snippet = snippet(mark);
1352
+ return new exception(message, mark);
1353
+ }
1354
+ __name(generateError, "generateError");
1355
+ function throwError(state, message) {
1356
+ throw generateError(state, message);
1357
+ }
1358
+ __name(throwError, "throwError");
1359
+ function throwWarning(state, message) {
1360
+ if (state.onWarning) {
1361
+ state.onWarning.call(null, generateError(state, message));
1362
+ }
1363
+ }
1364
+ __name(throwWarning, "throwWarning");
1365
+ var directiveHandlers = {
1366
+ YAML: /* @__PURE__ */ __name(function handleYamlDirective(state, name, args) {
1367
+ var match, major, minor;
1368
+ if (state.version !== null) {
1369
+ throwError(state, "duplication of %YAML directive");
1370
+ }
1371
+ if (args.length !== 1) {
1372
+ throwError(state, "YAML directive accepts exactly one argument");
1373
+ }
1374
+ match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1375
+ if (match === null) {
1376
+ throwError(state, "ill-formed argument of the YAML directive");
1377
+ }
1378
+ major = parseInt(match[1], 10);
1379
+ minor = parseInt(match[2], 10);
1380
+ if (major !== 1) {
1381
+ throwError(state, "unacceptable YAML version of the document");
1382
+ }
1383
+ state.version = args[0];
1384
+ state.checkLineBreaks = minor < 2;
1385
+ if (minor !== 1 && minor !== 2) {
1386
+ throwWarning(state, "unsupported YAML version of the document");
1387
+ }
1388
+ }, "handleYamlDirective"),
1389
+ TAG: /* @__PURE__ */ __name(function handleTagDirective(state, name, args) {
1390
+ var handle, prefix;
1391
+ if (args.length !== 2) {
1392
+ throwError(state, "TAG directive accepts exactly two arguments");
1393
+ }
1394
+ handle = args[0];
1395
+ prefix = args[1];
1396
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
1397
+ throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
1398
+ }
1399
+ if (_hasOwnProperty$1.call(state.tagMap, handle)) {
1400
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1401
+ }
1402
+ if (!PATTERN_TAG_URI.test(prefix)) {
1403
+ throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
1404
+ }
1405
+ try {
1406
+ prefix = decodeURIComponent(prefix);
1407
+ } catch (err) {
1408
+ throwError(state, "tag prefix is malformed: " + prefix);
1409
+ }
1410
+ state.tagMap[handle] = prefix;
1411
+ }, "handleTagDirective")
1412
+ };
1413
+ function captureSegment(state, start, end, checkJson) {
1414
+ var _position, _length, _character, _result;
1415
+ if (start < end) {
1416
+ _result = state.input.slice(start, end);
1417
+ if (checkJson) {
1418
+ for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
1419
+ _character = _result.charCodeAt(_position);
1420
+ if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
1421
+ throwError(state, "expected valid JSON character");
1422
+ }
1423
+ }
1424
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1425
+ throwError(state, "the stream contains non-printable characters");
1426
+ }
1427
+ state.result += _result;
1428
+ }
1429
+ }
1430
+ __name(captureSegment, "captureSegment");
1431
+ function mergeMappings(state, destination, source, overridableKeys) {
1432
+ var sourceKeys, key, index, quantity;
1433
+ if (!common.isObject(source)) {
1434
+ throwError(state, "cannot merge mappings; the provided source object is unacceptable");
1435
+ }
1436
+ sourceKeys = Object.keys(source);
1437
+ for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1438
+ key = sourceKeys[index];
1439
+ if (!_hasOwnProperty$1.call(destination, key)) {
1440
+ destination[key] = source[key];
1441
+ overridableKeys[key] = true;
1442
+ }
1443
+ }
1444
+ }
1445
+ __name(mergeMappings, "mergeMappings");
1446
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
1447
+ var index, quantity;
1448
+ if (Array.isArray(keyNode)) {
1449
+ keyNode = Array.prototype.slice.call(keyNode);
1450
+ for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
1451
+ if (Array.isArray(keyNode[index])) {
1452
+ throwError(state, "nested arrays are not supported inside keys");
1453
+ }
1454
+ if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
1455
+ keyNode[index] = "[object Object]";
1456
+ }
1457
+ }
1458
+ }
1459
+ if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
1460
+ keyNode = "[object Object]";
1461
+ }
1462
+ keyNode = String(keyNode);
1463
+ if (_result === null) {
1464
+ _result = {};
1465
+ }
1466
+ if (keyTag === "tag:yaml.org,2002:merge") {
1467
+ if (Array.isArray(valueNode)) {
1468
+ for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1469
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
1470
+ }
1471
+ } else {
1472
+ mergeMappings(state, _result, valueNode, overridableKeys);
1473
+ }
1474
+ } else {
1475
+ if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
1476
+ state.line = startLine || state.line;
1477
+ state.lineStart = startLineStart || state.lineStart;
1478
+ state.position = startPos || state.position;
1479
+ throwError(state, "duplicated mapping key");
1480
+ }
1481
+ if (keyNode === "__proto__") {
1482
+ Object.defineProperty(_result, keyNode, {
1483
+ configurable: true,
1484
+ enumerable: true,
1485
+ writable: true,
1486
+ value: valueNode
1487
+ });
1488
+ } else {
1489
+ _result[keyNode] = valueNode;
1490
+ }
1491
+ delete overridableKeys[keyNode];
1492
+ }
1493
+ return _result;
1494
+ }
1495
+ __name(storeMappingPair, "storeMappingPair");
1496
+ function readLineBreak(state) {
1497
+ var ch;
1498
+ ch = state.input.charCodeAt(state.position);
1499
+ if (ch === 10) {
1500
+ state.position++;
1501
+ } else if (ch === 13) {
1502
+ state.position++;
1503
+ if (state.input.charCodeAt(state.position) === 10) {
1504
+ state.position++;
1505
+ }
1506
+ } else {
1507
+ throwError(state, "a line break is expected");
1508
+ }
1509
+ state.line += 1;
1510
+ state.lineStart = state.position;
1511
+ state.firstTabInLine = -1;
1512
+ }
1513
+ __name(readLineBreak, "readLineBreak");
1514
+ function skipSeparationSpace(state, allowComments, checkIndent) {
1515
+ var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
1516
+ while (ch !== 0) {
1517
+ while (is_WHITE_SPACE(ch)) {
1518
+ if (ch === 9 && state.firstTabInLine === -1) {
1519
+ state.firstTabInLine = state.position;
1520
+ }
1521
+ ch = state.input.charCodeAt(++state.position);
1522
+ }
1523
+ if (allowComments && ch === 35) {
1524
+ do {
1525
+ ch = state.input.charCodeAt(++state.position);
1526
+ } while (ch !== 10 && ch !== 13 && ch !== 0);
1527
+ }
1528
+ if (is_EOL(ch)) {
1529
+ readLineBreak(state);
1530
+ ch = state.input.charCodeAt(state.position);
1531
+ lineBreaks++;
1532
+ state.lineIndent = 0;
1533
+ while (ch === 32) {
1534
+ state.lineIndent++;
1535
+ ch = state.input.charCodeAt(++state.position);
1536
+ }
1537
+ } else {
1538
+ break;
1539
+ }
1540
+ }
1541
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1542
+ throwWarning(state, "deficient indentation");
1543
+ }
1544
+ return lineBreaks;
1545
+ }
1546
+ __name(skipSeparationSpace, "skipSeparationSpace");
1547
+ function testDocumentSeparator(state) {
1548
+ var _position = state.position, ch;
1549
+ ch = state.input.charCodeAt(_position);
1550
+ if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
1551
+ _position += 3;
1552
+ ch = state.input.charCodeAt(_position);
1553
+ if (ch === 0 || is_WS_OR_EOL(ch)) {
1554
+ return true;
1555
+ }
1556
+ }
1557
+ return false;
1558
+ }
1559
+ __name(testDocumentSeparator, "testDocumentSeparator");
1560
+ function writeFoldedLines(state, count) {
1561
+ if (count === 1) {
1562
+ state.result += " ";
1563
+ } else if (count > 1) {
1564
+ state.result += common.repeat("\n", count - 1);
1565
+ }
1566
+ }
1567
+ __name(writeFoldedLines, "writeFoldedLines");
1568
+ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1569
+ var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
1570
+ ch = state.input.charCodeAt(state.position);
1571
+ if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
1572
+ return false;
1573
+ }
1574
+ if (ch === 63 || ch === 45) {
1575
+ following = state.input.charCodeAt(state.position + 1);
1576
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1577
+ return false;
1578
+ }
1579
+ }
1580
+ state.kind = "scalar";
1581
+ state.result = "";
1582
+ captureStart = captureEnd = state.position;
1583
+ hasPendingContent = false;
1584
+ while (ch !== 0) {
1585
+ if (ch === 58) {
1586
+ following = state.input.charCodeAt(state.position + 1);
1587
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1588
+ break;
1589
+ }
1590
+ } else if (ch === 35) {
1591
+ preceding = state.input.charCodeAt(state.position - 1);
1592
+ if (is_WS_OR_EOL(preceding)) {
1593
+ break;
1594
+ }
1595
+ } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1596
+ break;
1597
+ } else if (is_EOL(ch)) {
1598
+ _line = state.line;
1599
+ _lineStart = state.lineStart;
1600
+ _lineIndent = state.lineIndent;
1601
+ skipSeparationSpace(state, false, -1);
1602
+ if (state.lineIndent >= nodeIndent) {
1603
+ hasPendingContent = true;
1604
+ ch = state.input.charCodeAt(state.position);
1605
+ continue;
1606
+ } else {
1607
+ state.position = captureEnd;
1608
+ state.line = _line;
1609
+ state.lineStart = _lineStart;
1610
+ state.lineIndent = _lineIndent;
1611
+ break;
1612
+ }
1613
+ }
1614
+ if (hasPendingContent) {
1615
+ captureSegment(state, captureStart, captureEnd, false);
1616
+ writeFoldedLines(state, state.line - _line);
1617
+ captureStart = captureEnd = state.position;
1618
+ hasPendingContent = false;
1619
+ }
1620
+ if (!is_WHITE_SPACE(ch)) {
1621
+ captureEnd = state.position + 1;
1622
+ }
1623
+ ch = state.input.charCodeAt(++state.position);
1624
+ }
1625
+ captureSegment(state, captureStart, captureEnd, false);
1626
+ if (state.result) {
1627
+ return true;
1628
+ }
1629
+ state.kind = _kind;
1630
+ state.result = _result;
1631
+ return false;
1632
+ }
1633
+ __name(readPlainScalar, "readPlainScalar");
1634
+ function readSingleQuotedScalar(state, nodeIndent) {
1635
+ var ch, captureStart, captureEnd;
1636
+ ch = state.input.charCodeAt(state.position);
1637
+ if (ch !== 39) {
1638
+ return false;
1639
+ }
1640
+ state.kind = "scalar";
1641
+ state.result = "";
1642
+ state.position++;
1643
+ captureStart = captureEnd = state.position;
1644
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1645
+ if (ch === 39) {
1646
+ captureSegment(state, captureStart, state.position, true);
1647
+ ch = state.input.charCodeAt(++state.position);
1648
+ if (ch === 39) {
1649
+ captureStart = state.position;
1650
+ state.position++;
1651
+ captureEnd = state.position;
1652
+ } else {
1653
+ return true;
1654
+ }
1655
+ } else if (is_EOL(ch)) {
1656
+ captureSegment(state, captureStart, captureEnd, true);
1657
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1658
+ captureStart = captureEnd = state.position;
1659
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1660
+ throwError(state, "unexpected end of the document within a single quoted scalar");
1661
+ } else {
1662
+ state.position++;
1663
+ captureEnd = state.position;
1664
+ }
1665
+ }
1666
+ throwError(state, "unexpected end of the stream within a single quoted scalar");
1667
+ }
1668
+ __name(readSingleQuotedScalar, "readSingleQuotedScalar");
1669
+ function readDoubleQuotedScalar(state, nodeIndent) {
1670
+ var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
1671
+ ch = state.input.charCodeAt(state.position);
1672
+ if (ch !== 34) {
1673
+ return false;
1674
+ }
1675
+ state.kind = "scalar";
1676
+ state.result = "";
1677
+ state.position++;
1678
+ captureStart = captureEnd = state.position;
1679
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1680
+ if (ch === 34) {
1681
+ captureSegment(state, captureStart, state.position, true);
1682
+ state.position++;
1683
+ return true;
1684
+ } else if (ch === 92) {
1685
+ captureSegment(state, captureStart, state.position, true);
1686
+ ch = state.input.charCodeAt(++state.position);
1687
+ if (is_EOL(ch)) {
1688
+ skipSeparationSpace(state, false, nodeIndent);
1689
+ } else if (ch < 256 && simpleEscapeCheck[ch]) {
1690
+ state.result += simpleEscapeMap[ch];
1691
+ state.position++;
1692
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
1693
+ hexLength = tmp;
1694
+ hexResult = 0;
1695
+ for (; hexLength > 0; hexLength--) {
1696
+ ch = state.input.charCodeAt(++state.position);
1697
+ if ((tmp = fromHexCode(ch)) >= 0) {
1698
+ hexResult = (hexResult << 4) + tmp;
1699
+ } else {
1700
+ throwError(state, "expected hexadecimal character");
1701
+ }
1702
+ }
1703
+ state.result += charFromCodepoint(hexResult);
1704
+ state.position++;
1705
+ } else {
1706
+ throwError(state, "unknown escape sequence");
1707
+ }
1708
+ captureStart = captureEnd = state.position;
1709
+ } else if (is_EOL(ch)) {
1710
+ captureSegment(state, captureStart, captureEnd, true);
1711
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1712
+ captureStart = captureEnd = state.position;
1713
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1714
+ throwError(state, "unexpected end of the document within a double quoted scalar");
1715
+ } else {
1716
+ state.position++;
1717
+ captureEnd = state.position;
1718
+ }
1719
+ }
1720
+ throwError(state, "unexpected end of the stream within a double quoted scalar");
1721
+ }
1722
+ __name(readDoubleQuotedScalar, "readDoubleQuotedScalar");
1723
+ function readFlowCollection(state, nodeIndent) {
1724
+ var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
1725
+ ch = state.input.charCodeAt(state.position);
1726
+ if (ch === 91) {
1727
+ terminator = 93;
1728
+ isMapping = false;
1729
+ _result = [];
1730
+ } else if (ch === 123) {
1731
+ terminator = 125;
1732
+ isMapping = true;
1733
+ _result = {};
1734
+ } else {
1735
+ return false;
1736
+ }
1737
+ if (state.anchor !== null) {
1738
+ state.anchorMap[state.anchor] = _result;
1739
+ }
1740
+ ch = state.input.charCodeAt(++state.position);
1741
+ while (ch !== 0) {
1742
+ skipSeparationSpace(state, true, nodeIndent);
1743
+ ch = state.input.charCodeAt(state.position);
1744
+ if (ch === terminator) {
1745
+ state.position++;
1746
+ state.tag = _tag;
1747
+ state.anchor = _anchor;
1748
+ state.kind = isMapping ? "mapping" : "sequence";
1749
+ state.result = _result;
1750
+ return true;
1751
+ } else if (!readNext) {
1752
+ throwError(state, "missed comma between flow collection entries");
1753
+ } else if (ch === 44) {
1754
+ throwError(state, "expected the node content, but found ','");
1755
+ }
1756
+ keyTag = keyNode = valueNode = null;
1757
+ isPair = isExplicitPair = false;
1758
+ if (ch === 63) {
1759
+ following = state.input.charCodeAt(state.position + 1);
1760
+ if (is_WS_OR_EOL(following)) {
1761
+ isPair = isExplicitPair = true;
1762
+ state.position++;
1763
+ skipSeparationSpace(state, true, nodeIndent);
1764
+ }
1765
+ }
1766
+ _line = state.line;
1767
+ _lineStart = state.lineStart;
1768
+ _pos = state.position;
1769
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1770
+ keyTag = state.tag;
1771
+ keyNode = state.result;
1772
+ skipSeparationSpace(state, true, nodeIndent);
1773
+ ch = state.input.charCodeAt(state.position);
1774
+ if ((isExplicitPair || state.line === _line) && ch === 58) {
1775
+ isPair = true;
1776
+ ch = state.input.charCodeAt(++state.position);
1777
+ skipSeparationSpace(state, true, nodeIndent);
1778
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1779
+ valueNode = state.result;
1780
+ }
1781
+ if (isMapping) {
1782
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
1783
+ } else if (isPair) {
1784
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
1785
+ } else {
1786
+ _result.push(keyNode);
1787
+ }
1788
+ skipSeparationSpace(state, true, nodeIndent);
1789
+ ch = state.input.charCodeAt(state.position);
1790
+ if (ch === 44) {
1791
+ readNext = true;
1792
+ ch = state.input.charCodeAt(++state.position);
1793
+ } else {
1794
+ readNext = false;
1795
+ }
1796
+ }
1797
+ throwError(state, "unexpected end of the stream within a flow collection");
1798
+ }
1799
+ __name(readFlowCollection, "readFlowCollection");
1800
+ function readBlockScalar(state, nodeIndent) {
1801
+ var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
1802
+ ch = state.input.charCodeAt(state.position);
1803
+ if (ch === 124) {
1804
+ folding = false;
1805
+ } else if (ch === 62) {
1806
+ folding = true;
1807
+ } else {
1808
+ return false;
1809
+ }
1810
+ state.kind = "scalar";
1811
+ state.result = "";
1812
+ while (ch !== 0) {
1813
+ ch = state.input.charCodeAt(++state.position);
1814
+ if (ch === 43 || ch === 45) {
1815
+ if (CHOMPING_CLIP === chomping) {
1816
+ chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
1817
+ } else {
1818
+ throwError(state, "repeat of a chomping mode identifier");
1819
+ }
1820
+ } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1821
+ if (tmp === 0) {
1822
+ throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
1823
+ } else if (!detectedIndent) {
1824
+ textIndent = nodeIndent + tmp - 1;
1825
+ detectedIndent = true;
1826
+ } else {
1827
+ throwError(state, "repeat of an indentation width identifier");
1828
+ }
1829
+ } else {
1830
+ break;
1831
+ }
1832
+ }
1833
+ if (is_WHITE_SPACE(ch)) {
1834
+ do {
1835
+ ch = state.input.charCodeAt(++state.position);
1836
+ } while (is_WHITE_SPACE(ch));
1837
+ if (ch === 35) {
1838
+ do {
1839
+ ch = state.input.charCodeAt(++state.position);
1840
+ } while (!is_EOL(ch) && ch !== 0);
1841
+ }
1842
+ }
1843
+ while (ch !== 0) {
1844
+ readLineBreak(state);
1845
+ state.lineIndent = 0;
1846
+ ch = state.input.charCodeAt(state.position);
1847
+ while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
1848
+ state.lineIndent++;
1849
+ ch = state.input.charCodeAt(++state.position);
1850
+ }
1851
+ if (!detectedIndent && state.lineIndent > textIndent) {
1852
+ textIndent = state.lineIndent;
1853
+ }
1854
+ if (is_EOL(ch)) {
1855
+ emptyLines++;
1856
+ continue;
1857
+ }
1858
+ if (state.lineIndent < textIndent) {
1859
+ if (chomping === CHOMPING_KEEP) {
1860
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1861
+ } else if (chomping === CHOMPING_CLIP) {
1862
+ if (didReadContent) {
1863
+ state.result += "\n";
1864
+ }
1865
+ }
1866
+ break;
1867
+ }
1868
+ if (folding) {
1869
+ if (is_WHITE_SPACE(ch)) {
1870
+ atMoreIndented = true;
1871
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1872
+ } else if (atMoreIndented) {
1873
+ atMoreIndented = false;
1874
+ state.result += common.repeat("\n", emptyLines + 1);
1875
+ } else if (emptyLines === 0) {
1876
+ if (didReadContent) {
1877
+ state.result += " ";
1878
+ }
1879
+ } else {
1880
+ state.result += common.repeat("\n", emptyLines);
1881
+ }
1882
+ } else {
1883
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1884
+ }
1885
+ didReadContent = true;
1886
+ detectedIndent = true;
1887
+ emptyLines = 0;
1888
+ captureStart = state.position;
1889
+ while (!is_EOL(ch) && ch !== 0) {
1890
+ ch = state.input.charCodeAt(++state.position);
1891
+ }
1892
+ captureSegment(state, captureStart, state.position, false);
1893
+ }
1894
+ return true;
1895
+ }
1896
+ __name(readBlockScalar, "readBlockScalar");
1897
+ function readBlockSequence(state, nodeIndent) {
1898
+ var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
1899
+ if (state.firstTabInLine !== -1) return false;
1900
+ if (state.anchor !== null) {
1901
+ state.anchorMap[state.anchor] = _result;
1902
+ }
1903
+ ch = state.input.charCodeAt(state.position);
1904
+ while (ch !== 0) {
1905
+ if (state.firstTabInLine !== -1) {
1906
+ state.position = state.firstTabInLine;
1907
+ throwError(state, "tab characters must not be used in indentation");
1908
+ }
1909
+ if (ch !== 45) {
1910
+ break;
1911
+ }
1912
+ following = state.input.charCodeAt(state.position + 1);
1913
+ if (!is_WS_OR_EOL(following)) {
1914
+ break;
1915
+ }
1916
+ detected = true;
1917
+ state.position++;
1918
+ if (skipSeparationSpace(state, true, -1)) {
1919
+ if (state.lineIndent <= nodeIndent) {
1920
+ _result.push(null);
1921
+ ch = state.input.charCodeAt(state.position);
1922
+ continue;
1923
+ }
1924
+ }
1925
+ _line = state.line;
1926
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1927
+ _result.push(state.result);
1928
+ skipSeparationSpace(state, true, -1);
1929
+ ch = state.input.charCodeAt(state.position);
1930
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1931
+ throwError(state, "bad indentation of a sequence entry");
1932
+ } else if (state.lineIndent < nodeIndent) {
1933
+ break;
1934
+ }
1935
+ }
1936
+ if (detected) {
1937
+ state.tag = _tag;
1938
+ state.anchor = _anchor;
1939
+ state.kind = "sequence";
1940
+ state.result = _result;
1941
+ return true;
1942
+ }
1943
+ return false;
1944
+ }
1945
+ __name(readBlockSequence, "readBlockSequence");
1946
+ function readBlockMapping(state, nodeIndent, flowIndent) {
1947
+ var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
1948
+ if (state.firstTabInLine !== -1) return false;
1949
+ if (state.anchor !== null) {
1950
+ state.anchorMap[state.anchor] = _result;
1951
+ }
1952
+ ch = state.input.charCodeAt(state.position);
1953
+ while (ch !== 0) {
1954
+ if (!atExplicitKey && state.firstTabInLine !== -1) {
1955
+ state.position = state.firstTabInLine;
1956
+ throwError(state, "tab characters must not be used in indentation");
1957
+ }
1958
+ following = state.input.charCodeAt(state.position + 1);
1959
+ _line = state.line;
1960
+ if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
1961
+ if (ch === 63) {
1962
+ if (atExplicitKey) {
1963
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1964
+ keyTag = keyNode = valueNode = null;
1965
+ }
1966
+ detected = true;
1967
+ atExplicitKey = true;
1968
+ allowCompact = true;
1969
+ } else if (atExplicitKey) {
1970
+ atExplicitKey = false;
1971
+ allowCompact = true;
1972
+ } else {
1973
+ throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
1974
+ }
1975
+ state.position += 1;
1976
+ ch = following;
1977
+ } else {
1978
+ _keyLine = state.line;
1979
+ _keyLineStart = state.lineStart;
1980
+ _keyPos = state.position;
1981
+ if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1982
+ break;
1983
+ }
1984
+ if (state.line === _line) {
1985
+ ch = state.input.charCodeAt(state.position);
1986
+ while (is_WHITE_SPACE(ch)) {
1987
+ ch = state.input.charCodeAt(++state.position);
1988
+ }
1989
+ if (ch === 58) {
1990
+ ch = state.input.charCodeAt(++state.position);
1991
+ if (!is_WS_OR_EOL(ch)) {
1992
+ throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
1993
+ }
1994
+ if (atExplicitKey) {
1995
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1996
+ keyTag = keyNode = valueNode = null;
1997
+ }
1998
+ detected = true;
1999
+ atExplicitKey = false;
2000
+ allowCompact = false;
2001
+ keyTag = state.tag;
2002
+ keyNode = state.result;
2003
+ } else if (detected) {
2004
+ throwError(state, "can not read an implicit mapping pair; a colon is missed");
2005
+ } else {
2006
+ state.tag = _tag;
2007
+ state.anchor = _anchor;
2008
+ return true;
2009
+ }
2010
+ } else if (detected) {
2011
+ throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
2012
+ } else {
2013
+ state.tag = _tag;
2014
+ state.anchor = _anchor;
2015
+ return true;
2016
+ }
2017
+ }
2018
+ if (state.line === _line || state.lineIndent > nodeIndent) {
2019
+ if (atExplicitKey) {
2020
+ _keyLine = state.line;
2021
+ _keyLineStart = state.lineStart;
2022
+ _keyPos = state.position;
2023
+ }
2024
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
2025
+ if (atExplicitKey) {
2026
+ keyNode = state.result;
2027
+ } else {
2028
+ valueNode = state.result;
2029
+ }
2030
+ }
2031
+ if (!atExplicitKey) {
2032
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
2033
+ keyTag = keyNode = valueNode = null;
2034
+ }
2035
+ skipSeparationSpace(state, true, -1);
2036
+ ch = state.input.charCodeAt(state.position);
2037
+ }
2038
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
2039
+ throwError(state, "bad indentation of a mapping entry");
2040
+ } else if (state.lineIndent < nodeIndent) {
2041
+ break;
2042
+ }
2043
+ }
2044
+ if (atExplicitKey) {
2045
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
2046
+ }
2047
+ if (detected) {
2048
+ state.tag = _tag;
2049
+ state.anchor = _anchor;
2050
+ state.kind = "mapping";
2051
+ state.result = _result;
2052
+ }
2053
+ return detected;
2054
+ }
2055
+ __name(readBlockMapping, "readBlockMapping");
2056
+ function readTagProperty(state) {
2057
+ var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
2058
+ ch = state.input.charCodeAt(state.position);
2059
+ if (ch !== 33) return false;
2060
+ if (state.tag !== null) {
2061
+ throwError(state, "duplication of a tag property");
2062
+ }
2063
+ ch = state.input.charCodeAt(++state.position);
2064
+ if (ch === 60) {
2065
+ isVerbatim = true;
2066
+ ch = state.input.charCodeAt(++state.position);
2067
+ } else if (ch === 33) {
2068
+ isNamed = true;
2069
+ tagHandle = "!!";
2070
+ ch = state.input.charCodeAt(++state.position);
2071
+ } else {
2072
+ tagHandle = "!";
2073
+ }
2074
+ _position = state.position;
2075
+ if (isVerbatim) {
2076
+ do {
2077
+ ch = state.input.charCodeAt(++state.position);
2078
+ } while (ch !== 0 && ch !== 62);
2079
+ if (state.position < state.length) {
2080
+ tagName = state.input.slice(_position, state.position);
2081
+ ch = state.input.charCodeAt(++state.position);
2082
+ } else {
2083
+ throwError(state, "unexpected end of the stream within a verbatim tag");
2084
+ }
2085
+ } else {
2086
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2087
+ if (ch === 33) {
2088
+ if (!isNamed) {
2089
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
2090
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
2091
+ throwError(state, "named tag handle cannot contain such characters");
2092
+ }
2093
+ isNamed = true;
2094
+ _position = state.position + 1;
2095
+ } else {
2096
+ throwError(state, "tag suffix cannot contain exclamation marks");
2097
+ }
2098
+ }
2099
+ ch = state.input.charCodeAt(++state.position);
2100
+ }
2101
+ tagName = state.input.slice(_position, state.position);
2102
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) {
2103
+ throwError(state, "tag suffix cannot contain flow indicator characters");
2104
+ }
2105
+ }
2106
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) {
2107
+ throwError(state, "tag name cannot contain such characters: " + tagName);
2108
+ }
2109
+ try {
2110
+ tagName = decodeURIComponent(tagName);
2111
+ } catch (err) {
2112
+ throwError(state, "tag name is malformed: " + tagName);
2113
+ }
2114
+ if (isVerbatim) {
2115
+ state.tag = tagName;
2116
+ } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
2117
+ state.tag = state.tagMap[tagHandle] + tagName;
2118
+ } else if (tagHandle === "!") {
2119
+ state.tag = "!" + tagName;
2120
+ } else if (tagHandle === "!!") {
2121
+ state.tag = "tag:yaml.org,2002:" + tagName;
2122
+ } else {
2123
+ throwError(state, 'undeclared tag handle "' + tagHandle + '"');
2124
+ }
2125
+ return true;
2126
+ }
2127
+ __name(readTagProperty, "readTagProperty");
2128
+ function readAnchorProperty(state) {
2129
+ var _position, ch;
2130
+ ch = state.input.charCodeAt(state.position);
2131
+ if (ch !== 38) return false;
2132
+ if (state.anchor !== null) {
2133
+ throwError(state, "duplication of an anchor property");
2134
+ }
2135
+ ch = state.input.charCodeAt(++state.position);
2136
+ _position = state.position;
2137
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2138
+ ch = state.input.charCodeAt(++state.position);
2139
+ }
2140
+ if (state.position === _position) {
2141
+ throwError(state, "name of an anchor node must contain at least one character");
2142
+ }
2143
+ state.anchor = state.input.slice(_position, state.position);
2144
+ return true;
2145
+ }
2146
+ __name(readAnchorProperty, "readAnchorProperty");
2147
+ function readAlias(state) {
2148
+ var _position, alias, ch;
2149
+ ch = state.input.charCodeAt(state.position);
2150
+ if (ch !== 42) return false;
2151
+ ch = state.input.charCodeAt(++state.position);
2152
+ _position = state.position;
2153
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2154
+ ch = state.input.charCodeAt(++state.position);
2155
+ }
2156
+ if (state.position === _position) {
2157
+ throwError(state, "name of an alias node must contain at least one character");
2158
+ }
2159
+ alias = state.input.slice(_position, state.position);
2160
+ if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
2161
+ throwError(state, 'unidentified alias "' + alias + '"');
2162
+ }
2163
+ state.result = state.anchorMap[alias];
2164
+ skipSeparationSpace(state, true, -1);
2165
+ return true;
2166
+ }
2167
+ __name(readAlias, "readAlias");
2168
+ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
2169
+ var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
2170
+ if (state.listener !== null) {
2171
+ state.listener("open", state);
2172
+ }
2173
+ state.tag = null;
2174
+ state.anchor = null;
2175
+ state.kind = null;
2176
+ state.result = null;
2177
+ allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
2178
+ if (allowToSeek) {
2179
+ if (skipSeparationSpace(state, true, -1)) {
2180
+ atNewLine = true;
2181
+ if (state.lineIndent > parentIndent) {
2182
+ indentStatus = 1;
2183
+ } else if (state.lineIndent === parentIndent) {
2184
+ indentStatus = 0;
2185
+ } else if (state.lineIndent < parentIndent) {
2186
+ indentStatus = -1;
2187
+ }
2188
+ }
2189
+ }
2190
+ if (indentStatus === 1) {
2191
+ while (readTagProperty(state) || readAnchorProperty(state)) {
2192
+ if (skipSeparationSpace(state, true, -1)) {
2193
+ atNewLine = true;
2194
+ allowBlockCollections = allowBlockStyles;
2195
+ if (state.lineIndent > parentIndent) {
2196
+ indentStatus = 1;
2197
+ } else if (state.lineIndent === parentIndent) {
2198
+ indentStatus = 0;
2199
+ } else if (state.lineIndent < parentIndent) {
2200
+ indentStatus = -1;
2201
+ }
2202
+ } else {
2203
+ allowBlockCollections = false;
2204
+ }
2205
+ }
2206
+ }
2207
+ if (allowBlockCollections) {
2208
+ allowBlockCollections = atNewLine || allowCompact;
2209
+ }
2210
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
2211
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
2212
+ flowIndent = parentIndent;
2213
+ } else {
2214
+ flowIndent = parentIndent + 1;
2215
+ }
2216
+ blockIndent = state.position - state.lineStart;
2217
+ if (indentStatus === 1) {
2218
+ if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
2219
+ hasContent = true;
2220
+ } else {
2221
+ if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
2222
+ hasContent = true;
2223
+ } else if (readAlias(state)) {
2224
+ hasContent = true;
2225
+ if (state.tag !== null || state.anchor !== null) {
2226
+ throwError(state, "alias node should not have any properties");
2227
+ }
2228
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
2229
+ hasContent = true;
2230
+ if (state.tag === null) {
2231
+ state.tag = "?";
2232
+ }
2233
+ }
2234
+ if (state.anchor !== null) {
2235
+ state.anchorMap[state.anchor] = state.result;
2236
+ }
2237
+ }
2238
+ } else if (indentStatus === 0) {
2239
+ hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
2240
+ }
2241
+ }
2242
+ if (state.tag === null) {
2243
+ if (state.anchor !== null) {
2244
+ state.anchorMap[state.anchor] = state.result;
2245
+ }
2246
+ } else if (state.tag === "?") {
2247
+ if (state.result !== null && state.kind !== "scalar") {
2248
+ throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
2249
+ }
2250
+ for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
2251
+ type2 = state.implicitTypes[typeIndex];
2252
+ if (type2.resolve(state.result)) {
2253
+ state.result = type2.construct(state.result);
2254
+ state.tag = type2.tag;
2255
+ if (state.anchor !== null) {
2256
+ state.anchorMap[state.anchor] = state.result;
2257
+ }
2258
+ break;
2259
+ }
2260
+ }
2261
+ } else if (state.tag !== "!") {
2262
+ if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
2263
+ type2 = state.typeMap[state.kind || "fallback"][state.tag];
2264
+ } else {
2265
+ type2 = null;
2266
+ typeList = state.typeMap.multi[state.kind || "fallback"];
2267
+ for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
2268
+ if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
2269
+ type2 = typeList[typeIndex];
2270
+ break;
2271
+ }
2272
+ }
2273
+ }
2274
+ if (!type2) {
2275
+ throwError(state, "unknown tag !<" + state.tag + ">");
2276
+ }
2277
+ if (state.result !== null && type2.kind !== state.kind) {
2278
+ throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
2279
+ }
2280
+ if (!type2.resolve(state.result, state.tag)) {
2281
+ throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
2282
+ } else {
2283
+ state.result = type2.construct(state.result, state.tag);
2284
+ if (state.anchor !== null) {
2285
+ state.anchorMap[state.anchor] = state.result;
2286
+ }
2287
+ }
2288
+ }
2289
+ if (state.listener !== null) {
2290
+ state.listener("close", state);
2291
+ }
2292
+ return state.tag !== null || state.anchor !== null || hasContent;
2293
+ }
2294
+ __name(composeNode, "composeNode");
2295
+ function readDocument(state) {
2296
+ var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
2297
+ state.version = null;
2298
+ state.checkLineBreaks = state.legacy;
2299
+ state.tagMap = /* @__PURE__ */ Object.create(null);
2300
+ state.anchorMap = /* @__PURE__ */ Object.create(null);
2301
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2302
+ skipSeparationSpace(state, true, -1);
2303
+ ch = state.input.charCodeAt(state.position);
2304
+ if (state.lineIndent > 0 || ch !== 37) {
2305
+ break;
2306
+ }
2307
+ hasDirectives = true;
2308
+ ch = state.input.charCodeAt(++state.position);
2309
+ _position = state.position;
2310
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2311
+ ch = state.input.charCodeAt(++state.position);
2312
+ }
2313
+ directiveName = state.input.slice(_position, state.position);
2314
+ directiveArgs = [];
2315
+ if (directiveName.length < 1) {
2316
+ throwError(state, "directive name must not be less than one character in length");
2317
+ }
2318
+ while (ch !== 0) {
2319
+ while (is_WHITE_SPACE(ch)) {
2320
+ ch = state.input.charCodeAt(++state.position);
2321
+ }
2322
+ if (ch === 35) {
2323
+ do {
2324
+ ch = state.input.charCodeAt(++state.position);
2325
+ } while (ch !== 0 && !is_EOL(ch));
2326
+ break;
2327
+ }
2328
+ if (is_EOL(ch)) break;
2329
+ _position = state.position;
2330
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2331
+ ch = state.input.charCodeAt(++state.position);
2332
+ }
2333
+ directiveArgs.push(state.input.slice(_position, state.position));
2334
+ }
2335
+ if (ch !== 0) readLineBreak(state);
2336
+ if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
2337
+ directiveHandlers[directiveName](state, directiveName, directiveArgs);
2338
+ } else {
2339
+ throwWarning(state, 'unknown document directive "' + directiveName + '"');
2340
+ }
2341
+ }
2342
+ skipSeparationSpace(state, true, -1);
2343
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
2344
+ state.position += 3;
2345
+ skipSeparationSpace(state, true, -1);
2346
+ } else if (hasDirectives) {
2347
+ throwError(state, "directives end mark is expected");
2348
+ }
2349
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2350
+ skipSeparationSpace(state, true, -1);
2351
+ if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
2352
+ throwWarning(state, "non-ASCII line breaks are interpreted as content");
2353
+ }
2354
+ state.documents.push(state.result);
2355
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
2356
+ if (state.input.charCodeAt(state.position) === 46) {
2357
+ state.position += 3;
2358
+ skipSeparationSpace(state, true, -1);
2359
+ }
2360
+ return;
2361
+ }
2362
+ if (state.position < state.length - 1) {
2363
+ throwError(state, "end of the stream or a document separator is expected");
2364
+ } else {
2365
+ return;
2366
+ }
2367
+ }
2368
+ __name(readDocument, "readDocument");
2369
+ function loadDocuments(input, options) {
2370
+ input = String(input);
2371
+ options = options || {};
2372
+ if (input.length !== 0) {
2373
+ if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
2374
+ input += "\n";
2375
+ }
2376
+ if (input.charCodeAt(0) === 65279) {
2377
+ input = input.slice(1);
2378
+ }
2379
+ }
2380
+ var state = new State$1(input, options);
2381
+ var nullpos = input.indexOf("\0");
2382
+ if (nullpos !== -1) {
2383
+ state.position = nullpos;
2384
+ throwError(state, "null byte is not allowed in input");
2385
+ }
2386
+ state.input += "\0";
2387
+ while (state.input.charCodeAt(state.position) === 32) {
2388
+ state.lineIndent += 1;
2389
+ state.position += 1;
2390
+ }
2391
+ while (state.position < state.length - 1) {
2392
+ readDocument(state);
2393
+ }
2394
+ return state.documents;
2395
+ }
2396
+ __name(loadDocuments, "loadDocuments");
2397
+ function loadAll$1(input, iterator, options) {
2398
+ if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
2399
+ options = iterator;
2400
+ iterator = null;
2401
+ }
2402
+ var documents = loadDocuments(input, options);
2403
+ if (typeof iterator !== "function") {
2404
+ return documents;
2405
+ }
2406
+ for (var index = 0, length = documents.length; index < length; index += 1) {
2407
+ iterator(documents[index]);
2408
+ }
2409
+ }
2410
+ __name(loadAll$1, "loadAll$1");
2411
+ function load$1(input, options) {
2412
+ var documents = loadDocuments(input, options);
2413
+ if (documents.length === 0) {
2414
+ return void 0;
2415
+ } else if (documents.length === 1) {
2416
+ return documents[0];
2417
+ }
2418
+ throw new exception("expected a single document in the stream, but found more");
2419
+ }
2420
+ __name(load$1, "load$1");
2421
+ var loadAll_1 = loadAll$1;
2422
+ var load_1 = load$1;
2423
+ var loader = {
2424
+ loadAll: loadAll_1,
2425
+ load: load_1
2426
+ };
2427
+ var _toString = Object.prototype.toString;
2428
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
2429
+ var CHAR_BOM = 65279;
2430
+ var CHAR_TAB = 9;
2431
+ var CHAR_LINE_FEED = 10;
2432
+ var CHAR_CARRIAGE_RETURN = 13;
2433
+ var CHAR_SPACE = 32;
2434
+ var CHAR_EXCLAMATION = 33;
2435
+ var CHAR_DOUBLE_QUOTE = 34;
2436
+ var CHAR_SHARP = 35;
2437
+ var CHAR_PERCENT = 37;
2438
+ var CHAR_AMPERSAND = 38;
2439
+ var CHAR_SINGLE_QUOTE = 39;
2440
+ var CHAR_ASTERISK = 42;
2441
+ var CHAR_COMMA = 44;
2442
+ var CHAR_MINUS = 45;
2443
+ var CHAR_COLON = 58;
2444
+ var CHAR_EQUALS = 61;
2445
+ var CHAR_GREATER_THAN = 62;
2446
+ var CHAR_QUESTION = 63;
2447
+ var CHAR_COMMERCIAL_AT = 64;
2448
+ var CHAR_LEFT_SQUARE_BRACKET = 91;
2449
+ var CHAR_RIGHT_SQUARE_BRACKET = 93;
2450
+ var CHAR_GRAVE_ACCENT = 96;
2451
+ var CHAR_LEFT_CURLY_BRACKET = 123;
2452
+ var CHAR_VERTICAL_LINE = 124;
2453
+ var CHAR_RIGHT_CURLY_BRACKET = 125;
2454
+ var ESCAPE_SEQUENCES = {};
2455
+ ESCAPE_SEQUENCES[0] = "\\0";
2456
+ ESCAPE_SEQUENCES[7] = "\\a";
2457
+ ESCAPE_SEQUENCES[8] = "\\b";
2458
+ ESCAPE_SEQUENCES[9] = "\\t";
2459
+ ESCAPE_SEQUENCES[10] = "\\n";
2460
+ ESCAPE_SEQUENCES[11] = "\\v";
2461
+ ESCAPE_SEQUENCES[12] = "\\f";
2462
+ ESCAPE_SEQUENCES[13] = "\\r";
2463
+ ESCAPE_SEQUENCES[27] = "\\e";
2464
+ ESCAPE_SEQUENCES[34] = '\\"';
2465
+ ESCAPE_SEQUENCES[92] = "\\\\";
2466
+ ESCAPE_SEQUENCES[133] = "\\N";
2467
+ ESCAPE_SEQUENCES[160] = "\\_";
2468
+ ESCAPE_SEQUENCES[8232] = "\\L";
2469
+ ESCAPE_SEQUENCES[8233] = "\\P";
2470
+ var DEPRECATED_BOOLEANS_SYNTAX = [
2471
+ "y",
2472
+ "Y",
2473
+ "yes",
2474
+ "Yes",
2475
+ "YES",
2476
+ "on",
2477
+ "On",
2478
+ "ON",
2479
+ "n",
2480
+ "N",
2481
+ "no",
2482
+ "No",
2483
+ "NO",
2484
+ "off",
2485
+ "Off",
2486
+ "OFF"
2487
+ ];
2488
+ var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
2489
+ function compileStyleMap(schema2, map2) {
2490
+ var result, keys, index, length, tag, style, type2;
2491
+ if (map2 === null) return {};
2492
+ result = {};
2493
+ keys = Object.keys(map2);
2494
+ for (index = 0, length = keys.length; index < length; index += 1) {
2495
+ tag = keys[index];
2496
+ style = String(map2[tag]);
2497
+ if (tag.slice(0, 2) === "!!") {
2498
+ tag = "tag:yaml.org,2002:" + tag.slice(2);
2499
+ }
2500
+ type2 = schema2.compiledTypeMap["fallback"][tag];
2501
+ if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
2502
+ style = type2.styleAliases[style];
2503
+ }
2504
+ result[tag] = style;
2505
+ }
2506
+ return result;
2507
+ }
2508
+ __name(compileStyleMap, "compileStyleMap");
2509
+ function encodeHex(character) {
2510
+ var string, handle, length;
2511
+ string = character.toString(16).toUpperCase();
2512
+ if (character <= 255) {
2513
+ handle = "x";
2514
+ length = 2;
2515
+ } else if (character <= 65535) {
2516
+ handle = "u";
2517
+ length = 4;
2518
+ } else if (character <= 4294967295) {
2519
+ handle = "U";
2520
+ length = 8;
2521
+ } else {
2522
+ throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
2523
+ }
2524
+ return "\\" + handle + common.repeat("0", length - string.length) + string;
2525
+ }
2526
+ __name(encodeHex, "encodeHex");
2527
+ var QUOTING_TYPE_SINGLE = 1;
2528
+ var QUOTING_TYPE_DOUBLE = 2;
2529
+ function State(options) {
2530
+ this.schema = options["schema"] || _default;
2531
+ this.indent = Math.max(1, options["indent"] || 2);
2532
+ this.noArrayIndent = options["noArrayIndent"] || false;
2533
+ this.skipInvalid = options["skipInvalid"] || false;
2534
+ this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
2535
+ this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
2536
+ this.sortKeys = options["sortKeys"] || false;
2537
+ this.lineWidth = options["lineWidth"] || 80;
2538
+ this.noRefs = options["noRefs"] || false;
2539
+ this.noCompatMode = options["noCompatMode"] || false;
2540
+ this.condenseFlow = options["condenseFlow"] || false;
2541
+ this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
2542
+ this.forceQuotes = options["forceQuotes"] || false;
2543
+ this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
2544
+ this.implicitTypes = this.schema.compiledImplicit;
2545
+ this.explicitTypes = this.schema.compiledExplicit;
2546
+ this.tag = null;
2547
+ this.result = "";
2548
+ this.duplicates = [];
2549
+ this.usedDuplicates = null;
2550
+ }
2551
+ __name(State, "State");
2552
+ function indentString(string, spaces) {
2553
+ var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
2554
+ while (position < length) {
2555
+ next = string.indexOf("\n", position);
2556
+ if (next === -1) {
2557
+ line = string.slice(position);
2558
+ position = length;
2559
+ } else {
2560
+ line = string.slice(position, next + 1);
2561
+ position = next + 1;
2562
+ }
2563
+ if (line.length && line !== "\n") result += ind;
2564
+ result += line;
2565
+ }
2566
+ return result;
2567
+ }
2568
+ __name(indentString, "indentString");
2569
+ function generateNextLine(state, level) {
2570
+ return "\n" + common.repeat(" ", state.indent * level);
2571
+ }
2572
+ __name(generateNextLine, "generateNextLine");
2573
+ function testImplicitResolving(state, str2) {
2574
+ var index, length, type2;
2575
+ for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
2576
+ type2 = state.implicitTypes[index];
2577
+ if (type2.resolve(str2)) {
2578
+ return true;
2579
+ }
2580
+ }
2581
+ return false;
2582
+ }
2583
+ __name(testImplicitResolving, "testImplicitResolving");
2584
+ function isWhitespace(c) {
2585
+ return c === CHAR_SPACE || c === CHAR_TAB;
2586
+ }
2587
+ __name(isWhitespace, "isWhitespace");
2588
+ function isPrintable(c) {
2589
+ return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
2590
+ }
2591
+ __name(isPrintable, "isPrintable");
2592
+ function isNsCharOrWhitespace(c) {
2593
+ return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
2594
+ }
2595
+ __name(isNsCharOrWhitespace, "isNsCharOrWhitespace");
2596
+ function isPlainSafe(c, prev, inblock) {
2597
+ var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
2598
+ var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
2599
+ return (
2600
+ // ns-plain-safe
2601
+ (inblock ? (
2602
+ // c = flow-in
2603
+ cIsNsCharOrWhitespace
2604
+ ) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar
2605
+ );
2606
+ }
2607
+ __name(isPlainSafe, "isPlainSafe");
2608
+ function isPlainSafeFirst(c) {
2609
+ return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
2610
+ }
2611
+ __name(isPlainSafeFirst, "isPlainSafeFirst");
2612
+ function isPlainSafeLast(c) {
2613
+ return !isWhitespace(c) && c !== CHAR_COLON;
2614
+ }
2615
+ __name(isPlainSafeLast, "isPlainSafeLast");
2616
+ function codePointAt(string, pos) {
2617
+ var first = string.charCodeAt(pos), second;
2618
+ if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
2619
+ second = string.charCodeAt(pos + 1);
2620
+ if (second >= 56320 && second <= 57343) {
2621
+ return (first - 55296) * 1024 + second - 56320 + 65536;
2622
+ }
2623
+ }
2624
+ return first;
2625
+ }
2626
+ __name(codePointAt, "codePointAt");
2627
+ function needIndentIndicator(string) {
2628
+ var leadingSpaceRe = /^\n* /;
2629
+ return leadingSpaceRe.test(string);
2630
+ }
2631
+ __name(needIndentIndicator, "needIndentIndicator");
2632
+ var STYLE_PLAIN = 1;
2633
+ var STYLE_SINGLE = 2;
2634
+ var STYLE_LITERAL = 3;
2635
+ var STYLE_FOLDED = 4;
2636
+ var STYLE_DOUBLE = 5;
2637
+ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
2638
+ var i;
2639
+ var char = 0;
2640
+ var prevChar = null;
2641
+ var hasLineBreak = false;
2642
+ var hasFoldableLine = false;
2643
+ var shouldTrackWidth = lineWidth !== -1;
2644
+ var previousLineBreak = -1;
2645
+ var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
2646
+ if (singleLineOnly || forceQuotes) {
2647
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2648
+ char = codePointAt(string, i);
2649
+ if (!isPrintable(char)) {
2650
+ return STYLE_DOUBLE;
2651
+ }
2652
+ plain = plain && isPlainSafe(char, prevChar, inblock);
2653
+ prevChar = char;
2654
+ }
2655
+ } else {
2656
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2657
+ char = codePointAt(string, i);
2658
+ if (char === CHAR_LINE_FEED) {
2659
+ hasLineBreak = true;
2660
+ if (shouldTrackWidth) {
2661
+ hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
2662
+ i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
2663
+ previousLineBreak = i;
2664
+ }
2665
+ } else if (!isPrintable(char)) {
2666
+ return STYLE_DOUBLE;
2667
+ }
2668
+ plain = plain && isPlainSafe(char, prevChar, inblock);
2669
+ prevChar = char;
2670
+ }
2671
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
2672
+ }
2673
+ if (!hasLineBreak && !hasFoldableLine) {
2674
+ if (plain && !forceQuotes && !testAmbiguousType(string)) {
2675
+ return STYLE_PLAIN;
2676
+ }
2677
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2678
+ }
2679
+ if (indentPerLevel > 9 && needIndentIndicator(string)) {
2680
+ return STYLE_DOUBLE;
2681
+ }
2682
+ if (!forceQuotes) {
2683
+ return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
2684
+ }
2685
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2686
+ }
2687
+ __name(chooseScalarStyle, "chooseScalarStyle");
2688
+ function writeScalar(state, string, level, iskey, inblock) {
2689
+ state.dump = (function() {
2690
+ if (string.length === 0) {
2691
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
2692
+ }
2693
+ if (!state.noCompatMode) {
2694
+ if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
2695
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
2696
+ }
2697
+ }
2698
+ var indent = state.indent * Math.max(1, level);
2699
+ var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
2700
+ var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
2701
+ function testAmbiguity(string2) {
2702
+ return testImplicitResolving(state, string2);
2703
+ }
2704
+ __name(testAmbiguity, "testAmbiguity");
2705
+ switch (chooseScalarStyle(
2706
+ string,
2707
+ singleLineOnly,
2708
+ state.indent,
2709
+ lineWidth,
2710
+ testAmbiguity,
2711
+ state.quotingType,
2712
+ state.forceQuotes && !iskey,
2713
+ inblock
2714
+ )) {
2715
+ case STYLE_PLAIN:
2716
+ return string;
2717
+ case STYLE_SINGLE:
2718
+ return "'" + string.replace(/'/g, "''") + "'";
2719
+ case STYLE_LITERAL:
2720
+ return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
2721
+ case STYLE_FOLDED:
2722
+ return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
2723
+ case STYLE_DOUBLE:
2724
+ return '"' + escapeString2(string) + '"';
2725
+ default:
2726
+ throw new exception("impossible error: invalid scalar style");
2727
+ }
2728
+ })();
2729
+ }
2730
+ __name(writeScalar, "writeScalar");
2731
+ function blockHeader(string, indentPerLevel) {
2732
+ var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
2733
+ var clip = string[string.length - 1] === "\n";
2734
+ var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
2735
+ var chomp = keep ? "+" : clip ? "" : "-";
2736
+ return indentIndicator + chomp + "\n";
2737
+ }
2738
+ __name(blockHeader, "blockHeader");
2739
+ function dropEndingNewline(string) {
2740
+ return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
2741
+ }
2742
+ __name(dropEndingNewline, "dropEndingNewline");
2743
+ function foldString(string, width) {
2744
+ var lineRe = /(\n+)([^\n]*)/g;
2745
+ var result = (function() {
2746
+ var nextLF = string.indexOf("\n");
2747
+ nextLF = nextLF !== -1 ? nextLF : string.length;
2748
+ lineRe.lastIndex = nextLF;
2749
+ return foldLine(string.slice(0, nextLF), width);
2750
+ })();
2751
+ var prevMoreIndented = string[0] === "\n" || string[0] === " ";
2752
+ var moreIndented;
2753
+ var match;
2754
+ while (match = lineRe.exec(string)) {
2755
+ var prefix = match[1], line = match[2];
2756
+ moreIndented = line[0] === " ";
2757
+ result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
2758
+ prevMoreIndented = moreIndented;
2759
+ }
2760
+ return result;
2761
+ }
2762
+ __name(foldString, "foldString");
2763
+ function foldLine(line, width) {
2764
+ if (line === "" || line[0] === " ") return line;
2765
+ var breakRe = / [^ ]/g;
2766
+ var match;
2767
+ var start = 0, end, curr = 0, next = 0;
2768
+ var result = "";
2769
+ while (match = breakRe.exec(line)) {
2770
+ next = match.index;
2771
+ if (next - start > width) {
2772
+ end = curr > start ? curr : next;
2773
+ result += "\n" + line.slice(start, end);
2774
+ start = end + 1;
2775
+ }
2776
+ curr = next;
2777
+ }
2778
+ result += "\n";
2779
+ if (line.length - start > width && curr > start) {
2780
+ result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
2781
+ } else {
2782
+ result += line.slice(start);
2783
+ }
2784
+ return result.slice(1);
2785
+ }
2786
+ __name(foldLine, "foldLine");
2787
+ function escapeString2(string) {
2788
+ var result = "";
2789
+ var char = 0;
2790
+ var escapeSeq;
2791
+ for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2792
+ char = codePointAt(string, i);
2793
+ escapeSeq = ESCAPE_SEQUENCES[char];
2794
+ if (!escapeSeq && isPrintable(char)) {
2795
+ result += string[i];
2796
+ if (char >= 65536) result += string[i + 1];
2797
+ } else {
2798
+ result += escapeSeq || encodeHex(char);
2799
+ }
2800
+ }
2801
+ return result;
2802
+ }
2803
+ __name(escapeString2, "escapeString");
2804
+ function writeFlowSequence(state, level, object) {
2805
+ var _result = "", _tag = state.tag, index, length, value;
2806
+ for (index = 0, length = object.length; index < length; index += 1) {
2807
+ value = object[index];
2808
+ if (state.replacer) {
2809
+ value = state.replacer.call(object, String(index), value);
2810
+ }
2811
+ if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
2812
+ if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
2813
+ _result += state.dump;
2814
+ }
2815
+ }
2816
+ state.tag = _tag;
2817
+ state.dump = "[" + _result + "]";
2818
+ }
2819
+ __name(writeFlowSequence, "writeFlowSequence");
2820
+ function writeBlockSequence(state, level, object, compact) {
2821
+ var _result = "", _tag = state.tag, index, length, value;
2822
+ for (index = 0, length = object.length; index < length; index += 1) {
2823
+ value = object[index];
2824
+ if (state.replacer) {
2825
+ value = state.replacer.call(object, String(index), value);
2826
+ }
2827
+ if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
2828
+ if (!compact || _result !== "") {
2829
+ _result += generateNextLine(state, level);
2830
+ }
2831
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2832
+ _result += "-";
2833
+ } else {
2834
+ _result += "- ";
2835
+ }
2836
+ _result += state.dump;
2837
+ }
2838
+ }
2839
+ state.tag = _tag;
2840
+ state.dump = _result || "[]";
2841
+ }
2842
+ __name(writeBlockSequence, "writeBlockSequence");
2843
+ function writeFlowMapping(state, level, object) {
2844
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
2845
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2846
+ pairBuffer = "";
2847
+ if (_result !== "") pairBuffer += ", ";
2848
+ if (state.condenseFlow) pairBuffer += '"';
2849
+ objectKey = objectKeyList[index];
2850
+ objectValue = object[objectKey];
2851
+ if (state.replacer) {
2852
+ objectValue = state.replacer.call(object, objectKey, objectValue);
2853
+ }
2854
+ if (!writeNode(state, level, objectKey, false, false)) {
2855
+ continue;
2856
+ }
2857
+ if (state.dump.length > 1024) pairBuffer += "? ";
2858
+ pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
2859
+ if (!writeNode(state, level, objectValue, false, false)) {
2860
+ continue;
2861
+ }
2862
+ pairBuffer += state.dump;
2863
+ _result += pairBuffer;
2864
+ }
2865
+ state.tag = _tag;
2866
+ state.dump = "{" + _result + "}";
2867
+ }
2868
+ __name(writeFlowMapping, "writeFlowMapping");
2869
+ function writeBlockMapping(state, level, object, compact) {
2870
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
2871
+ if (state.sortKeys === true) {
2872
+ objectKeyList.sort();
2873
+ } else if (typeof state.sortKeys === "function") {
2874
+ objectKeyList.sort(state.sortKeys);
2875
+ } else if (state.sortKeys) {
2876
+ throw new exception("sortKeys must be a boolean or a function");
2877
+ }
2878
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2879
+ pairBuffer = "";
2880
+ if (!compact || _result !== "") {
2881
+ pairBuffer += generateNextLine(state, level);
2882
+ }
2883
+ objectKey = objectKeyList[index];
2884
+ objectValue = object[objectKey];
2885
+ if (state.replacer) {
2886
+ objectValue = state.replacer.call(object, objectKey, objectValue);
2887
+ }
2888
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) {
2889
+ continue;
2890
+ }
2891
+ explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
2892
+ if (explicitPair) {
2893
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2894
+ pairBuffer += "?";
2895
+ } else {
2896
+ pairBuffer += "? ";
2897
+ }
2898
+ }
2899
+ pairBuffer += state.dump;
2900
+ if (explicitPair) {
2901
+ pairBuffer += generateNextLine(state, level);
2902
+ }
2903
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
2904
+ continue;
2905
+ }
2906
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2907
+ pairBuffer += ":";
2908
+ } else {
2909
+ pairBuffer += ": ";
2910
+ }
2911
+ pairBuffer += state.dump;
2912
+ _result += pairBuffer;
2913
+ }
2914
+ state.tag = _tag;
2915
+ state.dump = _result || "{}";
2916
+ }
2917
+ __name(writeBlockMapping, "writeBlockMapping");
2918
+ function detectType(state, object, explicit) {
2919
+ var _result, typeList, index, length, type2, style;
2920
+ typeList = explicit ? state.explicitTypes : state.implicitTypes;
2921
+ for (index = 0, length = typeList.length; index < length; index += 1) {
2922
+ type2 = typeList[index];
2923
+ if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
2924
+ if (explicit) {
2925
+ if (type2.multi && type2.representName) {
2926
+ state.tag = type2.representName(object);
2927
+ } else {
2928
+ state.tag = type2.tag;
2929
+ }
2930
+ } else {
2931
+ state.tag = "?";
2932
+ }
2933
+ if (type2.represent) {
2934
+ style = state.styleMap[type2.tag] || type2.defaultStyle;
2935
+ if (_toString.call(type2.represent) === "[object Function]") {
2936
+ _result = type2.represent(object, style);
2937
+ } else if (_hasOwnProperty.call(type2.represent, style)) {
2938
+ _result = type2.represent[style](object, style);
2939
+ } else {
2940
+ throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
2941
+ }
2942
+ state.dump = _result;
2943
+ }
2944
+ return true;
2945
+ }
2946
+ }
2947
+ return false;
2948
+ }
2949
+ __name(detectType, "detectType");
2950
+ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
2951
+ state.tag = null;
2952
+ state.dump = object;
2953
+ if (!detectType(state, object, false)) {
2954
+ detectType(state, object, true);
2955
+ }
2956
+ var type2 = _toString.call(state.dump);
2957
+ var inblock = block;
2958
+ var tagStr;
2959
+ if (block) {
2960
+ block = state.flowLevel < 0 || state.flowLevel > level;
2961
+ }
2962
+ var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
2963
+ if (objectOrArray) {
2964
+ duplicateIndex = state.duplicates.indexOf(object);
2965
+ duplicate = duplicateIndex !== -1;
2966
+ }
2967
+ if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
2968
+ compact = false;
2969
+ }
2970
+ if (duplicate && state.usedDuplicates[duplicateIndex]) {
2971
+ state.dump = "*ref_" + duplicateIndex;
2972
+ } else {
2973
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
2974
+ state.usedDuplicates[duplicateIndex] = true;
2975
+ }
2976
+ if (type2 === "[object Object]") {
2977
+ if (block && Object.keys(state.dump).length !== 0) {
2978
+ writeBlockMapping(state, level, state.dump, compact);
2979
+ if (duplicate) {
2980
+ state.dump = "&ref_" + duplicateIndex + state.dump;
2981
+ }
2982
+ } else {
2983
+ writeFlowMapping(state, level, state.dump);
2984
+ if (duplicate) {
2985
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2986
+ }
2987
+ }
2988
+ } else if (type2 === "[object Array]") {
2989
+ if (block && state.dump.length !== 0) {
2990
+ if (state.noArrayIndent && !isblockseq && level > 0) {
2991
+ writeBlockSequence(state, level - 1, state.dump, compact);
2992
+ } else {
2993
+ writeBlockSequence(state, level, state.dump, compact);
2994
+ }
2995
+ if (duplicate) {
2996
+ state.dump = "&ref_" + duplicateIndex + state.dump;
2997
+ }
2998
+ } else {
2999
+ writeFlowSequence(state, level, state.dump);
3000
+ if (duplicate) {
3001
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
3002
+ }
3003
+ }
3004
+ } else if (type2 === "[object String]") {
3005
+ if (state.tag !== "?") {
3006
+ writeScalar(state, state.dump, level, iskey, inblock);
3007
+ }
3008
+ } else if (type2 === "[object Undefined]") {
3009
+ return false;
3010
+ } else {
3011
+ if (state.skipInvalid) return false;
3012
+ throw new exception("unacceptable kind of an object to dump " + type2);
3013
+ }
3014
+ if (state.tag !== null && state.tag !== "?") {
3015
+ tagStr = encodeURI(
3016
+ state.tag[0] === "!" ? state.tag.slice(1) : state.tag
3017
+ ).replace(/!/g, "%21");
3018
+ if (state.tag[0] === "!") {
3019
+ tagStr = "!" + tagStr;
3020
+ } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
3021
+ tagStr = "!!" + tagStr.slice(18);
3022
+ } else {
3023
+ tagStr = "!<" + tagStr + ">";
3024
+ }
3025
+ state.dump = tagStr + " " + state.dump;
3026
+ }
3027
+ }
3028
+ return true;
3029
+ }
3030
+ __name(writeNode, "writeNode");
3031
+ function getDuplicateReferences(object, state) {
3032
+ var objects = [], duplicatesIndexes = [], index, length;
3033
+ inspectNode(object, objects, duplicatesIndexes);
3034
+ for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
3035
+ state.duplicates.push(objects[duplicatesIndexes[index]]);
3036
+ }
3037
+ state.usedDuplicates = new Array(length);
3038
+ }
3039
+ __name(getDuplicateReferences, "getDuplicateReferences");
3040
+ function inspectNode(object, objects, duplicatesIndexes) {
3041
+ var objectKeyList, index, length;
3042
+ if (object !== null && typeof object === "object") {
3043
+ index = objects.indexOf(object);
3044
+ if (index !== -1) {
3045
+ if (duplicatesIndexes.indexOf(index) === -1) {
3046
+ duplicatesIndexes.push(index);
3047
+ }
3048
+ } else {
3049
+ objects.push(object);
3050
+ if (Array.isArray(object)) {
3051
+ for (index = 0, length = object.length; index < length; index += 1) {
3052
+ inspectNode(object[index], objects, duplicatesIndexes);
3053
+ }
3054
+ } else {
3055
+ objectKeyList = Object.keys(object);
3056
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
3057
+ inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
3058
+ }
3059
+ }
3060
+ }
3061
+ }
3062
+ }
3063
+ __name(inspectNode, "inspectNode");
3064
+ function dump$1(input, options) {
3065
+ options = options || {};
3066
+ var state = new State(options);
3067
+ if (!state.noRefs) getDuplicateReferences(input, state);
3068
+ var value = input;
3069
+ if (state.replacer) {
3070
+ value = state.replacer.call({ "": value }, "", value);
3071
+ }
3072
+ if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
3073
+ return "";
3074
+ }
3075
+ __name(dump$1, "dump$1");
3076
+ var dump_1 = dump$1;
3077
+ var dumper = {
3078
+ dump: dump_1
3079
+ };
3080
+ function renamed(from, to) {
3081
+ return function() {
3082
+ throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
3083
+ };
3084
+ }
3085
+ __name(renamed, "renamed");
3086
+ var load = loader.load;
3087
+ var loadAll = loader.loadAll;
3088
+ var dump = dumper.dump;
3089
+ var safeLoad = renamed("safeLoad", "load");
3090
+ var safeLoadAll = renamed("safeLoadAll", "loadAll");
3091
+ var safeDump = renamed("safeDump", "dump");
3092
+
3093
+ // ../../shared/src/core/swagger-parser.ts
3094
+ var SwaggerParser = class _SwaggerParser {
3095
+ static {
3096
+ __name(this, "SwaggerParser");
3097
+ }
3098
+ spec;
3099
+ constructor(spec, config) {
3100
+ const isInputValid = config.validateInput?.(spec) ?? true;
3101
+ if (!isInputValid) {
3102
+ throw new Error("Swagger spec is not valid. Check your `validateInput` condition.");
3103
+ }
3104
+ this.spec = spec;
3105
+ }
3106
+ static async create(swaggerPathOrUrl, config) {
3107
+ const swaggerContent = await _SwaggerParser.loadContent(swaggerPathOrUrl);
3108
+ const spec = _SwaggerParser.parseSpecContent(swaggerContent, swaggerPathOrUrl);
3109
+ return new _SwaggerParser(spec, config);
3110
+ }
3111
+ static async loadContent(pathOrUrl) {
3112
+ if (_SwaggerParser.isUrl(pathOrUrl)) {
3113
+ return await _SwaggerParser.fetchUrlContent(pathOrUrl);
3114
+ } else {
3115
+ return fs.readFileSync(pathOrUrl, "utf8");
3116
+ }
3117
+ }
3118
+ static isUrl(input) {
3119
+ try {
3120
+ new URL(input);
3121
+ return true;
3122
+ } catch {
3123
+ return false;
3124
+ }
3125
+ }
3126
+ static async fetchUrlContent(url) {
3127
+ try {
3128
+ const response = await fetch(url, {
3129
+ method: "GET",
3130
+ headers: {
3131
+ Accept: "application/json, application/yaml, text/yaml, text/plain, */*",
3132
+ "User-Agent": "ng-openapi"
3133
+ },
3134
+ // 30 second timeout
3135
+ signal: AbortSignal.timeout(3e4)
3136
+ });
3137
+ if (!response.ok) {
3138
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
3139
+ }
3140
+ const content = await response.text();
3141
+ if (!content || content.trim() === "") {
3142
+ throw new Error(`Empty response from URL: ${url}`);
3143
+ }
3144
+ return content;
3145
+ } catch (error) {
3146
+ let errorMessage = `Failed to fetch content from URL: ${url}`;
3147
+ if (error.name === "AbortError") {
3148
+ errorMessage += " - Request timeout (30s)";
3149
+ } else if (error.message) {
3150
+ errorMessage += ` - ${error.message}`;
3151
+ }
3152
+ throw new Error(errorMessage);
3153
+ }
3154
+ }
3155
+ static parseSpecContent(content, pathOrUrl) {
3156
+ let format;
3157
+ if (_SwaggerParser.isUrl(pathOrUrl)) {
3158
+ const urlPath = new URL(pathOrUrl).pathname.toLowerCase();
3159
+ if (urlPath.endsWith(".json")) {
3160
+ format = "json";
3161
+ } else if (urlPath.endsWith(".yaml") || urlPath.endsWith(".yml")) {
3162
+ format = "yaml";
3163
+ } else {
3164
+ format = _SwaggerParser.detectFormat(content);
3165
+ }
3166
+ } else {
3167
+ const extension = path.extname(pathOrUrl).toLowerCase();
3168
+ switch (extension) {
3169
+ case ".json":
3170
+ format = "json";
3171
+ break;
3172
+ case ".yaml":
3173
+ format = "yaml";
3174
+ break;
3175
+ case ".yml":
3176
+ format = "yml";
3177
+ break;
3178
+ default:
3179
+ format = _SwaggerParser.detectFormat(content);
3180
+ }
3181
+ }
3182
+ try {
3183
+ switch (format) {
3184
+ case "json":
3185
+ return JSON.parse(content);
3186
+ case "yaml":
3187
+ case "yml":
3188
+ return load(content);
3189
+ default:
3190
+ throw new Error(`Unable to determine format for: ${pathOrUrl}`);
3191
+ }
3192
+ } catch (error) {
3193
+ throw new Error(`Failed to parse ${format.toUpperCase()} content from: ${pathOrUrl}. Error: ${error instanceof Error ? error.message : error}`);
3194
+ }
3195
+ }
3196
+ static detectFormat(content) {
3197
+ const trimmed = content.trim();
3198
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
3199
+ return "json";
3200
+ }
3201
+ if (trimmed.includes("openapi:") || trimmed.includes("swagger:") || trimmed.includes("---") || /^[a-zA-Z][a-zA-Z0-9_]*\s*:/.test(trimmed)) {
3202
+ return "yaml";
3203
+ }
3204
+ return "json";
3205
+ }
3206
+ getDefinitions() {
3207
+ return this.spec.definitions || this.spec.components?.schemas || {};
3208
+ }
3209
+ getDefinition(name) {
3210
+ const definitions = this.getDefinitions();
3211
+ return definitions[name];
3212
+ }
3213
+ resolveReference(ref) {
3214
+ const parts = ref.split("/");
3215
+ const definitionName = parts[parts.length - 1];
3216
+ return this.getDefinition(definitionName);
3217
+ }
3218
+ getAllDefinitionNames() {
3219
+ return Object.keys(this.getDefinitions());
3220
+ }
3221
+ getSpec() {
3222
+ return this.spec;
3223
+ }
3224
+ getPaths() {
3225
+ return this.spec.paths || {};
3226
+ }
3227
+ isValidSpec() {
3228
+ return !!(this.spec.swagger && this.spec.swagger.startsWith("2.") || this.spec.openapi && this.spec.openapi.startsWith("3."));
3229
+ }
3230
+ getSpecVersion() {
3231
+ if (this.spec.swagger) {
3232
+ return {
3233
+ type: "swagger",
3234
+ version: this.spec.swagger
3235
+ };
3236
+ }
3237
+ if (this.spec.openapi) {
3238
+ return {
3239
+ type: "openapi",
3240
+ version: this.spec.openapi
3241
+ };
3242
+ }
3243
+ return null;
3244
+ }
3245
+ };
3246
+
3247
+ // src/lib/http-resource.generator.ts
3248
+ import * as path3 from "path";
3249
+
3250
+ // src/lib/http-resource-method/http-resource-method-body.generator.ts
3251
+ var HttpResourceMethodBodyGenerator = class {
3252
+ static {
3253
+ __name(this, "HttpResourceMethodBodyGenerator");
3254
+ }
3255
+ config;
3256
+ constructor(config) {
3257
+ this.config = config;
3258
+ }
3259
+ generateMethodBody(operation) {
3260
+ const context = this.createGenerationContext(operation);
3261
+ const bodyParts = [
3262
+ this.generateHeaders(context),
3263
+ this.generateHttpResource(operation, context)
3264
+ ];
3265
+ return bodyParts.filter(Boolean).join("\n");
3266
+ }
3267
+ createGenerationContext(operation) {
3268
+ return {
3269
+ pathParams: operation.parameters?.filter((p) => p.in === "path") || [],
3270
+ queryParams: operation.parameters?.filter((p) => p.in === "query") || [],
3271
+ responseType: this.determineResponseType(operation)
3272
+ };
3273
+ }
3274
+ generateUrl(operation, context) {
3275
+ let urlExpression = `\`\${this.basePath}${operation.path}\``;
3276
+ if (context.pathParams.length > 0) {
3277
+ context.pathParams.forEach((param) => {
3278
+ urlExpression = urlExpression.replace(`{${param.name}}`, `\${typeof ${param.name} === 'function' ? ${param.name}() : ${param.name}}`);
3279
+ });
3280
+ }
3281
+ return urlExpression;
3282
+ }
3283
+ generateQueryParams(context) {
3284
+ if (context.queryParams.length === 0) {
3285
+ return "";
3286
+ }
3287
+ const paramMappings = context.queryParams.map((param) => `const ${param.name}Value = typeof ${param.name} === 'function' ? ${param.name}() : ${param.name};
3288
+ if (${param.name}Value !== undefined) {
3289
+ params = params.set('${param.name}', String(${param.name}Value));
3290
+ }`).join("\n");
3291
+ return `
3292
+ let params = new HttpParams();
3293
+ ${paramMappings}`;
3294
+ }
3295
+ generateHeaders(context) {
3296
+ const hasCustomHeaders = this.config.options.customHeaders;
3297
+ if (!hasCustomHeaders) {
3298
+ return "";
3299
+ }
3300
+ let headerCode = `
3301
+ let headers: HttpHeaders;
3302
+ if (requestOptions?.headers instanceof HttpHeaders) {
3303
+ headers = requestOptions.headers;
3304
+ } else {
3305
+ headers = new HttpHeaders(requestOptions?.headers as Record<string, string>);
3306
+ }`;
3307
+ if (hasCustomHeaders) {
3308
+ headerCode += `
3309
+ // Add default headers if not already present
3310
+ ${Object.entries(this.config.options.customHeaders || {}).map(([key, value]) => `if (!headers.has('${key}')) {
3311
+ headers = headers.set('${key}', '${value}');
3312
+ }`).join("\n")}`;
3313
+ }
3314
+ return headerCode;
3315
+ }
3316
+ generateRequestOptions(operation, context) {
3317
+ const options = [];
3318
+ const url = this.generateUrl(operation, context);
3319
+ options.push(`url: ${url}`);
3320
+ options.push(`method: "GET"`);
3321
+ if (context.queryParams.length > 0) {
3322
+ options.push("params");
3323
+ }
3324
+ const hasHeaders = this.config.options.customHeaders;
3325
+ if (hasHeaders) {
3326
+ options.push("headers");
3327
+ }
3328
+ if (context.responseType !== "json") {
3329
+ options.push(`responseType: '${context.responseType}' as '${context.responseType}'`);
3330
+ }
3331
+ options.push("context: this.createContextWithClientId(requestOptions?.context)");
3332
+ const formattedOptions = options.filter((opt) => opt && !opt.includes("undefined")).join(",\n ");
3333
+ return `return {
3334
+ ${formattedOptions},
3335
+ ...requestOptions
3336
+ }`;
3337
+ }
3338
+ generateHttpResource(operation, context) {
3339
+ const resourceOptions = this.generateRequestOptions(operation, context);
3340
+ const queryParams = this.generateQueryParams(context);
3341
+ let httpResource = "httpResource";
3342
+ switch (context.responseType) {
3343
+ case "blob":
3344
+ httpResource += ".blob";
3345
+ break;
3346
+ case "arraybuffer":
3347
+ httpResource += ".arrayBuffer";
3348
+ break;
3349
+ case "text":
3350
+ httpResource += ".text";
3351
+ break;
3352
+ }
3353
+ return ` return ${httpResource}(() => {${queryParams}
3354
+ ${resourceOptions}
3355
+ }, resourceOptions);`;
3356
+ }
3357
+ determineResponseType(operation) {
3358
+ const successResponses = [
3359
+ "200",
3360
+ "201",
3361
+ "202",
3362
+ "204",
3363
+ "206"
3364
+ ];
3365
+ for (const statusCode of successResponses) {
3366
+ const response = operation.responses?.[statusCode];
3367
+ if (!response) continue;
3368
+ return getResponseTypeFromResponse(response);
3369
+ }
3370
+ return "json";
3371
+ }
3372
+ };
3373
+
3374
+ // src/lib/http-resource-method/http-resource-method-params.generator.ts
3375
+ var HttpResourceMethodParamsGenerator = class {
3376
+ static {
3377
+ __name(this, "HttpResourceMethodParamsGenerator");
3378
+ }
3379
+ config;
3380
+ constructor(config) {
3381
+ this.config = config;
3382
+ }
3383
+ generateMethodParameters(operation) {
3384
+ const params = this.generateApiParameters(operation);
3385
+ const responseType = this.getApiReturnType(operation);
3386
+ const optionsParam = this.addOptionsParameter(responseType);
3387
+ const combined = [
3388
+ ...params,
3389
+ ...optionsParam
3390
+ ];
3391
+ const seen = /* @__PURE__ */ new Set();
3392
+ const uniqueParams = [];
3393
+ for (const param of combined) {
3394
+ if (!seen.has(param.name)) {
3395
+ seen.add(param.name);
3396
+ uniqueParams.push(param);
3397
+ }
3398
+ }
3399
+ return uniqueParams;
3400
+ }
3401
+ generateApiParameters(operation) {
3402
+ const params = [];
3403
+ const pathParams = operation.parameters?.filter((p) => p.in === "path") || [];
3404
+ pathParams.forEach((param) => {
3405
+ const paramType = getTypeScriptType(param.schema || param, this.config);
3406
+ const signalParamType = param.required ? `Signal<${paramType}>` : `Signal<${paramType} | undefined>`;
3407
+ params.push({
3408
+ name: param.name,
3409
+ type: `${signalParamType} | ${paramType}`,
3410
+ hasQuestionToken: !param.required
3411
+ });
3412
+ });
3413
+ const queryParams = operation.parameters?.filter((p) => p.in === "query") || [];
3414
+ queryParams.forEach((param) => {
3415
+ const paramType = getTypeScriptType(param.schema || param, this.config);
3416
+ const signalParamType = param.required ? `Signal<${paramType}>` : `Signal<${paramType} | undefined>`;
3417
+ params.push({
3418
+ name: param.name,
3419
+ type: `${signalParamType} | ${paramType}`,
3420
+ hasQuestionToken: !param.required
3421
+ });
3422
+ });
3423
+ return params.sort((a, b) => Number(a.hasQuestionToken) - Number(b.hasQuestionToken));
3424
+ }
3425
+ addOptionsParameter(responseType) {
3426
+ const rawDataType = this.getResourceRawDataType(responseType);
3427
+ return [
3428
+ {
3429
+ name: "resourceOptions",
3430
+ type: `HttpResourceOptions<${responseType}, ${rawDataType}>`,
3431
+ hasQuestionToken: true
3432
+ },
3433
+ {
3434
+ name: "requestOptions",
3435
+ type: `Omit<HttpResourceRequest, "method" | "url" | "params">`,
3436
+ hasQuestionToken: true
3437
+ }
3438
+ ];
3439
+ }
3440
+ getApiReturnType(operation) {
3441
+ const successResponses = [
3442
+ "200",
3443
+ "201",
3444
+ "202",
3445
+ "204",
3446
+ "206"
3447
+ ];
3448
+ for (const statusCode of successResponses) {
3449
+ const response = operation.responses?.[statusCode];
3450
+ if (!response) continue;
3451
+ return getResponseType(response, this.config);
3452
+ }
3453
+ return "unknown";
3454
+ }
3455
+ getResourceRawDataType(responseType) {
3456
+ if (responseType !== "Blob" && responseType !== "ArrayBuffer" && responseType !== "string") {
3457
+ return "unknown";
3458
+ }
3459
+ return responseType;
3460
+ }
3461
+ };
3462
+
3463
+ // src/lib/http-resource-method.generator.ts
3464
+ var HttpResourceMethodGenerator = class {
3465
+ static {
3466
+ __name(this, "HttpResourceMethodGenerator");
3467
+ }
3468
+ config;
3469
+ bodyGenerator;
3470
+ paramsGenerator;
3471
+ #responseType = "unknown";
3472
+ constructor(config) {
3473
+ this.config = config;
3474
+ this.bodyGenerator = new HttpResourceMethodBodyGenerator(config);
3475
+ this.paramsGenerator = new HttpResourceMethodParamsGenerator(config);
3476
+ }
3477
+ addResourceMethod(serviceClass, operation) {
3478
+ const methodName = this.generateMethodName(operation);
3479
+ const parameters = this.paramsGenerator.generateMethodParameters(operation);
3480
+ const returnType = this.generateReturnType(operation);
3481
+ const overloads = this.generateMethodOverload(parameters);
3482
+ const methodBody = this.bodyGenerator.generateMethodBody(operation);
3483
+ serviceClass.addMethod({
3484
+ name: methodName,
3485
+ parameters,
3486
+ returnType,
3487
+ statements: methodBody,
3488
+ overloads
3489
+ });
3490
+ }
3491
+ generateMethodName(operation) {
3492
+ if (operation.operationId) {
3493
+ return camelCase(operation.operationId);
3494
+ }
3495
+ const method = operation.method.toLowerCase();
3496
+ const pathParts = operation.path.split("/").filter((p) => p && !p.startsWith("{"));
3497
+ const resource = pathParts[pathParts.length - 1] || "resource";
3498
+ return `${method}${pascalCase(resource)}`;
3499
+ }
3500
+ generateReturnType(operation) {
3501
+ const response = operation.responses?.["200"] || operation.responses?.["201"] || operation.responses?.["204"];
3502
+ if (!response) {
3503
+ return "any";
3504
+ }
3505
+ this.#responseType = getResponseType(response, this.config);
3506
+ return `HttpResourceRef<${this.#responseType} | undefined>`;
3507
+ }
3508
+ generateMethodOverload(methodParams) {
3509
+ const _methodParams = structuredClone(methodParams);
3510
+ const params = _methodParams.slice(0, -2).map((p) => {
3511
+ if (p.hasQuestionToken) {
3512
+ p.hasQuestionToken = false;
3513
+ p.type += " | undefined";
3514
+ }
3515
+ return p;
3516
+ });
3517
+ const optionParams = _methodParams.slice(-2).map((p) => {
3518
+ if (p.name === "resourceOptions") {
3519
+ p.hasQuestionToken = false;
3520
+ p.type += ` & { defaultValue: NoInfer<${this.#responseType}> }`;
3521
+ }
3522
+ return p;
3523
+ });
3524
+ return [
3525
+ {
3526
+ parameters: [
3527
+ ...params,
3528
+ ...optionParams
3529
+ ],
3530
+ returnType: `HttpResourceRef<${this.#responseType}>`
3531
+ }
3532
+ ];
3533
+ }
3534
+ };
3535
+
3536
+ // src/lib/http-resource-index.generator.ts
3537
+ import * as fs2 from "fs";
3538
+ import * as path2 from "path";
3539
+ var HttpResourceIndexGenerator = class {
3540
+ static {
3541
+ __name(this, "HttpResourceIndexGenerator");
3542
+ }
3543
+ project;
3544
+ constructor(project) {
3545
+ this.project = project;
3546
+ }
3547
+ generateIndex(outputRoot) {
3548
+ const servicesDir = path2.join(outputRoot, "resources");
3549
+ const indexPath = path2.join(servicesDir, "index.ts");
3550
+ const sourceFile = this.project.createSourceFile(indexPath, "", {
3551
+ overwrite: true
3552
+ });
3553
+ sourceFile.insertText(0, SERVICE_INDEX_GENERATOR_HEADER_COMMENT);
3554
+ const serviceFiles = fs2.readdirSync(servicesDir).filter((file) => file.endsWith(".resource.ts")).map((file) => file.replace(".resource.ts", ""));
3555
+ serviceFiles.forEach((serviceName) => {
3556
+ const className = pascalCase(serviceName) + "Resource";
3557
+ sourceFile.addExportDeclaration({
3558
+ namedExports: [
3559
+ className
3560
+ ],
3561
+ moduleSpecifier: `./${serviceName}.resource`
3562
+ });
3563
+ });
3564
+ sourceFile.formatText();
3565
+ sourceFile.saveSync();
3566
+ }
3567
+ };
3568
+
3569
+ // src/lib/http-resource.generator.ts
3570
+ var HttpResourceGenerator = class _HttpResourceGenerator {
3571
+ static {
3572
+ __name(this, "HttpResourceGenerator");
3573
+ }
3574
+ project;
3575
+ parser;
3576
+ spec;
3577
+ config;
3578
+ methodGenerator;
3579
+ indexGenerator;
3580
+ constructor(parser, project, config) {
3581
+ this.config = config;
3582
+ this.project = project;
3583
+ this.parser = parser;
3584
+ this.spec = this.parser.getSpec();
3585
+ this.indexGenerator = new HttpResourceIndexGenerator(project);
3586
+ if (!this.parser.isValidSpec()) {
3587
+ const versionInfo = this.parser.getSpecVersion();
3588
+ throw new Error(`Invalid or unsupported specification format. Expected OpenAPI 3.x or Swagger 2.x. ${versionInfo ? `Found: ${versionInfo.type} ${versionInfo.version}` : "No version info found"}`);
3589
+ }
3590
+ this.methodGenerator = new HttpResourceMethodGenerator(config);
3591
+ }
3592
+ static async create(swaggerPathOrUrl, project, config) {
3593
+ const parser = await SwaggerParser.create(swaggerPathOrUrl, config);
3594
+ return new _HttpResourceGenerator(parser, project, config);
3595
+ }
3596
+ generate(outputRoot) {
3597
+ const outputDir = path3.join(outputRoot, "resources");
3598
+ const paths = extractPaths(this.spec.paths, [
3599
+ "get"
3600
+ ]);
3601
+ if (paths.length === 0) {
3602
+ console.warn("No API paths found in the specification");
3603
+ return;
3604
+ }
3605
+ const controllerGroups = this.groupPathsByController(paths);
3606
+ Object.entries(controllerGroups).forEach(([resourceName, operations]) => {
3607
+ this.generateServiceFile(resourceName, operations, outputDir);
3608
+ });
3609
+ this.indexGenerator.generateIndex(outputRoot);
3610
+ }
3611
+ groupPathsByController(paths) {
3612
+ const groups = {};
3613
+ paths.forEach((path4) => {
3614
+ let controllerName = "Default";
3615
+ if (path4.tags && path4.tags.length > 0) {
3616
+ controllerName = path4.tags[0];
3617
+ } else {
3618
+ const pathParts = path4.path.split("/").filter((p) => p && !p.startsWith("{"));
3619
+ if (pathParts.length > 1) {
3620
+ controllerName = pascalCase(pathParts[1]);
3621
+ }
3622
+ }
3623
+ controllerName += "Resource";
3624
+ controllerName = pascalCase(controllerName);
3625
+ if (!groups[controllerName]) {
3626
+ groups[controllerName] = [];
3627
+ }
3628
+ groups[controllerName].push(path4);
3629
+ });
3630
+ return groups;
3631
+ }
3632
+ generateServiceFile(resourceName, operations, outputDir) {
3633
+ const fileName = `${camelCase(resourceName).replace(/Resource/, "")}.resource.ts`;
3634
+ const filePath = path3.join(outputDir, fileName);
3635
+ const sourceFile = this.project.createSourceFile(filePath, "", {
3636
+ overwrite: true
3637
+ });
3638
+ const usedTypes = collectUsedTypes(operations);
3639
+ this.addImports(sourceFile, usedTypes);
3640
+ this.addServiceClass(sourceFile, resourceName, operations);
3641
+ sourceFile.formatText();
3642
+ sourceFile.saveSync();
3643
+ }
3644
+ addImports(sourceFile, usedTypes) {
3645
+ const basePathTokenName = getBasePathTokenName(this.config.clientName);
3646
+ const clientContextTokenName = getClientContextTokenName(this.config.clientName);
3647
+ sourceFile.addImportDeclarations([
3648
+ {
3649
+ namedImports: [
3650
+ "Injectable",
3651
+ "inject",
3652
+ "Signal"
3653
+ ],
3654
+ moduleSpecifier: "@angular/core"
3655
+ },
3656
+ {
3657
+ namedImports: [
3658
+ "HttpResourceRef",
3659
+ "HttpContext",
3660
+ "httpResource",
3661
+ "HttpResourceRequest",
3662
+ "HttpResourceOptions",
3663
+ "HttpParams",
3664
+ "HttpContextToken",
3665
+ "HttpHeaders"
3666
+ ],
3667
+ moduleSpecifier: "@angular/common/http"
3668
+ },
3669
+ {
3670
+ namedImports: [
3671
+ basePathTokenName,
3672
+ clientContextTokenName
3673
+ ],
3674
+ moduleSpecifier: "../tokens"
3675
+ }
3676
+ ]);
3677
+ if (usedTypes.size > 0) {
3678
+ sourceFile.addImportDeclaration({
3679
+ namedImports: Array.from(usedTypes).sort(),
3680
+ moduleSpecifier: "../models"
3681
+ });
3682
+ }
3683
+ }
3684
+ addServiceClass(sourceFile, resourceName, operations) {
3685
+ const className = `${resourceName}`;
3686
+ const basePathTokenName = getBasePathTokenName(this.config.clientName);
3687
+ const clientContextTokenName = getClientContextTokenName(this.config.clientName);
3688
+ sourceFile.insertText(0, HTTP_RESOURCE_GENERATOR_HEADER_COMMENT(resourceName));
3689
+ const serviceClass = sourceFile.addClass({
3690
+ name: className,
3691
+ isExported: true,
3692
+ decorators: [
3693
+ {
3694
+ name: "Injectable",
3695
+ arguments: [
3696
+ '{ providedIn: "root" }'
3697
+ ]
3698
+ }
3699
+ ]
3700
+ });
3701
+ serviceClass.addProperty({
3702
+ name: "basePath",
3703
+ type: "string",
3704
+ scope: Scope.Private,
3705
+ isReadonly: true,
3706
+ initializer: `inject(${basePathTokenName})`
3707
+ });
3708
+ serviceClass.addProperty({
3709
+ name: "clientContextToken",
3710
+ type: "HttpContextToken<string>",
3711
+ scope: Scope.Private,
3712
+ isReadonly: true,
3713
+ initializer: clientContextTokenName
3714
+ });
3715
+ serviceClass.addMethod({
3716
+ name: "createContextWithClientId",
3717
+ scope: Scope.Private,
3718
+ parameters: [
3719
+ {
3720
+ name: "existingContext",
3721
+ type: "HttpContext",
3722
+ hasQuestionToken: true
3723
+ }
3724
+ ],
3725
+ returnType: "HttpContext",
3726
+ statements: `const context = existingContext || new HttpContext();
3727
+ return context.set(this.clientContextToken, '${this.config.clientName || "default"}');`
3728
+ });
3729
+ operations.forEach((operation) => {
3730
+ this.methodGenerator.addResourceMethod(serviceClass, operation);
3731
+ });
3732
+ if (hasDuplicateFunctionNames(serviceClass.getMethods())) {
3733
+ throw new Error(`Duplicate method names found in service class ${className}. Please ensure unique method names for each operation.`);
3734
+ }
3735
+ }
3736
+ };
3737
+ export {
3738
+ HttpResourceGenerator,
3739
+ HttpResourceIndexGenerator,
3740
+ HttpResourceMethodBodyGenerator,
3741
+ HttpResourceMethodGenerator,
3742
+ HttpResourceMethodParamsGenerator
3743
+ };
3744
+ /*! Bundled license information:
3745
+
3746
+ js-yaml/dist/js-yaml.mjs:
3747
+ (*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
3748
+ */
3749
+ //# sourceMappingURL=index.js.map