UNPKG

247 kBJavaScriptView Raw
1var WaveformPlaylist;
2/******/ (() => { // webpackBootstrap
3/******/ var __webpack_modules__ = ({
4
5/***/ 6824:
6/***/ ((module) => {
7
8/*!
9 * Cross-Browser Split 1.1.1
10 * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
11 * Available under the MIT License
12 * ECMAScript compliant, uniform cross-browser split method
13 */
14
15/**
16 * Splits a string into an array of strings using a regex or string separator. Matches of the
17 * separator are not included in the result array. However, if `separator` is a regex that contains
18 * capturing groups, backreferences are spliced into the result each time `separator` is matched.
19 * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably
20 * cross-browser.
21 * @param {String} str String to split.
22 * @param {RegExp|String} separator Regex or string to use for separating the string.
23 * @param {Number} [limit] Maximum number of items to include in the result array.
24 * @returns {Array} Array of substrings.
25 * @example
26 *
27 * // Basic use
28 * split('a b c d', ' ');
29 * // -> ['a', 'b', 'c', 'd']
30 *
31 * // With limit
32 * split('a b c d', ' ', 2);
33 * // -> ['a', 'b']
34 *
35 * // Backreferences in result array
36 * split('..word1 word2..', /([a-z]+)(\d+)/i);
37 * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
38 */
39module.exports = (function split(undef) {
40
41 var nativeSplit = String.prototype.split,
42 compliantExecNpcg = /()??/.exec("")[1] === undef,
43 // NPCG: nonparticipating capturing group
44 self;
45
46 self = function(str, separator, limit) {
47 // If `separator` is not a regex, use `nativeSplit`
48 if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
49 return nativeSplit.call(str, separator, limit);
50 }
51 var output = [],
52 flags = (separator.ignoreCase ? "i" : "") + (separator.multiline ? "m" : "") + (separator.extended ? "x" : "") + // Proposed for ES6
53 (separator.sticky ? "y" : ""),
54 // Firefox 3+
55 lastLastIndex = 0,
56 // Make `global` and avoid `lastIndex` issues by working with a copy
57 separator = new RegExp(separator.source, flags + "g"),
58 separator2, match, lastIndex, lastLength;
59 str += ""; // Type-convert
60 if (!compliantExecNpcg) {
61 // Doesn't need flags gy, but they don't hurt
62 separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
63 }
64 /* Values for `limit`, per the spec:
65 * If undefined: 4294967295 // Math.pow(2, 32) - 1
66 * If 0, Infinity, or NaN: 0
67 * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
68 * If negative number: 4294967296 - Math.floor(Math.abs(limit))
69 * If other: Type-convert, then use the above rules
70 */
71 limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1
72 limit >>> 0; // ToUint32(limit)
73 while (match = separator.exec(str)) {
74 // `separator.lastIndex` is not reliable cross-browser
75 lastIndex = match.index + match[0].length;
76 if (lastIndex > lastLastIndex) {
77 output.push(str.slice(lastLastIndex, match.index));
78 // Fix browsers whose `exec` methods don't consistently return `undefined` for
79 // nonparticipating capturing groups
80 if (!compliantExecNpcg && match.length > 1) {
81 match[0].replace(separator2, function() {
82 for (var i = 1; i < arguments.length - 2; i++) {
83 if (arguments[i] === undef) {
84 match[i] = undef;
85 }
86 }
87 });
88 }
89 if (match.length > 1 && match.index < str.length) {
90 Array.prototype.push.apply(output, match.slice(1));
91 }
92 lastLength = match[0].length;
93 lastLastIndex = lastIndex;
94 if (output.length >= limit) {
95 break;
96 }
97 }
98 if (separator.lastIndex === match.index) {
99 separator.lastIndex++; // Avoid an infinite loop
100 }
101 }
102 if (lastLastIndex === str.length) {
103 if (lastLength || !separator.test("")) {
104 output.push("");
105 }
106 } else {
107 output.push(str.slice(lastLastIndex));
108 }
109 return output.length > limit ? output.slice(0, limit) : output;
110 };
111
112 return self;
113})();
114
115
116/***/ }),
117
118/***/ 1804:
119/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
120
121"use strict";
122
123
124var isValue = __webpack_require__(5618)
125 , isPlainFunction = __webpack_require__(7205)
126 , assign = __webpack_require__(7191)
127 , normalizeOpts = __webpack_require__(5516)
128 , contains = __webpack_require__(9981);
129
130var d = (module.exports = function (dscr, value/*, options*/) {
131 var c, e, w, options, desc;
132 if (arguments.length < 2 || typeof dscr !== "string") {
133 options = value;
134 value = dscr;
135 dscr = null;
136 } else {
137 options = arguments[2];
138 }
139 if (isValue(dscr)) {
140 c = contains.call(dscr, "c");
141 e = contains.call(dscr, "e");
142 w = contains.call(dscr, "w");
143 } else {
144 c = w = true;
145 e = false;
146 }
147
148 desc = { value: value, configurable: c, enumerable: e, writable: w };
149 return !options ? desc : assign(normalizeOpts(options), desc);
150});
151
152d.gs = function (dscr, get, set/*, options*/) {
153 var c, e, options, desc;
154 if (typeof dscr !== "string") {
155 options = set;
156 set = get;
157 get = dscr;
158 dscr = null;
159 } else {
160 options = arguments[3];
161 }
162 if (!isValue(get)) {
163 get = undefined;
164 } else if (!isPlainFunction(get)) {
165 options = get;
166 get = set = undefined;
167 } else if (!isValue(set)) {
168 set = undefined;
169 } else if (!isPlainFunction(set)) {
170 options = set;
171 set = undefined;
172 }
173 if (isValue(dscr)) {
174 c = contains.call(dscr, "c");
175 e = contains.call(dscr, "e");
176 } else {
177 c = true;
178 e = false;
179 }
180
181 desc = { get: get, set: set, configurable: c, enumerable: e };
182 return !options ? desc : assign(normalizeOpts(options), desc);
183};
184
185
186/***/ }),
187
188/***/ 430:
189/***/ ((module) => {
190
191"use strict";
192
193
194// eslint-disable-next-line no-empty-function
195module.exports = function () {};
196
197
198/***/ }),
199
200/***/ 7191:
201/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
202
203"use strict";
204
205
206module.exports = __webpack_require__(6560)() ? Object.assign : __webpack_require__(7346);
207
208
209/***/ }),
210
211/***/ 6560:
212/***/ ((module) => {
213
214"use strict";
215
216
217module.exports = function () {
218 var assign = Object.assign, obj;
219 if (typeof assign !== "function") return false;
220 obj = { foo: "raz" };
221 assign(obj, { bar: "dwa" }, { trzy: "trzy" });
222 return obj.foo + obj.bar + obj.trzy === "razdwatrzy";
223};
224
225
226/***/ }),
227
228/***/ 7346:
229/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
230
231"use strict";
232
233
234var keys = __webpack_require__(5103)
235 , value = __webpack_require__(2745)
236 , max = Math.max;
237
238module.exports = function (dest, src/*, …srcn*/) {
239 var error, i, length = max(arguments.length, 2), assign;
240 dest = Object(value(dest));
241 assign = function (key) {
242 try {
243 dest[key] = src[key];
244 } catch (e) {
245 if (!error) error = e;
246 }
247 };
248 for (i = 1; i < length; ++i) {
249 src = arguments[i];
250 keys(src).forEach(assign);
251 }
252 if (error !== undefined) throw error;
253 return dest;
254};
255
256
257/***/ }),
258
259/***/ 6914:
260/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
261
262"use strict";
263
264
265var _undefined = __webpack_require__(430)(); // Support ES3 engines
266
267module.exports = function (val) { return val !== _undefined && val !== null; };
268
269
270/***/ }),
271
272/***/ 5103:
273/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
274
275"use strict";
276
277
278module.exports = __webpack_require__(7446)() ? Object.keys : __webpack_require__(6137);
279
280
281/***/ }),
282
283/***/ 7446:
284/***/ ((module) => {
285
286"use strict";
287
288
289module.exports = function () {
290 try {
291 Object.keys("primitive");
292 return true;
293 } catch (e) {
294 return false;
295 }
296};
297
298
299/***/ }),
300
301/***/ 6137:
302/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
303
304"use strict";
305
306
307var isValue = __webpack_require__(6914);
308
309var keys = Object.keys;
310
311module.exports = function (object) { return keys(isValue(object) ? Object(object) : object); };
312
313
314/***/ }),
315
316/***/ 5516:
317/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
318
319"use strict";
320
321
322var isValue = __webpack_require__(6914);
323
324var forEach = Array.prototype.forEach, create = Object.create;
325
326var process = function (src, obj) {
327 var key;
328 for (key in src) obj[key] = src[key];
329};
330
331// eslint-disable-next-line no-unused-vars
332module.exports = function (opts1/*, …options*/) {
333 var result = create(null);
334 forEach.call(arguments, function (options) {
335 if (!isValue(options)) return;
336 process(Object(options), result);
337 });
338 return result;
339};
340
341
342/***/ }),
343
344/***/ 1290:
345/***/ ((module) => {
346
347"use strict";
348
349
350module.exports = function (fn) {
351 if (typeof fn !== "function") throw new TypeError(fn + " is not a function");
352 return fn;
353};
354
355
356/***/ }),
357
358/***/ 2745:
359/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
360
361"use strict";
362
363
364var isValue = __webpack_require__(6914);
365
366module.exports = function (value) {
367 if (!isValue(value)) throw new TypeError("Cannot use null or undefined");
368 return value;
369};
370
371
372/***/ }),
373
374/***/ 9981:
375/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
376
377"use strict";
378
379
380module.exports = __webpack_require__(3591)() ? String.prototype.contains : __webpack_require__(6042);
381
382
383/***/ }),
384
385/***/ 3591:
386/***/ ((module) => {
387
388"use strict";
389
390
391var str = "razdwatrzy";
392
393module.exports = function () {
394 if (typeof str.contains !== "function") return false;
395 return str.contains("dwa") === true && str.contains("foo") === false;
396};
397
398
399/***/ }),
400
401/***/ 6042:
402/***/ ((module) => {
403
404"use strict";
405
406
407var indexOf = String.prototype.indexOf;
408
409module.exports = function (searchString/*, position*/) {
410 return indexOf.call(this, searchString, arguments[1]) > -1;
411};
412
413
414/***/ }),
415
416/***/ 8832:
417/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
418
419"use strict";
420
421
422var OneVersionConstraint = __webpack_require__(4167);
423
424var MY_VERSION = '7';
425OneVersionConstraint('ev-store', MY_VERSION);
426
427var hashKey = '__EV_STORE_KEY@' + MY_VERSION;
428
429module.exports = EvStore;
430
431function EvStore(elem) {
432 var hash = elem[hashKey];
433
434 if (!hash) {
435 hash = elem[hashKey] = {};
436 }
437
438 return hash;
439}
440
441
442/***/ }),
443
444/***/ 8370:
445/***/ ((module, exports, __webpack_require__) => {
446
447"use strict";
448
449
450var d = __webpack_require__(1804)
451 , callable = __webpack_require__(1290)
452
453 , apply = Function.prototype.apply, call = Function.prototype.call
454 , create = Object.create, defineProperty = Object.defineProperty
455 , defineProperties = Object.defineProperties
456 , hasOwnProperty = Object.prototype.hasOwnProperty
457 , descriptor = { configurable: true, enumerable: false, writable: true }
458
459 , on, once, off, emit, methods, descriptors, base;
460
461on = function (type, listener) {
462 var data;
463
464 callable(listener);
465
466 if (!hasOwnProperty.call(this, '__ee__')) {
467 data = descriptor.value = create(null);
468 defineProperty(this, '__ee__', descriptor);
469 descriptor.value = null;
470 } else {
471 data = this.__ee__;
472 }
473 if (!data[type]) data[type] = listener;
474 else if (typeof data[type] === 'object') data[type].push(listener);
475 else data[type] = [data[type], listener];
476
477 return this;
478};
479
480once = function (type, listener) {
481 var once, self;
482
483 callable(listener);
484 self = this;
485 on.call(this, type, once = function () {
486 off.call(self, type, once);
487 apply.call(listener, this, arguments);
488 });
489
490 once.__eeOnceListener__ = listener;
491 return this;
492};
493
494off = function (type, listener) {
495 var data, listeners, candidate, i;
496
497 callable(listener);
498
499 if (!hasOwnProperty.call(this, '__ee__')) return this;
500 data = this.__ee__;
501 if (!data[type]) return this;
502 listeners = data[type];
503
504 if (typeof listeners === 'object') {
505 for (i = 0; (candidate = listeners[i]); ++i) {
506 if ((candidate === listener) ||
507 (candidate.__eeOnceListener__ === listener)) {
508 if (listeners.length === 2) data[type] = listeners[i ? 0 : 1];
509 else listeners.splice(i, 1);
510 }
511 }
512 } else {
513 if ((listeners === listener) ||
514 (listeners.__eeOnceListener__ === listener)) {
515 delete data[type];
516 }
517 }
518
519 return this;
520};
521
522emit = function (type) {
523 var i, l, listener, listeners, args;
524
525 if (!hasOwnProperty.call(this, '__ee__')) return;
526 listeners = this.__ee__[type];
527 if (!listeners) return;
528
529 if (typeof listeners === 'object') {
530 l = arguments.length;
531 args = new Array(l - 1);
532 for (i = 1; i < l; ++i) args[i - 1] = arguments[i];
533
534 listeners = listeners.slice();
535 for (i = 0; (listener = listeners[i]); ++i) {
536 apply.call(listener, this, args);
537 }
538 } else {
539 switch (arguments.length) {
540 case 1:
541 call.call(listeners, this);
542 break;
543 case 2:
544 call.call(listeners, this, arguments[1]);
545 break;
546 case 3:
547 call.call(listeners, this, arguments[1], arguments[2]);
548 break;
549 default:
550 l = arguments.length;
551 args = new Array(l - 1);
552 for (i = 1; i < l; ++i) {
553 args[i - 1] = arguments[i];
554 }
555 apply.call(listeners, this, args);
556 }
557 }
558};
559
560methods = {
561 on: on,
562 once: once,
563 off: off,
564 emit: emit
565};
566
567descriptors = {
568 on: d(on),
569 once: d(once),
570 off: d(off),
571 emit: d(emit)
572};
573
574base = defineProperties({}, descriptors);
575
576module.exports = exports = function (o) {
577 return (o == null) ? create(base) : defineProperties(Object(o), descriptors);
578};
579exports.methods = methods;
580
581
582/***/ }),
583
584/***/ 6226:
585/***/ ((__unused_webpack_module, exports) => {
586
587"use strict";
588
589
590Object.defineProperty(exports, "__esModule", ({
591 value: true
592}));
593exports.linear = linear;
594exports.exponential = exponential;
595exports.sCurve = sCurve;
596exports.logarithmic = logarithmic;
597function linear(length, rotation) {
598 var curve = new Float32Array(length),
599 i,
600 x,
601 scale = length - 1;
602
603 for (i = 0; i < length; i++) {
604 x = i / scale;
605
606 if (rotation > 0) {
607 curve[i] = x;
608 } else {
609 curve[i] = 1 - x;
610 }
611 }
612
613 return curve;
614}
615
616function exponential(length, rotation) {
617 var curve = new Float32Array(length),
618 i,
619 x,
620 scale = length - 1,
621 index;
622
623 for (i = 0; i < length; i++) {
624 x = i / scale;
625 index = rotation > 0 ? i : length - 1 - i;
626
627 curve[index] = Math.exp(2 * x - 1) / Math.exp(1);
628 }
629
630 return curve;
631}
632
633//creating a curve to simulate an S-curve with setValueCurveAtTime.
634function sCurve(length, rotation) {
635 var curve = new Float32Array(length),
636 i,
637 phase = rotation > 0 ? Math.PI / 2 : -(Math.PI / 2);
638
639 for (i = 0; i < length; ++i) {
640 curve[i] = Math.sin(Math.PI * i / length - phase) / 2 + 0.5;
641 }
642 return curve;
643}
644
645//creating a curve to simulate a logarithmic curve with setValueCurveAtTime.
646function logarithmic(length, base, rotation) {
647 var curve = new Float32Array(length),
648 index,
649 x = 0,
650 i;
651
652 for (i = 0; i < length; i++) {
653 //index for the curve array.
654 index = rotation > 0 ? i : length - 1 - i;
655
656 x = i / length;
657 curve[index] = Math.log(1 + base * x) / Math.log(1 + base);
658 }
659
660 return curve;
661}
662
663
664/***/ }),
665
666/***/ 1114:
667/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
668
669"use strict";
670var __webpack_unused_export__;
671
672
673__webpack_unused_export__ = ({
674 value: true
675});
676exports.h7 = exports.Y1 = exports.Hp = exports.Jl = exports.t$ = exports._h = undefined;
677exports.L7 = createFadeIn;
678exports.Mt = createFadeOut;
679
680var _fadeCurves = __webpack_require__(6226);
681
682var SCURVE = exports._h = "sCurve";
683var LINEAR = exports.t$ = "linear";
684var EXPONENTIAL = exports.Jl = "exponential";
685var LOGARITHMIC = exports.Hp = "logarithmic";
686
687var FADEIN = exports.Y1 = "FadeIn";
688var FADEOUT = exports.h7 = "FadeOut";
689
690function sCurveFadeIn(start, duration) {
691 var curve = (0, _fadeCurves.sCurve)(10000, 1);
692 this.setValueCurveAtTime(curve, start, duration);
693}
694
695function sCurveFadeOut(start, duration) {
696 var curve = (0, _fadeCurves.sCurve)(10000, -1);
697 this.setValueCurveAtTime(curve, start, duration);
698}
699
700function linearFadeIn(start, duration) {
701 this.linearRampToValueAtTime(0, start);
702 this.linearRampToValueAtTime(1, start + duration);
703}
704
705function linearFadeOut(start, duration) {
706 this.linearRampToValueAtTime(1, start);
707 this.linearRampToValueAtTime(0, start + duration);
708}
709
710function exponentialFadeIn(start, duration) {
711 this.exponentialRampToValueAtTime(0.01, start);
712 this.exponentialRampToValueAtTime(1, start + duration);
713}
714
715function exponentialFadeOut(start, duration) {
716 this.exponentialRampToValueAtTime(1, start);
717 this.exponentialRampToValueAtTime(0.01, start + duration);
718}
719
720function logarithmicFadeIn(start, duration) {
721 var curve = (0, _fadeCurves.logarithmic)(10000, 10, 1);
722 this.setValueCurveAtTime(curve, start, duration);
723}
724
725function logarithmicFadeOut(start, duration) {
726 var curve = (0, _fadeCurves.logarithmic)(10000, 10, -1);
727 this.setValueCurveAtTime(curve, start, duration);
728}
729
730function createFadeIn(gain, shape, start, duration) {
731 switch (shape) {
732 case SCURVE:
733 sCurveFadeIn.call(gain, start, duration);
734 break;
735 case LINEAR:
736 linearFadeIn.call(gain, start, duration);
737 break;
738 case EXPONENTIAL:
739 exponentialFadeIn.call(gain, start, duration);
740 break;
741 case LOGARITHMIC:
742 logarithmicFadeIn.call(gain, start, duration);
743 break;
744 default:
745 throw new Error("Unsupported Fade type");
746 }
747}
748
749function createFadeOut(gain, shape, start, duration) {
750 switch (shape) {
751 case SCURVE:
752 sCurveFadeOut.call(gain, start, duration);
753 break;
754 case LINEAR:
755 linearFadeOut.call(gain, start, duration);
756 break;
757 case EXPONENTIAL:
758 exponentialFadeOut.call(gain, start, duration);
759 break;
760 case LOGARITHMIC:
761 logarithmicFadeOut.call(gain, start, duration);
762 break;
763 default:
764 throw new Error("Unsupported Fade type");
765 }
766}
767
768
769/***/ }),
770
771/***/ 9144:
772/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
773
774var topLevel = typeof __webpack_require__.g !== 'undefined' ? __webpack_require__.g :
775 typeof window !== 'undefined' ? window : {}
776var minDoc = __webpack_require__(5893);
777
778var doccy;
779
780if (typeof document !== 'undefined') {
781 doccy = document;
782} else {
783 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
784
785 if (!doccy) {
786 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
787 }
788}
789
790module.exports = doccy;
791
792
793/***/ }),
794
795/***/ 8070:
796/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
797
798"use strict";
799
800
801/*global window, global*/
802
803var root = typeof window !== 'undefined' ?
804 window : typeof __webpack_require__.g !== 'undefined' ?
805 __webpack_require__.g : {};
806
807module.exports = Individual;
808
809function Individual(key, value) {
810 if (key in root) {
811 return root[key];
812 }
813
814 root[key] = value;
815
816 return value;
817}
818
819
820/***/ }),
821
822/***/ 4167:
823/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
824
825"use strict";
826
827
828var Individual = __webpack_require__(8070);
829
830module.exports = OneVersion;
831
832function OneVersion(moduleName, version, defaultValue) {
833 var key = '__INDIVIDUAL_ONE_VERSION_' + moduleName;
834 var enforceKey = key + '_ENFORCE_SINGLETON';
835
836 var versionValue = Individual(enforceKey, version);
837
838 if (versionValue !== version) {
839 throw new Error('Can only have one copy of ' +
840 moduleName + '.\n' +
841 'You already have version ' + versionValue +
842 ' installed.\n' +
843 'This means you cannot install version ' + version);
844 }
845
846 return Individual(key, defaultValue);
847}
848
849
850/***/ }),
851
852/***/ 849:
853/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
854
855var WORKER_ENABLED = !!(__webpack_require__.g === __webpack_require__.g.window && __webpack_require__.g.URL && __webpack_require__.g.Blob && __webpack_require__.g.Worker);
856
857function InlineWorker(func, self) {
858 var _this = this;
859 var functionBody;
860
861 self = self || {};
862
863 if (WORKER_ENABLED) {
864 functionBody = func.toString().trim().match(
865 /^function\s*\w*\s*\([\w\s,]*\)\s*{([\w\W]*?)}$/
866 )[1];
867
868 return new __webpack_require__.g.Worker(__webpack_require__.g.URL.createObjectURL(
869 new __webpack_require__.g.Blob([ functionBody ], { type: "text/javascript" })
870 ));
871 }
872
873 function postMessage(data) {
874 setTimeout(function() {
875 _this.onmessage({ data: data });
876 }, 0);
877 }
878
879 this.self = self;
880 this.self.postMessage = postMessage;
881
882 setTimeout(func.bind(self, self), 0);
883}
884
885InlineWorker.prototype.postMessage = function postMessage(data) {
886 var _this = this;
887
888 setTimeout(function() {
889 _this.self.onmessage({ data: data });
890 }, 0);
891};
892
893module.exports = InlineWorker;
894
895
896/***/ }),
897
898/***/ 6240:
899/***/ ((module) => {
900
901"use strict";
902
903
904module.exports = function isObject(x) {
905 return typeof x === "object" && x !== null;
906};
907
908
909/***/ }),
910
911/***/ 1730:
912/***/ ((module) => {
913
914/**
915 * lodash (Custom Build) <https://lodash.com/>
916 * Build: `lodash modularize exports="npm" -o ./`
917 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
918 * Released under MIT license <https://lodash.com/license>
919 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
920 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
921 */
922
923/** Used as references for various `Number` constants. */
924var MAX_SAFE_INTEGER = 9007199254740991;
925
926/** `Object#toString` result references. */
927var argsTag = '[object Arguments]',
928 funcTag = '[object Function]',
929 genTag = '[object GeneratorFunction]';
930
931/** Used to detect unsigned integer values. */
932var reIsUint = /^(?:0|[1-9]\d*)$/;
933
934/**
935 * A faster alternative to `Function#apply`, this function invokes `func`
936 * with the `this` binding of `thisArg` and the arguments of `args`.
937 *
938 * @private
939 * @param {Function} func The function to invoke.
940 * @param {*} thisArg The `this` binding of `func`.
941 * @param {Array} args The arguments to invoke `func` with.
942 * @returns {*} Returns the result of `func`.
943 */
944function apply(func, thisArg, args) {
945 switch (args.length) {
946 case 0: return func.call(thisArg);
947 case 1: return func.call(thisArg, args[0]);
948 case 2: return func.call(thisArg, args[0], args[1]);
949 case 3: return func.call(thisArg, args[0], args[1], args[2]);
950 }
951 return func.apply(thisArg, args);
952}
953
954/**
955 * The base implementation of `_.times` without support for iteratee shorthands
956 * or max array length checks.
957 *
958 * @private
959 * @param {number} n The number of times to invoke `iteratee`.
960 * @param {Function} iteratee The function invoked per iteration.
961 * @returns {Array} Returns the array of results.
962 */
963function baseTimes(n, iteratee) {
964 var index = -1,
965 result = Array(n);
966
967 while (++index < n) {
968 result[index] = iteratee(index);
969 }
970 return result;
971}
972
973/**
974 * Creates a unary function that invokes `func` with its argument transformed.
975 *
976 * @private
977 * @param {Function} func The function to wrap.
978 * @param {Function} transform The argument transform.
979 * @returns {Function} Returns the new function.
980 */
981function overArg(func, transform) {
982 return function(arg) {
983 return func(transform(arg));
984 };
985}
986
987/** Used for built-in method references. */
988var objectProto = Object.prototype;
989
990/** Used to check objects for own properties. */
991var hasOwnProperty = objectProto.hasOwnProperty;
992
993/**
994 * Used to resolve the
995 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
996 * of values.
997 */
998var objectToString = objectProto.toString;
999
1000/** Built-in value references. */
1001var propertyIsEnumerable = objectProto.propertyIsEnumerable;
1002
1003/* Built-in method references for those with the same name as other `lodash` methods. */
1004var nativeKeys = overArg(Object.keys, Object),
1005 nativeMax = Math.max;
1006
1007/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
1008var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
1009
1010/**
1011 * Creates an array of the enumerable property names of the array-like `value`.
1012 *
1013 * @private
1014 * @param {*} value The value to query.
1015 * @param {boolean} inherited Specify returning inherited property names.
1016 * @returns {Array} Returns the array of property names.
1017 */
1018function arrayLikeKeys(value, inherited) {
1019 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
1020 // Safari 9 makes `arguments.length` enumerable in strict mode.
1021 var result = (isArray(value) || isArguments(value))
1022 ? baseTimes(value.length, String)
1023 : [];
1024
1025 var length = result.length,
1026 skipIndexes = !!length;
1027
1028 for (var key in value) {
1029 if ((inherited || hasOwnProperty.call(value, key)) &&
1030 !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
1031 result.push(key);
1032 }
1033 }
1034 return result;
1035}
1036
1037/**
1038 * Assigns `value` to `key` of `object` if the existing value is not equivalent
1039 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1040 * for equality comparisons.
1041 *
1042 * @private
1043 * @param {Object} object The object to modify.
1044 * @param {string} key The key of the property to assign.
1045 * @param {*} value The value to assign.
1046 */
1047function assignValue(object, key, value) {
1048 var objValue = object[key];
1049 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
1050 (value === undefined && !(key in object))) {
1051 object[key] = value;
1052 }
1053}
1054
1055/**
1056 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1057 *
1058 * @private
1059 * @param {Object} object The object to query.
1060 * @returns {Array} Returns the array of property names.
1061 */
1062function baseKeys(object) {
1063 if (!isPrototype(object)) {
1064 return nativeKeys(object);
1065 }
1066 var result = [];
1067 for (var key in Object(object)) {
1068 if (hasOwnProperty.call(object, key) && key != 'constructor') {
1069 result.push(key);
1070 }
1071 }
1072 return result;
1073}
1074
1075/**
1076 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
1077 *
1078 * @private
1079 * @param {Function} func The function to apply a rest parameter to.
1080 * @param {number} [start=func.length-1] The start position of the rest parameter.
1081 * @returns {Function} Returns the new function.
1082 */
1083function baseRest(func, start) {
1084 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
1085 return function() {
1086 var args = arguments,
1087 index = -1,
1088 length = nativeMax(args.length - start, 0),
1089 array = Array(length);
1090
1091 while (++index < length) {
1092 array[index] = args[start + index];
1093 }
1094 index = -1;
1095 var otherArgs = Array(start + 1);
1096 while (++index < start) {
1097 otherArgs[index] = args[index];
1098 }
1099 otherArgs[start] = array;
1100 return apply(func, this, otherArgs);
1101 };
1102}
1103
1104/**
1105 * Copies properties of `source` to `object`.
1106 *
1107 * @private
1108 * @param {Object} source The object to copy properties from.
1109 * @param {Array} props The property identifiers to copy.
1110 * @param {Object} [object={}] The object to copy properties to.
1111 * @param {Function} [customizer] The function to customize copied values.
1112 * @returns {Object} Returns `object`.
1113 */
1114function copyObject(source, props, object, customizer) {
1115 object || (object = {});
1116
1117 var index = -1,
1118 length = props.length;
1119
1120 while (++index < length) {
1121 var key = props[index];
1122
1123 var newValue = customizer
1124 ? customizer(object[key], source[key], key, object, source)
1125 : undefined;
1126
1127 assignValue(object, key, newValue === undefined ? source[key] : newValue);
1128 }
1129 return object;
1130}
1131
1132/**
1133 * Creates a function like `_.assign`.
1134 *
1135 * @private
1136 * @param {Function} assigner The function to assign values.
1137 * @returns {Function} Returns the new assigner function.
1138 */
1139function createAssigner(assigner) {
1140 return baseRest(function(object, sources) {
1141 var index = -1,
1142 length = sources.length,
1143 customizer = length > 1 ? sources[length - 1] : undefined,
1144 guard = length > 2 ? sources[2] : undefined;
1145
1146 customizer = (assigner.length > 3 && typeof customizer == 'function')
1147 ? (length--, customizer)
1148 : undefined;
1149
1150 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
1151 customizer = length < 3 ? undefined : customizer;
1152 length = 1;
1153 }
1154 object = Object(object);
1155 while (++index < length) {
1156 var source = sources[index];
1157 if (source) {
1158 assigner(object, source, index, customizer);
1159 }
1160 }
1161 return object;
1162 });
1163}
1164
1165/**
1166 * Checks if `value` is a valid array-like index.
1167 *
1168 * @private
1169 * @param {*} value The value to check.
1170 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1171 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1172 */
1173function isIndex(value, length) {
1174 length = length == null ? MAX_SAFE_INTEGER : length;
1175 return !!length &&
1176 (typeof value == 'number' || reIsUint.test(value)) &&
1177 (value > -1 && value % 1 == 0 && value < length);
1178}
1179
1180/**
1181 * Checks if the given arguments are from an iteratee call.
1182 *
1183 * @private
1184 * @param {*} value The potential iteratee value argument.
1185 * @param {*} index The potential iteratee index or key argument.
1186 * @param {*} object The potential iteratee object argument.
1187 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
1188 * else `false`.
1189 */
1190function isIterateeCall(value, index, object) {
1191 if (!isObject(object)) {
1192 return false;
1193 }
1194 var type = typeof index;
1195 if (type == 'number'
1196 ? (isArrayLike(object) && isIndex(index, object.length))
1197 : (type == 'string' && index in object)
1198 ) {
1199 return eq(object[index], value);
1200 }
1201 return false;
1202}
1203
1204/**
1205 * Checks if `value` is likely a prototype object.
1206 *
1207 * @private
1208 * @param {*} value The value to check.
1209 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1210 */
1211function isPrototype(value) {
1212 var Ctor = value && value.constructor,
1213 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1214
1215 return value === proto;
1216}
1217
1218/**
1219 * Performs a
1220 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1221 * comparison between two values to determine if they are equivalent.
1222 *
1223 * @static
1224 * @memberOf _
1225 * @since 4.0.0
1226 * @category Lang
1227 * @param {*} value The value to compare.
1228 * @param {*} other The other value to compare.
1229 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1230 * @example
1231 *
1232 * var object = { 'a': 1 };
1233 * var other = { 'a': 1 };
1234 *
1235 * _.eq(object, object);
1236 * // => true
1237 *
1238 * _.eq(object, other);
1239 * // => false
1240 *
1241 * _.eq('a', 'a');
1242 * // => true
1243 *
1244 * _.eq('a', Object('a'));
1245 * // => false
1246 *
1247 * _.eq(NaN, NaN);
1248 * // => true
1249 */
1250function eq(value, other) {
1251 return value === other || (value !== value && other !== other);
1252}
1253
1254/**
1255 * Checks if `value` is likely an `arguments` object.
1256 *
1257 * @static
1258 * @memberOf _
1259 * @since 0.1.0
1260 * @category Lang
1261 * @param {*} value The value to check.
1262 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1263 * else `false`.
1264 * @example
1265 *
1266 * _.isArguments(function() { return arguments; }());
1267 * // => true
1268 *
1269 * _.isArguments([1, 2, 3]);
1270 * // => false
1271 */
1272function isArguments(value) {
1273 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
1274 return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
1275 (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
1276}
1277
1278/**
1279 * Checks if `value` is classified as an `Array` object.
1280 *
1281 * @static
1282 * @memberOf _
1283 * @since 0.1.0
1284 * @category Lang
1285 * @param {*} value The value to check.
1286 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1287 * @example
1288 *
1289 * _.isArray([1, 2, 3]);
1290 * // => true
1291 *
1292 * _.isArray(document.body.children);
1293 * // => false
1294 *
1295 * _.isArray('abc');
1296 * // => false
1297 *
1298 * _.isArray(_.noop);
1299 * // => false
1300 */
1301var isArray = Array.isArray;
1302
1303/**
1304 * Checks if `value` is array-like. A value is considered array-like if it's
1305 * not a function and has a `value.length` that's an integer greater than or
1306 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1307 *
1308 * @static
1309 * @memberOf _
1310 * @since 4.0.0
1311 * @category Lang
1312 * @param {*} value The value to check.
1313 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1314 * @example
1315 *
1316 * _.isArrayLike([1, 2, 3]);
1317 * // => true
1318 *
1319 * _.isArrayLike(document.body.children);
1320 * // => true
1321 *
1322 * _.isArrayLike('abc');
1323 * // => true
1324 *
1325 * _.isArrayLike(_.noop);
1326 * // => false
1327 */
1328function isArrayLike(value) {
1329 return value != null && isLength(value.length) && !isFunction(value);
1330}
1331
1332/**
1333 * This method is like `_.isArrayLike` except that it also checks if `value`
1334 * is an object.
1335 *
1336 * @static
1337 * @memberOf _
1338 * @since 4.0.0
1339 * @category Lang
1340 * @param {*} value The value to check.
1341 * @returns {boolean} Returns `true` if `value` is an array-like object,
1342 * else `false`.
1343 * @example
1344 *
1345 * _.isArrayLikeObject([1, 2, 3]);
1346 * // => true
1347 *
1348 * _.isArrayLikeObject(document.body.children);
1349 * // => true
1350 *
1351 * _.isArrayLikeObject('abc');
1352 * // => false
1353 *
1354 * _.isArrayLikeObject(_.noop);
1355 * // => false
1356 */
1357function isArrayLikeObject(value) {
1358 return isObjectLike(value) && isArrayLike(value);
1359}
1360
1361/**
1362 * Checks if `value` is classified as a `Function` object.
1363 *
1364 * @static
1365 * @memberOf _
1366 * @since 0.1.0
1367 * @category Lang
1368 * @param {*} value The value to check.
1369 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1370 * @example
1371 *
1372 * _.isFunction(_);
1373 * // => true
1374 *
1375 * _.isFunction(/abc/);
1376 * // => false
1377 */
1378function isFunction(value) {
1379 // The use of `Object#toString` avoids issues with the `typeof` operator
1380 // in Safari 8-9 which returns 'object' for typed array and other constructors.
1381 var tag = isObject(value) ? objectToString.call(value) : '';
1382 return tag == funcTag || tag == genTag;
1383}
1384
1385/**
1386 * Checks if `value` is a valid array-like length.
1387 *
1388 * **Note:** This method is loosely based on
1389 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1390 *
1391 * @static
1392 * @memberOf _
1393 * @since 4.0.0
1394 * @category Lang
1395 * @param {*} value The value to check.
1396 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1397 * @example
1398 *
1399 * _.isLength(3);
1400 * // => true
1401 *
1402 * _.isLength(Number.MIN_VALUE);
1403 * // => false
1404 *
1405 * _.isLength(Infinity);
1406 * // => false
1407 *
1408 * _.isLength('3');
1409 * // => false
1410 */
1411function isLength(value) {
1412 return typeof value == 'number' &&
1413 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1414}
1415
1416/**
1417 * Checks if `value` is the
1418 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1419 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1420 *
1421 * @static
1422 * @memberOf _
1423 * @since 0.1.0
1424 * @category Lang
1425 * @param {*} value The value to check.
1426 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1427 * @example
1428 *
1429 * _.isObject({});
1430 * // => true
1431 *
1432 * _.isObject([1, 2, 3]);
1433 * // => true
1434 *
1435 * _.isObject(_.noop);
1436 * // => true
1437 *
1438 * _.isObject(null);
1439 * // => false
1440 */
1441function isObject(value) {
1442 var type = typeof value;
1443 return !!value && (type == 'object' || type == 'function');
1444}
1445
1446/**
1447 * Checks if `value` is object-like. A value is object-like if it's not `null`
1448 * and has a `typeof` result of "object".
1449 *
1450 * @static
1451 * @memberOf _
1452 * @since 4.0.0
1453 * @category Lang
1454 * @param {*} value The value to check.
1455 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1456 * @example
1457 *
1458 * _.isObjectLike({});
1459 * // => true
1460 *
1461 * _.isObjectLike([1, 2, 3]);
1462 * // => true
1463 *
1464 * _.isObjectLike(_.noop);
1465 * // => false
1466 *
1467 * _.isObjectLike(null);
1468 * // => false
1469 */
1470function isObjectLike(value) {
1471 return !!value && typeof value == 'object';
1472}
1473
1474/**
1475 * Assigns own enumerable string keyed properties of source objects to the
1476 * destination object. Source objects are applied from left to right.
1477 * Subsequent sources overwrite property assignments of previous sources.
1478 *
1479 * **Note:** This method mutates `object` and is loosely based on
1480 * [`Object.assign`](https://mdn.io/Object/assign).
1481 *
1482 * @static
1483 * @memberOf _
1484 * @since 0.10.0
1485 * @category Object
1486 * @param {Object} object The destination object.
1487 * @param {...Object} [sources] The source objects.
1488 * @returns {Object} Returns `object`.
1489 * @see _.assignIn
1490 * @example
1491 *
1492 * function Foo() {
1493 * this.a = 1;
1494 * }
1495 *
1496 * function Bar() {
1497 * this.c = 3;
1498 * }
1499 *
1500 * Foo.prototype.b = 2;
1501 * Bar.prototype.d = 4;
1502 *
1503 * _.assign({ 'a': 0 }, new Foo, new Bar);
1504 * // => { 'a': 1, 'c': 3 }
1505 */
1506var assign = createAssigner(function(object, source) {
1507 if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
1508 copyObject(source, keys(source), object);
1509 return;
1510 }
1511 for (var key in source) {
1512 if (hasOwnProperty.call(source, key)) {
1513 assignValue(object, key, source[key]);
1514 }
1515 }
1516});
1517
1518/**
1519 * Creates an array of the own enumerable property names of `object`.
1520 *
1521 * **Note:** Non-object values are coerced to objects. See the
1522 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1523 * for more details.
1524 *
1525 * @static
1526 * @since 0.1.0
1527 * @memberOf _
1528 * @category Object
1529 * @param {Object} object The object to query.
1530 * @returns {Array} Returns the array of property names.
1531 * @example
1532 *
1533 * function Foo() {
1534 * this.a = 1;
1535 * this.b = 2;
1536 * }
1537 *
1538 * Foo.prototype.c = 3;
1539 *
1540 * _.keys(new Foo);
1541 * // => ['a', 'b'] (iteration order is not guaranteed)
1542 *
1543 * _.keys('hi');
1544 * // => ['0', '1']
1545 */
1546function keys(object) {
1547 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1548}
1549
1550module.exports = assign;
1551
1552
1553/***/ }),
1554
1555/***/ 2098:
1556/***/ ((module, exports, __webpack_require__) => {
1557
1558/* module decorator */ module = __webpack_require__.nmd(module);
1559/**
1560 * Lodash (Custom Build) <https://lodash.com/>
1561 * Build: `lodash modularize exports="npm" -o ./`
1562 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
1563 * Released under MIT license <https://lodash.com/license>
1564 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1565 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1566 */
1567
1568/** Used as the size to enable large array optimizations. */
1569var LARGE_ARRAY_SIZE = 200;
1570
1571/** Used to stand-in for `undefined` hash values. */
1572var HASH_UNDEFINED = '__lodash_hash_undefined__';
1573
1574/** Used to detect hot functions by number of calls within a span of milliseconds. */
1575var HOT_COUNT = 800,
1576 HOT_SPAN = 16;
1577
1578/** Used as references for various `Number` constants. */
1579var MAX_SAFE_INTEGER = 9007199254740991;
1580
1581/** `Object#toString` result references. */
1582var argsTag = '[object Arguments]',
1583 arrayTag = '[object Array]',
1584 asyncTag = '[object AsyncFunction]',
1585 boolTag = '[object Boolean]',
1586 dateTag = '[object Date]',
1587 errorTag = '[object Error]',
1588 funcTag = '[object Function]',
1589 genTag = '[object GeneratorFunction]',
1590 mapTag = '[object Map]',
1591 numberTag = '[object Number]',
1592 nullTag = '[object Null]',
1593 objectTag = '[object Object]',
1594 proxyTag = '[object Proxy]',
1595 regexpTag = '[object RegExp]',
1596 setTag = '[object Set]',
1597 stringTag = '[object String]',
1598 undefinedTag = '[object Undefined]',
1599 weakMapTag = '[object WeakMap]';
1600
1601var arrayBufferTag = '[object ArrayBuffer]',
1602 dataViewTag = '[object DataView]',
1603 float32Tag = '[object Float32Array]',
1604 float64Tag = '[object Float64Array]',
1605 int8Tag = '[object Int8Array]',
1606 int16Tag = '[object Int16Array]',
1607 int32Tag = '[object Int32Array]',
1608 uint8Tag = '[object Uint8Array]',
1609 uint8ClampedTag = '[object Uint8ClampedArray]',
1610 uint16Tag = '[object Uint16Array]',
1611 uint32Tag = '[object Uint32Array]';
1612
1613/**
1614 * Used to match `RegExp`
1615 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
1616 */
1617var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
1618
1619/** Used to detect host constructors (Safari). */
1620var reIsHostCtor = /^\[object .+?Constructor\]$/;
1621
1622/** Used to detect unsigned integer values. */
1623var reIsUint = /^(?:0|[1-9]\d*)$/;
1624
1625/** Used to identify `toStringTag` values of typed arrays. */
1626var typedArrayTags = {};
1627typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
1628typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
1629typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
1630typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
1631typedArrayTags[uint32Tag] = true;
1632typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
1633typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
1634typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
1635typedArrayTags[errorTag] = typedArrayTags[funcTag] =
1636typedArrayTags[mapTag] = typedArrayTags[numberTag] =
1637typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
1638typedArrayTags[setTag] = typedArrayTags[stringTag] =
1639typedArrayTags[weakMapTag] = false;
1640
1641/** Detect free variable `global` from Node.js. */
1642var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
1643
1644/** Detect free variable `self`. */
1645var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
1646
1647/** Used as a reference to the global object. */
1648var root = freeGlobal || freeSelf || Function('return this')();
1649
1650/** Detect free variable `exports`. */
1651var freeExports = true && exports && !exports.nodeType && exports;
1652
1653/** Detect free variable `module`. */
1654var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
1655
1656/** Detect the popular CommonJS extension `module.exports`. */
1657var moduleExports = freeModule && freeModule.exports === freeExports;
1658
1659/** Detect free variable `process` from Node.js. */
1660var freeProcess = moduleExports && freeGlobal.process;
1661
1662/** Used to access faster Node.js helpers. */
1663var nodeUtil = (function() {
1664 try {
1665 // Use `util.types` for Node.js 10+.
1666 var types = freeModule && freeModule.require && freeModule.require('util').types;
1667
1668 if (types) {
1669 return types;
1670 }
1671
1672 // Legacy `process.binding('util')` for Node.js < 10.
1673 return freeProcess && freeProcess.binding && freeProcess.binding('util');
1674 } catch (e) {}
1675}());
1676
1677/* Node.js helper references. */
1678var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1679
1680/**
1681 * A faster alternative to `Function#apply`, this function invokes `func`
1682 * with the `this` binding of `thisArg` and the arguments of `args`.
1683 *
1684 * @private
1685 * @param {Function} func The function to invoke.
1686 * @param {*} thisArg The `this` binding of `func`.
1687 * @param {Array} args The arguments to invoke `func` with.
1688 * @returns {*} Returns the result of `func`.
1689 */
1690function apply(func, thisArg, args) {
1691 switch (args.length) {
1692 case 0: return func.call(thisArg);
1693 case 1: return func.call(thisArg, args[0]);
1694 case 2: return func.call(thisArg, args[0], args[1]);
1695 case 3: return func.call(thisArg, args[0], args[1], args[2]);
1696 }
1697 return func.apply(thisArg, args);
1698}
1699
1700/**
1701 * The base implementation of `_.times` without support for iteratee shorthands
1702 * or max array length checks.
1703 *
1704 * @private
1705 * @param {number} n The number of times to invoke `iteratee`.
1706 * @param {Function} iteratee The function invoked per iteration.
1707 * @returns {Array} Returns the array of results.
1708 */
1709function baseTimes(n, iteratee) {
1710 var index = -1,
1711 result = Array(n);
1712
1713 while (++index < n) {
1714 result[index] = iteratee(index);
1715 }
1716 return result;
1717}
1718
1719/**
1720 * The base implementation of `_.unary` without support for storing metadata.
1721 *
1722 * @private
1723 * @param {Function} func The function to cap arguments for.
1724 * @returns {Function} Returns the new capped function.
1725 */
1726function baseUnary(func) {
1727 return function(value) {
1728 return func(value);
1729 };
1730}
1731
1732/**
1733 * Gets the value at `key` of `object`.
1734 *
1735 * @private
1736 * @param {Object} [object] The object to query.
1737 * @param {string} key The key of the property to get.
1738 * @returns {*} Returns the property value.
1739 */
1740function getValue(object, key) {
1741 return object == null ? undefined : object[key];
1742}
1743
1744/**
1745 * Creates a unary function that invokes `func` with its argument transformed.
1746 *
1747 * @private
1748 * @param {Function} func The function to wrap.
1749 * @param {Function} transform The argument transform.
1750 * @returns {Function} Returns the new function.
1751 */
1752function overArg(func, transform) {
1753 return function(arg) {
1754 return func(transform(arg));
1755 };
1756}
1757
1758/** Used for built-in method references. */
1759var arrayProto = Array.prototype,
1760 funcProto = Function.prototype,
1761 objectProto = Object.prototype;
1762
1763/** Used to detect overreaching core-js shims. */
1764var coreJsData = root['__core-js_shared__'];
1765
1766/** Used to resolve the decompiled source of functions. */
1767var funcToString = funcProto.toString;
1768
1769/** Used to check objects for own properties. */
1770var hasOwnProperty = objectProto.hasOwnProperty;
1771
1772/** Used to detect methods masquerading as native. */
1773var maskSrcKey = (function() {
1774 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1775 return uid ? ('Symbol(src)_1.' + uid) : '';
1776}());
1777
1778/**
1779 * Used to resolve the
1780 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1781 * of values.
1782 */
1783var nativeObjectToString = objectProto.toString;
1784
1785/** Used to infer the `Object` constructor. */
1786var objectCtorString = funcToString.call(Object);
1787
1788/** Used to detect if a method is native. */
1789var reIsNative = RegExp('^' +
1790 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
1791 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1792);
1793
1794/** Built-in value references. */
1795var Buffer = moduleExports ? root.Buffer : undefined,
1796 Symbol = root.Symbol,
1797 Uint8Array = root.Uint8Array,
1798 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
1799 getPrototype = overArg(Object.getPrototypeOf, Object),
1800 objectCreate = Object.create,
1801 propertyIsEnumerable = objectProto.propertyIsEnumerable,
1802 splice = arrayProto.splice,
1803 symToStringTag = Symbol ? Symbol.toStringTag : undefined;
1804
1805var defineProperty = (function() {
1806 try {
1807 var func = getNative(Object, 'defineProperty');
1808 func({}, '', {});
1809 return func;
1810 } catch (e) {}
1811}());
1812
1813/* Built-in method references for those with the same name as other `lodash` methods. */
1814var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
1815 nativeMax = Math.max,
1816 nativeNow = Date.now;
1817
1818/* Built-in method references that are verified to be native. */
1819var Map = getNative(root, 'Map'),
1820 nativeCreate = getNative(Object, 'create');
1821
1822/**
1823 * The base implementation of `_.create` without support for assigning
1824 * properties to the created object.
1825 *
1826 * @private
1827 * @param {Object} proto The object to inherit from.
1828 * @returns {Object} Returns the new object.
1829 */
1830var baseCreate = (function() {
1831 function object() {}
1832 return function(proto) {
1833 if (!isObject(proto)) {
1834 return {};
1835 }
1836 if (objectCreate) {
1837 return objectCreate(proto);
1838 }
1839 object.prototype = proto;
1840 var result = new object;
1841 object.prototype = undefined;
1842 return result;
1843 };
1844}());
1845
1846/**
1847 * Creates a hash object.
1848 *
1849 * @private
1850 * @constructor
1851 * @param {Array} [entries] The key-value pairs to cache.
1852 */
1853function Hash(entries) {
1854 var index = -1,
1855 length = entries == null ? 0 : entries.length;
1856
1857 this.clear();
1858 while (++index < length) {
1859 var entry = entries[index];
1860 this.set(entry[0], entry[1]);
1861 }
1862}
1863
1864/**
1865 * Removes all key-value entries from the hash.
1866 *
1867 * @private
1868 * @name clear
1869 * @memberOf Hash
1870 */
1871function hashClear() {
1872 this.__data__ = nativeCreate ? nativeCreate(null) : {};
1873 this.size = 0;
1874}
1875
1876/**
1877 * Removes `key` and its value from the hash.
1878 *
1879 * @private
1880 * @name delete
1881 * @memberOf Hash
1882 * @param {Object} hash The hash to modify.
1883 * @param {string} key The key of the value to remove.
1884 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1885 */
1886function hashDelete(key) {
1887 var result = this.has(key) && delete this.__data__[key];
1888 this.size -= result ? 1 : 0;
1889 return result;
1890}
1891
1892/**
1893 * Gets the hash value for `key`.
1894 *
1895 * @private
1896 * @name get
1897 * @memberOf Hash
1898 * @param {string} key The key of the value to get.
1899 * @returns {*} Returns the entry value.
1900 */
1901function hashGet(key) {
1902 var data = this.__data__;
1903 if (nativeCreate) {
1904 var result = data[key];
1905 return result === HASH_UNDEFINED ? undefined : result;
1906 }
1907 return hasOwnProperty.call(data, key) ? data[key] : undefined;
1908}
1909
1910/**
1911 * Checks if a hash value for `key` exists.
1912 *
1913 * @private
1914 * @name has
1915 * @memberOf Hash
1916 * @param {string} key The key of the entry to check.
1917 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1918 */
1919function hashHas(key) {
1920 var data = this.__data__;
1921 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
1922}
1923
1924/**
1925 * Sets the hash `key` to `value`.
1926 *
1927 * @private
1928 * @name set
1929 * @memberOf Hash
1930 * @param {string} key The key of the value to set.
1931 * @param {*} value The value to set.
1932 * @returns {Object} Returns the hash instance.
1933 */
1934function hashSet(key, value) {
1935 var data = this.__data__;
1936 this.size += this.has(key) ? 0 : 1;
1937 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
1938 return this;
1939}
1940
1941// Add methods to `Hash`.
1942Hash.prototype.clear = hashClear;
1943Hash.prototype['delete'] = hashDelete;
1944Hash.prototype.get = hashGet;
1945Hash.prototype.has = hashHas;
1946Hash.prototype.set = hashSet;
1947
1948/**
1949 * Creates an list cache object.
1950 *
1951 * @private
1952 * @constructor
1953 * @param {Array} [entries] The key-value pairs to cache.
1954 */
1955function ListCache(entries) {
1956 var index = -1,
1957 length = entries == null ? 0 : entries.length;
1958
1959 this.clear();
1960 while (++index < length) {
1961 var entry = entries[index];
1962 this.set(entry[0], entry[1]);
1963 }
1964}
1965
1966/**
1967 * Removes all key-value entries from the list cache.
1968 *
1969 * @private
1970 * @name clear
1971 * @memberOf ListCache
1972 */
1973function listCacheClear() {
1974 this.__data__ = [];
1975 this.size = 0;
1976}
1977
1978/**
1979 * Removes `key` and its value from the list cache.
1980 *
1981 * @private
1982 * @name delete
1983 * @memberOf ListCache
1984 * @param {string} key The key of the value to remove.
1985 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1986 */
1987function listCacheDelete(key) {
1988 var data = this.__data__,
1989 index = assocIndexOf(data, key);
1990
1991 if (index < 0) {
1992 return false;
1993 }
1994 var lastIndex = data.length - 1;
1995 if (index == lastIndex) {
1996 data.pop();
1997 } else {
1998 splice.call(data, index, 1);
1999 }
2000 --this.size;
2001 return true;
2002}
2003
2004/**
2005 * Gets the list cache value for `key`.
2006 *
2007 * @private
2008 * @name get
2009 * @memberOf ListCache
2010 * @param {string} key The key of the value to get.
2011 * @returns {*} Returns the entry value.
2012 */
2013function listCacheGet(key) {
2014 var data = this.__data__,
2015 index = assocIndexOf(data, key);
2016
2017 return index < 0 ? undefined : data[index][1];
2018}
2019
2020/**
2021 * Checks if a list cache value for `key` exists.
2022 *
2023 * @private
2024 * @name has
2025 * @memberOf ListCache
2026 * @param {string} key The key of the entry to check.
2027 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2028 */
2029function listCacheHas(key) {
2030 return assocIndexOf(this.__data__, key) > -1;
2031}
2032
2033/**
2034 * Sets the list cache `key` to `value`.
2035 *
2036 * @private
2037 * @name set
2038 * @memberOf ListCache
2039 * @param {string} key The key of the value to set.
2040 * @param {*} value The value to set.
2041 * @returns {Object} Returns the list cache instance.
2042 */
2043function listCacheSet(key, value) {
2044 var data = this.__data__,
2045 index = assocIndexOf(data, key);
2046
2047 if (index < 0) {
2048 ++this.size;
2049 data.push([key, value]);
2050 } else {
2051 data[index][1] = value;
2052 }
2053 return this;
2054}
2055
2056// Add methods to `ListCache`.
2057ListCache.prototype.clear = listCacheClear;
2058ListCache.prototype['delete'] = listCacheDelete;
2059ListCache.prototype.get = listCacheGet;
2060ListCache.prototype.has = listCacheHas;
2061ListCache.prototype.set = listCacheSet;
2062
2063/**
2064 * Creates a map cache object to store key-value pairs.
2065 *
2066 * @private
2067 * @constructor
2068 * @param {Array} [entries] The key-value pairs to cache.
2069 */
2070function MapCache(entries) {
2071 var index = -1,
2072 length = entries == null ? 0 : entries.length;
2073
2074 this.clear();
2075 while (++index < length) {
2076 var entry = entries[index];
2077 this.set(entry[0], entry[1]);
2078 }
2079}
2080
2081/**
2082 * Removes all key-value entries from the map.
2083 *
2084 * @private
2085 * @name clear
2086 * @memberOf MapCache
2087 */
2088function mapCacheClear() {
2089 this.size = 0;
2090 this.__data__ = {
2091 'hash': new Hash,
2092 'map': new (Map || ListCache),
2093 'string': new Hash
2094 };
2095}
2096
2097/**
2098 * Removes `key` and its value from the map.
2099 *
2100 * @private
2101 * @name delete
2102 * @memberOf MapCache
2103 * @param {string} key The key of the value to remove.
2104 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2105 */
2106function mapCacheDelete(key) {
2107 var result = getMapData(this, key)['delete'](key);
2108 this.size -= result ? 1 : 0;
2109 return result;
2110}
2111
2112/**
2113 * Gets the map value for `key`.
2114 *
2115 * @private
2116 * @name get
2117 * @memberOf MapCache
2118 * @param {string} key The key of the value to get.
2119 * @returns {*} Returns the entry value.
2120 */
2121function mapCacheGet(key) {
2122 return getMapData(this, key).get(key);
2123}
2124
2125/**
2126 * Checks if a map value for `key` exists.
2127 *
2128 * @private
2129 * @name has
2130 * @memberOf MapCache
2131 * @param {string} key The key of the entry to check.
2132 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2133 */
2134function mapCacheHas(key) {
2135 return getMapData(this, key).has(key);
2136}
2137
2138/**
2139 * Sets the map `key` to `value`.
2140 *
2141 * @private
2142 * @name set
2143 * @memberOf MapCache
2144 * @param {string} key The key of the value to set.
2145 * @param {*} value The value to set.
2146 * @returns {Object} Returns the map cache instance.
2147 */
2148function mapCacheSet(key, value) {
2149 var data = getMapData(this, key),
2150 size = data.size;
2151
2152 data.set(key, value);
2153 this.size += data.size == size ? 0 : 1;
2154 return this;
2155}
2156
2157// Add methods to `MapCache`.
2158MapCache.prototype.clear = mapCacheClear;
2159MapCache.prototype['delete'] = mapCacheDelete;
2160MapCache.prototype.get = mapCacheGet;
2161MapCache.prototype.has = mapCacheHas;
2162MapCache.prototype.set = mapCacheSet;
2163
2164/**
2165 * Creates a stack cache object to store key-value pairs.
2166 *
2167 * @private
2168 * @constructor
2169 * @param {Array} [entries] The key-value pairs to cache.
2170 */
2171function Stack(entries) {
2172 var data = this.__data__ = new ListCache(entries);
2173 this.size = data.size;
2174}
2175
2176/**
2177 * Removes all key-value entries from the stack.
2178 *
2179 * @private
2180 * @name clear
2181 * @memberOf Stack
2182 */
2183function stackClear() {
2184 this.__data__ = new ListCache;
2185 this.size = 0;
2186}
2187
2188/**
2189 * Removes `key` and its value from the stack.
2190 *
2191 * @private
2192 * @name delete
2193 * @memberOf Stack
2194 * @param {string} key The key of the value to remove.
2195 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2196 */
2197function stackDelete(key) {
2198 var data = this.__data__,
2199 result = data['delete'](key);
2200
2201 this.size = data.size;
2202 return result;
2203}
2204
2205/**
2206 * Gets the stack value for `key`.
2207 *
2208 * @private
2209 * @name get
2210 * @memberOf Stack
2211 * @param {string} key The key of the value to get.
2212 * @returns {*} Returns the entry value.
2213 */
2214function stackGet(key) {
2215 return this.__data__.get(key);
2216}
2217
2218/**
2219 * Checks if a stack value for `key` exists.
2220 *
2221 * @private
2222 * @name has
2223 * @memberOf Stack
2224 * @param {string} key The key of the entry to check.
2225 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2226 */
2227function stackHas(key) {
2228 return this.__data__.has(key);
2229}
2230
2231/**
2232 * Sets the stack `key` to `value`.
2233 *
2234 * @private
2235 * @name set
2236 * @memberOf Stack
2237 * @param {string} key The key of the value to set.
2238 * @param {*} value The value to set.
2239 * @returns {Object} Returns the stack cache instance.
2240 */
2241function stackSet(key, value) {
2242 var data = this.__data__;
2243 if (data instanceof ListCache) {
2244 var pairs = data.__data__;
2245 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2246 pairs.push([key, value]);
2247 this.size = ++data.size;
2248 return this;
2249 }
2250 data = this.__data__ = new MapCache(pairs);
2251 }
2252 data.set(key, value);
2253 this.size = data.size;
2254 return this;
2255}
2256
2257// Add methods to `Stack`.
2258Stack.prototype.clear = stackClear;
2259Stack.prototype['delete'] = stackDelete;
2260Stack.prototype.get = stackGet;
2261Stack.prototype.has = stackHas;
2262Stack.prototype.set = stackSet;
2263
2264/**
2265 * Creates an array of the enumerable property names of the array-like `value`.
2266 *
2267 * @private
2268 * @param {*} value The value to query.
2269 * @param {boolean} inherited Specify returning inherited property names.
2270 * @returns {Array} Returns the array of property names.
2271 */
2272function arrayLikeKeys(value, inherited) {
2273 var isArr = isArray(value),
2274 isArg = !isArr && isArguments(value),
2275 isBuff = !isArr && !isArg && isBuffer(value),
2276 isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2277 skipIndexes = isArr || isArg || isBuff || isType,
2278 result = skipIndexes ? baseTimes(value.length, String) : [],
2279 length = result.length;
2280
2281 for (var key in value) {
2282 if ((inherited || hasOwnProperty.call(value, key)) &&
2283 !(skipIndexes && (
2284 // Safari 9 has enumerable `arguments.length` in strict mode.
2285 key == 'length' ||
2286 // Node.js 0.10 has enumerable non-index properties on buffers.
2287 (isBuff && (key == 'offset' || key == 'parent')) ||
2288 // PhantomJS 2 has enumerable non-index properties on typed arrays.
2289 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2290 // Skip index properties.
2291 isIndex(key, length)
2292 ))) {
2293 result.push(key);
2294 }
2295 }
2296 return result;
2297}
2298
2299/**
2300 * This function is like `assignValue` except that it doesn't assign
2301 * `undefined` values.
2302 *
2303 * @private
2304 * @param {Object} object The object to modify.
2305 * @param {string} key The key of the property to assign.
2306 * @param {*} value The value to assign.
2307 */
2308function assignMergeValue(object, key, value) {
2309 if ((value !== undefined && !eq(object[key], value)) ||
2310 (value === undefined && !(key in object))) {
2311 baseAssignValue(object, key, value);
2312 }
2313}
2314
2315/**
2316 * Assigns `value` to `key` of `object` if the existing value is not equivalent
2317 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2318 * for equality comparisons.
2319 *
2320 * @private
2321 * @param {Object} object The object to modify.
2322 * @param {string} key The key of the property to assign.
2323 * @param {*} value The value to assign.
2324 */
2325function assignValue(object, key, value) {
2326 var objValue = object[key];
2327 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
2328 (value === undefined && !(key in object))) {
2329 baseAssignValue(object, key, value);
2330 }
2331}
2332
2333/**
2334 * Gets the index at which the `key` is found in `array` of key-value pairs.
2335 *
2336 * @private
2337 * @param {Array} array The array to inspect.
2338 * @param {*} key The key to search for.
2339 * @returns {number} Returns the index of the matched value, else `-1`.
2340 */
2341function assocIndexOf(array, key) {
2342 var length = array.length;
2343 while (length--) {
2344 if (eq(array[length][0], key)) {
2345 return length;
2346 }
2347 }
2348 return -1;
2349}
2350
2351/**
2352 * The base implementation of `assignValue` and `assignMergeValue` without
2353 * value checks.
2354 *
2355 * @private
2356 * @param {Object} object The object to modify.
2357 * @param {string} key The key of the property to assign.
2358 * @param {*} value The value to assign.
2359 */
2360function baseAssignValue(object, key, value) {
2361 if (key == '__proto__' && defineProperty) {
2362 defineProperty(object, key, {
2363 'configurable': true,
2364 'enumerable': true,
2365 'value': value,
2366 'writable': true
2367 });
2368 } else {
2369 object[key] = value;
2370 }
2371}
2372
2373/**
2374 * The base implementation of `baseForOwn` which iterates over `object`
2375 * properties returned by `keysFunc` and invokes `iteratee` for each property.
2376 * Iteratee functions may exit iteration early by explicitly returning `false`.
2377 *
2378 * @private
2379 * @param {Object} object The object to iterate over.
2380 * @param {Function} iteratee The function invoked per iteration.
2381 * @param {Function} keysFunc The function to get the keys of `object`.
2382 * @returns {Object} Returns `object`.
2383 */
2384var baseFor = createBaseFor();
2385
2386/**
2387 * The base implementation of `getTag` without fallbacks for buggy environments.
2388 *
2389 * @private
2390 * @param {*} value The value to query.
2391 * @returns {string} Returns the `toStringTag`.
2392 */
2393function baseGetTag(value) {
2394 if (value == null) {
2395 return value === undefined ? undefinedTag : nullTag;
2396 }
2397 return (symToStringTag && symToStringTag in Object(value))
2398 ? getRawTag(value)
2399 : objectToString(value);
2400}
2401
2402/**
2403 * The base implementation of `_.isArguments`.
2404 *
2405 * @private
2406 * @param {*} value The value to check.
2407 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
2408 */
2409function baseIsArguments(value) {
2410 return isObjectLike(value) && baseGetTag(value) == argsTag;
2411}
2412
2413/**
2414 * The base implementation of `_.isNative` without bad shim checks.
2415 *
2416 * @private
2417 * @param {*} value The value to check.
2418 * @returns {boolean} Returns `true` if `value` is a native function,
2419 * else `false`.
2420 */
2421function baseIsNative(value) {
2422 if (!isObject(value) || isMasked(value)) {
2423 return false;
2424 }
2425 var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
2426 return pattern.test(toSource(value));
2427}
2428
2429/**
2430 * The base implementation of `_.isTypedArray` without Node.js optimizations.
2431 *
2432 * @private
2433 * @param {*} value The value to check.
2434 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2435 */
2436function baseIsTypedArray(value) {
2437 return isObjectLike(value) &&
2438 isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
2439}
2440
2441/**
2442 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
2443 *
2444 * @private
2445 * @param {Object} object The object to query.
2446 * @returns {Array} Returns the array of property names.
2447 */
2448function baseKeysIn(object) {
2449 if (!isObject(object)) {
2450 return nativeKeysIn(object);
2451 }
2452 var isProto = isPrototype(object),
2453 result = [];
2454
2455 for (var key in object) {
2456 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
2457 result.push(key);
2458 }
2459 }
2460 return result;
2461}
2462
2463/**
2464 * The base implementation of `_.merge` without support for multiple sources.
2465 *
2466 * @private
2467 * @param {Object} object The destination object.
2468 * @param {Object} source The source object.
2469 * @param {number} srcIndex The index of `source`.
2470 * @param {Function} [customizer] The function to customize merged values.
2471 * @param {Object} [stack] Tracks traversed source values and their merged
2472 * counterparts.
2473 */
2474function baseMerge(object, source, srcIndex, customizer, stack) {
2475 if (object === source) {
2476 return;
2477 }
2478 baseFor(source, function(srcValue, key) {
2479 stack || (stack = new Stack);
2480 if (isObject(srcValue)) {
2481 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
2482 }
2483 else {
2484 var newValue = customizer
2485 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
2486 : undefined;
2487
2488 if (newValue === undefined) {
2489 newValue = srcValue;
2490 }
2491 assignMergeValue(object, key, newValue);
2492 }
2493 }, keysIn);
2494}
2495
2496/**
2497 * A specialized version of `baseMerge` for arrays and objects which performs
2498 * deep merges and tracks traversed objects enabling objects with circular
2499 * references to be merged.
2500 *
2501 * @private
2502 * @param {Object} object The destination object.
2503 * @param {Object} source The source object.
2504 * @param {string} key The key of the value to merge.
2505 * @param {number} srcIndex The index of `source`.
2506 * @param {Function} mergeFunc The function to merge values.
2507 * @param {Function} [customizer] The function to customize assigned values.
2508 * @param {Object} [stack] Tracks traversed source values and their merged
2509 * counterparts.
2510 */
2511function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
2512 var objValue = safeGet(object, key),
2513 srcValue = safeGet(source, key),
2514 stacked = stack.get(srcValue);
2515
2516 if (stacked) {
2517 assignMergeValue(object, key, stacked);
2518 return;
2519 }
2520 var newValue = customizer
2521 ? customizer(objValue, srcValue, (key + ''), object, source, stack)
2522 : undefined;
2523
2524 var isCommon = newValue === undefined;
2525
2526 if (isCommon) {
2527 var isArr = isArray(srcValue),
2528 isBuff = !isArr && isBuffer(srcValue),
2529 isTyped = !isArr && !isBuff && isTypedArray(srcValue);
2530
2531 newValue = srcValue;
2532 if (isArr || isBuff || isTyped) {
2533 if (isArray(objValue)) {
2534 newValue = objValue;
2535 }
2536 else if (isArrayLikeObject(objValue)) {
2537 newValue = copyArray(objValue);
2538 }
2539 else if (isBuff) {
2540 isCommon = false;
2541 newValue = cloneBuffer(srcValue, true);
2542 }
2543 else if (isTyped) {
2544 isCommon = false;
2545 newValue = cloneTypedArray(srcValue, true);
2546 }
2547 else {
2548 newValue = [];
2549 }
2550 }
2551 else if (isPlainObject(srcValue) || isArguments(srcValue)) {
2552 newValue = objValue;
2553 if (isArguments(objValue)) {
2554 newValue = toPlainObject(objValue);
2555 }
2556 else if (!isObject(objValue) || isFunction(objValue)) {
2557 newValue = initCloneObject(srcValue);
2558 }
2559 }
2560 else {
2561 isCommon = false;
2562 }
2563 }
2564 if (isCommon) {
2565 // Recursively merge objects and arrays (susceptible to call stack limits).
2566 stack.set(srcValue, newValue);
2567 mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
2568 stack['delete'](srcValue);
2569 }
2570 assignMergeValue(object, key, newValue);
2571}
2572
2573/**
2574 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
2575 *
2576 * @private
2577 * @param {Function} func The function to apply a rest parameter to.
2578 * @param {number} [start=func.length-1] The start position of the rest parameter.
2579 * @returns {Function} Returns the new function.
2580 */
2581function baseRest(func, start) {
2582 return setToString(overRest(func, start, identity), func + '');
2583}
2584
2585/**
2586 * The base implementation of `setToString` without support for hot loop shorting.
2587 *
2588 * @private
2589 * @param {Function} func The function to modify.
2590 * @param {Function} string The `toString` result.
2591 * @returns {Function} Returns `func`.
2592 */
2593var baseSetToString = !defineProperty ? identity : function(func, string) {
2594 return defineProperty(func, 'toString', {
2595 'configurable': true,
2596 'enumerable': false,
2597 'value': constant(string),
2598 'writable': true
2599 });
2600};
2601
2602/**
2603 * Creates a clone of `buffer`.
2604 *
2605 * @private
2606 * @param {Buffer} buffer The buffer to clone.
2607 * @param {boolean} [isDeep] Specify a deep clone.
2608 * @returns {Buffer} Returns the cloned buffer.
2609 */
2610function cloneBuffer(buffer, isDeep) {
2611 if (isDeep) {
2612 return buffer.slice();
2613 }
2614 var length = buffer.length,
2615 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
2616
2617 buffer.copy(result);
2618 return result;
2619}
2620
2621/**
2622 * Creates a clone of `arrayBuffer`.
2623 *
2624 * @private
2625 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
2626 * @returns {ArrayBuffer} Returns the cloned array buffer.
2627 */
2628function cloneArrayBuffer(arrayBuffer) {
2629 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2630 new Uint8Array(result).set(new Uint8Array(arrayBuffer));
2631 return result;
2632}
2633
2634/**
2635 * Creates a clone of `typedArray`.
2636 *
2637 * @private
2638 * @param {Object} typedArray The typed array to clone.
2639 * @param {boolean} [isDeep] Specify a deep clone.
2640 * @returns {Object} Returns the cloned typed array.
2641 */
2642function cloneTypedArray(typedArray, isDeep) {
2643 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
2644 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2645}
2646
2647/**
2648 * Copies the values of `source` to `array`.
2649 *
2650 * @private
2651 * @param {Array} source The array to copy values from.
2652 * @param {Array} [array=[]] The array to copy values to.
2653 * @returns {Array} Returns `array`.
2654 */
2655function copyArray(source, array) {
2656 var index = -1,
2657 length = source.length;
2658
2659 array || (array = Array(length));
2660 while (++index < length) {
2661 array[index] = source[index];
2662 }
2663 return array;
2664}
2665
2666/**
2667 * Copies properties of `source` to `object`.
2668 *
2669 * @private
2670 * @param {Object} source The object to copy properties from.
2671 * @param {Array} props The property identifiers to copy.
2672 * @param {Object} [object={}] The object to copy properties to.
2673 * @param {Function} [customizer] The function to customize copied values.
2674 * @returns {Object} Returns `object`.
2675 */
2676function copyObject(source, props, object, customizer) {
2677 var isNew = !object;
2678 object || (object = {});
2679
2680 var index = -1,
2681 length = props.length;
2682
2683 while (++index < length) {
2684 var key = props[index];
2685
2686 var newValue = customizer
2687 ? customizer(object[key], source[key], key, object, source)
2688 : undefined;
2689
2690 if (newValue === undefined) {
2691 newValue = source[key];
2692 }
2693 if (isNew) {
2694 baseAssignValue(object, key, newValue);
2695 } else {
2696 assignValue(object, key, newValue);
2697 }
2698 }
2699 return object;
2700}
2701
2702/**
2703 * Creates a function like `_.assign`.
2704 *
2705 * @private
2706 * @param {Function} assigner The function to assign values.
2707 * @returns {Function} Returns the new assigner function.
2708 */
2709function createAssigner(assigner) {
2710 return baseRest(function(object, sources) {
2711 var index = -1,
2712 length = sources.length,
2713 customizer = length > 1 ? sources[length - 1] : undefined,
2714 guard = length > 2 ? sources[2] : undefined;
2715
2716 customizer = (assigner.length > 3 && typeof customizer == 'function')
2717 ? (length--, customizer)
2718 : undefined;
2719
2720 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
2721 customizer = length < 3 ? undefined : customizer;
2722 length = 1;
2723 }
2724 object = Object(object);
2725 while (++index < length) {
2726 var source = sources[index];
2727 if (source) {
2728 assigner(object, source, index, customizer);
2729 }
2730 }
2731 return object;
2732 });
2733}
2734
2735/**
2736 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
2737 *
2738 * @private
2739 * @param {boolean} [fromRight] Specify iterating from right to left.
2740 * @returns {Function} Returns the new base function.
2741 */
2742function createBaseFor(fromRight) {
2743 return function(object, iteratee, keysFunc) {
2744 var index = -1,
2745 iterable = Object(object),
2746 props = keysFunc(object),
2747 length = props.length;
2748
2749 while (length--) {
2750 var key = props[fromRight ? length : ++index];
2751 if (iteratee(iterable[key], key, iterable) === false) {
2752 break;
2753 }
2754 }
2755 return object;
2756 };
2757}
2758
2759/**
2760 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
2761 * objects into destination objects that are passed thru.
2762 *
2763 * @private
2764 * @param {*} objValue The destination value.
2765 * @param {*} srcValue The source value.
2766 * @param {string} key The key of the property to merge.
2767 * @param {Object} object The parent object of `objValue`.
2768 * @param {Object} source The parent object of `srcValue`.
2769 * @param {Object} [stack] Tracks traversed source values and their merged
2770 * counterparts.
2771 * @returns {*} Returns the value to assign.
2772 */
2773function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
2774 if (isObject(objValue) && isObject(srcValue)) {
2775 // Recursively merge objects and arrays (susceptible to call stack limits).
2776 stack.set(srcValue, objValue);
2777 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
2778 stack['delete'](srcValue);
2779 }
2780 return objValue;
2781}
2782
2783/**
2784 * Gets the data for `map`.
2785 *
2786 * @private
2787 * @param {Object} map The map to query.
2788 * @param {string} key The reference key.
2789 * @returns {*} Returns the map data.
2790 */
2791function getMapData(map, key) {
2792 var data = map.__data__;
2793 return isKeyable(key)
2794 ? data[typeof key == 'string' ? 'string' : 'hash']
2795 : data.map;
2796}
2797
2798/**
2799 * Gets the native function at `key` of `object`.
2800 *
2801 * @private
2802 * @param {Object} object The object to query.
2803 * @param {string} key The key of the method to get.
2804 * @returns {*} Returns the function if it's native, else `undefined`.
2805 */
2806function getNative(object, key) {
2807 var value = getValue(object, key);
2808 return baseIsNative(value) ? value : undefined;
2809}
2810
2811/**
2812 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
2813 *
2814 * @private
2815 * @param {*} value The value to query.
2816 * @returns {string} Returns the raw `toStringTag`.
2817 */
2818function getRawTag(value) {
2819 var isOwn = hasOwnProperty.call(value, symToStringTag),
2820 tag = value[symToStringTag];
2821
2822 try {
2823 value[symToStringTag] = undefined;
2824 var unmasked = true;
2825 } catch (e) {}
2826
2827 var result = nativeObjectToString.call(value);
2828 if (unmasked) {
2829 if (isOwn) {
2830 value[symToStringTag] = tag;
2831 } else {
2832 delete value[symToStringTag];
2833 }
2834 }
2835 return result;
2836}
2837
2838/**
2839 * Initializes an object clone.
2840 *
2841 * @private
2842 * @param {Object} object The object to clone.
2843 * @returns {Object} Returns the initialized clone.
2844 */
2845function initCloneObject(object) {
2846 return (typeof object.constructor == 'function' && !isPrototype(object))
2847 ? baseCreate(getPrototype(object))
2848 : {};
2849}
2850
2851/**
2852 * Checks if `value` is a valid array-like index.
2853 *
2854 * @private
2855 * @param {*} value The value to check.
2856 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
2857 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
2858 */
2859function isIndex(value, length) {
2860 var type = typeof value;
2861 length = length == null ? MAX_SAFE_INTEGER : length;
2862
2863 return !!length &&
2864 (type == 'number' ||
2865 (type != 'symbol' && reIsUint.test(value))) &&
2866 (value > -1 && value % 1 == 0 && value < length);
2867}
2868
2869/**
2870 * Checks if the given arguments are from an iteratee call.
2871 *
2872 * @private
2873 * @param {*} value The potential iteratee value argument.
2874 * @param {*} index The potential iteratee index or key argument.
2875 * @param {*} object The potential iteratee object argument.
2876 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
2877 * else `false`.
2878 */
2879function isIterateeCall(value, index, object) {
2880 if (!isObject(object)) {
2881 return false;
2882 }
2883 var type = typeof index;
2884 if (type == 'number'
2885 ? (isArrayLike(object) && isIndex(index, object.length))
2886 : (type == 'string' && index in object)
2887 ) {
2888 return eq(object[index], value);
2889 }
2890 return false;
2891}
2892
2893/**
2894 * Checks if `value` is suitable for use as unique object key.
2895 *
2896 * @private
2897 * @param {*} value The value to check.
2898 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
2899 */
2900function isKeyable(value) {
2901 var type = typeof value;
2902 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
2903 ? (value !== '__proto__')
2904 : (value === null);
2905}
2906
2907/**
2908 * Checks if `func` has its source masked.
2909 *
2910 * @private
2911 * @param {Function} func The function to check.
2912 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
2913 */
2914function isMasked(func) {
2915 return !!maskSrcKey && (maskSrcKey in func);
2916}
2917
2918/**
2919 * Checks if `value` is likely a prototype object.
2920 *
2921 * @private
2922 * @param {*} value The value to check.
2923 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
2924 */
2925function isPrototype(value) {
2926 var Ctor = value && value.constructor,
2927 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
2928
2929 return value === proto;
2930}
2931
2932/**
2933 * This function is like
2934 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2935 * except that it includes inherited enumerable properties.
2936 *
2937 * @private
2938 * @param {Object} object The object to query.
2939 * @returns {Array} Returns the array of property names.
2940 */
2941function nativeKeysIn(object) {
2942 var result = [];
2943 if (object != null) {
2944 for (var key in Object(object)) {
2945 result.push(key);
2946 }
2947 }
2948 return result;
2949}
2950
2951/**
2952 * Converts `value` to a string using `Object.prototype.toString`.
2953 *
2954 * @private
2955 * @param {*} value The value to convert.
2956 * @returns {string} Returns the converted string.
2957 */
2958function objectToString(value) {
2959 return nativeObjectToString.call(value);
2960}
2961
2962/**
2963 * A specialized version of `baseRest` which transforms the rest array.
2964 *
2965 * @private
2966 * @param {Function} func The function to apply a rest parameter to.
2967 * @param {number} [start=func.length-1] The start position of the rest parameter.
2968 * @param {Function} transform The rest array transform.
2969 * @returns {Function} Returns the new function.
2970 */
2971function overRest(func, start, transform) {
2972 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
2973 return function() {
2974 var args = arguments,
2975 index = -1,
2976 length = nativeMax(args.length - start, 0),
2977 array = Array(length);
2978
2979 while (++index < length) {
2980 array[index] = args[start + index];
2981 }
2982 index = -1;
2983 var otherArgs = Array(start + 1);
2984 while (++index < start) {
2985 otherArgs[index] = args[index];
2986 }
2987 otherArgs[start] = transform(array);
2988 return apply(func, this, otherArgs);
2989 };
2990}
2991
2992/**
2993 * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
2994 *
2995 * @private
2996 * @param {Object} object The object to query.
2997 * @param {string} key The key of the property to get.
2998 * @returns {*} Returns the property value.
2999 */
3000function safeGet(object, key) {
3001 if (key === 'constructor' && typeof object[key] === 'function') {
3002 return;
3003 }
3004
3005 if (key == '__proto__') {
3006 return;
3007 }
3008
3009 return object[key];
3010}
3011
3012/**
3013 * Sets the `toString` method of `func` to return `string`.
3014 *
3015 * @private
3016 * @param {Function} func The function to modify.
3017 * @param {Function} string The `toString` result.
3018 * @returns {Function} Returns `func`.
3019 */
3020var setToString = shortOut(baseSetToString);
3021
3022/**
3023 * Creates a function that'll short out and invoke `identity` instead
3024 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
3025 * milliseconds.
3026 *
3027 * @private
3028 * @param {Function} func The function to restrict.
3029 * @returns {Function} Returns the new shortable function.
3030 */
3031function shortOut(func) {
3032 var count = 0,
3033 lastCalled = 0;
3034
3035 return function() {
3036 var stamp = nativeNow(),
3037 remaining = HOT_SPAN - (stamp - lastCalled);
3038
3039 lastCalled = stamp;
3040 if (remaining > 0) {
3041 if (++count >= HOT_COUNT) {
3042 return arguments[0];
3043 }
3044 } else {
3045 count = 0;
3046 }
3047 return func.apply(undefined, arguments);
3048 };
3049}
3050
3051/**
3052 * Converts `func` to its source code.
3053 *
3054 * @private
3055 * @param {Function} func The function to convert.
3056 * @returns {string} Returns the source code.
3057 */
3058function toSource(func) {
3059 if (func != null) {
3060 try {
3061 return funcToString.call(func);
3062 } catch (e) {}
3063 try {
3064 return (func + '');
3065 } catch (e) {}
3066 }
3067 return '';
3068}
3069
3070/**
3071 * Performs a
3072 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
3073 * comparison between two values to determine if they are equivalent.
3074 *
3075 * @static
3076 * @memberOf _
3077 * @since 4.0.0
3078 * @category Lang
3079 * @param {*} value The value to compare.
3080 * @param {*} other The other value to compare.
3081 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3082 * @example
3083 *
3084 * var object = { 'a': 1 };
3085 * var other = { 'a': 1 };
3086 *
3087 * _.eq(object, object);
3088 * // => true
3089 *
3090 * _.eq(object, other);
3091 * // => false
3092 *
3093 * _.eq('a', 'a');
3094 * // => true
3095 *
3096 * _.eq('a', Object('a'));
3097 * // => false
3098 *
3099 * _.eq(NaN, NaN);
3100 * // => true
3101 */
3102function eq(value, other) {
3103 return value === other || (value !== value && other !== other);
3104}
3105
3106/**
3107 * Checks if `value` is likely an `arguments` object.
3108 *
3109 * @static
3110 * @memberOf _
3111 * @since 0.1.0
3112 * @category Lang
3113 * @param {*} value The value to check.
3114 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3115 * else `false`.
3116 * @example
3117 *
3118 * _.isArguments(function() { return arguments; }());
3119 * // => true
3120 *
3121 * _.isArguments([1, 2, 3]);
3122 * // => false
3123 */
3124var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
3125 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
3126 !propertyIsEnumerable.call(value, 'callee');
3127};
3128
3129/**
3130 * Checks if `value` is classified as an `Array` object.
3131 *
3132 * @static
3133 * @memberOf _
3134 * @since 0.1.0
3135 * @category Lang
3136 * @param {*} value The value to check.
3137 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
3138 * @example
3139 *
3140 * _.isArray([1, 2, 3]);
3141 * // => true
3142 *
3143 * _.isArray(document.body.children);
3144 * // => false
3145 *
3146 * _.isArray('abc');
3147 * // => false
3148 *
3149 * _.isArray(_.noop);
3150 * // => false
3151 */
3152var isArray = Array.isArray;
3153
3154/**
3155 * Checks if `value` is array-like. A value is considered array-like if it's
3156 * not a function and has a `value.length` that's an integer greater than or
3157 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
3158 *
3159 * @static
3160 * @memberOf _
3161 * @since 4.0.0
3162 * @category Lang
3163 * @param {*} value The value to check.
3164 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
3165 * @example
3166 *
3167 * _.isArrayLike([1, 2, 3]);
3168 * // => true
3169 *
3170 * _.isArrayLike(document.body.children);
3171 * // => true
3172 *
3173 * _.isArrayLike('abc');
3174 * // => true
3175 *
3176 * _.isArrayLike(_.noop);
3177 * // => false
3178 */
3179function isArrayLike(value) {
3180 return value != null && isLength(value.length) && !isFunction(value);
3181}
3182
3183/**
3184 * This method is like `_.isArrayLike` except that it also checks if `value`
3185 * is an object.
3186 *
3187 * @static
3188 * @memberOf _
3189 * @since 4.0.0
3190 * @category Lang
3191 * @param {*} value The value to check.
3192 * @returns {boolean} Returns `true` if `value` is an array-like object,
3193 * else `false`.
3194 * @example
3195 *
3196 * _.isArrayLikeObject([1, 2, 3]);
3197 * // => true
3198 *
3199 * _.isArrayLikeObject(document.body.children);
3200 * // => true
3201 *
3202 * _.isArrayLikeObject('abc');
3203 * // => false
3204 *
3205 * _.isArrayLikeObject(_.noop);
3206 * // => false
3207 */
3208function isArrayLikeObject(value) {
3209 return isObjectLike(value) && isArrayLike(value);
3210}
3211
3212/**
3213 * Checks if `value` is a buffer.
3214 *
3215 * @static
3216 * @memberOf _
3217 * @since 4.3.0
3218 * @category Lang
3219 * @param {*} value The value to check.
3220 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
3221 * @example
3222 *
3223 * _.isBuffer(new Buffer(2));
3224 * // => true
3225 *
3226 * _.isBuffer(new Uint8Array(2));
3227 * // => false
3228 */
3229var isBuffer = nativeIsBuffer || stubFalse;
3230
3231/**
3232 * Checks if `value` is classified as a `Function` object.
3233 *
3234 * @static
3235 * @memberOf _
3236 * @since 0.1.0
3237 * @category Lang
3238 * @param {*} value The value to check.
3239 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
3240 * @example
3241 *
3242 * _.isFunction(_);
3243 * // => true
3244 *
3245 * _.isFunction(/abc/);
3246 * // => false
3247 */
3248function isFunction(value) {
3249 if (!isObject(value)) {
3250 return false;
3251 }
3252 // The use of `Object#toString` avoids issues with the `typeof` operator
3253 // in Safari 9 which returns 'object' for typed arrays and other constructors.
3254 var tag = baseGetTag(value);
3255 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
3256}
3257
3258/**
3259 * Checks if `value` is a valid array-like length.
3260 *
3261 * **Note:** This method is loosely based on
3262 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
3263 *
3264 * @static
3265 * @memberOf _
3266 * @since 4.0.0
3267 * @category Lang
3268 * @param {*} value The value to check.
3269 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
3270 * @example
3271 *
3272 * _.isLength(3);
3273 * // => true
3274 *
3275 * _.isLength(Number.MIN_VALUE);
3276 * // => false
3277 *
3278 * _.isLength(Infinity);
3279 * // => false
3280 *
3281 * _.isLength('3');
3282 * // => false
3283 */
3284function isLength(value) {
3285 return typeof value == 'number' &&
3286 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
3287}
3288
3289/**
3290 * Checks if `value` is the
3291 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
3292 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
3293 *
3294 * @static
3295 * @memberOf _
3296 * @since 0.1.0
3297 * @category Lang
3298 * @param {*} value The value to check.
3299 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
3300 * @example
3301 *
3302 * _.isObject({});
3303 * // => true
3304 *
3305 * _.isObject([1, 2, 3]);
3306 * // => true
3307 *
3308 * _.isObject(_.noop);
3309 * // => true
3310 *
3311 * _.isObject(null);
3312 * // => false
3313 */
3314function isObject(value) {
3315 var type = typeof value;
3316 return value != null && (type == 'object' || type == 'function');
3317}
3318
3319/**
3320 * Checks if `value` is object-like. A value is object-like if it's not `null`
3321 * and has a `typeof` result of "object".
3322 *
3323 * @static
3324 * @memberOf _
3325 * @since 4.0.0
3326 * @category Lang
3327 * @param {*} value The value to check.
3328 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
3329 * @example
3330 *
3331 * _.isObjectLike({});
3332 * // => true
3333 *
3334 * _.isObjectLike([1, 2, 3]);
3335 * // => true
3336 *
3337 * _.isObjectLike(_.noop);
3338 * // => false
3339 *
3340 * _.isObjectLike(null);
3341 * // => false
3342 */
3343function isObjectLike(value) {
3344 return value != null && typeof value == 'object';
3345}
3346
3347/**
3348 * Checks if `value` is a plain object, that is, an object created by the
3349 * `Object` constructor or one with a `[[Prototype]]` of `null`.
3350 *
3351 * @static
3352 * @memberOf _
3353 * @since 0.8.0
3354 * @category Lang
3355 * @param {*} value The value to check.
3356 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
3357 * @example
3358 *
3359 * function Foo() {
3360 * this.a = 1;
3361 * }
3362 *
3363 * _.isPlainObject(new Foo);
3364 * // => false
3365 *
3366 * _.isPlainObject([1, 2, 3]);
3367 * // => false
3368 *
3369 * _.isPlainObject({ 'x': 0, 'y': 0 });
3370 * // => true
3371 *
3372 * _.isPlainObject(Object.create(null));
3373 * // => true
3374 */
3375function isPlainObject(value) {
3376 if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
3377 return false;
3378 }
3379 var proto = getPrototype(value);
3380 if (proto === null) {
3381 return true;
3382 }
3383 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
3384 return typeof Ctor == 'function' && Ctor instanceof Ctor &&
3385 funcToString.call(Ctor) == objectCtorString;
3386}
3387
3388/**
3389 * Checks if `value` is classified as a typed array.
3390 *
3391 * @static
3392 * @memberOf _
3393 * @since 3.0.0
3394 * @category Lang
3395 * @param {*} value The value to check.
3396 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3397 * @example
3398 *
3399 * _.isTypedArray(new Uint8Array);
3400 * // => true
3401 *
3402 * _.isTypedArray([]);
3403 * // => false
3404 */
3405var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
3406
3407/**
3408 * Converts `value` to a plain object flattening inherited enumerable string
3409 * keyed properties of `value` to own properties of the plain object.
3410 *
3411 * @static
3412 * @memberOf _
3413 * @since 3.0.0
3414 * @category Lang
3415 * @param {*} value The value to convert.
3416 * @returns {Object} Returns the converted plain object.
3417 * @example
3418 *
3419 * function Foo() {
3420 * this.b = 2;
3421 * }
3422 *
3423 * Foo.prototype.c = 3;
3424 *
3425 * _.assign({ 'a': 1 }, new Foo);
3426 * // => { 'a': 1, 'b': 2 }
3427 *
3428 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
3429 * // => { 'a': 1, 'b': 2, 'c': 3 }
3430 */
3431function toPlainObject(value) {
3432 return copyObject(value, keysIn(value));
3433}
3434
3435/**
3436 * This method is like `_.defaults` except that it recursively assigns
3437 * default properties.
3438 *
3439 * **Note:** This method mutates `object`.
3440 *
3441 * @static
3442 * @memberOf _
3443 * @since 3.10.0
3444 * @category Object
3445 * @param {Object} object The destination object.
3446 * @param {...Object} [sources] The source objects.
3447 * @returns {Object} Returns `object`.
3448 * @see _.defaults
3449 * @example
3450 *
3451 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
3452 * // => { 'a': { 'b': 2, 'c': 3 } }
3453 */
3454var defaultsDeep = baseRest(function(args) {
3455 args.push(undefined, customDefaultsMerge);
3456 return apply(mergeWith, undefined, args);
3457});
3458
3459/**
3460 * Creates an array of the own and inherited enumerable property names of `object`.
3461 *
3462 * **Note:** Non-object values are coerced to objects.
3463 *
3464 * @static
3465 * @memberOf _
3466 * @since 3.0.0
3467 * @category Object
3468 * @param {Object} object The object to query.
3469 * @returns {Array} Returns the array of property names.
3470 * @example
3471 *
3472 * function Foo() {
3473 * this.a = 1;
3474 * this.b = 2;
3475 * }
3476 *
3477 * Foo.prototype.c = 3;
3478 *
3479 * _.keysIn(new Foo);
3480 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
3481 */
3482function keysIn(object) {
3483 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
3484}
3485
3486/**
3487 * This method is like `_.merge` except that it accepts `customizer` which
3488 * is invoked to produce the merged values of the destination and source
3489 * properties. If `customizer` returns `undefined`, merging is handled by the
3490 * method instead. The `customizer` is invoked with six arguments:
3491 * (objValue, srcValue, key, object, source, stack).
3492 *
3493 * **Note:** This method mutates `object`.
3494 *
3495 * @static
3496 * @memberOf _
3497 * @since 4.0.0
3498 * @category Object
3499 * @param {Object} object The destination object.
3500 * @param {...Object} sources The source objects.
3501 * @param {Function} customizer The function to customize assigned values.
3502 * @returns {Object} Returns `object`.
3503 * @example
3504 *
3505 * function customizer(objValue, srcValue) {
3506 * if (_.isArray(objValue)) {
3507 * return objValue.concat(srcValue);
3508 * }
3509 * }
3510 *
3511 * var object = { 'a': [1], 'b': [2] };
3512 * var other = { 'a': [3], 'b': [4] };
3513 *
3514 * _.mergeWith(object, other, customizer);
3515 * // => { 'a': [1, 3], 'b': [2, 4] }
3516 */
3517var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
3518 baseMerge(object, source, srcIndex, customizer);
3519});
3520
3521/**
3522 * Creates a function that returns `value`.
3523 *
3524 * @static
3525 * @memberOf _
3526 * @since 2.4.0
3527 * @category Util
3528 * @param {*} value The value to return from the new function.
3529 * @returns {Function} Returns the new constant function.
3530 * @example
3531 *
3532 * var objects = _.times(2, _.constant({ 'a': 1 }));
3533 *
3534 * console.log(objects);
3535 * // => [{ 'a': 1 }, { 'a': 1 }]
3536 *
3537 * console.log(objects[0] === objects[1]);
3538 * // => true
3539 */
3540function constant(value) {
3541 return function() {
3542 return value;
3543 };
3544}
3545
3546/**
3547 * This method returns the first argument it receives.
3548 *
3549 * @static
3550 * @since 0.1.0
3551 * @memberOf _
3552 * @category Util
3553 * @param {*} value Any value.
3554 * @returns {*} Returns `value`.
3555 * @example
3556 *
3557 * var object = { 'a': 1 };
3558 *
3559 * console.log(_.identity(object) === object);
3560 * // => true
3561 */
3562function identity(value) {
3563 return value;
3564}
3565
3566/**
3567 * This method returns `false`.
3568 *
3569 * @static
3570 * @memberOf _
3571 * @since 4.13.0
3572 * @category Util
3573 * @returns {boolean} Returns `false`.
3574 * @example
3575 *
3576 * _.times(2, _.stubFalse);
3577 * // => [false, false]
3578 */
3579function stubFalse() {
3580 return false;
3581}
3582
3583module.exports = defaultsDeep;
3584
3585
3586/***/ }),
3587
3588/***/ 3520:
3589/***/ ((module) => {
3590
3591/**
3592 * lodash (Custom Build) <https://lodash.com/>
3593 * Build: `lodash modularize exports="npm" -o ./`
3594 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
3595 * Released under MIT license <https://lodash.com/license>
3596 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
3597 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
3598 */
3599
3600/** Used as references for various `Number` constants. */
3601var MAX_SAFE_INTEGER = 9007199254740991;
3602
3603/** `Object#toString` result references. */
3604var argsTag = '[object Arguments]',
3605 funcTag = '[object Function]',
3606 genTag = '[object GeneratorFunction]';
3607
3608/** Used to detect unsigned integer values. */
3609var reIsUint = /^(?:0|[1-9]\d*)$/;
3610
3611/**
3612 * The base implementation of `_.times` without support for iteratee shorthands
3613 * or max array length checks.
3614 *
3615 * @private
3616 * @param {number} n The number of times to invoke `iteratee`.
3617 * @param {Function} iteratee The function invoked per iteration.
3618 * @returns {Array} Returns the array of results.
3619 */
3620function baseTimes(n, iteratee) {
3621 var index = -1,
3622 result = Array(n);
3623
3624 while (++index < n) {
3625 result[index] = iteratee(index);
3626 }
3627 return result;
3628}
3629
3630/**
3631 * Creates a unary function that invokes `func` with its argument transformed.
3632 *
3633 * @private
3634 * @param {Function} func The function to wrap.
3635 * @param {Function} transform The argument transform.
3636 * @returns {Function} Returns the new function.
3637 */
3638function overArg(func, transform) {
3639 return function(arg) {
3640 return func(transform(arg));
3641 };
3642}
3643
3644/** Used for built-in method references. */
3645var objectProto = Object.prototype;
3646
3647/** Used to check objects for own properties. */
3648var hasOwnProperty = objectProto.hasOwnProperty;
3649
3650/**
3651 * Used to resolve the
3652 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
3653 * of values.
3654 */
3655var objectToString = objectProto.toString;
3656
3657/** Built-in value references. */
3658var propertyIsEnumerable = objectProto.propertyIsEnumerable;
3659
3660/* Built-in method references for those with the same name as other `lodash` methods. */
3661var nativeKeys = overArg(Object.keys, Object);
3662
3663/**
3664 * Creates an array of the enumerable property names of the array-like `value`.
3665 *
3666 * @private
3667 * @param {*} value The value to query.
3668 * @param {boolean} inherited Specify returning inherited property names.
3669 * @returns {Array} Returns the array of property names.
3670 */
3671function arrayLikeKeys(value, inherited) {
3672 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
3673 // Safari 9 makes `arguments.length` enumerable in strict mode.
3674 var result = (isArray(value) || isArguments(value))
3675 ? baseTimes(value.length, String)
3676 : [];
3677
3678 var length = result.length,
3679 skipIndexes = !!length;
3680
3681 for (var key in value) {
3682 if ((inherited || hasOwnProperty.call(value, key)) &&
3683 !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
3684 result.push(key);
3685 }
3686 }
3687 return result;
3688}
3689
3690/**
3691 * The base implementation of `baseForOwn` which iterates over `object`
3692 * properties returned by `keysFunc` and invokes `iteratee` for each property.
3693 * Iteratee functions may exit iteration early by explicitly returning `false`.
3694 *
3695 * @private
3696 * @param {Object} object The object to iterate over.
3697 * @param {Function} iteratee The function invoked per iteration.
3698 * @param {Function} keysFunc The function to get the keys of `object`.
3699 * @returns {Object} Returns `object`.
3700 */
3701var baseFor = createBaseFor();
3702
3703/**
3704 * The base implementation of `_.forOwn` without support for iteratee shorthands.
3705 *
3706 * @private
3707 * @param {Object} object The object to iterate over.
3708 * @param {Function} iteratee The function invoked per iteration.
3709 * @returns {Object} Returns `object`.
3710 */
3711function baseForOwn(object, iteratee) {
3712 return object && baseFor(object, iteratee, keys);
3713}
3714
3715/**
3716 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
3717 *
3718 * @private
3719 * @param {Object} object The object to query.
3720 * @returns {Array} Returns the array of property names.
3721 */
3722function baseKeys(object) {
3723 if (!isPrototype(object)) {
3724 return nativeKeys(object);
3725 }
3726 var result = [];
3727 for (var key in Object(object)) {
3728 if (hasOwnProperty.call(object, key) && key != 'constructor') {
3729 result.push(key);
3730 }
3731 }
3732 return result;
3733}
3734
3735/**
3736 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
3737 *
3738 * @private
3739 * @param {boolean} [fromRight] Specify iterating from right to left.
3740 * @returns {Function} Returns the new base function.
3741 */
3742function createBaseFor(fromRight) {
3743 return function(object, iteratee, keysFunc) {
3744 var index = -1,
3745 iterable = Object(object),
3746 props = keysFunc(object),
3747 length = props.length;
3748
3749 while (length--) {
3750 var key = props[fromRight ? length : ++index];
3751 if (iteratee(iterable[key], key, iterable) === false) {
3752 break;
3753 }
3754 }
3755 return object;
3756 };
3757}
3758
3759/**
3760 * Checks if `value` is a valid array-like index.
3761 *
3762 * @private
3763 * @param {*} value The value to check.
3764 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
3765 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
3766 */
3767function isIndex(value, length) {
3768 length = length == null ? MAX_SAFE_INTEGER : length;
3769 return !!length &&
3770 (typeof value == 'number' || reIsUint.test(value)) &&
3771 (value > -1 && value % 1 == 0 && value < length);
3772}
3773
3774/**
3775 * Checks if `value` is likely a prototype object.
3776 *
3777 * @private
3778 * @param {*} value The value to check.
3779 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
3780 */
3781function isPrototype(value) {
3782 var Ctor = value && value.constructor,
3783 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
3784
3785 return value === proto;
3786}
3787
3788/**
3789 * Checks if `value` is likely an `arguments` object.
3790 *
3791 * @static
3792 * @memberOf _
3793 * @since 0.1.0
3794 * @category Lang
3795 * @param {*} value The value to check.
3796 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3797 * else `false`.
3798 * @example
3799 *
3800 * _.isArguments(function() { return arguments; }());
3801 * // => true
3802 *
3803 * _.isArguments([1, 2, 3]);
3804 * // => false
3805 */
3806function isArguments(value) {
3807 // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
3808 return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
3809 (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
3810}
3811
3812/**
3813 * Checks if `value` is classified as an `Array` object.
3814 *
3815 * @static
3816 * @memberOf _
3817 * @since 0.1.0
3818 * @category Lang
3819 * @param {*} value The value to check.
3820 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
3821 * @example
3822 *
3823 * _.isArray([1, 2, 3]);
3824 * // => true
3825 *
3826 * _.isArray(document.body.children);
3827 * // => false
3828 *
3829 * _.isArray('abc');
3830 * // => false
3831 *
3832 * _.isArray(_.noop);
3833 * // => false
3834 */
3835var isArray = Array.isArray;
3836
3837/**
3838 * Checks if `value` is array-like. A value is considered array-like if it's
3839 * not a function and has a `value.length` that's an integer greater than or
3840 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
3841 *
3842 * @static
3843 * @memberOf _
3844 * @since 4.0.0
3845 * @category Lang
3846 * @param {*} value The value to check.
3847 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
3848 * @example
3849 *
3850 * _.isArrayLike([1, 2, 3]);
3851 * // => true
3852 *
3853 * _.isArrayLike(document.body.children);
3854 * // => true
3855 *
3856 * _.isArrayLike('abc');
3857 * // => true
3858 *
3859 * _.isArrayLike(_.noop);
3860 * // => false
3861 */
3862function isArrayLike(value) {
3863 return value != null && isLength(value.length) && !isFunction(value);
3864}
3865
3866/**
3867 * This method is like `_.isArrayLike` except that it also checks if `value`
3868 * is an object.
3869 *
3870 * @static
3871 * @memberOf _
3872 * @since 4.0.0
3873 * @category Lang
3874 * @param {*} value The value to check.
3875 * @returns {boolean} Returns `true` if `value` is an array-like object,
3876 * else `false`.
3877 * @example
3878 *
3879 * _.isArrayLikeObject([1, 2, 3]);
3880 * // => true
3881 *
3882 * _.isArrayLikeObject(document.body.children);
3883 * // => true
3884 *
3885 * _.isArrayLikeObject('abc');
3886 * // => false
3887 *
3888 * _.isArrayLikeObject(_.noop);
3889 * // => false
3890 */
3891function isArrayLikeObject(value) {
3892 return isObjectLike(value) && isArrayLike(value);
3893}
3894
3895/**
3896 * Checks if `value` is classified as a `Function` object.
3897 *
3898 * @static
3899 * @memberOf _
3900 * @since 0.1.0
3901 * @category Lang
3902 * @param {*} value The value to check.
3903 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
3904 * @example
3905 *
3906 * _.isFunction(_);
3907 * // => true
3908 *
3909 * _.isFunction(/abc/);
3910 * // => false
3911 */
3912function isFunction(value) {
3913 // The use of `Object#toString` avoids issues with the `typeof` operator
3914 // in Safari 8-9 which returns 'object' for typed array and other constructors.
3915 var tag = isObject(value) ? objectToString.call(value) : '';
3916 return tag == funcTag || tag == genTag;
3917}
3918
3919/**
3920 * Checks if `value` is a valid array-like length.
3921 *
3922 * **Note:** This method is loosely based on
3923 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
3924 *
3925 * @static
3926 * @memberOf _
3927 * @since 4.0.0
3928 * @category Lang
3929 * @param {*} value The value to check.
3930 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
3931 * @example
3932 *
3933 * _.isLength(3);
3934 * // => true
3935 *
3936 * _.isLength(Number.MIN_VALUE);
3937 * // => false
3938 *
3939 * _.isLength(Infinity);
3940 * // => false
3941 *
3942 * _.isLength('3');
3943 * // => false
3944 */
3945function isLength(value) {
3946 return typeof value == 'number' &&
3947 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
3948}
3949
3950/**
3951 * Checks if `value` is the
3952 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
3953 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
3954 *
3955 * @static
3956 * @memberOf _
3957 * @since 0.1.0
3958 * @category Lang
3959 * @param {*} value The value to check.
3960 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
3961 * @example
3962 *
3963 * _.isObject({});
3964 * // => true
3965 *
3966 * _.isObject([1, 2, 3]);
3967 * // => true
3968 *
3969 * _.isObject(_.noop);
3970 * // => true
3971 *
3972 * _.isObject(null);
3973 * // => false
3974 */
3975function isObject(value) {
3976 var type = typeof value;
3977 return !!value && (type == 'object' || type == 'function');
3978}
3979
3980/**
3981 * Checks if `value` is object-like. A value is object-like if it's not `null`
3982 * and has a `typeof` result of "object".
3983 *
3984 * @static
3985 * @memberOf _
3986 * @since 4.0.0
3987 * @category Lang
3988 * @param {*} value The value to check.
3989 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
3990 * @example
3991 *
3992 * _.isObjectLike({});
3993 * // => true
3994 *
3995 * _.isObjectLike([1, 2, 3]);
3996 * // => true
3997 *
3998 * _.isObjectLike(_.noop);
3999 * // => false
4000 *
4001 * _.isObjectLike(null);
4002 * // => false
4003 */
4004function isObjectLike(value) {
4005 return !!value && typeof value == 'object';
4006}
4007
4008/**
4009 * Iterates over own enumerable string keyed properties of an object and
4010 * invokes `iteratee` for each property. The iteratee is invoked with three
4011 * arguments: (value, key, object). Iteratee functions may exit iteration
4012 * early by explicitly returning `false`.
4013 *
4014 * @static
4015 * @memberOf _
4016 * @since 0.3.0
4017 * @category Object
4018 * @param {Object} object The object to iterate over.
4019 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
4020 * @returns {Object} Returns `object`.
4021 * @see _.forOwnRight
4022 * @example
4023 *
4024 * function Foo() {
4025 * this.a = 1;
4026 * this.b = 2;
4027 * }
4028 *
4029 * Foo.prototype.c = 3;
4030 *
4031 * _.forOwn(new Foo, function(value, key) {
4032 * console.log(key);
4033 * });
4034 * // => Logs 'a' then 'b' (iteration order is not guaranteed).
4035 */
4036function forOwn(object, iteratee) {
4037 return object && baseForOwn(object, typeof iteratee == 'function' ? iteratee : identity);
4038}
4039
4040/**
4041 * Creates an array of the own enumerable property names of `object`.
4042 *
4043 * **Note:** Non-object values are coerced to objects. See the
4044 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
4045 * for more details.
4046 *
4047 * @static
4048 * @since 0.1.0
4049 * @memberOf _
4050 * @category Object
4051 * @param {Object} object The object to query.
4052 * @returns {Array} Returns the array of property names.
4053 * @example
4054 *
4055 * function Foo() {
4056 * this.a = 1;
4057 * this.b = 2;
4058 * }
4059 *
4060 * Foo.prototype.c = 3;
4061 *
4062 * _.keys(new Foo);
4063 * // => ['a', 'b'] (iteration order is not guaranteed)
4064 *
4065 * _.keys('hi');
4066 * // => ['0', '1']
4067 */
4068function keys(object) {
4069 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
4070}
4071
4072/**
4073 * This method returns the first argument it receives.
4074 *
4075 * @static
4076 * @since 0.1.0
4077 * @memberOf _
4078 * @category Util
4079 * @param {*} value Any value.
4080 * @returns {*} Returns `value`.
4081 * @example
4082 *
4083 * var object = { 'a': 1 };
4084 *
4085 * console.log(_.identity(object) === object);
4086 * // => true
4087 */
4088function identity(value) {
4089 return value;
4090}
4091
4092module.exports = forOwn;
4093
4094
4095/***/ }),
4096
4097/***/ 372:
4098/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4099
4100"use strict";
4101
4102
4103var isPrototype = __webpack_require__(6060);
4104
4105module.exports = function (value) {
4106 if (typeof value !== "function") return false;
4107
4108 if (!hasOwnProperty.call(value, "length")) return false;
4109
4110 try {
4111 if (typeof value.length !== "number") return false;
4112 if (typeof value.call !== "function") return false;
4113 if (typeof value.apply !== "function") return false;
4114 } catch (error) {
4115 return false;
4116 }
4117
4118 return !isPrototype(value);
4119};
4120
4121
4122/***/ }),
4123
4124/***/ 3940:
4125/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4126
4127"use strict";
4128
4129
4130var isValue = __webpack_require__(5618);
4131
4132// prettier-ignore
4133var possibleTypes = { "object": true, "function": true, "undefined": true /* document.all */ };
4134
4135module.exports = function (value) {
4136 if (!isValue(value)) return false;
4137 return hasOwnProperty.call(possibleTypes, typeof value);
4138};
4139
4140
4141/***/ }),
4142
4143/***/ 7205:
4144/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4145
4146"use strict";
4147
4148
4149var isFunction = __webpack_require__(372);
4150
4151var classRe = /^\s*class[\s{/}]/, functionToString = Function.prototype.toString;
4152
4153module.exports = function (value) {
4154 if (!isFunction(value)) return false;
4155 if (classRe.test(functionToString.call(value))) return false;
4156 return true;
4157};
4158
4159
4160/***/ }),
4161
4162/***/ 6060:
4163/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4164
4165"use strict";
4166
4167
4168var isObject = __webpack_require__(3940);
4169
4170module.exports = function (value) {
4171 if (!isObject(value)) return false;
4172 try {
4173 if (!value.constructor) return false;
4174 return value.constructor.prototype === value;
4175 } catch (error) {
4176 return false;
4177 }
4178};
4179
4180
4181/***/ }),
4182
4183/***/ 5618:
4184/***/ ((module) => {
4185
4186"use strict";
4187
4188
4189// ES3 safe
4190var _undefined = void 0;
4191
4192module.exports = function (value) { return value !== _undefined && value !== null; };
4193
4194
4195/***/ }),
4196
4197/***/ 4935:
4198/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4199
4200var createElement = __webpack_require__(3513)
4201
4202module.exports = createElement
4203
4204
4205/***/ }),
4206
4207/***/ 7921:
4208/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4209
4210var diff = __webpack_require__(3072)
4211
4212module.exports = diff
4213
4214
4215/***/ }),
4216
4217/***/ 347:
4218/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4219
4220var h = __webpack_require__(8744)
4221
4222module.exports = h
4223
4224
4225/***/ }),
4226
4227/***/ 9720:
4228/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4229
4230var patch = __webpack_require__(6943)
4231
4232module.exports = patch
4233
4234
4235/***/ }),
4236
4237/***/ 6672:
4238/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4239
4240var isObject = __webpack_require__(6240)
4241var isHook = __webpack_require__(7265)
4242
4243module.exports = applyProperties
4244
4245function applyProperties(node, props, previous) {
4246 for (var propName in props) {
4247 var propValue = props[propName]
4248
4249 if (propValue === undefined) {
4250 removeProperty(node, propName, propValue, previous);
4251 } else if (isHook(propValue)) {
4252 removeProperty(node, propName, propValue, previous)
4253 if (propValue.hook) {
4254 propValue.hook(node,
4255 propName,
4256 previous ? previous[propName] : undefined)
4257 }
4258 } else {
4259 if (isObject(propValue)) {
4260 patchObject(node, props, previous, propName, propValue);
4261 } else {
4262 node[propName] = propValue
4263 }
4264 }
4265 }
4266}
4267
4268function removeProperty(node, propName, propValue, previous) {
4269 if (previous) {
4270 var previousValue = previous[propName]
4271
4272 if (!isHook(previousValue)) {
4273 if (propName === "attributes") {
4274 for (var attrName in previousValue) {
4275 node.removeAttribute(attrName)
4276 }
4277 } else if (propName === "style") {
4278 for (var i in previousValue) {
4279 node.style[i] = ""
4280 }
4281 } else if (typeof previousValue === "string") {
4282 node[propName] = ""
4283 } else {
4284 node[propName] = null
4285 }
4286 } else if (previousValue.unhook) {
4287 previousValue.unhook(node, propName, propValue)
4288 }
4289 }
4290}
4291
4292function patchObject(node, props, previous, propName, propValue) {
4293 var previousValue = previous ? previous[propName] : undefined
4294
4295 // Set attributes
4296 if (propName === "attributes") {
4297 for (var attrName in propValue) {
4298 var attrValue = propValue[attrName]
4299
4300 if (attrValue === undefined) {
4301 node.removeAttribute(attrName)
4302 } else {
4303 node.setAttribute(attrName, attrValue)
4304 }
4305 }
4306
4307 return
4308 }
4309
4310 if(previousValue && isObject(previousValue) &&
4311 getPrototype(previousValue) !== getPrototype(propValue)) {
4312 node[propName] = propValue
4313 return
4314 }
4315
4316 if (!isObject(node[propName])) {
4317 node[propName] = {}
4318 }
4319
4320 var replacer = propName === "style" ? "" : undefined
4321
4322 for (var k in propValue) {
4323 var value = propValue[k]
4324 node[propName][k] = (value === undefined) ? replacer : value
4325 }
4326}
4327
4328function getPrototype(value) {
4329 if (Object.getPrototypeOf) {
4330 return Object.getPrototypeOf(value)
4331 } else if (value.__proto__) {
4332 return value.__proto__
4333 } else if (value.constructor) {
4334 return value.constructor.prototype
4335 }
4336}
4337
4338
4339/***/ }),
4340
4341/***/ 3513:
4342/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4343
4344var document = __webpack_require__(9144)
4345
4346var applyProperties = __webpack_require__(6672)
4347
4348var isVNode = __webpack_require__(5170)
4349var isVText = __webpack_require__(6221)
4350var isWidget = __webpack_require__(4097)
4351var handleThunk = __webpack_require__(6078)
4352
4353module.exports = createElement
4354
4355function createElement(vnode, opts) {
4356 var doc = opts ? opts.document || document : document
4357 var warn = opts ? opts.warn : null
4358
4359 vnode = handleThunk(vnode).a
4360
4361 if (isWidget(vnode)) {
4362 return vnode.init()
4363 } else if (isVText(vnode)) {
4364 return doc.createTextNode(vnode.text)
4365 } else if (!isVNode(vnode)) {
4366 if (warn) {
4367 warn("Item is not a valid virtual dom node", vnode)
4368 }
4369 return null
4370 }
4371
4372 var node = (vnode.namespace === null) ?
4373 doc.createElement(vnode.tagName) :
4374 doc.createElementNS(vnode.namespace, vnode.tagName)
4375
4376 var props = vnode.properties
4377 applyProperties(node, props)
4378
4379 var children = vnode.children
4380
4381 for (var i = 0; i < children.length; i++) {
4382 var childNode = createElement(children[i], opts)
4383 if (childNode) {
4384 node.appendChild(childNode)
4385 }
4386 }
4387
4388 return node
4389}
4390
4391
4392/***/ }),
4393
4394/***/ 8992:
4395/***/ ((module) => {
4396
4397// Maps a virtual DOM tree onto a real DOM tree in an efficient manner.
4398// We don't want to read all of the DOM nodes in the tree so we use
4399// the in-order tree indexing to eliminate recursion down certain branches.
4400// We only recurse into a DOM node if we know that it contains a child of
4401// interest.
4402
4403var noChild = {}
4404
4405module.exports = domIndex
4406
4407function domIndex(rootNode, tree, indices, nodes) {
4408 if (!indices || indices.length === 0) {
4409 return {}
4410 } else {
4411 indices.sort(ascending)
4412 return recurse(rootNode, tree, indices, nodes, 0)
4413 }
4414}
4415
4416function recurse(rootNode, tree, indices, nodes, rootIndex) {
4417 nodes = nodes || {}
4418
4419
4420 if (rootNode) {
4421 if (indexInRange(indices, rootIndex, rootIndex)) {
4422 nodes[rootIndex] = rootNode
4423 }
4424
4425 var vChildren = tree.children
4426
4427 if (vChildren) {
4428
4429 var childNodes = rootNode.childNodes
4430
4431 for (var i = 0; i < tree.children.length; i++) {
4432 rootIndex += 1
4433
4434 var vChild = vChildren[i] || noChild
4435 var nextIndex = rootIndex + (vChild.count || 0)
4436
4437 // skip recursion down the tree if there are no nodes down here
4438 if (indexInRange(indices, rootIndex, nextIndex)) {
4439 recurse(childNodes[i], vChild, indices, nodes, rootIndex)
4440 }
4441
4442 rootIndex = nextIndex
4443 }
4444 }
4445 }
4446
4447 return nodes
4448}
4449
4450// Binary search for an index in the interval [left, right]
4451function indexInRange(indices, left, right) {
4452 if (indices.length === 0) {
4453 return false
4454 }
4455
4456 var minIndex = 0
4457 var maxIndex = indices.length - 1
4458 var currentIndex
4459 var currentItem
4460
4461 while (minIndex <= maxIndex) {
4462 currentIndex = ((maxIndex + minIndex) / 2) >> 0
4463 currentItem = indices[currentIndex]
4464
4465 if (minIndex === maxIndex) {
4466 return currentItem >= left && currentItem <= right
4467 } else if (currentItem < left) {
4468 minIndex = currentIndex + 1
4469 } else if (currentItem > right) {
4470 maxIndex = currentIndex - 1
4471 } else {
4472 return true
4473 }
4474 }
4475
4476 return false;
4477}
4478
4479function ascending(a, b) {
4480 return a > b ? 1 : -1
4481}
4482
4483
4484/***/ }),
4485
4486/***/ 9120:
4487/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4488
4489var applyProperties = __webpack_require__(6672)
4490
4491var isWidget = __webpack_require__(4097)
4492var VPatch = __webpack_require__(8057)
4493
4494var updateWidget = __webpack_require__(6670)
4495
4496module.exports = applyPatch
4497
4498function applyPatch(vpatch, domNode, renderOptions) {
4499 var type = vpatch.type
4500 var vNode = vpatch.vNode
4501 var patch = vpatch.patch
4502
4503 switch (type) {
4504 case VPatch.REMOVE:
4505 return removeNode(domNode, vNode)
4506 case VPatch.INSERT:
4507 return insertNode(domNode, patch, renderOptions)
4508 case VPatch.VTEXT:
4509 return stringPatch(domNode, vNode, patch, renderOptions)
4510 case VPatch.WIDGET:
4511 return widgetPatch(domNode, vNode, patch, renderOptions)
4512 case VPatch.VNODE:
4513 return vNodePatch(domNode, vNode, patch, renderOptions)
4514 case VPatch.ORDER:
4515 reorderChildren(domNode, patch)
4516 return domNode
4517 case VPatch.PROPS:
4518 applyProperties(domNode, patch, vNode.properties)
4519 return domNode
4520 case VPatch.THUNK:
4521 return replaceRoot(domNode,
4522 renderOptions.patch(domNode, patch, renderOptions))
4523 default:
4524 return domNode
4525 }
4526}
4527
4528function removeNode(domNode, vNode) {
4529 var parentNode = domNode.parentNode
4530
4531 if (parentNode) {
4532 parentNode.removeChild(domNode)
4533 }
4534
4535 destroyWidget(domNode, vNode);
4536
4537 return null
4538}
4539
4540function insertNode(parentNode, vNode, renderOptions) {
4541 var newNode = renderOptions.render(vNode, renderOptions)
4542
4543 if (parentNode) {
4544 parentNode.appendChild(newNode)
4545 }
4546
4547 return parentNode
4548}
4549
4550function stringPatch(domNode, leftVNode, vText, renderOptions) {
4551 var newNode
4552
4553 if (domNode.nodeType === 3) {
4554 domNode.replaceData(0, domNode.length, vText.text)
4555 newNode = domNode
4556 } else {
4557 var parentNode = domNode.parentNode
4558 newNode = renderOptions.render(vText, renderOptions)
4559
4560 if (parentNode && newNode !== domNode) {
4561 parentNode.replaceChild(newNode, domNode)
4562 }
4563 }
4564
4565 return newNode
4566}
4567
4568function widgetPatch(domNode, leftVNode, widget, renderOptions) {
4569 var updating = updateWidget(leftVNode, widget)
4570 var newNode
4571
4572 if (updating) {
4573 newNode = widget.update(leftVNode, domNode) || domNode
4574 } else {
4575 newNode = renderOptions.render(widget, renderOptions)
4576 }
4577
4578 var parentNode = domNode.parentNode
4579
4580 if (parentNode && newNode !== domNode) {
4581 parentNode.replaceChild(newNode, domNode)
4582 }
4583
4584 if (!updating) {
4585 destroyWidget(domNode, leftVNode)
4586 }
4587
4588 return newNode
4589}
4590
4591function vNodePatch(domNode, leftVNode, vNode, renderOptions) {
4592 var parentNode = domNode.parentNode
4593 var newNode = renderOptions.render(vNode, renderOptions)
4594
4595 if (parentNode && newNode !== domNode) {
4596 parentNode.replaceChild(newNode, domNode)
4597 }
4598
4599 return newNode
4600}
4601
4602function destroyWidget(domNode, w) {
4603 if (typeof w.destroy === "function" && isWidget(w)) {
4604 w.destroy(domNode)
4605 }
4606}
4607
4608function reorderChildren(domNode, moves) {
4609 var childNodes = domNode.childNodes
4610 var keyMap = {}
4611 var node
4612 var remove
4613 var insert
4614
4615 for (var i = 0; i < moves.removes.length; i++) {
4616 remove = moves.removes[i]
4617 node = childNodes[remove.from]
4618 if (remove.key) {
4619 keyMap[remove.key] = node
4620 }
4621 domNode.removeChild(node)
4622 }
4623
4624 var length = childNodes.length
4625 for (var j = 0; j < moves.inserts.length; j++) {
4626 insert = moves.inserts[j]
4627 node = keyMap[insert.key]
4628 // this is the weirdest bug i've ever seen in webkit
4629 domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to])
4630 }
4631}
4632
4633function replaceRoot(oldRoot, newRoot) {
4634 if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) {
4635 oldRoot.parentNode.replaceChild(newRoot, oldRoot)
4636 }
4637
4638 return newRoot;
4639}
4640
4641
4642/***/ }),
4643
4644/***/ 6943:
4645/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4646
4647var document = __webpack_require__(9144)
4648var isArray = __webpack_require__(7362)
4649
4650var render = __webpack_require__(3513)
4651var domIndex = __webpack_require__(8992)
4652var patchOp = __webpack_require__(9120)
4653module.exports = patch
4654
4655function patch(rootNode, patches, renderOptions) {
4656 renderOptions = renderOptions || {}
4657 renderOptions.patch = renderOptions.patch && renderOptions.patch !== patch
4658 ? renderOptions.patch
4659 : patchRecursive
4660 renderOptions.render = renderOptions.render || render
4661
4662 return renderOptions.patch(rootNode, patches, renderOptions)
4663}
4664
4665function patchRecursive(rootNode, patches, renderOptions) {
4666 var indices = patchIndices(patches)
4667
4668 if (indices.length === 0) {
4669 return rootNode
4670 }
4671
4672 var index = domIndex(rootNode, patches.a, indices)
4673 var ownerDocument = rootNode.ownerDocument
4674
4675 if (!renderOptions.document && ownerDocument !== document) {
4676 renderOptions.document = ownerDocument
4677 }
4678
4679 for (var i = 0; i < indices.length; i++) {
4680 var nodeIndex = indices[i]
4681 rootNode = applyPatch(rootNode,
4682 index[nodeIndex],
4683 patches[nodeIndex],
4684 renderOptions)
4685 }
4686
4687 return rootNode
4688}
4689
4690function applyPatch(rootNode, domNode, patchList, renderOptions) {
4691 if (!domNode) {
4692 return rootNode
4693 }
4694
4695 var newNode
4696
4697 if (isArray(patchList)) {
4698 for (var i = 0; i < patchList.length; i++) {
4699 newNode = patchOp(patchList[i], domNode, renderOptions)
4700
4701 if (domNode === rootNode) {
4702 rootNode = newNode
4703 }
4704 }
4705 } else {
4706 newNode = patchOp(patchList, domNode, renderOptions)
4707
4708 if (domNode === rootNode) {
4709 rootNode = newNode
4710 }
4711 }
4712
4713 return rootNode
4714}
4715
4716function patchIndices(patches) {
4717 var indices = []
4718
4719 for (var key in patches) {
4720 if (key !== "a") {
4721 indices.push(Number(key))
4722 }
4723 }
4724
4725 return indices
4726}
4727
4728
4729/***/ }),
4730
4731/***/ 6670:
4732/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4733
4734var isWidget = __webpack_require__(4097)
4735
4736module.exports = updateWidget
4737
4738function updateWidget(a, b) {
4739 if (isWidget(a) && isWidget(b)) {
4740 if ("name" in a && "name" in b) {
4741 return a.id === b.id
4742 } else {
4743 return a.init === b.init
4744 }
4745 }
4746
4747 return false
4748}
4749
4750
4751/***/ }),
4752
4753/***/ 6505:
4754/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4755
4756"use strict";
4757
4758
4759var EvStore = __webpack_require__(8832);
4760
4761module.exports = EvHook;
4762
4763function EvHook(value) {
4764 if (!(this instanceof EvHook)) {
4765 return new EvHook(value);
4766 }
4767
4768 this.value = value;
4769}
4770
4771EvHook.prototype.hook = function (node, propertyName) {
4772 var es = EvStore(node);
4773 var propName = propertyName.substr(3);
4774
4775 es[propName] = this.value;
4776};
4777
4778EvHook.prototype.unhook = function(node, propertyName) {
4779 var es = EvStore(node);
4780 var propName = propertyName.substr(3);
4781
4782 es[propName] = undefined;
4783};
4784
4785
4786/***/ }),
4787
4788/***/ 7199:
4789/***/ ((module) => {
4790
4791"use strict";
4792
4793
4794module.exports = SoftSetHook;
4795
4796function SoftSetHook(value) {
4797 if (!(this instanceof SoftSetHook)) {
4798 return new SoftSetHook(value);
4799 }
4800
4801 this.value = value;
4802}
4803
4804SoftSetHook.prototype.hook = function (node, propertyName) {
4805 if (node[propertyName] !== this.value) {
4806 node[propertyName] = this.value;
4807 }
4808};
4809
4810
4811/***/ }),
4812
4813/***/ 8744:
4814/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4815
4816"use strict";
4817
4818
4819var isArray = __webpack_require__(7362);
4820
4821var VNode = __webpack_require__(4282);
4822var VText = __webpack_require__(4268);
4823var isVNode = __webpack_require__(5170);
4824var isVText = __webpack_require__(6221);
4825var isWidget = __webpack_require__(4097);
4826var isHook = __webpack_require__(7265);
4827var isVThunk = __webpack_require__(6741);
4828
4829var parseTag = __webpack_require__(1948);
4830var softSetHook = __webpack_require__(7199);
4831var evHook = __webpack_require__(6505);
4832
4833module.exports = h;
4834
4835function h(tagName, properties, children) {
4836 var childNodes = [];
4837 var tag, props, key, namespace;
4838
4839 if (!children && isChildren(properties)) {
4840 children = properties;
4841 props = {};
4842 }
4843
4844 props = props || properties || {};
4845 tag = parseTag(tagName, props);
4846
4847 // support keys
4848 if (props.hasOwnProperty('key')) {
4849 key = props.key;
4850 props.key = undefined;
4851 }
4852
4853 // support namespace
4854 if (props.hasOwnProperty('namespace')) {
4855 namespace = props.namespace;
4856 props.namespace = undefined;
4857 }
4858
4859 // fix cursor bug
4860 if (tag === 'INPUT' &&
4861 !namespace &&
4862 props.hasOwnProperty('value') &&
4863 props.value !== undefined &&
4864 !isHook(props.value)
4865 ) {
4866 props.value = softSetHook(props.value);
4867 }
4868
4869 transformProperties(props);
4870
4871 if (children !== undefined && children !== null) {
4872 addChild(children, childNodes, tag, props);
4873 }
4874
4875
4876 return new VNode(tag, props, childNodes, key, namespace);
4877}
4878
4879function addChild(c, childNodes, tag, props) {
4880 if (typeof c === 'string') {
4881 childNodes.push(new VText(c));
4882 } else if (typeof c === 'number') {
4883 childNodes.push(new VText(String(c)));
4884 } else if (isChild(c)) {
4885 childNodes.push(c);
4886 } else if (isArray(c)) {
4887 for (var i = 0; i < c.length; i++) {
4888 addChild(c[i], childNodes, tag, props);
4889 }
4890 } else if (c === null || c === undefined) {
4891 return;
4892 } else {
4893 throw UnexpectedVirtualElement({
4894 foreignObject: c,
4895 parentVnode: {
4896 tagName: tag,
4897 properties: props
4898 }
4899 });
4900 }
4901}
4902
4903function transformProperties(props) {
4904 for (var propName in props) {
4905 if (props.hasOwnProperty(propName)) {
4906 var value = props[propName];
4907
4908 if (isHook(value)) {
4909 continue;
4910 }
4911
4912 if (propName.substr(0, 3) === 'ev-') {
4913 // add ev-foo support
4914 props[propName] = evHook(value);
4915 }
4916 }
4917 }
4918}
4919
4920function isChild(x) {
4921 return isVNode(x) || isVText(x) || isWidget(x) || isVThunk(x);
4922}
4923
4924function isChildren(x) {
4925 return typeof x === 'string' || isArray(x) || isChild(x);
4926}
4927
4928function UnexpectedVirtualElement(data) {
4929 var err = new Error();
4930
4931 err.type = 'virtual-hyperscript.unexpected.virtual-element';
4932 err.message = 'Unexpected virtual child passed to h().\n' +
4933 'Expected a VNode / Vthunk / VWidget / string but:\n' +
4934 'got:\n' +
4935 errorString(data.foreignObject) +
4936 '.\n' +
4937 'The parent vnode is:\n' +
4938 errorString(data.parentVnode)
4939 '\n' +
4940 'Suggested fix: change your `h(..., [ ... ])` callsite.';
4941 err.foreignObject = data.foreignObject;
4942 err.parentVnode = data.parentVnode;
4943
4944 return err;
4945}
4946
4947function errorString(obj) {
4948 try {
4949 return JSON.stringify(obj, null, ' ');
4950 } catch (e) {
4951 return String(obj);
4952 }
4953}
4954
4955
4956/***/ }),
4957
4958/***/ 1948:
4959/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4960
4961"use strict";
4962
4963
4964var split = __webpack_require__(6824);
4965
4966var classIdSplit = /([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/;
4967var notClassId = /^\.|#/;
4968
4969module.exports = parseTag;
4970
4971function parseTag(tag, props) {
4972 if (!tag) {
4973 return 'DIV';
4974 }
4975
4976 var noId = !(props.hasOwnProperty('id'));
4977
4978 var tagParts = split(tag, classIdSplit);
4979 var tagName = null;
4980
4981 if (notClassId.test(tagParts[1])) {
4982 tagName = 'DIV';
4983 }
4984
4985 var classes, part, type, i;
4986
4987 for (i = 0; i < tagParts.length; i++) {
4988 part = tagParts[i];
4989
4990 if (!part) {
4991 continue;
4992 }
4993
4994 type = part.charAt(0);
4995
4996 if (!tagName) {
4997 tagName = part;
4998 } else if (type === '.') {
4999 classes = classes || [];
5000 classes.push(part.substring(1, part.length));
5001 } else if (type === '#' && noId) {
5002 props.id = part.substring(1, part.length);
5003 }
5004 }
5005
5006 if (classes) {
5007 if (props.className) {
5008 classes.push(props.className);
5009 }
5010
5011 props.className = classes.join(' ');
5012 }
5013
5014 return props.namespace ? tagName : tagName.toUpperCase();
5015}
5016
5017
5018/***/ }),
5019
5020/***/ 6078:
5021/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5022
5023var isVNode = __webpack_require__(5170)
5024var isVText = __webpack_require__(6221)
5025var isWidget = __webpack_require__(4097)
5026var isThunk = __webpack_require__(6741)
5027
5028module.exports = handleThunk
5029
5030function handleThunk(a, b) {
5031 var renderedA = a
5032 var renderedB = b
5033
5034 if (isThunk(b)) {
5035 renderedB = renderThunk(b, a)
5036 }
5037
5038 if (isThunk(a)) {
5039 renderedA = renderThunk(a, null)
5040 }
5041
5042 return {
5043 a: renderedA,
5044 b: renderedB
5045 }
5046}
5047
5048function renderThunk(thunk, previous) {
5049 var renderedThunk = thunk.vnode
5050
5051 if (!renderedThunk) {
5052 renderedThunk = thunk.vnode = thunk.render(previous)
5053 }
5054
5055 if (!(isVNode(renderedThunk) ||
5056 isVText(renderedThunk) ||
5057 isWidget(renderedThunk))) {
5058 throw new Error("thunk did not return a valid node");
5059 }
5060
5061 return renderedThunk
5062}
5063
5064
5065/***/ }),
5066
5067/***/ 6741:
5068/***/ ((module) => {
5069
5070module.exports = isThunk
5071
5072function isThunk(t) {
5073 return t && t.type === "Thunk"
5074}
5075
5076
5077/***/ }),
5078
5079/***/ 7265:
5080/***/ ((module) => {
5081
5082module.exports = isHook
5083
5084function isHook(hook) {
5085 return hook &&
5086 (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") ||
5087 typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook"))
5088}
5089
5090
5091/***/ }),
5092
5093/***/ 5170:
5094/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5095
5096var version = __webpack_require__(9962)
5097
5098module.exports = isVirtualNode
5099
5100function isVirtualNode(x) {
5101 return x && x.type === "VirtualNode" && x.version === version
5102}
5103
5104
5105/***/ }),
5106
5107/***/ 6221:
5108/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5109
5110var version = __webpack_require__(9962)
5111
5112module.exports = isVirtualText
5113
5114function isVirtualText(x) {
5115 return x && x.type === "VirtualText" && x.version === version
5116}
5117
5118
5119/***/ }),
5120
5121/***/ 4097:
5122/***/ ((module) => {
5123
5124module.exports = isWidget
5125
5126function isWidget(w) {
5127 return w && w.type === "Widget"
5128}
5129
5130
5131/***/ }),
5132
5133/***/ 9962:
5134/***/ ((module) => {
5135
5136module.exports = "2"
5137
5138
5139/***/ }),
5140
5141/***/ 4282:
5142/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5143
5144var version = __webpack_require__(9962)
5145var isVNode = __webpack_require__(5170)
5146var isWidget = __webpack_require__(4097)
5147var isThunk = __webpack_require__(6741)
5148var isVHook = __webpack_require__(7265)
5149
5150module.exports = VirtualNode
5151
5152var noProperties = {}
5153var noChildren = []
5154
5155function VirtualNode(tagName, properties, children, key, namespace) {
5156 this.tagName = tagName
5157 this.properties = properties || noProperties
5158 this.children = children || noChildren
5159 this.key = key != null ? String(key) : undefined
5160 this.namespace = (typeof namespace === "string") ? namespace : null
5161
5162 var count = (children && children.length) || 0
5163 var descendants = 0
5164 var hasWidgets = false
5165 var hasThunks = false
5166 var descendantHooks = false
5167 var hooks
5168
5169 for (var propName in properties) {
5170 if (properties.hasOwnProperty(propName)) {
5171 var property = properties[propName]
5172 if (isVHook(property) && property.unhook) {
5173 if (!hooks) {
5174 hooks = {}
5175 }
5176
5177 hooks[propName] = property
5178 }
5179 }
5180 }
5181
5182 for (var i = 0; i < count; i++) {
5183 var child = children[i]
5184 if (isVNode(child)) {
5185 descendants += child.count || 0
5186
5187 if (!hasWidgets && child.hasWidgets) {
5188 hasWidgets = true
5189 }
5190
5191 if (!hasThunks && child.hasThunks) {
5192 hasThunks = true
5193 }
5194
5195 if (!descendantHooks && (child.hooks || child.descendantHooks)) {
5196 descendantHooks = true
5197 }
5198 } else if (!hasWidgets && isWidget(child)) {
5199 if (typeof child.destroy === "function") {
5200 hasWidgets = true
5201 }
5202 } else if (!hasThunks && isThunk(child)) {
5203 hasThunks = true;
5204 }
5205 }
5206
5207 this.count = count + descendants
5208 this.hasWidgets = hasWidgets
5209 this.hasThunks = hasThunks
5210 this.hooks = hooks
5211 this.descendantHooks = descendantHooks
5212}
5213
5214VirtualNode.prototype.version = version
5215VirtualNode.prototype.type = "VirtualNode"
5216
5217
5218/***/ }),
5219
5220/***/ 8057:
5221/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5222
5223var version = __webpack_require__(9962)
5224
5225VirtualPatch.NONE = 0
5226VirtualPatch.VTEXT = 1
5227VirtualPatch.VNODE = 2
5228VirtualPatch.WIDGET = 3
5229VirtualPatch.PROPS = 4
5230VirtualPatch.ORDER = 5
5231VirtualPatch.INSERT = 6
5232VirtualPatch.REMOVE = 7
5233VirtualPatch.THUNK = 8
5234
5235module.exports = VirtualPatch
5236
5237function VirtualPatch(type, vNode, patch) {
5238 this.type = Number(type)
5239 this.vNode = vNode
5240 this.patch = patch
5241}
5242
5243VirtualPatch.prototype.version = version
5244VirtualPatch.prototype.type = "VirtualPatch"
5245
5246
5247/***/ }),
5248
5249/***/ 4268:
5250/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5251
5252var version = __webpack_require__(9962)
5253
5254module.exports = VirtualText
5255
5256function VirtualText(text) {
5257 this.text = String(text)
5258}
5259
5260VirtualText.prototype.version = version
5261VirtualText.prototype.type = "VirtualText"
5262
5263
5264/***/ }),
5265
5266/***/ 9973:
5267/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5268
5269var isObject = __webpack_require__(6240)
5270var isHook = __webpack_require__(7265)
5271
5272module.exports = diffProps
5273
5274function diffProps(a, b) {
5275 var diff
5276
5277 for (var aKey in a) {
5278 if (!(aKey in b)) {
5279 diff = diff || {}
5280 diff[aKey] = undefined
5281 }
5282
5283 var aValue = a[aKey]
5284 var bValue = b[aKey]
5285
5286 if (aValue === bValue) {
5287 continue
5288 } else if (isObject(aValue) && isObject(bValue)) {
5289 if (getPrototype(bValue) !== getPrototype(aValue)) {
5290 diff = diff || {}
5291 diff[aKey] = bValue
5292 } else if (isHook(bValue)) {
5293 diff = diff || {}
5294 diff[aKey] = bValue
5295 } else {
5296 var objectDiff = diffProps(aValue, bValue)
5297 if (objectDiff) {
5298 diff = diff || {}
5299 diff[aKey] = objectDiff
5300 }
5301 }
5302 } else {
5303 diff = diff || {}
5304 diff[aKey] = bValue
5305 }
5306 }
5307
5308 for (var bKey in b) {
5309 if (!(bKey in a)) {
5310 diff = diff || {}
5311 diff[bKey] = b[bKey]
5312 }
5313 }
5314
5315 return diff
5316}
5317
5318function getPrototype(value) {
5319 if (Object.getPrototypeOf) {
5320 return Object.getPrototypeOf(value)
5321 } else if (value.__proto__) {
5322 return value.__proto__
5323 } else if (value.constructor) {
5324 return value.constructor.prototype
5325 }
5326}
5327
5328
5329/***/ }),
5330
5331/***/ 3072:
5332/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5333
5334var isArray = __webpack_require__(7362)
5335
5336var VPatch = __webpack_require__(8057)
5337var isVNode = __webpack_require__(5170)
5338var isVText = __webpack_require__(6221)
5339var isWidget = __webpack_require__(4097)
5340var isThunk = __webpack_require__(6741)
5341var handleThunk = __webpack_require__(6078)
5342
5343var diffProps = __webpack_require__(9973)
5344
5345module.exports = diff
5346
5347function diff(a, b) {
5348 var patch = { a: a }
5349 walk(a, b, patch, 0)
5350 return patch
5351}
5352
5353function walk(a, b, patch, index) {
5354 if (a === b) {
5355 return
5356 }
5357
5358 var apply = patch[index]
5359 var applyClear = false
5360
5361 if (isThunk(a) || isThunk(b)) {
5362 thunks(a, b, patch, index)
5363 } else if (b == null) {
5364
5365 // If a is a widget we will add a remove patch for it
5366 // Otherwise any child widgets/hooks must be destroyed.
5367 // This prevents adding two remove patches for a widget.
5368 if (!isWidget(a)) {
5369 clearState(a, patch, index)
5370 apply = patch[index]
5371 }
5372
5373 apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b))
5374 } else if (isVNode(b)) {
5375 if (isVNode(a)) {
5376 if (a.tagName === b.tagName &&
5377 a.namespace === b.namespace &&
5378 a.key === b.key) {
5379 var propsPatch = diffProps(a.properties, b.properties)
5380 if (propsPatch) {
5381 apply = appendPatch(apply,
5382 new VPatch(VPatch.PROPS, a, propsPatch))
5383 }
5384 apply = diffChildren(a, b, patch, apply, index)
5385 } else {
5386 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
5387 applyClear = true
5388 }
5389 } else {
5390 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
5391 applyClear = true
5392 }
5393 } else if (isVText(b)) {
5394 if (!isVText(a)) {
5395 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
5396 applyClear = true
5397 } else if (a.text !== b.text) {
5398 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
5399 }
5400 } else if (isWidget(b)) {
5401 if (!isWidget(a)) {
5402 applyClear = true
5403 }
5404
5405 apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b))
5406 }
5407
5408 if (apply) {
5409 patch[index] = apply
5410 }
5411
5412 if (applyClear) {
5413 clearState(a, patch, index)
5414 }
5415}
5416
5417function diffChildren(a, b, patch, apply, index) {
5418 var aChildren = a.children
5419 var orderedSet = reorder(aChildren, b.children)
5420 var bChildren = orderedSet.children
5421
5422 var aLen = aChildren.length
5423 var bLen = bChildren.length
5424 var len = aLen > bLen ? aLen : bLen
5425
5426 for (var i = 0; i < len; i++) {
5427 var leftNode = aChildren[i]
5428 var rightNode = bChildren[i]
5429 index += 1
5430
5431 if (!leftNode) {
5432 if (rightNode) {
5433 // Excess nodes in b need to be added
5434 apply = appendPatch(apply,
5435 new VPatch(VPatch.INSERT, null, rightNode))
5436 }
5437 } else {
5438 walk(leftNode, rightNode, patch, index)
5439 }
5440
5441 if (isVNode(leftNode) && leftNode.count) {
5442 index += leftNode.count
5443 }
5444 }
5445
5446 if (orderedSet.moves) {
5447 // Reorder nodes last
5448 apply = appendPatch(apply, new VPatch(
5449 VPatch.ORDER,
5450 a,
5451 orderedSet.moves
5452 ))
5453 }
5454
5455 return apply
5456}
5457
5458function clearState(vNode, patch, index) {
5459 // TODO: Make this a single walk, not two
5460 unhook(vNode, patch, index)
5461 destroyWidgets(vNode, patch, index)
5462}
5463
5464// Patch records for all destroyed widgets must be added because we need
5465// a DOM node reference for the destroy function
5466function destroyWidgets(vNode, patch, index) {
5467 if (isWidget(vNode)) {
5468 if (typeof vNode.destroy === "function") {
5469 patch[index] = appendPatch(
5470 patch[index],
5471 new VPatch(VPatch.REMOVE, vNode, null)
5472 )
5473 }
5474 } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
5475 var children = vNode.children
5476 var len = children.length
5477 for (var i = 0; i < len; i++) {
5478 var child = children[i]
5479 index += 1
5480
5481 destroyWidgets(child, patch, index)
5482
5483 if (isVNode(child) && child.count) {
5484 index += child.count
5485 }
5486 }
5487 } else if (isThunk(vNode)) {
5488 thunks(vNode, null, patch, index)
5489 }
5490}
5491
5492// Create a sub-patch for thunks
5493function thunks(a, b, patch, index) {
5494 var nodes = handleThunk(a, b)
5495 var thunkPatch = diff(nodes.a, nodes.b)
5496 if (hasPatches(thunkPatch)) {
5497 patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch)
5498 }
5499}
5500
5501function hasPatches(patch) {
5502 for (var index in patch) {
5503 if (index !== "a") {
5504 return true
5505 }
5506 }
5507
5508 return false
5509}
5510
5511// Execute hooks when two nodes are identical
5512function unhook(vNode, patch, index) {
5513 if (isVNode(vNode)) {
5514 if (vNode.hooks) {
5515 patch[index] = appendPatch(
5516 patch[index],
5517 new VPatch(
5518 VPatch.PROPS,
5519 vNode,
5520 undefinedKeys(vNode.hooks)
5521 )
5522 )
5523 }
5524
5525 if (vNode.descendantHooks || vNode.hasThunks) {
5526 var children = vNode.children
5527 var len = children.length
5528 for (var i = 0; i < len; i++) {
5529 var child = children[i]
5530 index += 1
5531
5532 unhook(child, patch, index)
5533
5534 if (isVNode(child) && child.count) {
5535 index += child.count
5536 }
5537 }
5538 }
5539 } else if (isThunk(vNode)) {
5540 thunks(vNode, null, patch, index)
5541 }
5542}
5543
5544function undefinedKeys(obj) {
5545 var result = {}
5546
5547 for (var key in obj) {
5548 result[key] = undefined
5549 }
5550
5551 return result
5552}
5553
5554// List diff, naive left to right reordering
5555function reorder(aChildren, bChildren) {
5556 // O(M) time, O(M) memory
5557 var bChildIndex = keyIndex(bChildren)
5558 var bKeys = bChildIndex.keys
5559 var bFree = bChildIndex.free
5560
5561 if (bFree.length === bChildren.length) {
5562 return {
5563 children: bChildren,
5564 moves: null
5565 }
5566 }
5567
5568 // O(N) time, O(N) memory
5569 var aChildIndex = keyIndex(aChildren)
5570 var aKeys = aChildIndex.keys
5571 var aFree = aChildIndex.free
5572
5573 if (aFree.length === aChildren.length) {
5574 return {
5575 children: bChildren,
5576 moves: null
5577 }
5578 }
5579
5580 // O(MAX(N, M)) memory
5581 var newChildren = []
5582
5583 var freeIndex = 0
5584 var freeCount = bFree.length
5585 var deletedItems = 0
5586
5587 // Iterate through a and match a node in b
5588 // O(N) time,
5589 for (var i = 0 ; i < aChildren.length; i++) {
5590 var aItem = aChildren[i]
5591 var itemIndex
5592
5593 if (aItem.key) {
5594 if (bKeys.hasOwnProperty(aItem.key)) {
5595 // Match up the old keys
5596 itemIndex = bKeys[aItem.key]
5597 newChildren.push(bChildren[itemIndex])
5598
5599 } else {
5600 // Remove old keyed items
5601 itemIndex = i - deletedItems++
5602 newChildren.push(null)
5603 }
5604 } else {
5605 // Match the item in a with the next free item in b
5606 if (freeIndex < freeCount) {
5607 itemIndex = bFree[freeIndex++]
5608 newChildren.push(bChildren[itemIndex])
5609 } else {
5610 // There are no free items in b to match with
5611 // the free items in a, so the extra free nodes
5612 // are deleted.
5613 itemIndex = i - deletedItems++
5614 newChildren.push(null)
5615 }
5616 }
5617 }
5618
5619 var lastFreeIndex = freeIndex >= bFree.length ?
5620 bChildren.length :
5621 bFree[freeIndex]
5622
5623 // Iterate through b and append any new keys
5624 // O(M) time
5625 for (var j = 0; j < bChildren.length; j++) {
5626 var newItem = bChildren[j]
5627
5628 if (newItem.key) {
5629 if (!aKeys.hasOwnProperty(newItem.key)) {
5630 // Add any new keyed items
5631 // We are adding new items to the end and then sorting them
5632 // in place. In future we should insert new items in place.
5633 newChildren.push(newItem)
5634 }
5635 } else if (j >= lastFreeIndex) {
5636 // Add any leftover non-keyed items
5637 newChildren.push(newItem)
5638 }
5639 }
5640
5641 var simulate = newChildren.slice()
5642 var simulateIndex = 0
5643 var removes = []
5644 var inserts = []
5645 var simulateItem
5646
5647 for (var k = 0; k < bChildren.length;) {
5648 var wantedItem = bChildren[k]
5649 simulateItem = simulate[simulateIndex]
5650
5651 // remove items
5652 while (simulateItem === null && simulate.length) {
5653 removes.push(remove(simulate, simulateIndex, null))
5654 simulateItem = simulate[simulateIndex]
5655 }
5656
5657 if (!simulateItem || simulateItem.key !== wantedItem.key) {
5658 // if we need a key in this position...
5659 if (wantedItem.key) {
5660 if (simulateItem && simulateItem.key) {
5661 // if an insert doesn't put this key in place, it needs to move
5662 if (bKeys[simulateItem.key] !== k + 1) {
5663 removes.push(remove(simulate, simulateIndex, simulateItem.key))
5664 simulateItem = simulate[simulateIndex]
5665 // if the remove didn't put the wanted item in place, we need to insert it
5666 if (!simulateItem || simulateItem.key !== wantedItem.key) {
5667 inserts.push({key: wantedItem.key, to: k})
5668 }
5669 // items are matching, so skip ahead
5670 else {
5671 simulateIndex++
5672 }
5673 }
5674 else {
5675 inserts.push({key: wantedItem.key, to: k})
5676 }
5677 }
5678 else {
5679 inserts.push({key: wantedItem.key, to: k})
5680 }
5681 k++
5682 }
5683 // a key in simulate has no matching wanted key, remove it
5684 else if (simulateItem && simulateItem.key) {
5685 removes.push(remove(simulate, simulateIndex, simulateItem.key))
5686 }
5687 }
5688 else {
5689 simulateIndex++
5690 k++
5691 }
5692 }
5693
5694 // remove all the remaining nodes from simulate
5695 while(simulateIndex < simulate.length) {
5696 simulateItem = simulate[simulateIndex]
5697 removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key))
5698 }
5699
5700 // If the only moves we have are deletes then we can just
5701 // let the delete patch remove these items.
5702 if (removes.length === deletedItems && !inserts.length) {
5703 return {
5704 children: newChildren,
5705 moves: null
5706 }
5707 }
5708
5709 return {
5710 children: newChildren,
5711 moves: {
5712 removes: removes,
5713 inserts: inserts
5714 }
5715 }
5716}
5717
5718function remove(arr, index, key) {
5719 arr.splice(index, 1)
5720
5721 return {
5722 from: index,
5723 key: key
5724 }
5725}
5726
5727function keyIndex(children) {
5728 var keys = {}
5729 var free = []
5730 var length = children.length
5731
5732 for (var i = 0; i < length; i++) {
5733 var child = children[i]
5734
5735 if (child.key) {
5736 keys[child.key] = i
5737 } else {
5738 free.push(i)
5739 }
5740 }
5741
5742 return {
5743 keys: keys, // A hash of key name to index
5744 free: free // An array of unkeyed item indices
5745 }
5746}
5747
5748function appendPatch(apply, patch) {
5749 if (apply) {
5750 if (isArray(apply)) {
5751 apply.push(patch)
5752 } else {
5753 apply = [apply, patch]
5754 }
5755
5756 return apply
5757 } else {
5758 return patch
5759 }
5760}
5761
5762
5763/***/ }),
5764
5765/***/ 4991:
5766/***/ ((module) => {
5767
5768"use strict";
5769
5770
5771/**
5772 * @param {TypedArray} array - Subarray of audio to calculate peaks from.
5773 */
5774function findMinMax(array) {
5775 var min = Infinity;
5776 var max = -Infinity;
5777 var i = 0;
5778 var len = array.length;
5779 var curr;
5780
5781 for (; i < len; i++) {
5782 curr = array[i];
5783 if (min > curr) {
5784 min = curr;
5785 }
5786 if (max < curr) {
5787 max = curr;
5788 }
5789 }
5790
5791 return {
5792 min: min,
5793 max: max
5794 };
5795}
5796
5797/**
5798 * @param {Number} n - peak to convert from float to Int8, Int16 etc.
5799 * @param {Number} bits - convert to #bits two's complement signed integer
5800 */
5801function convert(n, bits) {
5802 var max = Math.pow(2, bits - 1);
5803 var v = n < 0 ? n * max : n * (max - 1);
5804 return Math.max(-max, Math.min(max - 1, v));
5805}
5806
5807/**
5808 * @param {TypedArray} channel - Audio track frames to calculate peaks from.
5809 * @param {Number} samplesPerPixel - Audio frames per peak
5810 */
5811function extractPeaks(channel, samplesPerPixel, bits) {
5812 var i;
5813 var chanLength = channel.length;
5814 var numPeaks = Math.ceil(chanLength / samplesPerPixel);
5815 var start;
5816 var end;
5817 var segment;
5818 var max;
5819 var min;
5820 var extrema;
5821
5822 //create interleaved array of min,max
5823 var peaks = makeTypedArray(bits, numPeaks * 2);
5824
5825 for (i = 0; i < numPeaks; i++) {
5826 start = i * samplesPerPixel;
5827 end =
5828 (i + 1) * samplesPerPixel > chanLength
5829 ? chanLength
5830 : (i + 1) * samplesPerPixel;
5831
5832 segment = channel.subarray(start, end);
5833 extrema = findMinMax(segment);
5834 min = convert(extrema.min, bits);
5835 max = convert(extrema.max, bits);
5836
5837 peaks[i * 2] = min;
5838 peaks[i * 2 + 1] = max;
5839 }
5840
5841 return peaks;
5842}
5843
5844function makeTypedArray(bits, length) {
5845 return new (new Function(`return Int${bits}Array`)())(length);
5846}
5847
5848function makeMono(channelPeaks, bits) {
5849 var numChan = channelPeaks.length;
5850 var weight = 1 / numChan;
5851 var numPeaks = channelPeaks[0].length / 2;
5852 var c = 0;
5853 var i = 0;
5854 var min;
5855 var max;
5856 var peaks = makeTypedArray(bits, numPeaks * 2);
5857
5858 for (i = 0; i < numPeaks; i++) {
5859 min = 0;
5860 max = 0;
5861
5862 for (c = 0; c < numChan; c++) {
5863 min += weight * channelPeaks[c][i * 2];
5864 max += weight * channelPeaks[c][i * 2 + 1];
5865 }
5866
5867 peaks[i * 2] = min;
5868 peaks[i * 2 + 1] = max;
5869 }
5870
5871 //return in array so channel number counts still work.
5872 return [peaks];
5873}
5874
5875function defaultNumber(value, defaultNumber) {
5876 if (typeof value === "number") {
5877 return value;
5878 } else {
5879 return defaultNumber;
5880 }
5881}
5882
5883/**
5884 * @param {AudioBuffer,TypedArray} source - Source of audio samples for peak calculations.
5885 * @param {Number} samplesPerPixel - Number of audio samples per peak.
5886 * @param {Boolean} isMono - Whether to render the channels to a single array.
5887 * @param {Number} cueIn - index in channel to start peak calculations from.
5888 * @param {Number} cueOut - index in channel to end peak calculations from (non-inclusive).
5889 * @param {Number} bits - number of bits for a peak.
5890 */
5891module.exports = function (
5892 source,
5893 samplesPerPixel,
5894 isMono,
5895 cueIn,
5896 cueOut,
5897 bits
5898) {
5899 samplesPerPixel = defaultNumber(samplesPerPixel, 1000);
5900 bits = defaultNumber(bits, 16);
5901
5902 if (isMono === null || isMono === undefined) {
5903 isMono = true;
5904 }
5905
5906 if ([8, 16, 32].indexOf(bits) < 0) {
5907 throw new Error("Invalid number of bits specified for peaks.");
5908 }
5909
5910 var numChan = source.numberOfChannels;
5911 var peaks = [];
5912 var c;
5913 var numPeaks;
5914 var channel;
5915 var slice;
5916
5917 cueIn = defaultNumber(cueIn, 0);
5918 cueOut = defaultNumber(cueOut, source.length);
5919
5920 if (typeof source.subarray === "undefined") {
5921 for (c = 0; c < numChan; c++) {
5922 channel = source.getChannelData(c);
5923 slice = channel.subarray(cueIn, cueOut);
5924 peaks.push(extractPeaks(slice, samplesPerPixel, bits));
5925 }
5926 } else {
5927 peaks.push(
5928 extractPeaks(source.subarray(cueIn, cueOut), samplesPerPixel, bits)
5929 );
5930 }
5931
5932 if (isMono && peaks.length > 1) {
5933 peaks = makeMono(peaks, bits);
5934 }
5935
5936 numPeaks = peaks[0].length / 2;
5937
5938 return {
5939 length: numPeaks,
5940 data: peaks,
5941 bits: bits
5942 };
5943};
5944
5945
5946/***/ }),
5947
5948/***/ 7362:
5949/***/ ((module) => {
5950
5951var nativeIsArray = Array.isArray
5952var toString = Object.prototype.toString
5953
5954module.exports = nativeIsArray || isArray
5955
5956function isArray(obj) {
5957 return toString.call(obj) === "[object Array]"
5958}
5959
5960
5961/***/ }),
5962
5963/***/ 5893:
5964/***/ (() => {
5965
5966/* (ignored) */
5967
5968/***/ })
5969
5970/******/ });
5971/************************************************************************/
5972/******/ // The module cache
5973/******/ var __webpack_module_cache__ = {};
5974/******/
5975/******/ // The require function
5976/******/ function __webpack_require__(moduleId) {
5977/******/ // Check if module is in cache
5978/******/ var cachedModule = __webpack_module_cache__[moduleId];
5979/******/ if (cachedModule !== undefined) {
5980/******/ return cachedModule.exports;
5981/******/ }
5982/******/ // Create a new module (and put it into the cache)
5983/******/ var module = __webpack_module_cache__[moduleId] = {
5984/******/ id: moduleId,
5985/******/ loaded: false,
5986/******/ exports: {}
5987/******/ };
5988/******/
5989/******/ // Execute the module function
5990/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
5991/******/
5992/******/ // Flag the module as loaded
5993/******/ module.loaded = true;
5994/******/
5995/******/ // Return the exports of the module
5996/******/ return module.exports;
5997/******/ }
5998/******/
5999/************************************************************************/
6000/******/ /* webpack/runtime/compat get default export */
6001/******/ (() => {
6002/******/ // getDefaultExport function for compatibility with non-harmony modules
6003/******/ __webpack_require__.n = (module) => {
6004/******/ var getter = module && module.__esModule ?
6005/******/ () => (module['default']) :
6006/******/ () => (module);
6007/******/ __webpack_require__.d(getter, { a: getter });
6008/******/ return getter;
6009/******/ };
6010/******/ })();
6011/******/
6012/******/ /* webpack/runtime/define property getters */
6013/******/ (() => {
6014/******/ // define getter functions for harmony exports
6015/******/ __webpack_require__.d = (exports, definition) => {
6016/******/ for(var key in definition) {
6017/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
6018/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
6019/******/ }
6020/******/ }
6021/******/ };
6022/******/ })();
6023/******/
6024/******/ /* webpack/runtime/global */
6025/******/ (() => {
6026/******/ __webpack_require__.g = (function() {
6027/******/ if (typeof globalThis === 'object') return globalThis;
6028/******/ try {
6029/******/ return this || new Function('return this')();
6030/******/ } catch (e) {
6031/******/ if (typeof window === 'object') return window;
6032/******/ }
6033/******/ })();
6034/******/ })();
6035/******/
6036/******/ /* webpack/runtime/hasOwnProperty shorthand */
6037/******/ (() => {
6038/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
6039/******/ })();
6040/******/
6041/******/ /* webpack/runtime/make namespace object */
6042/******/ (() => {
6043/******/ // define __esModule on exports
6044/******/ __webpack_require__.r = (exports) => {
6045/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
6046/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
6047/******/ }
6048/******/ Object.defineProperty(exports, '__esModule', { value: true });
6049/******/ };
6050/******/ })();
6051/******/
6052/******/ /* webpack/runtime/node module decorator */
6053/******/ (() => {
6054/******/ __webpack_require__.nmd = (module) => {
6055/******/ module.paths = [];
6056/******/ if (!module.children) module.children = [];
6057/******/ return module;
6058/******/ };
6059/******/ })();
6060/******/
6061/************************************************************************/
6062var __webpack_exports__ = {};
6063// This entry need to be wrapped in an IIFE because it need to be in strict mode.
6064(() => {
6065"use strict";
6066// ESM COMPAT FLAG
6067__webpack_require__.r(__webpack_exports__);
6068
6069// EXPORTS
6070__webpack_require__.d(__webpack_exports__, {
6071 "default": () => (/* binding */ app),
6072 "init": () => (/* binding */ init)
6073});
6074
6075// EXTERNAL MODULE: ./node_modules/lodash.defaultsdeep/index.js
6076var lodash_defaultsdeep = __webpack_require__(2098);
6077var lodash_defaultsdeep_default = /*#__PURE__*/__webpack_require__.n(lodash_defaultsdeep);
6078// EXTERNAL MODULE: ./node_modules/virtual-dom/create-element.js
6079var create_element = __webpack_require__(4935);
6080var create_element_default = /*#__PURE__*/__webpack_require__.n(create_element);
6081// EXTERNAL MODULE: ./node_modules/event-emitter/index.js
6082var event_emitter = __webpack_require__(8370);
6083var event_emitter_default = /*#__PURE__*/__webpack_require__.n(event_emitter);
6084// EXTERNAL MODULE: ./node_modules/virtual-dom/h.js
6085var h = __webpack_require__(347);
6086var h_default = /*#__PURE__*/__webpack_require__.n(h);
6087// EXTERNAL MODULE: ./node_modules/virtual-dom/diff.js
6088var diff = __webpack_require__(7921);
6089var diff_default = /*#__PURE__*/__webpack_require__.n(diff);
6090// EXTERNAL MODULE: ./node_modules/virtual-dom/patch.js
6091var patch = __webpack_require__(9720);
6092var patch_default = /*#__PURE__*/__webpack_require__.n(patch);
6093// EXTERNAL MODULE: ./node_modules/inline-worker/index.js
6094var inline_worker = __webpack_require__(849);
6095var inline_worker_default = /*#__PURE__*/__webpack_require__.n(inline_worker);
6096;// CONCATENATED MODULE: ./src/utils/conversions.js
6097function samplesToSeconds(samples, sampleRate) {
6098 return samples / sampleRate;
6099}
6100
6101function secondsToSamples(seconds, sampleRate) {
6102 return Math.ceil(seconds * sampleRate);
6103}
6104
6105function samplesToPixels(samples, resolution) {
6106 return Math.floor(samples / resolution);
6107}
6108
6109function pixelsToSamples(pixels, resolution) {
6110 return Math.floor(pixels * resolution);
6111}
6112
6113function pixelsToSeconds(pixels, resolution, sampleRate) {
6114 return (pixels * resolution) / sampleRate;
6115}
6116
6117function secondsToPixels(seconds, resolution, sampleRate) {
6118 return Math.ceil((seconds * sampleRate) / resolution);
6119}
6120
6121;// CONCATENATED MODULE: ./src/track/loader/Loader.js
6122
6123
6124const STATE_UNINITIALIZED = 0;
6125const STATE_LOADING = 1;
6126const STATE_DECODING = 2;
6127const STATE_FINISHED = 3;
6128
6129/* harmony default export */ const Loader = (class {
6130 constructor(src, audioContext, ee = event_emitter_default()()) {
6131 this.src = src;
6132 this.ac = audioContext;
6133 this.audioRequestState = STATE_UNINITIALIZED;
6134 this.ee = ee;
6135 }
6136
6137 setStateChange(state) {
6138 this.audioRequestState = state;
6139 this.ee.emit("audiorequeststatechange", this.audioRequestState, this.src);
6140 }
6141
6142 fileProgress(e) {
6143 let percentComplete = 0;
6144
6145 if (this.audioRequestState === STATE_UNINITIALIZED) {
6146 this.setStateChange(STATE_LOADING);
6147 }
6148
6149 if (e.lengthComputable) {
6150 percentComplete = (e.loaded / e.total) * 100;
6151 }
6152
6153 this.ee.emit("loadprogress", percentComplete, this.src);
6154 }
6155
6156 fileLoad(e) {
6157 const audioData = e.target.response || e.target.result;
6158
6159 this.setStateChange(STATE_DECODING);
6160
6161 return new Promise((resolve, reject) => {
6162 this.ac.decodeAudioData(
6163 audioData,
6164 (audioBuffer) => {
6165 this.audioBuffer = audioBuffer;
6166 this.setStateChange(STATE_FINISHED);
6167
6168 resolve(audioBuffer);
6169 },
6170 (err) => {
6171 if (err === null) {
6172 // Safari issues with null error
6173 reject(Error("MediaDecodeAudioDataUnknownContentType"));
6174 } else {
6175 reject(err);
6176 }
6177 }
6178 );
6179 });
6180 }
6181});
6182
6183;// CONCATENATED MODULE: ./src/track/loader/BlobLoader.js
6184
6185
6186/* harmony default export */ const BlobLoader = (class extends Loader {
6187 /*
6188 * Loads an audio file via a FileReader
6189 */
6190 load() {
6191 return new Promise((resolve, reject) => {
6192 if (
6193 this.src.type.match(/audio.*/) ||
6194 // added for problems with Firefox mime types + ogg.
6195 this.src.type.match(/video\/ogg/)
6196 ) {
6197 const fr = new FileReader();
6198
6199 fr.readAsArrayBuffer(this.src);
6200
6201 fr.addEventListener("progress", (e) => {
6202 super.fileProgress(e);
6203 });
6204
6205 fr.addEventListener("load", (e) => {
6206 const decoderPromise = super.fileLoad(e);
6207
6208 decoderPromise
6209 .then((audioBuffer) => {
6210 resolve(audioBuffer);
6211 })
6212 .catch(reject);
6213 });
6214
6215 fr.addEventListener("error", reject);
6216 } else {
6217 reject(Error(`Unsupported file type ${this.src.type}`));
6218 }
6219 });
6220 }
6221});
6222
6223;// CONCATENATED MODULE: ./src/track/loader/IdentityLoader.js
6224
6225
6226class IdentityLoader extends Loader {
6227 load() {
6228 return Promise.resolve(this.src);
6229 }
6230}
6231
6232;// CONCATENATED MODULE: ./src/track/loader/XHRLoader.js
6233
6234
6235/* harmony default export */ const XHRLoader = (class extends Loader {
6236 /**
6237 * Loads an audio file via XHR.
6238 */
6239 load() {
6240 return new Promise((resolve, reject) => {
6241 const xhr = new XMLHttpRequest();
6242
6243 xhr.open("GET", this.src, true);
6244 xhr.responseType = "arraybuffer";
6245 xhr.send();
6246
6247 xhr.addEventListener("progress", (e) => {
6248 super.fileProgress(e);
6249 });
6250
6251 xhr.addEventListener("load", (e) => {
6252 const decoderPromise = super.fileLoad(e);
6253
6254 decoderPromise
6255 .then((audioBuffer) => {
6256 resolve(audioBuffer);
6257 })
6258 .catch(reject);
6259 });
6260
6261 xhr.addEventListener("error", () => {
6262 reject(Error(`Track ${this.src} failed to load`));
6263 });
6264 });
6265 }
6266});
6267
6268;// CONCATENATED MODULE: ./src/track/loader/LoaderFactory.js
6269
6270
6271
6272
6273/* harmony default export */ const LoaderFactory = (class {
6274 static createLoader(src, audioContext, ee) {
6275 if (src instanceof Blob) {
6276 return new BlobLoader(src, audioContext, ee);
6277 } else if (src instanceof AudioBuffer) {
6278 return new IdentityLoader(src, audioContext, ee);
6279 } else if (typeof src === "string") {
6280 return new XHRLoader(src, audioContext, ee);
6281 }
6282
6283 throw new Error("Unsupported src type");
6284 }
6285});
6286
6287;// CONCATENATED MODULE: ./src/render/ScrollHook.js
6288
6289
6290/*
6291 * virtual-dom hook for scrolling the track container.
6292 */
6293/* harmony default export */ const ScrollHook = (class {
6294 constructor(playlist) {
6295 this.playlist = playlist;
6296 }
6297
6298 hook(node) {
6299 const playlist = this.playlist;
6300 if (!playlist.isScrolling) {
6301 const el = node;
6302
6303 if (playlist.isAutomaticScroll) {
6304 const rect = node.getBoundingClientRect();
6305 const controlWidth = playlist.controls.show
6306 ? playlist.controls.width
6307 : 0;
6308 const width = pixelsToSeconds(
6309 rect.width - controlWidth,
6310 playlist.samplesPerPixel,
6311 playlist.sampleRate
6312 );
6313
6314 const timePoint = playlist.isPlaying()
6315 ? playlist.playbackSeconds
6316 : playlist.getTimeSelection().start;
6317
6318 if (
6319 timePoint < playlist.scrollLeft ||
6320 timePoint >= playlist.scrollLeft + width
6321 ) {
6322 playlist.scrollLeft = Math.min(timePoint, playlist.duration - width);
6323 }
6324 }
6325
6326 const left = secondsToPixels(
6327 playlist.scrollLeft,
6328 playlist.samplesPerPixel,
6329 playlist.sampleRate
6330 );
6331
6332 el.scrollLeft = left;
6333 }
6334 }
6335});
6336
6337;// CONCATENATED MODULE: ./src/render/TimeScaleHook.js
6338/*
6339 * virtual-dom hook for rendering the time scale canvas.
6340 */
6341/* harmony default export */ const TimeScaleHook = (class {
6342 constructor(tickInfo, offset, samplesPerPixel, duration, colors) {
6343 this.tickInfo = tickInfo;
6344 this.offset = offset;
6345 this.samplesPerPixel = samplesPerPixel;
6346 this.duration = duration;
6347 this.colors = colors;
6348 }
6349
6350 hook(canvas, prop, prev) {
6351 // canvas is up to date
6352 if (
6353 prev !== undefined &&
6354 prev.offset === this.offset &&
6355 prev.duration === this.duration &&
6356 prev.samplesPerPixel === this.samplesPerPixel
6357 ) {
6358 return;
6359 }
6360
6361 const width = canvas.width;
6362 const height = canvas.height;
6363 const ctx = canvas.getContext("2d");
6364
6365 ctx.clearRect(0, 0, width, height);
6366 ctx.fillStyle = this.colors.timeColor;
6367
6368 Object.keys(this.tickInfo).forEach((x) => {
6369 const scaleHeight = this.tickInfo[x];
6370 const scaleY = height - scaleHeight;
6371 ctx.fillRect(x, scaleY, 1, scaleHeight);
6372 });
6373 }
6374});
6375
6376;// CONCATENATED MODULE: ./src/TimeScale.js
6377
6378
6379
6380
6381
6382class TimeScale {
6383 constructor(
6384 duration,
6385 offset,
6386 samplesPerPixel,
6387 sampleRate,
6388 marginLeft = 0,
6389 colors
6390 ) {
6391 this.duration = duration;
6392 this.offset = offset;
6393 this.samplesPerPixel = samplesPerPixel;
6394 this.sampleRate = sampleRate;
6395 this.marginLeft = marginLeft;
6396 this.colors = colors;
6397
6398 this.timeinfo = {
6399 20000: {
6400 marker: 30000,
6401 bigStep: 10000,
6402 smallStep: 5000,
6403 secondStep: 5,
6404 },
6405 12000: {
6406 marker: 15000,
6407 bigStep: 5000,
6408 smallStep: 1000,
6409 secondStep: 1,
6410 },
6411 10000: {
6412 marker: 10000,
6413 bigStep: 5000,
6414 smallStep: 1000,
6415 secondStep: 1,
6416 },
6417 5000: {
6418 marker: 5000,
6419 bigStep: 1000,
6420 smallStep: 500,
6421 secondStep: 1 / 2,
6422 },
6423 2500: {
6424 marker: 2000,
6425 bigStep: 1000,
6426 smallStep: 500,
6427 secondStep: 1 / 2,
6428 },
6429 1500: {
6430 marker: 2000,
6431 bigStep: 1000,
6432 smallStep: 200,
6433 secondStep: 1 / 5,
6434 },
6435 700: {
6436 marker: 1000,
6437 bigStep: 500,
6438 smallStep: 100,
6439 secondStep: 1 / 10,
6440 },
6441 };
6442 }
6443
6444 getScaleInfo(resolution) {
6445 let keys = Object.keys(this.timeinfo).map((item) => parseInt(item, 10));
6446
6447 // make sure keys are numerically sorted.
6448 keys = keys.sort((a, b) => a - b);
6449
6450 for (let i = 0; i < keys.length; i += 1) {
6451 if (resolution <= keys[i]) {
6452 return this.timeinfo[keys[i]];
6453 }
6454 }
6455
6456 return this.timeinfo[keys[0]];
6457 }
6458
6459 /*
6460 Return time in format mm:ss
6461 */
6462 static formatTime(milliseconds) {
6463 const seconds = milliseconds / 1000;
6464 let s = seconds % 60;
6465 const m = (seconds - s) / 60;
6466
6467 if (s < 10) {
6468 s = `0${s}`;
6469 }
6470
6471 return `${m}:${s}`;
6472 }
6473
6474 render() {
6475 const widthX = secondsToPixels(
6476 this.duration,
6477 this.samplesPerPixel,
6478 this.sampleRate
6479 );
6480 const pixPerSec = this.sampleRate / this.samplesPerPixel;
6481 const pixOffset = secondsToPixels(
6482 this.offset,
6483 this.samplesPerPixel,
6484 this.sampleRate
6485 );
6486 const scaleInfo = this.getScaleInfo(this.samplesPerPixel);
6487 const canvasInfo = {};
6488 const timeMarkers = [];
6489 const end = widthX + pixOffset;
6490 let counter = 0;
6491
6492 for (let i = 0; i < end; i += pixPerSec * scaleInfo.secondStep) {
6493 const pixIndex = Math.floor(i);
6494 const pix = pixIndex - pixOffset;
6495
6496 if (pixIndex >= pixOffset) {
6497 // put a timestamp every 30 seconds.
6498 if (scaleInfo.marker && counter % scaleInfo.marker === 0) {
6499 timeMarkers.push(
6500 h_default()(
6501 "div.time",
6502 {
6503 attributes: {
6504 style: `position: absolute; left: ${pix}px;`,
6505 },
6506 },
6507 [TimeScale.formatTime(counter)]
6508 )
6509 );
6510
6511 canvasInfo[pix] = 10;
6512 } else if (scaleInfo.bigStep && counter % scaleInfo.bigStep === 0) {
6513 canvasInfo[pix] = 5;
6514 } else if (scaleInfo.smallStep && counter % scaleInfo.smallStep === 0) {
6515 canvasInfo[pix] = 2;
6516 }
6517 }
6518
6519 counter += 1000 * scaleInfo.secondStep;
6520 }
6521
6522 return h_default()(
6523 "div.playlist-time-scale",
6524 {
6525 attributes: {
6526 style: `position: relative; left: 0; right: 0; margin-left: ${this.marginLeft}px;`,
6527 },
6528 },
6529 [
6530 timeMarkers,
6531 h_default()("canvas", {
6532 attributes: {
6533 width: widthX,
6534 height: 30,
6535 style: "position: absolute; left: 0; right: 0; top: 0; bottom: 0;",
6536 },
6537 hook: new TimeScaleHook(
6538 canvasInfo,
6539 this.offset,
6540 this.samplesPerPixel,
6541 this.duration,
6542 this.colors
6543 ),
6544 }),
6545 ]
6546 );
6547 }
6548}
6549
6550/* harmony default export */ const src_TimeScale = (TimeScale);
6551
6552// EXTERNAL MODULE: ./node_modules/lodash.assign/index.js
6553var lodash_assign = __webpack_require__(1730);
6554var lodash_assign_default = /*#__PURE__*/__webpack_require__.n(lodash_assign);
6555// EXTERNAL MODULE: ./node_modules/lodash.forown/index.js
6556var lodash_forown = __webpack_require__(3520);
6557var lodash_forown_default = /*#__PURE__*/__webpack_require__.n(lodash_forown);
6558;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
6559// Unique ID creation requires a high quality random # generator. In the browser we therefore
6560// require the crypto API and do not support built-in fallback to lower quality random number
6561// generators (like Math.random()).
6562var getRandomValues;
6563var rnds8 = new Uint8Array(16);
6564function rng() {
6565 // lazy load so that environments that need to polyfill have a chance to do so
6566 if (!getRandomValues) {
6567 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
6568 // find the complete implementation of crypto (msCrypto) on IE11.
6569 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
6570
6571 if (!getRandomValues) {
6572 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
6573 }
6574 }
6575
6576 return getRandomValues(rnds8);
6577}
6578;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js
6579/* harmony default export */ const regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i);
6580;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js
6581
6582
6583function validate(uuid) {
6584 return typeof uuid === 'string' && regex.test(uuid);
6585}
6586
6587/* harmony default export */ const esm_browser_validate = (validate);
6588;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
6589
6590/**
6591 * Convert array of 16 byte values to UUID string format of the form:
6592 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
6593 */
6594
6595var byteToHex = [];
6596
6597for (var i = 0; i < 256; ++i) {
6598 byteToHex.push((i + 0x100).toString(16).substr(1));
6599}
6600
6601function stringify(arr) {
6602 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
6603 // Note: Be careful editing this code! It's been tuned for performance
6604 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
6605 var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
6606 // of the following:
6607 // - One or more input array values don't map to a hex octet (leading to
6608 // "undefined" in the uuid)
6609 // - Invalid input values for the RFC `version` or `variant` fields
6610
6611 if (!esm_browser_validate(uuid)) {
6612 throw TypeError('Stringified UUID is invalid');
6613 }
6614
6615 return uuid;
6616}
6617
6618/* harmony default export */ const esm_browser_stringify = (stringify);
6619;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
6620
6621
6622
6623function v4(options, buf, offset) {
6624 options = options || {};
6625 var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
6626
6627 rnds[6] = rnds[6] & 0x0f | 0x40;
6628 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
6629
6630 if (buf) {
6631 offset = offset || 0;
6632
6633 for (var i = 0; i < 16; ++i) {
6634 buf[offset + i] = rnds[i];
6635 }
6636
6637 return buf;
6638 }
6639
6640 return esm_browser_stringify(rnds);
6641}
6642
6643/* harmony default export */ const esm_browser_v4 = (v4);
6644// EXTERNAL MODULE: ./node_modules/webaudio-peaks/index.js
6645var webaudio_peaks = __webpack_require__(4991);
6646var webaudio_peaks_default = /*#__PURE__*/__webpack_require__.n(webaudio_peaks);
6647// EXTERNAL MODULE: ./node_modules/fade-maker/index.js
6648var fade_maker = __webpack_require__(1114);
6649;// CONCATENATED MODULE: ./src/track/states/CursorState.js
6650
6651
6652/* harmony default export */ const CursorState = (class {
6653 constructor(track) {
6654 this.track = track;
6655 }
6656
6657 setup(samplesPerPixel, sampleRate) {
6658 this.samplesPerPixel = samplesPerPixel;
6659 this.sampleRate = sampleRate;
6660 }
6661
6662 click(e) {
6663 e.preventDefault();
6664
6665 const startX = e.offsetX;
6666 const startTime = pixelsToSeconds(
6667 startX,
6668 this.samplesPerPixel,
6669 this.sampleRate
6670 );
6671
6672 this.track.ee.emit("select", startTime, startTime, this.track);
6673 }
6674
6675 static getClass() {
6676 return ".state-cursor";
6677 }
6678
6679 static getEvents() {
6680 return ["click"];
6681 }
6682});
6683
6684;// CONCATENATED MODULE: ./src/track/states/SelectState.js
6685
6686
6687/* harmony default export */ const SelectState = (class {
6688 constructor(track) {
6689 this.track = track;
6690 this.active = false;
6691 }
6692
6693 setup(samplesPerPixel, sampleRate) {
6694 this.samplesPerPixel = samplesPerPixel;
6695 this.sampleRate = sampleRate;
6696 }
6697
6698 emitSelection(x) {
6699 const minX = Math.min(x, this.startX);
6700 const maxX = Math.max(x, this.startX);
6701 const startTime = pixelsToSeconds(
6702 minX,
6703 this.samplesPerPixel,
6704 this.sampleRate
6705 );
6706 const endTime = pixelsToSeconds(
6707 maxX,
6708 this.samplesPerPixel,
6709 this.sampleRate
6710 );
6711
6712 this.track.ee.emit("select", startTime, endTime, this.track);
6713 }
6714
6715 complete(x) {
6716 this.emitSelection(x);
6717 this.active = false;
6718 }
6719
6720 mousedown(e) {
6721 e.preventDefault();
6722 this.active = true;
6723
6724 this.startX = e.offsetX;
6725 const startTime = pixelsToSeconds(
6726 this.startX,
6727 this.samplesPerPixel,
6728 this.sampleRate
6729 );
6730
6731 this.track.ee.emit("select", startTime, startTime, this.track);
6732 }
6733
6734 mousemove(e) {
6735 if (this.active) {
6736 e.preventDefault();
6737 this.emitSelection(e.offsetX);
6738 }
6739 }
6740
6741 mouseup(e) {
6742 if (this.active) {
6743 e.preventDefault();
6744 this.complete(e.offsetX);
6745 }
6746 }
6747
6748 mouseleave(e) {
6749 if (this.active) {
6750 e.preventDefault();
6751 this.complete(e.offsetX);
6752 }
6753 }
6754
6755 static getClass() {
6756 return ".state-select";
6757 }
6758
6759 static getEvents() {
6760 return ["mousedown", "mousemove", "mouseup", "mouseleave"];
6761 }
6762});
6763
6764;// CONCATENATED MODULE: ./src/track/states/ShiftState.js
6765
6766
6767/* harmony default export */ const ShiftState = (class {
6768 constructor(track) {
6769 this.track = track;
6770 this.active = false;
6771 }
6772
6773 setup(samplesPerPixel, sampleRate) {
6774 this.samplesPerPixel = samplesPerPixel;
6775 this.sampleRate = sampleRate;
6776 }
6777
6778 emitShift(x) {
6779 const deltaX = x - this.prevX;
6780 const deltaTime = pixelsToSeconds(
6781 deltaX,
6782 this.samplesPerPixel,
6783 this.sampleRate
6784 );
6785 this.prevX = x;
6786 this.track.ee.emit("shift", deltaTime, this.track);
6787 }
6788
6789 complete(x) {
6790 this.emitShift(x);
6791 this.active = false;
6792 }
6793
6794 mousedown(e) {
6795 e.preventDefault();
6796
6797 this.active = true;
6798 this.el = e.target;
6799 this.prevX = e.offsetX;
6800 }
6801
6802 mousemove(e) {
6803 if (this.active) {
6804 e.preventDefault();
6805 this.emitShift(e.offsetX);
6806 }
6807 }
6808
6809 mouseup(e) {
6810 if (this.active) {
6811 e.preventDefault();
6812 this.complete(e.offsetX);
6813 }
6814 }
6815
6816 mouseleave(e) {
6817 if (this.active) {
6818 e.preventDefault();
6819 this.complete(e.offsetX);
6820 }
6821 }
6822
6823 static getClass() {
6824 return ".state-shift";
6825 }
6826
6827 static getEvents() {
6828 return ["mousedown", "mousemove", "mouseup", "mouseleave"];
6829 }
6830});
6831
6832;// CONCATENATED MODULE: ./src/track/states/FadeInState.js
6833
6834
6835/* harmony default export */ const FadeInState = (class {
6836 constructor(track) {
6837 this.track = track;
6838 }
6839
6840 setup(samplesPerPixel, sampleRate) {
6841 this.samplesPerPixel = samplesPerPixel;
6842 this.sampleRate = sampleRate;
6843 }
6844
6845 click(e) {
6846 const startX = e.offsetX;
6847 const time = pixelsToSeconds(startX, this.samplesPerPixel, this.sampleRate);
6848
6849 if (time > this.track.getStartTime() && time < this.track.getEndTime()) {
6850 this.track.ee.emit(
6851 "fadein",
6852 time - this.track.getStartTime(),
6853 this.track
6854 );
6855 }
6856 }
6857
6858 static getClass() {
6859 return ".state-fadein";
6860 }
6861
6862 static getEvents() {
6863 return ["click"];
6864 }
6865});
6866
6867;// CONCATENATED MODULE: ./src/track/states/FadeOutState.js
6868
6869
6870/* harmony default export */ const FadeOutState = (class {
6871 constructor(track) {
6872 this.track = track;
6873 }
6874
6875 setup(samplesPerPixel, sampleRate) {
6876 this.samplesPerPixel = samplesPerPixel;
6877 this.sampleRate = sampleRate;
6878 }
6879
6880 click(e) {
6881 const startX = e.offsetX;
6882 const time = pixelsToSeconds(startX, this.samplesPerPixel, this.sampleRate);
6883
6884 if (time > this.track.getStartTime() && time < this.track.getEndTime()) {
6885 this.track.ee.emit("fadeout", this.track.getEndTime() - time, this.track);
6886 }
6887 }
6888
6889 static getClass() {
6890 return ".state-fadeout";
6891 }
6892
6893 static getEvents() {
6894 return ["click"];
6895 }
6896});
6897
6898;// CONCATENATED MODULE: ./src/track/states.js
6899
6900
6901
6902
6903
6904
6905/* harmony default export */ const states = ({
6906 cursor: CursorState,
6907 select: SelectState,
6908 shift: ShiftState,
6909 fadein: FadeInState,
6910 fadeout: FadeOutState,
6911});
6912
6913;// CONCATENATED MODULE: ./src/render/CanvasHook.js
6914/*
6915 * virtual-dom hook for drawing to the canvas element.
6916 */
6917class CanvasHook {
6918 constructor(peaks, offset, bits, color, scale, height, barWidth, barGap) {
6919 this.peaks = peaks;
6920 // http://stackoverflow.com/questions/6081483/maximum-size-of-a-canvas-element
6921 this.offset = offset;
6922 this.color = color;
6923 this.bits = bits;
6924 this.scale = scale;
6925 this.height = height;
6926 this.barWidth = barWidth;
6927 this.barGap = barGap;
6928 }
6929
6930 static drawFrame(cc, h2, x, minPeak, maxPeak, width, gap) {
6931 const min = Math.abs(minPeak * h2);
6932 const max = Math.abs(maxPeak * h2);
6933
6934 // draw max
6935 cc.fillRect(x, 0, width, h2 - max);
6936 // draw min
6937 cc.fillRect(x, h2 + min, width, h2 - min);
6938 // draw gap
6939 if (gap !== 0) {
6940 cc.fillRect(x + width, 0, gap, h2 * 2);
6941 }
6942 }
6943
6944 hook(canvas, prop, prev) {
6945 // canvas is up to date
6946 if (
6947 prev !== undefined &&
6948 prev.peaks === this.peaks &&
6949 prev.scale === this.scale &&
6950 prev.height === this.height
6951 ) {
6952 return;
6953 }
6954
6955 const scale = this.scale;
6956 const len = canvas.width / scale;
6957 const cc = canvas.getContext("2d");
6958 const h2 = canvas.height / scale / 2;
6959 const maxValue = 2 ** (this.bits - 1);
6960 const width = this.barWidth;
6961 const gap = this.barGap;
6962 const barStart = width + gap;
6963
6964 cc.clearRect(0, 0, canvas.width, canvas.height);
6965
6966 cc.save();
6967 cc.fillStyle = this.color;
6968 cc.scale(scale, scale);
6969
6970 for (let pixel = 0; pixel < len; pixel += barStart) {
6971 const minPeak = this.peaks[(pixel + this.offset) * 2] / maxValue;
6972 const maxPeak = this.peaks[(pixel + this.offset) * 2 + 1] / maxValue;
6973 CanvasHook.drawFrame(cc, h2, pixel, minPeak, maxPeak, width, gap);
6974 }
6975
6976 cc.restore();
6977 }
6978}
6979
6980/* harmony default export */ const render_CanvasHook = (CanvasHook);
6981
6982// EXTERNAL MODULE: ./node_modules/fade-curves/index.js
6983var fade_curves = __webpack_require__(6226);
6984;// CONCATENATED MODULE: ./src/render/FadeCanvasHook.js
6985
6986
6987
6988/*
6989 * virtual-dom hook for drawing the fade curve to the canvas element.
6990 */
6991class FadeCanvasHook {
6992 constructor(type, shape, duration, samplesPerPixel) {
6993 this.type = type;
6994 this.shape = shape;
6995 this.duration = duration;
6996 this.samplesPerPixel = samplesPerPixel;
6997 }
6998
6999 static createCurve(shape, type, width) {
7000 let reflection;
7001 let curve;
7002
7003 switch (type) {
7004 case fade_maker/* FADEIN */.Y1: {
7005 reflection = 1;
7006 break;
7007 }
7008 case fade_maker/* FADEOUT */.h7: {
7009 reflection = -1;
7010 break;
7011 }
7012 default: {
7013 throw new Error("Unsupported fade type.");
7014 }
7015 }
7016
7017 switch (shape) {
7018 case fade_maker/* SCURVE */._h: {
7019 curve = (0,fade_curves.sCurve)(width, reflection);
7020 break;
7021 }
7022 case fade_maker/* LINEAR */.t$: {
7023 curve = (0,fade_curves.linear)(width, reflection);
7024 break;
7025 }
7026 case fade_maker/* EXPONENTIAL */.Jl: {
7027 curve = (0,fade_curves.exponential)(width, reflection);
7028 break;
7029 }
7030 case fade_maker/* LOGARITHMIC */.Hp: {
7031 curve = (0,fade_curves.logarithmic)(width, 10, reflection);
7032 break;
7033 }
7034 default: {
7035 throw new Error("Unsupported fade shape");
7036 }
7037 }
7038
7039 return curve;
7040 }
7041
7042 hook(canvas, prop, prev) {
7043 // node is up to date.
7044 if (
7045 prev !== undefined &&
7046 prev.shape === this.shape &&
7047 prev.type === this.type &&
7048 prev.duration === this.duration &&
7049 prev.samplesPerPixel === this.samplesPerPixel
7050 ) {
7051 return;
7052 }
7053
7054 const ctx = canvas.getContext("2d");
7055 const width = canvas.width;
7056 const height = canvas.height;
7057 const curve = FadeCanvasHook.createCurve(this.shape, this.type, width);
7058 const len = curve.length;
7059 let y = height - curve[0] * height;
7060
7061 ctx.clearRect(0, 0, canvas.width, canvas.height);
7062 ctx.save();
7063
7064 ctx.strokeStyle = "black";
7065 ctx.beginPath();
7066 ctx.moveTo(0, y);
7067
7068 for (let i = 1; i < len; i += 1) {
7069 y = height - curve[i] * height;
7070 ctx.lineTo(i, y);
7071 }
7072 ctx.stroke();
7073 ctx.restore();
7074 }
7075}
7076
7077/* harmony default export */ const render_FadeCanvasHook = (FadeCanvasHook);
7078
7079;// CONCATENATED MODULE: ./src/render/VolumeSliderHook.js
7080/* eslint-disable no-param-reassign */
7081/*
7082 * virtual-dom hook for setting the volume input programmatically.
7083 */
7084/* harmony default export */ const VolumeSliderHook = (class {
7085 constructor(gain) {
7086 this.gain = gain;
7087 }
7088
7089 hook(volumeInput) {
7090 volumeInput.value = this.gain * 100;
7091 volumeInput.title = `${Math.round(this.gain * 100)}% volume`;
7092 }
7093});
7094
7095;// CONCATENATED MODULE: ./src/render/StereoPanSliderHook.js
7096/* eslint-disable no-param-reassign */
7097/*
7098 * virtual-dom hook for setting the stereoPan input programmatically.
7099 */
7100/* harmony default export */ const StereoPanSliderHook = (class {
7101 constructor(stereoPan) {
7102 this.stereoPan = stereoPan;
7103 }
7104
7105 hook(stereoPanInput) {
7106 stereoPanInput.value = this.stereoPan * 100;
7107
7108 let panOrientation;
7109 if (this.stereoPan === 0) {
7110 panOrientation = "Center";
7111 } else if (this.stereoPan < 0) {
7112 panOrientation = "Left";
7113 } else {
7114 panOrientation = "Right";
7115 }
7116 const percentage = `${Math.abs(Math.round(this.stereoPan * 100))}% `;
7117 stereoPanInput.title = `Pan: ${
7118 this.stereoPan !== 0 ? percentage : ""
7119 }${panOrientation}`;
7120 }
7121});
7122
7123;// CONCATENATED MODULE: ./src/Track.js
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141const MAX_CANVAS_WIDTH = 1000;
7142
7143/* harmony default export */ const Track = (class {
7144 constructor() {
7145 this.name = "Untitled";
7146 this.customClass = undefined;
7147 this.waveOutlineColor = undefined;
7148 this.gain = 1;
7149 this.fades = {};
7150 this.peakData = {
7151 type: "WebAudio",
7152 mono: false,
7153 };
7154
7155 this.cueIn = 0;
7156 this.cueOut = 0;
7157 this.duration = 0;
7158 this.startTime = 0;
7159 this.endTime = 0;
7160 this.stereoPan = 0;
7161 }
7162
7163 setEventEmitter(ee) {
7164 this.ee = ee;
7165 }
7166
7167 setName(name) {
7168 this.name = name;
7169 }
7170
7171 setCustomClass(className) {
7172 this.customClass = className;
7173 }
7174
7175 setWaveOutlineColor(color) {
7176 this.waveOutlineColor = color;
7177 }
7178
7179 setCues(cueIn, cueOut) {
7180 if (cueOut < cueIn) {
7181 throw new Error("cue out cannot be less than cue in");
7182 }
7183
7184 this.cueIn = cueIn;
7185 this.cueOut = cueOut;
7186 this.duration = this.cueOut - this.cueIn;
7187 this.endTime = this.startTime + this.duration;
7188 }
7189
7190 /*
7191 * start, end in seconds relative to the entire playlist.
7192 */
7193 trim(start, end) {
7194 const trackStart = this.getStartTime();
7195 const trackEnd = this.getEndTime();
7196 const offset = this.cueIn - trackStart;
7197
7198 if (
7199 (trackStart <= start && trackEnd >= start) ||
7200 (trackStart <= end && trackEnd >= end)
7201 ) {
7202 const cueIn = start < trackStart ? trackStart : start;
7203 const cueOut = end > trackEnd ? trackEnd : end;
7204
7205 this.setCues(cueIn + offset, cueOut + offset);
7206 if (start > trackStart) {
7207 this.setStartTime(start);
7208 }
7209 }
7210 }
7211
7212 setStartTime(start) {
7213 this.startTime = start;
7214 this.endTime = start + this.duration;
7215 }
7216
7217 setPlayout(playout) {
7218 this.playout = playout;
7219 }
7220
7221 setOfflinePlayout(playout) {
7222 this.offlinePlayout = playout;
7223 }
7224
7225 setEnabledStates(enabledStates = {}) {
7226 const defaultStatesEnabled = {
7227 cursor: true,
7228 fadein: true,
7229 fadeout: true,
7230 select: true,
7231 shift: true,
7232 };
7233
7234 this.enabledStates = lodash_assign_default()({}, defaultStatesEnabled, enabledStates);
7235 }
7236
7237 setFadeIn(duration, shape = "logarithmic") {
7238 if (duration > this.duration) {
7239 throw new Error("Invalid Fade In");
7240 }
7241
7242 const fade = {
7243 shape,
7244 start: 0,
7245 end: duration,
7246 };
7247
7248 if (this.fadeIn) {
7249 this.removeFade(this.fadeIn);
7250 this.fadeIn = undefined;
7251 }
7252
7253 this.fadeIn = this.saveFade(fade_maker/* FADEIN */.Y1, fade.shape, fade.start, fade.end);
7254 }
7255
7256 setFadeOut(duration, shape = "logarithmic") {
7257 if (duration > this.duration) {
7258 throw new Error("Invalid Fade Out");
7259 }
7260
7261 const fade = {
7262 shape,
7263 start: this.duration - duration,
7264 end: this.duration,
7265 };
7266
7267 if (this.fadeOut) {
7268 this.removeFade(this.fadeOut);
7269 this.fadeOut = undefined;
7270 }
7271
7272 this.fadeOut = this.saveFade(fade_maker/* FADEOUT */.h7, fade.shape, fade.start, fade.end);
7273 }
7274
7275 saveFade(type, shape, start, end) {
7276 const id = esm_browser_v4();
7277
7278 this.fades[id] = {
7279 type,
7280 shape,
7281 start,
7282 end,
7283 };
7284
7285 return id;
7286 }
7287
7288 removeFade(id) {
7289 delete this.fades[id];
7290 }
7291
7292 setBuffer(buffer) {
7293 this.buffer = buffer;
7294 }
7295
7296 setPeakData(data) {
7297 this.peakData = data;
7298 }
7299
7300 calculatePeaks(samplesPerPixel, sampleRate) {
7301 const cueIn = secondsToSamples(this.cueIn, sampleRate);
7302 const cueOut = secondsToSamples(this.cueOut, sampleRate);
7303
7304 this.setPeaks(
7305 webaudio_peaks_default()(
7306 this.buffer,
7307 samplesPerPixel,
7308 this.peakData.mono,
7309 cueIn,
7310 cueOut
7311 )
7312 );
7313 }
7314
7315 setPeaks(peaks) {
7316 this.peaks = peaks;
7317 }
7318
7319 setState(state) {
7320 this.state = state;
7321
7322 if (this.state && this.enabledStates[this.state]) {
7323 const StateClass = states[this.state];
7324 this.stateObj = new StateClass(this);
7325 } else {
7326 this.stateObj = undefined;
7327 }
7328 }
7329
7330 getStartTime() {
7331 return this.startTime;
7332 }
7333
7334 getEndTime() {
7335 return this.endTime;
7336 }
7337
7338 getDuration() {
7339 return this.duration;
7340 }
7341
7342 isPlaying() {
7343 return this.playout.isPlaying();
7344 }
7345
7346 setShouldPlay(bool) {
7347 this.playout.setShouldPlay(bool);
7348 }
7349
7350 setGainLevel(level) {
7351 this.gain = level;
7352 this.playout.setVolumeGainLevel(level);
7353 }
7354
7355 setMasterGainLevel(level) {
7356 this.playout.setMasterGainLevel(level);
7357 }
7358
7359 setStereoPanValue(value) {
7360 this.stereoPan = value;
7361 this.playout.setStereoPanValue(value);
7362 }
7363
7364 /*
7365 startTime, endTime in seconds (float).
7366 segment is for a highlighted section in the UI.
7367
7368 returns a Promise that will resolve when the AudioBufferSource
7369 is either stopped or plays out naturally.
7370 */
7371 schedulePlay(now, startTime, endTime, config) {
7372 let start;
7373 let duration;
7374 let when = now;
7375 let segment = endTime ? endTime - startTime : undefined;
7376
7377 const defaultOptions = {
7378 shouldPlay: true,
7379 masterGain: 1,
7380 isOffline: false,
7381 };
7382
7383 const options = lodash_assign_default()({}, defaultOptions, config);
7384 const playoutSystem = options.isOffline
7385 ? this.offlinePlayout
7386 : this.playout;
7387
7388 // 1) track has no content to play.
7389 // 2) track does not play in this selection.
7390 if (
7391 this.endTime <= startTime ||
7392 (segment && startTime + segment < this.startTime)
7393 ) {
7394 // return a resolved promise since this track is technically "stopped".
7395 return Promise.resolve();
7396 }
7397
7398 // track should have something to play if it gets here.
7399
7400 // the track starts in the future or on the cursor position
7401 if (this.startTime >= startTime) {
7402 start = 0;
7403 // schedule additional delay for this audio node.
7404 when += this.startTime - startTime;
7405
7406 if (endTime) {
7407 segment -= this.startTime - startTime;
7408 duration = Math.min(segment, this.duration);
7409 } else {
7410 duration = this.duration;
7411 }
7412 } else {
7413 start = startTime - this.startTime;
7414
7415 if (endTime) {
7416 duration = Math.min(segment, this.duration - start);
7417 } else {
7418 duration = this.duration - start;
7419 }
7420 }
7421
7422 start += this.cueIn;
7423 const relPos = startTime - this.startTime;
7424 const sourcePromise = playoutSystem.setUpSource();
7425
7426 // param relPos: cursor position in seconds relative to this track.
7427 // can be negative if the cursor is placed before the start of this track etc.
7428 lodash_forown_default()(this.fades, (fade) => {
7429 let fadeStart;
7430 let fadeDuration;
7431
7432 // only apply fade if it's ahead of the cursor.
7433 if (relPos < fade.end) {
7434 if (relPos <= fade.start) {
7435 fadeStart = now + (fade.start - relPos);
7436 fadeDuration = fade.end - fade.start;
7437 } else if (relPos > fade.start && relPos < fade.end) {
7438 fadeStart = now - (relPos - fade.start);
7439 fadeDuration = fade.end - fade.start;
7440 }
7441
7442 switch (fade.type) {
7443 case fade_maker/* FADEIN */.Y1: {
7444 playoutSystem.applyFadeIn(fadeStart, fadeDuration, fade.shape);
7445 break;
7446 }
7447 case fade_maker/* FADEOUT */.h7: {
7448 playoutSystem.applyFadeOut(fadeStart, fadeDuration, fade.shape);
7449 break;
7450 }
7451 default: {
7452 throw new Error("Invalid fade type saved on track.");
7453 }
7454 }
7455 }
7456 });
7457
7458 playoutSystem.setVolumeGainLevel(this.gain);
7459 playoutSystem.setShouldPlay(options.shouldPlay);
7460 playoutSystem.setMasterGainLevel(options.masterGain);
7461 playoutSystem.setStereoPanValue(this.stereoPan);
7462 playoutSystem.play(when, start, duration);
7463
7464 return sourcePromise;
7465 }
7466
7467 scheduleStop(when = 0) {
7468 this.playout.stop(when);
7469 }
7470
7471 renderOverlay(data) {
7472 const channelPixels = secondsToPixels(
7473 data.playlistLength,
7474 data.resolution,
7475 data.sampleRate
7476 );
7477
7478 const config = {
7479 attributes: {
7480 style: `position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: ${channelPixels}px; z-index: 9;`,
7481 },
7482 };
7483
7484 let overlayClass = "";
7485
7486 if (this.stateObj) {
7487 this.stateObj.setup(data.resolution, data.sampleRate);
7488 const StateClass = states[this.state];
7489 const events = StateClass.getEvents();
7490
7491 events.forEach((event) => {
7492 config[`on${event}`] = this.stateObj[event].bind(this.stateObj);
7493 });
7494
7495 overlayClass = StateClass.getClass();
7496 }
7497 // use this overlay for track event cursor position calculations.
7498 return h_default()(`div.playlist-overlay${overlayClass}`, config);
7499 }
7500
7501 renderControls(data) {
7502 const muteClass = data.muted ? ".active" : "";
7503 const soloClass = data.soloed ? ".active" : "";
7504 const isCollapsed = data.collapsed;
7505 const numChan = this.peaks.data.length;
7506 const widgets = data.controls.widgets;
7507
7508 const removeTrack = h_default()(
7509 "button.btn.btn-danger.btn-xs.track-remove",
7510 {
7511 attributes: {
7512 type: "button",
7513 title: "Remove track",
7514 },
7515 onclick: () => {
7516 this.ee.emit("removeTrack", this);
7517 },
7518 },
7519 [h_default()("i.fas.fa-times")]
7520 );
7521
7522 const trackName = h_default()("span", [this.name]);
7523
7524 const collapseTrack = h_default()(
7525 "button.btn.btn-info.btn-xs.track-collapse",
7526 {
7527 attributes: {
7528 type: "button",
7529 title: isCollapsed ? "Expand track" : "Collapse track",
7530 },
7531 onclick: () => {
7532 this.ee.emit("changeTrackView", this, {
7533 collapsed: !isCollapsed,
7534 });
7535 },
7536 },
7537 [h_default()(`i.fas.${isCollapsed ? "fa-caret-down" : "fa-caret-up"}`)]
7538 );
7539
7540 const headerChildren = [];
7541
7542 if (widgets.remove) {
7543 headerChildren.push(removeTrack);
7544 }
7545 headerChildren.push(trackName);
7546 if (widgets.collapse) {
7547 headerChildren.push(collapseTrack);
7548 }
7549
7550 const controls = [h_default()("div.track-header", headerChildren)];
7551
7552 if (!isCollapsed) {
7553 if (widgets.muteOrSolo) {
7554 controls.push(
7555 h_default()("div.btn-group", [
7556 h_default()(
7557 `button.btn.btn-outline-dark.btn-xs.btn-mute${muteClass}`,
7558 {
7559 attributes: {
7560 type: "button",
7561 },
7562 onclick: () => {
7563 this.ee.emit("mute", this);
7564 },
7565 },
7566 ["Mute"]
7567 ),
7568 h_default()(
7569 `button.btn.btn-outline-dark.btn-xs.btn-solo${soloClass}`,
7570 {
7571 onclick: () => {
7572 this.ee.emit("solo", this);
7573 },
7574 },
7575 ["Solo"]
7576 ),
7577 ])
7578 );
7579 }
7580
7581 if (widgets.volume) {
7582 controls.push(
7583 h_default()("label.volume", [
7584 h_default()("input.volume-slider", {
7585 attributes: {
7586 "aria-label": "Track volume control",
7587 type: "range",
7588 min: 0,
7589 max: 100,
7590 value: 100,
7591 },
7592 hook: new VolumeSliderHook(this.gain),
7593 oninput: (e) => {
7594 this.ee.emit("volumechange", e.target.value, this);
7595 },
7596 }),
7597 ])
7598 );
7599 }
7600
7601 if (widgets.stereoPan) {
7602 controls.push(
7603 h_default()("label.stereopan", [
7604 h_default()("input.stereopan-slider", {
7605 attributes: {
7606 "aria-label": "Track stereo pan control",
7607 type: "range",
7608 min: -100,
7609 max: 100,
7610 value: 100,
7611 },
7612 hook: new StereoPanSliderHook(this.stereoPan),
7613 oninput: (e) => {
7614 this.ee.emit("stereopan", e.target.value / 100, this);
7615 },
7616 }),
7617 ])
7618 );
7619 }
7620 }
7621
7622 return h_default()(
7623 "div.controls",
7624 {
7625 attributes: {
7626 style: `height: ${numChan * data.height}px; width: ${
7627 data.controls.width
7628 }px; position: absolute; left: 0; z-index: 10;`,
7629 },
7630 },
7631 controls
7632 );
7633 }
7634
7635 render(data) {
7636 const width = this.peaks.length;
7637 const playbackX = secondsToPixels(
7638 data.playbackSeconds,
7639 data.resolution,
7640 data.sampleRate
7641 );
7642 const startX = secondsToPixels(
7643 this.startTime,
7644 data.resolution,
7645 data.sampleRate
7646 );
7647 const endX = secondsToPixels(
7648 this.endTime,
7649 data.resolution,
7650 data.sampleRate
7651 );
7652 let progressWidth = 0;
7653 const numChan = this.peaks.data.length;
7654 const scale = Math.floor(window.devicePixelRatio);
7655
7656 if (playbackX > 0 && playbackX > startX) {
7657 if (playbackX < endX) {
7658 progressWidth = playbackX - startX;
7659 } else {
7660 progressWidth = width;
7661 }
7662 }
7663
7664 const waveformChildren = [
7665 h_default()("div.cursor", {
7666 attributes: {
7667 style: `position: absolute; width: 1px; margin: 0; padding: 0; top: 0; left: ${playbackX}px; bottom: 0; z-index: 5;`,
7668 },
7669 }),
7670 ];
7671
7672 const channels = Object.keys(this.peaks.data).map((channelNum) => {
7673 const channelChildren = [
7674 h_default()("div.channel-progress", {
7675 attributes: {
7676 style: `position: absolute; width: ${progressWidth}px; height: ${data.height}px; z-index: 2;`,
7677 },
7678 }),
7679 ];
7680 let offset = 0;
7681 let totalWidth = width;
7682 const peaks = this.peaks.data[channelNum];
7683
7684 while (totalWidth > 0) {
7685 const currentWidth = Math.min(totalWidth, MAX_CANVAS_WIDTH);
7686 const canvasColor = this.waveOutlineColor
7687 ? this.waveOutlineColor
7688 : data.colors.waveOutlineColor;
7689
7690 channelChildren.push(
7691 h_default()("canvas", {
7692 attributes: {
7693 width: currentWidth * scale,
7694 height: data.height * scale,
7695 style: `float: left; position: relative; margin: 0; padding: 0; z-index: 3; width: ${currentWidth}px; height: ${data.height}px;`,
7696 },
7697 hook: new render_CanvasHook(
7698 peaks,
7699 offset,
7700 this.peaks.bits,
7701 canvasColor,
7702 scale,
7703 data.height,
7704 data.barWidth,
7705 data.barGap
7706 ),
7707 })
7708 );
7709
7710 totalWidth -= currentWidth;
7711 offset += MAX_CANVAS_WIDTH;
7712 }
7713
7714 // if there are fades, display them.
7715 if (this.fadeIn) {
7716 const fadeIn = this.fades[this.fadeIn];
7717 const fadeWidth = secondsToPixels(
7718 fadeIn.end - fadeIn.start,
7719 data.resolution,
7720 data.sampleRate
7721 );
7722
7723 channelChildren.push(
7724 h_default()(
7725 "div.wp-fade.wp-fadein",
7726 {
7727 attributes: {
7728 style: `position: absolute; height: ${data.height}px; width: ${fadeWidth}px; top: 0; left: 0; z-index: 4;`,
7729 },
7730 },
7731 [
7732 h_default()("canvas", {
7733 attributes: {
7734 width: fadeWidth,
7735 height: data.height,
7736 },
7737 hook: new render_FadeCanvasHook(
7738 fadeIn.type,
7739 fadeIn.shape,
7740 fadeIn.end - fadeIn.start,
7741 data.resolution
7742 ),
7743 }),
7744 ]
7745 )
7746 );
7747 }
7748
7749 if (this.fadeOut) {
7750 const fadeOut = this.fades[this.fadeOut];
7751 const fadeWidth = secondsToPixels(
7752 fadeOut.end - fadeOut.start,
7753 data.resolution,
7754 data.sampleRate
7755 );
7756
7757 channelChildren.push(
7758 h_default()(
7759 "div.wp-fade.wp-fadeout",
7760 {
7761 attributes: {
7762 style: `position: absolute; height: ${data.height}px; width: ${fadeWidth}px; top: 0; right: 0; z-index: 4;`,
7763 },
7764 },
7765 [
7766 h_default()("canvas", {
7767 attributes: {
7768 width: fadeWidth,
7769 height: data.height,
7770 },
7771 hook: new render_FadeCanvasHook(
7772 fadeOut.type,
7773 fadeOut.shape,
7774 fadeOut.end - fadeOut.start,
7775 data.resolution
7776 ),
7777 }),
7778 ]
7779 )
7780 );
7781 }
7782
7783 return h_default()(
7784 `div.channel.channel-${channelNum}`,
7785 {
7786 attributes: {
7787 style: `height: ${data.height}px; width: ${width}px; top: ${
7788 channelNum * data.height
7789 }px; left: ${startX}px; position: absolute; margin: 0; padding: 0; z-index: 1;`,
7790 },
7791 },
7792 channelChildren
7793 );
7794 });
7795
7796 waveformChildren.push(channels);
7797 waveformChildren.push(this.renderOverlay(data));
7798
7799 // draw cursor selection on active track.
7800 if (data.isActive === true) {
7801 const cStartX = secondsToPixels(
7802 data.timeSelection.start,
7803 data.resolution,
7804 data.sampleRate
7805 );
7806 const cEndX = secondsToPixels(
7807 data.timeSelection.end,
7808 data.resolution,
7809 data.sampleRate
7810 );
7811 const cWidth = cEndX - cStartX + 1;
7812 const cClassName = cWidth > 1 ? ".segment" : ".point";
7813
7814 waveformChildren.push(
7815 h_default()(`div.selection${cClassName}`, {
7816 attributes: {
7817 style: `position: absolute; width: ${cWidth}px; bottom: 0; top: 0; left: ${cStartX}px; z-index: 4;`,
7818 },
7819 })
7820 );
7821 }
7822
7823 const waveform = h_default()(
7824 "div.waveform",
7825 {
7826 attributes: {
7827 style: `height: ${numChan * data.height}px; position: relative;`,
7828 },
7829 },
7830 waveformChildren
7831 );
7832
7833 const channelChildren = [];
7834 let channelMargin = 0;
7835
7836 if (data.controls.show) {
7837 channelChildren.push(this.renderControls(data));
7838 channelMargin = data.controls.width;
7839 }
7840
7841 channelChildren.push(waveform);
7842
7843 const audibleClass = data.shouldPlay ? "" : ".silent";
7844 const customClass =
7845 this.customClass === undefined ? "" : `.${this.customClass}`;
7846
7847 return h_default()(
7848 `div.channel-wrapper${audibleClass}${customClass}`,
7849 {
7850 attributes: {
7851 style: `margin-left: ${channelMargin}px; height: ${
7852 data.height * numChan
7853 }px;`,
7854 },
7855 },
7856 channelChildren
7857 );
7858 }
7859
7860 getTrackDetails() {
7861 const info = {
7862 src: this.src,
7863 start: this.startTime,
7864 end: this.endTime,
7865 name: this.name,
7866 customClass: this.customClass,
7867 cuein: this.cueIn,
7868 cueout: this.cueOut,
7869 stereoPan: this.stereoPan,
7870 gain: this.gain,
7871 };
7872
7873 if (this.fadeIn) {
7874 const fadeIn = this.fades[this.fadeIn];
7875
7876 info.fadeIn = {
7877 shape: fadeIn.shape,
7878 duration: fadeIn.end - fadeIn.start,
7879 };
7880 }
7881
7882 if (this.fadeOut) {
7883 const fadeOut = this.fades[this.fadeOut];
7884
7885 info.fadeOut = {
7886 shape: fadeOut.shape,
7887 duration: fadeOut.end - fadeOut.start,
7888 };
7889 }
7890
7891 return info;
7892 }
7893});
7894
7895;// CONCATENATED MODULE: ./src/Playout.js
7896
7897
7898/* harmony default export */ const Playout = (class {
7899 constructor(ac, buffer) {
7900 this.ac = ac;
7901 this.gain = 1;
7902 this.buffer = buffer;
7903 this.destination = this.ac.destination;
7904 this.ac.createStereoPanner = ac.createStereoPanner || ac.createPanner;
7905 }
7906
7907 applyFade(type, start, duration, shape = "logarithmic") {
7908 if (type === fade_maker/* FADEIN */.Y1) {
7909 (0,fade_maker/* createFadeIn */.L7)(this.fadeGain.gain, shape, start, duration);
7910 } else if (type === fade_maker/* FADEOUT */.h7) {
7911 (0,fade_maker/* createFadeOut */.Mt)(this.fadeGain.gain, shape, start, duration);
7912 } else {
7913 throw new Error("Unsupported fade type");
7914 }
7915 }
7916
7917 applyFadeIn(start, duration, shape = "logarithmic") {
7918 this.applyFade(fade_maker/* FADEIN */.Y1, start, duration, shape);
7919 }
7920
7921 applyFadeOut(start, duration, shape = "logarithmic") {
7922 this.applyFade(fade_maker/* FADEOUT */.h7, start, duration, shape);
7923 }
7924
7925 isPlaying() {
7926 return this.source !== undefined;
7927 }
7928
7929 getDuration() {
7930 return this.buffer.duration;
7931 }
7932
7933 setAudioContext(ac) {
7934 this.ac = ac;
7935 this.ac.createStereoPanner = ac.createStereoPanner || ac.createPanner;
7936 this.destination = this.ac.destination;
7937 }
7938
7939 setUpSource() {
7940 this.source = this.ac.createBufferSource();
7941 this.source.buffer = this.buffer;
7942
7943 const sourcePromise = new Promise((resolve) => {
7944 // keep track of the buffer state.
7945 this.source.onended = () => {
7946 this.source.disconnect();
7947 this.fadeGain.disconnect();
7948 this.volumeGain.disconnect();
7949 this.shouldPlayGain.disconnect();
7950 this.panner.disconnect();
7951 this.masterGain.disconnect();
7952
7953 this.source = undefined;
7954 this.fadeGain = undefined;
7955 this.volumeGain = undefined;
7956 this.shouldPlayGain = undefined;
7957 this.panner = undefined;
7958 this.masterGain = undefined;
7959
7960 resolve();
7961 };
7962 });
7963
7964 this.fadeGain = this.ac.createGain();
7965 // used for track volume slider
7966 this.volumeGain = this.ac.createGain();
7967 // used for solo/mute
7968 this.shouldPlayGain = this.ac.createGain();
7969 this.masterGain = this.ac.createGain();
7970
7971 this.panner = this.ac.createStereoPanner();
7972
7973 this.source.connect(this.fadeGain);
7974 this.fadeGain.connect(this.volumeGain);
7975 this.volumeGain.connect(this.shouldPlayGain);
7976 this.shouldPlayGain.connect(this.masterGain);
7977 this.masterGain.connect(this.panner);
7978 this.panner.connect(this.destination);
7979
7980 return sourcePromise;
7981 }
7982
7983 setVolumeGainLevel(level) {
7984 if (this.volumeGain) {
7985 this.volumeGain.gain.value = level;
7986 }
7987 }
7988
7989 setShouldPlay(bool) {
7990 if (this.shouldPlayGain) {
7991 this.shouldPlayGain.gain.value = bool ? 1 : 0;
7992 }
7993 }
7994
7995 setMasterGainLevel(level) {
7996 if (this.masterGain) {
7997 this.masterGain.gain.value = level;
7998 }
7999 }
8000
8001 setStereoPanValue(value) {
8002 const pan = value === undefined ? 0 : value;
8003
8004 if (this.panner) {
8005 if (this.panner.pan !== undefined) {
8006 this.panner.pan.value = pan;
8007 } else {
8008 this.panner.panningModel = "equalpower";
8009 this.panner.setPosition(pan, 0, 1 - Math.abs(pan));
8010 }
8011 }
8012 }
8013
8014 /*
8015 source.start is picky when passing the end time.
8016 If rounding error causes a number to make the source think
8017 it is playing slightly more samples than it has it won't play at all.
8018 Unfortunately it doesn't seem to work if you just give it a start time.
8019 */
8020 play(when, start, duration) {
8021 this.source.start(when, start, duration);
8022 }
8023
8024 stop(when = 0) {
8025 if (this.source) {
8026 this.source.stop(when);
8027 }
8028 }
8029});
8030
8031;// CONCATENATED MODULE: ./src/annotation/input/aeneas.js
8032/*
8033{
8034 "begin": "5.759",
8035 "end": "9.155",
8036 "id": "002",
8037 "language": "en",
8038 "lines": [
8039 "I just wanted to hold"
8040 ]
8041},
8042 */
8043
8044
8045
8046/* harmony default export */ function aeneas(aeneas) {
8047 const annotation = {
8048 id: aeneas.id || esm_browser_v4(),
8049 start: Number(aeneas.begin) || 0,
8050 end: Number(aeneas.end) || 0,
8051 lines: aeneas.lines || [""],
8052 lang: aeneas.language || "en",
8053 };
8054
8055 return annotation;
8056}
8057
8058;// CONCATENATED MODULE: ./src/annotation/output/aeneas.js
8059/*
8060{
8061 "begin": "5.759",
8062 "end": "9.155",
8063 "id": "002",
8064 "language": "en",
8065 "lines": [
8066 "I just wanted to hold"
8067 ]
8068},
8069 */
8070
8071/* harmony default export */ function output_aeneas(annotation) {
8072 return {
8073 begin: String(annotation.start.toFixed(3)),
8074 end: String(annotation.end.toFixed(3)),
8075 id: String(annotation.id),
8076 language: annotation.lang,
8077 lines: annotation.lines,
8078 };
8079}
8080
8081;// CONCATENATED MODULE: ./src/interaction/DragInteraction.js
8082
8083
8084/* harmony default export */ const DragInteraction = (class {
8085 constructor(playlist, data = {}) {
8086 this.playlist = playlist;
8087 this.data = data;
8088 this.active = false;
8089
8090 this.ondragover = (e) => {
8091 if (this.active) {
8092 e.preventDefault();
8093 this.emitDrag(e.clientX);
8094 }
8095 };
8096 }
8097
8098 emitDrag(x) {
8099 const deltaX = x - this.prevX;
8100
8101 // emit shift event if not 0
8102 if (deltaX) {
8103 const deltaTime = pixelsToSeconds(
8104 deltaX,
8105 this.playlist.samplesPerPixel,
8106 this.playlist.sampleRate
8107 );
8108 this.prevX = x;
8109 this.playlist.ee.emit("dragged", deltaTime, this.data);
8110 }
8111 }
8112
8113 complete() {
8114 this.active = false;
8115 document.removeEventListener("dragover", this.ondragover);
8116 }
8117
8118 dragstart(e) {
8119 const ev = e;
8120 this.active = true;
8121 this.prevX = e.clientX;
8122
8123 ev.dataTransfer.dropEffect = "move";
8124 ev.dataTransfer.effectAllowed = "move";
8125 ev.dataTransfer.setData("text/plain", "");
8126 document.addEventListener("dragover", this.ondragover);
8127 }
8128
8129 dragend(e) {
8130 if (this.active) {
8131 e.preventDefault();
8132 this.complete();
8133 }
8134 }
8135
8136 static getClass() {
8137 return ".shift";
8138 }
8139
8140 static getEvents() {
8141 return ["dragstart", "dragend"];
8142 }
8143});
8144
8145;// CONCATENATED MODULE: ./src/annotation/render/ScrollTopHook.js
8146/*
8147 * virtual-dom hook for scrolling to the text annotation.
8148 */
8149const Hook = function ScrollTopHook() {};
8150Hook.prototype.hook = function hook(node) {
8151 const el = node.querySelector(".current");
8152 if (el) {
8153 const box = node.getBoundingClientRect();
8154 const row = el.getBoundingClientRect();
8155 const diff = row.top - box.top;
8156 const list = node;
8157 list.scrollTop += diff;
8158 }
8159};
8160
8161/* harmony default export */ const ScrollTopHook = (Hook);
8162
8163;// CONCATENATED MODULE: ./src/utils/timeformat.js
8164/* harmony default export */ function timeformat(format) {
8165 function clockFormat(seconds, decimals) {
8166 const hours = parseInt(seconds / 3600, 10) % 24;
8167 const minutes = parseInt(seconds / 60, 10) % 60;
8168 const secs = (seconds % 60).toFixed(decimals);
8169
8170 const sHours = hours < 10 ? `0${hours}` : hours;
8171 const sMinutes = minutes < 10 ? `0${minutes}` : minutes;
8172 const sSeconds = secs < 10 ? `0${secs}` : secs;
8173
8174 return `${sHours}:${sMinutes}:${sSeconds}`;
8175 }
8176
8177 const formats = {
8178 seconds(seconds) {
8179 return seconds.toFixed(0);
8180 },
8181 thousandths(seconds) {
8182 return seconds.toFixed(3);
8183 },
8184 "hh:mm:ss": function hhmmss(seconds) {
8185 return clockFormat(seconds, 0);
8186 },
8187 "hh:mm:ss.u": function hhmmssu(seconds) {
8188 return clockFormat(seconds, 1);
8189 },
8190 "hh:mm:ss.uu": function hhmmssuu(seconds) {
8191 return clockFormat(seconds, 2);
8192 },
8193 "hh:mm:ss.uuu": function hhmmssuuu(seconds) {
8194 return clockFormat(seconds, 3);
8195 },
8196 };
8197
8198 return formats[format];
8199}
8200
8201;// CONCATENATED MODULE: ./src/annotation/AnnotationList.js
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211class AnnotationList {
8212 constructor(
8213 playlist,
8214 annotations,
8215 controls = [],
8216 editable = false,
8217 linkEndpoints = false,
8218 isContinuousPlay = false,
8219 marginLeft = 0
8220 ) {
8221 this.playlist = playlist;
8222 this.marginLeft = marginLeft;
8223 this.resizeHandlers = [];
8224 this.editable = editable;
8225 this.annotations = annotations.map((a) =>
8226 // TODO support different formats later on.
8227 aeneas(a)
8228 );
8229 this.setupInteractions();
8230
8231 this.controls = controls;
8232 this.setupEE(playlist.ee);
8233
8234 // TODO actually make a real plugin system that's not terrible.
8235 this.playlist.isContinuousPlay = isContinuousPlay;
8236 this.playlist.linkEndpoints = linkEndpoints;
8237 this.length = this.annotations.length;
8238 }
8239
8240 setupInteractions() {
8241 this.annotations.forEach((a, i) => {
8242 const leftShift = new DragInteraction(this.playlist, {
8243 direction: "left",
8244 index: i,
8245 });
8246 const rightShift = new DragInteraction(this.playlist, {
8247 direction: "right",
8248 index: i,
8249 });
8250
8251 this.resizeHandlers.push(leftShift);
8252 this.resizeHandlers.push(rightShift);
8253 });
8254 }
8255
8256 setupEE(ee) {
8257 ee.on("dragged", (deltaTime, data) => {
8258 const annotationIndex = data.index;
8259 const annotations = this.annotations;
8260 const note = annotations[annotationIndex];
8261
8262 // resizing to the left
8263 if (data.direction === "left") {
8264 const originalVal = note.start;
8265 note.start += deltaTime;
8266
8267 if (note.start < 0) {
8268 note.start = 0;
8269 }
8270
8271 if (
8272 annotationIndex &&
8273 annotations[annotationIndex - 1].end > note.start
8274 ) {
8275 annotations[annotationIndex - 1].end = note.start;
8276 }
8277
8278 if (
8279 this.playlist.linkEndpoints &&
8280 annotationIndex &&
8281 annotations[annotationIndex - 1].end === originalVal
8282 ) {
8283 annotations[annotationIndex - 1].end = note.start;
8284 }
8285 } else {
8286 // resizing to the right
8287 const originalVal = note.end;
8288 note.end += deltaTime;
8289
8290 if (note.end > this.playlist.duration) {
8291 note.end = this.playlist.duration;
8292 }
8293
8294 if (
8295 annotationIndex < annotations.length - 1 &&
8296 annotations[annotationIndex + 1].start < note.end
8297 ) {
8298 annotations[annotationIndex + 1].start = note.end;
8299 }
8300
8301 if (
8302 this.playlist.linkEndpoints &&
8303 annotationIndex < annotations.length - 1 &&
8304 annotations[annotationIndex + 1].start === originalVal
8305 ) {
8306 annotations[annotationIndex + 1].start = note.end;
8307 }
8308 }
8309
8310 this.playlist.drawRequest();
8311 });
8312
8313 ee.on("continuousplay", (val) => {
8314 this.playlist.isContinuousPlay = val;
8315 });
8316
8317 ee.on("linkendpoints", (val) => {
8318 this.playlist.linkEndpoints = val;
8319 });
8320
8321 ee.on("annotationsrequest", () => {
8322 this.export();
8323 });
8324
8325 return ee;
8326 }
8327
8328 export() {
8329 const output = this.annotations.map((a) => output_aeneas(a));
8330 const dataStr = `data:text/json;charset=utf-8,${encodeURIComponent(
8331 JSON.stringify(output)
8332 )}`;
8333 const a = document.createElement("a");
8334
8335 document.body.appendChild(a);
8336 a.href = dataStr;
8337 a.download = "annotations.json";
8338 a.click();
8339 document.body.removeChild(a);
8340 }
8341
8342 renderResizeLeft(i) {
8343 const events = DragInteraction.getEvents();
8344 const config = {
8345 attributes: {
8346 style:
8347 "position: absolute; height: 30px; width: 10px; top: 0; left: -2px",
8348 draggable: true,
8349 },
8350 };
8351 const handler = this.resizeHandlers[i * 2];
8352
8353 events.forEach((event) => {
8354 config[`on${event}`] = handler[event].bind(handler);
8355 });
8356
8357 return h_default()("div.resize-handle.resize-w", config);
8358 }
8359
8360 renderResizeRight(i) {
8361 const events = DragInteraction.getEvents();
8362 const config = {
8363 attributes: {
8364 style:
8365 "position: absolute; height: 30px; width: 10px; top: 0; right: -2px",
8366 draggable: true,
8367 },
8368 };
8369 const handler = this.resizeHandlers[i * 2 + 1];
8370
8371 events.forEach((event) => {
8372 config[`on${event}`] = handler[event].bind(handler);
8373 });
8374
8375 return h_default()("div.resize-handle.resize-e", config);
8376 }
8377
8378 renderControls(note, i) {
8379 // seems to be a bug with references, or I'm missing something.
8380 const that = this;
8381 return this.controls.map((ctrl) =>
8382 h_default()(`i.${ctrl.class}`, {
8383 attributes: {
8384 title: ctrl.title,
8385 },
8386 onclick: () => {
8387 ctrl.action(note, i, that.annotations, {
8388 linkEndpoints: that.playlist.linkEndpoints,
8389 });
8390 this.setupInteractions();
8391 that.playlist.drawRequest();
8392 },
8393 })
8394 );
8395 }
8396
8397 render() {
8398 const boxes = h_default()(
8399 "div.annotations-boxes",
8400 {
8401 attributes: {
8402 style: `height: 30px; position: relative; margin-left: ${this.marginLeft}px;`,
8403 },
8404 },
8405 this.annotations.map((note, i) => {
8406 const samplesPerPixel = this.playlist.samplesPerPixel;
8407 const sampleRate = this.playlist.sampleRate;
8408 const pixPerSec = sampleRate / samplesPerPixel;
8409 const pixOffset = secondsToPixels(
8410 this.playlist.scrollLeft,
8411 samplesPerPixel,
8412 sampleRate
8413 );
8414 const left = Math.floor(note.start * pixPerSec - pixOffset);
8415 const width = Math.ceil(note.end * pixPerSec - note.start * pixPerSec);
8416
8417 return h_default()(
8418 "div.annotation-box",
8419 {
8420 attributes: {
8421 style: `position: absolute; height: 30px; width: ${width}px; left: ${left}px`,
8422 "data-id": note.id,
8423 },
8424 },
8425 [
8426 this.renderResizeLeft(i),
8427 h_default()(
8428 "span.id",
8429 {
8430 onclick: () => {
8431 const start = this.annotations[i].start;
8432 const end = this.annotations[i].end;
8433
8434 if (this.playlist.isContinuousPlay) {
8435 this.playlist.seek(start, start);
8436 this.playlist.ee.emit("play", start);
8437 } else {
8438 this.playlist.seek(start, end);
8439 this.playlist.ee.emit("play", start, end);
8440 }
8441 },
8442 },
8443 [note.id]
8444 ),
8445 this.renderResizeRight(i),
8446 ]
8447 );
8448 })
8449 );
8450
8451 const boxesWrapper = h_default()(
8452 "div.annotations-boxes-wrapper",
8453 {
8454 attributes: {
8455 style: "overflow: hidden;",
8456 },
8457 },
8458 [boxes]
8459 );
8460
8461 const text = h_default()(
8462 "div.annotations-text",
8463 {
8464 hook: new ScrollTopHook(),
8465 },
8466 this.annotations.map((note, i) => {
8467 const format = timeformat(this.playlist.durationFormat);
8468 const start = format(note.start);
8469 const end = format(note.end);
8470
8471 let segmentClass = "";
8472 if (
8473 this.playlist.isPlaying() &&
8474 this.playlist.playbackSeconds >= note.start &&
8475 this.playlist.playbackSeconds <= note.end
8476 ) {
8477 segmentClass = ".current";
8478 }
8479
8480 const editableConfig = {
8481 attributes: {
8482 contenteditable: true,
8483 },
8484 oninput: (e) => {
8485 // needed currently for references
8486 // eslint-disable-next-line no-param-reassign
8487 note.lines = [e.target.innerText];
8488 },
8489 onkeypress: (e) => {
8490 if (e.which === 13 || e.keyCode === 13) {
8491 e.target.blur();
8492 e.preventDefault();
8493 }
8494 },
8495 };
8496
8497 const linesConfig = this.editable ? editableConfig : {};
8498
8499 return h_default()(`div.annotation${segmentClass}`, [
8500 h_default()("span.annotation-id", [note.id]),
8501 h_default()("span.annotation-start", [start]),
8502 h_default()("span.annotation-end", [end]),
8503 h_default()("span.annotation-lines", linesConfig, [note.lines]),
8504 h_default()("span.annotation-actions", this.renderControls(note, i)),
8505 ]);
8506 })
8507 );
8508
8509 return h_default()("div.annotations", [boxesWrapper, text]);
8510 }
8511}
8512
8513/* harmony default export */ const annotation_AnnotationList = (AnnotationList);
8514
8515;// CONCATENATED MODULE: ./src/utils/recorderWorker.js
8516/* harmony default export */ function recorderWorker() {
8517 // http://jsperf.com/typed-array-min-max/2
8518 // plain for loop for finding min/max is way faster than anything else.
8519 /**
8520 * @param {TypedArray} array - Subarray of audio to calculate peaks from.
8521 */
8522 function findMinMax(array) {
8523 let min = Infinity;
8524 let max = -Infinity;
8525 let curr;
8526
8527 for (let i = 0; i < array.length; i += 1) {
8528 curr = array[i];
8529 if (min > curr) {
8530 min = curr;
8531 }
8532 if (max < curr) {
8533 max = curr;
8534 }
8535 }
8536
8537 return {
8538 min,
8539 max,
8540 };
8541 }
8542
8543 /**
8544 * @param {Number} n - peak to convert from float to Int8, Int16 etc.
8545 * @param {Number} bits - convert to #bits two's complement signed integer
8546 */
8547 function convert(n, bits) {
8548 const max = 2 ** (bits - 1);
8549 const v = n < 0 ? n * max : n * max - 1;
8550 return Math.max(-max, Math.min(max - 1, v));
8551 }
8552
8553 /**
8554 * @param {TypedArray} channel - Audio track frames to calculate peaks from.
8555 * @param {Number} samplesPerPixel - Audio frames per peak
8556 */
8557 function extractPeaks(channel, samplesPerPixel, bits) {
8558 const chanLength = channel.length;
8559 const numPeaks = Math.ceil(chanLength / samplesPerPixel);
8560 let start;
8561 let end;
8562 let segment;
8563 let max;
8564 let min;
8565 let extrema;
8566
8567 // create interleaved array of min,max
8568 const peaks = new self[`Int${bits}Array`](numPeaks * 2);
8569
8570 for (let i = 0; i < numPeaks; i += 1) {
8571 start = i * samplesPerPixel;
8572 end =
8573 (i + 1) * samplesPerPixel > chanLength
8574 ? chanLength
8575 : (i + 1) * samplesPerPixel;
8576
8577 segment = channel.subarray(start, end);
8578 extrema = findMinMax(segment);
8579 min = convert(extrema.min, bits);
8580 max = convert(extrema.max, bits);
8581
8582 peaks[i * 2] = min;
8583 peaks[i * 2 + 1] = max;
8584 }
8585
8586 return peaks;
8587 }
8588
8589 /**
8590 * @param {TypedArray} source - Source of audio samples for peak calculations.
8591 * @param {Number} samplesPerPixel - Number of audio samples per peak.
8592 * @param {Number} cueIn - index in channel to start peak calculations from.
8593 * @param {Number} cueOut - index in channel to end peak calculations from (non-inclusive).
8594 */
8595 function audioPeaks(source, samplesPerPixel = 10000, bits = 8) {
8596 if ([8, 16, 32].indexOf(bits) < 0) {
8597 throw new Error("Invalid number of bits specified for peaks.");
8598 }
8599
8600 const peaks = [];
8601 const start = 0;
8602 const end = source.length;
8603 peaks.push(
8604 extractPeaks(source.subarray(start, end), samplesPerPixel, bits)
8605 );
8606
8607 const length = peaks[0].length / 2;
8608
8609 return {
8610 bits,
8611 length,
8612 data: peaks,
8613 };
8614 }
8615
8616 onmessage = function onmessage(e) {
8617 const peaks = audioPeaks(e.data.samples, e.data.samplesPerPixel);
8618
8619 postMessage(peaks);
8620 };
8621}
8622
8623;// CONCATENATED MODULE: ./src/utils/exportWavWorker.js
8624/* harmony default export */ function exportWavWorker() {
8625 let recLength = 0;
8626 let recBuffersL = [];
8627 let recBuffersR = [];
8628 let sampleRate;
8629
8630 function init(config) {
8631 sampleRate = config.sampleRate;
8632 }
8633
8634 function record(inputBuffer) {
8635 recBuffersL.push(inputBuffer[0]);
8636 recBuffersR.push(inputBuffer[1]);
8637 recLength += inputBuffer[0].length;
8638 }
8639
8640 function writeString(view, offset, string) {
8641 for (let i = 0; i < string.length; i += 1) {
8642 view.setUint8(offset + i, string.charCodeAt(i));
8643 }
8644 }
8645
8646 function floatTo16BitPCM(output, offset, input) {
8647 let writeOffset = offset;
8648 for (let i = 0; i < input.length; i += 1, writeOffset += 2) {
8649 const s = Math.max(-1, Math.min(1, input[i]));
8650 output.setInt16(writeOffset, s < 0 ? s * 0x8000 : s * 0x7fff, true);
8651 }
8652 }
8653
8654 function encodeWAV(samples, mono = false) {
8655 const buffer = new ArrayBuffer(44 + samples.length * 2);
8656 const view = new DataView(buffer);
8657
8658 /* RIFF identifier */
8659 writeString(view, 0, "RIFF");
8660 /* file length */
8661 view.setUint32(4, 32 + samples.length * 2, true);
8662 /* RIFF type */
8663 writeString(view, 8, "WAVE");
8664 /* format chunk identifier */
8665 writeString(view, 12, "fmt ");
8666 /* format chunk length */
8667 view.setUint32(16, 16, true);
8668 /* sample format (raw) */
8669 view.setUint16(20, 1, true);
8670 /* channel count */
8671 view.setUint16(22, mono ? 1 : 2, true);
8672 /* sample rate */
8673 view.setUint32(24, sampleRate, true);
8674 /* byte rate (sample rate * block align) */
8675 view.setUint32(28, sampleRate * 4, true);
8676 /* block align (channel count * bytes per sample) */
8677 view.setUint16(32, 4, true);
8678 /* bits per sample */
8679 view.setUint16(34, 16, true);
8680 /* data chunk identifier */
8681 writeString(view, 36, "data");
8682 /* data chunk length */
8683 view.setUint32(40, samples.length * 2, true);
8684
8685 floatTo16BitPCM(view, 44, samples);
8686
8687 return view;
8688 }
8689
8690 function mergeBuffers(recBuffers, length) {
8691 const result = new Float32Array(length);
8692 let offset = 0;
8693
8694 for (let i = 0; i < recBuffers.length; i += 1) {
8695 result.set(recBuffers[i], offset);
8696 offset += recBuffers[i].length;
8697 }
8698 return result;
8699 }
8700
8701 function interleave(inputL, inputR) {
8702 const length = inputL.length + inputR.length;
8703 const result = new Float32Array(length);
8704
8705 let index = 0;
8706 let inputIndex = 0;
8707
8708 while (index < length) {
8709 result[(index += 1)] = inputL[inputIndex];
8710 result[(index += 1)] = inputR[inputIndex];
8711 inputIndex += 1;
8712 }
8713
8714 return result;
8715 }
8716
8717 function exportWAV(type) {
8718 const bufferL = mergeBuffers(recBuffersL, recLength);
8719 const bufferR = mergeBuffers(recBuffersR, recLength);
8720 const interleaved = interleave(bufferL, bufferR);
8721 const dataview = encodeWAV(interleaved);
8722 const audioBlob = new Blob([dataview], { type });
8723
8724 postMessage(audioBlob);
8725 }
8726
8727 function clear() {
8728 recLength = 0;
8729 recBuffersL = [];
8730 recBuffersR = [];
8731 }
8732
8733 onmessage = function onmessage(e) {
8734 switch (e.data.command) {
8735 case "init": {
8736 init(e.data.config);
8737 break;
8738 }
8739 case "record": {
8740 record(e.data.buffer);
8741 break;
8742 }
8743 case "exportWAV": {
8744 exportWAV(e.data.type);
8745 break;
8746 }
8747 case "clear": {
8748 clear();
8749 break;
8750 }
8751 default: {
8752 throw new Error("Unknown export worker command");
8753 }
8754 }
8755 };
8756}
8757
8758;// CONCATENATED MODULE: ./src/Playlist.js
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777/* harmony default export */ const Playlist = (class {
8778 constructor() {
8779 this.tracks = [];
8780 this.soloedTracks = [];
8781 this.mutedTracks = [];
8782 this.collapsedTracks = [];
8783 this.playoutPromises = [];
8784
8785 this.cursor = 0;
8786 this.playbackSeconds = 0;
8787 this.duration = 0;
8788 this.scrollLeft = 0;
8789 this.scrollTimer = undefined;
8790 this.showTimescale = false;
8791 // whether a user is scrolling the waveform
8792 this.isScrolling = false;
8793
8794 this.fadeType = "logarithmic";
8795 this.masterGain = 1;
8796 this.annotations = [];
8797 this.durationFormat = "hh:mm:ss.uuu";
8798 this.isAutomaticScroll = false;
8799 this.resetDrawTimer = undefined;
8800 }
8801
8802 // TODO extract into a plugin
8803 initExporter() {
8804 this.exportWorker = new (inline_worker_default())(exportWavWorker);
8805 }
8806
8807 // TODO extract into a plugin
8808 initRecorder(stream) {
8809 this.mediaRecorder = new MediaRecorder(stream);
8810
8811 this.mediaRecorder.onstart = () => {
8812 const track = new Track();
8813 track.setName("Recording");
8814 track.setEnabledStates();
8815 track.setEventEmitter(this.ee);
8816
8817 this.recordingTrack = track;
8818 this.tracks.push(track);
8819
8820 this.chunks = [];
8821 this.working = false;
8822 };
8823
8824 this.mediaRecorder.ondataavailable = (e) => {
8825 this.chunks.push(e.data);
8826
8827 // throttle peaks calculation
8828 if (!this.working) {
8829 const recording = new Blob(this.chunks, {
8830 type: "audio/ogg; codecs=opus",
8831 });
8832 const loader = LoaderFactory.createLoader(recording, this.ac);
8833 loader
8834 .load()
8835 .then((audioBuffer) => {
8836 // ask web worker for peaks.
8837 this.recorderWorker.postMessage({
8838 samples: audioBuffer.getChannelData(0),
8839 samplesPerPixel: this.samplesPerPixel,
8840 });
8841 this.recordingTrack.setCues(0, audioBuffer.duration);
8842 this.recordingTrack.setBuffer(audioBuffer);
8843 this.recordingTrack.setPlayout(new Playout(this.ac, audioBuffer));
8844 this.adjustDuration();
8845 })
8846 .catch(() => {
8847 this.working = false;
8848 });
8849 this.working = true;
8850 }
8851 };
8852
8853 this.mediaRecorder.onstop = () => {
8854 this.chunks = [];
8855 this.working = false;
8856 };
8857
8858 this.recorderWorker = new (inline_worker_default())(recorderWorker);
8859 // use a worker for calculating recording peaks.
8860 this.recorderWorker.onmessage = (e) => {
8861 this.recordingTrack.setPeaks(e.data);
8862 this.working = false;
8863 this.drawRequest();
8864 };
8865 }
8866
8867 setShowTimeScale(show) {
8868 this.showTimescale = show;
8869 }
8870
8871 setMono(mono) {
8872 this.mono = mono;
8873 }
8874
8875 setExclSolo(exclSolo) {
8876 this.exclSolo = exclSolo;
8877 }
8878
8879 setSeekStyle(style) {
8880 this.seekStyle = style;
8881 }
8882
8883 getSeekStyle() {
8884 return this.seekStyle;
8885 }
8886
8887 setSampleRate(sampleRate) {
8888 this.sampleRate = sampleRate;
8889 }
8890
8891 setSamplesPerPixel(samplesPerPixel) {
8892 this.samplesPerPixel = samplesPerPixel;
8893 }
8894
8895 setAudioContext(ac) {
8896 this.ac = ac;
8897 }
8898
8899 setControlOptions(controlOptions) {
8900 this.controls = controlOptions;
8901 }
8902
8903 setWaveHeight(height) {
8904 this.waveHeight = height;
8905 }
8906
8907 setCollapsedWaveHeight(height) {
8908 this.collapsedWaveHeight = height;
8909 }
8910
8911 setColors(colors) {
8912 this.colors = colors;
8913 }
8914
8915 setBarWidth(width) {
8916 this.barWidth = width;
8917 }
8918
8919 setBarGap(width) {
8920 this.barGap = width;
8921 }
8922
8923 setAnnotations(config) {
8924 const controlWidth = this.controls.show ? this.controls.width : 0;
8925 this.annotationList = new annotation_AnnotationList(
8926 this,
8927 config.annotations,
8928 config.controls,
8929 config.editable,
8930 config.linkEndpoints,
8931 config.isContinuousPlay,
8932 controlWidth
8933 );
8934 }
8935
8936 setEventEmitter(ee) {
8937 this.ee = ee;
8938 }
8939
8940 getEventEmitter() {
8941 return this.ee;
8942 }
8943
8944 setUpEventEmitter() {
8945 const ee = this.ee;
8946
8947 ee.on("automaticscroll", (val) => {
8948 this.isAutomaticScroll = val;
8949 });
8950
8951 ee.on("durationformat", (format) => {
8952 this.durationFormat = format;
8953 this.drawRequest();
8954 });
8955
8956 ee.on("select", (start, end, track) => {
8957 if (this.isPlaying()) {
8958 this.lastSeeked = start;
8959 this.pausedAt = undefined;
8960 this.restartPlayFrom(start);
8961 } else {
8962 // reset if it was paused.
8963 this.seek(start, end, track);
8964 this.ee.emit("timeupdate", start);
8965 this.drawRequest();
8966 }
8967 });
8968
8969 ee.on("startaudiorendering", (type) => {
8970 this.startOfflineRender(type);
8971 });
8972
8973 ee.on("statechange", (state) => {
8974 this.setState(state);
8975 this.drawRequest();
8976 });
8977
8978 ee.on("shift", (deltaTime, track) => {
8979 track.setStartTime(track.getStartTime() + deltaTime);
8980 this.adjustDuration();
8981 this.drawRequest();
8982 });
8983
8984 ee.on("record", () => {
8985 this.record();
8986 });
8987
8988 ee.on("play", (start, end) => {
8989 this.play(start, end);
8990 });
8991
8992 ee.on("pause", () => {
8993 this.pause();
8994 });
8995
8996 ee.on("stop", () => {
8997 this.stop();
8998 });
8999
9000 ee.on("rewind", () => {
9001 this.rewind();
9002 });
9003
9004 ee.on("fastforward", () => {
9005 this.fastForward();
9006 });
9007
9008 ee.on("clear", () => {
9009 this.clear().then(() => {
9010 this.drawRequest();
9011 });
9012 });
9013
9014 ee.on("solo", (track) => {
9015 this.soloTrack(track);
9016 this.adjustTrackPlayout();
9017 this.drawRequest();
9018 });
9019
9020 ee.on("mute", (track) => {
9021 this.muteTrack(track);
9022 this.adjustTrackPlayout();
9023 this.drawRequest();
9024 });
9025
9026 ee.on("removeTrack", (track) => {
9027 this.removeTrack(track);
9028 this.adjustTrackPlayout();
9029 this.drawRequest();
9030 });
9031
9032 ee.on("changeTrackView", (track, opts) => {
9033 this.collapseTrack(track, opts);
9034 this.drawRequest();
9035 });
9036
9037 ee.on("volumechange", (volume, track) => {
9038 track.setGainLevel(volume / 100);
9039 this.drawRequest();
9040 });
9041
9042 ee.on("mastervolumechange", (volume) => {
9043 this.masterGain = volume / 100;
9044 this.tracks.forEach((track) => {
9045 track.setMasterGainLevel(this.masterGain);
9046 });
9047 });
9048
9049 ee.on("fadein", (duration, track) => {
9050 track.setFadeIn(duration, this.fadeType);
9051 this.drawRequest();
9052 });
9053
9054 ee.on("fadeout", (duration, track) => {
9055 track.setFadeOut(duration, this.fadeType);
9056 this.drawRequest();
9057 });
9058
9059 ee.on("stereopan", (panvalue, track) => {
9060 track.setStereoPanValue(panvalue);
9061 this.drawRequest();
9062 });
9063
9064 ee.on("fadetype", (type) => {
9065 this.fadeType = type;
9066 });
9067
9068 ee.on("newtrack", (file) => {
9069 this.load([
9070 {
9071 src: file,
9072 name: file.name,
9073 },
9074 ]);
9075 });
9076
9077 ee.on("trim", () => {
9078 const track = this.getActiveTrack();
9079 const timeSelection = this.getTimeSelection();
9080
9081 track.trim(timeSelection.start, timeSelection.end);
9082 track.calculatePeaks(this.samplesPerPixel, this.sampleRate);
9083
9084 this.setTimeSelection(0, 0);
9085 this.drawRequest();
9086 });
9087
9088 ee.on("zoomin", () => {
9089 const zoomIndex = Math.max(0, this.zoomIndex - 1);
9090 const zoom = this.zoomLevels[zoomIndex];
9091
9092 if (zoom !== this.samplesPerPixel) {
9093 this.setZoom(zoom);
9094 this.drawRequest();
9095 }
9096 });
9097
9098 ee.on("zoomout", () => {
9099 const zoomIndex = Math.min(
9100 this.zoomLevels.length - 1,
9101 this.zoomIndex + 1
9102 );
9103 const zoom = this.zoomLevels[zoomIndex];
9104
9105 if (zoom !== this.samplesPerPixel) {
9106 this.setZoom(zoom);
9107 this.drawRequest();
9108 }
9109 });
9110
9111 ee.on("scroll", () => {
9112 this.isScrolling = true;
9113 this.drawRequest();
9114 clearTimeout(this.scrollTimer);
9115 this.scrollTimer = setTimeout(() => {
9116 this.isScrolling = false;
9117 }, 200);
9118 });
9119 }
9120
9121 load(trackList) {
9122 const loadPromises = trackList.map((trackInfo) => {
9123 const loader = LoaderFactory.createLoader(
9124 trackInfo.src,
9125 this.ac,
9126 this.ee
9127 );
9128 return loader.load();
9129 });
9130
9131 return Promise.all(loadPromises)
9132 .then((audioBuffers) => {
9133 this.ee.emit("audiosourcesloaded");
9134
9135 const tracks = audioBuffers.map((audioBuffer, index) => {
9136 const info = trackList[index];
9137 const name = info.name || "Untitled";
9138 const start = info.start || 0;
9139 const states = info.states || {};
9140 const fadeIn = info.fadeIn;
9141 const fadeOut = info.fadeOut;
9142 const cueIn = info.cuein || 0;
9143 const cueOut = info.cueout || audioBuffer.duration;
9144 const gain = info.gain || 1;
9145 const muted = info.muted || false;
9146 const soloed = info.soloed || false;
9147 const selection = info.selected;
9148 const peaks = info.peaks || { type: "WebAudio", mono: this.mono };
9149 const customClass = info.customClass || undefined;
9150 const waveOutlineColor = info.waveOutlineColor || undefined;
9151 const stereoPan = info.stereoPan || 0;
9152
9153 // webaudio specific playout for now.
9154 const playout = new Playout(this.ac, audioBuffer);
9155
9156 const track = new Track();
9157 track.src = info.src;
9158 track.setBuffer(audioBuffer);
9159 track.setName(name);
9160 track.setEventEmitter(this.ee);
9161 track.setEnabledStates(states);
9162 track.setCues(cueIn, cueOut);
9163 track.setCustomClass(customClass);
9164 track.setWaveOutlineColor(waveOutlineColor);
9165
9166 if (fadeIn !== undefined) {
9167 track.setFadeIn(fadeIn.duration, fadeIn.shape);
9168 }
9169
9170 if (fadeOut !== undefined) {
9171 track.setFadeOut(fadeOut.duration, fadeOut.shape);
9172 }
9173
9174 if (selection !== undefined) {
9175 this.setActiveTrack(track);
9176 this.setTimeSelection(selection.start, selection.end);
9177 }
9178
9179 if (peaks !== undefined) {
9180 track.setPeakData(peaks);
9181 }
9182
9183 track.setState(this.getState());
9184 track.setStartTime(start);
9185 track.setPlayout(playout);
9186
9187 track.setGainLevel(gain);
9188 track.setStereoPanValue(stereoPan);
9189
9190 if (muted) {
9191 this.muteTrack(track);
9192 }
9193
9194 if (soloed) {
9195 this.soloTrack(track);
9196 }
9197
9198 // extract peaks with AudioContext for now.
9199 track.calculatePeaks(this.samplesPerPixel, this.sampleRate);
9200
9201 return track;
9202 });
9203
9204 this.tracks = this.tracks.concat(tracks);
9205 this.adjustDuration();
9206 this.draw(this.render());
9207
9208 this.ee.emit("audiosourcesrendered");
9209 })
9210 .catch((e) => {
9211 this.ee.emit("audiosourceserror", e);
9212 });
9213 }
9214
9215 /*
9216 track instance of Track.
9217 */
9218 setActiveTrack(track) {
9219 this.activeTrack = track;
9220 }
9221
9222 getActiveTrack() {
9223 return this.activeTrack;
9224 }
9225
9226 isSegmentSelection() {
9227 return this.timeSelection.start !== this.timeSelection.end;
9228 }
9229
9230 /*
9231 start, end in seconds.
9232 */
9233 setTimeSelection(start = 0, end) {
9234 this.timeSelection = {
9235 start,
9236 end: end === undefined ? start : end,
9237 };
9238
9239 this.cursor = start;
9240 }
9241
9242 startOfflineRender(type) {
9243 if (this.isRendering) {
9244 return;
9245 }
9246
9247 this.isRendering = true;
9248 this.offlineAudioContext = new OfflineAudioContext(
9249 2,
9250 44100 * this.duration,
9251 44100
9252 );
9253
9254 const currentTime = this.offlineAudioContext.currentTime;
9255
9256 this.tracks.forEach((track) => {
9257 track.setOfflinePlayout(
9258 new Playout(this.offlineAudioContext, track.buffer)
9259 );
9260 track.schedulePlay(currentTime, 0, 0, {
9261 shouldPlay: this.shouldTrackPlay(track),
9262 masterGain: 1,
9263 isOffline: true,
9264 });
9265 });
9266
9267 /*
9268 TODO cleanup of different audio playouts handling.
9269 */
9270 this.offlineAudioContext
9271 .startRendering()
9272 .then((audioBuffer) => {
9273 if (type === "buffer") {
9274 this.ee.emit("audiorenderingfinished", type, audioBuffer);
9275 this.isRendering = false;
9276 return;
9277 }
9278
9279 if (type === "wav") {
9280 this.exportWorker.postMessage({
9281 command: "init",
9282 config: {
9283 sampleRate: 44100,
9284 },
9285 });
9286
9287 // callback for `exportWAV`
9288 this.exportWorker.onmessage = (e) => {
9289 this.ee.emit("audiorenderingfinished", type, e.data);
9290 this.isRendering = false;
9291
9292 // clear out the buffer for next renderings.
9293 this.exportWorker.postMessage({
9294 command: "clear",
9295 });
9296 };
9297
9298 // send the channel data from our buffer to the worker
9299 this.exportWorker.postMessage({
9300 command: "record",
9301 buffer: [
9302 audioBuffer.getChannelData(0),
9303 audioBuffer.getChannelData(1),
9304 ],
9305 });
9306
9307 // ask the worker for a WAV
9308 this.exportWorker.postMessage({
9309 command: "exportWAV",
9310 type: "audio/wav",
9311 });
9312 }
9313 })
9314 .catch((e) => {
9315 throw e;
9316 });
9317 }
9318
9319 getTimeSelection() {
9320 return this.timeSelection;
9321 }
9322
9323 setState(state) {
9324 this.state = state;
9325
9326 this.tracks.forEach((track) => {
9327 track.setState(state);
9328 });
9329 }
9330
9331 getState() {
9332 return this.state;
9333 }
9334
9335 setZoomIndex(index) {
9336 this.zoomIndex = index;
9337 }
9338
9339 setZoomLevels(levels) {
9340 this.zoomLevels = levels;
9341 }
9342
9343 setZoom(zoom) {
9344 this.samplesPerPixel = zoom;
9345 this.zoomIndex = this.zoomLevels.indexOf(zoom);
9346 this.tracks.forEach((track) => {
9347 track.calculatePeaks(zoom, this.sampleRate);
9348 });
9349 }
9350
9351 muteTrack(track) {
9352 const index = this.mutedTracks.indexOf(track);
9353
9354 if (index > -1) {
9355 this.mutedTracks.splice(index, 1);
9356 } else {
9357 this.mutedTracks.push(track);
9358 }
9359 }
9360
9361 soloTrack(track) {
9362 const index = this.soloedTracks.indexOf(track);
9363
9364 if (index > -1) {
9365 this.soloedTracks.splice(index, 1);
9366 } else if (this.exclSolo) {
9367 this.soloedTracks = [track];
9368 } else {
9369 this.soloedTracks.push(track);
9370 }
9371 }
9372
9373 collapseTrack(track, opts) {
9374 if (opts.collapsed) {
9375 this.collapsedTracks.push(track);
9376 } else {
9377 const index = this.collapsedTracks.indexOf(track);
9378
9379 if (index > -1) {
9380 this.collapsedTracks.splice(index, 1);
9381 }
9382 }
9383 }
9384
9385 removeTrack(track) {
9386 if (track.isPlaying()) {
9387 track.scheduleStop();
9388 }
9389
9390 const trackLists = [
9391 this.mutedTracks,
9392 this.soloedTracks,
9393 this.collapsedTracks,
9394 this.tracks,
9395 ];
9396 trackLists.forEach((list) => {
9397 const index = list.indexOf(track);
9398 if (index > -1) {
9399 list.splice(index, 1);
9400 }
9401 });
9402 }
9403
9404 adjustTrackPlayout() {
9405 this.tracks.forEach((track) => {
9406 track.setShouldPlay(this.shouldTrackPlay(track));
9407 });
9408 }
9409
9410 adjustDuration() {
9411 this.duration = this.tracks.reduce(
9412 (duration, track) => Math.max(duration, track.getEndTime()),
9413 0
9414 );
9415 }
9416
9417 shouldTrackPlay(track) {
9418 let shouldPlay;
9419 // if there are solo tracks, only they should play.
9420 if (this.soloedTracks.length > 0) {
9421 shouldPlay = false;
9422 if (this.soloedTracks.indexOf(track) > -1) {
9423 shouldPlay = true;
9424 }
9425 } else {
9426 // play all tracks except any muted tracks.
9427 shouldPlay = true;
9428 if (this.mutedTracks.indexOf(track) > -1) {
9429 shouldPlay = false;
9430 }
9431 }
9432
9433 return shouldPlay;
9434 }
9435
9436 isPlaying() {
9437 return this.tracks.reduce(
9438 (isPlaying, track) => isPlaying || track.isPlaying(),
9439 false
9440 );
9441 }
9442
9443 /*
9444 * returns the current point of time in the playlist in seconds.
9445 */
9446 getCurrentTime() {
9447 const cursorPos = this.lastSeeked || this.pausedAt || this.cursor;
9448
9449 return cursorPos + this.getElapsedTime();
9450 }
9451
9452 getElapsedTime() {
9453 return this.ac.currentTime - this.lastPlay;
9454 }
9455
9456 setMasterGain(gain) {
9457 this.ee.emit("mastervolumechange", gain);
9458 }
9459
9460 restartPlayFrom(start, end) {
9461 this.stopAnimation();
9462
9463 this.tracks.forEach((editor) => {
9464 editor.scheduleStop();
9465 });
9466
9467 return Promise.all(this.playoutPromises).then(
9468 this.play.bind(this, start, end)
9469 );
9470 }
9471
9472 play(startTime, endTime) {
9473 clearTimeout(this.resetDrawTimer);
9474
9475 const currentTime = this.ac.currentTime;
9476 const selected = this.getTimeSelection();
9477 const playoutPromises = [];
9478
9479 const start = startTime || this.pausedAt || this.cursor;
9480 let end = endTime;
9481
9482 if (!end && selected.end !== selected.start && selected.end > start) {
9483 end = selected.end;
9484 }
9485
9486 if (this.isPlaying()) {
9487 return this.restartPlayFrom(start, end);
9488 }
9489
9490 this.tracks.forEach((track) => {
9491 track.setState("cursor");
9492 playoutPromises.push(
9493 track.schedulePlay(currentTime, start, end, {
9494 shouldPlay: this.shouldTrackPlay(track),
9495 masterGain: this.masterGain,
9496 })
9497 );
9498 });
9499
9500 this.lastPlay = currentTime;
9501 // use these to track when the playlist has fully stopped.
9502 this.playoutPromises = playoutPromises;
9503 this.startAnimation(start);
9504
9505 return Promise.all(this.playoutPromises);
9506 }
9507
9508 pause() {
9509 if (!this.isPlaying()) {
9510 return Promise.all(this.playoutPromises);
9511 }
9512
9513 this.pausedAt = this.getCurrentTime();
9514 return this.playbackReset();
9515 }
9516
9517 stop() {
9518 if (this.mediaRecorder && this.mediaRecorder.state === "recording") {
9519 this.mediaRecorder.stop();
9520 }
9521
9522 this.pausedAt = undefined;
9523 this.playbackSeconds = 0;
9524 return this.playbackReset();
9525 }
9526
9527 playbackReset() {
9528 this.lastSeeked = undefined;
9529 this.stopAnimation();
9530
9531 this.tracks.forEach((track) => {
9532 track.scheduleStop();
9533 track.setState(this.getState());
9534 });
9535
9536 this.drawRequest();
9537 return Promise.all(this.playoutPromises);
9538 }
9539
9540 rewind() {
9541 return this.stop().then(() => {
9542 this.scrollLeft = 0;
9543 this.ee.emit("select", 0, 0);
9544 });
9545 }
9546
9547 fastForward() {
9548 return this.stop().then(() => {
9549 if (this.viewDuration < this.duration) {
9550 this.scrollLeft = this.duration - this.viewDuration;
9551 } else {
9552 this.scrollLeft = 0;
9553 }
9554
9555 this.ee.emit("select", this.duration, this.duration);
9556 });
9557 }
9558
9559 clear() {
9560 return this.stop().then(() => {
9561 this.tracks = [];
9562 this.soloedTracks = [];
9563 this.mutedTracks = [];
9564 this.playoutPromises = [];
9565
9566 this.cursor = 0;
9567 this.playbackSeconds = 0;
9568 this.duration = 0;
9569 this.scrollLeft = 0;
9570
9571 this.seek(0, 0, undefined);
9572 });
9573 }
9574
9575 record() {
9576 const playoutPromises = [];
9577 this.mediaRecorder.start(300);
9578
9579 this.tracks.forEach((track) => {
9580 track.setState("none");
9581 playoutPromises.push(
9582 track.schedulePlay(this.ac.currentTime, 0, undefined, {
9583 shouldPlay: this.shouldTrackPlay(track),
9584 })
9585 );
9586 });
9587
9588 this.playoutPromises = playoutPromises;
9589 }
9590
9591 startAnimation(startTime) {
9592 this.lastDraw = this.ac.currentTime;
9593 this.animationRequest = window.requestAnimationFrame(() => {
9594 this.updateEditor(startTime);
9595 });
9596 }
9597
9598 stopAnimation() {
9599 window.cancelAnimationFrame(this.animationRequest);
9600 this.lastDraw = undefined;
9601 }
9602
9603 seek(start, end, track) {
9604 if (this.isPlaying()) {
9605 this.lastSeeked = start;
9606 this.pausedAt = undefined;
9607 this.restartPlayFrom(start);
9608 } else {
9609 // reset if it was paused.
9610 this.setActiveTrack(track || this.tracks[0]);
9611 this.pausedAt = start;
9612 this.setTimeSelection(start, end);
9613 if (this.getSeekStyle() === "fill") {
9614 this.playbackSeconds = start;
9615 }
9616 }
9617 }
9618
9619 /*
9620 * Animation function for the playlist.
9621 * Keep under 16.7 milliseconds based on a typical screen refresh rate of 60fps.
9622 */
9623 updateEditor(cursor) {
9624 const currentTime = this.ac.currentTime;
9625 const selection = this.getTimeSelection();
9626 const cursorPos = cursor || this.cursor;
9627 const elapsed = currentTime - this.lastDraw;
9628
9629 if (this.isPlaying()) {
9630 const playbackSeconds = cursorPos + elapsed;
9631 this.ee.emit("timeupdate", playbackSeconds);
9632 this.animationRequest = window.requestAnimationFrame(() => {
9633 this.updateEditor(playbackSeconds);
9634 });
9635
9636 this.playbackSeconds = playbackSeconds;
9637 this.draw(this.render());
9638 this.lastDraw = currentTime;
9639 } else {
9640 if (
9641 cursorPos + elapsed >=
9642 (this.isSegmentSelection() ? selection.end : this.duration)
9643 ) {
9644 this.ee.emit("finished");
9645 }
9646
9647 this.stopAnimation();
9648
9649 this.resetDrawTimer = setTimeout(() => {
9650 this.pausedAt = undefined;
9651 this.lastSeeked = undefined;
9652 this.setState(this.getState());
9653
9654 this.playbackSeconds = 0;
9655 this.draw(this.render());
9656 }, 0);
9657 }
9658 }
9659
9660 drawRequest() {
9661 window.requestAnimationFrame(() => {
9662 this.draw(this.render());
9663 });
9664 }
9665
9666 draw(newTree) {
9667 const patches = diff_default()(this.tree, newTree);
9668 this.rootNode = patch_default()(this.rootNode, patches);
9669 this.tree = newTree;
9670
9671 // use for fast forwarding.
9672 this.viewDuration = pixelsToSeconds(
9673 this.rootNode.clientWidth - this.controls.width,
9674 this.samplesPerPixel,
9675 this.sampleRate
9676 );
9677 }
9678
9679 getTrackRenderData(data = {}) {
9680 const defaults = {
9681 height: this.waveHeight,
9682 resolution: this.samplesPerPixel,
9683 sampleRate: this.sampleRate,
9684 controls: this.controls,
9685 isActive: false,
9686 timeSelection: this.getTimeSelection(),
9687 playlistLength: this.duration,
9688 playbackSeconds: this.playbackSeconds,
9689 colors: this.colors,
9690 barWidth: this.barWidth,
9691 barGap: this.barGap,
9692 };
9693
9694 return lodash_defaultsdeep_default()({}, data, defaults);
9695 }
9696
9697 isActiveTrack(track) {
9698 const activeTrack = this.getActiveTrack();
9699
9700 if (this.isSegmentSelection()) {
9701 return activeTrack === track;
9702 }
9703
9704 return true;
9705 }
9706
9707 renderAnnotations() {
9708 return this.annotationList.render();
9709 }
9710
9711 renderTimeScale() {
9712 const controlWidth = this.controls.show ? this.controls.width : 0;
9713 const timeScale = new src_TimeScale(
9714 this.duration,
9715 this.scrollLeft,
9716 this.samplesPerPixel,
9717 this.sampleRate,
9718 controlWidth,
9719 this.colors
9720 );
9721
9722 return timeScale.render();
9723 }
9724
9725 renderTrackSection() {
9726 const trackElements = this.tracks.map((track) => {
9727 const collapsed = this.collapsedTracks.indexOf(track) > -1;
9728 return track.render(
9729 this.getTrackRenderData({
9730 isActive: this.isActiveTrack(track),
9731 shouldPlay: this.shouldTrackPlay(track),
9732 soloed: this.soloedTracks.indexOf(track) > -1,
9733 muted: this.mutedTracks.indexOf(track) > -1,
9734 collapsed,
9735 height: collapsed ? this.collapsedWaveHeight : this.waveHeight,
9736 barGap: this.barGap,
9737 barWidth: this.barWidth,
9738 })
9739 );
9740 });
9741
9742 return h_default()(
9743 "div.playlist-tracks",
9744 {
9745 attributes: {
9746 style: "overflow: auto;",
9747 },
9748 onscroll: (e) => {
9749 this.scrollLeft = pixelsToSeconds(
9750 e.target.scrollLeft,
9751 this.samplesPerPixel,
9752 this.sampleRate
9753 );
9754
9755 this.ee.emit("scroll");
9756 },
9757 hook: new ScrollHook(this),
9758 },
9759 trackElements
9760 );
9761 }
9762
9763 render() {
9764 const containerChildren = [];
9765
9766 if (this.showTimescale) {
9767 containerChildren.push(this.renderTimeScale());
9768 }
9769
9770 containerChildren.push(this.renderTrackSection());
9771
9772 if (this.annotationList.length) {
9773 containerChildren.push(this.renderAnnotations());
9774 }
9775
9776 return h_default()(
9777 "div.playlist",
9778 {
9779 attributes: {
9780 style: "overflow: hidden; position: relative;",
9781 },
9782 },
9783 containerChildren
9784 );
9785 }
9786
9787 getInfo() {
9788 const info = [];
9789
9790 this.tracks.forEach((track) => {
9791 info.push(track.getTrackDetails());
9792 });
9793
9794 return info;
9795 }
9796});
9797
9798;// CONCATENATED MODULE: ./src/app.js
9799
9800
9801
9802
9803
9804function init(options = {}, ee = event_emitter_default()()) {
9805 if (options.container === undefined) {
9806 throw new Error("DOM element container must be given.");
9807 }
9808
9809 window.OfflineAudioContext =
9810 window.OfflineAudioContext || window.webkitOfflineAudioContext;
9811 window.AudioContext = window.AudioContext || window.webkitAudioContext;
9812
9813 const audioContext = new window.AudioContext();
9814
9815 const defaults = {
9816 ac: audioContext,
9817 sampleRate: audioContext.sampleRate,
9818 samplesPerPixel: 4096,
9819 mono: true,
9820 fadeType: "logarithmic",
9821 exclSolo: false,
9822 timescale: false,
9823 controls: {
9824 show: false,
9825 width: 150,
9826 widgets: {
9827 muteOrSolo: true,
9828 volume: true,
9829 stereoPan: true,
9830 collapse: true,
9831 remove: true,
9832 },
9833 },
9834 colors: {
9835 waveOutlineColor: "white",
9836 timeColor: "grey",
9837 fadeColor: "black",
9838 },
9839 seekStyle: "line",
9840 waveHeight: 128,
9841 collapsedWaveHeight: 30,
9842 barWidth: 1,
9843 barGap: 0,
9844 state: "cursor",
9845 zoomLevels: [512, 1024, 2048, 4096],
9846 annotationList: {
9847 annotations: [],
9848 controls: [],
9849 editable: false,
9850 linkEndpoints: false,
9851 isContinuousPlay: false,
9852 },
9853 isAutomaticScroll: false,
9854 };
9855
9856 const config = lodash_defaultsdeep_default()({}, options, defaults);
9857 const zoomIndex = config.zoomLevels.indexOf(config.samplesPerPixel);
9858
9859 if (zoomIndex === -1) {
9860 throw new Error(
9861 "initial samplesPerPixel must be included in array zoomLevels"
9862 );
9863 }
9864
9865 const playlist = new Playlist();
9866 playlist.setSampleRate(config.sampleRate);
9867 playlist.setSamplesPerPixel(config.samplesPerPixel);
9868 playlist.setAudioContext(config.ac);
9869 playlist.setEventEmitter(ee);
9870 playlist.setUpEventEmitter();
9871 playlist.setTimeSelection(0, 0);
9872 playlist.setState(config.state);
9873 playlist.setControlOptions(config.controls);
9874 playlist.setWaveHeight(config.waveHeight);
9875 playlist.setCollapsedWaveHeight(config.collapsedWaveHeight);
9876 playlist.setColors(config.colors);
9877 playlist.setZoomLevels(config.zoomLevels);
9878 playlist.setZoomIndex(zoomIndex);
9879 playlist.setMono(config.mono);
9880 playlist.setExclSolo(config.exclSolo);
9881 playlist.setShowTimeScale(config.timescale);
9882 playlist.setSeekStyle(config.seekStyle);
9883 playlist.setAnnotations(config.annotationList);
9884 playlist.setBarGap(config.barGap);
9885 playlist.setBarWidth(config.barWidth);
9886 playlist.isAutomaticScroll = config.isAutomaticScroll;
9887 playlist.isContinuousPlay = config.isContinuousPlay;
9888 playlist.linkedEndpoints = config.linkedEndpoints;
9889
9890 // take care of initial virtual dom rendering.
9891
9892 const tree = playlist.render();
9893 const rootNode = create_element_default()(tree);
9894
9895 config.container.appendChild(rootNode);
9896 playlist.tree = tree;
9897 playlist.rootNode = rootNode;
9898
9899 return playlist;
9900}
9901
9902/* harmony default export */ function app(options = {}, ee = event_emitter_default()()) {
9903 return init(options, ee);
9904}
9905
9906})();
9907
9908WaveformPlaylist = __webpack_exports__;
9909/******/ })()
9910;
\No newline at end of file