UNPKG

410 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
7var Vue = _interopDefault(require('vue'));
8var vueTemplateCompiler = require('vue-template-compiler');
9
10//
11
12function createVNodes(vm, slotValue, name) {
13 var el = vueTemplateCompiler.compileToFunctions(
14 ("<div><template slot=" + name + ">" + slotValue + "</template></div>")
15 );
16 var _staticRenderFns = vm._renderProxy.$options.staticRenderFns;
17 var _staticTrees = vm._renderProxy._staticTrees;
18 vm._renderProxy._staticTrees = [];
19 vm._renderProxy.$options.staticRenderFns = el.staticRenderFns;
20 var vnode = el.render.call(vm._renderProxy, vm.$createElement);
21 vm._renderProxy.$options.staticRenderFns = _staticRenderFns;
22 vm._renderProxy._staticTrees = _staticTrees;
23 return vnode.children[0]
24}
25
26function createVNodesForSlot(
27 vm,
28 slotValue,
29 name
30) {
31 if (typeof slotValue === 'string') {
32 return createVNodes(vm, slotValue, name)
33 }
34 var vnode = vm.$createElement(slotValue)
35 ;(vnode.data || (vnode.data = {})).slot = name;
36 return vnode
37}
38
39function createSlotVNodes(
40 vm,
41 slots
42) {
43 return Object.keys(slots).reduce(function (acc, key) {
44 var content = slots[key];
45 if (Array.isArray(content)) {
46 var nodes = content.map(function (slotDef) { return createVNodesForSlot(vm, slotDef, key); }
47 );
48 return acc.concat(nodes)
49 }
50
51 return acc.concat(createVNodesForSlot(vm, content, key))
52 }, [])
53}
54
55var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
56
57function createCommonjsModule(fn, module) {
58 return module = { exports: {} }, fn(module, module.exports), module.exports;
59}
60
61function getCjsExportFromNamespace (n) {
62 return n && n['default'] || n;
63}
64
65var semver = createCommonjsModule(function (module, exports) {
66exports = module.exports = SemVer;
67
68var debug;
69/* istanbul ignore next */
70if (typeof process === 'object' &&
71 process.env &&
72 process.env.NODE_DEBUG &&
73 /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
74 debug = function () {
75 var args = Array.prototype.slice.call(arguments, 0);
76 args.unshift('SEMVER');
77 console.log.apply(console, args);
78 };
79} else {
80 debug = function () {};
81}
82
83// Note: this is the semver.org version of the spec that it implements
84// Not necessarily the package version of this code.
85exports.SEMVER_SPEC_VERSION = '2.0.0';
86
87var MAX_LENGTH = 256;
88var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
89 /* istanbul ignore next */ 9007199254740991;
90
91// Max safe segment length for coercion.
92var MAX_SAFE_COMPONENT_LENGTH = 16;
93
94// The actual regexps go on exports.re
95var re = exports.re = [];
96var src = exports.src = [];
97var t = exports.tokens = {};
98var R = 0;
99
100function tok (n) {
101 t[n] = R++;
102}
103
104// The following Regular Expressions can be used for tokenizing,
105// validating, and parsing SemVer version strings.
106
107// ## Numeric Identifier
108// A single `0`, or a non-zero digit followed by zero or more digits.
109
110tok('NUMERICIDENTIFIER');
111src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
112tok('NUMERICIDENTIFIERLOOSE');
113src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
114
115// ## Non-numeric Identifier
116// Zero or more digits, followed by a letter or hyphen, and then zero or
117// more letters, digits, or hyphens.
118
119tok('NONNUMERICIDENTIFIER');
120src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
121
122// ## Main Version
123// Three dot-separated numeric identifiers.
124
125tok('MAINVERSION');
126src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
127 '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
128 '(' + src[t.NUMERICIDENTIFIER] + ')';
129
130tok('MAINVERSIONLOOSE');
131src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
132 '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
133 '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
134
135// ## Pre-release Version Identifier
136// A numeric identifier, or a non-numeric identifier.
137
138tok('PRERELEASEIDENTIFIER');
139src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
140 '|' + src[t.NONNUMERICIDENTIFIER] + ')';
141
142tok('PRERELEASEIDENTIFIERLOOSE');
143src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
144 '|' + src[t.NONNUMERICIDENTIFIER] + ')';
145
146// ## Pre-release Version
147// Hyphen, followed by one or more dot-separated pre-release version
148// identifiers.
149
150tok('PRERELEASE');
151src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
152 '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
153
154tok('PRERELEASELOOSE');
155src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
156 '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
157
158// ## Build Metadata Identifier
159// Any combination of digits, letters, or hyphens.
160
161tok('BUILDIDENTIFIER');
162src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
163
164// ## Build Metadata
165// Plus sign, followed by one or more period-separated build metadata
166// identifiers.
167
168tok('BUILD');
169src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
170 '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
171
172// ## Full Version String
173// A main version, followed optionally by a pre-release version and
174// build metadata.
175
176// Note that the only major, minor, patch, and pre-release sections of
177// the version string are capturing groups. The build metadata is not a
178// capturing group, because it should not ever be used in version
179// comparison.
180
181tok('FULL');
182tok('FULLPLAIN');
183src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
184 src[t.PRERELEASE] + '?' +
185 src[t.BUILD] + '?';
186
187src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
188
189// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
190// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
191// common in the npm registry.
192tok('LOOSEPLAIN');
193src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
194 src[t.PRERELEASELOOSE] + '?' +
195 src[t.BUILD] + '?';
196
197tok('LOOSE');
198src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
199
200tok('GTLT');
201src[t.GTLT] = '((?:<|>)?=?)';
202
203// Something like "2.*" or "1.2.x".
204// Note that "x.x" is a valid xRange identifer, meaning "any version"
205// Only the first item is strictly required.
206tok('XRANGEIDENTIFIERLOOSE');
207src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
208tok('XRANGEIDENTIFIER');
209src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
210
211tok('XRANGEPLAIN');
212src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
213 '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
214 '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
215 '(?:' + src[t.PRERELEASE] + ')?' +
216 src[t.BUILD] + '?' +
217 ')?)?';
218
219tok('XRANGEPLAINLOOSE');
220src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
221 '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
222 '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
223 '(?:' + src[t.PRERELEASELOOSE] + ')?' +
224 src[t.BUILD] + '?' +
225 ')?)?';
226
227tok('XRANGE');
228src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
229tok('XRANGELOOSE');
230src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
231
232// Coercion.
233// Extract anything that could conceivably be a part of a valid semver
234tok('COERCE');
235src[t.COERCE] = '(^|[^\\d])' +
236 '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
237 '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
238 '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
239 '(?:$|[^\\d])';
240tok('COERCERTL');
241re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
242
243// Tilde ranges.
244// Meaning is "reasonably at or greater than"
245tok('LONETILDE');
246src[t.LONETILDE] = '(?:~>?)';
247
248tok('TILDETRIM');
249src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
250re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
251var tildeTrimReplace = '$1~';
252
253tok('TILDE');
254src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
255tok('TILDELOOSE');
256src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
257
258// Caret ranges.
259// Meaning is "at least and backwards compatible with"
260tok('LONECARET');
261src[t.LONECARET] = '(?:\\^)';
262
263tok('CARETTRIM');
264src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
265re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
266var caretTrimReplace = '$1^';
267
268tok('CARET');
269src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
270tok('CARETLOOSE');
271src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
272
273// A simple gt/lt/eq thing, or just "" to indicate "any version"
274tok('COMPARATORLOOSE');
275src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
276tok('COMPARATOR');
277src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
278
279// An expression to strip any whitespace between the gtlt and the thing
280// it modifies, so that `> 1.2.3` ==> `>1.2.3`
281tok('COMPARATORTRIM');
282src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
283 '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
284
285// this one has to use the /g flag
286re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
287var comparatorTrimReplace = '$1$2$3';
288
289// Something like `1.2.3 - 1.2.4`
290// Note that these all use the loose form, because they'll be
291// checked against either the strict or loose comparator form
292// later.
293tok('HYPHENRANGE');
294src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
295 '\\s+-\\s+' +
296 '(' + src[t.XRANGEPLAIN] + ')' +
297 '\\s*$';
298
299tok('HYPHENRANGELOOSE');
300src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
301 '\\s+-\\s+' +
302 '(' + src[t.XRANGEPLAINLOOSE] + ')' +
303 '\\s*$';
304
305// Star ranges basically just allow anything at all.
306tok('STAR');
307src[t.STAR] = '(<|>)?=?\\s*\\*';
308
309// Compile to actual regexp objects.
310// All are flag-free, unless they were created above with a flag.
311for (var i = 0; i < R; i++) {
312 debug(i, src[i]);
313 if (!re[i]) {
314 re[i] = new RegExp(src[i]);
315 }
316}
317
318exports.parse = parse;
319function parse (version, options) {
320 if (!options || typeof options !== 'object') {
321 options = {
322 loose: !!options,
323 includePrerelease: false
324 };
325 }
326
327 if (version instanceof SemVer) {
328 return version
329 }
330
331 if (typeof version !== 'string') {
332 return null
333 }
334
335 if (version.length > MAX_LENGTH) {
336 return null
337 }
338
339 var r = options.loose ? re[t.LOOSE] : re[t.FULL];
340 if (!r.test(version)) {
341 return null
342 }
343
344 try {
345 return new SemVer(version, options)
346 } catch (er) {
347 return null
348 }
349}
350
351exports.valid = valid;
352function valid (version, options) {
353 var v = parse(version, options);
354 return v ? v.version : null
355}
356
357exports.clean = clean;
358function clean (version, options) {
359 var s = parse(version.trim().replace(/^[=v]+/, ''), options);
360 return s ? s.version : null
361}
362
363exports.SemVer = SemVer;
364
365function SemVer (version, options) {
366 if (!options || typeof options !== 'object') {
367 options = {
368 loose: !!options,
369 includePrerelease: false
370 };
371 }
372 if (version instanceof SemVer) {
373 if (version.loose === options.loose) {
374 return version
375 } else {
376 version = version.version;
377 }
378 } else if (typeof version !== 'string') {
379 throw new TypeError('Invalid Version: ' + version)
380 }
381
382 if (version.length > MAX_LENGTH) {
383 throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
384 }
385
386 if (!(this instanceof SemVer)) {
387 return new SemVer(version, options)
388 }
389
390 debug('SemVer', version, options);
391 this.options = options;
392 this.loose = !!options.loose;
393
394 var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
395
396 if (!m) {
397 throw new TypeError('Invalid Version: ' + version)
398 }
399
400 this.raw = version;
401
402 // these are actually numbers
403 this.major = +m[1];
404 this.minor = +m[2];
405 this.patch = +m[3];
406
407 if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
408 throw new TypeError('Invalid major version')
409 }
410
411 if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
412 throw new TypeError('Invalid minor version')
413 }
414
415 if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
416 throw new TypeError('Invalid patch version')
417 }
418
419 // numberify any prerelease numeric ids
420 if (!m[4]) {
421 this.prerelease = [];
422 } else {
423 this.prerelease = m[4].split('.').map(function (id) {
424 if (/^[0-9]+$/.test(id)) {
425 var num = +id;
426 if (num >= 0 && num < MAX_SAFE_INTEGER) {
427 return num
428 }
429 }
430 return id
431 });
432 }
433
434 this.build = m[5] ? m[5].split('.') : [];
435 this.format();
436}
437
438SemVer.prototype.format = function () {
439 this.version = this.major + '.' + this.minor + '.' + this.patch;
440 if (this.prerelease.length) {
441 this.version += '-' + this.prerelease.join('.');
442 }
443 return this.version
444};
445
446SemVer.prototype.toString = function () {
447 return this.version
448};
449
450SemVer.prototype.compare = function (other) {
451 debug('SemVer.compare', this.version, this.options, other);
452 if (!(other instanceof SemVer)) {
453 other = new SemVer(other, this.options);
454 }
455
456 return this.compareMain(other) || this.comparePre(other)
457};
458
459SemVer.prototype.compareMain = function (other) {
460 if (!(other instanceof SemVer)) {
461 other = new SemVer(other, this.options);
462 }
463
464 return compareIdentifiers(this.major, other.major) ||
465 compareIdentifiers(this.minor, other.minor) ||
466 compareIdentifiers(this.patch, other.patch)
467};
468
469SemVer.prototype.comparePre = function (other) {
470 if (!(other instanceof SemVer)) {
471 other = new SemVer(other, this.options);
472 }
473
474 // NOT having a prerelease is > having one
475 if (this.prerelease.length && !other.prerelease.length) {
476 return -1
477 } else if (!this.prerelease.length && other.prerelease.length) {
478 return 1
479 } else if (!this.prerelease.length && !other.prerelease.length) {
480 return 0
481 }
482
483 var i = 0;
484 do {
485 var a = this.prerelease[i];
486 var b = other.prerelease[i];
487 debug('prerelease compare', i, a, b);
488 if (a === undefined && b === undefined) {
489 return 0
490 } else if (b === undefined) {
491 return 1
492 } else if (a === undefined) {
493 return -1
494 } else if (a === b) {
495 continue
496 } else {
497 return compareIdentifiers(a, b)
498 }
499 } while (++i)
500};
501
502SemVer.prototype.compareBuild = function (other) {
503 if (!(other instanceof SemVer)) {
504 other = new SemVer(other, this.options);
505 }
506
507 var i = 0;
508 do {
509 var a = this.build[i];
510 var b = other.build[i];
511 debug('prerelease compare', i, a, b);
512 if (a === undefined && b === undefined) {
513 return 0
514 } else if (b === undefined) {
515 return 1
516 } else if (a === undefined) {
517 return -1
518 } else if (a === b) {
519 continue
520 } else {
521 return compareIdentifiers(a, b)
522 }
523 } while (++i)
524};
525
526// preminor will bump the version up to the next minor release, and immediately
527// down to pre-release. premajor and prepatch work the same way.
528SemVer.prototype.inc = function (release, identifier) {
529 switch (release) {
530 case 'premajor':
531 this.prerelease.length = 0;
532 this.patch = 0;
533 this.minor = 0;
534 this.major++;
535 this.inc('pre', identifier);
536 break
537 case 'preminor':
538 this.prerelease.length = 0;
539 this.patch = 0;
540 this.minor++;
541 this.inc('pre', identifier);
542 break
543 case 'prepatch':
544 // If this is already a prerelease, it will bump to the next version
545 // drop any prereleases that might already exist, since they are not
546 // relevant at this point.
547 this.prerelease.length = 0;
548 this.inc('patch', identifier);
549 this.inc('pre', identifier);
550 break
551 // If the input is a non-prerelease version, this acts the same as
552 // prepatch.
553 case 'prerelease':
554 if (this.prerelease.length === 0) {
555 this.inc('patch', identifier);
556 }
557 this.inc('pre', identifier);
558 break
559
560 case 'major':
561 // If this is a pre-major version, bump up to the same major version.
562 // Otherwise increment major.
563 // 1.0.0-5 bumps to 1.0.0
564 // 1.1.0 bumps to 2.0.0
565 if (this.minor !== 0 ||
566 this.patch !== 0 ||
567 this.prerelease.length === 0) {
568 this.major++;
569 }
570 this.minor = 0;
571 this.patch = 0;
572 this.prerelease = [];
573 break
574 case 'minor':
575 // If this is a pre-minor version, bump up to the same minor version.
576 // Otherwise increment minor.
577 // 1.2.0-5 bumps to 1.2.0
578 // 1.2.1 bumps to 1.3.0
579 if (this.patch !== 0 || this.prerelease.length === 0) {
580 this.minor++;
581 }
582 this.patch = 0;
583 this.prerelease = [];
584 break
585 case 'patch':
586 // If this is not a pre-release version, it will increment the patch.
587 // If it is a pre-release it will bump up to the same patch version.
588 // 1.2.0-5 patches to 1.2.0
589 // 1.2.0 patches to 1.2.1
590 if (this.prerelease.length === 0) {
591 this.patch++;
592 }
593 this.prerelease = [];
594 break
595 // This probably shouldn't be used publicly.
596 // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
597 case 'pre':
598 if (this.prerelease.length === 0) {
599 this.prerelease = [0];
600 } else {
601 var i = this.prerelease.length;
602 while (--i >= 0) {
603 if (typeof this.prerelease[i] === 'number') {
604 this.prerelease[i]++;
605 i = -2;
606 }
607 }
608 if (i === -1) {
609 // didn't increment anything
610 this.prerelease.push(0);
611 }
612 }
613 if (identifier) {
614 // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
615 // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
616 if (this.prerelease[0] === identifier) {
617 if (isNaN(this.prerelease[1])) {
618 this.prerelease = [identifier, 0];
619 }
620 } else {
621 this.prerelease = [identifier, 0];
622 }
623 }
624 break
625
626 default:
627 throw new Error('invalid increment argument: ' + release)
628 }
629 this.format();
630 this.raw = this.version;
631 return this
632};
633
634exports.inc = inc;
635function inc (version, release, loose, identifier) {
636 if (typeof (loose) === 'string') {
637 identifier = loose;
638 loose = undefined;
639 }
640
641 try {
642 return new SemVer(version, loose).inc(release, identifier).version
643 } catch (er) {
644 return null
645 }
646}
647
648exports.diff = diff;
649function diff (version1, version2) {
650 if (eq(version1, version2)) {
651 return null
652 } else {
653 var v1 = parse(version1);
654 var v2 = parse(version2);
655 var prefix = '';
656 if (v1.prerelease.length || v2.prerelease.length) {
657 prefix = 'pre';
658 var defaultResult = 'prerelease';
659 }
660 for (var key in v1) {
661 if (key === 'major' || key === 'minor' || key === 'patch') {
662 if (v1[key] !== v2[key]) {
663 return prefix + key
664 }
665 }
666 }
667 return defaultResult // may be undefined
668 }
669}
670
671exports.compareIdentifiers = compareIdentifiers;
672
673var numeric = /^[0-9]+$/;
674function compareIdentifiers (a, b) {
675 var anum = numeric.test(a);
676 var bnum = numeric.test(b);
677
678 if (anum && bnum) {
679 a = +a;
680 b = +b;
681 }
682
683 return a === b ? 0
684 : (anum && !bnum) ? -1
685 : (bnum && !anum) ? 1
686 : a < b ? -1
687 : 1
688}
689
690exports.rcompareIdentifiers = rcompareIdentifiers;
691function rcompareIdentifiers (a, b) {
692 return compareIdentifiers(b, a)
693}
694
695exports.major = major;
696function major (a, loose) {
697 return new SemVer(a, loose).major
698}
699
700exports.minor = minor;
701function minor (a, loose) {
702 return new SemVer(a, loose).minor
703}
704
705exports.patch = patch;
706function patch (a, loose) {
707 return new SemVer(a, loose).patch
708}
709
710exports.compare = compare;
711function compare (a, b, loose) {
712 return new SemVer(a, loose).compare(new SemVer(b, loose))
713}
714
715exports.compareLoose = compareLoose;
716function compareLoose (a, b) {
717 return compare(a, b, true)
718}
719
720exports.compareBuild = compareBuild;
721function compareBuild (a, b, loose) {
722 var versionA = new SemVer(a, loose);
723 var versionB = new SemVer(b, loose);
724 return versionA.compare(versionB) || versionA.compareBuild(versionB)
725}
726
727exports.rcompare = rcompare;
728function rcompare (a, b, loose) {
729 return compare(b, a, loose)
730}
731
732exports.sort = sort;
733function sort (list, loose) {
734 return list.sort(function (a, b) {
735 return exports.compareBuild(a, b, loose)
736 })
737}
738
739exports.rsort = rsort;
740function rsort (list, loose) {
741 return list.sort(function (a, b) {
742 return exports.compareBuild(b, a, loose)
743 })
744}
745
746exports.gt = gt;
747function gt (a, b, loose) {
748 return compare(a, b, loose) > 0
749}
750
751exports.lt = lt;
752function lt (a, b, loose) {
753 return compare(a, b, loose) < 0
754}
755
756exports.eq = eq;
757function eq (a, b, loose) {
758 return compare(a, b, loose) === 0
759}
760
761exports.neq = neq;
762function neq (a, b, loose) {
763 return compare(a, b, loose) !== 0
764}
765
766exports.gte = gte;
767function gte (a, b, loose) {
768 return compare(a, b, loose) >= 0
769}
770
771exports.lte = lte;
772function lte (a, b, loose) {
773 return compare(a, b, loose) <= 0
774}
775
776exports.cmp = cmp;
777function cmp (a, op, b, loose) {
778 switch (op) {
779 case '===':
780 if (typeof a === 'object')
781 { a = a.version; }
782 if (typeof b === 'object')
783 { b = b.version; }
784 return a === b
785
786 case '!==':
787 if (typeof a === 'object')
788 { a = a.version; }
789 if (typeof b === 'object')
790 { b = b.version; }
791 return a !== b
792
793 case '':
794 case '=':
795 case '==':
796 return eq(a, b, loose)
797
798 case '!=':
799 return neq(a, b, loose)
800
801 case '>':
802 return gt(a, b, loose)
803
804 case '>=':
805 return gte(a, b, loose)
806
807 case '<':
808 return lt(a, b, loose)
809
810 case '<=':
811 return lte(a, b, loose)
812
813 default:
814 throw new TypeError('Invalid operator: ' + op)
815 }
816}
817
818exports.Comparator = Comparator;
819function Comparator (comp, options) {
820 if (!options || typeof options !== 'object') {
821 options = {
822 loose: !!options,
823 includePrerelease: false
824 };
825 }
826
827 if (comp instanceof Comparator) {
828 if (comp.loose === !!options.loose) {
829 return comp
830 } else {
831 comp = comp.value;
832 }
833 }
834
835 if (!(this instanceof Comparator)) {
836 return new Comparator(comp, options)
837 }
838
839 debug('comparator', comp, options);
840 this.options = options;
841 this.loose = !!options.loose;
842 this.parse(comp);
843
844 if (this.semver === ANY) {
845 this.value = '';
846 } else {
847 this.value = this.operator + this.semver.version;
848 }
849
850 debug('comp', this);
851}
852
853var ANY = {};
854Comparator.prototype.parse = function (comp) {
855 var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
856 var m = comp.match(r);
857
858 if (!m) {
859 throw new TypeError('Invalid comparator: ' + comp)
860 }
861
862 this.operator = m[1] !== undefined ? m[1] : '';
863 if (this.operator === '=') {
864 this.operator = '';
865 }
866
867 // if it literally is just '>' or '' then allow anything.
868 if (!m[2]) {
869 this.semver = ANY;
870 } else {
871 this.semver = new SemVer(m[2], this.options.loose);
872 }
873};
874
875Comparator.prototype.toString = function () {
876 return this.value
877};
878
879Comparator.prototype.test = function (version) {
880 debug('Comparator.test', version, this.options.loose);
881
882 if (this.semver === ANY || version === ANY) {
883 return true
884 }
885
886 if (typeof version === 'string') {
887 try {
888 version = new SemVer(version, this.options);
889 } catch (er) {
890 return false
891 }
892 }
893
894 return cmp(version, this.operator, this.semver, this.options)
895};
896
897Comparator.prototype.intersects = function (comp, options) {
898 if (!(comp instanceof Comparator)) {
899 throw new TypeError('a Comparator is required')
900 }
901
902 if (!options || typeof options !== 'object') {
903 options = {
904 loose: !!options,
905 includePrerelease: false
906 };
907 }
908
909 var rangeTmp;
910
911 if (this.operator === '') {
912 if (this.value === '') {
913 return true
914 }
915 rangeTmp = new Range(comp.value, options);
916 return satisfies(this.value, rangeTmp, options)
917 } else if (comp.operator === '') {
918 if (comp.value === '') {
919 return true
920 }
921 rangeTmp = new Range(this.value, options);
922 return satisfies(comp.semver, rangeTmp, options)
923 }
924
925 var sameDirectionIncreasing =
926 (this.operator === '>=' || this.operator === '>') &&
927 (comp.operator === '>=' || comp.operator === '>');
928 var sameDirectionDecreasing =
929 (this.operator === '<=' || this.operator === '<') &&
930 (comp.operator === '<=' || comp.operator === '<');
931 var sameSemVer = this.semver.version === comp.semver.version;
932 var differentDirectionsInclusive =
933 (this.operator === '>=' || this.operator === '<=') &&
934 (comp.operator === '>=' || comp.operator === '<=');
935 var oppositeDirectionsLessThan =
936 cmp(this.semver, '<', comp.semver, options) &&
937 ((this.operator === '>=' || this.operator === '>') &&
938 (comp.operator === '<=' || comp.operator === '<'));
939 var oppositeDirectionsGreaterThan =
940 cmp(this.semver, '>', comp.semver, options) &&
941 ((this.operator === '<=' || this.operator === '<') &&
942 (comp.operator === '>=' || comp.operator === '>'));
943
944 return sameDirectionIncreasing || sameDirectionDecreasing ||
945 (sameSemVer && differentDirectionsInclusive) ||
946 oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
947};
948
949exports.Range = Range;
950function Range (range, options) {
951 if (!options || typeof options !== 'object') {
952 options = {
953 loose: !!options,
954 includePrerelease: false
955 };
956 }
957
958 if (range instanceof Range) {
959 if (range.loose === !!options.loose &&
960 range.includePrerelease === !!options.includePrerelease) {
961 return range
962 } else {
963 return new Range(range.raw, options)
964 }
965 }
966
967 if (range instanceof Comparator) {
968 return new Range(range.value, options)
969 }
970
971 if (!(this instanceof Range)) {
972 return new Range(range, options)
973 }
974
975 this.options = options;
976 this.loose = !!options.loose;
977 this.includePrerelease = !!options.includePrerelease;
978
979 // First, split based on boolean or ||
980 this.raw = range;
981 this.set = range.split(/\s*\|\|\s*/).map(function (range) {
982 return this.parseRange(range.trim())
983 }, this).filter(function (c) {
984 // throw out any that are not relevant for whatever reason
985 return c.length
986 });
987
988 if (!this.set.length) {
989 throw new TypeError('Invalid SemVer Range: ' + range)
990 }
991
992 this.format();
993}
994
995Range.prototype.format = function () {
996 this.range = this.set.map(function (comps) {
997 return comps.join(' ').trim()
998 }).join('||').trim();
999 return this.range
1000};
1001
1002Range.prototype.toString = function () {
1003 return this.range
1004};
1005
1006Range.prototype.parseRange = function (range) {
1007 var loose = this.options.loose;
1008 range = range.trim();
1009 // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
1010 var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
1011 range = range.replace(hr, hyphenReplace);
1012 debug('hyphen replace', range);
1013 // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
1014 range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
1015 debug('comparator trim', range, re[t.COMPARATORTRIM]);
1016
1017 // `~ 1.2.3` => `~1.2.3`
1018 range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
1019
1020 // `^ 1.2.3` => `^1.2.3`
1021 range = range.replace(re[t.CARETTRIM], caretTrimReplace);
1022
1023 // normalize spaces
1024 range = range.split(/\s+/).join(' ');
1025
1026 // At this point, the range is completely trimmed and
1027 // ready to be split into comparators.
1028
1029 var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1030 var set = range.split(' ').map(function (comp) {
1031 return parseComparator(comp, this.options)
1032 }, this).join(' ').split(/\s+/);
1033 if (this.options.loose) {
1034 // in loose mode, throw out any that are not valid comparators
1035 set = set.filter(function (comp) {
1036 return !!comp.match(compRe)
1037 });
1038 }
1039 set = set.map(function (comp) {
1040 return new Comparator(comp, this.options)
1041 }, this);
1042
1043 return set
1044};
1045
1046Range.prototype.intersects = function (range, options) {
1047 if (!(range instanceof Range)) {
1048 throw new TypeError('a Range is required')
1049 }
1050
1051 return this.set.some(function (thisComparators) {
1052 return (
1053 isSatisfiable(thisComparators, options) &&
1054 range.set.some(function (rangeComparators) {
1055 return (
1056 isSatisfiable(rangeComparators, options) &&
1057 thisComparators.every(function (thisComparator) {
1058 return rangeComparators.every(function (rangeComparator) {
1059 return thisComparator.intersects(rangeComparator, options)
1060 })
1061 })
1062 )
1063 })
1064 )
1065 })
1066};
1067
1068// take a set of comparators and determine whether there
1069// exists a version which can satisfy it
1070function isSatisfiable (comparators, options) {
1071 var result = true;
1072 var remainingComparators = comparators.slice();
1073 var testComparator = remainingComparators.pop();
1074
1075 while (result && remainingComparators.length) {
1076 result = remainingComparators.every(function (otherComparator) {
1077 return testComparator.intersects(otherComparator, options)
1078 });
1079
1080 testComparator = remainingComparators.pop();
1081 }
1082
1083 return result
1084}
1085
1086// Mostly just for testing and legacy API reasons
1087exports.toComparators = toComparators;
1088function toComparators (range, options) {
1089 return new Range(range, options).set.map(function (comp) {
1090 return comp.map(function (c) {
1091 return c.value
1092 }).join(' ').trim().split(' ')
1093 })
1094}
1095
1096// comprised of xranges, tildes, stars, and gtlt's at this point.
1097// already replaced the hyphen ranges
1098// turn into a set of JUST comparators.
1099function parseComparator (comp, options) {
1100 debug('comp', comp, options);
1101 comp = replaceCarets(comp, options);
1102 debug('caret', comp);
1103 comp = replaceTildes(comp, options);
1104 debug('tildes', comp);
1105 comp = replaceXRanges(comp, options);
1106 debug('xrange', comp);
1107 comp = replaceStars(comp, options);
1108 debug('stars', comp);
1109 return comp
1110}
1111
1112function isX (id) {
1113 return !id || id.toLowerCase() === 'x' || id === '*'
1114}
1115
1116// ~, ~> --> * (any, kinda silly)
1117// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
1118// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
1119// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
1120// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
1121// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
1122function replaceTildes (comp, options) {
1123 return comp.trim().split(/\s+/).map(function (comp) {
1124 return replaceTilde(comp, options)
1125 }).join(' ')
1126}
1127
1128function replaceTilde (comp, options) {
1129 var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1130 return comp.replace(r, function (_, M, m, p, pr) {
1131 debug('tilde', comp, _, M, m, p, pr);
1132 var ret;
1133
1134 if (isX(M)) {
1135 ret = '';
1136 } else if (isX(m)) {
1137 ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
1138 } else if (isX(p)) {
1139 // ~1.2 == >=1.2.0 <1.3.0
1140 ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
1141 } else if (pr) {
1142 debug('replaceTilde pr', pr);
1143 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
1144 ' <' + M + '.' + (+m + 1) + '.0';
1145 } else {
1146 // ~1.2.3 == >=1.2.3 <1.3.0
1147 ret = '>=' + M + '.' + m + '.' + p +
1148 ' <' + M + '.' + (+m + 1) + '.0';
1149 }
1150
1151 debug('tilde return', ret);
1152 return ret
1153 })
1154}
1155
1156// ^ --> * (any, kinda silly)
1157// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
1158// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
1159// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
1160// ^1.2.3 --> >=1.2.3 <2.0.0
1161// ^1.2.0 --> >=1.2.0 <2.0.0
1162function replaceCarets (comp, options) {
1163 return comp.trim().split(/\s+/).map(function (comp) {
1164 return replaceCaret(comp, options)
1165 }).join(' ')
1166}
1167
1168function replaceCaret (comp, options) {
1169 debug('caret', comp, options);
1170 var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1171 return comp.replace(r, function (_, M, m, p, pr) {
1172 debug('caret', comp, _, M, m, p, pr);
1173 var ret;
1174
1175 if (isX(M)) {
1176 ret = '';
1177 } else if (isX(m)) {
1178 ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
1179 } else if (isX(p)) {
1180 if (M === '0') {
1181 ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
1182 } else {
1183 ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
1184 }
1185 } else if (pr) {
1186 debug('replaceCaret pr', pr);
1187 if (M === '0') {
1188 if (m === '0') {
1189 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
1190 ' <' + M + '.' + m + '.' + (+p + 1);
1191 } else {
1192 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
1193 ' <' + M + '.' + (+m + 1) + '.0';
1194 }
1195 } else {
1196 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
1197 ' <' + (+M + 1) + '.0.0';
1198 }
1199 } else {
1200 debug('no pr');
1201 if (M === '0') {
1202 if (m === '0') {
1203 ret = '>=' + M + '.' + m + '.' + p +
1204 ' <' + M + '.' + m + '.' + (+p + 1);
1205 } else {
1206 ret = '>=' + M + '.' + m + '.' + p +
1207 ' <' + M + '.' + (+m + 1) + '.0';
1208 }
1209 } else {
1210 ret = '>=' + M + '.' + m + '.' + p +
1211 ' <' + (+M + 1) + '.0.0';
1212 }
1213 }
1214
1215 debug('caret return', ret);
1216 return ret
1217 })
1218}
1219
1220function replaceXRanges (comp, options) {
1221 debug('replaceXRanges', comp, options);
1222 return comp.split(/\s+/).map(function (comp) {
1223 return replaceXRange(comp, options)
1224 }).join(' ')
1225}
1226
1227function replaceXRange (comp, options) {
1228 comp = comp.trim();
1229 var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
1230 return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
1231 debug('xRange', comp, ret, gtlt, M, m, p, pr);
1232 var xM = isX(M);
1233 var xm = xM || isX(m);
1234 var xp = xm || isX(p);
1235 var anyX = xp;
1236
1237 if (gtlt === '=' && anyX) {
1238 gtlt = '';
1239 }
1240
1241 // if we're including prereleases in the match, then we need
1242 // to fix this to -0, the lowest possible prerelease value
1243 pr = options.includePrerelease ? '-0' : '';
1244
1245 if (xM) {
1246 if (gtlt === '>' || gtlt === '<') {
1247 // nothing is allowed
1248 ret = '<0.0.0-0';
1249 } else {
1250 // nothing is forbidden
1251 ret = '*';
1252 }
1253 } else if (gtlt && anyX) {
1254 // we know patch is an x, because we have any x at all.
1255 // replace X with 0
1256 if (xm) {
1257 m = 0;
1258 }
1259 p = 0;
1260
1261 if (gtlt === '>') {
1262 // >1 => >=2.0.0
1263 // >1.2 => >=1.3.0
1264 // >1.2.3 => >= 1.2.4
1265 gtlt = '>=';
1266 if (xm) {
1267 M = +M + 1;
1268 m = 0;
1269 p = 0;
1270 } else {
1271 m = +m + 1;
1272 p = 0;
1273 }
1274 } else if (gtlt === '<=') {
1275 // <=0.7.x is actually <0.8.0, since any 0.7.x should
1276 // pass. Similarly, <=7.x is actually <8.0.0, etc.
1277 gtlt = '<';
1278 if (xm) {
1279 M = +M + 1;
1280 } else {
1281 m = +m + 1;
1282 }
1283 }
1284
1285 ret = gtlt + M + '.' + m + '.' + p + pr;
1286 } else if (xm) {
1287 ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
1288 } else if (xp) {
1289 ret = '>=' + M + '.' + m + '.0' + pr +
1290 ' <' + M + '.' + (+m + 1) + '.0' + pr;
1291 }
1292
1293 debug('xRange return', ret);
1294
1295 return ret
1296 })
1297}
1298
1299// Because * is AND-ed with everything else in the comparator,
1300// and '' means "any version", just remove the *s entirely.
1301function replaceStars (comp, options) {
1302 debug('replaceStars', comp, options);
1303 // Looseness is ignored here. star is always as loose as it gets!
1304 return comp.trim().replace(re[t.STAR], '')
1305}
1306
1307// This function is passed to string.replace(re[t.HYPHENRANGE])
1308// M, m, patch, prerelease, build
1309// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
1310// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
1311// 1.2 - 3.4 => >=1.2.0 <3.5.0
1312function hyphenReplace ($0,
1313 from, fM, fm, fp, fpr, fb,
1314 to, tM, tm, tp, tpr, tb) {
1315 if (isX(fM)) {
1316 from = '';
1317 } else if (isX(fm)) {
1318 from = '>=' + fM + '.0.0';
1319 } else if (isX(fp)) {
1320 from = '>=' + fM + '.' + fm + '.0';
1321 } else {
1322 from = '>=' + from;
1323 }
1324
1325 if (isX(tM)) {
1326 to = '';
1327 } else if (isX(tm)) {
1328 to = '<' + (+tM + 1) + '.0.0';
1329 } else if (isX(tp)) {
1330 to = '<' + tM + '.' + (+tm + 1) + '.0';
1331 } else if (tpr) {
1332 to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
1333 } else {
1334 to = '<=' + to;
1335 }
1336
1337 return (from + ' ' + to).trim()
1338}
1339
1340// if ANY of the sets match ALL of its comparators, then pass
1341Range.prototype.test = function (version) {
1342 if (!version) {
1343 return false
1344 }
1345
1346 if (typeof version === 'string') {
1347 try {
1348 version = new SemVer(version, this.options);
1349 } catch (er) {
1350 return false
1351 }
1352 }
1353
1354 for (var i = 0; i < this.set.length; i++) {
1355 if (testSet(this.set[i], version, this.options)) {
1356 return true
1357 }
1358 }
1359 return false
1360};
1361
1362function testSet (set, version, options) {
1363 for (var i = 0; i < set.length; i++) {
1364 if (!set[i].test(version)) {
1365 return false
1366 }
1367 }
1368
1369 if (version.prerelease.length && !options.includePrerelease) {
1370 // Find the set of versions that are allowed to have prereleases
1371 // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
1372 // That should allow `1.2.3-pr.2` to pass.
1373 // However, `1.2.4-alpha.notready` should NOT be allowed,
1374 // even though it's within the range set by the comparators.
1375 for (i = 0; i < set.length; i++) {
1376 debug(set[i].semver);
1377 if (set[i].semver === ANY) {
1378 continue
1379 }
1380
1381 if (set[i].semver.prerelease.length > 0) {
1382 var allowed = set[i].semver;
1383 if (allowed.major === version.major &&
1384 allowed.minor === version.minor &&
1385 allowed.patch === version.patch) {
1386 return true
1387 }
1388 }
1389 }
1390
1391 // Version has a -pre, but it's not one of the ones we like.
1392 return false
1393 }
1394
1395 return true
1396}
1397
1398exports.satisfies = satisfies;
1399function satisfies (version, range, options) {
1400 try {
1401 range = new Range(range, options);
1402 } catch (er) {
1403 return false
1404 }
1405 return range.test(version)
1406}
1407
1408exports.maxSatisfying = maxSatisfying;
1409function maxSatisfying (versions, range, options) {
1410 var max = null;
1411 var maxSV = null;
1412 try {
1413 var rangeObj = new Range(range, options);
1414 } catch (er) {
1415 return null
1416 }
1417 versions.forEach(function (v) {
1418 if (rangeObj.test(v)) {
1419 // satisfies(v, range, options)
1420 if (!max || maxSV.compare(v) === -1) {
1421 // compare(max, v, true)
1422 max = v;
1423 maxSV = new SemVer(max, options);
1424 }
1425 }
1426 });
1427 return max
1428}
1429
1430exports.minSatisfying = minSatisfying;
1431function minSatisfying (versions, range, options) {
1432 var min = null;
1433 var minSV = null;
1434 try {
1435 var rangeObj = new Range(range, options);
1436 } catch (er) {
1437 return null
1438 }
1439 versions.forEach(function (v) {
1440 if (rangeObj.test(v)) {
1441 // satisfies(v, range, options)
1442 if (!min || minSV.compare(v) === 1) {
1443 // compare(min, v, true)
1444 min = v;
1445 minSV = new SemVer(min, options);
1446 }
1447 }
1448 });
1449 return min
1450}
1451
1452exports.minVersion = minVersion;
1453function minVersion (range, loose) {
1454 range = new Range(range, loose);
1455
1456 var minver = new SemVer('0.0.0');
1457 if (range.test(minver)) {
1458 return minver
1459 }
1460
1461 minver = new SemVer('0.0.0-0');
1462 if (range.test(minver)) {
1463 return minver
1464 }
1465
1466 minver = null;
1467 for (var i = 0; i < range.set.length; ++i) {
1468 var comparators = range.set[i];
1469
1470 comparators.forEach(function (comparator) {
1471 // Clone to avoid manipulating the comparator's semver object.
1472 var compver = new SemVer(comparator.semver.version);
1473 switch (comparator.operator) {
1474 case '>':
1475 if (compver.prerelease.length === 0) {
1476 compver.patch++;
1477 } else {
1478 compver.prerelease.push(0);
1479 }
1480 compver.raw = compver.format();
1481 /* fallthrough */
1482 case '':
1483 case '>=':
1484 if (!minver || gt(minver, compver)) {
1485 minver = compver;
1486 }
1487 break
1488 case '<':
1489 case '<=':
1490 /* Ignore maximum versions */
1491 break
1492 /* istanbul ignore next */
1493 default:
1494 throw new Error('Unexpected operation: ' + comparator.operator)
1495 }
1496 });
1497 }
1498
1499 if (minver && range.test(minver)) {
1500 return minver
1501 }
1502
1503 return null
1504}
1505
1506exports.validRange = validRange;
1507function validRange (range, options) {
1508 try {
1509 // Return '*' instead of '' so that truthiness works.
1510 // This will throw if it's invalid anyway
1511 return new Range(range, options).range || '*'
1512 } catch (er) {
1513 return null
1514 }
1515}
1516
1517// Determine if version is less than all the versions possible in the range
1518exports.ltr = ltr;
1519function ltr (version, range, options) {
1520 return outside(version, range, '<', options)
1521}
1522
1523// Determine if version is greater than all the versions possible in the range.
1524exports.gtr = gtr;
1525function gtr (version, range, options) {
1526 return outside(version, range, '>', options)
1527}
1528
1529exports.outside = outside;
1530function outside (version, range, hilo, options) {
1531 version = new SemVer(version, options);
1532 range = new Range(range, options);
1533
1534 var gtfn, ltefn, ltfn, comp, ecomp;
1535 switch (hilo) {
1536 case '>':
1537 gtfn = gt;
1538 ltefn = lte;
1539 ltfn = lt;
1540 comp = '>';
1541 ecomp = '>=';
1542 break
1543 case '<':
1544 gtfn = lt;
1545 ltefn = gte;
1546 ltfn = gt;
1547 comp = '<';
1548 ecomp = '<=';
1549 break
1550 default:
1551 throw new TypeError('Must provide a hilo val of "<" or ">"')
1552 }
1553
1554 // If it satisifes the range it is not outside
1555 if (satisfies(version, range, options)) {
1556 return false
1557 }
1558
1559 // From now on, variable terms are as if we're in "gtr" mode.
1560 // but note that everything is flipped for the "ltr" function.
1561
1562 for (var i = 0; i < range.set.length; ++i) {
1563 var comparators = range.set[i];
1564
1565 var high = null;
1566 var low = null;
1567
1568 comparators.forEach(function (comparator) {
1569 if (comparator.semver === ANY) {
1570 comparator = new Comparator('>=0.0.0');
1571 }
1572 high = high || comparator;
1573 low = low || comparator;
1574 if (gtfn(comparator.semver, high.semver, options)) {
1575 high = comparator;
1576 } else if (ltfn(comparator.semver, low.semver, options)) {
1577 low = comparator;
1578 }
1579 });
1580
1581 // If the edge version comparator has a operator then our version
1582 // isn't outside it
1583 if (high.operator === comp || high.operator === ecomp) {
1584 return false
1585 }
1586
1587 // If the lowest version comparator has an operator and our version
1588 // is less than it then it isn't higher than the range
1589 if ((!low.operator || low.operator === comp) &&
1590 ltefn(version, low.semver)) {
1591 return false
1592 } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1593 return false
1594 }
1595 }
1596 return true
1597}
1598
1599exports.prerelease = prerelease;
1600function prerelease (version, options) {
1601 var parsed = parse(version, options);
1602 return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
1603}
1604
1605exports.intersects = intersects;
1606function intersects (r1, r2, options) {
1607 r1 = new Range(r1, options);
1608 r2 = new Range(r2, options);
1609 return r1.intersects(r2)
1610}
1611
1612exports.coerce = coerce;
1613function coerce (version, options) {
1614 if (version instanceof SemVer) {
1615 return version
1616 }
1617
1618 if (typeof version === 'number') {
1619 version = String(version);
1620 }
1621
1622 if (typeof version !== 'string') {
1623 return null
1624 }
1625
1626 options = options || {};
1627
1628 var match = null;
1629 if (!options.rtl) {
1630 match = version.match(re[t.COERCE]);
1631 } else {
1632 // Find the right-most coercible string that does not share
1633 // a terminus with a more left-ward coercible string.
1634 // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
1635 //
1636 // Walk through the string checking with a /g regexp
1637 // Manually set the index so as to pick up overlapping matches.
1638 // Stop when we get a match that ends at the string end, since no
1639 // coercible string can be more right-ward without the same terminus.
1640 var next;
1641 while ((next = re[t.COERCERTL].exec(version)) &&
1642 (!match || match.index + match[0].length !== version.length)
1643 ) {
1644 if (!match ||
1645 next.index + next[0].length !== match.index + match[0].length) {
1646 match = next;
1647 }
1648 re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
1649 }
1650 // leave it in a clean state
1651 re[t.COERCERTL].lastIndex = -1;
1652 }
1653
1654 if (match === null) {
1655 return null
1656 }
1657
1658 return parse(match[2] +
1659 '.' + (match[3] || '0') +
1660 '.' + (match[4] || '0'), options)
1661}
1662});
1663var semver_1 = semver.SEMVER_SPEC_VERSION;
1664var semver_2 = semver.re;
1665var semver_3 = semver.src;
1666var semver_4 = semver.tokens;
1667var semver_5 = semver.parse;
1668var semver_6 = semver.valid;
1669var semver_7 = semver.clean;
1670var semver_8 = semver.SemVer;
1671var semver_9 = semver.inc;
1672var semver_10 = semver.diff;
1673var semver_11 = semver.compareIdentifiers;
1674var semver_12 = semver.rcompareIdentifiers;
1675var semver_13 = semver.major;
1676var semver_14 = semver.minor;
1677var semver_15 = semver.patch;
1678var semver_16 = semver.compare;
1679var semver_17 = semver.compareLoose;
1680var semver_18 = semver.compareBuild;
1681var semver_19 = semver.rcompare;
1682var semver_20 = semver.sort;
1683var semver_21 = semver.rsort;
1684var semver_22 = semver.gt;
1685var semver_23 = semver.lt;
1686var semver_24 = semver.eq;
1687var semver_25 = semver.neq;
1688var semver_26 = semver.gte;
1689var semver_27 = semver.lte;
1690var semver_28 = semver.cmp;
1691var semver_29 = semver.Comparator;
1692var semver_30 = semver.Range;
1693var semver_31 = semver.toComparators;
1694var semver_32 = semver.satisfies;
1695var semver_33 = semver.maxSatisfying;
1696var semver_34 = semver.minSatisfying;
1697var semver_35 = semver.minVersion;
1698var semver_36 = semver.validRange;
1699var semver_37 = semver.ltr;
1700var semver_38 = semver.gtr;
1701var semver_39 = semver.outside;
1702var semver_40 = semver.prerelease;
1703var semver_41 = semver.intersects;
1704var semver_42 = semver.coerce;
1705
1706var NAME_SELECTOR = 'NAME_SELECTOR';
1707var COMPONENT_SELECTOR = 'COMPONENT_SELECTOR';
1708var REF_SELECTOR = 'REF_SELECTOR';
1709var DOM_SELECTOR = 'DOM_SELECTOR';
1710var INVALID_SELECTOR = 'INVALID_SELECTOR';
1711
1712var VUE_VERSION = Number(
1713 ((Vue.version.split('.')[0]) + "." + (Vue.version.split('.')[1]))
1714);
1715
1716var FUNCTIONAL_OPTIONS =
1717 VUE_VERSION >= 2.5 ? 'fnOptions' : 'functionalOptions';
1718
1719var BEFORE_RENDER_LIFECYCLE_HOOK = semver.gt(Vue.version, '2.1.8')
1720 ? 'beforeCreate'
1721 : 'beforeMount';
1722
1723var CREATE_ELEMENT_ALIAS = semver.gt(Vue.version, '2.1.5')
1724 ? '_c'
1725 : '_h';
1726
1727//
1728
1729function throwError(msg) {
1730 throw new Error(("[vue-test-utils]: " + msg))
1731}
1732
1733function warn(msg) {
1734 console.error(("[vue-test-utils]: " + msg));
1735}
1736
1737var camelizeRE = /-(\w)/g;
1738
1739var camelize = function (str) {
1740 var camelizedStr = str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }
1741 );
1742 return camelizedStr.charAt(0).toLowerCase() + camelizedStr.slice(1)
1743};
1744
1745/**
1746 * Capitalize a string.
1747 */
1748var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.slice(1); };
1749
1750/**
1751 * Hyphenate a camelCase string.
1752 */
1753var hyphenateRE = /\B([A-Z])/g;
1754var hyphenate = function (str) { return str.replace(hyphenateRE, '-$1').toLowerCase(); };
1755
1756function hasOwnProperty(obj, prop) {
1757 return Object.prototype.hasOwnProperty.call(obj, prop)
1758}
1759
1760function keys(obj) {
1761 return Object.keys(obj)
1762}
1763
1764function resolveComponent(id, components) {
1765 if (typeof id !== 'string') {
1766 return
1767 }
1768 // check local registration variations first
1769 if (hasOwnProperty(components, id)) {
1770 return components[id]
1771 }
1772 var camelizedId = camelize(id);
1773 if (hasOwnProperty(components, camelizedId)) {
1774 return components[camelizedId]
1775 }
1776 var PascalCaseId = capitalize(camelizedId);
1777 if (hasOwnProperty(components, PascalCaseId)) {
1778 return components[PascalCaseId]
1779 }
1780 // fallback to prototype chain
1781 return components[id] || components[camelizedId] || components[PascalCaseId]
1782}
1783
1784var UA =
1785 typeof window !== 'undefined' &&
1786 'navigator' in window &&
1787 navigator.userAgent.toLowerCase();
1788
1789var isPhantomJS = UA && UA.includes && UA.match(/phantomjs/i);
1790
1791var isEdge = UA && UA.indexOf('edge/') > 0;
1792var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
1793
1794// get the event used to trigger v-model handler that updates bound data
1795function getCheckedEvent() {
1796 var version = Vue.version;
1797
1798 if (semver.satisfies(version, '2.1.9 - 2.1.10')) {
1799 return 'click'
1800 }
1801
1802 if (semver.satisfies(version, '2.2 - 2.4')) {
1803 return isChrome ? 'click' : 'change'
1804 }
1805
1806 // change is handler for version 2.0 - 2.1.8, and 2.5+
1807 return 'change'
1808}
1809
1810/**
1811 * Normalize nextTick to return a promise for all Vue 2 versions.
1812 * Vue < 2.1 does not return a Promise from nextTick
1813 * @return {Promise<R>}
1814 */
1815function nextTick() {
1816 if (VUE_VERSION > 2) { return Vue.nextTick() }
1817 return new Promise(function (resolve) {
1818 Vue.nextTick(resolve);
1819 })
1820}
1821
1822function warnDeprecated(method, fallback) {
1823 if ( fallback === void 0 ) fallback = '';
1824
1825 if (!config.showDeprecationWarnings) { return }
1826 var msg = method + " is deprecated and will be removed in the next major version.";
1827 if (fallback) { msg += " " + fallback + "."; }
1828 warn(msg);
1829}
1830
1831//
1832
1833function addMocks(
1834 _Vue,
1835 mockedProperties
1836) {
1837 if ( mockedProperties === void 0 ) mockedProperties = {};
1838
1839 if (mockedProperties === false) {
1840 return
1841 }
1842 Object.keys(mockedProperties).forEach(function (key) {
1843 try {
1844 // $FlowIgnore
1845 _Vue.prototype[key] = mockedProperties[key];
1846 } catch (e) {
1847 warn(
1848 "could not overwrite property " + key + ", this is " +
1849 "usually caused by a plugin that has added " +
1850 "the property as a read-only value"
1851 );
1852 }
1853 // $FlowIgnore
1854 Vue.util.defineReactive(_Vue, key, mockedProperties[key]);
1855 });
1856}
1857
1858//
1859
1860function logEvents(
1861 vm,
1862 emitted,
1863 emittedByOrder
1864) {
1865 var emit = vm.$emit;
1866 vm.$emit = function (name) {
1867 var args = [], len = arguments.length - 1;
1868 while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
1869(emitted[name] || (emitted[name] = [])).push(args);
1870 emittedByOrder.push({ name: name, args: args });
1871 return emit.call.apply(emit, [ vm, name ].concat( args ))
1872 };
1873}
1874
1875function addEventLogger(_Vue) {
1876 _Vue.mixin({
1877 beforeCreate: function() {
1878 this.__emitted = Object.create(null);
1879 this.__emittedByOrder = [];
1880 logEvents(this, this.__emitted, this.__emittedByOrder);
1881 }
1882 });
1883}
1884
1885function addStubs(_Vue, stubComponents) {
1886 var obj;
1887
1888 function addStubComponentsMixin() {
1889 Object.assign(this.$options.components, stubComponents);
1890 }
1891
1892 _Vue.mixin(( obj = {}, obj[BEFORE_RENDER_LIFECYCLE_HOOK] = addStubComponentsMixin, obj ));
1893}
1894
1895//
1896
1897function isDomSelector(selector) {
1898 if (typeof selector !== 'string') {
1899 return false
1900 }
1901
1902 try {
1903 if (typeof document === 'undefined') {
1904 throwError(
1905 "mount must be run in a browser environment like " +
1906 "PhantomJS, jsdom or chrome"
1907 );
1908 }
1909 } catch (error) {
1910 throwError(
1911 "mount must be run in a browser environment like " +
1912 "PhantomJS, jsdom or chrome"
1913 );
1914 }
1915
1916 try {
1917 document.querySelector(selector);
1918 return true
1919 } catch (error) {
1920 return false
1921 }
1922}
1923
1924function isVueComponent(c) {
1925 if (isConstructor(c)) {
1926 return true
1927 }
1928
1929 if (c === null || typeof c !== 'object') {
1930 return false
1931 }
1932
1933 if (c.extends || c._Ctor) {
1934 return true
1935 }
1936
1937 if (typeof c.template === 'string') {
1938 return true
1939 }
1940
1941 return typeof c.render === 'function'
1942}
1943
1944function componentNeedsCompiling(component) {
1945 return (
1946 component &&
1947 !component.render &&
1948 (component.template || component.extends || component.extendOptions) &&
1949 !component.functional
1950 )
1951}
1952
1953function isRefSelector(refOptionsObject) {
1954 if (
1955 typeof refOptionsObject !== 'object' ||
1956 Object.keys(refOptionsObject || {}).length !== 1
1957 ) {
1958 return false
1959 }
1960
1961 return typeof refOptionsObject.ref === 'string'
1962}
1963
1964function isNameSelector(nameOptionsObject) {
1965 if (typeof nameOptionsObject !== 'object' || nameOptionsObject === null) {
1966 return false
1967 }
1968
1969 return !!nameOptionsObject.name
1970}
1971
1972function isConstructor(c) {
1973 return typeof c === 'function' && c.cid
1974}
1975
1976function isDynamicComponent(c) {
1977 return typeof c === 'function' && !c.cid
1978}
1979
1980function isComponentOptions(c) {
1981 return typeof c === 'object' && (c.template || c.render)
1982}
1983
1984function isFunctionalComponent(c) {
1985 if (!isVueComponent(c)) {
1986 return false
1987 }
1988 if (isConstructor(c)) {
1989 return c.options.functional
1990 }
1991 return c.functional
1992}
1993
1994function templateContainsComponent(
1995 template,
1996 name
1997) {
1998 return [capitalize, camelize, hyphenate].some(function (format) {
1999 var re = new RegExp(("<" + (format(name)) + "\\s*(\\s|>|(/>))"), 'g');
2000 return re.test(template)
2001 })
2002}
2003
2004function isPlainObject(c) {
2005 return Object.prototype.toString.call(c) === '[object Object]'
2006}
2007
2008function isHTMLElement(c) {
2009 if (typeof HTMLElement === 'undefined') {
2010 return false
2011 }
2012 // eslint-disable-next-line no-undef
2013 return c instanceof HTMLElement
2014}
2015
2016function makeMap(str, expectsLowerCase) {
2017 var map = Object.create(null);
2018 var list = str.split(',');
2019 for (var i = 0; i < list.length; i++) {
2020 map[list[i]] = true;
2021 }
2022 return expectsLowerCase
2023 ? function(val) {
2024 return map[val.toLowerCase()]
2025 }
2026 : function(val) {
2027 return map[val]
2028 }
2029}
2030
2031var isHTMLTag = makeMap(
2032 'html,body,base,head,link,meta,style,title,' +
2033 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
2034 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
2035 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
2036 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,' +
2037 'embed,object,param,source,canvas,script,noscript,del,ins,' +
2038 'caption,col,colgroup,table,thead,tbody,td,th,tr,video,' +
2039 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
2040 'output,progress,select,textarea,' +
2041 'details,dialog,menu,menuitem,summary,' +
2042 'content,element,shadow,template,blockquote,iframe,tfoot'
2043);
2044
2045// this map is intentionally selective, only covering SVG elements that may
2046// contain child elements.
2047var isSVG = makeMap(
2048 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
2049 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
2050 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
2051 true
2052);
2053
2054var isReservedTag = function (tag) { return isHTMLTag(tag) || isSVG(tag); };
2055
2056//
2057
2058function compileTemplate(component) {
2059 if (component.template) {
2060 if (!vueTemplateCompiler.compileToFunctions) {
2061 throwError(
2062 "vueTemplateCompiler is undefined, you must pass " +
2063 "precompiled components if vue-template-compiler is " +
2064 "undefined"
2065 );
2066 }
2067
2068 if (component.template.charAt('#') === '#') {
2069 var el = document.querySelector(component.template);
2070 if (!el) {
2071 throwError('Cannot find element' + component.template);
2072
2073 el = document.createElement('div');
2074 }
2075 component.template = el.innerHTML;
2076 }
2077
2078 Object.assign(component, Object.assign({}, vueTemplateCompiler.compileToFunctions(component.template),
2079 {name: component.name}));
2080 }
2081
2082 if (component.components) {
2083 Object.keys(component.components).forEach(function (c) {
2084 var cmp = component.components[c];
2085 if (!cmp.render) {
2086 compileTemplate(cmp);
2087 }
2088 });
2089 }
2090
2091 if (component.extends) {
2092 compileTemplate(component.extends);
2093 }
2094
2095 if (component.extendOptions && !component.options.render) {
2096 compileTemplate(component.options);
2097 }
2098}
2099
2100function compileTemplateForSlots(slots) {
2101 Object.keys(slots).forEach(function (key) {
2102 var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
2103 slot.forEach(function (slotValue) {
2104 if (componentNeedsCompiling(slotValue)) {
2105 compileTemplate(slotValue);
2106 }
2107 });
2108 });
2109}
2110
2111//
2112
2113var MOUNTING_OPTIONS = [
2114 'attachToDocument',
2115 'mocks',
2116 'slots',
2117 'localVue',
2118 'stubs',
2119 'context',
2120 'clone',
2121 'attrs',
2122 'listeners',
2123 'propsData',
2124 'shouldProxy'
2125];
2126
2127function extractInstanceOptions(options) {
2128 var instanceOptions = Object.assign({}, options);
2129 MOUNTING_OPTIONS.forEach(function (mountingOption) {
2130 delete instanceOptions[mountingOption];
2131 });
2132 return instanceOptions
2133}
2134
2135//
2136
2137function isDestructuringSlotScope(slotScope) {
2138 return /^{.*}$/.test(slotScope)
2139}
2140
2141function getVueTemplateCompilerHelpers(
2142 _Vue
2143) {
2144 // $FlowIgnore
2145 var vue = new _Vue();
2146 var helpers = {};
2147 var names = [
2148 '_c',
2149 '_o',
2150 '_n',
2151 '_s',
2152 '_l',
2153 '_t',
2154 '_q',
2155 '_i',
2156 '_m',
2157 '_f',
2158 '_k',
2159 '_b',
2160 '_v',
2161 '_e',
2162 '_u',
2163 '_g'
2164 ];
2165 names.forEach(function (name) {
2166 helpers[name] = vue._renderProxy[name];
2167 });
2168 helpers.$createElement = vue._renderProxy.$createElement;
2169 helpers.$set = vue._renderProxy.$set;
2170 return helpers
2171}
2172
2173function validateEnvironment() {
2174 if (VUE_VERSION < 2.1) {
2175 throwError("the scopedSlots option is only supported in vue@2.1+.");
2176 }
2177}
2178
2179function isScopedSlot(slot) {
2180 if (typeof slot === 'function') { return { match: null, slot: slot } }
2181
2182 var slotScopeRe = /<[^>]+ slot-scope="(.+)"/;
2183 var vSlotRe = /<template v-slot(?::.+)?="(.+)"/;
2184 var shortVSlotRe = /<template #.*="(.+)"/;
2185
2186 var hasOldSlotScope = slot.match(slotScopeRe);
2187 var hasVSlotScopeAttr = slot.match(vSlotRe);
2188 var hasShortVSlotScopeAttr = slot.match(shortVSlotRe);
2189
2190 if (hasOldSlotScope) {
2191 return { slot: slot, match: hasOldSlotScope }
2192 } else if (hasVSlotScopeAttr || hasShortVSlotScopeAttr) {
2193 // Strip v-slot and #slot attributes from `template` tag. compileToFunctions leaves empty `template` tag otherwise.
2194 var sanitizedSlot = slot.replace(
2195 /(<template)([^>]+)(>.+<\/template>)/,
2196 '$1$3'
2197 );
2198 return {
2199 slot: sanitizedSlot,
2200 match: hasVSlotScopeAttr || hasShortVSlotScopeAttr
2201 }
2202 }
2203 // we have no matches, so we just return
2204 return {
2205 slot: slot,
2206 match: null
2207 }
2208}
2209
2210// Hide warning about <template> disallowed as root element
2211function customWarn(msg) {
2212 if (msg.indexOf('Cannot use <template> as component root element') === -1) {
2213 console.error(msg);
2214 }
2215}
2216
2217function createScopedSlots(
2218 scopedSlotsOption,
2219 _Vue
2220) {
2221 var scopedSlots = {};
2222 if (!scopedSlotsOption) {
2223 return scopedSlots
2224 }
2225 validateEnvironment();
2226 var helpers = getVueTemplateCompilerHelpers(_Vue);
2227 var loop = function ( scopedSlotName ) {
2228 var slot = scopedSlotsOption[scopedSlotName];
2229 var isFn = typeof slot === 'function';
2230
2231 var scopedSlotMatches = isScopedSlot(slot);
2232
2233 // Type check to silence flow (can't use isFn)
2234 var renderFn =
2235 typeof slot === 'function'
2236 ? slot
2237 : vueTemplateCompiler.compileToFunctions(scopedSlotMatches.slot, { warn: customWarn })
2238 .render;
2239
2240 var slotScope = scopedSlotMatches.match && scopedSlotMatches.match[1];
2241
2242 scopedSlots[scopedSlotName] = function(props) {
2243 var obj;
2244
2245 var res;
2246 if (isFn) {
2247 res = renderFn.call(Object.assign({}, helpers), props);
2248 } else if (slotScope && !isDestructuringSlotScope(slotScope)) {
2249 res = renderFn.call(Object.assign({}, helpers, ( obj = {}, obj[slotScope] = props, obj )));
2250 } else if (slotScope && isDestructuringSlotScope(slotScope)) {
2251 res = renderFn.call(Object.assign({}, helpers, props));
2252 } else {
2253 res = renderFn.call(Object.assign({}, helpers, {props: props}));
2254 }
2255 // res is Array if <template> is a root element
2256 return Array.isArray(res) ? res[0] : res
2257 };
2258 };
2259
2260 for (var scopedSlotName in scopedSlotsOption) loop( scopedSlotName );
2261 return scopedSlots
2262}
2263
2264//
2265
2266function isVueComponentStub(comp) {
2267 return (comp && comp.template) || isVueComponent(comp)
2268}
2269
2270function isValidStub(stub) {
2271 return (
2272 typeof stub === 'boolean' ||
2273 (!!stub && typeof stub === 'string') ||
2274 isVueComponentStub(stub)
2275 )
2276}
2277
2278function resolveComponent$1(obj, component) {
2279 return (
2280 obj[component] ||
2281 obj[hyphenate(component)] ||
2282 obj[camelize(component)] ||
2283 obj[capitalize(camelize(component))] ||
2284 obj[capitalize(component)] ||
2285 {}
2286 )
2287}
2288
2289function getCoreProperties(componentOptions) {
2290 return {
2291 attrs: componentOptions.attrs,
2292 name: componentOptions.name,
2293 model: componentOptions.model,
2294 props: componentOptions.props,
2295 on: componentOptions.on,
2296 key: componentOptions.key,
2297 domProps: componentOptions.domProps,
2298 class: componentOptions.class,
2299 staticClass: componentOptions.staticClass,
2300 staticStyle: componentOptions.staticStyle,
2301 style: componentOptions.style,
2302 normalizedStyle: componentOptions.normalizedStyle,
2303 nativeOn: componentOptions.nativeOn,
2304 functional: componentOptions.functional
2305 }
2306}
2307
2308function createClassString(staticClass, dynamicClass) {
2309 // :class="someComputedObject" can return a string, object or undefined
2310 // if it is a string, we don't need to do anything special.
2311 var evaluatedDynamicClass = dynamicClass;
2312
2313 // if it is an object, eg { 'foo': true }, we need to evaluate it.
2314 // see https://github.com/vuejs/vue-test-utils/issues/1474 for more context.
2315 if (typeof dynamicClass === 'object') {
2316 evaluatedDynamicClass = Object.keys(dynamicClass).reduce(function (acc, key) {
2317 if (dynamicClass[key]) {
2318 return acc + ' ' + key
2319 }
2320 return acc
2321 }, '');
2322 }
2323
2324 if (staticClass && evaluatedDynamicClass) {
2325 return staticClass + ' ' + evaluatedDynamicClass
2326 }
2327 return staticClass || evaluatedDynamicClass
2328}
2329
2330function resolveOptions(component, _Vue) {
2331 if (isDynamicComponent(component)) {
2332 return {}
2333 }
2334
2335 return isConstructor(component)
2336 ? component.options
2337 : _Vue.extend(component).options
2338}
2339
2340function getScopedSlotRenderFunctions(ctx) {
2341 // In Vue 2.6+ a new v-slot syntax was introduced
2342 // scopedSlots are now saved in parent._vnode.data.scopedSlots
2343 // We filter out the _normalized and $stable key
2344 if (
2345 ctx &&
2346 ctx.$options &&
2347 ctx.$options.parent &&
2348 ctx.$options.parent._vnode &&
2349 ctx.$options.parent._vnode.data &&
2350 ctx.$options.parent._vnode.data.scopedSlots
2351 ) {
2352 var slotKeys = ctx.$options.parent._vnode.data.scopedSlots;
2353 return keys(slotKeys).filter(function (x) { return x !== '_normalized' && x !== '$stable'; })
2354 }
2355
2356 return []
2357}
2358
2359function createStubFromComponent(
2360 originalComponent,
2361 name,
2362 _Vue
2363) {
2364 var componentOptions = resolveOptions(originalComponent, _Vue);
2365 var tagName = (name || 'anonymous') + "-stub";
2366
2367 // ignoreElements does not exist in Vue 2.0.x
2368 if (Vue.config.ignoredElements) {
2369 Vue.config.ignoredElements.push(tagName);
2370 }
2371
2372 return Object.assign({}, getCoreProperties(componentOptions),
2373 {$_vueTestUtils_original: originalComponent,
2374 $_doNotStubChildren: true,
2375 render: function render(h, context) {
2376 var this$1 = this;
2377
2378 return h(
2379 tagName,
2380 {
2381 ref: componentOptions.functional ? context.data.ref : undefined,
2382 attrs: componentOptions.functional
2383 ? Object.assign({}, context.props,
2384 context.data.attrs,
2385 {class: createClassString(
2386 context.data.staticClass,
2387 context.data.class
2388 )})
2389 : Object.assign({}, this.$props)
2390 },
2391 context
2392 ? context.children
2393 : this.$options._renderChildren ||
2394 getScopedSlotRenderFunctions(this).map(function (x) { return this$1.$options.parent._vnode.data.scopedSlots[x](); }
2395 )
2396 )
2397 }})
2398}
2399
2400// DEPRECATED: converts string stub to template stub.
2401function createStubFromString(templateString, name) {
2402 warnDeprecated('Using a string for stubs');
2403
2404 if (templateContainsComponent(templateString, name)) {
2405 throwError('options.stub cannot contain a circular reference');
2406 }
2407
2408 return {
2409 template: templateString,
2410 $_doNotStubChildren: true
2411 }
2412}
2413
2414function setStubComponentName(
2415 stub,
2416 originalComponent,
2417 _Vue
2418) {
2419 if ( originalComponent === void 0 ) originalComponent = {};
2420
2421 if (stub.name) { return }
2422
2423 var componentOptions = resolveOptions(originalComponent, _Vue);
2424 stub.name = getCoreProperties(componentOptions).name;
2425}
2426
2427function validateStub(stub) {
2428 if (!isValidStub(stub)) {
2429 throwError("options.stub values must be passed a string or " + "component");
2430 }
2431}
2432
2433function createStubsFromStubsObject(
2434 originalComponents,
2435 stubs,
2436 _Vue
2437) {
2438 if ( originalComponents === void 0 ) originalComponents = {};
2439
2440 return Object.keys(stubs || {}).reduce(function (acc, stubName) {
2441 var stub = stubs[stubName];
2442
2443 validateStub(stub);
2444
2445 if (stub === false) {
2446 return acc
2447 }
2448
2449 var component = resolveComponent$1(originalComponents, stubName);
2450
2451 if (stub === true) {
2452 acc[stubName] = createStubFromComponent(component, stubName, _Vue);
2453 return acc
2454 }
2455
2456 if (typeof stub === 'string') {
2457 stub = createStubFromString(stub, stubName);
2458 stubs[stubName];
2459 }
2460
2461 setStubComponentName(stub, component, _Vue);
2462 if (componentNeedsCompiling(stub)) {
2463 compileTemplate(stub);
2464 }
2465
2466 acc[stubName] = stub;
2467 stub._Ctor = {};
2468
2469 return acc
2470 }, {})
2471}
2472
2473var isAllowlisted = function (el, allowlist) { return resolveComponent(el, allowlist); };
2474var isAlreadyStubbed = function (el, stubs) { return stubs.has(el); };
2475
2476function shouldExtend(component, _Vue) {
2477 return isConstructor(component) || (component && component.extends)
2478}
2479
2480function extend(component, _Vue) {
2481 var componentOptions = component.options ? component.options : component;
2482 var stub = _Vue.extend(componentOptions);
2483 stub.options.$_vueTestUtils_original = component;
2484 stub.options._base = _Vue;
2485 return stub
2486}
2487
2488function createStubIfNeeded(shouldStub, component, _Vue, el) {
2489 if (shouldStub) {
2490 return createStubFromComponent(component || {}, el, _Vue)
2491 }
2492
2493 if (shouldExtend(component)) {
2494 return extend(component, _Vue)
2495 }
2496}
2497
2498function shouldNotBeStubbed(el, allowlist, modifiedComponents) {
2499 return (
2500 (typeof el === 'string' && isReservedTag(el)) ||
2501 isAllowlisted(el, allowlist) ||
2502 isAlreadyStubbed(el, modifiedComponents)
2503 )
2504}
2505
2506function patchCreateElement(_Vue, stubs, stubAllComponents) {
2507 var obj;
2508
2509 // This mixin patches vm.$createElement so that we can stub all components
2510 // before they are rendered in shallow mode. We also need to ensure that
2511 // component constructors were created from the _Vue constructor. If not,
2512 // we must replace them with components created from the _Vue constructor
2513 // before calling the original $createElement. This ensures that components
2514 // have the correct instance properties and stubs when they are rendered.
2515 function patchCreateElementMixin() {
2516 var vm = this;
2517
2518 if (vm.$options.$_doNotStubChildren || vm.$options._isFunctionalContainer) {
2519 return
2520 }
2521
2522 var modifiedComponents = new Set();
2523 var originalCreateElement = vm.$createElement;
2524 var originalComponents = vm.$options.components;
2525
2526 var createElement = function (el) {
2527 var obj;
2528
2529 var args = [], len = arguments.length - 1;
2530 while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
2531 if (shouldNotBeStubbed(el, stubs, modifiedComponents)) {
2532 return originalCreateElement.apply(void 0, [ el ].concat( args ))
2533 }
2534
2535 if (isConstructor(el) || isComponentOptions(el)) {
2536 if (stubAllComponents) {
2537 var stub = createStubFromComponent(el, el.name || 'anonymous', _Vue);
2538 return originalCreateElement.apply(void 0, [ stub ].concat( args ))
2539 }
2540 var Constructor = shouldExtend(el) ? extend(el, _Vue) : el;
2541
2542 return originalCreateElement.apply(void 0, [ Constructor ].concat( args ))
2543 }
2544
2545 if (typeof el === 'string') {
2546 var original = resolveComponent(el, originalComponents);
2547
2548 if (!original) {
2549 return originalCreateElement.apply(void 0, [ el ].concat( args ))
2550 }
2551
2552 if (isDynamicComponent(original)) {
2553 return originalCreateElement.apply(void 0, [ el ].concat( args ))
2554 }
2555
2556 var stub$1 = createStubIfNeeded(stubAllComponents, original, _Vue, el);
2557
2558 if (stub$1) {
2559 Object.assign(vm.$options.components, ( obj = {}, obj[el] = stub$1, obj ));
2560 modifiedComponents.add(el);
2561 }
2562 }
2563
2564 return originalCreateElement.apply(void 0, [ el ].concat( args ))
2565 };
2566
2567 vm[CREATE_ELEMENT_ALIAS] = createElement;
2568 vm.$createElement = createElement;
2569 }
2570
2571 _Vue.mixin(( obj = {}, obj[BEFORE_RENDER_LIFECYCLE_HOOK] = patchCreateElementMixin, obj ));
2572}
2573
2574//
2575
2576function createContext(options, scopedSlots) {
2577 var on = Object.assign({}, (options.context && options.context.on),
2578 options.listeners);
2579 return Object.assign({}, {attrs: Object.assign({}, options.attrs,
2580 // pass as attrs so that inheritAttrs works correctly
2581 // propsData should take precedence over attrs
2582 options.propsData)},
2583 (options.context || {}),
2584 {on: on,
2585 scopedSlots: scopedSlots})
2586}
2587
2588function createChildren(vm, h, ref) {
2589 var slots = ref.slots;
2590 var context = ref.context;
2591
2592 var slotVNodes = slots ? createSlotVNodes(vm, slots) : undefined;
2593 return (
2594 (context &&
2595 context.children &&
2596 context.children.map(function (x) { return (typeof x === 'function' ? x(h) : x); })) ||
2597 slotVNodes
2598 )
2599}
2600
2601function getValuesFromCallableOption(optionValue) {
2602 if (typeof optionValue === 'function') {
2603 return optionValue.call(this)
2604 }
2605 return optionValue
2606}
2607
2608function createInstance(
2609 component,
2610 options,
2611 _Vue
2612) {
2613 var componentOptions = isConstructor(component)
2614 ? component.options
2615 : component;
2616
2617 // instance options are options that are passed to the
2618 // root instance when it's instantiated
2619 var instanceOptions = extractInstanceOptions(options);
2620
2621 var globalComponents = _Vue.options.components || {};
2622 var componentsToStub = Object.assign(
2623 Object.create(globalComponents),
2624 componentOptions.components
2625 );
2626
2627 var stubComponentsObject = createStubsFromStubsObject(
2628 componentsToStub,
2629 // $FlowIgnore
2630 options.stubs,
2631 _Vue
2632 );
2633
2634 addEventLogger(_Vue);
2635 addMocks(_Vue, options.mocks);
2636 addStubs(_Vue, stubComponentsObject);
2637 patchCreateElement(_Vue, stubComponentsObject, options.shouldProxy);
2638
2639 if (componentNeedsCompiling(componentOptions)) {
2640 compileTemplate(componentOptions);
2641 }
2642
2643 // used to identify extended component using constructor
2644 componentOptions.$_vueTestUtils_original = component;
2645
2646 // watchers provided in mounting options should override preexisting ones
2647 if (componentOptions.watch && instanceOptions.watch) {
2648 var componentWatchers = Object.keys(componentOptions.watch);
2649 var instanceWatchers = Object.keys(instanceOptions.watch);
2650
2651 for (var i = 0; i < instanceWatchers.length; i++) {
2652 var k = instanceWatchers[i];
2653 // override the componentOptions with the one provided in mounting options
2654 if (componentWatchers.includes(k)) {
2655 componentOptions.watch[k] = instanceOptions.watch[k];
2656 }
2657 }
2658 }
2659
2660 // make sure all extends are based on this instance
2661 var Constructor = _Vue.extend(componentOptions).extend(instanceOptions);
2662 Constructor.options._base = _Vue;
2663
2664 var scopedSlots = createScopedSlots(options.scopedSlots, _Vue);
2665
2666 var parentComponentOptions = options.parentComponent || {};
2667
2668 var originalParentComponentProvide = parentComponentOptions.provide;
2669 parentComponentOptions.provide = function() {
2670 return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentProvide),
2671 getValuesFromCallableOption.call(this, options.provide))
2672 };
2673
2674 parentComponentOptions.$_doNotStubChildren = true;
2675 parentComponentOptions._isFunctionalContainer = componentOptions.functional;
2676 parentComponentOptions.render = function(h) {
2677 return h(
2678 Constructor,
2679 createContext(options, scopedSlots),
2680 createChildren(this, h, options)
2681 )
2682 };
2683 var Parent = _Vue.extend(parentComponentOptions);
2684
2685 return new Parent()
2686}
2687
2688//
2689
2690function createElement() {
2691 if (document) {
2692 var elem = document.createElement('div');
2693
2694 if (document.body) {
2695 document.body.appendChild(elem);
2696 }
2697 return elem
2698 }
2699}
2700
2701//
2702
2703function findDOMNodes(
2704 element,
2705 selector
2706) {
2707 var nodes = [];
2708 if (!element || !element.querySelectorAll || !element.matches) {
2709 return nodes
2710 }
2711
2712 if (element.matches(selector)) {
2713 nodes.push(element);
2714 }
2715 // $FlowIgnore
2716 return nodes.concat([].slice.call(element.querySelectorAll(selector)))
2717}
2718
2719function vmMatchesName(vm, name) {
2720 // We want to mirror how Vue resolves component names in SFCs:
2721 // For example, <test-component />, <TestComponent /> and `<testComponent />
2722 // all resolve to the same component
2723 var componentName = (vm.$options && vm.$options.name) || '';
2724 return (
2725 !!name &&
2726 (componentName === name ||
2727 // testComponent -> TestComponent
2728 componentName === capitalize(name) ||
2729 // test-component -> TestComponent
2730 componentName === capitalize(camelize(name)) ||
2731 // same match as above, but the component name vs query
2732 capitalize(camelize(componentName)) === name)
2733 )
2734}
2735
2736function vmCtorMatches(vm, component) {
2737 if (
2738 (vm.$options && vm.$options.$_vueTestUtils_original === component) ||
2739 vm.$_vueTestUtils_original === component
2740 ) {
2741 return true
2742 }
2743
2744 var Ctor = isConstructor(component)
2745 ? component.options._Ctor
2746 : component._Ctor;
2747
2748 if (!Ctor) {
2749 return false
2750 }
2751
2752 if (vm.constructor.extendOptions === component) {
2753 return true
2754 }
2755
2756 if (component.functional) {
2757 return Object.keys(vm._Ctor || {}).some(function (c) {
2758 return component === vm._Ctor[c].extendOptions
2759 })
2760 }
2761}
2762
2763function matches(node, selector) {
2764 if (selector.type === DOM_SELECTOR) {
2765 var element = node instanceof Element ? node : node.elm;
2766 return element && element.matches && element.matches(selector.value)
2767 }
2768
2769 var isFunctionalSelector = isConstructor(selector.value)
2770 ? selector.value.options.functional
2771 : selector.value.functional;
2772
2773 var componentInstance = isFunctionalSelector
2774 ? node[FUNCTIONAL_OPTIONS]
2775 : node.child;
2776
2777 if (!componentInstance) {
2778 return false
2779 }
2780
2781 if (selector.type === COMPONENT_SELECTOR) {
2782 if (vmCtorMatches(componentInstance, selector.value)) {
2783 return true
2784 }
2785 }
2786
2787 // Fallback to name selector for COMPONENT_SELECTOR for Vue < 2.1
2788 var nameSelector = isConstructor(selector.value)
2789 ? selector.value.extendOptions.name
2790 : selector.value.name;
2791 return vmMatchesName(componentInstance, nameSelector)
2792}
2793
2794//
2795
2796function findAllInstances(rootVm) {
2797 var instances = [rootVm];
2798 var i = 0;
2799 while (i < instances.length) {
2800 var vm = instances[i]
2801 ;(vm.$children || []).forEach(function (child) {
2802 instances.push(child);
2803 });
2804 i++;
2805 }
2806 return instances
2807}
2808
2809function findAllVNodes(vnode, selector) {
2810 var matchingNodes = [];
2811 var nodes = [vnode];
2812 while (nodes.length) {
2813 var node = nodes.shift();
2814 if (node.children) {
2815 var children = [].concat( node.children ).reverse();
2816 children.forEach(function (n) {
2817 nodes.unshift(n);
2818 });
2819 }
2820 if (node.child) {
2821 nodes.unshift(node.child._vnode);
2822 }
2823 if (matches(node, selector)) {
2824 matchingNodes.push(node);
2825 }
2826 }
2827
2828 return matchingNodes
2829}
2830
2831function removeDuplicateNodes(vNodes) {
2832 var vNodeElms = vNodes.map(function (vNode) { return vNode.elm; });
2833 return vNodes.filter(function (vNode, index) { return index === vNodeElms.indexOf(vNode.elm); })
2834}
2835
2836function find(
2837 root,
2838 vm,
2839 selector
2840) {
2841 if (root instanceof Element && selector.type !== DOM_SELECTOR) {
2842 throwError(
2843 "cannot find a Vue instance on a DOM node. The node " +
2844 "you are calling find on does not exist in the " +
2845 "VDom. Are you adding the node as innerHTML?"
2846 );
2847 }
2848
2849 if (
2850 selector.type === COMPONENT_SELECTOR &&
2851 (selector.value.functional ||
2852 (selector.value.options && selector.value.options.functional)) &&
2853 VUE_VERSION < 2.3
2854 ) {
2855 throwError(
2856 "find for functional components is not supported " + "in Vue < 2.3"
2857 );
2858 }
2859
2860 if (root instanceof Element) {
2861 return findDOMNodes(root, selector.value)
2862 }
2863
2864 if (!root && selector.type !== DOM_SELECTOR) {
2865 throwError(
2866 "cannot find a Vue instance on a DOM node. The node " +
2867 "you are calling find on does not exist in the " +
2868 "VDom. Are you adding the node as innerHTML?"
2869 );
2870 }
2871
2872 if (!vm && selector.type === REF_SELECTOR) {
2873 throwError("$ref selectors can only be used on Vue component " + "wrappers");
2874 }
2875
2876 if (vm && vm.$refs && selector.value.ref in vm.$refs) {
2877 var refs = vm.$refs[selector.value.ref];
2878 return Array.isArray(refs) ? refs : [refs]
2879 }
2880
2881 var nodes = findAllVNodes(root, selector);
2882 var dedupedNodes = removeDuplicateNodes(nodes);
2883
2884 if (nodes.length > 0 || selector.type !== DOM_SELECTOR) {
2885 return dedupedNodes
2886 }
2887
2888 // Fallback in case element exists in HTML, but not in vnode tree
2889 // (e.g. if innerHTML is set as a domProp)
2890 return findDOMNodes(root.elm, selector.value)
2891}
2892
2893function errorHandler(errorOrString, vm) {
2894 var error =
2895 typeof errorOrString === 'object' ? errorOrString : new Error(errorOrString);
2896
2897 vm._error = error;
2898 throw error
2899}
2900
2901function throwIfInstancesThrew(vm) {
2902 var instancesWithError = findAllInstances(vm).filter(function (_vm) { return _vm._error; });
2903
2904 if (instancesWithError.length > 0) {
2905 throw instancesWithError[0]._error
2906 }
2907}
2908
2909var hasWarned = false;
2910
2911// Vue swallows errors thrown by instances, even if the global error handler
2912// throws. In order to throw in the test, we add an _error property to an
2913// instance when it throws. Then we loop through the instances with
2914// throwIfInstancesThrew and throw an error in the test context if any
2915// instances threw.
2916function addGlobalErrorHandler(_Vue) {
2917 var existingErrorHandler = _Vue.config.errorHandler;
2918
2919 if (existingErrorHandler === errorHandler) {
2920 return
2921 }
2922
2923 if (_Vue.config.errorHandler && !hasWarned) {
2924 warn(
2925 "Global error handler detected (Vue.config.errorHandler). \n" +
2926 "Vue Test Utils sets a custom error handler to throw errors " +
2927 "thrown by instances. If you want this behavior in " +
2928 "your tests, you must remove the global error handler."
2929 );
2930 hasWarned = true;
2931 } else {
2932 _Vue.config.errorHandler = errorHandler;
2933 }
2934}
2935
2936function normalizeStubs(stubs) {
2937 if ( stubs === void 0 ) stubs = {};
2938
2939 if (stubs === false) {
2940 return false
2941 }
2942 if (isPlainObject(stubs)) {
2943 return stubs
2944 }
2945 if (Array.isArray(stubs)) {
2946 return stubs.reduce(function (acc, stub) {
2947 if (typeof stub !== 'string') {
2948 throwError('each item in an options.stubs array must be a string');
2949 }
2950 acc[stub] = true;
2951 return acc
2952 }, {})
2953 }
2954 throwError('options.stubs must be an object or an Array');
2955}
2956
2957function normalizeProvide(provide) {
2958 // Objects are not resolved in extended components in Vue < 2.5
2959 // https://github.com/vuejs/vue/issues/6436
2960 if (typeof provide === 'object' && VUE_VERSION < 2.5) {
2961 var obj = Object.assign({}, provide);
2962 return function () { return obj; }
2963 }
2964 return provide
2965}
2966
2967//
2968
2969function getOption(option, config) {
2970 if (option === false) {
2971 return false
2972 }
2973 if (option || (config && Object.keys(config).length > 0)) {
2974 if (option instanceof Function) {
2975 return option
2976 }
2977 if (config instanceof Function) {
2978 throw new Error("Config can't be a Function.")
2979 }
2980 return Object.assign({}, config,
2981 option)
2982 }
2983}
2984
2985function getStubs(stubs, configStubs) {
2986 var normalizedStubs = normalizeStubs(stubs);
2987 var normalizedConfigStubs = normalizeStubs(configStubs);
2988 return getOption(normalizedStubs, normalizedConfigStubs)
2989}
2990
2991function mergeOptions(
2992 options,
2993 config
2994) {
2995 var mocks = (getOption(options.mocks, config.mocks));
2996 var methods = (getOption(options.methods, config.methods));
2997 if (methods && Object.keys(methods).length) {
2998 warnDeprecated(
2999 'overwriting methods via the `methods` property',
3000 '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'
3001 );
3002 }
3003
3004 var provide = (getOption(options.provide, config.provide));
3005 var stubs = (getStubs(options.stubs, config.stubs));
3006 // $FlowIgnore
3007 return Object.assign({}, options,
3008 {provide: normalizeProvide(provide),
3009 stubs: stubs,
3010 mocks: mocks,
3011 methods: methods})
3012}
3013
3014var config = {
3015 stubs: {
3016 transition: true,
3017 'transition-group': true
3018 },
3019 mocks: {},
3020 methods: {},
3021 provide: {},
3022 silent: true,
3023 showDeprecationWarnings:
3024 true
3025};
3026
3027//
3028
3029function warnIfNoWindow() {
3030 if (typeof window === 'undefined') {
3031 throwError(
3032 "window is undefined, vue-test-utils needs to be " +
3033 "run in a browser environment. \n" +
3034 "You can run the tests in node using jsdom \n" +
3035 "See https://vue-test-utils.vuejs.org/guides/#browser-environment " +
3036 "for more details."
3037 );
3038 }
3039}
3040
3041function polyfill() {
3042 // Polyfill `Element.matches()` for IE and older versions of Chrome:
3043 // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
3044 if (!Element.prototype.matches) {
3045 Element.prototype.matches =
3046 Element.prototype.msMatchesSelector ||
3047 Element.prototype.webkitMatchesSelector;
3048 }
3049}
3050
3051/*jshint node:true */
3052
3053function OutputLine(parent) {
3054 this.__parent = parent;
3055 this.__character_count = 0;
3056 // use indent_count as a marker for this.__lines that have preserved indentation
3057 this.__indent_count = -1;
3058 this.__alignment_count = 0;
3059 this.__wrap_point_index = 0;
3060 this.__wrap_point_character_count = 0;
3061 this.__wrap_point_indent_count = -1;
3062 this.__wrap_point_alignment_count = 0;
3063
3064 this.__items = [];
3065}
3066
3067OutputLine.prototype.clone_empty = function() {
3068 var line = new OutputLine(this.__parent);
3069 line.set_indent(this.__indent_count, this.__alignment_count);
3070 return line;
3071};
3072
3073OutputLine.prototype.item = function(index) {
3074 if (index < 0) {
3075 return this.__items[this.__items.length + index];
3076 } else {
3077 return this.__items[index];
3078 }
3079};
3080
3081OutputLine.prototype.has_match = function(pattern) {
3082 for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
3083 if (this.__items[lastCheckedOutput].match(pattern)) {
3084 return true;
3085 }
3086 }
3087 return false;
3088};
3089
3090OutputLine.prototype.set_indent = function(indent, alignment) {
3091 if (this.is_empty()) {
3092 this.__indent_count = indent || 0;
3093 this.__alignment_count = alignment || 0;
3094 this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
3095 }
3096};
3097
3098OutputLine.prototype._set_wrap_point = function() {
3099 if (this.__parent.wrap_line_length) {
3100 this.__wrap_point_index = this.__items.length;
3101 this.__wrap_point_character_count = this.__character_count;
3102 this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
3103 this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
3104 }
3105};
3106
3107OutputLine.prototype._should_wrap = function() {
3108 return this.__wrap_point_index &&
3109 this.__character_count > this.__parent.wrap_line_length &&
3110 this.__wrap_point_character_count > this.__parent.next_line.__character_count;
3111};
3112
3113OutputLine.prototype._allow_wrap = function() {
3114 if (this._should_wrap()) {
3115 this.__parent.add_new_line();
3116 var next = this.__parent.current_line;
3117 next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
3118 next.__items = this.__items.slice(this.__wrap_point_index);
3119 this.__items = this.__items.slice(0, this.__wrap_point_index);
3120
3121 next.__character_count += this.__character_count - this.__wrap_point_character_count;
3122 this.__character_count = this.__wrap_point_character_count;
3123
3124 if (next.__items[0] === " ") {
3125 next.__items.splice(0, 1);
3126 next.__character_count -= 1;
3127 }
3128 return true;
3129 }
3130 return false;
3131};
3132
3133OutputLine.prototype.is_empty = function() {
3134 return this.__items.length === 0;
3135};
3136
3137OutputLine.prototype.last = function() {
3138 if (!this.is_empty()) {
3139 return this.__items[this.__items.length - 1];
3140 } else {
3141 return null;
3142 }
3143};
3144
3145OutputLine.prototype.push = function(item) {
3146 this.__items.push(item);
3147 var last_newline_index = item.lastIndexOf('\n');
3148 if (last_newline_index !== -1) {
3149 this.__character_count = item.length - last_newline_index;
3150 } else {
3151 this.__character_count += item.length;
3152 }
3153};
3154
3155OutputLine.prototype.pop = function() {
3156 var item = null;
3157 if (!this.is_empty()) {
3158 item = this.__items.pop();
3159 this.__character_count -= item.length;
3160 }
3161 return item;
3162};
3163
3164
3165OutputLine.prototype._remove_indent = function() {
3166 if (this.__indent_count > 0) {
3167 this.__indent_count -= 1;
3168 this.__character_count -= this.__parent.indent_size;
3169 }
3170};
3171
3172OutputLine.prototype._remove_wrap_indent = function() {
3173 if (this.__wrap_point_indent_count > 0) {
3174 this.__wrap_point_indent_count -= 1;
3175 }
3176};
3177OutputLine.prototype.trim = function() {
3178 while (this.last() === ' ') {
3179 this.__items.pop();
3180 this.__character_count -= 1;
3181 }
3182};
3183
3184OutputLine.prototype.toString = function() {
3185 var result = '';
3186 if (this.is_empty()) {
3187 if (this.__parent.indent_empty_lines) {
3188 result = this.__parent.get_indent_string(this.__indent_count);
3189 }
3190 } else {
3191 result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
3192 result += this.__items.join('');
3193 }
3194 return result;
3195};
3196
3197function IndentStringCache(options, baseIndentString) {
3198 this.__cache = [''];
3199 this.__indent_size = options.indent_size;
3200 this.__indent_string = options.indent_char;
3201 if (!options.indent_with_tabs) {
3202 this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
3203 }
3204
3205 // Set to null to continue support for auto detection of base indent
3206 baseIndentString = baseIndentString || '';
3207 if (options.indent_level > 0) {
3208 baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
3209 }
3210
3211 this.__base_string = baseIndentString;
3212 this.__base_string_length = baseIndentString.length;
3213}
3214
3215IndentStringCache.prototype.get_indent_size = function(indent, column) {
3216 var result = this.__base_string_length;
3217 column = column || 0;
3218 if (indent < 0) {
3219 result = 0;
3220 }
3221 result += indent * this.__indent_size;
3222 result += column;
3223 return result;
3224};
3225
3226IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
3227 var result = this.__base_string;
3228 column = column || 0;
3229 if (indent_level < 0) {
3230 indent_level = 0;
3231 result = '';
3232 }
3233 column += indent_level * this.__indent_size;
3234 this.__ensure_cache(column);
3235 result += this.__cache[column];
3236 return result;
3237};
3238
3239IndentStringCache.prototype.__ensure_cache = function(column) {
3240 while (column >= this.__cache.length) {
3241 this.__add_column();
3242 }
3243};
3244
3245IndentStringCache.prototype.__add_column = function() {
3246 var column = this.__cache.length;
3247 var indent = 0;
3248 var result = '';
3249 if (this.__indent_size && column >= this.__indent_size) {
3250 indent = Math.floor(column / this.__indent_size);
3251 column -= indent * this.__indent_size;
3252 result = new Array(indent + 1).join(this.__indent_string);
3253 }
3254 if (column) {
3255 result += new Array(column + 1).join(' ');
3256 }
3257
3258 this.__cache.push(result);
3259};
3260
3261function Output(options, baseIndentString) {
3262 this.__indent_cache = new IndentStringCache(options, baseIndentString);
3263 this.raw = false;
3264 this._end_with_newline = options.end_with_newline;
3265 this.indent_size = options.indent_size;
3266 this.wrap_line_length = options.wrap_line_length;
3267 this.indent_empty_lines = options.indent_empty_lines;
3268 this.__lines = [];
3269 this.previous_line = null;
3270 this.current_line = null;
3271 this.next_line = new OutputLine(this);
3272 this.space_before_token = false;
3273 this.non_breaking_space = false;
3274 this.previous_token_wrapped = false;
3275 // initialize
3276 this.__add_outputline();
3277}
3278
3279Output.prototype.__add_outputline = function() {
3280 this.previous_line = this.current_line;
3281 this.current_line = this.next_line.clone_empty();
3282 this.__lines.push(this.current_line);
3283};
3284
3285Output.prototype.get_line_number = function() {
3286 return this.__lines.length;
3287};
3288
3289Output.prototype.get_indent_string = function(indent, column) {
3290 return this.__indent_cache.get_indent_string(indent, column);
3291};
3292
3293Output.prototype.get_indent_size = function(indent, column) {
3294 return this.__indent_cache.get_indent_size(indent, column);
3295};
3296
3297Output.prototype.is_empty = function() {
3298 return !this.previous_line && this.current_line.is_empty();
3299};
3300
3301Output.prototype.add_new_line = function(force_newline) {
3302 // never newline at the start of file
3303 // otherwise, newline only if we didn't just add one or we're forced
3304 if (this.is_empty() ||
3305 (!force_newline && this.just_added_newline())) {
3306 return false;
3307 }
3308
3309 // if raw output is enabled, don't print additional newlines,
3310 // but still return True as though you had
3311 if (!this.raw) {
3312 this.__add_outputline();
3313 }
3314 return true;
3315};
3316
3317Output.prototype.get_code = function(eol) {
3318 this.trim(true);
3319
3320 // handle some edge cases where the last tokens
3321 // has text that ends with newline(s)
3322 var last_item = this.current_line.pop();
3323 if (last_item) {
3324 if (last_item[last_item.length - 1] === '\n') {
3325 last_item = last_item.replace(/\n+$/g, '');
3326 }
3327 this.current_line.push(last_item);
3328 }
3329
3330 if (this._end_with_newline) {
3331 this.__add_outputline();
3332 }
3333
3334 var sweet_code = this.__lines.join('\n');
3335
3336 if (eol !== '\n') {
3337 sweet_code = sweet_code.replace(/[\n]/g, eol);
3338 }
3339 return sweet_code;
3340};
3341
3342Output.prototype.set_wrap_point = function() {
3343 this.current_line._set_wrap_point();
3344};
3345
3346Output.prototype.set_indent = function(indent, alignment) {
3347 indent = indent || 0;
3348 alignment = alignment || 0;
3349
3350 // Next line stores alignment values
3351 this.next_line.set_indent(indent, alignment);
3352
3353 // Never indent your first output indent at the start of the file
3354 if (this.__lines.length > 1) {
3355 this.current_line.set_indent(indent, alignment);
3356 return true;
3357 }
3358
3359 this.current_line.set_indent();
3360 return false;
3361};
3362
3363Output.prototype.add_raw_token = function(token) {
3364 for (var x = 0; x < token.newlines; x++) {
3365 this.__add_outputline();
3366 }
3367 this.current_line.set_indent(-1);
3368 this.current_line.push(token.whitespace_before);
3369 this.current_line.push(token.text);
3370 this.space_before_token = false;
3371 this.non_breaking_space = false;
3372 this.previous_token_wrapped = false;
3373};
3374
3375Output.prototype.add_token = function(printable_token) {
3376 this.__add_space_before_token();
3377 this.current_line.push(printable_token);
3378 this.space_before_token = false;
3379 this.non_breaking_space = false;
3380 this.previous_token_wrapped = this.current_line._allow_wrap();
3381};
3382
3383Output.prototype.__add_space_before_token = function() {
3384 if (this.space_before_token && !this.just_added_newline()) {
3385 if (!this.non_breaking_space) {
3386 this.set_wrap_point();
3387 }
3388 this.current_line.push(' ');
3389 }
3390};
3391
3392Output.prototype.remove_indent = function(index) {
3393 var output_length = this.__lines.length;
3394 while (index < output_length) {
3395 this.__lines[index]._remove_indent();
3396 index++;
3397 }
3398 this.current_line._remove_wrap_indent();
3399};
3400
3401Output.prototype.trim = function(eat_newlines) {
3402 eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
3403
3404 this.current_line.trim();
3405
3406 while (eat_newlines && this.__lines.length > 1 &&
3407 this.current_line.is_empty()) {
3408 this.__lines.pop();
3409 this.current_line = this.__lines[this.__lines.length - 1];
3410 this.current_line.trim();
3411 }
3412
3413 this.previous_line = this.__lines.length > 1 ?
3414 this.__lines[this.__lines.length - 2] : null;
3415};
3416
3417Output.prototype.just_added_newline = function() {
3418 return this.current_line.is_empty();
3419};
3420
3421Output.prototype.just_added_blankline = function() {
3422 return this.is_empty() ||
3423 (this.current_line.is_empty() && this.previous_line.is_empty());
3424};
3425
3426Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
3427 var index = this.__lines.length - 2;
3428 while (index >= 0) {
3429 var potentialEmptyLine = this.__lines[index];
3430 if (potentialEmptyLine.is_empty()) {
3431 break;
3432 } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
3433 potentialEmptyLine.item(-1) !== ends_with) {
3434 this.__lines.splice(index + 1, 0, new OutputLine(this));
3435 this.previous_line = this.__lines[this.__lines.length - 2];
3436 break;
3437 }
3438 index--;
3439 }
3440};
3441
3442var Output_1 = Output;
3443
3444var output = {
3445 Output: Output_1
3446};
3447
3448/*jshint node:true */
3449
3450function Token(type, text, newlines, whitespace_before) {
3451 this.type = type;
3452 this.text = text;
3453
3454 // comments_before are
3455 // comments that have a new line before them
3456 // and may or may not have a newline after
3457 // this is a set of comments before
3458 this.comments_before = null; /* inline comment*/
3459
3460
3461 // this.comments_after = new TokenStream(); // no new line before and newline after
3462 this.newlines = newlines || 0;
3463 this.whitespace_before = whitespace_before || '';
3464 this.parent = null;
3465 this.next = null;
3466 this.previous = null;
3467 this.opened = null;
3468 this.closed = null;
3469 this.directives = null;
3470}
3471
3472
3473var Token_1 = Token;
3474
3475var token = {
3476 Token: Token_1
3477};
3478
3479var acorn = createCommonjsModule(function (module, exports) {
3480
3481// acorn used char codes to squeeze the last bit of performance out
3482// Beautifier is okay without that, so we're using regex
3483// permit $ (36) and @ (64). @ is used in ES7 decorators.
3484// 65 through 91 are uppercase letters.
3485// permit _ (95).
3486// 97 through 123 are lowercase letters.
3487var baseASCIIidentifierStartChars = "\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a";
3488
3489// inside an identifier @ is not allowed but 0-9 are.
3490var baseASCIIidentifierChars = "\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a";
3491
3492// Big ugly regular expressions that match characters in the
3493// whitespace, identifier, and identifier-start categories. These
3494// are only applied when a character is found to actually have a
3495// code point above 128.
3496var 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";
3497var 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";
3498//var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
3499//var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
3500
3501var identifierStart = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "])";
3502var identifierChars = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])*";
3503
3504exports.identifier = new RegExp(identifierStart + identifierChars, 'g');
3505exports.identifierStart = new RegExp(identifierStart);
3506exports.identifierMatch = new RegExp("(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])+");
3507
3508// Whether a single character denotes a newline.
3509
3510exports.newline = /[\n\r\u2028\u2029]/;
3511
3512// Matches a whole line break (where CRLF is considered a single
3513// line break). Used to count lines.
3514
3515// in javascript, these two differ
3516// in python they are the same, different methods are called on them
3517exports.lineBreak = new RegExp('\r\n|' + exports.newline.source);
3518exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g');
3519});
3520var acorn_1 = acorn.identifier;
3521var acorn_2 = acorn.identifierStart;
3522var acorn_3 = acorn.identifierMatch;
3523var acorn_4 = acorn.newline;
3524var acorn_5 = acorn.lineBreak;
3525var acorn_6 = acorn.allLineBreaks;
3526
3527/*jshint node:true */
3528
3529function Options(options, merge_child_field) {
3530 this.raw_options = _mergeOpts(options, merge_child_field);
3531
3532 // Support passing the source text back with no change
3533 this.disabled = this._get_boolean('disabled');
3534
3535 this.eol = this._get_characters('eol', 'auto');
3536 this.end_with_newline = this._get_boolean('end_with_newline');
3537 this.indent_size = this._get_number('indent_size', 4);
3538 this.indent_char = this._get_characters('indent_char', ' ');
3539 this.indent_level = this._get_number('indent_level');
3540
3541 this.preserve_newlines = this._get_boolean('preserve_newlines', true);
3542 this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
3543 if (!this.preserve_newlines) {
3544 this.max_preserve_newlines = 0;
3545 }
3546
3547 this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
3548 if (this.indent_with_tabs) {
3549 this.indent_char = '\t';
3550
3551 // indent_size behavior changed after 1.8.6
3552 // It used to be that indent_size would be
3553 // set to 1 for indent_with_tabs. That is no longer needed and
3554 // actually doesn't make sense - why not use spaces? Further,
3555 // that might produce unexpected behavior - tabs being used
3556 // for single-column alignment. So, when indent_with_tabs is true
3557 // and indent_size is 1, reset indent_size to 4.
3558 if (this.indent_size === 1) {
3559 this.indent_size = 4;
3560 }
3561 }
3562
3563 // Backwards compat with 1.3.x
3564 this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
3565
3566 this.indent_empty_lines = this._get_boolean('indent_empty_lines');
3567
3568 // valid templating languages ['django', 'erb', 'handlebars', 'php']
3569 // For now, 'auto' = all off for javascript, all on for html (and inline javascript).
3570 // other values ignored
3571 this.templating = this._get_selection_list('templating', ['auto', 'none', 'django', 'erb', 'handlebars', 'php'], ['auto']);
3572}
3573
3574Options.prototype._get_array = function(name, default_value) {
3575 var option_value = this.raw_options[name];
3576 var result = default_value || [];
3577 if (typeof option_value === 'object') {
3578 if (option_value !== null && typeof option_value.concat === 'function') {
3579 result = option_value.concat();
3580 }
3581 } else if (typeof option_value === 'string') {
3582 result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
3583 }
3584 return result;
3585};
3586
3587Options.prototype._get_boolean = function(name, default_value) {
3588 var option_value = this.raw_options[name];
3589 var result = option_value === undefined ? !!default_value : !!option_value;
3590 return result;
3591};
3592
3593Options.prototype._get_characters = function(name, default_value) {
3594 var option_value = this.raw_options[name];
3595 var result = default_value || '';
3596 if (typeof option_value === 'string') {
3597 result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
3598 }
3599 return result;
3600};
3601
3602Options.prototype._get_number = function(name, default_value) {
3603 var option_value = this.raw_options[name];
3604 default_value = parseInt(default_value, 10);
3605 if (isNaN(default_value)) {
3606 default_value = 0;
3607 }
3608 var result = parseInt(option_value, 10);
3609 if (isNaN(result)) {
3610 result = default_value;
3611 }
3612 return result;
3613};
3614
3615Options.prototype._get_selection = function(name, selection_list, default_value) {
3616 var result = this._get_selection_list(name, selection_list, default_value);
3617 if (result.length !== 1) {
3618 throw new Error(
3619 "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
3620 selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
3621 }
3622
3623 return result[0];
3624};
3625
3626
3627Options.prototype._get_selection_list = function(name, selection_list, default_value) {
3628 if (!selection_list || selection_list.length === 0) {
3629 throw new Error("Selection list cannot be empty.");
3630 }
3631
3632 default_value = default_value || [selection_list[0]];
3633 if (!this._is_valid_selection(default_value, selection_list)) {
3634 throw new Error("Invalid Default Value!");
3635 }
3636
3637 var result = this._get_array(name, default_value);
3638 if (!this._is_valid_selection(result, selection_list)) {
3639 throw new Error(
3640 "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
3641 selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
3642 }
3643
3644 return result;
3645};
3646
3647Options.prototype._is_valid_selection = function(result, selection_list) {
3648 return result.length && selection_list.length &&
3649 !result.some(function(item) { return selection_list.indexOf(item) === -1; });
3650};
3651
3652
3653// merges child options up with the parent options object
3654// Example: obj = {a: 1, b: {a: 2}}
3655// mergeOpts(obj, 'b')
3656//
3657// Returns: {a: 2}
3658function _mergeOpts(allOptions, childFieldName) {
3659 var finalOpts = {};
3660 allOptions = _normalizeOpts(allOptions);
3661 var name;
3662
3663 for (name in allOptions) {
3664 if (name !== childFieldName) {
3665 finalOpts[name] = allOptions[name];
3666 }
3667 }
3668
3669 //merge in the per type settings for the childFieldName
3670 if (childFieldName && allOptions[childFieldName]) {
3671 for (name in allOptions[childFieldName]) {
3672 finalOpts[name] = allOptions[childFieldName][name];
3673 }
3674 }
3675 return finalOpts;
3676}
3677
3678function _normalizeOpts(options) {
3679 var convertedOpts = {};
3680 var key;
3681
3682 for (key in options) {
3683 var newKey = key.replace(/-/g, "_");
3684 convertedOpts[newKey] = options[key];
3685 }
3686 return convertedOpts;
3687}
3688
3689var Options_1 = Options;
3690var normalizeOpts = _normalizeOpts;
3691var mergeOpts = _mergeOpts;
3692
3693var options = {
3694 Options: Options_1,
3695 normalizeOpts: normalizeOpts,
3696 mergeOpts: mergeOpts
3697};
3698
3699var BaseOptions = options.Options;
3700
3701var validPositionValues = ['before-newline', 'after-newline', 'preserve-newline'];
3702
3703function Options$1(options) {
3704 BaseOptions.call(this, options, 'js');
3705
3706 // compatibility, re
3707 var raw_brace_style = this.raw_options.brace_style || null;
3708 if (raw_brace_style === "expand-strict") { //graceful handling of deprecated option
3709 this.raw_options.brace_style = "expand";
3710 } else if (raw_brace_style === "collapse-preserve-inline") { //graceful handling of deprecated option
3711 this.raw_options.brace_style = "collapse,preserve-inline";
3712 } else if (this.raw_options.braces_on_own_line !== undefined) { //graceful handling of deprecated option
3713 this.raw_options.brace_style = this.raw_options.braces_on_own_line ? "expand" : "collapse";
3714 // } else if (!raw_brace_style) { //Nothing exists to set it
3715 // raw_brace_style = "collapse";
3716 }
3717
3718 //preserve-inline in delimited string will trigger brace_preserve_inline, everything
3719 //else is considered a brace_style and the last one only will have an effect
3720
3721 var brace_style_split = this._get_selection_list('brace_style', ['collapse', 'expand', 'end-expand', 'none', 'preserve-inline']);
3722
3723 this.brace_preserve_inline = false; //Defaults in case one or other was not specified in meta-option
3724 this.brace_style = "collapse";
3725
3726 for (var bs = 0; bs < brace_style_split.length; bs++) {
3727 if (brace_style_split[bs] === "preserve-inline") {
3728 this.brace_preserve_inline = true;
3729 } else {
3730 this.brace_style = brace_style_split[bs];
3731 }
3732 }
3733
3734 this.unindent_chained_methods = this._get_boolean('unindent_chained_methods');
3735 this.break_chained_methods = this._get_boolean('break_chained_methods');
3736 this.space_in_paren = this._get_boolean('space_in_paren');
3737 this.space_in_empty_paren = this._get_boolean('space_in_empty_paren');
3738 this.jslint_happy = this._get_boolean('jslint_happy');
3739 this.space_after_anon_function = this._get_boolean('space_after_anon_function');
3740 this.space_after_named_function = this._get_boolean('space_after_named_function');
3741 this.keep_array_indentation = this._get_boolean('keep_array_indentation');
3742 this.space_before_conditional = this._get_boolean('space_before_conditional', true);
3743 this.unescape_strings = this._get_boolean('unescape_strings');
3744 this.e4x = this._get_boolean('e4x');
3745 this.comma_first = this._get_boolean('comma_first');
3746 this.operator_position = this._get_selection('operator_position', validPositionValues);
3747
3748 // For testing of beautify preserve:start directive
3749 this.test_output_raw = this._get_boolean('test_output_raw');
3750
3751 // force this._options.space_after_anon_function to true if this._options.jslint_happy
3752 if (this.jslint_happy) {
3753 this.space_after_anon_function = true;
3754 }
3755
3756}
3757Options$1.prototype = new BaseOptions();
3758
3759
3760
3761var Options_1$1 = Options$1;
3762
3763var options$1 = {
3764 Options: Options_1$1
3765};
3766
3767/*jshint node:true */
3768
3769var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
3770
3771function InputScanner(input_string) {
3772 this.__input = input_string || '';
3773 this.__input_length = this.__input.length;
3774 this.__position = 0;
3775}
3776
3777InputScanner.prototype.restart = function() {
3778 this.__position = 0;
3779};
3780
3781InputScanner.prototype.back = function() {
3782 if (this.__position > 0) {
3783 this.__position -= 1;
3784 }
3785};
3786
3787InputScanner.prototype.hasNext = function() {
3788 return this.__position < this.__input_length;
3789};
3790
3791InputScanner.prototype.next = function() {
3792 var val = null;
3793 if (this.hasNext()) {
3794 val = this.__input.charAt(this.__position);
3795 this.__position += 1;
3796 }
3797 return val;
3798};
3799
3800InputScanner.prototype.peek = function(index) {
3801 var val = null;
3802 index = index || 0;
3803 index += this.__position;
3804 if (index >= 0 && index < this.__input_length) {
3805 val = this.__input.charAt(index);
3806 }
3807 return val;
3808};
3809
3810// This is a JavaScript only helper function (not in python)
3811// Javascript doesn't have a match method
3812// and not all implementation support "sticky" flag.
3813// If they do not support sticky then both this.match() and this.test() method
3814// must get the match and check the index of the match.
3815// If sticky is supported and set, this method will use it.
3816// Otherwise it will check that global is set, and fall back to the slower method.
3817InputScanner.prototype.__match = function(pattern, index) {
3818 pattern.lastIndex = index;
3819 var pattern_match = pattern.exec(this.__input);
3820
3821 if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
3822 if (pattern_match.index !== index) {
3823 pattern_match = null;
3824 }
3825 }
3826
3827 return pattern_match;
3828};
3829
3830InputScanner.prototype.test = function(pattern, index) {
3831 index = index || 0;
3832 index += this.__position;
3833
3834 if (index >= 0 && index < this.__input_length) {
3835 return !!this.__match(pattern, index);
3836 } else {
3837 return false;
3838 }
3839};
3840
3841InputScanner.prototype.testChar = function(pattern, index) {
3842 // test one character regex match
3843 var val = this.peek(index);
3844 pattern.lastIndex = 0;
3845 return val !== null && pattern.test(val);
3846};
3847
3848InputScanner.prototype.match = function(pattern) {
3849 var pattern_match = this.__match(pattern, this.__position);
3850 if (pattern_match) {
3851 this.__position += pattern_match[0].length;
3852 } else {
3853 pattern_match = null;
3854 }
3855 return pattern_match;
3856};
3857
3858InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
3859 var val = '';
3860 var match;
3861 if (starting_pattern) {
3862 match = this.match(starting_pattern);
3863 if (match) {
3864 val += match[0];
3865 }
3866 }
3867 if (until_pattern && (match || !starting_pattern)) {
3868 val += this.readUntil(until_pattern, until_after);
3869 }
3870 return val;
3871};
3872
3873InputScanner.prototype.readUntil = function(pattern, until_after) {
3874 var val = '';
3875 var match_index = this.__position;
3876 pattern.lastIndex = this.__position;
3877 var pattern_match = pattern.exec(this.__input);
3878 if (pattern_match) {
3879 match_index = pattern_match.index;
3880 if (until_after) {
3881 match_index += pattern_match[0].length;
3882 }
3883 } else {
3884 match_index = this.__input_length;
3885 }
3886
3887 val = this.__input.substring(this.__position, match_index);
3888 this.__position = match_index;
3889 return val;
3890};
3891
3892InputScanner.prototype.readUntilAfter = function(pattern) {
3893 return this.readUntil(pattern, true);
3894};
3895
3896InputScanner.prototype.get_regexp = function(pattern, match_from) {
3897 var result = null;
3898 var flags = 'g';
3899 if (match_from && regexp_has_sticky) {
3900 flags = 'y';
3901 }
3902 // strings are converted to regexp
3903 if (typeof pattern === "string" && pattern !== '') {
3904 // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
3905 result = new RegExp(pattern, flags);
3906 } else if (pattern) {
3907 result = new RegExp(pattern.source, flags);
3908 }
3909 return result;
3910};
3911
3912InputScanner.prototype.get_literal_regexp = function(literal_string) {
3913 return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
3914};
3915
3916/* css beautifier legacy helpers */
3917InputScanner.prototype.peekUntilAfter = function(pattern) {
3918 var start = this.__position;
3919 var val = this.readUntilAfter(pattern);
3920 this.__position = start;
3921 return val;
3922};
3923
3924InputScanner.prototype.lookBack = function(testVal) {
3925 var start = this.__position - 1;
3926 return start >= testVal.length && this.__input.substring(start - testVal.length, start)
3927 .toLowerCase() === testVal;
3928};
3929
3930var InputScanner_1 = InputScanner;
3931
3932var inputscanner = {
3933 InputScanner: InputScanner_1
3934};
3935
3936/*jshint node:true */
3937
3938function TokenStream(parent_token) {
3939 // private
3940 this.__tokens = [];
3941 this.__tokens_length = this.__tokens.length;
3942 this.__position = 0;
3943 this.__parent_token = parent_token;
3944}
3945
3946TokenStream.prototype.restart = function() {
3947 this.__position = 0;
3948};
3949
3950TokenStream.prototype.isEmpty = function() {
3951 return this.__tokens_length === 0;
3952};
3953
3954TokenStream.prototype.hasNext = function() {
3955 return this.__position < this.__tokens_length;
3956};
3957
3958TokenStream.prototype.next = function() {
3959 var val = null;
3960 if (this.hasNext()) {
3961 val = this.__tokens[this.__position];
3962 this.__position += 1;
3963 }
3964 return val;
3965};
3966
3967TokenStream.prototype.peek = function(index) {
3968 var val = null;
3969 index = index || 0;
3970 index += this.__position;
3971 if (index >= 0 && index < this.__tokens_length) {
3972 val = this.__tokens[index];
3973 }
3974 return val;
3975};
3976
3977TokenStream.prototype.add = function(token) {
3978 if (this.__parent_token) {
3979 token.parent = this.__parent_token;
3980 }
3981 this.__tokens.push(token);
3982 this.__tokens_length += 1;
3983};
3984
3985var TokenStream_1 = TokenStream;
3986
3987var tokenstream = {
3988 TokenStream: TokenStream_1
3989};
3990
3991/*jshint node:true */
3992
3993function Pattern(input_scanner, parent) {
3994 this._input = input_scanner;
3995 this._starting_pattern = null;
3996 this._match_pattern = null;
3997 this._until_pattern = null;
3998 this._until_after = false;
3999
4000 if (parent) {
4001 this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
4002 this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
4003 this._until_pattern = this._input.get_regexp(parent._until_pattern);
4004 this._until_after = parent._until_after;
4005 }
4006}
4007
4008Pattern.prototype.read = function() {
4009 var result = this._input.read(this._starting_pattern);
4010 if (!this._starting_pattern || result) {
4011 result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
4012 }
4013 return result;
4014};
4015
4016Pattern.prototype.read_match = function() {
4017 return this._input.match(this._match_pattern);
4018};
4019
4020Pattern.prototype.until_after = function(pattern) {
4021 var result = this._create();
4022 result._until_after = true;
4023 result._until_pattern = this._input.get_regexp(pattern);
4024 result._update();
4025 return result;
4026};
4027
4028Pattern.prototype.until = function(pattern) {
4029 var result = this._create();
4030 result._until_after = false;
4031 result._until_pattern = this._input.get_regexp(pattern);
4032 result._update();
4033 return result;
4034};
4035
4036Pattern.prototype.starting_with = function(pattern) {
4037 var result = this._create();
4038 result._starting_pattern = this._input.get_regexp(pattern, true);
4039 result._update();
4040 return result;
4041};
4042
4043Pattern.prototype.matching = function(pattern) {
4044 var result = this._create();
4045 result._match_pattern = this._input.get_regexp(pattern, true);
4046 result._update();
4047 return result;
4048};
4049
4050Pattern.prototype._create = function() {
4051 return new Pattern(this._input, this);
4052};
4053
4054Pattern.prototype._update = function() {};
4055
4056var Pattern_1 = Pattern;
4057
4058var pattern = {
4059 Pattern: Pattern_1
4060};
4061
4062var Pattern$1 = pattern.Pattern;
4063
4064function WhitespacePattern(input_scanner, parent) {
4065 Pattern$1.call(this, input_scanner, parent);
4066 if (parent) {
4067 this._line_regexp = this._input.get_regexp(parent._line_regexp);
4068 } else {
4069 this.__set_whitespace_patterns('', '');
4070 }
4071
4072 this.newline_count = 0;
4073 this.whitespace_before_token = '';
4074}
4075WhitespacePattern.prototype = new Pattern$1();
4076
4077WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
4078 whitespace_chars += '\\t ';
4079 newline_chars += '\\n\\r';
4080
4081 this._match_pattern = this._input.get_regexp(
4082 '[' + whitespace_chars + newline_chars + ']+', true);
4083 this._newline_regexp = this._input.get_regexp(
4084 '\\r\\n|[' + newline_chars + ']');
4085};
4086
4087WhitespacePattern.prototype.read = function() {
4088 this.newline_count = 0;
4089 this.whitespace_before_token = '';
4090
4091 var resulting_string = this._input.read(this._match_pattern);
4092 if (resulting_string === ' ') {
4093 this.whitespace_before_token = ' ';
4094 } else if (resulting_string) {
4095 var matches = this.__split(this._newline_regexp, resulting_string);
4096 this.newline_count = matches.length - 1;
4097 this.whitespace_before_token = matches[this.newline_count];
4098 }
4099
4100 return resulting_string;
4101};
4102
4103WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
4104 var result = this._create();
4105 result.__set_whitespace_patterns(whitespace_chars, newline_chars);
4106 result._update();
4107 return result;
4108};
4109
4110WhitespacePattern.prototype._create = function() {
4111 return new WhitespacePattern(this._input, this);
4112};
4113
4114WhitespacePattern.prototype.__split = function(regexp, input_string) {
4115 regexp.lastIndex = 0;
4116 var start_index = 0;
4117 var result = [];
4118 var next_match = regexp.exec(input_string);
4119 while (next_match) {
4120 result.push(input_string.substring(start_index, next_match.index));
4121 start_index = next_match.index + next_match[0].length;
4122 next_match = regexp.exec(input_string);
4123 }
4124
4125 if (start_index < input_string.length) {
4126 result.push(input_string.substring(start_index, input_string.length));
4127 } else {
4128 result.push('');
4129 }
4130
4131 return result;
4132};
4133
4134
4135
4136var WhitespacePattern_1 = WhitespacePattern;
4137
4138var whitespacepattern = {
4139 WhitespacePattern: WhitespacePattern_1
4140};
4141
4142var InputScanner$1 = inputscanner.InputScanner;
4143var Token$1 = token.Token;
4144var TokenStream$1 = tokenstream.TokenStream;
4145var WhitespacePattern$1 = whitespacepattern.WhitespacePattern;
4146
4147var TOKEN = {
4148 START: 'TK_START',
4149 RAW: 'TK_RAW',
4150 EOF: 'TK_EOF'
4151};
4152
4153var Tokenizer = function(input_string, options) {
4154 this._input = new InputScanner$1(input_string);
4155 this._options = options || {};
4156 this.__tokens = null;
4157
4158 this._patterns = {};
4159 this._patterns.whitespace = new WhitespacePattern$1(this._input);
4160};
4161
4162Tokenizer.prototype.tokenize = function() {
4163 this._input.restart();
4164 this.__tokens = new TokenStream$1();
4165
4166 this._reset();
4167
4168 var current;
4169 var previous = new Token$1(TOKEN.START, '');
4170 var open_token = null;
4171 var open_stack = [];
4172 var comments = new TokenStream$1();
4173
4174 while (previous.type !== TOKEN.EOF) {
4175 current = this._get_next_token(previous, open_token);
4176 while (this._is_comment(current)) {
4177 comments.add(current);
4178 current = this._get_next_token(previous, open_token);
4179 }
4180
4181 if (!comments.isEmpty()) {
4182 current.comments_before = comments;
4183 comments = new TokenStream$1();
4184 }
4185
4186 current.parent = open_token;
4187
4188 if (this._is_opening(current)) {
4189 open_stack.push(open_token);
4190 open_token = current;
4191 } else if (open_token && this._is_closing(current, open_token)) {
4192 current.opened = open_token;
4193 open_token.closed = current;
4194 open_token = open_stack.pop();
4195 current.parent = open_token;
4196 }
4197
4198 current.previous = previous;
4199 previous.next = current;
4200
4201 this.__tokens.add(current);
4202 previous = current;
4203 }
4204
4205 return this.__tokens;
4206};
4207
4208
4209Tokenizer.prototype._is_first_token = function() {
4210 return this.__tokens.isEmpty();
4211};
4212
4213Tokenizer.prototype._reset = function() {};
4214
4215Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
4216 this._readWhitespace();
4217 var resulting_string = this._input.read(/.+/g);
4218 if (resulting_string) {
4219 return this._create_token(TOKEN.RAW, resulting_string);
4220 } else {
4221 return this._create_token(TOKEN.EOF, '');
4222 }
4223};
4224
4225Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false
4226 return false;
4227};
4228
4229Tokenizer.prototype._is_opening = function(current_token) { // jshint unused:false
4230 return false;
4231};
4232
4233Tokenizer.prototype._is_closing = function(current_token, open_token) { // jshint unused:false
4234 return false;
4235};
4236
4237Tokenizer.prototype._create_token = function(type, text) {
4238 var token = new Token$1(type, text,
4239 this._patterns.whitespace.newline_count,
4240 this._patterns.whitespace.whitespace_before_token);
4241 return token;
4242};
4243
4244Tokenizer.prototype._readWhitespace = function() {
4245 return this._patterns.whitespace.read();
4246};
4247
4248
4249
4250var Tokenizer_1 = Tokenizer;
4251var TOKEN_1 = TOKEN;
4252
4253var tokenizer = {
4254 Tokenizer: Tokenizer_1,
4255 TOKEN: TOKEN_1
4256};
4257
4258/*jshint node:true */
4259
4260function Directives(start_block_pattern, end_block_pattern) {
4261 start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
4262 end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
4263 this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
4264 this.__directive_pattern = / (\w+)[:](\w+)/g;
4265
4266 this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
4267}
4268
4269Directives.prototype.get_directives = function(text) {
4270 if (!text.match(this.__directives_block_pattern)) {
4271 return null;
4272 }
4273
4274 var directives = {};
4275 this.__directive_pattern.lastIndex = 0;
4276 var directive_match = this.__directive_pattern.exec(text);
4277
4278 while (directive_match) {
4279 directives[directive_match[1]] = directive_match[2];
4280 directive_match = this.__directive_pattern.exec(text);
4281 }
4282
4283 return directives;
4284};
4285
4286Directives.prototype.readIgnored = function(input) {
4287 return input.readUntilAfter(this.__directives_end_ignore_pattern);
4288};
4289
4290
4291var Directives_1 = Directives;
4292
4293var directives = {
4294 Directives: Directives_1
4295};
4296
4297var Pattern$2 = pattern.Pattern;
4298
4299
4300var template_names = {
4301 django: false,
4302 erb: false,
4303 handlebars: false,
4304 php: false
4305};
4306
4307// This lets templates appear anywhere we would do a readUntil
4308// The cost is higher but it is pay to play.
4309function TemplatablePattern(input_scanner, parent) {
4310 Pattern$2.call(this, input_scanner, parent);
4311 this.__template_pattern = null;
4312 this._disabled = Object.assign({}, template_names);
4313 this._excluded = Object.assign({}, template_names);
4314
4315 if (parent) {
4316 this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
4317 this._excluded = Object.assign(this._excluded, parent._excluded);
4318 this._disabled = Object.assign(this._disabled, parent._disabled);
4319 }
4320 var pattern = new Pattern$2(input_scanner);
4321 this.__patterns = {
4322 handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
4323 handlebars: pattern.starting_with(/{{/).until_after(/}}/),
4324 php: pattern.starting_with(/<\?(?:[=]|php)/).until_after(/\?>/),
4325 erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
4326 // django coflicts with handlebars a bit.
4327 django: pattern.starting_with(/{%/).until_after(/%}/),
4328 django_value: pattern.starting_with(/{{/).until_after(/}}/),
4329 django_comment: pattern.starting_with(/{#/).until_after(/#}/)
4330 };
4331}
4332TemplatablePattern.prototype = new Pattern$2();
4333
4334TemplatablePattern.prototype._create = function() {
4335 return new TemplatablePattern(this._input, this);
4336};
4337
4338TemplatablePattern.prototype._update = function() {
4339 this.__set_templated_pattern();
4340};
4341
4342TemplatablePattern.prototype.disable = function(language) {
4343 var result = this._create();
4344 result._disabled[language] = true;
4345 result._update();
4346 return result;
4347};
4348
4349TemplatablePattern.prototype.read_options = function(options) {
4350 var result = this._create();
4351 for (var language in template_names) {
4352 result._disabled[language] = options.templating.indexOf(language) === -1;
4353 }
4354 result._update();
4355 return result;
4356};
4357
4358TemplatablePattern.prototype.exclude = function(language) {
4359 var result = this._create();
4360 result._excluded[language] = true;
4361 result._update();
4362 return result;
4363};
4364
4365TemplatablePattern.prototype.read = function() {
4366 var result = '';
4367 if (this._match_pattern) {
4368 result = this._input.read(this._starting_pattern);
4369 } else {
4370 result = this._input.read(this._starting_pattern, this.__template_pattern);
4371 }
4372 var next = this._read_template();
4373 while (next) {
4374 if (this._match_pattern) {
4375 next += this._input.read(this._match_pattern);
4376 } else {
4377 next += this._input.readUntil(this.__template_pattern);
4378 }
4379 result += next;
4380 next = this._read_template();
4381 }
4382
4383 if (this._until_after) {
4384 result += this._input.readUntilAfter(this._until_pattern);
4385 }
4386 return result;
4387};
4388
4389TemplatablePattern.prototype.__set_templated_pattern = function() {
4390 var items = [];
4391
4392 if (!this._disabled.php) {
4393 items.push(this.__patterns.php._starting_pattern.source);
4394 }
4395 if (!this._disabled.handlebars) {
4396 items.push(this.__patterns.handlebars._starting_pattern.source);
4397 }
4398 if (!this._disabled.erb) {
4399 items.push(this.__patterns.erb._starting_pattern.source);
4400 }
4401 if (!this._disabled.django) {
4402 items.push(this.__patterns.django._starting_pattern.source);
4403 items.push(this.__patterns.django_value._starting_pattern.source);
4404 items.push(this.__patterns.django_comment._starting_pattern.source);
4405 }
4406
4407 if (this._until_pattern) {
4408 items.push(this._until_pattern.source);
4409 }
4410 this.__template_pattern = this._input.get_regexp('(?:' + items.join('|') + ')');
4411};
4412
4413TemplatablePattern.prototype._read_template = function() {
4414 var resulting_string = '';
4415 var c = this._input.peek();
4416 if (c === '<') {
4417 var peek1 = this._input.peek(1);
4418 //if we're in a comment, do something special
4419 // We treat all comments as literals, even more than preformatted tags
4420 // we just look for the appropriate close tag
4421 if (!this._disabled.php && !this._excluded.php && peek1 === '?') {
4422 resulting_string = resulting_string ||
4423 this.__patterns.php.read();
4424 }
4425 if (!this._disabled.erb && !this._excluded.erb && peek1 === '%') {
4426 resulting_string = resulting_string ||
4427 this.__patterns.erb.read();
4428 }
4429 } else if (c === '{') {
4430 if (!this._disabled.handlebars && !this._excluded.handlebars) {
4431 resulting_string = resulting_string ||
4432 this.__patterns.handlebars_comment.read();
4433 resulting_string = resulting_string ||
4434 this.__patterns.handlebars.read();
4435 }
4436 if (!this._disabled.django) {
4437 // django coflicts with handlebars a bit.
4438 if (!this._excluded.django && !this._excluded.handlebars) {
4439 resulting_string = resulting_string ||
4440 this.__patterns.django_value.read();
4441 }
4442 if (!this._excluded.django) {
4443 resulting_string = resulting_string ||
4444 this.__patterns.django_comment.read();
4445 resulting_string = resulting_string ||
4446 this.__patterns.django.read();
4447 }
4448 }
4449 }
4450 return resulting_string;
4451};
4452
4453
4454var TemplatablePattern_1 = TemplatablePattern;
4455
4456var templatablepattern = {
4457 TemplatablePattern: TemplatablePattern_1
4458};
4459
4460var InputScanner$2 = inputscanner.InputScanner;
4461var BaseTokenizer = tokenizer.Tokenizer;
4462var BASETOKEN = tokenizer.TOKEN;
4463var Directives$1 = directives.Directives;
4464
4465var Pattern$3 = pattern.Pattern;
4466var TemplatablePattern$1 = templatablepattern.TemplatablePattern;
4467
4468
4469function in_array(what, arr) {
4470 return arr.indexOf(what) !== -1;
4471}
4472
4473
4474var TOKEN$1 = {
4475 START_EXPR: 'TK_START_EXPR',
4476 END_EXPR: 'TK_END_EXPR',
4477 START_BLOCK: 'TK_START_BLOCK',
4478 END_BLOCK: 'TK_END_BLOCK',
4479 WORD: 'TK_WORD',
4480 RESERVED: 'TK_RESERVED',
4481 SEMICOLON: 'TK_SEMICOLON',
4482 STRING: 'TK_STRING',
4483 EQUALS: 'TK_EQUALS',
4484 OPERATOR: 'TK_OPERATOR',
4485 COMMA: 'TK_COMMA',
4486 BLOCK_COMMENT: 'TK_BLOCK_COMMENT',
4487 COMMENT: 'TK_COMMENT',
4488 DOT: 'TK_DOT',
4489 UNKNOWN: 'TK_UNKNOWN',
4490 START: BASETOKEN.START,
4491 RAW: BASETOKEN.RAW,
4492 EOF: BASETOKEN.EOF
4493};
4494
4495
4496var directives_core = new Directives$1(/\/\*/, /\*\//);
4497
4498var number_pattern = /0[xX][0123456789abcdefABCDEF]*|0[oO][01234567]*|0[bB][01]*|\d+n|(?:\.\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?/;
4499
4500var digit = /[0-9]/;
4501
4502// Dot "." must be distinguished from "..." and decimal
4503var dot_pattern = /[^\d\.]/;
4504
4505var positionable_operators = (
4506 ">>> === !== " +
4507 "<< && >= ** != == <= >> || " +
4508 "< / - + > : & % ? ^ | *").split(' ');
4509
4510// IMPORTANT: this must be sorted longest to shortest or tokenizing many not work.
4511// Also, you must update possitionable operators separately from punct
4512var punct =
4513 ">>>= " +
4514 "... >>= <<= === >>> !== **= " +
4515 "=> ^= :: /= << <= == && -= >= >> != -- += ** || ++ %= &= *= |= " +
4516 "= ! ? > < : / ^ - + * & % ~ |";
4517
4518punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
4519punct = punct.replace(/ /g, '|');
4520
4521var punct_pattern = new RegExp(punct);
4522
4523// words which should always start on new line.
4524var line_starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export'.split(',');
4525var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as']);
4526var reserved_word_pattern = new RegExp('^(?:' + reserved_words.join('|') + ')$');
4527
4528// var template_pattern = /(?:(?:<\?php|<\?=)[\s\S]*?\?>)|(?:<%[\s\S]*?%>)/g;
4529
4530var in_html_comment;
4531
4532var Tokenizer$1 = function(input_string, options) {
4533 BaseTokenizer.call(this, input_string, options);
4534
4535 this._patterns.whitespace = this._patterns.whitespace.matching(
4536 /\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,
4537 /\u2028\u2029/.source);
4538
4539 var pattern_reader = new Pattern$3(this._input);
4540 var templatable = new TemplatablePattern$1(this._input)
4541 .read_options(this._options);
4542
4543 this.__patterns = {
4544 template: templatable,
4545 identifier: templatable.starting_with(acorn.identifier).matching(acorn.identifierMatch),
4546 number: pattern_reader.matching(number_pattern),
4547 punct: pattern_reader.matching(punct_pattern),
4548 // comment ends just before nearest linefeed or end of file
4549 comment: pattern_reader.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),
4550 // /* ... */ comment ends with nearest */ or end of file
4551 block_comment: pattern_reader.starting_with(/\/\*/).until_after(/\*\//),
4552 html_comment_start: pattern_reader.matching(/<!--/),
4553 html_comment_end: pattern_reader.matching(/-->/),
4554 include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak),
4555 shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak),
4556 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*>/),
4557 single_quote: templatable.until(/['\\\n\r\u2028\u2029]/),
4558 double_quote: templatable.until(/["\\\n\r\u2028\u2029]/),
4559 template_text: templatable.until(/[`\\$]/),
4560 template_expression: templatable.until(/[`}\\]/)
4561 };
4562
4563};
4564Tokenizer$1.prototype = new BaseTokenizer();
4565
4566Tokenizer$1.prototype._is_comment = function(current_token) {
4567 return current_token.type === TOKEN$1.COMMENT || current_token.type === TOKEN$1.BLOCK_COMMENT || current_token.type === TOKEN$1.UNKNOWN;
4568};
4569
4570Tokenizer$1.prototype._is_opening = function(current_token) {
4571 return current_token.type === TOKEN$1.START_BLOCK || current_token.type === TOKEN$1.START_EXPR;
4572};
4573
4574Tokenizer$1.prototype._is_closing = function(current_token, open_token) {
4575 return (current_token.type === TOKEN$1.END_BLOCK || current_token.type === TOKEN$1.END_EXPR) &&
4576 (open_token && (
4577 (current_token.text === ']' && open_token.text === '[') ||
4578 (current_token.text === ')' && open_token.text === '(') ||
4579 (current_token.text === '}' && open_token.text === '{')));
4580};
4581
4582Tokenizer$1.prototype._reset = function() {
4583 in_html_comment = false;
4584};
4585
4586Tokenizer$1.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
4587 var token = null;
4588 this._readWhitespace();
4589 var c = this._input.peek();
4590
4591 if (c === null) {
4592 return this._create_token(TOKEN$1.EOF, '');
4593 }
4594
4595 token = token || this._read_string(c);
4596 token = token || this._read_word(previous_token);
4597 token = token || this._read_singles(c);
4598 token = token || this._read_comment(c);
4599 token = token || this._read_regexp(c, previous_token);
4600 token = token || this._read_xml(c, previous_token);
4601 token = token || this._read_non_javascript(c);
4602 token = token || this._read_punctuation();
4603 token = token || this._create_token(TOKEN$1.UNKNOWN, this._input.next());
4604
4605 return token;
4606};
4607
4608Tokenizer$1.prototype._read_word = function(previous_token) {
4609 var resulting_string;
4610 resulting_string = this.__patterns.identifier.read();
4611 if (resulting_string !== '') {
4612 resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
4613 if (!(previous_token.type === TOKEN$1.DOT ||
4614 (previous_token.type === TOKEN$1.RESERVED && (previous_token.text === 'set' || previous_token.text === 'get'))) &&
4615 reserved_word_pattern.test(resulting_string)) {
4616 if (resulting_string === 'in' || resulting_string === 'of') { // hack for 'in' and 'of' operators
4617 return this._create_token(TOKEN$1.OPERATOR, resulting_string);
4618 }
4619 return this._create_token(TOKEN$1.RESERVED, resulting_string);
4620 }
4621 return this._create_token(TOKEN$1.WORD, resulting_string);
4622 }
4623
4624 resulting_string = this.__patterns.number.read();
4625 if (resulting_string !== '') {
4626 return this._create_token(TOKEN$1.WORD, resulting_string);
4627 }
4628};
4629
4630Tokenizer$1.prototype._read_singles = function(c) {
4631 var token = null;
4632 if (c === '(' || c === '[') {
4633 token = this._create_token(TOKEN$1.START_EXPR, c);
4634 } else if (c === ')' || c === ']') {
4635 token = this._create_token(TOKEN$1.END_EXPR, c);
4636 } else if (c === '{') {
4637 token = this._create_token(TOKEN$1.START_BLOCK, c);
4638 } else if (c === '}') {
4639 token = this._create_token(TOKEN$1.END_BLOCK, c);
4640 } else if (c === ';') {
4641 token = this._create_token(TOKEN$1.SEMICOLON, c);
4642 } else if (c === '.' && dot_pattern.test(this._input.peek(1))) {
4643 token = this._create_token(TOKEN$1.DOT, c);
4644 } else if (c === ',') {
4645 token = this._create_token(TOKEN$1.COMMA, c);
4646 }
4647
4648 if (token) {
4649 this._input.next();
4650 }
4651 return token;
4652};
4653
4654Tokenizer$1.prototype._read_punctuation = function() {
4655 var resulting_string = this.__patterns.punct.read();
4656
4657 if (resulting_string !== '') {
4658 if (resulting_string === '=') {
4659 return this._create_token(TOKEN$1.EQUALS, resulting_string);
4660 } else {
4661 return this._create_token(TOKEN$1.OPERATOR, resulting_string);
4662 }
4663 }
4664};
4665
4666Tokenizer$1.prototype._read_non_javascript = function(c) {
4667 var resulting_string = '';
4668
4669 if (c === '#') {
4670 if (this._is_first_token()) {
4671 resulting_string = this.__patterns.shebang.read();
4672
4673 if (resulting_string) {
4674 return this._create_token(TOKEN$1.UNKNOWN, resulting_string.trim() + '\n');
4675 }
4676 }
4677
4678 // handles extendscript #includes
4679 resulting_string = this.__patterns.include.read();
4680
4681 if (resulting_string) {
4682 return this._create_token(TOKEN$1.UNKNOWN, resulting_string.trim() + '\n');
4683 }
4684
4685 c = this._input.next();
4686
4687 // Spidermonkey-specific sharp variables for circular references. Considered obsolete.
4688 var sharp = '#';
4689 if (this._input.hasNext() && this._input.testChar(digit)) {
4690 do {
4691 c = this._input.next();
4692 sharp += c;
4693 } while (this._input.hasNext() && c !== '#' && c !== '=');
4694 if (c === '#') ; else if (this._input.peek() === '[' && this._input.peek(1) === ']') {
4695 sharp += '[]';
4696 this._input.next();
4697 this._input.next();
4698 } else if (this._input.peek() === '{' && this._input.peek(1) === '}') {
4699 sharp += '{}';
4700 this._input.next();
4701 this._input.next();
4702 }
4703 return this._create_token(TOKEN$1.WORD, sharp);
4704 }
4705
4706 this._input.back();
4707
4708 } else if (c === '<' && this._is_first_token()) {
4709 resulting_string = this.__patterns.html_comment_start.read();
4710 if (resulting_string) {
4711 while (this._input.hasNext() && !this._input.testChar(acorn.newline)) {
4712 resulting_string += this._input.next();
4713 }
4714 in_html_comment = true;
4715 return this._create_token(TOKEN$1.COMMENT, resulting_string);
4716 }
4717 } else if (in_html_comment && c === '-') {
4718 resulting_string = this.__patterns.html_comment_end.read();
4719 if (resulting_string) {
4720 in_html_comment = false;
4721 return this._create_token(TOKEN$1.COMMENT, resulting_string);
4722 }
4723 }
4724
4725 return null;
4726};
4727
4728Tokenizer$1.prototype._read_comment = function(c) {
4729 var token = null;
4730 if (c === '/') {
4731 var comment = '';
4732 if (this._input.peek(1) === '*') {
4733 // peek for comment /* ... */
4734 comment = this.__patterns.block_comment.read();
4735 var directives = directives_core.get_directives(comment);
4736 if (directives && directives.ignore === 'start') {
4737 comment += directives_core.readIgnored(this._input);
4738 }
4739 comment = comment.replace(acorn.allLineBreaks, '\n');
4740 token = this._create_token(TOKEN$1.BLOCK_COMMENT, comment);
4741 token.directives = directives;
4742 } else if (this._input.peek(1) === '/') {
4743 // peek for comment // ...
4744 comment = this.__patterns.comment.read();
4745 token = this._create_token(TOKEN$1.COMMENT, comment);
4746 }
4747 }
4748 return token;
4749};
4750
4751Tokenizer$1.prototype._read_string = function(c) {
4752 if (c === '`' || c === "'" || c === '"') {
4753 var resulting_string = this._input.next();
4754 this.has_char_escapes = false;
4755
4756 if (c === '`') {
4757 resulting_string += this._read_string_recursive('`', true, '${');
4758 } else {
4759 resulting_string += this._read_string_recursive(c);
4760 }
4761
4762 if (this.has_char_escapes && this._options.unescape_strings) {
4763 resulting_string = unescape_string(resulting_string);
4764 }
4765
4766 if (this._input.peek() === c) {
4767 resulting_string += this._input.next();
4768 }
4769
4770 resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
4771
4772 return this._create_token(TOKEN$1.STRING, resulting_string);
4773 }
4774
4775 return null;
4776};
4777
4778Tokenizer$1.prototype._allow_regexp_or_xml = function(previous_token) {
4779 // regex and xml can only appear in specific locations during parsing
4780 return (previous_token.type === TOKEN$1.RESERVED && in_array(previous_token.text, ['return', 'case', 'throw', 'else', 'do', 'typeof', 'yield'])) ||
4781 (previous_token.type === TOKEN$1.END_EXPR && previous_token.text === ')' &&
4782 previous_token.opened.previous.type === TOKEN$1.RESERVED && in_array(previous_token.opened.previous.text, ['if', 'while', 'for'])) ||
4783 (in_array(previous_token.type, [TOKEN$1.COMMENT, TOKEN$1.START_EXPR, TOKEN$1.START_BLOCK, TOKEN$1.START,
4784 TOKEN$1.END_BLOCK, TOKEN$1.OPERATOR, TOKEN$1.EQUALS, TOKEN$1.EOF, TOKEN$1.SEMICOLON, TOKEN$1.COMMA
4785 ]));
4786};
4787
4788Tokenizer$1.prototype._read_regexp = function(c, previous_token) {
4789
4790 if (c === '/' && this._allow_regexp_or_xml(previous_token)) {
4791 // handle regexp
4792 //
4793 var resulting_string = this._input.next();
4794 var esc = false;
4795
4796 var in_char_class = false;
4797 while (this._input.hasNext() &&
4798 ((esc || in_char_class || this._input.peek() !== c) &&
4799 !this._input.testChar(acorn.newline))) {
4800 resulting_string += this._input.peek();
4801 if (!esc) {
4802 esc = this._input.peek() === '\\';
4803 if (this._input.peek() === '[') {
4804 in_char_class = true;
4805 } else if (this._input.peek() === ']') {
4806 in_char_class = false;
4807 }
4808 } else {
4809 esc = false;
4810 }
4811 this._input.next();
4812 }
4813
4814 if (this._input.peek() === c) {
4815 resulting_string += this._input.next();
4816
4817 // regexps may have modifiers /regexp/MOD , so fetch those, too
4818 // Only [gim] are valid, but if the user puts in garbage, do what we can to take it.
4819 resulting_string += this._input.read(acorn.identifier);
4820 }
4821 return this._create_token(TOKEN$1.STRING, resulting_string);
4822 }
4823 return null;
4824};
4825
4826Tokenizer$1.prototype._read_xml = function(c, previous_token) {
4827
4828 if (this._options.e4x && c === "<" && this._allow_regexp_or_xml(previous_token)) {
4829 var xmlStr = '';
4830 var match = this.__patterns.xml.read_match();
4831 // handle e4x xml literals
4832 //
4833 if (match) {
4834 // Trim root tag to attempt to
4835 var rootTag = match[2].replace(/^{\s+/, '{').replace(/\s+}$/, '}');
4836 var isCurlyRoot = rootTag.indexOf('{') === 0;
4837 var depth = 0;
4838 while (match) {
4839 var isEndTag = !!match[1];
4840 var tagName = match[2];
4841 var isSingletonTag = (!!match[match.length - 1]) || (tagName.slice(0, 8) === "![CDATA[");
4842 if (!isSingletonTag &&
4843 (tagName === rootTag || (isCurlyRoot && tagName.replace(/^{\s+/, '{').replace(/\s+}$/, '}')))) {
4844 if (isEndTag) {
4845 --depth;
4846 } else {
4847 ++depth;
4848 }
4849 }
4850 xmlStr += match[0];
4851 if (depth <= 0) {
4852 break;
4853 }
4854 match = this.__patterns.xml.read_match();
4855 }
4856 // if we didn't close correctly, keep unformatted.
4857 if (!match) {
4858 xmlStr += this._input.match(/[\s\S]*/g)[0];
4859 }
4860 xmlStr = xmlStr.replace(acorn.allLineBreaks, '\n');
4861 return this._create_token(TOKEN$1.STRING, xmlStr);
4862 }
4863 }
4864
4865 return null;
4866};
4867
4868function unescape_string(s) {
4869 // You think that a regex would work for this
4870 // return s.replace(/\\x([0-9a-f]{2})/gi, function(match, val) {
4871 // return String.fromCharCode(parseInt(val, 16));
4872 // })
4873 // However, dealing with '\xff', '\\xff', '\\\xff' makes this more fun.
4874 var out = '',
4875 escaped = 0;
4876
4877 var input_scan = new InputScanner$2(s);
4878 var matched = null;
4879
4880 while (input_scan.hasNext()) {
4881 // Keep any whitespace, non-slash characters
4882 // also keep slash pairs.
4883 matched = input_scan.match(/([\s]|[^\\]|\\\\)+/g);
4884
4885 if (matched) {
4886 out += matched[0];
4887 }
4888
4889 if (input_scan.peek() === '\\') {
4890 input_scan.next();
4891 if (input_scan.peek() === 'x') {
4892 matched = input_scan.match(/x([0-9A-Fa-f]{2})/g);
4893 } else if (input_scan.peek() === 'u') {
4894 matched = input_scan.match(/u([0-9A-Fa-f]{4})/g);
4895 } else {
4896 out += '\\';
4897 if (input_scan.hasNext()) {
4898 out += input_scan.next();
4899 }
4900 continue;
4901 }
4902
4903 // If there's some error decoding, return the original string
4904 if (!matched) {
4905 return s;
4906 }
4907
4908 escaped = parseInt(matched[1], 16);
4909
4910 if (escaped > 0x7e && escaped <= 0xff && matched[0].indexOf('x') === 0) {
4911 // we bail out on \x7f..\xff,
4912 // leaving whole string escaped,
4913 // as it's probably completely binary
4914 return s;
4915 } else if (escaped >= 0x00 && escaped < 0x20) {
4916 // leave 0x00...0x1f escaped
4917 out += '\\' + matched[0];
4918 continue;
4919 } else if (escaped === 0x22 || escaped === 0x27 || escaped === 0x5c) {
4920 // single-quote, apostrophe, backslash - escape these
4921 out += '\\' + String.fromCharCode(escaped);
4922 } else {
4923 out += String.fromCharCode(escaped);
4924 }
4925 }
4926 }
4927
4928 return out;
4929}
4930
4931// handle string
4932//
4933Tokenizer$1.prototype._read_string_recursive = function(delimiter, allow_unescaped_newlines, start_sub) {
4934 var current_char;
4935 var pattern;
4936 if (delimiter === '\'') {
4937 pattern = this.__patterns.single_quote;
4938 } else if (delimiter === '"') {
4939 pattern = this.__patterns.double_quote;
4940 } else if (delimiter === '`') {
4941 pattern = this.__patterns.template_text;
4942 } else if (delimiter === '}') {
4943 pattern = this.__patterns.template_expression;
4944 }
4945
4946 var resulting_string = pattern.read();
4947 var next = '';
4948 while (this._input.hasNext()) {
4949 next = this._input.next();
4950 if (next === delimiter ||
4951 (!allow_unescaped_newlines && acorn.newline.test(next))) {
4952 this._input.back();
4953 break;
4954 } else if (next === '\\' && this._input.hasNext()) {
4955 current_char = this._input.peek();
4956
4957 if (current_char === 'x' || current_char === 'u') {
4958 this.has_char_escapes = true;
4959 } else if (current_char === '\r' && this._input.peek(1) === '\n') {
4960 this._input.next();
4961 }
4962 next += this._input.next();
4963 } else if (start_sub) {
4964 if (start_sub === '${' && next === '$' && this._input.peek() === '{') {
4965 next += this._input.next();
4966 }
4967
4968 if (start_sub === next) {
4969 if (delimiter === '`') {
4970 next += this._read_string_recursive('}', allow_unescaped_newlines, '`');
4971 } else {
4972 next += this._read_string_recursive('`', allow_unescaped_newlines, '${');
4973 }
4974 if (this._input.hasNext()) {
4975 next += this._input.next();
4976 }
4977 }
4978 }
4979 next += pattern.read();
4980 resulting_string += next;
4981 }
4982
4983 return resulting_string;
4984};
4985
4986var Tokenizer_1$1 = Tokenizer$1;
4987var TOKEN_1$1 = TOKEN$1;
4988var positionable_operators_1 = positionable_operators.slice();
4989var line_starters_1 = line_starters.slice();
4990
4991var tokenizer$1 = {
4992 Tokenizer: Tokenizer_1$1,
4993 TOKEN: TOKEN_1$1,
4994 positionable_operators: positionable_operators_1,
4995 line_starters: line_starters_1
4996};
4997
4998var Output$1 = output.Output;
4999var Token$2 = token.Token;
5000
5001var Options$2 = options$1.Options;
5002var Tokenizer$2 = tokenizer$1.Tokenizer;
5003var line_starters$1 = tokenizer$1.line_starters;
5004var positionable_operators$1 = tokenizer$1.positionable_operators;
5005var TOKEN$2 = tokenizer$1.TOKEN;
5006
5007
5008function in_array$1(what, arr) {
5009 return arr.indexOf(what) !== -1;
5010}
5011
5012function ltrim(s) {
5013 return s.replace(/^\s+/g, '');
5014}
5015
5016function generateMapFromStrings(list) {
5017 var result = {};
5018 for (var x = 0; x < list.length; x++) {
5019 // make the mapped names underscored instead of dash
5020 result[list[x].replace(/-/g, '_')] = list[x];
5021 }
5022 return result;
5023}
5024
5025function reserved_word(token, word) {
5026 return token && token.type === TOKEN$2.RESERVED && token.text === word;
5027}
5028
5029function reserved_array(token, words) {
5030 return token && token.type === TOKEN$2.RESERVED && in_array$1(token.text, words);
5031}
5032// Unsure of what they mean, but they work. Worth cleaning up in future.
5033var special_words = ['case', 'return', 'do', 'if', 'throw', 'else', 'await', 'break', 'continue', 'async'];
5034
5035var validPositionValues$1 = ['before-newline', 'after-newline', 'preserve-newline'];
5036
5037// Generate map from array
5038var OPERATOR_POSITION = generateMapFromStrings(validPositionValues$1);
5039
5040var OPERATOR_POSITION_BEFORE_OR_PRESERVE = [OPERATOR_POSITION.before_newline, OPERATOR_POSITION.preserve_newline];
5041
5042var MODE = {
5043 BlockStatement: 'BlockStatement', // 'BLOCK'
5044 Statement: 'Statement', // 'STATEMENT'
5045 ObjectLiteral: 'ObjectLiteral', // 'OBJECT',
5046 ArrayLiteral: 'ArrayLiteral', //'[EXPRESSION]',
5047 ForInitializer: 'ForInitializer', //'(FOR-EXPRESSION)',
5048 Conditional: 'Conditional', //'(COND-EXPRESSION)',
5049 Expression: 'Expression' //'(EXPRESSION)'
5050};
5051
5052function remove_redundant_indentation(output, frame) {
5053 // This implementation is effective but has some issues:
5054 // - can cause line wrap to happen too soon due to indent removal
5055 // after wrap points are calculated
5056 // These issues are minor compared to ugly indentation.
5057
5058 if (frame.multiline_frame ||
5059 frame.mode === MODE.ForInitializer ||
5060 frame.mode === MODE.Conditional) {
5061 return;
5062 }
5063
5064 // remove one indent from each line inside this section
5065 output.remove_indent(frame.start_line_index);
5066}
5067
5068// we could use just string.split, but
5069// IE doesn't like returning empty strings
5070function split_linebreaks(s) {
5071 //return s.split(/\x0d\x0a|\x0a/);
5072
5073 s = s.replace(acorn.allLineBreaks, '\n');
5074 var out = [],
5075 idx = s.indexOf("\n");
5076 while (idx !== -1) {
5077 out.push(s.substring(0, idx));
5078 s = s.substring(idx + 1);
5079 idx = s.indexOf("\n");
5080 }
5081 if (s.length) {
5082 out.push(s);
5083 }
5084 return out;
5085}
5086
5087function is_array(mode) {
5088 return mode === MODE.ArrayLiteral;
5089}
5090
5091function is_expression(mode) {
5092 return in_array$1(mode, [MODE.Expression, MODE.ForInitializer, MODE.Conditional]);
5093}
5094
5095function all_lines_start_with(lines, c) {
5096 for (var i = 0; i < lines.length; i++) {
5097 var line = lines[i].trim();
5098 if (line.charAt(0) !== c) {
5099 return false;
5100 }
5101 }
5102 return true;
5103}
5104
5105function each_line_matches_indent(lines, indent) {
5106 var i = 0,
5107 len = lines.length,
5108 line;
5109 for (; i < len; i++) {
5110 line = lines[i];
5111 // allow empty lines to pass through
5112 if (line && line.indexOf(indent) !== 0) {
5113 return false;
5114 }
5115 }
5116 return true;
5117}
5118
5119
5120function Beautifier(source_text, options) {
5121 options = options || {};
5122 this._source_text = source_text || '';
5123
5124 this._output = null;
5125 this._tokens = null;
5126 this._last_last_text = null;
5127 this._flags = null;
5128 this._previous_flags = null;
5129
5130 this._flag_store = null;
5131 this._options = new Options$2(options);
5132}
5133
5134Beautifier.prototype.create_flags = function(flags_base, mode) {
5135 var next_indent_level = 0;
5136 if (flags_base) {
5137 next_indent_level = flags_base.indentation_level;
5138 if (!this._output.just_added_newline() &&
5139 flags_base.line_indent_level > next_indent_level) {
5140 next_indent_level = flags_base.line_indent_level;
5141 }
5142 }
5143
5144 var next_flags = {
5145 mode: mode,
5146 parent: flags_base,
5147 last_token: flags_base ? flags_base.last_token : new Token$2(TOKEN$2.START_BLOCK, ''), // last token text
5148 last_word: flags_base ? flags_base.last_word : '', // last TOKEN.WORD passed
5149 declaration_statement: false,
5150 declaration_assignment: false,
5151 multiline_frame: false,
5152 inline_frame: false,
5153 if_block: false,
5154 else_block: false,
5155 do_block: false,
5156 do_while: false,
5157 import_block: false,
5158 in_case_statement: false, // switch(..){ INSIDE HERE }
5159 in_case: false, // we're on the exact line with "case 0:"
5160 case_body: false, // the indented case-action block
5161 indentation_level: next_indent_level,
5162 alignment: 0,
5163 line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level,
5164 start_line_index: this._output.get_line_number(),
5165 ternary_depth: 0
5166 };
5167 return next_flags;
5168};
5169
5170Beautifier.prototype._reset = function(source_text) {
5171 var baseIndentString = source_text.match(/^[\t ]*/)[0];
5172
5173 this._last_last_text = ''; // pre-last token text
5174 this._output = new Output$1(this._options, baseIndentString);
5175
5176 // If testing the ignore directive, start with output disable set to true
5177 this._output.raw = this._options.test_output_raw;
5178
5179
5180 // Stack of parsing/formatting states, including MODE.
5181 // We tokenize, parse, and output in an almost purely a forward-only stream of token input
5182 // and formatted output. This makes the beautifier less accurate than full parsers
5183 // but also far more tolerant of syntax errors.
5184 //
5185 // For example, the default mode is MODE.BlockStatement. If we see a '{' we push a new frame of type
5186 // MODE.BlockStatement on the the stack, even though it could be object literal. If we later
5187 // encounter a ":", we'll switch to to MODE.ObjectLiteral. If we then see a ";",
5188 // most full parsers would die, but the beautifier gracefully falls back to
5189 // MODE.BlockStatement and continues on.
5190 this._flag_store = [];
5191 this.set_mode(MODE.BlockStatement);
5192 var tokenizer = new Tokenizer$2(source_text, this._options);
5193 this._tokens = tokenizer.tokenize();
5194 return source_text;
5195};
5196
5197Beautifier.prototype.beautify = function() {
5198 // if disabled, return the input unchanged.
5199 if (this._options.disabled) {
5200 return this._source_text;
5201 }
5202
5203 var sweet_code;
5204 var source_text = this._reset(this._source_text);
5205
5206 var eol = this._options.eol;
5207 if (this._options.eol === 'auto') {
5208 eol = '\n';
5209 if (source_text && acorn.lineBreak.test(source_text || '')) {
5210 eol = source_text.match(acorn.lineBreak)[0];
5211 }
5212 }
5213
5214 var current_token = this._tokens.next();
5215 while (current_token) {
5216 this.handle_token(current_token);
5217
5218 this._last_last_text = this._flags.last_token.text;
5219 this._flags.last_token = current_token;
5220
5221 current_token = this._tokens.next();
5222 }
5223
5224 sweet_code = this._output.get_code(eol);
5225
5226 return sweet_code;
5227};
5228
5229Beautifier.prototype.handle_token = function(current_token, preserve_statement_flags) {
5230 if (current_token.type === TOKEN$2.START_EXPR) {
5231 this.handle_start_expr(current_token);
5232 } else if (current_token.type === TOKEN$2.END_EXPR) {
5233 this.handle_end_expr(current_token);
5234 } else if (current_token.type === TOKEN$2.START_BLOCK) {
5235 this.handle_start_block(current_token);
5236 } else if (current_token.type === TOKEN$2.END_BLOCK) {
5237 this.handle_end_block(current_token);
5238 } else if (current_token.type === TOKEN$2.WORD) {
5239 this.handle_word(current_token);
5240 } else if (current_token.type === TOKEN$2.RESERVED) {
5241 this.handle_word(current_token);
5242 } else if (current_token.type === TOKEN$2.SEMICOLON) {
5243 this.handle_semicolon(current_token);
5244 } else if (current_token.type === TOKEN$2.STRING) {
5245 this.handle_string(current_token);
5246 } else if (current_token.type === TOKEN$2.EQUALS) {
5247 this.handle_equals(current_token);
5248 } else if (current_token.type === TOKEN$2.OPERATOR) {
5249 this.handle_operator(current_token);
5250 } else if (current_token.type === TOKEN$2.COMMA) {
5251 this.handle_comma(current_token);
5252 } else if (current_token.type === TOKEN$2.BLOCK_COMMENT) {
5253 this.handle_block_comment(current_token, preserve_statement_flags);
5254 } else if (current_token.type === TOKEN$2.COMMENT) {
5255 this.handle_comment(current_token, preserve_statement_flags);
5256 } else if (current_token.type === TOKEN$2.DOT) {
5257 this.handle_dot(current_token);
5258 } else if (current_token.type === TOKEN$2.EOF) {
5259 this.handle_eof(current_token);
5260 } else if (current_token.type === TOKEN$2.UNKNOWN) {
5261 this.handle_unknown(current_token, preserve_statement_flags);
5262 } else {
5263 this.handle_unknown(current_token, preserve_statement_flags);
5264 }
5265};
5266
5267Beautifier.prototype.handle_whitespace_and_comments = function(current_token, preserve_statement_flags) {
5268 var newlines = current_token.newlines;
5269 var keep_whitespace = this._options.keep_array_indentation && is_array(this._flags.mode);
5270
5271 if (current_token.comments_before) {
5272 var comment_token = current_token.comments_before.next();
5273 while (comment_token) {
5274 // The cleanest handling of inline comments is to treat them as though they aren't there.
5275 // Just continue formatting and the behavior should be logical.
5276 // Also ignore unknown tokens. Again, this should result in better behavior.
5277 this.handle_whitespace_and_comments(comment_token, preserve_statement_flags);
5278 this.handle_token(comment_token, preserve_statement_flags);
5279 comment_token = current_token.comments_before.next();
5280 }
5281 }
5282
5283 if (keep_whitespace) {
5284 for (var i = 0; i < newlines; i += 1) {
5285 this.print_newline(i > 0, preserve_statement_flags);
5286 }
5287 } else {
5288 if (this._options.max_preserve_newlines && newlines > this._options.max_preserve_newlines) {
5289 newlines = this._options.max_preserve_newlines;
5290 }
5291
5292 if (this._options.preserve_newlines) {
5293 if (newlines > 1) {
5294 this.print_newline(false, preserve_statement_flags);
5295 for (var j = 1; j < newlines; j += 1) {
5296 this.print_newline(true, preserve_statement_flags);
5297 }
5298 }
5299 }
5300 }
5301
5302};
5303
5304var newline_restricted_tokens = ['async', 'break', 'continue', 'return', 'throw', 'yield'];
5305
5306Beautifier.prototype.allow_wrap_or_preserved_newline = function(current_token, force_linewrap) {
5307 force_linewrap = (force_linewrap === undefined) ? false : force_linewrap;
5308
5309 // Never wrap the first token on a line
5310 if (this._output.just_added_newline()) {
5311 return;
5312 }
5313
5314 var shouldPreserveOrForce = (this._options.preserve_newlines && current_token.newlines) || force_linewrap;
5315 var operatorLogicApplies = in_array$1(this._flags.last_token.text, positionable_operators$1) ||
5316 in_array$1(current_token.text, positionable_operators$1);
5317
5318 if (operatorLogicApplies) {
5319 var shouldPrintOperatorNewline = (
5320 in_array$1(this._flags.last_token.text, positionable_operators$1) &&
5321 in_array$1(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)
5322 ) ||
5323 in_array$1(current_token.text, positionable_operators$1);
5324 shouldPreserveOrForce = shouldPreserveOrForce && shouldPrintOperatorNewline;
5325 }
5326
5327 if (shouldPreserveOrForce) {
5328 this.print_newline(false, true);
5329 } else if (this._options.wrap_line_length) {
5330 if (reserved_array(this._flags.last_token, newline_restricted_tokens)) {
5331 // These tokens should never have a newline inserted
5332 // between them and the following expression.
5333 return;
5334 }
5335 this._output.set_wrap_point();
5336 }
5337};
5338
5339Beautifier.prototype.print_newline = function(force_newline, preserve_statement_flags) {
5340 if (!preserve_statement_flags) {
5341 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 === '++')) {
5342 var next_token = this._tokens.peek();
5343 while (this._flags.mode === MODE.Statement &&
5344 !(this._flags.if_block && reserved_word(next_token, 'else')) &&
5345 !this._flags.do_block) {
5346 this.restore_mode();
5347 }
5348 }
5349 }
5350
5351 if (this._output.add_new_line(force_newline)) {
5352 this._flags.multiline_frame = true;
5353 }
5354};
5355
5356Beautifier.prototype.print_token_line_indentation = function(current_token) {
5357 if (this._output.just_added_newline()) {
5358 if (this._options.keep_array_indentation &&
5359 current_token.newlines &&
5360 (current_token.text === '[' || is_array(this._flags.mode))) {
5361 this._output.current_line.set_indent(-1);
5362 this._output.current_line.push(current_token.whitespace_before);
5363 this._output.space_before_token = false;
5364 } else if (this._output.set_indent(this._flags.indentation_level, this._flags.alignment)) {
5365 this._flags.line_indent_level = this._flags.indentation_level;
5366 }
5367 }
5368};
5369
5370Beautifier.prototype.print_token = function(current_token) {
5371 if (this._output.raw) {
5372 this._output.add_raw_token(current_token);
5373 return;
5374 }
5375
5376 if (this._options.comma_first && current_token.previous && current_token.previous.type === TOKEN$2.COMMA &&
5377 this._output.just_added_newline()) {
5378 if (this._output.previous_line.last() === ',') {
5379 var popped = this._output.previous_line.pop();
5380 // if the comma was already at the start of the line,
5381 // pull back onto that line and reprint the indentation
5382 if (this._output.previous_line.is_empty()) {
5383 this._output.previous_line.push(popped);
5384 this._output.trim(true);
5385 this._output.current_line.pop();
5386 this._output.trim();
5387 }
5388
5389 // add the comma in front of the next token
5390 this.print_token_line_indentation(current_token);
5391 this._output.add_token(',');
5392 this._output.space_before_token = true;
5393 }
5394 }
5395
5396 this.print_token_line_indentation(current_token);
5397 this._output.non_breaking_space = true;
5398 this._output.add_token(current_token.text);
5399 if (this._output.previous_token_wrapped) {
5400 this._flags.multiline_frame = true;
5401 }
5402};
5403
5404Beautifier.prototype.indent = function() {
5405 this._flags.indentation_level += 1;
5406 this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
5407};
5408
5409Beautifier.prototype.deindent = function() {
5410 if (this._flags.indentation_level > 0 &&
5411 ((!this._flags.parent) || this._flags.indentation_level > this._flags.parent.indentation_level)) {
5412 this._flags.indentation_level -= 1;
5413 this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
5414 }
5415};
5416
5417Beautifier.prototype.set_mode = function(mode) {
5418 if (this._flags) {
5419 this._flag_store.push(this._flags);
5420 this._previous_flags = this._flags;
5421 } else {
5422 this._previous_flags = this.create_flags(null, mode);
5423 }
5424
5425 this._flags = this.create_flags(this._previous_flags, mode);
5426 this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
5427};
5428
5429
5430Beautifier.prototype.restore_mode = function() {
5431 if (this._flag_store.length > 0) {
5432 this._previous_flags = this._flags;
5433 this._flags = this._flag_store.pop();
5434 if (this._previous_flags.mode === MODE.Statement) {
5435 remove_redundant_indentation(this._output, this._previous_flags);
5436 }
5437 this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
5438 }
5439};
5440
5441Beautifier.prototype.start_of_object_property = function() {
5442 return this._flags.parent.mode === MODE.ObjectLiteral && this._flags.mode === MODE.Statement && (
5443 (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || (reserved_array(this._flags.last_token, ['get', 'set'])));
5444};
5445
5446Beautifier.prototype.start_of_statement = function(current_token) {
5447 var start = false;
5448 start = start || reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN$2.WORD;
5449 start = start || reserved_word(this._flags.last_token, 'do');
5450 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;
5451 start = start || reserved_word(this._flags.last_token, 'else') &&
5452 !(reserved_word(current_token, 'if') && !current_token.comments_before);
5453 start = start || (this._flags.last_token.type === TOKEN$2.END_EXPR && (this._previous_flags.mode === MODE.ForInitializer || this._previous_flags.mode === MODE.Conditional));
5454 start = start || (this._flags.last_token.type === TOKEN$2.WORD && this._flags.mode === MODE.BlockStatement &&
5455 !this._flags.in_case &&
5456 !(current_token.text === '--' || current_token.text === '++') &&
5457 this._last_last_text !== 'function' &&
5458 current_token.type !== TOKEN$2.WORD && current_token.type !== TOKEN$2.RESERVED);
5459 start = start || (this._flags.mode === MODE.ObjectLiteral && (
5460 (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || reserved_array(this._flags.last_token, ['get', 'set'])));
5461
5462 if (start) {
5463 this.set_mode(MODE.Statement);
5464 this.indent();
5465
5466 this.handle_whitespace_and_comments(current_token, true);
5467
5468 // Issue #276:
5469 // If starting a new statement with [if, for, while, do], push to a new line.
5470 // if (a) if (b) if(c) d(); else e(); else f();
5471 if (!this.start_of_object_property()) {
5472 this.allow_wrap_or_preserved_newline(current_token,
5473 reserved_array(current_token, ['do', 'for', 'if', 'while']));
5474 }
5475 return true;
5476 }
5477 return false;
5478};
5479
5480Beautifier.prototype.handle_start_expr = function(current_token) {
5481 // The conditional starts the statement if appropriate.
5482 if (!this.start_of_statement(current_token)) {
5483 this.handle_whitespace_and_comments(current_token);
5484 }
5485
5486 var next_mode = MODE.Expression;
5487 if (current_token.text === '[') {
5488
5489 if (this._flags.last_token.type === TOKEN$2.WORD || this._flags.last_token.text === ')') {
5490 // this is array index specifier, break immediately
5491 // a[x], fn()[x]
5492 if (reserved_array(this._flags.last_token, line_starters$1)) {
5493 this._output.space_before_token = true;
5494 }
5495 this.print_token(current_token);
5496 this.set_mode(next_mode);
5497 this.indent();
5498 if (this._options.space_in_paren) {
5499 this._output.space_before_token = true;
5500 }
5501 return;
5502 }
5503
5504 next_mode = MODE.ArrayLiteral;
5505 if (is_array(this._flags.mode)) {
5506 if (this._flags.last_token.text === '[' ||
5507 (this._flags.last_token.text === ',' && (this._last_last_text === ']' || this._last_last_text === '}'))) {
5508 // ], [ goes to new line
5509 // }, [ goes to new line
5510 if (!this._options.keep_array_indentation) {
5511 this.print_newline();
5512 }
5513 }
5514 }
5515
5516 if (!in_array$1(this._flags.last_token.type, [TOKEN$2.START_EXPR, TOKEN$2.END_EXPR, TOKEN$2.WORD, TOKEN$2.OPERATOR])) {
5517 this._output.space_before_token = true;
5518 }
5519 } else {
5520 if (this._flags.last_token.type === TOKEN$2.RESERVED) {
5521 if (this._flags.last_token.text === 'for') {
5522 this._output.space_before_token = this._options.space_before_conditional;
5523 next_mode = MODE.ForInitializer;
5524 } else if (in_array$1(this._flags.last_token.text, ['if', 'while'])) {
5525 this._output.space_before_token = this._options.space_before_conditional;
5526 next_mode = MODE.Conditional;
5527 } else if (in_array$1(this._flags.last_word, ['await', 'async'])) {
5528 // Should be a space between await and an IIFE, or async and an arrow function
5529 this._output.space_before_token = true;
5530 } else if (this._flags.last_token.text === 'import' && current_token.whitespace_before === '') {
5531 this._output.space_before_token = false;
5532 } else if (in_array$1(this._flags.last_token.text, line_starters$1) || this._flags.last_token.text === 'catch') {
5533 this._output.space_before_token = true;
5534 }
5535 } else if (this._flags.last_token.type === TOKEN$2.EQUALS || this._flags.last_token.type === TOKEN$2.OPERATOR) {
5536 // Support of this kind of newline preservation.
5537 // a = (b &&
5538 // (c || d));
5539 if (!this.start_of_object_property()) {
5540 this.allow_wrap_or_preserved_newline(current_token);
5541 }
5542 } else if (this._flags.last_token.type === TOKEN$2.WORD) {
5543 this._output.space_before_token = false;
5544
5545 // function name() vs function name ()
5546 // function* name() vs function* name ()
5547 // async name() vs async name ()
5548 // In ES6, you can also define the method properties of an object
5549 // var obj = {a: function() {}}
5550 // It can be abbreviated
5551 // var obj = {a() {}}
5552 // var obj = { a() {}} vs var obj = { a () {}}
5553 // var obj = { * a() {}} vs var obj = { * a () {}}
5554 var peek_back_two = this._tokens.peek(-3);
5555 if (this._options.space_after_named_function && peek_back_two) {
5556 // peek starts at next character so -1 is current token
5557 var peek_back_three = this._tokens.peek(-4);
5558 if (reserved_array(peek_back_two, ['async', 'function']) ||
5559 (peek_back_two.text === '*' && reserved_array(peek_back_three, ['async', 'function']))) {
5560 this._output.space_before_token = true;
5561 } else if (this._flags.mode === MODE.ObjectLiteral) {
5562 if ((peek_back_two.text === '{' || peek_back_two.text === ',') ||
5563 (peek_back_two.text === '*' && (peek_back_three.text === '{' || peek_back_three.text === ','))) {
5564 this._output.space_before_token = true;
5565 }
5566 }
5567 }
5568 } else {
5569 // Support preserving wrapped arrow function expressions
5570 // a.b('c',
5571 // () => d.e
5572 // )
5573 this.allow_wrap_or_preserved_newline(current_token);
5574 }
5575
5576 // function() vs function ()
5577 // yield*() vs yield* ()
5578 // function*() vs function* ()
5579 if ((this._flags.last_token.type === TOKEN$2.RESERVED && (this._flags.last_word === 'function' || this._flags.last_word === 'typeof')) ||
5580 (this._flags.last_token.text === '*' &&
5581 (in_array$1(this._last_last_text, ['function', 'yield']) ||
5582 (this._flags.mode === MODE.ObjectLiteral && in_array$1(this._last_last_text, ['{', ',']))))) {
5583 this._output.space_before_token = this._options.space_after_anon_function;
5584 }
5585 }
5586
5587 if (this._flags.last_token.text === ';' || this._flags.last_token.type === TOKEN$2.START_BLOCK) {
5588 this.print_newline();
5589 } 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) {
5590 // do nothing on (( and )( and ][ and ]( and .(
5591 // TODO: Consider whether forcing this is required. Review failing tests when removed.
5592 this.allow_wrap_or_preserved_newline(current_token, current_token.newlines);
5593 }
5594
5595 this.print_token(current_token);
5596 this.set_mode(next_mode);
5597 if (this._options.space_in_paren) {
5598 this._output.space_before_token = true;
5599 }
5600
5601 // In all cases, if we newline while inside an expression it should be indented.
5602 this.indent();
5603};
5604
5605Beautifier.prototype.handle_end_expr = function(current_token) {
5606 // statements inside expressions are not valid syntax, but...
5607 // statements must all be closed when their container closes
5608 while (this._flags.mode === MODE.Statement) {
5609 this.restore_mode();
5610 }
5611
5612 this.handle_whitespace_and_comments(current_token);
5613
5614 if (this._flags.multiline_frame) {
5615 this.allow_wrap_or_preserved_newline(current_token,
5616 current_token.text === ']' && is_array(this._flags.mode) && !this._options.keep_array_indentation);
5617 }
5618
5619 if (this._options.space_in_paren) {
5620 if (this._flags.last_token.type === TOKEN$2.START_EXPR && !this._options.space_in_empty_paren) {
5621 // () [] no inner space in empty parens like these, ever, ref #320
5622 this._output.trim();
5623 this._output.space_before_token = false;
5624 } else {
5625 this._output.space_before_token = true;
5626 }
5627 }
5628 this.deindent();
5629 this.print_token(current_token);
5630 this.restore_mode();
5631
5632 remove_redundant_indentation(this._output, this._previous_flags);
5633
5634 // do {} while () // no statement required after
5635 if (this._flags.do_while && this._previous_flags.mode === MODE.Conditional) {
5636 this._previous_flags.mode = MODE.Expression;
5637 this._flags.do_block = false;
5638 this._flags.do_while = false;
5639
5640 }
5641};
5642
5643Beautifier.prototype.handle_start_block = function(current_token) {
5644 this.handle_whitespace_and_comments(current_token);
5645
5646 // Check if this is should be treated as a ObjectLiteral
5647 var next_token = this._tokens.peek();
5648 var second_token = this._tokens.peek(1);
5649 if (this._flags.last_word === 'switch' && this._flags.last_token.type === TOKEN$2.END_EXPR) {
5650 this.set_mode(MODE.BlockStatement);
5651 this._flags.in_case_statement = true;
5652 } else if (this._flags.case_body) {
5653 this.set_mode(MODE.BlockStatement);
5654 } else if (second_token && (
5655 (in_array$1(second_token.text, [':', ',']) && in_array$1(next_token.type, [TOKEN$2.STRING, TOKEN$2.WORD, TOKEN$2.RESERVED])) ||
5656 (in_array$1(next_token.text, ['get', 'set', '...']) && in_array$1(second_token.type, [TOKEN$2.WORD, TOKEN$2.RESERVED]))
5657 )) {
5658 // We don't support TypeScript,but we didn't break it for a very long time.
5659 // We'll try to keep not breaking it.
5660 if (!in_array$1(this._last_last_text, ['class', 'interface'])) {
5661 this.set_mode(MODE.ObjectLiteral);
5662 } else {
5663 this.set_mode(MODE.BlockStatement);
5664 }
5665 } else if (this._flags.last_token.type === TOKEN$2.OPERATOR && this._flags.last_token.text === '=>') {
5666 // arrow function: (param1, paramN) => { statements }
5667 this.set_mode(MODE.BlockStatement);
5668 } else if (in_array$1(this._flags.last_token.type, [TOKEN$2.EQUALS, TOKEN$2.START_EXPR, TOKEN$2.COMMA, TOKEN$2.OPERATOR]) ||
5669 reserved_array(this._flags.last_token, ['return', 'throw', 'import', 'default'])
5670 ) {
5671 // Detecting shorthand function syntax is difficult by scanning forward,
5672 // so check the surrounding context.
5673 // If the block is being returned, imported, export default, passed as arg,
5674 // assigned with = or assigned in a nested object, treat as an ObjectLiteral.
5675 this.set_mode(MODE.ObjectLiteral);
5676 } else {
5677 this.set_mode(MODE.BlockStatement);
5678 }
5679
5680 var empty_braces = !next_token.comments_before && next_token.text === '}';
5681 var empty_anonymous_function = empty_braces && this._flags.last_word === 'function' &&
5682 this._flags.last_token.type === TOKEN$2.END_EXPR;
5683
5684 if (this._options.brace_preserve_inline) // check for inline, set inline_frame if so
5685 {
5686 // search forward for a newline wanted inside this block
5687 var index = 0;
5688 var check_token = null;
5689 this._flags.inline_frame = true;
5690 do {
5691 index += 1;
5692 check_token = this._tokens.peek(index - 1);
5693 if (check_token.newlines) {
5694 this._flags.inline_frame = false;
5695 break;
5696 }
5697 } while (check_token.type !== TOKEN$2.EOF &&
5698 !(check_token.type === TOKEN$2.END_BLOCK && check_token.opened === current_token));
5699 }
5700
5701 if ((this._options.brace_style === "expand" ||
5702 (this._options.brace_style === "none" && current_token.newlines)) &&
5703 !this._flags.inline_frame) {
5704 if (this._flags.last_token.type !== TOKEN$2.OPERATOR &&
5705 (empty_anonymous_function ||
5706 this._flags.last_token.type === TOKEN$2.EQUALS ||
5707 (reserved_array(this._flags.last_token, special_words) && this._flags.last_token.text !== 'else'))) {
5708 this._output.space_before_token = true;
5709 } else {
5710 this.print_newline(false, true);
5711 }
5712 } else { // collapse || inline_frame
5713 if (is_array(this._previous_flags.mode) && (this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.COMMA)) {
5714 if (this._flags.last_token.type === TOKEN$2.COMMA || this._options.space_in_paren) {
5715 this._output.space_before_token = true;
5716 }
5717
5718 if (this._flags.last_token.type === TOKEN$2.COMMA || (this._flags.last_token.type === TOKEN$2.START_EXPR && this._flags.inline_frame)) {
5719 this.allow_wrap_or_preserved_newline(current_token);
5720 this._previous_flags.multiline_frame = this._previous_flags.multiline_frame || this._flags.multiline_frame;
5721 this._flags.multiline_frame = false;
5722 }
5723 }
5724 if (this._flags.last_token.type !== TOKEN$2.OPERATOR && this._flags.last_token.type !== TOKEN$2.START_EXPR) {
5725 if (this._flags.last_token.type === TOKEN$2.START_BLOCK && !this._flags.inline_frame) {
5726 this.print_newline();
5727 } else {
5728 this._output.space_before_token = true;
5729 }
5730 }
5731 }
5732 this.print_token(current_token);
5733 this.indent();
5734
5735 // Except for specific cases, open braces are followed by a new line.
5736 if (!empty_braces && !(this._options.brace_preserve_inline && this._flags.inline_frame)) {
5737 this.print_newline();
5738 }
5739};
5740
5741Beautifier.prototype.handle_end_block = function(current_token) {
5742 // statements must all be closed when their container closes
5743 this.handle_whitespace_and_comments(current_token);
5744
5745 while (this._flags.mode === MODE.Statement) {
5746 this.restore_mode();
5747 }
5748
5749 var empty_braces = this._flags.last_token.type === TOKEN$2.START_BLOCK;
5750
5751 if (this._flags.inline_frame && !empty_braces) { // try inline_frame (only set if this._options.braces-preserve-inline) first
5752 this._output.space_before_token = true;
5753 } else if (this._options.brace_style === "expand") {
5754 if (!empty_braces) {
5755 this.print_newline();
5756 }
5757 } else {
5758 // skip {}
5759 if (!empty_braces) {
5760 if (is_array(this._flags.mode) && this._options.keep_array_indentation) {
5761 // we REALLY need a newline here, but newliner would skip that
5762 this._options.keep_array_indentation = false;
5763 this.print_newline();
5764 this._options.keep_array_indentation = true;
5765
5766 } else {
5767 this.print_newline();
5768 }
5769 }
5770 }
5771 this.restore_mode();
5772 this.print_token(current_token);
5773};
5774
5775Beautifier.prototype.handle_word = function(current_token) {
5776 if (current_token.type === TOKEN$2.RESERVED) {
5777 if (in_array$1(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) {
5778 current_token.type = TOKEN$2.WORD;
5779 } else if (current_token.text === 'import' && this._tokens.peek().text === '(') {
5780 current_token.type = TOKEN$2.WORD;
5781 } else if (in_array$1(current_token.text, ['as', 'from']) && !this._flags.import_block) {
5782 current_token.type = TOKEN$2.WORD;
5783 } else if (this._flags.mode === MODE.ObjectLiteral) {
5784 var next_token = this._tokens.peek();
5785 if (next_token.text === ':') {
5786 current_token.type = TOKEN$2.WORD;
5787 }
5788 }
5789 }
5790
5791 if (this.start_of_statement(current_token)) {
5792 // The conditional starts the statement if appropriate.
5793 if (reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN$2.WORD) {
5794 this._flags.declaration_statement = true;
5795 }
5796 } else if (current_token.newlines && !is_expression(this._flags.mode) &&
5797 (this._flags.last_token.type !== TOKEN$2.OPERATOR || (this._flags.last_token.text === '--' || this._flags.last_token.text === '++')) &&
5798 this._flags.last_token.type !== TOKEN$2.EQUALS &&
5799 (this._options.preserve_newlines || !reserved_array(this._flags.last_token, ['var', 'let', 'const', 'set', 'get']))) {
5800 this.handle_whitespace_and_comments(current_token);
5801 this.print_newline();
5802 } else {
5803 this.handle_whitespace_and_comments(current_token);
5804 }
5805
5806 if (this._flags.do_block && !this._flags.do_while) {
5807 if (reserved_word(current_token, 'while')) {
5808 // do {} ## while ()
5809 this._output.space_before_token = true;
5810 this.print_token(current_token);
5811 this._output.space_before_token = true;
5812 this._flags.do_while = true;
5813 return;
5814 } else {
5815 // do {} should always have while as the next word.
5816 // if we don't see the expected while, recover
5817 this.print_newline();
5818 this._flags.do_block = false;
5819 }
5820 }
5821
5822 // if may be followed by else, or not
5823 // Bare/inline ifs are tricky
5824 // Need to unwind the modes correctly: if (a) if (b) c(); else d(); else e();
5825 if (this._flags.if_block) {
5826 if (!this._flags.else_block && reserved_word(current_token, 'else')) {
5827 this._flags.else_block = true;
5828 } else {
5829 while (this._flags.mode === MODE.Statement) {
5830 this.restore_mode();
5831 }
5832 this._flags.if_block = false;
5833 this._flags.else_block = false;
5834 }
5835 }
5836
5837 if (this._flags.in_case_statement && reserved_array(current_token, ['case', 'default'])) {
5838 this.print_newline();
5839 if (this._flags.last_token.type !== TOKEN$2.END_BLOCK && (this._flags.case_body || this._options.jslint_happy)) {
5840 // switch cases following one another
5841 this.deindent();
5842 }
5843 this._flags.case_body = false;
5844
5845 this.print_token(current_token);
5846 this._flags.in_case = true;
5847 return;
5848 }
5849
5850 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) {
5851 if (!this.start_of_object_property()) {
5852 this.allow_wrap_or_preserved_newline(current_token);
5853 }
5854 }
5855
5856 if (reserved_word(current_token, 'function')) {
5857 if (in_array$1(this._flags.last_token.text, ['}', ';']) ||
5858 (this._output.just_added_newline() && !(in_array$1(this._flags.last_token.text, ['(', '[', '{', ':', '=', ',']) || this._flags.last_token.type === TOKEN$2.OPERATOR))) {
5859 // make sure there is a nice clean space of at least one blank line
5860 // before a new function definition
5861 if (!this._output.just_added_blankline() && !current_token.comments_before) {
5862 this.print_newline();
5863 this.print_newline(true);
5864 }
5865 }
5866 if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD) {
5867 if (reserved_array(this._flags.last_token, ['get', 'set', 'new', 'export']) ||
5868 reserved_array(this._flags.last_token, newline_restricted_tokens)) {
5869 this._output.space_before_token = true;
5870 } else if (reserved_word(this._flags.last_token, 'default') && this._last_last_text === 'export') {
5871 this._output.space_before_token = true;
5872 } else if (this._flags.last_token.text === 'declare') {
5873 // accomodates Typescript declare function formatting
5874 this._output.space_before_token = true;
5875 } else {
5876 this.print_newline();
5877 }
5878 } else if (this._flags.last_token.type === TOKEN$2.OPERATOR || this._flags.last_token.text === '=') {
5879 // foo = function
5880 this._output.space_before_token = true;
5881 } else if (!this._flags.multiline_frame && (is_expression(this._flags.mode) || is_array(this._flags.mode))) ; else {
5882 this.print_newline();
5883 }
5884
5885 this.print_token(current_token);
5886 this._flags.last_word = current_token.text;
5887 return;
5888 }
5889
5890 var prefix = 'NONE';
5891
5892 if (this._flags.last_token.type === TOKEN$2.END_BLOCK) {
5893
5894 if (this._previous_flags.inline_frame) {
5895 prefix = 'SPACE';
5896 } else if (!reserved_array(current_token, ['else', 'catch', 'finally', 'from'])) {
5897 prefix = 'NEWLINE';
5898 } else {
5899 if (this._options.brace_style === "expand" ||
5900 this._options.brace_style === "end-expand" ||
5901 (this._options.brace_style === "none" && current_token.newlines)) {
5902 prefix = 'NEWLINE';
5903 } else {
5904 prefix = 'SPACE';
5905 this._output.space_before_token = true;
5906 }
5907 }
5908 } else if (this._flags.last_token.type === TOKEN$2.SEMICOLON && this._flags.mode === MODE.BlockStatement) {
5909 // TODO: Should this be for STATEMENT as well?
5910 prefix = 'NEWLINE';
5911 } else if (this._flags.last_token.type === TOKEN$2.SEMICOLON && is_expression(this._flags.mode)) {
5912 prefix = 'SPACE';
5913 } else if (this._flags.last_token.type === TOKEN$2.STRING) {
5914 prefix = 'NEWLINE';
5915 } else if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD ||
5916 (this._flags.last_token.text === '*' &&
5917 (in_array$1(this._last_last_text, ['function', 'yield']) ||
5918 (this._flags.mode === MODE.ObjectLiteral && in_array$1(this._last_last_text, ['{', ',']))))) {
5919 prefix = 'SPACE';
5920 } else if (this._flags.last_token.type === TOKEN$2.START_BLOCK) {
5921 if (this._flags.inline_frame) {
5922 prefix = 'SPACE';
5923 } else {
5924 prefix = 'NEWLINE';
5925 }
5926 } else if (this._flags.last_token.type === TOKEN$2.END_EXPR) {
5927 this._output.space_before_token = true;
5928 prefix = 'NEWLINE';
5929 }
5930
5931 if (reserved_array(current_token, line_starters$1) && this._flags.last_token.text !== ')') {
5932 if (this._flags.inline_frame || this._flags.last_token.text === 'else' || this._flags.last_token.text === 'export') {
5933 prefix = 'SPACE';
5934 } else {
5935 prefix = 'NEWLINE';
5936 }
5937
5938 }
5939
5940 if (reserved_array(current_token, ['else', 'catch', 'finally'])) {
5941 if ((!(this._flags.last_token.type === TOKEN$2.END_BLOCK && this._previous_flags.mode === MODE.BlockStatement) ||
5942 this._options.brace_style === "expand" ||
5943 this._options.brace_style === "end-expand" ||
5944 (this._options.brace_style === "none" && current_token.newlines)) &&
5945 !this._flags.inline_frame) {
5946 this.print_newline();
5947 } else {
5948 this._output.trim(true);
5949 var line = this._output.current_line;
5950 // If we trimmed and there's something other than a close block before us
5951 // put a newline back in. Handles '} // comment' scenario.
5952 if (line.last() !== '}') {
5953 this.print_newline();
5954 }
5955 this._output.space_before_token = true;
5956 }
5957 } else if (prefix === 'NEWLINE') {
5958 if (reserved_array(this._flags.last_token, special_words)) {
5959 // no newline between 'return nnn'
5960 this._output.space_before_token = true;
5961 } else if (this._flags.last_token.text === 'declare' && reserved_array(current_token, ['var', 'let', 'const'])) {
5962 // accomodates Typescript declare formatting
5963 this._output.space_before_token = true;
5964 } else if (this._flags.last_token.type !== TOKEN$2.END_EXPR) {
5965 if ((this._flags.last_token.type !== TOKEN$2.START_EXPR || !reserved_array(current_token, ['var', 'let', 'const'])) && this._flags.last_token.text !== ':') {
5966 // no need to force newline on 'var': for (var x = 0...)
5967 if (reserved_word(current_token, 'if') && reserved_word(current_token.previous, 'else')) {
5968 // no newline for } else if {
5969 this._output.space_before_token = true;
5970 } else {
5971 this.print_newline();
5972 }
5973 }
5974 } else if (reserved_array(current_token, line_starters$1) && this._flags.last_token.text !== ')') {
5975 this.print_newline();
5976 }
5977 } else if (this._flags.multiline_frame && is_array(this._flags.mode) && this._flags.last_token.text === ',' && this._last_last_text === '}') {
5978 this.print_newline(); // }, in lists get a newline treatment
5979 } else if (prefix === 'SPACE') {
5980 this._output.space_before_token = true;
5981 }
5982 if (current_token.previous && (current_token.previous.type === TOKEN$2.WORD || current_token.previous.type === TOKEN$2.RESERVED)) {
5983 this._output.space_before_token = true;
5984 }
5985 this.print_token(current_token);
5986 this._flags.last_word = current_token.text;
5987
5988 if (current_token.type === TOKEN$2.RESERVED) {
5989 if (current_token.text === 'do') {
5990 this._flags.do_block = true;
5991 } else if (current_token.text === 'if') {
5992 this._flags.if_block = true;
5993 } else if (current_token.text === 'import') {
5994 this._flags.import_block = true;
5995 } else if (this._flags.import_block && reserved_word(current_token, 'from')) {
5996 this._flags.import_block = false;
5997 }
5998 }
5999};
6000
6001Beautifier.prototype.handle_semicolon = function(current_token) {
6002 if (this.start_of_statement(current_token)) {
6003 // The conditional starts the statement if appropriate.
6004 // Semicolon can be the start (and end) of a statement
6005 this._output.space_before_token = false;
6006 } else {
6007 this.handle_whitespace_and_comments(current_token);
6008 }
6009
6010 var next_token = this._tokens.peek();
6011 while (this._flags.mode === MODE.Statement &&
6012 !(this._flags.if_block && reserved_word(next_token, 'else')) &&
6013 !this._flags.do_block) {
6014 this.restore_mode();
6015 }
6016
6017 // hacky but effective for the moment
6018 if (this._flags.import_block) {
6019 this._flags.import_block = false;
6020 }
6021 this.print_token(current_token);
6022};
6023
6024Beautifier.prototype.handle_string = function(current_token) {
6025 if (this.start_of_statement(current_token)) {
6026 // The conditional starts the statement if appropriate.
6027 // One difference - strings want at least a space before
6028 this._output.space_before_token = true;
6029 } else {
6030 this.handle_whitespace_and_comments(current_token);
6031 if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD || this._flags.inline_frame) {
6032 this._output.space_before_token = true;
6033 } 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) {
6034 if (!this.start_of_object_property()) {
6035 this.allow_wrap_or_preserved_newline(current_token);
6036 }
6037 } else {
6038 this.print_newline();
6039 }
6040 }
6041 this.print_token(current_token);
6042};
6043
6044Beautifier.prototype.handle_equals = function(current_token) {
6045 if (this.start_of_statement(current_token)) ; else {
6046 this.handle_whitespace_and_comments(current_token);
6047 }
6048
6049 if (this._flags.declaration_statement) {
6050 // just got an '=' in a var-line, different formatting/line-breaking, etc will now be done
6051 this._flags.declaration_assignment = true;
6052 }
6053 this._output.space_before_token = true;
6054 this.print_token(current_token);
6055 this._output.space_before_token = true;
6056};
6057
6058Beautifier.prototype.handle_comma = function(current_token) {
6059 this.handle_whitespace_and_comments(current_token, true);
6060
6061 this.print_token(current_token);
6062 this._output.space_before_token = true;
6063 if (this._flags.declaration_statement) {
6064 if (is_expression(this._flags.parent.mode)) {
6065 // do not break on comma, for(var a = 1, b = 2)
6066 this._flags.declaration_assignment = false;
6067 }
6068
6069 if (this._flags.declaration_assignment) {
6070 this._flags.declaration_assignment = false;
6071 this.print_newline(false, true);
6072 } else if (this._options.comma_first) {
6073 // for comma-first, we want to allow a newline before the comma
6074 // to turn into a newline after the comma, which we will fixup later
6075 this.allow_wrap_or_preserved_newline(current_token);
6076 }
6077 } else if (this._flags.mode === MODE.ObjectLiteral ||
6078 (this._flags.mode === MODE.Statement && this._flags.parent.mode === MODE.ObjectLiteral)) {
6079 if (this._flags.mode === MODE.Statement) {
6080 this.restore_mode();
6081 }
6082
6083 if (!this._flags.inline_frame) {
6084 this.print_newline();
6085 }
6086 } else if (this._options.comma_first) {
6087 // EXPR or DO_BLOCK
6088 // for comma-first, we want to allow a newline before the comma
6089 // to turn into a newline after the comma, which we will fixup later
6090 this.allow_wrap_or_preserved_newline(current_token);
6091 }
6092};
6093
6094Beautifier.prototype.handle_operator = function(current_token) {
6095 var isGeneratorAsterisk = current_token.text === '*' &&
6096 (reserved_array(this._flags.last_token, ['function', 'yield']) ||
6097 (in_array$1(this._flags.last_token.type, [TOKEN$2.START_BLOCK, TOKEN$2.COMMA, TOKEN$2.END_BLOCK, TOKEN$2.SEMICOLON]))
6098 );
6099 var isUnary = in_array$1(current_token.text, ['-', '+']) && (
6100 in_array$1(this._flags.last_token.type, [TOKEN$2.START_BLOCK, TOKEN$2.START_EXPR, TOKEN$2.EQUALS, TOKEN$2.OPERATOR]) ||
6101 in_array$1(this._flags.last_token.text, line_starters$1) ||
6102 this._flags.last_token.text === ','
6103 );
6104
6105 if (this.start_of_statement(current_token)) ; else {
6106 var preserve_statement_flags = !isGeneratorAsterisk;
6107 this.handle_whitespace_and_comments(current_token, preserve_statement_flags);
6108 }
6109
6110 if (reserved_array(this._flags.last_token, special_words)) {
6111 // "return" had a special handling in TK_WORD. Now we need to return the favor
6112 this._output.space_before_token = true;
6113 this.print_token(current_token);
6114 return;
6115 }
6116
6117 // hack for actionscript's import .*;
6118 if (current_token.text === '*' && this._flags.last_token.type === TOKEN$2.DOT) {
6119 this.print_token(current_token);
6120 return;
6121 }
6122
6123 if (current_token.text === '::') {
6124 // no spaces around exotic namespacing syntax operator
6125 this.print_token(current_token);
6126 return;
6127 }
6128
6129 // Allow line wrapping between operators when operator_position is
6130 // set to before or preserve
6131 if (this._flags.last_token.type === TOKEN$2.OPERATOR && in_array$1(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)) {
6132 this.allow_wrap_or_preserved_newline(current_token);
6133 }
6134
6135 if (current_token.text === ':' && this._flags.in_case) {
6136 this.print_token(current_token);
6137
6138 this._flags.in_case = false;
6139 this._flags.case_body = true;
6140 if (this._tokens.peek().type !== TOKEN$2.START_BLOCK) {
6141 this.indent();
6142 this.print_newline();
6143 } else {
6144 this._output.space_before_token = true;
6145 }
6146 return;
6147 }
6148
6149 var space_before = true;
6150 var space_after = true;
6151 var in_ternary = false;
6152 if (current_token.text === ':') {
6153 if (this._flags.ternary_depth === 0) {
6154 // Colon is invalid javascript outside of ternary and object, but do our best to guess what was meant.
6155 space_before = false;
6156 } else {
6157 this._flags.ternary_depth -= 1;
6158 in_ternary = true;
6159 }
6160 } else if (current_token.text === '?') {
6161 this._flags.ternary_depth += 1;
6162 }
6163
6164 // let's handle the operator_position option prior to any conflicting logic
6165 if (!isUnary && !isGeneratorAsterisk && this._options.preserve_newlines && in_array$1(current_token.text, positionable_operators$1)) {
6166 var isColon = current_token.text === ':';
6167 var isTernaryColon = (isColon && in_ternary);
6168 var isOtherColon = (isColon && !in_ternary);
6169
6170 switch (this._options.operator_position) {
6171 case OPERATOR_POSITION.before_newline:
6172 // if the current token is : and it's not a ternary statement then we set space_before to false
6173 this._output.space_before_token = !isOtherColon;
6174
6175 this.print_token(current_token);
6176
6177 if (!isColon || isTernaryColon) {
6178 this.allow_wrap_or_preserved_newline(current_token);
6179 }
6180
6181 this._output.space_before_token = true;
6182 return;
6183
6184 case OPERATOR_POSITION.after_newline:
6185 // if the current token is anything but colon, or (via deduction) it's a colon and in a ternary statement,
6186 // then print a newline.
6187
6188 this._output.space_before_token = true;
6189
6190 if (!isColon || isTernaryColon) {
6191 if (this._tokens.peek().newlines) {
6192 this.print_newline(false, true);
6193 } else {
6194 this.allow_wrap_or_preserved_newline(current_token);
6195 }
6196 } else {
6197 this._output.space_before_token = false;
6198 }
6199
6200 this.print_token(current_token);
6201
6202 this._output.space_before_token = true;
6203 return;
6204
6205 case OPERATOR_POSITION.preserve_newline:
6206 if (!isOtherColon) {
6207 this.allow_wrap_or_preserved_newline(current_token);
6208 }
6209
6210 // if we just added a newline, or the current token is : and it's not a ternary statement,
6211 // then we set space_before to false
6212 space_before = !(this._output.just_added_newline() || isOtherColon);
6213
6214 this._output.space_before_token = space_before;
6215 this.print_token(current_token);
6216 this._output.space_before_token = true;
6217 return;
6218 }
6219 }
6220
6221 if (isGeneratorAsterisk) {
6222 this.allow_wrap_or_preserved_newline(current_token);
6223 space_before = false;
6224 var next_token = this._tokens.peek();
6225 space_after = next_token && in_array$1(next_token.type, [TOKEN$2.WORD, TOKEN$2.RESERVED]);
6226 } else if (current_token.text === '...') {
6227 this.allow_wrap_or_preserved_newline(current_token);
6228 space_before = this._flags.last_token.type === TOKEN$2.START_BLOCK;
6229 space_after = false;
6230 } else if (in_array$1(current_token.text, ['--', '++', '!', '~']) || isUnary) {
6231 // unary operators (and binary +/- pretending to be unary) special cases
6232 if (this._flags.last_token.type === TOKEN$2.COMMA || this._flags.last_token.type === TOKEN$2.START_EXPR) {
6233 this.allow_wrap_or_preserved_newline(current_token);
6234 }
6235
6236 space_before = false;
6237 space_after = false;
6238
6239 // http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1
6240 // if there is a newline between -- or ++ and anything else we should preserve it.
6241 if (current_token.newlines && (current_token.text === '--' || current_token.text === '++')) {
6242 this.print_newline(false, true);
6243 }
6244
6245 if (this._flags.last_token.text === ';' && is_expression(this._flags.mode)) {
6246 // for (;; ++i)
6247 // ^^^
6248 space_before = true;
6249 }
6250
6251 if (this._flags.last_token.type === TOKEN$2.RESERVED) {
6252 space_before = true;
6253 } else if (this._flags.last_token.type === TOKEN$2.END_EXPR) {
6254 space_before = !(this._flags.last_token.text === ']' && (current_token.text === '--' || current_token.text === '++'));
6255 } else if (this._flags.last_token.type === TOKEN$2.OPERATOR) {
6256 // a++ + ++b;
6257 // a - -b
6258 space_before = in_array$1(current_token.text, ['--', '-', '++', '+']) && in_array$1(this._flags.last_token.text, ['--', '-', '++', '+']);
6259 // + and - are not unary when preceeded by -- or ++ operator
6260 // a-- + b
6261 // a * +b
6262 // a - -b
6263 if (in_array$1(current_token.text, ['+', '-']) && in_array$1(this._flags.last_token.text, ['--', '++'])) {
6264 space_after = true;
6265 }
6266 }
6267
6268
6269 if (((this._flags.mode === MODE.BlockStatement && !this._flags.inline_frame) || this._flags.mode === MODE.Statement) &&
6270 (this._flags.last_token.text === '{' || this._flags.last_token.text === ';')) {
6271 // { foo; --i }
6272 // foo(); --bar;
6273 this.print_newline();
6274 }
6275 }
6276
6277 this._output.space_before_token = this._output.space_before_token || space_before;
6278 this.print_token(current_token);
6279 this._output.space_before_token = space_after;
6280};
6281
6282Beautifier.prototype.handle_block_comment = function(current_token, preserve_statement_flags) {
6283 if (this._output.raw) {
6284 this._output.add_raw_token(current_token);
6285 if (current_token.directives && current_token.directives.preserve === 'end') {
6286 // If we're testing the raw output behavior, do not allow a directive to turn it off.
6287 this._output.raw = this._options.test_output_raw;
6288 }
6289 return;
6290 }
6291
6292 if (current_token.directives) {
6293 this.print_newline(false, preserve_statement_flags);
6294 this.print_token(current_token);
6295 if (current_token.directives.preserve === 'start') {
6296 this._output.raw = true;
6297 }
6298 this.print_newline(false, true);
6299 return;
6300 }
6301
6302 // inline block
6303 if (!acorn.newline.test(current_token.text) && !current_token.newlines) {
6304 this._output.space_before_token = true;
6305 this.print_token(current_token);
6306 this._output.space_before_token = true;
6307 return;
6308 } else {
6309 this.print_block_commment(current_token, preserve_statement_flags);
6310 }
6311};
6312
6313Beautifier.prototype.print_block_commment = function(current_token, preserve_statement_flags) {
6314 var lines = split_linebreaks(current_token.text);
6315 var j; // iterator for this case
6316 var javadoc = false;
6317 var starless = false;
6318 var lastIndent = current_token.whitespace_before;
6319 var lastIndentLength = lastIndent.length;
6320
6321 // block comment starts with a new line
6322 this.print_newline(false, preserve_statement_flags);
6323
6324 // first line always indented
6325 this.print_token_line_indentation(current_token);
6326 this._output.add_token(lines[0]);
6327 this.print_newline(false, preserve_statement_flags);
6328
6329
6330 if (lines.length > 1) {
6331 lines = lines.slice(1);
6332 javadoc = all_lines_start_with(lines, '*');
6333 starless = each_line_matches_indent(lines, lastIndent);
6334
6335 if (javadoc) {
6336 this._flags.alignment = 1;
6337 }
6338
6339 for (j = 0; j < lines.length; j++) {
6340 if (javadoc) {
6341 // javadoc: reformat and re-indent
6342 this.print_token_line_indentation(current_token);
6343 this._output.add_token(ltrim(lines[j]));
6344 } else if (starless && lines[j]) {
6345 // starless: re-indent non-empty content, avoiding trim
6346 this.print_token_line_indentation(current_token);
6347 this._output.add_token(lines[j].substring(lastIndentLength));
6348 } else {
6349 // normal comments output raw
6350 this._output.current_line.set_indent(-1);
6351 this._output.add_token(lines[j]);
6352 }
6353
6354 // for comments on their own line or more than one line, make sure there's a new line after
6355 this.print_newline(false, preserve_statement_flags);
6356 }
6357
6358 this._flags.alignment = 0;
6359 }
6360};
6361
6362
6363Beautifier.prototype.handle_comment = function(current_token, preserve_statement_flags) {
6364 if (current_token.newlines) {
6365 this.print_newline(false, preserve_statement_flags);
6366 } else {
6367 this._output.trim(true);
6368 }
6369
6370 this._output.space_before_token = true;
6371 this.print_token(current_token);
6372 this.print_newline(false, preserve_statement_flags);
6373};
6374
6375Beautifier.prototype.handle_dot = function(current_token) {
6376 if (this.start_of_statement(current_token)) ; else {
6377 this.handle_whitespace_and_comments(current_token, true);
6378 }
6379
6380 if (reserved_array(this._flags.last_token, special_words)) {
6381 this._output.space_before_token = false;
6382 } else {
6383 // allow preserved newlines before dots in general
6384 // force newlines on dots after close paren when break_chained - for bar().baz()
6385 this.allow_wrap_or_preserved_newline(current_token,
6386 this._flags.last_token.text === ')' && this._options.break_chained_methods);
6387 }
6388
6389 // Only unindent chained method dot if this dot starts a new line.
6390 // Otherwise the automatic extra indentation removal will handle the over indent
6391 if (this._options.unindent_chained_methods && this._output.just_added_newline()) {
6392 this.deindent();
6393 }
6394
6395 this.print_token(current_token);
6396};
6397
6398Beautifier.prototype.handle_unknown = function(current_token, preserve_statement_flags) {
6399 this.print_token(current_token);
6400
6401 if (current_token.text[current_token.text.length - 1] === '\n') {
6402 this.print_newline(false, preserve_statement_flags);
6403 }
6404};
6405
6406Beautifier.prototype.handle_eof = function(current_token) {
6407 // Unwind any open statements
6408 while (this._flags.mode === MODE.Statement) {
6409 this.restore_mode();
6410 }
6411 this.handle_whitespace_and_comments(current_token);
6412};
6413
6414var Beautifier_1 = Beautifier;
6415
6416var beautifier = {
6417 Beautifier: Beautifier_1
6418};
6419
6420var Beautifier$1 = beautifier.Beautifier,
6421 Options$3 = options$1.Options;
6422
6423function js_beautify(js_source_text, options) {
6424 var beautifier = new Beautifier$1(js_source_text, options);
6425 return beautifier.beautify();
6426}
6427
6428var javascript = js_beautify;
6429var defaultOptions = function() {
6430 return new Options$3();
6431};
6432javascript.defaultOptions = defaultOptions;
6433
6434var BaseOptions$1 = options.Options;
6435
6436function Options$4(options) {
6437 BaseOptions$1.call(this, options, 'css');
6438
6439 this.selector_separator_newline = this._get_boolean('selector_separator_newline', true);
6440 this.newline_between_rules = this._get_boolean('newline_between_rules', true);
6441 var space_around_selector_separator = this._get_boolean('space_around_selector_separator');
6442 this.space_around_combinator = this._get_boolean('space_around_combinator') || space_around_selector_separator;
6443
6444}
6445Options$4.prototype = new BaseOptions$1();
6446
6447
6448
6449var Options_1$2 = Options$4;
6450
6451var options$2 = {
6452 Options: Options_1$2
6453};
6454
6455var Options$5 = options$2.Options;
6456var Output$2 = output.Output;
6457var InputScanner$3 = inputscanner.InputScanner;
6458var Directives$2 = directives.Directives;
6459
6460var directives_core$1 = new Directives$2(/\/\*/, /\*\//);
6461
6462var lineBreak = /\r\n|[\r\n]/;
6463var allLineBreaks = /\r\n|[\r\n]/g;
6464
6465// tokenizer
6466var whitespaceChar = /\s/;
6467var whitespacePattern = /(?:\s|\n)+/g;
6468var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
6469var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
6470
6471function Beautifier$2(source_text, options) {
6472 this._source_text = source_text || '';
6473 // Allow the setting of language/file-type specific options
6474 // with inheritance of overall settings
6475 this._options = new Options$5(options);
6476 this._ch = null;
6477 this._input = null;
6478
6479 // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
6480 this.NESTED_AT_RULE = {
6481 "@page": true,
6482 "@font-face": true,
6483 "@keyframes": true,
6484 // also in CONDITIONAL_GROUP_RULE below
6485 "@media": true,
6486 "@supports": true,
6487 "@document": true
6488 };
6489 this.CONDITIONAL_GROUP_RULE = {
6490 "@media": true,
6491 "@supports": true,
6492 "@document": true
6493 };
6494
6495}
6496
6497Beautifier$2.prototype.eatString = function(endChars) {
6498 var result = '';
6499 this._ch = this._input.next();
6500 while (this._ch) {
6501 result += this._ch;
6502 if (this._ch === "\\") {
6503 result += this._input.next();
6504 } else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
6505 break;
6506 }
6507 this._ch = this._input.next();
6508 }
6509 return result;
6510};
6511
6512// Skips any white space in the source text from the current position.
6513// When allowAtLeastOneNewLine is true, will output new lines for each
6514// newline character found; if the user has preserve_newlines off, only
6515// the first newline will be output
6516Beautifier$2.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
6517 var result = whitespaceChar.test(this._input.peek());
6518 var isFirstNewLine = true;
6519
6520 while (whitespaceChar.test(this._input.peek())) {
6521 this._ch = this._input.next();
6522 if (allowAtLeastOneNewLine && this._ch === '\n') {
6523 if (this._options.preserve_newlines || isFirstNewLine) {
6524 isFirstNewLine = false;
6525 this._output.add_new_line(true);
6526 }
6527 }
6528 }
6529 return result;
6530};
6531
6532// Nested pseudo-class if we are insideRule
6533// and the next special character found opens
6534// a new block
6535Beautifier$2.prototype.foundNestedPseudoClass = function() {
6536 var openParen = 0;
6537 var i = 1;
6538 var ch = this._input.peek(i);
6539 while (ch) {
6540 if (ch === "{") {
6541 return true;
6542 } else if (ch === '(') {
6543 // pseudoclasses can contain ()
6544 openParen += 1;
6545 } else if (ch === ')') {
6546 if (openParen === 0) {
6547 return false;
6548 }
6549 openParen -= 1;
6550 } else if (ch === ";" || ch === "}") {
6551 return false;
6552 }
6553 i++;
6554 ch = this._input.peek(i);
6555 }
6556 return false;
6557};
6558
6559Beautifier$2.prototype.print_string = function(output_string) {
6560 this._output.set_indent(this._indentLevel);
6561 this._output.non_breaking_space = true;
6562 this._output.add_token(output_string);
6563};
6564
6565Beautifier$2.prototype.preserveSingleSpace = function(isAfterSpace) {
6566 if (isAfterSpace) {
6567 this._output.space_before_token = true;
6568 }
6569};
6570
6571Beautifier$2.prototype.indent = function() {
6572 this._indentLevel++;
6573};
6574
6575Beautifier$2.prototype.outdent = function() {
6576 if (this._indentLevel > 0) {
6577 this._indentLevel--;
6578 }
6579};
6580
6581/*_____________________--------------------_____________________*/
6582
6583Beautifier$2.prototype.beautify = function() {
6584 if (this._options.disabled) {
6585 return this._source_text;
6586 }
6587
6588 var source_text = this._source_text;
6589 var eol = this._options.eol;
6590 if (eol === 'auto') {
6591 eol = '\n';
6592 if (source_text && lineBreak.test(source_text || '')) {
6593 eol = source_text.match(lineBreak)[0];
6594 }
6595 }
6596
6597
6598 // HACK: newline parsing inconsistent. This brute force normalizes the this._input.
6599 source_text = source_text.replace(allLineBreaks, '\n');
6600
6601 // reset
6602 var baseIndentString = source_text.match(/^[\t ]*/)[0];
6603
6604 this._output = new Output$2(this._options, baseIndentString);
6605 this._input = new InputScanner$3(source_text);
6606 this._indentLevel = 0;
6607 this._nestedLevel = 0;
6608
6609 this._ch = null;
6610 var parenLevel = 0;
6611
6612 var insideRule = false;
6613 // This is the value side of a property value pair (blue in the following ex)
6614 // label { content: blue }
6615 var insidePropertyValue = false;
6616 var enteringConditionalGroup = false;
6617 var insideAtExtend = false;
6618 var insideAtImport = false;
6619 var topCharacter = this._ch;
6620 var whitespace;
6621 var isAfterSpace;
6622 var previous_ch;
6623
6624 while (true) {
6625 whitespace = this._input.read(whitespacePattern);
6626 isAfterSpace = whitespace !== '';
6627 previous_ch = topCharacter;
6628 this._ch = this._input.next();
6629 if (this._ch === '\\' && this._input.hasNext()) {
6630 this._ch += this._input.next();
6631 }
6632 topCharacter = this._ch;
6633
6634 if (!this._ch) {
6635 break;
6636 } else if (this._ch === '/' && this._input.peek() === '*') {
6637 // /* css comment */
6638 // Always start block comments on a new line.
6639 // This handles scenarios where a block comment immediately
6640 // follows a property definition on the same line or where
6641 // minified code is being beautified.
6642 this._output.add_new_line();
6643 this._input.back();
6644
6645 var comment = this._input.read(block_comment_pattern);
6646
6647 // Handle ignore directive
6648 var directives = directives_core$1.get_directives(comment);
6649 if (directives && directives.ignore === 'start') {
6650 comment += directives_core$1.readIgnored(this._input);
6651 }
6652
6653 this.print_string(comment);
6654
6655 // Ensures any new lines following the comment are preserved
6656 this.eatWhitespace(true);
6657
6658 // Block comments are followed by a new line so they don't
6659 // share a line with other properties
6660 this._output.add_new_line();
6661 } else if (this._ch === '/' && this._input.peek() === '/') {
6662 // // single line comment
6663 // Preserves the space before a comment
6664 // on the same line as a rule
6665 this._output.space_before_token = true;
6666 this._input.back();
6667 this.print_string(this._input.read(comment_pattern));
6668
6669 // Ensures any new lines following the comment are preserved
6670 this.eatWhitespace(true);
6671 } else if (this._ch === '@') {
6672 this.preserveSingleSpace(isAfterSpace);
6673
6674 // deal with less propery mixins @{...}
6675 if (this._input.peek() === '{') {
6676 this.print_string(this._ch + this.eatString('}'));
6677 } else {
6678 this.print_string(this._ch);
6679
6680 // strip trailing space, if present, for hash property checks
6681 var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
6682
6683 if (variableOrRule.match(/[ :]$/)) {
6684 // we have a variable or pseudo-class, add it and insert one space before continuing
6685 variableOrRule = this.eatString(": ").replace(/\s$/, '');
6686 this.print_string(variableOrRule);
6687 this._output.space_before_token = true;
6688 }
6689
6690 variableOrRule = variableOrRule.replace(/\s$/, '');
6691
6692 if (variableOrRule === 'extend') {
6693 insideAtExtend = true;
6694 } else if (variableOrRule === 'import') {
6695 insideAtImport = true;
6696 }
6697
6698 // might be a nesting at-rule
6699 if (variableOrRule in this.NESTED_AT_RULE) {
6700 this._nestedLevel += 1;
6701 if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
6702 enteringConditionalGroup = true;
6703 }
6704 // might be less variable
6705 } else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
6706 insidePropertyValue = true;
6707 this.indent();
6708 }
6709 }
6710 } else if (this._ch === '#' && this._input.peek() === '{') {
6711 this.preserveSingleSpace(isAfterSpace);
6712 this.print_string(this._ch + this.eatString('}'));
6713 } else if (this._ch === '{') {
6714 if (insidePropertyValue) {
6715 insidePropertyValue = false;
6716 this.outdent();
6717 }
6718 this.indent();
6719 this._output.space_before_token = true;
6720 this.print_string(this._ch);
6721
6722 // when entering conditional groups, only rulesets are allowed
6723 if (enteringConditionalGroup) {
6724 enteringConditionalGroup = false;
6725 insideRule = (this._indentLevel > this._nestedLevel);
6726 } else {
6727 // otherwise, declarations are also allowed
6728 insideRule = (this._indentLevel >= this._nestedLevel);
6729 }
6730 if (this._options.newline_between_rules && insideRule) {
6731 if (this._output.previous_line && this._output.previous_line.item(-1) !== '{') {
6732 this._output.ensure_empty_line_above('/', ',');
6733 }
6734 }
6735 this.eatWhitespace(true);
6736 this._output.add_new_line();
6737 } else if (this._ch === '}') {
6738 this.outdent();
6739 this._output.add_new_line();
6740 if (previous_ch === '{') {
6741 this._output.trim(true);
6742 }
6743 insideAtImport = false;
6744 insideAtExtend = false;
6745 if (insidePropertyValue) {
6746 this.outdent();
6747 insidePropertyValue = false;
6748 }
6749 this.print_string(this._ch);
6750 insideRule = false;
6751 if (this._nestedLevel) {
6752 this._nestedLevel--;
6753 }
6754
6755 this.eatWhitespace(true);
6756 this._output.add_new_line();
6757
6758 if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
6759 if (this._input.peek() !== '}') {
6760 this._output.add_new_line(true);
6761 }
6762 }
6763 } else if (this._ch === ":") {
6764 if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
6765 // 'property: value' delimiter
6766 // which could be in a conditional group query
6767 this.print_string(':');
6768 if (!insidePropertyValue) {
6769 insidePropertyValue = true;
6770 this._output.space_before_token = true;
6771 this.eatWhitespace(true);
6772 this.indent();
6773 }
6774 } else {
6775 // sass/less parent reference don't use a space
6776 // sass nested pseudo-class don't use a space
6777
6778 // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
6779 if (this._input.lookBack(" ")) {
6780 this._output.space_before_token = true;
6781 }
6782 if (this._input.peek() === ":") {
6783 // pseudo-element
6784 this._ch = this._input.next();
6785 this.print_string("::");
6786 } else {
6787 // pseudo-class
6788 this.print_string(':');
6789 }
6790 }
6791 } else if (this._ch === '"' || this._ch === '\'') {
6792 this.preserveSingleSpace(isAfterSpace);
6793 this.print_string(this._ch + this.eatString(this._ch));
6794 this.eatWhitespace(true);
6795 } else if (this._ch === ';') {
6796 if (parenLevel === 0) {
6797 if (insidePropertyValue) {
6798 this.outdent();
6799 insidePropertyValue = false;
6800 }
6801 insideAtExtend = false;
6802 insideAtImport = false;
6803 this.print_string(this._ch);
6804 this.eatWhitespace(true);
6805
6806 // This maintains single line comments on the same
6807 // line. Block comments are also affected, but
6808 // a new line is always output before one inside
6809 // that section
6810 if (this._input.peek() !== '/') {
6811 this._output.add_new_line();
6812 }
6813 } else {
6814 this.print_string(this._ch);
6815 this.eatWhitespace(true);
6816 this._output.space_before_token = true;
6817 }
6818 } else if (this._ch === '(') { // may be a url
6819 if (this._input.lookBack("url")) {
6820 this.print_string(this._ch);
6821 this.eatWhitespace();
6822 parenLevel++;
6823 this.indent();
6824 this._ch = this._input.next();
6825 if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
6826 this._input.back();
6827 } else if (this._ch) {
6828 this.print_string(this._ch + this.eatString(')'));
6829 if (parenLevel) {
6830 parenLevel--;
6831 this.outdent();
6832 }
6833 }
6834 } else {
6835 this.preserveSingleSpace(isAfterSpace);
6836 this.print_string(this._ch);
6837 this.eatWhitespace();
6838 parenLevel++;
6839 this.indent();
6840 }
6841 } else if (this._ch === ')') {
6842 if (parenLevel) {
6843 parenLevel--;
6844 this.outdent();
6845 }
6846 this.print_string(this._ch);
6847 } else if (this._ch === ',') {
6848 this.print_string(this._ch);
6849 this.eatWhitespace(true);
6850 if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport) {
6851 this._output.add_new_line();
6852 } else {
6853 this._output.space_before_token = true;
6854 }
6855 } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel === 0) {
6856 //handle combinator spacing
6857 if (this._options.space_around_combinator) {
6858 this._output.space_before_token = true;
6859 this.print_string(this._ch);
6860 this._output.space_before_token = true;
6861 } else {
6862 this.print_string(this._ch);
6863 this.eatWhitespace();
6864 // squash extra whitespace
6865 if (this._ch && whitespaceChar.test(this._ch)) {
6866 this._ch = '';
6867 }
6868 }
6869 } else if (this._ch === ']') {
6870 this.print_string(this._ch);
6871 } else if (this._ch === '[') {
6872 this.preserveSingleSpace(isAfterSpace);
6873 this.print_string(this._ch);
6874 } else if (this._ch === '=') { // no whitespace before or after
6875 this.eatWhitespace();
6876 this.print_string('=');
6877 if (whitespaceChar.test(this._ch)) {
6878 this._ch = '';
6879 }
6880 } else if (this._ch === '!' && !this._input.lookBack("\\")) { // !important
6881 this.print_string(' ');
6882 this.print_string(this._ch);
6883 } else {
6884 this.preserveSingleSpace(isAfterSpace);
6885 this.print_string(this._ch);
6886 }
6887 }
6888
6889 var sweetCode = this._output.get_code(eol);
6890
6891 return sweetCode;
6892};
6893
6894var Beautifier_1$1 = Beautifier$2;
6895
6896var beautifier$1 = {
6897 Beautifier: Beautifier_1$1
6898};
6899
6900var Beautifier$3 = beautifier$1.Beautifier,
6901 Options$6 = options$2.Options;
6902
6903function css_beautify(source_text, options) {
6904 var beautifier = new Beautifier$3(source_text, options);
6905 return beautifier.beautify();
6906}
6907
6908var css = css_beautify;
6909var defaultOptions$1 = function() {
6910 return new Options$6();
6911};
6912css.defaultOptions = defaultOptions$1;
6913
6914var BaseOptions$2 = options.Options;
6915
6916function Options$7(options) {
6917 BaseOptions$2.call(this, options, 'html');
6918 if (this.templating.length === 1 && this.templating[0] === 'auto') {
6919 this.templating = ['django', 'erb', 'handlebars', 'php'];
6920 }
6921
6922 this.indent_inner_html = this._get_boolean('indent_inner_html');
6923 this.indent_body_inner_html = this._get_boolean('indent_body_inner_html', true);
6924 this.indent_head_inner_html = this._get_boolean('indent_head_inner_html', true);
6925
6926 this.indent_handlebars = this._get_boolean('indent_handlebars', true);
6927 this.wrap_attributes = this._get_selection('wrap_attributes',
6928 ['auto', 'force', 'force-aligned', 'force-expand-multiline', 'aligned-multiple', 'preserve', 'preserve-aligned']);
6929 this.wrap_attributes_indent_size = this._get_number('wrap_attributes_indent_size', this.indent_size);
6930 this.extra_liners = this._get_array('extra_liners', ['head', 'body', '/html']);
6931
6932 // Block vs inline elements
6933 // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
6934 // https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
6935 // https://www.w3.org/TR/html5/dom.html#phrasing-content
6936 this.inline = this._get_array('inline', [
6937 'a', 'abbr', 'area', 'audio', 'b', 'bdi', 'bdo', 'br', 'button', 'canvas', 'cite',
6938 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img',
6939 'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark', 'math', 'meter', 'noscript',
6940 'object', 'output', 'progress', 'q', 'ruby', 's', 'samp', /* 'script', */ 'select', 'small',
6941 'span', 'strong', 'sub', 'sup', 'svg', 'template', 'textarea', 'time', 'u', 'var',
6942 'video', 'wbr', 'text',
6943 // obsolete inline tags
6944 'acronym', 'big', 'strike', 'tt'
6945 ]);
6946 this.void_elements = this._get_array('void_elements', [
6947 // HTLM void elements - aka self-closing tags - aka singletons
6948 // https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
6949 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
6950 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr',
6951 // NOTE: Optional tags are too complex for a simple list
6952 // they are hard coded in _do_optional_end_element
6953
6954 // Doctype and xml elements
6955 '!doctype', '?xml',
6956
6957 // obsolete tags
6958 // basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
6959 // isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
6960 'basefont', 'isindex'
6961 ]);
6962 this.unformatted = this._get_array('unformatted', []);
6963 this.content_unformatted = this._get_array('content_unformatted', [
6964 'pre', 'textarea'
6965 ]);
6966 this.unformatted_content_delimiter = this._get_characters('unformatted_content_delimiter');
6967 this.indent_scripts = this._get_selection('indent_scripts', ['normal', 'keep', 'separate']);
6968
6969}
6970Options$7.prototype = new BaseOptions$2();
6971
6972
6973
6974var Options_1$3 = Options$7;
6975
6976var options$3 = {
6977 Options: Options_1$3
6978};
6979
6980var BaseTokenizer$1 = tokenizer.Tokenizer;
6981var BASETOKEN$1 = tokenizer.TOKEN;
6982var Directives$3 = directives.Directives;
6983var TemplatablePattern$2 = templatablepattern.TemplatablePattern;
6984var Pattern$4 = pattern.Pattern;
6985
6986var TOKEN$3 = {
6987 TAG_OPEN: 'TK_TAG_OPEN',
6988 TAG_CLOSE: 'TK_TAG_CLOSE',
6989 ATTRIBUTE: 'TK_ATTRIBUTE',
6990 EQUALS: 'TK_EQUALS',
6991 VALUE: 'TK_VALUE',
6992 COMMENT: 'TK_COMMENT',
6993 TEXT: 'TK_TEXT',
6994 UNKNOWN: 'TK_UNKNOWN',
6995 START: BASETOKEN$1.START,
6996 RAW: BASETOKEN$1.RAW,
6997 EOF: BASETOKEN$1.EOF
6998};
6999
7000var directives_core$2 = new Directives$3(/<\!--/, /-->/);
7001
7002var Tokenizer$3 = function(input_string, options) {
7003 BaseTokenizer$1.call(this, input_string, options);
7004 this._current_tag_name = '';
7005
7006 // Words end at whitespace or when a tag starts
7007 // if we are indenting handlebars, they are considered tags
7008 var templatable_reader = new TemplatablePattern$2(this._input).read_options(this._options);
7009 var pattern_reader = new Pattern$4(this._input);
7010
7011 this.__patterns = {
7012 word: templatable_reader.until(/[\n\r\t <]/),
7013 single_quote: templatable_reader.until_after(/'/),
7014 double_quote: templatable_reader.until_after(/"/),
7015 attribute: templatable_reader.until(/[\n\r\t =\/>]/),
7016 element_name: templatable_reader.until(/[\n\r\t >\/]/),
7017
7018 handlebars_comment: pattern_reader.starting_with(/{{!--/).until_after(/--}}/),
7019 handlebars: pattern_reader.starting_with(/{{/).until_after(/}}/),
7020 handlebars_open: pattern_reader.until(/[\n\r\t }]/),
7021 handlebars_raw_close: pattern_reader.until(/}}/),
7022 comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
7023 cdata: pattern_reader.starting_with(/<!\[cdata\[/).until_after(/]]>/),
7024 // https://en.wikipedia.org/wiki/Conditional_comment
7025 conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
7026 processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
7027 };
7028
7029 if (this._options.indent_handlebars) {
7030 this.__patterns.word = this.__patterns.word.exclude('handlebars');
7031 }
7032
7033 this._unformatted_content_delimiter = null;
7034
7035 if (this._options.unformatted_content_delimiter) {
7036 var literal_regexp = this._input.get_literal_regexp(this._options.unformatted_content_delimiter);
7037 this.__patterns.unformatted_content_delimiter =
7038 pattern_reader.matching(literal_regexp)
7039 .until_after(literal_regexp);
7040 }
7041};
7042Tokenizer$3.prototype = new BaseTokenizer$1();
7043
7044Tokenizer$3.prototype._is_comment = function(current_token) { // jshint unused:false
7045 return false; //current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.UNKNOWN;
7046};
7047
7048Tokenizer$3.prototype._is_opening = function(current_token) {
7049 return current_token.type === TOKEN$3.TAG_OPEN;
7050};
7051
7052Tokenizer$3.prototype._is_closing = function(current_token, open_token) {
7053 return current_token.type === TOKEN$3.TAG_CLOSE &&
7054 (open_token && (
7055 ((current_token.text === '>' || current_token.text === '/>') && open_token.text[0] === '<') ||
7056 (current_token.text === '}}' && open_token.text[0] === '{' && open_token.text[1] === '{')));
7057};
7058
7059Tokenizer$3.prototype._reset = function() {
7060 this._current_tag_name = '';
7061};
7062
7063Tokenizer$3.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
7064 var token = null;
7065 this._readWhitespace();
7066 var c = this._input.peek();
7067
7068 if (c === null) {
7069 return this._create_token(TOKEN$3.EOF, '');
7070 }
7071
7072 token = token || this._read_open_handlebars(c, open_token);
7073 token = token || this._read_attribute(c, previous_token, open_token);
7074 token = token || this._read_raw_content(c, previous_token, open_token);
7075 token = token || this._read_close(c, open_token);
7076 token = token || this._read_content_word(c);
7077 token = token || this._read_comment(c);
7078 token = token || this._read_open(c, open_token);
7079 token = token || this._create_token(TOKEN$3.UNKNOWN, this._input.next());
7080
7081 return token;
7082};
7083
7084Tokenizer$3.prototype._read_comment = function(c) { // jshint unused:false
7085 var token = null;
7086 var resulting_string = null;
7087 var directives = null;
7088
7089 if (c === '<') {
7090 var peek1 = this._input.peek(1);
7091 //if we're in a comment, do something special
7092 // We treat all comments as literals, even more than preformatted tags
7093 // we just look for the appropriate close tag
7094 if (c === '<' && (peek1 === '!' || peek1 === '?')) {
7095 resulting_string = this.__patterns.comment.read();
7096
7097 // only process directive on html comments
7098 if (resulting_string) {
7099 directives = directives_core$2.get_directives(resulting_string);
7100 if (directives && directives.ignore === 'start') {
7101 resulting_string += directives_core$2.readIgnored(this._input);
7102 }
7103 } else {
7104 resulting_string = this.__patterns.cdata.read();
7105 resulting_string = resulting_string || this.__patterns.conditional_comment.read();
7106 resulting_string = resulting_string || this.__patterns.processing.read();
7107 }
7108 }
7109
7110 if (resulting_string) {
7111 token = this._create_token(TOKEN$3.COMMENT, resulting_string);
7112 token.directives = directives;
7113 }
7114 }
7115
7116 return token;
7117};
7118
7119Tokenizer$3.prototype._read_open = function(c, open_token) {
7120 var resulting_string = null;
7121 var token = null;
7122 if (!open_token) {
7123 if (c === '<') {
7124
7125 resulting_string = this._input.next();
7126 if (this._input.peek() === '/') {
7127 resulting_string += this._input.next();
7128 }
7129 resulting_string += this.__patterns.element_name.read();
7130 token = this._create_token(TOKEN$3.TAG_OPEN, resulting_string);
7131 }
7132 }
7133 return token;
7134};
7135
7136Tokenizer$3.prototype._read_open_handlebars = function(c, open_token) {
7137 var resulting_string = null;
7138 var token = null;
7139 if (!open_token) {
7140 if (this._options.indent_handlebars && c === '{' && this._input.peek(1) === '{') {
7141 if (this._input.peek(2) === '!') {
7142 resulting_string = this.__patterns.handlebars_comment.read();
7143 resulting_string = resulting_string || this.__patterns.handlebars.read();
7144 token = this._create_token(TOKEN$3.COMMENT, resulting_string);
7145 } else {
7146 resulting_string = this.__patterns.handlebars_open.read();
7147 token = this._create_token(TOKEN$3.TAG_OPEN, resulting_string);
7148 }
7149 }
7150 }
7151 return token;
7152};
7153
7154
7155Tokenizer$3.prototype._read_close = function(c, open_token) {
7156 var resulting_string = null;
7157 var token = null;
7158 if (open_token) {
7159 if (open_token.text[0] === '<' && (c === '>' || (c === '/' && this._input.peek(1) === '>'))) {
7160 resulting_string = this._input.next();
7161 if (c === '/') { // for close tag "/>"
7162 resulting_string += this._input.next();
7163 }
7164 token = this._create_token(TOKEN$3.TAG_CLOSE, resulting_string);
7165 } else if (open_token.text[0] === '{' && c === '}' && this._input.peek(1) === '}') {
7166 this._input.next();
7167 this._input.next();
7168 token = this._create_token(TOKEN$3.TAG_CLOSE, '}}');
7169 }
7170 }
7171
7172 return token;
7173};
7174
7175Tokenizer$3.prototype._read_attribute = function(c, previous_token, open_token) {
7176 var token = null;
7177 var resulting_string = '';
7178 if (open_token && open_token.text[0] === '<') {
7179
7180 if (c === '=') {
7181 token = this._create_token(TOKEN$3.EQUALS, this._input.next());
7182 } else if (c === '"' || c === "'") {
7183 var content = this._input.next();
7184 if (c === '"') {
7185 content += this.__patterns.double_quote.read();
7186 } else {
7187 content += this.__patterns.single_quote.read();
7188 }
7189 token = this._create_token(TOKEN$3.VALUE, content);
7190 } else {
7191 resulting_string = this.__patterns.attribute.read();
7192
7193 if (resulting_string) {
7194 if (previous_token.type === TOKEN$3.EQUALS) {
7195 token = this._create_token(TOKEN$3.VALUE, resulting_string);
7196 } else {
7197 token = this._create_token(TOKEN$3.ATTRIBUTE, resulting_string);
7198 }
7199 }
7200 }
7201 }
7202 return token;
7203};
7204
7205Tokenizer$3.prototype._is_content_unformatted = function(tag_name) {
7206 // void_elements have no content and so cannot have unformatted content
7207 // script and style tags should always be read as unformatted content
7208 // finally content_unformatted and unformatted element contents are unformatted
7209 return this._options.void_elements.indexOf(tag_name) === -1 &&
7210 (this._options.content_unformatted.indexOf(tag_name) !== -1 ||
7211 this._options.unformatted.indexOf(tag_name) !== -1);
7212};
7213
7214
7215Tokenizer$3.prototype._read_raw_content = function(c, previous_token, open_token) { // jshint unused:false
7216 var resulting_string = '';
7217 if (open_token && open_token.text[0] === '{') {
7218 resulting_string = this.__patterns.handlebars_raw_close.read();
7219 } else if (previous_token.type === TOKEN$3.TAG_CLOSE && (previous_token.opened.text[0] === '<')) {
7220 var tag_name = previous_token.opened.text.substr(1).toLowerCase();
7221 if (tag_name === 'script' || tag_name === 'style') {
7222 // Script and style tags are allowed to have comments wrapping their content
7223 // or just have regular content.
7224 var token = this._read_comment(c);
7225 if (token) {
7226 token.type = TOKEN$3.TEXT;
7227 return token;
7228 }
7229 resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
7230 } else if (this._is_content_unformatted(tag_name)) {
7231 resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
7232 }
7233 }
7234
7235 if (resulting_string) {
7236 return this._create_token(TOKEN$3.TEXT, resulting_string);
7237 }
7238
7239 return null;
7240};
7241
7242Tokenizer$3.prototype._read_content_word = function(c) {
7243 var resulting_string = '';
7244 if (this._options.unformatted_content_delimiter) {
7245 if (c === this._options.unformatted_content_delimiter[0]) {
7246 resulting_string = this.__patterns.unformatted_content_delimiter.read();
7247 }
7248 }
7249
7250 if (!resulting_string) {
7251 resulting_string = this.__patterns.word.read();
7252 }
7253 if (resulting_string) {
7254 return this._create_token(TOKEN$3.TEXT, resulting_string);
7255 }
7256};
7257
7258var Tokenizer_1$2 = Tokenizer$3;
7259var TOKEN_1$2 = TOKEN$3;
7260
7261var tokenizer$2 = {
7262 Tokenizer: Tokenizer_1$2,
7263 TOKEN: TOKEN_1$2
7264};
7265
7266var Options$8 = options$3.Options;
7267var Output$3 = output.Output;
7268var Tokenizer$4 = tokenizer$2.Tokenizer;
7269var TOKEN$4 = tokenizer$2.TOKEN;
7270
7271var lineBreak$1 = /\r\n|[\r\n]/;
7272var allLineBreaks$1 = /\r\n|[\r\n]/g;
7273
7274var Printer = function(options, base_indent_string) { //handles input/output and some other printing functions
7275
7276 this.indent_level = 0;
7277 this.alignment_size = 0;
7278 this.max_preserve_newlines = options.max_preserve_newlines;
7279 this.preserve_newlines = options.preserve_newlines;
7280
7281 this._output = new Output$3(options, base_indent_string);
7282
7283};
7284
7285Printer.prototype.current_line_has_match = function(pattern) {
7286 return this._output.current_line.has_match(pattern);
7287};
7288
7289Printer.prototype.set_space_before_token = function(value, non_breaking) {
7290 this._output.space_before_token = value;
7291 this._output.non_breaking_space = non_breaking;
7292};
7293
7294Printer.prototype.set_wrap_point = function() {
7295 this._output.set_indent(this.indent_level, this.alignment_size);
7296 this._output.set_wrap_point();
7297};
7298
7299
7300Printer.prototype.add_raw_token = function(token) {
7301 this._output.add_raw_token(token);
7302};
7303
7304Printer.prototype.print_preserved_newlines = function(raw_token) {
7305 var newlines = 0;
7306 if (raw_token.type !== TOKEN$4.TEXT && raw_token.previous.type !== TOKEN$4.TEXT) {
7307 newlines = raw_token.newlines ? 1 : 0;
7308 }
7309
7310 if (this.preserve_newlines) {
7311 newlines = raw_token.newlines < this.max_preserve_newlines + 1 ? raw_token.newlines : this.max_preserve_newlines + 1;
7312 }
7313 for (var n = 0; n < newlines; n++) {
7314 this.print_newline(n > 0);
7315 }
7316
7317 return newlines !== 0;
7318};
7319
7320Printer.prototype.traverse_whitespace = function(raw_token) {
7321 if (raw_token.whitespace_before || raw_token.newlines) {
7322 if (!this.print_preserved_newlines(raw_token)) {
7323 this._output.space_before_token = true;
7324 }
7325 return true;
7326 }
7327 return false;
7328};
7329
7330Printer.prototype.previous_token_wrapped = function() {
7331 return this._output.previous_token_wrapped;
7332};
7333
7334Printer.prototype.print_newline = function(force) {
7335 this._output.add_new_line(force);
7336};
7337
7338Printer.prototype.print_token = function(token) {
7339 if (token.text) {
7340 this._output.set_indent(this.indent_level, this.alignment_size);
7341 this._output.add_token(token.text);
7342 }
7343};
7344
7345Printer.prototype.indent = function() {
7346 this.indent_level++;
7347};
7348
7349Printer.prototype.get_full_indent = function(level) {
7350 level = this.indent_level + (level || 0);
7351 if (level < 1) {
7352 return '';
7353 }
7354
7355 return this._output.get_indent_string(level);
7356};
7357
7358var get_type_attribute = function(start_token) {
7359 var result = null;
7360 var raw_token = start_token.next;
7361
7362 // Search attributes for a type attribute
7363 while (raw_token.type !== TOKEN$4.EOF && start_token.closed !== raw_token) {
7364 if (raw_token.type === TOKEN$4.ATTRIBUTE && raw_token.text === 'type') {
7365 if (raw_token.next && raw_token.next.type === TOKEN$4.EQUALS &&
7366 raw_token.next.next && raw_token.next.next.type === TOKEN$4.VALUE) {
7367 result = raw_token.next.next.text;
7368 }
7369 break;
7370 }
7371 raw_token = raw_token.next;
7372 }
7373
7374 return result;
7375};
7376
7377var get_custom_beautifier_name = function(tag_check, raw_token) {
7378 var typeAttribute = null;
7379 var result = null;
7380
7381 if (!raw_token.closed) {
7382 return null;
7383 }
7384
7385 if (tag_check === 'script') {
7386 typeAttribute = 'text/javascript';
7387 } else if (tag_check === 'style') {
7388 typeAttribute = 'text/css';
7389 }
7390
7391 typeAttribute = get_type_attribute(raw_token) || typeAttribute;
7392
7393 // For script and style tags that have a type attribute, only enable custom beautifiers for matching values
7394 // For those without a type attribute use default;
7395 if (typeAttribute.search('text/css') > -1) {
7396 result = 'css';
7397 } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect)/) > -1) {
7398 result = 'javascript';
7399 } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
7400 result = 'html';
7401 } else if (typeAttribute.search(/test\/null/) > -1) {
7402 // Test only mime-type for testing the beautifier when null is passed as beautifing function
7403 result = 'null';
7404 }
7405
7406 return result;
7407};
7408
7409function in_array$2(what, arr) {
7410 return arr.indexOf(what) !== -1;
7411}
7412
7413function TagFrame(parent, parser_token, indent_level) {
7414 this.parent = parent || null;
7415 this.tag = parser_token ? parser_token.tag_name : '';
7416 this.indent_level = indent_level || 0;
7417 this.parser_token = parser_token || null;
7418}
7419
7420function TagStack(printer) {
7421 this._printer = printer;
7422 this._current_frame = null;
7423}
7424
7425TagStack.prototype.get_parser_token = function() {
7426 return this._current_frame ? this._current_frame.parser_token : null;
7427};
7428
7429TagStack.prototype.record_tag = function(parser_token) { //function to record a tag and its parent in this.tags Object
7430 var new_frame = new TagFrame(this._current_frame, parser_token, this._printer.indent_level);
7431 this._current_frame = new_frame;
7432};
7433
7434TagStack.prototype._try_pop_frame = function(frame) { //function to retrieve the opening tag to the corresponding closer
7435 var parser_token = null;
7436
7437 if (frame) {
7438 parser_token = frame.parser_token;
7439 this._printer.indent_level = frame.indent_level;
7440 this._current_frame = frame.parent;
7441 }
7442
7443 return parser_token;
7444};
7445
7446TagStack.prototype._get_frame = function(tag_list, stop_list) { //function to retrieve the opening tag to the corresponding closer
7447 var frame = this._current_frame;
7448
7449 while (frame) { //till we reach '' (the initial value);
7450 if (tag_list.indexOf(frame.tag) !== -1) { //if this is it use it
7451 break;
7452 } else if (stop_list && stop_list.indexOf(frame.tag) !== -1) {
7453 frame = null;
7454 break;
7455 }
7456 frame = frame.parent;
7457 }
7458
7459 return frame;
7460};
7461
7462TagStack.prototype.try_pop = function(tag, stop_list) { //function to retrieve the opening tag to the corresponding closer
7463 var frame = this._get_frame([tag], stop_list);
7464 return this._try_pop_frame(frame);
7465};
7466
7467TagStack.prototype.indent_to_tag = function(tag_list) {
7468 var frame = this._get_frame(tag_list);
7469 if (frame) {
7470 this._printer.indent_level = frame.indent_level;
7471 }
7472};
7473
7474function Beautifier$4(source_text, options, js_beautify, css_beautify) {
7475 //Wrapper function to invoke all the necessary constructors and deal with the output.
7476 this._source_text = source_text || '';
7477 options = options || {};
7478 this._js_beautify = js_beautify;
7479 this._css_beautify = css_beautify;
7480 this._tag_stack = null;
7481
7482 // Allow the setting of language/file-type specific options
7483 // with inheritance of overall settings
7484 var optionHtml = new Options$8(options, 'html');
7485
7486 this._options = optionHtml;
7487
7488 this._is_wrap_attributes_force = this._options.wrap_attributes.substr(0, 'force'.length) === 'force';
7489 this._is_wrap_attributes_force_expand_multiline = (this._options.wrap_attributes === 'force-expand-multiline');
7490 this._is_wrap_attributes_force_aligned = (this._options.wrap_attributes === 'force-aligned');
7491 this._is_wrap_attributes_aligned_multiple = (this._options.wrap_attributes === 'aligned-multiple');
7492 this._is_wrap_attributes_preserve = this._options.wrap_attributes.substr(0, 'preserve'.length) === 'preserve';
7493 this._is_wrap_attributes_preserve_aligned = (this._options.wrap_attributes === 'preserve-aligned');
7494}
7495
7496Beautifier$4.prototype.beautify = function() {
7497
7498 // if disabled, return the input unchanged.
7499 if (this._options.disabled) {
7500 return this._source_text;
7501 }
7502
7503 var source_text = this._source_text;
7504 var eol = this._options.eol;
7505 if (this._options.eol === 'auto') {
7506 eol = '\n';
7507 if (source_text && lineBreak$1.test(source_text)) {
7508 eol = source_text.match(lineBreak$1)[0];
7509 }
7510 }
7511
7512 // HACK: newline parsing inconsistent. This brute force normalizes the input.
7513 source_text = source_text.replace(allLineBreaks$1, '\n');
7514
7515 var baseIndentString = source_text.match(/^[\t ]*/)[0];
7516
7517 var last_token = {
7518 text: '',
7519 type: ''
7520 };
7521
7522 var last_tag_token = new TagOpenParserToken();
7523
7524 var printer = new Printer(this._options, baseIndentString);
7525 var tokens = new Tokenizer$4(source_text, this._options).tokenize();
7526
7527 this._tag_stack = new TagStack(printer);
7528
7529 var parser_token = null;
7530 var raw_token = tokens.next();
7531 while (raw_token.type !== TOKEN$4.EOF) {
7532
7533 if (raw_token.type === TOKEN$4.TAG_OPEN || raw_token.type === TOKEN$4.COMMENT) {
7534 parser_token = this._handle_tag_open(printer, raw_token, last_tag_token, last_token);
7535 last_tag_token = parser_token;
7536 } else if ((raw_token.type === TOKEN$4.ATTRIBUTE || raw_token.type === TOKEN$4.EQUALS || raw_token.type === TOKEN$4.VALUE) ||
7537 (raw_token.type === TOKEN$4.TEXT && !last_tag_token.tag_complete)) {
7538 parser_token = this._handle_inside_tag(printer, raw_token, last_tag_token, tokens);
7539 } else if (raw_token.type === TOKEN$4.TAG_CLOSE) {
7540 parser_token = this._handle_tag_close(printer, raw_token, last_tag_token);
7541 } else if (raw_token.type === TOKEN$4.TEXT) {
7542 parser_token = this._handle_text(printer, raw_token, last_tag_token);
7543 } else {
7544 // This should never happen, but if it does. Print the raw token
7545 printer.add_raw_token(raw_token);
7546 }
7547
7548 last_token = parser_token;
7549
7550 raw_token = tokens.next();
7551 }
7552 var sweet_code = printer._output.get_code(eol);
7553
7554 return sweet_code;
7555};
7556
7557Beautifier$4.prototype._handle_tag_close = function(printer, raw_token, last_tag_token) {
7558 var parser_token = {
7559 text: raw_token.text,
7560 type: raw_token.type
7561 };
7562 printer.alignment_size = 0;
7563 last_tag_token.tag_complete = true;
7564
7565 printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
7566 if (last_tag_token.is_unformatted) {
7567 printer.add_raw_token(raw_token);
7568 } else {
7569 if (last_tag_token.tag_start_char === '<') {
7570 printer.set_space_before_token(raw_token.text[0] === '/', true); // space before />, no space before >
7571 if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) {
7572 printer.print_newline(false);
7573 }
7574 }
7575 printer.print_token(raw_token);
7576
7577 }
7578
7579 if (last_tag_token.indent_content &&
7580 !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
7581 printer.indent();
7582
7583 // only indent once per opened tag
7584 last_tag_token.indent_content = false;
7585 }
7586
7587 if (!last_tag_token.is_inline_element &&
7588 !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
7589 printer.set_wrap_point();
7590 }
7591
7592 return parser_token;
7593};
7594
7595Beautifier$4.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, tokens) {
7596 var wrapped = last_tag_token.has_wrapped_attrs;
7597 var parser_token = {
7598 text: raw_token.text,
7599 type: raw_token.type
7600 };
7601
7602 printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
7603 if (last_tag_token.is_unformatted) {
7604 printer.add_raw_token(raw_token);
7605 } else if (last_tag_token.tag_start_char === '{' && raw_token.type === TOKEN$4.TEXT) {
7606 // For the insides of handlebars allow newlines or a single space between open and contents
7607 if (printer.print_preserved_newlines(raw_token)) {
7608 raw_token.newlines = 0;
7609 printer.add_raw_token(raw_token);
7610 } else {
7611 printer.print_token(raw_token);
7612 }
7613 } else {
7614 if (raw_token.type === TOKEN$4.ATTRIBUTE) {
7615 printer.set_space_before_token(true);
7616 last_tag_token.attr_count += 1;
7617 } else if (raw_token.type === TOKEN$4.EQUALS) { //no space before =
7618 printer.set_space_before_token(false);
7619 } else if (raw_token.type === TOKEN$4.VALUE && raw_token.previous.type === TOKEN$4.EQUALS) { //no space before value
7620 printer.set_space_before_token(false);
7621 }
7622
7623 if (raw_token.type === TOKEN$4.ATTRIBUTE && last_tag_token.tag_start_char === '<') {
7624 if (this._is_wrap_attributes_preserve || this._is_wrap_attributes_preserve_aligned) {
7625 printer.traverse_whitespace(raw_token);
7626 wrapped = wrapped || raw_token.newlines !== 0;
7627 }
7628
7629
7630 if (this._is_wrap_attributes_force) {
7631 var force_attr_wrap = last_tag_token.attr_count > 1;
7632 if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.attr_count === 1) {
7633 var is_only_attribute = true;
7634 var peek_index = 0;
7635 var peek_token;
7636 do {
7637 peek_token = tokens.peek(peek_index);
7638 if (peek_token.type === TOKEN$4.ATTRIBUTE) {
7639 is_only_attribute = false;
7640 break;
7641 }
7642 peek_index += 1;
7643 } while (peek_index < 4 && peek_token.type !== TOKEN$4.EOF && peek_token.type !== TOKEN$4.TAG_CLOSE);
7644
7645 force_attr_wrap = !is_only_attribute;
7646 }
7647
7648 if (force_attr_wrap) {
7649 printer.print_newline(false);
7650 wrapped = true;
7651 }
7652 }
7653 }
7654 printer.print_token(raw_token);
7655 wrapped = wrapped || printer.previous_token_wrapped();
7656 last_tag_token.has_wrapped_attrs = wrapped;
7657 }
7658 return parser_token;
7659};
7660
7661Beautifier$4.prototype._handle_text = function(printer, raw_token, last_tag_token) {
7662 var parser_token = {
7663 text: raw_token.text,
7664 type: 'TK_CONTENT'
7665 };
7666 if (last_tag_token.custom_beautifier_name) { //check if we need to format javascript
7667 this._print_custom_beatifier_text(printer, raw_token, last_tag_token);
7668 } else if (last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) {
7669 printer.add_raw_token(raw_token);
7670 } else {
7671 printer.traverse_whitespace(raw_token);
7672 printer.print_token(raw_token);
7673 }
7674 return parser_token;
7675};
7676
7677Beautifier$4.prototype._print_custom_beatifier_text = function(printer, raw_token, last_tag_token) {
7678 var local = this;
7679 if (raw_token.text !== '') {
7680
7681 var text = raw_token.text,
7682 _beautifier,
7683 script_indent_level = 1,
7684 pre = '',
7685 post = '';
7686 if (last_tag_token.custom_beautifier_name === 'javascript' && typeof this._js_beautify === 'function') {
7687 _beautifier = this._js_beautify;
7688 } else if (last_tag_token.custom_beautifier_name === 'css' && typeof this._css_beautify === 'function') {
7689 _beautifier = this._css_beautify;
7690 } else if (last_tag_token.custom_beautifier_name === 'html') {
7691 _beautifier = function(html_source, options) {
7692 var beautifier = new Beautifier$4(html_source, options, local._js_beautify, local._css_beautify);
7693 return beautifier.beautify();
7694 };
7695 }
7696
7697 if (this._options.indent_scripts === "keep") {
7698 script_indent_level = 0;
7699 } else if (this._options.indent_scripts === "separate") {
7700 script_indent_level = -printer.indent_level;
7701 }
7702
7703 var indentation = printer.get_full_indent(script_indent_level);
7704
7705 // if there is at least one empty line at the end of this text, strip it
7706 // we'll be adding one back after the text but before the containing tag.
7707 text = text.replace(/\n[ \t]*$/, '');
7708
7709 // Handle the case where content is wrapped in a comment or cdata.
7710 if (last_tag_token.custom_beautifier_name !== 'html' &&
7711 text[0] === '<' && text.match(/^(<!--|<!\[CDATA\[)/)) {
7712 var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(text);
7713
7714 // if we start to wrap but don't finish, print raw
7715 if (!matched) {
7716 printer.add_raw_token(raw_token);
7717 return;
7718 }
7719
7720 pre = indentation + matched[1] + '\n';
7721 text = matched[4];
7722 if (matched[5]) {
7723 post = indentation + matched[5];
7724 }
7725
7726 // if there is at least one empty line at the end of this text, strip it
7727 // we'll be adding one back after the text but before the containing tag.
7728 text = text.replace(/\n[ \t]*$/, '');
7729
7730 if (matched[2] || matched[3].indexOf('\n') !== -1) {
7731 // if the first line of the non-comment text has spaces
7732 // use that as the basis for indenting in null case.
7733 matched = matched[3].match(/[ \t]+$/);
7734 if (matched) {
7735 raw_token.whitespace_before = matched[0];
7736 }
7737 }
7738 }
7739
7740 if (text) {
7741 if (_beautifier) {
7742
7743 // call the Beautifier if avaliable
7744 var Child_options = function() {
7745 this.eol = '\n';
7746 };
7747 Child_options.prototype = this._options.raw_options;
7748 var child_options = new Child_options();
7749 text = _beautifier(indentation + text, child_options);
7750 } else {
7751 // simply indent the string otherwise
7752 var white = raw_token.whitespace_before;
7753 if (white) {
7754 text = text.replace(new RegExp('\n(' + white + ')?', 'g'), '\n');
7755 }
7756
7757 text = indentation + text.replace(/\n/g, '\n' + indentation);
7758 }
7759 }
7760
7761 if (pre) {
7762 if (!text) {
7763 text = pre + post;
7764 } else {
7765 text = pre + text + '\n' + post;
7766 }
7767 }
7768
7769 printer.print_newline(false);
7770 if (text) {
7771 raw_token.text = text;
7772 raw_token.whitespace_before = '';
7773 raw_token.newlines = 0;
7774 printer.add_raw_token(raw_token);
7775 printer.print_newline(true);
7776 }
7777 }
7778};
7779
7780Beautifier$4.prototype._handle_tag_open = function(printer, raw_token, last_tag_token, last_token) {
7781 var parser_token = this._get_tag_open_token(raw_token);
7782
7783 if ((last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) &&
7784 raw_token.type === TOKEN$4.TAG_OPEN && raw_token.text.indexOf('</') === 0) {
7785 // End element tags for unformatted or content_unformatted elements
7786 // are printed raw to keep any newlines inside them exactly the same.
7787 printer.add_raw_token(raw_token);
7788 } else {
7789 printer.traverse_whitespace(raw_token);
7790 this._set_tag_position(printer, raw_token, parser_token, last_tag_token, last_token);
7791 if (!parser_token.is_inline_element) {
7792 printer.set_wrap_point();
7793 }
7794 printer.print_token(raw_token);
7795 }
7796
7797 //indent attributes an auto, forced, aligned or forced-align line-wrap
7798 if (this._is_wrap_attributes_force_aligned || this._is_wrap_attributes_aligned_multiple || this._is_wrap_attributes_preserve_aligned) {
7799 parser_token.alignment_size = raw_token.text.length + 1;
7800 }
7801
7802 if (!parser_token.tag_complete && !parser_token.is_unformatted) {
7803 printer.alignment_size = parser_token.alignment_size;
7804 }
7805
7806 return parser_token;
7807};
7808
7809var TagOpenParserToken = function(parent, raw_token) {
7810 this.parent = parent || null;
7811 this.text = '';
7812 this.type = 'TK_TAG_OPEN';
7813 this.tag_name = '';
7814 this.is_inline_element = false;
7815 this.is_unformatted = false;
7816 this.is_content_unformatted = false;
7817 this.is_empty_element = false;
7818 this.is_start_tag = false;
7819 this.is_end_tag = false;
7820 this.indent_content = false;
7821 this.multiline_content = false;
7822 this.custom_beautifier_name = null;
7823 this.start_tag_token = null;
7824 this.attr_count = 0;
7825 this.has_wrapped_attrs = false;
7826 this.alignment_size = 0;
7827 this.tag_complete = false;
7828 this.tag_start_char = '';
7829 this.tag_check = '';
7830
7831 if (!raw_token) {
7832 this.tag_complete = true;
7833 } else {
7834 var tag_check_match;
7835
7836 this.tag_start_char = raw_token.text[0];
7837 this.text = raw_token.text;
7838
7839 if (this.tag_start_char === '<') {
7840 tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
7841 this.tag_check = tag_check_match ? tag_check_match[1] : '';
7842 } else {
7843 tag_check_match = raw_token.text.match(/^{{[#\^]?([^\s}]+)/);
7844 this.tag_check = tag_check_match ? tag_check_match[1] : '';
7845 }
7846 this.tag_check = this.tag_check.toLowerCase();
7847
7848 if (raw_token.type === TOKEN$4.COMMENT) {
7849 this.tag_complete = true;
7850 }
7851
7852 this.is_start_tag = this.tag_check.charAt(0) !== '/';
7853 this.tag_name = !this.is_start_tag ? this.tag_check.substr(1) : this.tag_check;
7854 this.is_end_tag = !this.is_start_tag ||
7855 (raw_token.closed && raw_token.closed.text === '/>');
7856
7857 // handlebars tags that don't start with # or ^ are single_tags, and so also start and end.
7858 this.is_end_tag = this.is_end_tag ||
7859 (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(2)))));
7860 }
7861};
7862
7863Beautifier$4.prototype._get_tag_open_token = function(raw_token) { //function to get a full tag and parse its type
7864 var parser_token = new TagOpenParserToken(this._tag_stack.get_parser_token(), raw_token);
7865
7866 parser_token.alignment_size = this._options.wrap_attributes_indent_size;
7867
7868 parser_token.is_end_tag = parser_token.is_end_tag ||
7869 in_array$2(parser_token.tag_check, this._options.void_elements);
7870
7871 parser_token.is_empty_element = parser_token.tag_complete ||
7872 (parser_token.is_start_tag && parser_token.is_end_tag);
7873
7874 parser_token.is_unformatted = !parser_token.tag_complete && in_array$2(parser_token.tag_check, this._options.unformatted);
7875 parser_token.is_content_unformatted = !parser_token.is_empty_element && in_array$2(parser_token.tag_check, this._options.content_unformatted);
7876 parser_token.is_inline_element = in_array$2(parser_token.tag_name, this._options.inline) || parser_token.tag_start_char === '{';
7877
7878 return parser_token;
7879};
7880
7881Beautifier$4.prototype._set_tag_position = function(printer, raw_token, parser_token, last_tag_token, last_token) {
7882
7883 if (!parser_token.is_empty_element) {
7884 if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
7885 parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name); //remove it and all ancestors
7886 } else { // it's a start-tag
7887 // check if this tag is starting an element that has optional end element
7888 // and do an ending needed
7889 if (this._do_optional_end_element(parser_token)) {
7890 if (!parser_token.is_inline_element) {
7891 if (parser_token.parent) {
7892 parser_token.parent.multiline_content = true;
7893 }
7894 printer.print_newline(false);
7895 }
7896
7897 }
7898
7899 this._tag_stack.record_tag(parser_token); //push it on the tag stack
7900
7901 if ((parser_token.tag_name === 'script' || parser_token.tag_name === 'style') &&
7902 !(parser_token.is_unformatted || parser_token.is_content_unformatted)) {
7903 parser_token.custom_beautifier_name = get_custom_beautifier_name(parser_token.tag_check, raw_token);
7904 }
7905 }
7906 }
7907
7908 if (in_array$2(parser_token.tag_check, this._options.extra_liners)) { //check if this double needs an extra line
7909 printer.print_newline(false);
7910 if (!printer._output.just_added_blankline()) {
7911 printer.print_newline(true);
7912 }
7913 }
7914
7915 if (parser_token.is_empty_element) { //if this tag name is a single tag type (either in the list or has a closing /)
7916
7917 // if you hit an else case, reset the indent level if you are inside an:
7918 // 'if', 'unless', or 'each' block.
7919 if (parser_token.tag_start_char === '{' && parser_token.tag_check === 'else') {
7920 this._tag_stack.indent_to_tag(['if', 'unless', 'each']);
7921 parser_token.indent_content = true;
7922 // Don't add a newline if opening {{#if}} tag is on the current line
7923 var foundIfOnCurrentLine = printer.current_line_has_match(/{{#if/);
7924 if (!foundIfOnCurrentLine) {
7925 printer.print_newline(false);
7926 }
7927 }
7928
7929 // Don't add a newline before elements that should remain where they are.
7930 if (parser_token.tag_name === '!--' && last_token.type === TOKEN$4.TAG_CLOSE &&
7931 last_tag_token.is_end_tag && parser_token.text.indexOf('\n') === -1) ; else if (!parser_token.is_inline_element && !parser_token.is_unformatted) {
7932 printer.print_newline(false);
7933 }
7934 } else if (parser_token.is_unformatted || parser_token.is_content_unformatted) {
7935 if (!parser_token.is_inline_element && !parser_token.is_unformatted) {
7936 printer.print_newline(false);
7937 }
7938 } else if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
7939 if ((parser_token.start_tag_token && parser_token.start_tag_token.multiline_content) ||
7940 !(parser_token.is_inline_element ||
7941 (last_tag_token.is_inline_element) ||
7942 (last_token.type === TOKEN$4.TAG_CLOSE &&
7943 parser_token.start_tag_token === last_tag_token) ||
7944 (last_token.type === 'TK_CONTENT')
7945 )) {
7946 printer.print_newline(false);
7947 }
7948 } else { // it's a start-tag
7949 parser_token.indent_content = !parser_token.custom_beautifier_name;
7950
7951 if (parser_token.tag_start_char === '<') {
7952 if (parser_token.tag_name === 'html') {
7953 parser_token.indent_content = this._options.indent_inner_html;
7954 } else if (parser_token.tag_name === 'head') {
7955 parser_token.indent_content = this._options.indent_head_inner_html;
7956 } else if (parser_token.tag_name === 'body') {
7957 parser_token.indent_content = this._options.indent_body_inner_html;
7958 }
7959 }
7960
7961 if (!parser_token.is_inline_element && last_token.type !== 'TK_CONTENT') {
7962 if (parser_token.parent) {
7963 parser_token.parent.multiline_content = true;
7964 }
7965 printer.print_newline(false);
7966 }
7967 }
7968};
7969
7970//To be used for <p> tag special case:
7971//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'];
7972
7973Beautifier$4.prototype._do_optional_end_element = function(parser_token) {
7974 var result = null;
7975 // NOTE: cases of "if there is no more content in the parent element"
7976 // are handled automatically by the beautifier.
7977 // It assumes parent or ancestor close tag closes all children.
7978 // https://www.w3.org/TR/html5/syntax.html#optional-tags
7979 if (parser_token.is_empty_element || !parser_token.is_start_tag || !parser_token.parent) {
7980 return;
7981
7982 } else if (parser_token.tag_name === 'body') {
7983 // A head element’s end tag may be omitted if the head element is not immediately followed by a space character or a comment.
7984 result = result || this._tag_stack.try_pop('head');
7985
7986 //} else if (parser_token.tag_name === 'body') {
7987 // DONE: A body element’s end tag may be omitted if the body element is not immediately followed by a comment.
7988
7989 } else if (parser_token.tag_name === 'li') {
7990 // 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.
7991 result = result || this._tag_stack.try_pop('li', ['ol', 'ul']);
7992
7993 } else if (parser_token.tag_name === 'dd' || parser_token.tag_name === 'dt') {
7994 // 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.
7995 // A dt element’s end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
7996 result = result || this._tag_stack.try_pop('dt', ['dl']);
7997 result = result || this._tag_stack.try_pop('dd', ['dl']);
7998
7999 //} else if (p_closers.indexOf(parser_token.tag_name) !== -1) {
8000 //TODO: THIS IS A BUG FARM. We are not putting this into 1.8.0 as it is likely to blow up.
8001 //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.
8002 //result = result || this._tag_stack.try_pop('p', ['body']);
8003
8004 } else if (parser_token.tag_name === 'rp' || parser_token.tag_name === 'rt') {
8005 // 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.
8006 // 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.
8007 result = result || this._tag_stack.try_pop('rt', ['ruby', 'rtc']);
8008 result = result || this._tag_stack.try_pop('rp', ['ruby', 'rtc']);
8009
8010 } else if (parser_token.tag_name === 'optgroup') {
8011 // 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.
8012 // 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.
8013 result = result || this._tag_stack.try_pop('optgroup', ['select']);
8014 //result = result || this._tag_stack.try_pop('option', ['select']);
8015
8016 } else if (parser_token.tag_name === 'option') {
8017 // 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.
8018 result = result || this._tag_stack.try_pop('option', ['select', 'datalist', 'optgroup']);
8019
8020 } else if (parser_token.tag_name === 'colgroup') {
8021 // 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.
8022 // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8023 result = result || this._tag_stack.try_pop('caption', ['table']);
8024
8025 } else if (parser_token.tag_name === 'thead') {
8026 // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
8027 // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8028 result = result || this._tag_stack.try_pop('caption', ['table']);
8029 result = result || this._tag_stack.try_pop('colgroup', ['table']);
8030
8031 //} else if (parser_token.tag_name === 'caption') {
8032 // 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.
8033
8034 } else if (parser_token.tag_name === 'tbody' || parser_token.tag_name === 'tfoot') {
8035 // A thead element’s end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
8036 // 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.
8037 // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
8038 // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8039 result = result || this._tag_stack.try_pop('caption', ['table']);
8040 result = result || this._tag_stack.try_pop('colgroup', ['table']);
8041 result = result || this._tag_stack.try_pop('thead', ['table']);
8042 result = result || this._tag_stack.try_pop('tbody', ['table']);
8043
8044 //} else if (parser_token.tag_name === 'tfoot') {
8045 // DONE: A tfoot element’s end tag may be omitted if there is no more content in the parent element.
8046
8047 } else if (parser_token.tag_name === 'tr') {
8048 // 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.
8049 // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
8050 // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8051 result = result || this._tag_stack.try_pop('caption', ['table']);
8052 result = result || this._tag_stack.try_pop('colgroup', ['table']);
8053 result = result || this._tag_stack.try_pop('tr', ['table', 'thead', 'tbody', 'tfoot']);
8054
8055 } else if (parser_token.tag_name === 'th' || parser_token.tag_name === 'td') {
8056 // 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.
8057 // 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.
8058 result = result || this._tag_stack.try_pop('td', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
8059 result = result || this._tag_stack.try_pop('th', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
8060 }
8061
8062 // Start element omission not handled currently
8063 // 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.
8064 // 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.)
8065 // 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.)
8066
8067 // Fix up the parent of the parser token
8068 parser_token.parent = this._tag_stack.get_parser_token();
8069
8070 return result;
8071};
8072
8073var Beautifier_1$2 = Beautifier$4;
8074
8075var beautifier$2 = {
8076 Beautifier: Beautifier_1$2
8077};
8078
8079var Beautifier$5 = beautifier$2.Beautifier,
8080 Options$9 = options$3.Options;
8081
8082function style_html(html_source, options, js_beautify, css_beautify) {
8083 var beautifier = new Beautifier$5(html_source, options, js_beautify, css_beautify);
8084 return beautifier.beautify();
8085}
8086
8087var html = style_html;
8088var defaultOptions$2 = function() {
8089 return new Options$9();
8090};
8091html.defaultOptions = defaultOptions$2;
8092
8093function style_html$1(html_source, options, js, css$1) {
8094 js = js || javascript;
8095 css$1 = css$1 || css;
8096 return html(html_source, options, js, css$1);
8097}
8098style_html$1.defaultOptions = html.defaultOptions;
8099
8100var js = javascript;
8101var css$1 = css;
8102var html$1 = style_html$1;
8103
8104var src = {
8105 js: js,
8106 css: css$1,
8107 html: html$1
8108};
8109
8110var js$1 = createCommonjsModule(function (module) {
8111
8112/**
8113The following batches are equivalent:
8114
8115var beautify_js = require('js-beautify');
8116var beautify_js = require('js-beautify').js;
8117var beautify_js = require('js-beautify').js_beautify;
8118
8119var beautify_css = require('js-beautify').css;
8120var beautify_css = require('js-beautify').css_beautify;
8121
8122var beautify_html = require('js-beautify').html;
8123var beautify_html = require('js-beautify').html_beautify;
8124
8125All methods returned accept two arguments, the source string and an options object.
8126**/
8127
8128function get_beautify(js_beautify, css_beautify, html_beautify) {
8129 // the default is js
8130 var beautify = function(src, config) {
8131 return js_beautify.js_beautify(src, config);
8132 };
8133
8134 // short aliases
8135 beautify.js = js_beautify.js_beautify;
8136 beautify.css = css_beautify.css_beautify;
8137 beautify.html = html_beautify.html_beautify;
8138
8139 // legacy aliases
8140 beautify.js_beautify = js_beautify.js_beautify;
8141 beautify.css_beautify = css_beautify.css_beautify;
8142 beautify.html_beautify = html_beautify.html_beautify;
8143
8144 return beautify;
8145}
8146
8147{
8148 (function(mod) {
8149 var beautifier = src;
8150 beautifier.js_beautify = beautifier.js;
8151 beautifier.css_beautify = beautifier.css;
8152 beautifier.html_beautify = beautifier.html;
8153
8154 mod.exports = get_beautify(beautifier, beautifier, beautifier);
8155
8156 })(module);
8157}
8158});
8159
8160/*!
8161 * is-whitespace <https://github.com/jonschlinkert/is-whitespace>
8162 *
8163 * Copyright (c) 2014-2015, Jon Schlinkert.
8164 * Licensed under the MIT License.
8165 */
8166
8167var cache;
8168
8169var isWhitespace = function isWhitespace(str) {
8170 return (typeof str === 'string') && regex().test(str);
8171};
8172
8173function regex() {
8174 // ensure that runtime compilation only happens once
8175 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"]+$'));
8176}
8177
8178/*!
8179 * is-extendable <https://github.com/jonschlinkert/is-extendable>
8180 *
8181 * Copyright (c) 2015, Jon Schlinkert.
8182 * Licensed under the MIT License.
8183 */
8184
8185var isExtendable = function isExtendable(val) {
8186 return typeof val !== 'undefined' && val !== null
8187 && (typeof val === 'object' || typeof val === 'function');
8188};
8189
8190var extendShallow = function extend(o/*, objects*/) {
8191 var arguments$1 = arguments;
8192
8193 if (!isExtendable(o)) { o = {}; }
8194
8195 var len = arguments.length;
8196 for (var i = 1; i < len; i++) {
8197 var obj = arguments$1[i];
8198
8199 if (isExtendable(obj)) {
8200 assign(o, obj);
8201 }
8202 }
8203 return o;
8204};
8205
8206function assign(a, b) {
8207 for (var key in b) {
8208 if (hasOwn(b, key)) {
8209 a[key] = b[key];
8210 }
8211 }
8212}
8213
8214/**
8215 * Returns true if the given `key` is an own property of `obj`.
8216 */
8217
8218function hasOwn(obj, key) {
8219 return Object.prototype.hasOwnProperty.call(obj, key);
8220}
8221
8222/*!
8223 * Determine if an object is a Buffer
8224 *
8225 * @author Feross Aboukhadijeh <https://feross.org>
8226 * @license MIT
8227 */
8228
8229// The _isBuffer check is for Safari 5-7 support, because it's missing
8230// Object.prototype.constructor. Remove this eventually
8231var isBuffer_1 = function (obj) {
8232 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
8233};
8234
8235function isBuffer (obj) {
8236 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
8237}
8238
8239// For Node v0.10 support. Remove this eventually.
8240function isSlowBuffer (obj) {
8241 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
8242}
8243
8244var toString = Object.prototype.toString;
8245
8246/**
8247 * Get the native `typeof` a value.
8248 *
8249 * @param {*} `val`
8250 * @return {*} Native javascript type
8251 */
8252
8253var kindOf = function kindOf(val) {
8254 // primitivies
8255 if (typeof val === 'undefined') {
8256 return 'undefined';
8257 }
8258 if (val === null) {
8259 return 'null';
8260 }
8261 if (val === true || val === false || val instanceof Boolean) {
8262 return 'boolean';
8263 }
8264 if (typeof val === 'string' || val instanceof String) {
8265 return 'string';
8266 }
8267 if (typeof val === 'number' || val instanceof Number) {
8268 return 'number';
8269 }
8270
8271 // functions
8272 if (typeof val === 'function' || val instanceof Function) {
8273 return 'function';
8274 }
8275
8276 // array
8277 if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
8278 return 'array';
8279 }
8280
8281 // check for instances of RegExp and Date before calling `toString`
8282 if (val instanceof RegExp) {
8283 return 'regexp';
8284 }
8285 if (val instanceof Date) {
8286 return 'date';
8287 }
8288
8289 // other objects
8290 var type = toString.call(val);
8291
8292 if (type === '[object RegExp]') {
8293 return 'regexp';
8294 }
8295 if (type === '[object Date]') {
8296 return 'date';
8297 }
8298 if (type === '[object Arguments]') {
8299 return 'arguments';
8300 }
8301 if (type === '[object Error]') {
8302 return 'error';
8303 }
8304
8305 // buffer
8306 if (isBuffer_1(val)) {
8307 return 'buffer';
8308 }
8309
8310 // es6: Map, WeakMap, Set, WeakSet
8311 if (type === '[object Set]') {
8312 return 'set';
8313 }
8314 if (type === '[object WeakSet]') {
8315 return 'weakset';
8316 }
8317 if (type === '[object Map]') {
8318 return 'map';
8319 }
8320 if (type === '[object WeakMap]') {
8321 return 'weakmap';
8322 }
8323 if (type === '[object Symbol]') {
8324 return 'symbol';
8325 }
8326
8327 // typed arrays
8328 if (type === '[object Int8Array]') {
8329 return 'int8array';
8330 }
8331 if (type === '[object Uint8Array]') {
8332 return 'uint8array';
8333 }
8334 if (type === '[object Uint8ClampedArray]') {
8335 return 'uint8clampedarray';
8336 }
8337 if (type === '[object Int16Array]') {
8338 return 'int16array';
8339 }
8340 if (type === '[object Uint16Array]') {
8341 return 'uint16array';
8342 }
8343 if (type === '[object Int32Array]') {
8344 return 'int32array';
8345 }
8346 if (type === '[object Uint32Array]') {
8347 return 'uint32array';
8348 }
8349 if (type === '[object Float32Array]') {
8350 return 'float32array';
8351 }
8352 if (type === '[object Float64Array]') {
8353 return 'float64array';
8354 }
8355
8356 // must be a plain object
8357 return 'object';
8358};
8359
8360var condenseNewlines = function(str, options) {
8361 var opts = extendShallow({}, options);
8362 var sep = opts.sep || '\n\n';
8363 var min = opts.min;
8364 var re;
8365
8366 if (typeof min === 'number' && min !== 2) {
8367 re = new RegExp('(\\r\\n|\\n|\\u2424) {' + min + ',}');
8368 }
8369 if (typeof re === 'undefined') {
8370 re = opts.regex || /(\r\n|\n|\u2424){2,}/g;
8371 }
8372
8373 // if a line is 100% whitespace it will be trimmed, so that
8374 // later we can condense newlines correctly
8375 if (opts.keepWhitespace !== true) {
8376 str = str.split('\n').map(function(line) {
8377 return isWhitespace(line) ? line.trim() : line;
8378 }).join('\n');
8379 }
8380
8381 str = trailingNewline(str, opts);
8382 return str.replace(re, sep);
8383};
8384
8385function trailingNewline(str, options) {
8386 var val = options.trailingNewline;
8387 if (val === false) {
8388 return str;
8389 }
8390
8391 switch (kindOf(val)) {
8392 case 'string':
8393 str = str.replace(/\s+$/, options.trailingNewline);
8394 break;
8395 case 'function':
8396 str = options.trailingNewline(str);
8397 break;
8398 case 'undefined':
8399 case 'boolean':
8400 default: {
8401 str = str.replace(/\s+$/, '\n');
8402 break;
8403 }
8404 }
8405 return str;
8406}
8407
8408var defaults = {
8409 unformatted: ['code', 'pre', 'em', 'strong', 'span'],
8410 indent_inner_html: true,
8411 indent_char: ' ',
8412 indent_size: 2,
8413 sep: '\n'
8414};
8415
8416var pretty = function pretty(str, options) {
8417 var opts = extendShallow({}, defaults, options);
8418 str = js$1.html(str, opts);
8419
8420 if (opts.ocd === true) {
8421 if (opts.newlines) { opts.sep = opts.newlines; }
8422 return ocd(str, opts);
8423 }
8424
8425 return str;
8426};
8427
8428function ocd(str, options) {
8429 // Normalize and condense all newlines
8430 return condenseNewlines(str, options)
8431 // Remove empty whitespace the top of a file.
8432 .replace(/^\s+/g, '')
8433 // Remove extra whitespace from eof
8434 .replace(/\s+$/g, '\n')
8435
8436 // Add a space above each comment
8437 .replace(/(\s*<!--)/g, '\n$1')
8438 // Bring closing comments up to the same line as closing tag.
8439 .replace(/>(\s*)(?=<!--\s*\/)/g, '> ');
8440}
8441
8442//
8443
8444function getSelectorType(selector) {
8445 if (isDomSelector(selector)) { return DOM_SELECTOR }
8446 if (isVueComponent(selector)) { return COMPONENT_SELECTOR }
8447 if (isNameSelector(selector)) { return NAME_SELECTOR }
8448 if (isRefSelector(selector)) { return REF_SELECTOR }
8449
8450 return INVALID_SELECTOR
8451}
8452
8453function getSelector(
8454 selector,
8455 methodName
8456) {
8457 var type = getSelectorType(selector);
8458 if (type === INVALID_SELECTOR) {
8459 throwError(
8460 "wrapper." + methodName + "() must be passed a valid CSS selector, Vue " +
8461 "constructor, or valid find option object"
8462 );
8463 }
8464 return {
8465 type: type,
8466 value: selector
8467 }
8468}
8469
8470//
8471
8472var WrapperArray = function WrapperArray(wrappers) {
8473 var length = wrappers.length;
8474 // $FlowIgnore
8475 Object.defineProperty(this, 'wrappers', {
8476 get: function () { return wrappers; },
8477 set: function () { return throwError('wrapperArray.wrappers is read-only'); }
8478 });
8479 // $FlowIgnore
8480 Object.defineProperty(this, 'length', {
8481 get: function () { return length; },
8482 set: function () { return throwError('wrapperArray.length is read-only'); }
8483 });
8484};
8485
8486WrapperArray.prototype.at = function at (index) {
8487 var normalizedIndex = index < 0 ? this.length + index : index;
8488 if (normalizedIndex > this.length - 1 || normalizedIndex < 0) {
8489 var error = "no item exists at " + index;
8490 error += index < 0 ? (" (normalized to " + normalizedIndex + ")") : '';
8491 throwError(error);
8492 }
8493 return this.wrappers[normalizedIndex]
8494};
8495
8496WrapperArray.prototype.attributes = function attributes () {
8497 this.throwErrorIfWrappersIsEmpty('attributes');
8498
8499 throwError(
8500 "attributes must be called on a single wrapper, use " +
8501 "at(i) to access a wrapper"
8502 );
8503};
8504
8505WrapperArray.prototype.classes = function classes () {
8506 this.throwErrorIfWrappersIsEmpty('classes');
8507
8508 throwError(
8509 "classes must be called on a single wrapper, use " +
8510 "at(i) to access a wrapper"
8511 );
8512};
8513
8514WrapperArray.prototype.contains = function contains (selector) {
8515 this.throwErrorIfWrappersIsEmpty('contains');
8516
8517 return this.wrappers.every(function (wrapper) { return wrapper.contains(selector); })
8518};
8519
8520WrapperArray.prototype.exists = function exists () {
8521 return this.length > 0 && this.wrappers.every(function (wrapper) { return wrapper.exists(); })
8522};
8523
8524WrapperArray.prototype.filter = function filter (predicate) {
8525 return new WrapperArray(this.wrappers.filter(predicate))
8526};
8527
8528WrapperArray.prototype.emitted = function emitted () {
8529 this.throwErrorIfWrappersIsEmpty('emitted');
8530
8531 throwError(
8532 "emitted must be called on a single wrapper, use " +
8533 "at(i) to access a wrapper"
8534 );
8535};
8536
8537WrapperArray.prototype.emittedByOrder = function emittedByOrder () {
8538 this.throwErrorIfWrappersIsEmpty('emittedByOrder');
8539
8540 throwError(
8541 "emittedByOrder must be called on a single wrapper, " +
8542 "use at(i) to access a wrapper"
8543 );
8544};
8545
8546WrapperArray.prototype.findAll = function findAll () {
8547 this.throwErrorIfWrappersIsEmpty('findAll');
8548
8549 throwError(
8550 "findAll must be called on a single wrapper, use " +
8551 "at(i) to access a wrapper"
8552 );
8553};
8554
8555WrapperArray.prototype.find = function find () {
8556 this.throwErrorIfWrappersIsEmpty('find');
8557
8558 throwError(
8559 "find must be called on a single wrapper, use at(i) " +
8560 "to access a wrapper"
8561 );
8562};
8563
8564WrapperArray.prototype.html = function html () {
8565 this.throwErrorIfWrappersIsEmpty('html');
8566
8567 throwError(
8568 "html must be called on a single wrapper, use at(i) " +
8569 "to access a wrapper"
8570 );
8571};
8572
8573WrapperArray.prototype.is = function is (selector) {
8574 this.throwErrorIfWrappersIsEmpty('is');
8575
8576 return this.wrappers.every(function (wrapper) { return wrapper.is(selector); })
8577};
8578
8579WrapperArray.prototype.isEmpty = function isEmpty () {
8580 this.throwErrorIfWrappersIsEmpty('isEmpty');
8581
8582 return this.wrappers.every(function (wrapper) { return wrapper.isEmpty(); })
8583};
8584
8585WrapperArray.prototype.isVisible = function isVisible () {
8586 this.throwErrorIfWrappersIsEmpty('isVisible');
8587
8588 return this.wrappers.every(function (wrapper) { return wrapper.isVisible(); })
8589};
8590
8591WrapperArray.prototype.isVueInstance = function isVueInstance () {
8592 this.throwErrorIfWrappersIsEmpty('isVueInstance');
8593
8594 return this.wrappers.every(function (wrapper) { return wrapper.isVueInstance(); })
8595};
8596
8597WrapperArray.prototype.name = function name () {
8598 this.throwErrorIfWrappersIsEmpty('name');
8599
8600 throwError(
8601 "name must be called on a single wrapper, use at(i) " +
8602 "to access a wrapper"
8603 );
8604};
8605
8606WrapperArray.prototype.overview = function overview () {
8607 this.throwErrorIfWrappersIsEmpty('overview()');
8608
8609 throwError(
8610 "overview() must be called on a single wrapper, use at(i) " +
8611 "to access a wrapper"
8612 );
8613};
8614
8615WrapperArray.prototype.props = function props () {
8616 this.throwErrorIfWrappersIsEmpty('props');
8617
8618 throwError(
8619 "props must be called on a single wrapper, use " +
8620 "at(i) to access a wrapper"
8621 );
8622};
8623
8624WrapperArray.prototype.text = function text () {
8625 this.throwErrorIfWrappersIsEmpty('text');
8626
8627 throwError(
8628 "text must be called on a single wrapper, use at(i) " +
8629 "to access a wrapper"
8630 );
8631};
8632
8633WrapperArray.prototype.throwErrorIfWrappersIsEmpty = function throwErrorIfWrappersIsEmpty (method) {
8634 if (this.wrappers.length === 0) {
8635 throwError((method + " cannot be called on 0 items"));
8636 }
8637};
8638
8639WrapperArray.prototype.setData = function setData (data) {
8640 this.throwErrorIfWrappersIsEmpty('setData');
8641
8642 this.wrappers.forEach(function (wrapper) { return wrapper.setData(data); });
8643};
8644
8645WrapperArray.prototype.setMethods = function setMethods (props) {
8646 this.throwErrorIfWrappersIsEmpty('setMethods');
8647
8648 this.wrappers.forEach(function (wrapper) { return wrapper.setMethods(props); });
8649};
8650
8651WrapperArray.prototype.setProps = function setProps (props) {
8652 this.throwErrorIfWrappersIsEmpty('setProps');
8653
8654 this.wrappers.forEach(function (wrapper) { return wrapper.setProps(props); });
8655};
8656
8657WrapperArray.prototype.setValue = function setValue (value) {
8658 this.throwErrorIfWrappersIsEmpty('setValue');
8659
8660 this.wrappers.forEach(function (wrapper) { return wrapper.setValue(value); });
8661};
8662
8663WrapperArray.prototype.setChecked = function setChecked (checked) {
8664 if ( checked === void 0 ) checked = true;
8665
8666 this.throwErrorIfWrappersIsEmpty('setChecked');
8667
8668 this.wrappers.forEach(function (wrapper) { return wrapper.setChecked(checked); });
8669};
8670
8671WrapperArray.prototype.setSelected = function setSelected () {
8672 this.throwErrorIfWrappersIsEmpty('setSelected');
8673
8674 throwError(
8675 "setSelected must be called on a single wrapper, " +
8676 "use at(i) to access a wrapper"
8677 );
8678};
8679
8680WrapperArray.prototype.trigger = function trigger (event, options) {
8681 this.throwErrorIfWrappersIsEmpty('trigger');
8682
8683 this.wrappers.forEach(function (wrapper) { return wrapper.trigger(event, options); });
8684};
8685
8686WrapperArray.prototype.destroy = function destroy () {
8687 this.throwErrorIfWrappersIsEmpty('destroy');
8688
8689 this.wrappers.forEach(function (wrapper) { return wrapper.destroy(); });
8690};
8691
8692//
8693
8694var buildSelectorString = function (selector) {
8695 if (getSelectorType(selector) === REF_SELECTOR) {
8696 return ("ref=\"" + (selector.value.ref) + "\"")
8697 }
8698
8699 if (typeof selector === 'string') {
8700 return selector
8701 }
8702
8703 return 'Component'
8704};
8705
8706var ErrorWrapper = function ErrorWrapper(selector) {
8707 this.selector = selector;
8708};
8709
8710ErrorWrapper.prototype.at = function at () {
8711 throwError(
8712 ("find did not return " + (buildSelectorString(
8713 this.selector
8714 )) + ", cannot call at() on empty Wrapper")
8715 );
8716};
8717
8718ErrorWrapper.prototype.attributes = function attributes () {
8719 throwError(
8720 ("find did not return " + (buildSelectorString(
8721 this.selector
8722 )) + ", cannot call attributes() on empty Wrapper")
8723 );
8724};
8725
8726ErrorWrapper.prototype.classes = function classes () {
8727 throwError(
8728 ("find did not return " + (buildSelectorString(
8729 this.selector
8730 )) + ", cannot call classes() on empty Wrapper")
8731 );
8732};
8733
8734ErrorWrapper.prototype.contains = function contains () {
8735 throwError(
8736 ("find did not return " + (buildSelectorString(
8737 this.selector
8738 )) + ", cannot call contains() on empty Wrapper")
8739 );
8740};
8741
8742ErrorWrapper.prototype.emitted = function emitted () {
8743 throwError(
8744 ("find did not return " + (buildSelectorString(
8745 this.selector
8746 )) + ", cannot call emitted() on empty Wrapper")
8747 );
8748};
8749
8750ErrorWrapper.prototype.emittedByOrder = function emittedByOrder () {
8751 throwError(
8752 ("find did not return " + (buildSelectorString(
8753 this.selector
8754 )) + ", cannot call emittedByOrder() on empty Wrapper")
8755 );
8756};
8757
8758ErrorWrapper.prototype.exists = function exists () {
8759 return false
8760};
8761
8762ErrorWrapper.prototype.filter = function filter () {
8763 throwError(
8764 ("find did not return " + (buildSelectorString(
8765 this.selector
8766 )) + ", cannot call filter() on empty Wrapper")
8767 );
8768};
8769
8770ErrorWrapper.prototype.visible = function visible () {
8771 throwError(
8772 ("find did not return " + (buildSelectorString(
8773 this.selector
8774 )) + ", cannot call visible() on empty Wrapper")
8775 );
8776};
8777
8778ErrorWrapper.prototype.hasAttribute = function hasAttribute () {
8779 throwError(
8780 ("find did not return " + (buildSelectorString(
8781 this.selector
8782 )) + ", cannot call hasAttribute() on empty Wrapper")
8783 );
8784};
8785
8786ErrorWrapper.prototype.hasClass = function hasClass () {
8787 throwError(
8788 ("find did not return " + (buildSelectorString(
8789 this.selector
8790 )) + ", cannot call hasClass() on empty Wrapper")
8791 );
8792};
8793
8794ErrorWrapper.prototype.hasProp = function hasProp () {
8795 throwError(
8796 ("find did not return " + (buildSelectorString(
8797 this.selector
8798 )) + ", cannot call hasProp() on empty Wrapper")
8799 );
8800};
8801
8802ErrorWrapper.prototype.hasStyle = function hasStyle () {
8803 throwError(
8804 ("find did not return " + (buildSelectorString(
8805 this.selector
8806 )) + ", cannot call hasStyle() on empty Wrapper")
8807 );
8808};
8809
8810ErrorWrapper.prototype.findAll = function findAll () {
8811 throwError(
8812 ("find did not return " + (buildSelectorString(
8813 this.selector
8814 )) + ", cannot call findAll() on empty Wrapper")
8815 );
8816};
8817
8818ErrorWrapper.prototype.find = function find () {
8819 throwError(
8820 ("find did not return " + (buildSelectorString(
8821 this.selector
8822 )) + ", cannot call find() on empty Wrapper")
8823 );
8824};
8825
8826ErrorWrapper.prototype.html = function html () {
8827 throwError(
8828 ("find did not return " + (buildSelectorString(
8829 this.selector
8830 )) + ", cannot call html() on empty Wrapper")
8831 );
8832};
8833
8834ErrorWrapper.prototype.is = function is () {
8835 throwError(
8836 ("find did not return " + (buildSelectorString(
8837 this.selector
8838 )) + ", cannot call is() on empty Wrapper")
8839 );
8840};
8841
8842ErrorWrapper.prototype.isEmpty = function isEmpty () {
8843 throwError(
8844 ("find did not return " + (buildSelectorString(
8845 this.selector
8846 )) + ", cannot call isEmpty() on empty Wrapper")
8847 );
8848};
8849
8850ErrorWrapper.prototype.isVisible = function isVisible () {
8851 throwError(
8852 ("find did not return " + (buildSelectorString(
8853 this.selector
8854 )) + ", cannot call isVisible() on empty Wrapper")
8855 );
8856};
8857
8858ErrorWrapper.prototype.isVueInstance = function isVueInstance () {
8859 throwError(
8860 ("find did not return " + (buildSelectorString(
8861 this.selector
8862 )) + ", cannot call isVueInstance() on empty Wrapper")
8863 );
8864};
8865
8866ErrorWrapper.prototype.name = function name () {
8867 throwError(
8868 ("find did not return " + (buildSelectorString(
8869 this.selector
8870 )) + ", cannot call name() on empty Wrapper")
8871 );
8872};
8873
8874ErrorWrapper.prototype.overview = function overview () {
8875 throwError(
8876 ("find did not return " + (buildSelectorString(
8877 this.selector
8878 )) + ", cannot call overview() on empty Wrapper")
8879 );
8880};
8881
8882ErrorWrapper.prototype.props = function props () {
8883 throwError(
8884 ("find did not return " + (buildSelectorString(
8885 this.selector
8886 )) + ", cannot call props() on empty Wrapper")
8887 );
8888};
8889
8890ErrorWrapper.prototype.text = function text () {
8891 throwError(
8892 ("find did not return " + (buildSelectorString(
8893 this.selector
8894 )) + ", cannot call text() on empty Wrapper")
8895 );
8896};
8897
8898ErrorWrapper.prototype.setComputed = function setComputed () {
8899 throwError(
8900 ("find did not return " + (buildSelectorString(
8901 this.selector
8902 )) + ", cannot call setComputed() on empty Wrapper")
8903 );
8904};
8905
8906ErrorWrapper.prototype.setData = function setData () {
8907 throwError(
8908 ("find did not return " + (buildSelectorString(
8909 this.selector
8910 )) + ", cannot call setData() on empty Wrapper")
8911 );
8912};
8913
8914ErrorWrapper.prototype.setMethods = function setMethods () {
8915 throwError(
8916 ("find did not return " + (buildSelectorString(
8917 this.selector
8918 )) + ", cannot call setMethods() on empty Wrapper")
8919 );
8920};
8921
8922ErrorWrapper.prototype.setProps = function setProps () {
8923 throwError(
8924 ("find did not return " + (buildSelectorString(
8925 this.selector
8926 )) + ", cannot call setProps() on empty Wrapper")
8927 );
8928};
8929
8930ErrorWrapper.prototype.setValue = function setValue () {
8931 throwError(
8932 ("find did not return " + (buildSelectorString(
8933 this.selector
8934 )) + ", cannot call setValue() on empty Wrapper")
8935 );
8936};
8937
8938ErrorWrapper.prototype.setChecked = function setChecked () {
8939 throwError(
8940 ("find did not return " + (buildSelectorString(
8941 this.selector
8942 )) + ", cannot call setChecked() on empty Wrapper")
8943 );
8944};
8945
8946ErrorWrapper.prototype.setSelected = function setSelected () {
8947 throwError(
8948 ("find did not return " + (buildSelectorString(
8949 this.selector
8950 )) + ", cannot call setSelected() on empty Wrapper")
8951 );
8952};
8953
8954ErrorWrapper.prototype.trigger = function trigger () {
8955 throwError(
8956 ("find did not return " + (buildSelectorString(
8957 this.selector
8958 )) + ", cannot call trigger() on empty Wrapper")
8959 );
8960};
8961
8962ErrorWrapper.prototype.destroy = function destroy () {
8963 throwError(
8964 ("find did not return " + (buildSelectorString(
8965 this.selector
8966 )) + ", cannot call destroy() on empty Wrapper")
8967 );
8968};
8969
8970function recursivelySetData(vm, target, data) {
8971 Object.keys(data).forEach(function (key) {
8972 var val = data[key];
8973 var targetVal = target[key];
8974
8975 if (isPlainObject(val) && isPlainObject(targetVal)) {
8976 recursivelySetData(vm, targetVal, val);
8977 } else {
8978 vm.$set(target, key, val);
8979 }
8980 });
8981}
8982
8983var abort = {
8984 eventInterface: "Event",
8985 bubbles: false,
8986 cancelable: false
8987};
8988var afterprint = {
8989 eventInterface: "Event",
8990 bubbles: false,
8991 cancelable: false
8992};
8993var animationend = {
8994 eventInterface: "AnimationEvent",
8995 bubbles: true,
8996 cancelable: false
8997};
8998var animationiteration = {
8999 eventInterface: "AnimationEvent",
9000 bubbles: true,
9001 cancelable: false
9002};
9003var animationstart = {
9004 eventInterface: "AnimationEvent",
9005 bubbles: true,
9006 cancelable: false
9007};
9008var appinstalled = {
9009 eventInterface: "Event",
9010 bubbles: false,
9011 cancelable: false
9012};
9013var audioprocess = {
9014 eventInterface: "AudioProcessingEvent"
9015};
9016var audioend = {
9017 eventInterface: "Event",
9018 bubbles: false,
9019 cancelable: false
9020};
9021var audiostart = {
9022 eventInterface: "Event",
9023 bubbles: false,
9024 cancelable: false
9025};
9026var beforeprint = {
9027 eventInterface: "Event",
9028 bubbles: false,
9029 cancelable: false
9030};
9031var beforeunload = {
9032 eventInterface: "BeforeUnloadEvent",
9033 bubbles: false,
9034 cancelable: true
9035};
9036var beginEvent = {
9037 eventInterface: "TimeEvent",
9038 bubbles: false,
9039 cancelable: false
9040};
9041var blur = {
9042 eventInterface: "FocusEvent",
9043 bubbles: false,
9044 cancelable: false
9045};
9046var boundary = {
9047 eventInterface: "SpeechSynthesisEvent",
9048 bubbles: false,
9049 cancelable: false
9050};
9051var cached = {
9052 eventInterface: "Event",
9053 bubbles: false,
9054 cancelable: false
9055};
9056var canplay = {
9057 eventInterface: "Event",
9058 bubbles: false,
9059 cancelable: false
9060};
9061var canplaythrough = {
9062 eventInterface: "Event",
9063 bubbles: false,
9064 cancelable: false
9065};
9066var change = {
9067 eventInterface: "Event",
9068 bubbles: true,
9069 cancelable: false
9070};
9071var chargingchange = {
9072 eventInterface: "Event",
9073 bubbles: false,
9074 cancelable: false
9075};
9076var chargingtimechange = {
9077 eventInterface: "Event",
9078 bubbles: false,
9079 cancelable: false
9080};
9081var checking = {
9082 eventInterface: "Event",
9083 bubbles: false,
9084 cancelable: false
9085};
9086var click = {
9087 eventInterface: "MouseEvent",
9088 bubbles: true,
9089 cancelable: true
9090};
9091var close = {
9092 eventInterface: "Event",
9093 bubbles: false,
9094 cancelable: false
9095};
9096var complete = {
9097 eventInterface: "OfflineAudioCompletionEvent"
9098};
9099var compositionend = {
9100 eventInterface: "CompositionEvent",
9101 bubbles: true,
9102 cancelable: true
9103};
9104var compositionstart = {
9105 eventInterface: "CompositionEvent",
9106 bubbles: true,
9107 cancelable: true
9108};
9109var compositionupdate = {
9110 eventInterface: "CompositionEvent",
9111 bubbles: true,
9112 cancelable: false
9113};
9114var contextmenu = {
9115 eventInterface: "MouseEvent",
9116 bubbles: true,
9117 cancelable: true
9118};
9119var copy = {
9120 eventInterface: "ClipboardEvent"
9121};
9122var cut = {
9123 eventInterface: "ClipboardEvent",
9124 bubbles: true,
9125 cancelable: true
9126};
9127var dblclick = {
9128 eventInterface: "MouseEvent",
9129 bubbles: true,
9130 cancelable: true
9131};
9132var devicechange = {
9133 eventInterface: "Event",
9134 bubbles: false,
9135 cancelable: false
9136};
9137var devicelight = {
9138 eventInterface: "DeviceLightEvent",
9139 bubbles: false,
9140 cancelable: false
9141};
9142var devicemotion = {
9143 eventInterface: "DeviceMotionEvent",
9144 bubbles: false,
9145 cancelable: false
9146};
9147var deviceorientation = {
9148 eventInterface: "DeviceOrientationEvent",
9149 bubbles: false,
9150 cancelable: false
9151};
9152var deviceproximity = {
9153 eventInterface: "DeviceProximityEvent",
9154 bubbles: false,
9155 cancelable: false
9156};
9157var dischargingtimechange = {
9158 eventInterface: "Event",
9159 bubbles: false,
9160 cancelable: false
9161};
9162var DOMActivate = {
9163 eventInterface: "UIEvent",
9164 bubbles: true,
9165 cancelable: true
9166};
9167var DOMAttributeNameChanged = {
9168 eventInterface: "MutationNameEvent",
9169 bubbles: true,
9170 cancelable: true
9171};
9172var DOMAttrModified = {
9173 eventInterface: "MutationEvent",
9174 bubbles: true,
9175 cancelable: true
9176};
9177var DOMCharacterDataModified = {
9178 eventInterface: "MutationEvent",
9179 bubbles: true,
9180 cancelable: true
9181};
9182var DOMContentLoaded = {
9183 eventInterface: "Event",
9184 bubbles: true,
9185 cancelable: true
9186};
9187var DOMElementNameChanged = {
9188 eventInterface: "MutationNameEvent",
9189 bubbles: true,
9190 cancelable: true
9191};
9192var DOMFocusIn = {
9193 eventInterface: "FocusEvent",
9194 bubbles: true,
9195 cancelable: true
9196};
9197var DOMFocusOut = {
9198 eventInterface: "FocusEvent",
9199 bubbles: true,
9200 cancelable: true
9201};
9202var DOMNodeInserted = {
9203 eventInterface: "MutationEvent",
9204 bubbles: true,
9205 cancelable: true
9206};
9207var DOMNodeInsertedIntoDocument = {
9208 eventInterface: "MutationEvent",
9209 bubbles: true,
9210 cancelable: true
9211};
9212var DOMNodeRemoved = {
9213 eventInterface: "MutationEvent",
9214 bubbles: true,
9215 cancelable: true
9216};
9217var DOMNodeRemovedFromDocument = {
9218 eventInterface: "MutationEvent",
9219 bubbles: true,
9220 cancelable: true
9221};
9222var DOMSubtreeModified = {
9223 eventInterface: "MutationEvent"
9224};
9225var downloading = {
9226 eventInterface: "Event",
9227 bubbles: false,
9228 cancelable: false
9229};
9230var drag = {
9231 eventInterface: "DragEvent",
9232 bubbles: true,
9233 cancelable: true
9234};
9235var dragend = {
9236 eventInterface: "DragEvent",
9237 bubbles: true,
9238 cancelable: false
9239};
9240var dragenter = {
9241 eventInterface: "DragEvent",
9242 bubbles: true,
9243 cancelable: true
9244};
9245var dragleave = {
9246 eventInterface: "DragEvent",
9247 bubbles: true,
9248 cancelable: false
9249};
9250var dragover = {
9251 eventInterface: "DragEvent",
9252 bubbles: true,
9253 cancelable: true
9254};
9255var dragstart = {
9256 eventInterface: "DragEvent",
9257 bubbles: true,
9258 cancelable: true
9259};
9260var drop = {
9261 eventInterface: "DragEvent",
9262 bubbles: true,
9263 cancelable: true
9264};
9265var durationchange = {
9266 eventInterface: "Event",
9267 bubbles: false,
9268 cancelable: false
9269};
9270var emptied = {
9271 eventInterface: "Event",
9272 bubbles: false,
9273 cancelable: false
9274};
9275var end = {
9276 eventInterface: "Event",
9277 bubbles: false,
9278 cancelable: false
9279};
9280var ended = {
9281 eventInterface: "Event",
9282 bubbles: false,
9283 cancelable: false
9284};
9285var endEvent = {
9286 eventInterface: "TimeEvent",
9287 bubbles: false,
9288 cancelable: false
9289};
9290var error = {
9291 eventInterface: "Event",
9292 bubbles: false,
9293 cancelable: false
9294};
9295var focus = {
9296 eventInterface: "FocusEvent",
9297 bubbles: false,
9298 cancelable: false
9299};
9300var focusin = {
9301 eventInterface: "FocusEvent",
9302 bubbles: true,
9303 cancelable: false
9304};
9305var focusout = {
9306 eventInterface: "FocusEvent",
9307 bubbles: true,
9308 cancelable: false
9309};
9310var fullscreenchange = {
9311 eventInterface: "Event",
9312 bubbles: true,
9313 cancelable: false
9314};
9315var fullscreenerror = {
9316 eventInterface: "Event",
9317 bubbles: true,
9318 cancelable: false
9319};
9320var gamepadconnected = {
9321 eventInterface: "GamepadEvent",
9322 bubbles: false,
9323 cancelable: false
9324};
9325var gamepaddisconnected = {
9326 eventInterface: "GamepadEvent",
9327 bubbles: false,
9328 cancelable: false
9329};
9330var gotpointercapture = {
9331 eventInterface: "PointerEvent",
9332 bubbles: false,
9333 cancelable: false
9334};
9335var hashchange = {
9336 eventInterface: "HashChangeEvent",
9337 bubbles: true,
9338 cancelable: false
9339};
9340var lostpointercapture = {
9341 eventInterface: "PointerEvent",
9342 bubbles: false,
9343 cancelable: false
9344};
9345var input = {
9346 eventInterface: "Event",
9347 bubbles: true,
9348 cancelable: false
9349};
9350var invalid = {
9351 eventInterface: "Event",
9352 cancelable: true,
9353 bubbles: false
9354};
9355var keydown = {
9356 eventInterface: "KeyboardEvent",
9357 bubbles: true,
9358 cancelable: true
9359};
9360var keypress = {
9361 eventInterface: "KeyboardEvent",
9362 bubbles: true,
9363 cancelable: true
9364};
9365var keyup = {
9366 eventInterface: "KeyboardEvent",
9367 bubbles: true,
9368 cancelable: true
9369};
9370var languagechange = {
9371 eventInterface: "Event",
9372 bubbles: false,
9373 cancelable: false
9374};
9375var levelchange = {
9376 eventInterface: "Event",
9377 bubbles: false,
9378 cancelable: false
9379};
9380var load = {
9381 eventInterface: "UIEvent",
9382 bubbles: false,
9383 cancelable: false
9384};
9385var loadeddata = {
9386 eventInterface: "Event",
9387 bubbles: false,
9388 cancelable: false
9389};
9390var loadedmetadata = {
9391 eventInterface: "Event",
9392 bubbles: false,
9393 cancelable: false
9394};
9395var loadend = {
9396 eventInterface: "ProgressEvent",
9397 bubbles: false,
9398 cancelable: false
9399};
9400var loadstart = {
9401 eventInterface: "ProgressEvent",
9402 bubbles: false,
9403 cancelable: false
9404};
9405var mark = {
9406 eventInterface: "SpeechSynthesisEvent",
9407 bubbles: false,
9408 cancelable: false
9409};
9410var message = {
9411 eventInterface: "MessageEvent",
9412 bubbles: false,
9413 cancelable: false
9414};
9415var messageerror = {
9416 eventInterface: "MessageEvent",
9417 bubbles: false,
9418 cancelable: false
9419};
9420var mousedown = {
9421 eventInterface: "MouseEvent",
9422 bubbles: true,
9423 cancelable: true
9424};
9425var mouseenter = {
9426 eventInterface: "MouseEvent",
9427 bubbles: false,
9428 cancelable: false
9429};
9430var mouseleave = {
9431 eventInterface: "MouseEvent",
9432 bubbles: false,
9433 cancelable: false
9434};
9435var mousemove = {
9436 eventInterface: "MouseEvent",
9437 bubbles: true,
9438 cancelable: true
9439};
9440var mouseout = {
9441 eventInterface: "MouseEvent",
9442 bubbles: true,
9443 cancelable: true
9444};
9445var mouseover = {
9446 eventInterface: "MouseEvent",
9447 bubbles: true,
9448 cancelable: true
9449};
9450var mouseup = {
9451 eventInterface: "MouseEvent",
9452 bubbles: true,
9453 cancelable: true
9454};
9455var nomatch = {
9456 eventInterface: "SpeechRecognitionEvent",
9457 bubbles: false,
9458 cancelable: false
9459};
9460var notificationclick = {
9461 eventInterface: "NotificationEvent",
9462 bubbles: false,
9463 cancelable: false
9464};
9465var noupdate = {
9466 eventInterface: "Event",
9467 bubbles: false,
9468 cancelable: false
9469};
9470var obsolete = {
9471 eventInterface: "Event",
9472 bubbles: false,
9473 cancelable: false
9474};
9475var offline = {
9476 eventInterface: "Event",
9477 bubbles: false,
9478 cancelable: false
9479};
9480var online = {
9481 eventInterface: "Event",
9482 bubbles: false,
9483 cancelable: false
9484};
9485var open = {
9486 eventInterface: "Event",
9487 bubbles: false,
9488 cancelable: false
9489};
9490var orientationchange = {
9491 eventInterface: "Event",
9492 bubbles: false,
9493 cancelable: false
9494};
9495var pagehide = {
9496 eventInterface: "PageTransitionEvent",
9497 bubbles: false,
9498 cancelable: false
9499};
9500var pageshow = {
9501 eventInterface: "PageTransitionEvent",
9502 bubbles: false,
9503 cancelable: false
9504};
9505var paste = {
9506 eventInterface: "ClipboardEvent",
9507 bubbles: true,
9508 cancelable: true
9509};
9510var pause = {
9511 eventInterface: "SpeechSynthesisEvent",
9512 bubbles: false,
9513 cancelable: false
9514};
9515var pointercancel = {
9516 eventInterface: "PointerEvent",
9517 bubbles: true,
9518 cancelable: false
9519};
9520var pointerdown = {
9521 eventInterface: "PointerEvent",
9522 bubbles: true,
9523 cancelable: true
9524};
9525var pointerenter = {
9526 eventInterface: "PointerEvent",
9527 bubbles: false,
9528 cancelable: false
9529};
9530var pointerleave = {
9531 eventInterface: "PointerEvent",
9532 bubbles: false,
9533 cancelable: false
9534};
9535var pointerlockchange = {
9536 eventInterface: "Event",
9537 bubbles: true,
9538 cancelable: false
9539};
9540var pointerlockerror = {
9541 eventInterface: "Event",
9542 bubbles: true,
9543 cancelable: false
9544};
9545var pointermove = {
9546 eventInterface: "PointerEvent",
9547 bubbles: true,
9548 cancelable: true
9549};
9550var pointerout = {
9551 eventInterface: "PointerEvent",
9552 bubbles: true,
9553 cancelable: true
9554};
9555var pointerover = {
9556 eventInterface: "PointerEvent",
9557 bubbles: true,
9558 cancelable: true
9559};
9560var pointerup = {
9561 eventInterface: "PointerEvent",
9562 bubbles: true,
9563 cancelable: true
9564};
9565var play = {
9566 eventInterface: "Event",
9567 bubbles: false,
9568 cancelable: false
9569};
9570var playing = {
9571 eventInterface: "Event",
9572 bubbles: false,
9573 cancelable: false
9574};
9575var popstate = {
9576 eventInterface: "PopStateEvent",
9577 bubbles: true,
9578 cancelable: false
9579};
9580var progress = {
9581 eventInterface: "ProgressEvent",
9582 bubbles: false,
9583 cancelable: false
9584};
9585var push = {
9586 eventInterface: "PushEvent",
9587 bubbles: false,
9588 cancelable: false
9589};
9590var pushsubscriptionchange = {
9591 eventInterface: "PushEvent",
9592 bubbles: false,
9593 cancelable: false
9594};
9595var ratechange = {
9596 eventInterface: "Event",
9597 bubbles: false,
9598 cancelable: false
9599};
9600var readystatechange = {
9601 eventInterface: "Event",
9602 bubbles: false,
9603 cancelable: false
9604};
9605var repeatEvent = {
9606 eventInterface: "TimeEvent",
9607 bubbles: false,
9608 cancelable: false
9609};
9610var reset = {
9611 eventInterface: "Event",
9612 bubbles: true,
9613 cancelable: true
9614};
9615var resize = {
9616 eventInterface: "UIEvent",
9617 bubbles: false,
9618 cancelable: false
9619};
9620var resourcetimingbufferfull = {
9621 eventInterface: "Performance",
9622 bubbles: true,
9623 cancelable: true
9624};
9625var result = {
9626 eventInterface: "SpeechRecognitionEvent",
9627 bubbles: false,
9628 cancelable: false
9629};
9630var resume = {
9631 eventInterface: "SpeechSynthesisEvent",
9632 bubbles: false,
9633 cancelable: false
9634};
9635var scroll = {
9636 eventInterface: "UIEvent",
9637 bubbles: false,
9638 cancelable: false
9639};
9640var seeked = {
9641 eventInterface: "Event",
9642 bubbles: false,
9643 cancelable: false
9644};
9645var seeking = {
9646 eventInterface: "Event",
9647 bubbles: false,
9648 cancelable: false
9649};
9650var select = {
9651 eventInterface: "UIEvent",
9652 bubbles: true,
9653 cancelable: false
9654};
9655var selectstart = {
9656 eventInterface: "Event",
9657 bubbles: true,
9658 cancelable: true
9659};
9660var selectionchange = {
9661 eventInterface: "Event",
9662 bubbles: false,
9663 cancelable: false
9664};
9665var show = {
9666 eventInterface: "MouseEvent",
9667 bubbles: false,
9668 cancelable: false
9669};
9670var slotchange = {
9671 eventInterface: "Event",
9672 bubbles: true,
9673 cancelable: false
9674};
9675var soundend = {
9676 eventInterface: "Event",
9677 bubbles: false,
9678 cancelable: false
9679};
9680var soundstart = {
9681 eventInterface: "Event",
9682 bubbles: false,
9683 cancelable: false
9684};
9685var speechend = {
9686 eventInterface: "Event",
9687 bubbles: false,
9688 cancelable: false
9689};
9690var speechstart = {
9691 eventInterface: "Event",
9692 bubbles: false,
9693 cancelable: false
9694};
9695var stalled = {
9696 eventInterface: "Event",
9697 bubbles: false,
9698 cancelable: false
9699};
9700var start = {
9701 eventInterface: "SpeechSynthesisEvent",
9702 bubbles: false,
9703 cancelable: false
9704};
9705var storage = {
9706 eventInterface: "StorageEvent",
9707 bubbles: false,
9708 cancelable: false
9709};
9710var submit = {
9711 eventInterface: "Event",
9712 bubbles: true,
9713 cancelable: true
9714};
9715var success = {
9716 eventInterface: "Event",
9717 bubbles: false,
9718 cancelable: false
9719};
9720var suspend = {
9721 eventInterface: "Event",
9722 bubbles: false,
9723 cancelable: false
9724};
9725var SVGAbort = {
9726 eventInterface: "SVGEvent",
9727 bubbles: true,
9728 cancelable: false
9729};
9730var SVGError = {
9731 eventInterface: "SVGEvent",
9732 bubbles: true,
9733 cancelable: false
9734};
9735var SVGLoad = {
9736 eventInterface: "SVGEvent",
9737 bubbles: false,
9738 cancelable: false
9739};
9740var SVGResize = {
9741 eventInterface: "SVGEvent",
9742 bubbles: true,
9743 cancelable: false
9744};
9745var SVGScroll = {
9746 eventInterface: "SVGEvent",
9747 bubbles: true,
9748 cancelable: false
9749};
9750var SVGUnload = {
9751 eventInterface: "SVGEvent",
9752 bubbles: false,
9753 cancelable: false
9754};
9755var SVGZoom = {
9756 eventInterface: "SVGZoomEvent",
9757 bubbles: true,
9758 cancelable: false
9759};
9760var timeout = {
9761 eventInterface: "ProgressEvent",
9762 bubbles: false,
9763 cancelable: false
9764};
9765var timeupdate = {
9766 eventInterface: "Event",
9767 bubbles: false,
9768 cancelable: false
9769};
9770var touchcancel = {
9771 eventInterface: "TouchEvent",
9772 bubbles: true,
9773 cancelable: false
9774};
9775var touchend = {
9776 eventInterface: "TouchEvent",
9777 bubbles: true,
9778 cancelable: true
9779};
9780var touchmove = {
9781 eventInterface: "TouchEvent",
9782 bubbles: true,
9783 cancelable: true
9784};
9785var touchstart = {
9786 eventInterface: "TouchEvent",
9787 bubbles: true,
9788 cancelable: true
9789};
9790var transitionend = {
9791 eventInterface: "TransitionEvent",
9792 bubbles: true,
9793 cancelable: true
9794};
9795var unload = {
9796 eventInterface: "UIEvent",
9797 bubbles: false
9798};
9799var updateready = {
9800 eventInterface: "Event",
9801 bubbles: false,
9802 cancelable: false
9803};
9804var userproximity = {
9805 eventInterface: "UserProximityEvent",
9806 bubbles: false,
9807 cancelable: false
9808};
9809var voiceschanged = {
9810 eventInterface: "Event",
9811 bubbles: false,
9812 cancelable: false
9813};
9814var visibilitychange = {
9815 eventInterface: "Event",
9816 bubbles: true,
9817 cancelable: false
9818};
9819var volumechange = {
9820 eventInterface: "Event",
9821 bubbles: false,
9822 cancelable: false
9823};
9824var waiting = {
9825 eventInterface: "Event",
9826 bubbles: false,
9827 cancelable: false
9828};
9829var wheel = {
9830 eventInterface: "WheelEvent",
9831 bubbles: true,
9832 cancelable: true
9833};
9834var domEventTypes = {
9835 abort: abort,
9836 afterprint: afterprint,
9837 animationend: animationend,
9838 animationiteration: animationiteration,
9839 animationstart: animationstart,
9840 appinstalled: appinstalled,
9841 audioprocess: audioprocess,
9842 audioend: audioend,
9843 audiostart: audiostart,
9844 beforeprint: beforeprint,
9845 beforeunload: beforeunload,
9846 beginEvent: beginEvent,
9847 blur: blur,
9848 boundary: boundary,
9849 cached: cached,
9850 canplay: canplay,
9851 canplaythrough: canplaythrough,
9852 change: change,
9853 chargingchange: chargingchange,
9854 chargingtimechange: chargingtimechange,
9855 checking: checking,
9856 click: click,
9857 close: close,
9858 complete: complete,
9859 compositionend: compositionend,
9860 compositionstart: compositionstart,
9861 compositionupdate: compositionupdate,
9862 contextmenu: contextmenu,
9863 copy: copy,
9864 cut: cut,
9865 dblclick: dblclick,
9866 devicechange: devicechange,
9867 devicelight: devicelight,
9868 devicemotion: devicemotion,
9869 deviceorientation: deviceorientation,
9870 deviceproximity: deviceproximity,
9871 dischargingtimechange: dischargingtimechange,
9872 DOMActivate: DOMActivate,
9873 DOMAttributeNameChanged: DOMAttributeNameChanged,
9874 DOMAttrModified: DOMAttrModified,
9875 DOMCharacterDataModified: DOMCharacterDataModified,
9876 DOMContentLoaded: DOMContentLoaded,
9877 DOMElementNameChanged: DOMElementNameChanged,
9878 DOMFocusIn: DOMFocusIn,
9879 DOMFocusOut: DOMFocusOut,
9880 DOMNodeInserted: DOMNodeInserted,
9881 DOMNodeInsertedIntoDocument: DOMNodeInsertedIntoDocument,
9882 DOMNodeRemoved: DOMNodeRemoved,
9883 DOMNodeRemovedFromDocument: DOMNodeRemovedFromDocument,
9884 DOMSubtreeModified: DOMSubtreeModified,
9885 downloading: downloading,
9886 drag: drag,
9887 dragend: dragend,
9888 dragenter: dragenter,
9889 dragleave: dragleave,
9890 dragover: dragover,
9891 dragstart: dragstart,
9892 drop: drop,
9893 durationchange: durationchange,
9894 emptied: emptied,
9895 end: end,
9896 ended: ended,
9897 endEvent: endEvent,
9898 error: error,
9899 focus: focus,
9900 focusin: focusin,
9901 focusout: focusout,
9902 fullscreenchange: fullscreenchange,
9903 fullscreenerror: fullscreenerror,
9904 gamepadconnected: gamepadconnected,
9905 gamepaddisconnected: gamepaddisconnected,
9906 gotpointercapture: gotpointercapture,
9907 hashchange: hashchange,
9908 lostpointercapture: lostpointercapture,
9909 input: input,
9910 invalid: invalid,
9911 keydown: keydown,
9912 keypress: keypress,
9913 keyup: keyup,
9914 languagechange: languagechange,
9915 levelchange: levelchange,
9916 load: load,
9917 loadeddata: loadeddata,
9918 loadedmetadata: loadedmetadata,
9919 loadend: loadend,
9920 loadstart: loadstart,
9921 mark: mark,
9922 message: message,
9923 messageerror: messageerror,
9924 mousedown: mousedown,
9925 mouseenter: mouseenter,
9926 mouseleave: mouseleave,
9927 mousemove: mousemove,
9928 mouseout: mouseout,
9929 mouseover: mouseover,
9930 mouseup: mouseup,
9931 nomatch: nomatch,
9932 notificationclick: notificationclick,
9933 noupdate: noupdate,
9934 obsolete: obsolete,
9935 offline: offline,
9936 online: online,
9937 open: open,
9938 orientationchange: orientationchange,
9939 pagehide: pagehide,
9940 pageshow: pageshow,
9941 paste: paste,
9942 pause: pause,
9943 pointercancel: pointercancel,
9944 pointerdown: pointerdown,
9945 pointerenter: pointerenter,
9946 pointerleave: pointerleave,
9947 pointerlockchange: pointerlockchange,
9948 pointerlockerror: pointerlockerror,
9949 pointermove: pointermove,
9950 pointerout: pointerout,
9951 pointerover: pointerover,
9952 pointerup: pointerup,
9953 play: play,
9954 playing: playing,
9955 popstate: popstate,
9956 progress: progress,
9957 push: push,
9958 pushsubscriptionchange: pushsubscriptionchange,
9959 ratechange: ratechange,
9960 readystatechange: readystatechange,
9961 repeatEvent: repeatEvent,
9962 reset: reset,
9963 resize: resize,
9964 resourcetimingbufferfull: resourcetimingbufferfull,
9965 result: result,
9966 resume: resume,
9967 scroll: scroll,
9968 seeked: seeked,
9969 seeking: seeking,
9970 select: select,
9971 selectstart: selectstart,
9972 selectionchange: selectionchange,
9973 show: show,
9974 slotchange: slotchange,
9975 soundend: soundend,
9976 soundstart: soundstart,
9977 speechend: speechend,
9978 speechstart: speechstart,
9979 stalled: stalled,
9980 start: start,
9981 storage: storage,
9982 submit: submit,
9983 success: success,
9984 suspend: suspend,
9985 SVGAbort: SVGAbort,
9986 SVGError: SVGError,
9987 SVGLoad: SVGLoad,
9988 SVGResize: SVGResize,
9989 SVGScroll: SVGScroll,
9990 SVGUnload: SVGUnload,
9991 SVGZoom: SVGZoom,
9992 timeout: timeout,
9993 timeupdate: timeupdate,
9994 touchcancel: touchcancel,
9995 touchend: touchend,
9996 touchmove: touchmove,
9997 touchstart: touchstart,
9998 transitionend: transitionend,
9999 unload: unload,
10000 updateready: updateready,
10001 userproximity: userproximity,
10002 voiceschanged: voiceschanged,
10003 visibilitychange: visibilitychange,
10004 volumechange: volumechange,
10005 waiting: waiting,
10006 wheel: wheel
10007};
10008
10009var domEventTypes$1 = /*#__PURE__*/Object.freeze({
10010 __proto__: null,
10011 abort: abort,
10012 afterprint: afterprint,
10013 animationend: animationend,
10014 animationiteration: animationiteration,
10015 animationstart: animationstart,
10016 appinstalled: appinstalled,
10017 audioprocess: audioprocess,
10018 audioend: audioend,
10019 audiostart: audiostart,
10020 beforeprint: beforeprint,
10021 beforeunload: beforeunload,
10022 beginEvent: beginEvent,
10023 blur: blur,
10024 boundary: boundary,
10025 cached: cached,
10026 canplay: canplay,
10027 canplaythrough: canplaythrough,
10028 change: change,
10029 chargingchange: chargingchange,
10030 chargingtimechange: chargingtimechange,
10031 checking: checking,
10032 click: click,
10033 close: close,
10034 complete: complete,
10035 compositionend: compositionend,
10036 compositionstart: compositionstart,
10037 compositionupdate: compositionupdate,
10038 contextmenu: contextmenu,
10039 copy: copy,
10040 cut: cut,
10041 dblclick: dblclick,
10042 devicechange: devicechange,
10043 devicelight: devicelight,
10044 devicemotion: devicemotion,
10045 deviceorientation: deviceorientation,
10046 deviceproximity: deviceproximity,
10047 dischargingtimechange: dischargingtimechange,
10048 DOMActivate: DOMActivate,
10049 DOMAttributeNameChanged: DOMAttributeNameChanged,
10050 DOMAttrModified: DOMAttrModified,
10051 DOMCharacterDataModified: DOMCharacterDataModified,
10052 DOMContentLoaded: DOMContentLoaded,
10053 DOMElementNameChanged: DOMElementNameChanged,
10054 DOMFocusIn: DOMFocusIn,
10055 DOMFocusOut: DOMFocusOut,
10056 DOMNodeInserted: DOMNodeInserted,
10057 DOMNodeInsertedIntoDocument: DOMNodeInsertedIntoDocument,
10058 DOMNodeRemoved: DOMNodeRemoved,
10059 DOMNodeRemovedFromDocument: DOMNodeRemovedFromDocument,
10060 DOMSubtreeModified: DOMSubtreeModified,
10061 downloading: downloading,
10062 drag: drag,
10063 dragend: dragend,
10064 dragenter: dragenter,
10065 dragleave: dragleave,
10066 dragover: dragover,
10067 dragstart: dragstart,
10068 drop: drop,
10069 durationchange: durationchange,
10070 emptied: emptied,
10071 end: end,
10072 ended: ended,
10073 endEvent: endEvent,
10074 error: error,
10075 focus: focus,
10076 focusin: focusin,
10077 focusout: focusout,
10078 fullscreenchange: fullscreenchange,
10079 fullscreenerror: fullscreenerror,
10080 gamepadconnected: gamepadconnected,
10081 gamepaddisconnected: gamepaddisconnected,
10082 gotpointercapture: gotpointercapture,
10083 hashchange: hashchange,
10084 lostpointercapture: lostpointercapture,
10085 input: input,
10086 invalid: invalid,
10087 keydown: keydown,
10088 keypress: keypress,
10089 keyup: keyup,
10090 languagechange: languagechange,
10091 levelchange: levelchange,
10092 load: load,
10093 loadeddata: loadeddata,
10094 loadedmetadata: loadedmetadata,
10095 loadend: loadend,
10096 loadstart: loadstart,
10097 mark: mark,
10098 message: message,
10099 messageerror: messageerror,
10100 mousedown: mousedown,
10101 mouseenter: mouseenter,
10102 mouseleave: mouseleave,
10103 mousemove: mousemove,
10104 mouseout: mouseout,
10105 mouseover: mouseover,
10106 mouseup: mouseup,
10107 nomatch: nomatch,
10108 notificationclick: notificationclick,
10109 noupdate: noupdate,
10110 obsolete: obsolete,
10111 offline: offline,
10112 online: online,
10113 open: open,
10114 orientationchange: orientationchange,
10115 pagehide: pagehide,
10116 pageshow: pageshow,
10117 paste: paste,
10118 pause: pause,
10119 pointercancel: pointercancel,
10120 pointerdown: pointerdown,
10121 pointerenter: pointerenter,
10122 pointerleave: pointerleave,
10123 pointerlockchange: pointerlockchange,
10124 pointerlockerror: pointerlockerror,
10125 pointermove: pointermove,
10126 pointerout: pointerout,
10127 pointerover: pointerover,
10128 pointerup: pointerup,
10129 play: play,
10130 playing: playing,
10131 popstate: popstate,
10132 progress: progress,
10133 push: push,
10134 pushsubscriptionchange: pushsubscriptionchange,
10135 ratechange: ratechange,
10136 readystatechange: readystatechange,
10137 repeatEvent: repeatEvent,
10138 reset: reset,
10139 resize: resize,
10140 resourcetimingbufferfull: resourcetimingbufferfull,
10141 result: result,
10142 resume: resume,
10143 scroll: scroll,
10144 seeked: seeked,
10145 seeking: seeking,
10146 select: select,
10147 selectstart: selectstart,
10148 selectionchange: selectionchange,
10149 show: show,
10150 slotchange: slotchange,
10151 soundend: soundend,
10152 soundstart: soundstart,
10153 speechend: speechend,
10154 speechstart: speechstart,
10155 stalled: stalled,
10156 start: start,
10157 storage: storage,
10158 submit: submit,
10159 success: success,
10160 suspend: suspend,
10161 SVGAbort: SVGAbort,
10162 SVGError: SVGError,
10163 SVGLoad: SVGLoad,
10164 SVGResize: SVGResize,
10165 SVGScroll: SVGScroll,
10166 SVGUnload: SVGUnload,
10167 SVGZoom: SVGZoom,
10168 timeout: timeout,
10169 timeupdate: timeupdate,
10170 touchcancel: touchcancel,
10171 touchend: touchend,
10172 touchmove: touchmove,
10173 touchstart: touchstart,
10174 transitionend: transitionend,
10175 unload: unload,
10176 updateready: updateready,
10177 userproximity: userproximity,
10178 voiceschanged: voiceschanged,
10179 visibilitychange: visibilitychange,
10180 volumechange: volumechange,
10181 waiting: waiting,
10182 wheel: wheel,
10183 'default': domEventTypes
10184});
10185
10186var require$$0 = getCjsExportFromNamespace(domEventTypes$1);
10187
10188var domEventTypes$2 = require$$0;
10189
10190var defaultEventType = {
10191 eventInterface: 'Event',
10192 cancelable: true,
10193 bubbles: true
10194};
10195
10196var modifiers = {
10197 enter: 13,
10198 tab: 9,
10199 delete: 46,
10200 esc: 27,
10201 space: 32,
10202 up: 38,
10203 down: 40,
10204 left: 37,
10205 right: 39,
10206 end: 35,
10207 home: 36,
10208 backspace: 8,
10209 insert: 45,
10210 pageup: 33,
10211 pagedown: 34
10212};
10213
10214function getOptions(eventParams) {
10215 var modifier = eventParams.modifier;
10216 var meta = eventParams.meta;
10217 var options = eventParams.options;
10218 var keyCode = modifiers[modifier] || options.keyCode || options.code;
10219
10220 return Object.assign({}, options, // What the user passed in as the second argument to #trigger
10221
10222 {bubbles: meta.bubbles,
10223 cancelable: meta.cancelable,
10224
10225 // Any derived options should go here
10226 keyCode: keyCode,
10227 code: keyCode})
10228}
10229
10230function createEvent(eventParams) {
10231 var eventType = eventParams.eventType;
10232 var meta = eventParams.meta; if ( meta === void 0 ) meta = {};
10233
10234 var SupportedEventInterface =
10235 typeof window[meta.eventInterface] === 'function'
10236 ? window[meta.eventInterface]
10237 : window.Event;
10238
10239 var event = new SupportedEventInterface(
10240 eventType,
10241 // event properties can only be added when the event is instantiated
10242 // custom properties must be added after the event has been instantiated
10243 getOptions(eventParams)
10244 );
10245
10246 return event
10247}
10248
10249function createOldEvent(eventParams) {
10250 var eventType = eventParams.eventType;
10251 var modifier = eventParams.modifier;
10252 var meta = eventParams.meta;
10253 var bubbles = meta.bubbles;
10254 var cancelable = meta.cancelable;
10255
10256 var event = document.createEvent('Event');
10257 event.initEvent(eventType, bubbles, cancelable);
10258 event.keyCode = modifiers[modifier];
10259 return event
10260}
10261
10262function createDOMEvent(type, options) {
10263 var ref = type.split('.');
10264 var eventType = ref[0];
10265 var modifier = ref[1];
10266 var meta = domEventTypes$2[eventType] || defaultEventType;
10267
10268 var eventParams = { eventType: eventType, modifier: modifier, meta: meta, options: options };
10269
10270 // Fallback for IE10,11 - https://stackoverflow.com/questions/26596123
10271 var event =
10272 typeof window.Event === 'function'
10273 ? createEvent(eventParams)
10274 : createOldEvent(eventParams);
10275
10276 var eventPrototype = Object.getPrototypeOf(event);
10277 Object.keys(options || {}).forEach(function (key) {
10278 var propertyDescriptor = Object.getOwnPropertyDescriptor(
10279 eventPrototype,
10280 key
10281 );
10282
10283 var canSetProperty = !(
10284 propertyDescriptor && propertyDescriptor.setter === undefined
10285 );
10286 if (canSetProperty) {
10287 event[key] = options[key];
10288 }
10289 });
10290
10291 return event
10292}
10293
10294//
10295
10296var Wrapper = function Wrapper(
10297 node,
10298 options,
10299 isVueWrapper
10300) {
10301 var vnode = node instanceof Element ? null : node;
10302 var element = node instanceof Element ? node : node.elm;
10303 // Prevent redefine by VueWrapper
10304 if (!isVueWrapper) {
10305 // $FlowIgnore : issue with defineProperty
10306 Object.defineProperty(this, 'rootNode', {
10307 get: function () { return vnode || element; },
10308 set: function () { return throwError('wrapper.rootNode is read-only'); }
10309 });
10310 // $FlowIgnore
10311 Object.defineProperty(this, 'vnode', {
10312 get: function () { return vnode; },
10313 set: function () { return throwError('wrapper.vnode is read-only'); }
10314 });
10315 // $FlowIgnore
10316 Object.defineProperty(this, 'element', {
10317 get: function () { return element; },
10318 set: function () { return throwError('wrapper.element is read-only'); }
10319 });
10320 // $FlowIgnore
10321 Object.defineProperty(this, 'vm', {
10322 get: function () { return undefined; },
10323 set: function () { return throwError('wrapper.vm is read-only'); }
10324 });
10325 }
10326 var frozenOptions = Object.freeze(options);
10327 // $FlowIgnore
10328 Object.defineProperty(this, 'options', {
10329 get: function () { return frozenOptions; },
10330 set: function () { return throwError('wrapper.options is read-only'); }
10331 });
10332 if (
10333 this.vnode &&
10334 (this.vnode[FUNCTIONAL_OPTIONS] || this.vnode.functionalContext)
10335 ) {
10336 this.isFunctionalComponent = true;
10337 }
10338};
10339
10340Wrapper.prototype.at = function at () {
10341 throwError('at() must be called on a WrapperArray');
10342};
10343
10344/**
10345 * Returns an Object containing all the attribute/value pairs on the element.
10346 */
10347Wrapper.prototype.attributes = function attributes (key) {
10348 var attributes = this.element.attributes;
10349 var attributeMap = {};
10350 for (var i = 0; i < attributes.length; i++) {
10351 var att = attributes.item(i);
10352 attributeMap[att.localName] = att.value;
10353 }
10354
10355 return key ? attributeMap[key] : attributeMap
10356};
10357
10358/**
10359 * Returns an Array containing all the classes on the element
10360 */
10361Wrapper.prototype.classes = function classes (className) {
10362 var this$1 = this;
10363
10364 var classAttribute = this.element.getAttribute('class');
10365 var classes = classAttribute ? classAttribute.split(' ') : [];
10366 // Handle converting cssmodules identifiers back to the original class name
10367 if (this.vm && this.vm.$style) {
10368 var cssModuleIdentifiers = Object.keys(this.vm.$style).reduce(
10369 function (acc, key) {
10370 // $FlowIgnore
10371 var moduleIdent = this$1.vm.$style[key];
10372 if (moduleIdent) {
10373 acc[moduleIdent.split(' ')[0]] = key;
10374 }
10375 return acc
10376 },
10377 {}
10378 );
10379 classes = classes.map(function (name) { return cssModuleIdentifiers[name] || name; });
10380 }
10381
10382 return className ? !!(classes.indexOf(className) > -1) : classes
10383};
10384
10385/**
10386 * Checks if wrapper contains provided selector.
10387 * @deprecated
10388 */
10389Wrapper.prototype.contains = function contains (rawSelector) {
10390 warnDeprecated(
10391 'contains',
10392 'Use `wrapper.find`, `wrapper.findComponent` or `wrapper.get` instead'
10393 );
10394 var selector = getSelector(rawSelector, 'contains');
10395 var nodes = find(this.rootNode, this.vm, selector);
10396 return nodes.length > 0
10397};
10398
10399/**
10400 * Calls destroy on vm
10401 */
10402Wrapper.prototype.destroy = function destroy () {
10403 if (!this.vm && !this.isFunctionalComponent) {
10404 throwError(
10405 "wrapper.destroy() can only be called on a Vue instance or " +
10406 "functional component."
10407 );
10408 }
10409
10410 if (this.element.parentNode) {
10411 this.element.parentNode.removeChild(this.element);
10412 }
10413
10414 if (this.vm) {
10415 // $FlowIgnore
10416 this.vm.$destroy();
10417 throwIfInstancesThrew(this.vm);
10418 }
10419};
10420
10421/**
10422 * Returns an object containing custom events emitted by the Wrapper vm
10423 */
10424Wrapper.prototype.emitted = function emitted (
10425 event
10426) {
10427 if (!this._emitted && !this.vm) {
10428 throwError("wrapper.emitted() can only be called on a Vue instance");
10429 }
10430 if (event) {
10431 return this._emitted[event]
10432 }
10433 return this._emitted
10434};
10435
10436/**
10437 * Returns an Array containing custom events emitted by the Wrapper vm
10438 * @deprecated
10439 */
10440Wrapper.prototype.emittedByOrder = function emittedByOrder () {
10441 warnDeprecated('emittedByOrder', 'Use `wrapper.emitted` instead');
10442 if (!this._emittedByOrder && !this.vm) {
10443 throwError(
10444 "wrapper.emittedByOrder() can only be called on a Vue instance"
10445 );
10446 }
10447 return this._emittedByOrder
10448};
10449
10450/**
10451 * Utility to check wrapper exists. Returns true as Wrapper always exists
10452 */
10453Wrapper.prototype.exists = function exists () {
10454 if (this.vm) {
10455 return !!this.vm && !this.vm._isDestroyed
10456 }
10457 return true
10458};
10459
10460Wrapper.prototype.filter = function filter () {
10461 throwError('filter() must be called on a WrapperArray');
10462};
10463
10464/**
10465 * Gets first node in tree of the current wrapper that
10466 * matches the provided selector.
10467 */
10468Wrapper.prototype.get = function get (rawSelector) {
10469 var found = this.find(rawSelector);
10470 if (found instanceof ErrorWrapper) {
10471 throw new Error(("Unable to find " + rawSelector + " within: " + (this.html())))
10472 }
10473 return found
10474};
10475
10476/**
10477 * Finds first DOM node in tree of the current wrapper that
10478 * matches the provided selector.
10479 */
10480Wrapper.prototype.find = function find (rawSelector) {
10481 var selector = getSelector(rawSelector, 'find');
10482 if (selector.type !== DOM_SELECTOR) {
10483 warnDeprecated(
10484 'finding components with `find`',
10485 'Use `findComponent` instead'
10486 );
10487 }
10488
10489 return this.__find(rawSelector, selector)
10490};
10491
10492/**
10493 * Finds first component in tree of the current wrapper that
10494 * matches the provided selector.
10495 */
10496Wrapper.prototype.findComponent = function findComponent (rawSelector) {
10497 var selector = getSelector(rawSelector, 'findComponent');
10498 if (!this.vm && !this.isFunctionalComponent) {
10499 throwError(
10500 'You cannot chain findComponent off a DOM element. It can only be used on Vue Components.'
10501 );
10502 }
10503
10504 if (selector.type === DOM_SELECTOR) {
10505 throwError(
10506 'findComponent requires a Vue constructor or valid find object. If you are searching for DOM nodes, use `find` instead'
10507 );
10508 }
10509
10510 return this.__find(rawSelector, selector)
10511};
10512
10513Wrapper.prototype.__find = function __find (rawSelector, selector) {
10514 var node = find(this.rootNode, this.vm, selector)[0];
10515
10516 if (!node) {
10517 return new ErrorWrapper(rawSelector)
10518 }
10519
10520 var wrapper = createWrapper(node, this.options);
10521 wrapper.selector = rawSelector;
10522 return wrapper
10523};
10524
10525/**
10526 * Finds DOM elements in tree of the current wrapper that matches
10527 * the provided selector.
10528 */
10529Wrapper.prototype.findAll = function findAll (rawSelector) {
10530 var selector = getSelector(rawSelector, 'findAll');
10531 if (selector.type !== DOM_SELECTOR) {
10532 warnDeprecated(
10533 'finding components with `findAll`',
10534 'Use `findAllComponents` instead'
10535 );
10536 }
10537 return this.__findAll(rawSelector, selector)
10538};
10539
10540/**
10541 * Finds components in tree of the current wrapper that matches
10542 * the provided selector.
10543 */
10544Wrapper.prototype.findAllComponents = function findAllComponents (rawSelector) {
10545 var selector = getSelector(rawSelector, 'findAll');
10546 if (!this.vm) {
10547 throwError(
10548 'You cannot chain findAllComponents off a DOM element. It can only be used on Vue Components.'
10549 );
10550 }
10551 if (selector.type === DOM_SELECTOR) {
10552 throwError(
10553 'findAllComponents requires a Vue constructor or valid find object. If you are searching for DOM nodes, use `find` instead'
10554 );
10555 }
10556 return this.__findAll(rawSelector, selector)
10557};
10558
10559Wrapper.prototype.__findAll = function __findAll (rawSelector, selector) {
10560 var this$1 = this;
10561
10562 var nodes = find(this.rootNode, this.vm, selector);
10563 var wrappers = nodes.map(function (node) {
10564 // Using CSS Selector, returns a VueWrapper instance if the root element
10565 // binds a Vue instance.
10566 var wrapper = createWrapper(node, this$1.options);
10567 wrapper.selector = rawSelector;
10568 return wrapper
10569 });
10570
10571 var wrapperArray = new WrapperArray(wrappers);
10572 wrapperArray.selector = rawSelector;
10573 return wrapperArray
10574};
10575
10576/**
10577 * Returns HTML of element as a string
10578 */
10579Wrapper.prototype.html = function html () {
10580 return pretty(this.element.outerHTML)
10581};
10582
10583/**
10584 * Checks if node matches selector
10585 * @deprecated
10586 */
10587Wrapper.prototype.is = function is (rawSelector) {
10588 warnDeprecated('is', 'Use element.tagName instead');
10589 var selector = getSelector(rawSelector, 'is');
10590
10591 if (selector.type === REF_SELECTOR) {
10592 throwError('$ref selectors can not be used with wrapper.is()');
10593 }
10594
10595 return matches(this.rootNode, selector)
10596};
10597
10598/**
10599 * Checks if node is empty
10600 * @deprecated
10601 */
10602Wrapper.prototype.isEmpty = function isEmpty () {
10603 warnDeprecated(
10604 'isEmpty',
10605 'Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobeempty. ' +
10606 'When using with findComponent, access the DOM element with findComponent(Comp).element'
10607 );
10608 if (!this.vnode) {
10609 return this.element.innerHTML === ''
10610 }
10611 var nodes = [];
10612 var node = this.vnode;
10613 var i = 0;
10614
10615 while (node) {
10616 if (node.child) {
10617 nodes.push(node.child._vnode);
10618 }
10619 node.children &&
10620 node.children.forEach(function (n) {
10621 nodes.push(n);
10622 });
10623 node = nodes[i++];
10624 }
10625 return nodes.every(function (n) { return n.isComment || n.child; })
10626};
10627
10628/**
10629 * Checks if node is visible
10630 * @deprecated
10631 */
10632Wrapper.prototype.isVisible = function isVisible () {
10633 warnDeprecated(
10634 'isVisible',
10635 'Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobevisible. ' +
10636 'When using with findComponent, access the DOM element with findComponent(Comp).element'
10637 );
10638 var element = this.element;
10639 while (element) {
10640 if (
10641 element.hidden ||
10642 (element.style &&
10643 (element.style.visibility === 'hidden' ||
10644 element.style.display === 'none'))
10645 ) {
10646 return false
10647 }
10648 element = element.parentElement;
10649 }
10650
10651 return true
10652};
10653
10654/**
10655 * Checks if wrapper is a vue instance
10656 * @deprecated
10657 */
10658Wrapper.prototype.isVueInstance = function isVueInstance () {
10659 warnDeprecated("isVueInstance");
10660 return !!this.vm
10661};
10662
10663/**
10664 * Returns name of component, or tag name if node is not a Vue component
10665 * @deprecated
10666 */
10667Wrapper.prototype.name = function name () {
10668 warnDeprecated("name");
10669
10670 if (this.vm) {
10671 return (
10672 this.vm.$options.name ||
10673 // compat for Vue < 2.3
10674 (this.vm.$options.extendOptions && this.vm.$options.extendOptions.name)
10675 )
10676 }
10677
10678 if (!this.vnode) {
10679 return this.element.tagName
10680 }
10681
10682 return this.vnode.tag
10683};
10684
10685/**
10686 * Prints a simple overview of the wrapper current state
10687 * with useful information for debugging
10688 * @deprecated
10689 */
10690Wrapper.prototype.overview = function overview () {
10691 var this$1 = this;
10692
10693 warnDeprecated("overview");
10694
10695 if (!this.vm) {
10696 throwError("wrapper.overview() can only be called on a Vue instance");
10697 }
10698
10699 var identation = 4;
10700 var formatJSON = function (json, replacer) {
10701 if ( replacer === void 0 ) replacer = null;
10702
10703 return JSON.stringify(json, replacer, identation).replace(/"/g, '');
10704 };
10705
10706 var visibility = this.isVisible() ? 'Visible' : 'Not visible';
10707
10708 var html = this.html()
10709 ? this.html().replace(/^(?!\s*$)/gm, ' '.repeat(identation)) + '\n'
10710 : '';
10711
10712 // $FlowIgnore
10713 var data = formatJSON(this.vm.$data);
10714
10715 /* eslint-disable operator-linebreak */
10716 // $FlowIgnore
10717 var computed = this.vm._computedWatchers
10718 ? formatJSON.apply(
10719 // $FlowIgnore
10720 void 0, Object.keys(this.vm._computedWatchers).map(function (computedKey) {
10721 var obj;
10722
10723 return (( obj = {}, obj[computedKey] = this$1.vm[computedKey], obj ));
10724 })
10725 )
10726 : // $FlowIgnore
10727 this.vm.$options.computed
10728 ? formatJSON.apply(
10729 // $FlowIgnore
10730 void 0, Object.entries(this.vm.$options.computed).map(function (ref) {
10731 var obj;
10732
10733 var key = ref[0];
10734 var value = ref[1];
10735 return (( obj = {}, obj[key] = value(), obj ));
10736 })
10737 )
10738 : '{}';
10739 /* eslint-enable operator-linebreak */
10740
10741 var emittedJSONReplacer = function (key, value) { return value instanceof Array
10742 ? value.map(function (calledWith, index) {
10743 var callParams = calledWith.map(function (param) { return typeof param === 'object'
10744 ? JSON.stringify(param)
10745 .replace(/"/g, '')
10746 .replace(/,/g, ', ')
10747 : param; }
10748 );
10749
10750 return (index + ": [ " + (callParams.join(', ')) + " ]")
10751 })
10752 : value; };
10753
10754 var emitted = formatJSON(this.emitted(), emittedJSONReplacer);
10755
10756 console.log(
10757 '\n' +
10758 "Wrapper (" + visibility + "):\n\n" +
10759 "Html:\n" + html + "\n" +
10760 "Data: " + data + "\n\n" +
10761 "Computed: " + computed + "\n\n" +
10762 "Emitted: " + emitted + "\n"
10763 );
10764};
10765
10766/**
10767 * Returns an Object containing the prop name/value pairs on the element
10768 */
10769Wrapper.prototype.props = function props (key) {
10770 var this$1 = this;
10771
10772 if (this.isFunctionalComponent) {
10773 throwError(
10774 "wrapper.props() cannot be called on a mounted functional component."
10775 );
10776 }
10777 if (!this.vm) {
10778 throwError('wrapper.props() must be called on a Vue instance');
10779 }
10780
10781 var props = {};
10782 var keys = this.vm && this.vm.$options._propKeys;
10783
10784 if (keys) {
10785(keys || {}).forEach(function (key) {
10786 if (this$1.vm) {
10787 props[key] = this$1.vm[key];
10788 }
10789 });
10790 }
10791
10792 if (key) {
10793 return props[key]
10794 }
10795
10796 return props
10797};
10798
10799/**
10800 * Checks radio button or checkbox element
10801 * @deprecated
10802 */
10803Wrapper.prototype.setChecked = function setChecked (checked) {
10804 if ( checked === void 0 ) checked = true;
10805
10806 if (typeof checked !== 'boolean') {
10807 throwError('wrapper.setChecked() must be passed a boolean');
10808 }
10809 var tagName = this.element.tagName;
10810 // $FlowIgnore
10811 var type = this.attributes().type;
10812 var event = getCheckedEvent();
10813
10814 if (tagName === 'INPUT' && type === 'checkbox') {
10815 if (this.element.checked === checked) {
10816 return nextTick()
10817 }
10818 if (event !== 'click' || isPhantomJS) {
10819 // $FlowIgnore
10820 this.element.checked = checked;
10821 }
10822 return this.trigger(event)
10823 }
10824
10825 if (tagName === 'INPUT' && type === 'radio') {
10826 if (!checked) {
10827 throwError(
10828 "wrapper.setChecked() cannot be called with parameter false on a " +
10829 "<input type=\"radio\" /> element."
10830 );
10831 }
10832
10833 if (this.element.checked === checked) {
10834 return nextTick()
10835 }
10836
10837 if (event !== 'click' || isPhantomJS) {
10838 // $FlowIgnore
10839 this.element.selected = true;
10840 }
10841 return this.trigger(event)
10842 }
10843
10844 throwError("wrapper.setChecked() cannot be called on this element");
10845 return nextTick()
10846};
10847
10848/**
10849 * Selects <option></option> element
10850 * @deprecated
10851 */
10852Wrapper.prototype.setSelected = function setSelected () {
10853 var tagName = this.element.tagName;
10854
10855 if (tagName === 'SELECT') {
10856 throwError(
10857 "wrapper.setSelected() cannot be called on select. Call it on one of " +
10858 "its options"
10859 );
10860 }
10861
10862 if (tagName !== 'OPTION') {
10863 throwError("wrapper.setSelected() cannot be called on this element");
10864 }
10865
10866 if (this.element.selected) {
10867 return nextTick()
10868 }
10869
10870 // $FlowIgnore
10871 this.element.selected = true;
10872 // $FlowIgnore
10873 var parentElement = this.element.parentElement;
10874
10875 // $FlowIgnore
10876 if (parentElement.tagName === 'OPTGROUP') {
10877 // $FlowIgnore
10878 parentElement = parentElement.parentElement;
10879 }
10880
10881 // $FlowIgnore
10882 return createWrapper(parentElement, this.options).trigger('change')
10883};
10884
10885/**
10886 * Sets vm data
10887 */
10888Wrapper.prototype.setData = function setData (data) {
10889 if (this.isFunctionalComponent) {
10890 throwError("wrapper.setData() cannot be called on a functional component");
10891 }
10892
10893 if (!this.vm) {
10894 throwError("wrapper.setData() can only be called on a Vue instance");
10895 }
10896
10897 recursivelySetData(this.vm, this.vm, data);
10898 return nextTick()
10899};
10900
10901/**
10902 * Sets vm methods
10903 * @deprecated
10904 */
10905Wrapper.prototype.setMethods = function setMethods (methods) {
10906 var this$1 = this;
10907
10908 warnDeprecated(
10909 "setMethods",
10910 "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"
10911 );
10912
10913 if (!this.vm) {
10914 throwError("wrapper.setMethods() can only be called on a Vue instance");
10915 }
10916 Object.keys(methods).forEach(function (key) {
10917 // $FlowIgnore : Problem with possibly null this.vm
10918 this$1.vm[key] = methods[key];
10919 // $FlowIgnore : Problem with possibly null this.vm
10920 this$1.vm.$options.methods[key] = methods[key];
10921 });
10922
10923 if (this.vnode) {
10924 var context = this.vnode.context;
10925 if (context.$options.render) { context._update(context._render()); }
10926 }
10927};
10928
10929/**
10930 * Sets vm props
10931 */
10932Wrapper.prototype.setProps = function setProps (data) {
10933 var this$1 = this;
10934
10935 // Validate the setProps method call
10936 if (this.isFunctionalComponent) {
10937 throwError(
10938 "wrapper.setProps() cannot be called on a functional component"
10939 );
10940 }
10941
10942 if (!this.vm) {
10943 throwError("wrapper.setProps() can only be called on a Vue instance");
10944 }
10945
10946 // Save the original "silent" config so that we can directly mutate props
10947 var originalConfig = Vue.config.silent;
10948 Vue.config.silent = config.silent;
10949
10950 try {
10951 Object.keys(data).forEach(function (key) {
10952 // Don't let people set entire objects, because reactivity won't work
10953 if (
10954 typeof data[key] === 'object' &&
10955 data[key] !== null &&
10956 // $FlowIgnore : Problem with possibly null this.vm
10957 data[key] === this$1.vm[key]
10958 ) {
10959 throwError(
10960 "wrapper.setProps() called with the same object of the existing " +
10961 key + " property. You must call wrapper.setProps() with a new " +
10962 "object to trigger reactivity"
10963 );
10964 }
10965
10966 if (
10967 !this$1.vm ||
10968 !this$1.vm.$options._propKeys ||
10969 !this$1.vm.$options._propKeys.some(function (prop) { return prop === key; })
10970 ) {
10971 if (VUE_VERSION > 2.3) {
10972 // $FlowIgnore : Problem with possibly null this.vm
10973 this$1.vm.$attrs[key] = data[key];
10974 return nextTick()
10975 }
10976 throwError(
10977 "wrapper.setProps() called with " + key + " property which " +
10978 "is not defined on the component"
10979 );
10980 }
10981
10982 // Actually set the prop
10983 // $FlowIgnore : Problem with possibly null this.vm
10984 this$1.vm[key] = data[key];
10985 });
10986
10987 // $FlowIgnore : Problem with possibly null this.vm
10988 this.vm.$forceUpdate();
10989 return new Promise(function (resolve) {
10990 nextTick().then(function () {
10991 var isUpdated = Object.keys(data).some(function (key) {
10992 return (
10993 // $FlowIgnore : Problem with possibly null this.vm
10994 this$1.vm[key] === data[key] ||
10995 // $FlowIgnore : Problem with possibly null this.vm
10996 (this$1.vm.$attrs && this$1.vm.$attrs[key] === data[key])
10997 )
10998 });
10999 return !isUpdated ? this$1.setProps(data).then(resolve()) : resolve()
11000 });
11001 })
11002 } catch (err) {
11003 throw err
11004 } finally {
11005 // Ensure you teardown the modifications you made to the user's config
11006 // After all the props are set, then reset the state
11007 Vue.config.silent = originalConfig;
11008 }
11009};
11010
11011/**
11012 * Sets element value and triggers input event
11013 */
11014Wrapper.prototype.setValue = function setValue (value) {
11015 var tagName = this.element.tagName;
11016 // $FlowIgnore
11017 var type = this.attributes().type;
11018
11019 if (tagName === 'OPTION') {
11020 throwError(
11021 "wrapper.setValue() cannot be called on an <option> element. Use " +
11022 "wrapper.setSelected() instead"
11023 );
11024 } else if (tagName === 'INPUT' && type === 'checkbox') {
11025 throwError(
11026 "wrapper.setValue() cannot be called on a <input type=\"checkbox\" /> " +
11027 "element. Use wrapper.setChecked() instead"
11028 );
11029 } else if (tagName === 'INPUT' && type === 'radio') {
11030 throwError(
11031 "wrapper.setValue() cannot be called on a <input type=\"radio\" /> " +
11032 "element. Use wrapper.setChecked() instead"
11033 );
11034 } else if (tagName === 'SELECT') {
11035 if (Array.isArray(value)) {
11036 // $FlowIgnore
11037 var options = this.element.options;
11038 for (var i = 0; i < options.length; i++) {
11039 var option = options[i];
11040 option.selected = value.indexOf(option.value) >= 0;
11041 }
11042 } else {
11043 // $FlowIgnore
11044 this.element.value = value;
11045 }
11046
11047 this.trigger('change');
11048 return nextTick()
11049 } else if (tagName === 'INPUT' || tagName === 'TEXTAREA') {
11050 // $FlowIgnore
11051 this.element.value = value;
11052
11053 this.trigger('input');
11054
11055 // for v-model.lazy, we need to trigger a change event, too.
11056 // $FlowIgnore
11057 if (this.element._vModifiers && this.element._vModifiers.lazy) {
11058 this.trigger('change');
11059 }
11060 return nextTick()
11061 }
11062 throwError("wrapper.setValue() cannot be called on this element");
11063 return nextTick()
11064};
11065
11066/**
11067 * Return text of wrapper element
11068 */
11069Wrapper.prototype.text = function text () {
11070 return this.element.textContent.trim()
11071};
11072
11073/**
11074 * Dispatches a DOM event on wrapper
11075 */
11076Wrapper.prototype.trigger = function trigger (type, options) {
11077 if ( options === void 0 ) options = {};
11078
11079 if (typeof type !== 'string') {
11080 throwError('wrapper.trigger() must be passed a string');
11081 }
11082
11083 if (options.target) {
11084 throwError(
11085 "you cannot set the target value of an event. See the notes section " +
11086 "of the docs for more details—" +
11087 "https://vue-test-utils.vuejs.org/api/wrapper/trigger.html"
11088 );
11089 }
11090
11091 /**
11092 * Avoids firing events on specific disabled elements
11093 * See more: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
11094 */
11095
11096 var supportedTags = [
11097 'BUTTON',
11098 'COMMAND',
11099 'FIELDSET',
11100 'KEYGEN',
11101 'OPTGROUP',
11102 'OPTION',
11103 'SELECT',
11104 'TEXTAREA',
11105 'INPUT'
11106 ];
11107 var tagName = this.element.tagName;
11108
11109 if (this.attributes().disabled && supportedTags.indexOf(tagName) > -1) {
11110 return nextTick()
11111 }
11112
11113 var event = createDOMEvent(type, options);
11114 this.element.dispatchEvent(event);
11115 return nextTick()
11116};
11117
11118//
11119
11120var VueWrapper = /*@__PURE__*/(function (Wrapper) {
11121 function VueWrapper(vm, options) {
11122 var this$1 = this;
11123
11124 Wrapper.call(this, vm._vnode, options, true);
11125 // $FlowIgnore : issue with defineProperty
11126 Object.defineProperty(this, 'rootNode', {
11127 get: function () { return vm.$vnode || { child: this$1.vm }; },
11128 set: function () { return throwError('wrapper.vnode is read-only'); }
11129 });
11130 // $FlowIgnore : issue with defineProperty
11131 Object.defineProperty(this, 'vnode', {
11132 get: function () { return vm._vnode; },
11133 set: function () { return throwError('wrapper.vnode is read-only'); }
11134 });
11135 // $FlowIgnore
11136 Object.defineProperty(this, 'element', {
11137 get: function () { return vm.$el; },
11138 set: function () { return throwError('wrapper.element is read-only'); }
11139 });
11140 // $FlowIgnore
11141 Object.defineProperty(this, 'vm', {
11142 get: function () { return vm; },
11143 set: function () { return throwError('wrapper.vm is read-only'); }
11144 });
11145 this.isFunctionalComponent = vm.$options._isFunctionalContainer;
11146 this._emitted = vm.__emitted;
11147 this._emittedByOrder = vm.__emittedByOrder;
11148 }
11149
11150 if ( Wrapper ) VueWrapper.__proto__ = Wrapper;
11151 VueWrapper.prototype = Object.create( Wrapper && Wrapper.prototype );
11152 VueWrapper.prototype.constructor = VueWrapper;
11153
11154 return VueWrapper;
11155}(Wrapper));
11156
11157//
11158
11159var isEnabled = false;
11160var wrapperInstances = [];
11161
11162function resetAutoDestroyState() {
11163 isEnabled = false;
11164 wrapperInstances.length = 0;
11165}
11166
11167function enableAutoDestroy(hook) {
11168 if (isEnabled) {
11169 throwError('enableAutoDestroy cannot be called more than once');
11170 }
11171
11172 isEnabled = true;
11173
11174 hook(function () {
11175 wrapperInstances.forEach(function (wrapper) {
11176 // skip child wrappers created by wrapper.find()
11177 if (wrapper.selector) { return }
11178
11179 wrapper.destroy();
11180 });
11181
11182 wrapperInstances.length = 0;
11183 });
11184}
11185
11186function trackInstance(wrapper) {
11187 if (!isEnabled) { return }
11188
11189 wrapperInstances.push(wrapper);
11190}
11191
11192//
11193
11194function createWrapper(
11195 node,
11196 options
11197) {
11198 if ( options === void 0 ) options = {};
11199
11200 var componentInstance = node.child;
11201 if (componentInstance) {
11202 var wrapper$1 = new VueWrapper(componentInstance, options);
11203 trackInstance(wrapper$1);
11204 return wrapper$1
11205 }
11206 var wrapper =
11207 node instanceof Vue
11208 ? new VueWrapper(node, options)
11209 : new Wrapper(node, options);
11210 trackInstance(wrapper);
11211 return wrapper
11212}
11213
11214/**
11215 * Removes all key-value entries from the list cache.
11216 *
11217 * @private
11218 * @name clear
11219 * @memberOf ListCache
11220 */
11221function listCacheClear() {
11222 this.__data__ = [];
11223 this.size = 0;
11224}
11225
11226var _listCacheClear = listCacheClear;
11227
11228/**
11229 * Performs a
11230 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
11231 * comparison between two values to determine if they are equivalent.
11232 *
11233 * @static
11234 * @memberOf _
11235 * @since 4.0.0
11236 * @category Lang
11237 * @param {*} value The value to compare.
11238 * @param {*} other The other value to compare.
11239 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11240 * @example
11241 *
11242 * var object = { 'a': 1 };
11243 * var other = { 'a': 1 };
11244 *
11245 * _.eq(object, object);
11246 * // => true
11247 *
11248 * _.eq(object, other);
11249 * // => false
11250 *
11251 * _.eq('a', 'a');
11252 * // => true
11253 *
11254 * _.eq('a', Object('a'));
11255 * // => false
11256 *
11257 * _.eq(NaN, NaN);
11258 * // => true
11259 */
11260function eq(value, other) {
11261 return value === other || (value !== value && other !== other);
11262}
11263
11264var eq_1 = eq;
11265
11266/**
11267 * Gets the index at which the `key` is found in `array` of key-value pairs.
11268 *
11269 * @private
11270 * @param {Array} array The array to inspect.
11271 * @param {*} key The key to search for.
11272 * @returns {number} Returns the index of the matched value, else `-1`.
11273 */
11274function assocIndexOf(array, key) {
11275 var length = array.length;
11276 while (length--) {
11277 if (eq_1(array[length][0], key)) {
11278 return length;
11279 }
11280 }
11281 return -1;
11282}
11283
11284var _assocIndexOf = assocIndexOf;
11285
11286/** Used for built-in method references. */
11287var arrayProto = Array.prototype;
11288
11289/** Built-in value references. */
11290var splice = arrayProto.splice;
11291
11292/**
11293 * Removes `key` and its value from the list cache.
11294 *
11295 * @private
11296 * @name delete
11297 * @memberOf ListCache
11298 * @param {string} key The key of the value to remove.
11299 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11300 */
11301function listCacheDelete(key) {
11302 var data = this.__data__,
11303 index = _assocIndexOf(data, key);
11304
11305 if (index < 0) {
11306 return false;
11307 }
11308 var lastIndex = data.length - 1;
11309 if (index == lastIndex) {
11310 data.pop();
11311 } else {
11312 splice.call(data, index, 1);
11313 }
11314 --this.size;
11315 return true;
11316}
11317
11318var _listCacheDelete = listCacheDelete;
11319
11320/**
11321 * Gets the list cache value for `key`.
11322 *
11323 * @private
11324 * @name get
11325 * @memberOf ListCache
11326 * @param {string} key The key of the value to get.
11327 * @returns {*} Returns the entry value.
11328 */
11329function listCacheGet(key) {
11330 var data = this.__data__,
11331 index = _assocIndexOf(data, key);
11332
11333 return index < 0 ? undefined : data[index][1];
11334}
11335
11336var _listCacheGet = listCacheGet;
11337
11338/**
11339 * Checks if a list cache value for `key` exists.
11340 *
11341 * @private
11342 * @name has
11343 * @memberOf ListCache
11344 * @param {string} key The key of the entry to check.
11345 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
11346 */
11347function listCacheHas(key) {
11348 return _assocIndexOf(this.__data__, key) > -1;
11349}
11350
11351var _listCacheHas = listCacheHas;
11352
11353/**
11354 * Sets the list cache `key` to `value`.
11355 *
11356 * @private
11357 * @name set
11358 * @memberOf ListCache
11359 * @param {string} key The key of the value to set.
11360 * @param {*} value The value to set.
11361 * @returns {Object} Returns the list cache instance.
11362 */
11363function listCacheSet(key, value) {
11364 var data = this.__data__,
11365 index = _assocIndexOf(data, key);
11366
11367 if (index < 0) {
11368 ++this.size;
11369 data.push([key, value]);
11370 } else {
11371 data[index][1] = value;
11372 }
11373 return this;
11374}
11375
11376var _listCacheSet = listCacheSet;
11377
11378/**
11379 * Creates an list cache object.
11380 *
11381 * @private
11382 * @constructor
11383 * @param {Array} [entries] The key-value pairs to cache.
11384 */
11385function ListCache(entries) {
11386 var index = -1,
11387 length = entries == null ? 0 : entries.length;
11388
11389 this.clear();
11390 while (++index < length) {
11391 var entry = entries[index];
11392 this.set(entry[0], entry[1]);
11393 }
11394}
11395
11396// Add methods to `ListCache`.
11397ListCache.prototype.clear = _listCacheClear;
11398ListCache.prototype['delete'] = _listCacheDelete;
11399ListCache.prototype.get = _listCacheGet;
11400ListCache.prototype.has = _listCacheHas;
11401ListCache.prototype.set = _listCacheSet;
11402
11403var _ListCache = ListCache;
11404
11405/**
11406 * Removes all key-value entries from the stack.
11407 *
11408 * @private
11409 * @name clear
11410 * @memberOf Stack
11411 */
11412function stackClear() {
11413 this.__data__ = new _ListCache;
11414 this.size = 0;
11415}
11416
11417var _stackClear = stackClear;
11418
11419/**
11420 * Removes `key` and its value from the stack.
11421 *
11422 * @private
11423 * @name delete
11424 * @memberOf Stack
11425 * @param {string} key The key of the value to remove.
11426 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11427 */
11428function stackDelete(key) {
11429 var data = this.__data__,
11430 result = data['delete'](key);
11431
11432 this.size = data.size;
11433 return result;
11434}
11435
11436var _stackDelete = stackDelete;
11437
11438/**
11439 * Gets the stack value for `key`.
11440 *
11441 * @private
11442 * @name get
11443 * @memberOf Stack
11444 * @param {string} key The key of the value to get.
11445 * @returns {*} Returns the entry value.
11446 */
11447function stackGet(key) {
11448 return this.__data__.get(key);
11449}
11450
11451var _stackGet = stackGet;
11452
11453/**
11454 * Checks if a stack value for `key` exists.
11455 *
11456 * @private
11457 * @name has
11458 * @memberOf Stack
11459 * @param {string} key The key of the entry to check.
11460 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
11461 */
11462function stackHas(key) {
11463 return this.__data__.has(key);
11464}
11465
11466var _stackHas = stackHas;
11467
11468/** Detect free variable `global` from Node.js. */
11469var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
11470
11471var _freeGlobal = freeGlobal;
11472
11473/** Detect free variable `self`. */
11474var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
11475
11476/** Used as a reference to the global object. */
11477var root = _freeGlobal || freeSelf || Function('return this')();
11478
11479var _root = root;
11480
11481/** Built-in value references. */
11482var Symbol = _root.Symbol;
11483
11484var _Symbol = Symbol;
11485
11486/** Used for built-in method references. */
11487var objectProto = Object.prototype;
11488
11489/** Used to check objects for own properties. */
11490var hasOwnProperty$1 = objectProto.hasOwnProperty;
11491
11492/**
11493 * Used to resolve the
11494 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
11495 * of values.
11496 */
11497var nativeObjectToString = objectProto.toString;
11498
11499/** Built-in value references. */
11500var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
11501
11502/**
11503 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
11504 *
11505 * @private
11506 * @param {*} value The value to query.
11507 * @returns {string} Returns the raw `toStringTag`.
11508 */
11509function getRawTag(value) {
11510 var isOwn = hasOwnProperty$1.call(value, symToStringTag),
11511 tag = value[symToStringTag];
11512
11513 try {
11514 value[symToStringTag] = undefined;
11515 var unmasked = true;
11516 } catch (e) {}
11517
11518 var result = nativeObjectToString.call(value);
11519 if (unmasked) {
11520 if (isOwn) {
11521 value[symToStringTag] = tag;
11522 } else {
11523 delete value[symToStringTag];
11524 }
11525 }
11526 return result;
11527}
11528
11529var _getRawTag = getRawTag;
11530
11531/** Used for built-in method references. */
11532var objectProto$1 = Object.prototype;
11533
11534/**
11535 * Used to resolve the
11536 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
11537 * of values.
11538 */
11539var nativeObjectToString$1 = objectProto$1.toString;
11540
11541/**
11542 * Converts `value` to a string using `Object.prototype.toString`.
11543 *
11544 * @private
11545 * @param {*} value The value to convert.
11546 * @returns {string} Returns the converted string.
11547 */
11548function objectToString(value) {
11549 return nativeObjectToString$1.call(value);
11550}
11551
11552var _objectToString = objectToString;
11553
11554/** `Object#toString` result references. */
11555var nullTag = '[object Null]',
11556 undefinedTag = '[object Undefined]';
11557
11558/** Built-in value references. */
11559var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
11560
11561/**
11562 * The base implementation of `getTag` without fallbacks for buggy environments.
11563 *
11564 * @private
11565 * @param {*} value The value to query.
11566 * @returns {string} Returns the `toStringTag`.
11567 */
11568function baseGetTag(value) {
11569 if (value == null) {
11570 return value === undefined ? undefinedTag : nullTag;
11571 }
11572 return (symToStringTag$1 && symToStringTag$1 in Object(value))
11573 ? _getRawTag(value)
11574 : _objectToString(value);
11575}
11576
11577var _baseGetTag = baseGetTag;
11578
11579/**
11580 * Checks if `value` is the
11581 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
11582 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
11583 *
11584 * @static
11585 * @memberOf _
11586 * @since 0.1.0
11587 * @category Lang
11588 * @param {*} value The value to check.
11589 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
11590 * @example
11591 *
11592 * _.isObject({});
11593 * // => true
11594 *
11595 * _.isObject([1, 2, 3]);
11596 * // => true
11597 *
11598 * _.isObject(_.noop);
11599 * // => true
11600 *
11601 * _.isObject(null);
11602 * // => false
11603 */
11604function isObject(value) {
11605 var type = typeof value;
11606 return value != null && (type == 'object' || type == 'function');
11607}
11608
11609var isObject_1 = isObject;
11610
11611/** `Object#toString` result references. */
11612var asyncTag = '[object AsyncFunction]',
11613 funcTag = '[object Function]',
11614 genTag = '[object GeneratorFunction]',
11615 proxyTag = '[object Proxy]';
11616
11617/**
11618 * Checks if `value` is classified as a `Function` object.
11619 *
11620 * @static
11621 * @memberOf _
11622 * @since 0.1.0
11623 * @category Lang
11624 * @param {*} value The value to check.
11625 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
11626 * @example
11627 *
11628 * _.isFunction(_);
11629 * // => true
11630 *
11631 * _.isFunction(/abc/);
11632 * // => false
11633 */
11634function isFunction(value) {
11635 if (!isObject_1(value)) {
11636 return false;
11637 }
11638 // The use of `Object#toString` avoids issues with the `typeof` operator
11639 // in Safari 9 which returns 'object' for typed arrays and other constructors.
11640 var tag = _baseGetTag(value);
11641 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
11642}
11643
11644var isFunction_1 = isFunction;
11645
11646/** Used to detect overreaching core-js shims. */
11647var coreJsData = _root['__core-js_shared__'];
11648
11649var _coreJsData = coreJsData;
11650
11651/** Used to detect methods masquerading as native. */
11652var maskSrcKey = (function() {
11653 var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
11654 return uid ? ('Symbol(src)_1.' + uid) : '';
11655}());
11656
11657/**
11658 * Checks if `func` has its source masked.
11659 *
11660 * @private
11661 * @param {Function} func The function to check.
11662 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
11663 */
11664function isMasked(func) {
11665 return !!maskSrcKey && (maskSrcKey in func);
11666}
11667
11668var _isMasked = isMasked;
11669
11670/** Used for built-in method references. */
11671var funcProto = Function.prototype;
11672
11673/** Used to resolve the decompiled source of functions. */
11674var funcToString = funcProto.toString;
11675
11676/**
11677 * Converts `func` to its source code.
11678 *
11679 * @private
11680 * @param {Function} func The function to convert.
11681 * @returns {string} Returns the source code.
11682 */
11683function toSource(func) {
11684 if (func != null) {
11685 try {
11686 return funcToString.call(func);
11687 } catch (e) {}
11688 try {
11689 return (func + '');
11690 } catch (e) {}
11691 }
11692 return '';
11693}
11694
11695var _toSource = toSource;
11696
11697/**
11698 * Used to match `RegExp`
11699 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
11700 */
11701var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
11702
11703/** Used to detect host constructors (Safari). */
11704var reIsHostCtor = /^\[object .+?Constructor\]$/;
11705
11706/** Used for built-in method references. */
11707var funcProto$1 = Function.prototype,
11708 objectProto$2 = Object.prototype;
11709
11710/** Used to resolve the decompiled source of functions. */
11711var funcToString$1 = funcProto$1.toString;
11712
11713/** Used to check objects for own properties. */
11714var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
11715
11716/** Used to detect if a method is native. */
11717var reIsNative = RegExp('^' +
11718 funcToString$1.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
11719 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
11720);
11721
11722/**
11723 * The base implementation of `_.isNative` without bad shim checks.
11724 *
11725 * @private
11726 * @param {*} value The value to check.
11727 * @returns {boolean} Returns `true` if `value` is a native function,
11728 * else `false`.
11729 */
11730function baseIsNative(value) {
11731 if (!isObject_1(value) || _isMasked(value)) {
11732 return false;
11733 }
11734 var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
11735 return pattern.test(_toSource(value));
11736}
11737
11738var _baseIsNative = baseIsNative;
11739
11740/**
11741 * Gets the value at `key` of `object`.
11742 *
11743 * @private
11744 * @param {Object} [object] The object to query.
11745 * @param {string} key The key of the property to get.
11746 * @returns {*} Returns the property value.
11747 */
11748function getValue(object, key) {
11749 return object == null ? undefined : object[key];
11750}
11751
11752var _getValue = getValue;
11753
11754/**
11755 * Gets the native function at `key` of `object`.
11756 *
11757 * @private
11758 * @param {Object} object The object to query.
11759 * @param {string} key The key of the method to get.
11760 * @returns {*} Returns the function if it's native, else `undefined`.
11761 */
11762function getNative(object, key) {
11763 var value = _getValue(object, key);
11764 return _baseIsNative(value) ? value : undefined;
11765}
11766
11767var _getNative = getNative;
11768
11769/* Built-in method references that are verified to be native. */
11770var Map = _getNative(_root, 'Map');
11771
11772var _Map = Map;
11773
11774/* Built-in method references that are verified to be native. */
11775var nativeCreate = _getNative(Object, 'create');
11776
11777var _nativeCreate = nativeCreate;
11778
11779/**
11780 * Removes all key-value entries from the hash.
11781 *
11782 * @private
11783 * @name clear
11784 * @memberOf Hash
11785 */
11786function hashClear() {
11787 this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
11788 this.size = 0;
11789}
11790
11791var _hashClear = hashClear;
11792
11793/**
11794 * Removes `key` and its value from the hash.
11795 *
11796 * @private
11797 * @name delete
11798 * @memberOf Hash
11799 * @param {Object} hash The hash to modify.
11800 * @param {string} key The key of the value to remove.
11801 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11802 */
11803function hashDelete(key) {
11804 var result = this.has(key) && delete this.__data__[key];
11805 this.size -= result ? 1 : 0;
11806 return result;
11807}
11808
11809var _hashDelete = hashDelete;
11810
11811/** Used to stand-in for `undefined` hash values. */
11812var HASH_UNDEFINED = '__lodash_hash_undefined__';
11813
11814/** Used for built-in method references. */
11815var objectProto$3 = Object.prototype;
11816
11817/** Used to check objects for own properties. */
11818var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
11819
11820/**
11821 * Gets the hash value for `key`.
11822 *
11823 * @private
11824 * @name get
11825 * @memberOf Hash
11826 * @param {string} key The key of the value to get.
11827 * @returns {*} Returns the entry value.
11828 */
11829function hashGet(key) {
11830 var data = this.__data__;
11831 if (_nativeCreate) {
11832 var result = data[key];
11833 return result === HASH_UNDEFINED ? undefined : result;
11834 }
11835 return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
11836}
11837
11838var _hashGet = hashGet;
11839
11840/** Used for built-in method references. */
11841var objectProto$4 = Object.prototype;
11842
11843/** Used to check objects for own properties. */
11844var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
11845
11846/**
11847 * Checks if a hash value for `key` exists.
11848 *
11849 * @private
11850 * @name has
11851 * @memberOf Hash
11852 * @param {string} key The key of the entry to check.
11853 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
11854 */
11855function hashHas(key) {
11856 var data = this.__data__;
11857 return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$4.call(data, key);
11858}
11859
11860var _hashHas = hashHas;
11861
11862/** Used to stand-in for `undefined` hash values. */
11863var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
11864
11865/**
11866 * Sets the hash `key` to `value`.
11867 *
11868 * @private
11869 * @name set
11870 * @memberOf Hash
11871 * @param {string} key The key of the value to set.
11872 * @param {*} value The value to set.
11873 * @returns {Object} Returns the hash instance.
11874 */
11875function hashSet(key, value) {
11876 var data = this.__data__;
11877 this.size += this.has(key) ? 0 : 1;
11878 data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
11879 return this;
11880}
11881
11882var _hashSet = hashSet;
11883
11884/**
11885 * Creates a hash object.
11886 *
11887 * @private
11888 * @constructor
11889 * @param {Array} [entries] The key-value pairs to cache.
11890 */
11891function Hash(entries) {
11892 var index = -1,
11893 length = entries == null ? 0 : entries.length;
11894
11895 this.clear();
11896 while (++index < length) {
11897 var entry = entries[index];
11898 this.set(entry[0], entry[1]);
11899 }
11900}
11901
11902// Add methods to `Hash`.
11903Hash.prototype.clear = _hashClear;
11904Hash.prototype['delete'] = _hashDelete;
11905Hash.prototype.get = _hashGet;
11906Hash.prototype.has = _hashHas;
11907Hash.prototype.set = _hashSet;
11908
11909var _Hash = Hash;
11910
11911/**
11912 * Removes all key-value entries from the map.
11913 *
11914 * @private
11915 * @name clear
11916 * @memberOf MapCache
11917 */
11918function mapCacheClear() {
11919 this.size = 0;
11920 this.__data__ = {
11921 'hash': new _Hash,
11922 'map': new (_Map || _ListCache),
11923 'string': new _Hash
11924 };
11925}
11926
11927var _mapCacheClear = mapCacheClear;
11928
11929/**
11930 * Checks if `value` is suitable for use as unique object key.
11931 *
11932 * @private
11933 * @param {*} value The value to check.
11934 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
11935 */
11936function isKeyable(value) {
11937 var type = typeof value;
11938 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
11939 ? (value !== '__proto__')
11940 : (value === null);
11941}
11942
11943var _isKeyable = isKeyable;
11944
11945/**
11946 * Gets the data for `map`.
11947 *
11948 * @private
11949 * @param {Object} map The map to query.
11950 * @param {string} key The reference key.
11951 * @returns {*} Returns the map data.
11952 */
11953function getMapData(map, key) {
11954 var data = map.__data__;
11955 return _isKeyable(key)
11956 ? data[typeof key == 'string' ? 'string' : 'hash']
11957 : data.map;
11958}
11959
11960var _getMapData = getMapData;
11961
11962/**
11963 * Removes `key` and its value from the map.
11964 *
11965 * @private
11966 * @name delete
11967 * @memberOf MapCache
11968 * @param {string} key The key of the value to remove.
11969 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11970 */
11971function mapCacheDelete(key) {
11972 var result = _getMapData(this, key)['delete'](key);
11973 this.size -= result ? 1 : 0;
11974 return result;
11975}
11976
11977var _mapCacheDelete = mapCacheDelete;
11978
11979/**
11980 * Gets the map value for `key`.
11981 *
11982 * @private
11983 * @name get
11984 * @memberOf MapCache
11985 * @param {string} key The key of the value to get.
11986 * @returns {*} Returns the entry value.
11987 */
11988function mapCacheGet(key) {
11989 return _getMapData(this, key).get(key);
11990}
11991
11992var _mapCacheGet = mapCacheGet;
11993
11994/**
11995 * Checks if a map value for `key` exists.
11996 *
11997 * @private
11998 * @name has
11999 * @memberOf MapCache
12000 * @param {string} key The key of the entry to check.
12001 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
12002 */
12003function mapCacheHas(key) {
12004 return _getMapData(this, key).has(key);
12005}
12006
12007var _mapCacheHas = mapCacheHas;
12008
12009/**
12010 * Sets the map `key` to `value`.
12011 *
12012 * @private
12013 * @name set
12014 * @memberOf MapCache
12015 * @param {string} key The key of the value to set.
12016 * @param {*} value The value to set.
12017 * @returns {Object} Returns the map cache instance.
12018 */
12019function mapCacheSet(key, value) {
12020 var data = _getMapData(this, key),
12021 size = data.size;
12022
12023 data.set(key, value);
12024 this.size += data.size == size ? 0 : 1;
12025 return this;
12026}
12027
12028var _mapCacheSet = mapCacheSet;
12029
12030/**
12031 * Creates a map cache object to store key-value pairs.
12032 *
12033 * @private
12034 * @constructor
12035 * @param {Array} [entries] The key-value pairs to cache.
12036 */
12037function MapCache(entries) {
12038 var index = -1,
12039 length = entries == null ? 0 : entries.length;
12040
12041 this.clear();
12042 while (++index < length) {
12043 var entry = entries[index];
12044 this.set(entry[0], entry[1]);
12045 }
12046}
12047
12048// Add methods to `MapCache`.
12049MapCache.prototype.clear = _mapCacheClear;
12050MapCache.prototype['delete'] = _mapCacheDelete;
12051MapCache.prototype.get = _mapCacheGet;
12052MapCache.prototype.has = _mapCacheHas;
12053MapCache.prototype.set = _mapCacheSet;
12054
12055var _MapCache = MapCache;
12056
12057/** Used as the size to enable large array optimizations. */
12058var LARGE_ARRAY_SIZE = 200;
12059
12060/**
12061 * Sets the stack `key` to `value`.
12062 *
12063 * @private
12064 * @name set
12065 * @memberOf Stack
12066 * @param {string} key The key of the value to set.
12067 * @param {*} value The value to set.
12068 * @returns {Object} Returns the stack cache instance.
12069 */
12070function stackSet(key, value) {
12071 var data = this.__data__;
12072 if (data instanceof _ListCache) {
12073 var pairs = data.__data__;
12074 if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
12075 pairs.push([key, value]);
12076 this.size = ++data.size;
12077 return this;
12078 }
12079 data = this.__data__ = new _MapCache(pairs);
12080 }
12081 data.set(key, value);
12082 this.size = data.size;
12083 return this;
12084}
12085
12086var _stackSet = stackSet;
12087
12088/**
12089 * Creates a stack cache object to store key-value pairs.
12090 *
12091 * @private
12092 * @constructor
12093 * @param {Array} [entries] The key-value pairs to cache.
12094 */
12095function Stack(entries) {
12096 var data = this.__data__ = new _ListCache(entries);
12097 this.size = data.size;
12098}
12099
12100// Add methods to `Stack`.
12101Stack.prototype.clear = _stackClear;
12102Stack.prototype['delete'] = _stackDelete;
12103Stack.prototype.get = _stackGet;
12104Stack.prototype.has = _stackHas;
12105Stack.prototype.set = _stackSet;
12106
12107var _Stack = Stack;
12108
12109/**
12110 * A specialized version of `_.forEach` for arrays without support for
12111 * iteratee shorthands.
12112 *
12113 * @private
12114 * @param {Array} [array] The array to iterate over.
12115 * @param {Function} iteratee The function invoked per iteration.
12116 * @returns {Array} Returns `array`.
12117 */
12118function arrayEach(array, iteratee) {
12119 var index = -1,
12120 length = array == null ? 0 : array.length;
12121
12122 while (++index < length) {
12123 if (iteratee(array[index], index, array) === false) {
12124 break;
12125 }
12126 }
12127 return array;
12128}
12129
12130var _arrayEach = arrayEach;
12131
12132var defineProperty = (function() {
12133 try {
12134 var func = _getNative(Object, 'defineProperty');
12135 func({}, '', {});
12136 return func;
12137 } catch (e) {}
12138}());
12139
12140var _defineProperty = defineProperty;
12141
12142/**
12143 * The base implementation of `assignValue` and `assignMergeValue` without
12144 * value checks.
12145 *
12146 * @private
12147 * @param {Object} object The object to modify.
12148 * @param {string} key The key of the property to assign.
12149 * @param {*} value The value to assign.
12150 */
12151function baseAssignValue(object, key, value) {
12152 if (key == '__proto__' && _defineProperty) {
12153 _defineProperty(object, key, {
12154 'configurable': true,
12155 'enumerable': true,
12156 'value': value,
12157 'writable': true
12158 });
12159 } else {
12160 object[key] = value;
12161 }
12162}
12163
12164var _baseAssignValue = baseAssignValue;
12165
12166/** Used for built-in method references. */
12167var objectProto$5 = Object.prototype;
12168
12169/** Used to check objects for own properties. */
12170var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
12171
12172/**
12173 * Assigns `value` to `key` of `object` if the existing value is not equivalent
12174 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
12175 * for equality comparisons.
12176 *
12177 * @private
12178 * @param {Object} object The object to modify.
12179 * @param {string} key The key of the property to assign.
12180 * @param {*} value The value to assign.
12181 */
12182function assignValue(object, key, value) {
12183 var objValue = object[key];
12184 if (!(hasOwnProperty$5.call(object, key) && eq_1(objValue, value)) ||
12185 (value === undefined && !(key in object))) {
12186 _baseAssignValue(object, key, value);
12187 }
12188}
12189
12190var _assignValue = assignValue;
12191
12192/**
12193 * Copies properties of `source` to `object`.
12194 *
12195 * @private
12196 * @param {Object} source The object to copy properties from.
12197 * @param {Array} props The property identifiers to copy.
12198 * @param {Object} [object={}] The object to copy properties to.
12199 * @param {Function} [customizer] The function to customize copied values.
12200 * @returns {Object} Returns `object`.
12201 */
12202function copyObject(source, props, object, customizer) {
12203 var isNew = !object;
12204 object || (object = {});
12205
12206 var index = -1,
12207 length = props.length;
12208
12209 while (++index < length) {
12210 var key = props[index];
12211
12212 var newValue = customizer
12213 ? customizer(object[key], source[key], key, object, source)
12214 : undefined;
12215
12216 if (newValue === undefined) {
12217 newValue = source[key];
12218 }
12219 if (isNew) {
12220 _baseAssignValue(object, key, newValue);
12221 } else {
12222 _assignValue(object, key, newValue);
12223 }
12224 }
12225 return object;
12226}
12227
12228var _copyObject = copyObject;
12229
12230/**
12231 * The base implementation of `_.times` without support for iteratee shorthands
12232 * or max array length checks.
12233 *
12234 * @private
12235 * @param {number} n The number of times to invoke `iteratee`.
12236 * @param {Function} iteratee The function invoked per iteration.
12237 * @returns {Array} Returns the array of results.
12238 */
12239function baseTimes(n, iteratee) {
12240 var index = -1,
12241 result = Array(n);
12242
12243 while (++index < n) {
12244 result[index] = iteratee(index);
12245 }
12246 return result;
12247}
12248
12249var _baseTimes = baseTimes;
12250
12251/**
12252 * Checks if `value` is object-like. A value is object-like if it's not `null`
12253 * and has a `typeof` result of "object".
12254 *
12255 * @static
12256 * @memberOf _
12257 * @since 4.0.0
12258 * @category Lang
12259 * @param {*} value The value to check.
12260 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
12261 * @example
12262 *
12263 * _.isObjectLike({});
12264 * // => true
12265 *
12266 * _.isObjectLike([1, 2, 3]);
12267 * // => true
12268 *
12269 * _.isObjectLike(_.noop);
12270 * // => false
12271 *
12272 * _.isObjectLike(null);
12273 * // => false
12274 */
12275function isObjectLike(value) {
12276 return value != null && typeof value == 'object';
12277}
12278
12279var isObjectLike_1 = isObjectLike;
12280
12281/** `Object#toString` result references. */
12282var argsTag = '[object Arguments]';
12283
12284/**
12285 * The base implementation of `_.isArguments`.
12286 *
12287 * @private
12288 * @param {*} value The value to check.
12289 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
12290 */
12291function baseIsArguments(value) {
12292 return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
12293}
12294
12295var _baseIsArguments = baseIsArguments;
12296
12297/** Used for built-in method references. */
12298var objectProto$6 = Object.prototype;
12299
12300/** Used to check objects for own properties. */
12301var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
12302
12303/** Built-in value references. */
12304var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
12305
12306/**
12307 * Checks if `value` is likely an `arguments` object.
12308 *
12309 * @static
12310 * @memberOf _
12311 * @since 0.1.0
12312 * @category Lang
12313 * @param {*} value The value to check.
12314 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
12315 * else `false`.
12316 * @example
12317 *
12318 * _.isArguments(function() { return arguments; }());
12319 * // => true
12320 *
12321 * _.isArguments([1, 2, 3]);
12322 * // => false
12323 */
12324var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
12325 return isObjectLike_1(value) && hasOwnProperty$6.call(value, 'callee') &&
12326 !propertyIsEnumerable.call(value, 'callee');
12327};
12328
12329var isArguments_1 = isArguments;
12330
12331/**
12332 * Checks if `value` is classified as an `Array` object.
12333 *
12334 * @static
12335 * @memberOf _
12336 * @since 0.1.0
12337 * @category Lang
12338 * @param {*} value The value to check.
12339 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
12340 * @example
12341 *
12342 * _.isArray([1, 2, 3]);
12343 * // => true
12344 *
12345 * _.isArray(document.body.children);
12346 * // => false
12347 *
12348 * _.isArray('abc');
12349 * // => false
12350 *
12351 * _.isArray(_.noop);
12352 * // => false
12353 */
12354var isArray = Array.isArray;
12355
12356var isArray_1 = isArray;
12357
12358/**
12359 * This method returns `false`.
12360 *
12361 * @static
12362 * @memberOf _
12363 * @since 4.13.0
12364 * @category Util
12365 * @returns {boolean} Returns `false`.
12366 * @example
12367 *
12368 * _.times(2, _.stubFalse);
12369 * // => [false, false]
12370 */
12371function stubFalse() {
12372 return false;
12373}
12374
12375var stubFalse_1 = stubFalse;
12376
12377var isBuffer_1$1 = createCommonjsModule(function (module, exports) {
12378/** Detect free variable `exports`. */
12379var freeExports = exports && !exports.nodeType && exports;
12380
12381/** Detect free variable `module`. */
12382var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
12383
12384/** Detect the popular CommonJS extension `module.exports`. */
12385var moduleExports = freeModule && freeModule.exports === freeExports;
12386
12387/** Built-in value references. */
12388var Buffer = moduleExports ? _root.Buffer : undefined;
12389
12390/* Built-in method references for those with the same name as other `lodash` methods. */
12391var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
12392
12393/**
12394 * Checks if `value` is a buffer.
12395 *
12396 * @static
12397 * @memberOf _
12398 * @since 4.3.0
12399 * @category Lang
12400 * @param {*} value The value to check.
12401 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
12402 * @example
12403 *
12404 * _.isBuffer(new Buffer(2));
12405 * // => true
12406 *
12407 * _.isBuffer(new Uint8Array(2));
12408 * // => false
12409 */
12410var isBuffer = nativeIsBuffer || stubFalse_1;
12411
12412module.exports = isBuffer;
12413});
12414
12415/** Used as references for various `Number` constants. */
12416var MAX_SAFE_INTEGER = 9007199254740991;
12417
12418/** Used to detect unsigned integer values. */
12419var reIsUint = /^(?:0|[1-9]\d*)$/;
12420
12421/**
12422 * Checks if `value` is a valid array-like index.
12423 *
12424 * @private
12425 * @param {*} value The value to check.
12426 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
12427 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
12428 */
12429function isIndex(value, length) {
12430 var type = typeof value;
12431 length = length == null ? MAX_SAFE_INTEGER : length;
12432
12433 return !!length &&
12434 (type == 'number' ||
12435 (type != 'symbol' && reIsUint.test(value))) &&
12436 (value > -1 && value % 1 == 0 && value < length);
12437}
12438
12439var _isIndex = isIndex;
12440
12441/** Used as references for various `Number` constants. */
12442var MAX_SAFE_INTEGER$1 = 9007199254740991;
12443
12444/**
12445 * Checks if `value` is a valid array-like length.
12446 *
12447 * **Note:** This method is loosely based on
12448 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12449 *
12450 * @static
12451 * @memberOf _
12452 * @since 4.0.0
12453 * @category Lang
12454 * @param {*} value The value to check.
12455 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
12456 * @example
12457 *
12458 * _.isLength(3);
12459 * // => true
12460 *
12461 * _.isLength(Number.MIN_VALUE);
12462 * // => false
12463 *
12464 * _.isLength(Infinity);
12465 * // => false
12466 *
12467 * _.isLength('3');
12468 * // => false
12469 */
12470function isLength(value) {
12471 return typeof value == 'number' &&
12472 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
12473}
12474
12475var isLength_1 = isLength;
12476
12477/** `Object#toString` result references. */
12478var argsTag$1 = '[object Arguments]',
12479 arrayTag = '[object Array]',
12480 boolTag = '[object Boolean]',
12481 dateTag = '[object Date]',
12482 errorTag = '[object Error]',
12483 funcTag$1 = '[object Function]',
12484 mapTag = '[object Map]',
12485 numberTag = '[object Number]',
12486 objectTag = '[object Object]',
12487 regexpTag = '[object RegExp]',
12488 setTag = '[object Set]',
12489 stringTag = '[object String]',
12490 weakMapTag = '[object WeakMap]';
12491
12492var arrayBufferTag = '[object ArrayBuffer]',
12493 dataViewTag = '[object DataView]',
12494 float32Tag = '[object Float32Array]',
12495 float64Tag = '[object Float64Array]',
12496 int8Tag = '[object Int8Array]',
12497 int16Tag = '[object Int16Array]',
12498 int32Tag = '[object Int32Array]',
12499 uint8Tag = '[object Uint8Array]',
12500 uint8ClampedTag = '[object Uint8ClampedArray]',
12501 uint16Tag = '[object Uint16Array]',
12502 uint32Tag = '[object Uint32Array]';
12503
12504/** Used to identify `toStringTag` values of typed arrays. */
12505var typedArrayTags = {};
12506typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
12507typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
12508typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
12509typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
12510typedArrayTags[uint32Tag] = true;
12511typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
12512typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
12513typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
12514typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
12515typedArrayTags[mapTag] = typedArrayTags[numberTag] =
12516typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
12517typedArrayTags[setTag] = typedArrayTags[stringTag] =
12518typedArrayTags[weakMapTag] = false;
12519
12520/**
12521 * The base implementation of `_.isTypedArray` without Node.js optimizations.
12522 *
12523 * @private
12524 * @param {*} value The value to check.
12525 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12526 */
12527function baseIsTypedArray(value) {
12528 return isObjectLike_1(value) &&
12529 isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
12530}
12531
12532var _baseIsTypedArray = baseIsTypedArray;
12533
12534/**
12535 * The base implementation of `_.unary` without support for storing metadata.
12536 *
12537 * @private
12538 * @param {Function} func The function to cap arguments for.
12539 * @returns {Function} Returns the new capped function.
12540 */
12541function baseUnary(func) {
12542 return function(value) {
12543 return func(value);
12544 };
12545}
12546
12547var _baseUnary = baseUnary;
12548
12549var _nodeUtil = createCommonjsModule(function (module, exports) {
12550/** Detect free variable `exports`. */
12551var freeExports = exports && !exports.nodeType && exports;
12552
12553/** Detect free variable `module`. */
12554var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
12555
12556/** Detect the popular CommonJS extension `module.exports`. */
12557var moduleExports = freeModule && freeModule.exports === freeExports;
12558
12559/** Detect free variable `process` from Node.js. */
12560var freeProcess = moduleExports && _freeGlobal.process;
12561
12562/** Used to access faster Node.js helpers. */
12563var nodeUtil = (function() {
12564 try {
12565 // Use `util.types` for Node.js 10+.
12566 var types = freeModule && freeModule.require && freeModule.require('util').types;
12567
12568 if (types) {
12569 return types;
12570 }
12571
12572 // Legacy `process.binding('util')` for Node.js < 10.
12573 return freeProcess && freeProcess.binding && freeProcess.binding('util');
12574 } catch (e) {}
12575}());
12576
12577module.exports = nodeUtil;
12578});
12579
12580/* Node.js helper references. */
12581var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
12582
12583/**
12584 * Checks if `value` is classified as a typed array.
12585 *
12586 * @static
12587 * @memberOf _
12588 * @since 3.0.0
12589 * @category Lang
12590 * @param {*} value The value to check.
12591 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12592 * @example
12593 *
12594 * _.isTypedArray(new Uint8Array);
12595 * // => true
12596 *
12597 * _.isTypedArray([]);
12598 * // => false
12599 */
12600var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
12601
12602var isTypedArray_1 = isTypedArray;
12603
12604/** Used for built-in method references. */
12605var objectProto$7 = Object.prototype;
12606
12607/** Used to check objects for own properties. */
12608var hasOwnProperty$7 = objectProto$7.hasOwnProperty;
12609
12610/**
12611 * Creates an array of the enumerable property names of the array-like `value`.
12612 *
12613 * @private
12614 * @param {*} value The value to query.
12615 * @param {boolean} inherited Specify returning inherited property names.
12616 * @returns {Array} Returns the array of property names.
12617 */
12618function arrayLikeKeys(value, inherited) {
12619 var isArr = isArray_1(value),
12620 isArg = !isArr && isArguments_1(value),
12621 isBuff = !isArr && !isArg && isBuffer_1$1(value),
12622 isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
12623 skipIndexes = isArr || isArg || isBuff || isType,
12624 result = skipIndexes ? _baseTimes(value.length, String) : [],
12625 length = result.length;
12626
12627 for (var key in value) {
12628 if ((inherited || hasOwnProperty$7.call(value, key)) &&
12629 !(skipIndexes && (
12630 // Safari 9 has enumerable `arguments.length` in strict mode.
12631 key == 'length' ||
12632 // Node.js 0.10 has enumerable non-index properties on buffers.
12633 (isBuff && (key == 'offset' || key == 'parent')) ||
12634 // PhantomJS 2 has enumerable non-index properties on typed arrays.
12635 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
12636 // Skip index properties.
12637 _isIndex(key, length)
12638 ))) {
12639 result.push(key);
12640 }
12641 }
12642 return result;
12643}
12644
12645var _arrayLikeKeys = arrayLikeKeys;
12646
12647/** Used for built-in method references. */
12648var objectProto$8 = Object.prototype;
12649
12650/**
12651 * Checks if `value` is likely a prototype object.
12652 *
12653 * @private
12654 * @param {*} value The value to check.
12655 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
12656 */
12657function isPrototype(value) {
12658 var Ctor = value && value.constructor,
12659 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
12660
12661 return value === proto;
12662}
12663
12664var _isPrototype = isPrototype;
12665
12666/**
12667 * Creates a unary function that invokes `func` with its argument transformed.
12668 *
12669 * @private
12670 * @param {Function} func The function to wrap.
12671 * @param {Function} transform The argument transform.
12672 * @returns {Function} Returns the new function.
12673 */
12674function overArg(func, transform) {
12675 return function(arg) {
12676 return func(transform(arg));
12677 };
12678}
12679
12680var _overArg = overArg;
12681
12682/* Built-in method references for those with the same name as other `lodash` methods. */
12683var nativeKeys = _overArg(Object.keys, Object);
12684
12685var _nativeKeys = nativeKeys;
12686
12687/** Used for built-in method references. */
12688var objectProto$9 = Object.prototype;
12689
12690/** Used to check objects for own properties. */
12691var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
12692
12693/**
12694 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
12695 *
12696 * @private
12697 * @param {Object} object The object to query.
12698 * @returns {Array} Returns the array of property names.
12699 */
12700function baseKeys(object) {
12701 if (!_isPrototype(object)) {
12702 return _nativeKeys(object);
12703 }
12704 var result = [];
12705 for (var key in Object(object)) {
12706 if (hasOwnProperty$8.call(object, key) && key != 'constructor') {
12707 result.push(key);
12708 }
12709 }
12710 return result;
12711}
12712
12713var _baseKeys = baseKeys;
12714
12715/**
12716 * Checks if `value` is array-like. A value is considered array-like if it's
12717 * not a function and has a `value.length` that's an integer greater than or
12718 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
12719 *
12720 * @static
12721 * @memberOf _
12722 * @since 4.0.0
12723 * @category Lang
12724 * @param {*} value The value to check.
12725 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
12726 * @example
12727 *
12728 * _.isArrayLike([1, 2, 3]);
12729 * // => true
12730 *
12731 * _.isArrayLike(document.body.children);
12732 * // => true
12733 *
12734 * _.isArrayLike('abc');
12735 * // => true
12736 *
12737 * _.isArrayLike(_.noop);
12738 * // => false
12739 */
12740function isArrayLike(value) {
12741 return value != null && isLength_1(value.length) && !isFunction_1(value);
12742}
12743
12744var isArrayLike_1 = isArrayLike;
12745
12746/**
12747 * Creates an array of the own enumerable property names of `object`.
12748 *
12749 * **Note:** Non-object values are coerced to objects. See the
12750 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
12751 * for more details.
12752 *
12753 * @static
12754 * @since 0.1.0
12755 * @memberOf _
12756 * @category Object
12757 * @param {Object} object The object to query.
12758 * @returns {Array} Returns the array of property names.
12759 * @example
12760 *
12761 * function Foo() {
12762 * this.a = 1;
12763 * this.b = 2;
12764 * }
12765 *
12766 * Foo.prototype.c = 3;
12767 *
12768 * _.keys(new Foo);
12769 * // => ['a', 'b'] (iteration order is not guaranteed)
12770 *
12771 * _.keys('hi');
12772 * // => ['0', '1']
12773 */
12774function keys$1(object) {
12775 return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
12776}
12777
12778var keys_1 = keys$1;
12779
12780/**
12781 * The base implementation of `_.assign` without support for multiple sources
12782 * or `customizer` functions.
12783 *
12784 * @private
12785 * @param {Object} object The destination object.
12786 * @param {Object} source The source object.
12787 * @returns {Object} Returns `object`.
12788 */
12789function baseAssign(object, source) {
12790 return object && _copyObject(source, keys_1(source), object);
12791}
12792
12793var _baseAssign = baseAssign;
12794
12795/**
12796 * This function is like
12797 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
12798 * except that it includes inherited enumerable properties.
12799 *
12800 * @private
12801 * @param {Object} object The object to query.
12802 * @returns {Array} Returns the array of property names.
12803 */
12804function nativeKeysIn(object) {
12805 var result = [];
12806 if (object != null) {
12807 for (var key in Object(object)) {
12808 result.push(key);
12809 }
12810 }
12811 return result;
12812}
12813
12814var _nativeKeysIn = nativeKeysIn;
12815
12816/** Used for built-in method references. */
12817var objectProto$a = Object.prototype;
12818
12819/** Used to check objects for own properties. */
12820var hasOwnProperty$9 = objectProto$a.hasOwnProperty;
12821
12822/**
12823 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
12824 *
12825 * @private
12826 * @param {Object} object The object to query.
12827 * @returns {Array} Returns the array of property names.
12828 */
12829function baseKeysIn(object) {
12830 if (!isObject_1(object)) {
12831 return _nativeKeysIn(object);
12832 }
12833 var isProto = _isPrototype(object),
12834 result = [];
12835
12836 for (var key in object) {
12837 if (!(key == 'constructor' && (isProto || !hasOwnProperty$9.call(object, key)))) {
12838 result.push(key);
12839 }
12840 }
12841 return result;
12842}
12843
12844var _baseKeysIn = baseKeysIn;
12845
12846/**
12847 * Creates an array of the own and inherited enumerable property names of `object`.
12848 *
12849 * **Note:** Non-object values are coerced to objects.
12850 *
12851 * @static
12852 * @memberOf _
12853 * @since 3.0.0
12854 * @category Object
12855 * @param {Object} object The object to query.
12856 * @returns {Array} Returns the array of property names.
12857 * @example
12858 *
12859 * function Foo() {
12860 * this.a = 1;
12861 * this.b = 2;
12862 * }
12863 *
12864 * Foo.prototype.c = 3;
12865 *
12866 * _.keysIn(new Foo);
12867 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
12868 */
12869function keysIn$1(object) {
12870 return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
12871}
12872
12873var keysIn_1 = keysIn$1;
12874
12875/**
12876 * The base implementation of `_.assignIn` without support for multiple sources
12877 * or `customizer` functions.
12878 *
12879 * @private
12880 * @param {Object} object The destination object.
12881 * @param {Object} source The source object.
12882 * @returns {Object} Returns `object`.
12883 */
12884function baseAssignIn(object, source) {
12885 return object && _copyObject(source, keysIn_1(source), object);
12886}
12887
12888var _baseAssignIn = baseAssignIn;
12889
12890var _cloneBuffer = createCommonjsModule(function (module, exports) {
12891/** Detect free variable `exports`. */
12892var freeExports = exports && !exports.nodeType && exports;
12893
12894/** Detect free variable `module`. */
12895var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
12896
12897/** Detect the popular CommonJS extension `module.exports`. */
12898var moduleExports = freeModule && freeModule.exports === freeExports;
12899
12900/** Built-in value references. */
12901var Buffer = moduleExports ? _root.Buffer : undefined,
12902 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
12903
12904/**
12905 * Creates a clone of `buffer`.
12906 *
12907 * @private
12908 * @param {Buffer} buffer The buffer to clone.
12909 * @param {boolean} [isDeep] Specify a deep clone.
12910 * @returns {Buffer} Returns the cloned buffer.
12911 */
12912function cloneBuffer(buffer, isDeep) {
12913 if (isDeep) {
12914 return buffer.slice();
12915 }
12916 var length = buffer.length,
12917 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
12918
12919 buffer.copy(result);
12920 return result;
12921}
12922
12923module.exports = cloneBuffer;
12924});
12925
12926/**
12927 * Copies the values of `source` to `array`.
12928 *
12929 * @private
12930 * @param {Array} source The array to copy values from.
12931 * @param {Array} [array=[]] The array to copy values to.
12932 * @returns {Array} Returns `array`.
12933 */
12934function copyArray(source, array) {
12935 var index = -1,
12936 length = source.length;
12937
12938 array || (array = Array(length));
12939 while (++index < length) {
12940 array[index] = source[index];
12941 }
12942 return array;
12943}
12944
12945var _copyArray = copyArray;
12946
12947/**
12948 * A specialized version of `_.filter` for arrays without support for
12949 * iteratee shorthands.
12950 *
12951 * @private
12952 * @param {Array} [array] The array to iterate over.
12953 * @param {Function} predicate The function invoked per iteration.
12954 * @returns {Array} Returns the new filtered array.
12955 */
12956function arrayFilter(array, predicate) {
12957 var index = -1,
12958 length = array == null ? 0 : array.length,
12959 resIndex = 0,
12960 result = [];
12961
12962 while (++index < length) {
12963 var value = array[index];
12964 if (predicate(value, index, array)) {
12965 result[resIndex++] = value;
12966 }
12967 }
12968 return result;
12969}
12970
12971var _arrayFilter = arrayFilter;
12972
12973/**
12974 * This method returns a new empty array.
12975 *
12976 * @static
12977 * @memberOf _
12978 * @since 4.13.0
12979 * @category Util
12980 * @returns {Array} Returns the new empty array.
12981 * @example
12982 *
12983 * var arrays = _.times(2, _.stubArray);
12984 *
12985 * console.log(arrays);
12986 * // => [[], []]
12987 *
12988 * console.log(arrays[0] === arrays[1]);
12989 * // => false
12990 */
12991function stubArray() {
12992 return [];
12993}
12994
12995var stubArray_1 = stubArray;
12996
12997/** Used for built-in method references. */
12998var objectProto$b = Object.prototype;
12999
13000/** Built-in value references. */
13001var propertyIsEnumerable$1 = objectProto$b.propertyIsEnumerable;
13002
13003/* Built-in method references for those with the same name as other `lodash` methods. */
13004var nativeGetSymbols = Object.getOwnPropertySymbols;
13005
13006/**
13007 * Creates an array of the own enumerable symbols of `object`.
13008 *
13009 * @private
13010 * @param {Object} object The object to query.
13011 * @returns {Array} Returns the array of symbols.
13012 */
13013var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
13014 if (object == null) {
13015 return [];
13016 }
13017 object = Object(object);
13018 return _arrayFilter(nativeGetSymbols(object), function(symbol) {
13019 return propertyIsEnumerable$1.call(object, symbol);
13020 });
13021};
13022
13023var _getSymbols = getSymbols;
13024
13025/**
13026 * Copies own symbols of `source` to `object`.
13027 *
13028 * @private
13029 * @param {Object} source The object to copy symbols from.
13030 * @param {Object} [object={}] The object to copy symbols to.
13031 * @returns {Object} Returns `object`.
13032 */
13033function copySymbols(source, object) {
13034 return _copyObject(source, _getSymbols(source), object);
13035}
13036
13037var _copySymbols = copySymbols;
13038
13039/**
13040 * Appends the elements of `values` to `array`.
13041 *
13042 * @private
13043 * @param {Array} array The array to modify.
13044 * @param {Array} values The values to append.
13045 * @returns {Array} Returns `array`.
13046 */
13047function arrayPush(array, values) {
13048 var index = -1,
13049 length = values.length,
13050 offset = array.length;
13051
13052 while (++index < length) {
13053 array[offset + index] = values[index];
13054 }
13055 return array;
13056}
13057
13058var _arrayPush = arrayPush;
13059
13060/** Built-in value references. */
13061var getPrototype = _overArg(Object.getPrototypeOf, Object);
13062
13063var _getPrototype = getPrototype;
13064
13065/* Built-in method references for those with the same name as other `lodash` methods. */
13066var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
13067
13068/**
13069 * Creates an array of the own and inherited enumerable symbols of `object`.
13070 *
13071 * @private
13072 * @param {Object} object The object to query.
13073 * @returns {Array} Returns the array of symbols.
13074 */
13075var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
13076 var result = [];
13077 while (object) {
13078 _arrayPush(result, _getSymbols(object));
13079 object = _getPrototype(object);
13080 }
13081 return result;
13082};
13083
13084var _getSymbolsIn = getSymbolsIn;
13085
13086/**
13087 * Copies own and inherited symbols of `source` to `object`.
13088 *
13089 * @private
13090 * @param {Object} source The object to copy symbols from.
13091 * @param {Object} [object={}] The object to copy symbols to.
13092 * @returns {Object} Returns `object`.
13093 */
13094function copySymbolsIn(source, object) {
13095 return _copyObject(source, _getSymbolsIn(source), object);
13096}
13097
13098var _copySymbolsIn = copySymbolsIn;
13099
13100/**
13101 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
13102 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
13103 * symbols of `object`.
13104 *
13105 * @private
13106 * @param {Object} object The object to query.
13107 * @param {Function} keysFunc The function to get the keys of `object`.
13108 * @param {Function} symbolsFunc The function to get the symbols of `object`.
13109 * @returns {Array} Returns the array of property names and symbols.
13110 */
13111function baseGetAllKeys(object, keysFunc, symbolsFunc) {
13112 var result = keysFunc(object);
13113 return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
13114}
13115
13116var _baseGetAllKeys = baseGetAllKeys;
13117
13118/**
13119 * Creates an array of own enumerable property names and symbols of `object`.
13120 *
13121 * @private
13122 * @param {Object} object The object to query.
13123 * @returns {Array} Returns the array of property names and symbols.
13124 */
13125function getAllKeys(object) {
13126 return _baseGetAllKeys(object, keys_1, _getSymbols);
13127}
13128
13129var _getAllKeys = getAllKeys;
13130
13131/**
13132 * Creates an array of own and inherited enumerable property names and
13133 * symbols of `object`.
13134 *
13135 * @private
13136 * @param {Object} object The object to query.
13137 * @returns {Array} Returns the array of property names and symbols.
13138 */
13139function getAllKeysIn(object) {
13140 return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
13141}
13142
13143var _getAllKeysIn = getAllKeysIn;
13144
13145/* Built-in method references that are verified to be native. */
13146var DataView = _getNative(_root, 'DataView');
13147
13148var _DataView = DataView;
13149
13150/* Built-in method references that are verified to be native. */
13151var Promise$1 = _getNative(_root, 'Promise');
13152
13153var _Promise = Promise$1;
13154
13155/* Built-in method references that are verified to be native. */
13156var Set$1 = _getNative(_root, 'Set');
13157
13158var _Set = Set$1;
13159
13160/* Built-in method references that are verified to be native. */
13161var WeakMap = _getNative(_root, 'WeakMap');
13162
13163var _WeakMap = WeakMap;
13164
13165/** `Object#toString` result references. */
13166var mapTag$1 = '[object Map]',
13167 objectTag$1 = '[object Object]',
13168 promiseTag = '[object Promise]',
13169 setTag$1 = '[object Set]',
13170 weakMapTag$1 = '[object WeakMap]';
13171
13172var dataViewTag$1 = '[object DataView]';
13173
13174/** Used to detect maps, sets, and weakmaps. */
13175var dataViewCtorString = _toSource(_DataView),
13176 mapCtorString = _toSource(_Map),
13177 promiseCtorString = _toSource(_Promise),
13178 setCtorString = _toSource(_Set),
13179 weakMapCtorString = _toSource(_WeakMap);
13180
13181/**
13182 * Gets the `toStringTag` of `value`.
13183 *
13184 * @private
13185 * @param {*} value The value to query.
13186 * @returns {string} Returns the `toStringTag`.
13187 */
13188var getTag = _baseGetTag;
13189
13190// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
13191if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
13192 (_Map && getTag(new _Map) != mapTag$1) ||
13193 (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
13194 (_Set && getTag(new _Set) != setTag$1) ||
13195 (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
13196 getTag = function(value) {
13197 var result = _baseGetTag(value),
13198 Ctor = result == objectTag$1 ? value.constructor : undefined,
13199 ctorString = Ctor ? _toSource(Ctor) : '';
13200
13201 if (ctorString) {
13202 switch (ctorString) {
13203 case dataViewCtorString: return dataViewTag$1;
13204 case mapCtorString: return mapTag$1;
13205 case promiseCtorString: return promiseTag;
13206 case setCtorString: return setTag$1;
13207 case weakMapCtorString: return weakMapTag$1;
13208 }
13209 }
13210 return result;
13211 };
13212}
13213
13214var _getTag = getTag;
13215
13216/** Used for built-in method references. */
13217var objectProto$c = Object.prototype;
13218
13219/** Used to check objects for own properties. */
13220var hasOwnProperty$a = objectProto$c.hasOwnProperty;
13221
13222/**
13223 * Initializes an array clone.
13224 *
13225 * @private
13226 * @param {Array} array The array to clone.
13227 * @returns {Array} Returns the initialized clone.
13228 */
13229function initCloneArray(array) {
13230 var length = array.length,
13231 result = new array.constructor(length);
13232
13233 // Add properties assigned by `RegExp#exec`.
13234 if (length && typeof array[0] == 'string' && hasOwnProperty$a.call(array, 'index')) {
13235 result.index = array.index;
13236 result.input = array.input;
13237 }
13238 return result;
13239}
13240
13241var _initCloneArray = initCloneArray;
13242
13243/** Built-in value references. */
13244var Uint8Array = _root.Uint8Array;
13245
13246var _Uint8Array = Uint8Array;
13247
13248/**
13249 * Creates a clone of `arrayBuffer`.
13250 *
13251 * @private
13252 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
13253 * @returns {ArrayBuffer} Returns the cloned array buffer.
13254 */
13255function cloneArrayBuffer(arrayBuffer) {
13256 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
13257 new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
13258 return result;
13259}
13260
13261var _cloneArrayBuffer = cloneArrayBuffer;
13262
13263/**
13264 * Creates a clone of `dataView`.
13265 *
13266 * @private
13267 * @param {Object} dataView The data view to clone.
13268 * @param {boolean} [isDeep] Specify a deep clone.
13269 * @returns {Object} Returns the cloned data view.
13270 */
13271function cloneDataView(dataView, isDeep) {
13272 var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
13273 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
13274}
13275
13276var _cloneDataView = cloneDataView;
13277
13278/** Used to match `RegExp` flags from their coerced string values. */
13279var reFlags = /\w*$/;
13280
13281/**
13282 * Creates a clone of `regexp`.
13283 *
13284 * @private
13285 * @param {Object} regexp The regexp to clone.
13286 * @returns {Object} Returns the cloned regexp.
13287 */
13288function cloneRegExp(regexp) {
13289 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
13290 result.lastIndex = regexp.lastIndex;
13291 return result;
13292}
13293
13294var _cloneRegExp = cloneRegExp;
13295
13296/** Used to convert symbols to primitives and strings. */
13297var symbolProto = _Symbol ? _Symbol.prototype : undefined,
13298 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
13299
13300/**
13301 * Creates a clone of the `symbol` object.
13302 *
13303 * @private
13304 * @param {Object} symbol The symbol object to clone.
13305 * @returns {Object} Returns the cloned symbol object.
13306 */
13307function cloneSymbol(symbol) {
13308 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
13309}
13310
13311var _cloneSymbol = cloneSymbol;
13312
13313/**
13314 * Creates a clone of `typedArray`.
13315 *
13316 * @private
13317 * @param {Object} typedArray The typed array to clone.
13318 * @param {boolean} [isDeep] Specify a deep clone.
13319 * @returns {Object} Returns the cloned typed array.
13320 */
13321function cloneTypedArray(typedArray, isDeep) {
13322 var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
13323 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
13324}
13325
13326var _cloneTypedArray = cloneTypedArray;
13327
13328/** `Object#toString` result references. */
13329var boolTag$1 = '[object Boolean]',
13330 dateTag$1 = '[object Date]',
13331 mapTag$2 = '[object Map]',
13332 numberTag$1 = '[object Number]',
13333 regexpTag$1 = '[object RegExp]',
13334 setTag$2 = '[object Set]',
13335 stringTag$1 = '[object String]',
13336 symbolTag = '[object Symbol]';
13337
13338var arrayBufferTag$1 = '[object ArrayBuffer]',
13339 dataViewTag$2 = '[object DataView]',
13340 float32Tag$1 = '[object Float32Array]',
13341 float64Tag$1 = '[object Float64Array]',
13342 int8Tag$1 = '[object Int8Array]',
13343 int16Tag$1 = '[object Int16Array]',
13344 int32Tag$1 = '[object Int32Array]',
13345 uint8Tag$1 = '[object Uint8Array]',
13346 uint8ClampedTag$1 = '[object Uint8ClampedArray]',
13347 uint16Tag$1 = '[object Uint16Array]',
13348 uint32Tag$1 = '[object Uint32Array]';
13349
13350/**
13351 * Initializes an object clone based on its `toStringTag`.
13352 *
13353 * **Note:** This function only supports cloning values with tags of
13354 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
13355 *
13356 * @private
13357 * @param {Object} object The object to clone.
13358 * @param {string} tag The `toStringTag` of the object to clone.
13359 * @param {boolean} [isDeep] Specify a deep clone.
13360 * @returns {Object} Returns the initialized clone.
13361 */
13362function initCloneByTag(object, tag, isDeep) {
13363 var Ctor = object.constructor;
13364 switch (tag) {
13365 case arrayBufferTag$1:
13366 return _cloneArrayBuffer(object);
13367
13368 case boolTag$1:
13369 case dateTag$1:
13370 return new Ctor(+object);
13371
13372 case dataViewTag$2:
13373 return _cloneDataView(object, isDeep);
13374
13375 case float32Tag$1: case float64Tag$1:
13376 case int8Tag$1: case int16Tag$1: case int32Tag$1:
13377 case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
13378 return _cloneTypedArray(object, isDeep);
13379
13380 case mapTag$2:
13381 return new Ctor;
13382
13383 case numberTag$1:
13384 case stringTag$1:
13385 return new Ctor(object);
13386
13387 case regexpTag$1:
13388 return _cloneRegExp(object);
13389
13390 case setTag$2:
13391 return new Ctor;
13392
13393 case symbolTag:
13394 return _cloneSymbol(object);
13395 }
13396}
13397
13398var _initCloneByTag = initCloneByTag;
13399
13400/** Built-in value references. */
13401var objectCreate = Object.create;
13402
13403/**
13404 * The base implementation of `_.create` without support for assigning
13405 * properties to the created object.
13406 *
13407 * @private
13408 * @param {Object} proto The object to inherit from.
13409 * @returns {Object} Returns the new object.
13410 */
13411var baseCreate = (function() {
13412 function object() {}
13413 return function(proto) {
13414 if (!isObject_1(proto)) {
13415 return {};
13416 }
13417 if (objectCreate) {
13418 return objectCreate(proto);
13419 }
13420 object.prototype = proto;
13421 var result = new object;
13422 object.prototype = undefined;
13423 return result;
13424 };
13425}());
13426
13427var _baseCreate = baseCreate;
13428
13429/**
13430 * Initializes an object clone.
13431 *
13432 * @private
13433 * @param {Object} object The object to clone.
13434 * @returns {Object} Returns the initialized clone.
13435 */
13436function initCloneObject(object) {
13437 return (typeof object.constructor == 'function' && !_isPrototype(object))
13438 ? _baseCreate(_getPrototype(object))
13439 : {};
13440}
13441
13442var _initCloneObject = initCloneObject;
13443
13444/** `Object#toString` result references. */
13445var mapTag$3 = '[object Map]';
13446
13447/**
13448 * The base implementation of `_.isMap` without Node.js optimizations.
13449 *
13450 * @private
13451 * @param {*} value The value to check.
13452 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
13453 */
13454function baseIsMap(value) {
13455 return isObjectLike_1(value) && _getTag(value) == mapTag$3;
13456}
13457
13458var _baseIsMap = baseIsMap;
13459
13460/* Node.js helper references. */
13461var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
13462
13463/**
13464 * Checks if `value` is classified as a `Map` object.
13465 *
13466 * @static
13467 * @memberOf _
13468 * @since 4.3.0
13469 * @category Lang
13470 * @param {*} value The value to check.
13471 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
13472 * @example
13473 *
13474 * _.isMap(new Map);
13475 * // => true
13476 *
13477 * _.isMap(new WeakMap);
13478 * // => false
13479 */
13480var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
13481
13482var isMap_1 = isMap;
13483
13484/** `Object#toString` result references. */
13485var setTag$3 = '[object Set]';
13486
13487/**
13488 * The base implementation of `_.isSet` without Node.js optimizations.
13489 *
13490 * @private
13491 * @param {*} value The value to check.
13492 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
13493 */
13494function baseIsSet(value) {
13495 return isObjectLike_1(value) && _getTag(value) == setTag$3;
13496}
13497
13498var _baseIsSet = baseIsSet;
13499
13500/* Node.js helper references. */
13501var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
13502
13503/**
13504 * Checks if `value` is classified as a `Set` object.
13505 *
13506 * @static
13507 * @memberOf _
13508 * @since 4.3.0
13509 * @category Lang
13510 * @param {*} value The value to check.
13511 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
13512 * @example
13513 *
13514 * _.isSet(new Set);
13515 * // => true
13516 *
13517 * _.isSet(new WeakSet);
13518 * // => false
13519 */
13520var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
13521
13522var isSet_1 = isSet;
13523
13524/** Used to compose bitmasks for cloning. */
13525var CLONE_DEEP_FLAG = 1,
13526 CLONE_FLAT_FLAG = 2,
13527 CLONE_SYMBOLS_FLAG = 4;
13528
13529/** `Object#toString` result references. */
13530var argsTag$2 = '[object Arguments]',
13531 arrayTag$1 = '[object Array]',
13532 boolTag$2 = '[object Boolean]',
13533 dateTag$2 = '[object Date]',
13534 errorTag$1 = '[object Error]',
13535 funcTag$2 = '[object Function]',
13536 genTag$1 = '[object GeneratorFunction]',
13537 mapTag$4 = '[object Map]',
13538 numberTag$2 = '[object Number]',
13539 objectTag$2 = '[object Object]',
13540 regexpTag$2 = '[object RegExp]',
13541 setTag$4 = '[object Set]',
13542 stringTag$2 = '[object String]',
13543 symbolTag$1 = '[object Symbol]',
13544 weakMapTag$2 = '[object WeakMap]';
13545
13546var arrayBufferTag$2 = '[object ArrayBuffer]',
13547 dataViewTag$3 = '[object DataView]',
13548 float32Tag$2 = '[object Float32Array]',
13549 float64Tag$2 = '[object Float64Array]',
13550 int8Tag$2 = '[object Int8Array]',
13551 int16Tag$2 = '[object Int16Array]',
13552 int32Tag$2 = '[object Int32Array]',
13553 uint8Tag$2 = '[object Uint8Array]',
13554 uint8ClampedTag$2 = '[object Uint8ClampedArray]',
13555 uint16Tag$2 = '[object Uint16Array]',
13556 uint32Tag$2 = '[object Uint32Array]';
13557
13558/** Used to identify `toStringTag` values supported by `_.clone`. */
13559var cloneableTags = {};
13560cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
13561cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
13562cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
13563cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
13564cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
13565cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
13566cloneableTags[numberTag$2] = cloneableTags[objectTag$2] =
13567cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
13568cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
13569cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
13570cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
13571cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
13572cloneableTags[weakMapTag$2] = false;
13573
13574/**
13575 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
13576 * traversed objects.
13577 *
13578 * @private
13579 * @param {*} value The value to clone.
13580 * @param {boolean} bitmask The bitmask flags.
13581 * 1 - Deep clone
13582 * 2 - Flatten inherited properties
13583 * 4 - Clone symbols
13584 * @param {Function} [customizer] The function to customize cloning.
13585 * @param {string} [key] The key of `value`.
13586 * @param {Object} [object] The parent object of `value`.
13587 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
13588 * @returns {*} Returns the cloned value.
13589 */
13590function baseClone(value, bitmask, customizer, key, object, stack) {
13591 var result,
13592 isDeep = bitmask & CLONE_DEEP_FLAG,
13593 isFlat = bitmask & CLONE_FLAT_FLAG,
13594 isFull = bitmask & CLONE_SYMBOLS_FLAG;
13595
13596 if (customizer) {
13597 result = object ? customizer(value, key, object, stack) : customizer(value);
13598 }
13599 if (result !== undefined) {
13600 return result;
13601 }
13602 if (!isObject_1(value)) {
13603 return value;
13604 }
13605 var isArr = isArray_1(value);
13606 if (isArr) {
13607 result = _initCloneArray(value);
13608 if (!isDeep) {
13609 return _copyArray(value, result);
13610 }
13611 } else {
13612 var tag = _getTag(value),
13613 isFunc = tag == funcTag$2 || tag == genTag$1;
13614
13615 if (isBuffer_1$1(value)) {
13616 return _cloneBuffer(value, isDeep);
13617 }
13618 if (tag == objectTag$2 || tag == argsTag$2 || (isFunc && !object)) {
13619 result = (isFlat || isFunc) ? {} : _initCloneObject(value);
13620 if (!isDeep) {
13621 return isFlat
13622 ? _copySymbolsIn(value, _baseAssignIn(result, value))
13623 : _copySymbols(value, _baseAssign(result, value));
13624 }
13625 } else {
13626 if (!cloneableTags[tag]) {
13627 return object ? value : {};
13628 }
13629 result = _initCloneByTag(value, tag, isDeep);
13630 }
13631 }
13632 // Check for circular references and return its corresponding clone.
13633 stack || (stack = new _Stack);
13634 var stacked = stack.get(value);
13635 if (stacked) {
13636 return stacked;
13637 }
13638 stack.set(value, result);
13639
13640 if (isSet_1(value)) {
13641 value.forEach(function(subValue) {
13642 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
13643 });
13644 } else if (isMap_1(value)) {
13645 value.forEach(function(subValue, key) {
13646 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
13647 });
13648 }
13649
13650 var keysFunc = isFull
13651 ? (isFlat ? _getAllKeysIn : _getAllKeys)
13652 : (isFlat ? keysIn : keys_1);
13653
13654 var props = isArr ? undefined : keysFunc(value);
13655 _arrayEach(props || value, function(subValue, key) {
13656 if (props) {
13657 key = subValue;
13658 subValue = value[key];
13659 }
13660 // Recursively populate clone (susceptible to call stack limits).
13661 _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
13662 });
13663 return result;
13664}
13665
13666var _baseClone = baseClone;
13667
13668/** Used to compose bitmasks for cloning. */
13669var CLONE_DEEP_FLAG$1 = 1,
13670 CLONE_SYMBOLS_FLAG$1 = 4;
13671
13672/**
13673 * This method is like `_.clone` except that it recursively clones `value`.
13674 *
13675 * @static
13676 * @memberOf _
13677 * @since 1.0.0
13678 * @category Lang
13679 * @param {*} value The value to recursively clone.
13680 * @returns {*} Returns the deep cloned value.
13681 * @see _.clone
13682 * @example
13683 *
13684 * var objects = [{ 'a': 1 }, { 'b': 2 }];
13685 *
13686 * var deep = _.cloneDeep(objects);
13687 * console.log(deep[0] === objects[0]);
13688 * // => false
13689 */
13690function cloneDeep(value) {
13691 return _baseClone(value, CLONE_DEEP_FLAG$1 | CLONE_SYMBOLS_FLAG$1);
13692}
13693
13694var cloneDeep_1 = cloneDeep;
13695
13696//
13697
13698function createLocalVue(_Vue) {
13699 if ( _Vue === void 0 ) _Vue = Vue;
13700
13701 var instance = _Vue.extend();
13702
13703 // clone global APIs
13704 Object.keys(_Vue).forEach(function (key) {
13705 if (!instance.hasOwnProperty(key)) {
13706 var original = _Vue[key];
13707 // cloneDeep can fail when cloning Vue instances
13708 // cloneDeep checks that the instance has a Symbol
13709 // which errors in Vue < 2.17 (https://github.com/vuejs/vue/pull/7878)
13710 try {
13711 instance[key] =
13712 typeof original === 'object' ? cloneDeep_1(original) : original;
13713 } catch (e) {
13714 instance[key] = original;
13715 }
13716 }
13717 });
13718
13719 // config is not enumerable
13720 instance.config = cloneDeep_1(Vue.config);
13721
13722 instance.config.errorHandler = Vue.config.errorHandler;
13723
13724 // option merge strategies need to be exposed by reference
13725 // so that merge strats registered by plugins can work properly
13726 instance.config.optionMergeStrategies = Vue.config.optionMergeStrategies;
13727
13728 // make sure all extends are based on this instance.
13729 // this is important so that global components registered by plugins,
13730 // e.g. router-link are created using the correct base constructor
13731 instance.options._base = instance;
13732
13733 // compat for vue-router < 2.7.1 where it does not allow multiple installs
13734 if (instance._installedPlugins && instance._installedPlugins.length) {
13735 instance._installedPlugins.length = 0;
13736 }
13737 var use = instance.use;
13738 instance.use = function (plugin) {
13739 var rest = [], len = arguments.length - 1;
13740 while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];
13741
13742 if (plugin.installed === true) {
13743 plugin.installed = false;
13744 }
13745 if (plugin.install && plugin.install.installed === true) {
13746 plugin.install.installed = false;
13747 }
13748 use.call.apply(use, [ instance, plugin ].concat( rest ));
13749 };
13750 return instance
13751}
13752
13753//
13754
13755function isValidSlot(slot) {
13756 return isVueComponent(slot) || typeof slot === 'string'
13757}
13758
13759function requiresTemplateCompiler(slot) {
13760 if (typeof slot === 'string' && !vueTemplateCompiler.compileToFunctions) {
13761 throwError(
13762 "vueTemplateCompiler is undefined, you must pass " +
13763 "precompiled components if vue-template-compiler is " +
13764 "undefined"
13765 );
13766 }
13767}
13768
13769function validateSlots(slots) {
13770 Object.keys(slots).forEach(function (key) {
13771 var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
13772
13773 slot.forEach(function (slotValue) {
13774 if (!isValidSlot(slotValue)) {
13775 throwError(
13776 "slots[key] must be a Component, string or an array " +
13777 "of Components"
13778 );
13779 }
13780 requiresTemplateCompiler(slotValue);
13781 });
13782 });
13783}
13784
13785function vueExtendUnsupportedOption(option) {
13786 return (
13787 "options." + option + " is not supported for " +
13788 "components created with Vue.extend in Vue < 2.3. " +
13789 "You can set " + option + " to false to mount the component."
13790 )
13791}
13792// these options aren't supported if Vue is version < 2.3
13793// for components using Vue.extend. This is due to a bug
13794// that means the mixins we use to add properties are not applied
13795// correctly
13796var UNSUPPORTED_VERSION_OPTIONS = ['mocks', 'stubs', 'localVue'];
13797
13798function validateOptions(options, component) {
13799 if (
13800 options.attachTo &&
13801 !isHTMLElement(options.attachTo) &&
13802 !isDomSelector(options.attachTo)
13803 ) {
13804 throwError(
13805 "options.attachTo should be a valid HTMLElement or CSS selector string"
13806 );
13807 }
13808 if ('attachToDocument' in options) {
13809 warnDeprecated(
13810 "options.attachToDocument is deprecated in favor of options.attachTo and will be removed in a future release"
13811 );
13812 }
13813 if (options.parentComponent && !isPlainObject(options.parentComponent)) {
13814 throwError(
13815 "options.parentComponent should be a valid Vue component options object"
13816 );
13817 }
13818
13819 if (!isFunctionalComponent(component) && options.context) {
13820 throwError(
13821 "mount.context can only be used when mounting a functional component"
13822 );
13823 }
13824
13825 if (options.context && !isPlainObject(options.context)) {
13826 throwError('mount.context must be an object');
13827 }
13828
13829 if (VUE_VERSION < 2.3 && isConstructor(component)) {
13830 UNSUPPORTED_VERSION_OPTIONS.forEach(function (option) {
13831 if (options[option]) {
13832 throwError(vueExtendUnsupportedOption(option));
13833 }
13834 });
13835 }
13836
13837 if (options.slots) {
13838 compileTemplateForSlots(options.slots);
13839 // validate slots outside of the createSlots function so
13840 // that we can throw an error without it being caught by
13841 // the Vue error handler
13842 // $FlowIgnore
13843 validateSlots(options.slots);
13844 }
13845}
13846
13847Vue.config.productionTip = false;
13848Vue.config.devtools = false;
13849
13850function mount(component, options) {
13851 if ( options === void 0 ) options = {};
13852
13853 warnIfNoWindow();
13854
13855 polyfill();
13856
13857 addGlobalErrorHandler(Vue);
13858
13859 var _Vue = createLocalVue(options.localVue);
13860
13861 var mergedOptions = mergeOptions(options, config);
13862
13863 validateOptions(mergedOptions, component);
13864
13865 var parentVm = createInstance(component, mergedOptions, _Vue);
13866
13867 var el =
13868 options.attachTo || (options.attachToDocument ? createElement() : undefined);
13869 var vm = parentVm.$mount(el);
13870
13871 component._Ctor = {};
13872
13873 throwIfInstancesThrew(vm);
13874
13875 var wrapperOptions = {
13876 attachedToDocument: !!el
13877 };
13878
13879 var root = parentVm.$options._isFunctionalContainer
13880 ? vm._vnode
13881 : vm.$children[0];
13882
13883 return createWrapper(root, wrapperOptions)
13884}
13885
13886//
13887
13888
13889function shallowMount(
13890 component,
13891 options
13892) {
13893 if ( options === void 0 ) options = {};
13894
13895 return mount(component, Object.assign({}, options,
13896 {shouldProxy: true}))
13897}
13898
13899//
13900var toTypes = [String, Object];
13901var eventTypes = [String, Array];
13902
13903var RouterLinkStub = {
13904 name: 'RouterLinkStub',
13905 props: {
13906 to: {
13907 type: toTypes,
13908 required: true
13909 },
13910 tag: {
13911 type: String,
13912 default: 'a'
13913 },
13914 exact: Boolean,
13915 append: Boolean,
13916 replace: Boolean,
13917 activeClass: String,
13918 exactActiveClass: String,
13919 event: {
13920 type: eventTypes,
13921 default: 'click'
13922 }
13923 },
13924 render: function render(h) {
13925 return h(this.tag, undefined, this.$slots.default)
13926 }
13927};
13928
13929function shallow(component, options) {
13930 warn(
13931 "shallow has been renamed to shallowMount. shallow " +
13932 "will be removed in 1.0.0, use shallowMount instead"
13933 );
13934 return shallowMount(component, options)
13935}
13936
13937exports.RouterLinkStub = RouterLinkStub;
13938exports.Wrapper = Wrapper;
13939exports.WrapperArray = WrapperArray;
13940exports.config = config;
13941exports.createLocalVue = createLocalVue;
13942exports.createWrapper = createWrapper;
13943exports.enableAutoDestroy = enableAutoDestroy;
13944exports.mount = mount;
13945exports.resetAutoDestroyState = resetAutoDestroyState;
13946exports.shallow = shallow;
13947exports.shallowMount = shallowMount;