@continuonai/rcan-ts 0.1.1

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.
@@ -0,0 +1,3593 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __commonJS = (cb, mod) => function __require() {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+
29
+ // node_modules/js-yaml/lib/js-yaml/common.js
30
+ var require_common = __commonJS({
31
+ "node_modules/js-yaml/lib/js-yaml/common.js"(exports2, module2) {
32
+ "use strict";
33
+ function isNothing(subject) {
34
+ return typeof subject === "undefined" || subject === null;
35
+ }
36
+ function isObject(subject) {
37
+ return typeof subject === "object" && subject !== null;
38
+ }
39
+ function toArray(sequence) {
40
+ if (Array.isArray(sequence)) return sequence;
41
+ else if (isNothing(sequence)) return [];
42
+ return [sequence];
43
+ }
44
+ function extend(target, source) {
45
+ var index, length, key, sourceKeys;
46
+ if (source) {
47
+ sourceKeys = Object.keys(source);
48
+ for (index = 0, length = sourceKeys.length; index < length; index += 1) {
49
+ key = sourceKeys[index];
50
+ target[key] = source[key];
51
+ }
52
+ }
53
+ return target;
54
+ }
55
+ function repeat(string, count) {
56
+ var result = "", cycle;
57
+ for (cycle = 0; cycle < count; cycle += 1) {
58
+ result += string;
59
+ }
60
+ return result;
61
+ }
62
+ function isNegativeZero(number) {
63
+ return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
64
+ }
65
+ module2.exports.isNothing = isNothing;
66
+ module2.exports.isObject = isObject;
67
+ module2.exports.toArray = toArray;
68
+ module2.exports.repeat = repeat;
69
+ module2.exports.isNegativeZero = isNegativeZero;
70
+ module2.exports.extend = extend;
71
+ }
72
+ });
73
+
74
+ // node_modules/js-yaml/lib/js-yaml/exception.js
75
+ var require_exception = __commonJS({
76
+ "node_modules/js-yaml/lib/js-yaml/exception.js"(exports2, module2) {
77
+ "use strict";
78
+ function YAMLException(reason, mark) {
79
+ Error.call(this);
80
+ this.name = "YAMLException";
81
+ this.reason = reason;
82
+ this.mark = mark;
83
+ this.message = (this.reason || "(unknown reason)") + (this.mark ? " " + this.mark.toString() : "");
84
+ if (Error.captureStackTrace) {
85
+ Error.captureStackTrace(this, this.constructor);
86
+ } else {
87
+ this.stack = new Error().stack || "";
88
+ }
89
+ }
90
+ YAMLException.prototype = Object.create(Error.prototype);
91
+ YAMLException.prototype.constructor = YAMLException;
92
+ YAMLException.prototype.toString = function toString(compact) {
93
+ var result = this.name + ": ";
94
+ result += this.reason || "(unknown reason)";
95
+ if (!compact && this.mark) {
96
+ result += " " + this.mark.toString();
97
+ }
98
+ return result;
99
+ };
100
+ module2.exports = YAMLException;
101
+ }
102
+ });
103
+
104
+ // node_modules/js-yaml/lib/js-yaml/mark.js
105
+ var require_mark = __commonJS({
106
+ "node_modules/js-yaml/lib/js-yaml/mark.js"(exports2, module2) {
107
+ "use strict";
108
+ var common = require_common();
109
+ function Mark(name, buffer, position, line, column) {
110
+ this.name = name;
111
+ this.buffer = buffer;
112
+ this.position = position;
113
+ this.line = line;
114
+ this.column = column;
115
+ }
116
+ Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
117
+ var head, start, tail, end, snippet;
118
+ if (!this.buffer) return null;
119
+ indent = indent || 4;
120
+ maxLength = maxLength || 75;
121
+ head = "";
122
+ start = this.position;
123
+ while (start > 0 && "\0\r\n\x85\u2028\u2029".indexOf(this.buffer.charAt(start - 1)) === -1) {
124
+ start -= 1;
125
+ if (this.position - start > maxLength / 2 - 1) {
126
+ head = " ... ";
127
+ start += 5;
128
+ break;
129
+ }
130
+ }
131
+ tail = "";
132
+ end = this.position;
133
+ while (end < this.buffer.length && "\0\r\n\x85\u2028\u2029".indexOf(this.buffer.charAt(end)) === -1) {
134
+ end += 1;
135
+ if (end - this.position > maxLength / 2 - 1) {
136
+ tail = " ... ";
137
+ end -= 5;
138
+ break;
139
+ }
140
+ }
141
+ snippet = this.buffer.slice(start, end);
142
+ return common.repeat(" ", indent) + head + snippet + tail + "\n" + common.repeat(" ", indent + this.position - start + head.length) + "^";
143
+ };
144
+ Mark.prototype.toString = function toString(compact) {
145
+ var snippet, where = "";
146
+ if (this.name) {
147
+ where += 'in "' + this.name + '" ';
148
+ }
149
+ where += "at line " + (this.line + 1) + ", column " + (this.column + 1);
150
+ if (!compact) {
151
+ snippet = this.getSnippet();
152
+ if (snippet) {
153
+ where += ":\n" + snippet;
154
+ }
155
+ }
156
+ return where;
157
+ };
158
+ module2.exports = Mark;
159
+ }
160
+ });
161
+
162
+ // node_modules/js-yaml/lib/js-yaml/type.js
163
+ var require_type = __commonJS({
164
+ "node_modules/js-yaml/lib/js-yaml/type.js"(exports2, module2) {
165
+ "use strict";
166
+ var YAMLException = require_exception();
167
+ var TYPE_CONSTRUCTOR_OPTIONS = [
168
+ "kind",
169
+ "resolve",
170
+ "construct",
171
+ "instanceOf",
172
+ "predicate",
173
+ "represent",
174
+ "defaultStyle",
175
+ "styleAliases"
176
+ ];
177
+ var YAML_NODE_KINDS = [
178
+ "scalar",
179
+ "sequence",
180
+ "mapping"
181
+ ];
182
+ function compileStyleAliases(map) {
183
+ var result = {};
184
+ if (map !== null) {
185
+ Object.keys(map).forEach(function(style) {
186
+ map[style].forEach(function(alias) {
187
+ result[String(alias)] = style;
188
+ });
189
+ });
190
+ }
191
+ return result;
192
+ }
193
+ function Type(tag, options) {
194
+ options = options || {};
195
+ Object.keys(options).forEach(function(name) {
196
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
197
+ throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
198
+ }
199
+ });
200
+ this.tag = tag;
201
+ this.kind = options["kind"] || null;
202
+ this.resolve = options["resolve"] || function() {
203
+ return true;
204
+ };
205
+ this.construct = options["construct"] || function(data) {
206
+ return data;
207
+ };
208
+ this.instanceOf = options["instanceOf"] || null;
209
+ this.predicate = options["predicate"] || null;
210
+ this.represent = options["represent"] || null;
211
+ this.defaultStyle = options["defaultStyle"] || null;
212
+ this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
213
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
214
+ throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
215
+ }
216
+ }
217
+ module2.exports = Type;
218
+ }
219
+ });
220
+
221
+ // node_modules/js-yaml/lib/js-yaml/schema.js
222
+ var require_schema = __commonJS({
223
+ "node_modules/js-yaml/lib/js-yaml/schema.js"(exports2, module2) {
224
+ "use strict";
225
+ var common = require_common();
226
+ var YAMLException = require_exception();
227
+ var Type = require_type();
228
+ function compileList(schema, name, result) {
229
+ var exclude = [];
230
+ schema.include.forEach(function(includedSchema) {
231
+ result = compileList(includedSchema, name, result);
232
+ });
233
+ schema[name].forEach(function(currentType) {
234
+ result.forEach(function(previousType, previousIndex) {
235
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
236
+ exclude.push(previousIndex);
237
+ }
238
+ });
239
+ result.push(currentType);
240
+ });
241
+ return result.filter(function(type, index) {
242
+ return exclude.indexOf(index) === -1;
243
+ });
244
+ }
245
+ function compileMap() {
246
+ var result = {
247
+ scalar: {},
248
+ sequence: {},
249
+ mapping: {},
250
+ fallback: {}
251
+ }, index, length;
252
+ function collectType(type) {
253
+ result[type.kind][type.tag] = result["fallback"][type.tag] = type;
254
+ }
255
+ for (index = 0, length = arguments.length; index < length; index += 1) {
256
+ arguments[index].forEach(collectType);
257
+ }
258
+ return result;
259
+ }
260
+ function Schema(definition) {
261
+ this.include = definition.include || [];
262
+ this.implicit = definition.implicit || [];
263
+ this.explicit = definition.explicit || [];
264
+ this.implicit.forEach(function(type) {
265
+ if (type.loadKind && type.loadKind !== "scalar") {
266
+ throw new YAMLException("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
267
+ }
268
+ });
269
+ this.compiledImplicit = compileList(this, "implicit", []);
270
+ this.compiledExplicit = compileList(this, "explicit", []);
271
+ this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
272
+ }
273
+ Schema.DEFAULT = null;
274
+ Schema.create = function createSchema() {
275
+ var schemas, types;
276
+ switch (arguments.length) {
277
+ case 1:
278
+ schemas = Schema.DEFAULT;
279
+ types = arguments[0];
280
+ break;
281
+ case 2:
282
+ schemas = arguments[0];
283
+ types = arguments[1];
284
+ break;
285
+ default:
286
+ throw new YAMLException("Wrong number of arguments for Schema.create function");
287
+ }
288
+ schemas = common.toArray(schemas);
289
+ types = common.toArray(types);
290
+ if (!schemas.every(function(schema) {
291
+ return schema instanceof Schema;
292
+ })) {
293
+ throw new YAMLException("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");
294
+ }
295
+ if (!types.every(function(type) {
296
+ return type instanceof Type;
297
+ })) {
298
+ throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
299
+ }
300
+ return new Schema({
301
+ include: schemas,
302
+ explicit: types
303
+ });
304
+ };
305
+ module2.exports = Schema;
306
+ }
307
+ });
308
+
309
+ // node_modules/js-yaml/lib/js-yaml/type/str.js
310
+ var require_str = __commonJS({
311
+ "node_modules/js-yaml/lib/js-yaml/type/str.js"(exports2, module2) {
312
+ "use strict";
313
+ var Type = require_type();
314
+ module2.exports = new Type("tag:yaml.org,2002:str", {
315
+ kind: "scalar",
316
+ construct: function(data) {
317
+ return data !== null ? data : "";
318
+ }
319
+ });
320
+ }
321
+ });
322
+
323
+ // node_modules/js-yaml/lib/js-yaml/type/seq.js
324
+ var require_seq = __commonJS({
325
+ "node_modules/js-yaml/lib/js-yaml/type/seq.js"(exports2, module2) {
326
+ "use strict";
327
+ var Type = require_type();
328
+ module2.exports = new Type("tag:yaml.org,2002:seq", {
329
+ kind: "sequence",
330
+ construct: function(data) {
331
+ return data !== null ? data : [];
332
+ }
333
+ });
334
+ }
335
+ });
336
+
337
+ // node_modules/js-yaml/lib/js-yaml/type/map.js
338
+ var require_map = __commonJS({
339
+ "node_modules/js-yaml/lib/js-yaml/type/map.js"(exports2, module2) {
340
+ "use strict";
341
+ var Type = require_type();
342
+ module2.exports = new Type("tag:yaml.org,2002:map", {
343
+ kind: "mapping",
344
+ construct: function(data) {
345
+ return data !== null ? data : {};
346
+ }
347
+ });
348
+ }
349
+ });
350
+
351
+ // node_modules/js-yaml/lib/js-yaml/schema/failsafe.js
352
+ var require_failsafe = __commonJS({
353
+ "node_modules/js-yaml/lib/js-yaml/schema/failsafe.js"(exports2, module2) {
354
+ "use strict";
355
+ var Schema = require_schema();
356
+ module2.exports = new Schema({
357
+ explicit: [
358
+ require_str(),
359
+ require_seq(),
360
+ require_map()
361
+ ]
362
+ });
363
+ }
364
+ });
365
+
366
+ // node_modules/js-yaml/lib/js-yaml/type/null.js
367
+ var require_null = __commonJS({
368
+ "node_modules/js-yaml/lib/js-yaml/type/null.js"(exports2, module2) {
369
+ "use strict";
370
+ var Type = require_type();
371
+ function resolveYamlNull(data) {
372
+ if (data === null) return true;
373
+ var max = data.length;
374
+ return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
375
+ }
376
+ function constructYamlNull() {
377
+ return null;
378
+ }
379
+ function isNull(object) {
380
+ return object === null;
381
+ }
382
+ module2.exports = new Type("tag:yaml.org,2002:null", {
383
+ kind: "scalar",
384
+ resolve: resolveYamlNull,
385
+ construct: constructYamlNull,
386
+ predicate: isNull,
387
+ represent: {
388
+ canonical: function() {
389
+ return "~";
390
+ },
391
+ lowercase: function() {
392
+ return "null";
393
+ },
394
+ uppercase: function() {
395
+ return "NULL";
396
+ },
397
+ camelcase: function() {
398
+ return "Null";
399
+ }
400
+ },
401
+ defaultStyle: "lowercase"
402
+ });
403
+ }
404
+ });
405
+
406
+ // node_modules/js-yaml/lib/js-yaml/type/bool.js
407
+ var require_bool = __commonJS({
408
+ "node_modules/js-yaml/lib/js-yaml/type/bool.js"(exports2, module2) {
409
+ "use strict";
410
+ var Type = require_type();
411
+ function resolveYamlBoolean(data) {
412
+ if (data === null) return false;
413
+ var max = data.length;
414
+ return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
415
+ }
416
+ function constructYamlBoolean(data) {
417
+ return data === "true" || data === "True" || data === "TRUE";
418
+ }
419
+ function isBoolean(object) {
420
+ return Object.prototype.toString.call(object) === "[object Boolean]";
421
+ }
422
+ module2.exports = new Type("tag:yaml.org,2002:bool", {
423
+ kind: "scalar",
424
+ resolve: resolveYamlBoolean,
425
+ construct: constructYamlBoolean,
426
+ predicate: isBoolean,
427
+ represent: {
428
+ lowercase: function(object) {
429
+ return object ? "true" : "false";
430
+ },
431
+ uppercase: function(object) {
432
+ return object ? "TRUE" : "FALSE";
433
+ },
434
+ camelcase: function(object) {
435
+ return object ? "True" : "False";
436
+ }
437
+ },
438
+ defaultStyle: "lowercase"
439
+ });
440
+ }
441
+ });
442
+
443
+ // node_modules/js-yaml/lib/js-yaml/type/int.js
444
+ var require_int = __commonJS({
445
+ "node_modules/js-yaml/lib/js-yaml/type/int.js"(exports2, module2) {
446
+ "use strict";
447
+ var common = require_common();
448
+ var Type = require_type();
449
+ function isHexCode(c) {
450
+ return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
451
+ }
452
+ function isOctCode(c) {
453
+ return 48 <= c && c <= 55;
454
+ }
455
+ function isDecCode(c) {
456
+ return 48 <= c && c <= 57;
457
+ }
458
+ function resolveYamlInteger(data) {
459
+ if (data === null) return false;
460
+ var max = data.length, index = 0, hasDigits = false, ch;
461
+ if (!max) return false;
462
+ ch = data[index];
463
+ if (ch === "-" || ch === "+") {
464
+ ch = data[++index];
465
+ }
466
+ if (ch === "0") {
467
+ if (index + 1 === max) return true;
468
+ ch = data[++index];
469
+ if (ch === "b") {
470
+ index++;
471
+ for (; index < max; index++) {
472
+ ch = data[index];
473
+ if (ch === "_") continue;
474
+ if (ch !== "0" && ch !== "1") return false;
475
+ hasDigits = true;
476
+ }
477
+ return hasDigits && ch !== "_";
478
+ }
479
+ if (ch === "x") {
480
+ index++;
481
+ for (; index < max; index++) {
482
+ ch = data[index];
483
+ if (ch === "_") continue;
484
+ if (!isHexCode(data.charCodeAt(index))) return false;
485
+ hasDigits = true;
486
+ }
487
+ return hasDigits && ch !== "_";
488
+ }
489
+ for (; index < max; index++) {
490
+ ch = data[index];
491
+ if (ch === "_") continue;
492
+ if (!isOctCode(data.charCodeAt(index))) return false;
493
+ hasDigits = true;
494
+ }
495
+ return hasDigits && ch !== "_";
496
+ }
497
+ if (ch === "_") return false;
498
+ for (; index < max; index++) {
499
+ ch = data[index];
500
+ if (ch === "_") continue;
501
+ if (ch === ":") break;
502
+ if (!isDecCode(data.charCodeAt(index))) {
503
+ return false;
504
+ }
505
+ hasDigits = true;
506
+ }
507
+ if (!hasDigits || ch === "_") return false;
508
+ if (ch !== ":") return true;
509
+ return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
510
+ }
511
+ function constructYamlInteger(data) {
512
+ var value = data, sign = 1, ch, base, digits = [];
513
+ if (value.indexOf("_") !== -1) {
514
+ value = value.replace(/_/g, "");
515
+ }
516
+ ch = value[0];
517
+ if (ch === "-" || ch === "+") {
518
+ if (ch === "-") sign = -1;
519
+ value = value.slice(1);
520
+ ch = value[0];
521
+ }
522
+ if (value === "0") return 0;
523
+ if (ch === "0") {
524
+ if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
525
+ if (value[1] === "x") return sign * parseInt(value, 16);
526
+ return sign * parseInt(value, 8);
527
+ }
528
+ if (value.indexOf(":") !== -1) {
529
+ value.split(":").forEach(function(v) {
530
+ digits.unshift(parseInt(v, 10));
531
+ });
532
+ value = 0;
533
+ base = 1;
534
+ digits.forEach(function(d) {
535
+ value += d * base;
536
+ base *= 60;
537
+ });
538
+ return sign * value;
539
+ }
540
+ return sign * parseInt(value, 10);
541
+ }
542
+ function isInteger(object) {
543
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
544
+ }
545
+ module2.exports = new Type("tag:yaml.org,2002:int", {
546
+ kind: "scalar",
547
+ resolve: resolveYamlInteger,
548
+ construct: constructYamlInteger,
549
+ predicate: isInteger,
550
+ represent: {
551
+ binary: function(obj) {
552
+ return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
553
+ },
554
+ octal: function(obj) {
555
+ return obj >= 0 ? "0" + obj.toString(8) : "-0" + obj.toString(8).slice(1);
556
+ },
557
+ decimal: function(obj) {
558
+ return obj.toString(10);
559
+ },
560
+ /* eslint-disable max-len */
561
+ hexadecimal: function(obj) {
562
+ return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
563
+ }
564
+ },
565
+ defaultStyle: "decimal",
566
+ styleAliases: {
567
+ binary: [2, "bin"],
568
+ octal: [8, "oct"],
569
+ decimal: [10, "dec"],
570
+ hexadecimal: [16, "hex"]
571
+ }
572
+ });
573
+ }
574
+ });
575
+
576
+ // node_modules/js-yaml/lib/js-yaml/type/float.js
577
+ var require_float = __commonJS({
578
+ "node_modules/js-yaml/lib/js-yaml/type/float.js"(exports2, module2) {
579
+ "use strict";
580
+ var common = require_common();
581
+ var Type = require_type();
582
+ var YAML_FLOAT_PATTERN = new RegExp(
583
+ // 2.5e4, 2.5 and integers
584
+ "^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
585
+ );
586
+ function resolveYamlFloat(data) {
587
+ if (data === null) return false;
588
+ if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
589
+ // Probably should update regexp & check speed
590
+ data[data.length - 1] === "_") {
591
+ return false;
592
+ }
593
+ return true;
594
+ }
595
+ function constructYamlFloat(data) {
596
+ var value, sign, base, digits;
597
+ value = data.replace(/_/g, "").toLowerCase();
598
+ sign = value[0] === "-" ? -1 : 1;
599
+ digits = [];
600
+ if ("+-".indexOf(value[0]) >= 0) {
601
+ value = value.slice(1);
602
+ }
603
+ if (value === ".inf") {
604
+ return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
605
+ } else if (value === ".nan") {
606
+ return NaN;
607
+ } else if (value.indexOf(":") >= 0) {
608
+ value.split(":").forEach(function(v) {
609
+ digits.unshift(parseFloat(v, 10));
610
+ });
611
+ value = 0;
612
+ base = 1;
613
+ digits.forEach(function(d) {
614
+ value += d * base;
615
+ base *= 60;
616
+ });
617
+ return sign * value;
618
+ }
619
+ return sign * parseFloat(value, 10);
620
+ }
621
+ var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
622
+ function representYamlFloat(object, style) {
623
+ var res;
624
+ if (isNaN(object)) {
625
+ switch (style) {
626
+ case "lowercase":
627
+ return ".nan";
628
+ case "uppercase":
629
+ return ".NAN";
630
+ case "camelcase":
631
+ return ".NaN";
632
+ }
633
+ } else if (Number.POSITIVE_INFINITY === object) {
634
+ switch (style) {
635
+ case "lowercase":
636
+ return ".inf";
637
+ case "uppercase":
638
+ return ".INF";
639
+ case "camelcase":
640
+ return ".Inf";
641
+ }
642
+ } else if (Number.NEGATIVE_INFINITY === object) {
643
+ switch (style) {
644
+ case "lowercase":
645
+ return "-.inf";
646
+ case "uppercase":
647
+ return "-.INF";
648
+ case "camelcase":
649
+ return "-.Inf";
650
+ }
651
+ } else if (common.isNegativeZero(object)) {
652
+ return "-0.0";
653
+ }
654
+ res = object.toString(10);
655
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
656
+ }
657
+ function isFloat(object) {
658
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
659
+ }
660
+ module2.exports = new Type("tag:yaml.org,2002:float", {
661
+ kind: "scalar",
662
+ resolve: resolveYamlFloat,
663
+ construct: constructYamlFloat,
664
+ predicate: isFloat,
665
+ represent: representYamlFloat,
666
+ defaultStyle: "lowercase"
667
+ });
668
+ }
669
+ });
670
+
671
+ // node_modules/js-yaml/lib/js-yaml/schema/json.js
672
+ var require_json = __commonJS({
673
+ "node_modules/js-yaml/lib/js-yaml/schema/json.js"(exports2, module2) {
674
+ "use strict";
675
+ var Schema = require_schema();
676
+ module2.exports = new Schema({
677
+ include: [
678
+ require_failsafe()
679
+ ],
680
+ implicit: [
681
+ require_null(),
682
+ require_bool(),
683
+ require_int(),
684
+ require_float()
685
+ ]
686
+ });
687
+ }
688
+ });
689
+
690
+ // node_modules/js-yaml/lib/js-yaml/schema/core.js
691
+ var require_core = __commonJS({
692
+ "node_modules/js-yaml/lib/js-yaml/schema/core.js"(exports2, module2) {
693
+ "use strict";
694
+ var Schema = require_schema();
695
+ module2.exports = new Schema({
696
+ include: [
697
+ require_json()
698
+ ]
699
+ });
700
+ }
701
+ });
702
+
703
+ // node_modules/js-yaml/lib/js-yaml/type/timestamp.js
704
+ var require_timestamp = __commonJS({
705
+ "node_modules/js-yaml/lib/js-yaml/type/timestamp.js"(exports2, module2) {
706
+ "use strict";
707
+ var Type = require_type();
708
+ var YAML_DATE_REGEXP = new RegExp(
709
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
710
+ );
711
+ var YAML_TIMESTAMP_REGEXP = new RegExp(
712
+ "^([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]))?))?$"
713
+ );
714
+ function resolveYamlTimestamp(data) {
715
+ if (data === null) return false;
716
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
717
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
718
+ return false;
719
+ }
720
+ function constructYamlTimestamp(data) {
721
+ var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
722
+ match = YAML_DATE_REGEXP.exec(data);
723
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
724
+ if (match === null) throw new Error("Date resolve error");
725
+ year = +match[1];
726
+ month = +match[2] - 1;
727
+ day = +match[3];
728
+ if (!match[4]) {
729
+ return new Date(Date.UTC(year, month, day));
730
+ }
731
+ hour = +match[4];
732
+ minute = +match[5];
733
+ second = +match[6];
734
+ if (match[7]) {
735
+ fraction = match[7].slice(0, 3);
736
+ while (fraction.length < 3) {
737
+ fraction += "0";
738
+ }
739
+ fraction = +fraction;
740
+ }
741
+ if (match[9]) {
742
+ tz_hour = +match[10];
743
+ tz_minute = +(match[11] || 0);
744
+ delta = (tz_hour * 60 + tz_minute) * 6e4;
745
+ if (match[9] === "-") delta = -delta;
746
+ }
747
+ date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
748
+ if (delta) date.setTime(date.getTime() - delta);
749
+ return date;
750
+ }
751
+ function representYamlTimestamp(object) {
752
+ return object.toISOString();
753
+ }
754
+ module2.exports = new Type("tag:yaml.org,2002:timestamp", {
755
+ kind: "scalar",
756
+ resolve: resolveYamlTimestamp,
757
+ construct: constructYamlTimestamp,
758
+ instanceOf: Date,
759
+ represent: representYamlTimestamp
760
+ });
761
+ }
762
+ });
763
+
764
+ // node_modules/js-yaml/lib/js-yaml/type/merge.js
765
+ var require_merge = __commonJS({
766
+ "node_modules/js-yaml/lib/js-yaml/type/merge.js"(exports2, module2) {
767
+ "use strict";
768
+ var Type = require_type();
769
+ function resolveYamlMerge(data) {
770
+ return data === "<<" || data === null;
771
+ }
772
+ module2.exports = new Type("tag:yaml.org,2002:merge", {
773
+ kind: "scalar",
774
+ resolve: resolveYamlMerge
775
+ });
776
+ }
777
+ });
778
+
779
+ // node_modules/js-yaml/lib/js-yaml/type/binary.js
780
+ var require_binary = __commonJS({
781
+ "node_modules/js-yaml/lib/js-yaml/type/binary.js"(exports2, module2) {
782
+ "use strict";
783
+ var NodeBuffer;
784
+ try {
785
+ _require = require;
786
+ NodeBuffer = _require("buffer").Buffer;
787
+ } catch (__) {
788
+ }
789
+ var _require;
790
+ var Type = require_type();
791
+ var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
792
+ function resolveYamlBinary(data) {
793
+ if (data === null) return false;
794
+ var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
795
+ for (idx = 0; idx < max; idx++) {
796
+ code = map.indexOf(data.charAt(idx));
797
+ if (code > 64) continue;
798
+ if (code < 0) return false;
799
+ bitlen += 6;
800
+ }
801
+ return bitlen % 8 === 0;
802
+ }
803
+ function constructYamlBinary(data) {
804
+ var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map = BASE64_MAP, bits = 0, result = [];
805
+ for (idx = 0; idx < max; idx++) {
806
+ if (idx % 4 === 0 && idx) {
807
+ result.push(bits >> 16 & 255);
808
+ result.push(bits >> 8 & 255);
809
+ result.push(bits & 255);
810
+ }
811
+ bits = bits << 6 | map.indexOf(input.charAt(idx));
812
+ }
813
+ tailbits = max % 4 * 6;
814
+ if (tailbits === 0) {
815
+ result.push(bits >> 16 & 255);
816
+ result.push(bits >> 8 & 255);
817
+ result.push(bits & 255);
818
+ } else if (tailbits === 18) {
819
+ result.push(bits >> 10 & 255);
820
+ result.push(bits >> 2 & 255);
821
+ } else if (tailbits === 12) {
822
+ result.push(bits >> 4 & 255);
823
+ }
824
+ if (NodeBuffer) {
825
+ return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
826
+ }
827
+ return result;
828
+ }
829
+ function representYamlBinary(object) {
830
+ var result = "", bits = 0, idx, tail, max = object.length, map = BASE64_MAP;
831
+ for (idx = 0; idx < max; idx++) {
832
+ if (idx % 3 === 0 && idx) {
833
+ result += map[bits >> 18 & 63];
834
+ result += map[bits >> 12 & 63];
835
+ result += map[bits >> 6 & 63];
836
+ result += map[bits & 63];
837
+ }
838
+ bits = (bits << 8) + object[idx];
839
+ }
840
+ tail = max % 3;
841
+ if (tail === 0) {
842
+ result += map[bits >> 18 & 63];
843
+ result += map[bits >> 12 & 63];
844
+ result += map[bits >> 6 & 63];
845
+ result += map[bits & 63];
846
+ } else if (tail === 2) {
847
+ result += map[bits >> 10 & 63];
848
+ result += map[bits >> 4 & 63];
849
+ result += map[bits << 2 & 63];
850
+ result += map[64];
851
+ } else if (tail === 1) {
852
+ result += map[bits >> 2 & 63];
853
+ result += map[bits << 4 & 63];
854
+ result += map[64];
855
+ result += map[64];
856
+ }
857
+ return result;
858
+ }
859
+ function isBinary(object) {
860
+ return NodeBuffer && NodeBuffer.isBuffer(object);
861
+ }
862
+ module2.exports = new Type("tag:yaml.org,2002:binary", {
863
+ kind: "scalar",
864
+ resolve: resolveYamlBinary,
865
+ construct: constructYamlBinary,
866
+ predicate: isBinary,
867
+ represent: representYamlBinary
868
+ });
869
+ }
870
+ });
871
+
872
+ // node_modules/js-yaml/lib/js-yaml/type/omap.js
873
+ var require_omap = __commonJS({
874
+ "node_modules/js-yaml/lib/js-yaml/type/omap.js"(exports2, module2) {
875
+ "use strict";
876
+ var Type = require_type();
877
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
878
+ var _toString = Object.prototype.toString;
879
+ function resolveYamlOmap(data) {
880
+ if (data === null) return true;
881
+ var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
882
+ for (index = 0, length = object.length; index < length; index += 1) {
883
+ pair = object[index];
884
+ pairHasKey = false;
885
+ if (_toString.call(pair) !== "[object Object]") return false;
886
+ for (pairKey in pair) {
887
+ if (_hasOwnProperty.call(pair, pairKey)) {
888
+ if (!pairHasKey) pairHasKey = true;
889
+ else return false;
890
+ }
891
+ }
892
+ if (!pairHasKey) return false;
893
+ if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
894
+ else return false;
895
+ }
896
+ return true;
897
+ }
898
+ function constructYamlOmap(data) {
899
+ return data !== null ? data : [];
900
+ }
901
+ module2.exports = new Type("tag:yaml.org,2002:omap", {
902
+ kind: "sequence",
903
+ resolve: resolveYamlOmap,
904
+ construct: constructYamlOmap
905
+ });
906
+ }
907
+ });
908
+
909
+ // node_modules/js-yaml/lib/js-yaml/type/pairs.js
910
+ var require_pairs = __commonJS({
911
+ "node_modules/js-yaml/lib/js-yaml/type/pairs.js"(exports2, module2) {
912
+ "use strict";
913
+ var Type = require_type();
914
+ var _toString = Object.prototype.toString;
915
+ function resolveYamlPairs(data) {
916
+ if (data === null) return true;
917
+ var index, length, pair, keys, result, object = data;
918
+ result = new Array(object.length);
919
+ for (index = 0, length = object.length; index < length; index += 1) {
920
+ pair = object[index];
921
+ if (_toString.call(pair) !== "[object Object]") return false;
922
+ keys = Object.keys(pair);
923
+ if (keys.length !== 1) return false;
924
+ result[index] = [keys[0], pair[keys[0]]];
925
+ }
926
+ return true;
927
+ }
928
+ function constructYamlPairs(data) {
929
+ if (data === null) return [];
930
+ var index, length, pair, keys, result, object = data;
931
+ result = new Array(object.length);
932
+ for (index = 0, length = object.length; index < length; index += 1) {
933
+ pair = object[index];
934
+ keys = Object.keys(pair);
935
+ result[index] = [keys[0], pair[keys[0]]];
936
+ }
937
+ return result;
938
+ }
939
+ module2.exports = new Type("tag:yaml.org,2002:pairs", {
940
+ kind: "sequence",
941
+ resolve: resolveYamlPairs,
942
+ construct: constructYamlPairs
943
+ });
944
+ }
945
+ });
946
+
947
+ // node_modules/js-yaml/lib/js-yaml/type/set.js
948
+ var require_set = __commonJS({
949
+ "node_modules/js-yaml/lib/js-yaml/type/set.js"(exports2, module2) {
950
+ "use strict";
951
+ var Type = require_type();
952
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
953
+ function resolveYamlSet(data) {
954
+ if (data === null) return true;
955
+ var key, object = data;
956
+ for (key in object) {
957
+ if (_hasOwnProperty.call(object, key)) {
958
+ if (object[key] !== null) return false;
959
+ }
960
+ }
961
+ return true;
962
+ }
963
+ function constructYamlSet(data) {
964
+ return data !== null ? data : {};
965
+ }
966
+ module2.exports = new Type("tag:yaml.org,2002:set", {
967
+ kind: "mapping",
968
+ resolve: resolveYamlSet,
969
+ construct: constructYamlSet
970
+ });
971
+ }
972
+ });
973
+
974
+ // node_modules/js-yaml/lib/js-yaml/schema/default_safe.js
975
+ var require_default_safe = __commonJS({
976
+ "node_modules/js-yaml/lib/js-yaml/schema/default_safe.js"(exports2, module2) {
977
+ "use strict";
978
+ var Schema = require_schema();
979
+ module2.exports = new Schema({
980
+ include: [
981
+ require_core()
982
+ ],
983
+ implicit: [
984
+ require_timestamp(),
985
+ require_merge()
986
+ ],
987
+ explicit: [
988
+ require_binary(),
989
+ require_omap(),
990
+ require_pairs(),
991
+ require_set()
992
+ ]
993
+ });
994
+ }
995
+ });
996
+
997
+ // node_modules/js-yaml/lib/js-yaml/type/js/undefined.js
998
+ var require_undefined = __commonJS({
999
+ "node_modules/js-yaml/lib/js-yaml/type/js/undefined.js"(exports2, module2) {
1000
+ "use strict";
1001
+ var Type = require_type();
1002
+ function resolveJavascriptUndefined() {
1003
+ return true;
1004
+ }
1005
+ function constructJavascriptUndefined() {
1006
+ return void 0;
1007
+ }
1008
+ function representJavascriptUndefined() {
1009
+ return "";
1010
+ }
1011
+ function isUndefined(object) {
1012
+ return typeof object === "undefined";
1013
+ }
1014
+ module2.exports = new Type("tag:yaml.org,2002:js/undefined", {
1015
+ kind: "scalar",
1016
+ resolve: resolveJavascriptUndefined,
1017
+ construct: constructJavascriptUndefined,
1018
+ predicate: isUndefined,
1019
+ represent: representJavascriptUndefined
1020
+ });
1021
+ }
1022
+ });
1023
+
1024
+ // node_modules/js-yaml/lib/js-yaml/type/js/regexp.js
1025
+ var require_regexp = __commonJS({
1026
+ "node_modules/js-yaml/lib/js-yaml/type/js/regexp.js"(exports2, module2) {
1027
+ "use strict";
1028
+ var Type = require_type();
1029
+ function resolveJavascriptRegExp(data) {
1030
+ if (data === null) return false;
1031
+ if (data.length === 0) return false;
1032
+ var regexp = data, tail = /\/([gim]*)$/.exec(data), modifiers = "";
1033
+ if (regexp[0] === "/") {
1034
+ if (tail) modifiers = tail[1];
1035
+ if (modifiers.length > 3) return false;
1036
+ if (regexp[regexp.length - modifiers.length - 1] !== "/") return false;
1037
+ }
1038
+ return true;
1039
+ }
1040
+ function constructJavascriptRegExp(data) {
1041
+ var regexp = data, tail = /\/([gim]*)$/.exec(data), modifiers = "";
1042
+ if (regexp[0] === "/") {
1043
+ if (tail) modifiers = tail[1];
1044
+ regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
1045
+ }
1046
+ return new RegExp(regexp, modifiers);
1047
+ }
1048
+ function representJavascriptRegExp(object) {
1049
+ var result = "/" + object.source + "/";
1050
+ if (object.global) result += "g";
1051
+ if (object.multiline) result += "m";
1052
+ if (object.ignoreCase) result += "i";
1053
+ return result;
1054
+ }
1055
+ function isRegExp(object) {
1056
+ return Object.prototype.toString.call(object) === "[object RegExp]";
1057
+ }
1058
+ module2.exports = new Type("tag:yaml.org,2002:js/regexp", {
1059
+ kind: "scalar",
1060
+ resolve: resolveJavascriptRegExp,
1061
+ construct: constructJavascriptRegExp,
1062
+ predicate: isRegExp,
1063
+ represent: representJavascriptRegExp
1064
+ });
1065
+ }
1066
+ });
1067
+
1068
+ // node_modules/js-yaml/lib/js-yaml/type/js/function.js
1069
+ var require_function = __commonJS({
1070
+ "node_modules/js-yaml/lib/js-yaml/type/js/function.js"(exports2, module2) {
1071
+ "use strict";
1072
+ var esprima;
1073
+ try {
1074
+ _require = require;
1075
+ esprima = _require("esprima");
1076
+ } catch (_) {
1077
+ if (typeof window !== "undefined") esprima = window.esprima;
1078
+ }
1079
+ var _require;
1080
+ var Type = require_type();
1081
+ function resolveJavascriptFunction(data) {
1082
+ if (data === null) return false;
1083
+ try {
1084
+ var source = "(" + data + ")", ast = esprima.parse(source, { range: true });
1085
+ if (ast.type !== "Program" || ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement" || ast.body[0].expression.type !== "ArrowFunctionExpression" && ast.body[0].expression.type !== "FunctionExpression") {
1086
+ return false;
1087
+ }
1088
+ return true;
1089
+ } catch (err) {
1090
+ return false;
1091
+ }
1092
+ }
1093
+ function constructJavascriptFunction(data) {
1094
+ var source = "(" + data + ")", ast = esprima.parse(source, { range: true }), params = [], body;
1095
+ if (ast.type !== "Program" || ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement" || ast.body[0].expression.type !== "ArrowFunctionExpression" && ast.body[0].expression.type !== "FunctionExpression") {
1096
+ throw new Error("Failed to resolve function");
1097
+ }
1098
+ ast.body[0].expression.params.forEach(function(param) {
1099
+ params.push(param.name);
1100
+ });
1101
+ body = ast.body[0].expression.body.range;
1102
+ if (ast.body[0].expression.body.type === "BlockStatement") {
1103
+ return new Function(params, source.slice(body[0] + 1, body[1] - 1));
1104
+ }
1105
+ return new Function(params, "return " + source.slice(body[0], body[1]));
1106
+ }
1107
+ function representJavascriptFunction(object) {
1108
+ return object.toString();
1109
+ }
1110
+ function isFunction(object) {
1111
+ return Object.prototype.toString.call(object) === "[object Function]";
1112
+ }
1113
+ module2.exports = new Type("tag:yaml.org,2002:js/function", {
1114
+ kind: "scalar",
1115
+ resolve: resolveJavascriptFunction,
1116
+ construct: constructJavascriptFunction,
1117
+ predicate: isFunction,
1118
+ represent: representJavascriptFunction
1119
+ });
1120
+ }
1121
+ });
1122
+
1123
+ // node_modules/js-yaml/lib/js-yaml/schema/default_full.js
1124
+ var require_default_full = __commonJS({
1125
+ "node_modules/js-yaml/lib/js-yaml/schema/default_full.js"(exports2, module2) {
1126
+ "use strict";
1127
+ var Schema = require_schema();
1128
+ module2.exports = Schema.DEFAULT = new Schema({
1129
+ include: [
1130
+ require_default_safe()
1131
+ ],
1132
+ explicit: [
1133
+ require_undefined(),
1134
+ require_regexp(),
1135
+ require_function()
1136
+ ]
1137
+ });
1138
+ }
1139
+ });
1140
+
1141
+ // node_modules/js-yaml/lib/js-yaml/loader.js
1142
+ var require_loader = __commonJS({
1143
+ "node_modules/js-yaml/lib/js-yaml/loader.js"(exports2, module2) {
1144
+ "use strict";
1145
+ var common = require_common();
1146
+ var YAMLException = require_exception();
1147
+ var Mark = require_mark();
1148
+ var DEFAULT_SAFE_SCHEMA = require_default_safe();
1149
+ var DEFAULT_FULL_SCHEMA = require_default_full();
1150
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
1151
+ var CONTEXT_FLOW_IN = 1;
1152
+ var CONTEXT_FLOW_OUT = 2;
1153
+ var CONTEXT_BLOCK_IN = 3;
1154
+ var CONTEXT_BLOCK_OUT = 4;
1155
+ var CHOMPING_CLIP = 1;
1156
+ var CHOMPING_STRIP = 2;
1157
+ var CHOMPING_KEEP = 3;
1158
+ var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
1159
+ var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
1160
+ var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
1161
+ var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
1162
+ var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
1163
+ function _class(obj) {
1164
+ return Object.prototype.toString.call(obj);
1165
+ }
1166
+ function is_EOL(c) {
1167
+ return c === 10 || c === 13;
1168
+ }
1169
+ function is_WHITE_SPACE(c) {
1170
+ return c === 9 || c === 32;
1171
+ }
1172
+ function is_WS_OR_EOL(c) {
1173
+ return c === 9 || c === 32 || c === 10 || c === 13;
1174
+ }
1175
+ function is_FLOW_INDICATOR(c) {
1176
+ return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
1177
+ }
1178
+ function fromHexCode(c) {
1179
+ var lc;
1180
+ if (48 <= c && c <= 57) {
1181
+ return c - 48;
1182
+ }
1183
+ lc = c | 32;
1184
+ if (97 <= lc && lc <= 102) {
1185
+ return lc - 97 + 10;
1186
+ }
1187
+ return -1;
1188
+ }
1189
+ function escapedHexLen(c) {
1190
+ if (c === 120) {
1191
+ return 2;
1192
+ }
1193
+ if (c === 117) {
1194
+ return 4;
1195
+ }
1196
+ if (c === 85) {
1197
+ return 8;
1198
+ }
1199
+ return 0;
1200
+ }
1201
+ function fromDecimalCode(c) {
1202
+ if (48 <= c && c <= 57) {
1203
+ return c - 48;
1204
+ }
1205
+ return -1;
1206
+ }
1207
+ function simpleEscapeSequence(c) {
1208
+ 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" : "";
1209
+ }
1210
+ function charFromCodepoint(c) {
1211
+ if (c <= 65535) {
1212
+ return String.fromCharCode(c);
1213
+ }
1214
+ return String.fromCharCode(
1215
+ (c - 65536 >> 10) + 55296,
1216
+ (c - 65536 & 1023) + 56320
1217
+ );
1218
+ }
1219
+ function setProperty(object, key, value) {
1220
+ if (key === "__proto__") {
1221
+ Object.defineProperty(object, key, {
1222
+ configurable: true,
1223
+ enumerable: true,
1224
+ writable: true,
1225
+ value
1226
+ });
1227
+ } else {
1228
+ object[key] = value;
1229
+ }
1230
+ }
1231
+ var simpleEscapeCheck = new Array(256);
1232
+ var simpleEscapeMap = new Array(256);
1233
+ for (i = 0; i < 256; i++) {
1234
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
1235
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
1236
+ }
1237
+ var i;
1238
+ function State(input, options) {
1239
+ this.input = input;
1240
+ this.filename = options["filename"] || null;
1241
+ this.schema = options["schema"] || DEFAULT_FULL_SCHEMA;
1242
+ this.onWarning = options["onWarning"] || null;
1243
+ this.legacy = options["legacy"] || false;
1244
+ this.json = options["json"] || false;
1245
+ this.listener = options["listener"] || null;
1246
+ this.implicitTypes = this.schema.compiledImplicit;
1247
+ this.typeMap = this.schema.compiledTypeMap;
1248
+ this.length = input.length;
1249
+ this.position = 0;
1250
+ this.line = 0;
1251
+ this.lineStart = 0;
1252
+ this.lineIndent = 0;
1253
+ this.documents = [];
1254
+ }
1255
+ function generateError(state, message) {
1256
+ return new YAMLException(
1257
+ message,
1258
+ new Mark(state.filename, state.input, state.position, state.line, state.position - state.lineStart)
1259
+ );
1260
+ }
1261
+ function throwError(state, message) {
1262
+ throw generateError(state, message);
1263
+ }
1264
+ function throwWarning(state, message) {
1265
+ if (state.onWarning) {
1266
+ state.onWarning.call(null, generateError(state, message));
1267
+ }
1268
+ }
1269
+ var directiveHandlers = {
1270
+ YAML: function handleYamlDirective(state, name, args) {
1271
+ var match, major, minor;
1272
+ if (state.version !== null) {
1273
+ throwError(state, "duplication of %YAML directive");
1274
+ }
1275
+ if (args.length !== 1) {
1276
+ throwError(state, "YAML directive accepts exactly one argument");
1277
+ }
1278
+ match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1279
+ if (match === null) {
1280
+ throwError(state, "ill-formed argument of the YAML directive");
1281
+ }
1282
+ major = parseInt(match[1], 10);
1283
+ minor = parseInt(match[2], 10);
1284
+ if (major !== 1) {
1285
+ throwError(state, "unacceptable YAML version of the document");
1286
+ }
1287
+ state.version = args[0];
1288
+ state.checkLineBreaks = minor < 2;
1289
+ if (minor !== 1 && minor !== 2) {
1290
+ throwWarning(state, "unsupported YAML version of the document");
1291
+ }
1292
+ },
1293
+ TAG: function handleTagDirective(state, name, args) {
1294
+ var handle, prefix;
1295
+ if (args.length !== 2) {
1296
+ throwError(state, "TAG directive accepts exactly two arguments");
1297
+ }
1298
+ handle = args[0];
1299
+ prefix = args[1];
1300
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
1301
+ throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
1302
+ }
1303
+ if (_hasOwnProperty.call(state.tagMap, handle)) {
1304
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1305
+ }
1306
+ if (!PATTERN_TAG_URI.test(prefix)) {
1307
+ throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
1308
+ }
1309
+ state.tagMap[handle] = prefix;
1310
+ }
1311
+ };
1312
+ function captureSegment(state, start, end, checkJson) {
1313
+ var _position, _length, _character, _result;
1314
+ if (start < end) {
1315
+ _result = state.input.slice(start, end);
1316
+ if (checkJson) {
1317
+ for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
1318
+ _character = _result.charCodeAt(_position);
1319
+ if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
1320
+ throwError(state, "expected valid JSON character");
1321
+ }
1322
+ }
1323
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1324
+ throwError(state, "the stream contains non-printable characters");
1325
+ }
1326
+ state.result += _result;
1327
+ }
1328
+ }
1329
+ function mergeMappings(state, destination, source, overridableKeys) {
1330
+ var sourceKeys, key, index, quantity;
1331
+ if (!common.isObject(source)) {
1332
+ throwError(state, "cannot merge mappings; the provided source object is unacceptable");
1333
+ }
1334
+ sourceKeys = Object.keys(source);
1335
+ for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1336
+ key = sourceKeys[index];
1337
+ if (!_hasOwnProperty.call(destination, key)) {
1338
+ setProperty(destination, key, source[key]);
1339
+ overridableKeys[key] = true;
1340
+ }
1341
+ }
1342
+ }
1343
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
1344
+ var index, quantity;
1345
+ if (Array.isArray(keyNode)) {
1346
+ keyNode = Array.prototype.slice.call(keyNode);
1347
+ for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
1348
+ if (Array.isArray(keyNode[index])) {
1349
+ throwError(state, "nested arrays are not supported inside keys");
1350
+ }
1351
+ if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
1352
+ keyNode[index] = "[object Object]";
1353
+ }
1354
+ }
1355
+ }
1356
+ if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
1357
+ keyNode = "[object Object]";
1358
+ }
1359
+ keyNode = String(keyNode);
1360
+ if (_result === null) {
1361
+ _result = {};
1362
+ }
1363
+ if (keyTag === "tag:yaml.org,2002:merge") {
1364
+ if (Array.isArray(valueNode)) {
1365
+ for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1366
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
1367
+ }
1368
+ } else {
1369
+ mergeMappings(state, _result, valueNode, overridableKeys);
1370
+ }
1371
+ } else {
1372
+ if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
1373
+ state.line = startLine || state.line;
1374
+ state.position = startPos || state.position;
1375
+ throwError(state, "duplicated mapping key");
1376
+ }
1377
+ setProperty(_result, keyNode, valueNode);
1378
+ delete overridableKeys[keyNode];
1379
+ }
1380
+ return _result;
1381
+ }
1382
+ function readLineBreak(state) {
1383
+ var ch;
1384
+ ch = state.input.charCodeAt(state.position);
1385
+ if (ch === 10) {
1386
+ state.position++;
1387
+ } else if (ch === 13) {
1388
+ state.position++;
1389
+ if (state.input.charCodeAt(state.position) === 10) {
1390
+ state.position++;
1391
+ }
1392
+ } else {
1393
+ throwError(state, "a line break is expected");
1394
+ }
1395
+ state.line += 1;
1396
+ state.lineStart = state.position;
1397
+ }
1398
+ function skipSeparationSpace(state, allowComments, checkIndent) {
1399
+ var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
1400
+ while (ch !== 0) {
1401
+ while (is_WHITE_SPACE(ch)) {
1402
+ ch = state.input.charCodeAt(++state.position);
1403
+ }
1404
+ if (allowComments && ch === 35) {
1405
+ do {
1406
+ ch = state.input.charCodeAt(++state.position);
1407
+ } while (ch !== 10 && ch !== 13 && ch !== 0);
1408
+ }
1409
+ if (is_EOL(ch)) {
1410
+ readLineBreak(state);
1411
+ ch = state.input.charCodeAt(state.position);
1412
+ lineBreaks++;
1413
+ state.lineIndent = 0;
1414
+ while (ch === 32) {
1415
+ state.lineIndent++;
1416
+ ch = state.input.charCodeAt(++state.position);
1417
+ }
1418
+ } else {
1419
+ break;
1420
+ }
1421
+ }
1422
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1423
+ throwWarning(state, "deficient indentation");
1424
+ }
1425
+ return lineBreaks;
1426
+ }
1427
+ function testDocumentSeparator(state) {
1428
+ var _position = state.position, ch;
1429
+ ch = state.input.charCodeAt(_position);
1430
+ if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
1431
+ _position += 3;
1432
+ ch = state.input.charCodeAt(_position);
1433
+ if (ch === 0 || is_WS_OR_EOL(ch)) {
1434
+ return true;
1435
+ }
1436
+ }
1437
+ return false;
1438
+ }
1439
+ function writeFoldedLines(state, count) {
1440
+ if (count === 1) {
1441
+ state.result += " ";
1442
+ } else if (count > 1) {
1443
+ state.result += common.repeat("\n", count - 1);
1444
+ }
1445
+ }
1446
+ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1447
+ var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
1448
+ ch = state.input.charCodeAt(state.position);
1449
+ 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) {
1450
+ return false;
1451
+ }
1452
+ if (ch === 63 || ch === 45) {
1453
+ following = state.input.charCodeAt(state.position + 1);
1454
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1455
+ return false;
1456
+ }
1457
+ }
1458
+ state.kind = "scalar";
1459
+ state.result = "";
1460
+ captureStart = captureEnd = state.position;
1461
+ hasPendingContent = false;
1462
+ while (ch !== 0) {
1463
+ if (ch === 58) {
1464
+ following = state.input.charCodeAt(state.position + 1);
1465
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1466
+ break;
1467
+ }
1468
+ } else if (ch === 35) {
1469
+ preceding = state.input.charCodeAt(state.position - 1);
1470
+ if (is_WS_OR_EOL(preceding)) {
1471
+ break;
1472
+ }
1473
+ } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1474
+ break;
1475
+ } else if (is_EOL(ch)) {
1476
+ _line = state.line;
1477
+ _lineStart = state.lineStart;
1478
+ _lineIndent = state.lineIndent;
1479
+ skipSeparationSpace(state, false, -1);
1480
+ if (state.lineIndent >= nodeIndent) {
1481
+ hasPendingContent = true;
1482
+ ch = state.input.charCodeAt(state.position);
1483
+ continue;
1484
+ } else {
1485
+ state.position = captureEnd;
1486
+ state.line = _line;
1487
+ state.lineStart = _lineStart;
1488
+ state.lineIndent = _lineIndent;
1489
+ break;
1490
+ }
1491
+ }
1492
+ if (hasPendingContent) {
1493
+ captureSegment(state, captureStart, captureEnd, false);
1494
+ writeFoldedLines(state, state.line - _line);
1495
+ captureStart = captureEnd = state.position;
1496
+ hasPendingContent = false;
1497
+ }
1498
+ if (!is_WHITE_SPACE(ch)) {
1499
+ captureEnd = state.position + 1;
1500
+ }
1501
+ ch = state.input.charCodeAt(++state.position);
1502
+ }
1503
+ captureSegment(state, captureStart, captureEnd, false);
1504
+ if (state.result) {
1505
+ return true;
1506
+ }
1507
+ state.kind = _kind;
1508
+ state.result = _result;
1509
+ return false;
1510
+ }
1511
+ function readSingleQuotedScalar(state, nodeIndent) {
1512
+ var ch, captureStart, captureEnd;
1513
+ ch = state.input.charCodeAt(state.position);
1514
+ if (ch !== 39) {
1515
+ return false;
1516
+ }
1517
+ state.kind = "scalar";
1518
+ state.result = "";
1519
+ state.position++;
1520
+ captureStart = captureEnd = state.position;
1521
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1522
+ if (ch === 39) {
1523
+ captureSegment(state, captureStart, state.position, true);
1524
+ ch = state.input.charCodeAt(++state.position);
1525
+ if (ch === 39) {
1526
+ captureStart = state.position;
1527
+ state.position++;
1528
+ captureEnd = state.position;
1529
+ } else {
1530
+ return true;
1531
+ }
1532
+ } else if (is_EOL(ch)) {
1533
+ captureSegment(state, captureStart, captureEnd, true);
1534
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1535
+ captureStart = captureEnd = state.position;
1536
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1537
+ throwError(state, "unexpected end of the document within a single quoted scalar");
1538
+ } else {
1539
+ state.position++;
1540
+ captureEnd = state.position;
1541
+ }
1542
+ }
1543
+ throwError(state, "unexpected end of the stream within a single quoted scalar");
1544
+ }
1545
+ function readDoubleQuotedScalar(state, nodeIndent) {
1546
+ var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
1547
+ ch = state.input.charCodeAt(state.position);
1548
+ if (ch !== 34) {
1549
+ return false;
1550
+ }
1551
+ state.kind = "scalar";
1552
+ state.result = "";
1553
+ state.position++;
1554
+ captureStart = captureEnd = state.position;
1555
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1556
+ if (ch === 34) {
1557
+ captureSegment(state, captureStart, state.position, true);
1558
+ state.position++;
1559
+ return true;
1560
+ } else if (ch === 92) {
1561
+ captureSegment(state, captureStart, state.position, true);
1562
+ ch = state.input.charCodeAt(++state.position);
1563
+ if (is_EOL(ch)) {
1564
+ skipSeparationSpace(state, false, nodeIndent);
1565
+ } else if (ch < 256 && simpleEscapeCheck[ch]) {
1566
+ state.result += simpleEscapeMap[ch];
1567
+ state.position++;
1568
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
1569
+ hexLength = tmp;
1570
+ hexResult = 0;
1571
+ for (; hexLength > 0; hexLength--) {
1572
+ ch = state.input.charCodeAt(++state.position);
1573
+ if ((tmp = fromHexCode(ch)) >= 0) {
1574
+ hexResult = (hexResult << 4) + tmp;
1575
+ } else {
1576
+ throwError(state, "expected hexadecimal character");
1577
+ }
1578
+ }
1579
+ state.result += charFromCodepoint(hexResult);
1580
+ state.position++;
1581
+ } else {
1582
+ throwError(state, "unknown escape sequence");
1583
+ }
1584
+ captureStart = captureEnd = state.position;
1585
+ } else if (is_EOL(ch)) {
1586
+ captureSegment(state, captureStart, captureEnd, true);
1587
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1588
+ captureStart = captureEnd = state.position;
1589
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1590
+ throwError(state, "unexpected end of the document within a double quoted scalar");
1591
+ } else {
1592
+ state.position++;
1593
+ captureEnd = state.position;
1594
+ }
1595
+ }
1596
+ throwError(state, "unexpected end of the stream within a double quoted scalar");
1597
+ }
1598
+ function readFlowCollection(state, nodeIndent) {
1599
+ var readNext = true, _line, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = {}, keyNode, keyTag, valueNode, ch;
1600
+ ch = state.input.charCodeAt(state.position);
1601
+ if (ch === 91) {
1602
+ terminator = 93;
1603
+ isMapping = false;
1604
+ _result = [];
1605
+ } else if (ch === 123) {
1606
+ terminator = 125;
1607
+ isMapping = true;
1608
+ _result = {};
1609
+ } else {
1610
+ return false;
1611
+ }
1612
+ if (state.anchor !== null) {
1613
+ state.anchorMap[state.anchor] = _result;
1614
+ }
1615
+ ch = state.input.charCodeAt(++state.position);
1616
+ while (ch !== 0) {
1617
+ skipSeparationSpace(state, true, nodeIndent);
1618
+ ch = state.input.charCodeAt(state.position);
1619
+ if (ch === terminator) {
1620
+ state.position++;
1621
+ state.tag = _tag;
1622
+ state.anchor = _anchor;
1623
+ state.kind = isMapping ? "mapping" : "sequence";
1624
+ state.result = _result;
1625
+ return true;
1626
+ } else if (!readNext) {
1627
+ throwError(state, "missed comma between flow collection entries");
1628
+ }
1629
+ keyTag = keyNode = valueNode = null;
1630
+ isPair = isExplicitPair = false;
1631
+ if (ch === 63) {
1632
+ following = state.input.charCodeAt(state.position + 1);
1633
+ if (is_WS_OR_EOL(following)) {
1634
+ isPair = isExplicitPair = true;
1635
+ state.position++;
1636
+ skipSeparationSpace(state, true, nodeIndent);
1637
+ }
1638
+ }
1639
+ _line = state.line;
1640
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1641
+ keyTag = state.tag;
1642
+ keyNode = state.result;
1643
+ skipSeparationSpace(state, true, nodeIndent);
1644
+ ch = state.input.charCodeAt(state.position);
1645
+ if ((isExplicitPair || state.line === _line) && ch === 58) {
1646
+ isPair = true;
1647
+ ch = state.input.charCodeAt(++state.position);
1648
+ skipSeparationSpace(state, true, nodeIndent);
1649
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1650
+ valueNode = state.result;
1651
+ }
1652
+ if (isMapping) {
1653
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
1654
+ } else if (isPair) {
1655
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
1656
+ } else {
1657
+ _result.push(keyNode);
1658
+ }
1659
+ skipSeparationSpace(state, true, nodeIndent);
1660
+ ch = state.input.charCodeAt(state.position);
1661
+ if (ch === 44) {
1662
+ readNext = true;
1663
+ ch = state.input.charCodeAt(++state.position);
1664
+ } else {
1665
+ readNext = false;
1666
+ }
1667
+ }
1668
+ throwError(state, "unexpected end of the stream within a flow collection");
1669
+ }
1670
+ function readBlockScalar(state, nodeIndent) {
1671
+ var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
1672
+ ch = state.input.charCodeAt(state.position);
1673
+ if (ch === 124) {
1674
+ folding = false;
1675
+ } else if (ch === 62) {
1676
+ folding = true;
1677
+ } else {
1678
+ return false;
1679
+ }
1680
+ state.kind = "scalar";
1681
+ state.result = "";
1682
+ while (ch !== 0) {
1683
+ ch = state.input.charCodeAt(++state.position);
1684
+ if (ch === 43 || ch === 45) {
1685
+ if (CHOMPING_CLIP === chomping) {
1686
+ chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
1687
+ } else {
1688
+ throwError(state, "repeat of a chomping mode identifier");
1689
+ }
1690
+ } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1691
+ if (tmp === 0) {
1692
+ throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
1693
+ } else if (!detectedIndent) {
1694
+ textIndent = nodeIndent + tmp - 1;
1695
+ detectedIndent = true;
1696
+ } else {
1697
+ throwError(state, "repeat of an indentation width identifier");
1698
+ }
1699
+ } else {
1700
+ break;
1701
+ }
1702
+ }
1703
+ if (is_WHITE_SPACE(ch)) {
1704
+ do {
1705
+ ch = state.input.charCodeAt(++state.position);
1706
+ } while (is_WHITE_SPACE(ch));
1707
+ if (ch === 35) {
1708
+ do {
1709
+ ch = state.input.charCodeAt(++state.position);
1710
+ } while (!is_EOL(ch) && ch !== 0);
1711
+ }
1712
+ }
1713
+ while (ch !== 0) {
1714
+ readLineBreak(state);
1715
+ state.lineIndent = 0;
1716
+ ch = state.input.charCodeAt(state.position);
1717
+ while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
1718
+ state.lineIndent++;
1719
+ ch = state.input.charCodeAt(++state.position);
1720
+ }
1721
+ if (!detectedIndent && state.lineIndent > textIndent) {
1722
+ textIndent = state.lineIndent;
1723
+ }
1724
+ if (is_EOL(ch)) {
1725
+ emptyLines++;
1726
+ continue;
1727
+ }
1728
+ if (state.lineIndent < textIndent) {
1729
+ if (chomping === CHOMPING_KEEP) {
1730
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1731
+ } else if (chomping === CHOMPING_CLIP) {
1732
+ if (didReadContent) {
1733
+ state.result += "\n";
1734
+ }
1735
+ }
1736
+ break;
1737
+ }
1738
+ if (folding) {
1739
+ if (is_WHITE_SPACE(ch)) {
1740
+ atMoreIndented = true;
1741
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1742
+ } else if (atMoreIndented) {
1743
+ atMoreIndented = false;
1744
+ state.result += common.repeat("\n", emptyLines + 1);
1745
+ } else if (emptyLines === 0) {
1746
+ if (didReadContent) {
1747
+ state.result += " ";
1748
+ }
1749
+ } else {
1750
+ state.result += common.repeat("\n", emptyLines);
1751
+ }
1752
+ } else {
1753
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1754
+ }
1755
+ didReadContent = true;
1756
+ detectedIndent = true;
1757
+ emptyLines = 0;
1758
+ captureStart = state.position;
1759
+ while (!is_EOL(ch) && ch !== 0) {
1760
+ ch = state.input.charCodeAt(++state.position);
1761
+ }
1762
+ captureSegment(state, captureStart, state.position, false);
1763
+ }
1764
+ return true;
1765
+ }
1766
+ function readBlockSequence(state, nodeIndent) {
1767
+ var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
1768
+ if (state.anchor !== null) {
1769
+ state.anchorMap[state.anchor] = _result;
1770
+ }
1771
+ ch = state.input.charCodeAt(state.position);
1772
+ while (ch !== 0) {
1773
+ if (ch !== 45) {
1774
+ break;
1775
+ }
1776
+ following = state.input.charCodeAt(state.position + 1);
1777
+ if (!is_WS_OR_EOL(following)) {
1778
+ break;
1779
+ }
1780
+ detected = true;
1781
+ state.position++;
1782
+ if (skipSeparationSpace(state, true, -1)) {
1783
+ if (state.lineIndent <= nodeIndent) {
1784
+ _result.push(null);
1785
+ ch = state.input.charCodeAt(state.position);
1786
+ continue;
1787
+ }
1788
+ }
1789
+ _line = state.line;
1790
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1791
+ _result.push(state.result);
1792
+ skipSeparationSpace(state, true, -1);
1793
+ ch = state.input.charCodeAt(state.position);
1794
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1795
+ throwError(state, "bad indentation of a sequence entry");
1796
+ } else if (state.lineIndent < nodeIndent) {
1797
+ break;
1798
+ }
1799
+ }
1800
+ if (detected) {
1801
+ state.tag = _tag;
1802
+ state.anchor = _anchor;
1803
+ state.kind = "sequence";
1804
+ state.result = _result;
1805
+ return true;
1806
+ }
1807
+ return false;
1808
+ }
1809
+ function readBlockMapping(state, nodeIndent, flowIndent) {
1810
+ var following, allowCompact, _line, _pos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = {}, keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
1811
+ if (state.anchor !== null) {
1812
+ state.anchorMap[state.anchor] = _result;
1813
+ }
1814
+ ch = state.input.charCodeAt(state.position);
1815
+ while (ch !== 0) {
1816
+ following = state.input.charCodeAt(state.position + 1);
1817
+ _line = state.line;
1818
+ _pos = state.position;
1819
+ if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
1820
+ if (ch === 63) {
1821
+ if (atExplicitKey) {
1822
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1823
+ keyTag = keyNode = valueNode = null;
1824
+ }
1825
+ detected = true;
1826
+ atExplicitKey = true;
1827
+ allowCompact = true;
1828
+ } else if (atExplicitKey) {
1829
+ atExplicitKey = false;
1830
+ allowCompact = true;
1831
+ } else {
1832
+ throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
1833
+ }
1834
+ state.position += 1;
1835
+ ch = following;
1836
+ } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1837
+ if (state.line === _line) {
1838
+ ch = state.input.charCodeAt(state.position);
1839
+ while (is_WHITE_SPACE(ch)) {
1840
+ ch = state.input.charCodeAt(++state.position);
1841
+ }
1842
+ if (ch === 58) {
1843
+ ch = state.input.charCodeAt(++state.position);
1844
+ if (!is_WS_OR_EOL(ch)) {
1845
+ throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
1846
+ }
1847
+ if (atExplicitKey) {
1848
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1849
+ keyTag = keyNode = valueNode = null;
1850
+ }
1851
+ detected = true;
1852
+ atExplicitKey = false;
1853
+ allowCompact = false;
1854
+ keyTag = state.tag;
1855
+ keyNode = state.result;
1856
+ } else if (detected) {
1857
+ throwError(state, "can not read an implicit mapping pair; a colon is missed");
1858
+ } else {
1859
+ state.tag = _tag;
1860
+ state.anchor = _anchor;
1861
+ return true;
1862
+ }
1863
+ } else if (detected) {
1864
+ throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
1865
+ } else {
1866
+ state.tag = _tag;
1867
+ state.anchor = _anchor;
1868
+ return true;
1869
+ }
1870
+ } else {
1871
+ break;
1872
+ }
1873
+ if (state.line === _line || state.lineIndent > nodeIndent) {
1874
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
1875
+ if (atExplicitKey) {
1876
+ keyNode = state.result;
1877
+ } else {
1878
+ valueNode = state.result;
1879
+ }
1880
+ }
1881
+ if (!atExplicitKey) {
1882
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
1883
+ keyTag = keyNode = valueNode = null;
1884
+ }
1885
+ skipSeparationSpace(state, true, -1);
1886
+ ch = state.input.charCodeAt(state.position);
1887
+ }
1888
+ if (state.lineIndent > nodeIndent && ch !== 0) {
1889
+ throwError(state, "bad indentation of a mapping entry");
1890
+ } else if (state.lineIndent < nodeIndent) {
1891
+ break;
1892
+ }
1893
+ }
1894
+ if (atExplicitKey) {
1895
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1896
+ }
1897
+ if (detected) {
1898
+ state.tag = _tag;
1899
+ state.anchor = _anchor;
1900
+ state.kind = "mapping";
1901
+ state.result = _result;
1902
+ }
1903
+ return detected;
1904
+ }
1905
+ function readTagProperty(state) {
1906
+ var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
1907
+ ch = state.input.charCodeAt(state.position);
1908
+ if (ch !== 33) return false;
1909
+ if (state.tag !== null) {
1910
+ throwError(state, "duplication of a tag property");
1911
+ }
1912
+ ch = state.input.charCodeAt(++state.position);
1913
+ if (ch === 60) {
1914
+ isVerbatim = true;
1915
+ ch = state.input.charCodeAt(++state.position);
1916
+ } else if (ch === 33) {
1917
+ isNamed = true;
1918
+ tagHandle = "!!";
1919
+ ch = state.input.charCodeAt(++state.position);
1920
+ } else {
1921
+ tagHandle = "!";
1922
+ }
1923
+ _position = state.position;
1924
+ if (isVerbatim) {
1925
+ do {
1926
+ ch = state.input.charCodeAt(++state.position);
1927
+ } while (ch !== 0 && ch !== 62);
1928
+ if (state.position < state.length) {
1929
+ tagName = state.input.slice(_position, state.position);
1930
+ ch = state.input.charCodeAt(++state.position);
1931
+ } else {
1932
+ throwError(state, "unexpected end of the stream within a verbatim tag");
1933
+ }
1934
+ } else {
1935
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1936
+ if (ch === 33) {
1937
+ if (!isNamed) {
1938
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
1939
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
1940
+ throwError(state, "named tag handle cannot contain such characters");
1941
+ }
1942
+ isNamed = true;
1943
+ _position = state.position + 1;
1944
+ } else {
1945
+ throwError(state, "tag suffix cannot contain exclamation marks");
1946
+ }
1947
+ }
1948
+ ch = state.input.charCodeAt(++state.position);
1949
+ }
1950
+ tagName = state.input.slice(_position, state.position);
1951
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) {
1952
+ throwError(state, "tag suffix cannot contain flow indicator characters");
1953
+ }
1954
+ }
1955
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) {
1956
+ throwError(state, "tag name cannot contain such characters: " + tagName);
1957
+ }
1958
+ if (isVerbatim) {
1959
+ state.tag = tagName;
1960
+ } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
1961
+ state.tag = state.tagMap[tagHandle] + tagName;
1962
+ } else if (tagHandle === "!") {
1963
+ state.tag = "!" + tagName;
1964
+ } else if (tagHandle === "!!") {
1965
+ state.tag = "tag:yaml.org,2002:" + tagName;
1966
+ } else {
1967
+ throwError(state, 'undeclared tag handle "' + tagHandle + '"');
1968
+ }
1969
+ return true;
1970
+ }
1971
+ function readAnchorProperty(state) {
1972
+ var _position, ch;
1973
+ ch = state.input.charCodeAt(state.position);
1974
+ if (ch !== 38) return false;
1975
+ if (state.anchor !== null) {
1976
+ throwError(state, "duplication of an anchor property");
1977
+ }
1978
+ ch = state.input.charCodeAt(++state.position);
1979
+ _position = state.position;
1980
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1981
+ ch = state.input.charCodeAt(++state.position);
1982
+ }
1983
+ if (state.position === _position) {
1984
+ throwError(state, "name of an anchor node must contain at least one character");
1985
+ }
1986
+ state.anchor = state.input.slice(_position, state.position);
1987
+ return true;
1988
+ }
1989
+ function readAlias(state) {
1990
+ var _position, alias, ch;
1991
+ ch = state.input.charCodeAt(state.position);
1992
+ if (ch !== 42) return false;
1993
+ ch = state.input.charCodeAt(++state.position);
1994
+ _position = state.position;
1995
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1996
+ ch = state.input.charCodeAt(++state.position);
1997
+ }
1998
+ if (state.position === _position) {
1999
+ throwError(state, "name of an alias node must contain at least one character");
2000
+ }
2001
+ alias = state.input.slice(_position, state.position);
2002
+ if (!_hasOwnProperty.call(state.anchorMap, alias)) {
2003
+ throwError(state, 'unidentified alias "' + alias + '"');
2004
+ }
2005
+ state.result = state.anchorMap[alias];
2006
+ skipSeparationSpace(state, true, -1);
2007
+ return true;
2008
+ }
2009
+ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
2010
+ var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, type, flowIndent, blockIndent;
2011
+ if (state.listener !== null) {
2012
+ state.listener("open", state);
2013
+ }
2014
+ state.tag = null;
2015
+ state.anchor = null;
2016
+ state.kind = null;
2017
+ state.result = null;
2018
+ allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
2019
+ if (allowToSeek) {
2020
+ if (skipSeparationSpace(state, true, -1)) {
2021
+ atNewLine = true;
2022
+ if (state.lineIndent > parentIndent) {
2023
+ indentStatus = 1;
2024
+ } else if (state.lineIndent === parentIndent) {
2025
+ indentStatus = 0;
2026
+ } else if (state.lineIndent < parentIndent) {
2027
+ indentStatus = -1;
2028
+ }
2029
+ }
2030
+ }
2031
+ if (indentStatus === 1) {
2032
+ while (readTagProperty(state) || readAnchorProperty(state)) {
2033
+ if (skipSeparationSpace(state, true, -1)) {
2034
+ atNewLine = true;
2035
+ allowBlockCollections = allowBlockStyles;
2036
+ if (state.lineIndent > parentIndent) {
2037
+ indentStatus = 1;
2038
+ } else if (state.lineIndent === parentIndent) {
2039
+ indentStatus = 0;
2040
+ } else if (state.lineIndent < parentIndent) {
2041
+ indentStatus = -1;
2042
+ }
2043
+ } else {
2044
+ allowBlockCollections = false;
2045
+ }
2046
+ }
2047
+ }
2048
+ if (allowBlockCollections) {
2049
+ allowBlockCollections = atNewLine || allowCompact;
2050
+ }
2051
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
2052
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
2053
+ flowIndent = parentIndent;
2054
+ } else {
2055
+ flowIndent = parentIndent + 1;
2056
+ }
2057
+ blockIndent = state.position - state.lineStart;
2058
+ if (indentStatus === 1) {
2059
+ if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
2060
+ hasContent = true;
2061
+ } else {
2062
+ if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
2063
+ hasContent = true;
2064
+ } else if (readAlias(state)) {
2065
+ hasContent = true;
2066
+ if (state.tag !== null || state.anchor !== null) {
2067
+ throwError(state, "alias node should not have any properties");
2068
+ }
2069
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
2070
+ hasContent = true;
2071
+ if (state.tag === null) {
2072
+ state.tag = "?";
2073
+ }
2074
+ }
2075
+ if (state.anchor !== null) {
2076
+ state.anchorMap[state.anchor] = state.result;
2077
+ }
2078
+ }
2079
+ } else if (indentStatus === 0) {
2080
+ hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
2081
+ }
2082
+ }
2083
+ if (state.tag !== null && state.tag !== "!") {
2084
+ if (state.tag === "?") {
2085
+ if (state.result !== null && state.kind !== "scalar") {
2086
+ throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
2087
+ }
2088
+ for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
2089
+ type = state.implicitTypes[typeIndex];
2090
+ if (type.resolve(state.result)) {
2091
+ state.result = type.construct(state.result);
2092
+ state.tag = type.tag;
2093
+ if (state.anchor !== null) {
2094
+ state.anchorMap[state.anchor] = state.result;
2095
+ }
2096
+ break;
2097
+ }
2098
+ }
2099
+ } else if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) {
2100
+ type = state.typeMap[state.kind || "fallback"][state.tag];
2101
+ if (state.result !== null && type.kind !== state.kind) {
2102
+ throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
2103
+ }
2104
+ if (!type.resolve(state.result)) {
2105
+ throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
2106
+ } else {
2107
+ state.result = type.construct(state.result);
2108
+ if (state.anchor !== null) {
2109
+ state.anchorMap[state.anchor] = state.result;
2110
+ }
2111
+ }
2112
+ } else {
2113
+ throwError(state, "unknown tag !<" + state.tag + ">");
2114
+ }
2115
+ }
2116
+ if (state.listener !== null) {
2117
+ state.listener("close", state);
2118
+ }
2119
+ return state.tag !== null || state.anchor !== null || hasContent;
2120
+ }
2121
+ function readDocument(state) {
2122
+ var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
2123
+ state.version = null;
2124
+ state.checkLineBreaks = state.legacy;
2125
+ state.tagMap = {};
2126
+ state.anchorMap = {};
2127
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2128
+ skipSeparationSpace(state, true, -1);
2129
+ ch = state.input.charCodeAt(state.position);
2130
+ if (state.lineIndent > 0 || ch !== 37) {
2131
+ break;
2132
+ }
2133
+ hasDirectives = true;
2134
+ ch = state.input.charCodeAt(++state.position);
2135
+ _position = state.position;
2136
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2137
+ ch = state.input.charCodeAt(++state.position);
2138
+ }
2139
+ directiveName = state.input.slice(_position, state.position);
2140
+ directiveArgs = [];
2141
+ if (directiveName.length < 1) {
2142
+ throwError(state, "directive name must not be less than one character in length");
2143
+ }
2144
+ while (ch !== 0) {
2145
+ while (is_WHITE_SPACE(ch)) {
2146
+ ch = state.input.charCodeAt(++state.position);
2147
+ }
2148
+ if (ch === 35) {
2149
+ do {
2150
+ ch = state.input.charCodeAt(++state.position);
2151
+ } while (ch !== 0 && !is_EOL(ch));
2152
+ break;
2153
+ }
2154
+ if (is_EOL(ch)) break;
2155
+ _position = state.position;
2156
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2157
+ ch = state.input.charCodeAt(++state.position);
2158
+ }
2159
+ directiveArgs.push(state.input.slice(_position, state.position));
2160
+ }
2161
+ if (ch !== 0) readLineBreak(state);
2162
+ if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
2163
+ directiveHandlers[directiveName](state, directiveName, directiveArgs);
2164
+ } else {
2165
+ throwWarning(state, 'unknown document directive "' + directiveName + '"');
2166
+ }
2167
+ }
2168
+ skipSeparationSpace(state, true, -1);
2169
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
2170
+ state.position += 3;
2171
+ skipSeparationSpace(state, true, -1);
2172
+ } else if (hasDirectives) {
2173
+ throwError(state, "directives end mark is expected");
2174
+ }
2175
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2176
+ skipSeparationSpace(state, true, -1);
2177
+ if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
2178
+ throwWarning(state, "non-ASCII line breaks are interpreted as content");
2179
+ }
2180
+ state.documents.push(state.result);
2181
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
2182
+ if (state.input.charCodeAt(state.position) === 46) {
2183
+ state.position += 3;
2184
+ skipSeparationSpace(state, true, -1);
2185
+ }
2186
+ return;
2187
+ }
2188
+ if (state.position < state.length - 1) {
2189
+ throwError(state, "end of the stream or a document separator is expected");
2190
+ } else {
2191
+ return;
2192
+ }
2193
+ }
2194
+ function loadDocuments(input, options) {
2195
+ input = String(input);
2196
+ options = options || {};
2197
+ if (input.length !== 0) {
2198
+ if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
2199
+ input += "\n";
2200
+ }
2201
+ if (input.charCodeAt(0) === 65279) {
2202
+ input = input.slice(1);
2203
+ }
2204
+ }
2205
+ var state = new State(input, options);
2206
+ var nullpos = input.indexOf("\0");
2207
+ if (nullpos !== -1) {
2208
+ state.position = nullpos;
2209
+ throwError(state, "null byte is not allowed in input");
2210
+ }
2211
+ state.input += "\0";
2212
+ while (state.input.charCodeAt(state.position) === 32) {
2213
+ state.lineIndent += 1;
2214
+ state.position += 1;
2215
+ }
2216
+ while (state.position < state.length - 1) {
2217
+ readDocument(state);
2218
+ }
2219
+ return state.documents;
2220
+ }
2221
+ function loadAll(input, iterator, options) {
2222
+ if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
2223
+ options = iterator;
2224
+ iterator = null;
2225
+ }
2226
+ var documents = loadDocuments(input, options);
2227
+ if (typeof iterator !== "function") {
2228
+ return documents;
2229
+ }
2230
+ for (var index = 0, length = documents.length; index < length; index += 1) {
2231
+ iterator(documents[index]);
2232
+ }
2233
+ }
2234
+ function load(input, options) {
2235
+ var documents = loadDocuments(input, options);
2236
+ if (documents.length === 0) {
2237
+ return void 0;
2238
+ } else if (documents.length === 1) {
2239
+ return documents[0];
2240
+ }
2241
+ throw new YAMLException("expected a single document in the stream, but found more");
2242
+ }
2243
+ function safeLoadAll(input, iterator, options) {
2244
+ if (typeof iterator === "object" && iterator !== null && typeof options === "undefined") {
2245
+ options = iterator;
2246
+ iterator = null;
2247
+ }
2248
+ return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2249
+ }
2250
+ function safeLoad(input, options) {
2251
+ return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2252
+ }
2253
+ module2.exports.loadAll = loadAll;
2254
+ module2.exports.load = load;
2255
+ module2.exports.safeLoadAll = safeLoadAll;
2256
+ module2.exports.safeLoad = safeLoad;
2257
+ }
2258
+ });
2259
+
2260
+ // node_modules/js-yaml/lib/js-yaml/dumper.js
2261
+ var require_dumper = __commonJS({
2262
+ "node_modules/js-yaml/lib/js-yaml/dumper.js"(exports2, module2) {
2263
+ "use strict";
2264
+ var common = require_common();
2265
+ var YAMLException = require_exception();
2266
+ var DEFAULT_FULL_SCHEMA = require_default_full();
2267
+ var DEFAULT_SAFE_SCHEMA = require_default_safe();
2268
+ var _toString = Object.prototype.toString;
2269
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
2270
+ var CHAR_TAB = 9;
2271
+ var CHAR_LINE_FEED = 10;
2272
+ var CHAR_CARRIAGE_RETURN = 13;
2273
+ var CHAR_SPACE = 32;
2274
+ var CHAR_EXCLAMATION = 33;
2275
+ var CHAR_DOUBLE_QUOTE = 34;
2276
+ var CHAR_SHARP = 35;
2277
+ var CHAR_PERCENT = 37;
2278
+ var CHAR_AMPERSAND = 38;
2279
+ var CHAR_SINGLE_QUOTE = 39;
2280
+ var CHAR_ASTERISK = 42;
2281
+ var CHAR_COMMA = 44;
2282
+ var CHAR_MINUS = 45;
2283
+ var CHAR_COLON = 58;
2284
+ var CHAR_EQUALS = 61;
2285
+ var CHAR_GREATER_THAN = 62;
2286
+ var CHAR_QUESTION = 63;
2287
+ var CHAR_COMMERCIAL_AT = 64;
2288
+ var CHAR_LEFT_SQUARE_BRACKET = 91;
2289
+ var CHAR_RIGHT_SQUARE_BRACKET = 93;
2290
+ var CHAR_GRAVE_ACCENT = 96;
2291
+ var CHAR_LEFT_CURLY_BRACKET = 123;
2292
+ var CHAR_VERTICAL_LINE = 124;
2293
+ var CHAR_RIGHT_CURLY_BRACKET = 125;
2294
+ var ESCAPE_SEQUENCES = {};
2295
+ ESCAPE_SEQUENCES[0] = "\\0";
2296
+ ESCAPE_SEQUENCES[7] = "\\a";
2297
+ ESCAPE_SEQUENCES[8] = "\\b";
2298
+ ESCAPE_SEQUENCES[9] = "\\t";
2299
+ ESCAPE_SEQUENCES[10] = "\\n";
2300
+ ESCAPE_SEQUENCES[11] = "\\v";
2301
+ ESCAPE_SEQUENCES[12] = "\\f";
2302
+ ESCAPE_SEQUENCES[13] = "\\r";
2303
+ ESCAPE_SEQUENCES[27] = "\\e";
2304
+ ESCAPE_SEQUENCES[34] = '\\"';
2305
+ ESCAPE_SEQUENCES[92] = "\\\\";
2306
+ ESCAPE_SEQUENCES[133] = "\\N";
2307
+ ESCAPE_SEQUENCES[160] = "\\_";
2308
+ ESCAPE_SEQUENCES[8232] = "\\L";
2309
+ ESCAPE_SEQUENCES[8233] = "\\P";
2310
+ var DEPRECATED_BOOLEANS_SYNTAX = [
2311
+ "y",
2312
+ "Y",
2313
+ "yes",
2314
+ "Yes",
2315
+ "YES",
2316
+ "on",
2317
+ "On",
2318
+ "ON",
2319
+ "n",
2320
+ "N",
2321
+ "no",
2322
+ "No",
2323
+ "NO",
2324
+ "off",
2325
+ "Off",
2326
+ "OFF"
2327
+ ];
2328
+ function compileStyleMap(schema, map) {
2329
+ var result, keys, index, length, tag, style, type;
2330
+ if (map === null) return {};
2331
+ result = {};
2332
+ keys = Object.keys(map);
2333
+ for (index = 0, length = keys.length; index < length; index += 1) {
2334
+ tag = keys[index];
2335
+ style = String(map[tag]);
2336
+ if (tag.slice(0, 2) === "!!") {
2337
+ tag = "tag:yaml.org,2002:" + tag.slice(2);
2338
+ }
2339
+ type = schema.compiledTypeMap["fallback"][tag];
2340
+ if (type && _hasOwnProperty.call(type.styleAliases, style)) {
2341
+ style = type.styleAliases[style];
2342
+ }
2343
+ result[tag] = style;
2344
+ }
2345
+ return result;
2346
+ }
2347
+ function encodeHex(character) {
2348
+ var string, handle, length;
2349
+ string = character.toString(16).toUpperCase();
2350
+ if (character <= 255) {
2351
+ handle = "x";
2352
+ length = 2;
2353
+ } else if (character <= 65535) {
2354
+ handle = "u";
2355
+ length = 4;
2356
+ } else if (character <= 4294967295) {
2357
+ handle = "U";
2358
+ length = 8;
2359
+ } else {
2360
+ throw new YAMLException("code point within a string may not be greater than 0xFFFFFFFF");
2361
+ }
2362
+ return "\\" + handle + common.repeat("0", length - string.length) + string;
2363
+ }
2364
+ function State(options) {
2365
+ this.schema = options["schema"] || DEFAULT_FULL_SCHEMA;
2366
+ this.indent = Math.max(1, options["indent"] || 2);
2367
+ this.noArrayIndent = options["noArrayIndent"] || false;
2368
+ this.skipInvalid = options["skipInvalid"] || false;
2369
+ this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
2370
+ this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
2371
+ this.sortKeys = options["sortKeys"] || false;
2372
+ this.lineWidth = options["lineWidth"] || 80;
2373
+ this.noRefs = options["noRefs"] || false;
2374
+ this.noCompatMode = options["noCompatMode"] || false;
2375
+ this.condenseFlow = options["condenseFlow"] || false;
2376
+ this.implicitTypes = this.schema.compiledImplicit;
2377
+ this.explicitTypes = this.schema.compiledExplicit;
2378
+ this.tag = null;
2379
+ this.result = "";
2380
+ this.duplicates = [];
2381
+ this.usedDuplicates = null;
2382
+ }
2383
+ function indentString(string, spaces) {
2384
+ var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
2385
+ while (position < length) {
2386
+ next = string.indexOf("\n", position);
2387
+ if (next === -1) {
2388
+ line = string.slice(position);
2389
+ position = length;
2390
+ } else {
2391
+ line = string.slice(position, next + 1);
2392
+ position = next + 1;
2393
+ }
2394
+ if (line.length && line !== "\n") result += ind;
2395
+ result += line;
2396
+ }
2397
+ return result;
2398
+ }
2399
+ function generateNextLine(state, level) {
2400
+ return "\n" + common.repeat(" ", state.indent * level);
2401
+ }
2402
+ function testImplicitResolving(state, str) {
2403
+ var index, length, type;
2404
+ for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
2405
+ type = state.implicitTypes[index];
2406
+ if (type.resolve(str)) {
2407
+ return true;
2408
+ }
2409
+ }
2410
+ return false;
2411
+ }
2412
+ function isWhitespace(c) {
2413
+ return c === CHAR_SPACE || c === CHAR_TAB;
2414
+ }
2415
+ function isPrintable(c) {
2416
+ return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== 65279 || 65536 <= c && c <= 1114111;
2417
+ }
2418
+ function isNsChar(c) {
2419
+ return isPrintable(c) && !isWhitespace(c) && c !== 65279 && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
2420
+ }
2421
+ function isPlainSafe(c, prev) {
2422
+ return isPrintable(c) && c !== 65279 && 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_COLON && (c !== CHAR_SHARP || prev && isNsChar(prev));
2423
+ }
2424
+ function isPlainSafeFirst(c) {
2425
+ return isPrintable(c) && c !== 65279 && !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;
2426
+ }
2427
+ function needIndentIndicator(string) {
2428
+ var leadingSpaceRe = /^\n* /;
2429
+ return leadingSpaceRe.test(string);
2430
+ }
2431
+ var STYLE_PLAIN = 1;
2432
+ var STYLE_SINGLE = 2;
2433
+ var STYLE_LITERAL = 3;
2434
+ var STYLE_FOLDED = 4;
2435
+ var STYLE_DOUBLE = 5;
2436
+ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
2437
+ var i;
2438
+ var char, prev_char;
2439
+ var hasLineBreak = false;
2440
+ var hasFoldableLine = false;
2441
+ var shouldTrackWidth = lineWidth !== -1;
2442
+ var previousLineBreak = -1;
2443
+ var plain = isPlainSafeFirst(string.charCodeAt(0)) && !isWhitespace(string.charCodeAt(string.length - 1));
2444
+ if (singleLineOnly) {
2445
+ for (i = 0; i < string.length; i++) {
2446
+ char = string.charCodeAt(i);
2447
+ if (!isPrintable(char)) {
2448
+ return STYLE_DOUBLE;
2449
+ }
2450
+ prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
2451
+ plain = plain && isPlainSafe(char, prev_char);
2452
+ }
2453
+ } else {
2454
+ for (i = 0; i < string.length; i++) {
2455
+ char = string.charCodeAt(i);
2456
+ if (char === CHAR_LINE_FEED) {
2457
+ hasLineBreak = true;
2458
+ if (shouldTrackWidth) {
2459
+ hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
2460
+ i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
2461
+ previousLineBreak = i;
2462
+ }
2463
+ } else if (!isPrintable(char)) {
2464
+ return STYLE_DOUBLE;
2465
+ }
2466
+ prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
2467
+ plain = plain && isPlainSafe(char, prev_char);
2468
+ }
2469
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
2470
+ }
2471
+ if (!hasLineBreak && !hasFoldableLine) {
2472
+ return plain && !testAmbiguousType(string) ? STYLE_PLAIN : STYLE_SINGLE;
2473
+ }
2474
+ if (indentPerLevel > 9 && needIndentIndicator(string)) {
2475
+ return STYLE_DOUBLE;
2476
+ }
2477
+ return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
2478
+ }
2479
+ function writeScalar(state, string, level, iskey) {
2480
+ state.dump = (function() {
2481
+ if (string.length === 0) {
2482
+ return "''";
2483
+ }
2484
+ if (!state.noCompatMode && DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
2485
+ return "'" + string + "'";
2486
+ }
2487
+ var indent = state.indent * Math.max(1, level);
2488
+ var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
2489
+ var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
2490
+ function testAmbiguity(string2) {
2491
+ return testImplicitResolving(state, string2);
2492
+ }
2493
+ switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
2494
+ case STYLE_PLAIN:
2495
+ return string;
2496
+ case STYLE_SINGLE:
2497
+ return "'" + string.replace(/'/g, "''") + "'";
2498
+ case STYLE_LITERAL:
2499
+ return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
2500
+ case STYLE_FOLDED:
2501
+ return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
2502
+ case STYLE_DOUBLE:
2503
+ return '"' + escapeString(string, lineWidth) + '"';
2504
+ default:
2505
+ throw new YAMLException("impossible error: invalid scalar style");
2506
+ }
2507
+ })();
2508
+ }
2509
+ function blockHeader(string, indentPerLevel) {
2510
+ var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
2511
+ var clip = string[string.length - 1] === "\n";
2512
+ var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
2513
+ var chomp = keep ? "+" : clip ? "" : "-";
2514
+ return indentIndicator + chomp + "\n";
2515
+ }
2516
+ function dropEndingNewline(string) {
2517
+ return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
2518
+ }
2519
+ function foldString(string, width) {
2520
+ var lineRe = /(\n+)([^\n]*)/g;
2521
+ var result = (function() {
2522
+ var nextLF = string.indexOf("\n");
2523
+ nextLF = nextLF !== -1 ? nextLF : string.length;
2524
+ lineRe.lastIndex = nextLF;
2525
+ return foldLine(string.slice(0, nextLF), width);
2526
+ })();
2527
+ var prevMoreIndented = string[0] === "\n" || string[0] === " ";
2528
+ var moreIndented;
2529
+ var match;
2530
+ while (match = lineRe.exec(string)) {
2531
+ var prefix = match[1], line = match[2];
2532
+ moreIndented = line[0] === " ";
2533
+ result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
2534
+ prevMoreIndented = moreIndented;
2535
+ }
2536
+ return result;
2537
+ }
2538
+ function foldLine(line, width) {
2539
+ if (line === "" || line[0] === " ") return line;
2540
+ var breakRe = / [^ ]/g;
2541
+ var match;
2542
+ var start = 0, end, curr = 0, next = 0;
2543
+ var result = "";
2544
+ while (match = breakRe.exec(line)) {
2545
+ next = match.index;
2546
+ if (next - start > width) {
2547
+ end = curr > start ? curr : next;
2548
+ result += "\n" + line.slice(start, end);
2549
+ start = end + 1;
2550
+ }
2551
+ curr = next;
2552
+ }
2553
+ result += "\n";
2554
+ if (line.length - start > width && curr > start) {
2555
+ result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
2556
+ } else {
2557
+ result += line.slice(start);
2558
+ }
2559
+ return result.slice(1);
2560
+ }
2561
+ function escapeString(string) {
2562
+ var result = "";
2563
+ var char, nextChar;
2564
+ var escapeSeq;
2565
+ for (var i = 0; i < string.length; i++) {
2566
+ char = string.charCodeAt(i);
2567
+ if (char >= 55296 && char <= 56319) {
2568
+ nextChar = string.charCodeAt(i + 1);
2569
+ if (nextChar >= 56320 && nextChar <= 57343) {
2570
+ result += encodeHex((char - 55296) * 1024 + nextChar - 56320 + 65536);
2571
+ i++;
2572
+ continue;
2573
+ }
2574
+ }
2575
+ escapeSeq = ESCAPE_SEQUENCES[char];
2576
+ result += !escapeSeq && isPrintable(char) ? string[i] : escapeSeq || encodeHex(char);
2577
+ }
2578
+ return result;
2579
+ }
2580
+ function writeFlowSequence(state, level, object) {
2581
+ var _result = "", _tag = state.tag, index, length;
2582
+ for (index = 0, length = object.length; index < length; index += 1) {
2583
+ if (writeNode(state, level, object[index], false, false)) {
2584
+ if (index !== 0) _result += "," + (!state.condenseFlow ? " " : "");
2585
+ _result += state.dump;
2586
+ }
2587
+ }
2588
+ state.tag = _tag;
2589
+ state.dump = "[" + _result + "]";
2590
+ }
2591
+ function writeBlockSequence(state, level, object, compact) {
2592
+ var _result = "", _tag = state.tag, index, length;
2593
+ for (index = 0, length = object.length; index < length; index += 1) {
2594
+ if (writeNode(state, level + 1, object[index], true, true)) {
2595
+ if (!compact || index !== 0) {
2596
+ _result += generateNextLine(state, level);
2597
+ }
2598
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2599
+ _result += "-";
2600
+ } else {
2601
+ _result += "- ";
2602
+ }
2603
+ _result += state.dump;
2604
+ }
2605
+ }
2606
+ state.tag = _tag;
2607
+ state.dump = _result || "[]";
2608
+ }
2609
+ function writeFlowMapping(state, level, object) {
2610
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
2611
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2612
+ pairBuffer = "";
2613
+ if (index !== 0) pairBuffer += ", ";
2614
+ if (state.condenseFlow) pairBuffer += '"';
2615
+ objectKey = objectKeyList[index];
2616
+ objectValue = object[objectKey];
2617
+ if (!writeNode(state, level, objectKey, false, false)) {
2618
+ continue;
2619
+ }
2620
+ if (state.dump.length > 1024) pairBuffer += "? ";
2621
+ pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
2622
+ if (!writeNode(state, level, objectValue, false, false)) {
2623
+ continue;
2624
+ }
2625
+ pairBuffer += state.dump;
2626
+ _result += pairBuffer;
2627
+ }
2628
+ state.tag = _tag;
2629
+ state.dump = "{" + _result + "}";
2630
+ }
2631
+ function writeBlockMapping(state, level, object, compact) {
2632
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
2633
+ if (state.sortKeys === true) {
2634
+ objectKeyList.sort();
2635
+ } else if (typeof state.sortKeys === "function") {
2636
+ objectKeyList.sort(state.sortKeys);
2637
+ } else if (state.sortKeys) {
2638
+ throw new YAMLException("sortKeys must be a boolean or a function");
2639
+ }
2640
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2641
+ pairBuffer = "";
2642
+ if (!compact || index !== 0) {
2643
+ pairBuffer += generateNextLine(state, level);
2644
+ }
2645
+ objectKey = objectKeyList[index];
2646
+ objectValue = object[objectKey];
2647
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) {
2648
+ continue;
2649
+ }
2650
+ explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
2651
+ if (explicitPair) {
2652
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2653
+ pairBuffer += "?";
2654
+ } else {
2655
+ pairBuffer += "? ";
2656
+ }
2657
+ }
2658
+ pairBuffer += state.dump;
2659
+ if (explicitPair) {
2660
+ pairBuffer += generateNextLine(state, level);
2661
+ }
2662
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
2663
+ continue;
2664
+ }
2665
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
2666
+ pairBuffer += ":";
2667
+ } else {
2668
+ pairBuffer += ": ";
2669
+ }
2670
+ pairBuffer += state.dump;
2671
+ _result += pairBuffer;
2672
+ }
2673
+ state.tag = _tag;
2674
+ state.dump = _result || "{}";
2675
+ }
2676
+ function detectType(state, object, explicit) {
2677
+ var _result, typeList, index, length, type, style;
2678
+ typeList = explicit ? state.explicitTypes : state.implicitTypes;
2679
+ for (index = 0, length = typeList.length; index < length; index += 1) {
2680
+ type = typeList[index];
2681
+ if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
2682
+ state.tag = explicit ? type.tag : "?";
2683
+ if (type.represent) {
2684
+ style = state.styleMap[type.tag] || type.defaultStyle;
2685
+ if (_toString.call(type.represent) === "[object Function]") {
2686
+ _result = type.represent(object, style);
2687
+ } else if (_hasOwnProperty.call(type.represent, style)) {
2688
+ _result = type.represent[style](object, style);
2689
+ } else {
2690
+ throw new YAMLException("!<" + type.tag + '> tag resolver accepts not "' + style + '" style');
2691
+ }
2692
+ state.dump = _result;
2693
+ }
2694
+ return true;
2695
+ }
2696
+ }
2697
+ return false;
2698
+ }
2699
+ function writeNode(state, level, object, block, compact, iskey) {
2700
+ state.tag = null;
2701
+ state.dump = object;
2702
+ if (!detectType(state, object, false)) {
2703
+ detectType(state, object, true);
2704
+ }
2705
+ var type = _toString.call(state.dump);
2706
+ if (block) {
2707
+ block = state.flowLevel < 0 || state.flowLevel > level;
2708
+ }
2709
+ var objectOrArray = type === "[object Object]" || type === "[object Array]", duplicateIndex, duplicate;
2710
+ if (objectOrArray) {
2711
+ duplicateIndex = state.duplicates.indexOf(object);
2712
+ duplicate = duplicateIndex !== -1;
2713
+ }
2714
+ if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
2715
+ compact = false;
2716
+ }
2717
+ if (duplicate && state.usedDuplicates[duplicateIndex]) {
2718
+ state.dump = "*ref_" + duplicateIndex;
2719
+ } else {
2720
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
2721
+ state.usedDuplicates[duplicateIndex] = true;
2722
+ }
2723
+ if (type === "[object Object]") {
2724
+ if (block && Object.keys(state.dump).length !== 0) {
2725
+ writeBlockMapping(state, level, state.dump, compact);
2726
+ if (duplicate) {
2727
+ state.dump = "&ref_" + duplicateIndex + state.dump;
2728
+ }
2729
+ } else {
2730
+ writeFlowMapping(state, level, state.dump);
2731
+ if (duplicate) {
2732
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2733
+ }
2734
+ }
2735
+ } else if (type === "[object Array]") {
2736
+ var arrayLevel = state.noArrayIndent && level > 0 ? level - 1 : level;
2737
+ if (block && state.dump.length !== 0) {
2738
+ writeBlockSequence(state, arrayLevel, state.dump, compact);
2739
+ if (duplicate) {
2740
+ state.dump = "&ref_" + duplicateIndex + state.dump;
2741
+ }
2742
+ } else {
2743
+ writeFlowSequence(state, arrayLevel, state.dump);
2744
+ if (duplicate) {
2745
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
2746
+ }
2747
+ }
2748
+ } else if (type === "[object String]") {
2749
+ if (state.tag !== "?") {
2750
+ writeScalar(state, state.dump, level, iskey);
2751
+ }
2752
+ } else {
2753
+ if (state.skipInvalid) return false;
2754
+ throw new YAMLException("unacceptable kind of an object to dump " + type);
2755
+ }
2756
+ if (state.tag !== null && state.tag !== "?") {
2757
+ state.dump = "!<" + state.tag + "> " + state.dump;
2758
+ }
2759
+ }
2760
+ return true;
2761
+ }
2762
+ function getDuplicateReferences(object, state) {
2763
+ var objects = [], duplicatesIndexes = [], index, length;
2764
+ inspectNode(object, objects, duplicatesIndexes);
2765
+ for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
2766
+ state.duplicates.push(objects[duplicatesIndexes[index]]);
2767
+ }
2768
+ state.usedDuplicates = new Array(length);
2769
+ }
2770
+ function inspectNode(object, objects, duplicatesIndexes) {
2771
+ var objectKeyList, index, length;
2772
+ if (object !== null && typeof object === "object") {
2773
+ index = objects.indexOf(object);
2774
+ if (index !== -1) {
2775
+ if (duplicatesIndexes.indexOf(index) === -1) {
2776
+ duplicatesIndexes.push(index);
2777
+ }
2778
+ } else {
2779
+ objects.push(object);
2780
+ if (Array.isArray(object)) {
2781
+ for (index = 0, length = object.length; index < length; index += 1) {
2782
+ inspectNode(object[index], objects, duplicatesIndexes);
2783
+ }
2784
+ } else {
2785
+ objectKeyList = Object.keys(object);
2786
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
2787
+ inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
2788
+ }
2789
+ }
2790
+ }
2791
+ }
2792
+ }
2793
+ function dump(input, options) {
2794
+ options = options || {};
2795
+ var state = new State(options);
2796
+ if (!state.noRefs) getDuplicateReferences(input, state);
2797
+ if (writeNode(state, 0, input, true, true)) return state.dump + "\n";
2798
+ return "";
2799
+ }
2800
+ function safeDump(input, options) {
2801
+ return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2802
+ }
2803
+ module2.exports.dump = dump;
2804
+ module2.exports.safeDump = safeDump;
2805
+ }
2806
+ });
2807
+
2808
+ // node_modules/js-yaml/lib/js-yaml.js
2809
+ var require_js_yaml = __commonJS({
2810
+ "node_modules/js-yaml/lib/js-yaml.js"(exports2, module2) {
2811
+ "use strict";
2812
+ var loader = require_loader();
2813
+ var dumper = require_dumper();
2814
+ function deprecated(name) {
2815
+ return function() {
2816
+ throw new Error("Function " + name + " is deprecated and cannot be used.");
2817
+ };
2818
+ }
2819
+ module2.exports.Type = require_type();
2820
+ module2.exports.Schema = require_schema();
2821
+ module2.exports.FAILSAFE_SCHEMA = require_failsafe();
2822
+ module2.exports.JSON_SCHEMA = require_json();
2823
+ module2.exports.CORE_SCHEMA = require_core();
2824
+ module2.exports.DEFAULT_SAFE_SCHEMA = require_default_safe();
2825
+ module2.exports.DEFAULT_FULL_SCHEMA = require_default_full();
2826
+ module2.exports.load = loader.load;
2827
+ module2.exports.loadAll = loader.loadAll;
2828
+ module2.exports.safeLoad = loader.safeLoad;
2829
+ module2.exports.safeLoadAll = loader.safeLoadAll;
2830
+ module2.exports.dump = dumper.dump;
2831
+ module2.exports.safeDump = dumper.safeDump;
2832
+ module2.exports.YAMLException = require_exception();
2833
+ module2.exports.MINIMAL_SCHEMA = require_failsafe();
2834
+ module2.exports.SAFE_SCHEMA = require_default_safe();
2835
+ module2.exports.DEFAULT_SCHEMA = require_default_full();
2836
+ module2.exports.scan = deprecated("scan");
2837
+ module2.exports.parse = deprecated("parse");
2838
+ module2.exports.compose = deprecated("compose");
2839
+ module2.exports.addConstructor = deprecated("addConstructor");
2840
+ }
2841
+ });
2842
+
2843
+ // node_modules/js-yaml/index.js
2844
+ var require_js_yaml2 = __commonJS({
2845
+ "node_modules/js-yaml/index.js"(exports2, module2) {
2846
+ "use strict";
2847
+ var yaml = require_js_yaml();
2848
+ module2.exports = yaml;
2849
+ }
2850
+ });
2851
+
2852
+ // src/bin/rcan-validate.ts
2853
+ var fs = __toESM(require("fs"));
2854
+ var path = __toESM(require("path"));
2855
+
2856
+ // src/address.ts
2857
+ var RobotURIError = class extends Error {
2858
+ constructor(message) {
2859
+ super(message);
2860
+ this.name = "RobotURIError";
2861
+ }
2862
+ };
2863
+ var RobotURI = class _RobotURI {
2864
+ registry;
2865
+ manufacturer;
2866
+ model;
2867
+ version;
2868
+ deviceId;
2869
+ constructor(opts) {
2870
+ this.registry = opts.registry;
2871
+ this.manufacturer = opts.manufacturer;
2872
+ this.model = opts.model;
2873
+ this.version = opts.version;
2874
+ this.deviceId = opts.deviceId;
2875
+ }
2876
+ /** Parse a RCAN URI string. Throws RobotURIError on invalid input. */
2877
+ static parse(uri) {
2878
+ if (!uri.startsWith("rcan://")) {
2879
+ throw new RobotURIError(`URI must start with 'rcan://' \u2014 got: ${uri}`);
2880
+ }
2881
+ const withoutScheme = uri.slice("rcan://".length);
2882
+ const parts = withoutScheme.split("/");
2883
+ if (parts.length !== 5) {
2884
+ throw new RobotURIError(
2885
+ `URI must have exactly 5 path segments (registry/manufacturer/model/version/device-id) \u2014 got ${parts.length} in: ${uri}`
2886
+ );
2887
+ }
2888
+ const [registry, manufacturer, model, version, deviceId] = parts;
2889
+ for (const [name, value] of [
2890
+ ["registry", registry],
2891
+ ["manufacturer", manufacturer],
2892
+ ["model", model],
2893
+ ["version", version],
2894
+ ["device-id", deviceId]
2895
+ ]) {
2896
+ if (!value || value.trim() === "") {
2897
+ throw new RobotURIError(`URI segment '${name}' must not be empty`);
2898
+ }
2899
+ }
2900
+ return new _RobotURI({ registry, manufacturer, model, version, deviceId });
2901
+ }
2902
+ /** Build a RCAN URI from components. */
2903
+ static build(opts) {
2904
+ const registry = opts.registry ?? "registry.rcan.dev";
2905
+ const { manufacturer, model, version, deviceId } = opts;
2906
+ for (const [name, value] of [
2907
+ ["manufacturer", manufacturer],
2908
+ ["model", model],
2909
+ ["version", version],
2910
+ ["deviceId", deviceId]
2911
+ ]) {
2912
+ if (!value || value.trim() === "") {
2913
+ throw new RobotURIError(`'${name}' must not be empty`);
2914
+ }
2915
+ }
2916
+ return new _RobotURI({ registry, manufacturer, model, version, deviceId });
2917
+ }
2918
+ /** Full URI string: rcan://registry/manufacturer/model/version/device-id */
2919
+ toString() {
2920
+ return `rcan://${this.registry}/${this.manufacturer}/${this.model}/${this.version}/${this.deviceId}`;
2921
+ }
2922
+ /** Short namespace: manufacturer/model */
2923
+ get namespace() {
2924
+ return `${this.manufacturer}/${this.model}`;
2925
+ }
2926
+ /** HTTPS registry URL for this robot */
2927
+ get registryUrl() {
2928
+ return `https://${this.registry}/registry/${this.manufacturer}/${this.model}/${this.version}/${this.deviceId}`;
2929
+ }
2930
+ /** Check if two URIs refer to the same robot */
2931
+ equals(other) {
2932
+ return this.toString() === other.toString();
2933
+ }
2934
+ toJSON() {
2935
+ return {
2936
+ uri: this.toString(),
2937
+ registry: this.registry,
2938
+ manufacturer: this.manufacturer,
2939
+ model: this.model,
2940
+ version: this.version,
2941
+ deviceId: this.deviceId
2942
+ };
2943
+ }
2944
+ };
2945
+
2946
+ // src/message.ts
2947
+ var RCANMessageError = class extends Error {
2948
+ constructor(message) {
2949
+ super(message);
2950
+ this.name = "RCANMessageError";
2951
+ }
2952
+ };
2953
+ var RCANMessage = class _RCANMessage {
2954
+ rcan;
2955
+ cmd;
2956
+ target;
2957
+ params;
2958
+ confidence;
2959
+ modelIdentity;
2960
+ signature;
2961
+ timestamp;
2962
+ constructor(data) {
2963
+ if (!data.cmd || data.cmd.trim() === "") {
2964
+ throw new RCANMessageError("'cmd' is required");
2965
+ }
2966
+ if (!data.target) {
2967
+ throw new RCANMessageError("'target' is required");
2968
+ }
2969
+ this.rcan = data.rcan ?? "1.2";
2970
+ this.cmd = data.cmd;
2971
+ this.target = data.target instanceof RobotURI ? data.target.toString() : String(data.target);
2972
+ this.params = data.params ?? {};
2973
+ this.confidence = data.confidence;
2974
+ this.modelIdentity = data.modelIdentity ?? data.model_identity;
2975
+ this.signature = data.signature;
2976
+ this.timestamp = data.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
2977
+ if (this.confidence !== void 0) {
2978
+ if (this.confidence < 0 || this.confidence > 1) {
2979
+ throw new RCANMessageError(
2980
+ `confidence must be in [0.0, 1.0] \u2014 got ${this.confidence}`
2981
+ );
2982
+ }
2983
+ }
2984
+ }
2985
+ /** Whether this message has a signature block */
2986
+ get isSigned() {
2987
+ return this.signature !== void 0 && this.signature.sig !== "";
2988
+ }
2989
+ /** Whether this message was generated by an AI model (has confidence score) */
2990
+ get isAiDriven() {
2991
+ return this.confidence !== void 0;
2992
+ }
2993
+ /** Serialize to a plain object */
2994
+ toJSON() {
2995
+ const obj = {
2996
+ rcan: this.rcan,
2997
+ cmd: this.cmd,
2998
+ target: this.target,
2999
+ timestamp: this.timestamp
3000
+ };
3001
+ if (Object.keys(this.params).length > 0) obj.params = this.params;
3002
+ if (this.confidence !== void 0) obj.confidence = this.confidence;
3003
+ if (this.modelIdentity) obj.model_identity = this.modelIdentity;
3004
+ if (this.signature) obj.signature = this.signature;
3005
+ return obj;
3006
+ }
3007
+ /** Serialize to JSON string */
3008
+ toJSONString(indent) {
3009
+ return JSON.stringify(this.toJSON(), null, indent);
3010
+ }
3011
+ /** Parse from a plain object or JSON string */
3012
+ static fromJSON(data) {
3013
+ let obj;
3014
+ if (typeof data === "string") {
3015
+ try {
3016
+ obj = JSON.parse(data);
3017
+ } catch {
3018
+ throw new RCANMessageError("Invalid JSON string");
3019
+ }
3020
+ } else {
3021
+ obj = data;
3022
+ }
3023
+ if (!obj.cmd) throw new RCANMessageError("Missing required field: 'cmd'");
3024
+ if (!obj.target) throw new RCANMessageError("Missing required field: 'target'");
3025
+ if (!obj.rcan) throw new RCANMessageError("Missing required field: 'rcan'");
3026
+ return new _RCANMessage({
3027
+ rcan: obj.rcan,
3028
+ cmd: obj.cmd,
3029
+ target: obj.target,
3030
+ params: obj.params ?? {},
3031
+ confidence: obj.confidence,
3032
+ modelIdentity: obj.model_identity ?? obj.modelIdentity,
3033
+ signature: obj.signature,
3034
+ timestamp: obj.timestamp
3035
+ });
3036
+ }
3037
+ };
3038
+
3039
+ // src/validate.ts
3040
+ function makeResult() {
3041
+ return { ok: true, issues: [], warnings: [], info: [] };
3042
+ }
3043
+ function fail(result, msg) {
3044
+ result.ok = false;
3045
+ result.issues.push(msg);
3046
+ }
3047
+ function warn(result, msg) {
3048
+ result.warnings.push(msg);
3049
+ }
3050
+ function note(result, msg) {
3051
+ result.info.push(msg);
3052
+ }
3053
+ function validateURI(uri) {
3054
+ const result = makeResult();
3055
+ try {
3056
+ const parsed = RobotURI.parse(uri);
3057
+ note(result, `\u2705 Valid RCAN URI`);
3058
+ note(result, ` Registry: ${parsed.registry}`);
3059
+ note(result, ` Manufacturer: ${parsed.manufacturer}`);
3060
+ note(result, ` Model: ${parsed.model}`);
3061
+ note(result, ` Version: ${parsed.version}`);
3062
+ note(result, ` Device ID: ${parsed.deviceId}`);
3063
+ } catch (e) {
3064
+ fail(result, `Invalid RCAN URI: ${e instanceof Error ? e.message : e}`);
3065
+ }
3066
+ return result;
3067
+ }
3068
+ function validateMessage(data) {
3069
+ const result = makeResult();
3070
+ let obj;
3071
+ if (typeof data === "string") {
3072
+ try {
3073
+ obj = JSON.parse(data);
3074
+ } catch {
3075
+ fail(result, "Invalid JSON string");
3076
+ return result;
3077
+ }
3078
+ } else if (typeof data === "object" && data !== null) {
3079
+ obj = data;
3080
+ } else {
3081
+ fail(result, "Expected object or JSON string");
3082
+ return result;
3083
+ }
3084
+ for (const field of ["rcan", "cmd", "target"]) {
3085
+ if (!(field in obj) || !obj[field]) {
3086
+ fail(result, `Missing required field: '${field}'`);
3087
+ }
3088
+ }
3089
+ if (!result.ok) return result;
3090
+ try {
3091
+ const msg = RCANMessage.fromJSON(obj);
3092
+ note(result, `\u2705 RCAN message valid (v${msg.rcan})`);
3093
+ note(result, ` cmd: ${msg.cmd}`);
3094
+ note(result, ` target: ${msg.target}`);
3095
+ if (msg.confidence !== void 0) {
3096
+ note(result, ` confidence: ${msg.confidence}`);
3097
+ } else {
3098
+ warn(result, "No confidence score \u2014 add for RCAN \xA716 AI accountability");
3099
+ }
3100
+ if (msg.isSigned) {
3101
+ note(result, ` signature: alg=${msg.signature?.alg}, kid=${msg.signature?.kid}`);
3102
+ } else {
3103
+ warn(result, "Message is unsigned (recommended for production)");
3104
+ }
3105
+ } catch (e) {
3106
+ fail(result, `Message validation failed: ${e instanceof Error ? e.message : e}`);
3107
+ }
3108
+ return result;
3109
+ }
3110
+ function validateConfig(config) {
3111
+ const result = makeResult();
3112
+ const meta = config.metadata ?? {};
3113
+ const agent = config.agent ?? {};
3114
+ const rcanProto = config.rcan_protocol ?? {};
3115
+ if (!meta.manufacturer) fail(result, "L1: metadata.manufacturer is required (\xA72)");
3116
+ if (!meta.model) fail(result, "L1: metadata.model is required (\xA72)");
3117
+ if (!config.rcan_version) warn(result, "L1: rcan_version not declared (recommended)");
3118
+ if (!rcanProto.jwt_auth?.enabled) {
3119
+ warn(result, "L2: jwt_auth not enabled (required for L2 conformance, \xA78)");
3120
+ }
3121
+ if (!agent.confidence_gates || agent.confidence_gates.length === 0) {
3122
+ warn(result, "L2: confidence_gates not configured (\xA716)");
3123
+ }
3124
+ if (!agent.hitl_gates || agent.hitl_gates.length === 0) {
3125
+ warn(result, "L3: hitl_gates not configured (\xA716)");
3126
+ }
3127
+ if (!agent.commitment_chain?.enabled) {
3128
+ warn(result, "L3: commitment_chain not enabled (\xA716)");
3129
+ }
3130
+ if (meta.rrn) {
3131
+ note(result, `\u2705 RRN registered: ${meta.rrn}`);
3132
+ } else {
3133
+ warn(result, "Robot not registered \u2014 visit rcan.dev/registry/register");
3134
+ }
3135
+ if (result.ok && result.issues.length === 0) {
3136
+ const l1ok = !result.warnings.some((w) => w.startsWith("L1"));
3137
+ const l2ok = l1ok && !result.warnings.some((w) => w.startsWith("L2"));
3138
+ const l3ok = l2ok && !result.warnings.some((w) => w.startsWith("L3"));
3139
+ const level = l3ok ? "L3" : l2ok ? "L2" : l1ok ? "L1" : "FAIL";
3140
+ note(result, `\u2705 Config valid \u2014 conformance level: ${level}`);
3141
+ }
3142
+ return result;
3143
+ }
3144
+
3145
+ // src/crypto.ts
3146
+ function generateUUID() {
3147
+ if (typeof globalThis.crypto !== "undefined" && typeof globalThis.crypto.randomUUID === "function") {
3148
+ return globalThis.crypto.randomUUID();
3149
+ }
3150
+ try {
3151
+ const { randomUUID } = require("crypto");
3152
+ return randomUUID();
3153
+ } catch {
3154
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
3155
+ const r = Math.random() * 16 | 0;
3156
+ const v = c === "x" ? r : r & 3 | 8;
3157
+ return v.toString(16);
3158
+ });
3159
+ }
3160
+ }
3161
+ function hmacSha256Sync(secret, data) {
3162
+ if (typeof process !== "undefined" && process.versions?.node) {
3163
+ try {
3164
+ const { createHmac } = require("crypto");
3165
+ return createHmac("sha256", secret).update(data).digest("hex");
3166
+ } catch {
3167
+ }
3168
+ }
3169
+ return pureHmacSha256(secret, data);
3170
+ }
3171
+ function sha256(msg) {
3172
+ const K = [
3173
+ 1116352408,
3174
+ 1899447441,
3175
+ 3049323471,
3176
+ 3921009573,
3177
+ 961987163,
3178
+ 1508970993,
3179
+ 2453635748,
3180
+ 2870763221,
3181
+ 3624381080,
3182
+ 310598401,
3183
+ 607225278,
3184
+ 1426881987,
3185
+ 1925078388,
3186
+ 2162078206,
3187
+ 2614888103,
3188
+ 3248222580,
3189
+ 3835390401,
3190
+ 4022224774,
3191
+ 264347078,
3192
+ 604807628,
3193
+ 770255983,
3194
+ 1249150122,
3195
+ 1555081692,
3196
+ 1996064986,
3197
+ 2554220882,
3198
+ 2821834349,
3199
+ 2952996808,
3200
+ 3210313671,
3201
+ 3336571891,
3202
+ 3584528711,
3203
+ 113926993,
3204
+ 338241895,
3205
+ 666307205,
3206
+ 773529912,
3207
+ 1294757372,
3208
+ 1396182291,
3209
+ 1695183700,
3210
+ 1986661051,
3211
+ 2177026350,
3212
+ 2456956037,
3213
+ 2730485921,
3214
+ 2820302411,
3215
+ 3259730800,
3216
+ 3345764771,
3217
+ 3516065817,
3218
+ 3600352804,
3219
+ 4094571909,
3220
+ 275423344,
3221
+ 430227734,
3222
+ 506948616,
3223
+ 659060556,
3224
+ 883997877,
3225
+ 958139571,
3226
+ 1322822218,
3227
+ 1537002063,
3228
+ 1747873779,
3229
+ 1955562222,
3230
+ 2024104815,
3231
+ 2227730452,
3232
+ 2361852424,
3233
+ 2428436474,
3234
+ 2756734187,
3235
+ 3204031479,
3236
+ 3329325298
3237
+ ];
3238
+ let h0 = 1779033703, h1 = 3144134277, h2 = 1013904242, h3 = 2773480762;
3239
+ let h4 = 1359893119, h5 = 2600822924, h6 = 528734635, h7 = 1541459225;
3240
+ const msgLen = msg.length;
3241
+ const bitLen = msgLen * 8;
3242
+ const padded = [...msg];
3243
+ padded.push(128);
3244
+ while (padded.length % 64 !== 56) padded.push(0);
3245
+ for (let i = 7; i >= 0; i--) padded.push(bitLen / Math.pow(2, i * 8) & 255);
3246
+ for (let i = 0; i < padded.length; i += 64) {
3247
+ const w = [];
3248
+ for (let j = 0; j < 16; j++) {
3249
+ w[j] = padded[i + j * 4] << 24 | padded[i + j * 4 + 1] << 16 | padded[i + j * 4 + 2] << 8 | padded[i + j * 4 + 3];
3250
+ }
3251
+ for (let j = 16; j < 64; j++) {
3252
+ const s0 = ror(w[j - 15], 7) ^ ror(w[j - 15], 18) ^ w[j - 15] >>> 3;
3253
+ const s1 = ror(w[j - 2], 17) ^ ror(w[j - 2], 19) ^ w[j - 2] >>> 10;
3254
+ w[j] = w[j - 16] + s0 + w[j - 7] + s1 >>> 0;
3255
+ }
3256
+ let [a, b, c, d, e, f, g, h] = [h0, h1, h2, h3, h4, h5, h6, h7];
3257
+ for (let j = 0; j < 64; j++) {
3258
+ const S1 = ror(e, 6) ^ ror(e, 11) ^ ror(e, 25);
3259
+ const ch = e & f ^ ~e & g;
3260
+ const temp1 = h + S1 + ch + K[j] + w[j] >>> 0;
3261
+ const S0 = ror(a, 2) ^ ror(a, 13) ^ ror(a, 22);
3262
+ const maj = a & b ^ a & c ^ b & c;
3263
+ const temp2 = S0 + maj >>> 0;
3264
+ [h, g, f, e, d, c, b, a] = [g, f, e, d + temp1 >>> 0, c, b, a, temp1 + temp2 >>> 0];
3265
+ }
3266
+ h0 = h0 + a >>> 0;
3267
+ h1 = h1 + b >>> 0;
3268
+ h2 = h2 + c >>> 0;
3269
+ h3 = h3 + d >>> 0;
3270
+ h4 = h4 + e >>> 0;
3271
+ h5 = h5 + f >>> 0;
3272
+ h6 = h6 + g >>> 0;
3273
+ h7 = h7 + h >>> 0;
3274
+ }
3275
+ const out = new Uint8Array(32);
3276
+ const view = new DataView(out.buffer);
3277
+ [h0, h1, h2, h3, h4, h5, h6, h7].forEach((v, i) => view.setUint32(i * 4, v));
3278
+ return out;
3279
+ }
3280
+ function ror(x, n) {
3281
+ return x >>> n | x << 32 - n;
3282
+ }
3283
+ function toBytes(s) {
3284
+ if (typeof TextEncoder !== "undefined") return new TextEncoder().encode(s);
3285
+ const out = new Uint8Array(s.length);
3286
+ for (let i = 0; i < s.length; i++) out[i] = s.charCodeAt(i) & 255;
3287
+ return out;
3288
+ }
3289
+ function toHex(bytes) {
3290
+ return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
3291
+ }
3292
+ function pureHmacSha256(key, data) {
3293
+ const BLOCK = 64;
3294
+ let keyBytes = toBytes(key);
3295
+ if (keyBytes.length > BLOCK) keyBytes = sha256(keyBytes);
3296
+ const ipad = new Uint8Array(BLOCK), opad = new Uint8Array(BLOCK);
3297
+ for (let i = 0; i < BLOCK; i++) {
3298
+ ipad[i] = (keyBytes[i] ?? 0) ^ 54;
3299
+ opad[i] = (keyBytes[i] ?? 0) ^ 92;
3300
+ }
3301
+ const dataBytes = toBytes(data);
3302
+ const inner = new Uint8Array(BLOCK + dataBytes.length);
3303
+ inner.set(ipad);
3304
+ inner.set(dataBytes, BLOCK);
3305
+ const innerHash = sha256(inner);
3306
+ const outer = new Uint8Array(BLOCK + 32);
3307
+ outer.set(opad);
3308
+ outer.set(innerHash, BLOCK);
3309
+ return toHex(sha256(outer));
3310
+ }
3311
+
3312
+ // src/audit.ts
3313
+ function computeContentHash(recordId, action, robotUri, timestamp, params) {
3314
+ const payload = JSON.stringify(
3315
+ { recordId, action, robotUri, timestamp, params },
3316
+ Object.keys({ recordId, action, robotUri, timestamp, params }).sort()
3317
+ );
3318
+ return hmacSha256Sync("rcan-content-hash", payload);
3319
+ }
3320
+ function computeHmac(secret, data) {
3321
+ const { hmac: _ignored, ...rest } = data;
3322
+ const payload = JSON.stringify(rest, Object.keys(rest).sort());
3323
+ return hmacSha256Sync(secret, payload);
3324
+ }
3325
+ var CommitmentRecord = class _CommitmentRecord {
3326
+ recordId;
3327
+ action;
3328
+ robotUri;
3329
+ confidence;
3330
+ modelIdentity;
3331
+ params;
3332
+ safetyApproved;
3333
+ timestamp;
3334
+ contentHash;
3335
+ previousHash;
3336
+ hmac;
3337
+ constructor(data) {
3338
+ this.recordId = data.recordId;
3339
+ this.action = data.action;
3340
+ this.robotUri = data.robotUri;
3341
+ this.confidence = data.confidence;
3342
+ this.modelIdentity = data.modelIdentity;
3343
+ this.params = data.params;
3344
+ this.safetyApproved = data.safetyApproved;
3345
+ this.timestamp = data.timestamp;
3346
+ this.contentHash = data.contentHash;
3347
+ this.previousHash = data.previousHash;
3348
+ this.hmac = data.hmac;
3349
+ }
3350
+ static create(data, secret, previousHash = null) {
3351
+ const recordId = generateUUID();
3352
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
3353
+ const params = data.params ?? {};
3354
+ const robotUri = data.robotUri ?? "";
3355
+ const contentHash = computeContentHash(recordId, data.action, robotUri, timestamp, params);
3356
+ const draft = {
3357
+ recordId,
3358
+ action: data.action,
3359
+ robotUri,
3360
+ confidence: data.confidence,
3361
+ modelIdentity: data.modelIdentity,
3362
+ params,
3363
+ safetyApproved: data.safetyApproved ?? true,
3364
+ timestamp,
3365
+ contentHash,
3366
+ previousHash,
3367
+ hmac: ""
3368
+ };
3369
+ draft.hmac = computeHmac(secret, draft);
3370
+ return new _CommitmentRecord(draft);
3371
+ }
3372
+ verify(secret) {
3373
+ const expected = computeHmac(secret, this.toJSON());
3374
+ return expected === this.hmac;
3375
+ }
3376
+ toJSON() {
3377
+ return {
3378
+ recordId: this.recordId,
3379
+ action: this.action,
3380
+ robotUri: this.robotUri,
3381
+ confidence: this.confidence,
3382
+ modelIdentity: this.modelIdentity,
3383
+ params: this.params,
3384
+ safetyApproved: this.safetyApproved,
3385
+ timestamp: this.timestamp,
3386
+ contentHash: this.contentHash,
3387
+ previousHash: this.previousHash,
3388
+ hmac: this.hmac
3389
+ };
3390
+ }
3391
+ static fromJSON(obj) {
3392
+ return new _CommitmentRecord(obj);
3393
+ }
3394
+ };
3395
+ var AuditChain = class _AuditChain {
3396
+ _records = [];
3397
+ _secret;
3398
+ constructor(secret) {
3399
+ this._secret = secret;
3400
+ }
3401
+ get records() {
3402
+ return this._records;
3403
+ }
3404
+ append(data) {
3405
+ const prev = this._records[this._records.length - 1];
3406
+ const prevHash = prev?.contentHash ?? null;
3407
+ const record = CommitmentRecord.create(data, this._secret, prevHash);
3408
+ this._records.push(record);
3409
+ return record;
3410
+ }
3411
+ verifyAll() {
3412
+ const errors = [];
3413
+ let prevHash = null;
3414
+ for (const record of this._records) {
3415
+ if (!record.verify(this._secret)) {
3416
+ errors.push(`HMAC invalid for record ${record.recordId.slice(0, 8)}`);
3417
+ }
3418
+ if (prevHash !== null && record.previousHash !== prevHash) {
3419
+ errors.push(
3420
+ `Chain broken at ${record.recordId.slice(0, 8)}: expected prev=${prevHash.slice(0, 12)}`
3421
+ );
3422
+ }
3423
+ prevHash = record.contentHash;
3424
+ }
3425
+ return { valid: errors.length === 0, count: this._records.length, errors };
3426
+ }
3427
+ toJSONL() {
3428
+ return this._records.map((r) => JSON.stringify(r.toJSON())).join("\n") + "\n";
3429
+ }
3430
+ static fromJSONL(text, secret) {
3431
+ const chain = new _AuditChain(secret);
3432
+ const lines = text.trim().split("\n").filter((l) => l.trim() !== "");
3433
+ for (const line of lines) {
3434
+ const obj = JSON.parse(line);
3435
+ chain._records.push(CommitmentRecord.fromJSON(obj));
3436
+ }
3437
+ return chain;
3438
+ }
3439
+ };
3440
+
3441
+ // src/bin/rcan-validate.ts
3442
+ function printResult(result, label) {
3443
+ const status = result.ok ? "\x1B[32m\u2705 PASS\x1B[0m" : "\x1B[31m\u274C FAIL\x1B[0m";
3444
+ console.log(`
3445
+ ${status} ${label}
3446
+ `);
3447
+ for (const issue of result.issues) {
3448
+ console.log(` \x1B[31m\u2717 ${issue}\x1B[0m`);
3449
+ }
3450
+ for (const warn2 of result.warnings) {
3451
+ console.log(` \x1B[33m\u26A0 ${warn2}\x1B[0m`);
3452
+ }
3453
+ for (const note2 of result.info) {
3454
+ console.log(` ${note2}`);
3455
+ }
3456
+ console.log();
3457
+ }
3458
+ function readFile(filePath) {
3459
+ const resolved = path.resolve(filePath);
3460
+ if (!fs.existsSync(resolved)) {
3461
+ console.error(`Error: File not found: ${filePath}`);
3462
+ process.exit(1);
3463
+ }
3464
+ return fs.readFileSync(resolved, "utf-8");
3465
+ }
3466
+ function parseYAML(text) {
3467
+ text = text.trim();
3468
+ if (text.startsWith("{") || text.startsWith("[")) {
3469
+ return JSON.parse(text);
3470
+ }
3471
+ try {
3472
+ const yaml = require_js_yaml2();
3473
+ return yaml.load(text);
3474
+ } catch {
3475
+ try {
3476
+ return JSON.parse(text);
3477
+ } catch {
3478
+ console.error("Error: Could not parse file as YAML or JSON. Install js-yaml for YAML support: npm install js-yaml");
3479
+ process.exit(1);
3480
+ }
3481
+ }
3482
+ }
3483
+ function cmdConfig(filePath) {
3484
+ const text = readFile(filePath);
3485
+ const config = parseYAML(text);
3486
+ const result = validateConfig(config);
3487
+ printResult(result, `Config: ${filePath}`);
3488
+ process.exit(result.ok ? 0 : 1);
3489
+ }
3490
+ function cmdMessage(filePath) {
3491
+ const text = readFile(filePath);
3492
+ let data;
3493
+ try {
3494
+ data = JSON.parse(text);
3495
+ } catch {
3496
+ console.error("Error: Message file must be valid JSON");
3497
+ process.exit(1);
3498
+ }
3499
+ const result = validateMessage(data);
3500
+ printResult(result, `Message: ${filePath}`);
3501
+ process.exit(result.ok ? 0 : 1);
3502
+ }
3503
+ function cmdURI(uri) {
3504
+ const result = validateURI(uri);
3505
+ printResult(result, `URI: ${uri}`);
3506
+ process.exit(result.ok ? 0 : 1);
3507
+ }
3508
+ function cmdAudit(filePath, secret = "") {
3509
+ const text = readFile(filePath);
3510
+ const lines = text.trim().split("\n").filter(Boolean);
3511
+ if (lines.length === 0) {
3512
+ console.error("Error: Audit file is empty");
3513
+ process.exit(1);
3514
+ }
3515
+ try {
3516
+ const chain = AuditChain.fromJSONL(text, secret);
3517
+ const verifyResult = chain.verifyAll();
3518
+ const label = `Audit chain: ${filePath} (${verifyResult.count} records)`;
3519
+ if (verifyResult.valid) {
3520
+ console.log(`
3521
+ \x1B[32m\u2705 PASS\x1B[0m ${label}`);
3522
+ console.log(` Chain is tamper-evident and intact.
3523
+ `);
3524
+ process.exit(0);
3525
+ } else {
3526
+ console.log(`
3527
+ \x1B[31m\u274C FAIL\x1B[0m ${label}`);
3528
+ for (const e of verifyResult.errors) {
3529
+ console.log(` \x1B[31m\u2717 ${e}\x1B[0m`);
3530
+ }
3531
+ console.log();
3532
+ process.exit(1);
3533
+ }
3534
+ } catch (e) {
3535
+ console.error(`Error: ${e instanceof Error ? e.message : e}`);
3536
+ process.exit(1);
3537
+ }
3538
+ }
3539
+ function usage() {
3540
+ console.log(`
3541
+ rcan-validate \u2014 validate RCAN configs, messages, URIs, and audit chains
3542
+
3543
+ Usage:
3544
+ rcan-validate config <file.rcan.yaml> Validate RCAN config (L1/L2/L3 conformance)
3545
+ rcan-validate message <file.json> Validate a RCAN message
3546
+ rcan-validate uri <rcan://...> Validate a Robot URI
3547
+ rcan-validate audit <file.jsonl> [secret] Verify an audit chain (HMAC)
3548
+
3549
+ Examples:
3550
+ rcan-validate config myrobot.rcan.yaml
3551
+ rcan-validate message command.json
3552
+ rcan-validate uri 'rcan://registry.rcan.dev/acme/arm/v2/unit-001'
3553
+ rcan-validate audit audit.jsonl
3554
+ `);
3555
+ process.exit(0);
3556
+ }
3557
+ var [, , subcmd, arg, secretArg] = process.argv;
3558
+ if (!subcmd || subcmd === "--help" || subcmd === "-h") {
3559
+ usage();
3560
+ }
3561
+ switch (subcmd) {
3562
+ case "config":
3563
+ if (!arg) {
3564
+ console.error("Error: missing <file>");
3565
+ process.exit(1);
3566
+ }
3567
+ cmdConfig(arg);
3568
+ break;
3569
+ case "message":
3570
+ if (!arg) {
3571
+ console.error("Error: missing <file>");
3572
+ process.exit(1);
3573
+ }
3574
+ cmdMessage(arg);
3575
+ break;
3576
+ case "uri":
3577
+ if (!arg) {
3578
+ console.error("Error: missing <uri>");
3579
+ process.exit(1);
3580
+ }
3581
+ cmdURI(arg);
3582
+ break;
3583
+ case "audit":
3584
+ if (!arg) {
3585
+ console.error("Error: missing <file>");
3586
+ process.exit(1);
3587
+ }
3588
+ cmdAudit(arg, secretArg ?? "");
3589
+ break;
3590
+ default:
3591
+ console.error(`Error: unknown subcommand '${subcmd}'`);
3592
+ usage();
3593
+ }