PluginProbe
Gutenberg / 10.1.0
Gutenberg v10.1.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | build/core-data/index.js +1 -5750 12.6.0 → 10.1.0 View file →
@@ -1,5750 +1 @@
1 -/******/ (function() { // webpackBootstrap
2 -/******/ "use strict";
3 -/******/ var __webpack_modules__ = ({
4 -
5 -/***/ 3909:
6 -/***/ (function(module) {
7 -
8 -
9 -
10 -function _typeof(obj) {
11 - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
12 - _typeof = function (obj) {
13 - return typeof obj;
14 - };
15 - } else {
16 - _typeof = function (obj) {
17 - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
18 - };
19 - }
20 -
21 - return _typeof(obj);
22 -}
23 -
24 -function _classCallCheck(instance, Constructor) {
25 - if (!(instance instanceof Constructor)) {
26 - throw new TypeError("Cannot call a class as a function");
27 - }
28 -}
29 -
30 -function _defineProperties(target, props) {
31 - for (var i = 0; i < props.length; i++) {
32 - var descriptor = props[i];
33 - descriptor.enumerable = descriptor.enumerable || false;
34 - descriptor.configurable = true;
35 - if ("value" in descriptor) descriptor.writable = true;
36 - Object.defineProperty(target, descriptor.key, descriptor);
37 - }
38 -}
39 -
40 -function _createClass(Constructor, protoProps, staticProps) {
41 - if (protoProps) _defineProperties(Constructor.prototype, protoProps);
42 - if (staticProps) _defineProperties(Constructor, staticProps);
43 - return Constructor;
44 -}
45 -
46 -/**
47 - * Given an instance of EquivalentKeyMap, returns its internal value pair tuple
48 - * for a key, if one exists. The tuple members consist of the last reference
49 - * value for the key (used in efficient subsequent lookups) and the value
50 - * assigned for the key at the leaf node.
51 - *
52 - * @param {EquivalentKeyMap} instance EquivalentKeyMap instance.
53 - * @param {*} key The key for which to return value pair.
54 - *
55 - * @return {?Array} Value pair, if exists.
56 - */
57 -function getValuePair(instance, key) {
58 - var _map = instance._map,
59 - _arrayTreeMap = instance._arrayTreeMap,
60 - _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the
61 - // value, which can be used to shortcut immediately to the value.
62 -
63 - if (_map.has(key)) {
64 - return _map.get(key);
65 - } // Sort keys to ensure stable retrieval from tree.
66 -
67 -
68 - var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value.
69 -
70 - var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap;
71 -
72 - for (var i = 0; i < properties.length; i++) {
73 - var property = properties[i];
74 - map = map.get(property);
75 -
76 - if (map === undefined) {
77 - return;
78 - }
79 -
80 - var propertyValue = key[property];
81 - map = map.get(propertyValue);
82 -
83 - if (map === undefined) {
84 - return;
85 - }
86 - }
87 -
88 - var valuePair = map.get('_ekm_value');
89 -
90 - if (!valuePair) {
91 - return;
92 - } // If reached, it implies that an object-like key was set with another
93 - // reference, so delete the reference and replace with the current.
94 -
95 -
96 - _map.delete(valuePair[0]);
97 -
98 - valuePair[0] = key;
99 - map.set('_ekm_value', valuePair);
100 -
101 - _map.set(key, valuePair);
102 -
103 - return valuePair;
104 -}
105 -/**
106 - * Variant of a Map object which enables lookup by equivalent (deeply equal)
107 - * object and array keys.
108 - */
109 -
110 -
111 -var EquivalentKeyMap =
112 -/*#__PURE__*/
113 -function () {
114 - /**
115 - * Constructs a new instance of EquivalentKeyMap.
116 - *
117 - * @param {Iterable.<*>} iterable Initial pair of key, value for map.
118 - */
119 - function EquivalentKeyMap(iterable) {
120 - _classCallCheck(this, EquivalentKeyMap);
121 -
122 - this.clear();
123 -
124 - if (iterable instanceof EquivalentKeyMap) {
125 - // Map#forEach is only means of iterating with support for IE11.
126 - var iterablePairs = [];
127 - iterable.forEach(function (value, key) {
128 - iterablePairs.push([key, value]);
129 - });
130 - iterable = iterablePairs;
131 - }
132 -
133 - if (iterable != null) {
134 - for (var i = 0; i < iterable.length; i++) {
135 - this.set(iterable[i][0], iterable[i][1]);
136 - }
137 - }
138 - }
139 - /**
140 - * Accessor property returning the number of elements.
141 - *
142 - * @return {number} Number of elements.
143 - */
144 -
145 -
146 - _createClass(EquivalentKeyMap, [{
147 - key: "set",
148 -
149 - /**
150 - * Add or update an element with a specified key and value.
151 - *
152 - * @param {*} key The key of the element to add.
153 - * @param {*} value The value of the element to add.
154 - *
155 - * @return {EquivalentKeyMap} Map instance.
156 - */
157 - value: function set(key, value) {
158 - // Shortcut non-object-like to set on internal Map.
159 - if (key === null || _typeof(key) !== 'object') {
160 - this._map.set(key, value);
161 -
162 - return this;
163 - } // Sort keys to ensure stable assignment into tree.
164 -
165 -
166 - var properties = Object.keys(key).sort();
167 - var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value.
168 -
169 - var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap;
170 -
171 - for (var i = 0; i < properties.length; i++) {
172 - var property = properties[i];
173 -
174 - if (!map.has(property)) {
175 - map.set(property, new EquivalentKeyMap());
176 - }
177 -
178 - map = map.get(property);
179 - var propertyValue = key[property];
180 -
181 - if (!map.has(propertyValue)) {
182 - map.set(propertyValue, new EquivalentKeyMap());
183 - }
184 -
185 - map = map.get(propertyValue);
186 - } // If an _ekm_value exists, there was already an equivalent key. Before
187 - // overriding, ensure that the old key reference is removed from map to
188 - // avoid memory leak of accumulating equivalent keys. This is, in a
189 - // sense, a poor man's WeakMap, while still enabling iterability.
190 -
191 -
192 - var previousValuePair = map.get('_ekm_value');
193 -
194 - if (previousValuePair) {
195 - this._map.delete(previousValuePair[0]);
196 - }
197 -
198 - map.set('_ekm_value', valuePair);
199 -
200 - this._map.set(key, valuePair);
201 -
202 - return this;
203 - }
204 - /**
205 - * Returns a specified element.
206 - *
207 - * @param {*} key The key of the element to return.
208 - *
209 - * @return {?*} The element associated with the specified key or undefined
210 - * if the key can't be found.
211 - */
212 -
213 - }, {
214 - key: "get",
215 - value: function get(key) {
216 - // Shortcut non-object-like to get from internal Map.
217 - if (key === null || _typeof(key) !== 'object') {
218 - return this._map.get(key);
219 - }
220 -
221 - var valuePair = getValuePair(this, key);
222 -
223 - if (valuePair) {
224 - return valuePair[1];
225 - }
226 - }
227 - /**
228 - * Returns a boolean indicating whether an element with the specified key
229 - * exists or not.
230 - *
231 - * @param {*} key The key of the element to test for presence.
232 - *
233 - * @return {boolean} Whether an element with the specified key exists.
234 - */
235 -
236 - }, {
237 - key: "has",
238 - value: function has(key) {
239 - if (key === null || _typeof(key) !== 'object') {
240 - return this._map.has(key);
241 - } // Test on the _presence_ of the pair, not its value, as even undefined
242 - // can be a valid member value for a key.
243 -
244 -
245 - return getValuePair(this, key) !== undefined;
246 - }
247 - /**
248 - * Removes the specified element.
249 - *
250 - * @param {*} key The key of the element to remove.
251 - *
252 - * @return {boolean} Returns true if an element existed and has been
253 - * removed, or false if the element does not exist.
254 - */
255 -
256 - }, {
257 - key: "delete",
258 - value: function _delete(key) {
259 - if (!this.has(key)) {
260 - return false;
261 - } // This naive implementation will leave orphaned child trees. A better
262 - // implementation should traverse and remove orphans.
263 -
264 -
265 - this.set(key, undefined);
266 - return true;
267 - }
268 - /**
269 - * Executes a provided function once per each key/value pair, in insertion
270 - * order.
271 - *
272 - * @param {Function} callback Function to execute for each element.
273 - * @param {*} thisArg Value to use as `this` when executing
274 - * `callback`.
275 - */
276 -
277 - }, {
278 - key: "forEach",
279 - value: function forEach(callback) {
280 - var _this = this;
281 -
282 - var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
283 -
284 - this._map.forEach(function (value, key) {
285 - // Unwrap value from object-like value pair.
286 - if (key !== null && _typeof(key) === 'object') {
287 - value = value[1];
288 - }
289 -
290 - callback.call(thisArg, value, key, _this);
291 - });
292 - }
293 - /**
294 - * Removes all elements.
295 - */
296 -
297 - }, {
298 - key: "clear",
299 - value: function clear() {
300 - this._map = new Map();
301 - this._arrayTreeMap = new Map();
302 - this._objectTreeMap = new Map();
303 - }
304 - }, {
305 - key: "size",
306 - get: function get() {
307 - return this._map.size;
308 - }
309 - }]);
310 -
311 - return EquivalentKeyMap;
312 -}();
313 -
314 -module.exports = EquivalentKeyMap;
315 -
316 -
317 -/***/ })
318 -
319 -/******/ });
320 -/************************************************************************/
321 -/******/ // The module cache
322 -/******/ var __webpack_module_cache__ = {};
323 -/******/
324 -/******/ // The require function
325 -/******/ function __webpack_require__(moduleId) {
326 -/******/ // Check if module is in cache
327 -/******/ var cachedModule = __webpack_module_cache__[moduleId];
328 -/******/ if (cachedModule !== undefined) {
329 -/******/ return cachedModule.exports;
330 -/******/ }
331 -/******/ // Create a new module (and put it into the cache)
332 -/******/ var module = __webpack_module_cache__[moduleId] = {
333 -/******/ // no module.id needed
334 -/******/ // no module.loaded needed
335 -/******/ exports: {}
336 -/******/ };
337 -/******/
338 -/******/ // Execute the module function
339 -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
340 -/******/
341 -/******/ // Return the exports of the module
342 -/******/ return module.exports;
343 -/******/ }
344 -/******/
345 -/************************************************************************/
346 -/******/ /* webpack/runtime/compat get default export */
347 -/******/ !function() {
348 -/******/ // getDefaultExport function for compatibility with non-harmony modules
349 -/******/ __webpack_require__.n = function(module) {
350 -/******/ var getter = module && module.__esModule ?
351 -/******/ function() { return module['default']; } :
352 -/******/ function() { return module; };
353 -/******/ __webpack_require__.d(getter, { a: getter });
354 -/******/ return getter;
355 -/******/ };
356 -/******/ }();
357 -/******/
358 -/******/ /* webpack/runtime/define property getters */
359 -/******/ !function() {
360 -/******/ // define getter functions for harmony exports
361 -/******/ __webpack_require__.d = function(exports, definition) {
362 -/******/ for(var key in definition) {
363 -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
364 -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
365 -/******/ }
366 -/******/ }
367 -/******/ };
368 -/******/ }();
369 -/******/
370 -/******/ /* webpack/runtime/hasOwnProperty shorthand */
371 -/******/ !function() {
372 -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
373 -/******/ }();
374 -/******/
375 -/******/ /* webpack/runtime/make namespace object */
376 -/******/ !function() {
377 -/******/ // define __esModule on exports
378 -/******/ __webpack_require__.r = function(exports) {
379 -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
380 -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
381 -/******/ }
382 -/******/ Object.defineProperty(exports, '__esModule', { value: true });
383 -/******/ };
384 -/******/ }();
385 -/******/
386 -/************************************************************************/
387 -var __webpack_exports__ = {};
388 -// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
389 -!function() {
390 -// ESM COMPAT FLAG
391 -__webpack_require__.r(__webpack_exports__);
392 -
393 -// EXPORTS
394 -__webpack_require__.d(__webpack_exports__, {
395 - "EntityProvider": function() { return /* reexport */ EntityProvider; },
396 - "__experimentalFetchLinkSuggestions": function() { return /* reexport */ _experimental_fetch_link_suggestions; },
397 - "__experimentalFetchUrlData": function() { return /* reexport */ _experimental_fetch_url_data; },
398 - "store": function() { return /* binding */ store; },
399 - "useEntityBlockEditor": function() { return /* reexport */ useEntityBlockEditor; },
400 - "useEntityId": function() { return /* reexport */ useEntityId; },
401 - "useEntityProp": function() { return /* reexport */ useEntityProp; }
402 -});
403 -
404 -// NAMESPACE OBJECT: ./packages/core-data/build-module/actions.js
405 -var build_module_actions_namespaceObject = {};
406 -__webpack_require__.r(build_module_actions_namespaceObject);
407 -__webpack_require__.d(build_module_actions_namespaceObject, {
408 - "__experimentalBatch": function() { return __experimentalBatch; },
409 - "__experimentalReceiveCurrentGlobalStylesId": function() { return __experimentalReceiveCurrentGlobalStylesId; },
410 - "__experimentalReceiveThemeBaseGlobalStyles": function() { return __experimentalReceiveThemeBaseGlobalStyles; },
411 - "__experimentalReceiveThemeGlobalStyleVariations": function() { return __experimentalReceiveThemeGlobalStyleVariations; },
412 - "__experimentalSaveSpecifiedEntityEdits": function() { return __experimentalSaveSpecifiedEntityEdits; },
413 - "__unstableCreateUndoLevel": function() { return __unstableCreateUndoLevel; },
414 - "addEntities": function() { return addEntities; },
415 - "deleteEntityRecord": function() { return deleteEntityRecord; },
416 - "editEntityRecord": function() { return editEntityRecord; },
417 - "receiveAutosaves": function() { return receiveAutosaves; },
418 - "receiveCurrentTheme": function() { return receiveCurrentTheme; },
419 - "receiveCurrentUser": function() { return receiveCurrentUser; },
420 - "receiveEmbedPreview": function() { return receiveEmbedPreview; },
421 - "receiveEntityRecords": function() { return receiveEntityRecords; },
422 - "receiveThemeSupports": function() { return receiveThemeSupports; },
423 - "receiveUploadPermissions": function() { return receiveUploadPermissions; },
424 - "receiveUserPermission": function() { return receiveUserPermission; },
425 - "receiveUserQuery": function() { return receiveUserQuery; },
426 - "redo": function() { return redo; },
427 - "saveEditedEntityRecord": function() { return saveEditedEntityRecord; },
428 - "saveEntityRecord": function() { return saveEntityRecord; },
429 - "undo": function() { return undo; }
430 -});
431 -
432 -// NAMESPACE OBJECT: ./packages/core-data/build-module/selectors.js
433 -var build_module_selectors_namespaceObject = {};
434 -__webpack_require__.r(build_module_selectors_namespaceObject);
435 -__webpack_require__.d(build_module_selectors_namespaceObject, {
436 - "__experimentalGetCurrentGlobalStylesId": function() { return __experimentalGetCurrentGlobalStylesId; },
437 - "__experimentalGetCurrentThemeBaseGlobalStyles": function() { return __experimentalGetCurrentThemeBaseGlobalStyles; },
438 - "__experimentalGetCurrentThemeGlobalStylesVariations": function() { return __experimentalGetCurrentThemeGlobalStylesVariations; },
439 - "__experimentalGetDirtyEntityRecords": function() { return __experimentalGetDirtyEntityRecords; },
440 - "__experimentalGetEntitiesBeingSaved": function() { return __experimentalGetEntitiesBeingSaved; },
441 - "__experimentalGetEntityRecordNoResolver": function() { return __experimentalGetEntityRecordNoResolver; },
442 - "__experimentalGetTemplateForLink": function() { return __experimentalGetTemplateForLink; },
443 - "canUser": function() { return canUser; },
444 - "canUserEditEntityRecord": function() { return canUserEditEntityRecord; },
445 - "getAuthors": function() { return getAuthors; },
446 - "getAutosave": function() { return getAutosave; },
447 - "getAutosaves": function() { return getAutosaves; },
448 - "getCurrentTheme": function() { return getCurrentTheme; },
449 - "getCurrentUser": function() { return getCurrentUser; },
450 - "getEditedEntityRecord": function() { return getEditedEntityRecord; },
451 - "getEmbedPreview": function() { return getEmbedPreview; },
452 - "getEntitiesByKind": function() { return getEntitiesByKind; },
453 - "getEntity": function() { return getEntity; },
454 - "getEntityRecord": function() { return getEntityRecord; },
455 - "getEntityRecordEdits": function() { return getEntityRecordEdits; },
456 - "getEntityRecordNonTransientEdits": function() { return getEntityRecordNonTransientEdits; },
457 - "getEntityRecords": function() { return getEntityRecords; },
458 - "getLastEntityDeleteError": function() { return getLastEntityDeleteError; },
459 - "getLastEntitySaveError": function() { return getLastEntitySaveError; },
460 - "getRawEntityRecord": function() { return getRawEntityRecord; },
461 - "getRedoEdit": function() { return getRedoEdit; },
462 - "getReferenceByDistinctEdits": function() { return getReferenceByDistinctEdits; },
463 - "getThemeSupports": function() { return getThemeSupports; },
464 - "getUndoEdit": function() { return getUndoEdit; },
465 - "getUserQueryResults": function() { return getUserQueryResults; },
466 - "hasEditsForEntityRecord": function() { return hasEditsForEntityRecord; },
467 - "hasEntityRecords": function() { return hasEntityRecords; },
468 - "hasFetchedAutosaves": function() { return hasFetchedAutosaves; },
469 - "hasRedo": function() { return hasRedo; },
470 - "hasUndo": function() { return hasUndo; },
471 - "isAutosavingEntityRecord": function() { return isAutosavingEntityRecord; },
472 - "isDeletingEntityRecord": function() { return isDeletingEntityRecord; },
473 - "isPreviewEmbedFallback": function() { return isPreviewEmbedFallback; },
474 - "isRequestingEmbedPreview": function() { return isRequestingEmbedPreview; },
475 - "isSavingEntityRecord": function() { return isSavingEntityRecord; }
476 -});
477 -
478 -// NAMESPACE OBJECT: ./packages/core-data/build-module/resolvers.js
479 -var resolvers_namespaceObject = {};
480 -__webpack_require__.r(resolvers_namespaceObject);
481 -__webpack_require__.d(resolvers_namespaceObject, {
482 - "__experimentalGetCurrentGlobalStylesId": function() { return resolvers_experimentalGetCurrentGlobalStylesId; },
483 - "__experimentalGetCurrentThemeBaseGlobalStyles": function() { return resolvers_experimentalGetCurrentThemeBaseGlobalStyles; },
484 - "__experimentalGetCurrentThemeGlobalStylesVariations": function() { return resolvers_experimentalGetCurrentThemeGlobalStylesVariations; },
485 - "__experimentalGetTemplateForLink": function() { return resolvers_experimentalGetTemplateForLink; },
486 - "canUser": function() { return resolvers_canUser; },
487 - "canUserEditEntityRecord": function() { return resolvers_canUserEditEntityRecord; },
488 - "getAuthors": function() { return resolvers_getAuthors; },
489 - "getAutosave": function() { return resolvers_getAutosave; },
490 - "getAutosaves": function() { return resolvers_getAutosaves; },
491 - "getCurrentTheme": function() { return resolvers_getCurrentTheme; },
492 - "getCurrentUser": function() { return resolvers_getCurrentUser; },
493 - "getEditedEntityRecord": function() { return resolvers_getEditedEntityRecord; },
494 - "getEmbedPreview": function() { return resolvers_getEmbedPreview; },
495 - "getEntityRecord": function() { return resolvers_getEntityRecord; },
496 - "getEntityRecords": function() { return resolvers_getEntityRecords; },
497 - "getRawEntityRecord": function() { return resolvers_getRawEntityRecord; },
498 - "getThemeSupports": function() { return resolvers_getThemeSupports; }
499 -});
500 -
501 -;// CONCATENATED MODULE: external ["wp","data"]
502 -var external_wp_data_namespaceObject = window["wp"]["data"];
503 -;// CONCATENATED MODULE: external "lodash"
504 -var external_lodash_namespaceObject = window["lodash"];
505 -;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
506 -var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
507 -var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
508 -;// CONCATENATED MODULE: ./packages/core-data/build-module/utils/if-matching-action.js
509 -/**
510 - * A higher-order reducer creator which invokes the original reducer only if
511 - * the dispatching action matches the given predicate, **OR** if state is
512 - * initializing (undefined).
513 - *
514 - * @param {Function} isMatch Function predicate for allowing reducer call.
515 - *
516 - * @return {Function} Higher-order reducer.
517 - */
518 -const ifMatchingAction = isMatch => reducer => (state, action) => {
519 - if (state === undefined || isMatch(action)) {
520 - return reducer(state, action);
521 - }
522 -
523 - return state;
524 -};
525 -
526 -/* harmony default export */ var if_matching_action = (ifMatchingAction);
527 -//# sourceMappingURL=if-matching-action.js.map
528 -;// CONCATENATED MODULE: ./packages/core-data/build-module/utils/replace-action.js
529 -/**
530 - * Higher-order reducer creator which substitutes the action object before
531 - * passing to the original reducer.
532 - *
533 - * @param {Function} replacer Function mapping original action to replacement.
534 - *
535 - * @return {Function} Higher-order reducer.
536 - */
537 -const replaceAction = replacer => reducer => (state, action) => {
538 - return reducer(state, replacer(action));
539 -};
540 -
541 -/* harmony default export */ var replace_action = (replaceAction);
542 -//# sourceMappingURL=replace-action.js.map
543 -;// CONCATENATED MODULE: ./packages/core-data/build-module/utils/conservative-map-item.js
544 -/**
545 - * External dependencies
546 - */
547 -
548 -/**
549 - * Given the current and next item entity, returns the minimally "modified"
550 - * result of the next item, preferring value references from the original item
551 - * if equal. If all values match, the original item is returned.
552 - *
553 - * @param {Object} item Original item.
554 - * @param {Object} nextItem Next item.
555 - *
556 - * @return {Object} Minimally modified merged item.
557 - */
558 -
559 -function conservativeMapItem(item, nextItem) {
560 - // Return next item in its entirety if there is no original item.
561 - if (!item) {
562 - return nextItem;
563 - }
564 -
565 - let hasChanges = false;
566 - const result = {};
567 -
568 - for (const key in nextItem) {
569 - if ((0,external_lodash_namespaceObject.isEqual)(item[key], nextItem[key])) {
570 - result[key] = item[key];
571 - } else {
572 - hasChanges = true;
573 - result[key] = nextItem[key];
574 - }
575 - }
576 -
577 - if (!hasChanges) {
578 - return item;
579 - } // Only at this point, backfill properties from the original item which
580 - // weren't explicitly set into the result above. This is an optimization
581 - // to allow `hasChanges` to return early.
582 -
583 -
584 - for (const key in item) {
585 - if (!result.hasOwnProperty(key)) {
586 - result[key] = item[key];
587 - }
588 - }
589 -
590 - return result;
591 -}
592 -//# sourceMappingURL=conservative-map-item.js.map
593 -;// CONCATENATED MODULE: ./packages/core-data/build-module/utils/on-sub-key.js
594 -/**
595 - * Higher-order reducer creator which creates a combined reducer object, keyed
596 - * by a property on the action object.
597 - *
598 - * @param {string} actionProperty Action property by which to key object.
599 - *
600 - * @return {Function} Higher-order reducer.
601 - */
602 -const onSubKey = actionProperty => reducer => function () {
603 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
604 - let action = arguments.length > 1 ? arguments[1] : undefined;
605 - // Retrieve subkey from action. Do not track if undefined; useful for cases
606 - // where reducer is scoped by action shape.
607 - const key = action[actionProperty];
608 -
609 - if (key === undefined) {
610 - return state;
611 - } // Avoid updating state if unchanged. Note that this also accounts for a
612 - // reducer which returns undefined on a key which is not yet tracked.
613 -
614 -
615 - const nextKeyState = reducer(state[key], action);
616 -
617 - if (nextKeyState === state[key]) {
618 - return state;
619 - }
620 -
621 - return { ...state,
622 - [key]: nextKeyState
623 - };
624 -};
625 -/* harmony default export */ var on_sub_key = (onSubKey);
626 -//# sourceMappingURL=on-sub-key.js.map
627 -;// CONCATENATED MODULE: external ["wp","apiFetch"]
628 -var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
629 -var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
630 -;// CONCATENATED MODULE: external ["wp","i18n"]
631 -var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
632 -;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
633 -// Unique ID creation requires a high quality random # generator. In the browser we therefore
634 -// require the crypto API and do not support built-in fallback to lower quality random number
635 -// generators (like Math.random()).
636 -// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
637 -// find the complete implementation of crypto (msCrypto) on IE11.
638 -var getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
639 -var rnds8 = new Uint8Array(16);
640 -function rng() {
641 - if (!getRandomValues) {
642 - throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
643 - }
644 -
645 - return getRandomValues(rnds8);
646 -}
647 -;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js
648 -/* harmony default export */ var regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i);
649 -;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js
650 -
651 -
652 -function validate(uuid) {
653 - return typeof uuid === 'string' && regex.test(uuid);
654 -}
655 -
656 -/* harmony default export */ var esm_browser_validate = (validate);
657 -;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
658 -
659 -/**
660 - * Convert array of 16 byte values to UUID string format of the form:
661 - * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
662 - */
663 -
664 -var byteToHex = [];
665 -
666 -for (var i = 0; i < 256; ++i) {
667 - byteToHex.push((i + 0x100).toString(16).substr(1));
668 -}
669 -
670 -function stringify(arr) {
671 - var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
672 - // Note: Be careful editing this code! It's been tuned for performance
673 - // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
674 - var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
675 - // of the following:
676 - // - One or more input array values don't map to a hex octet (leading to
677 - // "undefined" in the uuid)
678 - // - Invalid input values for the RFC `version` or `variant` fields
679 -
680 - if (!esm_browser_validate(uuid)) {
681 - throw TypeError('Stringified UUID is invalid');
682 - }
683 -
684 - return uuid;
685 -}
686 -
687 -/* harmony default export */ var esm_browser_stringify = (stringify);
688 -;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
689 -
690 -
691 -
692 -function v4(options, buf, offset) {
693 - options = options || {};
694 - var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
695 -
696 - rnds[6] = rnds[6] & 0x0f | 0x40;
697 - rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
698 -
699 - if (buf) {
700 - offset = offset || 0;
701 -
702 - for (var i = 0; i < 16; ++i) {
703 - buf[offset + i] = rnds[i];
704 - }
705 -
706 - return buf;
707 - }
708 -
709 - return esm_browser_stringify(rnds);
710 -}
711 -
712 -/* harmony default export */ var esm_browser_v4 = (v4);
713 -;// CONCATENATED MODULE: external ["wp","url"]
714 -var external_wp_url_namespaceObject = window["wp"]["url"];
715 -;// CONCATENATED MODULE: external ["wp","deprecated"]
716 -var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
717 -var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
718 -;// CONCATENATED MODULE: ./packages/core-data/build-module/queried-data/actions.js
719 -/**
720 - * External dependencies
721 - */
722 -
723 -/**
724 - * Returns an action object used in signalling that items have been received.
725 - *
726 - * @param {Array} items Items received.
727 - * @param {?Object} edits Optional edits to reset.
728 - *
729 - * @return {Object} Action object.
730 - */
731 -
732 -function receiveItems(items, edits) {
733 - return {
734 - type: 'RECEIVE_ITEMS',
735 - items: (0,external_lodash_namespaceObject.castArray)(items),
736 - persistedEdits: edits
737 - };
738 -}
739 -/**
740 - * Returns an action object used in signalling that entity records have been
741 - * deleted and they need to be removed from entities state.
742 - *
743 - * @param {string} kind Kind of the removed entities.
744 - * @param {string} name Name of the removed entities.
745 - * @param {Array|number} records Record IDs of the removed entities.
746 - * @param {boolean} invalidateCache Controls whether we want to invalidate the cache.
747 - * @return {Object} Action object.
748 - */
749 -
750 -function removeItems(kind, name, records) {
751 - let invalidateCache = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
752 - return {
753 - type: 'REMOVE_ITEMS',
754 - itemIds: (0,external_lodash_namespaceObject.castArray)(records),
755 - kind,
756 - name,
757 - invalidateCache
758 - };
759 -}
760 -/**
761 - * Returns an action object used in signalling that queried data has been
762 - * received.
763 - *
764 - * @param {Array} items Queried items received.
765 - * @param {?Object} query Optional query object.
766 - * @param {?Object} edits Optional edits to reset.
767 - *
768 - * @return {Object} Action object.
769 - */
770 -
771 -function receiveQueriedItems(items) {
772 - let query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
773 - let edits = arguments.length > 2 ? arguments[2] : undefined;
774 - return { ...receiveItems(items, edits),
775 - query
776 - };
777 -}
778 -//# sourceMappingURL=actions.js.map
779 -;// CONCATENATED MODULE: ./packages/core-data/build-module/batch/default-processor.js
780 -/**
781 - * External dependencies
782 - */
783 -
784 -/**
785 - * WordPress dependencies
786 - */
787 -
788 -
789 -/**
790 - * Maximum number of requests to place in a single batch request. Obtained by
791 - * sending a preflight OPTIONS request to /batch/v1/.
792 - *
793 - * @type {number?}
794 - */
795 -
796 -let maxItems = null;
797 -/**
798 - * Default batch processor. Sends its input requests to /batch/v1.
799 - *
800 - * @param {Array} requests List of API requests to perform at once.
801 - *
802 - * @return {Promise} Promise that resolves to a list of objects containing
803 - * either `output` (if that request was succesful) or `error`
804 - * (if not ).
805 - */
806 -
807 -async function defaultProcessor(requests) {
808 - if (maxItems === null) {
809 - const preflightResponse = await external_wp_apiFetch_default()({
810 - path: '/batch/v1',
811 - method: 'OPTIONS'
812 - });
813 - maxItems = preflightResponse.endpoints[0].args.requests.maxItems;
814 - }
815 -
816 - const results = [];
817 -
818 - for (const batchRequests of (0,external_lodash_namespaceObject.chunk)(requests, maxItems)) {
819 - const batchResponse = await external_wp_apiFetch_default()({
820 - path: '/batch/v1',
821 - method: 'POST',
822 - data: {
823 - validation: 'require-all-validate',
824 - requests: batchRequests.map(request => ({
825 - path: request.path,
826 - body: request.data,
827 - // Rename 'data' to 'body'.
828 - method: request.method,
829 - headers: request.headers
830 - }))
831 - }
832 - });
833 - let batchResults;
834 -
835 - if (batchResponse.failed) {
836 - batchResults = batchResponse.responses.map(response => ({
837 - error: response === null || response === void 0 ? void 0 : response.body
838 - }));
839 - } else {
840 - batchResults = batchResponse.responses.map(response => {
841 - const result = {};
842 -
843 - if (response.status >= 200 && response.status < 300) {
844 - result.output = response.body;
845 - } else {
846 - result.error = response.body;
847 - }
848 -
849 - return result;
850 - });
851 - }
852 -
853 - results.push(...batchResults);
854 - }
855 -
856 - return results;
857 -}
858 -//# sourceMappingURL=default-processor.js.map
859 -;// CONCATENATED MODULE: ./packages/core-data/build-module/batch/create-batch.js
860 -/**
861 - * External dependencies
862 - */
863 -
864 -/**
865 - * Internal dependencies
866 - */
867 -
868 -
869 -/**
870 - * Creates a batch, which can be used to combine multiple API requests into one
871 - * API request using the WordPress batch processing API (/v1/batch).
872 - *
873 - * ```
874 - * const batch = createBatch();
875 - * const dunePromise = batch.add( {
876 - * path: '/v1/books',
877 - * method: 'POST',
878 - * data: { title: 'Dune' }
879 - * } );
880 - * const lotrPromise = batch.add( {
881 - * path: '/v1/books',
882 - * method: 'POST',
883 - * data: { title: 'Lord of the Rings' }
884 - * } );
885 - * const isSuccess = await batch.run(); // Sends one POST to /v1/batch.
886 - * if ( isSuccess ) {
887 - * console.log(
888 - * 'Saved two books:',
889 - * await dunePromise,
890 - * await lotrPromise
891 - * );
892 - * }
893 - * ```
894 - *
895 - * @param {Function} [processor] Processor function. Can be used to replace the
896 - * default functionality which is to send an API
897 - * request to /v1/batch. Is given an array of
898 - * inputs and must return a promise that
899 - * resolves to an array of objects containing
900 - * either `output` or `error`.
901 - */
902 -
903 -function createBatch() {
904 - let processor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultProcessor;
905 - let lastId = 0;
906 - let queue = [];
907 - const pending = new ObservableSet();
908 - return {
909 - /**
910 - * Adds an input to the batch and returns a promise that is resolved or
911 - * rejected when the input is processed by `batch.run()`.
912 - *
913 - * You may also pass a thunk which allows inputs to be added
914 - * asychronously.
915 - *
916 - * ```
917 - * // Both are allowed:
918 - * batch.add( { path: '/v1/books', ... } );
919 - * batch.add( ( add ) => add( { path: '/v1/books', ... } ) );
920 - * ```
921 - *
922 - * If a thunk is passed, `batch.run()` will pause until either:
923 - *
924 - * - The thunk calls its `add` argument, or;
925 - * - The thunk returns a promise and that promise resolves, or;
926 - * - The thunk returns a non-promise.
927 - *
928 - * @param {any|Function} inputOrThunk Input to add or thunk to execute.
929 - *
930 - * @return {Promise|any} If given an input, returns a promise that
931 - * is resolved or rejected when the batch is
932 - * processed. If given a thunk, returns the return
933 - * value of that thunk.
934 - */
935 - add(inputOrThunk) {
936 - const id = ++lastId;
937 - pending.add(id);
938 -
939 - const add = input => new Promise((resolve, reject) => {
940 - queue.push({
941 - input,
942 - resolve,
943 - reject
944 - });
945 - pending.delete(id);
946 - });
947 -
948 - if ((0,external_lodash_namespaceObject.isFunction)(inputOrThunk)) {
949 - return Promise.resolve(inputOrThunk(add)).finally(() => {
950 - pending.delete(id);
951 - });
952 - }
953 -
954 - return add(inputOrThunk);
955 - },
956 -
957 - /**
958 - * Runs the batch. This calls `batchProcessor` and resolves or rejects
959 - * all promises returned by `add()`.
960 - *
961 - * @return {Promise} A promise that resolves to a boolean that is true
962 - * if the processor returned no errors.
963 - */
964 - async run() {
965 - if (pending.size) {
966 - await new Promise(resolve => {
967 - const unsubscribe = pending.subscribe(() => {
968 - if (!pending.size) {
969 - unsubscribe();
970 - resolve();
971 - }
972 - });
973 - });
974 - }
975 -
976 - let results;
977 -
978 - try {
979 - results = await processor(queue.map(_ref => {
980 - let {
981 - input
982 - } = _ref;
983 - return input;
984 - }));
985 -
986 - if (results.length !== queue.length) {
987 - throw new Error('run: Array returned by processor must be same size as input array.');
988 - }
989 - } catch (error) {
990 - for (const {
991 - reject
992 - } of queue) {
993 - reject(error);
994 - }
995 -
996 - throw error;
997 - }
998 -
999 - let isSuccess = true;
1000 -
1001 - for (const [result, {
1002 - resolve,
1003 - reject
1004 - }] of (0,external_lodash_namespaceObject.zip)(results, queue)) {
1005 - if (result !== null && result !== void 0 && result.error) {
1006 - reject(result.error);
1007 - isSuccess = false;
1008 - } else {
1009 - var _result$output;
1010 -
1011 - resolve((_result$output = result === null || result === void 0 ? void 0 : result.output) !== null && _result$output !== void 0 ? _result$output : result);
1012 - }
1013 - }
1014 -
1015 - queue = [];
1016 - return isSuccess;
1017 - }
1018 -
1019 - };
1020 -}
1021 -
1022 -class ObservableSet {
1023 - constructor() {
1024 - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1025 - args[_key] = arguments[_key];
1026 - }
1027 -
1028 - this.set = new Set(...args);
1029 - this.subscribers = new Set();
1030 - }
1031 -
1032 - get size() {
1033 - return this.set.size;
1034 - }
1035 -
1036 - add() {
1037 - this.set.add(...arguments);
1038 - this.subscribers.forEach(subscriber => subscriber());
1039 - return this;
1040 - }
1041 -
1042 - delete() {
1043 - const isSuccess = this.set.delete(...arguments);
1044 - this.subscribers.forEach(subscriber => subscriber());
1045 - return isSuccess;
1046 - }
1047 -
1048 - subscribe(subscriber) {
1049 - this.subscribers.add(subscriber);
1050 - return () => {
1051 - this.subscribers.delete(subscriber);
1052 - };
1053 - }
1054 -
1055 -}
1056 -//# sourceMappingURL=create-batch.js.map
1057 -;// CONCATENATED MODULE: ./packages/core-data/build-module/name.js
1058 -/**
1059 - * The reducer key used by core data in store registration.
1060 - * This is defined in a separate file to avoid cycle-dependency
1061 - *
1062 - * @type {string}
1063 - */
1064 -const STORE_NAME = 'core';
1065 -//# sourceMappingURL=name.js.map
1066 -;// CONCATENATED MODULE: ./packages/core-data/build-module/actions.js
1067 -/**
1068 - * External dependencies
1069 - */
1070 -
1071 -
1072 -/**
1073 - * WordPress dependencies
1074 - */
1075 -
1076 -
1077 -
1078 -
1079 -/**
1080 - * Internal dependencies
1081 - */
1082 -
1083 -
1084 -
1085 -
1086 -
1087 -/**
1088 - * Returns an action object used in signalling that authors have been received.
1089 - *
1090 - * @param {string} queryID Query ID.
1091 - * @param {Array|Object} users Users received.
1092 - *
1093 - * @return {Object} Action object.
1094 - */
1095 -
1096 -function receiveUserQuery(queryID, users) {
1097 - return {
1098 - type: 'RECEIVE_USER_QUERY',
1099 - users: (0,external_lodash_namespaceObject.castArray)(users),
1100 - queryID
1101 - };
1102 -}
1103 -/**
1104 - * Returns an action used in signalling that the current user has been received.
1105 - *
1106 - * @param {Object} currentUser Current user object.
1107 - *
1108 - * @return {Object} Action object.
1109 - */
1110 -
1111 -function receiveCurrentUser(currentUser) {
1112 - return {
1113 - type: 'RECEIVE_CURRENT_USER',
1114 - currentUser
1115 - };
1116 -}
1117 -/**
1118 - * Returns an action object used in adding new entities.
1119 - *
1120 - * @param {Array} entities Entities received.
1121 - *
1122 - * @return {Object} Action object.
1123 - */
1124 -
1125 -function addEntities(entities) {
1126 - return {
1127 - type: 'ADD_ENTITIES',
1128 - entities
1129 - };
1130 -}
1131 -/**
1132 - * Returns an action object used in signalling that entity records have been received.
1133 - *
1134 - * @param {string} kind Kind of the received entity.
1135 - * @param {string} name Name of the received entity.
1136 - * @param {Array|Object} records Records received.
1137 - * @param {?Object} query Query Object.
1138 - * @param {?boolean} invalidateCache Should invalidate query caches.
1139 - * @param {?Object} edits Edits to reset.
1140 - * @return {Object} Action object.
1141 - */
1142 -
1143 -function receiveEntityRecords(kind, name, records, query) {
1144 - let invalidateCache = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
1145 - let edits = arguments.length > 5 ? arguments[5] : undefined;
1146 -
1147 - // Auto drafts should not have titles, but some plugins rely on them so we can't filter this
1148 - // on the server.
1149 - if (kind === 'postType') {
1150 - records = (0,external_lodash_namespaceObject.castArray)(records).map(record => record.status === 'auto-draft' ? { ...record,
1151 - title: ''
1152 - } : record);
1153 - }
1154 -
1155 - let action;
1156 -
1157 - if (query) {
1158 - action = receiveQueriedItems(records, query, edits);
1159 - } else {
1160 - action = receiveItems(records, edits);
1161 - }
1162 -
1163 - return { ...action,
1164 - kind,
1165 - name,
1166 - invalidateCache
1167 - };
1168 -}
1169 -/**
1170 - * Returns an action object used in signalling that the current theme has been received.
1171 - *
1172 - * @param {Object} currentTheme The current theme.
1173 - *
1174 - * @return {Object} Action object.
1175 - */
1176 -
1177 -function receiveCurrentTheme(currentTheme) {
1178 - return {
1179 - type: 'RECEIVE_CURRENT_THEME',
1180 - currentTheme
1181 - };
1182 -}
1183 -/**
1184 - * Returns an action object used in signalling that the current global styles id has been received.
1185 - *
1186 - * @param {string} currentGlobalStylesId The current global styles id.
1187 - *
1188 - * @return {Object} Action object.
1189 - */
1190 -
1191 -function __experimentalReceiveCurrentGlobalStylesId(currentGlobalStylesId) {
1192 - return {
1193 - type: 'RECEIVE_CURRENT_GLOBAL_STYLES_ID',
1194 - id: currentGlobalStylesId
1195 - };
1196 -}
1197 -/**
1198 - * Returns an action object used in signalling that the theme base global styles have been received
1199 - *
1200 - * @param {string} stylesheet The theme's identifier
1201 - * @param {Object} globalStyles The global styles object.
1202 - *
1203 - * @return {Object} Action object.
1204 - */
1205 -
1206 -function __experimentalReceiveThemeBaseGlobalStyles(stylesheet, globalStyles) {
1207 - return {
1208 - type: 'RECEIVE_THEME_GLOBAL_STYLES',
1209 - stylesheet,
1210 - globalStyles
1211 - };
1212 -}
1213 -/**
1214 - * Returns an action object used in signalling that the theme global styles variations have been received.
1215 - *
1216 - * @param {string} stylesheet The theme's identifier
1217 - * @param {Array} variations The global styles variations.
1218 - *
1219 - * @return {Object} Action object.
1220 - */
1221 -
1222 -function __experimentalReceiveThemeGlobalStyleVariations(stylesheet, variations) {
1223 - return {
1224 - type: 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS',
1225 - stylesheet,
1226 - variations
1227 - };
1228 -}
1229 -/**
1230 - * Returns an action object used in signalling that the index has been received.
1231 - *
1232 - * @deprecated since WP 5.9, this is not useful anymore, use the selector direclty.
1233 - *
1234 - * @return {Object} Action object.
1235 - */
1236 -
1237 -function receiveThemeSupports() {
1238 - external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveThemeSupports", {
1239 - since: '5.9'
1240 - });
1241 - return {
1242 - type: 'DO_NOTHING'
1243 - };
1244 -}
1245 -/**
1246 - * Returns an action object used in signalling that the preview data for
1247 - * a given URl has been received.
1248 - *
1249 - * @param {string} url URL to preview the embed for.
1250 - * @param {*} preview Preview data.
1251 - *
1252 - * @return {Object} Action object.
1253 - */
1254 -
1255 -function receiveEmbedPreview(url, preview) {
1256 - return {
1257 - type: 'RECEIVE_EMBED_PREVIEW',
1258 - url,
1259 - preview
1260 - };
1261 -}
1262 -/**
1263 - * Action triggered to delete an entity record.
1264 - *
1265 - * @param {string} kind Kind of the deleted entity.
1266 - * @param {string} name Name of the deleted entity.
1267 - * @param {string} recordId Record ID of the deleted entity.
1268 - * @param {?Object} query Special query parameters for the
1269 - * DELETE API call.
1270 - * @param {Object} [options] Delete options.
1271 - * @param {Function} [options.__unstableFetch] Internal use only. Function to
1272 - * call instead of `apiFetch()`.
1273 - * Must return a promise.
1274 - */
1275 -
1276 -const deleteEntityRecord = function (kind, name, recordId, query) {
1277 - let {
1278 - __unstableFetch = (external_wp_apiFetch_default())
1279 - } = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
1280 - return async _ref => {
1281 - let {
1282 - dispatch
1283 - } = _ref;
1284 - const entities = await dispatch(getKindEntities(kind));
1285 - const entity = (0,external_lodash_namespaceObject.find)(entities, {
1286 - kind,
1287 - name
1288 - });
1289 - let error;
1290 - let deletedRecord = false;
1291 -
1292 - if (!entity || entity !== null && entity !== void 0 && entity.__experimentalNoFetch) {
1293 - return;
1294 - }
1295 -
1296 - const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'data', kind, name, recordId], {
1297 - exclusive: true
1298 - });
1299 -
1300 - try {
1301 - dispatch({
1302 - type: 'DELETE_ENTITY_RECORD_START',
1303 - kind,
1304 - name,
1305 - recordId
1306 - });
1307 -
1308 - try {
1309 - let path = `${entity.baseURL}/${recordId}`;
1310 -
1311 - if (query) {
1312 - path = (0,external_wp_url_namespaceObject.addQueryArgs)(path, query);
1313 - }
1314 -
1315 - deletedRecord = await __unstableFetch({
1316 - path,
1317 - method: 'DELETE'
1318 - });
1319 - await dispatch(removeItems(kind, name, recordId, true));
1320 - } catch (_error) {
1321 - error = _error;
1322 - }
1323 -
1324 - dispatch({
1325 - type: 'DELETE_ENTITY_RECORD_FINISH',
1326 - kind,
1327 - name,
1328 - recordId,
1329 - error
1330 - });
1331 - return deletedRecord;
1332 - } finally {
1333 - dispatch.__unstableReleaseStoreLock(lock);
1334 - }
1335 - };
1336 -};
1337 -/**
1338 - * Returns an action object that triggers an
1339 - * edit to an entity record.
1340 - *
1341 - * @param {string} kind Kind of the edited entity record.
1342 - * @param {string} name Name of the edited entity record.
1343 - * @param {number} recordId Record ID of the edited entity record.
1344 - * @param {Object} edits The edits.
1345 - * @param {Object} options Options for the edit.
1346 - * @param {boolean} options.undoIgnore Whether to ignore the edit in undo history or not.
1347 - *
1348 - * @return {Object} Action object.
1349 - */
1350 -
1351 -const editEntityRecord = function (kind, name, recordId, edits) {
1352 - let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
1353 - return _ref2 => {
1354 - let {
1355 - select,
1356 - dispatch
1357 - } = _ref2;
1358 - const entity = select.getEntity(kind, name);
1359 -
1360 - if (!entity) {
1361 - throw new Error(`The entity being edited (${kind}, ${name}) does not have a loaded config.`);
1362 - }
1363 -
1364 - const {
1365 - transientEdits = {},
1366 - mergedEdits = {}
1367 - } = entity;
1368 - const record = select.getRawEntityRecord(kind, name, recordId);
1369 - const editedRecord = select.getEditedEntityRecord(kind, name, recordId);
1370 - const edit = {
1371 - kind,
1372 - name,
1373 - recordId,
1374 - // Clear edits when they are equal to their persisted counterparts
1375 - // so that the property is not considered dirty.
1376 - edits: Object.keys(edits).reduce((acc, key) => {
1377 - const recordValue = record[key];
1378 - const editedRecordValue = editedRecord[key];
1379 - const value = mergedEdits[key] ? { ...editedRecordValue,
1380 - ...edits[key]
1381 - } : edits[key];
1382 - acc[key] = (0,external_lodash_namespaceObject.isEqual)(recordValue, value) ? undefined : value;
1383 - return acc;
1384 - }, {}),
1385 - transientEdits
1386 - };
1387 - dispatch({
1388 - type: 'EDIT_ENTITY_RECORD',
1389 - ...edit,
1390 - meta: {
1391 - undo: !options.undoIgnore && { ...edit,
1392 - // Send the current values for things like the first undo stack entry.
1393 - edits: Object.keys(edits).reduce((acc, key) => {
1394 - acc[key] = editedRecord[key];
1395 - return acc;
1396 - }, {})
1397 - }
1398 - }
1399 - });
1400 - };
1401 -};
1402 -/**
1403 - * Action triggered to undo the last edit to
1404 - * an entity record, if any.
1405 - *
1406 - * @return {undefined}
1407 - */
1408 -
1409 -const undo = () => _ref3 => {
1410 - let {
1411 - select,
1412 - dispatch
1413 - } = _ref3;
1414 - const undoEdit = select.getUndoEdit();
1415 -
1416 - if (!undoEdit) {
1417 - return;
1418 - }
1419 -
1420 - dispatch({
1421 - type: 'EDIT_ENTITY_RECORD',
1422 - ...undoEdit,
1423 - meta: {
1424 - isUndo: true
1425 - }
1426 - });
1427 -};
1428 -/**
1429 - * Action triggered to redo the last undoed
1430 - * edit to an entity record, if any.
1431 - *
1432 - * @return {undefined}
1433 - */
1434 -
1435 -const redo = () => _ref4 => {
1436 - let {
1437 - select,
1438 - dispatch
1439 - } = _ref4;
1440 - const redoEdit = select.getRedoEdit();
1441 -
1442 - if (!redoEdit) {
1443 - return;
1444 - }
1445 -
1446 - dispatch({
1447 - type: 'EDIT_ENTITY_RECORD',
1448 - ...redoEdit,
1449 - meta: {
1450 - isRedo: true
1451 - }
1452 - });
1453 -};
1454 -/**
1455 - * Forces the creation of a new undo level.
1456 - *
1457 - * @return {Object} Action object.
1458 - */
1459 -
1460 -function __unstableCreateUndoLevel() {
1461 - return {
1462 - type: 'CREATE_UNDO_LEVEL'
1463 - };
1464 -}
1465 -/**
1466 - * Action triggered to save an entity record.
1467 - *
1468 - * @param {string} kind Kind of the received entity.
1469 - * @param {string} name Name of the received entity.
1470 - * @param {Object} record Record to be saved.
1471 - * @param {Object} options Saving options.
1472 - * @param {boolean} [options.isAutosave=false] Whether this is an autosave.
1473 - * @param {Function} [options.__unstableFetch] Internal use only. Function to
1474 - * call instead of `apiFetch()`.
1475 - * Must return a promise.
1476 - */
1477 -
1478 -const saveEntityRecord = function (kind, name, record) {
1479 - let {
1480 - isAutosave = false,
1481 - __unstableFetch = (external_wp_apiFetch_default())
1482 - } = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1483 - return async _ref5 => {
1484 - let {
1485 - select,
1486 - resolveSelect,
1487 - dispatch
1488 - } = _ref5;
1489 - const entities = await dispatch(getKindEntities(kind));
1490 - const entity = (0,external_lodash_namespaceObject.find)(entities, {
1491 - kind,
1492 - name
1493 - });
1494 -
1495 - if (!entity || entity !== null && entity !== void 0 && entity.__experimentalNoFetch) {
1496 - return;
1497 - }
1498 -
1499 - const entityIdKey = entity.key || DEFAULT_ENTITY_KEY;
1500 - const recordId = record[entityIdKey];
1501 - const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'data', kind, name, recordId || esm_browser_v4()], {
1502 - exclusive: true
1503 - });
1504 -
1505 - try {
1506 - // Evaluate optimized edits.
1507 - // (Function edits that should be evaluated on save to avoid expensive computations on every edit.)
1508 - for (const [key, value] of Object.entries(record)) {
1509 - if (typeof value === 'function') {
1510 - const evaluatedValue = value(select.getEditedEntityRecord(kind, name, recordId));
1511 - dispatch.editEntityRecord(kind, name, recordId, {
1512 - [key]: evaluatedValue
1513 - }, {
1514 - undoIgnore: true
1515 - });
1516 - record[key] = evaluatedValue;
1517 - }
1518 - }
1519 -
1520 - dispatch({
1521 - type: 'SAVE_ENTITY_RECORD_START',
1522 - kind,
1523 - name,
1524 - recordId,
1525 - isAutosave
1526 - });
1527 - let updatedRecord;
1528 - let error;
1529 -
1530 - try {
1531 - const path = `${entity.baseURL}${recordId ? '/' + recordId : ''}`;
1532 - const persistedRecord = select.getRawEntityRecord(kind, name, recordId);
1533 -
1534 - if (isAutosave) {
1535 - // Most of this autosave logic is very specific to posts.
1536 - // This is fine for now as it is the only supported autosave,
1537 - // but ideally this should all be handled in the back end,
1538 - // so the client just sends and receives objects.
1539 - const currentUser = select.getCurrentUser();
1540 - const currentUserId = currentUser ? currentUser.id : undefined;
1541 - const autosavePost = resolveSelect.getAutosave(persistedRecord.type, persistedRecord.id, currentUserId); // Autosaves need all expected fields to be present.
1542 - // So we fallback to the previous autosave and then
1543 - // to the actual persisted entity if the edits don't
1544 - // have a value.
1545 -
1546 - let data = { ...persistedRecord,
1547 - ...autosavePost,
1548 - ...record
1549 - };
1550 - data = Object.keys(data).reduce((acc, key) => {
1551 - if (['title', 'excerpt', 'content'].includes(key)) {
1552 - acc[key] = data[key];
1553 - }
1554 -
1555 - return acc;
1556 - }, {
1557 - status: data.status === 'auto-draft' ? 'draft' : data.status
1558 - });
1559 - updatedRecord = await __unstableFetch({
1560 - path: `${path}/autosaves`,
1561 - method: 'POST',
1562 - data
1563 - }); // An autosave may be processed by the server as a regular save
1564 - // when its update is requested by the author and the post had
1565 - // draft or auto-draft status.
1566 -
1567 - if (persistedRecord.id === updatedRecord.id) {
1568 - let newRecord = { ...persistedRecord,
1569 - ...data,
1570 - ...updatedRecord
1571 - };
1572 - newRecord = Object.keys(newRecord).reduce((acc, key) => {
1573 - // These properties are persisted in autosaves.
1574 - if (['title', 'excerpt', 'content'].includes(key)) {
1575 - acc[key] = newRecord[key];
1576 - } else if (key === 'status') {
1577 - // Status is only persisted in autosaves when going from
1578 - // "auto-draft" to "draft".
1579 - acc[key] = persistedRecord.status === 'auto-draft' && newRecord.status === 'draft' ? newRecord.status : persistedRecord.status;
1580 - } else {
1581 - // These properties are not persisted in autosaves.
1582 - acc[key] = persistedRecord[key];
1583 - }
1584 -
1585 - return acc;
1586 - }, {});
1587 - dispatch.receiveEntityRecords(kind, name, newRecord, undefined, true);
1588 - } else {
1589 - dispatch.receiveAutosaves(persistedRecord.id, updatedRecord);
1590 - }
1591 - } else {
1592 - let edits = record;
1593 -
1594 - if (entity.__unstablePrePersist) {
1595 - edits = { ...edits,
1596 - ...entity.__unstablePrePersist(persistedRecord, edits)
1597 - };
1598 - }
1599 -
1600 - updatedRecord = await __unstableFetch({
1601 - path,
1602 - method: recordId ? 'PUT' : 'POST',
1603 - data: edits
1604 - });
1605 - dispatch.receiveEntityRecords(kind, name, updatedRecord, undefined, true, edits);
1606 - }
1607 - } catch (_error) {
1608 - error = _error;
1609 - }
1610 -
1611 - dispatch({
1612 - type: 'SAVE_ENTITY_RECORD_FINISH',
1613 - kind,
1614 - name,
1615 - recordId,
1616 - error,
1617 - isAutosave
1618 - });
1619 - return updatedRecord;
1620 - } finally {
1621 - dispatch.__unstableReleaseStoreLock(lock);
1622 - }
1623 - };
1624 -};
1625 -/**
1626 - * Runs multiple core-data actions at the same time using one API request.
1627 - *
1628 - * Example:
1629 - *
1630 - * ```
1631 - * const [ savedRecord, updatedRecord, deletedRecord ] =
1632 - * await dispatch( 'core' ).__experimentalBatch( [
1633 - * ( { saveEntityRecord } ) => saveEntityRecord( 'root', 'widget', widget ),
1634 - * ( { saveEditedEntityRecord } ) => saveEntityRecord( 'root', 'widget', 123 ),
1635 - * ( { deleteEntityRecord } ) => deleteEntityRecord( 'root', 'widget', 123, null ),
1636 - * ] );
1637 - * ```
1638 - *
1639 - * @param {Array} requests Array of functions which are invoked simultaneously.
1640 - * Each function is passed an object containing
1641 - * `saveEntityRecord`, `saveEditedEntityRecord`, and
1642 - * `deleteEntityRecord`.
1643 - *
1644 - * @return {Promise} A promise that resolves to an array containing the return
1645 - * values of each function given in `requests`.
1646 - */
1647 -
1648 -const __experimentalBatch = requests => async _ref6 => {
1649 - let {
1650 - dispatch
1651 - } = _ref6;
1652 - const batch = createBatch();
1653 - const api = {
1654 - saveEntityRecord(kind, name, record, options) {
1655 - return batch.add(add => dispatch.saveEntityRecord(kind, name, record, { ...options,
1656 - __unstableFetch: add
1657 - }));
1658 - },
1659 -
1660 - saveEditedEntityRecord(kind, name, recordId, options) {
1661 - return batch.add(add => dispatch.saveEditedEntityRecord(kind, name, recordId, { ...options,
1662 - __unstableFetch: add
1663 - }));
1664 - },
1665 -
1666 - deleteEntityRecord(kind, name, recordId, query, options) {
1667 - return batch.add(add => dispatch.deleteEntityRecord(kind, name, recordId, query, { ...options,
1668 - __unstableFetch: add
1669 - }));
1670 - }
1671 -
1672 - };
1673 - const resultPromises = requests.map(request => request(api));
1674 - const [, ...results] = await Promise.all([batch.run(), ...resultPromises]);
1675 - return results;
1676 -};
1677 -/**
1678 - * Action triggered to save an entity record's edits.
1679 - *
1680 - * @param {string} kind Kind of the entity.
1681 - * @param {string} name Name of the entity.
1682 - * @param {Object} recordId ID of the record.
1683 - * @param {Object} options Saving options.
1684 - */
1685 -
1686 -const saveEditedEntityRecord = (kind, name, recordId, options) => async _ref7 => {
1687 - let {
1688 - select,
1689 - dispatch
1690 - } = _ref7;
1691 -
1692 - if (!select.hasEditsForEntityRecord(kind, name, recordId)) {
1693 - return;
1694 - }
1695 -
1696 - const entities = await dispatch(getKindEntities(kind));
1697 - const entity = (0,external_lodash_namespaceObject.find)(entities, {
1698 - kind,
1699 - name
1700 - });
1701 -
1702 - if (!entity) {
1703 - return;
1704 - }
1705 -
1706 - const entityIdKey = entity.key || DEFAULT_ENTITY_KEY;
1707 - const edits = select.getEntityRecordNonTransientEdits(kind, name, recordId);
1708 - const record = {
1709 - [entityIdKey]: recordId,
1710 - ...edits
1711 - };
1712 - return await dispatch.saveEntityRecord(kind, name, record, options);
1713 -};
1714 -/**
1715 - * Action triggered to save only specified properties for the entity.
1716 - *
1717 - * @param {string} kind Kind of the entity.
1718 - * @param {string} name Name of the entity.
1719 - * @param {Object} recordId ID of the record.
1720 - * @param {Array} itemsToSave List of entity properties to save.
1721 - * @param {Object} options Saving options.
1722 - */
1723 -
1724 -const __experimentalSaveSpecifiedEntityEdits = (kind, name, recordId, itemsToSave, options) => async _ref8 => {
1725 - let {
1726 - select,
1727 - dispatch
1728 - } = _ref8;
1729 -
1730 - if (!select.hasEditsForEntityRecord(kind, name, recordId)) {
1731 - return;
1732 - }
1733 -
1734 - const edits = select.getEntityRecordNonTransientEdits(kind, name, recordId);
1735 - const editsToSave = {};
1736 -
1737 - for (const edit in edits) {
1738 - if (itemsToSave.some(item => item === edit)) {
1739 - editsToSave[edit] = edits[edit];
1740 - }
1741 - }
1742 -
1743 - return await dispatch.saveEntityRecord(kind, name, editsToSave, options);
1744 -};
1745 -/**
1746 - * Returns an action object used in signalling that Upload permissions have been received.
1747 - *
1748 - * @deprecated since WP 5.9, use receiveUserPermission instead.
1749 - *
1750 - * @param {boolean} hasUploadPermissions Does the user have permission to upload files?
1751 - *
1752 - * @return {Object} Action object.
1753 - */
1754 -
1755 -function receiveUploadPermissions(hasUploadPermissions) {
1756 - external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveUploadPermissions", {
1757 - since: '5.9',
1758 - alternative: 'receiveUserPermission'
1759 - });
1760 - return receiveUserPermission('create/media', hasUploadPermissions);
1761 -}
1762 -/**
1763 - * Returns an action object used in signalling that the current user has
1764 - * permission to perform an action on a REST resource.
1765 - *
1766 - * @param {string} key A key that represents the action and REST resource.
1767 - * @param {boolean} isAllowed Whether or not the user can perform the action.
1768 - *
1769 - * @return {Object} Action object.
1770 - */
1771 -
1772 -function receiveUserPermission(key, isAllowed) {
1773 - return {
1774 - type: 'RECEIVE_USER_PERMISSION',
1775 - key,
1776 - isAllowed
1777 - };
1778 -}
1779 -/**
1780 - * Returns an action object used in signalling that the autosaves for a
1781 - * post have been received.
1782 - *
1783 - * @param {number} postId The id of the post that is parent to the autosave.
1784 - * @param {Array|Object} autosaves An array of autosaves or singular autosave object.
1785 - *
1786 - * @return {Object} Action object.
1787 - */
1788 -
1789 -function receiveAutosaves(postId, autosaves) {
1790 - return {
1791 - type: 'RECEIVE_AUTOSAVES',
1792 - postId,
1793 - autosaves: (0,external_lodash_namespaceObject.castArray)(autosaves)
1794 - };
1795 -}
1796 -//# sourceMappingURL=actions.js.map
1797 -;// CONCATENATED MODULE: ./packages/core-data/build-module/entities.js
1798 -/**
1799 - * External dependencies
1800 - */
1801 -
1802 -/**
1803 - * WordPress dependencies
1804 - */
1805 -
1806 -
1807 -
1808 -/**
1809 - * Internal dependencies
1810 - */
1811 -
1812 -
1813 -const DEFAULT_ENTITY_KEY = 'id';
1814 -const POST_RAW_ATTRIBUTES = ['title', 'excerpt', 'content'];
1815 -const defaultEntities = [{
1816 - label: (0,external_wp_i18n_namespaceObject.__)('Base'),
1817 - name: '__unstableBase',
1818 - kind: 'root',
1819 - baseURL: '/'
1820 -}, {
1821 - label: (0,external_wp_i18n_namespaceObject.__)('Site'),
1822 - name: 'site',
1823 - kind: 'root',
1824 - baseURL: '/wp/v2/settings',
1825 - getTitle: record => {
1826 - return (0,external_lodash_namespaceObject.get)(record, ['title'], (0,external_wp_i18n_namespaceObject.__)('Site Title'));
1827 - }
1828 -}, {
1829 - label: (0,external_wp_i18n_namespaceObject.__)('Post Type'),
1830 - name: 'postType',
1831 - kind: 'root',
1832 - key: 'slug',
1833 - baseURL: '/wp/v2/types',
1834 - baseURLParams: {
1835 - context: 'edit'
1836 - },
1837 - rawAttributes: POST_RAW_ATTRIBUTES
1838 -}, {
1839 - name: 'media',
1840 - kind: 'root',
1841 - baseURL: '/wp/v2/media',
1842 - baseURLParams: {
1843 - context: 'edit'
1844 - },
1845 - plural: 'mediaItems',
1846 - label: (0,external_wp_i18n_namespaceObject.__)('Media')
1847 -}, {
1848 - name: 'taxonomy',
1849 - kind: 'root',
1850 - key: 'slug',
1851 - baseURL: '/wp/v2/taxonomies',
1852 - baseURLParams: {
1853 - context: 'edit'
1854 - },
1855 - plural: 'taxonomies',
1856 - label: (0,external_wp_i18n_namespaceObject.__)('Taxonomy')
1857 -}, {
1858 - name: 'sidebar',
1859 - kind: 'root',
1860 - baseURL: '/wp/v2/sidebars',
1861 - plural: 'sidebars',
1862 - transientEdits: {
1863 - blocks: true
1864 - },
1865 - label: (0,external_wp_i18n_namespaceObject.__)('Widget areas')
1866 -}, {
1867 - name: 'widget',
1868 - kind: 'root',
1869 - baseURL: '/wp/v2/widgets',
1870 - baseURLParams: {
1871 - context: 'edit'
1872 - },
1873 - plural: 'widgets',
1874 - transientEdits: {
1875 - blocks: true
1876 - },
1877 - label: (0,external_wp_i18n_namespaceObject.__)('Widgets')
1878 -}, {
1879 - name: 'widgetType',
1880 - kind: 'root',
1881 - baseURL: '/wp/v2/widget-types',
1882 - baseURLParams: {
1883 - context: 'edit'
1884 - },
1885 - plural: 'widgetTypes',
1886 - label: (0,external_wp_i18n_namespaceObject.__)('Widget types')
1887 -}, {
1888 - label: (0,external_wp_i18n_namespaceObject.__)('User'),
1889 - name: 'user',
1890 - kind: 'root',
1891 - baseURL: '/wp/v2/users',
1892 - baseURLParams: {
1893 - context: 'edit'
1894 - },
1895 - plural: 'users'
1896 -}, {
1897 - name: 'comment',
1898 - kind: 'root',
1899 - baseURL: '/wp/v2/comments',
1900 - baseURLParams: {
1901 - context: 'edit'
1902 - },
1903 - plural: 'comments',
1904 - label: (0,external_wp_i18n_namespaceObject.__)('Comment')
1905 -}, {
1906 - name: 'menu',
1907 - kind: 'root',
1908 - baseURL: '/wp/v2/menus',
1909 - baseURLParams: {
1910 - context: 'edit'
1911 - },
1912 - plural: 'menus',
1913 - label: (0,external_wp_i18n_namespaceObject.__)('Menu')
1914 -}, {
1915 - name: 'menuItem',
1916 - kind: 'root',
1917 - baseURL: '/wp/v2/menu-items',
1918 - baseURLParams: {
1919 - context: 'edit'
1920 - },
1921 - plural: 'menuItems',
1922 - label: (0,external_wp_i18n_namespaceObject.__)('Menu Item'),
1923 - rawAttributes: ['title', 'content']
1924 -}, {
1925 - name: 'menuLocation',
1926 - kind: 'root',
1927 - baseURL: '/wp/v2/menu-locations',
1928 - baseURLParams: {
1929 - context: 'edit'
1930 - },
1931 - plural: 'menuLocations',
1932 - label: (0,external_wp_i18n_namespaceObject.__)('Menu Location'),
1933 - key: 'name'
1934 -}, {
1935 - name: 'navigationArea',
1936 - kind: 'root',
1937 - baseURL: '/wp/v2/block-navigation-areas',
1938 - baseURLParams: {
1939 - context: 'edit'
1940 - },
1941 - plural: 'navigationAreas',
1942 - label: (0,external_wp_i18n_namespaceObject.__)('Navigation Area'),
1943 - key: 'name',
1944 - getTitle: record => record === null || record === void 0 ? void 0 : record.description
1945 -}, {
1946 - label: (0,external_wp_i18n_namespaceObject.__)('Global Styles'),
1947 - name: 'globalStyles',
1948 - kind: 'root',
1949 - baseURL: '/wp/v2/global-styles',
1950 - baseURLParams: {
1951 - context: 'edit'
1952 - },
1953 - plural: 'globalStylesVariations',
1954 - // should be different than name
1955 - getTitle: record => {
1956 - var _record$title;
1957 -
1958 - return (record === null || record === void 0 ? void 0 : (_record$title = record.title) === null || _record$title === void 0 ? void 0 : _record$title.rendered) || (record === null || record === void 0 ? void 0 : record.title);
1959 - }
1960 -}, {
1961 - label: (0,external_wp_i18n_namespaceObject.__)('Themes'),
1962 - name: 'theme',
1963 - kind: 'root',
1964 - baseURL: '/wp/v2/themes',
1965 - baseURLParams: {
1966 - context: 'edit'
1967 - },
1968 - key: 'stylesheet'
1969 -}, {
1970 - label: (0,external_wp_i18n_namespaceObject.__)('Plugins'),
1971 - name: 'plugin',
1972 - kind: 'root',
1973 - baseURL: '/wp/v2/plugins',
1974 - baseURLParams: {
1975 - context: 'edit'
1976 - },
1977 - key: 'plugin'
1978 -}];
1979 -const kinds = [{
1980 - name: 'postType',
1981 - loadEntities: loadPostTypeEntities
1982 -}, {
1983 - name: 'taxonomy',
1984 - loadEntities: loadTaxonomyEntities
1985 -}];
1986 -/**
1987 - * Returns a function to be used to retrieve extra edits to apply before persisting a post type.
1988 - *
1989 - * @param {Object} persistedRecord Already persisted Post
1990 - * @param {Object} edits Edits.
1991 - * @return {Object} Updated edits.
1992 - */
1993 -
1994 -const prePersistPostType = (persistedRecord, edits) => {
1995 - const newEdits = {};
1996 -
1997 - if ((persistedRecord === null || persistedRecord === void 0 ? void 0 : persistedRecord.status) === 'auto-draft') {
1998 - // Saving an auto-draft should create a draft by default.
1999 - if (!edits.status && !newEdits.status) {
2000 - newEdits.status = 'draft';
2001 - } // Fix the auto-draft default title.
2002 -
2003 -
2004 - if ((!edits.title || edits.title === 'Auto Draft') && !newEdits.title && (!(persistedRecord !== null && persistedRecord !== void 0 && persistedRecord.title) || (persistedRecord === null || persistedRecord === void 0 ? void 0 : persistedRecord.title) === 'Auto Draft')) {
2005 - newEdits.title = '';
2006 - }
2007 - }
2008 -
2009 - return newEdits;
2010 -};
2011 -/**
2012 - * Returns the list of post type entities.
2013 - *
2014 - * @return {Promise} Entities promise
2015 - */
2016 -
2017 -async function loadPostTypeEntities() {
2018 - const postTypes = await external_wp_apiFetch_default()({
2019 - path: '/wp/v2/types?context=view'
2020 - });
2021 - return (0,external_lodash_namespaceObject.map)(postTypes, (postType, name) => {
2022 - var _postType$rest_namesp;
2023 -
2024 - const isTemplate = ['wp_template', 'wp_template_part'].includes(name);
2025 - const namespace = (_postType$rest_namesp = postType === null || postType === void 0 ? void 0 : postType.rest_namespace) !== null && _postType$rest_namesp !== void 0 ? _postType$rest_namesp : 'wp/v2';
2026 - return {
2027 - kind: 'postType',
2028 - baseURL: `/${namespace}/${postType.rest_base}`,
2029 - baseURLParams: {
2030 - context: 'edit'
2031 - },
2032 - name,
2033 - label: postType.name,
2034 - transientEdits: {
2035 - blocks: true,
2036 - selection: true
2037 - },
2038 - mergedEdits: {
2039 - meta: true
2040 - },
2041 - rawAttributes: POST_RAW_ATTRIBUTES,
2042 - getTitle: record => {
2043 - var _record$title2;
2044 -
2045 - return (record === null || record === void 0 ? void 0 : (_record$title2 = record.title) === null || _record$title2 === void 0 ? void 0 : _record$title2.rendered) || (record === null || record === void 0 ? void 0 : record.title) || (isTemplate ? (0,external_lodash_namespaceObject.startCase)(record.slug) : String(record.id));
2046 - },
2047 - __unstablePrePersist: isTemplate ? undefined : prePersistPostType,
2048 - __unstable_rest_base: postType.rest_base
2049 - };
2050 - });
2051 -}
2052 -/**
2053 - * Returns the list of the taxonomies entities.
2054 - *
2055 - * @return {Promise} Entities promise
2056 - */
2057 -
2058 -
2059 -async function loadTaxonomyEntities() {
2060 - const taxonomies = await external_wp_apiFetch_default()({
2061 - path: '/wp/v2/taxonomies?context=view'
2062 - });
2063 - return (0,external_lodash_namespaceObject.map)(taxonomies, (taxonomy, name) => {
2064 - var _taxonomy$rest_namesp;
2065 -
2066 - const namespace = (_taxonomy$rest_namesp = taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.rest_namespace) !== null && _taxonomy$rest_namesp !== void 0 ? _taxonomy$rest_namesp : 'wp/v2';
2067 - return {
2068 - kind: 'taxonomy',
2069 - baseURL: `/${namespace}/${taxonomy.rest_base}`,
2070 - baseURLParams: {
2071 - context: 'edit'
2072 - },
2073 - name,
2074 - label: taxonomy.name
2075 - };
2076 - });
2077 -}
2078 -/**
2079 - * Returns the entity's getter method name given its kind and name.
2080 - *
2081 - * @param {string} kind Entity kind.
2082 - * @param {string} name Entity name.
2083 - * @param {string} prefix Function prefix.
2084 - * @param {boolean} usePlural Whether to use the plural form or not.
2085 - *
2086 - * @return {string} Method name
2087 - */
2088 -
2089 -
2090 -const getMethodName = function (kind, name) {
2091 - let prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'get';
2092 - let usePlural = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
2093 - const entity = (0,external_lodash_namespaceObject.find)(defaultEntities, {
2094 - kind,
2095 - name
2096 - });
2097 - const kindPrefix = kind === 'root' ? '' : (0,external_lodash_namespaceObject.upperFirst)((0,external_lodash_namespaceObject.camelCase)(kind));
2098 - const nameSuffix = (0,external_lodash_namespaceObject.upperFirst)((0,external_lodash_namespaceObject.camelCase)(name)) + (usePlural ? 's' : '');
2099 - const suffix = usePlural && entity.plural ? (0,external_lodash_namespaceObject.upperFirst)((0,external_lodash_namespaceObject.camelCase)(entity.plural)) : nameSuffix;
2100 - return `${prefix}${kindPrefix}${suffix}`;
2101 -};
2102 -/**
2103 - * Loads the kind entities into the store.
2104 - *
2105 - * @param {string} kind Kind
2106 - *
2107 - * @return {Array} Entities
2108 - */
2109 -
2110 -const getKindEntities = kind => async _ref => {
2111 - let {
2112 - select,
2113 - dispatch
2114 - } = _ref;
2115 - let entities = select.getEntitiesByKind(kind);
2116 -
2117 - if (entities && entities.length !== 0) {
2118 - return entities;
2119 - }
2120 -
2121 - const kindConfig = (0,external_lodash_namespaceObject.find)(kinds, {
2122 - name: kind
2123 - });
2124 -
2125 - if (!kindConfig) {
2126 - return [];
2127 - }
2128 -
2129 - entities = await kindConfig.loadEntities();
2130 - dispatch(addEntities(entities));
2131 - return entities;
2132 -};
2133 -//# sourceMappingURL=entities.js.map
2134 -;// CONCATENATED MODULE: ./packages/core-data/build-module/utils/get-normalized-comma-separable.js
2135 -/**
2136 - * Given a value which can be specified as one or the other of a comma-separated
2137 - * string or an array, returns a value normalized to an array of strings, or
2138 - * null if the value cannot be interpreted as either.
2139 - *
2140 - * @param {string|string[]|*} value
2141 - *
2142 - * @return {?(string[])} Normalized field value.
2143 - */
2144 -function getNormalizedCommaSeparable(value) {
2145 - if (typeof value === 'string') {
2146 - return value.split(',');
2147 - } else if (Array.isArray(value)) {
2148 - return value;
2149 - }
2150 -
2151 - return null;
2152 -}
2153 -
2154 -/* harmony default export */ var get_normalized_comma_separable = (getNormalizedCommaSeparable);
2155 -//# sourceMappingURL=get-normalized-comma-separable.js.map
2156 -;// CONCATENATED MODULE: ./packages/core-data/build-module/utils/with-weak-map-cache.js
2157 -/**
2158 - * External dependencies
2159 - */
2160 -
2161 -/**
2162 - * Given a function, returns an enhanced function which caches the result and
2163 - * tracks in WeakMap. The result is only cached if the original function is
2164 - * passed a valid object-like argument (requirement for WeakMap key).
2165 - *
2166 - * @param {Function} fn Original function.
2167 - *
2168 - * @return {Function} Enhanced caching function.
2169 - */
2170 -
2171 -function withWeakMapCache(fn) {
2172 - const cache = new WeakMap();
2173 - return key => {
2174 - let value;
2175 -
2176 - if (cache.has(key)) {
2177 - value = cache.get(key);
2178 - } else {
2179 - value = fn(key); // Can reach here if key is not valid for WeakMap, since `has`
2180 - // will return false for invalid key. Since `set` will throw,
2181 - // ensure that key is valid before setting into cache.
2182 -
2183 - if ((0,external_lodash_namespaceObject.isObjectLike)(key)) {
2184 - cache.set(key, value);
2185 - }
2186 - }
2187 -
2188 - return value;
2189 - };
2190 -}
2191 -
2192 -/* harmony default export */ var with_weak_map_cache = (withWeakMapCache);
2193 -//# sourceMappingURL=with-weak-map-cache.js.map
2194 -;// CONCATENATED MODULE: ./packages/core-data/build-module/queried-data/get-query-parts.js
2195 -/**
2196 - * WordPress dependencies
2197 - */
2198 -
2199 -/**
2200 - * Internal dependencies
2201 - */
2202 -
2203 -
2204 -/**
2205 - * An object of properties describing a specific query.
2206 - *
2207 - * @typedef {Object} WPQueriedDataQueryParts
2208 - *
2209 - * @property {number} page The query page (1-based index, default 1).
2210 - * @property {number} perPage Items per page for query (default 10).
2211 - * @property {string} stableKey An encoded stable string of all non-
2212 - * pagination, non-fields query parameters.
2213 - * @property {?(string[])} fields Target subset of fields to derive from
2214 - * item objects.
2215 - * @property {?(number[])} include Specific item IDs to include.
2216 - * @property {string} context Scope under which the request is made;
2217 - * determines returned fields in response.
2218 - */
2219 -
2220 -/**
2221 - * Given a query object, returns an object of parts, including pagination
2222 - * details (`page` and `perPage`, or default values). All other properties are
2223 - * encoded into a stable (idempotent) `stableKey` value.
2224 - *
2225 - * @param {Object} query Optional query object.
2226 - *
2227 - * @return {WPQueriedDataQueryParts} Query parts.
2228 - */
2229 -
2230 -function getQueryParts(query) {
2231 - /**
2232 - * @type {WPQueriedDataQueryParts}
2233 - */
2234 - const parts = {
2235 - stableKey: '',
2236 - page: 1,
2237 - perPage: 10,
2238 - fields: null,
2239 - include: null,
2240 - context: 'default'
2241 - }; // Ensure stable key by sorting keys. Also more efficient for iterating.
2242 -
2243 - const keys = Object.keys(query).sort();
2244 -
2245 - for (let i = 0; i < keys.length; i++) {
2246 - const key = keys[i];
2247 - let value = query[key];
2248 -
2249 - switch (key) {
2250 - case 'page':
2251 - parts[key] = Number(value);
2252 - break;
2253 -
2254 - case 'per_page':
2255 - parts.perPage = Number(value);
2256 - break;
2257 -
2258 - case 'context':
2259 - parts.context = value;
2260 - break;
2261 -
2262 - default:
2263 - // While in theory, we could exclude "_fields" from the stableKey
2264 - // because two request with different fields have the same results
2265 - // We're not able to ensure that because the server can decide to omit
2266 - // fields from the response even if we explicitely asked for it.
2267 - // Example: Asking for titles in posts without title support.
2268 - if (key === '_fields') {
2269 - parts.fields = get_normalized_comma_separable(value); // Make sure to normalize value for `stableKey`
2270 -
2271 - value = parts.fields.join();
2272 - } // Two requests with different include values cannot have same results.
2273 -
2274 -
2275 - if (key === 'include') {
2276 - parts.include = get_normalized_comma_separable(value).map(Number); // Normalize value for `stableKey`.
2277 -
2278 - value = parts.include.join();
2279 - } // While it could be any deterministic string, for simplicity's
2280 - // sake mimic querystring encoding for stable key.
2281 - //
2282 - // TODO: For consistency with PHP implementation, addQueryArgs
2283 - // should accept a key value pair, which may optimize its
2284 - // implementation for our use here, vs. iterating an object
2285 - // with only a single key.
2286 -
2287 -
2288 - parts.stableKey += (parts.stableKey ? '&' : '') + (0,external_wp_url_namespaceObject.addQueryArgs)('', {
2289 - [key]: value
2290 - }).slice(1);
2291 - }
2292 - }
2293 -
2294 - return parts;
2295 -}
2296 -/* harmony default export */ var get_query_parts = (with_weak_map_cache(getQueryParts));
2297 -//# sourceMappingURL=get-query-parts.js.map
2298 -;// CONCATENATED MODULE: ./packages/core-data/build-module/queried-data/reducer.js
2299 -/**
2300 - * External dependencies
2301 - */
2302 -
2303 -/**
2304 - * WordPress dependencies
2305 - */
2306 -
2307 -
2308 -/**
2309 - * Internal dependencies
2310 - */
2311 -
2312 -
2313 -
2314 -
2315 -
2316 -function getContextFromAction(action) {
2317 - const {
2318 - query
2319 - } = action;
2320 -
2321 - if (!query) {
2322 - return 'default';
2323 - }
2324 -
2325 - const queryParts = get_query_parts(query);
2326 - return queryParts.context;
2327 -}
2328 -/**
2329 - * Returns a merged array of item IDs, given details of the received paginated
2330 - * items. The array is sparse-like with `undefined` entries where holes exist.
2331 - *
2332 - * @param {?Array<number>} itemIds Original item IDs (default empty array).
2333 - * @param {number[]} nextItemIds Item IDs to merge.
2334 - * @param {number} page Page of items merged.
2335 - * @param {number} perPage Number of items per page.
2336 - *
2337 - * @return {number[]} Merged array of item IDs.
2338 - */
2339 -
2340 -
2341 -function getMergedItemIds(itemIds, nextItemIds, page, perPage) {
2342 - const receivedAllIds = page === 1 && perPage === -1;
2343 -
2344 - if (receivedAllIds) {
2345 - return nextItemIds;
2346 - }
2347 -
2348 - const nextItemIdsStartIndex = (page - 1) * perPage; // If later page has already been received, default to the larger known
2349 - // size of the existing array, else calculate as extending the existing.
2350 -
2351 - const size = Math.max(itemIds.length, nextItemIdsStartIndex + nextItemIds.length); // Preallocate array since size is known.
2352 -
2353 - const mergedItemIds = new Array(size);
2354 -
2355 - for (let i = 0; i < size; i++) {
2356 - // Preserve existing item ID except for subset of range of next items.
2357 - const isInNextItemsRange = i >= nextItemIdsStartIndex && i < nextItemIdsStartIndex + nextItemIds.length;
2358 - mergedItemIds[i] = isInNextItemsRange ? nextItemIds[i - nextItemIdsStartIndex] : itemIds[i];
2359 - }
2360 -
2361 - return mergedItemIds;
2362 -}
2363 -/**
2364 - * Reducer tracking items state, keyed by ID. Items are assumed to be normal,
2365 - * where identifiers are common across all queries.
2366 - *
2367 - * @param {Object} state Current state.
2368 - * @param {Object} action Dispatched action.
2369 - *
2370 - * @return {Object} Next state.
2371 - */
2372 -
2373 -function items() {
2374 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2375 - let action = arguments.length > 1 ? arguments[1] : undefined;
2376 -
2377 - switch (action.type) {
2378 - case 'RECEIVE_ITEMS':
2379 - {
2380 - const context = getContextFromAction(action);
2381 - const key = action.key || DEFAULT_ENTITY_KEY;
2382 - return { ...state,
2383 - [context]: { ...state[context],
2384 - ...action.items.reduce((accumulator, value) => {
2385 - var _state$context;
2386 -
2387 - const itemId = value[key];
2388 - accumulator[itemId] = conservativeMapItem(state === null || state === void 0 ? void 0 : (_state$context = state[context]) === null || _state$context === void 0 ? void 0 : _state$context[itemId], value);
2389 - return accumulator;
2390 - }, {})
2391 - }
2392 - };
2393 - }
2394 -
2395 - case 'REMOVE_ITEMS':
2396 - return (0,external_lodash_namespaceObject.mapValues)(state, contextState => (0,external_lodash_namespaceObject.omit)(contextState, action.itemIds));
2397 - }
2398 -
2399 - return state;
2400 -}
2401 -/**
2402 - * Reducer tracking item completeness, keyed by ID. A complete item is one for
2403 - * which all fields are known. This is used in supporting `_fields` queries,
2404 - * where not all properties associated with an entity are necessarily returned.
2405 - * In such cases, completeness is used as an indication of whether it would be
2406 - * safe to use queried data for a non-`_fields`-limited request.
2407 - *
2408 - * @param {Object<string,boolean>} state Current state.
2409 - * @param {Object} action Dispatched action.
2410 - *
2411 - * @return {Object<string,boolean>} Next state.
2412 - */
2413 -
2414 -function itemIsComplete() {
2415 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2416 - let action = arguments.length > 1 ? arguments[1] : undefined;
2417 -
2418 - switch (action.type) {
2419 - case 'RECEIVE_ITEMS':
2420 - {
2421 - const context = getContextFromAction(action);
2422 - const {
2423 - query,
2424 - key = DEFAULT_ENTITY_KEY
2425 - } = action; // An item is considered complete if it is received without an associated
2426 - // fields query. Ideally, this would be implemented in such a way where the
2427 - // complete aggregate of all fields would satisfy completeness. Since the
2428 - // fields are not consistent across all entity types, this would require
2429 - // introspection on the REST schema for each entity to know which fields
2430 - // compose a complete item for that entity.
2431 -
2432 - const queryParts = query ? get_query_parts(query) : {};
2433 - const isCompleteQuery = !query || !Array.isArray(queryParts.fields);
2434 - return { ...state,
2435 - [context]: { ...state[context],
2436 - ...action.items.reduce((result, item) => {
2437 - var _state$context2;
2438 -
2439 - const itemId = item[key]; // Defer to completeness if already assigned. Technically the
2440 - // data may be outdated if receiving items for a field subset.
2441 -
2442 - result[itemId] = (state === null || state === void 0 ? void 0 : (_state$context2 = state[context]) === null || _state$context2 === void 0 ? void 0 : _state$context2[itemId]) || isCompleteQuery;
2443 - return result;
2444 - }, {})
2445 - }
2446 - };
2447 - }
2448 -
2449 - case 'REMOVE_ITEMS':
2450 - return (0,external_lodash_namespaceObject.mapValues)(state, contextState => (0,external_lodash_namespaceObject.omit)(contextState, action.itemIds));
2451 - }
2452 -
2453 - return state;
2454 -}
2455 -/**
2456 - * Reducer tracking queries state, keyed by stable query key. Each reducer
2457 - * query object includes `itemIds` and `requestingPageByPerPage`.
2458 - *
2459 - * @param {Object} state Current state.
2460 - * @param {Object} action Dispatched action.
2461 - *
2462 - * @return {Object} Next state.
2463 - */
2464 -
2465 -const receiveQueries = (0,external_lodash_namespaceObject.flowRight)([// Limit to matching action type so we don't attempt to replace action on
2466 -// an unhandled action.
2467 -if_matching_action(action => 'query' in action), // Inject query parts into action for use both in `onSubKey` and reducer.
2468 -replace_action(action => {
2469 - // `ifMatchingAction` still passes on initialization, where state is
2470 - // undefined and a query is not assigned. Avoid attempting to parse
2471 - // parts. `onSubKey` will omit by lack of `stableKey`.
2472 - if (action.query) {
2473 - return { ...action,
2474 - ...get_query_parts(action.query)
2475 - };
2476 - }
2477 -
2478 - return action;
2479 -}), on_sub_key('context'), // Queries shape is shared, but keyed by query `stableKey` part. Original
2480 -// reducer tracks only a single query object.
2481 -on_sub_key('stableKey')])(function () {
2482 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2483 - let action = arguments.length > 1 ? arguments[1] : undefined;
2484 - const {
2485 - type,
2486 - page,
2487 - perPage,
2488 - key = DEFAULT_ENTITY_KEY
2489 - } = action;
2490 -
2491 - if (type !== 'RECEIVE_ITEMS') {
2492 - return state;
2493 - }
2494 -
2495 - return getMergedItemIds(state || [], (0,external_lodash_namespaceObject.map)(action.items, key), page, perPage);
2496 -});
2497 -/**
2498 - * Reducer tracking queries state.
2499 - *
2500 - * @param {Object} state Current state.
2501 - * @param {Object} action Dispatched action.
2502 - *
2503 - * @return {Object} Next state.
2504 - */
2505 -
2506 -const queries = function () {
2507 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2508 - let action = arguments.length > 1 ? arguments[1] : undefined;
2509 -
2510 - switch (action.type) {
2511 - case 'RECEIVE_ITEMS':
2512 - return receiveQueries(state, action);
2513 -
2514 - case 'REMOVE_ITEMS':
2515 - const removedItems = action.itemIds.reduce((result, itemId) => {
2516 - result[itemId] = true;
2517 - return result;
2518 - }, {});
2519 - return (0,external_lodash_namespaceObject.mapValues)(state, contextQueries => {
2520 - return (0,external_lodash_namespaceObject.mapValues)(contextQueries, queryItems => {
2521 - return (0,external_lodash_namespaceObject.filter)(queryItems, queryId => {
2522 - return !removedItems[queryId];
2523 - });
2524 - });
2525 - });
2526 -
2527 - default:
2528 - return state;
2529 - }
2530 -};
2531 -
2532 -/* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2533 - items,
2534 - itemIsComplete,
2535 - queries
2536 -}));
2537 -//# sourceMappingURL=reducer.js.map
2538 -;// CONCATENATED MODULE: ./packages/core-data/build-module/reducer.js
2539 -/**
2540 - * External dependencies
2541 - */
2542 -
2543 -/**
2544 - * WordPress dependencies
2545 - */
2546 -
2547 -
2548 -
2549 -/**
2550 - * Internal dependencies
2551 - */
2552 -
2553 -
2554 -
2555 -
2556 -/**
2557 - * Reducer managing terms state. Keyed by taxonomy slug, the value is either
2558 - * undefined (if no request has been made for given taxonomy), null (if a
2559 - * request is in-flight for given taxonomy), or the array of terms for the
2560 - * taxonomy.
2561 - *
2562 - * @param {Object} state Current state.
2563 - * @param {Object} action Dispatched action.
2564 - *
2565 - * @return {Object} Updated state.
2566 - */
2567 -
2568 -function terms() {
2569 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2570 - let action = arguments.length > 1 ? arguments[1] : undefined;
2571 -
2572 - switch (action.type) {
2573 - case 'RECEIVE_TERMS':
2574 - return { ...state,
2575 - [action.taxonomy]: action.terms
2576 - };
2577 - }
2578 -
2579 - return state;
2580 -}
2581 -/**
2582 - * Reducer managing authors state. Keyed by id.
2583 - *
2584 - * @param {Object} state Current state.
2585 - * @param {Object} action Dispatched action.
2586 - *
2587 - * @return {Object} Updated state.
2588 - */
2589 -
2590 -function users() {
2591 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
2592 - byId: {},
2593 - queries: {}
2594 - };
2595 - let action = arguments.length > 1 ? arguments[1] : undefined;
2596 -
2597 - switch (action.type) {
2598 - case 'RECEIVE_USER_QUERY':
2599 - return {
2600 - byId: { ...state.byId,
2601 - ...(0,external_lodash_namespaceObject.keyBy)(action.users, 'id')
2602 - },
2603 - queries: { ...state.queries,
2604 - [action.queryID]: (0,external_lodash_namespaceObject.map)(action.users, user => user.id)
2605 - }
2606 - };
2607 - }
2608 -
2609 - return state;
2610 -}
2611 -/**
2612 - * Reducer managing current user state.
2613 - *
2614 - * @param {Object} state Current state.
2615 - * @param {Object} action Dispatched action.
2616 - *
2617 - * @return {Object} Updated state.
2618 - */
2619 -
2620 -function currentUser() {
2621 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2622 - let action = arguments.length > 1 ? arguments[1] : undefined;
2623 -
2624 - switch (action.type) {
2625 - case 'RECEIVE_CURRENT_USER':
2626 - return action.currentUser;
2627 - }
2628 -
2629 - return state;
2630 -}
2631 -/**
2632 - * Reducer managing taxonomies.
2633 - *
2634 - * @param {Object} state Current state.
2635 - * @param {Object} action Dispatched action.
2636 - *
2637 - * @return {Object} Updated state.
2638 - */
2639 -
2640 -function taxonomies() {
2641 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2642 - let action = arguments.length > 1 ? arguments[1] : undefined;
2643 -
2644 - switch (action.type) {
2645 - case 'RECEIVE_TAXONOMIES':
2646 - return action.taxonomies;
2647 - }
2648 -
2649 - return state;
2650 -}
2651 -/**
2652 - * Reducer managing the current theme.
2653 - *
2654 - * @param {string} state Current state.
2655 - * @param {Object} action Dispatched action.
2656 - *
2657 - * @return {string} Updated state.
2658 - */
2659 -
2660 -function currentTheme() {
2661 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
2662 - let action = arguments.length > 1 ? arguments[1] : undefined;
2663 -
2664 - switch (action.type) {
2665 - case 'RECEIVE_CURRENT_THEME':
2666 - return action.currentTheme.stylesheet;
2667 - }
2668 -
2669 - return state;
2670 -}
2671 -/**
2672 - * Reducer managing the current global styles id.
2673 - *
2674 - * @param {string} state Current state.
2675 - * @param {Object} action Dispatched action.
2676 - *
2677 - * @return {string} Updated state.
2678 - */
2679 -
2680 -function currentGlobalStylesId() {
2681 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
2682 - let action = arguments.length > 1 ? arguments[1] : undefined;
2683 -
2684 - switch (action.type) {
2685 - case 'RECEIVE_CURRENT_GLOBAL_STYLES_ID':
2686 - return action.id;
2687 - }
2688 -
2689 - return state;
2690 -}
2691 -/**
2692 - * Reducer managing the theme base global styles.
2693 - *
2694 - * @param {string} state Current state.
2695 - * @param {Object} action Dispatched action.
2696 - *
2697 - * @return {string} Updated state.
2698 - */
2699 -
2700 -function themeBaseGlobalStyles() {
2701 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2702 - let action = arguments.length > 1 ? arguments[1] : undefined;
2703 -
2704 - switch (action.type) {
2705 - case 'RECEIVE_THEME_GLOBAL_STYLES':
2706 - return { ...state,
2707 - [action.stylesheet]: action.globalStyles
2708 - };
2709 - }
2710 -
2711 - return state;
2712 -}
2713 -/**
2714 - * Reducer managing the theme global styles variations.
2715 - *
2716 - * @param {string} state Current state.
2717 - * @param {Object} action Dispatched action.
2718 - *
2719 - * @return {string} Updated state.
2720 - */
2721 -
2722 -function themeGlobalStyleVariations() {
2723 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2724 - let action = arguments.length > 1 ? arguments[1] : undefined;
2725 -
2726 - switch (action.type) {
2727 - case 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS':
2728 - return { ...state,
2729 - [action.stylesheet]: action.variations
2730 - };
2731 - }
2732 -
2733 - return state;
2734 -}
2735 -/**
2736 - * Higher Order Reducer for a given entity config. It supports:
2737 - *
2738 - * - Fetching
2739 - * - Editing
2740 - * - Saving
2741 - *
2742 - * @param {Object} entityConfig Entity config.
2743 - *
2744 - * @return {Function} Reducer.
2745 - */
2746 -
2747 -function entity(entityConfig) {
2748 - return (0,external_lodash_namespaceObject.flowRight)([// Limit to matching action type so we don't attempt to replace action on
2749 - // an unhandled action.
2750 - if_matching_action(action => action.name && action.kind && action.name === entityConfig.name && action.kind === entityConfig.kind), // Inject the entity config into the action.
2751 - replace_action(action => {
2752 - return { ...action,
2753 - key: entityConfig.key || DEFAULT_ENTITY_KEY
2754 - };
2755 - })])((0,external_wp_data_namespaceObject.combineReducers)({
2756 - queriedData: reducer,
2757 - edits: function () {
2758 - var _action$query$context, _action$query;
2759 -
2760 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2761 - let action = arguments.length > 1 ? arguments[1] : undefined;
2762 -
2763 - switch (action.type) {
2764 - case 'RECEIVE_ITEMS':
2765 - const context = (_action$query$context = action === null || action === void 0 ? void 0 : (_action$query = action.query) === null || _action$query === void 0 ? void 0 : _action$query.context) !== null && _action$query$context !== void 0 ? _action$query$context : 'default';
2766 -
2767 - if (context !== 'default') {
2768 - return state;
2769 - }
2770 -
2771 - const nextState = { ...state
2772 - };
2773 -
2774 - for (const record of action.items) {
2775 - const recordId = record[action.key];
2776 - const edits = nextState[recordId];
2777 -
2778 - if (!edits) {
2779 - continue;
2780 - }
2781 -
2782 - const nextEdits = Object.keys(edits).reduce((acc, key) => {
2783 - // If the edited value is still different to the persisted value,
2784 - // keep the edited value in edits.
2785 - if ( // Edits are the "raw" attribute values, but records may have
2786 - // objects with more properties, so we use `get` here for the
2787 - // comparison.
2788 - !(0,external_lodash_namespaceObject.isEqual)(edits[key], (0,external_lodash_namespaceObject.get)(record[key], 'raw', record[key])) && ( // Sometimes the server alters the sent value which means
2789 - // we need to also remove the edits before the api request.
2790 - !action.persistedEdits || !(0,external_lodash_namespaceObject.isEqual)(edits[key], action.persistedEdits[key]))) {
2791 - acc[key] = edits[key];
2792 - }
2793 -
2794 - return acc;
2795 - }, {});
2796 -
2797 - if (Object.keys(nextEdits).length) {
2798 - nextState[recordId] = nextEdits;
2799 - } else {
2800 - delete nextState[recordId];
2801 - }
2802 - }
2803 -
2804 - return nextState;
2805 -
2806 - case 'EDIT_ENTITY_RECORD':
2807 - const nextEdits = { ...state[action.recordId],
2808 - ...action.edits
2809 - };
2810 - Object.keys(nextEdits).forEach(key => {
2811 - // Delete cleared edits so that the properties
2812 - // are not considered dirty.
2813 - if (nextEdits[key] === undefined) {
2814 - delete nextEdits[key];
2815 - }
2816 - });
2817 - return { ...state,
2818 - [action.recordId]: nextEdits
2819 - };
2820 - }
2821 -
2822 - return state;
2823 - },
2824 - saving: function () {
2825 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2826 - let action = arguments.length > 1 ? arguments[1] : undefined;
2827 -
2828 - switch (action.type) {
2829 - case 'SAVE_ENTITY_RECORD_START':
2830 - case 'SAVE_ENTITY_RECORD_FINISH':
2831 - return { ...state,
2832 - [action.recordId]: {
2833 - pending: action.type === 'SAVE_ENTITY_RECORD_START',
2834 - error: action.error,
2835 - isAutosave: action.isAutosave
2836 - }
2837 - };
2838 - }
2839 -
2840 - return state;
2841 - },
2842 - deleting: function () {
2843 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2844 - let action = arguments.length > 1 ? arguments[1] : undefined;
2845 -
2846 - switch (action.type) {
2847 - case 'DELETE_ENTITY_RECORD_START':
2848 - case 'DELETE_ENTITY_RECORD_FINISH':
2849 - return { ...state,
2850 - [action.recordId]: {
2851 - pending: action.type === 'DELETE_ENTITY_RECORD_START',
2852 - error: action.error
2853 - }
2854 - };
2855 - }
2856 -
2857 - return state;
2858 - }
2859 - }));
2860 -}
2861 -/**
2862 - * Reducer keeping track of the registered entities.
2863 - *
2864 - * @param {Object} state Current state.
2865 - * @param {Object} action Dispatched action.
2866 - *
2867 - * @return {Object} Updated state.
2868 - */
2869 -
2870 -
2871 -function entitiesConfig() {
2872 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultEntities;
2873 - let action = arguments.length > 1 ? arguments[1] : undefined;
2874 -
2875 - switch (action.type) {
2876 - case 'ADD_ENTITIES':
2877 - return [...state, ...action.entities];
2878 - }
2879 -
2880 - return state;
2881 -}
2882 -/**
2883 - * Reducer keeping track of the registered entities config and data.
2884 - *
2885 - * @param {Object} state Current state.
2886 - * @param {Object} action Dispatched action.
2887 - *
2888 - * @return {Object} Updated state.
2889 - */
2890 -
2891 -const entities = function () {
2892 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2893 - let action = arguments.length > 1 ? arguments[1] : undefined;
2894 - const newConfig = entitiesConfig(state.config, action); // Generates a dynamic reducer for the entities
2895 -
2896 - let entitiesDataReducer = state.reducer;
2897 -
2898 - if (!entitiesDataReducer || newConfig !== state.config) {
2899 - const entitiesByKind = (0,external_lodash_namespaceObject.groupBy)(newConfig, 'kind');
2900 - entitiesDataReducer = (0,external_wp_data_namespaceObject.combineReducers)(Object.entries(entitiesByKind).reduce((memo, _ref) => {
2901 - let [kind, subEntities] = _ref;
2902 - const kindReducer = (0,external_wp_data_namespaceObject.combineReducers)(subEntities.reduce((kindMemo, entityConfig) => ({ ...kindMemo,
2903 - [entityConfig.name]: entity(entityConfig)
2904 - }), {}));
2905 - memo[kind] = kindReducer;
2906 - return memo;
2907 - }, {}));
2908 - }
2909 -
2910 - const newData = entitiesDataReducer(state.data, action);
2911 -
2912 - if (newData === state.data && newConfig === state.config && entitiesDataReducer === state.reducer) {
2913 - return state;
2914 - }
2915 -
2916 - return {
2917 - reducer: entitiesDataReducer,
2918 - data: newData,
2919 - config: newConfig
2920 - };
2921 -};
2922 -/**
2923 - * Reducer keeping track of entity edit undo history.
2924 - *
2925 - * @param {Object} state Current state.
2926 - * @param {Object} action Dispatched action.
2927 - *
2928 - * @return {Object} Updated state.
2929 - */
2930 -
2931 -const UNDO_INITIAL_STATE = [];
2932 -UNDO_INITIAL_STATE.offset = 0;
2933 -let lastEditAction;
2934 -function reducer_undo() {
2935 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UNDO_INITIAL_STATE;
2936 - let action = arguments.length > 1 ? arguments[1] : undefined;
2937 -
2938 - switch (action.type) {
2939 - case 'EDIT_ENTITY_RECORD':
2940 - case 'CREATE_UNDO_LEVEL':
2941 - let isCreateUndoLevel = action.type === 'CREATE_UNDO_LEVEL';
2942 - const isUndoOrRedo = !isCreateUndoLevel && (action.meta.isUndo || action.meta.isRedo);
2943 -
2944 - if (isCreateUndoLevel) {
2945 - action = lastEditAction;
2946 - } else if (!isUndoOrRedo) {
2947 - // Don't lose the last edit cache if the new one only has transient edits.
2948 - // Transient edits don't create new levels so updating the cache would make
2949 - // us skip an edit later when creating levels explicitly.
2950 - if (Object.keys(action.edits).some(key => !action.transientEdits[key])) {
2951 - lastEditAction = action;
2952 - } else {
2953 - lastEditAction = { ...action,
2954 - edits: { ...(lastEditAction && lastEditAction.edits),
2955 - ...action.edits
2956 - }
2957 - };
2958 - }
2959 - }
2960 -
2961 - let nextState;
2962 -
2963 - if (isUndoOrRedo) {
2964 - nextState = [...state];
2965 - nextState.offset = state.offset + (action.meta.isUndo ? -1 : 1);
2966 -
2967 - if (state.flattenedUndo) {
2968 - // The first undo in a sequence of undos might happen while we have
2969 - // flattened undos in state. If this is the case, we want execution
2970 - // to continue as if we were creating an explicit undo level. This
2971 - // will result in an extra undo level being appended with the flattened
2972 - // undo values.
2973 - // We also have to take into account if the `lastEditAction` had opted out
2974 - // of being tracked in undo history, like the action that persists the latest
2975 - // content right before saving. In that case we have to update the `lastEditAction`
2976 - // to avoid returning early before applying the existing flattened undos.
2977 - isCreateUndoLevel = true;
2978 -
2979 - if (!lastEditAction.meta.undo) {
2980 - lastEditAction.meta.undo = {
2981 - edits: {}
2982 - };
2983 - }
2984 -
2985 - action = lastEditAction;
2986 - } else {
2987 - return nextState;
2988 - }
2989 - }
2990 -
2991 - if (!action.meta.undo) {
2992 - return state;
2993 - } // Transient edits don't create an undo level, but are
2994 - // reachable in the next meaningful edit to which they
2995 - // are merged. They are defined in the entity's config.
2996 -
2997 -
2998 - if (!isCreateUndoLevel && !Object.keys(action.edits).some(key => !action.transientEdits[key])) {
2999 - nextState = [...state];
3000 - nextState.flattenedUndo = { ...state.flattenedUndo,
3001 - ...action.edits
3002 - };
3003 - nextState.offset = state.offset;
3004 - return nextState;
3005 - } // Clear potential redos, because this only supports linear history.
3006 -
3007 -
3008 - nextState = nextState || state.slice(0, state.offset || undefined);
3009 - nextState.offset = nextState.offset || 0;
3010 - nextState.pop();
3011 -
3012 - if (!isCreateUndoLevel) {
3013 - nextState.push({
3014 - kind: action.meta.undo.kind,
3015 - name: action.meta.undo.name,
3016 - recordId: action.meta.undo.recordId,
3017 - edits: { ...state.flattenedUndo,
3018 - ...action.meta.undo.edits
3019 - }
3020 - });
3021 - } // When an edit is a function it's an optimization to avoid running some expensive operation.
3022 - // We can't rely on the function references being the same so we opt out of comparing them here.
3023 -
3024 -
3025 - const comparisonUndoEdits = Object.values(action.meta.undo.edits).filter(edit => typeof edit !== 'function');
3026 - const comparisonEdits = Object.values(action.edits).filter(edit => typeof edit !== 'function');
3027 -
3028 - if (!external_wp_isShallowEqual_default()(comparisonUndoEdits, comparisonEdits)) {
3029 - nextState.push({
3030 - kind: action.kind,
3031 - name: action.name,
3032 - recordId: action.recordId,
3033 - edits: isCreateUndoLevel ? { ...state.flattenedUndo,
3034 - ...action.edits
3035 - } : action.edits
3036 - });
3037 - }
3038 -
3039 - return nextState;
3040 - }
3041 -
3042 - return state;
3043 -}
3044 -/**
3045 - * Reducer managing embed preview data.
3046 - *
3047 - * @param {Object} state Current state.
3048 - * @param {Object} action Dispatched action.
3049 - *
3050 - * @return {Object} Updated state.
3051 - */
3052 -
3053 -function embedPreviews() {
3054 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3055 - let action = arguments.length > 1 ? arguments[1] : undefined;
3056 -
3057 - switch (action.type) {
3058 - case 'RECEIVE_EMBED_PREVIEW':
3059 - const {
3060 - url,
3061 - preview
3062 - } = action;
3063 - return { ...state,
3064 - [url]: preview
3065 - };
3066 - }
3067 -
3068 - return state;
3069 -}
3070 -/**
3071 - * State which tracks whether the user can perform an action on a REST
3072 - * resource.
3073 - *
3074 - * @param {Object} state Current state.
3075 - * @param {Object} action Dispatched action.
3076 - *
3077 - * @return {Object} Updated state.
3078 - */
3079 -
3080 -function userPermissions() {
3081 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3082 - let action = arguments.length > 1 ? arguments[1] : undefined;
3083 -
3084 - switch (action.type) {
3085 - case 'RECEIVE_USER_PERMISSION':
3086 - return { ...state,
3087 - [action.key]: action.isAllowed
3088 - };
3089 - }
3090 -
3091 - return state;
3092 -}
3093 -/**
3094 - * Reducer returning autosaves keyed by their parent's post id.
3095 - *
3096 - * @param {Object} state Current state.
3097 - * @param {Object} action Dispatched action.
3098 - *
3099 - * @return {Object} Updated state.
3100 - */
3101 -
3102 -function autosaves() {
3103 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3104 - let action = arguments.length > 1 ? arguments[1] : undefined;
3105 -
3106 - switch (action.type) {
3107 - case 'RECEIVE_AUTOSAVES':
3108 - const {
3109 - postId,
3110 - autosaves: autosavesData
3111 - } = action;
3112 - return { ...state,
3113 - [postId]: autosavesData
3114 - };
3115 - }
3116 -
3117 - return state;
3118 -}
3119 -/* harmony default export */ var build_module_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
3120 - terms,
3121 - users,
3122 - currentTheme,
3123 - currentGlobalStylesId,
3124 - currentUser,
3125 - themeGlobalStyleVariations,
3126 - themeBaseGlobalStyles,
3127 - taxonomies,
3128 - entities,
3129 - undo: reducer_undo,
3130 - embedPreviews,
3131 - userPermissions,
3132 - autosaves
3133 -}));
3134 -//# sourceMappingURL=reducer.js.map
3135 -;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
3136 -
3137 -
3138 -var LEAF_KEY, hasWeakMap;
3139 -
3140 -/**
3141 - * Arbitrary value used as key for referencing cache object in WeakMap tree.
3142 - *
3143 - * @type {Object}
3144 - */
3145 -LEAF_KEY = {};
3146 -
3147 -/**
3148 - * Whether environment supports WeakMap.
3149 - *
3150 - * @type {boolean}
3151 - */
3152 -hasWeakMap = typeof WeakMap !== 'undefined';
3153 -
3154 -/**
3155 - * Returns the first argument as the sole entry in an array.
3156 - *
3157 - * @param {*} value Value to return.
3158 - *
3159 - * @return {Array} Value returned as entry in array.
3160 - */
3161 -function arrayOf( value ) {
3162 - return [ value ];
3163 -}
3164 -
3165 -/**
3166 - * Returns true if the value passed is object-like, or false otherwise. A value
3167 - * is object-like if it can support property assignment, e.g. object or array.
3168 - *
3169 - * @param {*} value Value to test.
3170 - *
3171 - * @return {boolean} Whether value is object-like.
3172 - */
3173 -function isObjectLike( value ) {
3174 - return !! value && 'object' === typeof value;
3175 -}
3176 -
3177 -/**
3178 - * Creates and returns a new cache object.
3179 - *
3180 - * @return {Object} Cache object.
3181 - */
3182 -function createCache() {
3183 - var cache = {
3184 - clear: function() {
3185 - cache.head = null;
3186 - },
3187 - };
3188 -
3189 - return cache;
3190 -}
3191 -
3192 -/**
3193 - * Returns true if entries within the two arrays are strictly equal by
3194 - * reference from a starting index.
3195 - *
3196 - * @param {Array} a First array.
3197 - * @param {Array} b Second array.
3198 - * @param {number} fromIndex Index from which to start comparison.
3199 - *
3200 - * @return {boolean} Whether arrays are shallowly equal.
3201 - */
3202 -function isShallowEqual( a, b, fromIndex ) {
3203 - var i;
3204 -
3205 - if ( a.length !== b.length ) {
3206 - return false;
3207 - }
3208 -
3209 - for ( i = fromIndex; i < a.length; i++ ) {
3210 - if ( a[ i ] !== b[ i ] ) {
3211 - return false;
3212 - }
3213 - }
3214 -
3215 - return true;
3216 -}
3217 -
3218 -/**
3219 - * Returns a memoized selector function. The getDependants function argument is
3220 - * called before the memoized selector and is expected to return an immutable
3221 - * reference or array of references on which the selector depends for computing
3222 - * its own return value. The memoize cache is preserved only as long as those
3223 - * dependant references remain the same. If getDependants returns a different
3224 - * reference(s), the cache is cleared and the selector value regenerated.
3225 - *
3226 - * @param {Function} selector Selector function.
3227 - * @param {Function} getDependants Dependant getter returning an immutable
3228 - * reference or array of reference used in
3229 - * cache bust consideration.
3230 - *
3231 - * @return {Function} Memoized selector.
3232 - */
3233 -/* harmony default export */ function rememo(selector, getDependants ) {
3234 - var rootCache, getCache;
3235 -
3236 - // Use object source as dependant if getter not provided
3237 - if ( ! getDependants ) {
3238 - getDependants = arrayOf;
3239 - }
3240 -
3241 - /**
3242 - * Returns the root cache. If WeakMap is supported, this is assigned to the
3243 - * root WeakMap cache set, otherwise it is a shared instance of the default
3244 - * cache object.
3245 - *
3246 - * @return {(WeakMap|Object)} Root cache object.
3247 - */
3248 - function getRootCache() {
3249 - return rootCache;
3250 - }
3251 -
3252 - /**
3253 - * Returns the cache for a given dependants array. When possible, a WeakMap
3254 - * will be used to create a unique cache for each set of dependants. This
3255 - * is feasible due to the nature of WeakMap in allowing garbage collection
3256 - * to occur on entries where the key object is no longer referenced. Since
3257 - * WeakMap requires the key to be an object, this is only possible when the
3258 - * dependant is object-like. The root cache is created as a hierarchy where
3259 - * each top-level key is the first entry in a dependants set, the value a
3260 - * WeakMap where each key is the next dependant, and so on. This continues
3261 - * so long as the dependants are object-like. If no dependants are object-
3262 - * like, then the cache is shared across all invocations.
3263 - *
3264 - * @see isObjectLike
3265 - *
3266 - * @param {Array} dependants Selector dependants.
3267 - *
3268 - * @return {Object} Cache object.
3269 - */
3270 - function getWeakMapCache( dependants ) {
3271 - var caches = rootCache,
3272 - isUniqueByDependants = true,
3273 - i, dependant, map, cache;
3274 -
3275 - for ( i = 0; i < dependants.length; i++ ) {
3276 - dependant = dependants[ i ];
3277 -
3278 - // Can only compose WeakMap from object-like key.
3279 - if ( ! isObjectLike( dependant ) ) {
3280 - isUniqueByDependants = false;
3281 - break;
3282 - }
3283 -
3284 - // Does current segment of cache already have a WeakMap?
3285 - if ( caches.has( dependant ) ) {
3286 - // Traverse into nested WeakMap.
3287 - caches = caches.get( dependant );
3288 - } else {
3289 - // Create, set, and traverse into a new one.
3290 - map = new WeakMap();
3291 - caches.set( dependant, map );
3292 - caches = map;
3293 - }
3294 - }
3295 -
3296 - // We use an arbitrary (but consistent) object as key for the last item
3297 - // in the WeakMap to serve as our running cache.
3298 - if ( ! caches.has( LEAF_KEY ) ) {
3299 - cache = createCache();
3300 - cache.isUniqueByDependants = isUniqueByDependants;
3301 - caches.set( LEAF_KEY, cache );
3302 - }
3303 -
3304 - return caches.get( LEAF_KEY );
3305 - }
3306 -
3307 - // Assign cache handler by availability of WeakMap
3308 - getCache = hasWeakMap ? getWeakMapCache : getRootCache;
3309 -
3310 - /**
3311 - * Resets root memoization cache.
3312 - */
3313 - function clear() {
3314 - rootCache = hasWeakMap ? new WeakMap() : createCache();
3315 - }
3316 -
3317 - // eslint-disable-next-line jsdoc/check-param-names
3318 - /**
3319 - * The augmented selector call, considering first whether dependants have
3320 - * changed before passing it to underlying memoize function.
3321 - *
3322 - * @param {Object} source Source object for derivation.
3323 - * @param {...*} extraArgs Additional arguments to pass to selector.
3324 - *
3325 - * @return {*} Selector result.
3326 - */
3327 - function callSelector( /* source, ...extraArgs */ ) {
3328 - var len = arguments.length,
3329 - cache, node, i, args, dependants;
3330 -
3331 - // Create copy of arguments (avoid leaking deoptimization).
3332 - args = new Array( len );
3333 - for ( i = 0; i < len; i++ ) {
3334 - args[ i ] = arguments[ i ];
3335 - }
3336 -
3337 - dependants = getDependants.apply( null, args );
3338 - cache = getCache( dependants );
3339 -
3340 - // If not guaranteed uniqueness by dependants (primitive type or lack
3341 - // of WeakMap support), shallow compare against last dependants and, if
3342 - // references have changed, destroy cache to recalculate result.
3343 - if ( ! cache.isUniqueByDependants ) {
3344 - if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
3345 - cache.clear();
3346 - }
3347 -
3348 - cache.lastDependants = dependants;
3349 - }
3350 -
3351 - node = cache.head;
3352 - while ( node ) {
3353 - // Check whether node arguments match arguments
3354 - if ( ! isShallowEqual( node.args, args, 1 ) ) {
3355 - node = node.next;
3356 - continue;
3357 - }
3358 -
3359 - // At this point we can assume we've found a match
3360 -
3361 - // Surface matched node to head if not already
3362 - if ( node !== cache.head ) {
3363 - // Adjust siblings to point to each other.
3364 - node.prev.next = node.next;
3365 - if ( node.next ) {
3366 - node.next.prev = node.prev;
3367 - }
3368 -
3369 - node.next = cache.head;
3370 - node.prev = null;
3371 - cache.head.prev = node;
3372 - cache.head = node;
3373 - }
3374 -
3375 - // Return immediately
3376 - return node.val;
3377 - }
3378 -
3379 - // No cached value found. Continue to insertion phase:
3380 -
3381 - node = {
3382 - // Generate the result from original function
3383 - val: selector.apply( null, args ),
3384 - };
3385 -
3386 - // Avoid including the source object in the cache.
3387 - args[ 0 ] = null;
3388 - node.args = args;
3389 -
3390 - // Don't need to check whether node is already head, since it would
3391 - // have been returned above already if it was
3392 -
3393 - // Shift existing head down list
3394 - if ( cache.head ) {
3395 - cache.head.prev = node;
3396 - node.next = cache.head;
3397 - }
3398 -
3399 - cache.head = node;
3400 -
3401 - return node.val;
3402 - }
3403 -
3404 - callSelector.getDependants = getDependants;
3405 - callSelector.clear = clear;
3406 - clear();
3407 -
3408 - return callSelector;
3409 -}
3410 -
3411 -// EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js
3412 -var equivalent_key_map = __webpack_require__(3909);
3413 -var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map);
3414 -;// CONCATENATED MODULE: ./packages/core-data/build-module/queried-data/selectors.js
3415 -/**
3416 - * External dependencies
3417 - */
3418 -
3419 -
3420 -
3421 -/**
3422 - * Internal dependencies
3423 - */
3424 -
3425 -
3426 -/**
3427 - * Cache of state keys to EquivalentKeyMap where the inner map tracks queries
3428 - * to their resulting items set. WeakMap allows garbage collection on expired
3429 - * state references.
3430 - *
3431 - * @type {WeakMap<Object,EquivalentKeyMap>}
3432 - */
3433 -
3434 -const queriedItemsCacheByState = new WeakMap();
3435 -/**
3436 - * Returns items for a given query, or null if the items are not known.
3437 - *
3438 - * @param {Object} state State object.
3439 - * @param {?Object} query Optional query.
3440 - *
3441 - * @return {?Array} Query items.
3442 - */
3443 -
3444 -function getQueriedItemsUncached(state, query) {
3445 - var _state$queries, _state$queries$contex;
3446 -
3447 - const {
3448 - stableKey,
3449 - page,
3450 - perPage,
3451 - include,
3452 - fields,
3453 - context
3454 - } = get_query_parts(query);
3455 - let itemIds;
3456 -
3457 - if ((_state$queries = state.queries) !== null && _state$queries !== void 0 && (_state$queries$contex = _state$queries[context]) !== null && _state$queries$contex !== void 0 && _state$queries$contex[stableKey]) {
3458 - itemIds = state.queries[context][stableKey];
3459 - }
3460 -
3461 - if (!itemIds) {
3462 - return null;
3463 - }
3464 -
3465 - const startOffset = perPage === -1 ? 0 : (page - 1) * perPage;
3466 - const endOffset = perPage === -1 ? itemIds.length : Math.min(startOffset + perPage, itemIds.length);
3467 - const items = [];
3468 -
3469 - for (let i = startOffset; i < endOffset; i++) {
3470 - var _state$items$context;
3471 -
3472 - const itemId = itemIds[i];
3473 -
3474 - if (Array.isArray(include) && !include.includes(itemId)) {
3475 - continue;
3476 - } // Having a target item ID doesn't guarantee that this object has been queried.
3477 -
3478 -
3479 - if (!((_state$items$context = state.items[context]) !== null && _state$items$context !== void 0 && _state$items$context.hasOwnProperty(itemId))) {
3480 - return null;
3481 - }
3482 -
3483 - const item = state.items[context][itemId];
3484 - let filteredItem;
3485 -
3486 - if (Array.isArray(fields)) {
3487 - filteredItem = {};
3488 -
3489 - for (let f = 0; f < fields.length; f++) {
3490 - const field = fields[f].split('.');
3491 - const value = (0,external_lodash_namespaceObject.get)(item, field);
3492 - (0,external_lodash_namespaceObject.set)(filteredItem, field, value);
3493 - }
3494 - } else {
3495 - var _state$itemIsComplete;
3496 -
3497 - // If expecting a complete item, validate that completeness, or
3498 - // otherwise abort.
3499 - if (!((_state$itemIsComplete = state.itemIsComplete[context]) !== null && _state$itemIsComplete !== void 0 && _state$itemIsComplete[itemId])) {
3500 - return null;
3501 - }
3502 -
3503 - filteredItem = item;
3504 - }
3505 -
3506 - items.push(filteredItem);
3507 - }
3508 -
3509 - return items;
3510 -}
3511 -/**
3512 - * Returns items for a given query, or null if the items are not known. Caches
3513 - * result both per state (by reference) and per query (by deep equality).
3514 - * The caching approach is intended to be durable to query objects which are
3515 - * deeply but not referentially equal, since otherwise:
3516 - *
3517 - * `getQueriedItems( state, {} ) !== getQueriedItems( state, {} )`
3518 - *
3519 - * @param {Object} state State object.
3520 - * @param {?Object} query Optional query.
3521 - *
3522 - * @return {?Array} Query items.
3523 - */
3524 -
3525 -
3526 -const getQueriedItems = rememo(function (state) {
3527 - let query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3528 - let queriedItemsCache = queriedItemsCacheByState.get(state);
3529 -
3530 - if (queriedItemsCache) {
3531 - const queriedItems = queriedItemsCache.get(query);
3532 -
3533 - if (queriedItems !== undefined) {
3534 - return queriedItems;
3535 - }
3536 - } else {
3537 - queriedItemsCache = new (equivalent_key_map_default())();
3538 - queriedItemsCacheByState.set(state, queriedItemsCache);
3539 - }
3540 -
3541 - const items = getQueriedItemsUncached(state, query);
3542 - queriedItemsCache.set(query, items);
3543 - return items;
3544 -});
3545 -//# sourceMappingURL=selectors.js.map
3546 -;// CONCATENATED MODULE: ./packages/core-data/build-module/utils/is-raw-attribute.js
3547 -/**
3548 - * Checks whether the attribute is a "raw" attribute or not.
3549 - *
3550 - * @param {Object} entity Entity data.
3551 - * @param {string} attribute Attribute name.
3552 - *
3553 - * @return {boolean} Is the attribute raw
3554 - */
3555 -function isRawAttribute(entity, attribute) {
3556 - return (entity.rawAttributes || []).includes(attribute);
3557 -}
3558 -//# sourceMappingURL=is-raw-attribute.js.map
3559 -;// CONCATENATED MODULE: ./packages/core-data/build-module/selectors.js
3560 -/**
3561 - * External dependencies
3562 - */
3563 -
3564 -
3565 -/**
3566 - * WordPress dependencies
3567 - */
3568 -
3569 -
3570 -
3571 -
3572 -/**
3573 - * Internal dependencies
3574 - */
3575 -
3576 -
3577 -
3578 -
3579 -
3580 -/**
3581 - * Shared reference to an empty object for cases where it is important to avoid
3582 - * returning a new object reference on every invocation, as in a connected or
3583 - * other pure component which performs `shouldComponentUpdate` check on props.
3584 - * This should be used as a last resort, since the normalized data should be
3585 - * maintained by the reducer result in state.
3586 - */
3587 -
3588 -const EMPTY_OBJECT = {};
3589 -/**
3590 - * Returns true if a request is in progress for embed preview data, or false
3591 - * otherwise.
3592 - *
3593 - * @param {Object} state Data state.
3594 - * @param {string} url URL the preview would be for.
3595 - *
3596 - * @return {boolean} Whether a request is in progress for an embed preview.
3597 - */
3598 -
3599 -const isRequestingEmbedPreview = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, url) => {
3600 - return select(STORE_NAME).isResolving('getEmbedPreview', [url]);
3601 -});
3602 -/**
3603 - * Returns all available authors.
3604 - *
3605 - * @deprecated since 11.3. Callers should use `select( 'core' ).getUsers({ who: 'authors' })` instead.
3606 - *
3607 - * @param {Object} state Data state.
3608 - * @param {Object|undefined} query Optional object of query parameters to
3609 - * include with request.
3610 - * @return {Array} Authors list.
3611 - */
3612 -
3613 -function getAuthors(state, query) {
3614 - external_wp_deprecated_default()("select( 'core' ).getAuthors()", {
3615 - since: '5.9',
3616 - alternative: "select( 'core' ).getUsers({ who: 'authors' })"
3617 - });
3618 - const path = (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/users/?who=authors&per_page=100', query);
3619 - return getUserQueryResults(state, path);
3620 -}
3621 -/**
3622 - * Returns the current user.
3623 - *
3624 - * @param {Object} state Data state.
3625 - *
3626 - * @return {Object} Current user object.
3627 - */
3628 -
3629 -function getCurrentUser(state) {
3630 - return state.currentUser;
3631 -}
3632 -/**
3633 - * Returns all the users returned by a query ID.
3634 - *
3635 - * @param {Object} state Data state.
3636 - * @param {string} queryID Query ID.
3637 - *
3638 - * @return {Array} Users list.
3639 - */
3640 -
3641 -const getUserQueryResults = rememo((state, queryID) => {
3642 - const queryResults = state.users.queries[queryID];
3643 - return (0,external_lodash_namespaceObject.map)(queryResults, id => state.users.byId[id]);
3644 -}, (state, queryID) => [state.users.queries[queryID], state.users.byId]);
3645 -/**
3646 - * Returns whether the entities for the give kind are loaded.
3647 - *
3648 - * @param {Object} state Data state.
3649 - * @param {string} kind Entity kind.
3650 - *
3651 - * @return {Array<Object>} Array of entities with config matching kind.
3652 - */
3653 -
3654 -function getEntitiesByKind(state, kind) {
3655 - return (0,external_lodash_namespaceObject.filter)(state.entities.config, {
3656 - kind
3657 - });
3658 -}
3659 -/**
3660 - * Returns the entity object given its kind and name.
3661 - *
3662 - * @param {Object} state Data state.
3663 - * @param {string} kind Entity kind.
3664 - * @param {string} name Entity name.
3665 - *
3666 - * @return {Object} Entity
3667 - */
3668 -
3669 -function getEntity(state, kind, name) {
3670 - return (0,external_lodash_namespaceObject.find)(state.entities.config, {
3671 - kind,
3672 - name
3673 - });
3674 -}
3675 -/**
3676 - * Returns the Entity's record object by key. Returns `null` if the value is not
3677 - * yet received, undefined if the value entity is known to not exist, or the
3678 - * entity object if it exists and is received.
3679 - *
3680 - * @param {Object} state State tree
3681 - * @param {string} kind Entity kind.
3682 - * @param {string} name Entity name.
3683 - * @param {number} key Record's key
3684 - * @param {?Object} query Optional query.
3685 - *
3686 - * @return {Object?} Record.
3687 - */
3688 -
3689 -const getEntityRecord = rememo((state, kind, name, key, query) => {
3690 - var _query$context, _queriedState$items$c;
3691 -
3692 - const queriedState = (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'queriedData']);
3693 -
3694 - if (!queriedState) {
3695 - return undefined;
3696 - }
3697 -
3698 - const context = (_query$context = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context !== void 0 ? _query$context : 'default';
3699 -
3700 - if (query === undefined) {
3701 - var _queriedState$itemIsC;
3702 -
3703 - // If expecting a complete item, validate that completeness.
3704 - if (!((_queriedState$itemIsC = queriedState.itemIsComplete[context]) !== null && _queriedState$itemIsC !== void 0 && _queriedState$itemIsC[key])) {
3705 - return undefined;
3706 - }
3707 -
3708 - return queriedState.items[context][key];
3709 - }
3710 -
3711 - const item = (_queriedState$items$c = queriedState.items[context]) === null || _queriedState$items$c === void 0 ? void 0 : _queriedState$items$c[key];
3712 -
3713 - if (item && query._fields) {
3714 - const filteredItem = {};
3715 - const fields = get_normalized_comma_separable(query._fields);
3716 -
3717 - for (let f = 0; f < fields.length; f++) {
3718 - const field = fields[f].split('.');
3719 - const value = (0,external_lodash_namespaceObject.get)(item, field);
3720 - (0,external_lodash_namespaceObject.set)(filteredItem, field, value);
3721 - }
3722 -
3723 - return filteredItem;
3724 - }
3725 -
3726 - return item;
3727 -}, (state, kind, name, recordId, query) => {
3728 - var _query$context2;
3729 -
3730 - const context = (_query$context2 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context2 !== void 0 ? _query$context2 : 'default';
3731 - return [(0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'queriedData', 'items', context, recordId]), (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'queriedData', 'itemIsComplete', context, recordId])];
3732 -});
3733 -/**
3734 - * Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity from the API if the entity record isn't available in the local state.
3735 - *
3736 - * @param {Object} state State tree
3737 - * @param {string} kind Entity kind.
3738 - * @param {string} name Entity name.
3739 - * @param {number} key Record's key
3740 - *
3741 - * @return {Object|null} Record.
3742 - */
3743 -
3744 -function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
3745 - return getEntityRecord(state, kind, name, key);
3746 -}
3747 -/**
3748 - * Returns the entity's record object by key,
3749 - * with its attributes mapped to their raw values.
3750 - *
3751 - * @param {Object} state State tree.
3752 - * @param {string} kind Entity kind.
3753 - * @param {string} name Entity name.
3754 - * @param {number} key Record's key.
3755 - *
3756 - * @return {Object?} Object with the entity's raw attributes.
3757 - */
3758 -
3759 -const getRawEntityRecord = rememo((state, kind, name, key) => {
3760 - const record = getEntityRecord(state, kind, name, key);
3761 - return record && Object.keys(record).reduce((accumulator, _key) => {
3762 - if (isRawAttribute(getEntity(state, kind, name), _key)) {
3763 - // Because edits are the "raw" attribute values,
3764 - // we return those from record selectors to make rendering,
3765 - // comparisons, and joins with edits easier.
3766 - accumulator[_key] = (0,external_lodash_namespaceObject.get)(record[_key], 'raw', record[_key]);
3767 - } else {
3768 - accumulator[_key] = record[_key];
3769 - }
3770 -
3771 - return accumulator;
3772 - }, {});
3773 -}, (state, kind, name, recordId, query) => {
3774 - var _query$context3;
3775 -
3776 - const context = (_query$context3 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context3 !== void 0 ? _query$context3 : 'default';
3777 - return [state.entities.config, (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'queriedData', 'items', context, recordId]), (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'queriedData', 'itemIsComplete', context, recordId])];
3778 -});
3779 -/**
3780 - * Returns true if records have been received for the given set of parameters,
3781 - * or false otherwise.
3782 - *
3783 - * @param {Object} state State tree
3784 - * @param {string} kind Entity kind.
3785 - * @param {string} name Entity name.
3786 - * @param {?Object} query Optional terms query.
3787 - *
3788 - * @return {boolean} Whether entity records have been received.
3789 - */
3790 -
3791 -function hasEntityRecords(state, kind, name, query) {
3792 - return Array.isArray(getEntityRecords(state, kind, name, query));
3793 -}
3794 -/**
3795 - * Returns the Entity's records.
3796 - *
3797 - * @param {Object} state State tree
3798 - * @param {string} kind Entity kind.
3799 - * @param {string} name Entity name.
3800 - * @param {?Object} query Optional terms query.
3801 - *
3802 - * @return {?Array} Records.
3803 - */
3804 -
3805 -function getEntityRecords(state, kind, name, query) {
3806 - // Queried data state is prepopulated for all known entities. If this is not
3807 - // assigned for the given parameters, then it is known to not exist.
3808 - const queriedState = (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'queriedData']);
3809 -
3810 - if (!queriedState) {
3811 - return null;
3812 - }
3813 -
3814 - return getQueriedItems(queriedState, query);
3815 -}
3816 -/**
3817 - * Returns the list of dirty entity records.
3818 - *
3819 - * @param {Object} state State tree.
3820 - *
3821 - * @return {[{ title: string, key: string, name: string, kind: string }]} The list of updated records
3822 - */
3823 -
3824 -const __experimentalGetDirtyEntityRecords = rememo(state => {
3825 - const {
3826 - entities: {
3827 - data
3828 - }
3829 - } = state;
3830 - const dirtyRecords = [];
3831 - Object.keys(data).forEach(kind => {
3832 - Object.keys(data[kind]).forEach(name => {
3833 - const primaryKeys = Object.keys(data[kind][name].edits).filter(primaryKey => // The entity record must exist (not be deleted),
3834 - // and it must have edits.
3835 - getEntityRecord(state, kind, name, primaryKey) && hasEditsForEntityRecord(state, kind, name, primaryKey));
3836 -
3837 - if (primaryKeys.length) {
3838 - const entity = getEntity(state, kind, name);
3839 - primaryKeys.forEach(primaryKey => {
3840 - var _entity$getTitle;
3841 -
3842 - const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey);
3843 - dirtyRecords.push({
3844 - // We avoid using primaryKey because it's transformed into a string
3845 - // when it's used as an object key.
3846 - key: entityRecord[entity.key || DEFAULT_ENTITY_KEY],
3847 - title: (entity === null || entity === void 0 ? void 0 : (_entity$getTitle = entity.getTitle) === null || _entity$getTitle === void 0 ? void 0 : _entity$getTitle.call(entity, entityRecord)) || '',
3848 - name,
3849 - kind
3850 - });
3851 - });
3852 - }
3853 - });
3854 - });
3855 - return dirtyRecords;
3856 -}, state => [state.entities.data]);
3857 -/**
3858 - * Returns the list of entities currently being saved.
3859 - *
3860 - * @param {Object} state State tree.
3861 - *
3862 - * @return {[{ title: string, key: string, name: string, kind: string }]} The list of records being saved.
3863 - */
3864 -
3865 -const __experimentalGetEntitiesBeingSaved = rememo(state => {
3866 - const {
3867 - entities: {
3868 - data
3869 - }
3870 - } = state;
3871 - const recordsBeingSaved = [];
3872 - Object.keys(data).forEach(kind => {
3873 - Object.keys(data[kind]).forEach(name => {
3874 - const primaryKeys = Object.keys(data[kind][name].saving).filter(primaryKey => isSavingEntityRecord(state, kind, name, primaryKey));
3875 -
3876 - if (primaryKeys.length) {
3877 - const entity = getEntity(state, kind, name);
3878 - primaryKeys.forEach(primaryKey => {
3879 - var _entity$getTitle2;
3880 -
3881 - const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey);
3882 - recordsBeingSaved.push({
3883 - // We avoid using primaryKey because it's transformed into a string
3884 - // when it's used as an object key.
3885 - key: entityRecord[entity.key || DEFAULT_ENTITY_KEY],
3886 - title: (entity === null || entity === void 0 ? void 0 : (_entity$getTitle2 = entity.getTitle) === null || _entity$getTitle2 === void 0 ? void 0 : _entity$getTitle2.call(entity, entityRecord)) || '',
3887 - name,
3888 - kind
3889 - });
3890 - });
3891 - }
3892 - });
3893 - });
3894 - return recordsBeingSaved;
3895 -}, state => [state.entities.data]);
3896 -/**
3897 - * Returns the specified entity record's edits.
3898 - *
3899 - * @param {Object} state State tree.
3900 - * @param {string} kind Entity kind.
3901 - * @param {string} name Entity name.
3902 - * @param {number} recordId Record ID.
3903 - *
3904 - * @return {Object?} The entity record's edits.
3905 - */
3906 -
3907 -function getEntityRecordEdits(state, kind, name, recordId) {
3908 - return (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'edits', recordId]);
3909 -}
3910 -/**
3911 - * Returns the specified entity record's non transient edits.
3912 - *
3913 - * Transient edits don't create an undo level, and
3914 - * are not considered for change detection.
3915 - * They are defined in the entity's config.
3916 - *
3917 - * @param {Object} state State tree.
3918 - * @param {string} kind Entity kind.
3919 - * @param {string} name Entity name.
3920 - * @param {number} recordId Record ID.
3921 - *
3922 - * @return {Object?} The entity record's non transient edits.
3923 - */
3924 -
3925 -const getEntityRecordNonTransientEdits = rememo((state, kind, name, recordId) => {
3926 - const {
3927 - transientEdits
3928 - } = getEntity(state, kind, name) || {};
3929 - const edits = getEntityRecordEdits(state, kind, name, recordId) || {};
3930 -
3931 - if (!transientEdits) {
3932 - return edits;
3933 - }
3934 -
3935 - return Object.keys(edits).reduce((acc, key) => {
3936 - if (!transientEdits[key]) {
3937 - acc[key] = edits[key];
3938 - }
3939 -
3940 - return acc;
3941 - }, {});
3942 -}, (state, kind, name, recordId) => [state.entities.config, (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'edits', recordId])]);
3943 -/**
3944 - * Returns true if the specified entity record has edits,
3945 - * and false otherwise.
3946 - *
3947 - * @param {Object} state State tree.
3948 - * @param {string} kind Entity kind.
3949 - * @param {string} name Entity name.
3950 - * @param {number} recordId Record ID.
3951 - *
3952 - * @return {boolean} Whether the entity record has edits or not.
3953 - */
3954 -
3955 -function hasEditsForEntityRecord(state, kind, name, recordId) {
3956 - return isSavingEntityRecord(state, kind, name, recordId) || Object.keys(getEntityRecordNonTransientEdits(state, kind, name, recordId)).length > 0;
3957 -}
3958 -/**
3959 - * Returns the specified entity record, merged with its edits.
3960 - *
3961 - * @param {Object} state State tree.
3962 - * @param {string} kind Entity kind.
3963 - * @param {string} name Entity name.
3964 - * @param {number} recordId Record ID.
3965 - *
3966 - * @return {Object?} The entity record, merged with its edits.
3967 - */
3968 -
3969 -const getEditedEntityRecord = rememo((state, kind, name, recordId) => ({ ...getRawEntityRecord(state, kind, name, recordId),
3970 - ...getEntityRecordEdits(state, kind, name, recordId)
3971 -}), (state, kind, name, recordId, query) => {
3972 - var _query$context4;
3973 -
3974 - const context = (_query$context4 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context4 !== void 0 ? _query$context4 : 'default';
3975 - return [state.entities.config, (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'queriedData', 'items', context, recordId]), (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'queriedData', 'itemIsComplete', context, recordId]), (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'edits', recordId])];
3976 -});
3977 -/**
3978 - * Returns true if the specified entity record is autosaving, and false otherwise.
3979 - *
3980 - * @param {Object} state State tree.
3981 - * @param {string} kind Entity kind.
3982 - * @param {string} name Entity name.
3983 - * @param {number} recordId Record ID.
3984 - *
3985 - * @return {boolean} Whether the entity record is autosaving or not.
3986 - */
3987 -
3988 -function isAutosavingEntityRecord(state, kind, name, recordId) {
3989 - const {
3990 - pending,
3991 - isAutosave
3992 - } = (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'saving', recordId], {});
3993 - return Boolean(pending && isAutosave);
3994 -}
3995 -/**
3996 - * Returns true if the specified entity record is saving, and false otherwise.
3997 - *
3998 - * @param {Object} state State tree.
3999 - * @param {string} kind Entity kind.
4000 - * @param {string} name Entity name.
4001 - * @param {number} recordId Record ID.
4002 - *
4003 - * @return {boolean} Whether the entity record is saving or not.
4004 - */
4005 -
4006 -function isSavingEntityRecord(state, kind, name, recordId) {
4007 - return (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'saving', recordId, 'pending'], false);
4008 -}
4009 -/**
4010 - * Returns true if the specified entity record is deleting, and false otherwise.
4011 - *
4012 - * @param {Object} state State tree.
4013 - * @param {string} kind Entity kind.
4014 - * @param {string} name Entity name.
4015 - * @param {number} recordId Record ID.
4016 - *
4017 - * @return {boolean} Whether the entity record is deleting or not.
4018 - */
4019 -
4020 -function isDeletingEntityRecord(state, kind, name, recordId) {
4021 - return (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'deleting', recordId, 'pending'], false);
4022 -}
4023 -/**
4024 - * Returns the specified entity record's last save error.
4025 - *
4026 - * @param {Object} state State tree.
4027 - * @param {string} kind Entity kind.
4028 - * @param {string} name Entity name.
4029 - * @param {number} recordId Record ID.
4030 - *
4031 - * @return {Object?} The entity record's save error.
4032 - */
4033 -
4034 -function getLastEntitySaveError(state, kind, name, recordId) {
4035 - return (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'saving', recordId, 'error']);
4036 -}
4037 -/**
4038 - * Returns the specified entity record's last delete error.
4039 - *
4040 - * @param {Object} state State tree.
4041 - * @param {string} kind Entity kind.
4042 - * @param {string} name Entity name.
4043 - * @param {number} recordId Record ID.
4044 - *
4045 - * @return {Object?} The entity record's save error.
4046 - */
4047 -
4048 -function getLastEntityDeleteError(state, kind, name, recordId) {
4049 - return (0,external_lodash_namespaceObject.get)(state.entities.data, [kind, name, 'deleting', recordId, 'error']);
4050 -}
4051 -/**
4052 - * Returns the current undo offset for the
4053 - * entity records edits history. The offset
4054 - * represents how many items from the end
4055 - * of the history stack we are at. 0 is the
4056 - * last edit, -1 is the second last, and so on.
4057 - *
4058 - * @param {Object} state State tree.
4059 - *
4060 - * @return {number} The current undo offset.
4061 - */
4062 -
4063 -function getCurrentUndoOffset(state) {
4064 - return state.undo.offset;
4065 -}
4066 -/**
4067 - * Returns the previous edit from the current undo offset
4068 - * for the entity records edits history, if any.
4069 - *
4070 - * @param {Object} state State tree.
4071 - *
4072 - * @return {Object?} The edit.
4073 - */
4074 -
4075 -
4076 -function getUndoEdit(state) {
4077 - return state.undo[state.undo.length - 2 + getCurrentUndoOffset(state)];
4078 -}
4079 -/**
4080 - * Returns the next edit from the current undo offset
4081 - * for the entity records edits history, if any.
4082 - *
4083 - * @param {Object} state State tree.
4084 - *
4085 - * @return {Object?} The edit.
4086 - */
4087 -
4088 -function getRedoEdit(state) {
4089 - return state.undo[state.undo.length + getCurrentUndoOffset(state)];
4090 -}
4091 -/**
4092 - * Returns true if there is a previous edit from the current undo offset
4093 - * for the entity records edits history, and false otherwise.
4094 - *
4095 - * @param {Object} state State tree.
4096 - *
4097 - * @return {boolean} Whether there is a previous edit or not.
4098 - */
4099 -
4100 -function hasUndo(state) {
4101 - return Boolean(getUndoEdit(state));
4102 -}
4103 -/**
4104 - * Returns true if there is a next edit from the current undo offset
4105 - * for the entity records edits history, and false otherwise.
4106 - *
4107 - * @param {Object} state State tree.
4108 - *
4109 - * @return {boolean} Whether there is a next edit or not.
4110 - */
4111 -
4112 -function hasRedo(state) {
4113 - return Boolean(getRedoEdit(state));
4114 -}
4115 -/**
4116 - * Return the current theme.
4117 - *
4118 - * @param {Object} state Data state.
4119 - *
4120 - * @return {Object} The current theme.
4121 - */
4122 -
4123 -function getCurrentTheme(state) {
4124 - return getEntityRecord(state, 'root', 'theme', state.currentTheme);
4125 -}
4126 -/**
4127 - * Return the ID of the current global styles object.
4128 - *
4129 - * @param {Object} state Data state.
4130 - *
4131 - * @return {string} The current global styles ID.
4132 - */
4133 -
4134 -function __experimentalGetCurrentGlobalStylesId(state) {
4135 - return state.currentGlobalStylesId;
4136 -}
4137 -/**
4138 - * Return theme supports data in the index.
4139 - *
4140 - * @param {Object} state Data state.
4141 - *
4142 - * @return {*} Index data.
4143 - */
4144 -
4145 -function getThemeSupports(state) {
4146 - var _getCurrentTheme$them, _getCurrentTheme;
4147 -
4148 - return (_getCurrentTheme$them = (_getCurrentTheme = getCurrentTheme(state)) === null || _getCurrentTheme === void 0 ? void 0 : _getCurrentTheme.theme_supports) !== null && _getCurrentTheme$them !== void 0 ? _getCurrentTheme$them : EMPTY_OBJECT;
4149 -}
4150 -/**
4151 - * Returns the embed preview for the given URL.
4152 - *
4153 - * @param {Object} state Data state.
4154 - * @param {string} url Embedded URL.
4155 - *
4156 - * @return {*} Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
4157 - */
4158 -
4159 -function getEmbedPreview(state, url) {
4160 - return state.embedPreviews[url];
4161 -}
4162 -/**
4163 - * Determines if the returned preview is an oEmbed link fallback.
4164 - *
4165 - * WordPress can be configured to return a simple link to a URL if it is not embeddable.
4166 - * We need to be able to determine if a URL is embeddable or not, based on what we
4167 - * get back from the oEmbed preview API.
4168 - *
4169 - * @param {Object} state Data state.
4170 - * @param {string} url Embedded URL.
4171 - *
4172 - * @return {boolean} Is the preview for the URL an oEmbed link fallback.
4173 - */
4174 -
4175 -function isPreviewEmbedFallback(state, url) {
4176 - const preview = state.embedPreviews[url];
4177 - const oEmbedLinkCheck = '<a href="' + url + '">' + url + '</a>';
4178 -
4179 - if (!preview) {
4180 - return false;
4181 - }
4182 -
4183 - return preview.html === oEmbedLinkCheck;
4184 -}
4185 -/**
4186 - * Returns whether the current user can perform the given action on the given
4187 - * REST resource.
4188 - *
4189 - * Calling this may trigger an OPTIONS request to the REST API via the
4190 - * `canUser()` resolver.
4191 - *
4192 - * https://developer.wordpress.org/rest-api/reference/
4193 - *
4194 - * @param {Object} state Data state.
4195 - * @param {string} action Action to check. One of: 'create', 'read', 'update', 'delete'.
4196 - * @param {string} resource REST resource to check, e.g. 'media' or 'posts'.
4197 - * @param {string=} id Optional ID of the rest resource to check.
4198 - *
4199 - * @return {boolean|undefined} Whether or not the user can perform the action,
4200 - * or `undefined` if the OPTIONS request is still being made.
4201 - */
4202 -
4203 -function canUser(state, action, resource, id) {
4204 - const key = (0,external_lodash_namespaceObject.compact)([action, resource, id]).join('/');
4205 - return (0,external_lodash_namespaceObject.get)(state, ['userPermissions', key]);
4206 -}
4207 -/**
4208 - * Returns whether the current user can edit the given entity.
4209 - *
4210 - * Calling this may trigger an OPTIONS request to the REST API via the
4211 - * `canUser()` resolver.
4212 - *
4213 - * https://developer.wordpress.org/rest-api/reference/
4214 - *
4215 - * @param {Object} state Data state.
4216 - * @param {string} kind Entity kind.
4217 - * @param {string} name Entity name.
4218 - * @param {string} recordId Record's id.
4219 - * @return {boolean|undefined} Whether or not the user can edit,
4220 - * or `undefined` if the OPTIONS request is still being made.
4221 - */
4222 -
4223 -function canUserEditEntityRecord(state, kind, name, recordId) {
4224 - const entity = getEntity(state, kind, name);
4225 -
4226 - if (!entity) {
4227 - return false;
4228 - }
4229 -
4230 - const resource = entity.__unstable_rest_base;
4231 - return canUser(state, 'update', resource, recordId);
4232 -}
4233 -/**
4234 - * Returns the latest autosaves for the post.
4235 - *
4236 - * May return multiple autosaves since the backend stores one autosave per
4237 - * author for each post.
4238 - *
4239 - * @param {Object} state State tree.
4240 - * @param {string} postType The type of the parent post.
4241 - * @param {number} postId The id of the parent post.
4242 - *
4243 - * @return {?Array} An array of autosaves for the post, or undefined if there is none.
4244 - */
4245 -
4246 -function getAutosaves(state, postType, postId) {
4247 - return state.autosaves[postId];
4248 -}
4249 -/**
4250 - * Returns the autosave for the post and author.
4251 - *
4252 - * @param {Object} state State tree.
4253 - * @param {string} postType The type of the parent post.
4254 - * @param {number} postId The id of the parent post.
4255 - * @param {number} authorId The id of the author.
4256 - *
4257 - * @return {?Object} The autosave for the post and author.
4258 - */
4259 -
4260 -function getAutosave(state, postType, postId, authorId) {
4261 - if (authorId === undefined) {
4262 - return;
4263 - }
4264 -
4265 - const autosaves = state.autosaves[postId];
4266 - return (0,external_lodash_namespaceObject.find)(autosaves, {
4267 - author: authorId
4268 - });
4269 -}
4270 -/**
4271 - * Returns true if the REST request for autosaves has completed.
4272 - *
4273 - * @param {Object} state State tree.
4274 - * @param {string} postType The type of the parent post.
4275 - * @param {number} postId The id of the parent post.
4276 - *
4277 - * @return {boolean} True if the REST request was completed. False otherwise.
4278 - */
4279 -
4280 -const hasFetchedAutosaves = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, postId) => {
4281 - return select(STORE_NAME).hasFinishedResolution('getAutosaves', [postType, postId]);
4282 -});
4283 -/**
4284 - * Returns a new reference when edited values have changed. This is useful in
4285 - * inferring where an edit has been made between states by comparison of the
4286 - * return values using strict equality.
4287 - *
4288 - * @example
4289 - *
4290 - * ```
4291 - * const hasEditOccurred = (
4292 - * getReferenceByDistinctEdits( beforeState ) !==
4293 - * getReferenceByDistinctEdits( afterState )
4294 - * );
4295 - * ```
4296 - *
4297 - * @param {Object} state Editor state.
4298 - *
4299 - * @return {*} A value whose reference will change only when an edit occurs.
4300 - */
4301 -
4302 -const getReferenceByDistinctEdits = rememo(() => [], state => [state.undo.length, state.undo.offset, state.undo.flattenedUndo]);
4303 -/**
4304 - * Retrieve the frontend template used for a given link.
4305 - *
4306 - * @param {Object} state Editor state.
4307 - * @param {string} link Link.
4308 - *
4309 - * @return {Object?} The template record.
4310 - */
4311 -
4312 -function __experimentalGetTemplateForLink(state, link) {
4313 - const records = getEntityRecords(state, 'postType', 'wp_template', {
4314 - 'find-template': link
4315 - });
4316 - const template = records !== null && records !== void 0 && records.length ? records[0] : null;
4317 -
4318 - if (template) {
4319 - return getEditedEntityRecord(state, 'postType', 'wp_template', template.id);
4320 - }
4321 -
4322 - return template;
4323 -}
4324 -/**
4325 - * Retrieve the current theme's base global styles
4326 - *
4327 - * @param {Object} state Editor state.
4328 - *
4329 - * @return {Object?} The Global Styles object.
4330 - */
4331 -
4332 -function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
4333 - const currentTheme = getCurrentTheme(state);
4334 -
4335 - if (!currentTheme) {
4336 - return null;
4337 - }
4338 -
4339 - return state.themeBaseGlobalStyles[currentTheme.stylesheet];
4340 -}
4341 -/**
4342 - * Return the ID of the current global styles object.
4343 - *
4344 - * @param {Object} state Data state.
4345 - *
4346 - * @return {string} The current global styles ID.
4347 - */
4348 -
4349 -function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
4350 - const currentTheme = getCurrentTheme(state);
4351 -
4352 - if (!currentTheme) {
4353 - return null;
4354 - }
4355 -
4356 - return state.themeGlobalStyleVariations[currentTheme.stylesheet];
4357 -}
4358 -//# sourceMappingURL=selectors.js.map
4359 -;// CONCATENATED MODULE: ./packages/core-data/build-module/utils/forward-resolver.js
4360 -/**
4361 - * Higher-order function which forward the resolution to another resolver with the same arguments.
4362 - *
4363 - * @param {string} resolverName forwarded resolver.
4364 - *
4365 - * @return {Function} Enhanced resolver.
4366 - */
4367 -const forwardResolver = resolverName => function () {
4368 - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4369 - args[_key] = arguments[_key];
4370 - }
4371 -
4372 - return async _ref => {
4373 - let {
4374 - resolveSelect
4375 - } = _ref;
4376 - await resolveSelect[resolverName](...args);
4377 - };
4378 -};
4379 -
4380 -/* harmony default export */ var forward_resolver = (forwardResolver);
4381 -//# sourceMappingURL=forward-resolver.js.map
4382 -;// CONCATENATED MODULE: ./packages/core-data/build-module/resolvers.js
4383 -/**
4384 - * External dependencies
4385 - */
4386 -
4387 -/**
4388 - * WordPress dependencies
4389 - */
4390 -
4391 -
4392 -
4393 -/**
4394 - * Internal dependencies
4395 - */
4396 -
4397 -
4398 -
4399 -
4400 -/**
4401 - * Requests authors from the REST API.
4402 - *
4403 - * @param {Object|undefined} query Optional object of query parameters to
4404 - * include with request.
4405 - */
4406 -
4407 -const resolvers_getAuthors = query => async _ref => {
4408 - let {
4409 - dispatch
4410 - } = _ref;
4411 - const path = (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/users/?who=authors&per_page=100', query);
4412 - const users = await external_wp_apiFetch_default()({
4413 - path
4414 - });
4415 - dispatch.receiveUserQuery(path, users);
4416 -};
4417 -/**
4418 - * Requests the current user from the REST API.
4419 - */
4420 -
4421 -const resolvers_getCurrentUser = () => async _ref2 => {
4422 - let {
4423 - dispatch
4424 - } = _ref2;
4425 - const currentUser = await external_wp_apiFetch_default()({
4426 - path: '/wp/v2/users/me'
4427 - });
4428 - dispatch.receiveCurrentUser(currentUser);
4429 -};
4430 -/**
4431 - * Requests an entity's record from the REST API.
4432 - *
4433 - * @param {string} kind Entity kind.
4434 - * @param {string} name Entity name.
4435 - * @param {number|string} key Record's key
4436 - * @param {Object|undefined} query Optional object of query parameters to
4437 - * include with request.
4438 - */
4439 -
4440 -const resolvers_getEntityRecord = function (kind, name) {
4441 - let key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
4442 - let query = arguments.length > 3 ? arguments[3] : undefined;
4443 - return async _ref3 => {
4444 - let {
4445 - select,
4446 - dispatch
4447 - } = _ref3;
4448 - const entities = await dispatch(getKindEntities(kind));
4449 - const entity = (0,external_lodash_namespaceObject.find)(entities, {
4450 - kind,
4451 - name
4452 - });
4453 -
4454 - if (!entity || entity !== null && entity !== void 0 && entity.__experimentalNoFetch) {
4455 - return;
4456 - }
4457 -
4458 - const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'data', kind, name, key], {
4459 - exclusive: false
4460 - });
4461 -
4462 - try {
4463 - if (query !== undefined && query._fields) {
4464 - // If requesting specific fields, items and query association to said
4465 - // records are stored by ID reference. Thus, fields must always include
4466 - // the ID.
4467 - query = { ...query,
4468 - _fields: (0,external_lodash_namespaceObject.uniq)([...(get_normalized_comma_separable(query._fields) || []), entity.key || DEFAULT_ENTITY_KEY]).join()
4469 - };
4470 - } // Disable reason: While true that an early return could leave `path`
4471 - // unused, it's important that path is derived using the query prior to
4472 - // additional query modifications in the condition below, since those
4473 - // modifications are relevant to how the data is tracked in state, and not
4474 - // for how the request is made to the REST API.
4475 - // eslint-disable-next-line @wordpress/no-unused-vars-before-return
4476 -
4477 -
4478 - const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entity.baseURL + (key ? '/' + key : ''), { ...entity.baseURLParams,
4479 - ...query
4480 - });
4481 -
4482 - if (query !== undefined) {
4483 - query = { ...query,
4484 - include: [key]
4485 - }; // The resolution cache won't consider query as reusable based on the
4486 - // fields, so it's tested here, prior to initiating the REST request,
4487 - // and without causing `getEntityRecords` resolution to occur.
4488 -
4489 - const hasRecords = select.hasEntityRecords(kind, name, query);
4490 -
4491 - if (hasRecords) {
4492 - return;
4493 - }
4494 - }
4495 -
4496 - const record = await external_wp_apiFetch_default()({
4497 - path
4498 - });
4499 - dispatch.receiveEntityRecords(kind, name, record, query);
4500 - } catch (error) {// We need a way to handle and access REST API errors in state
4501 - // Until then, catching the error ensures the resolver is marked as resolved.
4502 - // See similar implementation in `getEntityRecords()`.
4503 - } finally {
4504 - dispatch.__unstableReleaseStoreLock(lock);
4505 - }
4506 - };
4507 -};
4508 -/**
4509 - * Requests an entity's record from the REST API.
4510 - */
4511 -
4512 -const resolvers_getRawEntityRecord = forward_resolver('getEntityRecord');
4513 -/**
4514 - * Requests an entity's record from the REST API.
4515 - */
4516 -
4517 -const resolvers_getEditedEntityRecord = forward_resolver('getEntityRecord');
4518 -/**
4519 - * Requests the entity's records from the REST API.
4520 - *
4521 - * @param {string} kind Entity kind.
4522 - * @param {string} name Entity name.
4523 - * @param {Object?} query Query Object.
4524 - */
4525 -
4526 -const resolvers_getEntityRecords = function (kind, name) {
4527 - let query = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4528 - return async _ref4 => {
4529 - let {
4530 - dispatch
4531 - } = _ref4;
4532 - const entities = await dispatch(getKindEntities(kind));
4533 - const entity = (0,external_lodash_namespaceObject.find)(entities, {
4534 - kind,
4535 - name
4536 - });
4537 -
4538 - if (!entity || entity !== null && entity !== void 0 && entity.__experimentalNoFetch) {
4539 - return;
4540 - }
4541 -
4542 - const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'data', kind, name], {
4543 - exclusive: false
4544 - });
4545 -
4546 - try {
4547 - var _query;
4548 -
4549 - if (query._fields) {
4550 - // If requesting specific fields, items and query association to said
4551 - // records are stored by ID reference. Thus, fields must always include
4552 - // the ID.
4553 - query = { ...query,
4554 - _fields: (0,external_lodash_namespaceObject.uniq)([...(get_normalized_comma_separable(query._fields) || []), entity.key || DEFAULT_ENTITY_KEY]).join()
4555 - };
4556 - }
4557 -
4558 - const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entity.baseURL, { ...entity.baseURLParams,
4559 - ...query
4560 - });
4561 - let records = Object.values(await external_wp_apiFetch_default()({
4562 - path
4563 - })); // If we request fields but the result doesn't contain the fields,
4564 - // explicitely set these fields as "undefined"
4565 - // that way we consider the query "fullfilled".
4566 -
4567 - if (query._fields) {
4568 - records = records.map(record => {
4569 - query._fields.split(',').forEach(field => {
4570 - if (!record.hasOwnProperty(field)) {
4571 - record[field] = undefined;
4572 - }
4573 - });
4574 -
4575 - return record;
4576 - });
4577 - }
4578 -
4579 - dispatch.receiveEntityRecords(kind, name, records, query); // When requesting all fields, the list of results can be used to
4580 - // resolve the `getEntityRecord` selector in addition to `getEntityRecords`.
4581 - // See https://github.com/WordPress/gutenberg/pull/26575
4582 -
4583 - if (!((_query = query) !== null && _query !== void 0 && _query._fields) && !query.context) {
4584 - const key = entity.key || DEFAULT_ENTITY_KEY;
4585 - const resolutionsArgs = records.filter(record => record[key]).map(record => [kind, name, record[key]]);
4586 - dispatch({
4587 - type: 'START_RESOLUTIONS',
4588 - selectorName: 'getEntityRecord',
4589 - args: resolutionsArgs
4590 - });
4591 - dispatch({
4592 - type: 'FINISH_RESOLUTIONS',
4593 - selectorName: 'getEntityRecord',
4594 - args: resolutionsArgs
4595 - });
4596 - }
4597 - } catch (error) {// We need a way to handle and access REST API errors in state
4598 - // Until then, catching the error ensures the resolver is marked as resolved.
4599 - // See similar implementation in `getEntityRecord()`.
4600 - } finally {
4601 - dispatch.__unstableReleaseStoreLock(lock);
4602 - }
4603 - };
4604 -};
4605 -
4606 -resolvers_getEntityRecords.shouldInvalidate = (action, kind, name) => {
4607 - return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && kind === action.kind && name === action.name;
4608 -};
4609 -/**
4610 - * Requests the current theme.
4611 - */
4612 -
4613 -
4614 -const resolvers_getCurrentTheme = () => async _ref5 => {
4615 - let {
4616 - dispatch,
4617 - resolveSelect
4618 - } = _ref5;
4619 - const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
4620 - status: 'active'
4621 - });
4622 - dispatch.receiveCurrentTheme(activeThemes[0]);
4623 -};
4624 -/**
4625 - * Requests theme supports data from the index.
4626 - */
4627 -
4628 -const resolvers_getThemeSupports = forward_resolver('getCurrentTheme');
4629 -/**
4630 - * Requests a preview from the from the Embed API.
4631 - *
4632 - * @param {string} url URL to get the preview for.
4633 - */
4634 -
4635 -const resolvers_getEmbedPreview = url => async _ref6 => {
4636 - let {
4637 - dispatch
4638 - } = _ref6;
4639 -
4640 - try {
4641 - const embedProxyResponse = await external_wp_apiFetch_default()({
4642 - path: (0,external_wp_url_namespaceObject.addQueryArgs)('/oembed/1.0/proxy', {
4643 - url
4644 - })
4645 - });
4646 - dispatch.receiveEmbedPreview(url, embedProxyResponse);
4647 - } catch (error) {
4648 - // Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here.
4649 - dispatch.receiveEmbedPreview(url, false);
4650 - }
4651 -};
4652 -/**
4653 - * Checks whether the current user can perform the given action on the given
4654 - * REST resource.
4655 - *
4656 - * @param {string} action Action to check. One of: 'create', 'read', 'update',
4657 - * 'delete'.
4658 - * @param {string} resource REST resource to check, e.g. 'media' or 'posts'.
4659 - * @param {?string} id ID of the rest resource to check.
4660 - */
4661 -
4662 -const resolvers_canUser = (action, resource, id) => async _ref7 => {
4663 - let {
4664 - dispatch
4665 - } = _ref7;
4666 - const methods = {
4667 - create: 'POST',
4668 - read: 'GET',
4669 - update: 'PUT',
4670 - delete: 'DELETE'
4671 - };
4672 - const method = methods[action];
4673 -
4674 - if (!method) {
4675 - throw new Error(`'${action}' is not a valid action.`);
4676 - }
4677 -
4678 - const path = id ? `/wp/v2/${resource}/${id}` : `/wp/v2/${resource}`;
4679 - let response;
4680 -
4681 - try {
4682 - response = await external_wp_apiFetch_default()({
4683 - path,
4684 - // Ideally this would always be an OPTIONS request, but unfortunately there's
4685 - // a bug in the REST API which causes the Allow header to not be sent on
4686 - // OPTIONS requests to /posts/:id routes.
4687 - // https://core.trac.wordpress.org/ticket/45753
4688 - method: id ? 'GET' : 'OPTIONS',
4689 - parse: false
4690 - });
4691 - } catch (error) {
4692 - // Do nothing if our OPTIONS request comes back with an API error (4xx or
4693 - // 5xx). The previously determined isAllowed value will remain in the store.
4694 - return;
4695 - }
4696 -
4697 - let allowHeader;
4698 -
4699 - if ((0,external_lodash_namespaceObject.hasIn)(response, ['headers', 'get'])) {
4700 - // If the request is fetched using the fetch api, the header can be
4701 - // retrieved using the 'get' method.
4702 - allowHeader = response.headers.get('allow');
4703 - } else {
4704 - // If the request was preloaded server-side and is returned by the
4705 - // preloading middleware, the header will be a simple property.
4706 - allowHeader = (0,external_lodash_namespaceObject.get)(response, ['headers', 'Allow'], '');
4707 - }
4708 -
4709 - const key = (0,external_lodash_namespaceObject.compact)([action, resource, id]).join('/');
4710 - const isAllowed = (0,external_lodash_namespaceObject.includes)(allowHeader, method);
4711 - dispatch.receiveUserPermission(key, isAllowed);
4712 -};
4713 -/**
4714 - * Checks whether the current user can perform the given action on the given
4715 - * REST resource.
4716 - *
4717 - * @param {string} kind Entity kind.
4718 - * @param {string} name Entity name.
4719 - * @param {string} recordId Record's id.
4720 - */
4721 -
4722 -const resolvers_canUserEditEntityRecord = (kind, name, recordId) => async _ref8 => {
4723 - let {
4724 - dispatch
4725 - } = _ref8;
4726 - const entities = await dispatch(getKindEntities(kind));
4727 - const entity = (0,external_lodash_namespaceObject.find)(entities, {
4728 - kind,
4729 - name
4730 - });
4731 -
4732 - if (!entity) {
4733 - return;
4734 - }
4735 -
4736 - const resource = entity.__unstable_rest_base;
4737 - await dispatch(resolvers_canUser('update', resource, recordId));
4738 -};
4739 -/**
4740 - * Request autosave data from the REST API.
4741 - *
4742 - * @param {string} postType The type of the parent post.
4743 - * @param {number} postId The id of the parent post.
4744 - */
4745 -
4746 -const resolvers_getAutosaves = (postType, postId) => async _ref9 => {
4747 - let {
4748 - dispatch,
4749 - resolveSelect
4750 - } = _ref9;
4751 - const {
4752 - rest_base: restBase
4753 - } = await resolveSelect.getPostType(postType);
4754 - const autosaves = await external_wp_apiFetch_default()({
4755 - path: `/wp/v2/${restBase}/${postId}/autosaves?context=edit`
4756 - });
4757 -
4758 - if (autosaves && autosaves.length) {
4759 - dispatch.receiveAutosaves(postId, autosaves);
4760 - }
4761 -};
4762 -/**
4763 - * Request autosave data from the REST API.
4764 - *
4765 - * This resolver exists to ensure the underlying autosaves are fetched via
4766 - * `getAutosaves` when a call to the `getAutosave` selector is made.
4767 - *
4768 - * @param {string} postType The type of the parent post.
4769 - * @param {number} postId The id of the parent post.
4770 - */
4771 -
4772 -const resolvers_getAutosave = (postType, postId) => async _ref10 => {
4773 - let {
4774 - resolveSelect
4775 - } = _ref10;
4776 - await resolveSelect.getAutosaves(postType, postId);
4777 -};
4778 -/**
4779 - * Retrieve the frontend template used for a given link.
4780 - *
4781 - * @param {string} link Link.
4782 - */
4783 -
4784 -const resolvers_experimentalGetTemplateForLink = link => async _ref11 => {
4785 - let {
4786 - dispatch,
4787 - resolveSelect
4788 - } = _ref11;
4789 - // Ideally this should be using an apiFetch call
4790 - // We could potentially do so by adding a "filter" to the `wp_template` end point.
4791 - // Also it seems the returned object is not a regular REST API post type.
4792 - let template;
4793 -
4794 - try {
4795 - template = await window.fetch((0,external_wp_url_namespaceObject.addQueryArgs)(link, {
4796 - '_wp-find-template': true
4797 - })).then(res => res.json()).then(_ref12 => {
4798 - let {
4799 - data
4800 - } = _ref12;
4801 - return data;
4802 - });
4803 - } catch (e) {// For non-FSE themes, it is possible that this request returns an error.
4804 - }
4805 -
4806 - if (!template) {
4807 - return;
4808 - }
4809 -
4810 - const record = await resolveSelect.getEntityRecord('postType', 'wp_template', template.id);
4811 -
4812 - if (record) {
4813 - dispatch.receiveEntityRecords('postType', 'wp_template', [record], {
4814 - 'find-template': link
4815 - });
4816 - }
4817 -};
4818 -
4819 -resolvers_experimentalGetTemplateForLink.shouldInvalidate = action => {
4820 - return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && action.kind === 'postType' && action.name === 'wp_template';
4821 -};
4822 -
4823 -const resolvers_experimentalGetCurrentGlobalStylesId = () => async _ref13 => {
4824 - let {
4825 - dispatch,
4826 - resolveSelect
4827 - } = _ref13;
4828 - const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
4829 - status: 'active'
4830 - });
4831 - const globalStylesURL = (0,external_lodash_namespaceObject.get)(activeThemes, [0, '_links', 'wp:user-global-styles', 0, 'href']);
4832 -
4833 - if (globalStylesURL) {
4834 - const globalStylesObject = await external_wp_apiFetch_default()({
4835 - url: globalStylesURL
4836 - });
4837 -
4838 - dispatch.__experimentalReceiveCurrentGlobalStylesId(globalStylesObject.id);
4839 - }
4840 -};
4841 -const resolvers_experimentalGetCurrentThemeBaseGlobalStyles = () => async _ref14 => {
4842 - let {
4843 - resolveSelect,
4844 - dispatch
4845 - } = _ref14;
4846 - const currentTheme = await resolveSelect.getCurrentTheme();
4847 - const themeGlobalStyles = await external_wp_apiFetch_default()({
4848 - path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}`
4849 - });
4850 -
4851 - dispatch.__experimentalReceiveThemeBaseGlobalStyles(currentTheme.stylesheet, themeGlobalStyles);
4852 -};
4853 -const resolvers_experimentalGetCurrentThemeGlobalStylesVariations = () => async _ref15 => {
4854 - let {
4855 - resolveSelect,
4856 - dispatch
4857 - } = _ref15;
4858 - const currentTheme = await resolveSelect.getCurrentTheme();
4859 - const variations = await external_wp_apiFetch_default()({
4860 - path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}/variations`
4861 - });
4862 -
4863 - dispatch.__experimentalReceiveThemeGlobalStyleVariations(currentTheme.stylesheet, variations);
4864 -};
4865 -//# sourceMappingURL=resolvers.js.map
4866 -;// CONCATENATED MODULE: ./packages/core-data/build-module/locks/utils.js
4867 -function deepCopyLocksTreePath(tree, path) {
4868 - const newTree = { ...tree
4869 - };
4870 - let currentNode = newTree;
4871 -
4872 - for (const branchName of path) {
4873 - currentNode.children = { ...currentNode.children,
4874 - [branchName]: {
4875 - locks: [],
4876 - children: {},
4877 - ...currentNode.children[branchName]
4878 - }
4879 - };
4880 - currentNode = currentNode.children[branchName];
4881 - }
4882 -
4883 - return newTree;
4884 -}
4885 -function getNode(tree, path) {
4886 - let currentNode = tree;
4887 -
4888 - for (const branchName of path) {
4889 - const nextNode = currentNode.children[branchName];
4890 -
4891 - if (!nextNode) {
4892 - return null;
4893 - }
4894 -
4895 - currentNode = nextNode;
4896 - }
4897 -
4898 - return currentNode;
4899 -}
4900 -function* iteratePath(tree, path) {
4901 - let currentNode = tree;
4902 - yield currentNode;
4903 -
4904 - for (const branchName of path) {
4905 - const nextNode = currentNode.children[branchName];
4906 -
4907 - if (!nextNode) {
4908 - break;
4909 - }
4910 -
4911 - yield nextNode;
4912 - currentNode = nextNode;
4913 - }
4914 -}
4915 -function* iterateDescendants(node) {
4916 - const stack = Object.values(node.children);
4917 -
4918 - while (stack.length) {
4919 - const childNode = stack.pop();
4920 - yield childNode;
4921 - stack.push(...Object.values(childNode.children));
4922 - }
4923 -}
4924 -function hasConflictingLock(_ref, locks) {
4925 - let {
4926 - exclusive
4927 - } = _ref;
4928 -
4929 - if (exclusive && locks.length) {
4930 - return true;
4931 - }
4932 -
4933 - if (!exclusive && locks.filter(lock => lock.exclusive).length) {
4934 - return true;
4935 - }
4936 -
4937 - return false;
4938 -}
4939 -//# sourceMappingURL=utils.js.map
4940 -;// CONCATENATED MODULE: ./packages/core-data/build-module/locks/reducer.js
4941 -/**
4942 - * Internal dependencies
4943 - */
4944 -
4945 -const DEFAULT_STATE = {
4946 - requests: [],
4947 - tree: {
4948 - locks: [],
4949 - children: {}
4950 - }
4951 -};
4952 -/**
4953 - * Reducer returning locks.
4954 - *
4955 - * @param {Object} state Current state.
4956 - * @param {Object} action Dispatched action.
4957 - *
4958 - * @return {Object} Updated state.
4959 - */
4960 -
4961 -function locks() {
4962 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_STATE;
4963 - let action = arguments.length > 1 ? arguments[1] : undefined;
4964 -
4965 - switch (action.type) {
4966 - case 'ENQUEUE_LOCK_REQUEST':
4967 - {
4968 - const {
4969 - request
4970 - } = action;
4971 - return { ...state,
4972 - requests: [request, ...state.requests]
4973 - };
4974 - }
4975 -
4976 - case 'GRANT_LOCK_REQUEST':
4977 - {
4978 - const {
4979 - lock,
4980 - request
4981 - } = action;
4982 - const {
4983 - store,
4984 - path
4985 - } = request;
4986 - const storePath = [store, ...path];
4987 - const newTree = deepCopyLocksTreePath(state.tree, storePath);
4988 - const node = getNode(newTree, storePath);
4989 - node.locks = [...node.locks, lock];
4990 - return { ...state,
4991 - requests: state.requests.filter(r => r !== request),
4992 - tree: newTree
4993 - };
4994 - }
4995 -
4996 - case 'RELEASE_LOCK':
4997 - {
4998 - const {
4999 - lock
5000 - } = action;
5001 - const storePath = [lock.store, ...lock.path];
5002 - const newTree = deepCopyLocksTreePath(state.tree, storePath);
5003 - const node = getNode(newTree, storePath);
5004 - node.locks = node.locks.filter(l => l !== lock);
5005 - return { ...state,
5006 - tree: newTree
5007 - };
5008 - }
5009 - }
5010 -
5011 - return state;
5012 -}
5013 -//# sourceMappingURL=reducer.js.map
5014 -;// CONCATENATED MODULE: ./packages/core-data/build-module/locks/selectors.js
5015 -/**
5016 - * Internal dependencies
5017 - */
5018 -
5019 -function getPendingLockRequests(state) {
5020 - return state.requests;
5021 -}
5022 -function isLockAvailable(state, store, path, _ref) {
5023 - let {
5024 - exclusive
5025 - } = _ref;
5026 - const storePath = [store, ...path];
5027 - const locks = state.tree; // Validate all parents and the node itself
5028 -
5029 - for (const node of iteratePath(locks, storePath)) {
5030 - if (hasConflictingLock({
5031 - exclusive
5032 - }, node.locks)) {
5033 - return false;
5034 - }
5035 - } // iteratePath terminates early if path is unreachable, let's
5036 - // re-fetch the node and check it exists in the tree.
5037 -
5038 -
5039 - const node = getNode(locks, storePath);
5040 -
5041 - if (!node) {
5042 - return true;
5043 - } // Validate all nested nodes
5044 -
5045 -
5046 - for (const descendant of iterateDescendants(node)) {
5047 - if (hasConflictingLock({
5048 - exclusive
5049 - }, descendant.locks)) {
5050 - return false;
5051 - }
5052 - }
5053 -
5054 - return true;
5055 -}
5056 -//# sourceMappingURL=selectors.js.map
5057 -;// CONCATENATED MODULE: ./packages/core-data/build-module/locks/engine.js
5058 -/**
5059 - * Internal dependencies
5060 - */
5061 -
5062 -
5063 -function createLocks() {
5064 - let state = locks(undefined, {
5065 - type: '@@INIT'
5066 - });
5067 -
5068 - function processPendingLockRequests() {
5069 - for (const request of getPendingLockRequests(state)) {
5070 - const {
5071 - store,
5072 - path,
5073 - exclusive,
5074 - notifyAcquired
5075 - } = request;
5076 -
5077 - if (isLockAvailable(state, store, path, {
5078 - exclusive
5079 - })) {
5080 - const lock = {
5081 - store,
5082 - path,
5083 - exclusive
5084 - };
5085 - state = locks(state, {
5086 - type: 'GRANT_LOCK_REQUEST',
5087 - lock,
5088 - request
5089 - });
5090 - notifyAcquired(lock);
5091 - }
5092 - }
5093 - }
5094 -
5095 - function acquire(store, path, exclusive) {
5096 - return new Promise(resolve => {
5097 - state = locks(state, {
5098 - type: 'ENQUEUE_LOCK_REQUEST',
5099 - request: {
5100 - store,
5101 - path,
5102 - exclusive,
5103 - notifyAcquired: resolve
5104 - }
5105 - });
5106 - processPendingLockRequests();
5107 - });
5108 - }
5109 -
5110 - function release(lock) {
5111 - state = locks(state, {
5112 - type: 'RELEASE_LOCK',
5113 - lock
5114 - });
5115 - processPendingLockRequests();
5116 - }
5117 -
5118 - return {
5119 - acquire,
5120 - release
5121 - };
5122 -}
5123 -//# sourceMappingURL=engine.js.map
5124 -;// CONCATENATED MODULE: ./packages/core-data/build-module/locks/actions.js
5125 -/**
5126 - * Internal dependencies
5127 - */
5128 -
5129 -function createLocksActions() {
5130 - const locks = createLocks();
5131 -
5132 - function __unstableAcquireStoreLock(store, path, _ref) {
5133 - let {
5134 - exclusive
5135 - } = _ref;
5136 - return () => locks.acquire(store, path, exclusive);
5137 - }
5138 -
5139 - function __unstableReleaseStoreLock(lock) {
5140 - return () => locks.release(lock);
5141 - }
5142 -
5143 - return {
5144 - __unstableAcquireStoreLock,
5145 - __unstableReleaseStoreLock
5146 - };
5147 -}
5148 -//# sourceMappingURL=actions.js.map
5149 -;// CONCATENATED MODULE: external ["wp","element"]
5150 -var external_wp_element_namespaceObject = window["wp"]["element"];
5151 -;// CONCATENATED MODULE: external ["wp","blocks"]
5152 -var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
5153 -;// CONCATENATED MODULE: ./packages/core-data/build-module/entity-provider.js
5154 -
5155 -
5156 -/**
5157 - * WordPress dependencies
5158 - */
5159 -
5160 -
5161 -
5162 -/**
5163 - * Internal dependencies
5164 - */
5165 -
5166 -
5167 -const EMPTY_ARRAY = [];
5168 -/**
5169 - * Internal dependencies
5170 - */
5171 -
5172 -
5173 -const entity_provider_entities = { ...defaultEntities.reduce((acc, entity) => {
5174 - if (!acc[entity.kind]) {
5175 - acc[entity.kind] = {};
5176 - }
5177 -
5178 - acc[entity.kind][entity.name] = {
5179 - context: (0,external_wp_element_namespaceObject.createContext)()
5180 - };
5181 - return acc;
5182 - }, {}),
5183 - ...kinds.reduce((acc, kind) => {
5184 - acc[kind.name] = {};
5185 - return acc;
5186 - }, {})
5187 -};
5188 -
5189 -const entity_provider_getEntity = (kind, type) => {
5190 - if (!entity_provider_entities[kind]) {
5191 - throw new Error(`Missing entity config for kind: ${kind}.`);
5192 - }
5193 -
5194 - if (!entity_provider_entities[kind][type]) {
5195 - entity_provider_entities[kind][type] = {
5196 - context: (0,external_wp_element_namespaceObject.createContext)()
5197 - };
5198 - }
5199 -
5200 - return entity_provider_entities[kind][type];
5201 -};
5202 -/**
5203 - * Context provider component for providing
5204 - * an entity for a specific entity type.
5205 - *
5206 - * @param {Object} props The component's props.
5207 - * @param {string} props.kind The entity kind.
5208 - * @param {string} props.type The entity type.
5209 - * @param {number} props.id The entity ID.
5210 - * @param {*} props.children The children to wrap.
5211 - *
5212 - * @return {Object} The provided children, wrapped with
5213 - * the entity's context provider.
5214 - */
5215 -
5216 -
5217 -function EntityProvider(_ref) {
5218 - let {
5219 - kind,
5220 - type,
5221 - id,
5222 - children
5223 - } = _ref;
5224 - const Provider = entity_provider_getEntity(kind, type).context.Provider;
5225 - return (0,external_wp_element_namespaceObject.createElement)(Provider, {
5226 - value: id
5227 - }, children);
5228 -}
5229 -/**
5230 - * Hook that returns the ID for the nearest
5231 - * provided entity of the specified type.
5232 - *
5233 - * @param {string} kind The entity kind.
5234 - * @param {string} type The entity type.
5235 - */
5236 -
5237 -function useEntityId(kind, type) {
5238 - return (0,external_wp_element_namespaceObject.useContext)(entity_provider_getEntity(kind, type).context);
5239 -}
5240 -/**
5241 - * Hook that returns the value and a setter for the
5242 - * specified property of the nearest provided
5243 - * entity of the specified type.
5244 - *
5245 - * @param {string} kind The entity kind.
5246 - * @param {string} type The entity type.
5247 - * @param {string} prop The property name.
5248 - * @param {string} [_id] An entity ID to use instead of the context-provided one.
5249 - *
5250 - * @return {[*, Function, *]} An array where the first item is the
5251 - * property value, the second is the
5252 - * setter and the third is the full value
5253 - * object from REST API containing more
5254 - * information like `raw`, `rendered` and
5255 - * `protected` props.
5256 - */
5257 -
5258 -function useEntityProp(kind, type, prop, _id) {
5259 - const providerId = useEntityId(kind, type);
5260 - const id = _id !== null && _id !== void 0 ? _id : providerId;
5261 - const {
5262 - value,
5263 - fullValue
5264 - } = (0,external_wp_data_namespaceObject.useSelect)(select => {
5265 - const {
5266 - getEntityRecord,
5267 - getEditedEntityRecord
5268 - } = select(STORE_NAME);
5269 - const entity = getEntityRecord(kind, type, id); // Trigger resolver.
5270 -
5271 - const editedEntity = getEditedEntityRecord(kind, type, id);
5272 - return entity && editedEntity ? {
5273 - value: editedEntity[prop],
5274 - fullValue: entity[prop]
5275 - } : {};
5276 - }, [kind, type, id, prop]);
5277 - const {
5278 - editEntityRecord
5279 - } = (0,external_wp_data_namespaceObject.useDispatch)(STORE_NAME);
5280 - const setValue = (0,external_wp_element_namespaceObject.useCallback)(newValue => {
5281 - editEntityRecord(kind, type, id, {
5282 - [prop]: newValue
5283 - });
5284 - }, [kind, type, id, prop]);
5285 - return [value, setValue, fullValue];
5286 -}
5287 -/**
5288 - * Hook that returns block content getters and setters for
5289 - * the nearest provided entity of the specified type.
5290 - *
5291 - * The return value has the shape `[ blocks, onInput, onChange ]`.
5292 - * `onInput` is for block changes that don't create undo levels
5293 - * or dirty the post, non-persistent changes, and `onChange` is for
5294 - * peristent changes. They map directly to the props of a
5295 - * `BlockEditorProvider` and are intended to be used with it,
5296 - * or similar components or hooks.
5297 - *
5298 - * @param {string} kind The entity kind.
5299 - * @param {string} type The entity type.
5300 - * @param {Object} options
5301 - * @param {string} [options.id] An entity ID to use instead of the context-provided one.
5302 - *
5303 - * @return {[WPBlock[], Function, Function]} The block array and setters.
5304 - */
5305 -
5306 -function useEntityBlockEditor(kind, type) {
5307 - let {
5308 - id: _id
5309 - } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5310 - const providerId = useEntityId(kind, type);
5311 - const id = _id !== null && _id !== void 0 ? _id : providerId;
5312 - const {
5313 - content,
5314 - blocks
5315 - } = (0,external_wp_data_namespaceObject.useSelect)(select => {
5316 - const {
5317 - getEditedEntityRecord
5318 - } = select(STORE_NAME);
5319 - const editedEntity = getEditedEntityRecord(kind, type, id);
5320 - return {
5321 - blocks: editedEntity.blocks,
5322 - content: editedEntity.content
5323 - };
5324 - }, [kind, type, id]);
5325 - const {
5326 - __unstableCreateUndoLevel,
5327 - editEntityRecord
5328 - } = (0,external_wp_data_namespaceObject.useDispatch)(STORE_NAME);
5329 - (0,external_wp_element_namespaceObject.useEffect)(() => {
5330 - // Load the blocks from the content if not already in state
5331 - // Guard against other instances that might have
5332 - // set content to a function already or the blocks are already in state.
5333 - if (content && typeof content !== 'function' && !blocks) {
5334 - const parsedContent = (0,external_wp_blocks_namespaceObject.parse)(content);
5335 - editEntityRecord(kind, type, id, {
5336 - blocks: parsedContent
5337 - }, {
5338 - undoIgnore: true
5339 - });
5340 - }
5341 - }, [content]);
5342 - const onChange = (0,external_wp_element_namespaceObject.useCallback)((newBlocks, options) => {
5343 - const {
5344 - selection
5345 - } = options;
5346 - const edits = {
5347 - blocks: newBlocks,
5348 - selection
5349 - };
5350 - const noChange = blocks === edits.blocks;
5351 -
5352 - if (noChange) {
5353 - return __unstableCreateUndoLevel(kind, type, id);
5354 - } // We create a new function here on every persistent edit
5355 - // to make sure the edit makes the post dirty and creates
5356 - // a new undo level.
5357 -
5358 -
5359 - edits.content = _ref2 => {
5360 - let {
5361 - blocks: blocksForSerialization = []
5362 - } = _ref2;
5363 - return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
5364 - };
5365 -
5366 - editEntityRecord(kind, type, id, edits);
5367 - }, [kind, type, id, blocks]);
5368 - const onInput = (0,external_wp_element_namespaceObject.useCallback)((newBlocks, options) => {
5369 - const {
5370 - selection
5371 - } = options;
5372 - const edits = {
5373 - blocks: newBlocks,
5374 - selection
5375 - };
5376 - editEntityRecord(kind, type, id, edits);
5377 - }, [kind, type, id]);
5378 - return [blocks !== null && blocks !== void 0 ? blocks : EMPTY_ARRAY, onInput, onChange];
5379 -}
5380 -//# sourceMappingURL=entity-provider.js.map
5381 -;// CONCATENATED MODULE: external ["wp","htmlEntities"]
5382 -var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
5383 -;// CONCATENATED MODULE: ./packages/core-data/build-module/fetch/__experimental-fetch-link-suggestions.js
5384 -/**
5385 - * WordPress dependencies
5386 - */
5387 -
5388 -
5389 -
5390 -
5391 -/**
5392 - * Filters the search by type
5393 - *
5394 - * @typedef { 'post' | 'term' | 'post-format' } WPLinkSearchType
5395 - */
5396 -
5397 -/**
5398 - * A link with an id may be of kind post-type or taxonomy
5399 - *
5400 - * @typedef { 'post-type' | 'taxonomy' } WPKind
5401 - */
5402 -
5403 -/**
5404 - * @typedef WPLinkSearchOptions
5405 - *
5406 - * @property {boolean} [isInitialSuggestions] Displays initial search suggestions, when true.
5407 - * @property {WPLinkSearchType} [type] Filters by search type.
5408 - * @property {string} [subtype] Slug of the post-type or taxonomy.
5409 - * @property {number} [page] Which page of results to return.
5410 - * @property {number} [perPage] Search results per page.
5411 - */
5412 -
5413 -/**
5414 - * @typedef WPLinkSearchResult
5415 - *
5416 - * @property {number} id Post or term id.
5417 - * @property {string} url Link url.
5418 - * @property {string} title Title of the link.
5419 - * @property {string} type The taxonomy or post type slug or type URL.
5420 - * @property {WPKind} [kind] Link kind of post-type or taxonomy
5421 - */
5422 -
5423 -/**
5424 - * @typedef WPEditorSettings
5425 - *
5426 - * @property {boolean} [ disablePostFormats ] Disables post formats, when true.
5427 - */
5428 -
5429 -/**
5430 - * Fetches link suggestions from the API.
5431 - *
5432 - * @async
5433 - * @param {string} search
5434 - * @param {WPLinkSearchOptions} [searchOptions]
5435 - * @param {WPEditorSettings} [settings]
5436 - *
5437 - * @example
5438 - * ```js
5439 - * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';
5440 - *
5441 - * //...
5442 - *
5443 - * export function initialize( id, settings ) {
5444 - *
5445 - * settings.__experimentalFetchLinkSuggestions = (
5446 - * search,
5447 - * searchOptions
5448 - * ) => fetchLinkSuggestions( search, searchOptions, settings );
5449 - * ```
5450 - * @return {Promise< WPLinkSearchResult[] >} List of search suggestions
5451 - */
5452 -
5453 -const fetchLinkSuggestions = async function (search) {
5454 - let searchOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5455 - let settings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5456 - const {
5457 - isInitialSuggestions = false,
5458 - type = undefined,
5459 - subtype = undefined,
5460 - page = undefined,
5461 - perPage = isInitialSuggestions ? 3 : 20
5462 - } = searchOptions;
5463 - const {
5464 - disablePostFormats = false
5465 - } = settings;
5466 - const queries = [];
5467 -
5468 - if (!type || type === 'post') {
5469 - queries.push(external_wp_apiFetch_default()({
5470 - path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
5471 - search,
5472 - page,
5473 - per_page: perPage,
5474 - type: 'post',
5475 - subtype
5476 - })
5477 - }).then(results => {
5478 - return results.map(result => {
5479 - return { ...result,
5480 - meta: {
5481 - kind: 'post-type',
5482 - subtype
5483 - }
5484 - };
5485 - });
5486 - }).catch(() => []) // fail by returning no results
5487 - );
5488 - }
5489 -
5490 - if (!type || type === 'term') {
5491 - queries.push(external_wp_apiFetch_default()({
5492 - path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
5493 - search,
5494 - page,
5495 - per_page: perPage,
5496 - type: 'term',
5497 - subtype
5498 - })
5499 - }).then(results => {
5500 - return results.map(result => {
5501 - return { ...result,
5502 - meta: {
5503 - kind: 'taxonomy',
5504 - subtype
5505 - }
5506 - };
5507 - });
5508 - }).catch(() => []));
5509 - }
5510 -
5511 - if (!disablePostFormats && (!type || type === 'post-format')) {
5512 - queries.push(external_wp_apiFetch_default()({
5513 - path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
5514 - search,
5515 - page,
5516 - per_page: perPage,
5517 - type: 'post-format',
5518 - subtype
5519 - })
5520 - }).then(results => {
5521 - return results.map(result => {
5522 - return { ...result,
5523 - meta: {
5524 - kind: 'taxonomy',
5525 - subtype
5526 - }
5527 - };
5528 - });
5529 - }).catch(() => []));
5530 - }
5531 -
5532 - return Promise.all(queries).then(results => {
5533 - return results.reduce((accumulator, current) => accumulator.concat(current), //flatten list
5534 - []).filter(
5535 - /**
5536 - * @param {{ id: number }} result
5537 - */
5538 - result => {
5539 - return !!result.id;
5540 - }).slice(0, perPage).map(
5541 - /**
5542 - * @param {{ id: number, url:string, title?:string, subtype?: string, type?: string }} result
5543 - */
5544 - result => {
5545 - var _result$meta;
5546 -
5547 - return {
5548 - id: result.id,
5549 - url: result.url,
5550 - title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(result.title || '') || (0,external_wp_i18n_namespaceObject.__)('(no title)'),
5551 - type: result.subtype || result.type,
5552 - kind: result === null || result === void 0 ? void 0 : (_result$meta = result.meta) === null || _result$meta === void 0 ? void 0 : _result$meta.kind
5553 - };
5554 - });
5555 - });
5556 -};
5557 -
5558 -/* harmony default export */ var _experimental_fetch_link_suggestions = (fetchLinkSuggestions);
5559 -//# sourceMappingURL=__experimental-fetch-link-suggestions.js.map
5560 -;// CONCATENATED MODULE: ./packages/core-data/build-module/fetch/__experimental-fetch-url-data.js
5561 -/**
5562 - * WordPress dependencies
5563 - */
5564 -
5565 -
5566 -/**
5567 - * A simple in-memory cache for requests.
5568 - * This avoids repeat HTTP requests which may be beneficial
5569 - * for those wishing to preserve low-bandwidth.
5570 - */
5571 -
5572 -const CACHE = new Map();
5573 -/**
5574 - * @typedef WPRemoteUrlData
5575 - *
5576 - * @property {string} title contents of the remote URL's `<title>` tag.
5577 - */
5578 -
5579 -/**
5580 - * Fetches data about a remote URL.
5581 - * eg: <title> tag, favicon...etc.
5582 - *
5583 - * @async
5584 - * @param {string} url the URL to request details from.
5585 - * @param {Object?} options any options to pass to the underlying fetch.
5586 - * @example
5587 - * ```js
5588 - * import { __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';
5589 - *
5590 - * //...
5591 - *
5592 - * export function initialize( id, settings ) {
5593 - *
5594 - * settings.__experimentalFetchUrlData = (
5595 - * url
5596 - * ) => fetchUrlData( url );
5597 - * ```
5598 - * @return {Promise< WPRemoteUrlData[] >} Remote URL data.
5599 - */
5600 -
5601 -const fetchUrlData = async function (url) {
5602 - let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5603 - const endpoint = '/wp-block-editor/v1/url-details';
5604 - const args = {
5605 - url: (0,external_wp_url_namespaceObject.prependHTTP)(url)
5606 - };
5607 -
5608 - if (!(0,external_wp_url_namespaceObject.isURL)(url)) {
5609 - return Promise.reject(`${url} is not a valid URL.`);
5610 - } // Test for "http" based URL as it is possible for valid
5611 - // yet unusable URLs such as `tel:123456` to be passed.
5612 -
5613 -
5614 - const protocol = (0,external_wp_url_namespaceObject.getProtocol)(url);
5615 -
5616 - if (!(0,external_wp_url_namespaceObject.isValidProtocol)(protocol) || !protocol.startsWith('http') || !/^https?:\/\/[^\/\s]/i.test(url)) {
5617 - return Promise.reject(`${url} does not have a valid protocol. URLs must be "http" based`);
5618 - }
5619 -
5620 - if (CACHE.has(url)) {
5621 - return CACHE.get(url);
5622 - }
5623 -
5624 - return external_wp_apiFetch_default()({
5625 - path: (0,external_wp_url_namespaceObject.addQueryArgs)(endpoint, args),
5626 - ...options
5627 - }).then(res => {
5628 - CACHE.set(url, res);
5629 - return res;
5630 - });
5631 -};
5632 -
5633 -/* harmony default export */ var _experimental_fetch_url_data = (fetchUrlData);
5634 -//# sourceMappingURL=__experimental-fetch-url-data.js.map
5635 -;// CONCATENATED MODULE: ./packages/core-data/build-module/fetch/index.js
5636 -
5637 -
5638 -//# sourceMappingURL=index.js.map
5639 -;// CONCATENATED MODULE: ./packages/core-data/build-module/index.js
5640 -/**
5641 - * WordPress dependencies
5642 - */
5643 -
5644 -/**
5645 - * Internal dependencies
5646 - */
5647 -
5648 -
5649 -
5650 -
5651 -
5652 -
5653 -
5654 - // The entity selectors/resolvers and actions are shortcuts to their generic equivalents
5655 -// (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecordss)
5656 -// Instead of getEntityRecord, the consumer could use more user-frieldly named selector: getPostType, getTaxonomy...
5657 -// The "kind" and the "name" of the entity are combined to generate these shortcuts.
5658 -
5659 -const entitySelectors = defaultEntities.reduce((result, entity) => {
5660 - const {
5661 - kind,
5662 - name
5663 - } = entity;
5664 -
5665 - result[getMethodName(kind, name)] = (state, key, query) => getEntityRecord(state, kind, name, key, query);
5666 -
5667 - result[getMethodName(kind, name, 'get', true)] = function (state) {
5668 - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
5669 - args[_key - 1] = arguments[_key];
5670 - }
5671 -
5672 - return getEntityRecords(state, kind, name, ...args);
5673 - };
5674 -
5675 - return result;
5676 -}, {});
5677 -const entityResolvers = defaultEntities.reduce((result, entity) => {
5678 - const {
5679 - kind,
5680 - name
5681 - } = entity;
5682 -
5683 - result[getMethodName(kind, name)] = (key, query) => resolvers_getEntityRecord(kind, name, key, query);
5684 -
5685 - const pluralMethodName = getMethodName(kind, name, 'get', true);
5686 -
5687 - result[pluralMethodName] = function () {
5688 - for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
5689 - args[_key2] = arguments[_key2];
5690 - }
5691 -
5692 - return resolvers_getEntityRecords(kind, name, ...args);
5693 - };
5694 -
5695 - result[pluralMethodName].shouldInvalidate = function (action) {
5696 - for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
5697 - args[_key3 - 1] = arguments[_key3];
5698 - }
5699 -
5700 - return resolvers_getEntityRecords.shouldInvalidate(action, kind, name, ...args);
5701 - };
5702 -
5703 - return result;
5704 -}, {});
5705 -const entityActions = defaultEntities.reduce((result, entity) => {
5706 - const {
5707 - kind,
5708 - name
5709 - } = entity;
5710 -
5711 - result[getMethodName(kind, name, 'save')] = key => saveEntityRecord(kind, name, key);
5712 -
5713 - result[getMethodName(kind, name, 'delete')] = (key, query) => deleteEntityRecord(kind, name, key, query);
5714 -
5715 - return result;
5716 -}, {});
5717 -
5718 -const storeConfig = () => ({
5719 - reducer: build_module_reducer,
5720 - actions: { ...build_module_actions_namespaceObject,
5721 - ...entityActions,
5722 - ...createLocksActions()
5723 - },
5724 - selectors: { ...build_module_selectors_namespaceObject,
5725 - ...entitySelectors
5726 - },
5727 - resolvers: { ...resolvers_namespaceObject,
5728 - ...entityResolvers
5729 - },
5730 - __experimentalUseThunks: true
5731 -});
5732 -/**
5733 - * Store definition for the code data namespace.
5734 - *
5735 - * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
5736 - *
5737 - * @type {Object}
5738 - */
5739 -
5740 -
5741 -const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig());
5742 -(0,external_wp_data_namespaceObject.register)(store);
5743 -
5744 -
5745 -
5746 -//# sourceMappingURL=index.js.map
5747 -}();
5748 -(window.wp = window.wp || {}).coreData = __webpack_exports__;
5749 -/******/ })()
5750 -;
1 +window.wp=window.wp||{},window.wp.coreData=function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=529)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},11:function(e,t){e.exports=window.wp.blocks},114:function(e,t,r){"use strict";r.d(t,"a",(function(){return u}));var n=r(39),a=r(42),o=r(30),c=r(40);function u(e){return Object(n.a)(e)||Object(a.a)(e)||Object(o.a)(e)||Object(c.a)()}},122:function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function o(e,t){var r=e._map,n=e._arrayTreeMap,a=e._objectTreeMap;if(r.has(t))return r.get(t);for(var o=Object.keys(t).sort(),c=Array.isArray(t)?n:a,u=0;u<o.length;u++){var i=o[u];if(void 0===(c=c.get(i)))return;var s=t[i];if(void 0===(c=c.get(s)))return}var f=c.get("_ekm_value");return f?(r.delete(f[0]),f[0]=t,c.set("_ekm_value",f),r.set(t,f),f):void 0}var c=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.clear(),t instanceof e){var r=[];t.forEach((function(e,t){r.push([t,e])})),t=r}if(null!=t)for(var n=0;n<t.length;n++)this.set(t[n][0],t[n][1])}var t,r;return t=e,(r=[{key:"set",value:function(t,r){if(null===t||"object"!==n(t))return this._map.set(t,r),this;for(var a=Object.keys(t).sort(),o=[t,r],c=Array.isArray(t)?this._arrayTreeMap:this._objectTreeMap,u=0;u<a.length;u++){var i=a[u];c.has(i)||c.set(i,new e),c=c.get(i);var s=t[i];c.has(s)||c.set(s,new e),c=c.get(s)}var f=c.get("_ekm_value");return f&&this._map.delete(f[0]),c.set("_ekm_value",o),this._map.set(t,o),this}},{key:"get",value:function(e){if(null===e||"object"!==n(e))return this._map.get(e);var t=o(this,e);return t?t[1]:void 0}},{key:"has",value:function(e){return null===e||"object"!==n(e)?this._map.has(e):void 0!==o(this,e)}},{key:"delete",value:function(e){return!!this.has(e)&&(this.set(e,void 0),!0)}},{key:"forEach",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this;this._map.forEach((function(a,o){null!==o&&"object"===n(o)&&(a=a[1]),e.call(r,a,o,t)}))}},{key:"clear",value:function(){this._map=new Map,this._arrayTreeMap=new Map,this._objectTreeMap=new Map}},{key:"size",get:function(){return this._map.size}}])&&a(t.prototype,r),e}();e.exports=c},15:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(24),a=r(42),o=r(30);function c(e){return function(e){if(Array.isArray(e))return Object(n.a)(e)}(e)||Object(a.a)(e)||Object(o.a)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},16:function(e,t){e.exports=window.regeneratorRuntime},2:function(e,t){e.exports=window.lodash},204:function(e,t,r){"use strict";var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),a=new Uint8Array(16);function o(){if(!n)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(a)}for(var c=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,u=function(e){return"string"==typeof e&&c.test(e)},i=[],s=0;s<256;++s)i.push((s+256).toString(16).substr(1));t.a=function(e,t,r){var n=(e=e||{}).random||(e.rng||o)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var a=0;a<16;++a)t[r+a]=n[a];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(i[e[t+0]]+i[e[t+1]]+i[e[t+2]]+i[e[t+3]]+"-"+i[e[t+4]]+i[e[t+5]]+"-"+i[e[t+6]]+i[e[t+7]]+"-"+i[e[t+8]]+i[e[t+9]]+"-"+i[e[t+10]]+i[e[t+11]]+i[e[t+12]]+i[e[t+13]]+i[e[t+14]]+i[e[t+15]]).toLowerCase();if(!u(r))throw TypeError("Stringified UUID is invalid");return r}(n)}},24:function(e,t,r){"use strict";function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}r.d(t,"a",(function(){return n}))},28:function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}r.d(t,"a",(function(){return n}))},29:function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}r.d(t,"a",(function(){return a}))},30:function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(24);function a(e,t){if(e){if("string"==typeof e)return Object(n.a)(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Object(n.a)(e,t):void 0}}},31:function(e,t){e.exports=window.wp.url},38:function(e,t){e.exports=window.wp.deprecated},39:function(e,t,r){"use strict";function n(e){if(Array.isArray(e))return e}r.d(t,"a",(function(){return n}))},4:function(e,t){e.exports=window.wp.data},40:function(e,t,r){"use strict";function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}r.d(t,"a",(function(){return n}))},42:function(e,t,r){"use strict";function n(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}r.d(t,"a",(function(){return n}))},45:function(e,t,r){"use strict";function n(e,t,r,n,a,o,c){try{var u=e[o](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,a)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(a,o){var c=e.apply(t,r);function u(e){n(c,a,o,u,i,"next",e)}function i(e){n(c,a,o,u,i,"throw",e)}u(void 0)}))}}r.d(t,"a",(function(){return a}))},47:function(e,t){e.exports=window.wp.apiFetch},49:function(e,t,r){"use strict";var n,a;function o(e){return[e]}function c(){var e={clear:function(){e.head=null}};return e}function u(e,t,r){var n;if(e.length!==t.length)return!1;for(n=r;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}n={},a="undefined"!=typeof WeakMap,t.a=function(e,t){var r,i;function s(){r=a?new WeakMap:c()}function f(){var r,n,a,o,c,s=arguments.length;for(o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];for(c=t.apply(null,o),(r=i(c)).isUniqueByDependants||(r.lastDependants&&!u(c,r.lastDependants,0)&&r.clear(),r.lastDependants=c),n=r.head;n;){if(u(n.args,o,1))return n!==r.head&&(n.prev.next=n.next,n.next&&(n.next.prev=n.prev),n.next=r.head,n.prev=null,r.head.prev=n,r.head=n),n.val;n=n.next}return n={val:e.apply(null,o)},o[0]=null,n.args=o,r.head&&(r.head.prev=n,n.next=r.head),r.head=n,n.val}return t||(t=o),i=a?function(e){var t,a,o,u,i,s=r,f=!0;for(t=0;t<e.length;t++){if(!(i=a=e[t])||"object"!=typeof i){f=!1;break}s.has(a)?s=s.get(a):(o=new WeakMap,s.set(a,o),s=o)}return s.has(n)||((u=c()).isUniqueByDependants=f,s.set(n,u)),s.get(n)}:function(){return r},f.getDependants=t,f.clear=s,s(),f}},5:function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(t,"a",(function(){return n}))},529:function(e,t,r){"use strict";r.r(t),r.d(t,"store",(function(){return vn})),r.d(t,"EntityProvider",(function(){return an})),r.d(t,"useEntityId",(function(){return on})),r.d(t,"useEntityProp",(function(){return cn})),r.d(t,"useEntityBlockEditor",(function(){return un}));var n={};r.r(n),r.d(n,"__unstableAcquireStoreLock",(function(){return N})),r.d(n,"__unstableEnqueueLockRequest",(function(){return q})),r.d(n,"__unstableReleaseStoreLock",(function(){return V})),r.d(n,"__unstableProcessPendingLockRequests",(function(){return F}));var a={};r.r(a),r.d(a,"receiveUserQuery",(function(){return de})),r.d(a,"receiveCurrentUser",(function(){return pe})),r.d(a,"addEntities",(function(){return be})),r.d(a,"receiveEntityRecords",(function(){return ve})),r.d(a,"receiveCurrentTheme",(function(){return ye})),r.d(a,"receiveThemeSupports",(function(){return he})),r.d(a,"receiveEmbedPreview",(function(){return Oe})),r.d(a,"deleteEntityRecord",(function(){return me})),r.d(a,"editEntityRecord",(function(){return ge})),r.d(a,"undo",(function(){return je})),r.d(a,"redo",(function(){return Ee})),r.d(a,"__unstableCreateUndoLevel",(function(){return we})),r.d(a,"saveEntityRecord",(function(){return _e})),r.d(a,"__experimentalBatch",(function(){return xe})),r.d(a,"saveEditedEntityRecord",(function(){return ke})),r.d(a,"receiveUploadPermissions",(function(){return Re})),r.d(a,"receiveUserPermission",(function(){return Se})),r.d(a,"receiveAutosaves",(function(){return Pe}));var o={};r.r(o),r.d(o,"isRequestingEmbedPreview",(function(){return Tt})),r.d(o,"getAuthors",(function(){return It})),r.d(o,"__unstableGetAuthor",(function(){return At})),r.d(o,"getCurrentUser",(function(){return Dt})),r.d(o,"getUserQueryResults",(function(){return Ct})),r.d(o,"getEntitiesByKind",(function(){return Ut})),r.d(o,"getEntity",(function(){return Lt})),r.d(o,"getEntityRecord",(function(){return Mt})),r.d(o,"__experimentalGetEntityRecordNoResolver",(function(){return Nt})),r.d(o,"getRawEntityRecord",(function(){return qt})),r.d(o,"hasEntityRecords",(function(){return Vt})),r.d(o,"getEntityRecords",(function(){return Ft})),r.d(o,"__experimentalGetDirtyEntityRecords",(function(){return Yt})),r.d(o,"getEntityRecordEdits",(function(){return Qt})),r.d(o,"getEntityRecordNonTransientEdits",(function(){return Gt})),r.d(o,"hasEditsForEntityRecord",(function(){return Bt})),r.d(o,"getEditedEntityRecord",(function(){return Ht})),r.d(o,"isAutosavingEntityRecord",(function(){return Kt})),r.d(o,"isSavingEntityRecord",(function(){return zt})),r.d(o,"isDeletingEntityRecord",(function(){return Wt})),r.d(o,"getLastEntitySaveError",(function(){return $t})),r.d(o,"getLastEntityDeleteError",(function(){return Xt})),r.d(o,"getUndoEdit",(function(){return Zt})),r.d(o,"getRedoEdit",(function(){return er})),r.d(o,"hasUndo",(function(){return tr})),r.d(o,"hasRedo",(function(){return rr})),r.d(o,"getCurrentTheme",(function(){return nr})),r.d(o,"getThemeSupports",(function(){return ar})),r.d(o,"getEmbedPreview",(function(){return or})),r.d(o,"isPreviewEmbedFallback",(function(){return cr})),r.d(o,"hasUploadPermissions",(function(){return ur})),r.d(o,"canUser",(function(){return ir})),r.d(o,"getAutosaves",(function(){return sr})),r.d(o,"getAutosave",(function(){return fr})),r.d(o,"hasFetchedAutosaves",(function(){return lr})),r.d(o,"getReferenceByDistinctEdits",(function(){return dr})),r.d(o,"__experimentalGetTemplateForLink",(function(){return pr}));var c={};r.r(c),r.d(c,"getAuthors",(function(){return Ar})),r.d(c,"__unstableGetAuthor",(function(){return Dr})),r.d(c,"getCurrentUser",(function(){return Cr})),r.d(c,"getEntityRecord",(function(){return Ur})),r.d(c,"getRawEntityRecord",(function(){return Lr})),r.d(c,"getEditedEntityRecord",(function(){return Mr})),r.d(c,"getEntityRecords",(function(){return Nr})),r.d(c,"getCurrentTheme",(function(){return qr})),r.d(c,"getThemeSupports",(function(){return Vr})),r.d(c,"getEmbedPreview",(function(){return Fr})),r.d(c,"hasUploadPermissions",(function(){return Yr})),r.d(c,"canUser",(function(){return Qr})),r.d(c,"getAutosaves",(function(){return Gr})),r.d(c,"getAutosave",(function(){return Br})),r.d(c,"__experimentalGetTemplateForLink",(function(){return Hr}));var u={};r.r(u),r.d(u,"__unstableGetPendingLockRequests",(function(){return Wr})),r.d(u,"__unstableIsLockAvailable",(function(){return $r}));var i=r(5),s=r(4),f=r(55),l=r(8),d=r(15),p=r(2),b=r(72),v=r.n(b),y=function(e){return function(t){return function(r,n){return void 0===r||e(n)?t(r,n):r}}},h=function(e){return function(t){return function(r,n){return t(r,e(n))}}};function O(e,t){if(!e)return t;var r=!1,n={};for(var a in t)Object(p.isEqual)(e[a],t[a])?n[a]=e[a]:(r=!0,n[a]=t[a]);if(!r)return e;for(var o in e)n.hasOwnProperty(o)||(n[o]=e[o]);return n}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){Object(i.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var j=r(16),E=r.n(j),w=r(1),_=r(114),x=r(204),k=r(31);function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach((function(t){Object(i.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function P(e,t){return{type:"RECEIVE_ITEMS",items:Object(p.castArray)(e),persistedEdits:t}}function T(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return{type:"REMOVE_ITEMS",itemIds:Object(p.castArray)(r),kind:e,name:t,invalidateCache:n}}function I(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;return S(S({},P(e,r)),{},{query:t})}function A(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return D(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?D(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,c=!0,u=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return c=e.done,e},e:function(e){u=!0,o=e},f:function(){try{c||null==r.return||r.return()}finally{if(u)throw o}}}}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var C=E.a.mark(N),U=E.a.mark(q),L=E.a.mark(V),M=E.a.mark(F);function N(e,t,r){var n,a;return E.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return n=r.exclusive,o.delegateYield(q(e,t,{exclusive:n}),"t0",2);case 2:return a=o.t0,o.delegateYield(F(),"t1",4);case 4:return o.next=6,Object(f.__unstableAwaitPromise)(a);case 6:return o.abrupt("return",o.sent);case 7:case"end":return o.stop()}}),C)}function q(e,t,r){var n,a,o;return E.a.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return n=r.exclusive,o=new Promise((function(e){a=e})),c.next=4,{type:"ENQUEUE_LOCK_REQUEST",request:{store:e,path:t,exclusive:n,notifyAcquired:a}};case 4:return c.abrupt("return",o);case 5:case"end":return c.stop()}}),U)}function V(e){return E.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,{type:"RELEASE_LOCK",lock:e};case 2:return t.delegateYield(F(),"t0",3);case 3:case"end":return t.stop()}}),L)}function F(){var e,t,r,n,a,o,c,u,i;return E.a.wrap((function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,{type:"PROCESS_PENDING_LOCK_REQUESTS"};case 2:return f.next=4,s.controls.select("core","__unstableGetPendingLockRequests");case 4:e=f.sent,t=A(e),f.prev=6,t.s();case 8:if((r=t.n()).done){f.next=21;break}return n=r.value,a=n.store,o=n.path,c=n.exclusive,u=n.notifyAcquired,f.next=13,s.controls.select("core","__unstableIsLockAvailable",a,o,{exclusive:c});case 13:if(!f.sent){f.next=19;break}return i={store:a,path:o,exclusive:c},f.next=18,{type:"GRANT_LOCK_REQUEST",lock:i,request:n};case 18:u(i);case 19:f.next=8;break;case 21:f.next=26;break;case 23:f.prev=23,f.t0=f.catch(6),t.e(f.t0);case 26:return f.prev=26,t.f(),f.finish(26);case 29:case"end":return f.stop()}}),M,null,[[6,23,26,29]])}var Y=r(58);function Q(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function G(e,t,r){return(G=Q()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&Object(Y.a)(a,r.prototype),a}).apply(null,arguments)}var B=r(28),H=r(29),K=r(45),z=r(47),W=r.n(z);function $(_x){return X.apply(this,arguments)}function X(){return(X=Object(K.a)(E.a.mark((function e(t){var r;return E.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,W()({path:"/v1/batch",method:"POST",data:{validation:"require-all-validate",requests:t.map((function(e){return{path:e.path,body:e.data,method:e.method,headers:e.headers}}))}});case 2:if(!(r=e.sent).failed){e.next=5;break}return e.abrupt("return",r.responses.map((function(e){return{error:null==e?void 0:e.body}})));case 5:return e.abrupt("return",r.responses.map((function(e){var t={};return e.status>=200&&e.status<300?t.output=e.body:t.error=e.body,t})));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function J(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Z(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Z(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,c=!0,u=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return c=e.done,e},e:function(e){u=!0,o=e},f:function(){try{c||null==r.return||r.return()}finally{if(u)throw o}}}}function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function ee(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:$,t=0,r=[],n=new te;return{add:function(e){var a=++t;n.add(a);var o=function(e){return new Promise((function(t,o){r.push({input:e,resolve:t,reject:o}),n.delete(a)}))};return Object(p.isFunction)(e)?Promise.resolve(e(o)).finally((function(){n.delete(a)})):o(e)},run:function(){return Object(K.a)(E.a.mark((function t(){var a,o,c,u,i,s,f,d,b,v,y,h;return E.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.size){t.next=3;break}return t.next=3,new Promise((function(e){var t=n.subscribe((function(){n.size||(t(),e())}))}));case 3:return t.prev=3,t.next=6,e(r.map((function(e){return e.input})));case 6:if((a=t.sent).length===r.length){t.next=9;break}throw new Error("run: Array returned by processor must be same size as input array.");case 9:t.next=16;break;case 11:t.prev=11,t.t0=t.catch(3),o=J(r);try{for(o.s();!(c=o.n()).done;)(0,c.value.reject)(t.t0)}catch(e){o.e(e)}finally{o.f()}throw t.t0;case 16:u=!0,i=J(Object(p.zip)(a,r));try{for(i.s();!(s=i.n()).done;)f=Object(l.a)(s.value,2),d=f[0],b=f[1],v=b.resolve,y=b.reject,null!=d&&d.error?(y(d.error),u=!1):v(null!==(h=null==d?void 0:d.output)&&void 0!==h?h:d)}catch(e){i.e(e)}finally{i.f()}return r=[],t.abrupt("return",u);case 21:case"end":return t.stop()}}),t,null,[[3,11]])})))()}}}var te=function(){function e(){Object(B.a)(this,e);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.set=G(Set,r),this.subscribers=new Set}return Object(H.a)(e,[{key:"add",value:function(){var e;return(e=this.set).add.apply(e,arguments),this.subscribers.forEach((function(e){return e()})),this}},{key:"delete",value:function(){var e,t=(e=this.set).delete.apply(e,arguments);return this.subscribers.forEach((function(e){return e()})),t}},{key:"subscribe",value:function(e){var t=this;return this.subscribers.add(e),function(){t.subscribers.delete(e)}}},{key:"size",get:function(){return this.set.size}}]),e}(),re={REGULAR_FETCH:function(e){return Object(K.a)(E.a.mark((function t(){var r,n,a;return E.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.url,t.next=3,window.fetch(r).then((function(e){return e.json()}));case 3:return n=t.sent,a=n.data,t.abrupt("return",a);case 6:case"end":return t.stop()}}),t)})))()},GET_DISPATCH:Object(s.createRegistryControl)((function(e){var t=e.dispatch;return function(){return t}}))},ne=E.a.mark(me),ae=E.a.mark(ge),oe=E.a.mark(je),ce=E.a.mark(Ee),ue=E.a.mark(_e),ie=E.a.mark(xe),se=E.a.mark(ke);function fe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function le(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?fe(Object(r),!0).forEach((function(t){Object(i.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fe(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function de(e,t){return{type:"RECEIVE_USER_QUERY",users:Object(p.castArray)(t),queryID:e}}function pe(e){return{type:"RECEIVE_CURRENT_USER",currentUser:e}}function be(e){return{type:"ADD_ENTITIES",entities:e}}function ve(e,t,r,n){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=arguments.length>5?arguments[5]:void 0;return"postType"===e&&(r=Object(p.castArray)(r).map((function(e){return"auto-draft"===e.status?le(le({},e),{},{title:""}):e}))),le(le({},n?I(r,n,o):P(r,o)),{},{kind:e,name:t,invalidateCache:a})}function ye(e){return{type:"RECEIVE_CURRENT_THEME",currentTheme:e}}function he(e){return{type:"RECEIVE_THEME_SUPPORTS",themeSupports:e}}function Oe(e,t){return{type:"RECEIVE_EMBED_PREVIEW",url:e,preview:t}}function me(e,t,r,n){var a,o,c,u,i,s,l,d,b,v,y=arguments;return E.a.wrap((function(h){for(;;)switch(h.prev=h.next){case 0:return a=y.length>4&&void 0!==y[4]?y[4]:{},o=a.__unstableFetch,c=void 0===o?null:o,h.next=3,Ve(e);case 3:if(u=h.sent,i=Object(p.find)(u,{kind:e,name:t}),l=!1,i){h.next=8;break}return h.abrupt("return");case 8:return h.delegateYield(N("core",["entities","data",e,t,r],{exclusive:!0}),"t0",9);case 9:return d=h.t0,h.prev=10,h.next=13,{type:"DELETE_ENTITY_RECORD_START",kind:e,name:t,recordId:r};case 13:if(h.prev=13,b="".concat(i.baseURL,"/").concat(r),n&&(b=Object(k.addQueryArgs)(b,n)),v={path:b,method:"DELETE"},!c){h.next=23;break}return h.next=20,Object(f.__unstableAwaitPromise)(c(v));case 20:l=h.sent,h.next=26;break;case 23:return h.next=25,Object(f.apiFetch)(v);case 25:l=h.sent;case 26:return h.next=28,T(e,t,r,!0);case 28:h.next=33;break;case 30:h.prev=30,h.t1=h.catch(13),s=h.t1;case 33:return h.next=35,{type:"DELETE_ENTITY_RECORD_FINISH",kind:e,name:t,recordId:r,error:s};case 35:return h.abrupt("return",l);case 36:return h.prev=36,h.delegateYield(V(d),"t2",38);case 38:return h.finish(36);case 39:case"end":return h.stop()}}),ne,null,[[10,,36,39],[13,30]])}function ge(e,t,r,n){var a,o,c,u,i,f,l,d,b,v=arguments;return E.a.wrap((function(y){for(;;)switch(y.prev=y.next){case 0:return a=v.length>4&&void 0!==v[4]?v[4]:{},y.next=3,s.controls.select("core","getEntity",e,t);case 3:if(o=y.sent){y.next=6;break}throw new Error("The entity being edited (".concat(e,", ").concat(t,") does not have a loaded config."));case 6:return c=o.transientEdits,u=void 0===c?{}:c,i=o.mergedEdits,f=void 0===i?{}:i,y.next=9,s.controls.select("core","getRawEntityRecord",e,t,r);case 9:return l=y.sent,y.next=12,s.controls.select("core","getEditedEntityRecord",e,t,r);case 12:return d=y.sent,b={kind:e,name:t,recordId:r,edits:Object.keys(n).reduce((function(e,t){var r=l[t],a=d[t],o=f[t]?le(le({},a),n[t]):n[t];return e[t]=Object(p.isEqual)(r,o)?void 0:o,e}),{}),transientEdits:u},y.abrupt("return",le(le({type:"EDIT_ENTITY_RECORD"},b),{},{meta:{undo:!a.undoIgnore&&le(le({},b),{},{edits:Object.keys(n).reduce((function(e,t){return e[t]=d[t],e}),{})})}}));case 15:case"end":return y.stop()}}),ae)}function je(){var e;return E.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.controls.select("core","getUndoEdit");case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return");case 5:return t.next=7,le(le({type:"EDIT_ENTITY_RECORD"},e),{},{meta:{isUndo:!0}});case 7:case"end":return t.stop()}}),oe)}function Ee(){var e;return E.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.controls.select("core","getRedoEdit");case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return");case 5:return t.next=7,le(le({type:"EDIT_ENTITY_RECORD"},e),{},{meta:{isRedo:!0}});case 7:case"end":return t.stop()}}),ce)}function we(){return{type:"CREATE_UNDO_LEVEL"}}function _e(e,t,r){var n,a,o,c,u,d,b,v,y,h,O,m,g,j,w,_,k,R,S,P,T,I,A,D,C,U,L,M,q=arguments;return E.a.wrap((function(E){for(;;)switch(E.prev=E.next){case 0:return n=q.length>3&&void 0!==q[3]?q[3]:{},a=n.isAutosave,o=void 0!==a&&a,c=n.__unstableFetch,u=void 0===c?null:c,E.next=3,Ve(e);case 3:if(d=E.sent,b=Object(p.find)(d,{kind:e,name:t})){E.next=7;break}return E.abrupt("return");case 7:return v=b.key||De,y=r[v],E.delegateYield(N("core",["entities","data",e,t,y||Object(x.a)()],{exclusive:!0}),"t0",10);case 10:h=E.t0,E.prev=11,O=0,m=Object.entries(r);case 13:if(!(O<m.length)){E.next=27;break}if(g=Object(l.a)(m[O],2),j=g[0],"function"!=typeof(w=g[1])){E.next=24;break}return E.t1=w,E.next=19,s.controls.select("core","getEditedEntityRecord",e,t,y);case 19:return E.t2=E.sent,_=(0,E.t1)(E.t2),E.next=23,ge(e,t,y,Object(i.a)({},j,_),{undoIgnore:!0});case 23:r[j]=_;case 24:O++,E.next=13;break;case 27:return E.next=29,{type:"SAVE_ENTITY_RECORD_START",kind:e,name:t,recordId:y,isAutosave:o};case 29:return E.prev=29,S="".concat(b.baseURL).concat(y?"/"+y:""),E.next=33,s.controls.select("core","getRawEntityRecord",e,t,y);case 33:if(P=E.sent,!o){E.next=65;break}return E.next=37,s.controls.select("core","getCurrentUser");case 37:return T=E.sent,I=T?T.id:void 0,E.next=41,s.controls.select("core","getAutosave",P.type,P.id,I);case 41:if(A=E.sent,D=le(le(le({},P),A),r),D=Object.keys(D).reduce((function(e,t){return["title","excerpt","content"].includes(t)&&(e[t]=Object(p.get)(D[t],"raw",D[t])),e}),{status:"auto-draft"===D.status?"draft":D.status}),C={path:"".concat(S,"/autosaves"),method:"POST",data:D},!u){E.next=51;break}return E.next=48,Object(f.__unstableAwaitPromise)(u(C));case 48:k=E.sent,E.next=54;break;case 51:return E.next=53,Object(f.apiFetch)(C);case 53:k=E.sent;case 54:if(P.id!==k.id){E.next=61;break}return U=le(le(le({},P),D),k),U=Object.keys(U).reduce((function(e,t){return["title","excerpt","content"].includes(t)?e[t]=Object(p.get)(U[t],"raw",U[t]):e[t]="status"===t?"auto-draft"===P.status&&"draft"===U.status?U.status:P.status:Object(p.get)(P[t],"raw",P[t]),e}),{}),E.next=59,ve(e,t,U,void 0,!0);case 59:E.next=63;break;case 61:return E.next=63,Pe(P.id,k);case 63:E.next=79;break;case 65:if(L=r,b.__unstablePrePersist&&(L=le(le({},L),b.__unstablePrePersist(P,L))),M={path:S,method:y?"PUT":"POST",data:L},!u){E.next=74;break}return E.next=71,Object(f.__unstableAwaitPromise)(u(M));case 71:k=E.sent,E.next=77;break;case 74:return E.next=76,Object(f.apiFetch)(M);case 76:k=E.sent;case 77:return E.next=79,ve(e,t,k,void 0,!0,L);case 79:E.next=84;break;case 81:E.prev=81,E.t3=E.catch(29),R=E.t3;case 84:return E.next=86,{type:"SAVE_ENTITY_RECORD_FINISH",kind:e,name:t,recordId:y,error:R,isAutosave:o};case 86:return E.abrupt("return",k);case 87:return E.prev=87,E.delegateYield(V(h),"t4",89);case 89:return E.finish(87);case 90:case"end":return E.stop()}}),ue,null,[[11,,87,90],[29,81]])}function xe(e){var t,r,n,a,o,c,u;return E.a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return t=ee(),i.next=3,{type:"GET_DISPATCH"};case 3:return r=i.sent,n={saveEntityRecord:function(e,n,a,o){return t.add((function(t){return r("core").saveEntityRecord(e,n,a,le(le({},o),{},{__unstableFetch:t}))}))},saveEditedEntityRecord:function(e,n,a,o){return t.add((function(t){return r("core").saveEditedEntityRecord(e,n,a,le(le({},o),{},{__unstableFetch:t}))}))},deleteEntityRecord:function(e,n,a,o,c){return t.add((function(t){return r("core").deleteEntityRecord(e,n,a,o,le(le({},c),{},{__unstableFetch:t}))}))}},a=e.map((function(e){return e(n)})),i.next=8,Object(f.__unstableAwaitPromise)(Promise.all([t.run()].concat(Object(d.a)(a))));case 8:return o=i.sent,c=Object(_.a)(o),u=c.slice(1),i.abrupt("return",u);case 12:case"end":return i.stop()}}),ie)}function ke(e,t,r,n){var a,o;return E.a.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,s.controls.select("core","hasEditsForEntityRecord",e,t,r);case 2:if(c.sent){c.next=4;break}return c.abrupt("return");case 4:return c.next=6,s.controls.select("core","getEntityRecordNonTransientEdits",e,t,r);case 6:return a=c.sent,o=le({id:r},a),c.delegateYield(_e(e,t,o,n),"t0",9);case 9:return c.abrupt("return",c.t0);case 10:case"end":return c.stop()}}),se)}function Re(e){return{type:"RECEIVE_USER_PERMISSION",key:"create/media",isAllowed:e}}function Se(e,t){return{type:"RECEIVE_USER_PERMISSION",key:e,isAllowed:t}}function Pe(e,t){return{type:"RECEIVE_AUTOSAVES",postId:e,autosaves:Object(p.castArray)(t)}}var Te=E.a.mark(Me),Ie=E.a.mark(Ne),Ae=E.a.mark(Ve),De="id",Ce=[{label:Object(w.__)("Base"),name:"__unstableBase",kind:"root",baseURL:""},{label:Object(w.__)("Site"),name:"site",kind:"root",baseURL:"/wp/v2/settings",getTitle:function(e){return Object(p.get)(e,["title"],Object(w.__)("Site Title"))}},{label:Object(w.__)("Post Type"),name:"postType",kind:"root",key:"slug",baseURL:"/wp/v2/types"},{name:"media",kind:"root",baseURL:"/wp/v2/media",plural:"mediaItems",label:Object(w.__)("Media")},{name:"taxonomy",kind:"root",key:"slug",baseURL:"/wp/v2/taxonomies",plural:"taxonomies",label:Object(w.__)("Taxonomy")},{name:"sidebar",kind:"root",baseURL:"/wp/v2/sidebars",plural:"sidebars",transientEdits:{blocks:!0},label:Object(w.__)("Widget areas")},{name:"widget",kind:"root",baseURL:"/wp/v2/widgets",plural:"widgets",transientEdits:{blocks:!0},label:Object(w.__)("Widgets")},{label:Object(w.__)("User"),name:"user",kind:"root",baseURL:"/wp/v2/users",plural:"users"},{name:"comment",kind:"root",baseURL:"/wp/v2/comments",plural:"comments",label:Object(w.__)("Comment")},{name:"menu",kind:"root",baseURL:"/__experimental/menus",plural:"menus",label:Object(w.__)("Menu")},{name:"menuItem",kind:"root",baseURL:"/__experimental/menu-items",plural:"menuItems",label:Object(w.__)("Menu Item")},{name:"menuLocation",kind:"root",baseURL:"/__experimental/menu-locations",plural:"menuLocations",label:Object(w.__)("Menu Location"),key:"name"}],Ue=[{name:"postType",loadEntities:Me},{name:"taxonomy",loadEntities:Ne}],Le=function(e,t){var r={};return"auto-draft"===(null==e?void 0:e.status)&&(t.status||r.status||(r.status="draft"),t.title&&"Auto Draft"!==t.title||r.title||null!=e&&e.title&&"Auto Draft"!==(null==e?void 0:e.title)||(r.title="")),r};function Me(){var e;return E.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(f.apiFetch)({path:"/wp/v2/types?context=edit"});case 2:return e=t.sent,t.abrupt("return",Object(p.map)(e,(function(e,t){var r=["wp_template","wp_template_part"].includes(t);return{kind:"postType",baseURL:"/wp/v2/"+e.rest_base,name:t,label:e.labels.singular_name,transientEdits:{blocks:!0,selection:!0},mergedEdits:{meta:!0},getTitle:function(e){var t;return(null==e||null===(t=e.title)||void 0===t?void 0:t.rendered)||(null==e?void 0:e.title)||(r?Object(p.startCase)(e.slug):String(e.id))},__unstablePrePersist:r?void 0:Le}})));case 4:case"end":return t.stop()}}),Te)}function Ne(){var e;return E.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(f.apiFetch)({path:"/wp/v2/taxonomies?context=edit"});case 2:return e=t.sent,t.abrupt("return",Object(p.map)(e,(function(e,t){return{kind:"taxonomy",baseURL:"/wp/v2/"+e.rest_base,name:t,label:e.labels.singular_name}})));case 4:case"end":return t.stop()}}),Ie)}var qe=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"get",n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=Object(p.find)(Ce,{kind:e,name:t}),o="root"===e?"":Object(p.upperFirst)(Object(p.camelCase)(e)),c=Object(p.upperFirst)(Object(p.camelCase)(t))+(n?"s":""),u=n&&a.plural?Object(p.upperFirst)(Object(p.camelCase)(a.plural)):c;return"".concat(r).concat(o).concat(u)};function Ve(e){var t,r;return E.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,s.controls.select("core","getEntitiesByKind",e);case 2:if(!(t=n.sent)||0===t.length){n.next=5;break}return n.abrupt("return",t);case 5:if(r=Object(p.find)(Ue,{name:e})){n.next=8;break}return n.abrupt("return",[]);case 8:return n.next=10,r.loadEntities();case 10:return t=n.sent,n.next=13,be(t);case 13:return n.abrupt("return",t);case 14:case"end":return n.stop()}}),Ae)}var Fe,Ye=function(e){return"string"==typeof e?e.split(","):Array.isArray(e)?e:null},Qe=(Fe=new WeakMap,function(e){var t;return Fe.has(e)?t=Fe.get(e):(t=function(e){for(var t={stableKey:"",page:1,perPage:10,fields:null,include:null},r=Object.keys(e).sort(),n=0;n<r.length;n++){var a=r[n],o=e[a];switch(a){case"page":t[a]=Number(o);break;case"per_page":t.perPage=Number(o);break;case"include":t.include=Ye(o).map(Number);break;default:"_fields"===a&&(t.fields=Ye(o),o=t.fields.join()),t.stableKey+=(t.stableKey?"&":"")+Object(k.addQueryArgs)("",Object(i.a)({},a,o)).slice(1)}}return t}(e),Object(p.isObjectLike)(e)&&Fe.set(e,t)),t});function Ge(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Be(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ge(Object(r),!0).forEach((function(t){Object(i.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ge(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function He(e,t,r,n){if(1===r&&-1===n)return t;for(var a=(r-1)*n,o=Math.max(e.length,a+t.length),c=new Array(o),u=0;u<o;u++){var i=u>=a&&u<a+t.length;c[u]=i?t[u-a]:e[u]}return c}var Ke,ze=Object(p.flowRight)([y((function(e){return"query"in e})),h((function(e){return e.query?Be(Be({},e),Qe(e.query)):e})),(Ke="stableKey",function(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,n=r[Ke];if(void 0===n)return t;var a=e(t[n],r);return a===t[n]?t:g(g({},t),{},Object(i.a)({},n,a))}})])((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,r=t.type,n=t.page,a=t.perPage,o=t.key,c=void 0===o?De:o;return"RECEIVE_ITEMS"!==r?e:He(e||[],Object(p.map)(t.items,c),n,a)})),We=Object(s.combineReducers)({items:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_ITEMS":var r=t.key||De;return Be(Be({},e),t.items.reduce((function(t,n){var a=n[r];return t[a]=O(e[a],n),t}),{}));case"REMOVE_ITEMS":var n=Object(p.omit)(e,t.itemIds);return n}return e},itemIsComplete:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0,r=t.type,n=t.query,a=t.key,o=void 0===a?De:a;if("RECEIVE_ITEMS"!==r)return e;var c=!n||!Array.isArray(Qe(n).fields);return Be(Be({},e),t.items.reduce((function(t,r){var n=r[o];return t[n]=e[n]||c,t}),{}))},queries:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_ITEMS":return ze(e,t);case"REMOVE_ITEMS":var r=Be({},e),n=t.itemIds.reduce((function(e,t){return e[t]=!0,e}),{});return Object(p.forEach)(r,(function(e,t){r[t]=Object(p.filter)(e,(function(e){return!n[e]}))})),r;default:return e}}}),$e=E.a.mark(at),Xe=E.a.mark(ot);function Je(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Ze(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ze(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,c=!0,u=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return c=e.done,e},e:function(e){u=!0,o=e},f:function(){try{c||null==r.return||r.return()}finally{if(u)throw o}}}}function Ze(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function et(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function tt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?et(Object(r),!0).forEach((function(t){Object(i.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):et(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function rt(e,t){var r,n=tt({},e),a=n,o=Je(t);try{for(o.s();!(r=o.n()).done;){var c=r.value;a.children=tt(tt({},a.children),{},Object(i.a)({},c,tt({locks:[],children:{}},a.children[c]))),a=a.children[c]}}catch(e){o.e(e)}finally{o.f()}return n}function nt(e,t){var r,n=e,a=Je(t);try{for(a.s();!(r=a.n()).done;){var o=r.value,c=n.children[o];if(!c)return null;n=c}}catch(e){a.e(e)}finally{a.f()}return n}function at(e,t){var r,n,a,o,c;return E.a.wrap((function(u){for(;;)switch(u.prev=u.next){case 0:return r=e,u.next=3,r;case 3:n=Je(t),u.prev=4,n.s();case 6:if((a=n.n()).done){u.next=16;break}if(o=a.value,c=r.children[o]){u.next=11;break}return u.abrupt("break",16);case 11:return u.next=13,c;case 13:r=c;case 14:u.next=6;break;case 16:u.next=21;break;case 18:u.prev=18,u.t0=u.catch(4),n.e(u.t0);case 21:return u.prev=21,n.f(),u.finish(21);case 24:case"end":return u.stop()}}),$e,null,[[4,18,21,24]])}function ot(e){var t,r;return E.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:t=Object.values(e.children);case 1:if(!t.length){n.next=8;break}return r=t.pop(),n.next=5,r;case 5:t.push.apply(t,Object(d.a)(Object.values(r.children))),n.next=1;break;case 8:case"end":return n.stop()}}),Xe)}function ct(e,t){var r=e.exclusive;return!(!r||!t.length)||!(r||!t.filter((function(e){return e.exclusive})).length)}function ut(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function it(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ut(Object(r),!0).forEach((function(t){Object(i.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ut(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var st={requests:[],tree:{locks:[],children:{}}};function ft(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return lt(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?lt(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,c=!0,u=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return c=e.done,e},e:function(e){u=!0,o=e},f:function(){try{c||null==r.return||r.return()}finally{if(u)throw o}}}}function lt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function dt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function pt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?dt(Object(r),!0).forEach((function(t){Object(i.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function bt(e){return Object(p.flowRight)([y((function(t){return t.name&&t.kind&&t.name===e.name&&t.kind===e.kind})),h((function(t){return pt(pt({},t),{},{key:e.key||De})}))])(Object(s.combineReducers)({queriedData:We,edits:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_ITEMS":var r,n=pt({},e),a=ft(t.items);try{var o=function(){var e=r.value,a=e[t.key],o=n[a];if(!o)return"continue";var c=Object.keys(o).reduce((function(r,n){return Object(p.isEqual)(o[n],Object(p.get)(e[n],"raw",e[n]))||t.persistedEdits&&Object(p.isEqual)(o[n],t.persistedEdits[n])||(r[n]=o[n]),r}),{});Object.keys(c).length?n[a]=c:delete n[a]};for(a.s();!(r=a.n()).done;)o()}catch(e){a.e(e)}finally{a.f()}return n;case"EDIT_ENTITY_RECORD":var c=pt(pt({},e[t.recordId]),t.edits);return Object.keys(c).forEach((function(e){void 0===c[e]&&delete c[e]})),pt(pt({},e),{},Object(i.a)({},t.recordId,c))}return e},saving:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SAVE_ENTITY_RECORD_START":case"SAVE_ENTITY_RECORD_FINISH":return pt(pt({},e),{},Object(i.a)({},t.recordId,{pending:"SAVE_ENTITY_RECORD_START"===t.type,error:t.error,isAutosave:t.isAutosave}))}return e},deleting:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"DELETE_ENTITY_RECORD_START":case"DELETE_ENTITY_RECORD_FINISH":return pt(pt({},e),{},Object(i.a)({},t.recordId,{pending:"DELETE_ENTITY_RECORD_START"===t.type,error:t.error}))}return e}}))}function vt(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ce,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"ADD_ENTITIES":return[].concat(Object(d.a)(e),Object(d.a)(t.entities))}return e}var yt,ht=[];ht.offset=0;var Ot=Object(s.combineReducers)({terms:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_TERMS":return pt(pt({},e),{},Object(i.a)({},t.taxonomy,t.terms))}return e},users:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{byId:{},queries:{}},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_USER_QUERY":return{byId:pt(pt({},e.byId),Object(p.keyBy)(t.users,"id")),queries:pt(pt({},e.queries),{},Object(i.a)({},t.queryID,Object(p.map)(t.users,(function(e){return e.id}))))}}return e},currentTheme:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_CURRENT_THEME":return t.currentTheme.stylesheet}return e},currentUser:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_CURRENT_USER":return t.currentUser}return e},taxonomies:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_TAXONOMIES":return t.taxonomies}return e},themes:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_CURRENT_THEME":return pt(pt({},e),{},Object(i.a)({},t.currentTheme.stylesheet,t.currentTheme))}return e},themeSupports:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_THEME_SUPPORTS":return pt(pt({},e),t.themeSupports)}return e},entities:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0,r=vt(e.config,t),n=e.reducer;if(!n||r!==e.config){var a=Object(p.groupBy)(r,"kind");n=Object(s.combineReducers)(Object.entries(a).reduce((function(e,t){var r=Object(l.a)(t,2),n=r[0],a=r[1],o=Object(s.combineReducers)(a.reduce((function(e,t){return pt(pt({},e),{},Object(i.a)({},t.name,bt(t)))}),{}));return e[n]=o,e}),{}))}var o=n(e.data,t);return o===e.data&&r===e.config&&n===e.reducer?e:{reducer:n,data:o,config:r}},undo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ht,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"EDIT_ENTITY_RECORD":case"CREATE_UNDO_LEVEL":var r,n="CREATE_UNDO_LEVEL"===t.type,a=!n&&(t.meta.isUndo||t.meta.isRedo);if(n?t=yt:a||(yt=Object.keys(t.edits).some((function(e){return!t.transientEdits[e]}))?t:pt(pt({},t),{},{edits:pt(pt({},yt&&yt.edits),t.edits)})),a){if((r=Object(d.a)(e)).offset=e.offset+(t.meta.isUndo?-1:1),!e.flattenedUndo)return r;n=!0,t=yt}if(!t.meta.undo)return e;if(!n&&!Object.keys(t.edits).some((function(e){return!t.transientEdits[e]})))return(r=Object(d.a)(e)).flattenedUndo=pt(pt({},e.flattenedUndo),t.edits),r.offset=e.offset,r;(r=r||e.slice(0,e.offset||void 0)).offset=r.offset||0,r.pop(),n||r.push({kind:t.meta.undo.kind,name:t.meta.undo.name,recordId:t.meta.undo.recordId,edits:pt(pt({},e.flattenedUndo),t.meta.undo.edits)});var o=Object.values(t.meta.undo.edits).filter((function(e){return"function"!=typeof e})),c=Object.values(t.edits).filter((function(e){return"function"!=typeof e}));return v()(o,c)||r.push({kind:t.kind,name:t.name,recordId:t.recordId,edits:n?pt(pt({},e.flattenedUndo),t.edits):t.edits}),r}return e},embedPreviews:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_EMBED_PREVIEW":var r=t.url,n=t.preview;return pt(pt({},e),{},Object(i.a)({},r,n))}return e},userPermissions:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_USER_PERMISSION":return pt(pt({},e),{},Object(i.a)({},t.key,t.isAllowed))}return e},autosaves:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"RECEIVE_AUTOSAVES":var r=t.postId,n=t.autosaves;return pt(pt({},e),{},Object(i.a)({},r,n))}return e},locks:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:st,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"ENQUEUE_LOCK_REQUEST":var r=t.request;return it(it({},e),{},{requests:[r].concat(Object(d.a)(e.requests))});case"GRANT_LOCK_REQUEST":var n=t.lock,a=t.request,o=a.store,c=a.path,u=[o].concat(Object(d.a)(c)),i=rt(e.tree,u),s=nt(i,u);return s.locks=[].concat(Object(d.a)(s.locks),[n]),it(it({},e),{},{requests:e.requests.filter((function(e){return e!==a})),tree:i});case"RELEASE_LOCK":var f=t.lock,l=[f.store].concat(Object(d.a)(f.path)),p=rt(e.tree,l),b=nt(p,l);return b.locks=b.locks.filter((function(e){return e!==f})),it(it({},e),{},{tree:p})}return e}}),mt=r(49),gt=r(38),jt=r.n(gt),Et=r(122),wt=r.n(Et),_t=new WeakMap;function xt(e,t){var r,n=Qe(t),a=n.stableKey,o=n.page,c=n.perPage,u=n.include,i=n.fields;if(Array.isArray(u)&&!a?r=u:e.queries[a]&&(r=e.queries[a]),!r)return null;for(var s=-1===c?0:(o-1)*c,f=-1===c?r.length:Math.min(s+c,r.length),l=[],d=s;d<f;d++){var b=r[d];if(!Array.isArray(u)||u.includes(b)){if(!e.items.hasOwnProperty(b))return null;var v=e.items[b],y=void 0;if(Array.isArray(i)){y={};for(var h=0;h<i.length;h++){var O=i[h].split("."),m=Object(p.get)(v,O);Object(p.set)(y,O,m)}}else{if(!e.itemIsComplete[b])return null;y=v}l.push(y)}}return l}var kt=Object(mt.a)((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=_t.get(e);if(r){var n=r.get(t);if(void 0!==n)return n}else r=new wt.a,_t.set(e,r);var a=xt(e,t);return r.set(t,a),a}));function Rt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function St(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Rt(Object(r),!0).forEach((function(t){Object(i.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Pt=[],Tt=Object(s.createRegistrySelector)((function(e){return function(t,r){return e("core/data").isResolving("core","getEmbedPreview",[r])}}));function It(e,t){var r=Object(k.addQueryArgs)("/wp/v2/users/?who=authors&per_page=100",t);return Ct(e,r)}function At(e,t){return Object(p.get)(e,["users","byId",t],null)}function Dt(e){return e.currentUser}var Ct=Object(mt.a)((function(e,t){var r=e.users.queries[t];return Object(p.map)(r,(function(t){return e.users.byId[t]}))}),(function(e,t){return[e.users.queries[t],e.users.byId]}));function Ut(e,t){return Object(p.filter)(e.entities.config,{kind:t})}function Lt(e,t,r){return Object(p.find)(e.entities.config,{kind:t,name:r})}function Mt(e,t,r,n,a){var o=Object(p.get)(e.entities.data,[t,r,"queriedData"]);if(o){if(void 0===a){if(!o.itemIsComplete[n])return;return o.items[n]}var c=o.items[n];if(c&&a._fields){for(var u={},i=Ye(a._fields),s=0;s<i.length;s++){var f=i[s].split("."),l=Object(p.get)(c,f);Object(p.set)(u,f,l)}return u}return c}}function Nt(e,t,r,n){return Mt(e,t,r,n)}var qt=Object(mt.a)((function(e,t,r,n){var a=Mt(e,t,r,n);return a&&Object.keys(a).reduce((function(e,t){return e[t]=Object(p.get)(a[t],"raw",a[t]),e}),{})}),(function(e){return[e.entities.data]}));function Vt(e,t,r,n){return Array.isArray(Ft(e,t,r,n))}function Ft(e,t,r,n){var a=Object(p.get)(e.entities.data,[t,r,"queriedData"]);return a?kt(a,n):Pt}var Yt=Object(mt.a)((function(e){var t=e.entities.data,r=[];return Object.keys(t).forEach((function(n){Object.keys(t[n]).forEach((function(a){var o=Object.keys(t[n][a].edits).filter((function(t){return Bt(e,n,a,t)}));if(o.length){var c=Lt(e,n,a);o.forEach((function(t){var o,u=Ht(e,n,a,t);r.push({key:u[c.key||De],title:(null==c||null===(o=c.getTitle)||void 0===o?void 0:o.call(c,u))||"",name:a,kind:n})}))}}))})),r}),(function(e){return[e.entities.data]}));function Qt(e,t,r,n){return Object(p.get)(e.entities.data,[t,r,"edits",n])}var Gt=Object(mt.a)((function(e,t,r,n){var a=(Lt(e,t,r)||{}).transientEdits,o=Qt(e,t,r,n)||{};return a?Object.keys(o).reduce((function(e,t){return a[t]||(e[t]=o[t]),e}),{}):o}),(function(e){return[e.entities.config,e.entities.data]}));function Bt(e,t,r,n){return zt(e,t,r,n)||Object.keys(Gt(e,t,r,n)).length>0}var Ht=Object(mt.a)((function(e,t,r,n){return St(St({},qt(e,t,r,n)),Qt(e,t,r,n))}),(function(e){return[e.entities.data]}));function Kt(e,t,r,n){var a=Object(p.get)(e.entities.data,[t,r,"saving",n],{}),o=a.pending,c=a.isAutosave;return Boolean(o&&c)}function zt(e,t,r,n){return Object(p.get)(e.entities.data,[t,r,"saving",n,"pending"],!1)}function Wt(e,t,r,n){return Object(p.get)(e.entities.data,[t,r,"deleting",n,"pending"],!1)}function $t(e,t,r,n){return Object(p.get)(e.entities.data,[t,r,"saving",n,"error"])}function Xt(e,t,r,n){return Object(p.get)(e.entities.data,[t,r,"deleting",n,"error"])}function Jt(e){return e.undo.offset}function Zt(e){return e.undo[e.undo.length-2+Jt(e)]}function er(e){return e.undo[e.undo.length+Jt(e)]}function tr(e){return Boolean(Zt(e))}function rr(e){return Boolean(er(e))}function nr(e){return e.themes[e.currentTheme]}function ar(e){return e.themeSupports}function or(e,t){return e.embedPreviews[t]}function cr(e,t){var r=e.embedPreviews[t],n='<a href="'+t+'">'+t+"</a>";return!!r&&r.html===n}function ur(e){return jt()("select( 'core' ).hasUploadPermissions()",{alternative:"select( 'core' ).canUser( 'create', 'media' )"}),Object(p.defaultTo)(ir(e,"create","media"),!0)}function ir(e,t,r,n){var a=Object(p.compact)([t,r,n]).join("/");return Object(p.get)(e,["userPermissions",a])}function sr(e,t,r){return e.autosaves[r]}function fr(e,t,r,n){if(void 0!==n){var a=e.autosaves[r];return Object(p.find)(a,{author:n})}}var lr=Object(s.createRegistrySelector)((function(e){return function(t,r,n){return e("core").hasFinishedResolution("getAutosaves",[r,n])}})),dr=Object(mt.a)((function(){return[]}),(function(e){return[e.undo.length,e.undo.offset,e.undo.flattenedUndo]}));function pr(e,t){var r=Ft(e,"postType","wp_template",{"find-template":t});return null!=r&&r.length?r[0]:null}var br=function(e,t){return E.a.mark((function r(){var n,a,o,c=arguments;return E.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:for(n=c.length,a=new Array(n),o=0;o<n;o++)a[o]=c[o];return r.next=3,s.controls.select("core","hasStartedResolution",t,a);case 3:if(r.sent){r.next=6;break}return r.delegateYield(e.apply(void 0,a),"t0",6);case 6:case"end":return r.stop()}}),r)}))};function vr(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return yr(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?yr(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,c=!0,u=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return c=e.done,e},e:function(e){u=!0,o=e},f:function(){try{c||null==r.return||r.return()}finally{if(u)throw o}}}}function yr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function hr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Or(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?hr(Object(r),!0).forEach((function(t){Object(i.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):hr(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var mr=E.a.mark(Ar),gr=E.a.mark(Dr),jr=E.a.mark(Cr),Er=E.a.mark(Ur),wr=E.a.mark(Nr),_r=E.a.mark(qr),xr=E.a.mark(Vr),kr=E.a.mark(Fr),Rr=E.a.mark(Yr),Sr=E.a.mark(Qr),Pr=E.a.mark(Gr),Tr=E.a.mark(Br),Ir=E.a.mark(Hr);function Ar(e){var t,r;return E.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t=Object(k.addQueryArgs)("/wp/v2/users/?who=authors&per_page=100",e),n.next=3,Object(f.apiFetch)({path:t});case 3:return r=n.sent,n.next=6,de(t,r);case 6:case"end":return n.stop()}}),mr)}function Dr(e){var t,r;return E.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return t="/wp/v2/users?who=authors&include=".concat(e),n.next=3,Object(f.apiFetch)({path:t});case 3:return r=n.sent,n.next=6,de("author",r);case 6:case"end":return n.stop()}}),gr)}function Cr(){var e;return E.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(f.apiFetch)({path:"/wp/v2/users/me"});case 2:return e=t.sent,t.next=5,pe(e);case 5:case"end":return t.stop()}}),jr)}function Ur(e,t){var r,n,a,o,c,u,i,l=arguments;return E.a.wrap((function(b){for(;;)switch(b.prev=b.next){case 0:return r=l.length>2&&void 0!==l[2]?l[2]:"",n=l.length>3?l[3]:void 0,b.next=4,Ve(e);case 4:if(a=b.sent,o=Object(p.find)(a,{kind:e,name:t})){b.next=8;break}return b.abrupt("return");case 8:return b.delegateYield(N("core",["entities","data",e,t,r],{exclusive:!1}),"t0",9);case 9:if(c=b.t0,b.prev=10,void 0!==n&&n._fields&&(n=Or(Or({},n),{},{_fields:Object(p.uniq)([].concat(Object(d.a)(Ye(n._fields)||[]),[o.key||De])).join()})),u=Object(k.addQueryArgs)(o.baseURL+"/"+r,Or(Or({},n),{},{context:"edit"})),void 0===n){b.next=20;break}return n=Or(Or({},n),{},{include:[r]}),b.next=17,s.controls.select("core","hasEntityRecords",e,t,n);case 17:if(!b.sent){b.next=20;break}return b.abrupt("return");case 20:return b.next=22,Object(f.apiFetch)({path:u});case 22:return i=b.sent,b.next=25,ve(e,t,i,n);case 25:b.next=29;break;case 27:b.prev=27,b.t1=b.catch(10);case 29:return b.prev=29,b.delegateYield(V(c),"t2",31);case 31:return b.finish(29);case 32:case"end":return b.stop()}}),Er,null,[[10,27,29,32]])}var Lr=br(Ur,"getEntityRecord"),Mr=br(Lr,"getRawEntityRecord");function Nr(e,t){var r,n,a,o,c,u,i,s,l,b,v,y=arguments;return E.a.wrap((function(h){for(;;)switch(h.prev=h.next){case 0:return r=y.length>2&&void 0!==y[2]?y[2]:{},h.next=3,Ve(e);case 3:if(n=h.sent,a=Object(p.find)(n,{kind:e,name:t})){h.next=7;break}return h.abrupt("return");case 7:return h.delegateYield(N("core",["entities","data",e,t],{exclusive:!1}),"t0",8);case 8:return o=h.t0,h.prev=9,r._fields&&(r=Or(Or({},r),{},{_fields:Object(p.uniq)([].concat(Object(d.a)(Ye(r._fields)||[]),[a.key||De])).join()})),u=Object(k.addQueryArgs)(a.baseURL,Or(Or({},r),{},{context:"edit"})),h.t1=Object,h.next=15,Object(f.apiFetch)({path:u});case 15:return h.t2=h.sent,i=h.t1.values.call(h.t1,h.t2),r._fields&&(i=i.map((function(e){return r._fields.split(",").forEach((function(t){e.hasOwnProperty(t)||(e[t]=void 0)})),e}))),h.next=20,ve(e,t,i,r);case 20:if(null!==(c=r)&&void 0!==c&&c._fields){h.next=42;break}s=a.key||De,l=vr(i),h.prev=23,l.s();case 25:if((b=l.n()).done){h.next=34;break}if(!(v=b.value)[s]){h.next=32;break}return h.next=30,{type:"START_RESOLUTION",selectorName:"getEntityRecord",args:[e,t,v[s]]};case 30:return h.next=32,{type:"FINISH_RESOLUTION",selectorName:"getEntityRecord",args:[e,t,v[s]]};case 32:h.next=25;break;case 34:h.next=39;break;case 36:h.prev=36,h.t3=h.catch(23),l.e(h.t3);case 39:return h.prev=39,l.f(),h.finish(39);case 42:return h.prev=42,h.delegateYield(V(o),"t4",44);case 44:return h.finish(42);case 45:case"end":return h.stop()}}),wr,null,[[9,,42,45],[23,36,39,42]])}function qr(){var e;return E.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(f.apiFetch)({path:"/wp/v2/themes?status=active"});case 2:return e=t.sent,t.next=5,ye(e[0]);case 5:case"end":return t.stop()}}),_r)}function Vr(){var e;return E.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Object(f.apiFetch)({path:"/wp/v2/themes?status=active"});case 2:return e=t.sent,t.next=5,he(e[0].theme_supports);case 5:case"end":return t.stop()}}),xr)}function Fr(e){var t;return E.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,Object(f.apiFetch)({path:Object(k.addQueryArgs)("/oembed/1.0/proxy",{url:e})});case 3:return t=r.sent,r.next=6,Oe(e,t);case 6:r.next=12;break;case 8:return r.prev=8,r.t0=r.catch(0),r.next=12,Oe(e,!1);case 12:case"end":return r.stop()}}),kr,null,[[0,8]])}function Yr(){return E.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jt()("select( 'core' ).hasUploadPermissions()",{alternative:"select( 'core' ).canUser( 'create', 'media' )"}),e.delegateYield(Qr("create","media"),"t0",2);case 2:case"end":return e.stop()}}),Rr)}function Qr(e,t,r){var n,a,o,c,u,i;return E.a.wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(n={create:"POST",read:"GET",update:"PUT",delete:"DELETE"}[e]){s.next=4;break}throw new Error("'".concat(e,"' is not a valid action."));case 4:return a=r?"/wp/v2/".concat(t,"/").concat(r):"/wp/v2/".concat(t),s.prev=5,s.next=8,Object(f.apiFetch)({path:a,method:r?"GET":"OPTIONS",parse:!1});case 8:o=s.sent,s.next=14;break;case 11:return s.prev=11,s.t0=s.catch(5),s.abrupt("return");case 14:return c=Object(p.hasIn)(o,["headers","get"])?o.headers.get("allow"):Object(p.get)(o,["headers","Allow"],""),u=Object(p.compact)([e,t,r]).join("/"),i=Object(p.includes)(c,n),s.next=19,Se(u,i);case 19:case"end":return s.stop()}}),Sr,null,[[5,11]])}function Gr(e,t){var r,n,a;return E.a.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,s.controls.resolveSelect("core","getPostType",e);case 2:return r=o.sent,n=r.rest_base,o.next=6,Object(f.apiFetch)({path:"/wp/v2/".concat(n,"/").concat(t,"/autosaves?context=edit")});case 6:if(!(a=o.sent)||!a.length){o.next=10;break}return o.next=10,Pe(t,a);case 10:case"end":return o.stop()}}),Pr)}function Br(e,t){return E.a.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,s.controls.resolveSelect("core","getAutosaves",e,t);case 2:case"end":return r.stop()}}),Tr)}function Hr(e){var t,r;return E.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,{type:"REGULAR_FETCH",url:Object(k.addQueryArgs)(e,{"_wp-find-template":!0})};case 2:if(null!==(t=n.sent)){n.next=5;break}return n.abrupt("return");case 5:return n.next=7,Ur("postType","wp_template",t.id);case 7:return n.next=9,s.controls.select("core","getEntityRecord","postType","wp_template",t.id);case 9:if(!(r=n.sent)){n.next=13;break}return n.next=13,ve("postType","wp_template",[r],{"find-template":e});case 13:case"end":return n.stop()}}),Ir)}function Kr(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return zr(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?zr(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,c=!0,u=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return c=e.done,e},e:function(e){u=!0,o=e},f:function(){try{c||null==r.return||r.return()}finally{if(u)throw o}}}}function zr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Wr(e){return e.locks.requests}function $r(e,t,r,n){var a,o=n.exclusive,c=[t].concat(Object(d.a)(r)),u=e.locks.tree,i=Kr(at(u,c));try{for(i.s();!(a=i.n()).done;)if(ct({exclusive:o},a.value.locks))return!1}catch(e){i.e(e)}finally{i.f()}var s=nt(u,c);if(!s)return!0;var f,l=Kr(ot(s));try{for(l.s();!(f=l.n()).done;)if(ct({exclusive:o},f.value.locks))return!1}catch(e){l.e(e)}finally{l.f()}return!0}Nr.shouldInvalidate=function(e,t,r){return("RECEIVE_ITEMS"===e.type||"REMOVE_ITEMS"===e.type)&&e.invalidateCache&&t===e.kind&&r===e.name};var Xr=r(0),Jr=r(11);function Zr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function en(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Zr(Object(r),!0).forEach((function(t){Object(i.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Zr(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var tn=[],rn=en(en({},Ce.reduce((function(e,t){return e[t.kind]||(e[t.kind]={}),e[t.kind][t.name]={context:Object(Xr.createContext)()},e}),{})),Ue.reduce((function(e,t){return e[t.name]={},e}),{})),nn=function(e,t){if(!rn[e])throw new Error("Missing entity config for kind: ".concat(e,"."));return rn[e][t]||(rn[e][t]={context:Object(Xr.createContext)()}),rn[e][t]};function an(e){var t=e.kind,r=e.type,n=e.id,a=e.children,o=nn(t,r).context.Provider;return Object(Xr.createElement)(o,{value:n},a)}function on(e,t){return Object(Xr.useContext)(nn(e,t).context)}function cn(e,t,r,n){var a=on(e,t),o=null!=n?n:a,c=Object(s.useSelect)((function(n){var a=n("core"),c=a.getEntityRecord,u=a.getEditedEntityRecord,i=c(e,t,o),s=u(e,t,o);return i&&s?{value:s[r],fullValue:i[r]}:{}}),[e,t,o,r]),u=c.value,f=c.fullValue,l=Object(s.useDispatch)("core").editEntityRecord;return[u,Object(Xr.useCallback)((function(n){l(e,t,o,Object(i.a)({},r,n))}),[e,t,o,r]),f]}function un(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.id,a=on(e,t),o=null!=n?n:a,c=Object(s.useSelect)((function(r){var n=(0,r("core").getEditedEntityRecord)(e,t,o);return{blocks:n.blocks,content:n.content}}),[e,t,o]),u=c.content,i=c.blocks,f=Object(s.useDispatch)("core"),l=f.__unstableCreateUndoLevel,d=f.editEntityRecord;Object(Xr.useEffect)((function(){if(u&&"function"!=typeof u&&!i){var r=Object(Jr.parse)(u);d(e,t,o,{blocks:r},{undoIgnore:!0})}}),[u]);var p=Object(Xr.useCallback)((function(r,n){var a={blocks:r,selection:n.selection};if(i===a.blocks)return l(e,t,o);a.content=function(e){var t=e.blocks,r=void 0===t?[]:t;return Object(Jr.__unstableSerializeAndClean)(r)},d(e,t,o,a)}),[e,t,o,i]),b=Object(Xr.useCallback)((function(r,n){var a=n.selection;d(e,t,o,{blocks:r,selection:a})}),[e,t,o]);return[null!=i?i:tn,b,p]}function sn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function fn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sn(Object(r),!0).forEach((function(t){Object(i.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sn(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ln=Ce.reduce((function(e,t){var r=t.kind,n=t.name;return e[qe(r,n)]=function(e,t){return Mt(e,r,n,t)},e[qe(r,n,"get",!0)]=function(e){for(var t=arguments.length,a=new Array(t>1?t-1:0),c=1;c<t;c++)a[c-1]=arguments[c];return Ft.apply(o,[e,r,n].concat(a))},e}),{}),dn=Ce.reduce((function(e,t){var r=t.kind,n=t.name;e[qe(r,n)]=function(e){return Ur(r,n,e)};var a=qe(r,n,"get",!0);return e[a]=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return Nr.apply(c,[r,n].concat(t))},e[a].shouldInvalidate=function(e){for(var t,a=arguments.length,o=new Array(a>1?a-1:0),c=1;c<a;c++)o[c-1]=arguments[c];return(t=Nr).shouldInvalidate.apply(t,[e,r,n].concat(o))},e}),{}),pn=Ce.reduce((function(e,t){var r=t.kind,n=t.name;return e[qe(r,n,"save")]=function(e){return _e(r,n,e)},e[qe(r,n,"delete")]=function(e,t){return me(r,n,e,t)},e}),{}),bn={reducer:Ot,controls:fn(fn({},re),f.controls),actions:fn(fn(fn({},a),pn),n),selectors:fn(fn(fn({},o),ln),u),resolvers:fn(fn({},c),dn)},vn=Object(s.createReduxStore)("core",bn);Object(s.register)(vn)},55:function(e,t){e.exports=window.wp.dataControls},58:function(e,t,r){"use strict";function n(e,t){return(n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}r.d(t,"a",(function(){return n}))},72:function(e,t){e.exports=window.wp.isShallowEqual},8:function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(39),a=r(30),o=r(40);function c(e,t){return Object(n.a)(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],_n=!0,n=!1,a=void 0;try{for(var o,c=e[Symbol.iterator]();!(_n=(o=c.next()).done)&&(r.push(o.value),!t||r.length!==t);_n=!0);}catch(e){n=!0,a=e}finally{try{_n||null==c.return||c.return()}finally{if(n)throw a}}return r}}(e,t)||Object(a.a)(e,t)||Object(o.a)()}}});