@akson/cortex-analytics 0.8.1 → 0.9.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.
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@akson/cortex-analytics",
11
- version: "0.8.1",
11
+ version: "0.9.0",
12
12
  description: "Unified CLI for Cortex analytics operations across all platforms",
13
13
  type: "module",
14
14
  main: "dist/index.js",
@@ -25,17 +25,19 @@ var require_package = __commonJS({
25
25
  "type-check": "tsc --noEmit"
26
26
  },
27
27
  dependencies: {
28
- "@akson/cortex-gsc": "^0.5.0",
29
- "@akson/cortex-gtm": "^3.0.0",
30
- "@akson/cortex-posthog": "^0.4.0",
28
+ "@akson/cortex-gsc": "workspace:*",
29
+ "@akson/cortex-gtm": "workspace:*",
30
+ "@akson/cortex-posthog": "workspace:*",
31
31
  chalk: "^5.5.0",
32
32
  commander: "^14.0.0",
33
- inquirer: "^11.1.0",
33
+ inquirer: "^13.1.0",
34
+ "js-yaml": "^4.1.0",
34
35
  ora: "^8.1.1",
35
36
  table: "^6.9.0"
36
37
  },
37
38
  devDependencies: {
38
39
  "@types/inquirer": "^9.0.7",
40
+ "@types/js-yaml": "^4.0.9",
39
41
  "@types/node": "^22",
40
42
  eslint: "^8",
41
43
  tsup: "^8.5.0",
@@ -106,2630 +108,7 @@ import {
106
108
  } from "@akson/cortex-utilities";
107
109
  import chalk from "chalk";
108
110
  import inquirer from "inquirer";
109
-
110
- // node_modules/js-yaml/dist/js-yaml.mjs
111
- function isNothing(subject) {
112
- return typeof subject === "undefined" || subject === null;
113
- }
114
- function isObject(subject) {
115
- return typeof subject === "object" && subject !== null;
116
- }
117
- function toArray(sequence) {
118
- if (Array.isArray(sequence)) return sequence;
119
- else if (isNothing(sequence)) return [];
120
- return [sequence];
121
- }
122
- function extend(target, source) {
123
- var index, length, key, sourceKeys;
124
- if (source) {
125
- sourceKeys = Object.keys(source);
126
- for (index = 0, length = sourceKeys.length; index < length; index += 1) {
127
- key = sourceKeys[index];
128
- target[key] = source[key];
129
- }
130
- }
131
- return target;
132
- }
133
- function repeat(string, count) {
134
- var result = "", cycle;
135
- for (cycle = 0; cycle < count; cycle += 1) {
136
- result += string;
137
- }
138
- return result;
139
- }
140
- function isNegativeZero(number) {
141
- return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
142
- }
143
- var isNothing_1 = isNothing;
144
- var isObject_1 = isObject;
145
- var toArray_1 = toArray;
146
- var repeat_1 = repeat;
147
- var isNegativeZero_1 = isNegativeZero;
148
- var extend_1 = extend;
149
- var common = {
150
- isNothing: isNothing_1,
151
- isObject: isObject_1,
152
- toArray: toArray_1,
153
- repeat: repeat_1,
154
- isNegativeZero: isNegativeZero_1,
155
- extend: extend_1
156
- };
157
- function formatError(exception2, compact) {
158
- var where = "", message = exception2.reason || "(unknown reason)";
159
- if (!exception2.mark) return message;
160
- if (exception2.mark.name) {
161
- where += 'in "' + exception2.mark.name + '" ';
162
- }
163
- where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
164
- if (!compact && exception2.mark.snippet) {
165
- where += "\n\n" + exception2.mark.snippet;
166
- }
167
- return message + " " + where;
168
- }
169
- function YAMLException$1(reason, mark) {
170
- Error.call(this);
171
- this.name = "YAMLException";
172
- this.reason = reason;
173
- this.mark = mark;
174
- this.message = formatError(this, false);
175
- if (Error.captureStackTrace) {
176
- Error.captureStackTrace(this, this.constructor);
177
- } else {
178
- this.stack = new Error().stack || "";
179
- }
180
- }
181
- YAMLException$1.prototype = Object.create(Error.prototype);
182
- YAMLException$1.prototype.constructor = YAMLException$1;
183
- YAMLException$1.prototype.toString = function toString(compact) {
184
- return this.name + ": " + formatError(this, compact);
185
- };
186
- var exception = YAMLException$1;
187
- function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
188
- var head = "";
189
- var tail = "";
190
- var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
191
- if (position - lineStart > maxHalfLength) {
192
- head = " ... ";
193
- lineStart = position - maxHalfLength + head.length;
194
- }
195
- if (lineEnd - position > maxHalfLength) {
196
- tail = " ...";
197
- lineEnd = position + maxHalfLength - tail.length;
198
- }
199
- return {
200
- str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
201
- pos: position - lineStart + head.length
202
- // relative position
203
- };
204
- }
205
- function padStart(string, max) {
206
- return common.repeat(" ", max - string.length) + string;
207
- }
208
- function makeSnippet(mark, options) {
209
- options = Object.create(options || null);
210
- if (!mark.buffer) return null;
211
- if (!options.maxLength) options.maxLength = 79;
212
- if (typeof options.indent !== "number") options.indent = 1;
213
- if (typeof options.linesBefore !== "number") options.linesBefore = 3;
214
- if (typeof options.linesAfter !== "number") options.linesAfter = 2;
215
- var re = /\r?\n|\r|\0/g;
216
- var lineStarts = [0];
217
- var lineEnds = [];
218
- var match;
219
- var foundLineNo = -1;
220
- while (match = re.exec(mark.buffer)) {
221
- lineEnds.push(match.index);
222
- lineStarts.push(match.index + match[0].length);
223
- if (mark.position <= match.index && foundLineNo < 0) {
224
- foundLineNo = lineStarts.length - 2;
225
- }
226
- }
227
- if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
228
- var result = "", i, line;
229
- var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
230
- var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
231
- for (i = 1; i <= options.linesBefore; i++) {
232
- if (foundLineNo - i < 0) break;
233
- line = getLine(
234
- mark.buffer,
235
- lineStarts[foundLineNo - i],
236
- lineEnds[foundLineNo - i],
237
- mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
238
- maxLineLength
239
- );
240
- result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
241
- }
242
- line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
243
- result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
244
- result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
245
- for (i = 1; i <= options.linesAfter; i++) {
246
- if (foundLineNo + i >= lineEnds.length) break;
247
- line = getLine(
248
- mark.buffer,
249
- lineStarts[foundLineNo + i],
250
- lineEnds[foundLineNo + i],
251
- mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
252
- maxLineLength
253
- );
254
- result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
255
- }
256
- return result.replace(/\n$/, "");
257
- }
258
- var snippet = makeSnippet;
259
- var TYPE_CONSTRUCTOR_OPTIONS = [
260
- "kind",
261
- "multi",
262
- "resolve",
263
- "construct",
264
- "instanceOf",
265
- "predicate",
266
- "represent",
267
- "representName",
268
- "defaultStyle",
269
- "styleAliases"
270
- ];
271
- var YAML_NODE_KINDS = [
272
- "scalar",
273
- "sequence",
274
- "mapping"
275
- ];
276
- function compileStyleAliases(map2) {
277
- var result = {};
278
- if (map2 !== null) {
279
- Object.keys(map2).forEach(function(style) {
280
- map2[style].forEach(function(alias) {
281
- result[String(alias)] = style;
282
- });
283
- });
284
- }
285
- return result;
286
- }
287
- function Type$1(tag, options) {
288
- options = options || {};
289
- Object.keys(options).forEach(function(name) {
290
- if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
291
- throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
292
- }
293
- });
294
- this.options = options;
295
- this.tag = tag;
296
- this.kind = options["kind"] || null;
297
- this.resolve = options["resolve"] || function() {
298
- return true;
299
- };
300
- this.construct = options["construct"] || function(data) {
301
- return data;
302
- };
303
- this.instanceOf = options["instanceOf"] || null;
304
- this.predicate = options["predicate"] || null;
305
- this.represent = options["represent"] || null;
306
- this.representName = options["representName"] || null;
307
- this.defaultStyle = options["defaultStyle"] || null;
308
- this.multi = options["multi"] || false;
309
- this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
310
- if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
311
- throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
312
- }
313
- }
314
- var type = Type$1;
315
- function compileList(schema2, name) {
316
- var result = [];
317
- schema2[name].forEach(function(currentType) {
318
- var newIndex = result.length;
319
- result.forEach(function(previousType, previousIndex) {
320
- if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
321
- newIndex = previousIndex;
322
- }
323
- });
324
- result[newIndex] = currentType;
325
- });
326
- return result;
327
- }
328
- function compileMap() {
329
- var result = {
330
- scalar: {},
331
- sequence: {},
332
- mapping: {},
333
- fallback: {},
334
- multi: {
335
- scalar: [],
336
- sequence: [],
337
- mapping: [],
338
- fallback: []
339
- }
340
- }, index, length;
341
- function collectType(type2) {
342
- if (type2.multi) {
343
- result.multi[type2.kind].push(type2);
344
- result.multi["fallback"].push(type2);
345
- } else {
346
- result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
347
- }
348
- }
349
- for (index = 0, length = arguments.length; index < length; index += 1) {
350
- arguments[index].forEach(collectType);
351
- }
352
- return result;
353
- }
354
- function Schema$1(definition) {
355
- return this.extend(definition);
356
- }
357
- Schema$1.prototype.extend = function extend2(definition) {
358
- var implicit = [];
359
- var explicit = [];
360
- if (definition instanceof type) {
361
- explicit.push(definition);
362
- } else if (Array.isArray(definition)) {
363
- explicit = explicit.concat(definition);
364
- } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
365
- if (definition.implicit) implicit = implicit.concat(definition.implicit);
366
- if (definition.explicit) explicit = explicit.concat(definition.explicit);
367
- } else {
368
- throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
369
- }
370
- implicit.forEach(function(type$1) {
371
- if (!(type$1 instanceof type)) {
372
- throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
373
- }
374
- if (type$1.loadKind && type$1.loadKind !== "scalar") {
375
- throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
376
- }
377
- if (type$1.multi) {
378
- throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
379
- }
380
- });
381
- explicit.forEach(function(type$1) {
382
- if (!(type$1 instanceof type)) {
383
- throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
384
- }
385
- });
386
- var result = Object.create(Schema$1.prototype);
387
- result.implicit = (this.implicit || []).concat(implicit);
388
- result.explicit = (this.explicit || []).concat(explicit);
389
- result.compiledImplicit = compileList(result, "implicit");
390
- result.compiledExplicit = compileList(result, "explicit");
391
- result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
392
- return result;
393
- };
394
- var schema = Schema$1;
395
- var str = new type("tag:yaml.org,2002:str", {
396
- kind: "scalar",
397
- construct: function(data) {
398
- return data !== null ? data : "";
399
- }
400
- });
401
- var seq = new type("tag:yaml.org,2002:seq", {
402
- kind: "sequence",
403
- construct: function(data) {
404
- return data !== null ? data : [];
405
- }
406
- });
407
- var map = new type("tag:yaml.org,2002:map", {
408
- kind: "mapping",
409
- construct: function(data) {
410
- return data !== null ? data : {};
411
- }
412
- });
413
- var failsafe = new schema({
414
- explicit: [
415
- str,
416
- seq,
417
- map
418
- ]
419
- });
420
- function resolveYamlNull(data) {
421
- if (data === null) return true;
422
- var max = data.length;
423
- return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
424
- }
425
- function constructYamlNull() {
426
- return null;
427
- }
428
- function isNull(object) {
429
- return object === null;
430
- }
431
- var _null = new type("tag:yaml.org,2002:null", {
432
- kind: "scalar",
433
- resolve: resolveYamlNull,
434
- construct: constructYamlNull,
435
- predicate: isNull,
436
- represent: {
437
- canonical: function() {
438
- return "~";
439
- },
440
- lowercase: function() {
441
- return "null";
442
- },
443
- uppercase: function() {
444
- return "NULL";
445
- },
446
- camelcase: function() {
447
- return "Null";
448
- },
449
- empty: function() {
450
- return "";
451
- }
452
- },
453
- defaultStyle: "lowercase"
454
- });
455
- function resolveYamlBoolean(data) {
456
- if (data === null) return false;
457
- var max = data.length;
458
- return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
459
- }
460
- function constructYamlBoolean(data) {
461
- return data === "true" || data === "True" || data === "TRUE";
462
- }
463
- function isBoolean(object) {
464
- return Object.prototype.toString.call(object) === "[object Boolean]";
465
- }
466
- var bool = new type("tag:yaml.org,2002:bool", {
467
- kind: "scalar",
468
- resolve: resolveYamlBoolean,
469
- construct: constructYamlBoolean,
470
- predicate: isBoolean,
471
- represent: {
472
- lowercase: function(object) {
473
- return object ? "true" : "false";
474
- },
475
- uppercase: function(object) {
476
- return object ? "TRUE" : "FALSE";
477
- },
478
- camelcase: function(object) {
479
- return object ? "True" : "False";
480
- }
481
- },
482
- defaultStyle: "lowercase"
483
- });
484
- function isHexCode(c) {
485
- return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
486
- }
487
- function isOctCode(c) {
488
- return 48 <= c && c <= 55;
489
- }
490
- function isDecCode(c) {
491
- return 48 <= c && c <= 57;
492
- }
493
- function resolveYamlInteger(data) {
494
- if (data === null) return false;
495
- var max = data.length, index = 0, hasDigits = false, ch;
496
- if (!max) return false;
497
- ch = data[index];
498
- if (ch === "-" || ch === "+") {
499
- ch = data[++index];
500
- }
501
- if (ch === "0") {
502
- if (index + 1 === max) return true;
503
- ch = data[++index];
504
- if (ch === "b") {
505
- index++;
506
- for (; index < max; index++) {
507
- ch = data[index];
508
- if (ch === "_") continue;
509
- if (ch !== "0" && ch !== "1") return false;
510
- hasDigits = true;
511
- }
512
- return hasDigits && ch !== "_";
513
- }
514
- if (ch === "x") {
515
- index++;
516
- for (; index < max; index++) {
517
- ch = data[index];
518
- if (ch === "_") continue;
519
- if (!isHexCode(data.charCodeAt(index))) return false;
520
- hasDigits = true;
521
- }
522
- return hasDigits && ch !== "_";
523
- }
524
- if (ch === "o") {
525
- index++;
526
- for (; index < max; index++) {
527
- ch = data[index];
528
- if (ch === "_") continue;
529
- if (!isOctCode(data.charCodeAt(index))) return false;
530
- hasDigits = true;
531
- }
532
- return hasDigits && ch !== "_";
533
- }
534
- }
535
- if (ch === "_") return false;
536
- for (; index < max; index++) {
537
- ch = data[index];
538
- if (ch === "_") continue;
539
- if (!isDecCode(data.charCodeAt(index))) {
540
- return false;
541
- }
542
- hasDigits = true;
543
- }
544
- if (!hasDigits || ch === "_") return false;
545
- return true;
546
- }
547
- function constructYamlInteger(data) {
548
- var value = data, sign = 1, ch;
549
- if (value.indexOf("_") !== -1) {
550
- value = value.replace(/_/g, "");
551
- }
552
- ch = value[0];
553
- if (ch === "-" || ch === "+") {
554
- if (ch === "-") sign = -1;
555
- value = value.slice(1);
556
- ch = value[0];
557
- }
558
- if (value === "0") return 0;
559
- if (ch === "0") {
560
- if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
561
- if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
562
- if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
563
- }
564
- return sign * parseInt(value, 10);
565
- }
566
- function isInteger(object) {
567
- return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
568
- }
569
- var int = new type("tag:yaml.org,2002:int", {
570
- kind: "scalar",
571
- resolve: resolveYamlInteger,
572
- construct: constructYamlInteger,
573
- predicate: isInteger,
574
- represent: {
575
- binary: function(obj) {
576
- return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
577
- },
578
- octal: function(obj) {
579
- return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
580
- },
581
- decimal: function(obj) {
582
- return obj.toString(10);
583
- },
584
- /* eslint-disable max-len */
585
- hexadecimal: function(obj) {
586
- return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
587
- }
588
- },
589
- defaultStyle: "decimal",
590
- styleAliases: {
591
- binary: [2, "bin"],
592
- octal: [8, "oct"],
593
- decimal: [10, "dec"],
594
- hexadecimal: [16, "hex"]
595
- }
596
- });
597
- var YAML_FLOAT_PATTERN = new RegExp(
598
- // 2.5e4, 2.5 and integers
599
- "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
600
- );
601
- function resolveYamlFloat(data) {
602
- if (data === null) return false;
603
- if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
604
- // Probably should update regexp & check speed
605
- data[data.length - 1] === "_") {
606
- return false;
607
- }
608
- return true;
609
- }
610
- function constructYamlFloat(data) {
611
- var value, sign;
612
- value = data.replace(/_/g, "").toLowerCase();
613
- sign = value[0] === "-" ? -1 : 1;
614
- if ("+-".indexOf(value[0]) >= 0) {
615
- value = value.slice(1);
616
- }
617
- if (value === ".inf") {
618
- return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
619
- } else if (value === ".nan") {
620
- return NaN;
621
- }
622
- return sign * parseFloat(value, 10);
623
- }
624
- var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
625
- function representYamlFloat(object, style) {
626
- var res;
627
- if (isNaN(object)) {
628
- switch (style) {
629
- case "lowercase":
630
- return ".nan";
631
- case "uppercase":
632
- return ".NAN";
633
- case "camelcase":
634
- return ".NaN";
635
- }
636
- } else if (Number.POSITIVE_INFINITY === object) {
637
- switch (style) {
638
- case "lowercase":
639
- return ".inf";
640
- case "uppercase":
641
- return ".INF";
642
- case "camelcase":
643
- return ".Inf";
644
- }
645
- } else if (Number.NEGATIVE_INFINITY === object) {
646
- switch (style) {
647
- case "lowercase":
648
- return "-.inf";
649
- case "uppercase":
650
- return "-.INF";
651
- case "camelcase":
652
- return "-.Inf";
653
- }
654
- } else if (common.isNegativeZero(object)) {
655
- return "-0.0";
656
- }
657
- res = object.toString(10);
658
- return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
659
- }
660
- function isFloat(object) {
661
- return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
662
- }
663
- var float = new type("tag:yaml.org,2002:float", {
664
- kind: "scalar",
665
- resolve: resolveYamlFloat,
666
- construct: constructYamlFloat,
667
- predicate: isFloat,
668
- represent: representYamlFloat,
669
- defaultStyle: "lowercase"
670
- });
671
- var json = failsafe.extend({
672
- implicit: [
673
- _null,
674
- bool,
675
- int,
676
- float
677
- ]
678
- });
679
- var core = json;
680
- var YAML_DATE_REGEXP = new RegExp(
681
- "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
682
- );
683
- var YAML_TIMESTAMP_REGEXP = new RegExp(
684
- "^([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]))?))?$"
685
- );
686
- function resolveYamlTimestamp(data) {
687
- if (data === null) return false;
688
- if (YAML_DATE_REGEXP.exec(data) !== null) return true;
689
- if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
690
- return false;
691
- }
692
- function constructYamlTimestamp(data) {
693
- var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
694
- match = YAML_DATE_REGEXP.exec(data);
695
- if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
696
- if (match === null) throw new Error("Date resolve error");
697
- year = +match[1];
698
- month = +match[2] - 1;
699
- day = +match[3];
700
- if (!match[4]) {
701
- return new Date(Date.UTC(year, month, day));
702
- }
703
- hour = +match[4];
704
- minute = +match[5];
705
- second = +match[6];
706
- if (match[7]) {
707
- fraction = match[7].slice(0, 3);
708
- while (fraction.length < 3) {
709
- fraction += "0";
710
- }
711
- fraction = +fraction;
712
- }
713
- if (match[9]) {
714
- tz_hour = +match[10];
715
- tz_minute = +(match[11] || 0);
716
- delta = (tz_hour * 60 + tz_minute) * 6e4;
717
- if (match[9] === "-") delta = -delta;
718
- }
719
- date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
720
- if (delta) date.setTime(date.getTime() - delta);
721
- return date;
722
- }
723
- function representYamlTimestamp(object) {
724
- return object.toISOString();
725
- }
726
- var timestamp = new type("tag:yaml.org,2002:timestamp", {
727
- kind: "scalar",
728
- resolve: resolveYamlTimestamp,
729
- construct: constructYamlTimestamp,
730
- instanceOf: Date,
731
- represent: representYamlTimestamp
732
- });
733
- function resolveYamlMerge(data) {
734
- return data === "<<" || data === null;
735
- }
736
- var merge = new type("tag:yaml.org,2002:merge", {
737
- kind: "scalar",
738
- resolve: resolveYamlMerge
739
- });
740
- var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
741
- function resolveYamlBinary(data) {
742
- if (data === null) return false;
743
- var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
744
- for (idx = 0; idx < max; idx++) {
745
- code = map2.indexOf(data.charAt(idx));
746
- if (code > 64) continue;
747
- if (code < 0) return false;
748
- bitlen += 6;
749
- }
750
- return bitlen % 8 === 0;
751
- }
752
- function constructYamlBinary(data) {
753
- var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
754
- for (idx = 0; idx < max; idx++) {
755
- if (idx % 4 === 0 && idx) {
756
- result.push(bits >> 16 & 255);
757
- result.push(bits >> 8 & 255);
758
- result.push(bits & 255);
759
- }
760
- bits = bits << 6 | map2.indexOf(input.charAt(idx));
761
- }
762
- tailbits = max % 4 * 6;
763
- if (tailbits === 0) {
764
- result.push(bits >> 16 & 255);
765
- result.push(bits >> 8 & 255);
766
- result.push(bits & 255);
767
- } else if (tailbits === 18) {
768
- result.push(bits >> 10 & 255);
769
- result.push(bits >> 2 & 255);
770
- } else if (tailbits === 12) {
771
- result.push(bits >> 4 & 255);
772
- }
773
- return new Uint8Array(result);
774
- }
775
- function representYamlBinary(object) {
776
- var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
777
- for (idx = 0; idx < max; idx++) {
778
- if (idx % 3 === 0 && idx) {
779
- result += map2[bits >> 18 & 63];
780
- result += map2[bits >> 12 & 63];
781
- result += map2[bits >> 6 & 63];
782
- result += map2[bits & 63];
783
- }
784
- bits = (bits << 8) + object[idx];
785
- }
786
- tail = max % 3;
787
- if (tail === 0) {
788
- result += map2[bits >> 18 & 63];
789
- result += map2[bits >> 12 & 63];
790
- result += map2[bits >> 6 & 63];
791
- result += map2[bits & 63];
792
- } else if (tail === 2) {
793
- result += map2[bits >> 10 & 63];
794
- result += map2[bits >> 4 & 63];
795
- result += map2[bits << 2 & 63];
796
- result += map2[64];
797
- } else if (tail === 1) {
798
- result += map2[bits >> 2 & 63];
799
- result += map2[bits << 4 & 63];
800
- result += map2[64];
801
- result += map2[64];
802
- }
803
- return result;
804
- }
805
- function isBinary(obj) {
806
- return Object.prototype.toString.call(obj) === "[object Uint8Array]";
807
- }
808
- var binary = new type("tag:yaml.org,2002:binary", {
809
- kind: "scalar",
810
- resolve: resolveYamlBinary,
811
- construct: constructYamlBinary,
812
- predicate: isBinary,
813
- represent: representYamlBinary
814
- });
815
- var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
816
- var _toString$2 = Object.prototype.toString;
817
- function resolveYamlOmap(data) {
818
- if (data === null) return true;
819
- var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
820
- for (index = 0, length = object.length; index < length; index += 1) {
821
- pair = object[index];
822
- pairHasKey = false;
823
- if (_toString$2.call(pair) !== "[object Object]") return false;
824
- for (pairKey in pair) {
825
- if (_hasOwnProperty$3.call(pair, pairKey)) {
826
- if (!pairHasKey) pairHasKey = true;
827
- else return false;
828
- }
829
- }
830
- if (!pairHasKey) return false;
831
- if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
832
- else return false;
833
- }
834
- return true;
835
- }
836
- function constructYamlOmap(data) {
837
- return data !== null ? data : [];
838
- }
839
- var omap = new type("tag:yaml.org,2002:omap", {
840
- kind: "sequence",
841
- resolve: resolveYamlOmap,
842
- construct: constructYamlOmap
843
- });
844
- var _toString$1 = Object.prototype.toString;
845
- function resolveYamlPairs(data) {
846
- if (data === null) return true;
847
- var index, length, pair, keys, result, object = data;
848
- result = new Array(object.length);
849
- for (index = 0, length = object.length; index < length; index += 1) {
850
- pair = object[index];
851
- if (_toString$1.call(pair) !== "[object Object]") return false;
852
- keys = Object.keys(pair);
853
- if (keys.length !== 1) return false;
854
- result[index] = [keys[0], pair[keys[0]]];
855
- }
856
- return true;
857
- }
858
- function constructYamlPairs(data) {
859
- if (data === null) return [];
860
- var index, length, pair, keys, result, object = data;
861
- result = new Array(object.length);
862
- for (index = 0, length = object.length; index < length; index += 1) {
863
- pair = object[index];
864
- keys = Object.keys(pair);
865
- result[index] = [keys[0], pair[keys[0]]];
866
- }
867
- return result;
868
- }
869
- var pairs = new type("tag:yaml.org,2002:pairs", {
870
- kind: "sequence",
871
- resolve: resolveYamlPairs,
872
- construct: constructYamlPairs
873
- });
874
- var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
875
- function resolveYamlSet(data) {
876
- if (data === null) return true;
877
- var key, object = data;
878
- for (key in object) {
879
- if (_hasOwnProperty$2.call(object, key)) {
880
- if (object[key] !== null) return false;
881
- }
882
- }
883
- return true;
884
- }
885
- function constructYamlSet(data) {
886
- return data !== null ? data : {};
887
- }
888
- var set = new type("tag:yaml.org,2002:set", {
889
- kind: "mapping",
890
- resolve: resolveYamlSet,
891
- construct: constructYamlSet
892
- });
893
- var _default = core.extend({
894
- implicit: [
895
- timestamp,
896
- merge
897
- ],
898
- explicit: [
899
- binary,
900
- omap,
901
- pairs,
902
- set
903
- ]
904
- });
905
- var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
906
- var CONTEXT_FLOW_IN = 1;
907
- var CONTEXT_FLOW_OUT = 2;
908
- var CONTEXT_BLOCK_IN = 3;
909
- var CONTEXT_BLOCK_OUT = 4;
910
- var CHOMPING_CLIP = 1;
911
- var CHOMPING_STRIP = 2;
912
- var CHOMPING_KEEP = 3;
913
- var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
914
- var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
915
- var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
916
- var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
917
- var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
918
- function _class(obj) {
919
- return Object.prototype.toString.call(obj);
920
- }
921
- function is_EOL(c) {
922
- return c === 10 || c === 13;
923
- }
924
- function is_WHITE_SPACE(c) {
925
- return c === 9 || c === 32;
926
- }
927
- function is_WS_OR_EOL(c) {
928
- return c === 9 || c === 32 || c === 10 || c === 13;
929
- }
930
- function is_FLOW_INDICATOR(c) {
931
- return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
932
- }
933
- function fromHexCode(c) {
934
- var lc;
935
- if (48 <= c && c <= 57) {
936
- return c - 48;
937
- }
938
- lc = c | 32;
939
- if (97 <= lc && lc <= 102) {
940
- return lc - 97 + 10;
941
- }
942
- return -1;
943
- }
944
- function escapedHexLen(c) {
945
- if (c === 120) {
946
- return 2;
947
- }
948
- if (c === 117) {
949
- return 4;
950
- }
951
- if (c === 85) {
952
- return 8;
953
- }
954
- return 0;
955
- }
956
- function fromDecimalCode(c) {
957
- if (48 <= c && c <= 57) {
958
- return c - 48;
959
- }
960
- return -1;
961
- }
962
- function simpleEscapeSequence(c) {
963
- 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" : "";
964
- }
965
- function charFromCodepoint(c) {
966
- if (c <= 65535) {
967
- return String.fromCharCode(c);
968
- }
969
- return String.fromCharCode(
970
- (c - 65536 >> 10) + 55296,
971
- (c - 65536 & 1023) + 56320
972
- );
973
- }
974
- var simpleEscapeCheck = new Array(256);
975
- var simpleEscapeMap = new Array(256);
976
- for (i = 0; i < 256; i++) {
977
- simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
978
- simpleEscapeMap[i] = simpleEscapeSequence(i);
979
- }
980
- var i;
981
- function State$1(input, options) {
982
- this.input = input;
983
- this.filename = options["filename"] || null;
984
- this.schema = options["schema"] || _default;
985
- this.onWarning = options["onWarning"] || null;
986
- this.legacy = options["legacy"] || false;
987
- this.json = options["json"] || false;
988
- this.listener = options["listener"] || null;
989
- this.implicitTypes = this.schema.compiledImplicit;
990
- this.typeMap = this.schema.compiledTypeMap;
991
- this.length = input.length;
992
- this.position = 0;
993
- this.line = 0;
994
- this.lineStart = 0;
995
- this.lineIndent = 0;
996
- this.firstTabInLine = -1;
997
- this.documents = [];
998
- }
999
- function generateError(state, message) {
1000
- var mark = {
1001
- name: state.filename,
1002
- buffer: state.input.slice(0, -1),
1003
- // omit trailing \0
1004
- position: state.position,
1005
- line: state.line,
1006
- column: state.position - state.lineStart
1007
- };
1008
- mark.snippet = snippet(mark);
1009
- return new exception(message, mark);
1010
- }
1011
- function throwError(state, message) {
1012
- throw generateError(state, message);
1013
- }
1014
- function throwWarning(state, message) {
1015
- if (state.onWarning) {
1016
- state.onWarning.call(null, generateError(state, message));
1017
- }
1018
- }
1019
- var directiveHandlers = {
1020
- YAML: function handleYamlDirective(state, name, args) {
1021
- var match, major, minor;
1022
- if (state.version !== null) {
1023
- throwError(state, "duplication of %YAML directive");
1024
- }
1025
- if (args.length !== 1) {
1026
- throwError(state, "YAML directive accepts exactly one argument");
1027
- }
1028
- match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1029
- if (match === null) {
1030
- throwError(state, "ill-formed argument of the YAML directive");
1031
- }
1032
- major = parseInt(match[1], 10);
1033
- minor = parseInt(match[2], 10);
1034
- if (major !== 1) {
1035
- throwError(state, "unacceptable YAML version of the document");
1036
- }
1037
- state.version = args[0];
1038
- state.checkLineBreaks = minor < 2;
1039
- if (minor !== 1 && minor !== 2) {
1040
- throwWarning(state, "unsupported YAML version of the document");
1041
- }
1042
- },
1043
- TAG: function handleTagDirective(state, name, args) {
1044
- var handle, prefix;
1045
- if (args.length !== 2) {
1046
- throwError(state, "TAG directive accepts exactly two arguments");
1047
- }
1048
- handle = args[0];
1049
- prefix = args[1];
1050
- if (!PATTERN_TAG_HANDLE.test(handle)) {
1051
- throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
1052
- }
1053
- if (_hasOwnProperty$1.call(state.tagMap, handle)) {
1054
- throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1055
- }
1056
- if (!PATTERN_TAG_URI.test(prefix)) {
1057
- throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
1058
- }
1059
- try {
1060
- prefix = decodeURIComponent(prefix);
1061
- } catch (err) {
1062
- throwError(state, "tag prefix is malformed: " + prefix);
1063
- }
1064
- state.tagMap[handle] = prefix;
1065
- }
1066
- };
1067
- function captureSegment(state, start, end, checkJson) {
1068
- var _position, _length, _character, _result;
1069
- if (start < end) {
1070
- _result = state.input.slice(start, end);
1071
- if (checkJson) {
1072
- for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
1073
- _character = _result.charCodeAt(_position);
1074
- if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
1075
- throwError(state, "expected valid JSON character");
1076
- }
1077
- }
1078
- } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1079
- throwError(state, "the stream contains non-printable characters");
1080
- }
1081
- state.result += _result;
1082
- }
1083
- }
1084
- function mergeMappings(state, destination, source, overridableKeys) {
1085
- var sourceKeys, key, index, quantity;
1086
- if (!common.isObject(source)) {
1087
- throwError(state, "cannot merge mappings; the provided source object is unacceptable");
1088
- }
1089
- sourceKeys = Object.keys(source);
1090
- for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1091
- key = sourceKeys[index];
1092
- if (!_hasOwnProperty$1.call(destination, key)) {
1093
- destination[key] = source[key];
1094
- overridableKeys[key] = true;
1095
- }
1096
- }
1097
- }
1098
- function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
1099
- var index, quantity;
1100
- if (Array.isArray(keyNode)) {
1101
- keyNode = Array.prototype.slice.call(keyNode);
1102
- for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
1103
- if (Array.isArray(keyNode[index])) {
1104
- throwError(state, "nested arrays are not supported inside keys");
1105
- }
1106
- if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
1107
- keyNode[index] = "[object Object]";
1108
- }
1109
- }
1110
- }
1111
- if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
1112
- keyNode = "[object Object]";
1113
- }
1114
- keyNode = String(keyNode);
1115
- if (_result === null) {
1116
- _result = {};
1117
- }
1118
- if (keyTag === "tag:yaml.org,2002:merge") {
1119
- if (Array.isArray(valueNode)) {
1120
- for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1121
- mergeMappings(state, _result, valueNode[index], overridableKeys);
1122
- }
1123
- } else {
1124
- mergeMappings(state, _result, valueNode, overridableKeys);
1125
- }
1126
- } else {
1127
- if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
1128
- state.line = startLine || state.line;
1129
- state.lineStart = startLineStart || state.lineStart;
1130
- state.position = startPos || state.position;
1131
- throwError(state, "duplicated mapping key");
1132
- }
1133
- if (keyNode === "__proto__") {
1134
- Object.defineProperty(_result, keyNode, {
1135
- configurable: true,
1136
- enumerable: true,
1137
- writable: true,
1138
- value: valueNode
1139
- });
1140
- } else {
1141
- _result[keyNode] = valueNode;
1142
- }
1143
- delete overridableKeys[keyNode];
1144
- }
1145
- return _result;
1146
- }
1147
- function readLineBreak(state) {
1148
- var ch;
1149
- ch = state.input.charCodeAt(state.position);
1150
- if (ch === 10) {
1151
- state.position++;
1152
- } else if (ch === 13) {
1153
- state.position++;
1154
- if (state.input.charCodeAt(state.position) === 10) {
1155
- state.position++;
1156
- }
1157
- } else {
1158
- throwError(state, "a line break is expected");
1159
- }
1160
- state.line += 1;
1161
- state.lineStart = state.position;
1162
- state.firstTabInLine = -1;
1163
- }
1164
- function skipSeparationSpace(state, allowComments, checkIndent) {
1165
- var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
1166
- while (ch !== 0) {
1167
- while (is_WHITE_SPACE(ch)) {
1168
- if (ch === 9 && state.firstTabInLine === -1) {
1169
- state.firstTabInLine = state.position;
1170
- }
1171
- ch = state.input.charCodeAt(++state.position);
1172
- }
1173
- if (allowComments && ch === 35) {
1174
- do {
1175
- ch = state.input.charCodeAt(++state.position);
1176
- } while (ch !== 10 && ch !== 13 && ch !== 0);
1177
- }
1178
- if (is_EOL(ch)) {
1179
- readLineBreak(state);
1180
- ch = state.input.charCodeAt(state.position);
1181
- lineBreaks++;
1182
- state.lineIndent = 0;
1183
- while (ch === 32) {
1184
- state.lineIndent++;
1185
- ch = state.input.charCodeAt(++state.position);
1186
- }
1187
- } else {
1188
- break;
1189
- }
1190
- }
1191
- if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1192
- throwWarning(state, "deficient indentation");
1193
- }
1194
- return lineBreaks;
1195
- }
1196
- function testDocumentSeparator(state) {
1197
- var _position = state.position, ch;
1198
- ch = state.input.charCodeAt(_position);
1199
- if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
1200
- _position += 3;
1201
- ch = state.input.charCodeAt(_position);
1202
- if (ch === 0 || is_WS_OR_EOL(ch)) {
1203
- return true;
1204
- }
1205
- }
1206
- return false;
1207
- }
1208
- function writeFoldedLines(state, count) {
1209
- if (count === 1) {
1210
- state.result += " ";
1211
- } else if (count > 1) {
1212
- state.result += common.repeat("\n", count - 1);
1213
- }
1214
- }
1215
- function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1216
- var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
1217
- ch = state.input.charCodeAt(state.position);
1218
- 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) {
1219
- return false;
1220
- }
1221
- if (ch === 63 || ch === 45) {
1222
- following = state.input.charCodeAt(state.position + 1);
1223
- if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1224
- return false;
1225
- }
1226
- }
1227
- state.kind = "scalar";
1228
- state.result = "";
1229
- captureStart = captureEnd = state.position;
1230
- hasPendingContent = false;
1231
- while (ch !== 0) {
1232
- if (ch === 58) {
1233
- following = state.input.charCodeAt(state.position + 1);
1234
- if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1235
- break;
1236
- }
1237
- } else if (ch === 35) {
1238
- preceding = state.input.charCodeAt(state.position - 1);
1239
- if (is_WS_OR_EOL(preceding)) {
1240
- break;
1241
- }
1242
- } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1243
- break;
1244
- } else if (is_EOL(ch)) {
1245
- _line = state.line;
1246
- _lineStart = state.lineStart;
1247
- _lineIndent = state.lineIndent;
1248
- skipSeparationSpace(state, false, -1);
1249
- if (state.lineIndent >= nodeIndent) {
1250
- hasPendingContent = true;
1251
- ch = state.input.charCodeAt(state.position);
1252
- continue;
1253
- } else {
1254
- state.position = captureEnd;
1255
- state.line = _line;
1256
- state.lineStart = _lineStart;
1257
- state.lineIndent = _lineIndent;
1258
- break;
1259
- }
1260
- }
1261
- if (hasPendingContent) {
1262
- captureSegment(state, captureStart, captureEnd, false);
1263
- writeFoldedLines(state, state.line - _line);
1264
- captureStart = captureEnd = state.position;
1265
- hasPendingContent = false;
1266
- }
1267
- if (!is_WHITE_SPACE(ch)) {
1268
- captureEnd = state.position + 1;
1269
- }
1270
- ch = state.input.charCodeAt(++state.position);
1271
- }
1272
- captureSegment(state, captureStart, captureEnd, false);
1273
- if (state.result) {
1274
- return true;
1275
- }
1276
- state.kind = _kind;
1277
- state.result = _result;
1278
- return false;
1279
- }
1280
- function readSingleQuotedScalar(state, nodeIndent) {
1281
- var ch, captureStart, captureEnd;
1282
- ch = state.input.charCodeAt(state.position);
1283
- if (ch !== 39) {
1284
- return false;
1285
- }
1286
- state.kind = "scalar";
1287
- state.result = "";
1288
- state.position++;
1289
- captureStart = captureEnd = state.position;
1290
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1291
- if (ch === 39) {
1292
- captureSegment(state, captureStart, state.position, true);
1293
- ch = state.input.charCodeAt(++state.position);
1294
- if (ch === 39) {
1295
- captureStart = state.position;
1296
- state.position++;
1297
- captureEnd = state.position;
1298
- } else {
1299
- return true;
1300
- }
1301
- } else if (is_EOL(ch)) {
1302
- captureSegment(state, captureStart, captureEnd, true);
1303
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1304
- captureStart = captureEnd = state.position;
1305
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1306
- throwError(state, "unexpected end of the document within a single quoted scalar");
1307
- } else {
1308
- state.position++;
1309
- captureEnd = state.position;
1310
- }
1311
- }
1312
- throwError(state, "unexpected end of the stream within a single quoted scalar");
1313
- }
1314
- function readDoubleQuotedScalar(state, nodeIndent) {
1315
- var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
1316
- ch = state.input.charCodeAt(state.position);
1317
- if (ch !== 34) {
1318
- return false;
1319
- }
1320
- state.kind = "scalar";
1321
- state.result = "";
1322
- state.position++;
1323
- captureStart = captureEnd = state.position;
1324
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1325
- if (ch === 34) {
1326
- captureSegment(state, captureStart, state.position, true);
1327
- state.position++;
1328
- return true;
1329
- } else if (ch === 92) {
1330
- captureSegment(state, captureStart, state.position, true);
1331
- ch = state.input.charCodeAt(++state.position);
1332
- if (is_EOL(ch)) {
1333
- skipSeparationSpace(state, false, nodeIndent);
1334
- } else if (ch < 256 && simpleEscapeCheck[ch]) {
1335
- state.result += simpleEscapeMap[ch];
1336
- state.position++;
1337
- } else if ((tmp = escapedHexLen(ch)) > 0) {
1338
- hexLength = tmp;
1339
- hexResult = 0;
1340
- for (; hexLength > 0; hexLength--) {
1341
- ch = state.input.charCodeAt(++state.position);
1342
- if ((tmp = fromHexCode(ch)) >= 0) {
1343
- hexResult = (hexResult << 4) + tmp;
1344
- } else {
1345
- throwError(state, "expected hexadecimal character");
1346
- }
1347
- }
1348
- state.result += charFromCodepoint(hexResult);
1349
- state.position++;
1350
- } else {
1351
- throwError(state, "unknown escape sequence");
1352
- }
1353
- captureStart = captureEnd = state.position;
1354
- } else if (is_EOL(ch)) {
1355
- captureSegment(state, captureStart, captureEnd, true);
1356
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1357
- captureStart = captureEnd = state.position;
1358
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1359
- throwError(state, "unexpected end of the document within a double quoted scalar");
1360
- } else {
1361
- state.position++;
1362
- captureEnd = state.position;
1363
- }
1364
- }
1365
- throwError(state, "unexpected end of the stream within a double quoted scalar");
1366
- }
1367
- function readFlowCollection(state, nodeIndent) {
1368
- 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;
1369
- ch = state.input.charCodeAt(state.position);
1370
- if (ch === 91) {
1371
- terminator = 93;
1372
- isMapping = false;
1373
- _result = [];
1374
- } else if (ch === 123) {
1375
- terminator = 125;
1376
- isMapping = true;
1377
- _result = {};
1378
- } else {
1379
- return false;
1380
- }
1381
- if (state.anchor !== null) {
1382
- state.anchorMap[state.anchor] = _result;
1383
- }
1384
- ch = state.input.charCodeAt(++state.position);
1385
- while (ch !== 0) {
1386
- skipSeparationSpace(state, true, nodeIndent);
1387
- ch = state.input.charCodeAt(state.position);
1388
- if (ch === terminator) {
1389
- state.position++;
1390
- state.tag = _tag;
1391
- state.anchor = _anchor;
1392
- state.kind = isMapping ? "mapping" : "sequence";
1393
- state.result = _result;
1394
- return true;
1395
- } else if (!readNext) {
1396
- throwError(state, "missed comma between flow collection entries");
1397
- } else if (ch === 44) {
1398
- throwError(state, "expected the node content, but found ','");
1399
- }
1400
- keyTag = keyNode = valueNode = null;
1401
- isPair = isExplicitPair = false;
1402
- if (ch === 63) {
1403
- following = state.input.charCodeAt(state.position + 1);
1404
- if (is_WS_OR_EOL(following)) {
1405
- isPair = isExplicitPair = true;
1406
- state.position++;
1407
- skipSeparationSpace(state, true, nodeIndent);
1408
- }
1409
- }
1410
- _line = state.line;
1411
- _lineStart = state.lineStart;
1412
- _pos = state.position;
1413
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1414
- keyTag = state.tag;
1415
- keyNode = state.result;
1416
- skipSeparationSpace(state, true, nodeIndent);
1417
- ch = state.input.charCodeAt(state.position);
1418
- if ((isExplicitPair || state.line === _line) && ch === 58) {
1419
- isPair = true;
1420
- ch = state.input.charCodeAt(++state.position);
1421
- skipSeparationSpace(state, true, nodeIndent);
1422
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1423
- valueNode = state.result;
1424
- }
1425
- if (isMapping) {
1426
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
1427
- } else if (isPair) {
1428
- _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
1429
- } else {
1430
- _result.push(keyNode);
1431
- }
1432
- skipSeparationSpace(state, true, nodeIndent);
1433
- ch = state.input.charCodeAt(state.position);
1434
- if (ch === 44) {
1435
- readNext = true;
1436
- ch = state.input.charCodeAt(++state.position);
1437
- } else {
1438
- readNext = false;
1439
- }
1440
- }
1441
- throwError(state, "unexpected end of the stream within a flow collection");
1442
- }
1443
- function readBlockScalar(state, nodeIndent) {
1444
- var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
1445
- ch = state.input.charCodeAt(state.position);
1446
- if (ch === 124) {
1447
- folding = false;
1448
- } else if (ch === 62) {
1449
- folding = true;
1450
- } else {
1451
- return false;
1452
- }
1453
- state.kind = "scalar";
1454
- state.result = "";
1455
- while (ch !== 0) {
1456
- ch = state.input.charCodeAt(++state.position);
1457
- if (ch === 43 || ch === 45) {
1458
- if (CHOMPING_CLIP === chomping) {
1459
- chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
1460
- } else {
1461
- throwError(state, "repeat of a chomping mode identifier");
1462
- }
1463
- } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1464
- if (tmp === 0) {
1465
- throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
1466
- } else if (!detectedIndent) {
1467
- textIndent = nodeIndent + tmp - 1;
1468
- detectedIndent = true;
1469
- } else {
1470
- throwError(state, "repeat of an indentation width identifier");
1471
- }
1472
- } else {
1473
- break;
1474
- }
1475
- }
1476
- if (is_WHITE_SPACE(ch)) {
1477
- do {
1478
- ch = state.input.charCodeAt(++state.position);
1479
- } while (is_WHITE_SPACE(ch));
1480
- if (ch === 35) {
1481
- do {
1482
- ch = state.input.charCodeAt(++state.position);
1483
- } while (!is_EOL(ch) && ch !== 0);
1484
- }
1485
- }
1486
- while (ch !== 0) {
1487
- readLineBreak(state);
1488
- state.lineIndent = 0;
1489
- ch = state.input.charCodeAt(state.position);
1490
- while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
1491
- state.lineIndent++;
1492
- ch = state.input.charCodeAt(++state.position);
1493
- }
1494
- if (!detectedIndent && state.lineIndent > textIndent) {
1495
- textIndent = state.lineIndent;
1496
- }
1497
- if (is_EOL(ch)) {
1498
- emptyLines++;
1499
- continue;
1500
- }
1501
- if (state.lineIndent < textIndent) {
1502
- if (chomping === CHOMPING_KEEP) {
1503
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1504
- } else if (chomping === CHOMPING_CLIP) {
1505
- if (didReadContent) {
1506
- state.result += "\n";
1507
- }
1508
- }
1509
- break;
1510
- }
1511
- if (folding) {
1512
- if (is_WHITE_SPACE(ch)) {
1513
- atMoreIndented = true;
1514
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1515
- } else if (atMoreIndented) {
1516
- atMoreIndented = false;
1517
- state.result += common.repeat("\n", emptyLines + 1);
1518
- } else if (emptyLines === 0) {
1519
- if (didReadContent) {
1520
- state.result += " ";
1521
- }
1522
- } else {
1523
- state.result += common.repeat("\n", emptyLines);
1524
- }
1525
- } else {
1526
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1527
- }
1528
- didReadContent = true;
1529
- detectedIndent = true;
1530
- emptyLines = 0;
1531
- captureStart = state.position;
1532
- while (!is_EOL(ch) && ch !== 0) {
1533
- ch = state.input.charCodeAt(++state.position);
1534
- }
1535
- captureSegment(state, captureStart, state.position, false);
1536
- }
1537
- return true;
1538
- }
1539
- function readBlockSequence(state, nodeIndent) {
1540
- var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
1541
- if (state.firstTabInLine !== -1) return false;
1542
- if (state.anchor !== null) {
1543
- state.anchorMap[state.anchor] = _result;
1544
- }
1545
- ch = state.input.charCodeAt(state.position);
1546
- while (ch !== 0) {
1547
- if (state.firstTabInLine !== -1) {
1548
- state.position = state.firstTabInLine;
1549
- throwError(state, "tab characters must not be used in indentation");
1550
- }
1551
- if (ch !== 45) {
1552
- break;
1553
- }
1554
- following = state.input.charCodeAt(state.position + 1);
1555
- if (!is_WS_OR_EOL(following)) {
1556
- break;
1557
- }
1558
- detected = true;
1559
- state.position++;
1560
- if (skipSeparationSpace(state, true, -1)) {
1561
- if (state.lineIndent <= nodeIndent) {
1562
- _result.push(null);
1563
- ch = state.input.charCodeAt(state.position);
1564
- continue;
1565
- }
1566
- }
1567
- _line = state.line;
1568
- composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1569
- _result.push(state.result);
1570
- skipSeparationSpace(state, true, -1);
1571
- ch = state.input.charCodeAt(state.position);
1572
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1573
- throwError(state, "bad indentation of a sequence entry");
1574
- } else if (state.lineIndent < nodeIndent) {
1575
- break;
1576
- }
1577
- }
1578
- if (detected) {
1579
- state.tag = _tag;
1580
- state.anchor = _anchor;
1581
- state.kind = "sequence";
1582
- state.result = _result;
1583
- return true;
1584
- }
1585
- return false;
1586
- }
1587
- function readBlockMapping(state, nodeIndent, flowIndent) {
1588
- 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;
1589
- if (state.firstTabInLine !== -1) return false;
1590
- if (state.anchor !== null) {
1591
- state.anchorMap[state.anchor] = _result;
1592
- }
1593
- ch = state.input.charCodeAt(state.position);
1594
- while (ch !== 0) {
1595
- if (!atExplicitKey && state.firstTabInLine !== -1) {
1596
- state.position = state.firstTabInLine;
1597
- throwError(state, "tab characters must not be used in indentation");
1598
- }
1599
- following = state.input.charCodeAt(state.position + 1);
1600
- _line = state.line;
1601
- if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
1602
- if (ch === 63) {
1603
- if (atExplicitKey) {
1604
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1605
- keyTag = keyNode = valueNode = null;
1606
- }
1607
- detected = true;
1608
- atExplicitKey = true;
1609
- allowCompact = true;
1610
- } else if (atExplicitKey) {
1611
- atExplicitKey = false;
1612
- allowCompact = true;
1613
- } else {
1614
- throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
1615
- }
1616
- state.position += 1;
1617
- ch = following;
1618
- } else {
1619
- _keyLine = state.line;
1620
- _keyLineStart = state.lineStart;
1621
- _keyPos = state.position;
1622
- if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1623
- break;
1624
- }
1625
- if (state.line === _line) {
1626
- ch = state.input.charCodeAt(state.position);
1627
- while (is_WHITE_SPACE(ch)) {
1628
- ch = state.input.charCodeAt(++state.position);
1629
- }
1630
- if (ch === 58) {
1631
- ch = state.input.charCodeAt(++state.position);
1632
- if (!is_WS_OR_EOL(ch)) {
1633
- throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
1634
- }
1635
- if (atExplicitKey) {
1636
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1637
- keyTag = keyNode = valueNode = null;
1638
- }
1639
- detected = true;
1640
- atExplicitKey = false;
1641
- allowCompact = false;
1642
- keyTag = state.tag;
1643
- keyNode = state.result;
1644
- } else if (detected) {
1645
- throwError(state, "can not read an implicit mapping pair; a colon is missed");
1646
- } else {
1647
- state.tag = _tag;
1648
- state.anchor = _anchor;
1649
- return true;
1650
- }
1651
- } else if (detected) {
1652
- throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
1653
- } else {
1654
- state.tag = _tag;
1655
- state.anchor = _anchor;
1656
- return true;
1657
- }
1658
- }
1659
- if (state.line === _line || state.lineIndent > nodeIndent) {
1660
- if (atExplicitKey) {
1661
- _keyLine = state.line;
1662
- _keyLineStart = state.lineStart;
1663
- _keyPos = state.position;
1664
- }
1665
- if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
1666
- if (atExplicitKey) {
1667
- keyNode = state.result;
1668
- } else {
1669
- valueNode = state.result;
1670
- }
1671
- }
1672
- if (!atExplicitKey) {
1673
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
1674
- keyTag = keyNode = valueNode = null;
1675
- }
1676
- skipSeparationSpace(state, true, -1);
1677
- ch = state.input.charCodeAt(state.position);
1678
- }
1679
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1680
- throwError(state, "bad indentation of a mapping entry");
1681
- } else if (state.lineIndent < nodeIndent) {
1682
- break;
1683
- }
1684
- }
1685
- if (atExplicitKey) {
1686
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1687
- }
1688
- if (detected) {
1689
- state.tag = _tag;
1690
- state.anchor = _anchor;
1691
- state.kind = "mapping";
1692
- state.result = _result;
1693
- }
1694
- return detected;
1695
- }
1696
- function readTagProperty(state) {
1697
- var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
1698
- ch = state.input.charCodeAt(state.position);
1699
- if (ch !== 33) return false;
1700
- if (state.tag !== null) {
1701
- throwError(state, "duplication of a tag property");
1702
- }
1703
- ch = state.input.charCodeAt(++state.position);
1704
- if (ch === 60) {
1705
- isVerbatim = true;
1706
- ch = state.input.charCodeAt(++state.position);
1707
- } else if (ch === 33) {
1708
- isNamed = true;
1709
- tagHandle = "!!";
1710
- ch = state.input.charCodeAt(++state.position);
1711
- } else {
1712
- tagHandle = "!";
1713
- }
1714
- _position = state.position;
1715
- if (isVerbatim) {
1716
- do {
1717
- ch = state.input.charCodeAt(++state.position);
1718
- } while (ch !== 0 && ch !== 62);
1719
- if (state.position < state.length) {
1720
- tagName = state.input.slice(_position, state.position);
1721
- ch = state.input.charCodeAt(++state.position);
1722
- } else {
1723
- throwError(state, "unexpected end of the stream within a verbatim tag");
1724
- }
1725
- } else {
1726
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1727
- if (ch === 33) {
1728
- if (!isNamed) {
1729
- tagHandle = state.input.slice(_position - 1, state.position + 1);
1730
- if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
1731
- throwError(state, "named tag handle cannot contain such characters");
1732
- }
1733
- isNamed = true;
1734
- _position = state.position + 1;
1735
- } else {
1736
- throwError(state, "tag suffix cannot contain exclamation marks");
1737
- }
1738
- }
1739
- ch = state.input.charCodeAt(++state.position);
1740
- }
1741
- tagName = state.input.slice(_position, state.position);
1742
- if (PATTERN_FLOW_INDICATORS.test(tagName)) {
1743
- throwError(state, "tag suffix cannot contain flow indicator characters");
1744
- }
1745
- }
1746
- if (tagName && !PATTERN_TAG_URI.test(tagName)) {
1747
- throwError(state, "tag name cannot contain such characters: " + tagName);
1748
- }
1749
- try {
1750
- tagName = decodeURIComponent(tagName);
1751
- } catch (err) {
1752
- throwError(state, "tag name is malformed: " + tagName);
1753
- }
1754
- if (isVerbatim) {
1755
- state.tag = tagName;
1756
- } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
1757
- state.tag = state.tagMap[tagHandle] + tagName;
1758
- } else if (tagHandle === "!") {
1759
- state.tag = "!" + tagName;
1760
- } else if (tagHandle === "!!") {
1761
- state.tag = "tag:yaml.org,2002:" + tagName;
1762
- } else {
1763
- throwError(state, 'undeclared tag handle "' + tagHandle + '"');
1764
- }
1765
- return true;
1766
- }
1767
- function readAnchorProperty(state) {
1768
- var _position, ch;
1769
- ch = state.input.charCodeAt(state.position);
1770
- if (ch !== 38) return false;
1771
- if (state.anchor !== null) {
1772
- throwError(state, "duplication of an anchor property");
1773
- }
1774
- ch = state.input.charCodeAt(++state.position);
1775
- _position = state.position;
1776
- while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1777
- ch = state.input.charCodeAt(++state.position);
1778
- }
1779
- if (state.position === _position) {
1780
- throwError(state, "name of an anchor node must contain at least one character");
1781
- }
1782
- state.anchor = state.input.slice(_position, state.position);
1783
- return true;
1784
- }
1785
- function readAlias(state) {
1786
- var _position, alias, ch;
1787
- ch = state.input.charCodeAt(state.position);
1788
- if (ch !== 42) return false;
1789
- ch = state.input.charCodeAt(++state.position);
1790
- _position = state.position;
1791
- while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1792
- ch = state.input.charCodeAt(++state.position);
1793
- }
1794
- if (state.position === _position) {
1795
- throwError(state, "name of an alias node must contain at least one character");
1796
- }
1797
- alias = state.input.slice(_position, state.position);
1798
- if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
1799
- throwError(state, 'unidentified alias "' + alias + '"');
1800
- }
1801
- state.result = state.anchorMap[alias];
1802
- skipSeparationSpace(state, true, -1);
1803
- return true;
1804
- }
1805
- function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
1806
- var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
1807
- if (state.listener !== null) {
1808
- state.listener("open", state);
1809
- }
1810
- state.tag = null;
1811
- state.anchor = null;
1812
- state.kind = null;
1813
- state.result = null;
1814
- allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
1815
- if (allowToSeek) {
1816
- if (skipSeparationSpace(state, true, -1)) {
1817
- atNewLine = true;
1818
- if (state.lineIndent > parentIndent) {
1819
- indentStatus = 1;
1820
- } else if (state.lineIndent === parentIndent) {
1821
- indentStatus = 0;
1822
- } else if (state.lineIndent < parentIndent) {
1823
- indentStatus = -1;
1824
- }
1825
- }
1826
- }
1827
- if (indentStatus === 1) {
1828
- while (readTagProperty(state) || readAnchorProperty(state)) {
1829
- if (skipSeparationSpace(state, true, -1)) {
1830
- atNewLine = true;
1831
- allowBlockCollections = allowBlockStyles;
1832
- if (state.lineIndent > parentIndent) {
1833
- indentStatus = 1;
1834
- } else if (state.lineIndent === parentIndent) {
1835
- indentStatus = 0;
1836
- } else if (state.lineIndent < parentIndent) {
1837
- indentStatus = -1;
1838
- }
1839
- } else {
1840
- allowBlockCollections = false;
1841
- }
1842
- }
1843
- }
1844
- if (allowBlockCollections) {
1845
- allowBlockCollections = atNewLine || allowCompact;
1846
- }
1847
- if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
1848
- if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
1849
- flowIndent = parentIndent;
1850
- } else {
1851
- flowIndent = parentIndent + 1;
1852
- }
1853
- blockIndent = state.position - state.lineStart;
1854
- if (indentStatus === 1) {
1855
- if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
1856
- hasContent = true;
1857
- } else {
1858
- if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
1859
- hasContent = true;
1860
- } else if (readAlias(state)) {
1861
- hasContent = true;
1862
- if (state.tag !== null || state.anchor !== null) {
1863
- throwError(state, "alias node should not have any properties");
1864
- }
1865
- } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
1866
- hasContent = true;
1867
- if (state.tag === null) {
1868
- state.tag = "?";
1869
- }
1870
- }
1871
- if (state.anchor !== null) {
1872
- state.anchorMap[state.anchor] = state.result;
1873
- }
1874
- }
1875
- } else if (indentStatus === 0) {
1876
- hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
1877
- }
1878
- }
1879
- if (state.tag === null) {
1880
- if (state.anchor !== null) {
1881
- state.anchorMap[state.anchor] = state.result;
1882
- }
1883
- } else if (state.tag === "?") {
1884
- if (state.result !== null && state.kind !== "scalar") {
1885
- throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
1886
- }
1887
- for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
1888
- type2 = state.implicitTypes[typeIndex];
1889
- if (type2.resolve(state.result)) {
1890
- state.result = type2.construct(state.result);
1891
- state.tag = type2.tag;
1892
- if (state.anchor !== null) {
1893
- state.anchorMap[state.anchor] = state.result;
1894
- }
1895
- break;
1896
- }
1897
- }
1898
- } else if (state.tag !== "!") {
1899
- if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
1900
- type2 = state.typeMap[state.kind || "fallback"][state.tag];
1901
- } else {
1902
- type2 = null;
1903
- typeList = state.typeMap.multi[state.kind || "fallback"];
1904
- for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
1905
- if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
1906
- type2 = typeList[typeIndex];
1907
- break;
1908
- }
1909
- }
1910
- }
1911
- if (!type2) {
1912
- throwError(state, "unknown tag !<" + state.tag + ">");
1913
- }
1914
- if (state.result !== null && type2.kind !== state.kind) {
1915
- throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
1916
- }
1917
- if (!type2.resolve(state.result, state.tag)) {
1918
- throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
1919
- } else {
1920
- state.result = type2.construct(state.result, state.tag);
1921
- if (state.anchor !== null) {
1922
- state.anchorMap[state.anchor] = state.result;
1923
- }
1924
- }
1925
- }
1926
- if (state.listener !== null) {
1927
- state.listener("close", state);
1928
- }
1929
- return state.tag !== null || state.anchor !== null || hasContent;
1930
- }
1931
- function readDocument(state) {
1932
- var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
1933
- state.version = null;
1934
- state.checkLineBreaks = state.legacy;
1935
- state.tagMap = /* @__PURE__ */ Object.create(null);
1936
- state.anchorMap = /* @__PURE__ */ Object.create(null);
1937
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1938
- skipSeparationSpace(state, true, -1);
1939
- ch = state.input.charCodeAt(state.position);
1940
- if (state.lineIndent > 0 || ch !== 37) {
1941
- break;
1942
- }
1943
- hasDirectives = true;
1944
- ch = state.input.charCodeAt(++state.position);
1945
- _position = state.position;
1946
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1947
- ch = state.input.charCodeAt(++state.position);
1948
- }
1949
- directiveName = state.input.slice(_position, state.position);
1950
- directiveArgs = [];
1951
- if (directiveName.length < 1) {
1952
- throwError(state, "directive name must not be less than one character in length");
1953
- }
1954
- while (ch !== 0) {
1955
- while (is_WHITE_SPACE(ch)) {
1956
- ch = state.input.charCodeAt(++state.position);
1957
- }
1958
- if (ch === 35) {
1959
- do {
1960
- ch = state.input.charCodeAt(++state.position);
1961
- } while (ch !== 0 && !is_EOL(ch));
1962
- break;
1963
- }
1964
- if (is_EOL(ch)) break;
1965
- _position = state.position;
1966
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1967
- ch = state.input.charCodeAt(++state.position);
1968
- }
1969
- directiveArgs.push(state.input.slice(_position, state.position));
1970
- }
1971
- if (ch !== 0) readLineBreak(state);
1972
- if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
1973
- directiveHandlers[directiveName](state, directiveName, directiveArgs);
1974
- } else {
1975
- throwWarning(state, 'unknown document directive "' + directiveName + '"');
1976
- }
1977
- }
1978
- skipSeparationSpace(state, true, -1);
1979
- if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
1980
- state.position += 3;
1981
- skipSeparationSpace(state, true, -1);
1982
- } else if (hasDirectives) {
1983
- throwError(state, "directives end mark is expected");
1984
- }
1985
- composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
1986
- skipSeparationSpace(state, true, -1);
1987
- if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
1988
- throwWarning(state, "non-ASCII line breaks are interpreted as content");
1989
- }
1990
- state.documents.push(state.result);
1991
- if (state.position === state.lineStart && testDocumentSeparator(state)) {
1992
- if (state.input.charCodeAt(state.position) === 46) {
1993
- state.position += 3;
1994
- skipSeparationSpace(state, true, -1);
1995
- }
1996
- return;
1997
- }
1998
- if (state.position < state.length - 1) {
1999
- throwError(state, "end of the stream or a document separator is expected");
2000
- } else {
2001
- return;
2002
- }
2003
- }
2004
- function loadDocuments(input, options) {
2005
- input = String(input);
2006
- options = options || {};
2007
- if (input.length !== 0) {
2008
- if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
2009
- input += "\n";
2010
- }
2011
- if (input.charCodeAt(0) === 65279) {
2012
- input = input.slice(1);
2013
- }
2014
- }
2015
- var state = new State$1(input, options);
2016
- var nullpos = input.indexOf("\0");
2017
- if (nullpos !== -1) {
2018
- state.position = nullpos;
2019
- throwError(state, "null byte is not allowed in input");
2020
- }
2021
- state.input += "\0";
2022
- while (state.input.charCodeAt(state.position) === 32) {
2023
- state.lineIndent += 1;
2024
- state.position += 1;
2025
- }
2026
- while (state.position < state.length - 1) {
2027
- readDocument(state);
2028
- }
2029
- return state.documents;
2030
- }
2031
- function loadAll$1(input, iterator, options) {
2032
- if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
2033
- options = iterator;
2034
- iterator = null;
2035
- }
2036
- var documents = loadDocuments(input, options);
2037
- if (typeof iterator !== "function") {
2038
- return documents;
2039
- }
2040
- for (var index = 0, length = documents.length; index < length; index += 1) {
2041
- iterator(documents[index]);
2042
- }
2043
- }
2044
- function load$1(input, options) {
2045
- var documents = loadDocuments(input, options);
2046
- if (documents.length === 0) {
2047
- return void 0;
2048
- } else if (documents.length === 1) {
2049
- return documents[0];
2050
- }
2051
- throw new exception("expected a single document in the stream, but found more");
2052
- }
2053
- var loadAll_1 = loadAll$1;
2054
- var load_1 = load$1;
2055
- var loader = {
2056
- loadAll: loadAll_1,
2057
- load: load_1
2058
- };
2059
- var _toString = Object.prototype.toString;
2060
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
2061
- var CHAR_BOM = 65279;
2062
- var CHAR_TAB = 9;
2063
- var CHAR_LINE_FEED = 10;
2064
- var CHAR_CARRIAGE_RETURN = 13;
2065
- var CHAR_SPACE = 32;
2066
- var CHAR_EXCLAMATION = 33;
2067
- var CHAR_DOUBLE_QUOTE = 34;
2068
- var CHAR_SHARP = 35;
2069
- var CHAR_PERCENT = 37;
2070
- var CHAR_AMPERSAND = 38;
2071
- var CHAR_SINGLE_QUOTE = 39;
2072
- var CHAR_ASTERISK = 42;
2073
- var CHAR_COMMA = 44;
2074
- var CHAR_MINUS = 45;
2075
- var CHAR_COLON = 58;
2076
- var CHAR_EQUALS = 61;
2077
- var CHAR_GREATER_THAN = 62;
2078
- var CHAR_QUESTION = 63;
2079
- var CHAR_COMMERCIAL_AT = 64;
2080
- var CHAR_LEFT_SQUARE_BRACKET = 91;
2081
- var CHAR_RIGHT_SQUARE_BRACKET = 93;
2082
- var CHAR_GRAVE_ACCENT = 96;
2083
- var CHAR_LEFT_CURLY_BRACKET = 123;
2084
- var CHAR_VERTICAL_LINE = 124;
2085
- var CHAR_RIGHT_CURLY_BRACKET = 125;
2086
- var ESCAPE_SEQUENCES = {};
2087
- ESCAPE_SEQUENCES[0] = "\\0";
2088
- ESCAPE_SEQUENCES[7] = "\\a";
2089
- ESCAPE_SEQUENCES[8] = "\\b";
2090
- ESCAPE_SEQUENCES[9] = "\\t";
2091
- ESCAPE_SEQUENCES[10] = "\\n";
2092
- ESCAPE_SEQUENCES[11] = "\\v";
2093
- ESCAPE_SEQUENCES[12] = "\\f";
2094
- ESCAPE_SEQUENCES[13] = "\\r";
2095
- ESCAPE_SEQUENCES[27] = "\\e";
2096
- ESCAPE_SEQUENCES[34] = '\\"';
2097
- ESCAPE_SEQUENCES[92] = "\\\\";
2098
- ESCAPE_SEQUENCES[133] = "\\N";
2099
- ESCAPE_SEQUENCES[160] = "\\_";
2100
- ESCAPE_SEQUENCES[8232] = "\\L";
2101
- ESCAPE_SEQUENCES[8233] = "\\P";
2102
- var DEPRECATED_BOOLEANS_SYNTAX = [
2103
- "y",
2104
- "Y",
2105
- "yes",
2106
- "Yes",
2107
- "YES",
2108
- "on",
2109
- "On",
2110
- "ON",
2111
- "n",
2112
- "N",
2113
- "no",
2114
- "No",
2115
- "NO",
2116
- "off",
2117
- "Off",
2118
- "OFF"
2119
- ];
2120
- var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
2121
- function compileStyleMap(schema2, map2) {
2122
- var result, keys, index, length, tag, style, type2;
2123
- if (map2 === null) return {};
2124
- result = {};
2125
- keys = Object.keys(map2);
2126
- for (index = 0, length = keys.length; index < length; index += 1) {
2127
- tag = keys[index];
2128
- style = String(map2[tag]);
2129
- if (tag.slice(0, 2) === "!!") {
2130
- tag = "tag:yaml.org,2002:" + tag.slice(2);
2131
- }
2132
- type2 = schema2.compiledTypeMap["fallback"][tag];
2133
- if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
2134
- style = type2.styleAliases[style];
2135
- }
2136
- result[tag] = style;
2137
- }
2138
- return result;
2139
- }
2140
- function encodeHex(character) {
2141
- var string, handle, length;
2142
- string = character.toString(16).toUpperCase();
2143
- if (character <= 255) {
2144
- handle = "x";
2145
- length = 2;
2146
- } else if (character <= 65535) {
2147
- handle = "u";
2148
- length = 4;
2149
- } else if (character <= 4294967295) {
2150
- handle = "U";
2151
- length = 8;
2152
- } else {
2153
- throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
2154
- }
2155
- return "\\" + handle + common.repeat("0", length - string.length) + string;
2156
- }
2157
- var QUOTING_TYPE_SINGLE = 1;
2158
- var QUOTING_TYPE_DOUBLE = 2;
2159
- function State(options) {
2160
- this.schema = options["schema"] || _default;
2161
- this.indent = Math.max(1, options["indent"] || 2);
2162
- this.noArrayIndent = options["noArrayIndent"] || false;
2163
- this.skipInvalid = options["skipInvalid"] || false;
2164
- this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
2165
- this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
2166
- this.sortKeys = options["sortKeys"] || false;
2167
- this.lineWidth = options["lineWidth"] || 80;
2168
- this.noRefs = options["noRefs"] || false;
2169
- this.noCompatMode = options["noCompatMode"] || false;
2170
- this.condenseFlow = options["condenseFlow"] || false;
2171
- this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
2172
- this.forceQuotes = options["forceQuotes"] || false;
2173
- this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
2174
- this.implicitTypes = this.schema.compiledImplicit;
2175
- this.explicitTypes = this.schema.compiledExplicit;
2176
- this.tag = null;
2177
- this.result = "";
2178
- this.duplicates = [];
2179
- this.usedDuplicates = null;
2180
- }
2181
- function indentString(string, spaces) {
2182
- var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
2183
- while (position < length) {
2184
- next = string.indexOf("\n", position);
2185
- if (next === -1) {
2186
- line = string.slice(position);
2187
- position = length;
2188
- } else {
2189
- line = string.slice(position, next + 1);
2190
- position = next + 1;
2191
- }
2192
- if (line.length && line !== "\n") result += ind;
2193
- result += line;
2194
- }
2195
- return result;
2196
- }
2197
- function generateNextLine(state, level) {
2198
- return "\n" + common.repeat(" ", state.indent * level);
2199
- }
2200
- function testImplicitResolving(state, str2) {
2201
- var index, length, type2;
2202
- for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
2203
- type2 = state.implicitTypes[index];
2204
- if (type2.resolve(str2)) {
2205
- return true;
2206
- }
2207
- }
2208
- return false;
2209
- }
2210
- function isWhitespace(c) {
2211
- return c === CHAR_SPACE || c === CHAR_TAB;
2212
- }
2213
- function isPrintable(c) {
2214
- return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
2215
- }
2216
- function isNsCharOrWhitespace(c) {
2217
- return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
2218
- }
2219
- function isPlainSafe(c, prev, inblock) {
2220
- var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
2221
- var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
2222
- return (
2223
- // ns-plain-safe
2224
- (inblock ? (
2225
- // c = flow-in
2226
- cIsNsCharOrWhitespace
2227
- ) : 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
2228
- );
2229
- }
2230
- function isPlainSafeFirst(c) {
2231
- 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;
2232
- }
2233
- function isPlainSafeLast(c) {
2234
- return !isWhitespace(c) && c !== CHAR_COLON;
2235
- }
2236
- function codePointAt(string, pos) {
2237
- var first = string.charCodeAt(pos), second;
2238
- if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
2239
- second = string.charCodeAt(pos + 1);
2240
- if (second >= 56320 && second <= 57343) {
2241
- return (first - 55296) * 1024 + second - 56320 + 65536;
2242
- }
2243
- }
2244
- return first;
2245
- }
2246
- function needIndentIndicator(string) {
2247
- var leadingSpaceRe = /^\n* /;
2248
- return leadingSpaceRe.test(string);
2249
- }
2250
- var STYLE_PLAIN = 1;
2251
- var STYLE_SINGLE = 2;
2252
- var STYLE_LITERAL = 3;
2253
- var STYLE_FOLDED = 4;
2254
- var STYLE_DOUBLE = 5;
2255
- function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
2256
- var i;
2257
- var char = 0;
2258
- var prevChar = null;
2259
- var hasLineBreak = false;
2260
- var hasFoldableLine = false;
2261
- var shouldTrackWidth = lineWidth !== -1;
2262
- var previousLineBreak = -1;
2263
- var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
2264
- if (singleLineOnly || forceQuotes) {
2265
- for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2266
- char = codePointAt(string, i);
2267
- if (!isPrintable(char)) {
2268
- return STYLE_DOUBLE;
2269
- }
2270
- plain = plain && isPlainSafe(char, prevChar, inblock);
2271
- prevChar = char;
2272
- }
2273
- } else {
2274
- for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2275
- char = codePointAt(string, i);
2276
- if (char === CHAR_LINE_FEED) {
2277
- hasLineBreak = true;
2278
- if (shouldTrackWidth) {
2279
- hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
2280
- i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
2281
- previousLineBreak = i;
2282
- }
2283
- } else if (!isPrintable(char)) {
2284
- return STYLE_DOUBLE;
2285
- }
2286
- plain = plain && isPlainSafe(char, prevChar, inblock);
2287
- prevChar = char;
2288
- }
2289
- hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
2290
- }
2291
- if (!hasLineBreak && !hasFoldableLine) {
2292
- if (plain && !forceQuotes && !testAmbiguousType(string)) {
2293
- return STYLE_PLAIN;
2294
- }
2295
- return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2296
- }
2297
- if (indentPerLevel > 9 && needIndentIndicator(string)) {
2298
- return STYLE_DOUBLE;
2299
- }
2300
- if (!forceQuotes) {
2301
- return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
2302
- }
2303
- return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2304
- }
2305
- function writeScalar(state, string, level, iskey, inblock) {
2306
- state.dump = (function() {
2307
- if (string.length === 0) {
2308
- return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
2309
- }
2310
- if (!state.noCompatMode) {
2311
- if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
2312
- return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
2313
- }
2314
- }
2315
- var indent = state.indent * Math.max(1, level);
2316
- var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
2317
- var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
2318
- function testAmbiguity(string2) {
2319
- return testImplicitResolving(state, string2);
2320
- }
2321
- switch (chooseScalarStyle(
2322
- string,
2323
- singleLineOnly,
2324
- state.indent,
2325
- lineWidth,
2326
- testAmbiguity,
2327
- state.quotingType,
2328
- state.forceQuotes && !iskey,
2329
- inblock
2330
- )) {
2331
- case STYLE_PLAIN:
2332
- return string;
2333
- case STYLE_SINGLE:
2334
- return "'" + string.replace(/'/g, "''") + "'";
2335
- case STYLE_LITERAL:
2336
- return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
2337
- case STYLE_FOLDED:
2338
- return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
2339
- case STYLE_DOUBLE:
2340
- return '"' + escapeString(string) + '"';
2341
- default:
2342
- throw new exception("impossible error: invalid scalar style");
2343
- }
2344
- })();
2345
- }
2346
- function blockHeader(string, indentPerLevel) {
2347
- var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
2348
- var clip = string[string.length - 1] === "\n";
2349
- var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
2350
- var chomp = keep ? "+" : clip ? "" : "-";
2351
- return indentIndicator + chomp + "\n";
2352
- }
2353
- function dropEndingNewline(string) {
2354
- return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
2355
- }
2356
- function foldString(string, width) {
2357
- var lineRe = /(\n+)([^\n]*)/g;
2358
- var result = (function() {
2359
- var nextLF = string.indexOf("\n");
2360
- nextLF = nextLF !== -1 ? nextLF : string.length;
2361
- lineRe.lastIndex = nextLF;
2362
- return foldLine(string.slice(0, nextLF), width);
2363
- })();
2364
- var prevMoreIndented = string[0] === "\n" || string[0] === " ";
2365
- var moreIndented;
2366
- var match;
2367
- while (match = lineRe.exec(string)) {
2368
- var prefix = match[1], line = match[2];
2369
- moreIndented = line[0] === " ";
2370
- result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
2371
- prevMoreIndented = moreIndented;
2372
- }
2373
- return result;
2374
- }
2375
- function foldLine(line, width) {
2376
- if (line === "" || line[0] === " ") return line;
2377
- var breakRe = / [^ ]/g;
2378
- var match;
2379
- var start = 0, end, curr = 0, next = 0;
2380
- var result = "";
2381
- while (match = breakRe.exec(line)) {
2382
- next = match.index;
2383
- if (next - start > width) {
2384
- end = curr > start ? curr : next;
2385
- result += "\n" + line.slice(start, end);
2386
- start = end + 1;
2387
- }
2388
- curr = next;
2389
- }
2390
- result += "\n";
2391
- if (line.length - start > width && curr > start) {
2392
- result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
2393
- } else {
2394
- result += line.slice(start);
2395
- }
2396
- return result.slice(1);
2397
- }
2398
- function escapeString(string) {
2399
- var result = "";
2400
- var char = 0;
2401
- var escapeSeq;
2402
- for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2403
- char = codePointAt(string, i);
2404
- escapeSeq = ESCAPE_SEQUENCES[char];
2405
- if (!escapeSeq && isPrintable(char)) {
2406
- result += string[i];
2407
- if (char >= 65536) result += string[i + 1];
2408
- } else {
2409
- result += escapeSeq || encodeHex(char);
2410
- }
2411
- }
2412
- return result;
2413
- }
2414
- function writeFlowSequence(state, level, object) {
2415
- var _result = "", _tag = state.tag, index, length, value;
2416
- for (index = 0, length = object.length; index < length; index += 1) {
2417
- value = object[index];
2418
- if (state.replacer) {
2419
- value = state.replacer.call(object, String(index), value);
2420
- }
2421
- if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
2422
- if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
2423
- _result += state.dump;
2424
- }
2425
- }
2426
- state.tag = _tag;
2427
- state.dump = "[" + _result + "]";
2428
- }
2429
- function writeBlockSequence(state, level, object, compact) {
2430
- var _result = "", _tag = state.tag, index, length, value;
2431
- for (index = 0, length = object.length; index < length; index += 1) {
2432
- value = object[index];
2433
- if (state.replacer) {
2434
- value = state.replacer.call(object, String(index), value);
2435
- }
2436
- if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
2437
- if (!compact || _result !== "") {
2438
- _result += generateNextLine(state, level);
2439
- }
2440
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2441
- _result += "-";
2442
- } else {
2443
- _result += "- ";
2444
- }
2445
- _result += state.dump;
2446
- }
2447
- }
2448
- state.tag = _tag;
2449
- state.dump = _result || "[]";
2450
- }
2451
- function writeFlowMapping(state, level, object) {
2452
- var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
2453
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2454
- pairBuffer = "";
2455
- if (_result !== "") pairBuffer += ", ";
2456
- if (state.condenseFlow) pairBuffer += '"';
2457
- objectKey = objectKeyList[index];
2458
- objectValue = object[objectKey];
2459
- if (state.replacer) {
2460
- objectValue = state.replacer.call(object, objectKey, objectValue);
2461
- }
2462
- if (!writeNode(state, level, objectKey, false, false)) {
2463
- continue;
2464
- }
2465
- if (state.dump.length > 1024) pairBuffer += "? ";
2466
- pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
2467
- if (!writeNode(state, level, objectValue, false, false)) {
2468
- continue;
2469
- }
2470
- pairBuffer += state.dump;
2471
- _result += pairBuffer;
2472
- }
2473
- state.tag = _tag;
2474
- state.dump = "{" + _result + "}";
2475
- }
2476
- function writeBlockMapping(state, level, object, compact) {
2477
- var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
2478
- if (state.sortKeys === true) {
2479
- objectKeyList.sort();
2480
- } else if (typeof state.sortKeys === "function") {
2481
- objectKeyList.sort(state.sortKeys);
2482
- } else if (state.sortKeys) {
2483
- throw new exception("sortKeys must be a boolean or a function");
2484
- }
2485
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2486
- pairBuffer = "";
2487
- if (!compact || _result !== "") {
2488
- pairBuffer += generateNextLine(state, level);
2489
- }
2490
- objectKey = objectKeyList[index];
2491
- objectValue = object[objectKey];
2492
- if (state.replacer) {
2493
- objectValue = state.replacer.call(object, objectKey, objectValue);
2494
- }
2495
- if (!writeNode(state, level + 1, objectKey, true, true, true)) {
2496
- continue;
2497
- }
2498
- explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
2499
- if (explicitPair) {
2500
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2501
- pairBuffer += "?";
2502
- } else {
2503
- pairBuffer += "? ";
2504
- }
2505
- }
2506
- pairBuffer += state.dump;
2507
- if (explicitPair) {
2508
- pairBuffer += generateNextLine(state, level);
2509
- }
2510
- if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
2511
- continue;
2512
- }
2513
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2514
- pairBuffer += ":";
2515
- } else {
2516
- pairBuffer += ": ";
2517
- }
2518
- pairBuffer += state.dump;
2519
- _result += pairBuffer;
2520
- }
2521
- state.tag = _tag;
2522
- state.dump = _result || "{}";
2523
- }
2524
- function detectType(state, object, explicit) {
2525
- var _result, typeList, index, length, type2, style;
2526
- typeList = explicit ? state.explicitTypes : state.implicitTypes;
2527
- for (index = 0, length = typeList.length; index < length; index += 1) {
2528
- type2 = typeList[index];
2529
- if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
2530
- if (explicit) {
2531
- if (type2.multi && type2.representName) {
2532
- state.tag = type2.representName(object);
2533
- } else {
2534
- state.tag = type2.tag;
2535
- }
2536
- } else {
2537
- state.tag = "?";
2538
- }
2539
- if (type2.represent) {
2540
- style = state.styleMap[type2.tag] || type2.defaultStyle;
2541
- if (_toString.call(type2.represent) === "[object Function]") {
2542
- _result = type2.represent(object, style);
2543
- } else if (_hasOwnProperty.call(type2.represent, style)) {
2544
- _result = type2.represent[style](object, style);
2545
- } else {
2546
- throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
2547
- }
2548
- state.dump = _result;
2549
- }
2550
- return true;
2551
- }
2552
- }
2553
- return false;
2554
- }
2555
- function writeNode(state, level, object, block, compact, iskey, isblockseq) {
2556
- state.tag = null;
2557
- state.dump = object;
2558
- if (!detectType(state, object, false)) {
2559
- detectType(state, object, true);
2560
- }
2561
- var type2 = _toString.call(state.dump);
2562
- var inblock = block;
2563
- var tagStr;
2564
- if (block) {
2565
- block = state.flowLevel < 0 || state.flowLevel > level;
2566
- }
2567
- var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
2568
- if (objectOrArray) {
2569
- duplicateIndex = state.duplicates.indexOf(object);
2570
- duplicate = duplicateIndex !== -1;
2571
- }
2572
- if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
2573
- compact = false;
2574
- }
2575
- if (duplicate && state.usedDuplicates[duplicateIndex]) {
2576
- state.dump = "*ref_" + duplicateIndex;
2577
- } else {
2578
- if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
2579
- state.usedDuplicates[duplicateIndex] = true;
2580
- }
2581
- if (type2 === "[object Object]") {
2582
- if (block && Object.keys(state.dump).length !== 0) {
2583
- writeBlockMapping(state, level, state.dump, compact);
2584
- if (duplicate) {
2585
- state.dump = "&ref_" + duplicateIndex + state.dump;
2586
- }
2587
- } else {
2588
- writeFlowMapping(state, level, state.dump);
2589
- if (duplicate) {
2590
- state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2591
- }
2592
- }
2593
- } else if (type2 === "[object Array]") {
2594
- if (block && state.dump.length !== 0) {
2595
- if (state.noArrayIndent && !isblockseq && level > 0) {
2596
- writeBlockSequence(state, level - 1, state.dump, compact);
2597
- } else {
2598
- writeBlockSequence(state, level, state.dump, compact);
2599
- }
2600
- if (duplicate) {
2601
- state.dump = "&ref_" + duplicateIndex + state.dump;
2602
- }
2603
- } else {
2604
- writeFlowSequence(state, level, state.dump);
2605
- if (duplicate) {
2606
- state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2607
- }
2608
- }
2609
- } else if (type2 === "[object String]") {
2610
- if (state.tag !== "?") {
2611
- writeScalar(state, state.dump, level, iskey, inblock);
2612
- }
2613
- } else if (type2 === "[object Undefined]") {
2614
- return false;
2615
- } else {
2616
- if (state.skipInvalid) return false;
2617
- throw new exception("unacceptable kind of an object to dump " + type2);
2618
- }
2619
- if (state.tag !== null && state.tag !== "?") {
2620
- tagStr = encodeURI(
2621
- state.tag[0] === "!" ? state.tag.slice(1) : state.tag
2622
- ).replace(/!/g, "%21");
2623
- if (state.tag[0] === "!") {
2624
- tagStr = "!" + tagStr;
2625
- } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
2626
- tagStr = "!!" + tagStr.slice(18);
2627
- } else {
2628
- tagStr = "!<" + tagStr + ">";
2629
- }
2630
- state.dump = tagStr + " " + state.dump;
2631
- }
2632
- }
2633
- return true;
2634
- }
2635
- function getDuplicateReferences(object, state) {
2636
- var objects = [], duplicatesIndexes = [], index, length;
2637
- inspectNode(object, objects, duplicatesIndexes);
2638
- for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
2639
- state.duplicates.push(objects[duplicatesIndexes[index]]);
2640
- }
2641
- state.usedDuplicates = new Array(length);
2642
- }
2643
- function inspectNode(object, objects, duplicatesIndexes) {
2644
- var objectKeyList, index, length;
2645
- if (object !== null && typeof object === "object") {
2646
- index = objects.indexOf(object);
2647
- if (index !== -1) {
2648
- if (duplicatesIndexes.indexOf(index) === -1) {
2649
- duplicatesIndexes.push(index);
2650
- }
2651
- } else {
2652
- objects.push(object);
2653
- if (Array.isArray(object)) {
2654
- for (index = 0, length = object.length; index < length; index += 1) {
2655
- inspectNode(object[index], objects, duplicatesIndexes);
2656
- }
2657
- } else {
2658
- objectKeyList = Object.keys(object);
2659
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2660
- inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
2661
- }
2662
- }
2663
- }
2664
- }
2665
- }
2666
- function dump$1(input, options) {
2667
- options = options || {};
2668
- var state = new State(options);
2669
- if (!state.noRefs) getDuplicateReferences(input, state);
2670
- var value = input;
2671
- if (state.replacer) {
2672
- value = state.replacer.call({ "": value }, "", value);
2673
- }
2674
- if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
2675
- return "";
2676
- }
2677
- var dump_1 = dump$1;
2678
- var dumper = {
2679
- dump: dump_1
2680
- };
2681
- function renamed(from, to) {
2682
- return function() {
2683
- throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
2684
- };
2685
- }
2686
- var Type = type;
2687
- var Schema = schema;
2688
- var FAILSAFE_SCHEMA = failsafe;
2689
- var JSON_SCHEMA = json;
2690
- var CORE_SCHEMA = core;
2691
- var DEFAULT_SCHEMA = _default;
2692
- var load = loader.load;
2693
- var loadAll = loader.loadAll;
2694
- var dump = dumper.dump;
2695
- var YAMLException = exception;
2696
- var types = {
2697
- binary,
2698
- float,
2699
- map,
2700
- null: _null,
2701
- pairs,
2702
- set,
2703
- timestamp,
2704
- bool,
2705
- int,
2706
- merge,
2707
- omap,
2708
- seq,
2709
- str
2710
- };
2711
- var safeLoad = renamed("safeLoad", "load");
2712
- var safeLoadAll = renamed("safeLoadAll", "loadAll");
2713
- var safeDump = renamed("safeDump", "dump");
2714
- var jsYaml = {
2715
- Type,
2716
- Schema,
2717
- FAILSAFE_SCHEMA,
2718
- JSON_SCHEMA,
2719
- CORE_SCHEMA,
2720
- DEFAULT_SCHEMA,
2721
- load,
2722
- loadAll,
2723
- dump,
2724
- YAMLException,
2725
- types,
2726
- safeLoad,
2727
- safeLoadAll,
2728
- safeDump
2729
- };
2730
- var js_yaml_default = jsYaml;
2731
-
2732
- // src/analytics-manager.ts
111
+ import yaml from "js-yaml";
2733
112
  import ora from "ora";
2734
113
  import { table } from "table";
2735
114
  var AnalyticsManager = class {
@@ -3152,7 +531,7 @@ var AnalyticsManager = class {
3152
531
  "gtm.config.yaml not found. Please create the configuration file first."
3153
532
  );
3154
533
  }
3155
- const config = js_yaml_default.load(yamlContent);
534
+ const config = yaml.load(yamlContent);
3156
535
  spinner.text = "Querying current GTM state...";
3157
536
  const variablesResult = await this.clients.gtm.listVariables();
3158
537
  if (variablesResult.success && variablesResult.data) {
@@ -3173,7 +552,7 @@ var AnalyticsManager = class {
3173
552
  }
3174
553
  }
3175
554
  spinner.text = "Writing updated configuration...";
3176
- const updatedYaml = js_yaml_default.dump(config, {
555
+ const updatedYaml = yaml.dump(config, {
3177
556
  indent: 2,
3178
557
  lineWidth: -1,
3179
558
  quotingType: '"',
@@ -5189,8 +2568,8 @@ ${validation.errors.join("\n")}`
5189
2568
  /**
5190
2569
  * Normalize parameter map structures for GTM API (convert lowercase types to uppercase)
5191
2570
  */
5192
- normalizeParameterMap(map2) {
5193
- return map2.map((item) => ({
2571
+ normalizeParameterMap(map) {
2572
+ return map.map((item) => ({
5194
2573
  ...item,
5195
2574
  type: item.type?.toUpperCase() || "TEMPLATE",
5196
2575
  ...item.map && { map: this.normalizeParameterMap(item.map) },
@@ -5451,7 +2830,7 @@ ${validation.errors.join("\n")}`
5451
2830
  * Map tag type codes to full GTM API type names
5452
2831
  * CRITICAL: Auto-corrects googtag to gaawe for GA4 event tags
5453
2832
  */
5454
- mapTagType(type2, yamlConfig) {
2833
+ mapTagType(type, yamlConfig) {
5455
2834
  const typeMap = {
5456
2835
  googtag: "googtag",
5457
2836
  // Google Tag (basic config only - NOT for events)
@@ -5476,13 +2855,13 @@ ${validation.errors.join("\n")}`
5476
2855
  fls: "fls"
5477
2856
  // Floodlight Sales
5478
2857
  };
5479
- if (type2 === "googtag" && yamlConfig && this.isGA4EventTag(yamlConfig)) {
2858
+ if (type === "googtag" && yamlConfig && this.isGA4EventTag(yamlConfig)) {
5480
2859
  console.log(
5481
2860
  `[AUTO-CORRECT] Converting tag "${yamlConfig.name}" from type "googtag" to "gaawe" (GA4 Event Tag)`
5482
2861
  );
5483
2862
  return "gaawe";
5484
2863
  }
5485
- return typeMap[type2] || type2;
2864
+ return typeMap[type] || type;
5486
2865
  }
5487
2866
  /**
5488
2867
  * Get parameter type for tag parameters
@@ -5592,7 +2971,7 @@ ${validation.errors.join("\n")}`
5592
2971
  /**
5593
2972
  * Map trigger type codes to full GTM API type names
5594
2973
  */
5595
- mapTriggerType(type2) {
2974
+ mapTriggerType(type) {
5596
2975
  const typeMap = {
5597
2976
  pageview: "pageview",
5598
2977
  domReady: "domReady",
@@ -5606,7 +2985,7 @@ ${validation.errors.join("\n")}`
5606
2985
  scrollDepth: "scrollDepth",
5607
2986
  youtubeVideo: "youtubeVideo"
5608
2987
  };
5609
- return typeMap[type2] || type2;
2988
+ return typeMap[type] || type;
5610
2989
  }
5611
2990
  /**
5612
2991
  * Filter trigger fields for update operations
@@ -5800,7 +3179,7 @@ ${validation.errors.join("\n")}`
5800
3179
  /**
5801
3180
  * Map short variable type codes to full GTM API type names (LEGACY - for display purposes)
5802
3181
  */
5803
- mapVariableType(type2) {
3182
+ mapVariableType(type) {
5804
3183
  const typeMap = {
5805
3184
  c: "Constant",
5806
3185
  constant: "Constant",
@@ -5817,12 +3196,12 @@ ${validation.errors.join("\n")}`
5817
3196
  r: "Referrer",
5818
3197
  gas: "Google Analytics Settings"
5819
3198
  };
5820
- return typeMap[type2] || type2;
3199
+ return typeMap[type] || type;
5821
3200
  }
5822
3201
  /**
5823
3202
  * Map variable type codes to GTM API format (keep short codes, normalize long names to short codes)
5824
3203
  */
5825
- mapVariableTypeForGTMApi(type2) {
3204
+ mapVariableTypeForGTMApi(type) {
5826
3205
  const typeMap = {
5827
3206
  // Short codes remain as-is (these are what GTM API wants)
5828
3207
  c: "c",
@@ -5854,7 +3233,7 @@ ${validation.errors.join("\n")}`
5854
3233
  autoEvent: "aev",
5855
3234
  autoEventVariable: "aev"
5856
3235
  };
5857
- return typeMap[type2] || type2;
3236
+ return typeMap[type] || type;
5858
3237
  }
5859
3238
  /**
5860
3239
  * GTM API rate limiter: 0.25 QPS (1 request every 4 seconds)
@@ -6102,7 +3481,7 @@ Total resources: ${state.resources.length}`));
6102
3481
  } else if (options.format === "yaml") {
6103
3482
  const configParser = new ConfigParser();
6104
3483
  const config = configParser.stateToConfig(state);
6105
- console.log(js_yaml_default.dump(config));
3484
+ console.log(yaml.dump(config));
6106
3485
  } else {
6107
3486
  console.log(JSON.stringify(state, null, 2));
6108
3487
  }
@@ -6129,10 +3508,10 @@ Total resources: ${state.resources.length}`));
6129
3508
  )
6130
3509
  );
6131
3510
  if (config.resources) {
6132
- for (const [type2, resources] of Object.entries(config.resources)) {
3511
+ for (const [type, resources] of Object.entries(config.resources)) {
6133
3512
  if (Array.isArray(resources)) {
6134
3513
  console.log(
6135
- chalk.blue(` - ${type2}: ${resources.length} resources`)
3514
+ chalk.blue(` - ${type}: ${resources.length} resources`)
6136
3515
  );
6137
3516
  }
6138
3517
  }
@@ -6174,8 +3553,8 @@ Total resources: ${state.resources.length}`));
6174
3553
  async gtmTerraformStateShow(options) {
6175
3554
  try {
6176
3555
  const stateManager = new StateManager();
6177
- const [type2, name] = options.address.split(".");
6178
- const resource = await stateManager.getResource(type2, name);
3556
+ const [type, name] = options.address.split(".");
3557
+ const resource = await stateManager.getResource(type, name);
6179
3558
  if (!resource) {
6180
3559
  console.log(
6181
3560
  chalk.yellow(`Resource ${options.address} not found in state`)
@@ -6197,8 +3576,8 @@ Total resources: ${state.resources.length}`));
6197
3576
  const spinner = ora(`Removing ${options.address} from state...`).start();
6198
3577
  try {
6199
3578
  const stateManager = new StateManager();
6200
- const [type2, name] = options.address.split(".");
6201
- const result = await stateManager.removeResource(type2, name);
3579
+ const [type, name] = options.address.split(".");
3580
+ const result = await stateManager.removeResource(type, name);
6202
3581
  if (result.success) {
6203
3582
  spinner.succeed(`Removed ${options.address} from state`);
6204
3583
  } else {
@@ -8756,9 +6135,4 @@ export {
8756
6135
  showSwissMarketHelp,
8757
6136
  showTroubleshooting
8758
6137
  };
8759
- /*! Bundled license information:
8760
-
8761
- js-yaml/dist/js-yaml.mjs:
8762
- (*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
8763
- */
8764
6138
  //# sourceMappingURL=index.js.map