· 8 years ago · Nov 17, 2017, 09:44 AM
1/* Polyfill service v3.22.0
2 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
3 *
4 * UA detected: ie/9.0.0
5 * Features requested: default
6 *
7 * - Object.assign, License: CC0 (required by "default", "_Iterator", "_ArrayIterator", "Array.from")
8 * - Object.keys, License: MIT (required by "default", "Symbol", "Map", "Set")
9 * - Symbol, License: MIT (required by "Map", "default", "Set", "Symbol.iterator", "Symbol.species", "_Iterator", "_ArrayIterator", "Array.from", "Symbol.toStringTag")
10 * - Symbol.iterator, License: MIT (required by "Map", "default", "Set", "_Iterator", "_ArrayIterator", "Array.from")
11 * - Symbol.toStringTag, License: MIT (required by "_Iterator", "_ArrayIterator", "Array.from", "default")
12 * - _Iterator, License: MIT (required by "_ArrayIterator", "Array.from", "default")
13 * - Object.setPrototypeOf, License: MIT (required by "_ArrayIterator", "Array.from", "default")
14 * - String.prototype.includes, License: CC0 (required by "default", "String.prototype.contains", "_ArrayIterator", "Array.from")
15 * - String.prototype.contains, License: CC0 (required by "_ArrayIterator", "Array.from", "default")
16 * - _ArrayIterator, License: MIT (required by "Array.from", "default")
17 * - Number.isFinite, License: MIT (required by "Array.from", "default")
18 * - Number.isNaN, License: MIT (required by "default", "Array.from", "Map", "Set")
19 * - Array.from, License: CC0 (required by "default")
20 * - Array.of, License: MIT (required by "default")
21 * - Array.prototype.fill, License: CC0 (required by "default")
22 * - Event, License: CC0 (required by "default", "CustomEvent")
23 * - CustomEvent, License: CC0 (required by "default")
24 * - _DOMTokenList, License: CC0 (required by "DOMTokenList", "default", "Element.prototype.classList")
25 * - DOMTokenList, License: CC0 (required by "default")
26 * - DocumentFragment, License: CC0 (required by "DocumentFragment.prototype.append", "default", "DocumentFragment.prototype.prepend")
27 * - _mutation, License: CC0 (required by "DocumentFragment.prototype.append", "default", "DocumentFragment.prototype.prepend", "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith")
28 * - DocumentFragment.prototype.append, License: CC0 (required by "default")
29 * - DocumentFragment.prototype.prepend, License: CC0 (required by "default")
30 * - Element.prototype.after, License: CC0 (required by "default")
31 * - Element.prototype.append, License: CC0 (required by "default")
32 * - Element.prototype.before, License: CC0 (required by "default")
33 * - Element.prototype.classList, License: CC0 (required by "default")
34 * - Element.prototype.matches, License: CC0 (required by "default", "Element.prototype.closest")
35 * - Element.prototype.closest, License: CC0 (required by "default")
36 * - Element.prototype.prepend, License: CC0 (required by "default")
37 * - Element.prototype.remove, License: CC0 (required by "default")
38 * - Element.prototype.replaceWith, License: CC0 (required by "default")
39 * - Symbol.species, License: MIT (required by "Map", "default", "Set")
40 * - Map, License: CC0 (required by "default")
41 * - Node.prototype.contains, License: CC0 (required by "default")
42 * - Promise, License: MIT (required by "default")
43 * - Set, License: CC0 (required by "default")
44 * - String.prototype.endsWith, License: CC0 (required by "default")
45 * - String.prototype.startsWith, License: CC0 (required by "default")
46 * - URL, License: CC0 (required by "default")
47 * - atob, License: MIT (required by "default")
48 * - location.origin, License: CC0 (required by "default")
49 * - performance.now, License: CC0 (required by "requestAnimationFrame", "default")
50 * - requestAnimationFrame, License: MIT (required by "default")
51 * - ~html5-elements, License: MIT (required by "default") */
52
53(function(undefined) {
54
55// Object.assign
56Object.assign = function assign(target, source) { // eslint-disable-line no-unused-vars
57 for (var index = 1, key, src; index < arguments.length; ++index) {
58 src = arguments[index];
59
60 for (key in src) {
61 if (Object.prototype.hasOwnProperty.call(src, key)) {
62 target[key] = src[key];
63 }
64 }
65 }
66
67 return target;
68};
69
70// Object.keys
71Object.keys = (function() {
72 'use strict';
73
74 // modified from https://github.com/es-shims/object-keys
75
76 var has = Object.prototype.hasOwnProperty;
77 var toStr = Object.prototype.toString;
78 var isEnumerable = Object.prototype.propertyIsEnumerable;
79 var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
80 var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
81 var dontEnums = [
82 'toString',
83 'toLocaleString',
84 'valueOf',
85 'hasOwnProperty',
86 'isPrototypeOf',
87 'propertyIsEnumerable',
88 'constructor'
89 ];
90 var equalsConstructorPrototype = function (o) {
91 var ctor = o.constructor;
92 return ctor && ctor.prototype === o;
93 };
94 var excludedKeys = {
95 $console: true,
96 $external: true,
97 $frame: true,
98 $frameElement: true,
99 $frames: true,
100 $innerHeight: true,
101 $innerWidth: true,
102 $outerHeight: true,
103 $outerWidth: true,
104 $pageXOffset: true,
105 $pageYOffset: true,
106 $parent: true,
107 $scrollLeft: true,
108 $scrollTop: true,
109 $scrollX: true,
110 $scrollY: true,
111 $self: true,
112 $webkitIndexedDB: true,
113 $webkitStorageInfo: true,
114 $window: true
115 };
116 var hasAutomationEqualityBug = (function () {
117 /* global window */
118 if (typeof window === 'undefined') { return false; }
119 for (var k in window) {
120 try {
121 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
122 try {
123 equalsConstructorPrototype(window[k]);
124 } catch (e) {
125 return true;
126 }
127 }
128 } catch (e) {
129 return true;
130 }
131 }
132 return false;
133 }());
134 var equalsConstructorPrototypeIfNotBuggy = function (o) {
135 /* global window */
136 if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
137 return equalsConstructorPrototype(o);
138 }
139 try {
140 return equalsConstructorPrototype(o);
141 } catch (e) {
142 return false;
143 }
144 };
145
146 function isArgumentsObject(value) {
147 var str = toStr.call(value);
148 var isArgs = str === '[object Arguments]';
149 if (!isArgs) {
150 isArgs = str !== '[object Array]' &&
151 value !== null &&
152 typeof value === 'object' &&
153 typeof value.length === 'number' &&
154 value.length >= 0 &&
155 toStr.call(value.callee) === '[object Function]';
156 }
157 return isArgs;
158 };
159
160 return function keys(object) {
161 var isFunction = toStr.call(object) === '[object Function]';
162 var isArguments = isArgumentsObject(object);
163 var isString = toStr.call(object) === '[object String]';
164 var theKeys = [];
165
166 if (object === undefined || object === null) {
167 throw new TypeError('Cannot convert undefined or null to object');
168 }
169
170 var skipProto = hasProtoEnumBug && isFunction;
171 if (isString && object.length > 0 && !has.call(object, 0)) {
172 for (var i = 0; i < object.length; ++i) {
173 theKeys.push(String(i));
174 }
175 }
176
177 if (isArguments && object.length > 0) {
178 for (var j = 0; j < object.length; ++j) {
179 theKeys.push(String(j));
180 }
181 } else {
182 for (var name in object) {
183 if (!(skipProto && name === 'prototype') && has.call(object, name)) {
184 theKeys.push(String(name));
185 }
186 }
187 }
188
189 if (hasDontEnumBug) {
190 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
191
192 for (var k = 0; k < dontEnums.length; ++k) {
193 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
194 theKeys.push(dontEnums[k]);
195 }
196 }
197 }
198 return theKeys;
199 };
200}());
201
202// Symbol
203// A modification of https://github.com/WebReflection/get-own-property-symbols
204// (C) Andrea Giammarchi - MIT Licensed
205
206(function (Object, GOPS, global) {
207
208 var setDescriptor;
209 var id = 0;
210 var random = '' + Math.random();
211 var prefix = '__\x01symbol:';
212 var prefixLength = prefix.length;
213 var internalSymbol = '__\x01symbol@@' + random;
214 var DP = 'defineProperty';
215 var DPies = 'defineProperties';
216 var GOPN = 'getOwnPropertyNames';
217 var GOPD = 'getOwnPropertyDescriptor';
218 var PIE = 'propertyIsEnumerable';
219 var ObjectProto = Object.prototype;
220 var hOP = ObjectProto.hasOwnProperty;
221 var pIE = ObjectProto[PIE];
222 var toString = ObjectProto.toString;
223 var concat = Array.prototype.concat;
224 var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : [];
225 var nGOPN = Object[GOPN];
226 var gOPN = function getOwnPropertyNames (obj) {
227 if (toString.call(obj) === '[object Window]') {
228 try {
229 return nGOPN(obj);
230 } catch (e) {
231 // IE bug where layout engine calls userland gOPN for cross-domain `window` objects
232 return concat.call([], cachedWindowNames);
233 }
234 }
235 return nGOPN(obj);
236 };
237 var gOPD = Object[GOPD];
238 var create = Object.create;
239 var keys = Object.keys;
240 var freeze = Object.freeze || Object;
241 var defineProperty = Object[DP];
242 var $defineProperties = Object[DPies];
243 var descriptor = gOPD(Object, GOPN);
244 var addInternalIfNeeded = function (o, uid, enumerable) {
245 if (!hOP.call(o, internalSymbol)) {
246 try {
247 defineProperty(o, internalSymbol, {
248 enumerable: false,
249 configurable: false,
250 writable: false,
251 value: {}
252 });
253 } catch (e) {
254 o[internalSymbol] = {};
255 }
256 }
257 o[internalSymbol]['@@' + uid] = enumerable;
258 };
259 var createWithSymbols = function (proto, descriptors) {
260 var self = create(proto);
261 gOPN(descriptors).forEach(function (key) {
262 if (propertyIsEnumerable.call(descriptors, key)) {
263 $defineProperty(self, key, descriptors[key]);
264 }
265 });
266 return self;
267 };
268 var copyAsNonEnumerable = function (descriptor) {
269 var newDescriptor = create(descriptor);
270 newDescriptor.enumerable = false;
271 return newDescriptor;
272 };
273 var get = function get(){};
274 var onlyNonSymbols = function (name) {
275 return name != internalSymbol &&
276 !hOP.call(source, name);
277 };
278 var onlySymbols = function (name) {
279 return name != internalSymbol &&
280 hOP.call(source, name);
281 };
282 var propertyIsEnumerable = function propertyIsEnumerable(key) {
283 var uid = '' + key;
284 return onlySymbols(uid) ? (
285 hOP.call(this, uid) &&
286 this[internalSymbol]['@@' + uid]
287 ) : pIE.call(this, key);
288 };
289 var setAndGetSymbol = function (uid) {
290 var descriptor = {
291 enumerable: false,
292 configurable: true,
293 get: get,
294 set: function (value) {
295 setDescriptor(this, uid, {
296 enumerable: false,
297 configurable: true,
298 writable: true,
299 value: value
300 });
301 addInternalIfNeeded(this, uid, true);
302 }
303 };
304 try {
305 defineProperty(ObjectProto, uid, descriptor);
306 } catch (e) {
307 ObjectProto[uid] = descriptor.value;
308 }
309 return freeze(source[uid] = defineProperty(
310 Object(uid),
311 'constructor',
312 sourceConstructor
313 ));
314 };
315 var Symbol = function Symbol(description) {
316 if (this instanceof Symbol) {
317 throw new TypeError('Symbol is not a constructor');
318 }
319 return setAndGetSymbol(
320 prefix.concat(description || '', random, ++id)
321 );
322 };
323 var source = create(null);
324 var sourceConstructor = {value: Symbol};
325 var sourceMap = function (uid) {
326 return source[uid];
327 };
328 var $defineProperty = function defineProp(o, key, descriptor) {
329 var uid = '' + key;
330 if (onlySymbols(uid)) {
331 setDescriptor(o, uid, descriptor.enumerable ?
332 copyAsNonEnumerable(descriptor) : descriptor);
333 addInternalIfNeeded(o, uid, !!descriptor.enumerable);
334 } else {
335 defineProperty(o, key, descriptor);
336 }
337 return o;
338 };
339
340 var onlyInternalSymbols = function (obj) {
341 return function (name) {
342 return hOP.call(obj, internalSymbol) && hOP.call(obj[internalSymbol], '@@' + name);
343 };
344 };
345 var $getOwnPropertySymbols = function getOwnPropertySymbols(o) {
346 return gOPN(o).filter(o === ObjectProto ? onlyInternalSymbols(o) : onlySymbols).map(sourceMap);
347 }
348 ;
349
350 descriptor.value = $defineProperty;
351 defineProperty(Object, DP, descriptor);
352
353 descriptor.value = $getOwnPropertySymbols;
354 defineProperty(Object, GOPS, descriptor);
355
356 descriptor.value = function getOwnPropertyNames(o) {
357 return gOPN(o).filter(onlyNonSymbols);
358 };
359 defineProperty(Object, GOPN, descriptor);
360
361 descriptor.value = function defineProperties(o, descriptors) {
362 var symbols = $getOwnPropertySymbols(descriptors);
363 if (symbols.length) {
364 keys(descriptors).concat(symbols).forEach(function (uid) {
365 if (propertyIsEnumerable.call(descriptors, uid)) {
366 $defineProperty(o, uid, descriptors[uid]);
367 }
368 });
369 } else {
370 $defineProperties(o, descriptors);
371 }
372 return o;
373 };
374 defineProperty(Object, DPies, descriptor);
375
376 descriptor.value = propertyIsEnumerable;
377 defineProperty(ObjectProto, PIE, descriptor);
378
379 descriptor.value = Symbol;
380 defineProperty(global, 'Symbol', descriptor);
381
382 // defining `Symbol.for(key)`
383 descriptor.value = function (key) {
384 var uid = prefix.concat(prefix, key, random);
385 return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid);
386 };
387 defineProperty(Symbol, 'for', descriptor);
388
389 // defining `Symbol.keyFor(symbol)`
390 descriptor.value = function (symbol) {
391 if (onlyNonSymbols(symbol))
392 throw new TypeError(symbol + ' is not a symbol');
393 return hOP.call(source, symbol) ?
394 symbol.slice(prefixLength * 2, -random.length) :
395 void 0
396 ;
397 };
398 defineProperty(Symbol, 'keyFor', descriptor);
399
400 descriptor.value = function getOwnPropertyDescriptor(o, key) {
401 var descriptor = gOPD(o, key);
402 if (descriptor && onlySymbols(key)) {
403 descriptor.enumerable = propertyIsEnumerable.call(o, key);
404 }
405 return descriptor;
406 };
407 defineProperty(Object, GOPD, descriptor);
408
409 descriptor.value = function (proto, descriptors) {
410 return arguments.length === 1 || typeof descriptors === "undefined" ?
411 create(proto) :
412 createWithSymbols(proto, descriptors);
413 };
414 defineProperty(Object, 'create', descriptor);
415
416 descriptor.value = function () {
417 var str = toString.call(this);
418 return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
419 };
420 defineProperty(ObjectProto, 'toString', descriptor);
421
422
423 setDescriptor = function (o, key, descriptor) {
424 var protoDescriptor = gOPD(ObjectProto, key);
425 delete ObjectProto[key];
426 defineProperty(o, key, descriptor);
427 if (o !== ObjectProto) {
428 defineProperty(ObjectProto, key, protoDescriptor);
429 }
430 };
431
432}(Object, 'getOwnPropertySymbols', this));
433
434// Symbol.iterator
435Object.defineProperty(Symbol, 'iterator', {value: Symbol('iterator')});
436
437// Symbol.toStringTag
438Object.defineProperty(Symbol, 'toStringTag', {
439 value: Symbol('toStringTag')
440});
441
442// _Iterator
443// A modification of https://github.com/medikoo/es6-iterator
444// Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
445
446var Iterator = (function () { // eslint-disable-line no-unused-vars
447 var clear = function () {
448 this.length = 0;
449 return this;
450 };
451 var callable = function (fn) {
452 if (typeof fn !== 'function') throw new TypeError(fn + " is not a function");
453 return fn;
454 };
455
456 var Iterator = function (list, context) {
457 if (!(this instanceof Iterator)) {
458 return new Iterator(list, context);
459 }
460 Object.defineProperties(this, {
461 __list__: {
462 writable: true,
463 value: list
464 },
465 __context__: {
466 writable: true,
467 value: context
468 },
469 __nextIndex__: {
470 writable: true,
471 value: 0
472 }
473 });
474 if (!context) return;
475 callable(context.on);
476 context.on('_add', this._onAdd.bind(this));
477 context.on('_delete', this._onDelete.bind(this));
478 context.on('_clear', this._onClear.bind(this));
479 };
480
481 Object.defineProperties(Iterator.prototype, Object.assign({
482 constructor: {
483 value: Iterator,
484 configurable: true,
485 enumerable: false,
486 writable: true
487 },
488 _next: {
489 value: function () {
490 var i;
491 if (!this.__list__) return;
492 if (this.__redo__) {
493 i = this.__redo__.shift();
494 if (i !== undefined) return i;
495 }
496 if (this.__nextIndex__ < this.__list__.length) return this.__nextIndex__++;
497 this._unBind();
498 },
499 configurable: true,
500 enumerable: false,
501 writable: true
502 },
503 next: {
504 value: function () {
505 return this._createResult(this._next());
506 },
507 configurable: true,
508 enumerable: false,
509 writable: true
510 },
511 _createResult: {
512 value: function (i) {
513 if (i === undefined) return {
514 done: true,
515 value: undefined
516 };
517 return {
518 done: false,
519 value: this._resolve(i)
520 };
521 },
522 configurable: true,
523 enumerable: false,
524 writable: true
525 },
526 _resolve: {
527 value: function (i) {
528 return this.__list__[i];
529 },
530 configurable: true,
531 enumerable: false,
532 writable: true
533 },
534 _unBind: {
535 value: function () {
536 this.__list__ = null;
537 delete this.__redo__;
538 if (!this.__context__) return;
539 this.__context__.off('_add', this._onAdd.bind(this));
540 this.__context__.off('_delete', this._onDelete.bind(this));
541 this.__context__.off('_clear', this._onClear.bind(this));
542 this.__context__ = null;
543 },
544 configurable: true,
545 enumerable: false,
546 writable: true
547 },
548 toString: {
549 value: function () {
550 return '[object Iterator]';
551 },
552 configurable: true,
553 enumerable: false,
554 writable: true
555 }
556 }, {
557 _onAdd: {
558 value: function (index) {
559 if (index >= this.__nextIndex__) return;
560 ++this.__nextIndex__;
561 if (!this.__redo__) {
562 Object.defineProperty(this, '__redo__', {
563 value: [index],
564 configurable: true,
565 enumerable: false,
566 writable: false
567 });
568 return;
569 }
570 this.__redo__.forEach(function (redo, i) {
571 if (redo >= index) this.__redo__[i] = ++redo;
572 }, this);
573 this.__redo__.push(index);
574 },
575 configurable: true,
576 enumerable: false,
577 writable: true
578 },
579 _onDelete: {
580 value: function (index) {
581 var i;
582 if (index >= this.__nextIndex__) return;
583 --this.__nextIndex__;
584 if (!this.__redo__) return;
585 i = this.__redo__.indexOf(index);
586 if (i !== -1) this.__redo__.splice(i, 1);
587 this.__redo__.forEach(function (redo, i) {
588 if (redo > index) this.__redo__[i] = --redo;
589 }, this);
590 },
591 configurable: true,
592 enumerable: false,
593 writable: true
594 },
595 _onClear: {
596 value: function () {
597 if (this.__redo__) clear.call(this.__redo__);
598 this.__nextIndex__ = 0;
599 },
600 configurable: true,
601 enumerable: false,
602 writable: true
603 }
604 }));
605
606 Object.defineProperty(Iterator.prototype, Symbol.iterator, {
607 value: function () {
608 return this;
609 },
610 configurable: true,
611 enumerable: false,
612 writable: true
613 });
614 Object.defineProperty(Iterator.prototype, Symbol.toStringTag, {
615 value: 'Iterator',
616 configurable: false,
617 enumerable: false,
618 writable: true
619 });
620
621 return Iterator;
622}());
623
624// Object.setPrototypeOf
625// ES6-shim 0.16.0 (c) 2013-2014 Paul Miller (http://paulmillr.com)
626// ES6-shim may be freely distributed under the MIT license.
627// For more details and documentation:
628// https://github.com/paulmillr/es6-shim/
629
630(function(globals) {
631 'use strict';
632
633 var Object = globals.Object;
634
635 // NOTE: This versions needs object ownership
636 // because every promoted object needs to be reassigned
637 // otherwise uncompatible browsers cannot work as expected
638 //
639 // NOTE: This might need es5-shim or polyfills upfront
640 // because it's based on ES5 API.
641 // (probably just an IE <= 8 problem)
642 //
643 // NOTE: nodejs is fine in version 0.8, 0.10 and future versions.
644 if (!Object.setPrototypeOf) (function () {
645 /*jshint proto: true */
646 // @author Andrea Giammarchi - @WebReflection
647 var
648 // define into target descriptors from source
649 copyDescriptors = function (target, source) {
650 getOwnPropertyNames(source).forEach(function (key) {
651 defineProperty(
652 target,
653 key,
654 getOwnPropertyDescriptor(source, key)
655 );
656 });
657 return target;
658 },
659 // used as fallback when no promotion is possible
660 createAndCopy = function (origin, proto) {
661 return copyDescriptors(create(proto), origin);
662 },
663 create = Object.create,
664 defineProperty = Object.defineProperty,
665 getPrototypeOf = Object.getPrototypeOf,
666 getOwnPropertyNames = Object.getOwnPropertyNames,
667 getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor,
668 proto = Object.prototype,
669 set, setPrototypeOf
670 ;
671 try {
672 // this might fail for various reasons
673 // ignore if Chrome cought it at runtime
674 set = getOwnPropertyDescriptor(proto, '__proto__').set;
675 set.call({}, null);
676 // setter not poisoned, it can promote
677 // Firefox, Chrome
678 setPrototypeOf = function (origin, proto) {
679 set.call(origin, proto);
680 return origin;
681 };
682 } catch(e) {
683 // do one or more feature detections
684 set = {__proto__: null};
685 // if proto does not work, needs to fallback
686 // some Opera, Rhino, ducktape
687 if (set instanceof Object) {
688 setPrototypeOf = createAndCopy;
689 } else {
690 // verify if null objects are buggy
691 set.__proto__ = proto;
692 // if null objects are buggy
693 // nodejs 0.8 to 0.10
694 if (set instanceof Object) {
695 setPrototypeOf = function (origin, proto) {
696 // use such bug to promote
697 origin.__proto__ = proto;
698 return origin;
699 };
700 } else {
701 // try to use proto or fallback
702 // Safari, old Firefox, many others
703 setPrototypeOf = function (origin, proto) {
704 // if proto is not null
705 return getPrototypeOf(origin) ?
706 // use __proto__ to promote
707 ((origin.__proto__ = proto), origin) :
708 // otherwise unable to promote: fallback
709 createAndCopy(origin, proto);
710 };
711 }
712 }
713 }
714 Object.setPrototypeOf = setPrototypeOf;
715 }());
716}(this));
717
718// String.prototype.includes
719String.prototype.includes = function (string, index) {
720 if (typeof string === 'object' && string instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression");
721 return this.indexOf(string, index) !== -1;
722};
723
724// String.prototype.contains
725String.prototype.contains = String.prototype.includes;
726
727// _ArrayIterator
728// A modification of https://github.com/medikoo/es6-iterator
729// Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
730
731var ArrayIterator = (function() { // eslint-disable-line no-unused-vars
732
733 var ArrayIterator = function(arr, kind) {
734 if (!(this instanceof ArrayIterator)) return new ArrayIterator(arr, kind);
735 Iterator.call(this, arr);
736 if (!kind) kind = 'value';
737 else if (String.prototype.contains.call(kind, 'key+value')) kind = 'key+value';
738 else if (String.prototype.contains.call(kind, 'key')) kind = 'key';
739 else kind = 'value';
740 Object.defineProperty(this, '__kind__', {
741 value: kind,
742 configurable: false,
743 enumerable: false,
744 writable: false
745 });
746 };
747 if (Object.setPrototypeOf) Object.setPrototypeOf(ArrayIterator, Iterator.prototype);
748
749 ArrayIterator.prototype = Object.create(Iterator.prototype, {
750 constructor: {
751 value: ArrayIterator,
752 configurable: true,
753 enumerable: false,
754 writable: true
755 },
756 _resolve: {
757 value: function(i) {
758 if (this.__kind__ === 'value') return this.__list__[i];
759 if (this.__kind__ === 'key+value') return [i, this.__list__[i]];
760 return i;
761 },
762 configurable: true,
763 enumerable: false,
764 writable: true
765 },
766 toString: {
767 value: function() {
768 return '[object Array Iterator]';
769 },
770 configurable: true,
771 enumerable: false,
772 writable: true
773 }
774 });
775
776 return ArrayIterator;
777}());
778
779// Number.isFinite
780Number.isFinite = Number.isFinite || function(value) {
781 return typeof value === "number" && isFinite(value);
782};
783
784// Number.isNaN
785Number.isNaN = Number.isNaN || function(value) {
786 return typeof value === "number" && isNaN(value);
787};
788
789// Array.from
790// Wrapped in IIFE to prevent leaking to global scope.
791(function () {
792 'use strict';
793
794 function ToInteger(value) {
795 var number = Number(value);
796 return sign(number) * Math.floor(Math.abs(Math.min(Math.max(number || 0, 0), 9007199254740991)));
797 }
798
799 var has = Object.prototype.hasOwnProperty;
800 var strValue = String.prototype.valueOf;
801
802 var tryStringObject = function tryStringObject(value) {
803 try {
804 strValue.call(value);
805 return true;
806 } catch (e) {
807 return false;
808 }
809 };
810
811 function sign(number) {
812 return number >= 0 ? 1 : -1;
813 }
814
815 var toStr = Object.prototype.toString;
816 var strClass = '[object String]';
817 var hasSymbols = typeof Symbol === 'function';
818 var hasToStringTag = hasSymbols && 'toStringTag' in Symbol;
819
820 function isString(value) {
821 if (typeof value === 'string') {
822 return true;
823 }
824 if (typeof value !== 'object') {
825 return false;
826 }
827 return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass;
828 }
829
830 var fnToStr = Function.prototype.toString;
831
832 var constructorRegex = /^\s*class /;
833 var isES6ClassFn = function isES6ClassFn(value) {
834 try {
835 var fnStr = fnToStr.call(value);
836 var singleStripped = fnStr.replace(/\/\/.*\n/g, '');
837 var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, '');
838 var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' ');
839 return constructorRegex.test(spaceStripped);
840 } catch (e) {
841 return false; // not a function
842 }
843 };
844
845 var tryFunctionObject = function tryFunctionObject(value) {
846 try {
847 if (isES6ClassFn(value)) {
848 return false;
849 }
850 fnToStr.call(value);
851 return true;
852 } catch (e) {
853 return false;
854 }
855 };
856 var fnClass = '[object Function]';
857 var genClass = '[object GeneratorFunction]';
858
859 function isCallable(value) {
860 if (!value) {
861 return false;
862 }
863 if (typeof value !== 'function' && typeof value !== 'object') {
864 return false;
865 }
866 if (hasToStringTag) {
867 return tryFunctionObject(value);
868 }
869 if (isES6ClassFn(value)) {
870 return false;
871 }
872 var strClass = toStr.call(value);
873 return strClass === fnClass || strClass === genClass;
874 };
875 var isArray = Array.isArray;
876
877 var parseIterable = function (iterator) {
878 var done = false;
879 var iterableResponse;
880 var tempArray = [];
881
882 if (iterator && typeof iterator.next === 'function') {
883 while (!done) {
884 iterableResponse = iterator.next();
885 if (
886 has.call(iterableResponse, 'value') &&
887 has.call(iterableResponse, 'done')
888 ) {
889 if (iterableResponse.done === true) {
890 done = true;
891 break; // eslint-disable-line no-restricted-syntax
892
893 } else if (iterableResponse.done !== false) {
894 break; // eslint-disable-line no-restricted-syntax
895 }
896
897 tempArray.push(iterableResponse.value);
898 } else if (iterableResponse.done === true) {
899 done = true;
900 break; // eslint-disable-line no-restricted-syntax
901 } else {
902 break; // eslint-disable-line no-restricted-syntax
903 }
904 }
905 }
906
907 return done ? tempArray : false;
908 };
909
910 var iteratorSymbol;
911 var forOf;
912 var hasSet = typeof Set === 'function';
913 var hasMap = typeof Map === 'function';
914
915 if (hasSymbols) {
916 iteratorSymbol = Symbol.iterator;
917 } else {
918 var iterate;
919 try {
920 iterate = Function('iterable', 'var arr = []; for (var value of iterable) arr.push(value); return arr;'); // eslint-disable-line no-new-func
921 } catch (e) {}
922 var supportsStrIterator = (function () {
923 try {
924 var supported = false;
925 var obj = { // eslint-disable-line no-unused-vars
926 '@@iterator': function () {
927 return {
928 'next': function () {
929 supported = true;
930 return {
931 'done': true,
932 'value': undefined
933 };
934 }
935 };
936 }
937 };
938
939 iterate(obj);
940 return supported;
941 } catch (e) {
942 return false;
943 }
944 }());
945
946 if (supportsStrIterator) {
947 iteratorSymbol = '@@iterator';
948 } else if (typeof Set === 'function') {
949 var s = new Set();
950 s.add(0);
951 try {
952 if (iterate(s).length === 1) {
953 forOf = iterate;
954 }
955 } catch (e) {}
956 }
957 }
958
959 var isSet;
960 if (hasSet) {
961 var setSize = Object.getOwnPropertyDescriptor(Set.prototype, 'size').get;
962 isSet = function (set) {
963 try {
964 setSize.call(set);
965 return true;
966 } catch (e) {
967 return false;
968 }
969 };
970 }
971
972 var isMap;
973 if (hasMap) {
974 var mapSize = Object.getOwnPropertyDescriptor(Map.prototype, 'size').get;
975 isMap = function (m) {
976 try {
977 mapSize.call(m);
978 return true;
979 } catch (e) {
980 return false;
981 }
982 };
983 }
984
985 var setForEach = hasSet && Set.prototype.forEach;
986 var mapForEach = hasMap && Map.prototype.forEach;
987 var usingIterator = function (items) {
988 var tempArray = [];
989 if (has.call(items, iteratorSymbol)) {
990 return items[iteratorSymbol]();
991 } else if (setForEach && isSet(items)) {
992 setForEach.call(items, function (val) {
993 tempArray.push(val);
994 });
995 return {
996 next: function () {
997 return tempArray.length === 0
998 ? {
999 done: true
1000 }
1001 : {
1002 value: tempArray.splice(0, 1)[0],
1003 done: false
1004 };
1005 }
1006 };
1007 } else if (mapForEach && isMap(items)) {
1008 mapForEach.call(items, function (val, key) {
1009 tempArray.push([key, val]);
1010 });
1011 return {
1012 next: function () {
1013 return tempArray.length === 0
1014 ? {
1015 done: true
1016 }
1017 : {
1018 value: tempArray.splice(0, 1)[0],
1019 done: false
1020 };
1021 }
1022 };
1023 }
1024 return items;
1025 };
1026
1027 var strMatch = String.prototype.match;
1028
1029 var parseIterableLike = function (items) {
1030 var arr = parseIterable(usingIterator(items));
1031
1032 if (!arr) {
1033 if (isString(items)) {
1034 arr = strMatch.call(items, /[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g) || [];
1035 } else if (forOf && !isArray(items)) {
1036 // Safari 8's native Map or Set can't be iterated except with for..of
1037 try {
1038 arr = forOf(items);
1039 } catch (e) {}
1040 }
1041 }
1042 return arr || items;
1043 };
1044
1045 /*! https://mths.be/array-from v0.2.0 by @mathias */
1046 Object.defineProperty(Array, 'from', {
1047 configurable: true,
1048 value: function from(items) {
1049 var C = this;
1050 if (items === null || typeof items === 'undefined') {
1051 throw new TypeError('`Array.from` requires an array-like object, not `null` or `undefined`');
1052 }
1053 var mapFn, T;
1054 if (typeof arguments[1] !== 'undefined') {
1055 mapFn = arguments[1];
1056 if (!isCallable(mapFn)) {
1057 throw new TypeError('When provided, the second argument to `Array.from` must be a function');
1058 }
1059 if (arguments.length > 2) {
1060 T = arguments[2];
1061 }
1062 }
1063
1064 var arrayLike = Object(parseIterableLike(items));
1065 var len = ToInteger(arrayLike.length);
1066 var A = isCallable(C) ? Object(new C(len)) : new Array(len);
1067 var k = 0;
1068 var kValue, mappedValue;
1069
1070 while (k < len) {
1071 kValue = arrayLike[k];
1072 if (mapFn) {
1073 mappedValue = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.apply(T, [kValue, k]);
1074 } else {
1075 mappedValue = kValue;
1076 }
1077 Object.defineProperty(A, k, {
1078 'configurable': true,
1079 'enumerable': true,
1080 'value': mappedValue,
1081 'writable': true
1082 });
1083 k += 1;
1084 }
1085 A.length = len;
1086 return A;
1087 },
1088 writable: true
1089 });
1090}());
1091
1092// Array.of
1093/*! https://mths.be/array-of v0.1.0 by @mathias */
1094(function () {
1095 'use strict';
1096 var defineProperty = (function () {
1097 // IE 8 only supports `Object.defineProperty` on DOM elements
1098 try {
1099 var object = {};
1100 var $defineProperty = Object.defineProperty;
1101 var result = $defineProperty(object, object, object) && $defineProperty;
1102 } catch (error) { /**/ }
1103 return result;
1104 }());
1105 var isConstructor = function isConstructor(Constructor) {
1106 try {
1107 return !!new Constructor();
1108 } catch (_) {
1109 return false;
1110 }
1111 };
1112 var of = function of() {
1113 var items = arguments;
1114 var length = items.length;
1115 var Me = this;
1116 var result = isConstructor(Me) ? new Me(length) : new Array(length);
1117 var index = 0;
1118 var value;
1119 while (index < length) {
1120 value = items[index];
1121 if (defineProperty) {
1122 defineProperty(result, index, {
1123 'value': value,
1124 'writable': true,
1125 'enumerable': true,
1126 'configurable': true
1127 });
1128 } else {
1129 result[index] = value;
1130 }
1131 index += 1;
1132 }
1133 result.length = length;
1134 return result;
1135 };
1136 if (defineProperty) {
1137 defineProperty(Array, 'of', {
1138 'value': of,
1139 'configurable': true,
1140 'writable': true
1141 });
1142 } else {
1143 Array.of = of;
1144 }
1145}());
1146
1147// Array.prototype.fill
1148Object.defineProperty(Array.prototype, 'fill', {
1149 configurable: true,
1150 value: function fill(value) {
1151 if (this === undefined || this === null) {
1152 throw new TypeError(this + ' is not an object');
1153 }
1154
1155 var arrayLike = Object(this);
1156
1157 var length = Math.max(Math.min(arrayLike.length, 9007199254740991), 0) || 0;
1158
1159 var relativeStart = 1 in arguments ? parseInt(Number(arguments[1]), 10) || 0 : 0;
1160
1161 relativeStart = relativeStart < 0 ? Math.max(length + relativeStart, 0) : Math.min(relativeStart, length);
1162
1163 var relativeEnd = 2 in arguments && arguments[2] !== undefined ? parseInt(Number(arguments[2]), 10) || 0 : length;
1164
1165 relativeEnd = relativeEnd < 0 ? Math.max(length + arguments[2], 0) : Math.min(relativeEnd, length);
1166
1167 while (relativeStart < relativeEnd) {
1168 arrayLike[relativeStart] = value;
1169
1170 ++relativeStart;
1171 }
1172
1173 return arrayLike;
1174 },
1175 writable: true
1176});
1177
1178// Event
1179(function () {
1180 var unlistenableWindowEvents = {
1181 click: 1,
1182 dblclick: 1,
1183 keyup: 1,
1184 keypress: 1,
1185 keydown: 1,
1186 mousedown: 1,
1187 mouseup: 1,
1188 mousemove: 1,
1189 mouseover: 1,
1190 mouseenter: 1,
1191 mouseleave: 1,
1192 mouseout: 1,
1193 storage: 1,
1194 storagecommit: 1,
1195 textinput: 1
1196 };
1197
1198 // This polyfill depends on availability of `document` so will not run in a worker
1199 // However, we asssume there are no browsers with worker support that lack proper
1200 // support for `Event` within the worker
1201 if (typeof document === 'undefined' || typeof window === 'undefined') return;
1202
1203 function indexOf(array, element) {
1204 var
1205 index = -1,
1206 length = array.length;
1207
1208 while (++index < length) {
1209 if (index in array && array[index] === element) {
1210 return index;
1211 }
1212 }
1213
1214 return -1;
1215 }
1216
1217 var existingProto = (window.Event && window.Event.prototype) || null;
1218 window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
1219 if (!type) {
1220 throw new Error('Not enough arguments');
1221 }
1222
1223 var event;
1224 // Shortcut if browser supports createEvent
1225 if ('createEvent' in document) {
1226 event = document.createEvent('Event');
1227 var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
1228 var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
1229
1230 event.initEvent(type, bubbles, cancelable);
1231
1232 return event;
1233 }
1234
1235 event = document.createEventObject();
1236
1237 event.type = type;
1238 event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
1239 event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
1240
1241 return event;
1242 };
1243 if (existingProto) {
1244 Object.defineProperty(window.Event, 'prototype', {
1245 configurable: false,
1246 enumerable: false,
1247 writable: true,
1248 value: existingProto
1249 });
1250 }
1251
1252 if (!('createEvent' in document)) {
1253 window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
1254 var
1255 element = this,
1256 type = arguments[0],
1257 listener = arguments[1];
1258
1259 if (element === window && type in unlistenableWindowEvents) {
1260 throw new Error('In IE8 the event: ' + type + ' is not available on the window object. Please see https://github.com/Financial-Times/polyfill-service/issues/317 for more information.');
1261 }
1262
1263 if (!element._events) {
1264 element._events = {};
1265 }
1266
1267 if (!element._events[type]) {
1268 element._events[type] = function (event) {
1269 var
1270 list = element._events[event.type].list,
1271 events = list.slice(),
1272 index = -1,
1273 length = events.length,
1274 eventElement;
1275
1276 event.preventDefault = function preventDefault() {
1277 if (event.cancelable !== false) {
1278 event.returnValue = false;
1279 }
1280 };
1281
1282 event.stopPropagation = function stopPropagation() {
1283 event.cancelBubble = true;
1284 };
1285
1286 event.stopImmediatePropagation = function stopImmediatePropagation() {
1287 event.cancelBubble = true;
1288 event.cancelImmediate = true;
1289 };
1290
1291 event.currentTarget = element;
1292 event.relatedTarget = event.fromElement || null;
1293 event.target = event.target || event.srcElement || element;
1294 event.timeStamp = new Date().getTime();
1295
1296 if (event.clientX) {
1297 event.pageX = event.clientX + document.documentElement.scrollLeft;
1298 event.pageY = event.clientY + document.documentElement.scrollTop;
1299 }
1300
1301 while (++index < length && !event.cancelImmediate) {
1302 if (index in events) {
1303 eventElement = events[index];
1304
1305 if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
1306 eventElement.call(element, event);
1307 }
1308 }
1309 }
1310 };
1311
1312 element._events[type].list = [];
1313
1314 if (element.attachEvent) {
1315 element.attachEvent('on' + type, element._events[type]);
1316 }
1317 }
1318
1319 element._events[type].list.push(listener);
1320 };
1321
1322 window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
1323 var
1324 element = this,
1325 type = arguments[0],
1326 listener = arguments[1],
1327 index;
1328
1329 if (element._events && element._events[type] && element._events[type].list) {
1330 index = indexOf(element._events[type].list, listener);
1331
1332 if (index !== -1) {
1333 element._events[type].list.splice(index, 1);
1334
1335 if (!element._events[type].list.length) {
1336 if (element.detachEvent) {
1337 element.detachEvent('on' + type, element._events[type]);
1338 }
1339 delete element._events[type];
1340 }
1341 }
1342 }
1343 };
1344
1345 window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
1346 if (!arguments.length) {
1347 throw new Error('Not enough arguments');
1348 }
1349
1350 if (!event || typeof event.type !== 'string') {
1351 throw new Error('DOM Events Exception 0');
1352 }
1353
1354 var element = this, type = event.type;
1355
1356 try {
1357 if (!event.bubbles) {
1358 event.cancelBubble = true;
1359
1360 var cancelBubbleEvent = function (event) {
1361 event.cancelBubble = true;
1362
1363 (element || window).detachEvent('on' + type, cancelBubbleEvent);
1364 };
1365
1366 this.attachEvent('on' + type, cancelBubbleEvent);
1367 }
1368
1369 this.fireEvent('on' + type, event);
1370 } catch (error) {
1371 event.target = element;
1372
1373 do {
1374 event.currentTarget = element;
1375
1376 if ('_events' in element && typeof element._events[type] === 'function') {
1377 element._events[type].call(element, event);
1378 }
1379
1380 if (typeof element['on' + type] === 'function') {
1381 element['on' + type].call(element, event);
1382 }
1383
1384 element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
1385 } while (element && !event.cancelBubble);
1386 }
1387
1388 return true;
1389 };
1390
1391 // Add the DOMContentLoaded Event
1392 document.attachEvent('onreadystatechange', function() {
1393 if (document.readyState === 'complete') {
1394 document.dispatchEvent(new Event('DOMContentLoaded', {
1395 bubbles: true
1396 }));
1397 }
1398 });
1399 }
1400}());
1401
1402// CustomEvent
1403this.CustomEvent = function CustomEvent(type, eventInitDict) {
1404 if (!type) {
1405 throw Error('TypeError: Failed to construct "CustomEvent": An event name must be provided.');
1406 }
1407
1408 var event;
1409 eventInitDict = eventInitDict || {bubbles: false, cancelable: false, detail: null};
1410
1411 if ('createEvent' in document) {
1412 try {
1413 event = document.createEvent('CustomEvent');
1414 event.initCustomEvent(type, eventInitDict.bubbles, eventInitDict.cancelable, eventInitDict.detail);
1415 } catch (error) {
1416 // for browsers which don't support CustomEvent at all, we use a regular event instead
1417 event = document.createEvent('Event');
1418 event.initEvent(type, eventInitDict.bubbles, eventInitDict.cancelable);
1419 event.detail = eventInitDict.detail;
1420 }
1421 } else {
1422
1423 // IE8
1424 event = new Event(type, eventInitDict);
1425 event.detail = eventInitDict && eventInitDict.detail || null;
1426 }
1427 return event;
1428};
1429
1430CustomEvent.prototype = Event.prototype;
1431
1432// _DOMTokenList
1433var _DOMTokenList = (function () { // eslint-disable-line no-unused-vars
1434
1435 function tokenize(token) {
1436 if (/^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$/.test(token)) {
1437 return String(token);
1438 } else {
1439 throw new Error('InvalidCharacterError: DOM Exception 5');
1440 }
1441 }
1442
1443 function toObject(self) {
1444 for (var index = -1, object = {}, element; element = self[++index];) {
1445 object[element] = true;
1446 }
1447
1448 return object;
1449 }
1450
1451 function fromObject(self, object) {
1452 var array = [], token;
1453
1454 for (token in object) {
1455 if (object[token]) {
1456 array.push(token);
1457 }
1458 }
1459
1460 [].splice.apply(self, [0, self.length].concat(array));
1461 }
1462
1463 var DTL = function() {};
1464
1465 DTL.prototype = {
1466 constructor: DTL,
1467 item: function item(index) {
1468 return this[parseFloat(index)] || null;
1469 },
1470 length: Array.prototype.length,
1471 toString: function toString() {
1472 return [].join.call(this, ' ');
1473 },
1474
1475 add: function add() {
1476 for (var object = toObject(this), index = 0, token; index in arguments; ++index) {
1477 token = tokenize(arguments[index]);
1478
1479 object[token] = true;
1480 }
1481
1482 fromObject(this, object);
1483 },
1484 contains: function contains(token) {
1485 return token in toObject(this);
1486 },
1487 remove: function remove() {
1488 for (var object = toObject(this), index = 0, token; index in arguments; ++index) {
1489 token = tokenize(arguments[index]);
1490
1491 object[token] = false;
1492 }
1493
1494 fromObject(this, object);
1495 },
1496 toggle: function toggle(token) {
1497 var
1498 object = toObject(this),
1499 contains = 1 in arguments ? !arguments[1] : tokenize(token) in object;
1500
1501 object[token] = !contains;
1502
1503 fromObject(this, object);
1504
1505 return !contains;
1506 }
1507 };
1508
1509 return DTL;
1510
1511}());
1512
1513// DOMTokenList
1514(function (global) {
1515 var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
1516
1517 if (!nativeImpl) {
1518 global.DOMTokenList = _DOMTokenList;
1519 } else {
1520 var NativeToggle = nativeImpl.prototype.toggle;
1521
1522 nativeImpl.prototype.toggle = function toggle(token) {
1523 if (1 in arguments) {
1524 var contains = this.contains(token);
1525 var force = !!arguments[1];
1526
1527 if ((contains && force) || (!contains && !force)) {
1528 return force;
1529 }
1530 }
1531
1532 return NativeToggle.call(this, token);
1533 };
1534
1535 }
1536
1537}(this));
1538
1539// DocumentFragment
1540this.DocumentFragment = document.createDocumentFragment().constructor;
1541
1542// _mutation
1543var _mutation = (function () { // eslint-disable-line no-unused-vars
1544
1545 function isNode(object) {
1546 // DOM, Level2
1547 if (typeof Node === 'function') {
1548 return object instanceof Node;
1549 }
1550 // Older browsers, check if it looks like a Node instance)
1551 return object &&
1552 typeof object === "object" &&
1553 object.nodeName &&
1554 object.nodeType >= 1 &&
1555 object.nodeType <= 12;
1556 }
1557
1558 // http://dom.spec.whatwg.org/#mutation-method-macro
1559 return function mutation(nodes) {
1560 if (nodes.length === 1) {
1561 return isNode(nodes[0]) ? nodes[0] : document.createTextNode(nodes[0] + '');
1562 }
1563
1564 var fragment = document.createDocumentFragment();
1565 for (var i = 0; i < nodes.length; i++) {
1566 fragment.appendChild(isNode(nodes[i]) ? nodes[i] : document.createTextNode(nodes[i] + ''));
1567
1568 }
1569 return fragment;
1570 };
1571}());
1572
1573// DocumentFragment.prototype.append
1574DocumentFragment.prototype.append = function append() {
1575 this.appendChild(_mutation(arguments));
1576};
1577
1578// DocumentFragment.prototype.prepend
1579DocumentFragment.prototype.prepend = function prepend() {
1580 this.insertBefore(_mutation(arguments), this.firstChild);
1581};
1582
1583// Element.prototype.after
1584Document.prototype.after = Element.prototype.after = function after() {
1585 if (this.parentNode) {
1586 var args = Array.prototype.slice.call(arguments),
1587 viableNextSibling = this.nextSibling,
1588 idx = viableNextSibling ? args.indexOf(viableNextSibling) : -1;
1589
1590 while (idx !== -1) {
1591 viableNextSibling = viableNextSibling.nextSibling;
1592 if (!viableNextSibling) {
1593 break;
1594 }
1595 idx = args.indexOf(viableNextSibling);
1596 }
1597
1598 this.parentNode.insertBefore(_mutation(arguments), viableNextSibling);
1599 }
1600};
1601
1602// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
1603// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
1604if ("Text" in this) {
1605 Text.prototype.after = Element.prototype.after;
1606}
1607
1608// Element.prototype.append
1609Document.prototype.append = Element.prototype.append = function append() {
1610 this.appendChild(_mutation(arguments));
1611};
1612
1613// Element.prototype.before
1614Document.prototype.before = Element.prototype.before = function before() {
1615 if (this.parentNode) {
1616 var args = Array.prototype.slice.call(arguments),
1617 viablePreviousSibling = this.previousSibling,
1618 idx = viablePreviousSibling ? args.indexOf(viablePreviousSibling) : -1;
1619
1620 while (idx !== -1) {
1621 viablePreviousSibling = viablePreviousSibling.previousSibling;
1622 if (!viablePreviousSibling) {
1623 break;
1624 }
1625 idx = args.indexOf(viablePreviousSibling);
1626 }
1627
1628 this.parentNode.insertBefore(
1629 _mutation(arguments),
1630 viablePreviousSibling ? viablePreviousSibling.nextSibling : this.parentNode.firstChild
1631 );
1632 }
1633};
1634
1635// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
1636// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
1637if ("Text" in this) {
1638 Text.prototype.before = Element.prototype.before;
1639}
1640
1641// Element.prototype.classList
1642Object.defineProperty(Element.prototype, 'classList', {
1643 configurable: true,
1644 get: function () {
1645
1646 function pull() {
1647 var className = (typeof element.className === "object" ? element.className.baseVal : element.className);
1648 [].splice.apply(classList, [0, classList.length].concat((className || '').replace(/^\s+|\s+$/g, '').split(/\s+/)));
1649 }
1650
1651 function push() {
1652 if (element.attachEvent) {
1653 element.detachEvent('onpropertychange', pull);
1654 }
1655
1656 if (typeof element.className === "object") {
1657 element.className.baseVal = original.toString.call(classList);
1658 } else {
1659 element.className = original.toString.call(classList);
1660 }
1661
1662 if (element.attachEvent) {
1663 element.attachEvent('onpropertychange', pull);
1664 }
1665 }
1666
1667 var element = this;
1668 var original = _DOMTokenList.prototype;
1669 var ClassList = function ClassList() {};
1670 var classList;
1671
1672 ClassList.prototype = new _DOMTokenList;
1673
1674 ClassList.prototype.item = function item(index) { // eslint-disable-line no-unused-vars
1675 return pull(), original.item.apply(classList, arguments);
1676 };
1677
1678 ClassList.prototype.toString = function toString() {
1679 return pull(), original.toString.apply(classList, arguments);
1680 };
1681
1682 ClassList.prototype.add = function add() {
1683 return pull(), original.add.apply(classList, arguments), push();
1684 };
1685
1686 ClassList.prototype.contains = function contains(token) { // eslint-disable-line no-unused-vars
1687 return pull(), original.contains.apply(classList, arguments);
1688 };
1689
1690 ClassList.prototype.remove = function remove() {
1691 return pull(), original.remove.apply(classList, arguments), push();
1692 };
1693
1694 ClassList.prototype.toggle = function toggle(token) {
1695 return pull(), token = original.toggle.apply(classList, arguments), push(), token;
1696 };
1697
1698 classList = new ClassList;
1699
1700 if (element.attachEvent) {
1701 element.attachEvent('onpropertychange', pull);
1702 }
1703
1704 return classList;
1705 }
1706});
1707
1708// Element.prototype.matches
1709Element.prototype.matches = Element.prototype.webkitMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || function matches(selector) {
1710
1711 var element = this;
1712 var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
1713 var index = 0;
1714
1715 while (elements[index] && elements[index] !== element) {
1716 ++index;
1717 }
1718
1719 return !!elements[index];
1720};
1721
1722// Element.prototype.closest
1723Element.prototype.closest = function closest(selector) {
1724 var node = this;
1725
1726 while (node) {
1727 if (node.matches(selector)) return node;
1728 else node = node.tagName === 'svg' ? node.parentNode : node.parentElement;
1729 }
1730
1731 return null;
1732};
1733
1734// Element.prototype.prepend
1735Document.prototype.prepend = Element.prototype.prepend = function prepend() {
1736 this.insertBefore(_mutation(arguments), this.firstChild);
1737};
1738
1739// Element.prototype.remove
1740Document.prototype.remove = Element.prototype.remove = function remove() {
1741 if (this.parentNode) {
1742 this.parentNode.removeChild(this);
1743 }
1744};
1745
1746// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
1747// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
1748if ("Text" in this) {
1749 Text.prototype.remove = Element.prototype.remove;
1750}
1751
1752// Element.prototype.replaceWith
1753Document.prototype.replaceWith = Element.prototype.replaceWith = function replaceWith() {
1754 if (this.parentNode) {
1755 this.parentNode.replaceChild(_mutation(arguments), this);
1756 }
1757};
1758
1759// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
1760// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
1761if ('Text' in this) {
1762 Text.prototype.replaceWith = Element.prototype.replaceWith;
1763}
1764
1765// Symbol.species
1766Object.defineProperty(Symbol, 'species', {value: Symbol('species')});
1767
1768// Map
1769(function(global) {
1770
1771
1772 // Deleted map items mess with iterator pointers, so rather than removing them mark them as deleted. Can't use undefined or null since those both valid keys so use a private symbol.
1773 var undefMarker = Symbol('undef');
1774
1775 // NaN cannot be found in an array using indexOf, so we encode NaNs using a private symbol.
1776 var NaNMarker = Symbol('NaN');
1777
1778 function encodeKey(key) {
1779 return Number.isNaN(key) ? NaNMarker : key;
1780 }
1781 function decodeKey(encodedKey) {
1782 return (encodedKey === NaNMarker) ? NaN : encodedKey;
1783 }
1784
1785 function makeIterator(mapInst, getter) {
1786 var nextIdx = 0;
1787 var done = false;
1788 return {
1789 next: function() {
1790 if (!mapInst.size || nextIdx === mapInst._keys.length) {
1791 done = true;
1792 }
1793 if (!done) {
1794 while (nextIdx <= mapInst._keys.length) {
1795 if (mapInst._keys[nextIdx] === undefMarker) {
1796 nextIdx++;
1797 } else {
1798 break;
1799 }
1800 }
1801 if (!mapInst.size || nextIdx === mapInst._keys.length) {
1802 return {value: void 0, done:true};
1803 }
1804 return {value: getter.call(mapInst, nextIdx++), done: false};
1805 } else {
1806 return {value: void 0, done:true};
1807 }
1808 }
1809 };
1810 }
1811
1812 function hasProtoMethod(instance, method){
1813 return typeof instance[method] === 'function';
1814 }
1815
1816 var Map = function Map() {
1817 var data = arguments[0];
1818 this._keys = [];
1819 this._values = [];
1820 this.size = this._size = 0;
1821 // If `data` is iterable (indicated by presence of a forEach method), pre-populate the map
1822 if (data && hasProtoMethod(data, 'forEach')){
1823 // Fastpath: If `data` is a Map, shortcircuit all following the checks
1824 if (data instanceof Map ||
1825 // If `data` is not an instance of Map, it could be because you have a Map from an iframe or a worker or something.
1826 // Check if `data` has all the `Map` methods and if so, assume data is another Map
1827 hasProtoMethod(data, 'clear') &&
1828 hasProtoMethod(data, 'delete') &&
1829 hasProtoMethod(data, 'entries') &&
1830 hasProtoMethod(data, 'forEach') &&
1831 hasProtoMethod(data, 'get') &&
1832 hasProtoMethod(data, 'has') &&
1833 hasProtoMethod(data, 'keys') &&
1834 hasProtoMethod(data, 'set') &&
1835 hasProtoMethod(data, 'values')){
1836 data.forEach(function (value, key) {
1837 this.set.apply(this, [key, value]);
1838 }, this);
1839 } else {
1840 data.forEach(function (item) {
1841 this.set.apply(this, item);
1842 }, this);
1843 }
1844 }
1845 };
1846 Map.prototype = {};
1847
1848 // Some old engines do not support ES5 getters/setters. Since Map only requires these for the size property, we can fall back to setting the size property statically each time the size of the map changes.
1849 try {
1850 Object.defineProperty(Map.prototype, 'size', {
1851 get: function() {
1852 return this._size;
1853 }
1854 });
1855 } catch(e) {
1856 }
1857
1858 Map.prototype['get'] = function(key) {
1859 var idx = this._keys.indexOf(encodeKey(key));
1860 return (idx !== -1) ? this._values[idx] : undefined;
1861 };
1862 Map.prototype['set'] = function(key, value) {
1863 var idx = this._keys.indexOf(encodeKey(key));
1864 if (idx !== -1) {
1865 this._values[idx] = value;
1866 } else {
1867 this._keys.push(encodeKey(key));
1868 this._values.push(value);
1869
1870 this.size = ++this._size;
1871 }
1872 return this;
1873 };
1874 Map.prototype['has'] = function(key) {
1875 return (this._keys.indexOf(encodeKey(key)) !== -1);
1876 };
1877 Map.prototype['delete'] = function(key) {
1878 var idx = this._keys.indexOf(encodeKey(key));
1879 if (idx === -1) return false;
1880 this._keys[idx] = undefMarker;
1881 this._values[idx] = undefMarker;
1882
1883 this.size = --this._size;
1884 return true;
1885 };
1886 Map.prototype['clear'] = function() {
1887 this._keys = [];
1888 this._values = [];
1889 this.size = this._size = 0;
1890 };
1891 Map.prototype['values'] = function() {
1892 return makeIterator(this, function(i) { return this._values[i]; });
1893 };
1894 Map.prototype['keys'] = function() {
1895 return makeIterator(this, function(i) { return decodeKey(this._keys[i]); });
1896 };
1897 Map.prototype['entries'] =
1898 Map.prototype[Symbol.iterator] = function() {
1899 return makeIterator(this, function(i) { return [decodeKey(this._keys[i]), this._values[i]]; });
1900 };
1901 Map.prototype['forEach'] = function(callbackFn, thisArg) {
1902 thisArg = thisArg || global;
1903 var iterator = this.entries();
1904 var result = iterator.next();
1905 while (result.done === false) {
1906 callbackFn.call(thisArg, result.value[1], result.value[0], this);
1907 result = iterator.next();
1908 }
1909 };
1910 Map.prototype['constructor'] =
1911 Map.prototype[Symbol.species] = Map;
1912
1913 Map.prototype.constructor = Map;
1914 Map.name = "Map";
1915
1916 // Export the object
1917 global.Map = Map;
1918
1919}(this));
1920
1921// Node.prototype.contains
1922(function() {
1923
1924 function contains(node) {
1925 if (!(0 in arguments)) {
1926 throw new TypeError('1 argument is required');
1927 }
1928
1929 do {
1930 if (this === node) {
1931 return true;
1932 }
1933 } while (node = node && node.parentNode);
1934
1935 return false;
1936 }
1937
1938 // IE
1939 if ('HTMLElement' in this && 'contains' in HTMLElement.prototype) {
1940 try {
1941 delete HTMLElement.prototype.contains;
1942 } catch (e) {}
1943 }
1944
1945 if ('Node' in this) {
1946 Node.prototype.contains = contains;
1947 } else {
1948 document.contains = Element.prototype.contains = contains;
1949 }
1950
1951}());
1952
1953// Promise
1954!function(n){function t(e){if(r[e])return r[e].exports;var o=r[e]={exports:{},id:e,loaded:!1};return n[e].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=n,t.c=r,t.p="",t(0)}({0:/*!***********************!*\
1955 !*** ./src/global.js ***!
1956 \***********************/
1957function(n,t,r){(function(n){var t=r(/*! ./yaku */80);try{(n||{}).Promise=t,window.Promise=t}catch(err){}}).call(t,function(){return this}())},80:/*!*********************!*\
1958 !*** ./src/yaku.js ***!
1959 \*********************/
1960function(n,t){(function(t){!function(){"use strict";function r(){return un[B][G]||J}function e(n,t){for(var r in t)n[r]=t[r]}function o(n){return n&&"object"==typeof n}function i(n){return"function"==typeof n}function u(n,t){return n instanceof t}function c(n){return u(n,U)}function f(n,t,r){if(!t(n))throw v(r)}function s(){try{return C.apply(F,arguments)}catch(e){return rn.e=e,rn}}function a(n,t){return C=n,F=t,s}function l(n,t){function r(){for(var r=0;r<o;)t(e[r],e[r+1]),e[r++]=S,e[r++]=S;o=0,e.length>n&&(e.length=n)}var e=O(n),o=0;return function(n,t){e[o++]=n,e[o++]=t,2===o&&un.nextTick(r)}}function h(n,t){var r,e,o,c,f=0;if(!n)throw v(W);var s=n[un[B][D]];if(i(s))e=s.call(n);else{if(!i(n.next)){if(u(n,O)){for(r=n.length;f<r;)t(n[f],f++);return f}throw v(W)}e=n}for(;!(o=e.next()).done;)if(c=a(t)(o.value,f++),c===rn)throw i(e[K])&&e[K](),c.e;return f}function v(n){return new TypeError(n)}function _(n){return(n?"":X)+(new U).stack}function d(n,t){var r="on"+n.toLowerCase(),e=H[r];I&&I.listeners(n).length?n===tn?I.emit(n,t._v,t):I.emit(n,t):e?e({reason:t._v,promise:t}):un[n](t._v,t)}function p(n){return n&&n._s}function w(n){if(p(n))return new n(en);var t,r,e;return t=new n(function(n,o){if(t)throw v();r=n,e=o}),f(r,i),f(e,i),t}function m(n,t){return function(r){A&&(n[Q]=_(!0)),t===q?T(n,r):k(n,t,r)}}function y(n,t,r,e){return i(r)&&(t._onFulfilled=r),i(e)&&(n[M]&&d(nn,n),t._onRejected=e),A&&(t._p=n),n[n._c++]=t,n._s!==z&&cn(n,t),t}function j(n){if(n._umark)return!0;n._umark=!0;for(var t,r=0,e=n._c;r<e;)if(t=n[r++],t._onRejected||j(t))return!0}function x(n,t){function r(n){return e.push(n.replace(/^\s+|\s+$/g,""))}var e=[];return A&&(t[Q]&&r(t[Q]),function o(n){n&&N in n&&(o(n._next),r(n[N]+""),o(n._p))}(t)),(n&&n.stack?n.stack:n)+("\n"+e.join("\n")).replace(on,"")}function g(n,t){return n(t)}function k(n,t,r){var e=0,o=n._c;if(n._s===z)for(n._s=t,n._v=r,t===$&&(A&&c(r)&&(r.longStack=x(r,n)),fn(n));e<o;)cn(n,n[e++]);return n}function T(n,t){if(t===n&&t)return k(n,$,v(Y)),n;if(t!==P&&(i(t)||o(t))){var r=a(b)(t);if(r===rn)return k(n,$,r.e),n;i(r)?(A&&p(t)&&(n._next=t),p(t)?R(n,t,r):un.nextTick(function(){R(n,t,r)})):k(n,q,t)}else k(n,q,t);return n}function b(n){return n.then}function R(n,t,r){var e=a(r,t)(function(r){t&&(t=P,T(n,r))},function(r){t&&(t=P,k(n,$,r))});e===rn&&t&&(k(n,$,e.e),t=P)}var S,C,F,P=null,E="object"==typeof window,H=E?window:t,I=H.process,L=H.console,A=!1,O=Array,U=Error,$=1,q=2,z=3,B="Symbol",D="iterator",G="species",J=B+"("+G+")",K="return",M="_uh",N="_pt",Q="_st",V="Invalid this",W="Invalid argument",X="\nFrom previous ",Y="Chaining cycle detected for promise",Z="Uncaught (in promise)",nn="rejectionHandled",tn="unhandledRejection",rn={e:P},en=function(){},on=/^.+\/node_modules\/yaku\/.+\n?/gm,un=n.exports=function(n){var t,r=this;if(!o(r)||r._s!==S)throw v(V);if(r._s=z,A&&(r[N]=_()),n!==en){if(!i(n))throw v(W);t=a(n)(m(r,q),m(r,$)),t===rn&&k(r,$,t.e)}};un["default"]=un,e(un.prototype,{then:function(n,t){if(void 0===this._s)throw v();return y(this,w(un.speciesConstructor(this,un)),n,t)},"catch":function(n){return this.then(S,n)},"finally":function(n){function t(t){return un.resolve(n()).then(function(){return t})}return this.then(t,t)},_c:0,_p:P}),un.resolve=function(n){return p(n)?n:T(w(this),n)},un.reject=function(n){return k(w(this),$,n)},un.race=function(n){var t=this,r=w(t),e=function(n){k(r,q,n)},o=function(n){k(r,$,n)},i=a(h)(n,function(n){t.resolve(n).then(e,o)});return i===rn?t.reject(i.e):r},un.all=function(n){function t(n){k(o,$,n)}var r,e=this,o=w(e),i=[];return r=a(h)(n,function(n,u){e.resolve(n).then(function(n){i[u]=n,--r||k(o,q,i)},t)}),r===rn?e.reject(r.e):(r||k(o,q,[]),o)},un.Symbol=H[B]||{},a(function(){Object.defineProperty(un,r(),{get:function(){return this}})})(),un.speciesConstructor=function(n,t){var e=n.constructor;return e?e[r()]||t:t},un.unhandledRejection=function(n,t){L&&L.error(Z,A?t.longStack:x(n,t))},un.rejectionHandled=en,un.enableLongStackTrace=function(){A=!0},un.nextTick=E?function(n){setTimeout(n)}:I.nextTick,un._s=1;var cn=l(999,function(n,t){var r,e;return e=n._s!==$?t._onFulfilled:t._onRejected,e===S?void k(t,n._s,n._v):(r=a(g)(e,n._v),r===rn?void k(t,$,r.e):void T(t,r))}),fn=l(9,function(n){j(n)||(n[M]=1,d(tn,n))})}()}).call(t,function(){return this}())}});
1961// Set
1962(function(global) {
1963
1964
1965 // Deleted map items mess with iterator pointers, so rather than removing them mark them as deleted. Can't use undefined or null since those both valid keys so use a private symbol.
1966 var undefMarker = Symbol('undef');
1967
1968 // NaN cannot be found in an array using indexOf, so we encode NaNs using a private symbol.
1969 var NaNMarker = Symbol('NaN');
1970
1971 function encodeVal(data) {
1972 return Number.isNaN(data) ? NaNMarker : data;
1973 }
1974 function decodeVal(encodedData) {
1975 return (encodedData === NaNMarker) ? NaN : encodedData;
1976 }
1977
1978 function makeIterator(setInst, getter) {
1979 var nextIdx = 0;
1980 return {
1981 next: function() {
1982 while (setInst._values[nextIdx] === undefMarker) nextIdx++;
1983 if (nextIdx === setInst._values.length) {
1984 return {value: void 0, done: true};
1985 }
1986 else {
1987 return {value: getter.call(setInst, nextIdx++), done: false};
1988 }
1989 }
1990 };
1991 }
1992
1993 var Set = function Set() {
1994 var data = arguments[0];
1995 this._values = [];
1996 this.size = this._size = 0;
1997
1998 // If `data` is iterable (indicated by presence of a forEach method), pre-populate the set
1999 data && (typeof data.forEach === 'function') && data.forEach(function (item) {
2000 this.add.call(this, item);
2001 }, this);
2002 };
2003
2004 // Some old engines do not support ES5 getters/setters. Since Set only requires these for the size property, we can fall back to setting the size property statically each time the size of the set changes.
2005 try {
2006 Object.defineProperty(Set.prototype, 'size', {
2007 get: function() {
2008 return this._size;
2009 }
2010 });
2011 } catch(e) {
2012 }
2013
2014 Set.prototype['add'] = function(value) {
2015 value = encodeVal(value);
2016 if (this._values.indexOf(value) === -1) {
2017 this._values.push(value);
2018 this.size = ++this._size;
2019 }
2020 return this;
2021 };
2022 Set.prototype['has'] = function(value) {
2023 return (this._values.indexOf(encodeVal(value)) !== -1);
2024 };
2025 Set.prototype['delete'] = function(value) {
2026 var idx = this._values.indexOf(encodeVal(value));
2027 if (idx === -1) return false;
2028 this._values[idx] = undefMarker;
2029 this.size = --this._size;
2030 return true;
2031 };
2032 Set.prototype['clear'] = function() {
2033 this._values = [];
2034 this.size = this._size = 0;
2035 };
2036 Set.prototype['values'] =
2037 Set.prototype['keys'] =
2038 Set.prototype[Symbol.iterator] = function() {
2039 return makeIterator(this, function(i) { return decodeVal(this._values[i]); });
2040 };
2041 Set.prototype['entries'] = function() {
2042 return makeIterator(this, function(i) { return [decodeVal(this._values[i]), decodeVal(this._values[i])]; });
2043 };
2044 Set.prototype['forEach'] = function(callbackFn, thisArg) {
2045 thisArg = thisArg || global;
2046 var iterator = this.entries();
2047 var result = iterator.next();
2048 while (result.done === false) {
2049 callbackFn.call(thisArg, result.value[1], result.value[0], this);
2050 result = iterator.next();
2051 }
2052 };
2053 Set.prototype['constructor'] =
2054 Set.prototype[Symbol.species] = Set;
2055
2056 Set.prototype.constructor = Set;
2057 Set.name = "Set";
2058
2059 // Export the object
2060 global.Set = Set;
2061
2062}(this));
2063
2064// String.prototype.endsWith
2065String.prototype.endsWith = function (string) {
2066 var index = arguments.length < 2 ? this.length : arguments[1];
2067 var foundIndex = this.lastIndexOf(string);
2068 return foundIndex !== -1 && foundIndex === index - string.length;
2069};
2070
2071// String.prototype.startsWith
2072String.prototype.startsWith = function (string) {
2073 var index = arguments.length < 2 ? 0 : arguments[1];
2074
2075 return this.slice(index).indexOf(string) === 0;
2076};
2077
2078// URL
2079// URL Polyfill
2080// Draft specification: https://url.spec.whatwg.org
2081
2082// Notes:
2083// - Primarily useful for parsing URLs and modifying query parameters
2084// - Should work in IE8+ and everything more modern, with es5.js polyfills
2085
2086(function (global) {
2087 'use strict';
2088
2089 function isSequence(o) {
2090 if (!o) return false;
2091 if ('Symbol' in global && 'iterator' in global.Symbol &&
2092 typeof o[Symbol.iterator] === 'function') return true;
2093 if (Array.isArray(o)) return true;
2094 return false;
2095 }
2096
2097 function toArray(iter) {
2098 return ('from' in Array) ? Array.from(iter) : Array.prototype.slice.call(iter);
2099 }
2100
2101 (function() {
2102
2103 // Browsers may have:
2104 // * No global URL object
2105 // * URL with static methods only - may have a dummy constructor
2106 // * URL with members except searchParams
2107 // * Full URL API support
2108 var origURL = global.URL;
2109 var nativeURL;
2110 try {
2111 if (origURL) {
2112 nativeURL = new global.URL('http://example.com');
2113 if ('searchParams' in nativeURL)
2114 return;
2115 if (!('href' in nativeURL))
2116 nativeURL = undefined;
2117 }
2118 } catch (_) {}
2119
2120 // NOTE: Doesn't do the encoding/decoding dance
2121 function urlencoded_serialize(pairs) {
2122 var output = '', first = true;
2123 pairs.forEach(function (pair) {
2124 var name = encodeURIComponent(pair.name);
2125 var value = encodeURIComponent(pair.value);
2126 if (!first) output += '&';
2127 output += name + '=' + value;
2128 first = false;
2129 });
2130 return output.replace(/%20/g, '+');
2131 }
2132
2133 // NOTE: Doesn't do the encoding/decoding dance
2134 function urlencoded_parse(input, isindex) {
2135 var sequences = input.split('&');
2136 if (isindex && sequences[0].indexOf('=') === -1)
2137 sequences[0] = '=' + sequences[0];
2138 var pairs = [];
2139 sequences.forEach(function (bytes) {
2140 if (bytes.length === 0) return;
2141 var index = bytes.indexOf('=');
2142 if (index !== -1) {
2143 var name = bytes.substring(0, index);
2144 var value = bytes.substring(index + 1);
2145 } else {
2146 name = bytes;
2147 value = '';
2148 }
2149 name = name.replace(/\+/g, ' ');
2150 value = value.replace(/\+/g, ' ');
2151 pairs.push({ name: name, value: value });
2152 });
2153 var output = [];
2154 pairs.forEach(function (pair) {
2155 output.push({
2156 name: decodeURIComponent(pair.name),
2157 value: decodeURIComponent(pair.value)
2158 });
2159 });
2160 return output;
2161 }
2162
2163 function URLUtils(url) {
2164 if (nativeURL)
2165 return new origURL(url);
2166 var anchor = document.createElement('a');
2167 anchor.href = url;
2168 return anchor;
2169 }
2170
2171 function URLSearchParams(init) {
2172 var $this = this;
2173 this._list = [];
2174
2175 if (init === undefined || init === null) {
2176 // no-op
2177 } else if (init instanceof URLSearchParams) {
2178 // In ES6 init would be a sequence, but special case for ES5.
2179 this._list = urlencoded_parse(String(init));
2180 } else if (typeof init === 'object' && isSequence(init)) {
2181 toArray(init).forEach(function(e) {
2182 if (!isSequence(e)) throw TypeError();
2183 var nv = toArray(e);
2184 if (nv.length !== 2) throw TypeError();
2185 $this._list.push({name: String(nv[0]), value: String(nv[1])});
2186 });
2187 } else if (typeof init === 'object' && init) {
2188 Object.keys(init).forEach(function(key) {
2189 $this._list.push({name: String(key), value: String(init[key])});
2190 });
2191 } else {
2192 init = String(init);
2193 if (init.substring(0, 1) === '?')
2194 init = init.substring(1);
2195 this._list = urlencoded_parse(init);
2196 }
2197
2198 this._url_object = null;
2199 this._setList = function (list) { if (!updating) $this._list = list; };
2200
2201 var updating = false;
2202 this._update_steps = function() {
2203 if (updating) return;
2204 updating = true;
2205
2206 if (!$this._url_object) return;
2207
2208 // Partial workaround for IE issue with 'about:'
2209 if ($this._url_object.protocol === 'about:' &&
2210 $this._url_object.pathname.indexOf('?') !== -1) {
2211 $this._url_object.pathname = $this._url_object.pathname.split('?')[0];
2212 }
2213
2214 $this._url_object.search = urlencoded_serialize($this._list);
2215
2216 updating = false;
2217 };
2218 }
2219
2220
2221 Object.defineProperties(URLSearchParams.prototype, {
2222 append: {
2223 value: function (name, value) {
2224 this._list.push({ name: name, value: value });
2225 this._update_steps();
2226 }, writable: true, enumerable: true, configurable: true
2227 },
2228
2229 'delete': {
2230 value: function (name) {
2231 for (var i = 0; i < this._list.length;) {
2232 if (this._list[i].name === name)
2233 this._list.splice(i, 1);
2234 else
2235 ++i;
2236 }
2237 this._update_steps();
2238 }, writable: true, enumerable: true, configurable: true
2239 },
2240
2241 get: {
2242 value: function (name) {
2243 for (var i = 0; i < this._list.length; ++i) {
2244 if (this._list[i].name === name)
2245 return this._list[i].value;
2246 }
2247 return null;
2248 }, writable: true, enumerable: true, configurable: true
2249 },
2250
2251 getAll: {
2252 value: function (name) {
2253 var result = [];
2254 for (var i = 0; i < this._list.length; ++i) {
2255 if (this._list[i].name === name)
2256 result.push(this._list[i].value);
2257 }
2258 return result;
2259 }, writable: true, enumerable: true, configurable: true
2260 },
2261
2262 has: {
2263 value: function (name) {
2264 for (var i = 0; i < this._list.length; ++i) {
2265 if (this._list[i].name === name)
2266 return true;
2267 }
2268 return false;
2269 }, writable: true, enumerable: true, configurable: true
2270 },
2271
2272 set: {
2273 value: function (name, value) {
2274 var found = false;
2275 for (var i = 0; i < this._list.length;) {
2276 if (this._list[i].name === name) {
2277 if (!found) {
2278 this._list[i].value = value;
2279 found = true;
2280 ++i;
2281 } else {
2282 this._list.splice(i, 1);
2283 }
2284 } else {
2285 ++i;
2286 }
2287 }
2288
2289 if (!found)
2290 this._list.push({ name: name, value: value });
2291
2292 this._update_steps();
2293 }, writable: true, enumerable: true, configurable: true
2294 },
2295
2296 entries: {
2297 value: function() { return new Iterator(this._list, 'key+value'); },
2298 writable: true, enumerable: true, configurable: true
2299 },
2300
2301 keys: {
2302 value: function() { return new Iterator(this._list, 'key'); },
2303 writable: true, enumerable: true, configurable: true
2304 },
2305
2306 values: {
2307 value: function() { return new Iterator(this._list, 'value'); },
2308 writable: true, enumerable: true, configurable: true
2309 },
2310
2311 forEach: {
2312 value: function(callback) {
2313 var thisArg = (arguments.length > 1) ? arguments[1] : undefined;
2314 this._list.forEach(function(pair, index) {
2315 callback.call(thisArg, pair.value, pair.name);
2316 });
2317
2318 }, writable: true, enumerable: true, configurable: true
2319 },
2320
2321 toString: {
2322 value: function () {
2323 return urlencoded_serialize(this._list);
2324 }, writable: true, enumerable: false, configurable: true
2325 }
2326 });
2327
2328 function Iterator(source, kind) {
2329 var index = 0;
2330 this['next'] = function() {
2331 if (index >= source.length)
2332 return {done: true, value: undefined};
2333 var pair = source[index++];
2334 return {done: false, value:
2335 kind === 'key' ? pair.name :
2336 kind === 'value' ? pair.value :
2337 [pair.name, pair.value]};
2338 };
2339 }
2340
2341 if ('Symbol' in global && 'iterator' in global.Symbol) {
2342 Object.defineProperty(URLSearchParams.prototype, global.Symbol.iterator, {
2343 value: URLSearchParams.prototype.entries,
2344 writable: true, enumerable: true, configurable: true});
2345 Object.defineProperty(Iterator.prototype, global.Symbol.iterator, {
2346 value: function() { return this; },
2347 writable: true, enumerable: true, configurable: true});
2348 }
2349
2350 function URL(url, base) {
2351 if (!(this instanceof global.URL))
2352 throw new TypeError("Failed to construct 'URL': Please use the 'new' operator.");
2353
2354 if (base) {
2355 url = (function () {
2356 if (nativeURL) return new origURL(url, base).href;
2357
2358 var doc;
2359 // Use another document/base tag/anchor for relative URL resolution, if possible
2360 if (document.implementation && document.implementation.createHTMLDocument) {
2361 doc = document.implementation.createHTMLDocument('');
2362 } else if (document.implementation && document.implementation.createDocument) {
2363 doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);
2364 doc.documentElement.appendChild(doc.createElement('head'));
2365 doc.documentElement.appendChild(doc.createElement('body'));
2366 } else if (window.ActiveXObject) {
2367 doc = new window.ActiveXObject('htmlfile');
2368 doc.write('<head><\/head><body><\/body>');
2369 doc.close();
2370 }
2371
2372 if (!doc) throw Error('base not supported');
2373
2374 var baseTag = doc.createElement('base');
2375 baseTag.href = base;
2376 doc.getElementsByTagName('head')[0].appendChild(baseTag);
2377 var anchor = doc.createElement('a');
2378 anchor.href = url;
2379 return anchor.href;
2380 }());
2381 }
2382
2383 // An inner object implementing URLUtils (either a native URL
2384 // object or an HTMLAnchorElement instance) is used to perform the
2385 // URL algorithms. With full ES5 getter/setter support, return a
2386 // regular object For IE8's limited getter/setter support, a
2387 // different HTMLAnchorElement is returned with properties
2388 // overridden
2389
2390 var instance = URLUtils(url || '');
2391
2392 // Detect for ES5 getter/setter support
2393 // (an Object.defineProperties polyfill that doesn't support getters/setters may throw)
2394 var ES5_GET_SET = (function() {
2395 if (!('defineProperties' in Object)) return false;
2396 try {
2397 var obj = {};
2398 Object.defineProperties(obj, { prop: { 'get': function () { return true; } } });
2399 return obj.prop;
2400 } catch (_) {
2401 return false;
2402 }
2403 })();
2404
2405 var self = ES5_GET_SET ? this : document.createElement('a');
2406
2407
2408
2409 var query_object = new URLSearchParams(
2410 instance.search ? instance.search.substring(1) : null);
2411 query_object._url_object = self;
2412
2413 Object.defineProperties(self, {
2414 href: {
2415 get: function () { return instance.href; },
2416 set: function (v) { instance.href = v; tidy_instance(); update_steps(); },
2417 enumerable: true, configurable: true
2418 },
2419 origin: {
2420 get: function () {
2421 if ('origin' in instance) return instance.origin;
2422 return this.protocol + '//' + this.host;
2423 },
2424 enumerable: true, configurable: true
2425 },
2426 protocol: {
2427 get: function () { return instance.protocol; },
2428 set: function (v) { instance.protocol = v; },
2429 enumerable: true, configurable: true
2430 },
2431 username: {
2432 get: function () { return instance.username; },
2433 set: function (v) { instance.username = v; },
2434 enumerable: true, configurable: true
2435 },
2436 password: {
2437 get: function () { return instance.password; },
2438 set: function (v) { instance.password = v; },
2439 enumerable: true, configurable: true
2440 },
2441 host: {
2442 get: function () {
2443 // IE returns default port in |host|
2444 var re = {'http:': /:80$/, 'https:': /:443$/, 'ftp:': /:21$/}[instance.protocol];
2445 return re ? instance.host.replace(re, '') : instance.host;
2446 },
2447 set: function (v) { instance.host = v; },
2448 enumerable: true, configurable: true
2449 },
2450 hostname: {
2451 get: function () { return instance.hostname; },
2452 set: function (v) { instance.hostname = v; },
2453 enumerable: true, configurable: true
2454 },
2455 port: {
2456 get: function () { return instance.port; },
2457 set: function (v) { instance.port = v; },
2458 enumerable: true, configurable: true
2459 },
2460 pathname: {
2461 get: function () {
2462 // IE does not include leading '/' in |pathname|
2463 if (instance.pathname.charAt(0) !== '/') return '/' + instance.pathname;
2464 return instance.pathname;
2465 },
2466 set: function (v) { instance.pathname = v; },
2467 enumerable: true, configurable: true
2468 },
2469 search: {
2470 get: function () { return instance.search; },
2471 set: function (v) {
2472 if (instance.search === v) return;
2473 instance.search = v; tidy_instance(); update_steps();
2474 },
2475 enumerable: true, configurable: true
2476 },
2477 searchParams: {
2478 get: function () { return query_object; },
2479 enumerable: true, configurable: true
2480 },
2481 hash: {
2482 get: function () { return instance.hash; },
2483 set: function (v) { instance.hash = v; tidy_instance(); },
2484 enumerable: true, configurable: true
2485 },
2486 toString: {
2487 value: function() { return instance.toString(); },
2488 enumerable: false, configurable: true
2489 },
2490 valueOf: {
2491 value: function() { return instance.valueOf(); },
2492 enumerable: false, configurable: true
2493 }
2494 });
2495
2496 function tidy_instance() {
2497 var href = instance.href.replace(/#$|\?$|\?(?=#)/g, '');
2498 if (instance.href !== href)
2499 instance.href = href;
2500 }
2501
2502 function update_steps() {
2503 query_object._setList(instance.search ? urlencoded_parse(instance.search.substring(1)) : []);
2504 query_object._update_steps();
2505 };
2506
2507 return self;
2508 }
2509
2510 if (origURL) {
2511 for (var i in origURL) {
2512 if (origURL.hasOwnProperty(i) && typeof origURL[i] === 'function')
2513 URL[i] = origURL[i];
2514 }
2515 }
2516
2517 global.URL = URL;
2518 global.URLSearchParams = URLSearchParams;
2519 }());
2520
2521 // Patch native URLSearchParams constructor to handle sequences/records
2522 // if necessary.
2523 (function() {
2524 if (new global.URLSearchParams([['a', 1]]).get('a') === '1' &&
2525 new global.URLSearchParams({a: 1}).get('a') === '1')
2526 return;
2527 var orig = global.URLSearchParams;
2528 global.URLSearchParams = function(init) {
2529 if (init && typeof init === 'object' && isSequence(init)) {
2530 var o = new orig();
2531 toArray(init).forEach(function(e) {
2532 if (!isSequence(e)) throw TypeError();
2533 var nv = toArray(e);
2534 if (nv.length !== 2) throw TypeError();
2535 o.append(nv[0], nv[1]);
2536 });
2537 return o;
2538 } else if (init && typeof init === 'object') {
2539 o = new orig();
2540 Object.keys(init).forEach(function(key) {
2541 o.set(key, init[key]);
2542 });
2543 return o;
2544 } else {
2545 return new orig(init);
2546 }
2547 };
2548 }());
2549
2550}(self));
2551
2552// atob
2553;(function () {
2554
2555 var object =
2556 typeof exports != 'undefined' ? exports :
2557 typeof self != 'undefined' ? self : // #8: web workers
2558 $.global; // #31: ExtendScript
2559
2560 var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
2561
2562 function InvalidCharacterError(message) {
2563 this.message = message;
2564 }
2565 InvalidCharacterError.prototype = new Error;
2566 InvalidCharacterError.prototype.name = 'InvalidCharacterError';
2567
2568 // encoder
2569 // [https://gist.github.com/999166] by [https://github.com/nignag]
2570 object.btoa || (
2571 object.btoa = function (input) {
2572 var str = String(input);
2573 for (
2574 // initialize result and counter
2575 var block, charCode, idx = 0, map = chars, output = '';
2576 // if the next str index does not exist:
2577 // change the mapping table to "="
2578 // check if d has no fractional digits
2579 str.charAt(idx | 0) || (map = '=', idx % 1);
2580 // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
2581 output += map.charAt(63 & block >> 8 - idx % 1 * 8)
2582 ) {
2583 charCode = str.charCodeAt(idx += 3/4);
2584 if (charCode > 0xFF) {
2585 throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
2586 }
2587 block = block << 8 | charCode;
2588 }
2589 return output;
2590 });
2591
2592 // decoder
2593 // [https://gist.github.com/1020396] by [https://github.com/atk]
2594 object.atob || (
2595 object.atob = function (input) {
2596 var str = String(input).replace(/[=]+$/, ''); // #31: ExtendScript bad parse of /=
2597 if (str.length % 4 == 1) {
2598 throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
2599 }
2600 for (
2601 // initialize result and counters
2602 var bc = 0, bs, buffer, idx = 0, output = '';
2603 // get next character
2604 buffer = str.charAt(idx++);
2605 // character found in table? initialize bit storage and add its ascii value;
2606 ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
2607 // and if not first of each 4 characters,
2608 // convert the first 8 bits to one ascii character
2609 bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
2610 ) {
2611 // try to find character in table (0-63, not found => -1)
2612 buffer = chars.indexOf(buffer);
2613 }
2614 return output;
2615 });
2616
2617}());
2618
2619// location.origin
2620try {
2621 Object.defineProperty(window.location, 'origin', {
2622 enumerable: true,
2623 writable: false,
2624 value: window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''),
2625 configurable: false
2626 });
2627} catch(e) {
2628
2629 // IE9 is throwing "Object doesn't support this action" when attempting defineProperty on window.location, so provide an alternative
2630 window.location.origin = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
2631}
2632
2633// performance.now
2634(function (global) {
2635
2636var
2637startTime = Date.now();
2638
2639if (!global.performance) {
2640 global.performance = {};
2641}
2642
2643global.performance.now = function () {
2644 return Date.now() - startTime;
2645};
2646
2647}(this));
2648
2649// requestAnimationFrame
2650(function (global) {
2651 var rafPrefix;
2652
2653 if ('mozRequestAnimationFrame' in global) {
2654 rafPrefix = 'moz';
2655
2656 } else if ('webkitRequestAnimationFrame' in global) {
2657 rafPrefix = 'webkit';
2658
2659 }
2660
2661 if (rafPrefix) {
2662 global.requestAnimationFrame = function (callback) {
2663 return global[rafPrefix + 'RequestAnimationFrame'](function () {
2664 callback(performance.now());
2665 });
2666 };
2667 global.cancelAnimationFrame = global[rafPrefix + 'CancelAnimationFrame'];
2668 } else {
2669
2670 var lastTime = Date.now();
2671
2672 global.requestAnimationFrame = function (callback) {
2673 if (typeof callback !== 'function') {
2674 throw new TypeError(callback + ' is not a function');
2675 }
2676
2677 var
2678 currentTime = Date.now(),
2679 delay = 16 + lastTime - currentTime;
2680
2681 if (delay < 0) {
2682 delay = 0;
2683 }
2684
2685 lastTime = currentTime;
2686
2687 return setTimeout(function () {
2688 lastTime = Date.now();
2689
2690 callback(performance.now());
2691 }, delay);
2692 };
2693
2694 global.cancelAnimationFrame = function (id) {
2695 clearTimeout(id);
2696 };
2697 }
2698}(this));
2699
2700// ~html5-elements
2701/**
2702* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
2703*/
2704!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3-pre",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document);})
2705.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});