UNPKG

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