UNPKG

434 kBJavaScriptView Raw
1var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
2 'use strict';
3
4 Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue;
5
6 //
7
8 function createVNodes(vm, slotValue, name) {
9 var el = vueTemplateCompiler.compileToFunctions(
10 ("<div><template slot=" + name + ">" + slotValue + "</template></div>")
11 );
12 var _staticRenderFns = vm._renderProxy.$options.staticRenderFns;
13 var _staticTrees = vm._renderProxy._staticTrees;
14 vm._renderProxy._staticTrees = [];
15 vm._renderProxy.$options.staticRenderFns = el.staticRenderFns;
16 var vnode = el.render.call(vm._renderProxy, vm.$createElement);
17 vm._renderProxy.$options.staticRenderFns = _staticRenderFns;
18 vm._renderProxy._staticTrees = _staticTrees;
19 return vnode.children[0]
20 }
21
22 function createVNodesForSlot(
23 vm,
24 slotValue,
25 name
26 ) {
27 if (typeof slotValue === 'string') {
28 return createVNodes(vm, slotValue, name)
29 }
30 var vnode = vm.$createElement(slotValue)
31 ;(vnode.data || (vnode.data = {})).slot = name;
32 return vnode
33 }
34
35 function createSlotVNodes(
36 vm,
37 slots
38 ) {
39 return Object.keys(slots).reduce(function (acc, key) {
40 var content = slots[key];
41 if (Array.isArray(content)) {
42 var nodes = content.map(function (slotDef) { return createVNodesForSlot(vm, slotDef, key); }
43 );
44 return acc.concat(nodes)
45 }
46
47 return acc.concat(createVNodesForSlot(vm, content, key))
48 }, [])
49 }
50
51 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
52
53 function createCommonjsModule(fn, module) {
54 return module = { exports: {} }, fn(module, module.exports), module.exports;
55 }
56
57 function getCjsExportFromNamespace (n) {
58 return n && n['default'] || n;
59 }
60
61 var semver = createCommonjsModule(function (module, exports) {
62 exports = module.exports = SemVer;
63
64 var debug;
65 /* istanbul ignore next */
66 if (typeof process === 'object' &&
67 process.env &&
68 process.env.NODE_DEBUG &&
69 /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
70 debug = function () {
71 var args = Array.prototype.slice.call(arguments, 0);
72 args.unshift('SEMVER');
73 console.log.apply(console, args);
74 };
75 } else {
76 debug = function () {};
77 }
78
79 // Note: this is the semver.org version of the spec that it implements
80 // Not necessarily the package version of this code.
81 exports.SEMVER_SPEC_VERSION = '2.0.0';
82
83 var MAX_LENGTH = 256;
84 var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
85 /* istanbul ignore next */ 9007199254740991;
86
87 // Max safe segment length for coercion.
88 var MAX_SAFE_COMPONENT_LENGTH = 16;
89
90 // The actual regexps go on exports.re
91 var re = exports.re = [];
92 var src = exports.src = [];
93 var t = exports.tokens = {};
94 var R = 0;
95
96 function tok (n) {
97 t[n] = R++;
98 }
99
100 // The following Regular Expressions can be used for tokenizing,
101 // validating, and parsing SemVer version strings.
102
103 // ## Numeric Identifier
104 // A single `0`, or a non-zero digit followed by zero or more digits.
105
106 tok('NUMERICIDENTIFIER');
107 src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
108 tok('NUMERICIDENTIFIERLOOSE');
109 src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
110
111 // ## Non-numeric Identifier
112 // Zero or more digits, followed by a letter or hyphen, and then zero or
113 // more letters, digits, or hyphens.
114
115 tok('NONNUMERICIDENTIFIER');
116 src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
117
118 // ## Main Version
119 // Three dot-separated numeric identifiers.
120
121 tok('MAINVERSION');
122 src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
123 '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
124 '(' + src[t.NUMERICIDENTIFIER] + ')';
125
126 tok('MAINVERSIONLOOSE');
127 src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
128 '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
129 '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
130
131 // ## Pre-release Version Identifier
132 // A numeric identifier, or a non-numeric identifier.
133
134 tok('PRERELEASEIDENTIFIER');
135 src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
136 '|' + src[t.NONNUMERICIDENTIFIER] + ')';
137
138 tok('PRERELEASEIDENTIFIERLOOSE');
139 src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
140 '|' + src[t.NONNUMERICIDENTIFIER] + ')';
141
142 // ## Pre-release Version
143 // Hyphen, followed by one or more dot-separated pre-release version
144 // identifiers.
145
146 tok('PRERELEASE');
147 src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
148 '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
149
150 tok('PRERELEASELOOSE');
151 src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
152 '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
153
154 // ## Build Metadata Identifier
155 // Any combination of digits, letters, or hyphens.
156
157 tok('BUILDIDENTIFIER');
158 src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
159
160 // ## Build Metadata
161 // Plus sign, followed by one or more period-separated build metadata
162 // identifiers.
163
164 tok('BUILD');
165 src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
166 '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
167
168 // ## Full Version String
169 // A main version, followed optionally by a pre-release version and
170 // build metadata.
171
172 // Note that the only major, minor, patch, and pre-release sections of
173 // the version string are capturing groups. The build metadata is not a
174 // capturing group, because it should not ever be used in version
175 // comparison.
176
177 tok('FULL');
178 tok('FULLPLAIN');
179 src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
180 src[t.PRERELEASE] + '?' +
181 src[t.BUILD] + '?';
182
183 src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
184
185 // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
186 // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
187 // common in the npm registry.
188 tok('LOOSEPLAIN');
189 src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
190 src[t.PRERELEASELOOSE] + '?' +
191 src[t.BUILD] + '?';
192
193 tok('LOOSE');
194 src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
195
196 tok('GTLT');
197 src[t.GTLT] = '((?:<|>)?=?)';
198
199 // Something like "2.*" or "1.2.x".
200 // Note that "x.x" is a valid xRange identifer, meaning "any version"
201 // Only the first item is strictly required.
202 tok('XRANGEIDENTIFIERLOOSE');
203 src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
204 tok('XRANGEIDENTIFIER');
205 src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
206
207 tok('XRANGEPLAIN');
208 src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
209 '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
210 '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
211 '(?:' + src[t.PRERELEASE] + ')?' +
212 src[t.BUILD] + '?' +
213 ')?)?';
214
215 tok('XRANGEPLAINLOOSE');
216 src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
217 '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
218 '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
219 '(?:' + src[t.PRERELEASELOOSE] + ')?' +
220 src[t.BUILD] + '?' +
221 ')?)?';
222
223 tok('XRANGE');
224 src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
225 tok('XRANGELOOSE');
226 src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
227
228 // Coercion.
229 // Extract anything that could conceivably be a part of a valid semver
230 tok('COERCE');
231 src[t.COERCE] = '(^|[^\\d])' +
232 '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
233 '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
234 '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
235 '(?:$|[^\\d])';
236 tok('COERCERTL');
237 re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
238
239 // Tilde ranges.
240 // Meaning is "reasonably at or greater than"
241 tok('LONETILDE');
242 src[t.LONETILDE] = '(?:~>?)';
243
244 tok('TILDETRIM');
245 src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
246 re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
247 var tildeTrimReplace = '$1~';
248
249 tok('TILDE');
250 src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
251 tok('TILDELOOSE');
252 src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
253
254 // Caret ranges.
255 // Meaning is "at least and backwards compatible with"
256 tok('LONECARET');
257 src[t.LONECARET] = '(?:\\^)';
258
259 tok('CARETTRIM');
260 src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
261 re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
262 var caretTrimReplace = '$1^';
263
264 tok('CARET');
265 src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
266 tok('CARETLOOSE');
267 src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
268
269 // A simple gt/lt/eq thing, or just "" to indicate "any version"
270 tok('COMPARATORLOOSE');
271 src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
272 tok('COMPARATOR');
273 src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
274
275 // An expression to strip any whitespace between the gtlt and the thing
276 // it modifies, so that `> 1.2.3` ==> `>1.2.3`
277 tok('COMPARATORTRIM');
278 src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
279 '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
280
281 // this one has to use the /g flag
282 re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
283 var comparatorTrimReplace = '$1$2$3';
284
285 // Something like `1.2.3 - 1.2.4`
286 // Note that these all use the loose form, because they'll be
287 // checked against either the strict or loose comparator form
288 // later.
289 tok('HYPHENRANGE');
290 src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
291 '\\s+-\\s+' +
292 '(' + src[t.XRANGEPLAIN] + ')' +
293 '\\s*$';
294
295 tok('HYPHENRANGELOOSE');
296 src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
297 '\\s+-\\s+' +
298 '(' + src[t.XRANGEPLAINLOOSE] + ')' +
299 '\\s*$';
300
301 // Star ranges basically just allow anything at all.
302 tok('STAR');
303 src[t.STAR] = '(<|>)?=?\\s*\\*';
304
305 // Compile to actual regexp objects.
306 // All are flag-free, unless they were created above with a flag.
307 for (var i = 0; i < R; i++) {
308 debug(i, src[i]);
309 if (!re[i]) {
310 re[i] = new RegExp(src[i]);
311 }
312 }
313
314 exports.parse = parse;
315 function parse (version, options) {
316 if (!options || typeof options !== 'object') {
317 options = {
318 loose: !!options,
319 includePrerelease: false
320 };
321 }
322
323 if (version instanceof SemVer) {
324 return version
325 }
326
327 if (typeof version !== 'string') {
328 return null
329 }
330
331 if (version.length > MAX_LENGTH) {
332 return null
333 }
334
335 var r = options.loose ? re[t.LOOSE] : re[t.FULL];
336 if (!r.test(version)) {
337 return null
338 }
339
340 try {
341 return new SemVer(version, options)
342 } catch (er) {
343 return null
344 }
345 }
346
347 exports.valid = valid;
348 function valid (version, options) {
349 var v = parse(version, options);
350 return v ? v.version : null
351 }
352
353 exports.clean = clean;
354 function clean (version, options) {
355 var s = parse(version.trim().replace(/^[=v]+/, ''), options);
356 return s ? s.version : null
357 }
358
359 exports.SemVer = SemVer;
360
361 function SemVer (version, options) {
362 if (!options || typeof options !== 'object') {
363 options = {
364 loose: !!options,
365 includePrerelease: false
366 };
367 }
368 if (version instanceof SemVer) {
369 if (version.loose === options.loose) {
370 return version
371 } else {
372 version = version.version;
373 }
374 } else if (typeof version !== 'string') {
375 throw new TypeError('Invalid Version: ' + version)
376 }
377
378 if (version.length > MAX_LENGTH) {
379 throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
380 }
381
382 if (!(this instanceof SemVer)) {
383 return new SemVer(version, options)
384 }
385
386 debug('SemVer', version, options);
387 this.options = options;
388 this.loose = !!options.loose;
389
390 var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
391
392 if (!m) {
393 throw new TypeError('Invalid Version: ' + version)
394 }
395
396 this.raw = version;
397
398 // these are actually numbers
399 this.major = +m[1];
400 this.minor = +m[2];
401 this.patch = +m[3];
402
403 if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
404 throw new TypeError('Invalid major version')
405 }
406
407 if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
408 throw new TypeError('Invalid minor version')
409 }
410
411 if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
412 throw new TypeError('Invalid patch version')
413 }
414
415 // numberify any prerelease numeric ids
416 if (!m[4]) {
417 this.prerelease = [];
418 } else {
419 this.prerelease = m[4].split('.').map(function (id) {
420 if (/^[0-9]+$/.test(id)) {
421 var num = +id;
422 if (num >= 0 && num < MAX_SAFE_INTEGER) {
423 return num
424 }
425 }
426 return id
427 });
428 }
429
430 this.build = m[5] ? m[5].split('.') : [];
431 this.format();
432 }
433
434 SemVer.prototype.format = function () {
435 this.version = this.major + '.' + this.minor + '.' + this.patch;
436 if (this.prerelease.length) {
437 this.version += '-' + this.prerelease.join('.');
438 }
439 return this.version
440 };
441
442 SemVer.prototype.toString = function () {
443 return this.version
444 };
445
446 SemVer.prototype.compare = function (other) {
447 debug('SemVer.compare', this.version, this.options, other);
448 if (!(other instanceof SemVer)) {
449 other = new SemVer(other, this.options);
450 }
451
452 return this.compareMain(other) || this.comparePre(other)
453 };
454
455 SemVer.prototype.compareMain = function (other) {
456 if (!(other instanceof SemVer)) {
457 other = new SemVer(other, this.options);
458 }
459
460 return compareIdentifiers(this.major, other.major) ||
461 compareIdentifiers(this.minor, other.minor) ||
462 compareIdentifiers(this.patch, other.patch)
463 };
464
465 SemVer.prototype.comparePre = function (other) {
466 if (!(other instanceof SemVer)) {
467 other = new SemVer(other, this.options);
468 }
469
470 // NOT having a prerelease is > having one
471 if (this.prerelease.length && !other.prerelease.length) {
472 return -1
473 } else if (!this.prerelease.length && other.prerelease.length) {
474 return 1
475 } else if (!this.prerelease.length && !other.prerelease.length) {
476 return 0
477 }
478
479 var i = 0;
480 do {
481 var a = this.prerelease[i];
482 var b = other.prerelease[i];
483 debug('prerelease compare', i, a, b);
484 if (a === undefined && b === undefined) {
485 return 0
486 } else if (b === undefined) {
487 return 1
488 } else if (a === undefined) {
489 return -1
490 } else if (a === b) {
491 continue
492 } else {
493 return compareIdentifiers(a, b)
494 }
495 } while (++i)
496 };
497
498 SemVer.prototype.compareBuild = function (other) {
499 if (!(other instanceof SemVer)) {
500 other = new SemVer(other, this.options);
501 }
502
503 var i = 0;
504 do {
505 var a = this.build[i];
506 var b = other.build[i];
507 debug('prerelease compare', i, a, b);
508 if (a === undefined && b === undefined) {
509 return 0
510 } else if (b === undefined) {
511 return 1
512 } else if (a === undefined) {
513 return -1
514 } else if (a === b) {
515 continue
516 } else {
517 return compareIdentifiers(a, b)
518 }
519 } while (++i)
520 };
521
522 // preminor will bump the version up to the next minor release, and immediately
523 // down to pre-release. premajor and prepatch work the same way.
524 SemVer.prototype.inc = function (release, identifier) {
525 switch (release) {
526 case 'premajor':
527 this.prerelease.length = 0;
528 this.patch = 0;
529 this.minor = 0;
530 this.major++;
531 this.inc('pre', identifier);
532 break
533 case 'preminor':
534 this.prerelease.length = 0;
535 this.patch = 0;
536 this.minor++;
537 this.inc('pre', identifier);
538 break
539 case 'prepatch':
540 // If this is already a prerelease, it will bump to the next version
541 // drop any prereleases that might already exist, since they are not
542 // relevant at this point.
543 this.prerelease.length = 0;
544 this.inc('patch', identifier);
545 this.inc('pre', identifier);
546 break
547 // If the input is a non-prerelease version, this acts the same as
548 // prepatch.
549 case 'prerelease':
550 if (this.prerelease.length === 0) {
551 this.inc('patch', identifier);
552 }
553 this.inc('pre', identifier);
554 break
555
556 case 'major':
557 // If this is a pre-major version, bump up to the same major version.
558 // Otherwise increment major.
559 // 1.0.0-5 bumps to 1.0.0
560 // 1.1.0 bumps to 2.0.0
561 if (this.minor !== 0 ||
562 this.patch !== 0 ||
563 this.prerelease.length === 0) {
564 this.major++;
565 }
566 this.minor = 0;
567 this.patch = 0;
568 this.prerelease = [];
569 break
570 case 'minor':
571 // If this is a pre-minor version, bump up to the same minor version.
572 // Otherwise increment minor.
573 // 1.2.0-5 bumps to 1.2.0
574 // 1.2.1 bumps to 1.3.0
575 if (this.patch !== 0 || this.prerelease.length === 0) {
576 this.minor++;
577 }
578 this.patch = 0;
579 this.prerelease = [];
580 break
581 case 'patch':
582 // If this is not a pre-release version, it will increment the patch.
583 // If it is a pre-release it will bump up to the same patch version.
584 // 1.2.0-5 patches to 1.2.0
585 // 1.2.0 patches to 1.2.1
586 if (this.prerelease.length === 0) {
587 this.patch++;
588 }
589 this.prerelease = [];
590 break
591 // This probably shouldn't be used publicly.
592 // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
593 case 'pre':
594 if (this.prerelease.length === 0) {
595 this.prerelease = [0];
596 } else {
597 var i = this.prerelease.length;
598 while (--i >= 0) {
599 if (typeof this.prerelease[i] === 'number') {
600 this.prerelease[i]++;
601 i = -2;
602 }
603 }
604 if (i === -1) {
605 // didn't increment anything
606 this.prerelease.push(0);
607 }
608 }
609 if (identifier) {
610 // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
611 // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
612 if (this.prerelease[0] === identifier) {
613 if (isNaN(this.prerelease[1])) {
614 this.prerelease = [identifier, 0];
615 }
616 } else {
617 this.prerelease = [identifier, 0];
618 }
619 }
620 break
621
622 default:
623 throw new Error('invalid increment argument: ' + release)
624 }
625 this.format();
626 this.raw = this.version;
627 return this
628 };
629
630 exports.inc = inc;
631 function inc (version, release, loose, identifier) {
632 if (typeof (loose) === 'string') {
633 identifier = loose;
634 loose = undefined;
635 }
636
637 try {
638 return new SemVer(version, loose).inc(release, identifier).version
639 } catch (er) {
640 return null
641 }
642 }
643
644 exports.diff = diff;
645 function diff (version1, version2) {
646 if (eq(version1, version2)) {
647 return null
648 } else {
649 var v1 = parse(version1);
650 var v2 = parse(version2);
651 var prefix = '';
652 if (v1.prerelease.length || v2.prerelease.length) {
653 prefix = 'pre';
654 var defaultResult = 'prerelease';
655 }
656 for (var key in v1) {
657 if (key === 'major' || key === 'minor' || key === 'patch') {
658 if (v1[key] !== v2[key]) {
659 return prefix + key
660 }
661 }
662 }
663 return defaultResult // may be undefined
664 }
665 }
666
667 exports.compareIdentifiers = compareIdentifiers;
668
669 var numeric = /^[0-9]+$/;
670 function compareIdentifiers (a, b) {
671 var anum = numeric.test(a);
672 var bnum = numeric.test(b);
673
674 if (anum && bnum) {
675 a = +a;
676 b = +b;
677 }
678
679 return a === b ? 0
680 : (anum && !bnum) ? -1
681 : (bnum && !anum) ? 1
682 : a < b ? -1
683 : 1
684 }
685
686 exports.rcompareIdentifiers = rcompareIdentifiers;
687 function rcompareIdentifiers (a, b) {
688 return compareIdentifiers(b, a)
689 }
690
691 exports.major = major;
692 function major (a, loose) {
693 return new SemVer(a, loose).major
694 }
695
696 exports.minor = minor;
697 function minor (a, loose) {
698 return new SemVer(a, loose).minor
699 }
700
701 exports.patch = patch;
702 function patch (a, loose) {
703 return new SemVer(a, loose).patch
704 }
705
706 exports.compare = compare;
707 function compare (a, b, loose) {
708 return new SemVer(a, loose).compare(new SemVer(b, loose))
709 }
710
711 exports.compareLoose = compareLoose;
712 function compareLoose (a, b) {
713 return compare(a, b, true)
714 }
715
716 exports.compareBuild = compareBuild;
717 function compareBuild (a, b, loose) {
718 var versionA = new SemVer(a, loose);
719 var versionB = new SemVer(b, loose);
720 return versionA.compare(versionB) || versionA.compareBuild(versionB)
721 }
722
723 exports.rcompare = rcompare;
724 function rcompare (a, b, loose) {
725 return compare(b, a, loose)
726 }
727
728 exports.sort = sort;
729 function sort (list, loose) {
730 return list.sort(function (a, b) {
731 return exports.compareBuild(a, b, loose)
732 })
733 }
734
735 exports.rsort = rsort;
736 function rsort (list, loose) {
737 return list.sort(function (a, b) {
738 return exports.compareBuild(b, a, loose)
739 })
740 }
741
742 exports.gt = gt;
743 function gt (a, b, loose) {
744 return compare(a, b, loose) > 0
745 }
746
747 exports.lt = lt;
748 function lt (a, b, loose) {
749 return compare(a, b, loose) < 0
750 }
751
752 exports.eq = eq;
753 function eq (a, b, loose) {
754 return compare(a, b, loose) === 0
755 }
756
757 exports.neq = neq;
758 function neq (a, b, loose) {
759 return compare(a, b, loose) !== 0
760 }
761
762 exports.gte = gte;
763 function gte (a, b, loose) {
764 return compare(a, b, loose) >= 0
765 }
766
767 exports.lte = lte;
768 function lte (a, b, loose) {
769 return compare(a, b, loose) <= 0
770 }
771
772 exports.cmp = cmp;
773 function cmp (a, op, b, loose) {
774 switch (op) {
775 case '===':
776 if (typeof a === 'object')
777 { a = a.version; }
778 if (typeof b === 'object')
779 { b = b.version; }
780 return a === b
781
782 case '!==':
783 if (typeof a === 'object')
784 { a = a.version; }
785 if (typeof b === 'object')
786 { b = b.version; }
787 return a !== b
788
789 case '':
790 case '=':
791 case '==':
792 return eq(a, b, loose)
793
794 case '!=':
795 return neq(a, b, loose)
796
797 case '>':
798 return gt(a, b, loose)
799
800 case '>=':
801 return gte(a, b, loose)
802
803 case '<':
804 return lt(a, b, loose)
805
806 case '<=':
807 return lte(a, b, loose)
808
809 default:
810 throw new TypeError('Invalid operator: ' + op)
811 }
812 }
813
814 exports.Comparator = Comparator;
815 function Comparator (comp, options) {
816 if (!options || typeof options !== 'object') {
817 options = {
818 loose: !!options,
819 includePrerelease: false
820 };
821 }
822
823 if (comp instanceof Comparator) {
824 if (comp.loose === !!options.loose) {
825 return comp
826 } else {
827 comp = comp.value;
828 }
829 }
830
831 if (!(this instanceof Comparator)) {
832 return new Comparator(comp, options)
833 }
834
835 debug('comparator', comp, options);
836 this.options = options;
837 this.loose = !!options.loose;
838 this.parse(comp);
839
840 if (this.semver === ANY) {
841 this.value = '';
842 } else {
843 this.value = this.operator + this.semver.version;
844 }
845
846 debug('comp', this);
847 }
848
849 var ANY = {};
850 Comparator.prototype.parse = function (comp) {
851 var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
852 var m = comp.match(r);
853
854 if (!m) {
855 throw new TypeError('Invalid comparator: ' + comp)
856 }
857
858 this.operator = m[1] !== undefined ? m[1] : '';
859 if (this.operator === '=') {
860 this.operator = '';
861 }
862
863 // if it literally is just '>' or '' then allow anything.
864 if (!m[2]) {
865 this.semver = ANY;
866 } else {
867 this.semver = new SemVer(m[2], this.options.loose);
868 }
869 };
870
871 Comparator.prototype.toString = function () {
872 return this.value
873 };
874
875 Comparator.prototype.test = function (version) {
876 debug('Comparator.test', version, this.options.loose);
877
878 if (this.semver === ANY || version === ANY) {
879 return true
880 }
881
882 if (typeof version === 'string') {
883 try {
884 version = new SemVer(version, this.options);
885 } catch (er) {
886 return false
887 }
888 }
889
890 return cmp(version, this.operator, this.semver, this.options)
891 };
892
893 Comparator.prototype.intersects = function (comp, options) {
894 if (!(comp instanceof Comparator)) {
895 throw new TypeError('a Comparator is required')
896 }
897
898 if (!options || typeof options !== 'object') {
899 options = {
900 loose: !!options,
901 includePrerelease: false
902 };
903 }
904
905 var rangeTmp;
906
907 if (this.operator === '') {
908 if (this.value === '') {
909 return true
910 }
911 rangeTmp = new Range(comp.value, options);
912 return satisfies(this.value, rangeTmp, options)
913 } else if (comp.operator === '') {
914 if (comp.value === '') {
915 return true
916 }
917 rangeTmp = new Range(this.value, options);
918 return satisfies(comp.semver, rangeTmp, options)
919 }
920
921 var sameDirectionIncreasing =
922 (this.operator === '>=' || this.operator === '>') &&
923 (comp.operator === '>=' || comp.operator === '>');
924 var sameDirectionDecreasing =
925 (this.operator === '<=' || this.operator === '<') &&
926 (comp.operator === '<=' || comp.operator === '<');
927 var sameSemVer = this.semver.version === comp.semver.version;
928 var differentDirectionsInclusive =
929 (this.operator === '>=' || this.operator === '<=') &&
930 (comp.operator === '>=' || comp.operator === '<=');
931 var oppositeDirectionsLessThan =
932 cmp(this.semver, '<', comp.semver, options) &&
933 ((this.operator === '>=' || this.operator === '>') &&
934 (comp.operator === '<=' || comp.operator === '<'));
935 var oppositeDirectionsGreaterThan =
936 cmp(this.semver, '>', comp.semver, options) &&
937 ((this.operator === '<=' || this.operator === '<') &&
938 (comp.operator === '>=' || comp.operator === '>'));
939
940 return sameDirectionIncreasing || sameDirectionDecreasing ||
941 (sameSemVer && differentDirectionsInclusive) ||
942 oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
943 };
944
945 exports.Range = Range;
946 function Range (range, options) {
947 if (!options || typeof options !== 'object') {
948 options = {
949 loose: !!options,
950 includePrerelease: false
951 };
952 }
953
954 if (range instanceof Range) {
955 if (range.loose === !!options.loose &&
956 range.includePrerelease === !!options.includePrerelease) {
957 return range
958 } else {
959 return new Range(range.raw, options)
960 }
961 }
962
963 if (range instanceof Comparator) {
964 return new Range(range.value, options)
965 }
966
967 if (!(this instanceof Range)) {
968 return new Range(range, options)
969 }
970
971 this.options = options;
972 this.loose = !!options.loose;
973 this.includePrerelease = !!options.includePrerelease;
974
975 // First, split based on boolean or ||
976 this.raw = range;
977 this.set = range.split(/\s*\|\|\s*/).map(function (range) {
978 return this.parseRange(range.trim())
979 }, this).filter(function (c) {
980 // throw out any that are not relevant for whatever reason
981 return c.length
982 });
983
984 if (!this.set.length) {
985 throw new TypeError('Invalid SemVer Range: ' + range)
986 }
987
988 this.format();
989 }
990
991 Range.prototype.format = function () {
992 this.range = this.set.map(function (comps) {
993 return comps.join(' ').trim()
994 }).join('||').trim();
995 return this.range
996 };
997
998 Range.prototype.toString = function () {
999 return this.range
1000 };
1001
1002 Range.prototype.parseRange = function (range) {
1003 var loose = this.options.loose;
1004 range = range.trim();
1005 // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
1006 var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
1007 range = range.replace(hr, hyphenReplace);
1008 debug('hyphen replace', range);
1009 // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
1010 range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
1011 debug('comparator trim', range, re[t.COMPARATORTRIM]);
1012
1013 // `~ 1.2.3` => `~1.2.3`
1014 range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
1015
1016 // `^ 1.2.3` => `^1.2.3`
1017 range = range.replace(re[t.CARETTRIM], caretTrimReplace);
1018
1019 // normalize spaces
1020 range = range.split(/\s+/).join(' ');
1021
1022 // At this point, the range is completely trimmed and
1023 // ready to be split into comparators.
1024
1025 var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1026 var set = range.split(' ').map(function (comp) {
1027 return parseComparator(comp, this.options)
1028 }, this).join(' ').split(/\s+/);
1029 if (this.options.loose) {
1030 // in loose mode, throw out any that are not valid comparators
1031 set = set.filter(function (comp) {
1032 return !!comp.match(compRe)
1033 });
1034 }
1035 set = set.map(function (comp) {
1036 return new Comparator(comp, this.options)
1037 }, this);
1038
1039 return set
1040 };
1041
1042 Range.prototype.intersects = function (range, options) {
1043 if (!(range instanceof Range)) {
1044 throw new TypeError('a Range is required')
1045 }
1046
1047 return this.set.some(function (thisComparators) {
1048 return (
1049 isSatisfiable(thisComparators, options) &&
1050 range.set.some(function (rangeComparators) {
1051 return (
1052 isSatisfiable(rangeComparators, options) &&
1053 thisComparators.every(function (thisComparator) {
1054 return rangeComparators.every(function (rangeComparator) {
1055 return thisComparator.intersects(rangeComparator, options)
1056 })
1057 })
1058 )
1059 })
1060 )
1061 })
1062 };
1063
1064 // take a set of comparators and determine whether there
1065 // exists a version which can satisfy it
1066 function isSatisfiable (comparators, options) {
1067 var result = true;
1068 var remainingComparators = comparators.slice();
1069 var testComparator = remainingComparators.pop();
1070
1071 while (result && remainingComparators.length) {
1072 result = remainingComparators.every(function (otherComparator) {
1073 return testComparator.intersects(otherComparator, options)
1074 });
1075
1076 testComparator = remainingComparators.pop();
1077 }
1078
1079 return result
1080 }
1081
1082 // Mostly just for testing and legacy API reasons
1083 exports.toComparators = toComparators;
1084 function toComparators (range, options) {
1085 return new Range(range, options).set.map(function (comp) {
1086 return comp.map(function (c) {
1087 return c.value
1088 }).join(' ').trim().split(' ')
1089 })
1090 }
1091
1092 // comprised of xranges, tildes, stars, and gtlt's at this point.
1093 // already replaced the hyphen ranges
1094 // turn into a set of JUST comparators.
1095 function parseComparator (comp, options) {
1096 debug('comp', comp, options);
1097 comp = replaceCarets(comp, options);
1098 debug('caret', comp);
1099 comp = replaceTildes(comp, options);
1100 debug('tildes', comp);
1101 comp = replaceXRanges(comp, options);
1102 debug('xrange', comp);
1103 comp = replaceStars(comp, options);
1104 debug('stars', comp);
1105 return comp
1106 }
1107
1108 function isX (id) {
1109 return !id || id.toLowerCase() === 'x' || id === '*'
1110 }
1111
1112 // ~, ~> --> * (any, kinda silly)
1113 // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
1114 // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
1115 // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
1116 // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
1117 // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
1118 function replaceTildes (comp, options) {
1119 return comp.trim().split(/\s+/).map(function (comp) {
1120 return replaceTilde(comp, options)
1121 }).join(' ')
1122 }
1123
1124 function replaceTilde (comp, options) {
1125 var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1126 return comp.replace(r, function (_, M, m, p, pr) {
1127 debug('tilde', comp, _, M, m, p, pr);
1128 var ret;
1129
1130 if (isX(M)) {
1131 ret = '';
1132 } else if (isX(m)) {
1133 ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
1134 } else if (isX(p)) {
1135 // ~1.2 == >=1.2.0 <1.3.0
1136 ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
1137 } else if (pr) {
1138 debug('replaceTilde pr', pr);
1139 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
1140 ' <' + M + '.' + (+m + 1) + '.0';
1141 } else {
1142 // ~1.2.3 == >=1.2.3 <1.3.0
1143 ret = '>=' + M + '.' + m + '.' + p +
1144 ' <' + M + '.' + (+m + 1) + '.0';
1145 }
1146
1147 debug('tilde return', ret);
1148 return ret
1149 })
1150 }
1151
1152 // ^ --> * (any, kinda silly)
1153 // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
1154 // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
1155 // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
1156 // ^1.2.3 --> >=1.2.3 <2.0.0
1157 // ^1.2.0 --> >=1.2.0 <2.0.0
1158 function replaceCarets (comp, options) {
1159 return comp.trim().split(/\s+/).map(function (comp) {
1160 return replaceCaret(comp, options)
1161 }).join(' ')
1162 }
1163
1164 function replaceCaret (comp, options) {
1165 debug('caret', comp, options);
1166 var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1167 return comp.replace(r, function (_, M, m, p, pr) {
1168 debug('caret', comp, _, M, m, p, pr);
1169 var ret;
1170
1171 if (isX(M)) {
1172 ret = '';
1173 } else if (isX(m)) {
1174 ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
1175 } else if (isX(p)) {
1176 if (M === '0') {
1177 ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
1178 } else {
1179 ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
1180 }
1181 } else if (pr) {
1182 debug('replaceCaret pr', pr);
1183 if (M === '0') {
1184 if (m === '0') {
1185 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
1186 ' <' + M + '.' + m + '.' + (+p + 1);
1187 } else {
1188 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
1189 ' <' + M + '.' + (+m + 1) + '.0';
1190 }
1191 } else {
1192 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
1193 ' <' + (+M + 1) + '.0.0';
1194 }
1195 } else {
1196 debug('no pr');
1197 if (M === '0') {
1198 if (m === '0') {
1199 ret = '>=' + M + '.' + m + '.' + p +
1200 ' <' + M + '.' + m + '.' + (+p + 1);
1201 } else {
1202 ret = '>=' + M + '.' + m + '.' + p +
1203 ' <' + M + '.' + (+m + 1) + '.0';
1204 }
1205 } else {
1206 ret = '>=' + M + '.' + m + '.' + p +
1207 ' <' + (+M + 1) + '.0.0';
1208 }
1209 }
1210
1211 debug('caret return', ret);
1212 return ret
1213 })
1214 }
1215
1216 function replaceXRanges (comp, options) {
1217 debug('replaceXRanges', comp, options);
1218 return comp.split(/\s+/).map(function (comp) {
1219 return replaceXRange(comp, options)
1220 }).join(' ')
1221 }
1222
1223 function replaceXRange (comp, options) {
1224 comp = comp.trim();
1225 var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
1226 return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
1227 debug('xRange', comp, ret, gtlt, M, m, p, pr);
1228 var xM = isX(M);
1229 var xm = xM || isX(m);
1230 var xp = xm || isX(p);
1231 var anyX = xp;
1232
1233 if (gtlt === '=' && anyX) {
1234 gtlt = '';
1235 }
1236
1237 // if we're including prereleases in the match, then we need
1238 // to fix this to -0, the lowest possible prerelease value
1239 pr = options.includePrerelease ? '-0' : '';
1240
1241 if (xM) {
1242 if (gtlt === '>' || gtlt === '<') {
1243 // nothing is allowed
1244 ret = '<0.0.0-0';
1245 } else {
1246 // nothing is forbidden
1247 ret = '*';
1248 }
1249 } else if (gtlt && anyX) {
1250 // we know patch is an x, because we have any x at all.
1251 // replace X with 0
1252 if (xm) {
1253 m = 0;
1254 }
1255 p = 0;
1256
1257 if (gtlt === '>') {
1258 // >1 => >=2.0.0
1259 // >1.2 => >=1.3.0
1260 // >1.2.3 => >= 1.2.4
1261 gtlt = '>=';
1262 if (xm) {
1263 M = +M + 1;
1264 m = 0;
1265 p = 0;
1266 } else {
1267 m = +m + 1;
1268 p = 0;
1269 }
1270 } else if (gtlt === '<=') {
1271 // <=0.7.x is actually <0.8.0, since any 0.7.x should
1272 // pass. Similarly, <=7.x is actually <8.0.0, etc.
1273 gtlt = '<';
1274 if (xm) {
1275 M = +M + 1;
1276 } else {
1277 m = +m + 1;
1278 }
1279 }
1280
1281 ret = gtlt + M + '.' + m + '.' + p + pr;
1282 } else if (xm) {
1283 ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
1284 } else if (xp) {
1285 ret = '>=' + M + '.' + m + '.0' + pr +
1286 ' <' + M + '.' + (+m + 1) + '.0' + pr;
1287 }
1288
1289 debug('xRange return', ret);
1290
1291 return ret
1292 })
1293 }
1294
1295 // Because * is AND-ed with everything else in the comparator,
1296 // and '' means "any version", just remove the *s entirely.
1297 function replaceStars (comp, options) {
1298 debug('replaceStars', comp, options);
1299 // Looseness is ignored here. star is always as loose as it gets!
1300 return comp.trim().replace(re[t.STAR], '')
1301 }
1302
1303 // This function is passed to string.replace(re[t.HYPHENRANGE])
1304 // M, m, patch, prerelease, build
1305 // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
1306 // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
1307 // 1.2 - 3.4 => >=1.2.0 <3.5.0
1308 function hyphenReplace ($0,
1309 from, fM, fm, fp, fpr, fb,
1310 to, tM, tm, tp, tpr, tb) {
1311 if (isX(fM)) {
1312 from = '';
1313 } else if (isX(fm)) {
1314 from = '>=' + fM + '.0.0';
1315 } else if (isX(fp)) {
1316 from = '>=' + fM + '.' + fm + '.0';
1317 } else {
1318 from = '>=' + from;
1319 }
1320
1321 if (isX(tM)) {
1322 to = '';
1323 } else if (isX(tm)) {
1324 to = '<' + (+tM + 1) + '.0.0';
1325 } else if (isX(tp)) {
1326 to = '<' + tM + '.' + (+tm + 1) + '.0';
1327 } else if (tpr) {
1328 to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
1329 } else {
1330 to = '<=' + to;
1331 }
1332
1333 return (from + ' ' + to).trim()
1334 }
1335
1336 // if ANY of the sets match ALL of its comparators, then pass
1337 Range.prototype.test = function (version) {
1338 if (!version) {
1339 return false
1340 }
1341
1342 if (typeof version === 'string') {
1343 try {
1344 version = new SemVer(version, this.options);
1345 } catch (er) {
1346 return false
1347 }
1348 }
1349
1350 for (var i = 0; i < this.set.length; i++) {
1351 if (testSet(this.set[i], version, this.options)) {
1352 return true
1353 }
1354 }
1355 return false
1356 };
1357
1358 function testSet (set, version, options) {
1359 for (var i = 0; i < set.length; i++) {
1360 if (!set[i].test(version)) {
1361 return false
1362 }
1363 }
1364
1365 if (version.prerelease.length && !options.includePrerelease) {
1366 // Find the set of versions that are allowed to have prereleases
1367 // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
1368 // That should allow `1.2.3-pr.2` to pass.
1369 // However, `1.2.4-alpha.notready` should NOT be allowed,
1370 // even though it's within the range set by the comparators.
1371 for (i = 0; i < set.length; i++) {
1372 debug(set[i].semver);
1373 if (set[i].semver === ANY) {
1374 continue
1375 }
1376
1377 if (set[i].semver.prerelease.length > 0) {
1378 var allowed = set[i].semver;
1379 if (allowed.major === version.major &&
1380 allowed.minor === version.minor &&
1381 allowed.patch === version.patch) {
1382 return true
1383 }
1384 }
1385 }
1386
1387 // Version has a -pre, but it's not one of the ones we like.
1388 return false
1389 }
1390
1391 return true
1392 }
1393
1394 exports.satisfies = satisfies;
1395 function satisfies (version, range, options) {
1396 try {
1397 range = new Range(range, options);
1398 } catch (er) {
1399 return false
1400 }
1401 return range.test(version)
1402 }
1403
1404 exports.maxSatisfying = maxSatisfying;
1405 function maxSatisfying (versions, range, options) {
1406 var max = null;
1407 var maxSV = null;
1408 try {
1409 var rangeObj = new Range(range, options);
1410 } catch (er) {
1411 return null
1412 }
1413 versions.forEach(function (v) {
1414 if (rangeObj.test(v)) {
1415 // satisfies(v, range, options)
1416 if (!max || maxSV.compare(v) === -1) {
1417 // compare(max, v, true)
1418 max = v;
1419 maxSV = new SemVer(max, options);
1420 }
1421 }
1422 });
1423 return max
1424 }
1425
1426 exports.minSatisfying = minSatisfying;
1427 function minSatisfying (versions, range, options) {
1428 var min = null;
1429 var minSV = null;
1430 try {
1431 var rangeObj = new Range(range, options);
1432 } catch (er) {
1433 return null
1434 }
1435 versions.forEach(function (v) {
1436 if (rangeObj.test(v)) {
1437 // satisfies(v, range, options)
1438 if (!min || minSV.compare(v) === 1) {
1439 // compare(min, v, true)
1440 min = v;
1441 minSV = new SemVer(min, options);
1442 }
1443 }
1444 });
1445 return min
1446 }
1447
1448 exports.minVersion = minVersion;
1449 function minVersion (range, loose) {
1450 range = new Range(range, loose);
1451
1452 var minver = new SemVer('0.0.0');
1453 if (range.test(minver)) {
1454 return minver
1455 }
1456
1457 minver = new SemVer('0.0.0-0');
1458 if (range.test(minver)) {
1459 return minver
1460 }
1461
1462 minver = null;
1463 for (var i = 0; i < range.set.length; ++i) {
1464 var comparators = range.set[i];
1465
1466 comparators.forEach(function (comparator) {
1467 // Clone to avoid manipulating the comparator's semver object.
1468 var compver = new SemVer(comparator.semver.version);
1469 switch (comparator.operator) {
1470 case '>':
1471 if (compver.prerelease.length === 0) {
1472 compver.patch++;
1473 } else {
1474 compver.prerelease.push(0);
1475 }
1476 compver.raw = compver.format();
1477 /* fallthrough */
1478 case '':
1479 case '>=':
1480 if (!minver || gt(minver, compver)) {
1481 minver = compver;
1482 }
1483 break
1484 case '<':
1485 case '<=':
1486 /* Ignore maximum versions */
1487 break
1488 /* istanbul ignore next */
1489 default:
1490 throw new Error('Unexpected operation: ' + comparator.operator)
1491 }
1492 });
1493 }
1494
1495 if (minver && range.test(minver)) {
1496 return minver
1497 }
1498
1499 return null
1500 }
1501
1502 exports.validRange = validRange;
1503 function validRange (range, options) {
1504 try {
1505 // Return '*' instead of '' so that truthiness works.
1506 // This will throw if it's invalid anyway
1507 return new Range(range, options).range || '*'
1508 } catch (er) {
1509 return null
1510 }
1511 }
1512
1513 // Determine if version is less than all the versions possible in the range
1514 exports.ltr = ltr;
1515 function ltr (version, range, options) {
1516 return outside(version, range, '<', options)
1517 }
1518
1519 // Determine if version is greater than all the versions possible in the range.
1520 exports.gtr = gtr;
1521 function gtr (version, range, options) {
1522 return outside(version, range, '>', options)
1523 }
1524
1525 exports.outside = outside;
1526 function outside (version, range, hilo, options) {
1527 version = new SemVer(version, options);
1528 range = new Range(range, options);
1529
1530 var gtfn, ltefn, ltfn, comp, ecomp;
1531 switch (hilo) {
1532 case '>':
1533 gtfn = gt;
1534 ltefn = lte;
1535 ltfn = lt;
1536 comp = '>';
1537 ecomp = '>=';
1538 break
1539 case '<':
1540 gtfn = lt;
1541 ltefn = gte;
1542 ltfn = gt;
1543 comp = '<';
1544 ecomp = '<=';
1545 break
1546 default:
1547 throw new TypeError('Must provide a hilo val of "<" or ">"')
1548 }
1549
1550 // If it satisifes the range it is not outside
1551 if (satisfies(version, range, options)) {
1552 return false
1553 }
1554
1555 // From now on, variable terms are as if we're in "gtr" mode.
1556 // but note that everything is flipped for the "ltr" function.
1557
1558 for (var i = 0; i < range.set.length; ++i) {
1559 var comparators = range.set[i];
1560
1561 var high = null;
1562 var low = null;
1563
1564 comparators.forEach(function (comparator) {
1565 if (comparator.semver === ANY) {
1566 comparator = new Comparator('>=0.0.0');
1567 }
1568 high = high || comparator;
1569 low = low || comparator;
1570 if (gtfn(comparator.semver, high.semver, options)) {
1571 high = comparator;
1572 } else if (ltfn(comparator.semver, low.semver, options)) {
1573 low = comparator;
1574 }
1575 });
1576
1577 // If the edge version comparator has a operator then our version
1578 // isn't outside it
1579 if (high.operator === comp || high.operator === ecomp) {
1580 return false
1581 }
1582
1583 // If the lowest version comparator has an operator and our version
1584 // is less than it then it isn't higher than the range
1585 if ((!low.operator || low.operator === comp) &&
1586 ltefn(version, low.semver)) {
1587 return false
1588 } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1589 return false
1590 }
1591 }
1592 return true
1593 }
1594
1595 exports.prerelease = prerelease;
1596 function prerelease (version, options) {
1597 var parsed = parse(version, options);
1598 return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
1599 }
1600
1601 exports.intersects = intersects;
1602 function intersects (r1, r2, options) {
1603 r1 = new Range(r1, options);
1604 r2 = new Range(r2, options);
1605 return r1.intersects(r2)
1606 }
1607
1608 exports.coerce = coerce;
1609 function coerce (version, options) {
1610 if (version instanceof SemVer) {
1611 return version
1612 }
1613
1614 if (typeof version === 'number') {
1615 version = String(version);
1616 }
1617
1618 if (typeof version !== 'string') {
1619 return null
1620 }
1621
1622 options = options || {};
1623
1624 var match = null;
1625 if (!options.rtl) {
1626 match = version.match(re[t.COERCE]);
1627 } else {
1628 // Find the right-most coercible string that does not share
1629 // a terminus with a more left-ward coercible string.
1630 // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
1631 //
1632 // Walk through the string checking with a /g regexp
1633 // Manually set the index so as to pick up overlapping matches.
1634 // Stop when we get a match that ends at the string end, since no
1635 // coercible string can be more right-ward without the same terminus.
1636 var next;
1637 while ((next = re[t.COERCERTL].exec(version)) &&
1638 (!match || match.index + match[0].length !== version.length)
1639 ) {
1640 if (!match ||
1641 next.index + next[0].length !== match.index + match[0].length) {
1642 match = next;
1643 }
1644 re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
1645 }
1646 // leave it in a clean state
1647 re[t.COERCERTL].lastIndex = -1;
1648 }
1649
1650 if (match === null) {
1651 return null
1652 }
1653
1654 return parse(match[2] +
1655 '.' + (match[3] || '0') +
1656 '.' + (match[4] || '0'), options)
1657 }
1658 });
1659 var semver_1 = semver.SEMVER_SPEC_VERSION;
1660 var semver_2 = semver.re;
1661 var semver_3 = semver.src;
1662 var semver_4 = semver.tokens;
1663 var semver_5 = semver.parse;
1664 var semver_6 = semver.valid;
1665 var semver_7 = semver.clean;
1666 var semver_8 = semver.SemVer;
1667 var semver_9 = semver.inc;
1668 var semver_10 = semver.diff;
1669 var semver_11 = semver.compareIdentifiers;
1670 var semver_12 = semver.rcompareIdentifiers;
1671 var semver_13 = semver.major;
1672 var semver_14 = semver.minor;
1673 var semver_15 = semver.patch;
1674 var semver_16 = semver.compare;
1675 var semver_17 = semver.compareLoose;
1676 var semver_18 = semver.compareBuild;
1677 var semver_19 = semver.rcompare;
1678 var semver_20 = semver.sort;
1679 var semver_21 = semver.rsort;
1680 var semver_22 = semver.gt;
1681 var semver_23 = semver.lt;
1682 var semver_24 = semver.eq;
1683 var semver_25 = semver.neq;
1684 var semver_26 = semver.gte;
1685 var semver_27 = semver.lte;
1686 var semver_28 = semver.cmp;
1687 var semver_29 = semver.Comparator;
1688 var semver_30 = semver.Range;
1689 var semver_31 = semver.toComparators;
1690 var semver_32 = semver.satisfies;
1691 var semver_33 = semver.maxSatisfying;
1692 var semver_34 = semver.minSatisfying;
1693 var semver_35 = semver.minVersion;
1694 var semver_36 = semver.validRange;
1695 var semver_37 = semver.ltr;
1696 var semver_38 = semver.gtr;
1697 var semver_39 = semver.outside;
1698 var semver_40 = semver.prerelease;
1699 var semver_41 = semver.intersects;
1700 var semver_42 = semver.coerce;
1701
1702 var NAME_SELECTOR = 'NAME_SELECTOR';
1703 var COMPONENT_SELECTOR = 'COMPONENT_SELECTOR';
1704 var REF_SELECTOR = 'REF_SELECTOR';
1705 var DOM_SELECTOR = 'DOM_SELECTOR';
1706 var INVALID_SELECTOR = 'INVALID_SELECTOR';
1707
1708 var VUE_VERSION = Number(
1709 ((Vue.version.split('.')[0]) + "." + (Vue.version.split('.')[1]))
1710 );
1711
1712 var FUNCTIONAL_OPTIONS =
1713 VUE_VERSION >= 2.5 ? 'fnOptions' : 'functionalOptions';
1714
1715 var BEFORE_RENDER_LIFECYCLE_HOOK = semver.gt(Vue.version, '2.1.8')
1716 ? 'beforeCreate'
1717 : 'beforeMount';
1718
1719 var CREATE_ELEMENT_ALIAS = semver.gt(Vue.version, '2.1.5')
1720 ? '_c'
1721 : '_h';
1722
1723 //
1724
1725 function throwError(msg) {
1726 throw new Error(("[vue-test-utils]: " + msg))
1727 }
1728
1729 function warn(msg) {
1730 console.error(("[vue-test-utils]: " + msg));
1731 }
1732
1733 var camelizeRE = /-(\w)/g;
1734
1735 var camelize = function (str) {
1736 var camelizedStr = str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }
1737 );
1738 return camelizedStr.charAt(0).toLowerCase() + camelizedStr.slice(1)
1739 };
1740
1741 /**
1742 * Capitalize a string.
1743 */
1744 var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.slice(1); };
1745
1746 /**
1747 * Hyphenate a camelCase string.
1748 */
1749 var hyphenateRE = /\B([A-Z])/g;
1750 var hyphenate = function (str) { return str.replace(hyphenateRE, '-$1').toLowerCase(); };
1751
1752 function hasOwnProperty(obj, prop) {
1753 return Object.prototype.hasOwnProperty.call(obj, prop)
1754 }
1755
1756 function keys(obj) {
1757 return Object.keys(obj)
1758 }
1759
1760 function resolveComponent(id, components) {
1761 if (typeof id !== 'string') {
1762 return
1763 }
1764 // check local registration variations first
1765 if (hasOwnProperty(components, id)) {
1766 return components[id]
1767 }
1768 var camelizedId = camelize(id);
1769 if (hasOwnProperty(components, camelizedId)) {
1770 return components[camelizedId]
1771 }
1772 var PascalCaseId = capitalize(camelizedId);
1773 if (hasOwnProperty(components, PascalCaseId)) {
1774 return components[PascalCaseId]
1775 }
1776 // fallback to prototype chain
1777 return components[id] || components[camelizedId] || components[PascalCaseId]
1778 }
1779
1780 var UA =
1781 typeof window !== 'undefined' &&
1782 'navigator' in window &&
1783 navigator.userAgent.toLowerCase();
1784
1785 var isPhantomJS = UA && UA.includes && UA.match(/phantomjs/i);
1786
1787 var isEdge = UA && UA.indexOf('edge/') > 0;
1788 var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
1789
1790 // get the event used to trigger v-model handler that updates bound data
1791 function getCheckedEvent() {
1792 var version = Vue.version;
1793
1794 if (semver.satisfies(version, '2.1.9 - 2.1.10')) {
1795 return 'click'
1796 }
1797
1798 if (semver.satisfies(version, '2.2 - 2.4')) {
1799 return isChrome ? 'click' : 'change'
1800 }
1801
1802 // change is handler for version 2.0 - 2.1.8, and 2.5+
1803 return 'change'
1804 }
1805
1806 /**
1807 * Normalize nextTick to return a promise for all Vue 2 versions.
1808 * Vue < 2.1 does not return a Promise from nextTick
1809 * @return {Promise<R>}
1810 */
1811 function nextTick() {
1812 if (VUE_VERSION > 2) { return Vue.nextTick() }
1813 return new Promise(function (resolve) {
1814 Vue.nextTick(resolve);
1815 })
1816 }
1817
1818 function warnDeprecated(method, fallback) {
1819 if ( fallback === void 0 ) fallback = '';
1820
1821 if (!config.showDeprecationWarnings) { return }
1822 var msg = method + " is deprecated and will be removed in the next major version.";
1823 if (fallback) { msg += " " + fallback + "."; }
1824 warn(msg);
1825 }
1826
1827 //
1828
1829 function addMocks(
1830 _Vue,
1831 mockedProperties
1832 ) {
1833 if ( mockedProperties === void 0 ) mockedProperties = {};
1834
1835 if (mockedProperties === false) {
1836 return
1837 }
1838 Object.keys(mockedProperties).forEach(function (key) {
1839 try {
1840 // $FlowIgnore
1841 _Vue.prototype[key] = mockedProperties[key];
1842 } catch (e) {
1843 warn(
1844 "could not overwrite property " + key + ", this is " +
1845 "usually caused by a plugin that has added " +
1846 "the property as a read-only value"
1847 );
1848 }
1849 // $FlowIgnore
1850 Vue.util.defineReactive(_Vue, key, mockedProperties[key]);
1851 });
1852 }
1853
1854 //
1855
1856 function logEvents(
1857 vm,
1858 emitted,
1859 emittedByOrder
1860 ) {
1861 var emit = vm.$emit;
1862 vm.$emit = function (name) {
1863 var args = [], len = arguments.length - 1;
1864 while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
1865 (emitted[name] || (emitted[name] = [])).push(args);
1866 emittedByOrder.push({ name: name, args: args });
1867 return emit.call.apply(emit, [ vm, name ].concat( args ))
1868 };
1869 }
1870
1871 function addEventLogger(_Vue) {
1872 _Vue.mixin({
1873 beforeCreate: function() {
1874 this.__emitted = Object.create(null);
1875 this.__emittedByOrder = [];
1876 logEvents(this, this.__emitted, this.__emittedByOrder);
1877 }
1878 });
1879 }
1880
1881 function addStubs(_Vue, stubComponents) {
1882 var obj;
1883
1884 function addStubComponentsMixin() {
1885 Object.assign(this.$options.components, stubComponents);
1886 }
1887
1888 _Vue.mixin(( obj = {}, obj[BEFORE_RENDER_LIFECYCLE_HOOK] = addStubComponentsMixin, obj ));
1889 }
1890
1891 //
1892
1893 function isDomSelector(selector) {
1894 if (typeof selector !== 'string') {
1895 return false
1896 }
1897
1898 try {
1899 if (typeof document === 'undefined') {
1900 throwError(
1901 "mount must be run in a browser environment like " +
1902 "PhantomJS, jsdom or chrome"
1903 );
1904 }
1905 } catch (error) {
1906 throwError(
1907 "mount must be run in a browser environment like " +
1908 "PhantomJS, jsdom or chrome"
1909 );
1910 }
1911
1912 try {
1913 document.querySelector(selector);
1914 return true
1915 } catch (error) {
1916 return false
1917 }
1918 }
1919
1920 function isVueComponent(c) {
1921 if (isConstructor(c)) {
1922 return true
1923 }
1924
1925 if (c === null || typeof c !== 'object') {
1926 return false
1927 }
1928
1929 if (c.extends || c._Ctor) {
1930 return true
1931 }
1932
1933 if (typeof c.template === 'string') {
1934 return true
1935 }
1936
1937 return typeof c.render === 'function'
1938 }
1939
1940 function componentNeedsCompiling(component) {
1941 return (
1942 component &&
1943 !component.render &&
1944 (component.template || component.extends || component.extendOptions) &&
1945 !component.functional
1946 )
1947 }
1948
1949 function isRefSelector(refOptionsObject) {
1950 if (
1951 typeof refOptionsObject !== 'object' ||
1952 Object.keys(refOptionsObject || {}).length !== 1
1953 ) {
1954 return false
1955 }
1956
1957 return typeof refOptionsObject.ref === 'string'
1958 }
1959
1960 function isNameSelector(nameOptionsObject) {
1961 if (typeof nameOptionsObject !== 'object' || nameOptionsObject === null) {
1962 return false
1963 }
1964
1965 return !!nameOptionsObject.name
1966 }
1967
1968 function isConstructor(c) {
1969 return typeof c === 'function' && c.cid
1970 }
1971
1972 function isDynamicComponent(c) {
1973 return typeof c === 'function' && !c.cid
1974 }
1975
1976 function isComponentOptions(c) {
1977 return typeof c === 'object' && (c.template || c.render)
1978 }
1979
1980 function isFunctionalComponent(c) {
1981 if (!isVueComponent(c)) {
1982 return false
1983 }
1984 if (isConstructor(c)) {
1985 return c.options.functional
1986 }
1987 return c.functional
1988 }
1989
1990 function templateContainsComponent(
1991 template,
1992 name
1993 ) {
1994 return [capitalize, camelize, hyphenate].some(function (format) {
1995 var re = new RegExp(("<" + (format(name)) + "\\s*(\\s|>|(/>))"), 'g');
1996 return re.test(template)
1997 })
1998 }
1999
2000 function isPlainObject(c) {
2001 return Object.prototype.toString.call(c) === '[object Object]'
2002 }
2003
2004 function isHTMLElement(c) {
2005 if (typeof HTMLElement === 'undefined') {
2006 return false
2007 }
2008 // eslint-disable-next-line no-undef
2009 return c instanceof HTMLElement
2010 }
2011
2012 function makeMap(str, expectsLowerCase) {
2013 var map = Object.create(null);
2014 var list = str.split(',');
2015 for (var i = 0; i < list.length; i++) {
2016 map[list[i]] = true;
2017 }
2018 return expectsLowerCase
2019 ? function(val) {
2020 return map[val.toLowerCase()]
2021 }
2022 : function(val) {
2023 return map[val]
2024 }
2025 }
2026
2027 var isHTMLTag = makeMap(
2028 'html,body,base,head,link,meta,style,title,' +
2029 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
2030 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
2031 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
2032 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,' +
2033 'embed,object,param,source,canvas,script,noscript,del,ins,' +
2034 'caption,col,colgroup,table,thead,tbody,td,th,tr,video,' +
2035 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
2036 'output,progress,select,textarea,' +
2037 'details,dialog,menu,menuitem,summary,' +
2038 'content,element,shadow,template,blockquote,iframe,tfoot'
2039 );
2040
2041 // this map is intentionally selective, only covering SVG elements that may
2042 // contain child elements.
2043 var isSVG = makeMap(
2044 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
2045 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
2046 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
2047 true
2048 );
2049
2050 var isReservedTag = function (tag) { return isHTMLTag(tag) || isSVG(tag); };
2051
2052 //
2053
2054 function compileTemplate(component) {
2055 if (component.template) {
2056 if (!vueTemplateCompiler.compileToFunctions) {
2057 throwError(
2058 "vueTemplateCompiler is undefined, you must pass " +
2059 "precompiled components if vue-template-compiler is " +
2060 "undefined"
2061 );
2062 }
2063
2064 if (component.template.charAt('#') === '#') {
2065 var el = document.querySelector(component.template);
2066 if (!el) {
2067 throwError('Cannot find element' + component.template);
2068
2069 el = document.createElement('div');
2070 }
2071 component.template = el.innerHTML;
2072 }
2073
2074 Object.assign(component, Object.assign({}, vueTemplateCompiler.compileToFunctions(component.template),
2075 {name: component.name}));
2076 }
2077
2078 if (component.components) {
2079 Object.keys(component.components).forEach(function (c) {
2080 var cmp = component.components[c];
2081 if (!cmp.render) {
2082 compileTemplate(cmp);
2083 }
2084 });
2085 }
2086
2087 if (component.extends) {
2088 compileTemplate(component.extends);
2089 }
2090
2091 if (component.extendOptions && !component.options.render) {
2092 compileTemplate(component.options);
2093 }
2094 }
2095
2096 function compileTemplateForSlots(slots) {
2097 Object.keys(slots).forEach(function (key) {
2098 var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
2099 slot.forEach(function (slotValue) {
2100 if (componentNeedsCompiling(slotValue)) {
2101 compileTemplate(slotValue);
2102 }
2103 });
2104 });
2105 }
2106
2107 //
2108
2109 var MOUNTING_OPTIONS = [
2110 'attachToDocument',
2111 'mocks',
2112 'slots',
2113 'localVue',
2114 'stubs',
2115 'context',
2116 'clone',
2117 'attrs',
2118 'listeners',
2119 'propsData',
2120 'shouldProxy'
2121 ];
2122
2123 function extractInstanceOptions(options) {
2124 var instanceOptions = Object.assign({}, options);
2125 MOUNTING_OPTIONS.forEach(function (mountingOption) {
2126 delete instanceOptions[mountingOption];
2127 });
2128 return instanceOptions
2129 }
2130
2131 //
2132
2133 function isDestructuringSlotScope(slotScope) {
2134 return /^{.*}$/.test(slotScope)
2135 }
2136
2137 function getVueTemplateCompilerHelpers(
2138 _Vue
2139 ) {
2140 // $FlowIgnore
2141 var vue = new _Vue();
2142 var helpers = {};
2143 var names = [
2144 '_c',
2145 '_o',
2146 '_n',
2147 '_s',
2148 '_l',
2149 '_t',
2150 '_q',
2151 '_i',
2152 '_m',
2153 '_f',
2154 '_k',
2155 '_b',
2156 '_v',
2157 '_e',
2158 '_u',
2159 '_g'
2160 ];
2161 names.forEach(function (name) {
2162 helpers[name] = vue._renderProxy[name];
2163 });
2164 helpers.$createElement = vue._renderProxy.$createElement;
2165 helpers.$set = vue._renderProxy.$set;
2166 return helpers
2167 }
2168
2169 function validateEnvironment() {
2170 if (VUE_VERSION < 2.1) {
2171 throwError("the scopedSlots option is only supported in vue@2.1+.");
2172 }
2173 }
2174
2175 function isScopedSlot(slot) {
2176 if (typeof slot === 'function') { return { match: null, slot: slot } }
2177
2178 var slotScopeRe = /<[^>]+ slot-scope="(.+)"/;
2179 var vSlotRe = /<template v-slot(?::.+)?="(.+)"/;
2180 var shortVSlotRe = /<template #.*="(.+)"/;
2181
2182 var hasOldSlotScope = slot.match(slotScopeRe);
2183 var hasVSlotScopeAttr = slot.match(vSlotRe);
2184 var hasShortVSlotScopeAttr = slot.match(shortVSlotRe);
2185
2186 if (hasOldSlotScope) {
2187 return { slot: slot, match: hasOldSlotScope }
2188 } else if (hasVSlotScopeAttr || hasShortVSlotScopeAttr) {
2189 // Strip v-slot and #slot attributes from `template` tag. compileToFunctions leaves empty `template` tag otherwise.
2190 var sanitizedSlot = slot.replace(
2191 /(<template)([^>]+)(>.+<\/template>)/,
2192 '$1$3'
2193 );
2194 return {
2195 slot: sanitizedSlot,
2196 match: hasVSlotScopeAttr || hasShortVSlotScopeAttr
2197 }
2198 }
2199 // we have no matches, so we just return
2200 return {
2201 slot: slot,
2202 match: null
2203 }
2204 }
2205
2206 // Hide warning about <template> disallowed as root element
2207 function customWarn(msg) {
2208 if (msg.indexOf('Cannot use <template> as component root element') === -1) {
2209 console.error(msg);
2210 }
2211 }
2212
2213 function createScopedSlots(
2214 scopedSlotsOption,
2215 _Vue
2216 ) {
2217 var scopedSlots = {};
2218 if (!scopedSlotsOption) {
2219 return scopedSlots
2220 }
2221 validateEnvironment();
2222 var helpers = getVueTemplateCompilerHelpers(_Vue);
2223 var loop = function ( scopedSlotName ) {
2224 var slot = scopedSlotsOption[scopedSlotName];
2225 var isFn = typeof slot === 'function';
2226
2227 var scopedSlotMatches = isScopedSlot(slot);
2228
2229 // Type check to silence flow (can't use isFn)
2230 var renderFn =
2231 typeof slot === 'function'
2232 ? slot
2233 : vueTemplateCompiler.compileToFunctions(scopedSlotMatches.slot, { warn: customWarn })
2234 .render;
2235
2236 var slotScope = scopedSlotMatches.match && scopedSlotMatches.match[1];
2237
2238 scopedSlots[scopedSlotName] = function(props) {
2239 var obj;
2240
2241 var res;
2242 if (isFn) {
2243 res = renderFn.call(Object.assign({}, helpers), props);
2244 } else if (slotScope && !isDestructuringSlotScope(slotScope)) {
2245 res = renderFn.call(Object.assign({}, helpers, ( obj = {}, obj[slotScope] = props, obj )));
2246 } else if (slotScope && isDestructuringSlotScope(slotScope)) {
2247 res = renderFn.call(Object.assign({}, helpers, props));
2248 } else {
2249 res = renderFn.call(Object.assign({}, helpers, {props: props}));
2250 }
2251 // res is Array if <template> is a root element
2252 return Array.isArray(res) ? res[0] : res
2253 };
2254 };
2255
2256 for (var scopedSlotName in scopedSlotsOption) loop( scopedSlotName );
2257 return scopedSlots
2258 }
2259
2260 //
2261
2262 function isVueComponentStub(comp) {
2263 return (comp && comp.template) || isVueComponent(comp)
2264 }
2265
2266 function isValidStub(stub) {
2267 return (
2268 typeof stub === 'boolean' ||
2269 (!!stub && typeof stub === 'string') ||
2270 isVueComponentStub(stub)
2271 )
2272 }
2273
2274 function resolveComponent$1(obj, component) {
2275 return (
2276 obj[component] ||
2277 obj[hyphenate(component)] ||
2278 obj[camelize(component)] ||
2279 obj[capitalize(camelize(component))] ||
2280 obj[capitalize(component)] ||
2281 {}
2282 )
2283 }
2284
2285 function getCoreProperties(componentOptions) {
2286 return {
2287 attrs: componentOptions.attrs,
2288 name: componentOptions.name,
2289 model: componentOptions.model,
2290 props: componentOptions.props,
2291 on: componentOptions.on,
2292 key: componentOptions.key,
2293 domProps: componentOptions.domProps,
2294 class: componentOptions.class,
2295 staticClass: componentOptions.staticClass,
2296 staticStyle: componentOptions.staticStyle,
2297 style: componentOptions.style,
2298 normalizedStyle: componentOptions.normalizedStyle,
2299 nativeOn: componentOptions.nativeOn,
2300 functional: componentOptions.functional
2301 }
2302 }
2303
2304 function createClassString(staticClass, dynamicClass) {
2305 // :class="someComputedObject" can return a string, object or undefined
2306 // if it is a string, we don't need to do anything special.
2307 var evaluatedDynamicClass = dynamicClass;
2308
2309 // if it is an object, eg { 'foo': true }, we need to evaluate it.
2310 // see https://github.com/vuejs/vue-test-utils/issues/1474 for more context.
2311 if (typeof dynamicClass === 'object') {
2312 evaluatedDynamicClass = Object.keys(dynamicClass).reduce(function (acc, key) {
2313 if (dynamicClass[key]) {
2314 return acc + ' ' + key
2315 }
2316 return acc
2317 }, '');
2318 }
2319
2320 if (staticClass && evaluatedDynamicClass) {
2321 return staticClass + ' ' + evaluatedDynamicClass
2322 }
2323 return staticClass || evaluatedDynamicClass
2324 }
2325
2326 function resolveOptions(component, _Vue) {
2327 if (isDynamicComponent(component)) {
2328 return {}
2329 }
2330
2331 return isConstructor(component)
2332 ? component.options
2333 : _Vue.extend(component).options
2334 }
2335
2336 function getScopedSlotRenderFunctions(ctx) {
2337 // In Vue 2.6+ a new v-slot syntax was introduced
2338 // scopedSlots are now saved in parent._vnode.data.scopedSlots
2339 // We filter out the _normalized and $stable key
2340 if (
2341 ctx &&
2342 ctx.$options &&
2343 ctx.$options.parent &&
2344 ctx.$options.parent._vnode &&
2345 ctx.$options.parent._vnode.data &&
2346 ctx.$options.parent._vnode.data.scopedSlots
2347 ) {
2348 var slotKeys = ctx.$options.parent._vnode.data.scopedSlots;
2349 return keys(slotKeys).filter(function (x) { return x !== '_normalized' && x !== '$stable'; })
2350 }
2351
2352 return []
2353 }
2354
2355 function createStubFromComponent(
2356 originalComponent,
2357 name,
2358 _Vue
2359 ) {
2360 var componentOptions = resolveOptions(originalComponent, _Vue);
2361 var tagName = (name || 'anonymous') + "-stub";
2362
2363 // ignoreElements does not exist in Vue 2.0.x
2364 if (Vue.config.ignoredElements) {
2365 Vue.config.ignoredElements.push(tagName);
2366 }
2367
2368 return Object.assign({}, getCoreProperties(componentOptions),
2369 {$_vueTestUtils_original: originalComponent,
2370 $_doNotStubChildren: true,
2371 render: function render(h, context) {
2372 var this$1 = this;
2373
2374 return h(
2375 tagName,
2376 {
2377 ref: componentOptions.functional ? context.data.ref : undefined,
2378 attrs: componentOptions.functional
2379 ? Object.assign({}, context.props,
2380 context.data.attrs,
2381 {class: createClassString(
2382 context.data.staticClass,
2383 context.data.class
2384 )})
2385 : Object.assign({}, this.$props)
2386 },
2387 context
2388 ? context.children
2389 : this.$options._renderChildren ||
2390 getScopedSlotRenderFunctions(this).map(function (x) { return this$1.$options.parent._vnode.data.scopedSlots[x](); }
2391 )
2392 )
2393 }})
2394 }
2395
2396 // DEPRECATED: converts string stub to template stub.
2397 function createStubFromString(templateString, name) {
2398 warnDeprecated('Using a string for stubs');
2399
2400 if (templateContainsComponent(templateString, name)) {
2401 throwError('options.stub cannot contain a circular reference');
2402 }
2403
2404 return {
2405 template: templateString,
2406 $_doNotStubChildren: true
2407 }
2408 }
2409
2410 function setStubComponentName(
2411 stub,
2412 originalComponent,
2413 _Vue
2414 ) {
2415 if ( originalComponent === void 0 ) originalComponent = {};
2416
2417 if (stub.name) { return }
2418
2419 var componentOptions = resolveOptions(originalComponent, _Vue);
2420 stub.name = getCoreProperties(componentOptions).name;
2421 }
2422
2423 function validateStub(stub) {
2424 if (!isValidStub(stub)) {
2425 throwError("options.stub values must be passed a string or " + "component");
2426 }
2427 }
2428
2429 function createStubsFromStubsObject(
2430 originalComponents,
2431 stubs,
2432 _Vue
2433 ) {
2434 if ( originalComponents === void 0 ) originalComponents = {};
2435
2436 return Object.keys(stubs || {}).reduce(function (acc, stubName) {
2437 var stub = stubs[stubName];
2438
2439 validateStub(stub);
2440
2441 if (stub === false) {
2442 return acc
2443 }
2444
2445 var component = resolveComponent$1(originalComponents, stubName);
2446
2447 if (stub === true) {
2448 acc[stubName] = createStubFromComponent(component, stubName, _Vue);
2449 return acc
2450 }
2451
2452 if (typeof stub === 'string') {
2453 stub = createStubFromString(stub, stubName);
2454 stubs[stubName];
2455 }
2456
2457 setStubComponentName(stub, component, _Vue);
2458 if (componentNeedsCompiling(stub)) {
2459 compileTemplate(stub);
2460 }
2461
2462 acc[stubName] = stub;
2463 stub._Ctor = {};
2464
2465 return acc
2466 }, {})
2467 }
2468
2469 var isAllowlisted = function (el, allowlist) { return resolveComponent(el, allowlist); };
2470 var isAlreadyStubbed = function (el, stubs) { return stubs.has(el); };
2471
2472 function shouldExtend(component, _Vue) {
2473 return isConstructor(component) || (component && component.extends)
2474 }
2475
2476 function extend(component, _Vue) {
2477 var componentOptions = component.options ? component.options : component;
2478 var stub = _Vue.extend(componentOptions);
2479 stub.options.$_vueTestUtils_original = component;
2480 stub.options._base = _Vue;
2481 return stub
2482 }
2483
2484 function createStubIfNeeded(shouldStub, component, _Vue, el) {
2485 if (shouldStub) {
2486 return createStubFromComponent(component || {}, el, _Vue)
2487 }
2488
2489 if (shouldExtend(component)) {
2490 return extend(component, _Vue)
2491 }
2492 }
2493
2494 function shouldNotBeStubbed(el, allowlist, modifiedComponents) {
2495 return (
2496 (typeof el === 'string' && isReservedTag(el)) ||
2497 isAllowlisted(el, allowlist) ||
2498 isAlreadyStubbed(el, modifiedComponents)
2499 )
2500 }
2501
2502 function patchCreateElement(_Vue, stubs, stubAllComponents) {
2503 var obj;
2504
2505 // This mixin patches vm.$createElement so that we can stub all components
2506 // before they are rendered in shallow mode. We also need to ensure that
2507 // component constructors were created from the _Vue constructor. If not,
2508 // we must replace them with components created from the _Vue constructor
2509 // before calling the original $createElement. This ensures that components
2510 // have the correct instance properties and stubs when they are rendered.
2511 function patchCreateElementMixin() {
2512 var vm = this;
2513
2514 if (vm.$options.$_doNotStubChildren || vm.$options._isFunctionalContainer) {
2515 return
2516 }
2517
2518 var modifiedComponents = new Set();
2519 var originalCreateElement = vm.$createElement;
2520 var originalComponents = vm.$options.components;
2521
2522 var createElement = function (el) {
2523 var obj;
2524
2525 var args = [], len = arguments.length - 1;
2526 while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
2527 if (shouldNotBeStubbed(el, stubs, modifiedComponents)) {
2528 return originalCreateElement.apply(void 0, [ el ].concat( args ))
2529 }
2530
2531 if (isConstructor(el) || isComponentOptions(el)) {
2532 if (stubAllComponents) {
2533 var stub = createStubFromComponent(el, el.name || 'anonymous', _Vue);
2534 return originalCreateElement.apply(void 0, [ stub ].concat( args ))
2535 }
2536 var Constructor = shouldExtend(el) ? extend(el, _Vue) : el;
2537
2538 return originalCreateElement.apply(void 0, [ Constructor ].concat( args ))
2539 }
2540
2541 if (typeof el === 'string') {
2542 var original = resolveComponent(el, originalComponents);
2543
2544 if (!original) {
2545 return originalCreateElement.apply(void 0, [ el ].concat( args ))
2546 }
2547
2548 if (isDynamicComponent(original)) {
2549 return originalCreateElement.apply(void 0, [ el ].concat( args ))
2550 }
2551
2552 var stub$1 = createStubIfNeeded(stubAllComponents, original, _Vue, el);
2553
2554 if (stub$1) {
2555 Object.assign(vm.$options.components, ( obj = {}, obj[el] = stub$1, obj ));
2556 modifiedComponents.add(el);
2557 }
2558 }
2559
2560 return originalCreateElement.apply(void 0, [ el ].concat( args ))
2561 };
2562
2563 vm[CREATE_ELEMENT_ALIAS] = createElement;
2564 vm.$createElement = createElement;
2565 }
2566
2567 _Vue.mixin(( obj = {}, obj[BEFORE_RENDER_LIFECYCLE_HOOK] = patchCreateElementMixin, obj ));
2568 }
2569
2570 //
2571
2572 function createContext(options, scopedSlots) {
2573 var on = Object.assign({}, (options.context && options.context.on),
2574 options.listeners);
2575 return Object.assign({}, {attrs: Object.assign({}, options.attrs,
2576 // pass as attrs so that inheritAttrs works correctly
2577 // propsData should take precedence over attrs
2578 options.propsData)},
2579 (options.context || {}),
2580 {on: on,
2581 scopedSlots: scopedSlots})
2582 }
2583
2584 function createChildren(vm, h, ref) {
2585 var slots = ref.slots;
2586 var context = ref.context;
2587
2588 var slotVNodes = slots ? createSlotVNodes(vm, slots) : undefined;
2589 return (
2590 (context &&
2591 context.children &&
2592 context.children.map(function (x) { return (typeof x === 'function' ? x(h) : x); })) ||
2593 slotVNodes
2594 )
2595 }
2596
2597 function getValuesFromCallableOption(optionValue) {
2598 if (typeof optionValue === 'function') {
2599 return optionValue.call(this)
2600 }
2601 return optionValue
2602 }
2603
2604 function createInstance(
2605 component,
2606 options,
2607 _Vue
2608 ) {
2609 var componentOptions = isConstructor(component)
2610 ? component.options
2611 : component;
2612
2613 // instance options are options that are passed to the
2614 // root instance when it's instantiated
2615 var instanceOptions = extractInstanceOptions(options);
2616
2617 var globalComponents = _Vue.options.components || {};
2618 var componentsToStub = Object.assign(
2619 Object.create(globalComponents),
2620 componentOptions.components
2621 );
2622
2623 var stubComponentsObject = createStubsFromStubsObject(
2624 componentsToStub,
2625 // $FlowIgnore
2626 options.stubs,
2627 _Vue
2628 );
2629
2630 addEventLogger(_Vue);
2631 addMocks(_Vue, options.mocks);
2632 addStubs(_Vue, stubComponentsObject);
2633 patchCreateElement(_Vue, stubComponentsObject, options.shouldProxy);
2634
2635 if (componentNeedsCompiling(componentOptions)) {
2636 compileTemplate(componentOptions);
2637 }
2638
2639 // used to identify extended component using constructor
2640 componentOptions.$_vueTestUtils_original = component;
2641
2642 // watchers provided in mounting options should override preexisting ones
2643 if (componentOptions.watch && instanceOptions.watch) {
2644 var componentWatchers = Object.keys(componentOptions.watch);
2645 var instanceWatchers = Object.keys(instanceOptions.watch);
2646
2647 for (var i = 0; i < instanceWatchers.length; i++) {
2648 var k = instanceWatchers[i];
2649 // override the componentOptions with the one provided in mounting options
2650 if (componentWatchers.includes(k)) {
2651 componentOptions.watch[k] = instanceOptions.watch[k];
2652 }
2653 }
2654 }
2655
2656 // make sure all extends are based on this instance
2657 var Constructor = _Vue.extend(componentOptions).extend(instanceOptions);
2658 Constructor.options._base = _Vue;
2659
2660 var scopedSlots = createScopedSlots(options.scopedSlots, _Vue);
2661
2662 var parentComponentOptions = options.parentComponent || {};
2663
2664 var originalParentComponentProvide = parentComponentOptions.provide;
2665 parentComponentOptions.provide = function() {
2666 return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentProvide),
2667 getValuesFromCallableOption.call(this, options.provide))
2668 };
2669
2670 parentComponentOptions.$_doNotStubChildren = true;
2671 parentComponentOptions._isFunctionalContainer = componentOptions.functional;
2672 parentComponentOptions.render = function(h) {
2673 return h(
2674 Constructor,
2675 createContext(options, scopedSlots),
2676 createChildren(this, h, options)
2677 )
2678 };
2679 var Parent = _Vue.extend(parentComponentOptions);
2680
2681 return new Parent()
2682 }
2683
2684 //
2685
2686 function createElement() {
2687 if (document) {
2688 var elem = document.createElement('div');
2689
2690 if (document.body) {
2691 document.body.appendChild(elem);
2692 }
2693 return elem
2694 }
2695 }
2696
2697 //
2698
2699 function findDOMNodes(
2700 element,
2701 selector
2702 ) {
2703 var nodes = [];
2704 if (!element || !element.querySelectorAll || !element.matches) {
2705 return nodes
2706 }
2707
2708 if (element.matches(selector)) {
2709 nodes.push(element);
2710 }
2711 // $FlowIgnore
2712 return nodes.concat([].slice.call(element.querySelectorAll(selector)))
2713 }
2714
2715 function vmMatchesName(vm, name) {
2716 // We want to mirror how Vue resolves component names in SFCs:
2717 // For example, <test-component />, <TestComponent /> and `<testComponent />
2718 // all resolve to the same component
2719 var componentName = (vm.$options && vm.$options.name) || '';
2720 return (
2721 !!name &&
2722 (componentName === name ||
2723 // testComponent -> TestComponent
2724 componentName === capitalize(name) ||
2725 // test-component -> TestComponent
2726 componentName === capitalize(camelize(name)) ||
2727 // same match as above, but the component name vs query
2728 capitalize(camelize(componentName)) === name)
2729 )
2730 }
2731
2732 function vmCtorMatches(vm, component) {
2733 if (
2734 (vm.$options && vm.$options.$_vueTestUtils_original === component) ||
2735 vm.$_vueTestUtils_original === component
2736 ) {
2737 return true
2738 }
2739
2740 var Ctor = isConstructor(component)
2741 ? component.options._Ctor
2742 : component._Ctor;
2743
2744 if (!Ctor) {
2745 return false
2746 }
2747
2748 if (vm.constructor.extendOptions === component) {
2749 return true
2750 }
2751
2752 if (component.functional) {
2753 return Object.keys(vm._Ctor || {}).some(function (c) {
2754 return component === vm._Ctor[c].extendOptions
2755 })
2756 }
2757 }
2758
2759 function matches(node, selector) {
2760 if (selector.type === DOM_SELECTOR) {
2761 var element = node instanceof Element ? node : node.elm;
2762 return element && element.matches && element.matches(selector.value)
2763 }
2764
2765 var isFunctionalSelector = isConstructor(selector.value)
2766 ? selector.value.options.functional
2767 : selector.value.functional;
2768
2769 var componentInstance = isFunctionalSelector
2770 ? node[FUNCTIONAL_OPTIONS]
2771 : node.child;
2772
2773 if (!componentInstance) {
2774 return false
2775 }
2776
2777 if (selector.type === COMPONENT_SELECTOR) {
2778 if (vmCtorMatches(componentInstance, selector.value)) {
2779 return true
2780 }
2781 }
2782
2783 // Fallback to name selector for COMPONENT_SELECTOR for Vue < 2.1
2784 var nameSelector = isConstructor(selector.value)
2785 ? selector.value.extendOptions.name
2786 : selector.value.name;
2787 return vmMatchesName(componentInstance, nameSelector)
2788 }
2789
2790 //
2791
2792 function findAllInstances(rootVm) {
2793 var instances = [rootVm];
2794 var i = 0;
2795 while (i < instances.length) {
2796 var vm = instances[i]
2797 ;(vm.$children || []).forEach(function (child) {
2798 instances.push(child);
2799 });
2800 i++;
2801 }
2802 return instances
2803 }
2804
2805 function findAllVNodes(vnode, selector) {
2806 var matchingNodes = [];
2807 var nodes = [vnode];
2808 while (nodes.length) {
2809 var node = nodes.shift();
2810 if (node.children) {
2811 var children = [].concat( node.children ).reverse();
2812 children.forEach(function (n) {
2813 nodes.unshift(n);
2814 });
2815 }
2816 if (node.child) {
2817 nodes.unshift(node.child._vnode);
2818 }
2819 if (matches(node, selector)) {
2820 matchingNodes.push(node);
2821 }
2822 }
2823
2824 return matchingNodes
2825 }
2826
2827 function removeDuplicateNodes(vNodes) {
2828 var vNodeElms = vNodes.map(function (vNode) { return vNode.elm; });
2829 return vNodes.filter(function (vNode, index) { return index === vNodeElms.indexOf(vNode.elm); })
2830 }
2831
2832 function find(
2833 root,
2834 vm,
2835 selector
2836 ) {
2837 if (root instanceof Element && selector.type !== DOM_SELECTOR) {
2838 throwError(
2839 "cannot find a Vue instance on a DOM node. The node " +
2840 "you are calling find on does not exist in the " +
2841 "VDom. Are you adding the node as innerHTML?"
2842 );
2843 }
2844
2845 if (
2846 selector.type === COMPONENT_SELECTOR &&
2847 (selector.value.functional ||
2848 (selector.value.options && selector.value.options.functional)) &&
2849 VUE_VERSION < 2.3
2850 ) {
2851 throwError(
2852 "find for functional components is not supported " + "in Vue < 2.3"
2853 );
2854 }
2855
2856 if (root instanceof Element) {
2857 return findDOMNodes(root, selector.value)
2858 }
2859
2860 if (!root && selector.type !== DOM_SELECTOR) {
2861 throwError(
2862 "cannot find a Vue instance on a DOM node. The node " +
2863 "you are calling find on does not exist in the " +
2864 "VDom. Are you adding the node as innerHTML?"
2865 );
2866 }
2867
2868 if (!vm && selector.type === REF_SELECTOR) {
2869 throwError("$ref selectors can only be used on Vue component " + "wrappers");
2870 }
2871
2872 if (vm && vm.$refs && selector.value.ref in vm.$refs) {
2873 var refs = vm.$refs[selector.value.ref];
2874 return Array.isArray(refs) ? refs : [refs]
2875 }
2876
2877 var nodes = findAllVNodes(root, selector);
2878 var dedupedNodes = removeDuplicateNodes(nodes);
2879
2880 if (nodes.length > 0 || selector.type !== DOM_SELECTOR) {
2881 return dedupedNodes
2882 }
2883
2884 // Fallback in case element exists in HTML, but not in vnode tree
2885 // (e.g. if innerHTML is set as a domProp)
2886 return findDOMNodes(root.elm, selector.value)
2887 }
2888
2889 function errorHandler(errorOrString, vm) {
2890 var error =
2891 typeof errorOrString === 'object' ? errorOrString : new Error(errorOrString);
2892
2893 vm._error = error;
2894 throw error
2895 }
2896
2897 function throwIfInstancesThrew(vm) {
2898 var instancesWithError = findAllInstances(vm).filter(function (_vm) { return _vm._error; });
2899
2900 if (instancesWithError.length > 0) {
2901 throw instancesWithError[0]._error
2902 }
2903 }
2904
2905 var hasWarned = false;
2906
2907 // Vue swallows errors thrown by instances, even if the global error handler
2908 // throws. In order to throw in the test, we add an _error property to an
2909 // instance when it throws. Then we loop through the instances with
2910 // throwIfInstancesThrew and throw an error in the test context if any
2911 // instances threw.
2912 function addGlobalErrorHandler(_Vue) {
2913 var existingErrorHandler = _Vue.config.errorHandler;
2914
2915 if (existingErrorHandler === errorHandler) {
2916 return
2917 }
2918
2919 if (_Vue.config.errorHandler && !hasWarned) {
2920 warn(
2921 "Global error handler detected (Vue.config.errorHandler). \n" +
2922 "Vue Test Utils sets a custom error handler to throw errors " +
2923 "thrown by instances. If you want this behavior in " +
2924 "your tests, you must remove the global error handler."
2925 );
2926 hasWarned = true;
2927 } else {
2928 _Vue.config.errorHandler = errorHandler;
2929 }
2930 }
2931
2932 function normalizeStubs(stubs) {
2933 if ( stubs === void 0 ) stubs = {};
2934
2935 if (stubs === false) {
2936 return false
2937 }
2938 if (isPlainObject(stubs)) {
2939 return stubs
2940 }
2941 if (Array.isArray(stubs)) {
2942 return stubs.reduce(function (acc, stub) {
2943 if (typeof stub !== 'string') {
2944 throwError('each item in an options.stubs array must be a string');
2945 }
2946 acc[stub] = true;
2947 return acc
2948 }, {})
2949 }
2950 throwError('options.stubs must be an object or an Array');
2951 }
2952
2953 function normalizeProvide(provide) {
2954 // Objects are not resolved in extended components in Vue < 2.5
2955 // https://github.com/vuejs/vue/issues/6436
2956 if (typeof provide === 'object' && VUE_VERSION < 2.5) {
2957 var obj = Object.assign({}, provide);
2958 return function () { return obj; }
2959 }
2960 return provide
2961 }
2962
2963 //
2964
2965 function getOption(option, config) {
2966 if (option === false) {
2967 return false
2968 }
2969 if (option || (config && Object.keys(config).length > 0)) {
2970 if (option instanceof Function) {
2971 return option
2972 }
2973 if (config instanceof Function) {
2974 throw new Error("Config can't be a Function.")
2975 }
2976 return Object.assign({}, config,
2977 option)
2978 }
2979 }
2980
2981 function getStubs(stubs, configStubs) {
2982 var normalizedStubs = normalizeStubs(stubs);
2983 var normalizedConfigStubs = normalizeStubs(configStubs);
2984 return getOption(normalizedStubs, normalizedConfigStubs)
2985 }
2986
2987 function mergeOptions(
2988 options,
2989 config
2990 ) {
2991 var mocks = (getOption(options.mocks, config.mocks));
2992 var methods = (getOption(options.methods, config.methods));
2993 if (methods && Object.keys(methods).length) {
2994 warnDeprecated(
2995 'overwriting methods via the `methods` property',
2996 'There is no clear migration path for the `methods` property - Vue does not support arbitrarily replacement of methods, nor should VTU. To stub a complex method extract it from the component and test it in isolation. Otherwise, the suggestion is to rethink those tests'
2997 );
2998 }
2999
3000 var provide = (getOption(options.provide, config.provide));
3001 var stubs = (getStubs(options.stubs, config.stubs));
3002 // $FlowIgnore
3003 return Object.assign({}, options,
3004 {provide: normalizeProvide(provide),
3005 stubs: stubs,
3006 mocks: mocks,
3007 methods: methods})
3008 }
3009
3010 var config = {
3011 stubs: {
3012 transition: true,
3013 'transition-group': true
3014 },
3015 mocks: {},
3016 methods: {},
3017 provide: {},
3018 silent: true,
3019 showDeprecationWarnings:
3020 true
3021 };
3022
3023 //
3024
3025 function warnIfNoWindow() {
3026 if (typeof window === 'undefined') {
3027 throwError(
3028 "window is undefined, vue-test-utils needs to be " +
3029 "run in a browser environment. \n" +
3030 "You can run the tests in node using jsdom \n" +
3031 "See https://vue-test-utils.vuejs.org/guides/#browser-environment " +
3032 "for more details."
3033 );
3034 }
3035 }
3036
3037 function polyfill() {
3038 // Polyfill `Element.matches()` for IE and older versions of Chrome:
3039 // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
3040 if (!Element.prototype.matches) {
3041 Element.prototype.matches =
3042 Element.prototype.msMatchesSelector ||
3043 Element.prototype.webkitMatchesSelector;
3044 }
3045 }
3046
3047 /*jshint node:true */
3048
3049 function OutputLine(parent) {
3050 this.__parent = parent;
3051 this.__character_count = 0;
3052 // use indent_count as a marker for this.__lines that have preserved indentation
3053 this.__indent_count = -1;
3054 this.__alignment_count = 0;
3055 this.__wrap_point_index = 0;
3056 this.__wrap_point_character_count = 0;
3057 this.__wrap_point_indent_count = -1;
3058 this.__wrap_point_alignment_count = 0;
3059
3060 this.__items = [];
3061 }
3062
3063 OutputLine.prototype.clone_empty = function() {
3064 var line = new OutputLine(this.__parent);
3065 line.set_indent(this.__indent_count, this.__alignment_count);
3066 return line;
3067 };
3068
3069 OutputLine.prototype.item = function(index) {
3070 if (index < 0) {
3071 return this.__items[this.__items.length + index];
3072 } else {
3073 return this.__items[index];
3074 }
3075 };
3076
3077 OutputLine.prototype.has_match = function(pattern) {
3078 for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
3079 if (this.__items[lastCheckedOutput].match(pattern)) {
3080 return true;
3081 }
3082 }
3083 return false;
3084 };
3085
3086 OutputLine.prototype.set_indent = function(indent, alignment) {
3087 if (this.is_empty()) {
3088 this.__indent_count = indent || 0;
3089 this.__alignment_count = alignment || 0;
3090 this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
3091 }
3092 };
3093
3094 OutputLine.prototype._set_wrap_point = function() {
3095 if (this.__parent.wrap_line_length) {
3096 this.__wrap_point_index = this.__items.length;
3097 this.__wrap_point_character_count = this.__character_count;
3098 this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
3099 this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
3100 }
3101 };
3102
3103 OutputLine.prototype._should_wrap = function() {
3104 return this.__wrap_point_index &&
3105 this.__character_count > this.__parent.wrap_line_length &&
3106 this.__wrap_point_character_count > this.__parent.next_line.__character_count;
3107 };
3108
3109 OutputLine.prototype._allow_wrap = function() {
3110 if (this._should_wrap()) {
3111 this.__parent.add_new_line();
3112 var next = this.__parent.current_line;
3113 next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
3114 next.__items = this.__items.slice(this.__wrap_point_index);
3115 this.__items = this.__items.slice(0, this.__wrap_point_index);
3116
3117 next.__character_count += this.__character_count - this.__wrap_point_character_count;
3118 this.__character_count = this.__wrap_point_character_count;
3119
3120 if (next.__items[0] === " ") {
3121 next.__items.splice(0, 1);
3122 next.__character_count -= 1;
3123 }
3124 return true;
3125 }
3126 return false;
3127 };
3128
3129 OutputLine.prototype.is_empty = function() {
3130 return this.__items.length === 0;
3131 };
3132
3133 OutputLine.prototype.last = function() {
3134 if (!this.is_empty()) {
3135 return this.__items[this.__items.length - 1];
3136 } else {
3137 return null;
3138 }
3139 };
3140
3141 OutputLine.prototype.push = function(item) {
3142 this.__items.push(item);
3143 var last_newline_index = item.lastIndexOf('\n');
3144 if (last_newline_index !== -1) {
3145 this.__character_count = item.length - last_newline_index;
3146 } else {
3147 this.__character_count += item.length;
3148 }
3149 };
3150
3151 OutputLine.prototype.pop = function() {
3152 var item = null;
3153 if (!this.is_empty()) {
3154 item = this.__items.pop();
3155 this.__character_count -= item.length;
3156 }
3157 return item;
3158 };
3159
3160
3161 OutputLine.prototype._remove_indent = function() {
3162 if (this.__indent_count > 0) {
3163 this.__indent_count -= 1;
3164 this.__character_count -= this.__parent.indent_size;
3165 }
3166 };
3167
3168 OutputLine.prototype._remove_wrap_indent = function() {
3169 if (this.__wrap_point_indent_count > 0) {
3170 this.__wrap_point_indent_count -= 1;
3171 }
3172 };
3173 OutputLine.prototype.trim = function() {
3174 while (this.last() === ' ') {
3175 this.__items.pop();
3176 this.__character_count -= 1;
3177 }
3178 };
3179
3180 OutputLine.prototype.toString = function() {
3181 var result = '';
3182 if (this.is_empty()) {
3183 if (this.__parent.indent_empty_lines) {
3184 result = this.__parent.get_indent_string(this.__indent_count);
3185 }
3186 } else {
3187 result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
3188 result += this.__items.join('');
3189 }
3190 return result;
3191 };
3192
3193 function IndentStringCache(options, baseIndentString) {
3194 this.__cache = [''];
3195 this.__indent_size = options.indent_size;
3196 this.__indent_string = options.indent_char;
3197 if (!options.indent_with_tabs) {
3198 this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
3199 }
3200
3201 // Set to null to continue support for auto detection of base indent
3202 baseIndentString = baseIndentString || '';
3203 if (options.indent_level > 0) {
3204 baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
3205 }
3206
3207 this.__base_string = baseIndentString;
3208 this.__base_string_length = baseIndentString.length;
3209 }
3210
3211 IndentStringCache.prototype.get_indent_size = function(indent, column) {
3212 var result = this.__base_string_length;
3213 column = column || 0;
3214 if (indent < 0) {
3215 result = 0;
3216 }
3217 result += indent * this.__indent_size;
3218 result += column;
3219 return result;
3220 };
3221
3222 IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
3223 var result = this.__base_string;
3224 column = column || 0;
3225 if (indent_level < 0) {
3226 indent_level = 0;
3227 result = '';
3228 }
3229 column += indent_level * this.__indent_size;
3230 this.__ensure_cache(column);
3231 result += this.__cache[column];
3232 return result;
3233 };
3234
3235 IndentStringCache.prototype.__ensure_cache = function(column) {
3236 while (column >= this.__cache.length) {
3237 this.__add_column();
3238 }
3239 };
3240
3241 IndentStringCache.prototype.__add_column = function() {
3242 var column = this.__cache.length;
3243 var indent = 0;
3244 var result = '';
3245 if (this.__indent_size && column >= this.__indent_size) {
3246 indent = Math.floor(column / this.__indent_size);
3247 column -= indent * this.__indent_size;
3248 result = new Array(indent + 1).join(this.__indent_string);
3249 }
3250 if (column) {
3251 result += new Array(column + 1).join(' ');
3252 }
3253
3254 this.__cache.push(result);
3255 };
3256
3257 function Output(options, baseIndentString) {
3258 this.__indent_cache = new IndentStringCache(options, baseIndentString);
3259 this.raw = false;
3260 this._end_with_newline = options.end_with_newline;
3261 this.indent_size = options.indent_size;
3262 this.wrap_line_length = options.wrap_line_length;
3263 this.indent_empty_lines = options.indent_empty_lines;
3264 this.__lines = [];
3265 this.previous_line = null;
3266 this.current_line = null;
3267 this.next_line = new OutputLine(this);
3268 this.space_before_token = false;
3269 this.non_breaking_space = false;
3270 this.previous_token_wrapped = false;
3271 // initialize
3272 this.__add_outputline();
3273 }
3274
3275 Output.prototype.__add_outputline = function() {
3276 this.previous_line = this.current_line;
3277 this.current_line = this.next_line.clone_empty();
3278 this.__lines.push(this.current_line);
3279 };
3280
3281 Output.prototype.get_line_number = function() {
3282 return this.__lines.length;
3283 };
3284
3285 Output.prototype.get_indent_string = function(indent, column) {
3286 return this.__indent_cache.get_indent_string(indent, column);
3287 };
3288
3289 Output.prototype.get_indent_size = function(indent, column) {
3290 return this.__indent_cache.get_indent_size(indent, column);
3291 };
3292
3293 Output.prototype.is_empty = function() {
3294 return !this.previous_line && this.current_line.is_empty();
3295 };
3296
3297 Output.prototype.add_new_line = function(force_newline) {
3298 // never newline at the start of file
3299 // otherwise, newline only if we didn't just add one or we're forced
3300 if (this.is_empty() ||
3301 (!force_newline && this.just_added_newline())) {
3302 return false;
3303 }
3304
3305 // if raw output is enabled, don't print additional newlines,
3306 // but still return True as though you had
3307 if (!this.raw) {
3308 this.__add_outputline();
3309 }
3310 return true;
3311 };
3312
3313 Output.prototype.get_code = function(eol) {
3314 this.trim(true);
3315
3316 // handle some edge cases where the last tokens
3317 // has text that ends with newline(s)
3318 var last_item = this.current_line.pop();
3319 if (last_item) {
3320 if (last_item[last_item.length - 1] === '\n') {
3321 last_item = last_item.replace(/\n+$/g, '');
3322 }
3323 this.current_line.push(last_item);
3324 }
3325
3326 if (this._end_with_newline) {
3327 this.__add_outputline();
3328 }
3329
3330 var sweet_code = this.__lines.join('\n');
3331
3332 if (eol !== '\n') {
3333 sweet_code = sweet_code.replace(/[\n]/g, eol);
3334 }
3335 return sweet_code;
3336 };
3337
3338 Output.prototype.set_wrap_point = function() {
3339 this.current_line._set_wrap_point();
3340 };
3341
3342 Output.prototype.set_indent = function(indent, alignment) {
3343 indent = indent || 0;
3344 alignment = alignment || 0;
3345
3346 // Next line stores alignment values
3347 this.next_line.set_indent(indent, alignment);
3348
3349 // Never indent your first output indent at the start of the file
3350 if (this.__lines.length > 1) {
3351 this.current_line.set_indent(indent, alignment);
3352 return true;
3353 }
3354
3355 this.current_line.set_indent();
3356 return false;
3357 };
3358
3359 Output.prototype.add_raw_token = function(token) {
3360 for (var x = 0; x < token.newlines; x++) {
3361 this.__add_outputline();
3362 }
3363 this.current_line.set_indent(-1);
3364 this.current_line.push(token.whitespace_before);
3365 this.current_line.push(token.text);
3366 this.space_before_token = false;
3367 this.non_breaking_space = false;
3368 this.previous_token_wrapped = false;
3369 };
3370
3371 Output.prototype.add_token = function(printable_token) {
3372 this.__add_space_before_token();
3373 this.current_line.push(printable_token);
3374 this.space_before_token = false;
3375 this.non_breaking_space = false;
3376 this.previous_token_wrapped = this.current_line._allow_wrap();
3377 };
3378
3379 Output.prototype.__add_space_before_token = function() {
3380 if (this.space_before_token && !this.just_added_newline()) {
3381 if (!this.non_breaking_space) {
3382 this.set_wrap_point();
3383 }
3384 this.current_line.push(' ');
3385 }
3386 };
3387
3388 Output.prototype.remove_indent = function(index) {
3389 var output_length = this.__lines.length;
3390 while (index < output_length) {
3391 this.__lines[index]._remove_indent();
3392 index++;
3393 }
3394 this.current_line._remove_wrap_indent();
3395 };
3396
3397 Output.prototype.trim = function(eat_newlines) {
3398 eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
3399
3400 this.current_line.trim();
3401
3402 while (eat_newlines && this.__lines.length > 1 &&
3403 this.current_line.is_empty()) {
3404 this.__lines.pop();
3405 this.current_line = this.__lines[this.__lines.length - 1];
3406 this.current_line.trim();
3407 }
3408
3409 this.previous_line = this.__lines.length > 1 ?
3410 this.__lines[this.__lines.length - 2] : null;
3411 };
3412
3413 Output.prototype.just_added_newline = function() {
3414 return this.current_line.is_empty();
3415 };
3416
3417 Output.prototype.just_added_blankline = function() {
3418 return this.is_empty() ||
3419 (this.current_line.is_empty() && this.previous_line.is_empty());
3420 };
3421
3422 Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
3423 var index = this.__lines.length - 2;
3424 while (index >= 0) {
3425 var potentialEmptyLine = this.__lines[index];
3426 if (potentialEmptyLine.is_empty()) {
3427 break;
3428 } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
3429 potentialEmptyLine.item(-1) !== ends_with) {
3430 this.__lines.splice(index + 1, 0, new OutputLine(this));
3431 this.previous_line = this.__lines[this.__lines.length - 2];
3432 break;
3433 }
3434 index--;
3435 }
3436 };
3437
3438 var Output_1 = Output;
3439
3440 var output = {
3441 Output: Output_1
3442 };
3443
3444 /*jshint node:true */
3445
3446 function Token(type, text, newlines, whitespace_before) {
3447 this.type = type;
3448 this.text = text;
3449
3450 // comments_before are
3451 // comments that have a new line before them
3452 // and may or may not have a newline after
3453 // this is a set of comments before
3454 this.comments_before = null; /* inline comment*/
3455
3456
3457 // this.comments_after = new TokenStream(); // no new line before and newline after
3458 this.newlines = newlines || 0;
3459 this.whitespace_before = whitespace_before || '';
3460 this.parent = null;
3461 this.next = null;
3462 this.previous = null;
3463 this.opened = null;
3464 this.closed = null;
3465 this.directives = null;
3466 }
3467
3468
3469 var Token_1 = Token;
3470
3471 var token = {
3472 Token: Token_1
3473 };
3474
3475 var acorn = createCommonjsModule(function (module, exports) {
3476
3477 // acorn used char codes to squeeze the last bit of performance out
3478 // Beautifier is okay without that, so we're using regex
3479 // permit $ (36) and @ (64). @ is used in ES7 decorators.
3480 // 65 through 91 are uppercase letters.
3481 // permit _ (95).
3482 // 97 through 123 are lowercase letters.
3483 var baseASCIIidentifierStartChars = "\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a";
3484
3485 // inside an identifier @ is not allowed but 0-9 are.
3486 var baseASCIIidentifierChars = "\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a";
3487
3488 // Big ugly regular expressions that match characters in the
3489 // whitespace, identifier, and identifier-start categories. These
3490 // are only applied when a character is found to actually have a
3491 // code point above 128.
3492 var nonASCIIidentifierStartChars = "\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05d0-\\u05ea\\u05f0-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u08a0\\u08a2-\\u08ac\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097f\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c33\\u0c35-\\u0c39\\u0c3d\\u0c58\\u0c59\\u0c60\\u0c61\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d05-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d60\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e87\\u0e88\\u0e8a\\u0e8d\\u0e94-\\u0e97\\u0e99-\\u0e9f\\u0ea1-\\u0ea3\\u0ea5\\u0ea7\\u0eaa\\u0eab\\u0ead-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f4\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f0\\u1700-\\u170c\\u170e-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1877\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191c\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19c1-\\u19c7\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4b\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1ce9-\\u1cec\\u1cee-\\u1cf1\\u1cf5\\u1cf6\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2119-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u212d\\u212f-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2c2e\\u2c30-\\u2c5e\\u2c60-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u2e2f\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309d-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312d\\u3131-\\u318e\\u31a0-\\u31ba\\u31f0-\\u31ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua697\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua78e\\ua790-\\ua793\\ua7a0-\\ua7aa\\ua7f8-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa80-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uabc0-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc";
3493 var nonASCIIidentifierChars = "\\u0300-\\u036f\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u0620-\\u0649\\u0672-\\u06d3\\u06e7-\\u06e8\\u06fb-\\u06fc\\u0730-\\u074a\\u0800-\\u0814\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0840-\\u0857\\u08e4-\\u08fe\\u0900-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962-\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09d7\\u09df-\\u09e0\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2-\\u0ae3\\u0ae6-\\u0aef\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b56\\u0b57\\u0b5f-\\u0b60\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c01-\\u0c03\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62-\\u0c63\\u0c66-\\u0c6f\\u0c82\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2-\\u0ce3\\u0ce6-\\u0cef\\u0d02\\u0d03\\u0d46-\\u0d48\\u0d57\\u0d62-\\u0d63\\u0d66-\\u0d6f\\u0d82\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0df2\\u0df3\\u0e34-\\u0e3a\\u0e40-\\u0e45\\u0e50-\\u0e59\\u0eb4-\\u0eb9\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f41-\\u0f47\\u0f71-\\u0f84\\u0f86-\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u1000-\\u1029\\u1040-\\u1049\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u170e-\\u1710\\u1720-\\u1730\\u1740-\\u1750\\u1772\\u1773\\u1780-\\u17b2\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u1920-\\u192b\\u1930-\\u193b\\u1951-\\u196d\\u19b0-\\u19c0\\u19c8-\\u19c9\\u19d0-\\u19d9\\u1a00-\\u1a15\\u1a20-\\u1a53\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1b46-\\u1b4b\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c00-\\u1c22\\u1c40-\\u1c49\\u1c5b-\\u1c7d\\u1cd0-\\u1cd2\\u1d00-\\u1dbe\\u1e01-\\u1f15\\u200c\\u200d\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2d81-\\u2d96\\u2de0-\\u2dff\\u3021-\\u3028\\u3099\\u309a\\ua640-\\ua66d\\ua674-\\ua67d\\ua69f\\ua6f0-\\ua6f1\\ua7f8-\\ua800\\ua806\\ua80b\\ua823-\\ua827\\ua880-\\ua881\\ua8b4-\\ua8c4\\ua8d0-\\ua8d9\\ua8f3-\\ua8f7\\ua900-\\ua909\\ua926-\\ua92d\\ua930-\\ua945\\ua980-\\ua983\\ua9b3-\\ua9c0\\uaa00-\\uaa27\\uaa40-\\uaa41\\uaa4c-\\uaa4d\\uaa50-\\uaa59\\uaa7b\\uaae0-\\uaae9\\uaaf2-\\uaaf3\\uabc0-\\uabe1\\uabec\\uabed\\uabf0-\\uabf9\\ufb20-\\ufb28\\ufe00-\\ufe0f\\ufe20-\\ufe26\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f";
3494 //var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
3495 //var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
3496
3497 var identifierStart = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "])";
3498 var identifierChars = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])*";
3499
3500 exports.identifier = new RegExp(identifierStart + identifierChars, 'g');
3501 exports.identifierStart = new RegExp(identifierStart);
3502 exports.identifierMatch = new RegExp("(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])+");
3503
3504 // Whether a single character denotes a newline.
3505
3506 exports.newline = /[\n\r\u2028\u2029]/;
3507
3508 // Matches a whole line break (where CRLF is considered a single
3509 // line break). Used to count lines.
3510
3511 // in javascript, these two differ
3512 // in python they are the same, different methods are called on them
3513 exports.lineBreak = new RegExp('\r\n|' + exports.newline.source);
3514 exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g');
3515 });
3516 var acorn_1 = acorn.identifier;
3517 var acorn_2 = acorn.identifierStart;
3518 var acorn_3 = acorn.identifierMatch;
3519 var acorn_4 = acorn.newline;
3520 var acorn_5 = acorn.lineBreak;
3521 var acorn_6 = acorn.allLineBreaks;
3522
3523 /*jshint node:true */
3524
3525 function Options(options, merge_child_field) {
3526 this.raw_options = _mergeOpts(options, merge_child_field);
3527
3528 // Support passing the source text back with no change
3529 this.disabled = this._get_boolean('disabled');
3530
3531 this.eol = this._get_characters('eol', 'auto');
3532 this.end_with_newline = this._get_boolean('end_with_newline');
3533 this.indent_size = this._get_number('indent_size', 4);
3534 this.indent_char = this._get_characters('indent_char', ' ');
3535 this.indent_level = this._get_number('indent_level');
3536
3537 this.preserve_newlines = this._get_boolean('preserve_newlines', true);
3538 this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
3539 if (!this.preserve_newlines) {
3540 this.max_preserve_newlines = 0;
3541 }
3542
3543 this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
3544 if (this.indent_with_tabs) {
3545 this.indent_char = '\t';
3546
3547 // indent_size behavior changed after 1.8.6
3548 // It used to be that indent_size would be
3549 // set to 1 for indent_with_tabs. That is no longer needed and
3550 // actually doesn't make sense - why not use spaces? Further,
3551 // that might produce unexpected behavior - tabs being used
3552 // for single-column alignment. So, when indent_with_tabs is true
3553 // and indent_size is 1, reset indent_size to 4.
3554 if (this.indent_size === 1) {
3555 this.indent_size = 4;
3556 }
3557 }
3558
3559 // Backwards compat with 1.3.x
3560 this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
3561
3562 this.indent_empty_lines = this._get_boolean('indent_empty_lines');
3563
3564 // valid templating languages ['django', 'erb', 'handlebars', 'php']
3565 // For now, 'auto' = all off for javascript, all on for html (and inline javascript).
3566 // other values ignored
3567 this.templating = this._get_selection_list('templating', ['auto', 'none', 'django', 'erb', 'handlebars', 'php'], ['auto']);
3568 }
3569
3570 Options.prototype._get_array = function(name, default_value) {
3571 var option_value = this.raw_options[name];
3572 var result = default_value || [];
3573 if (typeof option_value === 'object') {
3574 if (option_value !== null && typeof option_value.concat === 'function') {
3575 result = option_value.concat();
3576 }
3577 } else if (typeof option_value === 'string') {
3578 result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
3579 }
3580 return result;
3581 };
3582
3583 Options.prototype._get_boolean = function(name, default_value) {
3584 var option_value = this.raw_options[name];
3585 var result = option_value === undefined ? !!default_value : !!option_value;
3586 return result;
3587 };
3588
3589 Options.prototype._get_characters = function(name, default_value) {
3590 var option_value = this.raw_options[name];
3591 var result = default_value || '';
3592 if (typeof option_value === 'string') {
3593 result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
3594 }
3595 return result;
3596 };
3597
3598 Options.prototype._get_number = function(name, default_value) {
3599 var option_value = this.raw_options[name];
3600 default_value = parseInt(default_value, 10);
3601 if (isNaN(default_value)) {
3602 default_value = 0;
3603 }
3604 var result = parseInt(option_value, 10);
3605 if (isNaN(result)) {
3606 result = default_value;
3607 }
3608 return result;
3609 };
3610
3611 Options.prototype._get_selection = function(name, selection_list, default_value) {
3612 var result = this._get_selection_list(name, selection_list, default_value);
3613 if (result.length !== 1) {
3614 throw new Error(
3615 "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
3616 selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
3617 }
3618
3619 return result[0];
3620 };
3621
3622
3623 Options.prototype._get_selection_list = function(name, selection_list, default_value) {
3624 if (!selection_list || selection_list.length === 0) {
3625 throw new Error("Selection list cannot be empty.");
3626 }
3627
3628 default_value = default_value || [selection_list[0]];
3629 if (!this._is_valid_selection(default_value, selection_list)) {
3630 throw new Error("Invalid Default Value!");
3631 }
3632
3633 var result = this._get_array(name, default_value);
3634 if (!this._is_valid_selection(result, selection_list)) {
3635 throw new Error(
3636 "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
3637 selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
3638 }
3639
3640 return result;
3641 };
3642
3643 Options.prototype._is_valid_selection = function(result, selection_list) {
3644 return result.length && selection_list.length &&
3645 !result.some(function(item) { return selection_list.indexOf(item) === -1; });
3646 };
3647
3648
3649 // merges child options up with the parent options object
3650 // Example: obj = {a: 1, b: {a: 2}}
3651 // mergeOpts(obj, 'b')
3652 //
3653 // Returns: {a: 2}
3654 function _mergeOpts(allOptions, childFieldName) {
3655 var finalOpts = {};
3656 allOptions = _normalizeOpts(allOptions);
3657 var name;
3658
3659 for (name in allOptions) {
3660 if (name !== childFieldName) {
3661 finalOpts[name] = allOptions[name];
3662 }
3663 }
3664
3665 //merge in the per type settings for the childFieldName
3666 if (childFieldName && allOptions[childFieldName]) {
3667 for (name in allOptions[childFieldName]) {
3668 finalOpts[name] = allOptions[childFieldName][name];
3669 }
3670 }
3671 return finalOpts;
3672 }
3673
3674 function _normalizeOpts(options) {
3675 var convertedOpts = {};
3676 var key;
3677
3678 for (key in options) {
3679 var newKey = key.replace(/-/g, "_");
3680 convertedOpts[newKey] = options[key];
3681 }
3682 return convertedOpts;
3683 }
3684
3685 var Options_1 = Options;
3686 var normalizeOpts = _normalizeOpts;
3687 var mergeOpts = _mergeOpts;
3688
3689 var options = {
3690 Options: Options_1,
3691 normalizeOpts: normalizeOpts,
3692 mergeOpts: mergeOpts
3693 };
3694
3695 var BaseOptions = options.Options;
3696
3697 var validPositionValues = ['before-newline', 'after-newline', 'preserve-newline'];
3698
3699 function Options$1(options) {
3700 BaseOptions.call(this, options, 'js');
3701
3702 // compatibility, re
3703 var raw_brace_style = this.raw_options.brace_style || null;
3704 if (raw_brace_style === "expand-strict") { //graceful handling of deprecated option
3705 this.raw_options.brace_style = "expand";
3706 } else if (raw_brace_style === "collapse-preserve-inline") { //graceful handling of deprecated option
3707 this.raw_options.brace_style = "collapse,preserve-inline";
3708 } else if (this.raw_options.braces_on_own_line !== undefined) { //graceful handling of deprecated option
3709 this.raw_options.brace_style = this.raw_options.braces_on_own_line ? "expand" : "collapse";
3710 // } else if (!raw_brace_style) { //Nothing exists to set it
3711 // raw_brace_style = "collapse";
3712 }
3713
3714 //preserve-inline in delimited string will trigger brace_preserve_inline, everything
3715 //else is considered a brace_style and the last one only will have an effect
3716
3717 var brace_style_split = this._get_selection_list('brace_style', ['collapse', 'expand', 'end-expand', 'none', 'preserve-inline']);
3718
3719 this.brace_preserve_inline = false; //Defaults in case one or other was not specified in meta-option
3720 this.brace_style = "collapse";
3721
3722 for (var bs = 0; bs < brace_style_split.length; bs++) {
3723 if (brace_style_split[bs] === "preserve-inline") {
3724 this.brace_preserve_inline = true;
3725 } else {
3726 this.brace_style = brace_style_split[bs];
3727 }
3728 }
3729
3730 this.unindent_chained_methods = this._get_boolean('unindent_chained_methods');
3731 this.break_chained_methods = this._get_boolean('break_chained_methods');
3732 this.space_in_paren = this._get_boolean('space_in_paren');
3733 this.space_in_empty_paren = this._get_boolean('space_in_empty_paren');
3734 this.jslint_happy = this._get_boolean('jslint_happy');
3735 this.space_after_anon_function = this._get_boolean('space_after_anon_function');
3736 this.space_after_named_function = this._get_boolean('space_after_named_function');
3737 this.keep_array_indentation = this._get_boolean('keep_array_indentation');
3738 this.space_before_conditional = this._get_boolean('space_before_conditional', true);
3739 this.unescape_strings = this._get_boolean('unescape_strings');
3740 this.e4x = this._get_boolean('e4x');
3741 this.comma_first = this._get_boolean('comma_first');
3742 this.operator_position = this._get_selection('operator_position', validPositionValues);
3743
3744 // For testing of beautify preserve:start directive
3745 this.test_output_raw = this._get_boolean('test_output_raw');
3746
3747 // force this._options.space_after_anon_function to true if this._options.jslint_happy
3748 if (this.jslint_happy) {
3749 this.space_after_anon_function = true;
3750 }
3751
3752 }
3753 Options$1.prototype = new BaseOptions();
3754
3755
3756
3757 var Options_1$1 = Options$1;
3758
3759 var options$1 = {
3760 Options: Options_1$1
3761 };
3762
3763 /*jshint node:true */
3764
3765 var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
3766
3767 function InputScanner(input_string) {
3768 this.__input = input_string || '';
3769 this.__input_length = this.__input.length;
3770 this.__position = 0;
3771 }
3772
3773 InputScanner.prototype.restart = function() {
3774 this.__position = 0;
3775 };
3776
3777 InputScanner.prototype.back = function() {
3778 if (this.__position > 0) {
3779 this.__position -= 1;
3780 }
3781 };
3782
3783 InputScanner.prototype.hasNext = function() {
3784 return this.__position < this.__input_length;
3785 };
3786
3787 InputScanner.prototype.next = function() {
3788 var val = null;
3789 if (this.hasNext()) {
3790 val = this.__input.charAt(this.__position);
3791 this.__position += 1;
3792 }
3793 return val;
3794 };
3795
3796 InputScanner.prototype.peek = function(index) {
3797 var val = null;
3798 index = index || 0;
3799 index += this.__position;
3800 if (index >= 0 && index < this.__input_length) {
3801 val = this.__input.charAt(index);
3802 }
3803 return val;
3804 };
3805
3806 // This is a JavaScript only helper function (not in python)
3807 // Javascript doesn't have a match method
3808 // and not all implementation support "sticky" flag.
3809 // If they do not support sticky then both this.match() and this.test() method
3810 // must get the match and check the index of the match.
3811 // If sticky is supported and set, this method will use it.
3812 // Otherwise it will check that global is set, and fall back to the slower method.
3813 InputScanner.prototype.__match = function(pattern, index) {
3814 pattern.lastIndex = index;
3815 var pattern_match = pattern.exec(this.__input);
3816
3817 if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
3818 if (pattern_match.index !== index) {
3819 pattern_match = null;
3820 }
3821 }
3822
3823 return pattern_match;
3824 };
3825
3826 InputScanner.prototype.test = function(pattern, index) {
3827 index = index || 0;
3828 index += this.__position;
3829
3830 if (index >= 0 && index < this.__input_length) {
3831 return !!this.__match(pattern, index);
3832 } else {
3833 return false;
3834 }
3835 };
3836
3837 InputScanner.prototype.testChar = function(pattern, index) {
3838 // test one character regex match
3839 var val = this.peek(index);
3840 pattern.lastIndex = 0;
3841 return val !== null && pattern.test(val);
3842 };
3843
3844 InputScanner.prototype.match = function(pattern) {
3845 var pattern_match = this.__match(pattern, this.__position);
3846 if (pattern_match) {
3847 this.__position += pattern_match[0].length;
3848 } else {
3849 pattern_match = null;
3850 }
3851 return pattern_match;
3852 };
3853
3854 InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
3855 var val = '';
3856 var match;
3857 if (starting_pattern) {
3858 match = this.match(starting_pattern);
3859 if (match) {
3860 val += match[0];
3861 }
3862 }
3863 if (until_pattern && (match || !starting_pattern)) {
3864 val += this.readUntil(until_pattern, until_after);
3865 }
3866 return val;
3867 };
3868
3869 InputScanner.prototype.readUntil = function(pattern, until_after) {
3870 var val = '';
3871 var match_index = this.__position;
3872 pattern.lastIndex = this.__position;
3873 var pattern_match = pattern.exec(this.__input);
3874 if (pattern_match) {
3875 match_index = pattern_match.index;
3876 if (until_after) {
3877 match_index += pattern_match[0].length;
3878 }
3879 } else {
3880 match_index = this.__input_length;
3881 }
3882
3883 val = this.__input.substring(this.__position, match_index);
3884 this.__position = match_index;
3885 return val;
3886 };
3887
3888 InputScanner.prototype.readUntilAfter = function(pattern) {
3889 return this.readUntil(pattern, true);
3890 };
3891
3892 InputScanner.prototype.get_regexp = function(pattern, match_from) {
3893 var result = null;
3894 var flags = 'g';
3895 if (match_from && regexp_has_sticky) {
3896 flags = 'y';
3897 }
3898 // strings are converted to regexp
3899 if (typeof pattern === "string" && pattern !== '') {
3900 // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
3901 result = new RegExp(pattern, flags);
3902 } else if (pattern) {
3903 result = new RegExp(pattern.source, flags);
3904 }
3905 return result;
3906 };
3907
3908 InputScanner.prototype.get_literal_regexp = function(literal_string) {
3909 return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
3910 };
3911
3912 /* css beautifier legacy helpers */
3913 InputScanner.prototype.peekUntilAfter = function(pattern) {
3914 var start = this.__position;
3915 var val = this.readUntilAfter(pattern);
3916 this.__position = start;
3917 return val;
3918 };
3919
3920 InputScanner.prototype.lookBack = function(testVal) {
3921 var start = this.__position - 1;
3922 return start >= testVal.length && this.__input.substring(start - testVal.length, start)
3923 .toLowerCase() === testVal;
3924 };
3925
3926 var InputScanner_1 = InputScanner;
3927
3928 var inputscanner = {
3929 InputScanner: InputScanner_1
3930 };
3931
3932 /*jshint node:true */
3933
3934 function TokenStream(parent_token) {
3935 // private
3936 this.__tokens = [];
3937 this.__tokens_length = this.__tokens.length;
3938 this.__position = 0;
3939 this.__parent_token = parent_token;
3940 }
3941
3942 TokenStream.prototype.restart = function() {
3943 this.__position = 0;
3944 };
3945
3946 TokenStream.prototype.isEmpty = function() {
3947 return this.__tokens_length === 0;
3948 };
3949
3950 TokenStream.prototype.hasNext = function() {
3951 return this.__position < this.__tokens_length;
3952 };
3953
3954 TokenStream.prototype.next = function() {
3955 var val = null;
3956 if (this.hasNext()) {
3957 val = this.__tokens[this.__position];
3958 this.__position += 1;
3959 }
3960 return val;
3961 };
3962
3963 TokenStream.prototype.peek = function(index) {
3964 var val = null;
3965 index = index || 0;
3966 index += this.__position;
3967 if (index >= 0 && index < this.__tokens_length) {
3968 val = this.__tokens[index];
3969 }
3970 return val;
3971 };
3972
3973 TokenStream.prototype.add = function(token) {
3974 if (this.__parent_token) {
3975 token.parent = this.__parent_token;
3976 }
3977 this.__tokens.push(token);
3978 this.__tokens_length += 1;
3979 };
3980
3981 var TokenStream_1 = TokenStream;
3982
3983 var tokenstream = {
3984 TokenStream: TokenStream_1
3985 };
3986
3987 /*jshint node:true */
3988
3989 function Pattern(input_scanner, parent) {
3990 this._input = input_scanner;
3991 this._starting_pattern = null;
3992 this._match_pattern = null;
3993 this._until_pattern = null;
3994 this._until_after = false;
3995
3996 if (parent) {
3997 this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
3998 this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
3999 this._until_pattern = this._input.get_regexp(parent._until_pattern);
4000 this._until_after = parent._until_after;
4001 }
4002 }
4003
4004 Pattern.prototype.read = function() {
4005 var result = this._input.read(this._starting_pattern);
4006 if (!this._starting_pattern || result) {
4007 result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
4008 }
4009 return result;
4010 };
4011
4012 Pattern.prototype.read_match = function() {
4013 return this._input.match(this._match_pattern);
4014 };
4015
4016 Pattern.prototype.until_after = function(pattern) {
4017 var result = this._create();
4018 result._until_after = true;
4019 result._until_pattern = this._input.get_regexp(pattern);
4020 result._update();
4021 return result;
4022 };
4023
4024 Pattern.prototype.until = function(pattern) {
4025 var result = this._create();
4026 result._until_after = false;
4027 result._until_pattern = this._input.get_regexp(pattern);
4028 result._update();
4029 return result;
4030 };
4031
4032 Pattern.prototype.starting_with = function(pattern) {
4033 var result = this._create();
4034 result._starting_pattern = this._input.get_regexp(pattern, true);
4035 result._update();
4036 return result;
4037 };
4038
4039 Pattern.prototype.matching = function(pattern) {
4040 var result = this._create();
4041 result._match_pattern = this._input.get_regexp(pattern, true);
4042 result._update();
4043 return result;
4044 };
4045
4046 Pattern.prototype._create = function() {
4047 return new Pattern(this._input, this);
4048 };
4049
4050 Pattern.prototype._update = function() {};
4051
4052 var Pattern_1 = Pattern;
4053
4054 var pattern = {
4055 Pattern: Pattern_1
4056 };
4057
4058 var Pattern$1 = pattern.Pattern;
4059
4060 function WhitespacePattern(input_scanner, parent) {
4061 Pattern$1.call(this, input_scanner, parent);
4062 if (parent) {
4063 this._line_regexp = this._input.get_regexp(parent._line_regexp);
4064 } else {
4065 this.__set_whitespace_patterns('', '');
4066 }
4067
4068 this.newline_count = 0;
4069 this.whitespace_before_token = '';
4070 }
4071 WhitespacePattern.prototype = new Pattern$1();
4072
4073 WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
4074 whitespace_chars += '\\t ';
4075 newline_chars += '\\n\\r';
4076
4077 this._match_pattern = this._input.get_regexp(
4078 '[' + whitespace_chars + newline_chars + ']+', true);
4079 this._newline_regexp = this._input.get_regexp(
4080 '\\r\\n|[' + newline_chars + ']');
4081 };
4082
4083 WhitespacePattern.prototype.read = function() {
4084 this.newline_count = 0;
4085 this.whitespace_before_token = '';
4086
4087 var resulting_string = this._input.read(this._match_pattern);
4088 if (resulting_string === ' ') {
4089 this.whitespace_before_token = ' ';
4090 } else if (resulting_string) {
4091 var matches = this.__split(this._newline_regexp, resulting_string);
4092 this.newline_count = matches.length - 1;
4093 this.whitespace_before_token = matches[this.newline_count];
4094 }
4095
4096 return resulting_string;
4097 };
4098
4099 WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
4100 var result = this._create();
4101 result.__set_whitespace_patterns(whitespace_chars, newline_chars);
4102 result._update();
4103 return result;
4104 };
4105
4106 WhitespacePattern.prototype._create = function() {
4107 return new WhitespacePattern(this._input, this);
4108 };
4109
4110 WhitespacePattern.prototype.__split = function(regexp, input_string) {
4111 regexp.lastIndex = 0;
4112 var start_index = 0;
4113 var result = [];
4114 var next_match = regexp.exec(input_string);
4115 while (next_match) {
4116 result.push(input_string.substring(start_index, next_match.index));
4117 start_index = next_match.index + next_match[0].length;
4118 next_match = regexp.exec(input_string);
4119 }
4120
4121 if (start_index < input_string.length) {
4122 result.push(input_string.substring(start_index, input_string.length));
4123 } else {
4124 result.push('');
4125 }
4126
4127 return result;
4128 };
4129
4130
4131
4132 var WhitespacePattern_1 = WhitespacePattern;
4133
4134 var whitespacepattern = {
4135 WhitespacePattern: WhitespacePattern_1
4136 };
4137
4138 var InputScanner$1 = inputscanner.InputScanner;
4139 var Token$1 = token.Token;
4140 var TokenStream$1 = tokenstream.TokenStream;
4141 var WhitespacePattern$1 = whitespacepattern.WhitespacePattern;
4142
4143 var TOKEN = {
4144 START: 'TK_START',
4145 RAW: 'TK_RAW',
4146 EOF: 'TK_EOF'
4147 };
4148
4149 var Tokenizer = function(input_string, options) {
4150 this._input = new InputScanner$1(input_string);
4151 this._options = options || {};
4152 this.__tokens = null;
4153
4154 this._patterns = {};
4155 this._patterns.whitespace = new WhitespacePattern$1(this._input);
4156 };
4157
4158 Tokenizer.prototype.tokenize = function() {
4159 this._input.restart();
4160 this.__tokens = new TokenStream$1();
4161
4162 this._reset();
4163
4164 var current;
4165 var previous = new Token$1(TOKEN.START, '');
4166 var open_token = null;
4167 var open_stack = [];
4168 var comments = new TokenStream$1();
4169
4170 while (previous.type !== TOKEN.EOF) {
4171 current = this._get_next_token(previous, open_token);
4172 while (this._is_comment(current)) {
4173 comments.add(current);
4174 current = this._get_next_token(previous, open_token);
4175 }
4176
4177 if (!comments.isEmpty()) {
4178 current.comments_before = comments;
4179 comments = new TokenStream$1();
4180 }
4181
4182 current.parent = open_token;
4183
4184 if (this._is_opening(current)) {
4185 open_stack.push(open_token);
4186 open_token = current;
4187 } else if (open_token && this._is_closing(current, open_token)) {
4188 current.opened = open_token;
4189 open_token.closed = current;
4190 open_token = open_stack.pop();
4191 current.parent = open_token;
4192 }
4193
4194 current.previous = previous;
4195 previous.next = current;
4196
4197 this.__tokens.add(current);
4198 previous = current;
4199 }
4200
4201 return this.__tokens;
4202 };
4203
4204
4205 Tokenizer.prototype._is_first_token = function() {
4206 return this.__tokens.isEmpty();
4207 };
4208
4209 Tokenizer.prototype._reset = function() {};
4210
4211 Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
4212 this._readWhitespace();
4213 var resulting_string = this._input.read(/.+/g);
4214 if (resulting_string) {
4215 return this._create_token(TOKEN.RAW, resulting_string);
4216 } else {
4217 return this._create_token(TOKEN.EOF, '');
4218 }
4219 };
4220
4221 Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false
4222 return false;
4223 };
4224
4225 Tokenizer.prototype._is_opening = function(current_token) { // jshint unused:false
4226 return false;
4227 };
4228
4229 Tokenizer.prototype._is_closing = function(current_token, open_token) { // jshint unused:false
4230 return false;
4231 };
4232
4233 Tokenizer.prototype._create_token = function(type, text) {
4234 var token = new Token$1(type, text,
4235 this._patterns.whitespace.newline_count,
4236 this._patterns.whitespace.whitespace_before_token);
4237 return token;
4238 };
4239
4240 Tokenizer.prototype._readWhitespace = function() {
4241 return this._patterns.whitespace.read();
4242 };
4243
4244
4245
4246 var Tokenizer_1 = Tokenizer;
4247 var TOKEN_1 = TOKEN;
4248
4249 var tokenizer = {
4250 Tokenizer: Tokenizer_1,
4251 TOKEN: TOKEN_1
4252 };
4253
4254 /*jshint node:true */
4255
4256 function Directives(start_block_pattern, end_block_pattern) {
4257 start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
4258 end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
4259 this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
4260 this.__directive_pattern = / (\w+)[:](\w+)/g;
4261
4262 this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
4263 }
4264
4265 Directives.prototype.get_directives = function(text) {
4266 if (!text.match(this.__directives_block_pattern)) {
4267 return null;
4268 }
4269
4270 var directives = {};
4271 this.__directive_pattern.lastIndex = 0;
4272 var directive_match = this.__directive_pattern.exec(text);
4273
4274 while (directive_match) {
4275 directives[directive_match[1]] = directive_match[2];
4276 directive_match = this.__directive_pattern.exec(text);
4277 }
4278
4279 return directives;
4280 };
4281
4282 Directives.prototype.readIgnored = function(input) {
4283 return input.readUntilAfter(this.__directives_end_ignore_pattern);
4284 };
4285
4286
4287 var Directives_1 = Directives;
4288
4289 var directives = {
4290 Directives: Directives_1
4291 };
4292
4293 var Pattern$2 = pattern.Pattern;
4294
4295
4296 var template_names = {
4297 django: false,
4298 erb: false,
4299 handlebars: false,
4300 php: false
4301 };
4302
4303 // This lets templates appear anywhere we would do a readUntil
4304 // The cost is higher but it is pay to play.
4305 function TemplatablePattern(input_scanner, parent) {
4306 Pattern$2.call(this, input_scanner, parent);
4307 this.__template_pattern = null;
4308 this._disabled = Object.assign({}, template_names);
4309 this._excluded = Object.assign({}, template_names);
4310
4311 if (parent) {
4312 this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
4313 this._excluded = Object.assign(this._excluded, parent._excluded);
4314 this._disabled = Object.assign(this._disabled, parent._disabled);
4315 }
4316 var pattern = new Pattern$2(input_scanner);
4317 this.__patterns = {
4318 handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
4319 handlebars: pattern.starting_with(/{{/).until_after(/}}/),
4320 php: pattern.starting_with(/<\?(?:[=]|php)/).until_after(/\?>/),
4321 erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
4322 // django coflicts with handlebars a bit.
4323 django: pattern.starting_with(/{%/).until_after(/%}/),
4324 django_value: pattern.starting_with(/{{/).until_after(/}}/),
4325 django_comment: pattern.starting_with(/{#/).until_after(/#}/)
4326 };
4327 }
4328 TemplatablePattern.prototype = new Pattern$2();
4329
4330 TemplatablePattern.prototype._create = function() {
4331 return new TemplatablePattern(this._input, this);
4332 };
4333
4334 TemplatablePattern.prototype._update = function() {
4335 this.__set_templated_pattern();
4336 };
4337
4338 TemplatablePattern.prototype.disable = function(language) {
4339 var result = this._create();
4340 result._disabled[language] = true;
4341 result._update();
4342 return result;
4343 };
4344
4345 TemplatablePattern.prototype.read_options = function(options) {
4346 var result = this._create();
4347 for (var language in template_names) {
4348 result._disabled[language] = options.templating.indexOf(language) === -1;
4349 }
4350 result._update();
4351 return result;
4352 };
4353
4354 TemplatablePattern.prototype.exclude = function(language) {
4355 var result = this._create();
4356 result._excluded[language] = true;
4357 result._update();
4358 return result;
4359 };
4360
4361 TemplatablePattern.prototype.read = function() {
4362 var result = '';
4363 if (this._match_pattern) {
4364 result = this._input.read(this._starting_pattern);
4365 } else {
4366 result = this._input.read(this._starting_pattern, this.__template_pattern);
4367 }
4368 var next = this._read_template();
4369 while (next) {
4370 if (this._match_pattern) {
4371 next += this._input.read(this._match_pattern);
4372 } else {
4373 next += this._input.readUntil(this.__template_pattern);
4374 }
4375 result += next;
4376 next = this._read_template();
4377 }
4378
4379 if (this._until_after) {
4380 result += this._input.readUntilAfter(this._until_pattern);
4381 }
4382 return result;
4383 };
4384
4385 TemplatablePattern.prototype.__set_templated_pattern = function() {
4386 var items = [];
4387
4388 if (!this._disabled.php) {
4389 items.push(this.__patterns.php._starting_pattern.source);
4390 }
4391 if (!this._disabled.handlebars) {
4392 items.push(this.__patterns.handlebars._starting_pattern.source);
4393 }
4394 if (!this._disabled.erb) {
4395 items.push(this.__patterns.erb._starting_pattern.source);
4396 }
4397 if (!this._disabled.django) {
4398 items.push(this.__patterns.django._starting_pattern.source);
4399 items.push(this.__patterns.django_value._starting_pattern.source);
4400 items.push(this.__patterns.django_comment._starting_pattern.source);
4401 }
4402
4403 if (this._until_pattern) {
4404 items.push(this._until_pattern.source);
4405 }
4406 this.__template_pattern = this._input.get_regexp('(?:' + items.join('|') + ')');
4407 };
4408
4409 TemplatablePattern.prototype._read_template = function() {
4410 var resulting_string = '';
4411 var c = this._input.peek();
4412 if (c === '<') {
4413 var peek1 = this._input.peek(1);
4414 //if we're in a comment, do something special
4415 // We treat all comments as literals, even more than preformatted tags
4416 // we just look for the appropriate close tag
4417 if (!this._disabled.php && !this._excluded.php && peek1 === '?') {
4418 resulting_string = resulting_string ||
4419 this.__patterns.php.read();
4420 }
4421 if (!this._disabled.erb && !this._excluded.erb && peek1 === '%') {
4422 resulting_string = resulting_string ||
4423 this.__patterns.erb.read();
4424 }
4425 } else if (c === '{') {
4426 if (!this._disabled.handlebars && !this._excluded.handlebars) {
4427 resulting_string = resulting_string ||
4428 this.__patterns.handlebars_comment.read();
4429 resulting_string = resulting_string ||
4430 this.__patterns.handlebars.read();
4431 }
4432 if (!this._disabled.django) {
4433 // django coflicts with handlebars a bit.
4434 if (!this._excluded.django && !this._excluded.handlebars) {
4435 resulting_string = resulting_string ||
4436 this.__patterns.django_value.read();
4437 }
4438 if (!this._excluded.django) {
4439 resulting_string = resulting_string ||
4440 this.__patterns.django_comment.read();
4441 resulting_string = resulting_string ||
4442 this.__patterns.django.read();
4443 }
4444 }
4445 }
4446 return resulting_string;
4447 };
4448
4449
4450 var TemplatablePattern_1 = TemplatablePattern;
4451
4452 var templatablepattern = {
4453 TemplatablePattern: TemplatablePattern_1
4454 };
4455
4456 var InputScanner$2 = inputscanner.InputScanner;
4457 var BaseTokenizer = tokenizer.Tokenizer;
4458 var BASETOKEN = tokenizer.TOKEN;
4459 var Directives$1 = directives.Directives;
4460
4461 var Pattern$3 = pattern.Pattern;
4462 var TemplatablePattern$1 = templatablepattern.TemplatablePattern;
4463
4464
4465 function in_array(what, arr) {
4466 return arr.indexOf(what) !== -1;
4467 }
4468
4469
4470 var TOKEN$1 = {
4471 START_EXPR: 'TK_START_EXPR',
4472 END_EXPR: 'TK_END_EXPR',
4473 START_BLOCK: 'TK_START_BLOCK',
4474 END_BLOCK: 'TK_END_BLOCK',
4475 WORD: 'TK_WORD',
4476 RESERVED: 'TK_RESERVED',
4477 SEMICOLON: 'TK_SEMICOLON',
4478 STRING: 'TK_STRING',
4479 EQUALS: 'TK_EQUALS',
4480 OPERATOR: 'TK_OPERATOR',
4481 COMMA: 'TK_COMMA',
4482 BLOCK_COMMENT: 'TK_BLOCK_COMMENT',
4483 COMMENT: 'TK_COMMENT',
4484 DOT: 'TK_DOT',
4485 UNKNOWN: 'TK_UNKNOWN',
4486 START: BASETOKEN.START,
4487 RAW: BASETOKEN.RAW,
4488 EOF: BASETOKEN.EOF
4489 };
4490
4491
4492 var directives_core = new Directives$1(/\/\*/, /\*\//);
4493
4494 var number_pattern = /0[xX][0123456789abcdefABCDEF]*|0[oO][01234567]*|0[bB][01]*|\d+n|(?:\.\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?/;
4495
4496 var digit = /[0-9]/;
4497
4498 // Dot "." must be distinguished from "..." and decimal
4499 var dot_pattern = /[^\d\.]/;
4500
4501 var positionable_operators = (
4502 ">>> === !== " +
4503 "<< && >= ** != == <= >> || " +
4504 "< / - + > : & % ? ^ | *").split(' ');
4505
4506 // IMPORTANT: this must be sorted longest to shortest or tokenizing many not work.
4507 // Also, you must update possitionable operators separately from punct
4508 var punct =
4509 ">>>= " +
4510 "... >>= <<= === >>> !== **= " +
4511 "=> ^= :: /= << <= == && -= >= >> != -- += ** || ++ %= &= *= |= " +
4512 "= ! ? > < : / ^ - + * & % ~ |";
4513
4514 punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
4515 punct = punct.replace(/ /g, '|');
4516
4517 var punct_pattern = new RegExp(punct);
4518
4519 // words which should always start on new line.
4520 var line_starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export'.split(',');
4521 var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as']);
4522 var reserved_word_pattern = new RegExp('^(?:' + reserved_words.join('|') + ')$');
4523
4524 // var template_pattern = /(?:(?:<\?php|<\?=)[\s\S]*?\?>)|(?:<%[\s\S]*?%>)/g;
4525
4526 var in_html_comment;
4527
4528 var Tokenizer$1 = function(input_string, options) {
4529 BaseTokenizer.call(this, input_string, options);
4530
4531 this._patterns.whitespace = this._patterns.whitespace.matching(
4532 /\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,
4533 /\u2028\u2029/.source);
4534
4535 var pattern_reader = new Pattern$3(this._input);
4536 var templatable = new TemplatablePattern$1(this._input)
4537 .read_options(this._options);
4538
4539 this.__patterns = {
4540 template: templatable,
4541 identifier: templatable.starting_with(acorn.identifier).matching(acorn.identifierMatch),
4542 number: pattern_reader.matching(number_pattern),
4543 punct: pattern_reader.matching(punct_pattern),
4544 // comment ends just before nearest linefeed or end of file
4545 comment: pattern_reader.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),
4546 // /* ... */ comment ends with nearest */ or end of file
4547 block_comment: pattern_reader.starting_with(/\/\*/).until_after(/\*\//),
4548 html_comment_start: pattern_reader.matching(/<!--/),
4549 html_comment_end: pattern_reader.matching(/-->/),
4550 include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak),
4551 shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak),
4552 xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\])(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/),
4553 single_quote: templatable.until(/['\\\n\r\u2028\u2029]/),
4554 double_quote: templatable.until(/["\\\n\r\u2028\u2029]/),
4555 template_text: templatable.until(/[`\\$]/),
4556 template_expression: templatable.until(/[`}\\]/)
4557 };
4558
4559 };
4560 Tokenizer$1.prototype = new BaseTokenizer();
4561
4562 Tokenizer$1.prototype._is_comment = function(current_token) {
4563 return current_token.type === TOKEN$1.COMMENT || current_token.type === TOKEN$1.BLOCK_COMMENT || current_token.type === TOKEN$1.UNKNOWN;
4564 };
4565
4566 Tokenizer$1.prototype._is_opening = function(current_token) {
4567 return current_token.type === TOKEN$1.START_BLOCK || current_token.type === TOKEN$1.START_EXPR;
4568 };
4569
4570 Tokenizer$1.prototype._is_closing = function(current_token, open_token) {
4571 return (current_token.type === TOKEN$1.END_BLOCK || current_token.type === TOKEN$1.END_EXPR) &&
4572 (open_token && (
4573 (current_token.text === ']' && open_token.text === '[') ||
4574 (current_token.text === ')' && open_token.text === '(') ||
4575 (current_token.text === '}' && open_token.text === '{')));
4576 };
4577
4578 Tokenizer$1.prototype._reset = function() {
4579 in_html_comment = false;
4580 };
4581
4582 Tokenizer$1.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
4583 var token = null;
4584 this._readWhitespace();
4585 var c = this._input.peek();
4586
4587 if (c === null) {
4588 return this._create_token(TOKEN$1.EOF, '');
4589 }
4590
4591 token = token || this._read_string(c);
4592 token = token || this._read_word(previous_token);
4593 token = token || this._read_singles(c);
4594 token = token || this._read_comment(c);
4595 token = token || this._read_regexp(c, previous_token);
4596 token = token || this._read_xml(c, previous_token);
4597 token = token || this._read_non_javascript(c);
4598 token = token || this._read_punctuation();
4599 token = token || this._create_token(TOKEN$1.UNKNOWN, this._input.next());
4600
4601 return token;
4602 };
4603
4604 Tokenizer$1.prototype._read_word = function(previous_token) {
4605 var resulting_string;
4606 resulting_string = this.__patterns.identifier.read();
4607 if (resulting_string !== '') {
4608 resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
4609 if (!(previous_token.type === TOKEN$1.DOT ||
4610 (previous_token.type === TOKEN$1.RESERVED && (previous_token.text === 'set' || previous_token.text === 'get'))) &&
4611 reserved_word_pattern.test(resulting_string)) {
4612 if (resulting_string === 'in' || resulting_string === 'of') { // hack for 'in' and 'of' operators
4613 return this._create_token(TOKEN$1.OPERATOR, resulting_string);
4614 }
4615 return this._create_token(TOKEN$1.RESERVED, resulting_string);
4616 }
4617 return this._create_token(TOKEN$1.WORD, resulting_string);
4618 }
4619
4620 resulting_string = this.__patterns.number.read();
4621 if (resulting_string !== '') {
4622 return this._create_token(TOKEN$1.WORD, resulting_string);
4623 }
4624 };
4625
4626 Tokenizer$1.prototype._read_singles = function(c) {
4627 var token = null;
4628 if (c === '(' || c === '[') {
4629 token = this._create_token(TOKEN$1.START_EXPR, c);
4630 } else if (c === ')' || c === ']') {
4631 token = this._create_token(TOKEN$1.END_EXPR, c);
4632 } else if (c === '{') {
4633 token = this._create_token(TOKEN$1.START_BLOCK, c);
4634 } else if (c === '}') {
4635 token = this._create_token(TOKEN$1.END_BLOCK, c);
4636 } else if (c === ';') {
4637 token = this._create_token(TOKEN$1.SEMICOLON, c);
4638 } else if (c === '.' && dot_pattern.test(this._input.peek(1))) {
4639 token = this._create_token(TOKEN$1.DOT, c);
4640 } else if (c === ',') {
4641 token = this._create_token(TOKEN$1.COMMA, c);
4642 }
4643
4644 if (token) {
4645 this._input.next();
4646 }
4647 return token;
4648 };
4649
4650 Tokenizer$1.prototype._read_punctuation = function() {
4651 var resulting_string = this.__patterns.punct.read();
4652
4653 if (resulting_string !== '') {
4654 if (resulting_string === '=') {
4655 return this._create_token(TOKEN$1.EQUALS, resulting_string);
4656 } else {
4657 return this._create_token(TOKEN$1.OPERATOR, resulting_string);
4658 }
4659 }
4660 };
4661
4662 Tokenizer$1.prototype._read_non_javascript = function(c) {
4663 var resulting_string = '';
4664
4665 if (c === '#') {
4666 if (this._is_first_token()) {
4667 resulting_string = this.__patterns.shebang.read();
4668
4669 if (resulting_string) {
4670 return this._create_token(TOKEN$1.UNKNOWN, resulting_string.trim() + '\n');
4671 }
4672 }
4673
4674 // handles extendscript #includes
4675 resulting_string = this.__patterns.include.read();
4676
4677 if (resulting_string) {
4678 return this._create_token(TOKEN$1.UNKNOWN, resulting_string.trim() + '\n');
4679 }
4680
4681 c = this._input.next();
4682
4683 // Spidermonkey-specific sharp variables for circular references. Considered obsolete.
4684 var sharp = '#';
4685 if (this._input.hasNext() && this._input.testChar(digit)) {
4686 do {
4687 c = this._input.next();
4688 sharp += c;
4689 } while (this._input.hasNext() && c !== '#' && c !== '=');
4690 if (c === '#') ; else if (this._input.peek() === '[' && this._input.peek(1) === ']') {
4691 sharp += '[]';
4692 this._input.next();
4693 this._input.next();
4694 } else if (this._input.peek() === '{' && this._input.peek(1) === '}') {
4695 sharp += '{}';
4696 this._input.next();
4697 this._input.next();
4698 }
4699 return this._create_token(TOKEN$1.WORD, sharp);
4700 }
4701
4702 this._input.back();
4703
4704 } else if (c === '<' && this._is_first_token()) {
4705 resulting_string = this.__patterns.html_comment_start.read();
4706 if (resulting_string) {
4707 while (this._input.hasNext() && !this._input.testChar(acorn.newline)) {
4708 resulting_string += this._input.next();
4709 }
4710 in_html_comment = true;
4711 return this._create_token(TOKEN$1.COMMENT, resulting_string);
4712 }
4713 } else if (in_html_comment && c === '-') {
4714 resulting_string = this.__patterns.html_comment_end.read();
4715 if (resulting_string) {
4716 in_html_comment = false;
4717 return this._create_token(TOKEN$1.COMMENT, resulting_string);
4718 }
4719 }
4720
4721 return null;
4722 };
4723
4724 Tokenizer$1.prototype._read_comment = function(c) {
4725 var token = null;
4726 if (c === '/') {
4727 var comment = '';
4728 if (this._input.peek(1) === '*') {
4729 // peek for comment /* ... */
4730 comment = this.__patterns.block_comment.read();
4731 var directives = directives_core.get_directives(comment);
4732 if (directives && directives.ignore === 'start') {
4733 comment += directives_core.readIgnored(this._input);
4734 }
4735 comment = comment.replace(acorn.allLineBreaks, '\n');
4736 token = this._create_token(TOKEN$1.BLOCK_COMMENT, comment);
4737 token.directives = directives;
4738 } else if (this._input.peek(1) === '/') {
4739 // peek for comment // ...
4740 comment = this.__patterns.comment.read();
4741 token = this._create_token(TOKEN$1.COMMENT, comment);
4742 }
4743 }
4744 return token;
4745 };
4746
4747 Tokenizer$1.prototype._read_string = function(c) {
4748 if (c === '`' || c === "'" || c === '"') {
4749 var resulting_string = this._input.next();
4750 this.has_char_escapes = false;
4751
4752 if (c === '`') {
4753 resulting_string += this._read_string_recursive('`', true, '${');
4754 } else {
4755 resulting_string += this._read_string_recursive(c);
4756 }
4757
4758 if (this.has_char_escapes && this._options.unescape_strings) {
4759 resulting_string = unescape_string(resulting_string);
4760 }
4761
4762 if (this._input.peek() === c) {
4763 resulting_string += this._input.next();
4764 }
4765
4766 resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
4767
4768 return this._create_token(TOKEN$1.STRING, resulting_string);
4769 }
4770
4771 return null;
4772 };
4773
4774 Tokenizer$1.prototype._allow_regexp_or_xml = function(previous_token) {
4775 // regex and xml can only appear in specific locations during parsing
4776 return (previous_token.type === TOKEN$1.RESERVED && in_array(previous_token.text, ['return', 'case', 'throw', 'else', 'do', 'typeof', 'yield'])) ||
4777 (previous_token.type === TOKEN$1.END_EXPR && previous_token.text === ')' &&
4778 previous_token.opened.previous.type === TOKEN$1.RESERVED && in_array(previous_token.opened.previous.text, ['if', 'while', 'for'])) ||
4779 (in_array(previous_token.type, [TOKEN$1.COMMENT, TOKEN$1.START_EXPR, TOKEN$1.START_BLOCK, TOKEN$1.START,
4780 TOKEN$1.END_BLOCK, TOKEN$1.OPERATOR, TOKEN$1.EQUALS, TOKEN$1.EOF, TOKEN$1.SEMICOLON, TOKEN$1.COMMA
4781 ]));
4782 };
4783
4784 Tokenizer$1.prototype._read_regexp = function(c, previous_token) {
4785
4786 if (c === '/' && this._allow_regexp_or_xml(previous_token)) {
4787 // handle regexp
4788 //
4789 var resulting_string = this._input.next();
4790 var esc = false;
4791
4792 var in_char_class = false;
4793 while (this._input.hasNext() &&
4794 ((esc || in_char_class || this._input.peek() !== c) &&
4795 !this._input.testChar(acorn.newline))) {
4796 resulting_string += this._input.peek();
4797 if (!esc) {
4798 esc = this._input.peek() === '\\';
4799 if (this._input.peek() === '[') {
4800 in_char_class = true;
4801 } else if (this._input.peek() === ']') {
4802 in_char_class = false;
4803 }
4804 } else {
4805 esc = false;
4806 }
4807 this._input.next();
4808 }
4809
4810 if (this._input.peek() === c) {
4811 resulting_string += this._input.next();
4812
4813 // regexps may have modifiers /regexp/MOD , so fetch those, too
4814 // Only [gim] are valid, but if the user puts in garbage, do what we can to take it.
4815 resulting_string += this._input.read(acorn.identifier);
4816 }
4817 return this._create_token(TOKEN$1.STRING, resulting_string);
4818 }
4819 return null;
4820 };
4821
4822 Tokenizer$1.prototype._read_xml = function(c, previous_token) {
4823
4824 if (this._options.e4x && c === "<" && this._allow_regexp_or_xml(previous_token)) {
4825 var xmlStr = '';
4826 var match = this.__patterns.xml.read_match();
4827 // handle e4x xml literals
4828 //
4829 if (match) {
4830 // Trim root tag to attempt to
4831 var rootTag = match[2].replace(/^{\s+/, '{').replace(/\s+}$/, '}');
4832 var isCurlyRoot = rootTag.indexOf('{') === 0;
4833 var depth = 0;
4834 while (match) {
4835 var isEndTag = !!match[1];
4836 var tagName = match[2];
4837 var isSingletonTag = (!!match[match.length - 1]) || (tagName.slice(0, 8) === "![CDATA[");
4838 if (!isSingletonTag &&
4839 (tagName === rootTag || (isCurlyRoot && tagName.replace(/^{\s+/, '{').replace(/\s+}$/, '}')))) {
4840 if (isEndTag) {
4841 --depth;
4842 } else {
4843 ++depth;
4844 }
4845 }
4846 xmlStr += match[0];
4847 if (depth <= 0) {
4848 break;
4849 }
4850 match = this.__patterns.xml.read_match();
4851 }
4852 // if we didn't close correctly, keep unformatted.
4853 if (!match) {
4854 xmlStr += this._input.match(/[\s\S]*/g)[0];
4855 }
4856 xmlStr = xmlStr.replace(acorn.allLineBreaks, '\n');
4857 return this._create_token(TOKEN$1.STRING, xmlStr);
4858 }
4859 }
4860
4861 return null;
4862 };
4863
4864 function unescape_string(s) {
4865 // You think that a regex would work for this
4866 // return s.replace(/\\x([0-9a-f]{2})/gi, function(match, val) {
4867 // return String.fromCharCode(parseInt(val, 16));
4868 // })
4869 // However, dealing with '\xff', '\\xff', '\\\xff' makes this more fun.
4870 var out = '',
4871 escaped = 0;
4872
4873 var input_scan = new InputScanner$2(s);
4874 var matched = null;
4875
4876 while (input_scan.hasNext()) {
4877 // Keep any whitespace, non-slash characters
4878 // also keep slash pairs.
4879 matched = input_scan.match(/([\s]|[^\\]|\\\\)+/g);
4880
4881 if (matched) {
4882 out += matched[0];
4883 }
4884
4885 if (input_scan.peek() === '\\') {
4886 input_scan.next();
4887 if (input_scan.peek() === 'x') {
4888 matched = input_scan.match(/x([0-9A-Fa-f]{2})/g);
4889 } else if (input_scan.peek() === 'u') {
4890 matched = input_scan.match(/u([0-9A-Fa-f]{4})/g);
4891 } else {
4892 out += '\\';
4893 if (input_scan.hasNext()) {
4894 out += input_scan.next();
4895 }
4896 continue;
4897 }
4898
4899 // If there's some error decoding, return the original string
4900 if (!matched) {
4901 return s;
4902 }
4903
4904 escaped = parseInt(matched[1], 16);
4905
4906 if (escaped > 0x7e && escaped <= 0xff && matched[0].indexOf('x') === 0) {
4907 // we bail out on \x7f..\xff,
4908 // leaving whole string escaped,
4909 // as it's probably completely binary
4910 return s;
4911 } else if (escaped >= 0x00 && escaped < 0x20) {
4912 // leave 0x00...0x1f escaped
4913 out += '\\' + matched[0];
4914 continue;
4915 } else if (escaped === 0x22 || escaped === 0x27 || escaped === 0x5c) {
4916 // single-quote, apostrophe, backslash - escape these
4917 out += '\\' + String.fromCharCode(escaped);
4918 } else {
4919 out += String.fromCharCode(escaped);
4920 }
4921 }
4922 }
4923
4924 return out;
4925 }
4926
4927 // handle string
4928 //
4929 Tokenizer$1.prototype._read_string_recursive = function(delimiter, allow_unescaped_newlines, start_sub) {
4930 var current_char;
4931 var pattern;
4932 if (delimiter === '\'') {
4933 pattern = this.__patterns.single_quote;
4934 } else if (delimiter === '"') {
4935 pattern = this.__patterns.double_quote;
4936 } else if (delimiter === '`') {
4937 pattern = this.__patterns.template_text;
4938 } else if (delimiter === '}') {
4939 pattern = this.__patterns.template_expression;
4940 }
4941
4942 var resulting_string = pattern.read();
4943 var next = '';
4944 while (this._input.hasNext()) {
4945 next = this._input.next();
4946 if (next === delimiter ||
4947 (!allow_unescaped_newlines && acorn.newline.test(next))) {
4948 this._input.back();
4949 break;
4950 } else if (next === '\\' && this._input.hasNext()) {
4951 current_char = this._input.peek();
4952
4953 if (current_char === 'x' || current_char === 'u') {
4954 this.has_char_escapes = true;
4955 } else if (current_char === '\r' && this._input.peek(1) === '\n') {
4956 this._input.next();
4957 }
4958 next += this._input.next();
4959 } else if (start_sub) {
4960 if (start_sub === '${' && next === '$' && this._input.peek() === '{') {
4961 next += this._input.next();
4962 }
4963
4964 if (start_sub === next) {
4965 if (delimiter === '`') {
4966 next += this._read_string_recursive('}', allow_unescaped_newlines, '`');
4967 } else {
4968 next += this._read_string_recursive('`', allow_unescaped_newlines, '${');
4969 }
4970 if (this._input.hasNext()) {
4971 next += this._input.next();
4972 }
4973 }
4974 }
4975 next += pattern.read();
4976 resulting_string += next;
4977 }
4978
4979 return resulting_string;
4980 };
4981
4982 var Tokenizer_1$1 = Tokenizer$1;
4983 var TOKEN_1$1 = TOKEN$1;
4984 var positionable_operators_1 = positionable_operators.slice();
4985 var line_starters_1 = line_starters.slice();
4986
4987 var tokenizer$1 = {
4988 Tokenizer: Tokenizer_1$1,
4989 TOKEN: TOKEN_1$1,
4990 positionable_operators: positionable_operators_1,
4991 line_starters: line_starters_1
4992 };
4993
4994 var Output$1 = output.Output;
4995 var Token$2 = token.Token;
4996
4997 var Options$2 = options$1.Options;
4998 var Tokenizer$2 = tokenizer$1.Tokenizer;
4999 var line_starters$1 = tokenizer$1.line_starters;
5000 var positionable_operators$1 = tokenizer$1.positionable_operators;
5001 var TOKEN$2 = tokenizer$1.TOKEN;
5002
5003
5004 function in_array$1(what, arr) {
5005 return arr.indexOf(what) !== -1;
5006 }
5007
5008 function ltrim(s) {
5009 return s.replace(/^\s+/g, '');
5010 }
5011
5012 function generateMapFromStrings(list) {
5013 var result = {};
5014 for (var x = 0; x < list.length; x++) {
5015 // make the mapped names underscored instead of dash
5016 result[list[x].replace(/-/g, '_')] = list[x];
5017 }
5018 return result;
5019 }
5020
5021 function reserved_word(token, word) {
5022 return token && token.type === TOKEN$2.RESERVED && token.text === word;
5023 }
5024
5025 function reserved_array(token, words) {
5026 return token && token.type === TOKEN$2.RESERVED && in_array$1(token.text, words);
5027 }
5028 // Unsure of what they mean, but they work. Worth cleaning up in future.
5029 var special_words = ['case', 'return', 'do', 'if', 'throw', 'else', 'await', 'break', 'continue', 'async'];
5030
5031 var validPositionValues$1 = ['before-newline', 'after-newline', 'preserve-newline'];
5032
5033 // Generate map from array
5034 var OPERATOR_POSITION = generateMapFromStrings(validPositionValues$1);
5035
5036 var OPERATOR_POSITION_BEFORE_OR_PRESERVE = [OPERATOR_POSITION.before_newline, OPERATOR_POSITION.preserve_newline];
5037
5038 var MODE = {
5039 BlockStatement: 'BlockStatement', // 'BLOCK'
5040 Statement: 'Statement', // 'STATEMENT'
5041 ObjectLiteral: 'ObjectLiteral', // 'OBJECT',
5042 ArrayLiteral: 'ArrayLiteral', //'[EXPRESSION]',
5043 ForInitializer: 'ForInitializer', //'(FOR-EXPRESSION)',
5044 Conditional: 'Conditional', //'(COND-EXPRESSION)',
5045 Expression: 'Expression' //'(EXPRESSION)'
5046 };
5047
5048 function remove_redundant_indentation(output, frame) {
5049 // This implementation is effective but has some issues:
5050 // - can cause line wrap to happen too soon due to indent removal
5051 // after wrap points are calculated
5052 // These issues are minor compared to ugly indentation.
5053
5054 if (frame.multiline_frame ||
5055 frame.mode === MODE.ForInitializer ||
5056 frame.mode === MODE.Conditional) {
5057 return;
5058 }
5059
5060 // remove one indent from each line inside this section
5061 output.remove_indent(frame.start_line_index);
5062 }
5063
5064 // we could use just string.split, but
5065 // IE doesn't like returning empty strings
5066 function split_linebreaks(s) {
5067 //return s.split(/\x0d\x0a|\x0a/);
5068
5069 s = s.replace(acorn.allLineBreaks, '\n');
5070 var out = [],
5071 idx = s.indexOf("\n");
5072 while (idx !== -1) {
5073 out.push(s.substring(0, idx));
5074 s = s.substring(idx + 1);
5075 idx = s.indexOf("\n");
5076 }
5077 if (s.length) {
5078 out.push(s);
5079 }
5080 return out;
5081 }
5082
5083 function is_array(mode) {
5084 return mode === MODE.ArrayLiteral;
5085 }
5086
5087 function is_expression(mode) {
5088 return in_array$1(mode, [MODE.Expression, MODE.ForInitializer, MODE.Conditional]);
5089 }
5090
5091 function all_lines_start_with(lines, c) {
5092 for (var i = 0; i < lines.length; i++) {
5093 var line = lines[i].trim();
5094 if (line.charAt(0) !== c) {
5095 return false;
5096 }
5097 }
5098 return true;
5099 }
5100
5101 function each_line_matches_indent(lines, indent) {
5102 var i = 0,
5103 len = lines.length,
5104 line;
5105 for (; i < len; i++) {
5106 line = lines[i];
5107 // allow empty lines to pass through
5108 if (line && line.indexOf(indent) !== 0) {
5109 return false;
5110 }
5111 }
5112 return true;
5113 }
5114
5115
5116 function Beautifier(source_text, options) {
5117 options = options || {};
5118 this._source_text = source_text || '';
5119
5120 this._output = null;
5121 this._tokens = null;
5122 this._last_last_text = null;
5123 this._flags = null;
5124 this._previous_flags = null;
5125
5126 this._flag_store = null;
5127 this._options = new Options$2(options);
5128 }
5129
5130 Beautifier.prototype.create_flags = function(flags_base, mode) {
5131 var next_indent_level = 0;
5132 if (flags_base) {
5133 next_indent_level = flags_base.indentation_level;
5134 if (!this._output.just_added_newline() &&
5135 flags_base.line_indent_level > next_indent_level) {
5136 next_indent_level = flags_base.line_indent_level;
5137 }
5138 }
5139
5140 var next_flags = {
5141 mode: mode,
5142 parent: flags_base,
5143 last_token: flags_base ? flags_base.last_token : new Token$2(TOKEN$2.START_BLOCK, ''), // last token text
5144 last_word: flags_base ? flags_base.last_word : '', // last TOKEN.WORD passed
5145 declaration_statement: false,
5146 declaration_assignment: false,
5147 multiline_frame: false,
5148 inline_frame: false,
5149 if_block: false,
5150 else_block: false,
5151 do_block: false,
5152 do_while: false,
5153 import_block: false,
5154 in_case_statement: false, // switch(..){ INSIDE HERE }
5155 in_case: false, // we're on the exact line with "case 0:"
5156 case_body: false, // the indented case-action block
5157 indentation_level: next_indent_level,
5158 alignment: 0,
5159 line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level,
5160 start_line_index: this._output.get_line_number(),
5161 ternary_depth: 0
5162 };
5163 return next_flags;
5164 };
5165
5166 Beautifier.prototype._reset = function(source_text) {
5167 var baseIndentString = source_text.match(/^[\t ]*/)[0];
5168
5169 this._last_last_text = ''; // pre-last token text
5170 this._output = new Output$1(this._options, baseIndentString);
5171
5172 // If testing the ignore directive, start with output disable set to true
5173 this._output.raw = this._options.test_output_raw;
5174
5175
5176 // Stack of parsing/formatting states, including MODE.
5177 // We tokenize, parse, and output in an almost purely a forward-only stream of token input
5178 // and formatted output. This makes the beautifier less accurate than full parsers
5179 // but also far more tolerant of syntax errors.
5180 //
5181 // For example, the default mode is MODE.BlockStatement. If we see a '{' we push a new frame of type
5182 // MODE.BlockStatement on the the stack, even though it could be object literal. If we later
5183 // encounter a ":", we'll switch to to MODE.ObjectLiteral. If we then see a ";",
5184 // most full parsers would die, but the beautifier gracefully falls back to
5185 // MODE.BlockStatement and continues on.
5186 this._flag_store = [];
5187 this.set_mode(MODE.BlockStatement);
5188 var tokenizer = new Tokenizer$2(source_text, this._options);
5189 this._tokens = tokenizer.tokenize();
5190 return source_text;
5191 };
5192
5193 Beautifier.prototype.beautify = function() {
5194 // if disabled, return the input unchanged.
5195 if (this._options.disabled) {
5196 return this._source_text;
5197 }
5198
5199 var sweet_code;
5200 var source_text = this._reset(this._source_text);
5201
5202 var eol = this._options.eol;
5203 if (this._options.eol === 'auto') {
5204 eol = '\n';
5205 if (source_text && acorn.lineBreak.test(source_text || '')) {
5206 eol = source_text.match(acorn.lineBreak)[0];
5207 }
5208 }
5209
5210 var current_token = this._tokens.next();
5211 while (current_token) {
5212 this.handle_token(current_token);
5213
5214 this._last_last_text = this._flags.last_token.text;
5215 this._flags.last_token = current_token;
5216
5217 current_token = this._tokens.next();
5218 }
5219
5220 sweet_code = this._output.get_code(eol);
5221
5222 return sweet_code;
5223 };
5224
5225 Beautifier.prototype.handle_token = function(current_token, preserve_statement_flags) {
5226 if (current_token.type === TOKEN$2.START_EXPR) {
5227 this.handle_start_expr(current_token);
5228 } else if (current_token.type === TOKEN$2.END_EXPR) {
5229 this.handle_end_expr(current_token);
5230 } else if (current_token.type === TOKEN$2.START_BLOCK) {
5231 this.handle_start_block(current_token);
5232 } else if (current_token.type === TOKEN$2.END_BLOCK) {
5233 this.handle_end_block(current_token);
5234 } else if (current_token.type === TOKEN$2.WORD) {
5235 this.handle_word(current_token);
5236 } else if (current_token.type === TOKEN$2.RESERVED) {
5237 this.handle_word(current_token);
5238 } else if (current_token.type === TOKEN$2.SEMICOLON) {
5239 this.handle_semicolon(current_token);
5240 } else if (current_token.type === TOKEN$2.STRING) {
5241 this.handle_string(current_token);
5242 } else if (current_token.type === TOKEN$2.EQUALS) {
5243 this.handle_equals(current_token);
5244 } else if (current_token.type === TOKEN$2.OPERATOR) {
5245 this.handle_operator(current_token);
5246 } else if (current_token.type === TOKEN$2.COMMA) {
5247 this.handle_comma(current_token);
5248 } else if (current_token.type === TOKEN$2.BLOCK_COMMENT) {
5249 this.handle_block_comment(current_token, preserve_statement_flags);
5250 } else if (current_token.type === TOKEN$2.COMMENT) {
5251 this.handle_comment(current_token, preserve_statement_flags);
5252 } else if (current_token.type === TOKEN$2.DOT) {
5253 this.handle_dot(current_token);
5254 } else if (current_token.type === TOKEN$2.EOF) {
5255 this.handle_eof(current_token);
5256 } else if (current_token.type === TOKEN$2.UNKNOWN) {
5257 this.handle_unknown(current_token, preserve_statement_flags);
5258 } else {
5259 this.handle_unknown(current_token, preserve_statement_flags);
5260 }
5261 };
5262
5263 Beautifier.prototype.handle_whitespace_and_comments = function(current_token, preserve_statement_flags) {
5264 var newlines = current_token.newlines;
5265 var keep_whitespace = this._options.keep_array_indentation && is_array(this._flags.mode);
5266
5267 if (current_token.comments_before) {
5268 var comment_token = current_token.comments_before.next();
5269 while (comment_token) {
5270 // The cleanest handling of inline comments is to treat them as though they aren't there.
5271 // Just continue formatting and the behavior should be logical.
5272 // Also ignore unknown tokens. Again, this should result in better behavior.
5273 this.handle_whitespace_and_comments(comment_token, preserve_statement_flags);
5274 this.handle_token(comment_token, preserve_statement_flags);
5275 comment_token = current_token.comments_before.next();
5276 }
5277 }
5278
5279 if (keep_whitespace) {
5280 for (var i = 0; i < newlines; i += 1) {
5281 this.print_newline(i > 0, preserve_statement_flags);
5282 }
5283 } else {
5284 if (this._options.max_preserve_newlines && newlines > this._options.max_preserve_newlines) {
5285 newlines = this._options.max_preserve_newlines;
5286 }
5287
5288 if (this._options.preserve_newlines) {
5289 if (newlines > 1) {
5290 this.print_newline(false, preserve_statement_flags);
5291 for (var j = 1; j < newlines; j += 1) {
5292 this.print_newline(true, preserve_statement_flags);
5293 }
5294 }
5295 }
5296 }
5297
5298 };
5299
5300 var newline_restricted_tokens = ['async', 'break', 'continue', 'return', 'throw', 'yield'];
5301
5302 Beautifier.prototype.allow_wrap_or_preserved_newline = function(current_token, force_linewrap) {
5303 force_linewrap = (force_linewrap === undefined) ? false : force_linewrap;
5304
5305 // Never wrap the first token on a line
5306 if (this._output.just_added_newline()) {
5307 return;
5308 }
5309
5310 var shouldPreserveOrForce = (this._options.preserve_newlines && current_token.newlines) || force_linewrap;
5311 var operatorLogicApplies = in_array$1(this._flags.last_token.text, positionable_operators$1) ||
5312 in_array$1(current_token.text, positionable_operators$1);
5313
5314 if (operatorLogicApplies) {
5315 var shouldPrintOperatorNewline = (
5316 in_array$1(this._flags.last_token.text, positionable_operators$1) &&
5317 in_array$1(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)
5318 ) ||
5319 in_array$1(current_token.text, positionable_operators$1);
5320 shouldPreserveOrForce = shouldPreserveOrForce && shouldPrintOperatorNewline;
5321 }
5322
5323 if (shouldPreserveOrForce) {
5324 this.print_newline(false, true);
5325 } else if (this._options.wrap_line_length) {
5326 if (reserved_array(this._flags.last_token, newline_restricted_tokens)) {
5327 // These tokens should never have a newline inserted
5328 // between them and the following expression.
5329 return;
5330 }
5331 this._output.set_wrap_point();
5332 }
5333 };
5334
5335 Beautifier.prototype.print_newline = function(force_newline, preserve_statement_flags) {
5336 if (!preserve_statement_flags) {
5337 if (this._flags.last_token.text !== ';' && this._flags.last_token.text !== ',' && this._flags.last_token.text !== '=' && (this._flags.last_token.type !== TOKEN$2.OPERATOR || this._flags.last_token.text === '--' || this._flags.last_token.text === '++')) {
5338 var next_token = this._tokens.peek();
5339 while (this._flags.mode === MODE.Statement &&
5340 !(this._flags.if_block && reserved_word(next_token, 'else')) &&
5341 !this._flags.do_block) {
5342 this.restore_mode();
5343 }
5344 }
5345 }
5346
5347 if (this._output.add_new_line(force_newline)) {
5348 this._flags.multiline_frame = true;
5349 }
5350 };
5351
5352 Beautifier.prototype.print_token_line_indentation = function(current_token) {
5353 if (this._output.just_added_newline()) {
5354 if (this._options.keep_array_indentation &&
5355 current_token.newlines &&
5356 (current_token.text === '[' || is_array(this._flags.mode))) {
5357 this._output.current_line.set_indent(-1);
5358 this._output.current_line.push(current_token.whitespace_before);
5359 this._output.space_before_token = false;
5360 } else if (this._output.set_indent(this._flags.indentation_level, this._flags.alignment)) {
5361 this._flags.line_indent_level = this._flags.indentation_level;
5362 }
5363 }
5364 };
5365
5366 Beautifier.prototype.print_token = function(current_token) {
5367 if (this._output.raw) {
5368 this._output.add_raw_token(current_token);
5369 return;
5370 }
5371
5372 if (this._options.comma_first && current_token.previous && current_token.previous.type === TOKEN$2.COMMA &&
5373 this._output.just_added_newline()) {
5374 if (this._output.previous_line.last() === ',') {
5375 var popped = this._output.previous_line.pop();
5376 // if the comma was already at the start of the line,
5377 // pull back onto that line and reprint the indentation
5378 if (this._output.previous_line.is_empty()) {
5379 this._output.previous_line.push(popped);
5380 this._output.trim(true);
5381 this._output.current_line.pop();
5382 this._output.trim();
5383 }
5384
5385 // add the comma in front of the next token
5386 this.print_token_line_indentation(current_token);
5387 this._output.add_token(',');
5388 this._output.space_before_token = true;
5389 }
5390 }
5391
5392 this.print_token_line_indentation(current_token);
5393 this._output.non_breaking_space = true;
5394 this._output.add_token(current_token.text);
5395 if (this._output.previous_token_wrapped) {
5396 this._flags.multiline_frame = true;
5397 }
5398 };
5399
5400 Beautifier.prototype.indent = function() {
5401 this._flags.indentation_level += 1;
5402 this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
5403 };
5404
5405 Beautifier.prototype.deindent = function() {
5406 if (this._flags.indentation_level > 0 &&
5407 ((!this._flags.parent) || this._flags.indentation_level > this._flags.parent.indentation_level)) {
5408 this._flags.indentation_level -= 1;
5409 this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
5410 }
5411 };
5412
5413 Beautifier.prototype.set_mode = function(mode) {
5414 if (this._flags) {
5415 this._flag_store.push(this._flags);
5416 this._previous_flags = this._flags;
5417 } else {
5418 this._previous_flags = this.create_flags(null, mode);
5419 }
5420
5421 this._flags = this.create_flags(this._previous_flags, mode);
5422 this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
5423 };
5424
5425
5426 Beautifier.prototype.restore_mode = function() {
5427 if (this._flag_store.length > 0) {
5428 this._previous_flags = this._flags;
5429 this._flags = this._flag_store.pop();
5430 if (this._previous_flags.mode === MODE.Statement) {
5431 remove_redundant_indentation(this._output, this._previous_flags);
5432 }
5433 this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
5434 }
5435 };
5436
5437 Beautifier.prototype.start_of_object_property = function() {
5438 return this._flags.parent.mode === MODE.ObjectLiteral && this._flags.mode === MODE.Statement && (
5439 (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || (reserved_array(this._flags.last_token, ['get', 'set'])));
5440 };
5441
5442 Beautifier.prototype.start_of_statement = function(current_token) {
5443 var start = false;
5444 start = start || reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN$2.WORD;
5445 start = start || reserved_word(this._flags.last_token, 'do');
5446 start = start || (!(this._flags.parent.mode === MODE.ObjectLiteral && this._flags.mode === MODE.Statement)) && reserved_array(this._flags.last_token, newline_restricted_tokens) && !current_token.newlines;
5447 start = start || reserved_word(this._flags.last_token, 'else') &&
5448 !(reserved_word(current_token, 'if') && !current_token.comments_before);
5449 start = start || (this._flags.last_token.type === TOKEN$2.END_EXPR && (this._previous_flags.mode === MODE.ForInitializer || this._previous_flags.mode === MODE.Conditional));
5450 start = start || (this._flags.last_token.type === TOKEN$2.WORD && this._flags.mode === MODE.BlockStatement &&
5451 !this._flags.in_case &&
5452 !(current_token.text === '--' || current_token.text === '++') &&
5453 this._last_last_text !== 'function' &&
5454 current_token.type !== TOKEN$2.WORD && current_token.type !== TOKEN$2.RESERVED);
5455 start = start || (this._flags.mode === MODE.ObjectLiteral && (
5456 (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || reserved_array(this._flags.last_token, ['get', 'set'])));
5457
5458 if (start) {
5459 this.set_mode(MODE.Statement);
5460 this.indent();
5461
5462 this.handle_whitespace_and_comments(current_token, true);
5463
5464 // Issue #276:
5465 // If starting a new statement with [if, for, while, do], push to a new line.
5466 // if (a) if (b) if(c) d(); else e(); else f();
5467 if (!this.start_of_object_property()) {
5468 this.allow_wrap_or_preserved_newline(current_token,
5469 reserved_array(current_token, ['do', 'for', 'if', 'while']));
5470 }
5471 return true;
5472 }
5473 return false;
5474 };
5475
5476 Beautifier.prototype.handle_start_expr = function(current_token) {
5477 // The conditional starts the statement if appropriate.
5478 if (!this.start_of_statement(current_token)) {
5479 this.handle_whitespace_and_comments(current_token);
5480 }
5481
5482 var next_mode = MODE.Expression;
5483 if (current_token.text === '[') {
5484
5485 if (this._flags.last_token.type === TOKEN$2.WORD || this._flags.last_token.text === ')') {
5486 // this is array index specifier, break immediately
5487 // a[x], fn()[x]
5488 if (reserved_array(this._flags.last_token, line_starters$1)) {
5489 this._output.space_before_token = true;
5490 }
5491 this.print_token(current_token);
5492 this.set_mode(next_mode);
5493 this.indent();
5494 if (this._options.space_in_paren) {
5495 this._output.space_before_token = true;
5496 }
5497 return;
5498 }
5499
5500 next_mode = MODE.ArrayLiteral;
5501 if (is_array(this._flags.mode)) {
5502 if (this._flags.last_token.text === '[' ||
5503 (this._flags.last_token.text === ',' && (this._last_last_text === ']' || this._last_last_text === '}'))) {
5504 // ], [ goes to new line
5505 // }, [ goes to new line
5506 if (!this._options.keep_array_indentation) {
5507 this.print_newline();
5508 }
5509 }
5510 }
5511
5512 if (!in_array$1(this._flags.last_token.type, [TOKEN$2.START_EXPR, TOKEN$2.END_EXPR, TOKEN$2.WORD, TOKEN$2.OPERATOR])) {
5513 this._output.space_before_token = true;
5514 }
5515 } else {
5516 if (this._flags.last_token.type === TOKEN$2.RESERVED) {
5517 if (this._flags.last_token.text === 'for') {
5518 this._output.space_before_token = this._options.space_before_conditional;
5519 next_mode = MODE.ForInitializer;
5520 } else if (in_array$1(this._flags.last_token.text, ['if', 'while'])) {
5521 this._output.space_before_token = this._options.space_before_conditional;
5522 next_mode = MODE.Conditional;
5523 } else if (in_array$1(this._flags.last_word, ['await', 'async'])) {
5524 // Should be a space between await and an IIFE, or async and an arrow function
5525 this._output.space_before_token = true;
5526 } else if (this._flags.last_token.text === 'import' && current_token.whitespace_before === '') {
5527 this._output.space_before_token = false;
5528 } else if (in_array$1(this._flags.last_token.text, line_starters$1) || this._flags.last_token.text === 'catch') {
5529 this._output.space_before_token = true;
5530 }
5531 } else if (this._flags.last_token.type === TOKEN$2.EQUALS || this._flags.last_token.type === TOKEN$2.OPERATOR) {
5532 // Support of this kind of newline preservation.
5533 // a = (b &&
5534 // (c || d));
5535 if (!this.start_of_object_property()) {
5536 this.allow_wrap_or_preserved_newline(current_token);
5537 }
5538 } else if (this._flags.last_token.type === TOKEN$2.WORD) {
5539 this._output.space_before_token = false;
5540
5541 // function name() vs function name ()
5542 // function* name() vs function* name ()
5543 // async name() vs async name ()
5544 // In ES6, you can also define the method properties of an object
5545 // var obj = {a: function() {}}
5546 // It can be abbreviated
5547 // var obj = {a() {}}
5548 // var obj = { a() {}} vs var obj = { a () {}}
5549 // var obj = { * a() {}} vs var obj = { * a () {}}
5550 var peek_back_two = this._tokens.peek(-3);
5551 if (this._options.space_after_named_function && peek_back_two) {
5552 // peek starts at next character so -1 is current token
5553 var peek_back_three = this._tokens.peek(-4);
5554 if (reserved_array(peek_back_two, ['async', 'function']) ||
5555 (peek_back_two.text === '*' && reserved_array(peek_back_three, ['async', 'function']))) {
5556 this._output.space_before_token = true;
5557 } else if (this._flags.mode === MODE.ObjectLiteral) {
5558 if ((peek_back_two.text === '{' || peek_back_two.text === ',') ||
5559 (peek_back_two.text === '*' && (peek_back_three.text === '{' || peek_back_three.text === ','))) {
5560 this._output.space_before_token = true;
5561 }
5562 }
5563 }
5564 } else {
5565 // Support preserving wrapped arrow function expressions
5566 // a.b('c',
5567 // () => d.e
5568 // )
5569 this.allow_wrap_or_preserved_newline(current_token);
5570 }
5571
5572 // function() vs function ()
5573 // yield*() vs yield* ()
5574 // function*() vs function* ()
5575 if ((this._flags.last_token.type === TOKEN$2.RESERVED && (this._flags.last_word === 'function' || this._flags.last_word === 'typeof')) ||
5576 (this._flags.last_token.text === '*' &&
5577 (in_array$1(this._last_last_text, ['function', 'yield']) ||
5578 (this._flags.mode === MODE.ObjectLiteral && in_array$1(this._last_last_text, ['{', ',']))))) {
5579 this._output.space_before_token = this._options.space_after_anon_function;
5580 }
5581 }
5582
5583 if (this._flags.last_token.text === ';' || this._flags.last_token.type === TOKEN$2.START_BLOCK) {
5584 this.print_newline();
5585 } else if (this._flags.last_token.type === TOKEN$2.END_EXPR || this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.END_BLOCK || this._flags.last_token.text === '.' || this._flags.last_token.type === TOKEN$2.COMMA) {
5586 // do nothing on (( and )( and ][ and ]( and .(
5587 // TODO: Consider whether forcing this is required. Review failing tests when removed.
5588 this.allow_wrap_or_preserved_newline(current_token, current_token.newlines);
5589 }
5590
5591 this.print_token(current_token);
5592 this.set_mode(next_mode);
5593 if (this._options.space_in_paren) {
5594 this._output.space_before_token = true;
5595 }
5596
5597 // In all cases, if we newline while inside an expression it should be indented.
5598 this.indent();
5599 };
5600
5601 Beautifier.prototype.handle_end_expr = function(current_token) {
5602 // statements inside expressions are not valid syntax, but...
5603 // statements must all be closed when their container closes
5604 while (this._flags.mode === MODE.Statement) {
5605 this.restore_mode();
5606 }
5607
5608 this.handle_whitespace_and_comments(current_token);
5609
5610 if (this._flags.multiline_frame) {
5611 this.allow_wrap_or_preserved_newline(current_token,
5612 current_token.text === ']' && is_array(this._flags.mode) && !this._options.keep_array_indentation);
5613 }
5614
5615 if (this._options.space_in_paren) {
5616 if (this._flags.last_token.type === TOKEN$2.START_EXPR && !this._options.space_in_empty_paren) {
5617 // () [] no inner space in empty parens like these, ever, ref #320
5618 this._output.trim();
5619 this._output.space_before_token = false;
5620 } else {
5621 this._output.space_before_token = true;
5622 }
5623 }
5624 this.deindent();
5625 this.print_token(current_token);
5626 this.restore_mode();
5627
5628 remove_redundant_indentation(this._output, this._previous_flags);
5629
5630 // do {} while () // no statement required after
5631 if (this._flags.do_while && this._previous_flags.mode === MODE.Conditional) {
5632 this._previous_flags.mode = MODE.Expression;
5633 this._flags.do_block = false;
5634 this._flags.do_while = false;
5635
5636 }
5637 };
5638
5639 Beautifier.prototype.handle_start_block = function(current_token) {
5640 this.handle_whitespace_and_comments(current_token);
5641
5642 // Check if this is should be treated as a ObjectLiteral
5643 var next_token = this._tokens.peek();
5644 var second_token = this._tokens.peek(1);
5645 if (this._flags.last_word === 'switch' && this._flags.last_token.type === TOKEN$2.END_EXPR) {
5646 this.set_mode(MODE.BlockStatement);
5647 this._flags.in_case_statement = true;
5648 } else if (this._flags.case_body) {
5649 this.set_mode(MODE.BlockStatement);
5650 } else if (second_token && (
5651 (in_array$1(second_token.text, [':', ',']) && in_array$1(next_token.type, [TOKEN$2.STRING, TOKEN$2.WORD, TOKEN$2.RESERVED])) ||
5652 (in_array$1(next_token.text, ['get', 'set', '...']) && in_array$1(second_token.type, [TOKEN$2.WORD, TOKEN$2.RESERVED]))
5653 )) {
5654 // We don't support TypeScript,but we didn't break it for a very long time.
5655 // We'll try to keep not breaking it.
5656 if (!in_array$1(this._last_last_text, ['class', 'interface'])) {
5657 this.set_mode(MODE.ObjectLiteral);
5658 } else {
5659 this.set_mode(MODE.BlockStatement);
5660 }
5661 } else if (this._flags.last_token.type === TOKEN$2.OPERATOR && this._flags.last_token.text === '=>') {
5662 // arrow function: (param1, paramN) => { statements }
5663 this.set_mode(MODE.BlockStatement);
5664 } else if (in_array$1(this._flags.last_token.type, [TOKEN$2.EQUALS, TOKEN$2.START_EXPR, TOKEN$2.COMMA, TOKEN$2.OPERATOR]) ||
5665 reserved_array(this._flags.last_token, ['return', 'throw', 'import', 'default'])
5666 ) {
5667 // Detecting shorthand function syntax is difficult by scanning forward,
5668 // so check the surrounding context.
5669 // If the block is being returned, imported, export default, passed as arg,
5670 // assigned with = or assigned in a nested object, treat as an ObjectLiteral.
5671 this.set_mode(MODE.ObjectLiteral);
5672 } else {
5673 this.set_mode(MODE.BlockStatement);
5674 }
5675
5676 var empty_braces = !next_token.comments_before && next_token.text === '}';
5677 var empty_anonymous_function = empty_braces && this._flags.last_word === 'function' &&
5678 this._flags.last_token.type === TOKEN$2.END_EXPR;
5679
5680 if (this._options.brace_preserve_inline) // check for inline, set inline_frame if so
5681 {
5682 // search forward for a newline wanted inside this block
5683 var index = 0;
5684 var check_token = null;
5685 this._flags.inline_frame = true;
5686 do {
5687 index += 1;
5688 check_token = this._tokens.peek(index - 1);
5689 if (check_token.newlines) {
5690 this._flags.inline_frame = false;
5691 break;
5692 }
5693 } while (check_token.type !== TOKEN$2.EOF &&
5694 !(check_token.type === TOKEN$2.END_BLOCK && check_token.opened === current_token));
5695 }
5696
5697 if ((this._options.brace_style === "expand" ||
5698 (this._options.brace_style === "none" && current_token.newlines)) &&
5699 !this._flags.inline_frame) {
5700 if (this._flags.last_token.type !== TOKEN$2.OPERATOR &&
5701 (empty_anonymous_function ||
5702 this._flags.last_token.type === TOKEN$2.EQUALS ||
5703 (reserved_array(this._flags.last_token, special_words) && this._flags.last_token.text !== 'else'))) {
5704 this._output.space_before_token = true;
5705 } else {
5706 this.print_newline(false, true);
5707 }
5708 } else { // collapse || inline_frame
5709 if (is_array(this._previous_flags.mode) && (this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.COMMA)) {
5710 if (this._flags.last_token.type === TOKEN$2.COMMA || this._options.space_in_paren) {
5711 this._output.space_before_token = true;
5712 }
5713
5714 if (this._flags.last_token.type === TOKEN$2.COMMA || (this._flags.last_token.type === TOKEN$2.START_EXPR && this._flags.inline_frame)) {
5715 this.allow_wrap_or_preserved_newline(current_token);
5716 this._previous_flags.multiline_frame = this._previous_flags.multiline_frame || this._flags.multiline_frame;
5717 this._flags.multiline_frame = false;
5718 }
5719 }
5720 if (this._flags.last_token.type !== TOKEN$2.OPERATOR && this._flags.last_token.type !== TOKEN$2.START_EXPR) {
5721 if (this._flags.last_token.type === TOKEN$2.START_BLOCK && !this._flags.inline_frame) {
5722 this.print_newline();
5723 } else {
5724 this._output.space_before_token = true;
5725 }
5726 }
5727 }
5728 this.print_token(current_token);
5729 this.indent();
5730
5731 // Except for specific cases, open braces are followed by a new line.
5732 if (!empty_braces && !(this._options.brace_preserve_inline && this._flags.inline_frame)) {
5733 this.print_newline();
5734 }
5735 };
5736
5737 Beautifier.prototype.handle_end_block = function(current_token) {
5738 // statements must all be closed when their container closes
5739 this.handle_whitespace_and_comments(current_token);
5740
5741 while (this._flags.mode === MODE.Statement) {
5742 this.restore_mode();
5743 }
5744
5745 var empty_braces = this._flags.last_token.type === TOKEN$2.START_BLOCK;
5746
5747 if (this._flags.inline_frame && !empty_braces) { // try inline_frame (only set if this._options.braces-preserve-inline) first
5748 this._output.space_before_token = true;
5749 } else if (this._options.brace_style === "expand") {
5750 if (!empty_braces) {
5751 this.print_newline();
5752 }
5753 } else {
5754 // skip {}
5755 if (!empty_braces) {
5756 if (is_array(this._flags.mode) && this._options.keep_array_indentation) {
5757 // we REALLY need a newline here, but newliner would skip that
5758 this._options.keep_array_indentation = false;
5759 this.print_newline();
5760 this._options.keep_array_indentation = true;
5761
5762 } else {
5763 this.print_newline();
5764 }
5765 }
5766 }
5767 this.restore_mode();
5768 this.print_token(current_token);
5769 };
5770
5771 Beautifier.prototype.handle_word = function(current_token) {
5772 if (current_token.type === TOKEN$2.RESERVED) {
5773 if (in_array$1(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) {
5774 current_token.type = TOKEN$2.WORD;
5775 } else if (current_token.text === 'import' && this._tokens.peek().text === '(') {
5776 current_token.type = TOKEN$2.WORD;
5777 } else if (in_array$1(current_token.text, ['as', 'from']) && !this._flags.import_block) {
5778 current_token.type = TOKEN$2.WORD;
5779 } else if (this._flags.mode === MODE.ObjectLiteral) {
5780 var next_token = this._tokens.peek();
5781 if (next_token.text === ':') {
5782 current_token.type = TOKEN$2.WORD;
5783 }
5784 }
5785 }
5786
5787 if (this.start_of_statement(current_token)) {
5788 // The conditional starts the statement if appropriate.
5789 if (reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN$2.WORD) {
5790 this._flags.declaration_statement = true;
5791 }
5792 } else if (current_token.newlines && !is_expression(this._flags.mode) &&
5793 (this._flags.last_token.type !== TOKEN$2.OPERATOR || (this._flags.last_token.text === '--' || this._flags.last_token.text === '++')) &&
5794 this._flags.last_token.type !== TOKEN$2.EQUALS &&
5795 (this._options.preserve_newlines || !reserved_array(this._flags.last_token, ['var', 'let', 'const', 'set', 'get']))) {
5796 this.handle_whitespace_and_comments(current_token);
5797 this.print_newline();
5798 } else {
5799 this.handle_whitespace_and_comments(current_token);
5800 }
5801
5802 if (this._flags.do_block && !this._flags.do_while) {
5803 if (reserved_word(current_token, 'while')) {
5804 // do {} ## while ()
5805 this._output.space_before_token = true;
5806 this.print_token(current_token);
5807 this._output.space_before_token = true;
5808 this._flags.do_while = true;
5809 return;
5810 } else {
5811 // do {} should always have while as the next word.
5812 // if we don't see the expected while, recover
5813 this.print_newline();
5814 this._flags.do_block = false;
5815 }
5816 }
5817
5818 // if may be followed by else, or not
5819 // Bare/inline ifs are tricky
5820 // Need to unwind the modes correctly: if (a) if (b) c(); else d(); else e();
5821 if (this._flags.if_block) {
5822 if (!this._flags.else_block && reserved_word(current_token, 'else')) {
5823 this._flags.else_block = true;
5824 } else {
5825 while (this._flags.mode === MODE.Statement) {
5826 this.restore_mode();
5827 }
5828 this._flags.if_block = false;
5829 this._flags.else_block = false;
5830 }
5831 }
5832
5833 if (this._flags.in_case_statement && reserved_array(current_token, ['case', 'default'])) {
5834 this.print_newline();
5835 if (this._flags.last_token.type !== TOKEN$2.END_BLOCK && (this._flags.case_body || this._options.jslint_happy)) {
5836 // switch cases following one another
5837 this.deindent();
5838 }
5839 this._flags.case_body = false;
5840
5841 this.print_token(current_token);
5842 this._flags.in_case = true;
5843 return;
5844 }
5845
5846 if (this._flags.last_token.type === TOKEN$2.COMMA || this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.EQUALS || this._flags.last_token.type === TOKEN$2.OPERATOR) {
5847 if (!this.start_of_object_property()) {
5848 this.allow_wrap_or_preserved_newline(current_token);
5849 }
5850 }
5851
5852 if (reserved_word(current_token, 'function')) {
5853 if (in_array$1(this._flags.last_token.text, ['}', ';']) ||
5854 (this._output.just_added_newline() && !(in_array$1(this._flags.last_token.text, ['(', '[', '{', ':', '=', ',']) || this._flags.last_token.type === TOKEN$2.OPERATOR))) {
5855 // make sure there is a nice clean space of at least one blank line
5856 // before a new function definition
5857 if (!this._output.just_added_blankline() && !current_token.comments_before) {
5858 this.print_newline();
5859 this.print_newline(true);
5860 }
5861 }
5862 if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD) {
5863 if (reserved_array(this._flags.last_token, ['get', 'set', 'new', 'export']) ||
5864 reserved_array(this._flags.last_token, newline_restricted_tokens)) {
5865 this._output.space_before_token = true;
5866 } else if (reserved_word(this._flags.last_token, 'default') && this._last_last_text === 'export') {
5867 this._output.space_before_token = true;
5868 } else if (this._flags.last_token.text === 'declare') {
5869 // accomodates Typescript declare function formatting
5870 this._output.space_before_token = true;
5871 } else {
5872 this.print_newline();
5873 }
5874 } else if (this._flags.last_token.type === TOKEN$2.OPERATOR || this._flags.last_token.text === '=') {
5875 // foo = function
5876 this._output.space_before_token = true;
5877 } else if (!this._flags.multiline_frame && (is_expression(this._flags.mode) || is_array(this._flags.mode))) ; else {
5878 this.print_newline();
5879 }
5880
5881 this.print_token(current_token);
5882 this._flags.last_word = current_token.text;
5883 return;
5884 }
5885
5886 var prefix = 'NONE';
5887
5888 if (this._flags.last_token.type === TOKEN$2.END_BLOCK) {
5889
5890 if (this._previous_flags.inline_frame) {
5891 prefix = 'SPACE';
5892 } else if (!reserved_array(current_token, ['else', 'catch', 'finally', 'from'])) {
5893 prefix = 'NEWLINE';
5894 } else {
5895 if (this._options.brace_style === "expand" ||
5896 this._options.brace_style === "end-expand" ||
5897 (this._options.brace_style === "none" && current_token.newlines)) {
5898 prefix = 'NEWLINE';
5899 } else {
5900 prefix = 'SPACE';
5901 this._output.space_before_token = true;
5902 }
5903 }
5904 } else if (this._flags.last_token.type === TOKEN$2.SEMICOLON && this._flags.mode === MODE.BlockStatement) {
5905 // TODO: Should this be for STATEMENT as well?
5906 prefix = 'NEWLINE';
5907 } else if (this._flags.last_token.type === TOKEN$2.SEMICOLON && is_expression(this._flags.mode)) {
5908 prefix = 'SPACE';
5909 } else if (this._flags.last_token.type === TOKEN$2.STRING) {
5910 prefix = 'NEWLINE';
5911 } else if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD ||
5912 (this._flags.last_token.text === '*' &&
5913 (in_array$1(this._last_last_text, ['function', 'yield']) ||
5914 (this._flags.mode === MODE.ObjectLiteral && in_array$1(this._last_last_text, ['{', ',']))))) {
5915 prefix = 'SPACE';
5916 } else if (this._flags.last_token.type === TOKEN$2.START_BLOCK) {
5917 if (this._flags.inline_frame) {
5918 prefix = 'SPACE';
5919 } else {
5920 prefix = 'NEWLINE';
5921 }
5922 } else if (this._flags.last_token.type === TOKEN$2.END_EXPR) {
5923 this._output.space_before_token = true;
5924 prefix = 'NEWLINE';
5925 }
5926
5927 if (reserved_array(current_token, line_starters$1) && this._flags.last_token.text !== ')') {
5928 if (this._flags.inline_frame || this._flags.last_token.text === 'else' || this._flags.last_token.text === 'export') {
5929 prefix = 'SPACE';
5930 } else {
5931 prefix = 'NEWLINE';
5932 }
5933
5934 }
5935
5936 if (reserved_array(current_token, ['else', 'catch', 'finally'])) {
5937 if ((!(this._flags.last_token.type === TOKEN$2.END_BLOCK && this._previous_flags.mode === MODE.BlockStatement) ||
5938 this._options.brace_style === "expand" ||
5939 this._options.brace_style === "end-expand" ||
5940 (this._options.brace_style === "none" && current_token.newlines)) &&
5941 !this._flags.inline_frame) {
5942 this.print_newline();
5943 } else {
5944 this._output.trim(true);
5945 var line = this._output.current_line;
5946 // If we trimmed and there's something other than a close block before us
5947 // put a newline back in. Handles '} // comment' scenario.
5948 if (line.last() !== '}') {
5949 this.print_newline();
5950 }
5951 this._output.space_before_token = true;
5952 }
5953 } else if (prefix === 'NEWLINE') {
5954 if (reserved_array(this._flags.last_token, special_words)) {
5955 // no newline between 'return nnn'
5956 this._output.space_before_token = true;
5957 } else if (this._flags.last_token.text === 'declare' && reserved_array(current_token, ['var', 'let', 'const'])) {
5958 // accomodates Typescript declare formatting
5959 this._output.space_before_token = true;
5960 } else if (this._flags.last_token.type !== TOKEN$2.END_EXPR) {
5961 if ((this._flags.last_token.type !== TOKEN$2.START_EXPR || !reserved_array(current_token, ['var', 'let', 'const'])) && this._flags.last_token.text !== ':') {
5962 // no need to force newline on 'var': for (var x = 0...)
5963 if (reserved_word(current_token, 'if') && reserved_word(current_token.previous, 'else')) {
5964 // no newline for } else if {
5965 this._output.space_before_token = true;
5966 } else {
5967 this.print_newline();
5968 }
5969 }
5970 } else if (reserved_array(current_token, line_starters$1) && this._flags.last_token.text !== ')') {
5971 this.print_newline();
5972 }
5973 } else if (this._flags.multiline_frame && is_array(this._flags.mode) && this._flags.last_token.text === ',' && this._last_last_text === '}') {
5974 this.print_newline(); // }, in lists get a newline treatment
5975 } else if (prefix === 'SPACE') {
5976 this._output.space_before_token = true;
5977 }
5978 if (current_token.previous && (current_token.previous.type === TOKEN$2.WORD || current_token.previous.type === TOKEN$2.RESERVED)) {
5979 this._output.space_before_token = true;
5980 }
5981 this.print_token(current_token);
5982 this._flags.last_word = current_token.text;
5983
5984 if (current_token.type === TOKEN$2.RESERVED) {
5985 if (current_token.text === 'do') {
5986 this._flags.do_block = true;
5987 } else if (current_token.text === 'if') {
5988 this._flags.if_block = true;
5989 } else if (current_token.text === 'import') {
5990 this._flags.import_block = true;
5991 } else if (this._flags.import_block && reserved_word(current_token, 'from')) {
5992 this._flags.import_block = false;
5993 }
5994 }
5995 };
5996
5997 Beautifier.prototype.handle_semicolon = function(current_token) {
5998 if (this.start_of_statement(current_token)) {
5999 // The conditional starts the statement if appropriate.
6000 // Semicolon can be the start (and end) of a statement
6001 this._output.space_before_token = false;
6002 } else {
6003 this.handle_whitespace_and_comments(current_token);
6004 }
6005
6006 var next_token = this._tokens.peek();
6007 while (this._flags.mode === MODE.Statement &&
6008 !(this._flags.if_block && reserved_word(next_token, 'else')) &&
6009 !this._flags.do_block) {
6010 this.restore_mode();
6011 }
6012
6013 // hacky but effective for the moment
6014 if (this._flags.import_block) {
6015 this._flags.import_block = false;
6016 }
6017 this.print_token(current_token);
6018 };
6019
6020 Beautifier.prototype.handle_string = function(current_token) {
6021 if (this.start_of_statement(current_token)) {
6022 // The conditional starts the statement if appropriate.
6023 // One difference - strings want at least a space before
6024 this._output.space_before_token = true;
6025 } else {
6026 this.handle_whitespace_and_comments(current_token);
6027 if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD || this._flags.inline_frame) {
6028 this._output.space_before_token = true;
6029 } else if (this._flags.last_token.type === TOKEN$2.COMMA || this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.EQUALS || this._flags.last_token.type === TOKEN$2.OPERATOR) {
6030 if (!this.start_of_object_property()) {
6031 this.allow_wrap_or_preserved_newline(current_token);
6032 }
6033 } else {
6034 this.print_newline();
6035 }
6036 }
6037 this.print_token(current_token);
6038 };
6039
6040 Beautifier.prototype.handle_equals = function(current_token) {
6041 if (this.start_of_statement(current_token)) ; else {
6042 this.handle_whitespace_and_comments(current_token);
6043 }
6044
6045 if (this._flags.declaration_statement) {
6046 // just got an '=' in a var-line, different formatting/line-breaking, etc will now be done
6047 this._flags.declaration_assignment = true;
6048 }
6049 this._output.space_before_token = true;
6050 this.print_token(current_token);
6051 this._output.space_before_token = true;
6052 };
6053
6054 Beautifier.prototype.handle_comma = function(current_token) {
6055 this.handle_whitespace_and_comments(current_token, true);
6056
6057 this.print_token(current_token);
6058 this._output.space_before_token = true;
6059 if (this._flags.declaration_statement) {
6060 if (is_expression(this._flags.parent.mode)) {
6061 // do not break on comma, for(var a = 1, b = 2)
6062 this._flags.declaration_assignment = false;
6063 }
6064
6065 if (this._flags.declaration_assignment) {
6066 this._flags.declaration_assignment = false;
6067 this.print_newline(false, true);
6068 } else if (this._options.comma_first) {
6069 // for comma-first, we want to allow a newline before the comma
6070 // to turn into a newline after the comma, which we will fixup later
6071 this.allow_wrap_or_preserved_newline(current_token);
6072 }
6073 } else if (this._flags.mode === MODE.ObjectLiteral ||
6074 (this._flags.mode === MODE.Statement && this._flags.parent.mode === MODE.ObjectLiteral)) {
6075 if (this._flags.mode === MODE.Statement) {
6076 this.restore_mode();
6077 }
6078
6079 if (!this._flags.inline_frame) {
6080 this.print_newline();
6081 }
6082 } else if (this._options.comma_first) {
6083 // EXPR or DO_BLOCK
6084 // for comma-first, we want to allow a newline before the comma
6085 // to turn into a newline after the comma, which we will fixup later
6086 this.allow_wrap_or_preserved_newline(current_token);
6087 }
6088 };
6089
6090 Beautifier.prototype.handle_operator = function(current_token) {
6091 var isGeneratorAsterisk = current_token.text === '*' &&
6092 (reserved_array(this._flags.last_token, ['function', 'yield']) ||
6093 (in_array$1(this._flags.last_token.type, [TOKEN$2.START_BLOCK, TOKEN$2.COMMA, TOKEN$2.END_BLOCK, TOKEN$2.SEMICOLON]))
6094 );
6095 var isUnary = in_array$1(current_token.text, ['-', '+']) && (
6096 in_array$1(this._flags.last_token.type, [TOKEN$2.START_BLOCK, TOKEN$2.START_EXPR, TOKEN$2.EQUALS, TOKEN$2.OPERATOR]) ||
6097 in_array$1(this._flags.last_token.text, line_starters$1) ||
6098 this._flags.last_token.text === ','
6099 );
6100
6101 if (this.start_of_statement(current_token)) ; else {
6102 var preserve_statement_flags = !isGeneratorAsterisk;
6103 this.handle_whitespace_and_comments(current_token, preserve_statement_flags);
6104 }
6105
6106 if (reserved_array(this._flags.last_token, special_words)) {
6107 // "return" had a special handling in TK_WORD. Now we need to return the favor
6108 this._output.space_before_token = true;
6109 this.print_token(current_token);
6110 return;
6111 }
6112
6113 // hack for actionscript's import .*;
6114 if (current_token.text === '*' && this._flags.last_token.type === TOKEN$2.DOT) {
6115 this.print_token(current_token);
6116 return;
6117 }
6118
6119 if (current_token.text === '::') {
6120 // no spaces around exotic namespacing syntax operator
6121 this.print_token(current_token);
6122 return;
6123 }
6124
6125 // Allow line wrapping between operators when operator_position is
6126 // set to before or preserve
6127 if (this._flags.last_token.type === TOKEN$2.OPERATOR && in_array$1(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)) {
6128 this.allow_wrap_or_preserved_newline(current_token);
6129 }
6130
6131 if (current_token.text === ':' && this._flags.in_case) {
6132 this.print_token(current_token);
6133
6134 this._flags.in_case = false;
6135 this._flags.case_body = true;
6136 if (this._tokens.peek().type !== TOKEN$2.START_BLOCK) {
6137 this.indent();
6138 this.print_newline();
6139 } else {
6140 this._output.space_before_token = true;
6141 }
6142 return;
6143 }
6144
6145 var space_before = true;
6146 var space_after = true;
6147 var in_ternary = false;
6148 if (current_token.text === ':') {
6149 if (this._flags.ternary_depth === 0) {
6150 // Colon is invalid javascript outside of ternary and object, but do our best to guess what was meant.
6151 space_before = false;
6152 } else {
6153 this._flags.ternary_depth -= 1;
6154 in_ternary = true;
6155 }
6156 } else if (current_token.text === '?') {
6157 this._flags.ternary_depth += 1;
6158 }
6159
6160 // let's handle the operator_position option prior to any conflicting logic
6161 if (!isUnary && !isGeneratorAsterisk && this._options.preserve_newlines && in_array$1(current_token.text, positionable_operators$1)) {
6162 var isColon = current_token.text === ':';
6163 var isTernaryColon = (isColon && in_ternary);
6164 var isOtherColon = (isColon && !in_ternary);
6165
6166 switch (this._options.operator_position) {
6167 case OPERATOR_POSITION.before_newline:
6168 // if the current token is : and it's not a ternary statement then we set space_before to false
6169 this._output.space_before_token = !isOtherColon;
6170
6171 this.print_token(current_token);
6172
6173 if (!isColon || isTernaryColon) {
6174 this.allow_wrap_or_preserved_newline(current_token);
6175 }
6176
6177 this._output.space_before_token = true;
6178 return;
6179
6180 case OPERATOR_POSITION.after_newline:
6181 // if the current token is anything but colon, or (via deduction) it's a colon and in a ternary statement,
6182 // then print a newline.
6183
6184 this._output.space_before_token = true;
6185
6186 if (!isColon || isTernaryColon) {
6187 if (this._tokens.peek().newlines) {
6188 this.print_newline(false, true);
6189 } else {
6190 this.allow_wrap_or_preserved_newline(current_token);
6191 }
6192 } else {
6193 this._output.space_before_token = false;
6194 }
6195
6196 this.print_token(current_token);
6197
6198 this._output.space_before_token = true;
6199 return;
6200
6201 case OPERATOR_POSITION.preserve_newline:
6202 if (!isOtherColon) {
6203 this.allow_wrap_or_preserved_newline(current_token);
6204 }
6205
6206 // if we just added a newline, or the current token is : and it's not a ternary statement,
6207 // then we set space_before to false
6208 space_before = !(this._output.just_added_newline() || isOtherColon);
6209
6210 this._output.space_before_token = space_before;
6211 this.print_token(current_token);
6212 this._output.space_before_token = true;
6213 return;
6214 }
6215 }
6216
6217 if (isGeneratorAsterisk) {
6218 this.allow_wrap_or_preserved_newline(current_token);
6219 space_before = false;
6220 var next_token = this._tokens.peek();
6221 space_after = next_token && in_array$1(next_token.type, [TOKEN$2.WORD, TOKEN$2.RESERVED]);
6222 } else if (current_token.text === '...') {
6223 this.allow_wrap_or_preserved_newline(current_token);
6224 space_before = this._flags.last_token.type === TOKEN$2.START_BLOCK;
6225 space_after = false;
6226 } else if (in_array$1(current_token.text, ['--', '++', '!', '~']) || isUnary) {
6227 // unary operators (and binary +/- pretending to be unary) special cases
6228 if (this._flags.last_token.type === TOKEN$2.COMMA || this._flags.last_token.type === TOKEN$2.START_EXPR) {
6229 this.allow_wrap_or_preserved_newline(current_token);
6230 }
6231
6232 space_before = false;
6233 space_after = false;
6234
6235 // http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1
6236 // if there is a newline between -- or ++ and anything else we should preserve it.
6237 if (current_token.newlines && (current_token.text === '--' || current_token.text === '++')) {
6238 this.print_newline(false, true);
6239 }
6240
6241 if (this._flags.last_token.text === ';' && is_expression(this._flags.mode)) {
6242 // for (;; ++i)
6243 // ^^^
6244 space_before = true;
6245 }
6246
6247 if (this._flags.last_token.type === TOKEN$2.RESERVED) {
6248 space_before = true;
6249 } else if (this._flags.last_token.type === TOKEN$2.END_EXPR) {
6250 space_before = !(this._flags.last_token.text === ']' && (current_token.text === '--' || current_token.text === '++'));
6251 } else if (this._flags.last_token.type === TOKEN$2.OPERATOR) {
6252 // a++ + ++b;
6253 // a - -b
6254 space_before = in_array$1(current_token.text, ['--', '-', '++', '+']) && in_array$1(this._flags.last_token.text, ['--', '-', '++', '+']);
6255 // + and - are not unary when preceeded by -- or ++ operator
6256 // a-- + b
6257 // a * +b
6258 // a - -b
6259 if (in_array$1(current_token.text, ['+', '-']) && in_array$1(this._flags.last_token.text, ['--', '++'])) {
6260 space_after = true;
6261 }
6262 }
6263
6264
6265 if (((this._flags.mode === MODE.BlockStatement && !this._flags.inline_frame) || this._flags.mode === MODE.Statement) &&
6266 (this._flags.last_token.text === '{' || this._flags.last_token.text === ';')) {
6267 // { foo; --i }
6268 // foo(); --bar;
6269 this.print_newline();
6270 }
6271 }
6272
6273 this._output.space_before_token = this._output.space_before_token || space_before;
6274 this.print_token(current_token);
6275 this._output.space_before_token = space_after;
6276 };
6277
6278 Beautifier.prototype.handle_block_comment = function(current_token, preserve_statement_flags) {
6279 if (this._output.raw) {
6280 this._output.add_raw_token(current_token);
6281 if (current_token.directives && current_token.directives.preserve === 'end') {
6282 // If we're testing the raw output behavior, do not allow a directive to turn it off.
6283 this._output.raw = this._options.test_output_raw;
6284 }
6285 return;
6286 }
6287
6288 if (current_token.directives) {
6289 this.print_newline(false, preserve_statement_flags);
6290 this.print_token(current_token);
6291 if (current_token.directives.preserve === 'start') {
6292 this._output.raw = true;
6293 }
6294 this.print_newline(false, true);
6295 return;
6296 }
6297
6298 // inline block
6299 if (!acorn.newline.test(current_token.text) && !current_token.newlines) {
6300 this._output.space_before_token = true;
6301 this.print_token(current_token);
6302 this._output.space_before_token = true;
6303 return;
6304 } else {
6305 this.print_block_commment(current_token, preserve_statement_flags);
6306 }
6307 };
6308
6309 Beautifier.prototype.print_block_commment = function(current_token, preserve_statement_flags) {
6310 var lines = split_linebreaks(current_token.text);
6311 var j; // iterator for this case
6312 var javadoc = false;
6313 var starless = false;
6314 var lastIndent = current_token.whitespace_before;
6315 var lastIndentLength = lastIndent.length;
6316
6317 // block comment starts with a new line
6318 this.print_newline(false, preserve_statement_flags);
6319
6320 // first line always indented
6321 this.print_token_line_indentation(current_token);
6322 this._output.add_token(lines[0]);
6323 this.print_newline(false, preserve_statement_flags);
6324
6325
6326 if (lines.length > 1) {
6327 lines = lines.slice(1);
6328 javadoc = all_lines_start_with(lines, '*');
6329 starless = each_line_matches_indent(lines, lastIndent);
6330
6331 if (javadoc) {
6332 this._flags.alignment = 1;
6333 }
6334
6335 for (j = 0; j < lines.length; j++) {
6336 if (javadoc) {
6337 // javadoc: reformat and re-indent
6338 this.print_token_line_indentation(current_token);
6339 this._output.add_token(ltrim(lines[j]));
6340 } else if (starless && lines[j]) {
6341 // starless: re-indent non-empty content, avoiding trim
6342 this.print_token_line_indentation(current_token);
6343 this._output.add_token(lines[j].substring(lastIndentLength));
6344 } else {
6345 // normal comments output raw
6346 this._output.current_line.set_indent(-1);
6347 this._output.add_token(lines[j]);
6348 }
6349
6350 // for comments on their own line or more than one line, make sure there's a new line after
6351 this.print_newline(false, preserve_statement_flags);
6352 }
6353
6354 this._flags.alignment = 0;
6355 }
6356 };
6357
6358
6359 Beautifier.prototype.handle_comment = function(current_token, preserve_statement_flags) {
6360 if (current_token.newlines) {
6361 this.print_newline(false, preserve_statement_flags);
6362 } else {
6363 this._output.trim(true);
6364 }
6365
6366 this._output.space_before_token = true;
6367 this.print_token(current_token);
6368 this.print_newline(false, preserve_statement_flags);
6369 };
6370
6371 Beautifier.prototype.handle_dot = function(current_token) {
6372 if (this.start_of_statement(current_token)) ; else {
6373 this.handle_whitespace_and_comments(current_token, true);
6374 }
6375
6376 if (reserved_array(this._flags.last_token, special_words)) {
6377 this._output.space_before_token = false;
6378 } else {
6379 // allow preserved newlines before dots in general
6380 // force newlines on dots after close paren when break_chained - for bar().baz()
6381 this.allow_wrap_or_preserved_newline(current_token,
6382 this._flags.last_token.text === ')' && this._options.break_chained_methods);
6383 }
6384
6385 // Only unindent chained method dot if this dot starts a new line.
6386 // Otherwise the automatic extra indentation removal will handle the over indent
6387 if (this._options.unindent_chained_methods && this._output.just_added_newline()) {
6388 this.deindent();
6389 }
6390
6391 this.print_token(current_token);
6392 };
6393
6394 Beautifier.prototype.handle_unknown = function(current_token, preserve_statement_flags) {
6395 this.print_token(current_token);
6396
6397 if (current_token.text[current_token.text.length - 1] === '\n') {
6398 this.print_newline(false, preserve_statement_flags);
6399 }
6400 };
6401
6402 Beautifier.prototype.handle_eof = function(current_token) {
6403 // Unwind any open statements
6404 while (this._flags.mode === MODE.Statement) {
6405 this.restore_mode();
6406 }
6407 this.handle_whitespace_and_comments(current_token);
6408 };
6409
6410 var Beautifier_1 = Beautifier;
6411
6412 var beautifier = {
6413 Beautifier: Beautifier_1
6414 };
6415
6416 var Beautifier$1 = beautifier.Beautifier,
6417 Options$3 = options$1.Options;
6418
6419 function js_beautify(js_source_text, options) {
6420 var beautifier = new Beautifier$1(js_source_text, options);
6421 return beautifier.beautify();
6422 }
6423
6424 var javascript = js_beautify;
6425 var defaultOptions = function() {
6426 return new Options$3();
6427 };
6428 javascript.defaultOptions = defaultOptions;
6429
6430 var BaseOptions$1 = options.Options;
6431
6432 function Options$4(options) {
6433 BaseOptions$1.call(this, options, 'css');
6434
6435 this.selector_separator_newline = this._get_boolean('selector_separator_newline', true);
6436 this.newline_between_rules = this._get_boolean('newline_between_rules', true);
6437 var space_around_selector_separator = this._get_boolean('space_around_selector_separator');
6438 this.space_around_combinator = this._get_boolean('space_around_combinator') || space_around_selector_separator;
6439
6440 }
6441 Options$4.prototype = new BaseOptions$1();
6442
6443
6444
6445 var Options_1$2 = Options$4;
6446
6447 var options$2 = {
6448 Options: Options_1$2
6449 };
6450
6451 var Options$5 = options$2.Options;
6452 var Output$2 = output.Output;
6453 var InputScanner$3 = inputscanner.InputScanner;
6454 var Directives$2 = directives.Directives;
6455
6456 var directives_core$1 = new Directives$2(/\/\*/, /\*\//);
6457
6458 var lineBreak = /\r\n|[\r\n]/;
6459 var allLineBreaks = /\r\n|[\r\n]/g;
6460
6461 // tokenizer
6462 var whitespaceChar = /\s/;
6463 var whitespacePattern = /(?:\s|\n)+/g;
6464 var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
6465 var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
6466
6467 function Beautifier$2(source_text, options) {
6468 this._source_text = source_text || '';
6469 // Allow the setting of language/file-type specific options
6470 // with inheritance of overall settings
6471 this._options = new Options$5(options);
6472 this._ch = null;
6473 this._input = null;
6474
6475 // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
6476 this.NESTED_AT_RULE = {
6477 "@page": true,
6478 "@font-face": true,
6479 "@keyframes": true,
6480 // also in CONDITIONAL_GROUP_RULE below
6481 "@media": true,
6482 "@supports": true,
6483 "@document": true
6484 };
6485 this.CONDITIONAL_GROUP_RULE = {
6486 "@media": true,
6487 "@supports": true,
6488 "@document": true
6489 };
6490
6491 }
6492
6493 Beautifier$2.prototype.eatString = function(endChars) {
6494 var result = '';
6495 this._ch = this._input.next();
6496 while (this._ch) {
6497 result += this._ch;
6498 if (this._ch === "\\") {
6499 result += this._input.next();
6500 } else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
6501 break;
6502 }
6503 this._ch = this._input.next();
6504 }
6505 return result;
6506 };
6507
6508 // Skips any white space in the source text from the current position.
6509 // When allowAtLeastOneNewLine is true, will output new lines for each
6510 // newline character found; if the user has preserve_newlines off, only
6511 // the first newline will be output
6512 Beautifier$2.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
6513 var result = whitespaceChar.test(this._input.peek());
6514 var isFirstNewLine = true;
6515
6516 while (whitespaceChar.test(this._input.peek())) {
6517 this._ch = this._input.next();
6518 if (allowAtLeastOneNewLine && this._ch === '\n') {
6519 if (this._options.preserve_newlines || isFirstNewLine) {
6520 isFirstNewLine = false;
6521 this._output.add_new_line(true);
6522 }
6523 }
6524 }
6525 return result;
6526 };
6527
6528 // Nested pseudo-class if we are insideRule
6529 // and the next special character found opens
6530 // a new block
6531 Beautifier$2.prototype.foundNestedPseudoClass = function() {
6532 var openParen = 0;
6533 var i = 1;
6534 var ch = this._input.peek(i);
6535 while (ch) {
6536 if (ch === "{") {
6537 return true;
6538 } else if (ch === '(') {
6539 // pseudoclasses can contain ()
6540 openParen += 1;
6541 } else if (ch === ')') {
6542 if (openParen === 0) {
6543 return false;
6544 }
6545 openParen -= 1;
6546 } else if (ch === ";" || ch === "}") {
6547 return false;
6548 }
6549 i++;
6550 ch = this._input.peek(i);
6551 }
6552 return false;
6553 };
6554
6555 Beautifier$2.prototype.print_string = function(output_string) {
6556 this._output.set_indent(this._indentLevel);
6557 this._output.non_breaking_space = true;
6558 this._output.add_token(output_string);
6559 };
6560
6561 Beautifier$2.prototype.preserveSingleSpace = function(isAfterSpace) {
6562 if (isAfterSpace) {
6563 this._output.space_before_token = true;
6564 }
6565 };
6566
6567 Beautifier$2.prototype.indent = function() {
6568 this._indentLevel++;
6569 };
6570
6571 Beautifier$2.prototype.outdent = function() {
6572 if (this._indentLevel > 0) {
6573 this._indentLevel--;
6574 }
6575 };
6576
6577 /*_____________________--------------------_____________________*/
6578
6579 Beautifier$2.prototype.beautify = function() {
6580 if (this._options.disabled) {
6581 return this._source_text;
6582 }
6583
6584 var source_text = this._source_text;
6585 var eol = this._options.eol;
6586 if (eol === 'auto') {
6587 eol = '\n';
6588 if (source_text && lineBreak.test(source_text || '')) {
6589 eol = source_text.match(lineBreak)[0];
6590 }
6591 }
6592
6593
6594 // HACK: newline parsing inconsistent. This brute force normalizes the this._input.
6595 source_text = source_text.replace(allLineBreaks, '\n');
6596
6597 // reset
6598 var baseIndentString = source_text.match(/^[\t ]*/)[0];
6599
6600 this._output = new Output$2(this._options, baseIndentString);
6601 this._input = new InputScanner$3(source_text);
6602 this._indentLevel = 0;
6603 this._nestedLevel = 0;
6604
6605 this._ch = null;
6606 var parenLevel = 0;
6607
6608 var insideRule = false;
6609 // This is the value side of a property value pair (blue in the following ex)
6610 // label { content: blue }
6611 var insidePropertyValue = false;
6612 var enteringConditionalGroup = false;
6613 var insideAtExtend = false;
6614 var insideAtImport = false;
6615 var topCharacter = this._ch;
6616 var whitespace;
6617 var isAfterSpace;
6618 var previous_ch;
6619
6620 while (true) {
6621 whitespace = this._input.read(whitespacePattern);
6622 isAfterSpace = whitespace !== '';
6623 previous_ch = topCharacter;
6624 this._ch = this._input.next();
6625 if (this._ch === '\\' && this._input.hasNext()) {
6626 this._ch += this._input.next();
6627 }
6628 topCharacter = this._ch;
6629
6630 if (!this._ch) {
6631 break;
6632 } else if (this._ch === '/' && this._input.peek() === '*') {
6633 // /* css comment */
6634 // Always start block comments on a new line.
6635 // This handles scenarios where a block comment immediately
6636 // follows a property definition on the same line or where
6637 // minified code is being beautified.
6638 this._output.add_new_line();
6639 this._input.back();
6640
6641 var comment = this._input.read(block_comment_pattern);
6642
6643 // Handle ignore directive
6644 var directives = directives_core$1.get_directives(comment);
6645 if (directives && directives.ignore === 'start') {
6646 comment += directives_core$1.readIgnored(this._input);
6647 }
6648
6649 this.print_string(comment);
6650
6651 // Ensures any new lines following the comment are preserved
6652 this.eatWhitespace(true);
6653
6654 // Block comments are followed by a new line so they don't
6655 // share a line with other properties
6656 this._output.add_new_line();
6657 } else if (this._ch === '/' && this._input.peek() === '/') {
6658 // // single line comment
6659 // Preserves the space before a comment
6660 // on the same line as a rule
6661 this._output.space_before_token = true;
6662 this._input.back();
6663 this.print_string(this._input.read(comment_pattern));
6664
6665 // Ensures any new lines following the comment are preserved
6666 this.eatWhitespace(true);
6667 } else if (this._ch === '@') {
6668 this.preserveSingleSpace(isAfterSpace);
6669
6670 // deal with less propery mixins @{...}
6671 if (this._input.peek() === '{') {
6672 this.print_string(this._ch + this.eatString('}'));
6673 } else {
6674 this.print_string(this._ch);
6675
6676 // strip trailing space, if present, for hash property checks
6677 var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
6678
6679 if (variableOrRule.match(/[ :]$/)) {
6680 // we have a variable or pseudo-class, add it and insert one space before continuing
6681 variableOrRule = this.eatString(": ").replace(/\s$/, '');
6682 this.print_string(variableOrRule);
6683 this._output.space_before_token = true;
6684 }
6685
6686 variableOrRule = variableOrRule.replace(/\s$/, '');
6687
6688 if (variableOrRule === 'extend') {
6689 insideAtExtend = true;
6690 } else if (variableOrRule === 'import') {
6691 insideAtImport = true;
6692 }
6693
6694 // might be a nesting at-rule
6695 if (variableOrRule in this.NESTED_AT_RULE) {
6696 this._nestedLevel += 1;
6697 if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
6698 enteringConditionalGroup = true;
6699 }
6700 // might be less variable
6701 } else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
6702 insidePropertyValue = true;
6703 this.indent();
6704 }
6705 }
6706 } else if (this._ch === '#' && this._input.peek() === '{') {
6707 this.preserveSingleSpace(isAfterSpace);
6708 this.print_string(this._ch + this.eatString('}'));
6709 } else if (this._ch === '{') {
6710 if (insidePropertyValue) {
6711 insidePropertyValue = false;
6712 this.outdent();
6713 }
6714 this.indent();
6715 this._output.space_before_token = true;
6716 this.print_string(this._ch);
6717
6718 // when entering conditional groups, only rulesets are allowed
6719 if (enteringConditionalGroup) {
6720 enteringConditionalGroup = false;
6721 insideRule = (this._indentLevel > this._nestedLevel);
6722 } else {
6723 // otherwise, declarations are also allowed
6724 insideRule = (this._indentLevel >= this._nestedLevel);
6725 }
6726 if (this._options.newline_between_rules && insideRule) {
6727 if (this._output.previous_line && this._output.previous_line.item(-1) !== '{') {
6728 this._output.ensure_empty_line_above('/', ',');
6729 }
6730 }
6731 this.eatWhitespace(true);
6732 this._output.add_new_line();
6733 } else if (this._ch === '}') {
6734 this.outdent();
6735 this._output.add_new_line();
6736 if (previous_ch === '{') {
6737 this._output.trim(true);
6738 }
6739 insideAtImport = false;
6740 insideAtExtend = false;
6741 if (insidePropertyValue) {
6742 this.outdent();
6743 insidePropertyValue = false;
6744 }
6745 this.print_string(this._ch);
6746 insideRule = false;
6747 if (this._nestedLevel) {
6748 this._nestedLevel--;
6749 }
6750
6751 this.eatWhitespace(true);
6752 this._output.add_new_line();
6753
6754 if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
6755 if (this._input.peek() !== '}') {
6756 this._output.add_new_line(true);
6757 }
6758 }
6759 } else if (this._ch === ":") {
6760 if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
6761 // 'property: value' delimiter
6762 // which could be in a conditional group query
6763 this.print_string(':');
6764 if (!insidePropertyValue) {
6765 insidePropertyValue = true;
6766 this._output.space_before_token = true;
6767 this.eatWhitespace(true);
6768 this.indent();
6769 }
6770 } else {
6771 // sass/less parent reference don't use a space
6772 // sass nested pseudo-class don't use a space
6773
6774 // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
6775 if (this._input.lookBack(" ")) {
6776 this._output.space_before_token = true;
6777 }
6778 if (this._input.peek() === ":") {
6779 // pseudo-element
6780 this._ch = this._input.next();
6781 this.print_string("::");
6782 } else {
6783 // pseudo-class
6784 this.print_string(':');
6785 }
6786 }
6787 } else if (this._ch === '"' || this._ch === '\'') {
6788 this.preserveSingleSpace(isAfterSpace);
6789 this.print_string(this._ch + this.eatString(this._ch));
6790 this.eatWhitespace(true);
6791 } else if (this._ch === ';') {
6792 if (parenLevel === 0) {
6793 if (insidePropertyValue) {
6794 this.outdent();
6795 insidePropertyValue = false;
6796 }
6797 insideAtExtend = false;
6798 insideAtImport = false;
6799 this.print_string(this._ch);
6800 this.eatWhitespace(true);
6801
6802 // This maintains single line comments on the same
6803 // line. Block comments are also affected, but
6804 // a new line is always output before one inside
6805 // that section
6806 if (this._input.peek() !== '/') {
6807 this._output.add_new_line();
6808 }
6809 } else {
6810 this.print_string(this._ch);
6811 this.eatWhitespace(true);
6812 this._output.space_before_token = true;
6813 }
6814 } else if (this._ch === '(') { // may be a url
6815 if (this._input.lookBack("url")) {
6816 this.print_string(this._ch);
6817 this.eatWhitespace();
6818 parenLevel++;
6819 this.indent();
6820 this._ch = this._input.next();
6821 if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
6822 this._input.back();
6823 } else if (this._ch) {
6824 this.print_string(this._ch + this.eatString(')'));
6825 if (parenLevel) {
6826 parenLevel--;
6827 this.outdent();
6828 }
6829 }
6830 } else {
6831 this.preserveSingleSpace(isAfterSpace);
6832 this.print_string(this._ch);
6833 this.eatWhitespace();
6834 parenLevel++;
6835 this.indent();
6836 }
6837 } else if (this._ch === ')') {
6838 if (parenLevel) {
6839 parenLevel--;
6840 this.outdent();
6841 }
6842 this.print_string(this._ch);
6843 } else if (this._ch === ',') {
6844 this.print_string(this._ch);
6845 this.eatWhitespace(true);
6846 if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport) {
6847 this._output.add_new_line();
6848 } else {
6849 this._output.space_before_token = true;
6850 }
6851 } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel === 0) {
6852 //handle combinator spacing
6853 if (this._options.space_around_combinator) {
6854 this._output.space_before_token = true;
6855 this.print_string(this._ch);
6856 this._output.space_before_token = true;
6857 } else {
6858 this.print_string(this._ch);
6859 this.eatWhitespace();
6860 // squash extra whitespace
6861 if (this._ch && whitespaceChar.test(this._ch)) {
6862 this._ch = '';
6863 }
6864 }
6865 } else if (this._ch === ']') {
6866 this.print_string(this._ch);
6867 } else if (this._ch === '[') {
6868 this.preserveSingleSpace(isAfterSpace);
6869 this.print_string(this._ch);
6870 } else if (this._ch === '=') { // no whitespace before or after
6871 this.eatWhitespace();
6872 this.print_string('=');
6873 if (whitespaceChar.test(this._ch)) {
6874 this._ch = '';
6875 }
6876 } else if (this._ch === '!' && !this._input.lookBack("\\")) { // !important
6877 this.print_string(' ');
6878 this.print_string(this._ch);
6879 } else {
6880 this.preserveSingleSpace(isAfterSpace);
6881 this.print_string(this._ch);
6882 }
6883 }
6884
6885 var sweetCode = this._output.get_code(eol);
6886
6887 return sweetCode;
6888 };
6889
6890 var Beautifier_1$1 = Beautifier$2;
6891
6892 var beautifier$1 = {
6893 Beautifier: Beautifier_1$1
6894 };
6895
6896 var Beautifier$3 = beautifier$1.Beautifier,
6897 Options$6 = options$2.Options;
6898
6899 function css_beautify(source_text, options) {
6900 var beautifier = new Beautifier$3(source_text, options);
6901 return beautifier.beautify();
6902 }
6903
6904 var css = css_beautify;
6905 var defaultOptions$1 = function() {
6906 return new Options$6();
6907 };
6908 css.defaultOptions = defaultOptions$1;
6909
6910 var BaseOptions$2 = options.Options;
6911
6912 function Options$7(options) {
6913 BaseOptions$2.call(this, options, 'html');
6914 if (this.templating.length === 1 && this.templating[0] === 'auto') {
6915 this.templating = ['django', 'erb', 'handlebars', 'php'];
6916 }
6917
6918 this.indent_inner_html = this._get_boolean('indent_inner_html');
6919 this.indent_body_inner_html = this._get_boolean('indent_body_inner_html', true);
6920 this.indent_head_inner_html = this._get_boolean('indent_head_inner_html', true);
6921
6922 this.indent_handlebars = this._get_boolean('indent_handlebars', true);
6923 this.wrap_attributes = this._get_selection('wrap_attributes',
6924 ['auto', 'force', 'force-aligned', 'force-expand-multiline', 'aligned-multiple', 'preserve', 'preserve-aligned']);
6925 this.wrap_attributes_indent_size = this._get_number('wrap_attributes_indent_size', this.indent_size);
6926 this.extra_liners = this._get_array('extra_liners', ['head', 'body', '/html']);
6927
6928 // Block vs inline elements
6929 // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
6930 // https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
6931 // https://www.w3.org/TR/html5/dom.html#phrasing-content
6932 this.inline = this._get_array('inline', [
6933 'a', 'abbr', 'area', 'audio', 'b', 'bdi', 'bdo', 'br', 'button', 'canvas', 'cite',
6934 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img',
6935 'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark', 'math', 'meter', 'noscript',
6936 'object', 'output', 'progress', 'q', 'ruby', 's', 'samp', /* 'script', */ 'select', 'small',
6937 'span', 'strong', 'sub', 'sup', 'svg', 'template', 'textarea', 'time', 'u', 'var',
6938 'video', 'wbr', 'text',
6939 // obsolete inline tags
6940 'acronym', 'big', 'strike', 'tt'
6941 ]);
6942 this.void_elements = this._get_array('void_elements', [
6943 // HTLM void elements - aka self-closing tags - aka singletons
6944 // https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
6945 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
6946 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr',
6947 // NOTE: Optional tags are too complex for a simple list
6948 // they are hard coded in _do_optional_end_element
6949
6950 // Doctype and xml elements
6951 '!doctype', '?xml',
6952
6953 // obsolete tags
6954 // basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
6955 // isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
6956 'basefont', 'isindex'
6957 ]);
6958 this.unformatted = this._get_array('unformatted', []);
6959 this.content_unformatted = this._get_array('content_unformatted', [
6960 'pre', 'textarea'
6961 ]);
6962 this.unformatted_content_delimiter = this._get_characters('unformatted_content_delimiter');
6963 this.indent_scripts = this._get_selection('indent_scripts', ['normal', 'keep', 'separate']);
6964
6965 }
6966 Options$7.prototype = new BaseOptions$2();
6967
6968
6969
6970 var Options_1$3 = Options$7;
6971
6972 var options$3 = {
6973 Options: Options_1$3
6974 };
6975
6976 var BaseTokenizer$1 = tokenizer.Tokenizer;
6977 var BASETOKEN$1 = tokenizer.TOKEN;
6978 var Directives$3 = directives.Directives;
6979 var TemplatablePattern$2 = templatablepattern.TemplatablePattern;
6980 var Pattern$4 = pattern.Pattern;
6981
6982 var TOKEN$3 = {
6983 TAG_OPEN: 'TK_TAG_OPEN',
6984 TAG_CLOSE: 'TK_TAG_CLOSE',
6985 ATTRIBUTE: 'TK_ATTRIBUTE',
6986 EQUALS: 'TK_EQUALS',
6987 VALUE: 'TK_VALUE',
6988 COMMENT: 'TK_COMMENT',
6989 TEXT: 'TK_TEXT',
6990 UNKNOWN: 'TK_UNKNOWN',
6991 START: BASETOKEN$1.START,
6992 RAW: BASETOKEN$1.RAW,
6993 EOF: BASETOKEN$1.EOF
6994 };
6995
6996 var directives_core$2 = new Directives$3(/<\!--/, /-->/);
6997
6998 var Tokenizer$3 = function(input_string, options) {
6999 BaseTokenizer$1.call(this, input_string, options);
7000 this._current_tag_name = '';
7001
7002 // Words end at whitespace or when a tag starts
7003 // if we are indenting handlebars, they are considered tags
7004 var templatable_reader = new TemplatablePattern$2(this._input).read_options(this._options);
7005 var pattern_reader = new Pattern$4(this._input);
7006
7007 this.__patterns = {
7008 word: templatable_reader.until(/[\n\r\t <]/),
7009 single_quote: templatable_reader.until_after(/'/),
7010 double_quote: templatable_reader.until_after(/"/),
7011 attribute: templatable_reader.until(/[\n\r\t =\/>]/),
7012 element_name: templatable_reader.until(/[\n\r\t >\/]/),
7013
7014 handlebars_comment: pattern_reader.starting_with(/{{!--/).until_after(/--}}/),
7015 handlebars: pattern_reader.starting_with(/{{/).until_after(/}}/),
7016 handlebars_open: pattern_reader.until(/[\n\r\t }]/),
7017 handlebars_raw_close: pattern_reader.until(/}}/),
7018 comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
7019 cdata: pattern_reader.starting_with(/<!\[cdata\[/).until_after(/]]>/),
7020 // https://en.wikipedia.org/wiki/Conditional_comment
7021 conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
7022 processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
7023 };
7024
7025 if (this._options.indent_handlebars) {
7026 this.__patterns.word = this.__patterns.word.exclude('handlebars');
7027 }
7028
7029 this._unformatted_content_delimiter = null;
7030
7031 if (this._options.unformatted_content_delimiter) {
7032 var literal_regexp = this._input.get_literal_regexp(this._options.unformatted_content_delimiter);
7033 this.__patterns.unformatted_content_delimiter =
7034 pattern_reader.matching(literal_regexp)
7035 .until_after(literal_regexp);
7036 }
7037 };
7038 Tokenizer$3.prototype = new BaseTokenizer$1();
7039
7040 Tokenizer$3.prototype._is_comment = function(current_token) { // jshint unused:false
7041 return false; //current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.UNKNOWN;
7042 };
7043
7044 Tokenizer$3.prototype._is_opening = function(current_token) {
7045 return current_token.type === TOKEN$3.TAG_OPEN;
7046 };
7047
7048 Tokenizer$3.prototype._is_closing = function(current_token, open_token) {
7049 return current_token.type === TOKEN$3.TAG_CLOSE &&
7050 (open_token && (
7051 ((current_token.text === '>' || current_token.text === '/>') && open_token.text[0] === '<') ||
7052 (current_token.text === '}}' && open_token.text[0] === '{' && open_token.text[1] === '{')));
7053 };
7054
7055 Tokenizer$3.prototype._reset = function() {
7056 this._current_tag_name = '';
7057 };
7058
7059 Tokenizer$3.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
7060 var token = null;
7061 this._readWhitespace();
7062 var c = this._input.peek();
7063
7064 if (c === null) {
7065 return this._create_token(TOKEN$3.EOF, '');
7066 }
7067
7068 token = token || this._read_open_handlebars(c, open_token);
7069 token = token || this._read_attribute(c, previous_token, open_token);
7070 token = token || this._read_raw_content(c, previous_token, open_token);
7071 token = token || this._read_close(c, open_token);
7072 token = token || this._read_content_word(c);
7073 token = token || this._read_comment(c);
7074 token = token || this._read_open(c, open_token);
7075 token = token || this._create_token(TOKEN$3.UNKNOWN, this._input.next());
7076
7077 return token;
7078 };
7079
7080 Tokenizer$3.prototype._read_comment = function(c) { // jshint unused:false
7081 var token = null;
7082 var resulting_string = null;
7083 var directives = null;
7084
7085 if (c === '<') {
7086 var peek1 = this._input.peek(1);
7087 //if we're in a comment, do something special
7088 // We treat all comments as literals, even more than preformatted tags
7089 // we just look for the appropriate close tag
7090 if (c === '<' && (peek1 === '!' || peek1 === '?')) {
7091 resulting_string = this.__patterns.comment.read();
7092
7093 // only process directive on html comments
7094 if (resulting_string) {
7095 directives = directives_core$2.get_directives(resulting_string);
7096 if (directives && directives.ignore === 'start') {
7097 resulting_string += directives_core$2.readIgnored(this._input);
7098 }
7099 } else {
7100 resulting_string = this.__patterns.cdata.read();
7101 resulting_string = resulting_string || this.__patterns.conditional_comment.read();
7102 resulting_string = resulting_string || this.__patterns.processing.read();
7103 }
7104 }
7105
7106 if (resulting_string) {
7107 token = this._create_token(TOKEN$3.COMMENT, resulting_string);
7108 token.directives = directives;
7109 }
7110 }
7111
7112 return token;
7113 };
7114
7115 Tokenizer$3.prototype._read_open = function(c, open_token) {
7116 var resulting_string = null;
7117 var token = null;
7118 if (!open_token) {
7119 if (c === '<') {
7120
7121 resulting_string = this._input.next();
7122 if (this._input.peek() === '/') {
7123 resulting_string += this._input.next();
7124 }
7125 resulting_string += this.__patterns.element_name.read();
7126 token = this._create_token(TOKEN$3.TAG_OPEN, resulting_string);
7127 }
7128 }
7129 return token;
7130 };
7131
7132 Tokenizer$3.prototype._read_open_handlebars = function(c, open_token) {
7133 var resulting_string = null;
7134 var token = null;
7135 if (!open_token) {
7136 if (this._options.indent_handlebars && c === '{' && this._input.peek(1) === '{') {
7137 if (this._input.peek(2) === '!') {
7138 resulting_string = this.__patterns.handlebars_comment.read();
7139 resulting_string = resulting_string || this.__patterns.handlebars.read();
7140 token = this._create_token(TOKEN$3.COMMENT, resulting_string);
7141 } else {
7142 resulting_string = this.__patterns.handlebars_open.read();
7143 token = this._create_token(TOKEN$3.TAG_OPEN, resulting_string);
7144 }
7145 }
7146 }
7147 return token;
7148 };
7149
7150
7151 Tokenizer$3.prototype._read_close = function(c, open_token) {
7152 var resulting_string = null;
7153 var token = null;
7154 if (open_token) {
7155 if (open_token.text[0] === '<' && (c === '>' || (c === '/' && this._input.peek(1) === '>'))) {
7156 resulting_string = this._input.next();
7157 if (c === '/') { // for close tag "/>"
7158 resulting_string += this._input.next();
7159 }
7160 token = this._create_token(TOKEN$3.TAG_CLOSE, resulting_string);
7161 } else if (open_token.text[0] === '{' && c === '}' && this._input.peek(1) === '}') {
7162 this._input.next();
7163 this._input.next();
7164 token = this._create_token(TOKEN$3.TAG_CLOSE, '}}');
7165 }
7166 }
7167
7168 return token;
7169 };
7170
7171 Tokenizer$3.prototype._read_attribute = function(c, previous_token, open_token) {
7172 var token = null;
7173 var resulting_string = '';
7174 if (open_token && open_token.text[0] === '<') {
7175
7176 if (c === '=') {
7177 token = this._create_token(TOKEN$3.EQUALS, this._input.next());
7178 } else if (c === '"' || c === "'") {
7179 var content = this._input.next();
7180 if (c === '"') {
7181 content += this.__patterns.double_quote.read();
7182 } else {
7183 content += this.__patterns.single_quote.read();
7184 }
7185 token = this._create_token(TOKEN$3.VALUE, content);
7186 } else {
7187 resulting_string = this.__patterns.attribute.read();
7188
7189 if (resulting_string) {
7190 if (previous_token.type === TOKEN$3.EQUALS) {
7191 token = this._create_token(TOKEN$3.VALUE, resulting_string);
7192 } else {
7193 token = this._create_token(TOKEN$3.ATTRIBUTE, resulting_string);
7194 }
7195 }
7196 }
7197 }
7198 return token;
7199 };
7200
7201 Tokenizer$3.prototype._is_content_unformatted = function(tag_name) {
7202 // void_elements have no content and so cannot have unformatted content
7203 // script and style tags should always be read as unformatted content
7204 // finally content_unformatted and unformatted element contents are unformatted
7205 return this._options.void_elements.indexOf(tag_name) === -1 &&
7206 (this._options.content_unformatted.indexOf(tag_name) !== -1 ||
7207 this._options.unformatted.indexOf(tag_name) !== -1);
7208 };
7209
7210
7211 Tokenizer$3.prototype._read_raw_content = function(c, previous_token, open_token) { // jshint unused:false
7212 var resulting_string = '';
7213 if (open_token && open_token.text[0] === '{') {
7214 resulting_string = this.__patterns.handlebars_raw_close.read();
7215 } else if (previous_token.type === TOKEN$3.TAG_CLOSE && (previous_token.opened.text[0] === '<')) {
7216 var tag_name = previous_token.opened.text.substr(1).toLowerCase();
7217 if (tag_name === 'script' || tag_name === 'style') {
7218 // Script and style tags are allowed to have comments wrapping their content
7219 // or just have regular content.
7220 var token = this._read_comment(c);
7221 if (token) {
7222 token.type = TOKEN$3.TEXT;
7223 return token;
7224 }
7225 resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
7226 } else if (this._is_content_unformatted(tag_name)) {
7227 resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
7228 }
7229 }
7230
7231 if (resulting_string) {
7232 return this._create_token(TOKEN$3.TEXT, resulting_string);
7233 }
7234
7235 return null;
7236 };
7237
7238 Tokenizer$3.prototype._read_content_word = function(c) {
7239 var resulting_string = '';
7240 if (this._options.unformatted_content_delimiter) {
7241 if (c === this._options.unformatted_content_delimiter[0]) {
7242 resulting_string = this.__patterns.unformatted_content_delimiter.read();
7243 }
7244 }
7245
7246 if (!resulting_string) {
7247 resulting_string = this.__patterns.word.read();
7248 }
7249 if (resulting_string) {
7250 return this._create_token(TOKEN$3.TEXT, resulting_string);
7251 }
7252 };
7253
7254 var Tokenizer_1$2 = Tokenizer$3;
7255 var TOKEN_1$2 = TOKEN$3;
7256
7257 var tokenizer$2 = {
7258 Tokenizer: Tokenizer_1$2,
7259 TOKEN: TOKEN_1$2
7260 };
7261
7262 var Options$8 = options$3.Options;
7263 var Output$3 = output.Output;
7264 var Tokenizer$4 = tokenizer$2.Tokenizer;
7265 var TOKEN$4 = tokenizer$2.TOKEN;
7266
7267 var lineBreak$1 = /\r\n|[\r\n]/;
7268 var allLineBreaks$1 = /\r\n|[\r\n]/g;
7269
7270 var Printer = function(options, base_indent_string) { //handles input/output and some other printing functions
7271
7272 this.indent_level = 0;
7273 this.alignment_size = 0;
7274 this.max_preserve_newlines = options.max_preserve_newlines;
7275 this.preserve_newlines = options.preserve_newlines;
7276
7277 this._output = new Output$3(options, base_indent_string);
7278
7279 };
7280
7281 Printer.prototype.current_line_has_match = function(pattern) {
7282 return this._output.current_line.has_match(pattern);
7283 };
7284
7285 Printer.prototype.set_space_before_token = function(value, non_breaking) {
7286 this._output.space_before_token = value;
7287 this._output.non_breaking_space = non_breaking;
7288 };
7289
7290 Printer.prototype.set_wrap_point = function() {
7291 this._output.set_indent(this.indent_level, this.alignment_size);
7292 this._output.set_wrap_point();
7293 };
7294
7295
7296 Printer.prototype.add_raw_token = function(token) {
7297 this._output.add_raw_token(token);
7298 };
7299
7300 Printer.prototype.print_preserved_newlines = function(raw_token) {
7301 var newlines = 0;
7302 if (raw_token.type !== TOKEN$4.TEXT && raw_token.previous.type !== TOKEN$4.TEXT) {
7303 newlines = raw_token.newlines ? 1 : 0;
7304 }
7305
7306 if (this.preserve_newlines) {
7307 newlines = raw_token.newlines < this.max_preserve_newlines + 1 ? raw_token.newlines : this.max_preserve_newlines + 1;
7308 }
7309 for (var n = 0; n < newlines; n++) {
7310 this.print_newline(n > 0);
7311 }
7312
7313 return newlines !== 0;
7314 };
7315
7316 Printer.prototype.traverse_whitespace = function(raw_token) {
7317 if (raw_token.whitespace_before || raw_token.newlines) {
7318 if (!this.print_preserved_newlines(raw_token)) {
7319 this._output.space_before_token = true;
7320 }
7321 return true;
7322 }
7323 return false;
7324 };
7325
7326 Printer.prototype.previous_token_wrapped = function() {
7327 return this._output.previous_token_wrapped;
7328 };
7329
7330 Printer.prototype.print_newline = function(force) {
7331 this._output.add_new_line(force);
7332 };
7333
7334 Printer.prototype.print_token = function(token) {
7335 if (token.text) {
7336 this._output.set_indent(this.indent_level, this.alignment_size);
7337 this._output.add_token(token.text);
7338 }
7339 };
7340
7341 Printer.prototype.indent = function() {
7342 this.indent_level++;
7343 };
7344
7345 Printer.prototype.get_full_indent = function(level) {
7346 level = this.indent_level + (level || 0);
7347 if (level < 1) {
7348 return '';
7349 }
7350
7351 return this._output.get_indent_string(level);
7352 };
7353
7354 var get_type_attribute = function(start_token) {
7355 var result = null;
7356 var raw_token = start_token.next;
7357
7358 // Search attributes for a type attribute
7359 while (raw_token.type !== TOKEN$4.EOF && start_token.closed !== raw_token) {
7360 if (raw_token.type === TOKEN$4.ATTRIBUTE && raw_token.text === 'type') {
7361 if (raw_token.next && raw_token.next.type === TOKEN$4.EQUALS &&
7362 raw_token.next.next && raw_token.next.next.type === TOKEN$4.VALUE) {
7363 result = raw_token.next.next.text;
7364 }
7365 break;
7366 }
7367 raw_token = raw_token.next;
7368 }
7369
7370 return result;
7371 };
7372
7373 var get_custom_beautifier_name = function(tag_check, raw_token) {
7374 var typeAttribute = null;
7375 var result = null;
7376
7377 if (!raw_token.closed) {
7378 return null;
7379 }
7380
7381 if (tag_check === 'script') {
7382 typeAttribute = 'text/javascript';
7383 } else if (tag_check === 'style') {
7384 typeAttribute = 'text/css';
7385 }
7386
7387 typeAttribute = get_type_attribute(raw_token) || typeAttribute;
7388
7389 // For script and style tags that have a type attribute, only enable custom beautifiers for matching values
7390 // For those without a type attribute use default;
7391 if (typeAttribute.search('text/css') > -1) {
7392 result = 'css';
7393 } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect)/) > -1) {
7394 result = 'javascript';
7395 } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
7396 result = 'html';
7397 } else if (typeAttribute.search(/test\/null/) > -1) {
7398 // Test only mime-type for testing the beautifier when null is passed as beautifing function
7399 result = 'null';
7400 }
7401
7402 return result;
7403 };
7404
7405 function in_array$2(what, arr) {
7406 return arr.indexOf(what) !== -1;
7407 }
7408
7409 function TagFrame(parent, parser_token, indent_level) {
7410 this.parent = parent || null;
7411 this.tag = parser_token ? parser_token.tag_name : '';
7412 this.indent_level = indent_level || 0;
7413 this.parser_token = parser_token || null;
7414 }
7415
7416 function TagStack(printer) {
7417 this._printer = printer;
7418 this._current_frame = null;
7419 }
7420
7421 TagStack.prototype.get_parser_token = function() {
7422 return this._current_frame ? this._current_frame.parser_token : null;
7423 };
7424
7425 TagStack.prototype.record_tag = function(parser_token) { //function to record a tag and its parent in this.tags Object
7426 var new_frame = new TagFrame(this._current_frame, parser_token, this._printer.indent_level);
7427 this._current_frame = new_frame;
7428 };
7429
7430 TagStack.prototype._try_pop_frame = function(frame) { //function to retrieve the opening tag to the corresponding closer
7431 var parser_token = null;
7432
7433 if (frame) {
7434 parser_token = frame.parser_token;
7435 this._printer.indent_level = frame.indent_level;
7436 this._current_frame = frame.parent;
7437 }
7438
7439 return parser_token;
7440 };
7441
7442 TagStack.prototype._get_frame = function(tag_list, stop_list) { //function to retrieve the opening tag to the corresponding closer
7443 var frame = this._current_frame;
7444
7445 while (frame) { //till we reach '' (the initial value);
7446 if (tag_list.indexOf(frame.tag) !== -1) { //if this is it use it
7447 break;
7448 } else if (stop_list && stop_list.indexOf(frame.tag) !== -1) {
7449 frame = null;
7450 break;
7451 }
7452 frame = frame.parent;
7453 }
7454
7455 return frame;
7456 };
7457
7458 TagStack.prototype.try_pop = function(tag, stop_list) { //function to retrieve the opening tag to the corresponding closer
7459 var frame = this._get_frame([tag], stop_list);
7460 return this._try_pop_frame(frame);
7461 };
7462
7463 TagStack.prototype.indent_to_tag = function(tag_list) {
7464 var frame = this._get_frame(tag_list);
7465 if (frame) {
7466 this._printer.indent_level = frame.indent_level;
7467 }
7468 };
7469
7470 function Beautifier$4(source_text, options, js_beautify, css_beautify) {
7471 //Wrapper function to invoke all the necessary constructors and deal with the output.
7472 this._source_text = source_text || '';
7473 options = options || {};
7474 this._js_beautify = js_beautify;
7475 this._css_beautify = css_beautify;
7476 this._tag_stack = null;
7477
7478 // Allow the setting of language/file-type specific options
7479 // with inheritance of overall settings
7480 var optionHtml = new Options$8(options, 'html');
7481
7482 this._options = optionHtml;
7483
7484 this._is_wrap_attributes_force = this._options.wrap_attributes.substr(0, 'force'.length) === 'force';
7485 this._is_wrap_attributes_force_expand_multiline = (this._options.wrap_attributes === 'force-expand-multiline');
7486 this._is_wrap_attributes_force_aligned = (this._options.wrap_attributes === 'force-aligned');
7487 this._is_wrap_attributes_aligned_multiple = (this._options.wrap_attributes === 'aligned-multiple');
7488 this._is_wrap_attributes_preserve = this._options.wrap_attributes.substr(0, 'preserve'.length) === 'preserve';
7489 this._is_wrap_attributes_preserve_aligned = (this._options.wrap_attributes === 'preserve-aligned');
7490 }
7491
7492 Beautifier$4.prototype.beautify = function() {
7493
7494 // if disabled, return the input unchanged.
7495 if (this._options.disabled) {
7496 return this._source_text;
7497 }
7498
7499 var source_text = this._source_text;
7500 var eol = this._options.eol;
7501 if (this._options.eol === 'auto') {
7502 eol = '\n';
7503 if (source_text && lineBreak$1.test(source_text)) {
7504 eol = source_text.match(lineBreak$1)[0];
7505 }
7506 }
7507
7508 // HACK: newline parsing inconsistent. This brute force normalizes the input.
7509 source_text = source_text.replace(allLineBreaks$1, '\n');
7510
7511 var baseIndentString = source_text.match(/^[\t ]*/)[0];
7512
7513 var last_token = {
7514 text: '',
7515 type: ''
7516 };
7517
7518 var last_tag_token = new TagOpenParserToken();
7519
7520 var printer = new Printer(this._options, baseIndentString);
7521 var tokens = new Tokenizer$4(source_text, this._options).tokenize();
7522
7523 this._tag_stack = new TagStack(printer);
7524
7525 var parser_token = null;
7526 var raw_token = tokens.next();
7527 while (raw_token.type !== TOKEN$4.EOF) {
7528
7529 if (raw_token.type === TOKEN$4.TAG_OPEN || raw_token.type === TOKEN$4.COMMENT) {
7530 parser_token = this._handle_tag_open(printer, raw_token, last_tag_token, last_token);
7531 last_tag_token = parser_token;
7532 } else if ((raw_token.type === TOKEN$4.ATTRIBUTE || raw_token.type === TOKEN$4.EQUALS || raw_token.type === TOKEN$4.VALUE) ||
7533 (raw_token.type === TOKEN$4.TEXT && !last_tag_token.tag_complete)) {
7534 parser_token = this._handle_inside_tag(printer, raw_token, last_tag_token, tokens);
7535 } else if (raw_token.type === TOKEN$4.TAG_CLOSE) {
7536 parser_token = this._handle_tag_close(printer, raw_token, last_tag_token);
7537 } else if (raw_token.type === TOKEN$4.TEXT) {
7538 parser_token = this._handle_text(printer, raw_token, last_tag_token);
7539 } else {
7540 // This should never happen, but if it does. Print the raw token
7541 printer.add_raw_token(raw_token);
7542 }
7543
7544 last_token = parser_token;
7545
7546 raw_token = tokens.next();
7547 }
7548 var sweet_code = printer._output.get_code(eol);
7549
7550 return sweet_code;
7551 };
7552
7553 Beautifier$4.prototype._handle_tag_close = function(printer, raw_token, last_tag_token) {
7554 var parser_token = {
7555 text: raw_token.text,
7556 type: raw_token.type
7557 };
7558 printer.alignment_size = 0;
7559 last_tag_token.tag_complete = true;
7560
7561 printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
7562 if (last_tag_token.is_unformatted) {
7563 printer.add_raw_token(raw_token);
7564 } else {
7565 if (last_tag_token.tag_start_char === '<') {
7566 printer.set_space_before_token(raw_token.text[0] === '/', true); // space before />, no space before >
7567 if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) {
7568 printer.print_newline(false);
7569 }
7570 }
7571 printer.print_token(raw_token);
7572
7573 }
7574
7575 if (last_tag_token.indent_content &&
7576 !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
7577 printer.indent();
7578
7579 // only indent once per opened tag
7580 last_tag_token.indent_content = false;
7581 }
7582
7583 if (!last_tag_token.is_inline_element &&
7584 !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
7585 printer.set_wrap_point();
7586 }
7587
7588 return parser_token;
7589 };
7590
7591 Beautifier$4.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, tokens) {
7592 var wrapped = last_tag_token.has_wrapped_attrs;
7593 var parser_token = {
7594 text: raw_token.text,
7595 type: raw_token.type
7596 };
7597
7598 printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
7599 if (last_tag_token.is_unformatted) {
7600 printer.add_raw_token(raw_token);
7601 } else if (last_tag_token.tag_start_char === '{' && raw_token.type === TOKEN$4.TEXT) {
7602 // For the insides of handlebars allow newlines or a single space between open and contents
7603 if (printer.print_preserved_newlines(raw_token)) {
7604 raw_token.newlines = 0;
7605 printer.add_raw_token(raw_token);
7606 } else {
7607 printer.print_token(raw_token);
7608 }
7609 } else {
7610 if (raw_token.type === TOKEN$4.ATTRIBUTE) {
7611 printer.set_space_before_token(true);
7612 last_tag_token.attr_count += 1;
7613 } else if (raw_token.type === TOKEN$4.EQUALS) { //no space before =
7614 printer.set_space_before_token(false);
7615 } else if (raw_token.type === TOKEN$4.VALUE && raw_token.previous.type === TOKEN$4.EQUALS) { //no space before value
7616 printer.set_space_before_token(false);
7617 }
7618
7619 if (raw_token.type === TOKEN$4.ATTRIBUTE && last_tag_token.tag_start_char === '<') {
7620 if (this._is_wrap_attributes_preserve || this._is_wrap_attributes_preserve_aligned) {
7621 printer.traverse_whitespace(raw_token);
7622 wrapped = wrapped || raw_token.newlines !== 0;
7623 }
7624
7625
7626 if (this._is_wrap_attributes_force) {
7627 var force_attr_wrap = last_tag_token.attr_count > 1;
7628 if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.attr_count === 1) {
7629 var is_only_attribute = true;
7630 var peek_index = 0;
7631 var peek_token;
7632 do {
7633 peek_token = tokens.peek(peek_index);
7634 if (peek_token.type === TOKEN$4.ATTRIBUTE) {
7635 is_only_attribute = false;
7636 break;
7637 }
7638 peek_index += 1;
7639 } while (peek_index < 4 && peek_token.type !== TOKEN$4.EOF && peek_token.type !== TOKEN$4.TAG_CLOSE);
7640
7641 force_attr_wrap = !is_only_attribute;
7642 }
7643
7644 if (force_attr_wrap) {
7645 printer.print_newline(false);
7646 wrapped = true;
7647 }
7648 }
7649 }
7650 printer.print_token(raw_token);
7651 wrapped = wrapped || printer.previous_token_wrapped();
7652 last_tag_token.has_wrapped_attrs = wrapped;
7653 }
7654 return parser_token;
7655 };
7656
7657 Beautifier$4.prototype._handle_text = function(printer, raw_token, last_tag_token) {
7658 var parser_token = {
7659 text: raw_token.text,
7660 type: 'TK_CONTENT'
7661 };
7662 if (last_tag_token.custom_beautifier_name) { //check if we need to format javascript
7663 this._print_custom_beatifier_text(printer, raw_token, last_tag_token);
7664 } else if (last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) {
7665 printer.add_raw_token(raw_token);
7666 } else {
7667 printer.traverse_whitespace(raw_token);
7668 printer.print_token(raw_token);
7669 }
7670 return parser_token;
7671 };
7672
7673 Beautifier$4.prototype._print_custom_beatifier_text = function(printer, raw_token, last_tag_token) {
7674 var local = this;
7675 if (raw_token.text !== '') {
7676
7677 var text = raw_token.text,
7678 _beautifier,
7679 script_indent_level = 1,
7680 pre = '',
7681 post = '';
7682 if (last_tag_token.custom_beautifier_name === 'javascript' && typeof this._js_beautify === 'function') {
7683 _beautifier = this._js_beautify;
7684 } else if (last_tag_token.custom_beautifier_name === 'css' && typeof this._css_beautify === 'function') {
7685 _beautifier = this._css_beautify;
7686 } else if (last_tag_token.custom_beautifier_name === 'html') {
7687 _beautifier = function(html_source, options) {
7688 var beautifier = new Beautifier$4(html_source, options, local._js_beautify, local._css_beautify);
7689 return beautifier.beautify();
7690 };
7691 }
7692
7693 if (this._options.indent_scripts === "keep") {
7694 script_indent_level = 0;
7695 } else if (this._options.indent_scripts === "separate") {
7696 script_indent_level = -printer.indent_level;
7697 }
7698
7699 var indentation = printer.get_full_indent(script_indent_level);
7700
7701 // if there is at least one empty line at the end of this text, strip it
7702 // we'll be adding one back after the text but before the containing tag.
7703 text = text.replace(/\n[ \t]*$/, '');
7704
7705 // Handle the case where content is wrapped in a comment or cdata.
7706 if (last_tag_token.custom_beautifier_name !== 'html' &&
7707 text[0] === '<' && text.match(/^(<!--|<!\[CDATA\[)/)) {
7708 var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(text);
7709
7710 // if we start to wrap but don't finish, print raw
7711 if (!matched) {
7712 printer.add_raw_token(raw_token);
7713 return;
7714 }
7715
7716 pre = indentation + matched[1] + '\n';
7717 text = matched[4];
7718 if (matched[5]) {
7719 post = indentation + matched[5];
7720 }
7721
7722 // if there is at least one empty line at the end of this text, strip it
7723 // we'll be adding one back after the text but before the containing tag.
7724 text = text.replace(/\n[ \t]*$/, '');
7725
7726 if (matched[2] || matched[3].indexOf('\n') !== -1) {
7727 // if the first line of the non-comment text has spaces
7728 // use that as the basis for indenting in null case.
7729 matched = matched[3].match(/[ \t]+$/);
7730 if (matched) {
7731 raw_token.whitespace_before = matched[0];
7732 }
7733 }
7734 }
7735
7736 if (text) {
7737 if (_beautifier) {
7738
7739 // call the Beautifier if avaliable
7740 var Child_options = function() {
7741 this.eol = '\n';
7742 };
7743 Child_options.prototype = this._options.raw_options;
7744 var child_options = new Child_options();
7745 text = _beautifier(indentation + text, child_options);
7746 } else {
7747 // simply indent the string otherwise
7748 var white = raw_token.whitespace_before;
7749 if (white) {
7750 text = text.replace(new RegExp('\n(' + white + ')?', 'g'), '\n');
7751 }
7752
7753 text = indentation + text.replace(/\n/g, '\n' + indentation);
7754 }
7755 }
7756
7757 if (pre) {
7758 if (!text) {
7759 text = pre + post;
7760 } else {
7761 text = pre + text + '\n' + post;
7762 }
7763 }
7764
7765 printer.print_newline(false);
7766 if (text) {
7767 raw_token.text = text;
7768 raw_token.whitespace_before = '';
7769 raw_token.newlines = 0;
7770 printer.add_raw_token(raw_token);
7771 printer.print_newline(true);
7772 }
7773 }
7774 };
7775
7776 Beautifier$4.prototype._handle_tag_open = function(printer, raw_token, last_tag_token, last_token) {
7777 var parser_token = this._get_tag_open_token(raw_token);
7778
7779 if ((last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) &&
7780 raw_token.type === TOKEN$4.TAG_OPEN && raw_token.text.indexOf('</') === 0) {
7781 // End element tags for unformatted or content_unformatted elements
7782 // are printed raw to keep any newlines inside them exactly the same.
7783 printer.add_raw_token(raw_token);
7784 } else {
7785 printer.traverse_whitespace(raw_token);
7786 this._set_tag_position(printer, raw_token, parser_token, last_tag_token, last_token);
7787 if (!parser_token.is_inline_element) {
7788 printer.set_wrap_point();
7789 }
7790 printer.print_token(raw_token);
7791 }
7792
7793 //indent attributes an auto, forced, aligned or forced-align line-wrap
7794 if (this._is_wrap_attributes_force_aligned || this._is_wrap_attributes_aligned_multiple || this._is_wrap_attributes_preserve_aligned) {
7795 parser_token.alignment_size = raw_token.text.length + 1;
7796 }
7797
7798 if (!parser_token.tag_complete && !parser_token.is_unformatted) {
7799 printer.alignment_size = parser_token.alignment_size;
7800 }
7801
7802 return parser_token;
7803 };
7804
7805 var TagOpenParserToken = function(parent, raw_token) {
7806 this.parent = parent || null;
7807 this.text = '';
7808 this.type = 'TK_TAG_OPEN';
7809 this.tag_name = '';
7810 this.is_inline_element = false;
7811 this.is_unformatted = false;
7812 this.is_content_unformatted = false;
7813 this.is_empty_element = false;
7814 this.is_start_tag = false;
7815 this.is_end_tag = false;
7816 this.indent_content = false;
7817 this.multiline_content = false;
7818 this.custom_beautifier_name = null;
7819 this.start_tag_token = null;
7820 this.attr_count = 0;
7821 this.has_wrapped_attrs = false;
7822 this.alignment_size = 0;
7823 this.tag_complete = false;
7824 this.tag_start_char = '';
7825 this.tag_check = '';
7826
7827 if (!raw_token) {
7828 this.tag_complete = true;
7829 } else {
7830 var tag_check_match;
7831
7832 this.tag_start_char = raw_token.text[0];
7833 this.text = raw_token.text;
7834
7835 if (this.tag_start_char === '<') {
7836 tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
7837 this.tag_check = tag_check_match ? tag_check_match[1] : '';
7838 } else {
7839 tag_check_match = raw_token.text.match(/^{{[#\^]?([^\s}]+)/);
7840 this.tag_check = tag_check_match ? tag_check_match[1] : '';
7841 }
7842 this.tag_check = this.tag_check.toLowerCase();
7843
7844 if (raw_token.type === TOKEN$4.COMMENT) {
7845 this.tag_complete = true;
7846 }
7847
7848 this.is_start_tag = this.tag_check.charAt(0) !== '/';
7849 this.tag_name = !this.is_start_tag ? this.tag_check.substr(1) : this.tag_check;
7850 this.is_end_tag = !this.is_start_tag ||
7851 (raw_token.closed && raw_token.closed.text === '/>');
7852
7853 // handlebars tags that don't start with # or ^ are single_tags, and so also start and end.
7854 this.is_end_tag = this.is_end_tag ||
7855 (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(2)))));
7856 }
7857 };
7858
7859 Beautifier$4.prototype._get_tag_open_token = function(raw_token) { //function to get a full tag and parse its type
7860 var parser_token = new TagOpenParserToken(this._tag_stack.get_parser_token(), raw_token);
7861
7862 parser_token.alignment_size = this._options.wrap_attributes_indent_size;
7863
7864 parser_token.is_end_tag = parser_token.is_end_tag ||
7865 in_array$2(parser_token.tag_check, this._options.void_elements);
7866
7867 parser_token.is_empty_element = parser_token.tag_complete ||
7868 (parser_token.is_start_tag && parser_token.is_end_tag);
7869
7870 parser_token.is_unformatted = !parser_token.tag_complete && in_array$2(parser_token.tag_check, this._options.unformatted);
7871 parser_token.is_content_unformatted = !parser_token.is_empty_element && in_array$2(parser_token.tag_check, this._options.content_unformatted);
7872 parser_token.is_inline_element = in_array$2(parser_token.tag_name, this._options.inline) || parser_token.tag_start_char === '{';
7873
7874 return parser_token;
7875 };
7876
7877 Beautifier$4.prototype._set_tag_position = function(printer, raw_token, parser_token, last_tag_token, last_token) {
7878
7879 if (!parser_token.is_empty_element) {
7880 if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
7881 parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name); //remove it and all ancestors
7882 } else { // it's a start-tag
7883 // check if this tag is starting an element that has optional end element
7884 // and do an ending needed
7885 if (this._do_optional_end_element(parser_token)) {
7886 if (!parser_token.is_inline_element) {
7887 if (parser_token.parent) {
7888 parser_token.parent.multiline_content = true;
7889 }
7890 printer.print_newline(false);
7891 }
7892
7893 }
7894
7895 this._tag_stack.record_tag(parser_token); //push it on the tag stack
7896
7897 if ((parser_token.tag_name === 'script' || parser_token.tag_name === 'style') &&
7898 !(parser_token.is_unformatted || parser_token.is_content_unformatted)) {
7899 parser_token.custom_beautifier_name = get_custom_beautifier_name(parser_token.tag_check, raw_token);
7900 }
7901 }
7902 }
7903
7904 if (in_array$2(parser_token.tag_check, this._options.extra_liners)) { //check if this double needs an extra line
7905 printer.print_newline(false);
7906 if (!printer._output.just_added_blankline()) {
7907 printer.print_newline(true);
7908 }
7909 }
7910
7911 if (parser_token.is_empty_element) { //if this tag name is a single tag type (either in the list or has a closing /)
7912
7913 // if you hit an else case, reset the indent level if you are inside an:
7914 // 'if', 'unless', or 'each' block.
7915 if (parser_token.tag_start_char === '{' && parser_token.tag_check === 'else') {
7916 this._tag_stack.indent_to_tag(['if', 'unless', 'each']);
7917 parser_token.indent_content = true;
7918 // Don't add a newline if opening {{#if}} tag is on the current line
7919 var foundIfOnCurrentLine = printer.current_line_has_match(/{{#if/);
7920 if (!foundIfOnCurrentLine) {
7921 printer.print_newline(false);
7922 }
7923 }
7924
7925 // Don't add a newline before elements that should remain where they are.
7926 if (parser_token.tag_name === '!--' && last_token.type === TOKEN$4.TAG_CLOSE &&
7927 last_tag_token.is_end_tag && parser_token.text.indexOf('\n') === -1) ; else if (!parser_token.is_inline_element && !parser_token.is_unformatted) {
7928 printer.print_newline(false);
7929 }
7930 } else if (parser_token.is_unformatted || parser_token.is_content_unformatted) {
7931 if (!parser_token.is_inline_element && !parser_token.is_unformatted) {
7932 printer.print_newline(false);
7933 }
7934 } else if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
7935 if ((parser_token.start_tag_token && parser_token.start_tag_token.multiline_content) ||
7936 !(parser_token.is_inline_element ||
7937 (last_tag_token.is_inline_element) ||
7938 (last_token.type === TOKEN$4.TAG_CLOSE &&
7939 parser_token.start_tag_token === last_tag_token) ||
7940 (last_token.type === 'TK_CONTENT')
7941 )) {
7942 printer.print_newline(false);
7943 }
7944 } else { // it's a start-tag
7945 parser_token.indent_content = !parser_token.custom_beautifier_name;
7946
7947 if (parser_token.tag_start_char === '<') {
7948 if (parser_token.tag_name === 'html') {
7949 parser_token.indent_content = this._options.indent_inner_html;
7950 } else if (parser_token.tag_name === 'head') {
7951 parser_token.indent_content = this._options.indent_head_inner_html;
7952 } else if (parser_token.tag_name === 'body') {
7953 parser_token.indent_content = this._options.indent_body_inner_html;
7954 }
7955 }
7956
7957 if (!parser_token.is_inline_element && last_token.type !== 'TK_CONTENT') {
7958 if (parser_token.parent) {
7959 parser_token.parent.multiline_content = true;
7960 }
7961 printer.print_newline(false);
7962 }
7963 }
7964 };
7965
7966 //To be used for <p> tag special case:
7967 //var p_closers = ['address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'];
7968
7969 Beautifier$4.prototype._do_optional_end_element = function(parser_token) {
7970 var result = null;
7971 // NOTE: cases of "if there is no more content in the parent element"
7972 // are handled automatically by the beautifier.
7973 // It assumes parent or ancestor close tag closes all children.
7974 // https://www.w3.org/TR/html5/syntax.html#optional-tags
7975 if (parser_token.is_empty_element || !parser_token.is_start_tag || !parser_token.parent) {
7976 return;
7977
7978 } else if (parser_token.tag_name === 'body') {
7979 // A head element’s end tag may be omitted if the head element is not immediately followed by a space character or a comment.
7980 result = result || this._tag_stack.try_pop('head');
7981
7982 //} else if (parser_token.tag_name === 'body') {
7983 // DONE: A body element’s end tag may be omitted if the body element is not immediately followed by a comment.
7984
7985 } else if (parser_token.tag_name === 'li') {
7986 // An li element’s end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element.
7987 result = result || this._tag_stack.try_pop('li', ['ol', 'ul']);
7988
7989 } else if (parser_token.tag_name === 'dd' || parser_token.tag_name === 'dt') {
7990 // A dd element’s end tag may be omitted if the dd element is immediately followed by another dd element or a dt element, or if there is no more content in the parent element.
7991 // A dt element’s end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
7992 result = result || this._tag_stack.try_pop('dt', ['dl']);
7993 result = result || this._tag_stack.try_pop('dd', ['dl']);
7994
7995 //} else if (p_closers.indexOf(parser_token.tag_name) !== -1) {
7996 //TODO: THIS IS A BUG FARM. We are not putting this into 1.8.0 as it is likely to blow up.
7997 //A p element’s end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hr, main, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element.
7998 //result = result || this._tag_stack.try_pop('p', ['body']);
7999
8000 } else if (parser_token.tag_name === 'rp' || parser_token.tag_name === 'rt') {
8001 // An rt element’s end tag may be omitted if the rt element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
8002 // An rp element’s end tag may be omitted if the rp element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
8003 result = result || this._tag_stack.try_pop('rt', ['ruby', 'rtc']);
8004 result = result || this._tag_stack.try_pop('rp', ['ruby', 'rtc']);
8005
8006 } else if (parser_token.tag_name === 'optgroup') {
8007 // An optgroup element’s end tag may be omitted if the optgroup element is immediately followed by another optgroup element, or if there is no more content in the parent element.
8008 // An option element’s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
8009 result = result || this._tag_stack.try_pop('optgroup', ['select']);
8010 //result = result || this._tag_stack.try_pop('option', ['select']);
8011
8012 } else if (parser_token.tag_name === 'option') {
8013 // An option element’s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
8014 result = result || this._tag_stack.try_pop('option', ['select', 'datalist', 'optgroup']);
8015
8016 } else if (parser_token.tag_name === 'colgroup') {
8017 // DONE: A colgroup element’s end tag may be omitted if the colgroup element is not immediately followed by a space character or a comment.
8018 // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8019 result = result || this._tag_stack.try_pop('caption', ['table']);
8020
8021 } else if (parser_token.tag_name === 'thead') {
8022 // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
8023 // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8024 result = result || this._tag_stack.try_pop('caption', ['table']);
8025 result = result || this._tag_stack.try_pop('colgroup', ['table']);
8026
8027 //} else if (parser_token.tag_name === 'caption') {
8028 // DONE: A caption element’s end tag may be omitted if the caption element is not immediately followed by a space character or a comment.
8029
8030 } else if (parser_token.tag_name === 'tbody' || parser_token.tag_name === 'tfoot') {
8031 // A thead element’s end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
8032 // A tbody element’s end tag may be omitted if the tbody element is immediately followed by a tbody or tfoot element, or if there is no more content in the parent element.
8033 // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
8034 // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8035 result = result || this._tag_stack.try_pop('caption', ['table']);
8036 result = result || this._tag_stack.try_pop('colgroup', ['table']);
8037 result = result || this._tag_stack.try_pop('thead', ['table']);
8038 result = result || this._tag_stack.try_pop('tbody', ['table']);
8039
8040 //} else if (parser_token.tag_name === 'tfoot') {
8041 // DONE: A tfoot element’s end tag may be omitted if there is no more content in the parent element.
8042
8043 } else if (parser_token.tag_name === 'tr') {
8044 // A tr element’s end tag may be omitted if the tr element is immediately followed by another tr element, or if there is no more content in the parent element.
8045 // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
8046 // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8047 result = result || this._tag_stack.try_pop('caption', ['table']);
8048 result = result || this._tag_stack.try_pop('colgroup', ['table']);
8049 result = result || this._tag_stack.try_pop('tr', ['table', 'thead', 'tbody', 'tfoot']);
8050
8051 } else if (parser_token.tag_name === 'th' || parser_token.tag_name === 'td') {
8052 // A td element’s end tag may be omitted if the td element is immediately followed by a td or th element, or if there is no more content in the parent element.
8053 // A th element’s end tag may be omitted if the th element is immediately followed by a td or th element, or if there is no more content in the parent element.
8054 result = result || this._tag_stack.try_pop('td', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
8055 result = result || this._tag_stack.try_pop('th', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
8056 }
8057
8058 // Start element omission not handled currently
8059 // A head element’s start tag may be omitted if the element is empty, or if the first thing inside the head element is an element.
8060 // A tbody element’s start tag may be omitted if the first thing inside the tbody element is a tr element, and if the element is not immediately preceded by a tbody, thead, or tfoot element whose end tag has been omitted. (It can’t be omitted if the element is empty.)
8061 // A colgroup element’s start tag may be omitted if the first thing inside the colgroup element is a col element, and if the element is not immediately preceded by another colgroup element whose end tag has been omitted. (It can’t be omitted if the element is empty.)
8062
8063 // Fix up the parent of the parser token
8064 parser_token.parent = this._tag_stack.get_parser_token();
8065
8066 return result;
8067 };
8068
8069 var Beautifier_1$2 = Beautifier$4;
8070
8071 var beautifier$2 = {
8072 Beautifier: Beautifier_1$2
8073 };
8074
8075 var Beautifier$5 = beautifier$2.Beautifier,
8076 Options$9 = options$3.Options;
8077
8078 function style_html(html_source, options, js_beautify, css_beautify) {
8079 var beautifier = new Beautifier$5(html_source, options, js_beautify, css_beautify);
8080 return beautifier.beautify();
8081 }
8082
8083 var html = style_html;
8084 var defaultOptions$2 = function() {
8085 return new Options$9();
8086 };
8087 html.defaultOptions = defaultOptions$2;
8088
8089 function style_html$1(html_source, options, js, css$1) {
8090 js = js || javascript;
8091 css$1 = css$1 || css;
8092 return html(html_source, options, js, css$1);
8093 }
8094 style_html$1.defaultOptions = html.defaultOptions;
8095
8096 var js = javascript;
8097 var css$1 = css;
8098 var html$1 = style_html$1;
8099
8100 var src = {
8101 js: js,
8102 css: css$1,
8103 html: html$1
8104 };
8105
8106 var js$1 = createCommonjsModule(function (module) {
8107
8108 /**
8109 The following batches are equivalent:
8110
8111 var beautify_js = require('js-beautify');
8112 var beautify_js = require('js-beautify').js;
8113 var beautify_js = require('js-beautify').js_beautify;
8114
8115 var beautify_css = require('js-beautify').css;
8116 var beautify_css = require('js-beautify').css_beautify;
8117
8118 var beautify_html = require('js-beautify').html;
8119 var beautify_html = require('js-beautify').html_beautify;
8120
8121 All methods returned accept two arguments, the source string and an options object.
8122 **/
8123
8124 function get_beautify(js_beautify, css_beautify, html_beautify) {
8125 // the default is js
8126 var beautify = function(src, config) {
8127 return js_beautify.js_beautify(src, config);
8128 };
8129
8130 // short aliases
8131 beautify.js = js_beautify.js_beautify;
8132 beautify.css = css_beautify.css_beautify;
8133 beautify.html = html_beautify.html_beautify;
8134
8135 // legacy aliases
8136 beautify.js_beautify = js_beautify.js_beautify;
8137 beautify.css_beautify = css_beautify.css_beautify;
8138 beautify.html_beautify = html_beautify.html_beautify;
8139
8140 return beautify;
8141 }
8142
8143 {
8144 (function(mod) {
8145 var beautifier = src;
8146 beautifier.js_beautify = beautifier.js;
8147 beautifier.css_beautify = beautifier.css;
8148 beautifier.html_beautify = beautifier.html;
8149
8150 mod.exports = get_beautify(beautifier, beautifier, beautifier);
8151
8152 })(module);
8153 }
8154 });
8155
8156 /*!
8157 * is-whitespace <https://github.com/jonschlinkert/is-whitespace>
8158 *
8159 * Copyright (c) 2014-2015, Jon Schlinkert.
8160 * Licensed under the MIT License.
8161 */
8162
8163 var cache;
8164
8165 var isWhitespace = function isWhitespace(str) {
8166 return (typeof str === 'string') && regex().test(str);
8167 };
8168
8169 function regex() {
8170 // ensure that runtime compilation only happens once
8171 return cache || (cache = new RegExp('^[\\s\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF"]+$'));
8172 }
8173
8174 /*!
8175 * is-extendable <https://github.com/jonschlinkert/is-extendable>
8176 *
8177 * Copyright (c) 2015, Jon Schlinkert.
8178 * Licensed under the MIT License.
8179 */
8180
8181 var isExtendable = function isExtendable(val) {
8182 return typeof val !== 'undefined' && val !== null
8183 && (typeof val === 'object' || typeof val === 'function');
8184 };
8185
8186 var extendShallow = function extend(o/*, objects*/) {
8187 var arguments$1 = arguments;
8188
8189 if (!isExtendable(o)) { o = {}; }
8190
8191 var len = arguments.length;
8192 for (var i = 1; i < len; i++) {
8193 var obj = arguments$1[i];
8194
8195 if (isExtendable(obj)) {
8196 assign(o, obj);
8197 }
8198 }
8199 return o;
8200 };
8201
8202 function assign(a, b) {
8203 for (var key in b) {
8204 if (hasOwn(b, key)) {
8205 a[key] = b[key];
8206 }
8207 }
8208 }
8209
8210 /**
8211 * Returns true if the given `key` is an own property of `obj`.
8212 */
8213
8214 function hasOwn(obj, key) {
8215 return Object.prototype.hasOwnProperty.call(obj, key);
8216 }
8217
8218 /*!
8219 * Determine if an object is a Buffer
8220 *
8221 * @author Feross Aboukhadijeh <https://feross.org>
8222 * @license MIT
8223 */
8224
8225 // The _isBuffer check is for Safari 5-7 support, because it's missing
8226 // Object.prototype.constructor. Remove this eventually
8227 var isBuffer_1 = function (obj) {
8228 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
8229 };
8230
8231 function isBuffer (obj) {
8232 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
8233 }
8234
8235 // For Node v0.10 support. Remove this eventually.
8236 function isSlowBuffer (obj) {
8237 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
8238 }
8239
8240 var toString = Object.prototype.toString;
8241
8242 /**
8243 * Get the native `typeof` a value.
8244 *
8245 * @param {*} `val`
8246 * @return {*} Native javascript type
8247 */
8248
8249 var kindOf = function kindOf(val) {
8250 // primitivies
8251 if (typeof val === 'undefined') {
8252 return 'undefined';
8253 }
8254 if (val === null) {
8255 return 'null';
8256 }
8257 if (val === true || val === false || val instanceof Boolean) {
8258 return 'boolean';
8259 }
8260 if (typeof val === 'string' || val instanceof String) {
8261 return 'string';
8262 }
8263 if (typeof val === 'number' || val instanceof Number) {
8264 return 'number';
8265 }
8266
8267 // functions
8268 if (typeof val === 'function' || val instanceof Function) {
8269 return 'function';
8270 }
8271
8272 // array
8273 if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
8274 return 'array';
8275 }
8276
8277 // check for instances of RegExp and Date before calling `toString`
8278 if (val instanceof RegExp) {
8279 return 'regexp';
8280 }
8281 if (val instanceof Date) {
8282 return 'date';
8283 }
8284
8285 // other objects
8286 var type = toString.call(val);
8287
8288 if (type === '[object RegExp]') {
8289 return 'regexp';
8290 }
8291 if (type === '[object Date]') {
8292 return 'date';
8293 }
8294 if (type === '[object Arguments]') {
8295 return 'arguments';
8296 }
8297 if (type === '[object Error]') {
8298 return 'error';
8299 }
8300
8301 // buffer
8302 if (isBuffer_1(val)) {
8303 return 'buffer';
8304 }
8305
8306 // es6: Map, WeakMap, Set, WeakSet
8307 if (type === '[object Set]') {
8308 return 'set';
8309 }
8310 if (type === '[object WeakSet]') {
8311 return 'weakset';
8312 }
8313 if (type === '[object Map]') {
8314 return 'map';
8315 }
8316 if (type === '[object WeakMap]') {
8317 return 'weakmap';
8318 }
8319 if (type === '[object Symbol]') {
8320 return 'symbol';
8321 }
8322
8323 // typed arrays
8324 if (type === '[object Int8Array]') {
8325 return 'int8array';
8326 }
8327 if (type === '[object Uint8Array]') {
8328 return 'uint8array';
8329 }
8330 if (type === '[object Uint8ClampedArray]') {
8331 return 'uint8clampedarray';
8332 }
8333 if (type === '[object Int16Array]') {
8334 return 'int16array';
8335 }
8336 if (type === '[object Uint16Array]') {
8337 return 'uint16array';
8338 }
8339 if (type === '[object Int32Array]') {
8340 return 'int32array';
8341 }
8342 if (type === '[object Uint32Array]') {
8343 return 'uint32array';
8344 }
8345 if (type === '[object Float32Array]') {
8346 return 'float32array';
8347 }
8348 if (type === '[object Float64Array]') {
8349 return 'float64array';
8350 }
8351
8352 // must be a plain object
8353 return 'object';
8354 };
8355
8356 var condenseNewlines = function(str, options) {
8357 var opts = extendShallow({}, options);
8358 var sep = opts.sep || '\n\n';
8359 var min = opts.min;
8360 var re;
8361
8362 if (typeof min === 'number' && min !== 2) {
8363 re = new RegExp('(\\r\\n|\\n|\\u2424) {' + min + ',}');
8364 }
8365 if (typeof re === 'undefined') {
8366 re = opts.regex || /(\r\n|\n|\u2424){2,}/g;
8367 }
8368
8369 // if a line is 100% whitespace it will be trimmed, so that
8370 // later we can condense newlines correctly
8371 if (opts.keepWhitespace !== true) {
8372 str = str.split('\n').map(function(line) {
8373 return isWhitespace(line) ? line.trim() : line;
8374 }).join('\n');
8375 }
8376
8377 str = trailingNewline(str, opts);
8378 return str.replace(re, sep);
8379 };
8380
8381 function trailingNewline(str, options) {
8382 var val = options.trailingNewline;
8383 if (val === false) {
8384 return str;
8385 }
8386
8387 switch (kindOf(val)) {
8388 case 'string':
8389 str = str.replace(/\s+$/, options.trailingNewline);
8390 break;
8391 case 'function':
8392 str = options.trailingNewline(str);
8393 break;
8394 case 'undefined':
8395 case 'boolean':
8396 default: {
8397 str = str.replace(/\s+$/, '\n');
8398 break;
8399 }
8400 }
8401 return str;
8402 }
8403
8404 var defaults = {
8405 unformatted: ['code', 'pre', 'em', 'strong', 'span'],
8406 indent_inner_html: true,
8407 indent_char: ' ',
8408 indent_size: 2,
8409 sep: '\n'
8410 };
8411
8412 var pretty = function pretty(str, options) {
8413 var opts = extendShallow({}, defaults, options);
8414 str = js$1.html(str, opts);
8415
8416 if (opts.ocd === true) {
8417 if (opts.newlines) { opts.sep = opts.newlines; }
8418 return ocd(str, opts);
8419 }
8420
8421 return str;
8422 };
8423
8424 function ocd(str, options) {
8425 // Normalize and condense all newlines
8426 return condenseNewlines(str, options)
8427 // Remove empty whitespace the top of a file.
8428 .replace(/^\s+/g, '')
8429 // Remove extra whitespace from eof
8430 .replace(/\s+$/g, '\n')
8431
8432 // Add a space above each comment
8433 .replace(/(\s*<!--)/g, '\n$1')
8434 // Bring closing comments up to the same line as closing tag.
8435 .replace(/>(\s*)(?=<!--\s*\/)/g, '> ');
8436 }
8437
8438 //
8439
8440 function getSelectorType(selector) {
8441 if (isDomSelector(selector)) { return DOM_SELECTOR }
8442 if (isVueComponent(selector)) { return COMPONENT_SELECTOR }
8443 if (isNameSelector(selector)) { return NAME_SELECTOR }
8444 if (isRefSelector(selector)) { return REF_SELECTOR }
8445
8446 return INVALID_SELECTOR
8447 }
8448
8449 function getSelector(
8450 selector,
8451 methodName
8452 ) {
8453 var type = getSelectorType(selector);
8454 if (type === INVALID_SELECTOR) {
8455 throwError(
8456 "wrapper." + methodName + "() must be passed a valid CSS selector, Vue " +
8457 "constructor, or valid find option object"
8458 );
8459 }
8460 return {
8461 type: type,
8462 value: selector
8463 }
8464 }
8465
8466 //
8467
8468 var WrapperArray = function WrapperArray(wrappers) {
8469 var length = wrappers.length;
8470 // $FlowIgnore
8471 Object.defineProperty(this, 'wrappers', {
8472 get: function () { return wrappers; },
8473 set: function () { return throwError('wrapperArray.wrappers is read-only'); }
8474 });
8475 // $FlowIgnore
8476 Object.defineProperty(this, 'length', {
8477 get: function () { return length; },
8478 set: function () { return throwError('wrapperArray.length is read-only'); }
8479 });
8480 };
8481
8482 WrapperArray.prototype.at = function at (index) {
8483 var normalizedIndex = index < 0 ? this.length + index : index;
8484 if (normalizedIndex > this.length - 1 || normalizedIndex < 0) {
8485 var error = "no item exists at " + index;
8486 error += index < 0 ? (" (normalized to " + normalizedIndex + ")") : '';
8487 throwError(error);
8488 }
8489 return this.wrappers[normalizedIndex]
8490 };
8491
8492 WrapperArray.prototype.attributes = function attributes () {
8493 this.throwErrorIfWrappersIsEmpty('attributes');
8494
8495 throwError(
8496 "attributes must be called on a single wrapper, use " +
8497 "at(i) to access a wrapper"
8498 );
8499 };
8500
8501 WrapperArray.prototype.classes = function classes () {
8502 this.throwErrorIfWrappersIsEmpty('classes');
8503
8504 throwError(
8505 "classes must be called on a single wrapper, use " +
8506 "at(i) to access a wrapper"
8507 );
8508 };
8509
8510 WrapperArray.prototype.contains = function contains (selector) {
8511 this.throwErrorIfWrappersIsEmpty('contains');
8512
8513 return this.wrappers.every(function (wrapper) { return wrapper.contains(selector); })
8514 };
8515
8516 WrapperArray.prototype.exists = function exists () {
8517 return this.length > 0 && this.wrappers.every(function (wrapper) { return wrapper.exists(); })
8518 };
8519
8520 WrapperArray.prototype.filter = function filter (predicate) {
8521 return new WrapperArray(this.wrappers.filter(predicate))
8522 };
8523
8524 WrapperArray.prototype.emitted = function emitted () {
8525 this.throwErrorIfWrappersIsEmpty('emitted');
8526
8527 throwError(
8528 "emitted must be called on a single wrapper, use " +
8529 "at(i) to access a wrapper"
8530 );
8531 };
8532
8533 WrapperArray.prototype.emittedByOrder = function emittedByOrder () {
8534 this.throwErrorIfWrappersIsEmpty('emittedByOrder');
8535
8536 throwError(
8537 "emittedByOrder must be called on a single wrapper, " +
8538 "use at(i) to access a wrapper"
8539 );
8540 };
8541
8542 WrapperArray.prototype.findAll = function findAll () {
8543 this.throwErrorIfWrappersIsEmpty('findAll');
8544
8545 throwError(
8546 "findAll must be called on a single wrapper, use " +
8547 "at(i) to access a wrapper"
8548 );
8549 };
8550
8551 WrapperArray.prototype.find = function find () {
8552 this.throwErrorIfWrappersIsEmpty('find');
8553
8554 throwError(
8555 "find must be called on a single wrapper, use at(i) " +
8556 "to access a wrapper"
8557 );
8558 };
8559
8560 WrapperArray.prototype.html = function html () {
8561 this.throwErrorIfWrappersIsEmpty('html');
8562
8563 throwError(
8564 "html must be called on a single wrapper, use at(i) " +
8565 "to access a wrapper"
8566 );
8567 };
8568
8569 WrapperArray.prototype.is = function is (selector) {
8570 this.throwErrorIfWrappersIsEmpty('is');
8571
8572 return this.wrappers.every(function (wrapper) { return wrapper.is(selector); })
8573 };
8574
8575 WrapperArray.prototype.isEmpty = function isEmpty () {
8576 this.throwErrorIfWrappersIsEmpty('isEmpty');
8577
8578 return this.wrappers.every(function (wrapper) { return wrapper.isEmpty(); })
8579 };
8580
8581 WrapperArray.prototype.isVisible = function isVisible () {
8582 this.throwErrorIfWrappersIsEmpty('isVisible');
8583
8584 return this.wrappers.every(function (wrapper) { return wrapper.isVisible(); })
8585 };
8586
8587 WrapperArray.prototype.isVueInstance = function isVueInstance () {
8588 this.throwErrorIfWrappersIsEmpty('isVueInstance');
8589
8590 return this.wrappers.every(function (wrapper) { return wrapper.isVueInstance(); })
8591 };
8592
8593 WrapperArray.prototype.name = function name () {
8594 this.throwErrorIfWrappersIsEmpty('name');
8595
8596 throwError(
8597 "name must be called on a single wrapper, use at(i) " +
8598 "to access a wrapper"
8599 );
8600 };
8601
8602 WrapperArray.prototype.overview = function overview () {
8603 this.throwErrorIfWrappersIsEmpty('overview()');
8604
8605 throwError(
8606 "overview() must be called on a single wrapper, use at(i) " +
8607 "to access a wrapper"
8608 );
8609 };
8610
8611 WrapperArray.prototype.props = function props () {
8612 this.throwErrorIfWrappersIsEmpty('props');
8613
8614 throwError(
8615 "props must be called on a single wrapper, use " +
8616 "at(i) to access a wrapper"
8617 );
8618 };
8619
8620 WrapperArray.prototype.text = function text () {
8621 this.throwErrorIfWrappersIsEmpty('text');
8622
8623 throwError(
8624 "text must be called on a single wrapper, use at(i) " +
8625 "to access a wrapper"
8626 );
8627 };
8628
8629 WrapperArray.prototype.throwErrorIfWrappersIsEmpty = function throwErrorIfWrappersIsEmpty (method) {
8630 if (this.wrappers.length === 0) {
8631 throwError((method + " cannot be called on 0 items"));
8632 }
8633 };
8634
8635 WrapperArray.prototype.setData = function setData (data) {
8636 this.throwErrorIfWrappersIsEmpty('setData');
8637
8638 this.wrappers.forEach(function (wrapper) { return wrapper.setData(data); });
8639 };
8640
8641 WrapperArray.prototype.setMethods = function setMethods (props) {
8642 this.throwErrorIfWrappersIsEmpty('setMethods');
8643
8644 this.wrappers.forEach(function (wrapper) { return wrapper.setMethods(props); });
8645 };
8646
8647 WrapperArray.prototype.setProps = function setProps (props) {
8648 this.throwErrorIfWrappersIsEmpty('setProps');
8649
8650 this.wrappers.forEach(function (wrapper) { return wrapper.setProps(props); });
8651 };
8652
8653 WrapperArray.prototype.setValue = function setValue (value) {
8654 this.throwErrorIfWrappersIsEmpty('setValue');
8655
8656 this.wrappers.forEach(function (wrapper) { return wrapper.setValue(value); });
8657 };
8658
8659 WrapperArray.prototype.setChecked = function setChecked (checked) {
8660 if ( checked === void 0 ) checked = true;
8661
8662 this.throwErrorIfWrappersIsEmpty('setChecked');
8663
8664 this.wrappers.forEach(function (wrapper) { return wrapper.setChecked(checked); });
8665 };
8666
8667 WrapperArray.prototype.setSelected = function setSelected () {
8668 this.throwErrorIfWrappersIsEmpty('setSelected');
8669
8670 throwError(
8671 "setSelected must be called on a single wrapper, " +
8672 "use at(i) to access a wrapper"
8673 );
8674 };
8675
8676 WrapperArray.prototype.trigger = function trigger (event, options) {
8677 this.throwErrorIfWrappersIsEmpty('trigger');
8678
8679 this.wrappers.forEach(function (wrapper) { return wrapper.trigger(event, options); });
8680 };
8681
8682 WrapperArray.prototype.destroy = function destroy () {
8683 this.throwErrorIfWrappersIsEmpty('destroy');
8684
8685 this.wrappers.forEach(function (wrapper) { return wrapper.destroy(); });
8686 };
8687
8688 //
8689
8690 var buildSelectorString = function (selector) {
8691 if (getSelectorType(selector) === REF_SELECTOR) {
8692 return ("ref=\"" + (selector.value.ref) + "\"")
8693 }
8694
8695 if (typeof selector === 'string') {
8696 return selector
8697 }
8698
8699 return 'Component'
8700 };
8701
8702 var ErrorWrapper = function ErrorWrapper(selector) {
8703 this.selector = selector;
8704 };
8705
8706 ErrorWrapper.prototype.at = function at () {
8707 throwError(
8708 ("find did not return " + (buildSelectorString(
8709 this.selector
8710 )) + ", cannot call at() on empty Wrapper")
8711 );
8712 };
8713
8714 ErrorWrapper.prototype.attributes = function attributes () {
8715 throwError(
8716 ("find did not return " + (buildSelectorString(
8717 this.selector
8718 )) + ", cannot call attributes() on empty Wrapper")
8719 );
8720 };
8721
8722 ErrorWrapper.prototype.classes = function classes () {
8723 throwError(
8724 ("find did not return " + (buildSelectorString(
8725 this.selector
8726 )) + ", cannot call classes() on empty Wrapper")
8727 );
8728 };
8729
8730 ErrorWrapper.prototype.contains = function contains () {
8731 throwError(
8732 ("find did not return " + (buildSelectorString(
8733 this.selector
8734 )) + ", cannot call contains() on empty Wrapper")
8735 );
8736 };
8737
8738 ErrorWrapper.prototype.emitted = function emitted () {
8739 throwError(
8740 ("find did not return " + (buildSelectorString(
8741 this.selector
8742 )) + ", cannot call emitted() on empty Wrapper")
8743 );
8744 };
8745
8746 ErrorWrapper.prototype.emittedByOrder = function emittedByOrder () {
8747 throwError(
8748 ("find did not return " + (buildSelectorString(
8749 this.selector
8750 )) + ", cannot call emittedByOrder() on empty Wrapper")
8751 );
8752 };
8753
8754 ErrorWrapper.prototype.exists = function exists () {
8755 return false
8756 };
8757
8758 ErrorWrapper.prototype.filter = function filter () {
8759 throwError(
8760 ("find did not return " + (buildSelectorString(
8761 this.selector
8762 )) + ", cannot call filter() on empty Wrapper")
8763 );
8764 };
8765
8766 ErrorWrapper.prototype.visible = function visible () {
8767 throwError(
8768 ("find did not return " + (buildSelectorString(
8769 this.selector
8770 )) + ", cannot call visible() on empty Wrapper")
8771 );
8772 };
8773
8774 ErrorWrapper.prototype.hasAttribute = function hasAttribute () {
8775 throwError(
8776 ("find did not return " + (buildSelectorString(
8777 this.selector
8778 )) + ", cannot call hasAttribute() on empty Wrapper")
8779 );
8780 };
8781
8782 ErrorWrapper.prototype.hasClass = function hasClass () {
8783 throwError(
8784 ("find did not return " + (buildSelectorString(
8785 this.selector
8786 )) + ", cannot call hasClass() on empty Wrapper")
8787 );
8788 };
8789
8790 ErrorWrapper.prototype.hasProp = function hasProp () {
8791 throwError(
8792 ("find did not return " + (buildSelectorString(
8793 this.selector
8794 )) + ", cannot call hasProp() on empty Wrapper")
8795 );
8796 };
8797
8798 ErrorWrapper.prototype.hasStyle = function hasStyle () {
8799 throwError(
8800 ("find did not return " + (buildSelectorString(
8801 this.selector
8802 )) + ", cannot call hasStyle() on empty Wrapper")
8803 );
8804 };
8805
8806 ErrorWrapper.prototype.findAll = function findAll () {
8807 throwError(
8808 ("find did not return " + (buildSelectorString(
8809 this.selector
8810 )) + ", cannot call findAll() on empty Wrapper")
8811 );
8812 };
8813
8814 ErrorWrapper.prototype.find = function find () {
8815 throwError(
8816 ("find did not return " + (buildSelectorString(
8817 this.selector
8818 )) + ", cannot call find() on empty Wrapper")
8819 );
8820 };
8821
8822 ErrorWrapper.prototype.html = function html () {
8823 throwError(
8824 ("find did not return " + (buildSelectorString(
8825 this.selector
8826 )) + ", cannot call html() on empty Wrapper")
8827 );
8828 };
8829
8830 ErrorWrapper.prototype.is = function is () {
8831 throwError(
8832 ("find did not return " + (buildSelectorString(
8833 this.selector
8834 )) + ", cannot call is() on empty Wrapper")
8835 );
8836 };
8837
8838 ErrorWrapper.prototype.isEmpty = function isEmpty () {
8839 throwError(
8840 ("find did not return " + (buildSelectorString(
8841 this.selector
8842 )) + ", cannot call isEmpty() on empty Wrapper")
8843 );
8844 };
8845
8846 ErrorWrapper.prototype.isVisible = function isVisible () {
8847 throwError(
8848 ("find did not return " + (buildSelectorString(
8849 this.selector
8850 )) + ", cannot call isVisible() on empty Wrapper")
8851 );
8852 };
8853
8854 ErrorWrapper.prototype.isVueInstance = function isVueInstance () {
8855 throwError(
8856 ("find did not return " + (buildSelectorString(
8857 this.selector
8858 )) + ", cannot call isVueInstance() on empty Wrapper")
8859 );
8860 };
8861
8862 ErrorWrapper.prototype.name = function name () {
8863 throwError(
8864 ("find did not return " + (buildSelectorString(
8865 this.selector
8866 )) + ", cannot call name() on empty Wrapper")
8867 );
8868 };
8869
8870 ErrorWrapper.prototype.overview = function overview () {
8871 throwError(
8872 ("find did not return " + (buildSelectorString(
8873 this.selector
8874 )) + ", cannot call overview() on empty Wrapper")
8875 );
8876 };
8877
8878 ErrorWrapper.prototype.props = function props () {
8879 throwError(
8880 ("find did not return " + (buildSelectorString(
8881 this.selector
8882 )) + ", cannot call props() on empty Wrapper")
8883 );
8884 };
8885
8886 ErrorWrapper.prototype.text = function text () {
8887 throwError(
8888 ("find did not return " + (buildSelectorString(
8889 this.selector
8890 )) + ", cannot call text() on empty Wrapper")
8891 );
8892 };
8893
8894 ErrorWrapper.prototype.setComputed = function setComputed () {
8895 throwError(
8896 ("find did not return " + (buildSelectorString(
8897 this.selector
8898 )) + ", cannot call setComputed() on empty Wrapper")
8899 );
8900 };
8901
8902 ErrorWrapper.prototype.setData = function setData () {
8903 throwError(
8904 ("find did not return " + (buildSelectorString(
8905 this.selector
8906 )) + ", cannot call setData() on empty Wrapper")
8907 );
8908 };
8909
8910 ErrorWrapper.prototype.setMethods = function setMethods () {
8911 throwError(
8912 ("find did not return " + (buildSelectorString(
8913 this.selector
8914 )) + ", cannot call setMethods() on empty Wrapper")
8915 );
8916 };
8917
8918 ErrorWrapper.prototype.setProps = function setProps () {
8919 throwError(
8920 ("find did not return " + (buildSelectorString(
8921 this.selector
8922 )) + ", cannot call setProps() on empty Wrapper")
8923 );
8924 };
8925
8926 ErrorWrapper.prototype.setValue = function setValue () {
8927 throwError(
8928 ("find did not return " + (buildSelectorString(
8929 this.selector
8930 )) + ", cannot call setValue() on empty Wrapper")
8931 );
8932 };
8933
8934 ErrorWrapper.prototype.setChecked = function setChecked () {
8935 throwError(
8936 ("find did not return " + (buildSelectorString(
8937 this.selector
8938 )) + ", cannot call setChecked() on empty Wrapper")
8939 );
8940 };
8941
8942 ErrorWrapper.prototype.setSelected = function setSelected () {
8943 throwError(
8944 ("find did not return " + (buildSelectorString(
8945 this.selector
8946 )) + ", cannot call setSelected() on empty Wrapper")
8947 );
8948 };
8949
8950 ErrorWrapper.prototype.trigger = function trigger () {
8951 throwError(
8952 ("find did not return " + (buildSelectorString(
8953 this.selector
8954 )) + ", cannot call trigger() on empty Wrapper")
8955 );
8956 };
8957
8958 ErrorWrapper.prototype.destroy = function destroy () {
8959 throwError(
8960 ("find did not return " + (buildSelectorString(
8961 this.selector
8962 )) + ", cannot call destroy() on empty Wrapper")
8963 );
8964 };
8965
8966 function recursivelySetData(vm, target, data) {
8967 Object.keys(data).forEach(function (key) {
8968 var val = data[key];
8969 var targetVal = target[key];
8970
8971 if (isPlainObject(val) && isPlainObject(targetVal)) {
8972 recursivelySetData(vm, targetVal, val);
8973 } else {
8974 vm.$set(target, key, val);
8975 }
8976 });
8977 }
8978
8979 var abort = {
8980 eventInterface: "Event",
8981 bubbles: false,
8982 cancelable: false
8983 };
8984 var afterprint = {
8985 eventInterface: "Event",
8986 bubbles: false,
8987 cancelable: false
8988 };
8989 var animationend = {
8990 eventInterface: "AnimationEvent",
8991 bubbles: true,
8992 cancelable: false
8993 };
8994 var animationiteration = {
8995 eventInterface: "AnimationEvent",
8996 bubbles: true,
8997 cancelable: false
8998 };
8999 var animationstart = {
9000 eventInterface: "AnimationEvent",
9001 bubbles: true,
9002 cancelable: false
9003 };
9004 var appinstalled = {
9005 eventInterface: "Event",
9006 bubbles: false,
9007 cancelable: false
9008 };
9009 var audioprocess = {
9010 eventInterface: "AudioProcessingEvent"
9011 };
9012 var audioend = {
9013 eventInterface: "Event",
9014 bubbles: false,
9015 cancelable: false
9016 };
9017 var audiostart = {
9018 eventInterface: "Event",
9019 bubbles: false,
9020 cancelable: false
9021 };
9022 var beforeprint = {
9023 eventInterface: "Event",
9024 bubbles: false,
9025 cancelable: false
9026 };
9027 var beforeunload = {
9028 eventInterface: "BeforeUnloadEvent",
9029 bubbles: false,
9030 cancelable: true
9031 };
9032 var beginEvent = {
9033 eventInterface: "TimeEvent",
9034 bubbles: false,
9035 cancelable: false
9036 };
9037 var blur = {
9038 eventInterface: "FocusEvent",
9039 bubbles: false,
9040 cancelable: false
9041 };
9042 var boundary = {
9043 eventInterface: "SpeechSynthesisEvent",
9044 bubbles: false,
9045 cancelable: false
9046 };
9047 var cached = {
9048 eventInterface: "Event",
9049 bubbles: false,
9050 cancelable: false
9051 };
9052 var canplay = {
9053 eventInterface: "Event",
9054 bubbles: false,
9055 cancelable: false
9056 };
9057 var canplaythrough = {
9058 eventInterface: "Event",
9059 bubbles: false,
9060 cancelable: false
9061 };
9062 var change = {
9063 eventInterface: "Event",
9064 bubbles: true,
9065 cancelable: false
9066 };
9067 var chargingchange = {
9068 eventInterface: "Event",
9069 bubbles: false,
9070 cancelable: false
9071 };
9072 var chargingtimechange = {
9073 eventInterface: "Event",
9074 bubbles: false,
9075 cancelable: false
9076 };
9077 var checking = {
9078 eventInterface: "Event",
9079 bubbles: false,
9080 cancelable: false
9081 };
9082 var click = {
9083 eventInterface: "MouseEvent",
9084 bubbles: true,
9085 cancelable: true
9086 };
9087 var close = {
9088 eventInterface: "Event",
9089 bubbles: false,
9090 cancelable: false
9091 };
9092 var complete = {
9093 eventInterface: "OfflineAudioCompletionEvent"
9094 };
9095 var compositionend = {
9096 eventInterface: "CompositionEvent",
9097 bubbles: true,
9098 cancelable: true
9099 };
9100 var compositionstart = {
9101 eventInterface: "CompositionEvent",
9102 bubbles: true,
9103 cancelable: true
9104 };
9105 var compositionupdate = {
9106 eventInterface: "CompositionEvent",
9107 bubbles: true,
9108 cancelable: false
9109 };
9110 var contextmenu = {
9111 eventInterface: "MouseEvent",
9112 bubbles: true,
9113 cancelable: true
9114 };
9115 var copy = {
9116 eventInterface: "ClipboardEvent"
9117 };
9118 var cut = {
9119 eventInterface: "ClipboardEvent",
9120 bubbles: true,
9121 cancelable: true
9122 };
9123 var dblclick = {
9124 eventInterface: "MouseEvent",
9125 bubbles: true,
9126 cancelable: true
9127 };
9128 var devicechange = {
9129 eventInterface: "Event",
9130 bubbles: false,
9131 cancelable: false
9132 };
9133 var devicelight = {
9134 eventInterface: "DeviceLightEvent",
9135 bubbles: false,
9136 cancelable: false
9137 };
9138 var devicemotion = {
9139 eventInterface: "DeviceMotionEvent",
9140 bubbles: false,
9141 cancelable: false
9142 };
9143 var deviceorientation = {
9144 eventInterface: "DeviceOrientationEvent",
9145 bubbles: false,
9146 cancelable: false
9147 };
9148 var deviceproximity = {
9149 eventInterface: "DeviceProximityEvent",
9150 bubbles: false,
9151 cancelable: false
9152 };
9153 var dischargingtimechange = {
9154 eventInterface: "Event",
9155 bubbles: false,
9156 cancelable: false
9157 };
9158 var DOMActivate = {
9159 eventInterface: "UIEvent",
9160 bubbles: true,
9161 cancelable: true
9162 };
9163 var DOMAttributeNameChanged = {
9164 eventInterface: "MutationNameEvent",
9165 bubbles: true,
9166 cancelable: true
9167 };
9168 var DOMAttrModified = {
9169 eventInterface: "MutationEvent",
9170 bubbles: true,
9171 cancelable: true
9172 };
9173 var DOMCharacterDataModified = {
9174 eventInterface: "MutationEvent",
9175 bubbles: true,
9176 cancelable: true
9177 };
9178 var DOMContentLoaded = {
9179 eventInterface: "Event",
9180 bubbles: true,
9181 cancelable: true
9182 };
9183 var DOMElementNameChanged = {
9184 eventInterface: "MutationNameEvent",
9185 bubbles: true,
9186 cancelable: true
9187 };
9188 var DOMFocusIn = {
9189 eventInterface: "FocusEvent",
9190 bubbles: true,
9191 cancelable: true
9192 };
9193 var DOMFocusOut = {
9194 eventInterface: "FocusEvent",
9195 bubbles: true,
9196 cancelable: true
9197 };
9198 var DOMNodeInserted = {
9199 eventInterface: "MutationEvent",
9200 bubbles: true,
9201 cancelable: true
9202 };
9203 var DOMNodeInsertedIntoDocument = {
9204 eventInterface: "MutationEvent",
9205 bubbles: true,
9206 cancelable: true
9207 };
9208 var DOMNodeRemoved = {
9209 eventInterface: "MutationEvent",
9210 bubbles: true,
9211 cancelable: true
9212 };
9213 var DOMNodeRemovedFromDocument = {
9214 eventInterface: "MutationEvent",
9215 bubbles: true,
9216 cancelable: true
9217 };
9218 var DOMSubtreeModified = {
9219 eventInterface: "MutationEvent"
9220 };
9221 var downloading = {
9222 eventInterface: "Event",
9223 bubbles: false,
9224 cancelable: false
9225 };
9226 var drag = {
9227 eventInterface: "DragEvent",
9228 bubbles: true,
9229 cancelable: true
9230 };
9231 var dragend = {
9232 eventInterface: "DragEvent",
9233 bubbles: true,
9234 cancelable: false
9235 };
9236 var dragenter = {
9237 eventInterface: "DragEvent",
9238 bubbles: true,
9239 cancelable: true
9240 };
9241 var dragleave = {
9242 eventInterface: "DragEvent",
9243 bubbles: true,
9244 cancelable: false
9245 };
9246 var dragover = {
9247 eventInterface: "DragEvent",
9248 bubbles: true,
9249 cancelable: true
9250 };
9251 var dragstart = {
9252 eventInterface: "DragEvent",
9253 bubbles: true,
9254 cancelable: true
9255 };
9256 var drop = {
9257 eventInterface: "DragEvent",
9258 bubbles: true,
9259 cancelable: true
9260 };
9261 var durationchange = {
9262 eventInterface: "Event",
9263 bubbles: false,
9264 cancelable: false
9265 };
9266 var emptied = {
9267 eventInterface: "Event",
9268 bubbles: false,
9269 cancelable: false
9270 };
9271 var end = {
9272 eventInterface: "Event",
9273 bubbles: false,
9274 cancelable: false
9275 };
9276 var ended = {
9277 eventInterface: "Event",
9278 bubbles: false,
9279 cancelable: false
9280 };
9281 var endEvent = {
9282 eventInterface: "TimeEvent",
9283 bubbles: false,
9284 cancelable: false
9285 };
9286 var error = {
9287 eventInterface: "Event",
9288 bubbles: false,
9289 cancelable: false
9290 };
9291 var focus = {
9292 eventInterface: "FocusEvent",
9293 bubbles: false,
9294 cancelable: false
9295 };
9296 var focusin = {
9297 eventInterface: "FocusEvent",
9298 bubbles: true,
9299 cancelable: false
9300 };
9301 var focusout = {
9302 eventInterface: "FocusEvent",
9303 bubbles: true,
9304 cancelable: false
9305 };
9306 var fullscreenchange = {
9307 eventInterface: "Event",
9308 bubbles: true,
9309 cancelable: false
9310 };
9311 var fullscreenerror = {
9312 eventInterface: "Event",
9313 bubbles: true,
9314 cancelable: false
9315 };
9316 var gamepadconnected = {
9317 eventInterface: "GamepadEvent",
9318 bubbles: false,
9319 cancelable: false
9320 };
9321 var gamepaddisconnected = {
9322 eventInterface: "GamepadEvent",
9323 bubbles: false,
9324 cancelable: false
9325 };
9326 var gotpointercapture = {
9327 eventInterface: "PointerEvent",
9328 bubbles: false,
9329 cancelable: false
9330 };
9331 var hashchange = {
9332 eventInterface: "HashChangeEvent",
9333 bubbles: true,
9334 cancelable: false
9335 };
9336 var lostpointercapture = {
9337 eventInterface: "PointerEvent",
9338 bubbles: false,
9339 cancelable: false
9340 };
9341 var input = {
9342 eventInterface: "Event",
9343 bubbles: true,
9344 cancelable: false
9345 };
9346 var invalid = {
9347 eventInterface: "Event",
9348 cancelable: true,
9349 bubbles: false
9350 };
9351 var keydown = {
9352 eventInterface: "KeyboardEvent",
9353 bubbles: true,
9354 cancelable: true
9355 };
9356 var keypress = {
9357 eventInterface: "KeyboardEvent",
9358 bubbles: true,
9359 cancelable: true
9360 };
9361 var keyup = {
9362 eventInterface: "KeyboardEvent",
9363 bubbles: true,
9364 cancelable: true
9365 };
9366 var languagechange = {
9367 eventInterface: "Event",
9368 bubbles: false,
9369 cancelable: false
9370 };
9371 var levelchange = {
9372 eventInterface: "Event",
9373 bubbles: false,
9374 cancelable: false
9375 };
9376 var load = {
9377 eventInterface: "UIEvent",
9378 bubbles: false,
9379 cancelable: false
9380 };
9381 var loadeddata = {
9382 eventInterface: "Event",
9383 bubbles: false,
9384 cancelable: false
9385 };
9386 var loadedmetadata = {
9387 eventInterface: "Event",
9388 bubbles: false,
9389 cancelable: false
9390 };
9391 var loadend = {
9392 eventInterface: "ProgressEvent",
9393 bubbles: false,
9394 cancelable: false
9395 };
9396 var loadstart = {
9397 eventInterface: "ProgressEvent",
9398 bubbles: false,
9399 cancelable: false
9400 };
9401 var mark = {
9402 eventInterface: "SpeechSynthesisEvent",
9403 bubbles: false,
9404 cancelable: false
9405 };
9406 var message = {
9407 eventInterface: "MessageEvent",
9408 bubbles: false,
9409 cancelable: false
9410 };
9411 var messageerror = {
9412 eventInterface: "MessageEvent",
9413 bubbles: false,
9414 cancelable: false
9415 };
9416 var mousedown = {
9417 eventInterface: "MouseEvent",
9418 bubbles: true,
9419 cancelable: true
9420 };
9421 var mouseenter = {
9422 eventInterface: "MouseEvent",
9423 bubbles: false,
9424 cancelable: false
9425 };
9426 var mouseleave = {
9427 eventInterface: "MouseEvent",
9428 bubbles: false,
9429 cancelable: false
9430 };
9431 var mousemove = {
9432 eventInterface: "MouseEvent",
9433 bubbles: true,
9434 cancelable: true
9435 };
9436 var mouseout = {
9437 eventInterface: "MouseEvent",
9438 bubbles: true,
9439 cancelable: true
9440 };
9441 var mouseover = {
9442 eventInterface: "MouseEvent",
9443 bubbles: true,
9444 cancelable: true
9445 };
9446 var mouseup = {
9447 eventInterface: "MouseEvent",
9448 bubbles: true,
9449 cancelable: true
9450 };
9451 var nomatch = {
9452 eventInterface: "SpeechRecognitionEvent",
9453 bubbles: false,
9454 cancelable: false
9455 };
9456 var notificationclick = {
9457 eventInterface: "NotificationEvent",
9458 bubbles: false,
9459 cancelable: false
9460 };
9461 var noupdate = {
9462 eventInterface: "Event",
9463 bubbles: false,
9464 cancelable: false
9465 };
9466 var obsolete = {
9467 eventInterface: "Event",
9468 bubbles: false,
9469 cancelable: false
9470 };
9471 var offline = {
9472 eventInterface: "Event",
9473 bubbles: false,
9474 cancelable: false
9475 };
9476 var online = {
9477 eventInterface: "Event",
9478 bubbles: false,
9479 cancelable: false
9480 };
9481 var open = {
9482 eventInterface: "Event",
9483 bubbles: false,
9484 cancelable: false
9485 };
9486 var orientationchange = {
9487 eventInterface: "Event",
9488 bubbles: false,
9489 cancelable: false
9490 };
9491 var pagehide = {
9492 eventInterface: "PageTransitionEvent",
9493 bubbles: false,
9494 cancelable: false
9495 };
9496 var pageshow = {
9497 eventInterface: "PageTransitionEvent",
9498 bubbles: false,
9499 cancelable: false
9500 };
9501 var paste = {
9502 eventInterface: "ClipboardEvent",
9503 bubbles: true,
9504 cancelable: true
9505 };
9506 var pause = {
9507 eventInterface: "SpeechSynthesisEvent",
9508 bubbles: false,
9509 cancelable: false
9510 };
9511 var pointercancel = {
9512 eventInterface: "PointerEvent",
9513 bubbles: true,
9514 cancelable: false
9515 };
9516 var pointerdown = {
9517 eventInterface: "PointerEvent",
9518 bubbles: true,
9519 cancelable: true
9520 };
9521 var pointerenter = {
9522 eventInterface: "PointerEvent",
9523 bubbles: false,
9524 cancelable: false
9525 };
9526 var pointerleave = {
9527 eventInterface: "PointerEvent",
9528 bubbles: false,
9529 cancelable: false
9530 };
9531 var pointerlockchange = {
9532 eventInterface: "Event",
9533 bubbles: true,
9534 cancelable: false
9535 };
9536 var pointerlockerror = {
9537 eventInterface: "Event",
9538 bubbles: true,
9539 cancelable: false
9540 };
9541 var pointermove = {
9542 eventInterface: "PointerEvent",
9543 bubbles: true,
9544 cancelable: true
9545 };
9546 var pointerout = {
9547 eventInterface: "PointerEvent",
9548 bubbles: true,
9549 cancelable: true
9550 };
9551 var pointerover = {
9552 eventInterface: "PointerEvent",
9553 bubbles: true,
9554 cancelable: true
9555 };
9556 var pointerup = {
9557 eventInterface: "PointerEvent",
9558 bubbles: true,
9559 cancelable: true
9560 };
9561 var play = {
9562 eventInterface: "Event",
9563 bubbles: false,
9564 cancelable: false
9565 };
9566 var playing = {
9567 eventInterface: "Event",
9568 bubbles: false,
9569 cancelable: false
9570 };
9571 var popstate = {
9572 eventInterface: "PopStateEvent",
9573 bubbles: true,
9574 cancelable: false
9575 };
9576 var progress = {
9577 eventInterface: "ProgressEvent",
9578 bubbles: false,
9579 cancelable: false
9580 };
9581 var push = {
9582 eventInterface: "PushEvent",
9583 bubbles: false,
9584 cancelable: false
9585 };
9586 var pushsubscriptionchange = {
9587 eventInterface: "PushEvent",
9588 bubbles: false,
9589 cancelable: false
9590 };
9591 var ratechange = {
9592 eventInterface: "Event",
9593 bubbles: false,
9594 cancelable: false
9595 };
9596 var readystatechange = {
9597 eventInterface: "Event",
9598 bubbles: false,
9599 cancelable: false
9600 };
9601 var repeatEvent = {
9602 eventInterface: "TimeEvent",
9603 bubbles: false,
9604 cancelable: false
9605 };
9606 var reset = {
9607 eventInterface: "Event",
9608 bubbles: true,
9609 cancelable: true
9610 };
9611 var resize = {
9612 eventInterface: "UIEvent",
9613 bubbles: false,
9614 cancelable: false
9615 };
9616 var resourcetimingbufferfull = {
9617 eventInterface: "Performance",
9618 bubbles: true,
9619 cancelable: true
9620 };
9621 var result = {
9622 eventInterface: "SpeechRecognitionEvent",
9623 bubbles: false,
9624 cancelable: false
9625 };
9626 var resume = {
9627 eventInterface: "SpeechSynthesisEvent",
9628 bubbles: false,
9629 cancelable: false
9630 };
9631 var scroll = {
9632 eventInterface: "UIEvent",
9633 bubbles: false,
9634 cancelable: false
9635 };
9636 var seeked = {
9637 eventInterface: "Event",
9638 bubbles: false,
9639 cancelable: false
9640 };
9641 var seeking = {
9642 eventInterface: "Event",
9643 bubbles: false,
9644 cancelable: false
9645 };
9646 var select = {
9647 eventInterface: "UIEvent",
9648 bubbles: true,
9649 cancelable: false
9650 };
9651 var selectstart = {
9652 eventInterface: "Event",
9653 bubbles: true,
9654 cancelable: true
9655 };
9656 var selectionchange = {
9657 eventInterface: "Event",
9658 bubbles: false,
9659 cancelable: false
9660 };
9661 var show = {
9662 eventInterface: "MouseEvent",
9663 bubbles: false,
9664 cancelable: false
9665 };
9666 var slotchange = {
9667 eventInterface: "Event",
9668 bubbles: true,
9669 cancelable: false
9670 };
9671 var soundend = {
9672 eventInterface: "Event",
9673 bubbles: false,
9674 cancelable: false
9675 };
9676 var soundstart = {
9677 eventInterface: "Event",
9678 bubbles: false,
9679 cancelable: false
9680 };
9681 var speechend = {
9682 eventInterface: "Event",
9683 bubbles: false,
9684 cancelable: false
9685 };
9686 var speechstart = {
9687 eventInterface: "Event",
9688 bubbles: false,
9689 cancelable: false
9690 };
9691 var stalled = {
9692 eventInterface: "Event",
9693 bubbles: false,
9694 cancelable: false
9695 };
9696 var start = {
9697 eventInterface: "SpeechSynthesisEvent",
9698 bubbles: false,
9699 cancelable: false
9700 };
9701 var storage = {
9702 eventInterface: "StorageEvent",
9703 bubbles: false,
9704 cancelable: false
9705 };
9706 var submit = {
9707 eventInterface: "Event",
9708 bubbles: true,
9709 cancelable: true
9710 };
9711 var success = {
9712 eventInterface: "Event",
9713 bubbles: false,
9714 cancelable: false
9715 };
9716 var suspend = {
9717 eventInterface: "Event",
9718 bubbles: false,
9719 cancelable: false
9720 };
9721 var SVGAbort = {
9722 eventInterface: "SVGEvent",
9723 bubbles: true,
9724 cancelable: false
9725 };
9726 var SVGError = {
9727 eventInterface: "SVGEvent",
9728 bubbles: true,
9729 cancelable: false
9730 };
9731 var SVGLoad = {
9732 eventInterface: "SVGEvent",
9733 bubbles: false,
9734 cancelable: false
9735 };
9736 var SVGResize = {
9737 eventInterface: "SVGEvent",
9738 bubbles: true,
9739 cancelable: false
9740 };
9741 var SVGScroll = {
9742 eventInterface: "SVGEvent",
9743 bubbles: true,
9744 cancelable: false
9745 };
9746 var SVGUnload = {
9747 eventInterface: "SVGEvent",
9748 bubbles: false,
9749 cancelable: false
9750 };
9751 var SVGZoom = {
9752 eventInterface: "SVGZoomEvent",
9753 bubbles: true,
9754 cancelable: false
9755 };
9756 var timeout = {
9757 eventInterface: "ProgressEvent",
9758 bubbles: false,
9759 cancelable: false
9760 };
9761 var timeupdate = {
9762 eventInterface: "Event",
9763 bubbles: false,
9764 cancelable: false
9765 };
9766 var touchcancel = {
9767 eventInterface: "TouchEvent",
9768 bubbles: true,
9769 cancelable: false
9770 };
9771 var touchend = {
9772 eventInterface: "TouchEvent",
9773 bubbles: true,
9774 cancelable: true
9775 };
9776 var touchmove = {
9777 eventInterface: "TouchEvent",
9778 bubbles: true,
9779 cancelable: true
9780 };
9781 var touchstart = {
9782 eventInterface: "TouchEvent",
9783 bubbles: true,
9784 cancelable: true
9785 };
9786 var transitionend = {
9787 eventInterface: "TransitionEvent",
9788 bubbles: true,
9789 cancelable: true
9790 };
9791 var unload = {
9792 eventInterface: "UIEvent",
9793 bubbles: false
9794 };
9795 var updateready = {
9796 eventInterface: "Event",
9797 bubbles: false,
9798 cancelable: false
9799 };
9800 var userproximity = {
9801 eventInterface: "UserProximityEvent",
9802 bubbles: false,
9803 cancelable: false
9804 };
9805 var voiceschanged = {
9806 eventInterface: "Event",
9807 bubbles: false,
9808 cancelable: false
9809 };
9810 var visibilitychange = {
9811 eventInterface: "Event",
9812 bubbles: true,
9813 cancelable: false
9814 };
9815 var volumechange = {
9816 eventInterface: "Event",
9817 bubbles: false,
9818 cancelable: false
9819 };
9820 var waiting = {
9821 eventInterface: "Event",
9822 bubbles: false,
9823 cancelable: false
9824 };
9825 var wheel = {
9826 eventInterface: "WheelEvent",
9827 bubbles: true,
9828 cancelable: true
9829 };
9830 var domEventTypes = {
9831 abort: abort,
9832 afterprint: afterprint,
9833 animationend: animationend,
9834 animationiteration: animationiteration,
9835 animationstart: animationstart,
9836 appinstalled: appinstalled,
9837 audioprocess: audioprocess,
9838 audioend: audioend,
9839 audiostart: audiostart,
9840 beforeprint: beforeprint,
9841 beforeunload: beforeunload,
9842 beginEvent: beginEvent,
9843 blur: blur,
9844 boundary: boundary,
9845 cached: cached,
9846 canplay: canplay,
9847 canplaythrough: canplaythrough,
9848 change: change,
9849 chargingchange: chargingchange,
9850 chargingtimechange: chargingtimechange,
9851 checking: checking,
9852 click: click,
9853 close: close,
9854 complete: complete,
9855 compositionend: compositionend,
9856 compositionstart: compositionstart,
9857 compositionupdate: compositionupdate,
9858 contextmenu: contextmenu,
9859 copy: copy,
9860 cut: cut,
9861 dblclick: dblclick,
9862 devicechange: devicechange,
9863 devicelight: devicelight,
9864 devicemotion: devicemotion,
9865 deviceorientation: deviceorientation,
9866 deviceproximity: deviceproximity,
9867 dischargingtimechange: dischargingtimechange,
9868 DOMActivate: DOMActivate,
9869 DOMAttributeNameChanged: DOMAttributeNameChanged,
9870 DOMAttrModified: DOMAttrModified,
9871 DOMCharacterDataModified: DOMCharacterDataModified,
9872 DOMContentLoaded: DOMContentLoaded,
9873 DOMElementNameChanged: DOMElementNameChanged,
9874 DOMFocusIn: DOMFocusIn,
9875 DOMFocusOut: DOMFocusOut,
9876 DOMNodeInserted: DOMNodeInserted,
9877 DOMNodeInsertedIntoDocument: DOMNodeInsertedIntoDocument,
9878 DOMNodeRemoved: DOMNodeRemoved,
9879 DOMNodeRemovedFromDocument: DOMNodeRemovedFromDocument,
9880 DOMSubtreeModified: DOMSubtreeModified,
9881 downloading: downloading,
9882 drag: drag,
9883 dragend: dragend,
9884 dragenter: dragenter,
9885 dragleave: dragleave,
9886 dragover: dragover,
9887 dragstart: dragstart,
9888 drop: drop,
9889 durationchange: durationchange,
9890 emptied: emptied,
9891 end: end,
9892 ended: ended,
9893 endEvent: endEvent,
9894 error: error,
9895 focus: focus,
9896 focusin: focusin,
9897 focusout: focusout,
9898 fullscreenchange: fullscreenchange,
9899 fullscreenerror: fullscreenerror,
9900 gamepadconnected: gamepadconnected,
9901 gamepaddisconnected: gamepaddisconnected,
9902 gotpointercapture: gotpointercapture,
9903 hashchange: hashchange,
9904 lostpointercapture: lostpointercapture,
9905 input: input,
9906 invalid: invalid,
9907 keydown: keydown,
9908 keypress: keypress,
9909 keyup: keyup,
9910 languagechange: languagechange,
9911 levelchange: levelchange,
9912 load: load,
9913 loadeddata: loadeddata,
9914 loadedmetadata: loadedmetadata,
9915 loadend: loadend,
9916 loadstart: loadstart,
9917 mark: mark,
9918 message: message,
9919 messageerror: messageerror,
9920 mousedown: mousedown,
9921 mouseenter: mouseenter,
9922 mouseleave: mouseleave,
9923 mousemove: mousemove,
9924 mouseout: mouseout,
9925 mouseover: mouseover,
9926 mouseup: mouseup,
9927 nomatch: nomatch,
9928 notificationclick: notificationclick,
9929 noupdate: noupdate,
9930 obsolete: obsolete,
9931 offline: offline,
9932 online: online,
9933 open: open,
9934 orientationchange: orientationchange,
9935 pagehide: pagehide,
9936 pageshow: pageshow,
9937 paste: paste,
9938 pause: pause,
9939 pointercancel: pointercancel,
9940 pointerdown: pointerdown,
9941 pointerenter: pointerenter,
9942 pointerleave: pointerleave,
9943 pointerlockchange: pointerlockchange,
9944 pointerlockerror: pointerlockerror,
9945 pointermove: pointermove,
9946 pointerout: pointerout,
9947 pointerover: pointerover,
9948 pointerup: pointerup,
9949 play: play,
9950 playing: playing,
9951 popstate: popstate,
9952 progress: progress,
9953 push: push,
9954 pushsubscriptionchange: pushsubscriptionchange,
9955 ratechange: ratechange,
9956 readystatechange: readystatechange,
9957 repeatEvent: repeatEvent,
9958 reset: reset,
9959 resize: resize,
9960 resourcetimingbufferfull: resourcetimingbufferfull,
9961 result: result,
9962 resume: resume,
9963 scroll: scroll,
9964 seeked: seeked,
9965 seeking: seeking,
9966 select: select,
9967 selectstart: selectstart,
9968 selectionchange: selectionchange,
9969 show: show,
9970 slotchange: slotchange,
9971 soundend: soundend,
9972 soundstart: soundstart,
9973 speechend: speechend,
9974 speechstart: speechstart,
9975 stalled: stalled,
9976 start: start,
9977 storage: storage,
9978 submit: submit,
9979 success: success,
9980 suspend: suspend,
9981 SVGAbort: SVGAbort,
9982 SVGError: SVGError,
9983 SVGLoad: SVGLoad,
9984 SVGResize: SVGResize,
9985 SVGScroll: SVGScroll,
9986 SVGUnload: SVGUnload,
9987 SVGZoom: SVGZoom,
9988 timeout: timeout,
9989 timeupdate: timeupdate,
9990 touchcancel: touchcancel,
9991 touchend: touchend,
9992 touchmove: touchmove,
9993 touchstart: touchstart,
9994 transitionend: transitionend,
9995 unload: unload,
9996 updateready: updateready,
9997 userproximity: userproximity,
9998 voiceschanged: voiceschanged,
9999 visibilitychange: visibilitychange,
10000 volumechange: volumechange,
10001 waiting: waiting,
10002 wheel: wheel
10003 };
10004
10005 var domEventTypes$1 = /*#__PURE__*/Object.freeze({
10006 __proto__: null,
10007 abort: abort,
10008 afterprint: afterprint,
10009 animationend: animationend,
10010 animationiteration: animationiteration,
10011 animationstart: animationstart,
10012 appinstalled: appinstalled,
10013 audioprocess: audioprocess,
10014 audioend: audioend,
10015 audiostart: audiostart,
10016 beforeprint: beforeprint,
10017 beforeunload: beforeunload,
10018 beginEvent: beginEvent,
10019 blur: blur,
10020 boundary: boundary,
10021 cached: cached,
10022 canplay: canplay,
10023 canplaythrough: canplaythrough,
10024 change: change,
10025 chargingchange: chargingchange,
10026 chargingtimechange: chargingtimechange,
10027 checking: checking,
10028 click: click,
10029 close: close,
10030 complete: complete,
10031 compositionend: compositionend,
10032 compositionstart: compositionstart,
10033 compositionupdate: compositionupdate,
10034 contextmenu: contextmenu,
10035 copy: copy,
10036 cut: cut,
10037 dblclick: dblclick,
10038 devicechange: devicechange,
10039 devicelight: devicelight,
10040 devicemotion: devicemotion,
10041 deviceorientation: deviceorientation,
10042 deviceproximity: deviceproximity,
10043 dischargingtimechange: dischargingtimechange,
10044 DOMActivate: DOMActivate,
10045 DOMAttributeNameChanged: DOMAttributeNameChanged,
10046 DOMAttrModified: DOMAttrModified,
10047 DOMCharacterDataModified: DOMCharacterDataModified,
10048 DOMContentLoaded: DOMContentLoaded,
10049 DOMElementNameChanged: DOMElementNameChanged,
10050 DOMFocusIn: DOMFocusIn,
10051 DOMFocusOut: DOMFocusOut,
10052 DOMNodeInserted: DOMNodeInserted,
10053 DOMNodeInsertedIntoDocument: DOMNodeInsertedIntoDocument,
10054 DOMNodeRemoved: DOMNodeRemoved,
10055 DOMNodeRemovedFromDocument: DOMNodeRemovedFromDocument,
10056 DOMSubtreeModified: DOMSubtreeModified,
10057 downloading: downloading,
10058 drag: drag,
10059 dragend: dragend,
10060 dragenter: dragenter,
10061 dragleave: dragleave,
10062 dragover: dragover,
10063 dragstart: dragstart,
10064 drop: drop,
10065 durationchange: durationchange,
10066 emptied: emptied,
10067 end: end,
10068 ended: ended,
10069 endEvent: endEvent,
10070 error: error,
10071 focus: focus,
10072 focusin: focusin,
10073 focusout: focusout,
10074 fullscreenchange: fullscreenchange,
10075 fullscreenerror: fullscreenerror,
10076 gamepadconnected: gamepadconnected,
10077 gamepaddisconnected: gamepaddisconnected,
10078 gotpointercapture: gotpointercapture,
10079 hashchange: hashchange,
10080 lostpointercapture: lostpointercapture,
10081 input: input,
10082 invalid: invalid,
10083 keydown: keydown,
10084 keypress: keypress,
10085 keyup: keyup,
10086 languagechange: languagechange,
10087 levelchange: levelchange,
10088 load: load,
10089 loadeddata: loadeddata,
10090 loadedmetadata: loadedmetadata,
10091 loadend: loadend,
10092 loadstart: loadstart,
10093 mark: mark,
10094 message: message,
10095 messageerror: messageerror,
10096 mousedown: mousedown,
10097 mouseenter: mouseenter,
10098 mouseleave: mouseleave,
10099 mousemove: mousemove,
10100 mouseout: mouseout,
10101 mouseover: mouseover,
10102 mouseup: mouseup,
10103 nomatch: nomatch,
10104 notificationclick: notificationclick,
10105 noupdate: noupdate,
10106 obsolete: obsolete,
10107 offline: offline,
10108 online: online,
10109 open: open,
10110 orientationchange: orientationchange,
10111 pagehide: pagehide,
10112 pageshow: pageshow,
10113 paste: paste,
10114 pause: pause,
10115 pointercancel: pointercancel,
10116 pointerdown: pointerdown,
10117 pointerenter: pointerenter,
10118 pointerleave: pointerleave,
10119 pointerlockchange: pointerlockchange,
10120 pointerlockerror: pointerlockerror,
10121 pointermove: pointermove,
10122 pointerout: pointerout,
10123 pointerover: pointerover,
10124 pointerup: pointerup,
10125 play: play,
10126 playing: playing,
10127 popstate: popstate,
10128 progress: progress,
10129 push: push,
10130 pushsubscriptionchange: pushsubscriptionchange,
10131 ratechange: ratechange,
10132 readystatechange: readystatechange,
10133 repeatEvent: repeatEvent,
10134 reset: reset,
10135 resize: resize,
10136 resourcetimingbufferfull: resourcetimingbufferfull,
10137 result: result,
10138 resume: resume,
10139 scroll: scroll,
10140 seeked: seeked,
10141 seeking: seeking,
10142 select: select,
10143 selectstart: selectstart,
10144 selectionchange: selectionchange,
10145 show: show,
10146 slotchange: slotchange,
10147 soundend: soundend,
10148 soundstart: soundstart,
10149 speechend: speechend,
10150 speechstart: speechstart,
10151 stalled: stalled,
10152 start: start,
10153 storage: storage,
10154 submit: submit,
10155 success: success,
10156 suspend: suspend,
10157 SVGAbort: SVGAbort,
10158 SVGError: SVGError,
10159 SVGLoad: SVGLoad,
10160 SVGResize: SVGResize,
10161 SVGScroll: SVGScroll,
10162 SVGUnload: SVGUnload,
10163 SVGZoom: SVGZoom,
10164 timeout: timeout,
10165 timeupdate: timeupdate,
10166 touchcancel: touchcancel,
10167 touchend: touchend,
10168 touchmove: touchmove,
10169 touchstart: touchstart,
10170 transitionend: transitionend,
10171 unload: unload,
10172 updateready: updateready,
10173 userproximity: userproximity,
10174 voiceschanged: voiceschanged,
10175 visibilitychange: visibilitychange,
10176 volumechange: volumechange,
10177 waiting: waiting,
10178 wheel: wheel,
10179 'default': domEventTypes
10180 });
10181
10182 var require$$0 = getCjsExportFromNamespace(domEventTypes$1);
10183
10184 var domEventTypes$2 = require$$0;
10185
10186 var defaultEventType = {
10187 eventInterface: 'Event',
10188 cancelable: true,
10189 bubbles: true
10190 };
10191
10192 var modifiers = {
10193 enter: 13,
10194 tab: 9,
10195 delete: 46,
10196 esc: 27,
10197 space: 32,
10198 up: 38,
10199 down: 40,
10200 left: 37,
10201 right: 39,
10202 end: 35,
10203 home: 36,
10204 backspace: 8,
10205 insert: 45,
10206 pageup: 33,
10207 pagedown: 34
10208 };
10209
10210 function getOptions(eventParams) {
10211 var modifier = eventParams.modifier;
10212 var meta = eventParams.meta;
10213 var options = eventParams.options;
10214 var keyCode = modifiers[modifier] || options.keyCode || options.code;
10215
10216 return Object.assign({}, options, // What the user passed in as the second argument to #trigger
10217
10218 {bubbles: meta.bubbles,
10219 cancelable: meta.cancelable,
10220
10221 // Any derived options should go here
10222 keyCode: keyCode,
10223 code: keyCode})
10224 }
10225
10226 function createEvent(eventParams) {
10227 var eventType = eventParams.eventType;
10228 var meta = eventParams.meta; if ( meta === void 0 ) meta = {};
10229
10230 var SupportedEventInterface =
10231 typeof window[meta.eventInterface] === 'function'
10232 ? window[meta.eventInterface]
10233 : window.Event;
10234
10235 var event = new SupportedEventInterface(
10236 eventType,
10237 // event properties can only be added when the event is instantiated
10238 // custom properties must be added after the event has been instantiated
10239 getOptions(eventParams)
10240 );
10241
10242 return event
10243 }
10244
10245 function createOldEvent(eventParams) {
10246 var eventType = eventParams.eventType;
10247 var modifier = eventParams.modifier;
10248 var meta = eventParams.meta;
10249 var bubbles = meta.bubbles;
10250 var cancelable = meta.cancelable;
10251
10252 var event = document.createEvent('Event');
10253 event.initEvent(eventType, bubbles, cancelable);
10254 event.keyCode = modifiers[modifier];
10255 return event
10256 }
10257
10258 function createDOMEvent(type, options) {
10259 var ref = type.split('.');
10260 var eventType = ref[0];
10261 var modifier = ref[1];
10262 var meta = domEventTypes$2[eventType] || defaultEventType;
10263
10264 var eventParams = { eventType: eventType, modifier: modifier, meta: meta, options: options };
10265
10266 // Fallback for IE10,11 - https://stackoverflow.com/questions/26596123
10267 var event =
10268 typeof window.Event === 'function'
10269 ? createEvent(eventParams)
10270 : createOldEvent(eventParams);
10271
10272 var eventPrototype = Object.getPrototypeOf(event);
10273 Object.keys(options || {}).forEach(function (key) {
10274 var propertyDescriptor = Object.getOwnPropertyDescriptor(
10275 eventPrototype,
10276 key
10277 );
10278
10279 var canSetProperty = !(
10280 propertyDescriptor && propertyDescriptor.setter === undefined
10281 );
10282 if (canSetProperty) {
10283 event[key] = options[key];
10284 }
10285 });
10286
10287 return event
10288 }
10289
10290 //
10291
10292 var Wrapper = function Wrapper(
10293 node,
10294 options,
10295 isVueWrapper
10296 ) {
10297 var vnode = node instanceof Element ? null : node;
10298 var element = node instanceof Element ? node : node.elm;
10299 // Prevent redefine by VueWrapper
10300 if (!isVueWrapper) {
10301 // $FlowIgnore : issue with defineProperty
10302 Object.defineProperty(this, 'rootNode', {
10303 get: function () { return vnode || element; },
10304 set: function () { return throwError('wrapper.rootNode is read-only'); }
10305 });
10306 // $FlowIgnore
10307 Object.defineProperty(this, 'vnode', {
10308 get: function () { return vnode; },
10309 set: function () { return throwError('wrapper.vnode is read-only'); }
10310 });
10311 // $FlowIgnore
10312 Object.defineProperty(this, 'element', {
10313 get: function () { return element; },
10314 set: function () { return throwError('wrapper.element is read-only'); }
10315 });
10316 // $FlowIgnore
10317 Object.defineProperty(this, 'vm', {
10318 get: function () { return undefined; },
10319 set: function () { return throwError('wrapper.vm is read-only'); }
10320 });
10321 }
10322 var frozenOptions = Object.freeze(options);
10323 // $FlowIgnore
10324 Object.defineProperty(this, 'options', {
10325 get: function () { return frozenOptions; },
10326 set: function () { return throwError('wrapper.options is read-only'); }
10327 });
10328 if (
10329 this.vnode &&
10330 (this.vnode[FUNCTIONAL_OPTIONS] || this.vnode.functionalContext)
10331 ) {
10332 this.isFunctionalComponent = true;
10333 }
10334 };
10335
10336 Wrapper.prototype.at = function at () {
10337 throwError('at() must be called on a WrapperArray');
10338 };
10339
10340 /**
10341 * Returns an Object containing all the attribute/value pairs on the element.
10342 */
10343 Wrapper.prototype.attributes = function attributes (key) {
10344 var attributes = this.element.attributes;
10345 var attributeMap = {};
10346 for (var i = 0; i < attributes.length; i++) {
10347 var att = attributes.item(i);
10348 attributeMap[att.localName] = att.value;
10349 }
10350
10351 return key ? attributeMap[key] : attributeMap
10352 };
10353
10354 /**
10355 * Returns an Array containing all the classes on the element
10356 */
10357 Wrapper.prototype.classes = function classes (className) {
10358 var this$1 = this;
10359
10360 var classAttribute = this.element.getAttribute('class');
10361 var classes = classAttribute ? classAttribute.split(' ') : [];
10362 // Handle converting cssmodules identifiers back to the original class name
10363 if (this.vm && this.vm.$style) {
10364 var cssModuleIdentifiers = Object.keys(this.vm.$style).reduce(
10365 function (acc, key) {
10366 // $FlowIgnore
10367 var moduleIdent = this$1.vm.$style[key];
10368 if (moduleIdent) {
10369 acc[moduleIdent.split(' ')[0]] = key;
10370 }
10371 return acc
10372 },
10373 {}
10374 );
10375 classes = classes.map(function (name) { return cssModuleIdentifiers[name] || name; });
10376 }
10377
10378 return className ? !!(classes.indexOf(className) > -1) : classes
10379 };
10380
10381 /**
10382 * Checks if wrapper contains provided selector.
10383 * @deprecated
10384 */
10385 Wrapper.prototype.contains = function contains (rawSelector) {
10386 warnDeprecated(
10387 'contains',
10388 'Use `wrapper.find`, `wrapper.findComponent` or `wrapper.get` instead'
10389 );
10390 var selector = getSelector(rawSelector, 'contains');
10391 var nodes = find(this.rootNode, this.vm, selector);
10392 return nodes.length > 0
10393 };
10394
10395 /**
10396 * Calls destroy on vm
10397 */
10398 Wrapper.prototype.destroy = function destroy () {
10399 if (!this.vm && !this.isFunctionalComponent) {
10400 throwError(
10401 "wrapper.destroy() can only be called on a Vue instance or " +
10402 "functional component."
10403 );
10404 }
10405
10406 if (this.element.parentNode) {
10407 this.element.parentNode.removeChild(this.element);
10408 }
10409
10410 if (this.vm) {
10411 // $FlowIgnore
10412 this.vm.$destroy();
10413 throwIfInstancesThrew(this.vm);
10414 }
10415 };
10416
10417 /**
10418 * Returns an object containing custom events emitted by the Wrapper vm
10419 */
10420 Wrapper.prototype.emitted = function emitted (
10421 event
10422 ) {
10423 if (!this._emitted && !this.vm) {
10424 throwError("wrapper.emitted() can only be called on a Vue instance");
10425 }
10426 if (event) {
10427 return this._emitted[event]
10428 }
10429 return this._emitted
10430 };
10431
10432 /**
10433 * Returns an Array containing custom events emitted by the Wrapper vm
10434 * @deprecated
10435 */
10436 Wrapper.prototype.emittedByOrder = function emittedByOrder () {
10437 warnDeprecated('emittedByOrder', 'Use `wrapper.emitted` instead');
10438 if (!this._emittedByOrder && !this.vm) {
10439 throwError(
10440 "wrapper.emittedByOrder() can only be called on a Vue instance"
10441 );
10442 }
10443 return this._emittedByOrder
10444 };
10445
10446 /**
10447 * Utility to check wrapper exists. Returns true as Wrapper always exists
10448 */
10449 Wrapper.prototype.exists = function exists () {
10450 if (this.vm) {
10451 return !!this.vm && !this.vm._isDestroyed
10452 }
10453 return true
10454 };
10455
10456 Wrapper.prototype.filter = function filter () {
10457 throwError('filter() must be called on a WrapperArray');
10458 };
10459
10460 /**
10461 * Gets first node in tree of the current wrapper that
10462 * matches the provided selector.
10463 */
10464 Wrapper.prototype.get = function get (rawSelector) {
10465 var found = this.find(rawSelector);
10466 if (found instanceof ErrorWrapper) {
10467 throw new Error(("Unable to find " + rawSelector + " within: " + (this.html())))
10468 }
10469 return found
10470 };
10471
10472 /**
10473 * Finds first DOM node in tree of the current wrapper that
10474 * matches the provided selector.
10475 */
10476 Wrapper.prototype.find = function find (rawSelector) {
10477 var selector = getSelector(rawSelector, 'find');
10478 if (selector.type !== DOM_SELECTOR) {
10479 warnDeprecated(
10480 'finding components with `find`',
10481 'Use `findComponent` instead'
10482 );
10483 }
10484
10485 return this.__find(rawSelector, selector)
10486 };
10487
10488 /**
10489 * Finds first component in tree of the current wrapper that
10490 * matches the provided selector.
10491 */
10492 Wrapper.prototype.findComponent = function findComponent (rawSelector) {
10493 var selector = getSelector(rawSelector, 'findComponent');
10494 if (!this.vm && !this.isFunctionalComponent) {
10495 throwError(
10496 'You cannot chain findComponent off a DOM element. It can only be used on Vue Components.'
10497 );
10498 }
10499
10500 if (selector.type === DOM_SELECTOR) {
10501 throwError(
10502 'findComponent requires a Vue constructor or valid find object. If you are searching for DOM nodes, use `find` instead'
10503 );
10504 }
10505
10506 return this.__find(rawSelector, selector)
10507 };
10508
10509 Wrapper.prototype.__find = function __find (rawSelector, selector) {
10510 var node = find(this.rootNode, this.vm, selector)[0];
10511
10512 if (!node) {
10513 return new ErrorWrapper(rawSelector)
10514 }
10515
10516 var wrapper = createWrapper(node, this.options);
10517 wrapper.selector = rawSelector;
10518 return wrapper
10519 };
10520
10521 /**
10522 * Finds DOM elements in tree of the current wrapper that matches
10523 * the provided selector.
10524 */
10525 Wrapper.prototype.findAll = function findAll (rawSelector) {
10526 var selector = getSelector(rawSelector, 'findAll');
10527 if (selector.type !== DOM_SELECTOR) {
10528 warnDeprecated(
10529 'finding components with `findAll`',
10530 'Use `findAllComponents` instead'
10531 );
10532 }
10533 return this.__findAll(rawSelector, selector)
10534 };
10535
10536 /**
10537 * Finds components in tree of the current wrapper that matches
10538 * the provided selector.
10539 */
10540 Wrapper.prototype.findAllComponents = function findAllComponents (rawSelector) {
10541 var selector = getSelector(rawSelector, 'findAll');
10542 if (!this.vm) {
10543 throwError(
10544 'You cannot chain findAllComponents off a DOM element. It can only be used on Vue Components.'
10545 );
10546 }
10547 if (selector.type === DOM_SELECTOR) {
10548 throwError(
10549 'findAllComponents requires a Vue constructor or valid find object. If you are searching for DOM nodes, use `find` instead'
10550 );
10551 }
10552 return this.__findAll(rawSelector, selector)
10553 };
10554
10555 Wrapper.prototype.__findAll = function __findAll (rawSelector, selector) {
10556 var this$1 = this;
10557
10558 var nodes = find(this.rootNode, this.vm, selector);
10559 var wrappers = nodes.map(function (node) {
10560 // Using CSS Selector, returns a VueWrapper instance if the root element
10561 // binds a Vue instance.
10562 var wrapper = createWrapper(node, this$1.options);
10563 wrapper.selector = rawSelector;
10564 return wrapper
10565 });
10566
10567 var wrapperArray = new WrapperArray(wrappers);
10568 wrapperArray.selector = rawSelector;
10569 return wrapperArray
10570 };
10571
10572 /**
10573 * Returns HTML of element as a string
10574 */
10575 Wrapper.prototype.html = function html () {
10576 return pretty(this.element.outerHTML)
10577 };
10578
10579 /**
10580 * Checks if node matches selector
10581 * @deprecated
10582 */
10583 Wrapper.prototype.is = function is (rawSelector) {
10584 warnDeprecated('is', 'Use element.tagName instead');
10585 var selector = getSelector(rawSelector, 'is');
10586
10587 if (selector.type === REF_SELECTOR) {
10588 throwError('$ref selectors can not be used with wrapper.is()');
10589 }
10590
10591 return matches(this.rootNode, selector)
10592 };
10593
10594 /**
10595 * Checks if node is empty
10596 * @deprecated
10597 */
10598 Wrapper.prototype.isEmpty = function isEmpty () {
10599 warnDeprecated(
10600 'isEmpty',
10601 'Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobeempty. ' +
10602 'When using with findComponent, access the DOM element with findComponent(Comp).element'
10603 );
10604 if (!this.vnode) {
10605 return this.element.innerHTML === ''
10606 }
10607 var nodes = [];
10608 var node = this.vnode;
10609 var i = 0;
10610
10611 while (node) {
10612 if (node.child) {
10613 nodes.push(node.child._vnode);
10614 }
10615 node.children &&
10616 node.children.forEach(function (n) {
10617 nodes.push(n);
10618 });
10619 node = nodes[i++];
10620 }
10621 return nodes.every(function (n) { return n.isComment || n.child; })
10622 };
10623
10624 /**
10625 * Checks if node is visible
10626 * @deprecated
10627 */
10628 Wrapper.prototype.isVisible = function isVisible () {
10629 warnDeprecated(
10630 'isVisible',
10631 'Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobevisible. ' +
10632 'When using with findComponent, access the DOM element with findComponent(Comp).element'
10633 );
10634 var element = this.element;
10635 while (element) {
10636 if (
10637 element.hidden ||
10638 (element.style &&
10639 (element.style.visibility === 'hidden' ||
10640 element.style.display === 'none'))
10641 ) {
10642 return false
10643 }
10644 element = element.parentElement;
10645 }
10646
10647 return true
10648 };
10649
10650 /**
10651 * Checks if wrapper is a vue instance
10652 * @deprecated
10653 */
10654 Wrapper.prototype.isVueInstance = function isVueInstance () {
10655 warnDeprecated("isVueInstance");
10656 return !!this.vm
10657 };
10658
10659 /**
10660 * Returns name of component, or tag name if node is not a Vue component
10661 * @deprecated
10662 */
10663 Wrapper.prototype.name = function name () {
10664 warnDeprecated("name");
10665
10666 if (this.vm) {
10667 return (
10668 this.vm.$options.name ||
10669 // compat for Vue < 2.3
10670 (this.vm.$options.extendOptions && this.vm.$options.extendOptions.name)
10671 )
10672 }
10673
10674 if (!this.vnode) {
10675 return this.element.tagName
10676 }
10677
10678 return this.vnode.tag
10679 };
10680
10681 /**
10682 * Prints a simple overview of the wrapper current state
10683 * with useful information for debugging
10684 * @deprecated
10685 */
10686 Wrapper.prototype.overview = function overview () {
10687 var this$1 = this;
10688
10689 warnDeprecated("overview");
10690
10691 if (!this.vm) {
10692 throwError("wrapper.overview() can only be called on a Vue instance");
10693 }
10694
10695 var identation = 4;
10696 var formatJSON = function (json, replacer) {
10697 if ( replacer === void 0 ) replacer = null;
10698
10699 return JSON.stringify(json, replacer, identation).replace(/"/g, '');
10700 };
10701
10702 var visibility = this.isVisible() ? 'Visible' : 'Not visible';
10703
10704 var html = this.html()
10705 ? this.html().replace(/^(?!\s*$)/gm, ' '.repeat(identation)) + '\n'
10706 : '';
10707
10708 // $FlowIgnore
10709 var data = formatJSON(this.vm.$data);
10710
10711 /* eslint-disable operator-linebreak */
10712 // $FlowIgnore
10713 var computed = this.vm._computedWatchers
10714 ? formatJSON.apply(
10715 // $FlowIgnore
10716 void 0, Object.keys(this.vm._computedWatchers).map(function (computedKey) {
10717 var obj;
10718
10719 return (( obj = {}, obj[computedKey] = this$1.vm[computedKey], obj ));
10720 })
10721 )
10722 : // $FlowIgnore
10723 this.vm.$options.computed
10724 ? formatJSON.apply(
10725 // $FlowIgnore
10726 void 0, Object.entries(this.vm.$options.computed).map(function (ref) {
10727 var obj;
10728
10729 var key = ref[0];
10730 var value = ref[1];
10731 return (( obj = {}, obj[key] = value(), obj ));
10732 })
10733 )
10734 : '{}';
10735 /* eslint-enable operator-linebreak */
10736
10737 var emittedJSONReplacer = function (key, value) { return value instanceof Array
10738 ? value.map(function (calledWith, index) {
10739 var callParams = calledWith.map(function (param) { return typeof param === 'object'
10740 ? JSON.stringify(param)
10741 .replace(/"/g, '')
10742 .replace(/,/g, ', ')
10743 : param; }
10744 );
10745
10746 return (index + ": [ " + (callParams.join(', ')) + " ]")
10747 })
10748 : value; };
10749
10750 var emitted = formatJSON(this.emitted(), emittedJSONReplacer);
10751
10752 console.log(
10753 '\n' +
10754 "Wrapper (" + visibility + "):\n\n" +
10755 "Html:\n" + html + "\n" +
10756 "Data: " + data + "\n\n" +
10757 "Computed: " + computed + "\n\n" +
10758 "Emitted: " + emitted + "\n"
10759 );
10760 };
10761
10762 /**
10763 * Returns an Object containing the prop name/value pairs on the element
10764 */
10765 Wrapper.prototype.props = function props (key) {
10766 var this$1 = this;
10767
10768 if (this.isFunctionalComponent) {
10769 throwError(
10770 "wrapper.props() cannot be called on a mounted functional component."
10771 );
10772 }
10773 if (!this.vm) {
10774 throwError('wrapper.props() must be called on a Vue instance');
10775 }
10776
10777 var props = {};
10778 var keys = this.vm && this.vm.$options._propKeys;
10779
10780 if (keys) {
10781 (keys || {}).forEach(function (key) {
10782 if (this$1.vm) {
10783 props[key] = this$1.vm[key];
10784 }
10785 });
10786 }
10787
10788 if (key) {
10789 return props[key]
10790 }
10791
10792 return props
10793 };
10794
10795 /**
10796 * Checks radio button or checkbox element
10797 * @deprecated
10798 */
10799 Wrapper.prototype.setChecked = function setChecked (checked) {
10800 if ( checked === void 0 ) checked = true;
10801
10802 if (typeof checked !== 'boolean') {
10803 throwError('wrapper.setChecked() must be passed a boolean');
10804 }
10805 var tagName = this.element.tagName;
10806 // $FlowIgnore
10807 var type = this.attributes().type;
10808 var event = getCheckedEvent();
10809
10810 if (tagName === 'INPUT' && type === 'checkbox') {
10811 if (this.element.checked === checked) {
10812 return nextTick()
10813 }
10814 if (event !== 'click' || isPhantomJS) {
10815 // $FlowIgnore
10816 this.element.checked = checked;
10817 }
10818 return this.trigger(event)
10819 }
10820
10821 if (tagName === 'INPUT' && type === 'radio') {
10822 if (!checked) {
10823 throwError(
10824 "wrapper.setChecked() cannot be called with parameter false on a " +
10825 "<input type=\"radio\" /> element."
10826 );
10827 }
10828
10829 if (this.element.checked === checked) {
10830 return nextTick()
10831 }
10832
10833 if (event !== 'click' || isPhantomJS) {
10834 // $FlowIgnore
10835 this.element.selected = true;
10836 }
10837 return this.trigger(event)
10838 }
10839
10840 throwError("wrapper.setChecked() cannot be called on this element");
10841 return nextTick()
10842 };
10843
10844 /**
10845 * Selects <option></option> element
10846 * @deprecated
10847 */
10848 Wrapper.prototype.setSelected = function setSelected () {
10849 var tagName = this.element.tagName;
10850
10851 if (tagName === 'SELECT') {
10852 throwError(
10853 "wrapper.setSelected() cannot be called on select. Call it on one of " +
10854 "its options"
10855 );
10856 }
10857
10858 if (tagName !== 'OPTION') {
10859 throwError("wrapper.setSelected() cannot be called on this element");
10860 }
10861
10862 if (this.element.selected) {
10863 return nextTick()
10864 }
10865
10866 // $FlowIgnore
10867 this.element.selected = true;
10868 // $FlowIgnore
10869 var parentElement = this.element.parentElement;
10870
10871 // $FlowIgnore
10872 if (parentElement.tagName === 'OPTGROUP') {
10873 // $FlowIgnore
10874 parentElement = parentElement.parentElement;
10875 }
10876
10877 // $FlowIgnore
10878 return createWrapper(parentElement, this.options).trigger('change')
10879 };
10880
10881 /**
10882 * Sets vm data
10883 */
10884 Wrapper.prototype.setData = function setData (data) {
10885 if (this.isFunctionalComponent) {
10886 throwError("wrapper.setData() cannot be called on a functional component");
10887 }
10888
10889 if (!this.vm) {
10890 throwError("wrapper.setData() can only be called on a Vue instance");
10891 }
10892
10893 recursivelySetData(this.vm, this.vm, data);
10894 return nextTick()
10895 };
10896
10897 /**
10898 * Sets vm methods
10899 * @deprecated
10900 */
10901 Wrapper.prototype.setMethods = function setMethods (methods) {
10902 var this$1 = this;
10903
10904 warnDeprecated(
10905 "setMethods",
10906 "There is no clear migration path for setMethods - Vue does not support arbitrarily replacement of methods, nor should VTU. To stub a complex method extract it from the component and test it in isolation. Otherwise, the suggestion is to rethink those tests"
10907 );
10908
10909 if (!this.vm) {
10910 throwError("wrapper.setMethods() can only be called on a Vue instance");
10911 }
10912 Object.keys(methods).forEach(function (key) {
10913 // $FlowIgnore : Problem with possibly null this.vm
10914 this$1.vm[key] = methods[key];
10915 // $FlowIgnore : Problem with possibly null this.vm
10916 this$1.vm.$options.methods[key] = methods[key];
10917 });
10918
10919 if (this.vnode) {
10920 var context = this.vnode.context;
10921 if (context.$options.render) { context._update(context._render()); }
10922 }
10923 };
10924
10925 /**
10926 * Sets vm props
10927 */
10928 Wrapper.prototype.setProps = function setProps (data) {
10929 var this$1 = this;
10930
10931 // Validate the setProps method call
10932 if (this.isFunctionalComponent) {
10933 throwError(
10934 "wrapper.setProps() cannot be called on a functional component"
10935 );
10936 }
10937
10938 if (!this.vm) {
10939 throwError("wrapper.setProps() can only be called on a Vue instance");
10940 }
10941
10942 // Save the original "silent" config so that we can directly mutate props
10943 var originalConfig = Vue.config.silent;
10944 Vue.config.silent = config.silent;
10945
10946 try {
10947 Object.keys(data).forEach(function (key) {
10948 // Don't let people set entire objects, because reactivity won't work
10949 if (
10950 typeof data[key] === 'object' &&
10951 data[key] !== null &&
10952 // $FlowIgnore : Problem with possibly null this.vm
10953 data[key] === this$1.vm[key]
10954 ) {
10955 throwError(
10956 "wrapper.setProps() called with the same object of the existing " +
10957 key + " property. You must call wrapper.setProps() with a new " +
10958 "object to trigger reactivity"
10959 );
10960 }
10961
10962 if (
10963 !this$1.vm ||
10964 !this$1.vm.$options._propKeys ||
10965 !this$1.vm.$options._propKeys.some(function (prop) { return prop === key; })
10966 ) {
10967 if (VUE_VERSION > 2.3) {
10968 // $FlowIgnore : Problem with possibly null this.vm
10969 this$1.vm.$attrs[key] = data[key];
10970 return nextTick()
10971 }
10972 throwError(
10973 "wrapper.setProps() called with " + key + " property which " +
10974 "is not defined on the component"
10975 );
10976 }
10977
10978 // Actually set the prop
10979 // $FlowIgnore : Problem with possibly null this.vm
10980 this$1.vm[key] = data[key];
10981 });
10982
10983 // $FlowIgnore : Problem with possibly null this.vm
10984 this.vm.$forceUpdate();
10985 return new Promise(function (resolve) {
10986 nextTick().then(function () {
10987 var isUpdated = Object.keys(data).some(function (key) {
10988 return (
10989 // $FlowIgnore : Problem with possibly null this.vm
10990 this$1.vm[key] === data[key] ||
10991 // $FlowIgnore : Problem with possibly null this.vm
10992 (this$1.vm.$attrs && this$1.vm.$attrs[key] === data[key])
10993 )
10994 });
10995 return !isUpdated ? this$1.setProps(data).then(resolve()) : resolve()
10996 });
10997 })
10998 } catch (err) {
10999 throw err
11000 } finally {
11001 // Ensure you teardown the modifications you made to the user's config
11002 // After all the props are set, then reset the state
11003 Vue.config.silent = originalConfig;
11004 }
11005 };
11006
11007 /**
11008 * Sets element value and triggers input event
11009 */
11010 Wrapper.prototype.setValue = function setValue (value) {
11011 var tagName = this.element.tagName;
11012 // $FlowIgnore
11013 var type = this.attributes().type;
11014
11015 if (tagName === 'OPTION') {
11016 throwError(
11017 "wrapper.setValue() cannot be called on an <option> element. Use " +
11018 "wrapper.setSelected() instead"
11019 );
11020 } else if (tagName === 'INPUT' && type === 'checkbox') {
11021 throwError(
11022 "wrapper.setValue() cannot be called on a <input type=\"checkbox\" /> " +
11023 "element. Use wrapper.setChecked() instead"
11024 );
11025 } else if (tagName === 'INPUT' && type === 'radio') {
11026 throwError(
11027 "wrapper.setValue() cannot be called on a <input type=\"radio\" /> " +
11028 "element. Use wrapper.setChecked() instead"
11029 );
11030 } else if (tagName === 'SELECT') {
11031 if (Array.isArray(value)) {
11032 // $FlowIgnore
11033 var options = this.element.options;
11034 for (var i = 0; i < options.length; i++) {
11035 var option = options[i];
11036 option.selected = value.indexOf(option.value) >= 0;
11037 }
11038 } else {
11039 // $FlowIgnore
11040 this.element.value = value;
11041 }
11042
11043 this.trigger('change');
11044 return nextTick()
11045 } else if (tagName === 'INPUT' || tagName === 'TEXTAREA') {
11046 // $FlowIgnore
11047 this.element.value = value;
11048
11049 this.trigger('input');
11050
11051 // for v-model.lazy, we need to trigger a change event, too.
11052 // $FlowIgnore
11053 if (this.element._vModifiers && this.element._vModifiers.lazy) {
11054 this.trigger('change');
11055 }
11056 return nextTick()
11057 }
11058 throwError("wrapper.setValue() cannot be called on this element");
11059 return nextTick()
11060 };
11061
11062 /**
11063 * Return text of wrapper element
11064 */
11065 Wrapper.prototype.text = function text () {
11066 return this.element.textContent.trim()
11067 };
11068
11069 /**
11070 * Dispatches a DOM event on wrapper
11071 */
11072 Wrapper.prototype.trigger = function trigger (type, options) {
11073 if ( options === void 0 ) options = {};
11074
11075 if (typeof type !== 'string') {
11076 throwError('wrapper.trigger() must be passed a string');
11077 }
11078
11079 if (options.target) {
11080 throwError(
11081 "you cannot set the target value of an event. See the notes section " +
11082 "of the docs for more details—" +
11083 "https://vue-test-utils.vuejs.org/api/wrapper/trigger.html"
11084 );
11085 }
11086
11087 /**
11088 * Avoids firing events on specific disabled elements
11089 * See more: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
11090 */
11091
11092 var supportedTags = [
11093 'BUTTON',
11094 'COMMAND',
11095 'FIELDSET',
11096 'KEYGEN',
11097 'OPTGROUP',
11098 'OPTION',
11099 'SELECT',
11100 'TEXTAREA',
11101 'INPUT'
11102 ];
11103 var tagName = this.element.tagName;
11104
11105 if (this.attributes().disabled && supportedTags.indexOf(tagName) > -1) {
11106 return nextTick()
11107 }
11108
11109 var event = createDOMEvent(type, options);
11110 this.element.dispatchEvent(event);
11111 return nextTick()
11112 };
11113
11114 //
11115
11116 var VueWrapper = /*@__PURE__*/(function (Wrapper) {
11117 function VueWrapper(vm, options) {
11118 var this$1 = this;
11119
11120 Wrapper.call(this, vm._vnode, options, true);
11121 // $FlowIgnore : issue with defineProperty
11122 Object.defineProperty(this, 'rootNode', {
11123 get: function () { return vm.$vnode || { child: this$1.vm }; },
11124 set: function () { return throwError('wrapper.vnode is read-only'); }
11125 });
11126 // $FlowIgnore : issue with defineProperty
11127 Object.defineProperty(this, 'vnode', {
11128 get: function () { return vm._vnode; },
11129 set: function () { return throwError('wrapper.vnode is read-only'); }
11130 });
11131 // $FlowIgnore
11132 Object.defineProperty(this, 'element', {
11133 get: function () { return vm.$el; },
11134 set: function () { return throwError('wrapper.element is read-only'); }
11135 });
11136 // $FlowIgnore
11137 Object.defineProperty(this, 'vm', {
11138 get: function () { return vm; },
11139 set: function () { return throwError('wrapper.vm is read-only'); }
11140 });
11141 this.isFunctionalComponent = vm.$options._isFunctionalContainer;
11142 this._emitted = vm.__emitted;
11143 this._emittedByOrder = vm.__emittedByOrder;
11144 }
11145
11146 if ( Wrapper ) VueWrapper.__proto__ = Wrapper;
11147 VueWrapper.prototype = Object.create( Wrapper && Wrapper.prototype );
11148 VueWrapper.prototype.constructor = VueWrapper;
11149
11150 return VueWrapper;
11151 }(Wrapper));
11152
11153 //
11154
11155 var isEnabled = false;
11156 var wrapperInstances = [];
11157
11158 function resetAutoDestroyState() {
11159 isEnabled = false;
11160 wrapperInstances.length = 0;
11161 }
11162
11163 function enableAutoDestroy(hook) {
11164 if (isEnabled) {
11165 throwError('enableAutoDestroy cannot be called more than once');
11166 }
11167
11168 isEnabled = true;
11169
11170 hook(function () {
11171 wrapperInstances.forEach(function (wrapper) {
11172 // skip child wrappers created by wrapper.find()
11173 if (wrapper.selector) { return }
11174
11175 wrapper.destroy();
11176 });
11177
11178 wrapperInstances.length = 0;
11179 });
11180 }
11181
11182 function trackInstance(wrapper) {
11183 if (!isEnabled) { return }
11184
11185 wrapperInstances.push(wrapper);
11186 }
11187
11188 //
11189
11190 function createWrapper(
11191 node,
11192 options
11193 ) {
11194 if ( options === void 0 ) options = {};
11195
11196 var componentInstance = node.child;
11197 if (componentInstance) {
11198 var wrapper$1 = new VueWrapper(componentInstance, options);
11199 trackInstance(wrapper$1);
11200 return wrapper$1
11201 }
11202 var wrapper =
11203 node instanceof Vue
11204 ? new VueWrapper(node, options)
11205 : new Wrapper(node, options);
11206 trackInstance(wrapper);
11207 return wrapper
11208 }
11209
11210 /**
11211 * Removes all key-value entries from the list cache.
11212 *
11213 * @private
11214 * @name clear
11215 * @memberOf ListCache
11216 */
11217 function listCacheClear() {
11218 this.__data__ = [];
11219 this.size = 0;
11220 }
11221
11222 var _listCacheClear = listCacheClear;
11223
11224 /**
11225 * Performs a
11226 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
11227 * comparison between two values to determine if they are equivalent.
11228 *
11229 * @static
11230 * @memberOf _
11231 * @since 4.0.0
11232 * @category Lang
11233 * @param {*} value The value to compare.
11234 * @param {*} other The other value to compare.
11235 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11236 * @example
11237 *
11238 * var object = { 'a': 1 };
11239 * var other = { 'a': 1 };
11240 *
11241 * _.eq(object, object);
11242 * // => true
11243 *
11244 * _.eq(object, other);
11245 * // => false
11246 *
11247 * _.eq('a', 'a');
11248 * // => true
11249 *
11250 * _.eq('a', Object('a'));
11251 * // => false
11252 *
11253 * _.eq(NaN, NaN);
11254 * // => true
11255 */
11256 function eq(value, other) {
11257 return value === other || (value !== value && other !== other);
11258 }
11259
11260 var eq_1 = eq;
11261
11262 /**
11263 * Gets the index at which the `key` is found in `array` of key-value pairs.
11264 *
11265 * @private
11266 * @param {Array} array The array to inspect.
11267 * @param {*} key The key to search for.
11268 * @returns {number} Returns the index of the matched value, else `-1`.
11269 */
11270 function assocIndexOf(array, key) {
11271 var length = array.length;
11272 while (length--) {
11273 if (eq_1(array[length][0], key)) {
11274 return length;
11275 }
11276 }
11277 return -1;
11278 }
11279
11280 var _assocIndexOf = assocIndexOf;
11281
11282 /** Used for built-in method references. */
11283 var arrayProto = Array.prototype;
11284
11285 /** Built-in value references. */
11286 var splice = arrayProto.splice;
11287
11288 /**
11289 * Removes `key` and its value from the list cache.
11290 *
11291 * @private
11292 * @name delete
11293 * @memberOf ListCache
11294 * @param {string} key The key of the value to remove.
11295 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11296 */
11297 function listCacheDelete(key) {
11298 var data = this.__data__,
11299 index = _assocIndexOf(data, key);
11300
11301 if (index < 0) {
11302 return false;
11303 }
11304 var lastIndex = data.length - 1;
11305 if (index == lastIndex) {
11306 data.pop();
11307 } else {
11308 splice.call(data, index, 1);
11309 }
11310 --this.size;
11311 return true;
11312 }
11313
11314 var _listCacheDelete = listCacheDelete;
11315
11316 /**
11317 * Gets the list cache value for `key`.
11318 *
11319 * @private
11320 * @name get
11321 * @memberOf ListCache
11322 * @param {string} key The key of the value to get.
11323 * @returns {*} Returns the entry value.
11324 */
11325 function listCacheGet(key) {
11326 var data = this.__data__,
11327 index = _assocIndexOf(data, key);
11328
11329 return index < 0 ? undefined : data[index][1];
11330 }
11331
11332 var _listCacheGet = listCacheGet;
11333
11334 /**
11335 * Checks if a list cache value for `key` exists.
11336 *
11337 * @private
11338 * @name has
11339 * @memberOf ListCache
11340 * @param {string} key The key of the entry to check.
11341 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
11342 */
11343 function listCacheHas(key) {
11344 return _assocIndexOf(this.__data__, key) > -1;
11345 }
11346
11347 var _listCacheHas = listCacheHas;
11348
11349 /**
11350 * Sets the list cache `key` to `value`.
11351 *
11352 * @private
11353 * @name set
11354 * @memberOf ListCache
11355 * @param {string} key The key of the value to set.
11356 * @param {*} value The value to set.
11357 * @returns {Object} Returns the list cache instance.
11358 */
11359 function listCacheSet(key, value) {
11360 var data = this.__data__,
11361 index = _assocIndexOf(data, key);
11362
11363 if (index < 0) {
11364 ++this.size;
11365 data.push([key, value]);
11366 } else {
11367 data[index][1] = value;
11368 }
11369 return this;
11370 }
11371
11372 var _listCacheSet = listCacheSet;
11373
11374 /**
11375 * Creates an list cache object.
11376 *
11377 * @private
11378 * @constructor
11379 * @param {Array} [entries] The key-value pairs to cache.
11380 */
11381 function ListCache(entries) {
11382 var index = -1,
11383 length = entries == null ? 0 : entries.length;
11384
11385 this.clear();
11386 while (++index < length) {
11387 var entry = entries[index];
11388 this.set(entry[0], entry[1]);
11389 }
11390 }
11391
11392 // Add methods to `ListCache`.
11393 ListCache.prototype.clear = _listCacheClear;
11394 ListCache.prototype['delete'] = _listCacheDelete;
11395 ListCache.prototype.get = _listCacheGet;
11396 ListCache.prototype.has = _listCacheHas;
11397 ListCache.prototype.set = _listCacheSet;
11398
11399 var _ListCache = ListCache;
11400
11401 /**
11402 * Removes all key-value entries from the stack.
11403 *
11404 * @private
11405 * @name clear
11406 * @memberOf Stack
11407 */
11408 function stackClear() {
11409 this.__data__ = new _ListCache;
11410 this.size = 0;
11411 }
11412
11413 var _stackClear = stackClear;
11414
11415 /**
11416 * Removes `key` and its value from the stack.
11417 *
11418 * @private
11419 * @name delete
11420 * @memberOf Stack
11421 * @param {string} key The key of the value to remove.
11422 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11423 */
11424 function stackDelete(key) {
11425 var data = this.__data__,
11426 result = data['delete'](key);
11427
11428 this.size = data.size;
11429 return result;
11430 }
11431
11432 var _stackDelete = stackDelete;
11433
11434 /**
11435 * Gets the stack value for `key`.
11436 *
11437 * @private
11438 * @name get
11439 * @memberOf Stack
11440 * @param {string} key The key of the value to get.
11441 * @returns {*} Returns the entry value.
11442 */
11443 function stackGet(key) {
11444 return this.__data__.get(key);
11445 }
11446
11447 var _stackGet = stackGet;
11448
11449 /**
11450 * Checks if a stack value for `key` exists.
11451 *
11452 * @private
11453 * @name has
11454 * @memberOf Stack
11455 * @param {string} key The key of the entry to check.
11456 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
11457 */
11458 function stackHas(key) {
11459 return this.__data__.has(key);
11460 }
11461
11462 var _stackHas = stackHas;
11463
11464 /** Detect free variable `global` from Node.js. */
11465 var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
11466
11467 var _freeGlobal = freeGlobal;
11468
11469 /** Detect free variable `self`. */
11470 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
11471
11472 /** Used as a reference to the global object. */
11473 var root = _freeGlobal || freeSelf || Function('return this')();
11474
11475 var _root = root;
11476
11477 /** Built-in value references. */
11478 var Symbol = _root.Symbol;
11479
11480 var _Symbol = Symbol;
11481
11482 /** Used for built-in method references. */
11483 var objectProto = Object.prototype;
11484
11485 /** Used to check objects for own properties. */
11486 var hasOwnProperty$1 = objectProto.hasOwnProperty;
11487
11488 /**
11489 * Used to resolve the
11490 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
11491 * of values.
11492 */
11493 var nativeObjectToString = objectProto.toString;
11494
11495 /** Built-in value references. */
11496 var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
11497
11498 /**
11499 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
11500 *
11501 * @private
11502 * @param {*} value The value to query.
11503 * @returns {string} Returns the raw `toStringTag`.
11504 */
11505 function getRawTag(value) {
11506 var isOwn = hasOwnProperty$1.call(value, symToStringTag),
11507 tag = value[symToStringTag];
11508
11509 try {
11510 value[symToStringTag] = undefined;
11511 var unmasked = true;
11512 } catch (e) {}
11513
11514 var result = nativeObjectToString.call(value);
11515 if (unmasked) {
11516 if (isOwn) {
11517 value[symToStringTag] = tag;
11518 } else {
11519 delete value[symToStringTag];
11520 }
11521 }
11522 return result;
11523 }
11524
11525 var _getRawTag = getRawTag;
11526
11527 /** Used for built-in method references. */
11528 var objectProto$1 = Object.prototype;
11529
11530 /**
11531 * Used to resolve the
11532 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
11533 * of values.
11534 */
11535 var nativeObjectToString$1 = objectProto$1.toString;
11536
11537 /**
11538 * Converts `value` to a string using `Object.prototype.toString`.
11539 *
11540 * @private
11541 * @param {*} value The value to convert.
11542 * @returns {string} Returns the converted string.
11543 */
11544 function objectToString(value) {
11545 return nativeObjectToString$1.call(value);
11546 }
11547
11548 var _objectToString = objectToString;
11549
11550 /** `Object#toString` result references. */
11551 var nullTag = '[object Null]',
11552 undefinedTag = '[object Undefined]';
11553
11554 /** Built-in value references. */
11555 var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
11556
11557 /**
11558 * The base implementation of `getTag` without fallbacks for buggy environments.
11559 *
11560 * @private
11561 * @param {*} value The value to query.
11562 * @returns {string} Returns the `toStringTag`.
11563 */
11564 function baseGetTag(value) {
11565 if (value == null) {
11566 return value === undefined ? undefinedTag : nullTag;
11567 }
11568 return (symToStringTag$1 && symToStringTag$1 in Object(value))
11569 ? _getRawTag(value)
11570 : _objectToString(value);
11571 }
11572
11573 var _baseGetTag = baseGetTag;
11574
11575 /**
11576 * Checks if `value` is the
11577 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
11578 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
11579 *
11580 * @static
11581 * @memberOf _
11582 * @since 0.1.0
11583 * @category Lang
11584 * @param {*} value The value to check.
11585 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
11586 * @example
11587 *
11588 * _.isObject({});
11589 * // => true
11590 *
11591 * _.isObject([1, 2, 3]);
11592 * // => true
11593 *
11594 * _.isObject(_.noop);
11595 * // => true
11596 *
11597 * _.isObject(null);
11598 * // => false
11599 */
11600 function isObject(value) {
11601 var type = typeof value;
11602 return value != null && (type == 'object' || type == 'function');
11603 }
11604
11605 var isObject_1 = isObject;
11606
11607 /** `Object#toString` result references. */
11608 var asyncTag = '[object AsyncFunction]',
11609 funcTag = '[object Function]',
11610 genTag = '[object GeneratorFunction]',
11611 proxyTag = '[object Proxy]';
11612
11613 /**
11614 * Checks if `value` is classified as a `Function` object.
11615 *
11616 * @static
11617 * @memberOf _
11618 * @since 0.1.0
11619 * @category Lang
11620 * @param {*} value The value to check.
11621 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
11622 * @example
11623 *
11624 * _.isFunction(_);
11625 * // => true
11626 *
11627 * _.isFunction(/abc/);
11628 * // => false
11629 */
11630 function isFunction(value) {
11631 if (!isObject_1(value)) {
11632 return false;
11633 }
11634 // The use of `Object#toString` avoids issues with the `typeof` operator
11635 // in Safari 9 which returns 'object' for typed arrays and other constructors.
11636 var tag = _baseGetTag(value);
11637 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
11638 }
11639
11640 var isFunction_1 = isFunction;
11641
11642 /** Used to detect overreaching core-js shims. */
11643 var coreJsData = _root['__core-js_shared__'];
11644
11645 var _coreJsData = coreJsData;
11646
11647 /** Used to detect methods masquerading as native. */
11648 var maskSrcKey = (function() {
11649 var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
11650 return uid ? ('Symbol(src)_1.' + uid) : '';
11651 }());
11652
11653 /**
11654 * Checks if `func` has its source masked.
11655 *
11656 * @private
11657 * @param {Function} func The function to check.
11658 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
11659 */
11660 function isMasked(func) {
11661 return !!maskSrcKey && (maskSrcKey in func);
11662 }
11663
11664 var _isMasked = isMasked;
11665
11666 /** Used for built-in method references. */
11667 var funcProto = Function.prototype;
11668
11669 /** Used to resolve the decompiled source of functions. */
11670 var funcToString = funcProto.toString;
11671
11672 /**
11673 * Converts `func` to its source code.
11674 *
11675 * @private
11676 * @param {Function} func The function to convert.
11677 * @returns {string} Returns the source code.
11678 */
11679 function toSource(func) {
11680 if (func != null) {
11681 try {
11682 return funcToString.call(func);
11683 } catch (e) {}
11684 try {
11685 return (func + '');
11686 } catch (e) {}
11687 }
11688 return '';
11689 }
11690
11691 var _toSource = toSource;
11692
11693 /**
11694 * Used to match `RegExp`
11695 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
11696 */
11697 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
11698
11699 /** Used to detect host constructors (Safari). */
11700 var reIsHostCtor = /^\[object .+?Constructor\]$/;
11701
11702 /** Used for built-in method references. */
11703 var funcProto$1 = Function.prototype,
11704 objectProto$2 = Object.prototype;
11705
11706 /** Used to resolve the decompiled source of functions. */
11707 var funcToString$1 = funcProto$1.toString;
11708
11709 /** Used to check objects for own properties. */
11710 var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
11711
11712 /** Used to detect if a method is native. */
11713 var reIsNative = RegExp('^' +
11714 funcToString$1.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
11715 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
11716 );
11717
11718 /**
11719 * The base implementation of `_.isNative` without bad shim checks.
11720 *
11721 * @private
11722 * @param {*} value The value to check.
11723 * @returns {boolean} Returns `true` if `value` is a native function,
11724 * else `false`.
11725 */
11726 function baseIsNative(value) {
11727 if (!isObject_1(value) || _isMasked(value)) {
11728 return false;
11729 }
11730 var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
11731 return pattern.test(_toSource(value));
11732 }
11733
11734 var _baseIsNative = baseIsNative;
11735
11736 /**
11737 * Gets the value at `key` of `object`.
11738 *
11739 * @private
11740 * @param {Object} [object] The object to query.
11741 * @param {string} key The key of the property to get.
11742 * @returns {*} Returns the property value.
11743 */
11744 function getValue(object, key) {
11745 return object == null ? undefined : object[key];
11746 }
11747
11748 var _getValue = getValue;
11749
11750 /**
11751 * Gets the native function at `key` of `object`.
11752 *
11753 * @private
11754 * @param {Object} object The object to query.
11755 * @param {string} key The key of the method to get.
11756 * @returns {*} Returns the function if it's native, else `undefined`.
11757 */
11758 function getNative(object, key) {
11759 var value = _getValue(object, key);
11760 return _baseIsNative(value) ? value : undefined;
11761 }
11762
11763 var _getNative = getNative;
11764
11765 /* Built-in method references that are verified to be native. */
11766 var Map = _getNative(_root, 'Map');
11767
11768 var _Map = Map;
11769
11770 /* Built-in method references that are verified to be native. */
11771 var nativeCreate = _getNative(Object, 'create');
11772
11773 var _nativeCreate = nativeCreate;
11774
11775 /**
11776 * Removes all key-value entries from the hash.
11777 *
11778 * @private
11779 * @name clear
11780 * @memberOf Hash
11781 */
11782 function hashClear() {
11783 this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
11784 this.size = 0;
11785 }
11786
11787 var _hashClear = hashClear;
11788
11789 /**
11790 * Removes `key` and its value from the hash.
11791 *
11792 * @private
11793 * @name delete
11794 * @memberOf Hash
11795 * @param {Object} hash The hash to modify.
11796 * @param {string} key The key of the value to remove.
11797 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11798 */
11799 function hashDelete(key) {
11800 var result = this.has(key) && delete this.__data__[key];
11801 this.size -= result ? 1 : 0;
11802 return result;
11803 }
11804
11805 var _hashDelete = hashDelete;
11806
11807 /** Used to stand-in for `undefined` hash values. */
11808 var HASH_UNDEFINED = '__lodash_hash_undefined__';
11809
11810 /** Used for built-in method references. */
11811 var objectProto$3 = Object.prototype;
11812
11813 /** Used to check objects for own properties. */
11814 var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
11815
11816 /**
11817 * Gets the hash value for `key`.
11818 *
11819 * @private
11820 * @name get
11821 * @memberOf Hash
11822 * @param {string} key The key of the value to get.
11823 * @returns {*} Returns the entry value.
11824 */
11825 function hashGet(key) {
11826 var data = this.__data__;
11827 if (_nativeCreate) {
11828 var result = data[key];
11829 return result === HASH_UNDEFINED ? undefined : result;
11830 }
11831 return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
11832 }
11833
11834 var _hashGet = hashGet;
11835
11836 /** Used for built-in method references. */
11837 var objectProto$4 = Object.prototype;
11838
11839 /** Used to check objects for own properties. */
11840 var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
11841
11842 /**
11843 * Checks if a hash value for `key` exists.
11844 *
11845 * @private
11846 * @name has
11847 * @memberOf Hash
11848 * @param {string} key The key of the entry to check.
11849 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
11850 */
11851 function hashHas(key) {
11852 var data = this.__data__;
11853 return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$4.call(data, key);
11854 }
11855
11856 var _hashHas = hashHas;
11857
11858 /** Used to stand-in for `undefined` hash values. */
11859 var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
11860
11861 /**
11862 * Sets the hash `key` to `value`.
11863 *
11864 * @private
11865 * @name set
11866 * @memberOf Hash
11867 * @param {string} key The key of the value to set.
11868 * @param {*} value The value to set.
11869 * @returns {Object} Returns the hash instance.
11870 */
11871 function hashSet(key, value) {
11872 var data = this.__data__;
11873 this.size += this.has(key) ? 0 : 1;
11874 data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
11875 return this;
11876 }
11877
11878 var _hashSet = hashSet;
11879
11880 /**
11881 * Creates a hash object.
11882 *
11883 * @private
11884 * @constructor
11885 * @param {Array} [entries] The key-value pairs to cache.
11886 */
11887 function Hash(entries) {
11888 var index = -1,
11889 length = entries == null ? 0 : entries.length;
11890
11891 this.clear();
11892 while (++index < length) {
11893 var entry = entries[index];
11894 this.set(entry[0], entry[1]);
11895 }
11896 }
11897
11898 // Add methods to `Hash`.
11899 Hash.prototype.clear = _hashClear;
11900 Hash.prototype['delete'] = _hashDelete;
11901 Hash.prototype.get = _hashGet;
11902 Hash.prototype.has = _hashHas;
11903 Hash.prototype.set = _hashSet;
11904
11905 var _Hash = Hash;
11906
11907 /**
11908 * Removes all key-value entries from the map.
11909 *
11910 * @private
11911 * @name clear
11912 * @memberOf MapCache
11913 */
11914 function mapCacheClear() {
11915 this.size = 0;
11916 this.__data__ = {
11917 'hash': new _Hash,
11918 'map': new (_Map || _ListCache),
11919 'string': new _Hash
11920 };
11921 }
11922
11923 var _mapCacheClear = mapCacheClear;
11924
11925 /**
11926 * Checks if `value` is suitable for use as unique object key.
11927 *
11928 * @private
11929 * @param {*} value The value to check.
11930 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
11931 */
11932 function isKeyable(value) {
11933 var type = typeof value;
11934 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
11935 ? (value !== '__proto__')
11936 : (value === null);
11937 }
11938
11939 var _isKeyable = isKeyable;
11940
11941 /**
11942 * Gets the data for `map`.
11943 *
11944 * @private
11945 * @param {Object} map The map to query.
11946 * @param {string} key The reference key.
11947 * @returns {*} Returns the map data.
11948 */
11949 function getMapData(map, key) {
11950 var data = map.__data__;
11951 return _isKeyable(key)
11952 ? data[typeof key == 'string' ? 'string' : 'hash']
11953 : data.map;
11954 }
11955
11956 var _getMapData = getMapData;
11957
11958 /**
11959 * Removes `key` and its value from the map.
11960 *
11961 * @private
11962 * @name delete
11963 * @memberOf MapCache
11964 * @param {string} key The key of the value to remove.
11965 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11966 */
11967 function mapCacheDelete(key) {
11968 var result = _getMapData(this, key)['delete'](key);
11969 this.size -= result ? 1 : 0;
11970 return result;
11971 }
11972
11973 var _mapCacheDelete = mapCacheDelete;
11974
11975 /**
11976 * Gets the map value for `key`.
11977 *
11978 * @private
11979 * @name get
11980 * @memberOf MapCache
11981 * @param {string} key The key of the value to get.
11982 * @returns {*} Returns the entry value.
11983 */
11984 function mapCacheGet(key) {
11985 return _getMapData(this, key).get(key);
11986 }
11987
11988 var _mapCacheGet = mapCacheGet;
11989
11990 /**
11991 * Checks if a map value for `key` exists.
11992 *
11993 * @private
11994 * @name has
11995 * @memberOf MapCache
11996 * @param {string} key The key of the entry to check.
11997 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
11998 */
11999 function mapCacheHas(key) {
12000 return _getMapData(this, key).has(key);
12001 }
12002
12003 var _mapCacheHas = mapCacheHas;
12004
12005 /**
12006 * Sets the map `key` to `value`.
12007 *
12008 * @private
12009 * @name set
12010 * @memberOf MapCache
12011 * @param {string} key The key of the value to set.
12012 * @param {*} value The value to set.
12013 * @returns {Object} Returns the map cache instance.
12014 */
12015 function mapCacheSet(key, value) {
12016 var data = _getMapData(this, key),
12017 size = data.size;
12018
12019 data.set(key, value);
12020 this.size += data.size == size ? 0 : 1;
12021 return this;
12022 }
12023
12024 var _mapCacheSet = mapCacheSet;
12025
12026 /**
12027 * Creates a map cache object to store key-value pairs.
12028 *
12029 * @private
12030 * @constructor
12031 * @param {Array} [entries] The key-value pairs to cache.
12032 */
12033 function MapCache(entries) {
12034 var index = -1,
12035 length = entries == null ? 0 : entries.length;
12036
12037 this.clear();
12038 while (++index < length) {
12039 var entry = entries[index];
12040 this.set(entry[0], entry[1]);
12041 }
12042 }
12043
12044 // Add methods to `MapCache`.
12045 MapCache.prototype.clear = _mapCacheClear;
12046 MapCache.prototype['delete'] = _mapCacheDelete;
12047 MapCache.prototype.get = _mapCacheGet;
12048 MapCache.prototype.has = _mapCacheHas;
12049 MapCache.prototype.set = _mapCacheSet;
12050
12051 var _MapCache = MapCache;
12052
12053 /** Used as the size to enable large array optimizations. */
12054 var LARGE_ARRAY_SIZE = 200;
12055
12056 /**
12057 * Sets the stack `key` to `value`.
12058 *
12059 * @private
12060 * @name set
12061 * @memberOf Stack
12062 * @param {string} key The key of the value to set.
12063 * @param {*} value The value to set.
12064 * @returns {Object} Returns the stack cache instance.
12065 */
12066 function stackSet(key, value) {
12067 var data = this.__data__;
12068 if (data instanceof _ListCache) {
12069 var pairs = data.__data__;
12070 if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
12071 pairs.push([key, value]);
12072 this.size = ++data.size;
12073 return this;
12074 }
12075 data = this.__data__ = new _MapCache(pairs);
12076 }
12077 data.set(key, value);
12078 this.size = data.size;
12079 return this;
12080 }
12081
12082 var _stackSet = stackSet;
12083
12084 /**
12085 * Creates a stack cache object to store key-value pairs.
12086 *
12087 * @private
12088 * @constructor
12089 * @param {Array} [entries] The key-value pairs to cache.
12090 */
12091 function Stack(entries) {
12092 var data = this.__data__ = new _ListCache(entries);
12093 this.size = data.size;
12094 }
12095
12096 // Add methods to `Stack`.
12097 Stack.prototype.clear = _stackClear;
12098 Stack.prototype['delete'] = _stackDelete;
12099 Stack.prototype.get = _stackGet;
12100 Stack.prototype.has = _stackHas;
12101 Stack.prototype.set = _stackSet;
12102
12103 var _Stack = Stack;
12104
12105 /**
12106 * A specialized version of `_.forEach` for arrays without support for
12107 * iteratee shorthands.
12108 *
12109 * @private
12110 * @param {Array} [array] The array to iterate over.
12111 * @param {Function} iteratee The function invoked per iteration.
12112 * @returns {Array} Returns `array`.
12113 */
12114 function arrayEach(array, iteratee) {
12115 var index = -1,
12116 length = array == null ? 0 : array.length;
12117
12118 while (++index < length) {
12119 if (iteratee(array[index], index, array) === false) {
12120 break;
12121 }
12122 }
12123 return array;
12124 }
12125
12126 var _arrayEach = arrayEach;
12127
12128 var defineProperty = (function() {
12129 try {
12130 var func = _getNative(Object, 'defineProperty');
12131 func({}, '', {});
12132 return func;
12133 } catch (e) {}
12134 }());
12135
12136 var _defineProperty = defineProperty;
12137
12138 /**
12139 * The base implementation of `assignValue` and `assignMergeValue` without
12140 * value checks.
12141 *
12142 * @private
12143 * @param {Object} object The object to modify.
12144 * @param {string} key The key of the property to assign.
12145 * @param {*} value The value to assign.
12146 */
12147 function baseAssignValue(object, key, value) {
12148 if (key == '__proto__' && _defineProperty) {
12149 _defineProperty(object, key, {
12150 'configurable': true,
12151 'enumerable': true,
12152 'value': value,
12153 'writable': true
12154 });
12155 } else {
12156 object[key] = value;
12157 }
12158 }
12159
12160 var _baseAssignValue = baseAssignValue;
12161
12162 /** Used for built-in method references. */
12163 var objectProto$5 = Object.prototype;
12164
12165 /** Used to check objects for own properties. */
12166 var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
12167
12168 /**
12169 * Assigns `value` to `key` of `object` if the existing value is not equivalent
12170 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
12171 * for equality comparisons.
12172 *
12173 * @private
12174 * @param {Object} object The object to modify.
12175 * @param {string} key The key of the property to assign.
12176 * @param {*} value The value to assign.
12177 */
12178 function assignValue(object, key, value) {
12179 var objValue = object[key];
12180 if (!(hasOwnProperty$5.call(object, key) && eq_1(objValue, value)) ||
12181 (value === undefined && !(key in object))) {
12182 _baseAssignValue(object, key, value);
12183 }
12184 }
12185
12186 var _assignValue = assignValue;
12187
12188 /**
12189 * Copies properties of `source` to `object`.
12190 *
12191 * @private
12192 * @param {Object} source The object to copy properties from.
12193 * @param {Array} props The property identifiers to copy.
12194 * @param {Object} [object={}] The object to copy properties to.
12195 * @param {Function} [customizer] The function to customize copied values.
12196 * @returns {Object} Returns `object`.
12197 */
12198 function copyObject(source, props, object, customizer) {
12199 var isNew = !object;
12200 object || (object = {});
12201
12202 var index = -1,
12203 length = props.length;
12204
12205 while (++index < length) {
12206 var key = props[index];
12207
12208 var newValue = customizer
12209 ? customizer(object[key], source[key], key, object, source)
12210 : undefined;
12211
12212 if (newValue === undefined) {
12213 newValue = source[key];
12214 }
12215 if (isNew) {
12216 _baseAssignValue(object, key, newValue);
12217 } else {
12218 _assignValue(object, key, newValue);
12219 }
12220 }
12221 return object;
12222 }
12223
12224 var _copyObject = copyObject;
12225
12226 /**
12227 * The base implementation of `_.times` without support for iteratee shorthands
12228 * or max array length checks.
12229 *
12230 * @private
12231 * @param {number} n The number of times to invoke `iteratee`.
12232 * @param {Function} iteratee The function invoked per iteration.
12233 * @returns {Array} Returns the array of results.
12234 */
12235 function baseTimes(n, iteratee) {
12236 var index = -1,
12237 result = Array(n);
12238
12239 while (++index < n) {
12240 result[index] = iteratee(index);
12241 }
12242 return result;
12243 }
12244
12245 var _baseTimes = baseTimes;
12246
12247 /**
12248 * Checks if `value` is object-like. A value is object-like if it's not `null`
12249 * and has a `typeof` result of "object".
12250 *
12251 * @static
12252 * @memberOf _
12253 * @since 4.0.0
12254 * @category Lang
12255 * @param {*} value The value to check.
12256 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
12257 * @example
12258 *
12259 * _.isObjectLike({});
12260 * // => true
12261 *
12262 * _.isObjectLike([1, 2, 3]);
12263 * // => true
12264 *
12265 * _.isObjectLike(_.noop);
12266 * // => false
12267 *
12268 * _.isObjectLike(null);
12269 * // => false
12270 */
12271 function isObjectLike(value) {
12272 return value != null && typeof value == 'object';
12273 }
12274
12275 var isObjectLike_1 = isObjectLike;
12276
12277 /** `Object#toString` result references. */
12278 var argsTag = '[object Arguments]';
12279
12280 /**
12281 * The base implementation of `_.isArguments`.
12282 *
12283 * @private
12284 * @param {*} value The value to check.
12285 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
12286 */
12287 function baseIsArguments(value) {
12288 return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
12289 }
12290
12291 var _baseIsArguments = baseIsArguments;
12292
12293 /** Used for built-in method references. */
12294 var objectProto$6 = Object.prototype;
12295
12296 /** Used to check objects for own properties. */
12297 var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
12298
12299 /** Built-in value references. */
12300 var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
12301
12302 /**
12303 * Checks if `value` is likely an `arguments` object.
12304 *
12305 * @static
12306 * @memberOf _
12307 * @since 0.1.0
12308 * @category Lang
12309 * @param {*} value The value to check.
12310 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
12311 * else `false`.
12312 * @example
12313 *
12314 * _.isArguments(function() { return arguments; }());
12315 * // => true
12316 *
12317 * _.isArguments([1, 2, 3]);
12318 * // => false
12319 */
12320 var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
12321 return isObjectLike_1(value) && hasOwnProperty$6.call(value, 'callee') &&
12322 !propertyIsEnumerable.call(value, 'callee');
12323 };
12324
12325 var isArguments_1 = isArguments;
12326
12327 /**
12328 * Checks if `value` is classified as an `Array` object.
12329 *
12330 * @static
12331 * @memberOf _
12332 * @since 0.1.0
12333 * @category Lang
12334 * @param {*} value The value to check.
12335 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
12336 * @example
12337 *
12338 * _.isArray([1, 2, 3]);
12339 * // => true
12340 *
12341 * _.isArray(document.body.children);
12342 * // => false
12343 *
12344 * _.isArray('abc');
12345 * // => false
12346 *
12347 * _.isArray(_.noop);
12348 * // => false
12349 */
12350 var isArray = Array.isArray;
12351
12352 var isArray_1 = isArray;
12353
12354 /**
12355 * This method returns `false`.
12356 *
12357 * @static
12358 * @memberOf _
12359 * @since 4.13.0
12360 * @category Util
12361 * @returns {boolean} Returns `false`.
12362 * @example
12363 *
12364 * _.times(2, _.stubFalse);
12365 * // => [false, false]
12366 */
12367 function stubFalse() {
12368 return false;
12369 }
12370
12371 var stubFalse_1 = stubFalse;
12372
12373 var isBuffer_1$1 = createCommonjsModule(function (module, exports) {
12374 /** Detect free variable `exports`. */
12375 var freeExports = exports && !exports.nodeType && exports;
12376
12377 /** Detect free variable `module`. */
12378 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
12379
12380 /** Detect the popular CommonJS extension `module.exports`. */
12381 var moduleExports = freeModule && freeModule.exports === freeExports;
12382
12383 /** Built-in value references. */
12384 var Buffer = moduleExports ? _root.Buffer : undefined;
12385
12386 /* Built-in method references for those with the same name as other `lodash` methods. */
12387 var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
12388
12389 /**
12390 * Checks if `value` is a buffer.
12391 *
12392 * @static
12393 * @memberOf _
12394 * @since 4.3.0
12395 * @category Lang
12396 * @param {*} value The value to check.
12397 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
12398 * @example
12399 *
12400 * _.isBuffer(new Buffer(2));
12401 * // => true
12402 *
12403 * _.isBuffer(new Uint8Array(2));
12404 * // => false
12405 */
12406 var isBuffer = nativeIsBuffer || stubFalse_1;
12407
12408 module.exports = isBuffer;
12409 });
12410
12411 /** Used as references for various `Number` constants. */
12412 var MAX_SAFE_INTEGER = 9007199254740991;
12413
12414 /** Used to detect unsigned integer values. */
12415 var reIsUint = /^(?:0|[1-9]\d*)$/;
12416
12417 /**
12418 * Checks if `value` is a valid array-like index.
12419 *
12420 * @private
12421 * @param {*} value The value to check.
12422 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
12423 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
12424 */
12425 function isIndex(value, length) {
12426 var type = typeof value;
12427 length = length == null ? MAX_SAFE_INTEGER : length;
12428
12429 return !!length &&
12430 (type == 'number' ||
12431 (type != 'symbol' && reIsUint.test(value))) &&
12432 (value > -1 && value % 1 == 0 && value < length);
12433 }
12434
12435 var _isIndex = isIndex;
12436
12437 /** Used as references for various `Number` constants. */
12438 var MAX_SAFE_INTEGER$1 = 9007199254740991;
12439
12440 /**
12441 * Checks if `value` is a valid array-like length.
12442 *
12443 * **Note:** This method is loosely based on
12444 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12445 *
12446 * @static
12447 * @memberOf _
12448 * @since 4.0.0
12449 * @category Lang
12450 * @param {*} value The value to check.
12451 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
12452 * @example
12453 *
12454 * _.isLength(3);
12455 * // => true
12456 *
12457 * _.isLength(Number.MIN_VALUE);
12458 * // => false
12459 *
12460 * _.isLength(Infinity);
12461 * // => false
12462 *
12463 * _.isLength('3');
12464 * // => false
12465 */
12466 function isLength(value) {
12467 return typeof value == 'number' &&
12468 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
12469 }
12470
12471 var isLength_1 = isLength;
12472
12473 /** `Object#toString` result references. */
12474 var argsTag$1 = '[object Arguments]',
12475 arrayTag = '[object Array]',
12476 boolTag = '[object Boolean]',
12477 dateTag = '[object Date]',
12478 errorTag = '[object Error]',
12479 funcTag$1 = '[object Function]',
12480 mapTag = '[object Map]',
12481 numberTag = '[object Number]',
12482 objectTag = '[object Object]',
12483 regexpTag = '[object RegExp]',
12484 setTag = '[object Set]',
12485 stringTag = '[object String]',
12486 weakMapTag = '[object WeakMap]';
12487
12488 var arrayBufferTag = '[object ArrayBuffer]',
12489 dataViewTag = '[object DataView]',
12490 float32Tag = '[object Float32Array]',
12491 float64Tag = '[object Float64Array]',
12492 int8Tag = '[object Int8Array]',
12493 int16Tag = '[object Int16Array]',
12494 int32Tag = '[object Int32Array]',
12495 uint8Tag = '[object Uint8Array]',
12496 uint8ClampedTag = '[object Uint8ClampedArray]',
12497 uint16Tag = '[object Uint16Array]',
12498 uint32Tag = '[object Uint32Array]';
12499
12500 /** Used to identify `toStringTag` values of typed arrays. */
12501 var typedArrayTags = {};
12502 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
12503 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
12504 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
12505 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
12506 typedArrayTags[uint32Tag] = true;
12507 typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
12508 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
12509 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
12510 typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
12511 typedArrayTags[mapTag] = typedArrayTags[numberTag] =
12512 typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
12513 typedArrayTags[setTag] = typedArrayTags[stringTag] =
12514 typedArrayTags[weakMapTag] = false;
12515
12516 /**
12517 * The base implementation of `_.isTypedArray` without Node.js optimizations.
12518 *
12519 * @private
12520 * @param {*} value The value to check.
12521 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12522 */
12523 function baseIsTypedArray(value) {
12524 return isObjectLike_1(value) &&
12525 isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
12526 }
12527
12528 var _baseIsTypedArray = baseIsTypedArray;
12529
12530 /**
12531 * The base implementation of `_.unary` without support for storing metadata.
12532 *
12533 * @private
12534 * @param {Function} func The function to cap arguments for.
12535 * @returns {Function} Returns the new capped function.
12536 */
12537 function baseUnary(func) {
12538 return function(value) {
12539 return func(value);
12540 };
12541 }
12542
12543 var _baseUnary = baseUnary;
12544
12545 var _nodeUtil = createCommonjsModule(function (module, exports) {
12546 /** Detect free variable `exports`. */
12547 var freeExports = exports && !exports.nodeType && exports;
12548
12549 /** Detect free variable `module`. */
12550 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
12551
12552 /** Detect the popular CommonJS extension `module.exports`. */
12553 var moduleExports = freeModule && freeModule.exports === freeExports;
12554
12555 /** Detect free variable `process` from Node.js. */
12556 var freeProcess = moduleExports && _freeGlobal.process;
12557
12558 /** Used to access faster Node.js helpers. */
12559 var nodeUtil = (function() {
12560 try {
12561 // Use `util.types` for Node.js 10+.
12562 var types = freeModule && freeModule.require && freeModule.require('util').types;
12563
12564 if (types) {
12565 return types;
12566 }
12567
12568 // Legacy `process.binding('util')` for Node.js < 10.
12569 return freeProcess && freeProcess.binding && freeProcess.binding('util');
12570 } catch (e) {}
12571 }());
12572
12573 module.exports = nodeUtil;
12574 });
12575
12576 /* Node.js helper references. */
12577 var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
12578
12579 /**
12580 * Checks if `value` is classified as a typed array.
12581 *
12582 * @static
12583 * @memberOf _
12584 * @since 3.0.0
12585 * @category Lang
12586 * @param {*} value The value to check.
12587 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12588 * @example
12589 *
12590 * _.isTypedArray(new Uint8Array);
12591 * // => true
12592 *
12593 * _.isTypedArray([]);
12594 * // => false
12595 */
12596 var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
12597
12598 var isTypedArray_1 = isTypedArray;
12599
12600 /** Used for built-in method references. */
12601 var objectProto$7 = Object.prototype;
12602
12603 /** Used to check objects for own properties. */
12604 var hasOwnProperty$7 = objectProto$7.hasOwnProperty;
12605
12606 /**
12607 * Creates an array of the enumerable property names of the array-like `value`.
12608 *
12609 * @private
12610 * @param {*} value The value to query.
12611 * @param {boolean} inherited Specify returning inherited property names.
12612 * @returns {Array} Returns the array of property names.
12613 */
12614 function arrayLikeKeys(value, inherited) {
12615 var isArr = isArray_1(value),
12616 isArg = !isArr && isArguments_1(value),
12617 isBuff = !isArr && !isArg && isBuffer_1$1(value),
12618 isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
12619 skipIndexes = isArr || isArg || isBuff || isType,
12620 result = skipIndexes ? _baseTimes(value.length, String) : [],
12621 length = result.length;
12622
12623 for (var key in value) {
12624 if ((inherited || hasOwnProperty$7.call(value, key)) &&
12625 !(skipIndexes && (
12626 // Safari 9 has enumerable `arguments.length` in strict mode.
12627 key == 'length' ||
12628 // Node.js 0.10 has enumerable non-index properties on buffers.
12629 (isBuff && (key == 'offset' || key == 'parent')) ||
12630 // PhantomJS 2 has enumerable non-index properties on typed arrays.
12631 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
12632 // Skip index properties.
12633 _isIndex(key, length)
12634 ))) {
12635 result.push(key);
12636 }
12637 }
12638 return result;
12639 }
12640
12641 var _arrayLikeKeys = arrayLikeKeys;
12642
12643 /** Used for built-in method references. */
12644 var objectProto$8 = Object.prototype;
12645
12646 /**
12647 * Checks if `value` is likely a prototype object.
12648 *
12649 * @private
12650 * @param {*} value The value to check.
12651 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
12652 */
12653 function isPrototype(value) {
12654 var Ctor = value && value.constructor,
12655 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
12656
12657 return value === proto;
12658 }
12659
12660 var _isPrototype = isPrototype;
12661
12662 /**
12663 * Creates a unary function that invokes `func` with its argument transformed.
12664 *
12665 * @private
12666 * @param {Function} func The function to wrap.
12667 * @param {Function} transform The argument transform.
12668 * @returns {Function} Returns the new function.
12669 */
12670 function overArg(func, transform) {
12671 return function(arg) {
12672 return func(transform(arg));
12673 };
12674 }
12675
12676 var _overArg = overArg;
12677
12678 /* Built-in method references for those with the same name as other `lodash` methods. */
12679 var nativeKeys = _overArg(Object.keys, Object);
12680
12681 var _nativeKeys = nativeKeys;
12682
12683 /** Used for built-in method references. */
12684 var objectProto$9 = Object.prototype;
12685
12686 /** Used to check objects for own properties. */
12687 var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
12688
12689 /**
12690 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
12691 *
12692 * @private
12693 * @param {Object} object The object to query.
12694 * @returns {Array} Returns the array of property names.
12695 */
12696 function baseKeys(object) {
12697 if (!_isPrototype(object)) {
12698 return _nativeKeys(object);
12699 }
12700 var result = [];
12701 for (var key in Object(object)) {
12702 if (hasOwnProperty$8.call(object, key) && key != 'constructor') {
12703 result.push(key);
12704 }
12705 }
12706 return result;
12707 }
12708
12709 var _baseKeys = baseKeys;
12710
12711 /**
12712 * Checks if `value` is array-like. A value is considered array-like if it's
12713 * not a function and has a `value.length` that's an integer greater than or
12714 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
12715 *
12716 * @static
12717 * @memberOf _
12718 * @since 4.0.0
12719 * @category Lang
12720 * @param {*} value The value to check.
12721 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
12722 * @example
12723 *
12724 * _.isArrayLike([1, 2, 3]);
12725 * // => true
12726 *
12727 * _.isArrayLike(document.body.children);
12728 * // => true
12729 *
12730 * _.isArrayLike('abc');
12731 * // => true
12732 *
12733 * _.isArrayLike(_.noop);
12734 * // => false
12735 */
12736 function isArrayLike(value) {
12737 return value != null && isLength_1(value.length) && !isFunction_1(value);
12738 }
12739
12740 var isArrayLike_1 = isArrayLike;
12741
12742 /**
12743 * Creates an array of the own enumerable property names of `object`.
12744 *
12745 * **Note:** Non-object values are coerced to objects. See the
12746 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
12747 * for more details.
12748 *
12749 * @static
12750 * @since 0.1.0
12751 * @memberOf _
12752 * @category Object
12753 * @param {Object} object The object to query.
12754 * @returns {Array} Returns the array of property names.
12755 * @example
12756 *
12757 * function Foo() {
12758 * this.a = 1;
12759 * this.b = 2;
12760 * }
12761 *
12762 * Foo.prototype.c = 3;
12763 *
12764 * _.keys(new Foo);
12765 * // => ['a', 'b'] (iteration order is not guaranteed)
12766 *
12767 * _.keys('hi');
12768 * // => ['0', '1']
12769 */
12770 function keys$1(object) {
12771 return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
12772 }
12773
12774 var keys_1 = keys$1;
12775
12776 /**
12777 * The base implementation of `_.assign` without support for multiple sources
12778 * or `customizer` functions.
12779 *
12780 * @private
12781 * @param {Object} object The destination object.
12782 * @param {Object} source The source object.
12783 * @returns {Object} Returns `object`.
12784 */
12785 function baseAssign(object, source) {
12786 return object && _copyObject(source, keys_1(source), object);
12787 }
12788
12789 var _baseAssign = baseAssign;
12790
12791 /**
12792 * This function is like
12793 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
12794 * except that it includes inherited enumerable properties.
12795 *
12796 * @private
12797 * @param {Object} object The object to query.
12798 * @returns {Array} Returns the array of property names.
12799 */
12800 function nativeKeysIn(object) {
12801 var result = [];
12802 if (object != null) {
12803 for (var key in Object(object)) {
12804 result.push(key);
12805 }
12806 }
12807 return result;
12808 }
12809
12810 var _nativeKeysIn = nativeKeysIn;
12811
12812 /** Used for built-in method references. */
12813 var objectProto$a = Object.prototype;
12814
12815 /** Used to check objects for own properties. */
12816 var hasOwnProperty$9 = objectProto$a.hasOwnProperty;
12817
12818 /**
12819 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
12820 *
12821 * @private
12822 * @param {Object} object The object to query.
12823 * @returns {Array} Returns the array of property names.
12824 */
12825 function baseKeysIn(object) {
12826 if (!isObject_1(object)) {
12827 return _nativeKeysIn(object);
12828 }
12829 var isProto = _isPrototype(object),
12830 result = [];
12831
12832 for (var key in object) {
12833 if (!(key == 'constructor' && (isProto || !hasOwnProperty$9.call(object, key)))) {
12834 result.push(key);
12835 }
12836 }
12837 return result;
12838 }
12839
12840 var _baseKeysIn = baseKeysIn;
12841
12842 /**
12843 * Creates an array of the own and inherited enumerable property names of `object`.
12844 *
12845 * **Note:** Non-object values are coerced to objects.
12846 *
12847 * @static
12848 * @memberOf _
12849 * @since 3.0.0
12850 * @category Object
12851 * @param {Object} object The object to query.
12852 * @returns {Array} Returns the array of property names.
12853 * @example
12854 *
12855 * function Foo() {
12856 * this.a = 1;
12857 * this.b = 2;
12858 * }
12859 *
12860 * Foo.prototype.c = 3;
12861 *
12862 * _.keysIn(new Foo);
12863 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
12864 */
12865 function keysIn$1(object) {
12866 return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
12867 }
12868
12869 var keysIn_1 = keysIn$1;
12870
12871 /**
12872 * The base implementation of `_.assignIn` without support for multiple sources
12873 * or `customizer` functions.
12874 *
12875 * @private
12876 * @param {Object} object The destination object.
12877 * @param {Object} source The source object.
12878 * @returns {Object} Returns `object`.
12879 */
12880 function baseAssignIn(object, source) {
12881 return object && _copyObject(source, keysIn_1(source), object);
12882 }
12883
12884 var _baseAssignIn = baseAssignIn;
12885
12886 var _cloneBuffer = createCommonjsModule(function (module, exports) {
12887 /** Detect free variable `exports`. */
12888 var freeExports = exports && !exports.nodeType && exports;
12889
12890 /** Detect free variable `module`. */
12891 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
12892
12893 /** Detect the popular CommonJS extension `module.exports`. */
12894 var moduleExports = freeModule && freeModule.exports === freeExports;
12895
12896 /** Built-in value references. */
12897 var Buffer = moduleExports ? _root.Buffer : undefined,
12898 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
12899
12900 /**
12901 * Creates a clone of `buffer`.
12902 *
12903 * @private
12904 * @param {Buffer} buffer The buffer to clone.
12905 * @param {boolean} [isDeep] Specify a deep clone.
12906 * @returns {Buffer} Returns the cloned buffer.
12907 */
12908 function cloneBuffer(buffer, isDeep) {
12909 if (isDeep) {
12910 return buffer.slice();
12911 }
12912 var length = buffer.length,
12913 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
12914
12915 buffer.copy(result);
12916 return result;
12917 }
12918
12919 module.exports = cloneBuffer;
12920 });
12921
12922 /**
12923 * Copies the values of `source` to `array`.
12924 *
12925 * @private
12926 * @param {Array} source The array to copy values from.
12927 * @param {Array} [array=[]] The array to copy values to.
12928 * @returns {Array} Returns `array`.
12929 */
12930 function copyArray(source, array) {
12931 var index = -1,
12932 length = source.length;
12933
12934 array || (array = Array(length));
12935 while (++index < length) {
12936 array[index] = source[index];
12937 }
12938 return array;
12939 }
12940
12941 var _copyArray = copyArray;
12942
12943 /**
12944 * A specialized version of `_.filter` for arrays without support for
12945 * iteratee shorthands.
12946 *
12947 * @private
12948 * @param {Array} [array] The array to iterate over.
12949 * @param {Function} predicate The function invoked per iteration.
12950 * @returns {Array} Returns the new filtered array.
12951 */
12952 function arrayFilter(array, predicate) {
12953 var index = -1,
12954 length = array == null ? 0 : array.length,
12955 resIndex = 0,
12956 result = [];
12957
12958 while (++index < length) {
12959 var value = array[index];
12960 if (predicate(value, index, array)) {
12961 result[resIndex++] = value;
12962 }
12963 }
12964 return result;
12965 }
12966
12967 var _arrayFilter = arrayFilter;
12968
12969 /**
12970 * This method returns a new empty array.
12971 *
12972 * @static
12973 * @memberOf _
12974 * @since 4.13.0
12975 * @category Util
12976 * @returns {Array} Returns the new empty array.
12977 * @example
12978 *
12979 * var arrays = _.times(2, _.stubArray);
12980 *
12981 * console.log(arrays);
12982 * // => [[], []]
12983 *
12984 * console.log(arrays[0] === arrays[1]);
12985 * // => false
12986 */
12987 function stubArray() {
12988 return [];
12989 }
12990
12991 var stubArray_1 = stubArray;
12992
12993 /** Used for built-in method references. */
12994 var objectProto$b = Object.prototype;
12995
12996 /** Built-in value references. */
12997 var propertyIsEnumerable$1 = objectProto$b.propertyIsEnumerable;
12998
12999 /* Built-in method references for those with the same name as other `lodash` methods. */
13000 var nativeGetSymbols = Object.getOwnPropertySymbols;
13001
13002 /**
13003 * Creates an array of the own enumerable symbols of `object`.
13004 *
13005 * @private
13006 * @param {Object} object The object to query.
13007 * @returns {Array} Returns the array of symbols.
13008 */
13009 var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
13010 if (object == null) {
13011 return [];
13012 }
13013 object = Object(object);
13014 return _arrayFilter(nativeGetSymbols(object), function(symbol) {
13015 return propertyIsEnumerable$1.call(object, symbol);
13016 });
13017 };
13018
13019 var _getSymbols = getSymbols;
13020
13021 /**
13022 * Copies own symbols of `source` to `object`.
13023 *
13024 * @private
13025 * @param {Object} source The object to copy symbols from.
13026 * @param {Object} [object={}] The object to copy symbols to.
13027 * @returns {Object} Returns `object`.
13028 */
13029 function copySymbols(source, object) {
13030 return _copyObject(source, _getSymbols(source), object);
13031 }
13032
13033 var _copySymbols = copySymbols;
13034
13035 /**
13036 * Appends the elements of `values` to `array`.
13037 *
13038 * @private
13039 * @param {Array} array The array to modify.
13040 * @param {Array} values The values to append.
13041 * @returns {Array} Returns `array`.
13042 */
13043 function arrayPush(array, values) {
13044 var index = -1,
13045 length = values.length,
13046 offset = array.length;
13047
13048 while (++index < length) {
13049 array[offset + index] = values[index];
13050 }
13051 return array;
13052 }
13053
13054 var _arrayPush = arrayPush;
13055
13056 /** Built-in value references. */
13057 var getPrototype = _overArg(Object.getPrototypeOf, Object);
13058
13059 var _getPrototype = getPrototype;
13060
13061 /* Built-in method references for those with the same name as other `lodash` methods. */
13062 var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
13063
13064 /**
13065 * Creates an array of the own and inherited enumerable symbols of `object`.
13066 *
13067 * @private
13068 * @param {Object} object The object to query.
13069 * @returns {Array} Returns the array of symbols.
13070 */
13071 var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
13072 var result = [];
13073 while (object) {
13074 _arrayPush(result, _getSymbols(object));
13075 object = _getPrototype(object);
13076 }
13077 return result;
13078 };
13079
13080 var _getSymbolsIn = getSymbolsIn;
13081
13082 /**
13083 * Copies own and inherited symbols of `source` to `object`.
13084 *
13085 * @private
13086 * @param {Object} source The object to copy symbols from.
13087 * @param {Object} [object={}] The object to copy symbols to.
13088 * @returns {Object} Returns `object`.
13089 */
13090 function copySymbolsIn(source, object) {
13091 return _copyObject(source, _getSymbolsIn(source), object);
13092 }
13093
13094 var _copySymbolsIn = copySymbolsIn;
13095
13096 /**
13097 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
13098 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
13099 * symbols of `object`.
13100 *
13101 * @private
13102 * @param {Object} object The object to query.
13103 * @param {Function} keysFunc The function to get the keys of `object`.
13104 * @param {Function} symbolsFunc The function to get the symbols of `object`.
13105 * @returns {Array} Returns the array of property names and symbols.
13106 */
13107 function baseGetAllKeys(object, keysFunc, symbolsFunc) {
13108 var result = keysFunc(object);
13109 return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
13110 }
13111
13112 var _baseGetAllKeys = baseGetAllKeys;
13113
13114 /**
13115 * Creates an array of own enumerable property names and symbols of `object`.
13116 *
13117 * @private
13118 * @param {Object} object The object to query.
13119 * @returns {Array} Returns the array of property names and symbols.
13120 */
13121 function getAllKeys(object) {
13122 return _baseGetAllKeys(object, keys_1, _getSymbols);
13123 }
13124
13125 var _getAllKeys = getAllKeys;
13126
13127 /**
13128 * Creates an array of own and inherited enumerable property names and
13129 * symbols of `object`.
13130 *
13131 * @private
13132 * @param {Object} object The object to query.
13133 * @returns {Array} Returns the array of property names and symbols.
13134 */
13135 function getAllKeysIn(object) {
13136 return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
13137 }
13138
13139 var _getAllKeysIn = getAllKeysIn;
13140
13141 /* Built-in method references that are verified to be native. */
13142 var DataView = _getNative(_root, 'DataView');
13143
13144 var _DataView = DataView;
13145
13146 /* Built-in method references that are verified to be native. */
13147 var Promise$1 = _getNative(_root, 'Promise');
13148
13149 var _Promise = Promise$1;
13150
13151 /* Built-in method references that are verified to be native. */
13152 var Set$1 = _getNative(_root, 'Set');
13153
13154 var _Set = Set$1;
13155
13156 /* Built-in method references that are verified to be native. */
13157 var WeakMap = _getNative(_root, 'WeakMap');
13158
13159 var _WeakMap = WeakMap;
13160
13161 /** `Object#toString` result references. */
13162 var mapTag$1 = '[object Map]',
13163 objectTag$1 = '[object Object]',
13164 promiseTag = '[object Promise]',
13165 setTag$1 = '[object Set]',
13166 weakMapTag$1 = '[object WeakMap]';
13167
13168 var dataViewTag$1 = '[object DataView]';
13169
13170 /** Used to detect maps, sets, and weakmaps. */
13171 var dataViewCtorString = _toSource(_DataView),
13172 mapCtorString = _toSource(_Map),
13173 promiseCtorString = _toSource(_Promise),
13174 setCtorString = _toSource(_Set),
13175 weakMapCtorString = _toSource(_WeakMap);
13176
13177 /**
13178 * Gets the `toStringTag` of `value`.
13179 *
13180 * @private
13181 * @param {*} value The value to query.
13182 * @returns {string} Returns the `toStringTag`.
13183 */
13184 var getTag = _baseGetTag;
13185
13186 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
13187 if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
13188 (_Map && getTag(new _Map) != mapTag$1) ||
13189 (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
13190 (_Set && getTag(new _Set) != setTag$1) ||
13191 (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
13192 getTag = function(value) {
13193 var result = _baseGetTag(value),
13194 Ctor = result == objectTag$1 ? value.constructor : undefined,
13195 ctorString = Ctor ? _toSource(Ctor) : '';
13196
13197 if (ctorString) {
13198 switch (ctorString) {
13199 case dataViewCtorString: return dataViewTag$1;
13200 case mapCtorString: return mapTag$1;
13201 case promiseCtorString: return promiseTag;
13202 case setCtorString: return setTag$1;
13203 case weakMapCtorString: return weakMapTag$1;
13204 }
13205 }
13206 return result;
13207 };
13208 }
13209
13210 var _getTag = getTag;
13211
13212 /** Used for built-in method references. */
13213 var objectProto$c = Object.prototype;
13214
13215 /** Used to check objects for own properties. */
13216 var hasOwnProperty$a = objectProto$c.hasOwnProperty;
13217
13218 /**
13219 * Initializes an array clone.
13220 *
13221 * @private
13222 * @param {Array} array The array to clone.
13223 * @returns {Array} Returns the initialized clone.
13224 */
13225 function initCloneArray(array) {
13226 var length = array.length,
13227 result = new array.constructor(length);
13228
13229 // Add properties assigned by `RegExp#exec`.
13230 if (length && typeof array[0] == 'string' && hasOwnProperty$a.call(array, 'index')) {
13231 result.index = array.index;
13232 result.input = array.input;
13233 }
13234 return result;
13235 }
13236
13237 var _initCloneArray = initCloneArray;
13238
13239 /** Built-in value references. */
13240 var Uint8Array = _root.Uint8Array;
13241
13242 var _Uint8Array = Uint8Array;
13243
13244 /**
13245 * Creates a clone of `arrayBuffer`.
13246 *
13247 * @private
13248 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
13249 * @returns {ArrayBuffer} Returns the cloned array buffer.
13250 */
13251 function cloneArrayBuffer(arrayBuffer) {
13252 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
13253 new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
13254 return result;
13255 }
13256
13257 var _cloneArrayBuffer = cloneArrayBuffer;
13258
13259 /**
13260 * Creates a clone of `dataView`.
13261 *
13262 * @private
13263 * @param {Object} dataView The data view to clone.
13264 * @param {boolean} [isDeep] Specify a deep clone.
13265 * @returns {Object} Returns the cloned data view.
13266 */
13267 function cloneDataView(dataView, isDeep) {
13268 var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
13269 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
13270 }
13271
13272 var _cloneDataView = cloneDataView;
13273
13274 /** Used to match `RegExp` flags from their coerced string values. */
13275 var reFlags = /\w*$/;
13276
13277 /**
13278 * Creates a clone of `regexp`.
13279 *
13280 * @private
13281 * @param {Object} regexp The regexp to clone.
13282 * @returns {Object} Returns the cloned regexp.
13283 */
13284 function cloneRegExp(regexp) {
13285 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
13286 result.lastIndex = regexp.lastIndex;
13287 return result;
13288 }
13289
13290 var _cloneRegExp = cloneRegExp;
13291
13292 /** Used to convert symbols to primitives and strings. */
13293 var symbolProto = _Symbol ? _Symbol.prototype : undefined,
13294 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
13295
13296 /**
13297 * Creates a clone of the `symbol` object.
13298 *
13299 * @private
13300 * @param {Object} symbol The symbol object to clone.
13301 * @returns {Object} Returns the cloned symbol object.
13302 */
13303 function cloneSymbol(symbol) {
13304 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
13305 }
13306
13307 var _cloneSymbol = cloneSymbol;
13308
13309 /**
13310 * Creates a clone of `typedArray`.
13311 *
13312 * @private
13313 * @param {Object} typedArray The typed array to clone.
13314 * @param {boolean} [isDeep] Specify a deep clone.
13315 * @returns {Object} Returns the cloned typed array.
13316 */
13317 function cloneTypedArray(typedArray, isDeep) {
13318 var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
13319 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
13320 }
13321
13322 var _cloneTypedArray = cloneTypedArray;
13323
13324 /** `Object#toString` result references. */
13325 var boolTag$1 = '[object Boolean]',
13326 dateTag$1 = '[object Date]',
13327 mapTag$2 = '[object Map]',
13328 numberTag$1 = '[object Number]',
13329 regexpTag$1 = '[object RegExp]',
13330 setTag$2 = '[object Set]',
13331 stringTag$1 = '[object String]',
13332 symbolTag = '[object Symbol]';
13333
13334 var arrayBufferTag$1 = '[object ArrayBuffer]',
13335 dataViewTag$2 = '[object DataView]',
13336 float32Tag$1 = '[object Float32Array]',
13337 float64Tag$1 = '[object Float64Array]',
13338 int8Tag$1 = '[object Int8Array]',
13339 int16Tag$1 = '[object Int16Array]',
13340 int32Tag$1 = '[object Int32Array]',
13341 uint8Tag$1 = '[object Uint8Array]',
13342 uint8ClampedTag$1 = '[object Uint8ClampedArray]',
13343 uint16Tag$1 = '[object Uint16Array]',
13344 uint32Tag$1 = '[object Uint32Array]';
13345
13346 /**
13347 * Initializes an object clone based on its `toStringTag`.
13348 *
13349 * **Note:** This function only supports cloning values with tags of
13350 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
13351 *
13352 * @private
13353 * @param {Object} object The object to clone.
13354 * @param {string} tag The `toStringTag` of the object to clone.
13355 * @param {boolean} [isDeep] Specify a deep clone.
13356 * @returns {Object} Returns the initialized clone.
13357 */
13358 function initCloneByTag(object, tag, isDeep) {
13359 var Ctor = object.constructor;
13360 switch (tag) {
13361 case arrayBufferTag$1:
13362 return _cloneArrayBuffer(object);
13363
13364 case boolTag$1:
13365 case dateTag$1:
13366 return new Ctor(+object);
13367
13368 case dataViewTag$2:
13369 return _cloneDataView(object, isDeep);
13370
13371 case float32Tag$1: case float64Tag$1:
13372 case int8Tag$1: case int16Tag$1: case int32Tag$1:
13373 case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
13374 return _cloneTypedArray(object, isDeep);
13375
13376 case mapTag$2:
13377 return new Ctor;
13378
13379 case numberTag$1:
13380 case stringTag$1:
13381 return new Ctor(object);
13382
13383 case regexpTag$1:
13384 return _cloneRegExp(object);
13385
13386 case setTag$2:
13387 return new Ctor;
13388
13389 case symbolTag:
13390 return _cloneSymbol(object);
13391 }
13392 }
13393
13394 var _initCloneByTag = initCloneByTag;
13395
13396 /** Built-in value references. */
13397 var objectCreate = Object.create;
13398
13399 /**
13400 * The base implementation of `_.create` without support for assigning
13401 * properties to the created object.
13402 *
13403 * @private
13404 * @param {Object} proto The object to inherit from.
13405 * @returns {Object} Returns the new object.
13406 */
13407 var baseCreate = (function() {
13408 function object() {}
13409 return function(proto) {
13410 if (!isObject_1(proto)) {
13411 return {};
13412 }
13413 if (objectCreate) {
13414 return objectCreate(proto);
13415 }
13416 object.prototype = proto;
13417 var result = new object;
13418 object.prototype = undefined;
13419 return result;
13420 };
13421 }());
13422
13423 var _baseCreate = baseCreate;
13424
13425 /**
13426 * Initializes an object clone.
13427 *
13428 * @private
13429 * @param {Object} object The object to clone.
13430 * @returns {Object} Returns the initialized clone.
13431 */
13432 function initCloneObject(object) {
13433 return (typeof object.constructor == 'function' && !_isPrototype(object))
13434 ? _baseCreate(_getPrototype(object))
13435 : {};
13436 }
13437
13438 var _initCloneObject = initCloneObject;
13439
13440 /** `Object#toString` result references. */
13441 var mapTag$3 = '[object Map]';
13442
13443 /**
13444 * The base implementation of `_.isMap` without Node.js optimizations.
13445 *
13446 * @private
13447 * @param {*} value The value to check.
13448 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
13449 */
13450 function baseIsMap(value) {
13451 return isObjectLike_1(value) && _getTag(value) == mapTag$3;
13452 }
13453
13454 var _baseIsMap = baseIsMap;
13455
13456 /* Node.js helper references. */
13457 var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
13458
13459 /**
13460 * Checks if `value` is classified as a `Map` object.
13461 *
13462 * @static
13463 * @memberOf _
13464 * @since 4.3.0
13465 * @category Lang
13466 * @param {*} value The value to check.
13467 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
13468 * @example
13469 *
13470 * _.isMap(new Map);
13471 * // => true
13472 *
13473 * _.isMap(new WeakMap);
13474 * // => false
13475 */
13476 var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
13477
13478 var isMap_1 = isMap;
13479
13480 /** `Object#toString` result references. */
13481 var setTag$3 = '[object Set]';
13482
13483 /**
13484 * The base implementation of `_.isSet` without Node.js optimizations.
13485 *
13486 * @private
13487 * @param {*} value The value to check.
13488 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
13489 */
13490 function baseIsSet(value) {
13491 return isObjectLike_1(value) && _getTag(value) == setTag$3;
13492 }
13493
13494 var _baseIsSet = baseIsSet;
13495
13496 /* Node.js helper references. */
13497 var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
13498
13499 /**
13500 * Checks if `value` is classified as a `Set` object.
13501 *
13502 * @static
13503 * @memberOf _
13504 * @since 4.3.0
13505 * @category Lang
13506 * @param {*} value The value to check.
13507 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
13508 * @example
13509 *
13510 * _.isSet(new Set);
13511 * // => true
13512 *
13513 * _.isSet(new WeakSet);
13514 * // => false
13515 */
13516 var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
13517
13518 var isSet_1 = isSet;
13519
13520 /** Used to compose bitmasks for cloning. */
13521 var CLONE_DEEP_FLAG = 1,
13522 CLONE_FLAT_FLAG = 2,
13523 CLONE_SYMBOLS_FLAG = 4;
13524
13525 /** `Object#toString` result references. */
13526 var argsTag$2 = '[object Arguments]',
13527 arrayTag$1 = '[object Array]',
13528 boolTag$2 = '[object Boolean]',
13529 dateTag$2 = '[object Date]',
13530 errorTag$1 = '[object Error]',
13531 funcTag$2 = '[object Function]',
13532 genTag$1 = '[object GeneratorFunction]',
13533 mapTag$4 = '[object Map]',
13534 numberTag$2 = '[object Number]',
13535 objectTag$2 = '[object Object]',
13536 regexpTag$2 = '[object RegExp]',
13537 setTag$4 = '[object Set]',
13538 stringTag$2 = '[object String]',
13539 symbolTag$1 = '[object Symbol]',
13540 weakMapTag$2 = '[object WeakMap]';
13541
13542 var arrayBufferTag$2 = '[object ArrayBuffer]',
13543 dataViewTag$3 = '[object DataView]',
13544 float32Tag$2 = '[object Float32Array]',
13545 float64Tag$2 = '[object Float64Array]',
13546 int8Tag$2 = '[object Int8Array]',
13547 int16Tag$2 = '[object Int16Array]',
13548 int32Tag$2 = '[object Int32Array]',
13549 uint8Tag$2 = '[object Uint8Array]',
13550 uint8ClampedTag$2 = '[object Uint8ClampedArray]',
13551 uint16Tag$2 = '[object Uint16Array]',
13552 uint32Tag$2 = '[object Uint32Array]';
13553
13554 /** Used to identify `toStringTag` values supported by `_.clone`. */
13555 var cloneableTags = {};
13556 cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
13557 cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
13558 cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
13559 cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
13560 cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
13561 cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
13562 cloneableTags[numberTag$2] = cloneableTags[objectTag$2] =
13563 cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
13564 cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
13565 cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
13566 cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
13567 cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
13568 cloneableTags[weakMapTag$2] = false;
13569
13570 /**
13571 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
13572 * traversed objects.
13573 *
13574 * @private
13575 * @param {*} value The value to clone.
13576 * @param {boolean} bitmask The bitmask flags.
13577 * 1 - Deep clone
13578 * 2 - Flatten inherited properties
13579 * 4 - Clone symbols
13580 * @param {Function} [customizer] The function to customize cloning.
13581 * @param {string} [key] The key of `value`.
13582 * @param {Object} [object] The parent object of `value`.
13583 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
13584 * @returns {*} Returns the cloned value.
13585 */
13586 function baseClone(value, bitmask, customizer, key, object, stack) {
13587 var result,
13588 isDeep = bitmask & CLONE_DEEP_FLAG,
13589 isFlat = bitmask & CLONE_FLAT_FLAG,
13590 isFull = bitmask & CLONE_SYMBOLS_FLAG;
13591
13592 if (customizer) {
13593 result = object ? customizer(value, key, object, stack) : customizer(value);
13594 }
13595 if (result !== undefined) {
13596 return result;
13597 }
13598 if (!isObject_1(value)) {
13599 return value;
13600 }
13601 var isArr = isArray_1(value);
13602 if (isArr) {
13603 result = _initCloneArray(value);
13604 if (!isDeep) {
13605 return _copyArray(value, result);
13606 }
13607 } else {
13608 var tag = _getTag(value),
13609 isFunc = tag == funcTag$2 || tag == genTag$1;
13610
13611 if (isBuffer_1$1(value)) {
13612 return _cloneBuffer(value, isDeep);
13613 }
13614 if (tag == objectTag$2 || tag == argsTag$2 || (isFunc && !object)) {
13615 result = (isFlat || isFunc) ? {} : _initCloneObject(value);
13616 if (!isDeep) {
13617 return isFlat
13618 ? _copySymbolsIn(value, _baseAssignIn(result, value))
13619 : _copySymbols(value, _baseAssign(result, value));
13620 }
13621 } else {
13622 if (!cloneableTags[tag]) {
13623 return object ? value : {};
13624 }
13625 result = _initCloneByTag(value, tag, isDeep);
13626 }
13627 }
13628 // Check for circular references and return its corresponding clone.
13629 stack || (stack = new _Stack);
13630 var stacked = stack.get(value);
13631 if (stacked) {
13632 return stacked;
13633 }
13634 stack.set(value, result);
13635
13636 if (isSet_1(value)) {
13637 value.forEach(function(subValue) {
13638 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
13639 });
13640 } else if (isMap_1(value)) {
13641 value.forEach(function(subValue, key) {
13642 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
13643 });
13644 }
13645
13646 var keysFunc = isFull
13647 ? (isFlat ? _getAllKeysIn : _getAllKeys)
13648 : (isFlat ? keysIn : keys_1);
13649
13650 var props = isArr ? undefined : keysFunc(value);
13651 _arrayEach(props || value, function(subValue, key) {
13652 if (props) {
13653 key = subValue;
13654 subValue = value[key];
13655 }
13656 // Recursively populate clone (susceptible to call stack limits).
13657 _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
13658 });
13659 return result;
13660 }
13661
13662 var _baseClone = baseClone;
13663
13664 /** Used to compose bitmasks for cloning. */
13665 var CLONE_DEEP_FLAG$1 = 1,
13666 CLONE_SYMBOLS_FLAG$1 = 4;
13667
13668 /**
13669 * This method is like `_.clone` except that it recursively clones `value`.
13670 *
13671 * @static
13672 * @memberOf _
13673 * @since 1.0.0
13674 * @category Lang
13675 * @param {*} value The value to recursively clone.
13676 * @returns {*} Returns the deep cloned value.
13677 * @see _.clone
13678 * @example
13679 *
13680 * var objects = [{ 'a': 1 }, { 'b': 2 }];
13681 *
13682 * var deep = _.cloneDeep(objects);
13683 * console.log(deep[0] === objects[0]);
13684 * // => false
13685 */
13686 function cloneDeep(value) {
13687 return _baseClone(value, CLONE_DEEP_FLAG$1 | CLONE_SYMBOLS_FLAG$1);
13688 }
13689
13690 var cloneDeep_1 = cloneDeep;
13691
13692 //
13693
13694 function createLocalVue(_Vue) {
13695 if ( _Vue === void 0 ) _Vue = Vue;
13696
13697 var instance = _Vue.extend();
13698
13699 // clone global APIs
13700 Object.keys(_Vue).forEach(function (key) {
13701 if (!instance.hasOwnProperty(key)) {
13702 var original = _Vue[key];
13703 // cloneDeep can fail when cloning Vue instances
13704 // cloneDeep checks that the instance has a Symbol
13705 // which errors in Vue < 2.17 (https://github.com/vuejs/vue/pull/7878)
13706 try {
13707 instance[key] =
13708 typeof original === 'object' ? cloneDeep_1(original) : original;
13709 } catch (e) {
13710 instance[key] = original;
13711 }
13712 }
13713 });
13714
13715 // config is not enumerable
13716 instance.config = cloneDeep_1(Vue.config);
13717
13718 instance.config.errorHandler = Vue.config.errorHandler;
13719
13720 // option merge strategies need to be exposed by reference
13721 // so that merge strats registered by plugins can work properly
13722 instance.config.optionMergeStrategies = Vue.config.optionMergeStrategies;
13723
13724 // make sure all extends are based on this instance.
13725 // this is important so that global components registered by plugins,
13726 // e.g. router-link are created using the correct base constructor
13727 instance.options._base = instance;
13728
13729 // compat for vue-router < 2.7.1 where it does not allow multiple installs
13730 if (instance._installedPlugins && instance._installedPlugins.length) {
13731 instance._installedPlugins.length = 0;
13732 }
13733 var use = instance.use;
13734 instance.use = function (plugin) {
13735 var rest = [], len = arguments.length - 1;
13736 while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];
13737
13738 if (plugin.installed === true) {
13739 plugin.installed = false;
13740 }
13741 if (plugin.install && plugin.install.installed === true) {
13742 plugin.install.installed = false;
13743 }
13744 use.call.apply(use, [ instance, plugin ].concat( rest ));
13745 };
13746 return instance
13747 }
13748
13749 //
13750
13751 function isValidSlot(slot) {
13752 return isVueComponent(slot) || typeof slot === 'string'
13753 }
13754
13755 function requiresTemplateCompiler(slot) {
13756 if (typeof slot === 'string' && !vueTemplateCompiler.compileToFunctions) {
13757 throwError(
13758 "vueTemplateCompiler is undefined, you must pass " +
13759 "precompiled components if vue-template-compiler is " +
13760 "undefined"
13761 );
13762 }
13763 }
13764
13765 function validateSlots(slots) {
13766 Object.keys(slots).forEach(function (key) {
13767 var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
13768
13769 slot.forEach(function (slotValue) {
13770 if (!isValidSlot(slotValue)) {
13771 throwError(
13772 "slots[key] must be a Component, string or an array " +
13773 "of Components"
13774 );
13775 }
13776 requiresTemplateCompiler(slotValue);
13777 });
13778 });
13779 }
13780
13781 function vueExtendUnsupportedOption(option) {
13782 return (
13783 "options." + option + " is not supported for " +
13784 "components created with Vue.extend in Vue < 2.3. " +
13785 "You can set " + option + " to false to mount the component."
13786 )
13787 }
13788 // these options aren't supported if Vue is version < 2.3
13789 // for components using Vue.extend. This is due to a bug
13790 // that means the mixins we use to add properties are not applied
13791 // correctly
13792 var UNSUPPORTED_VERSION_OPTIONS = ['mocks', 'stubs', 'localVue'];
13793
13794 function validateOptions(options, component) {
13795 if (
13796 options.attachTo &&
13797 !isHTMLElement(options.attachTo) &&
13798 !isDomSelector(options.attachTo)
13799 ) {
13800 throwError(
13801 "options.attachTo should be a valid HTMLElement or CSS selector string"
13802 );
13803 }
13804 if ('attachToDocument' in options) {
13805 warnDeprecated(
13806 "options.attachToDocument is deprecated in favor of options.attachTo and will be removed in a future release"
13807 );
13808 }
13809 if (options.parentComponent && !isPlainObject(options.parentComponent)) {
13810 throwError(
13811 "options.parentComponent should be a valid Vue component options object"
13812 );
13813 }
13814
13815 if (!isFunctionalComponent(component) && options.context) {
13816 throwError(
13817 "mount.context can only be used when mounting a functional component"
13818 );
13819 }
13820
13821 if (options.context && !isPlainObject(options.context)) {
13822 throwError('mount.context must be an object');
13823 }
13824
13825 if (VUE_VERSION < 2.3 && isConstructor(component)) {
13826 UNSUPPORTED_VERSION_OPTIONS.forEach(function (option) {
13827 if (options[option]) {
13828 throwError(vueExtendUnsupportedOption(option));
13829 }
13830 });
13831 }
13832
13833 if (options.slots) {
13834 compileTemplateForSlots(options.slots);
13835 // validate slots outside of the createSlots function so
13836 // that we can throw an error without it being caught by
13837 // the Vue error handler
13838 // $FlowIgnore
13839 validateSlots(options.slots);
13840 }
13841 }
13842
13843 Vue.config.productionTip = false;
13844 Vue.config.devtools = false;
13845
13846 function mount(component, options) {
13847 if ( options === void 0 ) options = {};
13848
13849 warnIfNoWindow();
13850
13851 polyfill();
13852
13853 addGlobalErrorHandler(Vue);
13854
13855 var _Vue = createLocalVue(options.localVue);
13856
13857 var mergedOptions = mergeOptions(options, config);
13858
13859 validateOptions(mergedOptions, component);
13860
13861 var parentVm = createInstance(component, mergedOptions, _Vue);
13862
13863 var el =
13864 options.attachTo || (options.attachToDocument ? createElement() : undefined);
13865 var vm = parentVm.$mount(el);
13866
13867 component._Ctor = {};
13868
13869 throwIfInstancesThrew(vm);
13870
13871 var wrapperOptions = {
13872 attachedToDocument: !!el
13873 };
13874
13875 var root = parentVm.$options._isFunctionalContainer
13876 ? vm._vnode
13877 : vm.$children[0];
13878
13879 return createWrapper(root, wrapperOptions)
13880 }
13881
13882 //
13883
13884
13885 function shallowMount(
13886 component,
13887 options
13888 ) {
13889 if ( options === void 0 ) options = {};
13890
13891 return mount(component, Object.assign({}, options,
13892 {shouldProxy: true}))
13893 }
13894
13895 //
13896 var toTypes = [String, Object];
13897 var eventTypes = [String, Array];
13898
13899 var RouterLinkStub = {
13900 name: 'RouterLinkStub',
13901 props: {
13902 to: {
13903 type: toTypes,
13904 required: true
13905 },
13906 tag: {
13907 type: String,
13908 default: 'a'
13909 },
13910 exact: Boolean,
13911 append: Boolean,
13912 replace: Boolean,
13913 activeClass: String,
13914 exactActiveClass: String,
13915 event: {
13916 type: eventTypes,
13917 default: 'click'
13918 }
13919 },
13920 render: function render(h) {
13921 return h(this.tag, undefined, this.$slots.default)
13922 }
13923 };
13924
13925 function shallow(component, options) {
13926 warn(
13927 "shallow has been renamed to shallowMount. shallow " +
13928 "will be removed in 1.0.0, use shallowMount instead"
13929 );
13930 return shallowMount(component, options)
13931 }
13932
13933 exports.RouterLinkStub = RouterLinkStub;
13934 exports.Wrapper = Wrapper;
13935 exports.WrapperArray = WrapperArray;
13936 exports.config = config;
13937 exports.createLocalVue = createLocalVue;
13938 exports.createWrapper = createWrapper;
13939 exports.enableAutoDestroy = enableAutoDestroy;
13940 exports.mount = mount;
13941 exports.resetAutoDestroyState = resetAutoDestroyState;
13942 exports.shallow = shallow;
13943 exports.shallowMount = shallowMount;
13944
13945 return exports;
13946
13947}({}, Vue, VueTemplateCompiler));