[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> widgets.js (source)

   1  this["wp"] = this["wp"] || {}; this["wp"]["widgets"] =
   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 = "4g8P");
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ "1ZqX":
  91  /***/ (function(module, exports) {
  92  
  93  (function() { module.exports = window["wp"]["data"]; }());
  94  
  95  /***/ }),
  96  
  97  /***/ "4g8P":
  98  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99  
 100  "use strict";
 101  // ESM COMPAT FLAG
 102  __webpack_require__.r(__webpack_exports__);
 103  
 104  // EXPORTS
 105  __webpack_require__.d(__webpack_exports__, "MoveToWidgetArea", function() { return /* reexport */ MoveToWidgetArea; });
 106  __webpack_require__.d(__webpack_exports__, "getWidgetIdFromBlock", function() { return /* reexport */ getWidgetIdFromBlock; });
 107  __webpack_require__.d(__webpack_exports__, "addWidgetIdToBlock", function() { return /* reexport */ addWidgetIdToBlock; });
 108  __webpack_require__.d(__webpack_exports__, "registerLegacyWidgetBlock", function() { return /* binding */ registerLegacyWidgetBlock; });
 109  __webpack_require__.d(__webpack_exports__, "registerLegacyWidgetVariations", function() { return /* reexport */ registerLegacyWidgetVariations; });
 110  
 111  // NAMESPACE OBJECT: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/index.js
 112  var legacy_widget_namespaceObject = {};
 113  __webpack_require__.r(legacy_widget_namespaceObject);
 114  __webpack_require__.d(legacy_widget_namespaceObject, "metadata", function() { return legacy_widget_metadata; });
 115  __webpack_require__.d(legacy_widget_namespaceObject, "name", function() { return legacy_widget_name; });
 116  __webpack_require__.d(legacy_widget_namespaceObject, "settings", function() { return legacy_widget_settings; });
 117  
 118  // EXTERNAL MODULE: external ["wp","blocks"]
 119  var external_wp_blocks_ = __webpack_require__("HSyU");
 120  
 121  // EXTERNAL MODULE: external ["wp","element"]
 122  var external_wp_element_ = __webpack_require__("GRId");
 123  
 124  // EXTERNAL MODULE: external ["wp","primitives"]
 125  var external_wp_primitives_ = __webpack_require__("Tqx9");
 126  
 127  // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/widget.js
 128  
 129  
 130  /**
 131   * WordPress dependencies
 132   */
 133  
 134  const widget_widget = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
 135    xmlns: "http://www.w3.org/2000/svg",
 136    viewBox: "0 0 24 24"
 137  }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
 138    d: "M6 3H8V5H16V3H18V5C19.1046 5 20 5.89543 20 7V19C20 20.1046 19.1046 21 18 21H6C4.89543 21 4 20.1046 4 19V7C4 5.89543 4.89543 5 6 5V3ZM18 6.5H6C5.72386 6.5 5.5 6.72386 5.5 7V8H18.5V7C18.5 6.72386 18.2761 6.5 18 6.5ZM18.5 9.5H5.5V19C5.5 19.2761 5.72386 19.5 6 19.5H18C18.2761 19.5 18.5 19.2761 18.5 19V9.5ZM11 11H13V13H11V11ZM7 11V13H9V11H7ZM15 13V11H17V13H15Z"
 139  }));
 140  /* harmony default export */ var library_widget = (widget_widget);
 141  
 142  // EXTERNAL MODULE: ./node_modules/classnames/index.js
 143  var classnames = __webpack_require__("TSYQ");
 144  var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
 145  
 146  // EXTERNAL MODULE: external ["wp","blockEditor"]
 147  var external_wp_blockEditor_ = __webpack_require__("axFQ");
 148  
 149  // EXTERNAL MODULE: external ["wp","components"]
 150  var external_wp_components_ = __webpack_require__("tI+e");
 151  
 152  // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/brush.js
 153  
 154  
 155  /**
 156   * WordPress dependencies
 157   */
 158  
 159  const brush = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
 160    xmlns: "http://www.w3.org/2000/svg",
 161    viewBox: "0 0 24 24"
 162  }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
 163    d: "M4 20h8v-1.5H4V20zM18.9 3.5c-.6-.6-1.5-.6-2.1 0l-7.2 7.2c-.4-.1-.7 0-1.1.1-.5.2-1.5.7-1.9 2.2-.4 1.7-.8 2.2-1.1 2.7-.1.1-.2.3-.3.4l-.6 1.1H6c2 0 3.4-.4 4.7-1.4.8-.6 1.2-1.4 1.3-2.3 0-.3 0-.5-.1-.7L19 5.7c.5-.6.5-1.6-.1-2.2zM9.7 14.7c-.7.5-1.5.8-2.4 1 .2-.5.5-1.2.8-2.3.2-.6.4-1 .8-1.1.5-.1 1 .1 1.3.3.2.2.3.5.2.8 0 .3-.1.9-.7 1.3z"
 164  }));
 165  /* harmony default export */ var library_brush = (brush);
 166  
 167  // EXTERNAL MODULE: external ["wp","i18n"]
 168  var external_wp_i18n_ = __webpack_require__("l3Sj");
 169  
 170  // EXTERNAL MODULE: external ["wp","data"]
 171  var external_wp_data_ = __webpack_require__("1ZqX");
 172  
 173  // EXTERNAL MODULE: external ["wp","coreData"]
 174  var external_wp_coreData_ = __webpack_require__("jZUy");
 175  
 176  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/widget-type-selector.js
 177  
 178  
 179  /**
 180   * WordPress dependencies
 181   */
 182  
 183  
 184  
 185  
 186  
 187  function WidgetTypeSelector({
 188    selectedId,
 189    onSelect
 190  }) {
 191    const widgetTypes = Object(external_wp_data_["useSelect"])(select => {
 192      var _select$getSettings$w, _select$getSettings, _select$getWidgetType;
 193  
 194      const hiddenIds = (_select$getSettings$w = (_select$getSettings = select(external_wp_blockEditor_["store"]).getSettings()) === null || _select$getSettings === void 0 ? void 0 : _select$getSettings.widgetTypesToHideFromLegacyWidgetBlock) !== null && _select$getSettings$w !== void 0 ? _select$getSettings$w : [];
 195      return (_select$getWidgetType = select(external_wp_coreData_["store"]).getWidgetTypes({
 196        per_page: -1
 197      })) === null || _select$getWidgetType === void 0 ? void 0 : _select$getWidgetType.filter(widgetType => !hiddenIds.includes(widgetType.id));
 198    }, []);
 199  
 200    if (!widgetTypes) {
 201      return Object(external_wp_element_["createElement"])(external_wp_components_["Spinner"], null);
 202    }
 203  
 204    if (widgetTypes.length === 0) {
 205      return Object(external_wp_i18n_["__"])('There are no widgets available.');
 206    }
 207  
 208    return Object(external_wp_element_["createElement"])(external_wp_components_["SelectControl"], {
 209      label: Object(external_wp_i18n_["__"])('Select a legacy widget to display:'),
 210      value: selectedId !== null && selectedId !== void 0 ? selectedId : '',
 211      options: [{
 212        value: '',
 213        label: Object(external_wp_i18n_["__"])('Select widget')
 214      }, ...widgetTypes.map(widgetType => ({
 215        value: widgetType.id,
 216        label: widgetType.name
 217      }))],
 218      onChange: value => {
 219        if (value) {
 220          const selected = widgetTypes.find(widgetType => widgetType.id === value);
 221          onSelect({
 222            selectedId: selected.id,
 223            isMulti: selected.is_multi
 224          });
 225        } else {
 226          onSelect({
 227            selectedId: null
 228          });
 229        }
 230      }
 231    });
 232  }
 233  
 234  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/inspector-card.js
 235  
 236  function InspectorCard({
 237    name,
 238    description
 239  }) {
 240    return Object(external_wp_element_["createElement"])("div", {
 241      className: "wp-block-legacy-widget-inspector-card"
 242    }, Object(external_wp_element_["createElement"])("h3", {
 243      className: "wp-block-legacy-widget-inspector-card__name"
 244    }, name), Object(external_wp_element_["createElement"])("span", null, description));
 245  }
 246  
 247  // EXTERNAL MODULE: external ["wp","notices"]
 248  var external_wp_notices_ = __webpack_require__("onLe");
 249  
 250  // EXTERNAL MODULE: external ["wp","compose"]
 251  var external_wp_compose_ = __webpack_require__("K9lf");
 252  
 253  // EXTERNAL MODULE: external "lodash"
 254  var external_lodash_ = __webpack_require__("YLtl");
 255  
 256  // EXTERNAL MODULE: external ["wp","apiFetch"]
 257  var external_wp_apiFetch_ = __webpack_require__("ywyh");
 258  var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_);
 259  
 260  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/control.js
 261  /**
 262   * External dependencies
 263   */
 264  
 265  /**
 266   * WordPress dependencies
 267   */
 268  
 269  
 270  
 271  /**
 272   * An API for creating and loading a widget control (a <div class="widget">
 273   * element) that is compatible with most third party widget scripts. By not
 274   * using React for this, we ensure that we have complete contorl over the DOM
 275   * and do not accidentally remove any elements that a third party widget script
 276   * has attached an event listener to.
 277   *
 278   * @property {Element} element The control's DOM element.
 279   */
 280  
 281  class control_Control {
 282    /**
 283     * Creates and loads a new control.
 284     *
 285     * @access public
 286     * @param {Object} params
 287     * @param {string} params.id
 288     * @param {string} params.idBase
 289     * @param {Object} params.instance
 290     * @param {Function} params.onChangeInstance
 291     * @param {Function} params.onChangeHasPreview
 292     * @param {Function} params.onError
 293     */
 294    constructor({
 295      id,
 296      idBase,
 297      instance,
 298      onChangeInstance,
 299      onChangeHasPreview,
 300      onError
 301    }) {
 302      this.id = id;
 303      this.idBase = idBase;
 304      this._instance = instance;
 305      this._hasPreview = null;
 306      this.onChangeInstance = onChangeInstance;
 307      this.onChangeHasPreview = onChangeHasPreview;
 308      this.onError = onError; // We can't use the real widget number as this is calculated by the
 309      // server and we may not ever *actually* save this widget. Instead, use
 310      // a fake but unique number.
 311  
 312      this.number = ++lastNumber;
 313      this.handleFormChange = Object(external_lodash_["debounce"])(this.handleFormChange.bind(this), 200);
 314      this.handleFormSubmit = this.handleFormSubmit.bind(this);
 315      this.initDOM();
 316      this.bindEvents();
 317      this.loadContent();
 318    }
 319    /**
 320     * Clean up the control so that it can be garabge collected.
 321     *
 322     * @access public
 323     */
 324  
 325  
 326    destroy() {
 327      this.unbindEvents();
 328      this.element.remove(); // TODO: How do we make third party widget scripts remove their event
 329      // listeners?
 330    }
 331    /**
 332     * Creates the control's DOM structure.
 333     *
 334     * @access private
 335     */
 336  
 337  
 338    initDOM() {
 339      var _this$id, _this$idBase;
 340  
 341      this.element = el('div', {
 342        class: 'widget open'
 343      }, [el('div', {
 344        class: 'widget-inside'
 345      }, [this.form = el('form', {
 346        class: 'form',
 347        method: 'post'
 348      }, [// These hidden form inputs are what most widgets' scripts
 349      // use to access data about the widget.
 350      el('input', {
 351        class: 'widget-id',
 352        type: 'hidden',
 353        name: 'widget-id',
 354        value: (_this$id = this.id) !== null && _this$id !== void 0 ? _this$id : `$this.idBase}-$this.number}`
 355      }), el('input', {
 356        class: 'id_base',
 357        type: 'hidden',
 358        name: 'id_base',
 359        value: (_this$idBase = this.idBase) !== null && _this$idBase !== void 0 ? _this$idBase : this.id
 360      }), el('input', {
 361        class: 'widget-width',
 362        type: 'hidden',
 363        name: 'widget-width',
 364        value: '250'
 365      }), el('input', {
 366        class: 'widget-height',
 367        type: 'hidden',
 368        name: 'widget-height',
 369        value: '200'
 370      }), el('input', {
 371        class: 'widget_number',
 372        type: 'hidden',
 373        name: 'widget_number',
 374        value: this.idBase ? this.number.toString() : ''
 375      }), this.content = el('div', {
 376        class: 'widget-content'
 377      }), // Non-multi widgets can be saved via a Save button.
 378      this.id && el('button', {
 379        class: 'button is-primary',
 380        type: 'submit'
 381      }, Object(external_wp_i18n_["__"])('Save'))])])]);
 382    }
 383    /**
 384     * Adds the control's event listeners.
 385     *
 386     * @access private
 387     */
 388  
 389  
 390    bindEvents() {
 391      // Prefer jQuery 'change' event instead of the native 'change' event
 392      // because many widgets use jQuery's event bus to trigger an update.
 393      if (window.jQuery) {
 394        const {
 395          jQuery: $
 396        } = window;
 397        $(this.form).on('change', null, this.handleFormChange);
 398        $(this.form).on('input', null, this.handleFormChange);
 399        $(this.form).on('submit', this.handleFormSubmit);
 400      } else {
 401        this.form.addEventListener('change', this.handleFormChange);
 402        this.form.addEventListener('input', this.handleFormChange);
 403        this.form.addEventListener('submit', this.handleFormSubmit);
 404      }
 405    }
 406    /**
 407     * Removes the control's event listeners.
 408     *
 409     * @access private
 410     */
 411  
 412  
 413    unbindEvents() {
 414      if (window.jQuery) {
 415        const {
 416          jQuery: $
 417        } = window;
 418        $(this.form).off('change', null, this.handleFormChange);
 419        $(this.form).off('input', null, this.handleFormChange);
 420        $(this.form).off('submit', this.handleFormSubmit);
 421      } else {
 422        this.form.removeEventListener('change', this.handleFormChange);
 423        this.form.removeEventListener('input', this.handleFormChange);
 424        this.form.removeEventListener('submit', this.handleFormSubmit);
 425      }
 426    }
 427    /**
 428     * Fetches the widget's form HTML from the REST API and loads it into the
 429     * control's form.
 430     *
 431     * @access private
 432     */
 433  
 434  
 435    async loadContent() {
 436      try {
 437        if (this.id) {
 438          const {
 439            form
 440          } = await saveWidget(this.id);
 441          this.content.innerHTML = form;
 442        } else if (this.idBase) {
 443          const {
 444            form,
 445            preview
 446          } = await encodeWidget({
 447            idBase: this.idBase,
 448            instance: this.instance,
 449            number: this.number
 450          });
 451          this.content.innerHTML = form;
 452          this.hasPreview = !isEmptyHTML(preview); // If we don't have an instance, perform a save right away. This
 453          // happens when creating a new Legacy Widget block.
 454  
 455          if (!this.instance.hash) {
 456            const {
 457              instance
 458            } = await encodeWidget({
 459              idBase: this.idBase,
 460              instance: this.instance,
 461              number: this.number,
 462              formData: serializeForm(this.form)
 463            });
 464            this.instance = instance;
 465          }
 466        } // Trigger 'widget-added' when widget is ready. This event is what
 467        // widgets' scripts use to initialize, attach events, etc. The event
 468        // must be fired using jQuery's event bus as this is what widget
 469        // scripts expect. If jQuery is not loaded, do nothing - some
 470        // widgets will still work regardless.
 471  
 472  
 473        if (window.jQuery) {
 474          const {
 475            jQuery: $
 476          } = window;
 477          $(document).trigger('widget-added', [$(this.element)]);
 478        }
 479      } catch (error) {
 480        this.onError(error);
 481      }
 482    }
 483    /**
 484     * Perform a save when a multi widget's form is changed. Non-multi widgets
 485     * are saved manually.
 486     *
 487     * @access private
 488     */
 489  
 490  
 491    handleFormChange() {
 492      if (this.idBase) {
 493        this.saveForm();
 494      }
 495    }
 496    /**
 497     * Perform a save when the control's form is manually submitted.
 498     *
 499     * @access private
 500     * @param {Event} event
 501     */
 502  
 503  
 504    handleFormSubmit(event) {
 505      event.preventDefault();
 506      this.saveForm();
 507    }
 508    /**
 509     * Serialize the control's form, send it to the REST API, and update the
 510     * instance with the encoded instance that the REST API returns.
 511     *
 512     * @access private
 513     */
 514  
 515  
 516    async saveForm() {
 517      const formData = serializeForm(this.form);
 518  
 519      try {
 520        if (this.id) {
 521          const {
 522            form
 523          } = await saveWidget(this.id, formData);
 524          this.content.innerHTML = form;
 525  
 526          if (window.jQuery) {
 527            const {
 528              jQuery: $
 529            } = window;
 530            $(document).trigger('widget-updated', [$(this.element)]);
 531          }
 532        } else if (this.idBase) {
 533          const {
 534            instance,
 535            preview
 536          } = await encodeWidget({
 537            idBase: this.idBase,
 538            instance: this.instance,
 539            number: this.number,
 540            formData
 541          });
 542          this.instance = instance;
 543          this.hasPreview = !isEmptyHTML(preview);
 544        }
 545      } catch (error) {
 546        this.onError(error);
 547      }
 548    }
 549    /**
 550     * The widget's instance object.
 551     *
 552     * @access private
 553     */
 554  
 555  
 556    get instance() {
 557      return this._instance;
 558    }
 559    /**
 560     * The widget's instance object.
 561     *
 562     * @access private
 563     */
 564  
 565  
 566    set instance(instance) {
 567      if (this._instance !== instance) {
 568        this._instance = instance;
 569        this.onChangeInstance(instance);
 570      }
 571    }
 572    /**
 573     * Whether or not the widget can be previewed.
 574     *
 575     * @access public
 576     */
 577  
 578  
 579    get hasPreview() {
 580      return this._hasPreview;
 581    }
 582    /**
 583     * Whether or not the widget can be previewed.
 584     *
 585     * @access private
 586     */
 587  
 588  
 589    set hasPreview(hasPreview) {
 590      if (this._hasPreview !== hasPreview) {
 591        this._hasPreview = hasPreview;
 592        this.onChangeHasPreview(hasPreview);
 593      }
 594    }
 595  
 596  }
 597  let lastNumber = 0;
 598  
 599  function el(tagName, attributes = {}, content = null) {
 600    const element = document.createElement(tagName);
 601  
 602    for (const [attribute, value] of Object.entries(attributes)) {
 603      element.setAttribute(attribute, value);
 604    }
 605  
 606    if (Array.isArray(content)) {
 607      for (const child of content) {
 608        if (child) {
 609          element.appendChild(child);
 610        }
 611      }
 612    } else if (typeof content === 'string') {
 613      element.innerText = content;
 614    }
 615  
 616    return element;
 617  }
 618  
 619  async function saveWidget(id, formData = null) {
 620    let widget;
 621  
 622    if (formData) {
 623      widget = await external_wp_apiFetch_default()({
 624        path: `/wp/v2/widgets/$id}?context=edit`,
 625        method: 'PUT',
 626        data: {
 627          form_data: formData
 628        }
 629      });
 630    } else {
 631      widget = await external_wp_apiFetch_default()({
 632        path: `/wp/v2/widgets/$id}?context=edit`,
 633        method: 'GET'
 634      });
 635    }
 636  
 637    return {
 638      form: widget.rendered_form
 639    };
 640  }
 641  
 642  async function encodeWidget({
 643    idBase,
 644    instance,
 645    number,
 646    formData = null
 647  }) {
 648    const response = await external_wp_apiFetch_default()({
 649      path: `/wp/v2/widget-types/$idBase}/encode`,
 650      method: 'POST',
 651      data: {
 652        instance,
 653        number,
 654        form_data: formData
 655      }
 656    });
 657    return {
 658      instance: response.instance,
 659      form: response.form,
 660      preview: response.preview
 661    };
 662  }
 663  
 664  function isEmptyHTML(html) {
 665    const element = document.createElement('div');
 666    element.innerHTML = html;
 667    return isEmptyNode(element);
 668  }
 669  
 670  function isEmptyNode(node) {
 671    switch (node.nodeType) {
 672      case node.TEXT_NODE:
 673        // Text nodes are empty if it's entirely whitespace.
 674        return node.nodeValue.trim() === '';
 675  
 676      case node.ELEMENT_NODE:
 677        // Elements that are "embedded content" are not empty.
 678        // https://dev.w3.org/html5/spec-LC/content-models.html#embedded-content-0
 679        if (['AUDIO', 'CANVAS', 'EMBED', 'IFRAME', 'IMG', 'MATH', 'OBJECT', 'SVG', 'VIDEO'].includes(node.tagName)) {
 680          return false;
 681        } // Elements with no children are empty.
 682  
 683  
 684        if (!node.hasChildNodes()) {
 685          return true;
 686        } // Elements with children are empty if all their children are empty.
 687  
 688  
 689        return Array.from(node.childNodes).every(isEmptyNode);
 690  
 691      default:
 692        return true;
 693    }
 694  }
 695  
 696  function serializeForm(form) {
 697    return new window.URLSearchParams(Array.from(new window.FormData(form))).toString();
 698  }
 699  
 700  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/form.js
 701  
 702  
 703  /**
 704   * External dependencies
 705   */
 706  
 707  /**
 708   * WordPress dependencies
 709   */
 710  
 711  
 712  
 713  
 714  
 715  
 716  
 717  /**
 718   * Internal dependencies
 719   */
 720  
 721  
 722  function Form({
 723    title,
 724    isVisible,
 725    id,
 726    idBase,
 727    instance,
 728    isWide,
 729    onChangeInstance,
 730    onChangeHasPreview
 731  }) {
 732    const ref = Object(external_wp_element_["useRef"])();
 733    const isMediumLargeViewport = Object(external_wp_compose_["useViewportMatch"])('small'); // We only want to remount the control when the instance changes
 734    // *externally*. For example, if the user performs an undo. To do this, we
 735    // keep track of changes made to instance by the control itself and then
 736    // ignore those.
 737  
 738    const outgoingInstances = Object(external_wp_element_["useRef"])(new Set());
 739    const incomingInstances = Object(external_wp_element_["useRef"])(new Set());
 740    const {
 741      createNotice
 742    } = Object(external_wp_data_["useDispatch"])(external_wp_notices_["store"]);
 743    Object(external_wp_element_["useEffect"])(() => {
 744      if (incomingInstances.current.has(instance)) {
 745        incomingInstances.current.delete(instance);
 746        return;
 747      }
 748  
 749      const control = new control_Control({
 750        id,
 751        idBase,
 752        instance,
 753  
 754        onChangeInstance(nextInstance) {
 755          outgoingInstances.current.add(instance);
 756          incomingInstances.current.add(nextInstance);
 757          onChangeInstance(nextInstance);
 758        },
 759  
 760        onChangeHasPreview,
 761  
 762        onError(error) {
 763          window.console.error(error);
 764          createNotice('error', Object(external_wp_i18n_["sprintf"])(
 765          /* translators: %s: the name of the affected block. */
 766          Object(external_wp_i18n_["__"])('The "%s" block was affected by errors and may not function properly. Check the developer tools for more details.'), idBase || id));
 767        }
 768  
 769      });
 770      ref.current.appendChild(control.element);
 771      return () => {
 772        if (outgoingInstances.current.has(instance)) {
 773          outgoingInstances.current.delete(instance);
 774          return;
 775        }
 776  
 777        control.destroy();
 778      };
 779    }, [id, idBase, instance, onChangeInstance, onChangeHasPreview, isMediumLargeViewport]);
 780  
 781    if (isWide && isMediumLargeViewport) {
 782      return Object(external_wp_element_["createElement"])("div", {
 783        className: classnames_default()({
 784          'wp-block-legacy-widget__container': isVisible
 785        })
 786      }, isVisible && Object(external_wp_element_["createElement"])("h3", {
 787        className: "wp-block-legacy-widget__edit-form-title"
 788      }, title), Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
 789        focusOnMount: false,
 790        position: "middle right",
 791        __unstableForceXAlignment: true
 792      }, Object(external_wp_element_["createElement"])("div", {
 793        ref: ref,
 794        className: "wp-block-legacy-widget__edit-form",
 795        hidden: !isVisible
 796      })));
 797    }
 798  
 799    return Object(external_wp_element_["createElement"])("div", {
 800      ref: ref,
 801      className: "wp-block-legacy-widget__edit-form",
 802      hidden: !isVisible
 803    }, Object(external_wp_element_["createElement"])("h3", {
 804      className: "wp-block-legacy-widget__edit-form-title"
 805    }, title));
 806  }
 807  
 808  // EXTERNAL MODULE: external ["wp","url"]
 809  var external_wp_url_ = __webpack_require__("Mmq9");
 810  
 811  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/preview.js
 812  
 813  
 814  /**
 815   * External dependencies
 816   */
 817  
 818  /**
 819   * WordPress dependencies
 820   */
 821  
 822  
 823  
 824  
 825  
 826  
 827  function Preview({
 828    idBase,
 829    instance,
 830    isVisible
 831  }) {
 832    const [isLoaded, setIsLoaded] = Object(external_wp_element_["useState"])(false); // Resize the iframe on either the load event, or when the iframe becomes visible.
 833  
 834    const ref = Object(external_wp_compose_["useRefEffect"])(iframe => {
 835      // Only set height if the iframe is loaded,
 836      // or it will grow to an unexpected large height in Safari if it's hidden initially.
 837      if (isLoaded) {
 838        // If the preview frame has another origin then this won't work.
 839        // One possible solution is to add custom script to call `postMessage` in the preview frame.
 840        // Or, better yet, we migrate away from iframe.
 841        function setHeight() {
 842          // Pick the maximum of these two values to account for margin collapsing.
 843          const height = Math.max(iframe.contentDocument.documentElement.offsetHeight, iframe.contentDocument.body.offsetHeight);
 844          iframe.style.height = `$height}px`;
 845        }
 846  
 847        const {
 848          IntersectionObserver
 849        } = iframe.ownerDocument.defaultView; // Observe for intersections that might cause a change in the height of
 850        // the iframe, e.g. a Widget Area becoming expanded.
 851  
 852        const intersectionObserver = new IntersectionObserver(([entry]) => {
 853          if (entry.isIntersecting) {
 854            setHeight();
 855          }
 856        }, {
 857          threshold: 1
 858        });
 859        intersectionObserver.observe(iframe);
 860        iframe.addEventListener('load', setHeight);
 861        return () => {
 862          intersectionObserver.disconnect();
 863          iframe.removeEventListener('load', setHeight);
 864        };
 865      }
 866    }, [isLoaded]);
 867    return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, isVisible && !isLoaded && Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Spinner"], null)), Object(external_wp_element_["createElement"])("div", {
 868      className: classnames_default()('wp-block-legacy-widget__edit-preview', {
 869        'is-offscreen': !isVisible || !isLoaded
 870      })
 871    }, Object(external_wp_element_["createElement"])(external_wp_components_["Disabled"], null, Object(external_wp_element_["createElement"])("iframe", {
 872      ref: ref,
 873      className: "wp-block-legacy-widget__edit-preview-iframe",
 874      title: Object(external_wp_i18n_["__"])('Legacy Widget Preview') // TODO: This chokes when the query param is too big.
 875      // Ideally, we'd render a <ServerSideRender>. Maybe by
 876      // rendering one in an iframe via a portal.
 877      ,
 878      src: Object(external_wp_url_["addQueryArgs"])('widgets.php', {
 879        'legacy-widget-preview': {
 880          idBase,
 881          instance
 882        }
 883      }),
 884      onLoad: event => {
 885        // To hide the scrollbars of the preview frame for some edge cases,
 886        // such as negative margins in the Gallery Legacy Widget.
 887        // It can't be scrolled anyway.
 888        // TODO: Ideally, this should be fixed in core.
 889        event.target.contentDocument.body.style.overflow = 'hidden';
 890        setIsLoaded(true);
 891      },
 892      height: 100
 893    }))));
 894  }
 895  
 896  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/no-preview.js
 897  
 898  
 899  /**
 900   * WordPress dependencies
 901   */
 902  
 903  function NoPreview({
 904    name
 905  }) {
 906    return Object(external_wp_element_["createElement"])("div", {
 907      className: "wp-block-legacy-widget__edit-no-preview"
 908    }, name && Object(external_wp_element_["createElement"])("h3", null, name), Object(external_wp_element_["createElement"])("p", null, Object(external_wp_i18n_["__"])('No preview available.')));
 909  }
 910  
 911  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/convert-to-blocks-button.js
 912  
 913  
 914  /**
 915   * WordPress dependencies
 916   */
 917  
 918  
 919  
 920  
 921  
 922  function ConvertToBlocksButton({
 923    clientId,
 924    rawInstance
 925  }) {
 926    const {
 927      replaceBlocks
 928    } = Object(external_wp_data_["useDispatch"])(external_wp_blockEditor_["store"]);
 929    return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
 930      onClick: () => {
 931        if (rawInstance.title) {
 932          replaceBlocks(clientId, [Object(external_wp_blocks_["createBlock"])('core/heading', {
 933            content: rawInstance.title
 934          }), ...Object(external_wp_blocks_["rawHandler"])({
 935            HTML: rawInstance.text
 936          })]);
 937        } else {
 938          replaceBlocks(clientId, Object(external_wp_blocks_["rawHandler"])({
 939            HTML: rawInstance.text
 940          }));
 941        }
 942      }
 943    }, Object(external_wp_i18n_["__"])('Convert to blocks'));
 944  }
 945  
 946  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/index.js
 947  
 948  
 949  /**
 950   * External dependencies
 951   */
 952  
 953  /**
 954   * WordPress dependencies
 955   */
 956  
 957  
 958  
 959  
 960  
 961  
 962  
 963  
 964  /**
 965   * Internal dependencies
 966   */
 967  
 968  
 969  
 970  
 971  
 972  
 973  
 974  function Edit(props) {
 975    const {
 976      id,
 977      idBase
 978    } = props.attributes;
 979    const {
 980      isWide = false
 981    } = props;
 982    const blockProps = Object(external_wp_blockEditor_["useBlockProps"])({
 983      className: classnames_default()({
 984        'is-wide-widget': isWide
 985      })
 986    });
 987    return Object(external_wp_element_["createElement"])("div", blockProps, !id && !idBase ? Object(external_wp_element_["createElement"])(Empty, props) : Object(external_wp_element_["createElement"])(NotEmpty, props));
 988  }
 989  
 990  function Empty({
 991    attributes: {
 992      id,
 993      idBase
 994    },
 995    setAttributes
 996  }) {
 997    return Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], {
 998      icon: Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockIcon"], {
 999        icon: library_brush
1000      }),
1001      label: Object(external_wp_i18n_["__"])('Legacy Widget')
1002    }, Object(external_wp_element_["createElement"])(WidgetTypeSelector, {
1003      selectedId: id !== null && id !== void 0 ? id : idBase,
1004      onSelect: ({
1005        selectedId,
1006        isMulti
1007      }) => {
1008        if (!selectedId) {
1009          setAttributes({
1010            id: null,
1011            idBase: null,
1012            instance: null
1013          });
1014        } else if (isMulti) {
1015          setAttributes({
1016            id: null,
1017            idBase: selectedId,
1018            instance: {}
1019          });
1020        } else {
1021          setAttributes({
1022            id: selectedId,
1023            idBase: null,
1024            instance: null
1025          });
1026        }
1027      }
1028    }));
1029  }
1030  
1031  function NotEmpty({
1032    attributes: {
1033      id,
1034      idBase,
1035      instance
1036    },
1037    setAttributes,
1038    clientId,
1039    isSelected,
1040    isWide = false
1041  }) {
1042    const [hasPreview, setHasPreview] = Object(external_wp_element_["useState"])(null);
1043    const {
1044      widgetType,
1045      hasResolvedWidgetType,
1046      isNavigationMode
1047    } = Object(external_wp_data_["useSelect"])(select => {
1048      const widgetTypeId = id !== null && id !== void 0 ? id : idBase;
1049      return {
1050        widgetType: select(external_wp_coreData_["store"]).getWidgetType(widgetTypeId),
1051        hasResolvedWidgetType: select(external_wp_coreData_["store"]).hasFinishedResolution('getWidgetType', [widgetTypeId]),
1052        isNavigationMode: select(external_wp_blockEditor_["store"]).isNavigationMode()
1053      };
1054    }, [id, idBase]);
1055    const setInstance = Object(external_wp_element_["useCallback"])(nextInstance => {
1056      setAttributes({
1057        instance: nextInstance
1058      });
1059    }, []);
1060  
1061    if (!widgetType && hasResolvedWidgetType) {
1062      return Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], {
1063        icon: Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockIcon"], {
1064          icon: library_brush
1065        }),
1066        label: Object(external_wp_i18n_["__"])('Legacy Widget')
1067      }, Object(external_wp_i18n_["__"])('Widget is missing.'));
1068    }
1069  
1070    if (!hasResolvedWidgetType) {
1071      return Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Spinner"], null));
1072    }
1073  
1074    const mode = idBase && (isNavigationMode || !isSelected) ? 'preview' : 'edit';
1075    return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, idBase === 'text' && Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockControls"], {
1076      group: "other"
1077    }, Object(external_wp_element_["createElement"])(ConvertToBlocksButton, {
1078      clientId: clientId,
1079      rawInstance: instance.raw
1080    })), Object(external_wp_element_["createElement"])(external_wp_blockEditor_["InspectorControls"], null, Object(external_wp_element_["createElement"])(InspectorCard, {
1081      name: widgetType.name,
1082      description: widgetType.description
1083    })), Object(external_wp_element_["createElement"])(Form, {
1084      title: widgetType.name,
1085      isVisible: mode === 'edit',
1086      id: id,
1087      idBase: idBase,
1088      instance: instance,
1089      isWide: isWide,
1090      onChangeInstance: setInstance,
1091      onChangeHasPreview: setHasPreview
1092    }), idBase && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, hasPreview === null && mode === 'preview' && Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Spinner"], null)), hasPreview === true && Object(external_wp_element_["createElement"])(Preview, {
1093      idBase: idBase,
1094      instance: instance,
1095      isVisible: mode === 'preview'
1096    }), hasPreview === false && mode === 'preview' && Object(external_wp_element_["createElement"])(NoPreview, {
1097      name: widgetType.name
1098    })));
1099  }
1100  
1101  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/transforms.js
1102  /**
1103   * WordPress dependencies
1104   */
1105  
1106  const legacyWidgetTransforms = [{
1107    block: 'core/calendar',
1108    widget: 'calendar'
1109  }, {
1110    block: 'core/search',
1111    widget: 'search'
1112  }, {
1113    block: 'core/html',
1114    widget: 'custom_html',
1115    transform: ({
1116      content
1117    }) => ({
1118      content
1119    })
1120  }, {
1121    block: 'core/archives',
1122    widget: 'archives',
1123    transform: ({
1124      count,
1125      dropdown
1126    }) => {
1127      return {
1128        displayAsDropdown: !!dropdown,
1129        showPostCounts: !!count
1130      };
1131    }
1132  }, {
1133    block: 'core/latest-posts',
1134    widget: 'recent-posts',
1135    transform: ({
1136      show_date: displayPostDate,
1137      number
1138    }) => {
1139      return {
1140        displayPostDate: !!displayPostDate,
1141        postsToShow: number
1142      };
1143    }
1144  }, {
1145    block: 'core/latest-comments',
1146    widget: 'recent-comments',
1147    transform: ({
1148      number
1149    }) => {
1150      return {
1151        commentsToShow: number
1152      };
1153    }
1154  }, {
1155    block: 'core/tag-cloud',
1156    widget: 'tag_cloud',
1157    transform: ({
1158      taxonomy,
1159      count
1160    }) => {
1161      return {
1162        showTagCounts: !!count,
1163        taxonomy
1164      };
1165    }
1166  }, {
1167    block: 'core/categories',
1168    widget: 'categories',
1169    transform: ({
1170      count,
1171      dropdown,
1172      hierarchical
1173    }) => {
1174      return {
1175        displayAsDropdown: !!dropdown,
1176        showPostCounts: !!count,
1177        showHierarchy: !!hierarchical
1178      };
1179    }
1180  }, {
1181    block: 'core/audio',
1182    widget: 'media_audio',
1183    transform: ({
1184      url,
1185      preload,
1186      loop,
1187      attachment_id: id
1188    }) => {
1189      return {
1190        src: url,
1191        id,
1192        preload,
1193        loop
1194      };
1195    }
1196  }, {
1197    block: 'core/video',
1198    widget: 'media_video',
1199    transform: ({
1200      url,
1201      preload,
1202      loop,
1203      attachment_id: id
1204    }) => {
1205      return {
1206        src: url,
1207        id,
1208        preload,
1209        loop
1210      };
1211    }
1212  }, {
1213    block: 'core/image',
1214    widget: 'media_image',
1215    transform: ({
1216      alt,
1217      attachment_id: id,
1218      caption,
1219      height,
1220      link_classes: linkClass,
1221      link_rel: rel,
1222      link_target_blank: targetBlack,
1223      link_type: linkDestination,
1224      link_url: link,
1225      size: sizeSlug,
1226      url,
1227      width
1228    }) => {
1229      return {
1230        alt,
1231        caption,
1232        height,
1233        id,
1234        link,
1235        linkClass,
1236        linkDestination,
1237        linkTarget: targetBlack ? '_blank' : undefined,
1238        rel,
1239        sizeSlug,
1240        url,
1241        width
1242      };
1243    }
1244  }, {
1245    block: 'core/gallery',
1246    widget: 'media_gallery',
1247    transform: ({
1248      ids,
1249      link_type: linkTo,
1250      size,
1251      number
1252    }) => {
1253      return {
1254        ids,
1255        columns: number,
1256        linkTo,
1257        sizeSlug: size,
1258        images: ids.map(id => ({
1259          id
1260        }))
1261      };
1262    }
1263  }, {
1264    block: 'core/rss',
1265    widget: 'rss',
1266    transform: ({
1267      url,
1268      show_author: displayAuthor,
1269      show_date: displayDate,
1270      show_summary: displayExcerpt,
1271      items
1272    }) => {
1273      return {
1274        feedURL: url,
1275        displayAuthor: !!displayAuthor,
1276        displayDate: !!displayDate,
1277        displayExcerpt: !!displayExcerpt,
1278        itemsToShow: items
1279      };
1280    }
1281  }].map(({
1282    block,
1283    widget,
1284    transform
1285  }) => {
1286    return {
1287      type: 'block',
1288      blocks: [block],
1289      isMatch: ({
1290        idBase,
1291        instance
1292      }) => {
1293        return idBase === widget && !!(instance !== null && instance !== void 0 && instance.raw);
1294      },
1295      transform: ({
1296        instance
1297      }) => {
1298        var _instance$raw;
1299  
1300        const transformedBlock = Object(external_wp_blocks_["createBlock"])(block, transform ? transform(instance.raw) : undefined);
1301  
1302        if (!((_instance$raw = instance.raw) !== null && _instance$raw !== void 0 && _instance$raw.title)) {
1303          return transformedBlock;
1304        }
1305  
1306        return [Object(external_wp_blocks_["createBlock"])('core/heading', {
1307          content: instance.raw.title
1308        }), transformedBlock];
1309      }
1310    };
1311  });
1312  const transforms = {
1313    to: legacyWidgetTransforms
1314  };
1315  /* harmony default export */ var legacy_widget_transforms = (transforms);
1316  
1317  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/index.js
1318  /**
1319   * WordPress dependencies
1320   */
1321  
1322  /**
1323   * Internal dependencies
1324   */
1325  
1326  const legacy_widget_metadata = {
1327    apiVersion: 2,
1328    name: "core/legacy-widget",
1329    title: "Legacy Widget",
1330    category: "widgets",
1331    description: "Display a legacy widget.",
1332    textdomain: "default",
1333    attributes: {
1334      id: {
1335        type: "string",
1336        "default": null
1337      },
1338      idBase: {
1339        type: "string",
1340        "default": null
1341      },
1342      instance: {
1343        type: "object",
1344        "default": null
1345      }
1346    },
1347    supports: {
1348      html: false,
1349      customClassName: false,
1350      reusable: false
1351    },
1352    editorStyle: "wp-block-legacy-widget-editor"
1353  };
1354  
1355  
1356  const {
1357    name: legacy_widget_name
1358  } = legacy_widget_metadata;
1359  
1360  const legacy_widget_settings = {
1361    icon: library_widget,
1362    edit: Edit,
1363    transforms: legacy_widget_transforms
1364  };
1365  
1366  // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/move-to.js
1367  
1368  
1369  /**
1370   * WordPress dependencies
1371   */
1372  
1373  const moveTo = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
1374    xmlns: "http://www.w3.org/2000/svg",
1375    viewBox: "0 0 24 24"
1376  }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
1377    d: "M19.75 9c0-1.257-.565-2.197-1.39-2.858-.797-.64-1.827-1.017-2.815-1.247-1.802-.42-3.703-.403-4.383-.396L11 4.5V6l.177-.001c.696-.006 2.416-.02 4.028.356.887.207 1.67.518 2.216.957.52.416.829.945.829 1.688 0 .592-.167.966-.407 1.23-.255.281-.656.508-1.236.674-1.19.34-2.82.346-4.607.346h-.077c-1.692 0-3.527 0-4.942.404-.732.209-1.424.545-1.935 1.108-.526.579-.796 1.33-.796 2.238 0 1.257.565 2.197 1.39 2.858.797.64 1.827 1.017 2.815 1.247 1.802.42 3.703.403 4.383.396L13 19.5h.714V22L18 18.5 13.714 15v3H13l-.177.001c-.696.006-2.416.02-4.028-.356-.887-.207-1.67-.518-2.216-.957-.52-.416-.829-.945-.829-1.688 0-.592.167-.966.407-1.23.255-.281.656-.508 1.237-.674 1.189-.34 2.819-.346 4.606-.346h.077c1.692 0 3.527 0 4.941-.404.732-.209 1.425-.545 1.936-1.108.526-.579.796-1.33.796-2.238z"
1378  }));
1379  /* harmony default export */ var move_to = (moveTo);
1380  
1381  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/components/move-to-widget-area/index.js
1382  
1383  
1384  /**
1385   * WordPress dependencies
1386   */
1387  
1388  
1389  
1390  function MoveToWidgetArea({
1391    currentWidgetAreaId,
1392    widgetAreas,
1393    onSelect
1394  }) {
1395    return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarItem"], null, toggleProps => Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], {
1396      icon: move_to,
1397      label: Object(external_wp_i18n_["__"])('Move to widget area'),
1398      toggleProps: toggleProps
1399    }, ({
1400      onClose
1401    }) => Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], {
1402      label: Object(external_wp_i18n_["__"])('Move to')
1403    }, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItemsChoice"], {
1404      choices: widgetAreas.map(widgetArea => ({
1405        value: widgetArea.id,
1406        label: widgetArea.name,
1407        info: widgetArea.description
1408      })),
1409      value: currentWidgetAreaId,
1410      onSelect: value => {
1411        onSelect(value);
1412        onClose();
1413      }
1414    })))));
1415  }
1416  
1417  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/components/index.js
1418  
1419  
1420  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/utils.js
1421  // @ts-check
1422  
1423  /**
1424   * Get the internal widget id from block.
1425   *
1426   * @typedef  {Object} Attributes
1427   * @property {string} __internalWidgetId The internal widget id.
1428   * @typedef  {Object} Block
1429   * @property {Attributes} attributes The attributes of the block.
1430   *
1431   * @param {Block} block The block.
1432   * @return {string} The internal widget id.
1433   */
1434  function getWidgetIdFromBlock(block) {
1435    return block.attributes.__internalWidgetId;
1436  }
1437  /**
1438   * Add internal widget id to block's attributes.
1439   *
1440   * @param {Block} block The block.
1441   * @param {string} widgetId The widget id.
1442   * @return {Block} The updated block.
1443   */
1444  
1445  function addWidgetIdToBlock(block, widgetId) {
1446    return { ...block,
1447      attributes: { ...(block.attributes || {}),
1448        __internalWidgetId: widgetId
1449      }
1450    };
1451  }
1452  
1453  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/register-legacy-widget-variations.js
1454  /**
1455   * WordPress dependencies
1456   */
1457  
1458  
1459  
1460  function registerLegacyWidgetVariations(settings) {
1461    const unsubscribe = Object(external_wp_data_["subscribe"])(() => {
1462      var _settings$widgetTypes, _select$getWidgetType;
1463  
1464      const hiddenIds = (_settings$widgetTypes = settings === null || settings === void 0 ? void 0 : settings.widgetTypesToHideFromLegacyWidgetBlock) !== null && _settings$widgetTypes !== void 0 ? _settings$widgetTypes : [];
1465      const widgetTypes = (_select$getWidgetType = Object(external_wp_data_["select"])(external_wp_coreData_["store"]).getWidgetTypes({
1466        per_page: -1
1467      })) === null || _select$getWidgetType === void 0 ? void 0 : _select$getWidgetType.filter(widgetType => !hiddenIds.includes(widgetType.id));
1468  
1469      if (widgetTypes) {
1470        unsubscribe();
1471        Object(external_wp_data_["dispatch"])(external_wp_blocks_["store"]).addBlockVariations('core/legacy-widget', widgetTypes.map(widgetType => ({
1472          name: widgetType.id,
1473          title: widgetType.name,
1474          description: widgetType.description,
1475          attributes: widgetType.is_multi ? {
1476            idBase: widgetType.id,
1477            instance: {}
1478          } : {
1479            id: widgetType.id
1480          }
1481        })));
1482      }
1483    });
1484  }
1485  
1486  // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/index.js
1487  /**
1488   * WordPress dependencies
1489   */
1490  
1491  /**
1492   * Internal dependencies
1493   */
1494  
1495  
1496  
1497  
1498  /**
1499   * Registers the Legacy Widget block.
1500   *
1501   * Note that for the block to be useful, any scripts required by a widget must
1502   * be loaded into the page.
1503   *
1504   * @see https://developer.wordpress.org/block-editor/how-to-guides/widgets/legacy-widget-block/
1505   */
1506  
1507  function registerLegacyWidgetBlock() {
1508    const {
1509      metadata,
1510      settings,
1511      name
1512    } = legacy_widget_namespaceObject;
1513    Object(external_wp_blocks_["registerBlockType"])({
1514      name,
1515      ...metadata
1516    }, settings);
1517  }
1518  
1519  
1520  
1521  /***/ }),
1522  
1523  /***/ "GRId":
1524  /***/ (function(module, exports) {
1525  
1526  (function() { module.exports = window["wp"]["element"]; }());
1527  
1528  /***/ }),
1529  
1530  /***/ "HSyU":
1531  /***/ (function(module, exports) {
1532  
1533  (function() { module.exports = window["wp"]["blocks"]; }());
1534  
1535  /***/ }),
1536  
1537  /***/ "K9lf":
1538  /***/ (function(module, exports) {
1539  
1540  (function() { module.exports = window["wp"]["compose"]; }());
1541  
1542  /***/ }),
1543  
1544  /***/ "Mmq9":
1545  /***/ (function(module, exports) {
1546  
1547  (function() { module.exports = window["wp"]["url"]; }());
1548  
1549  /***/ }),
1550  
1551  /***/ "TSYQ":
1552  /***/ (function(module, exports, __webpack_require__) {
1553  
1554  var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
1555    Copyright (c) 2018 Jed Watson.
1556    Licensed under the MIT License (MIT), see
1557    http://jedwatson.github.io/classnames
1558  */
1559  /* global define */
1560  
1561  (function () {
1562      'use strict';
1563  
1564      var hasOwn = {}.hasOwnProperty;
1565  
1566  	function classNames() {
1567          var classes = [];
1568  
1569          for (var i = 0; i < arguments.length; i++) {
1570              var arg = arguments[i];
1571              if (!arg) continue;
1572  
1573              var argType = typeof arg;
1574  
1575              if (argType === 'string' || argType === 'number') {
1576                  classes.push(arg);
1577              } else if (Array.isArray(arg)) {
1578                  if (arg.length) {
1579                      var inner = classNames.apply(null, arg);
1580                      if (inner) {
1581                          classes.push(inner);
1582                      }
1583                  }
1584              } else if (argType === 'object') {
1585                  if (arg.toString === Object.prototype.toString) {
1586                      for (var key in arg) {
1587                          if (hasOwn.call(arg, key) && arg[key]) {
1588                              classes.push(key);
1589                          }
1590                      }
1591                  } else {
1592                      classes.push(arg.toString());
1593                  }
1594              }
1595          }
1596  
1597          return classes.join(' ');
1598      }
1599  
1600      if ( true && module.exports) {
1601          classNames.default = classNames;
1602          module.exports = classNames;
1603      } else if (true) {
1604          // register as 'classnames', consistent with npm package name
1605          !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
1606              return classNames;
1607          }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
1608                  __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
1609      } else {}
1610  }());
1611  
1612  
1613  /***/ }),
1614  
1615  /***/ "Tqx9":
1616  /***/ (function(module, exports) {
1617  
1618  (function() { module.exports = window["wp"]["primitives"]; }());
1619  
1620  /***/ }),
1621  
1622  /***/ "YLtl":
1623  /***/ (function(module, exports) {
1624  
1625  (function() { module.exports = window["lodash"]; }());
1626  
1627  /***/ }),
1628  
1629  /***/ "axFQ":
1630  /***/ (function(module, exports) {
1631  
1632  (function() { module.exports = window["wp"]["blockEditor"]; }());
1633  
1634  /***/ }),
1635  
1636  /***/ "jZUy":
1637  /***/ (function(module, exports) {
1638  
1639  (function() { module.exports = window["wp"]["coreData"]; }());
1640  
1641  /***/ }),
1642  
1643  /***/ "l3Sj":
1644  /***/ (function(module, exports) {
1645  
1646  (function() { module.exports = window["wp"]["i18n"]; }());
1647  
1648  /***/ }),
1649  
1650  /***/ "onLe":
1651  /***/ (function(module, exports) {
1652  
1653  (function() { module.exports = window["wp"]["notices"]; }());
1654  
1655  /***/ }),
1656  
1657  /***/ "tI+e":
1658  /***/ (function(module, exports) {
1659  
1660  (function() { module.exports = window["wp"]["components"]; }());
1661  
1662  /***/ }),
1663  
1664  /***/ "ywyh":
1665  /***/ (function(module, exports) {
1666  
1667  (function() { module.exports = window["wp"]["apiFetch"]; }());
1668  
1669  /***/ })
1670  
1671  /******/ });


Generated: Tue Jul 27 01:00:09 2021 Cross-referenced by PHPXref 0.7.1