Guest User

Untitled

a guest
Jul 25th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 129.37 KB | None | 0 0
  1. /* Polyfill service DEVELOPMENT MODE - for live use set NODE_ENV to 'production'
  2. * For detailed credits and licence information see http://github.com/financial-times/polyfill-service.
  3. *
  4. * UA detected: ie/8.0.0
  5. * Features requested: HTMLPictureElement,default
  6. *
  7. * - ~html5-elements, License: MIT (required by "HTMLPictureElement", "default")
  8. * - HTMLPictureElement, License: MIT
  9. * - Object.defineProperty, License: CC0 (required by "Array.from", "Array.isArray", "Array.of", "Array.prototype.fill", "CustomEvent", "Element.prototype.classList", "Event", "Event.DOMContentLoaded", "Function.prototype.bind", "Map", "Object.create", "Object.defineProperties", "Object.getOwnPropertyDescriptor", "Promise", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "URL", "XMLHttpRequest", "default", "location.origin")
  10. * - Array.from, License: CC0 (required by "default")
  11. * - Array.isArray, License: CC0 (required by "Promise", "default")
  12. * - Array.of, License: CC0 (required by "default")
  13. * - Array.prototype.every, License: CC0 (required by "default")
  14. * - Array.prototype.fill, License: CC0 (required by "default")
  15. * - Array.prototype.filter, License: CC0 (required by "Map", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "default")
  16. * - Array.prototype.forEach, License: CC0 (required by "Map", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "URL", "default")
  17. * - Array.prototype.indexOf, License: CC0 (required by "Map", "Set", "default")
  18. * - Array.prototype.lastIndexOf, License: CC0 (required by "default")
  19. * - Array.prototype.map, License: CC0 (required by "default")
  20. * - Array.prototype.reduce, License: CC0 (required by "default")
  21. * - Array.prototype.reduceRight, License: CC0 (required by "default")
  22. * - Array.prototype.some, License: CC0 (required by "default")
  23. * - Document, License: CC0 (required by "CustomEvent", "Element", "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.classList", "Element.prototype.cloneNode", "Element.prototype.closest", "Element.prototype.matches", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith", "Event", "Event.DOMContentLoaded", "Node.prototype.contains", "XMLHttpRequest", "_mutation", "default", "document.querySelector")
  24. * - Element, License: CC0 (required by "CustomEvent", "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.classList", "Element.prototype.cloneNode", "Element.prototype.closest", "Element.prototype.matches", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith", "Event", "Event.DOMContentLoaded", "Node.prototype.contains", "XMLHttpRequest", "_mutation", "default", "document.querySelector")
  25. * - Event, License: CC0 (required by "CustomEvent", "Event.DOMContentLoaded", "XMLHttpRequest", "default")
  26. * - CustomEvent, License: CC0 (required by "default")
  27. * - _DOMTokenList, License: CC0 (required by "DOMTokenList", "Element.prototype.classList", "default")
  28. * - DOMTokenList, License: CC0 (required by "default")
  29. * - Date.now, License: CC0 (required by "default", "performance.now", "requestAnimationFrame")
  30. * - Date.prototype.toISOString, License: CC0 (required by "default")
  31. * - _mutation, License: CC0 (required by "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith", "default")
  32. * - Element.prototype.after, License: CC0 (required by "default")
  33. * - Element.prototype.append, License: CC0 (required by "default")
  34. * - Element.prototype.before, License: CC0 (required by "default")
  35. * - Element.prototype.classList, License: CC0 (required by "default")
  36. * - Element.prototype.cloneNode, License: CC0 (required by "default")
  37. * - document.querySelector, License: CC0 (required by "Element.prototype.closest", "Element.prototype.matches", "default")
  38. * - Element.prototype.matches, License: CC0 (required by "Element.prototype.closest", "default")
  39. * - Element.prototype.closest, License: CC0 (required by "default")
  40. * - Element.prototype.prepend, License: CC0 (required by "default")
  41. * - Element.prototype.remove, License: CC0 (required by "default")
  42. * - Element.prototype.replaceWith, License: CC0 (required by "default")
  43. * - Event.DOMContentLoaded, License: CC0 (required by "default")
  44. * - Function.prototype.bind, License: MIT (required by "Map", "Object.getOwnPropertyDescriptor", "Set", "Symbol", "default")
  45. * - Object.defineProperties, License: CC0 (required by "Map", "Object.create", "Set", "Symbol", "URL", "default", "location.origin")
  46. * - Object.create, License: CC0 (required by "Map", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "default")
  47. * - Object.getOwnPropertyNames, License: CC0 (required by "Map", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "default")
  48. * - Object.getOwnPropertyDescriptor, License: CC0 (required by "Map", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "default")
  49. * - Object.keys, License: CC0 (required by "Map", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "default")
  50. * - Symbol, License: MIT (required by "Map", "Set", "Symbol.iterator", "Symbol.species", "default")
  51. * - Symbol.iterator, License: MIT (required by "Map", "Set", "default")
  52. * - Symbol.species, License: MIT (required by "Map", "Set", "default")
  53. * - Number.isNaN, License: MIT (required by "Map", "Set", "default")
  54. * - Map, License: CC0 (required by "default")
  55. * - Node.prototype.contains, License: CC0 (required by "default")
  56. * - Object.assign, License: CC0 (required by "default")
  57. * - Object.getPrototypeOf, License: CC0 (required by "default")
  58. * - setImmediate, License: CC0 (required by "Promise", "default")
  59. * - Promise, License: MIT (required by "default")
  60. * - Set, License: CC0 (required by "default")
  61. * - String.prototype.endsWith, License: CC0 (required by "default")
  62. * - String.prototype.includes, License: CC0 (required by "default")
  63. * - String.prototype.startsWith, License: CC0 (required by "default")
  64. * - String.prototype.trim, License: CC0 (required by "default")
  65. * - URL, License: CC0 (required by "default")
  66. * - XMLHttpRequest, License: CC0 (required by "default")
  67. * - atob, License: MIT (required by "default")
  68. * - location.origin, License: CC0 (required by "default")
  69. * - performance.now, License: CC0 (required by "default", "requestAnimationFrame")
  70. * - requestAnimationFrame, License: MIT (required by "default") */
  71.  
  72. (function(undefined) {
  73. if (!(// Primitive detect for HTML5 element support - add a <section> element and check that it acquires block display mode by default
  74. (function() {
  75. var p = document.createElement('p');
  76. var result = false;
  77. p.innerHTML = '<section></section>';
  78. document.documentElement.appendChild(p);
  79. if (p.firstChild) {
  80. if ('getComputedStyle' in window) {
  81. result = (getComputedStyle(p.firstChild).display === 'block');
  82. } else if (p.firstChild.currentStyle) {
  83. result = (p.firstChild.currentStyle.display === 'block');
  84. }
  85. }
  86. document.documentElement.removeChild(p);
  87. return result;
  88. })())) {
  89.  
  90. // ~html5-elements
  91. /**
  92. * @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
  93. */
  94. ;(function(window, document) {
  95. /*jshint evil:true */
  96. /** version */
  97. var version = '3.7.3';
  98.  
  99. /** Preset options */
  100. var options = window.html5 || {};
  101.  
  102. /** Used to skip problem elements */
  103. var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;
  104.  
  105. /** Not all elements can be cloned in IE **/
  106. var saveClones = /^(?: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;
  107.  
  108. /** Detect whether the browser supports default html5 styles */
  109. var supportsHtml5Styles;
  110.  
  111. /** Name of the expando, to work with multiple documents or to re-shiv one document */
  112. var expando = '_html5shiv';
  113.  
  114. /** The id for the the documents expando */
  115. var expanID = 0;
  116.  
  117. /** Cached data for each document */
  118. var expandoData = {};
  119.  
  120. /** Detect whether the browser supports unknown elements */
  121. var supportsUnknownElements;
  122.  
  123. (function() {
  124. try {
  125. var a = document.createElement('a');
  126. a.innerHTML = '<xyz></xyz>';
  127. //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles
  128. supportsHtml5Styles = ('hidden' in a);
  129.  
  130. supportsUnknownElements = a.childNodes.length == 1 || (function() {
  131. // assign a false positive if unable to shiv
  132. (document.createElement)('a');
  133. var frag = document.createDocumentFragment();
  134. return (
  135. typeof frag.cloneNode == 'undefined' ||
  136. typeof frag.createDocumentFragment == 'undefined' ||
  137. typeof frag.createElement == 'undefined'
  138. );
  139. }());
  140. } catch(e) {
  141. // assign a false positive if detection fails => unable to shiv
  142. supportsHtml5Styles = true;
  143. supportsUnknownElements = true;
  144. }
  145.  
  146. }());
  147.  
  148. /*--------------------------------------------------------------------------*/
  149.  
  150. /**
  151. * Creates a style sheet with the given CSS text and adds it to the document.
  152. * @private
  153. * @param {Document} ownerDocument The document.
  154. * @param {String} cssText The CSS text.
  155. * @returns {StyleSheet} The style element.
  156. */
  157. function addStyleSheet(ownerDocument, cssText) {
  158. var p = ownerDocument.createElement('p'),
  159. parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
  160.  
  161. p.innerHTML = 'x<style>' + cssText + '</style>';
  162. return parent.insertBefore(p.lastChild, parent.firstChild);
  163. }
  164.  
  165. /**
  166. * Returns the value of `html5.elements` as an array.
  167. * @private
  168. * @returns {Array} An array of shived element node names.
  169. */
  170. function getElements() {
  171. var elements = html5.elements;
  172. return typeof elements == 'string' ? elements.split(' ') : elements;
  173. }
  174.  
  175. /**
  176. * Extends the built-in list of html5 elements
  177. * @memberOf html5
  178. * @param {String|Array} newElements whitespace separated list or array of new element names to shiv
  179. * @param {Document} ownerDocument The context document.
  180. */
  181. function addElements(newElements, ownerDocument) {
  182. var elements = html5.elements;
  183. if(typeof elements != 'string'){
  184. elements = elements.join(' ');
  185. }
  186. if(typeof newElements != 'string'){
  187. newElements = newElements.join(' ');
  188. }
  189. html5.elements = elements +' '+ newElements;
  190. shivDocument(ownerDocument);
  191. }
  192.  
  193. /**
  194. * Returns the data associated to the given document
  195. * @private
  196. * @param {Document} ownerDocument The document.
  197. * @returns {Object} An object of data.
  198. */
  199. function getExpandoData(ownerDocument) {
  200. var data = expandoData[ownerDocument[expando]];
  201. if (!data) {
  202. data = {};
  203. expanID++;
  204. ownerDocument[expando] = expanID;
  205. expandoData[expanID] = data;
  206. }
  207. return data;
  208. }
  209.  
  210. /**
  211. * returns a shived element for the given nodeName and document
  212. * @memberOf html5
  213. * @param {String} nodeName name of the element
  214. * @param {Document|DocumentFragment} ownerDocument The context document.
  215. * @returns {Object} The shived element.
  216. */
  217. function createElement(nodeName, ownerDocument, data){
  218. if (!ownerDocument) {
  219. ownerDocument = document;
  220. }
  221. if(supportsUnknownElements){
  222. return ownerDocument.createElement(nodeName);
  223. }
  224. if (!data) {
  225. data = getExpandoData(ownerDocument);
  226. }
  227. var node;
  228.  
  229. if (data.cache[nodeName]) {
  230. node = data.cache[nodeName].cloneNode();
  231. } else if (saveClones.test(nodeName)) {
  232. node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
  233. } else {
  234. node = data.createElem(nodeName);
  235. }
  236.  
  237. // Avoid adding some elements to fragments in IE < 9 because
  238. // * Attributes like `name` or `type` cannot be set/changed once an element
  239. // is inserted into a document/fragment
  240. // * Link elements with `src` attributes that are inaccessible, as with
  241. // a 403 response, will cause the tab/window to crash
  242. // * Script elements appended to fragments will execute when their `src`
  243. // or `text` property is set
  244. return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node;
  245. }
  246.  
  247. /**
  248. * returns a shived DocumentFragment for the given document
  249. * @memberOf html5
  250. * @param {Document} ownerDocument The context document.
  251. * @returns {Object} The shived DocumentFragment.
  252. */
  253. function createDocumentFragment(ownerDocument, data){
  254. if (!ownerDocument) {
  255. ownerDocument = document;
  256. }
  257. if(supportsUnknownElements){
  258. return ownerDocument.createDocumentFragment();
  259. }
  260. data = data || getExpandoData(ownerDocument);
  261. var clone = data.frag.cloneNode(),
  262. i = 0,
  263. elems = getElements(),
  264. l = elems.length;
  265. for(;i<l;i++){
  266. clone.createElement(elems[i]);
  267. }
  268. return clone;
  269. }
  270.  
  271. /**
  272. * Shivs the `createElement` and `createDocumentFragment` methods of the document.
  273. * @private
  274. * @param {Document|DocumentFragment} ownerDocument The document.
  275. * @param {Object} data of the document.
  276. */
  277. function shivMethods(ownerDocument, data) {
  278. if (!data.cache) {
  279. data.cache = {};
  280. data.createElem = ownerDocument.createElement;
  281. data.createFrag = ownerDocument.createDocumentFragment;
  282. data.frag = data.createFrag();
  283. }
  284.  
  285.  
  286. ownerDocument.createElement = function(nodeName) {
  287. //abort shiv
  288. if (!html5.shivMethods) {
  289. return data.createElem(nodeName);
  290. }
  291. return createElement(nodeName, ownerDocument, data);
  292. };
  293.  
  294. ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
  295. 'var n=f.cloneNode(),c=n.createElement;' +
  296. 'h.shivMethods&&(' +
  297. // unroll the `createElement` calls
  298. getElements().join().replace(/[\w\-:]+/g, function(nodeName) {
  299. data.createElem(nodeName);
  300. data.frag.createElement(nodeName);
  301. return 'c("' + nodeName + '")';
  302. }) +
  303. ');return n}'
  304. )(html5, data.frag);
  305. }
  306.  
  307. /*--------------------------------------------------------------------------*/
  308.  
  309. /**
  310. * Shivs the given document.
  311. * @memberOf html5
  312. * @param {Document} ownerDocument The document to shiv.
  313. * @returns {Document} The shived document.
  314. */
  315. function shivDocument(ownerDocument) {
  316. if (!ownerDocument) {
  317. ownerDocument = document;
  318. }
  319. var data = getExpandoData(ownerDocument);
  320.  
  321. if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {
  322. data.hasCSS = !!addStyleSheet(ownerDocument,
  323. // corrects block display not defined in IE6/7/8/9
  324. 'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' +
  325. // adds styling not present in IE6/7/8/9
  326. 'mark{background:#FF0;color:#000}' +
  327. // hides non-rendered elements
  328. 'template{display:none}'
  329. );
  330. }
  331. if (!supportsUnknownElements) {
  332. shivMethods(ownerDocument, data);
  333. }
  334. return ownerDocument;
  335. }
  336.  
  337. /*--------------------------------------------------------------------------*/
  338.  
  339. /**
  340. * The `html5` object is exposed so that more elements can be shived and
  341. * existing shiving can be detected on iframes.
  342. * @type Object
  343. * @example
  344. *
  345. * // options can be changed before the script is included
  346. * html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false };
  347. */
  348. var html5 = {
  349.  
  350. /**
  351. * An array or space separated string of node names of the elements to shiv.
  352. * @memberOf html5
  353. * @type Array|String
  354. */
  355. 'elements': options.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',
  356.  
  357. /**
  358. * current version of html5shiv
  359. */
  360. 'version': version,
  361.  
  362. /**
  363. * A flag to indicate that the HTML5 style sheet should be inserted.
  364. * @memberOf html5
  365. * @type Boolean
  366. */
  367. 'shivCSS': (options.shivCSS !== false),
  368.  
  369. /**
  370. * Is equal to true if a browser supports creating unknown/HTML5 elements
  371. * @memberOf html5
  372. * @type boolean
  373. */
  374. 'supportsUnknownElements': supportsUnknownElements,
  375.  
  376. /**
  377. * A flag to indicate that the document's `createElement` and `createDocumentFragment`
  378. * methods should be overwritten.
  379. * @memberOf html5
  380. * @type Boolean
  381. */
  382. 'shivMethods': (options.shivMethods !== false),
  383.  
  384. /**
  385. * A string to describe the type of `html5` object ("default" or "default print").
  386. * @memberOf html5
  387. * @type String
  388. */
  389. 'type': 'default',
  390.  
  391. // shivs the document according to the specified `html5` object options
  392. 'shivDocument': shivDocument,
  393.  
  394. //creates a shived element
  395. createElement: createElement,
  396.  
  397. //creates a shived documentFragment
  398. createDocumentFragment: createDocumentFragment,
  399.  
  400. //extends list of elements
  401. addElements: addElements
  402. };
  403.  
  404. /*--------------------------------------------------------------------------*/
  405.  
  406. // expose html5
  407. window.html5 = html5;
  408.  
  409. // shiv the document
  410. shivDocument(document);
  411.  
  412. if(typeof module == 'object' && module.exports){
  413. module.exports = html5;
  414. }
  415.  
  416. }(typeof window !== "undefined" ? window : this, document));
  417. }
  418.  
  419. if (!(/* Picturefill does not set the HTMLPictureElement global, and the srcset property of <source> does not appear to be accessible to JS in IE8, so in IE8 the only way to detect that the polyfill has applied is to use a non-standard global exposed by the polyfill */
  420. 'HTMLPictureElement' in this || 'picturefill' in this)) {
  421.  
  422. // HTMLPictureElement
  423. /*! picturefill - v3.0.2 - 2016-02-12
  424. * https://scottjehl.github.io/picturefill/
  425. * Copyright (c) 2016 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; Licensed MIT
  426. */
  427. !function(a){var b=navigator.userAgent;a.HTMLPictureElement&&/ecko/.test(b)&&b.match(/rv\:(\d+)/)&&RegExp.$1<45&&addEventListener("resize",function(){var b,c=document.createElement("source"),d=function(a){var b,d,e=a.parentNode;"PICTURE"===e.nodeName.toUpperCase()?(b=c.cloneNode(),e.insertBefore(b,e.firstElementChild),setTimeout(function(){e.removeChild(b)})):(!a._pfLastSize||a.offsetWidth>a._pfLastSize)&&(a._pfLastSize=a.offsetWidth,d=a.sizes,a.sizes+=",100vw",setTimeout(function(){a.sizes=d}))},e=function(){var a,b=document.querySelectorAll("picture > img, img[srcset][sizes]");for(a=0;a<b.length;a++)d(b[a])},f=function(){clearTimeout(b),b=setTimeout(e,99)},g=a.matchMedia&&matchMedia("(orientation: landscape)"),h=function(){f(),g&&g.addListener&&g.addListener(f)};return c.srcset="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",/^[c|i]|d$/.test(document.readyState||"")?h():document.addEventListener("DOMContentLoaded",h),f}())}(window),function(a,b,c){"use strict";function d(a){return" "===a||" "===a||"\n"===a||"\f"===a||"\r"===a}function e(b,c){var d=new a.Image;return d.onerror=function(){A[b]=!1,ba()},d.onload=function(){A[b]=1===d.width,ba()},d.src=c,"pending"}function f(){M=!1,P=a.devicePixelRatio,N={},O={},s.DPR=P||1,Q.width=Math.max(a.innerWidth||0,z.clientWidth),Q.height=Math.max(a.innerHeight||0,z.clientHeight),Q.vw=Q.width/100,Q.vh=Q.height/100,r=[Q.height,Q.width,P].join("-"),Q.em=s.getEmValue(),Q.rem=Q.em}function g(a,b,c,d){var e,f,g,h;return"saveData"===B.algorithm?a>2.7?h=c+1:(f=b-c,e=Math.pow(a-.6,1.5),g=f*e,d&&(g+=.1*e),h=a+g):h=c>1?Math.sqrt(a*b):a,h>c}function h(a){var b,c=s.getSet(a),d=!1;"pending"!==c&&(d=r,c&&(b=s.setRes(c),s.applySetCandidate(b,a))),a[s.ns].evaled=d}function i(a,b){return a.res-b.res}function j(a,b,c){var d;return!c&&b&&(c=a[s.ns].sets,c=c&&c[c.length-1]),d=k(b,c),d&&(b=s.makeUrl(b),a[s.ns].curSrc=b,a[s.ns].curCan=d,d.res||aa(d,d.set.sizes)),d}function k(a,b){var c,d,e;if(a&&b)for(e=s.parseSet(b),a=s.makeUrl(a),c=0;c<e.length;c++)if(a===s.makeUrl(e[c].url)){d=e[c];break}return d}function l(a,b){var c,d,e,f,g=a.getElementsByTagName("source");for(c=0,d=g.length;d>c;c++)e=g[c],e[s.ns]=!0,f=e.getAttribute("srcset"),f&&b.push({srcset:f,media:e.getAttribute("media"),type:e.getAttribute("type"),sizes:e.getAttribute("sizes")})}function m(a,b){function c(b){var c,d=b.exec(a.substring(m));return d?(c=d[0],m+=c.length,c):void 0}function e(){var a,c,d,e,f,i,j,k,l,m=!1,o={};for(e=0;e<h.length;e++)f=h[e],i=f[f.length-1],j=f.substring(0,f.length-1),k=parseInt(j,10),l=parseFloat(j),X.test(j)&&"w"===i?((a||c)&&(m=!0),0===k?m=!0:a=k):Y.test(j)&&"x"===i?((a||c||d)&&(m=!0),0>l?m=!0:c=l):X.test(j)&&"h"===i?((d||c)&&(m=!0),0===k?m=!0:d=k):m=!0;m||(o.url=g,a&&(o.w=a),c&&(o.d=c),d&&(o.h=d),d||c||a||(o.d=1),1===o.d&&(b.has1x=!0),o.set=b,n.push(o))}function f(){for(c(T),i="",j="in descriptor";;){if(k=a.charAt(m),"in descriptor"===j)if(d(k))i&&(h.push(i),i="",j="after descriptor");else{if(","===k)return m+=1,i&&h.push(i),void e();if("("===k)i+=k,j="in parens";else{if(""===k)return i&&h.push(i),void e();i+=k}}else if("in parens"===j)if(")"===k)i+=k,j="in descriptor";else{if(""===k)return h.push(i),void e();i+=k}else if("after descriptor"===j)if(d(k));else{if(""===k)return void e();j="in descriptor",m-=1}m+=1}}for(var g,h,i,j,k,l=a.length,m=0,n=[];;){if(c(U),m>=l)return n;g=c(V),h=[],","===g.slice(-1)?(g=g.replace(W,""),e()):f()}}function n(a){function b(a){function b(){f&&(g.push(f),f="")}function c(){g[0]&&(h.push(g),g=[])}for(var e,f="",g=[],h=[],i=0,j=0,k=!1;;){if(e=a.charAt(j),""===e)return b(),c(),h;if(k){if("*"===e&&"/"===a[j+1]){k=!1,j+=2,b();continue}j+=1}else{if(d(e)){if(a.charAt(j-1)&&d(a.charAt(j-1))||!f){j+=1;continue}if(0===i){b(),j+=1;continue}e=" "}else if("("===e)i+=1;else if(")"===e)i-=1;else{if(","===e){b(),c(),j+=1;continue}if("/"===e&&"*"===a.charAt(j+1)){k=!0,j+=2;continue}}f+=e,j+=1}}}function c(a){return k.test(a)&&parseFloat(a)>=0?!0:l.test(a)?!0:"0"===a||"-0"===a||"+0"===a?!0:!1}var e,f,g,h,i,j,k=/^(?:[+-]?[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?(?:ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmin|vmax|vw)$/i,l=/^calc\((?:[0-9a-z \.\+\-\*\/\(\)]+)\)$/i;for(f=b(a),g=f.length,e=0;g>e;e++)if(h=f[e],i=h[h.length-1],c(i)){if(j=i,h.pop(),0===h.length)return j;if(h=h.join(" "),s.matchesMedia(h))return j}return"100vw"}b.createElement("picture");var o,p,q,r,s={},t=!1,u=function(){},v=b.createElement("img"),w=v.getAttribute,x=v.setAttribute,y=v.removeAttribute,z=b.documentElement,A={},B={algorithm:""},C="data-pfsrc",D=C+"set",E=navigator.userAgent,F=/rident/.test(E)||/ecko/.test(E)&&E.match(/rv\:(\d+)/)&&RegExp.$1>35,G="currentSrc",H=/\s+\+?\d+(e\d+)?w/,I=/(\([^)]+\))?\s*(.+)/,J=a.picturefillCFG,K="position:absolute;left:0;visibility:hidden;display:block;padding:0;border:none;font-size:1em;width:1em;overflow:hidden;clip:rect(0px, 0px, 0px, 0px)",L="font-size:100%!important;",M=!0,N={},O={},P=a.devicePixelRatio,Q={px:1,"in":96},R=b.createElement("a"),S=!1,T=/^[ \t\n\r\u000c]+/,U=/^[, \t\n\r\u000c]+/,V=/^[^ \t\n\r\u000c]+/,W=/[,]+$/,X=/^\d+$/,Y=/^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,Z=function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d||!1):a.attachEvent&&a.attachEvent("on"+b,c)},$=function(a){var b={};return function(c){return c in b||(b[c]=a(c)),b[c]}},_=function(){var a=/^([\d\.]+)(em|vw|px)$/,b=function(){for(var a=arguments,b=0,c=a[0];++b in a;)c=c.replace(a[b],a[++b]);return c},c=$(function(a){return"return "+b((a||"").toLowerCase(),/\band\b/g,"&&",/,/g,"||",/min-([a-z-\s]+):/g,"e.$1>=",/max-([a-z-\s]+):/g,"e.$1<=",/calc([^)]+)/g,"($1)",/(\d+[\.]*[\d]*)([a-z]+)/g,"($1 * e.$2)",/^(?!(e.[a-z]|[0-9\.&=|><\+\-\*\(\)\/])).*/gi,"")+";"});return function(b,d){var e;if(!(b in N))if(N[b]=!1,d&&(e=b.match(a)))N[b]=e[1]*Q[e[2]];else try{N[b]=new Function("e",c(b))(Q)}catch(f){}return N[b]}}(),aa=function(a,b){return a.w?(a.cWidth=s.calcListLength(b||"100vw"),a.res=a.w/a.cWidth):a.res=a.d,a},ba=function(a){if(t){var c,d,e,f=a||{};if(f.elements&&1===f.elements.nodeType&&("IMG"===f.elements.nodeName.toUpperCase()?f.elements=[f.elements]:(f.context=f.elements,f.elements=null)),c=f.elements||s.qsa(f.context||b,f.reevaluate||f.reselect?s.sel:s.selShort),e=c.length){for(s.setupRun(f),S=!0,d=0;e>d;d++)s.fillImg(c[d],f);s.teardownRun(f)}}};o=a.console&&console.warn?function(a){console.warn(a)}:u,G in v||(G="src"),A["image/jpeg"]=!0,A["image/gif"]=!0,A["image/png"]=!0,A["image/svg+xml"]=b.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image","1.1"),s.ns=("pf"+(new Date).getTime()).substr(0,9),s.supSrcset="srcset"in v,s.supSizes="sizes"in v,s.supPicture=!!a.HTMLPictureElement,s.supSrcset&&s.supPicture&&!s.supSizes&&!function(a){v.srcset="data:,a",a.src="data:,a",s.supSrcset=v.complete===a.complete,s.supPicture=s.supSrcset&&s.supPicture}(b.createElement("img")),s.supSrcset&&!s.supSizes?!function(){var a="data:image/gif;base64,R0lGODlhAgABAPAAAP///wAAACH5BAAAAAAALAAAAAACAAEAAAICBAoAOw==",c="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",d=b.createElement("img"),e=function(){var a=d.width;2===a&&(s.supSizes=!0),q=s.supSrcset&&!s.supSizes,t=!0,setTimeout(ba)};d.onload=e,d.onerror=e,d.setAttribute("sizes","9px"),d.srcset=c+" 1w,"+a+" 9w",d.src=c}():t=!0,s.selShort="picture>img,img[srcset]",s.sel=s.selShort,s.cfg=B,s.DPR=P||1,s.u=Q,s.types=A,s.setSize=u,s.makeUrl=$(function(a){return R.href=a,R.href}),s.qsa=function(a,b){return"querySelector"in a?a.querySelectorAll(b):[]},s.matchesMedia=function(){return a.matchMedia&&(matchMedia("(min-width: 0.1em)")||{}).matches?s.matchesMedia=function(a){return!a||matchMedia(a).matches}:s.matchesMedia=s.mMQ,s.matchesMedia.apply(this,arguments)},s.mMQ=function(a){return a?_(a):!0},s.calcLength=function(a){var b=_(a,!0)||!1;return 0>b&&(b=!1),b},s.supportsType=function(a){return a?A[a]:!0},s.parseSize=$(function(a){var b=(a||"").match(I);return{media:b&&b[1],length:b&&b[2]}}),s.parseSet=function(a){return a.cands||(a.cands=m(a.srcset,a)),a.cands},s.getEmValue=function(){var a;if(!p&&(a=b.body)){var c=b.createElement("div"),d=z.style.cssText,e=a.style.cssText;c.style.cssText=K,z.style.cssText=L,a.style.cssText=L,a.appendChild(c),p=c.offsetWidth,a.removeChild(c),p=parseFloat(p,10),z.style.cssText=d,a.style.cssText=e}return p||16},s.calcListLength=function(a){if(!(a in O)||B.uT){var b=s.calcLength(n(a));O[a]=b?b:Q.width}return O[a]},s.setRes=function(a){var b;if(a){b=s.parseSet(a);for(var c=0,d=b.length;d>c;c++)aa(b[c],a.sizes)}return b},s.setRes.res=aa,s.applySetCandidate=function(a,b){if(a.length){var c,d,e,f,h,k,l,m,n,o=b[s.ns],p=s.DPR;if(k=o.curSrc||b[G],l=o.curCan||j(b,k,a[0].set),l&&l.set===a[0].set&&(n=F&&!b.complete&&l.res-.1>p,n||(l.cached=!0,l.res>=p&&(h=l))),!h)for(a.sort(i),f=a.length,h=a[f-1],d=0;f>d;d++)if(c=a[d],c.res>=p){e=d-1,h=a[e]&&(n||k!==s.makeUrl(c.url))&&g(a[e].res,c.res,p,a[e].cached)?a[e]:c;break}h&&(m=s.makeUrl(h.url),o.curSrc=m,o.curCan=h,m!==k&&s.setSrc(b,h),s.setSize(b))}},s.setSrc=function(a,b){var c;a.src=b.url,"image/svg+xml"===b.set.type&&(c=a.style.width,a.style.width=a.offsetWidth+1+"px",a.offsetWidth+1&&(a.style.width=c))},s.getSet=function(a){var b,c,d,e=!1,f=a[s.ns].sets;for(b=0;b<f.length&&!e;b++)if(c=f[b],c.srcset&&s.matchesMedia(c.media)&&(d=s.supportsType(c.type))){"pending"===d&&(c=d),e=c;break}return e},s.parseSets=function(a,b,d){var e,f,g,h,i=b&&"PICTURE"===b.nodeName.toUpperCase(),j=a[s.ns];(j.src===c||d.src)&&(j.src=w.call(a,"src"),j.src?x.call(a,C,j.src):y.call(a,C)),(j.srcset===c||d.srcset||!s.supSrcset||a.srcset)&&(e=w.call(a,"srcset"),j.srcset=e,h=!0),j.sets=[],i&&(j.pic=!0,l(b,j.sets)),j.srcset?(f={srcset:j.srcset,sizes:w.call(a,"sizes")},j.sets.push(f),g=(q||j.src)&&H.test(j.srcset||""),g||!j.src||k(j.src,f)||f.has1x||(f.srcset+=", "+j.src,f.cands.push({url:j.src,d:1,set:f}))):j.src&&j.sets.push({srcset:j.src,sizes:null}),j.curCan=null,j.curSrc=c,j.supported=!(i||f&&!s.supSrcset||g&&!s.supSizes),h&&s.supSrcset&&!j.supported&&(e?(x.call(a,D,e),a.srcset=""):y.call(a,D)),j.supported&&!j.srcset&&(!j.src&&a.src||a.src!==s.makeUrl(j.src))&&(null===j.src?a.removeAttribute("src"):a.src=j.src),j.parsed=!0},s.fillImg=function(a,b){var c,d=b.reselect||b.reevaluate;a[s.ns]||(a[s.ns]={}),c=a[s.ns],(d||c.evaled!==r)&&((!c.parsed||b.reevaluate)&&s.parseSets(a,a.parentNode,b),c.supported?c.evaled=r:h(a))},s.setupRun=function(){(!S||M||P!==a.devicePixelRatio)&&f()},s.supPicture?(ba=u,s.fillImg=u):!function(){var c,d=a.attachEvent?/d$|^c/:/d$|^c|^i/,e=function(){var a=b.readyState||"";f=setTimeout(e,"loading"===a?200:999),b.body&&(s.fillImgs(),c=c||d.test(a),c&&clearTimeout(f))},f=setTimeout(e,b.body?9:99),g=function(a,b){var c,d,e=function(){var f=new Date-d;b>f?c=setTimeout(e,b-f):(c=null,a())};return function(){d=new Date,c||(c=setTimeout(e,b))}},h=z.clientHeight,i=function(){M=Math.max(a.innerWidth||0,z.clientWidth)!==Q.width||z.clientHeight!==h,h=z.clientHeight,M&&s.fillImgs()};Z(a,"resize",g(i,99)),Z(b,"readystatechange",e)}(),s.picturefill=ba,s.fillImgs=ba,s.teardownRun=u,ba._=s,a.picturefillCFG={pf:s,push:function(a){var b=a.shift();"function"==typeof s[b]?s[b].apply(s,a):(B[b]=a[0],S&&s.fillImgs({reselect:!0}))}};for(;J&&J.length;)a.picturefillCFG.push(J.shift());a.picturefill=ba,"object"==typeof module&&"object"==typeof module.exports?module.exports=ba:"function"==typeof define&&define.amd&&define("picturefill",function(){return ba}),s.supPicture||(A["image/webp"]=e("image/webp","data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAABBxAR/Q9ERP8DAABWUDggGAAAADABAJ0BKgEAAQADADQlpAADcAD++/1QAA=="))}(window,document);/*! picturefill - v3.0.2 - 2016-02-12
  428. * https://scottjehl.github.io/picturefill/
  429. * Copyright (c) 2016 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; Licensed MIT
  430. */
  431. !function(a){"use strict";var b,c=0,d=function(){window.picturefill&&a(window.picturefill),(window.picturefill||c>9999)&&clearInterval(b),c++};b=setInterval(d,8),d()}(function(a){"use strict";var b=window.document,c=window.Element,d=window.MutationObserver,e=function(){},f={disconnect:e,take:e,observe:e,start:e,stop:e,connected:!1},g=/^loade|^c|^i/.test(b.readyState||""),h=a._;if(h.mutationSupport=!1,h.observer=f,Object.keys&&window.HTMLSourceElement&&b.addEventListener){var i,j,k,l,m={src:1,srcset:1,sizes:1,media:1},n=Object.keys(m),o={attributes:!0,childList:!0,subtree:!0,attributeFilter:n},p=c&&c.prototype,q={},r=function(a,b){q[a]=h[a],h[a]=b};p&&!p.matches&&(p.matches=p.matchesSelector||p.mozMatchesSelector||p.webkitMatchesSelector||p.msMatchesSelector),p&&p.matches&&(i=function(a,b){return a.matches(b)},h.mutationSupport=!(!Object.create||!Object.defineProperties)),h.mutationSupport&&(f.observe=function(){k&&(f.connected=!0,j&&j.observe(b.documentElement,o))},f.disconnect=function(){f.connected=!1,j&&j.disconnect()},f.take=function(){j?h.onMutations(j.takeRecords()):l&&l.take()},f.start=function(){k=!0,f.observe()},f.stop=function(){k=!1,f.disconnect()},r("setupRun",function(){return f.disconnect(),q.setupRun.apply(this,arguments)}),r("teardownRun",function(){var a=q.setupRun.apply(this,arguments);return f.observe(),a}),r("setSrc",function(){var a,b=f.connected;return f.disconnect(),a=q.setSrc.apply(this,arguments),b&&f.observe(),a}),h.onMutations=function(a){var b,c,d=[];for(b=0,c=a.length;c>b;b++)g&&"childList"===a[b].type?h.onSubtreeChange(a[b],d):"attributes"===a[b].type&&h.onAttrChange(a[b],d);d.length&&h.fillImgs({elements:d,reevaluate:!0})},h.onSubtreeChange=function(a,b){h.findAddedMutations(a.addedNodes,b),h.findRemovedMutations(a.removedNodes,a.target,b)},h.findAddedMutations=function(a,b){var c,d,e,f;for(c=0,d=a.length;d>c;c++)e=a[c],1===e.nodeType&&(f=e.nodeName.toUpperCase(),"PICTURE"===f?h.addToElements(e.getElementsByTagName("img")[0],b):"IMG"===f&&i(e,h.selShort)?h.addToElements(e,b):"SOURCE"===f?h.addImgForSource(e,e.parentNode,b):h.addToElements(h.qsa(e,h.selShort),b))},h.findRemovedMutations=function(a,b,c){var d,e,f;for(d=0,e=a.length;e>d;d++)f=a[d],1===f.nodeType&&"SOURCE"===f.nodeName.toUpperCase()&&h.addImgForSource(f,b,c)},h.addImgForSource=function(a,b,c){b&&"PICTURE"!==(b.nodeName||"").toUpperCase()&&(b=b.parentNode,b&&"PICTURE"===(b.nodeName||"").toUpperCase()||(b=null)),b&&h.addToElements(b.getElementsByTagName("img")[0],c)},h.addToElements=function(a,b){var c,d;if(a)if("length"in a&&!a.nodeType)for(c=0,d=a.length;d>c;c++)h.addToElements(a[c],b);else a.parentNode&&-1===b.indexOf(a)&&b.push(a)},h.onAttrChange=function(a,b){var c,d=a.target[h.ns];d||"srcset"!==a.attributeName||"IMG"!==(c=a.target.nodeName.toUpperCase())?d&&(c||(c=a.target.nodeName.toUpperCase()),"IMG"===c?(a.attributeName in d&&(d[a.attributeName]=void 0),h.addToElements(a.target,b)):"SOURCE"===c&&h.addImgForSource(a.target,a.target.parentNode,b)):h.addToElements(a.target,b)},h.supPicture||(d&&!h.testMutationEvents?j=new d(h.onMutations):(l=function(){var a=!1,b=[],c=window.setImmediate||window.setTimeout;return function(d){a||(a=!0,l.take||(l.take=function(){b.length&&(h.onMutations(b),b=[]),a=!1}),c(l.take)),b.push(d)}}(),b.documentElement.addEventListener("DOMNodeInserted",function(a){f.connected&&g&&l({type:"childList",addedNodes:[a.target],removedNodes:[]})},!0),b.documentElement.addEventListener("DOMNodeRemoved",function(a){f.connected&&g&&"SOURCE"===(a.target||{}).nodeName&&l({type:"childList",addedNodes:[],removedNodes:[a.target],target:a.target.parentNode})},!0),b.documentElement.addEventListener("DOMAttrModified",function(a){f.connected&&m[a.attrName]&&l({type:"attributes",target:a.target,attributeName:a.attrName})},!0)),window.HTMLImageElement&&Object.defineProperties&&!function(){var a=b.createElement("img"),c=[],d=a.getAttribute,e=a.setAttribute,f={src:1};h.supSrcset&&!h.supSizes&&(f.srcset=1),Object.defineProperties(HTMLImageElement.prototype,{getAttribute:{value:function(a){var b;return f[a]&&(b=this[h.ns])&&void 0!==b[a]?b[a]:d.apply(this,arguments)},writeable:!0,enumerable:!0,configurable:!0}}),h.supSrcset||c.push("srcset"),h.supSizes||c.push("sizes"),c.forEach(function(a){Object.defineProperty(HTMLImageElement.prototype,a,{set:function(b){e.call(this,a,b)},get:function(){return d.call(this,a)||""},enumerable:!0,configurable:!0})}),"currentSrc"in a||!function(){var a,c=function(a,b){null==b&&(b=a.src||""),Object.defineProperty(a,"pfCurrentSrc",{value:b,writable:!0})},d=c;h.supSrcset&&window.devicePixelRatio&&(a=function(a,b){var c=a.d||a.w||a.res,d=b.d||b.w||b.res;return c-d},c=function(b){var c,e,f,g,i=b[h.ns];if(i&&i.supported&&i.srcset&&i.sets&&(e=h.parseSet(i.sets[0]))&&e.sort){for(e.sort(a),f=e.length,g=e[f-1],c=0;f>c;c++)if(e[c].d>=window.devicePixelRatio){g=e[c];break}g&&(g=h.makeUrl(g.url))}d(b,g)}),b.addEventListener("load",function(a){"IMG"===a.target.nodeName.toUpperCase()&&c(a.target)},!0),Object.defineProperty(HTMLImageElement.prototype,"currentSrc",{set:function(){window.console&&console.warn&&console.warn("currentSrc can't be set on img element")},get:function(){return this.complete&&c(this),this.src||this.srcset?this.pfCurrentSrc||"":""},enumerable:!0,configurable:!0})}(),!window.HTMLSourceElement||"srcset"in b.createElement("source")||["srcset","sizes"].forEach(function(a){Object.defineProperty(window.HTMLSourceElement.prototype,a,{set:function(b){this.setAttribute(a,b)},get:function(){return this.getAttribute(a)||""},enumerable:!0,configurable:!0})})}(),f.start()),g||b.addEventListener("DOMContentLoaded",function(){g=!0}))}});}
  432.  
  433.  
  434. // Object.defineProperty
  435. (function (nativeDefineProperty) {
  436.  
  437. var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
  438. var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
  439. var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
  440.  
  441. Object.defineProperty = function defineProperty(object, property, descriptor) {
  442.  
  443. // Where native support exists, assume it
  444. if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
  445. return nativeDefineProperty(object, property, descriptor);
  446. }
  447.  
  448. var propertyString = String(property);
  449. var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
  450. var getterType = 'get' in descriptor && typeof descriptor.get;
  451. var setterType = 'set' in descriptor && typeof descriptor.set;
  452.  
  453. if (object === null || !(object instanceof Object || typeof object === 'object')) {
  454. throw new TypeError('Object must be an object (Object.defineProperty polyfill)');
  455. }
  456.  
  457. if (!(descriptor instanceof Object)) {
  458. throw new TypeError('Descriptor must be an object (Object.defineProperty polyfill)');
  459. }
  460.  
  461. // handle descriptor.get
  462. if (getterType) {
  463. if (getterType !== 'function') {
  464. throw new TypeError('Getter expected a function (Object.defineProperty polyfill)');
  465. }
  466. if (!supportsAccessors) {
  467. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  468. }
  469. if (hasValueOrWritable) {
  470. throw new TypeError(ERR_VALUE_ACCESSORS);
  471. }
  472. object.__defineGetter__(propertyString, descriptor.get);
  473. } else {
  474. object[propertyString] = descriptor.value;
  475. }
  476.  
  477. // handle descriptor.set
  478. if (setterType) {
  479. if (setterType !== 'function') {
  480. throw new TypeError('Setter expected a function (Object.defineProperty polyfill)');
  481. }
  482. if (!supportsAccessors) {
  483. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  484. }
  485. if (hasValueOrWritable) {
  486. throw new TypeError(ERR_VALUE_ACCESSORS);
  487. }
  488. object.__defineSetter__(propertyString, descriptor.set);
  489. }
  490.  
  491. // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
  492. if ('value' in descriptor) {
  493. object[propertyString] = descriptor.value;
  494. }
  495.  
  496. return object;
  497. };
  498. }(Object.defineProperty));
  499.  
  500. // Array.from
  501.  
  502. // Wrapped in IIFE to prevent leaking to global scope.
  503. (function () {
  504. function parseIterable (arraylike) {
  505. var done = false;
  506. var iterableResponse;
  507. var tempArray = [];
  508.  
  509. // if the iterable doesn't have next;
  510. // it is an iterable if 'next' is a function but it has not been defined on
  511. // the object itself.
  512. if (typeof arraylike.next === 'function' && arraylike.hasOwnProperty('next') === false) {
  513. while (!done) {
  514. iterableResponse = arraylike.next();
  515. if (
  516. iterableResponse.hasOwnProperty('value') &&
  517. iterableResponse.hasOwnProperty('done')
  518. ) {
  519. if (iterableResponse.done === true) {
  520. done = true;
  521. break;
  522.  
  523. // handle the case where the done value is not Boolean
  524. } else if (iterableResponse.done !== false) {
  525. break;
  526. }
  527.  
  528. tempArray.push(iterableResponse.value);
  529. } else {
  530.  
  531. // it does not conform to the iterable pattern
  532. break;
  533. }
  534. }
  535. }
  536.  
  537. if (done) {
  538. return tempArray;
  539. } else {
  540.  
  541. // something went wrong return false;
  542. return false;
  543. }
  544.  
  545. }
  546.  
  547. Object.defineProperty(Array, 'from', {
  548. configurable: true,
  549. value: function from(source) {
  550. // handle non-objects
  551. if (source === undefined || source === null) {
  552. throw new TypeError(source + ' is not an object');
  553. }
  554.  
  555. // handle maps that are not functions
  556. if (1 in arguments && !(arguments[1] instanceof Function)) {
  557. throw new TypeError(arguments[1] + ' is not a function');
  558. }
  559.  
  560. var arraylike = typeof source === 'string' ? source.split('') : Object(source);
  561. var map = arguments[1];
  562. var scope = arguments[2];
  563. var array = [];
  564. var index = -1;
  565. var length = Math.min(Math.max(Number(arraylike.length) || 0, 0), 9007199254740991);
  566. var value;
  567.  
  568. // variables for rebuilding array from iterator
  569. var arrayFromIterable;
  570.  
  571. // if it is an iterable treat like one
  572. arrayFromIterable = parseIterable(arraylike);
  573.  
  574. //if it is a Map or a Set then handle them appropriately
  575. if (
  576. typeof arraylike.entries === 'function' &&
  577. typeof arraylike.values === 'function'
  578. ) {
  579. if (arraylike.constructor.name === 'Set' && 'values' in Set.prototype) {
  580. arrayFromIterable = parseIterable(arraylike.values());
  581. }
  582. if (arraylike.constructor.name === 'Map' && 'entries' in Map.prototype) {
  583. arrayFromIterable = parseIterable(arraylike.entries());
  584. }
  585. }
  586.  
  587. if (arrayFromIterable) {
  588. arraylike = arrayFromIterable;
  589. length = arrayFromIterable.length;
  590. }
  591.  
  592. while (++index < length) {
  593. if (index in arraylike) {
  594. value = arraylike[index];
  595.  
  596. array[index] = map ? map.call(scope, value, index) : value;
  597. }
  598. }
  599.  
  600. array.length = length;
  601.  
  602. return array;
  603. },
  604. writable: true
  605. });
  606. }());
  607.  
  608. // Array.isArray
  609. (function (toString) {
  610. Object.defineProperty(Array, 'isArray', {
  611. configurable: true,
  612. value: function isArray(object) {
  613. return toString.call(object) === '[object Array]';
  614. },
  615. writable: true
  616. });
  617. })(Object.prototype.toString);
  618.  
  619. // Array.of
  620. (function (slice) {
  621. Object.defineProperty(Array, 'of', {
  622. configurable: true,
  623. value: function of() {
  624. return slice.call(arguments);
  625. },
  626. writable: true
  627. });
  628. })(Array.prototype.slice);
  629.  
  630. // Array.prototype.every
  631. Array.prototype.every = function every(callback) {
  632. if (this === undefined || this === null) {
  633. throw new TypeError(this + 'is not an object');
  634. }
  635.  
  636. if (!(callback instanceof Function)) {
  637. throw new TypeError(callback + ' is not a function');
  638. }
  639.  
  640. var
  641. object = Object(this),
  642. scope = arguments[1],
  643. arraylike = object instanceof String ? object.split('') : object,
  644. length = Number(arraylike.length) || 0,
  645. index = -1;
  646.  
  647. while (++index < length) {
  648. if (index in arraylike && !callback.call(scope, arraylike[index], index, object)) {
  649. return false;
  650. }
  651. }
  652.  
  653. return true;
  654. };
  655.  
  656. // Array.prototype.fill
  657. Object.defineProperty(Array.prototype, 'fill', {
  658. configurable: true,
  659. value: function fill(value) {
  660. if (this === undefined || this === null) {
  661. throw new TypeError(this + ' is not an object');
  662. }
  663.  
  664. var arrayLike = Object(this);
  665.  
  666. var length = Math.max(Math.min(arrayLike.length, 9007199254740991), 0) || 0;
  667.  
  668. var relativeStart = 1 in arguments ? parseInt(Number(arguments[1]), 10) || 0 : 0;
  669.  
  670. relativeStart = relativeStart < 0 ? Math.max(length + relativeStart, 0) : Math.min(relativeStart, length);
  671.  
  672. var relativeEnd = 2 in arguments && arguments[2] !== undefined ? parseInt(Number(arguments[2]), 10) || 0 : length;
  673.  
  674. relativeEnd = relativeEnd < 0 ? Math.max(length + arguments[2], 0) : Math.min(relativeEnd, length);
  675.  
  676. while (relativeStart < relativeEnd) {
  677. arrayLike[relativeStart] = value;
  678.  
  679. ++relativeStart;
  680. }
  681.  
  682. return arrayLike;
  683. },
  684. writable: true
  685. });
  686.  
  687. // Array.prototype.filter
  688. Array.prototype.filter = function filter(callback) {
  689. if (this === undefined || this === null) {
  690. throw new TypeError(this + 'is not an object');
  691. }
  692.  
  693. if (!(callback instanceof Function)) {
  694. throw new TypeError(callback + ' is not a function');
  695. }
  696.  
  697. var
  698. object = Object(this),
  699. scope = arguments[1],
  700. arraylike = object instanceof String ? object.split('') : object,
  701. length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
  702. index = -1,
  703. result = [],
  704. element;
  705.  
  706. while (++index < length) {
  707. element = arraylike[index];
  708.  
  709. if (index in arraylike && callback.call(scope, element, index, object)) {
  710. result.push(element);
  711. }
  712. }
  713.  
  714. return result;
  715. };
  716.  
  717. // Array.prototype.forEach
  718. Array.prototype.forEach = function forEach(callback) {
  719. if (this === undefined || this === null) {
  720. throw new TypeError(this + 'is not an object');
  721. }
  722.  
  723. if (!(callback instanceof Function)) {
  724. throw new TypeError(callback + ' is not a function');
  725. }
  726.  
  727. var
  728. object = Object(this),
  729. scope = arguments[1],
  730. arraylike = object instanceof String ? object.split('') : object,
  731. length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
  732. index = -1,
  733. result = [],
  734. element;
  735.  
  736. while (++index < length) {
  737. if (index in arraylike) {
  738. callback.call(scope, arraylike[index], index, object);
  739. }
  740. }
  741. };
  742.  
  743. // Array.prototype.indexOf
  744. Array.prototype.indexOf = function indexOf(searchElement) {
  745. if (this === undefined || this === null) {
  746. throw new TypeError(this + 'is not an object');
  747. }
  748.  
  749. var
  750. arraylike = this instanceof String ? this.split('') : this,
  751. length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
  752. index = Number(arguments[1]) || 0;
  753.  
  754. index = (index < 0 ? Math.max(length + index, 0) : index) - 1;
  755.  
  756. while (++index < length) {
  757. if (index in arraylike && arraylike[index] === searchElement) {
  758. return index;
  759. }
  760. }
  761.  
  762. return -1;
  763. };
  764.  
  765. // Array.prototype.lastIndexOf
  766. Array.prototype.lastIndexOf = function lastIndexOf(searchElement) {
  767. if (this === undefined || this === null) {
  768. throw new TypeError(this + 'is not an object');
  769. }
  770.  
  771. var
  772. arraylike = this instanceof String ? this.split('') : this,
  773. length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
  774. index = Number(arguments[1]) || 0;
  775.  
  776. index = 1 in arguments ? (index < 0 ? Math.max(length + index, 0) : index) + 1 : length;
  777.  
  778. while (--index >= 0) {
  779. if (index in arraylike && arraylike[index] === searchElement) {
  780. return index;
  781. }
  782. }
  783.  
  784. return -1;
  785. };
  786.  
  787. // Array.prototype.map
  788. Array.prototype.map = function map(callback) {
  789. if (this === undefined || this === null) {
  790. throw new TypeError(this + 'is not an object');
  791. }
  792.  
  793. if (!(callback instanceof Function)) {
  794. throw new TypeError(callback + ' is not a function');
  795. }
  796.  
  797. var
  798. object = Object(this),
  799. scope = arguments[1],
  800. arraylike = object instanceof String ? object.split('') : object,
  801. length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
  802. index = -1,
  803. result = [],
  804. element;
  805.  
  806. while (++index < length) {
  807. if (index in arraylike) {
  808. result[index] = callback.call(scope, arraylike[index], index, object);
  809. }
  810. }
  811.  
  812. return result;
  813. };
  814.  
  815. // Array.prototype.reduce
  816. Array.prototype.reduce = function reduce(callback) {
  817. if (this === undefined || this === null) {
  818. throw new TypeError(this + 'is not an object');
  819. }
  820.  
  821. if (!(callback instanceof Function)) {
  822. throw new TypeError(callback + ' is not a function');
  823. }
  824.  
  825. var
  826. object = Object(this),
  827. scope = arguments[1],
  828. arraylike = object instanceof String ? object.split('') : object,
  829. length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
  830. index = -1,
  831. previousValue;
  832.  
  833. if (1 in arguments) {
  834. previousValue = arguments[1];
  835. } else {
  836. while (++index < length && !(index in arraylike)) {}
  837.  
  838. if (index >= length) {
  839. throw new TypeError('Reduce of empty array with no initial value');
  840. }
  841.  
  842. previousValue = arraylike[index];
  843. }
  844.  
  845. while (++index < length) {
  846. if (index in arraylike) {
  847. previousValue = callback(previousValue, arraylike[index], index, object);
  848. }
  849. }
  850.  
  851. return previousValue;
  852. };
  853.  
  854. // Array.prototype.reduceRight
  855. Array.prototype.reduceRight = function reduceRight(callback) {
  856. if (this === undefined || this === null) {
  857. throw new TypeError(this + 'is not an object');
  858. }
  859.  
  860. if (!(callback instanceof Function)) {
  861. throw new TypeError(callback + ' is not a function');
  862. }
  863.  
  864. var
  865. object = Object(this),
  866. scope = arguments[1],
  867. arraylike = object instanceof String ? object.split('') : object,
  868. length = -1,
  869. index = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
  870. previousValue;
  871.  
  872. if (1 in arguments) {
  873. previousValue = arguments[1];
  874. } else {
  875. while (--index > length && !(index in arraylike)) {}
  876.  
  877. if (index <= length) {
  878. throw new TypeError('Reduce of empty array with no initial value');
  879. }
  880.  
  881. previousValue = arraylike[index];
  882. }
  883.  
  884. while (--index > length) {
  885. if (index in arraylike) {
  886. previousValue = callback(previousValue, arraylike[index], index, object);
  887. }
  888. }
  889.  
  890. return previousValue;
  891. };
  892.  
  893. // Array.prototype.some
  894. Array.prototype.some = function some(callback) {
  895. if (this === undefined || this === null) {
  896. throw new TypeError(this + 'is not an object');
  897. }
  898.  
  899. if (!(callback instanceof Function)) {
  900. throw new TypeError(callback + ' is not a function');
  901. }
  902.  
  903. var
  904. object = Object(this),
  905. scope = arguments[1],
  906. arraylike = object instanceof String ? object.split('') : object,
  907. length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
  908. index = -1;
  909.  
  910. while (++index < length) {
  911. if (index in arraylike && callback.call(scope, arraylike[index], index, object)) {
  912. return true;
  913. }
  914. }
  915.  
  916. return false;
  917. };
  918.  
  919. // Document
  920.  
  921. if (this.HTMLDocument) { // IE8
  922.  
  923. // HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
  924. this.Document = this.HTMLDocument;
  925.  
  926. } else {
  927.  
  928. // 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.
  929. this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
  930. this.Document.prototype = document;
  931. }
  932.  
  933. // Element
  934. (function () {
  935.  
  936. // IE8
  937. if (window.Element && !window.HTMLElement) {
  938. window.HTMLElement = window.Element;
  939. return;
  940. }
  941.  
  942. // create Element constructor
  943. window.Element = window.HTMLElement = new Function('return function Element() {}')();
  944.  
  945. // generate sandboxed iframe
  946. var vbody = document.appendChild(document.createElement('body'));
  947. var frame = vbody.appendChild(document.createElement('iframe'));
  948.  
  949. // use sandboxed iframe to replicate Element functionality
  950. var frameDocument = frame.contentWindow.document;
  951. var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
  952. var cache = {};
  953.  
  954. // polyfill Element.prototype on an element
  955. var shiv = function (element, deep) {
  956. var
  957. childNodes = element.childNodes || [],
  958. index = -1,
  959. key, value, childNode;
  960.  
  961. if (element.nodeType === 1 && element.constructor !== Element) {
  962. element.constructor = Element;
  963.  
  964. for (key in cache) {
  965. value = cache[key];
  966. element[key] = value;
  967. }
  968. }
  969.  
  970. while (childNode = deep && childNodes[++index]) {
  971. shiv(childNode, deep);
  972. }
  973.  
  974. return element;
  975. };
  976.  
  977. var elements = document.getElementsByTagName('*');
  978. var nativeCreateElement = document.createElement;
  979. var interval;
  980. var loopLimit = 100;
  981.  
  982. prototype.attachEvent('onpropertychange', function (event) {
  983. var
  984. propertyName = event.propertyName,
  985. nonValue = !cache.hasOwnProperty(propertyName),
  986. newValue = prototype[propertyName],
  987. oldValue = cache[propertyName],
  988. index = -1,
  989. element;
  990.  
  991. while (element = elements[++index]) {
  992. if (element.nodeType === 1) {
  993. if (nonValue || element[propertyName] === oldValue) {
  994. element[propertyName] = newValue;
  995. }
  996. }
  997. }
  998.  
  999. cache[propertyName] = newValue;
  1000. });
  1001.  
  1002. prototype.constructor = Element;
  1003.  
  1004. if (!prototype.hasAttribute) {
  1005. // <Element>.hasAttribute
  1006. prototype.hasAttribute = function hasAttribute(name) {
  1007. return this.getAttribute(name) !== null;
  1008. };
  1009. }
  1010.  
  1011. // Apply Element prototype to the pre-existing DOM as soon as the body element appears.
  1012. function bodyCheck(e) {
  1013. if (!(loopLimit--)) clearTimeout(interval);
  1014. if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
  1015. shiv(document, true);
  1016. if (interval && document.body.prototype) clearTimeout(interval);
  1017. return (!!document.body.prototype);
  1018. }
  1019. return false;
  1020. }
  1021. if (!bodyCheck(true)) {
  1022. document.onreadystatechange = bodyCheck;
  1023. interval = setInterval(bodyCheck, 25);
  1024. }
  1025.  
  1026. // Apply to any new elements created after load
  1027. document.createElement = function createElement(nodeName) {
  1028. var element = nativeCreateElement(String(nodeName).toLowerCase());
  1029. return shiv(element);
  1030. };
  1031.  
  1032. // remove sandboxed iframe
  1033. document.removeChild(vbody);
  1034. })();
  1035.  
  1036. // Event
  1037. (function () {
  1038. var unlistenableWindowEvents = {
  1039. click: 1,
  1040. dblclick: 1,
  1041. keyup: 1,
  1042. keypress: 1,
  1043. keydown: 1,
  1044. mousedown: 1,
  1045. mouseup: 1,
  1046. mousemove: 1,
  1047. mouseover: 1,
  1048. mouseenter: 1,
  1049. mouseleave: 1,
  1050. mouseout: 1,
  1051. storage: 1,
  1052. storagecommit: 1,
  1053. textinput: 1
  1054. };
  1055.  
  1056. function indexOf(array, element) {
  1057. var
  1058. index = -1,
  1059. length = array.length;
  1060.  
  1061. while (++index < length) {
  1062. if (index in array && array[index] === element) {
  1063. return index;
  1064. }
  1065. }
  1066.  
  1067. return -1;
  1068. }
  1069.  
  1070. var existingProto = (window.Event && window.Event.prototype) || null;
  1071. window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
  1072. if (!type) {
  1073. throw new Error('Not enough arguments');
  1074. }
  1075.  
  1076. // Shortcut if browser supports createEvent
  1077. if ('createEvent' in document) {
  1078. var event = document.createEvent('Event');
  1079. var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
  1080. var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
  1081.  
  1082. event.initEvent(type, bubbles, cancelable);
  1083.  
  1084. return event;
  1085. }
  1086.  
  1087. var event = document.createEventObject();
  1088.  
  1089. event.type = type;
  1090. event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
  1091. event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
  1092.  
  1093. return event;
  1094. };
  1095. if (existingProto) {
  1096. Object.defineProperty(window.Event, 'prototype', {
  1097. configurable: false,
  1098. enumerable: false,
  1099. writable: true,
  1100. value: existingProto
  1101. });
  1102. }
  1103.  
  1104. if (!('createEvent' in document)) {
  1105. window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
  1106. var
  1107. element = this,
  1108. type = arguments[0],
  1109. listener = arguments[1];
  1110.  
  1111. if (element === window && type in unlistenableWindowEvents) {
  1112. 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.');
  1113. }
  1114.  
  1115. if (!element._events) {
  1116. element._events = {};
  1117. }
  1118.  
  1119. if (!element._events[type]) {
  1120. element._events[type] = function (event) {
  1121. var
  1122. list = element._events[event.type].list,
  1123. events = list.slice(),
  1124. index = -1,
  1125. length = events.length,
  1126. eventElement;
  1127.  
  1128. event.preventDefault = function preventDefault() {
  1129. if (event.cancelable !== false) {
  1130. event.returnValue = false;
  1131. }
  1132. };
  1133.  
  1134. event.stopPropagation = function stopPropagation() {
  1135. event.cancelBubble = true;
  1136. };
  1137.  
  1138. event.stopImmediatePropagation = function stopImmediatePropagation() {
  1139. event.cancelBubble = true;
  1140. event.cancelImmediate = true;
  1141. };
  1142.  
  1143. event.currentTarget = element;
  1144. event.relatedTarget = event.fromElement || null;
  1145. event.target = event.target || event.srcElement || element;
  1146. event.timeStamp = new Date().getTime();
  1147.  
  1148. if (event.clientX) {
  1149. event.pageX = event.clientX + document.documentElement.scrollLeft;
  1150. event.pageY = event.clientY + document.documentElement.scrollTop;
  1151. }
  1152.  
  1153. while (++index < length && !event.cancelImmediate) {
  1154. if (index in events) {
  1155. eventElement = events[index];
  1156.  
  1157. if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
  1158. eventElement.call(element, event);
  1159. }
  1160. }
  1161. }
  1162. };
  1163.  
  1164. element._events[type].list = [];
  1165.  
  1166. if (element.attachEvent) {
  1167. element.attachEvent('on' + type, element._events[type]);
  1168. }
  1169. }
  1170.  
  1171. element._events[type].list.push(listener);
  1172. };
  1173.  
  1174. window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
  1175. var
  1176. element = this,
  1177. type = arguments[0],
  1178. listener = arguments[1],
  1179. index;
  1180.  
  1181. if (element._events && element._events[type] && element._events[type].list) {
  1182. index = indexOf(element._events[type].list, listener);
  1183.  
  1184. if (index !== -1) {
  1185. element._events[type].list.splice(index, 1);
  1186.  
  1187. if (!element._events[type].list.length) {
  1188. if (element.detachEvent) {
  1189. element.detachEvent('on' + type, element._events[type]);
  1190. }
  1191. delete element._events[type];
  1192. }
  1193. }
  1194. }
  1195. };
  1196.  
  1197. window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
  1198. if (!arguments.length) {
  1199. throw new Error('Not enough arguments');
  1200. }
  1201.  
  1202. if (!event || typeof event.type !== 'string') {
  1203. throw new Error('DOM Events Exception 0');
  1204. }
  1205.  
  1206. var element = this, type = event.type;
  1207.  
  1208. try {
  1209. if (!event.bubbles) {
  1210. event.cancelBubble = true;
  1211.  
  1212. var cancelBubbleEvent = function (event) {
  1213. event.cancelBubble = true;
  1214.  
  1215. (element || window).detachEvent('on' + type, cancelBubbleEvent);
  1216. };
  1217.  
  1218. this.attachEvent('on' + type, cancelBubbleEvent);
  1219. }
  1220.  
  1221. this.fireEvent('on' + type, event);
  1222. } catch (error) {
  1223. event.target = element;
  1224.  
  1225. do {
  1226. event.currentTarget = element;
  1227.  
  1228. if ('_events' in element && typeof element._events[type] === 'function') {
  1229. element._events[type].call(element, event);
  1230. }
  1231.  
  1232. if (typeof element['on' + type] === 'function') {
  1233. element['on' + type].call(element, event);
  1234. }
  1235.  
  1236. element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
  1237. } while (element && !event.cancelBubble);
  1238. }
  1239.  
  1240. return true;
  1241. };
  1242. }
  1243. })();
  1244.  
  1245. // CustomEvent
  1246. this.CustomEvent = function CustomEvent(type, eventInitDict) {
  1247. if (!type) {
  1248. throw Error('TypeError: Failed to construct "CustomEvent": An event name must be provided.');
  1249. }
  1250.  
  1251. var event;
  1252. eventInitDict = eventInitDict || {bubbles: false, cancelable: false, detail: null};
  1253.  
  1254. if ('createEvent' in document) {
  1255. try {
  1256. event = document.createEvent('CustomEvent');
  1257. event.initCustomEvent(type, eventInitDict.bubbles, eventInitDict.cancelable, eventInitDict.detail);
  1258. } catch (error) {
  1259. // for browsers which don't support CustomEvent at all, we use a regular event instead
  1260. event = document.createEvent('Event');
  1261. event.initEvent(type, eventInitDict.bubbles, eventInitDict.cancelable);
  1262. event.detail = eventInitDict.detail;
  1263. }
  1264. } else {
  1265.  
  1266. // IE8
  1267. event = new Event(type, eventInitDict);
  1268. event.detail = eventInitDict && eventInitDict.detail || null;
  1269. }
  1270. return event;
  1271. };
  1272.  
  1273. CustomEvent.prototype = Event.prototype;
  1274.  
  1275. // _DOMTokenList
  1276. var _DOMTokenList = (function (global) {
  1277.  
  1278. function tokenize(token) {
  1279. if (/^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$/.test(token)) {
  1280. return String(token);
  1281. } else {
  1282. throw new Error('InvalidCharacterError: DOM Exception 5');
  1283. }
  1284. }
  1285.  
  1286. function toObject(self) {
  1287. for (var index = -1, object = {}, element; element = self[++index];) {
  1288. object[element] = true;
  1289. }
  1290.  
  1291. return object;
  1292. }
  1293.  
  1294. function fromObject(self, object) {
  1295. var array = [], token;
  1296.  
  1297. for (token in object) {
  1298. if (object[token]) {
  1299. array.push(token);
  1300. }
  1301. }
  1302.  
  1303. [].splice.apply(self, [0, self.length].concat(array));
  1304. }
  1305.  
  1306. var DTL = function() {};
  1307.  
  1308. DTL.prototype = {
  1309. constructor: DTL,
  1310. item: function item(index) {
  1311. return this[parseFloat(index)] || null;
  1312. },
  1313. length: Array.prototype.length,
  1314. toString: function toString() {
  1315. return [].join.call(this, ' ');
  1316. },
  1317.  
  1318. add: function add() {
  1319. for (var object = toObject(this), index = 0, token; index in arguments; ++index) {
  1320. token = tokenize(arguments[index]);
  1321.  
  1322. object[token] = true;
  1323. }
  1324.  
  1325. fromObject(this, object);
  1326. },
  1327. contains: function contains(token) {
  1328. return token in toObject(this);
  1329. },
  1330. remove: function remove() {
  1331. for (var object = toObject(this), index = 0, token; index in arguments; ++index) {
  1332. token = tokenize(arguments[index]);
  1333.  
  1334. object[token] = false;
  1335. }
  1336.  
  1337. fromObject(this, object);
  1338. },
  1339. toggle: function toggle(token) {
  1340. var
  1341. object = toObject(this),
  1342. contains = 1 in arguments ? !arguments[1] : tokenize(token) in object;
  1343.  
  1344. object[token] = !contains;
  1345.  
  1346. fromObject(this, object);
  1347.  
  1348. return !contains;
  1349. }
  1350. };
  1351.  
  1352. return DTL;
  1353.  
  1354. })(this);
  1355.  
  1356. // DOMTokenList
  1357. (function (global, join, splice) {
  1358. var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
  1359.  
  1360. if (!nativeImpl) {
  1361. global.DOMTokenList = _DOMTokenList;
  1362. } else {
  1363. var NativeToggle = nativeImpl.prototype.toggle;
  1364.  
  1365. nativeImpl.prototype.toggle = function toggle(token) {
  1366. if (1 in arguments) {
  1367. var contains = this.contains(token);
  1368. var force = !!arguments[1];
  1369.  
  1370. if ((contains && force) || (!contains && !force)) {
  1371. return force;
  1372. }
  1373. }
  1374.  
  1375. return NativeToggle.call(this, token);
  1376. };
  1377.  
  1378. }
  1379.  
  1380. })(this, Array.prototype.join, Array.prototype.splice);
  1381.  
  1382. // Date.now
  1383. Date.now = function now() {
  1384. return new Date().getTime();
  1385. };
  1386.  
  1387. // Date.prototype.toISOString
  1388. Date.prototype.toISOString = function toISOString() {
  1389. var date = this;
  1390.  
  1391. function pad(str, len) {
  1392. var pad = "0000";
  1393. str = '' + str;
  1394. return pad.substr(0, len - str.length) + str
  1395. }
  1396.  
  1397. var y = date.getUTCFullYear(),
  1398. m = pad(date.getUTCMonth() + 1, 2),
  1399. d = pad(date.getUTCDate(), 2),
  1400. h = pad(date.getUTCHours(), 2),
  1401. i = pad(date.getUTCMinutes(), 2),
  1402. s = pad(date.getUTCSeconds(), 2),
  1403. ms = pad(date.getUTCMilliseconds(), 3);
  1404.  
  1405. return y +'-'+ m +'-'+ d + 'T' + h +':'+ i +':'+ s +'.'+ ms +'Z';
  1406. };
  1407.  
  1408. // _mutation
  1409. // http://dom.spec.whatwg.org/#mutation-method-macro
  1410. function _mutation(nodes) {
  1411. if (!nodes.length) {
  1412. throw new Error('DOM Exception 8');
  1413. } else if (nodes.length === 1) {
  1414. return typeof nodes[0] === 'string' ? document.createTextNode(nodes[0]) : nodes[0];
  1415. } else {
  1416. var
  1417. fragment = document.createDocumentFragment(),
  1418. length = nodes.length,
  1419. index = -1,
  1420. node;
  1421.  
  1422. while (++index < length) {
  1423. node = nodes[index];
  1424.  
  1425. fragment.appendChild(typeof node === 'string' ? document.createTextNode(node) : node);
  1426. }
  1427.  
  1428. return fragment;
  1429. }
  1430. }
  1431.  
  1432. // Element.prototype.after
  1433. Document.prototype.after = Element.prototype.after = function after() {
  1434. if (this.parentNode) {
  1435. this.parentNode.insertBefore(_mutation(arguments), this.nextSibling);
  1436. }
  1437. };
  1438.  
  1439. // Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
  1440. // TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
  1441. if ("Text" in this) {
  1442. Text.prototype.after = Element.prototype.after;
  1443. }
  1444.  
  1445. // Element.prototype.append
  1446. Document.prototype.append = Element.prototype.append = function append() {
  1447. this.appendChild(_mutation(arguments));
  1448. };
  1449.  
  1450. // Element.prototype.before
  1451. Document.prototype.before = Element.prototype.before = function before() {
  1452. if (this.parentNode) {
  1453. this.parentNode.insertBefore(_mutation(arguments), this);
  1454. }
  1455. };
  1456.  
  1457. // Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
  1458. // TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
  1459. if ("Text" in this) {
  1460. Text.prototype.before = Element.prototype.before;
  1461. }
  1462.  
  1463. // Element.prototype.classList
  1464. Object.defineProperty(Element.prototype, 'classList', {
  1465. configurable: true,
  1466. get: function () {
  1467.  
  1468. function pull() {
  1469. var className = (typeof element.className === "object" ? element.className.baseVal : element.className);
  1470. [].splice.apply(classList, [0, classList.length].concat((className || '').replace(/^\s+|\s+$/g, '').split(/\s+/)));
  1471. }
  1472.  
  1473. function push() {
  1474. if (element.attachEvent) {
  1475. element.detachEvent('onpropertychange', pull);
  1476. }
  1477.  
  1478. if (typeof element.className === "object") {
  1479. element.className.baseVal = original.toString.call(classList);
  1480. } else {
  1481. element.className = original.toString.call(classList);
  1482. }
  1483.  
  1484. if (element.attachEvent) {
  1485. element.attachEvent('onpropertychange', pull);
  1486. }
  1487. }
  1488.  
  1489. var element = this;
  1490. var original = _DOMTokenList.prototype;
  1491. var ClassList = function ClassList() {};
  1492. var classList;
  1493.  
  1494. ClassList.prototype = new _DOMTokenList;
  1495.  
  1496. ClassList.prototype.item = function item(index) {
  1497. return pull(), original.item.apply(classList, arguments);
  1498. };
  1499.  
  1500. ClassList.prototype.toString = function toString() {
  1501. return pull(), original.toString.apply(classList, arguments);
  1502. };
  1503.  
  1504. ClassList.prototype.add = function add() {
  1505. return pull(), original.add.apply(classList, arguments), push();
  1506. };
  1507.  
  1508. ClassList.prototype.contains = function contains(token) {
  1509. return pull(), original.contains.apply(classList, arguments);
  1510. };
  1511.  
  1512. ClassList.prototype.remove = function remove() {
  1513. return pull(), original.remove.apply(classList, arguments), push();
  1514. };
  1515.  
  1516. ClassList.prototype.toggle = function toggle(token) {
  1517. return pull(), token = original.toggle.apply(classList, arguments), push(), token;
  1518. };
  1519.  
  1520. classList = new ClassList;
  1521.  
  1522. if (element.attachEvent) {
  1523. element.attachEvent('onpropertychange', pull);
  1524. }
  1525.  
  1526. return classList;
  1527. }
  1528. });
  1529.  
  1530. // Element.prototype.cloneNode
  1531. Element.prototype.cloneNode = (function(nativeFunc) {
  1532. return function(deep) {
  1533. var clone = nativeFunc.call(this, deep);
  1534.  
  1535. if ('checked' in this) clone.checked = this.checked;
  1536.  
  1537. return clone;
  1538. }
  1539. })(Element.prototype.cloneNode);
  1540.  
  1541. // document.querySelector
  1542. (function (global) {
  1543. var
  1544. head = document.getElementsByTagName('head')[0];
  1545.  
  1546. function getElementsByQuery(node, selector, one) {
  1547. var
  1548. generator = document.createElement(),
  1549. id = 'qsa' + String(Math.random()).slice(3),
  1550. style, elements;
  1551.  
  1552. generator.innerHTML = 'x<style>' + selector + '{qsa:' + id + ';}';
  1553.  
  1554. style = head.appendChild(generator.lastChild);
  1555.  
  1556. elements = getElements(node, selector, one, id);
  1557.  
  1558. head.removeChild(style);
  1559.  
  1560. return one ? elements[0] : elements;
  1561. }
  1562.  
  1563. function getElements(node, selector, one, id) {
  1564. var
  1565. validNode = /1|9/.test(node.nodeType),
  1566. childNodes = node.childNodes,
  1567. elements = [],
  1568. index = -1,
  1569. childNode;
  1570.  
  1571. if (validNode && node.currentStyle && node.currentStyle.qsa === id) {
  1572. if (elements.push(node) && one) {
  1573. return elements;
  1574. }
  1575. }
  1576.  
  1577. while (childNode = childNodes[++index]) {
  1578. elements = elements.concat(getElements(childNode, selector, one, id));
  1579.  
  1580. if (one && elements.length) {
  1581. return elements;
  1582. }
  1583. }
  1584.  
  1585. return elements;
  1586. }
  1587.  
  1588. Document.prototype.querySelector = Element.prototype.querySelector = function querySelectorAll(selector) {
  1589. return getElementsByQuery(this, selector, true);
  1590. };
  1591.  
  1592. Document.prototype.querySelectorAll = Element.prototype.querySelectorAll = function querySelectorAll(selector) {
  1593. return getElementsByQuery(this, selector, false);
  1594. };
  1595. })(this);
  1596.  
  1597. // Element.prototype.matches
  1598. Element.prototype.matches = Element.prototype.webkitMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || function matches(selector) {
  1599.  
  1600. var element = this;
  1601. var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
  1602. var index = 0;
  1603.  
  1604. while (elements[index] && elements[index] !== element) {
  1605. ++index;
  1606. }
  1607.  
  1608. return !!elements[index];
  1609. };
  1610.  
  1611. // Element.prototype.closest
  1612. Element.prototype.closest = function closest(selector) {
  1613. var node = this;
  1614.  
  1615. while (node) {
  1616. if (node.matches(selector)) return node;
  1617. else node = node.parentElement;
  1618. }
  1619.  
  1620. return null;
  1621. };
  1622.  
  1623. // Element.prototype.prepend
  1624. Document.prototype.prepend = Element.prototype.prepend = function prepend() {
  1625. this.insertBefore(_mutation(arguments), this.firstChild);
  1626. };
  1627.  
  1628. // Element.prototype.remove
  1629. Document.prototype.remove = Element.prototype.remove = function remove() {
  1630. if (this.parentNode) {
  1631. this.parentNode.removeChild(this);
  1632. }
  1633. };
  1634.  
  1635. // Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
  1636. // TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
  1637. if ("Text" in this) {
  1638. Text.prototype.remove = Element.prototype.remove;
  1639. }
  1640.  
  1641. // Element.prototype.replaceWith
  1642. Document.prototype.replaceWith = Element.prototype.replaceWith = function replaceWith() {
  1643. if (this.parentNode) {
  1644. this.parentNode.replaceChild(_mutation(arguments), this);
  1645. }
  1646. };
  1647.  
  1648. // Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
  1649. // TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
  1650. if ('Text' in this) {
  1651. Text.prototype.replaceWith = Element.prototype.replaceWith;
  1652. }
  1653.  
  1654. // Event.DOMContentLoaded
  1655. document.attachEvent('onreadystatechange', function() {
  1656. if (document.readyState === 'complete') {
  1657. document.dispatchEvent(new Event('DOMContentLoaded', {
  1658. bubbles: true
  1659. }));
  1660. }
  1661. });
  1662.  
  1663. // Function.prototype.bind
  1664. // https://github.com/es-shims/es5-shim/blob/d6d7ff1b131c7ba14c798cafc598bb6780d37d3b/es5-shim.js#L182
  1665. Object.defineProperty(Function.prototype, 'bind', {
  1666. value: function bind(that) { // .length is 1
  1667. // add necessary es5-shim utilities
  1668. var $Array = Array;
  1669. var $Object = Object;
  1670. var ObjectPrototype = $Object.prototype;
  1671. var ArrayPrototype = $Array.prototype;
  1672. var Empty = function Empty() {};
  1673. var to_string = ObjectPrototype.toString;
  1674. var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
  1675. var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, tryFunctionObject = function tryFunctionObject(value) { try { fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]'; isCallable = function isCallable(value) { if (typeof value !== 'function') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
  1676. var array_slice = ArrayPrototype.slice;
  1677. var array_concat = ArrayPrototype.concat;
  1678. var array_push = ArrayPrototype.push;
  1679. var max = Math.max;
  1680. // /add necessary es5-shim utilities
  1681.  
  1682. // 1. Let Target be the this value.
  1683. var target = this;
  1684. // 2. If IsCallable(Target) is false, throw a TypeError exception.
  1685. if (!isCallable(target)) {
  1686. throw new TypeError('Function.prototype.bind called on incompatible ' + target);
  1687. }
  1688. // 3. Let A be a new (possibly empty) internal list of all of the
  1689. // argument values provided after thisArg (arg1, arg2 etc), in order.
  1690. // XXX slicedArgs will stand in for "A" if used
  1691. var args = array_slice.call(arguments, 1); // for normal call
  1692. // 4. Let F be a new native ECMAScript object.
  1693. // 11. Set the [[Prototype]] internal property of F to the standard
  1694. // built-in Function prototype object as specified in 15.3.3.1.
  1695. // 12. Set the [[Call]] internal property of F as described in
  1696. // 15.3.4.5.1.
  1697. // 13. Set the [[Construct]] internal property of F as described in
  1698. // 15.3.4.5.2.
  1699. // 14. Set the [[HasInstance]] internal property of F as described in
  1700. // 15.3.4.5.3.
  1701. var bound;
  1702. var binder = function () {
  1703.  
  1704. if (this instanceof bound) {
  1705. // 15.3.4.5.2 [[Construct]]
  1706. // When the [[Construct]] internal method of a function object,
  1707. // F that was created using the bind function is called with a
  1708. // list of arguments ExtraArgs, the following steps are taken:
  1709. // 1. Let target be the value of F's [[TargetFunction]]
  1710. // internal property.
  1711. // 2. If target has no [[Construct]] internal method, a
  1712. // TypeError exception is thrown.
  1713. // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
  1714. // property.
  1715. // 4. Let args be a new list containing the same values as the
  1716. // list boundArgs in the same order followed by the same
  1717. // values as the list ExtraArgs in the same order.
  1718. // 5. Return the result of calling the [[Construct]] internal
  1719. // method of target providing args as the arguments.
  1720.  
  1721. var result = target.apply(
  1722. this,
  1723. array_concat.call(args, array_slice.call(arguments))
  1724. );
  1725. if ($Object(result) === result) {
  1726. return result;
  1727. }
  1728. return this;
  1729.  
  1730. } else {
  1731. // 15.3.4.5.1 [[Call]]
  1732. // When the [[Call]] internal method of a function object, F,
  1733. // which was created using the bind function is called with a
  1734. // this value and a list of arguments ExtraArgs, the following
  1735. // steps are taken:
  1736. // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
  1737. // property.
  1738. // 2. Let boundThis be the value of F's [[BoundThis]] internal
  1739. // property.
  1740. // 3. Let target be the value of F's [[TargetFunction]] internal
  1741. // property.
  1742. // 4. Let args be a new list containing the same values as the
  1743. // list boundArgs in the same order followed by the same
  1744. // values as the list ExtraArgs in the same order.
  1745. // 5. Return the result of calling the [[Call]] internal method
  1746. // of target providing boundThis as the this value and
  1747. // providing args as the arguments.
  1748.  
  1749. // equiv: target.call(this, ...boundArgs, ...args)
  1750. return target.apply(
  1751. that,
  1752. array_concat.call(args, array_slice.call(arguments))
  1753. );
  1754.  
  1755. }
  1756.  
  1757. };
  1758.  
  1759. // 15. If the [[Class]] internal property of Target is "Function", then
  1760. // a. Let L be the length property of Target minus the length of A.
  1761. // b. Set the length own property of F to either 0 or L, whichever is
  1762. // larger.
  1763. // 16. Else set the length own property of F to 0.
  1764.  
  1765. var boundLength = max(0, target.length - args.length);
  1766.  
  1767. // 17. Set the attributes of the length own property of F to the values
  1768. // specified in 15.3.5.1.
  1769. var boundArgs = [];
  1770. for (var i = 0; i < boundLength; i++) {
  1771. array_push.call(boundArgs, '$' + i);
  1772. }
  1773.  
  1774. // XXX Build a dynamic function with desired amount of arguments is the only
  1775. // way to set the length property of a function.
  1776. // In environments where Content Security Policies enabled (Chrome extensions,
  1777. // for ex.) all use of eval or Function costructor throws an exception.
  1778. // However in all of these environments Function.prototype.bind exists
  1779. // and so this code will never be executed.
  1780. bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
  1781.  
  1782. if (target.prototype) {
  1783. Empty.prototype = target.prototype;
  1784. bound.prototype = new Empty();
  1785. // Clean up dangling references.
  1786. Empty.prototype = null;
  1787. }
  1788.  
  1789. // TODO
  1790. // 18. Set the [[Extensible]] internal property of F to true.
  1791.  
  1792. // TODO
  1793. // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
  1794. // 20. Call the [[DefineOwnProperty]] internal method of F with
  1795. // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
  1796. // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
  1797. // false.
  1798. // 21. Call the [[DefineOwnProperty]] internal method of F with
  1799. // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
  1800. // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
  1801. // and false.
  1802.  
  1803. // TODO
  1804. // NOTE Function objects created using Function.prototype.bind do not
  1805. // have a prototype property or the [[Code]], [[FormalParameters]], and
  1806. // [[Scope]] internal properties.
  1807. // XXX can't delete prototype in pure-js.
  1808.  
  1809. // 22. Return F.
  1810. return bound;
  1811. }
  1812. });
  1813.  
  1814. // Object.defineProperties
  1815. Object.defineProperties = function defineProperties(object, descriptors) {
  1816. for (var property in descriptors) {
  1817. Object.defineProperty(object, property, descriptors[property]);
  1818. }
  1819.  
  1820. return object;
  1821. };
  1822.  
  1823. // Object.create
  1824. Object.create = function create(prototype, properties) {
  1825. /* jshint evil: true */
  1826. if (typeof prototype !== 'object' && prototype !== null) {
  1827. throw TypeError('Object prototype may only be an Object or null');
  1828. }
  1829.  
  1830. var
  1831. object = new Function('e', 'function Object() {}Object.prototype=e;return new Object')(prototype);
  1832.  
  1833. object.constructor.prototype = prototype;
  1834.  
  1835. if (1 in arguments) {
  1836. Object.defineProperties(object, properties);
  1837. }
  1838.  
  1839. return object;
  1840. };
  1841.  
  1842. // Object.getOwnPropertyNames
  1843. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  1844. var buffer = [];
  1845. var key;
  1846.  
  1847. // Non-enumerable properties cannot be discovered but can be checked for by name.
  1848. // Define those used internally by JS to allow an incomplete solution
  1849. var commonProps = ['length', "name", "arguments", "caller", "prototype", "observe", "unobserve"];
  1850.  
  1851. if (typeof object === 'undefined' || object === null) {
  1852. throw new TypeError('Cannot convert undefined or null to object');
  1853. }
  1854.  
  1855. object = Object(object);
  1856.  
  1857. // Enumerable properties only
  1858. for (key in object) {
  1859. if (Object.prototype.hasOwnProperty.call(object, key)) {
  1860. buffer.push(key);
  1861. }
  1862. }
  1863.  
  1864. // Check for and add the common non-enumerable properties
  1865. for (var i=0, s=commonProps.length; i<s; i++) {
  1866. if (commonProps[i] in object) buffer.push(commonProps[i]);
  1867. }
  1868.  
  1869. return buffer;
  1870. };
  1871.  
  1872. // Object.getOwnPropertyDescriptor
  1873. (function() {
  1874. var call = Function.prototype.call;
  1875. var prototypeOfObject = Object.prototype;
  1876. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  1877.  
  1878. var defineGetter;
  1879. var defineSetter;
  1880. var lookupGetter;
  1881. var lookupSetter;
  1882. var supportsAccessors;
  1883. if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
  1884. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  1885. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  1886. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  1887. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  1888. }
  1889. function doesGetOwnPropertyDescriptorWork(object) {
  1890. try {
  1891. object.sentinel = 0;
  1892. return Object.getOwnPropertyDescriptor(
  1893. object,
  1894. "sentinel"
  1895. ).value === 0;
  1896. } catch (exception) {
  1897. // returns falsy
  1898. }
  1899. }
  1900. // check whether getOwnPropertyDescriptor works if it's given. Otherwise,
  1901. // shim partially.
  1902. if (Object.defineProperty) {
  1903. var getOwnPropertyDescriptorWorksOnObject =
  1904. doesGetOwnPropertyDescriptorWork({});
  1905. var getOwnPropertyDescriptorWorksOnDom = typeof document == "undefined" ||
  1906. doesGetOwnPropertyDescriptorWork(document.createElement("div"));
  1907. if (!getOwnPropertyDescriptorWorksOnDom ||
  1908. !getOwnPropertyDescriptorWorksOnObject
  1909. ) {
  1910. var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
  1911. }
  1912. }
  1913.  
  1914. if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
  1915. var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
  1916.  
  1917. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  1918. if ((typeof object != "object" && typeof object != "function") || object === null) {
  1919. throw new TypeError(ERR_NON_OBJECT + object);
  1920. }
  1921.  
  1922. // make a valiant attempt to use the real getOwnPropertyDescriptor
  1923. // for I8's DOM elements.
  1924. if (getOwnPropertyDescriptorFallback) {
  1925. try {
  1926. return getOwnPropertyDescriptorFallback.call(Object, object, property);
  1927. } catch (exception) {
  1928. // try the shim if the real one doesn't work
  1929. }
  1930. }
  1931.  
  1932. // If object does not owns property return undefined immediately.
  1933. if (!owns(object, property)) {
  1934. return;
  1935. }
  1936.  
  1937. // If object has a property then it's for sure both `enumerable` and
  1938. // `configurable`.
  1939. var descriptor = { enumerable: true, configurable: true };
  1940.  
  1941. // If JS engine supports accessor properties then property may be a
  1942. // getter or setter.
  1943. if (supportsAccessors) {
  1944. // Unfortunately `__lookupGetter__` will return a getter even
  1945. // if object has own non getter property along with a same named
  1946. // inherited getter. To avoid misbehavior we temporary remove
  1947. // `__proto__` so that `__lookupGetter__` will return getter only
  1948. // if it's owned by an object.
  1949. var prototype = object.__proto__;
  1950. object.__proto__ = prototypeOfObject;
  1951.  
  1952. var getter = lookupGetter(object, property);
  1953. var setter = lookupSetter(object, property);
  1954.  
  1955. // Once we have getter and setter we can put values back.
  1956. object.__proto__ = prototype;
  1957.  
  1958. if (getter || setter) {
  1959. if (getter) {
  1960. descriptor.get = getter;
  1961. }
  1962. if (setter) {
  1963. descriptor.set = setter;
  1964. }
  1965. // If it was accessor property we're done and return here
  1966. // in order to avoid adding `value` to the descriptor.
  1967. return descriptor;
  1968. }
  1969. }
  1970.  
  1971. // If we got this far we know that object has an own property that is
  1972. // not an accessor so we set it as a value and return descriptor.
  1973. descriptor.value = object[property];
  1974. return descriptor;
  1975. };
  1976. }
  1977. }())
  1978. // Object.keys
  1979. Object.keys = (function() {
  1980. 'use strict';
  1981. var hasOwnProperty = Object.prototype.hasOwnProperty,
  1982. hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
  1983. dontEnums = [
  1984. 'toString',
  1985. 'toLocaleString',
  1986. 'valueOf',
  1987. 'hasOwnProperty',
  1988. 'isPrototypeOf',
  1989. 'propertyIsEnumerable',
  1990. 'constructor'
  1991. ],
  1992. dontEnumsLength = dontEnums.length;
  1993.  
  1994. return function(obj) {
  1995. if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
  1996. throw new TypeError('Object.keys called on non-object');
  1997. }
  1998.  
  1999. var result = [], prop, i;
  2000.  
  2001. for (prop in obj) {
  2002. if (hasOwnProperty.call(obj, prop)) {
  2003. result.push(prop);
  2004. }
  2005. }
  2006.  
  2007. if (hasDontEnumBug) {
  2008. for (i = 0; i < dontEnumsLength; i++) {
  2009. if (hasOwnProperty.call(obj, dontEnums[i])) {
  2010. result.push(dontEnums[i]);
  2011. }
  2012. }
  2013. }
  2014. return result;
  2015. };
  2016. }());
  2017.  
  2018. // Symbol
  2019. // A modification of https://github.com/WebReflection/get-own-property-symbols
  2020. // (C) Andrea Giammarchi - MIT Licensed
  2021.  
  2022. (function (Object, GOPS) {
  2023.  
  2024. var setDescriptor;
  2025. var G = typeof global === typeof G ? window : global;
  2026. var id = 0;
  2027. var random = '' + Math.random();
  2028. var prefix = '__\x01symbol:';
  2029. var prefixLength = prefix.length;
  2030. var internalSymbol = '__\x01symbol@@' + random;
  2031. var DP = 'defineProperty';
  2032. var DPies = 'defineProperties';
  2033. var GOPN = 'getOwnPropertyNames';
  2034. var GOPD = 'getOwnPropertyDescriptor';
  2035. var PIE = 'propertyIsEnumerable';
  2036. var ObjectProto = Object.prototype;
  2037. var hOP = ObjectProto.hasOwnProperty;
  2038. var pIE = ObjectProto[PIE];
  2039. var toString = ObjectProto.toString;
  2040. var concat = Array.prototype.concat;
  2041. var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : [];
  2042. var nGOPN = Object[GOPN];
  2043. var gOPN = function getOwnPropertyNames (obj) {
  2044. if (toString.call(obj) === '[object Window]') {
  2045. try {
  2046. return nGOPN(obj);
  2047. } catch (e) {
  2048. // IE bug where layout engine calls userland gOPN for cross-domain `window` objects
  2049. return concat.call([], cachedWindowNames);
  2050. }
  2051. }
  2052. return nGOPN(obj);
  2053. }
  2054. var gOPD = Object[GOPD];
  2055. var create = Object.create;
  2056. var keys = Object.keys;
  2057. var freeze = Object.freeze || Object;
  2058. var defineProperty = Object[DP];
  2059. var $defineProperties = Object[DPies];
  2060. var descriptor = gOPD(Object, GOPN);
  2061. var indexOf = Array.prototype.indexOf || function (v) {
  2062. for (var i = this.length; i-- && this[i] !== v;) {}
  2063. return i;
  2064. };
  2065. var addInternalIfNeeded = function (o, uid, enumerable) {
  2066. if (!hOP.call(o, internalSymbol)) {
  2067. try {
  2068. defineProperty(o, internalSymbol, {
  2069. enumerable: false,
  2070. configurable: false,
  2071. writable: false,
  2072. value: {}
  2073. });
  2074. } catch (e) {
  2075. o.internalSymbol = value
  2076. }
  2077. }
  2078. o[internalSymbol]['@@' + uid] = enumerable;
  2079. };
  2080. var createWithSymbols = function (proto, descriptors) {
  2081. var self = create(proto);
  2082. gOPN(descriptors).forEach(function (key) {
  2083. if (propertyIsEnumerable.call(descriptors, key)) {
  2084. $defineProperty(self, key, descriptors[key]);
  2085. }
  2086. });
  2087. return self;
  2088. };
  2089. var copyAsNonEnumerable = function (descriptor) {
  2090. var newDescriptor = create(descriptor);
  2091. newDescriptor.enumerable = false;
  2092. return newDescriptor;
  2093. };
  2094. var get = function get(){};
  2095. var onlyNonSymbols = function (name) {
  2096. return name != internalSymbol &&
  2097. !hOP.call(source, name);
  2098. };
  2099. var onlySymbols = function (name) {
  2100. return name != internalSymbol &&
  2101. hOP.call(source, name);
  2102. };
  2103. var propertyIsEnumerable = function propertyIsEnumerable(key) {
  2104. var uid = '' + key;
  2105. return onlySymbols(uid) ? (
  2106. hOP.call(this, uid) &&
  2107. this[internalSymbol]['@@' + uid]
  2108. ) : pIE.call(this, key);
  2109. }
  2110. var setAndGetSymbol = function (uid) {
  2111. var descriptor = {
  2112. enumerable: false,
  2113. configurable: true,
  2114. get: get,
  2115. set: function (value) {
  2116. setDescriptor(this, uid, {
  2117. enumerable: false,
  2118. configurable: true,
  2119. writable: true,
  2120. value: value
  2121. });
  2122. addInternalIfNeeded(this, uid, true);
  2123. }
  2124. };
  2125. try {
  2126. defineProperty(ObjectProto, uid, descriptor);
  2127. } catch (e) {
  2128. ObjectProto[uid] = descriptor.value;
  2129. }
  2130. return freeze(source[uid] = defineProperty(
  2131. Object(uid),
  2132. 'constructor',
  2133. sourceConstructor
  2134. ));
  2135. };
  2136. var Symbol = function Symbol(description) {
  2137. if (this instanceof Symbol) {
  2138. throw new TypeError('Symbol is not a constructor');
  2139. }
  2140. return setAndGetSymbol(
  2141. prefix.concat(description || '', random, ++id)
  2142. );
  2143. };
  2144. var source = create(null);
  2145. var sourceConstructor = {value: Symbol};
  2146. var sourceMap = function (uid) {
  2147. return source[uid];
  2148. };
  2149. var $defineProperty = function defineProp(o, key, descriptor) {
  2150. var uid = '' + key;
  2151. if (onlySymbols(uid)) {
  2152. setDescriptor(o, uid, descriptor.enumerable ?
  2153. copyAsNonEnumerable(descriptor) : descriptor);
  2154. addInternalIfNeeded(o, uid, !!descriptor.enumerable);
  2155. } else {
  2156. defineProperty(o, key, descriptor);
  2157. }
  2158. return o;
  2159. };
  2160. var $getOwnPropertySymbols = function getOwnPropertySymbols(o) {
  2161. return gOPN(o).filter(onlySymbols).map(sourceMap);
  2162. }
  2163. ;
  2164.  
  2165. descriptor.value = $defineProperty;
  2166. defineProperty(Object, DP, descriptor);
  2167.  
  2168. descriptor.value = $getOwnPropertySymbols;
  2169. defineProperty(Object, GOPS, descriptor);
  2170.  
  2171. descriptor.value = function getOwnPropertyNames(o) {
  2172. return gOPN(o).filter(onlyNonSymbols);
  2173. };
  2174. defineProperty(Object, GOPN, descriptor);
  2175.  
  2176. descriptor.value = function defineProperties(o, descriptors) {
  2177. var symbols = $getOwnPropertySymbols(descriptors);
  2178. if (symbols.length) {
  2179. keys(descriptors).concat(symbols).forEach(function (uid) {
  2180. if (propertyIsEnumerable.call(descriptors, uid)) {
  2181. $defineProperty(o, uid, descriptors[uid]);
  2182. }
  2183. });
  2184. } else {
  2185. $defineProperties(o, descriptors);
  2186. }
  2187. return o;
  2188. };
  2189. defineProperty(Object, DPies, descriptor);
  2190.  
  2191. descriptor.value = propertyIsEnumerable;
  2192. defineProperty(ObjectProto, PIE, descriptor);
  2193.  
  2194. descriptor.value = Symbol;
  2195. defineProperty(G, 'Symbol', descriptor);
  2196.  
  2197. // defining `Symbol.for(key)`
  2198. descriptor.value = function (key) {
  2199. var uid = prefix.concat(prefix, key, random);
  2200. return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid);
  2201. };
  2202. defineProperty(Symbol, 'for', descriptor);
  2203.  
  2204. // defining `Symbol.keyFor(symbol)`
  2205. descriptor.value = function (symbol) {
  2206. if (onlyNonSymbols(symbol))
  2207. throw new TypeError(symbol + ' is not a symbol');
  2208. return hOP.call(source, symbol) ?
  2209. symbol.slice(prefixLength * 2, -random.length) :
  2210. void 0
  2211. ;
  2212. };
  2213. defineProperty(Symbol, 'keyFor', descriptor);
  2214.  
  2215. descriptor.value = function getOwnPropertyDescriptor(o, key) {
  2216. var descriptor = gOPD(o, key);
  2217. if (descriptor && onlySymbols(key)) {
  2218. descriptor.enumerable = propertyIsEnumerable.call(o, key);
  2219. }
  2220. return descriptor;
  2221. };
  2222. defineProperty(Object, GOPD, descriptor);
  2223.  
  2224. descriptor.value = function (proto, descriptors) {
  2225. return arguments.length === 1 || typeof descriptors === "undefined" ?
  2226. create(proto) :
  2227. createWithSymbols(proto, descriptors);
  2228. };
  2229. defineProperty(Object, 'create', descriptor);
  2230.  
  2231. descriptor.value = function () {
  2232. var str = toString.call(this);
  2233. return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
  2234. };
  2235. defineProperty(ObjectProto, 'toString', descriptor);
  2236.  
  2237.  
  2238. setDescriptor = function (o, key, descriptor) {
  2239. var protoDescriptor = gOPD(ObjectProto, key);
  2240. delete ObjectProto[key];
  2241. defineProperty(o, key, descriptor);
  2242. defineProperty(ObjectProto, key, protoDescriptor);
  2243. };
  2244.  
  2245. }(Object, 'getOwnPropertySymbols'));
  2246.  
  2247. // Symbol.iterator
  2248. Object.defineProperty(Symbol, 'iterator', {value: Symbol('iterator')});
  2249.  
  2250. // Symbol.species
  2251. Object.defineProperty(Symbol, 'species', {value: Symbol('species')});
  2252.  
  2253. // Number.isNaN
  2254. Number.isNaN = Number.isNaN || function(value) {
  2255. return typeof value === "number" && isNaN(value);
  2256. };
  2257.  
  2258. // Map
  2259. (function(global) {
  2260.  
  2261.  
  2262. // 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.
  2263. var undefMarker = Symbol('undef');
  2264.  
  2265. // NaN cannot be found in an array using indexOf, so we encode NaNs using a private symbol.
  2266. var NaNMarker = Symbol('NaN');
  2267.  
  2268. function encodeKey(key) {
  2269. return Number.isNaN(key) ? NaNMarker : key;
  2270. }
  2271. function decodeKey(encodedKey) {
  2272. return (encodedKey === NaNMarker) ? NaN : encodedKey;
  2273. }
  2274.  
  2275. function makeIterator(mapInst, getter) {
  2276. var nextIdx = 0;
  2277. var done = false;
  2278. return {
  2279. next: function() {
  2280. if (nextIdx === mapInst._keys.length) done = true;
  2281. if (!done) {
  2282. while (mapInst._keys[nextIdx] === undefMarker) nextIdx++;
  2283. return {value: getter.call(mapInst, nextIdx++), done: false};
  2284. } else {
  2285. return {done:true};
  2286. }
  2287. }
  2288. }
  2289. }
  2290.  
  2291. function calcSize(mapInst) {
  2292. var size = 0;
  2293. for (var i=0, s=mapInst._keys.length; i<s; i++) {
  2294. if (mapInst._keys[i] !== undefMarker) size++;
  2295. }
  2296. return size;
  2297. }
  2298.  
  2299. var ACCESSOR_SUPPORT = true;
  2300.  
  2301. var Map = function(data) {
  2302. this._keys = [];
  2303. this._values = [];
  2304.  
  2305. // If `data` is iterable (indicated by presence of a forEach method), pre-populate the map
  2306. data && (typeof data.forEach === 'function') && data.forEach(function (item) {
  2307. this.set.apply(this, item);
  2308. }, this);
  2309.  
  2310. if (!ACCESSOR_SUPPORT) this.size = calcSize(this);
  2311. };
  2312. Map.prototype = {};
  2313.  
  2314. // 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.
  2315. try {
  2316. Object.defineProperty(Map.prototype, 'size', {
  2317. get: function() {
  2318. return calcSize(this);
  2319. }
  2320. });
  2321. } catch(e) {
  2322. ACCESSOR_SUPPORT = false;
  2323. }
  2324.  
  2325. Map.prototype['get'] = function(key) {
  2326. var idx = this._keys.indexOf(encodeKey(key));
  2327. return (idx !== -1) ? this._values[idx] : undefined;
  2328. };
  2329. Map.prototype['set'] = function(key, value) {
  2330. var idx = this._keys.indexOf(encodeKey(key));
  2331. if (idx !== -1) {
  2332. this._values[idx] = value;
  2333. } else {
  2334. this._keys.push(encodeKey(key));
  2335. this._values.push(value);
  2336. if (!ACCESSOR_SUPPORT) this.size = calcSize(this);
  2337. }
  2338. return this;
  2339. };
  2340. Map.prototype['has'] = function(key) {
  2341. return (this._keys.indexOf(encodeKey(key)) !== -1);
  2342. };
  2343. Map.prototype['delete'] = function(key) {
  2344. var idx = this._keys.indexOf(encodeKey(key));
  2345. if (idx === -1) return false;
  2346. this._keys[idx] = undefMarker;
  2347. this._values[idx] = undefMarker;
  2348. if (!ACCESSOR_SUPPORT) this.size = calcSize(this);
  2349. return true;
  2350. };
  2351. Map.prototype['clear'] = function() {
  2352. this._keys = this._values = [];
  2353. if (!ACCESSOR_SUPPORT) this.size = 0;
  2354. };
  2355. Map.prototype['values'] = function() {
  2356. return makeIterator(this, function(i) { return this._values[i]; });
  2357. };
  2358. Map.prototype['keys'] = function() {
  2359. return makeIterator(this, function(i) { return decodeKey(this._keys[i]); });
  2360. };
  2361. Map.prototype['entries'] =
  2362. Map.prototype[Symbol.iterator] = function() {
  2363. return makeIterator(this, function(i) { return [decodeKey(this._keys[i]), this._values[i]]; });
  2364. };
  2365. Map.prototype['forEach'] = function(callbackFn, thisArg) {
  2366. thisArg = thisArg || global;
  2367. var iterator = this.entries();
  2368. result = iterator.next();
  2369. while (result.done === false) {
  2370. callbackFn.call(thisArg, result.value[1], result.value[0], this);
  2371. result = iterator.next();
  2372. }
  2373. };
  2374. Map.prototype['constructor'] =
  2375. Map.prototype[Symbol.species] = Map;
  2376.  
  2377. Map.length = 0;
  2378.  
  2379. // Export the object
  2380. this.Map = Map;
  2381.  
  2382. })(this);
  2383.  
  2384. // Node.prototype.contains
  2385. (function() {
  2386.  
  2387. function contains(node) {
  2388. if (!(0 in arguments)) {
  2389. throw new TypeError('1 argument is required');
  2390. }
  2391.  
  2392. do {
  2393. if (this === node) {
  2394. return true;
  2395. }
  2396. } while (node = node && node.parentNode);
  2397.  
  2398. return false;
  2399. }
  2400.  
  2401. // IE
  2402. if ('HTMLElement' in this && 'contains' in HTMLElement.prototype) {
  2403. try {
  2404. delete HTMLElement.prototype.contains;
  2405. } catch (e) {}
  2406. }
  2407.  
  2408. if ('Node' in this) {
  2409. Node.prototype.contains = contains;
  2410. } else {
  2411. document.contains = Element.prototype.contains = contains;
  2412. }
  2413.  
  2414. }());
  2415.  
  2416. // Object.assign
  2417. Object.assign = function assign(target, source) {
  2418. for (var index = 1, key, src; index < arguments.length; ++index) {
  2419. src = arguments[index];
  2420.  
  2421. for (key in src) {
  2422. if (Object.prototype.hasOwnProperty.call(src, key)) {
  2423. target[key] = src[key];
  2424. }
  2425. }
  2426. }
  2427.  
  2428. return target;
  2429. };
  2430.  
  2431. // Object.getPrototypeOf
  2432. Object.getPrototypeOf = function getPrototypeOf(object) {
  2433. if (object !== Object(object)) {
  2434. throw new TypeError('Object.getPrototypeOf called on non-object');
  2435. }
  2436.  
  2437. return object.constructor ? object.constructor.prototype : null;
  2438. };
  2439.  
  2440. // setImmediate
  2441. (function (global, undefined) {
  2442. "use strict";
  2443.  
  2444. if (global.setImmediate) {
  2445. return;
  2446. }
  2447.  
  2448. var nextHandle = 1; // Spec says greater than zero
  2449. var tasksByHandle = {};
  2450. var currentlyRunningATask = false;
  2451. var doc = global.document;
  2452. var setImmediate;
  2453.  
  2454. function addFromSetImmediateArguments(args) {
  2455. tasksByHandle[nextHandle] = partiallyApplied.apply(undefined, args);
  2456. return nextHandle++;
  2457. }
  2458.  
  2459. // This function accepts the same arguments as setImmediate, but
  2460. // returns a function that requires no arguments.
  2461. function partiallyApplied(handler) {
  2462. var args = [].slice.call(arguments, 1);
  2463. return function() {
  2464. if (typeof handler === "function") {
  2465. handler.apply(undefined, args);
  2466. } else {
  2467. (new Function("" + handler))();
  2468. }
  2469. };
  2470. }
  2471.  
  2472. function runIfPresent(handle) {
  2473. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  2474. // So if we're currently running a task, we'll need to delay this invocation.
  2475. if (currentlyRunningATask) {
  2476. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  2477. // "too much recursion" error.
  2478. setTimeout(partiallyApplied(runIfPresent, handle), 0);
  2479. } else {
  2480. var task = tasksByHandle[handle];
  2481. if (task) {
  2482. currentlyRunningATask = true;
  2483. try {
  2484. task();
  2485. } finally {
  2486. clearImmediate(handle);
  2487. currentlyRunningATask = false;
  2488. }
  2489. }
  2490. }
  2491. }
  2492.  
  2493. function clearImmediate(handle) {
  2494. delete tasksByHandle[handle];
  2495. }
  2496.  
  2497. function installNextTickImplementation() {
  2498. setImmediate = function() {
  2499. var handle = addFromSetImmediateArguments(arguments);
  2500. process.nextTick(partiallyApplied(runIfPresent, handle));
  2501. return handle;
  2502. };
  2503. }
  2504.  
  2505. function canUsePostMessage() {
  2506. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  2507. // where `global.postMessage` means something completely different and can't be used for this purpose.
  2508. if (global.postMessage && !global.importScripts) {
  2509. var postMessageIsAsynchronous = true;
  2510. var oldOnMessage = global.onmessage;
  2511. global.onmessage = function() {
  2512. postMessageIsAsynchronous = false;
  2513. };
  2514. global.postMessage("", "*");
  2515. global.onmessage = oldOnMessage;
  2516. return postMessageIsAsynchronous;
  2517. }
  2518. }
  2519.  
  2520. function installPostMessageImplementation() {
  2521. // Installs an event handler on `global` for the `message` event: see
  2522. // * https://developer.mozilla.org/en/DOM/window.postMessage
  2523. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  2524.  
  2525. var messagePrefix = "setImmediate$" + Math.random() + "$";
  2526. var onGlobalMessage = function(event) {
  2527. if (event.source === global &&
  2528. typeof event.data === "string" &&
  2529. event.data.indexOf(messagePrefix) === 0) {
  2530. runIfPresent(+event.data.slice(messagePrefix.length));
  2531. }
  2532. };
  2533.  
  2534. if (global.addEventListener) {
  2535. global.addEventListener("message", onGlobalMessage, false);
  2536. } else {
  2537. global.attachEvent("onmessage", onGlobalMessage);
  2538. }
  2539.  
  2540. setImmediate = function() {
  2541. var handle = addFromSetImmediateArguments(arguments);
  2542. global.postMessage(messagePrefix + handle, "*");
  2543. return handle;
  2544. };
  2545. }
  2546.  
  2547. function installMessageChannelImplementation() {
  2548. var channel = new MessageChannel();
  2549. channel.port1.onmessage = function(event) {
  2550. var handle = event.data;
  2551. runIfPresent(handle);
  2552. };
  2553.  
  2554. setImmediate = function() {
  2555. var handle = addFromSetImmediateArguments(arguments);
  2556. channel.port2.postMessage(handle);
  2557. return handle;
  2558. };
  2559. }
  2560.  
  2561. function installReadyStateChangeImplementation() {
  2562. var html = doc.documentElement;
  2563. setImmediate = function() {
  2564. var handle = addFromSetImmediateArguments(arguments);
  2565. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  2566. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  2567. var script = doc.createElement("script");
  2568. script.onreadystatechange = function () {
  2569. runIfPresent(handle);
  2570. script.onreadystatechange = null;
  2571. html.removeChild(script);
  2572. script = null;
  2573. };
  2574. html.appendChild(script);
  2575. return handle;
  2576. };
  2577. }
  2578.  
  2579. function installSetTimeoutImplementation() {
  2580. setImmediate = function() {
  2581. var handle = addFromSetImmediateArguments(arguments);
  2582. setTimeout(partiallyApplied(runIfPresent, handle), 0);
  2583. return handle;
  2584. };
  2585. }
  2586.  
  2587. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  2588. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  2589. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  2590.  
  2591. // Don't get fooled by e.g. browserify environments.
  2592. if ({}.toString.call(global.process) === "[object process]") {
  2593. // For Node.js before 0.9
  2594. installNextTickImplementation();
  2595.  
  2596. } else if (canUsePostMessage()) {
  2597. // For non-IE10 modern browsers
  2598. installPostMessageImplementation();
  2599.  
  2600. } else if (global.MessageChannel) {
  2601. // For web workers, where supported
  2602. installMessageChannelImplementation();
  2603.  
  2604. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  2605. // For IE 6–8
  2606. installReadyStateChangeImplementation();
  2607.  
  2608. } else {
  2609. // For older browsers
  2610. installSetTimeoutImplementation();
  2611. }
  2612.  
  2613. attachTo.setImmediate = setImmediate;
  2614. attachTo.clearImmediate = clearImmediate;
  2615. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  2616.  
  2617. // Promise
  2618. /**
  2619. * Promise polyfill v1.0.10
  2620. * requires setImmediate
  2621. *
  2622. * © 2014–2015 Dmitry Korobkin
  2623. * Released under the MIT license
  2624. * github.com/Octane/Promise
  2625. */
  2626. (function (global) {'use strict';
  2627.  
  2628. var STATUS = '[[PromiseStatus]]';
  2629. var VALUE = '[[PromiseValue]]';
  2630. var ON_FUlFILLED = '[[OnFulfilled]]';
  2631. var ON_REJECTED = '[[OnRejected]]';
  2632. var ORIGINAL_ERROR = '[[OriginalError]]';
  2633. var PENDING = 'pending';
  2634. var INTERNAL_PENDING = 'internal pending';
  2635. var FULFILLED = 'fulfilled';
  2636. var REJECTED = 'rejected';
  2637. var NOT_ARRAY = 'not an array.';
  2638. var REQUIRES_NEW = 'constructor Promise requires "new".';
  2639. var CHAINING_CYCLE = 'then() cannot return same Promise that it resolves.';
  2640.  
  2641. // Modifed by polyfill service - remove undefined require statement
  2642. var setImmediate = global.setImmediate;
  2643.  
  2644. var isArray = Array.isArray || function (anything) {
  2645. return Object.prototype.toString.call(anything) == '[object Array]';
  2646. };
  2647.  
  2648. function InternalError(originalError) {
  2649. this[ORIGINAL_ERROR] = originalError;
  2650. }
  2651.  
  2652. function isInternalError(anything) {
  2653. return anything instanceof InternalError;
  2654. }
  2655.  
  2656. function isObject(anything) {
  2657. //Object.create(null) instanceof Object → false
  2658. return Object(anything) === anything;
  2659. }
  2660.  
  2661. function isCallable(anything) {
  2662. return typeof anything == 'function';
  2663. }
  2664.  
  2665. function isPromise(anything) {
  2666. return anything instanceof Promise;
  2667. }
  2668.  
  2669. function identity(value) {
  2670. return value;
  2671. }
  2672.  
  2673. function thrower(reason) {
  2674. throw reason;
  2675. }
  2676.  
  2677. function enqueue(promise, onFulfilled, onRejected) {
  2678. if (!promise[ON_FUlFILLED]) {
  2679. promise[ON_FUlFILLED] = [];
  2680. promise[ON_REJECTED] = [];
  2681. }
  2682. promise[ON_FUlFILLED].push(onFulfilled);
  2683. promise[ON_REJECTED].push(onRejected);
  2684. }
  2685.  
  2686. function clearAllQueues(promise) {
  2687. delete promise[ON_FUlFILLED];
  2688. delete promise[ON_REJECTED];
  2689. }
  2690.  
  2691. function callEach(queue) {
  2692. var i;
  2693. var length = queue.length;
  2694. for (i = 0; i < length; i++) {
  2695. queue[i]();
  2696. }
  2697. }
  2698.  
  2699. function call(resolve, reject, value) {
  2700. var anything = toPromise(value);
  2701. if (isPromise(anything)) {
  2702. anything.then(resolve, reject);
  2703. } else if (isInternalError(anything)) {
  2704. reject(anything[ORIGINAL_ERROR]);
  2705. } else {
  2706. resolve(value);
  2707. }
  2708. }
  2709.  
  2710. function toPromise(anything) {
  2711. var then;
  2712. if (isPromise(anything)) {
  2713. return anything;
  2714. }
  2715. if(isObject(anything)) {
  2716. try {
  2717. then = anything.then;
  2718. } catch (error) {
  2719. return new InternalError(error);
  2720. }
  2721. if (isCallable(then)) {
  2722. return new Promise(function (resolve, reject) {
  2723. setImmediate(function () {
  2724. try {
  2725. then.call(anything, resolve, reject);
  2726. } catch (error) {
  2727. reject(error);
  2728. }
  2729. });
  2730. });
  2731. }
  2732. }
  2733. return null;
  2734. }
  2735.  
  2736. function resolvePromise(promise, resolver) {
  2737. function resolve(value) {
  2738. if (promise[STATUS] == PENDING) {
  2739. fulfillPromise(promise, value);
  2740. }
  2741. }
  2742. function reject(reason) {
  2743. if (promise[STATUS] == PENDING) {
  2744. rejectPromise(promise, reason);
  2745. }
  2746. }
  2747. try {
  2748. resolver(resolve, reject);
  2749. } catch(error) {
  2750. reject(error);
  2751. }
  2752. }
  2753.  
  2754. function fulfillPromise(promise, value) {
  2755. var queue;
  2756. var anything = toPromise(value);
  2757. if (isPromise(anything)) {
  2758. promise[STATUS] = INTERNAL_PENDING;
  2759. anything.then(
  2760. function (value) {
  2761. fulfillPromise(promise, value);
  2762. },
  2763. function (reason) {
  2764. rejectPromise(promise, reason);
  2765. }
  2766. );
  2767. } else if (isInternalError(anything)) {
  2768. rejectPromise(promise, anything[ORIGINAL_ERROR]);
  2769. } else {
  2770. promise[STATUS] = FULFILLED;
  2771. promise[VALUE] = value;
  2772. queue = promise[ON_FUlFILLED];
  2773. if (queue && queue.length) {
  2774. clearAllQueues(promise);
  2775. callEach(queue);
  2776. }
  2777. }
  2778. }
  2779.  
  2780. function rejectPromise(promise, reason) {
  2781. var queue = promise[ON_REJECTED];
  2782. promise[STATUS] = REJECTED;
  2783. promise[VALUE] = reason;
  2784. if (queue && queue.length) {
  2785. clearAllQueues(promise);
  2786. callEach(queue);
  2787. }
  2788. }
  2789.  
  2790. function Promise(resolver) {
  2791. var promise = this;
  2792. if (!isPromise(promise)) {
  2793. throw new TypeError(REQUIRES_NEW);
  2794. }
  2795. promise[STATUS] = PENDING;
  2796. promise[VALUE] = undefined;
  2797. resolvePromise(promise, resolver);
  2798. }
  2799.  
  2800. Promise.prototype.then = function (onFulfilled, onRejected) {
  2801. var promise = this;
  2802. var nextPromise;
  2803. onFulfilled = isCallable(onFulfilled) ? onFulfilled : identity;
  2804. onRejected = isCallable(onRejected) ? onRejected : thrower;
  2805. nextPromise = new Promise(function (resolve, reject) {
  2806. function tryCall(func) {
  2807. var value;
  2808. try {
  2809. value = func(promise[VALUE]);
  2810. } catch (error) {
  2811. reject(error);
  2812. return;
  2813. }
  2814. if (value === nextPromise) {
  2815. reject(new TypeError(CHAINING_CYCLE));
  2816. } else {
  2817. call(resolve, reject, value);
  2818. }
  2819. }
  2820. function asyncOnFulfilled() {
  2821. setImmediate(tryCall, onFulfilled);
  2822. }
  2823. function asyncOnRejected() {
  2824. setImmediate(tryCall, onRejected);
  2825. }
  2826. switch (promise[STATUS]) {
  2827. case FULFILLED:
  2828. asyncOnFulfilled();
  2829. break;
  2830. case REJECTED:
  2831. asyncOnRejected();
  2832. break;
  2833. default:
  2834. enqueue(promise, asyncOnFulfilled, asyncOnRejected);
  2835. }
  2836. });
  2837. return nextPromise;
  2838. };
  2839.  
  2840. Promise.prototype['catch'] = function (onRejected) {
  2841. return this.then(identity, onRejected);
  2842. };
  2843.  
  2844. Promise.resolve = function (value) {
  2845. var anything = toPromise(value);
  2846. if (isPromise(anything)) {
  2847. return anything;
  2848. }
  2849. return new Promise(function (resolve, reject) {
  2850. if (isInternalError(anything)) {
  2851. reject(anything[ORIGINAL_ERROR]);
  2852. } else {
  2853. resolve(value);
  2854. }
  2855. });
  2856. };
  2857.  
  2858. Promise.reject = function (reason) {
  2859. return new Promise(function (resolve, reject) {
  2860. reject(reason);
  2861. });
  2862. };
  2863.  
  2864. Promise.race = function (values) {
  2865. return new Promise(function (resolve, reject) {
  2866. var i;
  2867. var length;
  2868. if (isArray(values)) {
  2869. length = values.length;
  2870. for (i = 0; i < length; i++) {
  2871. call(resolve, reject, values[i]);
  2872. }
  2873. } else {
  2874. reject(new TypeError(NOT_ARRAY));
  2875. }
  2876. });
  2877. };
  2878.  
  2879. Promise.all = function (values) {
  2880. return new Promise(function (resolve, reject) {
  2881. var fulfilledCount = 0;
  2882. var promiseCount = 0;
  2883. var anything;
  2884. var length;
  2885. var value;
  2886. var i;
  2887. if (isArray(values)) {
  2888. values = values.slice(0);
  2889. length = values.length;
  2890. for (i = 0; i < length; i++) {
  2891. value = values[i];
  2892. anything = toPromise(value);
  2893. if (isPromise(anything)) {
  2894. promiseCount++;
  2895. anything.then(
  2896. function (index) {
  2897. return function (value) {
  2898. values[index] = value;
  2899. fulfilledCount++;
  2900. if (fulfilledCount == promiseCount) {
  2901. resolve(values);
  2902. }
  2903. };
  2904. }(i),
  2905. reject
  2906. );
  2907. } else if (isInternalError(anything)) {
  2908. reject(anything[ORIGINAL_ERROR]);
  2909. } else {
  2910. //[1, , 3] → [1, undefined, 3]
  2911. values[i] = value;
  2912. }
  2913. }
  2914. if (!promiseCount) {
  2915. resolve(values);
  2916. }
  2917. } else {
  2918. reject(new TypeError(NOT_ARRAY));
  2919. }
  2920. });
  2921. };
  2922.  
  2923. if (typeof module != 'undefined' && module.exports) {
  2924. module.exports = global.Promise || Promise;
  2925. } else if (!global.Promise) {
  2926. global.Promise = Promise;
  2927. }
  2928.  
  2929. }(this));
  2930.  
  2931. // Set
  2932. (function(global) {
  2933.  
  2934.  
  2935. // 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.
  2936. var undefMarker = Symbol('undef');
  2937.  
  2938. // NaN cannot be found in an array using indexOf, so we encode NaNs using a private symbol.
  2939. var NaNMarker = Symbol('NaN');
  2940.  
  2941. function encodeVal(data) {
  2942. return Number.isNaN(data) ? NaNMarker : data;
  2943. }
  2944. function decodeVal(encodedData) {
  2945. return (encodedData === NaNMarker) ? NaN : encodedData;
  2946. }
  2947.  
  2948. function makeIterator(setInst, getter) {
  2949. var nextIdx = 0;
  2950. var done = false;
  2951. return {
  2952. next: function() {
  2953. if (nextIdx === setInst._values.length) done = true;
  2954. if (!done) {
  2955. while (setInst._values[nextIdx] === undefMarker) nextIdx++;
  2956. return {value: getter.call(setInst, nextIdx++), done: false};
  2957. } else {
  2958. return {done:true};
  2959. }
  2960. }
  2961. }
  2962. }
  2963.  
  2964. function calcSize(setInst) {
  2965. var size = 0;
  2966. for (var i=0, s=setInst._values.length; i<s; i++) {
  2967. if (setInst._values[i] !== undefMarker) size++;
  2968. }
  2969. return size;
  2970. }
  2971.  
  2972. var ACCESSOR_SUPPORT = true;
  2973.  
  2974. var Set = function(data) {
  2975. this._values = [];
  2976.  
  2977. // If `data` is iterable (indicated by presence of a forEach method), pre-populate the set
  2978. data && (typeof data.forEach === 'function') && data.forEach(function (item) {
  2979. this.add.call(this, item);
  2980. }, this);
  2981.  
  2982. if (!ACCESSOR_SUPPORT) this.size = calcSize(this);
  2983. };
  2984.  
  2985. // 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.
  2986. try {
  2987. Object.defineProperty(Set.prototype, 'size', {
  2988. get: function() {
  2989. return calcSize(this);
  2990. }
  2991. });
  2992. } catch(e) {
  2993. ACCESSOR_SUPPORT = false;
  2994. }
  2995.  
  2996. Set.prototype['add'] = function(value) {
  2997. value = encodeVal(value);
  2998. if (this._values.indexOf(value) === -1) {
  2999. this._values.push(value);
  3000. if (!ACCESSOR_SUPPORT) this.size = calcSize(this);
  3001. }
  3002. return this;
  3003. };
  3004. Set.prototype['has'] = function(value) {
  3005. return (this._values.indexOf(encodeVal(value)) !== -1);
  3006. };
  3007. Set.prototype['delete'] = function(value) {
  3008. var idx = this._values.indexOf(encodeVal(value));
  3009. if (idx === -1) return false;
  3010. this._values[idx] = undefMarker;
  3011. if (!ACCESSOR_SUPPORT) this.size = calcSize(this);
  3012. return true;
  3013. };
  3014. Set.prototype['clear'] = function() {
  3015. this._values = [];
  3016. if (!ACCESSOR_SUPPORT) this.size = 0;
  3017. };
  3018. Set.prototype['values'] =
  3019. Set.prototype['keys'] = function() {
  3020. return makeIterator(this, function(i) { return decodeVal(this._values[i]); });
  3021. };
  3022. Set.prototype['entries'] =
  3023. Set.prototype[Symbol.iterator] = function() {
  3024. return makeIterator(this, function(i) { return [decodeVal(this._values[i]), decodeVal(this._values[i])]; });
  3025. };
  3026. Set.prototype['forEach'] = function(callbackFn, thisArg) {
  3027. thisArg = thisArg || global;
  3028. var iterator = this.entries();
  3029. result = iterator.next();
  3030. while (result.done === false) {
  3031. callbackFn.call(thisArg, result.value[1], result.value[0], this);
  3032. result = iterator.next();
  3033. }
  3034. };
  3035. Set.prototype['constructor'] =
  3036. Set.prototype[Symbol.species] = Set;
  3037.  
  3038. Set.length = 0;
  3039.  
  3040. // Export the object
  3041. this.Set = Set;
  3042.  
  3043. })(this);
  3044.  
  3045. // String.prototype.endsWith
  3046. String.prototype.endsWith = function (string) {
  3047. var index = arguments.length < 2 ? this.length : arguments[1];
  3048. var foundIndex = this.lastIndexOf(string);
  3049. return foundIndex !== -1 && foundIndex === index - string.length;
  3050. };
  3051.  
  3052. // String.prototype.includes
  3053. String.prototype.includes = function (string, index) {
  3054. if (typeof string === 'object' && string instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression");
  3055. return this.indexOf(string, index) !== -1;
  3056. };
  3057.  
  3058. // String.prototype.startsWith
  3059. String.prototype.startsWith = function (string) {
  3060. var index = arguments.length < 2 ? 0 : arguments[1];
  3061.  
  3062. return this.slice(index).indexOf(string) === 0;
  3063. };
  3064.  
  3065. // String.prototype.trim
  3066. String.prototype.trim = function trim() {
  3067. return this.replace(/^\s+|\s+$/g, '');
  3068. };
  3069.  
  3070. // URL
  3071. // URL Polyfill
  3072. // Draft specification: http://url.spec.whatwg.org
  3073.  
  3074. // Notes:
  3075. // - Primarily useful for parsing URLs and modifying query parameters
  3076. // - Should work in IE8+ and everything more modern
  3077.  
  3078. (function (global) {
  3079. 'use strict';
  3080.  
  3081. var origURL = global.URL;
  3082.  
  3083. function URLUtils (url) {
  3084. var anchor = document.createElement('a');
  3085. anchor.href = url;
  3086.  
  3087. return anchor;
  3088. }
  3089.  
  3090. global.URL = function URL (url, base) {
  3091. if (!(this instanceof global.URL)) {
  3092. throw new TypeError("Failed to construct 'URL': Please use the 'new' operator.");
  3093. }
  3094.  
  3095. if (base) {
  3096. url = (function () {
  3097. var doc;
  3098.  
  3099. // Use another document/base tag/anchor for relative URL resolution, if possible
  3100. if (document.implementation && document.implementation.createHTMLDocument) {
  3101. doc = document.implementation.createHTMLDocument('');
  3102. }
  3103. else if (document.implementation && document.implementation.createDocument) {
  3104. doc = document.implementation.createElement('http://www.w3.org/1999/xhtml', 'html', null);
  3105. doc.documentElement.appendChild(doc.createElement('head'));
  3106. doc.documentElement.appendChild(doc.createElement('body'));
  3107. }
  3108. else if (window.ActiveXObject) {
  3109. doc = new window.ActiveXObject('htmlfile');
  3110. doc.write('<head></head><body></body>');
  3111. doc.close();
  3112. }
  3113.  
  3114. if (!doc) {
  3115. throw Error('base not supported');
  3116. }
  3117.  
  3118. var baseTag = doc.createElement('base');
  3119. baseTag.href = base;
  3120.  
  3121. doc.getElementsByTagName('head')[0].appendChild(baseTag);
  3122.  
  3123. var anchor = doc.createElement('a');
  3124. anchor.href = url;
  3125.  
  3126. return anchor.href;
  3127. }());
  3128. }
  3129.  
  3130. // An inner object implementing URLUtils (either a native URL
  3131. // object or an HTMLAnchorElement instance) is used to perform the
  3132. // URL algorithms. With full ES5 getter/setter support, return a
  3133. // regular object For IE8's limited getter/setter support, a
  3134. // different HTMLAnchorElement is returned with properties
  3135. // overridden
  3136.  
  3137. var instance = URLUtils(url || '');
  3138.  
  3139. // Detect for ES5 getter/setter support
  3140. var ES5_GET_SET = false;
  3141. try {
  3142. ES5_GET_SET = (Object.defineProperties && (function () {
  3143. var o = {};
  3144.  
  3145. Object.defineProperties(o, {
  3146. p: {
  3147. 'get': function () {
  3148. return true;
  3149. }
  3150. }
  3151. });
  3152. return o.p;
  3153. }()));
  3154. } catch (e) {
  3155. ES5_GET_SET = false;
  3156. };
  3157.  
  3158. var self = ES5_GET_SET ? this : document.createElement('a');
  3159.  
  3160. // NOTE: Doesn't do the encoding/decoding dance
  3161. function parse (input, isindex) {
  3162. var sequences = input.split('&');
  3163.  
  3164. if (isindex && sequences[0].indexOf('=') === -1) {
  3165. sequences[0] = '=' + sequences[0];
  3166. }
  3167.  
  3168. var pairs = [];
  3169.  
  3170. sequences.forEach(function (bytes) {
  3171. if (bytes.length === 0) {
  3172. return;
  3173. }
  3174.  
  3175. var index = bytes.indexOf('=');
  3176.  
  3177. if (index !== -1) {
  3178. var name = bytes.substring(0, index);
  3179. var value = bytes.substring(index + 1);
  3180. }
  3181. else {
  3182. name = bytes;
  3183. value = '';
  3184. }
  3185.  
  3186. name = name.replace(/\+/g, ' ');
  3187. value = value.replace(/\+/g, ' ');
  3188. pairs.push({name: name, value: value});
  3189. });
  3190.  
  3191. var output = [];
  3192.  
  3193. pairs.forEach(function (pair) {
  3194. output.push({
  3195. name : decodeURIComponent(pair.name),
  3196. value: decodeURIComponent(pair.value)
  3197. });
  3198. });
  3199.  
  3200. return output;
  3201. }
  3202.  
  3203. function URLSearchParams (url_object, init) {
  3204. var pairs = [];
  3205.  
  3206. if (init) {
  3207. pairs = parse(init);
  3208. }
  3209.  
  3210. this._setPairs = function (list) {
  3211. pairs = list;
  3212. };
  3213.  
  3214. this._updateSteps = function () {
  3215. updateSteps();
  3216. };
  3217.  
  3218. var updating = false;
  3219.  
  3220. function updateSteps () {
  3221. if (updating) return;
  3222. updating = true;
  3223.  
  3224. // TODO: For all associated url objects
  3225. url_object.search = serialize(pairs);
  3226.  
  3227. updating = false;
  3228. }
  3229.  
  3230. // NOTE: Doesn't do the encoding/decoding dance
  3231. function serialize (pairs) {
  3232. var output = '',
  3233. first = true;
  3234.  
  3235. pairs.forEach(function (pair) {
  3236. var name = encodeURIComponent(pair.name);
  3237. var value = encodeURIComponent(pair.value);
  3238.  
  3239. if (!first) {
  3240. output += '&';
  3241. }
  3242.  
  3243. output += name + '=' + value;
  3244.  
  3245. first = false;
  3246. });
  3247.  
  3248. return output.replace(/%20/g, '+');
  3249. }
  3250.  
  3251. Object.defineProperties(this, {
  3252. append: {
  3253. value: function (name, value) {
  3254. pairs.push({
  3255. name : name,
  3256. value: value
  3257. });
  3258.  
  3259. updateSteps();
  3260. }
  3261. },
  3262.  
  3263. 'delete': {
  3264. value: function (name) {
  3265. for (var i = 0; i < pairs.length;) {
  3266. if (pairs[i].name === name){
  3267. pairs.splice(i, 1);
  3268. }
  3269. else {
  3270. ++i;
  3271. }
  3272. }
  3273.  
  3274. updateSteps();
  3275. }
  3276. },
  3277.  
  3278. get: {
  3279. value: function (name) {
  3280. for (var i = 0; i < pairs.length; ++i) {
  3281. if (pairs[i].name === name) {
  3282. return pairs[i].value;
  3283. }
  3284. }
  3285.  
  3286. return null;
  3287. }
  3288. },
  3289.  
  3290. getAll: {
  3291. value: function (name) {
  3292. var result = [];
  3293.  
  3294. for (var i = 0; i < pairs.length; ++i) {
  3295. if (pairs[i].name === name) {
  3296. result.push(pairs[i].value);
  3297. }
  3298. }
  3299.  
  3300. return result;
  3301. }
  3302. },
  3303.  
  3304. has: {
  3305. value: function (name) {
  3306. for (var i = 0; i < pairs.length; ++i) {
  3307. if (pairs[i].name === name) {
  3308. return true;
  3309. }
  3310. }
  3311.  
  3312. return false;
  3313. }
  3314. },
  3315.  
  3316. set: {
  3317. value: function (name, value) {
  3318. var found = false;
  3319.  
  3320. for (var i = 0; i < pairs.length;) {
  3321. if (pairs[i].name === name) {
  3322. if (!found) {
  3323. pairs[i].value = value;
  3324. found = true;
  3325. ++i;
  3326. }
  3327. else {
  3328. pairs.splice(i, 1);
  3329. }
  3330. }
  3331. else {
  3332. ++i;
  3333. }
  3334. }
  3335.  
  3336. if (!found){
  3337. pairs.push({name: name, value: value});
  3338. }
  3339.  
  3340. updateSteps();
  3341. }
  3342. },
  3343.  
  3344. toString: {
  3345. value: function () {
  3346. return serialize(pairs);
  3347. }
  3348. }
  3349. });
  3350. }
  3351.  
  3352. var queryObject = new URLSearchParams(
  3353. self, instance.search ? instance.search.substring(1) : null);
  3354.  
  3355. Object.defineProperties(self, {
  3356. href: {
  3357. get: function () {
  3358. return instance.href;
  3359. },
  3360.  
  3361. set: function (v) {
  3362. instance.href = v;
  3363. tidy_instance();
  3364. update_steps();
  3365. }
  3366. },
  3367.  
  3368. origin: {
  3369. get: function () {
  3370. if ('origin' in instance) {
  3371. return instance.origin;
  3372. }
  3373.  
  3374. return this.protocol + '//' + this.host;
  3375. }
  3376. },
  3377.  
  3378. protocol: {
  3379. get: function () {
  3380. return instance.protocol;
  3381. },
  3382.  
  3383. set: function (v) {
  3384. instance.protocol = v;
  3385. }
  3386. },
  3387.  
  3388. username: {
  3389. get: function () {
  3390. return instance.username;
  3391. },
  3392.  
  3393. set: function (v) {
  3394. instance.username = v;
  3395. }
  3396. },
  3397.  
  3398. password: {
  3399. get: function () {
  3400. return instance.password;
  3401. },
  3402.  
  3403. set: function (v) {
  3404. instance.password = v;
  3405. }
  3406. },
  3407.  
  3408. host: {
  3409. get: function () {
  3410. // IE returns default port in |host|
  3411. var re = {
  3412. 'http:' : /:80$/,
  3413. 'https:': /:443$/,
  3414. 'ftp:' : /:21$/
  3415. }
  3416. [instance.protocol];
  3417.  
  3418. return re ? instance.host.replace(re, '') : instance.host;
  3419. },
  3420.  
  3421. set: function (v) {
  3422. instance.host = v;
  3423. }
  3424. },
  3425.  
  3426. hostname: {
  3427. get: function () {
  3428. return instance.hostname;
  3429. },
  3430.  
  3431. set: function (v) {
  3432. instance.hostname = v;
  3433. }
  3434. },
  3435.  
  3436. port: {
  3437. get: function () {
  3438. return instance.port;
  3439. },
  3440.  
  3441. set: function (v) {
  3442. instance.port = v;
  3443. }
  3444. },
  3445.  
  3446. pathname: {
  3447. get: function () {
  3448. // IE does not include leading '/' in |pathname|
  3449. if (instance.pathname.charAt(0) !== '/') {
  3450. return '/' + instance.pathname;
  3451. }
  3452.  
  3453. return instance.pathname;
  3454. },
  3455.  
  3456. set: function (v) {
  3457. instance.pathname = v;
  3458. }
  3459. },
  3460.  
  3461. search: {
  3462. get: function () {
  3463. return instance.search;
  3464. },
  3465.  
  3466. set: function (v) {
  3467. if (instance.search !== v) {
  3468. instance.search = v;
  3469. tidy_instance();
  3470. update_steps();
  3471. }
  3472. }
  3473. },
  3474. searchParams: {
  3475. get: function () {
  3476. return queryObject;
  3477. }
  3478. // TODO: implement setter
  3479. },
  3480. hash: {
  3481. get: function () {
  3482. return instance.hash;
  3483. },
  3484.  
  3485. set: function (v) {
  3486. instance.hash = v;
  3487. tidy_instance();
  3488. }
  3489. },
  3490.  
  3491. toString: {
  3492. value: function () {
  3493. return instance.toString();
  3494. }
  3495. },
  3496.  
  3497. valueOf: {
  3498. value: function () {
  3499. return instance.valueOf();
  3500. }
  3501. }
  3502. });
  3503.  
  3504. function tidy_instance () {
  3505. var href = instance.href.replace(/#$|\?$|\?(?=#)/g, '');
  3506.  
  3507. if (instance.href !== href){
  3508. instance.href = href;
  3509. }
  3510. }
  3511.  
  3512. function update_steps () {
  3513. queryObject._setPairs(instance.search ?
  3514. parse(instance.search.substring(1)) : []);
  3515.  
  3516. queryObject._updateSteps();
  3517. }
  3518.  
  3519. return self;
  3520. };
  3521.  
  3522. if (origURL) {
  3523. for (var i in origURL) {
  3524. if (origURL.hasOwnProperty(i)) {
  3525. global.URL[i] = origURL[i];
  3526. }
  3527. }
  3528. }
  3529. }(this));
  3530.  
  3531. // XMLHttpRequest
  3532. (function (global, NativeXMLHttpRequest) {
  3533. // <Global>.XMLHttpRequest
  3534. global.XMLHttpRequest = function XMLHttpRequest() {
  3535. var request = this, nativeRequest = request._request = NativeXMLHttpRequest ? new NativeXMLHttpRequest() : new ActiveXObject('MSXML2.XMLHTTP.3.0');
  3536.  
  3537. nativeRequest.onreadystatechange = function () {
  3538. request.readyState = nativeRequest.readyState;
  3539.  
  3540. var readyState = request.readyState === 4;
  3541.  
  3542. request.response = request.responseText = readyState ? nativeRequest.responseText : null;
  3543. request.status = readyState ? nativeRequest.status : null;
  3544. request.statusText = readyState ? nativeRequest.statusText : null;
  3545.  
  3546. request.dispatchEvent(new Event('readystatechange'));
  3547.  
  3548. if (readyState) {
  3549. request.dispatchEvent(new Event('load'));
  3550. }
  3551. };
  3552.  
  3553. if ('onerror' in nativeRequest) {
  3554. nativeRequest.onerror = function () {
  3555. request.dispatchEvent(new Event('error'));
  3556. };
  3557. }
  3558. };
  3559.  
  3560. var XMLHttpRequestPrototype = global.XMLHttpRequest.prototype;
  3561.  
  3562. XMLHttpRequestPrototype.addEventListener = global.addEventListener;
  3563. XMLHttpRequestPrototype.removeEventListener = global.removeEventListener;
  3564. XMLHttpRequestPrototype.dispatchEvent = global.dispatchEvent;
  3565.  
  3566. XMLHttpRequestPrototype.abort = function abort() {
  3567. return this._request();
  3568. };
  3569.  
  3570. XMLHttpRequestPrototype.getAllResponseHeaders = function getAllResponseHeaders() {
  3571. return this._request.getAllResponseHeaders();
  3572. };
  3573.  
  3574. XMLHttpRequestPrototype.getResponseHeader = function getResponseHeader(header) {
  3575. return this._request.getResponseHeader(header);
  3576. };
  3577.  
  3578. XMLHttpRequestPrototype.open = function open(method, url) {
  3579. // method, url, async, username, password
  3580. this._request.open(method, url, arguments[2], arguments[3], arguments[4]);
  3581. };
  3582.  
  3583. XMLHttpRequestPrototype.overrideMimeType = function overrideMimeType(mimetype) {
  3584. this._request.overrideMimeType(mimetype);
  3585. };
  3586.  
  3587. XMLHttpRequestPrototype.send = function send() {
  3588. this._request.send(0 in arguments ? arguments[0] : null);
  3589. };
  3590.  
  3591. XMLHttpRequestPrototype.setRequestHeader = function setRequestHeader(header, value) {
  3592. this._request.setRequestHeader(header, value);
  3593. };
  3594. })(this, this.XMLHttpRequest);
  3595.  
  3596. // atob
  3597. (function (global) {
  3598. var keys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', keysRe = new RegExp('[^' + keys + ']');
  3599.  
  3600. // <Global>.atob
  3601. global.atob = function atob(input) {
  3602. var output = [], buffer, bufferB, chrs, index = 0, indexB, length = input.length;
  3603.  
  3604. if ((keysRe.test(input)) || (/=/.test(input) && (/=[^=]/.test(input) || /={3}/.test(input)))) {
  3605. throw new Error('Invalid base64 data');
  3606. }
  3607.  
  3608. if (length % 4 > 0) {
  3609. input += Array(4 - length % 4 + 1).join("=");
  3610. length = input.length;
  3611. }
  3612.  
  3613. while (index < length) {
  3614. for (bufferB = [], indexB = index; index < indexB + 4;) {
  3615. bufferB.push(keys.indexOf(input.charAt(index++)));
  3616. }
  3617.  
  3618. buffer = (bufferB[0] << 18) + (bufferB[1] << 12) + ((bufferB[2] & 63) << 6) + (bufferB[3] & 63);
  3619.  
  3620. chrs = [(buffer & (255 << 16)) >> 16, bufferB[2] === 64 ? -1 : (buffer & (255 << 8)) >> 8, bufferB[3] === 64 ? -1 : buffer & 255];
  3621.  
  3622. for (indexB = 0; indexB < 3; ++indexB) {
  3623. if (chrs[indexB] >= 0 || indexB === 0) {
  3624. output.push(String.fromCharCode(chrs[indexB]));
  3625. }
  3626. }
  3627. }
  3628.  
  3629. return output.join('');
  3630. };
  3631.  
  3632. // <Global>.btoa
  3633. global.btoa = function btoa(input) {
  3634. var output = [], buffer, chrs, index = 0, length = input.length;
  3635.  
  3636. while (index < length) {
  3637. chrs = [input.charCodeAt(index++), input.charCodeAt(index++), input.charCodeAt(index++)];
  3638.  
  3639. buffer = (chrs[0] << 16) + ((chrs[1] || 0) << 8) + (chrs[2] || 0);
  3640.  
  3641. output.push(
  3642. keys.charAt((buffer & (63 << 18)) >> 18),
  3643. keys.charAt((buffer & (63 << 12)) >> 12),
  3644. keys.charAt(isNaN(chrs[1]) ? 64 : (buffer & (63 << 6)) >> 6),
  3645. keys.charAt(isNaN(chrs[2]) ? 64 : (buffer & 63))
  3646. );
  3647. }
  3648.  
  3649. return output.join('');
  3650. };
  3651. })(this);
  3652.  
  3653. // location.origin
  3654. try {
  3655. Object.defineProperty(window.location, 'origin', {
  3656. enumerable: true,
  3657. writable: false,
  3658. value: window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''),
  3659. configurable: false
  3660. });
  3661. } catch(e) {
  3662.  
  3663. // IE9 is throwing "Object doesn't support this action" when attempting defineProperty on window.location, so provide an alternative
  3664. window.location.origin = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
  3665. }
  3666.  
  3667. // performance.now
  3668. (function (global) {
  3669.  
  3670. var
  3671. startTime = Date.now();
  3672.  
  3673. if (!global.performance) {
  3674. global.performance = {};
  3675. }
  3676.  
  3677. global.performance.now = function () {
  3678. return Date.now() - startTime;
  3679. };
  3680.  
  3681. }(this));
  3682.  
  3683. // requestAnimationFrame
  3684. (function (global) {
  3685.  
  3686. if ('mozRequestAnimationFrame' in global) {
  3687. global.requestAnimationFrame = function (callback) {
  3688. return mozRequestAnimationFrame(function () {
  3689. callback(performance.now());
  3690. });
  3691. };
  3692. global.cancelAnimationFrame = mozCancelAnimationFrame;
  3693.  
  3694. } else if ('webkitRequestAnimationFrame' in global) {
  3695. global.requestAnimationFrame = function (callback) {
  3696. return webkitRequestAnimationFrame(function () {
  3697. callback(performance.now());
  3698. });
  3699. };
  3700. global.cancelAnimationFrame = webkitCancelAnimationFrame;
  3701.  
  3702. } else {
  3703.  
  3704. var lastTime = Date.now();
  3705.  
  3706. global.requestAnimationFrame = function (callback) {
  3707. if (typeof callback !== 'function') {
  3708. throw new TypeError(callback + 'is not a function');
  3709. }
  3710.  
  3711. var
  3712. currentTime = Date.now(),
  3713. delay = 16 + lastTime - currentTime;
  3714.  
  3715. if (delay < 0) {
  3716. delay = 0;
  3717. }
  3718.  
  3719. lastTime = currentTime;
  3720.  
  3721. return setTimeout(function () {
  3722. lastTime = Date.now();
  3723.  
  3724. callback(performance.now());
  3725. }, delay);
  3726. };
  3727.  
  3728. global.cancelAnimationFrame = function (id) {
  3729. clearTimeout(id);
  3730. };
  3731. }
  3732. })(this);
  3733.  
  3734. })
  3735. .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
  3736. typeof ftNextPolyfillServiceCallback==='function' && ftNextPolyfillServiceCallback();
Add Comment
Please, Sign In to add comment