[ 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 = 474);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 0:
  91  /***/ (function(module, exports) {
  92  
  93  (function() { module.exports = window["wp"]["element"]; }());
  94  
  95  /***/ }),
  96  
  97  /***/ 1:
  98  /***/ (function(module, exports) {
  99  
 100  (function() { module.exports = window["wp"]["i18n"]; }());
 101  
 102  /***/ }),
 103  
 104  /***/ 12:
 105  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 106  
 107  "use strict";
 108  
 109  // EXPORTS
 110  __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; });
 111  
 112  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
 113  var arrayWithHoles = __webpack_require__(37);
 114  
 115  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
 116  function _iterableToArrayLimit(arr, i) {
 117    if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
 118    var _arr = [];
 119    var _n = true;
 120    var _d = false;
 121    var _e = undefined;
 122  
 123    try {
 124      for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
 125        _arr.push(_s.value);
 126  
 127        if (i && _arr.length === i) break;
 128      }
 129    } catch (err) {
 130      _d = true;
 131      _e = err;
 132    } finally {
 133      try {
 134        if (!_n && _i["return"] != null) _i["return"]();
 135      } finally {
 136        if (_d) throw _e;
 137      }
 138    }
 139  
 140    return _arr;
 141  }
 142  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
 143  var unsupportedIterableToArray = __webpack_require__(28);
 144  
 145  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
 146  var nonIterableRest = __webpack_require__(38);
 147  
 148  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
 149  
 150  
 151  
 152  
 153  function _slicedToArray(arr, i) {
 154    return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])();
 155  }
 156  
 157  /***/ }),
 158  
 159  /***/ 15:
 160  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 161  
 162  "use strict";
 163  
 164  // EXPORTS
 165  __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; });
 166  
 167  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
 168  var arrayLikeToArray = __webpack_require__(24);
 169  
 170  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
 171  
 172  function _arrayWithoutHoles(arr) {
 173    if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr);
 174  }
 175  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
 176  var iterableToArray = __webpack_require__(39);
 177  
 178  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
 179  var unsupportedIterableToArray = __webpack_require__(28);
 180  
 181  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
 182  function _nonIterableSpread() {
 183    throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
 184  }
 185  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
 186  
 187  
 188  
 189  
 190  function _toConsumableArray(arr) {
 191    return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread();
 192  }
 193  
 194  /***/ }),
 195  
 196  /***/ 16:
 197  /***/ (function(module, exports) {
 198  
 199  (function() { module.exports = window["regeneratorRuntime"]; }());
 200  
 201  /***/ }),
 202  
 203  /***/ 18:
 204  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 205  
 206  "use strict";
 207  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; });
 208  function _assertThisInitialized(self) {
 209    if (self === void 0) {
 210      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
 211    }
 212  
 213    return self;
 214  }
 215  
 216  /***/ }),
 217  
 218  /***/ 2:
 219  /***/ (function(module, exports) {
 220  
 221  (function() { module.exports = window["lodash"]; }());
 222  
 223  /***/ }),
 224  
 225  /***/ 22:
 226  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 227  
 228  "use strict";
 229  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; });
 230  function _getPrototypeOf(o) {
 231    _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
 232      return o.__proto__ || Object.getPrototypeOf(o);
 233    };
 234    return _getPrototypeOf(o);
 235  }
 236  
 237  /***/ }),
 238  
 239  /***/ 24:
 240  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 241  
 242  "use strict";
 243  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
 244  function _arrayLikeToArray(arr, len) {
 245    if (len == null || len > arr.length) len = arr.length;
 246  
 247    for (var i = 0, arr2 = new Array(len); i < len; i++) {
 248      arr2[i] = arr[i];
 249    }
 250  
 251    return arr2;
 252  }
 253  
 254  /***/ }),
 255  
 256  /***/ 25:
 257  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 258  
 259  "use strict";
 260  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
 261  function _classCallCheck(instance, Constructor) {
 262    if (!(instance instanceof Constructor)) {
 263      throw new TypeError("Cannot call a class as a function");
 264    }
 265  }
 266  
 267  /***/ }),
 268  
 269  /***/ 26:
 270  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 271  
 272  "use strict";
 273  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
 274  function _defineProperties(target, props) {
 275    for (var i = 0; i < props.length; i++) {
 276      var descriptor = props[i];
 277      descriptor.enumerable = descriptor.enumerable || false;
 278      descriptor.configurable = true;
 279      if ("value" in descriptor) descriptor.writable = true;
 280      Object.defineProperty(target, descriptor.key, descriptor);
 281    }
 282  }
 283  
 284  function _createClass(Constructor, protoProps, staticProps) {
 285    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
 286    if (staticProps) _defineProperties(Constructor, staticProps);
 287    return Constructor;
 288  }
 289  
 290  /***/ }),
 291  
 292  /***/ 28:
 293  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 294  
 295  "use strict";
 296  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
 297  /* harmony import */ var _arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24);
 298  
 299  function _unsupportedIterableToArray(o, minLen) {
 300    if (!o) return;
 301    if (typeof o === "string") return Object(_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 302    var n = Object.prototype.toString.call(o).slice(8, -1);
 303    if (n === "Object" && o.constructor) n = o.constructor.name;
 304    if (n === "Map" || n === "Set") return Array.from(o);
 305    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 306  }
 307  
 308  /***/ }),
 309  
 310  /***/ 32:
 311  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 312  
 313  "use strict";
 314  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; });
 315  /* harmony import */ var _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(55);
 316  
 317  function _inherits(subClass, superClass) {
 318    if (typeof superClass !== "function" && superClass !== null) {
 319      throw new TypeError("Super expression must either be null or a function");
 320    }
 321  
 322    subClass.prototype = Object.create(superClass && superClass.prototype, {
 323      constructor: {
 324        value: subClass,
 325        writable: true,
 326        configurable: true
 327      }
 328    });
 329    if (superClass) Object(_setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(subClass, superClass);
 330  }
 331  
 332  /***/ }),
 333  
 334  /***/ 34:
 335  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 336  
 337  "use strict";
 338  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; });
 339  /* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(59);
 340  /* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__);
 341  /* harmony import */ var _assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(18);
 342  
 343  
 344  function _possibleConstructorReturn(self, call) {
 345    if (call && (_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default()(call) === "object" || typeof call === "function")) {
 346      return call;
 347    }
 348  
 349    return Object(_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self);
 350  }
 351  
 352  /***/ }),
 353  
 354  /***/ 37:
 355  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 356  
 357  "use strict";
 358  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
 359  function _arrayWithHoles(arr) {
 360    if (Array.isArray(arr)) return arr;
 361  }
 362  
 363  /***/ }),
 364  
 365  /***/ 38:
 366  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 367  
 368  "use strict";
 369  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
 370  function _nonIterableRest() {
 371    throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
 372  }
 373  
 374  /***/ }),
 375  
 376  /***/ 39:
 377  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 378  
 379  "use strict";
 380  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
 381  function _iterableToArray(iter) {
 382    if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
 383  }
 384  
 385  /***/ }),
 386  
 387  /***/ 43:
 388  /***/ (function(module, exports) {
 389  
 390  (function() { module.exports = window["wp"]["blob"]; }());
 391  
 392  /***/ }),
 393  
 394  /***/ 474:
 395  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 396  
 397  "use strict";
 398  // ESM COMPAT FLAG
 399  __webpack_require__.r(__webpack_exports__);
 400  
 401  // EXPORTS
 402  __webpack_require__.d(__webpack_exports__, "MediaUpload", function() { return /* reexport */ media_upload; });
 403  __webpack_require__.d(__webpack_exports__, "uploadMedia", function() { return /* reexport */ uploadMedia; });
 404  
 405  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
 406  var classCallCheck = __webpack_require__(25);
 407  
 408  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
 409  var createClass = __webpack_require__(26);
 410  
 411  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
 412  var assertThisInitialized = __webpack_require__(18);
 413  
 414  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
 415  var inherits = __webpack_require__(32);
 416  
 417  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
 418  var possibleConstructorReturn = __webpack_require__(34);
 419  
 420  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
 421  var getPrototypeOf = __webpack_require__(22);
 422  
 423  // EXTERNAL MODULE: external "lodash"
 424  var external_lodash_ = __webpack_require__(2);
 425  
 426  // EXTERNAL MODULE: external ["wp","element"]
 427  var external_wp_element_ = __webpack_require__(0);
 428  
 429  // EXTERNAL MODULE: external ["wp","i18n"]
 430  var external_wp_i18n_ = __webpack_require__(1);
 431  
 432  // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/components/media-upload/index.js
 433  
 434  
 435  
 436  
 437  
 438  
 439  
 440  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; }
 441  
 442  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
 443  
 444  /**
 445   * External dependencies
 446   */
 447  
 448  /**
 449   * WordPress dependencies
 450   */
 451  
 452  
 453  
 454  var _window = window,
 455      wp = _window.wp;
 456  var DEFAULT_EMPTY_GALLERY = [];
 457  /**
 458   * Prepares the Featured Image toolbars and frames.
 459   *
 460   * @return {wp.media.view.MediaFrame.Select} The default media workflow.
 461   */
 462  
 463  var getFeaturedImageMediaFrame = function getFeaturedImageMediaFrame() {
 464    return wp.media.view.MediaFrame.Select.extend({
 465      /**
 466       * Enables the Set Featured Image Button.
 467       *
 468       * @param {Object} toolbar toolbar for featured image state
 469       * @return {void}
 470       */
 471      featuredImageToolbar: function featuredImageToolbar(toolbar) {
 472        this.createSelectToolbar(toolbar, {
 473          text: wp.media.view.l10n.setFeaturedImage,
 474          state: this.options.state
 475        });
 476      },
 477  
 478      /**
 479       * Handle the edit state requirements of selected media item.
 480       *
 481       * @return {void}
 482       */
 483      editState: function editState() {
 484        var selection = this.state('featured-image').get('selection');
 485        var view = new wp.media.view.EditImage({
 486          model: selection.single(),
 487          controller: this
 488        }).render(); // Set the view to the EditImage frame using the selected image.
 489  
 490        this.content.set(view); // After bringing in the frame, load the actual editor via an ajax call.
 491  
 492        view.loadEditor();
 493      },
 494  
 495      /**
 496       * Create the default states.
 497       *
 498       * @return {void}
 499       */
 500      createStates: function createStates() {
 501        this.on('toolbar:create:featured-image', this.featuredImageToolbar, this);
 502        this.on('content:render:edit-image', this.editState, this);
 503        this.states.add([new wp.media.controller.FeaturedImage(), new wp.media.controller.EditImage({
 504          model: this.options.editImage
 505        })]);
 506      }
 507    });
 508  };
 509  /**
 510   * Prepares the Gallery toolbars and frames.
 511   *
 512   * @return {wp.media.view.MediaFrame.Post} The default media workflow.
 513   */
 514  
 515  
 516  var media_upload_getGalleryDetailsMediaFrame = function getGalleryDetailsMediaFrame() {
 517    /**
 518     * Custom gallery details frame.
 519     *
 520     * @see https://github.com/xwp/wp-core-media-widgets/blob/905edbccfc2a623b73a93dac803c5335519d7837/wp-admin/js/widgets/media-gallery-widget.js
 521     * @class GalleryDetailsMediaFrame
 522     * @class
 523     */
 524    return wp.media.view.MediaFrame.Post.extend({
 525      /**
 526       * Set up gallery toolbar.
 527       *
 528       * @return {void}
 529       */
 530      galleryToolbar: function galleryToolbar() {
 531        var editing = this.state().get('editing');
 532        this.toolbar.set(new wp.media.view.Toolbar({
 533          controller: this,
 534          items: {
 535            insert: {
 536              style: 'primary',
 537              text: editing ? wp.media.view.l10n.updateGallery : wp.media.view.l10n.insertGallery,
 538              priority: 80,
 539              requires: {
 540                library: true
 541              },
 542  
 543              /**
 544               * @fires wp.media.controller.State#update
 545               */
 546              click: function click() {
 547                var controller = this.controller,
 548                    state = controller.state();
 549                controller.close();
 550                state.trigger('update', state.get('library')); // Restore and reset the default state.
 551  
 552                controller.setState(controller.options.state);
 553                controller.reset();
 554              }
 555            }
 556          }
 557        }));
 558      },
 559  
 560      /**
 561       * Handle the edit state requirements of selected media item.
 562       *
 563       * @return {void}
 564       */
 565      editState: function editState() {
 566        var selection = this.state('gallery').get('selection');
 567        var view = new wp.media.view.EditImage({
 568          model: selection.single(),
 569          controller: this
 570        }).render(); // Set the view to the EditImage frame using the selected image.
 571  
 572        this.content.set(view); // After bringing in the frame, load the actual editor via an ajax call.
 573  
 574        view.loadEditor();
 575      },
 576  
 577      /**
 578       * Create the default states.
 579       *
 580       * @return {void}
 581       */
 582      createStates: function createStates() {
 583        this.on('toolbar:create:main-gallery', this.galleryToolbar, this);
 584        this.on('content:render:edit-image', this.editState, this);
 585        this.states.add([new wp.media.controller.Library({
 586          id: 'gallery',
 587          title: wp.media.view.l10n.createGalleryTitle,
 588          priority: 40,
 589          toolbar: 'main-gallery',
 590          filterable: 'uploaded',
 591          multiple: 'add',
 592          editable: false,
 593          library: wp.media.query(Object(external_lodash_["defaults"])({
 594            type: 'image'
 595          }, this.options.library))
 596        }), new wp.media.controller.EditImage({
 597          model: this.options.editImage
 598        }), new wp.media.controller.GalleryEdit({
 599          library: this.options.selection,
 600          editing: this.options.editing,
 601          menu: 'gallery',
 602          displaySettings: false,
 603          multiple: true
 604        }), new wp.media.controller.GalleryAdd()]);
 605      }
 606    });
 607  }; // the media library image object contains numerous attributes
 608  // we only need this set to display the image in the library
 609  
 610  
 611  var media_upload_slimImageObject = function slimImageObject(img) {
 612    var attrSet = ['sizes', 'mime', 'type', 'subtype', 'id', 'url', 'alt', 'link', 'caption'];
 613    return Object(external_lodash_["pick"])(img, attrSet);
 614  };
 615  
 616  var getAttachmentsCollection = function getAttachmentsCollection(ids) {
 617    return wp.media.query({
 618      order: 'ASC',
 619      orderby: 'post__in',
 620      post__in: ids,
 621      posts_per_page: -1,
 622      query: true,
 623      type: 'image'
 624    });
 625  };
 626  
 627  var media_upload_MediaUpload = /*#__PURE__*/function (_Component) {
 628    Object(inherits["a" /* default */])(MediaUpload, _Component);
 629  
 630    var _super = _createSuper(MediaUpload);
 631  
 632    function MediaUpload(_ref) {
 633      var _this;
 634  
 635      var allowedTypes = _ref.allowedTypes,
 636          _ref$gallery = _ref.gallery,
 637          gallery = _ref$gallery === void 0 ? false : _ref$gallery,
 638          _ref$unstableFeatured = _ref.unstableFeaturedImageFlow,
 639          unstableFeaturedImageFlow = _ref$unstableFeatured === void 0 ? false : _ref$unstableFeatured,
 640          modalClass = _ref.modalClass,
 641          _ref$multiple = _ref.multiple,
 642          multiple = _ref$multiple === void 0 ? false : _ref$multiple,
 643          _ref$title = _ref.title,
 644          title = _ref$title === void 0 ? Object(external_wp_i18n_["__"])('Select or Upload Media') : _ref$title;
 645  
 646      Object(classCallCheck["a" /* default */])(this, MediaUpload);
 647  
 648      _this = _super.apply(this, arguments);
 649      _this.openModal = _this.openModal.bind(Object(assertThisInitialized["a" /* default */])(_this));
 650      _this.onOpen = _this.onOpen.bind(Object(assertThisInitialized["a" /* default */])(_this));
 651      _this.onSelect = _this.onSelect.bind(Object(assertThisInitialized["a" /* default */])(_this));
 652      _this.onUpdate = _this.onUpdate.bind(Object(assertThisInitialized["a" /* default */])(_this));
 653      _this.onClose = _this.onClose.bind(Object(assertThisInitialized["a" /* default */])(_this));
 654  
 655      if (gallery) {
 656        _this.buildAndSetGalleryFrame();
 657      } else {
 658        var frameConfig = {
 659          title: title,
 660          multiple: multiple
 661        };
 662  
 663        if (!!allowedTypes) {
 664          frameConfig.library = {
 665            type: allowedTypes
 666          };
 667        }
 668  
 669        _this.frame = wp.media(frameConfig);
 670      }
 671  
 672      if (modalClass) {
 673        _this.frame.$el.addClass(modalClass);
 674      }
 675  
 676      if (unstableFeaturedImageFlow) {
 677        _this.buildAndSetFeatureImageFrame();
 678      }
 679  
 680      _this.initializeListeners();
 681  
 682      return _this;
 683    }
 684  
 685    Object(createClass["a" /* default */])(MediaUpload, [{
 686      key: "initializeListeners",
 687      value: function initializeListeners() {
 688        // When an image is selected in the media frame...
 689        this.frame.on('select', this.onSelect);
 690        this.frame.on('update', this.onUpdate);
 691        this.frame.on('open', this.onOpen);
 692        this.frame.on('close', this.onClose);
 693      }
 694      /**
 695       * Sets the Gallery frame and initializes listeners.
 696       *
 697       * @return {void}
 698       */
 699  
 700    }, {
 701      key: "buildAndSetGalleryFrame",
 702      value: function buildAndSetGalleryFrame() {
 703        var _this$props = this.props,
 704            _this$props$addToGall = _this$props.addToGallery,
 705            addToGallery = _this$props$addToGall === void 0 ? false : _this$props$addToGall,
 706            allowedTypes = _this$props.allowedTypes,
 707            _this$props$multiple = _this$props.multiple,
 708            multiple = _this$props$multiple === void 0 ? false : _this$props$multiple,
 709            _this$props$value = _this$props.value,
 710            value = _this$props$value === void 0 ? DEFAULT_EMPTY_GALLERY : _this$props$value; // If the value did not changed there is no need to rebuild the frame,
 711        // we can continue to use the existing one.
 712  
 713        if (value === this.lastGalleryValue) {
 714          return;
 715        }
 716  
 717        this.lastGalleryValue = value; // If a frame already existed remove it.
 718  
 719        if (this.frame) {
 720          this.frame.remove();
 721        }
 722  
 723        var currentState;
 724  
 725        if (addToGallery) {
 726          currentState = 'gallery-library';
 727        } else {
 728          currentState = value && value.length ? 'gallery-edit' : 'gallery';
 729        }
 730  
 731        if (!this.GalleryDetailsMediaFrame) {
 732          this.GalleryDetailsMediaFrame = media_upload_getGalleryDetailsMediaFrame();
 733        }
 734  
 735        var attachments = getAttachmentsCollection(value);
 736        var selection = new wp.media.model.Selection(attachments.models, {
 737          props: attachments.props.toJSON(),
 738          multiple: multiple
 739        });
 740        this.frame = new this.GalleryDetailsMediaFrame({
 741          mimeType: allowedTypes,
 742          state: currentState,
 743          multiple: multiple,
 744          selection: selection,
 745          editing: value && value.length ? true : false
 746        });
 747        wp.media.frame = this.frame;
 748        this.initializeListeners();
 749      }
 750      /**
 751       * Initializes the Media Library requirements for the featured image flow.
 752       *
 753       * @return {void}
 754       */
 755  
 756    }, {
 757      key: "buildAndSetFeatureImageFrame",
 758      value: function buildAndSetFeatureImageFrame() {
 759        var featuredImageFrame = getFeaturedImageMediaFrame();
 760        var attachments = getAttachmentsCollection(this.props.value);
 761        var selection = new wp.media.model.Selection(attachments.models, {
 762          props: attachments.props.toJSON()
 763        });
 764        this.frame = new featuredImageFrame({
 765          mimeType: this.props.allowedTypes,
 766          state: 'featured-image',
 767          multiple: this.props.multiple,
 768          selection: selection,
 769          editing: this.props.value ? true : false
 770        });
 771        wp.media.frame = this.frame;
 772      }
 773    }, {
 774      key: "componentWillUnmount",
 775      value: function componentWillUnmount() {
 776        this.frame.remove();
 777      }
 778    }, {
 779      key: "onUpdate",
 780      value: function onUpdate(selections) {
 781        var _this$props2 = this.props,
 782            onSelect = _this$props2.onSelect,
 783            _this$props2$multiple = _this$props2.multiple,
 784            multiple = _this$props2$multiple === void 0 ? false : _this$props2$multiple;
 785        var state = this.frame.state();
 786        var selectedImages = selections || state.get('selection');
 787  
 788        if (!selectedImages || !selectedImages.models.length) {
 789          return;
 790        }
 791  
 792        if (multiple) {
 793          onSelect(selectedImages.models.map(function (model) {
 794            return media_upload_slimImageObject(model.toJSON());
 795          }));
 796        } else {
 797          onSelect(media_upload_slimImageObject(selectedImages.models[0].toJSON()));
 798        }
 799      }
 800    }, {
 801      key: "onSelect",
 802      value: function onSelect() {
 803        var _this$props3 = this.props,
 804            onSelect = _this$props3.onSelect,
 805            _this$props3$multiple = _this$props3.multiple,
 806            multiple = _this$props3$multiple === void 0 ? false : _this$props3$multiple; // Get media attachment details from the frame state
 807  
 808        var attachment = this.frame.state().get('selection').toJSON();
 809        onSelect(multiple ? attachment : attachment[0]);
 810      }
 811    }, {
 812      key: "onOpen",
 813      value: function onOpen() {
 814        var _this$props$value2;
 815  
 816        this.updateCollection(); // Handle both this.props.value being either (number[]) multiple ids
 817        // (for galleries) or a (number) singular id (e.g. image block).
 818  
 819        var hasMedia = Array.isArray(this.props.value) ? !!((_this$props$value2 = this.props.value) !== null && _this$props$value2 !== void 0 && _this$props$value2.length) : !!this.props.value;
 820  
 821        if (!hasMedia) {
 822          return;
 823        }
 824  
 825        if (!this.props.gallery) {
 826          var selection = this.frame.state().get('selection');
 827          Object(external_lodash_["castArray"])(this.props.value).forEach(function (id) {
 828            selection.add(wp.media.attachment(id));
 829          });
 830        } // load the images so they are available in the media modal.
 831  
 832  
 833        getAttachmentsCollection(Object(external_lodash_["castArray"])(this.props.value)).more();
 834      }
 835    }, {
 836      key: "onClose",
 837      value: function onClose() {
 838        var onClose = this.props.onClose;
 839  
 840        if (onClose) {
 841          onClose();
 842        }
 843      }
 844    }, {
 845      key: "updateCollection",
 846      value: function updateCollection() {
 847        var frameContent = this.frame.content.get();
 848  
 849        if (frameContent && frameContent.collection) {
 850          var collection = frameContent.collection; // clean all attachments we have in memory.
 851  
 852          collection.toArray().forEach(function (model) {
 853            return model.trigger('destroy', model);
 854          }); // reset has more flag, if library had small amount of items all items may have been loaded before.
 855  
 856          collection.mirroring._hasMore = true; // request items
 857  
 858          collection.more();
 859        }
 860      }
 861    }, {
 862      key: "openModal",
 863      value: function openModal() {
 864        if (this.props.gallery) {
 865          this.buildAndSetGalleryFrame();
 866        }
 867  
 868        this.frame.open();
 869      }
 870    }, {
 871      key: "render",
 872      value: function render() {
 873        return this.props.render({
 874          open: this.openModal
 875        });
 876      }
 877    }]);
 878  
 879    return MediaUpload;
 880  }(external_wp_element_["Component"]);
 881  
 882  /* harmony default export */ var media_upload = (media_upload_MediaUpload);
 883  
 884  // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/components/index.js
 885  
 886  
 887  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
 888  var defineProperty = __webpack_require__(5);
 889  
 890  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
 891  var asyncToGenerator = __webpack_require__(48);
 892  
 893  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
 894  var toConsumableArray = __webpack_require__(15);
 895  
 896  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
 897  var slicedToArray = __webpack_require__(12);
 898  
 899  // EXTERNAL MODULE: external "regeneratorRuntime"
 900  var external_regeneratorRuntime_ = __webpack_require__(16);
 901  var external_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_regeneratorRuntime_);
 902  
 903  // EXTERNAL MODULE: external ["wp","apiFetch"]
 904  var external_wp_apiFetch_ = __webpack_require__(50);
 905  var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_);
 906  
 907  // EXTERNAL MODULE: external ["wp","blob"]
 908  var external_wp_blob_ = __webpack_require__(43);
 909  
 910  // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/utils/upload-media.js
 911  
 912  
 913  
 914  
 915  
 916  
 917  
 918  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
 919  
 920  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
 921  
 922  function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
 923  
 924  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
 925  
 926  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
 927  
 928  /**
 929   * External dependencies
 930   */
 931  
 932  /**
 933   * WordPress dependencies
 934   */
 935  
 936  
 937  
 938  
 939  /**
 940   * Browsers may use unexpected mime types, and they differ from browser to browser.
 941   * This function computes a flexible array of mime types from the mime type structured provided by the server.
 942   * Converts { jpg|jpeg|jpe: "image/jpeg" } into [ "image/jpeg", "image/jpg", "image/jpeg", "image/jpe" ]
 943   * The computation of this array instead of directly using the object,
 944   * solves the problem in chrome where mp3 files have audio/mp3 as mime type instead of audio/mpeg.
 945   * https://bugs.chromium.org/p/chromium/issues/detail?id=227004
 946   *
 947   * @param {?Object} wpMimeTypesObject Mime type object received from the server.
 948   *                                    Extensions are keys separated by '|' and values are mime types associated with an extension.
 949   *
 950   * @return {?Array} An array of mime types or the parameter passed if it was "falsy".
 951   */
 952  
 953  function getMimeTypesArray(wpMimeTypesObject) {
 954    if (!wpMimeTypesObject) {
 955      return wpMimeTypesObject;
 956    }
 957  
 958    return Object(external_lodash_["flatMap"])(wpMimeTypesObject, function (mime, extensionsString) {
 959      var _mime$split = mime.split('/'),
 960          _mime$split2 = Object(slicedToArray["a" /* default */])(_mime$split, 1),
 961          type = _mime$split2[0];
 962  
 963      var extensions = extensionsString.split('|');
 964      return [mime].concat(Object(toConsumableArray["a" /* default */])(Object(external_lodash_["map"])(extensions, function (extension) {
 965        return "".concat(type, "/").concat(extension);
 966      })));
 967    });
 968  }
 969  /**
 970   *    Media Upload is used by audio, image, gallery, video, and file blocks to
 971   *    handle uploading a media file when a file upload button is activated.
 972   *
 973   *    TODO: future enhancement to add an upload indicator.
 974   *
 975   * @param   {Object}   $0                    Parameters object passed to the function.
 976   * @param   {?Array}   $0.allowedTypes       Array with the types of media that can be uploaded, if unset all types are allowed.
 977   * @param   {?Object}  $0.additionalData     Additional data to include in the request.
 978   * @param   {Array}    $0.filesList          List of files.
 979   * @param   {?number}  $0.maxUploadFileSize  Maximum upload size in bytes allowed for the site.
 980   * @param   {Function} $0.onError            Function called when an error happens.
 981   * @param   {Function} $0.onFileChange       Function called each time a file or a temporary representation of the file is available.
 982   * @param   {?Object}  $0.wpAllowedMimeTypes List of allowed mime types and file extensions.
 983   */
 984  
 985  function uploadMedia(_x) {
 986    return _uploadMedia.apply(this, arguments);
 987  }
 988  /**
 989   * @param {File}    file           Media File to Save.
 990   * @param {?Object} additionalData Additional data to include in the request.
 991   *
 992   * @return {Promise} Media Object Promise.
 993   */
 994  
 995  function _uploadMedia() {
 996    _uploadMedia = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee(_ref) {
 997      var allowedTypes, _ref$additionalData, additionalData, filesList, maxUploadFileSize, _ref$onError, onError, onFileChange, _ref$wpAllowedMimeTyp, wpAllowedMimeTypes, files, filesSet, setAndUpdateFiles, isAllowedType, allowedMimeTypesForUser, isAllowedMimeTypeForUser, triggerError, validFiles, _iterator, _step, _mediaFile, idx, mediaFile, savedMedia, mediaObject, message;
 998  
 999      return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
1000        while (1) {
1001          switch (_context.prev = _context.next) {
1002            case 0:
1003              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;
1004              // Cast filesList to array
1005              files = Object(toConsumableArray["a" /* default */])(filesList);
1006              filesSet = [];
1007  
1008              setAndUpdateFiles = function setAndUpdateFiles(idx, value) {
1009                Object(external_wp_blob_["revokeBlobURL"])(Object(external_lodash_["get"])(filesSet, [idx, 'url']));
1010                filesSet[idx] = value;
1011                onFileChange(Object(external_lodash_["compact"])(filesSet));
1012              }; // Allowed type specified by consumer
1013  
1014  
1015              isAllowedType = function isAllowedType(fileType) {
1016                if (!allowedTypes) {
1017                  return true;
1018                }
1019  
1020                return Object(external_lodash_["some"])(allowedTypes, function (allowedType) {
1021                  // If a complete mimetype is specified verify if it matches exactly the mime type of the file.
1022                  if (Object(external_lodash_["includes"])(allowedType, '/')) {
1023                    return allowedType === fileType;
1024                  } // Otherwise a general mime type is used and we should verify if the file mimetype starts with it.
1025  
1026  
1027                  return Object(external_lodash_["startsWith"])(fileType, "".concat(allowedType, "/"));
1028                });
1029              }; // Allowed types for the current WP_User
1030  
1031  
1032              allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes);
1033  
1034              isAllowedMimeTypeForUser = function isAllowedMimeTypeForUser(fileType) {
1035                return Object(external_lodash_["includes"])(allowedMimeTypesForUser, fileType);
1036              }; // Build the error message including the filename
1037  
1038  
1039              triggerError = function triggerError(error) {
1040                error.message = [Object(external_wp_element_["createElement"])("strong", {
1041                  key: "filename"
1042                }, error.file.name), ': ', error.message];
1043                onError(error);
1044              };
1045  
1046              validFiles = [];
1047              _iterator = _createForOfIteratorHelper(files);
1048              _context.prev = 10;
1049  
1050              _iterator.s();
1051  
1052            case 12:
1053              if ((_step = _iterator.n()).done) {
1054                _context.next = 31;
1055                break;
1056              }
1057  
1058              _mediaFile = _step.value;
1059  
1060              if (!(allowedMimeTypesForUser && _mediaFile.type && !isAllowedMimeTypeForUser(_mediaFile.type))) {
1061                _context.next = 17;
1062                break;
1063              }
1064  
1065              triggerError({
1066                code: 'MIME_TYPE_NOT_ALLOWED_FOR_USER',
1067                message: Object(external_wp_i18n_["__"])('Sorry, this file type is not permitted for security reasons.'),
1068                file: _mediaFile
1069              });
1070              return _context.abrupt("continue", 29);
1071  
1072            case 17:
1073              if (!(_mediaFile.type && !isAllowedType(_mediaFile.type))) {
1074                _context.next = 20;
1075                break;
1076              }
1077  
1078              triggerError({
1079                code: 'MIME_TYPE_NOT_SUPPORTED',
1080                message: Object(external_wp_i18n_["__"])('Sorry, this file type is not supported here.'),
1081                file: _mediaFile
1082              });
1083              return _context.abrupt("continue", 29);
1084  
1085            case 20:
1086              if (!(maxUploadFileSize && _mediaFile.size > maxUploadFileSize)) {
1087                _context.next = 23;
1088                break;
1089              }
1090  
1091              triggerError({
1092                code: 'SIZE_ABOVE_LIMIT',
1093                message: Object(external_wp_i18n_["__"])('This file exceeds the maximum upload size for this site.'),
1094                file: _mediaFile
1095              });
1096              return _context.abrupt("continue", 29);
1097  
1098            case 23:
1099              if (!(_mediaFile.size <= 0)) {
1100                _context.next = 26;
1101                break;
1102              }
1103  
1104              triggerError({
1105                code: 'EMPTY_FILE',
1106                message: Object(external_wp_i18n_["__"])('This file is empty.'),
1107                file: _mediaFile
1108              });
1109              return _context.abrupt("continue", 29);
1110  
1111            case 26:
1112              validFiles.push(_mediaFile); // Set temporary URL to create placeholder media file, this is replaced
1113              // with final file from media gallery when upload is `done` below
1114  
1115              filesSet.push({
1116                url: Object(external_wp_blob_["createBlobURL"])(_mediaFile)
1117              });
1118              onFileChange(filesSet);
1119  
1120            case 29:
1121              _context.next = 12;
1122              break;
1123  
1124            case 31:
1125              _context.next = 36;
1126              break;
1127  
1128            case 33:
1129              _context.prev = 33;
1130              _context.t0 = _context["catch"](10);
1131  
1132              _iterator.e(_context.t0);
1133  
1134            case 36:
1135              _context.prev = 36;
1136  
1137              _iterator.f();
1138  
1139              return _context.finish(36);
1140  
1141            case 39:
1142              idx = 0;
1143  
1144            case 40:
1145              if (!(idx < validFiles.length)) {
1146                _context.next = 59;
1147                break;
1148              }
1149  
1150              mediaFile = validFiles[idx];
1151              _context.prev = 42;
1152              _context.next = 45;
1153              return createMediaFromFile(mediaFile, additionalData);
1154  
1155            case 45:
1156              savedMedia = _context.sent;
1157              mediaObject = _objectSpread(_objectSpread({}, Object(external_lodash_["omit"])(savedMedia, ['alt_text', 'source_url'])), {}, {
1158                alt: savedMedia.alt_text,
1159                caption: Object(external_lodash_["get"])(savedMedia, ['caption', 'raw'], ''),
1160                title: savedMedia.title.raw,
1161                url: savedMedia.source_url
1162              });
1163              setAndUpdateFiles(idx, mediaObject);
1164              _context.next = 56;
1165              break;
1166  
1167            case 50:
1168              _context.prev = 50;
1169              _context.t1 = _context["catch"](42);
1170              // Reset to empty on failure.
1171              setAndUpdateFiles(idx, null);
1172              message = void 0;
1173  
1174              if (Object(external_lodash_["has"])(_context.t1, ['message'])) {
1175                message = Object(external_lodash_["get"])(_context.t1, ['message']);
1176              } else {
1177                message = Object(external_wp_i18n_["sprintf"])( // translators: %s: file name
1178                Object(external_wp_i18n_["__"])('Error while uploading file %s to the media library.'), mediaFile.name);
1179              }
1180  
1181              onError({
1182                code: 'GENERAL',
1183                message: message,
1184                file: mediaFile
1185              });
1186  
1187            case 56:
1188              ++idx;
1189              _context.next = 40;
1190              break;
1191  
1192            case 59:
1193            case "end":
1194              return _context.stop();
1195          }
1196        }
1197      }, _callee, null, [[10, 33, 36, 39], [42, 50]]);
1198    }));
1199    return _uploadMedia.apply(this, arguments);
1200  }
1201  
1202  function createMediaFromFile(file, additionalData) {
1203    // Create upload payload
1204    var data = new window.FormData();
1205    data.append('file', file, file.name || file.type.replace('/', '.'));
1206    Object(external_lodash_["forEach"])(additionalData, function (value, key) {
1207      return data.append(key, value);
1208    });
1209    return external_wp_apiFetch_default()({
1210      path: '/wp/v2/media',
1211      body: data,
1212      method: 'POST'
1213    });
1214  }
1215  
1216  // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/utils/index.js
1217  
1218  
1219  // CONCATENATED MODULE: ./node_modules/@wordpress/media-utils/build-module/index.js
1220  
1221  
1222  
1223  
1224  /***/ }),
1225  
1226  /***/ 48:
1227  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1228  
1229  "use strict";
1230  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; });
1231  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1232    try {
1233      var info = gen[key](arg);
1234      var value = info.value;
1235    } catch (error) {
1236      reject(error);
1237      return;
1238    }
1239  
1240    if (info.done) {
1241      resolve(value);
1242    } else {
1243      Promise.resolve(value).then(_next, _throw);
1244    }
1245  }
1246  
1247  function _asyncToGenerator(fn) {
1248    return function () {
1249      var self = this,
1250          args = arguments;
1251      return new Promise(function (resolve, reject) {
1252        var gen = fn.apply(self, args);
1253  
1254        function _next(value) {
1255          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1256        }
1257  
1258        function _throw(err) {
1259          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1260        }
1261  
1262        _next(undefined);
1263      });
1264    };
1265  }
1266  
1267  /***/ }),
1268  
1269  /***/ 5:
1270  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1271  
1272  "use strict";
1273  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
1274  function _defineProperty(obj, key, value) {
1275    if (key in obj) {
1276      Object.defineProperty(obj, key, {
1277        value: value,
1278        enumerable: true,
1279        configurable: true,
1280        writable: true
1281      });
1282    } else {
1283      obj[key] = value;
1284    }
1285  
1286    return obj;
1287  }
1288  
1289  /***/ }),
1290  
1291  /***/ 50:
1292  /***/ (function(module, exports) {
1293  
1294  (function() { module.exports = window["wp"]["apiFetch"]; }());
1295  
1296  /***/ }),
1297  
1298  /***/ 55:
1299  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1300  
1301  "use strict";
1302  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _setPrototypeOf; });
1303  function _setPrototypeOf(o, p) {
1304    _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
1305      o.__proto__ = p;
1306      return o;
1307    };
1308  
1309    return _setPrototypeOf(o, p);
1310  }
1311  
1312  /***/ }),
1313  
1314  /***/ 59:
1315  /***/ (function(module, exports) {
1316  
1317  function _typeof(obj) {
1318    "@babel/helpers - typeof";
1319  
1320    if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
1321      module.exports = _typeof = function _typeof(obj) {
1322        return typeof obj;
1323      };
1324  
1325      module.exports["default"] = module.exports, module.exports.__esModule = true;
1326    } else {
1327      module.exports = _typeof = function _typeof(obj) {
1328        return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1329      };
1330  
1331      module.exports["default"] = module.exports, module.exports.__esModule = true;
1332    }
1333  
1334    return _typeof(obj);
1335  }
1336  
1337  module.exports = _typeof;
1338  module.exports["default"] = module.exports, module.exports.__esModule = true;
1339  
1340  /***/ })
1341  
1342  /******/ });


Generated: Mon Apr 19 01:00:04 2021 Cross-referenced by PHPXref 0.7.1