· 6 years ago · Sep 10, 2019, 10:12 AM
1/* Polyfill service v3.40.0
2 * For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
3 *
4 * Features requested: Array.prototype.forEach,NodeList.prototype.forEach,default,es2015,es2016,es2017,es2018
5 *
6 * - _ESAbstract.ArrayCreate, License: CC0 (required by "Array.from", "default", "es2015", "Array.of", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map")
7 * - _ESAbstract.Call, License: CC0 (required by "Array.prototype.forEach", "default", "Array.from", "es2015", "Array.prototype.every", "Array.prototype.filter", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Array.prototype.find", "Array.prototype.findIndex", "WeakMap", "WeakSet", "_ESAbstract.GetIterator", "Map", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.IteratorNext", "_ESAbstract.IteratorStep", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.of", "Array.prototype.fill", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "String.prototype.trim", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.repeat", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "es2017", "String.prototype.padStart", "_ESAbstract.OrdinaryToPrimitive")
8 * - _ESAbstract.Get, License: CC0 (required by "Array.prototype.forEach", "default", "Array.from", "es2015", "Array.prototype.every", "Array.prototype.fill", "Array.prototype.filter", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Object.assign", "Object.defineProperties", "Object.create", "Map", "Array.prototype.find", "Array.prototype.findIndex", "RegExp.prototype.flags", "WeakMap", "WeakSet", "Array.prototype.includes", "es2016", "_ESAbstract.IteratorValue", "Set", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "_ESAbstract.EnumerableOwnProperties", "Object.entries", "es2017", "_ESAbstract.SpeciesConstructor", "Promise.prototype.finally", "es2018", "_ESAbstract.GetPrototypeFromConstructor", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "String.prototype.trim", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.repeat", "String.prototype.padEnd", "String.prototype.padStart")
9 * - _ESAbstract.HasProperty, License: CC0 (required by "Array.prototype.forEach", "default", "Array.prototype.every", "Array.prototype.filter", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Array.prototype.copyWithin", "es2015")
10 * - _ESAbstract.IsArray, License: CC0 (required by "Array.isArray", "default", "WeakMap", "es2015", "WeakSet", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map")
11 * - _ESAbstract.IsCallable, License: CC0 (required by "Array.prototype.forEach", "default", "Array.from", "es2015", "Array.prototype.every", "Array.prototype.filter", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Function.prototype.bind", "Map", "Set", "Array.prototype.find", "Array.prototype.findIndex", "WeakMap", "WeakSet", "Promise.prototype.finally", "es2018", "_ESAbstract.GetMethod", "_ESAbstract.OrdinaryToPrimitive", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.of", "Array.prototype.fill", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "String.prototype.trim", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.repeat", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "es2017", "String.prototype.padStart")
12 * - _ESAbstract.RequireObjectCoercible, License: CC0 (required by "String.prototype.endsWith", "default", "es2015", "String.prototype.includes", "String.prototype.startsWith", "String.prototype.trim", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.repeat", "String.prototype.padEnd", "es2016", "es2017", "String.prototype.padStart")
13 * - _ESAbstract.SameValueNonNumber, License: CC0 (required by "_ESAbstract.SameValueZero", "Map", "default", "es2015", "Array.from", "Set", "WeakSet", "Array.prototype.includes", "es2016", "_ESAbstract.SameValue", "Object.is", "WeakMap")
14 * - _ESAbstract.ToBoolean, License: CC0 (required by "Array.prototype.every", "default", "Array.prototype.filter", "Array.prototype.some", "Array.prototype.find", "es2015", "Array.prototype.findIndex", "RegExp.prototype.flags", "_ESAbstract.IteratorComplete", "Map", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet", "_ESAbstract.IsRegExp", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith")
15 * - _ESAbstract.ToInteger, License: CC0 (required by "Array.prototype.fill", "default", "es2015", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "Array.prototype.copyWithin", "Number.isInteger", "Number.isSafeInteger", "String.prototype.codePointAt", "String.prototype.repeat", "Array.prototype.includes", "es2016", "_ESAbstract.ToLength", "Array.prototype.forEach", "Array.from", "Array.prototype.every", "Array.prototype.filter", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.padEnd", "es2017", "String.prototype.padStart")
16 * - _ESAbstract.ToLength, License: CC0 (required by "Array.prototype.forEach", "default", "Array.from", "es2015", "Array.prototype.every", "Array.prototype.fill", "Array.prototype.filter", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "es2017", "String.prototype.padStart")
17 * - _ESAbstract.ToObject, License: CC0 (required by "Array.prototype.forEach", "default", "Array.from", "es2015", "Array.prototype.every", "Array.prototype.fill", "Array.prototype.filter", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Object.assign", "Object.defineProperties", "Object.create", "Map", "Array.prototype.entries", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "Array.prototype.includes", "es2016", "Object.entries", "es2017", "Object.getOwnPropertyDescriptors", "Object.values", "_ESAbstract.GetV", "_ESAbstract.GetMethod", "Set", "_ESAbstract.GetIterator", "WeakMap", "WeakSet")
18 * - _ESAbstract.GetV, License: CC0 (required by "_ESAbstract.GetMethod", "Array.from", "default", "es2015", "Map", "Set", "_ESAbstract.GetIterator", "WeakMap", "WeakSet")
19 * - _ESAbstract.GetMethod, License: CC0 (required by "Array.from", "default", "es2015", "Map", "Set", "_ESAbstract.IsConstructor", "Array.of", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ESAbstract.IteratorClose", "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.forEach", "Array.prototype.every", "Array.prototype.fill", "Array.prototype.filter", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "String.prototype.trim", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.repeat", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "es2017", "String.prototype.padStart")
20 * - _ESAbstract.ToUint32, License: CC0 (required by "Math.clz32", "es2015", "Math.imul")
21 * - _ESAbstract.Type, License: CC0 (required by "Map", "default", "es2015", "Array.from", "Number.isNaN", "Object.create", "Object.defineProperties", "Number.isFinite", "Number.isInteger", "Number.isSafeInteger", "Object.seal", "RegExp.prototype.flags", "WeakMap", "WeakSet", "_ESAbstract.ToString", "Array.prototype.forEach", "Array.of", "Array.prototype.every", "Array.prototype.fill", "Array.prototype.filter", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "String.prototype.trim", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.repeat", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "es2017", "String.prototype.padStart", "_ESAbstract.IsConstructor", "_ESAbstract.GetIterator", "Set", "_ESAbstract.IteratorClose", "_ESAbstract.IteratorValue", "_ESAbstract.ArraySpeciesCreate", "_ESAbstract.CreateIterResultObject", "_ESAbstract.IteratorComplete", "_ESAbstract.IteratorStep", "_ESAbstract.IteratorNext", "_ESAbstract.SameValueZero", "_ESAbstract.IsRegExp", "_ESAbstract.SameValue", "Object.is", "_ESAbstract.EnumerableOwnProperties", "Object.entries", "Reflect.ownKeys", "Object.getOwnPropertyDescriptors", "_ESAbstract.SpeciesConstructor", "Promise.prototype.finally", "es2018", "_ESAbstract.ToPrimitive", "_ESAbstract.GetPrototypeFromConstructor", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ESAbstract.OrdinaryToPrimitive")
22 * - _ESAbstract.GetPrototypeFromConstructor, License: CC0 (required by "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "default", "es2015", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
23 * - _ESAbstract.IsConstructor, License: CC0 (required by "Array.from", "default", "es2015", "Array.of", "_ESAbstract.Construct", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.SpeciesConstructor", "Promise.prototype.finally", "es2018")
24 * - _ESAbstract.IsRegExp, License: CC0 (required by "String.prototype.endsWith", "default", "es2015", "String.prototype.includes", "String.prototype.startsWith")
25 * - _ESAbstract.IteratorClose, License: CC0 (required by "Array.from", "default", "es2015", "Map", "Set", "WeakMap", "WeakSet")
26 * - _ESAbstract.IteratorComplete, License: CC0 (required by "Map", "default", "es2015", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet")
27 * - _ESAbstract.IteratorNext, License: CC0 (required by "Map", "default", "es2015", "Array.from", "Set", "_ESAbstract.IteratorStep", "WeakMap", "WeakSet")
28 * - _ESAbstract.IteratorStep, License: CC0 (required by "Array.from", "default", "es2015", "Map", "Set", "WeakMap", "WeakSet")
29 * - _ESAbstract.IteratorValue, License: CC0 (required by "Array.from", "default", "es2015", "Map", "Set", "WeakMap", "WeakSet")
30 * - _ESAbstract.OrdinaryToPrimitive, License: CC0 (required by "_ESAbstract.ToPrimitive", "_ESAbstract.ToString", "Array.prototype.forEach", "default", "Array.from", "es2015", "Array.of", "Array.prototype.every", "Array.prototype.fill", "Array.prototype.filter", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "String.prototype.trim", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.repeat", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "es2017", "String.prototype.padStart")
31 * - _ESAbstract.SameValue, License: CC0 (required by "Object.is", "es2015", "WeakMap")
32 * - _ESAbstract.SameValueZero, License: CC0 (required by "Map", "default", "es2015", "Array.from", "Set", "WeakSet", "Array.prototype.includes", "es2016")
33 * - _ESAbstract.SpeciesConstructor, License: CC0 (required by "Promise.prototype.finally", "es2018")
34 * - _ESAbstract.ToPrimitive, License: CC0 (required by "_ESAbstract.ToString", "Array.prototype.forEach", "default", "Array.from", "es2015", "Array.of", "Array.prototype.every", "Array.prototype.fill", "Array.prototype.filter", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "String.prototype.trim", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.repeat", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "es2017", "String.prototype.padStart")
35 * - _ESAbstract.ToString, License: CC0 (required by "Array.prototype.forEach", "default", "Array.from", "es2015", "Array.of", "Array.prototype.every", "Array.prototype.fill", "Array.prototype.filter", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "String.prototype.trim", "Array.prototype.find", "Array.prototype.findIndex", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.repeat", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "es2017", "String.prototype.padStart")
36 * - _ESAbstract.UTF16Decode, License: CC0 (required by "String.prototype.codePointAt", "es2015")
37 * - _TypedArray, License: MIT (required by "Math.fround", "es2015")
38 * - atob, License: MIT (required by "default")
39 * - Date.now, License: CC0 (required by "default", "requestAnimationFrame")
40 * - Date.prototype.toISOString, License: CC0 (required by "default")
41 * - document, License: CC0 (required by "default", "DocumentFragment.prototype.append", "DocumentFragment.prototype.prepend", "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith", "Element", "Element.prototype.classList", "Element.prototype.cloneNode", "Element.prototype.matches", "Element.prototype.closest", "Event", "CustomEvent", "Event.focusin", "Event.hashchange", "document.querySelector", "~html5-elements", "_mutation")
42 * - ~html5-elements, License: MIT (required by "default")
43 * - DocumentFragment, License: CC0 (required by "DocumentFragment.prototype.append", "default", "DocumentFragment.prototype.prepend")
44 * - Element, License: CC0 (required by "default", "DocumentFragment.prototype.append", "DocumentFragment.prototype.prepend", "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.classList", "Element.prototype.cloneNode", "Element.prototype.matches", "Element.prototype.closest", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith", "Event", "CustomEvent", "Event.focusin", "Event.hashchange", "Node.prototype.contains", "document.querySelector", "_mutation")
45 * - _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")
46 * - document.querySelector, License: CC0 (required by "default", "Element.prototype.matches", "Element.prototype.closest")
47 * - DocumentFragment.prototype.append, License: CC0 (required by "default")
48 * - DocumentFragment.prototype.prepend, License: CC0 (required by "default")
49 * - Element.prototype.append, License: CC0 (required by "default")
50 * - Element.prototype.cloneNode, License: CC0 (required by "default")
51 * - Element.prototype.matches, License: CC0 (required by "default", "Element.prototype.closest")
52 * - Element.prototype.closest, License: CC0 (required by "default")
53 * - Element.prototype.prepend, License: CC0 (required by "default")
54 * - Element.prototype.remove, License: CC0 (required by "default")
55 * - Element.prototype.replaceWith, License: CC0 (required by "default")
56 * - JSON, License: MIT (required by "default")
57 * - Node.prototype.contains, License: CC0 (required by "default")
58 * - Object.defineProperty, License: CC0 (required by "default", "Element.prototype.classList", "Event", "CustomEvent", "Event.focusin", "Event.hashchange", "Map", "es2015", "Array.from", "Object.defineProperties", "Object.create", "Set", "Function.prototype.name", "Number.Epsilon", "Number.MAX_SAFE_INTEGER", "Number.MIN_SAFE_INTEGER", "Object.setPrototypeOf", "RegExp.prototype.flags", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Symbol", "WeakMap", "WeakSet", "Object.getOwnPropertyDescriptors", "es2017", "Object.values", "Symbol.asyncIterator", "es2018", "_ESAbstract.CreateMethodProperty", "Array.prototype.forEach", "Array.isArray", "Array.of", "Array.prototype.every", "Array.prototype.fill", "Array.prototype.filter", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Function.prototype.bind", "Number.isNaN", "Object.assign", "Object.getOwnPropertyDescriptor", "Object.getOwnPropertyNames", "Object.getPrototypeOf", "Object.keys", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "String.prototype.trim", "Array.prototype.copyWithin", "Array.prototype.entries", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.keys", "Array.prototype.values", "Math.acosh", "Math.asinh", "Math.atanh", "Math.cbrt", "Math.clz32", "Math.cosh", "Math.expm1", "Math.fround", "Math.hypot", "Math.imul", "Math.log10", "Math.log1p", "Math.log2", "Math.sign", "Math.sinh", "Math.tanh", "Math.trunc", "Number.isFinite", "Number.isInteger", "Number.isSafeInteger", "Number.parseFloat", "Number.parseInt", "Object.is", "Object.seal", "String.prototype.codePointAt", "String.prototype.repeat", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "String.prototype.padStart", "Object.entries", "Promise.prototype.finally", "_DOMTokenList", "DOMTokenList", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "_ArrayIterator", "_StringIterator", "_ESAbstract.CreateDataProperty", "_ESAbstract.CreateDataPropertyOrThrow", "_ESAbstract.CreateIterResultObject", "_Iterator", "Reflect", "Reflect.ownKeys")
59 * - _DOMTokenList, License: ISC (required by "DOMTokenList", "default")
60 * - DOMTokenList, License: CC0 (required by "default", "Element.prototype.classList")
61 * - _ESAbstract.CreateDataProperty, License: CC0 (required by "Object.getOwnPropertyDescriptors", "es2017", "_ESAbstract.CreateDataPropertyOrThrow", "Array.from", "default", "es2015", "Array.of", "Array.prototype.filter", "Array.prototype.map", "_ESAbstract.CreateIterResultObject", "Map", "Set")
62 * - _ESAbstract.CreateDataPropertyOrThrow, License: CC0 (required by "Array.from", "default", "es2015", "Array.of", "Array.prototype.filter", "Array.prototype.map")
63 * - _ESAbstract.CreateIterResultObject, License: CC0 (required by "Map", "default", "es2015", "Array.from", "Set")
64 * - _ESAbstract.CreateMethodProperty, License: CC0 (required by "Array.prototype.forEach", "default", "Array.from", "es2015", "Array.isArray", "Array.of", "Array.prototype.every", "Array.prototype.fill", "Array.prototype.filter", "Array.prototype.indexOf", "Array.prototype.lastIndexOf", "Array.prototype.map", "Array.prototype.reduce", "Array.prototype.reduceRight", "Array.prototype.some", "Function.prototype.bind", "Map", "Number.isNaN", "Object.assign", "Object.create", "Object.defineProperties", "Object.getOwnPropertyDescriptor", "Object.getOwnPropertyNames", "Object.getPrototypeOf", "Object.keys", "Set", "String.prototype.endsWith", "String.prototype.includes", "String.prototype.startsWith", "String.prototype.trim", "Array.prototype.@@iterator", "Array.prototype.copyWithin", "Array.prototype.entries", "Array.prototype.find", "Array.prototype.findIndex", "Array.prototype.keys", "Array.prototype.values", "Math.acosh", "Math.asinh", "Math.atanh", "Math.cbrt", "Math.clz32", "Math.cosh", "Math.expm1", "Math.fround", "Math.hypot", "Math.imul", "Math.log10", "Math.log1p", "Math.log2", "Math.sign", "Math.sinh", "Math.tanh", "Math.trunc", "Number.isFinite", "Number.isInteger", "Number.isSafeInteger", "Number.parseFloat", "Number.parseInt", "Object.is", "Object.seal", "Object.setPrototypeOf", "String.prototype.@@iterator", "String.prototype.codePointAt", "String.prototype.repeat", "WeakMap", "WeakSet", "Array.prototype.includes", "es2016", "String.prototype.padEnd", "es2017", "String.prototype.padStart", "Object.entries", "Object.getOwnPropertyDescriptors", "Object.values", "Promise.prototype.finally", "es2018", "Object.freeze", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Reflect.ownKeys")
65 * - Array.isArray, License: CC0 (required by "default", "Map", "es2015", "Array.from", "Set", "URL", "WeakMap")
66 * - Array.prototype.copyWithin, License: MIT (required by "es2015")
67 * - Array.prototype.every, License: CC0 (required by "default")
68 * - Array.prototype.fill, License: CC0 (required by "default", "es2015")
69 * - Array.prototype.find, License: CC0 (required by "es2015")
70 * - Array.prototype.findIndex, License: CC0 (required by "es2015")
71 * - Array.prototype.forEach, License: CC0 (required by "default", "NodeList.prototype.forEach", "URL", "Object.setPrototypeOf", "es2015", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
72 * - NodeList.prototype.forEach, License: CC0
73 * - Array.prototype.includes, License: MIT (required by "es2016")
74 * - Array.prototype.indexOf, License: CC0 (required by "default", "Element.prototype.after", "Element.prototype.before")
75 * - Element.prototype.after, License: CC0 (required by "default")
76 * - Element.prototype.before, License: CC0 (required by "default")
77 * - Array.prototype.lastIndexOf, License: CC0 (required by "default")
78 * - Array.prototype.reduce, License: CC0 (required by "default")
79 * - Array.prototype.reduceRight, License: CC0 (required by "default")
80 * - Array.prototype.some, License: CC0 (required by "default")
81 * - Function.prototype.bind, License: MIT (required by "default", "Object.getOwnPropertyDescriptor", "Object.assign", "es2015", "Object.defineProperties", "Object.create", "Map", "Array.from", "Promise.prototype.finally", "es2018", "_ESAbstract.Construct", "Array.of", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
82 * - Math.acosh, License: CC0 (required by "es2015")
83 * - Math.asinh, License: CC0 (required by "es2015")
84 * - Math.atanh, License: CC0 (required by "es2015")
85 * - Math.cbrt, License: CC0 (required by "es2015")
86 * - Math.clz32, License: CC0 (required by "es2015")
87 * - Math.cosh, License: CC0 (required by "es2015")
88 * - Math.expm1, License: CC0 (required by "es2015")
89 * - Math.fround, License: CC0 (required by "es2015")
90 * - Math.hypot, License: CC0 (required by "es2015")
91 * - Math.imul, License: CC0 (required by "es2015")
92 * - Math.log10, License: CC0 (required by "es2015")
93 * - Math.log1p, License: CC0 (required by "es2015")
94 * - Math.log2, License: CC0 (required by "es2015")
95 * - Math.sign, License: CC0 (required by "es2015")
96 * - Math.sinh, License: CC0 (required by "es2015")
97 * - Math.tanh, License: CC0 (required by "es2015")
98 * - Math.trunc, License: CC0 (required by "es2015")
99 * - Number.isFinite, License: MIT (required by "es2015")
100 * - Number.isInteger, License: MIT (required by "es2015")
101 * - Number.isNaN, License: MIT (required by "default", "es2015")
102 * - Number.isSafeInteger, License: MIT (required by "es2015")
103 * - Number.parseFloat, License: MIT (required by "es2015")
104 * - Number.parseInt, License: MIT (required by "es2015")
105 * - Element.prototype.classList, License: ISC (required by "default")
106 * - Function.prototype.name, License: MIT (required by "es2015")
107 * - Number.Epsilon, License: MIT (required by "es2015")
108 * - Number.MAX_SAFE_INTEGER, License: MIT (required by "es2015")
109 * - Number.MIN_SAFE_INTEGER, License: MIT (required by "es2015")
110 * - Object.freeze, License: CC0 (required by "Symbol", "es2015", "Map", "default", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
111 * - Object.getOwnPropertyDescriptor, License: CC0 (required by "default", "Object.assign", "es2015", "Object.defineProperties", "Object.create", "Map", "Array.from", "Object.setPrototypeOf", "Symbol", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Object.getOwnPropertyDescriptors", "es2017", "_ESAbstract.EnumerableOwnProperties", "Object.entries")
112 * - Object.getOwnPropertyNames, License: CC0 (required by "default", "Object.setPrototypeOf", "es2015", "Symbol", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Reflect.ownKeys", "Object.getOwnPropertyDescriptors", "es2017")
113 * - Object.getPrototypeOf, License: CC0 (required by "default", "Object.setPrototypeOf", "es2015", "_ESAbstract.OrdinaryCreateFromConstructor", "Map", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
114 * - Object.is, License: CC0 (required by "es2015")
115 * - Object.keys, License: MIT (required by "default", "Object.assign", "es2015", "Object.defineProperties", "Object.create", "Map", "Array.from", "Symbol", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Object.values", "es2017", "_ESAbstract.EnumerableOwnProperties", "Object.entries")
116 * - _ESAbstract.EnumerableOwnProperties, License: CC0 (required by "Object.entries", "es2017")
117 * - Object.entries, License: CC0 (required by "es2017")
118 * - Object.assign, License: CC0 (required by "default", "es2015", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
119 * - Object.defineProperties, License: CC0 (required by "default", "Object.create", "Map", "es2015", "Array.from", "URL", "location.origin", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
120 * - location.origin, License: CC0 (required by "default")
121 * - Object.create, License: CC0 (required by "default", "Map", "es2015", "Array.from", "Set", "Object.setPrototypeOf", "Symbol", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_ESAbstract.OrdinaryCreateFromConstructor", "_ESAbstract.Construct", "Array.of", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
122 * - _ESAbstract.OrdinaryCreateFromConstructor, License: CC0 (required by "Map", "default", "es2015", "Array.from", "Set", "WeakMap", "WeakSet", "_ESAbstract.Construct", "Array.of")
123 * - _ESAbstract.Construct, License: CC0 (required by "Array.from", "default", "es2015", "Array.of", "_ESAbstract.ArraySpeciesCreate", "Array.prototype.filter", "Array.prototype.map")
124 * - _ESAbstract.ArraySpeciesCreate, License: CC0 (required by "Array.prototype.filter", "default", "Array.prototype.map")
125 * - Array.prototype.filter, License: CC0 (required by "default", "Symbol", "es2015", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables")
126 * - Array.prototype.map, License: CC0 (required by "default", "Symbol", "es2015", "Map", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "Object.values", "es2017")
127 * - Array.of, License: CC0 (required by "default", "es2015")
128 * - Object.seal, License: MIT (required by "es2015")
129 * - Object.setPrototypeOf, License: MIT (required by "es2015", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
130 * - Object.values, License: CC0 (required by "es2017")
131 * - Promise, License: MIT (required by "default", "es2015", "Promise.prototype.finally", "es2018")
132 * - Promise.prototype.finally, License: MIT (required by "es2018")
133 * - Reflect, License: CC0 (required by "Reflect.ownKeys", "Object.getOwnPropertyDescriptors", "es2017")
134 * - RegExp.prototype.flags, License: MIT (required by "es2015")
135 * - requestAnimationFrame, License: MIT (required by "default")
136 * - String.prototype.codePointAt, License: MIT (required by "es2015")
137 * - String.prototype.endsWith, License: CC0 (required by "default", "es2015")
138 * - String.prototype.includes, License: CC0 (required by "default", "es2015", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
139 * - String.prototype.padEnd, License: CC0 (required by "es2016", "es2017")
140 * - String.prototype.padStart, License: CC0 (required by "es2016", "es2017")
141 * - String.prototype.repeat, License: CC0 (required by "es2015")
142 * - String.prototype.startsWith, License: CC0 (required by "default", "es2015")
143 * - String.prototype.trim, License: CC0 (required by "default")
144 * - Symbol, License: MIT (required by "es2015", "Map", "default", "Array.from", "Set", "Symbol.hasInstance", "Symbol.isConcatSpreadable", "Symbol.iterator", "Array.prototype.@@iterator", "String.prototype.@@iterator", "Symbol.match", "Symbol.replace", "Symbol.search", "Symbol.species", "Symbol.split", "Symbol.toPrimitive", "Symbol.toStringTag", "Symbol.unscopables", "WeakMap", "WeakSet", "Symbol.asyncIterator", "es2018", "Reflect.ownKeys", "Object.getOwnPropertyDescriptors", "es2017", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
145 * - Reflect.ownKeys, License: CC0 (required by "Object.getOwnPropertyDescriptors", "es2017")
146 * - Object.getOwnPropertyDescriptors, License: CC0 (required by "es2017")
147 * - Symbol.asyncIterator, License: MIT (required by "es2018")
148 * - Symbol.hasInstance, License: MIT (required by "es2015")
149 * - Symbol.isConcatSpreadable, License: MIT (required by "es2015")
150 * - Symbol.iterator, License: MIT (required by "es2015", "Array.from", "default", "Map", "Set", "Array.prototype.@@iterator", "String.prototype.@@iterator", "_ESAbstract.GetIterator", "WeakMap", "WeakSet", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "_StringIterator")
151 * - _ESAbstract.GetIterator, License: CC0 (required by "Array.from", "default", "es2015", "Map", "Set", "WeakMap", "WeakSet")
152 * - Symbol.match, License: MIT (required by "es2015")
153 * - Symbol.replace, License: MIT (required by "es2015")
154 * - Symbol.search, License: MIT (required by "es2015")
155 * - Symbol.species, License: MIT (required by "es2015", "Map", "default", "Array.from", "Set")
156 * - Map, License: CC0 (required by "default", "es2015", "Array.from")
157 * - Set, License: CC0 (required by "default", "es2015", "Array.from")
158 * - Array.from, License: CC0 (required by "default", "es2015")
159 * - Symbol.split, License: MIT (required by "es2015")
160 * - Symbol.toPrimitive, License: MIT (required by "es2015")
161 * - Symbol.toStringTag, License: MIT (required by "es2015", "_Iterator", "_ArrayIterator", "Array.prototype.entries", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
162 * - _Iterator, License: MIT (required by "_ArrayIterator", "Array.prototype.entries", "es2015", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator", "_StringIterator", "String.prototype.@@iterator")
163 * - _ArrayIterator, License: MIT (required by "Array.prototype.entries", "es2015", "Array.prototype.keys", "Array.prototype.values", "Array.prototype.@@iterator")
164 * - Array.prototype.entries, License: CC0 (required by "es2015")
165 * - Array.prototype.keys, License: CC0 (required by "es2015")
166 * - Array.prototype.values, License: MIT (required by "es2015", "Array.prototype.@@iterator")
167 * - Array.prototype.@@iterator, License: CC0 (required by "es2015")
168 * - _StringIterator, License: MIT (required by "String.prototype.@@iterator", "es2015")
169 * - String.prototype.@@iterator, License: CC0 (required by "es2015")
170 * - Symbol.unscopables, License: MIT (required by "es2015")
171 * - URL, License: CC0-1.0 (required by "default")
172 * - WeakMap, License: MIT (required by "es2015")
173 * - WeakSet, License: MIT (required by "es2015")
174 * - Window, License: CC0 (required by "default", "Event", "CustomEvent", "Event.focusin", "Event.hashchange")
175 * - Event, License: CC0 (required by "default", "CustomEvent", "Event.focusin", "Event.hashchange", "XMLHttpRequest")
176 * - CustomEvent, License: CC0 (required by "default", "document.visibilityState")
177 * - document.visibilityState, License: CC0 (required by "default")
178 * - Event.focusin, License: CC0 (required by "default")
179 * - Event.hashchange, License: CC0 (required by "default")
180 * - XMLHttpRequest, License: CC0 (required by "default") */
181
182(function(undefined) {
183
184// _ESAbstract.ArrayCreate
185// 9.4.2.2. ArrayCreate ( length [ , proto ] )
186function ArrayCreate(length /* [, proto] */) { // eslint-disable-line no-unused-vars
187 // 1. Assert: length is an integer Number ≥ 0.
188 // 2. If length is -0, set length to +0.
189 if (1 / length === -Infinity) {
190 length = 0;
191 }
192 // 3. If length>2^32-1, throw a RangeError exception.
193 if (length > (Math.pow(2, 32) - 1)) {
194 throw new RangeError('Invalid array length');
195 }
196 // 4. If proto is not present, set proto to the intrinsic object %ArrayPrototype%.
197 // 5. Let A be a newly created Array exotic object.
198 var A = [];
199 // 6. Set A's essential internal methods except for [[DefineOwnProperty]] to the default ordinary object definitions specified in 9.1.
200 // 7. Set A.[[DefineOwnProperty]] as specified in 9.4.2.1.
201 // 8. Set A.[[Prototype]] to proto.
202 // 9. Set A.[[Extensible]] to true.
203 // 10. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor{[[Value]]: length, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
204 A.length = length;
205 // 11. Return A.
206 return A;
207}
208
209// _ESAbstract.Call
210/* global IsCallable */
211// 7.3.12. Call ( F, V [ , argumentsList ] )
212function Call(F, V /* [, argumentsList] */) { // eslint-disable-line no-unused-vars
213 // 1. If argumentsList is not present, set argumentsList to a new empty List.
214 var argumentsList = arguments.length > 2 ? arguments[2] : [];
215 // 2. If IsCallable(F) is false, throw a TypeError exception.
216 if (IsCallable(F) === false) {
217 throw new TypeError(Object.prototype.toString.call(F) + 'is not a function.');
218 }
219 // 3. Return ? F.[[Call]](V, argumentsList).
220 return F.apply(V, argumentsList);
221}
222
223// _ESAbstract.Get
224// 7.3.1. Get ( O, P )
225function Get(O, P) { // eslint-disable-line no-unused-vars
226 // 1. Assert: Type(O) is Object.
227 // 2. Assert: IsPropertyKey(P) is true.
228 // 3. Return ? O.[[Get]](P, O).
229 return O[P];
230}
231
232// _ESAbstract.HasProperty
233// 7.3.10. HasProperty ( O, P )
234function HasProperty(O, P) { // eslint-disable-line no-unused-vars
235 // Assert: Type(O) is Object.
236 // Assert: IsPropertyKey(P) is true.
237 // Return ? O.[[HasProperty]](P).
238 return P in O;
239}
240
241// _ESAbstract.IsArray
242// 7.2.2. IsArray ( argument )
243function IsArray(argument) { // eslint-disable-line no-unused-vars
244 // 1. If Type(argument) is not Object, return false.
245 // 2. If argument is an Array exotic object, return true.
246 // 3. If argument is a Proxy exotic object, then
247 // a. If argument.[[ProxyHandler]] is null, throw a TypeError exception.
248 // b. Let target be argument.[[ProxyTarget]].
249 // c. Return ? IsArray(target).
250 // 4. Return false.
251
252 // Polyfill.io - We can skip all the above steps and check the string returned from Object.prototype.toString().
253 return Object.prototype.toString.call(argument) === '[object Array]';
254}
255
256// _ESAbstract.IsCallable
257// 7.2.3. IsCallable ( argument )
258function IsCallable(argument) { // eslint-disable-line no-unused-vars
259 // 1. If Type(argument) is not Object, return false.
260 // 2. If argument has a [[Call]] internal method, return true.
261 // 3. Return false.
262
263 // 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.
264 return typeof argument === 'function';
265}
266
267// _ESAbstract.RequireObjectCoercible
268// 7.2.1. RequireObjectCoercible ( argument )
269// The abstract operation ToObject converts argument to a value of type Object according to Table 12:
270// Table 12: ToObject Conversions
271/*
272|----------------------------------------------------------------------------------------------------------------------------------------------------|
273| Argument Type | Result |
274|----------------------------------------------------------------------------------------------------------------------------------------------------|
275| Undefined | Throw a TypeError exception. |
276| Null | Throw a TypeError exception. |
277| Boolean | Return argument. |
278| Number | Return argument. |
279| String | Return argument. |
280| Symbol | Return argument. |
281| Object | Return argument. |
282|----------------------------------------------------------------------------------------------------------------------------------------------------|
283*/
284function RequireObjectCoercible(argument) { // eslint-disable-line no-unused-vars
285 if (argument === null || argument === undefined) {
286 throw TypeError();
287 }
288 return argument;
289}
290
291// _ESAbstract.SameValueNonNumber
292// 7.2.12. SameValueNonNumber ( x, y )
293function SameValueNonNumber(x, y) { // eslint-disable-line no-unused-vars
294 // 1. Assert: Type(x) is not Number.
295 // 2. Assert: Type(x) is the same as Type(y).
296 // 3. If Type(x) is Undefined, return true.
297 // 4. If Type(x) is Null, return true.
298 // 5. If Type(x) is String, then
299 // 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.
300 // 6. If Type(x) is Boolean, then
301 // a. If x and y are both true or both false, return true; otherwise, return false.
302 // 7. If Type(x) is Symbol, then
303 // a. If x and y are both the same Symbol value, return true; otherwise, return false.
304 // 8. If x and y are the same Object value, return true. Otherwise, return false.
305
306 // Polyfill.io - We can skip all above steps because the === operator does it all for us.
307 return x === y;
308}
309
310// _ESAbstract.ToBoolean
311// 7.1.2. ToBoolean ( argument )
312// The abstract operation ToBoolean converts argument to a value of type Boolean according to Table 9:
313/*
314--------------------------------------------------------------------------------------------------------------
315| Argument Type | Result |
316--------------------------------------------------------------------------------------------------------------
317| Undefined | Return false. |
318| Null | Return false. |
319| Boolean | Return argument. |
320| Number | If argument is +0, -0, or NaN, return false; otherwise return true. |
321| String | If argument is the empty String (its length is zero), return false; otherwise return true. |
322| Symbol | Return true. |
323| Object | Return true. |
324--------------------------------------------------------------------------------------------------------------
325*/
326function ToBoolean(argument) { // eslint-disable-line no-unused-vars
327 return Boolean(argument);
328}
329
330// _ESAbstract.ToInteger
331// 7.1.4. ToInteger ( argument )
332function ToInteger(argument) { // eslint-disable-line no-unused-vars
333 // 1. Let number be ? ToNumber(argument).
334 var number = Number(argument);
335 // 2. If number is NaN, return +0.
336 if (isNaN(number)) {
337 return 0;
338 }
339 // 3. If number is +0, -0, +∞, or -∞, return number.
340 if (1/number === Infinity || 1/number === -Infinity || number === Infinity || number === -Infinity) {
341 return number;
342 }
343 // 4. Return the number value that is the same sign as number and whose magnitude is floor(abs(number)).
344 return ((number < 0) ? -1 : 1) * Math.floor(Math.abs(number));
345}
346
347// _ESAbstract.ToLength
348/* global ToInteger */
349// 7.1.15. ToLength ( argument )
350function ToLength(argument) { // eslint-disable-line no-unused-vars
351 // 1. Let len be ? ToInteger(argument).
352 var len = ToInteger(argument);
353 // 2. If len ≤ +0, return +0.
354 if (len <= 0) {
355 return 0;
356 }
357 // 3. Return min(len, 253-1).
358 return Math.min(len, Math.pow(2, 53) -1);
359}
360
361// _ESAbstract.ToObject
362// 7.1.13 ToObject ( argument )
363// The abstract operation ToObject converts argument to a value of type Object according to Table 12:
364// Table 12: ToObject Conversions
365/*
366|----------------------------------------------------------------------------------------------------------------------------------------------------|
367| Argument Type | Result |
368|----------------------------------------------------------------------------------------------------------------------------------------------------|
369| Undefined | Throw a TypeError exception. |
370| Null | Throw a TypeError exception. |
371| Boolean | Return a new Boolean object whose [[BooleanData]] internal slot is set to argument. See 19.3 for a description of Boolean objects. |
372| Number | Return a new Number object whose [[NumberData]] internal slot is set to argument. See 20.1 for a description of Number objects. |
373| String | Return a new String object whose [[StringData]] internal slot is set to argument. See 21.1 for a description of String objects. |
374| Symbol | Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 19.4 for a description of Symbol objects. |
375| Object | Return argument. |
376|----------------------------------------------------------------------------------------------------------------------------------------------------|
377*/
378function ToObject(argument) { // eslint-disable-line no-unused-vars
379 if (argument === null || argument === undefined) {
380 throw TypeError();
381 }
382 return Object(argument);
383}
384
385// _ESAbstract.GetV
386/* global ToObject */
387// 7.3.2 GetV (V, P)
388function GetV(v, p) { // eslint-disable-line no-unused-vars
389 // 1. Assert: IsPropertyKey(P) is true.
390 // 2. Let O be ? ToObject(V).
391 var o = ToObject(v);
392 // 3. Return ? O.[[Get]](P, V).
393 return o[p];
394}
395
396// _ESAbstract.GetMethod
397/* global GetV, IsCallable */
398// 7.3.9. GetMethod ( V, P )
399function GetMethod(V, P) { // eslint-disable-line no-unused-vars
400 // 1. Assert: IsPropertyKey(P) is true.
401 // 2. Let func be ? GetV(V, P).
402 var func = GetV(V, P);
403 // 3. If func is either undefined or null, return undefined.
404 if (func === null || func === undefined) {
405 return undefined;
406 }
407 // 4. If IsCallable(func) is false, throw a TypeError exception.
408 if (IsCallable(func) === false) {
409 throw new TypeError('Method not callable: ' + P);
410 }
411 // 5. Return func.
412 return func;
413}
414
415// _ESAbstract.ToUint32
416// 7.1.6. ToUint32 ( argument )
417function ToUint32(argument) { // eslint-disable-line no-unused-vars
418 // 1. Let number be ? ToNumber(argument).
419 var number = Number(argument);
420 // 2. If number is NaN, +0, -0, +∞, or -∞, return +0.
421 if (isNaN(number) || 1/number === Infinity || 1/number === -Infinity || number === Infinity || number === -Infinity) {
422 return 0;
423 }
424 // 3. Let int be the mathematical value that is the same sign as number and whose magnitude is floor(abs(number)).
425 var int = ((number < 0) ? -1 : 1) * Math.floor(Math.abs(number));
426 // 4. Let int32bit be int modulo 2^32.
427 var int32bit = int >>> 0;
428 // 5. Return int32bit.
429 return int32bit;
430}
431
432// _ESAbstract.Type
433// "Type(x)" is used as shorthand for "the type of x"...
434function Type(x) { // eslint-disable-line no-unused-vars
435 switch (typeof x) {
436 case 'undefined':
437 return 'undefined';
438 case 'boolean':
439 return 'boolean';
440 case 'number':
441 return 'number';
442 case 'string':
443 return 'string';
444 case 'symbol':
445 return 'symbol';
446 default:
447 // typeof null is 'object'
448 if (x === null) return 'null';
449 // Polyfill.io - This is here because a Symbol polyfill will have a typeof `object`.
450 if ('Symbol' in this && x instanceof this.Symbol) return 'symbol';
451 return 'object';
452 }
453}
454
455// _ESAbstract.GetPrototypeFromConstructor
456/* global Get, Type */
457// 9.1.14. GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
458function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
459 // 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.
460 // 2. Assert: IsCallable(constructor) is true.
461 // 3. Let proto be ? Get(constructor, "prototype").
462 var proto = Get(constructor, "prototype");
463 // 4. If Type(proto) is not Object, then
464 if (Type(proto) !== 'object') {
465 // a. Let realm be ? GetFunctionRealm(constructor).
466 // b. Set proto to realm's intrinsic object named intrinsicDefaultProto.
467 proto = intrinsicDefaultProto;
468 }
469 // 5. Return proto.
470 return proto;
471}
472
473// _ESAbstract.IsConstructor
474/* global Type */
475// 7.2.4. IsConstructor ( argument )
476function IsConstructor(argument) { // eslint-disable-line no-unused-vars
477 // 1. If Type(argument) is not Object, return false.
478 if (Type(argument) !== 'object') {
479 return false;
480 }
481 // 2. If argument has a [[Construct]] internal method, return true.
482 // 3. Return false.
483
484 // Polyfill.io - `new argument` is the only way to truly test if a function is a constructor.
485 // We choose to not use`new argument` because the argument could have side effects when called.
486 // Instead we check to see if the argument is a function and if it has a prototype.
487 // Arrow functions do not have a [[Construct]] internal method, nor do they have a prototype.
488 return typeof argument === 'function' && !!argument.prototype;
489}
490
491// _ESAbstract.IsRegExp
492/* global Type, Get, ToBoolean */
493// 7.2.8. IsRegExp ( argument )
494function IsRegExp(argument) { // eslint-disable-line no-unused-vars
495 // 1. If Type(argument) is not Object, return false.
496 if (Type(argument) !== 'object') {
497 return false;
498 }
499 // 2. Let matcher be ? Get(argument, @@match).
500 var matcher = 'Symbol' in this && 'match' in this.Symbol ? Get(argument, this.Symbol.match) : undefined;
501 // 3. If matcher is not undefined, return ToBoolean(matcher).
502 if (matcher !== undefined) {
503 return ToBoolean(matcher);
504 }
505 // 4. If argument has a [[RegExpMatcher]] internal slot, return true.
506 try {
507 var lastIndex = argument.lastIndex;
508 argument.lastIndex = 0;
509 RegExp.prototype.exec.call(argument);
510 return true;
511 } catch (e) {} finally {
512 argument.lastIndex = lastIndex;
513 }
514 // 5. Return false.
515 return false;
516}
517
518// _ESAbstract.IteratorClose
519/* global GetMethod, Type, Call */
520// 7.4.6. IteratorClose ( iteratorRecord, completion )
521function IteratorClose(iteratorRecord, completion) { // eslint-disable-line no-unused-vars
522 // 1. Assert: Type(iteratorRecord.[[Iterator]]) is Object.
523 if (Type(iteratorRecord['[[Iterator]]']) !== 'object') {
524 throw new Error(Object.prototype.toString.call(iteratorRecord['[[Iterator]]']) + 'is not an Object.');
525 }
526 // 2. Assert: completion is a Completion Record.
527 // Polyfill.io - Ignoring this step as there is no way to check if something is a Completion Record in userland JavaScript.
528
529 // 3. Let iterator be iteratorRecord.[[Iterator]].
530 var iterator = iteratorRecord['[[Iterator]]'];
531 // 4. Let return be ? GetMethod(iterator, "return").
532 // 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).
533 var returnMethod = GetMethod(iterator, "return");
534 // 5. If return is undefined, return Completion(completion).
535 if (returnMethod === undefined) {
536 return completion;
537 }
538 // 6. Let innerResult be Call(return, iterator, « »).
539 try {
540 var innerResult = Call(returnMethod, iterator);
541 } catch (error) {
542 var innerException = error;
543 }
544 // 7. If completion.[[Type]] is throw, return Completion(completion).
545 if (completion) {
546 return completion;
547 }
548 // 8. If innerResult.[[Type]] is throw, return Completion(innerResult).
549 if (innerException) {
550 throw innerException;
551 }
552 // 9. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception.
553 if (Type(innerResult) !== 'object') {
554 throw new TypeError("Iterator's return method returned a non-object.");
555 }
556 // 10. Return Completion(completion).
557 return completion;
558}
559
560// _ESAbstract.IteratorComplete
561/* global Type, ToBoolean, Get */
562// 7.4.3 IteratorComplete ( iterResult )
563function IteratorComplete(iterResult) { // eslint-disable-line no-unused-vars
564 // 1. Assert: Type(iterResult) is Object.
565 if (Type(iterResult) !== 'object') {
566 throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
567 }
568 // 2. Return ToBoolean(? Get(iterResult, "done")).
569 return ToBoolean(Get(iterResult, "done"));
570}
571
572// _ESAbstract.IteratorNext
573/* global Call, Type */
574// 7.4.2. IteratorNext ( iteratorRecord [ , value ] )
575function IteratorNext(iteratorRecord /* [, value] */) { // eslint-disable-line no-unused-vars
576 // 1. If value is not present, then
577 if (arguments.length < 2) {
578 // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « »).
579 var result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]']);
580 // 2. Else,
581 } else {
582 // a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « value »).
583 result = Call(iteratorRecord['[[NextMethod]]'], iteratorRecord['[[Iterator]]'], [arguments[1]]);
584 }
585 // 3. If Type(result) is not Object, throw a TypeError exception.
586 if (Type(result) !== 'object') {
587 throw new TypeError('bad iterator');
588 }
589 // 4. Return result.
590 return result;
591}
592
593// _ESAbstract.IteratorStep
594/* global IteratorNext, IteratorComplete */
595// 7.4.5. IteratorStep ( iteratorRecord )
596function IteratorStep(iteratorRecord) { // eslint-disable-line no-unused-vars
597 // 1. Let result be ? IteratorNext(iteratorRecord).
598 var result = IteratorNext(iteratorRecord);
599 // 2. Let done be ? IteratorComplete(result).
600 var done = IteratorComplete(result);
601 // 3. If done is true, return false.
602 if (done === true) {
603 return false;
604 }
605 // 4. Return result.
606 return result;
607}
608
609// _ESAbstract.IteratorValue
610/* global Type, Get */
611// 7.4.4 IteratorValue ( iterResult )
612function IteratorValue(iterResult) { // eslint-disable-line no-unused-vars
613 // Assert: Type(iterResult) is Object.
614 if (Type(iterResult) !== 'object') {
615 throw new Error(Object.prototype.toString.call(iterResult) + 'is not an Object.');
616 }
617 // Return ? Get(iterResult, "value").
618 return Get(iterResult, "value");
619}
620
621// _ESAbstract.OrdinaryToPrimitive
622/* global Get, IsCallable, Call, Type */
623// 7.1.1.1. OrdinaryToPrimitive ( O, hint )
624function OrdinaryToPrimitive(O, hint) { // eslint-disable-line no-unused-vars
625 // 1. Assert: Type(O) is Object.
626 // 2. Assert: Type(hint) is String and its value is either "string" or "number".
627 // 3. If hint is "string", then
628 if (hint === 'string') {
629 // a. Let methodNames be « "toString", "valueOf" ».
630 var methodNames = ['toString', 'valueOf'];
631 // 4. Else,
632 } else {
633 // a. Let methodNames be « "valueOf", "toString" ».
634 methodNames = ['valueOf', 'toString'];
635 }
636 // 5. For each name in methodNames in List order, do
637 for (var i = 0; i < methodNames.length; ++i) {
638 var name = methodNames[i];
639 // a. Let method be ? Get(O, name).
640 var method = Get(O, name);
641 // b. If IsCallable(method) is true, then
642 if (IsCallable(method)) {
643 // i. Let result be ? Call(method, O).
644 var result = Call(method, O);
645 // ii. If Type(result) is not Object, return result.
646 if (Type(result) !== 'object') {
647 return result;
648 }
649 }
650 }
651 // 6. Throw a TypeError exception.
652 throw new TypeError('Cannot convert to primitive.');
653}
654
655// _ESAbstract.SameValue
656/* global Type, SameValueNonNumber */
657// 7.2.10. SameValue ( x, y )
658function SameValue(x, y) { // eslint-disable-line no-unused-vars
659 // 1. If Type(x) is different from Type(y), return false.
660 if (Type(x) !== Type(y)) {
661 return false;
662 }
663 // 2. If Type(x) is Number, then
664 if (Type(x) === 'number') {
665 // a. If x is NaN and y is NaN, return true.
666 if (isNaN(x) && isNaN(y)) {
667 return true;
668 }
669 // Polyfill.io - 0 === -0 is true, but they are not the same value.
670 // b. If x is +0 and y is -0, return false.
671 // c. If x is -0 and y is +0, return false.
672 if (x === 0 && y === 0 && 1/x !== 1/y) {
673 return false;
674 }
675 // d. If x is the same Number value as y, return true.
676 if (x === y) {
677 return true;
678 }
679 // e. Return false.
680 return false;
681 }
682 // 3. Return SameValueNonNumber(x, y).
683 return SameValueNonNumber(x, y);
684}
685
686// _ESAbstract.SameValueZero
687/* global Type, SameValueNonNumber */
688// 7.2.11. SameValueZero ( x, y )
689function SameValueZero (x, y) { // eslint-disable-line no-unused-vars
690 // 1. If Type(x) is different from Type(y), return false.
691 if (Type(x) !== Type(y)) {
692 return false;
693 }
694 // 2. If Type(x) is Number, then
695 if (Type(x) === 'number') {
696 // a. If x is NaN and y is NaN, return true.
697 if (isNaN(x) && isNaN(y)) {
698 return true;
699 }
700 // b. If x is +0 and y is -0, return true.
701 if (1/x === Infinity && 1/y === -Infinity) {
702 return true;
703 }
704 // c. If x is -0 and y is +0, return true.
705 if (1/x === -Infinity && 1/y === Infinity) {
706 return true;
707 }
708 // d. If x is the same Number value as y, return true.
709 if (x === y) {
710 return true;
711 }
712 // e. Return false.
713 return false;
714 }
715 // 3. Return SameValueNonNumber(x, y).
716 return SameValueNonNumber(x, y);
717}
718
719// _ESAbstract.SpeciesConstructor
720/* global Get, Type, IsConstructor */
721// 7.3.20 SpeciesConstructor(O, defaultConstructor)
722function SpeciesConstructor (O, defaultConstructor) { // eslint-disable-line no-unused-vars
723 // 7.3.20.1 Assert: Type(O) is Object.
724 // 7.3.20.2 Let C be ? Get(O, "constructor").
725 var C = Get(O, "constructor");
726 // 7.3.20.3 If C is undefined, return defaultConstructor.
727 if (C === undefined) {
728 return defaultConstructor;
729 }
730 // 7.3.20.4 If Type(C) is not Object, throw a TypeError exception
731 if (Type(C) !== 'object') {
732 throw new TypeError('O.constructor is not an Object');
733 }
734 // 7.3.20.5 Let S be ? Get(C, @@species).
735 var S = typeof this.Symbol === 'function' && typeof this.Symbol.species === 'symbol' ? C[this.Symbol.species] : undefined;
736 // 7.3.20.6 If S is either undefined or null, return defaultConstructor.
737 if (S === undefined || S === null) {
738 return defaultConstructor;
739 }
740 // 7.3.20.7 If IsConstructor(S) is true, return S.
741 if (IsConstructor(S)) {
742 return S;
743 }
744 // 7.3.20.8 Throw a TypeError exception.
745 throw new TypeError('No constructor found');
746}
747
748// _ESAbstract.ToPrimitive
749/* global Type, GetMethod, Call, OrdinaryToPrimitive */
750// 7.1.1. ToPrimitive ( input [ , PreferredType ] )
751function ToPrimitive(input /* [, PreferredType] */) { // eslint-disable-line no-unused-vars
752 var PreferredType = arguments.length > 1 ? arguments[1] : undefined;
753 // 1. Assert: input is an ECMAScript language value.
754 // 2. If Type(input) is Object, then
755 if (Type(input) === 'object') {
756 // a. If PreferredType is not present, let hint be "default".
757 if (arguments.length < 2) {
758 var hint = 'default';
759 // b. Else if PreferredType is hint String, let hint be "string".
760 } else if (PreferredType === String) {
761 hint = 'string';
762 // c. Else PreferredType is hint Number, let hint be "number".
763 } else if (PreferredType === Number) {
764 hint = 'number';
765 }
766 // d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
767 var exoticToPrim = typeof this.Symbol === 'function' && typeof this.Symbol.toPrimitive === 'symbol' ? GetMethod(input, this.Symbol.toPrimitive) : undefined;
768 // e. If exoticToPrim is not undefined, then
769 if (exoticToPrim !== undefined) {
770 // i. Let result be ? Call(exoticToPrim, input, « hint »).
771 var result = Call(exoticToPrim, input, [hint]);
772 // ii. If Type(result) is not Object, return result.
773 if (Type(result) !== 'object') {
774 return result;
775 }
776 // iii. Throw a TypeError exception.
777 throw new TypeError('Cannot convert exotic object to primitive.');
778 }
779 // f. If hint is "default", set hint to "number".
780 if (hint === 'default') {
781 hint = 'number';
782 }
783 // g. Return ? OrdinaryToPrimitive(input, hint).
784 return OrdinaryToPrimitive(input, hint);
785 }
786 // 3. Return input
787 return input;
788}
789
790// _ESAbstract.ToString
791/* global Type, ToPrimitive */
792// 7.1.12. ToString ( argument )
793// The abstract operation ToString converts argument to a value of type String according to Table 11:
794// Table 11: ToString Conversions
795/*
796|---------------|--------------------------------------------------------|
797| Argument Type | Result |
798|---------------|--------------------------------------------------------|
799| Undefined | Return "undefined". |
800|---------------|--------------------------------------------------------|
801| Null | Return "null". |
802|---------------|--------------------------------------------------------|
803| Boolean | If argument is true, return "true". |
804| | If argument is false, return "false". |
805|---------------|--------------------------------------------------------|
806| Number | Return NumberToString(argument). |
807|---------------|--------------------------------------------------------|
808| String | Return argument. |
809|---------------|--------------------------------------------------------|
810| Symbol | Throw a TypeError exception. |
811|---------------|--------------------------------------------------------|
812| Object | Apply the following steps: |
813| | Let primValue be ? ToPrimitive(argument, hint String). |
814| | Return ? ToString(primValue). |
815|---------------|--------------------------------------------------------|
816*/
817function ToString(argument) { // eslint-disable-line no-unused-vars
818 switch(Type(argument)) {
819 case 'symbol':
820 throw new TypeError('Cannot convert a Symbol value to a string');
821 break;
822 case 'object':
823 var primValue = ToPrimitive(argument, 'string');
824 return ToString(primValue);
825 default:
826 return String(argument);
827 }
828}
829
830// _ESAbstract.UTF16Decode
831// 10.1.2. Static Semantics: UTF16Decode( lead, trail )
832function UTF16Decode(lead, trail) { // eslint-disable-line no-unused-vars
833 // 1. Assert: 0xD800 ≤ lead ≤ 0xDBFF and 0xDC00 ≤ trail ≤ 0xDFFF.
834 // 2. Let cp be (lead - 0xD800) × 0x400 + (trail - 0xDC00) + 0x10000.
835 var cp = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
836 // 3. Return the code point cp.
837 return cp;
838}
839
840// _TypedArray
841/*
842 Copyright (c) 2010, Linden Research, Inc.
843 Copyright (c) 2014, Joshua Bell
844
845 Permission is hereby granted, free of charge, to any person obtaining a copy
846 of this software and associated documentation files (the "Software"), to deal
847 in the Software without restriction, including without limitation the rights
848 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
849 copies of the Software, and to permit persons to whom the Software is
850 furnished to do so, subject to the following conditions:
851
852 The above copyright notice and this permission notice shall be included in
853 all copies or substantial portions of the Software.
854
855 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
856 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
857 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
858 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
859 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
860 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
861 THE SOFTWARE.
862 $/LicenseInfo$
863 */
864
865// Original can be found at:
866// https://bitbucket.org/lindenlab/llsd
867// Modifications by Joshua Bell inexorabletash@gmail.com
868// https://github.com/inexorabletash/polyfill
869
870// ES3/ES5 implementation of the Krhonos Typed Array Specification
871// Ref: http://www.khronos.org/registry/typedarray/specs/latest/
872// Date: 2011-02-01
873//
874// Variations:
875// * Allows typed_array.get/set() as alias for subscripts (typed_array[])
876// * Gradually migrating structure from Khronos spec to ES2015 spec
877//
878// Caveats:
879// * Beyond 10000 or so entries, polyfilled array accessors (ta[0],
880// etc) become memory-prohibitive, so array creation will fail. Set
881// self.TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS=true to disable
882// creation of accessors. Your code will need to use the
883// non-standard get()/set() instead, and will need to add those to
884// native arrays for interop.
885(function(global) {
886 'use strict';
887 var undefined = (void 0); // Paranoia
888
889 // Beyond this value, index getters/setters (i.e. array[0], array[1]) are so slow to
890 // create, and consume so much memory, that the browser appears frozen.
891 var MAX_ARRAY_LENGTH = 1e5;
892
893 // Approximations of internal ECMAScript conversion functions
894 function Type(v) {
895 switch(typeof v) {
896 case 'undefined': return 'undefined';
897 case 'boolean': return 'boolean';
898 case 'number': return 'number';
899 case 'string': return 'string';
900 default: return v === null ? 'null' : 'object';
901 }
902 }
903
904 // Class returns internal [[Class]] property, used to avoid cross-frame instanceof issues:
905 function Class(v) { return Object.prototype.toString.call(v).replace(/^\[object *|\]$/g, ''); }
906 function IsCallable(o) { return typeof o === 'function'; }
907 function ToObject(v) {
908 if (v === null || v === undefined) throw TypeError();
909 return Object(v);
910 }
911 function ToInt32(v) { return v >> 0; }
912 function ToUint32(v) { return v >>> 0; }
913
914 // Snapshot intrinsics
915 var LN2 = Math.LN2,
916 abs = Math.abs,
917 floor = Math.floor,
918 log = Math.log,
919 max = Math.max,
920 min = Math.min,
921 pow = Math.pow,
922 round = Math.round;
923
924 // emulate ES5 getter/setter API using legacy APIs
925 // http://blogs.msdn.com/b/ie/archive/2010/09/07/transitioning-existing-code-to-the-es5-getter-setter-apis.aspx
926 // (second clause tests for Object.defineProperty() in IE<9 that only supports extending DOM prototypes, but
927 // note that IE<9 does not support __defineGetter__ or __defineSetter__ so it just renders the method harmless)
928
929 (function() {
930 var orig = Object.defineProperty;
931 var dom_only = !(function(){try{return Object.defineProperty({},'x',{});}catch(_){return false;}}());
932
933 if (!orig || dom_only) {
934 Object.defineProperty = function (o, prop, desc) {
935 // In IE8 try built-in implementation for defining properties on DOM prototypes.
936 if (orig)
937 try { return orig(o, prop, desc); } catch (_) {}
938 if (o !== Object(o))
939 throw TypeError('Object.defineProperty called on non-object');
940 if (Object.prototype.__defineGetter__ && ('get' in desc))
941 Object.prototype.__defineGetter__.call(o, prop, desc.get);
942 if (Object.prototype.__defineSetter__ && ('set' in desc))
943 Object.prototype.__defineSetter__.call(o, prop, desc.set);
944 if ('value' in desc)
945 o[prop] = desc.value;
946 return o;
947 };
948 }
949 }());
950
951 // ES5: Make obj[index] an alias for obj._getter(index)/obj._setter(index, value)
952 // for index in 0 ... obj.length
953 function makeArrayAccessors(obj) {
954 if ('TYPED_ARRAY_POLYFILL_NO_ARRAY_ACCESSORS' in global)
955 return;
956
957 if (obj.length > MAX_ARRAY_LENGTH) throw RangeError('Array too large for polyfill');
958
959 function makeArrayAccessor(index) {
960 Object.defineProperty(obj, index, {
961 'get': function() { return obj._getter(index); },
962 'set': function(v) { obj._setter(index, v); },
963 enumerable: true,
964 configurable: false
965 });
966 }
967
968 var i;
969 for (i = 0; i < obj.length; i += 1) {
970 makeArrayAccessor(i);
971 }
972 }
973
974 // Internal conversion functions:
975 // pack<Type>() - take a number (interpreted as Type), output a byte array
976 // unpack<Type>() - take a byte array, output a Type-like number
977
978 function as_signed(value, bits) { var s = 32 - bits; return (value << s) >> s; }
979 function as_unsigned(value, bits) { var s = 32 - bits; return (value << s) >>> s; }
980
981 function packI8(n) { return [n & 0xff]; }
982 function unpackI8(bytes) { return as_signed(bytes[0], 8); }
983
984 function packU8(n) { return [n & 0xff]; }
985 function unpackU8(bytes) { return as_unsigned(bytes[0], 8); }
986
987 function packU8Clamped(n) { n = round(Number(n)); return [n < 0 ? 0 : n > 0xff ? 0xff : n & 0xff]; }
988
989 function packI16(n) { return [n & 0xff, (n >> 8) & 0xff]; }
990 function unpackI16(bytes) { return as_signed(bytes[1] << 8 | bytes[0], 16); }
991
992 function packU16(n) { return [n & 0xff, (n >> 8) & 0xff]; }
993 function unpackU16(bytes) { return as_unsigned(bytes[1] << 8 | bytes[0], 16); }
994
995 function packI32(n) { return [n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, (n >> 24) & 0xff]; }
996 function unpackI32(bytes) { return as_signed(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0], 32); }
997
998 function packU32(n) { return [n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, (n >> 24) & 0xff]; }
999 function unpackU32(bytes) { return as_unsigned(bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0], 32); }
1000
1001 function packIEEE754(v, ebits, fbits) {
1002
1003 var bias = (1 << (ebits - 1)) - 1;
1004
1005 function roundToEven(n) {
1006 var w = floor(n), f = n - w;
1007 if (f < 0.5)
1008 return w;
1009 if (f > 0.5)
1010 return w + 1;
1011 return w % 2 ? w + 1 : w;
1012 }
1013
1014 // Compute sign, exponent, fraction
1015 var s, e, f;
1016 if (v !== v) {
1017 // NaN
1018 // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping
1019 e = (1 << ebits) - 1; f = pow(2, fbits - 1); s = 0;
1020 } else if (v === Infinity || v === -Infinity) {
1021 e = (1 << ebits) - 1; f = 0; s = (v < 0) ? 1 : 0;
1022 } else if (v === 0) {
1023 e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0;
1024 } else {
1025 s = v < 0;
1026 v = abs(v);
1027
1028 if (v >= pow(2, 1 - bias)) {
1029 // Normalized
1030 e = min(floor(log(v) / LN2), 1023);
1031 var significand = v / pow(2, e);
1032 if (significand < 1) {
1033 e -= 1;
1034 significand *= 2;
1035 }
1036 if (significand >= 2) {
1037 e += 1;
1038 significand /= 2;
1039 }
1040 var d = pow(2, fbits);
1041 f = roundToEven(significand * d) - d;
1042 e += bias;
1043 if (f / d >= 1) {
1044 e += 1;
1045 f = 0;
1046 }
1047 if (e > 2 * bias) {
1048 // Overflow
1049 e = (1 << ebits) - 1;
1050 f = 0;
1051 }
1052 } else {
1053 // Denormalized
1054 e = 0;
1055 f = roundToEven(v / pow(2, 1 - bias - fbits));
1056 }
1057 }
1058
1059 // Pack sign, exponent, fraction
1060 var bits = [], i;
1061 for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = floor(f / 2); }
1062 for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = floor(e / 2); }
1063 bits.push(s ? 1 : 0);
1064 bits.reverse();
1065 var str = bits.join('');
1066
1067 // Bits to bytes
1068 var bytes = [];
1069 while (str.length) {
1070 bytes.unshift(parseInt(str.substring(0, 8), 2));
1071 str = str.substring(8);
1072 }
1073 return bytes;
1074 }
1075
1076 function unpackIEEE754(bytes, ebits, fbits) {
1077 // Bytes to bits
1078 var bits = [], i, j, b, str,
1079 bias, s, e, f;
1080
1081 for (i = 0; i < bytes.length; ++i) {
1082 b = bytes[i];
1083 for (j = 8; j; j -= 1) {
1084 bits.push(b % 2 ? 1 : 0); b = b >> 1;
1085 }
1086 }
1087 bits.reverse();
1088 str = bits.join('');
1089
1090 // Unpack sign, exponent, fraction
1091 bias = (1 << (ebits - 1)) - 1;
1092 s = parseInt(str.substring(0, 1), 2) ? -1 : 1;
1093 e = parseInt(str.substring(1, 1 + ebits), 2);
1094 f = parseInt(str.substring(1 + ebits), 2);
1095
1096 // Produce number
1097 if (e === (1 << ebits) - 1) {
1098 return f !== 0 ? NaN : s * Infinity;
1099 } else if (e > 0) {
1100 // Normalized
1101 return s * pow(2, e - bias) * (1 + f / pow(2, fbits));
1102 } else if (f !== 0) {
1103 // Denormalized
1104 return s * pow(2, -(bias - 1)) * (f / pow(2, fbits));
1105 } else {
1106 return s < 0 ? -0 : 0;
1107 }
1108 }
1109
1110 function unpackF64(b) { return unpackIEEE754(b, 11, 52); }
1111 function packF64(v) { return packIEEE754(v, 11, 52); }
1112 function unpackF32(b) { return unpackIEEE754(b, 8, 23); }
1113 function packF32(v) { return packIEEE754(v, 8, 23); }
1114
1115 //
1116 // 3 The ArrayBuffer Type
1117 //
1118
1119 (function() {
1120
1121 function ArrayBuffer(length) {
1122 length = ToInt32(length);
1123 if (length < 0) throw RangeError('ArrayBuffer size is not a small enough positive integer.');
1124 Object.defineProperty(this, 'byteLength', {value: length});
1125 Object.defineProperty(this, '_bytes', {value: Array(length)});
1126
1127 for (var i = 0; i < length; i += 1)
1128 this._bytes[i] = 0;
1129 }
1130
1131 global.ArrayBuffer = global.ArrayBuffer || ArrayBuffer;
1132
1133 //
1134 // 5 The Typed Array View Types
1135 //
1136
1137 function $TypedArray$() {
1138
1139 // %TypedArray% ( length )
1140 if (!arguments.length || typeof arguments[0] !== 'object') {
1141 return (function(length) {
1142 length = ToInt32(length);
1143 if (length < 0) throw RangeError('length is not a small enough positive integer.');
1144 Object.defineProperty(this, 'length', {value: length});
1145 Object.defineProperty(this, 'byteLength', {value: length * this.BYTES_PER_ELEMENT});
1146 Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(this.byteLength)});
1147 Object.defineProperty(this, 'byteOffset', {value: 0});
1148
1149 }).apply(this, arguments);
1150 }
1151
1152 // %TypedArray% ( typedArray )
1153 if (arguments.length >= 1 &&
1154 Type(arguments[0]) === 'object' &&
1155 arguments[0] instanceof $TypedArray$) {
1156 return (function(typedArray){
1157 if (this.constructor !== typedArray.constructor) throw TypeError();
1158
1159 var byteLength = typedArray.length * this.BYTES_PER_ELEMENT;
1160 Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(byteLength)});
1161 Object.defineProperty(this, 'byteLength', {value: byteLength});
1162 Object.defineProperty(this, 'byteOffset', {value: 0});
1163 Object.defineProperty(this, 'length', {value: typedArray.length});
1164
1165 for (var i = 0; i < this.length; i += 1)
1166 this._setter(i, typedArray._getter(i));
1167
1168 }).apply(this, arguments);
1169 }
1170
1171 // %TypedArray% ( array )
1172 if (arguments.length >= 1 &&
1173 Type(arguments[0]) === 'object' &&
1174 !(arguments[0] instanceof $TypedArray$) &&
1175 !(arguments[0] instanceof ArrayBuffer || Class(arguments[0]) === 'ArrayBuffer')) {
1176 return (function(array) {
1177
1178 var byteLength = array.length * this.BYTES_PER_ELEMENT;
1179 Object.defineProperty(this, 'buffer', {value: new ArrayBuffer(byteLength)});
1180 Object.defineProperty(this, 'byteLength', {value: byteLength});
1181 Object.defineProperty(this, 'byteOffset', {value: 0});
1182 Object.defineProperty(this, 'length', {value: array.length});
1183
1184 for (var i = 0; i < this.length; i += 1) {
1185 var s = array[i];
1186 this._setter(i, Number(s));
1187 }
1188 }).apply(this, arguments);
1189 }
1190
1191 // %TypedArray% ( buffer, byteOffset=0, length=undefined )
1192 if (arguments.length >= 1 &&
1193 Type(arguments[0]) === 'object' &&
1194 (arguments[0] instanceof ArrayBuffer || Class(arguments[0]) === 'ArrayBuffer')) {
1195 return (function(buffer, byteOffset, length) {
1196
1197 byteOffset = ToUint32(byteOffset);
1198 if (byteOffset > buffer.byteLength)
1199 throw RangeError('byteOffset out of range');
1200
1201 // The given byteOffset must be a multiple of the element
1202 // size of the specific type, otherwise an exception is raised.
1203 if (byteOffset % this.BYTES_PER_ELEMENT)
1204 throw RangeError('buffer length minus the byteOffset is not a multiple of the element size.');
1205
1206 if (length === undefined) {
1207 var byteLength = buffer.byteLength - byteOffset;
1208 if (byteLength % this.BYTES_PER_ELEMENT)
1209 throw RangeError('length of buffer minus byteOffset not a multiple of the element size');
1210 length = byteLength / this.BYTES_PER_ELEMENT;
1211
1212 } else {
1213 length = ToUint32(length);
1214 byteLength = length * this.BYTES_PER_ELEMENT;
1215 }
1216
1217 if ((byteOffset + byteLength) > buffer.byteLength)
1218 throw RangeError('byteOffset and length reference an area beyond the end of the buffer');
1219
1220 Object.defineProperty(this, 'buffer', {value: buffer});
1221 Object.defineProperty(this, 'byteLength', {value: byteLength});
1222 Object.defineProperty(this, 'byteOffset', {value: byteOffset});
1223 Object.defineProperty(this, 'length', {value: length});
1224
1225 }).apply(this, arguments);
1226 }
1227
1228 // %TypedArray% ( all other argument combinations )
1229 throw TypeError();
1230 }
1231
1232 // Properties of the %TypedArray Instrinsic Object
1233
1234 // %TypedArray%.from ( source , mapfn=undefined, thisArg=undefined )
1235 Object.defineProperty($TypedArray$, 'from', {value: function(iterable) {
1236 return new this(iterable);
1237 }});
1238
1239 // %TypedArray%.of ( ...items )
1240 Object.defineProperty($TypedArray$, 'of', {value: function(/*...items*/) {
1241 return new this(arguments);
1242 }});
1243
1244 // %TypedArray%.prototype
1245 var $TypedArrayPrototype$ = {};
1246 $TypedArray$.prototype = $TypedArrayPrototype$;
1247
1248 // WebIDL: getter type (unsigned long index);
1249 Object.defineProperty($TypedArray$.prototype, '_getter', {value: function(index) {
1250 if (arguments.length < 1) throw SyntaxError('Not enough arguments');
1251
1252 index = ToUint32(index);
1253 if (index >= this.length)
1254 return undefined;
1255
1256 var bytes = [], i, o;
1257 for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT;
1258 i < this.BYTES_PER_ELEMENT;
1259 i += 1, o += 1) {
1260 bytes.push(this.buffer._bytes[o]);
1261 }
1262 return this._unpack(bytes);
1263 }});
1264
1265 // NONSTANDARD: convenience alias for getter: type get(unsigned long index);
1266 Object.defineProperty($TypedArray$.prototype, 'get', {value: $TypedArray$.prototype._getter});
1267
1268 // WebIDL: setter void (unsigned long index, type value);
1269 Object.defineProperty($TypedArray$.prototype, '_setter', {value: function(index, value) {
1270 if (arguments.length < 2) throw SyntaxError('Not enough arguments');
1271
1272 index = ToUint32(index);
1273 if (index >= this.length)
1274 return;
1275
1276 var bytes = this._pack(value), i, o;
1277 for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT;
1278 i < this.BYTES_PER_ELEMENT;
1279 i += 1, o += 1) {
1280 this.buffer._bytes[o] = bytes[i];
1281 }
1282 }});
1283
1284 // get %TypedArray%.prototype.buffer
1285 // get %TypedArray%.prototype.byteLength
1286 // get %TypedArray%.prototype.byteOffset
1287 // -- applied directly to the object in the constructor
1288
1289 // %TypedArray%.prototype.constructor
1290 Object.defineProperty($TypedArray$.prototype, 'constructor', {value: $TypedArray$});
1291
1292 // %TypedArray%.prototype.copyWithin (target, start, end = this.length )
1293 Object.defineProperty($TypedArray$.prototype, 'copyWithin', {value: function(target, start) {
1294 var end = arguments[2];
1295
1296 var o = ToObject(this);
1297 var lenVal = o.length;
1298 var len = ToUint32(lenVal);
1299 len = max(len, 0);
1300 var relativeTarget = ToInt32(target);
1301 var to;
1302 if (relativeTarget < 0)
1303 to = max(len + relativeTarget, 0);
1304 else
1305 to = min(relativeTarget, len);
1306 var relativeStart = ToInt32(start);
1307 var from;
1308 if (relativeStart < 0)
1309 from = max(len + relativeStart, 0);
1310 else
1311 from = min(relativeStart, len);
1312 var relativeEnd;
1313 if (end === undefined)
1314 relativeEnd = len;
1315 else
1316 relativeEnd = ToInt32(end);
1317 var final;
1318 if (relativeEnd < 0)
1319 final = max(len + relativeEnd, 0);
1320 else
1321 final = min(relativeEnd, len);
1322 var count = min(final - from, len - to);
1323 var direction;
1324 if (from < to && to < from + count) {
1325 direction = -1;
1326 from = from + count - 1;
1327 to = to + count - 1;
1328 } else {
1329 direction = 1;
1330 }
1331 while (count > 0) {
1332 o._setter(to, o._getter(from));
1333 from = from + direction;
1334 to = to + direction;
1335 count = count - 1;
1336 }
1337 return o;
1338 }});
1339
1340 // %TypedArray%.prototype.entries ( )
1341 // -- defined in es6.js to shim browsers w/ native TypedArrays
1342
1343 // %TypedArray%.prototype.every ( callbackfn, thisArg = undefined )
1344 Object.defineProperty($TypedArray$.prototype, 'every', {value: function(callbackfn) {
1345 if (this === undefined || this === null) throw TypeError();
1346 var t = Object(this);
1347 var len = ToUint32(t.length);
1348 if (!IsCallable(callbackfn)) throw TypeError();
1349 var thisArg = arguments[1];
1350 for (var i = 0; i < len; i++) {
1351 if (!callbackfn.call(thisArg, t._getter(i), i, t))
1352 return false;
1353 }
1354 return true;
1355 }});
1356
1357 // %TypedArray%.prototype.fill (value, start = 0, end = this.length )
1358 Object.defineProperty($TypedArray$.prototype, 'fill', {value: function(value) {
1359 var start = arguments[1],
1360 end = arguments[2];
1361
1362 var o = ToObject(this);
1363 var lenVal = o.length;
1364 var len = ToUint32(lenVal);
1365 len = max(len, 0);
1366 var relativeStart = ToInt32(start);
1367 var k;
1368 if (relativeStart < 0)
1369 k = max((len + relativeStart), 0);
1370 else
1371 k = min(relativeStart, len);
1372 var relativeEnd;
1373 if (end === undefined)
1374 relativeEnd = len;
1375 else
1376 relativeEnd = ToInt32(end);
1377 var final;
1378 if (relativeEnd < 0)
1379 final = max((len + relativeEnd), 0);
1380 else
1381 final = min(relativeEnd, len);
1382 while (k < final) {
1383 o._setter(k, value);
1384 k += 1;
1385 }
1386 return o;
1387 }});
1388
1389 // %TypedArray%.prototype.filter ( callbackfn, thisArg = undefined )
1390 Object.defineProperty($TypedArray$.prototype, 'filter', {value: function(callbackfn) {
1391 if (this === undefined || this === null) throw TypeError();
1392 var t = Object(this);
1393 var len = ToUint32(t.length);
1394 if (!IsCallable(callbackfn)) throw TypeError();
1395 var res = [];
1396 var thisp = arguments[1];
1397 for (var i = 0; i < len; i++) {
1398 var val = t._getter(i); // in case fun mutates this
1399 if (callbackfn.call(thisp, val, i, t))
1400 res.push(val);
1401 }
1402 return new this.constructor(res);
1403 }});
1404
1405 // %TypedArray%.prototype.find (predicate, thisArg = undefined)
1406 Object.defineProperty($TypedArray$.prototype, 'find', {value: function(predicate) {
1407 var o = ToObject(this);
1408 var lenValue = o.length;
1409 var len = ToUint32(lenValue);
1410 if (!IsCallable(predicate)) throw TypeError();
1411 var t = arguments.length > 1 ? arguments[1] : undefined;
1412 var k = 0;
1413 while (k < len) {
1414 var kValue = o._getter(k);
1415 var testResult = predicate.call(t, kValue, k, o);
1416 if (Boolean(testResult))
1417 return kValue;
1418 ++k;
1419 }
1420 return undefined;
1421 }});
1422
1423 // %TypedArray%.prototype.findIndex ( predicate, thisArg = undefined )
1424 Object.defineProperty($TypedArray$.prototype, 'findIndex', {value: function(predicate) {
1425 var o = ToObject(this);
1426 var lenValue = o.length;
1427 var len = ToUint32(lenValue);
1428 if (!IsCallable(predicate)) throw TypeError();
1429 var t = arguments.length > 1 ? arguments[1] : undefined;
1430 var k = 0;
1431 while (k < len) {
1432 var kValue = o._getter(k);
1433 var testResult = predicate.call(t, kValue, k, o);
1434 if (Boolean(testResult))
1435 return k;
1436 ++k;
1437 }
1438 return -1;
1439 }});
1440
1441 // %TypedArray%.prototype.forEach ( callbackfn, thisArg = undefined )
1442 Object.defineProperty($TypedArray$.prototype, 'forEach', {value: function(callbackfn) {
1443 if (this === undefined || this === null) throw TypeError();
1444 var t = Object(this);
1445 var len = ToUint32(t.length);
1446 if (!IsCallable(callbackfn)) throw TypeError();
1447 var thisp = arguments[1];
1448 for (var i = 0; i < len; i++)
1449 callbackfn.call(thisp, t._getter(i), i, t);
1450 }});
1451
1452 // %TypedArray%.prototype.indexOf (searchElement, fromIndex = 0 )
1453 Object.defineProperty($TypedArray$.prototype, 'indexOf', {value: function(searchElement) {
1454 if (this === undefined || this === null) throw TypeError();
1455 var t = Object(this);
1456 var len = ToUint32(t.length);
1457 if (len === 0) return -1;
1458 var n = 0;
1459 if (arguments.length > 0) {
1460 n = Number(arguments[1]);
1461 if (n !== n) {
1462 n = 0;
1463 } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
1464 n = (n > 0 || -1) * floor(abs(n));
1465 }
1466 }
1467 if (n >= len) return -1;
1468 var k = n >= 0 ? n : max(len - abs(n), 0);
1469 for (; k < len; k++) {
1470 if (t._getter(k) === searchElement) {
1471 return k;
1472 }
1473 }
1474 return -1;
1475 }});
1476
1477 // %TypedArray%.prototype.join ( separator )
1478 Object.defineProperty($TypedArray$.prototype, 'join', {value: function(separator) {
1479 if (this === undefined || this === null) throw TypeError();
1480 var t = Object(this);
1481 var len = ToUint32(t.length);
1482 var tmp = Array(len);
1483 for (var i = 0; i < len; ++i)
1484 tmp[i] = t._getter(i);
1485 return tmp.join(separator === undefined ? ',' : separator); // Hack for IE7
1486 }});
1487
1488 // %TypedArray%.prototype.keys ( )
1489 // -- defined in es6.js to shim browsers w/ native TypedArrays
1490
1491 // %TypedArray%.prototype.lastIndexOf ( searchElement, fromIndex = this.length-1 )
1492 Object.defineProperty($TypedArray$.prototype, 'lastIndexOf', {value: function(searchElement) {
1493 if (this === undefined || this === null) throw TypeError();
1494 var t = Object(this);
1495 var len = ToUint32(t.length);
1496 if (len === 0) return -1;
1497 var n = len;
1498 if (arguments.length > 1) {
1499 n = Number(arguments[1]);
1500 if (n !== n) {
1501 n = 0;
1502 } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
1503 n = (n > 0 || -1) * floor(abs(n));
1504 }
1505 }
1506 var k = n >= 0 ? min(n, len - 1) : len - abs(n);
1507 for (; k >= 0; k--) {
1508 if (t._getter(k) === searchElement)
1509 return k;
1510 }
1511 return -1;
1512 }});
1513
1514 // get %TypedArray%.prototype.length
1515 // -- applied directly to the object in the constructor
1516
1517 // %TypedArray%.prototype.map ( callbackfn, thisArg = undefined )
1518 Object.defineProperty($TypedArray$.prototype, 'map', {value: function(callbackfn) {
1519 if (this === undefined || this === null) throw TypeError();
1520 var t = Object(this);
1521 var len = ToUint32(t.length);
1522 if (!IsCallable(callbackfn)) throw TypeError();
1523 var res = []; res.length = len;
1524 var thisp = arguments[1];
1525 for (var i = 0; i < len; i++)
1526 res[i] = callbackfn.call(thisp, t._getter(i), i, t);
1527 return new this.constructor(res);
1528 }});
1529
1530 // %TypedArray%.prototype.reduce ( callbackfn [, initialValue] )
1531 Object.defineProperty($TypedArray$.prototype, 'reduce', {value: function(callbackfn) {
1532 if (this === undefined || this === null) throw TypeError();
1533 var t = Object(this);
1534 var len = ToUint32(t.length);
1535 if (!IsCallable(callbackfn)) throw TypeError();
1536 // no value to return if no initial value and an empty array
1537 if (len === 0 && arguments.length === 1) throw TypeError();
1538 var k = 0;
1539 var accumulator;
1540 if (arguments.length >= 2) {
1541 accumulator = arguments[1];
1542 } else {
1543 accumulator = t._getter(k++);
1544 }
1545 while (k < len) {
1546 accumulator = callbackfn.call(undefined, accumulator, t._getter(k), k, t);
1547 k++;
1548 }
1549 return accumulator;
1550 }});
1551
1552 // %TypedArray%.prototype.reduceRight ( callbackfn [, initialValue] )
1553 Object.defineProperty($TypedArray$.prototype, 'reduceRight', {value: function(callbackfn) {
1554 if (this === undefined || this === null) throw TypeError();
1555 var t = Object(this);
1556 var len = ToUint32(t.length);
1557 if (!IsCallable(callbackfn)) throw TypeError();
1558 // no value to return if no initial value, empty array
1559 if (len === 0 && arguments.length === 1) throw TypeError();
1560 var k = len - 1;
1561 var accumulator;
1562 if (arguments.length >= 2) {
1563 accumulator = arguments[1];
1564 } else {
1565 accumulator = t._getter(k--);
1566 }
1567 while (k >= 0) {
1568 accumulator = callbackfn.call(undefined, accumulator, t._getter(k), k, t);
1569 k--;
1570 }
1571 return accumulator;
1572 }});
1573
1574 // %TypedArray%.prototype.reverse ( )
1575 Object.defineProperty($TypedArray$.prototype, 'reverse', {value: function() {
1576 if (this === undefined || this === null) throw TypeError();
1577 var t = Object(this);
1578 var len = ToUint32(t.length);
1579 var half = floor(len / 2);
1580 for (var i = 0, j = len - 1; i < half; ++i, --j) {
1581 var tmp = t._getter(i);
1582 t._setter(i, t._getter(j));
1583 t._setter(j, tmp);
1584 }
1585 return t;
1586 }});
1587
1588 // %TypedArray%.prototype.set(array, offset = 0 )
1589 // %TypedArray%.prototype.set(typedArray, offset = 0 )
1590 // WebIDL: void set(TypedArray array, optional unsigned long offset);
1591 // WebIDL: void set(sequence<type> array, optional unsigned long offset);
1592 Object.defineProperty($TypedArray$.prototype, 'set', {value: function(index, value) {
1593 if (arguments.length < 1) throw SyntaxError('Not enough arguments');
1594 var array, sequence, offset, len,
1595 i, s, d,
1596 byteOffset, byteLength, tmp;
1597
1598 if (typeof arguments[0] === 'object' && arguments[0].constructor === this.constructor) {
1599 // void set(TypedArray array, optional unsigned long offset);
1600 array = arguments[0];
1601 offset = ToUint32(arguments[1]);
1602
1603 if (offset + array.length > this.length) {
1604 throw RangeError('Offset plus length of array is out of range');
1605 }
1606
1607 byteOffset = this.byteOffset + offset * this.BYTES_PER_ELEMENT;
1608 byteLength = array.length * this.BYTES_PER_ELEMENT;
1609
1610 if (array.buffer === this.buffer) {
1611 tmp = [];
1612 for (i = 0, s = array.byteOffset; i < byteLength; i += 1, s += 1) {
1613 tmp[i] = array.buffer._bytes[s];
1614 }
1615 for (i = 0, d = byteOffset; i < byteLength; i += 1, d += 1) {
1616 this.buffer._bytes[d] = tmp[i];
1617 }
1618 } else {
1619 for (i = 0, s = array.byteOffset, d = byteOffset;
1620 i < byteLength; i += 1, s += 1, d += 1) {
1621 this.buffer._bytes[d] = array.buffer._bytes[s];
1622 }
1623 }
1624 } else if (typeof arguments[0] === 'object' && typeof arguments[0].length !== 'undefined') {
1625 // void set(sequence<type> array, optional unsigned long offset);
1626 sequence = arguments[0];
1627 len = ToUint32(sequence.length);
1628 offset = ToUint32(arguments[1]);
1629
1630 if (offset + len > this.length) {
1631 throw RangeError('Offset plus length of array is out of range');
1632 }
1633
1634 for (i = 0; i < len; i += 1) {
1635 s = sequence[i];
1636 this._setter(offset + i, Number(s));
1637 }
1638 } else {
1639 throw TypeError('Unexpected argument type(s)');
1640 }
1641 }});
1642
1643 // %TypedArray%.prototype.slice ( start, end )
1644 Object.defineProperty($TypedArray$.prototype, 'slice', {value: function(start, end) {
1645 var o = ToObject(this);
1646 var lenVal = o.length;
1647 var len = ToUint32(lenVal);
1648 var relativeStart = ToInt32(start);
1649 var k = (relativeStart < 0) ? max(len + relativeStart, 0) : min(relativeStart, len);
1650 var relativeEnd = (end === undefined) ? len : ToInt32(end);
1651 var final = (relativeEnd < 0) ? max(len + relativeEnd, 0) : min(relativeEnd, len);
1652 var count = final - k;
1653 var c = o.constructor;
1654 var a = new c(count);
1655 var n = 0;
1656 while (k < final) {
1657 var kValue = o._getter(k);
1658 a._setter(n, kValue);
1659 ++k;
1660 ++n;
1661 }
1662 return a;
1663 }});
1664
1665 // %TypedArray%.prototype.some ( callbackfn, thisArg = undefined )
1666 Object.defineProperty($TypedArray$.prototype, 'some', {value: function(callbackfn) {
1667 if (this === undefined || this === null) throw TypeError();
1668 var t = Object(this);
1669 var len = ToUint32(t.length);
1670 if (!IsCallable(callbackfn)) throw TypeError();
1671 var thisp = arguments[1];
1672 for (var i = 0; i < len; i++) {
1673 if (callbackfn.call(thisp, t._getter(i), i, t)) {
1674 return true;
1675 }
1676 }
1677 return false;
1678 }});
1679
1680 // %TypedArray%.prototype.sort ( comparefn )
1681 Object.defineProperty($TypedArray$.prototype, 'sort', {value: function(comparefn) {
1682 if (this === undefined || this === null) throw TypeError();
1683 var t = Object(this);
1684 var len = ToUint32(t.length);
1685 var tmp = Array(len);
1686 for (var i = 0; i < len; ++i)
1687 tmp[i] = t._getter(i);
1688 function sortCompare(x, y) {
1689 if (x !== x && y !== y) return +0;
1690 if (x !== x) return 1;
1691 if (y !== y) return -1;
1692 if (comparefn !== undefined) {
1693 return comparefn(x, y);
1694 }
1695 if (x < y) return -1;
1696 if (x > y) return 1;
1697 return +0;
1698 }
1699 tmp.sort(sortCompare);
1700 for (i = 0; i < len; ++i)
1701 t._setter(i, tmp[i]);
1702 return t;
1703 }});
1704
1705 // %TypedArray%.prototype.subarray(begin = 0, end = this.length )
1706 // WebIDL: TypedArray subarray(long begin, optional long end);
1707 Object.defineProperty($TypedArray$.prototype, 'subarray', {value: function(start, end) {
1708 function clamp(v, min, max) { return v < min ? min : v > max ? max : v; }
1709
1710 start = ToInt32(start);
1711 end = ToInt32(end);
1712
1713 if (arguments.length < 1) { start = 0; }
1714 if (arguments.length < 2) { end = this.length; }
1715
1716 if (start < 0) { start = this.length + start; }
1717 if (end < 0) { end = this.length + end; }
1718
1719 start = clamp(start, 0, this.length);
1720 end = clamp(end, 0, this.length);
1721
1722 var len = end - start;
1723 if (len < 0) {
1724 len = 0;
1725 }
1726
1727 return new this.constructor(
1728 this.buffer, this.byteOffset + start * this.BYTES_PER_ELEMENT, len);
1729 }});
1730
1731 // %TypedArray%.prototype.toLocaleString ( )
1732 // %TypedArray%.prototype.toString ( )
1733 // %TypedArray%.prototype.values ( )
1734 // %TypedArray%.prototype [ @@iterator ] ( )
1735 // get %TypedArray%.prototype [ @@toStringTag ]
1736 // -- defined in es6.js to shim browsers w/ native TypedArrays
1737
1738 function makeTypedArray(elementSize, pack, unpack) {
1739 // Each TypedArray type requires a distinct constructor instance with
1740 // identical logic, which this produces.
1741 var TypedArray = function() {
1742 Object.defineProperty(this, 'constructor', {value: TypedArray});
1743 $TypedArray$.apply(this, arguments);
1744 makeArrayAccessors(this);
1745 };
1746 if ('__proto__' in TypedArray) {
1747 TypedArray.__proto__ = $TypedArray$;
1748 } else {
1749 TypedArray.from = $TypedArray$.from;
1750 TypedArray.of = $TypedArray$.of;
1751 }
1752
1753 TypedArray.BYTES_PER_ELEMENT = elementSize;
1754
1755 var TypedArrayPrototype = function() {};
1756 TypedArrayPrototype.prototype = $TypedArrayPrototype$;
1757
1758 TypedArray.prototype = new TypedArrayPrototype();
1759
1760 Object.defineProperty(TypedArray.prototype, 'BYTES_PER_ELEMENT', {value: elementSize});
1761 Object.defineProperty(TypedArray.prototype, '_pack', {value: pack});
1762 Object.defineProperty(TypedArray.prototype, '_unpack', {value: unpack});
1763
1764 return TypedArray;
1765 }
1766
1767 var Int8Array = makeTypedArray(1, packI8, unpackI8);
1768 var Uint8Array = makeTypedArray(1, packU8, unpackU8);
1769 var Uint8ClampedArray = makeTypedArray(1, packU8Clamped, unpackU8);
1770 var Int16Array = makeTypedArray(2, packI16, unpackI16);
1771 var Uint16Array = makeTypedArray(2, packU16, unpackU16);
1772 var Int32Array = makeTypedArray(4, packI32, unpackI32);
1773 var Uint32Array = makeTypedArray(4, packU32, unpackU32);
1774 var Float32Array = makeTypedArray(4, packF32, unpackF32);
1775 var Float64Array = makeTypedArray(8, packF64, unpackF64);
1776
1777 global.Int8Array = global.Int8Array || Int8Array;
1778 global.Uint8Array = global.Uint8Array || Uint8Array;
1779 global.Uint8ClampedArray = global.Uint8ClampedArray || Uint8ClampedArray;
1780 global.Int16Array = global.Int16Array || Int16Array;
1781 global.Uint16Array = global.Uint16Array || Uint16Array;
1782 global.Int32Array = global.Int32Array || Int32Array;
1783 global.Uint32Array = global.Uint32Array || Uint32Array;
1784 global.Float32Array = global.Float32Array || Float32Array;
1785 global.Float64Array = global.Float64Array || Float64Array;
1786 }());
1787
1788 //
1789 // 6 The DataView View Type
1790 //
1791
1792 (function() {
1793 function r(array, index) {
1794 return IsCallable(array.get) ? array.get(index) : array[index];
1795 }
1796
1797 var IS_BIG_ENDIAN = (function() {
1798 var u16array = new Uint16Array([0x1234]),
1799 u8array = new Uint8Array(u16array.buffer);
1800 return r(u8array, 0) === 0x12;
1801 }());
1802
1803 // DataView(buffer, byteOffset=0, byteLength=undefined)
1804 // WebIDL: Constructor(ArrayBuffer buffer,
1805 // optional unsigned long byteOffset,
1806 // optional unsigned long byteLength)
1807 function DataView(buffer, byteOffset, byteLength) {
1808 if (!(buffer instanceof ArrayBuffer || Class(buffer) === 'ArrayBuffer')) throw TypeError();
1809
1810 byteOffset = ToUint32(byteOffset);
1811 if (byteOffset > buffer.byteLength)
1812 throw RangeError('byteOffset out of range');
1813
1814 if (byteLength === undefined)
1815 byteLength = buffer.byteLength - byteOffset;
1816 else
1817 byteLength = ToUint32(byteLength);
1818
1819 if ((byteOffset + byteLength) > buffer.byteLength)
1820 throw RangeError('byteOffset and length reference an area beyond the end of the buffer');
1821
1822 Object.defineProperty(this, 'buffer', {value: buffer});
1823 Object.defineProperty(this, 'byteLength', {value: byteLength});
1824 Object.defineProperty(this, 'byteOffset', {value: byteOffset});
1825 };
1826
1827 // get DataView.prototype.buffer
1828 // get DataView.prototype.byteLength
1829 // get DataView.prototype.byteOffset
1830 // -- applied directly to instances by the constructor
1831
1832 function makeGetter(arrayType) {
1833 return function GetViewValue(byteOffset, littleEndian) {
1834 byteOffset = ToUint32(byteOffset);
1835
1836 if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength)
1837 throw RangeError('Array index out of range');
1838
1839 byteOffset += this.byteOffset;
1840
1841 var uint8Array = new Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT),
1842 bytes = [];
1843 for (var i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1)
1844 bytes.push(r(uint8Array, i));
1845
1846 if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN))
1847 bytes.reverse();
1848
1849 return r(new arrayType(new Uint8Array(bytes).buffer), 0);
1850 };
1851 }
1852
1853 Object.defineProperty(DataView.prototype, 'getUint8', {value: makeGetter(Uint8Array)});
1854 Object.defineProperty(DataView.prototype, 'getInt8', {value: makeGetter(Int8Array)});
1855 Object.defineProperty(DataView.prototype, 'getUint16', {value: makeGetter(Uint16Array)});
1856 Object.defineProperty(DataView.prototype, 'getInt16', {value: makeGetter(Int16Array)});
1857 Object.defineProperty(DataView.prototype, 'getUint32', {value: makeGetter(Uint32Array)});
1858 Object.defineProperty(DataView.prototype, 'getInt32', {value: makeGetter(Int32Array)});
1859 Object.defineProperty(DataView.prototype, 'getFloat32', {value: makeGetter(Float32Array)});
1860 Object.defineProperty(DataView.prototype, 'getFloat64', {value: makeGetter(Float64Array)});
1861
1862 function makeSetter(arrayType) {
1863 return function SetViewValue(byteOffset, value, littleEndian) {
1864 byteOffset = ToUint32(byteOffset);
1865 if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength)
1866 throw RangeError('Array index out of range');
1867
1868 // Get bytes
1869 var typeArray = new arrayType([value]),
1870 byteArray = new Uint8Array(typeArray.buffer),
1871 bytes = [], i, byteView;
1872
1873 for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1)
1874 bytes.push(r(byteArray, i));
1875
1876 // Flip if necessary
1877 if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN))
1878 bytes.reverse();
1879
1880 // Write them
1881 byteView = new Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT);
1882 byteView.set(bytes);
1883 };
1884 }
1885
1886 Object.defineProperty(DataView.prototype, 'setUint8', {value: makeSetter(Uint8Array)});
1887 Object.defineProperty(DataView.prototype, 'setInt8', {value: makeSetter(Int8Array)});
1888 Object.defineProperty(DataView.prototype, 'setUint16', {value: makeSetter(Uint16Array)});
1889 Object.defineProperty(DataView.prototype, 'setInt16', {value: makeSetter(Int16Array)});
1890 Object.defineProperty(DataView.prototype, 'setUint32', {value: makeSetter(Uint32Array)});
1891 Object.defineProperty(DataView.prototype, 'setInt32', {value: makeSetter(Int32Array)});
1892 Object.defineProperty(DataView.prototype, 'setFloat32', {value: makeSetter(Float32Array)});
1893 Object.defineProperty(DataView.prototype, 'setFloat64', {value: makeSetter(Float64Array)});
1894
1895 global.DataView = global.DataView || DataView;
1896
1897 }());
1898
1899}(self));
1900if (!("atob"in this
1901)) {
1902
1903// atob
1904;(function () {
1905
1906 var object =
1907 typeof exports != 'undefined' ? exports :
1908 typeof self != 'undefined' ? self : // #8: web workers
1909 $.global; // #31: ExtendScript
1910
1911 var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
1912
1913 function InvalidCharacterError(message) {
1914 this.message = message;
1915 }
1916 InvalidCharacterError.prototype = new Error;
1917 InvalidCharacterError.prototype.name = 'InvalidCharacterError';
1918
1919 // encoder
1920 // [https://gist.github.com/999166] by [https://github.com/nignag]
1921 object.btoa || (
1922 object.btoa = function (input) {
1923 var str = String(input);
1924 for (
1925 // initialize result and counter
1926 var block, charCode, idx = 0, map = chars, output = '';
1927 // if the next str index does not exist:
1928 // change the mapping table to "="
1929 // check if d has no fractional digits
1930 str.charAt(idx | 0) || (map = '=', idx % 1);
1931 // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
1932 output += map.charAt(63 & block >> 8 - idx % 1 * 8)
1933 ) {
1934 charCode = str.charCodeAt(idx += 3/4);
1935 if (charCode > 0xFF) {
1936 throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
1937 }
1938 block = block << 8 | charCode;
1939 }
1940 return output;
1941 });
1942
1943 // decoder
1944 // [https://gist.github.com/1020396] by [https://github.com/atk]
1945 object.atob || (
1946 object.atob = function (input) {
1947 var str = String(input).replace(/[=]+$/, ''); // #31: ExtendScript bad parse of /=
1948 if (str.length % 4 == 1) {
1949 throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
1950 }
1951 for (
1952 // initialize result and counters
1953 var bc = 0, bs, buffer, idx = 0, output = '';
1954 // get next character
1955 buffer = str.charAt(idx++);
1956 // character found in table? initialize bit storage and add its ascii value;
1957 ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
1958 // and if not first of each 4 characters,
1959 // convert the first 8 bits to one ascii character
1960 bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
1961 ) {
1962 // try to find character in table (0-63, not found => -1)
1963 buffer = chars.indexOf(buffer);
1964 }
1965 return output;
1966 });
1967
1968}());
1969
1970}
1971
1972if (!("Date"in this&&"now"in this.Date&&"getTime"in this.Date.prototype
1973)) {
1974
1975// Date.now
1976Date.now = function now() {
1977 return new Date().getTime();
1978};
1979
1980}
1981
1982if (!("Date"in this&&"toISOString"in Date.prototype
1983)) {
1984
1985// Date.prototype.toISOString
1986Date.prototype.toISOString = function toISOString() {
1987 var date = this;
1988
1989 function pad(str, len) {
1990 var pad = "0000";
1991 str = '' + str;
1992 return pad.substr(0, len - str.length) + str;
1993 }
1994
1995 var y = date.getUTCFullYear(),
1996 m = pad(date.getUTCMonth() + 1, 2),
1997 d = pad(date.getUTCDate(), 2),
1998 h = pad(date.getUTCHours(), 2),
1999 i = pad(date.getUTCMinutes(), 2),
2000 s = pad(date.getUTCSeconds(), 2),
2001 ms = pad(date.getUTCMilliseconds(), 3);
2002
2003 return y +'-'+ m +'-'+ d + 'T' + h +':'+ i +':'+ s +'.'+ ms +'Z';
2004};
2005
2006}
2007
2008if (!("document"in this
2009)) {
2010
2011// document
2012if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
2013
2014 if (this.HTMLDocument) { // IE8
2015
2016 // HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
2017 this.Document = this.HTMLDocument;
2018
2019 } else {
2020
2021 // Create an empty function to act as the missing constructor for the document object, attach the document object as its prototype. The function needs to be anonymous else it is hoisted and causes the feature detect to prematurely pass, preventing the assignments below being made.
2022 this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
2023 this.Document.prototype = document;
2024 }
2025}
2026
2027}
2028
2029if (!((function(){var e=document.createElement("p"),t=!1
2030return e.innerHTML="<section></section>",document.documentElement.appendChild(e),e.firstChild&&("getComputedStyle"in window?t="block"===getComputedStyle(e.firstChild).display:e.firstChild.currentStyle&&(t="block"===e.firstChild.currentStyle.display)),document.documentElement.removeChild(e),t})()
2031)) {
2032
2033// ~html5-elements
2034/**
2035* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
2036*/
2037!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3-pre",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document);
2038}
2039
2040if (!("DocumentFragment"in this&&this.DocumentFragment===document.createDocumentFragment().constructor
2041)) {
2042
2043// DocumentFragment
2044this.DocumentFragment = document.createDocumentFragment().constructor;
2045
2046}
2047
2048if (!("Element"in this&&"HTMLElement"in this
2049)) {
2050
2051// Element
2052(function () {
2053
2054 // IE8
2055 if (window.Element && !window.HTMLElement) {
2056 window.HTMLElement = window.Element;
2057 return;
2058 }
2059
2060 // create Element constructor
2061 window.Element = window.HTMLElement = new Function('return function Element() {}')();
2062
2063 // generate sandboxed iframe
2064 var vbody = document.appendChild(document.createElement('body'));
2065 var frame = vbody.appendChild(document.createElement('iframe'));
2066
2067 // use sandboxed iframe to replicate Element functionality
2068 var frameDocument = frame.contentWindow.document;
2069 var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
2070 var cache = {};
2071
2072 // polyfill Element.prototype on an element
2073 var shiv = function (element, deep) {
2074 var
2075 childNodes = element.childNodes || [],
2076 index = -1,
2077 key, value, childNode;
2078
2079 if (element.nodeType === 1 && element.constructor !== Element) {
2080 element.constructor = Element;
2081
2082 for (key in cache) {
2083 value = cache[key];
2084 element[key] = value;
2085 }
2086 }
2087
2088 while (childNode = deep && childNodes[++index]) {
2089 shiv(childNode, deep);
2090 }
2091
2092 return element;
2093 };
2094
2095 var elements = document.getElementsByTagName('*');
2096 var nativeCreateElement = document.createElement;
2097 var interval;
2098 var loopLimit = 100;
2099
2100 prototype.attachEvent('onpropertychange', function (event) {
2101 var
2102 propertyName = event.propertyName,
2103 nonValue = !cache.hasOwnProperty(propertyName),
2104 newValue = prototype[propertyName],
2105 oldValue = cache[propertyName],
2106 index = -1,
2107 element;
2108
2109 while (element = elements[++index]) {
2110 if (element.nodeType === 1) {
2111 if (nonValue || element[propertyName] === oldValue) {
2112 element[propertyName] = newValue;
2113 }
2114 }
2115 }
2116
2117 cache[propertyName] = newValue;
2118 });
2119
2120 prototype.constructor = Element;
2121
2122 if (!prototype.hasAttribute) {
2123 // <Element>.hasAttribute
2124 prototype.hasAttribute = function hasAttribute(name) {
2125 return this.getAttribute(name) !== null;
2126 };
2127 }
2128
2129 // Apply Element prototype to the pre-existing DOM as soon as the body element appears.
2130 function bodyCheck() {
2131 if (!(loopLimit--)) clearTimeout(interval);
2132 if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
2133 shiv(document, true);
2134 if (interval && document.body.prototype) clearTimeout(interval);
2135 return (!!document.body.prototype);
2136 }
2137 return false;
2138 }
2139 if (!bodyCheck()) {
2140 document.onreadystatechange = bodyCheck;
2141 interval = setInterval(bodyCheck, 25);
2142 }
2143
2144 // Apply to any new elements created after load
2145 document.createElement = function createElement(nodeName) {
2146 var element = nativeCreateElement(String(nodeName).toLowerCase());
2147 return shiv(element);
2148 };
2149
2150 // remove sandboxed iframe
2151 document.removeChild(vbody);
2152}());
2153
2154}
2155
2156
2157// _mutation
2158var _mutation = (function () { // eslint-disable-line no-unused-vars
2159
2160 function isNode(object) {
2161 // DOM, Level2
2162 if (typeof Node === 'function') {
2163 return object instanceof Node;
2164 }
2165 // Older browsers, check if it looks like a Node instance)
2166 return object &&
2167 typeof object === "object" &&
2168 object.nodeName &&
2169 object.nodeType >= 1 &&
2170 object.nodeType <= 12;
2171 }
2172
2173 // http://dom.spec.whatwg.org/#mutation-method-macro
2174 return function mutation(nodes) {
2175 if (nodes.length === 1) {
2176 return isNode(nodes[0]) ? nodes[0] : document.createTextNode(nodes[0] + '');
2177 }
2178
2179 var fragment = document.createDocumentFragment();
2180 for (var i = 0; i < nodes.length; i++) {
2181 fragment.appendChild(isNode(nodes[i]) ? nodes[i] : document.createTextNode(nodes[i] + ''));
2182
2183 }
2184 return fragment;
2185 };
2186}());
2187if (!("document"in this&&"querySelector"in this.document
2188)) {
2189
2190// document.querySelector
2191(function () {
2192 var
2193 head = document.getElementsByTagName('head')[0];
2194
2195 function getElementsByQuery(node, selector, one) {
2196 var
2197 generator = document.createElement('div'),
2198 id = 'qsa' + String(Math.random()).slice(3),
2199 style, elements;
2200
2201 generator.innerHTML = 'x<style>' + selector + '{qsa:' + id + ';}';
2202
2203 style = head.appendChild(generator.lastChild);
2204
2205 elements = getElements(node, selector, one, id);
2206
2207 head.removeChild(style);
2208
2209 return one ? elements[0] : elements;
2210 }
2211
2212 function getElements(node, selector, one, id) {
2213 var
2214 validNode = /1|9/.test(node.nodeType),
2215 childNodes = node.childNodes,
2216 elements = [],
2217 index = -1,
2218 childNode;
2219
2220 if (validNode && node.currentStyle && node.currentStyle.qsa === id) {
2221 if (elements.push(node) && one) {
2222 return elements;
2223 }
2224 }
2225
2226 while (childNode = childNodes[++index]) {
2227 elements = elements.concat(getElements(childNode, selector, one, id));
2228
2229 if (one && elements.length) {
2230 return elements;
2231 }
2232 }
2233
2234 return elements;
2235 }
2236
2237 Document.prototype.querySelector = Element.prototype.querySelector = function querySelectorAll(selector) {
2238 return getElementsByQuery(this, selector, true);
2239 };
2240
2241 Document.prototype.querySelectorAll = Element.prototype.querySelectorAll = function querySelectorAll(selector) {
2242 return getElementsByQuery(this, selector, false);
2243 };
2244}());
2245
2246}
2247
2248if (!("DocumentFragment"in this&&"append"in DocumentFragment.prototype
2249)) {
2250
2251// DocumentFragment.prototype.append
2252DocumentFragment.prototype.append = function append() {
2253 this.appendChild(_mutation(arguments));
2254};
2255
2256}
2257
2258if (!("DocumentFragment"in this&&"prepend"in DocumentFragment.prototype
2259)) {
2260
2261// DocumentFragment.prototype.prepend
2262DocumentFragment.prototype.prepend = function prepend() {
2263 this.insertBefore(_mutation(arguments), this.firstChild);
2264};
2265
2266}
2267
2268if (!("Element"in this&&"append"in Element.prototype
2269)) {
2270
2271// Element.prototype.append
2272Document.prototype.append = Element.prototype.append = function append() {
2273 this.appendChild(_mutation(arguments));
2274};
2275
2276}
2277
2278if (!("document"in this&&"cloneNode"in document.documentElement&&function(){var e=document.createElement("div"),n=document.createElement("input")
2279n.type="radio",n.checked=!0,e.appendChild(n)
2280var t,c=n.cloneNode(!1)
2281try{t=e.cloneNode()}catch(d){return!1}return c.checked&&void 0!==t&&0===t.childNodes.length}()
2282)) {
2283
2284// Element.prototype.cloneNode
2285Element.prototype.cloneNode = (function(nativeFunc, undef) {
2286 return function(deep) {
2287 if (deep === undef) {
2288 deep = false;
2289 }
2290 var clone = nativeFunc.call(this, deep);
2291
2292 if ('checked' in this) clone.checked = this.checked;
2293
2294 return clone;
2295 };
2296}(Element.prototype.cloneNode));
2297
2298}
2299
2300if (!("document"in this&&"matches"in document.documentElement
2301)) {
2302
2303// Element.prototype.matches
2304Element.prototype.matches = Element.prototype.webkitMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || function matches(selector) {
2305
2306 var element = this;
2307 var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
2308 var index = 0;
2309
2310 while (elements[index] && elements[index] !== element) {
2311 ++index;
2312 }
2313
2314 return !!elements[index];
2315};
2316
2317}
2318
2319if (!("document"in this&&"closest"in document.documentElement
2320)) {
2321
2322// Element.prototype.closest
2323Element.prototype.closest = function closest(selector) {
2324 var node = this;
2325
2326 while (node) {
2327 if (node.matches(selector)) return node;
2328 else node = 'SVGElement' in window && node instanceof SVGElement ? node.parentNode : node.parentElement;
2329 }
2330
2331 return null;
2332};
2333
2334}
2335
2336if (!("Element"in this&&"prepend"in Element.prototype
2337)) {
2338
2339// Element.prototype.prepend
2340Document.prototype.prepend = Element.prototype.prepend = function prepend() {
2341 this.insertBefore(_mutation(arguments), this.firstChild);
2342};
2343
2344}
2345
2346if (!("Element"in this&&"remove"in Element.prototype
2347)) {
2348
2349// Element.prototype.remove
2350Document.prototype.remove = Element.prototype.remove = function remove() {
2351 if (this.parentNode) {
2352 this.parentNode.removeChild(this);
2353 }
2354};
2355
2356// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
2357// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
2358if ("Text" in this) {
2359 Text.prototype.remove = Element.prototype.remove;
2360}
2361
2362}
2363
2364if (!("Element"in this&&"replaceWith"in Element.prototype
2365)) {
2366
2367// Element.prototype.replaceWith
2368Document.prototype.replaceWith = Element.prototype.replaceWith = function replaceWith() {
2369 if (this.parentNode) {
2370 this.parentNode.replaceChild(_mutation(arguments), this);
2371 }
2372};
2373
2374// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
2375// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
2376if ('Text' in this) {
2377 Text.prototype.replaceWith = Element.prototype.replaceWith;
2378}
2379
2380}
2381
2382if (!("JSON"in this
2383)) {
2384
2385// JSON
2386/*! JSON v3.3.2 | http://bestiejs.github.io/json3 | Copyright 2012-2014, Kit Cambridge | http://kit.mit-license.org */
2387;(function () {
2388 // Detect the `define` function exposed by asynchronous module loaders. The
2389 // strict `define` check is necessary for compatibility with `r.js`.
2390 var isLoader = typeof define === "function" && define.amd;
2391
2392 // A set of types used to distinguish objects from primitives.
2393 var objectTypes = {
2394 "function": true,
2395 "object": true
2396 };
2397
2398 // Detect the `exports` object exposed by CommonJS implementations.
2399 var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
2400
2401 // Use the `global` object exposed by Node (including Browserify via
2402 // `insert-module-globals`), Narwhal, and Ringo as the default context,
2403 // and the `window` object in browsers. Rhino exports a `global` function
2404 // instead.
2405 var root = objectTypes[typeof window] && window || this,
2406 freeGlobal = freeExports && objectTypes[typeof module] && module && !module.nodeType && typeof global == "object" && global;
2407
2408 if (freeGlobal && (freeGlobal["global"] === freeGlobal || freeGlobal["window"] === freeGlobal || freeGlobal["self"] === freeGlobal)) {
2409 root = freeGlobal;
2410 }
2411
2412 // Public: Initializes JSON 3 using the given `context` object, attaching the
2413 // `stringify` and `parse` functions to the specified `exports` object.
2414 function runInContext(context, exports) {
2415 context || (context = root["Object"]());
2416 exports || (exports = root["Object"]());
2417
2418 // Native constructor aliases.
2419 var Number = context["Number"] || root["Number"],
2420 String = context["String"] || root["String"],
2421 Object = context["Object"] || root["Object"],
2422 Date = context["Date"] || root["Date"],
2423 SyntaxError = context["SyntaxError"] || root["SyntaxError"],
2424 TypeError = context["TypeError"] || root["TypeError"],
2425 Math = context["Math"] || root["Math"],
2426 nativeJSON = context["JSON"] || root["JSON"];
2427
2428 // Delegate to the native `stringify` and `parse` implementations.
2429 if (typeof nativeJSON == "object" && nativeJSON) {
2430 exports.stringify = nativeJSON.stringify;
2431 exports.parse = nativeJSON.parse;
2432 }
2433
2434 // Convenience aliases.
2435 var objectProto = Object.prototype,
2436 getClass = objectProto.toString,
2437 isProperty, forEach, undef;
2438
2439 // Test the `Date#getUTC*` methods. Based on work by @Yaffle.
2440 var isExtended = new Date(-3509827334573292);
2441 try {
2442 // The `getUTCFullYear`, `Month`, and `Date` methods return nonsensical
2443 // results for certain dates in Opera >= 10.53.
2444 isExtended = isExtended.getUTCFullYear() == -109252 && isExtended.getUTCMonth() === 0 && isExtended.getUTCDate() === 1 &&
2445 // Safari < 2.0.2 stores the internal millisecond time value correctly,
2446 // but clips the values returned by the date methods to the range of
2447 // signed 32-bit integers ([-2 ** 31, 2 ** 31 - 1]).
2448 isExtended.getUTCHours() == 10 && isExtended.getUTCMinutes() == 37 && isExtended.getUTCSeconds() == 6 && isExtended.getUTCMilliseconds() == 708;
2449 } catch (exception) {}
2450
2451 // Internal: Determines whether the native `JSON.stringify` and `parse`
2452 // implementations are spec-compliant. Based on work by Ken Snyder.
2453 function has(name) {
2454 if (has[name] !== undef) {
2455 // Return cached feature test result.
2456 return has[name];
2457 }
2458 var isSupported;
2459 if (name == "bug-string-char-index") {
2460 // IE <= 7 doesn't support accessing string characters using square
2461 // bracket notation. IE 8 only supports this for primitives.
2462 isSupported = "a"[0] != "a";
2463 } else if (name == "json") {
2464 // Indicates whether both `JSON.stringify` and `JSON.parse` are
2465 // supported.
2466 isSupported = has("json-stringify") && has("json-parse");
2467 } else {
2468 var value, serialized = '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';
2469 // Test `JSON.stringify`.
2470 if (name == "json-stringify") {
2471 var stringify = exports.stringify, stringifySupported = typeof stringify == "function" && isExtended;
2472 if (stringifySupported) {
2473 // A test function object with a custom `toJSON` method.
2474 (value = function () {
2475 return 1;
2476 }).toJSON = value;
2477 try {
2478 stringifySupported =
2479 // Firefox 3.1b1 and b2 serialize string, number, and boolean
2480 // primitives as object literals.
2481 stringify(0) === "0" &&
2482 // FF 3.1b1, b2, and JSON 2 serialize wrapped primitives as object
2483 // literals.
2484 stringify(new Number()) === "0" &&
2485 stringify(new String()) == '""' &&
2486 // FF 3.1b1, 2 throw an error if the value is `null`, `undefined`, or
2487 // does not define a canonical JSON representation (this applies to
2488 // objects with `toJSON` properties as well, *unless* they are nested
2489 // within an object or array).
2490 stringify(getClass) === undef &&
2491 // IE 8 serializes `undefined` as `"undefined"`. Safari <= 5.1.7 and
2492 // FF 3.1b3 pass this test.
2493 stringify(undef) === undef &&
2494 // Safari <= 5.1.7 and FF 3.1b3 throw `Error`s and `TypeError`s,
2495 // respectively, if the value is omitted entirely.
2496 stringify() === undef &&
2497 // FF 3.1b1, 2 throw an error if the given value is not a number,
2498 // string, array, object, Boolean, or `null` literal. This applies to
2499 // objects with custom `toJSON` methods as well, unless they are nested
2500 // inside object or array literals. YUI 3.0.0b1 ignores custom `toJSON`
2501 // methods entirely.
2502 stringify(value) === "1" &&
2503 stringify([value]) == "[1]" &&
2504 // Prototype <= 1.6.1 serializes `[undefined]` as `"[]"` instead of
2505 // `"[null]"`.
2506 stringify([undef]) == "[null]" &&
2507 // YUI 3.0.0b1 fails to serialize `null` literals.
2508 stringify(null) == "null" &&
2509 // FF 3.1b1, 2 halts serialization if an array contains a function:
2510 // `[1, true, getClass, 1]` serializes as "[1,true,],". FF 3.1b3
2511 // elides non-JSON values from objects and arrays, unless they
2512 // define custom `toJSON` methods.
2513 stringify([undef, getClass, null]) == "[null,null,null]" &&
2514 // Simple serialization test. FF 3.1b1 uses Unicode escape sequences
2515 // where character escape codes are expected (e.g., `\b` => `\u0008`).
2516 stringify({ "a": [value, true, false, null, "\x00\b\n\f\r\t"] }) == serialized &&
2517 // FF 3.1b1 and b2 ignore the `filter` and `width` arguments.
2518 stringify(null, value) === "1" &&
2519 stringify([1, 2], null, 1) == "[\n 1,\n 2\n]" &&
2520 // JSON 2, Prototype <= 1.7, and older WebKit builds incorrectly
2521 // serialize extended years.
2522 stringify(new Date(-8.64e15)) == '"-271821-04-20T00:00:00.000Z"' &&
2523 // The milliseconds are optional in ES 5, but required in 5.1.
2524 stringify(new Date(8.64e15)) == '"+275760-09-13T00:00:00.000Z"' &&
2525 // Firefox <= 11.0 incorrectly serializes years prior to 0 as negative
2526 // four-digit years instead of six-digit years. Credits: @Yaffle.
2527 stringify(new Date(-621987552e5)) == '"-000001-01-01T00:00:00.000Z"' &&
2528 // Safari <= 5.1.5 and Opera >= 10.53 incorrectly serialize millisecond
2529 // values less than 1000. Credits: @Yaffle.
2530 stringify(new Date(-1)) == '"1969-12-31T23:59:59.999Z"';
2531 } catch (exception) {
2532 stringifySupported = false;
2533 }
2534 }
2535 isSupported = stringifySupported;
2536 }
2537 // Test `JSON.parse`.
2538 if (name == "json-parse") {
2539 var parse = exports.parse;
2540 if (typeof parse == "function") {
2541 try {
2542 // FF 3.1b1, b2 will throw an exception if a bare literal is provided.
2543 // Conforming implementations should also coerce the initial argument to
2544 // a string prior to parsing.
2545 if (parse("0") === 0 && !parse(false)) {
2546 // Simple parsing test.
2547 value = parse(serialized);
2548 var parseSupported = value["a"].length == 5 && value["a"][0] === 1;
2549 if (parseSupported) {
2550 try {
2551 // Safari <= 5.1.2 and FF 3.1b1 allow unescaped tabs in strings.
2552 parseSupported = !parse('"\t"');
2553 } catch (exception) {}
2554 if (parseSupported) {
2555 try {
2556 // FF 4.0 and 4.0.1 allow leading `+` signs and leading
2557 // decimal points. FF 4.0, 4.0.1, and IE 9-10 also allow
2558 // certain octal literals.
2559 parseSupported = parse("01") !== 1;
2560 } catch (exception) {}
2561 }
2562 if (parseSupported) {
2563 try {
2564 // FF 4.0, 4.0.1, and Rhino 1.7R3-R4 allow trailing decimal
2565 // points. These environments, along with FF 3.1b1 and 2,
2566 // also allow trailing commas in JSON objects and arrays.
2567 parseSupported = parse("1.") !== 1;
2568 } catch (exception) {}
2569 }
2570 }
2571 }
2572 } catch (exception) {
2573 parseSupported = false;
2574 }
2575 }
2576 isSupported = parseSupported;
2577 }
2578 }
2579 return has[name] = !!isSupported;
2580 }
2581
2582 if (!has("json")) {
2583 // Common `[[Class]]` name aliases.
2584 var functionClass = "[object Function]",
2585 dateClass = "[object Date]",
2586 numberClass = "[object Number]",
2587 stringClass = "[object String]",
2588 arrayClass = "[object Array]",
2589 booleanClass = "[object Boolean]";
2590
2591 // Detect incomplete support for accessing string characters by index.
2592 var charIndexBuggy = has("bug-string-char-index");
2593
2594 // Define additional utility methods if the `Date` methods are buggy.
2595 if (!isExtended) {
2596 var floor = Math.floor;
2597 // A mapping between the months of the year and the number of days between
2598 // January 1st and the first of the respective month.
2599 var Months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
2600 // Internal: Calculates the number of days between the Unix epoch and the
2601 // first day of the given month.
2602 var getDay = function (year, month) {
2603 return Months[month] + 365 * (year - 1970) + floor((year - 1969 + (month = +(month > 1))) / 4) - floor((year - 1901 + month) / 100) + floor((year - 1601 + month) / 400);
2604 };
2605 }
2606
2607 // Internal: Determines if a property is a direct property of the given
2608 // object. Delegates to the native `Object#hasOwnProperty` method.
2609 if (!(isProperty = objectProto.hasOwnProperty)) {
2610 isProperty = function (property) {
2611 var members = {}, constructor;
2612 if ((members.__proto__ = null, members.__proto__ = {
2613 // The *proto* property cannot be set multiple times in recent
2614 // versions of Firefox and SeaMonkey.
2615 "toString": 1
2616 }, members).toString != getClass) {
2617 // Safari <= 2.0.3 doesn't implement `Object#hasOwnProperty`, but
2618 // supports the mutable *proto* property.
2619 isProperty = function (property) {
2620 // Capture and break the object's prototype chain (see section 8.6.2
2621 // of the ES 5.1 spec). The parenthesized expression prevents an
2622 // unsafe transformation by the Closure Compiler.
2623 var original = this.__proto__, result = property in (this.__proto__ = null, this);
2624 // Restore the original prototype chain.
2625 this.__proto__ = original;
2626 return result;
2627 };
2628 } else {
2629 // Capture a reference to the top-level `Object` constructor.
2630 constructor = members.constructor;
2631 // Use the `constructor` property to simulate `Object#hasOwnProperty` in
2632 // other environments.
2633 isProperty = function (property) {
2634 var parent = (this.constructor || constructor).prototype;
2635 return property in this && !(property in parent && this[property] === parent[property]);
2636 };
2637 }
2638 members = null;
2639 return isProperty.call(this, property);
2640 };
2641 }
2642
2643 // Internal: Normalizes the `for...in` iteration algorithm across
2644 // environments. Each enumerated key is yielded to a `callback` function.
2645 forEach = function (object, callback) {
2646 var size = 0, Properties, members, property;
2647
2648 // Tests for bugs in the current environment's `for...in` algorithm. The
2649 // `valueOf` property inherits the non-enumerable flag from
2650 // `Object.prototype` in older versions of IE, Netscape, and Mozilla.
2651 (Properties = function () {
2652 this.valueOf = 0;
2653 }).prototype.valueOf = 0;
2654
2655 // Iterate over a new instance of the `Properties` class.
2656 members = new Properties();
2657 for (property in members) {
2658 // Ignore all properties inherited from `Object.prototype`.
2659 if (isProperty.call(members, property)) {
2660 size++;
2661 }
2662 }
2663 Properties = members = null;
2664
2665 // Normalize the iteration algorithm.
2666 if (!size) {
2667 // A list of non-enumerable properties inherited from `Object.prototype`.
2668 members = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"];
2669 // IE <= 8, Mozilla 1.0, and Netscape 6.2 ignore shadowed non-enumerable
2670 // properties.
2671 forEach = function (object, callback) {
2672 var isFunction = getClass.call(object) == functionClass, property, length;
2673 var hasProperty = !isFunction && typeof object.constructor != "function" && objectTypes[typeof object.hasOwnProperty] && object.hasOwnProperty || isProperty;
2674 for (property in object) {
2675 // Gecko <= 1.0 enumerates the `prototype` property of functions under
2676 // certain conditions; IE does not.
2677 if (!(isFunction && property == "prototype") && hasProperty.call(object, property)) {
2678 callback(property);
2679 }
2680 }
2681 // Manually invoke the callback for each non-enumerable property.
2682 for (length = members.length; property = members[--length]; hasProperty.call(object, property) && callback(property));
2683 };
2684 } else if (size == 2) {
2685 // Safari <= 2.0.4 enumerates shadowed properties twice.
2686 forEach = function (object, callback) {
2687 // Create a set of iterated properties.
2688 var members = {}, isFunction = getClass.call(object) == functionClass, property;
2689 for (property in object) {
2690 // Store each property name to prevent double enumeration. The
2691 // `prototype` property of functions is not enumerated due to cross-
2692 // environment inconsistencies.
2693 if (!(isFunction && property == "prototype") && !isProperty.call(members, property) && (members[property] = 1) && isProperty.call(object, property)) {
2694 callback(property);
2695 }
2696 }
2697 };
2698 } else {
2699 // No bugs detected; use the standard `for...in` algorithm.
2700 forEach = function (object, callback) {
2701 var isFunction = getClass.call(object) == functionClass, property, isConstructor;
2702 for (property in object) {
2703 if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) {
2704 callback(property);
2705 }
2706 }
2707 // Manually invoke the callback for the `constructor` property due to
2708 // cross-environment inconsistencies.
2709 if (isConstructor || isProperty.call(object, (property = "constructor"))) {
2710 callback(property);
2711 }
2712 };
2713 }
2714 return forEach(object, callback);
2715 };
2716
2717 // Public: Serializes a JavaScript `value` as a JSON string. The optional
2718 // `filter` argument may specify either a function that alters how object and
2719 // array members are serialized, or an array of strings and numbers that
2720 // indicates which properties should be serialized. The optional `width`
2721 // argument may be either a string or number that specifies the indentation
2722 // level of the output.
2723 if (!has("json-stringify")) {
2724 // Internal: A map of control characters and their escaped equivalents.
2725 var Escapes = {
2726 92: "\\\\",
2727 34: '\\"',
2728 8: "\\b",
2729 12: "\\f",
2730 10: "\\n",
2731 13: "\\r",
2732 9: "\\t"
2733 };
2734
2735 // Internal: Converts `value` into a zero-padded string such that its
2736 // length is at least equal to `width`. The `width` must be <= 6.
2737 var leadingZeroes = "000000";
2738 var toPaddedString = function (width, value) {
2739 // The `|| 0` expression is necessary to work around a bug in
2740 // Opera <= 7.54u2 where `0 == -0`, but `String(-0) !== "0"`.
2741 return (leadingZeroes + (value || 0)).slice(-width);
2742 };
2743
2744 // Internal: Double-quotes a string `value`, replacing all ASCII control
2745 // characters (characters with code unit values between 0 and 31) with
2746 // their escaped equivalents. This is an implementation of the
2747 // `Quote(value)` operation defined in ES 5.1 section 15.12.3.
2748 var unicodePrefix = "\\u00";
2749 var quote = function (value) {
2750 var result = '"', index = 0, length = value.length, useCharIndex = !charIndexBuggy || length > 10;
2751 var symbols = useCharIndex && (charIndexBuggy ? value.split("") : value);
2752 for (; index < length; index++) {
2753 var charCode = value.charCodeAt(index);
2754 // If the character is a control character, append its Unicode or
2755 // shorthand escape sequence; otherwise, append the character as-is.
2756 switch (charCode) {
2757 case 8: case 9: case 10: case 12: case 13: case 34: case 92:
2758 result += Escapes[charCode];
2759 break;
2760 default:
2761 if (charCode < 32) {
2762 result += unicodePrefix + toPaddedString(2, charCode.toString(16));
2763 break;
2764 }
2765 result += useCharIndex ? symbols[index] : value.charAt(index);
2766 }
2767 }
2768 return result + '"';
2769 };
2770
2771 // Internal: Recursively serializes an object. Implements the
2772 // `Str(key, holder)`, `JO(value)`, and `JA(value)` operations.
2773 var serialize = function (property, object, callback, properties, whitespace, indentation, stack) {
2774 var value, className, year, month, date, time, hours, minutes, seconds, milliseconds, results, element, index, length, prefix, result;
2775 try {
2776 // Necessary for host object support.
2777 value = object[property];
2778 } catch (exception) {}
2779 if (typeof value == "object" && value) {
2780 className = getClass.call(value);
2781 if (className == dateClass && !isProperty.call(value, "toJSON")) {
2782 if (value > -1 / 0 && value < 1 / 0) {
2783 // Dates are serialized according to the `Date#toJSON` method
2784 // specified in ES 5.1 section 15.9.5.44. See section 15.9.1.15
2785 // for the ISO 8601 date time string format.
2786 if (getDay) {
2787 // Manually compute the year, month, date, hours, minutes,
2788 // seconds, and milliseconds if the `getUTC*` methods are
2789 // buggy. Adapted from @Yaffle's `date-shim` project.
2790 date = floor(value / 864e5);
2791 for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++);
2792 for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++);
2793 date = 1 + date - getDay(year, month);
2794 // The `time` value specifies the time within the day (see ES
2795 // 5.1 section 15.9.1.2). The formula `(A % B + B) % B` is used
2796 // to compute `A modulo B`, as the `%` operator does not
2797 // correspond to the `modulo` operation for negative numbers.
2798 time = (value % 864e5 + 864e5) % 864e5;
2799 // The hours, minutes, seconds, and milliseconds are obtained by
2800 // decomposing the time within the day. See section 15.9.1.10.
2801 hours = floor(time / 36e5) % 24;
2802 minutes = floor(time / 6e4) % 60;
2803 seconds = floor(time / 1e3) % 60;
2804 milliseconds = time % 1e3;
2805 } else {
2806 year = value.getUTCFullYear();
2807 month = value.getUTCMonth();
2808 date = value.getUTCDate();
2809 hours = value.getUTCHours();
2810 minutes = value.getUTCMinutes();
2811 seconds = value.getUTCSeconds();
2812 milliseconds = value.getUTCMilliseconds();
2813 }
2814 // Serialize extended years correctly.
2815 value = (year <= 0 || year >= 1e4 ? (year < 0 ? "-" : "+") + toPaddedString(6, year < 0 ? -year : year) : toPaddedString(4, year)) +
2816 "-" + toPaddedString(2, month + 1) + "-" + toPaddedString(2, date) +
2817 // Months, dates, hours, minutes, and seconds should have two
2818 // digits; milliseconds should have three.
2819 "T" + toPaddedString(2, hours) + ":" + toPaddedString(2, minutes) + ":" + toPaddedString(2, seconds) +
2820 // Milliseconds are optional in ES 5.0, but required in 5.1.
2821 "." + toPaddedString(3, milliseconds) + "Z";
2822 } else {
2823 value = null;
2824 }
2825 } else if (typeof value.toJSON == "function" && ((className != numberClass && className != stringClass && className != arrayClass) || isProperty.call(value, "toJSON"))) {
2826 // Prototype <= 1.6.1 adds non-standard `toJSON` methods to the
2827 // `Number`, `String`, `Date`, and `Array` prototypes. JSON 3
2828 // ignores all `toJSON` methods on these objects unless they are
2829 // defined directly on an instance.
2830 value = value.toJSON(property);
2831 }
2832 }
2833 if (callback) {
2834 // If a replacement function was provided, call it to obtain the value
2835 // for serialization.
2836 value = callback.call(object, property, value);
2837 }
2838 if (value === null) {
2839 return "null";
2840 }
2841 className = getClass.call(value);
2842 if (className == booleanClass) {
2843 // Booleans are represented literally.
2844 return "" + value;
2845 } else if (className == numberClass) {
2846 // JSON numbers must be finite. `Infinity` and `NaN` are serialized as
2847 // `"null"`.
2848 return value > -1 / 0 && value < 1 / 0 ? "" + value : "null";
2849 } else if (className == stringClass) {
2850 // Strings are double-quoted and escaped.
2851 return quote("" + value);
2852 }
2853 // Recursively serialize objects and arrays.
2854 if (typeof value == "object") {
2855 // Check for cyclic structures. This is a linear search; performance
2856 // is inversely proportional to the number of unique nested objects.
2857 for (length = stack.length; length--;) {
2858 if (stack[length] === value) {
2859 // Cyclic structures cannot be serialized by `JSON.stringify`.
2860 throw TypeError();
2861 }
2862 }
2863 // Add the object to the stack of traversed objects.
2864 stack.push(value);
2865 results = [];
2866 // Save the current indentation level and indent one additional level.
2867 prefix = indentation;
2868 indentation += whitespace;
2869 if (className == arrayClass) {
2870 // Recursively serialize array elements.
2871 for (index = 0, length = value.length; index < length; index++) {
2872 element = serialize(index, value, callback, properties, whitespace, indentation, stack);
2873 results.push(element === undef ? "null" : element);
2874 }
2875 result = results.length ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]";
2876 } else {
2877 // Recursively serialize object members. Members are selected from
2878 // either a user-specified list of property names, or the object
2879 // itself.
2880 forEach(properties || value, function (property) {
2881 var element = serialize(property, value, callback, properties, whitespace, indentation, stack);
2882 if (element !== undef) {
2883 // According to ES 5.1 section 15.12.3: "If `gap` {whitespace}
2884 // is not the empty string, let `member` {quote(property) + ":"}
2885 // be the concatenation of `member` and the `space` character."
2886 // The "`space` character" refers to the literal space
2887 // character, not the `space` {width} argument provided to
2888 // `JSON.stringify`.
2889 results.push(quote(property) + ":" + (whitespace ? " " : "") + element);
2890 }
2891 });
2892 result = results.length ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}";
2893 }
2894 // Remove the object from the traversed object stack.
2895 stack.pop();
2896 return result;
2897 }
2898 };
2899
2900 // Public: `JSON.stringify`. See ES 5.1 section 15.12.3.
2901 exports.stringify = function (source, filter, width) {
2902 var whitespace, callback, properties, className;
2903 if (objectTypes[typeof filter] && filter) {
2904 if ((className = getClass.call(filter)) == functionClass) {
2905 callback = filter;
2906 } else if (className == arrayClass) {
2907 // Convert the property names array into a makeshift set.
2908 properties = {};
2909 for (var index = 0, length = filter.length, value; index < length; value = filter[index++], ((className = getClass.call(value)), className == stringClass || className == numberClass) && (properties[value] = 1));
2910 }
2911 }
2912 if (width) {
2913 if ((className = getClass.call(width)) == numberClass) {
2914 // Convert the `width` to an integer and create a string containing
2915 // `width` number of space characters.
2916 if ((width -= width % 1) > 0) {
2917 for (whitespace = "", width > 10 && (width = 10); whitespace.length < width; whitespace += " ");
2918 }
2919 } else if (className == stringClass) {
2920 whitespace = width.length <= 10 ? width : width.slice(0, 10);
2921 }
2922 }
2923 // Opera <= 7.54u2 discards the values associated with empty string keys
2924 // (`""`) only if they are used directly within an object member list
2925 // (e.g., `!("" in { "": 1})`).
2926 return serialize("", (value = {}, value[""] = source, value), callback, properties, whitespace, "", []);
2927 };
2928 }
2929
2930 // Public: Parses a JSON source string.
2931 if (!has("json-parse")) {
2932 var fromCharCode = String.fromCharCode;
2933
2934 // Internal: A map of escaped control characters and their unescaped
2935 // equivalents.
2936 var Unescapes = {
2937 92: "\\",
2938 34: '"',
2939 47: "/",
2940 98: "\b",
2941 116: "\t",
2942 110: "\n",
2943 102: "\f",
2944 114: "\r"
2945 };
2946
2947 // Internal: Stores the parser state.
2948 var Index, Source;
2949
2950 // Internal: Resets the parser state and throws a `SyntaxError`.
2951 var abort = function () {
2952 Index = Source = null;
2953 throw SyntaxError();
2954 };
2955
2956 // Internal: Returns the next token, or `"$"` if the parser has reached
2957 // the end of the source string. A token may be a string, number, `null`
2958 // literal, or Boolean literal.
2959 var lex = function () {
2960 var source = Source, length = source.length, value, begin, position, isSigned, charCode;
2961 while (Index < length) {
2962 charCode = source.charCodeAt(Index);
2963 switch (charCode) {
2964 case 9: case 10: case 13: case 32:
2965 // Skip whitespace tokens, including tabs, carriage returns, line
2966 // feeds, and space characters.
2967 Index++;
2968 break;
2969 case 123: case 125: case 91: case 93: case 58: case 44:
2970 // Parse a punctuator token (`{`, `}`, `[`, `]`, `:`, or `,`) at
2971 // the current position.
2972 value = charIndexBuggy ? source.charAt(Index) : source[Index];
2973 Index++;
2974 return value;
2975 case 34:
2976 // `"` delimits a JSON string; advance to the next character and
2977 // begin parsing the string. String tokens are prefixed with the
2978 // sentinel `@` character to distinguish them from punctuators and
2979 // end-of-string tokens.
2980 for (value = "@", Index++; Index < length;) {
2981 charCode = source.charCodeAt(Index);
2982 if (charCode < 32) {
2983 // Unescaped ASCII control characters (those with a code unit
2984 // less than the space character) are not permitted.
2985 abort();
2986 } else if (charCode == 92) {
2987 // A reverse solidus (`\`) marks the beginning of an escaped
2988 // control character (including `"`, `\`, and `/`) or Unicode
2989 // escape sequence.
2990 charCode = source.charCodeAt(++Index);
2991 switch (charCode) {
2992 case 92: case 34: case 47: case 98: case 116: case 110: case 102: case 114:
2993 // Revive escaped control characters.
2994 value += Unescapes[charCode];
2995 Index++;
2996 break;
2997 case 117:
2998 // `\u` marks the beginning of a Unicode escape sequence.
2999 // Advance to the first character and validate the
3000 // four-digit code point.
3001 begin = ++Index;
3002 for (position = Index + 4; Index < position; Index++) {
3003 charCode = source.charCodeAt(Index);
3004 // A valid sequence comprises four hexdigits (case-
3005 // insensitive) that form a single hexadecimal value.
3006 if (!(charCode >= 48 && charCode <= 57 || charCode >= 97 && charCode <= 102 || charCode >= 65 && charCode <= 70)) {
3007 // Invalid Unicode escape sequence.
3008 abort();
3009 }
3010 }
3011 // Revive the escaped character.
3012 value += fromCharCode("0x" + source.slice(begin, Index));
3013 break;
3014 default:
3015 // Invalid escape sequence.
3016 abort();
3017 }
3018 } else {
3019 if (charCode == 34) {
3020 // An unescaped double-quote character marks the end of the
3021 // string.
3022 break;
3023 }
3024 charCode = source.charCodeAt(Index);
3025 begin = Index;
3026 // Optimize for the common case where a string is valid.
3027 while (charCode >= 32 && charCode != 92 && charCode != 34) {
3028 charCode = source.charCodeAt(++Index);
3029 }
3030 // Append the string as-is.
3031 value += source.slice(begin, Index);
3032 }
3033 }
3034 if (source.charCodeAt(Index) == 34) {
3035 // Advance to the next character and return the revived string.
3036 Index++;
3037 return value;
3038 }
3039 // Unterminated string.
3040 abort();
3041 default:
3042 // Parse numbers and literals.
3043 begin = Index;
3044 // Advance past the negative sign, if one is specified.
3045 if (charCode == 45) {
3046 isSigned = true;
3047 charCode = source.charCodeAt(++Index);
3048 }
3049 // Parse an integer or floating-point value.
3050 if (charCode >= 48 && charCode <= 57) {
3051 // Leading zeroes are interpreted as octal literals.
3052 if (charCode == 48 && ((charCode = source.charCodeAt(Index + 1)), charCode >= 48 && charCode <= 57)) {
3053 // Illegal octal literal.
3054 abort();
3055 }
3056 isSigned = false;
3057 // Parse the integer component.
3058 for (; Index < length && ((charCode = source.charCodeAt(Index)), charCode >= 48 && charCode <= 57); Index++);
3059 // Floats cannot contain a leading decimal point; however, this
3060 // case is already accounted for by the parser.
3061 if (source.charCodeAt(Index) == 46) {
3062 position = ++Index;
3063 // Parse the decimal component.
3064 for (; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++);
3065 if (position == Index) {
3066 // Illegal trailing decimal.
3067 abort();
3068 }
3069 Index = position;
3070 }
3071 // Parse exponents. The `e` denoting the exponent is
3072 // case-insensitive.
3073 charCode = source.charCodeAt(Index);
3074 if (charCode == 101 || charCode == 69) {
3075 charCode = source.charCodeAt(++Index);
3076 // Skip past the sign following the exponent, if one is
3077 // specified.
3078 if (charCode == 43 || charCode == 45) {
3079 Index++;
3080 }
3081 // Parse the exponential component.
3082 for (position = Index; position < length && ((charCode = source.charCodeAt(position)), charCode >= 48 && charCode <= 57); position++);
3083 if (position == Index) {
3084 // Illegal empty exponent.
3085 abort();
3086 }
3087 Index = position;
3088 }
3089 // Coerce the parsed value to a JavaScript number.
3090 return +source.slice(begin, Index);
3091 }
3092 // A negative sign may only precede numbers.
3093 if (isSigned) {
3094 abort();
3095 }
3096 // `true`, `false`, and `null` literals.
3097 if (source.slice(Index, Index + 4) == "true") {
3098 Index += 4;
3099 return true;
3100 } else if (source.slice(Index, Index + 5) == "false") {
3101 Index += 5;
3102 return false;
3103 } else if (source.slice(Index, Index + 4) == "null") {
3104 Index += 4;
3105 return null;
3106 }
3107 // Unrecognized token.
3108 abort();
3109 }
3110 }
3111 // Return the sentinel `$` character if the parser has reached the end
3112 // of the source string.
3113 return "$";
3114 };
3115
3116 // Internal: Parses a JSON `value` token.
3117 var get = function (value) {
3118 var results, hasMembers;
3119 if (value == "$") {
3120 // Unexpected end of input.
3121 abort();
3122 }
3123 if (typeof value == "string") {
3124 if ((charIndexBuggy ? value.charAt(0) : value[0]) == "@") {
3125 // Remove the sentinel `@` character.
3126 return value.slice(1);
3127 }
3128 // Parse object and array literals.
3129 if (value == "[") {
3130 // Parses a JSON array, returning a new JavaScript array.
3131 results = [];
3132 for (;; hasMembers || (hasMembers = true)) {
3133 value = lex();
3134 // A closing square bracket marks the end of the array literal.
3135 if (value == "]") {
3136 break;
3137 }
3138 // If the array literal contains elements, the current token
3139 // should be a comma separating the previous element from the
3140 // next.
3141 if (hasMembers) {
3142 if (value == ",") {
3143 value = lex();
3144 if (value == "]") {
3145 // Unexpected trailing `,` in array literal.
3146 abort();
3147 }
3148 } else {
3149 // A `,` must separate each array element.
3150 abort();
3151 }
3152 }
3153 // Elisions and leading commas are not permitted.
3154 if (value == ",") {
3155 abort();
3156 }
3157 results.push(get(value));
3158 }
3159 return results;
3160 } else if (value == "{") {
3161 // Parses a JSON object, returning a new JavaScript object.
3162 results = {};
3163 for (;; hasMembers || (hasMembers = true)) {
3164 value = lex();
3165 // A closing curly brace marks the end of the object literal.
3166 if (value == "}") {
3167 break;
3168 }
3169 // If the object literal contains members, the current token
3170 // should be a comma separator.
3171 if (hasMembers) {
3172 if (value == ",") {
3173 value = lex();
3174 if (value == "}") {
3175 // Unexpected trailing `,` in object literal.
3176 abort();
3177 }
3178 } else {
3179 // A `,` must separate each object member.
3180 abort();
3181 }
3182 }
3183 // Leading commas are not permitted, object property names must be
3184 // double-quoted strings, and a `:` must separate each property
3185 // name and value.
3186 if (value == "," || typeof value != "string" || (charIndexBuggy ? value.charAt(0) : value[0]) != "@" || lex() != ":") {
3187 abort();
3188 }
3189 results[value.slice(1)] = get(lex());
3190 }
3191 return results;
3192 }
3193 // Unexpected token encountered.
3194 abort();
3195 }
3196 return value;
3197 };
3198
3199 // Internal: Updates a traversed object member.
3200 var update = function (source, property, callback) {
3201 var element = walk(source, property, callback);
3202 if (element === undef) {
3203 delete source[property];
3204 } else {
3205 source[property] = element;
3206 }
3207 };
3208
3209 // Internal: Recursively traverses a parsed JSON object, invoking the
3210 // `callback` function for each value. This is an implementation of the
3211 // `Walk(holder, name)` operation defined in ES 5.1 section 15.12.2.
3212 var walk = function (source, property, callback) {
3213 var value = source[property], length;
3214 if (typeof value == "object" && value) {
3215 // `forEach` can't be used to traverse an array in Opera <= 8.54
3216 // because its `Object#hasOwnProperty` implementation returns `false`
3217 // for array indices (e.g., `![1, 2, 3].hasOwnProperty("0")`).
3218 if (getClass.call(value) == arrayClass) {
3219 for (length = value.length; length--;) {
3220 update(value, length, callback);
3221 }
3222 } else {
3223 forEach(value, function (property) {
3224 update(value, property, callback);
3225 });
3226 }
3227 }
3228 return callback.call(source, property, value);
3229 };
3230
3231 // Public: `JSON.parse`. See ES 5.1 section 15.12.2.
3232 exports.parse = function (source, callback) {
3233 var result, value;
3234 Index = 0;
3235 Source = "" + source;
3236 result = get(lex());
3237 // If a JSON string contains multiple tokens, it is invalid.
3238 if (lex() != "$") {
3239 abort();
3240 }
3241 // Reset the parser state.
3242 Index = Source = null;
3243 return callback && getClass.call(callback) == functionClass ? walk((value = {}, value[""] = result, value), "", callback) : result;
3244 };
3245 }
3246 }
3247
3248 exports["runInContext"] = runInContext;
3249 return exports;
3250 }
3251
3252 if (freeExports && !isLoader) {
3253 // Export for CommonJS environments.
3254 runInContext(root, freeExports);
3255 } else {
3256 // Export for web browsers and JavaScript engines.
3257 var nativeJSON = root.JSON,
3258 previousJSON = root["JSON3"],
3259 isRestored = false;
3260
3261 var JSON3 = runInContext(root, (root["JSON3"] = {
3262 // Public: Restores the original value of the global `JSON` object and
3263 // returns a reference to the `JSON3` object.
3264 "noConflict": function () {
3265 if (!isRestored) {
3266 isRestored = true;
3267 root.JSON = nativeJSON;
3268 root["JSON3"] = previousJSON;
3269 nativeJSON = previousJSON = null;
3270 }
3271 return JSON3;
3272 }
3273 }));
3274
3275 root.JSON = {
3276 "parse": JSON3.parse,
3277 "stringify": JSON3.stringify
3278 };
3279 }
3280
3281 // Export for asynchronous module loaders.
3282 if (isLoader) {
3283 define(function () {
3284 return JSON3;
3285 });
3286 }
3287}).call(this);
3288
3289}
3290
3291if (!(document.contains
3292)) {
3293
3294// Node.prototype.contains
3295(function() {
3296
3297 function contains(node) {
3298 if (!(0 in arguments)) {
3299 throw new TypeError('1 argument is required');
3300 }
3301
3302 do {
3303 if (this === node) {
3304 return true;
3305 }
3306 } while (node = node && node.parentNode);
3307
3308 return false;
3309 }
3310
3311 // IE
3312 if ('HTMLElement' in this && 'contains' in HTMLElement.prototype) {
3313 try {
3314 delete HTMLElement.prototype.contains;
3315 } catch (e) {}
3316 }
3317
3318 if ('Node' in this) {
3319 Node.prototype.contains = contains;
3320 } else {
3321 document.contains = Element.prototype.contains = contains;
3322 }
3323
3324}());
3325
3326}
3327
3328if (!("defineProperty"in Object&&function(){try{var e={}
3329return Object.defineProperty(e,"test",{value:42}),!0}catch(t){return!1}}()
3330)) {
3331
3332// Object.defineProperty
3333(function (nativeDefineProperty) {
3334
3335 var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
3336 var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
3337 var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
3338
3339 // Polyfill.io - This does not use CreateMethodProperty because our CreateMethodProperty function uses Object.defineProperty.
3340 Object['defineProperty'] = function defineProperty(object, property, descriptor) {
3341
3342 // Where native support exists, assume it
3343 if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
3344 return nativeDefineProperty(object, property, descriptor);
3345 }
3346
3347 if (object === null || !(object instanceof Object || typeof object === 'object')) {
3348 throw new TypeError('Object.defineProperty called on non-object');
3349 }
3350
3351 if (!(descriptor instanceof Object)) {
3352 throw new TypeError('Property description must be an object');
3353 }
3354
3355 var propertyString = String(property);
3356 var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
3357 var getterType = 'get' in descriptor && typeof descriptor.get;
3358 var setterType = 'set' in descriptor && typeof descriptor.set;
3359
3360 // handle descriptor.get
3361 if (getterType) {
3362 if (getterType !== 'function') {
3363 throw new TypeError('Getter must be a function');
3364 }
3365 if (!supportsAccessors) {
3366 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
3367 }
3368 if (hasValueOrWritable) {
3369 throw new TypeError(ERR_VALUE_ACCESSORS);
3370 }
3371 Object.__defineGetter__.call(object, propertyString, descriptor.get);
3372 } else {
3373 object[propertyString] = descriptor.value;
3374 }
3375
3376 // handle descriptor.set
3377 if (setterType) {
3378 if (setterType !== 'function') {
3379 throw new TypeError('Setter must be a function');
3380 }
3381 if (!supportsAccessors) {
3382 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
3383 }
3384 if (hasValueOrWritable) {
3385 throw new TypeError(ERR_VALUE_ACCESSORS);
3386 }
3387 Object.__defineSetter__.call(object, propertyString, descriptor.set);
3388 }
3389
3390 // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
3391 if ('value' in descriptor) {
3392 object[propertyString] = descriptor.value;
3393 }
3394
3395 return object;
3396 };
3397}(Object.defineProperty));
3398
3399}
3400
3401
3402// _DOMTokenList
3403/*
3404Copyright (c) 2016, John Gardner
3405
3406Permission 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.
3407
3408THE 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.
3409*/
3410var _DOMTokenList = (function() { // eslint-disable-line no-unused-vars
3411 var dpSupport = true;
3412 var defineGetter = function (object, name, fn, configurable) {
3413 if (Object.defineProperty)
3414 Object.defineProperty(object, name, {
3415 configurable: false === dpSupport ? true : !!configurable,
3416 get: fn
3417 });
3418
3419 else object.__defineGetter__(name, fn);
3420 };
3421
3422 /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
3423 try {
3424 defineGetter({}, "support");
3425 }
3426 catch (e) {
3427 dpSupport = false;
3428 }
3429
3430
3431 var _DOMTokenList = function (el, prop) {
3432 var that = this;
3433 var tokens = [];
3434 var tokenMap = {};
3435 var length = 0;
3436 var maxLength = 0;
3437 var addIndexGetter = function (i) {
3438 defineGetter(that, i, function () {
3439 preop();
3440 return tokens[i];
3441 }, false);
3442
3443 };
3444 var reindex = function () {
3445
3446 /** Define getter functions for array-like access to the tokenList's contents. */
3447 if (length >= maxLength)
3448 for (; maxLength < length; ++maxLength) {
3449 addIndexGetter(maxLength);
3450 }
3451 };
3452
3453 /** Helper function called at the start of each class method. Internal use only. */
3454 var preop = function () {
3455 var error;
3456 var i;
3457 var args = arguments;
3458 var rSpace = /\s+/;
3459
3460 /** Validate the token/s passed to an instance method, if any. */
3461 if (args.length)
3462 for (i = 0; i < args.length; ++i)
3463 if (rSpace.test(args[i])) {
3464 error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
3465 error.code = 5;
3466 error.name = "InvalidCharacterError";
3467 throw error;
3468 }
3469
3470
3471 /** Split the new value apart by whitespace*/
3472 if (typeof el[prop] === "object") {
3473 tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
3474 } else {
3475 tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
3476 }
3477
3478 /** Avoid treating blank strings as single-item token lists */
3479 if ("" === tokens[0]) tokens = [];
3480
3481 /** Repopulate the internal token lists */
3482 tokenMap = {};
3483 for (i = 0; i < tokens.length; ++i)
3484 tokenMap[tokens[i]] = true;
3485 length = tokens.length;
3486 reindex();
3487 };
3488
3489 /** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
3490 preop();
3491
3492 /** Return the number of tokens in the underlying string. Read-only. */
3493 defineGetter(that, "length", function () {
3494 preop();
3495 return length;
3496 });
3497
3498 /** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
3499 that.toLocaleString =
3500 that.toString = function () {
3501 preop();
3502 return tokens.join(" ");
3503 };
3504
3505 that.item = function (idx) {
3506 preop();
3507 return tokens[idx];
3508 };
3509
3510 that.contains = function (token) {
3511 preop();
3512 return !!tokenMap[token];
3513 };
3514
3515 that.add = function () {
3516 preop.apply(that, args = arguments);
3517
3518 for (var args, token, i = 0, l = args.length; i < l; ++i) {
3519 token = args[i];
3520 if (!tokenMap[token]) {
3521 tokens.push(token);
3522 tokenMap[token] = true;
3523 }
3524 }
3525
3526 /** Update the targeted attribute of the attached element if the token list's changed. */
3527 if (length !== tokens.length) {
3528 length = tokens.length >>> 0;
3529 if (typeof el[prop] === "object") {
3530 el[prop].baseVal = tokens.join(" ");
3531 } else {
3532 el[prop] = tokens.join(" ");
3533 }
3534 reindex();
3535 }
3536 };
3537
3538 that.remove = function () {
3539 preop.apply(that, args = arguments);
3540
3541 /** Build a hash of token names to compare against when recollecting our token list. */
3542 for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
3543 ignore[args[i]] = true;
3544 delete tokenMap[args[i]];
3545 }
3546
3547 /** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
3548 for (i = 0; i < tokens.length; ++i)
3549 if (!ignore[tokens[i]]) t.push(tokens[i]);
3550
3551 tokens = t;
3552 length = t.length >>> 0;
3553
3554 /** Update the targeted attribute of the attached element. */
3555 if (typeof el[prop] === "object") {
3556 el[prop].baseVal = tokens.join(" ");
3557 } else {
3558 el[prop] = tokens.join(" ");
3559 }
3560 reindex();
3561 };
3562
3563 that.toggle = function (token, force) {
3564 preop.apply(that, [token]);
3565
3566 /** Token state's being forced. */
3567 if (undefined !== force) {
3568 if (force) {
3569 that.add(token);
3570 return true;
3571 } else {
3572 that.remove(token);
3573 return false;
3574 }
3575 }
3576
3577 /** Token already exists in tokenList. Remove it, and return FALSE. */
3578 if (tokenMap[token]) {
3579 that.remove(token);
3580 return false;
3581 }
3582
3583 /** Otherwise, add the token and return TRUE. */
3584 that.add(token);
3585 return true;
3586 };
3587
3588 return that;
3589 };
3590
3591 return _DOMTokenList;
3592}());
3593if (!("DOMTokenList"in this&&function(s){return!("classList"in s)||!s.classList.toggle("x",!1)&&!s.className}(document.createElement("x"))
3594)) {
3595
3596// DOMTokenList
3597(function (global) {
3598 var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
3599
3600 if (
3601 !nativeImpl ||
3602 (
3603 !!document.createElementNS &&
3604 !!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
3605 !(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
3606 )
3607 ) {
3608 global.DOMTokenList = _DOMTokenList;
3609 }
3610
3611 // Add second argument to native DOMTokenList.toggle() if necessary
3612 (function () {
3613 var e = document.createElement('span');
3614 if (!('classList' in e)) return;
3615 e.classList.toggle('x', false);
3616 if (!e.classList.contains('x')) return;
3617 e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
3618 var force = arguments[1];
3619 if (force === undefined) {
3620 var add = !this.contains(token);
3621 this[add ? 'add' : 'remove'](token);
3622 return add;
3623 }
3624 force = !!force;
3625 this[force ? 'add' : 'remove'](token);
3626 return force;
3627 };
3628 }());
3629
3630 // Add multiple arguments to native DOMTokenList.add() if necessary
3631 (function () {
3632 var e = document.createElement('span');
3633 if (!('classList' in e)) return;
3634 e.classList.add('a', 'b');
3635 if (e.classList.contains('b')) return;
3636 var native = e.classList.constructor.prototype.add;
3637 e.classList.constructor.prototype.add = function () {
3638 var args = arguments;
3639 var l = arguments.length;
3640 for (var i = 0; i < l; i++) {
3641 native.call(this, args[i]);
3642 }
3643 };
3644 }());
3645
3646 // Add multiple arguments to native DOMTokenList.remove() if necessary
3647 (function () {
3648 var e = document.createElement('span');
3649 if (!('classList' in e)) return;
3650 e.classList.add('a');
3651 e.classList.add('b');
3652 e.classList.remove('a', 'b');
3653 if (!e.classList.contains('b')) return;
3654 var native = e.classList.constructor.prototype.remove;
3655 e.classList.constructor.prototype.remove = function () {
3656 var args = arguments;
3657 var l = arguments.length;
3658 for (var i = 0; i < l; i++) {
3659 native.call(this, args[i]);
3660 }
3661 };
3662 }());
3663
3664}(this));
3665
3666}
3667
3668
3669// _ESAbstract.CreateDataProperty
3670// 7.3.4. CreateDataProperty ( O, P, V )
3671// NOTE
3672// This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator.
3673// 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.
3674function CreateDataProperty(O, P, V) { // eslint-disable-line no-unused-vars
3675 // 1. Assert: Type(O) is Object.
3676 // 2. Assert: IsPropertyKey(P) is true.
3677 // 3. Let newDesc be the PropertyDescriptor{ [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }.
3678 var newDesc = {
3679 value: V,
3680 writable: true,
3681 enumerable: true,
3682 configurable: true
3683 };
3684 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
3685 try {
3686 Object.defineProperty(O, P, newDesc);
3687 return true;
3688 } catch (e) {
3689 return false;
3690 }
3691}
3692
3693// _ESAbstract.CreateDataPropertyOrThrow
3694/* global CreateDataProperty */
3695// 7.3.6. CreateDataPropertyOrThrow ( O, P, V )
3696function CreateDataPropertyOrThrow(O, P, V) { // eslint-disable-line no-unused-vars
3697 // 1. Assert: Type(O) is Object.
3698 // 2. Assert: IsPropertyKey(P) is true.
3699 // 3. Let success be ? CreateDataProperty(O, P, V).
3700 var success = CreateDataProperty(O, P, V);
3701 // 4. If success is false, throw a TypeError exception.
3702 if (!success) {
3703 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) + '`');
3704 }
3705 // 5. Return success.
3706 return success;
3707}
3708
3709// _ESAbstract.CreateIterResultObject
3710/* global Type, CreateDataProperty */
3711// 7.4.7. CreateIterResultObject ( value, done )
3712function CreateIterResultObject(value, done) { // eslint-disable-line no-unused-vars
3713 // 1. Assert: Type(done) is Boolean.
3714 if (Type(done) !== 'boolean') {
3715 throw new Error();
3716 }
3717 // 2. Let obj be ObjectCreate(%ObjectPrototype%).
3718 var obj = {};
3719 // 3. Perform CreateDataProperty(obj, "value", value).
3720 CreateDataProperty(obj, "value", value);
3721 // 4. Perform CreateDataProperty(obj, "done", done).
3722 CreateDataProperty(obj, "done", done);
3723 // 5. Return obj.
3724 return obj;
3725}
3726
3727// _ESAbstract.CreateMethodProperty
3728// 7.3.5. CreateMethodProperty ( O, P, V )
3729function CreateMethodProperty(O, P, V) { // eslint-disable-line no-unused-vars
3730 // 1. Assert: Type(O) is Object.
3731 // 2. Assert: IsPropertyKey(P) is true.
3732 // 3. Let newDesc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true}.
3733 var newDesc = {
3734 value: V,
3735 writable: true,
3736 enumerable: false,
3737 configurable: true
3738 };
3739 // 4. Return ? O.[[DefineOwnProperty]](P, newDesc).
3740 Object.defineProperty(O, P, newDesc);
3741}
3742if (!("isArray"in Array
3743)) {
3744
3745// Array.isArray
3746/* global CreateMethodProperty, IsArray */
3747// 22.1.2.2. Array.isArray ( arg )
3748CreateMethodProperty(Array, 'isArray', function isArray(arg) {
3749 // 1. Return ? IsArray(arg).
3750 return IsArray(arg);
3751});
3752
3753}
3754
3755if (!("copyWithin"in Array.prototype&&function(){try{var t=function n(){}
3756t.prototype[0]="foo"
3757var o=new t
3758o[1]=1,o[2]=2,o.length=3
3759var r=Array.prototype.copyWithin.call(o,1,0)
3760return!(!r[0]||Object.prototype.hasOwnProperty.call(r,"0")||!Object.prototype.hasOwnProperty.call(r,"1")||"foo"!==r[0]||"foo"!==r[1]||1!==r[2]||3!==r.length)}catch(e){return!1}}()
3761)) {
3762
3763// Array.prototype.copyWithin
3764/* global CreateMethodProperty, HasProperty, ToInteger */
3765// 22.1.3.3 Array.prototype.copyWithin ( target, start [ , end ] )
3766CreateMethodProperty(Array.prototype, 'copyWithin', function copyWithin(target, start /* [ , end ] */ ) {
3767 'use strict';
3768 var end = arguments[2];
3769
3770 // 22.1.3.3.1 Let O be ? ToObject(this value).
3771 if (this === null || this === undefined) {
3772 throw new TypeError('Cannot call method on ' + this);
3773 }
3774
3775 var o = Object(this);
3776
3777 // 22.1.3.3.2 Let len be ? ToLength(? Get(O, "length")).
3778 var len = ToInteger(o.length);
3779 if (len <= 0) {
3780 len = 0;
3781 }
3782 if (len === Infinity) {
3783 len = Math.pow(2, 53) - 1;
3784 } else {
3785 len = Math.min(len, Math.pow(2, 53) - 1);
3786 }
3787 len = Math.max(len, 0);
3788
3789 // 22.1.3.3.3 Let relativeTarget be ? ToInteger(target).
3790 var relativeTarget = ToInteger(target);
3791
3792 // 22.1.3.3.4 If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let to be min(relativeTarget, len).
3793 var to;
3794 if (relativeTarget < 0) {
3795 to = Math.max(len + relativeTarget, 0);
3796 } else {
3797 to = Math.min(relativeTarget, len);
3798 }
3799
3800 // 22.1.3.3.5 Let relativeStart be ? ToInteger(start).
3801 var relativeStart = ToInteger(start);
3802
3803 // 22.1.3.3.6 If relativeStart < 0, let from be max((len + relativeStart), 0); else let from be min(relativeStart, len).
3804 var from;
3805 if (relativeStart < 0) {
3806 from = Math.max(len + relativeStart, 0);
3807 } else {
3808 from = Math.min(relativeStart, len);
3809 }
3810
3811 // 22.1.3.3.7 If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
3812 var relativeEnd;
3813 if (end === undefined) {
3814 relativeEnd = len;
3815 } else {
3816 relativeEnd = ToInteger(end);
3817 }
3818
3819 // 22.1.3.3.8 If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
3820 var final;
3821 if (relativeEnd < 0) {
3822 final = Math.max(len + relativeEnd, 0);
3823 } else {
3824 final = Math.min(relativeEnd, len);
3825 }
3826
3827 // 22.1.3.3.9 Let count be min(final-from, len-to).
3828 var count = Math.min(final - from, len - to);
3829
3830 // 22.1.3.3.10 If from<to and to<from+count, then
3831 var direction;
3832 if (from < to && to < from + count) {
3833 // 22.1.3.3.10.a Let direction be -1.
3834 direction = -1;
3835
3836 // 22.1.3.3.10.b Let from be from + count - 1.
3837 from = from + count - 1;
3838
3839 // 22.1.3.3.10.c Let to be to + count - 1.
3840 to = to + count - 1;
3841 } else {
3842 // 22.1.3.3.11 Else,
3843 // 22.1.3.3.11.a Let direction be 1.
3844 direction = 1;
3845 }
3846
3847 // 22.1.3.3.12 Repeat, while count > 0
3848 while (count > 0) {
3849 // 22.1.3.3.12.a Let fromKey be ! ToString(from).
3850 var fromKey = String(from);
3851 // 22.1.3.3.12.b Let toKey be ! ToString(to).
3852 var toKey = String(to);
3853 // 22.1.3.3.12.c Let fromPresent be ? HasProperty(O, fromKey).
3854 var fromPresent = HasProperty(o, fromKey);
3855 // 22.1.3.3.12.d If fromPresent is true, then
3856 if (fromPresent) {
3857 // 22.1.3.3.12.d.i Let fromVal be ? Get(O, fromKey).
3858 var fromVal = o[fromKey];
3859 // 22.1.3.3.12.d.ii Perform ? Set(O, toKey, fromVal, true).
3860 o[toKey] = fromVal;
3861 } else {
3862 // 22.1.3.3.12.e Else fromPresent is false,
3863 // 22.1.3.3.12.e.i Perform ? DeletePropertyOrThrow(O, toKey).
3864 delete o[toKey];
3865 }
3866 // 22.1.3.3.12.f Let from be from + direction.
3867 from = from + direction;
3868 // 22.1.3.3.12.g Let to be to + direction.
3869 to = to + direction;
3870 // 22.1.3.3.12.h Let count be count - 1.
3871 count = count - 1;
3872 }
3873 // 22.1.3.3.13 Return O.
3874 return o;
3875});
3876
3877}
3878
3879if (!("every"in Array.prototype
3880)) {
3881
3882// Array.prototype.every
3883/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToBoolean, ToLength, ToObject, ToString */
3884// 22.1.3.5. Array.prototype.every ( callbackfn [ , thisArg ] )
3885CreateMethodProperty(Array.prototype, 'every', function every(callbackfn /* [ , thisArg ] */) {
3886 // 1. Let O be ? ToObject(this value).
3887 var O = ToObject(this);
3888 // 2. Let len be ? ToLength(? Get(O, "length")).
3889 var len = ToLength(Get(O, "length"));
3890 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
3891 if (IsCallable(callbackfn) === false) {
3892 throw new TypeError(callbackfn + ' is not a function');
3893 }
3894 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
3895 var T = arguments.length > 1 ? arguments[1] : undefined;
3896 // 5. Let k be 0.
3897 var k = 0;
3898 // 6. Repeat, while k < len
3899 while (k < len) {
3900 // a. Let Pk be ! ToString(k).
3901 var Pk = ToString(k);
3902 // b. Let kPresent be ? HasProperty(O, Pk).
3903 var kPresent = HasProperty(O, Pk);
3904 // c. If kPresent is true, then
3905 if (kPresent) {
3906 // i. Let kValue be ? Get(O, Pk).
3907 var kValue = Get(O, Pk);
3908 // ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
3909 var testResult = ToBoolean(Call(callbackfn, T, [kValue, k, O]));
3910 // iii. If testResult is false, return false.
3911 if (testResult === false) {
3912 return false;
3913 }
3914 }
3915 // d. Increase k by 1.
3916 var k = k + 1;
3917 }
3918 // 7. Return true.
3919 return true;
3920});
3921
3922}
3923
3924if (!("fill"in Array.prototype
3925)) {
3926
3927// Array.prototype.fill
3928/* global CreateMethodProperty, Get, ToInteger, ToLength, ToObject, ToString */
3929// 22.1.3.6. Array.prototype.fill ( value [ , start [ , end ] ] )
3930CreateMethodProperty(Array.prototype, 'fill', function fill(value /* [ , start [ , end ] ] */) {
3931 var start = arguments[1];
3932 var end = arguments[2];
3933 // 1. Let O be ? ToObject(this value).
3934 var O = ToObject(this);
3935 // 2. Let len be ? ToLength(? Get(O, "length")).
3936 var len = ToLength(Get(O, "length"));
3937 // 3. Let relativeStart be ? ToInteger(start).
3938 var relativeStart = ToInteger(start);
3939 // 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be min(relativeStart, len)
3940 var k = relativeStart < 0 ? Math.max((len + relativeStart), 0) : Math.min(relativeStart, len);
3941 // 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
3942 var relativeEnd = end === undefined ? len : ToInteger(end);
3943 // 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
3944 var final = relativeEnd < 0 ? Math.max((len + relativeEnd), 0) : Math.min(relativeEnd, len);
3945 // 7. Repeat, while k < final
3946 while (k < final) {
3947 // a. Let Pk be ! ToString(k).
3948 var Pk = ToString(k);
3949 // b. Perform ? Set(O, Pk, value, true).
3950 O[Pk] = value;
3951 // c. Increase k by 1.
3952 k = k + 1;
3953 }
3954 // 8. Return O.
3955 return O;
3956});
3957
3958}
3959
3960if (!("find"in Array.prototype
3961)) {
3962
3963// Array.prototype.find
3964/* global Call, CreateMethodProperty, Get, IsCallable, ToBoolean, ToLength, ToObject, ToString */
3965// 22.1.3.8 Array.prototype.find ( predicate [ , thisArg ] )
3966CreateMethodProperty(Array.prototype, 'find', function find( predicate /* [ , thisArg ] */) {
3967 // 1. Let O be ? ToObject(this value).
3968 var O = ToObject(this);
3969 // 2. Let len be ? ToLength(? Get(O, "length")).
3970 var len = ToLength(Get(O, "length"));
3971 // 3. If IsCallable(predicate) is false, throw a TypeError exception.
3972 if (IsCallable(predicate) === false) {
3973 throw new TypeError(predicate + ' is not a function');
3974 }
3975 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
3976 var T = arguments.length > 1 ? arguments[1] : undefined;
3977 // 5. Let k be 0.
3978 var k = 0;
3979 // 6. Repeat, while k < len
3980 while (k < len) {
3981 // a. Let Pk be ! ToString(k).
3982 var Pk = ToString(k);
3983 // b. Let kValue be ? Get(O, Pk).
3984 var kValue = Get(O, Pk);
3985 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
3986 var testResult = ToBoolean(Call(predicate, T, [kValue, k, O ]));
3987 // d. If testResult is true, return kValue.
3988 if (testResult) {
3989 return kValue;
3990 }
3991 // e. Increase k by 1.
3992 var k = k + 1;
3993 }
3994 // 7. Return undefined.
3995 return undefined;
3996});
3997
3998}
3999
4000if (!("findIndex"in Array.prototype
4001)) {
4002
4003// Array.prototype.findIndex
4004/* global Call, CreateMethodProperty, Get, IsCallable, ToBoolean, ToLength, ToObject, ToString */
4005// 22.1.3.9. Array.prototype.findIndex ( predicate [ , thisArg ] )
4006CreateMethodProperty(Array.prototype, 'findIndex', function findIndex(predicate /* [ , thisArg ] */) {
4007 // 1. Let O be ? ToObject(this value).
4008 var O = ToObject(this);
4009 // 2. Let len be ? ToLength(? Get(O, "length")).
4010 var len = ToLength(Get(O, "length"));
4011 // 3. If IsCallable(predicate) is false, throw a TypeError exception.
4012 if (IsCallable(predicate) === false) {
4013 throw new TypeError(predicate + ' is not a function');
4014 }
4015 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
4016 var T = arguments.length > 1 ? arguments[1] : undefined;
4017 // 5. Let k be 0.
4018 var k = 0;
4019 // 6. Repeat, while k < len
4020 while (k < len) {
4021 // a. Let Pk be ! ToString(k).
4022 var Pk = ToString(k);
4023 // b. Let kValue be ? Get(O, Pk).
4024 var kValue = Get(O, Pk);
4025 // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
4026 var testResult = ToBoolean(Call(predicate, T, [kValue, k, O]));
4027 // d. If testResult is true, return k.
4028 if (testResult) {
4029 return k;
4030 }
4031 // e. Increase k by 1.
4032 k = k + 1;
4033 }
4034 // 7. Return -1.
4035 return -1;
4036});
4037
4038}
4039
4040if (!("forEach"in Array.prototype
4041)) {
4042
4043// Array.prototype.forEach
4044/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
4045// 22.1.3.10. Array.prototype.forEach ( callbackfn [ , thisArg ] )
4046CreateMethodProperty(Array.prototype, 'forEach', function forEach(callbackfn /* [ , thisArg ] */) {
4047 // 1. Let O be ? ToObject(this value).
4048 var O = ToObject(this);
4049 // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
4050 // We will use arrayLike in place of O when we are iterating through the list.
4051 var arraylike = O instanceof String ? O.split('') : O;
4052 // 2. Let len be ? ToLength(? Get(O, "length")).
4053 var len = ToLength(Get(O, "length"));
4054 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
4055 if (IsCallable(callbackfn) === false) {
4056 throw new TypeError(callbackfn + ' is not a function');
4057 }
4058 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
4059 var T = arguments.length > 1 ? arguments[1] : undefined;
4060 // 5. Let k be 0.
4061 var k = 0;
4062 // 6. Repeat, while k < len
4063 while (k < len) {
4064 // a. Let Pk be ! ToString(k).
4065 var Pk = ToString(k);
4066 // b. Let kPresent be ? HasProperty(O, Pk).
4067 var kPresent = HasProperty(arraylike, Pk);
4068 // c. If kPresent is true, then
4069 if (kPresent) {
4070 // i. Let kValue be ? Get(O, Pk).
4071 var kValue = Get(arraylike, Pk);
4072 // ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
4073 Call(callbackfn, T, [kValue, k, O]);
4074 }
4075 // d. Increase k by 1.
4076 k = k + 1;
4077 }
4078 // 7. Return undefined.
4079 return undefined;
4080});
4081
4082}
4083
4084if (!("forEach"in NodeList.prototype
4085)) {
4086
4087// NodeList.prototype.forEach
4088NodeList.prototype.forEach = Array.prototype.forEach;
4089}
4090
4091if (!("includes"in Array.prototype
4092)) {
4093
4094// Array.prototype.includes
4095/* global CreateMethodProperty, Get, SameValueZero, ToInteger, ToLength, ToObject, ToString */
4096// 22.1.3.11. Array.prototype.includes ( searchElement [ , fromIndex ] )
4097CreateMethodProperty(Array.prototype, 'includes', function includes(searchElement /* [ , fromIndex ] */) {
4098 'use strict';
4099 // 1. Let O be ? ToObject(this value).
4100 var O = ToObject(this);
4101 // 2. Let len be ? ToLength(? Get(O, "length")).
4102 var len = ToLength(Get(O, "length"));
4103 // 3. If len is 0, return false.
4104 if (len === 0) {
4105 return false;
4106 }
4107 // 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.)
4108 var n = ToInteger(arguments[1]);
4109 // 5. If n ≥ 0, then
4110 if (n >= 0) {
4111 // a. Let k be n.
4112 var k = n;
4113 // 6. Else n < 0,
4114 } else {
4115 // a. Let k be len + n.
4116 k = len + n;
4117 // b. If k < 0, let k be 0.
4118 if (k < 0) {
4119 k = 0;
4120 }
4121 }
4122 // 7. Repeat, while k < len
4123 while (k < len) {
4124 // a. Let elementK be the result of ? Get(O, ! ToString(k)).
4125 var elementK = Get(O, ToString(k));
4126 // b. If SameValueZero(searchElement, elementK) is true, return true.
4127 if (SameValueZero(searchElement, elementK)) {
4128 return true;
4129 }
4130 // c. Increase k by 1.
4131 k = k + 1;
4132 }
4133 // 8. Return false.
4134 return false;
4135});
4136
4137}
4138
4139if (!("indexOf"in Array.prototype
4140)) {
4141
4142// Array.prototype.indexOf
4143/* global CreateMethodProperty, Get, HasProperty, ToInteger, ToLength, ToObject, ToString */
4144// 22.1.3.12. Array.prototype.indexOf ( searchElement [ , fromIndex ] )
4145CreateMethodProperty(Array.prototype, 'indexOf', function indexOf(searchElement /* [ , fromIndex ] */) {
4146 // 1. Let O be ? ToObject(this value).
4147 var O = ToObject(this);
4148 // 2. Let len be ? ToLength(? Get(O, "length")).
4149 var len = ToLength(Get(O, "length"));
4150 // 3. If len is 0, return -1.
4151 if (len === 0) {
4152 return -1;
4153 }
4154 // 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.)
4155 var n = ToInteger(arguments[1]);
4156 // 5. If n ≥ len, return -1.
4157 if (n >= len) {
4158 return -1;
4159 }
4160 // 6. If n ≥ 0, then
4161 if (n >= 0) {
4162 // a. If n is -0, let k be +0; else let k be n.
4163 var k = n === -0 ? 0 : n;
4164 // 7. Else n < 0,
4165 } else {
4166 // a. Let k be len + n.
4167 var k = len + n;
4168 // b. If k < 0, let k be 0.
4169 if (k < 0) {
4170 k = 0;
4171 }
4172 }
4173 // 8. Repeat, while k < len
4174 while (k < len) {
4175 // a. Let kPresent be ? HasProperty(O, ! ToString(k)).
4176 var kPresent = HasProperty(O, ToString(k));
4177 // b. If kPresent is true, then
4178 if (kPresent) {
4179 // i. Let elementK be ? Get(O, ! ToString(k)).
4180 var elementK = Get(O, ToString(k));
4181 // ii. Let same be the result of performing Strict Equality Comparison searchElement === elementK.
4182 var same = searchElement === elementK;
4183 // iii. If same is true, return k.
4184 if (same) {
4185 return k;
4186 }
4187 }
4188 // c. Increase k by 1.
4189 k = k + 1;
4190 }
4191 // 9. Return -1.
4192 return -1;
4193});
4194
4195}
4196
4197if (!("Element"in this&&"after"in Element.prototype
4198)) {
4199
4200// Element.prototype.after
4201Document.prototype.after = Element.prototype.after = function after() {
4202 if (this.parentNode) {
4203 var args = Array.prototype.slice.call(arguments),
4204 viableNextSibling = this.nextSibling,
4205 idx = viableNextSibling ? args.indexOf(viableNextSibling) : -1;
4206
4207 while (idx !== -1) {
4208 viableNextSibling = viableNextSibling.nextSibling;
4209 if (!viableNextSibling) {
4210 break;
4211 }
4212 idx = args.indexOf(viableNextSibling);
4213 }
4214
4215 this.parentNode.insertBefore(_mutation(arguments), viableNextSibling);
4216 }
4217};
4218
4219// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
4220// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
4221if ("Text" in this) {
4222 Text.prototype.after = Element.prototype.after;
4223}
4224
4225}
4226
4227if (!("Element"in this&&"before"in Element.prototype
4228)) {
4229
4230// Element.prototype.before
4231Document.prototype.before = Element.prototype.before = function before() {
4232 if (this.parentNode) {
4233 var args = Array.prototype.slice.call(arguments),
4234 viablePreviousSibling = this.previousSibling,
4235 idx = viablePreviousSibling ? args.indexOf(viablePreviousSibling) : -1;
4236
4237 while (idx !== -1) {
4238 viablePreviousSibling = viablePreviousSibling.previousSibling;
4239 if (!viablePreviousSibling) {
4240 break;
4241 }
4242 idx = args.indexOf(viablePreviousSibling);
4243 }
4244
4245 this.parentNode.insertBefore(
4246 _mutation(arguments),
4247 viablePreviousSibling ? viablePreviousSibling.nextSibling : this.parentNode.firstChild
4248 );
4249 }
4250};
4251
4252// Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
4253// TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
4254if ("Text" in this) {
4255 Text.prototype.before = Element.prototype.before;
4256}
4257
4258}
4259
4260if (!("lastIndexOf"in Array.prototype
4261)) {
4262
4263// Array.prototype.lastIndexOf
4264/* global CreateMethodProperty, Get, HasProperty, ToInteger, ToLength, ToObject, ToString */
4265// 22.1.3.15. Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
4266CreateMethodProperty(Array.prototype, 'lastIndexOf', function lastIndexOf(searchElement /* [ , fromIndex ] */) {
4267 // 1. Let O be ? ToObject(this value).
4268 var O = ToObject(this);
4269 // 2. Let len be ? ToLength(? Get(O, "length")).
4270 var len = ToLength(Get(O, "length"));
4271 // 3. If len is 0, return -1.
4272 if (len === 0) {
4273 return -1;
4274 }
4275 // 4. If fromIndex is present, let n be ? ToInteger(fromIndex); else let n be len-1.
4276 var n = arguments.length > 1 ? ToInteger(arguments[1]) : len - 1;
4277 // 5. If n ≥ 0, then
4278 if (n >= 0) {
4279 // a. If n is -0, let k be +0; else let k be min(n, len - 1).
4280 var k = n === -0 ? 0 : Math.min(n, len - 1);
4281 // 6. Else n < 0,
4282 } else {
4283 // a. Let k be len + n.
4284 k = len + n;
4285 }
4286 // 7. Repeat, while k ≥ 0
4287 while (k >= 0) {
4288 // a. Let kPresent be ? HasProperty(O, ! ToString(k)).
4289 var kPresent = HasProperty(O, ToString(k));
4290 // b. If kPresent is true, then
4291 if (kPresent) {
4292 // i. Let elementK be ? Get(O, ! ToString(k)).
4293 var elementK = Get(O, ToString(k));
4294 // ii. Let same be the result of performing Strict Equality Comparison searchElement === elementK.
4295 var same = searchElement === elementK;
4296 // iii. If same is true, return k.
4297 if (same) {
4298 return k;
4299 }
4300 }
4301 // c. Decrease k by 1.
4302 k = k - 1;
4303 }
4304 // 9. Return -1.
4305 return -1;
4306});
4307
4308}
4309
4310if (!("reduce"in Array.prototype
4311)) {
4312
4313// Array.prototype.reduce
4314/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
4315// 22.1.3.19. Array.prototype.reduce ( callbackfn [ , initialValue ] )
4316CreateMethodProperty(Array.prototype, 'reduce', function reduce(callbackfn /* [ , initialValue ] */) {
4317 // 1. Let O be ? ToObject(this value).
4318 var O = ToObject(this);
4319 // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
4320 // We will use arrayLike in place of O when we are iterating through the list.
4321 var arraylike = O instanceof String ? O.split('') : O;
4322 // 2. Let len be ? ToLength(? Get(O, "length")).
4323 var len = ToLength(Get(arraylike, "length"));
4324 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
4325 if (IsCallable(callbackfn) === false) {
4326 throw new TypeError(callbackfn + ' is not a function');
4327 }
4328 // 4. If len is 0 and initialValue is not present, throw a TypeError exception.
4329 var initialValue = arguments.length > 1 ? arguments[1] : undefined;
4330 if (len === 0 && arguments.length < 2) {
4331 throw new TypeError('Reduce of empty array with no initial value');
4332 }
4333 // 5. Let k be 0.
4334 var k = 0;
4335 // 6. Let accumulator be undefined.
4336 var accumulator = undefined;
4337 // 7. If initialValue is present, then
4338 if (arguments.length > 1) {
4339 // a. Set accumulator to initialValue.
4340 accumulator = initialValue;
4341 // 8. Else initialValue is not present,
4342 } else {
4343 // a. Let kPresent be false.
4344 var kPresent = false;
4345 // b. Repeat, while kPresent is false and k < len
4346 while (kPresent === false && k < len) {
4347 // i. Let Pk be ! ToString(k).
4348 var Pk = ToString(k);
4349 // ii. Let kPresent be ? HasProperty(O, Pk).
4350 var kPresent = HasProperty(arraylike, Pk);
4351 // iii. If kPresent is true, then
4352 if (kPresent) {
4353 // 1. Set accumulator to ? Get(O, Pk).
4354 var accumulator = Get(arraylike, Pk);
4355 }
4356 // iv. Increase k by 1.
4357 k = k + 1;
4358 }
4359 // c. If kPresent is false, throw a TypeError exception.
4360 if (kPresent === false) {
4361 throw new TypeError('Reduce of empty array with no initial value');
4362 }
4363 }
4364 // 9. Repeat, while k < len
4365 while (k < len) {
4366 // a. Let Pk be ! ToString(k).
4367 var Pk = ToString(k);
4368 // b. Let kPresent be ? HasProperty(O, Pk).
4369 var kPresent = HasProperty(arraylike, Pk);
4370 // c. If kPresent is true, then
4371 if (kPresent) {
4372 // i. Let kValue be ? Get(O, Pk).
4373 var kValue = Get(arraylike, Pk);
4374 // ii. Set accumulator to ? Call(callbackfn, undefined, « accumulator, kValue, k, O »).
4375 accumulator = Call(callbackfn, undefined, [accumulator, kValue, k, O]);
4376 }
4377 // d. Increase k by 1.
4378 k = k + 1;
4379 }
4380 // 10. Return accumulator.
4381 return accumulator;
4382});
4383
4384}
4385
4386if (!("reduceRight"in Array.prototype
4387)) {
4388
4389// Array.prototype.reduceRight
4390/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
4391// 22.1.3.20. Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
4392CreateMethodProperty(Array.prototype, 'reduceRight', function reduceRight(callbackfn /* [ , initialValue ] */) {
4393 // 1. Let O be ? ToObject(this value).
4394 var O = ToObject(this);
4395 // Polyfill.io - If O is a String object, split it into an array in order to iterate correctly.
4396 // We will use arrayLike in place of O when we are iterating through the list.
4397 var arraylike = O instanceof String ? O.split('') : O;
4398 // 2. Let len be ? ToLength(? Get(O, "length")).
4399 var len = ToLength(Get(arraylike, "length"));
4400 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
4401 if (IsCallable(callbackfn) === false) {
4402 throw new TypeError(callbackfn + ' is not a function');
4403 }
4404 // 4. If len is 0 and initialValue is not present, throw a TypeError exception.
4405 var initialValue = arguments.length > 1 ? arguments[1] : undefined;
4406 if (len === 0 && arguments.length < 2) {
4407 throw new TypeError('Reduce of empty array with no initial value');
4408 }
4409 // 5. Let k be len-1.
4410 var k = len - 1;
4411 // 6. Let accumulator be undefined.
4412 var accumulator = undefined;
4413 // 7. If initialValue is present, then
4414 if (arguments.length > 1) {
4415 // a. Set accumulator to initialValue.
4416 accumulator = initialValue;
4417 // 8.Else initialValue is not present,
4418 } else {
4419 // a. Let kPresent be false.
4420 var kPresent = false;
4421 // b. Repeat, while kPresent is false and k ≥ 0
4422 while (kPresent === false && k >= 0) {
4423 // i. Let Pk be ! ToString(k).
4424 var Pk = ToString(k);
4425 // ii. Let kPresent be ? HasProperty(O, Pk).
4426 var kPresent = HasProperty(arraylike, Pk);
4427 // iii. If kPresent is true, then
4428 if (kPresent) {
4429 // 1. Set accumulator to ? Get(O, Pk).
4430 accumulator = Get(arraylike, Pk);
4431 }
4432 // iv. Decrease k by 1.
4433 k = k - 1;
4434 }
4435 // c. If kPresent is false, throw a TypeError exception.
4436 if (kPresent === false) {
4437 throw new TypeError('Reduce of empty array with no initial value');
4438 }
4439 }
4440 // 9. Repeat, while k ≥ 0
4441 while (k >= 0) {
4442 // a. Let Pk be ! ToString(k).
4443 var Pk = ToString(k);
4444 // b. Let kPresent be ? HasProperty(O, Pk).
4445 var kPresent = HasProperty(arraylike, Pk);
4446 // c. If kPresent is true, then
4447 if (kPresent) {
4448 // i. Let kValue be ? Get(O, Pk).
4449 var kValue = Get(arraylike, Pk);
4450 // ii. Set accumulator to ? Call(callbackfn, undefined, « accumulator, kValue, k, O »).
4451 accumulator = Call(callbackfn, undefined, [accumulator, kValue, k, O]);
4452 }
4453 // d. Decrease k by 1.
4454 k = k - 1;
4455 }
4456 // 10 Return accumulator.
4457 return accumulator;
4458});
4459
4460}
4461
4462if (!("some"in Array.prototype
4463)) {
4464
4465// Array.prototype.some
4466/* global Call, CreateMethodProperty, Get, HasProperty, IsCallable, ToBoolean, ToLength, ToObject, ToString */
4467// 22.1.3.24. Array.prototype.some ( callbackfn [ , thisArg ] )
4468CreateMethodProperty(Array.prototype, 'some', function some(callbackfn /* [ , thisArg ] */) {
4469 // 1. Let O be ? ToObject(this value).
4470 var O = ToObject(this);
4471 // 2. Let len be ? ToLength(? Get(O, "length")).
4472 var len = ToLength(Get(O, "length"));
4473 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
4474 if (IsCallable(callbackfn) === false) {
4475 throw new TypeError(callbackfn + ' is not a function');
4476 }
4477 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
4478 var T = arguments.length > 1 ? arguments[1] : undefined;
4479 // 5. Let k be 0.
4480 var k = 0;
4481 // 6. Repeat, while k < len
4482 while (k < len) {
4483 // a. Let Pk be ! ToString(k).
4484 var Pk = ToString(k);
4485 // b. Let kPresent be ? HasProperty(O, Pk).
4486 var kPresent = HasProperty(O, Pk);
4487 // c. If kPresent is true, then
4488 if (kPresent) {
4489 // i. Let kValue be ? Get(O, Pk).
4490 var kValue = Get(O, Pk);
4491 // ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
4492 var testResult = ToBoolean(Call(callbackfn, T, [kValue, k, O]));
4493 // iii. If testResult is true, return true.
4494 if (testResult) {
4495 return true;
4496 }
4497 }
4498 // d. Increase k by 1.
4499 k = k + 1;
4500 }
4501 // 7. Return false.
4502 return false;
4503});
4504
4505}
4506
4507if (!("bind"in Function.prototype
4508)) {
4509
4510// Function.prototype.bind
4511/* global CreateMethodProperty, IsCallable */
4512// 19.2.3.2. Function.prototype.bind ( thisArg, ...args )
4513// https://github.com/es-shims/es5-shim/blob/d6d7ff1b131c7ba14c798cafc598bb6780d37d3b/es5-shim.js#L182
4514CreateMethodProperty(Function.prototype, 'bind', function bind(that) { // .length is 1
4515 // add necessary es5-shim utilities
4516 var $Array = Array;
4517 var $Object = Object;
4518 var ArrayPrototype = $Array.prototype;
4519 var Empty = function Empty() { };
4520 var array_slice = ArrayPrototype.slice;
4521 var array_concat = ArrayPrototype.concat;
4522 var array_push = ArrayPrototype.push;
4523 var max = Math.max;
4524 // /add necessary es5-shim utilities
4525
4526 // 1. Let Target be the this value.
4527 var target = this;
4528 // 2. If IsCallable(Target) is false, throw a TypeError exception.
4529 if (!IsCallable(target)) {
4530 throw new TypeError('Function.prototype.bind called on incompatible ' + target);
4531 }
4532 // 3. Let A be a new (possibly empty) internal list of all of the
4533 // argument values provided after thisArg (arg1, arg2 etc), in order.
4534 // XXX slicedArgs will stand in for "A" if used
4535 var args = array_slice.call(arguments, 1); // for normal call
4536 // 4. Let F be a new native ECMAScript object.
4537 // 11. Set the [[Prototype]] internal property of F to the standard
4538 // built-in Function prototype object as specified in 15.3.3.1.
4539 // 12. Set the [[Call]] internal property of F as described in
4540 // 15.3.4.5.1.
4541 // 13. Set the [[Construct]] internal property of F as described in
4542 // 15.3.4.5.2.
4543 // 14. Set the [[HasInstance]] internal property of F as described in
4544 // 15.3.4.5.3.
4545 var bound;
4546 var binder = function () {
4547
4548 if (this instanceof bound) {
4549 // 15.3.4.5.2 [[Construct]]
4550 // When the [[Construct]] internal method of a function object,
4551 // F that was created using the bind function is called with a
4552 // list of arguments ExtraArgs, the following steps are taken:
4553 // 1. Let target be the value of F's [[TargetFunction]]
4554 // internal property.
4555 // 2. If target has no [[Construct]] internal method, a
4556 // TypeError exception is thrown.
4557 // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
4558 // property.
4559 // 4. Let args be a new list containing the same values as the
4560 // list boundArgs in the same order followed by the same
4561 // values as the list ExtraArgs in the same order.
4562 // 5. Return the result of calling the [[Construct]] internal
4563 // method of target providing args as the arguments.
4564
4565 var result = target.apply(
4566 this,
4567 array_concat.call(args, array_slice.call(arguments))
4568 );
4569 if ($Object(result) === result) {
4570 return result;
4571 }
4572 return this;
4573
4574 } else {
4575 // 15.3.4.5.1 [[Call]]
4576 // When the [[Call]] internal method of a function object, F,
4577 // which was created using the bind function is called with a
4578 // this value and a list of arguments ExtraArgs, the following
4579 // steps are taken:
4580 // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
4581 // property.
4582 // 2. Let boundThis be the value of F's [[BoundThis]] internal
4583 // property.
4584 // 3. Let target be the value of F's [[TargetFunction]] internal
4585 // property.
4586 // 4. Let args be a new list containing the same values as the
4587 // list boundArgs in the same order followed by the same
4588 // values as the list ExtraArgs in the same order.
4589 // 5. Return the result of calling the [[Call]] internal method
4590 // of target providing boundThis as the this value and
4591 // providing args as the arguments.
4592
4593 // equiv: target.call(this, ...boundArgs, ...args)
4594 return target.apply(
4595 that,
4596 array_concat.call(args, array_slice.call(arguments))
4597 );
4598
4599 }
4600
4601 };
4602
4603 // 15. If the [[Class]] internal property of Target is "Function", then
4604 // a. Let L be the length property of Target minus the length of A.
4605 // b. Set the length own property of F to either 0 or L, whichever is
4606 // larger.
4607 // 16. Else set the length own property of F to 0.
4608
4609 var boundLength = max(0, target.length - args.length);
4610
4611 // 17. Set the attributes of the length own property of F to the values
4612 // specified in 15.3.5.1.
4613 var boundArgs = [];
4614 for (var i = 0; i < boundLength; i++) {
4615 array_push.call(boundArgs, '$' + i);
4616 }
4617
4618 // XXX Build a dynamic function with desired amount of arguments is the only
4619 // way to set the length property of a function.
4620 // In environments where Content Security Policies enabled (Chrome extensions,
4621 // for ex.) all use of eval or Function costructor throws an exception.
4622 // However in all of these environments Function.prototype.bind exists
4623 // and so this code will never be executed.
4624 bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
4625
4626 if (target.prototype) {
4627 Empty.prototype = target.prototype;
4628 bound.prototype = new Empty();
4629 // Clean up dangling references.
4630 Empty.prototype = null;
4631 }
4632
4633 // TODO
4634 // 18. Set the [[Extensible]] internal property of F to true.
4635
4636 // TODO
4637 // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
4638 // 20. Call the [[DefineOwnProperty]] internal method of F with
4639 // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
4640 // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
4641 // false.
4642 // 21. Call the [[DefineOwnProperty]] internal method of F with
4643 // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
4644 // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
4645 // and false.
4646
4647 // TODO
4648 // NOTE Function objects created using Function.prototype.bind do not
4649 // have a prototype property or the [[Code]], [[FormalParameters]], and
4650 // [[Scope]] internal properties.
4651 // XXX can't delete prototype in pure-js.
4652
4653 // 22. Return F.
4654 return bound;
4655});
4656
4657}
4658
4659if (!("acosh"in Math
4660)) {
4661
4662// Math.acosh
4663/* global CreateMethodProperty */
4664// 20.2.2.3. Math.acosh ( x )
4665CreateMethodProperty(Math, 'acosh', function acosh(x) {
4666 // If x is NaN, the result is NaN.
4667 if (isNaN(x)) {
4668 return NaN;
4669 }
4670 // If x is less than 1, the result is NaN.
4671 if (x < 1) {
4672 return NaN;
4673 }
4674 // If x is 1, the result is +0.
4675 if (x === 1) {
4676 return 0;
4677 }
4678 // If x is +∞, the result is +∞.
4679 if (x === Infinity) {
4680 return Infinity;
4681 }
4682 return Math.log(x + Math.sqrt(x * x - 1));
4683});
4684
4685}
4686
4687if (!("asinh"in Math
4688)) {
4689
4690// Math.asinh
4691/* global CreateMethodProperty */
4692// 20.2.2.5. Math.asinh ( x )
4693CreateMethodProperty(Math, 'asinh', function asinh(x) {
4694 // If x is NaN, the result is NaN.
4695 if (isNaN(x)) {
4696 return NaN;
4697 }
4698 // If x is +0, the result is +0.
4699 if (x === 0 && 1/x === Infinity) {
4700 return 0;
4701 }
4702 // If x is -0, the result is -0.
4703 if (x === 0 && 1/x === -Infinity) {
4704 return -0;
4705 }
4706 // If x is +∞, the result is +∞.
4707 if (x === Infinity) {
4708 return Infinity;
4709 }
4710 // If x is -∞, the result is -∞.
4711 if (x === -Infinity) {
4712 return -Infinity;
4713 }
4714 return Math.log(x + Math.sqrt(x * x + 1));
4715});
4716
4717}
4718
4719if (!("atanh"in Math
4720)) {
4721
4722// Math.atanh
4723/* global CreateMethodProperty */
4724// 20.2.2.7. Math.atanh ( x )
4725CreateMethodProperty(Math, 'atanh', function atanh(x) {
4726 // If x is NaN, the result is NaN.
4727 if (isNaN(x)) {
4728 return NaN;
4729 }
4730 // If x is less than -1, the result is NaN.
4731 if (x < -1) {
4732 return NaN;
4733 }
4734 // If x is greater than 1, the result is NaN.
4735 if (x > 1) {
4736 return NaN;
4737 }
4738 // If x is -1, the result is -∞.
4739 if (x === -1) {
4740 return -Infinity;
4741 }
4742 // If x is +1, the result is +∞.
4743 if (x === 1) {
4744 return Infinity;
4745 }
4746 // If x is +0, the result is +0.
4747 if (x === 0 && 1/x === Infinity) {
4748 return 0;
4749 }
4750 // If x is -0, the result is -0.
4751 if (x === 0 && 1/x === -Infinity) {
4752 return -0;
4753 }
4754 return Math.log((1 + x) / (1 - x)) / 2;
4755});
4756
4757}
4758
4759if (!("cbrt"in Math
4760)) {
4761
4762// Math.cbrt
4763/* global CreateMethodProperty */
4764// 20.2.2.9. Math.cbrt ( x )
4765CreateMethodProperty(Math, 'cbrt', function cbrt(x) {
4766 // If x is NaN, the result is NaN.
4767 if (isNaN(x)) {
4768 return NaN;
4769 }
4770 // If x is +0, the result is +0.
4771 if (x === 0 && 1/x === Infinity) {
4772 return 0;
4773 }
4774 // If x is -0, the result is -0.
4775 if (x === 0 && 1/x === -Infinity) {
4776 return -0;
4777 }
4778 // If x is +∞, the result is +∞.
4779 if (x === Infinity) {
4780 return Infinity;
4781 }
4782 // If x is -∞, the result is -∞.
4783 if (x === -Infinity) {
4784 return -Infinity;
4785 }
4786 var y = Math.pow(Math.abs(x), 1 / 3);
4787 return x < 0 ? -y : y;
4788});
4789
4790}
4791
4792if (!("clz32"in Math
4793)) {
4794
4795// Math.clz32
4796/* global CreateMethodProperty, ToUint32 */
4797// 20.2.2.11. Math.clz32 ( x )
4798CreateMethodProperty(Math, 'clz32', function clz32(x) {
4799 // 1. Let n be ToUint32(x).
4800 var n = ToUint32(x);
4801 // 2. Let p be the number of leading zero bits in the 32-bit binary representation of n.
4802 var p = n ? 32 - n.toString(2).length : 32;
4803 // 3. Return p.
4804 return p;
4805});
4806
4807}
4808
4809if (!("cosh"in Math
4810)) {
4811
4812// Math.cosh
4813/* global CreateMethodProperty */
4814// 20.2.2.1. 3Math.cosh ( x )
4815CreateMethodProperty(Math, 'cosh', function cosh(x) {
4816 // If x is NaN, the result is NaN.
4817 if (isNaN(x)) {
4818 return NaN;
4819 }
4820 // If x is +0, the result is 1.
4821 if (x === 0 && 1/x === Infinity) {
4822 return 1;
4823 }
4824 // If x is -0, the result is 1.
4825 if (x === 0 && 1/x === -Infinity) {
4826 return 1;
4827 }
4828 // If x is +∞, the result is +∞.
4829 if (x === Infinity) {
4830 return Infinity;
4831 }
4832 // If x is -∞, the result is +∞.
4833 if (x === -Infinity) {
4834 return Infinity;
4835 }
4836 x = Math.abs(x);
4837 if (x > 709) {
4838 var y = Math.exp(0.5 * x);
4839 return y / 2 * y;
4840 }
4841 var y = Math.exp(x);
4842 return (y + 1 / y) / 2;
4843});
4844
4845}
4846
4847if (!("expm1"in Math
4848)) {
4849
4850// Math.expm1
4851/* global CreateMethodProperty */
4852// 20.2.2.15. Math.expm1 ( x )
4853CreateMethodProperty(Math, 'expm1', function expm1(x) {
4854 // If x is NaN, the result is NaN.
4855 if (isNaN(x)) {
4856 return NaN;
4857 }
4858 // If x is +0, the result is +0.
4859 if (x === 0 && 1/x === Infinity) {
4860 return 0;
4861 }
4862 // If x is -0, the result is -0.
4863 if (x === 0 && 1/x === -Infinity) {
4864 return -0;
4865 }
4866 // If x is +∞, the result is +∞.
4867 if (x === Infinity) {
4868 return Infinity;
4869 }
4870 // If x is -∞, the result is -1.
4871 if (x === -Infinity) {
4872 return -1;
4873 }
4874
4875 if (x > -1e-6 && x < 1e-6) {
4876 return x + x * x / 2;
4877 } else {
4878 return Math.exp(x) - 1;
4879 }
4880});
4881
4882}
4883
4884if (!("fround"in Math
4885)) {
4886
4887// Math.fround
4888/* global Float32Array, CreateMethodProperty */
4889// 20.2.2.17 Math.fround ( x )
4890CreateMethodProperty(Math, 'fround', function (x) {
4891 // 1. If x is NaN, return NaN.
4892 if (isNaN(x)) {
4893 return NaN;
4894 }
4895 // 2. If x is one of +0, -0, +∞, -∞, return x.
4896 if (1 / x === +Infinity || 1 / x === -Infinity || x === +Infinity || x === -Infinity) {
4897 return x;
4898 }
4899 // 3. Let x32 be the result of converting x to a value in IEEE 754-2008 binary32 format using roundTiesToEven.
4900 // 4. Let x64 be the result of converting x32 to a value in IEEE 754-2008 binary64 format.
4901 // 5. Return the ECMAScript Number value corresponding to x64.
4902 return (new Float32Array([x]))[0];
4903});
4904
4905}
4906
4907if (!("hypot"in Math
4908)) {
4909
4910// Math.hypot
4911/* global CreateMethodProperty */
4912// 20.2.2.18. Math.hypot ( value1, value2, ...values )
4913CreateMethodProperty(Math, 'hypot', function hypot(value1, value2) { // eslint-disable-line no-unused-vars
4914 // If no arguments are passed, the result is +0.
4915 if (arguments.length === 0) {
4916 return 0;
4917 }
4918 var y = 0;
4919 var max = 0;
4920 for (var i = 0; i < arguments.length; ++i) {
4921 // If any argument is +∞, the result is +∞.
4922 if (arguments[i] === Infinity) {
4923 return Infinity;
4924 }
4925
4926 // If any argument is -∞, the result is +∞.
4927 if (arguments[i] === -Infinity) {
4928 return Infinity;
4929 }
4930
4931 // If no argument is +∞ or -∞, and any argument is NaN, the result is NaN.
4932 // If all arguments are either +0 or -0, the result is +0.
4933 // Polyfill.io - The two conditions above are handled in the math.
4934
4935 var arg = Math.abs(Number(arguments[i]));
4936 if (arg > max) {
4937 y = y * Math.pow(max / arg, 2);
4938 max = arg;
4939 }
4940 if (arg !== 0 || max !== 0) {
4941 y = y + Math.pow(arg / max, 2);
4942 }
4943 }
4944
4945 return max * Math.sqrt(y);
4946});
4947
4948}
4949
4950if (!("imul"in Math
4951)) {
4952
4953// Math.imul
4954/* global CreateMethodProperty, ToUint32 */
4955// 20.2.2.19. Math.imul ( x, y )
4956CreateMethodProperty(Math, 'imul', function imul(x, y) {
4957 // 1. Let a be ToUint32(x).
4958 var a = ToUint32(x);
4959 // 2. Let b be ToUint32(y).
4960 var b = ToUint32(y);
4961 var UINT16 = 0xffff;
4962 var aHigh = a >>> 16 & UINT16;
4963 var aLow = UINT16 & a;
4964 var bHigh = b >>> 16 & UINT16;
4965 var bLow = UINT16 & b;
4966 // the shift by 0 fixes the sign on the high part
4967 // the final |0 converts the unsigned value into a signed value
4968 return aLow * bLow + (aHigh * bLow + aLow * bHigh << 16 >>> 0) | 0;
4969});
4970}
4971
4972if (!("log10"in Math
4973)) {
4974
4975// Math.log10
4976/* global CreateMethodProperty */
4977// 20.2.2.22. Math.log10 ( x )
4978CreateMethodProperty(Math, 'log10', function log10(x) {
4979 return Math.log(x) / Math.LN10;
4980});
4981
4982}
4983
4984if (!("log1p"in Math
4985)) {
4986
4987// Math.log1p
4988/* global CreateMethodProperty */
4989// 20.2.2.21. Math.log1p ( x )
4990CreateMethodProperty(Math, 'log1p', function log1p(x) {
4991 x = Number(x);
4992 if (-1 < x && x < 1) {
4993 // Polyfill.io - For numbers in the range −1 < x < 1
4994 // Because we are using log, the precision of the result will be identical to log(1).
4995 // To fix this we avoid using log and use the Taylor Series expansion of log.
4996 // This series converges when |x| < 1. As we can not sum to infinity,
4997 // we instead sum the first 300 parts of the series to give a close approximation.
4998 // |x|<1, log(1+x) = x - x^2/2 + x^3/3 - ... + (-1)^(n-1)*x^n/n + ...
4999 var y = x;
5000 for (var i = 2; i <= 300; i++) {
5001 y += Math.pow((-1), (i - 1)) * Math.pow(x, i) / i;
5002 }
5003 return y;
5004 }
5005
5006 return Math.log(1 + x);
5007});
5008}
5009
5010if (!("log2"in Math
5011)) {
5012
5013// Math.log2
5014/* global CreateMethodProperty */
5015// 20.2.2.23. Math.log2 ( x )
5016CreateMethodProperty(Math, 'log2', function log2(x) {
5017 return Math.log(x) / Math.LN2;
5018});
5019
5020}
5021
5022if (!("sign"in Math
5023)) {
5024
5025// Math.sign
5026/* global CreateMethodProperty */
5027// 20.2.2.29. Math.sign ( x )
5028CreateMethodProperty(Math, 'sign', function sign(x) {
5029 var x = Number(x);
5030 // If x is NaN, the result is NaN.
5031 if (isNaN(x)) {
5032 return NaN;
5033 }
5034 // If x is -0, the result is -0.
5035 if (1 / x === -Infinity) {
5036 return -0;
5037 }
5038 // If x is +0, the result is +0.
5039 if (1 / x === Infinity) {
5040 return 0;
5041 }
5042 // If x is negative and not -0, the result is -1.
5043 if (x < 0) {
5044 return -1;
5045 }
5046 // If x is positive and not +0, the result is +1.
5047 if (x > 0) {
5048 return 1;
5049 }
5050});
5051
5052}
5053
5054if (!("sinh"in Math
5055)) {
5056
5057// Math.sinh
5058/* global CreateMethodProperty */
5059// 20.2.2.31. Math.sinh ( x )
5060CreateMethodProperty(Math, 'sinh', function sinh(x) {
5061 var s = (x < 0) ? -1 : 1;
5062 var absx = Math.abs(x);
5063 if (absx < 22) {
5064 if (absx < Math.pow(2, -28)) {
5065 return x;
5066 }
5067 var t = Math.exp(absx) - 1;
5068 if (absx < 1) {
5069 return (s * (2 * t - t * t / (t + 1)))/2;
5070 }
5071 return (s * (t + t / (t + 1)))/2;
5072 }
5073 if (absx < 709.7822265625) {
5074 return (s * Math.exp(absx))/2;
5075 }
5076 var w = Math.exp(0.5 * absx);
5077 var t = (s * w)/2;
5078 return t * w;
5079});
5080
5081}
5082
5083if (!("tanh"in Math
5084)) {
5085
5086// Math.tanh
5087/* global CreateMethodProperty */
5088// 20.2.2.34. Math.tanh ( x )
5089CreateMethodProperty(Math, 'tanh', function tanh(x) {
5090 var y;
5091
5092 return x === Infinity ? 1 : x === -Infinity ? -1 : (y = Math.exp(2 * x), (y - 1) / (y + 1));
5093});
5094
5095}
5096
5097if (!("trunc"in Math
5098)) {
5099
5100// Math.trunc
5101/* global CreateMethodProperty */
5102CreateMethodProperty(Math, 'trunc', function trunc(x) {
5103 return x < 0 ? Math.ceil(x) : Math.floor(x);
5104});
5105
5106}
5107
5108if (!("isFinite"in Number
5109)) {
5110
5111// Number.isFinite
5112/* global CreateMethodProperty, Type */
5113(function () {
5114 var that = this;
5115 // 20.1.2.2. Number.isFinite ( number )
5116 CreateMethodProperty(Number, 'isFinite', function isFinite(number) {
5117 // 1. If Type(number) is not Number, return false.
5118 if (Type(number) !== 'number') {
5119 return false;
5120 }
5121 // 2. If number is NaN, +∞, or -∞, return false.
5122 // 3. Otherwise, return true.
5123 // Polyfill.io - We use isFinite as it implements steps 2 and 3.
5124 return that.isFinite(number);
5125 });
5126}());
5127
5128}
5129
5130if (!("isInteger"in Number
5131)) {
5132
5133// Number.isInteger
5134/* global CreateMethodProperty, ToInteger, Type */
5135// 20.1.2.3. Number.isInteger ( number )
5136CreateMethodProperty(Number, 'isInteger', function isInteger(number) {
5137 // 1. If Type(number) is not Number, return false.
5138 if (Type(number) !== 'number') {
5139 return false;
5140 }
5141 // 2. If number is NaN, +∞, or -∞, return false.
5142 if (isNaN(number) || number === Infinity || number === -Infinity) {
5143 return false;
5144 }
5145 // 3. Let integer be ToInteger(number).
5146 var integer = ToInteger(number);
5147 // 4. If integer is not equal to number, return false.
5148 if (integer !== number) {
5149 return false;
5150 }
5151 // 5. Otherwise, return true.
5152 return true;
5153});
5154
5155}
5156
5157if (!("isNaN"in Number
5158)) {
5159
5160// Number.isNaN
5161/* global CreateMethodProperty, Type */
5162(function () {
5163 var that = this;
5164 // 20.1.2.4. Number.isNaN ( number )
5165 CreateMethodProperty(Number, 'isNaN', function isNaN(number) {
5166 // 1. If Type(number) is not Number, return false.
5167 if (Type(number) !== 'number') {
5168 return false;
5169 }
5170 // 2. If number is NaN, return true.
5171 if (that.isNaN(number)) {
5172 return true;
5173 }
5174 // 3. Otherwise, return false.
5175 return false;
5176 });
5177}());
5178
5179}
5180
5181if (!("isSafeInteger"in Number
5182)) {
5183
5184// Number.isSafeInteger
5185/* global CreateMethodProperty, Type, ToInteger */
5186// 20.1.2.5. Number.isSafeInteger ( number )
5187CreateMethodProperty(Number, 'isSafeInteger', function isSafeInteger(number) {
5188 // 1. If Type(number) is not Number, return false.
5189 if (Type(number) !== 'number') {
5190 return false;
5191 }
5192 // 2. If number is NaN, +∞, or -∞, return false.
5193 if (isNaN(number) || number === Infinity || number === -Infinity) {
5194 return false;
5195 }
5196 // 3. Let integer be ToInteger(number).
5197 var integer = ToInteger(number);
5198 // 4. If integer is not equal to number, return false.
5199 if (integer !== number) {
5200 return false;
5201 }
5202 // 5. If abs(integer) ≤ 2^53-1, return true.
5203 if (Math.abs(integer) <= (Math.pow(2, 53) - 1)) {
5204 return true;
5205 }
5206 // 6. Otherwise, return false.
5207 return false;
5208});
5209
5210}
5211
5212if (!("parseFloat"in Number
5213)) {
5214
5215// Number.parseFloat
5216/* global CreateMethodProperty */
5217// 20.1.2.12. Number.parseFloat ( string )
5218// The value of the Number.parseFloat data property is the same built-in function object that is the value of the parseFloat property of the global object defined in 18.2.4.
5219CreateMethodProperty(Number, 'parseFloat', parseFloat);
5220
5221}
5222
5223if (!("parseInt"in Number
5224)) {
5225
5226// Number.parseInt
5227/* global CreateMethodProperty */
5228// 20.1.2.13. Number.parseInt ( string, radix )
5229// The value of the Number.parseInt data property is the same built-in function object that is the value of the parseInt property of the global object defined in 18.2.5.
5230CreateMethodProperty(Number, 'parseInt', parseInt);
5231
5232}
5233
5234if (!("document"in this&&"classList"in document.documentElement&&"Element"in this&&"classList"in Element.prototype&&function(){var t=document.createElement("span")
5235return t.classList.add("a","b"),t.classList.contains("b")}()
5236)) {
5237
5238// Element.prototype.classList
5239/*
5240Copyright (c) 2016, John Gardner
5241
5242Permission 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.
5243
5244THE 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.
5245*/
5246(function (global) {
5247 var dpSupport = true;
5248 var defineGetter = function (object, name, fn, configurable) {
5249 if (Object.defineProperty)
5250 Object.defineProperty(object, name, {
5251 configurable: false === dpSupport ? true : !!configurable,
5252 get: fn
5253 });
5254
5255 else object.__defineGetter__(name, fn);
5256 };
5257 /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
5258 try {
5259 defineGetter({}, "support");
5260 }
5261 catch (e) {
5262 dpSupport = false;
5263 }
5264 /** Polyfills a property with a DOMTokenList */
5265 var addProp = function (o, name, attr) {
5266
5267 defineGetter(o.prototype, name, function () {
5268 var tokenList;
5269
5270 var THIS = this,
5271
5272 /** Prevent this from firing twice for some reason. What the hell, IE. */
5273 gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
5274 if(THIS[gibberishProperty]) return tokenList;
5275 THIS[gibberishProperty] = true;
5276
5277 /**
5278 * IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
5279 *
5280 * What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
5281 * that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
5282 * element instead, this would conflict with element types which use indexed properties (such as forms and
5283 * select lists).
5284 */
5285 if (false === dpSupport) {
5286
5287 var visage;
5288 var mirror = addProp.mirror || document.createElement("div");
5289 var reflections = mirror.childNodes;
5290 var l = reflections.length;
5291
5292 for (var i = 0; i < l; ++i)
5293 if (reflections[i]._R === THIS) {
5294 visage = reflections[i];
5295 break;
5296 }
5297
5298 /** Couldn't find an element's reflection inside the mirror. Materialise one. */
5299 visage || (visage = mirror.appendChild(document.createElement("div")));
5300
5301 tokenList = DOMTokenList.call(visage, THIS, attr);
5302 } else tokenList = new _DOMTokenList(THIS, attr);
5303
5304 defineGetter(THIS, name, function () {
5305 return tokenList;
5306 });
5307 delete THIS[gibberishProperty];
5308
5309 return tokenList;
5310 }, true);
5311 };
5312
5313 addProp(global.Element, "classList", "className");
5314 addProp(global.HTMLElement, "classList", "className");
5315 addProp(global.HTMLLinkElement, "relList", "rel");
5316 addProp(global.HTMLAnchorElement, "relList", "rel");
5317 addProp(global.HTMLAreaElement, "relList", "rel");
5318}(this));
5319
5320}
5321
5322if (!("name"in Function.prototype&&"x"===function n(){}.name
5323)) {
5324
5325// Function.prototype.name
5326(function () {
5327
5328 var
5329 accessorName = 'name',
5330 fnNameMatchRegex = /^\s*function\s+([^\(\s]*)\s*/,
5331 $Function = Function,
5332 FunctionName = 'Function',
5333 FunctionProto = $Function.prototype,
5334 FunctionProtoCtor = FunctionProto.constructor,
5335
5336 getFunctionName = function(fn) {
5337 var match, name;
5338
5339 if (fn === $Function || fn === FunctionProtoCtor) {
5340 name = FunctionName;
5341 }
5342 else if (fn !== FunctionProto) {
5343 match = ('' + fn).match(fnNameMatchRegex);
5344 name = match && match[1];
5345 }
5346 return name || '';
5347 };
5348
5349
5350 Object.defineProperty(FunctionProto, accessorName, {
5351 get: function Function$name() {
5352 var
5353 fn = this,
5354 fnName = getFunctionName(fn);
5355
5356 // Since named function definitions have immutable names, also memoize the
5357 // output by defining the `name` property directly on this Function
5358 // instance so the accessor function will not need to be invoked again.
5359 if (fn !== FunctionProto) {
5360 Object.defineProperty(fn, accessorName, {
5361 value: fnName,
5362 configurable: true
5363 });
5364 }
5365
5366 return fnName;
5367 },
5368 configurable: true
5369 });
5370
5371}());
5372
5373}
5374
5375if (!("EPSILON"in Number
5376)) {
5377
5378// Number.Epsilon
5379// 20.1.2.1. Number.EPSILON
5380// The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 that is representable as a Number value, which is approximately 2.2204460492503130808472633361816 x 10-16.
5381// This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
5382Object.defineProperty(Number, 'EPSILON', {
5383 enumerable: false,
5384 configurable: false,
5385 writable: false,
5386 value: Math.pow(2, -52)
5387});
5388
5389}
5390
5391if (!("MAX_SAFE_INTEGER"in Number
5392)) {
5393
5394// Number.MAX_SAFE_INTEGER
5395// 20.1.2.6. Number.MAX_SAFE_INTEGER
5396// The value of Number.MAX_SAFE_INTEGER is 9007199254740991 (2^53-1).
5397// This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
5398Object.defineProperty(Number, 'MAX_SAFE_INTEGER', {
5399 enumerable: false,
5400 configurable: false,
5401 writable: false,
5402 value: Math.pow(2, 53) - 1
5403});
5404
5405}
5406
5407if (!("MIN_SAFE_INTEGER"in Number
5408)) {
5409
5410// Number.MIN_SAFE_INTEGER
5411// 20.1.2.8. Number.MIN_SAFE_INTEGER
5412// The value of Number.MIN_SAFE_INTEGER is -9007199254740991 (-(253-1)).
5413// This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
5414Object.defineProperty(Number, 'MIN_SAFE_INTEGER', {
5415 enumerable: false,
5416 configurable: false,
5417 writable: false,
5418 value: -(Math.pow(2, 53) - 1)
5419});
5420
5421}
5422
5423if (!("freeze"in Object
5424)) {
5425
5426// Object.freeze
5427/* global CreateMethodProperty */
5428// 19.1.2.6. Object.freeze ( O )
5429CreateMethodProperty(Object, 'freeze', function freeze(O) {
5430 // This feature cannot be implemented fully as a polyfill.
5431 // We choose to silently fail which allows "securable" code
5432 // to "gracefully" degrade to working but insecure code.
5433 return O;
5434});
5435
5436}
5437
5438if (!("getOwnPropertyDescriptor"in Object&&"function"==typeof Object.getOwnPropertyDescriptor&&function(){try{var t={}
5439return t.test=0,0===Object.getOwnPropertyDescriptor(t,"test").value}catch(e){return!1}}()
5440)) {
5441
5442// Object.getOwnPropertyDescriptor
5443/* global CreateMethodProperty */
5444(function () {
5445 var call = Function.prototype.call;
5446 var prototypeOfObject = Object.prototype;
5447 var owns = call.bind(prototypeOfObject.hasOwnProperty);
5448
5449 var lookupGetter;
5450 var lookupSetter;
5451 var supportsAccessors;
5452 if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
5453 lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
5454 lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
5455 }
5456 function doesGetOwnPropertyDescriptorWork(object) {
5457 try {
5458 object.sentinel = 0;
5459 return Object.getOwnPropertyDescriptor(
5460 object,
5461 "sentinel"
5462 ).value === 0;
5463 } catch (exception) {
5464 // returns falsy
5465 }
5466 }
5467 // check whether getOwnPropertyDescriptor works if it's given. Otherwise,
5468 // shim partially.
5469 if (Object.defineProperty) {
5470 var getOwnPropertyDescriptorWorksOnObject =
5471 doesGetOwnPropertyDescriptorWork({});
5472 var getOwnPropertyDescriptorWorksOnDom = typeof document == "undefined" ||
5473 doesGetOwnPropertyDescriptorWork(document.createElement("div"));
5474 if (!getOwnPropertyDescriptorWorksOnDom ||
5475 !getOwnPropertyDescriptorWorksOnObject
5476 ) {
5477 var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
5478 }
5479 }
5480
5481 if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
5482 var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
5483
5484 CreateMethodProperty(Object, 'getOwnPropertyDescriptor', function getOwnPropertyDescriptor(object, property) {
5485 if ((typeof object != "object" && typeof object != "function") || object === null) {
5486 throw new TypeError(ERR_NON_OBJECT + object);
5487 }
5488
5489 // make a valiant attempt to use the real getOwnPropertyDescriptor
5490 // for I8's DOM elements.
5491 if (getOwnPropertyDescriptorFallback) {
5492 try {
5493 return getOwnPropertyDescriptorFallback.call(Object, object, property);
5494 } catch (exception) {
5495 // try the shim if the real one doesn't work
5496 }
5497 }
5498
5499 // If object does not owns property return undefined immediately.
5500 if (!owns(object, property)) {
5501 return;
5502 }
5503
5504 // If object has a property then it's for sure both `enumerable` and
5505 // `configurable`.
5506 var descriptor = { enumerable: true, configurable: true };
5507
5508 // If JS engine supports accessor properties then property may be a
5509 // getter or setter.
5510 if (supportsAccessors) {
5511 // Unfortunately `__lookupGetter__` will return a getter even
5512 // if object has own non getter property along with a same named
5513 // inherited getter. To avoid misbehavior we temporary remove
5514 // `__proto__` so that `__lookupGetter__` will return getter only
5515 // if it's owned by an object.
5516 var prototype = object.__proto__;
5517 object.__proto__ = prototypeOfObject;
5518
5519 var getter = lookupGetter(object, property);
5520 var setter = lookupSetter(object, property);
5521
5522 // Once we have getter and setter we can put values back.
5523 object.__proto__ = prototype;
5524
5525 if (getter || setter) {
5526 if (getter) {
5527 descriptor.get = getter;
5528 }
5529 if (setter) {
5530 descriptor.set = setter;
5531 }
5532 // If it was accessor property we're done and return here
5533 // in order to avoid adding `value` to the descriptor.
5534 return descriptor;
5535 }
5536 }
5537
5538 // If we got this far we know that object has an own property that is
5539 // not an accessor so we set it as a value and return descriptor.
5540 descriptor.value = object[property];
5541 descriptor.writable = true;
5542 return descriptor;
5543 });
5544 }
5545}());
5546
5547}
5548
5549if (!("getOwnPropertyNames"in Object
5550)) {
5551
5552// Object.getOwnPropertyNames
5553/* global CreateMethodProperty */
5554
5555var toString = ({}).toString;
5556var split = ''.split;
5557
5558CreateMethodProperty(Object, 'getOwnPropertyNames', function getOwnPropertyNames(object) {
5559 var buffer = [];
5560 var key;
5561
5562 // Non-enumerable properties cannot be discovered but can be checked for by name.
5563 // Define those used internally by JS to allow an incomplete solution
5564 var commonProps = ['length', "name", "arguments", "caller", "prototype", "observe", "unobserve"];
5565
5566 if (typeof object === 'undefined' || object === null) {
5567 throw new TypeError('Cannot convert undefined or null to object');
5568 }
5569
5570 // Polyfill.io fallback for non-array-like strings which exist in some ES3 user-agents (IE 8)
5571 object = toString.call(object) == '[object String]' ? split.call(object, '') : Object(object);
5572
5573 // Enumerable properties only
5574 for (key in object) {
5575 if (Object.prototype.hasOwnProperty.call(object, key)) {
5576 buffer.push(key);
5577 }
5578 }
5579
5580 // Check for and add the common non-enumerable properties
5581 for (var i=0, s=commonProps.length; i<s; i++) {
5582 if (commonProps[i] in object) buffer.push(commonProps[i]);
5583 }
5584
5585 return buffer;
5586});
5587
5588}
5589
5590if (!("getPrototypeOf"in Object
5591)) {
5592
5593// Object.getPrototypeOf
5594/* global CreateMethodProperty */
5595// Based on: https://github.com/es-shims/es5-shim/blob/master/es5-sham.js
5596
5597// https://github.com/es-shims/es5-shim/issues#issue/2
5598// http://ejohn.org/blog/objectgetprototypeof/
5599// recommended by fschaefer on github
5600//
5601// sure, and webreflection says ^_^
5602// ... this will nerever possibly return null
5603// ... Opera Mini breaks here with infinite loops
5604CreateMethodProperty(Object, 'getPrototypeOf', function getPrototypeOf(object) {
5605 if (object !== Object(object)) {
5606 throw new TypeError('Object.getPrototypeOf called on non-object');
5607 }
5608 var proto = object.__proto__;
5609 if (proto || proto === null) {
5610 return proto;
5611 } else if (typeof object.constructor == 'function' && object instanceof object.constructor) {
5612 return object.constructor.prototype;
5613 } else if (object instanceof Object) {
5614 return Object.prototype;
5615 } else {
5616 // Correctly return null for Objects created with `Object.create(null)`
5617 // (shammed or native) or `{ __proto__: null}`. Also returns null for
5618 // cross-realm objects on browsers that lack `__proto__` support (like
5619 // IE <11), but that's the best we can do.
5620 return null;
5621 }
5622});
5623
5624}
5625
5626if (!("is"in Object
5627)) {
5628
5629// Object.is
5630/* global CreateMethodProperty, SameValue */
5631// 19.1.2.12. Object.is ( value1, value2 )
5632CreateMethodProperty(Object, 'is', function is(value1, value2) {
5633 // 1. Return SameValue(value1, value2).
5634 return SameValue(value1, value2);
5635});
5636
5637}
5638
5639if (!("keys"in Object&&function(){return 2===Object.keys(arguments).length}(1,2)&&function(){try{return Object.keys(""),!0}catch(t){return!1}}()
5640)) {
5641
5642// Object.keys
5643/* global CreateMethodProperty */
5644CreateMethodProperty(Object, "keys", (function() {
5645 'use strict';
5646
5647 // modified from https://github.com/es-shims/object-keys
5648
5649 var has = Object.prototype.hasOwnProperty;
5650 var toStr = Object.prototype.toString;
5651 var isEnumerable = Object.prototype.propertyIsEnumerable;
5652 var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
5653 var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
5654 var dontEnums = [
5655 'toString',
5656 'toLocaleString',
5657 'valueOf',
5658 'hasOwnProperty',
5659 'isPrototypeOf',
5660 'propertyIsEnumerable',
5661 'constructor'
5662 ];
5663 var equalsConstructorPrototype = function (o) {
5664 var ctor = o.constructor;
5665 return ctor && ctor.prototype === o;
5666 };
5667 var excludedKeys = {
5668 $console: true,
5669 $external: true,
5670 $frame: true,
5671 $frameElement: true,
5672 $frames: true,
5673 $innerHeight: true,
5674 $innerWidth: true,
5675 $outerHeight: true,
5676 $outerWidth: true,
5677 $pageXOffset: true,
5678 $pageYOffset: true,
5679 $parent: true,
5680 $scrollLeft: true,
5681 $scrollTop: true,
5682 $scrollX: true,
5683 $scrollY: true,
5684 $self: true,
5685 $webkitIndexedDB: true,
5686 $webkitStorageInfo: true,
5687 $window: true
5688 };
5689 var hasAutomationEqualityBug = (function () {
5690 /* global window */
5691 if (typeof window === 'undefined') { return false; }
5692 for (var k in window) {
5693 try {
5694 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
5695 try {
5696 equalsConstructorPrototype(window[k]);
5697 } catch (e) {
5698 return true;
5699 }
5700 }
5701 } catch (e) {
5702 return true;
5703 }
5704 }
5705 return false;
5706 }());
5707 var equalsConstructorPrototypeIfNotBuggy = function (o) {
5708 /* global window */
5709 if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
5710 return equalsConstructorPrototype(o);
5711 }
5712 try {
5713 return equalsConstructorPrototype(o);
5714 } catch (e) {
5715 return false;
5716 }
5717 };
5718
5719 function isArgumentsObject(value) {
5720 var str = toStr.call(value);
5721 var isArgs = str === '[object Arguments]';
5722 if (!isArgs) {
5723 isArgs = str !== '[object Array]' &&
5724 value !== null &&
5725 typeof value === 'object' &&
5726 typeof value.length === 'number' &&
5727 value.length >= 0 &&
5728 toStr.call(value.callee) === '[object Function]';
5729 }
5730 return isArgs;
5731 }
5732
5733 return function keys(object) {
5734 var isFunction = toStr.call(object) === '[object Function]';
5735 var isArguments = isArgumentsObject(object);
5736 var isString = toStr.call(object) === '[object String]';
5737 var theKeys = [];
5738
5739 if (object === undefined || object === null) {
5740 throw new TypeError('Cannot convert undefined or null to object');
5741 }
5742
5743 var skipProto = hasProtoEnumBug && isFunction;
5744 if (isString && object.length > 0 && !has.call(object, 0)) {
5745 for (var i = 0; i < object.length; ++i) {
5746 theKeys.push(String(i));
5747 }
5748 }
5749
5750 if (isArguments && object.length > 0) {
5751 for (var j = 0; j < object.length; ++j) {
5752 theKeys.push(String(j));
5753 }
5754 } else {
5755 for (var name in object) {
5756 if (!(skipProto && name === 'prototype') && has.call(object, name)) {
5757 theKeys.push(String(name));
5758 }
5759 }
5760 }
5761
5762 if (hasDontEnumBug) {
5763 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
5764
5765 for (var k = 0; k < dontEnums.length; ++k) {
5766 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
5767 theKeys.push(dontEnums[k]);
5768 }
5769 }
5770 }
5771 return theKeys;
5772 };
5773}()));
5774
5775}
5776
5777
5778// _ESAbstract.EnumerableOwnProperties
5779/* globals Type, Get */
5780// 7.3.21. EnumerableOwnProperties ( O, kind )
5781function EnumerableOwnProperties(O, kind) { // eslint-disable-line no-unused-vars
5782 // 1. Assert: Type(O) is Object.
5783 // 2. Let ownKeys be ? O.[[OwnPropertyKeys]]().
5784 var ownKeys = Object.keys(O);
5785 // 3. Let properties be a new empty List.
5786 var properties = [];
5787 // 4. For each element key of ownKeys in List order, do
5788 var length = ownKeys.length;
5789 for (var i = 0; i < length; i++) {
5790 var key = ownKeys[i];
5791 // a. If Type(key) is String, then
5792 if (Type(key) === 'string') {
5793 // i. Let desc be ? O.[[GetOwnProperty]](key).
5794 var desc = Object.getOwnPropertyDescriptor(O, key);
5795 // ii. If desc is not undefined and desc.[[Enumerable]] is true, then
5796 if (desc && desc.enumerable) {
5797 // 1. If kind is "key", append key to properties.
5798 if (kind === 'key') {
5799 properties.push(key);
5800 // 2. Else,
5801 } else {
5802 // a. Let value be ? Get(O, key).
5803 var value = Get(O, key);
5804 // b. If kind is "value", append value to properties.
5805 if (kind === 'value') {
5806 properties.push(value);
5807 // c. Else,
5808 } else {
5809 // i. Assert: kind is "key+value".
5810 // ii. Let entry be CreateArrayFromList(« key, value »).
5811 var entry = [key, value];
5812 // iii. Append entry to properties.
5813 properties.push(entry);
5814 }
5815 }
5816 }
5817 }
5818 }
5819 // 5. Order the elements of properties so they are in the same relative order as would be produced by the Iterator that would be returned if the EnumerateObjectProperties internal method were invoked with O.
5820 // 6. Return properties.
5821 return properties;
5822}
5823if (!("entries"in Object
5824)) {
5825
5826// Object.entries
5827/* global CreateMethodProperty, EnumerableOwnProperties, ToObject */
5828
5829(function () {
5830 var toString = ({}).toString;
5831 var split = ''.split;
5832
5833 // 19.1.2.5. Object.entries ( O )
5834 CreateMethodProperty(Object, 'entries', function entries(O) {
5835 // 1. Let obj be ? ToObject(O).
5836 var obj = ToObject(O);
5837 // Polyfill.io fallback for non-array-like strings which exist in some ES3 user-agents (IE 8)
5838 var obj = toString.call(O) == '[object String]' ? split.call(O, '') : Object(O);
5839 // 2. Let nameList be ? EnumerableOwnProperties(obj, "key+value").
5840 var nameList = EnumerableOwnProperties(obj, "key+value");
5841 // 3. Return CreateArrayFromList(nameList).
5842 // Polyfill.io - nameList is already an array.
5843 return nameList;
5844 });
5845}());
5846}
5847
5848if (!("assign"in Object
5849)) {
5850
5851// Object.assign
5852/* global CreateMethodProperty, Get, ToObject */
5853// 19.1.2.1 Object.assign ( target, ...sources )
5854CreateMethodProperty(Object, 'assign', function assign(target, source) { // eslint-disable-line no-unused-vars
5855 // 1. Let to be ? ToObject(target).
5856 var to = ToObject(target);
5857
5858 // 2. If only one argument was passed, return to.
5859 if (arguments.length === 1) {
5860 return to;
5861 }
5862
5863 // 3. Let sources be the List of argument values starting with the second argument
5864 var sources = Array.prototype.slice.call(arguments, 1);
5865
5866 // 4. For each element nextSource of sources, in ascending index order, do
5867 var index1;
5868 var index2;
5869 var keys;
5870 var from;
5871 for (index1 = 0; index1 < sources.length; index1++) {
5872 var nextSource = sources[index1];
5873 // a. If nextSource is undefined or null, let keys be a new empty List.
5874 if (nextSource === undefined || nextSource === null) {
5875 keys = [];
5876 // b. Else,
5877 } else {
5878 // i. Let from be ! ToObject(nextSource).
5879 from = ToObject(nextSource);
5880 // ii. Let keys be ? from.[[OwnPropertyKeys]]().
5881 /*
5882 This step in our polyfill is not complying with the specification.
5883 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
5884 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
5885 */
5886 keys = Object.keys(from);
5887 }
5888
5889 // c. For each element nextKey of keys in List order, do
5890 for (index2 = 0; index2 < keys.length; index2++) {
5891 var nextKey = keys[index2];
5892 var enumerable;
5893 try {
5894 // i. Let desc be ? from.[[GetOwnProperty]](nextKey).
5895 var desc = Object.getOwnPropertyDescriptor(from, nextKey);
5896 // ii. If desc is not undefined and desc.[[Enumerable]] is true, then
5897 enumerable = desc !== undefined && desc.enumerable === true;
5898 } catch (e) {
5899 // Polyfill.io - We use Object.prototype.propertyIsEnumerable as a fallback
5900 // because `Object.getOwnPropertyDescriptor(window.location, 'hash')` causes Internet Explorer 11 to crash.
5901 enumerable = Object.prototype.propertyIsEnumerable.call(from, nextKey);
5902 }
5903 if (enumerable) {
5904 // 1. Let propValue be ? Get(from, nextKey).
5905 var propValue = Get(from, nextKey);
5906 // 2. Perform ? Set(to, nextKey, propValue, true).
5907 to[nextKey] = propValue;
5908 }
5909 }
5910 }
5911 // 5. Return to.
5912 return to;
5913});
5914
5915}
5916
5917if (!("defineProperties"in Object
5918)) {
5919
5920// Object.defineProperties
5921/* global CreateMethodProperty, Get, ToObject, Type */
5922// 19.1.2.3. Object.defineProperties ( O, Properties )
5923CreateMethodProperty(Object, 'defineProperties', function defineProperties(O, Properties) {
5924 // 1. If Type(O) is not Object, throw a TypeError exception.
5925 if (Type(O) !== 'object') {
5926 throw new TypeError('Object.defineProperties called on non-object');
5927 }
5928 // 2. Let props be ? ToObject(Properties).
5929 var props = ToObject(Properties);
5930 // 3. Let keys be ? props.[[OwnPropertyKeys]]().
5931 /*
5932 Polyfill.io - This step in our polyfill is not complying with the specification.
5933 [[OwnPropertyKeys]] is meant to return ALL keys, including non-enumerable and symbols.
5934 TODO: When we have Reflect.ownKeys, use that instead as it is the userland equivalent of [[OwnPropertyKeys]].
5935 */
5936 var keys = Object.keys(props);
5937 // 4. Let descriptors be a new empty List.
5938 var descriptors = [];
5939 // 5. For each element nextKey of keys in List order, do
5940 for (var i = 0; i < keys.length; i++) {
5941 var nextKey = keys[i];
5942 // a. Let propDesc be ? props.[[GetOwnProperty]](nextKey).
5943 var propDesc = Object.getOwnPropertyDescriptor(props, nextKey);
5944 // b. If propDesc is not undefined and propDesc.[[Enumerable]] is true, then
5945 if (propDesc !== undefined && propDesc.enumerable) {
5946 // i. Let descObj be ? Get(props, nextKey).
5947 var descObj = Get(props, nextKey);
5948 // ii. Let desc be ? ToPropertyDescriptor(descObj).
5949 // Polyfill.io - We skip this step because Object.defineProperty deals with it.
5950 // TODO: Implement this step?
5951 var desc = descObj;
5952 // iii. Append the pair (a two element List) consisting of nextKey and desc to the end of descriptors.
5953 descriptors.push([nextKey, desc]);
5954 }
5955 }
5956 // 6. For each pair from descriptors in list order, do
5957 for (var i = 0; i < descriptors.length; i++){
5958 // a. Let P be the first element of pair.
5959 var P = descriptors[i][0];
5960 // b. Let desc be the second element of pair.
5961 var desc = descriptors[i][1];
5962 // c. Perform ? DefinePropertyOrThrow(O, P, desc).
5963 Object.defineProperty(O, P, desc);
5964 }
5965 // 7. Return O.
5966 return O;
5967});
5968
5969}
5970
5971if (!("location"in this&&"origin"in this.location
5972)) {
5973
5974// location.origin
5975try {
5976 Object.defineProperty(window.location, 'origin', {
5977 enumerable: true,
5978 writable: false,
5979 value: window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''),
5980 configurable: false
5981 });
5982} catch(e) {
5983
5984 // IE9 is throwing "Object doesn't support this action" when attempting defineProperty on window.location, so provide an alternative
5985 window.location.origin = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
5986}
5987
5988}
5989
5990if (!("create"in Object
5991)) {
5992
5993// Object.create
5994/* global CreateMethodProperty, Type */
5995CreateMethodProperty(Object, 'create', function create(O, properties) {
5996 // 1. If Type(O) is neither Object nor Null, throw a TypeError exception.
5997 if (Type(O) !== 'object' && Type(O) !== 'null') {
5998 throw new TypeError('Object prototype may only be an Object or null');
5999 }
6000 // 2. Let obj be ObjectCreate(O).
6001 var obj = new Function('e', 'function Object() {}Object.prototype=e;return new Object')(O);
6002
6003 obj.constructor.prototype = O;
6004
6005 // 3. If Properties is not undefined, then
6006 if (1 in arguments) {
6007 // a. Return ? ObjectDefineProperties(obj, Properties).
6008 return Object.defineProperties(obj, properties);
6009 }
6010
6011 return obj;
6012});
6013
6014}
6015
6016
6017// _ESAbstract.OrdinaryCreateFromConstructor
6018/* global GetPrototypeFromConstructor */
6019// 9.1.13. OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
6020function OrdinaryCreateFromConstructor(constructor, intrinsicDefaultProto) { // eslint-disable-line no-unused-vars
6021 var internalSlotsList = arguments[2] || {};
6022 // 1. Assert: intrinsicDefaultProto is a String value that is this specification's name of an intrinsic object.
6023 // The corresponding object must be an intrinsic that is intended to be used as the[[Prototype]] value of an object.
6024
6025 // 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto).
6026 var proto = GetPrototypeFromConstructor(constructor, intrinsicDefaultProto);
6027
6028 // 3. Return ObjectCreate(proto, internalSlotsList).
6029 // 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.
6030 var obj = Object.create(proto);
6031 for (var name in internalSlotsList) {
6032 if (Object.prototype.hasOwnProperty.call(internalSlotsList, name)) {
6033 Object.defineProperty(obj, name, {
6034 configurable: true,
6035 enumerable: false,
6036 writable: true,
6037 value: internalSlotsList[name]
6038 });
6039 }
6040 }
6041 return obj;
6042}
6043
6044// _ESAbstract.Construct
6045/* global IsConstructor, OrdinaryCreateFromConstructor, Call */
6046// 7.3.13. Construct ( F [ , argumentsList [ , newTarget ]] )
6047function Construct(F /* [ , argumentsList [ , newTarget ]] */) { // eslint-disable-line no-unused-vars
6048 // 1. If newTarget is not present, set newTarget to F.
6049 var newTarget = arguments.length > 2 ? arguments[2] : F;
6050
6051 // 2. If argumentsList is not present, set argumentsList to a new empty List.
6052 var argumentsList = arguments.length > 1 ? arguments[1] : [];
6053
6054 // 3. Assert: IsConstructor(F) is true.
6055 if (!IsConstructor(F)) {
6056 throw new TypeError('F must be a constructor.');
6057 }
6058
6059 // 4. Assert: IsConstructor(newTarget) is true.
6060 if (!IsConstructor(newTarget)) {
6061 throw new TypeError('newTarget must be a constructor.');
6062 }
6063
6064 // 5. Return ? F.[[Construct]](argumentsList, newTarget).
6065 // Polyfill.io - If newTarget is the same as F, it is equivalent to new F(...argumentsList).
6066 if (newTarget === F) {
6067 return new (Function.prototype.bind.apply(F, [null].concat(argumentsList)))();
6068 } else {
6069 // Polyfill.io - This is mimicking section 9.2.2 step 5.a.
6070 var obj = OrdinaryCreateFromConstructor(newTarget, Object.prototype);
6071 return Call(F, obj, argumentsList);
6072 }
6073}
6074
6075// _ESAbstract.ArraySpeciesCreate
6076/* global IsArray, ArrayCreate, Get, Type, IsConstructor, Construct */
6077// 9.4.2.3. ArraySpeciesCreate ( originalArray, length )
6078function ArraySpeciesCreate(originalArray, length) { // eslint-disable-line no-unused-vars
6079 // 1. Assert: length is an integer Number ≥ 0.
6080 // 2. If length is -0, set length to +0.
6081 if (1/length === -Infinity) {
6082 length = 0;
6083 }
6084
6085 // 3. Let isArray be ? IsArray(originalArray).
6086 var isArray = IsArray(originalArray);
6087
6088 // 4. If isArray is false, return ? ArrayCreate(length).
6089 if (isArray === false) {
6090 return ArrayCreate(length);
6091 }
6092
6093 // 5. Let C be ? Get(originalArray, "constructor").
6094 var C = Get(originalArray, 'constructor');
6095
6096 // Polyfill.io - We skip this section as not sure how to make a cross-realm normal Array, a same-realm Array.
6097 // 6. If IsConstructor(C) is true, then
6098 // if (IsConstructor(C)) {
6099 // a. Let thisRealm be the current Realm Record.
6100 // b. Let realmC be ? GetFunctionRealm(C).
6101 // c. If thisRealm and realmC are not the same Realm Record, then
6102 // i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, set C to undefined.
6103 // }
6104 // 7. If Type(C) is Object, then
6105 if (Type(C) === 'object') {
6106 // a. Set C to ? Get(C, @@species).
6107 C = 'Symbol' in this && 'species' in this.Symbol ? Get(C, this.Symbol.species) : undefined;
6108 // b. If C is null, set C to undefined.
6109 if (C === null) {
6110 C = undefined;
6111 }
6112 }
6113 // 8. If C is undefined, return ? ArrayCreate(length).
6114 if (C === undefined) {
6115 return ArrayCreate(length);
6116 }
6117 // 9. If IsConstructor(C) is false, throw a TypeError exception.
6118 if (!IsConstructor(C)) {
6119 throw new TypeError('C must be a constructor');
6120 }
6121 // 10. Return ? Construct(C, « length »).
6122 return Construct(C, [length]);
6123}
6124if (!("filter"in Array.prototype
6125)) {
6126
6127// Array.prototype.filter
6128/* global CreateMethodProperty, ToObject, ToLength, Get, IsCallable, ArraySpeciesCreate, ToString, HasProperty, ToBoolean, Call, CreateDataPropertyOrThrow */
6129// 22.1.3.7. Array.prototype.filter ( callbackfn [ , thisArg ] )
6130CreateMethodProperty(Array.prototype, 'filter', function filter(callbackfn /* [ , thisArg ] */) {
6131 // 1. Let O be ? ToObject(this value).
6132 var O = ToObject(this);
6133 // 2. Let len be ? ToLength(? Get(O, "length")).
6134 var len = ToLength(Get(O, "length"));
6135 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
6136 if (IsCallable(callbackfn) === false) {
6137 throw new TypeError(callbackfn + ' is not a function');
6138 }
6139 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
6140 var T = arguments.length > 1 ? arguments[1] : undefined;
6141 // 5. Let A be ? ArraySpeciesCreate(O, 0).
6142 var A = ArraySpeciesCreate(O, 0);
6143 // 6. Let k be 0.
6144 var k = 0;
6145 // 7. Let to be 0.
6146 var to = 0;
6147 // 8. Repeat, while k < len
6148 while (k < len) {
6149 // a. Let Pk be ! ToString(k).
6150 var Pk = ToString(k);
6151 // b. Let kPresent be ? HasProperty(O, Pk).
6152 var kPresent = HasProperty(O, Pk);
6153 // c. If kPresent is true, then
6154 if (kPresent) {
6155 // i. Let kValue be ? Get(O, Pk).
6156 var kValue = Get(O, Pk);
6157 // ii. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
6158 var selected = ToBoolean(Call(callbackfn, T, [kValue, k, O]));
6159 // iii. If selected is true, then
6160 if (selected) {
6161 // 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue)
6162 CreateDataPropertyOrThrow(A, ToString(to), kValue);
6163 // 2. Increase to by 1.
6164 to = to + 1;
6165 }
6166
6167 }
6168 // d. Increase k by 1.
6169 k = k + 1;
6170 }
6171 // 9. Return A.
6172 return A;
6173});
6174
6175}
6176
6177if (!("map"in Array.prototype
6178)) {
6179
6180// Array.prototype.map
6181/* global ArraySpeciesCreate, Call, CreateDataPropertyOrThrow, CreateMethodProperty, Get, HasProperty, IsCallable, ToLength, ToObject, ToString */
6182/* global CreateMethodProperty, ToObject, ToLength, Get, ArraySpeciesCreate, ToString, HasProperty, Call, CreateDataPropertyOrThrow */
6183// 22.1.3.16. Array.prototype.map ( callbackfn [ , thisArg ] )
6184CreateMethodProperty(Array.prototype, 'map', function map(callbackfn /* [ , thisArg ] */) {
6185 // 1. Let O be ? ToObject(this value).
6186 var O = ToObject(this);
6187 // 2. Let len be ? ToLength(? Get(O, "length")).
6188 var len = ToLength(Get(O, "length"));
6189 // 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
6190 if (IsCallable(callbackfn) === false) {
6191 throw new TypeError(callbackfn + ' is not a function');
6192 }
6193 // 4. If thisArg is present, let T be thisArg; else let T be undefined.
6194 var T = arguments.length > 1 ? arguments[1] : undefined;
6195 // 5. Let A be ? ArraySpeciesCreate(O, len).
6196 var A = ArraySpeciesCreate(O, len);
6197 // 6. Let k be 0.
6198 var k = 0;
6199 // 7. Repeat, while k < len
6200 while (k < len) {
6201 // a. Let Pk be ! ToString(k).
6202 var Pk = ToString(k);
6203 // b. Let kPresent be ? HasProperty(O, Pk).
6204 var kPresent = HasProperty(O, Pk);
6205 // c. If kPresent is true, then
6206 if (kPresent) {
6207 // i. Let kValue be ? Get(O, Pk).
6208 var kValue = Get(O, Pk);
6209 // ii. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
6210 var mappedValue = Call(callbackfn, T, [kValue, k, O]);
6211 // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
6212 CreateDataPropertyOrThrow(A, Pk, mappedValue);
6213 }
6214 // d. Increase k by 1.
6215 k = k + 1;
6216 }
6217 // 8. Return A.
6218 return A;
6219});
6220
6221}
6222
6223if (!("of"in Array
6224)) {
6225
6226// Array.of
6227/* global ArrayCreate, Construct, CreateDataPropertyOrThrow, CreateMethodProperty, IsConstructor, ToString */
6228// 22.1.2.3. Array.of ( ...items )
6229CreateMethodProperty(Array, 'of', function of() {
6230 // 1. Let len be the actual number of arguments passed to this function.
6231 var len = arguments.length;
6232 // 2. Let items be the List of arguments passed to this function.
6233 var items = arguments;
6234 // 3. Let C be the this value.
6235 var C = this;
6236 // 4. If IsConstructor(C) is true, then
6237 if (IsConstructor(C)) {
6238 // a. Let A be ? Construct(C, « len »).
6239 var A = Construct(C, [len]);
6240 // 5. Else,
6241 } else {
6242 // a. Let A be ? ArrayCreate(len).
6243 var A = ArrayCreate(len);
6244 }
6245 // 6. Let k be 0.
6246 var k = 0;
6247 // 7. Repeat, while k < len
6248 while (k < len) {
6249 // a. Let kValue be items[k].
6250 var kValue = items[k];
6251 // b. Let Pk be ! ToString(k).
6252 var Pk = ToString(k);
6253 // c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue).
6254 CreateDataPropertyOrThrow(A, Pk, kValue);
6255 // d. Increase k by 1.
6256 var k = k + 1;
6257
6258 }
6259 // 8. Perform ? Set(A, "length", len, true)
6260 A["length"] = len;
6261 // 9. Return A.
6262 return A;
6263});
6264
6265}
6266
6267if (!("seal"in Object&&function(){try{return Object.seal("1"),!0}catch(t){return!1}}
6268)) {
6269
6270// Object.seal
6271/* global CreateMethodProperty, Type */
6272// 19.1.2.19 Object.seal ( O )
6273(function(originalObjectSeal) {
6274 CreateMethodProperty(Object, 'seal', function seal(O) {
6275 // 1. If Type(O) is not Object, return O.
6276 if (Type(O) === 'object') {
6277 return O;
6278 }
6279 // 2. Let status be ? SetIntegrityLevel(O, "sealed").
6280 // 3. If status is false, throw a TypeError exception.
6281 // 4. Return O.
6282 return originalObjectSeal ? originalObjectSeal(O) : O;
6283 });
6284}(Object.seal));
6285
6286
6287}
6288
6289
6290// Object.setPrototypeOf
6291/* global CreateMethodProperty */
6292// ES6-shim 0.16.0 (c) 2013-2014 Paul Miller (http://paulmillr.com)
6293// ES6-shim may be freely distributed under the MIT license.
6294// For more details and documentation:
6295// https://github.com/paulmillr/es6-shim/
6296
6297 // NOTE: This versions needs object ownership
6298 // because every promoted object needs to be reassigned
6299 // otherwise uncompatible browsers cannot work as expected
6300 //
6301 // NOTE: This might need es5-shim or polyfills upfront
6302 // because it's based on ES5 API.
6303 // (probably just an IE <= 8 problem)
6304 //
6305 // NOTE: nodejs is fine in version 0.8, 0.10, and future versions.
6306(function () {
6307 if (Object.setPrototypeOf) { return; }
6308
6309 /*jshint proto: true */
6310 // @author Andrea Giammarchi - @WebReflection
6311
6312 var getOwnPropertyNames = Object.getOwnPropertyNames;
6313 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
6314 var create = Object.create;
6315 var defineProperty = Object.defineProperty;
6316 var getPrototypeOf = Object.getPrototypeOf;
6317 var objProto = Object.prototype;
6318
6319 var copyDescriptors = function (target, source) {
6320 // define into target descriptors from source
6321 getOwnPropertyNames(source).forEach(function (key) {
6322 defineProperty(
6323 target,
6324 key,
6325 getOwnPropertyDescriptor(source, key)
6326 );
6327 });
6328 return target;
6329 };
6330 // used as fallback when no promotion is possible
6331 var createAndCopy = function setPrototypeOf(origin, proto) {
6332 return copyDescriptors(create(proto), origin);
6333 };
6334 var set, sPOf;
6335 try {
6336 // this might fail for various reasons
6337 // ignore if Chrome cought it at runtime
6338 set = getOwnPropertyDescriptor(objProto, '__proto__').set;
6339 set.call({}, null);
6340 // setter not poisoned, it can promote
6341 // Firefox, Chrome
6342 sPOf = function setPrototypeOf(origin, proto) {
6343 set.call(origin, proto);
6344 return origin;
6345 };
6346 } catch (e) {
6347 // do one or more feature detections
6348 set = { __proto__: null };
6349 // if proto does not work, needs to fallback
6350 // some Opera, Rhino, ducktape
6351 if (set instanceof Object) {
6352 sPOf = createAndCopy;
6353 } else {
6354 // verify if null objects are buggy
6355 /* eslint-disable no-proto */
6356 set.__proto__ = objProto;
6357 /* eslint-enable no-proto */
6358 // if null objects are buggy
6359 // nodejs 0.8 to 0.10
6360 if (set instanceof Object) {
6361 sPOf = function setPrototypeOf(origin, proto) {
6362 // use such bug to promote
6363 /* eslint-disable no-proto */
6364 origin.__proto__ = proto;
6365 /* eslint-enable no-proto */
6366 return origin;
6367 };
6368 } else {
6369 // try to use proto or fallback
6370 // Safari, old Firefox, many others
6371 sPOf = function setPrototypeOf(origin, proto) {
6372 // if proto is not null
6373 if (getPrototypeOf(origin)) {
6374 // use __proto__ to promote
6375 /* eslint-disable no-proto */
6376 origin.__proto__ = proto;
6377 /* eslint-enable no-proto */
6378 return origin;
6379 } else {
6380 // otherwise unable to promote: fallback
6381 return createAndCopy(origin, proto);
6382 }
6383 };
6384 }
6385 }
6386 }
6387 CreateMethodProperty(Object, 'setPrototypeOf', sPOf);
6388}());
6389if (!("values"in Object
6390)) {
6391
6392// Object.values
6393/* global CreateMethodProperty, ToObject */
6394(function () {
6395 var toString = ({}).toString;
6396 var split = ''.split;
6397 // 19.1.2.21. Object.values ( O )
6398 CreateMethodProperty(Object, 'values', function values(O) {
6399 // 1. Let obj be ? ToObject(O).
6400 // Polyfill.io fallback for non-array-like strings which exist in some ES3 user-agents (IE 8)
6401 var obj = toString.call(O) == '[object String]' ? split.call(O, '') : ToObject(O);
6402 // 2. Let nameList be ? EnumerableOwnProperties(obj, "value").
6403 var nameList = Object.keys(obj).map(function (key) {
6404 return obj[key];
6405 });
6406 // 3. Return CreateArrayFromList(nameList).
6407 // Polyfill.io - nameList is already an array.
6408 return nameList;
6409 });
6410}());
6411
6412}
6413
6414if (!("Promise"in this
6415)) {
6416
6417// Promise
6418!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:/*!***********************!*\
6419 !*** ./src/global.js ***!
6420 \***********************/
6421function(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:/*!***********************************!*\
6422 !*** (webpack)/buildin/global.js ***!
6423 \***********************************/
6424function(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:/*!*********************!*\
6425 !*** ./src/yaku.js ***!
6426 \*********************/
6427function(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))}});
6428}
6429
6430if (!("Promise"in this&&"finally"in Promise.prototype
6431)) {
6432
6433// Promise.prototype.finally
6434/* global CreateMethodProperty, IsCallable, SpeciesConstructor, Type, Promise */
6435(function () {
6436 // Based on https://github.com/tc39/proposal-promise-finally/blob/master/polyfill.js
6437 var then = Function.prototype.bind.call(Function.prototype.call, Promise.prototype.then);
6438
6439 var getPromise = function (C, handler) {
6440 return new C(function (resolve) {
6441 resolve(handler());
6442 });
6443 };
6444 // 1. Promise.prototype.finally ( onFinally )
6445 CreateMethodProperty(Promise.prototype, 'finally', function (onFinally) {
6446 // 1. Let promise be the this value.
6447 var promise = this;
6448 // 2. If Type(promise) is not Object, throw a TypeError exception.
6449 if (Type(promise) !== 'object') {
6450 throw new TypeError('Method %PromisePrototype%.finally called on incompatible receiver ' + Object.prototype.toString.call(promise));
6451 }
6452 // 3. Let C be ? SpeciesConstructor(promise, %Promise%).
6453 var C = SpeciesConstructor(promise, Promise);
6454 // 4. Assert: IsConstructor(C) is true.
6455 // 5. If IsCallable(onFinally) is false,
6456 if (IsCallable(onFinally) === false) {
6457 // a. Let thenFinally be onFinally.
6458 var thenFinally = onFinally;
6459 // b. Let catchFinally be onFinally.
6460 var catchFinally = onFinally;
6461 // 6. Else,
6462 } else {
6463 // a. Let thenFinally be a new built-in function object as defined in ThenFinally Function.
6464 var thenFinally = function (x) {
6465 return then(getPromise(C, onFinally), function () {
6466 return x;
6467 });
6468 };
6469 // b. Let catchFinally be a new built-in function object as defined in CatchFinally Function.
6470 var catchFinally = function (e) {
6471 return then(getPromise(C, onFinally), function () {
6472 throw e;
6473 });
6474 };
6475 // c. Set thenFinally and catchFinally's [[Constructor]] internal slots to C.
6476 // d. Set thenFinally and catchFinally's [[OnFinally]] internal slots to onFinally.
6477 }
6478 // 7. Return ? Invoke(promise, "then", « thenFinally, catchFinally »).
6479 return then(promise, thenFinally, catchFinally);
6480 });
6481}());
6482
6483}
6484
6485if (!("Reflect"in this
6486)) {
6487
6488// Reflect
6489// 26.1 The Reflect Object
6490Object.defineProperty(self, "Reflect", {
6491 value: self.Reflect || {},
6492 writable: true,
6493 configurable: true
6494});
6495Object.defineProperty(self, "Reflect", {
6496 value: self.Reflect || {},
6497 enumerable: false
6498});
6499}
6500
6501if (!("flags"in RegExp.prototype
6502)) {
6503
6504// RegExp.prototype.flags
6505/* global Get, ToBoolean, Type */
6506Object.defineProperty(RegExp.prototype, 'flags', {
6507 configurable: true,
6508 enumerable: false,
6509 get: function () {
6510 // 21.2.5.3.1 Let R be the this value.
6511 var R = this;
6512
6513 // 21.2.5.3.2 If Type(R) is not Object, throw a TypeError exception.
6514 if (Type(R) !== 'object') {
6515 throw new TypeError('Method called on incompatible type: must be an object.');
6516 }
6517 // 21.2.5.3.3 Let result be the empty String.
6518 var result = '';
6519
6520 // 21.2.5.3.4 Let global be ToBoolean(? Get(R, "global")).
6521 var global = ToBoolean(Get(R, 'global'));
6522
6523 // 21.2.5.3.5 If global is true, append the code unit 0x0067 (LATIN SMALL LETTER G) as the last code unit of result.
6524 if (global) {
6525 result += 'g';
6526 }
6527
6528 // 21.2.5.3.6 Let ignoreCase be ToBoolean(? Get(R, "ignoreCase")).
6529 var ignoreCase = ToBoolean(Get(R, 'ignoreCase'));
6530
6531 // 21.2.5.3.7 If ignoreCase is true, append the code unit 0x0069 (LATIN SMALL LETTER I) as the last code unit of result.
6532 if (ignoreCase) {
6533 result += 'i';
6534 }
6535
6536 // 21.2.5.3.8 Let multiline be ToBoolean(? Get(R, "multiline")).
6537 var multiline = ToBoolean(Get(R, 'multiline'));
6538
6539 // 21.2.5.3.9 If multiline is true, append the code unit 0x006D (LATIN SMALL LETTER M) as the last code unit of result.
6540 if (multiline) {
6541 result += 'm';
6542 }
6543
6544 // 21.2.5.3.10 Let unicode be ToBoolean(? Get(R, "unicode")).
6545 var unicode = ToBoolean(Get(R, 'unicode'));
6546
6547 // 21.2.5.3.11 If unicode is true, append the code unit 0x0075 (LATIN SMALL LETTER U) as the last code unit of result.
6548 if (unicode) {
6549 result += 'u';
6550 }
6551
6552 // 21.2.5.3.12 Let sticky be ToBoolean(? Get(R, "sticky")).
6553 var sticky = ToBoolean(Get(R, 'sticky'));
6554
6555 // 21.2.5.3.13 If sticky is true, append the code unit 0x0079 (LATIN SMALL LETTER Y) as the last code unit of result.
6556 if (sticky) {
6557 result += 'y';
6558 }
6559
6560 // 21.2.5.3.14 Return result.
6561 return result;
6562 }
6563});
6564
6565}
6566
6567if (!("requestAnimationFrame"in this
6568)) {
6569
6570// requestAnimationFrame
6571(function (global) {
6572 var rafPrefix;
6573
6574 // do not inject RAF in order to avoid broken performance
6575 var nowOffset = Date.now();
6576
6577 // use performance api if exist, otherwise use Date.now.
6578 // Date.now polyfill required.
6579 var pnow = function () {
6580 if (global.performance && typeof global.performance.now === 'function') {
6581 return global.performance.now();
6582 }
6583 // fallback
6584 return Date.now() - nowOffset;
6585 };
6586
6587 if ('mozRequestAnimationFrame' in global) {
6588 rafPrefix = 'moz';
6589
6590 } else if ('webkitRequestAnimationFrame' in global) {
6591 rafPrefix = 'webkit';
6592
6593 }
6594
6595 if (rafPrefix) {
6596 global.requestAnimationFrame = function (callback) {
6597 return global[rafPrefix + 'RequestAnimationFrame'](function () {
6598 callback(pnow());
6599 });
6600 };
6601 global.cancelAnimationFrame = global[rafPrefix + 'CancelAnimationFrame'];
6602 } else {
6603
6604 var lastTime = Date.now();
6605
6606 global.requestAnimationFrame = function (callback) {
6607 if (typeof callback !== 'function') {
6608 throw new TypeError(callback + ' is not a function');
6609 }
6610
6611 var
6612 currentTime = Date.now(),
6613 delay = 16 + lastTime - currentTime;
6614
6615 if (delay < 0) {
6616 delay = 0;
6617 }
6618
6619 lastTime = currentTime;
6620
6621 return setTimeout(function () {
6622 lastTime = Date.now();
6623
6624 callback(pnow());
6625 }, delay);
6626 };
6627
6628 global.cancelAnimationFrame = function (id) {
6629 clearTimeout(id);
6630 };
6631 }
6632}(this));
6633
6634}
6635
6636if (!("codePointAt"in String.prototype
6637)) {
6638
6639// String.prototype.codePointAt
6640/* global CreateMethodProperty, RequireObjectCoercible, ToInteger, ToString, UTF16Decode */
6641// 21.1.3.3. String.prototype.codePointAt ( pos )
6642CreateMethodProperty(String.prototype, 'codePointAt', function codePointAt(pos) {
6643 // 1. Let O be ? RequireObjectCoercible(this value).
6644 var O = RequireObjectCoercible(this);
6645 // 2. Let S be ? ToString(O).
6646 var S = ToString(O);
6647 // 3. Let position be ? ToInteger(pos).
6648 var position = ToInteger(pos);
6649 // 4. Let size be the length of S.
6650 var size = S.length;
6651 // 5. If position < 0 or position ≥ size, return undefined.
6652 if (position < 0 || position >= size) {
6653 return undefined;
6654 }
6655 // 6. Let first be the numeric value of the code unit at index position within the String S.
6656 var first = String.prototype.charCodeAt.call(S, position);
6657 // 7. If first < 0xD800 or first > 0xDBFF or position+1 = size, return first.
6658 if (first < 0xD800 || first > 0xDBFF || position + 1 === size) {
6659 return first;
6660 }
6661 // 8. Let second be the numeric value of the code unit at index position+1 within the String S.
6662 var second = String.prototype.charCodeAt.call(S, position + 1);
6663 // 9. If second < 0xDC00 or second > 0xDFFF, return first.
6664 if (second < 0xDC00 || second > 0xDFFF) {
6665 return first;
6666 }
6667 // 10. Return UTF16Decode(first, second).
6668 // 21.1.3.3.10 Return UTF16Decode(first, second).
6669 return UTF16Decode(first, second);
6670});
6671
6672}
6673
6674if (!("endsWith"in String.prototype
6675)) {
6676
6677// String.prototype.endsWith
6678/* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
6679// 21.1.3.6. String.prototype.endsWith ( searchString [ , endPosition ] )
6680CreateMethodProperty(String.prototype, 'endsWith', function endsWith(searchString /* [ , endPosition ] */) {
6681 'use strict';
6682 var endPosition = arguments.length > 1 ? arguments[1] : undefined;
6683 // 1. Let O be ? RequireObjectCoercible(this value).
6684 var O = RequireObjectCoercible(this);
6685 // 2. Let S be ? ToString(O).
6686 var S = ToString(O);
6687 // 3. Let isRegExp be ? IsRegExp(searchString).
6688 var isRegExp = IsRegExp(searchString);
6689 // 4. If isRegExp is true, throw a TypeError exception.
6690 if (isRegExp) {
6691 throw new TypeError('First argument to String.prototype.endsWith must not be a regular expression');
6692 }
6693 // 5. Let searchStr be ? ToString(searchString).
6694 var searchStr = ToString(searchString);
6695 // 6. Let len be the length of S.
6696 var len = S.length;
6697 // 7. If endPosition is undefined, let pos be len, else let pos be ? ToInteger(endPosition).
6698 var pos = endPosition === undefined ? len : ToInteger(endPosition);
6699 // 8. Let end be min(max(pos, 0), len).
6700 var end = Math.min(Math.max(pos, 0), len);
6701 // 9. Let searchLength be the length of searchStr.
6702 var searchLength = searchStr.length;
6703 // 10. Let start be end - searchLength.
6704 var start = end - searchLength;
6705 // 11. If start is less than 0, return false.
6706 if (start < 0) {
6707 return false;
6708 }
6709 // 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.
6710 if (S.substr(start, searchLength) === searchStr) {
6711 return true;
6712 }
6713 // 13. Otherwise, return false.
6714 return false;
6715});
6716
6717}
6718
6719if (!("includes"in String.prototype
6720)) {
6721
6722// String.prototype.includes
6723/* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
6724// 21.1.3.7. String.prototype.includes ( searchString [ , position ] )
6725CreateMethodProperty(String.prototype, 'includes', function includes(searchString /* [ , position ] */) {
6726 'use strict';
6727 var position = arguments.length > 1 ? arguments[1] : undefined;
6728 // 1. Let O be ? RequireObjectCoercible(this value).
6729 var O = RequireObjectCoercible(this);
6730 // 2. Let S be ? ToString(O).
6731 var S = ToString(O);
6732 // 3. Let isRegExp be ? IsRegExp(searchString).
6733 var isRegExp = IsRegExp(searchString);
6734 // 4. If isRegExp is true, throw a TypeError exception.
6735 if (isRegExp) {
6736 throw new TypeError('First argument to String.prototype.includes must not be a regular expression');
6737 }
6738 // 5. Let searchStr be ? ToString(searchString).
6739 var searchStr = ToString(searchString);
6740 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
6741 var pos = ToInteger(position);
6742 // 7. Let len be the length of S.
6743 var len = S.length;
6744 // 8. Let start be min(max(pos, 0), len).
6745 var start = Math.min(Math.max(pos, 0), len);
6746 // 9. Let searchLen be the length of searchStr.
6747 // var searchLength = searchStr.length;
6748 // 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.
6749 return String.prototype.indexOf.call(S, searchStr, start) !== -1;
6750});
6751
6752}
6753
6754if (!("padEnd"in String.prototype
6755)) {
6756
6757// String.prototype.padEnd
6758/* global CreateMethodProperty, RequireObjectCoercible, ToLength, ToString */
6759// 21.1.3.13. String.prototype.padEnd( maxLength [ , fillString ] )
6760CreateMethodProperty(String.prototype, 'padEnd', function padEnd(maxLength /* [ , fillString ] */) {
6761 'use strict';
6762 var fillString = arguments.length > 1 ? arguments[1] : undefined;
6763 // 1. Let O be ? RequireObjectCoercible(this value).
6764 var O = RequireObjectCoercible(this);
6765 // 2. Let S be ? ToString(O).
6766 var S = ToString(O);
6767 // 3. Let intMaxLength be ? ToLength(maxLength).
6768 var intMaxLength = ToLength(maxLength);
6769 // 4. Let stringLength be the length of S.
6770 var stringLength = S.length;
6771 // 5. If intMaxLength is not greater than stringLength, return S.
6772 if (intMaxLength <= stringLength) {
6773 return S;
6774 }
6775 // 6. If fillString is undefined, let filler be the String value consisting solely of the code unit 0x0020 (SPACE).
6776 if (fillString === undefined) {
6777 var filler = ' ';
6778 // 7. Else, let filler be ? ToString(fillString).
6779 } else {
6780 var filler = ToString(fillString);
6781 }
6782 // 8. If filler is the empty String, return S.
6783 if (filler === '') {
6784 return S;
6785 }
6786 // 9. Let fillLen be intMaxLength - stringLength.
6787 var fillLen = intMaxLength - stringLength;
6788 // 10. Let truncatedStringFiller be the String value consisting of repeated concatenations of filler truncated to length fillLen.
6789 var truncatedStringFiller = '';
6790 for (var i = 0; i < fillLen; i++) {
6791 truncatedStringFiller += filler;
6792 }
6793 truncatedStringFiller = truncatedStringFiller.substr(0, fillLen);
6794 // 11. Return the string-concatenation of S and truncatedStringFiller.
6795 return S + truncatedStringFiller;
6796});
6797
6798}
6799
6800if (!("padStart"in String.prototype
6801)) {
6802
6803// String.prototype.padStart
6804/* global CreateMethodProperty, RequireObjectCoercible, ToLength, ToString */
6805// 21.1.3.14. String.prototype.padStart( maxLength [ , fillString ] )
6806CreateMethodProperty(String.prototype, 'padStart', function padStart(maxLength /* [ , fillString ] */) {
6807 'use strict';
6808 var fillString = arguments.length > 1 ? arguments[1] : undefined;
6809 // 1. Let O be ? RequireObjectCoercible(this value).
6810 var O = RequireObjectCoercible(this);
6811 // 2. Let S be ? ToString(O).
6812 var S = ToString(O);
6813 // 3. Let intMaxLength be ? ToLength(maxLength).
6814 var intMaxLength = ToLength(maxLength);
6815 // 4. Let stringLength be the length of S.
6816 var stringLength = S.length;
6817 // 5. If intMaxLength is not greater than stringLength, return S.
6818 if (intMaxLength <= stringLength) {
6819 return S;
6820 }
6821 // 6. If fillString is undefined, let filler be the String value consisting solely of the code unit 0x0020 (SPACE).
6822 if (fillString === undefined) {
6823 var filler = ' ';
6824 // 7. Else, let filler be ? ToString(fillString).
6825 } else {
6826 var filler = ToString(fillString);
6827 }
6828 // 8. If filler is the empty String, return S.
6829 if (filler === '') {
6830 return S;
6831 }
6832 // 9. Let fillLen be intMaxLength - stringLength.
6833 var fillLen = intMaxLength - stringLength;
6834 // 10. Let truncatedStringFiller be the String value consisting of repeated concatenations of filler truncated to length fillLen.
6835 var truncatedStringFiller = '';
6836 for (var i = 0; i < fillLen; i++) {
6837 truncatedStringFiller += filler;
6838 }
6839 truncatedStringFiller = truncatedStringFiller.substr(0, fillLen);
6840 // 11. Return the string-concatenation of truncatedStringFiller and S.
6841 return truncatedStringFiller + S;
6842});
6843
6844}
6845
6846if (!("repeat"in String.prototype
6847)) {
6848
6849// String.prototype.repeat
6850/* global CreateMethodProperty, RequireObjectCoercible, ToInteger, ToString */
6851// 21.1.3.15String.prototype.repeat ( count )
6852CreateMethodProperty(String.prototype, 'repeat', function repeat(count) {
6853 'use strict';
6854 // 1. Let O be ? RequireObjectCoercible(this value).
6855 var O = RequireObjectCoercible(this);
6856 // 2. Let S be ? ToString(O).
6857 var S = ToString(O);
6858 // 3. Let n be ? ToInteger(count).
6859 var n = ToInteger(count);
6860 // 4. If n < 0, throw a RangeError exception.
6861 if (n < 0) {
6862 throw new RangeError('Invalid count value');
6863 }
6864 // 5. If n is +∞, throw a RangeError exception.
6865 if (n === Infinity) {
6866 throw new RangeError('Invalid count value');
6867 }
6868 // 6. Let T be the String value that is made from n copies of S appended together. If n is 0, T is the empty String.
6869 var T = n === 0 ? '' : new Array(n + 1).join(S);
6870 // 7. Return T.
6871 return T;
6872});
6873
6874}
6875
6876if (!("startsWith"in String.prototype
6877)) {
6878
6879// String.prototype.startsWith
6880/* global CreateMethodProperty, IsRegExp, RequireObjectCoercible, ToInteger, ToString */
6881// 21.1.3.20. String.prototype.startsWith ( searchString [ , position ] )
6882CreateMethodProperty(String.prototype, 'startsWith', function startsWith(searchString /* [ , position ] */) {
6883 'use strict';
6884 var position = arguments.length > 1 ? arguments[1] : undefined;
6885 // 1. Let O be ? RequireObjectCoercible(this value).
6886 var O = RequireObjectCoercible(this);
6887 // 2. Let S be ? ToString(O).
6888 var S = ToString(O);
6889 // 3. Let isRegExp be ? IsRegExp(searchString).
6890 var isRegExp = IsRegExp(searchString);
6891 // 4. If isRegExp is true, throw a TypeError exception.
6892 if (isRegExp) {
6893 throw new TypeError('First argument to String.prototype.startsWith must not be a regular expression');
6894 }
6895 // 5. Let searchStr be ? ToString(searchString).
6896 var searchStr = ToString(searchString);
6897 // 6. Let pos be ? ToInteger(position). (If position is undefined, this step produces the value 0.)
6898 var pos = ToInteger(position);
6899 // 7. Let len be the length of S.
6900 var len = S.length;
6901 // 8. Let start be min(max(pos, 0), len).
6902 var start = Math.min(Math.max(pos, 0), len);
6903 // 9. Let searchLength be the length of searchStr.
6904 var searchLength = searchStr.length;
6905 // 10. If searchLength+start is greater than len, return false.
6906 if (searchLength + start > len) {
6907 return false;
6908 }
6909 // 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.
6910 if (S.substr(start).indexOf(searchString) === 0) {
6911 return true;
6912 }
6913 // 12. Otherwise, return false.
6914 return false;
6915});
6916
6917}
6918
6919if (!("trim"in String.prototype
6920)) {
6921
6922// String.prototype.trim
6923/* global CreateMethodProperty, RequireObjectCoercible, ToString */
6924// 21.1.3.27. String.prototype.trim ( )
6925CreateMethodProperty(String.prototype, 'trim', function trim() {
6926 // 1. Let O be ? RequireObjectCoercible(this value).
6927 var O = RequireObjectCoercible(this);
6928 // 2. Let S be ? ToString(O).
6929 var S = ToString(O);
6930 // 3. Let T be the String value that is a copy of S with both leading and trailing white space removed. The definition of white space is the union of WhiteSpace and LineTerminator. When determining whether a Unicode code point is in Unicode general category “Space_Separator” (“Zs”), code unit sequences are interpreted as UTF-16 encoded code point sequences as specified in 6.1.4.
6931 var T = String.prototype.replace.call(S, /^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+|[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/g, '');
6932 // 4. Return T.
6933 return T;
6934});
6935
6936}
6937
6938if (!("Symbol"in this&&0===this.Symbol.length
6939)) {
6940
6941// Symbol
6942// A modification of https://github.com/WebReflection/get-own-property-symbols
6943// (C) Andrea Giammarchi - MIT Licensed
6944
6945(function (Object, GOPS, global) {
6946 'use strict'; //so that ({}).toString.call(null) returns the correct [object Null] rather than [object Window]
6947
6948 var setDescriptor;
6949 var id = 0;
6950 var random = '' + Math.random();
6951 var prefix = '__\x01symbol:';
6952 var prefixLength = prefix.length;
6953 var internalSymbol = '__\x01symbol@@' + random;
6954 var DP = 'defineProperty';
6955 var DPies = 'defineProperties';
6956 var GOPN = 'getOwnPropertyNames';
6957 var GOPD = 'getOwnPropertyDescriptor';
6958 var PIE = 'propertyIsEnumerable';
6959 var ObjectProto = Object.prototype;
6960 var hOP = ObjectProto.hasOwnProperty;
6961 var pIE = ObjectProto[PIE];
6962 var toString = ObjectProto.toString;
6963 var concat = Array.prototype.concat;
6964 var cachedWindowNames = Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
6965 var nGOPN = Object[GOPN];
6966 var gOPN = function getOwnPropertyNames (obj) {
6967 if (toString.call(obj) === '[object Window]') {
6968 try {
6969 return nGOPN(obj);
6970 } catch (e) {
6971 // IE bug where layout engine calls userland gOPN for cross-domain `window` objects
6972 return concat.call([], cachedWindowNames);
6973 }
6974 }
6975 return nGOPN(obj);
6976 };
6977 var gOPD = Object[GOPD];
6978 var create = Object.create;
6979 var keys = Object.keys;
6980 var freeze = Object.freeze || Object;
6981 var defineProperty = Object[DP];
6982 var $defineProperties = Object[DPies];
6983 var descriptor = gOPD(Object, GOPN);
6984 var addInternalIfNeeded = function (o, uid, enumerable) {
6985 if (!hOP.call(o, internalSymbol)) {
6986 try {
6987 defineProperty(o, internalSymbol, {
6988 enumerable: false,
6989 configurable: false,
6990 writable: false,
6991 value: {}
6992 });
6993 } catch (e) {
6994 o[internalSymbol] = {};
6995 }
6996 }
6997 o[internalSymbol]['@@' + uid] = enumerable;
6998 };
6999 var createWithSymbols = function (proto, descriptors) {
7000 var self = create(proto);
7001 gOPN(descriptors).forEach(function (key) {
7002 if (propertyIsEnumerable.call(descriptors, key)) {
7003 $defineProperty(self, key, descriptors[key]);
7004 }
7005 });
7006 return self;
7007 };
7008 var copyAsNonEnumerable = function (descriptor) {
7009 var newDescriptor = create(descriptor);
7010 newDescriptor.enumerable = false;
7011 return newDescriptor;
7012 };
7013 var get = function get(){};
7014 var onlyNonSymbols = function (name) {
7015 return name != internalSymbol &&
7016 !hOP.call(source, name);
7017 };
7018 var onlySymbols = function (name) {
7019 return name != internalSymbol &&
7020 hOP.call(source, name);
7021 };
7022 var propertyIsEnumerable = function propertyIsEnumerable(key) {
7023 var uid = '' + key;
7024 return onlySymbols(uid) ? (
7025 hOP.call(this, uid) &&
7026 this[internalSymbol]['@@' + uid]
7027 ) : pIE.call(this, key);
7028 };
7029 var setAndGetSymbol = function (uid) {
7030 var descriptor = {
7031 enumerable: false,
7032 configurable: true,
7033 get: get,
7034 set: function (value) {
7035 setDescriptor(this, uid, {
7036 enumerable: false,
7037 configurable: true,
7038 writable: true,
7039 value: value
7040 });
7041 addInternalIfNeeded(this, uid, true);
7042 }
7043 };
7044 try {
7045 defineProperty(ObjectProto, uid, descriptor);
7046 } catch (e) {
7047 ObjectProto[uid] = descriptor.value;
7048 }
7049 return freeze(source[uid] = defineProperty(
7050 Object(uid),
7051 'constructor',
7052 sourceConstructor
7053 ));
7054 };
7055 var Symbol = function Symbol() {
7056 var description = arguments[0];
7057 if (this instanceof Symbol) {
7058 throw new TypeError('Symbol is not a constructor');
7059 }
7060 return setAndGetSymbol(
7061 prefix.concat(description || '', random, ++id)
7062 );
7063 };
7064 var source = create(null);
7065 var sourceConstructor = {value: Symbol};
7066 var sourceMap = function (uid) {
7067 return source[uid];
7068 };
7069 var $defineProperty = function defineProp(o, key, descriptor) {
7070 var uid = '' + key;
7071 if (onlySymbols(uid)) {
7072 setDescriptor(o, uid, descriptor.enumerable ?
7073 copyAsNonEnumerable(descriptor) : descriptor);
7074 addInternalIfNeeded(o, uid, !!descriptor.enumerable);
7075 } else {
7076 defineProperty(o, key, descriptor);
7077 }
7078 return o;
7079 };
7080
7081 var onlyInternalSymbols = function (obj) {
7082 return function (name) {
7083 return hOP.call(obj, internalSymbol) && hOP.call(obj[internalSymbol], '@@' + name);
7084 };
7085 };
7086 var $getOwnPropertySymbols = function getOwnPropertySymbols(o) {
7087 return gOPN(o).filter(o === ObjectProto ? onlyInternalSymbols(o) : onlySymbols).map(sourceMap);
7088 }
7089 ;
7090
7091 descriptor.value = $defineProperty;
7092 defineProperty(Object, DP, descriptor);
7093
7094 descriptor.value = $getOwnPropertySymbols;
7095 defineProperty(Object, GOPS, descriptor);
7096
7097 descriptor.value = function getOwnPropertyNames(o) {
7098 return gOPN(o).filter(onlyNonSymbols);
7099 };
7100 defineProperty(Object, GOPN, descriptor);
7101
7102 descriptor.value = function defineProperties(o, descriptors) {
7103 var symbols = $getOwnPropertySymbols(descriptors);
7104 if (symbols.length) {
7105 keys(descriptors).concat(symbols).forEach(function (uid) {
7106 if (propertyIsEnumerable.call(descriptors, uid)) {
7107 $defineProperty(o, uid, descriptors[uid]);
7108 }
7109 });
7110 } else {
7111 $defineProperties(o, descriptors);
7112 }
7113 return o;
7114 };
7115 defineProperty(Object, DPies, descriptor);
7116
7117 descriptor.value = propertyIsEnumerable;
7118 defineProperty(ObjectProto, PIE, descriptor);
7119
7120 descriptor.value = Symbol;
7121 defineProperty(global, 'Symbol', descriptor);
7122
7123 // defining `Symbol.for(key)`
7124 descriptor.value = function (key) {
7125 var uid = prefix.concat(prefix, key, random);
7126 return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid);
7127 };
7128 defineProperty(Symbol, 'for', descriptor);
7129
7130 // defining `Symbol.keyFor(symbol)`
7131 descriptor.value = function (symbol) {
7132 if (onlyNonSymbols(symbol))
7133 throw new TypeError(symbol + ' is not a symbol');
7134 return hOP.call(source, symbol) ?
7135 symbol.slice(prefixLength * 2, -random.length) :
7136 void 0
7137 ;
7138 };
7139 defineProperty(Symbol, 'keyFor', descriptor);
7140
7141 descriptor.value = function getOwnPropertyDescriptor(o, key) {
7142 var descriptor = gOPD(o, key);
7143 if (descriptor && onlySymbols(key)) {
7144 descriptor.enumerable = propertyIsEnumerable.call(o, key);
7145 }
7146 return descriptor;
7147 };
7148 defineProperty(Object, GOPD, descriptor);
7149
7150 descriptor.value = function (proto, descriptors) {
7151 return arguments.length === 1 || typeof descriptors === "undefined" ?
7152 create(proto) :
7153 createWithSymbols(proto, descriptors);
7154 };
7155 defineProperty(Object, 'create', descriptor);
7156
7157 var strictModeSupported = (function(){ 'use strict'; return this; }).call(null) === null;
7158 if (strictModeSupported) {
7159 descriptor.value = function () {
7160 var str = toString.call(this);
7161 return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
7162 };
7163 } else {
7164 descriptor.value = function () {
7165 // https://github.com/Financial-Times/polyfill-library/issues/164#issuecomment-486965300
7166 // Polyfill.io this code is here for the situation where a browser does not
7167 // support strict mode and is executing `Object.prototype.toString.call(null)`.
7168 // This code ensures that we return the correct result in that situation however,
7169 // this code also introduces a bug where it will return the incorrect result for
7170 // `Object.prototype.toString.call(window)`. We can't have the correct result for
7171 // both `window` and `null`, so we have opted for `null` as we believe this is the more
7172 // common situation.
7173 if (this === window) {
7174 return '[object Null]';
7175 }
7176
7177 var str = toString.call(this);
7178 return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
7179 };
7180 }
7181 defineProperty(ObjectProto, 'toString', descriptor);
7182
7183 setDescriptor = function (o, key, descriptor) {
7184 var protoDescriptor = gOPD(ObjectProto, key);
7185 delete ObjectProto[key];
7186 defineProperty(o, key, descriptor);
7187 if (o !== ObjectProto) {
7188 defineProperty(ObjectProto, key, protoDescriptor);
7189 }
7190 };
7191
7192}(Object, 'getOwnPropertySymbols', this));
7193
7194}
7195
7196if (!("ownKeys"in Reflect
7197)) {
7198
7199// Reflect.ownKeys
7200/* global CreateMethodProperty, Reflect, Type */
7201// 26.1.10 Reflect.ownKeys ( target )
7202CreateMethodProperty(Reflect, 'ownKeys', function ownKeys(target) {
7203 // 1. If Type(target) is not Object, throw a TypeError exception.
7204 if (Type(target) !== "object") {
7205 throw new TypeError(Object.prototype.toString.call(target) + ' is not an Object');
7206 }
7207 // polyfill-library - These steps are taken care of by Object.getOwnPropertyNames.
7208 // 2. Let keys be ? target.[[OwnPropertyKeys]]().
7209 // 3. Return CreateArrayFromList(keys).
7210 return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
7211});
7212
7213}
7214
7215if (!("getOwnPropertyDescriptor"in Object&&"function"==typeof Object.getOwnPropertyDescriptor&&function(){try{var t={}
7216return t.test=0,0===Object.getOwnPropertyDescriptors(t).test.value}catch(e){return!1}}()
7217)) {
7218
7219// Object.getOwnPropertyDescriptors
7220/* global CreateMethodProperty, Reflect, ToObject, CreateDataProperty */
7221
7222// 19.1.2.9. Object.getOwnPropertyDescriptors ( O )
7223CreateMethodProperty(
7224 Object,
7225 'getOwnPropertyDescriptors',
7226 function getOwnPropertyDescriptors(O) {
7227 // 1. Let obj be ? ToObject(O).
7228 var obj = ToObject(O);
7229 // 2. Let ownKeys be ? obj.[[OwnPropertyKeys]]().
7230 var ownKeys = Reflect.ownKeys(obj);
7231 // 3. Let descriptors be ! ObjectCreate(%ObjectPrototype%).
7232 var descriptors = {};
7233 // 4. For each element key of ownKeys in List order, do
7234 var length = ownKeys.length;
7235 for (var i = 0; i < length; i++) {
7236 var key = ownKeys[i];
7237 // a. Let desc be ? obj.[[GetOwnProperty]](key).
7238 // b. Let descriptor be ! FromPropertyDescriptor(desc).
7239 var descriptor = Object.getOwnPropertyDescriptor(O, key);
7240 // c. If descriptor is not undefined, perform ! CreateDataProperty(descriptors, key, descriptor).
7241 if (descriptor !== undefined) {
7242 CreateDataProperty(descriptors, key, descriptor);
7243 }
7244 }
7245 // 5. Return descriptors.
7246 return descriptors;
7247 }
7248);
7249
7250}
7251
7252if (!("Symbol"in this&&"asyncIterator"in this.Symbol
7253)) {
7254
7255// Symbol.asyncIterator
7256/* global Symbol */
7257Object.defineProperty(Symbol, 'asyncIterator', { value: Symbol('asyncIterator') });
7258
7259}
7260
7261if (!("Symbol"in this&&"hasInstance"in this.Symbol
7262)) {
7263
7264// Symbol.hasInstance
7265/* global Symbol */
7266Object.defineProperty(Symbol, 'hasInstance', { value: Symbol('hasInstance') });
7267
7268}
7269
7270if (!("Symbol"in this&&"isConcatSpreadable"in this.Symbol
7271)) {
7272
7273// Symbol.isConcatSpreadable
7274/* global Symbol */
7275Object.defineProperty(Symbol, 'isConcatSpreadable', { value: Symbol('isConcatSpreadable') });
7276
7277}
7278
7279if (!("Symbol"in this&&"iterator"in this.Symbol
7280)) {
7281
7282// Symbol.iterator
7283/* global Symbol */
7284Object.defineProperty(Symbol, 'iterator', { value: Symbol('iterator') });
7285
7286}
7287
7288
7289// _ESAbstract.GetIterator
7290/* global GetMethod, Symbol, Call, Type, GetV */
7291// 7.4.1. GetIterator ( obj [ , method ] )
7292// The abstract operation GetIterator with argument obj and optional argument method performs the following steps:
7293function GetIterator(obj /*, method */) { // eslint-disable-line no-unused-vars
7294 // 1. If method is not present, then
7295 // a. Set method to ? GetMethod(obj, @@iterator).
7296 var method = arguments.length > 1 ? arguments[1] : GetMethod(obj, Symbol.iterator);
7297 // 2. Let iterator be ? Call(method, obj).
7298 var iterator = Call(method, obj);
7299 // 3. If Type(iterator) is not Object, throw a TypeError exception.
7300 if (Type(iterator) !== 'object') {
7301 throw new TypeError('bad iterator');
7302 }
7303 // 4. Let nextMethod be ? GetV(iterator, "next").
7304 var nextMethod = GetV(iterator, "next");
7305 // 5. Let iteratorRecord be Record {[[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false}.
7306 var iteratorRecord = Object.create(null);
7307 iteratorRecord['[[Iterator]]'] = iterator;
7308 iteratorRecord['[[NextMethod]]'] = nextMethod;
7309 iteratorRecord['[[Done]]'] = false;
7310 // 6. Return iteratorRecord.
7311 return iteratorRecord;
7312}
7313if (!("Symbol"in this&&"match"in this.Symbol
7314)) {
7315
7316// Symbol.match
7317/* global Symbol */
7318Object.defineProperty(Symbol, 'match', { value: Symbol('match') });
7319
7320}
7321
7322if (!("Symbol"in this&&"replace"in this.Symbol
7323)) {
7324
7325// Symbol.replace
7326/* global Symbol */
7327Object.defineProperty(Symbol, 'replace', { value: Symbol('replace') });
7328
7329}
7330
7331if (!("Symbol"in this&&"search"in this.Symbol
7332)) {
7333
7334// Symbol.search
7335/* global Symbol */
7336Object.defineProperty(Symbol, 'search', { value: Symbol('search') });
7337
7338}
7339
7340if (!("Symbol"in this&&"species"in this.Symbol
7341)) {
7342
7343// Symbol.species
7344/* global Symbol */
7345Object.defineProperty(Symbol, 'species', { value: Symbol('species') });
7346
7347}
7348
7349if (!("Map"in this&&function(t){try{var n=new Map([[1,1],[2,2]])
7350return 0===Map.length&&2===n.size&&"Symbol"in t&&"iterator"in Symbol&&"function"==typeof n[Symbol.iterator]}catch(i){return!1}}(this)
7351)) {
7352
7353// Map
7354/* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
7355(function (global) {
7356 var supportsGetters = (function () {
7357 try {
7358 var a = {};
7359 Object.defineProperty(a, 't', {
7360 configurable: true,
7361 enumerable: false,
7362 get: function () {
7363 return true;
7364 },
7365 set: undefined
7366 });
7367 return !!a.t;
7368 } catch (e) {
7369 return false;
7370 }
7371 }());
7372
7373 // 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.
7374 var undefMarker = Symbol('undef');
7375 // 23.1.1.1 Map ( [ iterable ] )
7376 var Map = function Map(/* iterable */) {
7377 // 1. If NewTarget is undefined, throw a TypeError exception.
7378 if (!(this instanceof Map)) {
7379 throw new TypeError('Constructor Map requires "new"');
7380 }
7381 // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%MapPrototype%", « [[MapData]] »).
7382 var map = OrdinaryCreateFromConstructor(this, Map.prototype, {
7383 _keys: [],
7384 _values: [],
7385 _size: 0,
7386 _es6Map: true
7387 });
7388
7389 // 3. Set map.[[MapData]] to a new empty List.
7390 // Polyfill.io - This step was done as part of step two.
7391
7392 // 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.
7393 if (!supportsGetters) {
7394 Object.defineProperty(map, 'size', {
7395 configurable: true,
7396 enumerable: false,
7397 writable: true,
7398 value: 0
7399 });
7400 }
7401
7402 // 4. If iterable is not present, let iterable be undefined.
7403 var iterable = arguments.length > 0 ? arguments[0] : undefined;
7404
7405 // 5. If iterable is either undefined or null, return map.
7406 if (iterable === null || iterable === undefined) {
7407 return map;
7408 }
7409
7410 // 6. Let adder be ? Get(map, "set").
7411 var adder = map.set;
7412
7413 // 7. If IsCallable(adder) is false, throw a TypeError exception.
7414 if (!IsCallable(adder)) {
7415 throw new TypeError("Map.prototype.set is not a function");
7416 }
7417
7418 // 8. Let iteratorRecord be ? GetIterator(iterable).
7419 try {
7420 var iteratorRecord = GetIterator(iterable);
7421 // 9. Repeat,
7422 while (true) {
7423 // a. Let next be ? IteratorStep(iteratorRecord).
7424 var next = IteratorStep(iteratorRecord);
7425 // b. If next is false, return map.
7426 if (next === false) {
7427 return map;
7428 }
7429 // c. Let nextItem be ? IteratorValue(next).
7430 var nextItem = IteratorValue(next);
7431 // d. If Type(nextItem) is not Object, then
7432 if (Type(nextItem) !== 'object') {
7433 // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
7434 try {
7435 throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
7436 } catch (error) {
7437 // ii. Return ? IteratorClose(iteratorRecord, error).
7438 return IteratorClose(iteratorRecord, error);
7439 }
7440 }
7441 try {
7442 // Polyfill.io - The try catch accounts for steps: f, h, and j.
7443
7444 // e. Let k be Get(nextItem, "0").
7445 var k = nextItem[0];
7446 // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
7447 // g. Let v be Get(nextItem, "1").
7448 var v = nextItem[1];
7449 // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
7450 // i. Let status be Call(adder, map, « k.[[Value]], v.[[Value]] »).
7451 adder.call(map, k, v);
7452 } catch (e) {
7453 // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
7454 return IteratorClose(iteratorRecord, e);
7455 }
7456 }
7457 } catch (e) {
7458 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
7459 if (Array.isArray(iterable) ||
7460 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
7461 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
7462 (!!iterable.callee)) {
7463 var index;
7464 var length = iterable.length;
7465 for (index = 0; index < length; index++) {
7466 adder.call(map, iterable[index][0], iterable[index][1]);
7467 }
7468 }
7469 }
7470 return map;
7471 };
7472
7473 // 23.1.2.1. Map.prototype
7474 // The initial value of Map.prototype is the intrinsic object %MapPrototype%.
7475 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
7476 Object.defineProperty(Map, 'prototype', {
7477 configurable: false,
7478 enumerable: false,
7479 writable: false,
7480 value: {}
7481 });
7482
7483 // 23.1.2.2 get Map [ @@species ]
7484 if (supportsGetters) {
7485 Object.defineProperty(Map, Symbol.species, {
7486 configurable: true,
7487 enumerable: false,
7488 get: function () {
7489 // 1. Return the this value.
7490 return this;
7491 },
7492 set: undefined
7493 });
7494 } else {
7495 CreateMethodProperty(Map, Symbol.species, Map);
7496 }
7497
7498 // 23.1.3.1 Map.prototype.clear ( )
7499 CreateMethodProperty(Map.prototype, 'clear', function clear() {
7500 // 1. Let M be the this value.
7501 var M = this;
7502 // 2. If Type(M) is not Object, throw a TypeError exception.
7503 if (Type(M) !== 'object') {
7504 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
7505 }
7506 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
7507 if (M._es6Map !== true) {
7508 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
7509 }
7510 // 4. Let entries be the List that is M.[[MapData]].
7511 var entries = M._keys;
7512 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
7513 for (var i = 0; i < entries.length; i++) {
7514 // 5.a. Set p.[[Key]] to empty.
7515 M._keys[i] = undefMarker;
7516 // 5.b. Set p.[[Value]] to empty.
7517 M._values[i] = undefMarker;
7518 }
7519 this._size = 0;
7520 if (!supportsGetters) {
7521 this.size = this._size;
7522 }
7523 // 6. Return undefined.
7524 return undefined;
7525 }
7526 );
7527
7528 // 23.1.3.2. Map.prototype.constructor
7529 CreateMethodProperty(Map.prototype, 'constructor', Map);
7530
7531 // 23.1.3.3. Map.prototype.delete ( key )
7532 CreateMethodProperty(Map.prototype, 'delete', function (key) {
7533 // 1. Let M be the this value.
7534 var M = this;
7535 // 2. If Type(M) is not Object, throw a TypeError exception.
7536 if (Type(M) !== 'object') {
7537 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
7538 }
7539 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
7540 if (M._es6Map !== true) {
7541 throw new TypeError('Method Map.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
7542 }
7543 // 4. Let entries be the List that is M.[[MapData]].
7544 var entries = M._keys;
7545 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
7546 for (var i = 0; i < entries.length; i++) {
7547 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
7548 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
7549 // i. Set p.[[Key]] to empty.
7550 this._keys[i] = undefMarker;
7551 // ii. Set p.[[Value]] to empty.
7552 this._values[i] = undefMarker;
7553 this._size = --this._size;
7554 if (!supportsGetters) {
7555 this.size = this._size;
7556 }
7557 // iii. Return true.
7558 return true;
7559 }
7560 }
7561 // 6. Return false.
7562 return false;
7563 }
7564 );
7565
7566 // 23.1.3.4. Map.prototype.entries ( )
7567 CreateMethodProperty(Map.prototype, 'entries', function entries () {
7568 // 1. Let M be the this value.
7569 var M = this;
7570 // 2. Return ? CreateMapIterator(M, "key+value").
7571 return CreateMapIterator(M, 'key+value');
7572 }
7573 );
7574
7575 // 23.1.3.5. Map.prototype.forEach ( callbackfn [ , thisArg ] )
7576 CreateMethodProperty(Map.prototype, 'forEach', function (callbackFn) {
7577 // 1. Let M be the this value.
7578 var M = this;
7579 // 2. If Type(M) is not Object, throw a TypeError exception.
7580 if (Type(M) !== 'object') {
7581 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
7582 }
7583 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
7584 if (M._es6Map !== true) {
7585 throw new TypeError('Method Map.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(M));
7586 }
7587 // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
7588 if (!IsCallable(callbackFn)) {
7589 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
7590 }
7591 // 5. If thisArg is present, let T be thisArg; else let T be undefined.
7592 if (arguments[1]) {
7593 var T = arguments[1];
7594 }
7595 // 6. Let entries be the List that is M.[[MapData]].
7596 var entries = M._keys;
7597 // 7. For each Record {[[Key]], [[Value]]} e that is an element of entries, in original key insertion order, do
7598 for (var i = 0; i < entries.length; i++) {
7599 // a. If e.[[Key]] is not empty, then
7600 if (M._keys[i] !== undefMarker && M._values[i] !== undefMarker ) {
7601 // i. Perform ? Call(callbackfn, T, « e.[[Value]], e.[[Key]], M »).
7602 callbackFn.call(T, M._values[i], M._keys[i], M);
7603 }
7604 }
7605 // 8. Return undefined.
7606 return undefined;
7607 }
7608 );
7609
7610 // 23.1.3.6. Map.prototype.get ( key )
7611 CreateMethodProperty(Map.prototype, 'get', function get(key) {
7612 // 1. Let M be the this value.
7613 var M = this;
7614 // 2. If Type(M) is not Object, throw a TypeError exception.
7615 if (Type(M) !== 'object') {
7616 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
7617 }
7618 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
7619 if (M._es6Map !== true) {
7620 throw new TypeError('Method Map.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
7621 }
7622 // 4. Let entries be the List that is M.[[MapData]].
7623 var entries = M._keys;
7624 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
7625 for (var i = 0; i < entries.length; i++) {
7626 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return p.[[Value]].
7627 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
7628 return M._values[i];
7629 }
7630 }
7631 // 6. Return undefined.
7632 return undefined;
7633 });
7634
7635 // 23.1.3.7. Map.prototype.has ( key )
7636 CreateMethodProperty(Map.prototype, 'has', function has (key) {
7637 // 1. Let M be the this value.
7638 var M = this;
7639 // 2. If Type(M) is not Object, throw a TypeError exception.
7640 if (typeof M !== 'object') {
7641 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
7642 }
7643 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
7644 if (M._es6Map !== true) {
7645 throw new TypeError('Method Map.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
7646 }
7647 // 4. Let entries be the List that is M.[[MapData]].
7648 var entries = M._keys;
7649 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
7650 for (var i = 0; i < entries.length; i++) {
7651 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, return true.
7652 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
7653 return true;
7654 }
7655 }
7656 // 6. Return false.
7657 return false;
7658 });
7659
7660 // 23.1.3.8. Map.prototype.keys ( )
7661 CreateMethodProperty(Map.prototype, 'keys', function keys () {
7662 // 1. Let M be the this value.
7663 var M = this;
7664 // 2. Return ? CreateMapIterator(M, "key").
7665 return CreateMapIterator(M, "key");
7666 });
7667
7668 // 23.1.3.9. Map.prototype.set ( key, value )
7669 CreateMethodProperty(Map.prototype, 'set', function set(key, value) {
7670 // 1. Let M be the this value.
7671 var M = this;
7672 // 2. If Type(M) is not Object, throw a TypeError exception.
7673 if (Type(M) !== 'object') {
7674 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
7675 }
7676 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
7677 if (M._es6Map !== true) {
7678 throw new TypeError('Method Map.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
7679 }
7680 // 4. Let entries be the List that is M.[[MapData]].
7681 var entries = M._keys;
7682 // 5. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
7683 for (var i = 0; i < entries.length; i++) {
7684 // a. If p.[[Key]] is not empty and SameValueZero(p.[[Key]], key) is true, then
7685 if (M._keys[i] !== undefMarker && SameValueZero(M._keys[i], key)) {
7686 // i. Set p.[[Value]] to value.
7687 M._values[i] = value;
7688 // Return M.
7689 return M;
7690 }
7691 }
7692 // 6. If key is -0, let key be +0.
7693 if (key === -0) {
7694 key = 0;
7695 }
7696 // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
7697 var p = {};
7698 p['[[Key]]'] = key;
7699 p['[[Value]]'] = value;
7700 // 8. Append p as the last element of entries.
7701 M._keys.push(p['[[Key]]']);
7702 M._values.push(p['[[Value]]']);
7703 ++M._size;
7704 if (!supportsGetters) {
7705 M.size = M._size;
7706 }
7707 // 9. Return M.
7708 return M;
7709 });
7710
7711 // 23.1.3.10. get Map.prototype.size
7712 if (supportsGetters) {
7713 Object.defineProperty(Map.prototype, 'size', {
7714 configurable: true,
7715 enumerable: false,
7716 get: function () {
7717 // 1. Let M be the this value.
7718 var M = this;
7719 // 2. If Type(M) is not Object, throw a TypeError exception.
7720 if (Type(M) !== 'object') {
7721 throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
7722 }
7723 // 3. If M does not have a [[MapData]] internal slot, throw a TypeError exception.
7724 if (M._es6Map !== true) {
7725 throw new TypeError('Method Map.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(M));
7726 }
7727 // 4. Let entries be the List that is M.[[MapData]].
7728 var entries = M._keys;
7729 // 5. Let count be 0.
7730 var count = 0;
7731 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
7732 for (var i = 0; i < entries.length; i++) {
7733 // a. If p.[[Key]] is not empty, set count to count+1.
7734 if (M._keys[i] !== undefMarker) {
7735 count = count + 1;
7736 }
7737 }
7738 // 7. Return count.
7739 return count;
7740 },
7741 set: undefined
7742 });
7743 }
7744
7745 // 23.1.3.11. Map.prototype.values ( )
7746 CreateMethodProperty(Map.prototype, 'values', function values () {
7747 // 1. Let M be the this value.
7748 var M = this;
7749 // 2. Return ? CreateMapIterator(M, "value").
7750 return CreateMapIterator(M, 'value');
7751 }
7752 );
7753
7754 // 23.1.3.12. Map.prototype [ @@iterator ] ( )
7755 // The initial value of the @@iterator property is the same function object as the initial value of the entries property.
7756 CreateMethodProperty(Map.prototype, Symbol.iterator, Map.prototype.entries);
7757
7758 // 23.1.3.13. Map.prototype [ @@toStringTag ]
7759 // The initial value of the @@toStringTag property is the String value "Map".
7760 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
7761
7762 // 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.
7763 if (!('name' in Map)) {
7764 // 19.2.4.2 name
7765 Object.defineProperty(Map, 'name', {
7766 configurable: true,
7767 enumerable: false,
7768 writable: false,
7769 value: 'Map'
7770 });
7771 }
7772
7773 // 23.1.5.1. CreateMapIterator ( map, kind )
7774 function CreateMapIterator(map, kind) {
7775 // 1. If Type(map) is not Object, throw a TypeError exception.
7776 if (Type(map) !== 'object') {
7777 throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
7778 }
7779 // 2. If map does not have a [[MapData]] internal slot, throw a TypeError exception.
7780 if (map._es6Map !== true) {
7781 throw new TypeError('createMapIterator called on incompatible receiver ' + Object.prototype.toString.call(map));
7782 }
7783 // 3. Let iterator be ObjectCreate(%MapIteratorPrototype%, « [[Map]], [[MapNextIndex]], [[MapIterationKind]] »).
7784 var iterator = Object.create(MapIteratorPrototype);
7785 // 4. Set iterator.[[Map]] to map.
7786 Object.defineProperty(iterator, '[[Map]]', {
7787 configurable: true,
7788 enumerable: false,
7789 writable: true,
7790 value: map
7791 });
7792 // 5. Set iterator.[[MapNextIndex]] to 0.
7793 Object.defineProperty(iterator, '[[MapNextIndex]]', {
7794 configurable: true,
7795 enumerable: false,
7796 writable: true,
7797 value: 0
7798 });
7799 // 6. Set iterator.[[MapIterationKind]] to kind.
7800 Object.defineProperty(iterator, '[[MapIterationKind]]', {
7801 configurable: true,
7802 enumerable: false,
7803 writable: true,
7804 value: kind
7805 });
7806 // 7. Return iterator.
7807 return iterator;
7808 }
7809
7810 // 23.1.5.2. The %MapIteratorPrototype% Object
7811 var MapIteratorPrototype = {};
7812 // Polyfill.io - We use this as a quick way to check if an object is a Map Iterator instance.
7813 Object.defineProperty(MapIteratorPrototype, 'isMapIterator', {
7814 configurable: false,
7815 enumerable: false,
7816 writable: false,
7817 value: true
7818 });
7819
7820 // 23.1.5.2.1. %MapIteratorPrototype%.next ( )
7821 CreateMethodProperty(MapIteratorPrototype, 'next', function next() {
7822 // 1. Let O be the this value.
7823 var O = this;
7824 // 2. If Type(O) is not Object, throw a TypeError exception.
7825 if (Type(O) !== 'object') {
7826 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
7827 }
7828 // 3. If O does not have all of the internal slots of a Map Iterator Instance (23.1.5.3), throw a TypeError exception.
7829 if (!O.isMapIterator) {
7830 throw new TypeError('Method %MapIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
7831 }
7832 // 4. Let m be O.[[Map]].
7833 var m = O['[[Map]]'];
7834 // 5. Let index be O.[[MapNextIndex]].
7835 var index = O['[[MapNextIndex]]'];
7836 // 6. Let itemKind be O.[[MapIterationKind]].
7837 var itemKind = O['[[MapIterationKind]]'];
7838 // 7. If m is undefined, return CreateIterResultObject(undefined, true).
7839 if (m === undefined) {
7840 return CreateIterResultObject(undefined, true);
7841 }
7842 // 8. Assert: m has a [[MapData]] internal slot.
7843 if (!m._es6Map) {
7844 throw new Error(Object.prototype.toString.call(m) + ' has a [[MapData]] internal slot.');
7845 }
7846 // 9. Let entries be the List that is m.[[MapData]].
7847 var entries = m._keys;
7848 // 10. Let numEntries be the number of elements of entries.
7849 var numEntries = entries.length;
7850 // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
7851 // 12. Repeat, while index is less than numEntries,
7852 while (index < numEntries) {
7853 // a. Let e be the Record {[[Key]], [[Value]]} that is the value of entries[index].
7854 var e = Object.create(null);
7855 e['[[Key]]'] = m._keys[index];
7856 e['[[Value]]'] = m._values[index];
7857 // b. Set index to index+1.
7858 index = index + 1;
7859 // c. Set O.[[MapNextIndex]] to index.
7860 O['[[MapNextIndex]]'] = index;
7861 // d. If e.[[Key]] is not empty, then
7862 if (e['[[Key]]'] !== undefMarker) {
7863 // i. If itemKind is "key", let result be e.[[Key]].
7864 if (itemKind === 'key') {
7865 var result = e['[[Key]]'];
7866 // ii. Else if itemKind is "value", let result be e.[[Value]].
7867 } else if (itemKind === 'value') {
7868 result = e['[[Value]]'];
7869 // iii. Else,
7870 } else {
7871 // 1. Assert: itemKind is "key+value".
7872 if (itemKind !== 'key+value') {
7873 throw new Error();
7874 }
7875 // 2. Let result be CreateArrayFromList(« e.[[Key]], e.[[Value]] »).
7876 result = [
7877 e['[[Key]]'],
7878 e['[[Value]]']
7879 ];
7880 }
7881 // iv. Return CreateIterResultObject(result, false).
7882 return CreateIterResultObject(result, false);
7883 }
7884 }
7885 // 13. Set O.[[Map]] to undefined.
7886 O['[[Map]]'] = undefined;
7887 // 14. Return CreateIterResultObject(undefined, true).
7888 return CreateIterResultObject(undefined, true);
7889 }
7890 );
7891
7892 // 23.1.5.2.2 %MapIteratorPrototype% [ @@toStringTag ]
7893 // The initial value of the @@toStringTag property is the String value "Map Iterator".
7894 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
7895
7896 CreateMethodProperty(MapIteratorPrototype, Symbol.iterator, function iterator() {
7897 return this;
7898 }
7899 );
7900
7901 // Export the object
7902 try {
7903 CreateMethodProperty(global, 'Map', Map);
7904 } catch (e) {
7905 // IE8 throws an error here if we set enumerable to false.
7906 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
7907 global['Map'] = Map;
7908 }
7909}(this));
7910
7911}
7912
7913if (!("Set"in this&&function(){try{var t=new Set([1,2])
7914return 0===Set.length&&2===t.size&&"Symbol"in this&&"iterator"in Symbol&&"function"==typeof t[Symbol.iterator]}catch(e){return!1}}()
7915)) {
7916
7917// Set
7918/* global CreateIterResultObject, CreateMethodProperty, GetIterator, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Symbol */
7919(function (global) {
7920 var supportsGetters = (function () {
7921 try {
7922 var a = {};
7923 Object.defineProperty(a, 't', {
7924 configurable: true,
7925 enumerable: false,
7926 get: function () {
7927 return true;
7928 },
7929 set: undefined
7930 });
7931 return !!a.t;
7932 } catch (e) {
7933 return false;
7934 }
7935 }());
7936
7937 // 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.
7938 var undefMarker = Symbol('undef');
7939 // 23.2.1.1. Set ( [ iterable ] )
7940 var Set = function Set(/* iterable */) {
7941 // 1. If NewTarget is undefined, throw a TypeError exception.
7942 if (!(this instanceof Set)) {
7943 throw new TypeError('Constructor Set requires "new"');
7944 }
7945 // 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%SetPrototype%", « [[SetData]] »).
7946 var set = OrdinaryCreateFromConstructor(this, Set.prototype, {
7947 _values: [],
7948 _size: 0,
7949 _es6Set: true
7950 });
7951
7952 // 3. Set set.[[SetData]] to a new empty List.
7953 // Polyfill.io - This step was done as part of step two.
7954
7955 // 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.
7956 if (!supportsGetters) {
7957 Object.defineProperty(set, 'size', {
7958 configurable: true,
7959 enumerable: false,
7960 writable: true,
7961 value: 0
7962 });
7963 }
7964
7965 // 4. If iterable is not present, let iterable be undefined.
7966 var iterable = arguments.length > 0 ? arguments[0] : undefined;
7967
7968 // 5. If iterable is either undefined or null, return set.
7969 if (iterable === null || iterable === undefined) {
7970 return set;
7971 }
7972
7973 // 6. Let adder be ? Get(set, "add").
7974 var adder = set.add;
7975 // 7. If IsCallable(adder) is false, throw a TypeError exception.
7976 if (!IsCallable(adder)) {
7977 throw new TypeError("Set.prototype.add is not a function");
7978 }
7979
7980 try {
7981 // 8. Let iteratorRecord be ? GetIterator(iterable).
7982 var iteratorRecord = GetIterator(iterable);
7983 // 9. Repeat,
7984 while (true) {
7985 // a. Let next be ? IteratorStep(iteratorRecord).
7986 var next = IteratorStep(iteratorRecord);
7987 // b. If next is false, return set.
7988 if (next === false) {
7989 return set;
7990 }
7991 // c. Let nextValue be ? IteratorValue(next).
7992 var nextValue = IteratorValue(next);
7993 // d. Let status be Call(adder, set, « nextValue.[[Value]] »).
7994 try {
7995 adder.call(set, nextValue);
7996 } catch (e) {
7997 // e. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
7998 return IteratorClose(iteratorRecord, e);
7999 }
8000 }
8001 } catch (e) {
8002 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
8003 if (Array.isArray(iterable) ||
8004 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
8005 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
8006 (!!iterable.callee)) {
8007 var index;
8008 var length = iterable.length;
8009 for (index = 0; index < length; index++) {
8010 adder.call(set, iterable[index]);
8011 }
8012 } else {
8013 throw (e);
8014 }
8015 }
8016 return set;
8017 };
8018
8019 // 23.2.2.1. Set.prototype
8020 // The initial value of Set.prototype is the intrinsic %SetPrototype% object.
8021 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
8022 Object.defineProperty(Set, 'prototype', {
8023 configurable: false,
8024 enumerable: false,
8025 writable: false,
8026 value: {}
8027 });
8028
8029 // 23.2.2.2 get Set [ @@species ]
8030 if (supportsGetters) {
8031 Object.defineProperty(Set, Symbol.species, {
8032 configurable: true,
8033 enumerable: false,
8034 get: function () {
8035 // 1. Return the this value.
8036 return this;
8037 },
8038 set: undefined
8039 });
8040 } else {
8041 CreateMethodProperty(Set, Symbol.species, Set);
8042 }
8043
8044 // 23.2.3.1. Set.prototype.add ( value )
8045 CreateMethodProperty(Set.prototype, 'add', function add(value) {
8046 // 1. Let S be the this value.
8047 var S = this;
8048 // 2. If Type(S) is not Object, throw a TypeError exception.
8049 if (typeof S !== 'object') {
8050 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
8051 }
8052 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
8053 if (S._es6Set !== true) {
8054 throw new TypeError('Method Set.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
8055 }
8056 // 4. Let entries be the List that is S.[[SetData]].
8057 var entries = S._values;
8058 // 5. For each e that is an element of entries, do
8059 for (var i = 0; i < entries.length; i++) {
8060 var e = entries[i];
8061 // a. If e is not empty and SameValueZero(e, value) is true, then
8062 if (e !== undefMarker && SameValueZero(e, value)) {
8063 // i. Return S.
8064 return S;
8065 }
8066 }
8067 // 6. If value is -0, let value be +0.
8068 if (1/value === -Infinity) {
8069 value = 0;
8070 }
8071 // 7. Append value as the last element of entries.
8072 S._values.push(value);
8073
8074 this._size = ++this._size;
8075 if (!supportsGetters) {
8076 this.size = this._size;
8077 }
8078 // 8. Return S.
8079 return S;
8080 });
8081
8082 // 23.2.3.2. Set.prototype.clear ( )
8083 CreateMethodProperty(Set.prototype, 'clear', function clear() {
8084 // 1. Let S be the this value.
8085 var S = this;
8086 // 2. If Type(S) is not Object, throw a TypeError exception.
8087 if (typeof S !== 'object') {
8088 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
8089 }
8090 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
8091 if (S._es6Set !== true) {
8092 throw new TypeError('Method Set.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(S));
8093 }
8094 // 4. Let entries be the List that is S.[[SetData]].
8095 var entries = S._values;
8096 // 5. For each e that is an element of entries, do
8097 for (var i = 0; i < entries.length; i++) {
8098 // a. Replace the element of entries whose value is e with an element whose value is empty.
8099 entries[i] = undefMarker;
8100 }
8101 this._size = 0;
8102 if (!supportsGetters) {
8103 this.size = this._size;
8104 }
8105 // 6. Return undefined.
8106 return undefined;
8107 });
8108
8109 // 23.2.3.3. Set.prototype.constructor
8110 CreateMethodProperty(Set.prototype, 'constructor', Set);
8111
8112 // 23.2.3.4. Set.prototype.delete ( value )
8113 CreateMethodProperty(Set.prototype, 'delete', function (value) {
8114 // 1. Let S be the this value.
8115 var S = this;
8116 // 2. If Type(S) is not Object, throw a TypeError exception.
8117 if (typeof S !== 'object') {
8118 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
8119 }
8120 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
8121 if (S._es6Set !== true) {
8122 throw new TypeError('Method Set.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
8123 }
8124 // 4. Let entries be the List that is S.[[SetData]].
8125 var entries = S._values;
8126 // 5. For each e that is an element of entries, do
8127 for (var i = 0; i < entries.length; i++) {
8128 var e = entries[i];
8129 // a. If e is not empty and SameValueZero(e, value) is true, then
8130 if (e !== undefMarker && SameValueZero(e, value)) {
8131 // i. Replace the element of entries whose value is e with an element whose value is empty.
8132 entries[i] = undefMarker;
8133
8134 this._size = --this._size;
8135 if (!supportsGetters) {
8136 this.size = this._size;
8137 }
8138 // ii. Return true.
8139 return true;
8140 }
8141 }
8142 // 6. Return false.
8143 return false;
8144 }
8145 );
8146
8147 // 23.2.3.5. Set.prototype.entries ( )
8148 CreateMethodProperty(Set.prototype, 'entries', function entries() {
8149 // 1. Let S be the this value.
8150 var S = this;
8151 // 2. Return ? CreateSetIterator(S, "key+value").
8152 return CreateSetIterator(S, 'key+value');
8153 }
8154 );
8155
8156 // 23.2.3.6. Set.prototype.forEach ( callbackfn [ , thisArg ] )
8157 CreateMethodProperty(Set.prototype, 'forEach', function forEach(callbackFn /*[ , thisArg ]*/) {
8158 // 1. Let S be the this value.
8159 var S = this;
8160 // 2. If Type(S) is not Object, throw a TypeError exception.
8161 if (typeof S !== 'object') {
8162 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
8163 }
8164 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
8165 if (S._es6Set !== true) {
8166 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
8167 }
8168 // 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
8169 if (!IsCallable(callbackFn)) {
8170 throw new TypeError(Object.prototype.toString.call(callbackFn) + ' is not a function.');
8171 }
8172 // 5. If thisArg is present, let T be thisArg; else let T be undefined.
8173 if (arguments[1]) {
8174 var T = arguments[1];
8175 }
8176 // 6. Let entries be the List that is S.[[SetData]].
8177 var entries = S._values;
8178 // 7. For each e that is an element of entries, in original insertion order, do
8179 for (var i = 0; i < entries.length; i++) {
8180 var e = entries[i];
8181 // a. If e is not empty, then
8182 if (e !== undefMarker) {
8183 // i. Perform ? Call(callbackfn, T, « e, e, S »).
8184 callbackFn.call(T, e, e, S);
8185 }
8186 }
8187 // 8. Return undefined.
8188 return undefined;
8189 }
8190 );
8191
8192 // 23.2.3.7. Set.prototype.has ( value )
8193 CreateMethodProperty(Set.prototype, 'has', function has(value) {
8194 // 1. Let S be the this value.
8195 var S = this;
8196 // 2. If Type(S) is not Object, throw a TypeError exception.
8197 if (typeof S !== 'object') {
8198 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
8199 }
8200 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
8201 if (S._es6Set !== true) {
8202 throw new TypeError('Method Set.prototype.forEach called on incompatible receiver ' + Object.prototype.toString.call(S));
8203 }
8204 // 4. Let entries be the List that is S.[[SetData]].
8205 var entries = S._values;
8206 // 5. For each e that is an element of entries, do
8207 for (var i = 0; i < entries.length; i++) {
8208 var e = entries[i];
8209 // a. If e is not empty and SameValueZero(e, value) is true, return true.
8210 if (e !== undefMarker && SameValueZero(e, value)) {
8211 return true;
8212 }
8213 }
8214 // 6. Return false.
8215 return false;
8216 }
8217 );
8218
8219 // Polyfill.io - We need to define Set.prototype.values before Set.prototype.keys because keys is a reference to values.
8220 // 23.2.3.10. Set.prototype.values()
8221 var values = function values() {
8222 // 1. Let S be the this value.
8223 var S = this;
8224 // 2. Return ? CreateSetIterator(S, "value").
8225 return CreateSetIterator(S, "value");
8226 };
8227 CreateMethodProperty(Set.prototype, 'values', values);
8228
8229 // 23.2.3.8 Set.prototype.keys ( )
8230 // The initial value of the keys property is the same function object as the initial value of the values property.
8231 CreateMethodProperty(Set.prototype, 'keys', values);
8232
8233 // 23.2.3.9. get Set.prototype.size
8234 if (supportsGetters) {
8235 Object.defineProperty(Set.prototype, 'size', {
8236 configurable: true,
8237 enumerable: false,
8238 get: function () {
8239 // 1. Let S be the this value.
8240 var S = this;
8241 // 2. If Type(S) is not Object, throw a TypeError exception.
8242 if (typeof S !== 'object') {
8243 throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
8244 }
8245 // 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
8246 if (S._es6Set !== true) {
8247 throw new TypeError('Method Set.prototype.size called on incompatible receiver ' + Object.prototype.toString.call(S));
8248 }
8249 // 4. Let entries be the List that is S.[[SetData]].
8250 var entries = S._values;
8251 // 5. Let count be 0.
8252 var count = 0;
8253 // 6. For each e that is an element of entries, do
8254 for (var i = 0; i < entries.length; i++) {
8255 var e = entries[i];
8256 // a. If e is not empty, set count to count+1.
8257 if (e !== undefMarker) {
8258 count = count + 1;
8259 }
8260 }
8261 // 7. Return count.
8262 return count;
8263 },
8264 set: undefined
8265 });
8266 }
8267
8268 // 23.2.3.11. Set.prototype [ @@iterator ] ( )
8269 // The initial value of the @@iterator property is the same function object as the initial value of the values property.
8270 CreateMethodProperty(Set.prototype, Symbol.iterator, values);
8271
8272 // 23.2.3.12. Set.prototype [ @@toStringTag ]
8273 // The initial value of the @@toStringTag property is the String value "Set".
8274 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
8275
8276 // 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.
8277 if (!('name' in Set)) {
8278 // 19.2.4.2 name
8279 Object.defineProperty(Set, 'name', {
8280 configurable: true,
8281 enumerable: false,
8282 writable: false,
8283 value: 'Set'
8284 });
8285 }
8286
8287 // 23.2.5.1. CreateSetIterator ( set, kind )
8288 function CreateSetIterator(set, kind) {
8289 // 1. If Type(set) is not Object, throw a TypeError exception.
8290 if (typeof set !== 'object') {
8291 throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
8292 }
8293 // 2. If set does not have a [[SetData]] internal slot, throw a TypeError exception.
8294 if (set._es6Set !== true) {
8295 throw new TypeError('createSetIterator called on incompatible receiver ' + Object.prototype.toString.call(set));
8296 }
8297 // 3. Let iterator be ObjectCreate(%SetIteratorPrototype%, « [[IteratedSet]], [[SetNextIndex]], [[SetIterationKind]] »).
8298 var iterator = Object.create(SetIteratorPrototype);
8299 // 4. Set iterator.[[IteratedSet]] to set.
8300 Object.defineProperty(iterator, '[[IteratedSet]]', {
8301 configurable: true,
8302 enumerable: false,
8303 writable: true,
8304 value: set
8305 });
8306 // 5. Set iterator.[[SetNextIndex]] to 0.
8307 Object.defineProperty(iterator, '[[SetNextIndex]]', {
8308 configurable: true,
8309 enumerable: false,
8310 writable: true,
8311 value: 0
8312 });
8313 // 6. Set iterator.[[SetIterationKind]] to kind.
8314 Object.defineProperty(iterator, '[[SetIterationKind]]', {
8315 configurable: true,
8316 enumerable: false,
8317 writable: true,
8318 value: kind
8319 });
8320 // 7. Return iterator.
8321 return iterator;
8322 }
8323
8324 // 23.2.5.2. The %SetIteratorPrototype% Object
8325 var SetIteratorPrototype = {};
8326 //Polyfill.io - We add this property to help us identify what is a set iterator.
8327 Object.defineProperty(SetIteratorPrototype, 'isSetIterator', {
8328 configurable: false,
8329 enumerable: false,
8330 writable: false,
8331 value: true
8332 });
8333
8334 // 23.2.5.2.1. %SetIteratorPrototype%.next ( )
8335 CreateMethodProperty(SetIteratorPrototype, 'next', function next() {
8336 // 1. Let O be the this value.
8337 var O = this;
8338 // 2. If Type(O) is not Object, throw a TypeError exception.
8339 if (typeof O !== 'object') {
8340 throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
8341 }
8342 // 3. If O does not have all of the internal slots of a Set Iterator Instance (23.2.5.3), throw a TypeError exception.
8343 if (!O.isSetIterator) {
8344 throw new TypeError('Method %SetIteratorPrototype%.next called on incompatible receiver ' + Object.prototype.toString.call(O));
8345 }
8346 // 4. Let s be O.[[IteratedSet]].
8347 var s = O['[[IteratedSet]]'];
8348 // 5. Let index be O.[[SetNextIndex]].
8349 var index = O['[[SetNextIndex]]'];
8350 // 6. Let itemKind be O.[[SetIterationKind]].
8351 var itemKind = O['[[SetIterationKind]]'];
8352 // 7. If s is undefined, return CreateIterResultObject(undefined, true).
8353 if (s === undefined) {
8354 return CreateIterResultObject(undefined, true);
8355 }
8356 // 8. Assert: s has a [[SetData]] internal slot.
8357 if (!s._es6Set) {
8358 throw new Error(Object.prototype.toString.call(s) + ' does not have [[SetData]] internal slot.');
8359 }
8360 // 9. Let entries be the List that is s.[[SetData]].
8361 var entries = s._values;
8362 // 10. Let numEntries be the number of elements of entries.
8363 var numEntries = entries.length;
8364 // 11. NOTE: numEntries must be redetermined each time this method is evaluated.
8365 // 12. Repeat, while index is less than numEntries,
8366 while (index < numEntries) {
8367 // a. Let e be entries[index].
8368 var e = entries[index];
8369 // b. Set index to index+1.
8370 index = index + 1;
8371 // c. Set O.[[SetNextIndex]] to index.
8372 O['[[SetNextIndex]]'] = index;
8373 // d. If e is not empty, then
8374 if (e !== undefMarker) {
8375 // i. If itemKind is "key+value", then
8376 if (itemKind === 'key+value') {
8377 // 1. Return CreateIterResultObject(CreateArrayFromList(« e, e »), false).
8378 return CreateIterResultObject([e, e], false);
8379 }
8380 // ii. Return CreateIterResultObject(e, false).
8381 return CreateIterResultObject(e, false);
8382 }
8383 }
8384 // 13. Set O.[[IteratedSet]] to undefined.
8385 O['[[IteratedSet]]'] = undefined;
8386 // 14. Return CreateIterResultObject(undefined, true).
8387 return CreateIterResultObject(undefined, true);
8388 });
8389
8390 // 23.2.5.2.2. %SetIteratorPrototype% [ @@toStringTag ]
8391 // The initial value of the @@toStringTag property is the String value "Set Iterator".
8392 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
8393
8394 CreateMethodProperty(SetIteratorPrototype, Symbol.iterator, function iterator() {
8395 return this;
8396 }
8397 );
8398
8399 // Export the object
8400 try {
8401 CreateMethodProperty(global, 'Set', Set);
8402 } catch (e) {
8403 // IE8 throws an error here if we set enumerable to false.
8404 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
8405 global['Set'] = Set;
8406 }
8407
8408}(this));
8409
8410}
8411
8412if (!("from"in Array&&function(){try{return Array.from({length:-Infinity}),!0}catch(r){return!1}}()
8413)) {
8414
8415// Array.from
8416/* globals
8417 IsCallable, GetMethod, Symbol, IsConstructor, Construct, ArrayCreate, GetIterator, IteratorClose,
8418 ToString, IteratorStep, IteratorValue, Call, CreateDataPropertyOrThrow, ToObject, ToLength, Get, CreateMethodProperty
8419*/
8420(function () {
8421 var toString = Object.prototype.toString;
8422 var stringMatch = String.prototype.match;
8423 // A cross-realm friendly way to detect if a value is a String object or literal.
8424 function isString(value) {
8425 if (typeof value === 'string') { return true; }
8426 if (typeof value !== 'object') { return false; }
8427 return toString.call(value) === '[object String]';
8428 }
8429
8430 // 22.1.2.1. Array.from ( items [ , mapfn [ , thisArg ] ] )
8431 CreateMethodProperty(Array, 'from', function from(items /* [ , mapfn [ , thisArg ] ] */) { // eslint-disable-line no-undef
8432 // 1. Let C be the this value.
8433 var C = this;
8434 // 2. If mapfn is undefined, let mapping be false.
8435 var mapfn = arguments.length > 1 ? arguments[1] : undefined;
8436 if (mapfn === undefined) {
8437 var mapping = false;
8438 // 3. Else,
8439 } else {
8440 // a. If IsCallable(mapfn) is false, throw a TypeError exception.
8441 if (IsCallable(mapfn) === false) {
8442 throw new TypeError(Object.prototype.toString.call(mapfn) + ' is not a function.');
8443 }
8444 // b. If thisArg is present, let T be thisArg; else let T be undefined.
8445 var thisArg = arguments.length > 2 ? arguments[2] : undefined;
8446 if (thisArg !== undefined) {
8447 var T = thisArg;
8448 } else {
8449 T = undefined;
8450 }
8451 // c. Let mapping be true.
8452 mapping = true;
8453
8454 }
8455 // 4. Let usingIterator be ? GetMethod(items, @@iterator).
8456 var usingIterator = GetMethod(items, Symbol.iterator);
8457 // 5. If usingIterator is not undefined, then
8458 if (usingIterator !== undefined) {
8459 // a. If IsConstructor(C) is true, then
8460 if (IsConstructor(C)) {
8461 // i. Let A be ? Construct(C).
8462 var A = Construct(C);
8463 // b. Else,
8464 } else {
8465 // i. Let A be ! ArrayCreate(0).
8466 A = ArrayCreate(0);
8467 }
8468 // c. Let iteratorRecord be ? GetIterator(items, usingIterator).
8469 var iteratorRecord = GetIterator(items, usingIterator);
8470 // d. Let k be 0.
8471 var k = 0;
8472 // e. Repeat,
8473 while (true) {
8474 // i. If k ≥ 2^53-1, then
8475 if (k >= (Math.pow(2, 53) - 1)) {
8476 // 1. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
8477 var error = new TypeError('Iteration count can not be greater than or equal 9007199254740991.');
8478 // 2. Return ? IteratorClose(iteratorRecord, error).
8479 return IteratorClose(iteratorRecord, error);
8480 }
8481 // ii. Let Pk be ! ToString(k).
8482 var Pk = ToString(k);
8483 // iii. Let next be ? IteratorStep(iteratorRecord).
8484 var next = IteratorStep(iteratorRecord);
8485 // iv. If next is false, then
8486 if (next === false) {
8487 // 1. Perform ? Set(A, "length", k, true).
8488 A["length"] = k;
8489 // 2. Return A.
8490 return A;
8491 }
8492 // v. Let nextValue be ? IteratorValue(next).
8493 var nextValue = IteratorValue(next);
8494 // vi. If mapping is true, then
8495 if (mapping) {
8496 try {
8497 // Polyfill.io - The try catch accounts for step 2.
8498 // 1. Let mappedValue be Call(mapfn, T, « nextValue, k »).
8499 var mappedValue = Call(mapfn, T, [nextValue, k]);
8500 // 2. If mappedValue is an abrupt completion, return ? IteratorClose(iteratorRecord, mappedValue).
8501 // 3. Let mappedValue be mappedValue.[[Value]].
8502 } catch (e) {
8503 return IteratorClose(iteratorRecord, e);
8504 }
8505
8506 // vii. Else, let mappedValue be nextValue.
8507 } else {
8508 mappedValue = nextValue;
8509 }
8510 try {
8511 // Polyfill.io - The try catch accounts for step ix.
8512 // viii. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, mappedValue).
8513 CreateDataPropertyOrThrow(A, Pk, mappedValue);
8514 // ix. If defineStatus is an abrupt completion, return ? IteratorClose(iteratorRecord, defineStatus).
8515 } catch (e) {
8516 return IteratorClose(iteratorRecord, e);
8517 }
8518 // x. Increase k by 1.
8519 k = k + 1;
8520 }
8521 }
8522 // 6. NOTE: items is not an Iterable so assume it is an array-like object.
8523 // 7. Let arrayLike be ! ToObject(items).
8524 // Polyfill.io - For Strings we need to split astral symbols into surrogate pairs.
8525 if (isString(items)) {
8526 var arrayLike = stringMatch.call(items, /[\uD800-\uDBFF][\uDC00-\uDFFF]?|[^\uD800-\uDFFF]|./g) || [];
8527 } else {
8528 arrayLike = ToObject(items);
8529 }
8530 // 8. Let len be ? ToLength(? Get(arrayLike, "length")).
8531 var len = ToLength(Get(arrayLike, "length"));
8532 // 9. If IsConstructor(C) is true, then
8533 if (IsConstructor(C)) {
8534 // a. Let A be ? Construct(C, « len »).
8535 A = Construct(C, [len]);
8536 // 10. Else,
8537 } else {
8538 // a. Let A be ? ArrayCreate(len).
8539 A = ArrayCreate(len);
8540 }
8541 // 11. Let k be 0.
8542 k = 0;
8543 // 12. Repeat, while k < len
8544 while (k < len) {
8545 // a. Let Pk be ! ToString(k).
8546 Pk = ToString(k);
8547 // b. Let kValue be ? Get(arrayLike, Pk).
8548 var kValue = Get(arrayLike, Pk);
8549 // c. If mapping is true, then
8550 if (mapping === true) {
8551 // i. Let mappedValue be ? Call(mapfn, T, « kValue, k »).
8552 mappedValue = Call(mapfn, T, [kValue, k]);
8553 // d. Else, let mappedValue be kValue.
8554 } else {
8555 mappedValue = kValue;
8556 }
8557 // e. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue).
8558 CreateDataPropertyOrThrow(A, Pk, mappedValue);
8559 // f. Increase k by 1.
8560 k = k + 1;
8561 }
8562 // 13. Perform ? Set(A, "length", len, true).
8563 A["length"] = len;
8564 // 14. Return A.
8565 return A;
8566 });
8567}());
8568
8569}
8570
8571if (!("Symbol"in this&&"split"in this.Symbol
8572)) {
8573
8574// Symbol.split
8575/* global Symbol */
8576Object.defineProperty(Symbol, 'split', { value: Symbol('split') });
8577
8578}
8579
8580if (!("Symbol"in this&&"toPrimitive"in this.Symbol
8581)) {
8582
8583// Symbol.toPrimitive
8584/* global Symbol */
8585Object.defineProperty(Symbol, 'toPrimitive', { value: Symbol('toPrimitive') });
8586
8587}
8588
8589if (!("Symbol"in this&&"toStringTag"in this.Symbol
8590)) {
8591
8592// Symbol.toStringTag
8593/* global Symbol */
8594Object.defineProperty(Symbol, 'toStringTag', {
8595 value: Symbol('toStringTag')
8596});
8597
8598}
8599
8600
8601// _Iterator
8602/* global Symbol */
8603// A modification of https://github.com/medikoo/es6-iterator
8604// Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
8605
8606var Iterator = (function () { // eslint-disable-line no-unused-vars
8607 var clear = function () {
8608 this.length = 0;
8609 return this;
8610 };
8611 var callable = function (fn) {
8612 if (typeof fn !== 'function') throw new TypeError(fn + " is not a function");
8613 return fn;
8614 };
8615
8616 var Iterator = function (list, context) {
8617 if (!(this instanceof Iterator)) {
8618 return new Iterator(list, context);
8619 }
8620 Object.defineProperties(this, {
8621 __list__: {
8622 writable: true,
8623 value: list
8624 },
8625 __context__: {
8626 writable: true,
8627 value: context
8628 },
8629 __nextIndex__: {
8630 writable: true,
8631 value: 0
8632 }
8633 });
8634 if (!context) return;
8635 callable(context.on);
8636 context.on('_add', this._onAdd.bind(this));
8637 context.on('_delete', this._onDelete.bind(this));
8638 context.on('_clear', this._onClear.bind(this));
8639 };
8640
8641 Object.defineProperties(Iterator.prototype, Object.assign({
8642 constructor: {
8643 value: Iterator,
8644 configurable: true,
8645 enumerable: false,
8646 writable: true
8647 },
8648 _next: {
8649 value: function () {
8650 var i;
8651 if (!this.__list__) return;
8652 if (this.__redo__) {
8653 i = this.__redo__.shift();
8654 if (i !== undefined) return i;
8655 }
8656 if (this.__nextIndex__ < this.__list__.length) return this.__nextIndex__++;
8657 this._unBind();
8658 },
8659 configurable: true,
8660 enumerable: false,
8661 writable: true
8662 },
8663 next: {
8664 value: function () {
8665 return this._createResult(this._next());
8666 },
8667 configurable: true,
8668 enumerable: false,
8669 writable: true
8670 },
8671 _createResult: {
8672 value: function (i) {
8673 if (i === undefined) return {
8674 done: true,
8675 value: undefined
8676 };
8677 return {
8678 done: false,
8679 value: this._resolve(i)
8680 };
8681 },
8682 configurable: true,
8683 enumerable: false,
8684 writable: true
8685 },
8686 _resolve: {
8687 value: function (i) {
8688 return this.__list__[i];
8689 },
8690 configurable: true,
8691 enumerable: false,
8692 writable: true
8693 },
8694 _unBind: {
8695 value: function () {
8696 this.__list__ = null;
8697 delete this.__redo__;
8698 if (!this.__context__) return;
8699 this.__context__.off('_add', this._onAdd.bind(this));
8700 this.__context__.off('_delete', this._onDelete.bind(this));
8701 this.__context__.off('_clear', this._onClear.bind(this));
8702 this.__context__ = null;
8703 },
8704 configurable: true,
8705 enumerable: false,
8706 writable: true
8707 },
8708 toString: {
8709 value: function () {
8710 return '[object Iterator]';
8711 },
8712 configurable: true,
8713 enumerable: false,
8714 writable: true
8715 }
8716 }, {
8717 _onAdd: {
8718 value: function (index) {
8719 if (index >= this.__nextIndex__) return;
8720 ++this.__nextIndex__;
8721 if (!this.__redo__) {
8722 Object.defineProperty(this, '__redo__', {
8723 value: [index],
8724 configurable: true,
8725 enumerable: false,
8726 writable: false
8727 });
8728 return;
8729 }
8730 this.__redo__.forEach(function (redo, i) {
8731 if (redo >= index) this.__redo__[i] = ++redo;
8732 }, this);
8733 this.__redo__.push(index);
8734 },
8735 configurable: true,
8736 enumerable: false,
8737 writable: true
8738 },
8739 _onDelete: {
8740 value: function (index) {
8741 var i;
8742 if (index >= this.__nextIndex__) return;
8743 --this.__nextIndex__;
8744 if (!this.__redo__) return;
8745 i = this.__redo__.indexOf(index);
8746 if (i !== -1) this.__redo__.splice(i, 1);
8747 this.__redo__.forEach(function (redo, i) {
8748 if (redo > index) this.__redo__[i] = --redo;
8749 }, this);
8750 },
8751 configurable: true,
8752 enumerable: false,
8753 writable: true
8754 },
8755 _onClear: {
8756 value: function () {
8757 if (this.__redo__) clear.call(this.__redo__);
8758 this.__nextIndex__ = 0;
8759 },
8760 configurable: true,
8761 enumerable: false,
8762 writable: true
8763 }
8764 }));
8765
8766 Object.defineProperty(Iterator.prototype, Symbol.iterator, {
8767 value: function () {
8768 return this;
8769 },
8770 configurable: true,
8771 enumerable: false,
8772 writable: true
8773 });
8774 Object.defineProperty(Iterator.prototype, Symbol.toStringTag, {
8775 value: 'Iterator',
8776 configurable: false,
8777 enumerable: false,
8778 writable: true
8779 });
8780
8781 return Iterator;
8782}());
8783
8784// _ArrayIterator
8785/* global Iterator */
8786// A modification of https://github.com/medikoo/es6-iterator
8787// Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
8788
8789var ArrayIterator = (function() { // eslint-disable-line no-unused-vars
8790
8791 var ArrayIterator = function(arr, kind) {
8792 if (!(this instanceof ArrayIterator)) return new ArrayIterator(arr, kind);
8793 Iterator.call(this, arr);
8794 if (!kind) kind = 'value';
8795 else if (String.prototype.includes.call(kind, 'key+value')) kind = 'key+value';
8796 else if (String.prototype.includes.call(kind, 'key')) kind = 'key';
8797 else kind = 'value';
8798 Object.defineProperty(this, '__kind__', {
8799 value: kind,
8800 configurable: false,
8801 enumerable: false,
8802 writable: false
8803 });
8804 };
8805 if (Object.setPrototypeOf) Object.setPrototypeOf(ArrayIterator, Iterator.prototype);
8806
8807 ArrayIterator.prototype = Object.create(Iterator.prototype, {
8808 constructor: {
8809 value: ArrayIterator,
8810 configurable: true,
8811 enumerable: false,
8812 writable: true
8813 },
8814 _resolve: {
8815 value: function(i) {
8816 if (this.__kind__ === 'value') return this.__list__[i];
8817 if (this.__kind__ === 'key+value') return [i, this.__list__[i]];
8818 return i;
8819 },
8820 configurable: true,
8821 enumerable: false,
8822 writable: true
8823 },
8824 toString: {
8825 value: function() {
8826 return '[object Array Iterator]';
8827 },
8828 configurable: true,
8829 enumerable: false,
8830 writable: true
8831 }
8832 });
8833
8834 return ArrayIterator;
8835}());
8836if (!("Symbol"in this&&"iterator"in this.Symbol&&!!Array.prototype.entries
8837)) {
8838
8839// Array.prototype.entries
8840/* global CreateMethodProperty, ToObject */
8841// 22.1.3.4. Array.prototype.entries ( )
8842CreateMethodProperty(Array.prototype, 'entries', function entries() {
8843 // 1. Let O be ? ToObject(this value).
8844 var O = ToObject(this);
8845 // 2. Return CreateArrayIterator(O, "key+value").
8846 // TODO: Add CreateArrayIterator
8847 return new ArrayIterator(O, 'key+value');
8848});
8849
8850}
8851
8852if (!("Symbol"in this&&"iterator"in this.Symbol&&!!Array.prototype.keys
8853)) {
8854
8855// Array.prototype.keys
8856/* global CreateMethodProperty, ToObject */
8857// 22.1.3.14. Array.prototype.keys ( )
8858CreateMethodProperty(Array.prototype, 'keys', function keys() {
8859 // 1. Let O be ? ToObject(this value).
8860 var O = ToObject(this);
8861 // 2. Return CreateArrayIterator(O, "key").
8862 // TODO: Add CreateArrayIterator.
8863 return new ArrayIterator(O, 'key');
8864});
8865
8866}
8867
8868if (!("values"in Array.prototype
8869)) {
8870
8871// Array.prototype.values
8872/* global CreateMethodProperty, Symbol, ToObject */
8873// 22.1.3.30/ Array.prototype.values ( )
8874// Polyfill.io - Firefox, Chrome and Opera have Array.prototype[Symbol.iterator], which is the exact same function as Array.prototype.values.
8875if ('Symbol' in this && 'iterator' in Symbol && typeof Array.prototype[Symbol.iterator] === 'function') {
8876 CreateMethodProperty(Array.prototype, 'values', Array.prototype[Symbol.iterator]);
8877} else {
8878 CreateMethodProperty(Array.prototype, 'values', function values () {
8879 // 1. Let O be ? ToObject(this value).
8880 var O = ToObject(this);
8881 // 2. Return CreateArrayIterator(O, "value").
8882 // TODO: Add CreateArrayIterator
8883 return new ArrayIterator(O, 'value');
8884 });
8885}
8886
8887}
8888
8889if (!("Symbol"in this&&"iterator"in this.Symbol&&!!Array.prototype[Symbol.iterator]
8890)) {
8891
8892// Array.prototype.@@iterator
8893/* global Symbol, CreateMethodProperty */
8894// 22.1.3.31. Array.prototype [ @@iterator ] ( )
8895// The initial value of the @@iterator property is the same function object as the initial value of the Array.prototype.values property.
8896CreateMethodProperty(Array.prototype, Symbol.iterator, Array.prototype.values);
8897
8898}
8899
8900
8901// _StringIterator
8902// A modification of https://github.com/medikoo/es6-iterator
8903// Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com)
8904
8905/* global Iterator */
8906
8907var StringIterator = (function() { // eslint-disable-line no-unused-vars
8908
8909 var StringIterator = function (str) {
8910 if (!(this instanceof StringIterator)) return new StringIterator(str);
8911 str = String(str);
8912 Iterator.call(this, str);
8913 Object.defineProperty(this, '__length__', {
8914 value: str.length,
8915 configurable: false,
8916 enumerable: false,
8917 writable: false
8918 });
8919 };
8920 if (Object.setPrototypeOf) Object.setPrototypeOf(StringIterator, Iterator);
8921
8922 StringIterator.prototype = Object.create(Iterator.prototype, {
8923 constructor: {
8924 value: StringIterator,
8925 configurable: true,
8926 enumerable: false,
8927 writable: true
8928 },
8929 _next: {
8930 value: function() {
8931 if (!this.__list__) return;
8932 if (this.__nextIndex__ < this.__length__) return this.__nextIndex__++;
8933 this._unBind();
8934 },
8935 configurable: true,
8936 enumerable: false,
8937 writable: true
8938 },
8939 _resolve: {
8940 value: function (i) {
8941 var char = this.__list__[i], code;
8942 if (this.__nextIndex__ === this.__length__) return char;
8943 code = char.charCodeAt(0);
8944 if ((code >= 0xD800) && (code <= 0xDBFF)) return char + this.__list__[this.__nextIndex__++];
8945 return char;
8946 },
8947 configurable: true,
8948 enumerable: false,
8949 writable: true
8950 },
8951 toString: {
8952 value: function() {
8953 return '[object String Iterator]';
8954 },
8955 configurable: true,
8956 enumerable: false,
8957 writable: true
8958 }
8959 });
8960
8961 return StringIterator;
8962}());
8963if (!("Symbol"in this&&"iterator"in this.Symbol&&!!String.prototype[Symbol.iterator]
8964)) {
8965
8966// String.prototype.@@iterator
8967/* global CreateMethodProperty, RequireObjectCoercible, ToString, StringIterator, Symbol */
8968// 21.1.3.29. String.prototype [ @@iterator ] ( )
8969CreateMethodProperty(String.prototype, Symbol.iterator, function () {
8970 // 1. Let O be ? RequireObjectCoercible(this value).
8971 var O = RequireObjectCoercible(this);
8972 // 2. Let S be ? ToString(O).
8973 var S = ToString(O);
8974 // 3. Return CreateStringIterator(S).
8975 // TODO: Add CreateStringIterator.
8976 return new StringIterator(S);
8977});
8978
8979}
8980
8981if (!("Symbol"in this&&"unscopables"in this.Symbol
8982)) {
8983
8984// Symbol.unscopables
8985/* global Symbol */
8986Object.defineProperty(Symbol, 'unscopables', { value: Symbol('unscopables') });
8987
8988}
8989
8990if (!((function(e){"use strict"
8991try{var a=new e.URL("http://example.com")
8992if("href"in a&&"searchParams"in a){var r=new URL("http://example.com")
8993if(r.search="a=1&b=2","http://example.com/?a=1&b=2"===r.href&&(r.search="","http://example.com/"===r.href)){var t=new e.URLSearchParams("a=1"),h=new e.URLSearchParams(t)
8994if("a=1"===String(h))return!0}}return!1}catch(c){return!1}})(this)
8995)) {
8996
8997// URL
8998/* global Symbol */
8999// URL Polyfill
9000// Draft specification: https://url.spec.whatwg.org
9001
9002// Notes:
9003// - Primarily useful for parsing URLs and modifying query parameters
9004// - Should work in IE8+ and everything more modern, with es5.js polyfills
9005
9006(function (global) {
9007 'use strict';
9008
9009 function isSequence(o) {
9010 if (!o) return false;
9011 if ('Symbol' in global && 'iterator' in global.Symbol &&
9012 typeof o[Symbol.iterator] === 'function') return true;
9013 if (Array.isArray(o)) return true;
9014 return false;
9015 }
9016
9017 function toArray(iter) {
9018 return ('from' in Array) ? Array.from(iter) : Array.prototype.slice.call(iter);
9019 }
9020
9021 (function() {
9022
9023 // Browsers may have:
9024 // * No global URL object
9025 // * URL with static methods only - may have a dummy constructor
9026 // * URL with members except searchParams
9027 // * Full URL API support
9028 var origURL = global.URL;
9029 var nativeURL;
9030 try {
9031 if (origURL) {
9032 nativeURL = new global.URL('http://example.com');
9033 if ('searchParams' in nativeURL) {
9034 var url = new URL('http://example.com');
9035 url.search = 'a=1&b=2';
9036 if (url.href === 'http://example.com/?a=1&b=2') {
9037 url.search = '';
9038 if (url.href === 'http://example.com/') {
9039 return;
9040 }
9041 }
9042 }
9043 if (!('href' in nativeURL)) {
9044 nativeURL = undefined;
9045 }
9046 nativeURL = undefined;
9047 }
9048 } catch (_) {}
9049
9050 // NOTE: Doesn't do the encoding/decoding dance
9051 function urlencoded_serialize(pairs) {
9052 var output = '', first = true;
9053 pairs.forEach(function (pair) {
9054 var name = encodeURIComponent(pair.name);
9055 var value = encodeURIComponent(pair.value);
9056 if (!first) output += '&';
9057 output += name + '=' + value;
9058 first = false;
9059 });
9060 return output.replace(/%20/g, '+');
9061 }
9062
9063 // NOTE: Doesn't do the encoding/decoding dance
9064 function urlencoded_parse(input, isindex) {
9065 var sequences = input.split('&');
9066 if (isindex && sequences[0].indexOf('=') === -1)
9067 sequences[0] = '=' + sequences[0];
9068 var pairs = [];
9069 sequences.forEach(function (bytes) {
9070 if (bytes.length === 0) return;
9071 var index = bytes.indexOf('=');
9072 if (index !== -1) {
9073 var name = bytes.substring(0, index);
9074 var value = bytes.substring(index + 1);
9075 } else {
9076 name = bytes;
9077 value = '';
9078 }
9079 name = name.replace(/\+/g, ' ');
9080 value = value.replace(/\+/g, ' ');
9081 pairs.push({ name: name, value: value });
9082 });
9083 var output = [];
9084 pairs.forEach(function (pair) {
9085 output.push({
9086 name: decodeURIComponent(pair.name),
9087 value: decodeURIComponent(pair.value)
9088 });
9089 });
9090 return output;
9091 }
9092
9093 function URLUtils(url) {
9094 if (nativeURL)
9095 return new origURL(url);
9096 var anchor = document.createElement('a');
9097 anchor.href = url;
9098 return anchor;
9099 }
9100
9101 function URLSearchParams(init) {
9102 var $this = this;
9103 this._list = [];
9104
9105 if (init === undefined || init === null) {
9106 // no-op
9107 } else if (init instanceof URLSearchParams) {
9108 // In ES6 init would be a sequence, but special case for ES5.
9109 this._list = urlencoded_parse(String(init));
9110 } else if (typeof init === 'object' && isSequence(init)) {
9111 toArray(init).forEach(function(e) {
9112 if (!isSequence(e)) throw TypeError();
9113 var nv = toArray(e);
9114 if (nv.length !== 2) throw TypeError();
9115 $this._list.push({name: String(nv[0]), value: String(nv[1])});
9116 });
9117 } else if (typeof init === 'object' && init) {
9118 Object.keys(init).forEach(function(key) {
9119 $this._list.push({name: String(key), value: String(init[key])});
9120 });
9121 } else {
9122 init = String(init);
9123 if (init.substring(0, 1) === '?')
9124 init = init.substring(1);
9125 this._list = urlencoded_parse(init);
9126 }
9127
9128 this._url_object = null;
9129 this._setList = function (list) { if (!updating) $this._list = list; };
9130
9131 var updating = false;
9132 this._update_steps = function() {
9133 if (updating) return;
9134 updating = true;
9135
9136 if (!$this._url_object) return;
9137
9138 // Partial workaround for IE issue with 'about:'
9139 if ($this._url_object.protocol === 'about:' &&
9140 $this._url_object.pathname.indexOf('?') !== -1) {
9141 $this._url_object.pathname = $this._url_object.pathname.split('?')[0];
9142 }
9143
9144 $this._url_object.search = urlencoded_serialize($this._list);
9145
9146 updating = false;
9147 };
9148 }
9149
9150
9151 Object.defineProperties(URLSearchParams.prototype, {
9152 append: {
9153 value: function (name, value) {
9154 this._list.push({ name: name, value: value });
9155 this._update_steps();
9156 }, writable: true, enumerable: true, configurable: true
9157 },
9158
9159 'delete': {
9160 value: function (name) {
9161 for (var i = 0; i < this._list.length;) {
9162 if (this._list[i].name === name)
9163 this._list.splice(i, 1);
9164 else
9165 ++i;
9166 }
9167 this._update_steps();
9168 }, writable: true, enumerable: true, configurable: true
9169 },
9170
9171 get: {
9172 value: function (name) {
9173 for (var i = 0; i < this._list.length; ++i) {
9174 if (this._list[i].name === name)
9175 return this._list[i].value;
9176 }
9177 return null;
9178 }, writable: true, enumerable: true, configurable: true
9179 },
9180
9181 getAll: {
9182 value: function (name) {
9183 var result = [];
9184 for (var i = 0; i < this._list.length; ++i) {
9185 if (this._list[i].name === name)
9186 result.push(this._list[i].value);
9187 }
9188 return result;
9189 }, writable: true, enumerable: true, configurable: true
9190 },
9191
9192 has: {
9193 value: function (name) {
9194 for (var i = 0; i < this._list.length; ++i) {
9195 if (this._list[i].name === name)
9196 return true;
9197 }
9198 return false;
9199 }, writable: true, enumerable: true, configurable: true
9200 },
9201
9202 set: {
9203 value: function (name, value) {
9204 var found = false;
9205 for (var i = 0; i < this._list.length;) {
9206 if (this._list[i].name === name) {
9207 if (!found) {
9208 this._list[i].value = value;
9209 found = true;
9210 ++i;
9211 } else {
9212 this._list.splice(i, 1);
9213 }
9214 } else {
9215 ++i;
9216 }
9217 }
9218
9219 if (!found)
9220 this._list.push({ name: name, value: value });
9221
9222 this._update_steps();
9223 }, writable: true, enumerable: true, configurable: true
9224 },
9225
9226 entries: {
9227 value: function() { return new Iterator(this._list, 'key+value'); },
9228 writable: true, enumerable: true, configurable: true
9229 },
9230
9231 keys: {
9232 value: function() { return new Iterator(this._list, 'key'); },
9233 writable: true, enumerable: true, configurable: true
9234 },
9235
9236 values: {
9237 value: function() { return new Iterator(this._list, 'value'); },
9238 writable: true, enumerable: true, configurable: true
9239 },
9240
9241 forEach: {
9242 value: function(callback) {
9243 var thisArg = (arguments.length > 1) ? arguments[1] : undefined;
9244 this._list.forEach(function(pair) {
9245 callback.call(thisArg, pair.value, pair.name);
9246 });
9247
9248 }, writable: true, enumerable: true, configurable: true
9249 },
9250
9251 toString: {
9252 value: function () {
9253 return urlencoded_serialize(this._list);
9254 }, writable: true, enumerable: false, configurable: true
9255 }
9256 });
9257
9258 function Iterator(source, kind) {
9259 var index = 0;
9260 this['next'] = function() {
9261 if (index >= source.length)
9262 return {done: true, value: undefined};
9263 var pair = source[index++];
9264 return {done: false, value:
9265 kind === 'key' ? pair.name :
9266 kind === 'value' ? pair.value :
9267 [pair.name, pair.value]};
9268 };
9269 }
9270
9271 if ('Symbol' in global && 'iterator' in global.Symbol) {
9272 Object.defineProperty(URLSearchParams.prototype, global.Symbol.iterator, {
9273 value: URLSearchParams.prototype.entries,
9274 writable: true, enumerable: true, configurable: true});
9275 Object.defineProperty(Iterator.prototype, global.Symbol.iterator, {
9276 value: function() { return this; },
9277 writable: true, enumerable: true, configurable: true});
9278 }
9279
9280 function URL(url, base) {
9281 if (!(this instanceof global.URL))
9282 throw new TypeError("Failed to construct 'URL': Please use the 'new' operator.");
9283
9284 if (base) {
9285 url = (function () {
9286 if (nativeURL) return new origURL(url, base).href;
9287 var iframe;
9288 try {
9289 var doc;
9290 // Use another document/base tag/anchor for relative URL resolution, if possible
9291 if (Object.prototype.toString.call(window.operamini) === "[object OperaMini]") {
9292 iframe = document.createElement('iframe');
9293 iframe.style.display = 'none';
9294 document.documentElement.appendChild(iframe);
9295 doc = iframe.contentWindow.document;
9296 } else if (document.implementation && document.implementation.createHTMLDocument) {
9297 doc = document.implementation.createHTMLDocument('');
9298 } else if (document.implementation && document.implementation.createDocument) {
9299 doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);
9300 doc.documentElement.appendChild(doc.createElement('head'));
9301 doc.documentElement.appendChild(doc.createElement('body'));
9302 } else if (window.ActiveXObject) {
9303 doc = new window.ActiveXObject('htmlfile');
9304 doc.write('<head><\/head><body><\/body>');
9305 doc.close();
9306 }
9307
9308 if (!doc) throw Error('base not supported');
9309
9310 var baseTag = doc.createElement('base');
9311 baseTag.href = base;
9312 doc.getElementsByTagName('head')[0].appendChild(baseTag);
9313 var anchor = doc.createElement('a');
9314 anchor.href = url;
9315 return anchor.href;
9316 } finally {
9317 if (iframe)
9318 iframe.parentNode.removeChild(iframe);
9319 }
9320 }());
9321 }
9322
9323 // An inner object implementing URLUtils (either a native URL
9324 // object or an HTMLAnchorElement instance) is used to perform the
9325 // URL algorithms. With full ES5 getter/setter support, return a
9326 // regular object For IE8's limited getter/setter support, a
9327 // different HTMLAnchorElement is returned with properties
9328 // overridden
9329
9330 var instance = URLUtils(url || '');
9331
9332 // Detect for ES5 getter/setter support
9333 // (an Object.defineProperties polyfill that doesn't support getters/setters may throw)
9334 var ES5_GET_SET = (function() {
9335 if (!('defineProperties' in Object)) return false;
9336 try {
9337 var obj = {};
9338 Object.defineProperties(obj, { prop: { 'get': function () { return true; } } });
9339 return obj.prop;
9340 } catch (_) {
9341 return false;
9342 }
9343 }());
9344
9345 var self = ES5_GET_SET ? this : document.createElement('a');
9346
9347
9348
9349 var query_object = new URLSearchParams(
9350 instance.search ? instance.search.substring(1) : null);
9351 query_object._url_object = self;
9352
9353 Object.defineProperties(self, {
9354 href: {
9355 get: function () { return instance.href; },
9356 set: function (v) { instance.href = v; tidy_instance(); update_steps(); },
9357 enumerable: true, configurable: true
9358 },
9359 origin: {
9360 get: function () {
9361 if ('origin' in instance) return instance.origin;
9362 return this.protocol + '//' + this.host;
9363 },
9364 enumerable: true, configurable: true
9365 },
9366 protocol: {
9367 get: function () { return instance.protocol; },
9368 set: function (v) { instance.protocol = v; },
9369 enumerable: true, configurable: true
9370 },
9371 username: {
9372 get: function () { return instance.username; },
9373 set: function (v) { instance.username = v; },
9374 enumerable: true, configurable: true
9375 },
9376 password: {
9377 get: function () { return instance.password; },
9378 set: function (v) { instance.password = v; },
9379 enumerable: true, configurable: true
9380 },
9381 host: {
9382 get: function () {
9383 // IE returns default port in |host|
9384 var re = {'http:': /:80$/, 'https:': /:443$/, 'ftp:': /:21$/}[instance.protocol];
9385 return re ? instance.host.replace(re, '') : instance.host;
9386 },
9387 set: function (v) { instance.host = v; },
9388 enumerable: true, configurable: true
9389 },
9390 hostname: {
9391 get: function () { return instance.hostname; },
9392 set: function (v) { instance.hostname = v; },
9393 enumerable: true, configurable: true
9394 },
9395 port: {
9396 get: function () { return instance.port; },
9397 set: function (v) { instance.port = v; },
9398 enumerable: true, configurable: true
9399 },
9400 pathname: {
9401 get: function () {
9402 // IE does not include leading '/' in |pathname|
9403 if (instance.pathname.charAt(0) !== '/') return '/' + instance.pathname;
9404 return instance.pathname;
9405 },
9406 set: function (v) { instance.pathname = v; },
9407 enumerable: true, configurable: true
9408 },
9409 search: {
9410 get: function () { return instance.search; },
9411 set: function (v) {
9412 if (instance.search === v) return;
9413 instance.search = v; tidy_instance(); update_steps();
9414 },
9415 enumerable: true, configurable: true
9416 },
9417 searchParams: {
9418 get: function () { return query_object; },
9419 enumerable: true, configurable: true
9420 },
9421 hash: {
9422 get: function () { return instance.hash; },
9423 set: function (v) { instance.hash = v; tidy_instance(); },
9424 enumerable: true, configurable: true
9425 },
9426 toString: {
9427 value: function() { return instance.toString(); },
9428 enumerable: false, configurable: true
9429 },
9430 valueOf: {
9431 value: function() { return instance.valueOf(); },
9432 enumerable: false, configurable: true
9433 }
9434 });
9435
9436 function tidy_instance() {
9437 var href = instance.href.replace(/#$|\?$|\?(?=#)/g, '');
9438 if (instance.href !== href)
9439 instance.href = href;
9440 }
9441
9442 function update_steps() {
9443 query_object._setList(instance.search ? urlencoded_parse(instance.search.substring(1)) : []);
9444 query_object._update_steps();
9445 }
9446
9447 return self;
9448 }
9449
9450 if (origURL) {
9451 for (var i in origURL) {
9452 if (origURL.hasOwnProperty(i) && typeof origURL[i] === 'function')
9453 URL[i] = origURL[i];
9454 }
9455 }
9456
9457 global.URL = URL;
9458 global.URLSearchParams = URLSearchParams;
9459 }());
9460
9461 // Patch native URLSearchParams constructor to handle sequences/records
9462 // if necessary.
9463 (function() {
9464 if (new global.URLSearchParams([['a', 1]]).get('a') === '1' &&
9465 new global.URLSearchParams({a: 1}).get('a') === '1')
9466 return;
9467 var orig = global.URLSearchParams;
9468 global.URLSearchParams = function(init) {
9469 if (init && typeof init === 'object' && isSequence(init)) {
9470 var o = new orig();
9471 toArray(init).forEach(function(e) {
9472 if (!isSequence(e)) throw TypeError();
9473 var nv = toArray(e);
9474 if (nv.length !== 2) throw TypeError();
9475 o.append(nv[0], nv[1]);
9476 });
9477 return o;
9478 } else if (init && typeof init === 'object') {
9479 o = new orig();
9480 Object.keys(init).forEach(function(key) {
9481 o.set(key, init[key]);
9482 });
9483 return o;
9484 } else {
9485 return new orig(init);
9486 }
9487 };
9488 }());
9489
9490}(self));
9491
9492}
9493
9494if (!((function(e){try{if("WeakMap"in e&&0===WeakMap.length){var t={},a=new WeakMap([[t,"test"]])
9495return"test"===a.get(t)&&!1===a["delete"](0)}return!1}catch(n){return!1}})(this)
9496)) {
9497
9498// WeakMap
9499/* globals Symbol, OrdinaryCreateFromConstructor, IsCallable, GetIterator, IteratorStep, IteratorValue, IteratorClose, Get, Call, CreateMethodProperty, Type, SameValue */
9500(function (global) {
9501 // 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.
9502 var undefMarker = Symbol('undef');
9503 // 23.3.1.1 WeakMap ( [ iterable ] )
9504 var WeakMap = function WeakMap(/* iterable */) {
9505 // 1. If NewTarget is undefined, throw a TypeError exception.
9506 if (!(this instanceof WeakMap)) {
9507 throw new TypeError('Constructor WeakMap requires "new"');
9508 }
9509 // 2. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakMapPrototype%", « [[WeakMapData]] »).
9510 var map = OrdinaryCreateFromConstructor(this, WeakMap.prototype, {
9511 _keys: [],
9512 _values: [],
9513 _es6WeakMap: true
9514 });
9515
9516 // 3. Set map.[[WeakMapData]] to a new empty List.
9517 // Polyfill.io - This step was done as part of step two.
9518
9519 // 4. If iterable is not present, let iterable be undefined.
9520 var iterable = arguments.length > 0 ? arguments[0] : undefined;
9521
9522 // 5. If iterable is either undefined or null, return map.
9523 if (iterable === null || iterable === undefined) {
9524 return map;
9525 }
9526
9527 // 6. Let adder be ? Get(map, "set").
9528 var adder = Get(map, "set");
9529
9530 // 7. If IsCallable(adder) is false, throw a TypeError exception.
9531 if (!IsCallable(adder)) {
9532 throw new TypeError("WeakMap.prototype.set is not a function");
9533 }
9534
9535 // 8. Let iteratorRecord be ? GetIterator(iterable).
9536 try {
9537 var iteratorRecord = GetIterator(iterable);
9538 // 9. Repeat,
9539 while (true) {
9540 // a. Let next be ? IteratorStep(iteratorRecord).
9541 var next = IteratorStep(iteratorRecord);
9542 // b. If next is false, return map.
9543 if (next === false) {
9544 return map;
9545 }
9546 // c. Let nextItem be ? IteratorValue(next).
9547 var nextItem = IteratorValue(next);
9548 // d. If Type(nextItem) is not Object, then
9549 if (Type(nextItem) !== 'object') {
9550 // i. Let error be Completion{[[Type]]: throw, [[Value]]: a newly created TypeError object, [[Target]]: empty}.
9551 try {
9552 throw new TypeError('Iterator value ' + nextItem + ' is not an entry object');
9553 } catch (error) {
9554 // ii. Return ? IteratorClose(iteratorRecord, error).
9555 return IteratorClose(iteratorRecord, error);
9556 }
9557 }
9558 try {
9559 // Polyfill.io - The try catch accounts for steps: f, h, and j.
9560
9561 // e. Let k be Get(nextItem, "0").
9562 var k = Get(nextItem, "0");
9563 // f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k).
9564 // g. Let v be Get(nextItem, "1").
9565 var v = Get(nextItem, "1");
9566 // h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v).
9567 // i. Let status be Call(adder, map, « k.[[Value]], v.[[Value]] »).
9568 Call(adder, map, [k, v]);
9569 } catch (e) {
9570 // j. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
9571 return IteratorClose(iteratorRecord, e);
9572 }
9573 }
9574 } catch (e) {
9575 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
9576 if (Array.isArray(iterable) ||
9577 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
9578 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
9579 (!!iterable.callee)) {
9580 var index;
9581 var length = iterable.length;
9582 for (index = 0; index < length; index++) {
9583 var k = iterable[index][0];
9584 var v = iterable[index][1];
9585 Call(adder, map, [k, v]);
9586 }
9587 }
9588 }
9589 return map;
9590 };
9591
9592 // 23.3.2.1 WeakMap.prototype
9593 // The initial value of WeakMap.prototype is the intrinsic object %WeakMapPrototype%.
9594 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
9595 Object.defineProperty(WeakMap, 'prototype', {
9596 configurable: false,
9597 enumerable: false,
9598 writable: false,
9599 value: {}
9600 });
9601
9602 // 23.3.3.1 WeakMap.prototype.constructor
9603 CreateMethodProperty(WeakMap.prototype, 'constructor', WeakMap);
9604
9605 // 23.3.3.2 WeakMap.prototype.delete ( key )
9606 CreateMethodProperty(WeakMap.prototype, 'delete', function (key) {
9607 // 1. Let M be the this value.
9608 var M = this;
9609 // 2. If Type(M) is not Object, throw a TypeError exception.
9610 if (Type(M) !== 'object') {
9611 throw new TypeError('Method WeakMap.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
9612 }
9613 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
9614 if (M._es6WeakMap !== true) {
9615 throw new TypeError('Method WeakMap.prototype.clear called on incompatible receiver ' + Object.prototype.toString.call(M));
9616 }
9617 // 4. Let entries be the List that is M.[[WeakMapData]].
9618 var entries = M._keys;
9619 // 5. If Type(key) is not Object, return false.
9620 if (Type(key) !== 'object') {
9621 return false;
9622 }
9623 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
9624 for (var i = 0; i < entries.length; i++) {
9625 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, then
9626 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
9627 // i. Set p.[[Key]] to empty.
9628 this._keys[i] = undefMarker;
9629 // ii. Set p.[[Value]] to empty.
9630 this._values[i] = undefMarker;
9631 this._size = --this._size;
9632 // iii. Return true.
9633 return true;
9634 }
9635 }
9636 // 7. Return false.
9637 return false;
9638 });
9639
9640 // 23.3.3.3 WeakMap.prototype.get ( key )
9641 CreateMethodProperty(WeakMap.prototype, 'get', function get(key) {
9642 // 1. Let M be the this value.
9643 var M = this;
9644 // 2. If Type(M) is not Object, throw a TypeError exception.
9645 if (Type(M) !== 'object') {
9646 throw new TypeError('Method WeakMap.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
9647 }
9648 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
9649 if (M._es6WeakMap !== true) {
9650 throw new TypeError('Method WeakMap.prototype.get called on incompatible receiver ' + Object.prototype.toString.call(M));
9651 }
9652 // 4. Let entries be the List that is M.[[WeakMapData]].
9653 var entries = M._keys;
9654 // 5. If Type(key) is not Object, return undefined.
9655 if (Type(key) !== 'object') {
9656 return undefined;
9657 }
9658 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
9659 for (var i = 0; i < entries.length; i++) {
9660 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return p.[[Value]].
9661 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
9662 return M._values[i];
9663 }
9664 }
9665 // 7. Return undefined.
9666 return undefined;
9667 });
9668
9669 // 23.3.3.4 WeakMap.prototype.has ( key )
9670 CreateMethodProperty(WeakMap.prototype, 'has', function has(key) {
9671 // 1. Let M be the this value.
9672 var M = this;
9673 // 2. If Type(M) is not Object, throw a TypeError exception.
9674 if (typeof M !== 'object') {
9675 throw new TypeError('Method WeakMap.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
9676 }
9677 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
9678 if (M._es6WeakMap !== true) {
9679 throw new TypeError('Method WeakMap.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(M));
9680 }
9681 // 4. Let entries be the List that is M.[[WeakMapData]].
9682 var entries = M._keys;
9683 // 5. If Type(key) is not Object, return false.
9684 if (Type(key) !== 'object') {
9685 return false;
9686 }
9687 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
9688 for (var i = 0; i < entries.length; i++) {
9689 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, return true.
9690 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
9691 return true;
9692 }
9693 }
9694 // 7. Return false.
9695 return false;
9696 });
9697
9698 // 23.3.3.5 WeakMap.prototype.set ( key, value )
9699 CreateMethodProperty(WeakMap.prototype, 'set', function set(key, value) {
9700 // 1. Let M be the this value.
9701 var M = this;
9702 // 2. If Type(M) is not Object, throw a TypeError exception.
9703 if (Type(M) !== 'object') {
9704 throw new TypeError('Method WeakMap.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
9705 }
9706 // 3. If M does not have a [[WeakMapData]] internal slot, throw a TypeError exception.
9707 if (M._es6WeakMap !== true) {
9708 throw new TypeError('Method WeakMap.prototype.set called on incompatible receiver ' + Object.prototype.toString.call(M));
9709 }
9710 // 4. Let entries be the List that is M.[[WeakMapData]].
9711 var entries = M._keys;
9712 // 5. If Type(key) is not Object, throw a TypeError exception.
9713 if (Type(key) !== 'object') {
9714 throw new TypeError("Invalid value used as weak map key");
9715 }
9716 // 6. For each Record {[[Key]], [[Value]]} p that is an element of entries, do
9717 for (var i = 0; i < entries.length; i++) {
9718 // a. If p.[[Key]] is not empty and SameValue(p.[[Key]], key) is true, then
9719 if (M._keys[i] !== undefMarker && SameValue(M._keys[i], key)) {
9720 // i. Set p.[[Value]] to value.
9721 M._values[i] = value;
9722 // ii. Return M.
9723 return M;
9724 }
9725 }
9726 // 7. Let p be the Record {[[Key]]: key, [[Value]]: value}.
9727 var p = {
9728 '[[Key]]': key,
9729 '[[Value]]': value
9730 };
9731 // 8. Append p as the last element of entries.
9732 M._keys.push(p['[[Key]]']);
9733 M._values.push(p['[[Value]]']);
9734 // 9. Return M.
9735 return M;
9736 });
9737
9738 // 23.3.3.6 WeakMap.prototype [ @@toStringTag ]
9739 // The initial value of the @@toStringTag property is the String value "WeakMap".
9740 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
9741
9742 // Polyfill.io - Safari 8 implements WeakMap.name but as a non-writable property, which means it would throw an error if we try and write to it here.
9743 if (!('name' in WeakMap)) {
9744 // 19.2.4.2 name
9745 Object.defineProperty(WeakMap, 'name', {
9746 configurable: true,
9747 enumerable: false,
9748 writable: false,
9749 value: 'WeakMap'
9750 });
9751 }
9752
9753 // Export the object
9754 try {
9755 CreateMethodProperty(global, 'WeakMap', WeakMap);
9756 } catch (e) {
9757 // IE8 throws an error here if we set enumerable to false.
9758 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
9759 global['WeakMap'] = WeakMap;
9760 }
9761}(this));
9762
9763}
9764
9765if (!((function(e){try{if("WeakSet"in e&&0===WeakSet.length){var t={},n=new WeakSet([t])
9766return n.has(t)&&!1===n["delete"](0)}return!1}catch(r){return!1}})(this)
9767)) {
9768
9769// WeakSet
9770/* global Call, CreateMethodProperty, Get, GetIterator, IsArray, IsCallable, IteratorClose, IteratorStep, IteratorValue, OrdinaryCreateFromConstructor, SameValueZero, Type, Symbol */
9771(function (global) {
9772 // 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.
9773 var undefMarker = Symbol('undef');
9774 // 23.4.1.1. WeakSet ( [ iterable ] )
9775 var WeakSet = function WeakSet() {
9776 // 1. If NewTarget is undefined, throw a TypeError exception.
9777 if (!(this instanceof WeakSet)) {
9778 throw new TypeError('Constructor WeakSet requires "new"');
9779 }
9780 // 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%WeakSetPrototype%", « [[WeakSetData]] »).
9781 var set = OrdinaryCreateFromConstructor(this, WeakSet.prototype, {
9782 _values: [],
9783 _size: 0,
9784 _es6WeakSet: true
9785 });
9786
9787 // 3. Set set.[[WeakSetData]] to a new empty List.
9788 // Polyfill.io - This step was done as part of step two.
9789
9790 // 4. If iterable is not present, let iterable be undefined.
9791 var iterable = arguments.length > 0 ? arguments[0] : undefined;
9792 // 5. If iterable is either undefined or null, return set.
9793 if (iterable === null || iterable === undefined) {
9794 return set;
9795 }
9796 // 6. Let adder be ? Get(set, "add").
9797 var adder = Get(set, 'add');
9798 // 7. If IsCallable(adder) is false, throw a TypeError exception.
9799 if (!IsCallable(adder)) {
9800 throw new TypeError("WeakSet.prototype.add is not a function");
9801 }
9802 try {
9803 // 8. Let iteratorRecord be ? GetIterator(iterable).
9804 var iteratorRecord = GetIterator(iterable);
9805 // 9. Repeat,
9806 while (true) {
9807 // a. Let next be ? IteratorStep(iteratorRecord).
9808 var next = IteratorStep(iteratorRecord);
9809 // b. If next is false, return set.
9810 if (next === false) {
9811 return set;
9812 }
9813 // c. Let nextValue be ? IteratorValue(next).
9814 var nextValue = IteratorValue(next);
9815 // d. Let status be Call(adder, set, « nextValue »).
9816 try {
9817 Call(adder, set, [nextValue]);
9818 } catch (e) {
9819 // e. If status is an abrupt completion, return ? IteratorClose(iteratorRecord, status).
9820 return IteratorClose(iteratorRecord, e);
9821 }
9822 }
9823 } catch (e) {
9824 // Polyfill.io - For user agents which do not have iteration methods on argument objects or arrays, we can special case those.
9825 if (IsArray(iterable) ||
9826 Object.prototype.toString.call(iterable) === '[object Arguments]' ||
9827 // IE 7 & IE 8 return '[object Object]' for the arguments object, we can detect by checking for the existence of the callee property
9828 (!!iterable.callee)) {
9829 var index;
9830 var length = iterable.length;
9831 for (index = 0; index < length; index++) {
9832 Call(adder, set, [iterable[index]]);
9833 }
9834 }
9835 }
9836 return set;
9837 };
9838
9839 // 23.4.2.1. WeakSet.prototype
9840 // The initial value of WeakSet.prototype is the intrinsic %WeakSetPrototype% object.
9841 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
9842 Object.defineProperty(WeakSet, 'prototype', {
9843 configurable: false,
9844 enumerable: false,
9845 writable: false,
9846 value: {}
9847 });
9848
9849 // 23.4.3.1. WeakSet.prototype.add ( value )
9850 CreateMethodProperty(WeakSet.prototype, 'add', function add(value) {
9851 // 1. Let S be the this value.
9852 var S = this;
9853 // 2. If Type(S) is not Object, throw a TypeError exception.
9854 if (Type(S) !== 'object') {
9855 throw new TypeError('Method WeakSet.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
9856 }
9857 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
9858 if (S._es6WeakSet !== true) {
9859 throw new TypeError('Method WeakSet.prototype.add called on incompatible receiver ' + Object.prototype.toString.call(S));
9860 }
9861 // 4. If Type(value) is not Object, throw a TypeError exception.
9862 if (Type(value) !== 'object') {
9863 throw new TypeError('Invalid value used in weak set');
9864 }
9865 // 5. Let entries be the List that is S.[[WeakSetData]].
9866 var entries = S._values;
9867 // 6. For each e that is an element of entries, do
9868 for (var i = 0; i < entries.length; i++) {
9869 var e = entries[i];
9870 // a. If e is not empty and SameValue(e, value) is true, then
9871 if (e !== undefMarker && SameValueZero(e, value)) {
9872 // i. Return S.
9873 return S;
9874 }
9875 }
9876 // 7. Append value as the last element of entries.
9877 S._values.push(value);
9878 // 8. Return S.
9879 return S;
9880 });
9881
9882 // 23.4.3.2. WeakSet.prototype.constructor
9883 CreateMethodProperty(WeakSet.prototype, 'constructor', WeakSet);
9884
9885 // 23.4.3.3. WeakSet.prototype.delete ( value )
9886 CreateMethodProperty(WeakSet.prototype, 'delete', function (value) {
9887 // 1. Let S be the this value.
9888 var S = this;
9889 // 2. If Type(S) is not Object, throw a TypeError exception.
9890 if (Type(S) !== 'object') {
9891 throw new TypeError('Method WeakSet.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
9892 }
9893 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
9894 if (S._es6WeakSet !== true) {
9895 throw new TypeError('Method WeakSet.prototype.delete called on incompatible receiver ' + Object.prototype.toString.call(S));
9896 }
9897 // 4. If Type(value) is not Object, return false.
9898 if (Type(value) !== 'object') {
9899 return false;
9900 }
9901 // 5. Let entries be the List that is S.[[WeakSetData]].
9902 var entries = S._values;
9903 // 6. For each e that is an element of entries, do
9904 for (var i = 0; i < entries.length; i++) {
9905 var e = entries[i];
9906 // a. If e is not empty and SameValue(e, value) is true, then
9907 if (e !== undefMarker && SameValueZero(e, value)) {
9908 // i. Replace the element of entries whose value is e with an element whose value is empty.
9909 entries[i] = undefMarker;
9910 // ii. Return true.
9911 return true;
9912 }
9913 }
9914 // 7. Return false.
9915 return false;
9916 });
9917
9918 // 23.4.3.4. WeakSet.prototype.has ( value )
9919 CreateMethodProperty(WeakSet.prototype, 'has', function has(value) {
9920 // 1. Let S be the this value.
9921 var S = this;
9922 // 2. If Type(S) is not Object, throw a TypeError exception.
9923 if (Type(S) !== 'object') {
9924 throw new TypeError('Method WeakSet.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(S));
9925 }
9926 // 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError exception.
9927 if (S._es6WeakSet !== true) {
9928 throw new TypeError('Method WeakSet.prototype.has called on incompatible receiver ' + Object.prototype.toString.call(S));
9929 }
9930 // 4. Let entries be the List that is S.[[WeakSetData]].
9931 var entries = S._values;
9932 // 5. If Type(value) is not Object, return false.
9933 if (Type(value) !== 'object') {
9934 return false;
9935 }
9936 // 6. For each e that is an element of entries, do
9937 for (var i = 0; i < entries.length; i++) {
9938 var e = entries[i];
9939 // a. If e is not empty and SameValue(e, value) is true, return true.
9940 if (e !== undefMarker && SameValueZero(e, value)) {
9941 return true;
9942 }
9943 }
9944 // 7. Return false.
9945 return false;
9946 });
9947
9948 // 23.4.3.5. WeakSet.prototype [ @@toStringTag ]
9949 // The initial value of the @@toStringTag property is the String value "WeakSet".
9950 // This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
9951
9952 // 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.
9953 if (!('name' in WeakSet)) {
9954 // 19.2.4.2 name
9955 Object.defineProperty(WeakSet, 'name', {
9956 configurable: true,
9957 enumerable: false,
9958 writable: false,
9959 value: 'WeakSet'
9960 });
9961 }
9962
9963 // Export the object
9964 try {
9965 CreateMethodProperty(global, 'WeakSet', WeakSet);
9966 } catch (e) {
9967 // IE8 throws an error here if we set enumerable to false.
9968 // More info on table 2: https://msdn.microsoft.com/en-us/library/dd229916(v=vs.85).aspx
9969 global['WeakSet'] = WeakSet;
9970 }
9971
9972}(this));
9973
9974}
9975
9976if (!("Window"in this
9977)) {
9978
9979// Window
9980if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
9981 (function (global) {
9982 if (global.constructor) {
9983 global.Window = global.constructor;
9984 } else {
9985 (global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
9986 }
9987 }(this));
9988}
9989
9990}
9991
9992if (!((function(n){if(!("Event"in n))return!1
9993try{return new Event("click"),!0}catch(t){return!1}})(this)
9994)) {
9995
9996// Event
9997(function () {
9998 var unlistenableWindowEvents = {
9999 click: 1,
10000 dblclick: 1,
10001 keyup: 1,
10002 keypress: 1,
10003 keydown: 1,
10004 mousedown: 1,
10005 mouseup: 1,
10006 mousemove: 1,
10007 mouseover: 1,
10008 mouseenter: 1,
10009 mouseleave: 1,
10010 mouseout: 1,
10011 storage: 1,
10012 storagecommit: 1,
10013 textinput: 1
10014 };
10015
10016 // This polyfill depends on availability of `document` so will not run in a worker
10017 // However, we asssume there are no browsers with worker support that lack proper
10018 // support for `Event` within the worker
10019 if (typeof document === 'undefined' || typeof window === 'undefined') return;
10020
10021 function indexOf(array, element) {
10022 var
10023 index = -1,
10024 length = array.length;
10025
10026 while (++index < length) {
10027 if (index in array && array[index] === element) {
10028 return index;
10029 }
10030 }
10031
10032 return -1;
10033 }
10034
10035 var existingProto = (window.Event && window.Event.prototype) || null;
10036 function Event(type, eventInitDict) {
10037 if (!type) {
10038 throw new Error('Not enough arguments');
10039 }
10040
10041 var event;
10042 // Shortcut if browser supports createEvent
10043 if ('createEvent' in document) {
10044 event = document.createEvent('Event');
10045 var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
10046 var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
10047
10048 event.initEvent(type, bubbles, cancelable);
10049
10050 return event;
10051 }
10052
10053 event = document.createEventObject();
10054
10055 event.type = type;
10056 event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
10057 event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
10058
10059 return event;
10060 };
10061 Event.NONE = 0;
10062 Event.CAPTURING_PHASE = 1;
10063 Event.AT_TARGET = 2;
10064 Event.BUBBLING_PHASE = 3;
10065 window.Event = Window.prototype.Event = Event;
10066 if (existingProto) {
10067 Object.defineProperty(window.Event, 'prototype', {
10068 configurable: false,
10069 enumerable: false,
10070 writable: true,
10071 value: existingProto
10072 });
10073 }
10074
10075 if (!('createEvent' in document)) {
10076 window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
10077 var
10078 element = this,
10079 type = arguments[0],
10080 listener = arguments[1];
10081
10082 if (element === window && type in unlistenableWindowEvents) {
10083 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.');
10084 }
10085
10086 if (!element._events) {
10087 element._events = {};
10088 }
10089
10090 if (!element._events[type]) {
10091 element._events[type] = function (event) {
10092 var
10093 list = element._events[event.type].list,
10094 events = list.slice(),
10095 index = -1,
10096 length = events.length,
10097 eventElement;
10098
10099 event.preventDefault = function preventDefault() {
10100 if (event.cancelable !== false) {
10101 event.returnValue = false;
10102 }
10103 };
10104
10105 event.stopPropagation = function stopPropagation() {
10106 event.cancelBubble = true;
10107 };
10108
10109 event.stopImmediatePropagation = function stopImmediatePropagation() {
10110 event.cancelBubble = true;
10111 event.cancelImmediate = true;
10112 };
10113
10114 event.currentTarget = element;
10115 event.relatedTarget = event.fromElement || null;
10116 event.target = event.target || event.srcElement || element;
10117 event.timeStamp = new Date().getTime();
10118
10119 if (event.clientX) {
10120 event.pageX = event.clientX + document.documentElement.scrollLeft;
10121 event.pageY = event.clientY + document.documentElement.scrollTop;
10122 }
10123
10124 while (++index < length && !event.cancelImmediate) {
10125 if (index in events) {
10126 eventElement = events[index];
10127
10128 if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
10129 eventElement.call(element, event);
10130 }
10131 }
10132 }
10133 };
10134
10135 element._events[type].list = [];
10136
10137 if (element.attachEvent) {
10138 element.attachEvent('on' + type, element._events[type]);
10139 }
10140 }
10141
10142 element._events[type].list.push(listener);
10143 };
10144
10145 window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
10146 var
10147 element = this,
10148 type = arguments[0],
10149 listener = arguments[1],
10150 index;
10151
10152 if (element._events && element._events[type] && element._events[type].list) {
10153 index = indexOf(element._events[type].list, listener);
10154
10155 if (index !== -1) {
10156 element._events[type].list.splice(index, 1);
10157
10158 if (!element._events[type].list.length) {
10159 if (element.detachEvent) {
10160 element.detachEvent('on' + type, element._events[type]);
10161 }
10162 delete element._events[type];
10163 }
10164 }
10165 }
10166 };
10167
10168 window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
10169 if (!arguments.length) {
10170 throw new Error('Not enough arguments');
10171 }
10172
10173 if (!event || typeof event.type !== 'string') {
10174 throw new Error('DOM Events Exception 0');
10175 }
10176
10177 var element = this, type = event.type;
10178
10179 try {
10180 if (!event.bubbles) {
10181 event.cancelBubble = true;
10182
10183 var cancelBubbleEvent = function (event) {
10184 event.cancelBubble = true;
10185
10186 (element || window).detachEvent('on' + type, cancelBubbleEvent);
10187 };
10188
10189 this.attachEvent('on' + type, cancelBubbleEvent);
10190 }
10191
10192 this.fireEvent('on' + type, event);
10193 } catch (error) {
10194 event.target = element;
10195
10196 do {
10197 event.currentTarget = element;
10198
10199 if ('_events' in element && typeof element._events[type] === 'function') {
10200 element._events[type].call(element, event);
10201 }
10202
10203 if (typeof element['on' + type] === 'function') {
10204 element['on' + type].call(element, event);
10205 }
10206
10207 element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
10208 } while (element && !event.cancelBubble);
10209 }
10210
10211 return true;
10212 };
10213
10214 // Add the DOMContentLoaded Event
10215 document.attachEvent('onreadystatechange', function() {
10216 if (document.readyState === 'complete') {
10217 document.dispatchEvent(new Event('DOMContentLoaded', {
10218 bubbles: true
10219 }));
10220 }
10221 });
10222 }
10223}());
10224
10225}
10226
10227if (!("CustomEvent"in this&&("function"==typeof this.CustomEvent||this.CustomEvent.toString().indexOf("CustomEventConstructor")>-1)
10228)) {
10229
10230// CustomEvent
10231this.CustomEvent = function CustomEvent(type, eventInitDict) {
10232 if (!type) {
10233 throw Error('TypeError: Failed to construct "CustomEvent": An event name must be provided.');
10234 }
10235
10236 var event;
10237 eventInitDict = eventInitDict || {bubbles: false, cancelable: false, detail: null};
10238
10239 if ('createEvent' in document) {
10240 try {
10241 event = document.createEvent('CustomEvent');
10242 event.initCustomEvent(type, eventInitDict.bubbles, eventInitDict.cancelable, eventInitDict.detail);
10243 } catch (error) {
10244 // for browsers which don't support CustomEvent at all, we use a regular event instead
10245 event = document.createEvent('Event');
10246 event.initEvent(type, eventInitDict.bubbles, eventInitDict.cancelable);
10247 event.detail = eventInitDict.detail;
10248 }
10249 } else {
10250
10251 // IE8
10252 event = new Event(type, eventInitDict);
10253 event.detail = eventInitDict && eventInitDict.detail || null;
10254 }
10255 return event;
10256};
10257
10258CustomEvent.prototype = Event.prototype;
10259
10260}
10261
10262if (!("document"in this&&"hidden"in document&&"visibilityState"in document
10263)) {
10264
10265// document.visibilityState
10266// PageVisibility
10267(function () {
10268 var prefix = document.webkitVisibilityState ? 'webkit' : document.mozVisibilityState ? 'moz' : null;
10269
10270 function normalizeState () {
10271 document.hidden = document[prefix + 'Hidden'];
10272 document.visibilityState = document[prefix + 'VisibilityState'];
10273 }
10274
10275 if (!prefix) {
10276 return;
10277 }
10278
10279 normalizeState();
10280
10281 document.addEventListener(prefix + 'visibilitychange', function () {
10282 normalizeState();
10283 document.dispatchEvent(new CustomEvent('visibilitychange'));
10284 });
10285
10286}());
10287
10288}
10289
10290
10291// Event.focusin
10292this.addEventListener('focus', function (event) {
10293 event.target.dispatchEvent(new Event('focusin', {
10294 bubbles: true,
10295 cancelable: true
10296 }));
10297}, true);
10298
10299this.addEventListener('blur', function (event) {
10300 event.target.dispatchEvent(new Event('focusout', {
10301 bubbles: true,
10302 cancelable: true
10303 }));
10304}, true);
10305if (!("onhashchange"in this&&(null==this.onhashchange||"function"==typeof this.onhashchange)
10306)) {
10307
10308// Event.hashchange
10309(function (global) {
10310 var hash = global.location.hash;
10311
10312 function poll() {
10313 if (hash !== global.location.hash) {
10314 hash = global.location.hash;
10315
10316 global.dispatchEvent(new Event('hashchange'));
10317 }
10318
10319 setTimeout(poll, 500);
10320 }
10321
10322 // Make sure a check for 'onhashchange' in window will pass (note: setting to undefined IE<9 causes 'Not implemented' error)
10323 global.onhashchange = function () { };
10324
10325 poll();
10326}(this));
10327
10328}
10329
10330if (!("XMLHttpRequest"in this&&"prototype"in this.XMLHttpRequest&&"addEventListener"in this.XMLHttpRequest.prototype
10331)) {
10332
10333// XMLHttpRequest
10334(function (global, NativeXMLHttpRequest) {
10335 // <Global>.XMLHttpRequest
10336 global.XMLHttpRequest = function XMLHttpRequest() {
10337 var request = this, nativeRequest = request._request = NativeXMLHttpRequest ? new NativeXMLHttpRequest() : new ActiveXObject('MSXML2.XMLHTTP.3.0');
10338
10339 nativeRequest.onreadystatechange = function () {
10340 request.readyState = nativeRequest.readyState;
10341
10342 var readyState = request.readyState === 4;
10343
10344 request.response = request.responseText = readyState ? nativeRequest.responseText : null;
10345 request.status = readyState ? nativeRequest.status : null;
10346 request.statusText = readyState ? nativeRequest.statusText : null;
10347
10348 request.dispatchEvent(new Event('readystatechange'));
10349
10350 if (readyState) {
10351 request.dispatchEvent(new Event('load'));
10352 }
10353 };
10354
10355 if ('onerror' in nativeRequest) {
10356 nativeRequest.onerror = function () {
10357 request.dispatchEvent(new Event('error'));
10358 };
10359 }
10360 };
10361
10362 global.XMLHttpRequest.UNSENT = 0;
10363 global.XMLHttpRequest.OPENED = 1;
10364 global.XMLHttpRequest.HEADERS_RECEIVED = 2;
10365 global.XMLHttpRequest.LOADING = 3;
10366 global.XMLHttpRequest.DONE = 4;
10367
10368 var XMLHttpRequestPrototype = global.XMLHttpRequest.prototype;
10369
10370 XMLHttpRequestPrototype.addEventListener = global.addEventListener;
10371 XMLHttpRequestPrototype.removeEventListener = global.removeEventListener;
10372 XMLHttpRequestPrototype.dispatchEvent = global.dispatchEvent;
10373
10374 XMLHttpRequestPrototype.abort = function abort() {
10375 return this._request();
10376 };
10377
10378 XMLHttpRequestPrototype.getAllResponseHeaders = function getAllResponseHeaders() {
10379 return this._request.getAllResponseHeaders();
10380 };
10381
10382 XMLHttpRequestPrototype.getResponseHeader = function getResponseHeader(header) {
10383 return this._request.getResponseHeader(header);
10384 };
10385
10386 XMLHttpRequestPrototype.open = function open(method, url) {
10387 // method, url, async, username, password
10388 this._request.open(method, url, arguments[2], arguments[3], arguments[4]);
10389 };
10390
10391 XMLHttpRequestPrototype.overrideMimeType = function overrideMimeType(mimetype) {
10392 this._request.overrideMimeType(mimetype);
10393 };
10394
10395 XMLHttpRequestPrototype.send = function send() {
10396 this._request.send(0 in arguments ? arguments[0] : null);
10397 };
10398
10399 XMLHttpRequestPrototype.setRequestHeader = function setRequestHeader(header, value) {
10400 this._request.setRequestHeader(header, value);
10401 };
10402}(this, this.XMLHttpRequest));
10403
10404}
10405
10406})
10407.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});