Guest User

Untitled

a guest
Nov 23rd, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Polyfill service v3.27.0
  2.  * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
  3.  *
  4.  * Features requested: default
  5.  *
  6.  * - _ESAbstract.IsCallable, License: CC0 (required by "Array.from", "default", "Map", "Set", "_ESAbstract.GetMethod", "Array.prototype.forEach", "URL", "Symbol", "Symbol.iterator", "Function.prototype.bind", "_ESAbstract.Construct", "Array.of", "Object.getOwnPropertyDescriptor", "Object.assign", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith")
  7.  * - _ESAbstract.CreateMethodProperty, License: CC0 (required by "Array.from", "default", "Array.of", "Array.prototype.fill", "Map", "Number.isNaN", "Object.assign", "Set", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.indexOf", "Element.prototype.after", "Element.prototype.before", "Array.isArray", "URL", "Object.create", "_ESAbstract.GetIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Symbol", "Symbol.iterator", "Object.getOwnPropertyDescriptor", "Object.defineProperties", "Array.prototype.forEach", "Function.prototype.bind", "Object.getPrototypeOf", "Array.prototype.filter", "Array.prototype.map", "Object.getOwnPropertyNames", "Object.freeze")
  8.  * - _ESAbstract.ToObject, License: CC0 (required by "Array.from", "default", "Array.prototype.fill", "Object.assign", "Array.prototype.indexOf", "Element.prototype.after", "Element.prototype.before", "Object.defineProperties", "URL", "Object.create", "Map", "Set", "_ESAbstract.GetIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "Symbol", "Symbol.iterator", "Array.prototype.forEach", "_ESAbstract.GetV", "_ESAbstract.GetMethod", "Array.prototype.filter", "Array.prototype.map")
  9.  * - _ESAbstract.GetV, License: CC0 (required by "_ESAbstract.GetMethod", "Array.from", "default", "Map", "Set", "_ESAbstract.GetIterator")
  10.  * - _ESAbstract.GetMethod, License: CC0 (required by "Array.from", "default", "Map", "Set", "_ESAbstract.IsConstructor", "Array.of", "_ESAbstract.GetIterator", "_ESAbstract.IteratorClose", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith")
  11.  * - Symbol, License: MIT (required by "Map", "default", "Array.from", "Set", "Symbol.iterator", "Symbol.species")
  12.  * - Symbol.iterator, License: MIT (required by "Array.from", "default", "Map", "Set")
  13.  * - _ESAbstract.Type, License: CC0 (required by "Map", "default", "Array.from", "Number.isNaN", "_ESAbstract.IsConstructor", "Array.of", "_ESAbstract.GetIterator", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.ToString", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "_ESAbstract.IteratorValue", "_ESAbstract.CreateIterResultObject", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "_ESAbstract.IteratorNext", "_ESAbstract.SameValueZero", "Object.create", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Symbol", "Symbol.iterator", "_ESAbstract.IsRegExp", "Object.defineProperties", "URL", "_ESAbstract.ToPrimitive", "_ESAbstract.GetPrototypeFromConstructor", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map")
  14.  * - _ESAbstract.IsConstructor, License: CC0 (required by "Array.from", "default", "Array.of", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.iterator", "Array.prototype.map")
  15.  * - _ESAbstract.Get, License: CC0 (required by "Array.from", "default", "Array.prototype.fill", "Object.assign", "_ESAbstract.IteratorValue", "Map", "Set", "Array.prototype.indexOf", "Element.prototype.after", "Element.prototype.before", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Object.defineProperties", "URL", "Object.create", "_ESAbstract.GetIterator", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "Symbol", "Symbol.iterator", "Array.prototype.forEach", "_ESAbstract.GetPrototypeFromConstructor", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "_ESAbstract.ArraySpeciesCreate")
  16.  * - _ESAbstract.GetPrototypeFromConstructor, License: CC0 (required by "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "default", "Array.from", "Set", "_ESAbstract.Construct", "Array.of")
  17.  * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "Map", "default", "Array.from", "Set", "_ESAbstract.Construct", "Array.of")
  18.  * - _ESAbstract.Construct, License: CC0 (required by "Array.from", "default", "Array.of", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.iterator", "Array.prototype.map")
  19.  * - _ESAbstract.ArrayCreate, License: CC0 (required by "Array.from", "default", "Array.of", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.iterator", "Array.prototype.map")
  20.  * - _ESAbstract.Call, License: CC0 (required by "Array.from", "default", "_ESAbstract.GetIterator", "Map", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.IteratorNext", "_ESAbstract.IteratorStep", "Array.prototype.forEach", "URL", "Symbol", "Symbol.iterator", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.of", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.OrdinaryToPrimitive")
  21.  * - _ESAbstract.GetIterator, License: CC0 (required by "Array.from", "default", "Map", "Set")
  22.  * - _ESAbstract.IteratorClose, License: CC0 (required by "Array.from", "default", "Map", "Set")
  23.  * - _ESAbstract.OrdinaryToPrimitive, License: CC0 (required by "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.from", "default", "Array.of", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith")
  24.  * - _ESAbstract.ToPrimitive, License: CC0 (required by "_ESAbstract.ToString", "Array.from", "default", "Array.of", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith")
  25.  * - _ESAbstract.ToString, License: CC0 (required by "Array.from", "default", "Array.of", "Array.prototype.fill", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.indexOf", "Element.prototype.after", "Element.prototype.before", "Array.prototype.forEach", "URL", "Symbol", "Map", "Set", "Symbol.iterator", "Array.prototype.filter", "Array.prototype.map")
  26.  * - _ESAbstract.IteratorNext, License: CC0 (required by "Map", "default", "Array.from", "Set", "_ESAbstract.IteratorStep")
  27.  * - _ESAbstract.ToBoolean, License: CC0 (required by "_ESAbstract.IteratorComplete", "Map", "default", "Array.from", "Set", "_ESAbstract.IteratorStep", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.filter", "Symbol", "Symbol.iterator")
  28.  * - _ESAbstract.IteratorComplete, License: CC0 (required by "Map", "default", "Array.from", "Set", "_ESAbstract.IteratorStep")
  29.  * - _ESAbstract.IteratorStep, License: CC0 (required by "Array.from", "default", "Map", "Set")
  30.  * - _ESAbstract.IteratorValue, License: CC0 (required by "Array.from", "default", "Map", "Set")
  31.  * - _ESAbstract.CreateDataProperty, License: CC0 (required by "_ESAbstract.CreateDataPropertyOrThrow", "Array.from", "default", "Array.of", "_ESAbstract.CreateIterResultObject", "Map", "Set")
  32.  * - _ESAbstract.CreateDataPropertyOrThrow, License: CC0 (required by "Array.from", "default", "Array.of", "Array.prototype.filter", "Symbol", "Map", "Set", "Symbol.iterator", "Array.prototype.map")
  33.  * - _ESAbstract.ToInteger, License: CC0 (required by "Array.prototype.fill", "default", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "_ESAbstract.ToLength", "Array.from", "Array.prototype.indexOf", "Element.prototype.after", "Element.prototype.before")
  34.  * - _ESAbstract.ToLength, License: CC0 (required by "Array.from", "default", "Array.prototype.fill", "Array.prototype.indexOf", "Element.prototype.after", "Element.prototype.before", "Array.prototype.forEach", "URL", "Symbol", "Map", "Set", "Symbol.iterator", "Array.prototype.filter", "Array.prototype.map")
  35.  * - _ESAbstract.CreateIterResultObject, License: CC0 (required by "Map", "default", "Array.from", "Set")
  36.  * - _ESAbstract.SameValueNonNumber, License: CC0 (required by "_ESAbstract.SameValueZero", "Map", "default", "Array.from", "Set")
  37.  * - _ESAbstract.SameValueZero, License: CC0 (required by "Map", "default", "Array.from", "Set")
  38.  * - Symbol.species, License: MIT (required by "Map", "default", "Array.from", "Set")
  39.  * - Map, License: CC0 (required by "default", "Array.from")
  40.  * - Set, License: CC0 (required by "default", "Array.from")
  41.  * - Array.from, License: CC0 (required by "default")
  42.  * - Array.of, License: CC0 (required by "default")
  43.  * - Array.prototype.fill, License: CC0 (required by "default")
  44.  * - Event, License: CC0 (required by "default", "CustomEvent")
  45.  * - CustomEvent, License: CC0 (required by "default")
  46.  * - _DOMTokenList, License: ISC (required by "DOMTokenList", "default")
  47.  * - DOMTokenList, License: CC0 (required by "default", "Element.prototype.classList")
  48.  * - _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")
  49.  * - DocumentFragment.prototype.append, License: CC0 (required by "default")
  50.  * - DocumentFragment.prototype.prepend, License: CC0 (required by "default")
  51.  * - Element.prototype.after, License: CC0 (required by "default")
  52.  * - Element.prototype.append, License: CC0 (required by "default")
  53.  * - Element.prototype.before, License: CC0 (required by "default")
  54.  * - Element.prototype.classList, License: ISC (required by "default")
  55.  * - Element.prototype.matches, License: CC0 (required by "default", "Element.prototype.closest")
  56.  * - Element.prototype.closest, License: CC0 (required by "default")
  57.  * - Element.prototype.prepend, License: CC0 (required by "default")
  58.  * - Element.prototype.remove, License: CC0 (required by "default")
  59.  * - Element.prototype.replaceWith, License: CC0 (required by "default")
  60.  * - Node.prototype.contains, License: CC0 (required by "default")
  61.  * - Number.isNaN, License: MIT (required by "default")
  62.  * - Object.assign, License: CC0 (required by "default")
  63.  * - Promise, License: MIT (required by "default")
  64.  * - _ESAbstract.RequireObjectCoercible, License: CC0 (required by "String.prototype.endsWith", "default", "String.prototype.includes", "String.prototype.startsWith")
  65.  * - _ESAbstract.IsRegExp, License: CC0 (required by "String.prototype.endsWith", "default", "String.prototype.includes", "String.prototype.startsWith")
  66.  * - String.prototype.endsWith, License: CC0 (required by "default")
  67.  * - String.prototype.includes, License: CC0 (required by "default")
  68.  * - String.prototype.startsWith, License: CC0 (required by "default")
  69.  * - URL, License: CC0 (required by "default") */
  70.  
  71. (function(undefined) {
  72.  
  73. // _ESAbstract.IsCallable
  74. // 7.2.3. IsCallable ( argument )
  75. function IsCallable(argument) { // eslint-disable-line no-unused-vars
  76.     // 1. If Type(argument) is not Object, return false.
  77.     // 2. If argument has a [[Call]] internal method, return true.
  78.     // 3. Return false.
  79.  
  80.     // Polyfill.io - Only function objects have a [[Call]] internal method. This means we can simplify this function to check that the argument has a type of function.
  81.     return typeof argument === 'function';
  82. }
  83.  
  84. // _ESAbstract.CreateMethodProperty
  85. // 7.3.5. CreateMethodProperty ( O, P, V )
  86. function CreateMethodProperty(O, P, V) { // eslint-disable-line no-unused-vars
  87.     // 1. Assert: Type(O) is Object.
  88.     // 2. Assert: IsPropertyKey(P) is true.
  89.     // 3. Let newDesc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}.
  90.     var newDesc = {
  91.         value: V,
  92.         writable: true,
  93.         enumerable: false,
  94.         configurable: true
  95.     };
  96.     // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
  97.     Object.defineProperty(O, P, newDesc);
  98. }
  99.  
  100. // _ESAbstract.ToObject
  101. // 7.1.13 ToObject ( argument )
  102. // The abstract operation ToObject converts argument to a value of type Object according to Table 12:
  103. // Table 12: ToObject Conversions
  104. /*
  105. |----------------------------------------------------------------------------------------------------------------------------------------------------|
  106. | Argument Type | Result                                                                                                                             |
  107. |----------------------------------------------------------------------------------------------------------------------------------------------------|
  108. | Undefined     | Throw a TypeError exception.                                                                                                       |
  109. | Null          | Throw a TypeError exception.                                                                                                       |
  110. | Boolean       | Return a new Boolean object whose [[BooleanData]] internal slot is set to argument. See 19.3 for a description of Boolean objects. |
  111. | Number        | Return a new Number object whose [[NumberData]] internal slot is set to argument. See 20.1 for a description of Number objects.    |
  112. | String        | Return a new String object whose [[StringData]] internal slot is set to argument. See 21.1 for a description of String objects.    |
  113. | Symbol        | Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 19.4 for a description of Symbol objects.    |
  114. | Object        | Return argument.                                                                                                                   |
  115. |----------------------------------------------------------------------------------------------------------------------------------------------------|
  116. */
  117. function ToObject(argument) { // eslint-disable-line no-unused-vars
  118.     if (argument === null || argument === undefined) {
  119.         throw TypeError();
  120.     }
  121.   return Object(argument);
  122. }
  123.  
  124. // _ESAbstract.GetV
  125. /* global ToObject */
  126. // 7.3.2 GetV (V, P)
  127. function GetV(v, p) { // eslint-disable-line no-unused-vars
  128.     // 1. Assert: IsPropertyKey(P) is true.
  129.     // 2. Let O be ? ToObject(V).
  130.     var o = ToObject(v);
  131.     // 3. Return ? O.[[Get]](P, V).
  132.     return o[p];
  133. }
  134.  
  135. // _ESAbstract.GetMethod
  136. /* global GetV, IsCallable */
  137. // 7.3.9. GetMethod ( V, P )
  138. function GetMethod(V, P) { // eslint-disable-line no-unused-vars
  139.     // 1. Assert: IsPropertyKey(P) is true.
  140.     // 2. Let func be ? GetV(V, P).
  141.     var func = GetV(V, P);
  142.     // 3. If func is either undefined or null, return undefined.
  143.     if (func === null || func === undefined) {
  144.         return undefined;
  145.     }
  146.     // 4. If IsCallable(func) is false, throw a TypeError exception.
  147.     if (IsCallable(func) === false) {
  148.         throw new TypeError('Method not callable: ' + P);
  149.     }
  150.     // 5. Return func.
  151.     return func;
  152. }
  153.  
  154. // Symbol
  155. // A modification of https://github.com/WebReflection/get-own-property-symbols
  156. // (C) Andrea Giammarchi - MIT Licensed
  157.  
  158. (function (Object, GOPS, global) {
  159.  
  160.     var setDescriptor;
  161.     var id = 0;
  162.     var random = '' + Math.random();
  163.     var prefix = '__\x01symbol:';
  164.     var prefixLength = prefix.length;
  165.     var internalSymbol = '__\x01symbol@@' + random;
  166.     var DP = 'defineProperty';
  167.     var DPies = 'defineProperties';
  168.     var GOPN = 'getOwnPropertyNames';
  169.     var GOPD = 'getOwnPropertyDescriptor';
  170.     var PIE = 'propertyIsEnumerable';
  171.     var ObjectProto = Object.prototype;
  172.     var hOP = ObjectProto.hasOwnProperty;
  173.     var pIE = ObjectProto[PIE];
  174.     var toString = ObjectProto.toString;
  175.     var concat = Array.prototype.concat;
  176.     var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : [];
  177.     var nGOPN = Object[GOPN];
  178.     var gOPN = function getOwnPropertyNames (obj) {
  179.         if (toString.call(obj) === '[object Window]') {
  180.             try {
  181.                 return nGOPN(obj);
  182.             } catch (e) {
  183.                 // IE bug where layout engine calls userland gOPN for cross-domain `window` objects
  184.                 return concat.call([], cachedWindowNames);
  185.             }
  186.         }
  187.         return nGOPN(obj);
  188.     };
  189.     var gOPD = Object[GOPD];
  190.     var create = Object.create;
  191.     var keys = Object.keys;
  192.     var freeze = Object.freeze || Object;
  193.     var defineProperty = Object[DP];
  194.     var $defineProperties = Object[DPies];
  195.     var descriptor = gOPD(Object, GOPN);
  196.     var addInternalIfNeeded = function (o, uid, enumerable) {
  197.         if (!hOP.call(o, internalSymbol)) {
  198.             try {
  199.                 defineProperty(o, internalSymbol, {
  200.                     enumerable: false,
  201.                     configurable: false,
  202.                     writable: false,
  203.                     value: {}
  204.                 });
  205.             } catch (e) {
  206.                 o[internalSymbol] = {};
  207.             }
  208.         }
  209.         o[internalSymbol]['@@' + uid] = enumerable;
  210.     };
  211.     var createWithSymbols = function (proto, descriptors) {
  212.         var self = create(proto);
  213.         gOPN(descriptors).forEach(function (key) {
  214.             if (propertyIsEnumerable.call(descriptors, key)) {
  215.                 $defineProperty(self, key, descriptors[key]);
  216.             }
  217.         });
  218.         return self;
  219.     };
  220.     var copyAsNonEnumerable = function (descriptor) {
  221.         var newDescriptor = create(descriptor);
  222.         newDescriptor.enumerable = false;
  223.         return newDescriptor;
  224.     };
  225.     var get = function get(){};
  226.     var onlyNonSymbols = function (name) {
  227.         return name != internalSymbol &&
  228.             !hOP.call(source, name);
  229.     };
  230.     var onlySymbols = function (name) {
  231.         return name != internalSymbol &&
  232.             hOP.call(source, name);
  233.     };
  234.     var propertyIsEnumerable = function propertyIsEnumerable(key) {
  235.         var uid = '' + key;
  236.         return onlySymbols(uid) ? (
  237.             hOP.call(this, uid) &&
  238.             this[internalSymbol]['@@' + uid]
  239.         ) : pIE.call(this, key);
  240.     };
  241.     var setAndGetSymbol = function (uid) {
  242.         var descriptor = {
  243.             enumerable: false,
  244.             configurable: true,
  245.             get: get,
  246.             set: function (value) {
  247.             setDescriptor(this, uid, {
  248.                 enumerable: false,
  249.                 configurable: true,
  250.                 writable: true,
  251.                 value: value
  252.             });
  253.             addInternalIfNeeded(this, uid, true);
  254.             }
  255.         };
  256.         try {
  257.             defineProperty(ObjectProto, uid, descriptor);
  258.         } catch (e) {
  259.             ObjectProto[uid] = descriptor.value;
  260.         }
  261.         return freeze(source[uid] = defineProperty(
  262.             Object(uid),
  263.             'constructor',
  264.             sourceConstructor
  265.         ));
  266.     };
  267.     var Symbol = function Symbol() {
  268.         var description = arguments[0];
  269.         if (this instanceof Symbol) {
  270.             throw new TypeError('Symbol is not a constructor');
  271.         }
  272.         return setAndGetSymbol(
  273.             prefix.concat(description || '', random, ++id)
  274.         );
  275.         };
  276.     var source = create(null);
  277.     var sourceConstructor = {value: Symbol};
  278.     var sourceMap = function (uid) {
  279.         return source[uid];
  280.         };
  281.     var $defineProperty = function defineProp(o, key, descriptor) {
  282.         var uid = '' + key;
  283.         if (onlySymbols(uid)) {
  284.             setDescriptor(o, uid, descriptor.enumerable ?
  285.                 copyAsNonEnumerable(descriptor) : descriptor);
  286.             addInternalIfNeeded(o, uid, !!descriptor.enumerable);
  287.         } else {
  288.             defineProperty(o, key, descriptor);
  289.         }
  290.         return o;
  291.     };
  292.  
  293.     var onlyInternalSymbols = function (obj) {
  294.         return function (name) {
  295.             return hOP.call(obj, internalSymbol) && hOP.call(obj[internalSymbol], '@@' + name);
  296.         };
  297.     };
  298.     var $getOwnPropertySymbols = function getOwnPropertySymbols(o) {
  299.         return gOPN(o).filter(o === ObjectProto ? onlyInternalSymbols(o) : onlySymbols).map(sourceMap);
  300.         }
  301.     ;
  302.  
  303.     descriptor.value = $defineProperty;
  304.     defineProperty(Object, DP, descriptor);
  305.  
  306.     descriptor.value = $getOwnPropertySymbols;
  307.     defineProperty(Object, GOPS, descriptor);
  308.  
  309.     descriptor.value = function getOwnPropertyNames(o) {
  310.         return gOPN(o).filter(onlyNonSymbols);
  311.     };
  312.     defineProperty(Object, GOPN, descriptor);
  313.  
  314.     descriptor.value = function defineProperties(o, descriptors) {
  315.         var symbols = $getOwnPropertySymbols(descriptors);
  316.         if (symbols.length) {
  317.         keys(descriptors).concat(symbols).forEach(function (uid) {
  318.             if (propertyIsEnumerable.call(descriptors, uid)) {
  319.             $defineProperty(o, uid, descriptors[uid]);
  320.             }
  321.         });
  322.         } else {
  323.         $defineProperties(o, descriptors);
  324.         }
  325.         return o;
  326.     };
  327.     defineProperty(Object, DPies, descriptor);
  328.  
  329.     descriptor.value = propertyIsEnumerable;
  330.     defineProperty(ObjectProto, PIE, descriptor);
  331.  
  332.     descriptor.value = Symbol;
  333.     defineProperty(global, 'Symbol', descriptor);
  334.  
  335.     // defining `Symbol.for(key)`
  336.     descriptor.value = function (key) {
  337.         var uid = prefix.concat(prefix, key, random);
  338.         return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid);
  339.     };
  340.     defineProperty(Symbol, 'for', descriptor);
  341.  
  342.     // defining `Symbol.keyFor(symbol)`
  343.     descriptor.value = function (symbol) {
  344.         if (onlyNonSymbols(symbol))
  345.         throw new TypeError(symbol + ' is not a symbol');
  346.         return hOP.call(source, symbol) ?
  347.         symbol.slice(prefixLength * 2, -random.length) :
  348.         void 0
  349.         ;
  350.     };
  351.     defineProperty(Symbol, 'keyFor', descriptor);
  352.  
  353.     descriptor.value = function getOwnPropertyDescriptor(o, key) {
  354.         var descriptor = gOPD(o, key);
  355.         if (descriptor && onlySymbols(key)) {
  356.         descriptor.enumerable = propertyIsEnumerable.call(o, key);
  357.         }
  358.         return descriptor;
  359.     };
  360.     defineProperty(Object, GOPD, descriptor);
  361.  
  362.     descriptor.value = function (proto, descriptors) {
  363.         return arguments.length === 1 || typeof descriptors === "undefined" ?
  364.         create(proto) :
  365.         createWithSymbols(proto, descriptors);
  366.     };
  367.     defineProperty(Object, 'create', descriptor);
  368.  
  369.     descriptor.value = function () {
  370.         var str = toString.call(this);
  371.         return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
  372.     };
  373.     defineProperty(ObjectProto, 'toString', descriptor);
  374.  
  375.  
  376.     setDescriptor = function (o, key, descriptor) {
  377.         var protoDescriptor = gOPD(ObjectProto, key);
  378.         delete ObjectProto[key];
  379.         defineProperty(o, key, descriptor);
  380.         if (o !== ObjectProto) {
  381.             defineProperty(ObjectProto, key, protoDescriptor);
  382.         }
  383.     };
  384.  
  385. }(Object, 'getOwnPropertySymbols', this));
  386.  
  387. // Symbol.iterator
  388. /* global Symbol */
  389. Object.defineProperty(Symbol, 'iterator', { value: Symbol('iterator') });
  390.  
  391. // _ESAbstract.Type
  392. // "Type(x)" is used as shorthand for "the type of x"...
  393. function Type(x) { // eslint-disable-line no-unused-vars
  394.     switch (typeof x) {
  395.         case 'undefined':
  396.             return 'undefined';
  397.         case 'boolean':
  398.             return 'boolean';
  399.         case 'number':
  400.             return 'number';
  401.         case 'string':
  402.             return 'string';
  403.         case 'symbol':
  404.             return 'symbol';
  405.         default:
  406.             // typeof null is 'object'
  407.             if (x === null) return 'null';
  408.             // Polyfill.io - This is here because a Symbol polyfill will have a typeof `object`.
  409.             if ('Symbol' in this && x instanceof this.Symbol) return 'symbol';
  410.             return 'object';
  411.     }
  412. }
  413.  
  414. // _ESAbstract.IsConstructor
  415. /* global Type */
  416. // 7.2.4. IsConstructor ( argument )
  417. function IsConstructor(argument) { // eslint-disable-line no-unused-vars
  418.     // 1. If Type(argument) is not Object, return false.
  419.     if (Type(argument) !== 'object') {
  420.         return false;
  421.     }
  422.     // 2. If argument has a [[Construct]] internal method, return true.
  423.     // 3. Return false.
  424.  
  425.     // Polyfill.io - `new argument` is the only way  to truly test if a function is a constructor.
  426.     // We choose to not use`new argument` because the argument could have side effects when called.
  427.     // Instead we check to see if the argument is a function and if it has a prototype.
  428.     // Arrow functions do not have a [[Construct]] internal method, nor do they have a prototype.
  429.     return typeof argument === 'function' && !!argument.prototype;
  430. }
  431.  
  432. // _ESAbstract.Get
  433. // 7.3.1. Get ( O, P )
  434. function Get(O, P) { // eslint-disable-line no-unused-vars
  435.     // 1. Assert: Type(O) is Object.
  436.     // 2. Assert: IsPropertyKey(P) is true.
  437.     // 3. Return ? O.[[Get]](P, O).
  438.     return O[P];
  439. }
  440.  
  441. // _ESAbstract.GetPrototypeFromConstructor
  442. /* global Get, Type */
  443. // 9.1.14. GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
  444. function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
  445.     // 1. Assert: intrinsicDefaultProto is a String value that is this specification's name of an intrinsic object. The corresponding object must be an intrinsic that is intended to be used as the [[Prototype]] value of an object.
  446.     // 2. Assert: IsCallable(constructor) is true.
  447.     // 3. Let proto be ? Get(constructor, "prototype").
  448.     var proto = Get(constructor, "prototype");
  449.     // 4. If Type(proto) is not Object, then
  450.     if (Type(proto) !== 'object') {
  451.         // a. Let realm be ? GetFunctionRealm(constructor).
  452.         // b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
  453.         proto = intrinsicDefaultProto;
  454.     }
  455.     // 5. Return proto.
  456.     return proto;
  457. }
  458.  
  459. // _ESAbstract.OrdinaryCreateFromConstructor
  460. /* global GetPrototypeFromConstructor */
  461. // 9.1.13. OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
  462. function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
  463.     var internalSlotsList = arguments[2] || {};
  464.     // 1. Assert: intrinsicDefaultProto is a String value that is this specification's name of an intrinsic object.
  465.     // The corresponding object must be an intrinsic that is intended to be used as the[[Prototype]] value of an object.
  466.  
  467.     // 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
  468.     var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto);
  469.  
  470.     // 3. Return ObjectCreate(proto, internalSlotsList).
  471.     // Polyfill.io - We do not pass internalSlotsList to Object.create because Object.create does not use the default ordinary object definitions specified in 9.1.
  472.     var obj = Object.create(proto);
  473.     for (var name in internalSlotsList) {
  474.         if (Object.prototype.hasOwnProperty.call(internalSlotsList, name)) {
  475.             Object.defineProperty(obj, name, {
  476.                 configurable: true,
  477.                 enumerable: false,
  478.                 writable: true,
  479.                 value: internalSlotsList[name]
  480.             });
  481.         }
  482.     }
  483.     return obj;
  484. }
  485.  
  486. // _ESAbstract.Construct
  487. /* global IsConstructor, OrdinaryCreateFromConstructor, Call */
  488. // 7.3.13. Construct ( F [ , argumentsList [ , newTarget ]] )
  489. function Construct(F /* [ , argumentsList [ , newTarget ]] */) { // eslint-disable-line no-unused-vars
  490.     // 1. If newTarget is not present, set newTarget to F.
  491.     var newTarget = arguments.length > 2 ? arguments[2] : F;
  492.  
  493.     // 2. If argumentsList is not present, set argumentsList to a new empty List.
  494.     var argumentsList = arguments.length > 1 ? arguments[1] : [];
  495.  
  496.     // 3. Assert: IsConstructor(F) is true.
  497.     if (!IsConstructor(F)) {
  498.         throw new TypeError('F must be a constructor.');
  499.     }
  500.  
  501.     // 4. Assert: IsConstructor(newTarget) is true.
  502.     if (!IsConstructor(newTarget)) {
  503.         throw new TypeError('newTarget must be a constructor.');
  504.     }
  505.  
  506.     // 5. Return ? F.[[Construct]](argumentsList, newTarget).
  507.     // Polyfill.io - If newTarget is the same as F, it is equivalent to new F(...argumentsList).
  508.     if (newTarget === F) {
  509.         return new (Function.prototype.bind.apply(F, [null].concat(argumentsList)))();
  510.     } else {
  511.         // Polyfill.io - This is mimicking section 9.2.2 step 5.a.
  512.         var obj = OrdinaryCreateFromConstructor(newTarget, Object.prototype);
  513.         return Call(F, obj, argumentsList);
  514.     }
  515. }
  516.  
  517. // _ESAbstract.ArrayCreate
  518. // 9.4.2.2. ArrayCreate ( length [ , proto ] )
  519. function ArrayCreate(length /* [, proto] */) { // eslint-disable-line no-unused-vars
  520.     // 1. Assert: length is an integer Number β‰₯ 0.
  521.     // 2. If length is -0, set length to +0.
  522.     if (1 / length === -Infinity) {
  523.         length = 0;
  524.     }
  525.     // 3. If length>2^32-1, throw a RangeError exception.
  526.     if (length > (Math.pow(2, 32) - 1)) {
  527.         throw new RangeError('Invalid array length');
  528.     }
  529.     // 4. If proto is not present, set proto to the intrinsic object %ArrayPrototype%.
  530.     // 5. Let A be a newly created Array exotic object.
  531.     var A = [];
  532.     // 6. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.
  533.     // 7. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1.
  534.     // 8. Set A.[[Prototype]] to proto.
  535.     // 9. Set A.[[Extensible]] to true.
  536.     // 10. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
  537.     A.length = length;
  538.     // 11. Return A.
  539.     return A;
  540. }
  541.  
  542. // _ESAbstract.Call
  543. /* global IsCallable */
  544. // 7.3.12. Call ( F, V [ , argumentsList ] )
  545. function Call(F, V /* [, argumentsList] */) { // eslint-disable-line no-unused-vars
  546.     // 1. If argumentsList is not present, set argumentsList to a new empty List.
  547.     var argumentsList = arguments.length > 2 ? arguments[2] : [];
  548.     // 2. If IsCallable(F) is false, throw a TypeError exception.
  549.     if (IsCallable(F) === false) {
  550.         throw new TypeError(Object.prototype.toString.call(F) + 'is not a function.');
  551.     }
  552.     // 3. Return ? F.[[Call]](V, argumentsList).
  553.     return F.apply(V, argumentsList);
  554. }
  555.  
  556. // _ESAbstract.GetIterator
  557. /* global GetMethod, Symbol, Call, Type, GetV */
  558. // 7.4.1. GetIterator ( obj [ , method ] )
  559. // The abstract operation GetIterator with argument obj and optional argument method performs the following steps:
  560. function GetIterator(obj /*, method */) { // eslint-disable-line no-unused-vars
  561.     // 1. If method is not present, then
  562.         // a. Set method to ? GetMethod(obj, @@iterator).
  563.     var method = arguments.length > 1 ? arguments[1] : GetMethod(obj, Symbol.iterator);
  564.     // 2. Let iterator be ? Call(method, obj).
  565.     var iterator = Call(method, obj);
  566.     // 3. If Type(iterator) is not Object, throw a TypeError exception.
  567.     if (Type(iterator) !== 'object') {
  568.         throw new TypeError('bad iterator');
  569.     }
  570.     // 4. Let nextMethod be ? GetV(iterator, "next").
  571.     var nextMethod = GetV(iterator, "next");
  572.     // 5. Let iteratorRecord be Record {[[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false}.
  573.     var iteratorRecord = Object.create(null);
  574.     iteratorRecord['[[Iterator]]'] = iterator;
  575.     iteratorRecord['[[NextMethod]]'] = nextMethod;
  576.     iteratorRecord['[[Done]]'] = false;
  577.     // 6. Return iteratorRecord.
  578.     return iteratorRecord;
  579. }
  580.  
  581. // _ESAbstract.IteratorClose
  582. /* global GetMethod, Type, Call */
  583. // 7.4.6. IteratorClose ( iteratorRecord, completion )
  584. function IteratorClose(iteratorRecord, completion) { // eslint-disable-line no-unused-vars
  585.     // 1. Assert: Type(iteratorRecord.[[Iterator]]) is Object.
  586.     if (Type(iteratorRecord['[[Iterator]]']) !== 'object') {
  587.         throw new Error(Object.prototype.toString.call(iteratorRecord['[[Iterator]]']) + 'is not an Object.');
  588.     }
  589.     // 2. Assert: completion is a Completion Record.
  590.     // Polyfill.io - Ignoring this step as there is no way to check if something is a Completion Record in userland JavaScript.
  591.  
  592.     // 3. Let iterator be iteratorRecord.[[Iterator]].
  593.     var iterator = iteratorRecord['[[Iterator]]'];
  594.     // 4. Let return be ? GetMethod(iterator, "return").
  595.     // Polyfill.io - We name it  returnMethod because return is a keyword and can not be used as an identifier (E.G. variable name, function name etc).
  596.     var returnMethod = GetMethod(iterator, "return");
  597.     // 5. If return is undefined, return Completion(completion).
  598.     if (returnMethod === undefined) {
  599.         return completion;
  600.     }
  601.     // 6. Let innerResult be Call(return, iterator, Β« Β»).
  602.     try {
  603.         var innerResult = Call(returnMethod, iterator);
  604.     } catch (error) {
  605.         var innerException = error;
  606.     }
  607.     // 7. If completion.[[Type]] is throw, return Completion(completion).
  608.     if (completion) {
  609.         return completion;
  610.     }
  611.     // 8. If innerResult.[[Type]] is throw, return Completion(innerResult).
  612.     if (innerException) {
  613.         throw innerException;
  614.     }
  615.     // 9. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
  616.     if (Type(innerResult) !== 'object') {
  617.         throw new TypeError("Iterator's return method returned a non-object.");
  618.     }
  619.     // 10. Return Completion(completion).
  620.     return completion;
  621. }
  622.  
  623. // _ESAbstract.OrdinaryToPrimitive
  624. /* global Get, IsCallable, Call, Type */
  625. // 7.1.1.1. OrdinaryToPrimitive ( O, hint )
  626. function OrdinaryToPrimitive(O, hint) { // eslint-disable-line no-unused-vars
  627.     // 1. Assert: Type(O) is Object.
  628.     // 2. Assert: Type(hint) is String and its value is either "string" or "number".
  629.     // 3. If hint is "string", then
  630.     if (hint === 'string') {
  631.         // a. Let methodNames be Β« "toString", "valueOf" Β».
  632.         var methodNames = ['toString', 'valueOf'];
  633.         // 4. Else,
  634.     } else {
  635.         // a. Let methodNames be Β« "valueOf", "toString" Β».
  636.         methodNames = ['valueOf', 'toString'];
  637.     }
  638.     // 5. For each name in methodNames in List order, do
  639.     for (var i = 0; i < methodNames.length; ++i) {
  640.         var name = methodNames[i];
  641.         // a. Let method be ? Get(O, name).
  642.         var method = Get(O, name);
  643.         // b. If IsCallable(method) is true, then
  644.         if (IsCallable(method)) {
  645.             // i. Let result be ? Call(method, O).
  646.             var result = Call(method, O);
  647.             // ii. If Type(result) is not Object, return result.
  648.             if (Type(result) !== 'object') {
  649.                 return result;
  650.             }
  651.         }
  652.     }
  653.     // 6. Throw a TypeError exception.
  654.     throw new TypeError('Cannot convert to primitive.');
  655. }
  656.  
  657. // _ESAbstract.ToPrimitive
  658. /* global Type, GetMethod, Call, OrdinaryToPrimitive */
  659. // 7.1.1. ToPrimitive ( input [ , PreferredType ] )
  660. function ToPrimitive(input /* [, PreferredType] */) { // eslint-disable-line no-unused-vars
  661.     var PreferredType = arguments.length > 1 ? arguments[1] : undefined;
  662.     // 1. Assert: input is an ECMAScript language value.
  663.     // 2. If Type(input) is Object, then
  664.     if (Type(input) === 'object') {
  665.         // a. If PreferredType is not present, let hint be "default".
  666.         if (arguments.length < 2) {
  667.             var hint = 'default';
  668.             // b. Else if PreferredType is hint String, let hint be "string".
  669.         } else if (PreferredType === String) {
  670.             hint = 'string';
  671.             // c. Else PreferredType is hint Number, let hint be "number".
  672.         } else if (PreferredType === Number) {
  673.             hint = 'number';
  674.         }
  675.         // d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
  676.         var exoticToPrim = typeof this.Symbol === 'function' && typeof this.Symbol.toPrimitive === 'symbol' ? GetMethod(input, this.Symbol.toPrimitive) : undefined;
  677.         // e. If exoticToPrim is not undefined, then
  678.         if (exoticToPrim !== undefined) {
  679.             // i. Let result be ? Call(exoticToPrim, input, Β« hint Β»).
  680.             var result = Call(exoticToPrim, input, [hint]);
  681.             // ii. If Type(result) is not Object, return result.
  682.             if (Type(result) !== 'object') {
  683.                 return result;
  684.             }
  685.             // iii. Throw a TypeError exception.
  686.             throw new TypeError('Cannot convert exotic object to primitive.');
  687.         }
  688.         // f. If hint is "default", set hint to "number".
  689.         if (hint === 'default') {
  690.             hint = 'number';
  691.         }
  692.         // g. Return ? OrdinaryToPrimitive(input, hint).
  693.         return OrdinaryToPrimitive(input, hint);
  694.     }
  695.     // 3. Return input
  696.     return input;
  697. }
  698.  
  699. // _ESAbstract.ToString
  700. /* global Type, ToPrimitive */
  701. // 7.1.12. ToString ( argument )
  702. // The abstract operation ToString converts argument to a value of type String according to Table 11:
  703. // Table 11: ToString Conversions
  704. /*
  705. |---------------|--------------------------------------------------------|
  706. | Argument Type | Result                                                 |
  707. |---------------|--------------------------------------------------------|
  708. | Undefined     | Return "undefined".                                    |
  709. |---------------|--------------------------------------------------------|
  710. | Null          | Return "null".                                         |
  711. |---------------|--------------------------------------------------------|
  712. | Boolean       | If argument is true, return "true".                    |
  713. |               | If argument is false, return "false".                  |
  714. |---------------|--------------------------------------------------------|
  715. | Number        | Return NumberToString(argument).                       |
  716. |---------------|--------------------------------------------------------|
  717. | String        | Return argument.                                       |
  718. |---------------|--------------------------------------------------------|
  719. | Symbol        | Throw a TypeError exception.                           |
  720. |---------------|--------------------------------------------------------|
  721. | Object        | Apply the following steps:                             |
  722. |               | Let primValue be ? ToPrimitive(argument, hint String). |
  723. |               | Return ? ToString(primValue).                          |
  724. |---------------|--------------------------------------------------------|
  725. */
  726. function ToString(argument) { // eslint-disable-line no-unused-vars
  727.     switch(Type(argument)) {
  728.         case 'symbol':
  729.             throw new TypeError('Cannot convert a Symbol value to a string');
  730.             break;
  731.         case 'object':
  732.             var primValue = ToPrimitive(argument, 'string');
  733.             return ToString(primValue);
  734.         default:
  735.             return String(argument);
  736.     }
  737. }
  738.  
  739. // _ESAbstract.IteratorNext
  740. /* global Call, Type */
  741. // 7.4.2. IteratorNext ( iteratorRecord [ , value ] )
  742. function IteratorNext(iteratorRecord /* [, value] */) { // eslint-disable-line no-unused-vars
  743.     // 1. If value is not present, then
  744.     if (arguments.length < 2) {
  745.         // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], Β« Β»).
  746.         var result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']);
  747.     // 2. Else,
  748.     } else {
  749.         // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], Β« value Β»).
  750.         result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]);
  751.     }
  752.     // 3. If Type(result) is not Object, throw a TypeError exception.
  753.     if (Type(result) !== 'object') {
  754.         throw new TypeError('bad iterator');
  755.     }
  756.     // 4. Return result.
  757.     return result;
  758. }
  759.  
  760. // _ESAbstract.ToBoolean
  761. // 7.1.2. ToBoolean ( argument )
  762. // The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 9:
  763. /*
  764. --------------------------------------------------------------------------------------------------------------
  765. | Argument Type | Result                                                                                     |
  766. --------------------------------------------------------------------------------------------------------------
  767. | Undefined     | Return false.                                                                              |
  768. | Null          | Return false.                                                                              |
  769. | Boolean       | Return argument.                                                                           |
  770. | Number        | If argument is +0, -0, or NaN, return false; otherwise return true.                        |
  771. | String        | If argument is the empty String (its length is zero), return false; otherwise return true. |
  772. | Symbol        | Return true.                                                                               |
  773. | Object        | Return true.                                                                               |
  774. --------------------------------------------------------------------------------------------------------------
  775. */
  776. function ToBoolean(argument) { // eslint-disable-line no-unused-vars
  777.     return Boolean(argument);
  778. }
  779.  
  780. // _ESAbstract.IteratorComplete
  781. /* global Type, ToBoolean, Get */
  782. // 7.4.3 IteratorComplete ( iterResult )
  783. function IteratorComplete(iterResult) { // eslint-disable-line no-unused-vars
  784.     // 1. Assert: Type(iterResult) is Object.
  785.     if (Type(iterResult) !== 'object') {
  786.         throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
  787.     }
  788.     // 2. Return ToBoolean(? Get(iterResult, "done")).
  789.     return ToBoolean(Get(iterResult, "done"));
  790. }
  791.  
  792. // _ESAbstract.IteratorStep
  793. /* global IteratorNext, IteratorComplete */
  794. // 7.4.5. IteratorStep ( iteratorRecord )
  795. function IteratorStep(iteratorRecord) { // eslint-disable-line no-unused-vars
  796.     // 1. Let result be ? IteratorNext(iteratorRecord).
  797.     var result = IteratorNext(iteratorRecord);
  798.     // 2. Let done be ? IteratorComplete(result).
  799.     var done = IteratorComplete(result);
  800.     // 3. If done is true, return false.
  801.     if (done === true) {
  802.         return false;
  803.     }
  804.     // 4. Return result.
  805.     return result;
  806. }
  807.  
  808. // _ESAbstract.IteratorValue
  809. /* global Type, Get */
  810. // 7.4.4 IteratorValue ( iterResult )
  811. function IteratorValue(iterResult) { // eslint-disable-line no-unused-vars
  812.     // Assert: Type(iterResult) is Object.
  813.     if (Type(iterResult) !== 'object') {
  814.         throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
  815.     }
  816.     // Return ? Get(iterResult, "value").
  817.     return Get(iterResult, "value");
  818. }
  819.  
  820. // _ESAbstract.CreateDataProperty
  821. // 7.3.4. CreateDataProperty ( O, P, V )
  822. // NOTE
  823. // This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator.
  824. // Normally, the property will not already exist. If it does exist and is not configurable or if O is not extensible, [[DefineOwnProperty]] will return false.
  825. function CreateDataProperty(O, P, V) { // eslint-disable-line no-unused-vars
  826.     // 1. Assert: Type(O) is Object.
  827.     // 2. Assert: IsPropertyKey(P) is true.
  828.     // 3. Let newDesc be the PropertyDescriptor{ [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.
  829.     var newDesc = {
  830.         value: V,
  831.         writable: true,
  832.         enumerable: true,
  833.         configurable: true
  834.     };
  835.     // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
  836.     try {
  837.         Object.defineProperty(O, P, newDesc);
  838.         return true;
  839.     } catch (e) {
  840.         return false;
  841.     }
  842. }
  843.  
  844. // _ESAbstract.CreateDataPropertyOrThrow
  845. /* global CreateDataProperty */
  846. // 7.3.6. CreateDataPropertyOrThrow ( O, P, V )
  847. function CreateDataPropertyOrThrow(O, P, V) { // eslint-disable-line no-unused-vars
  848.     // 1. Assert: Type(O) is Object.
  849.     // 2. Assert: IsPropertyKey(P) is true.
  850.     // 3. Let success be ? CreateDataProperty(O, P, V).
  851.     var success = CreateDataProperty(O, P, V);
  852.     // 4. If success is false, throw a TypeError exception.
  853.     if (!success) {
  854.         throw new TypeError('Cannot assign value `' + Object.prototype.toString.call(V) + '` to property `' + Object.prototype.toString.call(P) + '` on object `' + Object.prototype.toString.call(O) + '`');
  855.     }
  856.     // 5. Return success.
  857.     return success;
  858. }
  859.  
  860. // _ESAbstract.ToInteger
  861. // 7.1.4. ToInteger ( argument )
  862. function ToInteger(argument) { // eslint-disable-line no-unused-vars
  863.     // 1. Let number be ? ToNumber(argument).
  864.     var number = Number(argument);
  865.     // 2. If number is NaN, return +0.
  866.     if (isNaN(number)) {
  867.         return 0;
  868.     }
  869.     // 3. If number is +0, -0, +∞, or -∞, return number.
  870.     if (1/number === Infinity || 1/number === -Infinity || number === Infinity || number === -Infinity) {
  871.         return number;
  872.     }
  873.     // 4. Return the number value that is the same sign as number and whose magnitude is floor(abs(number)).
  874.     return ((number < 0) ? -1 : 1) * Math.floor(Math.abs(number));
  875. }
  876.  
  877. // _ESAbstract.ToLength
  878. /* global ToInteger */
  879. // 7.1.15. ToLength ( argument )
  880. function ToLength(argument) { // eslint-disable-line no-unused-vars
  881.     // 1. Let len be ? ToInteger(argument).
  882.     var len = ToInteger(argument);
  883.     // 2. If len ≀ +0, return +0.
  884.     if (len <= 0) {
  885.         return 0;
  886.     }
  887.     // 3. Return min(len, 253-1).
  888.     return Math.min(len, Math.pow(2, 53) -1);
  889. }
  890.  
  891. // _ESAbstract.CreateIterResultObject
  892. /* global Type, CreateDataProperty */
  893. // 7.4.7. CreateIterResultObject ( value, done )
  894. function CreateIterResultObject(value, done) { // eslint-disable-line no-unused-vars
  895.     // 1. Assert: Type(done) is Boolean.
  896.     if (Type(done) !== 'boolean') {
  897.         throw new Error();
  898.     }
  899.     // 2. Let obj be ObjectCreate(%ObjectPrototype%).
  900.     var obj = {};
  901.     // 3. Perform CreateDataProperty(obj, "value", value).
  902.     CreateDataProperty(obj, "value", value);
  903.     // 4. Perform CreateDataProperty(obj, "done", done).
  904.     CreateDataProperty(obj, "done", done);
  905.     // 5. Return obj.
  906.     return obj;
  907. }
  908.  
  909. // _ESAbstract.SameValueNonNumber
  910. // 7.2.12. SameValueNonNumber ( x, y )
  911. function SameValueNonNumber(x, y) { // eslint-disable-line no-unused-vars
  912.     // 1. Assert: Type(x) is not Number.
  913.     // 2. Assert: Type(x) is the same as Type(y).
  914.     // 3. If Type(x) is Undefined, return true.
  915.     // 4. If Type(x) is Null, return true.
  916.     // 5. If Type(x) is String, then
  917.         // a. If x and y are exactly the same sequence of code units (same length and same code units at corresponding indices), return true; otherwise, return false.
  918.     // 6. If Type(x) is Boolean, then
  919.         // a. If x and y are both true or both false, return true; otherwise, return false.
  920.     // 7. If Type(x) is Symbol, then
  921.         // a. If x and y are both the same Symbol value, return true; otherwise, return false.
  922.     // 8. If x and y are the same Object value, return true. Otherwise, return false.
  923.  
  924.     // Polyfill.io - We can skip all above steps because the === operator does it all for us.
  925.     return x === y;
  926. }
  927.  
  928. // _ESAbstract.SameValueZero
  929. /* global Type, SameValueNonNumber */
  930. // 7.2.11. SameValueZero ( x, y )
  931. function SameValueZero (x, y) { // eslint-disable-line no-unused-vars
  932.     // 1. If Type(x) is different from Type(y), return false.
  933.     if (Type(x) !== Type(y)) {
  934.         return false;
  935.     }
  936.     // 2. If Type(x) is Number, then
  937.     if (Type(x) === 'number') {
  938.         // a. If x is NaN and y is NaN, return true.
  939.         if (isNaN(x) && isNaN(y)) {
  940.             return true;
  941.         }
  942.         // b. If x is +0 and y is -0, return true.
  943.         if (1/x === Infinity && 1/y === -Infinity) {
  944.             return true;
  945.         }
  946.         // c. If x is -0 and y is +0, return true.
  947.         if (1/x === -Infinity && 1/y === Infinity) {
  948.             return true;
  949.         }
  950.         // d. If x is the same Number value as y, return true.
  951.         if (x === y) {
  952.             return true;
  953.         }
  954.         // e. Return false.
  955.         return false;
  956.     }
  957.     // 3. Return SameValueNonNumber(x, y).
  958.     return SameValueNonNumber(x, y);
  959. }
  960.  
  961. // Symbol.species
  962. /* global Symbol */
  963. Object.defineProperty(Symbol, 'species', { value: Symbol('species') });
  964.  
  965. // Map
  966. /* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
  967. (function (global) {
  968.     var supportsGetters = (function () {
  969.         try {
  970.             var a = {};
  971.             Object.defineProperty(a, 't', {
  972.                 configurable: true,
  973.                 enumerable: false,
  974.                 get: function () {
  975.                     return true;
  976.                 },
  977.                 set: undefined
  978.             });
  979.             return !!a.t;
  980.         } catch (e) {
  981.             return false;
  982.         }
  983.     }());
  984.  
  985.     // 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.
  986.     var undefMarker = Symbol('undef');
  987.     // 23.1.1.1 Map ( [ iterable ] )
  988.     var Map = function Map(/* iterable */) {
  989.         // 1. If NewTarget is undefined, throw a TypeError exception.
  990.         if (!(this instanceof Map)) {
  991.             throw new TypeError('Constructor Map requires "new"');
  992.         }
  993.         // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%MapPrototype%", Β« [[MapData]] Β»).
  994.         var map = OrdinaryCreateFromConstructor(this, Map.prototype, {
  995.             _keys: [],
  996.             _values: [],
  997.             _size: 0,
  998.             _es6Map: true
  999.         });
  1000.  
  1001.         // 3. Set map.[[MapData]] to a new empty List.
  1002.         // Polyfill.io - This step was done as part of step two.
  1003.  
  1004.         // 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.
  1005.         if (!supportsGetters) {
  1006.             Object.defineProperty(map, 'size', {
  1007.                 configurable: true,
  1008.                 enumerable: false,
  1009.                 writable: true,
  1010.                 value: 0
  1011.             });
  1012.         }
  1013.  
  1014.         // 4. If iterable is not present, let iterable be undefined.
  1015.         var iterable = arguments.length > 0 ? arguments[0] : undefined;
  1016.  
  1017.         // 5. If iterable is either undefined or null, return map.
  1018.         if (iterable === null || iterable === undefined) {
  1019.             return map;
  1020.         }
  1021.  
  1022.         // 6. Let adder be ? Get(map, "set").
  1023.         var adder = map.set;
  1024.  
  1025.         // 7. If IsCallable(adder) is false, throw a TypeError exception.
  1026.         if (!IsCallable(adder)) {
  1027.             throw new TypeError("Map.prototype.set is not a function");
  1028.         }
  1029.  
  1030.         // 8. Let iteratorRecord be ? GetIterator(iterable).
  1031.         try {
  1032.             var iteratorRecord = GetIterator(iterable);
  1033.             // 9. Repeat,
  1034.             while (true) {
  1035.                 // a. Let next be ? IteratorStep(iteratorRecord).
  1036.                 var next = IteratorStep(iteratorRecord);
  1037.                 // b. If next is false, return map.
  1038.                 if (next === false) {
  1039.                     return map;
  1040.                 }
  1041.                 // c. Let nextItem be ? IteratorValue(next).
  1042.                 var nextItem = IteratorValue(next);
  1043.                 // d. If Type(nextItem) is not Object, then
  1044.                 if (Type(nextItem) !== 'object') {
  1045.                     // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
  1046.                     try {
  1047.                         throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
  1048.                     } catch (error) {
  1049.                         // ii. Return ? IteratorClose(iteratorRecord, error).
  1050.                         return IteratorClose(iteratorRecord, error);
  1051.                     }
  1052.                 }
  1053.                 try {
  1054.                     // Polyfill.io - The try catch accounts for steps: f, h, and j.
  1055.  
  1056.                     // e. Let k be Get(nextItem, "0").
  1057.                     var k = nextItem[0];
  1058.                     // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
  1059.                     // g. Let v be Get(nextItem, "1").
  1060.                     var v = nextItem[1];
  1061.                     // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
  1062.                     // i. Let status be Call(adder, map, Β« k.[[Value]], v.[[Value]] Β»).
  1063.                     adder.call(map, k, v);
  1064.                 } catch (e) {
  1065.                     // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
  1066.                     return IteratorClose(iteratorRecord, e);
  1067.                 }
  1068.             }
  1069.         } catch (e) {
  1070.             // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
  1071.             if (Array.isArray(iterable) ||
  1072.                 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
  1073.                 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
  1074.                 (!!iterable.callee)) {
  1075.                 var index;
  1076.                 var length = iterable.length;
  1077.                 for (index = 0; index < length; index++) {
  1078.                     adder.call(map, iterable[index][0], iterable[index][1]);
  1079.                 }
  1080.             }
  1081.         }
  1082.         return map;
  1083.     };
  1084.  
  1085.     // 23.1.2.1. Map.prototype
  1086.     // The initial value of Map.prototype is the intrinsic object %MapPrototype%.
  1087.     // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
  1088.     Object.defineProperty(Map, 'prototype', {
  1089.         configurable: false,
  1090.         enumerable: false,
  1091.         writable: false,
  1092.         value: {}
  1093.     });
  1094.  
  1095.     // 23.1.2.2 get Map [ @@species ]
  1096.     if (supportsGetters) {
  1097.         Object.defineProperty(Map, Symbol.species, {
  1098.             configurable: true,
  1099.             enumerable: false,
  1100.             get: function () {
  1101.                 // 1. Return the this value.
  1102.                 return this;
  1103.             },
  1104.             set: undefined
  1105.         });
  1106.     } else {
  1107.         CreateMethodProperty(Map, Symbol.species, Map);
  1108.     }
  1109.  
  1110.     // 23.1.3.1 Map.prototype.clear ( )
  1111.     CreateMethodProperty(Map.prototype, 'clear', function clear() {
  1112.             // 1. Let M be the this value.
  1113.             var M = this;
  1114.             // 2. If Type(M) is not Object, throw a TypeError exception.
  1115.             if (Type(M) !== 'object') {
  1116.                 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
  1117.             }
  1118.             // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
  1119.             if (M._es6Map !== true) {
  1120.                 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
  1121.             }
  1122.             // 4. Let entries be the List that is M.[[MapData]].
  1123.             var entries = M._keys;
  1124.             // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
  1125.             for (var i = 0; i < entries.length; i++) {
  1126.                 // 5.a. Set p.[[Key]] to empty.
  1127.                 M._keys[i] = undefMarker;
  1128.                 // 5.b. Set p.[[Value]] to empty.
  1129.                 M._values[i] = undefMarker;
  1130.             }
  1131.             this._size = 0;
  1132.             if (!supportsGetters) {
  1133.                 this.size = this._size;
  1134.             }
  1135.             // 6. Return undefined.
  1136.             return undefined;
  1137.         }
  1138.     );
  1139.  
  1140.     // 23.1.3.2. Map.prototype.constructor
  1141.     CreateMethodProperty(Map.prototype, 'constructor', Map);
  1142.  
  1143.     // 23.1.3.3. Map.prototype.delete ( key )
  1144.     CreateMethodProperty(Map.prototype, 'delete', function (key) {
  1145.             // 1. Let M be the this value.
  1146.             var M = this;
  1147.             // 2. If Type(M) is not Object, throw a TypeError exception.
  1148.             if (Type(M) !== 'object') {
  1149.                 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
  1150.             }
  1151.             // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
  1152.             if (M._es6Map !== true) {
  1153.                 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
  1154.             }
  1155.             // 4. Let entries be the List that is M.[[MapData]].
  1156.             var entries = M._keys;
  1157.             // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
  1158.             for (var i = 0; i < entries.length; i++) {
  1159.                 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
  1160.                 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
  1161.                     // i. Set p.[[Key]] to empty.
  1162.                     this._keys[i] = undefMarker;
  1163.                     // ii. Set p.[[Value]] to empty.
  1164.                     this._values[i] = undefMarker;
  1165.                     this._size = --this._size;
  1166.                     if (!supportsGetters) {
  1167.                         this.size = this._size;
  1168.                     }
  1169.                     // iii. Return true.
  1170.                     return true;
  1171.                 }
  1172.             }
  1173.             // 6. Return false.
  1174.             return false;
  1175.         }
  1176.     );
  1177.  
  1178.     // 23.1.3.4. Map.prototype.entries ( )
  1179.     CreateMethodProperty(Map.prototype, 'entries', function entries () {
  1180.             // 1. Let M be the this value.
  1181.             var M = this;
  1182.             // 2. Return ? CreateMapIterator(M, "key+value").
  1183.             return CreateMapIterator(M, 'key+value');
  1184.         }
  1185.     );
  1186.  
  1187.     // 23.1.3.5. Map.prototype.forEach ( callbackfn [ , thisArg ] )
  1188.     CreateMethodProperty(Map.prototype, 'forEach', function (callbackFn) {
  1189.             // 1. Let M be the this value.
  1190.             var M = this;
  1191.             // 2. If Type(M) is not Object, throw a TypeError exception.
  1192.             if (Type(M) !== 'object') {
  1193.                 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
  1194.             }
  1195.             // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
  1196.             if (M._es6Map !== true) {
  1197.                 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
  1198.             }
  1199.             // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
  1200.             if (!IsCallable(callbackFn)) {
  1201.                 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
  1202.             }
  1203.             // 5. If thisArg is present, let T be thisArg; else let T be undefined.
  1204.             if (arguments[1]) {
  1205.                 var T = arguments[1];
  1206.             }
  1207.             // 6. Let entries be the List that is M.[[MapData]].
  1208.             var entries = M._keys;
  1209.             // 7. For each Record {[[Key]], [[Value]]} e that is an element of entries, in original key insertion order, do
  1210.             for (var i = 0; i < entries.length; i++) {
  1211.                 // a. If e.[[Key]] is not empty, then
  1212.                 if (M._keys[i] !== undefMarker && M._values[i] !== undefMarker ) {
  1213.                     // i. Perform ? Call(callbackfn, T, Β« e.[[Value]], e.[[Key]], M Β»).
  1214.                     callbackFn.call(T, M._values[i], M._keys[i], M);
  1215.                 }
  1216.             }
  1217.             // 8. Return undefined.
  1218.             return undefined;
  1219.         }
  1220.     );
  1221.  
  1222.     // 23.1.3.6. Map.prototype.get ( key )
  1223.     CreateMethodProperty(Map.prototype, 'get', function get(key) {
  1224.             // 1. Let M be the this value.
  1225.             var M = this;
  1226.             // 2. If Type(M) is not Object, throw a TypeError exception.
  1227.             if (Type(M) !== 'object') {
  1228.                 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
  1229.             }
  1230.             // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
  1231.             if (M._es6Map !== true) {
  1232.                 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
  1233.             }
  1234.             // 4. Let entries be the List that is M.[[MapData]].
  1235.             var entries = M._keys;
  1236.             // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
  1237.             for (var i = 0; i < entries.length; i++) {
  1238.                 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return p.[[Value]].
  1239.                 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
  1240.                     return M._values[i];
  1241.                 }
  1242.             }
  1243.             // 6. Return undefined.
  1244.             return undefined;
  1245.         });
  1246.  
  1247.     // 23.1.3.7. Map.prototype.has ( key )
  1248.     CreateMethodProperty(Map.prototype, 'has', function has (key) {
  1249.             // 1. Let M be the this value.
  1250.             var M = this;
  1251.             // 2. If Type(M) is not Object, throw a TypeError exception.
  1252.             if (typeof M !== 'object') {
  1253.                 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
  1254.             }
  1255.             // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
  1256.             if (M._es6Map !== true) {
  1257.                 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
  1258.             }
  1259.             // 4. Let entries be the List that is M.[[MapData]].
  1260.             var entries = M._keys;
  1261.             // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
  1262.             for (var i = 0; i < entries.length; i++) {
  1263.                 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return true.
  1264.                 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
  1265.                     return true;
  1266.                 }
  1267.             }
  1268.             // 6. Return false.
  1269.             return false;
  1270.         });
  1271.  
  1272.     // 23.1.3.8. Map.prototype.keys ( )
  1273.     CreateMethodProperty(Map.prototype, 'keys', function keys () {
  1274.             // 1. Let M be the this value.
  1275.             var M = this;
  1276.             // 2. Return ? CreateMapIterator(M, "key").
  1277.             return CreateMapIterator(M, "key");
  1278.         });
  1279.  
  1280.     // 23.1.3.9. Map.prototype.set ( key, value )
  1281.     CreateMethodProperty(Map.prototype, 'set', function set(key, value) {
  1282.             // 1. Let M be the this value.
  1283.             var M = this;
  1284.             // 2. If Type(M) is not Object, throw a TypeError exception.
  1285.             if (Type(M) !== 'object') {
  1286.                 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
  1287.             }
  1288.             // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
  1289.             if (M._es6Map !== true) {
  1290.                 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
  1291.             }
  1292.             // 4. Let entries be the List that is M.[[MapData]].
  1293.             var entries = M._keys;
  1294.             // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
  1295.             for (var i = 0; i < entries.length; i++) {
  1296.                 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
  1297.                 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
  1298.                     // i. Set p.[[Value]] to value.
  1299.                     M._values[i] = value;
  1300.                     // Return M.
  1301.                     return M;
  1302.                 }
  1303.             }
  1304.             // 6. If key is -0, let key be +0.
  1305.             if (1/key === -Infinity) {
  1306.                 key = 0;
  1307.             }
  1308.             // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
  1309.             var p = {};
  1310.             p['[[Key]]'] = key;
  1311.             p['[[Value]]'] = value;
  1312.             // 8. Append p as the last element of entries.
  1313.             M._keys.push(p['[[Key]]']);
  1314.             M._values.push(p['[[Value]]']);
  1315.             ++M._size;
  1316.             if (!supportsGetters) {
  1317.                 M.size = M._size;
  1318.             }
  1319.             // 9. Return M.
  1320.             return M;
  1321.         });
  1322.  
  1323.     // 23.1.3.10. get Map.prototype.size
  1324.     if (supportsGetters) {
  1325.         Object.defineProperty(Map.prototype, 'size', {
  1326.             configurable: true,
  1327.             enumerable: false,
  1328.             get: function () {
  1329.                 // 1. Let M be the this value.
  1330.                 var M = this;
  1331.                 // 2. If Type(M) is not Object, throw a TypeError exception.
  1332.                 if (Type(M) !== 'object') {
  1333.                     throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
  1334.                 }
  1335.                 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
  1336.                 if (M._es6Map !== true) {
  1337.                     throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
  1338.                 }
  1339.                 // 4. Let entries be the List that is M.[[MapData]].
  1340.                 var entries = M._keys;
  1341.                 // 5. Let count be 0.
  1342.                 var count = 0;
  1343.                 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
  1344.                 for (var i = 0; i < entries.length; i++) {
  1345.                     // a. If p.[[Key]] is not empty, set count to count+1.
  1346.                     if (M._keys[i] !== undefMarker) {
  1347.                         count = count + 1;
  1348.                     }
  1349.                 }
  1350.                 // 7. Return count.
  1351.                 return count;
  1352.             },
  1353.             set: undefined
  1354.         });
  1355.     }
  1356.  
  1357.     // 23.1.3.11. Map.prototype.values ( )
  1358.     CreateMethodProperty(Map.prototype, 'values', function values () {
  1359.             // 1. Let M be the this value.
  1360.             var M = this;
  1361.             // 2. Return ? CreateMapIterator(M, "value").
  1362.             return CreateMapIterator(M, 'value');
  1363.         }
  1364.     );
  1365.  
  1366.     // 23.1.3.12. Map.prototype [ @@iterator ] ( )
  1367.     // The initial value of the @@iterator property is the same function object as the initial value of the entries property.
  1368.     CreateMethodProperty(Map.prototype, Symbol.iterator, Map.prototype.entries);
  1369.  
  1370.     // 23.1.3.13. Map.prototype [ @@toStringTag ]
  1371.     // The initial value of the @@toStringTag property is the String value "Map".
  1372.     // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
  1373.  
  1374.     // Polyfill.io - Safari 8 implements Map.name but as a non-configurable property, which means it would throw an error if we try and configure it here.
  1375.     if (!('name' in Map)) {
  1376.         // 19.2.4.2 name
  1377.         Object.defineProperty(Map, 'name', {
  1378.             configurable: true,
  1379.             enumerable: false,
  1380.             writable: false,
  1381.             value: 'Map'
  1382.         });
  1383.     }
  1384.  
  1385.     // 23.1.5.1. CreateMapIterator ( map, kind )
  1386.     function CreateMapIterator(map, kind) {
  1387.         // 1. If Type(map) is not Object, throw a TypeError exception.
  1388.         if (Type(map) !== 'object') {
  1389.             throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
  1390.         }
  1391.         // 2. If map does not have a [[MapData]] internal slot, throw a TypeError exception.
  1392.         if (map._es6Map !== true) {
  1393.             throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
  1394.         }
  1395.         // 3. Let iterator be ObjectCreate(%MapIteratorPrototype%, Β« [[Map]], [[MapNextIndex]], [[MapIterationKind]] Β»).
  1396.         var iterator = Object.create(MapIteratorPrototype);
  1397.         // 4. Set iterator.[[Map]] to map.
  1398.         Object.defineProperty(iterator, '[[Map]]', {
  1399.             configurable: true,
  1400.             enumerable: false,
  1401.             writable: true,
  1402.             value: map
  1403.         });
  1404.         // 5. Set iterator.[[MapNextIndex]] to 0.
  1405.         Object.defineProperty(iterator, '[[MapNextIndex]]', {
  1406.             configurable: true,
  1407.             enumerable: false,
  1408.             writable: true,
  1409.             value: 0
  1410.         });
  1411.         // 6. Set iterator.[[MapIterationKind]] to kind.
  1412.         Object.defineProperty(iterator, '[[MapIterationKind]]', {
  1413.             configurable: true,
  1414.             enumerable: false,
  1415.             writable: true,
  1416.             value: kind
  1417.         });
  1418.         // 7. Return iterator.
  1419.         return iterator;
  1420.     }
  1421.  
  1422.     // 23.1.5.2. The %MapIteratorPrototype% Object
  1423.     var MapIteratorPrototype = {};
  1424.     // Polyfill.io - We use this as a quick way to check if an object is a Map Iterator instance.
  1425.     Object.defineProperty(MapIteratorPrototype, 'isMapIterator', {
  1426.         configurable: false,
  1427.         enumerable: false,
  1428.         writable: false,
  1429.         value: true
  1430.     });
  1431.  
  1432.     // 23.1.5.2.1. %MapIteratorPrototype%.next ( )
  1433.     CreateMethodProperty(MapIteratorPrototype, 'next', function next() {
  1434.             // 1. Let O be the this value.
  1435.             var O = this;
  1436.             // 2. If Type(O) is not Object, throw a TypeError exception.
  1437.             if (Type(O) !== 'object') {
  1438.                 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
  1439.             }
  1440.             // 3. If O does not have all of the internal slots of a Map Iterator Instance (23.1.5.3), throw a TypeError exception.
  1441.             if (!O.isMapIterator) {
  1442.                 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
  1443.             }
  1444.             // 4. Let m be O.[[Map]].
  1445.             var m = O['[[Map]]'];
  1446.             // 5. Let index be O.[[MapNextIndex]].
  1447.             var index = O['[[MapNextIndex]]'];
  1448.             // 6. Let itemKind be O.[[MapIterationKind]].
  1449.             var itemKind = O['[[MapIterationKind]]'];
  1450.             // 7. If m is undefined, return CreateIterResultObject(undefined, true).
  1451.             if (m === undefined) {
  1452.                 return CreateIterResultObject(undefined, true);
  1453.             }
  1454.             // 8. Assert: m has a [[MapData]] internal slot.
  1455.             if (!m._es6Map) {
  1456.                 throw new Error(Object.prototype.toString.call(m) + ' has a [[MapData]] internal slot.');
  1457.             }
  1458.             // 9. Let entries be the List that is m.[[MapData]].
  1459.             var entries = m._keys;
  1460.             // 10. Let numEntries be the number of elements of entries.
  1461.             var numEntries = entries.length;
  1462.             // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
  1463.             // 12. Repeat, while index is less than numEntries,
  1464.             while (index < numEntries) {
  1465.                 // a. Let e be the Record {[[Key]], [[Value]]} that is the value of entries[index].
  1466.                 var e = Object.create(null);
  1467.                 e['[[Key]]'] = m._keys[index];
  1468.                 e['[[Value]]'] = m._values[index];
  1469.                 // b. Set index to index+1.
  1470.                 index = index + 1;
  1471.                 // c. Set O.[[MapNextIndex]] to index.
  1472.                 O['[[MapNextIndex]]'] = index;
  1473.                 // d. If e.[[Key]] is not empty, then
  1474.                 if (e['[[Key]]'] !== undefMarker) {
  1475.                     // i. If itemKind is "key", let result be e.[[Key]].
  1476.                     if (itemKind === 'key') {
  1477.                         var result = e['[[Key]]'];
  1478.                         // ii. Else if itemKind is "value", let result be e.[[Value]].
  1479.                     } else if (itemKind === 'value') {
  1480.                         result = e['[[Value]]'];
  1481.                         // iii. Else,
  1482.                     } else {
  1483.                         // 1. Assert: itemKind is "key+value".
  1484.                         if (itemKind !== 'key+value') {
  1485.                             throw new Error();
  1486.                         }
  1487.                         // 2. Let result be CreateArrayFromList(Β« e.[[Key]], e.[[Value]] Β»).
  1488.                         result = [
  1489.                             e['[[Key]]'],
  1490.                             e['[[Value]]']
  1491.                         ];
  1492.                     }
  1493.                     // iv. Return CreateIterResultObject(result, false).
  1494.                     return CreateIterResultObject(result, false);
  1495.                 }
  1496.             }
  1497.             // 13. Set O.[[Map]] to undefined.
  1498.             O['[[Map]]'] = undefined;
  1499.             // 14. Return CreateIterResultObject(undefined, true).
  1500.             return CreateIterResultObject(undefined, true);
  1501.         }
  1502.     );
  1503.  
  1504.     // 23.1.5.2.2 %MapIteratorPrototype% [ @@toStringTag ]
  1505.     // The initial value of the @@toStringTag property is the String value "Map Iterator".
  1506.     // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
  1507.  
  1508.     CreateMethodProperty(MapIteratorPrototype, Symbol.iterator, function iterator() {
  1509.             return this;
  1510.         }
  1511.     );
  1512.  
  1513.     // Export the object
  1514.     try {
  1515.         CreateMethodProperty(global, 'Map', Map);
  1516.     } catch (e) {
  1517.         // IE8 throws an error here if we set enumerable to false.
  1518.         // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
  1519.         global['Map'] = Map;
  1520.     }
  1521. }(this));
  1522.  
  1523. // Set
  1524. /* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Symbol */
  1525. (function (global) {
  1526.     var supportsGetters = (function () {
  1527.         try {
  1528.             var a = {};
  1529.             Object.defineProperty(a, 't', {
  1530.                 configurable: true,
  1531.                 enumerable: false,
  1532.                 get: function () {
  1533.                     return true;
  1534.                 },
  1535.                 set: undefined
  1536.             });
  1537.             return !!a.t;
  1538.         } catch (e) {
  1539.             return false;
  1540.         }
  1541.     }());
  1542.  
  1543.     // Deleted set 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.
  1544.     var undefMarker = Symbol('undef');
  1545.     // 23.2.1.1. Set ( [ iterable ] )
  1546.     var Set = function Set(/* iterable */) {
  1547.         // 1. If NewTarget is undefined, throw a TypeError exception.
  1548.         if (!(this instanceof Set)) {
  1549.             throw new TypeError('Constructor Set requires "new"');
  1550.         }
  1551.         // 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%SetPrototype%", Β« [[SetData]] Β»).
  1552.         var set = OrdinaryCreateFromConstructor(this, Set.prototype, {
  1553.             _values: [],
  1554.             _size: 0,
  1555.             _es6Set: true
  1556.         });
  1557.  
  1558.         // 3. Set set.[[SetData]] to a new empty List.
  1559.         // Polyfill.io - This step was done as part of step two.
  1560.  
  1561.         // 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.
  1562.         if (!supportsGetters) {
  1563.             Object.defineProperty(set, 'size', {
  1564.                 configurable: true,
  1565.                 enumerable: false,
  1566.                 writable: true,
  1567.                 value: 0
  1568.             });
  1569.         }
  1570.  
  1571.         // 4. If iterable is not present, let iterable be undefined.
  1572.         var iterable = arguments.length > 0 ? arguments[0] : undefined;
  1573.  
  1574.         // 5. If iterable is either undefined or null, return set.
  1575.         if (iterable === null || iterable === undefined) {
  1576.             return set;
  1577.         }
  1578.  
  1579.         // 6. Let adder be ? Get(set, "add").
  1580.         var adder = set.add;
  1581.         // 7. If IsCallable(adder) is false, throw a TypeError exception.
  1582.         if (!IsCallable(adder)) {
  1583.             throw new TypeError("Set.prototype.add is not a function");
  1584.         }
  1585.  
  1586.         try {
  1587.             // 8. Let iteratorRecord be ? GetIterator(iterable).
  1588.             var iteratorRecord = GetIterator(iterable);
  1589.             // 9. Repeat,
  1590.             while (true) {
  1591.                 // a. Let next be ? IteratorStep(iteratorRecord).
  1592.                 var next = IteratorStep(iteratorRecord);
  1593.                 // b. If next is false, return set.
  1594.                 if (next === false) {
  1595.                     return set;
  1596.                 }
  1597.                 // c. Let nextValue be ? IteratorValue(next).
  1598.                 var nextValue = IteratorValue(next);
  1599.                 // d. Let status be Call(adder, set, Β« nextValue.[[Value]] Β»).
  1600.                 try {
  1601.                     adder.call(set, nextValue);
  1602.                 } catch (e) {
  1603.                     // e. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
  1604.                     return IteratorClose(iteratorRecord, e);
  1605.                 }
  1606.             }
  1607.         } catch (e) {
  1608.             // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
  1609.             if (Array.isArray(iterable) ||
  1610.                 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
  1611.                 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
  1612.                 (!!iterable.callee)) {
  1613.                 var index;
  1614.                 var length = iterable.length;
  1615.                 for (index = 0; index < length; index++) {
  1616.                     adder.call(set, iterable[index]);
  1617.                 }
  1618.             }
  1619.         }
  1620.         return set;
  1621.     };
  1622.  
  1623.     // 23.2.2.1. Set.prototype
  1624.     // The initial value of Set.prototype is the intrinsic %SetPrototype% object.
  1625.     // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
  1626.     Object.defineProperty(Set, 'prototype', {
  1627.         configurable: false,
  1628.         enumerable: false,
  1629.         writable: false,
  1630.         value: {}
  1631.     });
  1632.  
  1633.     // 23.2.2.2 get Set [ @@species ]
  1634.     if (supportsGetters) {
  1635.         Object.defineProperty(Set, Symbol.species, {
  1636.             configurable: true,
  1637.             enumerable: false,
  1638.             get: function () {
  1639.                 // 1. Return the this value.
  1640.                 return this;
  1641.             },
  1642.             set: undefined
  1643.         });
  1644.     } else {
  1645.         CreateMethodProperty(Set, Symbol.species, Set);
  1646.     }
  1647.  
  1648.     // 23.2.3.1. Set.prototype.add ( value )
  1649.     CreateMethodProperty(Set.prototype, 'add', function add(value) {
  1650.             // 1. Let S be the this value.
  1651.             var S = this;
  1652.             // 2. If Type(S) is not Object, throw a TypeError exception.
  1653.             if (typeof S !== 'object') {
  1654.                 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
  1655.             }
  1656.             // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
  1657.             if (S._es6Set !== true) {
  1658.                 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
  1659.             }
  1660.             // 4. Let entries be the List that is S.[[SetData]].
  1661.             var entries = S._values;
  1662.             // 5. For each e that is an element of entries, do
  1663.             for (var i = 0; i < entries.length; i++) {
  1664.                 var e = entries[i];
  1665.                 // a. If e is not empty and SameValueZero(e, value) is true, then
  1666.                 if (e !== undefMarker && SameValueZero(e, value)) {
  1667.                     // i. Return S.
  1668.                     return S;
  1669.                 }
  1670.             }
  1671.             // 6. If value is -0, let value be +0.
  1672.             if (1/value === -Infinity) {
  1673.                 value = 0;
  1674.             }
  1675.             // 7. Append value as the last element of entries.
  1676.             S._values.push(value);
  1677.  
  1678.             this._size = ++this._size;
  1679.             if (!supportsGetters) {
  1680.                 this.size = this._size;
  1681.             }
  1682.             // 8. Return S.
  1683.             return S;
  1684.         });
  1685.  
  1686.     // 23.2.3.2. Set.prototype.clear ( )
  1687.     CreateMethodProperty(Set.prototype, 'clear', function clear() {
  1688.             // 1. Let S be the this value.
  1689.             var S = this;
  1690.             // 2. If Type(S) is not Object, throw a TypeError exception.
  1691.             if (typeof S !== 'object') {
  1692.                 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
  1693.             }
  1694.             // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
  1695.             if (S._es6Set !== true) {
  1696.                 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
  1697.             }
  1698.             // 4. Let entries be the List that is S.[[SetData]].
  1699.             var entries = S._values;
  1700.             // 5. For each e that is an element of entries, do
  1701.             for (var i = 0; i < entries.length; i++) {
  1702.                 // a. Replace the element of entries whose value is e with an element whose value is empty.
  1703.                 entries[i] = undefMarker;
  1704.             }
  1705.             this._size = 0;
  1706.             if (!supportsGetters) {
  1707.                 this.size = this._size;
  1708.             }
  1709.             // 6. Return undefined.
  1710.             return undefined;
  1711.         });
  1712.  
  1713.     // 23.2.3.3. Set.prototype.constructor
  1714.     CreateMethodProperty(Set.prototype, 'constructor', Set);
  1715.  
  1716.     // 23.2.3.4. Set.prototype.delete ( value )
  1717.     CreateMethodProperty(Set.prototype, 'delete', function (value) {
  1718.             // 1. Let S be the this value.
  1719.             var S = this;
  1720.             // 2. If Type(S) is not Object, throw a TypeError exception.
  1721.             if (typeof S !== 'object') {
  1722.                 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
  1723.             }
  1724.             // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
  1725.             if (S._es6Set !== true) {
  1726.                 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
  1727.             }
  1728.             // 4. Let entries be the List that is S.[[SetData]].
  1729.             var entries = S._values;
  1730.             // 5. For each e that is an element of entries, do
  1731.             for (var i = 0; i < entries.length; i++) {
  1732.                 var e = entries[i];
  1733.                 // a. If e is not empty and SameValueZero(e, value) is true, then
  1734.                 if (e !== undefMarker && SameValueZero(e, value)) {
  1735.                     // i. Replace the element of entries whose value is e with an element whose value is empty.
  1736.                     entries[i] = undefMarker;
  1737.  
  1738.                     this._size = --this._size;
  1739.                     if (!supportsGetters) {
  1740.                         this.size = this._size;
  1741.                     }
  1742.                     // ii. Return true.
  1743.                     return true;
  1744.                 }
  1745.             }
  1746.             // 6. Return false.
  1747.             return false;
  1748.         }
  1749.     );
  1750.  
  1751.     // 23.2.3.5. Set.prototype.entries ( )
  1752.     CreateMethodProperty(Set.prototype, 'entries', function entries() {
  1753.             // 1. Let S be the this value.
  1754.             var S = this;
  1755.             // 2. Return ? CreateSetIterator(S, "key+value").
  1756.             return CreateSetIterator(S, 'key+value');
  1757.         }
  1758.     );
  1759.  
  1760.     // 23.2.3.6. Set.prototype.forEach ( callbackfn [ , thisArg ] )
  1761.     CreateMethodProperty(Set.prototype, 'forEach', function forEach(callbackFn /*[ , thisArg ]*/) {
  1762.             // 1. Let S be the this value.
  1763.             var S = this;
  1764.             // 2. If Type(S) is not Object, throw a TypeError exception.
  1765.             if (typeof S !== 'object') {
  1766.                 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
  1767.             }
  1768.             // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
  1769.             if (S._es6Set !== true) {
  1770.                 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
  1771.             }
  1772.             // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
  1773.             if (!IsCallable(callbackFn)) {
  1774.                 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
  1775.             }
  1776.             // 5. If thisArg is present, let T be thisArg; else let T be undefined.
  1777.             if (arguments[1]) {
  1778.                 var T = arguments[1];
  1779.             }
  1780.             // 6. Let entries be the List that is S.[[SetData]].
  1781.             var entries = S._values;
  1782.             // 7. For each e that is an element of entries, in original insertion order, do
  1783.             for (var i = 0; i < entries.length; i++) {
  1784.                 var e = entries[i];
  1785.                 // a. If e is not empty, then
  1786.                 if (e !== undefMarker) {
  1787.                     // i. Perform ? Call(callbackfn, T, Β« e, e, S Β»).
  1788.                     callbackFn.call(T, e, e, S);
  1789.                 }
  1790.             }
  1791.             // 8. Return undefined.
  1792.             return undefined;
  1793.         }
  1794.     );
  1795.  
  1796.     // 23.2.3.7. Set.prototype.has ( value )
  1797.     CreateMethodProperty(Set.prototype, 'has', function has(value) {
  1798.             // 1. Let S be the this value.
  1799.             var S = this;
  1800.             // 2. If Type(S) is not Object, throw a TypeError exception.
  1801.             if (typeof S !== 'object') {
  1802.                 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
  1803.             }
  1804.             // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
  1805.             if (S._es6Set !== true) {
  1806.                 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
  1807.             }
  1808.             // 4. Let entries be the List that is S.[[SetData]].
  1809.             var entries = S._values;
  1810.             // 5. For each e that is an element of entries, do
  1811.             for (var i = 0; i < entries.length; i++) {
  1812.                 var e = entries[i];
  1813.                 // a. If e is not empty and SameValueZero(e, value) is true, return true.
  1814.                 if (e !== undefMarker && SameValueZero(e, value)) {
  1815.                     return true;
  1816.                 }
  1817.             }
  1818.             // 6. Return false.
  1819.             return false;
  1820.         }
  1821.     );
  1822.  
  1823.     // Polyfill.io - We need to define Set.prototype.values before Set.prototype.keys because keys is a reference to values.
  1824.     // 23.2.3.10. Set.prototype.values()
  1825.     var values = function values() {
  1826.         // 1. Let S be the this value.
  1827.         var S = this;
  1828.         // 2. Return ? CreateSetIterator(S, "value").
  1829.         return CreateSetIterator(S, "value");
  1830.     };
  1831.     CreateMethodProperty(Set.prototype, 'values', values);
  1832.  
  1833.     // 23.2.3.8 Set.prototype.keys ( )
  1834.     // The initial value of the keys property is the same function object as the initial value of the values property.
  1835.     CreateMethodProperty(Set.prototype, 'keys', values);
  1836.  
  1837.     // 23.2.3.9. get Set.prototype.size
  1838.     if (supportsGetters) {
  1839.         Object.defineProperty(Set.prototype, 'size', {
  1840.             configurable: true,
  1841.             enumerable: false,
  1842.             get: function () {
  1843.                 // 1. Let S be the this value.
  1844.                 var S = this;
  1845.                 // 2. If Type(S) is not Object, throw a TypeError exception.
  1846.                 if (typeof S !== 'object') {
  1847.                     throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
  1848.                 }
  1849.                 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
  1850.                 if (S._es6Set !== true) {
  1851.                     throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
  1852.                 }
  1853.                 // 4. Let entries be the List that is S.[[SetData]].
  1854.                 var entries = S._values;
  1855.                 // 5. Let count be 0.
  1856.                 var count = 0;
  1857.                 // 6. For each e that is an element of entries, do
  1858.                 for (var i = 0; i < entries.length; i++) {
  1859.                     var e = entries[i];
  1860.                     // a. If e is not empty, set count to count+1.
  1861.                     if (e !== undefMarker) {
  1862.                         count = count + 1;
  1863.                     }
  1864.                 }
  1865.                 // 7. Return count.
  1866.                 return count;
  1867.             },
  1868.             set: undefined
  1869.         });
  1870.     }
  1871.  
  1872.     // 23.2.3.11. Set.prototype [ @@iterator ] ( )
  1873.     // The initial value of the @@iterator property is the same function object as the initial value of the values property.
  1874.     CreateMethodProperty(Set.prototype, Symbol.iterator, values);
  1875.  
  1876.     // 23.2.3.12. Set.prototype [ @@toStringTag ]
  1877.     // The initial value of the @@toStringTag property is the String value "Set".
  1878.     // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
  1879.  
  1880.     // Polyfill.io - Safari 8 implements Set.name but as a non-configurable property, which means it would throw an error if we try and configure it here.
  1881.     if (!('name' in Set)) {
  1882.         // 19.2.4.2 name
  1883.         Object.defineProperty(Set, 'name', {
  1884.             configurable: true,
  1885.             enumerable: false,
  1886.             writable: false,
  1887.             value: 'Set'
  1888.         });
  1889.     }
  1890.  
  1891.     // 23.2.5.1. CreateSetIterator ( set, kind )
  1892.     function CreateSetIterator(set, kind) {
  1893.         // 1. If Type(set) is not Object, throw a TypeError exception.
  1894.         if (typeof set !== 'object') {
  1895.             throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
  1896.         }
  1897.         // 2. If set does not have a [[SetData]] internal slot, throw a TypeError exception.
  1898.         if (set._es6Set !== true) {
  1899.             throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
  1900.         }
  1901.         // 3. Let iterator be ObjectCreate(%SetIteratorPrototype%, Β« [[IteratedSet]], [[SetNextIndex]], [[SetIterationKind]] Β»).
  1902.         var iterator = Object.create(SetIteratorPrototype);
  1903.         // 4. Set iterator.[[IteratedSet]] to set.
  1904.         Object.defineProperty(iterator, '[[IteratedSet]]', {
  1905.             configurable: true,
  1906.             enumerable: false,
  1907.             writable: true,
  1908.             value: set
  1909.         });
  1910.         // 5. Set iterator.[[SetNextIndex]] to 0.
  1911.         Object.defineProperty(iterator, '[[SetNextIndex]]', {
  1912.             configurable: true,
  1913.             enumerable: false,
  1914.             writable: true,
  1915.             value: 0
  1916.         });
  1917.         // 6. Set iterator.[[SetIterationKind]] to kind.
  1918.         Object.defineProperty(iterator, '[[SetIterationKind]]', {
  1919.             configurable: true,
  1920.             enumerable: false,
  1921.             writable: true,
  1922.             value: kind
  1923.         });
  1924.         // 7. Return iterator.
  1925.         return iterator;
  1926.     }
  1927.  
  1928.     // 23.2.5.2. The %SetIteratorPrototype% Object
  1929.     var SetIteratorPrototype = {};
  1930.     //Polyfill.io - We add this property to help us identify what is a set iterator.
  1931.     Object.defineProperty(SetIteratorPrototype, 'isSetIterator', {
  1932.         configurable: false,
  1933.         enumerable: false,
  1934.         writable: false,
  1935.         value: true
  1936.     });
  1937.  
  1938.     // 23.2.5.2.1. %SetIteratorPrototype%.next ( )
  1939.     CreateMethodProperty(SetIteratorPrototype, 'next', function next() {
  1940.         // 1. Let O be the this value.
  1941.         var O = this;
  1942.         // 2. If Type(O) is not Object, throw a TypeError exception.
  1943.         if (typeof O !== 'object') {
  1944.             throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
  1945.         }
  1946.         // 3. If O does not have all of the internal slots of a Set Iterator Instance (23.2.5.3), throw a TypeError exception.
  1947.         if (!O.isSetIterator) {
  1948.             throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
  1949.         }
  1950.         // 4. Let s be O.[[IteratedSet]].
  1951.         var s = O['[[IteratedSet]]'];
  1952.         // 5. Let index be O.[[SetNextIndex]].
  1953.         var index = O['[[SetNextIndex]]'];
  1954.         // 6. Let itemKind be O.[[SetIterationKind]].
  1955.         var itemKind = O['[[SetIterationKind]]'];
  1956.         // 7. If s is undefined, return CreateIterResultObject(undefined, true).
  1957.         if (s === undefined) {
  1958.             return CreateIterResultObject(undefined, true);
  1959.         }
  1960.         // 8. Assert: s has a [[SetData]] internal slot.
  1961.         if (!s._es6Set) {
  1962.             throw new Error(Object.prototype.toString.call(s) + ' does not have [[SetData]] internal slot.');
  1963.         }
  1964.         // 9. Let entries be the List that is s.[[SetData]].
  1965.         var entries = s._values;
  1966.         // 10. Let numEntries be the number of elements of entries.
  1967.         var numEntries = entries.length;
  1968.         // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
  1969.         // 12. Repeat, while index is less than numEntries,
  1970.         while (index < numEntries) {
  1971.             // a. Let e be entries[index].
  1972.             var e = entries[index];
  1973.             // b. Set index to index+1.
  1974.             index = index + 1;
  1975.             // c. Set O.[[SetNextIndex]] to index.
  1976.             O['[[SetNextIndex]]'] = index;
  1977.             // d. If e is not empty, then
  1978.             if (e !== undefMarker) {
  1979.                 // i. If itemKind is "key+value", then
  1980.                 if (itemKind === 'key+value') {
  1981.                     // 1. Return CreateIterResultObject(CreateArrayFromList(Β« e, e Β»), false).
  1982.                     return CreateIterResultObject([e, e], false);
  1983.                 }
  1984.                 // ii. Return CreateIterResultObject(e, false).
  1985.                 return CreateIterResultObject(e, false);
  1986.             }
  1987.         }
  1988.         // 13. Set O.[[IteratedSet]] to undefined.
  1989.         O['[[IteratedSet]]'] = undefined;
  1990.         // 14. Return CreateIterResultObject(undefined, true).
  1991.         return CreateIterResultObject(undefined, true);
  1992.     });
  1993.  
  1994.     // 23.2.5.2.2. %SetIteratorPrototype% [ @@toStringTag ]
  1995.     // The initial value of the @@toStringTag property is the String value "Set Iterator".
  1996.     // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
  1997.  
  1998.     CreateMethodProperty(SetIteratorPrototype, Symbol.iterator, function iterator() {
  1999.             return this;
  2000.         }
  2001.     );
  2002.  
  2003.     // Export the object
  2004.     try {
  2005.         CreateMethodProperty(global, 'Set', Set);
  2006.     } catch (e) {
  2007.         // IE8 throws an error here if we set enumerable to false.
  2008.         // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
  2009.         global['Set'] = Set;
  2010.     }
  2011.  
  2012. }(this));
  2013.  
  2014. // Array.from
  2015. /* globals
  2016.     IsCallable, GetMethod, Symbol, IsConstructor, Construct, ArrayCreate, GetIterator, IteratorClose,
  2017.     ToString, IteratorStep, IteratorValue, Call, CreateDataPropertyOrThrow, ToObject, ToLength, Get, CreateMethodProperty
  2018. */
  2019. (function () {
  2020.     var toString = Object.prototype.toString;
  2021.     var stringMatch = String.prototype.match;
  2022.     // A cross-realm friendly way to detect if a value is a String object or literal.
  2023.     function isString(value) {
  2024.         if (typeof value === 'string') { return true; }
  2025.         if (typeof value !== 'object') { return false; }
  2026.         return toString.call(value) === '[object String]';
  2027.     }
  2028.  
  2029.     // 22.1.2.1. Array.from ( items [ , mapfn [ , thisArg ] ] )
  2030.     CreateMethodProperty(Array, 'from', function from(items /* [ , mapfn [ , thisArg ] ] */) { // eslint-disable-line no-undef
  2031.         // 1. Let C be the this value.
  2032.         var C = this;
  2033.         // 2. If mapfn is undefined, let mapping be false.
  2034.         var mapfn = arguments.length > 1 ? arguments[1] : undefined;
  2035.         if (mapfn === undefined) {
  2036.             var mapping = false;
  2037.             // 3. Else,
  2038.         } else {
  2039.             // a. If IsCallable(mapfn) is false, throw a TypeError exception.
  2040.             if (IsCallable(mapfn) === false) {
  2041.                 throw new TypeError(Object.prototype.toString.call(mapfn) + ' is not a function.');
  2042.             }
  2043.             // b. If thisArg is present, let T be thisArg; else let T be undefined.
  2044.             var thisArg = arguments.length > 2 ? arguments[2] : undefined;
  2045.             if (thisArg !== undefined) {
  2046.                 var T = thisArg;
  2047.             } else {
  2048.                 T = undefined;
  2049.             }
  2050.             // c. Let mapping be true.
  2051.             mapping = true;
  2052.  
  2053.         }
  2054.         // 4. Let usingIterator be ? GetMethod(items, @@iterator).
  2055.         var usingIterator = GetMethod(items, Symbol.iterator);
  2056.         // 5. If usingIterator is not undefined, then
  2057.         if (usingIterator !== undefined) {
  2058.             // a. If IsConstructor(C) is true, then
  2059.             if (IsConstructor(C)) {
  2060.                 // i. Let A be ? Construct(C).
  2061.                 var A = Construct(C);
  2062.                 // b. Else,
  2063.             } else {
  2064.                 // i. Let A be ! ArrayCreate(0).
  2065.                 A = ArrayCreate(0);
  2066.             }
  2067.             // c. Let iteratorRecord be ? GetIterator(items, usingIterator).
  2068.             var iteratorRecord = GetIterator(items, usingIterator);
  2069.             // d. Let k be 0.
  2070.             var k = 0;
  2071.             // e. Repeat,
  2072.             while (true) {
  2073.                 // i. If k β‰₯ 2^53-1, then
  2074.                 if (k >= (Math.pow(2, 53) - 1)) {
  2075.                     // 1. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
  2076.                     var error = new TypeError('Iteration count can not be greater than or equal 9007199254740991.');
  2077.                     // 2. Return ? IteratorClose(iteratorRecord, error).
  2078.                     return IteratorClose(iteratorRecord, error);
  2079.                 }
  2080.                 // ii. Let Pk be ! ToString(k).
  2081.                 var Pk = ToString(k);
  2082.                 // iii. Let next be ? IteratorStep(iteratorRecord).
  2083.                 var next = IteratorStep(iteratorRecord);
  2084.                 // iv. If next is false, then
  2085.                 if (next === false) {
  2086.                     // 1. Perform ? Set(A, "length", k, true).
  2087.                     A["length"] = k;
  2088.                     // 2. Return A.
  2089.                     return A;
  2090.                 }
  2091.                 // v. Let nextValue be ? IteratorValue(next).
  2092.                 var nextValue = IteratorValue(next);
  2093.                 // vi. If mapping is true, then
  2094.                 if (mapping) {
  2095.                     try {
  2096.                         // Polyfill.io - The try catch accounts for step 2.
  2097.                         // 1. Let mappedValue be Call(mapfn, T, Β« nextValue, k Β»).
  2098.                         var mappedValue = Call(mapfn, T, [nextValue, k]);
  2099.                         // 2. If mappedValue is an abrupt completion, return ? IteratorClose(iteratorRecord, mappedValue).
  2100.                         // 3. Let mappedValue be mappedValue.[[Value]].
  2101.                     } catch (e) {
  2102.                         return IteratorClose(iteratorRecord, e);
  2103.                     }
  2104.  
  2105.                     // vii. Else, let mappedValue be nextValue.
  2106.                 } else {
  2107.                     mappedValue = nextValue;
  2108.                 }
  2109.                 try {
  2110.                     // Polyfill.io - The try catch accounts for step ix.
  2111.                     // viii. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, mappedValue).
  2112.                     CreateDataPropertyOrThrow(A, Pk, mappedValue);
  2113.                     // ix. If defineStatus is an abrupt completion, return ? IteratorClose(iteratorRecord, defineStatus).
  2114.                 } catch (e) {
  2115.                     return IteratorClose(iteratorRecord, e);
  2116.                 }
  2117.                 // x. Increase k by 1.
  2118.                 k = k + 1;
  2119.             }
  2120.         }
  2121.         // 6. NOTE: items is not an Iterable so assume it is an array-like object.
  2122.         // 7. Let arrayLike be ! ToObject(items).
  2123.         // Polyfill.io - For Strings we need to split astral symbols into surrogate pairs.
  2124.         if (isString(items)) {
  2125.             var arrayLike = stringMatch.call(items, /[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g) || [];
  2126.         } else {
  2127.             arrayLike = ToObject(items);
  2128.         }
  2129.         // 8. Let len be ? ToLength(? Get(arrayLike, "length")).
  2130.         var len = ToLength(Get(arrayLike, "length"));
  2131.         // 9. If IsConstructor(C) is true, then
  2132.         if (IsConstructor(C)) {
  2133.             // a. Let A be ? Construct(C, Β« len Β»).
  2134.             A = Construct(C, [len]);
  2135.             // 10. Else,
  2136.         } else {
  2137.             // a. Let A be ? ArrayCreate(len).
  2138.             A = ArrayCreate(len);
  2139.         }
  2140.         // 11. Let k be 0.
  2141.         k = 0;
  2142.         // 12. Repeat, while k < len
  2143.         while (k < len) {
  2144.             // a. Let Pk be ! ToString(k).
  2145.             Pk = ToString(k);
  2146.             // b. Let kValue be ? Get(arrayLike, Pk).
  2147.             var kValue = Get(arrayLike, Pk);
  2148.             // c. If mapping is true, then
  2149.             if (mapping === true) {
  2150.                 // i. Let mappedValue be ? Call(mapfn, T, Β« kValue, k Β»).
  2151.                 mappedValue = Call(mapfn, T, [kValue, k]);
  2152.                 // d. Else, let mappedValue be kValue.
  2153.             } else {
  2154.                 mappedValue = kValue;
  2155.             }
  2156.             // e. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
  2157.             CreateDataPropertyOrThrow(A, Pk, mappedValue);
  2158.             // f. Increase k by 1.
  2159.             k = k + 1;
  2160.         }
  2161.         // 13. Perform ? Set(A, "length", len, true).
  2162.         A["length"] = len;
  2163.         // 14. Return A.
  2164.         return A;
  2165.     });
  2166. }());
  2167.  
  2168. // Array.of
  2169. /* global ArrayCreate, Construct, CreateDataPropertyOrThrow, CreateMethodProperty, IsConstructor, ToString */
  2170. // 22.1.2.3. Array.of ( ...items )
  2171. CreateMethodProperty(Array, 'of', function of() {
  2172.     // 1. Let len be the actual number of arguments passed to this function.
  2173.     var len = arguments.length;
  2174.     // 2. Let items be the List of arguments passed to this function.
  2175.     var items = arguments;
  2176.     // 3. Let C be the this value.
  2177.     var C = this;
  2178.     // 4. If IsConstructor(C) is true, then
  2179.     if (IsConstructor(C)) {
  2180.         // a. Let A be ? Construct(C, Β« len Β»).
  2181.         var A = Construct(C, [len]);
  2182.         // 5. Else,
  2183.     } else {
  2184.         // a. Let A be ? ArrayCreate(len).
  2185.         var A = ArrayCreate(len);
  2186.     }
  2187.     // 6. Let k be 0.
  2188.     var k = 0;
  2189.     // 7. Repeat, while k < len
  2190.     while (k < len) {
  2191.         // a. Let kValue be items[k].
  2192.         var kValue = items[k];
  2193.         // b. Let Pk be ! ToString(k).
  2194.         var Pk = ToString(k);
  2195.         // c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue).
  2196.         CreateDataPropertyOrThrow(A, Pk, kValue);
  2197.         // d. Increase k by 1.
  2198.         var k = k + 1;
  2199.  
  2200.     }
  2201.     // 8. Perform ? Set(A, "length", len, true)
  2202.     A["length"] = len;
  2203.     // 9. Return A.
  2204.     return A;
  2205. });
  2206.  
  2207. // Array.prototype.fill
  2208. /* global CreateMethodProperty, Get, ToInteger, ToLength, ToObject, ToString */
  2209. // 22.1.3.6. Array.prototype.fill ( value [ , start [ , end ] ] )
  2210. CreateMethodProperty(Array.prototype, 'fill', function fill(value /* [ , start [ , end ] ] */) {
  2211.     var start = arguments[1];
  2212.     var end = arguments[2];
  2213.     // 1. Let O be ? ToObject(this value).
  2214.     var O = ToObject(this);
  2215.     // 2. Let len be ? ToLength(? Get(O, "length")).
  2216.     var len = ToLength(Get(O, "length"));
  2217.     // 3. Let relativeStart be ? ToInteger(start).
  2218.     var relativeStart = ToInteger(start);
  2219.     // 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be min(relativeStart, len)
  2220.     var k = relativeStart < 0 ? Math.max((len + relativeStart), 0) : Math.min(relativeStart, len);
  2221.     // 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
  2222.     var relativeEnd = end === undefined ? len : ToInteger(end);
  2223.     // 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
  2224.     var final = relativeEnd < 0 ? Math.max((len + relativeEnd), 0) : Math.min(relativeEnd, len);
  2225.     // 7. Repeat, while k < final
  2226.     while (k < final) {
  2227.         // a. Let Pk be ! ToString(k).
  2228.         var Pk = ToString(k);
  2229.         // b. Perform ? Set(O, Pk, value, true).
  2230.         O[Pk] = value;
  2231.         // c. Increase k by 1.
  2232.         k = k + 1;
  2233.     }
  2234.     // 8. Return O.
  2235.     return O;
  2236. });
  2237.  
  2238. // Event
  2239. (function () {
  2240.     var unlistenableWindowEvents = {
  2241.         click: 1,
  2242.         dblclick: 1,
  2243.         keyup: 1,
  2244.         keypress: 1,
  2245.         keydown: 1,
  2246.         mousedown: 1,
  2247.         mouseup: 1,
  2248.         mousemove: 1,
  2249.         mouseover: 1,
  2250.         mouseenter: 1,
  2251.         mouseleave: 1,
  2252.         mouseout: 1,
  2253.         storage: 1,
  2254.         storagecommit: 1,
  2255.         textinput: 1
  2256.     };
  2257.  
  2258.     // This polyfill depends on availability of `document` so will not run in a worker
  2259.     // However, we asssume there are no browsers with worker support that lack proper
  2260.     // support for `Event` within the worker
  2261.     if (typeof document === 'undefined' || typeof window === 'undefined') return;
  2262.  
  2263.     function indexOf(array, element) {
  2264.         var
  2265.         index = -1,
  2266.         length = array.length;
  2267.  
  2268.         while (++index < length) {
  2269.             if (index in array && array[index] === element) {
  2270.                 return index;
  2271.             }
  2272.         }
  2273.  
  2274.         return -1;
  2275.     }
  2276.  
  2277.     var existingProto = (window.Event && window.Event.prototype) || null;
  2278.     function Event(type, eventInitDict) {
  2279.         if (!type) {
  2280.             throw new Error('Not enough arguments');
  2281.         }
  2282.  
  2283.         var event;
  2284.         // Shortcut if browser supports createEvent
  2285.         if ('createEvent' in document) {
  2286.             event = document.createEvent('Event');
  2287.             var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
  2288.             var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
  2289.  
  2290.             event.initEvent(type, bubbles, cancelable);
  2291.  
  2292.             return event;
  2293.         }
  2294.  
  2295.         event = document.createEventObject();
  2296.  
  2297.         event.type = type;
  2298.         event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
  2299.         event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
  2300.  
  2301.         return event;
  2302.     };
  2303.     Event.NONE = 0;
  2304.     Event.CAPTURING_PHASE = 1;
  2305.     Event.AT_TARGET = 2;
  2306.     Event.BUBBLING_PHASE = 3;
  2307.     window.Event = Window.prototype.Event = Event;
  2308.     if (existingProto) {
  2309.         Object.defineProperty(window.Event, 'prototype', {
  2310.             configurable: false,
  2311.             enumerable: false,
  2312.             writable: true,
  2313.             value: existingProto
  2314.         });
  2315.     }
  2316.  
  2317.     if (!('createEvent' in document)) {
  2318.         window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
  2319.             var
  2320.             element = this,
  2321.             type = arguments[0],
  2322.             listener = arguments[1];
  2323.  
  2324.             if (element === window && type in unlistenableWindowEvents) {
  2325.                 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.');
  2326.             }
  2327.  
  2328.             if (!element._events) {
  2329.                 element._events = {};
  2330.             }
  2331.  
  2332.             if (!element._events[type]) {
  2333.                 element._events[type] = function (event) {
  2334.                     var
  2335.                     list = element._events[event.type].list,
  2336.                     events = list.slice(),
  2337.                     index = -1,
  2338.                     length = events.length,
  2339.                     eventElement;
  2340.  
  2341.                     event.preventDefault = function preventDefault() {
  2342.                         if (event.cancelable !== false) {
  2343.                             event.returnValue = false;
  2344.                         }
  2345.                     };
  2346.  
  2347.                     event.stopPropagation = function stopPropagation() {
  2348.                         event.cancelBubble = true;
  2349.                     };
  2350.  
  2351.                     event.stopImmediatePropagation = function stopImmediatePropagation() {
  2352.                         event.cancelBubble = true;
  2353.                         event.cancelImmediate = true;
  2354.                     };
  2355.  
  2356.                     event.currentTarget = element;
  2357.                     event.relatedTarget = event.fromElement || null;
  2358.                     event.target = event.target || event.srcElement || element;
  2359.                     event.timeStamp = new Date().getTime();
  2360.  
  2361.                     if (event.clientX) {
  2362.                         event.pageX = event.clientX + document.documentElement.scrollLeft;
  2363.                         event.pageY = event.clientY + document.documentElement.scrollTop;
  2364.                     }
  2365.  
  2366.                     while (++index < length && !event.cancelImmediate) {
  2367.                         if (index in events) {
  2368.                             eventElement = events[index];
  2369.  
  2370.                             if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
  2371.                                 eventElement.call(element, event);
  2372.                             }
  2373.                         }
  2374.                     }
  2375.                 };
  2376.  
  2377.                 element._events[type].list = [];
  2378.  
  2379.                 if (element.attachEvent) {
  2380.                     element.attachEvent('on' + type, element._events[type]);
  2381.                 }
  2382.             }
  2383.  
  2384.             element._events[type].list.push(listener);
  2385.         };
  2386.  
  2387.         window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
  2388.             var
  2389.             element = this,
  2390.             type = arguments[0],
  2391.             listener = arguments[1],
  2392.             index;
  2393.  
  2394.             if (element._events && element._events[type] && element._events[type].list) {
  2395.                 index = indexOf(element._events[type].list, listener);
  2396.  
  2397.                 if (index !== -1) {
  2398.                     element._events[type].list.splice(index, 1);
  2399.  
  2400.                     if (!element._events[type].list.length) {
  2401.                         if (element.detachEvent) {
  2402.                             element.detachEvent('on' + type, element._events[type]);
  2403.                         }
  2404.                         delete element._events[type];
  2405.                     }
  2406.                 }
  2407.             }
  2408.         };
  2409.  
  2410.         window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
  2411.             if (!arguments.length) {
  2412.                 throw new Error('Not enough arguments');
  2413.             }
  2414.  
  2415.             if (!event || typeof event.type !== 'string') {
  2416.                 throw new Error('DOM Events Exception 0');
  2417.             }
  2418.  
  2419.             var element = this, type = event.type;
  2420.  
  2421.             try {
  2422.                 if (!event.bubbles) {
  2423.                     event.cancelBubble = true;
  2424.  
  2425.                     var cancelBubbleEvent = function (event) {
  2426.                         event.cancelBubble = true;
  2427.  
  2428.                         (element || window).detachEvent('on' + type, cancelBubbleEvent);
  2429.                     };
  2430.  
  2431.                     this.attachEvent('on' + type, cancelBubbleEvent);
  2432.                 }
  2433.  
  2434.                 this.fireEvent('on' + type, event);
  2435.             } catch (error) {
  2436.                 event.target = element;
  2437.  
  2438.                 do {
  2439.                     event.currentTarget = element;
  2440.  
  2441.                     if ('_events' in element && typeof element._events[type] === 'function') {
  2442.                         element._events[type].call(element, event);
  2443.                     }
  2444.  
  2445.                     if (typeof element['on' + type] === 'function') {
  2446.                         element['on' + type].call(element, event);
  2447.                     }
  2448.  
  2449.                     element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
  2450.                 } while (element && !event.cancelBubble);
  2451.             }
  2452.  
  2453.             return true;
  2454.         };
  2455.  
  2456.         // Add the DOMContentLoaded Event
  2457.         document.attachEvent('onreadystatechange', function() {
  2458.             if (document.readyState === 'complete') {
  2459.                 document.dispatchEvent(new Event('DOMContentLoaded', {
  2460.                     bubbles: true
  2461.                 }));
  2462.             }
  2463.         });
  2464.     }
  2465. }());
  2466.  
  2467. // CustomEvent
  2468. this.CustomEvent = function CustomEvent(type, eventInitDict) {
  2469.     if (!type) {
  2470.         throw Error('TypeError: Failed to construct "CustomEvent": An event name must be provided.');
  2471.     }
  2472.  
  2473.     var event;
  2474.     eventInitDict = eventInitDict || {bubbles: false, cancelable: false, detail: null};
  2475.  
  2476.     if ('createEvent' in document) {
  2477.         try {
  2478.             event = document.createEvent('CustomEvent');
  2479.             event.initCustomEvent(type, eventInitDict.bubbles, eventInitDict.cancelable, eventInitDict.detail);
  2480.         } catch (error) {
  2481.             // for browsers which don't support CustomEvent at all, we use a regular event instead
  2482.             event = document.createEvent('Event');
  2483.             event.initEvent(type, eventInitDict.bubbles, eventInitDict.cancelable);
  2484.             event.detail = eventInitDict.detail;
  2485.         }
  2486.     } else {
  2487.  
  2488.         // IE8
  2489.         event = new Event(type, eventInitDict);
  2490.         event.detail = eventInitDict && eventInitDict.detail || null;
  2491.     }
  2492.     return event;
  2493. };
  2494.  
  2495. CustomEvent.prototype = Event.prototype;
  2496.  
  2497. // _DOMTokenList
  2498. /*
  2499. Copyright (c) 2016, John Gardner
  2500.  
  2501. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
  2502.  
  2503. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  2504. */
  2505. var _DOMTokenList = (function() { // eslint-disable-line no-unused-vars
  2506.     var dpSupport = true;
  2507.     var defineGetter = function (object, name, fn, configurable) {
  2508.         if (Object.defineProperty)
  2509.             Object.defineProperty(object, name, {
  2510.                 configurable: false === dpSupport ? true : !!configurable,
  2511.                 get: fn
  2512.             });
  2513.  
  2514.         else object.__defineGetter__(name, fn);
  2515.     };
  2516.  
  2517.     /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
  2518.     try {
  2519.         defineGetter({}, "support");
  2520.     }
  2521.     catch (e) {
  2522.         dpSupport = false;
  2523.     }
  2524.  
  2525.  
  2526.     var _DOMTokenList = function (el, prop) {
  2527.         var that = this;
  2528.         var tokens = [];
  2529.         var tokenMap = {};
  2530.         var length = 0;
  2531.         var maxLength = 0;
  2532.         var addIndexGetter = function (i) {
  2533.             defineGetter(that, i, function () {
  2534.                 preop();
  2535.                 return tokens[i];
  2536.             }, false);
  2537.  
  2538.         };
  2539.         var reindex = function () {
  2540.  
  2541.             /** Define getter functions for array-like access to the tokenList's contents. */
  2542.             if (length >= maxLength)
  2543.                 for (; maxLength < length; ++maxLength) {
  2544.                     addIndexGetter(maxLength);
  2545.                 }
  2546.         };
  2547.  
  2548.         /** Helper function called at the start of each class method. Internal use only. */
  2549.         var preop = function () {
  2550.             var error;
  2551.             var i;
  2552.             var args = arguments;
  2553.             var rSpace = /\s+/;
  2554.  
  2555.             /** Validate the token/s passed to an instance method, if any. */
  2556.             if (args.length)
  2557.                 for (i = 0; i < args.length; ++i)
  2558.                     if (rSpace.test(args[i])) {
  2559.                         error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
  2560.                         error.code = 5;
  2561.                         error.name = "InvalidCharacterError";
  2562.                         throw error;
  2563.                     }
  2564.  
  2565.  
  2566.             /** Split the new value apart by whitespace*/
  2567.             if (typeof el[prop] === "object") {
  2568.                 tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
  2569.             } else {
  2570.                 tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
  2571.             }
  2572.  
  2573.             /** Avoid treating blank strings as single-item token lists */
  2574.             if ("" === tokens[0]) tokens = [];
  2575.  
  2576.             /** Repopulate the internal token lists */
  2577.             tokenMap = {};
  2578.             for (i = 0; i < tokens.length; ++i)
  2579.                 tokenMap[tokens[i]] = true;
  2580.             length = tokens.length;
  2581.             reindex();
  2582.         };
  2583.  
  2584.         /** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
  2585.         preop();
  2586.  
  2587.         /** Return the number of tokens in the underlying string. Read-only. */
  2588.         defineGetter(that, "length", function () {
  2589.             preop();
  2590.             return length;
  2591.         });
  2592.  
  2593.         /** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
  2594.         that.toLocaleString =
  2595.             that.toString = function () {
  2596.                 preop();
  2597.                 return tokens.join(" ");
  2598.             };
  2599.  
  2600.         that.item = function (idx) {
  2601.             preop();
  2602.             return tokens[idx];
  2603.         };
  2604.  
  2605.         that.contains = function (token) {
  2606.             preop();
  2607.             return !!tokenMap[token];
  2608.         };
  2609.  
  2610.         that.add = function () {
  2611.             preop.apply(that, args = arguments);
  2612.  
  2613.             for (var args, token, i = 0, l = args.length; i < l; ++i) {
  2614.                 token = args[i];
  2615.                 if (!tokenMap[token]) {
  2616.                     tokens.push(token);
  2617.                     tokenMap[token] = true;
  2618.                 }
  2619.             }
  2620.  
  2621.             /** Update the targeted attribute of the attached element if the token list's changed. */
  2622.             if (length !== tokens.length) {
  2623.                 length = tokens.length >>> 0;
  2624.                 if (typeof el[prop] === "object") {
  2625.                     el[prop].baseVal = tokens.join(" ");
  2626.                 } else {
  2627.                     el[prop] = tokens.join(" ");
  2628.                 }
  2629.                 reindex();
  2630.             }
  2631.         };
  2632.  
  2633.         that.remove = function () {
  2634.             preop.apply(that, args = arguments);
  2635.  
  2636.             /** Build a hash of token names to compare against when recollecting our token list. */
  2637.             for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
  2638.                 ignore[args[i]] = true;
  2639.                 delete tokenMap[args[i]];
  2640.             }
  2641.  
  2642.             /** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
  2643.             for (i = 0; i < tokens.length; ++i)
  2644.                 if (!ignore[tokens[i]]) t.push(tokens[i]);
  2645.  
  2646.             tokens = t;
  2647.             length = t.length >>> 0;
  2648.  
  2649.             /** Update the targeted attribute of the attached element. */
  2650.             if (typeof el[prop] === "object") {
  2651.                 el[prop].baseVal = tokens.join(" ");
  2652.             } else {
  2653.                 el[prop] = tokens.join(" ");
  2654.             }
  2655.             reindex();
  2656.         };
  2657.  
  2658.         that.toggle = function (token, force) {
  2659.             preop.apply(that, [token]);
  2660.  
  2661.             /** Token state's being forced. */
  2662.             if (undefined !== force) {
  2663.                 if (force) {
  2664.                     that.add(token);
  2665.                     return true;
  2666.                 } else {
  2667.                     that.remove(token);
  2668.                     return false;
  2669.                 }
  2670.             }
  2671.  
  2672.             /** Token already exists in tokenList. Remove it, and return FALSE. */
  2673.             if (tokenMap[token]) {
  2674.                 that.remove(token);
  2675.                 return false;
  2676.             }
  2677.  
  2678.             /** Otherwise, add the token and return TRUE. */
  2679.             that.add(token);
  2680.             return true;
  2681.         };
  2682.  
  2683.         return that;
  2684.     };
  2685.  
  2686.     return _DOMTokenList;
  2687. }());
  2688.  
  2689. // DOMTokenList
  2690. (function (global) {
  2691.     var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
  2692.  
  2693.     if (
  2694.             !nativeImpl ||
  2695.             (
  2696.                 !!document.createElementNS &&
  2697.                 !!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
  2698.                 !(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
  2699.             )
  2700.         ) {
  2701.         global.DOMTokenList = _DOMTokenList;
  2702.     }
  2703.  
  2704.     // Add second argument to native DOMTokenList.toggle() if necessary
  2705.     (function () {
  2706.         var e = document.createElement('span');
  2707.         if (!('classList' in e)) return;
  2708.         e.classList.toggle('x', false);
  2709.         if (!e.classList.contains('x')) return;
  2710.         e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
  2711.             var force = arguments[1];
  2712.             if (force === undefined) {
  2713.                 var add = !this.contains(token);
  2714.                 this[add ? 'add' : 'remove'](token);
  2715.                 return add;
  2716.             }
  2717.             force = !!force;
  2718.             this[force ? 'add' : 'remove'](token);
  2719.             return force;
  2720.         };
  2721.     }());
  2722.  
  2723.     // Add multiple arguments to native DOMTokenList.add() if necessary
  2724.     (function () {
  2725.         var e = document.createElement('span');
  2726.         if (!('classList' in e)) return;
  2727.         e.classList.add('a', 'b');
  2728.         if (e.classList.contains('b')) return;
  2729.         var native = e.classList.constructor.prototype.add;
  2730.         e.classList.constructor.prototype.add = function () {
  2731.             var args = arguments;
  2732.             var l = arguments.length;
  2733.             for (var i = 0; i < l; i++) {
  2734.                 native.call(this, args[i]);
  2735.             }
  2736.         };
  2737.     }());
  2738.  
  2739.     // Add multiple arguments to native DOMTokenList.remove() if necessary
  2740.     (function () {
  2741.         var e = document.createElement('span');
  2742.         if (!('classList' in e)) return;
  2743.         e.classList.add('a');
  2744.         e.classList.add('b');
  2745.         e.classList.remove('a', 'b');
  2746.         if (!e.classList.contains('b')) return;
  2747.         var native = e.classList.constructor.prototype.remove;
  2748.         e.classList.constructor.prototype.remove = function () {
  2749.             var args = arguments;
  2750.             var l = arguments.length;
  2751.             for (var i = 0; i < l; i++) {
  2752.                 native.call(this, args[i]);
  2753.             }
  2754.         };
  2755.     }());
  2756.  
  2757. }(this));
  2758.  
  2759. // _mutation
  2760. var _mutation = (function () { // eslint-disable-line no-unused-vars
  2761.  
  2762.     function isNode(object) {
  2763.         // DOM, Level2
  2764.         if (typeof Node === 'function') {
  2765.             return object instanceof Node;
  2766.         }
  2767.         // Older browsers, check if it looks like a Node instance)
  2768.         return object &&
  2769.             typeof object === "object" &&
  2770.             object.nodeName &&
  2771.             object.nodeType >= 1 &&
  2772.             object.nodeType <= 12;
  2773.     }
  2774.  
  2775.     // http://dom.spec.whatwg.org/#mutation-method-macro
  2776.     return function mutation(nodes) {
  2777.         if (nodes.length === 1) {
  2778.             return isNode(nodes[0]) ? nodes[0] : document.createTextNode(nodes[0] + '');
  2779.         }
  2780.  
  2781.         var fragment = document.createDocumentFragment();
  2782.         for (var i = 0; i < nodes.length; i++) {
  2783.             fragment.appendChild(isNode(nodes[i]) ? nodes[i] : document.createTextNode(nodes[i] + ''));
  2784.  
  2785.         }
  2786.         return fragment;
  2787.     };
  2788. }());
  2789.  
  2790. // DocumentFragment.prototype.append
  2791. DocumentFragment.prototype.append = function append() {
  2792.     this.appendChild(_mutation(arguments));
  2793. };
  2794.  
  2795. // DocumentFragment.prototype.prepend
  2796. DocumentFragment.prototype.prepend = function prepend() {
  2797.     this.insertBefore(_mutation(arguments), this.firstChild);
  2798. };
  2799.  
  2800. // Element.prototype.after
  2801. Document.prototype.after = Element.prototype.after = function after() {
  2802.     if (this.parentNode) {
  2803.         var args = Array.prototype.slice.call(arguments),
  2804.                 viableNextSibling = this.nextSibling,
  2805.                 idx = viableNextSibling ? args.indexOf(viableNextSibling) : -1;
  2806.  
  2807.         while (idx !== -1) {
  2808.             viableNextSibling = viableNextSibling.nextSibling;
  2809.             if (!viableNextSibling) {
  2810.                 break;
  2811.             }
  2812.             idx = args.indexOf(viableNextSibling);
  2813.         }
  2814.        
  2815.         this.parentNode.insertBefore(_mutation(arguments), viableNextSibling);
  2816.     }
  2817. };
  2818.  
  2819. // Not all UAs support the Text constructor.  Polyfill on the Text constructor only where it exists
  2820. // TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
  2821. if ("Text" in this) {
  2822.     Text.prototype.after = Element.prototype.after;
  2823. }
  2824.  
  2825. // Element.prototype.append
  2826. Document.prototype.append = Element.prototype.append = function append() {
  2827.     this.appendChild(_mutation(arguments));
  2828. };
  2829.  
  2830. // Element.prototype.before
  2831. Document.prototype.before = Element.prototype.before = function before() {
  2832.     if (this.parentNode) {
  2833.         var args = Array.prototype.slice.call(arguments),
  2834.             viablePreviousSibling = this.previousSibling,
  2835.             idx = viablePreviousSibling ? args.indexOf(viablePreviousSibling) : -1;
  2836.  
  2837.         while (idx !== -1) {
  2838.             viablePreviousSibling = viablePreviousSibling.previousSibling;
  2839.             if (!viablePreviousSibling) {
  2840.                 break;
  2841.             }
  2842.             idx = args.indexOf(viablePreviousSibling);
  2843.         }
  2844.  
  2845.         this.parentNode.insertBefore(
  2846.             _mutation(arguments),
  2847.             viablePreviousSibling ? viablePreviousSibling.nextSibling : this.parentNode.firstChild
  2848.         );
  2849.     }
  2850. };
  2851.  
  2852. // Not all UAs support the Text constructor.  Polyfill on the Text constructor only where it exists
  2853. // TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
  2854. if ("Text" in this) {
  2855.     Text.prototype.before = Element.prototype.before;
  2856. }
  2857.  
  2858. // Element.prototype.classList
  2859. /*
  2860. Copyright (c) 2016, John Gardner
  2861.  
  2862. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
  2863.  
  2864. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  2865. */
  2866. (function (global) {
  2867.     var dpSupport = true;
  2868.     var defineGetter = function (object, name, fn, configurable) {
  2869.         if (Object.defineProperty)
  2870.             Object.defineProperty(object, name, {
  2871.                 configurable: false === dpSupport ? true : !!configurable,
  2872.                 get: fn
  2873.             });
  2874.  
  2875.         else object.__defineGetter__(name, fn);
  2876.     };
  2877.     /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
  2878.     try {
  2879.         defineGetter({}, "support");
  2880.     }
  2881.     catch (e) {
  2882.         dpSupport = false;
  2883.     }
  2884.     /** Polyfills a property with a DOMTokenList */
  2885.     var addProp = function (o, name, attr) {
  2886.  
  2887.         defineGetter(o.prototype, name, function () {
  2888.             var tokenList;
  2889.  
  2890.             var THIS = this,
  2891.  
  2892.             /** Prevent this from firing twice for some reason. What the hell, IE. */
  2893.             gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
  2894.             if(THIS[gibberishProperty]) return tokenList;
  2895.             THIS[gibberishProperty] = true;
  2896.  
  2897.             /**
  2898.              * IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
  2899.              *
  2900.              * What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
  2901.              * that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
  2902.              * element instead, this would conflict with element types which use indexed properties (such as forms and
  2903.              * select lists).
  2904.              */
  2905.             if (false === dpSupport) {
  2906.  
  2907.                 var visage;
  2908.                 var mirror = addProp.mirror || document.createElement("div");
  2909.                 var reflections = mirror.childNodes;
  2910.                 var l = reflections.length;
  2911.  
  2912.                 for (var i = 0; i < l; ++i)
  2913.                     if (reflections[i]._R === THIS) {
  2914.                         visage = reflections[i];
  2915.                         break;
  2916.                     }
  2917.  
  2918.                 /** Couldn't find an element's reflection inside the mirror. Materialise one. */
  2919.                 visage || (visage = mirror.appendChild(document.createElement("div")));
  2920.  
  2921.                 tokenList = DOMTokenList.call(visage, THIS, attr);
  2922.             } else tokenList = new DOMTokenList(THIS, attr);
  2923.  
  2924.             defineGetter(THIS, name, function () {
  2925.                 return tokenList;
  2926.             });
  2927.             delete THIS[gibberishProperty];
  2928.  
  2929.             return tokenList;
  2930.         }, true);
  2931.     };
  2932.  
  2933.     addProp(global.Element, "classList", "className");
  2934.     addProp(global.HTMLElement, "classList", "className");
  2935.     addProp(global.HTMLLinkElement, "relList", "rel");
  2936.     addProp(global.HTMLAnchorElement, "relList", "rel");
  2937.     addProp(global.HTMLAreaElement, "relList", "rel");
  2938. }(this));
  2939.  
  2940. // Element.prototype.matches
  2941. Element.prototype.matches = Element.prototype.webkitMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || function matches(selector) {
  2942.  
  2943.     var element = this;
  2944.     var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
  2945.     var index = 0;
  2946.  
  2947.     while (elements[index] && elements[index] !== element) {
  2948.         ++index;
  2949.     }
  2950.  
  2951.     return !!elements[index];
  2952. };
  2953.  
  2954. // Element.prototype.closest
  2955. Element.prototype.closest = function closest(selector) {
  2956.     var node = this;
  2957.  
  2958.     while (node) {
  2959.         if (node.matches(selector)) return node;
  2960.         else node = 'SVGElement' in window && node instanceof SVGElement ? node.parentNode : node.parentElement;
  2961.     }
  2962.  
  2963.     return null;
  2964. };
  2965.  
  2966. // Element.prototype.prepend
  2967. Document.prototype.prepend = Element.prototype.prepend = function prepend() {
  2968.     this.insertBefore(_mutation(arguments), this.firstChild);
  2969. };
  2970.  
  2971. // Element.prototype.remove
  2972. Document.prototype.remove = Element.prototype.remove = function remove() {
  2973.     if (this.parentNode) {
  2974.         this.parentNode.removeChild(this);
  2975.     }
  2976. };
  2977.  
  2978. // Not all UAs support the Text constructor.  Polyfill on the Text constructor only where it exists
  2979. // TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
  2980. if ("Text" in this) {
  2981.     Text.prototype.remove = Element.prototype.remove;
  2982. }
  2983.  
  2984. // Element.prototype.replaceWith
  2985. Document.prototype.replaceWith = Element.prototype.replaceWith = function replaceWith() {
  2986.     if (this.parentNode) {
  2987.         this.parentNode.replaceChild(_mutation(arguments), this);
  2988.     }
  2989. };
  2990.  
  2991. // Not all UAs support the Text constructor.  Polyfill on the Text constructor only where it exists
  2992. // TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
  2993. if ('Text' in this) {
  2994.     Text.prototype.replaceWith = Element.prototype.replaceWith;
  2995. }
  2996.  
  2997. // Node.prototype.contains
  2998. (function() {
  2999.  
  3000.     function contains(node) {
  3001.         if (!(0 in arguments)) {
  3002.             throw new TypeError('1 argument is required');
  3003.         }
  3004.  
  3005.         do {
  3006.             if (this === node) {
  3007.                 return true;
  3008.             }
  3009.         } while (node = node && node.parentNode);
  3010.  
  3011.         return false;
  3012.     }
  3013.  
  3014.     // IE
  3015.     if ('HTMLElement' in this && 'contains' in HTMLElement.prototype) {
  3016.         try {
  3017.             delete HTMLElement.prototype.contains;
  3018.         } catch (e) {}
  3019.     }
  3020.  
  3021.     if ('Node' in this) {
  3022.         Node.prototype.contains = contains;
  3023.     } else {
  3024.         document.contains = Element.prototype.contains = contains;
  3025.     }
  3026.  
  3027. }());
  3028.  
  3029. // Number.isNaN
  3030. /* global CreateMethodProperty, Type */
  3031. (function () {
  3032.     var that = this;
  3033.     // 20.1.2.4. Number.isNaN ( number )
  3034.     CreateMethodProperty(Number, 'isNaN', function isNaN(number) {
  3035.         // 1. If Type(number) is not Number, return false.
  3036.         if (Type(number) !== 'number') {
  3037.             return false;
  3038.         }
  3039.         // 2. If number is NaN, return true.
  3040.         if (that.isNaN(number)) {
  3041.             return true;
  3042.         }
  3043.         // 3. Otherwise, return false.
  3044.         return false;
  3045.     });
  3046. }());
  3047.  
  3048. // Object.assign
  3049. /* global CreateMethodProperty, Get, ToObject */
  3050. // 19.1.2.1 Object.assign ( target, ...sources )
  3051. CreateMethodProperty(Object, 'assign', function assign(target, source) { // eslint-disable-line no-unused-vars
  3052.     // 1. Let to be ? ToObject(target).
  3053.     var to = ToObject(target);
  3054.  
  3055.     // 2. If only one argument was passed, return to.
  3056.     if (arguments.length === 1) {
  3057.         return to;
  3058.     }
  3059.  
  3060.     // 3. Let sources be the List of argument values starting with the second argument
  3061.     var sources = Array.prototype.slice.call(arguments, 1);
  3062.  
  3063.     // 4. For each element nextSource of sources, in ascending index order, do
  3064.     var index1;
  3065.     var index2;
  3066.     var keys;
  3067.     var from;
  3068.     for (index1 = 0; index1 < sources.length; index1++) {
  3069.         var nextSource = sources[index1];
  3070.         // a. If nextSource is undefined or null, let keys be a new empty List.
  3071.         if (nextSource === undefined || nextSource === null) {
  3072.             keys = [];
  3073.             // b. Else,
  3074.         } else {
  3075.             // i. Let from be ! ToObject(nextSource).
  3076.             from = ToObject(nextSource);
  3077.             // ii. Let keys be ? from.[[OwnPropertyKeys]]().
  3078.             /*
  3079.                 This step in our polyfill is not complying with the specification.
  3080.                 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
  3081.                 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
  3082.             */
  3083.             keys = Object.keys(from);
  3084.         }
  3085.  
  3086.         // c. For each element nextKey of keys in List order, do
  3087.         for (index2 = 0; index2 < keys.length; index2++) {
  3088.             var nextKey = keys[index2];
  3089.             // i. Let desc be ? from.[[GetOwnProperty]](nextKey).
  3090.             var desc = Object.getOwnPropertyDescriptor(from, nextKey);
  3091.             // ii. If desc is not undefined and desc.[[Enumerable]] is true, then
  3092.             if (desc !== undefined && desc.enumerable) {
  3093.                 // 1. Let propValue be ? Get(from, nextKey).
  3094.                 var propValue = Get(from, nextKey);
  3095.                 // 2. Perform ? Set(to, nextKey, propValue, true).
  3096.                 to[nextKey] = propValue;
  3097.             }
  3098.         }
  3099.     }
  3100.     // 5. Return to.
  3101.     return to;
  3102. });
  3103.  
  3104. // Promise
  3105. !function(n){function t(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var e={};t.m=n,t.c=e,t.i=function(n){return n},t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:r})},t.n=function(n){var e=n&&n.__esModule?function(){return n["default"]}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},t.p="",t(t.s=100)}({100:/*!***********************!*\
  3106.   !*** ./src/global.js ***!
  3107.   \***********************/
  3108. function(n,t,e){(function(n){var t=e(/*! ./yaku */5);try{n.Promise=t,window.Promise=t}catch(r){}}).call(t,e(/*! ./../~/webpack/buildin/global.js */2))},2:/*!***********************************!*\
  3109.   !*** (webpack)/buildin/global.js ***!
  3110.   \***********************************/
  3111. function(n,t){var e;e=function(){return this}();try{e=e||Function("return this")()||(0,eval)("this")}catch(r){"object"==typeof window&&(e=window)}n.exports=e},5:/*!*********************!*\
  3112.   !*** ./src/yaku.js ***!
  3113.   \*********************/
  3114. function(n,t,e){(function(t){!function(){"use strict";function e(){return rn[q][B]||D}function r(n){return n&&"object"==typeof n}function o(n){return"function"==typeof n}function i(n,t){return n instanceof t}function u(n){return i(n,M)}function c(n,t,e){if(!t(n))throw h(e)}function f(){try{return R.apply(S,arguments)}catch(n){return nn.e=n,nn}}function s(n,t){return R=n,S=t,f}function a(n,t){function e(){for(var e=0;e<o;)t(r[e],r[e+1]),r[e++]=P,r[e++]=P;o=0,r.length>n&&(r.length=n)}var r=A(n),o=0;return function(n,t){r[o++]=n,r[o++]=t,2===o&&rn.nextTick(e)}}function l(n,t){var e,r,u,c,f=0;if(!n)throw h(Q);var a=n[rn[q][z]];if(o(a))r=a.call(n);else{if(!o(n.next)){if(i(n,A)){for(e=n.length;f<e;)t(n[f],f++);return f}throw h(Q)}r=n}for(;!(u=r.next()).done;)if((c=s(t)(u.value,f++))===nn)throw o(r[G])&&r[G](),c.e;return f}function h(n){return new TypeError(n)}function v(n){return(n?"":V)+(new M).stack}function _(n,t){var e="on"+n.toLowerCase(),r=O[e];H&&H.listeners(n).length?n===Z?H.emit(n,t._v,t):H.emit(n,t):r?r({reason:t._v,promise:t}):rn[n](t._v,t)}function p(n){return n&&n._s}function d(n){if(p(n))return new n(tn);var t,e,r;return t=new n(function(n,o){if(t)throw h();e=n,r=o}),c(e,o),c(r,o),t}function w(n,t){var e=!1;return function(r){e||(e=!0,L&&(n[N]=v(!0)),t===Y?k(n,r):x(n,t,r))}}function y(n,t,e,r){return o(e)&&(t._onFulfilled=e),o(r)&&(n[J]&&_(X,n),t._onRejected=r),L&&(t._p=n),n[n._c++]=t,n._s!==$&&on(n,t),t}function m(n){if(n._umark)return!0;n._umark=!0;for(var t,e=0,r=n._c;e<r;)if(t=n[e++],t._onRejected||m(t))return!0}function j(n,t){function e(n){return r.push(n.replace(/^\s+|\s+$/g,""))}var r=[];return L&&(t[N]&&e(t[N]),function o(n){n&&K in n&&(o(n._next),e(n[K]+""),o(n._p))}(t)),(n&&n.stack?n.stack:n)+("\n"+r.join("\n")).replace(en,"")}function g(n,t){return n(t)}function x(n,t,e){var r=0,o=n._c;if(n._s===$)for(n._s=t,n._v=e,t===U&&(L&&u(e)&&(e.longStack=j(e,n)),un(n));r<o;)on(n,n[r++]);return n}function k(n,t){if(t===n&&t)return x(n,U,h(W)),n;if(t!==C&&(o(t)||r(t))){var e=s(b)(t);if(e===nn)return x(n,U,e.e),n;o(e)?(L&&p(t)&&(n._next=t),p(t)?T(n,t,e):rn.nextTick(function(){T(n,t,e)})):x(n,Y,t)}else x(n,Y,t);return n}function b(n){return n.then}function T(n,t,e){var r=s(e,t)(function(e){t&&(t=C,k(n,e))},function(e){t&&(t=C,x(n,U,e))});r===nn&&t&&(x(n,U,r.e),t=C)}var P,R,S,C=null,F="object"==typeof self,O=F?self:t,E=O.Promise,H=O.process,I=O.console,L=!1,A=Array,M=Error,U=1,Y=2,$=3,q="Symbol",z="iterator",B="species",D=q+"("+B+")",G="return",J="_uh",K="_pt",N="_st",Q="Invalid argument",V="\nFrom previous ",W="Chaining cycle detected for promise",X="rejectionHandled",Z="unhandledRejection",nn={e:C},tn=function(){},en=/^.+\/node_modules\/yaku\/.+\n?/gm,rn=function(n){var t,e=this;if(!r(e)||e._s!==P)throw h("Invalid this");if(e._s=$,L&&(e[K]=v()),n!==tn){if(!o(n))throw h(Q);t=s(n)(w(e,Y),w(e,U)),t===nn&&x(e,U,t.e)}};rn["default"]=rn,function(n,t){for(var e in t)n[e]=t[e]}(rn.prototype,{then:function(n,t){if(this._s===undefined)throw h();return y(this,d(rn.speciesConstructor(this,rn)),n,t)},"catch":function(n){return this.then(P,n)},"finally":function(n){return this.then(function(t){return rn.resolve(n()).then(function(){return t})},function(t){return rn.resolve(n()).then(function(){throw t})})},_c:0,_p:C}),rn.resolve=function(n){return p(n)?n:k(d(this),n)},rn.reject=function(n){return x(d(this),U,n)},rn.race=function(n){var t=this,e=d(t),r=function(n){x(e,Y,n)},o=function(n){x(e,U,n)},i=s(l)(n,function(n){t.resolve(n).then(r,o)});return i===nn?t.reject(i.e):e},rn.all=function(n){function t(n){x(o,U,n)}var e,r=this,o=d(r),i=[];return(e=s(l)(n,function(n,u){r.resolve(n).then(function(n){i[u]=n,--e||x(o,Y,i)},t)}))===nn?r.reject(e.e):(e||x(o,Y,[]),o)},rn.Symbol=O[q]||{},s(function(){Object.defineProperty(rn,e(),{get:function(){return this}})})(),rn.speciesConstructor=function(n,t){var r=n.constructor;return r?r[e()]||t:t},rn.unhandledRejection=function(n,t){I&&I.error("Uncaught (in promise)",L?t.longStack:j(n,t))},rn.rejectionHandled=tn,rn.enableLongStackTrace=function(){L=!0},rn.nextTick=F?function(n){E?new E(function(n){n()}).then(n):setTimeout(n)}:H.nextTick,rn._s=1;var on=a(999,function(n,t){var e,r;return(r=n._s!==U?t._onFulfilled:t._onRejected)===P?void x(t,n._s,n._v):(e=s(g)(r,n._v))===nn?void x(t,U,e.e):void k(t,e)}),un=a(9,function(n){m(n)||(n[J]=1,_(Z,n))});try{n.exports=rn}catch(cn){O.Yaku=rn}}()}).call(t,e(/*! ./../~/webpack/buildin/global.js */2))}});
  3115. // _ESAbstract.RequireObjectCoercible
  3116. // 7.2.1. RequireObjectCoercible ( argument )
  3117. // The abstract operation ToObject converts argument to a value of type Object according to Table 12:
  3118. // Table 12: ToObject Conversions
  3119. /*
  3120. |----------------------------------------------------------------------------------------------------------------------------------------------------|
  3121. | Argument Type | Result                                                                                                                             |
  3122. |----------------------------------------------------------------------------------------------------------------------------------------------------|
  3123. | Undefined     | Throw a TypeError exception.                                                                                                       |
  3124. | Null          | Throw a TypeError exception.                                                                                                       |
  3125. | Boolean       | Return argument.                                                                                                                   |
  3126. | Number        | Return argument.                                                                                                                   |
  3127. | String        | Return argument.                                                                                                                   |
  3128. | Symbol        | Return argument.                                                                                                                   |
  3129. | Object        | Return argument.                                                                                                                   |
  3130. |----------------------------------------------------------------------------------------------------------------------------------------------------|
  3131. */
  3132. function RequireObjectCoercible(argument) { // eslint-disable-line no-unused-vars
  3133.     if (argument === null || argument === undefined) {
  3134.         throw TypeError();
  3135.     }
  3136.   return argument;
  3137. }
  3138.  
  3139. // _ESAbstract.IsRegExp
  3140. /* global Type, Get, ToBoolean */
  3141. // 7.2.8. IsRegExp ( argument )
  3142. function IsRegExp(argument) { // eslint-disable-line no-unused-vars
  3143.     // 1. If Type(argument) is not Object, return false.
  3144.     if (Type(argument) !== 'object') {
  3145.         return false;
  3146.     }
  3147.     // 2. Let matcher be ? Get(argument, @@match).
  3148.     var matcher = 'Symbol' in this && 'match' in this.Symbol ? Get(argument, this.Symbol.match) : undefined;
  3149.     // 3. If matcher is not undefined, return ToBoolean(matcher).
  3150.     if (matcher !== undefined) {
  3151.         return ToBoolean(matcher);
  3152.     }
  3153.     // 4. If argument has a [[RegExpMatcher]] internal slot, return true.
  3154.     try {
  3155.         var lastIndex = argument.lastIndex;
  3156.         argument.lastIndex = 0;
  3157.         RegExp.prototype.exec.call(argument);
  3158.         return true;
  3159.     } catch (e) {} finally {
  3160.         argument.lastIndex = lastIndex;
  3161.     }
  3162.     // 5. Return false.
  3163.     return false;
  3164. }
  3165.  
  3166. // String.prototype.endsWith
  3167. /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
  3168. // 21.1.3.6. String.prototype.endsWith ( searchString [ , endPosition ] )
  3169. CreateMethodProperty(String.prototype, 'endsWith', function endsWith(searchString /* [ , endPosition ] */) {
  3170.     'use strict';
  3171.     var endPosition = arguments.length > 1 ? arguments[1] : undefined;
  3172.     // 1. Let O be ? RequireObjectCoercible(this value).
  3173.     var O = RequireObjectCoercible(this);
  3174.     // 2. Let S be ? ToString(O).
  3175.     var S = ToString(O);
  3176.     // 3. Let isRegExp be ? IsRegExp(searchString).
  3177.     var isRegExp = IsRegExp(searchString);
  3178.     // 4. If isRegExp is true, throw a TypeError exception.
  3179.     if (isRegExp) {
  3180.         throw new TypeError('First argument to String.prototype.endsWith must not be a regular expression');
  3181.     }
  3182.     // 5. Let searchStr be ? ToString(searchString).
  3183.     var searchStr = ToString(searchString);
  3184.     // 6. Let len be the length of S.
  3185.     var len = S.length;
  3186.     // 7. If endPosition is undefined, let pos be len, else let pos be ? ToInteger(endPosition).
  3187.     var pos = endPosition === undefined ? len : ToInteger(endPosition);
  3188.     // 8. Let end be min(max(pos, 0), len).
  3189.     var end = Math.min(Math.max(pos, 0), len);
  3190.     // 9. Let searchLength be the length of searchStr.
  3191.     var searchLength = searchStr.length;
  3192.     // 10. Let start be end - searchLength.
  3193.     var start = end - searchLength;
  3194.     // 11. If start is less than 0, return false.
  3195.     if (start < 0) {
  3196.         return false;
  3197.     }
  3198.     // 12. If the sequence of elements of S starting at start of length searchLength is the same as the full element sequence of searchStr, return true.
  3199.     if (S.substr(start, searchLength) === searchStr) {
  3200.         return true;
  3201.      }
  3202.     // 13. Otherwise, return false.
  3203.     return false;
  3204. });
  3205.  
  3206. // String.prototype.includes
  3207. /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
  3208. // 21.1.3.7. String.prototype.includes ( searchString [ , position ] )
  3209. CreateMethodProperty(String.prototype, 'includes', function includes(searchString /* [ , position ] */) {
  3210.     'use strict';
  3211.     var position = arguments.length > 1 ? arguments[1] : undefined;
  3212.     // 1. Let O be ? RequireObjectCoercible(this value).
  3213.     var O = RequireObjectCoercible(this);
  3214.     // 2. Let S be ? ToString(O).
  3215.     var S = ToString(O);
  3216.     // 3. Let isRegExp be ? IsRegExp(searchString).
  3217.     var isRegExp = IsRegExp(searchString);
  3218.     // 4. If isRegExp is true, throw a TypeError exception.
  3219.     if (isRegExp) {
  3220.         throw new TypeError('First argument to String.prototype.includes must not be a regular expression');
  3221.     }
  3222.     // 5. Let searchStr be ? ToString(searchString).
  3223.     var searchStr = ToString(searchString);
  3224.     // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
  3225.     var pos = ToInteger(position);
  3226.     // 7. Let len be the length of S.
  3227.     var len = S.length;
  3228.     // 8. Let start be min(max(pos, 0), len).
  3229.     var start = Math.min(Math.max(pos, 0), len);
  3230.     // 9. Let searchLen be the length of searchStr.
  3231.     // var searchLength = searchStr.length;
  3232.     // 10. If there exists any integer k not smaller than start such that k + searchLen is not greater than len, and for all nonnegative integers j less than searchLen, the code unit at index k+j within S is the same as the code unit at index j within searchStr, return true; but if there is no such integer k, return false.
  3233.     return String.prototype.indexOf.call(S, searchStr, start) !== -1;
  3234. });
  3235.  
  3236. // String.prototype.startsWith
  3237. /* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
  3238. // 21.1.3.20. String.prototype.startsWith ( searchString [ , position ] )
  3239. CreateMethodProperty(String.prototype, 'startsWith', function startsWith(searchString /* [ , position ] */) {
  3240.     'use strict';
  3241.     var position = arguments.length > 1 ? arguments[1] : undefined;
  3242.     // 1. Let O be ? RequireObjectCoercible(this value).
  3243.     var O = RequireObjectCoercible(this);
  3244.     // 2. Let S be ? ToString(O).
  3245.     var S = ToString(O);
  3246.     // 3. Let isRegExp be ? IsRegExp(searchString).
  3247.     var isRegExp = IsRegExp(searchString);
  3248.     // 4. If isRegExp is true, throw a TypeError exception.
  3249.     if (isRegExp) {
  3250.         throw new TypeError('First argument to String.prototype.startsWith must not be a regular expression');
  3251.     }
  3252.     // 5. Let searchStr be ? ToString(searchString).
  3253.     var searchStr = ToString(searchString);
  3254.     // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
  3255.     var pos = ToInteger(position);
  3256.     // 7. Let len be the length of S.
  3257.     var len = S.length;
  3258.     // 8. Let start be min(max(pos, 0), len).
  3259.     var start = Math.min(Math.max(pos, 0), len);
  3260.     // 9. Let searchLength be the length of searchStr.
  3261.     var searchLength = searchStr.length;
  3262.     // 10. If searchLength+start is greater than len, return false.
  3263.     if (searchLength + start > len) {
  3264.         return false;
  3265.     }
  3266.     // 11. If the sequence of elements of S starting at start of length searchLength is the same as the full element sequence of searchStr, return true.
  3267.     if (S.substr(start).indexOf(searchString) === 0) {
  3268.         return true;
  3269.     }
  3270.     // 12. Otherwise, return false.
  3271.     return false;
  3272. });
  3273.  
  3274. // URL
  3275. /* global Symbol */
  3276. // URL Polyfill
  3277. // Draft specification: https://url.spec.whatwg.org
  3278.  
  3279. // Notes:
  3280. // - Primarily useful for parsing URLs and modifying query parameters
  3281. // - Should work in IE8+ and everything more modern, with es5.js polyfills
  3282.  
  3283. (function (global) {
  3284.   'use strict';
  3285.  
  3286.   function isSequence(o) {
  3287.     if (!o) return false;
  3288.     if ('Symbol' in global && 'iterator' in global.Symbol &&
  3289.         typeof o[Symbol.iterator] === 'function') return true;
  3290.     if (Array.isArray(o)) return true;
  3291.     return false;
  3292.   }
  3293.  
  3294.   function toArray(iter) {
  3295.     return ('from' in Array) ? Array.from(iter) : Array.prototype.slice.call(iter);
  3296.   }
  3297.  
  3298.   (function() {
  3299.  
  3300.     // Browsers may have:
  3301.     // * No global URL object
  3302.     // * URL with static methods only - may have a dummy constructor
  3303.     // * URL with members except searchParams
  3304.     // * Full URL API support
  3305.     var origURL = global.URL;
  3306.     var nativeURL;
  3307.     try {
  3308.       if (origURL) {
  3309.         nativeURL = new global.URL('http://example.com');
  3310.         if ('searchParams' in nativeURL) {
  3311.                     var url = new URL('http://example.com');
  3312.                     url.search = 'a=1&b=2';
  3313.                     if (url.href === 'http://example.com/?a=1&b=2') {
  3314.                         url.search = '';
  3315.                         if (url.href === 'http://example.com/') {
  3316.                             return;
  3317.                         }
  3318.                     }
  3319.                 }
  3320.         if (!('href' in nativeURL)) {
  3321.                     nativeURL = undefined;
  3322.                 }
  3323.                 nativeURL = undefined;
  3324.       }
  3325.     } catch (_) {}
  3326.  
  3327.     // NOTE: Doesn't do the encoding/decoding dance
  3328.     function urlencoded_serialize(pairs) {
  3329.       var output = '', first = true;
  3330.       pairs.forEach(function (pair) {
  3331.         var name = encodeURIComponent(pair.name);
  3332.         var value = encodeURIComponent(pair.value);
  3333.         if (!first) output += '&';
  3334.         output += name + '=' + value;
  3335.         first = false;
  3336.       });
  3337.       return output.replace(/%20/g, '+');
  3338.     }
  3339.  
  3340.     // NOTE: Doesn't do the encoding/decoding dance
  3341.     function urlencoded_parse(input, isindex) {
  3342.       var sequences = input.split('&');
  3343.       if (isindex && sequences[0].indexOf('=') === -1)
  3344.         sequences[0] = '=' + sequences[0];
  3345.       var pairs = [];
  3346.       sequences.forEach(function (bytes) {
  3347.         if (bytes.length === 0) return;
  3348.         var index = bytes.indexOf('=');
  3349.         if (index !== -1) {
  3350.           var name = bytes.substring(0, index);
  3351.           var value = bytes.substring(index + 1);
  3352.         } else {
  3353.           name = bytes;
  3354.           value = '';
  3355.         }
  3356.         name = name.replace(/\+/g, ' ');
  3357.         value = value.replace(/\+/g, ' ');
  3358.         pairs.push({ name: name, value: value });
  3359.       });
  3360.       var output = [];
  3361.       pairs.forEach(function (pair) {
  3362.         output.push({
  3363.           name: decodeURIComponent(pair.name),
  3364.           value: decodeURIComponent(pair.value)
  3365.         });
  3366.       });
  3367.       return output;
  3368.     }
  3369.  
  3370.     function URLUtils(url) {
  3371.       if (nativeURL)
  3372.         return new origURL(url);
  3373.       var anchor = document.createElement('a');
  3374.       anchor.href = url;
  3375.       return anchor;
  3376.     }
  3377.  
  3378.     function URLSearchParams(init) {
  3379.       var $this = this;
  3380.       this._list = [];
  3381.  
  3382.       if (init === undefined || init === null) {
  3383.         // no-op
  3384.       } else if (init instanceof URLSearchParams) {
  3385.         // In ES6 init would be a sequence, but special case for ES5.
  3386.         this._list = urlencoded_parse(String(init));
  3387.       } else if (typeof init === 'object' && isSequence(init)) {
  3388.         toArray(init).forEach(function(e) {
  3389.           if (!isSequence(e)) throw TypeError();
  3390.           var nv = toArray(e);
  3391.           if (nv.length !== 2) throw TypeError();
  3392.           $this._list.push({name: String(nv[0]), value: String(nv[1])});
  3393.         });
  3394.       } else if (typeof init === 'object' && init) {
  3395.         Object.keys(init).forEach(function(key) {
  3396.           $this._list.push({name: String(key), value: String(init[key])});
  3397.         });
  3398.       } else {
  3399.         init = String(init);
  3400.         if (init.substring(0, 1) === '?')
  3401.           init = init.substring(1);
  3402.         this._list = urlencoded_parse(init);
  3403.       }
  3404.  
  3405.       this._url_object = null;
  3406.       this._setList = function (list) { if (!updating) $this._list = list; };
  3407.  
  3408.       var updating = false;
  3409.       this._update_steps = function() {
  3410.         if (updating) return;
  3411.         updating = true;
  3412.  
  3413.         if (!$this._url_object) return;
  3414.  
  3415.         // Partial workaround for IE issue with 'about:'
  3416.         if ($this._url_object.protocol === 'about:' &&
  3417.             $this._url_object.pathname.indexOf('?') !== -1) {
  3418.           $this._url_object.pathname = $this._url_object.pathname.split('?')[0];
  3419.         }
  3420.  
  3421.         $this._url_object.search = urlencoded_serialize($this._list);
  3422.  
  3423.         updating = false;
  3424.       };
  3425.     }
  3426.  
  3427.  
  3428.     Object.defineProperties(URLSearchParams.prototype, {
  3429.       append: {
  3430.         value: function (name, value) {
  3431.           this._list.push({ name: name, value: value });
  3432.           this._update_steps();
  3433.         }, writable: true, enumerable: true, configurable: true
  3434.       },
  3435.  
  3436.       'delete': {
  3437.         value: function (name) {
  3438.           for (var i = 0; i < this._list.length;) {
  3439.             if (this._list[i].name === name)
  3440.               this._list.splice(i, 1);
  3441.             else
  3442.               ++i;
  3443.           }
  3444.           this._update_steps();
  3445.         }, writable: true, enumerable: true, configurable: true
  3446.       },
  3447.  
  3448.       get: {
  3449.         value: function (name) {
  3450.           for (var i = 0; i < this._list.length; ++i) {
  3451.             if (this._list[i].name === name)
  3452.               return this._list[i].value;
  3453.           }
  3454.           return null;
  3455.         }, writable: true, enumerable: true, configurable: true
  3456.       },
  3457.  
  3458.       getAll: {
  3459.         value: function (name) {
  3460.           var result = [];
  3461.           for (var i = 0; i < this._list.length; ++i) {
  3462.             if (this._list[i].name === name)
  3463.               result.push(this._list[i].value);
  3464.           }
  3465.           return result;
  3466.         }, writable: true, enumerable: true, configurable: true
  3467.       },
  3468.  
  3469.       has: {
  3470.         value: function (name) {
  3471.           for (var i = 0; i < this._list.length; ++i) {
  3472.             if (this._list[i].name === name)
  3473.               return true;
  3474.           }
  3475.           return false;
  3476.         }, writable: true, enumerable: true, configurable: true
  3477.       },
  3478.  
  3479.       set: {
  3480.         value: function (name, value) {
  3481.           var found = false;
  3482.           for (var i = 0; i < this._list.length;) {
  3483.             if (this._list[i].name === name) {
  3484.               if (!found) {
  3485.                 this._list[i].value = value;
  3486.                 found = true;
  3487.                 ++i;
  3488.               } else {
  3489.                 this._list.splice(i, 1);
  3490.               }
  3491.             } else {
  3492.               ++i;
  3493.             }
  3494.           }
  3495.  
  3496.           if (!found)
  3497.             this._list.push({ name: name, value: value });
  3498.  
  3499.           this._update_steps();
  3500.         }, writable: true, enumerable: true, configurable: true
  3501.       },
  3502.  
  3503.       entries: {
  3504.         value: function() { return new Iterator(this._list, 'key+value'); },
  3505.         writable: true, enumerable: true, configurable: true
  3506.       },
  3507.  
  3508.       keys: {
  3509.         value: function() { return new Iterator(this._list, 'key'); },
  3510.         writable: true, enumerable: true, configurable: true
  3511.       },
  3512.  
  3513.       values: {
  3514.         value: function() { return new Iterator(this._list, 'value'); },
  3515.         writable: true, enumerable: true, configurable: true
  3516.       },
  3517.  
  3518.       forEach: {
  3519.         value: function(callback) {
  3520.           var thisArg = (arguments.length > 1) ? arguments[1] : undefined;
  3521.           this._list.forEach(function(pair) {
  3522.             callback.call(thisArg, pair.value, pair.name);
  3523.           });
  3524.  
  3525.         }, writable: true, enumerable: true, configurable: true
  3526.       },
  3527.  
  3528.       toString: {
  3529.         value: function () {
  3530.           return urlencoded_serialize(this._list);
  3531.         }, writable: true, enumerable: false, configurable: true
  3532.       }
  3533.     });
  3534.  
  3535.     function Iterator(source, kind) {
  3536.       var index = 0;
  3537.       this['next'] = function() {
  3538.         if (index >= source.length)
  3539.           return {done: true, value: undefined};
  3540.         var pair = source[index++];
  3541.         return {done: false, value:
  3542.                 kind === 'key' ? pair.name :
  3543.                 kind === 'value' ? pair.value :
  3544.                 [pair.name, pair.value]};
  3545.       };
  3546.     }
  3547.  
  3548.     if ('Symbol' in global && 'iterator' in global.Symbol) {
  3549.       Object.defineProperty(URLSearchParams.prototype, global.Symbol.iterator, {
  3550.         value: URLSearchParams.prototype.entries,
  3551.         writable: true, enumerable: true, configurable: true});
  3552.       Object.defineProperty(Iterator.prototype, global.Symbol.iterator, {
  3553.         value: function() { return this; },
  3554.         writable: true, enumerable: true, configurable: true});
  3555.     }
  3556.  
  3557.     function URL(url, base) {
  3558.       if (!(this instanceof global.URL))
  3559.         throw new TypeError("Failed to construct 'URL': Please use the 'new' operator.");
  3560.  
  3561.       if (base) {
  3562.         url = (function () {
  3563.           if (nativeURL) return new origURL(url, base).href;
  3564.           var iframe;
  3565.           try {
  3566.             var doc;
  3567.             // Use another document/base tag/anchor for relative URL resolution, if possible
  3568.             if (Object.prototype.toString.call(window.operamini) === "[object OperaMini]") {
  3569.               iframe = document.createElement('iframe');
  3570.               iframe.style.display = 'none';
  3571.               document.documentElement.appendChild(iframe);
  3572.               doc = iframe.contentWindow.document;
  3573.             } else if (document.implementation && document.implementation.createHTMLDocument) {
  3574.               doc = document.implementation.createHTMLDocument('');
  3575.             } else if (document.implementation && document.implementation.createDocument) {
  3576.               doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);
  3577.               doc.documentElement.appendChild(doc.createElement('head'));
  3578.               doc.documentElement.appendChild(doc.createElement('body'));
  3579.             } else if (window.ActiveXObject) {
  3580.               doc = new window.ActiveXObject('htmlfile');
  3581.               doc.write('<head><\/head><body><\/body>');
  3582.               doc.close();
  3583.             }
  3584.  
  3585.             if (!doc) throw Error('base not supported');
  3586.  
  3587.             var baseTag = doc.createElement('base');
  3588.             baseTag.href = base;
  3589.             doc.getElementsByTagName('head')[0].appendChild(baseTag);
  3590.             var anchor = doc.createElement('a');
  3591.             anchor.href = url;
  3592.             return anchor.href;
  3593.           } finally {
  3594.             if (iframe)
  3595.               iframe.parentNode.removeChild(iframe);
  3596.           }
  3597.         }());
  3598.       }
  3599.  
  3600.       // An inner object implementing URLUtils (either a native URL
  3601.       // object or an HTMLAnchorElement instance) is used to perform the
  3602.       // URL algorithms. With full ES5 getter/setter support, return a
  3603.       // regular object For IE8's limited getter/setter support, a
  3604.       // different HTMLAnchorElement is returned with properties
  3605.       // overridden
  3606.  
  3607.       var instance = URLUtils(url || '');
  3608.  
  3609.       // Detect for ES5 getter/setter support
  3610.       // (an Object.defineProperties polyfill that doesn't support getters/setters may throw)
  3611.       var ES5_GET_SET = (function() {
  3612.         if (!('defineProperties' in Object)) return false;
  3613.         try {
  3614.           var obj = {};
  3615.           Object.defineProperties(obj, { prop: { 'get': function () { return true; } } });
  3616.           return obj.prop;
  3617.         } catch (_) {
  3618.           return false;
  3619.         }
  3620.       }());
  3621.  
  3622.       var self = ES5_GET_SET ? this : document.createElement('a');
  3623.  
  3624.  
  3625.  
  3626.       var query_object = new URLSearchParams(
  3627.         instance.search ? instance.search.substring(1) : null);
  3628.       query_object._url_object = self;
  3629.  
  3630.       Object.defineProperties(self, {
  3631.         href: {
  3632.           get: function () { return instance.href; },
  3633.           set: function (v) { instance.href = v; tidy_instance(); update_steps(); },
  3634.           enumerable: true, configurable: true
  3635.         },
  3636.         origin: {
  3637.           get: function () {
  3638.             if ('origin' in instance) return instance.origin;
  3639.             return this.protocol + '//' + this.host;
  3640.           },
  3641.           enumerable: true, configurable: true
  3642.         },
  3643.         protocol: {
  3644.           get: function () { return instance.protocol; },
  3645.           set: function (v) { instance.protocol = v; },
  3646.           enumerable: true, configurable: true
  3647.         },
  3648.         username: {
  3649.           get: function () { return instance.username; },
  3650.           set: function (v) { instance.username = v; },
  3651.           enumerable: true, configurable: true
  3652.         },
  3653.         password: {
  3654.           get: function () { return instance.password; },
  3655.           set: function (v) { instance.password = v; },
  3656.           enumerable: true, configurable: true
  3657.         },
  3658.         host: {
  3659.           get: function () {
  3660.             // IE returns default port in |host|
  3661.             var re = {'http:': /:80$/, 'https:': /:443$/, 'ftp:': /:21$/}[instance.protocol];
  3662.             return re ? instance.host.replace(re, '') : instance.host;
  3663.           },
  3664.           set: function (v) { instance.host = v; },
  3665.           enumerable: true, configurable: true
  3666.         },
  3667.         hostname: {
  3668.           get: function () { return instance.hostname; },
  3669.           set: function (v) { instance.hostname = v; },
  3670.           enumerable: true, configurable: true
  3671.         },
  3672.         port: {
  3673.           get: function () { return instance.port; },
  3674.           set: function (v) { instance.port = v; },
  3675.           enumerable: true, configurable: true
  3676.         },
  3677.         pathname: {
  3678.           get: function () {
  3679.             // IE does not include leading '/' in |pathname|
  3680.             if (instance.pathname.charAt(0) !== '/') return '/' + instance.pathname;
  3681.             return instance.pathname;
  3682.           },
  3683.           set: function (v) { instance.pathname = v; },
  3684.           enumerable: true, configurable: true
  3685.         },
  3686.         search: {
  3687.           get: function () { return instance.search; },
  3688.           set: function (v) {
  3689.             if (instance.search === v) return;
  3690.             instance.search = v; tidy_instance(); update_steps();
  3691.           },
  3692.           enumerable: true, configurable: true
  3693.         },
  3694.         searchParams: {
  3695.           get: function () { return query_object; },
  3696.           enumerable: true, configurable: true
  3697.         },
  3698.         hash: {
  3699.           get: function () { return instance.hash; },
  3700.           set: function (v) { instance.hash = v; tidy_instance(); },
  3701.           enumerable: true, configurable: true
  3702.         },
  3703.         toString: {
  3704.           value: function() { return instance.toString(); },
  3705.           enumerable: false, configurable: true
  3706.         },
  3707.         valueOf: {
  3708.           value: function() { return instance.valueOf(); },
  3709.           enumerable: false, configurable: true
  3710.         }
  3711.       });
  3712.  
  3713.       function tidy_instance() {
  3714.         var href = instance.href.replace(/#$|\?$|\?(?=#)/g, '');
  3715.         if (instance.href !== href)
  3716.           instance.href = href;
  3717.       }
  3718.  
  3719.       function update_steps() {
  3720.         query_object._setList(instance.search ? urlencoded_parse(instance.search.substring(1)) : []);
  3721.         query_object._update_steps();
  3722.       }
  3723.  
  3724.       return self;
  3725.     }
  3726.  
  3727.     if (origURL) {
  3728.       for (var i in origURL) {
  3729.         if (origURL.hasOwnProperty(i) && typeof origURL[i] === 'function')
  3730.           URL[i] = origURL[i];
  3731.       }
  3732.     }
  3733.  
  3734.     global.URL = URL;
  3735.     global.URLSearchParams = URLSearchParams;
  3736.   }());
  3737.  
  3738.   // Patch native URLSearchParams constructor to handle sequences/records
  3739.   // if necessary.
  3740.   (function() {
  3741.     if (new global.URLSearchParams([['a', 1]]).get('a') === '1' &&
  3742.         new global.URLSearchParams({a: 1}).get('a') === '1')
  3743.       return;
  3744.     var orig = global.URLSearchParams;
  3745.     global.URLSearchParams = function(init) {
  3746.       if (init && typeof init === 'object' && isSequence(init)) {
  3747.         var o = new orig();
  3748.         toArray(init).forEach(function(e) {
  3749.           if (!isSequence(e)) throw TypeError();
  3750.           var nv = toArray(e);
  3751.           if (nv.length !== 2) throw TypeError();
  3752.           o.append(nv[0], nv[1]);
  3753.         });
  3754.         return o;
  3755.       } else if (init && typeof init === 'object') {
  3756.         o = new orig();
  3757.         Object.keys(init).forEach(function(key) {
  3758.           o.set(key, init[key]);
  3759.         });
  3760.         return o;
  3761.       } else {
  3762.         return new orig(init);
  3763.       }
  3764.     };
  3765.   }());
  3766.  
  3767. }(self));
  3768. })
  3769. .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
Add Comment
Please, Sign In to add comment