PageSourceSearch

https://www.tromso.kommune.no/modules/contrib/gutenberg/js/vendor/gutenberg/widgets/index.js?tlu16d

js tromso.kommune.no collected 2026-09-24 18:30:51 UTC 54,244 bytes, 1,756 lines download raw bytes

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

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.