[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> media-utils.js (source)

   1  this["wp"] = this["wp"] || {}; this["wp"]["mediaUtils"] =
   2  /******/ (function(modules) { // webpackBootstrap
   3  /******/     // The module cache
   4  /******/     var installedModules = {};
   5  /******/
   6  /******/     // The require function
   7  /******/ 	function __webpack_require__(moduleId) {
   8  /******/
   9  /******/         // Check if module is in cache
  10  /******/         if(installedModules[moduleId]) {
  11  /******/             return installedModules[moduleId].exports;
  12  /******/         }
  13  /******/         // Create a new module (and put it into the cache)
  14  /******/         var module = installedModules[moduleId] = {
  15  /******/             i: moduleId,
  16  /******/             l: false,
  17  /******/             exports: {}
  18  /******/         };
  19  /******/
  20  /******/         // Execute the module function
  21  /******/         modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22  /******/
  23  /******/         // Flag the module as loaded
  24  /******/         module.l = true;
  25  /******/
  26  /******/         // Return the exports of the module
  27  /******/         return module.exports;
  28  /******/     }
  29  /******/
  30  /******/
  31  /******/     // expose the modules object (__webpack_modules__)
  32  /******/     __webpack_require__.m = modules;
  33  /******/
  34  /******/     // expose the module cache
  35  /******/     __webpack_require__.c = installedModules;
  36  /******/
  37  /******/     // define getter function for harmony exports
  38  /******/     __webpack_require__.d = function(exports, name, getter) {
  39  /******/         if(!__webpack_require__.o(exports, name)) {
  40  /******/             Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41  /******/         }
  42  /******/     };
  43  /******/
  44  /******/     // define __esModule on exports
  45  /******/     __webpack_require__.r = function(exports) {
  46  /******/         if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47  /******/             Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48  /******/         }
  49  /******/         Object.defineProperty(exports, '__esModule', { value: true });
  50  /******/     };
  51  /******/
  52  /******/     // create a fake namespace object
  53  /******/     // mode & 1: value is a module id, require it
  54  /******/     // mode & 2: merge all properties of value into the ns
  55  /******/     // mode & 4: return value when already ns object
  56  /******/     // mode & 8|1: behave like require
  57  /******/     __webpack_require__.t = function(value, mode) {
  58  /******/         if(mode & 1) value = __webpack_require__(value);
  59  /******/         if(mode & 8) return value;
  60  /******/         if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61  /******/         var ns = Object.create(null);
  62  /******/         __webpack_require__.r(ns);
  63  /******/         Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64  /******/         if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65  /******/         return ns;
  66  /******/     };
  67  /******/
  68  /******/     // getDefaultExport function for compatibility with non-harmony modules
  69  /******/     __webpack_require__.n = function(module) {
  70  /******/         var getter = module && module.__esModule ?
  71  /******/ 			function getDefault() { return module['default']; } :
  72  /******/ 			function getModuleExports() { return module; };
  73  /******/         __webpack_require__.d(getter, 'a', getter);
  74  /******/         return getter;
  75  /******/     };
  76  /******/
  77  /******/     // Object.prototype.hasOwnProperty.call
  78  /******/     __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79  /******/
  80  /******/     // __webpack_public_path__
  81  /******/     __webpack_require__.p = "";
  82  /******/
  83  /******/
  84  /******/     // Load entry module and return exports
  85  /******/     return __webpack_require__(__webpack_require__.s = 362);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 0:
  91  /***/ (function(module, exports) {
  92  
  93  (function() { module.exports = this["wp"]["element"]; }());
  94  
  95  /***/ }),
  96  
  97  /***/ 1:
  98  /***/ (function(module, exports) {
  99  
 100  (function() { module.exports = this["wp"]["i18n"]; }());
 101  
 102  /***/ }),
 103  
 104  /***/ 10:
 105  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 106  
 107  "use strict";
 108  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
 109  function _defineProperty(obj, key, value) {
 110    if (key in obj) {
 111      Object.defineProperty(obj, key, {
 112        value: value,
 113        enumerable: true,
 114        configurable: true,
 115        writable: true
 116      });
 117    } else {
 118      obj[key] = value;
 119    }
 120  
 121    return obj;
 122  }
 123  
 124  /***/ }),
 125  
 126  /***/ 11:
 127  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 128  
 129  "use strict";
 130  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
 131  function _defineProperties(target, props) {
 132    for (var i = 0; i < props.length; i++) {
 133      var descriptor = props[i];
 134      descriptor.enumerable = descriptor.enumerable || false;
 135      descriptor.configurable = true;
 136      if ("value" in descriptor) descriptor.writable = true;
 137      Object.defineProperty(target, descriptor.key, descriptor);
 138    }
 139  }
 140  
 141  function _createClass(Constructor, protoProps, staticProps) {
 142    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
 143    if (staticProps) _defineProperties(Constructor, staticProps);
 144    return Constructor;
 145  }
 146  
 147  /***/ }),
 148  
 149  /***/ 12:
 150  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 151  
 152  "use strict";
 153  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
 154  function _classCallCheck(instance, Constructor) {
 155    if (!(instance instanceof Constructor)) {
 156      throw new TypeError("Cannot call a class as a function");
 157    }
 158  }
 159  
 160  /***/ }),
 161  
 162  /***/ 13:
 163  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 164  
 165  "use strict";
 166  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; });
 167  /* harmony import */ var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(31);
 168  /* harmony import */ var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
 169  
 170  
 171  function _possibleConstructorReturn(self, call) {
 172    if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) {
 173      return call;
 174    }
 175  
 176    return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self);
 177  }
 178  
 179  /***/ }),
 180  
 181  /***/ 14:
 182  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 183  
 184  "use strict";
 185  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; });
 186  function _getPrototypeOf(o) {
 187    _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
 188      return o.__proto__ || Object.getPrototypeOf(o);
 189    };
 190    return _getPrototypeOf(o);
 191  }
 192  
 193  /***/ }),
 194  
 195  /***/ 15:
 196  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 197  
 198  "use strict";
 199  
 200  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
 201  function _setPrototypeOf(o, p) {
 202    _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
 203      o.__proto__ = p;
 204      return o;
 205    };
 206  
 207    return _setPrototypeOf(o, p);
 208  }
 209  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
 210  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; });
 211  
 212  function _inherits(subClass, superClass) {
 213    if (typeof superClass !== "function" && superClass !== null) {
 214      throw new TypeError("Super expression must either be null or a function");
 215    }
 216  
 217    subClass.prototype = Object.create(superClass && superClass.prototype, {
 218      constructor: {
 219        value: subClass,
 220        writable: true,
 221        configurable: true
 222      }
 223    });
 224    if (superClass) _setPrototypeOf(subClass, superClass);
 225  }
 226  
 227  /***/ }),
 228  
 229  /***/ 17:
 230  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 231  
 232  "use strict";
 233  
 234  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
 235  function _arrayWithoutHoles(arr) {
 236    if (Array.isArray(arr)) {
 237      for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
 238        arr2[i] = arr[i];
 239      }
 240  
 241      return arr2;
 242    }
 243  }
 244  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
 245  var iterableToArray = __webpack_require__(30);
 246  
 247  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
 248  function _nonIterableSpread() {
 249    throw new TypeError("Invalid attempt to spread non-iterable instance");
 250  }
 251  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
 252  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; });
 253  
 254  
 255  
 256  function _toConsumableArray(arr) {
 257    return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || _nonIterableSpread();
 258  }
 259  
 260  /***/ }),
 261  
 262  /***/ 2:
 263  /***/ (function(module, exports) {
 264  
 265  (function() { module.exports = this["lodash"]; }());
 266  
 267  /***/ }),
 268  
 269  /***/ 20:
 270  /***/ (function(module, exports, __webpack_require__) {
 271  
 272  module.exports = __webpack_require__(47);
 273  
 274  
 275  /***/ }),
 276  
 277  /***/ 23:
 278  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 279  
 280  "use strict";
 281  
 282  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
 283  var arrayWithHoles = __webpack_require__(38);
 284  
 285  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
 286  function _iterableToArrayLimit(arr, i) {
 287    var _arr = [];
 288    var _n = true;
 289    var _d = false;
 290    var _e = undefined;
 291  
 292    try {
 293      for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
 294        _arr.push(_s.value);
 295  
 296        if (i && _arr.length === i) break;
 297      }
 298    } catch (err) {
 299      _d = true;
 300      _e = err;
 301    } finally {
 302      try {
 303        if (!_n && _i["return"] != null) _i["return"]();
 304      } finally {
 305        if (_d) throw _e;
 306      }
 307    }
 308  
 309    return _arr;
 310  }
 311  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
 312  var nonIterableRest = __webpack_require__(39);
 313  
 314  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
 315  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _slicedToArray; });
 316  
 317  
 318  
 319  function _slicedToArray(arr, i) {
 320    return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(nonIterableRest["a" /* default */])();
 321  }
 322  
 323  /***/ }),
 324  
 325  /***/ 30:
 326  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 327  
 328  "use strict";
 329  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
 330  function _iterableToArray(iter) {
 331    if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
 332  }
 333  
 334  /***/ }),
 335  
 336  /***/ 31:
 337  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 338  
 339  "use strict";
 340  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; });
 341  function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
 342  
 343  function _typeof(obj) {
 344    if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
 345      _typeof = function _typeof(obj) {
 346        return _typeof2(obj);
 347      };
 348    } else {
 349      _typeof = function _typeof(obj) {
 350        return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
 351      };
 352    }
 353  
 354    return _typeof(obj);
 355  }
 356  
 357  /***/ }),
 358  
 359  /***/ 34:
 360  /***/ (function(module, exports) {
 361  
 362  (function() { module.exports = this["wp"]["apiFetch"]; }());
 363  
 364  /***/ }),
 365  
 366  /***/ 35:
 367  /***/ (function(module, exports) {
 368  
 369  (function() { module.exports = this["wp"]["blob"]; }());
 370  
 371  /***/ }),
 372  
 373  /***/ 362:
 374  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 375  
 376  "use strict";
 377  __webpack_require__.r(__webpack_exports__);
 378  
 379  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
 380  var classCallCheck = __webpack_require__(12);
 381  
 382  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
 383  var createClass = __webpack_require__(11);
 384  
 385  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
 386  var possibleConstructorReturn = __webpack_require__(13);
 387  
 388  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
 389  var getPrototypeOf = __webpack_require__(14);
 390  
 391  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
 392  var assertThisInitialized = __webpack_require__(5);
 393  
 394  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules
 395  var inherits = __webpack_require__(15);
 396  
 397  // EXTERNAL MODULE: external "lodash"
 398  var external_lodash_ = __webpack_require__(2);
 399  
 400  // EXTERNAL MODULE: external {"this":["wp","element"]}
 401  var external_this_wp_element_ = __webpack_require__(0);
 402  
 403  // EXTERNAL MODULE: external {"this":["wp","i18n"]}
 404  var external_this_wp_i18n_ = __webpack_require__(1);
 405  
 406  // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/components/media-upload/index.js
 407  
 408  
 409  
 410  
 411  
 412  
 413  
 414  /**
 415   * External dependencies
 416   */
 417  
 418  /**
 419   * WordPress dependencies
 420   */
 421  
 422  
 423  
 424  var _window = window,
 425      wp = _window.wp;
 426  
 427  var getFeaturedImageMediaFrame = function getFeaturedImageMediaFrame() {
 428    return wp.media.view.MediaFrame.Select.extend({
 429      /**
 430       * Enables the Set Featured Image Button.
 431       *
 432       * @param {Object} toolbar toolbar for featured image state
 433       * @return {void}
 434       */
 435      featuredImageToolbar: function featuredImageToolbar(toolbar) {
 436        this.createSelectToolbar(toolbar, {
 437          text: wp.media.view.l10n.setFeaturedImage,
 438          state: this.options.state
 439        });
 440      },
 441  
 442      /**
 443       * Create the default states.
 444       *
 445       * @return {void}
 446       */
 447      createStates: function createStates() {
 448        this.on('toolbar:create:featured-image', this.featuredImageToolbar, this);
 449        this.states.add([new wp.media.controller.FeaturedImage()]);
 450      }
 451    });
 452  }; // Getter for the sake of unit tests.
 453  
 454  
 455  var media_upload_getGalleryDetailsMediaFrame = function getGalleryDetailsMediaFrame() {
 456    /**
 457     * Custom gallery details frame.
 458     *
 459     * @see https://github.com/xwp/wp-core-media-widgets/blob/905edbccfc2a623b73a93dac803c5335519d7837/wp-admin/js/widgets/media-gallery-widget.js
 460     * @class GalleryDetailsMediaFrame
 461     * @class
 462     */
 463    return wp.media.view.MediaFrame.Post.extend({
 464      /**
 465       * Create the default states.
 466       *
 467       * @return {void}
 468       */
 469      createStates: function createStates() {
 470        this.states.add([new wp.media.controller.Library({
 471          id: 'gallery',
 472          title: wp.media.view.l10n.createGalleryTitle,
 473          priority: 40,
 474          toolbar: 'main-gallery',
 475          filterable: 'uploaded',
 476          multiple: 'add',
 477          editable: false,
 478          library: wp.media.query(Object(external_lodash_["defaults"])({
 479            type: 'image'
 480          }, this.options.library))
 481        }), new wp.media.controller.GalleryEdit({
 482          library: this.options.selection,
 483          editing: this.options.editing,
 484          menu: 'gallery',
 485          displaySettings: false,
 486          multiple: true
 487        }), new wp.media.controller.GalleryAdd()]);
 488      }
 489    });
 490  }; // the media library image object contains numerous attributes
 491  // we only need this set to display the image in the library
 492  
 493  
 494  var media_upload_slimImageObject = function slimImageObject(img) {
 495    var attrSet = ['sizes', 'mime', 'type', 'subtype', 'id', 'url', 'alt', 'link', 'caption'];
 496    return Object(external_lodash_["pick"])(img, attrSet);
 497  };
 498  
 499  var getAttachmentsCollection = function getAttachmentsCollection(ids) {
 500    return wp.media.query({
 501      order: 'ASC',
 502      orderby: 'post__in',
 503      post__in: ids,
 504      posts_per_page: -1,
 505      query: true,
 506      type: 'image'
 507    });
 508  };
 509  
 510  var media_upload_MediaUpload =
 511  /*#__PURE__*/
 512  function (_Component) {
 513    Object(inherits["a" /* default */])(MediaUpload, _Component);
 514  
 515    function MediaUpload(_ref) {
 516      var _this;
 517  
 518      var allowedTypes = _ref.allowedTypes,
 519          _ref$gallery = _ref.gallery,
 520          gallery = _ref$gallery === void 0 ? false : _ref$gallery,
 521          _ref$unstableFeatured = _ref.unstableFeaturedImageFlow,
 522          unstableFeaturedImageFlow = _ref$unstableFeatured === void 0 ? false : _ref$unstableFeatured,
 523          modalClass = _ref.modalClass,
 524          _ref$multiple = _ref.multiple,
 525          multiple = _ref$multiple === void 0 ? false : _ref$multiple,
 526          _ref$title = _ref.title,
 527          title = _ref$title === void 0 ? Object(external_this_wp_i18n_["__"])('Select or Upload Media') : _ref$title;
 528  
 529      Object(classCallCheck["a" /* default */])(this, MediaUpload);
 530  
 531      _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(MediaUpload).apply(this, arguments));
 532      _this.openModal = _this.openModal.bind(Object(assertThisInitialized["a" /* default */])(_this));
 533      _this.onOpen = _this.onOpen.bind(Object(assertThisInitialized["a" /* default */])(_this));
 534      _this.onSelect = _this.onSelect.bind(Object(assertThisInitialized["a" /* default */])(_this));
 535      _this.onUpdate = _this.onUpdate.bind(Object(assertThisInitialized["a" /* default */])(_this));
 536      _this.onClose = _this.onClose.bind(Object(assertThisInitialized["a" /* default */])(_this));
 537  
 538      if (gallery) {
 539        _this.buildAndSetGalleryFrame();
 540      } else {
 541        var frameConfig = {
 542          title: title,
 543          multiple: multiple
 544        };
 545  
 546        if (!!allowedTypes) {
 547          frameConfig.library = {
 548            type: allowedTypes
 549          };
 550        }
 551  
 552        _this.frame = wp.media(frameConfig);
 553      }
 554  
 555      if (modalClass) {
 556        _this.frame.$el.addClass(modalClass);
 557      }
 558  
 559      if (unstableFeaturedImageFlow) {
 560        _this.buildAndSetFeatureImageFrame();
 561      }
 562  
 563      _this.initializeListeners();
 564  
 565      return _this;
 566    }
 567  
 568    Object(createClass["a" /* default */])(MediaUpload, [{
 569      key: "initializeListeners",
 570      value: function initializeListeners() {
 571        // When an image is selected in the media frame...
 572        this.frame.on('select', this.onSelect);
 573        this.frame.on('update', this.onUpdate);
 574        this.frame.on('open', this.onOpen);
 575        this.frame.on('close', this.onClose);
 576      }
 577    }, {
 578      key: "buildAndSetGalleryFrame",
 579      value: function buildAndSetGalleryFrame() {
 580        var _this$props = this.props,
 581            _this$props$addToGall = _this$props.addToGallery,
 582            addToGallery = _this$props$addToGall === void 0 ? false : _this$props$addToGall,
 583            allowedTypes = _this$props.allowedTypes,
 584            _this$props$multiple = _this$props.multiple,
 585            multiple = _this$props$multiple === void 0 ? false : _this$props$multiple,
 586            _this$props$value = _this$props.value,
 587            value = _this$props$value === void 0 ? null : _this$props$value; // If the value did not changed there is no need to rebuild the frame,
 588        // we can continue to use the existing one.
 589  
 590        if (value === this.lastGalleryValue) {
 591          return;
 592        }
 593  
 594        this.lastGalleryValue = value; // If a frame already existed remove it.
 595  
 596        if (this.frame) {
 597          this.frame.remove();
 598        }
 599  
 600        var currentState;
 601  
 602        if (addToGallery) {
 603          currentState = 'gallery-library';
 604        } else {
 605          currentState = value ? 'gallery-edit' : 'gallery';
 606        }
 607  
 608        if (!this.GalleryDetailsMediaFrame) {
 609          this.GalleryDetailsMediaFrame = media_upload_getGalleryDetailsMediaFrame();
 610        }
 611  
 612        var attachments = getAttachmentsCollection(value);
 613        var selection = new wp.media.model.Selection(attachments.models, {
 614          props: attachments.props.toJSON(),
 615          multiple: multiple
 616        });
 617        this.frame = new this.GalleryDetailsMediaFrame({
 618          mimeType: allowedTypes,
 619          state: currentState,
 620          multiple: multiple,
 621          selection: selection,
 622          editing: value ? true : false
 623        });
 624        wp.media.frame = this.frame;
 625        this.initializeListeners();
 626      }
 627    }, {
 628      key: "buildAndSetFeatureImageFrame",
 629      value: function buildAndSetFeatureImageFrame() {
 630        var featuredImageFrame = getFeaturedImageMediaFrame();
 631        var attachments = getAttachmentsCollection(this.props.value);
 632        var selection = new wp.media.model.Selection(attachments.models, {
 633          props: attachments.props.toJSON()
 634        });
 635        this.frame = new featuredImageFrame({
 636          mimeType: this.props.allowedTypes,
 637          state: 'featured-image',
 638          multiple: this.props.multiple,
 639          selection: selection,
 640          editing: this.props.value ? true : false
 641        });
 642        wp.media.frame = this.frame;
 643      }
 644    }, {
 645      key: "componentWillUnmount",
 646      value: function componentWillUnmount() {
 647        this.frame.remove();
 648      }
 649    }, {
 650      key: "onUpdate",
 651      value: function onUpdate(selections) {
 652        var _this$props2 = this.props,
 653            onSelect = _this$props2.onSelect,
 654            _this$props2$multiple = _this$props2.multiple,
 655            multiple = _this$props2$multiple === void 0 ? false : _this$props2$multiple;
 656        var state = this.frame.state();
 657        var selectedImages = selections || state.get('selection');
 658  
 659        if (!selectedImages || !selectedImages.models.length) {
 660          return;
 661        }
 662  
 663        if (multiple) {
 664          onSelect(selectedImages.models.map(function (model) {
 665            return media_upload_slimImageObject(model.toJSON());
 666          }));
 667        } else {
 668          onSelect(media_upload_slimImageObject(selectedImages.models[0].toJSON()));
 669        }
 670      }
 671    }, {
 672      key: "onSelect",
 673      value: function onSelect() {
 674        var _this$props3 = this.props,
 675            onSelect = _this$props3.onSelect,
 676            _this$props3$multiple = _this$props3.multiple,
 677            multiple = _this$props3$multiple === void 0 ? false : _this$props3$multiple; // Get media attachment details from the frame state
 678  
 679        var attachment = this.frame.state().get('selection').toJSON();
 680        onSelect(multiple ? attachment : attachment[0]);
 681      }
 682    }, {
 683      key: "onOpen",
 684      value: function onOpen() {
 685        this.updateCollection();
 686  
 687        if (!this.props.value) {
 688          return;
 689        }
 690  
 691        if (!this.props.gallery) {
 692          var selection = this.frame.state().get('selection');
 693          Object(external_lodash_["castArray"])(this.props.value).forEach(function (id) {
 694            selection.add(wp.media.attachment(id));
 695          });
 696        } // load the images so they are available in the media modal.
 697  
 698  
 699        getAttachmentsCollection(Object(external_lodash_["castArray"])(this.props.value)).more();
 700      }
 701    }, {
 702      key: "onClose",
 703      value: function onClose() {
 704        var onClose = this.props.onClose;
 705  
 706        if (onClose) {
 707          onClose();
 708        }
 709      }
 710    }, {
 711      key: "updateCollection",
 712      value: function updateCollection() {
 713        var frameContent = this.frame.content.get();
 714  
 715        if (frameContent && frameContent.collection) {
 716          var collection = frameContent.collection; // clean all attachments we have in memory.
 717  
 718          collection.toArray().forEach(function (model) {
 719            return model.trigger('destroy', model);
 720          }); // reset has more flag, if library had small amount of items all items may have been loaded before.
 721  
 722          collection.mirroring._hasMore = true; // request items
 723  
 724          collection.more();
 725        }
 726      }
 727    }, {
 728      key: "openModal",
 729      value: function openModal() {
 730        if (this.props.gallery && this.props.value && this.props.value.length > 0) {
 731          this.buildAndSetGalleryFrame();
 732        }
 733  
 734        this.frame.open();
 735      }
 736    }, {
 737      key: "render",
 738      value: function render() {
 739        return this.props.render({
 740          open: this.openModal
 741        });
 742      }
 743    }]);
 744  
 745    return MediaUpload;
 746  }(external_this_wp_element_["Component"]);
 747  
 748  /* harmony default export */ var media_upload = (media_upload_MediaUpload);
 749  
 750  // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/components/index.js
 751  
 752  
 753  // EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js
 754  var regenerator = __webpack_require__(20);
 755  var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);
 756  
 757  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js
 758  var objectSpread = __webpack_require__(7);
 759  
 760  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
 761  var asyncToGenerator = __webpack_require__(43);
 762  
 763  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
 764  var toConsumableArray = __webpack_require__(17);
 765  
 766  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
 767  var slicedToArray = __webpack_require__(23);
 768  
 769  // EXTERNAL MODULE: external {"this":["wp","apiFetch"]}
 770  var external_this_wp_apiFetch_ = __webpack_require__(34);
 771  var external_this_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_apiFetch_);
 772  
 773  // EXTERNAL MODULE: external {"this":["wp","blob"]}
 774  var external_this_wp_blob_ = __webpack_require__(35);
 775  
 776  // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/utils/upload-media.js
 777  
 778  
 779  
 780  
 781  
 782  
 783  
 784  /**
 785   * External dependencies
 786   */
 787  
 788  /**
 789   * WordPress dependencies
 790   */
 791  
 792  
 793  
 794  
 795  /**
 796   * Browsers may use unexpected mime types, and they differ from browser to browser.
 797   * This function computes a flexible array of mime types from the mime type structured provided by the server.
 798   * Converts { jpg|jpeg|jpe: "image/jpeg" } into [ "image/jpeg", "image/jpg", "image/jpeg", "image/jpe" ]
 799   * The computation of this array instead of directly using the object,
 800   * solves the problem in chrome where mp3 files have audio/mp3 as mime type instead of audio/mpeg.
 801   * https://bugs.chromium.org/p/chromium/issues/detail?id=227004
 802   *
 803   * @param {?Object} wpMimeTypesObject Mime type object received from the server.
 804   *                                    Extensions are keys separated by '|' and values are mime types associated with an extension.
 805   *
 806   * @return {?Array} An array of mime types or the parameter passed if it was "falsy".
 807   */
 808  
 809  function getMimeTypesArray(wpMimeTypesObject) {
 810    if (!wpMimeTypesObject) {
 811      return wpMimeTypesObject;
 812    }
 813  
 814    return Object(external_lodash_["flatMap"])(wpMimeTypesObject, function (mime, extensionsString) {
 815      var _mime$split = mime.split('/'),
 816          _mime$split2 = Object(slicedToArray["a" /* default */])(_mime$split, 1),
 817          type = _mime$split2[0];
 818  
 819      var extensions = extensionsString.split('|');
 820      return [mime].concat(Object(toConsumableArray["a" /* default */])(Object(external_lodash_["map"])(extensions, function (extension) {
 821        return "".concat(type, "/").concat(extension);
 822      })));
 823    });
 824  }
 825  /**
 826   *    Media Upload is used by audio, image, gallery, video, and file blocks to
 827   *    handle uploading a media file when a file upload button is activated.
 828   *
 829   *    TODO: future enhancement to add an upload indicator.
 830   *
 831   * @param   {Object}   $0                    Parameters object passed to the function.
 832   * @param   {?Array}   $0.allowedTypes       Array with the types of media that can be uploaded, if unset all types are allowed.
 833   * @param   {?Object}  $0.additionalData     Additional data to include in the request.
 834   * @param   {Array}    $0.filesList          List of files.
 835   * @param   {?number}  $0.maxUploadFileSize  Maximum upload size in bytes allowed for the site.
 836   * @param   {Function} $0.onError            Function called when an error happens.
 837   * @param   {Function} $0.onFileChange       Function called each time a file or a temporary representation of the file is available.
 838   * @param   {?Object}  $0.wpAllowedMimeTypes List of allowed mime types and file extensions.
 839   */
 840  
 841  function uploadMedia(_x) {
 842    return _uploadMedia.apply(this, arguments);
 843  }
 844  /**
 845   * @param {File}    file           Media File to Save.
 846   * @param {?Object} additionalData Additional data to include in the request.
 847   *
 848   * @return {Promise} Media Object Promise.
 849   */
 850  
 851  function _uploadMedia() {
 852    _uploadMedia = Object(asyncToGenerator["a" /* default */])(
 853    /*#__PURE__*/
 854    regenerator_default.a.mark(function _callee(_ref) {
 855      var allowedTypes, _ref$additionalData, additionalData, filesList, maxUploadFileSize, _ref$onError, onError, onFileChange, _ref$wpAllowedMimeTyp, wpAllowedMimeTypes, files, filesSet, setAndUpdateFiles, isAllowedType, allowedMimeTypesForUser, isAllowedMimeTypeForUser, triggerError, validFiles, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _mediaFile, idx, mediaFile, savedMedia, mediaObject, message;
 856  
 857      return regenerator_default.a.wrap(function _callee$(_context) {
 858        while (1) {
 859          switch (_context.prev = _context.next) {
 860            case 0:
 861              allowedTypes = _ref.allowedTypes, _ref$additionalData = _ref.additionalData, additionalData = _ref$additionalData === void 0 ? {} : _ref$additionalData, filesList = _ref.filesList, maxUploadFileSize = _ref.maxUploadFileSize, _ref$onError = _ref.onError, onError = _ref$onError === void 0 ? external_lodash_["noop"] : _ref$onError, onFileChange = _ref.onFileChange, _ref$wpAllowedMimeTyp = _ref.wpAllowedMimeTypes, wpAllowedMimeTypes = _ref$wpAllowedMimeTyp === void 0 ? null : _ref$wpAllowedMimeTyp;
 862              // Cast filesList to array
 863              files = Object(toConsumableArray["a" /* default */])(filesList);
 864              filesSet = [];
 865  
 866              setAndUpdateFiles = function setAndUpdateFiles(idx, value) {
 867                Object(external_this_wp_blob_["revokeBlobURL"])(Object(external_lodash_["get"])(filesSet, [idx, 'url']));
 868                filesSet[idx] = value;
 869                onFileChange(Object(external_lodash_["compact"])(filesSet));
 870              }; // Allowed type specified by consumer
 871  
 872  
 873              isAllowedType = function isAllowedType(fileType) {
 874                if (!allowedTypes) {
 875                  return true;
 876                }
 877  
 878                return Object(external_lodash_["some"])(allowedTypes, function (allowedType) {
 879                  // If a complete mimetype is specified verify if it matches exactly the mime type of the file.
 880                  if (Object(external_lodash_["includes"])(allowedType, '/')) {
 881                    return allowedType === fileType;
 882                  } // Otherwise a general mime type is used and we should verify if the file mimetype starts with it.
 883  
 884  
 885                  return Object(external_lodash_["startsWith"])(fileType, "".concat(allowedType, "/"));
 886                });
 887              }; // Allowed types for the current WP_User
 888  
 889  
 890              allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes);
 891  
 892              isAllowedMimeTypeForUser = function isAllowedMimeTypeForUser(fileType) {
 893                return Object(external_lodash_["includes"])(allowedMimeTypesForUser, fileType);
 894              }; // Build the error message including the filename
 895  
 896  
 897              triggerError = function triggerError(error) {
 898                error.message = [Object(external_this_wp_element_["createElement"])("strong", {
 899                  key: "filename"
 900                }, error.file.name), ': ', error.message];
 901                onError(error);
 902              };
 903  
 904              validFiles = [];
 905              _iteratorNormalCompletion = true;
 906              _didIteratorError = false;
 907              _iteratorError = undefined;
 908              _context.prev = 12;
 909              _iterator = files[Symbol.iterator]();
 910  
 911            case 14:
 912              if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
 913                _context.next = 34;
 914                break;
 915              }
 916  
 917              _mediaFile = _step.value;
 918  
 919              if (!(allowedMimeTypesForUser && !isAllowedMimeTypeForUser(_mediaFile.type))) {
 920                _context.next = 19;
 921                break;
 922              }
 923  
 924              triggerError({
 925                code: 'MIME_TYPE_NOT_ALLOWED_FOR_USER',
 926                message: Object(external_this_wp_i18n_["__"])('Sorry, this file type is not permitted for security reasons.'),
 927                file: _mediaFile
 928              });
 929              return _context.abrupt("continue", 31);
 930  
 931            case 19:
 932              if (isAllowedType(_mediaFile.type)) {
 933                _context.next = 22;
 934                break;
 935              }
 936  
 937              triggerError({
 938                code: 'MIME_TYPE_NOT_SUPPORTED',
 939                message: Object(external_this_wp_i18n_["__"])('Sorry, this file type is not supported here.'),
 940                file: _mediaFile
 941              });
 942              return _context.abrupt("continue", 31);
 943  
 944            case 22:
 945              if (!(maxUploadFileSize && _mediaFile.size > maxUploadFileSize)) {
 946                _context.next = 25;
 947                break;
 948              }
 949  
 950              triggerError({
 951                code: 'SIZE_ABOVE_LIMIT',
 952                message: Object(external_this_wp_i18n_["__"])('This file exceeds the maximum upload size for this site.'),
 953                file: _mediaFile
 954              });
 955              return _context.abrupt("continue", 31);
 956  
 957            case 25:
 958              if (!(_mediaFile.size <= 0)) {
 959                _context.next = 28;
 960                break;
 961              }
 962  
 963              triggerError({
 964                code: 'EMPTY_FILE',
 965                message: Object(external_this_wp_i18n_["__"])('This file is empty.'),
 966                file: _mediaFile
 967              });
 968              return _context.abrupt("continue", 31);
 969  
 970            case 28:
 971              validFiles.push(_mediaFile); // Set temporary URL to create placeholder media file, this is replaced
 972              // with final file from media gallery when upload is `done` below
 973  
 974              filesSet.push({
 975                url: Object(external_this_wp_blob_["createBlobURL"])(_mediaFile)
 976              });
 977              onFileChange(filesSet);
 978  
 979            case 31:
 980              _iteratorNormalCompletion = true;
 981              _context.next = 14;
 982              break;
 983  
 984            case 34:
 985              _context.next = 40;
 986              break;
 987  
 988            case 36:
 989              _context.prev = 36;
 990              _context.t0 = _context["catch"](12);
 991              _didIteratorError = true;
 992              _iteratorError = _context.t0;
 993  
 994            case 40:
 995              _context.prev = 40;
 996              _context.prev = 41;
 997  
 998              if (!_iteratorNormalCompletion && _iterator.return != null) {
 999                _iterator.return();
1000              }
1001  
1002            case 43:
1003              _context.prev = 43;
1004  
1005              if (!_didIteratorError) {
1006                _context.next = 46;
1007                break;
1008              }
1009  
1010              throw _iteratorError;
1011  
1012            case 46:
1013              return _context.finish(43);
1014  
1015            case 47:
1016              return _context.finish(40);
1017  
1018            case 48:
1019              idx = 0;
1020  
1021            case 49:
1022              if (!(idx < validFiles.length)) {
1023                _context.next = 68;
1024                break;
1025              }
1026  
1027              mediaFile = validFiles[idx];
1028              _context.prev = 51;
1029              _context.next = 54;
1030              return createMediaFromFile(mediaFile, additionalData);
1031  
1032            case 54:
1033              savedMedia = _context.sent;
1034              mediaObject = Object(objectSpread["a" /* default */])({}, Object(external_lodash_["omit"])(savedMedia, ['alt_text', 'source_url']), {
1035                alt: savedMedia.alt_text,
1036                caption: Object(external_lodash_["get"])(savedMedia, ['caption', 'raw'], ''),
1037                title: savedMedia.title.raw,
1038                url: savedMedia.source_url
1039              });
1040              setAndUpdateFiles(idx, mediaObject);
1041              _context.next = 65;
1042              break;
1043  
1044            case 59:
1045              _context.prev = 59;
1046              _context.t1 = _context["catch"](51);
1047              // Reset to empty on failure.
1048              setAndUpdateFiles(idx, null);
1049              message = void 0;
1050  
1051              if (Object(external_lodash_["has"])(_context.t1, ['message'])) {
1052                message = Object(external_lodash_["get"])(_context.t1, ['message']);
1053              } else {
1054                message = Object(external_this_wp_i18n_["sprintf"])( // translators: %s: file name
1055                Object(external_this_wp_i18n_["__"])('Error while uploading file %s to the media library.'), mediaFile.name);
1056              }
1057  
1058              onError({
1059                code: 'GENERAL',
1060                message: message,
1061                file: mediaFile
1062              });
1063  
1064            case 65:
1065              ++idx;
1066              _context.next = 49;
1067              break;
1068  
1069            case 68:
1070            case "end":
1071              return _context.stop();
1072          }
1073        }
1074      }, _callee, null, [[12, 36, 40, 48], [41,, 43, 47], [51, 59]]);
1075    }));
1076    return _uploadMedia.apply(this, arguments);
1077  }
1078  
1079  function createMediaFromFile(file, additionalData) {
1080    // Create upload payload
1081    var data = new window.FormData();
1082    data.append('file', file, file.name || file.type.replace('/', '.'));
1083    Object(external_lodash_["forEach"])(additionalData, function (value, key) {
1084      return data.append(key, value);
1085    });
1086    return external_this_wp_apiFetch_default()({
1087      path: '/wp/v2/media',
1088      body: data,
1089      method: 'POST'
1090    });
1091  }
1092  
1093  // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/utils/index.js
1094  
1095  
1096  // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/index.js
1097  /* concated harmony reexport MediaUpload */__webpack_require__.d(__webpack_exports__, "MediaUpload", function() { return media_upload; });
1098  /* concated harmony reexport uploadMedia */__webpack_require__.d(__webpack_exports__, "uploadMedia", function() { return uploadMedia; });
1099  
1100  
1101  
1102  
1103  /***/ }),
1104  
1105  /***/ 38:
1106  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1107  
1108  "use strict";
1109  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
1110  function _arrayWithHoles(arr) {
1111    if (Array.isArray(arr)) return arr;
1112  }
1113  
1114  /***/ }),
1115  
1116  /***/ 39:
1117  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1118  
1119  "use strict";
1120  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
1121  function _nonIterableRest() {
1122    throw new TypeError("Invalid attempt to destructure non-iterable instance");
1123  }
1124  
1125  /***/ }),
1126  
1127  /***/ 43:
1128  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1129  
1130  "use strict";
1131  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; });
1132  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1133    try {
1134      var info = gen[key](arg);
1135      var value = info.value;
1136    } catch (error) {
1137      reject(error);
1138      return;
1139    }
1140  
1141    if (info.done) {
1142      resolve(value);
1143    } else {
1144      Promise.resolve(value).then(_next, _throw);
1145    }
1146  }
1147  
1148  function _asyncToGenerator(fn) {
1149    return function () {
1150      var self = this,
1151          args = arguments;
1152      return new Promise(function (resolve, reject) {
1153        var gen = fn.apply(self, args);
1154  
1155        function _next(value) {
1156          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1157        }
1158  
1159        function _throw(err) {
1160          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1161        }
1162  
1163        _next(undefined);
1164      });
1165    };
1166  }
1167  
1168  /***/ }),
1169  
1170  /***/ 47:
1171  /***/ (function(module, exports, __webpack_require__) {
1172  
1173  /**
1174   * Copyright (c) 2014-present, Facebook, Inc.
1175   *
1176   * This source code is licensed under the MIT license found in the
1177   * LICENSE file in the root directory of this source tree.
1178   */
1179  
1180  var runtime = (function (exports) {
1181    "use strict";
1182  
1183    var Op = Object.prototype;
1184    var hasOwn = Op.hasOwnProperty;
1185    var undefined; // More compressible than void 0.
1186    var $Symbol = typeof Symbol === "function" ? Symbol : {};
1187    var iteratorSymbol = $Symbol.iterator || "@@iterator";
1188    var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
1189    var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
1190  
1191    function wrap(innerFn, outerFn, self, tryLocsList) {
1192      // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
1193      var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
1194      var generator = Object.create(protoGenerator.prototype);
1195      var context = new Context(tryLocsList || []);
1196  
1197      // The ._invoke method unifies the implementations of the .next,
1198      // .throw, and .return methods.
1199      generator._invoke = makeInvokeMethod(innerFn, self, context);
1200  
1201      return generator;
1202    }
1203    exports.wrap = wrap;
1204  
1205    // Try/catch helper to minimize deoptimizations. Returns a completion
1206    // record like context.tryEntries[i].completion. This interface could
1207    // have been (and was previously) designed to take a closure to be
1208    // invoked without arguments, but in all the cases we care about we
1209    // already have an existing method we want to call, so there's no need
1210    // to create a new function object. We can even get away with assuming
1211    // the method takes exactly one argument, since that happens to be true
1212    // in every case, so we don't have to touch the arguments object. The
1213    // only additional allocation required is the completion record, which
1214    // has a stable shape and so hopefully should be cheap to allocate.
1215    function tryCatch(fn, obj, arg) {
1216      try {
1217        return { type: "normal", arg: fn.call(obj, arg) };
1218      } catch (err) {
1219        return { type: "throw", arg: err };
1220      }
1221    }
1222  
1223    var GenStateSuspendedStart = "suspendedStart";
1224    var GenStateSuspendedYield = "suspendedYield";
1225    var GenStateExecuting = "executing";
1226    var GenStateCompleted = "completed";
1227  
1228    // Returning this object from the innerFn has the same effect as
1229    // breaking out of the dispatch switch statement.
1230    var ContinueSentinel = {};
1231  
1232    // Dummy constructor functions that we use as the .constructor and
1233    // .constructor.prototype properties for functions that return Generator
1234    // objects. For full spec compliance, you may wish to configure your
1235    // minifier not to mangle the names of these two functions.
1236    function Generator() {}
1237    function GeneratorFunction() {}
1238    function GeneratorFunctionPrototype() {}
1239  
1240    // This is a polyfill for %IteratorPrototype% for environments that
1241    // don't natively support it.
1242    var IteratorPrototype = {};
1243    IteratorPrototype[iteratorSymbol] = function () {
1244      return this;
1245    };
1246  
1247    var getProto = Object.getPrototypeOf;
1248    var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
1249    if (NativeIteratorPrototype &&
1250        NativeIteratorPrototype !== Op &&
1251        hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
1252      // This environment has a native %IteratorPrototype%; use it instead
1253      // of the polyfill.
1254      IteratorPrototype = NativeIteratorPrototype;
1255    }
1256  
1257    var Gp = GeneratorFunctionPrototype.prototype =
1258      Generator.prototype = Object.create(IteratorPrototype);
1259    GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
1260    GeneratorFunctionPrototype.constructor = GeneratorFunction;
1261    GeneratorFunctionPrototype[toStringTagSymbol] =
1262      GeneratorFunction.displayName = "GeneratorFunction";
1263  
1264    // Helper for defining the .next, .throw, and .return methods of the
1265    // Iterator interface in terms of a single ._invoke method.
1266    function defineIteratorMethods(prototype) {
1267      ["next", "throw", "return"].forEach(function(method) {
1268        prototype[method] = function(arg) {
1269          return this._invoke(method, arg);
1270        };
1271      });
1272    }
1273  
1274    exports.isGeneratorFunction = function(genFun) {
1275      var ctor = typeof genFun === "function" && genFun.constructor;
1276      return ctor
1277        ? ctor === GeneratorFunction ||
1278          // For the native GeneratorFunction constructor, the best we can
1279          // do is to check its .name property.
1280          (ctor.displayName || ctor.name) === "GeneratorFunction"
1281        : false;
1282    };
1283  
1284    exports.mark = function(genFun) {
1285      if (Object.setPrototypeOf) {
1286        Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
1287      } else {
1288        genFun.__proto__ = GeneratorFunctionPrototype;
1289        if (!(toStringTagSymbol in genFun)) {
1290          genFun[toStringTagSymbol] = "GeneratorFunction";
1291        }
1292      }
1293      genFun.prototype = Object.create(Gp);
1294      return genFun;
1295    };
1296  
1297    // Within the body of any async function, `await x` is transformed to
1298    // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
1299    // `hasOwn.call(value, "__await")` to determine if the yielded value is
1300    // meant to be awaited.
1301    exports.awrap = function(arg) {
1302      return { __await: arg };
1303    };
1304  
1305    function AsyncIterator(generator) {
1306      function invoke(method, arg, resolve, reject) {
1307        var record = tryCatch(generator[method], generator, arg);
1308        if (record.type === "throw") {
1309          reject(record.arg);
1310        } else {
1311          var result = record.arg;
1312          var value = result.value;
1313          if (value &&
1314              typeof value === "object" &&
1315              hasOwn.call(value, "__await")) {
1316            return Promise.resolve(value.__await).then(function(value) {
1317              invoke("next", value, resolve, reject);
1318            }, function(err) {
1319              invoke("throw", err, resolve, reject);
1320            });
1321          }
1322  
1323          return Promise.resolve(value).then(function(unwrapped) {
1324            // When a yielded Promise is resolved, its final value becomes
1325            // the .value of the Promise<{value,done}> result for the
1326            // current iteration.
1327            result.value = unwrapped;
1328            resolve(result);
1329          }, function(error) {
1330            // If a rejected Promise was yielded, throw the rejection back
1331            // into the async generator function so it can be handled there.
1332            return invoke("throw", error, resolve, reject);
1333          });
1334        }
1335      }
1336  
1337      var previousPromise;
1338  
1339      function enqueue(method, arg) {
1340        function callInvokeWithMethodAndArg() {
1341          return new Promise(function(resolve, reject) {
1342            invoke(method, arg, resolve, reject);
1343          });
1344        }
1345  
1346        return previousPromise =
1347          // If enqueue has been called before, then we want to wait until
1348          // all previous Promises have been resolved before calling invoke,
1349          // so that results are always delivered in the correct order. If
1350          // enqueue has not been called before, then it is important to
1351          // call invoke immediately, without waiting on a callback to fire,
1352          // so that the async generator function has the opportunity to do
1353          // any necessary setup in a predictable way. This predictability
1354          // is why the Promise constructor synchronously invokes its
1355          // executor callback, and why async functions synchronously
1356          // execute code before the first await. Since we implement simple
1357          // async functions in terms of async generators, it is especially
1358          // important to get this right, even though it requires care.
1359          previousPromise ? previousPromise.then(
1360            callInvokeWithMethodAndArg,
1361            // Avoid propagating failures to Promises returned by later
1362            // invocations of the iterator.
1363            callInvokeWithMethodAndArg
1364          ) : callInvokeWithMethodAndArg();
1365      }
1366  
1367      // Define the unified helper method that is used to implement .next,
1368      // .throw, and .return (see defineIteratorMethods).
1369      this._invoke = enqueue;
1370    }
1371  
1372    defineIteratorMethods(AsyncIterator.prototype);
1373    AsyncIterator.prototype[asyncIteratorSymbol] = function () {
1374      return this;
1375    };
1376    exports.AsyncIterator = AsyncIterator;
1377  
1378    // Note that simple async functions are implemented on top of
1379    // AsyncIterator objects; they just return a Promise for the value of
1380    // the final result produced by the iterator.
1381    exports.async = function(innerFn, outerFn, self, tryLocsList) {
1382      var iter = new AsyncIterator(
1383        wrap(innerFn, outerFn, self, tryLocsList)
1384      );
1385  
1386      return exports.isGeneratorFunction(outerFn)
1387        ? iter // If outerFn is a generator, return the full iterator.
1388        : iter.next().then(function(result) {
1389            return result.done ? result.value : iter.next();
1390          });
1391    };
1392  
1393    function makeInvokeMethod(innerFn, self, context) {
1394      var state = GenStateSuspendedStart;
1395  
1396      return function invoke(method, arg) {
1397        if (state === GenStateExecuting) {
1398          throw new Error("Generator is already running");
1399        }
1400  
1401        if (state === GenStateCompleted) {
1402          if (method === "throw") {
1403            throw arg;
1404          }
1405  
1406          // Be forgiving, per 25.3.3.3.3 of the spec:
1407          // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
1408          return doneResult();
1409        }
1410  
1411        context.method = method;
1412        context.arg = arg;
1413  
1414        while (true) {
1415          var delegate = context.delegate;
1416          if (delegate) {
1417            var delegateResult = maybeInvokeDelegate(delegate, context);
1418            if (delegateResult) {
1419              if (delegateResult === ContinueSentinel) continue;
1420              return delegateResult;
1421            }
1422          }
1423  
1424          if (context.method === "next") {
1425            // Setting context._sent for legacy support of Babel's
1426            // function.sent implementation.
1427            context.sent = context._sent = context.arg;
1428  
1429          } else if (context.method === "throw") {
1430            if (state === GenStateSuspendedStart) {
1431              state = GenStateCompleted;
1432              throw context.arg;
1433            }
1434  
1435            context.dispatchException(context.arg);
1436  
1437          } else if (context.method === "return") {
1438            context.abrupt("return", context.arg);
1439          }
1440  
1441          state = GenStateExecuting;
1442  
1443          var record = tryCatch(innerFn, self, context);
1444          if (record.type === "normal") {
1445            // If an exception is thrown from innerFn, we leave state ===
1446            // GenStateExecuting and loop back for another invocation.
1447            state = context.done
1448              ? GenStateCompleted
1449              : GenStateSuspendedYield;
1450  
1451            if (record.arg === ContinueSentinel) {
1452              continue;
1453            }
1454  
1455            return {
1456              value: record.arg,
1457              done: context.done
1458            };
1459  
1460          } else if (record.type === "throw") {
1461            state = GenStateCompleted;
1462            // Dispatch the exception by looping back around to the
1463            // context.dispatchException(context.arg) call above.
1464            context.method = "throw";
1465            context.arg = record.arg;
1466          }
1467        }
1468      };
1469    }
1470  
1471    // Call delegate.iterator[context.method](context.arg) and handle the
1472    // result, either by returning a { value, done } result from the
1473    // delegate iterator, or by modifying context.method and context.arg,
1474    // setting context.delegate to null, and returning the ContinueSentinel.
1475    function maybeInvokeDelegate(delegate, context) {
1476      var method = delegate.iterator[context.method];
1477      if (method === undefined) {
1478        // A .throw or .return when the delegate iterator has no .throw
1479        // method always terminates the yield* loop.
1480        context.delegate = null;
1481  
1482        if (context.method === "throw") {
1483          // Note: ["return"] must be used for ES3 parsing compatibility.
1484          if (delegate.iterator["return"]) {
1485            // If the delegate iterator has a return method, give it a
1486            // chance to clean up.
1487            context.method = "return";
1488            context.arg = undefined;
1489            maybeInvokeDelegate(delegate, context);
1490  
1491            if (context.method === "throw") {
1492              // If maybeInvokeDelegate(context) changed context.method from
1493              // "return" to "throw", let that override the TypeError below.
1494              return ContinueSentinel;
1495            }
1496          }
1497  
1498          context.method = "throw";
1499          context.arg = new TypeError(
1500            "The iterator does not provide a 'throw' method");
1501        }
1502  
1503        return ContinueSentinel;
1504      }
1505  
1506      var record = tryCatch(method, delegate.iterator, context.arg);
1507  
1508      if (record.type === "throw") {
1509        context.method = "throw";
1510        context.arg = record.arg;
1511        context.delegate = null;
1512        return ContinueSentinel;
1513      }
1514  
1515      var info = record.arg;
1516  
1517      if (! info) {
1518        context.method = "throw";
1519        context.arg = new TypeError("iterator result is not an object");
1520        context.delegate = null;
1521        return ContinueSentinel;
1522      }
1523  
1524      if (info.done) {
1525        // Assign the result of the finished delegate to the temporary
1526        // variable specified by delegate.resultName (see delegateYield).
1527        context[delegate.resultName] = info.value;
1528  
1529        // Resume execution at the desired location (see delegateYield).
1530        context.next = delegate.nextLoc;
1531  
1532        // If context.method was "throw" but the delegate handled the
1533        // exception, let the outer generator proceed normally. If
1534        // context.method was "next", forget context.arg since it has been
1535        // "consumed" by the delegate iterator. If context.method was
1536        // "return", allow the original .return call to continue in the
1537        // outer generator.
1538        if (context.method !== "return") {
1539          context.method = "next";
1540          context.arg = undefined;
1541        }
1542  
1543      } else {
1544        // Re-yield the result returned by the delegate method.
1545        return info;
1546      }
1547  
1548      // The delegate iterator is finished, so forget it and continue with
1549      // the outer generator.
1550      context.delegate = null;
1551      return ContinueSentinel;
1552    }
1553  
1554    // Define Generator.prototype.{next,throw,return} in terms of the
1555    // unified ._invoke helper method.
1556    defineIteratorMethods(Gp);
1557  
1558    Gp[toStringTagSymbol] = "Generator";
1559  
1560    // A Generator should always return itself as the iterator object when the
1561    // @@iterator function is called on it. Some browsers' implementations of the
1562    // iterator prototype chain incorrectly implement this, causing the Generator
1563    // object to not be returned from this call. This ensures that doesn't happen.
1564    // See https://github.com/facebook/regenerator/issues/274 for more details.
1565    Gp[iteratorSymbol] = function() {
1566      return this;
1567    };
1568  
1569    Gp.toString = function() {
1570      return "[object Generator]";
1571    };
1572  
1573    function pushTryEntry(locs) {
1574      var entry = { tryLoc: locs[0] };
1575  
1576      if (1 in locs) {
1577        entry.catchLoc = locs[1];
1578      }
1579  
1580      if (2 in locs) {
1581        entry.finallyLoc = locs[2];
1582        entry.afterLoc = locs[3];
1583      }
1584  
1585      this.tryEntries.push(entry);
1586    }
1587  
1588    function resetTryEntry(entry) {
1589      var record = entry.completion || {};
1590      record.type = "normal";
1591      delete record.arg;
1592      entry.completion = record;
1593    }
1594  
1595    function Context(tryLocsList) {
1596      // The root entry object (effectively a try statement without a catch
1597      // or a finally block) gives us a place to store values thrown from
1598      // locations where there is no enclosing try statement.
1599      this.tryEntries = [{ tryLoc: "root" }];
1600      tryLocsList.forEach(pushTryEntry, this);
1601      this.reset(true);
1602    }
1603  
1604    exports.keys = function(object) {
1605      var keys = [];
1606      for (var key in object) {
1607        keys.push(key);
1608      }
1609      keys.reverse();
1610  
1611      // Rather than returning an object with a next method, we keep
1612      // things simple and return the next function itself.
1613      return function next() {
1614        while (keys.length) {
1615          var key = keys.pop();
1616          if (key in object) {
1617            next.value = key;
1618            next.done = false;
1619            return next;
1620          }
1621        }
1622  
1623        // To avoid creating an additional object, we just hang the .value
1624        // and .done properties off the next function object itself. This
1625        // also ensures that the minifier will not anonymize the function.
1626        next.done = true;
1627        return next;
1628      };
1629    };
1630  
1631    function values(iterable) {
1632      if (iterable) {
1633        var iteratorMethod = iterable[iteratorSymbol];
1634        if (iteratorMethod) {
1635          return iteratorMethod.call(iterable);
1636        }
1637  
1638        if (typeof iterable.next === "function") {
1639          return iterable;
1640        }
1641  
1642        if (!isNaN(iterable.length)) {
1643          var i = -1, next = function next() {
1644            while (++i < iterable.length) {
1645              if (hasOwn.call(iterable, i)) {
1646                next.value = iterable[i];
1647                next.done = false;
1648                return next;
1649              }
1650            }
1651  
1652            next.value = undefined;
1653            next.done = true;
1654  
1655            return next;
1656          };
1657  
1658          return next.next = next;
1659        }
1660      }
1661  
1662      // Return an iterator with no values.
1663      return { next: doneResult };
1664    }
1665    exports.values = values;
1666  
1667    function doneResult() {
1668      return { value: undefined, done: true };
1669    }
1670  
1671    Context.prototype = {
1672      constructor: Context,
1673  
1674      reset: function(skipTempReset) {
1675        this.prev = 0;
1676        this.next = 0;
1677        // Resetting context._sent for legacy support of Babel's
1678        // function.sent implementation.
1679        this.sent = this._sent = undefined;
1680        this.done = false;
1681        this.delegate = null;
1682  
1683        this.method = "next";
1684        this.arg = undefined;
1685  
1686        this.tryEntries.forEach(resetTryEntry);
1687  
1688        if (!skipTempReset) {
1689          for (var name in this) {
1690            // Not sure about the optimal order of these conditions:
1691            if (name.charAt(0) === "t" &&
1692                hasOwn.call(this, name) &&
1693                !isNaN(+name.slice(1))) {
1694              this[name] = undefined;
1695            }
1696          }
1697        }
1698      },
1699  
1700      stop: function() {
1701        this.done = true;
1702  
1703        var rootEntry = this.tryEntries[0];
1704        var rootRecord = rootEntry.completion;
1705        if (rootRecord.type === "throw") {
1706          throw rootRecord.arg;
1707        }
1708  
1709        return this.rval;
1710      },
1711  
1712      dispatchException: function(exception) {
1713        if (this.done) {
1714          throw exception;
1715        }
1716  
1717        var context = this;
1718        function handle(loc, caught) {
1719          record.type = "throw";
1720          record.arg = exception;
1721          context.next = loc;
1722  
1723          if (caught) {
1724            // If the dispatched exception was caught by a catch block,
1725            // then let that catch block handle the exception normally.
1726            context.method = "next";
1727            context.arg = undefined;
1728          }
1729  
1730          return !! caught;
1731        }
1732  
1733        for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1734          var entry = this.tryEntries[i];
1735          var record = entry.completion;
1736  
1737          if (entry.tryLoc === "root") {
1738            // Exception thrown outside of any try block that could handle
1739            // it, so set the completion value of the entire function to
1740            // throw the exception.
1741            return handle("end");
1742          }
1743  
1744          if (entry.tryLoc <= this.prev) {
1745            var hasCatch = hasOwn.call(entry, "catchLoc");
1746            var hasFinally = hasOwn.call(entry, "finallyLoc");
1747  
1748            if (hasCatch && hasFinally) {
1749              if (this.prev < entry.catchLoc) {
1750                return handle(entry.catchLoc, true);
1751              } else if (this.prev < entry.finallyLoc) {
1752                return handle(entry.finallyLoc);
1753              }
1754  
1755            } else if (hasCatch) {
1756              if (this.prev < entry.catchLoc) {
1757                return handle(entry.catchLoc, true);
1758              }
1759  
1760            } else if (hasFinally) {
1761              if (this.prev < entry.finallyLoc) {
1762                return handle(entry.finallyLoc);
1763              }
1764  
1765            } else {
1766              throw new Error("try statement without catch or finally");
1767            }
1768          }
1769        }
1770      },
1771  
1772      abrupt: function(type, arg) {
1773        for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1774          var entry = this.tryEntries[i];
1775          if (entry.tryLoc <= this.prev &&
1776              hasOwn.call(entry, "finallyLoc") &&
1777              this.prev < entry.finallyLoc) {
1778            var finallyEntry = entry;
1779            break;
1780          }
1781        }
1782  
1783        if (finallyEntry &&
1784            (type === "break" ||
1785             type === "continue") &&
1786            finallyEntry.tryLoc <= arg &&
1787            arg <= finallyEntry.finallyLoc) {
1788          // Ignore the finally entry if control is not jumping to a
1789          // location outside the try/catch block.
1790          finallyEntry = null;
1791        }
1792  
1793        var record = finallyEntry ? finallyEntry.completion : {};
1794        record.type = type;
1795        record.arg = arg;
1796  
1797        if (finallyEntry) {
1798          this.method = "next";
1799          this.next = finallyEntry.finallyLoc;
1800          return ContinueSentinel;
1801        }
1802  
1803        return this.complete(record);
1804      },
1805  
1806      complete: function(record, afterLoc) {
1807        if (record.type === "throw") {
1808          throw record.arg;
1809        }
1810  
1811        if (record.type === "break" ||
1812            record.type === "continue") {
1813          this.next = record.arg;
1814        } else if (record.type === "return") {
1815          this.rval = this.arg = record.arg;
1816          this.method = "return";
1817          this.next = "end";
1818        } else if (record.type === "normal" && afterLoc) {
1819          this.next = afterLoc;
1820        }
1821  
1822        return ContinueSentinel;
1823      },
1824  
1825      finish: function(finallyLoc) {
1826        for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1827          var entry = this.tryEntries[i];
1828          if (entry.finallyLoc === finallyLoc) {
1829            this.complete(entry.completion, entry.afterLoc);
1830            resetTryEntry(entry);
1831            return ContinueSentinel;
1832          }
1833        }
1834      },
1835  
1836      "catch": function(tryLoc) {
1837        for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1838          var entry = this.tryEntries[i];
1839          if (entry.tryLoc === tryLoc) {
1840            var record = entry.completion;
1841            if (record.type === "throw") {
1842              var thrown = record.arg;
1843              resetTryEntry(entry);
1844            }
1845            return thrown;
1846          }
1847        }
1848  
1849        // The context.catch method must only be called with a location
1850        // argument that corresponds to a known catch block.
1851        throw new Error("illegal catch attempt");
1852      },
1853  
1854      delegateYield: function(iterable, resultName, nextLoc) {
1855        this.delegate = {
1856          iterator: values(iterable),
1857          resultName: resultName,
1858          nextLoc: nextLoc
1859        };
1860  
1861        if (this.method === "next") {
1862          // Deliberately forget the last sent value so that we don't
1863          // accidentally pass it on to the delegate.
1864          this.arg = undefined;
1865        }
1866  
1867        return ContinueSentinel;
1868      }
1869    };
1870  
1871    // Regardless of whether this script is executing as a CommonJS module
1872    // or not, return the runtime object so that we can declare the variable
1873    // regeneratorRuntime in the outer scope, which allows this module to be
1874    // injected easily by `bin/regenerator --include-runtime script.js`.
1875    return exports;
1876  
1877  }(
1878    // If this script is executing as a CommonJS module, use module.exports
1879    // as the regeneratorRuntime namespace. Otherwise create a new empty
1880    // object. Either way, the resulting object will be used to initialize
1881    // the regeneratorRuntime variable at the top of this file.
1882     true ? module.exports : undefined
1883  ));
1884  
1885  try {
1886    regeneratorRuntime = runtime;
1887  } catch (accidentalStrictMode) {
1888    // This module should not be running in strict mode, so the above
1889    // assignment should always work unless something is misconfigured. Just
1890    // in case runtime.js accidentally runs in strict mode, we can escape
1891    // strict mode using a global Function call. This could conceivably fail
1892    // if a Content Security Policy forbids using Function, but in that case
1893    // the proper solution is to fix the accidental strict mode problem. If
1894    // you've misconfigured your bundler to force strict mode and applied a
1895    // CSP to forbid Function, and you're not willing to fix either of those
1896    // problems, please detail your unique predicament in a GitHub issue.
1897    Function("r", "regeneratorRuntime = r")(runtime);
1898  }
1899  
1900  
1901  /***/ }),
1902  
1903  /***/ 5:
1904  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1905  
1906  "use strict";
1907  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; });
1908  function _assertThisInitialized(self) {
1909    if (self === void 0) {
1910      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1911    }
1912  
1913    return self;
1914  }
1915  
1916  /***/ }),
1917  
1918  /***/ 7:
1919  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1920  
1921  "use strict";
1922  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; });
1923  /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
1924  
1925  function _objectSpread(target) {
1926    for (var i = 1; i < arguments.length; i++) {
1927      var source = arguments[i] != null ? arguments[i] : {};
1928      var ownKeys = Object.keys(source);
1929  
1930      if (typeof Object.getOwnPropertySymbols === 'function') {
1931        ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
1932          return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1933        }));
1934      }
1935  
1936      ownKeys.forEach(function (key) {
1937        Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]);
1938      });
1939    }
1940  
1941    return target;
1942  }
1943  
1944  /***/ })
1945  
1946  /******/ });


Generated: Mon Nov 18 01:00:04 2019 Cross-referenced by PHPXref 0.7.1