@browserstack/accessibility-devtools-cli 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +3348 -132
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -32,6 +32,2983 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
32
32
  ));
33
33
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
34
 
35
+ // ../common/node_modules/js-yaml/lib/common.js
36
+ var require_common = __commonJS({
37
+ "../common/node_modules/js-yaml/lib/common.js"(exports2, module2) {
38
+ "use strict";
39
+ function isNothing(subject) {
40
+ return typeof subject === "undefined" || subject === null;
41
+ }
42
+ function isObject(subject) {
43
+ return typeof subject === "object" && subject !== null;
44
+ }
45
+ function toArray(sequence) {
46
+ if (Array.isArray(sequence)) return sequence;
47
+ else if (isNothing(sequence)) return [];
48
+ return [sequence];
49
+ }
50
+ function extend(target, source) {
51
+ var index, length, key, sourceKeys;
52
+ if (source) {
53
+ sourceKeys = Object.keys(source);
54
+ for (index = 0, length = sourceKeys.length; index < length; index += 1) {
55
+ key = sourceKeys[index];
56
+ target[key] = source[key];
57
+ }
58
+ }
59
+ return target;
60
+ }
61
+ function repeat(string, count) {
62
+ var result = "", cycle;
63
+ for (cycle = 0; cycle < count; cycle += 1) {
64
+ result += string;
65
+ }
66
+ return result;
67
+ }
68
+ function isNegativeZero(number) {
69
+ return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
70
+ }
71
+ module2.exports.isNothing = isNothing;
72
+ module2.exports.isObject = isObject;
73
+ module2.exports.toArray = toArray;
74
+ module2.exports.repeat = repeat;
75
+ module2.exports.isNegativeZero = isNegativeZero;
76
+ module2.exports.extend = extend;
77
+ }
78
+ });
79
+
80
+ // ../common/node_modules/js-yaml/lib/exception.js
81
+ var require_exception = __commonJS({
82
+ "../common/node_modules/js-yaml/lib/exception.js"(exports2, module2) {
83
+ "use strict";
84
+ function formatError(exception, compact) {
85
+ var where = "", message = exception.reason || "(unknown reason)";
86
+ if (!exception.mark) return message;
87
+ if (exception.mark.name) {
88
+ where += 'in "' + exception.mark.name + '" ';
89
+ }
90
+ where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
91
+ if (!compact && exception.mark.snippet) {
92
+ where += "\n\n" + exception.mark.snippet;
93
+ }
94
+ return message + " " + where;
95
+ }
96
+ function YAMLException(reason, mark) {
97
+ Error.call(this);
98
+ this.name = "YAMLException";
99
+ this.reason = reason;
100
+ this.mark = mark;
101
+ this.message = formatError(this, false);
102
+ if (Error.captureStackTrace) {
103
+ Error.captureStackTrace(this, this.constructor);
104
+ } else {
105
+ this.stack = new Error().stack || "";
106
+ }
107
+ }
108
+ YAMLException.prototype = Object.create(Error.prototype);
109
+ YAMLException.prototype.constructor = YAMLException;
110
+ YAMLException.prototype.toString = function toString(compact) {
111
+ return this.name + ": " + formatError(this, compact);
112
+ };
113
+ module2.exports = YAMLException;
114
+ }
115
+ });
116
+
117
+ // ../common/node_modules/js-yaml/lib/snippet.js
118
+ var require_snippet = __commonJS({
119
+ "../common/node_modules/js-yaml/lib/snippet.js"(exports2, module2) {
120
+ "use strict";
121
+ var common = require_common();
122
+ function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
123
+ var head = "";
124
+ var tail = "";
125
+ var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
126
+ if (position - lineStart > maxHalfLength) {
127
+ head = " ... ";
128
+ lineStart = position - maxHalfLength + head.length;
129
+ }
130
+ if (lineEnd - position > maxHalfLength) {
131
+ tail = " ...";
132
+ lineEnd = position + maxHalfLength - tail.length;
133
+ }
134
+ return {
135
+ str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
136
+ pos: position - lineStart + head.length
137
+ // relative position
138
+ };
139
+ }
140
+ function padStart(string, max) {
141
+ return common.repeat(" ", max - string.length) + string;
142
+ }
143
+ function makeSnippet(mark, options) {
144
+ options = Object.create(options || null);
145
+ if (!mark.buffer) return null;
146
+ if (!options.maxLength) options.maxLength = 79;
147
+ if (typeof options.indent !== "number") options.indent = 1;
148
+ if (typeof options.linesBefore !== "number") options.linesBefore = 3;
149
+ if (typeof options.linesAfter !== "number") options.linesAfter = 2;
150
+ var re = /\r?\n|\r|\0/g;
151
+ var lineStarts = [0];
152
+ var lineEnds = [];
153
+ var match;
154
+ var foundLineNo = -1;
155
+ while (match = re.exec(mark.buffer)) {
156
+ lineEnds.push(match.index);
157
+ lineStarts.push(match.index + match[0].length);
158
+ if (mark.position <= match.index && foundLineNo < 0) {
159
+ foundLineNo = lineStarts.length - 2;
160
+ }
161
+ }
162
+ if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
163
+ var result = "", i, line;
164
+ var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
165
+ var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
166
+ for (i = 1; i <= options.linesBefore; i++) {
167
+ if (foundLineNo - i < 0) break;
168
+ line = getLine(
169
+ mark.buffer,
170
+ lineStarts[foundLineNo - i],
171
+ lineEnds[foundLineNo - i],
172
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
173
+ maxLineLength
174
+ );
175
+ result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
176
+ }
177
+ line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
178
+ result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
179
+ result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
180
+ for (i = 1; i <= options.linesAfter; i++) {
181
+ if (foundLineNo + i >= lineEnds.length) break;
182
+ line = getLine(
183
+ mark.buffer,
184
+ lineStarts[foundLineNo + i],
185
+ lineEnds[foundLineNo + i],
186
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
187
+ maxLineLength
188
+ );
189
+ result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
190
+ }
191
+ return result.replace(/\n$/, "");
192
+ }
193
+ module2.exports = makeSnippet;
194
+ }
195
+ });
196
+
197
+ // ../common/node_modules/js-yaml/lib/type.js
198
+ var require_type = __commonJS({
199
+ "../common/node_modules/js-yaml/lib/type.js"(exports2, module2) {
200
+ "use strict";
201
+ var YAMLException = require_exception();
202
+ var TYPE_CONSTRUCTOR_OPTIONS = [
203
+ "kind",
204
+ "multi",
205
+ "resolve",
206
+ "construct",
207
+ "instanceOf",
208
+ "predicate",
209
+ "represent",
210
+ "representName",
211
+ "defaultStyle",
212
+ "styleAliases"
213
+ ];
214
+ var YAML_NODE_KINDS = [
215
+ "scalar",
216
+ "sequence",
217
+ "mapping"
218
+ ];
219
+ function compileStyleAliases(map) {
220
+ var result = {};
221
+ if (map !== null) {
222
+ Object.keys(map).forEach(function(style) {
223
+ map[style].forEach(function(alias) {
224
+ result[String(alias)] = style;
225
+ });
226
+ });
227
+ }
228
+ return result;
229
+ }
230
+ function Type(tag, options) {
231
+ options = options || {};
232
+ Object.keys(options).forEach(function(name) {
233
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
234
+ throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
235
+ }
236
+ });
237
+ this.options = options;
238
+ this.tag = tag;
239
+ this.kind = options["kind"] || null;
240
+ this.resolve = options["resolve"] || function() {
241
+ return true;
242
+ };
243
+ this.construct = options["construct"] || function(data) {
244
+ return data;
245
+ };
246
+ this.instanceOf = options["instanceOf"] || null;
247
+ this.predicate = options["predicate"] || null;
248
+ this.represent = options["represent"] || null;
249
+ this.representName = options["representName"] || null;
250
+ this.defaultStyle = options["defaultStyle"] || null;
251
+ this.multi = options["multi"] || false;
252
+ this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
253
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
254
+ throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
255
+ }
256
+ }
257
+ module2.exports = Type;
258
+ }
259
+ });
260
+
261
+ // ../common/node_modules/js-yaml/lib/schema.js
262
+ var require_schema = __commonJS({
263
+ "../common/node_modules/js-yaml/lib/schema.js"(exports2, module2) {
264
+ "use strict";
265
+ var YAMLException = require_exception();
266
+ var Type = require_type();
267
+ function compileList(schema, name) {
268
+ var result = [];
269
+ schema[name].forEach(function(currentType) {
270
+ var newIndex = result.length;
271
+ result.forEach(function(previousType, previousIndex) {
272
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
273
+ newIndex = previousIndex;
274
+ }
275
+ });
276
+ result[newIndex] = currentType;
277
+ });
278
+ return result;
279
+ }
280
+ function compileMap() {
281
+ var result = {
282
+ scalar: {},
283
+ sequence: {},
284
+ mapping: {},
285
+ fallback: {},
286
+ multi: {
287
+ scalar: [],
288
+ sequence: [],
289
+ mapping: [],
290
+ fallback: []
291
+ }
292
+ }, index, length;
293
+ function collectType(type) {
294
+ if (type.multi) {
295
+ result.multi[type.kind].push(type);
296
+ result.multi["fallback"].push(type);
297
+ } else {
298
+ result[type.kind][type.tag] = result["fallback"][type.tag] = type;
299
+ }
300
+ }
301
+ for (index = 0, length = arguments.length; index < length; index += 1) {
302
+ arguments[index].forEach(collectType);
303
+ }
304
+ return result;
305
+ }
306
+ function Schema(definition) {
307
+ return this.extend(definition);
308
+ }
309
+ Schema.prototype.extend = function extend(definition) {
310
+ var implicit = [];
311
+ var explicit = [];
312
+ if (definition instanceof Type) {
313
+ explicit.push(definition);
314
+ } else if (Array.isArray(definition)) {
315
+ explicit = explicit.concat(definition);
316
+ } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
317
+ if (definition.implicit) implicit = implicit.concat(definition.implicit);
318
+ if (definition.explicit) explicit = explicit.concat(definition.explicit);
319
+ } else {
320
+ throw new YAMLException("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
321
+ }
322
+ implicit.forEach(function(type) {
323
+ if (!(type instanceof Type)) {
324
+ throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
325
+ }
326
+ if (type.loadKind && type.loadKind !== "scalar") {
327
+ throw new YAMLException("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
328
+ }
329
+ if (type.multi) {
330
+ throw new YAMLException("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
331
+ }
332
+ });
333
+ explicit.forEach(function(type) {
334
+ if (!(type instanceof Type)) {
335
+ throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
336
+ }
337
+ });
338
+ var result = Object.create(Schema.prototype);
339
+ result.implicit = (this.implicit || []).concat(implicit);
340
+ result.explicit = (this.explicit || []).concat(explicit);
341
+ result.compiledImplicit = compileList(result, "implicit");
342
+ result.compiledExplicit = compileList(result, "explicit");
343
+ result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
344
+ return result;
345
+ };
346
+ module2.exports = Schema;
347
+ }
348
+ });
349
+
350
+ // ../common/node_modules/js-yaml/lib/type/str.js
351
+ var require_str = __commonJS({
352
+ "../common/node_modules/js-yaml/lib/type/str.js"(exports2, module2) {
353
+ "use strict";
354
+ var Type = require_type();
355
+ module2.exports = new Type("tag:yaml.org,2002:str", {
356
+ kind: "scalar",
357
+ construct: function(data) {
358
+ return data !== null ? data : "";
359
+ }
360
+ });
361
+ }
362
+ });
363
+
364
+ // ../common/node_modules/js-yaml/lib/type/seq.js
365
+ var require_seq = __commonJS({
366
+ "../common/node_modules/js-yaml/lib/type/seq.js"(exports2, module2) {
367
+ "use strict";
368
+ var Type = require_type();
369
+ module2.exports = new Type("tag:yaml.org,2002:seq", {
370
+ kind: "sequence",
371
+ construct: function(data) {
372
+ return data !== null ? data : [];
373
+ }
374
+ });
375
+ }
376
+ });
377
+
378
+ // ../common/node_modules/js-yaml/lib/type/map.js
379
+ var require_map = __commonJS({
380
+ "../common/node_modules/js-yaml/lib/type/map.js"(exports2, module2) {
381
+ "use strict";
382
+ var Type = require_type();
383
+ module2.exports = new Type("tag:yaml.org,2002:map", {
384
+ kind: "mapping",
385
+ construct: function(data) {
386
+ return data !== null ? data : {};
387
+ }
388
+ });
389
+ }
390
+ });
391
+
392
+ // ../common/node_modules/js-yaml/lib/schema/failsafe.js
393
+ var require_failsafe = __commonJS({
394
+ "../common/node_modules/js-yaml/lib/schema/failsafe.js"(exports2, module2) {
395
+ "use strict";
396
+ var Schema = require_schema();
397
+ module2.exports = new Schema({
398
+ explicit: [
399
+ require_str(),
400
+ require_seq(),
401
+ require_map()
402
+ ]
403
+ });
404
+ }
405
+ });
406
+
407
+ // ../common/node_modules/js-yaml/lib/type/null.js
408
+ var require_null = __commonJS({
409
+ "../common/node_modules/js-yaml/lib/type/null.js"(exports2, module2) {
410
+ "use strict";
411
+ var Type = require_type();
412
+ function resolveYamlNull(data) {
413
+ if (data === null) return true;
414
+ var max = data.length;
415
+ return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
416
+ }
417
+ function constructYamlNull() {
418
+ return null;
419
+ }
420
+ function isNull(object) {
421
+ return object === null;
422
+ }
423
+ module2.exports = new Type("tag:yaml.org,2002:null", {
424
+ kind: "scalar",
425
+ resolve: resolveYamlNull,
426
+ construct: constructYamlNull,
427
+ predicate: isNull,
428
+ represent: {
429
+ canonical: function() {
430
+ return "~";
431
+ },
432
+ lowercase: function() {
433
+ return "null";
434
+ },
435
+ uppercase: function() {
436
+ return "NULL";
437
+ },
438
+ camelcase: function() {
439
+ return "Null";
440
+ },
441
+ empty: function() {
442
+ return "";
443
+ }
444
+ },
445
+ defaultStyle: "lowercase"
446
+ });
447
+ }
448
+ });
449
+
450
+ // ../common/node_modules/js-yaml/lib/type/bool.js
451
+ var require_bool = __commonJS({
452
+ "../common/node_modules/js-yaml/lib/type/bool.js"(exports2, module2) {
453
+ "use strict";
454
+ var Type = require_type();
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
+ module2.exports = 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
+ }
485
+ });
486
+
487
+ // ../common/node_modules/js-yaml/lib/type/int.js
488
+ var require_int = __commonJS({
489
+ "../common/node_modules/js-yaml/lib/type/int.js"(exports2, module2) {
490
+ "use strict";
491
+ var common = require_common();
492
+ var Type = require_type();
493
+ function isHexCode(c) {
494
+ return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
495
+ }
496
+ function isOctCode(c) {
497
+ return 48 <= c && c <= 55;
498
+ }
499
+ function isDecCode(c) {
500
+ return 48 <= c && c <= 57;
501
+ }
502
+ function resolveYamlInteger(data) {
503
+ if (data === null) return false;
504
+ var max = data.length, index = 0, hasDigits = false, ch;
505
+ if (!max) return false;
506
+ ch = data[index];
507
+ if (ch === "-" || ch === "+") {
508
+ ch = data[++index];
509
+ }
510
+ if (ch === "0") {
511
+ if (index + 1 === max) return true;
512
+ ch = data[++index];
513
+ if (ch === "b") {
514
+ index++;
515
+ for (; index < max; index++) {
516
+ ch = data[index];
517
+ if (ch === "_") continue;
518
+ if (ch !== "0" && ch !== "1") return false;
519
+ hasDigits = true;
520
+ }
521
+ return hasDigits && ch !== "_";
522
+ }
523
+ if (ch === "x") {
524
+ index++;
525
+ for (; index < max; index++) {
526
+ ch = data[index];
527
+ if (ch === "_") continue;
528
+ if (!isHexCode(data.charCodeAt(index))) return false;
529
+ hasDigits = true;
530
+ }
531
+ return hasDigits && ch !== "_";
532
+ }
533
+ if (ch === "o") {
534
+ index++;
535
+ for (; index < max; index++) {
536
+ ch = data[index];
537
+ if (ch === "_") continue;
538
+ if (!isOctCode(data.charCodeAt(index))) return false;
539
+ hasDigits = true;
540
+ }
541
+ return hasDigits && ch !== "_";
542
+ }
543
+ }
544
+ if (ch === "_") return false;
545
+ for (; index < max; index++) {
546
+ ch = data[index];
547
+ if (ch === "_") continue;
548
+ if (!isDecCode(data.charCodeAt(index))) {
549
+ return false;
550
+ }
551
+ hasDigits = true;
552
+ }
553
+ if (!hasDigits || ch === "_") return false;
554
+ return true;
555
+ }
556
+ function constructYamlInteger(data) {
557
+ var value = data, sign = 1, ch;
558
+ if (value.indexOf("_") !== -1) {
559
+ value = value.replace(/_/g, "");
560
+ }
561
+ ch = value[0];
562
+ if (ch === "-" || ch === "+") {
563
+ if (ch === "-") sign = -1;
564
+ value = value.slice(1);
565
+ ch = value[0];
566
+ }
567
+ if (value === "0") return 0;
568
+ if (ch === "0") {
569
+ if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
570
+ if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
571
+ if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
572
+ }
573
+ return sign * parseInt(value, 10);
574
+ }
575
+ function isInteger(object) {
576
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
577
+ }
578
+ module2.exports = new Type("tag:yaml.org,2002:int", {
579
+ kind: "scalar",
580
+ resolve: resolveYamlInteger,
581
+ construct: constructYamlInteger,
582
+ predicate: isInteger,
583
+ represent: {
584
+ binary: function(obj) {
585
+ return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
586
+ },
587
+ octal: function(obj) {
588
+ return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
589
+ },
590
+ decimal: function(obj) {
591
+ return obj.toString(10);
592
+ },
593
+ /* eslint-disable max-len */
594
+ hexadecimal: function(obj) {
595
+ return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
596
+ }
597
+ },
598
+ defaultStyle: "decimal",
599
+ styleAliases: {
600
+ binary: [2, "bin"],
601
+ octal: [8, "oct"],
602
+ decimal: [10, "dec"],
603
+ hexadecimal: [16, "hex"]
604
+ }
605
+ });
606
+ }
607
+ });
608
+
609
+ // ../common/node_modules/js-yaml/lib/type/float.js
610
+ var require_float = __commonJS({
611
+ "../common/node_modules/js-yaml/lib/type/float.js"(exports2, module2) {
612
+ "use strict";
613
+ var common = require_common();
614
+ var Type = require_type();
615
+ var YAML_FLOAT_PATTERN = new RegExp(
616
+ // 2.5e4, 2.5 and integers
617
+ "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
618
+ );
619
+ function resolveYamlFloat(data) {
620
+ if (data === null) return false;
621
+ if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
622
+ // Probably should update regexp & check speed
623
+ data[data.length - 1] === "_") {
624
+ return false;
625
+ }
626
+ return true;
627
+ }
628
+ function constructYamlFloat(data) {
629
+ var value, sign;
630
+ value = data.replace(/_/g, "").toLowerCase();
631
+ sign = value[0] === "-" ? -1 : 1;
632
+ if ("+-".indexOf(value[0]) >= 0) {
633
+ value = value.slice(1);
634
+ }
635
+ if (value === ".inf") {
636
+ return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
637
+ } else if (value === ".nan") {
638
+ return NaN;
639
+ }
640
+ return sign * parseFloat(value, 10);
641
+ }
642
+ var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
643
+ function representYamlFloat(object, style) {
644
+ var res;
645
+ if (isNaN(object)) {
646
+ switch (style) {
647
+ case "lowercase":
648
+ return ".nan";
649
+ case "uppercase":
650
+ return ".NAN";
651
+ case "camelcase":
652
+ return ".NaN";
653
+ }
654
+ } else if (Number.POSITIVE_INFINITY === object) {
655
+ switch (style) {
656
+ case "lowercase":
657
+ return ".inf";
658
+ case "uppercase":
659
+ return ".INF";
660
+ case "camelcase":
661
+ return ".Inf";
662
+ }
663
+ } else if (Number.NEGATIVE_INFINITY === object) {
664
+ switch (style) {
665
+ case "lowercase":
666
+ return "-.inf";
667
+ case "uppercase":
668
+ return "-.INF";
669
+ case "camelcase":
670
+ return "-.Inf";
671
+ }
672
+ } else if (common.isNegativeZero(object)) {
673
+ return "-0.0";
674
+ }
675
+ res = object.toString(10);
676
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
677
+ }
678
+ function isFloat(object) {
679
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
680
+ }
681
+ module2.exports = new Type("tag:yaml.org,2002:float", {
682
+ kind: "scalar",
683
+ resolve: resolveYamlFloat,
684
+ construct: constructYamlFloat,
685
+ predicate: isFloat,
686
+ represent: representYamlFloat,
687
+ defaultStyle: "lowercase"
688
+ });
689
+ }
690
+ });
691
+
692
+ // ../common/node_modules/js-yaml/lib/schema/json.js
693
+ var require_json = __commonJS({
694
+ "../common/node_modules/js-yaml/lib/schema/json.js"(exports2, module2) {
695
+ "use strict";
696
+ module2.exports = require_failsafe().extend({
697
+ implicit: [
698
+ require_null(),
699
+ require_bool(),
700
+ require_int(),
701
+ require_float()
702
+ ]
703
+ });
704
+ }
705
+ });
706
+
707
+ // ../common/node_modules/js-yaml/lib/schema/core.js
708
+ var require_core = __commonJS({
709
+ "../common/node_modules/js-yaml/lib/schema/core.js"(exports2, module2) {
710
+ "use strict";
711
+ module2.exports = require_json();
712
+ }
713
+ });
714
+
715
+ // ../common/node_modules/js-yaml/lib/type/timestamp.js
716
+ var require_timestamp = __commonJS({
717
+ "../common/node_modules/js-yaml/lib/type/timestamp.js"(exports2, module2) {
718
+ "use strict";
719
+ var Type = require_type();
720
+ var YAML_DATE_REGEXP = new RegExp(
721
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
722
+ );
723
+ var YAML_TIMESTAMP_REGEXP = new RegExp(
724
+ "^([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]))?))?$"
725
+ );
726
+ function resolveYamlTimestamp(data) {
727
+ if (data === null) return false;
728
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
729
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
730
+ return false;
731
+ }
732
+ function constructYamlTimestamp(data) {
733
+ var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
734
+ match = YAML_DATE_REGEXP.exec(data);
735
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
736
+ if (match === null) throw new Error("Date resolve error");
737
+ year = +match[1];
738
+ month = +match[2] - 1;
739
+ day = +match[3];
740
+ if (!match[4]) {
741
+ return new Date(Date.UTC(year, month, day));
742
+ }
743
+ hour = +match[4];
744
+ minute = +match[5];
745
+ second = +match[6];
746
+ if (match[7]) {
747
+ fraction = match[7].slice(0, 3);
748
+ while (fraction.length < 3) {
749
+ fraction += "0";
750
+ }
751
+ fraction = +fraction;
752
+ }
753
+ if (match[9]) {
754
+ tz_hour = +match[10];
755
+ tz_minute = +(match[11] || 0);
756
+ delta = (tz_hour * 60 + tz_minute) * 6e4;
757
+ if (match[9] === "-") delta = -delta;
758
+ }
759
+ date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
760
+ if (delta) date.setTime(date.getTime() - delta);
761
+ return date;
762
+ }
763
+ function representYamlTimestamp(object) {
764
+ return object.toISOString();
765
+ }
766
+ module2.exports = new Type("tag:yaml.org,2002:timestamp", {
767
+ kind: "scalar",
768
+ resolve: resolveYamlTimestamp,
769
+ construct: constructYamlTimestamp,
770
+ instanceOf: Date,
771
+ represent: representYamlTimestamp
772
+ });
773
+ }
774
+ });
775
+
776
+ // ../common/node_modules/js-yaml/lib/type/merge.js
777
+ var require_merge = __commonJS({
778
+ "../common/node_modules/js-yaml/lib/type/merge.js"(exports2, module2) {
779
+ "use strict";
780
+ var Type = require_type();
781
+ function resolveYamlMerge(data) {
782
+ return data === "<<" || data === null;
783
+ }
784
+ module2.exports = new Type("tag:yaml.org,2002:merge", {
785
+ kind: "scalar",
786
+ resolve: resolveYamlMerge
787
+ });
788
+ }
789
+ });
790
+
791
+ // ../common/node_modules/js-yaml/lib/type/binary.js
792
+ var require_binary = __commonJS({
793
+ "../common/node_modules/js-yaml/lib/type/binary.js"(exports2, module2) {
794
+ "use strict";
795
+ var Type = require_type();
796
+ var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
797
+ function resolveYamlBinary(data) {
798
+ if (data === null) return false;
799
+ var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
800
+ for (idx = 0; idx < max; idx++) {
801
+ code = map.indexOf(data.charAt(idx));
802
+ if (code > 64) continue;
803
+ if (code < 0) return false;
804
+ bitlen += 6;
805
+ }
806
+ return bitlen % 8 === 0;
807
+ }
808
+ function constructYamlBinary(data) {
809
+ var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map = BASE64_MAP, bits = 0, result = [];
810
+ for (idx = 0; idx < max; idx++) {
811
+ if (idx % 4 === 0 && idx) {
812
+ result.push(bits >> 16 & 255);
813
+ result.push(bits >> 8 & 255);
814
+ result.push(bits & 255);
815
+ }
816
+ bits = bits << 6 | map.indexOf(input.charAt(idx));
817
+ }
818
+ tailbits = max % 4 * 6;
819
+ if (tailbits === 0) {
820
+ result.push(bits >> 16 & 255);
821
+ result.push(bits >> 8 & 255);
822
+ result.push(bits & 255);
823
+ } else if (tailbits === 18) {
824
+ result.push(bits >> 10 & 255);
825
+ result.push(bits >> 2 & 255);
826
+ } else if (tailbits === 12) {
827
+ result.push(bits >> 4 & 255);
828
+ }
829
+ return new Uint8Array(result);
830
+ }
831
+ function representYamlBinary(object) {
832
+ var result = "", bits = 0, idx, tail, max = object.length, map = BASE64_MAP;
833
+ for (idx = 0; idx < max; idx++) {
834
+ if (idx % 3 === 0 && idx) {
835
+ result += map[bits >> 18 & 63];
836
+ result += map[bits >> 12 & 63];
837
+ result += map[bits >> 6 & 63];
838
+ result += map[bits & 63];
839
+ }
840
+ bits = (bits << 8) + object[idx];
841
+ }
842
+ tail = max % 3;
843
+ if (tail === 0) {
844
+ result += map[bits >> 18 & 63];
845
+ result += map[bits >> 12 & 63];
846
+ result += map[bits >> 6 & 63];
847
+ result += map[bits & 63];
848
+ } else if (tail === 2) {
849
+ result += map[bits >> 10 & 63];
850
+ result += map[bits >> 4 & 63];
851
+ result += map[bits << 2 & 63];
852
+ result += map[64];
853
+ } else if (tail === 1) {
854
+ result += map[bits >> 2 & 63];
855
+ result += map[bits << 4 & 63];
856
+ result += map[64];
857
+ result += map[64];
858
+ }
859
+ return result;
860
+ }
861
+ function isBinary(obj) {
862
+ return Object.prototype.toString.call(obj) === "[object Uint8Array]";
863
+ }
864
+ module2.exports = new Type("tag:yaml.org,2002:binary", {
865
+ kind: "scalar",
866
+ resolve: resolveYamlBinary,
867
+ construct: constructYamlBinary,
868
+ predicate: isBinary,
869
+ represent: representYamlBinary
870
+ });
871
+ }
872
+ });
873
+
874
+ // ../common/node_modules/js-yaml/lib/type/omap.js
875
+ var require_omap = __commonJS({
876
+ "../common/node_modules/js-yaml/lib/type/omap.js"(exports2, module2) {
877
+ "use strict";
878
+ var Type = require_type();
879
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
880
+ var _toString = Object.prototype.toString;
881
+ function resolveYamlOmap(data) {
882
+ if (data === null) return true;
883
+ var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
884
+ for (index = 0, length = object.length; index < length; index += 1) {
885
+ pair = object[index];
886
+ pairHasKey = false;
887
+ if (_toString.call(pair) !== "[object Object]") return false;
888
+ for (pairKey in pair) {
889
+ if (_hasOwnProperty.call(pair, pairKey)) {
890
+ if (!pairHasKey) pairHasKey = true;
891
+ else return false;
892
+ }
893
+ }
894
+ if (!pairHasKey) return false;
895
+ if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
896
+ else return false;
897
+ }
898
+ return true;
899
+ }
900
+ function constructYamlOmap(data) {
901
+ return data !== null ? data : [];
902
+ }
903
+ module2.exports = new Type("tag:yaml.org,2002:omap", {
904
+ kind: "sequence",
905
+ resolve: resolveYamlOmap,
906
+ construct: constructYamlOmap
907
+ });
908
+ }
909
+ });
910
+
911
+ // ../common/node_modules/js-yaml/lib/type/pairs.js
912
+ var require_pairs = __commonJS({
913
+ "../common/node_modules/js-yaml/lib/type/pairs.js"(exports2, module2) {
914
+ "use strict";
915
+ var Type = require_type();
916
+ var _toString = Object.prototype.toString;
917
+ function resolveYamlPairs(data) {
918
+ if (data === null) return true;
919
+ var index, length, pair, keys, result, object = data;
920
+ result = new Array(object.length);
921
+ for (index = 0, length = object.length; index < length; index += 1) {
922
+ pair = object[index];
923
+ if (_toString.call(pair) !== "[object Object]") return false;
924
+ keys = Object.keys(pair);
925
+ if (keys.length !== 1) return false;
926
+ result[index] = [keys[0], pair[keys[0]]];
927
+ }
928
+ return true;
929
+ }
930
+ function constructYamlPairs(data) {
931
+ if (data === null) return [];
932
+ var index, length, pair, keys, result, object = data;
933
+ result = new Array(object.length);
934
+ for (index = 0, length = object.length; index < length; index += 1) {
935
+ pair = object[index];
936
+ keys = Object.keys(pair);
937
+ result[index] = [keys[0], pair[keys[0]]];
938
+ }
939
+ return result;
940
+ }
941
+ module2.exports = new Type("tag:yaml.org,2002:pairs", {
942
+ kind: "sequence",
943
+ resolve: resolveYamlPairs,
944
+ construct: constructYamlPairs
945
+ });
946
+ }
947
+ });
948
+
949
+ // ../common/node_modules/js-yaml/lib/type/set.js
950
+ var require_set = __commonJS({
951
+ "../common/node_modules/js-yaml/lib/type/set.js"(exports2, module2) {
952
+ "use strict";
953
+ var Type = require_type();
954
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
955
+ function resolveYamlSet(data) {
956
+ if (data === null) return true;
957
+ var key, object = data;
958
+ for (key in object) {
959
+ if (_hasOwnProperty.call(object, key)) {
960
+ if (object[key] !== null) return false;
961
+ }
962
+ }
963
+ return true;
964
+ }
965
+ function constructYamlSet(data) {
966
+ return data !== null ? data : {};
967
+ }
968
+ module2.exports = new Type("tag:yaml.org,2002:set", {
969
+ kind: "mapping",
970
+ resolve: resolveYamlSet,
971
+ construct: constructYamlSet
972
+ });
973
+ }
974
+ });
975
+
976
+ // ../common/node_modules/js-yaml/lib/schema/default.js
977
+ var require_default = __commonJS({
978
+ "../common/node_modules/js-yaml/lib/schema/default.js"(exports2, module2) {
979
+ "use strict";
980
+ module2.exports = require_core().extend({
981
+ implicit: [
982
+ require_timestamp(),
983
+ require_merge()
984
+ ],
985
+ explicit: [
986
+ require_binary(),
987
+ require_omap(),
988
+ require_pairs(),
989
+ require_set()
990
+ ]
991
+ });
992
+ }
993
+ });
994
+
995
+ // ../common/node_modules/js-yaml/lib/loader.js
996
+ var require_loader = __commonJS({
997
+ "../common/node_modules/js-yaml/lib/loader.js"(exports2, module2) {
998
+ "use strict";
999
+ var common = require_common();
1000
+ var YAMLException = require_exception();
1001
+ var makeSnippet = require_snippet();
1002
+ var DEFAULT_SCHEMA = require_default();
1003
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
1004
+ var CONTEXT_FLOW_IN = 1;
1005
+ var CONTEXT_FLOW_OUT = 2;
1006
+ var CONTEXT_BLOCK_IN = 3;
1007
+ var CONTEXT_BLOCK_OUT = 4;
1008
+ var CHOMPING_CLIP = 1;
1009
+ var CHOMPING_STRIP = 2;
1010
+ var CHOMPING_KEEP = 3;
1011
+ var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
1012
+ var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
1013
+ var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
1014
+ var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
1015
+ var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
1016
+ function _class(obj) {
1017
+ return Object.prototype.toString.call(obj);
1018
+ }
1019
+ function is_EOL(c) {
1020
+ return c === 10 || c === 13;
1021
+ }
1022
+ function is_WHITE_SPACE(c) {
1023
+ return c === 9 || c === 32;
1024
+ }
1025
+ function is_WS_OR_EOL(c) {
1026
+ return c === 9 || c === 32 || c === 10 || c === 13;
1027
+ }
1028
+ function is_FLOW_INDICATOR(c) {
1029
+ return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
1030
+ }
1031
+ function fromHexCode(c) {
1032
+ var lc;
1033
+ if (48 <= c && c <= 57) {
1034
+ return c - 48;
1035
+ }
1036
+ lc = c | 32;
1037
+ if (97 <= lc && lc <= 102) {
1038
+ return lc - 97 + 10;
1039
+ }
1040
+ return -1;
1041
+ }
1042
+ function escapedHexLen(c) {
1043
+ if (c === 120) {
1044
+ return 2;
1045
+ }
1046
+ if (c === 117) {
1047
+ return 4;
1048
+ }
1049
+ if (c === 85) {
1050
+ return 8;
1051
+ }
1052
+ return 0;
1053
+ }
1054
+ function fromDecimalCode(c) {
1055
+ if (48 <= c && c <= 57) {
1056
+ return c - 48;
1057
+ }
1058
+ return -1;
1059
+ }
1060
+ function simpleEscapeSequence(c) {
1061
+ 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" : "";
1062
+ }
1063
+ function charFromCodepoint(c) {
1064
+ if (c <= 65535) {
1065
+ return String.fromCharCode(c);
1066
+ }
1067
+ return String.fromCharCode(
1068
+ (c - 65536 >> 10) + 55296,
1069
+ (c - 65536 & 1023) + 56320
1070
+ );
1071
+ }
1072
+ function setProperty(object, key, value) {
1073
+ if (key === "__proto__") {
1074
+ Object.defineProperty(object, key, {
1075
+ configurable: true,
1076
+ enumerable: true,
1077
+ writable: true,
1078
+ value
1079
+ });
1080
+ } else {
1081
+ object[key] = value;
1082
+ }
1083
+ }
1084
+ var simpleEscapeCheck = new Array(256);
1085
+ var simpleEscapeMap = new Array(256);
1086
+ for (i = 0; i < 256; i++) {
1087
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
1088
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
1089
+ }
1090
+ var i;
1091
+ function State(input, options) {
1092
+ this.input = input;
1093
+ this.filename = options["filename"] || null;
1094
+ this.schema = options["schema"] || DEFAULT_SCHEMA;
1095
+ this.onWarning = options["onWarning"] || null;
1096
+ this.legacy = options["legacy"] || false;
1097
+ this.json = options["json"] || false;
1098
+ this.listener = options["listener"] || null;
1099
+ this.implicitTypes = this.schema.compiledImplicit;
1100
+ this.typeMap = this.schema.compiledTypeMap;
1101
+ this.length = input.length;
1102
+ this.position = 0;
1103
+ this.line = 0;
1104
+ this.lineStart = 0;
1105
+ this.lineIndent = 0;
1106
+ this.firstTabInLine = -1;
1107
+ this.documents = [];
1108
+ }
1109
+ function generateError(state, message) {
1110
+ var mark = {
1111
+ name: state.filename,
1112
+ buffer: state.input.slice(0, -1),
1113
+ // omit trailing \0
1114
+ position: state.position,
1115
+ line: state.line,
1116
+ column: state.position - state.lineStart
1117
+ };
1118
+ mark.snippet = makeSnippet(mark);
1119
+ return new YAMLException(message, mark);
1120
+ }
1121
+ function throwError(state, message) {
1122
+ throw generateError(state, message);
1123
+ }
1124
+ function throwWarning(state, message) {
1125
+ if (state.onWarning) {
1126
+ state.onWarning.call(null, generateError(state, message));
1127
+ }
1128
+ }
1129
+ var directiveHandlers = {
1130
+ YAML: function handleYamlDirective(state, name, args) {
1131
+ var match, major, minor;
1132
+ if (state.version !== null) {
1133
+ throwError(state, "duplication of %YAML directive");
1134
+ }
1135
+ if (args.length !== 1) {
1136
+ throwError(state, "YAML directive accepts exactly one argument");
1137
+ }
1138
+ match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1139
+ if (match === null) {
1140
+ throwError(state, "ill-formed argument of the YAML directive");
1141
+ }
1142
+ major = parseInt(match[1], 10);
1143
+ minor = parseInt(match[2], 10);
1144
+ if (major !== 1) {
1145
+ throwError(state, "unacceptable YAML version of the document");
1146
+ }
1147
+ state.version = args[0];
1148
+ state.checkLineBreaks = minor < 2;
1149
+ if (minor !== 1 && minor !== 2) {
1150
+ throwWarning(state, "unsupported YAML version of the document");
1151
+ }
1152
+ },
1153
+ TAG: function handleTagDirective(state, name, args) {
1154
+ var handle, prefix;
1155
+ if (args.length !== 2) {
1156
+ throwError(state, "TAG directive accepts exactly two arguments");
1157
+ }
1158
+ handle = args[0];
1159
+ prefix = args[1];
1160
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
1161
+ throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
1162
+ }
1163
+ if (_hasOwnProperty.call(state.tagMap, handle)) {
1164
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1165
+ }
1166
+ if (!PATTERN_TAG_URI.test(prefix)) {
1167
+ throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
1168
+ }
1169
+ try {
1170
+ prefix = decodeURIComponent(prefix);
1171
+ } catch (err) {
1172
+ throwError(state, "tag prefix is malformed: " + prefix);
1173
+ }
1174
+ state.tagMap[handle] = prefix;
1175
+ }
1176
+ };
1177
+ function captureSegment(state, start, end, checkJson) {
1178
+ var _position, _length, _character, _result;
1179
+ if (start < end) {
1180
+ _result = state.input.slice(start, end);
1181
+ if (checkJson) {
1182
+ for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
1183
+ _character = _result.charCodeAt(_position);
1184
+ if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
1185
+ throwError(state, "expected valid JSON character");
1186
+ }
1187
+ }
1188
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1189
+ throwError(state, "the stream contains non-printable characters");
1190
+ }
1191
+ state.result += _result;
1192
+ }
1193
+ }
1194
+ function mergeMappings(state, destination, source, overridableKeys) {
1195
+ var sourceKeys, key, index, quantity;
1196
+ if (!common.isObject(source)) {
1197
+ throwError(state, "cannot merge mappings; the provided source object is unacceptable");
1198
+ }
1199
+ sourceKeys = Object.keys(source);
1200
+ for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1201
+ key = sourceKeys[index];
1202
+ if (!_hasOwnProperty.call(destination, key)) {
1203
+ setProperty(destination, key, source[key]);
1204
+ overridableKeys[key] = true;
1205
+ }
1206
+ }
1207
+ }
1208
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
1209
+ var index, quantity;
1210
+ if (Array.isArray(keyNode)) {
1211
+ keyNode = Array.prototype.slice.call(keyNode);
1212
+ for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
1213
+ if (Array.isArray(keyNode[index])) {
1214
+ throwError(state, "nested arrays are not supported inside keys");
1215
+ }
1216
+ if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
1217
+ keyNode[index] = "[object Object]";
1218
+ }
1219
+ }
1220
+ }
1221
+ if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
1222
+ keyNode = "[object Object]";
1223
+ }
1224
+ keyNode = String(keyNode);
1225
+ if (_result === null) {
1226
+ _result = {};
1227
+ }
1228
+ if (keyTag === "tag:yaml.org,2002:merge") {
1229
+ if (Array.isArray(valueNode)) {
1230
+ for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1231
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
1232
+ }
1233
+ } else {
1234
+ mergeMappings(state, _result, valueNode, overridableKeys);
1235
+ }
1236
+ } else {
1237
+ if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
1238
+ state.line = startLine || state.line;
1239
+ state.lineStart = startLineStart || state.lineStart;
1240
+ state.position = startPos || state.position;
1241
+ throwError(state, "duplicated mapping key");
1242
+ }
1243
+ setProperty(_result, keyNode, valueNode);
1244
+ delete overridableKeys[keyNode];
1245
+ }
1246
+ return _result;
1247
+ }
1248
+ function readLineBreak(state) {
1249
+ var ch;
1250
+ ch = state.input.charCodeAt(state.position);
1251
+ if (ch === 10) {
1252
+ state.position++;
1253
+ } else if (ch === 13) {
1254
+ state.position++;
1255
+ if (state.input.charCodeAt(state.position) === 10) {
1256
+ state.position++;
1257
+ }
1258
+ } else {
1259
+ throwError(state, "a line break is expected");
1260
+ }
1261
+ state.line += 1;
1262
+ state.lineStart = state.position;
1263
+ state.firstTabInLine = -1;
1264
+ }
1265
+ function skipSeparationSpace(state, allowComments, checkIndent) {
1266
+ var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
1267
+ while (ch !== 0) {
1268
+ while (is_WHITE_SPACE(ch)) {
1269
+ if (ch === 9 && state.firstTabInLine === -1) {
1270
+ state.firstTabInLine = state.position;
1271
+ }
1272
+ ch = state.input.charCodeAt(++state.position);
1273
+ }
1274
+ if (allowComments && ch === 35) {
1275
+ do {
1276
+ ch = state.input.charCodeAt(++state.position);
1277
+ } while (ch !== 10 && ch !== 13 && ch !== 0);
1278
+ }
1279
+ if (is_EOL(ch)) {
1280
+ readLineBreak(state);
1281
+ ch = state.input.charCodeAt(state.position);
1282
+ lineBreaks++;
1283
+ state.lineIndent = 0;
1284
+ while (ch === 32) {
1285
+ state.lineIndent++;
1286
+ ch = state.input.charCodeAt(++state.position);
1287
+ }
1288
+ } else {
1289
+ break;
1290
+ }
1291
+ }
1292
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1293
+ throwWarning(state, "deficient indentation");
1294
+ }
1295
+ return lineBreaks;
1296
+ }
1297
+ function testDocumentSeparator(state) {
1298
+ var _position = state.position, ch;
1299
+ ch = state.input.charCodeAt(_position);
1300
+ if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
1301
+ _position += 3;
1302
+ ch = state.input.charCodeAt(_position);
1303
+ if (ch === 0 || is_WS_OR_EOL(ch)) {
1304
+ return true;
1305
+ }
1306
+ }
1307
+ return false;
1308
+ }
1309
+ function writeFoldedLines(state, count) {
1310
+ if (count === 1) {
1311
+ state.result += " ";
1312
+ } else if (count > 1) {
1313
+ state.result += common.repeat("\n", count - 1);
1314
+ }
1315
+ }
1316
+ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1317
+ var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
1318
+ ch = state.input.charCodeAt(state.position);
1319
+ 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) {
1320
+ return false;
1321
+ }
1322
+ if (ch === 63 || ch === 45) {
1323
+ following = state.input.charCodeAt(state.position + 1);
1324
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1325
+ return false;
1326
+ }
1327
+ }
1328
+ state.kind = "scalar";
1329
+ state.result = "";
1330
+ captureStart = captureEnd = state.position;
1331
+ hasPendingContent = false;
1332
+ while (ch !== 0) {
1333
+ if (ch === 58) {
1334
+ following = state.input.charCodeAt(state.position + 1);
1335
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1336
+ break;
1337
+ }
1338
+ } else if (ch === 35) {
1339
+ preceding = state.input.charCodeAt(state.position - 1);
1340
+ if (is_WS_OR_EOL(preceding)) {
1341
+ break;
1342
+ }
1343
+ } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1344
+ break;
1345
+ } else if (is_EOL(ch)) {
1346
+ _line = state.line;
1347
+ _lineStart = state.lineStart;
1348
+ _lineIndent = state.lineIndent;
1349
+ skipSeparationSpace(state, false, -1);
1350
+ if (state.lineIndent >= nodeIndent) {
1351
+ hasPendingContent = true;
1352
+ ch = state.input.charCodeAt(state.position);
1353
+ continue;
1354
+ } else {
1355
+ state.position = captureEnd;
1356
+ state.line = _line;
1357
+ state.lineStart = _lineStart;
1358
+ state.lineIndent = _lineIndent;
1359
+ break;
1360
+ }
1361
+ }
1362
+ if (hasPendingContent) {
1363
+ captureSegment(state, captureStart, captureEnd, false);
1364
+ writeFoldedLines(state, state.line - _line);
1365
+ captureStart = captureEnd = state.position;
1366
+ hasPendingContent = false;
1367
+ }
1368
+ if (!is_WHITE_SPACE(ch)) {
1369
+ captureEnd = state.position + 1;
1370
+ }
1371
+ ch = state.input.charCodeAt(++state.position);
1372
+ }
1373
+ captureSegment(state, captureStart, captureEnd, false);
1374
+ if (state.result) {
1375
+ return true;
1376
+ }
1377
+ state.kind = _kind;
1378
+ state.result = _result;
1379
+ return false;
1380
+ }
1381
+ function readSingleQuotedScalar(state, nodeIndent) {
1382
+ var ch, captureStart, captureEnd;
1383
+ ch = state.input.charCodeAt(state.position);
1384
+ if (ch !== 39) {
1385
+ return false;
1386
+ }
1387
+ state.kind = "scalar";
1388
+ state.result = "";
1389
+ state.position++;
1390
+ captureStart = captureEnd = state.position;
1391
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1392
+ if (ch === 39) {
1393
+ captureSegment(state, captureStart, state.position, true);
1394
+ ch = state.input.charCodeAt(++state.position);
1395
+ if (ch === 39) {
1396
+ captureStart = state.position;
1397
+ state.position++;
1398
+ captureEnd = state.position;
1399
+ } else {
1400
+ return true;
1401
+ }
1402
+ } else if (is_EOL(ch)) {
1403
+ captureSegment(state, captureStart, captureEnd, true);
1404
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1405
+ captureStart = captureEnd = state.position;
1406
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1407
+ throwError(state, "unexpected end of the document within a single quoted scalar");
1408
+ } else {
1409
+ state.position++;
1410
+ captureEnd = state.position;
1411
+ }
1412
+ }
1413
+ throwError(state, "unexpected end of the stream within a single quoted scalar");
1414
+ }
1415
+ function readDoubleQuotedScalar(state, nodeIndent) {
1416
+ var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
1417
+ ch = state.input.charCodeAt(state.position);
1418
+ if (ch !== 34) {
1419
+ return false;
1420
+ }
1421
+ state.kind = "scalar";
1422
+ state.result = "";
1423
+ state.position++;
1424
+ captureStart = captureEnd = state.position;
1425
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1426
+ if (ch === 34) {
1427
+ captureSegment(state, captureStart, state.position, true);
1428
+ state.position++;
1429
+ return true;
1430
+ } else if (ch === 92) {
1431
+ captureSegment(state, captureStart, state.position, true);
1432
+ ch = state.input.charCodeAt(++state.position);
1433
+ if (is_EOL(ch)) {
1434
+ skipSeparationSpace(state, false, nodeIndent);
1435
+ } else if (ch < 256 && simpleEscapeCheck[ch]) {
1436
+ state.result += simpleEscapeMap[ch];
1437
+ state.position++;
1438
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
1439
+ hexLength = tmp;
1440
+ hexResult = 0;
1441
+ for (; hexLength > 0; hexLength--) {
1442
+ ch = state.input.charCodeAt(++state.position);
1443
+ if ((tmp = fromHexCode(ch)) >= 0) {
1444
+ hexResult = (hexResult << 4) + tmp;
1445
+ } else {
1446
+ throwError(state, "expected hexadecimal character");
1447
+ }
1448
+ }
1449
+ state.result += charFromCodepoint(hexResult);
1450
+ state.position++;
1451
+ } else {
1452
+ throwError(state, "unknown escape sequence");
1453
+ }
1454
+ captureStart = captureEnd = state.position;
1455
+ } else if (is_EOL(ch)) {
1456
+ captureSegment(state, captureStart, captureEnd, true);
1457
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1458
+ captureStart = captureEnd = state.position;
1459
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1460
+ throwError(state, "unexpected end of the document within a double quoted scalar");
1461
+ } else {
1462
+ state.position++;
1463
+ captureEnd = state.position;
1464
+ }
1465
+ }
1466
+ throwError(state, "unexpected end of the stream within a double quoted scalar");
1467
+ }
1468
+ function readFlowCollection(state, nodeIndent) {
1469
+ 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;
1470
+ ch = state.input.charCodeAt(state.position);
1471
+ if (ch === 91) {
1472
+ terminator = 93;
1473
+ isMapping = false;
1474
+ _result = [];
1475
+ } else if (ch === 123) {
1476
+ terminator = 125;
1477
+ isMapping = true;
1478
+ _result = {};
1479
+ } else {
1480
+ return false;
1481
+ }
1482
+ if (state.anchor !== null) {
1483
+ state.anchorMap[state.anchor] = _result;
1484
+ }
1485
+ ch = state.input.charCodeAt(++state.position);
1486
+ while (ch !== 0) {
1487
+ skipSeparationSpace(state, true, nodeIndent);
1488
+ ch = state.input.charCodeAt(state.position);
1489
+ if (ch === terminator) {
1490
+ state.position++;
1491
+ state.tag = _tag;
1492
+ state.anchor = _anchor;
1493
+ state.kind = isMapping ? "mapping" : "sequence";
1494
+ state.result = _result;
1495
+ return true;
1496
+ } else if (!readNext) {
1497
+ throwError(state, "missed comma between flow collection entries");
1498
+ } else if (ch === 44) {
1499
+ throwError(state, "expected the node content, but found ','");
1500
+ }
1501
+ keyTag = keyNode = valueNode = null;
1502
+ isPair = isExplicitPair = false;
1503
+ if (ch === 63) {
1504
+ following = state.input.charCodeAt(state.position + 1);
1505
+ if (is_WS_OR_EOL(following)) {
1506
+ isPair = isExplicitPair = true;
1507
+ state.position++;
1508
+ skipSeparationSpace(state, true, nodeIndent);
1509
+ }
1510
+ }
1511
+ _line = state.line;
1512
+ _lineStart = state.lineStart;
1513
+ _pos = state.position;
1514
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1515
+ keyTag = state.tag;
1516
+ keyNode = state.result;
1517
+ skipSeparationSpace(state, true, nodeIndent);
1518
+ ch = state.input.charCodeAt(state.position);
1519
+ if ((isExplicitPair || state.line === _line) && ch === 58) {
1520
+ isPair = true;
1521
+ ch = state.input.charCodeAt(++state.position);
1522
+ skipSeparationSpace(state, true, nodeIndent);
1523
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1524
+ valueNode = state.result;
1525
+ }
1526
+ if (isMapping) {
1527
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
1528
+ } else if (isPair) {
1529
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
1530
+ } else {
1531
+ _result.push(keyNode);
1532
+ }
1533
+ skipSeparationSpace(state, true, nodeIndent);
1534
+ ch = state.input.charCodeAt(state.position);
1535
+ if (ch === 44) {
1536
+ readNext = true;
1537
+ ch = state.input.charCodeAt(++state.position);
1538
+ } else {
1539
+ readNext = false;
1540
+ }
1541
+ }
1542
+ throwError(state, "unexpected end of the stream within a flow collection");
1543
+ }
1544
+ function readBlockScalar(state, nodeIndent) {
1545
+ var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
1546
+ ch = state.input.charCodeAt(state.position);
1547
+ if (ch === 124) {
1548
+ folding = false;
1549
+ } else if (ch === 62) {
1550
+ folding = true;
1551
+ } else {
1552
+ return false;
1553
+ }
1554
+ state.kind = "scalar";
1555
+ state.result = "";
1556
+ while (ch !== 0) {
1557
+ ch = state.input.charCodeAt(++state.position);
1558
+ if (ch === 43 || ch === 45) {
1559
+ if (CHOMPING_CLIP === chomping) {
1560
+ chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
1561
+ } else {
1562
+ throwError(state, "repeat of a chomping mode identifier");
1563
+ }
1564
+ } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1565
+ if (tmp === 0) {
1566
+ throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
1567
+ } else if (!detectedIndent) {
1568
+ textIndent = nodeIndent + tmp - 1;
1569
+ detectedIndent = true;
1570
+ } else {
1571
+ throwError(state, "repeat of an indentation width identifier");
1572
+ }
1573
+ } else {
1574
+ break;
1575
+ }
1576
+ }
1577
+ if (is_WHITE_SPACE(ch)) {
1578
+ do {
1579
+ ch = state.input.charCodeAt(++state.position);
1580
+ } while (is_WHITE_SPACE(ch));
1581
+ if (ch === 35) {
1582
+ do {
1583
+ ch = state.input.charCodeAt(++state.position);
1584
+ } while (!is_EOL(ch) && ch !== 0);
1585
+ }
1586
+ }
1587
+ while (ch !== 0) {
1588
+ readLineBreak(state);
1589
+ state.lineIndent = 0;
1590
+ ch = state.input.charCodeAt(state.position);
1591
+ while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
1592
+ state.lineIndent++;
1593
+ ch = state.input.charCodeAt(++state.position);
1594
+ }
1595
+ if (!detectedIndent && state.lineIndent > textIndent) {
1596
+ textIndent = state.lineIndent;
1597
+ }
1598
+ if (is_EOL(ch)) {
1599
+ emptyLines++;
1600
+ continue;
1601
+ }
1602
+ if (state.lineIndent < textIndent) {
1603
+ if (chomping === CHOMPING_KEEP) {
1604
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1605
+ } else if (chomping === CHOMPING_CLIP) {
1606
+ if (didReadContent) {
1607
+ state.result += "\n";
1608
+ }
1609
+ }
1610
+ break;
1611
+ }
1612
+ if (folding) {
1613
+ if (is_WHITE_SPACE(ch)) {
1614
+ atMoreIndented = true;
1615
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1616
+ } else if (atMoreIndented) {
1617
+ atMoreIndented = false;
1618
+ state.result += common.repeat("\n", emptyLines + 1);
1619
+ } else if (emptyLines === 0) {
1620
+ if (didReadContent) {
1621
+ state.result += " ";
1622
+ }
1623
+ } else {
1624
+ state.result += common.repeat("\n", emptyLines);
1625
+ }
1626
+ } else {
1627
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1628
+ }
1629
+ didReadContent = true;
1630
+ detectedIndent = true;
1631
+ emptyLines = 0;
1632
+ captureStart = state.position;
1633
+ while (!is_EOL(ch) && ch !== 0) {
1634
+ ch = state.input.charCodeAt(++state.position);
1635
+ }
1636
+ captureSegment(state, captureStart, state.position, false);
1637
+ }
1638
+ return true;
1639
+ }
1640
+ function readBlockSequence(state, nodeIndent) {
1641
+ var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
1642
+ if (state.firstTabInLine !== -1) return false;
1643
+ if (state.anchor !== null) {
1644
+ state.anchorMap[state.anchor] = _result;
1645
+ }
1646
+ ch = state.input.charCodeAt(state.position);
1647
+ while (ch !== 0) {
1648
+ if (state.firstTabInLine !== -1) {
1649
+ state.position = state.firstTabInLine;
1650
+ throwError(state, "tab characters must not be used in indentation");
1651
+ }
1652
+ if (ch !== 45) {
1653
+ break;
1654
+ }
1655
+ following = state.input.charCodeAt(state.position + 1);
1656
+ if (!is_WS_OR_EOL(following)) {
1657
+ break;
1658
+ }
1659
+ detected = true;
1660
+ state.position++;
1661
+ if (skipSeparationSpace(state, true, -1)) {
1662
+ if (state.lineIndent <= nodeIndent) {
1663
+ _result.push(null);
1664
+ ch = state.input.charCodeAt(state.position);
1665
+ continue;
1666
+ }
1667
+ }
1668
+ _line = state.line;
1669
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1670
+ _result.push(state.result);
1671
+ skipSeparationSpace(state, true, -1);
1672
+ ch = state.input.charCodeAt(state.position);
1673
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1674
+ throwError(state, "bad indentation of a sequence entry");
1675
+ } else if (state.lineIndent < nodeIndent) {
1676
+ break;
1677
+ }
1678
+ }
1679
+ if (detected) {
1680
+ state.tag = _tag;
1681
+ state.anchor = _anchor;
1682
+ state.kind = "sequence";
1683
+ state.result = _result;
1684
+ return true;
1685
+ }
1686
+ return false;
1687
+ }
1688
+ function readBlockMapping(state, nodeIndent, flowIndent) {
1689
+ 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;
1690
+ if (state.firstTabInLine !== -1) return false;
1691
+ if (state.anchor !== null) {
1692
+ state.anchorMap[state.anchor] = _result;
1693
+ }
1694
+ ch = state.input.charCodeAt(state.position);
1695
+ while (ch !== 0) {
1696
+ if (!atExplicitKey && state.firstTabInLine !== -1) {
1697
+ state.position = state.firstTabInLine;
1698
+ throwError(state, "tab characters must not be used in indentation");
1699
+ }
1700
+ following = state.input.charCodeAt(state.position + 1);
1701
+ _line = state.line;
1702
+ if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
1703
+ if (ch === 63) {
1704
+ if (atExplicitKey) {
1705
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1706
+ keyTag = keyNode = valueNode = null;
1707
+ }
1708
+ detected = true;
1709
+ atExplicitKey = true;
1710
+ allowCompact = true;
1711
+ } else if (atExplicitKey) {
1712
+ atExplicitKey = false;
1713
+ allowCompact = true;
1714
+ } else {
1715
+ throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
1716
+ }
1717
+ state.position += 1;
1718
+ ch = following;
1719
+ } else {
1720
+ _keyLine = state.line;
1721
+ _keyLineStart = state.lineStart;
1722
+ _keyPos = state.position;
1723
+ if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1724
+ break;
1725
+ }
1726
+ if (state.line === _line) {
1727
+ ch = state.input.charCodeAt(state.position);
1728
+ while (is_WHITE_SPACE(ch)) {
1729
+ ch = state.input.charCodeAt(++state.position);
1730
+ }
1731
+ if (ch === 58) {
1732
+ ch = state.input.charCodeAt(++state.position);
1733
+ if (!is_WS_OR_EOL(ch)) {
1734
+ throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
1735
+ }
1736
+ if (atExplicitKey) {
1737
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1738
+ keyTag = keyNode = valueNode = null;
1739
+ }
1740
+ detected = true;
1741
+ atExplicitKey = false;
1742
+ allowCompact = false;
1743
+ keyTag = state.tag;
1744
+ keyNode = state.result;
1745
+ } else if (detected) {
1746
+ throwError(state, "can not read an implicit mapping pair; a colon is missed");
1747
+ } else {
1748
+ state.tag = _tag;
1749
+ state.anchor = _anchor;
1750
+ return true;
1751
+ }
1752
+ } else if (detected) {
1753
+ throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
1754
+ } else {
1755
+ state.tag = _tag;
1756
+ state.anchor = _anchor;
1757
+ return true;
1758
+ }
1759
+ }
1760
+ if (state.line === _line || state.lineIndent > nodeIndent) {
1761
+ if (atExplicitKey) {
1762
+ _keyLine = state.line;
1763
+ _keyLineStart = state.lineStart;
1764
+ _keyPos = state.position;
1765
+ }
1766
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
1767
+ if (atExplicitKey) {
1768
+ keyNode = state.result;
1769
+ } else {
1770
+ valueNode = state.result;
1771
+ }
1772
+ }
1773
+ if (!atExplicitKey) {
1774
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
1775
+ keyTag = keyNode = valueNode = null;
1776
+ }
1777
+ skipSeparationSpace(state, true, -1);
1778
+ ch = state.input.charCodeAt(state.position);
1779
+ }
1780
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1781
+ throwError(state, "bad indentation of a mapping entry");
1782
+ } else if (state.lineIndent < nodeIndent) {
1783
+ break;
1784
+ }
1785
+ }
1786
+ if (atExplicitKey) {
1787
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1788
+ }
1789
+ if (detected) {
1790
+ state.tag = _tag;
1791
+ state.anchor = _anchor;
1792
+ state.kind = "mapping";
1793
+ state.result = _result;
1794
+ }
1795
+ return detected;
1796
+ }
1797
+ function readTagProperty(state) {
1798
+ var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
1799
+ ch = state.input.charCodeAt(state.position);
1800
+ if (ch !== 33) return false;
1801
+ if (state.tag !== null) {
1802
+ throwError(state, "duplication of a tag property");
1803
+ }
1804
+ ch = state.input.charCodeAt(++state.position);
1805
+ if (ch === 60) {
1806
+ isVerbatim = true;
1807
+ ch = state.input.charCodeAt(++state.position);
1808
+ } else if (ch === 33) {
1809
+ isNamed = true;
1810
+ tagHandle = "!!";
1811
+ ch = state.input.charCodeAt(++state.position);
1812
+ } else {
1813
+ tagHandle = "!";
1814
+ }
1815
+ _position = state.position;
1816
+ if (isVerbatim) {
1817
+ do {
1818
+ ch = state.input.charCodeAt(++state.position);
1819
+ } while (ch !== 0 && ch !== 62);
1820
+ if (state.position < state.length) {
1821
+ tagName = state.input.slice(_position, state.position);
1822
+ ch = state.input.charCodeAt(++state.position);
1823
+ } else {
1824
+ throwError(state, "unexpected end of the stream within a verbatim tag");
1825
+ }
1826
+ } else {
1827
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1828
+ if (ch === 33) {
1829
+ if (!isNamed) {
1830
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
1831
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
1832
+ throwError(state, "named tag handle cannot contain such characters");
1833
+ }
1834
+ isNamed = true;
1835
+ _position = state.position + 1;
1836
+ } else {
1837
+ throwError(state, "tag suffix cannot contain exclamation marks");
1838
+ }
1839
+ }
1840
+ ch = state.input.charCodeAt(++state.position);
1841
+ }
1842
+ tagName = state.input.slice(_position, state.position);
1843
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) {
1844
+ throwError(state, "tag suffix cannot contain flow indicator characters");
1845
+ }
1846
+ }
1847
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) {
1848
+ throwError(state, "tag name cannot contain such characters: " + tagName);
1849
+ }
1850
+ try {
1851
+ tagName = decodeURIComponent(tagName);
1852
+ } catch (err) {
1853
+ throwError(state, "tag name is malformed: " + tagName);
1854
+ }
1855
+ if (isVerbatim) {
1856
+ state.tag = tagName;
1857
+ } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
1858
+ state.tag = state.tagMap[tagHandle] + tagName;
1859
+ } else if (tagHandle === "!") {
1860
+ state.tag = "!" + tagName;
1861
+ } else if (tagHandle === "!!") {
1862
+ state.tag = "tag:yaml.org,2002:" + tagName;
1863
+ } else {
1864
+ throwError(state, 'undeclared tag handle "' + tagHandle + '"');
1865
+ }
1866
+ return true;
1867
+ }
1868
+ function readAnchorProperty(state) {
1869
+ var _position, ch;
1870
+ ch = state.input.charCodeAt(state.position);
1871
+ if (ch !== 38) return false;
1872
+ if (state.anchor !== null) {
1873
+ throwError(state, "duplication of an anchor property");
1874
+ }
1875
+ ch = state.input.charCodeAt(++state.position);
1876
+ _position = state.position;
1877
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1878
+ ch = state.input.charCodeAt(++state.position);
1879
+ }
1880
+ if (state.position === _position) {
1881
+ throwError(state, "name of an anchor node must contain at least one character");
1882
+ }
1883
+ state.anchor = state.input.slice(_position, state.position);
1884
+ return true;
1885
+ }
1886
+ function readAlias(state) {
1887
+ var _position, alias, ch;
1888
+ ch = state.input.charCodeAt(state.position);
1889
+ if (ch !== 42) return false;
1890
+ ch = state.input.charCodeAt(++state.position);
1891
+ _position = state.position;
1892
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1893
+ ch = state.input.charCodeAt(++state.position);
1894
+ }
1895
+ if (state.position === _position) {
1896
+ throwError(state, "name of an alias node must contain at least one character");
1897
+ }
1898
+ alias = state.input.slice(_position, state.position);
1899
+ if (!_hasOwnProperty.call(state.anchorMap, alias)) {
1900
+ throwError(state, 'unidentified alias "' + alias + '"');
1901
+ }
1902
+ state.result = state.anchorMap[alias];
1903
+ skipSeparationSpace(state, true, -1);
1904
+ return true;
1905
+ }
1906
+ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
1907
+ var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type, flowIndent, blockIndent;
1908
+ if (state.listener !== null) {
1909
+ state.listener("open", state);
1910
+ }
1911
+ state.tag = null;
1912
+ state.anchor = null;
1913
+ state.kind = null;
1914
+ state.result = null;
1915
+ allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
1916
+ if (allowToSeek) {
1917
+ if (skipSeparationSpace(state, true, -1)) {
1918
+ atNewLine = true;
1919
+ if (state.lineIndent > parentIndent) {
1920
+ indentStatus = 1;
1921
+ } else if (state.lineIndent === parentIndent) {
1922
+ indentStatus = 0;
1923
+ } else if (state.lineIndent < parentIndent) {
1924
+ indentStatus = -1;
1925
+ }
1926
+ }
1927
+ }
1928
+ if (indentStatus === 1) {
1929
+ while (readTagProperty(state) || readAnchorProperty(state)) {
1930
+ if (skipSeparationSpace(state, true, -1)) {
1931
+ atNewLine = true;
1932
+ allowBlockCollections = allowBlockStyles;
1933
+ if (state.lineIndent > parentIndent) {
1934
+ indentStatus = 1;
1935
+ } else if (state.lineIndent === parentIndent) {
1936
+ indentStatus = 0;
1937
+ } else if (state.lineIndent < parentIndent) {
1938
+ indentStatus = -1;
1939
+ }
1940
+ } else {
1941
+ allowBlockCollections = false;
1942
+ }
1943
+ }
1944
+ }
1945
+ if (allowBlockCollections) {
1946
+ allowBlockCollections = atNewLine || allowCompact;
1947
+ }
1948
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
1949
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
1950
+ flowIndent = parentIndent;
1951
+ } else {
1952
+ flowIndent = parentIndent + 1;
1953
+ }
1954
+ blockIndent = state.position - state.lineStart;
1955
+ if (indentStatus === 1) {
1956
+ if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
1957
+ hasContent = true;
1958
+ } else {
1959
+ if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
1960
+ hasContent = true;
1961
+ } else if (readAlias(state)) {
1962
+ hasContent = true;
1963
+ if (state.tag !== null || state.anchor !== null) {
1964
+ throwError(state, "alias node should not have any properties");
1965
+ }
1966
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
1967
+ hasContent = true;
1968
+ if (state.tag === null) {
1969
+ state.tag = "?";
1970
+ }
1971
+ }
1972
+ if (state.anchor !== null) {
1973
+ state.anchorMap[state.anchor] = state.result;
1974
+ }
1975
+ }
1976
+ } else if (indentStatus === 0) {
1977
+ hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
1978
+ }
1979
+ }
1980
+ if (state.tag === null) {
1981
+ if (state.anchor !== null) {
1982
+ state.anchorMap[state.anchor] = state.result;
1983
+ }
1984
+ } else if (state.tag === "?") {
1985
+ if (state.result !== null && state.kind !== "scalar") {
1986
+ throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
1987
+ }
1988
+ for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
1989
+ type = state.implicitTypes[typeIndex];
1990
+ if (type.resolve(state.result)) {
1991
+ state.result = type.construct(state.result);
1992
+ state.tag = type.tag;
1993
+ if (state.anchor !== null) {
1994
+ state.anchorMap[state.anchor] = state.result;
1995
+ }
1996
+ break;
1997
+ }
1998
+ }
1999
+ } else if (state.tag !== "!") {
2000
+ if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) {
2001
+ type = state.typeMap[state.kind || "fallback"][state.tag];
2002
+ } else {
2003
+ type = null;
2004
+ typeList = state.typeMap.multi[state.kind || "fallback"];
2005
+ for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
2006
+ if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
2007
+ type = typeList[typeIndex];
2008
+ break;
2009
+ }
2010
+ }
2011
+ }
2012
+ if (!type) {
2013
+ throwError(state, "unknown tag !<" + state.tag + ">");
2014
+ }
2015
+ if (state.result !== null && type.kind !== state.kind) {
2016
+ throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
2017
+ }
2018
+ if (!type.resolve(state.result, state.tag)) {
2019
+ throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
2020
+ } else {
2021
+ state.result = type.construct(state.result, state.tag);
2022
+ if (state.anchor !== null) {
2023
+ state.anchorMap[state.anchor] = state.result;
2024
+ }
2025
+ }
2026
+ }
2027
+ if (state.listener !== null) {
2028
+ state.listener("close", state);
2029
+ }
2030
+ return state.tag !== null || state.anchor !== null || hasContent;
2031
+ }
2032
+ function readDocument(state) {
2033
+ var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
2034
+ state.version = null;
2035
+ state.checkLineBreaks = state.legacy;
2036
+ state.tagMap = /* @__PURE__ */ Object.create(null);
2037
+ state.anchorMap = /* @__PURE__ */ Object.create(null);
2038
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2039
+ skipSeparationSpace(state, true, -1);
2040
+ ch = state.input.charCodeAt(state.position);
2041
+ if (state.lineIndent > 0 || ch !== 37) {
2042
+ break;
2043
+ }
2044
+ hasDirectives = true;
2045
+ ch = state.input.charCodeAt(++state.position);
2046
+ _position = state.position;
2047
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2048
+ ch = state.input.charCodeAt(++state.position);
2049
+ }
2050
+ directiveName = state.input.slice(_position, state.position);
2051
+ directiveArgs = [];
2052
+ if (directiveName.length < 1) {
2053
+ throwError(state, "directive name must not be less than one character in length");
2054
+ }
2055
+ while (ch !== 0) {
2056
+ while (is_WHITE_SPACE(ch)) {
2057
+ ch = state.input.charCodeAt(++state.position);
2058
+ }
2059
+ if (ch === 35) {
2060
+ do {
2061
+ ch = state.input.charCodeAt(++state.position);
2062
+ } while (ch !== 0 && !is_EOL(ch));
2063
+ break;
2064
+ }
2065
+ if (is_EOL(ch)) break;
2066
+ _position = state.position;
2067
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2068
+ ch = state.input.charCodeAt(++state.position);
2069
+ }
2070
+ directiveArgs.push(state.input.slice(_position, state.position));
2071
+ }
2072
+ if (ch !== 0) readLineBreak(state);
2073
+ if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
2074
+ directiveHandlers[directiveName](state, directiveName, directiveArgs);
2075
+ } else {
2076
+ throwWarning(state, 'unknown document directive "' + directiveName + '"');
2077
+ }
2078
+ }
2079
+ skipSeparationSpace(state, true, -1);
2080
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
2081
+ state.position += 3;
2082
+ skipSeparationSpace(state, true, -1);
2083
+ } else if (hasDirectives) {
2084
+ throwError(state, "directives end mark is expected");
2085
+ }
2086
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2087
+ skipSeparationSpace(state, true, -1);
2088
+ if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
2089
+ throwWarning(state, "non-ASCII line breaks are interpreted as content");
2090
+ }
2091
+ state.documents.push(state.result);
2092
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
2093
+ if (state.input.charCodeAt(state.position) === 46) {
2094
+ state.position += 3;
2095
+ skipSeparationSpace(state, true, -1);
2096
+ }
2097
+ return;
2098
+ }
2099
+ if (state.position < state.length - 1) {
2100
+ throwError(state, "end of the stream or a document separator is expected");
2101
+ } else {
2102
+ return;
2103
+ }
2104
+ }
2105
+ function loadDocuments(input, options) {
2106
+ input = String(input);
2107
+ options = options || {};
2108
+ if (input.length !== 0) {
2109
+ if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
2110
+ input += "\n";
2111
+ }
2112
+ if (input.charCodeAt(0) === 65279) {
2113
+ input = input.slice(1);
2114
+ }
2115
+ }
2116
+ var state = new State(input, options);
2117
+ var nullpos = input.indexOf("\0");
2118
+ if (nullpos !== -1) {
2119
+ state.position = nullpos;
2120
+ throwError(state, "null byte is not allowed in input");
2121
+ }
2122
+ state.input += "\0";
2123
+ while (state.input.charCodeAt(state.position) === 32) {
2124
+ state.lineIndent += 1;
2125
+ state.position += 1;
2126
+ }
2127
+ while (state.position < state.length - 1) {
2128
+ readDocument(state);
2129
+ }
2130
+ return state.documents;
2131
+ }
2132
+ function loadAll(input, iterator, options) {
2133
+ if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
2134
+ options = iterator;
2135
+ iterator = null;
2136
+ }
2137
+ var documents = loadDocuments(input, options);
2138
+ if (typeof iterator !== "function") {
2139
+ return documents;
2140
+ }
2141
+ for (var index = 0, length = documents.length; index < length; index += 1) {
2142
+ iterator(documents[index]);
2143
+ }
2144
+ }
2145
+ function load(input, options) {
2146
+ var documents = loadDocuments(input, options);
2147
+ if (documents.length === 0) {
2148
+ return void 0;
2149
+ } else if (documents.length === 1) {
2150
+ return documents[0];
2151
+ }
2152
+ throw new YAMLException("expected a single document in the stream, but found more");
2153
+ }
2154
+ module2.exports.loadAll = loadAll;
2155
+ module2.exports.load = load;
2156
+ }
2157
+ });
2158
+
2159
+ // ../common/node_modules/js-yaml/lib/dumper.js
2160
+ var require_dumper = __commonJS({
2161
+ "../common/node_modules/js-yaml/lib/dumper.js"(exports2, module2) {
2162
+ "use strict";
2163
+ var common = require_common();
2164
+ var YAMLException = require_exception();
2165
+ var DEFAULT_SCHEMA = require_default();
2166
+ var _toString = Object.prototype.toString;
2167
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
2168
+ var CHAR_BOM = 65279;
2169
+ var CHAR_TAB = 9;
2170
+ var CHAR_LINE_FEED = 10;
2171
+ var CHAR_CARRIAGE_RETURN = 13;
2172
+ var CHAR_SPACE = 32;
2173
+ var CHAR_EXCLAMATION = 33;
2174
+ var CHAR_DOUBLE_QUOTE = 34;
2175
+ var CHAR_SHARP = 35;
2176
+ var CHAR_PERCENT = 37;
2177
+ var CHAR_AMPERSAND = 38;
2178
+ var CHAR_SINGLE_QUOTE = 39;
2179
+ var CHAR_ASTERISK = 42;
2180
+ var CHAR_COMMA = 44;
2181
+ var CHAR_MINUS = 45;
2182
+ var CHAR_COLON = 58;
2183
+ var CHAR_EQUALS = 61;
2184
+ var CHAR_GREATER_THAN = 62;
2185
+ var CHAR_QUESTION = 63;
2186
+ var CHAR_COMMERCIAL_AT = 64;
2187
+ var CHAR_LEFT_SQUARE_BRACKET = 91;
2188
+ var CHAR_RIGHT_SQUARE_BRACKET = 93;
2189
+ var CHAR_GRAVE_ACCENT = 96;
2190
+ var CHAR_LEFT_CURLY_BRACKET = 123;
2191
+ var CHAR_VERTICAL_LINE = 124;
2192
+ var CHAR_RIGHT_CURLY_BRACKET = 125;
2193
+ var ESCAPE_SEQUENCES = {};
2194
+ ESCAPE_SEQUENCES[0] = "\\0";
2195
+ ESCAPE_SEQUENCES[7] = "\\a";
2196
+ ESCAPE_SEQUENCES[8] = "\\b";
2197
+ ESCAPE_SEQUENCES[9] = "\\t";
2198
+ ESCAPE_SEQUENCES[10] = "\\n";
2199
+ ESCAPE_SEQUENCES[11] = "\\v";
2200
+ ESCAPE_SEQUENCES[12] = "\\f";
2201
+ ESCAPE_SEQUENCES[13] = "\\r";
2202
+ ESCAPE_SEQUENCES[27] = "\\e";
2203
+ ESCAPE_SEQUENCES[34] = '\\"';
2204
+ ESCAPE_SEQUENCES[92] = "\\\\";
2205
+ ESCAPE_SEQUENCES[133] = "\\N";
2206
+ ESCAPE_SEQUENCES[160] = "\\_";
2207
+ ESCAPE_SEQUENCES[8232] = "\\L";
2208
+ ESCAPE_SEQUENCES[8233] = "\\P";
2209
+ var DEPRECATED_BOOLEANS_SYNTAX = [
2210
+ "y",
2211
+ "Y",
2212
+ "yes",
2213
+ "Yes",
2214
+ "YES",
2215
+ "on",
2216
+ "On",
2217
+ "ON",
2218
+ "n",
2219
+ "N",
2220
+ "no",
2221
+ "No",
2222
+ "NO",
2223
+ "off",
2224
+ "Off",
2225
+ "OFF"
2226
+ ];
2227
+ var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
2228
+ function compileStyleMap(schema, map) {
2229
+ var result, keys, index, length, tag, style, type;
2230
+ if (map === null) return {};
2231
+ result = {};
2232
+ keys = Object.keys(map);
2233
+ for (index = 0, length = keys.length; index < length; index += 1) {
2234
+ tag = keys[index];
2235
+ style = String(map[tag]);
2236
+ if (tag.slice(0, 2) === "!!") {
2237
+ tag = "tag:yaml.org,2002:" + tag.slice(2);
2238
+ }
2239
+ type = schema.compiledTypeMap["fallback"][tag];
2240
+ if (type && _hasOwnProperty.call(type.styleAliases, style)) {
2241
+ style = type.styleAliases[style];
2242
+ }
2243
+ result[tag] = style;
2244
+ }
2245
+ return result;
2246
+ }
2247
+ function encodeHex(character) {
2248
+ var string, handle, length;
2249
+ string = character.toString(16).toUpperCase();
2250
+ if (character <= 255) {
2251
+ handle = "x";
2252
+ length = 2;
2253
+ } else if (character <= 65535) {
2254
+ handle = "u";
2255
+ length = 4;
2256
+ } else if (character <= 4294967295) {
2257
+ handle = "U";
2258
+ length = 8;
2259
+ } else {
2260
+ throw new YAMLException("code point within a string may not be greater than 0xFFFFFFFF");
2261
+ }
2262
+ return "\\" + handle + common.repeat("0", length - string.length) + string;
2263
+ }
2264
+ var QUOTING_TYPE_SINGLE = 1;
2265
+ var QUOTING_TYPE_DOUBLE = 2;
2266
+ function State(options) {
2267
+ this.schema = options["schema"] || DEFAULT_SCHEMA;
2268
+ this.indent = Math.max(1, options["indent"] || 2);
2269
+ this.noArrayIndent = options["noArrayIndent"] || false;
2270
+ this.skipInvalid = options["skipInvalid"] || false;
2271
+ this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
2272
+ this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
2273
+ this.sortKeys = options["sortKeys"] || false;
2274
+ this.lineWidth = options["lineWidth"] || 80;
2275
+ this.noRefs = options["noRefs"] || false;
2276
+ this.noCompatMode = options["noCompatMode"] || false;
2277
+ this.condenseFlow = options["condenseFlow"] || false;
2278
+ this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
2279
+ this.forceQuotes = options["forceQuotes"] || false;
2280
+ this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
2281
+ this.implicitTypes = this.schema.compiledImplicit;
2282
+ this.explicitTypes = this.schema.compiledExplicit;
2283
+ this.tag = null;
2284
+ this.result = "";
2285
+ this.duplicates = [];
2286
+ this.usedDuplicates = null;
2287
+ }
2288
+ function indentString(string, spaces) {
2289
+ var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
2290
+ while (position < length) {
2291
+ next = string.indexOf("\n", position);
2292
+ if (next === -1) {
2293
+ line = string.slice(position);
2294
+ position = length;
2295
+ } else {
2296
+ line = string.slice(position, next + 1);
2297
+ position = next + 1;
2298
+ }
2299
+ if (line.length && line !== "\n") result += ind;
2300
+ result += line;
2301
+ }
2302
+ return result;
2303
+ }
2304
+ function generateNextLine(state, level) {
2305
+ return "\n" + common.repeat(" ", state.indent * level);
2306
+ }
2307
+ function testImplicitResolving(state, str) {
2308
+ var index, length, type;
2309
+ for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
2310
+ type = state.implicitTypes[index];
2311
+ if (type.resolve(str)) {
2312
+ return true;
2313
+ }
2314
+ }
2315
+ return false;
2316
+ }
2317
+ function isWhitespace(c) {
2318
+ return c === CHAR_SPACE || c === CHAR_TAB;
2319
+ }
2320
+ function isPrintable(c) {
2321
+ return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
2322
+ }
2323
+ function isNsCharOrWhitespace(c) {
2324
+ return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
2325
+ }
2326
+ function isPlainSafe(c, prev, inblock) {
2327
+ var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
2328
+ var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
2329
+ return (
2330
+ // ns-plain-safe
2331
+ (inblock ? (
2332
+ // c = flow-in
2333
+ cIsNsCharOrWhitespace
2334
+ ) : 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
2335
+ );
2336
+ }
2337
+ function isPlainSafeFirst(c) {
2338
+ 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;
2339
+ }
2340
+ function isPlainSafeLast(c) {
2341
+ return !isWhitespace(c) && c !== CHAR_COLON;
2342
+ }
2343
+ function codePointAt(string, pos) {
2344
+ var first = string.charCodeAt(pos), second;
2345
+ if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
2346
+ second = string.charCodeAt(pos + 1);
2347
+ if (second >= 56320 && second <= 57343) {
2348
+ return (first - 55296) * 1024 + second - 56320 + 65536;
2349
+ }
2350
+ }
2351
+ return first;
2352
+ }
2353
+ function needIndentIndicator(string) {
2354
+ var leadingSpaceRe = /^\n* /;
2355
+ return leadingSpaceRe.test(string);
2356
+ }
2357
+ var STYLE_PLAIN = 1;
2358
+ var STYLE_SINGLE = 2;
2359
+ var STYLE_LITERAL = 3;
2360
+ var STYLE_FOLDED = 4;
2361
+ var STYLE_DOUBLE = 5;
2362
+ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
2363
+ var i;
2364
+ var char = 0;
2365
+ var prevChar = null;
2366
+ var hasLineBreak = false;
2367
+ var hasFoldableLine = false;
2368
+ var shouldTrackWidth = lineWidth !== -1;
2369
+ var previousLineBreak = -1;
2370
+ var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
2371
+ if (singleLineOnly || forceQuotes) {
2372
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2373
+ char = codePointAt(string, i);
2374
+ if (!isPrintable(char)) {
2375
+ return STYLE_DOUBLE;
2376
+ }
2377
+ plain = plain && isPlainSafe(char, prevChar, inblock);
2378
+ prevChar = char;
2379
+ }
2380
+ } else {
2381
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2382
+ char = codePointAt(string, i);
2383
+ if (char === CHAR_LINE_FEED) {
2384
+ hasLineBreak = true;
2385
+ if (shouldTrackWidth) {
2386
+ hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
2387
+ i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
2388
+ previousLineBreak = i;
2389
+ }
2390
+ } else if (!isPrintable(char)) {
2391
+ return STYLE_DOUBLE;
2392
+ }
2393
+ plain = plain && isPlainSafe(char, prevChar, inblock);
2394
+ prevChar = char;
2395
+ }
2396
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
2397
+ }
2398
+ if (!hasLineBreak && !hasFoldableLine) {
2399
+ if (plain && !forceQuotes && !testAmbiguousType(string)) {
2400
+ return STYLE_PLAIN;
2401
+ }
2402
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2403
+ }
2404
+ if (indentPerLevel > 9 && needIndentIndicator(string)) {
2405
+ return STYLE_DOUBLE;
2406
+ }
2407
+ if (!forceQuotes) {
2408
+ return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
2409
+ }
2410
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2411
+ }
2412
+ function writeScalar(state, string, level, iskey, inblock) {
2413
+ state.dump = (function() {
2414
+ if (string.length === 0) {
2415
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
2416
+ }
2417
+ if (!state.noCompatMode) {
2418
+ if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
2419
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
2420
+ }
2421
+ }
2422
+ var indent = state.indent * Math.max(1, level);
2423
+ var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
2424
+ var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
2425
+ function testAmbiguity(string2) {
2426
+ return testImplicitResolving(state, string2);
2427
+ }
2428
+ switch (chooseScalarStyle(
2429
+ string,
2430
+ singleLineOnly,
2431
+ state.indent,
2432
+ lineWidth,
2433
+ testAmbiguity,
2434
+ state.quotingType,
2435
+ state.forceQuotes && !iskey,
2436
+ inblock
2437
+ )) {
2438
+ case STYLE_PLAIN:
2439
+ return string;
2440
+ case STYLE_SINGLE:
2441
+ return "'" + string.replace(/'/g, "''") + "'";
2442
+ case STYLE_LITERAL:
2443
+ return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
2444
+ case STYLE_FOLDED:
2445
+ return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
2446
+ case STYLE_DOUBLE:
2447
+ return '"' + escapeString(string, lineWidth) + '"';
2448
+ default:
2449
+ throw new YAMLException("impossible error: invalid scalar style");
2450
+ }
2451
+ })();
2452
+ }
2453
+ function blockHeader(string, indentPerLevel) {
2454
+ var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
2455
+ var clip = string[string.length - 1] === "\n";
2456
+ var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
2457
+ var chomp = keep ? "+" : clip ? "" : "-";
2458
+ return indentIndicator + chomp + "\n";
2459
+ }
2460
+ function dropEndingNewline(string) {
2461
+ return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
2462
+ }
2463
+ function foldString(string, width) {
2464
+ var lineRe = /(\n+)([^\n]*)/g;
2465
+ var result = (function() {
2466
+ var nextLF = string.indexOf("\n");
2467
+ nextLF = nextLF !== -1 ? nextLF : string.length;
2468
+ lineRe.lastIndex = nextLF;
2469
+ return foldLine(string.slice(0, nextLF), width);
2470
+ })();
2471
+ var prevMoreIndented = string[0] === "\n" || string[0] === " ";
2472
+ var moreIndented;
2473
+ var match;
2474
+ while (match = lineRe.exec(string)) {
2475
+ var prefix = match[1], line = match[2];
2476
+ moreIndented = line[0] === " ";
2477
+ result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
2478
+ prevMoreIndented = moreIndented;
2479
+ }
2480
+ return result;
2481
+ }
2482
+ function foldLine(line, width) {
2483
+ if (line === "" || line[0] === " ") return line;
2484
+ var breakRe = / [^ ]/g;
2485
+ var match;
2486
+ var start = 0, end, curr = 0, next = 0;
2487
+ var result = "";
2488
+ while (match = breakRe.exec(line)) {
2489
+ next = match.index;
2490
+ if (next - start > width) {
2491
+ end = curr > start ? curr : next;
2492
+ result += "\n" + line.slice(start, end);
2493
+ start = end + 1;
2494
+ }
2495
+ curr = next;
2496
+ }
2497
+ result += "\n";
2498
+ if (line.length - start > width && curr > start) {
2499
+ result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
2500
+ } else {
2501
+ result += line.slice(start);
2502
+ }
2503
+ return result.slice(1);
2504
+ }
2505
+ function escapeString(string) {
2506
+ var result = "";
2507
+ var char = 0;
2508
+ var escapeSeq;
2509
+ for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2510
+ char = codePointAt(string, i);
2511
+ escapeSeq = ESCAPE_SEQUENCES[char];
2512
+ if (!escapeSeq && isPrintable(char)) {
2513
+ result += string[i];
2514
+ if (char >= 65536) result += string[i + 1];
2515
+ } else {
2516
+ result += escapeSeq || encodeHex(char);
2517
+ }
2518
+ }
2519
+ return result;
2520
+ }
2521
+ function writeFlowSequence(state, level, object) {
2522
+ var _result = "", _tag = state.tag, index, length, value;
2523
+ for (index = 0, length = object.length; index < length; index += 1) {
2524
+ value = object[index];
2525
+ if (state.replacer) {
2526
+ value = state.replacer.call(object, String(index), value);
2527
+ }
2528
+ if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
2529
+ if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
2530
+ _result += state.dump;
2531
+ }
2532
+ }
2533
+ state.tag = _tag;
2534
+ state.dump = "[" + _result + "]";
2535
+ }
2536
+ function writeBlockSequence(state, level, object, compact) {
2537
+ var _result = "", _tag = state.tag, index, length, value;
2538
+ for (index = 0, length = object.length; index < length; index += 1) {
2539
+ value = object[index];
2540
+ if (state.replacer) {
2541
+ value = state.replacer.call(object, String(index), value);
2542
+ }
2543
+ if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
2544
+ if (!compact || _result !== "") {
2545
+ _result += generateNextLine(state, level);
2546
+ }
2547
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2548
+ _result += "-";
2549
+ } else {
2550
+ _result += "- ";
2551
+ }
2552
+ _result += state.dump;
2553
+ }
2554
+ }
2555
+ state.tag = _tag;
2556
+ state.dump = _result || "[]";
2557
+ }
2558
+ function writeFlowMapping(state, level, object) {
2559
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
2560
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2561
+ pairBuffer = "";
2562
+ if (_result !== "") pairBuffer += ", ";
2563
+ if (state.condenseFlow) pairBuffer += '"';
2564
+ objectKey = objectKeyList[index];
2565
+ objectValue = object[objectKey];
2566
+ if (state.replacer) {
2567
+ objectValue = state.replacer.call(object, objectKey, objectValue);
2568
+ }
2569
+ if (!writeNode(state, level, objectKey, false, false)) {
2570
+ continue;
2571
+ }
2572
+ if (state.dump.length > 1024) pairBuffer += "? ";
2573
+ pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
2574
+ if (!writeNode(state, level, objectValue, false, false)) {
2575
+ continue;
2576
+ }
2577
+ pairBuffer += state.dump;
2578
+ _result += pairBuffer;
2579
+ }
2580
+ state.tag = _tag;
2581
+ state.dump = "{" + _result + "}";
2582
+ }
2583
+ function writeBlockMapping(state, level, object, compact) {
2584
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
2585
+ if (state.sortKeys === true) {
2586
+ objectKeyList.sort();
2587
+ } else if (typeof state.sortKeys === "function") {
2588
+ objectKeyList.sort(state.sortKeys);
2589
+ } else if (state.sortKeys) {
2590
+ throw new YAMLException("sortKeys must be a boolean or a function");
2591
+ }
2592
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2593
+ pairBuffer = "";
2594
+ if (!compact || _result !== "") {
2595
+ pairBuffer += generateNextLine(state, level);
2596
+ }
2597
+ objectKey = objectKeyList[index];
2598
+ objectValue = object[objectKey];
2599
+ if (state.replacer) {
2600
+ objectValue = state.replacer.call(object, objectKey, objectValue);
2601
+ }
2602
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) {
2603
+ continue;
2604
+ }
2605
+ explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
2606
+ if (explicitPair) {
2607
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2608
+ pairBuffer += "?";
2609
+ } else {
2610
+ pairBuffer += "? ";
2611
+ }
2612
+ }
2613
+ pairBuffer += state.dump;
2614
+ if (explicitPair) {
2615
+ pairBuffer += generateNextLine(state, level);
2616
+ }
2617
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
2618
+ continue;
2619
+ }
2620
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2621
+ pairBuffer += ":";
2622
+ } else {
2623
+ pairBuffer += ": ";
2624
+ }
2625
+ pairBuffer += state.dump;
2626
+ _result += pairBuffer;
2627
+ }
2628
+ state.tag = _tag;
2629
+ state.dump = _result || "{}";
2630
+ }
2631
+ function detectType(state, object, explicit) {
2632
+ var _result, typeList, index, length, type, style;
2633
+ typeList = explicit ? state.explicitTypes : state.implicitTypes;
2634
+ for (index = 0, length = typeList.length; index < length; index += 1) {
2635
+ type = typeList[index];
2636
+ if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
2637
+ if (explicit) {
2638
+ if (type.multi && type.representName) {
2639
+ state.tag = type.representName(object);
2640
+ } else {
2641
+ state.tag = type.tag;
2642
+ }
2643
+ } else {
2644
+ state.tag = "?";
2645
+ }
2646
+ if (type.represent) {
2647
+ style = state.styleMap[type.tag] || type.defaultStyle;
2648
+ if (_toString.call(type.represent) === "[object Function]") {
2649
+ _result = type.represent(object, style);
2650
+ } else if (_hasOwnProperty.call(type.represent, style)) {
2651
+ _result = type.represent[style](object, style);
2652
+ } else {
2653
+ throw new YAMLException("!<" + type.tag + '> tag resolver accepts not "' + style + '" style');
2654
+ }
2655
+ state.dump = _result;
2656
+ }
2657
+ return true;
2658
+ }
2659
+ }
2660
+ return false;
2661
+ }
2662
+ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
2663
+ state.tag = null;
2664
+ state.dump = object;
2665
+ if (!detectType(state, object, false)) {
2666
+ detectType(state, object, true);
2667
+ }
2668
+ var type = _toString.call(state.dump);
2669
+ var inblock = block;
2670
+ var tagStr;
2671
+ if (block) {
2672
+ block = state.flowLevel < 0 || state.flowLevel > level;
2673
+ }
2674
+ var objectOrArray = type === "[object Object]" || type === "[object Array]", duplicateIndex, duplicate;
2675
+ if (objectOrArray) {
2676
+ duplicateIndex = state.duplicates.indexOf(object);
2677
+ duplicate = duplicateIndex !== -1;
2678
+ }
2679
+ if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
2680
+ compact = false;
2681
+ }
2682
+ if (duplicate && state.usedDuplicates[duplicateIndex]) {
2683
+ state.dump = "*ref_" + duplicateIndex;
2684
+ } else {
2685
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
2686
+ state.usedDuplicates[duplicateIndex] = true;
2687
+ }
2688
+ if (type === "[object Object]") {
2689
+ if (block && Object.keys(state.dump).length !== 0) {
2690
+ writeBlockMapping(state, level, state.dump, compact);
2691
+ if (duplicate) {
2692
+ state.dump = "&ref_" + duplicateIndex + state.dump;
2693
+ }
2694
+ } else {
2695
+ writeFlowMapping(state, level, state.dump);
2696
+ if (duplicate) {
2697
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2698
+ }
2699
+ }
2700
+ } else if (type === "[object Array]") {
2701
+ if (block && state.dump.length !== 0) {
2702
+ if (state.noArrayIndent && !isblockseq && level > 0) {
2703
+ writeBlockSequence(state, level - 1, state.dump, compact);
2704
+ } else {
2705
+ writeBlockSequence(state, level, state.dump, compact);
2706
+ }
2707
+ if (duplicate) {
2708
+ state.dump = "&ref_" + duplicateIndex + state.dump;
2709
+ }
2710
+ } else {
2711
+ writeFlowSequence(state, level, state.dump);
2712
+ if (duplicate) {
2713
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2714
+ }
2715
+ }
2716
+ } else if (type === "[object String]") {
2717
+ if (state.tag !== "?") {
2718
+ writeScalar(state, state.dump, level, iskey, inblock);
2719
+ }
2720
+ } else if (type === "[object Undefined]") {
2721
+ return false;
2722
+ } else {
2723
+ if (state.skipInvalid) return false;
2724
+ throw new YAMLException("unacceptable kind of an object to dump " + type);
2725
+ }
2726
+ if (state.tag !== null && state.tag !== "?") {
2727
+ tagStr = encodeURI(
2728
+ state.tag[0] === "!" ? state.tag.slice(1) : state.tag
2729
+ ).replace(/!/g, "%21");
2730
+ if (state.tag[0] === "!") {
2731
+ tagStr = "!" + tagStr;
2732
+ } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
2733
+ tagStr = "!!" + tagStr.slice(18);
2734
+ } else {
2735
+ tagStr = "!<" + tagStr + ">";
2736
+ }
2737
+ state.dump = tagStr + " " + state.dump;
2738
+ }
2739
+ }
2740
+ return true;
2741
+ }
2742
+ function getDuplicateReferences(object, state) {
2743
+ var objects = [], duplicatesIndexes = [], index, length;
2744
+ inspectNode(object, objects, duplicatesIndexes);
2745
+ for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
2746
+ state.duplicates.push(objects[duplicatesIndexes[index]]);
2747
+ }
2748
+ state.usedDuplicates = new Array(length);
2749
+ }
2750
+ function inspectNode(object, objects, duplicatesIndexes) {
2751
+ var objectKeyList, index, length;
2752
+ if (object !== null && typeof object === "object") {
2753
+ index = objects.indexOf(object);
2754
+ if (index !== -1) {
2755
+ if (duplicatesIndexes.indexOf(index) === -1) {
2756
+ duplicatesIndexes.push(index);
2757
+ }
2758
+ } else {
2759
+ objects.push(object);
2760
+ if (Array.isArray(object)) {
2761
+ for (index = 0, length = object.length; index < length; index += 1) {
2762
+ inspectNode(object[index], objects, duplicatesIndexes);
2763
+ }
2764
+ } else {
2765
+ objectKeyList = Object.keys(object);
2766
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2767
+ inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
2768
+ }
2769
+ }
2770
+ }
2771
+ }
2772
+ }
2773
+ function dump(input, options) {
2774
+ options = options || {};
2775
+ var state = new State(options);
2776
+ if (!state.noRefs) getDuplicateReferences(input, state);
2777
+ var value = input;
2778
+ if (state.replacer) {
2779
+ value = state.replacer.call({ "": value }, "", value);
2780
+ }
2781
+ if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
2782
+ return "";
2783
+ }
2784
+ module2.exports.dump = dump;
2785
+ }
2786
+ });
2787
+
2788
+ // ../common/node_modules/js-yaml/index.js
2789
+ var require_js_yaml = __commonJS({
2790
+ "../common/node_modules/js-yaml/index.js"(exports2, module2) {
2791
+ "use strict";
2792
+ var loader = require_loader();
2793
+ var dumper = require_dumper();
2794
+ function renamed(from, to) {
2795
+ return function() {
2796
+ throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
2797
+ };
2798
+ }
2799
+ module2.exports.Type = require_type();
2800
+ module2.exports.Schema = require_schema();
2801
+ module2.exports.FAILSAFE_SCHEMA = require_failsafe();
2802
+ module2.exports.JSON_SCHEMA = require_json();
2803
+ module2.exports.CORE_SCHEMA = require_core();
2804
+ module2.exports.DEFAULT_SCHEMA = require_default();
2805
+ module2.exports.load = loader.load;
2806
+ module2.exports.loadAll = loader.loadAll;
2807
+ module2.exports.dump = dumper.dump;
2808
+ module2.exports.YAMLException = require_exception();
2809
+ module2.exports.types = {
2810
+ binary: require_binary(),
2811
+ float: require_float(),
2812
+ map: require_map(),
2813
+ null: require_null(),
2814
+ pairs: require_pairs(),
2815
+ set: require_set(),
2816
+ timestamp: require_timestamp(),
2817
+ bool: require_bool(),
2818
+ int: require_int(),
2819
+ merge: require_merge(),
2820
+ omap: require_omap(),
2821
+ seq: require_seq(),
2822
+ str: require_str()
2823
+ };
2824
+ module2.exports.safeLoad = renamed("safeLoad", "load");
2825
+ module2.exports.safeLoadAll = renamed("safeLoadAll", "loadAll");
2826
+ module2.exports.safeDump = renamed("safeDump", "dump");
2827
+ }
2828
+ });
2829
+
2830
+ // ../common/dist/utils/deva11yConfig.v1.js
2831
+ var require_deva11yConfig_v1 = __commonJS({
2832
+ "../common/dist/utils/deva11yConfig.v1.js"(exports2) {
2833
+ "use strict";
2834
+ Object.defineProperty(exports2, "__esModule", { value: true });
2835
+ exports2.normalizeV1ConfigFromRaw = normalizeV1ConfigFromRaw;
2836
+ async function normalizeV1ConfigFromRaw(rawConfig, sourcePath) {
2837
+ const raw = rawConfig;
2838
+ if (raw == null || typeof raw !== "object") {
2839
+ throw new Error(`DevA11y config at ${sourcePath} must be an object`);
2840
+ }
2841
+ if (raw.version !== 1) {
2842
+ throw new Error(`Unsupported DevA11y config version at ${sourcePath}: ${String(raw.version)}. Only version 1 is supported.`);
2843
+ }
2844
+ validateV1RawConfig(raw, sourcePath);
2845
+ return normalizeV1Config(raw);
2846
+ }
2847
+ function validateV1RawConfig(raw, sourcePath) {
2848
+ const allowedTopLevelKeys = /* @__PURE__ */ new Set(["version", "$schema", "components"]);
2849
+ for (const key of Object.keys(raw)) {
2850
+ if (!allowedTopLevelKeys.has(key)) {
2851
+ throw new Error(`Unknown top-level key "${key}" in DevA11y config at ${sourcePath}`);
2852
+ }
2853
+ }
2854
+ if (raw.components && typeof raw.components !== "object") {
2855
+ throw new Error(`DevA11y config "components" must be an object at ${sourcePath}`);
2856
+ }
2857
+ if (raw.components) {
2858
+ validateComponents(raw.components, sourcePath);
2859
+ }
2860
+ }
2861
+ function normalizeV1Config(raw) {
2862
+ const components = raw.components ?? {};
2863
+ return {
2864
+ version: 1,
2865
+ $schema: raw.$schema,
2866
+ components
2867
+ };
2868
+ }
2869
+ function validateComponents(components, sourcePath) {
2870
+ for (const [framework, frameworkComponents] of Object.entries(components)) {
2871
+ if (!framework || framework !== "react") {
2872
+ throw new Error(`Invalid framework key in "components" at ${sourcePath}`);
2873
+ }
2874
+ if (typeof frameworkComponents !== "object" || frameworkComponents === null) {
2875
+ throw new Error(`Framework "${framework}" in "components" must be an object in DevA11y config at ${sourcePath}`);
2876
+ }
2877
+ for (const [componentName, mapping] of Object.entries(frameworkComponents)) {
2878
+ if (!componentName || typeof componentName !== "string") {
2879
+ throw new Error(`Invalid component name in "components.${framework}" at ${sourcePath}`);
2880
+ }
2881
+ if (typeof mapping === "string") {
2882
+ continue;
2883
+ }
2884
+ if (typeof mapping !== "object" || mapping === null) {
2885
+ throw new Error(`Component "${componentName}" in "components.${framework}" must be an object at ${sourcePath}`);
2886
+ }
2887
+ const allowedKeys = /* @__PURE__ */ new Set(["element", "attributes"]);
2888
+ for (const key of Object.keys(mapping)) {
2889
+ if (!allowedKeys.has(key)) {
2890
+ throw new Error(`Unknown key "${key}" in "components.${framework}.${componentName}" at ${sourcePath}`);
2891
+ }
2892
+ }
2893
+ if ("element" in mapping && typeof mapping.element !== "string") {
2894
+ throw new Error(`"components.${framework}.${componentName}.element" must be a string at ${sourcePath}`);
2895
+ }
2896
+ if ("attributes" in mapping) {
2897
+ if (!Array.isArray(mapping.attributes)) {
2898
+ throw new Error(`"components.${framework}.${componentName}.attributes" must be an array at ${sourcePath}`);
2899
+ }
2900
+ for (const attr of mapping.attributes ?? []) {
2901
+ if (typeof attr === "string")
2902
+ continue;
2903
+ if (typeof attr !== "object" || attr === null) {
2904
+ throw new Error(`Invalid attribute spec in "components.${framework}.${componentName}.attributes" at ${sourcePath}`);
2905
+ }
2906
+ for (const [propName, token] of Object.entries(attr)) {
2907
+ if (!propName || typeof propName !== "string") {
2908
+ throw new Error(`Invalid prop name in attribute mapping for "components.${framework}.${componentName}" at ${sourcePath}`);
2909
+ }
2910
+ if (typeof token !== "string") {
2911
+ throw new Error(`Invalid attribute token for prop "${propName}" in "components.${framework}.${componentName}" at ${sourcePath}`);
2912
+ }
2913
+ }
2914
+ }
2915
+ }
2916
+ }
2917
+ }
2918
+ }
2919
+ }
2920
+ });
2921
+
2922
+ // ../common/dist/utils/deva11yConfig.js
2923
+ var require_deva11yConfig = __commonJS({
2924
+ "../common/dist/utils/deva11yConfig.js"(exports2) {
2925
+ "use strict";
2926
+ var __importDefault = exports2 && exports2.__importDefault || function(mod) {
2927
+ return mod && mod.__esModule ? mod : { "default": mod };
2928
+ };
2929
+ Object.defineProperty(exports2, "__esModule", { value: true });
2930
+ exports2.loadHomeConfig = loadHomeConfig;
2931
+ exports2.loadConfigFromFile = loadConfigFromFile2;
2932
+ exports2.loadConfigForPath = loadConfigForPath;
2933
+ var promises_1 = __importDefault(require("fs/promises"));
2934
+ var js_yaml_1 = require_js_yaml();
2935
+ var os_1 = __importDefault(require("os"));
2936
+ var path_1 = __importDefault(require("path"));
2937
+ var deva11yConfig_v1_1 = require_deva11yConfig_v1();
2938
+ var DEVA11Y_CONFIG_FILENAMES = [
2939
+ "accessibility-devtools.config.yaml",
2940
+ "accessibility-devtools.config.yml",
2941
+ "accessibility-devtools.config.json"
2942
+ ];
2943
+ async function loadHomeConfig() {
2944
+ const homeDir = os_1.default.homedir();
2945
+ for (const candidate of DEVA11Y_CONFIG_FILENAMES) {
2946
+ const fullPath = path_1.default.join(homeDir, candidate);
2947
+ try {
2948
+ const stat2 = await promises_1.default.stat(fullPath);
2949
+ if (!stat2.isFile())
2950
+ continue;
2951
+ return loadConfigFromFile2(fullPath);
2952
+ } catch {
2953
+ }
2954
+ }
2955
+ return null;
2956
+ }
2957
+ async function loadConfigFromFile2(configPath) {
2958
+ const absPath = path_1.default.resolve(configPath);
2959
+ return loadConfigFromFileInternal(absPath);
2960
+ }
2961
+ async function loadConfigForPath(sourceFile, workspaceRoot) {
2962
+ const absFile = path_1.default.resolve(sourceFile);
2963
+ let currentDir = path_1.default.dirname(absFile);
2964
+ const rootDir = workspaceRoot ? path_1.default.resolve(workspaceRoot) : path_1.default.parse(currentDir).root;
2965
+ while (true) {
2966
+ for (const candidate of DEVA11Y_CONFIG_FILENAMES) {
2967
+ const candidatePath = path_1.default.join(currentDir, candidate);
2968
+ try {
2969
+ const stat2 = await promises_1.default.stat(candidatePath);
2970
+ if (stat2.isFile()) {
2971
+ return loadConfigFromFile2(candidatePath);
2972
+ }
2973
+ } catch {
2974
+ }
2975
+ }
2976
+ if (currentDir === rootDir) {
2977
+ break;
2978
+ }
2979
+ const parent = path_1.default.dirname(currentDir);
2980
+ if (parent === currentDir) {
2981
+ break;
2982
+ }
2983
+ currentDir = parent;
2984
+ }
2985
+ return null;
2986
+ }
2987
+ async function loadConfigFromFileInternal(absPath) {
2988
+ const raw = await parseConfigFile(absPath);
2989
+ const version = raw?.version;
2990
+ switch (version) {
2991
+ case 1: {
2992
+ return (0, deva11yConfig_v1_1.normalizeV1ConfigFromRaw)(raw, absPath);
2993
+ }
2994
+ default:
2995
+ throw new Error(`Unsupported DevA11y config version at ${absPath}: ${String(version)}. Only version 1 is supported.`);
2996
+ }
2997
+ }
2998
+ async function parseConfigFile(filePath) {
2999
+ const content = await promises_1.default.readFile(filePath, "utf8");
3000
+ const ext = path_1.default.extname(filePath).toLowerCase();
3001
+ if (ext === ".json") {
3002
+ return JSON.parse(content);
3003
+ }
3004
+ if (ext === ".yaml" || ext === ".yml") {
3005
+ return (0, js_yaml_1.load)(content);
3006
+ }
3007
+ throw new Error(`Unsupported DevA11y config extension for ${filePath}. Expected .json, .yaml, or .yml.`);
3008
+ }
3009
+ }
3010
+ });
3011
+
35
3012
  // ../node_modules/uuid/dist/cjs/max.js
36
3013
  var require_max = __commonJS({
37
3014
  "../node_modules/uuid/dist/cjs/max.js"(exports2) {
@@ -4437,6 +7414,7 @@ var require_linterClient = __commonJS({
4437
7414
  };
4438
7415
  Object.defineProperty(exports2, "__esModule", { value: true });
4439
7416
  var events_1 = __importDefault(require("events"));
7417
+ var node_buffer_1 = require("node:buffer");
4440
7418
  var path_1 = __importDefault(require("path"));
4441
7419
  var ws_1 = __importDefault(require_ws());
4442
7420
  var LinterClient2 = class _LinterClient extends events_1.default {
@@ -4446,6 +7424,8 @@ var require_linterClient = __commonJS({
4446
7424
  this.disposables = [];
4447
7425
  this.responseMap = /* @__PURE__ */ new Map();
4448
7426
  this.supportedFileExtensions = [];
7427
+ this.authorizationHeader = null;
7428
+ this.lastKnownUserProfile = null;
4449
7429
  this.linterServerAddress = linterServerAddress;
4450
7430
  this.userLogger = userLogger;
4451
7431
  this.internalLogger = internalLogger;
@@ -4467,20 +7447,56 @@ var require_linterClient = __commonJS({
4467
7447
  get isInitialized() {
4468
7448
  return this.socket !== null && this.socket.readyState === ws_1.default.OPEN;
4469
7449
  }
4470
- retryConnection() {
7450
+ async retryConnection() {
7451
+ if (!this.authorizationHeader) {
7452
+ this.internalLogger.warn("Cannot retry BrowserStack connection without credentials");
7453
+ return;
7454
+ }
4471
7455
  if (!this.socket || this.socket.readyState === ws_1.default.CLOSED) {
4472
7456
  this.internalLogger.log("Retrying BrowserStack connection...");
4473
- this.initialize();
7457
+ try {
7458
+ await this.connectSocket();
7459
+ } catch (error) {
7460
+ const serialized = error instanceof Error ? error.message : String(error);
7461
+ this.internalLogger.error(`Error reconnecting to BrowserStack: ${serialized}`);
7462
+ setTimeout(() => this.retryConnection(), this.retryInterval);
7463
+ }
7464
+ }
7465
+ }
7466
+ isDisconnected() {
7467
+ return !this.socket || this.socket.readyState === ws_1.default.CLOSED;
7468
+ }
7469
+ errorIfDisconnected() {
7470
+ if (this.isDisconnected()) {
7471
+ throw new Error("WebSocket is disconnected");
4474
7472
  }
4475
7473
  }
4476
7474
  async initialize() {
4477
- this.socket = new ws_1.default(this.linterServerAddress);
7475
+ if (!this.authorizationHeader) {
7476
+ this.internalLogger.log("Delaying BrowserStack connection until credentials are provided");
7477
+ return;
7478
+ }
7479
+ return this.connectSocket();
7480
+ }
7481
+ async connectSocket() {
7482
+ if (!this.authorizationHeader) {
7483
+ throw new Error("Authorization header is not configured");
7484
+ }
7485
+ if (this.socket && (this.socket.readyState === ws_1.default.OPEN || this.socket.readyState === ws_1.default.CONNECTING)) {
7486
+ return;
7487
+ }
7488
+ this.socket = new ws_1.default(this.linterServerAddress, {
7489
+ autoPong: true,
7490
+ headers: {
7491
+ Authorization: this.authorizationHeader
7492
+ }
7493
+ });
4478
7494
  this.internalLogger.log(`Connecting to BrowserStack at ${this.linterServerAddress}`);
4479
7495
  this.socket.onclose = (e) => {
4480
7496
  this.emit("uninitialized");
4481
- this.userLogger.log(`BrowserStack connection ${e.wasClean ? "closed cleanly" : "failed"}`);
7497
+ this.userLogger.log(`BrowserStack connection ${e.wasClean ? "closed cleanly" : "failed"}; code=${e.code} reason=${e.reason}, e=${e}`);
4482
7498
  this._cleanup();
4483
- if (this.retry)
7499
+ if (this.retry && !e.wasClean)
4484
7500
  setTimeout(() => this.retryConnection(), this.retryInterval);
4485
7501
  };
4486
7502
  this.socket.onmessage = (event) => {
@@ -4506,10 +7522,11 @@ var require_linterClient = __commonJS({
4506
7522
  };
4507
7523
  return new Promise((resolve, reject) => {
4508
7524
  this.socket.onerror = (error) => {
4509
- this.emit("uninitialized");
7525
+ try {
7526
+ this.emit("error", error);
7527
+ } catch {
7528
+ }
4510
7529
  reject(error);
4511
- if (this.retry)
4512
- setTimeout(() => this.retryConnection(), this.retryInterval);
4513
7530
  };
4514
7531
  this.socket.onopen = () => {
4515
7532
  this.userLogger.log("BrowserStack connection established");
@@ -4527,11 +7544,11 @@ var require_linterClient = __commonJS({
4527
7544
  if (this.socket) {
4528
7545
  this.socket.close();
4529
7546
  this.socket = null;
4530
- } else {
4531
- this._cleanup();
4532
7547
  }
7548
+ this._cleanup();
4533
7549
  }
4534
7550
  async sendRequest(request) {
7551
+ this.errorIfDisconnected();
4535
7552
  return new Promise((resolve, reject) => {
4536
7553
  if (!this.socket || this.socket.readyState !== ws_1.default.OPEN) {
4537
7554
  reject(new Error("WebSocket is not connected"));
@@ -4549,16 +7566,41 @@ var require_linterClient = __commonJS({
4549
7566
  }
4550
7567
  // Actions
4551
7568
  async authenticate(username, token) {
7569
+ if (!username || !token) {
7570
+ throw new Error("Username and token are required for authentication");
7571
+ }
7572
+ this.authorizationHeader = "Basic " + node_buffer_1.Buffer.from(`${username}:${token}`).toString("base64");
7573
+ if (this.socket) {
7574
+ this.socket.close();
7575
+ this.socket = null;
7576
+ }
7577
+ await this.connectSocket();
7578
+ const profile = await this.fetchUserProfile();
7579
+ this.lastKnownUserProfile = profile;
7580
+ this.supportedFileExtensions = await this._getSupportedFileTypes();
7581
+ return profile;
7582
+ }
7583
+ async fetchUserProfile() {
7584
+ this.errorIfDisconnected();
4552
7585
  const result = await this.sendRequest({
4553
- type: "authenticate",
4554
- payload: { username, token }
7586
+ type: "get-user-profile",
7587
+ payload: {}
4555
7588
  });
4556
- if ("error" in result)
7589
+ if ("error" in result) {
4557
7590
  throw new Error(result.error);
4558
- this.supportedFileExtensions = await this._getSupportedFileTypes();
7591
+ }
4559
7592
  return result.payload.user;
4560
7593
  }
7594
+ async refreshUserProfile() {
7595
+ const profile = await this.fetchUserProfile();
7596
+ this.lastKnownUserProfile = profile;
7597
+ return profile;
7598
+ }
7599
+ getCachedUserProfile() {
7600
+ return this.lastKnownUserProfile;
7601
+ }
4561
7602
  async _getSupportedFileTypes() {
7603
+ this.errorIfDisconnected();
4562
7604
  const result = await this.sendRequest({
4563
7605
  type: "get-supported-file-types",
4564
7606
  payload: {}
@@ -4575,6 +7617,7 @@ var require_linterClient = __commonJS({
4575
7617
  return this.supportedFileExtensions.includes(extension);
4576
7618
  }
4577
7619
  async createFile(filePath, code) {
7620
+ this.errorIfDisconnected();
4578
7621
  const result = await this.sendRequest({
4579
7622
  type: "file-system-sync",
4580
7623
  payload: { filePath, code, action: "create" }
@@ -4584,6 +7627,7 @@ var require_linterClient = __commonJS({
4584
7627
  return result.statusCode === 200;
4585
7628
  }
4586
7629
  async updateFile(filePath, code) {
7630
+ this.errorIfDisconnected();
4587
7631
  const result = await this.sendRequest({
4588
7632
  type: "file-system-sync",
4589
7633
  payload: { filePath, code, action: "update" }
@@ -4593,6 +7637,7 @@ var require_linterClient = __commonJS({
4593
7637
  return result.statusCode === 200;
4594
7638
  }
4595
7639
  async deleteFile(filePath) {
7640
+ this.errorIfDisconnected();
4596
7641
  const result = await this.sendRequest({
4597
7642
  type: "file-system-sync",
4598
7643
  payload: { filePath, action: "delete" }
@@ -4602,6 +7647,7 @@ var require_linterClient = __commonJS({
4602
7647
  return result.statusCode === 200;
4603
7648
  }
4604
7649
  async lintText(filePath, code) {
7650
+ this.errorIfDisconnected();
4605
7651
  const result = await this.sendRequest({
4606
7652
  type: "lint-text",
4607
7653
  payload: { filePath, code }
@@ -4611,6 +7657,7 @@ var require_linterClient = __commonJS({
4611
7657
  return result.payload.results;
4612
7658
  }
4613
7659
  async lintFiles(filePath, code) {
7660
+ this.errorIfDisconnected();
4614
7661
  const result = await this.sendRequest({
4615
7662
  type: "lint-files",
4616
7663
  payload: { filePath, code }
@@ -4619,6 +7666,24 @@ var require_linterClient = __commonJS({
4619
7666
  throw new Error(result.error);
4620
7667
  return result.payload.results;
4621
7668
  }
7669
+ /**
7670
+ * Sends a fully-resolved DevA11y configuration to the linter server for a
7671
+ * given root path. The server is responsible for validating and storing the
7672
+ * config before applying it to subsequent lint requests.
7673
+ */
7674
+ async setConfig(rootPath, config) {
7675
+ this.errorIfDisconnected();
7676
+ const result = await this.sendRequest({
7677
+ type: "set-config",
7678
+ payload: {
7679
+ rootPath,
7680
+ config
7681
+ }
7682
+ });
7683
+ if ("error" in result) {
7684
+ throw new Error(result.error);
7685
+ }
7686
+ }
4622
7687
  };
4623
7688
  LinterClient2.instance = null;
4624
7689
  exports2.default = LinterClient2;
@@ -5564,7 +8629,7 @@ var require_command = __commonJS({
5564
8629
  "use strict";
5565
8630
  var EventEmitter = require("node:events").EventEmitter;
5566
8631
  var childProcess = require("node:child_process");
5567
- var path2 = require("node:path");
8632
+ var path3 = require("node:path");
5568
8633
  var fs2 = require("node:fs");
5569
8634
  var process3 = require("node:process");
5570
8635
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -6497,9 +9562,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
6497
9562
  let launchWithNode = false;
6498
9563
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
6499
9564
  function findFile(baseDir, baseName) {
6500
- const localBin = path2.resolve(baseDir, baseName);
9565
+ const localBin = path3.resolve(baseDir, baseName);
6501
9566
  if (fs2.existsSync(localBin)) return localBin;
6502
- if (sourceExt.includes(path2.extname(baseName))) return void 0;
9567
+ if (sourceExt.includes(path3.extname(baseName))) return void 0;
6503
9568
  const foundExt = sourceExt.find(
6504
9569
  (ext) => fs2.existsSync(`${localBin}${ext}`)
6505
9570
  );
@@ -6517,17 +9582,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
6517
9582
  } catch (err) {
6518
9583
  resolvedScriptPath = this._scriptPath;
6519
9584
  }
6520
- executableDir = path2.resolve(
6521
- path2.dirname(resolvedScriptPath),
9585
+ executableDir = path3.resolve(
9586
+ path3.dirname(resolvedScriptPath),
6522
9587
  executableDir
6523
9588
  );
6524
9589
  }
6525
9590
  if (executableDir) {
6526
9591
  let localFile = findFile(executableDir, executableFile);
6527
9592
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
6528
- const legacyName = path2.basename(
9593
+ const legacyName = path3.basename(
6529
9594
  this._scriptPath,
6530
- path2.extname(this._scriptPath)
9595
+ path3.extname(this._scriptPath)
6531
9596
  );
6532
9597
  if (legacyName !== this._name) {
6533
9598
  localFile = findFile(
@@ -6538,7 +9603,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
6538
9603
  }
6539
9604
  executableFile = localFile || executableFile;
6540
9605
  }
6541
- launchWithNode = sourceExt.includes(path2.extname(executableFile));
9606
+ launchWithNode = sourceExt.includes(path3.extname(executableFile));
6542
9607
  let proc;
6543
9608
  if (process3.platform !== "win32") {
6544
9609
  if (launchWithNode) {
@@ -7378,7 +10443,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
7378
10443
  * @return {Command}
7379
10444
  */
7380
10445
  nameFromFilename(filename) {
7381
- this._name = path2.basename(filename, path2.extname(filename));
10446
+ this._name = path3.basename(filename, path3.extname(filename));
7382
10447
  return this;
7383
10448
  }
7384
10449
  /**
@@ -7392,9 +10457,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
7392
10457
  * @param {string} [path]
7393
10458
  * @return {(string|null|Command)}
7394
10459
  */
7395
- executableDir(path3) {
7396
- if (path3 === void 0) return this._executableDir;
7397
- this._executableDir = path3;
10460
+ executableDir(path4) {
10461
+ if (path4 === void 0) return this._executableDir;
10462
+ this._executableDir = path4;
7398
10463
  return this;
7399
10464
  }
7400
10465
  /**
@@ -7639,19 +10704,19 @@ var require_globrex = __commonJS({
7639
10704
  function globrex(glob2, { extended = false, globstar = false, strict = false, filepath = false, flags = "" } = {}) {
7640
10705
  let regex = "";
7641
10706
  let segment = "";
7642
- let path2 = { regex: "", segments: [] };
10707
+ let path3 = { regex: "", segments: [] };
7643
10708
  let inGroup = false;
7644
10709
  let inRange = false;
7645
10710
  const ext = [];
7646
10711
  function add(str, { split, last, only } = {}) {
7647
10712
  if (only !== "path") regex += str;
7648
10713
  if (filepath && only !== "regex") {
7649
- path2.regex += str === "\\/" ? SEP : str;
10714
+ path3.regex += str === "\\/" ? SEP : str;
7650
10715
  if (split) {
7651
10716
  if (last) segment += str;
7652
10717
  if (segment !== "") {
7653
10718
  if (!flags.includes("g")) segment = `^${segment}$`;
7654
- path2.segments.push(new RegExp(segment, flags));
10719
+ path3.segments.push(new RegExp(segment, flags));
7655
10720
  }
7656
10721
  segment = "";
7657
10722
  } else {
@@ -7836,14 +10901,14 @@ var require_globrex = __commonJS({
7836
10901
  if (!flags.includes("g")) {
7837
10902
  regex = `^${regex}$`;
7838
10903
  segment = `^${segment}$`;
7839
- if (filepath) path2.regex = `^${path2.regex}$`;
10904
+ if (filepath) path3.regex = `^${path3.regex}$`;
7840
10905
  }
7841
10906
  const result = { regex: new RegExp(regex, flags) };
7842
10907
  if (filepath) {
7843
- path2.segments.push(new RegExp(segment, flags));
7844
- path2.regex = new RegExp(path2.regex, flags);
7845
- path2.globstar = new RegExp(!flags.includes("g") ? `^${GLOBSTAR_SEGMENT}$` : GLOBSTAR_SEGMENT, flags);
7846
- result.path = path2;
10908
+ path3.segments.push(new RegExp(segment, flags));
10909
+ path3.regex = new RegExp(path3.regex, flags);
10910
+ path3.globstar = new RegExp(!flags.includes("g") ? `^${GLOBSTAR_SEGMENT}$` : GLOBSTAR_SEGMENT, flags);
10911
+ result.path = path3;
7847
10912
  }
7848
10913
  return result;
7849
10914
  }
@@ -7856,7 +10921,7 @@ var require_src = __commonJS({
7856
10921
  "../node_modules/globalyzer/src/index.js"(exports2, module2) {
7857
10922
  "use strict";
7858
10923
  var os2 = require("os");
7859
- var path2 = require("path");
10924
+ var path3 = require("path");
7860
10925
  var isWin = os2.platform() === "win32";
7861
10926
  var CHARS = { "{": "}", "(": ")", "[": "]" };
7862
10927
  var STRICT = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\)|(\\).|([@?!+*]\(.*\)))/;
@@ -7883,7 +10948,7 @@ var require_src = __commonJS({
7883
10948
  if (/[\{\[].*[\/]*.*[\}\]]$/.test(str)) str += "/";
7884
10949
  str += "a";
7885
10950
  do {
7886
- str = path2.dirname(str);
10951
+ str = path3.dirname(str);
7887
10952
  } while (isglob(str, { strict }) || /(^|[^\\])([\{\[]|\([^\)]+$)/.test(str));
7888
10953
  return str.replace(/\\([\*\?\|\[\]\(\)\{\}])/g, "$1");
7889
10954
  }
@@ -7898,7 +10963,7 @@ var require_src = __commonJS({
7898
10963
  glob2 = pattern;
7899
10964
  }
7900
10965
  if (!isGlob) {
7901
- base = path2.dirname(pattern);
10966
+ base = path3.dirname(pattern);
7902
10967
  glob2 = base !== "." ? pattern.substr(base.length) : pattern;
7903
10968
  }
7904
10969
  if (glob2.startsWith("./")) glob2 = glob2.substr(2);
@@ -7920,7 +10985,7 @@ var require_tiny_glob = __commonJS({
7920
10985
  var { join, resolve, relative: relative2 } = require("path");
7921
10986
  var isHidden = /(^|[\\\/])\.[^\\\/\.]/g;
7922
10987
  var readdir = promisify(fs2.readdir);
7923
- var stat = promisify(fs2.stat);
10988
+ var stat2 = promisify(fs2.stat);
7924
10989
  var CACHE = {};
7925
10990
  async function walk(output, prefix, lexer, opts, dirname = "", level = 0) {
7926
10991
  const rgx = lexer.segments[level];
@@ -7953,7 +11018,7 @@ var require_tiny_glob = __commonJS({
7953
11018
  if (!glob2.isGlob) {
7954
11019
  try {
7955
11020
  let resolved = resolve(opts.cwd, str);
7956
- let dirent = await stat(resolved);
11021
+ let dirent = await stat2(resolved);
7957
11022
  if (opts.filesOnly && !dirent.isFile()) return [];
7958
11023
  return opts.absolute ? [resolved] : [str];
7959
11024
  } catch (err) {
@@ -7963,9 +11028,9 @@ var require_tiny_glob = __commonJS({
7963
11028
  }
7964
11029
  if (opts.flush) CACHE = {};
7965
11030
  let matches = [];
7966
- const { path: path2 } = globrex(glob2.glob, { filepath: true, globstar: true, extended: true });
7967
- path2.globstar = path2.globstar.toString();
7968
- await walk(matches, glob2.base, path2, opts, ".", 0);
11031
+ const { path: path3 } = globrex(glob2.glob, { filepath: true, globstar: true, extended: true });
11032
+ path3.globstar = path3.globstar.toString();
11033
+ await walk(matches, glob2.base, path3, opts, ".", 0);
7969
11034
  return opts.absolute ? matches.map((x) => resolve(opts.cwd, x)) : matches;
7970
11035
  };
7971
11036
  }
@@ -7979,6 +11044,7 @@ __export(index_exports, {
7979
11044
  parseArgs: () => parseArgs
7980
11045
  });
7981
11046
  module.exports = __toCommonJS(index_exports);
11047
+ var import_deva11yConfig = __toESM(require_deva11yConfig());
7982
11048
  var import_instrumentationService = __toESM(require_instrumentationService());
7983
11049
  var import_linterClient = __toESM(require_linterClient());
7984
11050
 
@@ -8259,6 +11325,12 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
8259
11325
  if (env.TERM === "xterm-kitty") {
8260
11326
  return 3;
8261
11327
  }
11328
+ if (env.TERM === "xterm-ghostty") {
11329
+ return 3;
11330
+ }
11331
+ if (env.TERM === "wezterm") {
11332
+ return 3;
11333
+ }
8262
11334
  if ("TERM_PROGRAM" in env) {
8263
11335
  const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
8264
11336
  switch (env.TERM_PROGRAM) {
@@ -8474,7 +11546,7 @@ var source_default = chalk;
8474
11546
  // src/index.ts
8475
11547
  var fs = __toESM(require("fs/promises"));
8476
11548
  var import_node_perf_hooks = require("node:perf_hooks");
8477
- var path = __toESM(require("path"));
11549
+ var import_path = __toESM(require("path"));
8478
11550
 
8479
11551
  // ../node_modules/uuid/dist/esm/stringify.js
8480
11552
  var byteToHex = [];
@@ -8576,6 +11648,7 @@ function parseArgs(args = process.argv) {
8576
11648
  return {
8577
11649
  include: opts.include,
8578
11650
  exclude: opts.exclude,
11651
+ format: opts.format,
8579
11652
  browserstackUsername: opts.username,
8580
11653
  browserstackAccessKey: opts.accessKey,
8581
11654
  nonStrict: !!opts.nonStrict
@@ -8606,6 +11679,106 @@ async function resolveLintFiles(args) {
8606
11679
  return files;
8607
11680
  }
8608
11681
 
11682
+ // src/formatters.ts
11683
+ var path = __toESM(require("path"));
11684
+ function tryParseMessage(message) {
11685
+ try {
11686
+ const parsed = JSON.parse(message);
11687
+ if (parsed && typeof parsed === "object") {
11688
+ return {
11689
+ ...parsed,
11690
+ description: parsed.description || message
11691
+ };
11692
+ }
11693
+ return null;
11694
+ } catch {
11695
+ return null;
11696
+ }
11697
+ }
11698
+ function formatLocation(filePath, line, column, endLine, endColumn) {
11699
+ const relativePath = path.relative(process.cwd(), filePath);
11700
+ const endPos = endLine ? `-${endLine}:${endColumn || ""}` : "";
11701
+ return `${relativePath}:${line}:${column}${endPos}`;
11702
+ }
11703
+ function formatText(results) {
11704
+ return results.filter((r) => r.filePath && r.messages?.length > 0).flatMap(
11705
+ (r) => r.messages.map((msg) => {
11706
+ const { ruleId, message, line, column, endLine, endColumn } = msg;
11707
+ const parsed = tryParseMessage(message);
11708
+ if (!parsed) {
11709
+ return [
11710
+ source_default.cyan(formatLocation(r.filePath, line, column, endLine, endColumn)),
11711
+ source_default.yellow(`Rule: ${ruleId}`),
11712
+ source_default.white(`Description: ${message}`)
11713
+ ].join("\n");
11714
+ }
11715
+ const ruleName = ruleId?.includes("/") ? ruleId.split("/")[1] : ruleId;
11716
+ const lines = [
11717
+ source_default.cyan(formatLocation(r.filePath, line, column, endLine, endColumn)),
11718
+ source_default.yellow(`Rule: ${ruleName}`),
11719
+ source_default.white(`Description: ${parsed.description}`),
11720
+ parsed.help && source_default.green(`Help: ${parsed.help}`),
11721
+ parsed.failureSummary && source_default.magenta(`Failure Summary: ${parsed.failureSummary}`)
11722
+ ];
11723
+ return lines.filter(Boolean).join("\n");
11724
+ })
11725
+ ).join("\n\n");
11726
+ }
11727
+ function formatXcode(results) {
11728
+ return results.filter((r) => r.filePath && r.messages?.length > 0).flatMap(
11729
+ (r) => r.messages.map((msg) => {
11730
+ const { ruleId, message, line, column, severity } = msg;
11731
+ const parsed = tryParseMessage(message);
11732
+ const type = severity === 2 ? "error" : "warning";
11733
+ let text;
11734
+ if (parsed) {
11735
+ const { description, failureSummary, ruleName } = parsed;
11736
+ const finalM = [description];
11737
+ if (ruleName) {
11738
+ finalM.unshift(`${ruleName}: `);
11739
+ }
11740
+ if (failureSummary && failureSummary.trim().length > 0 && !["not applicable", "na", "n/a"].includes(failureSummary.toLowerCase())) {
11741
+ finalM.push(
11742
+ " ".repeat(600),
11743
+ // blank line
11744
+ "\u2800",
11745
+ " ".repeat(600),
11746
+ // blank line
11747
+ "How to fix:",
11748
+ " ".repeat(600),
11749
+ // End the How to fix last line
11750
+ failureSummary ?? "",
11751
+ " ".repeat(600),
11752
+ // blank line
11753
+ "\u2800",
11754
+ " ".repeat(600)
11755
+ // blank line
11756
+ );
11757
+ }
11758
+ finalM.push(`(Browserstack Accessibility DevTools/${ruleId.split("/")[1]})`);
11759
+ text = finalM.join("");
11760
+ } else {
11761
+ text = message;
11762
+ }
11763
+ const fileRelative = path.relative(process.cwd(), r.filePath);
11764
+ return `${fileRelative}:${line}:${column}: ${type}: ${text}`;
11765
+ })
11766
+ ).join("\n");
11767
+ }
11768
+ function formatResults(results, format) {
11769
+ switch (format) {
11770
+ case "xcode":
11771
+ return formatXcode(results);
11772
+ // case 'junit':
11773
+ // return formatJUnit(results);
11774
+ // case 'json':
11775
+ // return formatJson(results);
11776
+ case "text":
11777
+ default:
11778
+ return formatText(results);
11779
+ }
11780
+ }
11781
+
8609
11782
  // src/index.ts
8610
11783
  var EXIT_CODES = {
8611
11784
  SUCCESS: 0,
@@ -8624,49 +11797,6 @@ var mockLogger = {
8624
11797
  log: () => {
8625
11798
  }
8626
11799
  };
8627
- function safeParseMessage(message) {
8628
- try {
8629
- const { description, help, failureSummary } = JSON.parse(message);
8630
- return {
8631
- success: true,
8632
- data: {
8633
- description: description || message,
8634
- help: help || "",
8635
- failureSummary: failureSummary || ""
8636
- }
8637
- };
8638
- } catch {
8639
- return { success: false, error: "Invalid JSON message" };
8640
- }
8641
- }
8642
- function formatLocation(filePath, line, column, endLine, endColumn) {
8643
- const relativePath = path.relative(process.cwd(), filePath);
8644
- const endPos = endLine ? `-${endLine}:${endColumn || ""}` : "";
8645
- return `${relativePath}:${line}:${column}${endPos}`;
8646
- }
8647
- function formatMessage(msg, filePath) {
8648
- const { ruleId, message, severity, line, column, endLine, endColumn } = msg;
8649
- const parsed = safeParseMessage(message);
8650
- if (!parsed.success) {
8651
- return [
8652
- source_default.cyan(formatLocation(filePath, line, column, endLine, endColumn)),
8653
- source_default.yellow(`Rule: ${ruleId}`),
8654
- source_default.white(`Description: ${message}`)
8655
- ].join("\n");
8656
- }
8657
- const { description, help, failureSummary } = parsed.data;
8658
- const lines = [
8659
- source_default.cyan(formatLocation(filePath, line, column, endLine, endColumn)),
8660
- source_default.yellow(`Rule: ${ruleId.split("/")[1]}`),
8661
- source_default.white(`Description: ${description}`),
8662
- help && source_default.green(`Help: ${help}`),
8663
- failureSummary && source_default.magenta(`Failure Summary: ${failureSummary}`)
8664
- ];
8665
- return lines.filter(Boolean).join("\n");
8666
- }
8667
- function formatResults(results) {
8668
- return results.filter((result) => result.filePath && result.messages?.length > 0).flatMap((result) => result.messages.map((msg) => formatMessage(msg, result.filePath))).filter(Boolean).join("\n\n");
8669
- }
8670
11800
  async function initializeAndAuthenticate(linterClient, args) {
8671
11801
  const { browserstackUsername, browserstackAccessKey } = args;
8672
11802
  if (!browserstackUsername || !browserstackAccessKey) {
@@ -8676,24 +11806,108 @@ async function initializeAndAuthenticate(linterClient, args) {
8676
11806
  };
8677
11807
  }
8678
11808
  try {
8679
- const linterInitResult = await linterClient.initialize();
8680
- if (linterInitResult instanceof Error) {
8681
- return { success: false, error: "Unable to connect to BrowserStack backend" };
8682
- }
8683
11809
  const userProfile = await linterClient.authenticate(
8684
11810
  browserstackUsername,
8685
11811
  browserstackAccessKey
8686
11812
  );
8687
11813
  if (!userProfile || typeof userProfile.id !== "string") {
8688
- return { success: false, error: "Authentication failed. Please check your credentials." };
11814
+ return {
11815
+ success: false,
11816
+ error: "Unable to authenticate. Please check your credentials or plan."
11817
+ };
11818
+ }
11819
+ const linterInitResult = await linterClient.initialize();
11820
+ if (linterInitResult instanceof Error) {
11821
+ return {
11822
+ success: false,
11823
+ error: "Unable to connect to BrowserStack. Please check your network connection."
11824
+ };
8689
11825
  }
8690
11826
  return { success: true, data: userProfile };
8691
11827
  } catch (e) {
8692
- return { success: false, error: e instanceof Error ? e.message : String(e) };
11828
+ const message = e instanceof Error ? e.message : String(e);
11829
+ return {
11830
+ success: false,
11831
+ error: `BrowserStack authentication failed: ${message}`
11832
+ };
8693
11833
  }
8694
11834
  }
11835
+ async function discoverAndSendConfigsForFiles(linterClient, files) {
11836
+ const candidateNames = [
11837
+ "accessibility-devtools.config.yaml",
11838
+ "accessibility-devtools.config.yml",
11839
+ "accessibility-devtools.config.json"
11840
+ ];
11841
+ const visitedDirs = /* @__PURE__ */ new Set();
11842
+ for (const file of files) {
11843
+ let currentDir = import_path.default.resolve(import_path.default.dirname(file));
11844
+ const rootDir = import_path.default.parse(currentDir).root;
11845
+ while (true) {
11846
+ if (!visitedDirs.has(currentDir)) {
11847
+ visitedDirs.add(currentDir);
11848
+ for (const name of candidateNames) {
11849
+ const candidatePath = import_path.default.join(currentDir, name);
11850
+ try {
11851
+ const stat2 = await fs.stat(candidatePath);
11852
+ if (!stat2.isFile()) continue;
11853
+ const config = await (0, import_deva11yConfig.loadConfigFromFile)(candidatePath);
11854
+ await linterClient.setConfig(currentDir, config);
11855
+ break;
11856
+ } catch {
11857
+ }
11858
+ }
11859
+ }
11860
+ if (currentDir === rootDir) break;
11861
+ const parent = import_path.default.dirname(currentDir);
11862
+ if (parent === currentDir) break;
11863
+ currentDir = parent;
11864
+ }
11865
+ }
11866
+ return { success: true, data: void 0 };
11867
+ }
11868
+ async function lintFilesAndCollectMetrics(files, linterClient) {
11869
+ const fileTimings = [];
11870
+ const ruleCounts = {};
11871
+ const perFileRuleRates = [];
11872
+ const perFileResults = await Promise.all(
11873
+ files.map(async (file) => {
11874
+ const fileStart = import_node_perf_hooks.performance.now();
11875
+ const code = await fs.readFile(file, "utf-8");
11876
+ if (!code) {
11877
+ return [];
11878
+ }
11879
+ let result = [];
11880
+ try {
11881
+ result = await linterClient.lintText(file, code);
11882
+ } catch {
11883
+ throw new Error("Internal server error");
11884
+ }
11885
+ const fileEnd = import_node_perf_hooks.performance.now();
11886
+ const fileTime = fileEnd - fileStart;
11887
+ const roundedFileTime = Math.round(fileTime);
11888
+ fileTimings.push(roundedFileTime);
11889
+ let fileRuleCount = 0;
11890
+ result.forEach((lintResult) => {
11891
+ lintResult.messages.forEach((message) => {
11892
+ const rule = message.ruleId?.split("/")[1] || message.ruleId || "unknown";
11893
+ ruleCounts[rule] = (ruleCounts[rule] || 0) + 1;
11894
+ fileRuleCount += 1;
11895
+ });
11896
+ });
11897
+ perFileRuleRates.push(fileTime > 0 ? fileRuleCount / fileTime : 0);
11898
+ return result;
11899
+ })
11900
+ );
11901
+ return {
11902
+ results: perFileResults.flat(),
11903
+ fileTimings,
11904
+ ruleCounts,
11905
+ perFileRuleRates
11906
+ };
11907
+ }
8695
11908
  function computeAnalytics(fileTimings, ruleCounts, perFileRuleRates, totalTimeTaken) {
8696
11909
  return {
11910
+ source: "cli",
8697
11911
  rule_counts: ruleCounts,
8698
11912
  averages: {
8699
11913
  per_file: fileTimings.length ? Math.round(fileTimings.reduce((a, b) => a + b, 0) / fileTimings.length) : 0,
@@ -8704,71 +11918,73 @@ function computeAnalytics(fileTimings, ruleCounts, perFileRuleRates, totalTimeTa
8704
11918
  total_time_taken: totalTimeTaken
8705
11919
  };
8706
11920
  }
11921
+ function isRunningInXcodeEnvironment(env2) {
11922
+ const {
11923
+ XCODE_PRODUCT_BUILD_VERSION,
11924
+ XCODE_VERSION_MAJOR,
11925
+ XCODE_VERSION_MINOR,
11926
+ XCODE_VERSION_ACTUAL,
11927
+ XCODE_APP_SUPPORT_DIR
11928
+ } = env2;
11929
+ return Boolean(
11930
+ XCODE_APP_SUPPORT_DIR || XCODE_PRODUCT_BUILD_VERSION || XCODE_VERSION_MAJOR || XCODE_VERSION_MINOR || XCODE_VERSION_ACTUAL
11931
+ );
11932
+ }
11933
+ function inferOutputFormat(_args) {
11934
+ return isRunningInXcodeEnvironment(process.env) ? "xcode" : "text";
11935
+ }
11936
+ function getUnsupportedExtensions(files, linterClient) {
11937
+ const unsupportedExtensions = new Set(
11938
+ files.filter((file) => !linterClient.isFileExtensionSupported(file)).map((file) => import_path.default.extname(file))
11939
+ );
11940
+ return Array.from(unsupportedExtensions);
11941
+ }
8707
11942
  async function main(args) {
11943
+ const logger = DEBUG ? console : mockLogger;
8708
11944
  const linterClient = import_linterClient.default.getInstance({
8709
11945
  linterServerAddress: LINTER_SERVER_ADDRESS,
8710
- userLogger: DEBUG ? console : mockLogger,
8711
- internalLogger: DEBUG ? console : mockLogger,
11946
+ userLogger: logger,
11947
+ internalLogger: logger,
8712
11948
  retry: false
8713
11949
  });
8714
11950
  const startTime = import_node_perf_hooks.performance.now();
8715
11951
  const isInstrumentationAvailable = Boolean(EDS_API_KEY && EDS_BACKEND);
8716
11952
  const authResult = await initializeAndAuthenticate(linterClient, args);
8717
11953
  if (!authResult.success) {
8718
- console.error(source_default.red(`Error: Authentication failed`));
11954
+ console.error(source_default.red(`Error: ${authResult.error}`));
8719
11955
  process.exit(EXIT_CODES.ERROR);
8720
11956
  }
8721
11957
  const userProfile = authResult.data;
8722
11958
  const sessionId = v4_default();
8723
- import_instrumentationService.default.setSessionId(sessionId).setEdsApiKey(EDS_API_KEY).setEdsBackend(EDS_BACKEND).setUserLogger(DEBUG ? console : mockLogger).setInternalLogger(DEBUG ? console : mockLogger).setUser({ user_id: userProfile.id, group_id: "0" });
11959
+ import_instrumentationService.default.setSessionId(sessionId).setEdsApiKey(EDS_API_KEY).setEdsBackend(EDS_BACKEND).setUserLogger(logger).setInternalLogger(logger).setUser({ user_id: userProfile.id, group_id: "0" });
8724
11960
  if (isInstrumentationAvailable) import_instrumentationService.default.startLogging();
8725
11961
  const fileList = await resolveLintFiles(args);
8726
11962
  if (fileList.length === 0) {
8727
11963
  console.log(source_default.yellow("No files to lint. Please check your include/exclude patterns."));
8728
11964
  process.exit(EXIT_CODES.SUCCESS);
8729
11965
  }
8730
- if (fileList.some((file) => !linterClient.isFileExtensionSupported(file))) {
11966
+ const unsupportedExtensions = getUnsupportedExtensions(fileList, linterClient);
11967
+ if (unsupportedExtensions.length > 0) {
8731
11968
  console.error(
8732
11969
  source_default.red(
8733
- `Error: Unsupported file types. Supported extensions are: ${linterClient.getSupportedFileExtensions().join(", ")}`
11970
+ `{${unsupportedExtensions.join(", ")}} is not supported. Supported file types are ${linterClient.getSupportedFileExtensions().join(", ")}`
8734
11971
  )
8735
11972
  );
8736
- process.exit(1);
11973
+ process.exit(EXIT_CODES.FAILURE);
8737
11974
  }
8738
- const fileTimings = [];
8739
- const ruleCounts = {};
8740
- const perFileRuleRates = [];
8741
- const lintResult = await Promise.all(
8742
- fileList.map(async (file) => {
8743
- const fileStart = import_node_perf_hooks.performance.now();
8744
- const code = await fs.readFile(file, "utf-8");
8745
- if (!code || !file) {
8746
- return [];
8747
- }
8748
- let result = [];
8749
- try {
8750
- result = await linterClient.lintText(file, code);
8751
- } catch (e) {
8752
- throw new Error("Internal server error");
8753
- }
8754
- const fileEnd = import_node_perf_hooks.performance.now();
8755
- const fileTime = fileEnd - fileStart;
8756
- fileTimings.push(Math.round(fileTime));
8757
- let fileRuleCount = 0;
8758
- result.forEach((r) => {
8759
- r.messages.forEach((msg) => {
8760
- const rule = msg.ruleId?.split("/")[1] || msg.ruleId || "unknown";
8761
- ruleCounts[rule] = (ruleCounts[rule] || 0) + 1;
8762
- fileRuleCount++;
8763
- });
8764
- });
8765
- perFileRuleRates.push(fileTime > 0 ? fileRuleCount / fileTime : 0);
8766
- return result;
8767
- })
8768
- );
11975
+ const configResult = await discoverAndSendConfigsForFiles(linterClient, fileList);
11976
+ if (!configResult.success) {
11977
+ console.error(source_default.red(configResult.error));
11978
+ process.exit(EXIT_CODES.ERROR);
11979
+ }
11980
+ const {
11981
+ results: lintResultsFlat,
11982
+ fileTimings,
11983
+ ruleCounts,
11984
+ perFileRuleRates
11985
+ } = await lintFilesAndCollectMetrics(fileList, linterClient);
8769
11986
  const lintEnd = import_node_perf_hooks.performance.now();
8770
11987
  const totalTimeTaken = Math.round(lintEnd - startTime);
8771
- const lintResultsFlat = lintResult.flat();
8772
11988
  const analytics = computeAnalytics(fileTimings, ruleCounts, perFileRuleRates, totalTimeTaken);
8773
11989
  if (isInstrumentationAvailable)
8774
11990
  await import_instrumentationService.default.logEvent("cli:lint_run_analytics", analytics);
@@ -8776,7 +11992,7 @@ async function main(args) {
8776
11992
  console.log(source_default.green("No accessibility violations found! Awesome!"));
8777
11993
  process.exit(EXIT_CODES.SUCCESS);
8778
11994
  }
8779
- console.log(formatResults(lintResultsFlat));
11995
+ console.log(formatResults(lintResultsFlat, inferOutputFormat(args)));
8780
11996
  process.exit(
8781
11997
  lintResultsFlat.length > 0 ? args.nonStrict ? EXIT_CODES.SUCCESS : EXIT_CODES.FAILURE : EXIT_CODES.SUCCESS
8782
11998
  );