UNPKG

505 kBJavaScriptView Raw
1/**
2 * vis-graph3d
3 * https://visjs.github.io/vis-graph3d/
4 *
5 * Create interactive, animated 3d graphs. Surfaces, lines, dots and block styling out of the box.
6 *
7 * @version 6.0.2
8 * @date 2021-08-22T15:00:39.032Z
9 *
10 * @copyright (c) 2011-2017 Almende B.V, http://almende.com
11 * @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
12 *
13 * @license
14 * vis.js is dual licensed under both
15 *
16 * 1. The Apache 2.0 License
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * and
20 *
21 * 2. The MIT License
22 * http://opensource.org/licenses/MIT
23 *
24 * vis.js may be distributed under either license.
25 */
26
27var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
28
29var check = function (it) {
30 return it && it.Math == Math && it;
31}; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
32
33
34var global$i = // eslint-disable-next-line es/no-global-this -- safe
35check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || // eslint-disable-next-line no-restricted-globals -- safe
36check(typeof self == 'object' && self) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || // eslint-disable-next-line no-new-func -- fallback
37function () {
38 return this;
39}() || Function('return this')();
40
41var objectGetOwnPropertyDescriptor = {};
42
43var fails$l = function (exec) {
44 try {
45 return !!exec();
46 } catch (error) {
47 return true;
48 }
49};
50
51var fails$k = fails$l; // Detect IE8's incomplete defineProperty implementation
52
53var descriptors = !fails$k(function () {
54 // eslint-disable-next-line es/no-object-defineproperty -- required for testing
55 return Object.defineProperty({}, 1, {
56 get: function () {
57 return 7;
58 }
59 })[1] != 7;
60});
61
62var objectPropertyIsEnumerable = {};
63
64var $propertyIsEnumerable$1 = {}.propertyIsEnumerable; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
65
66var getOwnPropertyDescriptor$5 = Object.getOwnPropertyDescriptor; // Nashorn ~ JDK8 bug
67
68var NASHORN_BUG = getOwnPropertyDescriptor$5 && !$propertyIsEnumerable$1.call({
69 1: 2
70}, 1); // `Object.prototype.propertyIsEnumerable` method implementation
71// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
72
73objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
74 var descriptor = getOwnPropertyDescriptor$5(this, V);
75 return !!descriptor && descriptor.enumerable;
76} : $propertyIsEnumerable$1;
77
78var createPropertyDescriptor$5 = function (bitmap, value) {
79 return {
80 enumerable: !(bitmap & 1),
81 configurable: !(bitmap & 2),
82 writable: !(bitmap & 4),
83 value: value
84 };
85};
86
87var toString$a = {}.toString;
88
89var classofRaw$1 = function (it) {
90 return toString$a.call(it).slice(8, -1);
91};
92
93var fails$j = fails$l;
94var classof$b = classofRaw$1;
95var split = ''.split; // fallback for non-array-like ES3 and non-enumerable old V8 strings
96
97var indexedObject = fails$j(function () {
98 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
99 // eslint-disable-next-line no-prototype-builtins -- safe
100 return !Object('z').propertyIsEnumerable(0);
101}) ? function (it) {
102 return classof$b(it) == 'String' ? split.call(it, '') : Object(it);
103} : Object;
104
105// https://tc39.es/ecma262/#sec-requireobjectcoercible
106
107var requireObjectCoercible$5 = function (it) {
108 if (it == undefined) throw TypeError("Can't call method on " + it);
109 return it;
110};
111
112var IndexedObject$3 = indexedObject;
113var requireObjectCoercible$4 = requireObjectCoercible$5;
114
115var toIndexedObject$a = function (it) {
116 return IndexedObject$3(requireObjectCoercible$4(it));
117};
118
119var isObject$f = function (it) {
120 return typeof it === 'object' ? it !== null : typeof it === 'function';
121};
122
123var path$s = {};
124
125var path$r = path$s;
126var global$h = global$i;
127
128var aFunction$7 = function (variable) {
129 return typeof variable == 'function' ? variable : undefined;
130};
131
132var getBuiltIn$8 = function (namespace, method) {
133 return arguments.length < 2 ? aFunction$7(path$r[namespace]) || aFunction$7(global$h[namespace]) : path$r[namespace] && path$r[namespace][method] || global$h[namespace] && global$h[namespace][method];
134};
135
136var getBuiltIn$7 = getBuiltIn$8;
137var engineUserAgent = getBuiltIn$7('navigator', 'userAgent') || '';
138
139var global$g = global$i;
140var userAgent$3 = engineUserAgent;
141var process = global$g.process;
142var Deno = global$g.Deno;
143var versions = process && process.versions || Deno && Deno.version;
144var v8 = versions && versions.v8;
145var match, version;
146
147if (v8) {
148 match = v8.split('.');
149 version = match[0] < 4 ? 1 : match[0] + match[1];
150} else if (userAgent$3) {
151 match = userAgent$3.match(/Edge\/(\d+)/);
152
153 if (!match || match[1] >= 74) {
154 match = userAgent$3.match(/Chrome\/(\d+)/);
155 if (match) version = match[1];
156 }
157}
158
159var engineV8Version = version && +version;
160
161/* eslint-disable es/no-symbol -- required for testing */
162var V8_VERSION$2 = engineV8Version;
163var fails$i = fails$l; // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
164
165var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$i(function () {
166 var symbol = Symbol(); // Chrome 38 Symbol has incorrect toString conversion
167 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
168
169 return !String(symbol) || !(Object(symbol) instanceof Symbol) || // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
170 !Symbol.sham && V8_VERSION$2 && V8_VERSION$2 < 41;
171});
172
173/* eslint-disable es/no-symbol -- required for testing */
174var NATIVE_SYMBOL$2 = nativeSymbol;
175var useSymbolAsUid = NATIVE_SYMBOL$2 && !Symbol.sham && typeof Symbol.iterator == 'symbol';
176
177var getBuiltIn$6 = getBuiltIn$8;
178var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
179var isSymbol$4 = USE_SYMBOL_AS_UID$1 ? function (it) {
180 return typeof it == 'symbol';
181} : function (it) {
182 var $Symbol = getBuiltIn$6('Symbol');
183 return typeof $Symbol == 'function' && Object(it) instanceof $Symbol;
184};
185
186var isObject$e = isObject$f; // `OrdinaryToPrimitive` abstract operation
187// https://tc39.es/ecma262/#sec-ordinarytoprimitive
188
189var ordinaryToPrimitive$1 = function (input, pref) {
190 var fn, val;
191 if (pref === 'string' && typeof (fn = input.toString) == 'function' && !isObject$e(val = fn.call(input))) return val;
192 if (typeof (fn = input.valueOf) == 'function' && !isObject$e(val = fn.call(input))) return val;
193 if (pref !== 'string' && typeof (fn = input.toString) == 'function' && !isObject$e(val = fn.call(input))) return val;
194 throw TypeError("Can't convert object to primitive value");
195};
196
197var shared$4 = {exports: {}};
198
199var global$f = global$i;
200
201var setGlobal$1 = function (key, value) {
202 try {
203 // eslint-disable-next-line es/no-object-defineproperty -- safe
204 Object.defineProperty(global$f, key, {
205 value: value,
206 configurable: true,
207 writable: true
208 });
209 } catch (error) {
210 global$f[key] = value;
211 }
212
213 return value;
214};
215
216var global$e = global$i;
217var setGlobal = setGlobal$1;
218var SHARED = '__core-js_shared__';
219var store$3 = global$e[SHARED] || setGlobal(SHARED, {});
220var sharedStore = store$3;
221
222var store$2 = sharedStore;
223(shared$4.exports = function (key, value) {
224 return store$2[key] || (store$2[key] = value !== undefined ? value : {});
225})('versions', []).push({
226 version: '3.16.1',
227 mode: 'pure' ,
228 copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
229});
230
231var requireObjectCoercible$3 = requireObjectCoercible$5; // `ToObject` abstract operation
232// https://tc39.es/ecma262/#sec-toobject
233
234var toObject$e = function (argument) {
235 return Object(requireObjectCoercible$3(argument));
236};
237
238var toObject$d = toObject$e;
239var hasOwnProperty = {}.hasOwnProperty;
240
241var has$b = Object.hasOwn || function hasOwn(it, key) {
242 return hasOwnProperty.call(toObject$d(it), key);
243};
244
245var id$1 = 0;
246var postfix = Math.random();
247
248var uid$4 = function (key) {
249 return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id$1 + postfix).toString(36);
250};
251
252var global$d = global$i;
253var shared$3 = shared$4.exports;
254var has$a = has$b;
255var uid$3 = uid$4;
256var NATIVE_SYMBOL$1 = nativeSymbol;
257var USE_SYMBOL_AS_UID = useSymbolAsUid;
258var WellKnownSymbolsStore$1 = shared$3('wks');
259var Symbol$1 = global$d.Symbol;
260var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$3;
261
262var wellKnownSymbol$j = function (name) {
263 if (!has$a(WellKnownSymbolsStore$1, name) || !(NATIVE_SYMBOL$1 || typeof WellKnownSymbolsStore$1[name] == 'string')) {
264 if (NATIVE_SYMBOL$1 && has$a(Symbol$1, name)) {
265 WellKnownSymbolsStore$1[name] = Symbol$1[name];
266 } else {
267 WellKnownSymbolsStore$1[name] = createWellKnownSymbol('Symbol.' + name);
268 }
269 }
270
271 return WellKnownSymbolsStore$1[name];
272};
273
274var isObject$d = isObject$f;
275var isSymbol$3 = isSymbol$4;
276var ordinaryToPrimitive = ordinaryToPrimitive$1;
277var wellKnownSymbol$i = wellKnownSymbol$j;
278var TO_PRIMITIVE$1 = wellKnownSymbol$i('toPrimitive'); // `ToPrimitive` abstract operation
279// https://tc39.es/ecma262/#sec-toprimitive
280
281var toPrimitive$1 = function (input, pref) {
282 if (!isObject$d(input) || isSymbol$3(input)) return input;
283 var exoticToPrim = input[TO_PRIMITIVE$1];
284 var result;
285
286 if (exoticToPrim !== undefined) {
287 if (pref === undefined) pref = 'default';
288 result = exoticToPrim.call(input, pref);
289 if (!isObject$d(result) || isSymbol$3(result)) return result;
290 throw TypeError("Can't convert object to primitive value");
291 }
292
293 if (pref === undefined) pref = 'number';
294 return ordinaryToPrimitive(input, pref);
295};
296
297var toPrimitive = toPrimitive$1;
298var isSymbol$2 = isSymbol$4; // `ToPropertyKey` abstract operation
299// https://tc39.es/ecma262/#sec-topropertykey
300
301var toPropertyKey$4 = function (argument) {
302 var key = toPrimitive(argument, 'string');
303 return isSymbol$2(key) ? key : String(key);
304};
305
306var global$c = global$i;
307var isObject$c = isObject$f;
308var document$1 = global$c.document; // typeof document.createElement is 'object' in old IE
309
310var EXISTS = isObject$c(document$1) && isObject$c(document$1.createElement);
311
312var documentCreateElement$1 = function (it) {
313 return EXISTS ? document$1.createElement(it) : {};
314};
315
316var DESCRIPTORS$f = descriptors;
317var fails$h = fails$l;
318var createElement = documentCreateElement$1; // Thank's IE8 for his funny defineProperty
319
320var ie8DomDefine = !DESCRIPTORS$f && !fails$h(function () {
321 // eslint-disable-next-line es/no-object-defineproperty -- requied for testing
322 return Object.defineProperty(createElement('div'), 'a', {
323 get: function () {
324 return 7;
325 }
326 }).a != 7;
327});
328
329var DESCRIPTORS$e = descriptors;
330var propertyIsEnumerableModule$2 = objectPropertyIsEnumerable;
331var createPropertyDescriptor$4 = createPropertyDescriptor$5;
332var toIndexedObject$9 = toIndexedObject$a;
333var toPropertyKey$3 = toPropertyKey$4;
334var has$9 = has$b;
335var IE8_DOM_DEFINE$1 = ie8DomDefine; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
336
337var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method
338// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
339
340objectGetOwnPropertyDescriptor.f = DESCRIPTORS$e ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
341 O = toIndexedObject$9(O);
342 P = toPropertyKey$3(P);
343 if (IE8_DOM_DEFINE$1) try {
344 return $getOwnPropertyDescriptor$1(O, P);
345 } catch (error) {
346 /* empty */
347 }
348 if (has$9(O, P)) return createPropertyDescriptor$4(!propertyIsEnumerableModule$2.f.call(O, P), O[P]);
349};
350
351var fails$g = fails$l;
352var replacement = /#|\.prototype\./;
353
354var isForced$1 = function (feature, detection) {
355 var value = data[normalize(feature)];
356 return value == POLYFILL ? true : value == NATIVE ? false : typeof detection == 'function' ? fails$g(detection) : !!detection;
357};
358
359var normalize = isForced$1.normalize = function (string) {
360 return String(string).replace(replacement, '.').toLowerCase();
361};
362
363var data = isForced$1.data = {};
364var NATIVE = isForced$1.NATIVE = 'N';
365var POLYFILL = isForced$1.POLYFILL = 'P';
366var isForced_1 = isForced$1;
367
368var aFunction$6 = function (it) {
369 if (typeof it != 'function') {
370 throw TypeError(String(it) + ' is not a function');
371 }
372
373 return it;
374};
375
376var aFunction$5 = aFunction$6; // optional / simple context binding
377
378var functionBindContext = function (fn, that, length) {
379 aFunction$5(fn);
380 if (that === undefined) return fn;
381
382 switch (length) {
383 case 0:
384 return function () {
385 return fn.call(that);
386 };
387
388 case 1:
389 return function (a) {
390 return fn.call(that, a);
391 };
392
393 case 2:
394 return function (a, b) {
395 return fn.call(that, a, b);
396 };
397
398 case 3:
399 return function (a, b, c) {
400 return fn.call(that, a, b, c);
401 };
402 }
403
404 return function () {
405 return fn.apply(that, arguments);
406 };
407};
408
409var objectDefineProperty = {};
410
411var isObject$b = isObject$f;
412
413var anObject$b = function (it) {
414 if (!isObject$b(it)) {
415 throw TypeError(String(it) + ' is not an object');
416 }
417
418 return it;
419};
420
421var DESCRIPTORS$d = descriptors;
422var IE8_DOM_DEFINE = ie8DomDefine;
423var anObject$a = anObject$b;
424var toPropertyKey$2 = toPropertyKey$4; // eslint-disable-next-line es/no-object-defineproperty -- safe
425
426var $defineProperty$1 = Object.defineProperty; // `Object.defineProperty` method
427// https://tc39.es/ecma262/#sec-object.defineproperty
428
429objectDefineProperty.f = DESCRIPTORS$d ? $defineProperty$1 : function defineProperty(O, P, Attributes) {
430 anObject$a(O);
431 P = toPropertyKey$2(P);
432 anObject$a(Attributes);
433 if (IE8_DOM_DEFINE) try {
434 return $defineProperty$1(O, P, Attributes);
435 } catch (error) {
436 /* empty */
437 }
438 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
439 if ('value' in Attributes) O[P] = Attributes.value;
440 return O;
441};
442
443var DESCRIPTORS$c = descriptors;
444var definePropertyModule$4 = objectDefineProperty;
445var createPropertyDescriptor$3 = createPropertyDescriptor$5;
446var createNonEnumerableProperty$9 = DESCRIPTORS$c ? function (object, key, value) {
447 return definePropertyModule$4.f(object, key, createPropertyDescriptor$3(1, value));
448} : function (object, key, value) {
449 object[key] = value;
450 return object;
451};
452
453var global$b = global$i;
454var getOwnPropertyDescriptor$4 = objectGetOwnPropertyDescriptor.f;
455var isForced = isForced_1;
456var path$q = path$s;
457var bind$b = functionBindContext;
458var createNonEnumerableProperty$8 = createNonEnumerableProperty$9;
459var has$8 = has$b;
460
461var wrapConstructor = function (NativeConstructor) {
462 var Wrapper = function (a, b, c) {
463 if (this instanceof NativeConstructor) {
464 switch (arguments.length) {
465 case 0:
466 return new NativeConstructor();
467
468 case 1:
469 return new NativeConstructor(a);
470
471 case 2:
472 return new NativeConstructor(a, b);
473 }
474
475 return new NativeConstructor(a, b, c);
476 }
477
478 return NativeConstructor.apply(this, arguments);
479 };
480
481 Wrapper.prototype = NativeConstructor.prototype;
482 return Wrapper;
483};
484/*
485 options.target - name of the target object
486 options.global - target is the global object
487 options.stat - export as static methods of target
488 options.proto - export as prototype methods of target
489 options.real - real prototype method for the `pure` version
490 options.forced - export even if the native feature is available
491 options.bind - bind methods to the target, required for the `pure` version
492 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
493 options.unsafe - use the simple assignment of property instead of delete + defineProperty
494 options.sham - add a flag to not completely full polyfills
495 options.enumerable - export as enumerable property
496 options.noTargetGet - prevent calling a getter on target
497*/
498
499
500var _export = function (options, source) {
501 var TARGET = options.target;
502 var GLOBAL = options.global;
503 var STATIC = options.stat;
504 var PROTO = options.proto;
505 var nativeSource = GLOBAL ? global$b : STATIC ? global$b[TARGET] : (global$b[TARGET] || {}).prototype;
506 var target = GLOBAL ? path$q : path$q[TARGET] || (path$q[TARGET] = {});
507 var targetPrototype = target.prototype;
508 var FORCED, USE_NATIVE, VIRTUAL_PROTOTYPE;
509 var key, sourceProperty, targetProperty, nativeProperty, resultProperty, descriptor;
510
511 for (key in source) {
512 FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contains in native
513
514 USE_NATIVE = !FORCED && nativeSource && has$8(nativeSource, key);
515 targetProperty = target[key];
516 if (USE_NATIVE) if (options.noTargetGet) {
517 descriptor = getOwnPropertyDescriptor$4(nativeSource, key);
518 nativeProperty = descriptor && descriptor.value;
519 } else nativeProperty = nativeSource[key]; // export native or implementation
520
521 sourceProperty = USE_NATIVE && nativeProperty ? nativeProperty : source[key];
522 if (USE_NATIVE && typeof targetProperty === typeof sourceProperty) continue; // bind timers to global for call from export context
523
524 if (options.bind && USE_NATIVE) resultProperty = bind$b(sourceProperty, global$b); // wrap global constructors for prevent changs in this version
525 else if (options.wrap && USE_NATIVE) resultProperty = wrapConstructor(sourceProperty); // make static versions for prototype methods
526 else if (PROTO && typeof sourceProperty == 'function') resultProperty = bind$b(Function.call, sourceProperty); // default case
527 else resultProperty = sourceProperty; // add a flag to not completely full polyfills
528
529 if (options.sham || sourceProperty && sourceProperty.sham || targetProperty && targetProperty.sham) {
530 createNonEnumerableProperty$8(resultProperty, 'sham', true);
531 }
532
533 target[key] = resultProperty;
534
535 if (PROTO) {
536 VIRTUAL_PROTOTYPE = TARGET + 'Prototype';
537
538 if (!has$8(path$q, VIRTUAL_PROTOTYPE)) {
539 createNonEnumerableProperty$8(path$q, VIRTUAL_PROTOTYPE, {});
540 } // export virtual prototype methods
541
542
543 path$q[VIRTUAL_PROTOTYPE][key] = sourceProperty; // export real prototype methods
544
545 if (options.real && targetPrototype && !targetPrototype[key]) {
546 createNonEnumerableProperty$8(targetPrototype, key, sourceProperty);
547 }
548 }
549 }
550};
551
552var classof$a = classofRaw$1; // `IsArray` abstract operation
553// https://tc39.es/ecma262/#sec-isarray
554// eslint-disable-next-line es/no-array-isarray -- safe
555
556var isArray$c = Array.isArray || function isArray(arg) {
557 return classof$a(arg) == 'Array';
558};
559
560var ceil = Math.ceil;
561var floor$1 = Math.floor; // `ToInteger` abstract operation
562// https://tc39.es/ecma262/#sec-tointeger
563
564var toInteger$4 = function (argument) {
565 return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor$1 : ceil)(argument);
566};
567
568var toInteger$3 = toInteger$4;
569var min$2 = Math.min; // `ToLength` abstract operation
570// https://tc39.es/ecma262/#sec-tolength
571
572var toLength$c = function (argument) {
573 return argument > 0 ? min$2(toInteger$3(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
574};
575
576var toPropertyKey$1 = toPropertyKey$4;
577var definePropertyModule$3 = objectDefineProperty;
578var createPropertyDescriptor$2 = createPropertyDescriptor$5;
579
580var createProperty$5 = function (object, key, value) {
581 var propertyKey = toPropertyKey$1(key);
582 if (propertyKey in object) definePropertyModule$3.f(object, propertyKey, createPropertyDescriptor$2(0, value));else object[propertyKey] = value;
583};
584
585var isObject$a = isObject$f;
586var isArray$b = isArray$c;
587var wellKnownSymbol$h = wellKnownSymbol$j;
588var SPECIES$3 = wellKnownSymbol$h('species'); // a part of `ArraySpeciesCreate` abstract operation
589// https://tc39.es/ecma262/#sec-arrayspeciescreate
590
591var arraySpeciesConstructor$1 = function (originalArray) {
592 var C;
593
594 if (isArray$b(originalArray)) {
595 C = originalArray.constructor; // cross-realm fallback
596
597 if (typeof C == 'function' && (C === Array || isArray$b(C.prototype))) C = undefined;else if (isObject$a(C)) {
598 C = C[SPECIES$3];
599 if (C === null) C = undefined;
600 }
601 }
602
603 return C === undefined ? Array : C;
604};
605
606var arraySpeciesConstructor = arraySpeciesConstructor$1; // `ArraySpeciesCreate` abstract operation
607// https://tc39.es/ecma262/#sec-arrayspeciescreate
608
609var arraySpeciesCreate$4 = function (originalArray, length) {
610 return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
611};
612
613var fails$f = fails$l;
614var wellKnownSymbol$g = wellKnownSymbol$j;
615var V8_VERSION$1 = engineV8Version;
616var SPECIES$2 = wellKnownSymbol$g('species');
617
618var arrayMethodHasSpeciesSupport$5 = function (METHOD_NAME) {
619 // We can't use this feature detection in V8 since it causes
620 // deoptimization and serious performance degradation
621 // https://github.com/zloirock/core-js/issues/677
622 return V8_VERSION$1 >= 51 || !fails$f(function () {
623 var array = [];
624 var constructor = array.constructor = {};
625
626 constructor[SPECIES$2] = function () {
627 return {
628 foo: 1
629 };
630 };
631
632 return array[METHOD_NAME](Boolean).foo !== 1;
633 });
634};
635
636var $$F = _export;
637var fails$e = fails$l;
638var isArray$a = isArray$c;
639var isObject$9 = isObject$f;
640var toObject$c = toObject$e;
641var toLength$b = toLength$c;
642var createProperty$4 = createProperty$5;
643var arraySpeciesCreate$3 = arraySpeciesCreate$4;
644var arrayMethodHasSpeciesSupport$4 = arrayMethodHasSpeciesSupport$5;
645var wellKnownSymbol$f = wellKnownSymbol$j;
646var V8_VERSION = engineV8Version;
647var IS_CONCAT_SPREADABLE = wellKnownSymbol$f('isConcatSpreadable');
648var MAX_SAFE_INTEGER$1 = 0x1FFFFFFFFFFFFF;
649var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded'; // We can't use this feature detection in V8 since it causes
650// deoptimization and serious performance degradation
651// https://github.com/zloirock/core-js/issues/679
652
653var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails$e(function () {
654 var array = [];
655 array[IS_CONCAT_SPREADABLE] = false;
656 return array.concat()[0] !== array;
657});
658var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport$4('concat');
659
660var isConcatSpreadable = function (O) {
661 if (!isObject$9(O)) return false;
662 var spreadable = O[IS_CONCAT_SPREADABLE];
663 return spreadable !== undefined ? !!spreadable : isArray$a(O);
664};
665
666var FORCED$6 = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT; // `Array.prototype.concat` method
667// https://tc39.es/ecma262/#sec-array.prototype.concat
668// with adding support of @@isConcatSpreadable and @@species
669
670$$F({
671 target: 'Array',
672 proto: true,
673 forced: FORCED$6
674}, {
675 // eslint-disable-next-line no-unused-vars -- required for `.length`
676 concat: function concat(arg) {
677 var O = toObject$c(this);
678 var A = arraySpeciesCreate$3(O, 0);
679 var n = 0;
680 var i, k, length, len, E;
681
682 for (i = -1, length = arguments.length; i < length; i++) {
683 E = i === -1 ? O : arguments[i];
684
685 if (isConcatSpreadable(E)) {
686 len = toLength$b(E.length);
687 if (n + len > MAX_SAFE_INTEGER$1) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
688
689 for (k = 0; k < len; k++, n++) if (k in E) createProperty$4(A, n, E[k]);
690 } else {
691 if (n >= MAX_SAFE_INTEGER$1) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
692 createProperty$4(A, n++, E);
693 }
694 }
695
696 A.length = n;
697 return A;
698 }
699});
700
701var isSymbol$1 = isSymbol$4;
702
703var toString$9 = function (argument) {
704 if (isSymbol$1(argument)) throw TypeError('Cannot convert a Symbol value to a string');
705 return String(argument);
706};
707
708var toInteger$2 = toInteger$4;
709var max$2 = Math.max;
710var min$1 = Math.min; // Helper for a popular repeating case of the spec:
711// Let integer be ? ToInteger(index).
712// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
713
714var toAbsoluteIndex$4 = function (index, length) {
715 var integer = toInteger$2(index);
716 return integer < 0 ? max$2(integer + length, 0) : min$1(integer, length);
717};
718
719var toIndexedObject$8 = toIndexedObject$a;
720var toLength$a = toLength$c;
721var toAbsoluteIndex$3 = toAbsoluteIndex$4; // `Array.prototype.{ indexOf, includes }` methods implementation
722
723var createMethod$5 = function (IS_INCLUDES) {
724 return function ($this, el, fromIndex) {
725 var O = toIndexedObject$8($this);
726 var length = toLength$a(O.length);
727 var index = toAbsoluteIndex$3(fromIndex, length);
728 var value; // Array#includes uses SameValueZero equality algorithm
729 // eslint-disable-next-line no-self-compare -- NaN check
730
731 if (IS_INCLUDES && el != el) while (length > index) {
732 value = O[index++]; // eslint-disable-next-line no-self-compare -- NaN check
733
734 if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not
735 } else for (; length > index; index++) {
736 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
737 }
738 return !IS_INCLUDES && -1;
739 };
740};
741
742var arrayIncludes$1 = {
743 // `Array.prototype.includes` method
744 // https://tc39.es/ecma262/#sec-array.prototype.includes
745 includes: createMethod$5(true),
746 // `Array.prototype.indexOf` method
747 // https://tc39.es/ecma262/#sec-array.prototype.indexof
748 indexOf: createMethod$5(false)
749};
750
751var hiddenKeys$6 = {};
752
753var has$7 = has$b;
754var toIndexedObject$7 = toIndexedObject$a;
755var indexOf$4 = arrayIncludes$1.indexOf;
756var hiddenKeys$5 = hiddenKeys$6;
757
758var objectKeysInternal = function (object, names) {
759 var O = toIndexedObject$7(object);
760 var i = 0;
761 var result = [];
762 var key;
763
764 for (key in O) !has$7(hiddenKeys$5, key) && has$7(O, key) && result.push(key); // Don't enum bug & hidden keys
765
766
767 while (names.length > i) if (has$7(O, key = names[i++])) {
768 ~indexOf$4(result, key) || result.push(key);
769 }
770
771 return result;
772};
773
774var enumBugKeys$3 = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf'];
775
776var internalObjectKeys$1 = objectKeysInternal;
777var enumBugKeys$2 = enumBugKeys$3; // `Object.keys` method
778// https://tc39.es/ecma262/#sec-object.keys
779// eslint-disable-next-line es/no-object-keys -- safe
780
781var objectKeys$4 = Object.keys || function keys(O) {
782 return internalObjectKeys$1(O, enumBugKeys$2);
783};
784
785var DESCRIPTORS$b = descriptors;
786var definePropertyModule$2 = objectDefineProperty;
787var anObject$9 = anObject$b;
788var objectKeys$3 = objectKeys$4; // `Object.defineProperties` method
789// https://tc39.es/ecma262/#sec-object.defineproperties
790// eslint-disable-next-line es/no-object-defineproperties -- safe
791
792var objectDefineProperties = DESCRIPTORS$b ? Object.defineProperties : function defineProperties(O, Properties) {
793 anObject$9(O);
794 var keys = objectKeys$3(Properties);
795 var length = keys.length;
796 var index = 0;
797 var key;
798
799 while (length > index) definePropertyModule$2.f(O, key = keys[index++], Properties[key]);
800
801 return O;
802};
803
804var getBuiltIn$5 = getBuiltIn$8;
805var html$1 = getBuiltIn$5('document', 'documentElement');
806
807var shared$2 = shared$4.exports;
808var uid$2 = uid$4;
809var keys$7 = shared$2('keys');
810
811var sharedKey$4 = function (key) {
812 return keys$7[key] || (keys$7[key] = uid$2(key));
813};
814
815/* global ActiveXObject -- old IE, WSH */
816var anObject$8 = anObject$b;
817var defineProperties$5 = objectDefineProperties;
818var enumBugKeys$1 = enumBugKeys$3;
819var hiddenKeys$4 = hiddenKeys$6;
820var html = html$1;
821var documentCreateElement = documentCreateElement$1;
822var sharedKey$3 = sharedKey$4;
823var GT = '>';
824var LT = '<';
825var PROTOTYPE$1 = 'prototype';
826var SCRIPT = 'script';
827var IE_PROTO$1 = sharedKey$3('IE_PROTO');
828
829var EmptyConstructor = function () {
830 /* empty */
831};
832
833var scriptTag = function (content) {
834 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
835}; // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
836
837
838var NullProtoObjectViaActiveX = function (activeXDocument) {
839 activeXDocument.write(scriptTag(''));
840 activeXDocument.close();
841 var temp = activeXDocument.parentWindow.Object;
842 activeXDocument = null; // avoid memory leak
843
844 return temp;
845}; // Create object with fake `null` prototype: use iframe Object with cleared prototype
846
847
848var NullProtoObjectViaIFrame = function () {
849 // Thrash, waste and sodomy: IE GC bug
850 var iframe = documentCreateElement('iframe');
851 var JS = 'java' + SCRIPT + ':';
852 var iframeDocument;
853
854 if (iframe.style) {
855 iframe.style.display = 'none';
856 html.appendChild(iframe); // https://github.com/zloirock/core-js/issues/475
857
858 iframe.src = String(JS);
859 iframeDocument = iframe.contentWindow.document;
860 iframeDocument.open();
861 iframeDocument.write(scriptTag('document.F=Object'));
862 iframeDocument.close();
863 return iframeDocument.F;
864 }
865}; // Check for document.domain and active x support
866// No need to use active x approach when document.domain is not set
867// see https://github.com/es-shims/es5-shim/issues/150
868// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
869// avoid IE GC bug
870
871
872var activeXDocument;
873
874var NullProtoObject = function () {
875 try {
876 activeXDocument = new ActiveXObject('htmlfile');
877 } catch (error) {
878 /* ignore */
879 }
880
881 NullProtoObject = document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : // old IE
882 NullProtoObjectViaIFrame() || NullProtoObjectViaActiveX(activeXDocument); // WSH
883
884 var length = enumBugKeys$1.length;
885
886 while (length--) delete NullProtoObject[PROTOTYPE$1][enumBugKeys$1[length]];
887
888 return NullProtoObject();
889};
890
891hiddenKeys$4[IE_PROTO$1] = true; // `Object.create` method
892// https://tc39.es/ecma262/#sec-object.create
893
894var objectCreate = Object.create || function create(O, Properties) {
895 var result;
896
897 if (O !== null) {
898 EmptyConstructor[PROTOTYPE$1] = anObject$8(O);
899 result = new EmptyConstructor();
900 EmptyConstructor[PROTOTYPE$1] = null; // add "__proto__" for Object.getPrototypeOf polyfill
901
902 result[IE_PROTO$1] = O;
903 } else result = NullProtoObject();
904
905 return Properties === undefined ? result : defineProperties$5(result, Properties);
906};
907
908var objectGetOwnPropertyNames = {};
909
910var internalObjectKeys = objectKeysInternal;
911var enumBugKeys = enumBugKeys$3;
912var hiddenKeys$3 = enumBugKeys.concat('length', 'prototype'); // `Object.getOwnPropertyNames` method
913// https://tc39.es/ecma262/#sec-object.getownpropertynames
914// eslint-disable-next-line es/no-object-getownpropertynames -- safe
915
916objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
917 return internalObjectKeys(O, hiddenKeys$3);
918};
919
920var objectGetOwnPropertyNamesExternal = {};
921
922/* eslint-disable es/no-object-getownpropertynames -- safe */
923var toIndexedObject$6 = toIndexedObject$a;
924var $getOwnPropertyNames$1 = objectGetOwnPropertyNames.f;
925var toString$8 = {}.toString;
926var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
927
928var getWindowNames = function (it) {
929 try {
930 return $getOwnPropertyNames$1(it);
931 } catch (error) {
932 return windowNames.slice();
933 }
934}; // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
935
936
937objectGetOwnPropertyNamesExternal.f = function getOwnPropertyNames(it) {
938 return windowNames && toString$8.call(it) == '[object Window]' ? getWindowNames(it) : $getOwnPropertyNames$1(toIndexedObject$6(it));
939};
940
941var objectGetOwnPropertySymbols = {};
942
943objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
944
945var createNonEnumerableProperty$7 = createNonEnumerableProperty$9;
946
947var redefine$3 = function (target, key, value, options) {
948 if (options && options.enumerable) target[key] = value;else createNonEnumerableProperty$7(target, key, value);
949};
950
951var wellKnownSymbolWrapped = {};
952
953var wellKnownSymbol$e = wellKnownSymbol$j;
954wellKnownSymbolWrapped.f = wellKnownSymbol$e;
955
956var path$p = path$s;
957var has$6 = has$b;
958var wrappedWellKnownSymbolModule$1 = wellKnownSymbolWrapped;
959var defineProperty$b = objectDefineProperty.f;
960
961var defineWellKnownSymbol$l = function (NAME) {
962 var Symbol = path$p.Symbol || (path$p.Symbol = {});
963 if (!has$6(Symbol, NAME)) defineProperty$b(Symbol, NAME, {
964 value: wrappedWellKnownSymbolModule$1.f(NAME)
965 });
966};
967
968var wellKnownSymbol$d = wellKnownSymbol$j;
969var TO_STRING_TAG$3 = wellKnownSymbol$d('toStringTag');
970var test$2 = {};
971test$2[TO_STRING_TAG$3] = 'z';
972var toStringTagSupport = String(test$2) === '[object z]';
973
974var TO_STRING_TAG_SUPPORT$2 = toStringTagSupport;
975var classofRaw = classofRaw$1;
976var wellKnownSymbol$c = wellKnownSymbol$j;
977var TO_STRING_TAG$2 = wellKnownSymbol$c('toStringTag'); // ES3 wrong here
978
979var CORRECT_ARGUMENTS = classofRaw(function () {
980 return arguments;
981}()) == 'Arguments'; // fallback for IE11 Script Access Denied error
982
983var tryGet = function (it, key) {
984 try {
985 return it[key];
986 } catch (error) {
987 /* empty */
988 }
989}; // getting tag from ES6+ `Object.prototype.toString`
990
991
992var classof$9 = TO_STRING_TAG_SUPPORT$2 ? classofRaw : function (it) {
993 var O, tag, result;
994 return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case
995 : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$2)) == 'string' ? tag // builtinTag case
996 : CORRECT_ARGUMENTS ? classofRaw(O) // ES3 arguments fallback
997 : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
998};
999
1000var TO_STRING_TAG_SUPPORT$1 = toStringTagSupport;
1001var classof$8 = classof$9; // `Object.prototype.toString` method implementation
1002// https://tc39.es/ecma262/#sec-object.prototype.tostring
1003
1004var objectToString = TO_STRING_TAG_SUPPORT$1 ? {}.toString : function toString() {
1005 return '[object ' + classof$8(this) + ']';
1006};
1007
1008var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1009var defineProperty$a = objectDefineProperty.f;
1010var createNonEnumerableProperty$6 = createNonEnumerableProperty$9;
1011var has$5 = has$b;
1012var toString$7 = objectToString;
1013var wellKnownSymbol$b = wellKnownSymbol$j;
1014var TO_STRING_TAG$1 = wellKnownSymbol$b('toStringTag');
1015
1016var setToStringTag$5 = function (it, TAG, STATIC, SET_METHOD) {
1017 if (it) {
1018 var target = STATIC ? it : it.prototype;
1019
1020 if (!has$5(target, TO_STRING_TAG$1)) {
1021 defineProperty$a(target, TO_STRING_TAG$1, {
1022 configurable: true,
1023 value: TAG
1024 });
1025 }
1026
1027 if (SET_METHOD && !TO_STRING_TAG_SUPPORT) {
1028 createNonEnumerableProperty$6(target, 'toString', toString$7);
1029 }
1030 }
1031};
1032
1033var store$1 = sharedStore;
1034var functionToString = Function.toString; // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
1035
1036if (typeof store$1.inspectSource != 'function') {
1037 store$1.inspectSource = function (it) {
1038 return functionToString.call(it);
1039 };
1040}
1041
1042var inspectSource$1 = store$1.inspectSource;
1043
1044var global$a = global$i;
1045var inspectSource = inspectSource$1;
1046var WeakMap$1 = global$a.WeakMap;
1047var nativeWeakMap = typeof WeakMap$1 === 'function' && /native code/.test(inspectSource(WeakMap$1));
1048
1049var NATIVE_WEAK_MAP = nativeWeakMap;
1050var global$9 = global$i;
1051var isObject$8 = isObject$f;
1052var createNonEnumerableProperty$5 = createNonEnumerableProperty$9;
1053var objectHas = has$b;
1054var shared$1 = sharedStore;
1055var sharedKey$2 = sharedKey$4;
1056var hiddenKeys$2 = hiddenKeys$6;
1057var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
1058var WeakMap = global$9.WeakMap;
1059var set$3, get, has$4;
1060
1061var enforce = function (it) {
1062 return has$4(it) ? get(it) : set$3(it, {});
1063};
1064
1065var getterFor = function (TYPE) {
1066 return function (it) {
1067 var state;
1068
1069 if (!isObject$8(it) || (state = get(it)).type !== TYPE) {
1070 throw TypeError('Incompatible receiver, ' + TYPE + ' required');
1071 }
1072
1073 return state;
1074 };
1075};
1076
1077if (NATIVE_WEAK_MAP || shared$1.state) {
1078 var store = shared$1.state || (shared$1.state = new WeakMap());
1079 var wmget = store.get;
1080 var wmhas = store.has;
1081 var wmset = store.set;
1082
1083 set$3 = function (it, metadata) {
1084 if (wmhas.call(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
1085 metadata.facade = it;
1086 wmset.call(store, it, metadata);
1087 return metadata;
1088 };
1089
1090 get = function (it) {
1091 return wmget.call(store, it) || {};
1092 };
1093
1094 has$4 = function (it) {
1095 return wmhas.call(store, it);
1096 };
1097} else {
1098 var STATE = sharedKey$2('state');
1099 hiddenKeys$2[STATE] = true;
1100
1101 set$3 = function (it, metadata) {
1102 if (objectHas(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
1103 metadata.facade = it;
1104 createNonEnumerableProperty$5(it, STATE, metadata);
1105 return metadata;
1106 };
1107
1108 get = function (it) {
1109 return objectHas(it, STATE) ? it[STATE] : {};
1110 };
1111
1112 has$4 = function (it) {
1113 return objectHas(it, STATE);
1114 };
1115}
1116
1117var internalState = {
1118 set: set$3,
1119 get: get,
1120 has: has$4,
1121 enforce: enforce,
1122 getterFor: getterFor
1123};
1124
1125var bind$a = functionBindContext;
1126var IndexedObject$2 = indexedObject;
1127var toObject$b = toObject$e;
1128var toLength$9 = toLength$c;
1129var arraySpeciesCreate$2 = arraySpeciesCreate$4;
1130var push = [].push; // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
1131
1132var createMethod$4 = function (TYPE) {
1133 var IS_MAP = TYPE == 1;
1134 var IS_FILTER = TYPE == 2;
1135 var IS_SOME = TYPE == 3;
1136 var IS_EVERY = TYPE == 4;
1137 var IS_FIND_INDEX = TYPE == 6;
1138 var IS_FILTER_REJECT = TYPE == 7;
1139 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
1140 return function ($this, callbackfn, that, specificCreate) {
1141 var O = toObject$b($this);
1142 var self = IndexedObject$2(O);
1143 var boundFunction = bind$a(callbackfn, that, 3);
1144 var length = toLength$9(self.length);
1145 var index = 0;
1146 var create = specificCreate || arraySpeciesCreate$2;
1147 var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
1148 var value, result;
1149
1150 for (; length > index; index++) if (NO_HOLES || index in self) {
1151 value = self[index];
1152 result = boundFunction(value, index, O);
1153
1154 if (TYPE) {
1155 if (IS_MAP) target[index] = result; // map
1156 else if (result) switch (TYPE) {
1157 case 3:
1158 return true;
1159 // some
1160
1161 case 5:
1162 return value;
1163 // find
1164
1165 case 6:
1166 return index;
1167 // findIndex
1168
1169 case 2:
1170 push.call(target, value);
1171 // filter
1172 } else switch (TYPE) {
1173 case 4:
1174 return false;
1175 // every
1176
1177 case 7:
1178 push.call(target, value);
1179 // filterReject
1180 }
1181 }
1182 }
1183
1184 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
1185 };
1186};
1187
1188var arrayIteration = {
1189 // `Array.prototype.forEach` method
1190 // https://tc39.es/ecma262/#sec-array.prototype.foreach
1191 forEach: createMethod$4(0),
1192 // `Array.prototype.map` method
1193 // https://tc39.es/ecma262/#sec-array.prototype.map
1194 map: createMethod$4(1),
1195 // `Array.prototype.filter` method
1196 // https://tc39.es/ecma262/#sec-array.prototype.filter
1197 filter: createMethod$4(2),
1198 // `Array.prototype.some` method
1199 // https://tc39.es/ecma262/#sec-array.prototype.some
1200 some: createMethod$4(3),
1201 // `Array.prototype.every` method
1202 // https://tc39.es/ecma262/#sec-array.prototype.every
1203 every: createMethod$4(4),
1204 // `Array.prototype.find` method
1205 // https://tc39.es/ecma262/#sec-array.prototype.find
1206 find: createMethod$4(5),
1207 // `Array.prototype.findIndex` method
1208 // https://tc39.es/ecma262/#sec-array.prototype.findIndex
1209 findIndex: createMethod$4(6),
1210 // `Array.prototype.filterReject` method
1211 // https://github.com/tc39/proposal-array-filtering
1212 filterReject: createMethod$4(7)
1213};
1214
1215var $$E = _export;
1216var global$8 = global$i;
1217var getBuiltIn$4 = getBuiltIn$8;
1218var DESCRIPTORS$a = descriptors;
1219var NATIVE_SYMBOL = nativeSymbol;
1220var fails$d = fails$l;
1221var has$3 = has$b;
1222var isArray$9 = isArray$c;
1223var isObject$7 = isObject$f;
1224var isSymbol = isSymbol$4;
1225var anObject$7 = anObject$b;
1226var toObject$a = toObject$e;
1227var toIndexedObject$5 = toIndexedObject$a;
1228var toPropertyKey = toPropertyKey$4;
1229var $toString = toString$9;
1230var createPropertyDescriptor$1 = createPropertyDescriptor$5;
1231var nativeObjectCreate = objectCreate;
1232var objectKeys$2 = objectKeys$4;
1233var getOwnPropertyNamesModule$2 = objectGetOwnPropertyNames;
1234var getOwnPropertyNamesExternal = objectGetOwnPropertyNamesExternal;
1235var getOwnPropertySymbolsModule$2 = objectGetOwnPropertySymbols;
1236var getOwnPropertyDescriptorModule$1 = objectGetOwnPropertyDescriptor;
1237var definePropertyModule$1 = objectDefineProperty;
1238var propertyIsEnumerableModule$1 = objectPropertyIsEnumerable;
1239var createNonEnumerableProperty$4 = createNonEnumerableProperty$9;
1240var redefine$2 = redefine$3;
1241var shared = shared$4.exports;
1242var sharedKey$1 = sharedKey$4;
1243var hiddenKeys$1 = hiddenKeys$6;
1244var uid$1 = uid$4;
1245var wellKnownSymbol$a = wellKnownSymbol$j;
1246var wrappedWellKnownSymbolModule = wellKnownSymbolWrapped;
1247var defineWellKnownSymbol$k = defineWellKnownSymbol$l;
1248var setToStringTag$4 = setToStringTag$5;
1249var InternalStateModule$4 = internalState;
1250var $forEach$1 = arrayIteration.forEach;
1251var HIDDEN = sharedKey$1('hidden');
1252var SYMBOL = 'Symbol';
1253var PROTOTYPE = 'prototype';
1254var TO_PRIMITIVE = wellKnownSymbol$a('toPrimitive');
1255var setInternalState$4 = InternalStateModule$4.set;
1256var getInternalState$2 = InternalStateModule$4.getterFor(SYMBOL);
1257var ObjectPrototype$1 = Object[PROTOTYPE];
1258var $Symbol = global$8.Symbol;
1259var $stringify$1 = getBuiltIn$4('JSON', 'stringify');
1260var nativeGetOwnPropertyDescriptor$1 = getOwnPropertyDescriptorModule$1.f;
1261var nativeDefineProperty = definePropertyModule$1.f;
1262var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
1263var nativePropertyIsEnumerable = propertyIsEnumerableModule$1.f;
1264var AllSymbols = shared('symbols');
1265var ObjectPrototypeSymbols = shared('op-symbols');
1266var StringToSymbolRegistry = shared('string-to-symbol-registry');
1267var SymbolToStringRegistry = shared('symbol-to-string-registry');
1268var WellKnownSymbolsStore = shared('wks');
1269var QObject = global$8.QObject; // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
1270
1271var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
1272
1273var setSymbolDescriptor = DESCRIPTORS$a && fails$d(function () {
1274 return nativeObjectCreate(nativeDefineProperty({}, 'a', {
1275 get: function () {
1276 return nativeDefineProperty(this, 'a', {
1277 value: 7
1278 }).a;
1279 }
1280 })).a != 7;
1281}) ? function (O, P, Attributes) {
1282 var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor$1(ObjectPrototype$1, P);
1283 if (ObjectPrototypeDescriptor) delete ObjectPrototype$1[P];
1284 nativeDefineProperty(O, P, Attributes);
1285
1286 if (ObjectPrototypeDescriptor && O !== ObjectPrototype$1) {
1287 nativeDefineProperty(ObjectPrototype$1, P, ObjectPrototypeDescriptor);
1288 }
1289} : nativeDefineProperty;
1290
1291var wrap$1 = function (tag, description) {
1292 var symbol = AllSymbols[tag] = nativeObjectCreate($Symbol[PROTOTYPE]);
1293 setInternalState$4(symbol, {
1294 type: SYMBOL,
1295 tag: tag,
1296 description: description
1297 });
1298 if (!DESCRIPTORS$a) symbol.description = description;
1299 return symbol;
1300};
1301
1302var $defineProperty = function defineProperty(O, P, Attributes) {
1303 if (O === ObjectPrototype$1) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
1304 anObject$7(O);
1305 var key = toPropertyKey(P);
1306 anObject$7(Attributes);
1307
1308 if (has$3(AllSymbols, key)) {
1309 if (!Attributes.enumerable) {
1310 if (!has$3(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor$1(1, {}));
1311 O[HIDDEN][key] = true;
1312 } else {
1313 if (has$3(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
1314 Attributes = nativeObjectCreate(Attributes, {
1315 enumerable: createPropertyDescriptor$1(0, false)
1316 });
1317 }
1318
1319 return setSymbolDescriptor(O, key, Attributes);
1320 }
1321
1322 return nativeDefineProperty(O, key, Attributes);
1323};
1324
1325var $defineProperties = function defineProperties(O, Properties) {
1326 anObject$7(O);
1327 var properties = toIndexedObject$5(Properties);
1328 var keys = objectKeys$2(properties).concat($getOwnPropertySymbols(properties));
1329 $forEach$1(keys, function (key) {
1330 if (!DESCRIPTORS$a || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]);
1331 });
1332 return O;
1333};
1334
1335var $create = function create(O, Properties) {
1336 return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
1337};
1338
1339var $propertyIsEnumerable = function propertyIsEnumerable(V) {
1340 var P = toPropertyKey(V);
1341 var enumerable = nativePropertyIsEnumerable.call(this, P);
1342 if (this === ObjectPrototype$1 && has$3(AllSymbols, P) && !has$3(ObjectPrototypeSymbols, P)) return false;
1343 return enumerable || !has$3(this, P) || !has$3(AllSymbols, P) || has$3(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;
1344};
1345
1346var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
1347 var it = toIndexedObject$5(O);
1348 var key = toPropertyKey(P);
1349 if (it === ObjectPrototype$1 && has$3(AllSymbols, key) && !has$3(ObjectPrototypeSymbols, key)) return;
1350 var descriptor = nativeGetOwnPropertyDescriptor$1(it, key);
1351
1352 if (descriptor && has$3(AllSymbols, key) && !(has$3(it, HIDDEN) && it[HIDDEN][key])) {
1353 descriptor.enumerable = true;
1354 }
1355
1356 return descriptor;
1357};
1358
1359var $getOwnPropertyNames = function getOwnPropertyNames(O) {
1360 var names = nativeGetOwnPropertyNames(toIndexedObject$5(O));
1361 var result = [];
1362 $forEach$1(names, function (key) {
1363 if (!has$3(AllSymbols, key) && !has$3(hiddenKeys$1, key)) result.push(key);
1364 });
1365 return result;
1366};
1367
1368var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
1369 var IS_OBJECT_PROTOTYPE = O === ObjectPrototype$1;
1370 var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject$5(O));
1371 var result = [];
1372 $forEach$1(names, function (key) {
1373 if (has$3(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has$3(ObjectPrototype$1, key))) {
1374 result.push(AllSymbols[key]);
1375 }
1376 });
1377 return result;
1378}; // `Symbol` constructor
1379// https://tc39.es/ecma262/#sec-symbol-constructor
1380
1381
1382if (!NATIVE_SYMBOL) {
1383 $Symbol = function Symbol() {
1384 if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor');
1385 var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);
1386 var tag = uid$1(description);
1387
1388 var setter = function (value) {
1389 if (this === ObjectPrototype$1) setter.call(ObjectPrototypeSymbols, value);
1390 if (has$3(this, HIDDEN) && has$3(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
1391 setSymbolDescriptor(this, tag, createPropertyDescriptor$1(1, value));
1392 };
1393
1394 if (DESCRIPTORS$a && USE_SETTER) setSymbolDescriptor(ObjectPrototype$1, tag, {
1395 configurable: true,
1396 set: setter
1397 });
1398 return wrap$1(tag, description);
1399 };
1400
1401 redefine$2($Symbol[PROTOTYPE], 'toString', function toString() {
1402 return getInternalState$2(this).tag;
1403 });
1404 redefine$2($Symbol, 'withoutSetter', function (description) {
1405 return wrap$1(uid$1(description), description);
1406 });
1407 propertyIsEnumerableModule$1.f = $propertyIsEnumerable;
1408 definePropertyModule$1.f = $defineProperty;
1409 getOwnPropertyDescriptorModule$1.f = $getOwnPropertyDescriptor;
1410 getOwnPropertyNamesModule$2.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
1411 getOwnPropertySymbolsModule$2.f = $getOwnPropertySymbols;
1412
1413 wrappedWellKnownSymbolModule.f = function (name) {
1414 return wrap$1(wellKnownSymbol$a(name), name);
1415 };
1416
1417 if (DESCRIPTORS$a) {
1418 // https://github.com/tc39/proposal-Symbol-description
1419 nativeDefineProperty($Symbol[PROTOTYPE], 'description', {
1420 configurable: true,
1421 get: function description() {
1422 return getInternalState$2(this).description;
1423 }
1424 });
1425 }
1426}
1427
1428$$E({
1429 global: true,
1430 wrap: true,
1431 forced: !NATIVE_SYMBOL,
1432 sham: !NATIVE_SYMBOL
1433}, {
1434 Symbol: $Symbol
1435});
1436$forEach$1(objectKeys$2(WellKnownSymbolsStore), function (name) {
1437 defineWellKnownSymbol$k(name);
1438});
1439$$E({
1440 target: SYMBOL,
1441 stat: true,
1442 forced: !NATIVE_SYMBOL
1443}, {
1444 // `Symbol.for` method
1445 // https://tc39.es/ecma262/#sec-symbol.for
1446 'for': function (key) {
1447 var string = $toString(key);
1448 if (has$3(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
1449 var symbol = $Symbol(string);
1450 StringToSymbolRegistry[string] = symbol;
1451 SymbolToStringRegistry[symbol] = string;
1452 return symbol;
1453 },
1454 // `Symbol.keyFor` method
1455 // https://tc39.es/ecma262/#sec-symbol.keyfor
1456 keyFor: function keyFor(sym) {
1457 if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');
1458 if (has$3(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
1459 },
1460 useSetter: function () {
1461 USE_SETTER = true;
1462 },
1463 useSimple: function () {
1464 USE_SETTER = false;
1465 }
1466});
1467$$E({
1468 target: 'Object',
1469 stat: true,
1470 forced: !NATIVE_SYMBOL,
1471 sham: !DESCRIPTORS$a
1472}, {
1473 // `Object.create` method
1474 // https://tc39.es/ecma262/#sec-object.create
1475 create: $create,
1476 // `Object.defineProperty` method
1477 // https://tc39.es/ecma262/#sec-object.defineproperty
1478 defineProperty: $defineProperty,
1479 // `Object.defineProperties` method
1480 // https://tc39.es/ecma262/#sec-object.defineproperties
1481 defineProperties: $defineProperties,
1482 // `Object.getOwnPropertyDescriptor` method
1483 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
1484 getOwnPropertyDescriptor: $getOwnPropertyDescriptor
1485});
1486$$E({
1487 target: 'Object',
1488 stat: true,
1489 forced: !NATIVE_SYMBOL
1490}, {
1491 // `Object.getOwnPropertyNames` method
1492 // https://tc39.es/ecma262/#sec-object.getownpropertynames
1493 getOwnPropertyNames: $getOwnPropertyNames,
1494 // `Object.getOwnPropertySymbols` method
1495 // https://tc39.es/ecma262/#sec-object.getownpropertysymbols
1496 getOwnPropertySymbols: $getOwnPropertySymbols
1497}); // Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
1498// https://bugs.chromium.org/p/v8/issues/detail?id=3443
1499
1500$$E({
1501 target: 'Object',
1502 stat: true,
1503 forced: fails$d(function () {
1504 getOwnPropertySymbolsModule$2.f(1);
1505 })
1506}, {
1507 getOwnPropertySymbols: function getOwnPropertySymbols(it) {
1508 return getOwnPropertySymbolsModule$2.f(toObject$a(it));
1509 }
1510}); // `JSON.stringify` method behavior with symbols
1511// https://tc39.es/ecma262/#sec-json.stringify
1512
1513if ($stringify$1) {
1514 var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails$d(function () {
1515 var symbol = $Symbol(); // MS Edge converts symbol values to JSON as {}
1516
1517 return $stringify$1([symbol]) != '[null]' // WebKit converts symbol values to JSON as null
1518 || $stringify$1({
1519 a: symbol
1520 }) != '{}' // V8 throws on boxed symbols
1521 || $stringify$1(Object(symbol)) != '{}';
1522 });
1523 $$E({
1524 target: 'JSON',
1525 stat: true,
1526 forced: FORCED_JSON_STRINGIFY
1527 }, {
1528 // eslint-disable-next-line no-unused-vars -- required for `.length`
1529 stringify: function stringify(it, replacer, space) {
1530 var args = [it];
1531 var index = 1;
1532 var $replacer;
1533
1534 while (arguments.length > index) args.push(arguments[index++]);
1535
1536 $replacer = replacer;
1537 if (!isObject$7(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
1538
1539 if (!isArray$9(replacer)) replacer = function (key, value) {
1540 if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
1541 if (!isSymbol(value)) return value;
1542 };
1543 args[1] = replacer;
1544 return $stringify$1.apply(null, args);
1545 }
1546 });
1547} // `Symbol.prototype[@@toPrimitive]` method
1548// https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
1549
1550
1551if (!$Symbol[PROTOTYPE][TO_PRIMITIVE]) {
1552 createNonEnumerableProperty$4($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
1553} // `Symbol.prototype[@@toStringTag]` property
1554// https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
1555
1556
1557setToStringTag$4($Symbol, SYMBOL);
1558hiddenKeys$1[HIDDEN] = true;
1559
1560var defineWellKnownSymbol$j = defineWellKnownSymbol$l; // `Symbol.asyncIterator` well-known symbol
1561// https://tc39.es/ecma262/#sec-symbol.asynciterator
1562
1563defineWellKnownSymbol$j('asyncIterator');
1564
1565var defineWellKnownSymbol$i = defineWellKnownSymbol$l; // `Symbol.hasInstance` well-known symbol
1566// https://tc39.es/ecma262/#sec-symbol.hasinstance
1567
1568defineWellKnownSymbol$i('hasInstance');
1569
1570var defineWellKnownSymbol$h = defineWellKnownSymbol$l; // `Symbol.isConcatSpreadable` well-known symbol
1571// https://tc39.es/ecma262/#sec-symbol.isconcatspreadable
1572
1573defineWellKnownSymbol$h('isConcatSpreadable');
1574
1575var defineWellKnownSymbol$g = defineWellKnownSymbol$l; // `Symbol.iterator` well-known symbol
1576// https://tc39.es/ecma262/#sec-symbol.iterator
1577
1578defineWellKnownSymbol$g('iterator');
1579
1580var defineWellKnownSymbol$f = defineWellKnownSymbol$l; // `Symbol.match` well-known symbol
1581// https://tc39.es/ecma262/#sec-symbol.match
1582
1583defineWellKnownSymbol$f('match');
1584
1585var defineWellKnownSymbol$e = defineWellKnownSymbol$l; // `Symbol.matchAll` well-known symbol
1586// https://tc39.es/ecma262/#sec-symbol.matchall
1587
1588defineWellKnownSymbol$e('matchAll');
1589
1590var defineWellKnownSymbol$d = defineWellKnownSymbol$l; // `Symbol.replace` well-known symbol
1591// https://tc39.es/ecma262/#sec-symbol.replace
1592
1593defineWellKnownSymbol$d('replace');
1594
1595var defineWellKnownSymbol$c = defineWellKnownSymbol$l; // `Symbol.search` well-known symbol
1596// https://tc39.es/ecma262/#sec-symbol.search
1597
1598defineWellKnownSymbol$c('search');
1599
1600var defineWellKnownSymbol$b = defineWellKnownSymbol$l; // `Symbol.species` well-known symbol
1601// https://tc39.es/ecma262/#sec-symbol.species
1602
1603defineWellKnownSymbol$b('species');
1604
1605var defineWellKnownSymbol$a = defineWellKnownSymbol$l; // `Symbol.split` well-known symbol
1606// https://tc39.es/ecma262/#sec-symbol.split
1607
1608defineWellKnownSymbol$a('split');
1609
1610var defineWellKnownSymbol$9 = defineWellKnownSymbol$l; // `Symbol.toPrimitive` well-known symbol
1611// https://tc39.es/ecma262/#sec-symbol.toprimitive
1612
1613defineWellKnownSymbol$9('toPrimitive');
1614
1615var defineWellKnownSymbol$8 = defineWellKnownSymbol$l; // `Symbol.toStringTag` well-known symbol
1616// https://tc39.es/ecma262/#sec-symbol.tostringtag
1617
1618defineWellKnownSymbol$8('toStringTag');
1619
1620var defineWellKnownSymbol$7 = defineWellKnownSymbol$l; // `Symbol.unscopables` well-known symbol
1621// https://tc39.es/ecma262/#sec-symbol.unscopables
1622
1623defineWellKnownSymbol$7('unscopables');
1624
1625var global$7 = global$i;
1626var setToStringTag$3 = setToStringTag$5; // JSON[@@toStringTag] property
1627// https://tc39.es/ecma262/#sec-json-@@tostringtag
1628
1629setToStringTag$3(global$7.JSON, 'JSON', true);
1630
1631var path$o = path$s;
1632var symbol$4 = path$o.Symbol;
1633
1634var iterators = {};
1635
1636var fails$c = fails$l;
1637var correctPrototypeGetter = !fails$c(function () {
1638 function F() {
1639 /* empty */
1640 }
1641
1642 F.prototype.constructor = null; // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
1643
1644 return Object.getPrototypeOf(new F()) !== F.prototype;
1645});
1646
1647var has$2 = has$b;
1648var toObject$9 = toObject$e;
1649var sharedKey = sharedKey$4;
1650var CORRECT_PROTOTYPE_GETTER$1 = correctPrototypeGetter;
1651var IE_PROTO = sharedKey('IE_PROTO');
1652var ObjectPrototype = Object.prototype; // `Object.getPrototypeOf` method
1653// https://tc39.es/ecma262/#sec-object.getprototypeof
1654// eslint-disable-next-line es/no-object-getprototypeof -- safe
1655
1656var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER$1 ? Object.getPrototypeOf : function (O) {
1657 O = toObject$9(O);
1658 if (has$2(O, IE_PROTO)) return O[IE_PROTO];
1659
1660 if (typeof O.constructor == 'function' && O instanceof O.constructor) {
1661 return O.constructor.prototype;
1662 }
1663
1664 return O instanceof Object ? ObjectPrototype : null;
1665};
1666
1667var fails$b = fails$l;
1668var getPrototypeOf$6 = objectGetPrototypeOf;
1669var createNonEnumerableProperty$3 = createNonEnumerableProperty$9;
1670var has$1 = has$b;
1671var wellKnownSymbol$9 = wellKnownSymbol$j;
1672var ITERATOR$4 = wellKnownSymbol$9('iterator');
1673var BUGGY_SAFARI_ITERATORS$1 = false;
1674
1675var returnThis$2 = function () {
1676 return this;
1677}; // `%IteratorPrototype%` object
1678// https://tc39.es/ecma262/#sec-%iteratorprototype%-object
1679
1680
1681var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator;
1682/* eslint-disable es/no-array-prototype-keys -- safe */
1683
1684if ([].keys) {
1685 arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next`
1686
1687 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true;else {
1688 PrototypeOfArrayIteratorPrototype = getPrototypeOf$6(getPrototypeOf$6(arrayIterator));
1689 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype;
1690 }
1691}
1692
1693var NEW_ITERATOR_PROTOTYPE = IteratorPrototype$2 == undefined || fails$b(function () {
1694 var test = {}; // FF44- legacy iterators case
1695
1696 return IteratorPrototype$2[ITERATOR$4].call(test) !== test;
1697});
1698if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {}; // `%IteratorPrototype%[@@iterator]()` method
1699// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
1700
1701if ((NEW_ITERATOR_PROTOTYPE) && !has$1(IteratorPrototype$2, ITERATOR$4)) {
1702 createNonEnumerableProperty$3(IteratorPrototype$2, ITERATOR$4, returnThis$2);
1703}
1704
1705var iteratorsCore = {
1706 IteratorPrototype: IteratorPrototype$2,
1707 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1
1708};
1709
1710var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
1711var create$8 = objectCreate;
1712var createPropertyDescriptor = createPropertyDescriptor$5;
1713var setToStringTag$2 = setToStringTag$5;
1714var Iterators$5 = iterators;
1715
1716var returnThis$1 = function () {
1717 return this;
1718};
1719
1720var createIteratorConstructor$1 = function (IteratorConstructor, NAME, next) {
1721 var TO_STRING_TAG = NAME + ' Iterator';
1722 IteratorConstructor.prototype = create$8(IteratorPrototype$1, {
1723 next: createPropertyDescriptor(1, next)
1724 });
1725 setToStringTag$2(IteratorConstructor, TO_STRING_TAG, false, true);
1726 Iterators$5[TO_STRING_TAG] = returnThis$1;
1727 return IteratorConstructor;
1728};
1729
1730var isObject$6 = isObject$f;
1731
1732var aPossiblePrototype$1 = function (it) {
1733 if (!isObject$6(it) && it !== null) {
1734 throw TypeError("Can't set " + String(it) + ' as a prototype');
1735 }
1736
1737 return it;
1738};
1739
1740/* eslint-disable no-proto -- safe */
1741var anObject$6 = anObject$b;
1742var aPossiblePrototype = aPossiblePrototype$1; // `Object.setPrototypeOf` method
1743// https://tc39.es/ecma262/#sec-object.setprototypeof
1744// Works with __proto__ only. Old v8 can't work with null proto objects.
1745// eslint-disable-next-line es/no-object-setprototypeof -- safe
1746
1747var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
1748 var CORRECT_SETTER = false;
1749 var test = {};
1750 var setter;
1751
1752 try {
1753 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1754 setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
1755 setter.call(test, []);
1756 CORRECT_SETTER = test instanceof Array;
1757 } catch (error) {
1758 /* empty */
1759 }
1760
1761 return function setPrototypeOf(O, proto) {
1762 anObject$6(O);
1763 aPossiblePrototype(proto);
1764 if (CORRECT_SETTER) setter.call(O, proto);else O.__proto__ = proto;
1765 return O;
1766 };
1767}() : undefined);
1768
1769var $$D = _export;
1770var createIteratorConstructor = createIteratorConstructor$1;
1771var getPrototypeOf$5 = objectGetPrototypeOf;
1772var setToStringTag$1 = setToStringTag$5;
1773var createNonEnumerableProperty$2 = createNonEnumerableProperty$9;
1774var redefine$1 = redefine$3;
1775var wellKnownSymbol$8 = wellKnownSymbol$j;
1776var Iterators$4 = iterators;
1777var IteratorsCore = iteratorsCore;
1778var IteratorPrototype = IteratorsCore.IteratorPrototype;
1779var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
1780var ITERATOR$3 = wellKnownSymbol$8('iterator');
1781var KEYS = 'keys';
1782var VALUES = 'values';
1783var ENTRIES = 'entries';
1784
1785var returnThis = function () {
1786 return this;
1787};
1788
1789var defineIterator$3 = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
1790 createIteratorConstructor(IteratorConstructor, NAME, next);
1791
1792 var getIterationMethod = function (KIND) {
1793 if (KIND === DEFAULT && defaultIterator) return defaultIterator;
1794 if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
1795
1796 switch (KIND) {
1797 case KEYS:
1798 return function keys() {
1799 return new IteratorConstructor(this, KIND);
1800 };
1801
1802 case VALUES:
1803 return function values() {
1804 return new IteratorConstructor(this, KIND);
1805 };
1806
1807 case ENTRIES:
1808 return function entries() {
1809 return new IteratorConstructor(this, KIND);
1810 };
1811 }
1812
1813 return function () {
1814 return new IteratorConstructor(this);
1815 };
1816 };
1817
1818 var TO_STRING_TAG = NAME + ' Iterator';
1819 var INCORRECT_VALUES_NAME = false;
1820 var IterablePrototype = Iterable.prototype;
1821 var nativeIterator = IterablePrototype[ITERATOR$3] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT];
1822 var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
1823 var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
1824 var CurrentIteratorPrototype, methods, KEY; // fix native
1825
1826 if (anyNativeIterator) {
1827 CurrentIteratorPrototype = getPrototypeOf$5(anyNativeIterator.call(new Iterable()));
1828
1829 if (IteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
1830
1831
1832 setToStringTag$1(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
1833 Iterators$4[TO_STRING_TAG] = returnThis;
1834 }
1835 } // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
1836
1837
1838 if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
1839 INCORRECT_VALUES_NAME = true;
1840
1841 defaultIterator = function values() {
1842 return nativeIterator.call(this);
1843 };
1844 } // define iterator
1845
1846
1847 if ((FORCED) && IterablePrototype[ITERATOR$3] !== defaultIterator) {
1848 createNonEnumerableProperty$2(IterablePrototype, ITERATOR$3, defaultIterator);
1849 }
1850
1851 Iterators$4[NAME] = defaultIterator; // export additional methods
1852
1853 if (DEFAULT) {
1854 methods = {
1855 values: getIterationMethod(VALUES),
1856 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
1857 entries: getIterationMethod(ENTRIES)
1858 };
1859 if (FORCED) for (KEY in methods) {
1860 if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
1861 redefine$1(IterablePrototype, KEY, methods[KEY]);
1862 }
1863 } else $$D({
1864 target: NAME,
1865 proto: true,
1866 forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME
1867 }, methods);
1868 }
1869
1870 return methods;
1871};
1872
1873var toIndexedObject$4 = toIndexedObject$a;
1874var Iterators$3 = iterators;
1875var InternalStateModule$3 = internalState;
1876var defineIterator$2 = defineIterator$3;
1877var ARRAY_ITERATOR = 'Array Iterator';
1878var setInternalState$3 = InternalStateModule$3.set;
1879var getInternalState$1 = InternalStateModule$3.getterFor(ARRAY_ITERATOR); // `Array.prototype.entries` method
1880// https://tc39.es/ecma262/#sec-array.prototype.entries
1881// `Array.prototype.keys` method
1882// https://tc39.es/ecma262/#sec-array.prototype.keys
1883// `Array.prototype.values` method
1884// https://tc39.es/ecma262/#sec-array.prototype.values
1885// `Array.prototype[@@iterator]` method
1886// https://tc39.es/ecma262/#sec-array.prototype-@@iterator
1887// `CreateArrayIterator` internal method
1888// https://tc39.es/ecma262/#sec-createarrayiterator
1889
1890defineIterator$2(Array, 'Array', function (iterated, kind) {
1891 setInternalState$3(this, {
1892 type: ARRAY_ITERATOR,
1893 target: toIndexedObject$4(iterated),
1894 // target
1895 index: 0,
1896 // next index
1897 kind: kind // kind
1898
1899 }); // `%ArrayIteratorPrototype%.next` method
1900 // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
1901}, function () {
1902 var state = getInternalState$1(this);
1903 var target = state.target;
1904 var kind = state.kind;
1905 var index = state.index++;
1906
1907 if (!target || index >= target.length) {
1908 state.target = undefined;
1909 return {
1910 value: undefined,
1911 done: true
1912 };
1913 }
1914
1915 if (kind == 'keys') return {
1916 value: index,
1917 done: false
1918 };
1919 if (kind == 'values') return {
1920 value: target[index],
1921 done: false
1922 };
1923 return {
1924 value: [index, target[index]],
1925 done: false
1926 };
1927}, 'values'); // argumentsList[@@iterator] is %ArrayProto_values%
1928// https://tc39.es/ecma262/#sec-createunmappedargumentsobject
1929// https://tc39.es/ecma262/#sec-createmappedargumentsobject
1930
1931Iterators$3.Arguments = Iterators$3.Array; // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
1932
1933// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
1934
1935var domIterables = {
1936 CSSRuleList: 0,
1937 CSSStyleDeclaration: 0,
1938 CSSValueList: 0,
1939 ClientRectList: 0,
1940 DOMRectList: 0,
1941 DOMStringList: 0,
1942 DOMTokenList: 1,
1943 DataTransferItemList: 0,
1944 FileList: 0,
1945 HTMLAllCollection: 0,
1946 HTMLCollection: 0,
1947 HTMLFormElement: 0,
1948 HTMLSelectElement: 0,
1949 MediaList: 0,
1950 MimeTypeArray: 0,
1951 NamedNodeMap: 0,
1952 NodeList: 1,
1953 PaintRequestList: 0,
1954 Plugin: 0,
1955 PluginArray: 0,
1956 SVGLengthList: 0,
1957 SVGNumberList: 0,
1958 SVGPathSegList: 0,
1959 SVGPointList: 0,
1960 SVGStringList: 0,
1961 SVGTransformList: 0,
1962 SourceBufferList: 0,
1963 StyleSheetList: 0,
1964 TextTrackCueList: 0,
1965 TextTrackList: 0,
1966 TouchList: 0
1967};
1968
1969var DOMIterables$4 = domIterables;
1970var global$6 = global$i;
1971var classof$7 = classof$9;
1972var createNonEnumerableProperty$1 = createNonEnumerableProperty$9;
1973var Iterators$2 = iterators;
1974var wellKnownSymbol$7 = wellKnownSymbol$j;
1975var TO_STRING_TAG = wellKnownSymbol$7('toStringTag');
1976
1977for (var COLLECTION_NAME in DOMIterables$4) {
1978 var Collection = global$6[COLLECTION_NAME];
1979 var CollectionPrototype = Collection && Collection.prototype;
1980
1981 if (CollectionPrototype && classof$7(CollectionPrototype) !== TO_STRING_TAG) {
1982 createNonEnumerableProperty$1(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
1983 }
1984
1985 Iterators$2[COLLECTION_NAME] = Iterators$2.Array;
1986}
1987
1988var parent$R = symbol$4;
1989var symbol$3 = parent$R;
1990
1991var defineWellKnownSymbol$6 = defineWellKnownSymbol$l; // `Symbol.asyncDispose` well-known symbol
1992// https://github.com/tc39/proposal-using-statement
1993
1994defineWellKnownSymbol$6('asyncDispose');
1995
1996var defineWellKnownSymbol$5 = defineWellKnownSymbol$l; // `Symbol.dispose` well-known symbol
1997// https://github.com/tc39/proposal-using-statement
1998
1999defineWellKnownSymbol$5('dispose');
2000
2001var defineWellKnownSymbol$4 = defineWellKnownSymbol$l; // `Symbol.matcher` well-known symbol
2002// https://github.com/tc39/proposal-pattern-matching
2003
2004defineWellKnownSymbol$4('matcher');
2005
2006var defineWellKnownSymbol$3 = defineWellKnownSymbol$l; // `Symbol.metadata` well-known symbol
2007// https://github.com/tc39/proposal-decorators
2008
2009defineWellKnownSymbol$3('metadata');
2010
2011var defineWellKnownSymbol$2 = defineWellKnownSymbol$l; // `Symbol.observable` well-known symbol
2012// https://github.com/tc39/proposal-observable
2013
2014defineWellKnownSymbol$2('observable');
2015
2016var defineWellKnownSymbol$1 = defineWellKnownSymbol$l; // `Symbol.patternMatch` well-known symbol
2017// https://github.com/tc39/proposal-pattern-matching
2018
2019defineWellKnownSymbol$1('patternMatch');
2020
2021var defineWellKnownSymbol = defineWellKnownSymbol$l;
2022defineWellKnownSymbol('replaceAll');
2023
2024var parent$Q = symbol$3; // TODO: Remove from `core-js@4`
2025// TODO: Remove from `core-js@4`
2026
2027var symbol$2 = parent$Q;
2028
2029var symbol$1 = symbol$2;
2030
2031var toInteger$1 = toInteger$4;
2032var toString$6 = toString$9;
2033var requireObjectCoercible$2 = requireObjectCoercible$5; // `String.prototype.codePointAt` methods implementation
2034
2035var createMethod$3 = function (CONVERT_TO_STRING) {
2036 return function ($this, pos) {
2037 var S = toString$6(requireObjectCoercible$2($this));
2038 var position = toInteger$1(pos);
2039 var size = S.length;
2040 var first, second;
2041 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
2042 first = S.charCodeAt(position);
2043 return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? S.charAt(position) : first : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
2044 };
2045};
2046
2047var stringMultibyte = {
2048 // `String.prototype.codePointAt` method
2049 // https://tc39.es/ecma262/#sec-string.prototype.codepointat
2050 codeAt: createMethod$3(false),
2051 // `String.prototype.at` method
2052 // https://github.com/mathiasbynens/String.prototype.at
2053 charAt: createMethod$3(true)
2054};
2055
2056var charAt = stringMultibyte.charAt;
2057var toString$5 = toString$9;
2058var InternalStateModule$2 = internalState;
2059var defineIterator$1 = defineIterator$3;
2060var STRING_ITERATOR = 'String Iterator';
2061var setInternalState$2 = InternalStateModule$2.set;
2062var getInternalState = InternalStateModule$2.getterFor(STRING_ITERATOR); // `String.prototype[@@iterator]` method
2063// https://tc39.es/ecma262/#sec-string.prototype-@@iterator
2064
2065defineIterator$1(String, 'String', function (iterated) {
2066 setInternalState$2(this, {
2067 type: STRING_ITERATOR,
2068 string: toString$5(iterated),
2069 index: 0
2070 }); // `%StringIteratorPrototype%.next` method
2071 // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
2072}, function next() {
2073 var state = getInternalState(this);
2074 var string = state.string;
2075 var index = state.index;
2076 var point;
2077 if (index >= string.length) return {
2078 value: undefined,
2079 done: true
2080 };
2081 point = charAt(string, index);
2082 state.index += point.length;
2083 return {
2084 value: point,
2085 done: false
2086 };
2087});
2088
2089var WrappedWellKnownSymbolModule = wellKnownSymbolWrapped;
2090var iterator$4 = WrappedWellKnownSymbolModule.f('iterator');
2091
2092var parent$P = iterator$4;
2093var iterator$3 = parent$P;
2094
2095var parent$O = iterator$3;
2096var iterator$2 = parent$O;
2097
2098var iterator$1 = iterator$2;
2099
2100function _typeof(obj) {
2101 "@babel/helpers - typeof";
2102
2103 if (typeof symbol$1 === "function" && typeof iterator$1 === "symbol") {
2104 _typeof = function _typeof(obj) {
2105 return typeof obj;
2106 };
2107 } else {
2108 _typeof = function _typeof(obj) {
2109 return obj && typeof symbol$1 === "function" && obj.constructor === symbol$1 && obj !== symbol$1.prototype ? "symbol" : typeof obj;
2110 };
2111 }
2112
2113 return _typeof(obj);
2114}
2115
2116var floor = Math.floor;
2117
2118var mergeSort = function (array, comparefn) {
2119 var length = array.length;
2120 var middle = floor(length / 2);
2121 return length < 8 ? insertionSort(array, comparefn) : merge$1(mergeSort(array.slice(0, middle), comparefn), mergeSort(array.slice(middle), comparefn), comparefn);
2122};
2123
2124var insertionSort = function (array, comparefn) {
2125 var length = array.length;
2126 var i = 1;
2127 var element, j;
2128
2129 while (i < length) {
2130 j = i;
2131 element = array[i];
2132
2133 while (j && comparefn(array[j - 1], element) > 0) {
2134 array[j] = array[--j];
2135 }
2136
2137 if (j !== i++) array[j] = element;
2138 }
2139
2140 return array;
2141};
2142
2143var merge$1 = function (left, right, comparefn) {
2144 var llength = left.length;
2145 var rlength = right.length;
2146 var lindex = 0;
2147 var rindex = 0;
2148 var result = [];
2149
2150 while (lindex < llength || rindex < rlength) {
2151 if (lindex < llength && rindex < rlength) {
2152 result.push(comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]);
2153 } else {
2154 result.push(lindex < llength ? left[lindex++] : right[rindex++]);
2155 }
2156 }
2157
2158 return result;
2159};
2160
2161var arraySort = mergeSort;
2162
2163var fails$a = fails$l;
2164
2165var arrayMethodIsStrict$5 = function (METHOD_NAME, argument) {
2166 var method = [][METHOD_NAME];
2167 return !!method && fails$a(function () {
2168 // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
2169 method.call(null, argument || function () {
2170 throw 1;
2171 }, 1);
2172 });
2173};
2174
2175var userAgent$2 = engineUserAgent;
2176var firefox = userAgent$2.match(/firefox\/(\d+)/i);
2177var engineFfVersion = !!firefox && +firefox[1];
2178
2179var UA = engineUserAgent;
2180var engineIsIeOrEdge = /MSIE|Trident/.test(UA);
2181
2182var userAgent$1 = engineUserAgent;
2183var webkit = userAgent$1.match(/AppleWebKit\/(\d+)\./);
2184var engineWebkitVersion = !!webkit && +webkit[1];
2185
2186var $$C = _export;
2187var aFunction$4 = aFunction$6;
2188var toObject$8 = toObject$e;
2189var toLength$8 = toLength$c;
2190var toString$4 = toString$9;
2191var fails$9 = fails$l;
2192var internalSort = arraySort;
2193var arrayMethodIsStrict$4 = arrayMethodIsStrict$5;
2194var FF = engineFfVersion;
2195var IE_OR_EDGE = engineIsIeOrEdge;
2196var V8 = engineV8Version;
2197var WEBKIT = engineWebkitVersion;
2198var test$1 = [];
2199var nativeSort = test$1.sort; // IE8-
2200
2201var FAILS_ON_UNDEFINED = fails$9(function () {
2202 test$1.sort(undefined);
2203}); // V8 bug
2204
2205var FAILS_ON_NULL = fails$9(function () {
2206 test$1.sort(null);
2207}); // Old WebKit
2208
2209var STRICT_METHOD$4 = arrayMethodIsStrict$4('sort');
2210var STABLE_SORT = !fails$9(function () {
2211 // feature detection can be too slow, so check engines versions
2212 if (V8) return V8 < 70;
2213 if (FF && FF > 3) return;
2214 if (IE_OR_EDGE) return true;
2215 if (WEBKIT) return WEBKIT < 603;
2216 var result = '';
2217 var code, chr, value, index; // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
2218
2219 for (code = 65; code < 76; code++) {
2220 chr = String.fromCharCode(code);
2221
2222 switch (code) {
2223 case 66:
2224 case 69:
2225 case 70:
2226 case 72:
2227 value = 3;
2228 break;
2229
2230 case 68:
2231 case 71:
2232 value = 4;
2233 break;
2234
2235 default:
2236 value = 2;
2237 }
2238
2239 for (index = 0; index < 47; index++) {
2240 test$1.push({
2241 k: chr + index,
2242 v: value
2243 });
2244 }
2245 }
2246
2247 test$1.sort(function (a, b) {
2248 return b.v - a.v;
2249 });
2250
2251 for (index = 0; index < test$1.length; index++) {
2252 chr = test$1[index].k.charAt(0);
2253 if (result.charAt(result.length - 1) !== chr) result += chr;
2254 }
2255
2256 return result !== 'DGBEFHACIJK';
2257});
2258var FORCED$5 = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD$4 || !STABLE_SORT;
2259
2260var getSortCompare = function (comparefn) {
2261 return function (x, y) {
2262 if (y === undefined) return -1;
2263 if (x === undefined) return 1;
2264 if (comparefn !== undefined) return +comparefn(x, y) || 0;
2265 return toString$4(x) > toString$4(y) ? 1 : -1;
2266 };
2267}; // `Array.prototype.sort` method
2268// https://tc39.es/ecma262/#sec-array.prototype.sort
2269
2270
2271$$C({
2272 target: 'Array',
2273 proto: true,
2274 forced: FORCED$5
2275}, {
2276 sort: function sort(comparefn) {
2277 if (comparefn !== undefined) aFunction$4(comparefn);
2278 var array = toObject$8(this);
2279 if (STABLE_SORT) return comparefn === undefined ? nativeSort.call(array) : nativeSort.call(array, comparefn);
2280 var items = [];
2281 var arrayLength = toLength$8(array.length);
2282 var itemsLength, index;
2283
2284 for (index = 0; index < arrayLength; index++) {
2285 if (index in array) items.push(array[index]);
2286 }
2287
2288 items = internalSort(items, getSortCompare(comparefn));
2289 itemsLength = items.length;
2290 index = 0;
2291
2292 while (index < itemsLength) array[index] = items[index++];
2293
2294 while (index < arrayLength) delete array[index++];
2295
2296 return array;
2297 }
2298});
2299
2300var path$n = path$s;
2301
2302var entryVirtual$k = function (CONSTRUCTOR) {
2303 return path$n[CONSTRUCTOR + 'Prototype'];
2304};
2305
2306var entryVirtual$j = entryVirtual$k;
2307var sort$3 = entryVirtual$j('Array').sort;
2308
2309var sort$2 = sort$3;
2310var ArrayPrototype$h = Array.prototype;
2311
2312var sort_1 = function (it) {
2313 var own = it.sort;
2314 return it === ArrayPrototype$h || it instanceof Array && own === ArrayPrototype$h.sort ? sort$2 : own;
2315};
2316
2317var parent$N = sort_1;
2318var sort$1 = parent$N;
2319
2320var sort = sort$1;
2321
2322/* eslint-disable es/no-array-prototype-indexof -- required for testing */
2323
2324
2325var $$B = _export;
2326var $indexOf = arrayIncludes$1.indexOf;
2327var arrayMethodIsStrict$3 = arrayMethodIsStrict$5;
2328var nativeIndexOf = [].indexOf;
2329var NEGATIVE_ZERO = !!nativeIndexOf && 1 / [1].indexOf(1, -0) < 0;
2330var STRICT_METHOD$3 = arrayMethodIsStrict$3('indexOf'); // `Array.prototype.indexOf` method
2331// https://tc39.es/ecma262/#sec-array.prototype.indexof
2332
2333$$B({
2334 target: 'Array',
2335 proto: true,
2336 forced: NEGATIVE_ZERO || !STRICT_METHOD$3
2337}, {
2338 indexOf: function indexOf(searchElement
2339 /* , fromIndex = 0 */
2340 ) {
2341 return NEGATIVE_ZERO // convert -0 to +0
2342 ? nativeIndexOf.apply(this, arguments) || 0 : $indexOf(this, searchElement, arguments.length > 1 ? arguments[1] : undefined);
2343 }
2344});
2345
2346var entryVirtual$i = entryVirtual$k;
2347var indexOf$3 = entryVirtual$i('Array').indexOf;
2348
2349var indexOf$2 = indexOf$3;
2350var ArrayPrototype$g = Array.prototype;
2351
2352var indexOf_1 = function (it) {
2353 var own = it.indexOf;
2354 return it === ArrayPrototype$g || it instanceof Array && own === ArrayPrototype$g.indexOf ? indexOf$2 : own;
2355};
2356
2357var parent$M = indexOf_1;
2358var indexOf$1 = parent$M;
2359
2360var indexOf = indexOf$1;
2361
2362var $$A = _export;
2363var $filter = arrayIteration.filter;
2364var arrayMethodHasSpeciesSupport$3 = arrayMethodHasSpeciesSupport$5;
2365var HAS_SPECIES_SUPPORT$3 = arrayMethodHasSpeciesSupport$3('filter'); // `Array.prototype.filter` method
2366// https://tc39.es/ecma262/#sec-array.prototype.filter
2367// with adding support of @@species
2368
2369$$A({
2370 target: 'Array',
2371 proto: true,
2372 forced: !HAS_SPECIES_SUPPORT$3
2373}, {
2374 filter: function filter(callbackfn
2375 /* , thisArg */
2376 ) {
2377 return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
2378 }
2379});
2380
2381var entryVirtual$h = entryVirtual$k;
2382var filter$3 = entryVirtual$h('Array').filter;
2383
2384var filter$2 = filter$3;
2385var ArrayPrototype$f = Array.prototype;
2386
2387var filter_1 = function (it) {
2388 var own = it.filter;
2389 return it === ArrayPrototype$f || it instanceof Array && own === ArrayPrototype$f.filter ? filter$2 : own;
2390};
2391
2392var parent$L = filter_1;
2393var filter$1 = parent$L;
2394
2395var filter = filter$1;
2396
2397var whitespaces$4 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' + '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
2398
2399var requireObjectCoercible$1 = requireObjectCoercible$5;
2400var toString$3 = toString$9;
2401var whitespaces$3 = whitespaces$4;
2402var whitespace = '[' + whitespaces$3 + ']';
2403var ltrim = RegExp('^' + whitespace + whitespace + '*');
2404var rtrim = RegExp(whitespace + whitespace + '*$'); // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
2405
2406var createMethod$2 = function (TYPE) {
2407 return function ($this) {
2408 var string = toString$3(requireObjectCoercible$1($this));
2409 if (TYPE & 1) string = string.replace(ltrim, '');
2410 if (TYPE & 2) string = string.replace(rtrim, '');
2411 return string;
2412 };
2413};
2414
2415var stringTrim = {
2416 // `String.prototype.{ trimLeft, trimStart }` methods
2417 // https://tc39.es/ecma262/#sec-string.prototype.trimstart
2418 start: createMethod$2(1),
2419 // `String.prototype.{ trimRight, trimEnd }` methods
2420 // https://tc39.es/ecma262/#sec-string.prototype.trimend
2421 end: createMethod$2(2),
2422 // `String.prototype.trim` method
2423 // https://tc39.es/ecma262/#sec-string.prototype.trim
2424 trim: createMethod$2(3)
2425};
2426
2427var global$5 = global$i;
2428var toString$2 = toString$9;
2429var trim$1 = stringTrim.trim;
2430var whitespaces$2 = whitespaces$4;
2431var $parseFloat = global$5.parseFloat;
2432var FORCED$4 = 1 / $parseFloat(whitespaces$2 + '-0') !== -Infinity; // `parseFloat` method
2433// https://tc39.es/ecma262/#sec-parsefloat-string
2434
2435var numberParseFloat = FORCED$4 ? function parseFloat(string) {
2436 var trimmedString = trim$1(toString$2(string));
2437 var result = $parseFloat(trimmedString);
2438 return result === 0 && trimmedString.charAt(0) == '-' ? -0 : result;
2439} : $parseFloat;
2440
2441var $$z = _export;
2442var parseFloatImplementation = numberParseFloat; // `parseFloat` method
2443// https://tc39.es/ecma262/#sec-parsefloat-string
2444
2445$$z({
2446 global: true,
2447 forced: parseFloat != parseFloatImplementation
2448}, {
2449 parseFloat: parseFloatImplementation
2450});
2451
2452var path$m = path$s;
2453var _parseFloat$2 = path$m.parseFloat;
2454
2455var parent$K = _parseFloat$2;
2456var _parseFloat$1 = parent$K;
2457
2458var _parseFloat = _parseFloat$1;
2459
2460var toObject$7 = toObject$e;
2461var toAbsoluteIndex$2 = toAbsoluteIndex$4;
2462var toLength$7 = toLength$c; // `Array.prototype.fill` method implementation
2463// https://tc39.es/ecma262/#sec-array.prototype.fill
2464
2465var arrayFill = function fill(value
2466/* , start = 0, end = @length */
2467) {
2468 var O = toObject$7(this);
2469 var length = toLength$7(O.length);
2470 var argumentsLength = arguments.length;
2471 var index = toAbsoluteIndex$2(argumentsLength > 1 ? arguments[1] : undefined, length);
2472 var end = argumentsLength > 2 ? arguments[2] : undefined;
2473 var endPos = end === undefined ? length : toAbsoluteIndex$2(end, length);
2474
2475 while (endPos > index) O[index++] = value;
2476
2477 return O;
2478};
2479
2480var $$y = _export;
2481var fill$4 = arrayFill;
2482// https://tc39.es/ecma262/#sec-array.prototype.fill
2483
2484$$y({
2485 target: 'Array',
2486 proto: true
2487}, {
2488 fill: fill$4
2489}); // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
2490
2491var entryVirtual$g = entryVirtual$k;
2492var fill$3 = entryVirtual$g('Array').fill;
2493
2494var fill$2 = fill$3;
2495var ArrayPrototype$e = Array.prototype;
2496
2497var fill_1 = function (it) {
2498 var own = it.fill;
2499 return it === ArrayPrototype$e || it instanceof Array && own === ArrayPrototype$e.fill ? fill$2 : own;
2500};
2501
2502var parent$J = fill_1;
2503var fill$1 = parent$J;
2504
2505var fill = fill$1;
2506
2507var entryVirtual$f = entryVirtual$k;
2508var values$3 = entryVirtual$f('Array').values;
2509
2510var parent$I = values$3;
2511var values$2 = parent$I;
2512
2513var values$1 = values$2;
2514var classof$6 = classof$9;
2515var ArrayPrototype$d = Array.prototype;
2516var DOMIterables$3 = {
2517 DOMTokenList: true,
2518 NodeList: true
2519};
2520
2521var values_1 = function (it) {
2522 var own = it.values;
2523 return it === ArrayPrototype$d || it instanceof Array && own === ArrayPrototype$d.values // eslint-disable-next-line no-prototype-builtins -- safe
2524 || DOMIterables$3.hasOwnProperty(classof$6(it)) ? values$1 : own;
2525};
2526
2527var values = values_1;
2528
2529var $forEach = arrayIteration.forEach;
2530var arrayMethodIsStrict$2 = arrayMethodIsStrict$5;
2531var STRICT_METHOD$2 = arrayMethodIsStrict$2('forEach'); // `Array.prototype.forEach` method implementation
2532// https://tc39.es/ecma262/#sec-array.prototype.foreach
2533
2534var arrayForEach = !STRICT_METHOD$2 ? function forEach(callbackfn
2535/* , thisArg */
2536) {
2537 return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); // eslint-disable-next-line es/no-array-prototype-foreach -- safe
2538} : [].forEach;
2539
2540var $$x = _export;
2541var forEach$5 = arrayForEach; // `Array.prototype.forEach` method
2542// https://tc39.es/ecma262/#sec-array.prototype.foreach
2543// eslint-disable-next-line es/no-array-prototype-foreach -- safe
2544
2545$$x({
2546 target: 'Array',
2547 proto: true,
2548 forced: [].forEach != forEach$5
2549}, {
2550 forEach: forEach$5
2551});
2552
2553var entryVirtual$e = entryVirtual$k;
2554var forEach$4 = entryVirtual$e('Array').forEach;
2555
2556var parent$H = forEach$4;
2557var forEach$3 = parent$H;
2558
2559var forEach$2 = forEach$3;
2560var classof$5 = classof$9;
2561var ArrayPrototype$c = Array.prototype;
2562var DOMIterables$2 = {
2563 DOMTokenList: true,
2564 NodeList: true
2565};
2566
2567var forEach_1 = function (it) {
2568 var own = it.forEach;
2569 return it === ArrayPrototype$c || it instanceof Array && own === ArrayPrototype$c.forEach // eslint-disable-next-line no-prototype-builtins -- safe
2570 || DOMIterables$2.hasOwnProperty(classof$5(it)) ? forEach$2 : own;
2571};
2572
2573var forEach$1 = forEach_1;
2574
2575var $$w = _export;
2576var isArray$8 = isArray$c; // `Array.isArray` method
2577// https://tc39.es/ecma262/#sec-array.isarray
2578
2579$$w({
2580 target: 'Array',
2581 stat: true
2582}, {
2583 isArray: isArray$8
2584});
2585
2586var path$l = path$s;
2587var isArray$7 = path$l.Array.isArray;
2588
2589var parent$G = isArray$7;
2590var isArray$6 = parent$G;
2591
2592var isArray$5 = isArray$6;
2593
2594var $$v = _export; // `Number.isNaN` method
2595// https://tc39.es/ecma262/#sec-number.isnan
2596
2597$$v({
2598 target: 'Number',
2599 stat: true
2600}, {
2601 isNaN: function isNaN(number) {
2602 // eslint-disable-next-line no-self-compare -- NaN check
2603 return number != number;
2604 }
2605});
2606
2607var path$k = path$s;
2608var isNan$2 = path$k.Number.isNaN;
2609
2610var parent$F = isNan$2;
2611var isNan$1 = parent$F;
2612
2613var isNan = isNan$1;
2614
2615var entryVirtual$d = entryVirtual$k;
2616var concat$3 = entryVirtual$d('Array').concat;
2617
2618var concat$2 = concat$3;
2619var ArrayPrototype$b = Array.prototype;
2620
2621var concat_1 = function (it) {
2622 var own = it.concat;
2623 return it === ArrayPrototype$b || it instanceof Array && own === ArrayPrototype$b.concat ? concat$2 : own;
2624};
2625
2626var parent$E = concat_1;
2627var concat$1 = parent$E;
2628
2629var concat = concat$1;
2630
2631var $$u = _export;
2632var global$4 = global$i;
2633var userAgent = engineUserAgent;
2634var slice$7 = [].slice;
2635var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
2636
2637var wrap = function (scheduler) {
2638 return function (handler, timeout
2639 /* , ...arguments */
2640 ) {
2641 var boundArgs = arguments.length > 2;
2642 var args = boundArgs ? slice$7.call(arguments, 2) : undefined;
2643 return scheduler(boundArgs ? function () {
2644 // eslint-disable-next-line no-new-func -- spec requirement
2645 (typeof handler == 'function' ? handler : Function(handler)).apply(this, args);
2646 } : handler, timeout);
2647 };
2648}; // ie9- setTimeout & setInterval additional parameters fix
2649// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
2650
2651
2652$$u({
2653 global: true,
2654 bind: true,
2655 forced: MSIE
2656}, {
2657 // `setTimeout` method
2658 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
2659 setTimeout: wrap(global$4.setTimeout),
2660 // `setInterval` method
2661 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
2662 setInterval: wrap(global$4.setInterval)
2663});
2664
2665var path$j = path$s;
2666var setTimeout$2 = path$j.setTimeout;
2667
2668var setTimeout$1 = setTimeout$2;
2669
2670var DESCRIPTORS$9 = descriptors;
2671var fails$8 = fails$l;
2672var objectKeys$1 = objectKeys$4;
2673var getOwnPropertySymbolsModule$1 = objectGetOwnPropertySymbols;
2674var propertyIsEnumerableModule = objectPropertyIsEnumerable;
2675var toObject$6 = toObject$e;
2676var IndexedObject$1 = indexedObject; // eslint-disable-next-line es/no-object-assign -- safe
2677
2678var $assign = Object.assign; // eslint-disable-next-line es/no-object-defineproperty -- required for testing
2679
2680var defineProperty$9 = Object.defineProperty; // `Object.assign` method
2681// https://tc39.es/ecma262/#sec-object.assign
2682
2683var objectAssign = !$assign || fails$8(function () {
2684 // should have correct order of operations (Edge bug)
2685 if (DESCRIPTORS$9 && $assign({
2686 b: 1
2687 }, $assign(defineProperty$9({}, 'a', {
2688 enumerable: true,
2689 get: function () {
2690 defineProperty$9(this, 'b', {
2691 value: 3,
2692 enumerable: false
2693 });
2694 }
2695 }), {
2696 b: 2
2697 })).b !== 1) return true; // should work with symbols and should have deterministic property order (V8 bug)
2698
2699 var A = {};
2700 var B = {}; // eslint-disable-next-line es/no-symbol -- safe
2701
2702 var symbol = Symbol();
2703 var alphabet = 'abcdefghijklmnopqrst';
2704 A[symbol] = 7;
2705 alphabet.split('').forEach(function (chr) {
2706 B[chr] = chr;
2707 });
2708 return $assign({}, A)[symbol] != 7 || objectKeys$1($assign({}, B)).join('') != alphabet;
2709}) ? function assign(target, source) {
2710 // eslint-disable-line no-unused-vars -- required for `.length`
2711 var T = toObject$6(target);
2712 var argumentsLength = arguments.length;
2713 var index = 1;
2714 var getOwnPropertySymbols = getOwnPropertySymbolsModule$1.f;
2715 var propertyIsEnumerable = propertyIsEnumerableModule.f;
2716
2717 while (argumentsLength > index) {
2718 var S = IndexedObject$1(arguments[index++]);
2719 var keys = getOwnPropertySymbols ? objectKeys$1(S).concat(getOwnPropertySymbols(S)) : objectKeys$1(S);
2720 var length = keys.length;
2721 var j = 0;
2722 var key;
2723
2724 while (length > j) {
2725 key = keys[j++];
2726 if (!DESCRIPTORS$9 || propertyIsEnumerable.call(S, key)) T[key] = S[key];
2727 }
2728 }
2729
2730 return T;
2731} : $assign;
2732
2733var $$t = _export;
2734var assign$5 = objectAssign; // `Object.assign` method
2735// https://tc39.es/ecma262/#sec-object.assign
2736// eslint-disable-next-line es/no-object-assign -- required for testing
2737
2738$$t({
2739 target: 'Object',
2740 stat: true,
2741 forced: Object.assign !== assign$5
2742}, {
2743 assign: assign$5
2744});
2745
2746var path$i = path$s;
2747var assign$4 = path$i.Object.assign;
2748
2749var parent$D = assign$4;
2750var assign$3 = parent$D;
2751
2752var assign$2 = assign$3;
2753
2754var componentEmitter = {exports: {}};
2755
2756(function (module) {
2757 /**
2758 * Expose `Emitter`.
2759 */
2760 {
2761 module.exports = Emitter;
2762 }
2763 /**
2764 * Initialize a new `Emitter`.
2765 *
2766 * @api public
2767 */
2768
2769
2770 function Emitter(obj) {
2771 if (obj) return mixin(obj);
2772 }
2773 /**
2774 * Mixin the emitter properties.
2775 *
2776 * @param {Object} obj
2777 * @return {Object}
2778 * @api private
2779 */
2780
2781 function mixin(obj) {
2782 for (var key in Emitter.prototype) {
2783 obj[key] = Emitter.prototype[key];
2784 }
2785
2786 return obj;
2787 }
2788 /**
2789 * Listen on the given `event` with `fn`.
2790 *
2791 * @param {String} event
2792 * @param {Function} fn
2793 * @return {Emitter}
2794 * @api public
2795 */
2796
2797
2798 Emitter.prototype.on = Emitter.prototype.addEventListener = function (event, fn) {
2799 this._callbacks = this._callbacks || {};
2800 (this._callbacks['$' + event] = this._callbacks['$' + event] || []).push(fn);
2801 return this;
2802 };
2803 /**
2804 * Adds an `event` listener that will be invoked a single
2805 * time then automatically removed.
2806 *
2807 * @param {String} event
2808 * @param {Function} fn
2809 * @return {Emitter}
2810 * @api public
2811 */
2812
2813
2814 Emitter.prototype.once = function (event, fn) {
2815 function on() {
2816 this.off(event, on);
2817 fn.apply(this, arguments);
2818 }
2819
2820 on.fn = fn;
2821 this.on(event, on);
2822 return this;
2823 };
2824 /**
2825 * Remove the given callback for `event` or all
2826 * registered callbacks.
2827 *
2828 * @param {String} event
2829 * @param {Function} fn
2830 * @return {Emitter}
2831 * @api public
2832 */
2833
2834
2835 Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function (event, fn) {
2836 this._callbacks = this._callbacks || {}; // all
2837
2838 if (0 == arguments.length) {
2839 this._callbacks = {};
2840 return this;
2841 } // specific event
2842
2843
2844 var callbacks = this._callbacks['$' + event];
2845 if (!callbacks) return this; // remove all handlers
2846
2847 if (1 == arguments.length) {
2848 delete this._callbacks['$' + event];
2849 return this;
2850 } // remove specific handler
2851
2852
2853 var cb;
2854
2855 for (var i = 0; i < callbacks.length; i++) {
2856 cb = callbacks[i];
2857
2858 if (cb === fn || cb.fn === fn) {
2859 callbacks.splice(i, 1);
2860 break;
2861 }
2862 } // Remove event specific arrays for event types that no
2863 // one is subscribed for to avoid memory leak.
2864
2865
2866 if (callbacks.length === 0) {
2867 delete this._callbacks['$' + event];
2868 }
2869
2870 return this;
2871 };
2872 /**
2873 * Emit `event` with the given args.
2874 *
2875 * @param {String} event
2876 * @param {Mixed} ...
2877 * @return {Emitter}
2878 */
2879
2880
2881 Emitter.prototype.emit = function (event) {
2882 this._callbacks = this._callbacks || {};
2883 var args = new Array(arguments.length - 1),
2884 callbacks = this._callbacks['$' + event];
2885
2886 for (var i = 1; i < arguments.length; i++) {
2887 args[i - 1] = arguments[i];
2888 }
2889
2890 if (callbacks) {
2891 callbacks = callbacks.slice(0);
2892
2893 for (var i = 0, len = callbacks.length; i < len; ++i) {
2894 callbacks[i].apply(this, args);
2895 }
2896 }
2897
2898 return this;
2899 };
2900 /**
2901 * Return array of callbacks for `event`.
2902 *
2903 * @param {String} event
2904 * @return {Array}
2905 * @api public
2906 */
2907
2908
2909 Emitter.prototype.listeners = function (event) {
2910 this._callbacks = this._callbacks || {};
2911 return this._callbacks['$' + event] || [];
2912 };
2913 /**
2914 * Check if this emitter has `event` handlers.
2915 *
2916 * @param {String} event
2917 * @return {Boolean}
2918 * @api public
2919 */
2920
2921
2922 Emitter.prototype.hasListeners = function (event) {
2923 return !!this.listeners(event).length;
2924 };
2925})(componentEmitter);
2926
2927var Emitter = componentEmitter.exports;
2928
2929var anObject$5 = anObject$b;
2930
2931var iteratorClose$2 = function (iterator) {
2932 var returnMethod = iterator['return'];
2933
2934 if (returnMethod !== undefined) {
2935 return anObject$5(returnMethod.call(iterator)).value;
2936 }
2937};
2938
2939var anObject$4 = anObject$b;
2940var iteratorClose$1 = iteratorClose$2; // call something on iterator step with safe closing on error
2941
2942var callWithSafeIterationClosing$1 = function (iterator, fn, value, ENTRIES) {
2943 try {
2944 return ENTRIES ? fn(anObject$4(value)[0], value[1]) : fn(value);
2945 } catch (error) {
2946 iteratorClose$1(iterator);
2947 throw error;
2948 }
2949};
2950
2951var wellKnownSymbol$6 = wellKnownSymbol$j;
2952var Iterators$1 = iterators;
2953var ITERATOR$2 = wellKnownSymbol$6('iterator');
2954var ArrayPrototype$a = Array.prototype; // check on default Array iterator
2955
2956var isArrayIteratorMethod$2 = function (it) {
2957 return it !== undefined && (Iterators$1.Array === it || ArrayPrototype$a[ITERATOR$2] === it);
2958};
2959
2960var classof$4 = classof$9;
2961var Iterators = iterators;
2962var wellKnownSymbol$5 = wellKnownSymbol$j;
2963var ITERATOR$1 = wellKnownSymbol$5('iterator');
2964
2965var getIteratorMethod$7 = function (it) {
2966 if (it != undefined) return it[ITERATOR$1] || it['@@iterator'] || Iterators[classof$4(it)];
2967};
2968
2969var bind$9 = functionBindContext;
2970var toObject$5 = toObject$e;
2971var callWithSafeIterationClosing = callWithSafeIterationClosing$1;
2972var isArrayIteratorMethod$1 = isArrayIteratorMethod$2;
2973var toLength$6 = toLength$c;
2974var createProperty$3 = createProperty$5;
2975var getIteratorMethod$6 = getIteratorMethod$7; // `Array.from` method implementation
2976// https://tc39.es/ecma262/#sec-array.from
2977
2978var arrayFrom = function from(arrayLike
2979/* , mapfn = undefined, thisArg = undefined */
2980) {
2981 var O = toObject$5(arrayLike);
2982 var C = typeof this == 'function' ? this : Array;
2983 var argumentsLength = arguments.length;
2984 var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
2985 var mapping = mapfn !== undefined;
2986 var iteratorMethod = getIteratorMethod$6(O);
2987 var index = 0;
2988 var length, result, step, iterator, next, value;
2989 if (mapping) mapfn = bind$9(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2); // if the target is not iterable or it's an array with the default iterator - use a simple case
2990
2991 if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod$1(iteratorMethod))) {
2992 iterator = iteratorMethod.call(O);
2993 next = iterator.next;
2994 result = new C();
2995
2996 for (; !(step = next.call(iterator)).done; index++) {
2997 value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
2998 createProperty$3(result, index, value);
2999 }
3000 } else {
3001 length = toLength$6(O.length);
3002 result = new C(length);
3003
3004 for (; length > index; index++) {
3005 value = mapping ? mapfn(O[index], index) : O[index];
3006 createProperty$3(result, index, value);
3007 }
3008 }
3009
3010 result.length = index;
3011 return result;
3012};
3013
3014var wellKnownSymbol$4 = wellKnownSymbol$j;
3015var ITERATOR = wellKnownSymbol$4('iterator');
3016var SAFE_CLOSING = false;
3017
3018try {
3019 var called = 0;
3020 var iteratorWithReturn = {
3021 next: function () {
3022 return {
3023 done: !!called++
3024 };
3025 },
3026 'return': function () {
3027 SAFE_CLOSING = true;
3028 }
3029 };
3030
3031 iteratorWithReturn[ITERATOR] = function () {
3032 return this;
3033 }; // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
3034
3035
3036 Array.from(iteratorWithReturn, function () {
3037 throw 2;
3038 });
3039} catch (error) {
3040 /* empty */
3041}
3042
3043var checkCorrectnessOfIteration$1 = function (exec, SKIP_CLOSING) {
3044 if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
3045 var ITERATION_SUPPORT = false;
3046
3047 try {
3048 var object = {};
3049
3050 object[ITERATOR] = function () {
3051 return {
3052 next: function () {
3053 return {
3054 done: ITERATION_SUPPORT = true
3055 };
3056 }
3057 };
3058 };
3059
3060 exec(object);
3061 } catch (error) {
3062 /* empty */
3063 }
3064
3065 return ITERATION_SUPPORT;
3066};
3067
3068var $$s = _export;
3069var from$5 = arrayFrom;
3070var checkCorrectnessOfIteration = checkCorrectnessOfIteration$1;
3071var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
3072 // eslint-disable-next-line es/no-array-from -- required for testing
3073 Array.from(iterable);
3074}); // `Array.from` method
3075// https://tc39.es/ecma262/#sec-array.from
3076
3077$$s({
3078 target: 'Array',
3079 stat: true,
3080 forced: INCORRECT_ITERATION
3081}, {
3082 from: from$5
3083});
3084
3085var path$h = path$s;
3086var from$4 = path$h.Array.from;
3087
3088var parent$C = from$4;
3089var from$3 = parent$C;
3090
3091var from$2 = from$3;
3092
3093var getIteratorMethod$5 = getIteratorMethod$7;
3094var getIteratorMethod_1 = getIteratorMethod$5;
3095
3096var parent$B = getIteratorMethod_1;
3097var getIteratorMethod$4 = parent$B;
3098
3099var parent$A = getIteratorMethod$4;
3100var getIteratorMethod$3 = parent$A;
3101
3102var getIteratorMethod$2 = getIteratorMethod$3;
3103
3104var path$g = path$s;
3105var getOwnPropertySymbols$2 = path$g.Object.getOwnPropertySymbols;
3106
3107var parent$z = getOwnPropertySymbols$2;
3108var getOwnPropertySymbols$1 = parent$z;
3109
3110var getOwnPropertySymbols = getOwnPropertySymbols$1;
3111
3112var getOwnPropertyDescriptor$3 = {exports: {}};
3113
3114var $$r = _export;
3115var fails$7 = fails$l;
3116var toIndexedObject$3 = toIndexedObject$a;
3117var nativeGetOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
3118var DESCRIPTORS$8 = descriptors;
3119var FAILS_ON_PRIMITIVES$2 = fails$7(function () {
3120 nativeGetOwnPropertyDescriptor(1);
3121});
3122var FORCED$3 = !DESCRIPTORS$8 || FAILS_ON_PRIMITIVES$2; // `Object.getOwnPropertyDescriptor` method
3123// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
3124
3125$$r({
3126 target: 'Object',
3127 stat: true,
3128 forced: FORCED$3,
3129 sham: !DESCRIPTORS$8
3130}, {
3131 getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
3132 return nativeGetOwnPropertyDescriptor(toIndexedObject$3(it), key);
3133 }
3134});
3135
3136var path$f = path$s;
3137var Object$4 = path$f.Object;
3138
3139var getOwnPropertyDescriptor$2 = getOwnPropertyDescriptor$3.exports = function getOwnPropertyDescriptor(it, key) {
3140 return Object$4.getOwnPropertyDescriptor(it, key);
3141};
3142
3143if (Object$4.getOwnPropertyDescriptor.sham) getOwnPropertyDescriptor$2.sham = true;
3144
3145var parent$y = getOwnPropertyDescriptor$3.exports;
3146var getOwnPropertyDescriptor$1 = parent$y;
3147
3148var getOwnPropertyDescriptor = getOwnPropertyDescriptor$1;
3149
3150var getBuiltIn$3 = getBuiltIn$8;
3151var getOwnPropertyNamesModule$1 = objectGetOwnPropertyNames;
3152var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
3153var anObject$3 = anObject$b; // all object keys, includes non-enumerable and symbols
3154
3155var ownKeys$6 = getBuiltIn$3('Reflect', 'ownKeys') || function ownKeys(it) {
3156 var keys = getOwnPropertyNamesModule$1.f(anObject$3(it));
3157 var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
3158 return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
3159};
3160
3161var $$q = _export;
3162var DESCRIPTORS$7 = descriptors;
3163var ownKeys$5 = ownKeys$6;
3164var toIndexedObject$2 = toIndexedObject$a;
3165var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
3166var createProperty$2 = createProperty$5; // `Object.getOwnPropertyDescriptors` method
3167// https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
3168
3169$$q({
3170 target: 'Object',
3171 stat: true,
3172 sham: !DESCRIPTORS$7
3173}, {
3174 getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
3175 var O = toIndexedObject$2(object);
3176 var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
3177 var keys = ownKeys$5(O);
3178 var result = {};
3179 var index = 0;
3180 var key, descriptor;
3181
3182 while (keys.length > index) {
3183 descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
3184 if (descriptor !== undefined) createProperty$2(result, key, descriptor);
3185 }
3186
3187 return result;
3188 }
3189});
3190
3191var path$e = path$s;
3192var getOwnPropertyDescriptors$2 = path$e.Object.getOwnPropertyDescriptors;
3193
3194var parent$x = getOwnPropertyDescriptors$2;
3195var getOwnPropertyDescriptors$1 = parent$x;
3196
3197var getOwnPropertyDescriptors = getOwnPropertyDescriptors$1;
3198
3199var defineProperties$4 = {exports: {}};
3200
3201var $$p = _export;
3202var DESCRIPTORS$6 = descriptors;
3203var defineProperties$3 = objectDefineProperties; // `Object.defineProperties` method
3204// https://tc39.es/ecma262/#sec-object.defineproperties
3205
3206$$p({
3207 target: 'Object',
3208 stat: true,
3209 forced: !DESCRIPTORS$6,
3210 sham: !DESCRIPTORS$6
3211}, {
3212 defineProperties: defineProperties$3
3213});
3214
3215var path$d = path$s;
3216var Object$3 = path$d.Object;
3217
3218var defineProperties$2 = defineProperties$4.exports = function defineProperties(T, D) {
3219 return Object$3.defineProperties(T, D);
3220};
3221
3222if (Object$3.defineProperties.sham) defineProperties$2.sham = true;
3223
3224var parent$w = defineProperties$4.exports;
3225var defineProperties$1 = parent$w;
3226
3227var defineProperties = defineProperties$1;
3228
3229var defineProperty$8 = {exports: {}};
3230
3231var $$o = _export;
3232var DESCRIPTORS$5 = descriptors;
3233var objectDefinePropertyModile = objectDefineProperty; // `Object.defineProperty` method
3234// https://tc39.es/ecma262/#sec-object.defineproperty
3235
3236$$o({
3237 target: 'Object',
3238 stat: true,
3239 forced: !DESCRIPTORS$5,
3240 sham: !DESCRIPTORS$5
3241}, {
3242 defineProperty: objectDefinePropertyModile.f
3243});
3244
3245var path$c = path$s;
3246var Object$2 = path$c.Object;
3247
3248var defineProperty$7 = defineProperty$8.exports = function defineProperty(it, key, desc) {
3249 return Object$2.defineProperty(it, key, desc);
3250};
3251
3252if (Object$2.defineProperty.sham) defineProperty$7.sham = true;
3253
3254var parent$v = defineProperty$8.exports;
3255var defineProperty$6 = parent$v;
3256
3257var defineProperty$5 = defineProperty$6;
3258
3259function _classCallCheck(instance, Constructor) {
3260 if (!(instance instanceof Constructor)) {
3261 throw new TypeError("Cannot call a class as a function");
3262 }
3263}
3264
3265var parent$u = defineProperty$6;
3266var defineProperty$4 = parent$u;
3267
3268var defineProperty$3 = defineProperty$4;
3269
3270function _defineProperties(target, props) {
3271 for (var i = 0; i < props.length; i++) {
3272 var descriptor = props[i];
3273 descriptor.enumerable = descriptor.enumerable || false;
3274 descriptor.configurable = true;
3275 if ("value" in descriptor) descriptor.writable = true;
3276
3277 defineProperty$3(target, descriptor.key, descriptor);
3278 }
3279}
3280
3281function _createClass(Constructor, protoProps, staticProps) {
3282 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
3283 if (staticProps) _defineProperties(Constructor, staticProps);
3284 return Constructor;
3285}
3286
3287function _defineProperty(obj, key, value) {
3288 if (key in obj) {
3289 defineProperty$3(obj, key, {
3290 value: value,
3291 enumerable: true,
3292 configurable: true,
3293 writable: true
3294 });
3295 } else {
3296 obj[key] = value;
3297 }
3298
3299 return obj;
3300}
3301
3302var parent$t = isArray$6;
3303var isArray$4 = parent$t;
3304
3305var isArray$3 = isArray$4;
3306
3307function _arrayWithHoles(arr) {
3308 if (isArray$3(arr)) return arr;
3309}
3310
3311function _iterableToArrayLimit(arr, i) {
3312 var _i = arr == null ? null : typeof symbol$1 !== "undefined" && getIteratorMethod$2(arr) || arr["@@iterator"];
3313
3314 if (_i == null) return;
3315 var _arr = [];
3316 var _n = true;
3317 var _d = false;
3318
3319 var _s, _e;
3320
3321 try {
3322 for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
3323 _arr.push(_s.value);
3324
3325 if (i && _arr.length === i) break;
3326 }
3327 } catch (err) {
3328 _d = true;
3329 _e = err;
3330 } finally {
3331 try {
3332 if (!_n && _i["return"] != null) _i["return"]();
3333 } finally {
3334 if (_d) throw _e;
3335 }
3336 }
3337
3338 return _arr;
3339}
3340
3341var $$n = _export;
3342var isObject$5 = isObject$f;
3343var isArray$2 = isArray$c;
3344var toAbsoluteIndex$1 = toAbsoluteIndex$4;
3345var toLength$5 = toLength$c;
3346var toIndexedObject$1 = toIndexedObject$a;
3347var createProperty$1 = createProperty$5;
3348var wellKnownSymbol$3 = wellKnownSymbol$j;
3349var arrayMethodHasSpeciesSupport$2 = arrayMethodHasSpeciesSupport$5;
3350var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport$2('slice');
3351var SPECIES$1 = wellKnownSymbol$3('species');
3352var nativeSlice = [].slice;
3353var max$1 = Math.max; // `Array.prototype.slice` method
3354// https://tc39.es/ecma262/#sec-array.prototype.slice
3355// fallback for not array-like ES3 strings and DOM objects
3356
3357$$n({
3358 target: 'Array',
3359 proto: true,
3360 forced: !HAS_SPECIES_SUPPORT$2
3361}, {
3362 slice: function slice(start, end) {
3363 var O = toIndexedObject$1(this);
3364 var length = toLength$5(O.length);
3365 var k = toAbsoluteIndex$1(start, length);
3366 var fin = toAbsoluteIndex$1(end === undefined ? length : end, length); // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
3367
3368 var Constructor, result, n;
3369
3370 if (isArray$2(O)) {
3371 Constructor = O.constructor; // cross-realm fallback
3372
3373 if (typeof Constructor == 'function' && (Constructor === Array || isArray$2(Constructor.prototype))) {
3374 Constructor = undefined;
3375 } else if (isObject$5(Constructor)) {
3376 Constructor = Constructor[SPECIES$1];
3377 if (Constructor === null) Constructor = undefined;
3378 }
3379
3380 if (Constructor === Array || Constructor === undefined) {
3381 return nativeSlice.call(O, k, fin);
3382 }
3383 }
3384
3385 result = new (Constructor === undefined ? Array : Constructor)(max$1(fin - k, 0));
3386
3387 for (n = 0; k < fin; k++, n++) if (k in O) createProperty$1(result, n, O[k]);
3388
3389 result.length = n;
3390 return result;
3391 }
3392});
3393
3394var entryVirtual$c = entryVirtual$k;
3395var slice$6 = entryVirtual$c('Array').slice;
3396
3397var slice$5 = slice$6;
3398var ArrayPrototype$9 = Array.prototype;
3399
3400var slice_1 = function (it) {
3401 var own = it.slice;
3402 return it === ArrayPrototype$9 || it instanceof Array && own === ArrayPrototype$9.slice ? slice$5 : own;
3403};
3404
3405var parent$s = slice_1;
3406var slice$4 = parent$s;
3407
3408var parent$r = slice$4;
3409var slice$3 = parent$r;
3410
3411var slice$2 = slice$3;
3412
3413var parent$q = from$3;
3414var from$1 = parent$q;
3415
3416var from = from$1;
3417
3418function _arrayLikeToArray$2(arr, len) {
3419 if (len == null || len > arr.length) len = arr.length;
3420
3421 for (var i = 0, arr2 = new Array(len); i < len; i++) {
3422 arr2[i] = arr[i];
3423 }
3424
3425 return arr2;
3426}
3427
3428function _unsupportedIterableToArray$2(o, minLen) {
3429 var _context;
3430
3431 if (!o) return;
3432 if (typeof o === "string") return _arrayLikeToArray$2(o, minLen);
3433
3434 var n = slice$2(_context = Object.prototype.toString.call(o)).call(_context, 8, -1);
3435
3436 if (n === "Object" && o.constructor) n = o.constructor.name;
3437 if (n === "Map" || n === "Set") return from(o);
3438 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen);
3439}
3440
3441function _nonIterableRest() {
3442 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3443}
3444
3445function _slicedToArray(arr, i) {
3446 return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$2(arr, i) || _nonIterableRest();
3447}
3448
3449function _arrayWithoutHoles(arr) {
3450 if (isArray$3(arr)) return _arrayLikeToArray$2(arr);
3451}
3452
3453function _iterableToArray(iter) {
3454 if (typeof symbol$1 !== "undefined" && getIteratorMethod$2(iter) != null || iter["@@iterator"] != null) return from(iter);
3455}
3456
3457function _nonIterableSpread() {
3458 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3459}
3460
3461function _toConsumableArray(arr) {
3462 return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$2(arr) || _nonIterableSpread();
3463}
3464
3465var symbol = symbol$3;
3466
3467var slice$1 = slice$4;
3468
3469var $$m = _export;
3470var ownKeys$4 = ownKeys$6; // `Reflect.ownKeys` method
3471// https://tc39.es/ecma262/#sec-reflect.ownkeys
3472
3473$$m({
3474 target: 'Reflect',
3475 stat: true
3476}, {
3477 ownKeys: ownKeys$4
3478});
3479
3480var path$b = path$s;
3481var ownKeys$3 = path$b.Reflect.ownKeys;
3482
3483var parent$p = ownKeys$3;
3484var ownKeys$2 = parent$p;
3485
3486var ownKeys$1 = ownKeys$2;
3487
3488var $$l = _export;
3489var $map = arrayIteration.map;
3490var arrayMethodHasSpeciesSupport$1 = arrayMethodHasSpeciesSupport$5;
3491var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport$1('map'); // `Array.prototype.map` method
3492// https://tc39.es/ecma262/#sec-array.prototype.map
3493// with adding support of @@species
3494
3495$$l({
3496 target: 'Array',
3497 proto: true,
3498 forced: !HAS_SPECIES_SUPPORT$1
3499}, {
3500 map: function map(callbackfn
3501 /* , thisArg */
3502 ) {
3503 return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
3504 }
3505});
3506
3507var entryVirtual$b = entryVirtual$k;
3508var map$6 = entryVirtual$b('Array').map;
3509
3510var map$5 = map$6;
3511var ArrayPrototype$8 = Array.prototype;
3512
3513var map_1 = function (it) {
3514 var own = it.map;
3515 return it === ArrayPrototype$8 || it instanceof Array && own === ArrayPrototype$8.map ? map$5 : own;
3516};
3517
3518var parent$o = map_1;
3519var map$4 = parent$o;
3520
3521var map$3 = map$4;
3522
3523var $$k = _export;
3524var toObject$4 = toObject$e;
3525var nativeKeys = objectKeys$4;
3526var fails$6 = fails$l;
3527var FAILS_ON_PRIMITIVES$1 = fails$6(function () {
3528 nativeKeys(1);
3529}); // `Object.keys` method
3530// https://tc39.es/ecma262/#sec-object.keys
3531
3532$$k({
3533 target: 'Object',
3534 stat: true,
3535 forced: FAILS_ON_PRIMITIVES$1
3536}, {
3537 keys: function keys(it) {
3538 return nativeKeys(toObject$4(it));
3539 }
3540});
3541
3542var path$a = path$s;
3543var keys$6 = path$a.Object.keys;
3544
3545var parent$n = keys$6;
3546var keys$5 = parent$n;
3547
3548var keys$4 = keys$5;
3549
3550var $$j = _export; // `Date.now` method
3551// https://tc39.es/ecma262/#sec-date.now
3552
3553$$j({
3554 target: 'Date',
3555 stat: true
3556}, {
3557 now: function now() {
3558 return new Date().getTime();
3559 }
3560});
3561
3562var path$9 = path$s;
3563path$9.Date.now;
3564
3565var aFunction$3 = aFunction$6;
3566var isObject$4 = isObject$f;
3567var slice = [].slice;
3568var factories = {};
3569
3570var construct$3 = function (C, argsLength, args) {
3571 if (!(argsLength in factories)) {
3572 for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']'; // eslint-disable-next-line no-new-func -- we have no proper alternatives, IE8- only
3573
3574
3575 factories[argsLength] = Function('C,a', 'return new C(' + list.join(',') + ')');
3576 }
3577
3578 return factories[argsLength](C, args);
3579}; // `Function.prototype.bind` method implementation
3580// https://tc39.es/ecma262/#sec-function.prototype.bind
3581
3582
3583var functionBind = Function.bind || function bind(that
3584/* , ...args */
3585) {
3586 var fn = aFunction$3(this);
3587 var partArgs = slice.call(arguments, 1);
3588
3589 var boundFunction = function bound() {
3590 var args = partArgs.concat(slice.call(arguments));
3591 return this instanceof boundFunction ? construct$3(fn, args.length, args) : fn.apply(that, args);
3592 };
3593
3594 if (isObject$4(fn.prototype)) boundFunction.prototype = fn.prototype;
3595 return boundFunction;
3596};
3597
3598var $$i = _export;
3599var bind$8 = functionBind; // `Function.prototype.bind` method
3600// https://tc39.es/ecma262/#sec-function.prototype.bind
3601
3602$$i({
3603 target: 'Function',
3604 proto: true
3605}, {
3606 bind: bind$8
3607});
3608
3609var entryVirtual$a = entryVirtual$k;
3610var bind$7 = entryVirtual$a('Function').bind;
3611
3612var bind$6 = bind$7;
3613var FunctionPrototype = Function.prototype;
3614
3615var bind_1 = function (it) {
3616 var own = it.bind;
3617 return it === FunctionPrototype || it instanceof Function && own === FunctionPrototype.bind ? bind$6 : own;
3618};
3619
3620var parent$m = bind_1;
3621var bind$5 = parent$m;
3622
3623var bind$4 = bind$5;
3624
3625var $$h = _export;
3626var isArray$1 = isArray$c;
3627var nativeReverse = [].reverse;
3628var test = [1, 2]; // `Array.prototype.reverse` method
3629// https://tc39.es/ecma262/#sec-array.prototype.reverse
3630// fix for Safari 12.0 bug
3631// https://bugs.webkit.org/show_bug.cgi?id=188794
3632
3633$$h({
3634 target: 'Array',
3635 proto: true,
3636 forced: String(test) === String(test.reverse())
3637}, {
3638 reverse: function reverse() {
3639 // eslint-disable-next-line no-self-assign -- dirty hack
3640 if (isArray$1(this)) this.length = this.length;
3641 return nativeReverse.call(this);
3642 }
3643});
3644
3645var entryVirtual$9 = entryVirtual$k;
3646var reverse$3 = entryVirtual$9('Array').reverse;
3647
3648var reverse$2 = reverse$3;
3649var ArrayPrototype$7 = Array.prototype;
3650
3651var reverse_1 = function (it) {
3652 var own = it.reverse;
3653 return it === ArrayPrototype$7 || it instanceof Array && own === ArrayPrototype$7.reverse ? reverse$2 : own;
3654};
3655
3656var parent$l = reverse_1;
3657var reverse$1 = parent$l;
3658
3659var reverse = reverse$1;
3660
3661var $$g = _export;
3662var toAbsoluteIndex = toAbsoluteIndex$4;
3663var toInteger = toInteger$4;
3664var toLength$4 = toLength$c;
3665var toObject$3 = toObject$e;
3666var arraySpeciesCreate$1 = arraySpeciesCreate$4;
3667var createProperty = createProperty$5;
3668var arrayMethodHasSpeciesSupport = arrayMethodHasSpeciesSupport$5;
3669var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');
3670var max = Math.max;
3671var min = Math.min;
3672var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
3673var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded'; // `Array.prototype.splice` method
3674// https://tc39.es/ecma262/#sec-array.prototype.splice
3675// with adding support of @@species
3676
3677$$g({
3678 target: 'Array',
3679 proto: true,
3680 forced: !HAS_SPECIES_SUPPORT
3681}, {
3682 splice: function splice(start, deleteCount
3683 /* , ...items */
3684 ) {
3685 var O = toObject$3(this);
3686 var len = toLength$4(O.length);
3687 var actualStart = toAbsoluteIndex(start, len);
3688 var argumentsLength = arguments.length;
3689 var insertCount, actualDeleteCount, A, k, from, to;
3690
3691 if (argumentsLength === 0) {
3692 insertCount = actualDeleteCount = 0;
3693 } else if (argumentsLength === 1) {
3694 insertCount = 0;
3695 actualDeleteCount = len - actualStart;
3696 } else {
3697 insertCount = argumentsLength - 2;
3698 actualDeleteCount = min(max(toInteger(deleteCount), 0), len - actualStart);
3699 }
3700
3701 if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) {
3702 throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
3703 }
3704
3705 A = arraySpeciesCreate$1(O, actualDeleteCount);
3706
3707 for (k = 0; k < actualDeleteCount; k++) {
3708 from = actualStart + k;
3709 if (from in O) createProperty(A, k, O[from]);
3710 }
3711
3712 A.length = actualDeleteCount;
3713
3714 if (insertCount < actualDeleteCount) {
3715 for (k = actualStart; k < len - actualDeleteCount; k++) {
3716 from = k + actualDeleteCount;
3717 to = k + insertCount;
3718 if (from in O) O[to] = O[from];else delete O[to];
3719 }
3720
3721 for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
3722 } else if (insertCount > actualDeleteCount) {
3723 for (k = len - actualDeleteCount; k > actualStart; k--) {
3724 from = k + actualDeleteCount - 1;
3725 to = k + insertCount - 1;
3726 if (from in O) O[to] = O[from];else delete O[to];
3727 }
3728 }
3729
3730 for (k = 0; k < insertCount; k++) {
3731 O[k + actualStart] = arguments[k + 2];
3732 }
3733
3734 O.length = len - actualDeleteCount + insertCount;
3735 return A;
3736 }
3737});
3738
3739var entryVirtual$8 = entryVirtual$k;
3740var splice$3 = entryVirtual$8('Array').splice;
3741
3742var splice$2 = splice$3;
3743var ArrayPrototype$6 = Array.prototype;
3744
3745var splice_1 = function (it) {
3746 var own = it.splice;
3747 return it === ArrayPrototype$6 || it instanceof Array && own === ArrayPrototype$6.splice ? splice$2 : own;
3748};
3749
3750var parent$k = splice_1;
3751var splice$1 = parent$k;
3752
3753var splice = splice$1;
3754
3755var $$f = _export;
3756var $includes = arrayIncludes$1.includes;
3757// https://tc39.es/ecma262/#sec-array.prototype.includes
3758
3759$$f({
3760 target: 'Array',
3761 proto: true
3762}, {
3763 includes: function includes(el
3764 /* , fromIndex = 0 */
3765 ) {
3766 return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
3767 }
3768}); // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
3769
3770var entryVirtual$7 = entryVirtual$k;
3771var includes$4 = entryVirtual$7('Array').includes;
3772
3773var isObject$3 = isObject$f;
3774var classof$3 = classofRaw$1;
3775var wellKnownSymbol$2 = wellKnownSymbol$j;
3776var MATCH$1 = wellKnownSymbol$2('match'); // `IsRegExp` abstract operation
3777// https://tc39.es/ecma262/#sec-isregexp
3778
3779var isRegexp = function (it) {
3780 var isRegExp;
3781 return isObject$3(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classof$3(it) == 'RegExp');
3782};
3783
3784var isRegExp = isRegexp;
3785
3786var notARegexp = function (it) {
3787 if (isRegExp(it)) {
3788 throw TypeError("The method doesn't accept regular expressions");
3789 }
3790
3791 return it;
3792};
3793
3794var wellKnownSymbol$1 = wellKnownSymbol$j;
3795var MATCH = wellKnownSymbol$1('match');
3796
3797var correctIsRegexpLogic = function (METHOD_NAME) {
3798 var regexp = /./;
3799
3800 try {
3801 '/./'[METHOD_NAME](regexp);
3802 } catch (error1) {
3803 try {
3804 regexp[MATCH] = false;
3805 return '/./'[METHOD_NAME](regexp);
3806 } catch (error2) {
3807 /* empty */
3808 }
3809 }
3810
3811 return false;
3812};
3813
3814var $$e = _export;
3815var notARegExp = notARegexp;
3816var requireObjectCoercible = requireObjectCoercible$5;
3817var toString$1 = toString$9;
3818var correctIsRegExpLogic = correctIsRegexpLogic; // `String.prototype.includes` method
3819// https://tc39.es/ecma262/#sec-string.prototype.includes
3820
3821$$e({
3822 target: 'String',
3823 proto: true,
3824 forced: !correctIsRegExpLogic('includes')
3825}, {
3826 includes: function includes(searchString
3827 /* , position = 0 */
3828 ) {
3829 return !!~toString$1(requireObjectCoercible(this)).indexOf(toString$1(notARegExp(searchString)), arguments.length > 1 ? arguments[1] : undefined);
3830 }
3831});
3832
3833var entryVirtual$6 = entryVirtual$k;
3834var includes$3 = entryVirtual$6('String').includes;
3835
3836var arrayIncludes = includes$4;
3837var stringIncludes = includes$3;
3838var ArrayPrototype$5 = Array.prototype;
3839var StringPrototype = String.prototype;
3840
3841var includes$2 = function (it) {
3842 var own = it.includes;
3843 if (it === ArrayPrototype$5 || it instanceof Array && own === ArrayPrototype$5.includes) return arrayIncludes;
3844
3845 if (typeof it === 'string' || it === StringPrototype || it instanceof String && own === StringPrototype.includes) {
3846 return stringIncludes;
3847 }
3848
3849 return own;
3850};
3851
3852var parent$j = includes$2;
3853var includes$1 = parent$j;
3854
3855var includes = includes$1;
3856
3857var $$d = _export;
3858var fails$5 = fails$l;
3859var toObject$2 = toObject$e;
3860var nativeGetPrototypeOf = objectGetPrototypeOf;
3861var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
3862var FAILS_ON_PRIMITIVES = fails$5(function () {
3863 nativeGetPrototypeOf(1);
3864}); // `Object.getPrototypeOf` method
3865// https://tc39.es/ecma262/#sec-object.getprototypeof
3866
3867$$d({
3868 target: 'Object',
3869 stat: true,
3870 forced: FAILS_ON_PRIMITIVES,
3871 sham: !CORRECT_PROTOTYPE_GETTER
3872}, {
3873 getPrototypeOf: function getPrototypeOf(it) {
3874 return nativeGetPrototypeOf(toObject$2(it));
3875 }
3876});
3877
3878var path$8 = path$s;
3879var getPrototypeOf$4 = path$8.Object.getPrototypeOf;
3880
3881var parent$i = getPrototypeOf$4;
3882var getPrototypeOf$3 = parent$i;
3883
3884var getPrototypeOf$2 = getPrototypeOf$3;
3885
3886var DESCRIPTORS$4 = descriptors;
3887var objectKeys = objectKeys$4;
3888var toIndexedObject = toIndexedObject$a;
3889var propertyIsEnumerable = objectPropertyIsEnumerable.f; // `Object.{ entries, values }` methods implementation
3890
3891var createMethod$1 = function (TO_ENTRIES) {
3892 return function (it) {
3893 var O = toIndexedObject(it);
3894 var keys = objectKeys(O);
3895 var length = keys.length;
3896 var i = 0;
3897 var result = [];
3898 var key;
3899
3900 while (length > i) {
3901 key = keys[i++];
3902
3903 if (!DESCRIPTORS$4 || propertyIsEnumerable.call(O, key)) {
3904 result.push(TO_ENTRIES ? [key, O[key]] : O[key]);
3905 }
3906 }
3907
3908 return result;
3909 };
3910};
3911
3912var objectToArray = {
3913 // `Object.entries` method
3914 // https://tc39.es/ecma262/#sec-object.entries
3915 entries: createMethod$1(true),
3916 // `Object.values` method
3917 // https://tc39.es/ecma262/#sec-object.values
3918 values: createMethod$1(false)
3919};
3920
3921var $$c = _export;
3922var $values = objectToArray.values; // `Object.values` method
3923// https://tc39.es/ecma262/#sec-object.values
3924
3925$$c({
3926 target: 'Object',
3927 stat: true
3928}, {
3929 values: function values(O) {
3930 return $values(O);
3931 }
3932});
3933
3934var path$7 = path$s;
3935path$7.Object.values;
3936
3937var global$3 = global$i;
3938var toString = toString$9;
3939var trim = stringTrim.trim;
3940var whitespaces$1 = whitespaces$4;
3941var $parseInt = global$3.parseInt;
3942var hex = /^[+-]?0[Xx]/;
3943var FORCED$2 = $parseInt(whitespaces$1 + '08') !== 8 || $parseInt(whitespaces$1 + '0x16') !== 22; // `parseInt` method
3944// https://tc39.es/ecma262/#sec-parseint-string-radix
3945
3946var numberParseInt = FORCED$2 ? function parseInt(string, radix) {
3947 var S = trim(toString(string));
3948 return $parseInt(S, radix >>> 0 || (hex.test(S) ? 16 : 10));
3949} : $parseInt;
3950
3951var $$b = _export;
3952var parseIntImplementation = numberParseInt; // `parseInt` method
3953// https://tc39.es/ecma262/#sec-parseint-string-radix
3954
3955$$b({
3956 global: true,
3957 forced: parseInt != parseIntImplementation
3958}, {
3959 parseInt: parseIntImplementation
3960});
3961
3962var path$6 = path$s;
3963var _parseInt$2 = path$6.parseInt;
3964
3965var parent$h = _parseInt$2;
3966var _parseInt$1 = parent$h;
3967
3968var _parseInt = _parseInt$1;
3969
3970var fails$4 = fails$l;
3971var whitespaces = whitespaces$4;
3972var non = '\u200B\u0085\u180E'; // check that a method works with the correct list
3973// of whitespaces and has a correct name
3974
3975var stringTrimForced = function (METHOD_NAME) {
3976 return fails$4(function () {
3977 return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME;
3978 });
3979};
3980
3981var $$a = _export;
3982var $trim = stringTrim.trim;
3983var forcedStringTrimMethod = stringTrimForced; // `String.prototype.trim` method
3984// https://tc39.es/ecma262/#sec-string.prototype.trim
3985
3986$$a({
3987 target: 'String',
3988 proto: true,
3989 forced: forcedStringTrimMethod('trim')
3990}, {
3991 trim: function trim() {
3992 return $trim(this);
3993 }
3994});
3995
3996var entryVirtual$5 = entryVirtual$k;
3997entryVirtual$5('String').trim;
3998
3999var $$9 = _export;
4000var DESCRIPTORS$3 = descriptors;
4001var create$7 = objectCreate; // `Object.create` method
4002// https://tc39.es/ecma262/#sec-object.create
4003
4004$$9({
4005 target: 'Object',
4006 stat: true,
4007 sham: !DESCRIPTORS$3
4008}, {
4009 create: create$7
4010});
4011
4012var path$5 = path$s;
4013var Object$1 = path$5.Object;
4014
4015var create$6 = function create(P, D) {
4016 return Object$1.create(P, D);
4017};
4018
4019var parent$g = create$6;
4020var create$5 = parent$g;
4021
4022var create$4 = create$5;
4023
4024var $$8 = _export;
4025var getBuiltIn$2 = getBuiltIn$8;
4026var fails$3 = fails$l;
4027var $stringify = getBuiltIn$2('JSON', 'stringify');
4028var re = /[\uD800-\uDFFF]/g;
4029var low = /^[\uD800-\uDBFF]$/;
4030var hi = /^[\uDC00-\uDFFF]$/;
4031
4032var fix = function (match, offset, string) {
4033 var prev = string.charAt(offset - 1);
4034 var next = string.charAt(offset + 1);
4035
4036 if (low.test(match) && !hi.test(next) || hi.test(match) && !low.test(prev)) {
4037 return '\\u' + match.charCodeAt(0).toString(16);
4038 }
4039
4040 return match;
4041};
4042
4043var FORCED$1 = fails$3(function () {
4044 return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"' || $stringify('\uDEAD') !== '"\\udead"';
4045});
4046
4047if ($stringify) {
4048 // `JSON.stringify` method
4049 // https://tc39.es/ecma262/#sec-json.stringify
4050 // https://github.com/tc39/proposal-well-formed-stringify
4051 $$8({
4052 target: 'JSON',
4053 stat: true,
4054 forced: FORCED$1
4055 }, {
4056 // eslint-disable-next-line no-unused-vars -- required for `.length`
4057 stringify: function stringify(it, replacer, space) {
4058 var result = $stringify.apply(null, arguments);
4059 return typeof result == 'string' ? result.replace(re, fix) : result;
4060 }
4061 });
4062}
4063
4064var core = path$s; // eslint-disable-next-line es/no-json -- safe
4065
4066if (!core.JSON) core.JSON = {
4067 stringify: JSON.stringify
4068}; // eslint-disable-next-line no-unused-vars -- required for `.length`
4069
4070var stringify$3 = function stringify(it, replacer, space) {
4071 return core.JSON.stringify.apply(null, arguments);
4072};
4073
4074var parent$f = stringify$3;
4075var stringify$2 = parent$f;
4076
4077var stringify$1 = stringify$2;
4078
4079/*! Hammer.JS - v2.0.17-rc - 2019-12-16
4080 * http://naver.github.io/egjs
4081 *
4082 * Forked By Naver egjs
4083 * Copyright (c) hammerjs
4084 * Licensed under the MIT license */
4085function _extends() {
4086 _extends = Object.assign || function (target) {
4087 for (var i = 1; i < arguments.length; i++) {
4088 var source = arguments[i];
4089
4090 for (var key in source) {
4091 if (Object.prototype.hasOwnProperty.call(source, key)) {
4092 target[key] = source[key];
4093 }
4094 }
4095 }
4096
4097 return target;
4098 };
4099
4100 return _extends.apply(this, arguments);
4101}
4102
4103function _inheritsLoose(subClass, superClass) {
4104 subClass.prototype = Object.create(superClass.prototype);
4105 subClass.prototype.constructor = subClass;
4106 subClass.__proto__ = superClass;
4107}
4108
4109function _assertThisInitialized$1(self) {
4110 if (self === void 0) {
4111 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4112 }
4113
4114 return self;
4115}
4116/**
4117 * @private
4118 * extend object.
4119 * means that properties in dest will be overwritten by the ones in src.
4120 * @param {Object} target
4121 * @param {...Object} objects_to_assign
4122 * @returns {Object} target
4123 */
4124
4125
4126var assign;
4127
4128if (typeof Object.assign !== 'function') {
4129 assign = function assign(target) {
4130 if (target === undefined || target === null) {
4131 throw new TypeError('Cannot convert undefined or null to object');
4132 }
4133
4134 var output = Object(target);
4135
4136 for (var index = 1; index < arguments.length; index++) {
4137 var source = arguments[index];
4138
4139 if (source !== undefined && source !== null) {
4140 for (var nextKey in source) {
4141 if (source.hasOwnProperty(nextKey)) {
4142 output[nextKey] = source[nextKey];
4143 }
4144 }
4145 }
4146 }
4147
4148 return output;
4149 };
4150} else {
4151 assign = Object.assign;
4152}
4153
4154var assign$1 = assign;
4155var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
4156var TEST_ELEMENT = typeof document === "undefined" ? {
4157 style: {}
4158} : document.createElement('div');
4159var TYPE_FUNCTION = 'function';
4160var round = Math.round,
4161 abs = Math.abs;
4162var now = Date.now;
4163/**
4164 * @private
4165 * get the prefixed property
4166 * @param {Object} obj
4167 * @param {String} property
4168 * @returns {String|Undefined} prefixed
4169 */
4170
4171function prefixed(obj, property) {
4172 var prefix;
4173 var prop;
4174 var camelProp = property[0].toUpperCase() + property.slice(1);
4175 var i = 0;
4176
4177 while (i < VENDOR_PREFIXES.length) {
4178 prefix = VENDOR_PREFIXES[i];
4179 prop = prefix ? prefix + camelProp : property;
4180
4181 if (prop in obj) {
4182 return prop;
4183 }
4184
4185 i++;
4186 }
4187
4188 return undefined;
4189}
4190/* eslint-disable no-new-func, no-nested-ternary */
4191
4192
4193var win;
4194
4195if (typeof window === "undefined") {
4196 // window is undefined in node.js
4197 win = {};
4198} else {
4199 win = window;
4200}
4201
4202var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
4203var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
4204
4205function getTouchActionProps() {
4206 if (!NATIVE_TOUCH_ACTION) {
4207 return false;
4208 }
4209
4210 var touchMap = {};
4211 var cssSupports = win.CSS && win.CSS.supports;
4212 ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function (val) {
4213 // If css.supports is not supported but there is native touch-action assume it supports
4214 // all values. This is the case for IE 10 and 11.
4215 return touchMap[val] = cssSupports ? win.CSS.supports('touch-action', val) : true;
4216 });
4217 return touchMap;
4218}
4219
4220var TOUCH_ACTION_COMPUTE = 'compute';
4221var TOUCH_ACTION_AUTO = 'auto';
4222var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
4223
4224var TOUCH_ACTION_NONE = 'none';
4225var TOUCH_ACTION_PAN_X = 'pan-x';
4226var TOUCH_ACTION_PAN_Y = 'pan-y';
4227var TOUCH_ACTION_MAP = getTouchActionProps();
4228var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
4229var SUPPORT_TOUCH = ('ontouchstart' in win);
4230var SUPPORT_POINTER_EVENTS = prefixed(win, 'PointerEvent') !== undefined;
4231var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
4232var INPUT_TYPE_TOUCH = 'touch';
4233var INPUT_TYPE_PEN = 'pen';
4234var INPUT_TYPE_MOUSE = 'mouse';
4235var INPUT_TYPE_KINECT = 'kinect';
4236var COMPUTE_INTERVAL = 25;
4237var INPUT_START = 1;
4238var INPUT_MOVE = 2;
4239var INPUT_END = 4;
4240var INPUT_CANCEL = 8;
4241var DIRECTION_NONE = 1;
4242var DIRECTION_LEFT = 2;
4243var DIRECTION_RIGHT = 4;
4244var DIRECTION_UP = 8;
4245var DIRECTION_DOWN = 16;
4246var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
4247var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
4248var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
4249var PROPS_XY = ['x', 'y'];
4250var PROPS_CLIENT_XY = ['clientX', 'clientY'];
4251/**
4252 * @private
4253 * walk objects and arrays
4254 * @param {Object} obj
4255 * @param {Function} iterator
4256 * @param {Object} context
4257 */
4258
4259function each(obj, iterator, context) {
4260 var i;
4261
4262 if (!obj) {
4263 return;
4264 }
4265
4266 if (obj.forEach) {
4267 obj.forEach(iterator, context);
4268 } else if (obj.length !== undefined) {
4269 i = 0;
4270
4271 while (i < obj.length) {
4272 iterator.call(context, obj[i], i, obj);
4273 i++;
4274 }
4275 } else {
4276 for (i in obj) {
4277 obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
4278 }
4279 }
4280}
4281/**
4282 * @private
4283 * let a boolean value also be a function that must return a boolean
4284 * this first item in args will be used as the context
4285 * @param {Boolean|Function} val
4286 * @param {Array} [args]
4287 * @returns {Boolean}
4288 */
4289
4290
4291function boolOrFn(val, args) {
4292 if (typeof val === TYPE_FUNCTION) {
4293 return val.apply(args ? args[0] || undefined : undefined, args);
4294 }
4295
4296 return val;
4297}
4298/**
4299 * @private
4300 * small indexOf wrapper
4301 * @param {String} str
4302 * @param {String} find
4303 * @returns {Boolean} found
4304 */
4305
4306
4307function inStr(str, find) {
4308 return str.indexOf(find) > -1;
4309}
4310/**
4311 * @private
4312 * when the touchActions are collected they are not a valid value, so we need to clean things up. *
4313 * @param {String} actions
4314 * @returns {*}
4315 */
4316
4317
4318function cleanTouchActions(actions) {
4319 // none
4320 if (inStr(actions, TOUCH_ACTION_NONE)) {
4321 return TOUCH_ACTION_NONE;
4322 }
4323
4324 var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
4325 var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y); // if both pan-x and pan-y are set (different recognizers
4326 // for different directions, e.g. horizontal pan but vertical swipe?)
4327 // we need none (as otherwise with pan-x pan-y combined none of these
4328 // recognizers will work, since the browser would handle all panning
4329
4330 if (hasPanX && hasPanY) {
4331 return TOUCH_ACTION_NONE;
4332 } // pan-x OR pan-y
4333
4334
4335 if (hasPanX || hasPanY) {
4336 return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
4337 } // manipulation
4338
4339
4340 if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
4341 return TOUCH_ACTION_MANIPULATION;
4342 }
4343
4344 return TOUCH_ACTION_AUTO;
4345}
4346/**
4347 * @private
4348 * Touch Action
4349 * sets the touchAction property or uses the js alternative
4350 * @param {Manager} manager
4351 * @param {String} value
4352 * @constructor
4353 */
4354
4355
4356var TouchAction = /*#__PURE__*/function () {
4357 function TouchAction(manager, value) {
4358 this.manager = manager;
4359 this.set(value);
4360 }
4361 /**
4362 * @private
4363 * set the touchAction value on the element or enable the polyfill
4364 * @param {String} value
4365 */
4366
4367
4368 var _proto = TouchAction.prototype;
4369
4370 _proto.set = function set(value) {
4371 // find out the touch-action by the event handlers
4372 if (value === TOUCH_ACTION_COMPUTE) {
4373 value = this.compute();
4374 }
4375
4376 if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
4377 this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
4378 }
4379
4380 this.actions = value.toLowerCase().trim();
4381 };
4382 /**
4383 * @private
4384 * just re-set the touchAction value
4385 */
4386
4387
4388 _proto.update = function update() {
4389 this.set(this.manager.options.touchAction);
4390 };
4391 /**
4392 * @private
4393 * compute the value for the touchAction property based on the recognizer's settings
4394 * @returns {String} value
4395 */
4396
4397
4398 _proto.compute = function compute() {
4399 var actions = [];
4400 each(this.manager.recognizers, function (recognizer) {
4401 if (boolOrFn(recognizer.options.enable, [recognizer])) {
4402 actions = actions.concat(recognizer.getTouchAction());
4403 }
4404 });
4405 return cleanTouchActions(actions.join(' '));
4406 };
4407 /**
4408 * @private
4409 * this method is called on each input cycle and provides the preventing of the browser behavior
4410 * @param {Object} input
4411 */
4412
4413
4414 _proto.preventDefaults = function preventDefaults(input) {
4415 var srcEvent = input.srcEvent;
4416 var direction = input.offsetDirection; // if the touch action did prevented once this session
4417
4418 if (this.manager.session.prevented) {
4419 srcEvent.preventDefault();
4420 return;
4421 }
4422
4423 var actions = this.actions;
4424 var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
4425 var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
4426 var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
4427
4428 if (hasNone) {
4429 // do not prevent defaults if this is a tap gesture
4430 var isTapPointer = input.pointers.length === 1;
4431 var isTapMovement = input.distance < 2;
4432 var isTapTouchTime = input.deltaTime < 250;
4433
4434 if (isTapPointer && isTapMovement && isTapTouchTime) {
4435 return;
4436 }
4437 }
4438
4439 if (hasPanX && hasPanY) {
4440 // `pan-x pan-y` means browser handles all scrolling/panning, do not prevent
4441 return;
4442 }
4443
4444 if (hasNone || hasPanY && direction & DIRECTION_HORIZONTAL || hasPanX && direction & DIRECTION_VERTICAL) {
4445 return this.preventSrc(srcEvent);
4446 }
4447 };
4448 /**
4449 * @private
4450 * call preventDefault to prevent the browser's default behavior (scrolling in most cases)
4451 * @param {Object} srcEvent
4452 */
4453
4454
4455 _proto.preventSrc = function preventSrc(srcEvent) {
4456 this.manager.session.prevented = true;
4457 srcEvent.preventDefault();
4458 };
4459
4460 return TouchAction;
4461}();
4462/**
4463 * @private
4464 * find if a node is in the given parent
4465 * @method hasParent
4466 * @param {HTMLElement} node
4467 * @param {HTMLElement} parent
4468 * @return {Boolean} found
4469 */
4470
4471
4472function hasParent(node, parent) {
4473 while (node) {
4474 if (node === parent) {
4475 return true;
4476 }
4477
4478 node = node.parentNode;
4479 }
4480
4481 return false;
4482}
4483/**
4484 * @private
4485 * get the center of all the pointers
4486 * @param {Array} pointers
4487 * @return {Object} center contains `x` and `y` properties
4488 */
4489
4490
4491function getCenter(pointers) {
4492 var pointersLength = pointers.length; // no need to loop when only one touch
4493
4494 if (pointersLength === 1) {
4495 return {
4496 x: round(pointers[0].clientX),
4497 y: round(pointers[0].clientY)
4498 };
4499 }
4500
4501 var x = 0;
4502 var y = 0;
4503 var i = 0;
4504
4505 while (i < pointersLength) {
4506 x += pointers[i].clientX;
4507 y += pointers[i].clientY;
4508 i++;
4509 }
4510
4511 return {
4512 x: round(x / pointersLength),
4513 y: round(y / pointersLength)
4514 };
4515}
4516/**
4517 * @private
4518 * create a simple clone from the input used for storage of firstInput and firstMultiple
4519 * @param {Object} input
4520 * @returns {Object} clonedInputData
4521 */
4522
4523
4524function simpleCloneInputData(input) {
4525 // make a simple copy of the pointers because we will get a reference if we don't
4526 // we only need clientXY for the calculations
4527 var pointers = [];
4528 var i = 0;
4529
4530 while (i < input.pointers.length) {
4531 pointers[i] = {
4532 clientX: round(input.pointers[i].clientX),
4533 clientY: round(input.pointers[i].clientY)
4534 };
4535 i++;
4536 }
4537
4538 return {
4539 timeStamp: now(),
4540 pointers: pointers,
4541 center: getCenter(pointers),
4542 deltaX: input.deltaX,
4543 deltaY: input.deltaY
4544 };
4545}
4546/**
4547 * @private
4548 * calculate the absolute distance between two points
4549 * @param {Object} p1 {x, y}
4550 * @param {Object} p2 {x, y}
4551 * @param {Array} [props] containing x and y keys
4552 * @return {Number} distance
4553 */
4554
4555
4556function getDistance(p1, p2, props) {
4557 if (!props) {
4558 props = PROPS_XY;
4559 }
4560
4561 var x = p2[props[0]] - p1[props[0]];
4562 var y = p2[props[1]] - p1[props[1]];
4563 return Math.sqrt(x * x + y * y);
4564}
4565/**
4566 * @private
4567 * calculate the angle between two coordinates
4568 * @param {Object} p1
4569 * @param {Object} p2
4570 * @param {Array} [props] containing x and y keys
4571 * @return {Number} angle
4572 */
4573
4574
4575function getAngle(p1, p2, props) {
4576 if (!props) {
4577 props = PROPS_XY;
4578 }
4579
4580 var x = p2[props[0]] - p1[props[0]];
4581 var y = p2[props[1]] - p1[props[1]];
4582 return Math.atan2(y, x) * 180 / Math.PI;
4583}
4584/**
4585 * @private
4586 * get the direction between two points
4587 * @param {Number} x
4588 * @param {Number} y
4589 * @return {Number} direction
4590 */
4591
4592
4593function getDirection(x, y) {
4594 if (x === y) {
4595 return DIRECTION_NONE;
4596 }
4597
4598 if (abs(x) >= abs(y)) {
4599 return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
4600 }
4601
4602 return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
4603}
4604
4605function computeDeltaXY(session, input) {
4606 var center = input.center; // let { offsetDelta:offset = {}, prevDelta = {}, prevInput = {} } = session;
4607 // jscs throwing error on defalut destructured values and without defaults tests fail
4608
4609 var offset = session.offsetDelta || {};
4610 var prevDelta = session.prevDelta || {};
4611 var prevInput = session.prevInput || {};
4612
4613 if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
4614 prevDelta = session.prevDelta = {
4615 x: prevInput.deltaX || 0,
4616 y: prevInput.deltaY || 0
4617 };
4618 offset = session.offsetDelta = {
4619 x: center.x,
4620 y: center.y
4621 };
4622 }
4623
4624 input.deltaX = prevDelta.x + (center.x - offset.x);
4625 input.deltaY = prevDelta.y + (center.y - offset.y);
4626}
4627/**
4628 * @private
4629 * calculate the velocity between two points. unit is in px per ms.
4630 * @param {Number} deltaTime
4631 * @param {Number} x
4632 * @param {Number} y
4633 * @return {Object} velocity `x` and `y`
4634 */
4635
4636
4637function getVelocity(deltaTime, x, y) {
4638 return {
4639 x: x / deltaTime || 0,
4640 y: y / deltaTime || 0
4641 };
4642}
4643/**
4644 * @private
4645 * calculate the scale factor between two pointersets
4646 * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
4647 * @param {Array} start array of pointers
4648 * @param {Array} end array of pointers
4649 * @return {Number} scale
4650 */
4651
4652
4653function getScale(start, end) {
4654 return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
4655}
4656/**
4657 * @private
4658 * calculate the rotation degrees between two pointersets
4659 * @param {Array} start array of pointers
4660 * @param {Array} end array of pointers
4661 * @return {Number} rotation
4662 */
4663
4664
4665function getRotation(start, end) {
4666 return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
4667}
4668/**
4669 * @private
4670 * velocity is calculated every x ms
4671 * @param {Object} session
4672 * @param {Object} input
4673 */
4674
4675
4676function computeIntervalInputData(session, input) {
4677 var last = session.lastInterval || input;
4678 var deltaTime = input.timeStamp - last.timeStamp;
4679 var velocity;
4680 var velocityX;
4681 var velocityY;
4682 var direction;
4683
4684 if (input.eventType !== INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
4685 var deltaX = input.deltaX - last.deltaX;
4686 var deltaY = input.deltaY - last.deltaY;
4687 var v = getVelocity(deltaTime, deltaX, deltaY);
4688 velocityX = v.x;
4689 velocityY = v.y;
4690 velocity = abs(v.x) > abs(v.y) ? v.x : v.y;
4691 direction = getDirection(deltaX, deltaY);
4692 session.lastInterval = input;
4693 } else {
4694 // use latest velocity info if it doesn't overtake a minimum period
4695 velocity = last.velocity;
4696 velocityX = last.velocityX;
4697 velocityY = last.velocityY;
4698 direction = last.direction;
4699 }
4700
4701 input.velocity = velocity;
4702 input.velocityX = velocityX;
4703 input.velocityY = velocityY;
4704 input.direction = direction;
4705}
4706/**
4707* @private
4708 * extend the data with some usable properties like scale, rotate, velocity etc
4709 * @param {Object} manager
4710 * @param {Object} input
4711 */
4712
4713
4714function computeInputData(manager, input) {
4715 var session = manager.session;
4716 var pointers = input.pointers;
4717 var pointersLength = pointers.length; // store the first input to calculate the distance and direction
4718
4719 if (!session.firstInput) {
4720 session.firstInput = simpleCloneInputData(input);
4721 } // to compute scale and rotation we need to store the multiple touches
4722
4723
4724 if (pointersLength > 1 && !session.firstMultiple) {
4725 session.firstMultiple = simpleCloneInputData(input);
4726 } else if (pointersLength === 1) {
4727 session.firstMultiple = false;
4728 }
4729
4730 var firstInput = session.firstInput,
4731 firstMultiple = session.firstMultiple;
4732 var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
4733 var center = input.center = getCenter(pointers);
4734 input.timeStamp = now();
4735 input.deltaTime = input.timeStamp - firstInput.timeStamp;
4736 input.angle = getAngle(offsetCenter, center);
4737 input.distance = getDistance(offsetCenter, center);
4738 computeDeltaXY(session, input);
4739 input.offsetDirection = getDirection(input.deltaX, input.deltaY);
4740 var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
4741 input.overallVelocityX = overallVelocity.x;
4742 input.overallVelocityY = overallVelocity.y;
4743 input.overallVelocity = abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y;
4744 input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
4745 input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
4746 input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers;
4747 computeIntervalInputData(session, input); // find the correct target
4748
4749 var target = manager.element;
4750 var srcEvent = input.srcEvent;
4751 var srcEventTarget;
4752
4753 if (srcEvent.composedPath) {
4754 srcEventTarget = srcEvent.composedPath()[0];
4755 } else if (srcEvent.path) {
4756 srcEventTarget = srcEvent.path[0];
4757 } else {
4758 srcEventTarget = srcEvent.target;
4759 }
4760
4761 if (hasParent(srcEventTarget, target)) {
4762 target = srcEventTarget;
4763 }
4764
4765 input.target = target;
4766}
4767/**
4768 * @private
4769 * handle input events
4770 * @param {Manager} manager
4771 * @param {String} eventType
4772 * @param {Object} input
4773 */
4774
4775
4776function inputHandler(manager, eventType, input) {
4777 var pointersLen = input.pointers.length;
4778 var changedPointersLen = input.changedPointers.length;
4779 var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
4780 var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && pointersLen - changedPointersLen === 0;
4781 input.isFirst = !!isFirst;
4782 input.isFinal = !!isFinal;
4783
4784 if (isFirst) {
4785 manager.session = {};
4786 } // source event is the normalized value of the domEvents
4787 // like 'touchstart, mouseup, pointerdown'
4788
4789
4790 input.eventType = eventType; // compute scale, rotation etc
4791
4792 computeInputData(manager, input); // emit secret event
4793
4794 manager.emit('hammer.input', input);
4795 manager.recognize(input);
4796 manager.session.prevInput = input;
4797}
4798/**
4799 * @private
4800 * split string on whitespace
4801 * @param {String} str
4802 * @returns {Array} words
4803 */
4804
4805
4806function splitStr(str) {
4807 return str.trim().split(/\s+/g);
4808}
4809/**
4810 * @private
4811 * addEventListener with multiple events at once
4812 * @param {EventTarget} target
4813 * @param {String} types
4814 * @param {Function} handler
4815 */
4816
4817
4818function addEventListeners(target, types, handler) {
4819 each(splitStr(types), function (type) {
4820 target.addEventListener(type, handler, false);
4821 });
4822}
4823/**
4824 * @private
4825 * removeEventListener with multiple events at once
4826 * @param {EventTarget} target
4827 * @param {String} types
4828 * @param {Function} handler
4829 */
4830
4831
4832function removeEventListeners(target, types, handler) {
4833 each(splitStr(types), function (type) {
4834 target.removeEventListener(type, handler, false);
4835 });
4836}
4837/**
4838 * @private
4839 * get the window object of an element
4840 * @param {HTMLElement} element
4841 * @returns {DocumentView|Window}
4842 */
4843
4844
4845function getWindowForElement(element) {
4846 var doc = element.ownerDocument || element;
4847 return doc.defaultView || doc.parentWindow || window;
4848}
4849/**
4850 * @private
4851 * create new input type manager
4852 * @param {Manager} manager
4853 * @param {Function} callback
4854 * @returns {Input}
4855 * @constructor
4856 */
4857
4858
4859var Input = /*#__PURE__*/function () {
4860 function Input(manager, callback) {
4861 var self = this;
4862 this.manager = manager;
4863 this.callback = callback;
4864 this.element = manager.element;
4865 this.target = manager.options.inputTarget; // smaller wrapper around the handler, for the scope and the enabled state of the manager,
4866 // so when disabled the input events are completely bypassed.
4867
4868 this.domHandler = function (ev) {
4869 if (boolOrFn(manager.options.enable, [manager])) {
4870 self.handler(ev);
4871 }
4872 };
4873
4874 this.init();
4875 }
4876 /**
4877 * @private
4878 * should handle the inputEvent data and trigger the callback
4879 * @virtual
4880 */
4881
4882
4883 var _proto = Input.prototype;
4884
4885 _proto.handler = function handler() {};
4886 /**
4887 * @private
4888 * bind the events
4889 */
4890
4891
4892 _proto.init = function init() {
4893 this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
4894 this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
4895 this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
4896 };
4897 /**
4898 * @private
4899 * unbind the events
4900 */
4901
4902
4903 _proto.destroy = function destroy() {
4904 this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
4905 this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
4906 this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
4907 };
4908
4909 return Input;
4910}();
4911/**
4912 * @private
4913 * find if a array contains the object using indexOf or a simple polyFill
4914 * @param {Array} src
4915 * @param {String} find
4916 * @param {String} [findByKey]
4917 * @return {Boolean|Number} false when not found, or the index
4918 */
4919
4920
4921function inArray(src, find, findByKey) {
4922 if (src.indexOf && !findByKey) {
4923 return src.indexOf(find);
4924 } else {
4925 var i = 0;
4926
4927 while (i < src.length) {
4928 if (findByKey && src[i][findByKey] == find || !findByKey && src[i] === find) {
4929 // do not use === here, test fails
4930 return i;
4931 }
4932
4933 i++;
4934 }
4935
4936 return -1;
4937 }
4938}
4939
4940var POINTER_INPUT_MAP = {
4941 pointerdown: INPUT_START,
4942 pointermove: INPUT_MOVE,
4943 pointerup: INPUT_END,
4944 pointercancel: INPUT_CANCEL,
4945 pointerout: INPUT_CANCEL
4946}; // in IE10 the pointer types is defined as an enum
4947
4948var IE10_POINTER_TYPE_ENUM = {
4949 2: INPUT_TYPE_TOUCH,
4950 3: INPUT_TYPE_PEN,
4951 4: INPUT_TYPE_MOUSE,
4952 5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
4953
4954};
4955var POINTER_ELEMENT_EVENTS = 'pointerdown';
4956var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel'; // IE10 has prefixed support, and case-sensitive
4957
4958if (win.MSPointerEvent && !win.PointerEvent) {
4959 POINTER_ELEMENT_EVENTS = 'MSPointerDown';
4960 POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
4961}
4962/**
4963 * @private
4964 * Pointer events input
4965 * @constructor
4966 * @extends Input
4967 */
4968
4969
4970var PointerEventInput = /*#__PURE__*/function (_Input) {
4971 _inheritsLoose(PointerEventInput, _Input);
4972
4973 function PointerEventInput() {
4974 var _this;
4975
4976 var proto = PointerEventInput.prototype;
4977 proto.evEl = POINTER_ELEMENT_EVENTS;
4978 proto.evWin = POINTER_WINDOW_EVENTS;
4979 _this = _Input.apply(this, arguments) || this;
4980 _this.store = _this.manager.session.pointerEvents = [];
4981 return _this;
4982 }
4983 /**
4984 * @private
4985 * handle mouse events
4986 * @param {Object} ev
4987 */
4988
4989
4990 var _proto = PointerEventInput.prototype;
4991
4992 _proto.handler = function handler(ev) {
4993 var store = this.store;
4994 var removePointer = false;
4995 var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
4996 var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
4997 var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
4998 var isTouch = pointerType === INPUT_TYPE_TOUCH; // get index of the event in the store
4999
5000 var storeIndex = inArray(store, ev.pointerId, 'pointerId'); // start and mouse must be down
5001
5002 if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
5003 if (storeIndex < 0) {
5004 store.push(ev);
5005 storeIndex = store.length - 1;
5006 }
5007 } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
5008 removePointer = true;
5009 } // it not found, so the pointer hasn't been down (so it's probably a hover)
5010
5011
5012 if (storeIndex < 0) {
5013 return;
5014 } // update the event in the store
5015
5016
5017 store[storeIndex] = ev;
5018 this.callback(this.manager, eventType, {
5019 pointers: store,
5020 changedPointers: [ev],
5021 pointerType: pointerType,
5022 srcEvent: ev
5023 });
5024
5025 if (removePointer) {
5026 // remove from the store
5027 store.splice(storeIndex, 1);
5028 }
5029 };
5030
5031 return PointerEventInput;
5032}(Input);
5033/**
5034 * @private
5035 * convert array-like objects to real arrays
5036 * @param {Object} obj
5037 * @returns {Array}
5038 */
5039
5040
5041function toArray(obj) {
5042 return Array.prototype.slice.call(obj, 0);
5043}
5044/**
5045 * @private
5046 * unique array with objects based on a key (like 'id') or just by the array's value
5047 * @param {Array} src [{id:1},{id:2},{id:1}]
5048 * @param {String} [key]
5049 * @param {Boolean} [sort=False]
5050 * @returns {Array} [{id:1},{id:2}]
5051 */
5052
5053
5054function uniqueArray(src, key, sort) {
5055 var results = [];
5056 var values = [];
5057 var i = 0;
5058
5059 while (i < src.length) {
5060 var val = key ? src[i][key] : src[i];
5061
5062 if (inArray(values, val) < 0) {
5063 results.push(src[i]);
5064 }
5065
5066 values[i] = val;
5067 i++;
5068 }
5069
5070 if (sort) {
5071 if (!key) {
5072 results = results.sort();
5073 } else {
5074 results = results.sort(function (a, b) {
5075 return a[key] > b[key];
5076 });
5077 }
5078 }
5079
5080 return results;
5081}
5082
5083var TOUCH_INPUT_MAP = {
5084 touchstart: INPUT_START,
5085 touchmove: INPUT_MOVE,
5086 touchend: INPUT_END,
5087 touchcancel: INPUT_CANCEL
5088};
5089var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
5090/**
5091 * @private
5092 * Multi-user touch events input
5093 * @constructor
5094 * @extends Input
5095 */
5096
5097var TouchInput = /*#__PURE__*/function (_Input) {
5098 _inheritsLoose(TouchInput, _Input);
5099
5100 function TouchInput() {
5101 var _this;
5102
5103 TouchInput.prototype.evTarget = TOUCH_TARGET_EVENTS;
5104 _this = _Input.apply(this, arguments) || this;
5105 _this.targetIds = {}; // this.evTarget = TOUCH_TARGET_EVENTS;
5106
5107 return _this;
5108 }
5109
5110 var _proto = TouchInput.prototype;
5111
5112 _proto.handler = function handler(ev) {
5113 var type = TOUCH_INPUT_MAP[ev.type];
5114 var touches = getTouches.call(this, ev, type);
5115
5116 if (!touches) {
5117 return;
5118 }
5119
5120 this.callback(this.manager, type, {
5121 pointers: touches[0],
5122 changedPointers: touches[1],
5123 pointerType: INPUT_TYPE_TOUCH,
5124 srcEvent: ev
5125 });
5126 };
5127
5128 return TouchInput;
5129}(Input);
5130
5131function getTouches(ev, type) {
5132 var allTouches = toArray(ev.touches);
5133 var targetIds = this.targetIds; // when there is only one touch, the process can be simplified
5134
5135 if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
5136 targetIds[allTouches[0].identifier] = true;
5137 return [allTouches, allTouches];
5138 }
5139
5140 var i;
5141 var targetTouches;
5142 var changedTouches = toArray(ev.changedTouches);
5143 var changedTargetTouches = [];
5144 var target = this.target; // get target touches from touches
5145
5146 targetTouches = allTouches.filter(function (touch) {
5147 return hasParent(touch.target, target);
5148 }); // collect touches
5149
5150 if (type === INPUT_START) {
5151 i = 0;
5152
5153 while (i < targetTouches.length) {
5154 targetIds[targetTouches[i].identifier] = true;
5155 i++;
5156 }
5157 } // filter changed touches to only contain touches that exist in the collected target ids
5158
5159
5160 i = 0;
5161
5162 while (i < changedTouches.length) {
5163 if (targetIds[changedTouches[i].identifier]) {
5164 changedTargetTouches.push(changedTouches[i]);
5165 } // cleanup removed touches
5166
5167
5168 if (type & (INPUT_END | INPUT_CANCEL)) {
5169 delete targetIds[changedTouches[i].identifier];
5170 }
5171
5172 i++;
5173 }
5174
5175 if (!changedTargetTouches.length) {
5176 return;
5177 }
5178
5179 return [// merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
5180 uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true), changedTargetTouches];
5181}
5182
5183var MOUSE_INPUT_MAP = {
5184 mousedown: INPUT_START,
5185 mousemove: INPUT_MOVE,
5186 mouseup: INPUT_END
5187};
5188var MOUSE_ELEMENT_EVENTS = 'mousedown';
5189var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
5190/**
5191 * @private
5192 * Mouse events input
5193 * @constructor
5194 * @extends Input
5195 */
5196
5197var MouseInput = /*#__PURE__*/function (_Input) {
5198 _inheritsLoose(MouseInput, _Input);
5199
5200 function MouseInput() {
5201 var _this;
5202
5203 var proto = MouseInput.prototype;
5204 proto.evEl = MOUSE_ELEMENT_EVENTS;
5205 proto.evWin = MOUSE_WINDOW_EVENTS;
5206 _this = _Input.apply(this, arguments) || this;
5207 _this.pressed = false; // mousedown state
5208
5209 return _this;
5210 }
5211 /**
5212 * @private
5213 * handle mouse events
5214 * @param {Object} ev
5215 */
5216
5217
5218 var _proto = MouseInput.prototype;
5219
5220 _proto.handler = function handler(ev) {
5221 var eventType = MOUSE_INPUT_MAP[ev.type]; // on start we want to have the left mouse button down
5222
5223 if (eventType & INPUT_START && ev.button === 0) {
5224 this.pressed = true;
5225 }
5226
5227 if (eventType & INPUT_MOVE && ev.which !== 1) {
5228 eventType = INPUT_END;
5229 } // mouse must be down
5230
5231
5232 if (!this.pressed) {
5233 return;
5234 }
5235
5236 if (eventType & INPUT_END) {
5237 this.pressed = false;
5238 }
5239
5240 this.callback(this.manager, eventType, {
5241 pointers: [ev],
5242 changedPointers: [ev],
5243 pointerType: INPUT_TYPE_MOUSE,
5244 srcEvent: ev
5245 });
5246 };
5247
5248 return MouseInput;
5249}(Input);
5250/**
5251 * @private
5252 * Combined touch and mouse input
5253 *
5254 * Touch has a higher priority then mouse, and while touching no mouse events are allowed.
5255 * This because touch devices also emit mouse events while doing a touch.
5256 *
5257 * @constructor
5258 * @extends Input
5259 */
5260
5261
5262var DEDUP_TIMEOUT = 2500;
5263var DEDUP_DISTANCE = 25;
5264
5265function setLastTouch(eventData) {
5266 var _eventData$changedPoi = eventData.changedPointers,
5267 touch = _eventData$changedPoi[0];
5268
5269 if (touch.identifier === this.primaryTouch) {
5270 var lastTouch = {
5271 x: touch.clientX,
5272 y: touch.clientY
5273 };
5274 var lts = this.lastTouches;
5275 this.lastTouches.push(lastTouch);
5276
5277 var removeLastTouch = function removeLastTouch() {
5278 var i = lts.indexOf(lastTouch);
5279
5280 if (i > -1) {
5281 lts.splice(i, 1);
5282 }
5283 };
5284
5285 setTimeout(removeLastTouch, DEDUP_TIMEOUT);
5286 }
5287}
5288
5289function recordTouches(eventType, eventData) {
5290 if (eventType & INPUT_START) {
5291 this.primaryTouch = eventData.changedPointers[0].identifier;
5292 setLastTouch.call(this, eventData);
5293 } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
5294 setLastTouch.call(this, eventData);
5295 }
5296}
5297
5298function isSyntheticEvent(eventData) {
5299 var x = eventData.srcEvent.clientX;
5300 var y = eventData.srcEvent.clientY;
5301
5302 for (var i = 0; i < this.lastTouches.length; i++) {
5303 var t = this.lastTouches[i];
5304 var dx = Math.abs(x - t.x);
5305 var dy = Math.abs(y - t.y);
5306
5307 if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
5308 return true;
5309 }
5310 }
5311
5312 return false;
5313}
5314
5315var TouchMouseInput = /*#__PURE__*/function () {
5316 var TouchMouseInput = /*#__PURE__*/function (_Input) {
5317 _inheritsLoose(TouchMouseInput, _Input);
5318
5319 function TouchMouseInput(_manager, callback) {
5320 var _this;
5321
5322 _this = _Input.call(this, _manager, callback) || this;
5323
5324 _this.handler = function (manager, inputEvent, inputData) {
5325 var isTouch = inputData.pointerType === INPUT_TYPE_TOUCH;
5326 var isMouse = inputData.pointerType === INPUT_TYPE_MOUSE;
5327
5328 if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
5329 return;
5330 } // when we're in a touch event, record touches to de-dupe synthetic mouse event
5331
5332
5333 if (isTouch) {
5334 recordTouches.call(_assertThisInitialized$1(_assertThisInitialized$1(_this)), inputEvent, inputData);
5335 } else if (isMouse && isSyntheticEvent.call(_assertThisInitialized$1(_assertThisInitialized$1(_this)), inputData)) {
5336 return;
5337 }
5338
5339 _this.callback(manager, inputEvent, inputData);
5340 };
5341
5342 _this.touch = new TouchInput(_this.manager, _this.handler);
5343 _this.mouse = new MouseInput(_this.manager, _this.handler);
5344 _this.primaryTouch = null;
5345 _this.lastTouches = [];
5346 return _this;
5347 }
5348 /**
5349 * @private
5350 * handle mouse and touch events
5351 * @param {Hammer} manager
5352 * @param {String} inputEvent
5353 * @param {Object} inputData
5354 */
5355
5356
5357 var _proto = TouchMouseInput.prototype;
5358 /**
5359 * @private
5360 * remove the event listeners
5361 */
5362
5363 _proto.destroy = function destroy() {
5364 this.touch.destroy();
5365 this.mouse.destroy();
5366 };
5367
5368 return TouchMouseInput;
5369 }(Input);
5370
5371 return TouchMouseInput;
5372}();
5373/**
5374 * @private
5375 * create new input type manager
5376 * called by the Manager constructor
5377 * @param {Hammer} manager
5378 * @returns {Input}
5379 */
5380
5381
5382function createInputInstance(manager) {
5383 var Type; // let inputClass = manager.options.inputClass;
5384
5385 var inputClass = manager.options.inputClass;
5386
5387 if (inputClass) {
5388 Type = inputClass;
5389 } else if (SUPPORT_POINTER_EVENTS) {
5390 Type = PointerEventInput;
5391 } else if (SUPPORT_ONLY_TOUCH) {
5392 Type = TouchInput;
5393 } else if (!SUPPORT_TOUCH) {
5394 Type = MouseInput;
5395 } else {
5396 Type = TouchMouseInput;
5397 }
5398
5399 return new Type(manager, inputHandler);
5400}
5401/**
5402 * @private
5403 * if the argument is an array, we want to execute the fn on each entry
5404 * if it aint an array we don't want to do a thing.
5405 * this is used by all the methods that accept a single and array argument.
5406 * @param {*|Array} arg
5407 * @param {String} fn
5408 * @param {Object} [context]
5409 * @returns {Boolean}
5410 */
5411
5412
5413function invokeArrayArg(arg, fn, context) {
5414 if (Array.isArray(arg)) {
5415 each(arg, context[fn], context);
5416 return true;
5417 }
5418
5419 return false;
5420}
5421
5422var STATE_POSSIBLE = 1;
5423var STATE_BEGAN = 2;
5424var STATE_CHANGED = 4;
5425var STATE_ENDED = 8;
5426var STATE_RECOGNIZED = STATE_ENDED;
5427var STATE_CANCELLED = 16;
5428var STATE_FAILED = 32;
5429/**
5430 * @private
5431 * get a unique id
5432 * @returns {number} uniqueId
5433 */
5434
5435var _uniqueId = 1;
5436
5437function uniqueId() {
5438 return _uniqueId++;
5439}
5440/**
5441 * @private
5442 * get a recognizer by name if it is bound to a manager
5443 * @param {Recognizer|String} otherRecognizer
5444 * @param {Recognizer} recognizer
5445 * @returns {Recognizer}
5446 */
5447
5448
5449function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
5450 var manager = recognizer.manager;
5451
5452 if (manager) {
5453 return manager.get(otherRecognizer);
5454 }
5455
5456 return otherRecognizer;
5457}
5458/**
5459 * @private
5460 * get a usable string, used as event postfix
5461 * @param {constant} state
5462 * @returns {String} state
5463 */
5464
5465
5466function stateStr(state) {
5467 if (state & STATE_CANCELLED) {
5468 return 'cancel';
5469 } else if (state & STATE_ENDED) {
5470 return 'end';
5471 } else if (state & STATE_CHANGED) {
5472 return 'move';
5473 } else if (state & STATE_BEGAN) {
5474 return 'start';
5475 }
5476
5477 return '';
5478}
5479/**
5480 * @private
5481 * Recognizer flow explained; *
5482 * All recognizers have the initial state of POSSIBLE when a input session starts.
5483 * The definition of a input session is from the first input until the last input, with all it's movement in it. *
5484 * Example session for mouse-input: mousedown -> mousemove -> mouseup
5485 *
5486 * On each recognizing cycle (see Manager.recognize) the .recognize() method is executed
5487 * which determines with state it should be.
5488 *
5489 * If the recognizer has the state FAILED, CANCELLED or RECOGNIZED (equals ENDED), it is reset to
5490 * POSSIBLE to give it another change on the next cycle.
5491 *
5492 * Possible
5493 * |
5494 * +-----+---------------+
5495 * | |
5496 * +-----+-----+ |
5497 * | | |
5498 * Failed Cancelled |
5499 * +-------+------+
5500 * | |
5501 * Recognized Began
5502 * |
5503 * Changed
5504 * |
5505 * Ended/Recognized
5506 */
5507
5508/**
5509 * @private
5510 * Recognizer
5511 * Every recognizer needs to extend from this class.
5512 * @constructor
5513 * @param {Object} options
5514 */
5515
5516
5517var Recognizer = /*#__PURE__*/function () {
5518 function Recognizer(options) {
5519 if (options === void 0) {
5520 options = {};
5521 }
5522
5523 this.options = _extends({
5524 enable: true
5525 }, options);
5526 this.id = uniqueId();
5527 this.manager = null; // default is enable true
5528
5529 this.state = STATE_POSSIBLE;
5530 this.simultaneous = {};
5531 this.requireFail = [];
5532 }
5533 /**
5534 * @private
5535 * set options
5536 * @param {Object} options
5537 * @return {Recognizer}
5538 */
5539
5540
5541 var _proto = Recognizer.prototype;
5542
5543 _proto.set = function set(options) {
5544 assign$1(this.options, options); // also update the touchAction, in case something changed about the directions/enabled state
5545
5546 this.manager && this.manager.touchAction.update();
5547 return this;
5548 };
5549 /**
5550 * @private
5551 * recognize simultaneous with an other recognizer.
5552 * @param {Recognizer} otherRecognizer
5553 * @returns {Recognizer} this
5554 */
5555
5556
5557 _proto.recognizeWith = function recognizeWith(otherRecognizer) {
5558 if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
5559 return this;
5560 }
5561
5562 var simultaneous = this.simultaneous;
5563 otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
5564
5565 if (!simultaneous[otherRecognizer.id]) {
5566 simultaneous[otherRecognizer.id] = otherRecognizer;
5567 otherRecognizer.recognizeWith(this);
5568 }
5569
5570 return this;
5571 };
5572 /**
5573 * @private
5574 * drop the simultaneous link. it doesnt remove the link on the other recognizer.
5575 * @param {Recognizer} otherRecognizer
5576 * @returns {Recognizer} this
5577 */
5578
5579
5580 _proto.dropRecognizeWith = function dropRecognizeWith(otherRecognizer) {
5581 if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
5582 return this;
5583 }
5584
5585 otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
5586 delete this.simultaneous[otherRecognizer.id];
5587 return this;
5588 };
5589 /**
5590 * @private
5591 * recognizer can only run when an other is failing
5592 * @param {Recognizer} otherRecognizer
5593 * @returns {Recognizer} this
5594 */
5595
5596
5597 _proto.requireFailure = function requireFailure(otherRecognizer) {
5598 if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
5599 return this;
5600 }
5601
5602 var requireFail = this.requireFail;
5603 otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
5604
5605 if (inArray(requireFail, otherRecognizer) === -1) {
5606 requireFail.push(otherRecognizer);
5607 otherRecognizer.requireFailure(this);
5608 }
5609
5610 return this;
5611 };
5612 /**
5613 * @private
5614 * drop the requireFailure link. it does not remove the link on the other recognizer.
5615 * @param {Recognizer} otherRecognizer
5616 * @returns {Recognizer} this
5617 */
5618
5619
5620 _proto.dropRequireFailure = function dropRequireFailure(otherRecognizer) {
5621 if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
5622 return this;
5623 }
5624
5625 otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
5626 var index = inArray(this.requireFail, otherRecognizer);
5627
5628 if (index > -1) {
5629 this.requireFail.splice(index, 1);
5630 }
5631
5632 return this;
5633 };
5634 /**
5635 * @private
5636 * has require failures boolean
5637 * @returns {boolean}
5638 */
5639
5640
5641 _proto.hasRequireFailures = function hasRequireFailures() {
5642 return this.requireFail.length > 0;
5643 };
5644 /**
5645 * @private
5646 * if the recognizer can recognize simultaneous with an other recognizer
5647 * @param {Recognizer} otherRecognizer
5648 * @returns {Boolean}
5649 */
5650
5651
5652 _proto.canRecognizeWith = function canRecognizeWith(otherRecognizer) {
5653 return !!this.simultaneous[otherRecognizer.id];
5654 };
5655 /**
5656 * @private
5657 * You should use `tryEmit` instead of `emit` directly to check
5658 * that all the needed recognizers has failed before emitting.
5659 * @param {Object} input
5660 */
5661
5662
5663 _proto.emit = function emit(input) {
5664 var self = this;
5665 var state = this.state;
5666
5667 function emit(event) {
5668 self.manager.emit(event, input);
5669 } // 'panstart' and 'panmove'
5670
5671
5672 if (state < STATE_ENDED) {
5673 emit(self.options.event + stateStr(state));
5674 }
5675
5676 emit(self.options.event); // simple 'eventName' events
5677
5678 if (input.additionalEvent) {
5679 // additional event(panleft, panright, pinchin, pinchout...)
5680 emit(input.additionalEvent);
5681 } // panend and pancancel
5682
5683
5684 if (state >= STATE_ENDED) {
5685 emit(self.options.event + stateStr(state));
5686 }
5687 };
5688 /**
5689 * @private
5690 * Check that all the require failure recognizers has failed,
5691 * if true, it emits a gesture event,
5692 * otherwise, setup the state to FAILED.
5693 * @param {Object} input
5694 */
5695
5696
5697 _proto.tryEmit = function tryEmit(input) {
5698 if (this.canEmit()) {
5699 return this.emit(input);
5700 } // it's failing anyway
5701
5702
5703 this.state = STATE_FAILED;
5704 };
5705 /**
5706 * @private
5707 * can we emit?
5708 * @returns {boolean}
5709 */
5710
5711
5712 _proto.canEmit = function canEmit() {
5713 var i = 0;
5714
5715 while (i < this.requireFail.length) {
5716 if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
5717 return false;
5718 }
5719
5720 i++;
5721 }
5722
5723 return true;
5724 };
5725 /**
5726 * @private
5727 * update the recognizer
5728 * @param {Object} inputData
5729 */
5730
5731
5732 _proto.recognize = function recognize(inputData) {
5733 // make a new copy of the inputData
5734 // so we can change the inputData without messing up the other recognizers
5735 var inputDataClone = assign$1({}, inputData); // is is enabled and allow recognizing?
5736
5737 if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
5738 this.reset();
5739 this.state = STATE_FAILED;
5740 return;
5741 } // reset when we've reached the end
5742
5743
5744 if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
5745 this.state = STATE_POSSIBLE;
5746 }
5747
5748 this.state = this.process(inputDataClone); // the recognizer has recognized a gesture
5749 // so trigger an event
5750
5751 if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
5752 this.tryEmit(inputDataClone);
5753 }
5754 };
5755 /**
5756 * @private
5757 * return the state of the recognizer
5758 * the actual recognizing happens in this method
5759 * @virtual
5760 * @param {Object} inputData
5761 * @returns {constant} STATE
5762 */
5763
5764 /* jshint ignore:start */
5765
5766
5767 _proto.process = function process(inputData) {};
5768 /* jshint ignore:end */
5769
5770 /**
5771 * @private
5772 * return the preferred touch-action
5773 * @virtual
5774 * @returns {Array}
5775 */
5776
5777
5778 _proto.getTouchAction = function getTouchAction() {};
5779 /**
5780 * @private
5781 * called when the gesture isn't allowed to recognize
5782 * like when another is being recognized or it is disabled
5783 * @virtual
5784 */
5785
5786
5787 _proto.reset = function reset() {};
5788
5789 return Recognizer;
5790}();
5791/**
5792 * @private
5793 * A tap is recognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
5794 * between the given interval and position. The delay option can be used to recognize multi-taps without firing
5795 * a single tap.
5796 *
5797 * The eventData from the emitted event contains the property `tapCount`, which contains the amount of
5798 * multi-taps being recognized.
5799 * @constructor
5800 * @extends Recognizer
5801 */
5802
5803
5804var TapRecognizer = /*#__PURE__*/function (_Recognizer) {
5805 _inheritsLoose(TapRecognizer, _Recognizer);
5806
5807 function TapRecognizer(options) {
5808 var _this;
5809
5810 if (options === void 0) {
5811 options = {};
5812 }
5813
5814 _this = _Recognizer.call(this, _extends({
5815 event: 'tap',
5816 pointers: 1,
5817 taps: 1,
5818 interval: 300,
5819 // max time between the multi-tap taps
5820 time: 250,
5821 // max time of the pointer to be down (like finger on the screen)
5822 threshold: 9,
5823 // a minimal movement is ok, but keep it low
5824 posThreshold: 10
5825 }, options)) || this; // previous time and center,
5826 // used for tap counting
5827
5828 _this.pTime = false;
5829 _this.pCenter = false;
5830 _this._timer = null;
5831 _this._input = null;
5832 _this.count = 0;
5833 return _this;
5834 }
5835
5836 var _proto = TapRecognizer.prototype;
5837
5838 _proto.getTouchAction = function getTouchAction() {
5839 return [TOUCH_ACTION_MANIPULATION];
5840 };
5841
5842 _proto.process = function process(input) {
5843 var _this2 = this;
5844
5845 var options = this.options;
5846 var validPointers = input.pointers.length === options.pointers;
5847 var validMovement = input.distance < options.threshold;
5848 var validTouchTime = input.deltaTime < options.time;
5849 this.reset();
5850
5851 if (input.eventType & INPUT_START && this.count === 0) {
5852 return this.failTimeout();
5853 } // we only allow little movement
5854 // and we've reached an end event, so a tap is possible
5855
5856
5857 if (validMovement && validTouchTime && validPointers) {
5858 if (input.eventType !== INPUT_END) {
5859 return this.failTimeout();
5860 }
5861
5862 var validInterval = this.pTime ? input.timeStamp - this.pTime < options.interval : true;
5863 var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
5864 this.pTime = input.timeStamp;
5865 this.pCenter = input.center;
5866
5867 if (!validMultiTap || !validInterval) {
5868 this.count = 1;
5869 } else {
5870 this.count += 1;
5871 }
5872
5873 this._input = input; // if tap count matches we have recognized it,
5874 // else it has began recognizing...
5875
5876 var tapCount = this.count % options.taps;
5877
5878 if (tapCount === 0) {
5879 // no failing requirements, immediately trigger the tap event
5880 // or wait as long as the multitap interval to trigger
5881 if (!this.hasRequireFailures()) {
5882 return STATE_RECOGNIZED;
5883 } else {
5884 this._timer = setTimeout(function () {
5885 _this2.state = STATE_RECOGNIZED;
5886
5887 _this2.tryEmit();
5888 }, options.interval);
5889 return STATE_BEGAN;
5890 }
5891 }
5892 }
5893
5894 return STATE_FAILED;
5895 };
5896
5897 _proto.failTimeout = function failTimeout() {
5898 var _this3 = this;
5899
5900 this._timer = setTimeout(function () {
5901 _this3.state = STATE_FAILED;
5902 }, this.options.interval);
5903 return STATE_FAILED;
5904 };
5905
5906 _proto.reset = function reset() {
5907 clearTimeout(this._timer);
5908 };
5909
5910 _proto.emit = function emit() {
5911 if (this.state === STATE_RECOGNIZED) {
5912 this._input.tapCount = this.count;
5913 this.manager.emit(this.options.event, this._input);
5914 }
5915 };
5916
5917 return TapRecognizer;
5918}(Recognizer);
5919/**
5920 * @private
5921 * This recognizer is just used as a base for the simple attribute recognizers.
5922 * @constructor
5923 * @extends Recognizer
5924 */
5925
5926
5927var AttrRecognizer = /*#__PURE__*/function (_Recognizer) {
5928 _inheritsLoose(AttrRecognizer, _Recognizer);
5929
5930 function AttrRecognizer(options) {
5931 if (options === void 0) {
5932 options = {};
5933 }
5934
5935 return _Recognizer.call(this, _extends({
5936 pointers: 1
5937 }, options)) || this;
5938 }
5939 /**
5940 * @private
5941 * Used to check if it the recognizer receives valid input, like input.distance > 10.
5942 * @memberof AttrRecognizer
5943 * @param {Object} input
5944 * @returns {Boolean} recognized
5945 */
5946
5947
5948 var _proto = AttrRecognizer.prototype;
5949
5950 _proto.attrTest = function attrTest(input) {
5951 var optionPointers = this.options.pointers;
5952 return optionPointers === 0 || input.pointers.length === optionPointers;
5953 };
5954 /**
5955 * @private
5956 * Process the input and return the state for the recognizer
5957 * @memberof AttrRecognizer
5958 * @param {Object} input
5959 * @returns {*} State
5960 */
5961
5962
5963 _proto.process = function process(input) {
5964 var state = this.state;
5965 var eventType = input.eventType;
5966 var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
5967 var isValid = this.attrTest(input); // on cancel input and we've recognized before, return STATE_CANCELLED
5968
5969 if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
5970 return state | STATE_CANCELLED;
5971 } else if (isRecognized || isValid) {
5972 if (eventType & INPUT_END) {
5973 return state | STATE_ENDED;
5974 } else if (!(state & STATE_BEGAN)) {
5975 return STATE_BEGAN;
5976 }
5977
5978 return state | STATE_CHANGED;
5979 }
5980
5981 return STATE_FAILED;
5982 };
5983
5984 return AttrRecognizer;
5985}(Recognizer);
5986/**
5987 * @private
5988 * direction cons to string
5989 * @param {constant} direction
5990 * @returns {String}
5991 */
5992
5993
5994function directionStr(direction) {
5995 if (direction === DIRECTION_DOWN) {
5996 return 'down';
5997 } else if (direction === DIRECTION_UP) {
5998 return 'up';
5999 } else if (direction === DIRECTION_LEFT) {
6000 return 'left';
6001 } else if (direction === DIRECTION_RIGHT) {
6002 return 'right';
6003 }
6004
6005 return '';
6006}
6007/**
6008 * @private
6009 * Pan
6010 * Recognized when the pointer is down and moved in the allowed direction.
6011 * @constructor
6012 * @extends AttrRecognizer
6013 */
6014
6015
6016var PanRecognizer = /*#__PURE__*/function (_AttrRecognizer) {
6017 _inheritsLoose(PanRecognizer, _AttrRecognizer);
6018
6019 function PanRecognizer(options) {
6020 var _this;
6021
6022 if (options === void 0) {
6023 options = {};
6024 }
6025
6026 _this = _AttrRecognizer.call(this, _extends({
6027 event: 'pan',
6028 threshold: 10,
6029 pointers: 1,
6030 direction: DIRECTION_ALL
6031 }, options)) || this;
6032 _this.pX = null;
6033 _this.pY = null;
6034 return _this;
6035 }
6036
6037 var _proto = PanRecognizer.prototype;
6038
6039 _proto.getTouchAction = function getTouchAction() {
6040 var direction = this.options.direction;
6041 var actions = [];
6042
6043 if (direction & DIRECTION_HORIZONTAL) {
6044 actions.push(TOUCH_ACTION_PAN_Y);
6045 }
6046
6047 if (direction & DIRECTION_VERTICAL) {
6048 actions.push(TOUCH_ACTION_PAN_X);
6049 }
6050
6051 return actions;
6052 };
6053
6054 _proto.directionTest = function directionTest(input) {
6055 var options = this.options;
6056 var hasMoved = true;
6057 var distance = input.distance;
6058 var direction = input.direction;
6059 var x = input.deltaX;
6060 var y = input.deltaY; // lock to axis?
6061
6062 if (!(direction & options.direction)) {
6063 if (options.direction & DIRECTION_HORIZONTAL) {
6064 direction = x === 0 ? DIRECTION_NONE : x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
6065 hasMoved = x !== this.pX;
6066 distance = Math.abs(input.deltaX);
6067 } else {
6068 direction = y === 0 ? DIRECTION_NONE : y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
6069 hasMoved = y !== this.pY;
6070 distance = Math.abs(input.deltaY);
6071 }
6072 }
6073
6074 input.direction = direction;
6075 return hasMoved && distance > options.threshold && direction & options.direction;
6076 };
6077
6078 _proto.attrTest = function attrTest(input) {
6079 return AttrRecognizer.prototype.attrTest.call(this, input) && ( // replace with a super call
6080 this.state & STATE_BEGAN || !(this.state & STATE_BEGAN) && this.directionTest(input));
6081 };
6082
6083 _proto.emit = function emit(input) {
6084 this.pX = input.deltaX;
6085 this.pY = input.deltaY;
6086 var direction = directionStr(input.direction);
6087
6088 if (direction) {
6089 input.additionalEvent = this.options.event + direction;
6090 }
6091
6092 _AttrRecognizer.prototype.emit.call(this, input);
6093 };
6094
6095 return PanRecognizer;
6096}(AttrRecognizer);
6097/**
6098 * @private
6099 * Swipe
6100 * Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
6101 * @constructor
6102 * @extends AttrRecognizer
6103 */
6104
6105
6106var SwipeRecognizer = /*#__PURE__*/function (_AttrRecognizer) {
6107 _inheritsLoose(SwipeRecognizer, _AttrRecognizer);
6108
6109 function SwipeRecognizer(options) {
6110 if (options === void 0) {
6111 options = {};
6112 }
6113
6114 return _AttrRecognizer.call(this, _extends({
6115 event: 'swipe',
6116 threshold: 10,
6117 velocity: 0.3,
6118 direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
6119 pointers: 1
6120 }, options)) || this;
6121 }
6122
6123 var _proto = SwipeRecognizer.prototype;
6124
6125 _proto.getTouchAction = function getTouchAction() {
6126 return PanRecognizer.prototype.getTouchAction.call(this);
6127 };
6128
6129 _proto.attrTest = function attrTest(input) {
6130 var direction = this.options.direction;
6131 var velocity;
6132
6133 if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
6134 velocity = input.overallVelocity;
6135 } else if (direction & DIRECTION_HORIZONTAL) {
6136 velocity = input.overallVelocityX;
6137 } else if (direction & DIRECTION_VERTICAL) {
6138 velocity = input.overallVelocityY;
6139 }
6140
6141 return _AttrRecognizer.prototype.attrTest.call(this, input) && direction & input.offsetDirection && input.distance > this.options.threshold && input.maxPointers === this.options.pointers && abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
6142 };
6143
6144 _proto.emit = function emit(input) {
6145 var direction = directionStr(input.offsetDirection);
6146
6147 if (direction) {
6148 this.manager.emit(this.options.event + direction, input);
6149 }
6150
6151 this.manager.emit(this.options.event, input);
6152 };
6153
6154 return SwipeRecognizer;
6155}(AttrRecognizer);
6156/**
6157 * @private
6158 * Pinch
6159 * Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
6160 * @constructor
6161 * @extends AttrRecognizer
6162 */
6163
6164
6165var PinchRecognizer = /*#__PURE__*/function (_AttrRecognizer) {
6166 _inheritsLoose(PinchRecognizer, _AttrRecognizer);
6167
6168 function PinchRecognizer(options) {
6169 if (options === void 0) {
6170 options = {};
6171 }
6172
6173 return _AttrRecognizer.call(this, _extends({
6174 event: 'pinch',
6175 threshold: 0,
6176 pointers: 2
6177 }, options)) || this;
6178 }
6179
6180 var _proto = PinchRecognizer.prototype;
6181
6182 _proto.getTouchAction = function getTouchAction() {
6183 return [TOUCH_ACTION_NONE];
6184 };
6185
6186 _proto.attrTest = function attrTest(input) {
6187 return _AttrRecognizer.prototype.attrTest.call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
6188 };
6189
6190 _proto.emit = function emit(input) {
6191 if (input.scale !== 1) {
6192 var inOut = input.scale < 1 ? 'in' : 'out';
6193 input.additionalEvent = this.options.event + inOut;
6194 }
6195
6196 _AttrRecognizer.prototype.emit.call(this, input);
6197 };
6198
6199 return PinchRecognizer;
6200}(AttrRecognizer);
6201/**
6202 * @private
6203 * Rotate
6204 * Recognized when two or more pointer are moving in a circular motion.
6205 * @constructor
6206 * @extends AttrRecognizer
6207 */
6208
6209
6210var RotateRecognizer = /*#__PURE__*/function (_AttrRecognizer) {
6211 _inheritsLoose(RotateRecognizer, _AttrRecognizer);
6212
6213 function RotateRecognizer(options) {
6214 if (options === void 0) {
6215 options = {};
6216 }
6217
6218 return _AttrRecognizer.call(this, _extends({
6219 event: 'rotate',
6220 threshold: 0,
6221 pointers: 2
6222 }, options)) || this;
6223 }
6224
6225 var _proto = RotateRecognizer.prototype;
6226
6227 _proto.getTouchAction = function getTouchAction() {
6228 return [TOUCH_ACTION_NONE];
6229 };
6230
6231 _proto.attrTest = function attrTest(input) {
6232 return _AttrRecognizer.prototype.attrTest.call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
6233 };
6234
6235 return RotateRecognizer;
6236}(AttrRecognizer);
6237/**
6238 * @private
6239 * Press
6240 * Recognized when the pointer is down for x ms without any movement.
6241 * @constructor
6242 * @extends Recognizer
6243 */
6244
6245
6246var PressRecognizer = /*#__PURE__*/function (_Recognizer) {
6247 _inheritsLoose(PressRecognizer, _Recognizer);
6248
6249 function PressRecognizer(options) {
6250 var _this;
6251
6252 if (options === void 0) {
6253 options = {};
6254 }
6255
6256 _this = _Recognizer.call(this, _extends({
6257 event: 'press',
6258 pointers: 1,
6259 time: 251,
6260 // minimal time of the pointer to be pressed
6261 threshold: 9
6262 }, options)) || this;
6263 _this._timer = null;
6264 _this._input = null;
6265 return _this;
6266 }
6267
6268 var _proto = PressRecognizer.prototype;
6269
6270 _proto.getTouchAction = function getTouchAction() {
6271 return [TOUCH_ACTION_AUTO];
6272 };
6273
6274 _proto.process = function process(input) {
6275 var _this2 = this;
6276
6277 var options = this.options;
6278 var validPointers = input.pointers.length === options.pointers;
6279 var validMovement = input.distance < options.threshold;
6280 var validTime = input.deltaTime > options.time;
6281 this._input = input; // we only allow little movement
6282 // and we've reached an end event, so a tap is possible
6283
6284 if (!validMovement || !validPointers || input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime) {
6285 this.reset();
6286 } else if (input.eventType & INPUT_START) {
6287 this.reset();
6288 this._timer = setTimeout(function () {
6289 _this2.state = STATE_RECOGNIZED;
6290
6291 _this2.tryEmit();
6292 }, options.time);
6293 } else if (input.eventType & INPUT_END) {
6294 return STATE_RECOGNIZED;
6295 }
6296
6297 return STATE_FAILED;
6298 };
6299
6300 _proto.reset = function reset() {
6301 clearTimeout(this._timer);
6302 };
6303
6304 _proto.emit = function emit(input) {
6305 if (this.state !== STATE_RECOGNIZED) {
6306 return;
6307 }
6308
6309 if (input && input.eventType & INPUT_END) {
6310 this.manager.emit(this.options.event + "up", input);
6311 } else {
6312 this._input.timeStamp = now();
6313 this.manager.emit(this.options.event, this._input);
6314 }
6315 };
6316
6317 return PressRecognizer;
6318}(Recognizer);
6319
6320var defaults = {
6321 /**
6322 * @private
6323 * set if DOM events are being triggered.
6324 * But this is slower and unused by simple implementations, so disabled by default.
6325 * @type {Boolean}
6326 * @default false
6327 */
6328 domEvents: false,
6329
6330 /**
6331 * @private
6332 * The value for the touchAction property/fallback.
6333 * When set to `compute` it will magically set the correct value based on the added recognizers.
6334 * @type {String}
6335 * @default compute
6336 */
6337 touchAction: TOUCH_ACTION_COMPUTE,
6338
6339 /**
6340 * @private
6341 * @type {Boolean}
6342 * @default true
6343 */
6344 enable: true,
6345
6346 /**
6347 * @private
6348 * EXPERIMENTAL FEATURE -- can be removed/changed
6349 * Change the parent input target element.
6350 * If Null, then it is being set the to main element.
6351 * @type {Null|EventTarget}
6352 * @default null
6353 */
6354 inputTarget: null,
6355
6356 /**
6357 * @private
6358 * force an input class
6359 * @type {Null|Function}
6360 * @default null
6361 */
6362 inputClass: null,
6363
6364 /**
6365 * @private
6366 * Some CSS properties can be used to improve the working of Hammer.
6367 * Add them to this method and they will be set when creating a new Manager.
6368 * @namespace
6369 */
6370 cssProps: {
6371 /**
6372 * @private
6373 * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
6374 * @type {String}
6375 * @default 'none'
6376 */
6377 userSelect: "none",
6378
6379 /**
6380 * @private
6381 * Disable the Windows Phone grippers when pressing an element.
6382 * @type {String}
6383 * @default 'none'
6384 */
6385 touchSelect: "none",
6386
6387 /**
6388 * @private
6389 * Disables the default callout shown when you touch and hold a touch target.
6390 * On iOS, when you touch and hold a touch target such as a link, Safari displays
6391 * a callout containing information about the link. This property allows you to disable that callout.
6392 * @type {String}
6393 * @default 'none'
6394 */
6395 touchCallout: "none",
6396
6397 /**
6398 * @private
6399 * Specifies whether zooming is enabled. Used by IE10>
6400 * @type {String}
6401 * @default 'none'
6402 */
6403 contentZooming: "none",
6404
6405 /**
6406 * @private
6407 * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
6408 * @type {String}
6409 * @default 'none'
6410 */
6411 userDrag: "none",
6412
6413 /**
6414 * @private
6415 * Overrides the highlight color shown when the user taps a link or a JavaScript
6416 * clickable element in iOS. This property obeys the alpha value, if specified.
6417 * @type {String}
6418 * @default 'rgba(0,0,0,0)'
6419 */
6420 tapHighlightColor: "rgba(0,0,0,0)"
6421 }
6422};
6423/**
6424 * @private
6425 * Default recognizer setup when calling `Hammer()`
6426 * When creating a new Manager these will be skipped.
6427 * This is separated with other defaults because of tree-shaking.
6428 * @type {Array}
6429 */
6430
6431var preset = [[RotateRecognizer, {
6432 enable: false
6433}], [PinchRecognizer, {
6434 enable: false
6435}, ['rotate']], [SwipeRecognizer, {
6436 direction: DIRECTION_HORIZONTAL
6437}], [PanRecognizer, {
6438 direction: DIRECTION_HORIZONTAL
6439}, ['swipe']], [TapRecognizer], [TapRecognizer, {
6440 event: 'doubletap',
6441 taps: 2
6442}, ['tap']], [PressRecognizer]];
6443var STOP = 1;
6444var FORCED_STOP = 2;
6445/**
6446 * @private
6447 * add/remove the css properties as defined in manager.options.cssProps
6448 * @param {Manager} manager
6449 * @param {Boolean} add
6450 */
6451
6452function toggleCssProps(manager, add) {
6453 var element = manager.element;
6454
6455 if (!element.style) {
6456 return;
6457 }
6458
6459 var prop;
6460 each(manager.options.cssProps, function (value, name) {
6461 prop = prefixed(element.style, name);
6462
6463 if (add) {
6464 manager.oldCssProps[prop] = element.style[prop];
6465 element.style[prop] = value;
6466 } else {
6467 element.style[prop] = manager.oldCssProps[prop] || "";
6468 }
6469 });
6470
6471 if (!add) {
6472 manager.oldCssProps = {};
6473 }
6474}
6475/**
6476 * @private
6477 * trigger dom event
6478 * @param {String} event
6479 * @param {Object} data
6480 */
6481
6482
6483function triggerDomEvent(event, data) {
6484 var gestureEvent = document.createEvent("Event");
6485 gestureEvent.initEvent(event, true, true);
6486 gestureEvent.gesture = data;
6487 data.target.dispatchEvent(gestureEvent);
6488}
6489/**
6490* @private
6491 * Manager
6492 * @param {HTMLElement} element
6493 * @param {Object} [options]
6494 * @constructor
6495 */
6496
6497
6498var Manager = /*#__PURE__*/function () {
6499 function Manager(element, options) {
6500 var _this = this;
6501
6502 this.options = assign$1({}, defaults, options || {});
6503 this.options.inputTarget = this.options.inputTarget || element;
6504 this.handlers = {};
6505 this.session = {};
6506 this.recognizers = [];
6507 this.oldCssProps = {};
6508 this.element = element;
6509 this.input = createInputInstance(this);
6510 this.touchAction = new TouchAction(this, this.options.touchAction);
6511 toggleCssProps(this, true);
6512 each(this.options.recognizers, function (item) {
6513 var recognizer = _this.add(new item[0](item[1]));
6514
6515 item[2] && recognizer.recognizeWith(item[2]);
6516 item[3] && recognizer.requireFailure(item[3]);
6517 }, this);
6518 }
6519 /**
6520 * @private
6521 * set options
6522 * @param {Object} options
6523 * @returns {Manager}
6524 */
6525
6526
6527 var _proto = Manager.prototype;
6528
6529 _proto.set = function set(options) {
6530 assign$1(this.options, options); // Options that need a little more setup
6531
6532 if (options.touchAction) {
6533 this.touchAction.update();
6534 }
6535
6536 if (options.inputTarget) {
6537 // Clean up existing event listeners and reinitialize
6538 this.input.destroy();
6539 this.input.target = options.inputTarget;
6540 this.input.init();
6541 }
6542
6543 return this;
6544 };
6545 /**
6546 * @private
6547 * stop recognizing for this session.
6548 * This session will be discarded, when a new [input]start event is fired.
6549 * When forced, the recognizer cycle is stopped immediately.
6550 * @param {Boolean} [force]
6551 */
6552
6553
6554 _proto.stop = function stop(force) {
6555 this.session.stopped = force ? FORCED_STOP : STOP;
6556 };
6557 /**
6558 * @private
6559 * run the recognizers!
6560 * called by the inputHandler function on every movement of the pointers (touches)
6561 * it walks through all the recognizers and tries to detect the gesture that is being made
6562 * @param {Object} inputData
6563 */
6564
6565
6566 _proto.recognize = function recognize(inputData) {
6567 var session = this.session;
6568
6569 if (session.stopped) {
6570 return;
6571 } // run the touch-action polyfill
6572
6573
6574 this.touchAction.preventDefaults(inputData);
6575 var recognizer;
6576 var recognizers = this.recognizers; // this holds the recognizer that is being recognized.
6577 // so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED
6578 // if no recognizer is detecting a thing, it is set to `null`
6579
6580 var curRecognizer = session.curRecognizer; // reset when the last recognizer is recognized
6581 // or when we're in a new session
6582
6583 if (!curRecognizer || curRecognizer && curRecognizer.state & STATE_RECOGNIZED) {
6584 session.curRecognizer = null;
6585 curRecognizer = null;
6586 }
6587
6588 var i = 0;
6589
6590 while (i < recognizers.length) {
6591 recognizer = recognizers[i]; // find out if we are allowed try to recognize the input for this one.
6592 // 1. allow if the session is NOT forced stopped (see the .stop() method)
6593 // 2. allow if we still haven't recognized a gesture in this session, or the this recognizer is the one
6594 // that is being recognized.
6595 // 3. allow if the recognizer is allowed to run simultaneous with the current recognized recognizer.
6596 // this can be setup with the `recognizeWith()` method on the recognizer.
6597
6598 if (session.stopped !== FORCED_STOP && ( // 1
6599 !curRecognizer || recognizer === curRecognizer || // 2
6600 recognizer.canRecognizeWith(curRecognizer))) {
6601 // 3
6602 recognizer.recognize(inputData);
6603 } else {
6604 recognizer.reset();
6605 } // if the recognizer has been recognizing the input as a valid gesture, we want to store this one as the
6606 // current active recognizer. but only if we don't already have an active recognizer
6607
6608
6609 if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
6610 session.curRecognizer = recognizer;
6611 curRecognizer = recognizer;
6612 }
6613
6614 i++;
6615 }
6616 };
6617 /**
6618 * @private
6619 * get a recognizer by its event name.
6620 * @param {Recognizer|String} recognizer
6621 * @returns {Recognizer|Null}
6622 */
6623
6624
6625 _proto.get = function get(recognizer) {
6626 if (recognizer instanceof Recognizer) {
6627 return recognizer;
6628 }
6629
6630 var recognizers = this.recognizers;
6631
6632 for (var i = 0; i < recognizers.length; i++) {
6633 if (recognizers[i].options.event === recognizer) {
6634 return recognizers[i];
6635 }
6636 }
6637
6638 return null;
6639 };
6640 /**
6641 * @private add a recognizer to the manager
6642 * existing recognizers with the same event name will be removed
6643 * @param {Recognizer} recognizer
6644 * @returns {Recognizer|Manager}
6645 */
6646
6647
6648 _proto.add = function add(recognizer) {
6649 if (invokeArrayArg(recognizer, "add", this)) {
6650 return this;
6651 } // remove existing
6652
6653
6654 var existing = this.get(recognizer.options.event);
6655
6656 if (existing) {
6657 this.remove(existing);
6658 }
6659
6660 this.recognizers.push(recognizer);
6661 recognizer.manager = this;
6662 this.touchAction.update();
6663 return recognizer;
6664 };
6665 /**
6666 * @private
6667 * remove a recognizer by name or instance
6668 * @param {Recognizer|String} recognizer
6669 * @returns {Manager}
6670 */
6671
6672
6673 _proto.remove = function remove(recognizer) {
6674 if (invokeArrayArg(recognizer, "remove", this)) {
6675 return this;
6676 }
6677
6678 var targetRecognizer = this.get(recognizer); // let's make sure this recognizer exists
6679
6680 if (recognizer) {
6681 var recognizers = this.recognizers;
6682 var index = inArray(recognizers, targetRecognizer);
6683
6684 if (index !== -1) {
6685 recognizers.splice(index, 1);
6686 this.touchAction.update();
6687 }
6688 }
6689
6690 return this;
6691 };
6692 /**
6693 * @private
6694 * bind event
6695 * @param {String} events
6696 * @param {Function} handler
6697 * @returns {EventEmitter} this
6698 */
6699
6700
6701 _proto.on = function on(events, handler) {
6702 if (events === undefined || handler === undefined) {
6703 return this;
6704 }
6705
6706 var handlers = this.handlers;
6707 each(splitStr(events), function (event) {
6708 handlers[event] = handlers[event] || [];
6709 handlers[event].push(handler);
6710 });
6711 return this;
6712 };
6713 /**
6714 * @private unbind event, leave emit blank to remove all handlers
6715 * @param {String} events
6716 * @param {Function} [handler]
6717 * @returns {EventEmitter} this
6718 */
6719
6720
6721 _proto.off = function off(events, handler) {
6722 if (events === undefined) {
6723 return this;
6724 }
6725
6726 var handlers = this.handlers;
6727 each(splitStr(events), function (event) {
6728 if (!handler) {
6729 delete handlers[event];
6730 } else {
6731 handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
6732 }
6733 });
6734 return this;
6735 };
6736 /**
6737 * @private emit event to the listeners
6738 * @param {String} event
6739 * @param {Object} data
6740 */
6741
6742
6743 _proto.emit = function emit(event, data) {
6744 // we also want to trigger dom events
6745 if (this.options.domEvents) {
6746 triggerDomEvent(event, data);
6747 } // no handlers, so skip it all
6748
6749
6750 var handlers = this.handlers[event] && this.handlers[event].slice();
6751
6752 if (!handlers || !handlers.length) {
6753 return;
6754 }
6755
6756 data.type = event;
6757
6758 data.preventDefault = function () {
6759 data.srcEvent.preventDefault();
6760 };
6761
6762 var i = 0;
6763
6764 while (i < handlers.length) {
6765 handlers[i](data);
6766 i++;
6767 }
6768 };
6769 /**
6770 * @private
6771 * destroy the manager and unbinds all events
6772 * it doesn't unbind dom events, that is the user own responsibility
6773 */
6774
6775
6776 _proto.destroy = function destroy() {
6777 this.element && toggleCssProps(this, false);
6778 this.handlers = {};
6779 this.session = {};
6780 this.input.destroy();
6781 this.element = null;
6782 };
6783
6784 return Manager;
6785}();
6786
6787var SINGLE_TOUCH_INPUT_MAP = {
6788 touchstart: INPUT_START,
6789 touchmove: INPUT_MOVE,
6790 touchend: INPUT_END,
6791 touchcancel: INPUT_CANCEL
6792};
6793var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
6794var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
6795/**
6796 * @private
6797 * Touch events input
6798 * @constructor
6799 * @extends Input
6800 */
6801
6802var SingleTouchInput = /*#__PURE__*/function (_Input) {
6803 _inheritsLoose(SingleTouchInput, _Input);
6804
6805 function SingleTouchInput() {
6806 var _this;
6807
6808 var proto = SingleTouchInput.prototype;
6809 proto.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
6810 proto.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
6811 _this = _Input.apply(this, arguments) || this;
6812 _this.started = false;
6813 return _this;
6814 }
6815
6816 var _proto = SingleTouchInput.prototype;
6817
6818 _proto.handler = function handler(ev) {
6819 var type = SINGLE_TOUCH_INPUT_MAP[ev.type]; // should we handle the touch events?
6820
6821 if (type === INPUT_START) {
6822 this.started = true;
6823 }
6824
6825 if (!this.started) {
6826 return;
6827 }
6828
6829 var touches = normalizeSingleTouches.call(this, ev, type); // when done, reset the started state
6830
6831 if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
6832 this.started = false;
6833 }
6834
6835 this.callback(this.manager, type, {
6836 pointers: touches[0],
6837 changedPointers: touches[1],
6838 pointerType: INPUT_TYPE_TOUCH,
6839 srcEvent: ev
6840 });
6841 };
6842
6843 return SingleTouchInput;
6844}(Input);
6845
6846function normalizeSingleTouches(ev, type) {
6847 var all = toArray(ev.touches);
6848 var changed = toArray(ev.changedTouches);
6849
6850 if (type & (INPUT_END | INPUT_CANCEL)) {
6851 all = uniqueArray(all.concat(changed), 'identifier', true);
6852 }
6853
6854 return [all, changed];
6855}
6856/**
6857 * @private
6858 * wrap a method with a deprecation warning and stack trace
6859 * @param {Function} method
6860 * @param {String} name
6861 * @param {String} message
6862 * @returns {Function} A new function wrapping the supplied method.
6863 */
6864
6865
6866function deprecate(method, name, message) {
6867 var deprecationMessage = "DEPRECATED METHOD: " + name + "\n" + message + " AT \n";
6868 return function () {
6869 var e = new Error('get-stack-trace');
6870 var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, '').replace(/^\s+at\s+/gm, '').replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') : 'Unknown Stack Trace';
6871 var log = window.console && (window.console.warn || window.console.log);
6872
6873 if (log) {
6874 log.call(window.console, deprecationMessage, stack);
6875 }
6876
6877 return method.apply(this, arguments);
6878 };
6879}
6880/**
6881 * @private
6882 * extend object.
6883 * means that properties in dest will be overwritten by the ones in src.
6884 * @param {Object} dest
6885 * @param {Object} src
6886 * @param {Boolean} [merge=false]
6887 * @returns {Object} dest
6888 */
6889
6890
6891var extend = deprecate(function (dest, src, merge) {
6892 var keys = Object.keys(src);
6893 var i = 0;
6894
6895 while (i < keys.length) {
6896 if (!merge || merge && dest[keys[i]] === undefined) {
6897 dest[keys[i]] = src[keys[i]];
6898 }
6899
6900 i++;
6901 }
6902
6903 return dest;
6904}, 'extend', 'Use `assign`.');
6905/**
6906 * @private
6907 * merge the values from src in the dest.
6908 * means that properties that exist in dest will not be overwritten by src
6909 * @param {Object} dest
6910 * @param {Object} src
6911 * @returns {Object} dest
6912 */
6913
6914var merge = deprecate(function (dest, src) {
6915 return extend(dest, src, true);
6916}, 'merge', 'Use `assign`.');
6917/**
6918 * @private
6919 * simple class inheritance
6920 * @param {Function} child
6921 * @param {Function} base
6922 * @param {Object} [properties]
6923 */
6924
6925function inherit(child, base, properties) {
6926 var baseP = base.prototype;
6927 var childP;
6928 childP = child.prototype = Object.create(baseP);
6929 childP.constructor = child;
6930 childP._super = baseP;
6931
6932 if (properties) {
6933 assign$1(childP, properties);
6934 }
6935}
6936/**
6937 * @private
6938 * simple function bind
6939 * @param {Function} fn
6940 * @param {Object} context
6941 * @returns {Function}
6942 */
6943
6944
6945function bindFn(fn, context) {
6946 return function boundFn() {
6947 return fn.apply(context, arguments);
6948 };
6949}
6950/**
6951 * @private
6952 * Simple way to create a manager with a default set of recognizers.
6953 * @param {HTMLElement} element
6954 * @param {Object} [options]
6955 * @constructor
6956 */
6957
6958
6959var Hammer$1 = /*#__PURE__*/function () {
6960 var Hammer =
6961 /**
6962 * @private
6963 * @const {string}
6964 */
6965 function Hammer(element, options) {
6966 if (options === void 0) {
6967 options = {};
6968 }
6969
6970 return new Manager(element, _extends({
6971 recognizers: preset.concat()
6972 }, options));
6973 };
6974
6975 Hammer.VERSION = "2.0.17-rc";
6976 Hammer.DIRECTION_ALL = DIRECTION_ALL;
6977 Hammer.DIRECTION_DOWN = DIRECTION_DOWN;
6978 Hammer.DIRECTION_LEFT = DIRECTION_LEFT;
6979 Hammer.DIRECTION_RIGHT = DIRECTION_RIGHT;
6980 Hammer.DIRECTION_UP = DIRECTION_UP;
6981 Hammer.DIRECTION_HORIZONTAL = DIRECTION_HORIZONTAL;
6982 Hammer.DIRECTION_VERTICAL = DIRECTION_VERTICAL;
6983 Hammer.DIRECTION_NONE = DIRECTION_NONE;
6984 Hammer.DIRECTION_DOWN = DIRECTION_DOWN;
6985 Hammer.INPUT_START = INPUT_START;
6986 Hammer.INPUT_MOVE = INPUT_MOVE;
6987 Hammer.INPUT_END = INPUT_END;
6988 Hammer.INPUT_CANCEL = INPUT_CANCEL;
6989 Hammer.STATE_POSSIBLE = STATE_POSSIBLE;
6990 Hammer.STATE_BEGAN = STATE_BEGAN;
6991 Hammer.STATE_CHANGED = STATE_CHANGED;
6992 Hammer.STATE_ENDED = STATE_ENDED;
6993 Hammer.STATE_RECOGNIZED = STATE_RECOGNIZED;
6994 Hammer.STATE_CANCELLED = STATE_CANCELLED;
6995 Hammer.STATE_FAILED = STATE_FAILED;
6996 Hammer.Manager = Manager;
6997 Hammer.Input = Input;
6998 Hammer.TouchAction = TouchAction;
6999 Hammer.TouchInput = TouchInput;
7000 Hammer.MouseInput = MouseInput;
7001 Hammer.PointerEventInput = PointerEventInput;
7002 Hammer.TouchMouseInput = TouchMouseInput;
7003 Hammer.SingleTouchInput = SingleTouchInput;
7004 Hammer.Recognizer = Recognizer;
7005 Hammer.AttrRecognizer = AttrRecognizer;
7006 Hammer.Tap = TapRecognizer;
7007 Hammer.Pan = PanRecognizer;
7008 Hammer.Swipe = SwipeRecognizer;
7009 Hammer.Pinch = PinchRecognizer;
7010 Hammer.Rotate = RotateRecognizer;
7011 Hammer.Press = PressRecognizer;
7012 Hammer.on = addEventListeners;
7013 Hammer.off = removeEventListeners;
7014 Hammer.each = each;
7015 Hammer.merge = merge;
7016 Hammer.extend = extend;
7017 Hammer.bindFn = bindFn;
7018 Hammer.assign = assign$1;
7019 Hammer.inherit = inherit;
7020 Hammer.bindFn = bindFn;
7021 Hammer.prefixed = prefixed;
7022 Hammer.toArray = toArray;
7023 Hammer.inArray = inArray;
7024 Hammer.uniqueArray = uniqueArray;
7025 Hammer.splitStr = splitStr;
7026 Hammer.boolOrFn = boolOrFn;
7027 Hammer.hasParent = hasParent;
7028 Hammer.addEventListeners = addEventListeners;
7029 Hammer.removeEventListeners = removeEventListeners;
7030 Hammer.defaults = assign$1({}, defaults, {
7031 preset: preset
7032 });
7033 return Hammer;
7034}(); // style loader but by script tag, not by the loader.
7035var RealHammer = Hammer$1;
7036
7037function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof symbol !== "undefined" && getIteratorMethod$2(o) || o["@@iterator"]; if (!it) { if (isArray$5(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7038
7039function _unsupportedIterableToArray$1(o, minLen) { var _context21; if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = slice$1(_context21 = Object.prototype.toString.call(o)).call(_context21, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return from$2(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
7040
7041function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
7042/**
7043 * Use this symbol to delete properies in deepObjectAssign.
7044 */
7045
7046var DELETE = symbol("DELETE");
7047/**
7048 * Pure version of deepObjectAssign, it doesn't modify any of it's arguments.
7049 *
7050 * @param base - The base object that fullfils the whole interface T.
7051 * @param updates - Updates that may change or delete props.
7052 *
7053 * @returns A brand new instance with all the supplied objects deeply merged.
7054 */
7055
7056
7057function pureDeepObjectAssign(base) {
7058 var _context;
7059
7060 for (var _len = arguments.length, updates = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
7061 updates[_key - 1] = arguments[_key];
7062 }
7063
7064 return deepObjectAssign.apply(void 0, concat(_context = [{}, base]).call(_context, updates));
7065}
7066/**
7067 * Deep version of object assign with additional deleting by the DELETE symbol.
7068 *
7069 * @param values - Objects to be deeply merged.
7070 *
7071 * @returns The first object from values.
7072 */
7073
7074
7075function deepObjectAssign() {
7076 var merged = deepObjectAssignNonentry.apply(void 0, arguments);
7077 stripDelete(merged);
7078 return merged;
7079}
7080/**
7081 * Deep version of object assign with additional deleting by the DELETE symbol.
7082 *
7083 * @remarks
7084 * This doesn't strip the DELETE symbols so they may end up in the final object.
7085 *
7086 * @param values - Objects to be deeply merged.
7087 *
7088 * @returns The first object from values.
7089 */
7090
7091
7092function deepObjectAssignNonentry() {
7093 for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
7094 values[_key2] = arguments[_key2];
7095 }
7096
7097 if (values.length < 2) {
7098 return values[0];
7099 } else if (values.length > 2) {
7100 var _context2;
7101
7102 return deepObjectAssignNonentry.apply(void 0, concat(_context2 = [deepObjectAssign(values[0], values[1])]).call(_context2, _toConsumableArray(slice$1(values).call(values, 2))));
7103 }
7104
7105 var a = values[0];
7106 var b = values[1];
7107
7108 var _iterator = _createForOfIteratorHelper$1(ownKeys$1(b)),
7109 _step;
7110
7111 try {
7112 for (_iterator.s(); !(_step = _iterator.n()).done;) {
7113 var prop = _step.value;
7114 if (!Object.prototype.propertyIsEnumerable.call(b, prop)) ;else if (b[prop] === DELETE) {
7115 delete a[prop];
7116 } else if (a[prop] !== null && b[prop] !== null && _typeof(a[prop]) === "object" && _typeof(b[prop]) === "object" && !isArray$5(a[prop]) && !isArray$5(b[prop])) {
7117 a[prop] = deepObjectAssignNonentry(a[prop], b[prop]);
7118 } else {
7119 a[prop] = clone(b[prop]);
7120 }
7121 }
7122 } catch (err) {
7123 _iterator.e(err);
7124 } finally {
7125 _iterator.f();
7126 }
7127
7128 return a;
7129}
7130/**
7131 * Deep clone given object or array. In case of primitive simply return.
7132 *
7133 * @param a - Anything.
7134 *
7135 * @returns Deep cloned object/array or unchanged a.
7136 */
7137
7138
7139function clone(a) {
7140 if (isArray$5(a)) {
7141 return map$3(a).call(a, function (value) {
7142 return clone(value);
7143 });
7144 } else if (_typeof(a) === "object" && a !== null) {
7145 return deepObjectAssignNonentry({}, a);
7146 } else {
7147 return a;
7148 }
7149}
7150/**
7151 * Strip DELETE from given object.
7152 *
7153 * @param a - Object which may contain DELETE but won't after this is executed.
7154 */
7155
7156
7157function stripDelete(a) {
7158 for (var _i = 0, _Object$keys = keys$4(a); _i < _Object$keys.length; _i++) {
7159 var prop = _Object$keys[_i];
7160
7161 if (a[prop] === DELETE) {
7162 delete a[prop];
7163 } else if (_typeof(a[prop]) === "object" && a[prop] !== null) {
7164 stripDelete(a[prop]);
7165 }
7166 }
7167}
7168/**
7169 * Setup a mock hammer.js object, for unit testing.
7170 *
7171 * Inspiration: https://github.com/uber/deck.gl/pull/658
7172 *
7173 * @returns {{on: noop, off: noop, destroy: noop, emit: noop, get: get}}
7174 */
7175
7176
7177function hammerMock() {
7178 var noop = function noop() {};
7179
7180 return {
7181 on: noop,
7182 off: noop,
7183 destroy: noop,
7184 emit: noop,
7185 get: function get() {
7186 return {
7187 set: noop
7188 };
7189 }
7190 };
7191}
7192
7193var Hammer = typeof window !== "undefined" ? window.Hammer || RealHammer : function () {
7194 // hammer.js is only available in a browser, not in node.js. Replacing it with a mock object.
7195 return hammerMock();
7196};
7197/**
7198 * Turn an element into an clickToUse element.
7199 * When not active, the element has a transparent overlay. When the overlay is
7200 * clicked, the mode is changed to active.
7201 * When active, the element is displayed with a blue border around it, and
7202 * the interactive contents of the element can be used. When clicked outside
7203 * the element, the elements mode is changed to inactive.
7204 *
7205 * @param {Element} container
7206 * @class Activator
7207 */
7208
7209function Activator(container) {
7210 var _this = this,
7211 _context3;
7212
7213 this._cleanupQueue = [];
7214 this.active = false;
7215 this._dom = {
7216 container: container,
7217 overlay: document.createElement("div")
7218 };
7219
7220 this._dom.overlay.classList.add("vis-overlay");
7221
7222 this._dom.container.appendChild(this._dom.overlay);
7223
7224 this._cleanupQueue.push(function () {
7225 _this._dom.overlay.parentNode.removeChild(_this._dom.overlay);
7226 });
7227
7228 var hammer = Hammer(this._dom.overlay);
7229 hammer.on("tap", bind$4(_context3 = this._onTapOverlay).call(_context3, this));
7230
7231 this._cleanupQueue.push(function () {
7232 hammer.destroy(); // FIXME: cleaning up hammer instances doesn't work (Timeline not removed
7233 // from memory)
7234 }); // block all touch events (except tap)
7235
7236
7237 var events = ["tap", "doubletap", "press", "pinch", "pan", "panstart", "panmove", "panend"];
7238
7239 forEach$1(events).call(events, function (event) {
7240 hammer.on(event, function (event) {
7241 event.srcEvent.stopPropagation();
7242 });
7243 }); // attach a click event to the window, in order to deactivate when clicking outside the timeline
7244
7245
7246 if (document && document.body) {
7247 this._onClick = function (event) {
7248 if (!_hasParent(event.target, container)) {
7249 _this.deactivate();
7250 }
7251 };
7252
7253 document.body.addEventListener("click", this._onClick);
7254
7255 this._cleanupQueue.push(function () {
7256 document.body.removeEventListener("click", _this._onClick);
7257 });
7258 } // prepare escape key listener for deactivating when active
7259
7260
7261 this._escListener = function (event) {
7262 if ("key" in event ? event.key === "Escape" : event.keyCode === 27
7263 /* the keyCode is for IE11 */
7264 ) {
7265 _this.deactivate();
7266 }
7267 };
7268} // turn into an event emitter
7269
7270
7271Emitter(Activator.prototype); // The currently active activator
7272
7273Activator.current = null;
7274/**
7275 * Destroy the activator. Cleans up all created DOM and event listeners
7276 */
7277
7278Activator.prototype.destroy = function () {
7279 var _context4, _context5;
7280
7281 this.deactivate();
7282
7283 var _iterator2 = _createForOfIteratorHelper$1(reverse(_context4 = splice(_context5 = this._cleanupQueue).call(_context5, 0)).call(_context4)),
7284 _step2;
7285
7286 try {
7287 for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
7288 var callback = _step2.value;
7289 callback();
7290 }
7291 } catch (err) {
7292 _iterator2.e(err);
7293 } finally {
7294 _iterator2.f();
7295 }
7296};
7297/**
7298 * Activate the element
7299 * Overlay is hidden, element is decorated with a blue shadow border
7300 */
7301
7302
7303Activator.prototype.activate = function () {
7304 // we allow only one active activator at a time
7305 if (Activator.current) {
7306 Activator.current.deactivate();
7307 }
7308
7309 Activator.current = this;
7310 this.active = true;
7311 this._dom.overlay.style.display = "none";
7312
7313 this._dom.container.classList.add("vis-active");
7314
7315 this.emit("change");
7316 this.emit("activate"); // ugly hack: bind ESC after emitting the events, as the Network rebinds all
7317 // keyboard events on a 'change' event
7318
7319 document.body.addEventListener("keydown", this._escListener);
7320};
7321/**
7322 * Deactivate the element
7323 * Overlay is displayed on top of the element
7324 */
7325
7326
7327Activator.prototype.deactivate = function () {
7328 this.active = false;
7329 this._dom.overlay.style.display = "block";
7330
7331 this._dom.container.classList.remove("vis-active");
7332
7333 document.body.removeEventListener("keydown", this._escListener);
7334 this.emit("change");
7335 this.emit("deactivate");
7336};
7337/**
7338 * Handle a tap event: activate the container
7339 *
7340 * @param {Event} event The event
7341 * @private
7342 */
7343
7344
7345Activator.prototype._onTapOverlay = function (event) {
7346 // activate the container
7347 this.activate();
7348 event.srcEvent.stopPropagation();
7349};
7350/**
7351 * Test whether the element has the requested parent element somewhere in
7352 * its chain of parent nodes.
7353 *
7354 * @param {HTMLElement} element
7355 * @param {HTMLElement} parent
7356 * @returns {boolean} Returns true when the parent is found somewhere in the
7357 * chain of parent nodes.
7358 * @private
7359 */
7360
7361
7362function _hasParent(element, parent) {
7363 while (element) {
7364 if (element === parent) {
7365 return true;
7366 }
7367
7368 element = element.parentNode;
7369 }
7370
7371 return false;
7372} // utility functions
7373
7374var fullHexRE = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
7375var shortHexRE = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
7376/**
7377 * Copy property from b to a if property present in a.
7378 * If property in b explicitly set to null, delete it if `allowDeletion` set.
7379 *
7380 * Internal helper routine, should not be exported. Not added to `exports` for that reason.
7381 *
7382 * @param a - Target object.
7383 * @param b - Source object.
7384 * @param prop - Name of property to copy from b to a.
7385 * @param allowDeletion - If true, delete property in a if explicitly set to null in b.
7386 */
7387
7388
7389function copyOrDelete(a, b, prop, allowDeletion) {
7390 var doDeletion = false;
7391
7392 if (allowDeletion === true) {
7393 doDeletion = b[prop] === null && a[prop] !== undefined;
7394 }
7395
7396 if (doDeletion) {
7397 delete a[prop];
7398 } else {
7399 a[prop] = b[prop]; // Remember, this is a reference copy!
7400 }
7401}
7402/**
7403 * Extend object a with selected properties of object b.
7404 * Only properties with defined values are copied.
7405 *
7406 * @remarks
7407 * Previous version of this routine implied that multiple source objects could
7408 * be used; however, the implementation was **wrong**. Since multiple (\>1)
7409 * sources weren't used anywhere in the `vis.js` code, this has been removed
7410 *
7411 * @param props - Names of first-level properties to copy over.
7412 * @param a - Target object.
7413 * @param b - Source object.
7414 * @param allowDeletion - If true, delete property in a if explicitly set to null in b.
7415 *
7416 * @returns Argument a.
7417 */
7418
7419
7420function selectiveDeepExtend(props, a, b) {
7421 var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
7422
7423 // TODO: add support for Arrays to deepExtend
7424 if (isArray$5(b)) {
7425 throw new TypeError("Arrays are not supported by deepExtend");
7426 }
7427
7428 for (var p = 0; p < props.length; p++) {
7429 var prop = props[p];
7430
7431 if (Object.prototype.hasOwnProperty.call(b, prop)) {
7432 if (b[prop] && b[prop].constructor === Object) {
7433 if (a[prop] === undefined) {
7434 a[prop] = {};
7435 }
7436
7437 if (a[prop].constructor === Object) {
7438 deepExtend(a[prop], b[prop], false, allowDeletion);
7439 } else {
7440 copyOrDelete(a, b, prop, allowDeletion);
7441 }
7442 } else if (isArray$5(b[prop])) {
7443 throw new TypeError("Arrays are not supported by deepExtend");
7444 } else {
7445 copyOrDelete(a, b, prop, allowDeletion);
7446 }
7447 }
7448 }
7449
7450 return a;
7451}
7452/**
7453 * Deep extend an object a with the properties of object b.
7454 *
7455 * @param a - Target object.
7456 * @param b - Source object.
7457 * @param protoExtend - If true, the prototype values will also be extended.
7458 * (That is the options objects that inherit from others will also get the
7459 * inherited options).
7460 * @param allowDeletion - If true, the values of fields that are null will be deleted.
7461 *
7462 * @returns Argument a.
7463 */
7464
7465
7466function deepExtend(a, b) {
7467 var protoExtend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
7468 var allowDeletion = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
7469
7470 for (var prop in b) {
7471 if (Object.prototype.hasOwnProperty.call(b, prop) || protoExtend === true) {
7472 if (_typeof(b[prop]) === "object" && b[prop] !== null && getPrototypeOf$2(b[prop]) === Object.prototype) {
7473 if (a[prop] === undefined) {
7474 a[prop] = deepExtend({}, b[prop], protoExtend); // NOTE: allowDeletion not propagated!
7475 } else if (_typeof(a[prop]) === "object" && a[prop] !== null && getPrototypeOf$2(a[prop]) === Object.prototype) {
7476 deepExtend(a[prop], b[prop], protoExtend); // NOTE: allowDeletion not propagated!
7477 } else {
7478 copyOrDelete(a, b, prop, allowDeletion);
7479 }
7480 } else if (isArray$5(b[prop])) {
7481 var _context6;
7482
7483 a[prop] = slice$1(_context6 = b[prop]).call(_context6);
7484 } else {
7485 copyOrDelete(a, b, prop, allowDeletion);
7486 }
7487 }
7488 }
7489
7490 return a;
7491}
7492/**
7493 * Used to extend an array and copy it. This is used to propagate paths recursively.
7494 *
7495 * @param arr - First part.
7496 * @param newValue - The value to be aadded into the array.
7497 *
7498 * @returns A new array with all items from arr and newValue (which is last).
7499 */
7500
7501
7502function copyAndExtendArray(arr, newValue) {
7503 var _context7;
7504
7505 return concat(_context7 = []).call(_context7, _toConsumableArray(arr), [newValue]);
7506}
7507/**
7508 * Used to extend an array and copy it. This is used to propagate paths recursively.
7509 *
7510 * @param arr - The array to be copied.
7511 *
7512 * @returns Shallow copy of arr.
7513 */
7514
7515
7516function copyArray(arr) {
7517 return slice$1(arr).call(arr);
7518}
7519/**
7520 * Add and event listener. Works for all browsers.
7521 *
7522 * @param element - The element to bind the event listener to.
7523 * @param action - Same as Element.addEventListener(action, —, —).
7524 * @param listener - Same as Element.addEventListener(—, listener, —).
7525 * @param useCapture - Same as Element.addEventListener(—, —, useCapture).
7526 */
7527
7528
7529function addEventListener(element, action, listener, useCapture) {
7530 if (element.addEventListener) {
7531 var _context8;
7532
7533 if (useCapture === undefined) {
7534 useCapture = false;
7535 }
7536
7537 if (action === "mousewheel" && includes(_context8 = navigator.userAgent).call(_context8, "Firefox")) {
7538 action = "DOMMouseScroll"; // For Firefox
7539 }
7540
7541 element.addEventListener(action, listener, useCapture);
7542 } else {
7543 // @TODO: IE types? Does anyone care?
7544 element.attachEvent("on" + action, listener); // IE browsers
7545 }
7546}
7547/**
7548 * Remove an event listener from an element.
7549 *
7550 * @param element - The element to bind the event listener to.
7551 * @param action - Same as Element.removeEventListener(action, —, —).
7552 * @param listener - Same as Element.removeEventListener(—, listener, —).
7553 * @param useCapture - Same as Element.removeEventListener(—, —, useCapture).
7554 */
7555
7556
7557function removeEventListener(element, action, listener, useCapture) {
7558 if (element.removeEventListener) {
7559 var _context9;
7560
7561 // non-IE browsers
7562 if (useCapture === undefined) {
7563 useCapture = false;
7564 }
7565
7566 if (action === "mousewheel" && includes(_context9 = navigator.userAgent).call(_context9, "Firefox")) {
7567 action = "DOMMouseScroll"; // For Firefox
7568 }
7569
7570 element.removeEventListener(action, listener, useCapture);
7571 } else {
7572 // @TODO: IE types? Does anyone care?
7573 element.detachEvent("on" + action, listener); // IE browsers
7574 }
7575}
7576/**
7577 * Cancels the event's default action if it is cancelable, without stopping further propagation of the event.
7578 *
7579 * @param event - The event whose default action should be prevented.
7580 */
7581
7582
7583function preventDefault(event) {
7584 if (!event) {
7585 event = window.event;
7586 }
7587
7588 if (!event) ;else if (event.preventDefault) {
7589 event.preventDefault(); // non-IE browsers
7590 } else {
7591 // @TODO: IE types? Does anyone care?
7592 event.returnValue = false; // IE browsers
7593 }
7594}
7595/**
7596 * Convert hex color string into RGB color object.
7597 *
7598 * @remarks
7599 * {@link http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb}
7600 *
7601 * @param hex - Hex color string (3 or 6 digits, with or without #).
7602 *
7603 * @returns RGB color object.
7604 */
7605
7606function hexToRGB(hex) {
7607 var result;
7608
7609 switch (hex.length) {
7610 case 3:
7611 case 4:
7612 result = shortHexRE.exec(hex);
7613 return result ? {
7614 r: _parseInt(result[1] + result[1], 16),
7615 g: _parseInt(result[2] + result[2], 16),
7616 b: _parseInt(result[3] + result[3], 16)
7617 } : null;
7618
7619 case 6:
7620 case 7:
7621 result = fullHexRE.exec(hex);
7622 return result ? {
7623 r: _parseInt(result[1], 16),
7624 g: _parseInt(result[2], 16),
7625 b: _parseInt(result[3], 16)
7626 } : null;
7627
7628 default:
7629 return null;
7630 }
7631}
7632/**
7633 * Convert HSV \<0, 1\> into RGB color object.
7634 *
7635 * @remarks
7636 * {@link https://gist.github.com/mjijackson/5311256}
7637 *
7638 * @param h - Hue.
7639 * @param s - Saturation.
7640 * @param v - Value.
7641 *
7642 * @returns RGB color object.
7643 */
7644
7645
7646function HSVToRGB(h, s, v) {
7647 var r;
7648 var g;
7649 var b;
7650 var i = Math.floor(h * 6);
7651 var f = h * 6 - i;
7652 var p = v * (1 - s);
7653 var q = v * (1 - f * s);
7654 var t = v * (1 - (1 - f) * s);
7655
7656 switch (i % 6) {
7657 case 0:
7658 r = v, g = t, b = p;
7659 break;
7660
7661 case 1:
7662 r = q, g = v, b = p;
7663 break;
7664
7665 case 2:
7666 r = p, g = v, b = t;
7667 break;
7668
7669 case 3:
7670 r = p, g = q, b = v;
7671 break;
7672
7673 case 4:
7674 r = t, g = p, b = v;
7675 break;
7676
7677 case 5:
7678 r = v, g = p, b = q;
7679 break;
7680 }
7681
7682 return {
7683 r: Math.floor(r * 255),
7684 g: Math.floor(g * 255),
7685 b: Math.floor(b * 255)
7686 };
7687}
7688/**
7689 * Validate hex color string.
7690 *
7691 * @param hex - Unknown string that may contain a color.
7692 *
7693 * @returns True if the string is valid, false otherwise.
7694 */
7695
7696
7697function isValidHex(hex) {
7698 var isOk = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex);
7699 return isOk;
7700}
7701
7702var errorFound = false;
7703var allOptions$1;
7704var VALIDATOR_PRINT_STYLE = "background: #FFeeee; color: #dd0000";
7705/**
7706 * Used to validate options.
7707 */
7708
7709var Validator = /*#__PURE__*/function () {
7710 function Validator() {
7711 _classCallCheck(this, Validator);
7712 }
7713
7714 _createClass(Validator, null, [{
7715 key: "validate",
7716 value:
7717 /**
7718 * Main function to be called
7719 *
7720 * @param {object} options
7721 * @param {object} referenceOptions
7722 * @param {object} subObject
7723 * @returns {boolean}
7724 * @static
7725 */
7726 function validate(options, referenceOptions, subObject) {
7727 errorFound = false;
7728 allOptions$1 = referenceOptions;
7729 var usedOptions = referenceOptions;
7730
7731 if (subObject !== undefined) {
7732 usedOptions = referenceOptions[subObject];
7733 }
7734
7735 Validator.parse(options, usedOptions, []);
7736 return errorFound;
7737 }
7738 /**
7739 * Will traverse an object recursively and check every value
7740 *
7741 * @param {object} options
7742 * @param {object} referenceOptions
7743 * @param {Array} path | where to look for the actual option
7744 * @static
7745 */
7746
7747 }, {
7748 key: "parse",
7749 value: function parse(options, referenceOptions, path) {
7750 for (var _option3 in options) {
7751 if (Object.prototype.hasOwnProperty.call(options, _option3)) {
7752 Validator.check(_option3, options, referenceOptions, path);
7753 }
7754 }
7755 }
7756 /**
7757 * Check every value. If the value is an object, call the parse function on that object.
7758 *
7759 * @param {string} option
7760 * @param {object} options
7761 * @param {object} referenceOptions
7762 * @param {Array} path | where to look for the actual option
7763 * @static
7764 */
7765
7766 }, {
7767 key: "check",
7768 value: function check(option, options, referenceOptions, path) {
7769 if (referenceOptions[option] === undefined && referenceOptions.__any__ === undefined) {
7770 Validator.getSuggestion(option, referenceOptions, path);
7771 return;
7772 }
7773
7774 var referenceOption = option;
7775 var is_object = true;
7776
7777 if (referenceOptions[option] === undefined && referenceOptions.__any__ !== undefined) {
7778 // NOTE: This only triggers if the __any__ is in the top level of the options object.
7779 // THAT'S A REALLY BAD PLACE TO ALLOW IT!!!!
7780 // TODO: Examine if needed, remove if possible
7781 // __any__ is a wildcard. Any value is accepted and will be further analysed by reference.
7782 referenceOption = "__any__"; // if the any-subgroup is not a predefined object in the configurator,
7783 // we do not look deeper into the object.
7784
7785 is_object = Validator.getType(options[option]) === "object";
7786 }
7787
7788 var refOptionObj = referenceOptions[referenceOption];
7789
7790 if (is_object && refOptionObj.__type__ !== undefined) {
7791 refOptionObj = refOptionObj.__type__;
7792 }
7793
7794 Validator.checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path);
7795 }
7796 /**
7797 *
7798 * @param {string} option | the option property
7799 * @param {object} options | The supplied options object
7800 * @param {object} referenceOptions | The reference options containing all options and their allowed formats
7801 * @param {string} referenceOption | Usually this is the same as option, except when handling an __any__ tag.
7802 * @param {string} refOptionObj | This is the type object from the reference options
7803 * @param {Array} path | where in the object is the option
7804 * @static
7805 */
7806
7807 }, {
7808 key: "checkFields",
7809 value: function checkFields(option, options, referenceOptions, referenceOption, refOptionObj, path) {
7810 var log = function log(message) {
7811 console.error("%c" + message + Validator.printLocation(path, option), VALIDATOR_PRINT_STYLE);
7812 };
7813
7814 var optionType = Validator.getType(options[option]);
7815 var refOptionType = refOptionObj[optionType];
7816
7817 if (refOptionType !== undefined) {
7818 // if the type is correct, we check if it is supposed to be one of a few select values
7819 if (Validator.getType(refOptionType) === "array" && indexOf(refOptionType).call(refOptionType, options[option]) === -1) {
7820 log('Invalid option detected in "' + option + '".' + " Allowed values are:" + Validator.print(refOptionType) + ' not "' + options[option] + '". ');
7821 errorFound = true;
7822 } else if (optionType === "object" && referenceOption !== "__any__") {
7823 path = copyAndExtendArray(path, option);
7824 Validator.parse(options[option], referenceOptions[referenceOption], path);
7825 }
7826 } else if (refOptionObj["any"] === undefined) {
7827 // type of the field is incorrect and the field cannot be any
7828 log('Invalid type received for "' + option + '". Expected: ' + Validator.print(keys$4(refOptionObj)) + ". Received [" + optionType + '] "' + options[option] + '"');
7829 errorFound = true;
7830 }
7831 }
7832 /**
7833 *
7834 * @param {object | boolean | number | string | Array.<number> | Date | Node | Moment | undefined | null} object
7835 * @returns {string}
7836 * @static
7837 */
7838
7839 }, {
7840 key: "getType",
7841 value: function getType(object) {
7842 var type = _typeof(object);
7843
7844 if (type === "object") {
7845 if (object === null) {
7846 return "null";
7847 }
7848
7849 if (object instanceof Boolean) {
7850 return "boolean";
7851 }
7852
7853 if (object instanceof Number) {
7854 return "number";
7855 }
7856
7857 if (object instanceof String) {
7858 return "string";
7859 }
7860
7861 if (isArray$5(object)) {
7862 return "array";
7863 }
7864
7865 if (object instanceof Date) {
7866 return "date";
7867 }
7868
7869 if (object.nodeType !== undefined) {
7870 return "dom";
7871 }
7872
7873 if (object._isAMomentObject === true) {
7874 return "moment";
7875 }
7876
7877 return "object";
7878 } else if (type === "number") {
7879 return "number";
7880 } else if (type === "boolean") {
7881 return "boolean";
7882 } else if (type === "string") {
7883 return "string";
7884 } else if (type === undefined) {
7885 return "undefined";
7886 }
7887
7888 return type;
7889 }
7890 /**
7891 * @param {string} option
7892 * @param {object} options
7893 * @param {Array.<string>} path
7894 * @static
7895 */
7896
7897 }, {
7898 key: "getSuggestion",
7899 value: function getSuggestion(option, options, path) {
7900 var localSearch = Validator.findInOptions(option, options, path, false);
7901 var globalSearch = Validator.findInOptions(option, allOptions$1, [], true);
7902 var localSearchThreshold = 8;
7903 var globalSearchThreshold = 4;
7904 var msg;
7905
7906 if (localSearch.indexMatch !== undefined) {
7907 msg = " in " + Validator.printLocation(localSearch.path, option, "") + 'Perhaps it was incomplete? Did you mean: "' + localSearch.indexMatch + '"?\n\n';
7908 } else if (globalSearch.distance <= globalSearchThreshold && localSearch.distance > globalSearch.distance) {
7909 msg = " in " + Validator.printLocation(localSearch.path, option, "") + "Perhaps it was misplaced? Matching option found at: " + Validator.printLocation(globalSearch.path, globalSearch.closestMatch, "");
7910 } else if (localSearch.distance <= localSearchThreshold) {
7911 msg = '. Did you mean "' + localSearch.closestMatch + '"?' + Validator.printLocation(localSearch.path, option);
7912 } else {
7913 msg = ". Did you mean one of these: " + Validator.print(keys$4(options)) + Validator.printLocation(path, option);
7914 }
7915
7916 console.error('%cUnknown option detected: "' + option + '"' + msg, VALIDATOR_PRINT_STYLE);
7917 errorFound = true;
7918 }
7919 /**
7920 * traverse the options in search for a match.
7921 *
7922 * @param {string} option
7923 * @param {object} options
7924 * @param {Array} path | where to look for the actual option
7925 * @param {boolean} [recursive=false]
7926 * @returns {{closestMatch: string, path: Array, distance: number}}
7927 * @static
7928 */
7929
7930 }, {
7931 key: "findInOptions",
7932 value: function findInOptions(option, options, path) {
7933 var recursive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
7934 var min = 1e9;
7935 var closestMatch = "";
7936 var closestMatchPath = [];
7937 var lowerCaseOption = option.toLowerCase();
7938 var indexMatch = undefined;
7939
7940 for (var op in options) {
7941 var distance = void 0;
7942
7943 if (options[op].__type__ !== undefined && recursive === true) {
7944 var result = Validator.findInOptions(option, options[op], copyAndExtendArray(path, op));
7945
7946 if (min > result.distance) {
7947 closestMatch = result.closestMatch;
7948 closestMatchPath = result.path;
7949 min = result.distance;
7950 indexMatch = result.indexMatch;
7951 }
7952 } else {
7953 var _context20;
7954
7955 if (indexOf(_context20 = op.toLowerCase()).call(_context20, lowerCaseOption) !== -1) {
7956 indexMatch = op;
7957 }
7958
7959 distance = Validator.levenshteinDistance(option, op);
7960
7961 if (min > distance) {
7962 closestMatch = op;
7963 closestMatchPath = copyArray(path);
7964 min = distance;
7965 }
7966 }
7967 }
7968
7969 return {
7970 closestMatch: closestMatch,
7971 path: closestMatchPath,
7972 distance: min,
7973 indexMatch: indexMatch
7974 };
7975 }
7976 /**
7977 * @param {Array.<string>} path
7978 * @param {object} option
7979 * @param {string} prefix
7980 * @returns {string}
7981 * @static
7982 */
7983
7984 }, {
7985 key: "printLocation",
7986 value: function printLocation(path, option) {
7987 var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "Problem value found at: \n";
7988 var str = "\n\n" + prefix + "options = {\n";
7989
7990 for (var i = 0; i < path.length; i++) {
7991 for (var j = 0; j < i + 1; j++) {
7992 str += " ";
7993 }
7994
7995 str += path[i] + ": {\n";
7996 }
7997
7998 for (var _j = 0; _j < path.length + 1; _j++) {
7999 str += " ";
8000 }
8001
8002 str += option + "\n";
8003
8004 for (var _i3 = 0; _i3 < path.length + 1; _i3++) {
8005 for (var _j2 = 0; _j2 < path.length - _i3; _j2++) {
8006 str += " ";
8007 }
8008
8009 str += "}\n";
8010 }
8011
8012 return str + "\n\n";
8013 }
8014 /**
8015 * @param {object} options
8016 * @returns {string}
8017 * @static
8018 */
8019
8020 }, {
8021 key: "print",
8022 value: function print(options) {
8023 return stringify$1(options).replace(/(")|(\[)|(\])|(,"__type__")/g, "").replace(/(,)/g, ", ");
8024 }
8025 /**
8026 * Compute the edit distance between the two given strings
8027 * http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#JavaScript
8028 *
8029 * Copyright (c) 2011 Andrei Mackenzie
8030 *
8031 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8032 *
8033 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8034 *
8035 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8036 *
8037 * @param {string} a
8038 * @param {string} b
8039 * @returns {Array.<Array.<number>>}}
8040 * @static
8041 */
8042
8043 }, {
8044 key: "levenshteinDistance",
8045 value: function levenshteinDistance(a, b) {
8046 if (a.length === 0) return b.length;
8047 if (b.length === 0) return a.length;
8048 var matrix = []; // increment along the first column of each row
8049
8050 var i;
8051
8052 for (i = 0; i <= b.length; i++) {
8053 matrix[i] = [i];
8054 } // increment each column in the first row
8055
8056
8057 var j;
8058
8059 for (j = 0; j <= a.length; j++) {
8060 matrix[0][j] = j;
8061 } // Fill in the rest of the matrix
8062
8063
8064 for (i = 1; i <= b.length; i++) {
8065 for (j = 1; j <= a.length; j++) {
8066 if (b.charAt(i - 1) == a.charAt(j - 1)) {
8067 matrix[i][j] = matrix[i - 1][j - 1];
8068 } else {
8069 matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, // substitution
8070 Math.min(matrix[i][j - 1] + 1, // insertion
8071 matrix[i - 1][j] + 1)); // deletion
8072 }
8073 }
8074 }
8075
8076 return matrix[b.length][a.length];
8077 }
8078 }]);
8079
8080 return Validator;
8081}();
8082var VALIDATOR_PRINT_STYLE$1 = VALIDATOR_PRINT_STYLE;
8083var Validator$1 = Validator;
8084
8085/**
8086 * @prototype Point3d
8087 * @param {number} [x]
8088 * @param {number} [y]
8089 * @param {number} [z]
8090 */
8091
8092function Point3d(x, y, z) {
8093 this.x = x !== undefined ? x : 0;
8094 this.y = y !== undefined ? y : 0;
8095 this.z = z !== undefined ? z : 0;
8096}
8097/**
8098 * Subtract the two provided points, returns a-b
8099 * @param {Point3d} a
8100 * @param {Point3d} b
8101 * @return {Point3d} a-b
8102 */
8103
8104
8105Point3d.subtract = function (a, b) {
8106 var sub = new Point3d();
8107 sub.x = a.x - b.x;
8108 sub.y = a.y - b.y;
8109 sub.z = a.z - b.z;
8110 return sub;
8111};
8112/**
8113 * Add the two provided points, returns a+b
8114 * @param {Point3d} a
8115 * @param {Point3d} b
8116 * @return {Point3d} a+b
8117 */
8118
8119
8120Point3d.add = function (a, b) {
8121 var sum = new Point3d();
8122 sum.x = a.x + b.x;
8123 sum.y = a.y + b.y;
8124 sum.z = a.z + b.z;
8125 return sum;
8126};
8127/**
8128 * Calculate the average of two 3d points
8129 * @param {Point3d} a
8130 * @param {Point3d} b
8131 * @return {Point3d} The average, (a+b)/2
8132 */
8133
8134
8135Point3d.avg = function (a, b) {
8136 return new Point3d((a.x + b.x) / 2, (a.y + b.y) / 2, (a.z + b.z) / 2);
8137};
8138/**
8139 * Scale the provided point by a scalar, returns p*c
8140 * @param {Point3d} p
8141 * @param {number} c
8142 * @return {Point3d} p*c
8143 */
8144
8145
8146Point3d.scalarProduct = function (p, c) {
8147 return new Point3d(p.x * c, p.y * c, p.z * c);
8148};
8149/**
8150 * Calculate the dot product of the two provided points, returns a.b
8151 * Documentation: http://en.wikipedia.org/wiki/Dot_product
8152 * @param {Point3d} a
8153 * @param {Point3d} b
8154 * @return {Point3d} dot product a.b
8155 */
8156
8157
8158Point3d.dotProduct = function (a, b) {
8159 return a.x * b.x + a.y * b.y + a.z * b.z;
8160};
8161/**
8162 * Calculate the cross product of the two provided points, returns axb
8163 * Documentation: http://en.wikipedia.org/wiki/Cross_product
8164 * @param {Point3d} a
8165 * @param {Point3d} b
8166 * @return {Point3d} cross product axb
8167 */
8168
8169
8170Point3d.crossProduct = function (a, b) {
8171 var crossproduct = new Point3d();
8172 crossproduct.x = a.y * b.z - a.z * b.y;
8173 crossproduct.y = a.z * b.x - a.x * b.z;
8174 crossproduct.z = a.x * b.y - a.y * b.x;
8175 return crossproduct;
8176};
8177/**
8178 * Retrieve the length of the vector (or the distance from this point to the origin
8179 * @return {number} length
8180 */
8181
8182
8183Point3d.prototype.length = function () {
8184 return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
8185};
8186/**
8187 * Return a normalized vector pointing in the same direction.
8188 * @return {Point3d} normalized
8189 */
8190
8191
8192Point3d.prototype.normalize = function () {
8193 return Point3d.scalarProduct(this, 1 / this.length());
8194};
8195
8196var Point3d_1 = Point3d;
8197
8198/**
8199 * @prototype Point2d
8200 * @param {number} [x]
8201 * @param {number} [y]
8202 */
8203
8204function Point2d(x, y) {
8205 this.x = x !== undefined ? x : 0;
8206 this.y = y !== undefined ? y : 0;
8207}
8208
8209var Point2d_1 = Point2d;
8210
8211/**
8212 * An html slider control with start/stop/prev/next buttons
8213 *
8214 * @constructor Slider
8215 * @param {Element} container The element where the slider will be created
8216 * @param {Object} options Available options:
8217 * {boolean} visible If true (default) the
8218 * slider is visible.
8219 */
8220
8221function Slider(container, options) {
8222 if (container === undefined) {
8223 throw new Error('No container element defined');
8224 }
8225
8226 this.container = container;
8227 this.visible = options && options.visible != undefined ? options.visible : true;
8228
8229 if (this.visible) {
8230 this.frame = document.createElement('DIV'); //this.frame.style.backgroundColor = '#E5E5E5';
8231
8232 this.frame.style.width = '100%';
8233 this.frame.style.position = 'relative';
8234 this.container.appendChild(this.frame);
8235 this.frame.prev = document.createElement('INPUT');
8236 this.frame.prev.type = 'BUTTON';
8237 this.frame.prev.value = 'Prev';
8238 this.frame.appendChild(this.frame.prev);
8239 this.frame.play = document.createElement('INPUT');
8240 this.frame.play.type = 'BUTTON';
8241 this.frame.play.value = 'Play';
8242 this.frame.appendChild(this.frame.play);
8243 this.frame.next = document.createElement('INPUT');
8244 this.frame.next.type = 'BUTTON';
8245 this.frame.next.value = 'Next';
8246 this.frame.appendChild(this.frame.next);
8247 this.frame.bar = document.createElement('INPUT');
8248 this.frame.bar.type = 'BUTTON';
8249 this.frame.bar.style.position = 'absolute';
8250 this.frame.bar.style.border = '1px solid red';
8251 this.frame.bar.style.width = '100px';
8252 this.frame.bar.style.height = '6px';
8253 this.frame.bar.style.borderRadius = '2px';
8254 this.frame.bar.style.MozBorderRadius = '2px';
8255 this.frame.bar.style.border = '1px solid #7F7F7F';
8256 this.frame.bar.style.backgroundColor = '#E5E5E5';
8257 this.frame.appendChild(this.frame.bar);
8258 this.frame.slide = document.createElement('INPUT');
8259 this.frame.slide.type = 'BUTTON';
8260 this.frame.slide.style.margin = '0px';
8261 this.frame.slide.value = ' ';
8262 this.frame.slide.style.position = 'relative';
8263 this.frame.slide.style.left = '-100px';
8264 this.frame.appendChild(this.frame.slide); // create events
8265
8266 var me = this;
8267
8268 this.frame.slide.onmousedown = function (event) {
8269 me._onMouseDown(event);
8270 };
8271
8272 this.frame.prev.onclick = function (event) {
8273 me.prev(event);
8274 };
8275
8276 this.frame.play.onclick = function (event) {
8277 me.togglePlay(event);
8278 };
8279
8280 this.frame.next.onclick = function (event) {
8281 me.next(event);
8282 };
8283 }
8284
8285 this.onChangeCallback = undefined;
8286 this.values = [];
8287 this.index = undefined;
8288 this.playTimeout = undefined;
8289 this.playInterval = 1000; // milliseconds
8290
8291 this.playLoop = true;
8292}
8293/**
8294 * Select the previous index
8295 */
8296
8297
8298Slider.prototype.prev = function () {
8299 var index = this.getIndex();
8300
8301 if (index > 0) {
8302 index--;
8303 this.setIndex(index);
8304 }
8305};
8306/**
8307 * Select the next index
8308 */
8309
8310
8311Slider.prototype.next = function () {
8312 var index = this.getIndex();
8313
8314 if (index < values(this).length - 1) {
8315 index++;
8316 this.setIndex(index);
8317 }
8318};
8319/**
8320 * Select the next index
8321 */
8322
8323
8324Slider.prototype.playNext = function () {
8325 var start = new Date();
8326 var index = this.getIndex();
8327
8328 if (index < values(this).length - 1) {
8329 index++;
8330 this.setIndex(index);
8331 } else if (this.playLoop) {
8332 // jump to the start
8333 index = 0;
8334 this.setIndex(index);
8335 }
8336
8337 var end = new Date();
8338 var diff = end - start; // calculate how much time it to to set the index and to execute the callback
8339 // function.
8340
8341 var interval = Math.max(this.playInterval - diff, 0); // document.title = diff // TODO: cleanup
8342
8343 var me = this;
8344 this.playTimeout = setTimeout$1(function () {
8345 me.playNext();
8346 }, interval);
8347};
8348/**
8349 * Toggle start or stop playing
8350 */
8351
8352
8353Slider.prototype.togglePlay = function () {
8354 if (this.playTimeout === undefined) {
8355 this.play();
8356 } else {
8357 this.stop();
8358 }
8359};
8360/**
8361 * Start playing
8362 */
8363
8364
8365Slider.prototype.play = function () {
8366 // Test whether already playing
8367 if (this.playTimeout) return;
8368 this.playNext();
8369
8370 if (this.frame) {
8371 this.frame.play.value = 'Stop';
8372 }
8373};
8374/**
8375 * Stop playing
8376 */
8377
8378
8379Slider.prototype.stop = function () {
8380 clearInterval(this.playTimeout);
8381 this.playTimeout = undefined;
8382
8383 if (this.frame) {
8384 this.frame.play.value = 'Play';
8385 }
8386};
8387/**
8388 * Set a callback function which will be triggered when the value of the
8389 * slider bar has changed.
8390 *
8391 * @param {function} callback
8392 */
8393
8394
8395Slider.prototype.setOnChangeCallback = function (callback) {
8396 this.onChangeCallback = callback;
8397};
8398/**
8399 * Set the interval for playing the list
8400 * @param {number} interval The interval in milliseconds
8401 */
8402
8403
8404Slider.prototype.setPlayInterval = function (interval) {
8405 this.playInterval = interval;
8406};
8407/**
8408 * Retrieve the current play interval
8409 * @return {number} interval The interval in milliseconds
8410 */
8411
8412
8413Slider.prototype.getPlayInterval = function () {
8414 return this.playInterval;
8415};
8416/**
8417 * Set looping on or off
8418 * @param {boolean} doLoop If true, the slider will jump to the start when
8419 * the end is passed, and will jump to the end
8420 * when the start is passed.
8421 *
8422 */
8423
8424
8425Slider.prototype.setPlayLoop = function (doLoop) {
8426 this.playLoop = doLoop;
8427};
8428/**
8429 * Execute the onchange callback function
8430 */
8431
8432
8433Slider.prototype.onChange = function () {
8434 if (this.onChangeCallback !== undefined) {
8435 this.onChangeCallback();
8436 }
8437};
8438/**
8439 * redraw the slider on the correct place
8440 */
8441
8442
8443Slider.prototype.redraw = function () {
8444 if (this.frame) {
8445 // resize the bar
8446 this.frame.bar.style.top = this.frame.clientHeight / 2 - this.frame.bar.offsetHeight / 2 + 'px';
8447 this.frame.bar.style.width = this.frame.clientWidth - this.frame.prev.clientWidth - this.frame.play.clientWidth - this.frame.next.clientWidth - 30 + 'px'; // position the slider button
8448
8449 var left = this.indexToLeft(this.index);
8450 this.frame.slide.style.left = left + 'px';
8451 }
8452};
8453/**
8454 * Set the list with values for the slider
8455 * @param {Array} values A javascript array with values (any type)
8456 */
8457
8458
8459Slider.prototype.setValues = function (values$1) {
8460 this.values = values$1;
8461 if (values(this).length > 0) this.setIndex(0);else this.index = undefined;
8462};
8463/**
8464 * Select a value by its index
8465 * @param {number} index
8466 */
8467
8468
8469Slider.prototype.setIndex = function (index) {
8470 if (index < values(this).length) {
8471 this.index = index;
8472 this.redraw();
8473 this.onChange();
8474 } else {
8475 throw new Error('Index out of range');
8476 }
8477};
8478/**
8479 * retrieve the index of the currently selected vaue
8480 * @return {number} index
8481 */
8482
8483
8484Slider.prototype.getIndex = function () {
8485 return this.index;
8486};
8487/**
8488 * retrieve the currently selected value
8489 * @return {*} value
8490 */
8491
8492
8493Slider.prototype.get = function () {
8494 return values(this)[this.index];
8495};
8496
8497Slider.prototype._onMouseDown = function (event) {
8498 // only react on left mouse button down
8499 var leftButtonDown = event.which ? event.which === 1 : event.button === 1;
8500 if (!leftButtonDown) return;
8501 this.startClientX = event.clientX;
8502 this.startSlideX = _parseFloat(this.frame.slide.style.left);
8503 this.frame.style.cursor = 'move'; // add event listeners to handle moving the contents
8504 // we store the function onmousemove and onmouseup in the graph, so we can
8505 // remove the eventlisteners lateron in the function mouseUp()
8506
8507 var me = this;
8508
8509 this.onmousemove = function (event) {
8510 me._onMouseMove(event);
8511 };
8512
8513 this.onmouseup = function (event) {
8514 me._onMouseUp(event);
8515 };
8516
8517 addEventListener(document, 'mousemove', this.onmousemove);
8518 addEventListener(document, 'mouseup', this.onmouseup);
8519 preventDefault(event);
8520};
8521
8522Slider.prototype.leftToIndex = function (left) {
8523 var width = _parseFloat(this.frame.bar.style.width) - this.frame.slide.clientWidth - 10;
8524 var x = left - 3;
8525 var index = Math.round(x / width * (values(this).length - 1));
8526 if (index < 0) index = 0;
8527 if (index > values(this).length - 1) index = values(this).length - 1;
8528 return index;
8529};
8530
8531Slider.prototype.indexToLeft = function (index) {
8532 var width = _parseFloat(this.frame.bar.style.width) - this.frame.slide.clientWidth - 10;
8533 var x = index / (values(this).length - 1) * width;
8534 var left = x + 3;
8535 return left;
8536};
8537
8538Slider.prototype._onMouseMove = function (event) {
8539 var diff = event.clientX - this.startClientX;
8540 var x = this.startSlideX + diff;
8541 var index = this.leftToIndex(x);
8542 this.setIndex(index);
8543 preventDefault();
8544};
8545
8546Slider.prototype._onMouseUp = function (event) {
8547 // eslint-disable-line no-unused-vars
8548 this.frame.style.cursor = 'auto'; // remove event listeners
8549
8550 removeEventListener(document, 'mousemove', this.onmousemove);
8551 removeEventListener(document, 'mouseup', this.onmouseup);
8552 preventDefault();
8553};
8554
8555function StepNumber(start, end, step, prettyStep) {
8556 // set default values
8557 this._start = 0;
8558 this._end = 0;
8559 this._step = 1;
8560 this.prettyStep = true;
8561 this.precision = 5;
8562 this._current = 0;
8563 this.setRange(start, end, step, prettyStep);
8564}
8565/**
8566 * Check for input values, to prevent disasters from happening
8567 *
8568 * Source: http://stackoverflow.com/a/1830844
8569 *
8570 * @param {string} n
8571 * @returns {boolean}
8572 */
8573
8574
8575StepNumber.prototype.isNumeric = function (n) {
8576 return !isNaN(_parseFloat(n)) && isFinite(n);
8577};
8578/**
8579 * Set a new range: start, end and step.
8580 *
8581 * @param {number} start The start value
8582 * @param {number} end The end value
8583 * @param {number} step Optional. Step size. Must be a positive value.
8584 * @param {boolean} prettyStep Optional. If true, the step size is rounded
8585 * To a pretty step size (like 1, 2, 5, 10, 20, 50, ...)
8586 */
8587
8588
8589StepNumber.prototype.setRange = function (start, end, step, prettyStep) {
8590 if (!this.isNumeric(start)) {
8591 throw new Error('Parameter \'start\' is not numeric; value: ' + start);
8592 }
8593
8594 if (!this.isNumeric(end)) {
8595 throw new Error('Parameter \'end\' is not numeric; value: ' + start);
8596 }
8597
8598 if (!this.isNumeric(step)) {
8599 throw new Error('Parameter \'step\' is not numeric; value: ' + start);
8600 }
8601
8602 this._start = start ? start : 0;
8603 this._end = end ? end : 0;
8604 this.setStep(step, prettyStep);
8605};
8606/**
8607 * Set a new step size
8608 * @param {number} step New step size. Must be a positive value
8609 * @param {boolean} prettyStep Optional. If true, the provided step is rounded
8610 * to a pretty step size (like 1, 2, 5, 10, 20, 50, ...)
8611 */
8612
8613
8614StepNumber.prototype.setStep = function (step, prettyStep) {
8615 if (step === undefined || step <= 0) return;
8616 if (prettyStep !== undefined) this.prettyStep = prettyStep;
8617 if (this.prettyStep === true) this._step = StepNumber.calculatePrettyStep(step);else this._step = step;
8618};
8619/**
8620 * Calculate a nice step size, closest to the desired step size.
8621 * Returns a value in one of the ranges 1*10^n, 2*10^n, or 5*10^n, where n is an
8622 * integer Number. For example 1, 2, 5, 10, 20, 50, etc...
8623 * @param {number} step Desired step size
8624 * @return {number} Nice step size
8625 */
8626
8627
8628StepNumber.calculatePrettyStep = function (step) {
8629 var log10 = function log10(x) {
8630 return Math.log(x) / Math.LN10;
8631 }; // try three steps (multiple of 1, 2, or 5
8632
8633
8634 var step1 = Math.pow(10, Math.round(log10(step))),
8635 step2 = 2 * Math.pow(10, Math.round(log10(step / 2))),
8636 step5 = 5 * Math.pow(10, Math.round(log10(step / 5))); // choose the best step (closest to minimum step)
8637
8638 var prettyStep = step1;
8639 if (Math.abs(step2 - step) <= Math.abs(prettyStep - step)) prettyStep = step2;
8640 if (Math.abs(step5 - step) <= Math.abs(prettyStep - step)) prettyStep = step5; // for safety
8641
8642 if (prettyStep <= 0) {
8643 prettyStep = 1;
8644 }
8645
8646 return prettyStep;
8647};
8648/**
8649 * returns the current value of the step
8650 * @return {number} current value
8651 */
8652
8653
8654StepNumber.prototype.getCurrent = function () {
8655 return _parseFloat(this._current.toPrecision(this.precision));
8656};
8657/**
8658 * returns the current step size
8659 * @return {number} current step size
8660 */
8661
8662
8663StepNumber.prototype.getStep = function () {
8664 return this._step;
8665};
8666/**
8667 * Set the current to its starting value.
8668 *
8669 * By default, this will be the largest value smaller than start, which
8670 * is a multiple of the step size.
8671 *
8672 * Parameters checkFirst is optional, default false.
8673 * If set to true, move the current value one step if smaller than start.
8674 *
8675 * @param {boolean} [checkFirst=false]
8676 */
8677
8678
8679StepNumber.prototype.start = function (checkFirst) {
8680 if (checkFirst === undefined) {
8681 checkFirst = false;
8682 }
8683
8684 this._current = this._start - this._start % this._step;
8685
8686 if (checkFirst) {
8687 if (this.getCurrent() < this._start) {
8688 this.next();
8689 }
8690 }
8691};
8692/**
8693 * Do a step, add the step size to the current value
8694 */
8695
8696
8697StepNumber.prototype.next = function () {
8698 this._current += this._step;
8699};
8700/**
8701 * Returns true whether the end is reached
8702 * @return {boolean} True if the current value has passed the end value.
8703 */
8704
8705
8706StepNumber.prototype.end = function () {
8707 return this._current > this._end;
8708};
8709
8710var StepNumber_1 = StepNumber;
8711
8712// https://tc39.es/ecma262/#sec-math.sign
8713// eslint-disable-next-line es/no-math-sign -- safe
8714
8715var mathSign = Math.sign || function sign(x) {
8716 // eslint-disable-next-line no-self-compare -- NaN check
8717 return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
8718};
8719
8720var $$7 = _export;
8721var sign$3 = mathSign; // `Math.sign` method
8722// https://tc39.es/ecma262/#sec-math.sign
8723
8724$$7({
8725 target: 'Math',
8726 stat: true
8727}, {
8728 sign: sign$3
8729});
8730
8731var path$4 = path$s;
8732var sign$2 = path$4.Math.sign;
8733
8734var parent$e = sign$2;
8735var sign$1 = parent$e;
8736
8737var sign = sign$1;
8738
8739/**
8740 * The camera is mounted on a (virtual) camera arm. The camera arm can rotate
8741 * The camera is always looking in the direction of the origin of the arm.
8742 * This way, the camera always rotates around one fixed point, the location
8743 * of the camera arm.
8744 *
8745 * Documentation:
8746 * http://en.wikipedia.org/wiki/3D_projection
8747 * @class Camera
8748 */
8749
8750function Camera() {
8751 this.armLocation = new Point3d_1();
8752 this.armRotation = {};
8753 this.armRotation.horizontal = 0;
8754 this.armRotation.vertical = 0;
8755 this.armLength = 1.7;
8756 this.cameraOffset = new Point3d_1();
8757 this.offsetMultiplier = 0.6;
8758 this.cameraLocation = new Point3d_1();
8759 this.cameraRotation = new Point3d_1(0.5 * Math.PI, 0, 0);
8760 this.calculateCameraOrientation();
8761}
8762/**
8763 * Set offset camera in camera coordinates
8764 * @param {number} x offset by camera horisontal
8765 * @param {number} y offset by camera vertical
8766 */
8767
8768
8769Camera.prototype.setOffset = function (x, y) {
8770 var abs = Math.abs,
8771 sign$1 = sign,
8772 mul = this.offsetMultiplier,
8773 border = this.armLength * mul;
8774
8775 if (abs(x) > border) {
8776 x = sign$1(x) * border;
8777 }
8778
8779 if (abs(y) > border) {
8780 y = sign$1(y) * border;
8781 }
8782
8783 this.cameraOffset.x = x;
8784 this.cameraOffset.y = y;
8785 this.calculateCameraOrientation();
8786};
8787/**
8788 * Get camera offset by horizontal and vertical
8789 * @returns {number}
8790 */
8791
8792
8793Camera.prototype.getOffset = function () {
8794 return this.cameraOffset;
8795};
8796/**
8797 * Set the location (origin) of the arm
8798 * @param {number} x Normalized value of x
8799 * @param {number} y Normalized value of y
8800 * @param {number} z Normalized value of z
8801 */
8802
8803
8804Camera.prototype.setArmLocation = function (x, y, z) {
8805 this.armLocation.x = x;
8806 this.armLocation.y = y;
8807 this.armLocation.z = z;
8808 this.calculateCameraOrientation();
8809};
8810/**
8811 * Set the rotation of the camera arm
8812 * @param {number} horizontal The horizontal rotation, between 0 and 2*PI.
8813 * Optional, can be left undefined.
8814 * @param {number} vertical The vertical rotation, between 0 and 0.5*PI
8815 * if vertical=0.5*PI, the graph is shown from the
8816 * top. Optional, can be left undefined.
8817 */
8818
8819
8820Camera.prototype.setArmRotation = function (horizontal, vertical) {
8821 if (horizontal !== undefined) {
8822 this.armRotation.horizontal = horizontal;
8823 }
8824
8825 if (vertical !== undefined) {
8826 this.armRotation.vertical = vertical;
8827 if (this.armRotation.vertical < 0) this.armRotation.vertical = 0;
8828 if (this.armRotation.vertical > 0.5 * Math.PI) this.armRotation.vertical = 0.5 * Math.PI;
8829 }
8830
8831 if (horizontal !== undefined || vertical !== undefined) {
8832 this.calculateCameraOrientation();
8833 }
8834};
8835/**
8836 * Retrieve the current arm rotation
8837 * @return {object} An object with parameters horizontal and vertical
8838 */
8839
8840
8841Camera.prototype.getArmRotation = function () {
8842 var rot = {};
8843 rot.horizontal = this.armRotation.horizontal;
8844 rot.vertical = this.armRotation.vertical;
8845 return rot;
8846};
8847/**
8848 * Set the (normalized) length of the camera arm.
8849 * @param {number} length A length between 0.71 and 5.0
8850 */
8851
8852
8853Camera.prototype.setArmLength = function (length) {
8854 if (length === undefined) return;
8855 this.armLength = length; // Radius must be larger than the corner of the graph,
8856 // which has a distance of sqrt(0.5^2+0.5^2) = 0.71 from the center of the
8857 // graph
8858
8859 if (this.armLength < 0.71) this.armLength = 0.71;
8860 if (this.armLength > 5.0) this.armLength = 5.0;
8861 this.setOffset(this.cameraOffset.x, this.cameraOffset.y);
8862 this.calculateCameraOrientation();
8863};
8864/**
8865 * Retrieve the arm length
8866 * @return {number} length
8867 */
8868
8869
8870Camera.prototype.getArmLength = function () {
8871 return this.armLength;
8872};
8873/**
8874 * Retrieve the camera location
8875 * @return {Point3d} cameraLocation
8876 */
8877
8878
8879Camera.prototype.getCameraLocation = function () {
8880 return this.cameraLocation;
8881};
8882/**
8883 * Retrieve the camera rotation
8884 * @return {Point3d} cameraRotation
8885 */
8886
8887
8888Camera.prototype.getCameraRotation = function () {
8889 return this.cameraRotation;
8890};
8891/**
8892 * Calculate the location and rotation of the camera based on the
8893 * position and orientation of the camera arm
8894 */
8895
8896
8897Camera.prototype.calculateCameraOrientation = function () {
8898 // calculate location of the camera
8899 this.cameraLocation.x = this.armLocation.x - this.armLength * Math.sin(this.armRotation.horizontal) * Math.cos(this.armRotation.vertical);
8900 this.cameraLocation.y = this.armLocation.y - this.armLength * Math.cos(this.armRotation.horizontal) * Math.cos(this.armRotation.vertical);
8901 this.cameraLocation.z = this.armLocation.z + this.armLength * Math.sin(this.armRotation.vertical); // calculate rotation of the camera
8902
8903 this.cameraRotation.x = Math.PI / 2 - this.armRotation.vertical;
8904 this.cameraRotation.y = 0;
8905 this.cameraRotation.z = -this.armRotation.horizontal;
8906 var xa = this.cameraRotation.x;
8907 var za = this.cameraRotation.z;
8908 var dx = this.cameraOffset.x;
8909 var dy = this.cameraOffset.y;
8910 var sin = Math.sin,
8911 cos = Math.cos;
8912 this.cameraLocation.x = this.cameraLocation.x + dx * cos(za) + dy * -sin(za) * cos(xa);
8913 this.cameraLocation.y = this.cameraLocation.y + dx * sin(za) + dy * cos(za) * cos(xa);
8914 this.cameraLocation.z = this.cameraLocation.z + dy * sin(xa);
8915};
8916
8917var STYLE = {
8918 BAR: 0,
8919 BARCOLOR: 1,
8920 BARSIZE: 2,
8921 DOT: 3,
8922 DOTLINE: 4,
8923 DOTCOLOR: 5,
8924 DOTSIZE: 6,
8925 GRID: 7,
8926 LINE: 8,
8927 SURFACE: 9
8928}; // The string representations of the styles
8929
8930var STYLENAME = {
8931 'dot': STYLE.DOT,
8932 'dot-line': STYLE.DOTLINE,
8933 'dot-color': STYLE.DOTCOLOR,
8934 'dot-size': STYLE.DOTSIZE,
8935 'line': STYLE.LINE,
8936 'grid': STYLE.GRID,
8937 'surface': STYLE.SURFACE,
8938 'bar': STYLE.BAR,
8939 'bar-color': STYLE.BARCOLOR,
8940 'bar-size': STYLE.BARSIZE
8941};
8942/**
8943 * Field names in the options hash which are of relevance to the user.
8944 *
8945 * Specifically, these are the fields which require no special handling,
8946 * and can be directly copied over.
8947 */
8948
8949var OPTIONKEYS = ['width', 'height', 'filterLabel', 'legendLabel', 'xLabel', 'yLabel', 'zLabel', 'xValueLabel', 'yValueLabel', 'zValueLabel', 'showXAxis', 'showYAxis', 'showZAxis', 'showGrayBottom', 'showGrid', 'showPerspective', 'showShadow', 'showSurfaceGrid', 'keepAspectRatio', 'rotateAxisLabels', 'verticalRatio', 'dotSizeRatio', 'dotSizeMinFraction', 'dotSizeMaxFraction', 'showAnimationControls', 'animationInterval', 'animationPreload', 'animationAutoStart', 'axisColor', 'axisFontSize', 'axisFontType', 'gridColor', 'xCenter', 'yCenter', 'zoomable', 'tooltipDelay', 'ctrlToZoom'];
8950/**
8951 * Field names in the options hash which are of relevance to the user.
8952 *
8953 * Same as OPTIONKEYS, but internally these fields are stored with
8954 * prefix 'default' in the name.
8955 */
8956
8957var PREFIXEDOPTIONKEYS = ['xBarWidth', 'yBarWidth', 'valueMin', 'valueMax', 'xMin', 'xMax', 'xStep', 'yMin', 'yMax', 'yStep', 'zMin', 'zMax', 'zStep']; // Placeholder for DEFAULTS reference
8958
8959var DEFAULTS = undefined;
8960/**
8961 * Check if given hash is empty.
8962 *
8963 * Source: http://stackoverflow.com/a/679937
8964 *
8965 * @param {object} obj
8966 * @returns {boolean}
8967 */
8968
8969function isEmpty(obj) {
8970 for (var prop in obj) {
8971 if (obj.hasOwnProperty(prop)) return false;
8972 }
8973
8974 return true;
8975}
8976/**
8977 * Make first letter of parameter upper case.
8978 *
8979 * Source: http://stackoverflow.com/a/1026087
8980 *
8981 * @param {string} str
8982 * @returns {string}
8983 */
8984
8985
8986function capitalize(str) {
8987 if (str === undefined || str === "" || typeof str != "string") {
8988 return str;
8989 }
8990
8991 return str.charAt(0).toUpperCase() + slice$1(str).call(str, 1);
8992}
8993/**
8994 * Add a prefix to a field name, taking style guide into account
8995 *
8996 * @param {string} prefix
8997 * @param {string} fieldName
8998 * @returns {string}
8999 */
9000
9001
9002function prefixFieldName(prefix, fieldName) {
9003 if (prefix === undefined || prefix === "") {
9004 return fieldName;
9005 }
9006
9007 return prefix + capitalize(fieldName);
9008}
9009/**
9010 * Forcibly copy fields from src to dst in a controlled manner.
9011 *
9012 * A given field in dst will always be overwitten. If this field
9013 * is undefined or not present in src, the field in dst will
9014 * be explicitly set to undefined.
9015 *
9016 * The intention here is to be able to reset all option fields.
9017 *
9018 * Only the fields mentioned in array 'fields' will be handled.
9019 *
9020 * @param {object} src
9021 * @param {object} dst
9022 * @param {array<string>} fields array with names of fields to copy
9023 * @param {string} [prefix] prefix to use for the target fields.
9024 */
9025
9026
9027function forceCopy(src, dst, fields, prefix) {
9028 var srcKey;
9029 var dstKey;
9030
9031 for (var i = 0; i < fields.length; ++i) {
9032 srcKey = fields[i];
9033 dstKey = prefixFieldName(prefix, srcKey);
9034 dst[dstKey] = src[srcKey];
9035 }
9036}
9037/**
9038 * Copy fields from src to dst in a safe and controlled manner.
9039 *
9040 * Only the fields mentioned in array 'fields' will be copied over,
9041 * and only if these are actually defined.
9042 *
9043 * @param {object} src
9044 * @param {object} dst
9045 * @param {array<string>} fields array with names of fields to copy
9046 * @param {string} [prefix] prefix to use for the target fields.
9047 */
9048
9049
9050function safeCopy(src, dst, fields, prefix) {
9051 var srcKey;
9052 var dstKey;
9053
9054 for (var i = 0; i < fields.length; ++i) {
9055 srcKey = fields[i];
9056 if (src[srcKey] === undefined) continue;
9057 dstKey = prefixFieldName(prefix, srcKey);
9058 dst[dstKey] = src[srcKey];
9059 }
9060}
9061/**
9062 * Initialize dst with the values in src.
9063 *
9064 * src is the hash with the default values.
9065 * A reference DEFAULTS to this hash is stored locally for
9066 * further handling.
9067 *
9068 * For now, dst is assumed to be a Graph3d instance.
9069 * @param {object} src
9070 * @param {object} dst
9071 */
9072
9073
9074function setDefaults(src, dst) {
9075 if (src === undefined || isEmpty(src)) {
9076 throw new Error('No DEFAULTS passed');
9077 }
9078
9079 if (dst === undefined) {
9080 throw new Error('No dst passed');
9081 } // Remember defaults for future reference
9082
9083
9084 DEFAULTS = src; // Handle the defaults which can be simply copied over
9085
9086 forceCopy(src, dst, OPTIONKEYS);
9087 forceCopy(src, dst, PREFIXEDOPTIONKEYS, 'default'); // Handle the more complex ('special') fields
9088
9089 setSpecialSettings(src, dst); // Following are internal fields, not part of the user settings
9090
9091 dst.margin = 10; // px
9092
9093 dst.showTooltip = false;
9094 dst.onclick_callback = null;
9095 dst.eye = new Point3d_1(0, 0, -1); // TODO: set eye.z about 3/4 of the width of the window?
9096}
9097/**
9098 *
9099 * @param {object} options
9100 * @param {object} dst
9101 */
9102
9103
9104function setOptions(options, dst) {
9105 if (options === undefined) {
9106 return;
9107 }
9108
9109 if (dst === undefined) {
9110 throw new Error('No dst passed');
9111 }
9112
9113 if (DEFAULTS === undefined || isEmpty(DEFAULTS)) {
9114 throw new Error('DEFAULTS not set for module Settings');
9115 } // Handle the parameters which can be simply copied over
9116
9117
9118 safeCopy(options, dst, OPTIONKEYS);
9119 safeCopy(options, dst, PREFIXEDOPTIONKEYS, 'default'); // Handle the more complex ('special') fields
9120
9121 setSpecialSettings(options, dst);
9122}
9123/**
9124 * Special handling for certain parameters
9125 *
9126 * 'Special' here means: setting requires more than a simple copy
9127 *
9128 * @param {object} src
9129 * @param {object} dst
9130 */
9131
9132
9133function setSpecialSettings(src, dst) {
9134 if (src.backgroundColor !== undefined) {
9135 setBackgroundColor(src.backgroundColor, dst);
9136 }
9137
9138 setDataColor(src.dataColor, dst);
9139 setStyle(src.style, dst);
9140
9141 if (src.surfaceColors !== undefined) {
9142 console.warn('`options.surfaceColors` is deprecated and may be removed in a future ' + 'version. Please use `options.colormap` instead. Note that the `colormap` ' + 'option uses the inverse array ordering (running from vMin to vMax).');
9143
9144 if (src.colormap !== undefined) {
9145 throw new Error('The `colormap` and `surfaceColors` options are mutually exclusive.');
9146 }
9147
9148 if (dst.style !== 'surface') {
9149 console.warn('Ignoring `surfaceColors` in graph style `' + dst.style + '` for ' + 'backward compatibility (only effective in `surface` plots).');
9150 } else {
9151 setSurfaceColor(src.surfaceColors, dst);
9152 }
9153 } else {
9154 setColormap(src.colormap, dst);
9155 }
9156
9157 setShowLegend(src.showLegend, dst);
9158 setCameraPosition(src.cameraPosition, dst); // As special fields go, this is an easy one; just a translation of the name.
9159 // Can't use this.tooltip directly, because that field exists internally
9160
9161 if (src.tooltip !== undefined) {
9162 dst.showTooltip = src.tooltip;
9163 }
9164
9165 if (src.onclick != undefined) {
9166 dst.onclick_callback = src.onclick;
9167 console.warn("`options.onclick` is deprecated and may be removed in a future version." + " Please use `Graph3d.on('click', handler)` instead.");
9168 }
9169
9170 if (src.tooltipStyle !== undefined) {
9171 selectiveDeepExtend(['tooltipStyle'], dst, src);
9172 }
9173}
9174/**
9175 * Set the value of setting 'showLegend'
9176 *
9177 * This depends on the value of the style fields, so it must be called
9178 * after the style field has been initialized.
9179 *
9180 * @param {boolean} showLegend
9181 * @param {object} dst
9182 */
9183
9184
9185function setShowLegend(showLegend, dst) {
9186 if (showLegend === undefined) {
9187 // If the default was auto, make a choice for this field
9188 var isAutoByDefault = DEFAULTS.showLegend === undefined;
9189
9190 if (isAutoByDefault) {
9191 // these styles default to having legends
9192 var isLegendGraphStyle = dst.style === STYLE.DOTCOLOR || dst.style === STYLE.DOTSIZE;
9193 dst.showLegend = isLegendGraphStyle;
9194 }
9195 } else {
9196 dst.showLegend = showLegend;
9197 }
9198}
9199/**
9200 * Retrieve the style index from given styleName
9201 * @param {string} styleName Style name such as 'dot', 'grid', 'dot-line'
9202 * @return {number} styleNumber Enumeration value representing the style, or -1
9203 * when not found
9204 */
9205
9206
9207function getStyleNumberByName(styleName) {
9208 var number = STYLENAME[styleName];
9209
9210 if (number === undefined) {
9211 return -1;
9212 }
9213
9214 return number;
9215}
9216/**
9217 * Check if given number is a valid style number.
9218 *
9219 * @param {string | number} style
9220 * @return {boolean} true if valid, false otherwise
9221 */
9222
9223
9224function checkStyleNumber(style) {
9225 var valid = false;
9226
9227 for (var n in STYLE) {
9228 if (STYLE[n] === style) {
9229 valid = true;
9230 break;
9231 }
9232 }
9233
9234 return valid;
9235}
9236/**
9237 *
9238 * @param {string | number} style
9239 * @param {Object} dst
9240 */
9241
9242
9243function setStyle(style, dst) {
9244 if (style === undefined) {
9245 return; // Nothing to do
9246 }
9247
9248 var styleNumber;
9249
9250 if (typeof style === 'string') {
9251 styleNumber = getStyleNumberByName(style);
9252
9253 if (styleNumber === -1) {
9254 throw new Error('Style \'' + style + '\' is invalid');
9255 }
9256 } else {
9257 // Do a pedantic check on style number value
9258 if (!checkStyleNumber(style)) {
9259 throw new Error('Style \'' + style + '\' is invalid');
9260 }
9261
9262 styleNumber = style;
9263 }
9264
9265 dst.style = styleNumber;
9266}
9267/**
9268 * Set the background styling for the graph
9269 * @param {string | {fill: string, stroke: string, strokeWidth: string}} backgroundColor
9270 * @param {Object} dst
9271 */
9272
9273
9274function setBackgroundColor(backgroundColor, dst) {
9275 var fill$1 = 'white';
9276 var stroke = 'gray';
9277 var strokeWidth = 1;
9278
9279 if (typeof backgroundColor === 'string') {
9280 fill$1 = backgroundColor;
9281 stroke = 'none';
9282 strokeWidth = 0;
9283 } else if (_typeof(backgroundColor) === 'object') {
9284 if (fill(backgroundColor) !== undefined) fill$1 = fill(backgroundColor);
9285 if (backgroundColor.stroke !== undefined) stroke = backgroundColor.stroke;
9286 if (backgroundColor.strokeWidth !== undefined) strokeWidth = backgroundColor.strokeWidth;
9287 } else {
9288 throw new Error('Unsupported type of backgroundColor');
9289 }
9290
9291 dst.frame.style.backgroundColor = fill$1;
9292 dst.frame.style.borderColor = stroke;
9293 dst.frame.style.borderWidth = strokeWidth + 'px';
9294 dst.frame.style.borderStyle = 'solid';
9295}
9296/**
9297 *
9298 * @param {string | Object} dataColor
9299 * @param {Object} dst
9300 */
9301
9302
9303function setDataColor(dataColor, dst) {
9304 if (dataColor === undefined) {
9305 return; // Nothing to do
9306 }
9307
9308 if (dst.dataColor === undefined) {
9309 dst.dataColor = {};
9310 }
9311
9312 if (typeof dataColor === 'string') {
9313 dst.dataColor.fill = dataColor;
9314 dst.dataColor.stroke = dataColor;
9315 } else {
9316 if (fill(dataColor)) {
9317 dst.dataColor.fill = fill(dataColor);
9318 }
9319
9320 if (dataColor.stroke) {
9321 dst.dataColor.stroke = dataColor.stroke;
9322 }
9323
9324 if (dataColor.strokeWidth !== undefined) {
9325 dst.dataColor.strokeWidth = dataColor.strokeWidth;
9326 }
9327 }
9328}
9329/**
9330 *
9331 * @param {Object | Array<string>} surfaceColors Either an object that describes the HUE, or an array of HTML hex color codes
9332 * @param {Object} dst
9333 */
9334
9335
9336function setSurfaceColor(surfaceColors, dst) {
9337 if (surfaceColors === undefined || surfaceColors === true) {
9338 return; // Nothing to do
9339 }
9340
9341 if (surfaceColors === false) {
9342 dst.surfaceColors = undefined;
9343 return;
9344 }
9345
9346 if (dst.surfaceColors === undefined) {
9347 dst.surfaceColors = {};
9348 }
9349
9350 var rgbColors;
9351
9352 if (isArray$5(surfaceColors)) {
9353 rgbColors = parseColorArray(surfaceColors);
9354 } else if (_typeof(surfaceColors) === 'object') {
9355 rgbColors = parseColorObject(surfaceColors.hue);
9356 } else {
9357 throw new Error('Unsupported type of surfaceColors');
9358 } // for some reason surfaceColors goes from vMax to vMin:
9359
9360
9361 reverse(rgbColors).call(rgbColors);
9362
9363 dst.colormap = rgbColors;
9364}
9365/**
9366 *
9367 * @param {Object | Array<string>} colormap Either an object that describes the HUE, or an array of HTML hex color codes
9368 * @param {Object} dst
9369 */
9370
9371
9372function setColormap(colormap, dst) {
9373 if (colormap === undefined) {
9374 return;
9375 }
9376
9377 var rgbColors;
9378
9379 if (isArray$5(colormap)) {
9380 rgbColors = parseColorArray(colormap);
9381 } else if (_typeof(colormap) === 'object') {
9382 rgbColors = parseColorObject(colormap.hue);
9383 } else if (typeof colormap === 'function') {
9384 rgbColors = colormap;
9385 } else {
9386 throw new Error('Unsupported type of colormap');
9387 }
9388
9389 dst.colormap = rgbColors;
9390}
9391/**
9392 *
9393 * @param {Array} colormap
9394 */
9395
9396
9397function parseColorArray(colormap) {
9398 if (colormap.length < 2) {
9399 throw new Error('Colormap array length must be 2 or above.');
9400 }
9401
9402 return map$3(colormap).call(colormap, function (colorCode) {
9403 if (!isValidHex(colorCode)) {
9404 throw new Error("Invalid hex color code supplied to colormap.");
9405 }
9406
9407 return hexToRGB(colorCode);
9408 });
9409}
9410/**
9411 * Converts an object to a certain amount of hex color stops. At which point:
9412 * the HTML hex color codes is converted into an RGB color object.
9413 *
9414 * @param {Object} hues
9415 */
9416
9417
9418function parseColorObject(hues) {
9419 if (hues === undefined) {
9420 throw new Error('Unsupported type of colormap');
9421 }
9422
9423 if (!(hues.saturation >= 0 && hues.saturation <= 100)) {
9424 throw new Error('Saturation is out of bounds. Expected range is 0-100.');
9425 }
9426
9427 if (!(hues.brightness >= 0 && hues.brightness <= 100)) {
9428 throw new Error('Brightness is out of bounds. Expected range is 0-100.');
9429 }
9430
9431 if (!(hues.colorStops >= 2)) {
9432 throw new Error('colorStops is out of bounds. Expected 2 or above.');
9433 }
9434
9435 var hueStep = (hues.end - hues.start) / (hues.colorStops - 1);
9436 var rgbColors = [];
9437
9438 for (var i = 0; i < hues.colorStops; ++i) {
9439 var hue = (hues.start + hueStep * i) % 360 / 360;
9440 rgbColors.push(HSVToRGB(hue < 0 ? hue + 1 : hue, hues.saturation / 100, hues.brightness / 100));
9441 }
9442
9443 return rgbColors;
9444}
9445/**
9446 *
9447 * @param {Object} cameraPosition
9448 * @param {Object} dst
9449 */
9450
9451
9452function setCameraPosition(cameraPosition, dst) {
9453 var camPos = cameraPosition;
9454
9455 if (camPos === undefined) {
9456 return;
9457 }
9458
9459 if (dst.camera === undefined) {
9460 dst.camera = new Camera();
9461 }
9462
9463 dst.camera.setArmRotation(camPos.horizontal, camPos.vertical);
9464 dst.camera.setArmLength(camPos.distance);
9465}
9466
9467/**
9468 * This object contains all possible options. It will check if the types are correct, if required if the option is one
9469 * of the allowed values.
9470 *
9471 * __any__ means that the name of the property does not matter.
9472 * __type__ is a required field for all objects and contains the allowed types of all objects
9473 */
9474var string = 'string';
9475var bool = 'boolean';
9476var number = 'number';
9477var object = 'object'; // should only be in a __type__ property
9478
9479var array = 'array'; // Following not used here, but useful for reference
9480//let dom = 'dom';
9481//let any = 'any';
9482
9483var colorOptions = {
9484 fill: {
9485 string: string
9486 },
9487 stroke: {
9488 string: string
9489 },
9490 strokeWidth: {
9491 number: number
9492 },
9493 __type__: {
9494 string: string,
9495 object: object,
9496 'undefined': 'undefined'
9497 }
9498};
9499var surfaceColorsOptions = {
9500 hue: {
9501 start: {
9502 number: number
9503 },
9504 end: {
9505 number: number
9506 },
9507 saturation: {
9508 number: number
9509 },
9510 brightness: {
9511 number: number
9512 },
9513 colorStops: {
9514 number: number
9515 },
9516 __type__: {
9517 object: object
9518 }
9519 },
9520 __type__: {
9521 boolean: bool,
9522 array: array,
9523 object: object,
9524 'undefined': 'undefined'
9525 }
9526};
9527var colormapOptions = {
9528 hue: {
9529 start: {
9530 number: number
9531 },
9532 end: {
9533 number: number
9534 },
9535 saturation: {
9536 number: number
9537 },
9538 brightness: {
9539 number: number
9540 },
9541 colorStops: {
9542 number: number
9543 },
9544 __type__: {
9545 object: object
9546 }
9547 },
9548 __type__: {
9549 array: array,
9550 object: object,
9551 'function': 'function',
9552 'undefined': 'undefined'
9553 }
9554};
9555/**
9556 * Order attempted to be alphabetical.
9557 * - x/y/z-prefixes ignored in sorting
9558 * - __type__ always at end
9559 * - globals at end
9560 */
9561
9562var allOptions = {
9563 animationAutoStart: {
9564 boolean: bool,
9565 'undefined': 'undefined'
9566 },
9567 animationInterval: {
9568 number: number
9569 },
9570 animationPreload: {
9571 boolean: bool
9572 },
9573 axisColor: {
9574 string: string
9575 },
9576 axisFontSize: {
9577 number: number
9578 },
9579 axisFontType: {
9580 string: string
9581 },
9582 backgroundColor: colorOptions,
9583 xBarWidth: {
9584 number: number,
9585 'undefined': 'undefined'
9586 },
9587 yBarWidth: {
9588 number: number,
9589 'undefined': 'undefined'
9590 },
9591 cameraPosition: {
9592 distance: {
9593 number: number
9594 },
9595 horizontal: {
9596 number: number
9597 },
9598 vertical: {
9599 number: number
9600 },
9601 __type__: {
9602 object: object
9603 }
9604 },
9605 zoomable: {
9606 boolean: bool
9607 },
9608 ctrlToZoom: {
9609 boolean: bool
9610 },
9611 xCenter: {
9612 string: string
9613 },
9614 yCenter: {
9615 string: string
9616 },
9617 colormap: colormapOptions,
9618 dataColor: colorOptions,
9619 dotSizeMinFraction: {
9620 number: number
9621 },
9622 dotSizeMaxFraction: {
9623 number: number
9624 },
9625 dotSizeRatio: {
9626 number: number
9627 },
9628 filterLabel: {
9629 string: string
9630 },
9631 gridColor: {
9632 string: string
9633 },
9634 onclick: {
9635 'function': 'function'
9636 },
9637 keepAspectRatio: {
9638 boolean: bool
9639 },
9640 xLabel: {
9641 string: string
9642 },
9643 yLabel: {
9644 string: string
9645 },
9646 zLabel: {
9647 string: string
9648 },
9649 legendLabel: {
9650 string: string
9651 },
9652 xMin: {
9653 number: number,
9654 'undefined': 'undefined'
9655 },
9656 yMin: {
9657 number: number,
9658 'undefined': 'undefined'
9659 },
9660 zMin: {
9661 number: number,
9662 'undefined': 'undefined'
9663 },
9664 xMax: {
9665 number: number,
9666 'undefined': 'undefined'
9667 },
9668 yMax: {
9669 number: number,
9670 'undefined': 'undefined'
9671 },
9672 zMax: {
9673 number: number,
9674 'undefined': 'undefined'
9675 },
9676 showAnimationControls: {
9677 boolean: bool,
9678 'undefined': 'undefined'
9679 },
9680 showGrayBottom: {
9681 boolean: bool
9682 },
9683 showGrid: {
9684 boolean: bool
9685 },
9686 showLegend: {
9687 boolean: bool,
9688 'undefined': 'undefined'
9689 },
9690 showPerspective: {
9691 boolean: bool
9692 },
9693 showShadow: {
9694 boolean: bool
9695 },
9696 showSurfaceGrid: {
9697 boolean: bool
9698 },
9699 showXAxis: {
9700 boolean: bool
9701 },
9702 showYAxis: {
9703 boolean: bool
9704 },
9705 showZAxis: {
9706 boolean: bool
9707 },
9708 rotateAxisLabels: {
9709 boolean: bool
9710 },
9711 surfaceColors: surfaceColorsOptions,
9712 xStep: {
9713 number: number,
9714 'undefined': 'undefined'
9715 },
9716 yStep: {
9717 number: number,
9718 'undefined': 'undefined'
9719 },
9720 zStep: {
9721 number: number,
9722 'undefined': 'undefined'
9723 },
9724 style: {
9725 number: number,
9726 // TODO: either Graph3d.DEFAULT has string, or number allowed in documentation
9727 string: ['bar', 'bar-color', 'bar-size', 'dot', 'dot-line', 'dot-color', 'dot-size', 'line', 'grid', 'surface']
9728 },
9729 tooltip: {
9730 boolean: bool,
9731 'function': 'function'
9732 },
9733 tooltipDelay: {
9734 number: number
9735 },
9736 tooltipStyle: {
9737 content: {
9738 color: {
9739 string: string
9740 },
9741 background: {
9742 string: string
9743 },
9744 border: {
9745 string: string
9746 },
9747 borderRadius: {
9748 string: string
9749 },
9750 boxShadow: {
9751 string: string
9752 },
9753 padding: {
9754 string: string
9755 },
9756 __type__: {
9757 object: object
9758 }
9759 },
9760 line: {
9761 borderLeft: {
9762 string: string
9763 },
9764 height: {
9765 string: string
9766 },
9767 width: {
9768 string: string
9769 },
9770 pointerEvents: {
9771 string: string
9772 },
9773 __type__: {
9774 object: object
9775 }
9776 },
9777 dot: {
9778 border: {
9779 string: string
9780 },
9781 borderRadius: {
9782 string: string
9783 },
9784 height: {
9785 string: string
9786 },
9787 width: {
9788 string: string
9789 },
9790 pointerEvents: {
9791 string: string
9792 },
9793 __type__: {
9794 object: object
9795 }
9796 },
9797 __type__: {
9798 object: object
9799 }
9800 },
9801 xValueLabel: {
9802 'function': 'function'
9803 },
9804 yValueLabel: {
9805 'function': 'function'
9806 },
9807 zValueLabel: {
9808 'function': 'function'
9809 },
9810 valueMax: {
9811 number: number,
9812 'undefined': 'undefined'
9813 },
9814 valueMin: {
9815 number: number,
9816 'undefined': 'undefined'
9817 },
9818 verticalRatio: {
9819 number: number
9820 },
9821 //globals :
9822 height: {
9823 string: string
9824 },
9825 width: {
9826 string: string
9827 },
9828 __type__: {
9829 object: object
9830 }
9831};
9832
9833var $$6 = _export;
9834var getBuiltIn$1 = getBuiltIn$8;
9835var aFunction$2 = aFunction$6;
9836var anObject$2 = anObject$b;
9837var isObject$2 = isObject$f;
9838var create$3 = objectCreate;
9839var bind$3 = functionBind;
9840var fails$2 = fails$l;
9841var nativeConstruct = getBuiltIn$1('Reflect', 'construct'); // `Reflect.construct` method
9842// https://tc39.es/ecma262/#sec-reflect.construct
9843// MS Edge supports only 2 arguments and argumentsList argument is optional
9844// FF Nightly sets third argument as `new.target`, but does not create `this` from it
9845
9846var NEW_TARGET_BUG = fails$2(function () {
9847 function F() {
9848 /* empty */
9849 }
9850
9851 return !(nativeConstruct(function () {
9852 /* empty */
9853 }, [], F) instanceof F);
9854});
9855var ARGS_BUG = !fails$2(function () {
9856 nativeConstruct(function () {
9857 /* empty */
9858 });
9859});
9860var FORCED = NEW_TARGET_BUG || ARGS_BUG;
9861$$6({
9862 target: 'Reflect',
9863 stat: true,
9864 forced: FORCED,
9865 sham: FORCED
9866}, {
9867 construct: function construct(Target, args
9868 /* , newTarget */
9869 ) {
9870 aFunction$2(Target);
9871 anObject$2(args);
9872 var newTarget = arguments.length < 3 ? Target : aFunction$2(arguments[2]);
9873 if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget);
9874
9875 if (Target == newTarget) {
9876 // w/o altered newTarget, optimization for 0-4 arguments
9877 switch (args.length) {
9878 case 0:
9879 return new Target();
9880
9881 case 1:
9882 return new Target(args[0]);
9883
9884 case 2:
9885 return new Target(args[0], args[1]);
9886
9887 case 3:
9888 return new Target(args[0], args[1], args[2]);
9889
9890 case 4:
9891 return new Target(args[0], args[1], args[2], args[3]);
9892 } // w/o altered newTarget, lot of arguments case
9893
9894
9895 var $args = [null];
9896 $args.push.apply($args, args);
9897 return new (bind$3.apply(Target, $args))();
9898 } // with altered newTarget, not support built-in constructors
9899
9900
9901 var proto = newTarget.prototype;
9902 var instance = create$3(isObject$2(proto) ? proto : Object.prototype);
9903 var result = Function.apply.call(Target, instance, args);
9904 return isObject$2(result) ? result : instance;
9905 }
9906});
9907
9908var path$3 = path$s;
9909var construct$2 = path$3.Reflect.construct;
9910
9911var parent$d = construct$2;
9912var construct$1 = parent$d;
9913
9914var construct = construct$1;
9915
9916function _assertThisInitialized(self) {
9917 if (self === void 0) {
9918 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
9919 }
9920
9921 return self;
9922}
9923
9924var parent$c = create$5;
9925var create$2 = parent$c;
9926
9927var create$1 = create$2;
9928
9929var $$5 = _export;
9930var setPrototypeOf$4 = objectSetPrototypeOf; // `Object.setPrototypeOf` method
9931// https://tc39.es/ecma262/#sec-object.setprototypeof
9932
9933$$5({
9934 target: 'Object',
9935 stat: true
9936}, {
9937 setPrototypeOf: setPrototypeOf$4
9938});
9939
9940var path$2 = path$s;
9941var setPrototypeOf$3 = path$2.Object.setPrototypeOf;
9942
9943var parent$b = setPrototypeOf$3;
9944var setPrototypeOf$2 = parent$b;
9945
9946var parent$a = setPrototypeOf$2;
9947var setPrototypeOf$1 = parent$a;
9948
9949var setPrototypeOf = setPrototypeOf$1;
9950
9951function _setPrototypeOf(o, p) {
9952 _setPrototypeOf = setPrototypeOf || function _setPrototypeOf(o, p) {
9953 o.__proto__ = p;
9954 return o;
9955 };
9956
9957 return _setPrototypeOf(o, p);
9958}
9959
9960function _inherits(subClass, superClass) {
9961 if (typeof superClass !== "function" && superClass !== null) {
9962 throw new TypeError("Super expression must either be null or a function");
9963 }
9964
9965 subClass.prototype = create$1(superClass && superClass.prototype, {
9966 constructor: {
9967 value: subClass,
9968 writable: true,
9969 configurable: true
9970 }
9971 });
9972 if (superClass) _setPrototypeOf(subClass, superClass);
9973}
9974
9975function _possibleConstructorReturn(self, call) {
9976 if (call && (_typeof(call) === "object" || typeof call === "function")) {
9977 return call;
9978 } else if (call !== void 0) {
9979 throw new TypeError("Derived constructors may only return object or undefined");
9980 }
9981
9982 return _assertThisInitialized(self);
9983}
9984
9985var parent$9 = getPrototypeOf$3;
9986var getPrototypeOf$1 = parent$9;
9987
9988var getPrototypeOf = getPrototypeOf$1;
9989
9990function _getPrototypeOf(o) {
9991 _getPrototypeOf = setPrototypeOf ? getPrototypeOf : function _getPrototypeOf(o) {
9992 return o.__proto__ || getPrototypeOf(o);
9993 };
9994 return _getPrototypeOf(o);
9995}
9996
9997var runtime = {exports: {}};
9998
9999/**
10000 * Copyright (c) 2014-present, Facebook, Inc.
10001 *
10002 * This source code is licensed under the MIT license found in the
10003 * LICENSE file in the root directory of this source tree.
10004 */
10005
10006(function (module) {
10007 var runtime = function (exports) {
10008
10009 var Op = Object.prototype;
10010 var hasOwn = Op.hasOwnProperty;
10011 var undefined$1; // More compressible than void 0.
10012
10013 var $Symbol = typeof Symbol === "function" ? Symbol : {};
10014 var iteratorSymbol = $Symbol.iterator || "@@iterator";
10015 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
10016 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
10017
10018 function define(obj, key, value) {
10019 Object.defineProperty(obj, key, {
10020 value: value,
10021 enumerable: true,
10022 configurable: true,
10023 writable: true
10024 });
10025 return obj[key];
10026 }
10027
10028 try {
10029 // IE 8 has a broken Object.defineProperty that only works on DOM objects.
10030 define({}, "");
10031 } catch (err) {
10032 define = function (obj, key, value) {
10033 return obj[key] = value;
10034 };
10035 }
10036
10037 function wrap(innerFn, outerFn, self, tryLocsList) {
10038 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
10039 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
10040 var generator = Object.create(protoGenerator.prototype);
10041 var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
10042 // .throw, and .return methods.
10043
10044 generator._invoke = makeInvokeMethod(innerFn, self, context);
10045 return generator;
10046 }
10047
10048 exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
10049 // record like context.tryEntries[i].completion. This interface could
10050 // have been (and was previously) designed to take a closure to be
10051 // invoked without arguments, but in all the cases we care about we
10052 // already have an existing method we want to call, so there's no need
10053 // to create a new function object. We can even get away with assuming
10054 // the method takes exactly one argument, since that happens to be true
10055 // in every case, so we don't have to touch the arguments object. The
10056 // only additional allocation required is the completion record, which
10057 // has a stable shape and so hopefully should be cheap to allocate.
10058
10059 function tryCatch(fn, obj, arg) {
10060 try {
10061 return {
10062 type: "normal",
10063 arg: fn.call(obj, arg)
10064 };
10065 } catch (err) {
10066 return {
10067 type: "throw",
10068 arg: err
10069 };
10070 }
10071 }
10072
10073 var GenStateSuspendedStart = "suspendedStart";
10074 var GenStateSuspendedYield = "suspendedYield";
10075 var GenStateExecuting = "executing";
10076 var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
10077 // breaking out of the dispatch switch statement.
10078
10079 var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
10080 // .constructor.prototype properties for functions that return Generator
10081 // objects. For full spec compliance, you may wish to configure your
10082 // minifier not to mangle the names of these two functions.
10083
10084 function Generator() {}
10085
10086 function GeneratorFunction() {}
10087
10088 function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
10089 // don't natively support it.
10090
10091
10092 var IteratorPrototype = {};
10093
10094 IteratorPrototype[iteratorSymbol] = function () {
10095 return this;
10096 };
10097
10098 var getProto = Object.getPrototypeOf;
10099 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
10100
10101 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
10102 // This environment has a native %IteratorPrototype%; use it instead
10103 // of the polyfill.
10104 IteratorPrototype = NativeIteratorPrototype;
10105 }
10106
10107 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
10108 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
10109 GeneratorFunctionPrototype.constructor = GeneratorFunction;
10110 GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
10111 // Iterator interface in terms of a single ._invoke method.
10112
10113 function defineIteratorMethods(prototype) {
10114 ["next", "throw", "return"].forEach(function (method) {
10115 define(prototype, method, function (arg) {
10116 return this._invoke(method, arg);
10117 });
10118 });
10119 }
10120
10121 exports.isGeneratorFunction = function (genFun) {
10122 var ctor = typeof genFun === "function" && genFun.constructor;
10123 return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
10124 // do is to check its .name property.
10125 (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
10126 };
10127
10128 exports.mark = function (genFun) {
10129 if (Object.setPrototypeOf) {
10130 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
10131 } else {
10132 genFun.__proto__ = GeneratorFunctionPrototype;
10133 define(genFun, toStringTagSymbol, "GeneratorFunction");
10134 }
10135
10136 genFun.prototype = Object.create(Gp);
10137 return genFun;
10138 }; // Within the body of any async function, `await x` is transformed to
10139 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
10140 // `hasOwn.call(value, "__await")` to determine if the yielded value is
10141 // meant to be awaited.
10142
10143
10144 exports.awrap = function (arg) {
10145 return {
10146 __await: arg
10147 };
10148 };
10149
10150 function AsyncIterator(generator, PromiseImpl) {
10151 function invoke(method, arg, resolve, reject) {
10152 var record = tryCatch(generator[method], generator, arg);
10153
10154 if (record.type === "throw") {
10155 reject(record.arg);
10156 } else {
10157 var result = record.arg;
10158 var value = result.value;
10159
10160 if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
10161 return PromiseImpl.resolve(value.__await).then(function (value) {
10162 invoke("next", value, resolve, reject);
10163 }, function (err) {
10164 invoke("throw", err, resolve, reject);
10165 });
10166 }
10167
10168 return PromiseImpl.resolve(value).then(function (unwrapped) {
10169 // When a yielded Promise is resolved, its final value becomes
10170 // the .value of the Promise<{value,done}> result for the
10171 // current iteration.
10172 result.value = unwrapped;
10173 resolve(result);
10174 }, function (error) {
10175 // If a rejected Promise was yielded, throw the rejection back
10176 // into the async generator function so it can be handled there.
10177 return invoke("throw", error, resolve, reject);
10178 });
10179 }
10180 }
10181
10182 var previousPromise;
10183
10184 function enqueue(method, arg) {
10185 function callInvokeWithMethodAndArg() {
10186 return new PromiseImpl(function (resolve, reject) {
10187 invoke(method, arg, resolve, reject);
10188 });
10189 }
10190
10191 return previousPromise = // If enqueue has been called before, then we want to wait until
10192 // all previous Promises have been resolved before calling invoke,
10193 // so that results are always delivered in the correct order. If
10194 // enqueue has not been called before, then it is important to
10195 // call invoke immediately, without waiting on a callback to fire,
10196 // so that the async generator function has the opportunity to do
10197 // any necessary setup in a predictable way. This predictability
10198 // is why the Promise constructor synchronously invokes its
10199 // executor callback, and why async functions synchronously
10200 // execute code before the first await. Since we implement simple
10201 // async functions in terms of async generators, it is especially
10202 // important to get this right, even though it requires care.
10203 previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
10204 // invocations of the iterator.
10205 callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
10206 } // Define the unified helper method that is used to implement .next,
10207 // .throw, and .return (see defineIteratorMethods).
10208
10209
10210 this._invoke = enqueue;
10211 }
10212
10213 defineIteratorMethods(AsyncIterator.prototype);
10214
10215 AsyncIterator.prototype[asyncIteratorSymbol] = function () {
10216 return this;
10217 };
10218
10219 exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
10220 // AsyncIterator objects; they just return a Promise for the value of
10221 // the final result produced by the iterator.
10222
10223 exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
10224 if (PromiseImpl === void 0) PromiseImpl = Promise;
10225 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
10226 return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
10227 : iter.next().then(function (result) {
10228 return result.done ? result.value : iter.next();
10229 });
10230 };
10231
10232 function makeInvokeMethod(innerFn, self, context) {
10233 var state = GenStateSuspendedStart;
10234 return function invoke(method, arg) {
10235 if (state === GenStateExecuting) {
10236 throw new Error("Generator is already running");
10237 }
10238
10239 if (state === GenStateCompleted) {
10240 if (method === "throw") {
10241 throw arg;
10242 } // Be forgiving, per 25.3.3.3.3 of the spec:
10243 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
10244
10245
10246 return doneResult();
10247 }
10248
10249 context.method = method;
10250 context.arg = arg;
10251
10252 while (true) {
10253 var delegate = context.delegate;
10254
10255 if (delegate) {
10256 var delegateResult = maybeInvokeDelegate(delegate, context);
10257
10258 if (delegateResult) {
10259 if (delegateResult === ContinueSentinel) continue;
10260 return delegateResult;
10261 }
10262 }
10263
10264 if (context.method === "next") {
10265 // Setting context._sent for legacy support of Babel's
10266 // function.sent implementation.
10267 context.sent = context._sent = context.arg;
10268 } else if (context.method === "throw") {
10269 if (state === GenStateSuspendedStart) {
10270 state = GenStateCompleted;
10271 throw context.arg;
10272 }
10273
10274 context.dispatchException(context.arg);
10275 } else if (context.method === "return") {
10276 context.abrupt("return", context.arg);
10277 }
10278
10279 state = GenStateExecuting;
10280 var record = tryCatch(innerFn, self, context);
10281
10282 if (record.type === "normal") {
10283 // If an exception is thrown from innerFn, we leave state ===
10284 // GenStateExecuting and loop back for another invocation.
10285 state = context.done ? GenStateCompleted : GenStateSuspendedYield;
10286
10287 if (record.arg === ContinueSentinel) {
10288 continue;
10289 }
10290
10291 return {
10292 value: record.arg,
10293 done: context.done
10294 };
10295 } else if (record.type === "throw") {
10296 state = GenStateCompleted; // Dispatch the exception by looping back around to the
10297 // context.dispatchException(context.arg) call above.
10298
10299 context.method = "throw";
10300 context.arg = record.arg;
10301 }
10302 }
10303 };
10304 } // Call delegate.iterator[context.method](context.arg) and handle the
10305 // result, either by returning a { value, done } result from the
10306 // delegate iterator, or by modifying context.method and context.arg,
10307 // setting context.delegate to null, and returning the ContinueSentinel.
10308
10309
10310 function maybeInvokeDelegate(delegate, context) {
10311 var method = delegate.iterator[context.method];
10312
10313 if (method === undefined$1) {
10314 // A .throw or .return when the delegate iterator has no .throw
10315 // method always terminates the yield* loop.
10316 context.delegate = null;
10317
10318 if (context.method === "throw") {
10319 // Note: ["return"] must be used for ES3 parsing compatibility.
10320 if (delegate.iterator["return"]) {
10321 // If the delegate iterator has a return method, give it a
10322 // chance to clean up.
10323 context.method = "return";
10324 context.arg = undefined$1;
10325 maybeInvokeDelegate(delegate, context);
10326
10327 if (context.method === "throw") {
10328 // If maybeInvokeDelegate(context) changed context.method from
10329 // "return" to "throw", let that override the TypeError below.
10330 return ContinueSentinel;
10331 }
10332 }
10333
10334 context.method = "throw";
10335 context.arg = new TypeError("The iterator does not provide a 'throw' method");
10336 }
10337
10338 return ContinueSentinel;
10339 }
10340
10341 var record = tryCatch(method, delegate.iterator, context.arg);
10342
10343 if (record.type === "throw") {
10344 context.method = "throw";
10345 context.arg = record.arg;
10346 context.delegate = null;
10347 return ContinueSentinel;
10348 }
10349
10350 var info = record.arg;
10351
10352 if (!info) {
10353 context.method = "throw";
10354 context.arg = new TypeError("iterator result is not an object");
10355 context.delegate = null;
10356 return ContinueSentinel;
10357 }
10358
10359 if (info.done) {
10360 // Assign the result of the finished delegate to the temporary
10361 // variable specified by delegate.resultName (see delegateYield).
10362 context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
10363
10364 context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
10365 // exception, let the outer generator proceed normally. If
10366 // context.method was "next", forget context.arg since it has been
10367 // "consumed" by the delegate iterator. If context.method was
10368 // "return", allow the original .return call to continue in the
10369 // outer generator.
10370
10371 if (context.method !== "return") {
10372 context.method = "next";
10373 context.arg = undefined$1;
10374 }
10375 } else {
10376 // Re-yield the result returned by the delegate method.
10377 return info;
10378 } // The delegate iterator is finished, so forget it and continue with
10379 // the outer generator.
10380
10381
10382 context.delegate = null;
10383 return ContinueSentinel;
10384 } // Define Generator.prototype.{next,throw,return} in terms of the
10385 // unified ._invoke helper method.
10386
10387
10388 defineIteratorMethods(Gp);
10389 define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
10390 // @@iterator function is called on it. Some browsers' implementations of the
10391 // iterator prototype chain incorrectly implement this, causing the Generator
10392 // object to not be returned from this call. This ensures that doesn't happen.
10393 // See https://github.com/facebook/regenerator/issues/274 for more details.
10394
10395 Gp[iteratorSymbol] = function () {
10396 return this;
10397 };
10398
10399 Gp.toString = function () {
10400 return "[object Generator]";
10401 };
10402
10403 function pushTryEntry(locs) {
10404 var entry = {
10405 tryLoc: locs[0]
10406 };
10407
10408 if (1 in locs) {
10409 entry.catchLoc = locs[1];
10410 }
10411
10412 if (2 in locs) {
10413 entry.finallyLoc = locs[2];
10414 entry.afterLoc = locs[3];
10415 }
10416
10417 this.tryEntries.push(entry);
10418 }
10419
10420 function resetTryEntry(entry) {
10421 var record = entry.completion || {};
10422 record.type = "normal";
10423 delete record.arg;
10424 entry.completion = record;
10425 }
10426
10427 function Context(tryLocsList) {
10428 // The root entry object (effectively a try statement without a catch
10429 // or a finally block) gives us a place to store values thrown from
10430 // locations where there is no enclosing try statement.
10431 this.tryEntries = [{
10432 tryLoc: "root"
10433 }];
10434 tryLocsList.forEach(pushTryEntry, this);
10435 this.reset(true);
10436 }
10437
10438 exports.keys = function (object) {
10439 var keys = [];
10440
10441 for (var key in object) {
10442 keys.push(key);
10443 }
10444
10445 keys.reverse(); // Rather than returning an object with a next method, we keep
10446 // things simple and return the next function itself.
10447
10448 return function next() {
10449 while (keys.length) {
10450 var key = keys.pop();
10451
10452 if (key in object) {
10453 next.value = key;
10454 next.done = false;
10455 return next;
10456 }
10457 } // To avoid creating an additional object, we just hang the .value
10458 // and .done properties off the next function object itself. This
10459 // also ensures that the minifier will not anonymize the function.
10460
10461
10462 next.done = true;
10463 return next;
10464 };
10465 };
10466
10467 function values(iterable) {
10468 if (iterable) {
10469 var iteratorMethod = iterable[iteratorSymbol];
10470
10471 if (iteratorMethod) {
10472 return iteratorMethod.call(iterable);
10473 }
10474
10475 if (typeof iterable.next === "function") {
10476 return iterable;
10477 }
10478
10479 if (!isNaN(iterable.length)) {
10480 var i = -1,
10481 next = function next() {
10482 while (++i < iterable.length) {
10483 if (hasOwn.call(iterable, i)) {
10484 next.value = iterable[i];
10485 next.done = false;
10486 return next;
10487 }
10488 }
10489
10490 next.value = undefined$1;
10491 next.done = true;
10492 return next;
10493 };
10494
10495 return next.next = next;
10496 }
10497 } // Return an iterator with no values.
10498
10499
10500 return {
10501 next: doneResult
10502 };
10503 }
10504
10505 exports.values = values;
10506
10507 function doneResult() {
10508 return {
10509 value: undefined$1,
10510 done: true
10511 };
10512 }
10513
10514 Context.prototype = {
10515 constructor: Context,
10516 reset: function (skipTempReset) {
10517 this.prev = 0;
10518 this.next = 0; // Resetting context._sent for legacy support of Babel's
10519 // function.sent implementation.
10520
10521 this.sent = this._sent = undefined$1;
10522 this.done = false;
10523 this.delegate = null;
10524 this.method = "next";
10525 this.arg = undefined$1;
10526 this.tryEntries.forEach(resetTryEntry);
10527
10528 if (!skipTempReset) {
10529 for (var name in this) {
10530 // Not sure about the optimal order of these conditions:
10531 if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
10532 this[name] = undefined$1;
10533 }
10534 }
10535 }
10536 },
10537 stop: function () {
10538 this.done = true;
10539 var rootEntry = this.tryEntries[0];
10540 var rootRecord = rootEntry.completion;
10541
10542 if (rootRecord.type === "throw") {
10543 throw rootRecord.arg;
10544 }
10545
10546 return this.rval;
10547 },
10548 dispatchException: function (exception) {
10549 if (this.done) {
10550 throw exception;
10551 }
10552
10553 var context = this;
10554
10555 function handle(loc, caught) {
10556 record.type = "throw";
10557 record.arg = exception;
10558 context.next = loc;
10559
10560 if (caught) {
10561 // If the dispatched exception was caught by a catch block,
10562 // then let that catch block handle the exception normally.
10563 context.method = "next";
10564 context.arg = undefined$1;
10565 }
10566
10567 return !!caught;
10568 }
10569
10570 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
10571 var entry = this.tryEntries[i];
10572 var record = entry.completion;
10573
10574 if (entry.tryLoc === "root") {
10575 // Exception thrown outside of any try block that could handle
10576 // it, so set the completion value of the entire function to
10577 // throw the exception.
10578 return handle("end");
10579 }
10580
10581 if (entry.tryLoc <= this.prev) {
10582 var hasCatch = hasOwn.call(entry, "catchLoc");
10583 var hasFinally = hasOwn.call(entry, "finallyLoc");
10584
10585 if (hasCatch && hasFinally) {
10586 if (this.prev < entry.catchLoc) {
10587 return handle(entry.catchLoc, true);
10588 } else if (this.prev < entry.finallyLoc) {
10589 return handle(entry.finallyLoc);
10590 }
10591 } else if (hasCatch) {
10592 if (this.prev < entry.catchLoc) {
10593 return handle(entry.catchLoc, true);
10594 }
10595 } else if (hasFinally) {
10596 if (this.prev < entry.finallyLoc) {
10597 return handle(entry.finallyLoc);
10598 }
10599 } else {
10600 throw new Error("try statement without catch or finally");
10601 }
10602 }
10603 }
10604 },
10605 abrupt: function (type, arg) {
10606 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
10607 var entry = this.tryEntries[i];
10608
10609 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
10610 var finallyEntry = entry;
10611 break;
10612 }
10613 }
10614
10615 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
10616 // Ignore the finally entry if control is not jumping to a
10617 // location outside the try/catch block.
10618 finallyEntry = null;
10619 }
10620
10621 var record = finallyEntry ? finallyEntry.completion : {};
10622 record.type = type;
10623 record.arg = arg;
10624
10625 if (finallyEntry) {
10626 this.method = "next";
10627 this.next = finallyEntry.finallyLoc;
10628 return ContinueSentinel;
10629 }
10630
10631 return this.complete(record);
10632 },
10633 complete: function (record, afterLoc) {
10634 if (record.type === "throw") {
10635 throw record.arg;
10636 }
10637
10638 if (record.type === "break" || record.type === "continue") {
10639 this.next = record.arg;
10640 } else if (record.type === "return") {
10641 this.rval = this.arg = record.arg;
10642 this.method = "return";
10643 this.next = "end";
10644 } else if (record.type === "normal" && afterLoc) {
10645 this.next = afterLoc;
10646 }
10647
10648 return ContinueSentinel;
10649 },
10650 finish: function (finallyLoc) {
10651 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
10652 var entry = this.tryEntries[i];
10653
10654 if (entry.finallyLoc === finallyLoc) {
10655 this.complete(entry.completion, entry.afterLoc);
10656 resetTryEntry(entry);
10657 return ContinueSentinel;
10658 }
10659 }
10660 },
10661 "catch": function (tryLoc) {
10662 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
10663 var entry = this.tryEntries[i];
10664
10665 if (entry.tryLoc === tryLoc) {
10666 var record = entry.completion;
10667
10668 if (record.type === "throw") {
10669 var thrown = record.arg;
10670 resetTryEntry(entry);
10671 }
10672
10673 return thrown;
10674 }
10675 } // The context.catch method must only be called with a location
10676 // argument that corresponds to a known catch block.
10677
10678
10679 throw new Error("illegal catch attempt");
10680 },
10681 delegateYield: function (iterable, resultName, nextLoc) {
10682 this.delegate = {
10683 iterator: values(iterable),
10684 resultName: resultName,
10685 nextLoc: nextLoc
10686 };
10687
10688 if (this.method === "next") {
10689 // Deliberately forget the last sent value so that we don't
10690 // accidentally pass it on to the delegate.
10691 this.arg = undefined$1;
10692 }
10693
10694 return ContinueSentinel;
10695 }
10696 }; // Regardless of whether this script is executing as a CommonJS module
10697 // or not, return the runtime object so that we can declare the variable
10698 // regeneratorRuntime in the outer scope, which allows this module to be
10699 // injected easily by `bin/regenerator --include-runtime script.js`.
10700
10701 return exports;
10702 }( // If this script is executing as a CommonJS module, use module.exports
10703 // as the regeneratorRuntime namespace. Otherwise create a new empty
10704 // object. Either way, the resulting object will be used to initialize
10705 // the regeneratorRuntime variable at the top of this file.
10706 module.exports );
10707
10708 try {
10709 regeneratorRuntime = runtime;
10710 } catch (accidentalStrictMode) {
10711 // This module should not be running in strict mode, so the above
10712 // assignment should always work unless something is misconfigured. Just
10713 // in case runtime.js accidentally runs in strict mode, we can escape
10714 // strict mode using a global Function call. This could conceivably fail
10715 // if a Content Security Policy forbids using Function, but in that case
10716 // the proper solution is to fix the accidental strict mode problem. If
10717 // you've misconfigured your bundler to force strict mode and applied a
10718 // CSP to forbid Function, and you're not willing to fix either of those
10719 // problems, please detail your unique predicament in a GitHub issue.
10720 Function("r", "regeneratorRuntime = r")(runtime);
10721 }
10722})(runtime);
10723
10724var regenerator = runtime.exports;
10725
10726var aFunction$1 = aFunction$6;
10727var toObject$1 = toObject$e;
10728var IndexedObject = indexedObject;
10729var toLength$3 = toLength$c; // `Array.prototype.{ reduce, reduceRight }` methods implementation
10730
10731var createMethod = function (IS_RIGHT) {
10732 return function (that, callbackfn, argumentsLength, memo) {
10733 aFunction$1(callbackfn);
10734 var O = toObject$1(that);
10735 var self = IndexedObject(O);
10736 var length = toLength$3(O.length);
10737 var index = IS_RIGHT ? length - 1 : 0;
10738 var i = IS_RIGHT ? -1 : 1;
10739 if (argumentsLength < 2) while (true) {
10740 if (index in self) {
10741 memo = self[index];
10742 index += i;
10743 break;
10744 }
10745
10746 index += i;
10747
10748 if (IS_RIGHT ? index < 0 : length <= index) {
10749 throw TypeError('Reduce of empty array with no initial value');
10750 }
10751 }
10752
10753 for (; IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
10754 memo = callbackfn(memo, self[index], index, O);
10755 }
10756
10757 return memo;
10758 };
10759};
10760
10761var arrayReduce = {
10762 // `Array.prototype.reduce` method
10763 // https://tc39.es/ecma262/#sec-array.prototype.reduce
10764 left: createMethod(false),
10765 // `Array.prototype.reduceRight` method
10766 // https://tc39.es/ecma262/#sec-array.prototype.reduceright
10767 right: createMethod(true)
10768};
10769
10770var classof$2 = classofRaw$1;
10771var global$2 = global$i;
10772var engineIsNode = classof$2(global$2.process) == 'process';
10773
10774var $$4 = _export;
10775var $reduce = arrayReduce.left;
10776var arrayMethodIsStrict$1 = arrayMethodIsStrict$5;
10777var CHROME_VERSION = engineV8Version;
10778var IS_NODE = engineIsNode;
10779var STRICT_METHOD$1 = arrayMethodIsStrict$1('reduce'); // Chrome 80-82 has a critical bug
10780// https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
10781
10782var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83; // `Array.prototype.reduce` method
10783// https://tc39.es/ecma262/#sec-array.prototype.reduce
10784
10785$$4({
10786 target: 'Array',
10787 proto: true,
10788 forced: !STRICT_METHOD$1 || CHROME_BUG
10789}, {
10790 reduce: function reduce(callbackfn
10791 /* , initialValue */
10792 ) {
10793 return $reduce(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
10794 }
10795});
10796
10797var entryVirtual$4 = entryVirtual$k;
10798var reduce$3 = entryVirtual$4('Array').reduce;
10799
10800var reduce$2 = reduce$3;
10801var ArrayPrototype$4 = Array.prototype;
10802
10803var reduce_1 = function (it) {
10804 var own = it.reduce;
10805 return it === ArrayPrototype$4 || it instanceof Array && own === ArrayPrototype$4.reduce ? reduce$2 : own;
10806};
10807
10808var parent$8 = reduce_1;
10809var reduce$1 = parent$8;
10810
10811var reduce = reduce$1;
10812
10813var isArray = isArray$c;
10814var toLength$2 = toLength$c;
10815var bind$2 = functionBindContext; // `FlattenIntoArray` abstract operation
10816// https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
10817
10818var flattenIntoArray$1 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
10819 var targetIndex = start;
10820 var sourceIndex = 0;
10821 var mapFn = mapper ? bind$2(mapper, thisArg, 3) : false;
10822 var element;
10823
10824 while (sourceIndex < sourceLen) {
10825 if (sourceIndex in source) {
10826 element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
10827
10828 if (depth > 0 && isArray(element)) {
10829 targetIndex = flattenIntoArray$1(target, original, element, toLength$2(element.length), targetIndex, depth - 1) - 1;
10830 } else {
10831 if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError('Exceed the acceptable array length');
10832 target[targetIndex] = element;
10833 }
10834
10835 targetIndex++;
10836 }
10837
10838 sourceIndex++;
10839 }
10840
10841 return targetIndex;
10842};
10843
10844var flattenIntoArray_1 = flattenIntoArray$1;
10845
10846var $$3 = _export;
10847var flattenIntoArray = flattenIntoArray_1;
10848var toObject = toObject$e;
10849var toLength$1 = toLength$c;
10850var aFunction = aFunction$6;
10851var arraySpeciesCreate = arraySpeciesCreate$4; // `Array.prototype.flatMap` method
10852// https://tc39.es/ecma262/#sec-array.prototype.flatmap
10853
10854$$3({
10855 target: 'Array',
10856 proto: true
10857}, {
10858 flatMap: function flatMap(callbackfn
10859 /* , thisArg */
10860 ) {
10861 var O = toObject(this);
10862 var sourceLen = toLength$1(O.length);
10863 var A;
10864 aFunction(callbackfn);
10865 A = arraySpeciesCreate(O, 0);
10866 A.length = flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
10867 return A;
10868 }
10869});
10870
10871var entryVirtual$3 = entryVirtual$k;
10872var flatMap$3 = entryVirtual$3('Array').flatMap;
10873
10874var flatMap$2 = flatMap$3;
10875var ArrayPrototype$3 = Array.prototype;
10876
10877var flatMap_1 = function (it) {
10878 var own = it.flatMap;
10879 return it === ArrayPrototype$3 || it instanceof Array && own === ArrayPrototype$3.flatMap ? flatMap$2 : own;
10880};
10881
10882var parent$7 = flatMap_1;
10883var flatMap$1 = parent$7;
10884
10885var flatMap = flatMap$1;
10886
10887var internalMetadata = {exports: {}};
10888
10889var fails$1 = fails$l;
10890var freezing = !fails$1(function () {
10891 // eslint-disable-next-line es/no-object-isextensible, es/no-object-preventextensions -- required for testing
10892 return Object.isExtensible(Object.preventExtensions({}));
10893});
10894
10895var $$2 = _export;
10896var hiddenKeys = hiddenKeys$6;
10897var isObject$1 = isObject$f;
10898var has = has$b;
10899var defineProperty$2 = objectDefineProperty.f;
10900var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
10901var getOwnPropertyNamesExternalModule = objectGetOwnPropertyNamesExternal;
10902var uid = uid$4;
10903var FREEZING = freezing;
10904var REQUIRED = false;
10905var METADATA = uid('meta');
10906var id = 0; // eslint-disable-next-line es/no-object-isextensible -- safe
10907
10908var isExtensible = Object.isExtensible || function () {
10909 return true;
10910};
10911
10912var setMetadata = function (it) {
10913 defineProperty$2(it, METADATA, {
10914 value: {
10915 objectID: 'O' + id++,
10916 // object ID
10917 weakData: {} // weak collections IDs
10918
10919 }
10920 });
10921};
10922
10923var fastKey$1 = function (it, create) {
10924 // return a primitive with prefix
10925 if (!isObject$1(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
10926
10927 if (!has(it, METADATA)) {
10928 // can't set metadata to uncaught frozen object
10929 if (!isExtensible(it)) return 'F'; // not necessary to add metadata
10930
10931 if (!create) return 'E'; // add missing metadata
10932
10933 setMetadata(it); // return object ID
10934 }
10935
10936 return it[METADATA].objectID;
10937};
10938
10939var getWeakData = function (it, create) {
10940 if (!has(it, METADATA)) {
10941 // can't set metadata to uncaught frozen object
10942 if (!isExtensible(it)) return true; // not necessary to add metadata
10943
10944 if (!create) return false; // add missing metadata
10945
10946 setMetadata(it); // return the store of weak collections IDs
10947 }
10948
10949 return it[METADATA].weakData;
10950}; // add metadata on freeze-family methods calling
10951
10952
10953var onFreeze = function (it) {
10954 if (FREEZING && REQUIRED && isExtensible(it) && !has(it, METADATA)) setMetadata(it);
10955 return it;
10956};
10957
10958var enable = function () {
10959 meta.enable = function () {
10960 /* empty */
10961 };
10962
10963 REQUIRED = true;
10964 var getOwnPropertyNames = getOwnPropertyNamesModule.f;
10965 var splice = [].splice;
10966 var test = {};
10967 test[METADATA] = 1; // prevent exposing of metadata key
10968
10969 if (getOwnPropertyNames(test).length) {
10970 getOwnPropertyNamesModule.f = function (it) {
10971 var result = getOwnPropertyNames(it);
10972
10973 for (var i = 0, length = result.length; i < length; i++) {
10974 if (result[i] === METADATA) {
10975 splice.call(result, i, 1);
10976 break;
10977 }
10978 }
10979
10980 return result;
10981 };
10982
10983 $$2({
10984 target: 'Object',
10985 stat: true,
10986 forced: true
10987 }, {
10988 getOwnPropertyNames: getOwnPropertyNamesExternalModule.f
10989 });
10990 }
10991};
10992
10993var meta = internalMetadata.exports = {
10994 enable: enable,
10995 fastKey: fastKey$1,
10996 getWeakData: getWeakData,
10997 onFreeze: onFreeze
10998};
10999hiddenKeys[METADATA] = true;
11000
11001var anObject$1 = anObject$b;
11002var isArrayIteratorMethod = isArrayIteratorMethod$2;
11003var toLength = toLength$c;
11004var bind$1 = functionBindContext;
11005var getIteratorMethod$1 = getIteratorMethod$7;
11006var iteratorClose = iteratorClose$2;
11007
11008var Result = function (stopped, result) {
11009 this.stopped = stopped;
11010 this.result = result;
11011};
11012
11013var iterate$2 = function (iterable, unboundFunction, options) {
11014 var that = options && options.that;
11015 var AS_ENTRIES = !!(options && options.AS_ENTRIES);
11016 var IS_ITERATOR = !!(options && options.IS_ITERATOR);
11017 var INTERRUPTED = !!(options && options.INTERRUPTED);
11018 var fn = bind$1(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED);
11019 var iterator, iterFn, index, length, result, next, step;
11020
11021 var stop = function (condition) {
11022 if (iterator) iteratorClose(iterator);
11023 return new Result(true, condition);
11024 };
11025
11026 var callFn = function (value) {
11027 if (AS_ENTRIES) {
11028 anObject$1(value);
11029 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
11030 }
11031
11032 return INTERRUPTED ? fn(value, stop) : fn(value);
11033 };
11034
11035 if (IS_ITERATOR) {
11036 iterator = iterable;
11037 } else {
11038 iterFn = getIteratorMethod$1(iterable);
11039 if (typeof iterFn != 'function') throw TypeError('Target is not iterable'); // optimisation for array iterators
11040
11041 if (isArrayIteratorMethod(iterFn)) {
11042 for (index = 0, length = toLength(iterable.length); length > index; index++) {
11043 result = callFn(iterable[index]);
11044 if (result && result instanceof Result) return result;
11045 }
11046
11047 return new Result(false);
11048 }
11049
11050 iterator = iterFn.call(iterable);
11051 }
11052
11053 next = iterator.next;
11054
11055 while (!(step = next.call(iterator)).done) {
11056 try {
11057 result = callFn(step.value);
11058 } catch (error) {
11059 iteratorClose(iterator);
11060 throw error;
11061 }
11062
11063 if (typeof result == 'object' && result && result instanceof Result) return result;
11064 }
11065
11066 return new Result(false);
11067};
11068
11069var anInstance$2 = function (it, Constructor, name) {
11070 if (!(it instanceof Constructor)) {
11071 throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
11072 }
11073
11074 return it;
11075};
11076
11077var $$1 = _export;
11078var global$1 = global$i;
11079var InternalMetadataModule = internalMetadata.exports;
11080var fails = fails$l;
11081var createNonEnumerableProperty = createNonEnumerableProperty$9;
11082var iterate$1 = iterate$2;
11083var anInstance$1 = anInstance$2;
11084var isObject = isObject$f;
11085var setToStringTag = setToStringTag$5;
11086var defineProperty$1 = objectDefineProperty.f;
11087var forEach = arrayIteration.forEach;
11088var DESCRIPTORS$2 = descriptors;
11089var InternalStateModule$1 = internalState;
11090var setInternalState$1 = InternalStateModule$1.set;
11091var internalStateGetterFor$1 = InternalStateModule$1.getterFor;
11092
11093var collection$2 = function (CONSTRUCTOR_NAME, wrapper, common) {
11094 var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
11095 var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
11096 var ADDER = IS_MAP ? 'set' : 'add';
11097 var NativeConstructor = global$1[CONSTRUCTOR_NAME];
11098 var NativePrototype = NativeConstructor && NativeConstructor.prototype;
11099 var exported = {};
11100 var Constructor;
11101
11102 if (!DESCRIPTORS$2 || typeof NativeConstructor != 'function' || !(IS_WEAK || NativePrototype.forEach && !fails(function () {
11103 new NativeConstructor().entries().next();
11104 }))) {
11105 // create collection constructor
11106 Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
11107 InternalMetadataModule.enable();
11108 } else {
11109 Constructor = wrapper(function (target, iterable) {
11110 setInternalState$1(anInstance$1(target, Constructor, CONSTRUCTOR_NAME), {
11111 type: CONSTRUCTOR_NAME,
11112 collection: new NativeConstructor()
11113 });
11114 if (iterable != undefined) iterate$1(iterable, target[ADDER], {
11115 that: target,
11116 AS_ENTRIES: IS_MAP
11117 });
11118 });
11119 var getInternalState = internalStateGetterFor$1(CONSTRUCTOR_NAME);
11120 forEach(['add', 'clear', 'delete', 'forEach', 'get', 'has', 'set', 'keys', 'values', 'entries'], function (KEY) {
11121 var IS_ADDER = KEY == 'add' || KEY == 'set';
11122
11123 if (KEY in NativePrototype && !(IS_WEAK && KEY == 'clear')) {
11124 createNonEnumerableProperty(Constructor.prototype, KEY, function (a, b) {
11125 var collection = getInternalState(this).collection;
11126 if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
11127 var result = collection[KEY](a === 0 ? 0 : a, b);
11128 return IS_ADDER ? this : result;
11129 });
11130 }
11131 });
11132 IS_WEAK || defineProperty$1(Constructor.prototype, 'size', {
11133 configurable: true,
11134 get: function () {
11135 return getInternalState(this).collection.size;
11136 }
11137 });
11138 }
11139
11140 setToStringTag(Constructor, CONSTRUCTOR_NAME, false, true);
11141 exported[CONSTRUCTOR_NAME] = Constructor;
11142 $$1({
11143 global: true,
11144 forced: true
11145 }, exported);
11146 if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
11147 return Constructor;
11148};
11149
11150var redefine = redefine$3;
11151
11152var redefineAll$1 = function (target, src, options) {
11153 for (var key in src) {
11154 if (options && options.unsafe && target[key]) target[key] = src[key];else redefine(target, key, src[key], options);
11155 }
11156
11157 return target;
11158};
11159
11160var getBuiltIn = getBuiltIn$8;
11161var definePropertyModule = objectDefineProperty;
11162var wellKnownSymbol = wellKnownSymbol$j;
11163var DESCRIPTORS$1 = descriptors;
11164var SPECIES = wellKnownSymbol('species');
11165
11166var setSpecies$1 = function (CONSTRUCTOR_NAME) {
11167 var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
11168 var defineProperty = definePropertyModule.f;
11169
11170 if (DESCRIPTORS$1 && Constructor && !Constructor[SPECIES]) {
11171 defineProperty(Constructor, SPECIES, {
11172 configurable: true,
11173 get: function () {
11174 return this;
11175 }
11176 });
11177 }
11178};
11179
11180var defineProperty = objectDefineProperty.f;
11181var create = objectCreate;
11182var redefineAll = redefineAll$1;
11183var bind = functionBindContext;
11184var anInstance = anInstance$2;
11185var iterate = iterate$2;
11186var defineIterator = defineIterator$3;
11187var setSpecies = setSpecies$1;
11188var DESCRIPTORS = descriptors;
11189var fastKey = internalMetadata.exports.fastKey;
11190var InternalStateModule = internalState;
11191var setInternalState = InternalStateModule.set;
11192var internalStateGetterFor = InternalStateModule.getterFor;
11193var collectionStrong$2 = {
11194 getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
11195 var C = wrapper(function (that, iterable) {
11196 anInstance(that, C, CONSTRUCTOR_NAME);
11197 setInternalState(that, {
11198 type: CONSTRUCTOR_NAME,
11199 index: create(null),
11200 first: undefined,
11201 last: undefined,
11202 size: 0
11203 });
11204 if (!DESCRIPTORS) that.size = 0;
11205 if (iterable != undefined) iterate(iterable, that[ADDER], {
11206 that: that,
11207 AS_ENTRIES: IS_MAP
11208 });
11209 });
11210 var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
11211
11212 var define = function (that, key, value) {
11213 var state = getInternalState(that);
11214 var entry = getEntry(that, key);
11215 var previous, index; // change existing entry
11216
11217 if (entry) {
11218 entry.value = value; // create new entry
11219 } else {
11220 state.last = entry = {
11221 index: index = fastKey(key, true),
11222 key: key,
11223 value: value,
11224 previous: previous = state.last,
11225 next: undefined,
11226 removed: false
11227 };
11228 if (!state.first) state.first = entry;
11229 if (previous) previous.next = entry;
11230 if (DESCRIPTORS) state.size++;else that.size++; // add to index
11231
11232 if (index !== 'F') state.index[index] = entry;
11233 }
11234
11235 return that;
11236 };
11237
11238 var getEntry = function (that, key) {
11239 var state = getInternalState(that); // fast case
11240
11241 var index = fastKey(key);
11242 var entry;
11243 if (index !== 'F') return state.index[index]; // frozen object case
11244
11245 for (entry = state.first; entry; entry = entry.next) {
11246 if (entry.key == key) return entry;
11247 }
11248 };
11249
11250 redefineAll(C.prototype, {
11251 // `{ Map, Set }.prototype.clear()` methods
11252 // https://tc39.es/ecma262/#sec-map.prototype.clear
11253 // https://tc39.es/ecma262/#sec-set.prototype.clear
11254 clear: function clear() {
11255 var that = this;
11256 var state = getInternalState(that);
11257 var data = state.index;
11258 var entry = state.first;
11259
11260 while (entry) {
11261 entry.removed = true;
11262 if (entry.previous) entry.previous = entry.previous.next = undefined;
11263 delete data[entry.index];
11264 entry = entry.next;
11265 }
11266
11267 state.first = state.last = undefined;
11268 if (DESCRIPTORS) state.size = 0;else that.size = 0;
11269 },
11270 // `{ Map, Set }.prototype.delete(key)` methods
11271 // https://tc39.es/ecma262/#sec-map.prototype.delete
11272 // https://tc39.es/ecma262/#sec-set.prototype.delete
11273 'delete': function (key) {
11274 var that = this;
11275 var state = getInternalState(that);
11276 var entry = getEntry(that, key);
11277
11278 if (entry) {
11279 var next = entry.next;
11280 var prev = entry.previous;
11281 delete state.index[entry.index];
11282 entry.removed = true;
11283 if (prev) prev.next = next;
11284 if (next) next.previous = prev;
11285 if (state.first == entry) state.first = next;
11286 if (state.last == entry) state.last = prev;
11287 if (DESCRIPTORS) state.size--;else that.size--;
11288 }
11289
11290 return !!entry;
11291 },
11292 // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods
11293 // https://tc39.es/ecma262/#sec-map.prototype.foreach
11294 // https://tc39.es/ecma262/#sec-set.prototype.foreach
11295 forEach: function forEach(callbackfn
11296 /* , that = undefined */
11297 ) {
11298 var state = getInternalState(this);
11299 var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
11300 var entry;
11301
11302 while (entry = entry ? entry.next : state.first) {
11303 boundFunction(entry.value, entry.key, this); // revert to the last existing entry
11304
11305 while (entry && entry.removed) entry = entry.previous;
11306 }
11307 },
11308 // `{ Map, Set}.prototype.has(key)` methods
11309 // https://tc39.es/ecma262/#sec-map.prototype.has
11310 // https://tc39.es/ecma262/#sec-set.prototype.has
11311 has: function has(key) {
11312 return !!getEntry(this, key);
11313 }
11314 });
11315 redefineAll(C.prototype, IS_MAP ? {
11316 // `Map.prototype.get(key)` method
11317 // https://tc39.es/ecma262/#sec-map.prototype.get
11318 get: function get(key) {
11319 var entry = getEntry(this, key);
11320 return entry && entry.value;
11321 },
11322 // `Map.prototype.set(key, value)` method
11323 // https://tc39.es/ecma262/#sec-map.prototype.set
11324 set: function set(key, value) {
11325 return define(this, key === 0 ? 0 : key, value);
11326 }
11327 } : {
11328 // `Set.prototype.add(value)` method
11329 // https://tc39.es/ecma262/#sec-set.prototype.add
11330 add: function add(value) {
11331 return define(this, value = value === 0 ? 0 : value, value);
11332 }
11333 });
11334 if (DESCRIPTORS) defineProperty(C.prototype, 'size', {
11335 get: function () {
11336 return getInternalState(this).size;
11337 }
11338 });
11339 return C;
11340 },
11341 setStrong: function (C, CONSTRUCTOR_NAME, IS_MAP) {
11342 var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
11343 var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
11344 var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME); // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods
11345 // https://tc39.es/ecma262/#sec-map.prototype.entries
11346 // https://tc39.es/ecma262/#sec-map.prototype.keys
11347 // https://tc39.es/ecma262/#sec-map.prototype.values
11348 // https://tc39.es/ecma262/#sec-map.prototype-@@iterator
11349 // https://tc39.es/ecma262/#sec-set.prototype.entries
11350 // https://tc39.es/ecma262/#sec-set.prototype.keys
11351 // https://tc39.es/ecma262/#sec-set.prototype.values
11352 // https://tc39.es/ecma262/#sec-set.prototype-@@iterator
11353
11354 defineIterator(C, CONSTRUCTOR_NAME, function (iterated, kind) {
11355 setInternalState(this, {
11356 type: ITERATOR_NAME,
11357 target: iterated,
11358 state: getInternalCollectionState(iterated),
11359 kind: kind,
11360 last: undefined
11361 });
11362 }, function () {
11363 var state = getInternalIteratorState(this);
11364 var kind = state.kind;
11365 var entry = state.last; // revert to the last existing entry
11366
11367 while (entry && entry.removed) entry = entry.previous; // get next entry
11368
11369
11370 if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
11371 // or finish the iteration
11372 state.target = undefined;
11373 return {
11374 value: undefined,
11375 done: true
11376 };
11377 } // return step by kind
11378
11379
11380 if (kind == 'keys') return {
11381 value: entry.key,
11382 done: false
11383 };
11384 if (kind == 'values') return {
11385 value: entry.value,
11386 done: false
11387 };
11388 return {
11389 value: [entry.key, entry.value],
11390 done: false
11391 };
11392 }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); // `{ Map, Set }.prototype[@@species]` accessors
11393 // https://tc39.es/ecma262/#sec-get-map-@@species
11394 // https://tc39.es/ecma262/#sec-get-set-@@species
11395
11396 setSpecies(CONSTRUCTOR_NAME);
11397 }
11398};
11399
11400var collection$1 = collection$2;
11401var collectionStrong$1 = collectionStrong$2; // `Map` constructor
11402// https://tc39.es/ecma262/#sec-map-objects
11403
11404collection$1('Map', function (init) {
11405 return function Map() {
11406 return init(this, arguments.length ? arguments[0] : undefined);
11407 };
11408}, collectionStrong$1);
11409
11410var path$1 = path$s;
11411var map$2 = path$1.Map;
11412
11413var parent$6 = map$2;
11414var map$1 = parent$6;
11415
11416var map = map$1;
11417
11418var collection = collection$2;
11419var collectionStrong = collectionStrong$2; // `Set` constructor
11420// https://tc39.es/ecma262/#sec-set-objects
11421
11422collection('Set', function (init) {
11423 return function Set() {
11424 return init(this, arguments.length ? arguments[0] : undefined);
11425 };
11426}, collectionStrong);
11427
11428var path = path$s;
11429var set$2 = path.Set;
11430
11431var parent$5 = set$2;
11432var set$1 = parent$5;
11433
11434var set = set$1;
11435
11436var iterator = iterator$3;
11437
11438var anObject = anObject$b;
11439var getIteratorMethod = getIteratorMethod$7;
11440
11441var getIterator$4 = function (it) {
11442 var iteratorMethod = getIteratorMethod(it);
11443
11444 if (typeof iteratorMethod != 'function') {
11445 throw TypeError(String(it) + ' is not iterable');
11446 }
11447
11448 return anObject(iteratorMethod.call(it));
11449};
11450
11451var getIterator$3 = getIterator$4;
11452var getIterator_1 = getIterator$3;
11453
11454var parent$4 = getIterator_1;
11455var getIterator$2 = parent$4;
11456
11457var parent$3 = getIterator$2;
11458var getIterator$1 = parent$3;
11459
11460var getIterator = getIterator$1;
11461
11462var $ = _export;
11463var $some = arrayIteration.some;
11464var arrayMethodIsStrict = arrayMethodIsStrict$5;
11465var STRICT_METHOD = arrayMethodIsStrict('some'); // `Array.prototype.some` method
11466// https://tc39.es/ecma262/#sec-array.prototype.some
11467
11468$({
11469 target: 'Array',
11470 proto: true,
11471 forced: !STRICT_METHOD
11472}, {
11473 some: function some(callbackfn
11474 /* , thisArg */
11475 ) {
11476 return $some(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
11477 }
11478});
11479
11480var entryVirtual$2 = entryVirtual$k;
11481var some$3 = entryVirtual$2('Array').some;
11482
11483var some$2 = some$3;
11484var ArrayPrototype$2 = Array.prototype;
11485
11486var some_1 = function (it) {
11487 var own = it.some;
11488 return it === ArrayPrototype$2 || it instanceof Array && own === ArrayPrototype$2.some ? some$2 : own;
11489};
11490
11491var parent$2 = some_1;
11492var some$1 = parent$2;
11493
11494var some = some$1;
11495
11496var entryVirtual$1 = entryVirtual$k;
11497var keys$3 = entryVirtual$1('Array').keys;
11498
11499var parent$1 = keys$3;
11500var keys$2 = parent$1;
11501
11502var keys$1 = keys$2;
11503var classof$1 = classof$9;
11504var ArrayPrototype$1 = Array.prototype;
11505var DOMIterables$1 = {
11506 DOMTokenList: true,
11507 NodeList: true
11508};
11509
11510var keys_1 = function (it) {
11511 var own = it.keys;
11512 return it === ArrayPrototype$1 || it instanceof Array && own === ArrayPrototype$1.keys // eslint-disable-next-line no-prototype-builtins -- safe
11513 || DOMIterables$1.hasOwnProperty(classof$1(it)) ? keys$1 : own;
11514};
11515
11516var keys = keys_1;
11517
11518var entryVirtual = entryVirtual$k;
11519var entries$3 = entryVirtual('Array').entries;
11520
11521var parent = entries$3;
11522var entries$2 = parent;
11523
11524var entries$1 = entries$2;
11525var classof = classof$9;
11526var ArrayPrototype = Array.prototype;
11527var DOMIterables = {
11528 DOMTokenList: true,
11529 NodeList: true
11530};
11531
11532var entries_1 = function (it) {
11533 var own = it.entries;
11534 return it === ArrayPrototype || it instanceof Array && own === ArrayPrototype.entries // eslint-disable-next-line no-prototype-builtins -- safe
11535 || DOMIterables.hasOwnProperty(classof(it)) ? entries$1 : own;
11536};
11537
11538var entries = entries_1;
11539
11540// Unique ID creation requires a high quality random # generator. In the browser we therefore
11541// require the crypto API and do not support built-in fallback to lower quality random number
11542// generators (like Math.random()).
11543var getRandomValues;
11544var rnds8 = new Uint8Array(16);
11545function rng() {
11546 // lazy load so that environments that need to polyfill have a chance to do so
11547 if (!getRandomValues) {
11548 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
11549 // find the complete implementation of crypto (msCrypto) on IE11.
11550 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
11551
11552 if (!getRandomValues) {
11553 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
11554 }
11555 }
11556
11557 return getRandomValues(rnds8);
11558}
11559
11560var 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;
11561
11562function validate(uuid) {
11563 return typeof uuid === 'string' && REGEX.test(uuid);
11564}
11565
11566/**
11567 * Convert array of 16 byte values to UUID string format of the form:
11568 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
11569 */
11570
11571var byteToHex = [];
11572
11573for (var i = 0; i < 256; ++i) {
11574 byteToHex.push((i + 0x100).toString(16).substr(1));
11575}
11576
11577function stringify(arr) {
11578 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; // Note: Be careful editing this code! It's been tuned for performance
11579 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
11580
11581 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
11582 // of the following:
11583 // - One or more input array values don't map to a hex octet (leading to
11584 // "undefined" in the uuid)
11585 // - Invalid input values for the RFC `version` or `variant` fields
11586
11587 if (!validate(uuid)) {
11588 throw TypeError('Stringified UUID is invalid');
11589 }
11590
11591 return uuid;
11592}
11593
11594function v4(options, buf, offset) {
11595 options = options || {};
11596 var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
11597
11598 rnds[6] = rnds[6] & 0x0f | 0x40;
11599 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
11600
11601 if (buf) {
11602 offset = offset || 0;
11603
11604 for (var i = 0; i < 16; ++i) {
11605 buf[offset + i] = rnds[i];
11606 }
11607
11608 return buf;
11609 }
11610
11611 return stringify(rnds);
11612}
11613
11614function ownKeys(object, enumerableOnly) { var keys = keys$4(object); if (getOwnPropertySymbols) { var symbols = getOwnPropertySymbols(object); if (enumerableOnly) { symbols = filter(symbols).call(symbols, function (sym) { return getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
11615
11616function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context32; forEach$1(_context32 = ownKeys(Object(source), true)).call(_context32, function (key) { _defineProperty(target, key, source[key]); }); } else if (getOwnPropertyDescriptors) { defineProperties(target, getOwnPropertyDescriptors(source)); } else { var _context33; forEach$1(_context33 = ownKeys(Object(source))).call(_context33, function (key) { defineProperty$5(target, key, getOwnPropertyDescriptor(source, key)); }); } } return target; }
11617
11618function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11619
11620function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !construct) return false; if (construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11621
11622function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof symbol !== "undefined" && getIteratorMethod$2(o) || o["@@iterator"]; if (!it) { if (isArray$5(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
11623
11624function _unsupportedIterableToArray(o, minLen) { var _context31; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = slice$1(_context31 = Object.prototype.toString.call(o)).call(_context31, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return from$2(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11625
11626function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
11627/**
11628 * Create new data pipe.
11629 *
11630 * @param from - The source data set or data view.
11631 *
11632 * @remarks
11633 * Example usage:
11634 * ```typescript
11635 * interface AppItem {
11636 * whoami: string;
11637 * appData: unknown;
11638 * visData: VisItem;
11639 * }
11640 * interface VisItem {
11641 * id: number;
11642 * label: string;
11643 * color: string;
11644 * x: number;
11645 * y: number;
11646 * }
11647 *
11648 * const ds1 = new DataSet<AppItem, "whoami">([], { fieldId: "whoami" });
11649 * const ds2 = new DataSet<VisItem, "id">();
11650 *
11651 * const pipe = createNewDataPipeFrom(ds1)
11652 * .filter((item): boolean => item.enabled === true)
11653 * .map<VisItem, "id">((item): VisItem => item.visData)
11654 * .to(ds2);
11655 *
11656 * pipe.start();
11657 * ```
11658 *
11659 * @returns A factory whose methods can be used to configure the pipe.
11660 */
11661
11662function createNewDataPipeFrom(from) {
11663 return new DataPipeUnderConstruction(from);
11664}
11665/**
11666 * Internal implementation of the pipe. This should be accessible only through
11667 * `createNewDataPipeFrom` from the outside.
11668 *
11669 * @typeParam SI - Source item type.
11670 * @typeParam SP - Source item type's id property name.
11671 * @typeParam TI - Target item type.
11672 * @typeParam TP - Target item type's id property name.
11673 */
11674
11675
11676var SimpleDataPipe = /*#__PURE__*/function () {
11677 /**
11678 * Create a new data pipe.
11679 *
11680 * @param _source - The data set or data view that will be observed.
11681 * @param _transformers - An array of transforming functions to be used to
11682 * filter or transform the items in the pipe.
11683 * @param _target - The data set or data view that will receive the items.
11684 */
11685 function SimpleDataPipe(_source, _transformers, _target) {
11686 var _context, _context2, _context3;
11687
11688 _classCallCheck(this, SimpleDataPipe);
11689
11690 this._source = _source;
11691 this._transformers = _transformers;
11692 this._target = _target;
11693 /**
11694 * Bound listeners for use with `DataInterface['on' | 'off']`.
11695 */
11696
11697 this._listeners = {
11698 add: bind$4(_context = this._add).call(_context, this),
11699 remove: bind$4(_context2 = this._remove).call(_context2, this),
11700 update: bind$4(_context3 = this._update).call(_context3, this)
11701 };
11702 }
11703 /** @inheritDoc */
11704
11705
11706 _createClass(SimpleDataPipe, [{
11707 key: "all",
11708 value: function all() {
11709 this._target.update(this._transformItems(this._source.get()));
11710
11711 return this;
11712 }
11713 /** @inheritDoc */
11714
11715 }, {
11716 key: "start",
11717 value: function start() {
11718 this._source.on("add", this._listeners.add);
11719
11720 this._source.on("remove", this._listeners.remove);
11721
11722 this._source.on("update", this._listeners.update);
11723
11724 return this;
11725 }
11726 /** @inheritDoc */
11727
11728 }, {
11729 key: "stop",
11730 value: function stop() {
11731 this._source.off("add", this._listeners.add);
11732
11733 this._source.off("remove", this._listeners.remove);
11734
11735 this._source.off("update", this._listeners.update);
11736
11737 return this;
11738 }
11739 /**
11740 * Apply the transformers to the items.
11741 *
11742 * @param items - The items to be transformed.
11743 *
11744 * @returns The transformed items.
11745 */
11746
11747 }, {
11748 key: "_transformItems",
11749 value: function _transformItems(items) {
11750 var _context4;
11751
11752 return reduce(_context4 = this._transformers).call(_context4, function (items, transform) {
11753 return transform(items);
11754 }, items);
11755 }
11756 /**
11757 * Handle an add event.
11758 *
11759 * @param _name - Ignored.
11760 * @param payload - The payload containing the ids of the added items.
11761 */
11762
11763 }, {
11764 key: "_add",
11765 value: function _add(_name, payload) {
11766 if (payload == null) {
11767 return;
11768 }
11769
11770 this._target.add(this._transformItems(this._source.get(payload.items)));
11771 }
11772 /**
11773 * Handle an update event.
11774 *
11775 * @param _name - Ignored.
11776 * @param payload - The payload containing the ids of the updated items.
11777 */
11778
11779 }, {
11780 key: "_update",
11781 value: function _update(_name, payload) {
11782 if (payload == null) {
11783 return;
11784 }
11785
11786 this._target.update(this._transformItems(this._source.get(payload.items)));
11787 }
11788 /**
11789 * Handle a remove event.
11790 *
11791 * @param _name - Ignored.
11792 * @param payload - The payload containing the data of the removed items.
11793 */
11794
11795 }, {
11796 key: "_remove",
11797 value: function _remove(_name, payload) {
11798 if (payload == null) {
11799 return;
11800 }
11801
11802 this._target.remove(this._transformItems(payload.oldData));
11803 }
11804 }]);
11805
11806 return SimpleDataPipe;
11807}();
11808/**
11809 * Internal implementation of the pipe factory. This should be accessible
11810 * only through `createNewDataPipeFrom` from the outside.
11811 *
11812 * @typeParam TI - Target item type.
11813 * @typeParam TP - Target item type's id property name.
11814 */
11815
11816
11817var DataPipeUnderConstruction = /*#__PURE__*/function () {
11818 /**
11819 * Create a new data pipe factory. This is an internal constructor that
11820 * should never be called from outside of this file.
11821 *
11822 * @param _source - The source data set or data view for this pipe.
11823 */
11824 function DataPipeUnderConstruction(_source) {
11825 _classCallCheck(this, DataPipeUnderConstruction);
11826
11827 this._source = _source;
11828 /**
11829 * Array transformers used to transform items within the pipe. This is typed
11830 * as any for the sake of simplicity.
11831 */
11832
11833 this._transformers = [];
11834 }
11835 /**
11836 * Filter the items.
11837 *
11838 * @param callback - A filtering function that returns true if given item
11839 * should be piped and false if not.
11840 *
11841 * @returns This factory for further configuration.
11842 */
11843
11844
11845 _createClass(DataPipeUnderConstruction, [{
11846 key: "filter",
11847 value: function filter$1(callback) {
11848 this._transformers.push(function (input) {
11849 return filter(input).call(input, callback);
11850 });
11851
11852 return this;
11853 }
11854 /**
11855 * Map each source item to a new type.
11856 *
11857 * @param callback - A mapping function that takes a source item and returns
11858 * corresponding mapped item.
11859 *
11860 * @typeParam TI - Target item type.
11861 * @typeParam TP - Target item type's id property name.
11862 *
11863 * @returns This factory for further configuration.
11864 */
11865
11866 }, {
11867 key: "map",
11868 value: function map(callback) {
11869 this._transformers.push(function (input) {
11870 return map$3(input).call(input, callback);
11871 });
11872
11873 return this;
11874 }
11875 /**
11876 * Map each source item to zero or more items of a new type.
11877 *
11878 * @param callback - A mapping function that takes a source item and returns
11879 * an array of corresponding mapped items.
11880 *
11881 * @typeParam TI - Target item type.
11882 * @typeParam TP - Target item type's id property name.
11883 *
11884 * @returns This factory for further configuration.
11885 */
11886
11887 }, {
11888 key: "flatMap",
11889 value: function flatMap$1(callback) {
11890 this._transformers.push(function (input) {
11891 return flatMap(input).call(input, callback);
11892 });
11893
11894 return this;
11895 }
11896 /**
11897 * Connect this pipe to given data set.
11898 *
11899 * @param target - The data set that will receive the items from this pipe.
11900 *
11901 * @returns The pipe connected between given data sets and performing
11902 * configured transformation on the processed items.
11903 */
11904
11905 }, {
11906 key: "to",
11907 value: function to(target) {
11908 return new SimpleDataPipe(this._source, this._transformers, target);
11909 }
11910 }]);
11911
11912 return DataPipeUnderConstruction;
11913}();
11914/**
11915 * Determine whether a value can be used as an id.
11916 *
11917 * @param value - Input value of unknown type.
11918 *
11919 * @returns True if the value is valid id, false otherwise.
11920 */
11921
11922
11923function isId(value) {
11924 return typeof value === "string" || typeof value === "number";
11925}
11926/**
11927 * A queue.
11928 *
11929 * @typeParam T - The type of method names to be replaced by queued versions.
11930 */
11931
11932
11933var Queue = /*#__PURE__*/function () {
11934 /**
11935 * Construct a new Queue.
11936 *
11937 * @param options - Queue configuration.
11938 */
11939 function Queue(options) {
11940 _classCallCheck(this, Queue);
11941
11942 this._queue = [];
11943 this._timeout = null;
11944 this._extended = null; // options
11945
11946 this.delay = null;
11947 this.max = Infinity;
11948 this.setOptions(options);
11949 }
11950 /**
11951 * Update the configuration of the queue.
11952 *
11953 * @param options - Queue configuration.
11954 */
11955
11956
11957 _createClass(Queue, [{
11958 key: "setOptions",
11959 value: function setOptions(options) {
11960 if (options && typeof options.delay !== "undefined") {
11961 this.delay = options.delay;
11962 }
11963
11964 if (options && typeof options.max !== "undefined") {
11965 this.max = options.max;
11966 }
11967
11968 this._flushIfNeeded();
11969 }
11970 /**
11971 * Extend an object with queuing functionality.
11972 * The object will be extended with a function flush, and the methods provided in options.replace will be replaced with queued ones.
11973 *
11974 * @param object - The object to be extended.
11975 * @param options - Additional options.
11976 *
11977 * @returns The created queue.
11978 */
11979
11980 }, {
11981 key: "destroy",
11982 value:
11983 /**
11984 * Destroy the queue. The queue will first flush all queued actions, and in case it has extended an object, will restore the original object.
11985 */
11986 function destroy() {
11987 this.flush();
11988
11989 if (this._extended) {
11990 var object = this._extended.object;
11991 var methods = this._extended.methods;
11992
11993 for (var i = 0; i < methods.length; i++) {
11994 var method = methods[i];
11995
11996 if (method.original) {
11997 // @TODO: better solution?
11998 object[method.name] = method.original;
11999 } else {
12000 // @TODO: better solution?
12001 delete object[method.name];
12002 }
12003 }
12004
12005 this._extended = null;
12006 }
12007 }
12008 /**
12009 * Replace a method on an object with a queued version.
12010 *
12011 * @param object - Object having the method.
12012 * @param method - The method name.
12013 */
12014
12015 }, {
12016 key: "replace",
12017 value: function replace(object, method) {
12018 /* eslint-disable-next-line @typescript-eslint/no-this-alias -- Function this is necessary in the function bellow, so class this has to be saved into a variable here. */
12019 var me = this;
12020 var original = object[method];
12021
12022 if (!original) {
12023 throw new Error("Method " + method + " undefined");
12024 }
12025
12026 object[method] = function () {
12027 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
12028 args[_key] = arguments[_key];
12029 }
12030
12031 // add this call to the queue
12032 me.queue({
12033 args: args,
12034 fn: original,
12035 context: this
12036 });
12037 };
12038 }
12039 /**
12040 * Queue a call.
12041 *
12042 * @param entry - The function or entry to be queued.
12043 */
12044
12045 }, {
12046 key: "queue",
12047 value: function queue(entry) {
12048 if (typeof entry === "function") {
12049 this._queue.push({
12050 fn: entry
12051 });
12052 } else {
12053 this._queue.push(entry);
12054 }
12055
12056 this._flushIfNeeded();
12057 }
12058 /**
12059 * Check whether the queue needs to be flushed.
12060 */
12061
12062 }, {
12063 key: "_flushIfNeeded",
12064 value: function _flushIfNeeded() {
12065 var _this = this;
12066
12067 // flush when the maximum is exceeded.
12068 if (this._queue.length > this.max) {
12069 this.flush();
12070 } // flush after a period of inactivity when a delay is configured
12071
12072
12073 if (this._timeout != null) {
12074 clearTimeout(this._timeout);
12075 this._timeout = null;
12076 }
12077
12078 if (this.queue.length > 0 && typeof this.delay === "number") {
12079 this._timeout = setTimeout$1(function () {
12080 _this.flush();
12081 }, this.delay);
12082 }
12083 }
12084 /**
12085 * Flush all queued calls
12086 */
12087
12088 }, {
12089 key: "flush",
12090 value: function flush() {
12091 var _context5, _context6;
12092
12093 forEach$1(_context5 = splice(_context6 = this._queue).call(_context6, 0)).call(_context5, function (entry) {
12094 entry.fn.apply(entry.context || entry.fn, entry.args || []);
12095 });
12096 }
12097 }], [{
12098 key: "extend",
12099 value: function extend(object, options) {
12100 var queue = new Queue(options);
12101
12102 if (object.flush !== undefined) {
12103 throw new Error("Target object already has a property flush");
12104 }
12105
12106 object.flush = function () {
12107 queue.flush();
12108 };
12109
12110 var methods = [{
12111 name: "flush",
12112 original: undefined
12113 }];
12114
12115 if (options && options.replace) {
12116 for (var i = 0; i < options.replace.length; i++) {
12117 var name = options.replace[i];
12118 methods.push({
12119 name: name,
12120 // @TODO: better solution?
12121 original: object[name]
12122 }); // @TODO: better solution?
12123
12124 queue.replace(object, name);
12125 }
12126 }
12127
12128 queue._extended = {
12129 object: object,
12130 methods: methods
12131 };
12132 return queue;
12133 }
12134 }]);
12135
12136 return Queue;
12137}();
12138/**
12139 * [[DataSet]] code that can be reused in [[DataView]] or other similar implementations of [[DataInterface]].
12140 *
12141 * @typeParam Item - Item type that may or may not have an id.
12142 * @typeParam IdProp - Name of the property that contains the id.
12143 */
12144
12145
12146var DataSetPart = /*#__PURE__*/function () {
12147 function DataSetPart() {
12148 _classCallCheck(this, DataSetPart);
12149
12150 this._subscribers = {
12151 "*": [],
12152 add: [],
12153 remove: [],
12154 update: []
12155 };
12156 /**
12157 * @deprecated Use on instead (PS: DataView.subscribe === DataView.on).
12158 */
12159
12160 this.subscribe = DataSetPart.prototype.on;
12161 /**
12162 * @deprecated Use off instead (PS: DataView.unsubscribe === DataView.off).
12163 */
12164
12165 this.unsubscribe = DataSetPart.prototype.off;
12166 }
12167 /**
12168 * Trigger an event
12169 *
12170 * @param event - Event name.
12171 * @param payload - Event payload.
12172 * @param senderId - Id of the sender.
12173 */
12174
12175
12176 _createClass(DataSetPart, [{
12177 key: "_trigger",
12178 value: function _trigger(event, payload, senderId) {
12179 var _context7, _context8;
12180
12181 if (event === "*") {
12182 throw new Error("Cannot trigger event *");
12183 }
12184
12185 forEach$1(_context7 = concat(_context8 = []).call(_context8, _toConsumableArray(this._subscribers[event]), _toConsumableArray(this._subscribers["*"]))).call(_context7, function (subscriber) {
12186 subscriber(event, payload, senderId != null ? senderId : null);
12187 });
12188 }
12189 /**
12190 * Subscribe to an event, add an event listener.
12191 *
12192 * @remarks Non-function callbacks are ignored.
12193 *
12194 * @param event - Event name.
12195 * @param callback - Callback method.
12196 */
12197
12198 }, {
12199 key: "on",
12200 value: function on(event, callback) {
12201 if (typeof callback === "function") {
12202 this._subscribers[event].push(callback);
12203 } // @TODO: Maybe throw for invalid callbacks?
12204
12205 }
12206 /**
12207 * Unsubscribe from an event, remove an event listener.
12208 *
12209 * @remarks If the same callback was subscribed more than once **all** occurences will be removed.
12210 *
12211 * @param event - Event name.
12212 * @param callback - Callback method.
12213 */
12214
12215 }, {
12216 key: "off",
12217 value: function off(event, callback) {
12218 var _context9;
12219
12220 this._subscribers[event] = filter(_context9 = this._subscribers[event]).call(_context9, function (subscriber) {
12221 return subscriber !== callback;
12222 });
12223 }
12224 }]);
12225
12226 return DataSetPart;
12227}();
12228/**
12229 * Data stream
12230 *
12231 * @remarks
12232 * [[DataStream]] offers an always up to date stream of items from a [[DataSet]] or [[DataView]].
12233 * That means that the stream is evaluated at the time of iteration, conversion to another data type or when [[cache]] is called, not when the [[DataStream]] was created.
12234 * Multiple invocations of for example [[toItemArray]] may yield different results (if the data source like for example [[DataSet]] gets modified).
12235 *
12236 * @typeParam Item - The item type this stream is going to work with.
12237 */
12238
12239
12240var DataStream = /*#__PURE__*/function (_Symbol$iterator) {
12241 /**
12242 * Create a new data stream.
12243 *
12244 * @param pairs - The id, item pairs.
12245 */
12246 function DataStream(pairs) {
12247 _classCallCheck(this, DataStream);
12248
12249 this._pairs = pairs;
12250 }
12251 /**
12252 * Return an iterable of key, value pairs for every entry in the stream.
12253 */
12254
12255
12256 _createClass(DataStream, [{
12257 key: _Symbol$iterator,
12258 value:
12259 /*#__PURE__*/
12260 regenerator.mark(function value() {
12261 var _iterator, _step, _step$value, id, item;
12262
12263 return regenerator.wrap(function value$(_context10) {
12264 while (1) {
12265 switch (_context10.prev = _context10.next) {
12266 case 0:
12267 _iterator = _createForOfIteratorHelper(this._pairs);
12268 _context10.prev = 1;
12269
12270 _iterator.s();
12271
12272 case 3:
12273 if ((_step = _iterator.n()).done) {
12274 _context10.next = 9;
12275 break;
12276 }
12277
12278 _step$value = _slicedToArray(_step.value, 2), id = _step$value[0], item = _step$value[1];
12279 _context10.next = 7;
12280 return [id, item];
12281
12282 case 7:
12283 _context10.next = 3;
12284 break;
12285
12286 case 9:
12287 _context10.next = 14;
12288 break;
12289
12290 case 11:
12291 _context10.prev = 11;
12292 _context10.t0 = _context10["catch"](1);
12293
12294 _iterator.e(_context10.t0);
12295
12296 case 14:
12297 _context10.prev = 14;
12298
12299 _iterator.f();
12300
12301 return _context10.finish(14);
12302
12303 case 17:
12304 case "end":
12305 return _context10.stop();
12306 }
12307 }
12308 }, value, this, [[1, 11, 14, 17]]);
12309 })
12310 /**
12311 * Return an iterable of key, value pairs for every entry in the stream.
12312 */
12313
12314 }, {
12315 key: "entries",
12316 value:
12317 /*#__PURE__*/
12318 regenerator.mark(function entries() {
12319 var _iterator2, _step2, _step2$value, id, item;
12320
12321 return regenerator.wrap(function entries$(_context11) {
12322 while (1) {
12323 switch (_context11.prev = _context11.next) {
12324 case 0:
12325 _iterator2 = _createForOfIteratorHelper(this._pairs);
12326 _context11.prev = 1;
12327
12328 _iterator2.s();
12329
12330 case 3:
12331 if ((_step2 = _iterator2.n()).done) {
12332 _context11.next = 9;
12333 break;
12334 }
12335
12336 _step2$value = _slicedToArray(_step2.value, 2), id = _step2$value[0], item = _step2$value[1];
12337 _context11.next = 7;
12338 return [id, item];
12339
12340 case 7:
12341 _context11.next = 3;
12342 break;
12343
12344 case 9:
12345 _context11.next = 14;
12346 break;
12347
12348 case 11:
12349 _context11.prev = 11;
12350 _context11.t0 = _context11["catch"](1);
12351
12352 _iterator2.e(_context11.t0);
12353
12354 case 14:
12355 _context11.prev = 14;
12356
12357 _iterator2.f();
12358
12359 return _context11.finish(14);
12360
12361 case 17:
12362 case "end":
12363 return _context11.stop();
12364 }
12365 }
12366 }, entries, this, [[1, 11, 14, 17]]);
12367 })
12368 /**
12369 * Return an iterable of keys in the stream.
12370 */
12371
12372 }, {
12373 key: "keys",
12374 value:
12375 /*#__PURE__*/
12376 regenerator.mark(function keys() {
12377 var _iterator3, _step3, _step3$value, id;
12378
12379 return regenerator.wrap(function keys$(_context12) {
12380 while (1) {
12381 switch (_context12.prev = _context12.next) {
12382 case 0:
12383 _iterator3 = _createForOfIteratorHelper(this._pairs);
12384 _context12.prev = 1;
12385
12386 _iterator3.s();
12387
12388 case 3:
12389 if ((_step3 = _iterator3.n()).done) {
12390 _context12.next = 9;
12391 break;
12392 }
12393
12394 _step3$value = _slicedToArray(_step3.value, 1), id = _step3$value[0];
12395 _context12.next = 7;
12396 return id;
12397
12398 case 7:
12399 _context12.next = 3;
12400 break;
12401
12402 case 9:
12403 _context12.next = 14;
12404 break;
12405
12406 case 11:
12407 _context12.prev = 11;
12408 _context12.t0 = _context12["catch"](1);
12409
12410 _iterator3.e(_context12.t0);
12411
12412 case 14:
12413 _context12.prev = 14;
12414
12415 _iterator3.f();
12416
12417 return _context12.finish(14);
12418
12419 case 17:
12420 case "end":
12421 return _context12.stop();
12422 }
12423 }
12424 }, keys, this, [[1, 11, 14, 17]]);
12425 })
12426 /**
12427 * Return an iterable of values in the stream.
12428 */
12429
12430 }, {
12431 key: "values",
12432 value:
12433 /*#__PURE__*/
12434 regenerator.mark(function values() {
12435 var _iterator4, _step4, _step4$value, item;
12436
12437 return regenerator.wrap(function values$(_context13) {
12438 while (1) {
12439 switch (_context13.prev = _context13.next) {
12440 case 0:
12441 _iterator4 = _createForOfIteratorHelper(this._pairs);
12442 _context13.prev = 1;
12443
12444 _iterator4.s();
12445
12446 case 3:
12447 if ((_step4 = _iterator4.n()).done) {
12448 _context13.next = 9;
12449 break;
12450 }
12451
12452 _step4$value = _slicedToArray(_step4.value, 2), item = _step4$value[1];
12453 _context13.next = 7;
12454 return item;
12455
12456 case 7:
12457 _context13.next = 3;
12458 break;
12459
12460 case 9:
12461 _context13.next = 14;
12462 break;
12463
12464 case 11:
12465 _context13.prev = 11;
12466 _context13.t0 = _context13["catch"](1);
12467
12468 _iterator4.e(_context13.t0);
12469
12470 case 14:
12471 _context13.prev = 14;
12472
12473 _iterator4.f();
12474
12475 return _context13.finish(14);
12476
12477 case 17:
12478 case "end":
12479 return _context13.stop();
12480 }
12481 }
12482 }, values, this, [[1, 11, 14, 17]]);
12483 })
12484 /**
12485 * Return an array containing all the ids in this stream.
12486 *
12487 * @remarks
12488 * The array may contain duplicities.
12489 *
12490 * @returns The array with all ids from this stream.
12491 */
12492
12493 }, {
12494 key: "toIdArray",
12495 value: function toIdArray() {
12496 var _context14;
12497
12498 return map$3(_context14 = _toConsumableArray(this._pairs)).call(_context14, function (pair) {
12499 return pair[0];
12500 });
12501 }
12502 /**
12503 * Return an array containing all the items in this stream.
12504 *
12505 * @remarks
12506 * The array may contain duplicities.
12507 *
12508 * @returns The array with all items from this stream.
12509 */
12510
12511 }, {
12512 key: "toItemArray",
12513 value: function toItemArray() {
12514 var _context15;
12515
12516 return map$3(_context15 = _toConsumableArray(this._pairs)).call(_context15, function (pair) {
12517 return pair[1];
12518 });
12519 }
12520 /**
12521 * Return an array containing all the entries in this stream.
12522 *
12523 * @remarks
12524 * The array may contain duplicities.
12525 *
12526 * @returns The array with all entries from this stream.
12527 */
12528
12529 }, {
12530 key: "toEntryArray",
12531 value: function toEntryArray() {
12532 return _toConsumableArray(this._pairs);
12533 }
12534 /**
12535 * Return an object map containing all the items in this stream accessible by ids.
12536 *
12537 * @remarks
12538 * In case of duplicate ids (coerced to string so `7 == '7'`) the last encoutered appears in the returned object.
12539 *
12540 * @returns The object map of all id → item pairs from this stream.
12541 */
12542
12543 }, {
12544 key: "toObjectMap",
12545 value: function toObjectMap() {
12546 var map = create$4(null);
12547
12548 var _iterator5 = _createForOfIteratorHelper(this._pairs),
12549 _step5;
12550
12551 try {
12552 for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
12553 var _step5$value = _slicedToArray(_step5.value, 2),
12554 id = _step5$value[0],
12555 item = _step5$value[1];
12556
12557 map[id] = item;
12558 }
12559 } catch (err) {
12560 _iterator5.e(err);
12561 } finally {
12562 _iterator5.f();
12563 }
12564
12565 return map;
12566 }
12567 /**
12568 * Return a map containing all the items in this stream accessible by ids.
12569 *
12570 * @returns The map of all id → item pairs from this stream.
12571 */
12572
12573 }, {
12574 key: "toMap",
12575 value: function toMap() {
12576 return new map(this._pairs);
12577 }
12578 /**
12579 * Return a set containing all the (unique) ids in this stream.
12580 *
12581 * @returns The set of all ids from this stream.
12582 */
12583
12584 }, {
12585 key: "toIdSet",
12586 value: function toIdSet() {
12587 return new set(this.toIdArray());
12588 }
12589 /**
12590 * Return a set containing all the (unique) items in this stream.
12591 *
12592 * @returns The set of all items from this stream.
12593 */
12594
12595 }, {
12596 key: "toItemSet",
12597 value: function toItemSet() {
12598 return new set(this.toItemArray());
12599 }
12600 /**
12601 * Cache the items from this stream.
12602 *
12603 * @remarks
12604 * This method allows for items to be fetched immediatelly and used (possibly multiple times) later.
12605 * It can also be used to optimize performance as [[DataStream]] would otherwise reevaluate everything upon each iteration.
12606 *
12607 * ## Example
12608 * ```javascript
12609 * const ds = new DataSet([…])
12610 *
12611 * const cachedStream = ds.stream()
12612 * .filter(…)
12613 * .sort(…)
12614 * .map(…)
12615 * .cached(…) // Data are fetched, processed and cached here.
12616 *
12617 * ds.clear()
12618 * chachedStream // Still has all the items.
12619 * ```
12620 *
12621 * @returns A new [[DataStream]] with cached items (detached from the original [[DataSet]]).
12622 */
12623
12624 }, {
12625 key: "cache",
12626 value: function cache() {
12627 return new DataStream(_toConsumableArray(this._pairs));
12628 }
12629 /**
12630 * Get the distinct values of given property.
12631 *
12632 * @param callback - The function that picks and possibly converts the property.
12633 *
12634 * @typeParam T - The type of the distinct value.
12635 *
12636 * @returns A set of all distinct properties.
12637 */
12638
12639 }, {
12640 key: "distinct",
12641 value: function distinct(callback) {
12642 var set$1 = new set();
12643
12644 var _iterator6 = _createForOfIteratorHelper(this._pairs),
12645 _step6;
12646
12647 try {
12648 for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
12649 var _step6$value = _slicedToArray(_step6.value, 2),
12650 id = _step6$value[0],
12651 item = _step6$value[1];
12652
12653 set$1.add(callback(item, id));
12654 }
12655 } catch (err) {
12656 _iterator6.e(err);
12657 } finally {
12658 _iterator6.f();
12659 }
12660
12661 return set$1;
12662 }
12663 /**
12664 * Filter the items of the stream.
12665 *
12666 * @param callback - The function that decides whether an item will be included.
12667 *
12668 * @returns A new data stream with the filtered items.
12669 */
12670
12671 }, {
12672 key: "filter",
12673 value: function filter(callback) {
12674 var pairs = this._pairs;
12675 return new DataStream(_defineProperty({}, iterator, /*#__PURE__*/regenerator.mark(function _callee() {
12676 var _iterator7, _step7, _step7$value, id, item;
12677
12678 return regenerator.wrap(function _callee$(_context16) {
12679 while (1) {
12680 switch (_context16.prev = _context16.next) {
12681 case 0:
12682 _iterator7 = _createForOfIteratorHelper(pairs);
12683 _context16.prev = 1;
12684
12685 _iterator7.s();
12686
12687 case 3:
12688 if ((_step7 = _iterator7.n()).done) {
12689 _context16.next = 10;
12690 break;
12691 }
12692
12693 _step7$value = _slicedToArray(_step7.value, 2), id = _step7$value[0], item = _step7$value[1];
12694
12695 if (!callback(item, id)) {
12696 _context16.next = 8;
12697 break;
12698 }
12699
12700 _context16.next = 8;
12701 return [id, item];
12702
12703 case 8:
12704 _context16.next = 3;
12705 break;
12706
12707 case 10:
12708 _context16.next = 15;
12709 break;
12710
12711 case 12:
12712 _context16.prev = 12;
12713 _context16.t0 = _context16["catch"](1);
12714
12715 _iterator7.e(_context16.t0);
12716
12717 case 15:
12718 _context16.prev = 15;
12719
12720 _iterator7.f();
12721
12722 return _context16.finish(15);
12723
12724 case 18:
12725 case "end":
12726 return _context16.stop();
12727 }
12728 }
12729 }, _callee, null, [[1, 12, 15, 18]]);
12730 })));
12731 }
12732 /**
12733 * Execute a callback for each item of the stream.
12734 *
12735 * @param callback - The function that will be invoked for each item.
12736 */
12737
12738 }, {
12739 key: "forEach",
12740 value: function forEach(callback) {
12741 var _iterator8 = _createForOfIteratorHelper(this._pairs),
12742 _step8;
12743
12744 try {
12745 for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
12746 var _step8$value = _slicedToArray(_step8.value, 2),
12747 id = _step8$value[0],
12748 item = _step8$value[1];
12749
12750 callback(item, id);
12751 }
12752 } catch (err) {
12753 _iterator8.e(err);
12754 } finally {
12755 _iterator8.f();
12756 }
12757 }
12758 /**
12759 * Map the items into a different type.
12760 *
12761 * @param callback - The function that does the conversion.
12762 *
12763 * @typeParam Mapped - The type of the item after mapping.
12764 *
12765 * @returns A new data stream with the mapped items.
12766 */
12767
12768 }, {
12769 key: "map",
12770 value: function map(callback) {
12771 var pairs = this._pairs;
12772 return new DataStream(_defineProperty({}, iterator, /*#__PURE__*/regenerator.mark(function _callee2() {
12773 var _iterator9, _step9, _step9$value, id, item;
12774
12775 return regenerator.wrap(function _callee2$(_context17) {
12776 while (1) {
12777 switch (_context17.prev = _context17.next) {
12778 case 0:
12779 _iterator9 = _createForOfIteratorHelper(pairs);
12780 _context17.prev = 1;
12781
12782 _iterator9.s();
12783
12784 case 3:
12785 if ((_step9 = _iterator9.n()).done) {
12786 _context17.next = 9;
12787 break;
12788 }
12789
12790 _step9$value = _slicedToArray(_step9.value, 2), id = _step9$value[0], item = _step9$value[1];
12791 _context17.next = 7;
12792 return [id, callback(item, id)];
12793
12794 case 7:
12795 _context17.next = 3;
12796 break;
12797
12798 case 9:
12799 _context17.next = 14;
12800 break;
12801
12802 case 11:
12803 _context17.prev = 11;
12804 _context17.t0 = _context17["catch"](1);
12805
12806 _iterator9.e(_context17.t0);
12807
12808 case 14:
12809 _context17.prev = 14;
12810
12811 _iterator9.f();
12812
12813 return _context17.finish(14);
12814
12815 case 17:
12816 case "end":
12817 return _context17.stop();
12818 }
12819 }
12820 }, _callee2, null, [[1, 11, 14, 17]]);
12821 })));
12822 }
12823 /**
12824 * Get the item with the maximum value of given property.
12825 *
12826 * @param callback - The function that picks and possibly converts the property.
12827 *
12828 * @returns The item with the maximum if found otherwise null.
12829 */
12830
12831 }, {
12832 key: "max",
12833 value: function max(callback) {
12834 var iter = getIterator(this._pairs);
12835
12836 var curr = iter.next();
12837
12838 if (curr.done) {
12839 return null;
12840 }
12841
12842 var maxItem = curr.value[1];
12843 var maxValue = callback(curr.value[1], curr.value[0]);
12844
12845 while (!(curr = iter.next()).done) {
12846 var _curr$value = _slicedToArray(curr.value, 2),
12847 id = _curr$value[0],
12848 item = _curr$value[1];
12849
12850 var _value = callback(item, id);
12851
12852 if (_value > maxValue) {
12853 maxValue = _value;
12854 maxItem = item;
12855 }
12856 }
12857
12858 return maxItem;
12859 }
12860 /**
12861 * Get the item with the minimum value of given property.
12862 *
12863 * @param callback - The function that picks and possibly converts the property.
12864 *
12865 * @returns The item with the minimum if found otherwise null.
12866 */
12867
12868 }, {
12869 key: "min",
12870 value: function min(callback) {
12871 var iter = getIterator(this._pairs);
12872
12873 var curr = iter.next();
12874
12875 if (curr.done) {
12876 return null;
12877 }
12878
12879 var minItem = curr.value[1];
12880 var minValue = callback(curr.value[1], curr.value[0]);
12881
12882 while (!(curr = iter.next()).done) {
12883 var _curr$value2 = _slicedToArray(curr.value, 2),
12884 id = _curr$value2[0],
12885 item = _curr$value2[1];
12886
12887 var _value2 = callback(item, id);
12888
12889 if (_value2 < minValue) {
12890 minValue = _value2;
12891 minItem = item;
12892 }
12893 }
12894
12895 return minItem;
12896 }
12897 /**
12898 * Reduce the items into a single value.
12899 *
12900 * @param callback - The function that does the reduction.
12901 * @param accumulator - The initial value of the accumulator.
12902 *
12903 * @typeParam T - The type of the accumulated value.
12904 *
12905 * @returns The reduced value.
12906 */
12907
12908 }, {
12909 key: "reduce",
12910 value: function reduce(callback, accumulator) {
12911 var _iterator10 = _createForOfIteratorHelper(this._pairs),
12912 _step10;
12913
12914 try {
12915 for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
12916 var _step10$value = _slicedToArray(_step10.value, 2),
12917 id = _step10$value[0],
12918 item = _step10$value[1];
12919
12920 accumulator = callback(accumulator, item, id);
12921 }
12922 } catch (err) {
12923 _iterator10.e(err);
12924 } finally {
12925 _iterator10.f();
12926 }
12927
12928 return accumulator;
12929 }
12930 /**
12931 * Sort the items.
12932 *
12933 * @param callback - Item comparator.
12934 *
12935 * @returns A new stream with sorted items.
12936 */
12937
12938 }, {
12939 key: "sort",
12940 value: function sort$1(callback) {
12941 var _this2 = this;
12942
12943 return new DataStream(_defineProperty({}, iterator, function () {
12944 var _context18;
12945
12946 return getIterator(sort(_context18 = _toConsumableArray(_this2._pairs)).call(_context18, function (_ref, _ref2) {
12947 var _ref3 = _slicedToArray(_ref, 2),
12948 idA = _ref3[0],
12949 itemA = _ref3[1];
12950
12951 var _ref4 = _slicedToArray(_ref2, 2),
12952 idB = _ref4[0],
12953 itemB = _ref4[1];
12954
12955 return callback(itemA, itemB, idA, idB);
12956 }));
12957 }));
12958 }
12959 }]);
12960
12961 return DataStream;
12962}(iterator);
12963/**
12964 * Add an id to given item if it doesn't have one already.
12965 *
12966 * @remarks
12967 * The item will be modified.
12968 *
12969 * @param item - The item that will have an id after a call to this function.
12970 * @param idProp - The key of the id property.
12971 *
12972 * @typeParam Item - Item type that may or may not have an id.
12973 * @typeParam IdProp - Name of the property that contains the id.
12974 *
12975 * @returns true
12976 */
12977
12978
12979function ensureFullItem(item, idProp) {
12980 if (item[idProp] == null) {
12981 // generate an id
12982 item[idProp] = v4();
12983 }
12984
12985 return item;
12986}
12987/**
12988 * # DataSet
12989 *
12990 * Vis.js comes with a flexible DataSet, which can be used to hold and
12991 * manipulate unstructured data and listen for changes in the data. The DataSet
12992 * is key/value based. Data items can be added, updated and removed from the
12993 * DataSet, and one can subscribe to changes in the DataSet. The data in the
12994 * DataSet can be filtered and ordered. Data can be normalized when appending it
12995 * to the DataSet as well.
12996 *
12997 * ## Example
12998 *
12999 * The following example shows how to use a DataSet.
13000 *
13001 * ```javascript
13002 * // create a DataSet
13003 * var options = {};
13004 * var data = new vis.DataSet(options);
13005 *
13006 * // add items
13007 * // note that the data items can contain different properties and data formats
13008 * data.add([
13009 * {id: 1, text: 'item 1', date: new Date(2013, 6, 20), group: 1, first: true},
13010 * {id: 2, text: 'item 2', date: '2013-06-23', group: 2},
13011 * {id: 3, text: 'item 3', date: '2013-06-25', group: 2},
13012 * {id: 4, text: 'item 4'}
13013 * ]);
13014 *
13015 * // subscribe to any change in the DataSet
13016 * data.on('*', function (event, properties, senderId) {
13017 * console.log('event', event, properties);
13018 * });
13019 *
13020 * // update an existing item
13021 * data.update({id: 2, group: 1});
13022 *
13023 * // remove an item
13024 * data.remove(4);
13025 *
13026 * // get all ids
13027 * var ids = data.getIds();
13028 * console.log('ids', ids);
13029 *
13030 * // get a specific item
13031 * var item1 = data.get(1);
13032 * console.log('item1', item1);
13033 *
13034 * // retrieve a filtered subset of the data
13035 * var items = data.get({
13036 * filter: function (item) {
13037 * return item.group == 1;
13038 * }
13039 * });
13040 * console.log('filtered items', items);
13041 * ```
13042 *
13043 * @typeParam Item - Item type that may or may not have an id.
13044 * @typeParam IdProp - Name of the property that contains the id.
13045 */
13046
13047
13048var DataSet = /*#__PURE__*/function (_DataSetPart) {
13049 _inherits(DataSet, _DataSetPart);
13050
13051 var _super = _createSuper(DataSet);
13052
13053 /**
13054 * Construct a new DataSet.
13055 *
13056 * @param data - Initial data or options.
13057 * @param options - Options (type error if data is also options).
13058 */
13059 function DataSet(data, options) {
13060 var _this3;
13061
13062 _classCallCheck(this, DataSet);
13063
13064 _this3 = _super.call(this);
13065 _this3._queue = null; // correctly read optional arguments
13066
13067 if (data && !isArray$5(data)) {
13068 options = data;
13069 data = [];
13070 }
13071
13072 _this3._options = options || {};
13073 _this3._data = new map(); // map with data indexed by id
13074
13075 _this3.length = 0; // number of items in the DataSet
13076
13077 _this3._idProp = _this3._options.fieldId || "id"; // name of the field containing id
13078 // add initial data when provided
13079
13080 if (data && data.length) {
13081 _this3.add(data);
13082 }
13083
13084 _this3.setOptions(options);
13085
13086 return _this3;
13087 }
13088 /** @inheritDoc */
13089
13090
13091 _createClass(DataSet, [{
13092 key: "idProp",
13093 get: function get() {
13094 return this._idProp;
13095 }
13096 /**
13097 * Set new options.
13098 *
13099 * @param options - The new options.
13100 */
13101
13102 }, {
13103 key: "setOptions",
13104 value: function setOptions(options) {
13105 if (options && options.queue !== undefined) {
13106 if (options.queue === false) {
13107 // delete queue if loaded
13108 if (this._queue) {
13109 this._queue.destroy();
13110
13111 this._queue = null;
13112 }
13113 } else {
13114 // create queue and update its options
13115 if (!this._queue) {
13116 this._queue = Queue.extend(this, {
13117 replace: ["add", "update", "remove"]
13118 });
13119 }
13120
13121 if (options.queue && _typeof(options.queue) === "object") {
13122 this._queue.setOptions(options.queue);
13123 }
13124 }
13125 }
13126 }
13127 /**
13128 * Add a data item or an array with items.
13129 *
13130 * After the items are added to the DataSet, the DataSet will trigger an event `add`. When a `senderId` is provided, this id will be passed with the triggered event to all subscribers.
13131 *
13132 * ## Example
13133 *
13134 * ```javascript
13135 * // create a DataSet
13136 * const data = new vis.DataSet()
13137 *
13138 * // add items
13139 * const ids = data.add([
13140 * { id: 1, text: 'item 1' },
13141 * { id: 2, text: 'item 2' },
13142 * { text: 'item without an id' }
13143 * ])
13144 *
13145 * console.log(ids) // [1, 2, '<UUIDv4>']
13146 * ```
13147 *
13148 * @param data - Items to be added (ids will be generated if missing).
13149 * @param senderId - Sender id.
13150 *
13151 * @returns addedIds - Array with the ids (generated if not present) of the added items.
13152 *
13153 * @throws When an item with the same id as any of the added items already exists.
13154 */
13155
13156 }, {
13157 key: "add",
13158 value: function add(data, senderId) {
13159 var _this4 = this;
13160
13161 var addedIds = [];
13162 var id;
13163
13164 if (isArray$5(data)) {
13165 // Array
13166 var idsToAdd = map$3(data).call(data, function (d) {
13167 return d[_this4._idProp];
13168 });
13169
13170 if (some(idsToAdd).call(idsToAdd, function (id) {
13171 return _this4._data.has(id);
13172 })) {
13173 throw new Error("A duplicate id was found in the parameter array.");
13174 }
13175
13176 for (var i = 0, len = data.length; i < len; i++) {
13177 id = this._addItem(data[i]);
13178 addedIds.push(id);
13179 }
13180 } else if (data && _typeof(data) === "object") {
13181 // Single item
13182 id = this._addItem(data);
13183 addedIds.push(id);
13184 } else {
13185 throw new Error("Unknown dataType");
13186 }
13187
13188 if (addedIds.length) {
13189 this._trigger("add", {
13190 items: addedIds
13191 }, senderId);
13192 }
13193
13194 return addedIds;
13195 }
13196 /**
13197 * Update existing items. When an item does not exist, it will be created.
13198 *
13199 * @remarks
13200 * The provided properties will be merged in the existing item. When an item does not exist, it will be created.
13201 *
13202 * After the items are updated, the DataSet will trigger an event `add` for the added items, and an event `update`. When a `senderId` is provided, this id will be passed with the triggered event to all subscribers.
13203 *
13204 * ## Example
13205 *
13206 * ```javascript
13207 * // create a DataSet
13208 * const data = new vis.DataSet([
13209 * { id: 1, text: 'item 1' },
13210 * { id: 2, text: 'item 2' },
13211 * { id: 3, text: 'item 3' }
13212 * ])
13213 *
13214 * // update items
13215 * const ids = data.update([
13216 * { id: 2, text: 'item 2 (updated)' },
13217 * { id: 4, text: 'item 4 (new)' }
13218 * ])
13219 *
13220 * console.log(ids) // [2, 4]
13221 * ```
13222 *
13223 * ## Warning for TypeScript users
13224 * This method may introduce partial items into the data set. Use add or updateOnly instead for better type safety.
13225 *
13226 * @param data - Items to be updated (if the id is already present) or added (if the id is missing).
13227 * @param senderId - Sender id.
13228 *
13229 * @returns updatedIds - The ids of the added (these may be newly generated if there was no id in the item from the data) or updated items.
13230 *
13231 * @throws When the supplied data is neither an item nor an array of items.
13232 */
13233
13234 }, {
13235 key: "update",
13236 value: function update(data, senderId) {
13237 var _this5 = this;
13238
13239 var addedIds = [];
13240 var updatedIds = [];
13241 var oldData = [];
13242 var updatedData = [];
13243 var idProp = this._idProp;
13244
13245 var addOrUpdate = function addOrUpdate(item) {
13246 var origId = item[idProp];
13247
13248 if (origId != null && _this5._data.has(origId)) {
13249 var fullItem = item; // it has an id, therefore it is a fullitem
13250
13251 var oldItem = assign$2({}, _this5._data.get(origId)); // update item
13252
13253
13254 var id = _this5._updateItem(fullItem);
13255
13256 updatedIds.push(id);
13257 updatedData.push(fullItem);
13258 oldData.push(oldItem);
13259 } else {
13260 // add new item
13261 var _id = _this5._addItem(item);
13262
13263 addedIds.push(_id);
13264 }
13265 };
13266
13267 if (isArray$5(data)) {
13268 // Array
13269 for (var i = 0, len = data.length; i < len; i++) {
13270 if (data[i] && _typeof(data[i]) === "object") {
13271 addOrUpdate(data[i]);
13272 } else {
13273 console.warn("Ignoring input item, which is not an object at index " + i);
13274 }
13275 }
13276 } else if (data && _typeof(data) === "object") {
13277 // Single item
13278 addOrUpdate(data);
13279 } else {
13280 throw new Error("Unknown dataType");
13281 }
13282
13283 if (addedIds.length) {
13284 this._trigger("add", {
13285 items: addedIds
13286 }, senderId);
13287 }
13288
13289 if (updatedIds.length) {
13290 var props = {
13291 items: updatedIds,
13292 oldData: oldData,
13293 data: updatedData
13294 }; // TODO: remove deprecated property 'data' some day
13295 //Object.defineProperty(props, 'data', {
13296 // 'get': (function() {
13297 // console.warn('Property data is deprecated. Use DataSet.get(ids) to retrieve the new data, use the oldData property on this object to get the old data');
13298 // return updatedData;
13299 // }).bind(this)
13300 //});
13301
13302 this._trigger("update", props, senderId);
13303 }
13304
13305 return concat(addedIds).call(addedIds, updatedIds);
13306 }
13307 /**
13308 * Update existing items. When an item does not exist, an error will be thrown.
13309 *
13310 * @remarks
13311 * The provided properties will be deeply merged into the existing item.
13312 * When an item does not exist (id not present in the data set or absent), an error will be thrown and nothing will be changed.
13313 *
13314 * After the items are updated, the DataSet will trigger an event `update`.
13315 * When a `senderId` is provided, this id will be passed with the triggered event to all subscribers.
13316 *
13317 * ## Example
13318 *
13319 * ```javascript
13320 * // create a DataSet
13321 * const data = new vis.DataSet([
13322 * { id: 1, text: 'item 1' },
13323 * { id: 2, text: 'item 2' },
13324 * { id: 3, text: 'item 3' },
13325 * ])
13326 *
13327 * // update items
13328 * const ids = data.update([
13329 * { id: 2, text: 'item 2 (updated)' }, // works
13330 * // { id: 4, text: 'item 4 (new)' }, // would throw
13331 * // { text: 'item 4 (new)' }, // would also throw
13332 * ])
13333 *
13334 * console.log(ids) // [2]
13335 * ```
13336 *
13337 * @param data - Updates (the id and optionally other props) to the items in this data set.
13338 * @param senderId - Sender id.
13339 *
13340 * @returns updatedIds - The ids of the updated items.
13341 *
13342 * @throws When the supplied data is neither an item nor an array of items, when the ids are missing.
13343 */
13344
13345 }, {
13346 key: "updateOnly",
13347 value: function updateOnly(data, senderId) {
13348 var _context19,
13349 _this6 = this;
13350
13351 if (!isArray$5(data)) {
13352 data = [data];
13353 }
13354
13355 var updateEventData = map$3(_context19 = map$3(data).call(data, function (update) {
13356 var oldData = _this6._data.get(update[_this6._idProp]);
13357
13358 if (oldData == null) {
13359 throw new Error("Updating non-existent items is not allowed.");
13360 }
13361
13362 return {
13363 oldData: oldData,
13364 update: update
13365 };
13366 })).call(_context19, function (_ref5) {
13367 var oldData = _ref5.oldData,
13368 update = _ref5.update;
13369 var id = oldData[_this6._idProp];
13370 var updatedData = pureDeepObjectAssign(oldData, update);
13371
13372 _this6._data.set(id, updatedData);
13373
13374 return {
13375 id: id,
13376 oldData: oldData,
13377 updatedData: updatedData
13378 };
13379 });
13380
13381 if (updateEventData.length) {
13382 var props = {
13383 items: map$3(updateEventData).call(updateEventData, function (value) {
13384 return value.id;
13385 }),
13386 oldData: map$3(updateEventData).call(updateEventData, function (value) {
13387 return value.oldData;
13388 }),
13389 data: map$3(updateEventData).call(updateEventData, function (value) {
13390 return value.updatedData;
13391 })
13392 }; // TODO: remove deprecated property 'data' some day
13393 //Object.defineProperty(props, 'data', {
13394 // 'get': (function() {
13395 // console.warn('Property data is deprecated. Use DataSet.get(ids) to retrieve the new data, use the oldData property on this object to get the old data');
13396 // return updatedData;
13397 // }).bind(this)
13398 //});
13399
13400 this._trigger("update", props, senderId);
13401
13402 return props.items;
13403 } else {
13404 return [];
13405 }
13406 }
13407 /** @inheritDoc */
13408
13409 }, {
13410 key: "get",
13411 value: function get(first, second) {
13412 // @TODO: Woudn't it be better to split this into multiple methods?
13413 // parse the arguments
13414 var id = undefined;
13415 var ids = undefined;
13416 var options = undefined;
13417
13418 if (isId(first)) {
13419 // get(id [, options])
13420 id = first;
13421 options = second;
13422 } else if (isArray$5(first)) {
13423 // get(ids [, options])
13424 ids = first;
13425 options = second;
13426 } else {
13427 // get([, options])
13428 options = first;
13429 } // determine the return type
13430
13431
13432 var returnType = options && options.returnType === "Object" ? "Object" : "Array"; // @TODO: WTF is this? Or am I missing something?
13433 // var returnType
13434 // if (options && options.returnType) {
13435 // var allowedValues = ['Array', 'Object']
13436 // returnType =
13437 // allowedValues.indexOf(options.returnType) == -1
13438 // ? 'Array'
13439 // : options.returnType
13440 // } else {
13441 // returnType = 'Array'
13442 // }
13443 // build options
13444
13445 var filter$1 = options && filter(options);
13446
13447 var items = [];
13448 var item = undefined;
13449 var itemIds = undefined;
13450 var itemId = undefined; // convert items
13451
13452 if (id != null) {
13453 // return a single item
13454 item = this._data.get(id);
13455
13456 if (item && filter$1 && !filter$1(item)) {
13457 item = undefined;
13458 }
13459 } else if (ids != null) {
13460 // return a subset of items
13461 for (var i = 0, len = ids.length; i < len; i++) {
13462 item = this._data.get(ids[i]);
13463
13464 if (item != null && (!filter$1 || filter$1(item))) {
13465 items.push(item);
13466 }
13467 }
13468 } else {
13469 var _context20;
13470
13471 // return all items
13472 itemIds = _toConsumableArray(keys(_context20 = this._data).call(_context20));
13473
13474 for (var _i = 0, _len2 = itemIds.length; _i < _len2; _i++) {
13475 itemId = itemIds[_i];
13476 item = this._data.get(itemId);
13477
13478 if (item != null && (!filter$1 || filter$1(item))) {
13479 items.push(item);
13480 }
13481 }
13482 } // order the results
13483
13484
13485 if (options && options.order && id == undefined) {
13486 this._sort(items, options.order);
13487 } // filter fields of the items
13488
13489
13490 if (options && options.fields) {
13491 var fields = options.fields;
13492
13493 if (id != undefined && item != null) {
13494 item = this._filterFields(item, fields);
13495 } else {
13496 for (var _i2 = 0, _len3 = items.length; _i2 < _len3; _i2++) {
13497 items[_i2] = this._filterFields(items[_i2], fields);
13498 }
13499 }
13500 } // return the results
13501
13502
13503 if (returnType == "Object") {
13504 var result = {};
13505
13506 for (var _i3 = 0, _len4 = items.length; _i3 < _len4; _i3++) {
13507 var resultant = items[_i3]; // @TODO: Shoudn't this be this._fieldId?
13508 // result[resultant.id] = resultant
13509
13510 var _id2 = resultant[this._idProp];
13511 result[_id2] = resultant;
13512 }
13513
13514 return result;
13515 } else {
13516 if (id != null) {
13517 var _item;
13518
13519 // a single item
13520 return (_item = item) !== null && _item !== void 0 ? _item : null;
13521 } else {
13522 // just return our array
13523 return items;
13524 }
13525 }
13526 }
13527 /** @inheritDoc */
13528
13529 }, {
13530 key: "getIds",
13531 value: function getIds(options) {
13532 var data = this._data;
13533
13534 var filter$1 = options && filter(options);
13535
13536 var order = options && options.order;
13537
13538 var itemIds = _toConsumableArray(keys(data).call(data));
13539
13540 var ids = [];
13541
13542 if (filter$1) {
13543 // get filtered items
13544 if (order) {
13545 // create ordered list
13546 var items = [];
13547
13548 for (var i = 0, len = itemIds.length; i < len; i++) {
13549 var id = itemIds[i];
13550
13551 var item = this._data.get(id);
13552
13553 if (item != null && filter$1(item)) {
13554 items.push(item);
13555 }
13556 }
13557
13558 this._sort(items, order);
13559
13560 for (var _i4 = 0, _len5 = items.length; _i4 < _len5; _i4++) {
13561 ids.push(items[_i4][this._idProp]);
13562 }
13563 } else {
13564 // create unordered list
13565 for (var _i5 = 0, _len6 = itemIds.length; _i5 < _len6; _i5++) {
13566 var _id3 = itemIds[_i5];
13567
13568 var _item2 = this._data.get(_id3);
13569
13570 if (_item2 != null && filter$1(_item2)) {
13571 ids.push(_item2[this._idProp]);
13572 }
13573 }
13574 }
13575 } else {
13576 // get all items
13577 if (order) {
13578 // create an ordered list
13579 var _items = [];
13580
13581 for (var _i6 = 0, _len7 = itemIds.length; _i6 < _len7; _i6++) {
13582 var _id4 = itemIds[_i6];
13583
13584 _items.push(data.get(_id4));
13585 }
13586
13587 this._sort(_items, order);
13588
13589 for (var _i7 = 0, _len8 = _items.length; _i7 < _len8; _i7++) {
13590 ids.push(_items[_i7][this._idProp]);
13591 }
13592 } else {
13593 // create unordered list
13594 for (var _i8 = 0, _len9 = itemIds.length; _i8 < _len9; _i8++) {
13595 var _id5 = itemIds[_i8];
13596
13597 var _item3 = data.get(_id5);
13598
13599 if (_item3 != null) {
13600 ids.push(_item3[this._idProp]);
13601 }
13602 }
13603 }
13604 }
13605
13606 return ids;
13607 }
13608 /** @inheritDoc */
13609
13610 }, {
13611 key: "getDataSet",
13612 value: function getDataSet() {
13613 return this;
13614 }
13615 /** @inheritDoc */
13616
13617 }, {
13618 key: "forEach",
13619 value: function forEach(callback, options) {
13620 var filter$1 = options && filter(options);
13621
13622 var data = this._data;
13623
13624 var itemIds = _toConsumableArray(keys(data).call(data));
13625
13626 if (options && options.order) {
13627 // execute forEach on ordered list
13628 var items = this.get(options);
13629
13630 for (var i = 0, len = items.length; i < len; i++) {
13631 var item = items[i];
13632 var id = item[this._idProp];
13633 callback(item, id);
13634 }
13635 } else {
13636 // unordered
13637 for (var _i9 = 0, _len10 = itemIds.length; _i9 < _len10; _i9++) {
13638 var _id6 = itemIds[_i9];
13639
13640 var _item4 = this._data.get(_id6);
13641
13642 if (_item4 != null && (!filter$1 || filter$1(_item4))) {
13643 callback(_item4, _id6);
13644 }
13645 }
13646 }
13647 }
13648 /** @inheritDoc */
13649
13650 }, {
13651 key: "map",
13652 value: function map(callback, options) {
13653 var filter$1 = options && filter(options);
13654
13655 var mappedItems = [];
13656 var data = this._data;
13657
13658 var itemIds = _toConsumableArray(keys(data).call(data)); // convert and filter items
13659
13660
13661 for (var i = 0, len = itemIds.length; i < len; i++) {
13662 var id = itemIds[i];
13663
13664 var item = this._data.get(id);
13665
13666 if (item != null && (!filter$1 || filter$1(item))) {
13667 mappedItems.push(callback(item, id));
13668 }
13669 } // order items
13670
13671
13672 if (options && options.order) {
13673 this._sort(mappedItems, options.order);
13674 }
13675
13676 return mappedItems;
13677 }
13678 /**
13679 * Filter the fields of an item.
13680 *
13681 * @param item - The item whose fields should be filtered.
13682 * @param fields - The names of the fields that will be kept.
13683 *
13684 * @typeParam K - Field name type.
13685 *
13686 * @returns The item without any additional fields.
13687 */
13688
13689 }, {
13690 key: "_filterFields",
13691 value: function _filterFields(item, fields) {
13692 var _context21;
13693
13694 if (!item) {
13695 // item is null
13696 return item;
13697 }
13698
13699 return reduce(_context21 = isArray$5(fields) ? // Use the supplied array
13700 fields : // Use the keys of the supplied object
13701 keys$4(fields)).call(_context21, function (filteredItem, field) {
13702 filteredItem[field] = item[field];
13703 return filteredItem;
13704 }, {});
13705 }
13706 /**
13707 * Sort the provided array with items.
13708 *
13709 * @param items - Items to be sorted in place.
13710 * @param order - A field name or custom sort function.
13711 *
13712 * @typeParam T - The type of the items in the items array.
13713 */
13714
13715 }, {
13716 key: "_sort",
13717 value: function _sort(items, order) {
13718 if (typeof order === "string") {
13719 // order by provided field name
13720 var name = order; // field name
13721
13722 sort(items).call(items, function (a, b) {
13723 // @TODO: How to treat missing properties?
13724 var av = a[name];
13725 var bv = b[name];
13726 return av > bv ? 1 : av < bv ? -1 : 0;
13727 });
13728 } else if (typeof order === "function") {
13729 // order by sort function
13730 sort(items).call(items, order);
13731 } else {
13732 // TODO: extend order by an Object {field:string, direction:string}
13733 // where direction can be 'asc' or 'desc'
13734 throw new TypeError("Order must be a function or a string");
13735 }
13736 }
13737 /**
13738 * Remove an item or multiple items by “reference” (only the id is used) or by id.
13739 *
13740 * The method ignores removal of non-existing items, and returns an array containing the ids of the items which are actually removed from the DataSet.
13741 *
13742 * After the items are removed, the DataSet will trigger an event `remove` for the removed items. When a `senderId` is provided, this id will be passed with the triggered event to all subscribers.
13743 *
13744 * ## Example
13745 * ```javascript
13746 * // create a DataSet
13747 * const data = new vis.DataSet([
13748 * { id: 1, text: 'item 1' },
13749 * { id: 2, text: 'item 2' },
13750 * { id: 3, text: 'item 3' }
13751 * ])
13752 *
13753 * // remove items
13754 * const ids = data.remove([2, { id: 3 }, 4])
13755 *
13756 * console.log(ids) // [2, 3]
13757 * ```
13758 *
13759 * @param id - One or more items or ids of items to be removed.
13760 * @param senderId - Sender id.
13761 *
13762 * @returns The ids of the removed items.
13763 */
13764
13765 }, {
13766 key: "remove",
13767 value: function remove(id, senderId) {
13768 var removedIds = [];
13769 var removedItems = []; // force everything to be an array for simplicity
13770
13771 var ids = isArray$5(id) ? id : [id];
13772
13773 for (var i = 0, len = ids.length; i < len; i++) {
13774 var item = this._remove(ids[i]);
13775
13776 if (item) {
13777 var itemId = item[this._idProp];
13778
13779 if (itemId != null) {
13780 removedIds.push(itemId);
13781 removedItems.push(item);
13782 }
13783 }
13784 }
13785
13786 if (removedIds.length) {
13787 this._trigger("remove", {
13788 items: removedIds,
13789 oldData: removedItems
13790 }, senderId);
13791 }
13792
13793 return removedIds;
13794 }
13795 /**
13796 * Remove an item by its id or reference.
13797 *
13798 * @param id - Id of an item or the item itself.
13799 *
13800 * @returns The removed item if removed, null otherwise.
13801 */
13802
13803 }, {
13804 key: "_remove",
13805 value: function _remove(id) {
13806 // @TODO: It origianlly returned the item although the docs say id.
13807 // The code expects the item, so probably an error in the docs.
13808 var ident; // confirm the id to use based on the args type
13809
13810 if (isId(id)) {
13811 ident = id;
13812 } else if (id && _typeof(id) === "object") {
13813 ident = id[this._idProp]; // look for the identifier field using ._idProp
13814 } // do the removing if the item is found
13815
13816
13817 if (ident != null && this._data.has(ident)) {
13818 var item = this._data.get(ident) || null;
13819
13820 this._data.delete(ident);
13821
13822 --this.length;
13823 return item;
13824 }
13825
13826 return null;
13827 }
13828 /**
13829 * Clear the entire data set.
13830 *
13831 * After the items are removed, the [[DataSet]] will trigger an event `remove` for all removed items. When a `senderId` is provided, this id will be passed with the triggered event to all subscribers.
13832 *
13833 * @param senderId - Sender id.
13834 *
13835 * @returns removedIds - The ids of all removed items.
13836 */
13837
13838 }, {
13839 key: "clear",
13840 value: function clear(senderId) {
13841 var _context22;
13842
13843 var ids = _toConsumableArray(keys(_context22 = this._data).call(_context22));
13844
13845 var items = [];
13846
13847 for (var i = 0, len = ids.length; i < len; i++) {
13848 items.push(this._data.get(ids[i]));
13849 }
13850
13851 this._data.clear();
13852
13853 this.length = 0;
13854
13855 this._trigger("remove", {
13856 items: ids,
13857 oldData: items
13858 }, senderId);
13859
13860 return ids;
13861 }
13862 /**
13863 * Find the item with maximum value of a specified field.
13864 *
13865 * @param field - Name of the property that should be searched for max value.
13866 *
13867 * @returns Item containing max value, or null if no items.
13868 */
13869
13870 }, {
13871 key: "max",
13872 value: function max(field) {
13873 var _context23;
13874
13875 var max = null;
13876 var maxField = null;
13877
13878 var _iterator11 = _createForOfIteratorHelper(values(_context23 = this._data).call(_context23)),
13879 _step11;
13880
13881 try {
13882 for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
13883 var item = _step11.value;
13884 var itemField = item[field];
13885
13886 if (typeof itemField === "number" && (maxField == null || itemField > maxField)) {
13887 max = item;
13888 maxField = itemField;
13889 }
13890 }
13891 } catch (err) {
13892 _iterator11.e(err);
13893 } finally {
13894 _iterator11.f();
13895 }
13896
13897 return max || null;
13898 }
13899 /**
13900 * Find the item with minimum value of a specified field.
13901 *
13902 * @param field - Name of the property that should be searched for min value.
13903 *
13904 * @returns Item containing min value, or null if no items.
13905 */
13906
13907 }, {
13908 key: "min",
13909 value: function min(field) {
13910 var _context24;
13911
13912 var min = null;
13913 var minField = null;
13914
13915 var _iterator12 = _createForOfIteratorHelper(values(_context24 = this._data).call(_context24)),
13916 _step12;
13917
13918 try {
13919 for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
13920 var item = _step12.value;
13921 var itemField = item[field];
13922
13923 if (typeof itemField === "number" && (minField == null || itemField < minField)) {
13924 min = item;
13925 minField = itemField;
13926 }
13927 }
13928 } catch (err) {
13929 _iterator12.e(err);
13930 } finally {
13931 _iterator12.f();
13932 }
13933
13934 return min || null;
13935 }
13936 /**
13937 * Find all distinct values of a specified field
13938 *
13939 * @param prop - The property name whose distinct values should be returned.
13940 *
13941 * @returns Unordered array containing all distinct values. Items without specified property are ignored.
13942 */
13943
13944 }, {
13945 key: "distinct",
13946 value: function distinct(prop) {
13947 var data = this._data;
13948
13949 var itemIds = _toConsumableArray(keys(data).call(data));
13950
13951 var values = [];
13952 var count = 0;
13953
13954 for (var i = 0, len = itemIds.length; i < len; i++) {
13955 var id = itemIds[i];
13956 var item = data.get(id);
13957 var _value3 = item[prop];
13958 var exists = false;
13959
13960 for (var j = 0; j < count; j++) {
13961 if (values[j] == _value3) {
13962 exists = true;
13963 break;
13964 }
13965 }
13966
13967 if (!exists && _value3 !== undefined) {
13968 values[count] = _value3;
13969 count++;
13970 }
13971 }
13972
13973 return values;
13974 }
13975 /**
13976 * Add a single item. Will fail when an item with the same id already exists.
13977 *
13978 * @param item - A new item to be added.
13979 *
13980 * @returns Added item's id. An id is generated when it is not present in the item.
13981 */
13982
13983 }, {
13984 key: "_addItem",
13985 value: function _addItem(item) {
13986 var fullItem = ensureFullItem(item, this._idProp);
13987 var id = fullItem[this._idProp]; // check whether this id is already taken
13988
13989 if (this._data.has(id)) {
13990 // item already exists
13991 throw new Error("Cannot add item: item with id " + id + " already exists");
13992 }
13993
13994 this._data.set(id, fullItem);
13995
13996 ++this.length;
13997 return id;
13998 }
13999 /**
14000 * Update a single item: merge with existing item.
14001 * Will fail when the item has no id, or when there does not exist an item with the same id.
14002 *
14003 * @param update - The new item
14004 *
14005 * @returns The id of the updated item.
14006 */
14007
14008 }, {
14009 key: "_updateItem",
14010 value: function _updateItem(update) {
14011 var id = update[this._idProp];
14012
14013 if (id == null) {
14014 throw new Error("Cannot update item: item has no id (item: " + stringify$1(update) + ")");
14015 }
14016
14017 var item = this._data.get(id);
14018
14019 if (!item) {
14020 // item doesn't exist
14021 throw new Error("Cannot update item: no item with id " + id + " found");
14022 }
14023
14024 this._data.set(id, _objectSpread(_objectSpread({}, item), update));
14025
14026 return id;
14027 }
14028 /** @inheritDoc */
14029
14030 }, {
14031 key: "stream",
14032 value: function stream(ids) {
14033 if (ids) {
14034 var data = this._data;
14035 return new DataStream(_defineProperty({}, iterator, /*#__PURE__*/regenerator.mark(function _callee3() {
14036 var _iterator13, _step13, id, item;
14037
14038 return regenerator.wrap(function _callee3$(_context25) {
14039 while (1) {
14040 switch (_context25.prev = _context25.next) {
14041 case 0:
14042 _iterator13 = _createForOfIteratorHelper(ids);
14043 _context25.prev = 1;
14044
14045 _iterator13.s();
14046
14047 case 3:
14048 if ((_step13 = _iterator13.n()).done) {
14049 _context25.next = 11;
14050 break;
14051 }
14052
14053 id = _step13.value;
14054 item = data.get(id);
14055
14056 if (!(item != null)) {
14057 _context25.next = 9;
14058 break;
14059 }
14060
14061 _context25.next = 9;
14062 return [id, item];
14063
14064 case 9:
14065 _context25.next = 3;
14066 break;
14067
14068 case 11:
14069 _context25.next = 16;
14070 break;
14071
14072 case 13:
14073 _context25.prev = 13;
14074 _context25.t0 = _context25["catch"](1);
14075
14076 _iterator13.e(_context25.t0);
14077
14078 case 16:
14079 _context25.prev = 16;
14080
14081 _iterator13.f();
14082
14083 return _context25.finish(16);
14084
14085 case 19:
14086 case "end":
14087 return _context25.stop();
14088 }
14089 }
14090 }, _callee3, null, [[1, 13, 16, 19]]);
14091 })));
14092 } else {
14093 var _context26;
14094
14095 return new DataStream(_defineProperty({}, iterator, bind$4(_context26 = entries(this._data)).call(_context26, this._data)));
14096 }
14097 }
14098 }]);
14099
14100 return DataSet;
14101}(DataSetPart);
14102/**
14103 * DataView
14104 *
14105 * A DataView offers a filtered and/or formatted view on a DataSet. One can subscribe to changes in a DataView, and easily get filtered or formatted data without having to specify filters and field types all the time.
14106 *
14107 * ## Example
14108 * ```javascript
14109 * // create a DataSet
14110 * var data = new vis.DataSet();
14111 * data.add([
14112 * {id: 1, text: 'item 1', date: new Date(2013, 6, 20), group: 1, first: true},
14113 * {id: 2, text: 'item 2', date: '2013-06-23', group: 2},
14114 * {id: 3, text: 'item 3', date: '2013-06-25', group: 2},
14115 * {id: 4, text: 'item 4'}
14116 * ]);
14117 *
14118 * // create a DataView
14119 * // the view will only contain items having a property group with value 1,
14120 * // and will only output fields id, text, and date.
14121 * var view = new vis.DataView(data, {
14122 * filter: function (item) {
14123 * return (item.group == 1);
14124 * },
14125 * fields: ['id', 'text', 'date']
14126 * });
14127 *
14128 * // subscribe to any change in the DataView
14129 * view.on('*', function (event, properties, senderId) {
14130 * console.log('event', event, properties);
14131 * });
14132 *
14133 * // update an item in the data set
14134 * data.update({id: 2, group: 1});
14135 *
14136 * // get all ids in the view
14137 * var ids = view.getIds();
14138 * console.log('ids', ids); // will output [1, 2]
14139 *
14140 * // get all items in the view
14141 * var items = view.get();
14142 * ```
14143 *
14144 * @typeParam Item - Item type that may or may not have an id.
14145 * @typeParam IdProp - Name of the property that contains the id.
14146 */
14147
14148
14149var DataView = /*#__PURE__*/function (_DataSetPart2) {
14150 _inherits(DataView, _DataSetPart2);
14151
14152 var _super2 = _createSuper(DataView);
14153
14154 /**
14155 * Create a DataView.
14156 *
14157 * @param data - The instance containing data (directly or indirectly).
14158 * @param options - Options to configure this data view.
14159 */
14160 function DataView(data, options) {
14161 var _context27;
14162
14163 var _this7;
14164
14165 _classCallCheck(this, DataView);
14166
14167 _this7 = _super2.call(this);
14168 /** @inheritDoc */
14169
14170 _this7.length = 0;
14171 _this7._ids = new set(); // ids of the items currently in memory (just contains a boolean true)
14172
14173 _this7._options = options || {};
14174 _this7._listener = bind$4(_context27 = _this7._onEvent).call(_context27, _assertThisInitialized(_this7));
14175
14176 _this7.setData(data);
14177
14178 return _this7;
14179 }
14180 /** @inheritDoc */
14181
14182
14183 _createClass(DataView, [{
14184 key: "idProp",
14185 get: function get() {
14186 return this.getDataSet().idProp;
14187 } // TODO: implement a function .config() to dynamically update things like configured filter
14188 // and trigger changes accordingly
14189
14190 /**
14191 * Set a data source for the view.
14192 *
14193 * @param data - The instance containing data (directly or indirectly).
14194 *
14195 * @remarks
14196 * Note that when the data view is bound to a data set it won't be garbage
14197 * collected unless the data set is too. Use `dataView.setData(null)` or
14198 * `dataView.dispose()` to enable garbage collection before you lose the last
14199 * reference.
14200 */
14201
14202 }, {
14203 key: "setData",
14204 value: function setData(data) {
14205 if (this._data) {
14206 // unsubscribe from current dataset
14207 if (this._data.off) {
14208 this._data.off("*", this._listener);
14209 } // trigger a remove of all items in memory
14210
14211
14212 var ids = this._data.getIds({
14213 filter: filter(this._options)
14214 });
14215
14216 var items = this._data.get(ids);
14217
14218 this._ids.clear();
14219
14220 this.length = 0;
14221
14222 this._trigger("remove", {
14223 items: ids,
14224 oldData: items
14225 });
14226 }
14227
14228 if (data != null) {
14229 this._data = data; // trigger an add of all added items
14230
14231 var _ids = this._data.getIds({
14232 filter: filter(this._options)
14233 });
14234
14235 for (var i = 0, len = _ids.length; i < len; i++) {
14236 var id = _ids[i];
14237
14238 this._ids.add(id);
14239 }
14240
14241 this.length = _ids.length;
14242
14243 this._trigger("add", {
14244 items: _ids
14245 });
14246 } else {
14247 this._data = new DataSet();
14248 } // subscribe to new dataset
14249
14250
14251 if (this._data.on) {
14252 this._data.on("*", this._listener);
14253 }
14254 }
14255 /**
14256 * Refresh the DataView.
14257 * Useful when the DataView has a filter function containing a variable parameter.
14258 */
14259
14260 }, {
14261 key: "refresh",
14262 value: function refresh() {
14263 var ids = this._data.getIds({
14264 filter: filter(this._options)
14265 });
14266
14267 var oldIds = _toConsumableArray(this._ids);
14268
14269 var newIds = {};
14270 var addedIds = [];
14271 var removedIds = [];
14272 var removedItems = []; // check for additions
14273
14274 for (var i = 0, len = ids.length; i < len; i++) {
14275 var id = ids[i];
14276 newIds[id] = true;
14277
14278 if (!this._ids.has(id)) {
14279 addedIds.push(id);
14280
14281 this._ids.add(id);
14282 }
14283 } // check for removals
14284
14285
14286 for (var _i10 = 0, _len11 = oldIds.length; _i10 < _len11; _i10++) {
14287 var _id7 = oldIds[_i10];
14288
14289 var item = this._data.get(_id7);
14290
14291 if (item == null) {
14292 // @TODO: Investigate.
14293 // Doesn't happen during tests or examples.
14294 // Is it really impossible or could it eventually happen?
14295 // How to handle it if it does? The types guarantee non-nullable items.
14296 console.error("If you see this, report it please.");
14297 } else if (!newIds[_id7]) {
14298 removedIds.push(_id7);
14299 removedItems.push(item);
14300
14301 this._ids.delete(_id7);
14302 }
14303 }
14304
14305 this.length += addedIds.length - removedIds.length; // trigger events
14306
14307 if (addedIds.length) {
14308 this._trigger("add", {
14309 items: addedIds
14310 });
14311 }
14312
14313 if (removedIds.length) {
14314 this._trigger("remove", {
14315 items: removedIds,
14316 oldData: removedItems
14317 });
14318 }
14319 }
14320 /** @inheritDoc */
14321
14322 }, {
14323 key: "get",
14324 value: function get(first, second) {
14325 if (this._data == null) {
14326 return null;
14327 } // parse the arguments
14328
14329
14330 var ids = null;
14331 var options;
14332
14333 if (isId(first) || isArray$5(first)) {
14334 ids = first;
14335 options = second;
14336 } else {
14337 options = first;
14338 } // extend the options with the default options and provided options
14339
14340
14341 var viewOptions = assign$2({}, this._options, options); // create a combined filter method when needed
14342
14343
14344 var thisFilter = filter(this._options);
14345
14346 var optionsFilter = options && filter(options);
14347
14348 if (thisFilter && optionsFilter) {
14349 viewOptions.filter = function (item) {
14350 return thisFilter(item) && optionsFilter(item);
14351 };
14352 }
14353
14354 if (ids == null) {
14355 return this._data.get(viewOptions);
14356 } else {
14357 return this._data.get(ids, viewOptions);
14358 }
14359 }
14360 /** @inheritDoc */
14361
14362 }, {
14363 key: "getIds",
14364 value: function getIds(options) {
14365 if (this._data.length) {
14366 var defaultFilter = filter(this._options);
14367
14368 var optionsFilter = options != null ? filter(options) : null;
14369 var filter$1;
14370
14371 if (optionsFilter) {
14372 if (defaultFilter) {
14373 filter$1 = function filter(item) {
14374 return defaultFilter(item) && optionsFilter(item);
14375 };
14376 } else {
14377 filter$1 = optionsFilter;
14378 }
14379 } else {
14380 filter$1 = defaultFilter;
14381 }
14382
14383 return this._data.getIds({
14384 filter: filter$1,
14385 order: options && options.order
14386 });
14387 } else {
14388 return [];
14389 }
14390 }
14391 /** @inheritDoc */
14392
14393 }, {
14394 key: "forEach",
14395 value: function forEach(callback, options) {
14396 if (this._data) {
14397 var _context28;
14398
14399 var defaultFilter = filter(this._options);
14400
14401 var optionsFilter = options && filter(options);
14402
14403 var filter$1;
14404
14405 if (optionsFilter) {
14406 if (defaultFilter) {
14407 filter$1 = function filter(item) {
14408 return defaultFilter(item) && optionsFilter(item);
14409 };
14410 } else {
14411 filter$1 = optionsFilter;
14412 }
14413 } else {
14414 filter$1 = defaultFilter;
14415 }
14416
14417 forEach$1(_context28 = this._data).call(_context28, callback, {
14418 filter: filter$1,
14419 order: options && options.order
14420 });
14421 }
14422 }
14423 /** @inheritDoc */
14424
14425 }, {
14426 key: "map",
14427 value: function map(callback, options) {
14428 if (this._data) {
14429 var _context29;
14430
14431 var defaultFilter = filter(this._options);
14432
14433 var optionsFilter = options && filter(options);
14434
14435 var filter$1;
14436
14437 if (optionsFilter) {
14438 if (defaultFilter) {
14439 filter$1 = function filter(item) {
14440 return defaultFilter(item) && optionsFilter(item);
14441 };
14442 } else {
14443 filter$1 = optionsFilter;
14444 }
14445 } else {
14446 filter$1 = defaultFilter;
14447 }
14448
14449 return map$3(_context29 = this._data).call(_context29, callback, {
14450 filter: filter$1,
14451 order: options && options.order
14452 });
14453 } else {
14454 return [];
14455 }
14456 }
14457 /** @inheritDoc */
14458
14459 }, {
14460 key: "getDataSet",
14461 value: function getDataSet() {
14462 return this._data.getDataSet();
14463 }
14464 /** @inheritDoc */
14465
14466 }, {
14467 key: "stream",
14468 value: function stream(ids) {
14469 var _context30;
14470
14471 return this._data.stream(ids || _defineProperty({}, iterator, bind$4(_context30 = keys(this._ids)).call(_context30, this._ids)));
14472 }
14473 /**
14474 * Render the instance unusable prior to garbage collection.
14475 *
14476 * @remarks
14477 * The intention of this method is to help discover scenarios where the data
14478 * view is being used when the programmer thinks it has been garbage collected
14479 * already. It's stricter version of `dataView.setData(null)`.
14480 */
14481
14482 }, {
14483 key: "dispose",
14484 value: function dispose() {
14485 var _this$_data;
14486
14487 if ((_this$_data = this._data) !== null && _this$_data !== void 0 && _this$_data.off) {
14488 this._data.off("*", this._listener);
14489 }
14490
14491 var message = "This data view has already been disposed of.";
14492 var replacement = {
14493 get: function get() {
14494 throw new Error(message);
14495 },
14496 set: function set() {
14497 throw new Error(message);
14498 },
14499 configurable: false
14500 };
14501
14502 var _iterator14 = _createForOfIteratorHelper(ownKeys$1(DataView.prototype)),
14503 _step14;
14504
14505 try {
14506 for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
14507 var key = _step14.value;
14508
14509 defineProperty$5(this, key, replacement);
14510 }
14511 } catch (err) {
14512 _iterator14.e(err);
14513 } finally {
14514 _iterator14.f();
14515 }
14516 }
14517 /**
14518 * Event listener. Will propagate all events from the connected data set to the subscribers of the DataView, but will filter the items and only trigger when there are changes in the filtered data set.
14519 *
14520 * @param event - The name of the event.
14521 * @param params - Parameters of the event.
14522 * @param senderId - Id supplied by the sender.
14523 */
14524
14525 }, {
14526 key: "_onEvent",
14527 value: function _onEvent(event, params, senderId) {
14528 if (!params || !params.items || !this._data) {
14529 return;
14530 }
14531
14532 var ids = params.items;
14533 var addedIds = [];
14534 var updatedIds = [];
14535 var removedIds = [];
14536 var oldItems = [];
14537 var updatedItems = [];
14538 var removedItems = [];
14539
14540 switch (event) {
14541 case "add":
14542 // filter the ids of the added items
14543 for (var i = 0, len = ids.length; i < len; i++) {
14544 var id = ids[i];
14545 var item = this.get(id);
14546
14547 if (item) {
14548 this._ids.add(id);
14549
14550 addedIds.push(id);
14551 }
14552 }
14553
14554 break;
14555
14556 case "update":
14557 // determine the event from the views viewpoint: an updated
14558 // item can be added, updated, or removed from this view.
14559 for (var _i11 = 0, _len12 = ids.length; _i11 < _len12; _i11++) {
14560 var _id8 = ids[_i11];
14561
14562 var _item5 = this.get(_id8);
14563
14564 if (_item5) {
14565 if (this._ids.has(_id8)) {
14566 updatedIds.push(_id8);
14567 updatedItems.push(params.data[_i11]);
14568 oldItems.push(params.oldData[_i11]);
14569 } else {
14570 this._ids.add(_id8);
14571
14572 addedIds.push(_id8);
14573 }
14574 } else {
14575 if (this._ids.has(_id8)) {
14576 this._ids.delete(_id8);
14577
14578 removedIds.push(_id8);
14579 removedItems.push(params.oldData[_i11]);
14580 }
14581 }
14582 }
14583
14584 break;
14585
14586 case "remove":
14587 // filter the ids of the removed items
14588 for (var _i12 = 0, _len13 = ids.length; _i12 < _len13; _i12++) {
14589 var _id9 = ids[_i12];
14590
14591 if (this._ids.has(_id9)) {
14592 this._ids.delete(_id9);
14593
14594 removedIds.push(_id9);
14595 removedItems.push(params.oldData[_i12]);
14596 }
14597 }
14598
14599 break;
14600 }
14601
14602 this.length += addedIds.length - removedIds.length;
14603
14604 if (addedIds.length) {
14605 this._trigger("add", {
14606 items: addedIds
14607 }, senderId);
14608 }
14609
14610 if (updatedIds.length) {
14611 this._trigger("update", {
14612 items: updatedIds,
14613 oldData: oldItems,
14614 data: updatedItems
14615 }, senderId);
14616 }
14617
14618 if (removedIds.length) {
14619 this._trigger("remove", {
14620 items: removedIds,
14621 oldData: removedItems
14622 }, senderId);
14623 }
14624 }
14625 }]);
14626
14627 return DataView;
14628}(DataSetPart);
14629/**
14630 * Check that given value is compatible with Vis Data Set interface.
14631 *
14632 * @param idProp - The expected property to contain item id.
14633 * @param v - The value to be tested.
14634 *
14635 * @returns True if all expected values and methods match, false otherwise.
14636 */
14637
14638
14639function isDataSetLike(idProp, v) {
14640 return _typeof(v) === "object" && v !== null && idProp === v.idProp && typeof v.add === "function" && typeof v.clear === "function" && typeof v.distinct === "function" && typeof forEach$1(v) === "function" && typeof v.get === "function" && typeof v.getDataSet === "function" && typeof v.getIds === "function" && typeof v.length === "number" && typeof map$3(v) === "function" && typeof v.max === "function" && typeof v.min === "function" && typeof v.off === "function" && typeof v.on === "function" && typeof v.remove === "function" && typeof v.setOptions === "function" && typeof v.stream === "function" && typeof v.update === "function" && typeof v.updateOnly === "function";
14641}
14642/**
14643 * Check that given value is compatible with Vis Data View interface.
14644 *
14645 * @param idProp - The expected property to contain item id.
14646 * @param v - The value to be tested.
14647 *
14648 * @returns True if all expected values and methods match, false otherwise.
14649 */
14650
14651
14652function isDataViewLike(idProp, v) {
14653 return _typeof(v) === "object" && v !== null && idProp === v.idProp && typeof forEach$1(v) === "function" && typeof v.get === "function" && typeof v.getDataSet === "function" && typeof v.getIds === "function" && typeof v.length === "number" && typeof map$3(v) === "function" && typeof v.off === "function" && typeof v.on === "function" && typeof v.stream === "function" && isDataSetLike(idProp, v.getDataSet());
14654}
14655
14656/**
14657 * @prototype Range
14658 *
14659 * Helper class to make working with related min and max values easier.
14660 *
14661 * The range is inclusive; a given value is considered part of the range if:
14662 *
14663 * this.min <= value <= this.max
14664 */
14665
14666function Range() {
14667 this.min = undefined;
14668 this.max = undefined;
14669}
14670/**
14671 * Adjust the range so that the passed value fits in it.
14672 *
14673 * If the value is outside of the current extremes, adjust
14674 * the min or max so that the value is within the range.
14675 *
14676 * @param {number} value Numeric value to fit in range
14677 */
14678
14679
14680Range.prototype.adjust = function (value) {
14681 if (value === undefined) return;
14682
14683 if (this.min === undefined || this.min > value) {
14684 this.min = value;
14685 }
14686
14687 if (this.max === undefined || this.max < value) {
14688 this.max = value;
14689 }
14690};
14691/**
14692 * Adjust the current range so that the passed range fits in it.
14693 *
14694 * @param {Range} range Range instance to fit in current instance
14695 */
14696
14697
14698Range.prototype.combine = function (range) {
14699 this.add(range.min);
14700 this.add(range.max);
14701};
14702/**
14703 * Expand the range by the given value
14704 *
14705 * min will be lowered by given value;
14706 * max will be raised by given value
14707 *
14708 * Shrinking by passing a negative value is allowed.
14709 *
14710 * @param {number} val Amount by which to expand or shrink current range with
14711 */
14712
14713
14714Range.prototype.expand = function (val) {
14715 if (val === undefined) {
14716 return;
14717 }
14718
14719 var newMin = this.min - val;
14720 var newMax = this.max + val; // Note that following allows newMin === newMax.
14721 // This should be OK, since method expand() allows this also.
14722
14723 if (newMin > newMax) {
14724 throw new Error('Passed expansion value makes range invalid');
14725 }
14726
14727 this.min = newMin;
14728 this.max = newMax;
14729};
14730/**
14731 * Determine the full range width of current instance.
14732 *
14733 * @returns {num} The calculated width of this range
14734 */
14735
14736
14737Range.prototype.range = function () {
14738 return this.max - this.min;
14739};
14740/**
14741 * Determine the central point of current instance.
14742 *
14743 * @returns {number} the value in the middle of min and max
14744 */
14745
14746
14747Range.prototype.center = function () {
14748 return (this.min + this.max) / 2;
14749};
14750
14751var Range_1 = Range;
14752
14753/**
14754 * @class Filter
14755 *
14756 * @param {DataGroup} dataGroup the data group
14757 * @param {number} column The index of the column to be filtered
14758 * @param {Graph3d} graph The graph
14759 */
14760
14761function Filter(dataGroup, column, graph) {
14762 this.dataGroup = dataGroup;
14763 this.column = column;
14764 this.graph = graph; // the parent graph
14765
14766 this.index = undefined;
14767 this.value = undefined; // read all distinct values and select the first one
14768
14769 this.values = dataGroup.getDistinctValues(this.column);
14770
14771 if (values(this).length > 0) {
14772 this.selectValue(0);
14773 } // create an array with the filtered datapoints. this will be loaded afterwards
14774
14775
14776 this.dataPoints = [];
14777 this.loaded = false;
14778 this.onLoadCallback = undefined;
14779
14780 if (graph.animationPreload) {
14781 this.loaded = false;
14782 this.loadInBackground();
14783 } else {
14784 this.loaded = true;
14785 }
14786}
14787/**
14788 * Return the label
14789 * @return {string} label
14790 */
14791
14792
14793Filter.prototype.isLoaded = function () {
14794 return this.loaded;
14795};
14796/**
14797 * Return the loaded progress
14798 * @return {number} percentage between 0 and 100
14799 */
14800
14801
14802Filter.prototype.getLoadedProgress = function () {
14803 var len = values(this).length;
14804
14805 var i = 0;
14806
14807 while (this.dataPoints[i]) {
14808 i++;
14809 }
14810
14811 return Math.round(i / len * 100);
14812};
14813/**
14814 * Return the label
14815 * @return {string} label
14816 */
14817
14818
14819Filter.prototype.getLabel = function () {
14820 return this.graph.filterLabel;
14821};
14822/**
14823 * Return the columnIndex of the filter
14824 * @return {number} columnIndex
14825 */
14826
14827
14828Filter.prototype.getColumn = function () {
14829 return this.column;
14830};
14831/**
14832 * Return the currently selected value. Returns undefined if there is no selection
14833 * @return {*} value
14834 */
14835
14836
14837Filter.prototype.getSelectedValue = function () {
14838 if (this.index === undefined) return undefined;
14839 return values(this)[this.index];
14840};
14841/**
14842 * Retrieve all values of the filter
14843 * @return {Array} values
14844 */
14845
14846
14847Filter.prototype.getValues = function () {
14848 return values(this);
14849};
14850/**
14851 * Retrieve one value of the filter
14852 * @param {number} index
14853 * @return {*} value
14854 */
14855
14856
14857Filter.prototype.getValue = function (index) {
14858 if (index >= values(this).length) throw new Error('Index out of range');
14859 return values(this)[index];
14860};
14861/**
14862 * Retrieve the (filtered) dataPoints for the currently selected filter index
14863 * @param {number} [index] (optional)
14864 * @return {Array} dataPoints
14865 */
14866
14867
14868Filter.prototype._getDataPoints = function (index) {
14869 if (index === undefined) index = this.index;
14870 if (index === undefined) return [];
14871 var dataPoints;
14872
14873 if (this.dataPoints[index]) {
14874 dataPoints = this.dataPoints[index];
14875 } else {
14876 var f = {};
14877 f.column = this.column;
14878 f.value = values(this)[index];
14879 var dataView = new DataView(this.dataGroup.getDataSet(), {
14880 filter: function filter(item) {
14881 return item[f.column] == f.value;
14882 }
14883 }).get();
14884 dataPoints = this.dataGroup._getDataPoints(dataView);
14885 this.dataPoints[index] = dataPoints;
14886 }
14887
14888 return dataPoints;
14889};
14890/**
14891 * Set a callback function when the filter is fully loaded.
14892 *
14893 * @param {function} callback
14894 */
14895
14896
14897Filter.prototype.setOnLoadCallback = function (callback) {
14898 this.onLoadCallback = callback;
14899};
14900/**
14901 * Add a value to the list with available values for this filter
14902 * No double entries will be created.
14903 * @param {number} index
14904 */
14905
14906
14907Filter.prototype.selectValue = function (index) {
14908 if (index >= values(this).length) throw new Error('Index out of range');
14909 this.index = index;
14910 this.value = values(this)[index];
14911};
14912/**
14913 * Load all filtered rows in the background one by one
14914 * Start this method without providing an index!
14915 *
14916 * @param {number} [index=0]
14917 */
14918
14919
14920Filter.prototype.loadInBackground = function (index) {
14921 if (index === undefined) index = 0;
14922 var frame = this.graph.frame;
14923
14924 if (index < values(this).length) {
14925 // create a progress box
14926 if (frame.progress === undefined) {
14927 frame.progress = document.createElement('DIV');
14928 frame.progress.style.position = 'absolute';
14929 frame.progress.style.color = 'gray';
14930 frame.appendChild(frame.progress);
14931 }
14932
14933 var progress = this.getLoadedProgress();
14934 frame.progress.innerHTML = 'Loading animation... ' + progress + '%'; // TODO: this is no nice solution...
14935
14936 frame.progress.style.bottom = 60 + 'px'; // TODO: use height of slider
14937
14938 frame.progress.style.left = 10 + 'px';
14939 var me = this;
14940
14941 setTimeout$1(function () {
14942 me.loadInBackground(index + 1);
14943 }, 10);
14944
14945 this.loaded = false;
14946 } else {
14947 this.loaded = true; // remove the progress box
14948
14949 if (frame.progress !== undefined) {
14950 frame.removeChild(frame.progress);
14951 frame.progress = undefined;
14952 }
14953
14954 if (this.onLoadCallback) this.onLoadCallback();
14955 }
14956};
14957
14958/**
14959 * Creates a container for all data of one specific 3D-graph.
14960 *
14961 * On construction, the container is totally empty; the data
14962 * needs to be initialized with method initializeData().
14963 * Failure to do so will result in the following exception begin thrown
14964 * on instantiation of Graph3D:
14965 *
14966 * Error: Array, DataSet, or DataView expected
14967 *
14968 * @constructor DataGroup
14969 */
14970
14971function DataGroup() {
14972 this.dataTable = null; // The original data table
14973}
14974/**
14975 * Initializes the instance from the passed data.
14976 *
14977 * Calculates minimum and maximum values and column index values.
14978 *
14979 * The graph3d instance is used internally to access the settings for
14980 * the given instance.
14981 * TODO: Pass settings only instead.
14982 *
14983 * @param {vis.Graph3d} graph3d Reference to the calling Graph3D instance.
14984 * @param {Array | DataSet | DataView} rawData The data containing the items for
14985 * the Graph.
14986 * @param {number} style Style Number
14987 * @returns {Array.<Object>}
14988 */
14989
14990
14991DataGroup.prototype.initializeData = function (graph3d, rawData, style) {
14992 if (rawData === undefined) return;
14993
14994 if (isArray$5(rawData)) {
14995 rawData = new DataSet(rawData);
14996 }
14997
14998 var data;
14999
15000 if (rawData instanceof DataSet || rawData instanceof DataView) {
15001 data = rawData.get();
15002 } else {
15003 throw new Error('Array, DataSet, or DataView expected');
15004 }
15005
15006 if (data.length == 0) return;
15007 this.style = style; // unsubscribe from the dataTable
15008
15009 if (this.dataSet) {
15010 this.dataSet.off('*', this._onChange);
15011 }
15012
15013 this.dataSet = rawData;
15014 this.dataTable = data; // subscribe to changes in the dataset
15015
15016 var me = this;
15017
15018 this._onChange = function () {
15019 graph3d.setData(me.dataSet);
15020 };
15021
15022 this.dataSet.on('*', this._onChange); // determine the location of x,y,z,value,filter columns
15023
15024 this.colX = 'x';
15025 this.colY = 'y';
15026 this.colZ = 'z';
15027 var withBars = graph3d.hasBars(style); // determine barWidth from data
15028
15029 if (withBars) {
15030 if (graph3d.defaultXBarWidth !== undefined) {
15031 this.xBarWidth = graph3d.defaultXBarWidth;
15032 } else {
15033 this.xBarWidth = this.getSmallestDifference(data, this.colX) || 1;
15034 }
15035
15036 if (graph3d.defaultYBarWidth !== undefined) {
15037 this.yBarWidth = graph3d.defaultYBarWidth;
15038 } else {
15039 this.yBarWidth = this.getSmallestDifference(data, this.colY) || 1;
15040 }
15041 } // calculate minima and maxima
15042
15043
15044 this._initializeRange(data, this.colX, graph3d, withBars);
15045
15046 this._initializeRange(data, this.colY, graph3d, withBars);
15047
15048 this._initializeRange(data, this.colZ, graph3d, false);
15049
15050 if (data[0].hasOwnProperty('style')) {
15051 this.colValue = 'style';
15052 var valueRange = this.getColumnRange(data, this.colValue);
15053
15054 this._setRangeDefaults(valueRange, graph3d.defaultValueMin, graph3d.defaultValueMax);
15055
15056 this.valueRange = valueRange;
15057 } else {
15058 this.colValue = 'z';
15059 this.valueRange = this.zRange;
15060 } // Initialize data filter if a filter column is provided
15061
15062
15063 var table = this.getDataTable();
15064
15065 if (table[0].hasOwnProperty('filter')) {
15066 if (this.dataFilter === undefined) {
15067 this.dataFilter = new Filter(this, 'filter', graph3d);
15068 this.dataFilter.setOnLoadCallback(function () {
15069 graph3d.redraw();
15070 });
15071 }
15072 }
15073
15074 var dataPoints;
15075
15076 if (this.dataFilter) {
15077 // apply filtering
15078 dataPoints = this.dataFilter._getDataPoints();
15079 } else {
15080 // no filtering. load all data
15081 dataPoints = this._getDataPoints(this.getDataTable());
15082 }
15083
15084 return dataPoints;
15085};
15086/**
15087 * Collect the range settings for the given data column.
15088 *
15089 * This internal method is intended to make the range
15090 * initalization more generic.
15091 *
15092 * TODO: if/when combined settings per axis defined, get rid of this.
15093 *
15094 * @private
15095 *
15096 * @param {'x'|'y'|'z'} column The data column to process
15097 * @param {vis.Graph3d} graph3d Reference to the calling Graph3D instance;
15098 * required for access to settings
15099 * @returns {Object}
15100 */
15101
15102
15103DataGroup.prototype._collectRangeSettings = function (column, graph3d) {
15104 var _context;
15105
15106 var index = indexOf(_context = ['x', 'y', 'z']).call(_context, column);
15107
15108 if (index == -1) {
15109 throw new Error('Column \'' + column + '\' invalid');
15110 }
15111
15112 var upper = column.toUpperCase();
15113 return {
15114 barWidth: this[column + 'BarWidth'],
15115 min: graph3d['default' + upper + 'Min'],
15116 max: graph3d['default' + upper + 'Max'],
15117 step: graph3d['default' + upper + 'Step'],
15118 range_label: column + 'Range',
15119 // Name of instance field to write to
15120 step_label: column + 'Step' // Name of instance field to write to
15121
15122 };
15123};
15124/**
15125 * Initializes the settings per given column.
15126 *
15127 * TODO: if/when combined settings per axis defined, rewrite this.
15128 *
15129 * @private
15130 *
15131 * @param {DataSet | DataView} data The data containing the items for the Graph
15132 * @param {'x'|'y'|'z'} column The data column to process
15133 * @param {vis.Graph3d} graph3d Reference to the calling Graph3D instance;
15134 * required for access to settings
15135 * @param {boolean} withBars True if initializing for bar graph
15136 */
15137
15138
15139DataGroup.prototype._initializeRange = function (data, column, graph3d, withBars) {
15140 var NUMSTEPS = 5;
15141
15142 var settings = this._collectRangeSettings(column, graph3d);
15143
15144 var range = this.getColumnRange(data, column);
15145
15146 if (withBars && column != 'z') {
15147 // Safeguard for 'z'; it doesn't have a bar width
15148 range.expand(settings.barWidth / 2);
15149 }
15150
15151 this._setRangeDefaults(range, settings.min, settings.max);
15152
15153 this[settings.range_label] = range;
15154 this[settings.step_label] = settings.step !== undefined ? settings.step : range.range() / NUMSTEPS;
15155};
15156/**
15157 * Creates a list with all the different values in the data for the given column.
15158 *
15159 * If no data passed, use the internal data of this instance.
15160 *
15161 * @param {'x'|'y'|'z'} column The data column to process
15162 * @param {DataSet|DataView|undefined} data The data containing the items for the Graph
15163 *
15164 * @returns {Array} All distinct values in the given column data, sorted ascending.
15165 */
15166
15167
15168DataGroup.prototype.getDistinctValues = function (column, data) {
15169 if (data === undefined) {
15170 data = this.dataTable;
15171 }
15172
15173 var values = [];
15174
15175 for (var i = 0; i < data.length; i++) {
15176 var value = data[i][column] || 0;
15177
15178 if (indexOf(values).call(values, value) === -1) {
15179 values.push(value);
15180 }
15181 }
15182
15183 return sort(values).call(values, function (a, b) {
15184 return a - b;
15185 });
15186};
15187/**
15188 * Determine the smallest difference between the values for given
15189 * column in the passed data set.
15190 *
15191 * @param {DataSet|DataView|undefined} data The data containing the items for the Graph
15192 * @param {'x'|'y'|'z'} column The data column to process
15193 *
15194 * @returns {number|null} Smallest difference value or
15195 * null, if it can't be determined.
15196 */
15197
15198
15199DataGroup.prototype.getSmallestDifference = function (data, column) {
15200 var values = this.getDistinctValues(data, column); // Get all the distinct diffs
15201 // Array values is assumed to be sorted here
15202
15203 var smallest_diff = null;
15204
15205 for (var i = 1; i < values.length; i++) {
15206 var diff = values[i] - values[i - 1];
15207
15208 if (smallest_diff == null || smallest_diff > diff) {
15209 smallest_diff = diff;
15210 }
15211 }
15212
15213 return smallest_diff;
15214};
15215/**
15216 * Get the absolute min/max values for the passed data column.
15217 *
15218 * @param {DataSet|DataView|undefined} data The data containing the items for the Graph
15219 * @param {'x'|'y'|'z'} column The data column to process
15220 *
15221 * @returns {Range} A Range instance with min/max members properly set.
15222 */
15223
15224
15225DataGroup.prototype.getColumnRange = function (data, column) {
15226 var range = new Range_1(); // Adjust the range so that it covers all values in the passed data elements.
15227
15228 for (var i = 0; i < data.length; i++) {
15229 var item = data[i][column];
15230 range.adjust(item);
15231 }
15232
15233 return range;
15234};
15235/**
15236 * Determines the number of rows in the current data.
15237 *
15238 * @returns {number}
15239 */
15240
15241
15242DataGroup.prototype.getNumberOfRows = function () {
15243 return this.dataTable.length;
15244};
15245/**
15246 * Set default values for range
15247 *
15248 * The default values override the range values, if defined.
15249 *
15250 * Because it's possible that only defaultMin or defaultMax is set, it's better
15251 * to pass in a range already set with the min/max set from the data. Otherwise,
15252 * it's quite hard to process the min/max properly.
15253 *
15254 * @param {vis.Range} range
15255 * @param {number} [defaultMin=range.min]
15256 * @param {number} [defaultMax=range.max]
15257 * @private
15258 */
15259
15260
15261DataGroup.prototype._setRangeDefaults = function (range, defaultMin, defaultMax) {
15262 if (defaultMin !== undefined) {
15263 range.min = defaultMin;
15264 }
15265
15266 if (defaultMax !== undefined) {
15267 range.max = defaultMax;
15268 } // This is the original way that the default min/max values were adjusted.
15269 // TODO: Perhaps it's better if an error is thrown if the values do not agree.
15270 // But this will change the behaviour.
15271
15272
15273 if (range.max <= range.min) range.max = range.min + 1;
15274};
15275
15276DataGroup.prototype.getDataTable = function () {
15277 return this.dataTable;
15278};
15279
15280DataGroup.prototype.getDataSet = function () {
15281 return this.dataSet;
15282};
15283/**
15284 * Return all data values as a list of Point3d objects
15285 * @param {Array.<Object>} data
15286 * @returns {Array.<Object>}
15287 */
15288
15289
15290DataGroup.prototype.getDataPoints = function (data) {
15291 var dataPoints = [];
15292
15293 for (var i = 0; i < data.length; i++) {
15294 var point = new Point3d_1();
15295 point.x = data[i][this.colX] || 0;
15296 point.y = data[i][this.colY] || 0;
15297 point.z = data[i][this.colZ] || 0;
15298 point.data = data[i];
15299 point.value = data[i][this.colValue] || 0;
15300 var obj = {};
15301 obj.point = point;
15302 obj.bottom = new Point3d_1(point.x, point.y, this.zRange.min);
15303 obj.trans = undefined;
15304 obj.screen = undefined;
15305 dataPoints.push(obj);
15306 }
15307
15308 return dataPoints;
15309};
15310/**
15311 * Copy all values from the data table to a matrix.
15312 *
15313 * The provided values are supposed to form a grid of (x,y) positions.
15314 * @param {Array.<Object>} data
15315 * @returns {Array.<Object>}
15316 * @private
15317 */
15318
15319
15320DataGroup.prototype.initDataAsMatrix = function (data) {
15321 // TODO: store the created matrix dataPoints in the filters instead of
15322 // reloading each time.
15323 var x, y, i, obj; // create two lists with all present x and y values
15324
15325 var dataX = this.getDistinctValues(this.colX, data);
15326 var dataY = this.getDistinctValues(this.colY, data);
15327 var dataPoints = this.getDataPoints(data); // create a grid, a 2d matrix, with all values.
15328
15329 var dataMatrix = []; // temporary data matrix
15330
15331 for (i = 0; i < dataPoints.length; i++) {
15332 obj = dataPoints[i]; // TODO: implement Array().indexOf() for Internet Explorer
15333
15334 var xIndex = indexOf(dataX).call(dataX, obj.point.x);
15335
15336 var yIndex = indexOf(dataY).call(dataY, obj.point.y);
15337
15338 if (dataMatrix[xIndex] === undefined) {
15339 dataMatrix[xIndex] = [];
15340 }
15341
15342 dataMatrix[xIndex][yIndex] = obj;
15343 } // fill in the pointers to the neighbors.
15344
15345
15346 for (x = 0; x < dataMatrix.length; x++) {
15347 for (y = 0; y < dataMatrix[x].length; y++) {
15348 if (dataMatrix[x][y]) {
15349 dataMatrix[x][y].pointRight = x < dataMatrix.length - 1 ? dataMatrix[x + 1][y] : undefined;
15350 dataMatrix[x][y].pointTop = y < dataMatrix[x].length - 1 ? dataMatrix[x][y + 1] : undefined;
15351 dataMatrix[x][y].pointCross = x < dataMatrix.length - 1 && y < dataMatrix[x].length - 1 ? dataMatrix[x + 1][y + 1] : undefined;
15352 }
15353 }
15354 }
15355
15356 return dataPoints;
15357};
15358/**
15359 * Return common information, if present
15360 *
15361 * @returns {string}
15362 */
15363
15364
15365DataGroup.prototype.getInfo = function () {
15366 var dataFilter = this.dataFilter;
15367 if (!dataFilter) return undefined;
15368 return dataFilter.getLabel() + ': ' + dataFilter.getSelectedValue();
15369};
15370/**
15371 * Reload the data
15372 */
15373
15374
15375DataGroup.prototype.reload = function () {
15376 if (this.dataTable) {
15377 this.setData(this.dataTable);
15378 }
15379};
15380/**
15381 * Filter the data based on the current filter
15382 *
15383 * @param {Array} data
15384 * @returns {Array} dataPoints Array with point objects which can be drawn on
15385 * screen
15386 */
15387
15388
15389DataGroup.prototype._getDataPoints = function (data) {
15390 var dataPoints = [];
15391
15392 if (this.style === STYLE.GRID || this.style === STYLE.SURFACE) {
15393 dataPoints = this.initDataAsMatrix(data);
15394 } else {
15395 // 'dot', 'dot-line', etc.
15396 dataPoints = this.getDataPoints(data);
15397
15398 if (this.style === STYLE.LINE) {
15399 // Add next member points for line drawing
15400 for (var i = 0; i < dataPoints.length; i++) {
15401 if (i > 0) {
15402 dataPoints[i - 1].pointNext = dataPoints[i];
15403 }
15404 }
15405 }
15406 }
15407
15408 return dataPoints;
15409};
15410
15411Graph3d.STYLE = STYLE;
15412/**
15413 * Following label is used in the settings to describe values which should be
15414 * determined by the code while running, from the current data and graph style.
15415 *
15416 * Using 'undefined' directly achieves the same thing, but this is more
15417 * descriptive by describing the intent.
15418 */
15419
15420var autoByDefault = undefined;
15421/**
15422 * Default values for option settings.
15423 *
15424 * These are the values used when a Graph3d instance is initialized without
15425 * custom settings.
15426 *
15427 * If a field is not in this list, a default value of 'autoByDefault' is assumed,
15428 * which is just an alias for 'undefined'.
15429 */
15430
15431Graph3d.DEFAULTS = {
15432 width: '400px',
15433 height: '400px',
15434 filterLabel: 'time',
15435 legendLabel: 'value',
15436 xLabel: 'x',
15437 yLabel: 'y',
15438 zLabel: 'z',
15439 xValueLabel: function xValueLabel(v) {
15440 return v;
15441 },
15442 yValueLabel: function yValueLabel(v) {
15443 return v;
15444 },
15445 zValueLabel: function zValueLabel(v) {
15446 return v;
15447 },
15448 showXAxis: true,
15449 showYAxis: true,
15450 showZAxis: true,
15451 showGrayBottom: false,
15452 showGrid: true,
15453 showPerspective: true,
15454 showShadow: false,
15455 showSurfaceGrid: true,
15456 keepAspectRatio: true,
15457 rotateAxisLabels: true,
15458 verticalRatio: 0.5,
15459 // 0.1 to 1.0, where 1.0 results in a 'cube'
15460 dotSizeRatio: 0.02,
15461 // size of the dots as a fraction of the graph width
15462 dotSizeMinFraction: 0.5,
15463 // size of min-value dot as a fraction of dotSizeRatio
15464 dotSizeMaxFraction: 2.5,
15465 // size of max-value dot as a fraction of dotSizeRatio
15466 showAnimationControls: autoByDefault,
15467 animationInterval: 1000,
15468 // milliseconds
15469 animationPreload: false,
15470 animationAutoStart: autoByDefault,
15471 axisFontSize: 14,
15472 axisFontType: 'arial',
15473 axisColor: '#4D4D4D',
15474 gridColor: '#D3D3D3',
15475 xCenter: '55%',
15476 yCenter: '50%',
15477 style: Graph3d.STYLE.DOT,
15478 tooltip: false,
15479 tooltipDelay: 300,
15480 // milliseconds
15481 tooltipStyle: {
15482 content: {
15483 padding: '10px',
15484 border: '1px solid #4d4d4d',
15485 color: '#1a1a1a',
15486 background: 'rgba(255,255,255,0.7)',
15487 borderRadius: '2px',
15488 boxShadow: '5px 5px 10px rgba(128,128,128,0.5)'
15489 },
15490 line: {
15491 height: '40px',
15492 width: '0',
15493 borderLeft: '1px solid #4d4d4d',
15494 pointerEvents: 'none'
15495 },
15496 dot: {
15497 height: '0',
15498 width: '0',
15499 border: '5px solid #4d4d4d',
15500 borderRadius: '5px',
15501 pointerEvents: 'none'
15502 }
15503 },
15504 dataColor: {
15505 fill: '#7DC1FF',
15506 stroke: '#3267D2',
15507 strokeWidth: 1 // px
15508
15509 },
15510 surfaceColors: autoByDefault,
15511 colormap: autoByDefault,
15512 cameraPosition: {
15513 horizontal: 1.0,
15514 vertical: 0.5,
15515 distance: 1.7
15516 },
15517 zoomable: true,
15518 ctrlToZoom: false,
15519
15520 /*
15521 The following fields are 'auto by default', see above.
15522 */
15523 showLegend: autoByDefault,
15524 // determined by graph style
15525 backgroundColor: autoByDefault,
15526 xBarWidth: autoByDefault,
15527 yBarWidth: autoByDefault,
15528 valueMin: autoByDefault,
15529 valueMax: autoByDefault,
15530 xMin: autoByDefault,
15531 xMax: autoByDefault,
15532 xStep: autoByDefault,
15533 yMin: autoByDefault,
15534 yMax: autoByDefault,
15535 yStep: autoByDefault,
15536 zMin: autoByDefault,
15537 zMax: autoByDefault,
15538 zStep: autoByDefault
15539}; // -----------------------------------------------------------------------------
15540// Class Graph3d
15541// -----------------------------------------------------------------------------
15542
15543/**
15544 * Graph3d displays data in 3d.
15545 *
15546 * Graph3d is developed in javascript as a Google Visualization Chart.
15547 *
15548 * @constructor Graph3d
15549 * @param {Element} container The DOM element in which the Graph3d will
15550 * be created. Normally a div element.
15551 * @param {DataSet | DataView | Array} [data]
15552 * @param {Object} [options]
15553 */
15554
15555function Graph3d(container, data, options) {
15556 if (!(this instanceof Graph3d)) {
15557 throw new SyntaxError('Constructor must be called with the new operator');
15558 } // create variables and set default values
15559
15560
15561 this.containerElement = container;
15562 this.dataGroup = new DataGroup();
15563 this.dataPoints = null; // The table with point objects
15564 // create a frame and canvas
15565
15566 this.create();
15567 setDefaults(Graph3d.DEFAULTS, this); // the column indexes
15568
15569 this.colX = undefined;
15570 this.colY = undefined;
15571 this.colZ = undefined;
15572 this.colValue = undefined; // TODO: customize axis range
15573 // apply options (also when undefined)
15574
15575 this.setOptions(options); // apply data
15576
15577 this.setData(data);
15578} // Extend Graph3d with an Emitter mixin
15579
15580
15581Emitter(Graph3d.prototype);
15582/**
15583 * Calculate the scaling values, dependent on the range in x, y, and z direction
15584 */
15585
15586Graph3d.prototype._setScale = function () {
15587 this.scale = new Point3d_1(1 / this.xRange.range(), 1 / this.yRange.range(), 1 / this.zRange.range()); // keep aspect ration between x and y scale if desired
15588
15589 if (this.keepAspectRatio) {
15590 if (this.scale.x < this.scale.y) {
15591 //noinspection JSSuspiciousNameCombination
15592 this.scale.y = this.scale.x;
15593 } else {
15594 //noinspection JSSuspiciousNameCombination
15595 this.scale.x = this.scale.y;
15596 }
15597 } // scale the vertical axis
15598
15599
15600 this.scale.z *= this.verticalRatio; // TODO: can this be automated? verticalRatio?
15601 // determine scale for (optional) value
15602
15603 if (this.valueRange !== undefined) {
15604 this.scale.value = 1 / this.valueRange.range();
15605 } // position the camera arm
15606
15607
15608 var xCenter = this.xRange.center() * this.scale.x;
15609 var yCenter = this.yRange.center() * this.scale.y;
15610 var zCenter = this.zRange.center() * this.scale.z;
15611 this.camera.setArmLocation(xCenter, yCenter, zCenter);
15612};
15613/**
15614 * Convert a 3D location to a 2D location on screen
15615 * Source: ttp://en.wikipedia.org/wiki/3D_projection
15616 *
15617 * @param {Point3d} point3d A 3D point with parameters x, y, z
15618 * @returns {Point2d} point2d A 2D point with parameters x, y
15619 */
15620
15621
15622Graph3d.prototype._convert3Dto2D = function (point3d) {
15623 var translation = this._convertPointToTranslation(point3d);
15624
15625 return this._convertTranslationToScreen(translation);
15626};
15627/**
15628 * Convert a 3D location its translation seen from the camera
15629 * Source: http://en.wikipedia.org/wiki/3D_projection
15630 *
15631 * @param {Point3d} point3d A 3D point with parameters x, y, z
15632 * @returns {Point3d} translation A 3D point with parameters x, y, z This is
15633 * the translation of the point, seen from the
15634 * camera.
15635 */
15636
15637
15638Graph3d.prototype._convertPointToTranslation = function (point3d) {
15639 var cameraLocation = this.camera.getCameraLocation(),
15640 cameraRotation = this.camera.getCameraRotation(),
15641 ax = point3d.x * this.scale.x,
15642 ay = point3d.y * this.scale.y,
15643 az = point3d.z * this.scale.z,
15644 cx = cameraLocation.x,
15645 cy = cameraLocation.y,
15646 cz = cameraLocation.z,
15647 // calculate angles
15648 sinTx = Math.sin(cameraRotation.x),
15649 cosTx = Math.cos(cameraRotation.x),
15650 sinTy = Math.sin(cameraRotation.y),
15651 cosTy = Math.cos(cameraRotation.y),
15652 sinTz = Math.sin(cameraRotation.z),
15653 cosTz = Math.cos(cameraRotation.z),
15654 // calculate translation
15655 dx = cosTy * (sinTz * (ay - cy) + cosTz * (ax - cx)) - sinTy * (az - cz),
15656 dy = sinTx * (cosTy * (az - cz) + sinTy * (sinTz * (ay - cy) + cosTz * (ax - cx))) + cosTx * (cosTz * (ay - cy) - sinTz * (ax - cx)),
15657 dz = cosTx * (cosTy * (az - cz) + sinTy * (sinTz * (ay - cy) + cosTz * (ax - cx))) - sinTx * (cosTz * (ay - cy) - sinTz * (ax - cx));
15658 return new Point3d_1(dx, dy, dz);
15659};
15660/**
15661 * Convert a translation point to a point on the screen
15662 *
15663 * @param {Point3d} translation A 3D point with parameters x, y, z This is
15664 * the translation of the point, seen from the
15665 * camera.
15666 * @returns {Point2d} point2d A 2D point with parameters x, y
15667 */
15668
15669
15670Graph3d.prototype._convertTranslationToScreen = function (translation) {
15671 var ex = this.eye.x,
15672 ey = this.eye.y,
15673 ez = this.eye.z,
15674 dx = translation.x,
15675 dy = translation.y,
15676 dz = translation.z; // calculate position on screen from translation
15677
15678 var bx;
15679 var by;
15680
15681 if (this.showPerspective) {
15682 bx = (dx - ex) * (ez / dz);
15683 by = (dy - ey) * (ez / dz);
15684 } else {
15685 bx = dx * -(ez / this.camera.getArmLength());
15686 by = dy * -(ez / this.camera.getArmLength());
15687 } // shift and scale the point to the center of the screen
15688 // use the width of the graph to scale both horizontally and vertically.
15689
15690
15691 return new Point2d_1(this.currentXCenter + bx * this.frame.canvas.clientWidth, this.currentYCenter - by * this.frame.canvas.clientWidth);
15692};
15693/**
15694 * Calculate the translations and screen positions of all points
15695 *
15696 * @param {Array.<Point3d>} points
15697 * @private
15698 */
15699
15700
15701Graph3d.prototype._calcTranslations = function (points) {
15702 for (var i = 0; i < points.length; i++) {
15703 var point = points[i];
15704 point.trans = this._convertPointToTranslation(point.point);
15705 point.screen = this._convertTranslationToScreen(point.trans); // calculate the translation of the point at the bottom (needed for sorting)
15706
15707 var transBottom = this._convertPointToTranslation(point.bottom);
15708
15709 point.dist = this.showPerspective ? transBottom.length() : -transBottom.z;
15710 } // sort the points on depth of their (x,y) position (not on z)
15711
15712
15713 var sortDepth = function sortDepth(a, b) {
15714 return b.dist - a.dist;
15715 };
15716
15717 sort(points).call(points, sortDepth);
15718};
15719/**
15720 * Transfer min/max values to the Graph3d instance.
15721 */
15722
15723
15724Graph3d.prototype._initializeRanges = function () {
15725 // TODO: later on, all min/maxes of all datagroups will be combined here
15726 var dg = this.dataGroup;
15727 this.xRange = dg.xRange;
15728 this.yRange = dg.yRange;
15729 this.zRange = dg.zRange;
15730 this.valueRange = dg.valueRange; // Values currently needed but which need to be sorted out for
15731 // the multiple graph case.
15732
15733 this.xStep = dg.xStep;
15734 this.yStep = dg.yStep;
15735 this.zStep = dg.zStep;
15736 this.xBarWidth = dg.xBarWidth;
15737 this.yBarWidth = dg.yBarWidth;
15738 this.colX = dg.colX;
15739 this.colY = dg.colY;
15740 this.colZ = dg.colZ;
15741 this.colValue = dg.colValue; // set the scale dependent on the ranges.
15742
15743 this._setScale();
15744};
15745/**
15746 * Return all data values as a list of Point3d objects
15747 *
15748 * @param {vis.DataSet} data
15749 * @returns {Array.<Object>}
15750 */
15751
15752
15753Graph3d.prototype.getDataPoints = function (data) {
15754 var dataPoints = [];
15755
15756 for (var i = 0; i < data.length; i++) {
15757 var point = new Point3d_1();
15758 point.x = data[i][this.colX] || 0;
15759 point.y = data[i][this.colY] || 0;
15760 point.z = data[i][this.colZ] || 0;
15761 point.data = data[i];
15762 point.value = data[i][this.colValue] || 0;
15763 var obj = {};
15764 obj.point = point;
15765 obj.bottom = new Point3d_1(point.x, point.y, this.zRange.min);
15766 obj.trans = undefined;
15767 obj.screen = undefined;
15768 dataPoints.push(obj);
15769 }
15770
15771 return dataPoints;
15772};
15773/**
15774 * Filter the data based on the current filter
15775 *
15776 * @param {Array} data
15777 * @returns {Array} dataPoints Array with point objects which can be drawn on
15778 * screen
15779 */
15780
15781
15782Graph3d.prototype._getDataPoints = function (data) {
15783 // TODO: store the created matrix dataPoints in the filters instead of
15784 // reloading each time.
15785 var x, y, i, obj;
15786 var dataPoints = [];
15787
15788 if (this.style === Graph3d.STYLE.GRID || this.style === Graph3d.STYLE.SURFACE) {
15789 // copy all values from the data table to a matrix
15790 // the provided values are supposed to form a grid of (x,y) positions
15791 // create two lists with all present x and y values
15792 var dataX = this.dataGroup.getDistinctValues(this.colX, data);
15793 var dataY = this.dataGroup.getDistinctValues(this.colY, data);
15794 dataPoints = this.getDataPoints(data); // create a grid, a 2d matrix, with all values.
15795
15796 var dataMatrix = []; // temporary data matrix
15797
15798 for (i = 0; i < dataPoints.length; i++) {
15799 obj = dataPoints[i]; // TODO: implement Array().indexOf() for Internet Explorer
15800
15801 var xIndex = indexOf(dataX).call(dataX, obj.point.x);
15802
15803 var yIndex = indexOf(dataY).call(dataY, obj.point.y);
15804
15805 if (dataMatrix[xIndex] === undefined) {
15806 dataMatrix[xIndex] = [];
15807 }
15808
15809 dataMatrix[xIndex][yIndex] = obj;
15810 } // fill in the pointers to the neighbors.
15811
15812
15813 for (x = 0; x < dataMatrix.length; x++) {
15814 for (y = 0; y < dataMatrix[x].length; y++) {
15815 if (dataMatrix[x][y]) {
15816 dataMatrix[x][y].pointRight = x < dataMatrix.length - 1 ? dataMatrix[x + 1][y] : undefined;
15817 dataMatrix[x][y].pointTop = y < dataMatrix[x].length - 1 ? dataMatrix[x][y + 1] : undefined;
15818 dataMatrix[x][y].pointCross = x < dataMatrix.length - 1 && y < dataMatrix[x].length - 1 ? dataMatrix[x + 1][y + 1] : undefined;
15819 }
15820 }
15821 }
15822 } else {
15823 // 'dot', 'dot-line', etc.
15824 dataPoints = this.getDataPoints(data);
15825
15826 if (this.style === Graph3d.STYLE.LINE) {
15827 // Add next member points for line drawing
15828 for (i = 0; i < dataPoints.length; i++) {
15829 if (i > 0) {
15830 dataPoints[i - 1].pointNext = dataPoints[i];
15831 }
15832 }
15833 }
15834 }
15835
15836 return dataPoints;
15837};
15838/**
15839 * Create the main frame for the Graph3d.
15840 *
15841 * This function is executed once when a Graph3d object is created. The frame
15842 * contains a canvas, and this canvas contains all objects like the axis and
15843 * nodes.
15844 */
15845
15846
15847Graph3d.prototype.create = function () {
15848 // remove all elements from the container element.
15849 while (this.containerElement.hasChildNodes()) {
15850 this.containerElement.removeChild(this.containerElement.firstChild);
15851 }
15852
15853 this.frame = document.createElement('div');
15854 this.frame.style.position = 'relative';
15855 this.frame.style.overflow = 'hidden'; // create the graph canvas (HTML canvas element)
15856
15857 this.frame.canvas = document.createElement('canvas');
15858 this.frame.canvas.style.position = 'relative';
15859 this.frame.appendChild(this.frame.canvas); //if (!this.frame.canvas.getContext) {
15860
15861 {
15862 var noCanvas = document.createElement('DIV');
15863 noCanvas.style.color = 'red';
15864 noCanvas.style.fontWeight = 'bold';
15865 noCanvas.style.padding = '10px';
15866 noCanvas.innerHTML = 'Error: your browser does not support HTML canvas';
15867 this.frame.canvas.appendChild(noCanvas);
15868 }
15869 this.frame.filter = document.createElement('div');
15870 filter(this.frame).style.position = 'absolute';
15871 filter(this.frame).style.bottom = '0px';
15872 filter(this.frame).style.left = '0px';
15873 filter(this.frame).style.width = '100%';
15874 this.frame.appendChild(filter(this.frame)); // add event listeners to handle moving and zooming the contents
15875
15876 var me = this;
15877
15878 var onmousedown = function onmousedown(event) {
15879 me._onMouseDown(event);
15880 };
15881
15882 var ontouchstart = function ontouchstart(event) {
15883 me._onTouchStart(event);
15884 };
15885
15886 var onmousewheel = function onmousewheel(event) {
15887 me._onWheel(event);
15888 };
15889
15890 var ontooltip = function ontooltip(event) {
15891 me._onTooltip(event);
15892 };
15893
15894 var onclick = function onclick(event) {
15895 me._onClick(event);
15896 }; // TODO: these events are never cleaned up... can give a 'memory leakage'
15897
15898
15899 addEventListener(this.frame.canvas, 'mousedown', onmousedown);
15900 addEventListener(this.frame.canvas, 'touchstart', ontouchstart);
15901 addEventListener(this.frame.canvas, 'mousewheel', onmousewheel);
15902 addEventListener(this.frame.canvas, 'mousemove', ontooltip);
15903 addEventListener(this.frame.canvas, 'click', onclick); // add the new graph to the container element
15904
15905 this.containerElement.appendChild(this.frame);
15906};
15907/**
15908 * Set a new size for the graph
15909 *
15910 * @param {number} width
15911 * @param {number} height
15912 * @private
15913 */
15914
15915
15916Graph3d.prototype._setSize = function (width, height) {
15917 this.frame.style.width = width;
15918 this.frame.style.height = height;
15919
15920 this._resizeCanvas();
15921};
15922/**
15923 * Resize the canvas to the current size of the frame
15924 */
15925
15926
15927Graph3d.prototype._resizeCanvas = function () {
15928 this.frame.canvas.style.width = '100%';
15929 this.frame.canvas.style.height = '100%';
15930 this.frame.canvas.width = this.frame.canvas.clientWidth;
15931 this.frame.canvas.height = this.frame.canvas.clientHeight; // adjust with for margin
15932
15933 filter(this.frame).style.width = this.frame.canvas.clientWidth - 2 * 10 + 'px';
15934};
15935/**
15936 * Start playing the animation, if requested and filter present. Only applicable
15937 * when animation data is available.
15938 */
15939
15940
15941Graph3d.prototype.animationStart = function () {
15942 // start animation when option is true
15943 if (!this.animationAutoStart || !this.dataGroup.dataFilter) return;
15944 if (!filter(this.frame) || !filter(this.frame).slider) throw new Error('No animation available');
15945
15946 filter(this.frame).slider.play();
15947};
15948/**
15949 * Stop animation
15950 */
15951
15952
15953Graph3d.prototype.animationStop = function () {
15954 if (!filter(this.frame) || !filter(this.frame).slider) return;
15955
15956 filter(this.frame).slider.stop();
15957};
15958/**
15959 * Resize the center position based on the current values in this.xCenter
15960 * and this.yCenter (which are strings with a percentage or a value
15961 * in pixels). The center positions are the variables this.currentXCenter
15962 * and this.currentYCenter
15963 */
15964
15965
15966Graph3d.prototype._resizeCenter = function () {
15967 // calculate the horizontal center position
15968 if (this.xCenter.charAt(this.xCenter.length - 1) === '%') {
15969 this.currentXCenter = _parseFloat(this.xCenter) / 100 * this.frame.canvas.clientWidth;
15970 } else {
15971 this.currentXCenter = _parseFloat(this.xCenter); // supposed to be in px
15972 } // calculate the vertical center position
15973
15974
15975 if (this.yCenter.charAt(this.yCenter.length - 1) === '%') {
15976 this.currentYCenter = _parseFloat(this.yCenter) / 100 * (this.frame.canvas.clientHeight - filter(this.frame).clientHeight);
15977 } else {
15978 this.currentYCenter = _parseFloat(this.yCenter); // supposed to be in px
15979 }
15980};
15981/**
15982 * Retrieve the current camera rotation
15983 *
15984 * @returns {object} An object with parameters horizontal, vertical, and
15985 * distance
15986 */
15987
15988
15989Graph3d.prototype.getCameraPosition = function () {
15990 var pos = this.camera.getArmRotation();
15991 pos.distance = this.camera.getArmLength();
15992 return pos;
15993};
15994/**
15995 * Load data into the 3D Graph
15996 *
15997 * @param {vis.DataSet} data
15998 * @private
15999 */
16000
16001
16002Graph3d.prototype._readData = function (data) {
16003 // read the data
16004 this.dataPoints = this.dataGroup.initializeData(this, data, this.style);
16005
16006 this._initializeRanges();
16007
16008 this._redrawFilter();
16009};
16010/**
16011 * Replace the dataset of the Graph3d
16012 *
16013 * @param {Array | DataSet | DataView} data
16014 */
16015
16016
16017Graph3d.prototype.setData = function (data) {
16018 if (data === undefined || data === null) return;
16019
16020 this._readData(data);
16021
16022 this.redraw();
16023 this.animationStart();
16024};
16025/**
16026 * Update the options. Options will be merged with current options
16027 *
16028 * @param {Object} options
16029 */
16030
16031
16032Graph3d.prototype.setOptions = function (options) {
16033 if (options === undefined) return;
16034 var errorFound = Validator$1.validate(options, allOptions);
16035
16036 if (errorFound === true) {
16037 console.log("%cErrors have been found in the supplied options object.", VALIDATOR_PRINT_STYLE$1);
16038 }
16039
16040 this.animationStop();
16041 setOptions(options, this);
16042 this.setPointDrawingMethod();
16043
16044 this._setSize(this.width, this.height);
16045
16046 this.setAxisLabelMethod();
16047 this.setData(this.dataGroup.getDataTable());
16048 this.animationStart();
16049};
16050/**
16051 * Determine which point drawing method to use for the current graph style.
16052 */
16053
16054
16055Graph3d.prototype.setPointDrawingMethod = function () {
16056 var method = undefined;
16057
16058 switch (this.style) {
16059 case Graph3d.STYLE.BAR:
16060 method = this._redrawBarGraphPoint;
16061 break;
16062
16063 case Graph3d.STYLE.BARCOLOR:
16064 method = this._redrawBarColorGraphPoint;
16065 break;
16066
16067 case Graph3d.STYLE.BARSIZE:
16068 method = this._redrawBarSizeGraphPoint;
16069 break;
16070
16071 case Graph3d.STYLE.DOT:
16072 method = this._redrawDotGraphPoint;
16073 break;
16074
16075 case Graph3d.STYLE.DOTLINE:
16076 method = this._redrawDotLineGraphPoint;
16077 break;
16078
16079 case Graph3d.STYLE.DOTCOLOR:
16080 method = this._redrawDotColorGraphPoint;
16081 break;
16082
16083 case Graph3d.STYLE.DOTSIZE:
16084 method = this._redrawDotSizeGraphPoint;
16085 break;
16086
16087 case Graph3d.STYLE.SURFACE:
16088 method = this._redrawSurfaceGraphPoint;
16089 break;
16090
16091 case Graph3d.STYLE.GRID:
16092 method = this._redrawGridGraphPoint;
16093 break;
16094
16095 case Graph3d.STYLE.LINE:
16096 method = this._redrawLineGraphPoint;
16097 break;
16098
16099 default:
16100 throw new Error('Can not determine point drawing method ' + 'for graph style \'' + this.style + '\'');
16101 }
16102
16103 this._pointDrawingMethod = method;
16104};
16105/**
16106 * Determine which functions to use to draw axis labels.
16107 */
16108
16109
16110Graph3d.prototype.setAxisLabelMethod = function () {
16111 if (this.rotateAxisLabels) {
16112 this._drawAxisLabelX = this.drawAxisLabelXRotate;
16113 this._drawAxisLabelY = this.drawAxisLabelYRotate;
16114 this._drawAxisLabelZ = this.drawAxisLabelZRotate;
16115 } else {
16116 this._drawAxisLabelX = this.drawAxisLabelX;
16117 this._drawAxisLabelY = this.drawAxisLabelY;
16118 this._drawAxisLabelZ = this.drawAxisLabelZ;
16119 }
16120};
16121/**
16122 * Redraw the Graph.
16123 */
16124
16125
16126Graph3d.prototype.redraw = function () {
16127 if (this.dataPoints === undefined) {
16128 throw new Error('Graph data not initialized');
16129 }
16130
16131 this._resizeCanvas();
16132
16133 this._resizeCenter();
16134
16135 this._redrawSlider();
16136
16137 this._redrawClear();
16138
16139 this._redrawAxis();
16140
16141 this._redrawDataGraph();
16142
16143 this._redrawInfo();
16144
16145 this._redrawLegend();
16146};
16147/**
16148 * Get drawing context without exposing canvas
16149 *
16150 * @returns {CanvasRenderingContext2D}
16151 * @private
16152 */
16153
16154
16155Graph3d.prototype._getContext = function () {
16156 var canvas = this.frame.canvas;
16157 var ctx = canvas.getContext('2d');
16158 ctx.lineJoin = 'round';
16159 ctx.lineCap = 'round';
16160 return ctx;
16161};
16162/**
16163 * Clear the canvas before redrawing
16164 */
16165
16166
16167Graph3d.prototype._redrawClear = function () {
16168 var canvas = this.frame.canvas;
16169 var ctx = canvas.getContext('2d');
16170 ctx.clearRect(0, 0, canvas.width, canvas.height);
16171};
16172
16173Graph3d.prototype._dotSize = function () {
16174 return this.frame.clientWidth * this.dotSizeRatio;
16175};
16176/**
16177 * Get legend width
16178 *
16179 * @returns {*}
16180 * @private
16181 */
16182
16183
16184Graph3d.prototype._getLegendWidth = function () {
16185 var width;
16186
16187 if (this.style === Graph3d.STYLE.DOTSIZE) {
16188 var dotSize = this._dotSize(); //width = dotSize / 2 + dotSize * 2;
16189
16190
16191 width = dotSize * this.dotSizeMaxFraction;
16192 } else if (this.style === Graph3d.STYLE.BARSIZE) {
16193 width = this.xBarWidth;
16194 } else {
16195 width = 20;
16196 }
16197
16198 return width;
16199};
16200/**
16201 * Redraw the legend based on size, dot color, or surface height
16202 */
16203
16204
16205Graph3d.prototype._redrawLegend = function () {
16206 //Return without drawing anything, if no legend is specified
16207 if (this.showLegend !== true) {
16208 return;
16209 } // Do not draw legend when graph style does not support
16210
16211
16212 if (this.style === Graph3d.STYLE.LINE || this.style === Graph3d.STYLE.BARSIZE //TODO add legend support for BARSIZE
16213 ) {
16214 return;
16215 } // Legend types - size and color. Determine if size legend.
16216
16217
16218 var isSizeLegend = this.style === Graph3d.STYLE.BARSIZE || this.style === Graph3d.STYLE.DOTSIZE; // Legend is either tracking z values or style values. This flag if false means use z values.
16219
16220 var isValueLegend = this.style === Graph3d.STYLE.DOTSIZE || this.style === Graph3d.STYLE.DOTCOLOR || this.style === Graph3d.STYLE.SURFACE || this.style === Graph3d.STYLE.BARCOLOR;
16221 var height = Math.max(this.frame.clientHeight * 0.25, 100);
16222 var top = this.margin;
16223
16224 var width = this._getLegendWidth(); // px - overwritten by size legend
16225
16226
16227 var right = this.frame.clientWidth - this.margin;
16228 var left = right - width;
16229 var bottom = top + height;
16230
16231 var ctx = this._getContext();
16232
16233 ctx.lineWidth = 1;
16234 ctx.font = '14px arial'; // TODO: put in options
16235
16236 if (isSizeLegend === false) {
16237 // draw the color bar
16238 var ymin = 0;
16239 var ymax = height; // Todo: make height customizable
16240
16241 var y;
16242
16243 for (y = ymin; y < ymax; y++) {
16244 // Need (1 - x) because y runs from top to bottom:
16245 var f = 1 - (y - ymin) / (ymax - ymin);
16246
16247 var color = this._colormap(f, 1);
16248
16249 ctx.strokeStyle = color;
16250 ctx.beginPath();
16251 ctx.moveTo(left, top + y);
16252 ctx.lineTo(right, top + y);
16253 ctx.stroke();
16254 }
16255
16256 ctx.strokeStyle = this.axisColor;
16257 ctx.strokeRect(left, top, width, height);
16258 } else {
16259 // draw the size legend box
16260 var widthMin;
16261
16262 if (this.style === Graph3d.STYLE.DOTSIZE) {
16263 // Get the proportion to max and min right
16264 widthMin = width * (this.dotSizeMinFraction / this.dotSizeMaxFraction);
16265 } else if (this.style === Graph3d.STYLE.BARSIZE) ;
16266
16267 ctx.strokeStyle = this.axisColor;
16268 ctx.fillStyle = fill(this.dataColor);
16269 ctx.beginPath();
16270 ctx.moveTo(left, top);
16271 ctx.lineTo(right, top);
16272 ctx.lineTo(left + widthMin, bottom);
16273 ctx.lineTo(left, bottom);
16274 ctx.closePath();
16275
16276 fill(ctx).call(ctx);
16277
16278 ctx.stroke();
16279 } // print value text along the legend edge
16280
16281
16282 var gridLineLen = 5; // px
16283
16284 var legendMin = isValueLegend ? this.valueRange.min : this.zRange.min;
16285 var legendMax = isValueLegend ? this.valueRange.max : this.zRange.max;
16286 var step = new StepNumber_1(legendMin, legendMax, (legendMax - legendMin) / 5, true);
16287 step.start(true);
16288 var from;
16289 var to;
16290
16291 while (!step.end()) {
16292 y = bottom - (step.getCurrent() - legendMin) / (legendMax - legendMin) * height;
16293 from = new Point2d_1(left - gridLineLen, y);
16294 to = new Point2d_1(left, y);
16295
16296 this._line(ctx, from, to);
16297
16298 ctx.textAlign = 'right';
16299 ctx.textBaseline = 'middle';
16300 ctx.fillStyle = this.axisColor;
16301 ctx.fillText(step.getCurrent(), left - 2 * gridLineLen, y);
16302 step.next();
16303 }
16304
16305 ctx.textAlign = 'right';
16306 ctx.textBaseline = 'top';
16307 var label = this.legendLabel;
16308 ctx.fillText(label, right, bottom + this.margin);
16309};
16310/**
16311 * Redraw the filter
16312 */
16313
16314
16315Graph3d.prototype._redrawFilter = function () {
16316 var dataFilter = this.dataGroup.dataFilter;
16317
16318 var filter$1 = filter(this.frame);
16319
16320 filter$1.innerHTML = '';
16321
16322 if (!dataFilter) {
16323 filter$1.slider = undefined;
16324 return;
16325 }
16326
16327 var options = {
16328 'visible': this.showAnimationControls
16329 };
16330 var slider = new Slider(filter$1, options);
16331 filter$1.slider = slider; // TODO: css here is not nice here...
16332
16333 filter$1.style.padding = '10px'; //this.frame.filter.style.backgroundColor = '#EFEFEF';
16334
16335 slider.setValues(values(dataFilter));
16336 slider.setPlayInterval(this.animationInterval); // create an event handler
16337
16338 var me = this;
16339
16340 var onchange = function onchange() {
16341 var dataFilter = me.dataGroup.dataFilter;
16342 var index = slider.getIndex();
16343 dataFilter.selectValue(index);
16344 me.dataPoints = dataFilter._getDataPoints();
16345 me.redraw();
16346 };
16347
16348 slider.setOnChangeCallback(onchange);
16349};
16350/**
16351 * Redraw the slider
16352 */
16353
16354
16355Graph3d.prototype._redrawSlider = function () {
16356 if (filter(this.frame).slider !== undefined) {
16357 filter(this.frame).slider.redraw();
16358 }
16359};
16360/**
16361 * Redraw common information
16362 */
16363
16364
16365Graph3d.prototype._redrawInfo = function () {
16366 var info = this.dataGroup.getInfo();
16367 if (info === undefined) return;
16368
16369 var ctx = this._getContext();
16370
16371 ctx.font = '14px arial'; // TODO: put in options
16372
16373 ctx.lineStyle = 'gray';
16374 ctx.fillStyle = 'gray';
16375 ctx.textAlign = 'left';
16376 ctx.textBaseline = 'top';
16377 var x = this.margin;
16378 var y = this.margin;
16379 ctx.fillText(info, x, y);
16380};
16381/**
16382 * Draw a line between 2d points 'from' and 'to'.
16383 *
16384 * If stroke style specified, set that as well.
16385 *
16386 * @param {CanvasRenderingContext2D} ctx
16387 * @param {vis.Point2d} from
16388 * @param {vis.Point2d} to
16389 * @param {string} [strokeStyle]
16390 * @private
16391 */
16392
16393
16394Graph3d.prototype._line = function (ctx, from, to, strokeStyle) {
16395 if (strokeStyle !== undefined) {
16396 ctx.strokeStyle = strokeStyle;
16397 }
16398
16399 ctx.beginPath();
16400 ctx.moveTo(from.x, from.y);
16401 ctx.lineTo(to.x, to.y);
16402 ctx.stroke();
16403};
16404/**
16405 *
16406 * @param {CanvasRenderingContext2D} ctx
16407 * @param {vis.Point3d} point3d
16408 * @param {string} text
16409 * @param {number} armAngle
16410 * @param {number} [yMargin=0]
16411 */
16412
16413
16414Graph3d.prototype.drawAxisLabelX = function (ctx, point3d, text, armAngle, yMargin) {
16415 if (yMargin === undefined) {
16416 yMargin = 0;
16417 }
16418
16419 var point2d = this._convert3Dto2D(point3d);
16420
16421 if (Math.cos(armAngle * 2) > 0) {
16422 ctx.textAlign = 'center';
16423 ctx.textBaseline = 'top';
16424 point2d.y += yMargin;
16425 } else if (Math.sin(armAngle * 2) < 0) {
16426 ctx.textAlign = 'right';
16427 ctx.textBaseline = 'middle';
16428 } else {
16429 ctx.textAlign = 'left';
16430 ctx.textBaseline = 'middle';
16431 }
16432
16433 ctx.fillStyle = this.axisColor;
16434 ctx.fillText(text, point2d.x, point2d.y);
16435};
16436/**
16437 *
16438 * @param {CanvasRenderingContext2D} ctx
16439 * @param {vis.Point3d} point3d
16440 * @param {string} text
16441 * @param {number} armAngle
16442 * @param {number} [yMargin=0]
16443 */
16444
16445
16446Graph3d.prototype.drawAxisLabelY = function (ctx, point3d, text, armAngle, yMargin) {
16447 if (yMargin === undefined) {
16448 yMargin = 0;
16449 }
16450
16451 var point2d = this._convert3Dto2D(point3d);
16452
16453 if (Math.cos(armAngle * 2) < 0) {
16454 ctx.textAlign = 'center';
16455 ctx.textBaseline = 'top';
16456 point2d.y += yMargin;
16457 } else if (Math.sin(armAngle * 2) > 0) {
16458 ctx.textAlign = 'right';
16459 ctx.textBaseline = 'middle';
16460 } else {
16461 ctx.textAlign = 'left';
16462 ctx.textBaseline = 'middle';
16463 }
16464
16465 ctx.fillStyle = this.axisColor;
16466 ctx.fillText(text, point2d.x, point2d.y);
16467};
16468/**
16469 *
16470 * @param {CanvasRenderingContext2D} ctx
16471 * @param {vis.Point3d} point3d
16472 * @param {string} text
16473 * @param {number} [offset=0]
16474 */
16475
16476
16477Graph3d.prototype.drawAxisLabelZ = function (ctx, point3d, text, offset) {
16478 if (offset === undefined) {
16479 offset = 0;
16480 }
16481
16482 var point2d = this._convert3Dto2D(point3d);
16483
16484 ctx.textAlign = 'right';
16485 ctx.textBaseline = 'middle';
16486 ctx.fillStyle = this.axisColor;
16487 ctx.fillText(text, point2d.x - offset, point2d.y);
16488};
16489/**
16490 *
16491 * @param {CanvasRenderingContext2D} ctx
16492 * @param {vis.Point3d} point3d
16493 * @param {string} text
16494 * @param {number} armAngle
16495 * @param {number} [yMargin=0]
16496 */
16497
16498
16499Graph3d.prototype.drawAxisLabelXRotate = function (ctx, point3d, text, armAngle, yMargin) {
16500
16501 var point2d = this._convert3Dto2D(point3d);
16502
16503 if (Math.cos(armAngle * 2) > 0) {
16504 ctx.save();
16505 ctx.translate(point2d.x, point2d.y);
16506 ctx.rotate(-Math.PI / 2);
16507 ctx.textAlign = 'right';
16508 ctx.textBaseline = 'middle';
16509 ctx.fillStyle = this.axisColor;
16510 ctx.fillText(text, 0, 0);
16511 ctx.restore();
16512 } else if (Math.sin(armAngle * 2) < 0) {
16513 ctx.textAlign = 'right';
16514 ctx.textBaseline = 'middle';
16515 ctx.fillStyle = this.axisColor;
16516 ctx.fillText(text, point2d.x, point2d.y);
16517 } else {
16518 ctx.textAlign = 'left';
16519 ctx.textBaseline = 'middle';
16520 ctx.fillStyle = this.axisColor;
16521 ctx.fillText(text, point2d.x, point2d.y);
16522 }
16523};
16524/**
16525 *
16526 * @param {CanvasRenderingContext2D} ctx
16527 * @param {vis.Point3d} point3d
16528 * @param {string} text
16529 * @param {number} armAngle
16530 * @param {number} [yMargin=0]
16531 */
16532
16533
16534Graph3d.prototype.drawAxisLabelYRotate = function (ctx, point3d, text, armAngle, yMargin) {
16535
16536 var point2d = this._convert3Dto2D(point3d);
16537
16538 if (Math.cos(armAngle * 2) < 0) {
16539 ctx.save();
16540 ctx.translate(point2d.x, point2d.y);
16541 ctx.rotate(-Math.PI / 2);
16542 ctx.textAlign = 'right';
16543 ctx.textBaseline = 'middle';
16544 ctx.fillStyle = this.axisColor;
16545 ctx.fillText(text, 0, 0);
16546 ctx.restore();
16547 } else if (Math.sin(armAngle * 2) > 0) {
16548 ctx.textAlign = 'right';
16549 ctx.textBaseline = 'middle';
16550 ctx.fillStyle = this.axisColor;
16551 ctx.fillText(text, point2d.x, point2d.y);
16552 } else {
16553 ctx.textAlign = 'left';
16554 ctx.textBaseline = 'middle';
16555 ctx.fillStyle = this.axisColor;
16556 ctx.fillText(text, point2d.x, point2d.y);
16557 }
16558};
16559/**
16560 *
16561 * @param {CanvasRenderingContext2D} ctx
16562 * @param {vis.Point3d} point3d
16563 * @param {string} text
16564 * @param {number} [offset=0]
16565 */
16566
16567
16568Graph3d.prototype.drawAxisLabelZRotate = function (ctx, point3d, text, offset) {
16569 if (offset === undefined) {
16570 offset = 0;
16571 }
16572
16573 var point2d = this._convert3Dto2D(point3d);
16574
16575 ctx.textAlign = 'right';
16576 ctx.textBaseline = 'middle';
16577 ctx.fillStyle = this.axisColor;
16578 ctx.fillText(text, point2d.x - offset, point2d.y);
16579};
16580/**
16581
16582
16583/**
16584 * Draw a line between 2d points 'from' and 'to'.
16585 *
16586 * If stroke style specified, set that as well.
16587 *
16588 * @param {CanvasRenderingContext2D} ctx
16589 * @param {vis.Point2d} from
16590 * @param {vis.Point2d} to
16591 * @param {string} [strokeStyle]
16592 * @private
16593 */
16594
16595
16596Graph3d.prototype._line3d = function (ctx, from, to, strokeStyle) {
16597 var from2d = this._convert3Dto2D(from);
16598
16599 var to2d = this._convert3Dto2D(to);
16600
16601 this._line(ctx, from2d, to2d, strokeStyle);
16602};
16603/**
16604 * Redraw the axis
16605 */
16606
16607
16608Graph3d.prototype._redrawAxis = function () {
16609 var ctx = this._getContext(),
16610 from,
16611 to,
16612 step,
16613 prettyStep,
16614 text,
16615 xText,
16616 yText,
16617 zText,
16618 offset,
16619 xOffset,
16620 yOffset; // TODO: get the actual rendered style of the containerElement
16621 //ctx.font = this.containerElement.style.font;
16622 //ctx.font = 24 / this.camera.getArmLength() + 'px arial';
16623
16624
16625 ctx.font = this.axisFontSize / this.camera.getArmLength() + 'px ' + this.axisFontType; // calculate the length for the short grid lines
16626
16627 var gridLenX = 0.025 / this.scale.x;
16628 var gridLenY = 0.025 / this.scale.y;
16629 var textMargin = 5 / this.camera.getArmLength(); // px
16630
16631 var armAngle = this.camera.getArmRotation().horizontal;
16632 var armVector = new Point2d_1(Math.cos(armAngle), Math.sin(armAngle));
16633 var xRange = this.xRange;
16634 var yRange = this.yRange;
16635 var zRange = this.zRange;
16636 var point3d; // draw x-grid lines
16637
16638 ctx.lineWidth = 1;
16639 prettyStep = this.defaultXStep === undefined;
16640 step = new StepNumber_1(xRange.min, xRange.max, this.xStep, prettyStep);
16641 step.start(true);
16642
16643 while (!step.end()) {
16644 var x = step.getCurrent();
16645
16646 if (this.showGrid) {
16647 from = new Point3d_1(x, yRange.min, zRange.min);
16648 to = new Point3d_1(x, yRange.max, zRange.min);
16649
16650 this._line3d(ctx, from, to, this.gridColor);
16651 } else if (this.showXAxis) {
16652 from = new Point3d_1(x, yRange.min, zRange.min);
16653 to = new Point3d_1(x, yRange.min + gridLenX, zRange.min);
16654
16655 this._line3d(ctx, from, to, this.axisColor);
16656
16657 from = new Point3d_1(x, yRange.max, zRange.min);
16658 to = new Point3d_1(x, yRange.max - gridLenX, zRange.min);
16659
16660 this._line3d(ctx, from, to, this.axisColor);
16661 }
16662
16663 if (this.showXAxis) {
16664 yText = armVector.x > 0 ? yRange.min : yRange.max;
16665 point3d = new Point3d_1(x, yText, zRange.min);
16666 var msg = ' ' + this.xValueLabel(x) + ' ';
16667
16668 this._drawAxisLabelX.call(this, ctx, point3d, msg, armAngle, textMargin);
16669 }
16670
16671 step.next();
16672 } // draw y-grid lines
16673
16674
16675 ctx.lineWidth = 1;
16676 prettyStep = this.defaultYStep === undefined;
16677 step = new StepNumber_1(yRange.min, yRange.max, this.yStep, prettyStep);
16678 step.start(true);
16679
16680 while (!step.end()) {
16681 var y = step.getCurrent();
16682
16683 if (this.showGrid) {
16684 from = new Point3d_1(xRange.min, y, zRange.min);
16685 to = new Point3d_1(xRange.max, y, zRange.min);
16686
16687 this._line3d(ctx, from, to, this.gridColor);
16688 } else if (this.showYAxis) {
16689 from = new Point3d_1(xRange.min, y, zRange.min);
16690 to = new Point3d_1(xRange.min + gridLenY, y, zRange.min);
16691
16692 this._line3d(ctx, from, to, this.axisColor);
16693
16694 from = new Point3d_1(xRange.max, y, zRange.min);
16695 to = new Point3d_1(xRange.max - gridLenY, y, zRange.min);
16696
16697 this._line3d(ctx, from, to, this.axisColor);
16698 }
16699
16700 if (this.showYAxis) {
16701 xText = armVector.y > 0 ? xRange.min : xRange.max;
16702 point3d = new Point3d_1(xText, y, zRange.min);
16703
16704 var _msg = ' ' + this.yValueLabel(y) + ' ';
16705
16706 this._drawAxisLabelY.call(this, ctx, point3d, _msg, armAngle, textMargin);
16707 }
16708
16709 step.next();
16710 } // draw z-grid lines and axis
16711
16712
16713 if (this.showZAxis) {
16714 ctx.lineWidth = 1;
16715 prettyStep = this.defaultZStep === undefined;
16716 step = new StepNumber_1(zRange.min, zRange.max, this.zStep, prettyStep);
16717 step.start(true);
16718 xText = armVector.x > 0 ? xRange.min : xRange.max;
16719 yText = armVector.y < 0 ? yRange.min : yRange.max;
16720
16721 while (!step.end()) {
16722 var z = step.getCurrent(); // TODO: make z-grid lines really 3d?
16723
16724 var from3d = new Point3d_1(xText, yText, z);
16725
16726 var from2d = this._convert3Dto2D(from3d);
16727
16728 to = new Point2d_1(from2d.x - textMargin, from2d.y);
16729
16730 this._line(ctx, from2d, to, this.axisColor);
16731
16732 var _msg2 = this.zValueLabel(z) + ' ';
16733
16734 this._drawAxisLabelZ.call(this, ctx, from3d, _msg2, 5);
16735
16736 step.next();
16737 }
16738
16739 ctx.lineWidth = 1;
16740 from = new Point3d_1(xText, yText, zRange.min);
16741 to = new Point3d_1(xText, yText, zRange.max);
16742
16743 this._line3d(ctx, from, to, this.axisColor);
16744 } // draw x-axis
16745
16746
16747 if (this.showXAxis) {
16748 var xMin2d;
16749 var xMax2d;
16750 ctx.lineWidth = 1; // line at yMin
16751
16752 xMin2d = new Point3d_1(xRange.min, yRange.min, zRange.min);
16753 xMax2d = new Point3d_1(xRange.max, yRange.min, zRange.min);
16754
16755 this._line3d(ctx, xMin2d, xMax2d, this.axisColor); // line at ymax
16756
16757
16758 xMin2d = new Point3d_1(xRange.min, yRange.max, zRange.min);
16759 xMax2d = new Point3d_1(xRange.max, yRange.max, zRange.min);
16760
16761 this._line3d(ctx, xMin2d, xMax2d, this.axisColor);
16762 } // draw y-axis
16763
16764
16765 if (this.showYAxis) {
16766 ctx.lineWidth = 1; // line at xMin
16767
16768 from = new Point3d_1(xRange.min, yRange.min, zRange.min);
16769 to = new Point3d_1(xRange.min, yRange.max, zRange.min);
16770
16771 this._line3d(ctx, from, to, this.axisColor); // line at xMax
16772
16773
16774 from = new Point3d_1(xRange.max, yRange.min, zRange.min);
16775 to = new Point3d_1(xRange.max, yRange.max, zRange.min);
16776
16777 this._line3d(ctx, from, to, this.axisColor);
16778 } // draw x-label
16779
16780
16781 var xLabel = this.xLabel;
16782
16783 if (xLabel.length > 0 && this.showXAxis) {
16784 yOffset = 0.1 / this.scale.y;
16785 xText = (xRange.max + 3 * xRange.min) / 4;
16786 yText = armVector.x > 0 ? yRange.min - yOffset : yRange.max + yOffset;
16787 text = new Point3d_1(xText, yText, zRange.min);
16788 this.drawAxisLabelX(ctx, text, xLabel, armAngle);
16789 } // draw y-label
16790
16791
16792 var yLabel = this.yLabel;
16793
16794 if (yLabel.length > 0 && this.showYAxis) {
16795 xOffset = 0.1 / this.scale.x;
16796 xText = armVector.y > 0 ? xRange.min - xOffset : xRange.max + xOffset;
16797 yText = (yRange.max + 3 * yRange.min) / 4;
16798 text = new Point3d_1(xText, yText, zRange.min);
16799 this.drawAxisLabelY(ctx, text, yLabel, armAngle);
16800 } // draw z-label
16801
16802
16803 var zLabel = this.zLabel;
16804
16805 if (zLabel.length > 0 && this.showZAxis) {
16806 offset = 30; // pixels. // TODO: relate to the max width of the values on the z axis?
16807
16808 xText = armVector.x > 0 ? xRange.min : xRange.max;
16809 yText = armVector.y < 0 ? yRange.min : yRange.max;
16810 zText = (zRange.max + 3 * zRange.min) / 4;
16811 text = new Point3d_1(xText, yText, zText);
16812 this.drawAxisLabelZ(ctx, text, zLabel, offset);
16813 }
16814};
16815/**
16816 *
16817 * @param {vis.Point3d} point
16818 * @returns {*}
16819 * @private
16820 */
16821
16822
16823Graph3d.prototype._getStrokeWidth = function (point) {
16824 if (point !== undefined) {
16825 if (this.showPerspective) {
16826 return 1 / -point.trans.z * this.dataColor.strokeWidth;
16827 } else {
16828 return -(this.eye.z / this.camera.getArmLength()) * this.dataColor.strokeWidth;
16829 }
16830 }
16831
16832 return this.dataColor.strokeWidth;
16833}; // -----------------------------------------------------------------------------
16834// Drawing primitives for the graphs
16835// -----------------------------------------------------------------------------
16836
16837/**
16838 * Draw a bar element in the view with the given properties.
16839 *
16840 * @param {CanvasRenderingContext2D} ctx
16841 * @param {Object} point
16842 * @param {number} xWidth
16843 * @param {number} yWidth
16844 * @param {string} color
16845 * @param {string} borderColor
16846 * @private
16847 */
16848
16849
16850Graph3d.prototype._redrawBar = function (ctx, point, xWidth, yWidth, color, borderColor) {
16851 var surface; // calculate all corner points
16852
16853 var me = this;
16854 var point3d = point.point;
16855 var zMin = this.zRange.min;
16856 var top = [{
16857 point: new Point3d_1(point3d.x - xWidth, point3d.y - yWidth, point3d.z)
16858 }, {
16859 point: new Point3d_1(point3d.x + xWidth, point3d.y - yWidth, point3d.z)
16860 }, {
16861 point: new Point3d_1(point3d.x + xWidth, point3d.y + yWidth, point3d.z)
16862 }, {
16863 point: new Point3d_1(point3d.x - xWidth, point3d.y + yWidth, point3d.z)
16864 }];
16865 var bottom = [{
16866 point: new Point3d_1(point3d.x - xWidth, point3d.y - yWidth, zMin)
16867 }, {
16868 point: new Point3d_1(point3d.x + xWidth, point3d.y - yWidth, zMin)
16869 }, {
16870 point: new Point3d_1(point3d.x + xWidth, point3d.y + yWidth, zMin)
16871 }, {
16872 point: new Point3d_1(point3d.x - xWidth, point3d.y + yWidth, zMin)
16873 }]; // calculate screen location of the points
16874
16875 forEach$1(top).call(top, function (obj) {
16876 obj.screen = me._convert3Dto2D(obj.point);
16877 });
16878
16879 forEach$1(bottom).call(bottom, function (obj) {
16880 obj.screen = me._convert3Dto2D(obj.point);
16881 }); // create five sides, calculate both corner points and center points
16882
16883
16884 var surfaces = [{
16885 corners: top,
16886 center: Point3d_1.avg(bottom[0].point, bottom[2].point)
16887 }, {
16888 corners: [top[0], top[1], bottom[1], bottom[0]],
16889 center: Point3d_1.avg(bottom[1].point, bottom[0].point)
16890 }, {
16891 corners: [top[1], top[2], bottom[2], bottom[1]],
16892 center: Point3d_1.avg(bottom[2].point, bottom[1].point)
16893 }, {
16894 corners: [top[2], top[3], bottom[3], bottom[2]],
16895 center: Point3d_1.avg(bottom[3].point, bottom[2].point)
16896 }, {
16897 corners: [top[3], top[0], bottom[0], bottom[3]],
16898 center: Point3d_1.avg(bottom[0].point, bottom[3].point)
16899 }];
16900 point.surfaces = surfaces; // calculate the distance of each of the surface centers to the camera
16901
16902 for (var j = 0; j < surfaces.length; j++) {
16903 surface = surfaces[j];
16904
16905 var transCenter = this._convertPointToTranslation(surface.center);
16906
16907 surface.dist = this.showPerspective ? transCenter.length() : -transCenter.z; // TODO: this dept calculation doesn't work 100% of the cases due to perspective,
16908 // but the current solution is fast/simple and works in 99.9% of all cases
16909 // the issue is visible in example 14, with graph.setCameraPosition({horizontal: 2.97, vertical: 0.5, distance: 0.9})
16910 } // order the surfaces by their (translated) depth
16911
16912
16913 sort(surfaces).call(surfaces, function (a, b) {
16914 var diff = b.dist - a.dist;
16915 if (diff) return diff; // if equal depth, sort the top surface last
16916
16917 if (a.corners === top) return 1;
16918 if (b.corners === top) return -1; // both are equal
16919
16920 return 0;
16921 }); // draw the ordered surfaces
16922
16923
16924 ctx.lineWidth = this._getStrokeWidth(point);
16925 ctx.strokeStyle = borderColor;
16926 ctx.fillStyle = color; // NOTE: we start at j=2 instead of j=0 as we don't need to draw the two surfaces at the backside
16927
16928 for (var _j = 2; _j < surfaces.length; _j++) {
16929 surface = surfaces[_j];
16930
16931 this._polygon(ctx, surface.corners);
16932 }
16933};
16934/**
16935 * Draw a polygon using the passed points and fill it with the passed style and stroke.
16936 *
16937 * @param {CanvasRenderingContext2D} ctx
16938 * @param {Array.<vis.Point3d>} points an array of points.
16939 * @param {string} [fillStyle] the fill style to set
16940 * @param {string} [strokeStyle] the stroke style to set
16941 */
16942
16943
16944Graph3d.prototype._polygon = function (ctx, points, fillStyle, strokeStyle) {
16945 if (points.length < 2) {
16946 return;
16947 }
16948
16949 if (fillStyle !== undefined) {
16950 ctx.fillStyle = fillStyle;
16951 }
16952
16953 if (strokeStyle !== undefined) {
16954 ctx.strokeStyle = strokeStyle;
16955 }
16956
16957 ctx.beginPath();
16958 ctx.moveTo(points[0].screen.x, points[0].screen.y);
16959
16960 for (var i = 1; i < points.length; ++i) {
16961 var point = points[i];
16962 ctx.lineTo(point.screen.x, point.screen.y);
16963 }
16964
16965 ctx.closePath();
16966
16967 fill(ctx).call(ctx);
16968
16969 ctx.stroke(); // TODO: only draw stroke when strokeWidth > 0
16970};
16971/**
16972 * @param {CanvasRenderingContext2D} ctx
16973 * @param {object} point
16974 * @param {string} color
16975 * @param {string} borderColor
16976 * @param {number} [size=this._dotSize()]
16977 * @private
16978 */
16979
16980
16981Graph3d.prototype._drawCircle = function (ctx, point, color, borderColor, size) {
16982 var radius = this._calcRadius(point, size);
16983
16984 ctx.lineWidth = this._getStrokeWidth(point);
16985 ctx.strokeStyle = borderColor;
16986 ctx.fillStyle = color;
16987 ctx.beginPath();
16988 ctx.arc(point.screen.x, point.screen.y, radius, 0, Math.PI * 2, true);
16989
16990 fill(ctx).call(ctx);
16991
16992 ctx.stroke();
16993};
16994/**
16995 * Determine the colors for the 'regular' graph styles.
16996 *
16997 * @param {object} point
16998 * @returns {{fill, border}}
16999 * @private
17000 */
17001
17002
17003Graph3d.prototype._getColorsRegular = function (point) {
17004 var f = (point.point.value - this.valueRange.min) * this.scale.value;
17005
17006 var color = this._colormap(f, 1);
17007
17008 var borderColor = this._colormap(f, 0.8);
17009
17010 return {
17011 fill: color,
17012 border: borderColor
17013 };
17014};
17015/**
17016 * Get the colors for the 'color' graph styles.
17017 * These styles are currently: 'bar-color' and 'dot-color'
17018 * Color may be set as a string representation of HTML color, like #ff00ff,
17019 * or calculated from a number, for example, distance from this point
17020 * The first option is useful when we have some pre-given legend, to which we have to adjust ourselves
17021 * The second option is useful when we are interested in automatically setting the color, from some value,
17022 * using some color scale
17023 * @param {object} point
17024 * @returns {{fill: *, border: *}}
17025 * @private
17026 */
17027
17028
17029Graph3d.prototype._getColorsColor = function (point) {
17030 // calculate the color based on the value
17031 var color, borderColor, pointStyle;
17032
17033 if (point && point.point && point.point.data && point.point.data.style) {
17034 pointStyle = point.point.data.style;
17035 }
17036
17037 if (pointStyle && _typeof(pointStyle) === 'object' && fill(pointStyle) && pointStyle.stroke) {
17038 return {
17039 fill: fill(pointStyle),
17040 border: pointStyle.stroke
17041 };
17042 }
17043
17044 if (typeof point.point.value === "string") {
17045 color = point.point.value;
17046 borderColor = point.point.value;
17047 } else {
17048 var f = (point.point.value - this.valueRange.min) * this.scale.value;
17049 color = this._colormap(f, 1);
17050 borderColor = this._colormap(f, 0.8);
17051 }
17052
17053 return {
17054 fill: color,
17055 border: borderColor
17056 };
17057};
17058/**
17059 * Get the colors for the 'size' graph styles.
17060 * These styles are currently: 'bar-size' and 'dot-size'
17061 *
17062 * @returns {{fill: *, border: (string|colorOptions.stroke|{string, undefined}|string|colorOptions.stroke|{string}|*)}}
17063 * @private
17064 */
17065
17066
17067Graph3d.prototype._getColorsSize = function () {
17068 return {
17069 fill: fill(this.dataColor),
17070 border: this.dataColor.stroke
17071 };
17072};
17073/**
17074 * Determine the color corresponding to a given value on the color scale.
17075 *
17076 * @param {number} [x] the data value to be mapped running from 0 to 1
17077 * @param {number} [v] scale factor between 0 and 1 for the color brightness
17078 * @returns {string}
17079 * @private
17080 */
17081
17082
17083Graph3d.prototype._colormap = function (x) {
17084 var v = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
17085 var r, g, b, a;
17086 var colormap = this.colormap;
17087
17088 if (isArray$5(colormap)) {
17089 var maxIndex = colormap.length - 1;
17090 var startIndex = Math.max(Math.floor(x * maxIndex), 0);
17091 var endIndex = Math.min(startIndex + 1, maxIndex);
17092 var innerRatio = x * maxIndex - startIndex;
17093 var min = colormap[startIndex];
17094 var max = colormap[endIndex];
17095 r = min.r + innerRatio * (max.r - min.r);
17096 g = min.g + innerRatio * (max.g - min.g);
17097 b = min.b + innerRatio * (max.b - min.b);
17098 } else if (typeof colormap === 'function') {
17099 var _colormap = colormap(x);
17100
17101 r = _colormap.r;
17102 g = _colormap.g;
17103 b = _colormap.b;
17104 a = _colormap.a;
17105 } else {
17106 var hue = (1 - x) * 240;
17107
17108 var _util$HSVToRGB = HSVToRGB(hue / 360, 1, 1);
17109
17110 r = _util$HSVToRGB.r;
17111 g = _util$HSVToRGB.g;
17112 b = _util$HSVToRGB.b;
17113 }
17114
17115 if (typeof a === 'number' && !isNan(a)) {
17116 var _context, _context2, _context3;
17117
17118 return concat(_context = concat(_context2 = concat(_context3 = "RGBA(".concat(Math.round(r * v), ", ")).call(_context3, Math.round(g * v), ", ")).call(_context2, Math.round(b * v), ", ")).call(_context, a, ")");
17119 } else {
17120 var _context4, _context5;
17121
17122 return concat(_context4 = concat(_context5 = "RGB(".concat(Math.round(r * v), ", ")).call(_context5, Math.round(g * v), ", ")).call(_context4, Math.round(b * v), ")");
17123 }
17124};
17125/**
17126 * Determine the size of a point on-screen, as determined by the
17127 * distance to the camera.
17128 *
17129 * @param {Object} point
17130 * @param {number} [size=this._dotSize()] the size that needs to be translated to screen coordinates.
17131 * optional; if not passed, use the default point size.
17132 * @returns {number}
17133 * @private
17134 */
17135
17136
17137Graph3d.prototype._calcRadius = function (point, size) {
17138 if (size === undefined) {
17139 size = this._dotSize();
17140 }
17141
17142 var radius;
17143
17144 if (this.showPerspective) {
17145 radius = size / -point.trans.z;
17146 } else {
17147 radius = size * -(this.eye.z / this.camera.getArmLength());
17148 }
17149
17150 if (radius < 0) {
17151 radius = 0;
17152 }
17153
17154 return radius;
17155}; // -----------------------------------------------------------------------------
17156// Methods for drawing points per graph style.
17157// -----------------------------------------------------------------------------
17158
17159/**
17160 * Draw single datapoint for graph style 'bar'.
17161 *
17162 * @param {CanvasRenderingContext2D} ctx
17163 * @param {Object} point
17164 * @private
17165 */
17166
17167
17168Graph3d.prototype._redrawBarGraphPoint = function (ctx, point) {
17169 var xWidth = this.xBarWidth / 2;
17170 var yWidth = this.yBarWidth / 2;
17171
17172 var colors = this._getColorsRegular(point);
17173
17174 this._redrawBar(ctx, point, xWidth, yWidth, fill(colors), colors.border);
17175};
17176/**
17177 * Draw single datapoint for graph style 'bar-color'.
17178 *
17179 * @param {CanvasRenderingContext2D} ctx
17180 * @param {Object} point
17181 * @private
17182 */
17183
17184
17185Graph3d.prototype._redrawBarColorGraphPoint = function (ctx, point) {
17186 var xWidth = this.xBarWidth / 2;
17187 var yWidth = this.yBarWidth / 2;
17188
17189 var colors = this._getColorsColor(point);
17190
17191 this._redrawBar(ctx, point, xWidth, yWidth, fill(colors), colors.border);
17192};
17193/**
17194 * Draw single datapoint for graph style 'bar-size'.
17195 *
17196 * @param {CanvasRenderingContext2D} ctx
17197 * @param {Object} point
17198 * @private
17199 */
17200
17201
17202Graph3d.prototype._redrawBarSizeGraphPoint = function (ctx, point) {
17203 // calculate size for the bar
17204 var fraction = (point.point.value - this.valueRange.min) / this.valueRange.range();
17205 var xWidth = this.xBarWidth / 2 * (fraction * 0.8 + 0.2);
17206 var yWidth = this.yBarWidth / 2 * (fraction * 0.8 + 0.2);
17207
17208 var colors = this._getColorsSize();
17209
17210 this._redrawBar(ctx, point, xWidth, yWidth, fill(colors), colors.border);
17211};
17212/**
17213 * Draw single datapoint for graph style 'dot'.
17214 *
17215 * @param {CanvasRenderingContext2D} ctx
17216 * @param {Object} point
17217 * @private
17218 */
17219
17220
17221Graph3d.prototype._redrawDotGraphPoint = function (ctx, point) {
17222 var colors = this._getColorsRegular(point);
17223
17224 this._drawCircle(ctx, point, fill(colors), colors.border);
17225};
17226/**
17227 * Draw single datapoint for graph style 'dot-line'.
17228 *
17229 * @param {CanvasRenderingContext2D} ctx
17230 * @param {Object} point
17231 * @private
17232 */
17233
17234
17235Graph3d.prototype._redrawDotLineGraphPoint = function (ctx, point) {
17236 // draw a vertical line from the XY-plane to the graph value
17237 var from = this._convert3Dto2D(point.bottom);
17238
17239 ctx.lineWidth = 1;
17240
17241 this._line(ctx, from, point.screen, this.gridColor);
17242
17243 this._redrawDotGraphPoint(ctx, point);
17244};
17245/**
17246 * Draw single datapoint for graph style 'dot-color'.
17247 *
17248 * @param {CanvasRenderingContext2D} ctx
17249 * @param {Object} point
17250 * @private
17251 */
17252
17253
17254Graph3d.prototype._redrawDotColorGraphPoint = function (ctx, point) {
17255 var colors = this._getColorsColor(point);
17256
17257 this._drawCircle(ctx, point, fill(colors), colors.border);
17258};
17259/**
17260 * Draw single datapoint for graph style 'dot-size'.
17261 *
17262 * @param {CanvasRenderingContext2D} ctx
17263 * @param {Object} point
17264 * @private
17265 */
17266
17267
17268Graph3d.prototype._redrawDotSizeGraphPoint = function (ctx, point) {
17269 var dotSize = this._dotSize();
17270
17271 var fraction = (point.point.value - this.valueRange.min) / this.valueRange.range();
17272 var sizeMin = dotSize * this.dotSizeMinFraction;
17273 var sizeRange = dotSize * this.dotSizeMaxFraction - sizeMin;
17274 var size = sizeMin + sizeRange * fraction;
17275
17276 var colors = this._getColorsSize();
17277
17278 this._drawCircle(ctx, point, fill(colors), colors.border, size);
17279};
17280/**
17281 * Draw single datapoint for graph style 'surface'.
17282 *
17283 * @param {CanvasRenderingContext2D} ctx
17284 * @param {Object} point
17285 * @private
17286 */
17287
17288
17289Graph3d.prototype._redrawSurfaceGraphPoint = function (ctx, point) {
17290 var right = point.pointRight;
17291 var top = point.pointTop;
17292 var cross = point.pointCross;
17293
17294 if (point === undefined || right === undefined || top === undefined || cross === undefined) {
17295 return;
17296 }
17297
17298 var topSideVisible = true;
17299 var fillStyle;
17300 var strokeStyle;
17301 var cosViewAngle;
17302
17303 if (this.showGrayBottom || this.showShadow) {
17304 // calculate the cross product of the two vectors from center
17305 // to left and right, in order to know whether we are looking at the
17306 // bottom or at the top side. We can also use the cross product
17307 // for calculating light intensity
17308 var aDiff = Point3d_1.subtract(cross.trans, point.trans);
17309 var bDiff = Point3d_1.subtract(top.trans, right.trans);
17310 var surfaceNormal = Point3d_1.crossProduct(aDiff, bDiff);
17311
17312 if (this.showPerspective) {
17313 var surfacePosition = Point3d_1.avg(Point3d_1.avg(point.trans, cross.trans), Point3d_1.avg(right.trans, top.trans)); // This corresponds to diffuse lighting with light source at (0, 0, 0).
17314 // More generally, we would need `surfacePosition - lightPosition`:
17315
17316 cosViewAngle = -Point3d_1.dotProduct(surfaceNormal.normalize(), surfacePosition.normalize());
17317 } else {
17318 cosViewAngle = surfaceNormal.z / surfaceNormal.length();
17319 }
17320
17321 topSideVisible = cosViewAngle > 0;
17322 }
17323
17324 if (topSideVisible || !this.showGrayBottom) {
17325 var vAvg = (point.point.value + right.point.value + top.point.value + cross.point.value) / 4;
17326 var ratio = (vAvg - this.valueRange.min) * this.scale.value; // lighting factor. TODO: let user specify lighting model as function(?)
17327
17328 var v = this.showShadow ? (1 + cosViewAngle) / 2 : 1;
17329 fillStyle = this._colormap(ratio, v);
17330 } else {
17331 fillStyle = 'gray';
17332 }
17333
17334 if (this.showSurfaceGrid) {
17335 strokeStyle = this.axisColor; // TODO: should be customizable
17336 } else {
17337 strokeStyle = fillStyle;
17338 }
17339
17340 ctx.lineWidth = this._getStrokeWidth(point); // TODO: only draw stroke when strokeWidth > 0
17341
17342 var points = [point, right, cross, top];
17343
17344 this._polygon(ctx, points, fillStyle, strokeStyle);
17345};
17346/**
17347 * Helper method for _redrawGridGraphPoint()
17348 *
17349 * @param {CanvasRenderingContext2D} ctx
17350 * @param {Object} from
17351 * @param {Object} to
17352 * @private
17353 */
17354
17355
17356Graph3d.prototype._drawGridLine = function (ctx, from, to) {
17357 if (from === undefined || to === undefined) {
17358 return;
17359 }
17360
17361 var vAvg = (from.point.value + to.point.value) / 2;
17362 var f = (vAvg - this.valueRange.min) * this.scale.value;
17363 ctx.lineWidth = this._getStrokeWidth(from) * 2;
17364 ctx.strokeStyle = this._colormap(f, 1);
17365
17366 this._line(ctx, from.screen, to.screen);
17367};
17368/**
17369 * Draw single datapoint for graph style 'Grid'.
17370 *
17371 * @param {CanvasRenderingContext2D} ctx
17372 * @param {Object} point
17373 * @private
17374 */
17375
17376
17377Graph3d.prototype._redrawGridGraphPoint = function (ctx, point) {
17378 this._drawGridLine(ctx, point, point.pointRight);
17379
17380 this._drawGridLine(ctx, point, point.pointTop);
17381};
17382/**
17383 * Draw single datapoint for graph style 'line'.
17384 *
17385 * @param {CanvasRenderingContext2D} ctx
17386 * @param {Object} point
17387 * @private
17388 */
17389
17390
17391Graph3d.prototype._redrawLineGraphPoint = function (ctx, point) {
17392 if (point.pointNext === undefined) {
17393 return;
17394 }
17395
17396 ctx.lineWidth = this._getStrokeWidth(point);
17397 ctx.strokeStyle = this.dataColor.stroke;
17398
17399 this._line(ctx, point.screen, point.pointNext.screen);
17400};
17401/**
17402 * Draw all datapoints for currently selected graph style.
17403 *
17404 */
17405
17406
17407Graph3d.prototype._redrawDataGraph = function () {
17408 var ctx = this._getContext();
17409
17410 var i;
17411 if (this.dataPoints === undefined || this.dataPoints.length <= 0) return; // TODO: throw exception?
17412
17413 this._calcTranslations(this.dataPoints);
17414
17415 for (i = 0; i < this.dataPoints.length; i++) {
17416 var point = this.dataPoints[i]; // Using call() ensures that the correct context is used
17417
17418 this._pointDrawingMethod.call(this, ctx, point);
17419 }
17420}; // -----------------------------------------------------------------------------
17421// End methods for drawing points per graph style.
17422// -----------------------------------------------------------------------------
17423
17424/**
17425 * Store startX, startY and startOffset for mouse operations
17426 *
17427 * @param {Event} event The event that occurred
17428 */
17429
17430
17431Graph3d.prototype._storeMousePosition = function (event) {
17432 // get mouse position (different code for IE and all other browsers)
17433 this.startMouseX = getMouseX(event);
17434 this.startMouseY = getMouseY(event);
17435 this._startCameraOffset = this.camera.getOffset();
17436};
17437/**
17438 * Start a moving operation inside the provided parent element
17439 * @param {Event} event The event that occurred (required for
17440 * retrieving the mouse position)
17441 */
17442
17443
17444Graph3d.prototype._onMouseDown = function (event) {
17445 event = event || window.event; // check if mouse is still down (may be up when focus is lost for example
17446 // in an iframe)
17447
17448 if (this.leftButtonDown) {
17449 this._onMouseUp(event);
17450 } // only react on left mouse button down
17451
17452
17453 this.leftButtonDown = event.which ? event.which === 1 : event.button === 1;
17454 if (!this.leftButtonDown && !this.touchDown) return;
17455
17456 this._storeMousePosition(event);
17457
17458 this.startStart = new Date(this.start);
17459 this.startEnd = new Date(this.end);
17460 this.startArmRotation = this.camera.getArmRotation();
17461 this.frame.style.cursor = 'move'; // add event listeners to handle moving the contents
17462 // we store the function onmousemove and onmouseup in the graph, so we can
17463 // remove the eventlisteners lateron in the function mouseUp()
17464
17465 var me = this;
17466
17467 this.onmousemove = function (event) {
17468 me._onMouseMove(event);
17469 };
17470
17471 this.onmouseup = function (event) {
17472 me._onMouseUp(event);
17473 };
17474
17475 addEventListener(document, 'mousemove', me.onmousemove);
17476 addEventListener(document, 'mouseup', me.onmouseup);
17477 preventDefault(event);
17478};
17479/**
17480 * Perform moving operating.
17481 * This function activated from within the funcion Graph.mouseDown().
17482 * @param {Event} event Well, eehh, the event
17483 */
17484
17485
17486Graph3d.prototype._onMouseMove = function (event) {
17487 this.moving = true;
17488 event = event || window.event; // calculate change in mouse position
17489
17490 var diffX = _parseFloat(getMouseX(event)) - this.startMouseX;
17491 var diffY = _parseFloat(getMouseY(event)) - this.startMouseY; // move with ctrl or rotate by other
17492
17493 if (event && event.ctrlKey === true) {
17494 // calculate change in mouse position
17495 var scaleX = this.frame.clientWidth * 0.5;
17496 var scaleY = this.frame.clientHeight * 0.5;
17497 var offXNew = (this._startCameraOffset.x || 0) - diffX / scaleX * this.camera.armLength * 0.8;
17498 var offYNew = (this._startCameraOffset.y || 0) + diffY / scaleY * this.camera.armLength * 0.8;
17499 this.camera.setOffset(offXNew, offYNew);
17500
17501 this._storeMousePosition(event);
17502 } else {
17503 var horizontalNew = this.startArmRotation.horizontal + diffX / 200;
17504 var verticalNew = this.startArmRotation.vertical + diffY / 200;
17505 var snapAngle = 4; // degrees
17506
17507 var snapValue = Math.sin(snapAngle / 360 * 2 * Math.PI); // snap horizontally to nice angles at 0pi, 0.5pi, 1pi, 1.5pi, etc...
17508 // the -0.001 is to take care that the vertical axis is always drawn at the left front corner
17509
17510 if (Math.abs(Math.sin(horizontalNew)) < snapValue) {
17511 horizontalNew = Math.round(horizontalNew / Math.PI) * Math.PI - 0.001;
17512 }
17513
17514 if (Math.abs(Math.cos(horizontalNew)) < snapValue) {
17515 horizontalNew = (Math.round(horizontalNew / Math.PI - 0.5) + 0.5) * Math.PI - 0.001;
17516 } // snap vertically to nice angles
17517
17518
17519 if (Math.abs(Math.sin(verticalNew)) < snapValue) {
17520 verticalNew = Math.round(verticalNew / Math.PI) * Math.PI;
17521 }
17522
17523 if (Math.abs(Math.cos(verticalNew)) < snapValue) {
17524 verticalNew = (Math.round(verticalNew / Math.PI - 0.5) + 0.5) * Math.PI;
17525 }
17526
17527 this.camera.setArmRotation(horizontalNew, verticalNew);
17528 }
17529
17530 this.redraw(); // fire a cameraPositionChange event
17531
17532 var parameters = this.getCameraPosition();
17533 this.emit('cameraPositionChange', parameters);
17534 preventDefault(event);
17535};
17536/**
17537 * Stop moving operating.
17538 * This function activated from within the funcion Graph.mouseDown().
17539 * @param {Event} event The event
17540 */
17541
17542
17543Graph3d.prototype._onMouseUp = function (event) {
17544 this.frame.style.cursor = 'auto';
17545 this.leftButtonDown = false; // remove event listeners here
17546
17547 removeEventListener(document, 'mousemove', this.onmousemove);
17548 removeEventListener(document, 'mouseup', this.onmouseup);
17549 preventDefault(event);
17550};
17551/**
17552 * @param {Event} event The event
17553 */
17554
17555
17556Graph3d.prototype._onClick = function (event) {
17557 // NOTE: onclick_callback is deprecated and may be removed in a future version.
17558 if (!this.onclick_callback && !this.hasListeners('click')) return;
17559
17560 if (!this.moving) {
17561 var boundingRect = this.frame.getBoundingClientRect();
17562 var mouseX = getMouseX(event) - boundingRect.left;
17563 var mouseY = getMouseY(event) - boundingRect.top;
17564
17565 var dataPoint = this._dataPointFromXY(mouseX, mouseY);
17566
17567 if (dataPoint) {
17568 if (this.onclick_callback) this.onclick_callback(dataPoint.point.data);
17569 this.emit('click', dataPoint.point.data);
17570 }
17571 } else {
17572 // disable onclick callback, if it came immediately after rotate/pan
17573 this.moving = false;
17574 }
17575
17576 preventDefault(event);
17577};
17578/**
17579 * After having moved the mouse, a tooltip should pop up when the mouse is resting on a data point
17580 * @param {Event} event A mouse move event
17581 */
17582
17583
17584Graph3d.prototype._onTooltip = function (event) {
17585 var delay = this.tooltipDelay; // ms
17586
17587 var boundingRect = this.frame.getBoundingClientRect();
17588 var mouseX = getMouseX(event) - boundingRect.left;
17589 var mouseY = getMouseY(event) - boundingRect.top;
17590
17591 if (!this.showTooltip) {
17592 return;
17593 }
17594
17595 if (this.tooltipTimeout) {
17596 clearTimeout(this.tooltipTimeout);
17597 } // (delayed) display of a tooltip only if no mouse button is down
17598
17599
17600 if (this.leftButtonDown) {
17601 this._hideTooltip();
17602
17603 return;
17604 }
17605
17606 if (this.tooltip && this.tooltip.dataPoint) {
17607 // tooltip is currently visible
17608 var dataPoint = this._dataPointFromXY(mouseX, mouseY);
17609
17610 if (dataPoint !== this.tooltip.dataPoint) {
17611 // datapoint changed
17612 if (dataPoint) {
17613 this._showTooltip(dataPoint);
17614 } else {
17615 this._hideTooltip();
17616 }
17617 }
17618 } else {
17619 // tooltip is currently not visible
17620 var me = this;
17621 this.tooltipTimeout = setTimeout$1(function () {
17622 me.tooltipTimeout = null; // show a tooltip if we have a data point
17623
17624 var dataPoint = me._dataPointFromXY(mouseX, mouseY);
17625
17626 if (dataPoint) {
17627 me._showTooltip(dataPoint);
17628 }
17629 }, delay);
17630 }
17631};
17632/**
17633 * Event handler for touchstart event on mobile devices
17634 * @param {Event} event The event
17635 */
17636
17637
17638Graph3d.prototype._onTouchStart = function (event) {
17639 this.touchDown = true;
17640 var me = this;
17641
17642 this.ontouchmove = function (event) {
17643 me._onTouchMove(event);
17644 };
17645
17646 this.ontouchend = function (event) {
17647 me._onTouchEnd(event);
17648 };
17649
17650 addEventListener(document, 'touchmove', me.ontouchmove);
17651 addEventListener(document, 'touchend', me.ontouchend);
17652
17653 this._onMouseDown(event);
17654};
17655/**
17656 * Event handler for touchmove event on mobile devices
17657 * @param {Event} event The event
17658 */
17659
17660
17661Graph3d.prototype._onTouchMove = function (event) {
17662 this._onMouseMove(event);
17663};
17664/**
17665 * Event handler for touchend event on mobile devices
17666 * @param {Event} event The event
17667 */
17668
17669
17670Graph3d.prototype._onTouchEnd = function (event) {
17671 this.touchDown = false;
17672 removeEventListener(document, 'touchmove', this.ontouchmove);
17673 removeEventListener(document, 'touchend', this.ontouchend);
17674
17675 this._onMouseUp(event);
17676};
17677/**
17678 * Event handler for mouse wheel event, used to zoom the graph
17679 * Code from http://adomas.org/javascript-mouse-wheel/
17680 * @param {Event} event The event
17681 */
17682
17683
17684Graph3d.prototype._onWheel = function (event) {
17685 if (!event)
17686 /* For IE. */
17687 event = window.event;
17688
17689 if (this.zoomable && (!this.ctrlToZoom || event.ctrlKey)) {
17690 // retrieve delta
17691 var delta = 0;
17692
17693 if (event.wheelDelta) {
17694 /* IE/Opera. */
17695 delta = event.wheelDelta / 120;
17696 } else if (event.detail) {
17697 /* Mozilla case. */
17698 // In Mozilla, sign of delta is different than in IE.
17699 // Also, delta is multiple of 3.
17700 delta = -event.detail / 3;
17701 } // If delta is nonzero, handle it.
17702 // Basically, delta is now positive if wheel was scrolled up,
17703 // and negative, if wheel was scrolled down.
17704
17705
17706 if (delta) {
17707 var oldLength = this.camera.getArmLength();
17708 var newLength = oldLength * (1 - delta / 10);
17709 this.camera.setArmLength(newLength);
17710 this.redraw();
17711
17712 this._hideTooltip();
17713 } // fire a cameraPositionChange event
17714
17715
17716 var parameters = this.getCameraPosition();
17717 this.emit('cameraPositionChange', parameters); // Prevent default actions caused by mouse wheel.
17718 // That might be ugly, but we handle scrolls somehow
17719 // anyway, so don't bother here..
17720
17721 preventDefault(event);
17722 }
17723};
17724/**
17725 * Test whether a point lies inside given 2D triangle
17726 *
17727 * @param {vis.Point2d} point
17728 * @param {vis.Point2d[]} triangle
17729 * @returns {boolean} true if given point lies inside or on the edge of the
17730 * triangle, false otherwise
17731 * @private
17732 */
17733
17734
17735Graph3d.prototype._insideTriangle = function (point, triangle) {
17736 var a = triangle[0],
17737 b = triangle[1],
17738 c = triangle[2];
17739 /**
17740 *
17741 * @param {number} x
17742 * @returns {number}
17743 */
17744
17745 function sign(x) {
17746 return x > 0 ? 1 : x < 0 ? -1 : 0;
17747 }
17748
17749 var as = sign((b.x - a.x) * (point.y - a.y) - (b.y - a.y) * (point.x - a.x));
17750 var bs = sign((c.x - b.x) * (point.y - b.y) - (c.y - b.y) * (point.x - b.x));
17751 var cs = sign((a.x - c.x) * (point.y - c.y) - (a.y - c.y) * (point.x - c.x)); // each of the three signs must be either equal to each other or zero
17752
17753 return (as == 0 || bs == 0 || as == bs) && (bs == 0 || cs == 0 || bs == cs) && (as == 0 || cs == 0 || as == cs);
17754};
17755/**
17756 * Find a data point close to given screen position (x, y)
17757 *
17758 * @param {number} x
17759 * @param {number} y
17760 * @returns {Object | null} The closest data point or null if not close to any
17761 * data point
17762 * @private
17763 */
17764
17765
17766Graph3d.prototype._dataPointFromXY = function (x, y) {
17767 var i,
17768 distMax = 100,
17769 // px
17770 dataPoint = null,
17771 closestDataPoint = null,
17772 closestDist = null,
17773 center = new Point2d_1(x, y);
17774
17775 if (this.style === Graph3d.STYLE.BAR || this.style === Graph3d.STYLE.BARCOLOR || this.style === Graph3d.STYLE.BARSIZE) {
17776 // the data points are ordered from far away to closest
17777 for (i = this.dataPoints.length - 1; i >= 0; i--) {
17778 dataPoint = this.dataPoints[i];
17779 var surfaces = dataPoint.surfaces;
17780
17781 if (surfaces) {
17782 for (var s = surfaces.length - 1; s >= 0; s--) {
17783 // split each surface in two triangles, and see if the center point is inside one of these
17784 var surface = surfaces[s];
17785 var corners = surface.corners;
17786 var triangle1 = [corners[0].screen, corners[1].screen, corners[2].screen];
17787 var triangle2 = [corners[2].screen, corners[3].screen, corners[0].screen];
17788
17789 if (this._insideTriangle(center, triangle1) || this._insideTriangle(center, triangle2)) {
17790 // return immediately at the first hit
17791 return dataPoint;
17792 }
17793 }
17794 }
17795 }
17796 } else {
17797 // find the closest data point, using distance to the center of the point on 2d screen
17798 for (i = 0; i < this.dataPoints.length; i++) {
17799 dataPoint = this.dataPoints[i];
17800 var point = dataPoint.screen;
17801
17802 if (point) {
17803 var distX = Math.abs(x - point.x);
17804 var distY = Math.abs(y - point.y);
17805 var dist = Math.sqrt(distX * distX + distY * distY);
17806
17807 if ((closestDist === null || dist < closestDist) && dist < distMax) {
17808 closestDist = dist;
17809 closestDataPoint = dataPoint;
17810 }
17811 }
17812 }
17813 }
17814
17815 return closestDataPoint;
17816};
17817/**
17818 * Determine if the given style has bars
17819 *
17820 * @param {number} style the style to check
17821 * @returns {boolean} true if bar style, false otherwise
17822 */
17823
17824
17825Graph3d.prototype.hasBars = function (style) {
17826 return style == Graph3d.STYLE.BAR || style == Graph3d.STYLE.BARCOLOR || style == Graph3d.STYLE.BARSIZE;
17827};
17828/**
17829 * Display a tooltip for given data point
17830 * @param {Object} dataPoint
17831 * @private
17832 */
17833
17834
17835Graph3d.prototype._showTooltip = function (dataPoint) {
17836 var content, line, dot;
17837
17838 if (!this.tooltip) {
17839 content = document.createElement('div');
17840
17841 assign$2(content.style, {}, this.tooltipStyle.content);
17842
17843 content.style.position = 'absolute';
17844 line = document.createElement('div');
17845
17846 assign$2(line.style, {}, this.tooltipStyle.line);
17847
17848 line.style.position = 'absolute';
17849 dot = document.createElement('div');
17850
17851 assign$2(dot.style, {}, this.tooltipStyle.dot);
17852
17853 dot.style.position = 'absolute';
17854 this.tooltip = {
17855 dataPoint: null,
17856 dom: {
17857 content: content,
17858 line: line,
17859 dot: dot
17860 }
17861 };
17862 } else {
17863 content = this.tooltip.dom.content;
17864 line = this.tooltip.dom.line;
17865 dot = this.tooltip.dom.dot;
17866 }
17867
17868 this._hideTooltip();
17869
17870 this.tooltip.dataPoint = dataPoint;
17871
17872 if (typeof this.showTooltip === 'function') {
17873 content.innerHTML = this.showTooltip(dataPoint.point);
17874 } else {
17875 content.innerHTML = '<table>' + '<tr><td>' + this.xLabel + ':</td><td>' + dataPoint.point.x + '</td></tr>' + '<tr><td>' + this.yLabel + ':</td><td>' + dataPoint.point.y + '</td></tr>' + '<tr><td>' + this.zLabel + ':</td><td>' + dataPoint.point.z + '</td></tr>' + '</table>';
17876 }
17877
17878 content.style.left = '0';
17879 content.style.top = '0';
17880 this.frame.appendChild(content);
17881 this.frame.appendChild(line);
17882 this.frame.appendChild(dot); // calculate sizes
17883
17884 var contentWidth = content.offsetWidth;
17885 var contentHeight = content.offsetHeight;
17886 var lineHeight = line.offsetHeight;
17887 var dotWidth = dot.offsetWidth;
17888 var dotHeight = dot.offsetHeight;
17889 var left = dataPoint.screen.x - contentWidth / 2;
17890 left = Math.min(Math.max(left, 10), this.frame.clientWidth - 10 - contentWidth);
17891 line.style.left = dataPoint.screen.x + 'px';
17892 line.style.top = dataPoint.screen.y - lineHeight + 'px';
17893 content.style.left = left + 'px';
17894 content.style.top = dataPoint.screen.y - lineHeight - contentHeight + 'px';
17895 dot.style.left = dataPoint.screen.x - dotWidth / 2 + 'px';
17896 dot.style.top = dataPoint.screen.y - dotHeight / 2 + 'px';
17897};
17898/**
17899 * Hide the tooltip when displayed
17900 * @private
17901 */
17902
17903
17904Graph3d.prototype._hideTooltip = function () {
17905 if (this.tooltip) {
17906 this.tooltip.dataPoint = null;
17907
17908 for (var prop in this.tooltip.dom) {
17909 if (this.tooltip.dom.hasOwnProperty(prop)) {
17910 var elem = this.tooltip.dom[prop];
17911
17912 if (elem && elem.parentNode) {
17913 elem.parentNode.removeChild(elem);
17914 }
17915 }
17916 }
17917 }
17918};
17919/**--------------------------------------------------------------------------**/
17920
17921/**
17922 * Get the horizontal mouse position from a mouse event
17923 *
17924 * @param {Event} event
17925 * @returns {number} mouse x
17926 */
17927
17928
17929function getMouseX(event) {
17930 if ('clientX' in event) return event.clientX;
17931 return event.targetTouches[0] && event.targetTouches[0].clientX || 0;
17932}
17933/**
17934 * Get the vertical mouse position from a mouse event
17935 *
17936 * @param {Event} event
17937 * @returns {number} mouse y
17938 */
17939
17940
17941function getMouseY(event) {
17942 if ('clientY' in event) return event.clientY;
17943 return event.targetTouches[0] && event.targetTouches[0].clientY || 0;
17944} // -----------------------------------------------------------------------------
17945// Public methods for specific settings
17946// -----------------------------------------------------------------------------
17947
17948/**
17949 * Set the rotation and distance of the camera
17950 *
17951 * @param {Object} pos An object with the camera position
17952 * @param {number} [pos.horizontal] The horizontal rotation, between 0 and 2*PI.
17953 * Optional, can be left undefined.
17954 * @param {number} [pos.vertical] The vertical rotation, between 0 and 0.5*PI.
17955 * if vertical=0.5*PI, the graph is shown from
17956 * the top. Optional, can be left undefined.
17957 * @param {number} [pos.distance] The (normalized) distance of the camera to the
17958 * center of the graph, a value between 0.71 and
17959 * 5.0. Optional, can be left undefined.
17960 */
17961
17962
17963Graph3d.prototype.setCameraPosition = function (pos) {
17964 setCameraPosition(pos, this);
17965 this.redraw();
17966};
17967/**
17968 * Set a new size for the graph
17969 *
17970 * @param {string} width Width in pixels or percentage (for example '800px'
17971 * or '50%')
17972 * @param {string} height Height in pixels or percentage (for example '400px'
17973 * or '30%')
17974 */
17975
17976
17977Graph3d.prototype.setSize = function (width, height) {
17978 this._setSize(width, height);
17979
17980 this.redraw();
17981}; // -----------------------------------------------------------------------------
17982
17983export { DELETE, DataSet, DataStream, DataView, Graph3d, Camera as Graph3dCamera, Filter as Graph3dFilter, Point2d_1 as Graph3dPoint2d, Point3d_1 as Graph3dPoint3d, Slider as Graph3dSlider, StepNumber_1 as Graph3dStepNumber, Queue, createNewDataPipeFrom, isDataSetLike, isDataViewLike };
17984//# sourceMappingURL=vis-graph3d.js.map