· 6 years ago · Sep 30, 2019, 12:24 AM
1/* builtbylane (@lanegoldberg) ~ here be dragons */
2(function() {
3 function r(e, n, t) {
4 function o(i, f) {
5 if (!n[i]) {
6 if (!e[i]) {
7 var c = "function" == typeof require && require;
8 if (!f && c) return c(i, !0);
9 if (u) return u(i, !0);
10 var a = new Error("Cannot find module '" + i + "'");
11 throw a.code = "MODULE_NOT_FOUND", a
12 }
13 var p = n[i] = {
14 exports: {}
15 };
16 e[i][0].call(p.exports, function(r) {
17 var n = e[i][1][r];
18 return o(n || r)
19 }, p, p.exports, r, e, n, t)
20 }
21 return n[i].exports
22 }
23 for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) o(t[i]);
24 return o
25 }
26 return r
27})()({
28 1: [function(require, module, exports) {
29 (function() {
30 var JSONP, computedUrl, createElement, encode, noop, objectToURI, random, randomString;
31
32 createElement = function(tag) {
33 return window.document.createElement(tag);
34 };
35
36 encode = window.encodeURIComponent;
37
38 random = Math.random;
39
40 JSONP = function(options) {
41 var callback, callbackFunc, callbackName, done, head, params, script;
42 if (options == null) {
43 options = {};
44 }
45 params = {
46 data: options.data || {},
47 error: options.error || noop,
48 success: options.success || noop,
49 beforeSend: options.beforeSend || noop,
50 complete: options.complete || noop,
51 url: options.url || ''
52 };
53 params.computedUrl = computedUrl(params);
54 if (params.url.length === 0) {
55 throw new Error('MissingUrl');
56 }
57 done = false;
58 if (params.beforeSend({}, params) !== false) {
59 callbackName = options.callbackName || 'callback';
60 callbackFunc = options.callbackFunc || 'jsonp_' + randomString(15);
61 callback = params.data[callbackName] = callbackFunc;
62 window[callback] = function(data) {
63 window[callback] = null;
64 params.success(data, params);
65 return params.complete(data, params);
66 };
67 script = createElement('script');
68 script.src = computedUrl(params);
69 script.async = true;
70 script.onerror = function(evt) {
71 params.error({
72 url: script.src,
73 event: evt
74 });
75 return params.complete({
76 url: script.src,
77 event: evt
78 }, params);
79 };
80 script.onload = script.onreadystatechange = function() {
81 var ref, ref1;
82 if (done || ((ref = this.readyState) !== 'loaded' && ref !== 'complete')) {
83 return;
84 }
85 done = true;
86 if (script) {
87 script.onload = script.onreadystatechange = null;
88 if ((ref1 = script.parentNode) != null) {
89 ref1.removeChild(script);
90 }
91 return script = null;
92 }
93 };
94 head = window.document.getElementsByTagName('head')[0] || window.document.documentElement;
95 head.insertBefore(script, head.firstChild);
96 }
97 return {
98 abort: function() {
99 window[callback] = function() {
100 return window[callback] = null;
101 };
102 done = true;
103 if (script != null ? script.parentNode : void 0) {
104 script.onload = script.onreadystatechange = null;
105 script.parentNode.removeChild(script);
106 return script = null;
107 }
108 }
109 };
110 };
111
112 noop = function() {
113 return void 0;
114 };
115
116 computedUrl = function(params) {
117 var url;
118 url = params.url;
119 url += params.url.indexOf('?') < 0 ? '?' : '&';
120 url += objectToURI(params.data);
121 return url;
122 };
123
124 randomString = function(length) {
125 var str;
126 str = '';
127 while (str.length < length) {
128 str += random().toString(36).slice(2, 3);
129 }
130 return str;
131 };
132
133 objectToURI = function(obj) {
134 var data, key, value;
135 data = (function() {
136 var results;
137 results = [];
138 for (key in obj) {
139 value = obj[key];
140 results.push(encode(key) + '=' + encode(value));
141 }
142 return results;
143 })();
144 return data.join('&');
145 };
146
147 if (typeof define !== "undefined" && define !== null ? define.amd : void 0) {
148 define(function() {
149 return JSONP;
150 });
151 } else if (typeof module !== "undefined" && module !== null ? module.exports : void 0) {
152 module.exports = JSONP;
153 } else {
154 this.JSONP = JSONP;
155 }
156
157 }).call(this);
158
159 }, {}],
160 2: [function(require, module, exports) {
161 require('../../modules/es6.string.iterator');
162 require('../../modules/es6.array.from');
163 module.exports = require('../../modules/_core').Array.from;
164
165 }, {
166 "../../modules/_core": 10,
167 "../../modules/es6.array.from": 55,
168 "../../modules/es6.string.iterator": 56
169 }],
170 3: [function(require, module, exports) {
171 require('../../modules/es7.array.includes');
172 module.exports = require('../../modules/_core').Array.includes;
173
174 }, {
175 "../../modules/_core": 10,
176 "../../modules/es7.array.includes": 57
177 }],
178 4: [function(require, module, exports) {
179 module.exports = function(it) {
180 if (typeof it != 'function') throw TypeError(it + ' is not a function!');
181 return it;
182 };
183
184 }, {}],
185 5: [function(require, module, exports) {
186 // 22.1.3.31 Array.prototype[@@unscopables]
187 var UNSCOPABLES = require('./_wks')('unscopables');
188 var ArrayProto = Array.prototype;
189 if (ArrayProto[UNSCOPABLES] == undefined) require('./_hide')(ArrayProto, UNSCOPABLES, {});
190 module.exports = function(key) {
191 ArrayProto[UNSCOPABLES][key] = true;
192 };
193
194 }, {
195 "./_hide": 22,
196 "./_wks": 53
197 }],
198 6: [function(require, module, exports) {
199 var isObject = require('./_is-object');
200 module.exports = function(it) {
201 if (!isObject(it)) throw TypeError(it + ' is not an object!');
202 return it;
203 };
204
205 }, {
206 "./_is-object": 27
207 }],
208 7: [function(require, module, exports) {
209 // false -> Array#indexOf
210 // true -> Array#includes
211 var toIObject = require('./_to-iobject');
212 var toLength = require('./_to-length');
213 var toAbsoluteIndex = require('./_to-absolute-index');
214 module.exports = function(IS_INCLUDES) {
215 return function($this, el, fromIndex) {
216 var O = toIObject($this);
217 var length = toLength(O.length);
218 var index = toAbsoluteIndex(fromIndex, length);
219 var value;
220 // Array#includes uses SameValueZero equality algorithm
221 // eslint-disable-next-line no-self-compare
222 if (IS_INCLUDES && el != el)
223 while (length > index) {
224 value = O[index++];
225 // eslint-disable-next-line no-self-compare
226 if (value != value) return true;
227 // Array#indexOf ignores holes, Array#includes - not
228 } else
229 for (; length > index; index++)
230 if (IS_INCLUDES || index in O) {
231 if (O[index] === el) return IS_INCLUDES || index || 0;
232 } return !IS_INCLUDES && -1;
233 };
234 };
235
236 }, {
237 "./_to-absolute-index": 46,
238 "./_to-iobject": 48,
239 "./_to-length": 49
240 }],
241 8: [function(require, module, exports) {
242 // getting tag from 19.1.3.6 Object.prototype.toString()
243 var cof = require('./_cof');
244 var TAG = require('./_wks')('toStringTag');
245 // ES3 wrong here
246 var ARG = cof(function() {
247 return arguments;
248 }()) == 'Arguments';
249
250 // fallback for IE11 Script Access Denied error
251 var tryGet = function(it, key) {
252 try {
253 return it[key];
254 } catch (e) {
255 /* empty */ }
256 };
257
258 module.exports = function(it) {
259 var O, T, B;
260 return it === undefined ? 'Undefined' : it === null ? 'Null'
261 // @@toStringTag case
262 :
263 typeof(T = tryGet(O = Object(it), TAG)) == 'string' ? T
264 // builtinTag case
265 :
266 ARG ? cof(O)
267 // ES3 arguments fallback
268 :
269 (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
270 };
271
272 }, {
273 "./_cof": 9,
274 "./_wks": 53
275 }],
276 9: [function(require, module, exports) {
277 var toString = {}.toString;
278
279 module.exports = function(it) {
280 return toString.call(it).slice(8, -1);
281 };
282
283 }, {}],
284 10: [function(require, module, exports) {
285 var core = module.exports = {
286 version: '2.6.9'
287 };
288 if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
289
290 }, {}],
291 11: [function(require, module, exports) {
292 'use strict';
293 var $defineProperty = require('./_object-dp');
294 var createDesc = require('./_property-desc');
295
296 module.exports = function(object, index, value) {
297 if (index in object) $defineProperty.f(object, index, createDesc(0, value));
298 else object[index] = value;
299 };
300
301 }, {
302 "./_object-dp": 35,
303 "./_property-desc": 40
304 }],
305 12: [function(require, module, exports) {
306 // optional / simple context binding
307 var aFunction = require('./_a-function');
308 module.exports = function(fn, that, length) {
309 aFunction(fn);
310 if (that === undefined) return fn;
311 switch (length) {
312 case 1:
313 return function(a) {
314 return fn.call(that, a);
315 };
316 case 2:
317 return function(a, b) {
318 return fn.call(that, a, b);
319 };
320 case 3:
321 return function(a, b, c) {
322 return fn.call(that, a, b, c);
323 };
324 }
325 return function( /* ...args */ ) {
326 return fn.apply(that, arguments);
327 };
328 };
329
330 }, {
331 "./_a-function": 4
332 }],
333 13: [function(require, module, exports) {
334 // 7.2.1 RequireObjectCoercible(argument)
335 module.exports = function(it) {
336 if (it == undefined) throw TypeError("Can't call method on " + it);
337 return it;
338 };
339
340 }, {}],
341 14: [function(require, module, exports) {
342 // Thank's IE8 for his funny defineProperty
343 module.exports = !require('./_fails')(function() {
344 return Object.defineProperty({}, 'a', {
345 get: function() {
346 return 7;
347 }
348 }).a != 7;
349 });
350
351 }, {
352 "./_fails": 18
353 }],
354 15: [function(require, module, exports) {
355 var isObject = require('./_is-object');
356 var document = require('./_global').document;
357 // typeof document.createElement is 'object' in old IE
358 var is = isObject(document) && isObject(document.createElement);
359 module.exports = function(it) {
360 return is ? document.createElement(it) : {};
361 };
362
363 }, {
364 "./_global": 20,
365 "./_is-object": 27
366 }],
367 16: [function(require, module, exports) {
368 // IE 8- don't enum bug keys
369 module.exports = (
370 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
371 ).split(',');
372
373 }, {}],
374 17: [function(require, module, exports) {
375 var global = require('./_global');
376 var core = require('./_core');
377 var hide = require('./_hide');
378 var redefine = require('./_redefine');
379 var ctx = require('./_ctx');
380 var PROTOTYPE = 'prototype';
381
382 var $export = function(type, name, source) {
383 var IS_FORCED = type & $export.F;
384 var IS_GLOBAL = type & $export.G;
385 var IS_STATIC = type & $export.S;
386 var IS_PROTO = type & $export.P;
387 var IS_BIND = type & $export.B;
388 var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
389 var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
390 var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
391 var key, own, out, exp;
392 if (IS_GLOBAL) source = name;
393 for (key in source) {
394 // contains in native
395 own = !IS_FORCED && target && target[key] !== undefined;
396 // export native or passed
397 out = (own ? target : source)[key];
398 // bind timers to global for call from export context
399 exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
400 // extend global
401 if (target) redefine(target, key, out, type & $export.U);
402 // export
403 if (exports[key] != out) hide(exports, key, exp);
404 if (IS_PROTO && expProto[key] != out) expProto[key] = out;
405 }
406 };
407 global.core = core;
408 // type bitmap
409 $export.F = 1; // forced
410 $export.G = 2; // global
411 $export.S = 4; // static
412 $export.P = 8; // proto
413 $export.B = 16; // bind
414 $export.W = 32; // wrap
415 $export.U = 64; // safe
416 $export.R = 128; // real proto method for `library`
417 module.exports = $export;
418
419 }, {
420 "./_core": 10,
421 "./_ctx": 12,
422 "./_global": 20,
423 "./_hide": 22,
424 "./_redefine": 41
425 }],
426 18: [function(require, module, exports) {
427 module.exports = function(exec) {
428 try {
429 return !!exec();
430 } catch (e) {
431 return true;
432 }
433 };
434
435 }, {}],
436 19: [function(require, module, exports) {
437 module.exports = require('./_shared')('native-function-to-string', Function.toString);
438
439 }, {
440 "./_shared": 44
441 }],
442 20: [function(require, module, exports) {
443 // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
444 var global = module.exports = typeof window != 'undefined' && window.Math == Math ?
445 window : typeof self != 'undefined' && self.Math == Math ? self
446 // eslint-disable-next-line no-new-func
447 :
448 Function('return this')();
449 if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
450
451 }, {}],
452 21: [function(require, module, exports) {
453 var hasOwnProperty = {}.hasOwnProperty;
454 module.exports = function(it, key) {
455 return hasOwnProperty.call(it, key);
456 };
457
458 }, {}],
459 22: [function(require, module, exports) {
460 var dP = require('./_object-dp');
461 var createDesc = require('./_property-desc');
462 module.exports = require('./_descriptors') ? function(object, key, value) {
463 return dP.f(object, key, createDesc(1, value));
464 } : function(object, key, value) {
465 object[key] = value;
466 return object;
467 };
468
469 }, {
470 "./_descriptors": 14,
471 "./_object-dp": 35,
472 "./_property-desc": 40
473 }],
474 23: [function(require, module, exports) {
475 var document = require('./_global').document;
476 module.exports = document && document.documentElement;
477
478 }, {
479 "./_global": 20
480 }],
481 24: [function(require, module, exports) {
482 module.exports = !require('./_descriptors') && !require('./_fails')(function() {
483 return Object.defineProperty(require('./_dom-create')('div'), 'a', {
484 get: function() {
485 return 7;
486 }
487 }).a != 7;
488 });
489
490 }, {
491 "./_descriptors": 14,
492 "./_dom-create": 15,
493 "./_fails": 18
494 }],
495 25: [function(require, module, exports) {
496 // fallback for non-array-like ES3 and non-enumerable old V8 strings
497 var cof = require('./_cof');
498 // eslint-disable-next-line no-prototype-builtins
499 module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it) {
500 return cof(it) == 'String' ? it.split('') : Object(it);
501 };
502
503 }, {
504 "./_cof": 9
505 }],
506 26: [function(require, module, exports) {
507 // check on default Array iterator
508 var Iterators = require('./_iterators');
509 var ITERATOR = require('./_wks')('iterator');
510 var ArrayProto = Array.prototype;
511
512 module.exports = function(it) {
513 return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
514 };
515
516 }, {
517 "./_iterators": 32,
518 "./_wks": 53
519 }],
520 27: [function(require, module, exports) {
521 module.exports = function(it) {
522 return typeof it === 'object' ? it !== null : typeof it === 'function';
523 };
524
525 }, {}],
526 28: [function(require, module, exports) {
527 // call something on iterator step with safe closing on error
528 var anObject = require('./_an-object');
529 module.exports = function(iterator, fn, value, entries) {
530 try {
531 return entries ? fn(anObject(value)[0], value[1]) : fn(value);
532 // 7.4.6 IteratorClose(iterator, completion)
533 } catch (e) {
534 var ret = iterator['return'];
535 if (ret !== undefined) anObject(ret.call(iterator));
536 throw e;
537 }
538 };
539
540 }, {
541 "./_an-object": 6
542 }],
543 29: [function(require, module, exports) {
544 'use strict';
545 var create = require('./_object-create');
546 var descriptor = require('./_property-desc');
547 var setToStringTag = require('./_set-to-string-tag');
548 var IteratorPrototype = {};
549
550 // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
551 require('./_hide')(IteratorPrototype, require('./_wks')('iterator'), function() {
552 return this;
553 });
554
555 module.exports = function(Constructor, NAME, next) {
556 Constructor.prototype = create(IteratorPrototype, {
557 next: descriptor(1, next)
558 });
559 setToStringTag(Constructor, NAME + ' Iterator');
560 };
561
562 }, {
563 "./_hide": 22,
564 "./_object-create": 34,
565 "./_property-desc": 40,
566 "./_set-to-string-tag": 42,
567 "./_wks": 53
568 }],
569 30: [function(require, module, exports) {
570 'use strict';
571 var LIBRARY = require('./_library');
572 var $export = require('./_export');
573 var redefine = require('./_redefine');
574 var hide = require('./_hide');
575 var Iterators = require('./_iterators');
576 var $iterCreate = require('./_iter-create');
577 var setToStringTag = require('./_set-to-string-tag');
578 var getPrototypeOf = require('./_object-gpo');
579 var ITERATOR = require('./_wks')('iterator');
580 var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
581 var FF_ITERATOR = '@@iterator';
582 var KEYS = 'keys';
583 var VALUES = 'values';
584
585 var returnThis = function() {
586 return this;
587 };
588
589 module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
590 $iterCreate(Constructor, NAME, next);
591 var getMethod = function(kind) {
592 if (!BUGGY && kind in proto) return proto[kind];
593 switch (kind) {
594 case KEYS:
595 return function keys() {
596 return new Constructor(this, kind);
597 };
598 case VALUES:
599 return function values() {
600 return new Constructor(this, kind);
601 };
602 }
603 return function entries() {
604 return new Constructor(this, kind);
605 };
606 };
607 var TAG = NAME + ' Iterator';
608 var DEF_VALUES = DEFAULT == VALUES;
609 var VALUES_BUG = false;
610 var proto = Base.prototype;
611 var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
612 var $default = $native || getMethod(DEFAULT);
613 var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
614 var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
615 var methods, key, IteratorPrototype;
616 // Fix native
617 if ($anyNative) {
618 IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
619 if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
620 // Set @@toStringTag to native iterators
621 setToStringTag(IteratorPrototype, TAG, true);
622 // fix for some old engines
623 if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
624 }
625 }
626 // fix Array#{values, @@iterator}.name in V8 / FF
627 if (DEF_VALUES && $native && $native.name !== VALUES) {
628 VALUES_BUG = true;
629 $default = function values() {
630 return $native.call(this);
631 };
632 }
633 // Define iterator
634 if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
635 hide(proto, ITERATOR, $default);
636 }
637 // Plug for library
638 Iterators[NAME] = $default;
639 Iterators[TAG] = returnThis;
640 if (DEFAULT) {
641 methods = {
642 values: DEF_VALUES ? $default : getMethod(VALUES),
643 keys: IS_SET ? $default : getMethod(KEYS),
644 entries: $entries
645 };
646 if (FORCED)
647 for (key in methods) {
648 if (!(key in proto)) redefine(proto, key, methods[key]);
649 } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
650 }
651 return methods;
652 };
653
654 }, {
655 "./_export": 17,
656 "./_hide": 22,
657 "./_iter-create": 29,
658 "./_iterators": 32,
659 "./_library": 33,
660 "./_object-gpo": 37,
661 "./_redefine": 41,
662 "./_set-to-string-tag": 42,
663 "./_wks": 53
664 }],
665 31: [function(require, module, exports) {
666 var ITERATOR = require('./_wks')('iterator');
667 var SAFE_CLOSING = false;
668
669 try {
670 var riter = [7][ITERATOR]();
671 riter['return'] = function() {
672 SAFE_CLOSING = true;
673 };
674 // eslint-disable-next-line no-throw-literal
675 Array.from(riter, function() {
676 throw 2;
677 });
678 } catch (e) {
679 /* empty */ }
680
681 module.exports = function(exec, skipClosing) {
682 if (!skipClosing && !SAFE_CLOSING) return false;
683 var safe = false;
684 try {
685 var arr = [7];
686 var iter = arr[ITERATOR]();
687 iter.next = function() {
688 return {
689 done: safe = true
690 };
691 };
692 arr[ITERATOR] = function() {
693 return iter;
694 };
695 exec(arr);
696 } catch (e) {
697 /* empty */ }
698 return safe;
699 };
700
701 }, {
702 "./_wks": 53
703 }],
704 32: [function(require, module, exports) {
705 module.exports = {};
706
707 }, {}],
708 33: [function(require, module, exports) {
709 module.exports = false;
710
711 }, {}],
712 34: [function(require, module, exports) {
713 // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
714 var anObject = require('./_an-object');
715 var dPs = require('./_object-dps');
716 var enumBugKeys = require('./_enum-bug-keys');
717 var IE_PROTO = require('./_shared-key')('IE_PROTO');
718 var Empty = function() {
719 /* empty */ };
720 var PROTOTYPE = 'prototype';
721
722 // Create object with fake `null` prototype: use iframe Object with cleared prototype
723 var createDict = function() {
724 // Thrash, waste and sodomy: IE GC bug
725 var iframe = require('./_dom-create')('iframe');
726 var i = enumBugKeys.length;
727 var lt = '<';
728 var gt = '>';
729 var iframeDocument;
730 iframe.style.display = 'none';
731 require('./_html').appendChild(iframe);
732 iframe.src = 'javascript:'; // eslint-disable-line no-script-url
733 // createDict = iframe.contentWindow.Object;
734 // html.removeChild(iframe);
735 iframeDocument = iframe.contentWindow.document;
736 iframeDocument.open();
737 iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
738 iframeDocument.close();
739 createDict = iframeDocument.F;
740 while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
741 return createDict();
742 };
743
744 module.exports = Object.create || function create(O, Properties) {
745 var result;
746 if (O !== null) {
747 Empty[PROTOTYPE] = anObject(O);
748 result = new Empty();
749 Empty[PROTOTYPE] = null;
750 // add "__proto__" for Object.getPrototypeOf polyfill
751 result[IE_PROTO] = O;
752 } else result = createDict();
753 return Properties === undefined ? result : dPs(result, Properties);
754 };
755
756 }, {
757 "./_an-object": 6,
758 "./_dom-create": 15,
759 "./_enum-bug-keys": 16,
760 "./_html": 23,
761 "./_object-dps": 36,
762 "./_shared-key": 43
763 }],
764 35: [function(require, module, exports) {
765 var anObject = require('./_an-object');
766 var IE8_DOM_DEFINE = require('./_ie8-dom-define');
767 var toPrimitive = require('./_to-primitive');
768 var dP = Object.defineProperty;
769
770 exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
771 anObject(O);
772 P = toPrimitive(P, true);
773 anObject(Attributes);
774 if (IE8_DOM_DEFINE) try {
775 return dP(O, P, Attributes);
776 } catch (e) {
777 /* empty */ }
778 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
779 if ('value' in Attributes) O[P] = Attributes.value;
780 return O;
781 };
782
783 }, {
784 "./_an-object": 6,
785 "./_descriptors": 14,
786 "./_ie8-dom-define": 24,
787 "./_to-primitive": 51
788 }],
789 36: [function(require, module, exports) {
790 var dP = require('./_object-dp');
791 var anObject = require('./_an-object');
792 var getKeys = require('./_object-keys');
793
794 module.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {
795 anObject(O);
796 var keys = getKeys(Properties);
797 var length = keys.length;
798 var i = 0;
799 var P;
800 while (length > i) dP.f(O, P = keys[i++], Properties[P]);
801 return O;
802 };
803
804 }, {
805 "./_an-object": 6,
806 "./_descriptors": 14,
807 "./_object-dp": 35,
808 "./_object-keys": 39
809 }],
810 37: [function(require, module, exports) {
811 // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
812 var has = require('./_has');
813 var toObject = require('./_to-object');
814 var IE_PROTO = require('./_shared-key')('IE_PROTO');
815 var ObjectProto = Object.prototype;
816
817 module.exports = Object.getPrototypeOf || function(O) {
818 O = toObject(O);
819 if (has(O, IE_PROTO)) return O[IE_PROTO];
820 if (typeof O.constructor == 'function' && O instanceof O.constructor) {
821 return O.constructor.prototype;
822 }
823 return O instanceof Object ? ObjectProto : null;
824 };
825
826 }, {
827 "./_has": 21,
828 "./_shared-key": 43,
829 "./_to-object": 50
830 }],
831 38: [function(require, module, exports) {
832 var has = require('./_has');
833 var toIObject = require('./_to-iobject');
834 var arrayIndexOf = require('./_array-includes')(false);
835 var IE_PROTO = require('./_shared-key')('IE_PROTO');
836
837 module.exports = function(object, names) {
838 var O = toIObject(object);
839 var i = 0;
840 var result = [];
841 var key;
842 for (key in O)
843 if (key != IE_PROTO) has(O, key) && result.push(key);
844 // Don't enum bug & hidden keys
845 while (names.length > i)
846 if (has(O, key = names[i++])) {
847 ~arrayIndexOf(result, key) || result.push(key);
848 }
849 return result;
850 };
851
852 }, {
853 "./_array-includes": 7,
854 "./_has": 21,
855 "./_shared-key": 43,
856 "./_to-iobject": 48
857 }],
858 39: [function(require, module, exports) {
859 // 19.1.2.14 / 15.2.3.14 Object.keys(O)
860 var $keys = require('./_object-keys-internal');
861 var enumBugKeys = require('./_enum-bug-keys');
862
863 module.exports = Object.keys || function keys(O) {
864 return $keys(O, enumBugKeys);
865 };
866
867 }, {
868 "./_enum-bug-keys": 16,
869 "./_object-keys-internal": 38
870 }],
871 40: [function(require, module, exports) {
872 module.exports = function(bitmap, value) {
873 return {
874 enumerable: !(bitmap & 1),
875 configurable: !(bitmap & 2),
876 writable: !(bitmap & 4),
877 value: value
878 };
879 };
880
881 }, {}],
882 41: [function(require, module, exports) {
883 var global = require('./_global');
884 var hide = require('./_hide');
885 var has = require('./_has');
886 var SRC = require('./_uid')('src');
887 var $toString = require('./_function-to-string');
888 var TO_STRING = 'toString';
889 var TPL = ('' + $toString).split(TO_STRING);
890
891 require('./_core').inspectSource = function(it) {
892 return $toString.call(it);
893 };
894
895 (module.exports = function(O, key, val, safe) {
896 var isFunction = typeof val == 'function';
897 if (isFunction) has(val, 'name') || hide(val, 'name', key);
898 if (O[key] === val) return;
899 if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
900 if (O === global) {
901 O[key] = val;
902 } else if (!safe) {
903 delete O[key];
904 hide(O, key, val);
905 } else if (O[key]) {
906 O[key] = val;
907 } else {
908 hide(O, key, val);
909 }
910 // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
911 })(Function.prototype, TO_STRING, function toString() {
912 return typeof this == 'function' && this[SRC] || $toString.call(this);
913 });
914
915 }, {
916 "./_core": 10,
917 "./_function-to-string": 19,
918 "./_global": 20,
919 "./_has": 21,
920 "./_hide": 22,
921 "./_uid": 52
922 }],
923 42: [function(require, module, exports) {
924 var def = require('./_object-dp').f;
925 var has = require('./_has');
926 var TAG = require('./_wks')('toStringTag');
927
928 module.exports = function(it, tag, stat) {
929 if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {
930 configurable: true,
931 value: tag
932 });
933 };
934
935 }, {
936 "./_has": 21,
937 "./_object-dp": 35,
938 "./_wks": 53
939 }],
940 43: [function(require, module, exports) {
941 var shared = require('./_shared')('keys');
942 var uid = require('./_uid');
943 module.exports = function(key) {
944 return shared[key] || (shared[key] = uid(key));
945 };
946
947 }, {
948 "./_shared": 44,
949 "./_uid": 52
950 }],
951 44: [function(require, module, exports) {
952 var core = require('./_core');
953 var global = require('./_global');
954 var SHARED = '__core-js_shared__';
955 var store = global[SHARED] || (global[SHARED] = {});
956
957 (module.exports = function(key, value) {
958 return store[key] || (store[key] = value !== undefined ? value : {});
959 })('versions', []).push({
960 version: core.version,
961 mode: require('./_library') ? 'pure' : 'global',
962 copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
963 });
964
965 }, {
966 "./_core": 10,
967 "./_global": 20,
968 "./_library": 33
969 }],
970 45: [function(require, module, exports) {
971 var toInteger = require('./_to-integer');
972 var defined = require('./_defined');
973 // true -> String#at
974 // false -> String#codePointAt
975 module.exports = function(TO_STRING) {
976 return function(that, pos) {
977 var s = String(defined(that));
978 var i = toInteger(pos);
979 var l = s.length;
980 var a, b;
981 if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
982 a = s.charCodeAt(i);
983 return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ?
984 TO_STRING ? s.charAt(i) : a :
985 TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
986 };
987 };
988
989 }, {
990 "./_defined": 13,
991 "./_to-integer": 47
992 }],
993 46: [function(require, module, exports) {
994 var toInteger = require('./_to-integer');
995 var max = Math.max;
996 var min = Math.min;
997 module.exports = function(index, length) {
998 index = toInteger(index);
999 return index < 0 ? max(index + length, 0) : min(index, length);
1000 };
1001
1002 }, {
1003 "./_to-integer": 47
1004 }],
1005 47: [function(require, module, exports) {
1006 // 7.1.4 ToInteger
1007 var ceil = Math.ceil;
1008 var floor = Math.floor;
1009 module.exports = function(it) {
1010 return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
1011 };
1012
1013 }, {}],
1014 48: [function(require, module, exports) {
1015 // to indexed object, toObject with fallback for non-array-like ES3 strings
1016 var IObject = require('./_iobject');
1017 var defined = require('./_defined');
1018 module.exports = function(it) {
1019 return IObject(defined(it));
1020 };
1021
1022 }, {
1023 "./_defined": 13,
1024 "./_iobject": 25
1025 }],
1026 49: [function(require, module, exports) {
1027 // 7.1.15 ToLength
1028 var toInteger = require('./_to-integer');
1029 var min = Math.min;
1030 module.exports = function(it) {
1031 return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
1032 };
1033
1034 }, {
1035 "./_to-integer": 47
1036 }],
1037 50: [function(require, module, exports) {
1038 // 7.1.13 ToObject(argument)
1039 var defined = require('./_defined');
1040 module.exports = function(it) {
1041 return Object(defined(it));
1042 };
1043
1044 }, {
1045 "./_defined": 13
1046 }],
1047 51: [function(require, module, exports) {
1048 // 7.1.1 ToPrimitive(input [, PreferredType])
1049 var isObject = require('./_is-object');
1050 // instead of the ES6 spec version, we didn't implement @@toPrimitive case
1051 // and the second argument - flag - preferred type is a string
1052 module.exports = function(it, S) {
1053 if (!isObject(it)) return it;
1054 var fn, val;
1055 if (S && typeof(fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
1056 if (typeof(fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
1057 if (!S && typeof(fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
1058 throw TypeError("Can't convert object to primitive value");
1059 };
1060
1061 }, {
1062 "./_is-object": 27
1063 }],
1064 52: [function(require, module, exports) {
1065 var id = 0;
1066 var px = Math.random();
1067 module.exports = function(key) {
1068 return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
1069 };
1070
1071 }, {}],
1072 53: [function(require, module, exports) {
1073 var store = require('./_shared')('wks');
1074 var uid = require('./_uid');
1075 var Symbol = require('./_global').Symbol;
1076 var USE_SYMBOL = typeof Symbol == 'function';
1077
1078 var $exports = module.exports = function(name) {
1079 return store[name] || (store[name] =
1080 USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
1081 };
1082
1083 $exports.store = store;
1084
1085 }, {
1086 "./_global": 20,
1087 "./_shared": 44,
1088 "./_uid": 52
1089 }],
1090 54: [function(require, module, exports) {
1091 var classof = require('./_classof');
1092 var ITERATOR = require('./_wks')('iterator');
1093 var Iterators = require('./_iterators');
1094 module.exports = require('./_core').getIteratorMethod = function(it) {
1095 if (it != undefined) return it[ITERATOR] ||
1096 it['@@iterator'] ||
1097 Iterators[classof(it)];
1098 };
1099
1100 }, {
1101 "./_classof": 8,
1102 "./_core": 10,
1103 "./_iterators": 32,
1104 "./_wks": 53
1105 }],
1106 55: [function(require, module, exports) {
1107 'use strict';
1108 var ctx = require('./_ctx');
1109 var $export = require('./_export');
1110 var toObject = require('./_to-object');
1111 var call = require('./_iter-call');
1112 var isArrayIter = require('./_is-array-iter');
1113 var toLength = require('./_to-length');
1114 var createProperty = require('./_create-property');
1115 var getIterFn = require('./core.get-iterator-method');
1116
1117 $export($export.S + $export.F * !require('./_iter-detect')(function(iter) {
1118 Array.from(iter);
1119 }), 'Array', {
1120 // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
1121 from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */ ) {
1122 var O = toObject(arrayLike);
1123 var C = typeof this == 'function' ? this : Array;
1124 var aLen = arguments.length;
1125 var mapfn = aLen > 1 ? arguments[1] : undefined;
1126 var mapping = mapfn !== undefined;
1127 var index = 0;
1128 var iterFn = getIterFn(O);
1129 var length, result, step, iterator;
1130 if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
1131 // if object isn't iterable or it's array with default iterator - use simple case
1132 if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
1133 for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
1134 createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
1135 }
1136 } else {
1137 length = toLength(O.length);
1138 for (result = new C(length); length > index; index++) {
1139 createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
1140 }
1141 }
1142 result.length = index;
1143 return result;
1144 }
1145 });
1146
1147 }, {
1148 "./_create-property": 11,
1149 "./_ctx": 12,
1150 "./_export": 17,
1151 "./_is-array-iter": 26,
1152 "./_iter-call": 28,
1153 "./_iter-detect": 31,
1154 "./_to-length": 49,
1155 "./_to-object": 50,
1156 "./core.get-iterator-method": 54
1157 }],
1158 56: [function(require, module, exports) {
1159 'use strict';
1160 var $at = require('./_string-at')(true);
1161
1162 // 21.1.3.27 String.prototype[@@iterator]()
1163 require('./_iter-define')(String, 'String', function(iterated) {
1164 this._t = String(iterated); // target
1165 this._i = 0; // next index
1166 // 21.1.5.2.1 %StringIteratorPrototype%.next()
1167 }, function() {
1168 var O = this._t;
1169 var index = this._i;
1170 var point;
1171 if (index >= O.length) return {
1172 value: undefined,
1173 done: true
1174 };
1175 point = $at(O, index);
1176 this._i += point.length;
1177 return {
1178 value: point,
1179 done: false
1180 };
1181 });
1182
1183 }, {
1184 "./_iter-define": 30,
1185 "./_string-at": 45
1186 }],
1187 57: [function(require, module, exports) {
1188 'use strict';
1189 // https://github.com/tc39/Array.prototype.includes
1190 var $export = require('./_export');
1191 var $includes = require('./_array-includes')(true);
1192
1193 $export($export.P, 'Array', {
1194 includes: function includes(el /* , fromIndex = 0 */ ) {
1195 return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
1196 }
1197 });
1198
1199 require('./_add-to-unscopables')('includes');
1200
1201 }, {
1202 "./_add-to-unscopables": 5,
1203 "./_array-includes": 7,
1204 "./_export": 17
1205 }],
1206 58: [function(require, module, exports) {
1207 /*global window */
1208 /**
1209 * @license countdown.js v2.6.0 http://countdownjs.org
1210 * Copyright (c)2006-2014 Stephen M. McKamey.
1211 * Licensed under The MIT License.
1212 */
1213 /*jshint bitwise:false */
1214
1215 /**
1216 * @public
1217 * @type {Object|null}
1218 */
1219 var module;
1220
1221 /**
1222 * API entry
1223 * @public
1224 * @param {function(Object)|Date|number} start the starting date
1225 * @param {function(Object)|Date|number} end the ending date
1226 * @param {number} units the units to populate
1227 * @return {Object|number}
1228 */
1229 var countdown = (
1230
1231 /**
1232 * @param {Object} module CommonJS Module
1233 */
1234 function(module) {
1235 /*jshint smarttabs:true */
1236
1237 'use strict';
1238
1239 /**
1240 * @private
1241 * @const
1242 * @type {number}
1243 */
1244 var MILLISECONDS = 0x001;
1245
1246 /**
1247 * @private
1248 * @const
1249 * @type {number}
1250 */
1251 var SECONDS = 0x002;
1252
1253 /**
1254 * @private
1255 * @const
1256 * @type {number}
1257 */
1258 var MINUTES = 0x004;
1259
1260 /**
1261 * @private
1262 * @const
1263 * @type {number}
1264 */
1265 var HOURS = 0x008;
1266
1267 /**
1268 * @private
1269 * @const
1270 * @type {number}
1271 */
1272 var DAYS = 0x010;
1273
1274 /**
1275 * @private
1276 * @const
1277 * @type {number}
1278 */
1279 var WEEKS = 0x020;
1280
1281 /**
1282 * @private
1283 * @const
1284 * @type {number}
1285 */
1286 var MONTHS = 0x040;
1287
1288 /**
1289 * @private
1290 * @const
1291 * @type {number}
1292 */
1293 var YEARS = 0x080;
1294
1295 /**
1296 * @private
1297 * @const
1298 * @type {number}
1299 */
1300 var DECADES = 0x100;
1301
1302 /**
1303 * @private
1304 * @const
1305 * @type {number}
1306 */
1307 var CENTURIES = 0x200;
1308
1309 /**
1310 * @private
1311 * @const
1312 * @type {number}
1313 */
1314 var MILLENNIA = 0x400;
1315
1316 /**
1317 * @private
1318 * @const
1319 * @type {number}
1320 */
1321 var DEFAULTS = YEARS | MONTHS | DAYS | HOURS | MINUTES | SECONDS;
1322
1323 /**
1324 * @private
1325 * @const
1326 * @type {number}
1327 */
1328 var MILLISECONDS_PER_SECOND = 1000;
1329
1330 /**
1331 * @private
1332 * @const
1333 * @type {number}
1334 */
1335 var SECONDS_PER_MINUTE = 60;
1336
1337 /**
1338 * @private
1339 * @const
1340 * @type {number}
1341 */
1342 var MINUTES_PER_HOUR = 60;
1343
1344 /**
1345 * @private
1346 * @const
1347 * @type {number}
1348 */
1349 var HOURS_PER_DAY = 24;
1350
1351 /**
1352 * @private
1353 * @const
1354 * @type {number}
1355 */
1356 var MILLISECONDS_PER_DAY = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MILLISECONDS_PER_SECOND;
1357
1358 /**
1359 * @private
1360 * @const
1361 * @type {number}
1362 */
1363 var DAYS_PER_WEEK = 7;
1364
1365 /**
1366 * @private
1367 * @const
1368 * @type {number}
1369 */
1370 var MONTHS_PER_YEAR = 12;
1371
1372 /**
1373 * @private
1374 * @const
1375 * @type {number}
1376 */
1377 var YEARS_PER_DECADE = 10;
1378
1379 /**
1380 * @private
1381 * @const
1382 * @type {number}
1383 */
1384 var DECADES_PER_CENTURY = 10;
1385
1386 /**
1387 * @private
1388 * @const
1389 * @type {number}
1390 */
1391 var CENTURIES_PER_MILLENNIUM = 10;
1392
1393 /**
1394 * @private
1395 * @param {number} x number
1396 * @return {number}
1397 */
1398 var ceil = Math.ceil;
1399
1400 /**
1401 * @private
1402 * @param {number} x number
1403 * @return {number}
1404 */
1405 var floor = Math.floor;
1406
1407 /**
1408 * @private
1409 * @param {Date} ref reference date
1410 * @param {number} shift number of months to shift
1411 * @return {number} number of days shifted
1412 */
1413 function borrowMonths(ref, shift) {
1414 var prevTime = ref.getTime();
1415
1416 // increment month by shift
1417 ref.setMonth(ref.getMonth() + shift);
1418
1419 // this is the trickiest since months vary in length
1420 return Math.round((ref.getTime() - prevTime) / MILLISECONDS_PER_DAY);
1421 }
1422
1423 /**
1424 * @private
1425 * @param {Date} ref reference date
1426 * @return {number} number of days
1427 */
1428 function daysPerMonth(ref) {
1429 var a = ref.getTime();
1430
1431 // increment month by 1
1432 var b = new Date(a);
1433 b.setMonth(ref.getMonth() + 1);
1434
1435 // this is the trickiest since months vary in length
1436 return Math.round((b.getTime() - a) / MILLISECONDS_PER_DAY);
1437 }
1438
1439 /**
1440 * @private
1441 * @param {Date} ref reference date
1442 * @return {number} number of days
1443 */
1444 function daysPerYear(ref) {
1445 var a = ref.getTime();
1446
1447 // increment year by 1
1448 var b = new Date(a);
1449 b.setFullYear(ref.getFullYear() + 1);
1450
1451 // this is the trickiest since years (periodically) vary in length
1452 return Math.round((b.getTime() - a) / MILLISECONDS_PER_DAY);
1453 }
1454
1455 /**
1456 * Applies the Timespan to the given date.
1457 *
1458 * @private
1459 * @param {Timespan} ts
1460 * @param {Date=} date
1461 * @return {Date}
1462 */
1463 function addToDate(ts, date) {
1464 date = (date instanceof Date) || ((date !== null) && isFinite(date)) ? new Date(+date) : new Date();
1465 if (!ts) {
1466 return date;
1467 }
1468
1469 // if there is a value field, use it directly
1470 var value = +ts.value || 0;
1471 if (value) {
1472 date.setTime(date.getTime() + value);
1473 return date;
1474 }
1475
1476 value = +ts.milliseconds || 0;
1477 if (value) {
1478 date.setMilliseconds(date.getMilliseconds() + value);
1479 }
1480
1481 value = +ts.seconds || 0;
1482 if (value) {
1483 date.setSeconds(date.getSeconds() + value);
1484 }
1485
1486 value = +ts.minutes || 0;
1487 if (value) {
1488 date.setMinutes(date.getMinutes() + value);
1489 }
1490
1491 value = +ts.hours || 0;
1492 if (value) {
1493 date.setHours(date.getHours() + value);
1494 }
1495
1496 value = +ts.weeks || 0;
1497 if (value) {
1498 value *= DAYS_PER_WEEK;
1499 }
1500
1501 value += +ts.days || 0;
1502 if (value) {
1503 date.setDate(date.getDate() + value);
1504 }
1505
1506 value = +ts.months || 0;
1507 if (value) {
1508 date.setMonth(date.getMonth() + value);
1509 }
1510
1511 value = +ts.millennia || 0;
1512 if (value) {
1513 value *= CENTURIES_PER_MILLENNIUM;
1514 }
1515
1516 value += +ts.centuries || 0;
1517 if (value) {
1518 value *= DECADES_PER_CENTURY;
1519 }
1520
1521 value += +ts.decades || 0;
1522 if (value) {
1523 value *= YEARS_PER_DECADE;
1524 }
1525
1526 value += +ts.years || 0;
1527 if (value) {
1528 date.setFullYear(date.getFullYear() + value);
1529 }
1530
1531 return date;
1532 }
1533
1534 /**
1535 * @private
1536 * @const
1537 * @type {number}
1538 */
1539 var LABEL_MILLISECONDS = 0;
1540
1541 /**
1542 * @private
1543 * @const
1544 * @type {number}
1545 */
1546 var LABEL_SECONDS = 1;
1547
1548 /**
1549 * @private
1550 * @const
1551 * @type {number}
1552 */
1553 var LABEL_MINUTES = 2;
1554
1555 /**
1556 * @private
1557 * @const
1558 * @type {number}
1559 */
1560 var LABEL_HOURS = 3;
1561
1562 /**
1563 * @private
1564 * @const
1565 * @type {number}
1566 */
1567 var LABEL_DAYS = 4;
1568
1569 /**
1570 * @private
1571 * @const
1572 * @type {number}
1573 */
1574 var LABEL_WEEKS = 5;
1575
1576 /**
1577 * @private
1578 * @const
1579 * @type {number}
1580 */
1581 var LABEL_MONTHS = 6;
1582
1583 /**
1584 * @private
1585 * @const
1586 * @type {number}
1587 */
1588 var LABEL_YEARS = 7;
1589
1590 /**
1591 * @private
1592 * @const
1593 * @type {number}
1594 */
1595 var LABEL_DECADES = 8;
1596
1597 /**
1598 * @private
1599 * @const
1600 * @type {number}
1601 */
1602 var LABEL_CENTURIES = 9;
1603
1604 /**
1605 * @private
1606 * @const
1607 * @type {number}
1608 */
1609 var LABEL_MILLENNIA = 10;
1610
1611 /**
1612 * @private
1613 * @type {Array}
1614 */
1615 var LABELS_SINGLUAR;
1616
1617 /**
1618 * @private
1619 * @type {Array}
1620 */
1621 var LABELS_PLURAL;
1622
1623 /**
1624 * @private
1625 * @type {string}
1626 */
1627 var LABEL_LAST;
1628
1629 /**
1630 * @private
1631 * @type {string}
1632 */
1633 var LABEL_DELIM;
1634
1635 /**
1636 * @private
1637 * @type {string}
1638 */
1639 var LABEL_NOW;
1640
1641 /**
1642 * Formats a number & unit as a string
1643 *
1644 * @param {number} value
1645 * @param {number} unit
1646 * @return {string}
1647 */
1648 var formatter;
1649
1650 /**
1651 * Formats a number as a string
1652 *
1653 * @private
1654 * @param {number} value
1655 * @return {string}
1656 */
1657 var formatNumber;
1658
1659 /**
1660 * @private
1661 * @param {number} value
1662 * @param {number} unit unit index into label list
1663 * @return {string}
1664 */
1665 function plurality(value, unit) {
1666 return formatNumber(value) + ((value === 1) ? LABELS_SINGLUAR[unit] : LABELS_PLURAL[unit]);
1667 }
1668
1669 /**
1670 * Formats the entries with singular or plural labels
1671 *
1672 * @private
1673 * @param {Timespan} ts
1674 * @return {Array}
1675 */
1676 var formatList;
1677
1678 /**
1679 * Timespan representation of a duration of time
1680 *
1681 * @private
1682 * @this {Timespan}
1683 * @constructor
1684 */
1685 function Timespan() {}
1686
1687 /**
1688 * Formats the Timespan as a sentence
1689 *
1690 * @param {string=} emptyLabel the string to use when no values returned
1691 * @return {string}
1692 */
1693 Timespan.prototype.toString = function(emptyLabel) {
1694 var label = formatList(this);
1695
1696 var count = label.length;
1697 if (!count) {
1698 return emptyLabel ? '' + emptyLabel : LABEL_NOW;
1699 }
1700 if (count === 1) {
1701 return label[0];
1702 }
1703
1704 var last = LABEL_LAST + label.pop();
1705 return label.join(LABEL_DELIM) + last;
1706 };
1707
1708 /**
1709 * Formats the Timespan as a sentence in HTML
1710 *
1711 * @param {string=} tag HTML tag name to wrap each value
1712 * @param {string=} emptyLabel the string to use when no values returned
1713 * @return {string}
1714 */
1715 Timespan.prototype.toHTML = function(tag, emptyLabel) {
1716 tag = tag || 'span';
1717 var label = formatList(this);
1718
1719 var count = label.length;
1720 if (!count) {
1721 emptyLabel = emptyLabel || LABEL_NOW;
1722 return emptyLabel ? '<' + tag + '>' + emptyLabel + '</' + tag + '>' : emptyLabel;
1723 }
1724 for (var i = 0; i < count; i++) {
1725 // wrap each unit in tag
1726 label[i] = '<' + tag + '>' + label[i] + '</' + tag + '>';
1727 }
1728 if (count === 1) {
1729 return label[0];
1730 }
1731
1732 var last = LABEL_LAST + label.pop();
1733 return label.join(LABEL_DELIM) + last;
1734 };
1735
1736 /**
1737 * Applies the Timespan to the given date
1738 *
1739 * @param {Date=} date the date to which the timespan is added.
1740 * @return {Date}
1741 */
1742 Timespan.prototype.addTo = function(date) {
1743 return addToDate(this, date);
1744 };
1745
1746 /**
1747 * Formats the entries as English labels
1748 *
1749 * @private
1750 * @param {Timespan} ts
1751 * @return {Array}
1752 */
1753 formatList = function(ts) {
1754 var list = [];
1755
1756 var value = ts.millennia;
1757 if (value) {
1758 list.push(formatter(value, LABEL_MILLENNIA));
1759 }
1760
1761 value = ts.centuries;
1762 if (value) {
1763 list.push(formatter(value, LABEL_CENTURIES));
1764 }
1765
1766 value = ts.decades;
1767 if (value) {
1768 list.push(formatter(value, LABEL_DECADES));
1769 }
1770
1771 value = ts.years;
1772 if (value) {
1773 list.push(formatter(value, LABEL_YEARS));
1774 }
1775
1776 value = ts.months;
1777 if (value) {
1778 list.push(formatter(value, LABEL_MONTHS));
1779 }
1780
1781 value = ts.weeks;
1782 if (value) {
1783 list.push(formatter(value, LABEL_WEEKS));
1784 }
1785
1786 value = ts.days;
1787 if (value) {
1788 list.push(formatter(value, LABEL_DAYS));
1789 }
1790
1791 value = ts.hours;
1792 if (value) {
1793 list.push(formatter(value, LABEL_HOURS));
1794 }
1795
1796 value = ts.minutes;
1797 if (value) {
1798 list.push(formatter(value, LABEL_MINUTES));
1799 }
1800
1801 value = ts.seconds;
1802 if (value) {
1803 list.push(formatter(value, LABEL_SECONDS));
1804 }
1805
1806 value = ts.milliseconds;
1807 if (value) {
1808 list.push(formatter(value, LABEL_MILLISECONDS));
1809 }
1810
1811 return list;
1812 };
1813
1814 /**
1815 * Borrow any underflow units, carry any overflow units
1816 *
1817 * @private
1818 * @param {Timespan} ts
1819 * @param {string} toUnit
1820 */
1821 function rippleRounded(ts, toUnit) {
1822 switch (toUnit) {
1823 case 'seconds':
1824 if (ts.seconds !== SECONDS_PER_MINUTE || isNaN(ts.minutes)) {
1825 return;
1826 }
1827 // ripple seconds up to minutes
1828 ts.minutes++;
1829 ts.seconds = 0;
1830
1831 /* falls through */
1832 case 'minutes':
1833 if (ts.minutes !== MINUTES_PER_HOUR || isNaN(ts.hours)) {
1834 return;
1835 }
1836 // ripple minutes up to hours
1837 ts.hours++;
1838 ts.minutes = 0;
1839
1840 /* falls through */
1841 case 'hours':
1842 if (ts.hours !== HOURS_PER_DAY || isNaN(ts.days)) {
1843 return;
1844 }
1845 // ripple hours up to days
1846 ts.days++;
1847 ts.hours = 0;
1848
1849 /* falls through */
1850 case 'days':
1851 if (ts.days !== DAYS_PER_WEEK || isNaN(ts.weeks)) {
1852 return;
1853 }
1854 // ripple days up to weeks
1855 ts.weeks++;
1856 ts.days = 0;
1857
1858 /* falls through */
1859 case 'weeks':
1860 if (ts.weeks !== daysPerMonth(ts.refMonth) / DAYS_PER_WEEK || isNaN(ts.months)) {
1861 return;
1862 }
1863 // ripple weeks up to months
1864 ts.months++;
1865 ts.weeks = 0;
1866
1867 /* falls through */
1868 case 'months':
1869 if (ts.months !== MONTHS_PER_YEAR || isNaN(ts.years)) {
1870 return;
1871 }
1872 // ripple months up to years
1873 ts.years++;
1874 ts.months = 0;
1875
1876 /* falls through */
1877 case 'years':
1878 if (ts.years !== YEARS_PER_DECADE || isNaN(ts.decades)) {
1879 return;
1880 }
1881 // ripple years up to decades
1882 ts.decades++;
1883 ts.years = 0;
1884
1885 /* falls through */
1886 case 'decades':
1887 if (ts.decades !== DECADES_PER_CENTURY || isNaN(ts.centuries)) {
1888 return;
1889 }
1890 // ripple decades up to centuries
1891 ts.centuries++;
1892 ts.decades = 0;
1893
1894 /* falls through */
1895 case 'centuries':
1896 if (ts.centuries !== CENTURIES_PER_MILLENNIUM || isNaN(ts.millennia)) {
1897 return;
1898 }
1899 // ripple centuries up to millennia
1900 ts.millennia++;
1901 ts.centuries = 0;
1902 /* falls through */
1903 }
1904 }
1905
1906 /**
1907 * Ripple up partial units one place
1908 *
1909 * @private
1910 * @param {Timespan} ts timespan
1911 * @param {number} frac accumulated fractional value
1912 * @param {string} fromUnit source unit name
1913 * @param {string} toUnit target unit name
1914 * @param {number} conversion multiplier between units
1915 * @param {number} digits max number of decimal digits to output
1916 * @return {number} new fractional value
1917 */
1918 function fraction(ts, frac, fromUnit, toUnit, conversion, digits) {
1919 if (ts[fromUnit] >= 0) {
1920 frac += ts[fromUnit];
1921 delete ts[fromUnit];
1922 }
1923
1924 frac /= conversion;
1925 if (frac + 1 <= 1) {
1926 // drop if below machine epsilon
1927 return 0;
1928 }
1929
1930 if (ts[toUnit] >= 0) {
1931 // ensure does not have more than specified number of digits
1932 ts[toUnit] = +(ts[toUnit] + frac).toFixed(digits);
1933 rippleRounded(ts, toUnit);
1934 return 0;
1935 }
1936
1937 return frac;
1938 }
1939
1940 /**
1941 * Ripple up partial units to next existing
1942 *
1943 * @private
1944 * @param {Timespan} ts
1945 * @param {number} digits max number of decimal digits to output
1946 */
1947 function fractional(ts, digits) {
1948 var frac = fraction(ts, 0, 'milliseconds', 'seconds', MILLISECONDS_PER_SECOND, digits);
1949 if (!frac) {
1950 return;
1951 }
1952
1953 frac = fraction(ts, frac, 'seconds', 'minutes', SECONDS_PER_MINUTE, digits);
1954 if (!frac) {
1955 return;
1956 }
1957
1958 frac = fraction(ts, frac, 'minutes', 'hours', MINUTES_PER_HOUR, digits);
1959 if (!frac) {
1960 return;
1961 }
1962
1963 frac = fraction(ts, frac, 'hours', 'days', HOURS_PER_DAY, digits);
1964 if (!frac) {
1965 return;
1966 }
1967
1968 frac = fraction(ts, frac, 'days', 'weeks', DAYS_PER_WEEK, digits);
1969 if (!frac) {
1970 return;
1971 }
1972
1973 frac = fraction(ts, frac, 'weeks', 'months', daysPerMonth(ts.refMonth) / DAYS_PER_WEEK, digits);
1974 if (!frac) {
1975 return;
1976 }
1977
1978 frac = fraction(ts, frac, 'months', 'years', daysPerYear(ts.refMonth) / daysPerMonth(ts.refMonth), digits);
1979 if (!frac) {
1980 return;
1981 }
1982
1983 frac = fraction(ts, frac, 'years', 'decades', YEARS_PER_DECADE, digits);
1984 if (!frac) {
1985 return;
1986 }
1987
1988 frac = fraction(ts, frac, 'decades', 'centuries', DECADES_PER_CENTURY, digits);
1989 if (!frac) {
1990 return;
1991 }
1992
1993 frac = fraction(ts, frac, 'centuries', 'millennia', CENTURIES_PER_MILLENNIUM, digits);
1994
1995 // should never reach this with remaining fractional value
1996 if (frac) {
1997 throw new Error('Fractional unit overflow');
1998 }
1999 }
2000
2001 /**
2002 * Borrow any underflow units, carry any overflow units
2003 *
2004 * @private
2005 * @param {Timespan} ts
2006 */
2007 function ripple(ts) {
2008 var x;
2009
2010 if (ts.milliseconds < 0) {
2011 // ripple seconds down to milliseconds
2012 x = ceil(-ts.milliseconds / MILLISECONDS_PER_SECOND);
2013 ts.seconds -= x;
2014 ts.milliseconds += x * MILLISECONDS_PER_SECOND;
2015
2016 } else if (ts.milliseconds >= MILLISECONDS_PER_SECOND) {
2017 // ripple milliseconds up to seconds
2018 ts.seconds += floor(ts.milliseconds / MILLISECONDS_PER_SECOND);
2019 ts.milliseconds %= MILLISECONDS_PER_SECOND;
2020 }
2021
2022 if (ts.seconds < 0) {
2023 // ripple minutes down to seconds
2024 x = ceil(-ts.seconds / SECONDS_PER_MINUTE);
2025 ts.minutes -= x;
2026 ts.seconds += x * SECONDS_PER_MINUTE;
2027
2028 } else if (ts.seconds >= SECONDS_PER_MINUTE) {
2029 // ripple seconds up to minutes
2030 ts.minutes += floor(ts.seconds / SECONDS_PER_MINUTE);
2031 ts.seconds %= SECONDS_PER_MINUTE;
2032 }
2033
2034 if (ts.minutes < 0) {
2035 // ripple hours down to minutes
2036 x = ceil(-ts.minutes / MINUTES_PER_HOUR);
2037 ts.hours -= x;
2038 ts.minutes += x * MINUTES_PER_HOUR;
2039
2040 } else if (ts.minutes >= MINUTES_PER_HOUR) {
2041 // ripple minutes up to hours
2042 ts.hours += floor(ts.minutes / MINUTES_PER_HOUR);
2043 ts.minutes %= MINUTES_PER_HOUR;
2044 }
2045
2046 if (ts.hours < 0) {
2047 // ripple days down to hours
2048 x = ceil(-ts.hours / HOURS_PER_DAY);
2049 ts.days -= x;
2050 ts.hours += x * HOURS_PER_DAY;
2051
2052 } else if (ts.hours >= HOURS_PER_DAY) {
2053 // ripple hours up to days
2054 ts.days += floor(ts.hours / HOURS_PER_DAY);
2055 ts.hours %= HOURS_PER_DAY;
2056 }
2057
2058 while (ts.days < 0) {
2059 // NOTE: never actually seen this loop more than once
2060
2061 // ripple months down to days
2062 ts.months--;
2063 ts.days += borrowMonths(ts.refMonth, 1);
2064 }
2065
2066 // weeks is always zero here
2067
2068 if (ts.days >= DAYS_PER_WEEK) {
2069 // ripple days up to weeks
2070 ts.weeks += floor(ts.days / DAYS_PER_WEEK);
2071 ts.days %= DAYS_PER_WEEK;
2072 }
2073
2074 if (ts.months < 0) {
2075 // ripple years down to months
2076 x = ceil(-ts.months / MONTHS_PER_YEAR);
2077 ts.years -= x;
2078 ts.months += x * MONTHS_PER_YEAR;
2079
2080 } else if (ts.months >= MONTHS_PER_YEAR) {
2081 // ripple months up to years
2082 ts.years += floor(ts.months / MONTHS_PER_YEAR);
2083 ts.months %= MONTHS_PER_YEAR;
2084 }
2085
2086 // years is always non-negative here
2087 // decades, centuries and millennia are always zero here
2088
2089 if (ts.years >= YEARS_PER_DECADE) {
2090 // ripple years up to decades
2091 ts.decades += floor(ts.years / YEARS_PER_DECADE);
2092 ts.years %= YEARS_PER_DECADE;
2093
2094 if (ts.decades >= DECADES_PER_CENTURY) {
2095 // ripple decades up to centuries
2096 ts.centuries += floor(ts.decades / DECADES_PER_CENTURY);
2097 ts.decades %= DECADES_PER_CENTURY;
2098
2099 if (ts.centuries >= CENTURIES_PER_MILLENNIUM) {
2100 // ripple centuries up to millennia
2101 ts.millennia += floor(ts.centuries / CENTURIES_PER_MILLENNIUM);
2102 ts.centuries %= CENTURIES_PER_MILLENNIUM;
2103 }
2104 }
2105 }
2106 }
2107
2108 /**
2109 * Remove any units not requested
2110 *
2111 * @private
2112 * @param {Timespan} ts
2113 * @param {number} units the units to populate
2114 * @param {number} max number of labels to output
2115 * @param {number} digits max number of decimal digits to output
2116 */
2117 function pruneUnits(ts, units, max, digits) {
2118 var count = 0;
2119
2120 // Calc from largest unit to smallest to prevent underflow
2121 if (!(units & MILLENNIA) || (count >= max)) {
2122 // ripple millennia down to centuries
2123 ts.centuries += ts.millennia * CENTURIES_PER_MILLENNIUM;
2124 delete ts.millennia;
2125
2126 } else if (ts.millennia) {
2127 count++;
2128 }
2129
2130 if (!(units & CENTURIES) || (count >= max)) {
2131 // ripple centuries down to decades
2132 ts.decades += ts.centuries * DECADES_PER_CENTURY;
2133 delete ts.centuries;
2134
2135 } else if (ts.centuries) {
2136 count++;
2137 }
2138
2139 if (!(units & DECADES) || (count >= max)) {
2140 // ripple decades down to years
2141 ts.years += ts.decades * YEARS_PER_DECADE;
2142 delete ts.decades;
2143
2144 } else if (ts.decades) {
2145 count++;
2146 }
2147
2148 if (!(units & YEARS) || (count >= max)) {
2149 // ripple years down to months
2150 ts.months += ts.years * MONTHS_PER_YEAR;
2151 delete ts.years;
2152
2153 } else if (ts.years) {
2154 count++;
2155 }
2156
2157 if (!(units & MONTHS) || (count >= max)) {
2158 // ripple months down to days
2159 if (ts.months) {
2160 ts.days += borrowMonths(ts.refMonth, ts.months);
2161 }
2162 delete ts.months;
2163
2164 if (ts.days >= DAYS_PER_WEEK) {
2165 // ripple day overflow back up to weeks
2166 ts.weeks += floor(ts.days / DAYS_PER_WEEK);
2167 ts.days %= DAYS_PER_WEEK;
2168 }
2169
2170 } else if (ts.months) {
2171 count++;
2172 }
2173
2174 if (!(units & WEEKS) || (count >= max)) {
2175 // ripple weeks down to days
2176 ts.days += ts.weeks * DAYS_PER_WEEK;
2177 delete ts.weeks;
2178
2179 } else if (ts.weeks) {
2180 count++;
2181 }
2182
2183 if (!(units & DAYS) || (count >= max)) {
2184 //ripple days down to hours
2185 ts.hours += ts.days * HOURS_PER_DAY;
2186 delete ts.days;
2187
2188 } else if (ts.days) {
2189 count++;
2190 }
2191
2192 if (!(units & HOURS) || (count >= max)) {
2193 // ripple hours down to minutes
2194 ts.minutes += ts.hours * MINUTES_PER_HOUR;
2195 delete ts.hours;
2196
2197 } else if (ts.hours) {
2198 count++;
2199 }
2200
2201 if (!(units & MINUTES) || (count >= max)) {
2202 // ripple minutes down to seconds
2203 ts.seconds += ts.minutes * SECONDS_PER_MINUTE;
2204 delete ts.minutes;
2205
2206 } else if (ts.minutes) {
2207 count++;
2208 }
2209
2210 if (!(units & SECONDS) || (count >= max)) {
2211 // ripple seconds down to milliseconds
2212 ts.milliseconds += ts.seconds * MILLISECONDS_PER_SECOND;
2213 delete ts.seconds;
2214
2215 } else if (ts.seconds) {
2216 count++;
2217 }
2218
2219 // nothing to ripple milliseconds down to
2220 // so ripple back up to smallest existing unit as a fractional value
2221 if (!(units & MILLISECONDS) || (count >= max)) {
2222 fractional(ts, digits);
2223 }
2224 }
2225
2226 /**
2227 * Populates the Timespan object
2228 *
2229 * @private
2230 * @param {Timespan} ts
2231 * @param {?Date} start the starting date
2232 * @param {?Date} end the ending date
2233 * @param {number} units the units to populate
2234 * @param {number} max number of labels to output
2235 * @param {number} digits max number of decimal digits to output
2236 */
2237 function populate(ts, start, end, units, max, digits) {
2238 var now = new Date();
2239
2240 ts.start = start = start || now;
2241 ts.end = end = end || now;
2242 ts.units = units;
2243
2244 ts.value = end.getTime() - start.getTime();
2245 if (ts.value < 0) {
2246 // swap if reversed
2247 var tmp = end;
2248 end = start;
2249 start = tmp;
2250 }
2251
2252 // reference month for determining days in month
2253 ts.refMonth = new Date(start.getFullYear(), start.getMonth(), 15, 12, 0, 0);
2254 try {
2255 // reset to initial deltas
2256 ts.millennia = 0;
2257 ts.centuries = 0;
2258 ts.decades = 0;
2259 ts.years = end.getFullYear() - start.getFullYear();
2260 ts.months = end.getMonth() - start.getMonth();
2261 ts.weeks = 0;
2262 ts.days = end.getDate() - start.getDate();
2263 ts.hours = end.getHours() - start.getHours();
2264 ts.minutes = end.getMinutes() - start.getMinutes();
2265 ts.seconds = end.getSeconds() - start.getSeconds();
2266 ts.milliseconds = end.getMilliseconds() - start.getMilliseconds();
2267
2268 ripple(ts);
2269 pruneUnits(ts, units, max, digits);
2270
2271 } finally {
2272 delete ts.refMonth;
2273 }
2274
2275 return ts;
2276 }
2277
2278 /**
2279 * Determine an appropriate refresh rate based upon units
2280 *
2281 * @private
2282 * @param {number} units the units to populate
2283 * @return {number} milliseconds to delay
2284 */
2285 function getDelay(units) {
2286 if (units & MILLISECONDS) {
2287 // refresh very quickly
2288 return MILLISECONDS_PER_SECOND / 30; //30Hz
2289 }
2290
2291 if (units & SECONDS) {
2292 // refresh every second
2293 return MILLISECONDS_PER_SECOND; //1Hz
2294 }
2295
2296 if (units & MINUTES) {
2297 // refresh every minute
2298 return MILLISECONDS_PER_SECOND * SECONDS_PER_MINUTE;
2299 }
2300
2301 if (units & HOURS) {
2302 // refresh hourly
2303 return MILLISECONDS_PER_SECOND * SECONDS_PER_MINUTE * MINUTES_PER_HOUR;
2304 }
2305
2306 if (units & DAYS) {
2307 // refresh daily
2308 return MILLISECONDS_PER_SECOND * SECONDS_PER_MINUTE * MINUTES_PER_HOUR * HOURS_PER_DAY;
2309 }
2310
2311 // refresh the rest weekly
2312 return MILLISECONDS_PER_SECOND * SECONDS_PER_MINUTE * MINUTES_PER_HOUR * HOURS_PER_DAY * DAYS_PER_WEEK;
2313 }
2314
2315 /**
2316 * API entry point
2317 *
2318 * @public
2319 * @param {Date|number|Timespan|null|function(Timespan,number)} start the starting date
2320 * @param {Date|number|Timespan|null|function(Timespan,number)} end the ending date
2321 * @param {number=} units the units to populate
2322 * @param {number=} max number of labels to output
2323 * @param {number=} digits max number of decimal digits to output
2324 * @return {Timespan|number}
2325 */
2326 function countdown(start, end, units, max, digits) {
2327 var callback;
2328
2329 // ensure some units or use defaults
2330 units = +units || DEFAULTS;
2331 // max must be positive
2332 max = (max > 0) ? max : NaN;
2333 // clamp digits to an integer between [0, 20]
2334 digits = (digits > 0) ? (digits < 20) ? Math.round(digits) : 20 : 0;
2335
2336 // ensure start date
2337 var startTS = null;
2338 if ('function' === typeof start) {
2339 callback = start;
2340 start = null;
2341
2342 } else if (!(start instanceof Date)) {
2343 if ((start !== null) && isFinite(start)) {
2344 start = new Date(+start);
2345 } else {
2346 if ('object' === typeof startTS) {
2347 startTS = /** @type{Timespan} */ (start);
2348 }
2349 start = null;
2350 }
2351 }
2352
2353 // ensure end date
2354 var endTS = null;
2355 if ('function' === typeof end) {
2356 callback = end;
2357 end = null;
2358
2359 } else if (!(end instanceof Date)) {
2360 if ((end !== null) && isFinite(end)) {
2361 end = new Date(+end);
2362 } else {
2363 if ('object' === typeof end) {
2364 endTS = /** @type{Timespan} */ (end);
2365 }
2366 end = null;
2367 }
2368 }
2369
2370 // must wait to interpret timespans until after resolving dates
2371 if (startTS) {
2372 start = addToDate(startTS, end);
2373 }
2374 if (endTS) {
2375 end = addToDate(endTS, start);
2376 }
2377
2378 if (!start && !end) {
2379 // used for unit testing
2380 return new Timespan();
2381 }
2382
2383 if (!callback) {
2384 return populate(new Timespan(), /** @type{Date} */ (start), /** @type{Date} */ (end), /** @type{number} */ (units), /** @type{number} */ (max), /** @type{number} */ (digits));
2385 }
2386
2387 // base delay off units
2388 var delay = getDelay(units),
2389 timerId,
2390 fn = function() {
2391 callback(
2392 populate(new Timespan(), /** @type{Date} */ (start), /** @type{Date} */ (end), /** @type{number} */ (units), /** @type{number} */ (max), /** @type{number} */ (digits)),
2393 timerId
2394 );
2395 };
2396
2397 fn();
2398 return (timerId = setInterval(fn, delay));
2399 }
2400
2401 /**
2402 * @public
2403 * @const
2404 * @type {number}
2405 */
2406 countdown.MILLISECONDS = MILLISECONDS;
2407
2408 /**
2409 * @public
2410 * @const
2411 * @type {number}
2412 */
2413 countdown.SECONDS = SECONDS;
2414
2415 /**
2416 * @public
2417 * @const
2418 * @type {number}
2419 */
2420 countdown.MINUTES = MINUTES;
2421
2422 /**
2423 * @public
2424 * @const
2425 * @type {number}
2426 */
2427 countdown.HOURS = HOURS;
2428
2429 /**
2430 * @public
2431 * @const
2432 * @type {number}
2433 */
2434 countdown.DAYS = DAYS;
2435
2436 /**
2437 * @public
2438 * @const
2439 * @type {number}
2440 */
2441 countdown.WEEKS = WEEKS;
2442
2443 /**
2444 * @public
2445 * @const
2446 * @type {number}
2447 */
2448 countdown.MONTHS = MONTHS;
2449
2450 /**
2451 * @public
2452 * @const
2453 * @type {number}
2454 */
2455 countdown.YEARS = YEARS;
2456
2457 /**
2458 * @public
2459 * @const
2460 * @type {number}
2461 */
2462 countdown.DECADES = DECADES;
2463
2464 /**
2465 * @public
2466 * @const
2467 * @type {number}
2468 */
2469 countdown.CENTURIES = CENTURIES;
2470
2471 /**
2472 * @public
2473 * @const
2474 * @type {number}
2475 */
2476 countdown.MILLENNIA = MILLENNIA;
2477
2478 /**
2479 * @public
2480 * @const
2481 * @type {number}
2482 */
2483 countdown.DEFAULTS = DEFAULTS;
2484
2485 /**
2486 * @public
2487 * @const
2488 * @type {number}
2489 */
2490 countdown.ALL = MILLENNIA | CENTURIES | DECADES | YEARS | MONTHS | WEEKS | DAYS | HOURS | MINUTES | SECONDS | MILLISECONDS;
2491
2492 /**
2493 * Customize the format settings.
2494 * @public
2495 * @param {Object} format settings object
2496 */
2497 var setFormat = countdown.setFormat = function(format) {
2498 if (!format) {
2499 return;
2500 }
2501
2502 if ('singular' in format || 'plural' in format) {
2503 var singular = format.singular || [];
2504 if (singular.split) {
2505 singular = singular.split('|');
2506 }
2507 var plural = format.plural || [];
2508 if (plural.split) {
2509 plural = plural.split('|');
2510 }
2511
2512 for (var i = LABEL_MILLISECONDS; i <= LABEL_MILLENNIA; i++) {
2513 // override any specified units
2514 LABELS_SINGLUAR[i] = singular[i] || LABELS_SINGLUAR[i];
2515 LABELS_PLURAL[i] = plural[i] || LABELS_PLURAL[i];
2516 }
2517 }
2518
2519 if ('string' === typeof format.last) {
2520 LABEL_LAST = format.last;
2521 }
2522 if ('string' === typeof format.delim) {
2523 LABEL_DELIM = format.delim;
2524 }
2525 if ('string' === typeof format.empty) {
2526 LABEL_NOW = format.empty;
2527 }
2528 if ('function' === typeof format.formatNumber) {
2529 formatNumber = format.formatNumber;
2530 }
2531 if ('function' === typeof format.formatter) {
2532 formatter = format.formatter;
2533 }
2534 };
2535
2536 /**
2537 * Revert to the default formatting.
2538 * @public
2539 */
2540 var resetFormat = countdown.resetFormat = function() {
2541 LABELS_SINGLUAR = ' millisecond| second| minute| hour| day| week| month| year| decade| century| millennium'.split('|');
2542 LABELS_PLURAL = ' milliseconds| seconds| minutes| hours| days| weeks| months| years| decades| centuries| millennia'.split('|');
2543 LABEL_LAST = ' and ';
2544 LABEL_DELIM = ', ';
2545 LABEL_NOW = '';
2546 formatNumber = function(value) {
2547 return value;
2548 };
2549 formatter = plurality;
2550 };
2551
2552 /**
2553 * Override the unit labels.
2554 * @public
2555 * @param {string|Array=} singular a pipe ('|') delimited list of singular unit name overrides
2556 * @param {string|Array=} plural a pipe ('|') delimited list of plural unit name overrides
2557 * @param {string=} last a delimiter before the last unit (default: ' and ')
2558 * @param {string=} delim a delimiter to use between all other units (default: ', ')
2559 * @param {string=} empty a label to use when all units are zero (default: '')
2560 * @param {function(number):string=} formatNumber a function which formats numbers as a string
2561 * @param {function(number,number):string=} formatter a function which formats a number/unit pair as a string
2562 * @deprecated since version 2.6.0
2563 */
2564 countdown.setLabels = function(singular, plural, last, delim, empty, formatNumber, formatter) {
2565 setFormat({
2566 singular: singular,
2567 plural: plural,
2568 last: last,
2569 delim: delim,
2570 empty: empty,
2571 formatNumber: formatNumber,
2572 formatter: formatter
2573 });
2574 };
2575
2576 /**
2577 * Revert to the default unit labels.
2578 * @public
2579 * @deprecated since version 2.6.0
2580 */
2581 countdown.resetLabels = resetFormat;
2582
2583 resetFormat();
2584
2585 if (module && module.exports) {
2586 module.exports = countdown;
2587
2588 } else if (typeof window.define === 'function' && typeof window.define.amd !== 'undefined') {
2589 window.define('countdown', [], function() {
2590 return countdown;
2591 });
2592 }
2593
2594 return countdown;
2595
2596 })(module);
2597
2598 }, {}],
2599 59: [function(require, module, exports) {
2600 'use strict';
2601 var token = '%[a-f0-9]{2}';
2602 var singleMatcher = new RegExp(token, 'gi');
2603 var multiMatcher = new RegExp('(' + token + ')+', 'gi');
2604
2605 function decodeComponents(components, split) {
2606 try {
2607 // Try to decode the entire string first
2608 return decodeURIComponent(components.join(''));
2609 } catch (err) {
2610 // Do nothing
2611 }
2612
2613 if (components.length === 1) {
2614 return components;
2615 }
2616
2617 split = split || 1;
2618
2619 // Split the array in 2 parts
2620 var left = components.slice(0, split);
2621 var right = components.slice(split);
2622
2623 return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
2624 }
2625
2626 function decode(input) {
2627 try {
2628 return decodeURIComponent(input);
2629 } catch (err) {
2630 var tokens = input.match(singleMatcher);
2631
2632 for (var i = 1; i < tokens.length; i++) {
2633 input = decodeComponents(tokens, i).join('');
2634
2635 tokens = input.match(singleMatcher);
2636 }
2637
2638 return input;
2639 }
2640 }
2641
2642 function customDecodeURIComponent(input) {
2643 // Keep track of all the replacements and prefill the map with the `BOM`
2644 var replaceMap = {
2645 '%FE%FF': '\uFFFD\uFFFD',
2646 '%FF%FE': '\uFFFD\uFFFD'
2647 };
2648
2649 var match = multiMatcher.exec(input);
2650 while (match) {
2651 try {
2652 // Decode as big chunks as possible
2653 replaceMap[match[0]] = decodeURIComponent(match[0]);
2654 } catch (err) {
2655 var result = decode(match[0]);
2656
2657 if (result !== match[0]) {
2658 replaceMap[match[0]] = result;
2659 }
2660 }
2661
2662 match = multiMatcher.exec(input);
2663 }
2664
2665 // Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
2666 replaceMap['%C2'] = '\uFFFD';
2667
2668 var entries = Object.keys(replaceMap);
2669
2670 for (var i = 0; i < entries.length; i++) {
2671 // Replace all decoded components
2672 var key = entries[i];
2673 input = input.replace(new RegExp(key, 'g'), replaceMap[key]);
2674 }
2675
2676 return input;
2677 }
2678
2679 module.exports = function(encodedURI) {
2680 if (typeof encodedURI !== 'string') {
2681 throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`');
2682 }
2683
2684 try {
2685 encodedURI = encodedURI.replace(/\+/g, ' ');
2686
2687 // Try the built in decoder first
2688 return decodeURIComponent(encodedURI);
2689 } catch (err) {
2690 // Fallback to a more advanced decoder
2691 return customDecodeURIComponent(encodedURI);
2692 }
2693 };
2694
2695 }, {}],
2696 60: [function(require, module, exports) {
2697 "use strict";
2698
2699 var tester = /^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;
2700 // Thanks to:
2701 // http://fightingforalostcause.net/misc/2006/compare-email-regex.php
2702 // http://thedailywtf.com/Articles/Validating_Email_Addresses.aspx
2703 // http://stackoverflow.com/questions/201323/what-is-the-best-regular-expression-for-validating-email-addresses/201378#201378
2704 exports.validate = function(email) {
2705 if (!email)
2706 return false;
2707
2708 if (email.length > 254)
2709 return false;
2710
2711 var valid = tester.test(email);
2712 if (!valid)
2713 return false;
2714
2715 // Further checking of some things regex can't handle
2716 var parts = email.split("@");
2717 if (parts[0].length > 64)
2718 return false;
2719
2720 var domainParts = parts[1].split(".");
2721 if (domainParts.some(function(part) {
2722 return part.length > 63;
2723 }))
2724 return false;
2725
2726 return true;
2727 }
2728 }, {}],
2729 61: [function(require, module, exports) {
2730 'use strict';
2731 const strictUriEncode = require('strict-uri-encode');
2732 const decodeComponent = require('decode-uri-component');
2733 const splitOnFirst = require('split-on-first');
2734
2735 function encoderForArrayFormat(options) {
2736 switch (options.arrayFormat) {
2737 case 'index':
2738 return key => (result, value) => {
2739 const index = result.length;
2740 if (value === undefined) {
2741 return result;
2742 }
2743
2744 if (value === null) {
2745 return [...result, [encode(key, options), '[', index, ']'].join('')];
2746 }
2747
2748 return [
2749 ...result,
2750 [encode(key, options), '[', encode(index, options), ']=', encode(value, options)].join('')
2751 ];
2752 };
2753
2754 case 'bracket':
2755 return key => (result, value) => {
2756 if (value === undefined) {
2757 return result;
2758 }
2759
2760 if (value === null) {
2761 return [...result, [encode(key, options), '[]'].join('')];
2762 }
2763
2764 return [...result, [encode(key, options), '[]=', encode(value, options)].join('')];
2765 };
2766
2767 case 'comma':
2768 return key => (result, value, index) => {
2769 if (value === null || value === undefined || value.length === 0) {
2770 return result;
2771 }
2772
2773 if (index === 0) {
2774 return [
2775 [encode(key, options), '=', encode(value, options)].join('')
2776 ];
2777 }
2778
2779 return [
2780 [result, encode(value, options)].join(',')
2781 ];
2782 };
2783
2784 default:
2785 return key => (result, value) => {
2786 if (value === undefined) {
2787 return result;
2788 }
2789
2790 if (value === null) {
2791 return [...result, encode(key, options)];
2792 }
2793
2794 return [...result, [encode(key, options), '=', encode(value, options)].join('')];
2795 };
2796 }
2797 }
2798
2799 function parserForArrayFormat(options) {
2800 let result;
2801
2802 switch (options.arrayFormat) {
2803 case 'index':
2804 return (key, value, accumulator) => {
2805 result = /\[(\d*)\]$/.exec(key);
2806
2807 key = key.replace(/\[\d*\]$/, '');
2808
2809 if (!result) {
2810 accumulator[key] = value;
2811 return;
2812 }
2813
2814 if (accumulator[key] === undefined) {
2815 accumulator[key] = {};
2816 }
2817
2818 accumulator[key][result[1]] = value;
2819 };
2820
2821 case 'bracket':
2822 return (key, value, accumulator) => {
2823 result = /(\[\])$/.exec(key);
2824 key = key.replace(/\[\]$/, '');
2825
2826 if (!result) {
2827 accumulator[key] = value;
2828 return;
2829 }
2830
2831 if (accumulator[key] === undefined) {
2832 accumulator[key] = [value];
2833 return;
2834 }
2835
2836 accumulator[key] = [].concat(accumulator[key], value);
2837 };
2838
2839 case 'comma':
2840 return (key, value, accumulator) => {
2841 const isArray = typeof value === 'string' && value.split('').indexOf(',') > -1;
2842 const newValue = isArray ? value.split(',') : value;
2843 accumulator[key] = newValue;
2844 };
2845
2846 default:
2847 return (key, value, accumulator) => {
2848 if (accumulator[key] === undefined) {
2849 accumulator[key] = value;
2850 return;
2851 }
2852
2853 accumulator[key] = [].concat(accumulator[key], value);
2854 };
2855 }
2856 }
2857
2858 function encode(value, options) {
2859 if (options.encode) {
2860 return options.strict ? strictUriEncode(value) : encodeURIComponent(value);
2861 }
2862
2863 return value;
2864 }
2865
2866 function decode(value, options) {
2867 if (options.decode) {
2868 return decodeComponent(value);
2869 }
2870
2871 return value;
2872 }
2873
2874 function keysSorter(input) {
2875 if (Array.isArray(input)) {
2876 return input.sort();
2877 }
2878
2879 if (typeof input === 'object') {
2880 return keysSorter(Object.keys(input))
2881 .sort((a, b) => Number(a) - Number(b))
2882 .map(key => input[key]);
2883 }
2884
2885 return input;
2886 }
2887
2888 function removeHash(input) {
2889 const hashStart = input.indexOf('#');
2890 if (hashStart !== -1) {
2891 input = input.slice(0, hashStart);
2892 }
2893
2894 return input;
2895 }
2896
2897 function extract(input) {
2898 input = removeHash(input);
2899 const queryStart = input.indexOf('?');
2900 if (queryStart === -1) {
2901 return '';
2902 }
2903
2904 return input.slice(queryStart + 1);
2905 }
2906
2907 function parseValue(value, options) {
2908 if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
2909 value = Number(value);
2910 } else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
2911 value = value.toLowerCase() === 'true';
2912 }
2913
2914 return value;
2915 }
2916
2917 function parse(input, options) {
2918 options = Object.assign({
2919 decode: true,
2920 sort: true,
2921 arrayFormat: 'none',
2922 parseNumbers: false,
2923 parseBooleans: false
2924 }, options);
2925
2926 const formatter = parserForArrayFormat(options);
2927
2928 // Create an object with no prototype
2929 const ret = Object.create(null);
2930
2931 if (typeof input !== 'string') {
2932 return ret;
2933 }
2934
2935 input = input.trim().replace(/^[?#&]/, '');
2936
2937 if (!input) {
2938 return ret;
2939 }
2940
2941 for (const param of input.split('&')) {
2942 let [key, value] = splitOnFirst(param.replace(/\+/g, ' '), '=');
2943
2944 // Missing `=` should be `null`:
2945 // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
2946 value = value === undefined ? null : decode(value, options);
2947 formatter(decode(key, options), value, ret);
2948 }
2949
2950 for (const key of Object.keys(ret)) {
2951 const value = ret[key];
2952 if (typeof value === 'object' && value !== null) {
2953 for (const k of Object.keys(value)) {
2954 value[k] = parseValue(value[k], options);
2955 }
2956 } else {
2957 ret[key] = parseValue(value, options);
2958 }
2959 }
2960
2961 if (options.sort === false) {
2962 return ret;
2963 }
2964
2965 return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
2966 const value = ret[key];
2967 if (Boolean(value) && typeof value === 'object' && !Array.isArray(value)) {
2968 // Sort object keys, not values
2969 result[key] = keysSorter(value);
2970 } else {
2971 result[key] = value;
2972 }
2973
2974 return result;
2975 }, Object.create(null));
2976 }
2977
2978 exports.extract = extract;
2979 exports.parse = parse;
2980
2981 exports.stringify = (object, options) => {
2982 if (!object) {
2983 return '';
2984 }
2985
2986 options = Object.assign({
2987 encode: true,
2988 strict: true,
2989 arrayFormat: 'none'
2990 }, options);
2991
2992 const formatter = encoderForArrayFormat(options);
2993 const keys = Object.keys(object);
2994
2995 if (options.sort !== false) {
2996 keys.sort(options.sort);
2997 }
2998
2999 return keys.map(key => {
3000 const value = object[key];
3001
3002 if (value === undefined) {
3003 return '';
3004 }
3005
3006 if (value === null) {
3007 return encode(key, options);
3008 }
3009
3010 if (Array.isArray(value)) {
3011 return value
3012 .reduce(formatter(key), [])
3013 .join('&');
3014 }
3015
3016 return encode(key, options) + '=' + encode(value, options);
3017 }).filter(x => x.length > 0).join('&');
3018 };
3019
3020 exports.parseUrl = (input, options) => {
3021 return {
3022 url: removeHash(input).split('?')[0] || '',
3023 query: parse(extract(input), options)
3024 };
3025 };
3026
3027 }, {
3028 "decode-uri-component": 59,
3029 "split-on-first": 62,
3030 "strict-uri-encode": 63
3031 }],
3032 62: [function(require, module, exports) {
3033 'use strict';
3034
3035 module.exports = (string, separator) => {
3036 if (!(typeof string === 'string' && typeof separator === 'string')) {
3037 throw new TypeError('Expected the arguments to be of type `string`');
3038 }
3039
3040 if (separator === '') {
3041 return [string];
3042 }
3043
3044 const separatorIndex = string.indexOf(separator);
3045
3046 if (separatorIndex === -1) {
3047 return [string];
3048 }
3049
3050 return [
3051 string.slice(0, separatorIndex),
3052 string.slice(separatorIndex + separator.length)
3053 ];
3054 };
3055
3056 }, {}],
3057 63: [function(require, module, exports) {
3058 'use strict';
3059 module.exports = str => encodeURIComponent(str).replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
3060
3061 }, {}],
3062 64: [function(require, module, exports) {
3063 'use strict';
3064
3065 Object.defineProperty(exports, "__esModule", {
3066 value: true
3067 });
3068
3069 require('core-js/fn/array/includes');
3070
3071 var _countdown = require('countdown');
3072
3073 var _countdown2 = _interopRequireDefault(_countdown);
3074
3075 function _interopRequireDefault(obj) {
3076 return obj && obj.__esModule ? obj : {
3077 default: obj
3078 };
3079 }
3080
3081 function _classCallCheck(instance, Constructor) {
3082 if (!(instance instanceof Constructor)) {
3083 throw new TypeError("Cannot call a class as a function");
3084 }
3085 }
3086
3087 var _window = window,
3088 KANYE = _window.KANYE;
3089
3090 var CountDown = function() {
3091 function CountDown(el) {
3092 _classCallCheck(this, CountDown);
3093
3094 if (KANYE.ffc) return;
3095 this.el = el || document.querySelector('.js-countdown');
3096 if (!this.el) return console.log('countdown: el not found');
3097 if (this.el.className.indexOf('js-init') > -1) return;
3098 this.cd_date = this.el.getAttribute('data-date');
3099 if (!this.cd_date) return console.log('NO COUNTDOWN');
3100 // TODO: if less than 24 hours, should not show days, but show seconds
3101 var now = new Date();
3102 var endDate = new Date(this.cd_date);
3103 if (now > endDate) return this.turnOff();
3104 this.opts = ['hours', 'minutes', 'seconds', 'milliseconds'];
3105 this.prev = {};
3106 this.render();
3107 // this.els = this.opts.map(o => this.el.querySelector(`.js-${o}`));
3108 /* eslint no-bitwise:0 */
3109 this.el.classList.add('js-init');
3110
3111 this.countdownTimer = (0, _countdown2.default)(endDate, this.tick.bind(this),
3112 // countdown.DAYS |
3113 _countdown2.default.HOURS | _countdown2.default.MINUTES | _countdown2.default.SECONDS | _countdown2.default.MILLISECONDS);
3114 }
3115
3116 CountDown.prototype.render = function render() {
3117 var _this = this;
3118
3119 this.els = []; // all the time elements.
3120 var frag = document.createDocumentFragment();
3121 this.opts.forEach(function(o, i) {
3122 var time_el = document.createElement('span');
3123 time_el.className = 'CD_time_section';
3124 time_el.setAttribute('data-type', o);
3125 frag.appendChild(time_el);
3126 _this.els.push(time_el);
3127
3128 // put a seperator in between each item
3129 if (i === _this.opts.length - 1) return;
3130 var sep = document.createElement('span');
3131 sep.className = 'CD__sep';
3132 sep.innerHTML = ':';
3133 frag.appendChild(sep);
3134 });
3135 this.el.appendChild(frag);
3136 };
3137
3138 CountDown.prototype.tick = function tick(ts) {
3139 var _this2 = this;
3140
3141 // positive values means end < start
3142 if (ts.value > 0) {
3143 setTimeout(function() {
3144 window.location.reload();
3145 }, 8000);
3146 return this.turnOff();
3147 }
3148 this.opts.forEach(function(opt, i) {
3149 if (!_this2.els[i]) return;
3150 if (_this2.prev[opt] && _this2.prev[opt] === ts[opt]) return;
3151 var time = ts[opt] < 10 ? '0' + ts[opt] : ts[opt];
3152 if (opt === 'milliseconds') {
3153 time = Math.round(ts[opt] / 10);
3154 // if (ts[opt] < 100) {
3155 // time = '0' + ts[opt];
3156 if (time === 100) {
3157 time = '00';
3158 } else if (time < 10) {
3159 time = '0' + time;
3160 }
3161 }
3162 _this2.els[i].innerHTML = time;
3163 _this2.prev[opt] = ts[opt];
3164 });
3165 };
3166
3167 CountDown.prototype.turnOff = function turnOff() {
3168 console.log('turn off countdown', this.cd_date);
3169 if (this.countdownTimer) clearInterval(this.countdownTimer);
3170 if (this.el) this.el.parentNode.removeChild(this.el);
3171 };
3172
3173 return CountDown;
3174 }();
3175
3176 exports.default = CountDown;
3177
3178 }, {
3179 "core-js/fn/array/includes": 3,
3180 "countdown": 58
3181 }],
3182 65: [function(require, module, exports) {
3183 'use strict';
3184
3185 Object.defineProperty(exports, "__esModule", {
3186 value: true
3187 });
3188
3189 var _browserJsonp = require('browser-jsonp');
3190
3191 var _browserJsonp2 = _interopRequireDefault(_browserJsonp);
3192
3193 var _emailValidator = require('email-validator');
3194
3195 var _emailValidator2 = _interopRequireDefault(_emailValidator);
3196
3197 function _interopRequireDefault(obj) {
3198 return obj && obj.__esModule ? obj : {
3199 default: obj
3200 };
3201 }
3202
3203 function _classCallCheck(instance, Constructor) {
3204 if (!(instance instanceof Constructor)) {
3205 throw new TypeError("Cannot call a class as a function");
3206 }
3207 } // import jsCookie from 'js-cookie';
3208
3209
3210 var Newlettter = function() {
3211 function Newlettter(el, product_json) {
3212 _classCallCheck(this, Newlettter);
3213
3214 this.form = el;
3215 this.p = product_json;
3216 this.error_msg = this.form.querySelector('.js-error');
3217 this.input = this.form.querySelector('.js-email');
3218 this.form.onsubmit = this.onSubmit.bind(this);
3219 this.form.classList.add('js-ready');
3220 this.optin = this.form.querySelector('.js-optin');
3221 this.submit_btn = this.form.querySelector('.js-submit');
3222 if (this.optin) this.optin.addEventListener('change', this.opt_in_change.bind(this));
3223 // jsonP callbacks have to be attached to the window, so we create
3224 // a unique namespace for one (similar to how jquery does it)
3225 this.json_cb_name = 'jsonCallback' + parseInt(Math.random() * 10000, 10);
3226 window[this.json_cb_name] = this.json_cb;
3227 }
3228
3229 Newlettter.prototype.opt_in_change = function opt_in_change() {
3230 this.submit_btn.style.visibility = this.optin.checked ? 'visible' : 'hidden';
3231 };
3232
3233 Newlettter.prototype.do_optin_err = function do_optin_err() {
3234 var _this = this;
3235
3236 if (this.error_msg) {
3237 this.error_msg.innerHTML = 'You must agree to our privacy policy';
3238 }
3239 this.optin.parentElement.classList.add('js-invalid');
3240 if (this.input) this.input.blur();
3241 setTimeout(function() {
3242 return _this.optin.parentElement.classList.remove('js-invalid');
3243 }, 700);
3244 };
3245
3246 Newlettter.prototype.do_email_err = function do_email_err() {
3247 var _this2 = this;
3248
3249 if (this.error_msg) {
3250 this.error_msg.innerHTML = 'Please enter a valid email address';
3251 }
3252 this.input.classList.add('js-invalid');
3253 setTimeout(function() {
3254 return _this2.input.classList.remove('js-invalid');
3255 }, 700);
3256 };
3257
3258 Newlettter.prototype.json_cb = function json_cb(data) {
3259 console.log('custom mailchimp response...', data);
3260 if (data && data.result === 'success') this.do_analytics();
3261 };
3262
3263 Newlettter.prototype.success = function success() {
3264 this.input.blur();
3265 var thanks = document.createElement('div');
3266 thanks.className = 'NL__thanks js-message';
3267 thanks.innerHTML = 'THANKS!';
3268 this.form.innerHTML = '';
3269 this.form.appendChild(thanks);
3270 this.do_analytics();
3271 setTimeout(function() {
3272 thanks.classList.add('js-hide');
3273 }, 2000);
3274 // ACCESSIBILITY: technically supposted to do this, but it's ugly.
3275 // thanks.setAttribute('tabindex', -1);
3276 // thanks.focus();
3277 };
3278
3279 Newlettter.prototype.do_analytics = function do_analytics() {
3280 if (!window.ga || typeof window.ga === 'undefined') return;
3281 if (!this.p || !this.p.handle) return; // only send if we have product info under the hammer.
3282 window.ga('send', {
3283 hitType: 'event',
3284 eventCategory: 'Email Form',
3285 eventAction: 'Submit',
3286 eventLabel: this.p.handle
3287 });
3288 };
3289
3290 Newlettter.prototype.onSubmit = function onSubmit(e) {
3291 if (e) e.preventDefault();
3292
3293 var val = this.input.value;
3294
3295 // handle invalid email
3296 if (!val || !_emailValidator2.default.validate(val)) {
3297 return this.do_email_err();
3298 }
3299
3300 // handle invalid optin (if we are doing an optin)
3301 if (this.optin && !this.optin.checked) {
3302 return this.do_optin_err();
3303 }
3304
3305 if (this.error_msg) {
3306 this.error_msg.innerHTML = '';
3307 }
3308 this.success();
3309
3310 return (0, _browserJsonp2.default)({
3311 url: this.form.action,
3312 data: {
3313 EMAIL: val,
3314 c: this.json_cb_name
3315 }
3316 });
3317 };
3318
3319 return Newlettter;
3320 }();
3321
3322 exports.default = Newlettter;
3323
3324 }, {
3325 "browser-jsonp": 1,
3326 "email-validator": 60
3327 }],
3328 66: [function(require, module, exports) {
3329 'use strict';
3330
3331 require('core-js/fn/array/includes');
3332
3333 require('core-js/fn/array/from');
3334
3335 var _queryString = require('query-string');
3336
3337 var _queryString2 = _interopRequireDefault(_queryString);
3338
3339 var _NewsLetter = require('./NewsLetter');
3340
3341 var _NewsLetter2 = _interopRequireDefault(_NewsLetter);
3342
3343 var _CountDown = require('./CountDown');
3344
3345 var _CountDown2 = _interopRequireDefault(_CountDown);
3346
3347 function _interopRequireDefault(obj) {
3348 return obj && obj.__esModule ? obj : {
3349 default: obj
3350 };
3351 }
3352
3353 function _toConsumableArray(arr) {
3354 if (Array.isArray(arr)) {
3355 for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
3356 arr2[i] = arr[i];
3357 }
3358 return arr2;
3359 } else {
3360 return Array.from(arr);
3361 }
3362 }
3363
3364 var _window = window,
3365 KANYE = _window.KANYE;
3366
3367 var q = _queryString2.default.parse(window.location.search);
3368
3369 function registerCountdown() {
3370 [].concat(_toConsumableArray(document.querySelectorAll('[data-component="countdown"]'))).forEach(function(el) {
3371 new _CountDown2.default(el);
3372 });
3373 }
3374
3375 (function() {
3376 if (KANYE.redirect && !q.password) {
3377 window.top.location.href = KANYE.redirect;
3378 return;
3379 }
3380 var news = document.querySelector('.js-newsletter');
3381 if (news) new _NewsLetter2.default(news);
3382
3383 var el = document.querySelector('.js-password-wrap');
3384
3385 if (!el) return; // console.error('NO PASSWORD EL');
3386
3387 var errors = el.querySelector('.errors');
3388 var input = el.querySelector('.js-password');
3389 registerCountdown();
3390 if (q.k || q.password || errors) {
3391 el.style.display = 'block';
3392 var content = document.querySelector('.js-content');
3393 if (content) content.style.display = 'none';
3394 }
3395
3396 if (!errors) return;
3397
3398 input.classList.add('js-error');
3399 // input.classList.add('js-invalid');
3400 // setTimeout(() => input.classList.remove(('js-invalid'), 500);
3401
3402 return input.addEventListener('input', function() {
3403 return input.classList.remove('js-error');
3404 });
3405 })();
3406
3407 }, {
3408 "./CountDown": 64,
3409 "./NewsLetter": 65,
3410 "core-js/fn/array/from": 2,
3411 "core-js/fn/array/includes": 3,
3412 "query-string": 61
3413 }]
3414}, {}, [66]);