Greasy Fork 还支持 简体中文。

Video Game Music 批量下載器

批量下載 downloads.khinsider.com 的原聲帶

目前為 2018-02-28 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Video Game Music batch downloader
  3. // @name:zh-TW Video Game Music 批量下載器
  4. // @namespace https://blog.maple3142.net/
  5. // @description batch download for downloads.khinsider.com originalsoundtracks
  6. // @description:zh-TW 批量下載 downloads.khinsider.com 的原聲帶
  7. // @version 0.1.3
  8. // @author maple3142
  9. // @match https://downloads.khinsider.com/game-soundtracks/album/*
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js
  11. // @connect 66.90.93.122
  12. // @license MIT
  13. // @copyright 2018, maple3142 (https://blog.maple3142.net/)
  14. // @grant GM_xmlhttpRequest
  15. // ==/UserScript==
  16.  
  17. (function ($,JSZip) {
  18. 'use strict';
  19.  
  20. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  21. JSZip = JSZip && JSZip.hasOwnProperty('default') ? JSZip['default'] : JSZip;
  22.  
  23. function unwrapExports (x) {
  24. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  25. }
  26.  
  27. function createCommonjsModule(fn, module) {
  28. return module = { exports: {} }, fn(module, module.exports), module.exports;
  29. }
  30.  
  31. var runtime = createCommonjsModule(function (module) {
  32. /**
  33. * Copyright (c) 2014-present, Facebook, Inc.
  34. *
  35. * This source code is licensed under the MIT license found in the
  36. * LICENSE file in the root directory of this source tree.
  37. */
  38.  
  39. !(function(global) {
  40.  
  41. var Op = Object.prototype;
  42. var hasOwn = Op.hasOwnProperty;
  43. var undefined; // More compressible than void 0.
  44. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  45. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  46. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  47. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  48.  
  49. var inModule = 'object' === "object";
  50. var runtime = global.regeneratorRuntime;
  51. if (runtime) {
  52. if (inModule) {
  53. // If regeneratorRuntime is defined globally and we're in a module,
  54. // make the exports object identical to regeneratorRuntime.
  55. module.exports = runtime;
  56. }
  57. // Don't bother evaluating the rest of this file if the runtime was
  58. // already defined globally.
  59. return;
  60. }
  61.  
  62. // Define the runtime globally (as expected by generated code) as either
  63. // module.exports (if we're in a module) or a new, empty object.
  64. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  65.  
  66. function wrap(innerFn, outerFn, self, tryLocsList) {
  67. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  68. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  69. var generator = Object.create(protoGenerator.prototype);
  70. var context = new Context(tryLocsList || []);
  71.  
  72. // The ._invoke method unifies the implementations of the .next,
  73. // .throw, and .return methods.
  74. generator._invoke = makeInvokeMethod(innerFn, self, context);
  75.  
  76. return generator;
  77. }
  78. runtime.wrap = wrap;
  79.  
  80. // Try/catch helper to minimize deoptimizations. Returns a completion
  81. // record like context.tryEntries[i].completion. This interface could
  82. // have been (and was previously) designed to take a closure to be
  83. // invoked without arguments, but in all the cases we care about we
  84. // already have an existing method we want to call, so there's no need
  85. // to create a new function object. We can even get away with assuming
  86. // the method takes exactly one argument, since that happens to be true
  87. // in every case, so we don't have to touch the arguments object. The
  88. // only additional allocation required is the completion record, which
  89. // has a stable shape and so hopefully should be cheap to allocate.
  90. function tryCatch(fn, obj, arg) {
  91. try {
  92. return { type: "normal", arg: fn.call(obj, arg) };
  93. } catch (err) {
  94. return { type: "throw", arg: err };
  95. }
  96. }
  97.  
  98. var GenStateSuspendedStart = "suspendedStart";
  99. var GenStateSuspendedYield = "suspendedYield";
  100. var GenStateExecuting = "executing";
  101. var GenStateCompleted = "completed";
  102.  
  103. // Returning this object from the innerFn has the same effect as
  104. // breaking out of the dispatch switch statement.
  105. var ContinueSentinel = {};
  106.  
  107. // Dummy constructor functions that we use as the .constructor and
  108. // .constructor.prototype properties for functions that return Generator
  109. // objects. For full spec compliance, you may wish to configure your
  110. // minifier not to mangle the names of these two functions.
  111. function Generator() {}
  112. function GeneratorFunction() {}
  113. function GeneratorFunctionPrototype() {}
  114.  
  115. // This is a polyfill for %IteratorPrototype% for environments that
  116. // don't natively support it.
  117. var IteratorPrototype = {};
  118. IteratorPrototype[iteratorSymbol] = function () {
  119. return this;
  120. };
  121.  
  122. var getProto = Object.getPrototypeOf;
  123. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  124. if (NativeIteratorPrototype &&
  125. NativeIteratorPrototype !== Op &&
  126. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  127. // This environment has a native %IteratorPrototype%; use it instead
  128. // of the polyfill.
  129. IteratorPrototype = NativeIteratorPrototype;
  130. }
  131.  
  132. var Gp = GeneratorFunctionPrototype.prototype =
  133. Generator.prototype = Object.create(IteratorPrototype);
  134. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  135. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  136. GeneratorFunctionPrototype[toStringTagSymbol] =
  137. GeneratorFunction.displayName = "GeneratorFunction";
  138.  
  139. // Helper for defining the .next, .throw, and .return methods of the
  140. // Iterator interface in terms of a single ._invoke method.
  141. function defineIteratorMethods(prototype) {
  142. ["next", "throw", "return"].forEach(function(method) {
  143. prototype[method] = function(arg) {
  144. return this._invoke(method, arg);
  145. };
  146. });
  147. }
  148.  
  149. runtime.isGeneratorFunction = function(genFun) {
  150. var ctor = typeof genFun === "function" && genFun.constructor;
  151. return ctor
  152. ? ctor === GeneratorFunction ||
  153. // For the native GeneratorFunction constructor, the best we can
  154. // do is to check its .name property.
  155. (ctor.displayName || ctor.name) === "GeneratorFunction"
  156. : false;
  157. };
  158.  
  159. runtime.mark = function(genFun) {
  160. if (Object.setPrototypeOf) {
  161. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  162. } else {
  163. genFun.__proto__ = GeneratorFunctionPrototype;
  164. if (!(toStringTagSymbol in genFun)) {
  165. genFun[toStringTagSymbol] = "GeneratorFunction";
  166. }
  167. }
  168. genFun.prototype = Object.create(Gp);
  169. return genFun;
  170. };
  171.  
  172. // Within the body of any async function, `await x` is transformed to
  173. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  174. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  175. // meant to be awaited.
  176. runtime.awrap = function(arg) {
  177. return { __await: arg };
  178. };
  179.  
  180. function AsyncIterator(generator) {
  181. function invoke(method, arg, resolve, reject) {
  182. var record = tryCatch(generator[method], generator, arg);
  183. if (record.type === "throw") {
  184. reject(record.arg);
  185. } else {
  186. var result = record.arg;
  187. var value = result.value;
  188. if (value &&
  189. typeof value === "object" &&
  190. hasOwn.call(value, "__await")) {
  191. return Promise.resolve(value.__await).then(function(value) {
  192. invoke("next", value, resolve, reject);
  193. }, function(err) {
  194. invoke("throw", err, resolve, reject);
  195. });
  196. }
  197.  
  198. return Promise.resolve(value).then(function(unwrapped) {
  199. // When a yielded Promise is resolved, its final value becomes
  200. // the .value of the Promise<{value,done}> result for the
  201. // current iteration. If the Promise is rejected, however, the
  202. // result for this iteration will be rejected with the same
  203. // reason. Note that rejections of yielded Promises are not
  204. // thrown back into the generator function, as is the case
  205. // when an awaited Promise is rejected. This difference in
  206. // behavior between yield and await is important, because it
  207. // allows the consumer to decide what to do with the yielded
  208. // rejection (swallow it and continue, manually .throw it back
  209. // into the generator, abandon iteration, whatever). With
  210. // await, by contrast, there is no opportunity to examine the
  211. // rejection reason outside the generator function, so the
  212. // only option is to throw it from the await expression, and
  213. // let the generator function handle the exception.
  214. result.value = unwrapped;
  215. resolve(result);
  216. }, reject);
  217. }
  218. }
  219.  
  220. var previousPromise;
  221.  
  222. function enqueue(method, arg) {
  223. function callInvokeWithMethodAndArg() {
  224. return new Promise(function(resolve, reject) {
  225. invoke(method, arg, resolve, reject);
  226. });
  227. }
  228.  
  229. return previousPromise =
  230. // If enqueue has been called before, then we want to wait until
  231. // all previous Promises have been resolved before calling invoke,
  232. // so that results are always delivered in the correct order. If
  233. // enqueue has not been called before, then it is important to
  234. // call invoke immediately, without waiting on a callback to fire,
  235. // so that the async generator function has the opportunity to do
  236. // any necessary setup in a predictable way. This predictability
  237. // is why the Promise constructor synchronously invokes its
  238. // executor callback, and why async functions synchronously
  239. // execute code before the first await. Since we implement simple
  240. // async functions in terms of async generators, it is especially
  241. // important to get this right, even though it requires care.
  242. previousPromise ? previousPromise.then(
  243. callInvokeWithMethodAndArg,
  244. // Avoid propagating failures to Promises returned by later
  245. // invocations of the iterator.
  246. callInvokeWithMethodAndArg
  247. ) : callInvokeWithMethodAndArg();
  248. }
  249.  
  250. // Define the unified helper method that is used to implement .next,
  251. // .throw, and .return (see defineIteratorMethods).
  252. this._invoke = enqueue;
  253. }
  254.  
  255. defineIteratorMethods(AsyncIterator.prototype);
  256. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  257. return this;
  258. };
  259. runtime.AsyncIterator = AsyncIterator;
  260.  
  261. // Note that simple async functions are implemented on top of
  262. // AsyncIterator objects; they just return a Promise for the value of
  263. // the final result produced by the iterator.
  264. runtime.async = function(innerFn, outerFn, self, tryLocsList) {
  265. var iter = new AsyncIterator(
  266. wrap(innerFn, outerFn, self, tryLocsList)
  267. );
  268.  
  269. return runtime.isGeneratorFunction(outerFn)
  270. ? iter // If outerFn is a generator, return the full iterator.
  271. : iter.next().then(function(result) {
  272. return result.done ? result.value : iter.next();
  273. });
  274. };
  275.  
  276. function makeInvokeMethod(innerFn, self, context) {
  277. var state = GenStateSuspendedStart;
  278.  
  279. return function invoke(method, arg) {
  280. if (state === GenStateExecuting) {
  281. throw new Error("Generator is already running");
  282. }
  283.  
  284. if (state === GenStateCompleted) {
  285. if (method === "throw") {
  286. throw arg;
  287. }
  288.  
  289. // Be forgiving, per 25.3.3.3.3 of the spec:
  290. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  291. return doneResult();
  292. }
  293.  
  294. context.method = method;
  295. context.arg = arg;
  296.  
  297. while (true) {
  298. var delegate = context.delegate;
  299. if (delegate) {
  300. var delegateResult = maybeInvokeDelegate(delegate, context);
  301. if (delegateResult) {
  302. if (delegateResult === ContinueSentinel) continue;
  303. return delegateResult;
  304. }
  305. }
  306.  
  307. if (context.method === "next") {
  308. // Setting context._sent for legacy support of Babel's
  309. // function.sent implementation.
  310. context.sent = context._sent = context.arg;
  311.  
  312. } else if (context.method === "throw") {
  313. if (state === GenStateSuspendedStart) {
  314. state = GenStateCompleted;
  315. throw context.arg;
  316. }
  317.  
  318. context.dispatchException(context.arg);
  319.  
  320. } else if (context.method === "return") {
  321. context.abrupt("return", context.arg);
  322. }
  323.  
  324. state = GenStateExecuting;
  325.  
  326. var record = tryCatch(innerFn, self, context);
  327. if (record.type === "normal") {
  328. // If an exception is thrown from innerFn, we leave state ===
  329. // GenStateExecuting and loop back for another invocation.
  330. state = context.done
  331. ? GenStateCompleted
  332. : GenStateSuspendedYield;
  333.  
  334. if (record.arg === ContinueSentinel) {
  335. continue;
  336. }
  337.  
  338. return {
  339. value: record.arg,
  340. done: context.done
  341. };
  342.  
  343. } else if (record.type === "throw") {
  344. state = GenStateCompleted;
  345. // Dispatch the exception by looping back around to the
  346. // context.dispatchException(context.arg) call above.
  347. context.method = "throw";
  348. context.arg = record.arg;
  349. }
  350. }
  351. };
  352. }
  353.  
  354. // Call delegate.iterator[context.method](context.arg) and handle the
  355. // result, either by returning a { value, done } result from the
  356. // delegate iterator, or by modifying context.method and context.arg,
  357. // setting context.delegate to null, and returning the ContinueSentinel.
  358. function maybeInvokeDelegate(delegate, context) {
  359. var method = delegate.iterator[context.method];
  360. if (method === undefined) {
  361. // A .throw or .return when the delegate iterator has no .throw
  362. // method always terminates the yield* loop.
  363. context.delegate = null;
  364.  
  365. if (context.method === "throw") {
  366. if (delegate.iterator.return) {
  367. // If the delegate iterator has a return method, give it a
  368. // chance to clean up.
  369. context.method = "return";
  370. context.arg = undefined;
  371. maybeInvokeDelegate(delegate, context);
  372.  
  373. if (context.method === "throw") {
  374. // If maybeInvokeDelegate(context) changed context.method from
  375. // "return" to "throw", let that override the TypeError below.
  376. return ContinueSentinel;
  377. }
  378. }
  379.  
  380. context.method = "throw";
  381. context.arg = new TypeError(
  382. "The iterator does not provide a 'throw' method");
  383. }
  384.  
  385. return ContinueSentinel;
  386. }
  387.  
  388. var record = tryCatch(method, delegate.iterator, context.arg);
  389.  
  390. if (record.type === "throw") {
  391. context.method = "throw";
  392. context.arg = record.arg;
  393. context.delegate = null;
  394. return ContinueSentinel;
  395. }
  396.  
  397. var info = record.arg;
  398.  
  399. if (! info) {
  400. context.method = "throw";
  401. context.arg = new TypeError("iterator result is not an object");
  402. context.delegate = null;
  403. return ContinueSentinel;
  404. }
  405.  
  406. if (info.done) {
  407. // Assign the result of the finished delegate to the temporary
  408. // variable specified by delegate.resultName (see delegateYield).
  409. context[delegate.resultName] = info.value;
  410.  
  411. // Resume execution at the desired location (see delegateYield).
  412. context.next = delegate.nextLoc;
  413.  
  414. // If context.method was "throw" but the delegate handled the
  415. // exception, let the outer generator proceed normally. If
  416. // context.method was "next", forget context.arg since it has been
  417. // "consumed" by the delegate iterator. If context.method was
  418. // "return", allow the original .return call to continue in the
  419. // outer generator.
  420. if (context.method !== "return") {
  421. context.method = "next";
  422. context.arg = undefined;
  423. }
  424.  
  425. } else {
  426. // Re-yield the result returned by the delegate method.
  427. return info;
  428. }
  429.  
  430. // The delegate iterator is finished, so forget it and continue with
  431. // the outer generator.
  432. context.delegate = null;
  433. return ContinueSentinel;
  434. }
  435.  
  436. // Define Generator.prototype.{next,throw,return} in terms of the
  437. // unified ._invoke helper method.
  438. defineIteratorMethods(Gp);
  439.  
  440. Gp[toStringTagSymbol] = "Generator";
  441.  
  442. // A Generator should always return itself as the iterator object when the
  443. // @@iterator function is called on it. Some browsers' implementations of the
  444. // iterator prototype chain incorrectly implement this, causing the Generator
  445. // object to not be returned from this call. This ensures that doesn't happen.
  446. // See https://github.com/facebook/regenerator/issues/274 for more details.
  447. Gp[iteratorSymbol] = function() {
  448. return this;
  449. };
  450.  
  451. Gp.toString = function() {
  452. return "[object Generator]";
  453. };
  454.  
  455. function pushTryEntry(locs) {
  456. var entry = { tryLoc: locs[0] };
  457.  
  458. if (1 in locs) {
  459. entry.catchLoc = locs[1];
  460. }
  461.  
  462. if (2 in locs) {
  463. entry.finallyLoc = locs[2];
  464. entry.afterLoc = locs[3];
  465. }
  466.  
  467. this.tryEntries.push(entry);
  468. }
  469.  
  470. function resetTryEntry(entry) {
  471. var record = entry.completion || {};
  472. record.type = "normal";
  473. delete record.arg;
  474. entry.completion = record;
  475. }
  476.  
  477. function Context(tryLocsList) {
  478. // The root entry object (effectively a try statement without a catch
  479. // or a finally block) gives us a place to store values thrown from
  480. // locations where there is no enclosing try statement.
  481. this.tryEntries = [{ tryLoc: "root" }];
  482. tryLocsList.forEach(pushTryEntry, this);
  483. this.reset(true);
  484. }
  485.  
  486. runtime.keys = function(object) {
  487. var keys = [];
  488. for (var key in object) {
  489. keys.push(key);
  490. }
  491. keys.reverse();
  492.  
  493. // Rather than returning an object with a next method, we keep
  494. // things simple and return the next function itself.
  495. return function next() {
  496. while (keys.length) {
  497. var key = keys.pop();
  498. if (key in object) {
  499. next.value = key;
  500. next.done = false;
  501. return next;
  502. }
  503. }
  504.  
  505. // To avoid creating an additional object, we just hang the .value
  506. // and .done properties off the next function object itself. This
  507. // also ensures that the minifier will not anonymize the function.
  508. next.done = true;
  509. return next;
  510. };
  511. };
  512.  
  513. function values(iterable) {
  514. if (iterable) {
  515. var iteratorMethod = iterable[iteratorSymbol];
  516. if (iteratorMethod) {
  517. return iteratorMethod.call(iterable);
  518. }
  519.  
  520. if (typeof iterable.next === "function") {
  521. return iterable;
  522. }
  523.  
  524. if (!isNaN(iterable.length)) {
  525. var i = -1, next = function next() {
  526. while (++i < iterable.length) {
  527. if (hasOwn.call(iterable, i)) {
  528. next.value = iterable[i];
  529. next.done = false;
  530. return next;
  531. }
  532. }
  533.  
  534. next.value = undefined;
  535. next.done = true;
  536.  
  537. return next;
  538. };
  539.  
  540. return next.next = next;
  541. }
  542. }
  543.  
  544. // Return an iterator with no values.
  545. return { next: doneResult };
  546. }
  547. runtime.values = values;
  548.  
  549. function doneResult() {
  550. return { value: undefined, done: true };
  551. }
  552.  
  553. Context.prototype = {
  554. constructor: Context,
  555.  
  556. reset: function(skipTempReset) {
  557. this.prev = 0;
  558. this.next = 0;
  559. // Resetting context._sent for legacy support of Babel's
  560. // function.sent implementation.
  561. this.sent = this._sent = undefined;
  562. this.done = false;
  563. this.delegate = null;
  564.  
  565. this.method = "next";
  566. this.arg = undefined;
  567.  
  568. this.tryEntries.forEach(resetTryEntry);
  569.  
  570. if (!skipTempReset) {
  571. for (var name in this) {
  572. // Not sure about the optimal order of these conditions:
  573. if (name.charAt(0) === "t" &&
  574. hasOwn.call(this, name) &&
  575. !isNaN(+name.slice(1))) {
  576. this[name] = undefined;
  577. }
  578. }
  579. }
  580. },
  581.  
  582. stop: function() {
  583. this.done = true;
  584.  
  585. var rootEntry = this.tryEntries[0];
  586. var rootRecord = rootEntry.completion;
  587. if (rootRecord.type === "throw") {
  588. throw rootRecord.arg;
  589. }
  590.  
  591. return this.rval;
  592. },
  593.  
  594. dispatchException: function(exception) {
  595. if (this.done) {
  596. throw exception;
  597. }
  598.  
  599. var context = this;
  600. function handle(loc, caught) {
  601. record.type = "throw";
  602. record.arg = exception;
  603. context.next = loc;
  604.  
  605. if (caught) {
  606. // If the dispatched exception was caught by a catch block,
  607. // then let that catch block handle the exception normally.
  608. context.method = "next";
  609. context.arg = undefined;
  610. }
  611.  
  612. return !! caught;
  613. }
  614.  
  615. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  616. var entry = this.tryEntries[i];
  617. var record = entry.completion;
  618.  
  619. if (entry.tryLoc === "root") {
  620. // Exception thrown outside of any try block that could handle
  621. // it, so set the completion value of the entire function to
  622. // throw the exception.
  623. return handle("end");
  624. }
  625.  
  626. if (entry.tryLoc <= this.prev) {
  627. var hasCatch = hasOwn.call(entry, "catchLoc");
  628. var hasFinally = hasOwn.call(entry, "finallyLoc");
  629.  
  630. if (hasCatch && hasFinally) {
  631. if (this.prev < entry.catchLoc) {
  632. return handle(entry.catchLoc, true);
  633. } else if (this.prev < entry.finallyLoc) {
  634. return handle(entry.finallyLoc);
  635. }
  636.  
  637. } else if (hasCatch) {
  638. if (this.prev < entry.catchLoc) {
  639. return handle(entry.catchLoc, true);
  640. }
  641.  
  642. } else if (hasFinally) {
  643. if (this.prev < entry.finallyLoc) {
  644. return handle(entry.finallyLoc);
  645. }
  646.  
  647. } else {
  648. throw new Error("try statement without catch or finally");
  649. }
  650. }
  651. }
  652. },
  653.  
  654. abrupt: function(type, arg) {
  655. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  656. var entry = this.tryEntries[i];
  657. if (entry.tryLoc <= this.prev &&
  658. hasOwn.call(entry, "finallyLoc") &&
  659. this.prev < entry.finallyLoc) {
  660. var finallyEntry = entry;
  661. break;
  662. }
  663. }
  664.  
  665. if (finallyEntry &&
  666. (type === "break" ||
  667. type === "continue") &&
  668. finallyEntry.tryLoc <= arg &&
  669. arg <= finallyEntry.finallyLoc) {
  670. // Ignore the finally entry if control is not jumping to a
  671. // location outside the try/catch block.
  672. finallyEntry = null;
  673. }
  674.  
  675. var record = finallyEntry ? finallyEntry.completion : {};
  676. record.type = type;
  677. record.arg = arg;
  678.  
  679. if (finallyEntry) {
  680. this.method = "next";
  681. this.next = finallyEntry.finallyLoc;
  682. return ContinueSentinel;
  683. }
  684.  
  685. return this.complete(record);
  686. },
  687.  
  688. complete: function(record, afterLoc) {
  689. if (record.type === "throw") {
  690. throw record.arg;
  691. }
  692.  
  693. if (record.type === "break" ||
  694. record.type === "continue") {
  695. this.next = record.arg;
  696. } else if (record.type === "return") {
  697. this.rval = this.arg = record.arg;
  698. this.method = "return";
  699. this.next = "end";
  700. } else if (record.type === "normal" && afterLoc) {
  701. this.next = afterLoc;
  702. }
  703.  
  704. return ContinueSentinel;
  705. },
  706.  
  707. finish: function(finallyLoc) {
  708. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  709. var entry = this.tryEntries[i];
  710. if (entry.finallyLoc === finallyLoc) {
  711. this.complete(entry.completion, entry.afterLoc);
  712. resetTryEntry(entry);
  713. return ContinueSentinel;
  714. }
  715. }
  716. },
  717.  
  718. "catch": function(tryLoc) {
  719. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  720. var entry = this.tryEntries[i];
  721. if (entry.tryLoc === tryLoc) {
  722. var record = entry.completion;
  723. if (record.type === "throw") {
  724. var thrown = record.arg;
  725. resetTryEntry(entry);
  726. }
  727. return thrown;
  728. }
  729. }
  730.  
  731. // The context.catch method must only be called with a location
  732. // argument that corresponds to a known catch block.
  733. throw new Error("illegal catch attempt");
  734. },
  735.  
  736. delegateYield: function(iterable, resultName, nextLoc) {
  737. this.delegate = {
  738. iterator: values(iterable),
  739. resultName: resultName,
  740. nextLoc: nextLoc
  741. };
  742.  
  743. if (this.method === "next") {
  744. // Deliberately forget the last sent value so that we don't
  745. // accidentally pass it on to the delegate.
  746. this.arg = undefined;
  747. }
  748.  
  749. return ContinueSentinel;
  750. }
  751. };
  752. })(
  753. // In sloppy mode, unbound `this` refers to the global object, fallback to
  754. // Function constructor if we're in global strict mode. That is sadly a form
  755. // of indirect eval which violates Content Security Policy.
  756. (function() { return this })() || Function("return this")()
  757. );
  758. });
  759.  
  760. /**
  761. * Copyright (c) 2014-present, Facebook, Inc.
  762. *
  763. * This source code is licensed under the MIT license found in the
  764. * LICENSE file in the root directory of this source tree.
  765. */
  766.  
  767. // This method of obtaining a reference to the global object needs to be
  768. // kept identical to the way it is obtained in runtime.js
  769. var g = (function() { return this })() || Function("return this")();
  770.  
  771. // Use `getOwnPropertyNames` because not all browsers support calling
  772. // `hasOwnProperty` on the global `self` object in a worker. See #183.
  773. var hadRuntime = g.regeneratorRuntime &&
  774. Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
  775.  
  776. // Save the old regeneratorRuntime in case it needs to be restored later.
  777. var oldRuntime = hadRuntime && g.regeneratorRuntime;
  778.  
  779. // Force reevalutation of runtime.js.
  780. g.regeneratorRuntime = undefined;
  781.  
  782. var runtimeModule = runtime;
  783.  
  784. if (hadRuntime) {
  785. // Restore the original runtime.
  786. g.regeneratorRuntime = oldRuntime;
  787. } else {
  788. // Remove the global property added by runtime.js.
  789. try {
  790. delete g.regeneratorRuntime;
  791. } catch(e) {
  792. g.regeneratorRuntime = undefined;
  793. }
  794. }
  795.  
  796. var regenerator = runtimeModule;
  797.  
  798. // 7.1.4 ToInteger
  799. var ceil = Math.ceil;
  800. var floor = Math.floor;
  801. var _toInteger = function (it) {
  802. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  803. };
  804.  
  805. // 7.2.1 RequireObjectCoercible(argument)
  806. var _defined = function (it) {
  807. if (it == undefined) throw TypeError("Can't call method on " + it);
  808. return it;
  809. };
  810.  
  811. // true -> String#at
  812. // false -> String#codePointAt
  813. var _stringAt = function (TO_STRING) {
  814. return function (that, pos) {
  815. var s = String(_defined(that));
  816. var i = _toInteger(pos);
  817. var l = s.length;
  818. var a, b;
  819. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  820. a = s.charCodeAt(i);
  821. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  822. ? TO_STRING ? s.charAt(i) : a
  823. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  824. };
  825. };
  826.  
  827. var _library = true;
  828.  
  829. var _global = createCommonjsModule(function (module) {
  830. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  831. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  832. ? window : typeof self != 'undefined' && self.Math == Math ? self
  833. // eslint-disable-next-line no-new-func
  834. : Function('return this')();
  835. if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
  836. });
  837.  
  838. var _core = createCommonjsModule(function (module) {
  839. var core = module.exports = { version: '2.5.3' };
  840. if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
  841. });
  842. var _core_1 = _core.version;
  843.  
  844. var _aFunction = function (it) {
  845. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  846. return it;
  847. };
  848.  
  849. // optional / simple context binding
  850.  
  851. var _ctx = function (fn, that, length) {
  852. _aFunction(fn);
  853. if (that === undefined) return fn;
  854. switch (length) {
  855. case 1: return function (a) {
  856. return fn.call(that, a);
  857. };
  858. case 2: return function (a, b) {
  859. return fn.call(that, a, b);
  860. };
  861. case 3: return function (a, b, c) {
  862. return fn.call(that, a, b, c);
  863. };
  864. }
  865. return function (/* ...args */) {
  866. return fn.apply(that, arguments);
  867. };
  868. };
  869.  
  870. var _isObject = function (it) {
  871. return typeof it === 'object' ? it !== null : typeof it === 'function';
  872. };
  873.  
  874. var _anObject = function (it) {
  875. if (!_isObject(it)) throw TypeError(it + ' is not an object!');
  876. return it;
  877. };
  878.  
  879. var _fails = function (exec) {
  880. try {
  881. return !!exec();
  882. } catch (e) {
  883. return true;
  884. }
  885. };
  886.  
  887. // Thank's IE8 for his funny defineProperty
  888. var _descriptors = !_fails(function () {
  889. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  890. });
  891.  
  892. var document$1 = _global.document;
  893. // typeof document.createElement is 'object' in old IE
  894. var is = _isObject(document$1) && _isObject(document$1.createElement);
  895. var _domCreate = function (it) {
  896. return is ? document$1.createElement(it) : {};
  897. };
  898.  
  899. var _ie8DomDefine = !_descriptors && !_fails(function () {
  900. return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
  901. });
  902.  
  903. // 7.1.1 ToPrimitive(input [, PreferredType])
  904.  
  905. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  906. // and the second argument - flag - preferred type is a string
  907. var _toPrimitive = function (it, S) {
  908. if (!_isObject(it)) return it;
  909. var fn, val;
  910. if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
  911. if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
  912. if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
  913. throw TypeError("Can't convert object to primitive value");
  914. };
  915.  
  916. var dP = Object.defineProperty;
  917.  
  918. var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  919. _anObject(O);
  920. P = _toPrimitive(P, true);
  921. _anObject(Attributes);
  922. if (_ie8DomDefine) try {
  923. return dP(O, P, Attributes);
  924. } catch (e) { /* empty */ }
  925. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  926. if ('value' in Attributes) O[P] = Attributes.value;
  927. return O;
  928. };
  929.  
  930. var _objectDp = {
  931. f: f
  932. };
  933.  
  934. var _propertyDesc = function (bitmap, value) {
  935. return {
  936. enumerable: !(bitmap & 1),
  937. configurable: !(bitmap & 2),
  938. writable: !(bitmap & 4),
  939. value: value
  940. };
  941. };
  942.  
  943. var _hide = _descriptors ? function (object, key, value) {
  944. return _objectDp.f(object, key, _propertyDesc(1, value));
  945. } : function (object, key, value) {
  946. object[key] = value;
  947. return object;
  948. };
  949.  
  950. var PROTOTYPE = 'prototype';
  951.  
  952. var $export = function (type, name, source) {
  953. var IS_FORCED = type & $export.F;
  954. var IS_GLOBAL = type & $export.G;
  955. var IS_STATIC = type & $export.S;
  956. var IS_PROTO = type & $export.P;
  957. var IS_BIND = type & $export.B;
  958. var IS_WRAP = type & $export.W;
  959. var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
  960. var expProto = exports[PROTOTYPE];
  961. var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] : (_global[name] || {})[PROTOTYPE];
  962. var key, own, out;
  963. if (IS_GLOBAL) source = name;
  964. for (key in source) {
  965. // contains in native
  966. own = !IS_FORCED && target && target[key] !== undefined;
  967. if (own && key in exports) continue;
  968. // export native or passed
  969. out = own ? target[key] : source[key];
  970. // prevent global pollution for namespaces
  971. exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
  972. // bind timers to global for call from export context
  973. : IS_BIND && own ? _ctx(out, _global)
  974. // wrap global constructors for prevent change them in library
  975. : IS_WRAP && target[key] == out ? (function (C) {
  976. var F = function (a, b, c) {
  977. if (this instanceof C) {
  978. switch (arguments.length) {
  979. case 0: return new C();
  980. case 1: return new C(a);
  981. case 2: return new C(a, b);
  982. } return new C(a, b, c);
  983. } return C.apply(this, arguments);
  984. };
  985. F[PROTOTYPE] = C[PROTOTYPE];
  986. return F;
  987. // make static versions for prototype methods
  988. })(out) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
  989. // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
  990. if (IS_PROTO) {
  991. (exports.virtual || (exports.virtual = {}))[key] = out;
  992. // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
  993. if (type & $export.R && expProto && !expProto[key]) _hide(expProto, key, out);
  994. }
  995. }
  996. };
  997. // type bitmap
  998. $export.F = 1; // forced
  999. $export.G = 2; // global
  1000. $export.S = 4; // static
  1001. $export.P = 8; // proto
  1002. $export.B = 16; // bind
  1003. $export.W = 32; // wrap
  1004. $export.U = 64; // safe
  1005. $export.R = 128; // real proto method for `library`
  1006. var _export = $export;
  1007.  
  1008. var _redefine = _hide;
  1009.  
  1010. var hasOwnProperty = {}.hasOwnProperty;
  1011. var _has = function (it, key) {
  1012. return hasOwnProperty.call(it, key);
  1013. };
  1014.  
  1015. var _iterators = {};
  1016.  
  1017. var toString = {}.toString;
  1018.  
  1019. var _cof = function (it) {
  1020. return toString.call(it).slice(8, -1);
  1021. };
  1022.  
  1023. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  1024.  
  1025. // eslint-disable-next-line no-prototype-builtins
  1026. var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  1027. return _cof(it) == 'String' ? it.split('') : Object(it);
  1028. };
  1029.  
  1030. // to indexed object, toObject with fallback for non-array-like ES3 strings
  1031.  
  1032.  
  1033. var _toIobject = function (it) {
  1034. return _iobject(_defined(it));
  1035. };
  1036.  
  1037. // 7.1.15 ToLength
  1038.  
  1039. var min = Math.min;
  1040. var _toLength = function (it) {
  1041. return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  1042. };
  1043.  
  1044. var max = Math.max;
  1045. var min$1 = Math.min;
  1046. var _toAbsoluteIndex = function (index, length) {
  1047. index = _toInteger(index);
  1048. return index < 0 ? max(index + length, 0) : min$1(index, length);
  1049. };
  1050.  
  1051. // false -> Array#indexOf
  1052. // true -> Array#includes
  1053.  
  1054.  
  1055.  
  1056. var _arrayIncludes = function (IS_INCLUDES) {
  1057. return function ($this, el, fromIndex) {
  1058. var O = _toIobject($this);
  1059. var length = _toLength(O.length);
  1060. var index = _toAbsoluteIndex(fromIndex, length);
  1061. var value;
  1062. // Array#includes uses SameValueZero equality algorithm
  1063. // eslint-disable-next-line no-self-compare
  1064. if (IS_INCLUDES && el != el) while (length > index) {
  1065. value = O[index++];
  1066. // eslint-disable-next-line no-self-compare
  1067. if (value != value) return true;
  1068. // Array#indexOf ignores holes, Array#includes - not
  1069. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  1070. if (O[index] === el) return IS_INCLUDES || index || 0;
  1071. } return !IS_INCLUDES && -1;
  1072. };
  1073. };
  1074.  
  1075. var SHARED = '__core-js_shared__';
  1076. var store = _global[SHARED] || (_global[SHARED] = {});
  1077. var _shared = function (key) {
  1078. return store[key] || (store[key] = {});
  1079. };
  1080.  
  1081. var id = 0;
  1082. var px = Math.random();
  1083. var _uid = function (key) {
  1084. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  1085. };
  1086.  
  1087. var shared = _shared('keys');
  1088.  
  1089. var _sharedKey = function (key) {
  1090. return shared[key] || (shared[key] = _uid(key));
  1091. };
  1092.  
  1093. var arrayIndexOf = _arrayIncludes(false);
  1094. var IE_PROTO = _sharedKey('IE_PROTO');
  1095.  
  1096. var _objectKeysInternal = function (object, names) {
  1097. var O = _toIobject(object);
  1098. var i = 0;
  1099. var result = [];
  1100. var key;
  1101. for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key);
  1102. // Don't enum bug & hidden keys
  1103. while (names.length > i) if (_has(O, key = names[i++])) {
  1104. ~arrayIndexOf(result, key) || result.push(key);
  1105. }
  1106. return result;
  1107. };
  1108.  
  1109. // IE 8- don't enum bug keys
  1110. var _enumBugKeys = (
  1111. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  1112. ).split(',');
  1113.  
  1114. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  1115.  
  1116.  
  1117.  
  1118. var _objectKeys = Object.keys || function keys(O) {
  1119. return _objectKeysInternal(O, _enumBugKeys);
  1120. };
  1121.  
  1122. var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
  1123. _anObject(O);
  1124. var keys = _objectKeys(Properties);
  1125. var length = keys.length;
  1126. var i = 0;
  1127. var P;
  1128. while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
  1129. return O;
  1130. };
  1131.  
  1132. var document$2 = _global.document;
  1133. var _html = document$2 && document$2.documentElement;
  1134.  
  1135. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  1136.  
  1137.  
  1138.  
  1139. var IE_PROTO$1 = _sharedKey('IE_PROTO');
  1140. var Empty = function () { /* empty */ };
  1141. var PROTOTYPE$1 = 'prototype';
  1142.  
  1143. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  1144. var createDict = function () {
  1145. // Thrash, waste and sodomy: IE GC bug
  1146. var iframe = _domCreate('iframe');
  1147. var i = _enumBugKeys.length;
  1148. var lt = '<';
  1149. var gt = '>';
  1150. var iframeDocument;
  1151. iframe.style.display = 'none';
  1152. _html.appendChild(iframe);
  1153. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  1154. // createDict = iframe.contentWindow.Object;
  1155. // html.removeChild(iframe);
  1156. iframeDocument = iframe.contentWindow.document;
  1157. iframeDocument.open();
  1158. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  1159. iframeDocument.close();
  1160. createDict = iframeDocument.F;
  1161. while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
  1162. return createDict();
  1163. };
  1164.  
  1165. var _objectCreate = Object.create || function create(O, Properties) {
  1166. var result;
  1167. if (O !== null) {
  1168. Empty[PROTOTYPE$1] = _anObject(O);
  1169. result = new Empty();
  1170. Empty[PROTOTYPE$1] = null;
  1171. // add "__proto__" for Object.getPrototypeOf polyfill
  1172. result[IE_PROTO$1] = O;
  1173. } else result = createDict();
  1174. return Properties === undefined ? result : _objectDps(result, Properties);
  1175. };
  1176.  
  1177. var _wks = createCommonjsModule(function (module) {
  1178. var store = _shared('wks');
  1179.  
  1180. var Symbol = _global.Symbol;
  1181. var USE_SYMBOL = typeof Symbol == 'function';
  1182.  
  1183. var $exports = module.exports = function (name) {
  1184. return store[name] || (store[name] =
  1185. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name));
  1186. };
  1187.  
  1188. $exports.store = store;
  1189. });
  1190.  
  1191. var def = _objectDp.f;
  1192.  
  1193. var TAG = _wks('toStringTag');
  1194.  
  1195. var _setToStringTag = function (it, tag, stat) {
  1196. if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
  1197. };
  1198.  
  1199. var IteratorPrototype = {};
  1200.  
  1201. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  1202. _hide(IteratorPrototype, _wks('iterator'), function () { return this; });
  1203.  
  1204. var _iterCreate = function (Constructor, NAME, next) {
  1205. Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) });
  1206. _setToStringTag(Constructor, NAME + ' Iterator');
  1207. };
  1208.  
  1209. // 7.1.13 ToObject(argument)
  1210.  
  1211. var _toObject = function (it) {
  1212. return Object(_defined(it));
  1213. };
  1214.  
  1215. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  1216.  
  1217.  
  1218. var IE_PROTO$2 = _sharedKey('IE_PROTO');
  1219. var ObjectProto = Object.prototype;
  1220.  
  1221. var _objectGpo = Object.getPrototypeOf || function (O) {
  1222. O = _toObject(O);
  1223. if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
  1224. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  1225. return O.constructor.prototype;
  1226. } return O instanceof Object ? ObjectProto : null;
  1227. };
  1228.  
  1229. var ITERATOR = _wks('iterator');
  1230. var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
  1231. var FF_ITERATOR = '@@iterator';
  1232. var KEYS = 'keys';
  1233. var VALUES = 'values';
  1234.  
  1235. var returnThis = function () { return this; };
  1236.  
  1237. var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  1238. _iterCreate(Constructor, NAME, next);
  1239. var getMethod = function (kind) {
  1240. if (!BUGGY && kind in proto) return proto[kind];
  1241. switch (kind) {
  1242. case KEYS: return function keys() { return new Constructor(this, kind); };
  1243. case VALUES: return function values() { return new Constructor(this, kind); };
  1244. } return function entries() { return new Constructor(this, kind); };
  1245. };
  1246. var TAG = NAME + ' Iterator';
  1247. var DEF_VALUES = DEFAULT == VALUES;
  1248. var VALUES_BUG = false;
  1249. var proto = Base.prototype;
  1250. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  1251. var $default = (!BUGGY && $native) || getMethod(DEFAULT);
  1252. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  1253. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  1254. var methods, key, IteratorPrototype;
  1255. // Fix native
  1256. if ($anyNative) {
  1257. IteratorPrototype = _objectGpo($anyNative.call(new Base()));
  1258. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  1259. // Set @@toStringTag to native iterators
  1260. _setToStringTag(IteratorPrototype, TAG, true);
  1261. // fix for some old engines
  1262. if (!_library && !_has(IteratorPrototype, ITERATOR)) _hide(IteratorPrototype, ITERATOR, returnThis);
  1263. }
  1264. }
  1265. // fix Array#{values, @@iterator}.name in V8 / FF
  1266. if (DEF_VALUES && $native && $native.name !== VALUES) {
  1267. VALUES_BUG = true;
  1268. $default = function values() { return $native.call(this); };
  1269. }
  1270. // Define iterator
  1271. if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  1272. _hide(proto, ITERATOR, $default);
  1273. }
  1274. // Plug for library
  1275. _iterators[NAME] = $default;
  1276. _iterators[TAG] = returnThis;
  1277. if (DEFAULT) {
  1278. methods = {
  1279. values: DEF_VALUES ? $default : getMethod(VALUES),
  1280. keys: IS_SET ? $default : getMethod(KEYS),
  1281. entries: $entries
  1282. };
  1283. if (FORCED) for (key in methods) {
  1284. if (!(key in proto)) _redefine(proto, key, methods[key]);
  1285. } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
  1286. }
  1287. return methods;
  1288. };
  1289.  
  1290. var $at = _stringAt(true);
  1291.  
  1292. // 21.1.3.27 String.prototype[@@iterator]()
  1293. _iterDefine(String, 'String', function (iterated) {
  1294. this._t = String(iterated); // target
  1295. this._i = 0; // next index
  1296. // 21.1.5.2.1 %StringIteratorPrototype%.next()
  1297. }, function () {
  1298. var O = this._t;
  1299. var index = this._i;
  1300. var point;
  1301. if (index >= O.length) return { value: undefined, done: true };
  1302. point = $at(O, index);
  1303. this._i += point.length;
  1304. return { value: point, done: false };
  1305. });
  1306.  
  1307. var _iterStep = function (done, value) {
  1308. return { value: value, done: !!done };
  1309. };
  1310.  
  1311. // 22.1.3.4 Array.prototype.entries()
  1312. // 22.1.3.13 Array.prototype.keys()
  1313. // 22.1.3.29 Array.prototype.values()
  1314. // 22.1.3.30 Array.prototype[@@iterator]()
  1315. var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
  1316. this._t = _toIobject(iterated); // target
  1317. this._i = 0; // next index
  1318. this._k = kind; // kind
  1319. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  1320. }, function () {
  1321. var O = this._t;
  1322. var kind = this._k;
  1323. var index = this._i++;
  1324. if (!O || index >= O.length) {
  1325. this._t = undefined;
  1326. return _iterStep(1);
  1327. }
  1328. if (kind == 'keys') return _iterStep(0, index);
  1329. if (kind == 'values') return _iterStep(0, O[index]);
  1330. return _iterStep(0, [index, O[index]]);
  1331. }, 'values');
  1332.  
  1333. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  1334. _iterators.Arguments = _iterators.Array;
  1335.  
  1336. var TO_STRING_TAG = _wks('toStringTag');
  1337.  
  1338. var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
  1339. 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
  1340. 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
  1341. 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
  1342. 'TextTrackList,TouchList').split(',');
  1343.  
  1344. for (var i = 0; i < DOMIterables.length; i++) {
  1345. var NAME = DOMIterables[i];
  1346. var Collection = _global[NAME];
  1347. var proto = Collection && Collection.prototype;
  1348. if (proto && !proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME);
  1349. _iterators[NAME] = _iterators.Array;
  1350. }
  1351.  
  1352. // getting tag from 19.1.3.6 Object.prototype.toString()
  1353.  
  1354. var TAG$1 = _wks('toStringTag');
  1355. // ES3 wrong here
  1356. var ARG = _cof(function () { return arguments; }()) == 'Arguments';
  1357.  
  1358. // fallback for IE11 Script Access Denied error
  1359. var tryGet = function (it, key) {
  1360. try {
  1361. return it[key];
  1362. } catch (e) { /* empty */ }
  1363. };
  1364.  
  1365. var _classof = function (it) {
  1366. var O, T, B;
  1367. return it === undefined ? 'Undefined' : it === null ? 'Null'
  1368. // @@toStringTag case
  1369. : typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T
  1370. // builtinTag case
  1371. : ARG ? _cof(O)
  1372. // ES3 arguments fallback
  1373. : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  1374. };
  1375.  
  1376. var _anInstance = function (it, Constructor, name, forbiddenField) {
  1377. if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
  1378. throw TypeError(name + ': incorrect invocation!');
  1379. } return it;
  1380. };
  1381.  
  1382. // call something on iterator step with safe closing on error
  1383.  
  1384. var _iterCall = function (iterator, fn, value, entries) {
  1385. try {
  1386. return entries ? fn(_anObject(value)[0], value[1]) : fn(value);
  1387. // 7.4.6 IteratorClose(iterator, completion)
  1388. } catch (e) {
  1389. var ret = iterator['return'];
  1390. if (ret !== undefined) _anObject(ret.call(iterator));
  1391. throw e;
  1392. }
  1393. };
  1394.  
  1395. // check on default Array iterator
  1396.  
  1397. var ITERATOR$1 = _wks('iterator');
  1398. var ArrayProto = Array.prototype;
  1399.  
  1400. var _isArrayIter = function (it) {
  1401. return it !== undefined && (_iterators.Array === it || ArrayProto[ITERATOR$1] === it);
  1402. };
  1403.  
  1404. var ITERATOR$2 = _wks('iterator');
  1405.  
  1406. var core_getIteratorMethod = _core.getIteratorMethod = function (it) {
  1407. if (it != undefined) return it[ITERATOR$2]
  1408. || it['@@iterator']
  1409. || _iterators[_classof(it)];
  1410. };
  1411.  
  1412. var _forOf = createCommonjsModule(function (module) {
  1413. var BREAK = {};
  1414. var RETURN = {};
  1415. var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  1416. var iterFn = ITERATOR ? function () { return iterable; } : core_getIteratorMethod(iterable);
  1417. var f = _ctx(fn, that, entries ? 2 : 1);
  1418. var index = 0;
  1419. var length, step, iterator, result;
  1420. if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
  1421. // fast case for arrays with default iterator
  1422. if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) {
  1423. result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  1424. if (result === BREAK || result === RETURN) return result;
  1425. } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
  1426. result = _iterCall(iterator, f, step.value, entries);
  1427. if (result === BREAK || result === RETURN) return result;
  1428. }
  1429. };
  1430. exports.BREAK = BREAK;
  1431. exports.RETURN = RETURN;
  1432. });
  1433.  
  1434. // 7.3.20 SpeciesConstructor(O, defaultConstructor)
  1435.  
  1436.  
  1437. var SPECIES = _wks('species');
  1438. var _speciesConstructor = function (O, D) {
  1439. var C = _anObject(O).constructor;
  1440. var S;
  1441. return C === undefined || (S = _anObject(C)[SPECIES]) == undefined ? D : _aFunction(S);
  1442. };
  1443.  
  1444. // fast apply, http://jsperf.lnkit.com/fast-apply/5
  1445. var _invoke = function (fn, args, that) {
  1446. var un = that === undefined;
  1447. switch (args.length) {
  1448. case 0: return un ? fn()
  1449. : fn.call(that);
  1450. case 1: return un ? fn(args[0])
  1451. : fn.call(that, args[0]);
  1452. case 2: return un ? fn(args[0], args[1])
  1453. : fn.call(that, args[0], args[1]);
  1454. case 3: return un ? fn(args[0], args[1], args[2])
  1455. : fn.call(that, args[0], args[1], args[2]);
  1456. case 4: return un ? fn(args[0], args[1], args[2], args[3])
  1457. : fn.call(that, args[0], args[1], args[2], args[3]);
  1458. } return fn.apply(that, args);
  1459. };
  1460.  
  1461. var process = _global.process;
  1462. var setTask = _global.setImmediate;
  1463. var clearTask = _global.clearImmediate;
  1464. var MessageChannel = _global.MessageChannel;
  1465. var Dispatch = _global.Dispatch;
  1466. var counter = 0;
  1467. var queue = {};
  1468. var ONREADYSTATECHANGE = 'onreadystatechange';
  1469. var defer, channel, port;
  1470. var run = function () {
  1471. var id = +this;
  1472. // eslint-disable-next-line no-prototype-builtins
  1473. if (queue.hasOwnProperty(id)) {
  1474. var fn = queue[id];
  1475. delete queue[id];
  1476. fn();
  1477. }
  1478. };
  1479. var listener = function (event) {
  1480. run.call(event.data);
  1481. };
  1482. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  1483. if (!setTask || !clearTask) {
  1484. setTask = function setImmediate(fn) {
  1485. var args = [];
  1486. var i = 1;
  1487. while (arguments.length > i) args.push(arguments[i++]);
  1488. queue[++counter] = function () {
  1489. // eslint-disable-next-line no-new-func
  1490. _invoke(typeof fn == 'function' ? fn : Function(fn), args);
  1491. };
  1492. defer(counter);
  1493. return counter;
  1494. };
  1495. clearTask = function clearImmediate(id) {
  1496. delete queue[id];
  1497. };
  1498. // Node.js 0.8-
  1499. if (_cof(process) == 'process') {
  1500. defer = function (id) {
  1501. process.nextTick(_ctx(run, id, 1));
  1502. };
  1503. // Sphere (JS game engine) Dispatch API
  1504. } else if (Dispatch && Dispatch.now) {
  1505. defer = function (id) {
  1506. Dispatch.now(_ctx(run, id, 1));
  1507. };
  1508. // Browsers with MessageChannel, includes WebWorkers
  1509. } else if (MessageChannel) {
  1510. channel = new MessageChannel();
  1511. port = channel.port2;
  1512. channel.port1.onmessage = listener;
  1513. defer = _ctx(port.postMessage, port, 1);
  1514. // Browsers with postMessage, skip WebWorkers
  1515. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  1516. } else if (_global.addEventListener && typeof postMessage == 'function' && !_global.importScripts) {
  1517. defer = function (id) {
  1518. _global.postMessage(id + '', '*');
  1519. };
  1520. _global.addEventListener('message', listener, false);
  1521. // IE8-
  1522. } else if (ONREADYSTATECHANGE in _domCreate('script')) {
  1523. defer = function (id) {
  1524. _html.appendChild(_domCreate('script'))[ONREADYSTATECHANGE] = function () {
  1525. _html.removeChild(this);
  1526. run.call(id);
  1527. };
  1528. };
  1529. // Rest old browsers
  1530. } else {
  1531. defer = function (id) {
  1532. setTimeout(_ctx(run, id, 1), 0);
  1533. };
  1534. }
  1535. }
  1536. var _task = {
  1537. set: setTask,
  1538. clear: clearTask
  1539. };
  1540.  
  1541. var macrotask = _task.set;
  1542. var Observer = _global.MutationObserver || _global.WebKitMutationObserver;
  1543. var process$1 = _global.process;
  1544. var Promise$1 = _global.Promise;
  1545. var isNode = _cof(process$1) == 'process';
  1546.  
  1547. var _microtask = function () {
  1548. var head, last, notify;
  1549.  
  1550. var flush = function () {
  1551. var parent, fn;
  1552. if (isNode && (parent = process$1.domain)) parent.exit();
  1553. while (head) {
  1554. fn = head.fn;
  1555. head = head.next;
  1556. try {
  1557. fn();
  1558. } catch (e) {
  1559. if (head) notify();
  1560. else last = undefined;
  1561. throw e;
  1562. }
  1563. } last = undefined;
  1564. if (parent) parent.enter();
  1565. };
  1566.  
  1567. // Node.js
  1568. if (isNode) {
  1569. notify = function () {
  1570. process$1.nextTick(flush);
  1571. };
  1572. // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
  1573. } else if (Observer && !(_global.navigator && _global.navigator.standalone)) {
  1574. var toggle = true;
  1575. var node = document.createTextNode('');
  1576. new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
  1577. notify = function () {
  1578. node.data = toggle = !toggle;
  1579. };
  1580. // environments with maybe non-completely correct, but existent Promise
  1581. } else if (Promise$1 && Promise$1.resolve) {
  1582. var promise = Promise$1.resolve();
  1583. notify = function () {
  1584. promise.then(flush);
  1585. };
  1586. // for other environments - macrotask based on:
  1587. // - setImmediate
  1588. // - MessageChannel
  1589. // - window.postMessag
  1590. // - onreadystatechange
  1591. // - setTimeout
  1592. } else {
  1593. notify = function () {
  1594. // strange IE + webpack dev server bug - use .call(global)
  1595. macrotask.call(_global, flush);
  1596. };
  1597. }
  1598.  
  1599. return function (fn) {
  1600. var task = { fn: fn, next: undefined };
  1601. if (last) last.next = task;
  1602. if (!head) {
  1603. head = task;
  1604. notify();
  1605. } last = task;
  1606. };
  1607. };
  1608.  
  1609. // 25.4.1.5 NewPromiseCapability(C)
  1610.  
  1611.  
  1612. function PromiseCapability(C) {
  1613. var resolve, reject;
  1614. this.promise = new C(function ($$resolve, $$reject) {
  1615. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  1616. resolve = $$resolve;
  1617. reject = $$reject;
  1618. });
  1619. this.resolve = _aFunction(resolve);
  1620. this.reject = _aFunction(reject);
  1621. }
  1622.  
  1623. var f$1 = function (C) {
  1624. return new PromiseCapability(C);
  1625. };
  1626.  
  1627. var _newPromiseCapability = {
  1628. f: f$1
  1629. };
  1630.  
  1631. var _perform = function (exec) {
  1632. try {
  1633. return { e: false, v: exec() };
  1634. } catch (e) {
  1635. return { e: true, v: e };
  1636. }
  1637. };
  1638.  
  1639. var _promiseResolve = function (C, x) {
  1640. _anObject(C);
  1641. if (_isObject(x) && x.constructor === C) return x;
  1642. var promiseCapability = _newPromiseCapability.f(C);
  1643. var resolve = promiseCapability.resolve;
  1644. resolve(x);
  1645. return promiseCapability.promise;
  1646. };
  1647.  
  1648. var _redefineAll = function (target, src, safe) {
  1649. for (var key in src) {
  1650. if (safe && target[key]) target[key] = src[key];
  1651. else _hide(target, key, src[key]);
  1652. } return target;
  1653. };
  1654.  
  1655. var SPECIES$1 = _wks('species');
  1656.  
  1657. var _setSpecies = function (KEY) {
  1658. var C = typeof _core[KEY] == 'function' ? _core[KEY] : _global[KEY];
  1659. if (_descriptors && C && !C[SPECIES$1]) _objectDp.f(C, SPECIES$1, {
  1660. configurable: true,
  1661. get: function () { return this; }
  1662. });
  1663. };
  1664.  
  1665. var ITERATOR$3 = _wks('iterator');
  1666. var SAFE_CLOSING = false;
  1667.  
  1668. try {
  1669. var riter = [7][ITERATOR$3]();
  1670. riter['return'] = function () { SAFE_CLOSING = true; };
  1671. } catch (e) { /* empty */ }
  1672.  
  1673. var _iterDetect = function (exec, skipClosing) {
  1674. if (!skipClosing && !SAFE_CLOSING) return false;
  1675. var safe = false;
  1676. try {
  1677. var arr = [7];
  1678. var iter = arr[ITERATOR$3]();
  1679. iter.next = function () { return { done: safe = true }; };
  1680. arr[ITERATOR$3] = function () { return iter; };
  1681. exec(arr);
  1682. } catch (e) { /* empty */ }
  1683. return safe;
  1684. };
  1685.  
  1686. var task = _task.set;
  1687. var microtask = _microtask();
  1688.  
  1689.  
  1690.  
  1691. var PROMISE = 'Promise';
  1692. var TypeError$1 = _global.TypeError;
  1693. var process$2 = _global.process;
  1694. var $Promise = _global[PROMISE];
  1695. var isNode$1 = _classof(process$2) == 'process';
  1696. var empty = function () { /* empty */ };
  1697. var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
  1698. var newPromiseCapability = newGenericPromiseCapability = _newPromiseCapability.f;
  1699.  
  1700. var USE_NATIVE = !!function () {
  1701. try {
  1702. // correct subclassing with @@species support
  1703. var promise = $Promise.resolve(1);
  1704. var FakePromise = (promise.constructor = {})[_wks('species')] = function (exec) {
  1705. exec(empty, empty);
  1706. };
  1707. // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  1708. return (isNode$1 || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
  1709. } catch (e) { /* empty */ }
  1710. }();
  1711.  
  1712. // helpers
  1713. var isThenable = function (it) {
  1714. var then;
  1715. return _isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  1716. };
  1717. var notify = function (promise, isReject) {
  1718. if (promise._n) return;
  1719. promise._n = true;
  1720. var chain = promise._c;
  1721. microtask(function () {
  1722. var value = promise._v;
  1723. var ok = promise._s == 1;
  1724. var i = 0;
  1725. var run = function (reaction) {
  1726. var handler = ok ? reaction.ok : reaction.fail;
  1727. var resolve = reaction.resolve;
  1728. var reject = reaction.reject;
  1729. var domain = reaction.domain;
  1730. var result, then;
  1731. try {
  1732. if (handler) {
  1733. if (!ok) {
  1734. if (promise._h == 2) onHandleUnhandled(promise);
  1735. promise._h = 1;
  1736. }
  1737. if (handler === true) result = value;
  1738. else {
  1739. if (domain) domain.enter();
  1740. result = handler(value);
  1741. if (domain) domain.exit();
  1742. }
  1743. if (result === reaction.promise) {
  1744. reject(TypeError$1('Promise-chain cycle'));
  1745. } else if (then = isThenable(result)) {
  1746. then.call(result, resolve, reject);
  1747. } else resolve(result);
  1748. } else reject(value);
  1749. } catch (e) {
  1750. reject(e);
  1751. }
  1752. };
  1753. while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
  1754. promise._c = [];
  1755. promise._n = false;
  1756. if (isReject && !promise._h) onUnhandled(promise);
  1757. });
  1758. };
  1759. var onUnhandled = function (promise) {
  1760. task.call(_global, function () {
  1761. var value = promise._v;
  1762. var unhandled = isUnhandled(promise);
  1763. var result, handler, console;
  1764. if (unhandled) {
  1765. result = _perform(function () {
  1766. if (isNode$1) {
  1767. process$2.emit('unhandledRejection', value, promise);
  1768. } else if (handler = _global.onunhandledrejection) {
  1769. handler({ promise: promise, reason: value });
  1770. } else if ((console = _global.console) && console.error) {
  1771. console.error('Unhandled promise rejection', value);
  1772. }
  1773. });
  1774. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  1775. promise._h = isNode$1 || isUnhandled(promise) ? 2 : 1;
  1776. } promise._a = undefined;
  1777. if (unhandled && result.e) throw result.v;
  1778. });
  1779. };
  1780. var isUnhandled = function (promise) {
  1781. return promise._h !== 1 && (promise._a || promise._c).length === 0;
  1782. };
  1783. var onHandleUnhandled = function (promise) {
  1784. task.call(_global, function () {
  1785. var handler;
  1786. if (isNode$1) {
  1787. process$2.emit('rejectionHandled', promise);
  1788. } else if (handler = _global.onrejectionhandled) {
  1789. handler({ promise: promise, reason: promise._v });
  1790. }
  1791. });
  1792. };
  1793. var $reject = function (value) {
  1794. var promise = this;
  1795. if (promise._d) return;
  1796. promise._d = true;
  1797. promise = promise._w || promise; // unwrap
  1798. promise._v = value;
  1799. promise._s = 2;
  1800. if (!promise._a) promise._a = promise._c.slice();
  1801. notify(promise, true);
  1802. };
  1803. var $resolve = function (value) {
  1804. var promise = this;
  1805. var then;
  1806. if (promise._d) return;
  1807. promise._d = true;
  1808. promise = promise._w || promise; // unwrap
  1809. try {
  1810. if (promise === value) throw TypeError$1("Promise can't be resolved itself");
  1811. if (then = isThenable(value)) {
  1812. microtask(function () {
  1813. var wrapper = { _w: promise, _d: false }; // wrap
  1814. try {
  1815. then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1));
  1816. } catch (e) {
  1817. $reject.call(wrapper, e);
  1818. }
  1819. });
  1820. } else {
  1821. promise._v = value;
  1822. promise._s = 1;
  1823. notify(promise, false);
  1824. }
  1825. } catch (e) {
  1826. $reject.call({ _w: promise, _d: false }, e); // wrap
  1827. }
  1828. };
  1829.  
  1830. // constructor polyfill
  1831. if (!USE_NATIVE) {
  1832. // 25.4.3.1 Promise(executor)
  1833. $Promise = function Promise(executor) {
  1834. _anInstance(this, $Promise, PROMISE, '_h');
  1835. _aFunction(executor);
  1836. Internal.call(this);
  1837. try {
  1838. executor(_ctx($resolve, this, 1), _ctx($reject, this, 1));
  1839. } catch (err) {
  1840. $reject.call(this, err);
  1841. }
  1842. };
  1843. // eslint-disable-next-line no-unused-vars
  1844. Internal = function Promise(executor) {
  1845. this._c = []; // <- awaiting reactions
  1846. this._a = undefined; // <- checked in isUnhandled reactions
  1847. this._s = 0; // <- state
  1848. this._d = false; // <- done
  1849. this._v = undefined; // <- value
  1850. this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
  1851. this._n = false; // <- notify
  1852. };
  1853. Internal.prototype = _redefineAll($Promise.prototype, {
  1854. // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
  1855. then: function then(onFulfilled, onRejected) {
  1856. var reaction = newPromiseCapability(_speciesConstructor(this, $Promise));
  1857. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  1858. reaction.fail = typeof onRejected == 'function' && onRejected;
  1859. reaction.domain = isNode$1 ? process$2.domain : undefined;
  1860. this._c.push(reaction);
  1861. if (this._a) this._a.push(reaction);
  1862. if (this._s) notify(this, false);
  1863. return reaction.promise;
  1864. },
  1865. // 25.4.5.1 Promise.prototype.catch(onRejected)
  1866. 'catch': function (onRejected) {
  1867. return this.then(undefined, onRejected);
  1868. }
  1869. });
  1870. OwnPromiseCapability = function () {
  1871. var promise = new Internal();
  1872. this.promise = promise;
  1873. this.resolve = _ctx($resolve, promise, 1);
  1874. this.reject = _ctx($reject, promise, 1);
  1875. };
  1876. _newPromiseCapability.f = newPromiseCapability = function (C) {
  1877. return C === $Promise || C === Wrapper
  1878. ? new OwnPromiseCapability(C)
  1879. : newGenericPromiseCapability(C);
  1880. };
  1881. }
  1882.  
  1883. _export(_export.G + _export.W + _export.F * !USE_NATIVE, { Promise: $Promise });
  1884. _setToStringTag($Promise, PROMISE);
  1885. _setSpecies(PROMISE);
  1886. Wrapper = _core[PROMISE];
  1887.  
  1888. // statics
  1889. _export(_export.S + _export.F * !USE_NATIVE, PROMISE, {
  1890. // 25.4.4.5 Promise.reject(r)
  1891. reject: function reject(r) {
  1892. var capability = newPromiseCapability(this);
  1893. var $$reject = capability.reject;
  1894. $$reject(r);
  1895. return capability.promise;
  1896. }
  1897. });
  1898. _export(_export.S + _export.F * (_library || !USE_NATIVE), PROMISE, {
  1899. // 25.4.4.6 Promise.resolve(x)
  1900. resolve: function resolve(x) {
  1901. return _promiseResolve(_library && this === Wrapper ? $Promise : this, x);
  1902. }
  1903. });
  1904. _export(_export.S + _export.F * !(USE_NATIVE && _iterDetect(function (iter) {
  1905. $Promise.all(iter)['catch'](empty);
  1906. })), PROMISE, {
  1907. // 25.4.4.1 Promise.all(iterable)
  1908. all: function all(iterable) {
  1909. var C = this;
  1910. var capability = newPromiseCapability(C);
  1911. var resolve = capability.resolve;
  1912. var reject = capability.reject;
  1913. var result = _perform(function () {
  1914. var values = [];
  1915. var index = 0;
  1916. var remaining = 1;
  1917. _forOf(iterable, false, function (promise) {
  1918. var $index = index++;
  1919. var alreadyCalled = false;
  1920. values.push(undefined);
  1921. remaining++;
  1922. C.resolve(promise).then(function (value) {
  1923. if (alreadyCalled) return;
  1924. alreadyCalled = true;
  1925. values[$index] = value;
  1926. --remaining || resolve(values);
  1927. }, reject);
  1928. });
  1929. --remaining || resolve(values);
  1930. });
  1931. if (result.e) reject(result.v);
  1932. return capability.promise;
  1933. },
  1934. // 25.4.4.4 Promise.race(iterable)
  1935. race: function race(iterable) {
  1936. var C = this;
  1937. var capability = newPromiseCapability(C);
  1938. var reject = capability.reject;
  1939. var result = _perform(function () {
  1940. _forOf(iterable, false, function (promise) {
  1941. C.resolve(promise).then(capability.resolve, reject);
  1942. });
  1943. });
  1944. if (result.e) reject(result.v);
  1945. return capability.promise;
  1946. }
  1947. });
  1948.  
  1949. _export(_export.P + _export.R, 'Promise', { 'finally': function (onFinally) {
  1950. var C = _speciesConstructor(this, _core.Promise || _global.Promise);
  1951. var isFunction = typeof onFinally == 'function';
  1952. return this.then(
  1953. isFunction ? function (x) {
  1954. return _promiseResolve(C, onFinally()).then(function () { return x; });
  1955. } : onFinally,
  1956. isFunction ? function (e) {
  1957. return _promiseResolve(C, onFinally()).then(function () { throw e; });
  1958. } : onFinally
  1959. );
  1960. } });
  1961.  
  1962. // https://github.com/tc39/proposal-promise-try
  1963.  
  1964.  
  1965.  
  1966.  
  1967. _export(_export.S, 'Promise', { 'try': function (callbackfn) {
  1968. var promiseCapability = _newPromiseCapability.f(this);
  1969. var result = _perform(callbackfn);
  1970. (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
  1971. return promiseCapability.promise;
  1972. } });
  1973.  
  1974. var promise = _core.Promise;
  1975.  
  1976. var promise$1 = createCommonjsModule(function (module) {
  1977. module.exports = { "default": promise, __esModule: true };
  1978. });
  1979.  
  1980. unwrapExports(promise$1);
  1981.  
  1982. var asyncToGenerator = createCommonjsModule(function (module, exports) {
  1983.  
  1984. exports.__esModule = true;
  1985.  
  1986.  
  1987.  
  1988. var _promise2 = _interopRequireDefault(promise$1);
  1989.  
  1990. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1991.  
  1992. exports.default = function (fn) {
  1993. return function () {
  1994. var gen = fn.apply(this, arguments);
  1995. return new _promise2.default(function (resolve, reject) {
  1996. function step(key, arg) {
  1997. try {
  1998. var info = gen[key](arg);
  1999. var value = info.value;
  2000. } catch (error) {
  2001. reject(error);
  2002. return;
  2003. }
  2004.  
  2005. if (info.done) {
  2006. resolve(value);
  2007. } else {
  2008. return _promise2.default.resolve(value).then(function (value) {
  2009. step("next", value);
  2010. }, function (err) {
  2011. step("throw", err);
  2012. });
  2013. }
  2014. }
  2015.  
  2016. return step("next");
  2017. });
  2018. };
  2019. };
  2020. });
  2021.  
  2022. var _asyncToGenerator = unwrapExports(asyncToGenerator);
  2023.  
  2024. function downloadblob(url) {
  2025. return new Promise(function (resolve, reject) {
  2026. GM_xmlhttpRequest({
  2027. method: 'GET',
  2028. url: url,
  2029. responseType: 'blob',
  2030. onload: function onload(res) {
  2031. return resolve(res.response);
  2032. }
  2033. });
  2034. });
  2035. }
  2036.  
  2037. var _this = window;
  2038.  
  2039. $('a:contains("click to download")').on('click', function () {
  2040. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2041. var title, urls, requests, files, blob, url, a;
  2042. return regenerator.wrap(function _callee$(_context) {
  2043. while (1) {
  2044. switch (_context.prev = _context.next) {
  2045. case 0:
  2046. e.preventDefault();
  2047. $('.albumMassDownload').append('\n<div>\n<span>Download progress:</span>\n<progress min="0" max="100" id="dp" value="0"></progress>\n</div>\n');
  2048.  
  2049. title = $('h2')[0].textContent;
  2050. urls = $('tr>td.clickable-row:not([align])').toArray().map(function (el) {
  2051. return $(el).find('a').attr('href');
  2052. });
  2053. requests = urls.map(function (e) {
  2054. return fetch(e).then(function (r) {
  2055. return r.text();
  2056. });
  2057. });
  2058. _context.next = 7;
  2059. return Promise.all(requests);
  2060.  
  2061. case 7:
  2062. _context.t0 = function (html) {
  2063. var url = $(html).find('a:contains("Click here to download as MP3")').attr('href');
  2064. return { blob: downloadblob(url), name: decodeURIComponent(url.split('/').pop()) };
  2065. };
  2066.  
  2067. files = _context.sent.map(_context.t0);
  2068. _context.next = 11;
  2069. return files.reduce(function (zip, file) {
  2070. zip.file(file.name, file.blob);
  2071. return zip;
  2072. }, new JSZip()).generateAsync({ type: 'blob' }, function (meta) {
  2073. return $('#dp').attr('value', parseInt(meta.percent));
  2074. });
  2075.  
  2076. case 11:
  2077. blob = _context.sent;
  2078. url = URL.createObjectURL(blob);
  2079. a = document.createElement('a');
  2080.  
  2081. a.download = title + '.zip';
  2082. a.href = url;
  2083. document.body.appendChild(a);
  2084. a.click();
  2085. a.remove();
  2086. URL.revokeObjectURL(url);
  2087.  
  2088. case 20:
  2089. case 'end':
  2090. return _context.stop();
  2091. }
  2092. }
  2093. }, _callee, _this);
  2094. }));
  2095.  
  2096. return function (_x) {
  2097. return _ref.apply(this, arguments);
  2098. };
  2099. }());
  2100.  
  2101. }($,JSZip));