wp/wp-includes/js/dist/core-data.js
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
     1 /******/ (function() { // webpackBootstrap
     1 /******/ (() => { // webpackBootstrap
       
     2 /******/ 	"use strict";
     2 /******/ 	var __webpack_modules__ = ({
     3 /******/ 	var __webpack_modules__ = ({
     3 
     4 
     4 /***/ 2167:
     5 /***/ 6689:
     5 /***/ (function(module) {
     6 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
     6 
     7 
     7 "use strict";
     8 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
       
     9 /* harmony export */   createUndoManager: () => (/* binding */ createUndoManager)
       
    10 /* harmony export */ });
       
    11 /* harmony import */ var _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(923);
       
    12 /* harmony import */ var _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0__);
       
    13 /**
       
    14  * WordPress dependencies
       
    15  */
       
    16 
       
    17 
       
    18 /** @typedef {import('./types').HistoryRecord}  HistoryRecord */
       
    19 /** @typedef {import('./types').HistoryChange}  HistoryChange */
       
    20 /** @typedef {import('./types').HistoryChanges} HistoryChanges */
       
    21 /** @typedef {import('./types').UndoManager} UndoManager */
       
    22 
       
    23 /**
       
    24  * Merge changes for a single item into a record of changes.
       
    25  *
       
    26  * @param {Record< string, HistoryChange >} changes1 Previous changes
       
    27  * @param {Record< string, HistoryChange >} changes2 NextChanges
       
    28  *
       
    29  * @return {Record< string, HistoryChange >} Merged changes
       
    30  */
       
    31 function mergeHistoryChanges(changes1, changes2) {
       
    32   /**
       
    33    * @type {Record< string, HistoryChange >}
       
    34    */
       
    35   const newChanges = {
       
    36     ...changes1
       
    37   };
       
    38   Object.entries(changes2).forEach(([key, value]) => {
       
    39     if (newChanges[key]) {
       
    40       newChanges[key] = {
       
    41         ...newChanges[key],
       
    42         to: value.to
       
    43       };
       
    44     } else {
       
    45       newChanges[key] = value;
       
    46     }
       
    47   });
       
    48   return newChanges;
       
    49 }
       
    50 
       
    51 /**
       
    52  * Adds history changes for a single item into a record of changes.
       
    53  *
       
    54  * @param {HistoryRecord}  record  The record to merge into.
       
    55  * @param {HistoryChanges} changes The changes to merge.
       
    56  */
       
    57 const addHistoryChangesIntoRecord = (record, changes) => {
       
    58   const existingChangesIndex = record?.findIndex(({
       
    59     id: recordIdentifier
       
    60   }) => {
       
    61     return typeof recordIdentifier === 'string' ? recordIdentifier === changes.id : _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default()(recordIdentifier, changes.id);
       
    62   });
       
    63   const nextRecord = [...record];
       
    64   if (existingChangesIndex !== -1) {
       
    65     // If the edit is already in the stack leave the initial "from" value.
       
    66     nextRecord[existingChangesIndex] = {
       
    67       id: changes.id,
       
    68       changes: mergeHistoryChanges(nextRecord[existingChangesIndex].changes, changes.changes)
       
    69     };
       
    70   } else {
       
    71     nextRecord.push(changes);
       
    72   }
       
    73   return nextRecord;
       
    74 };
       
    75 
       
    76 /**
       
    77  * Creates an undo manager.
       
    78  *
       
    79  * @return {UndoManager} Undo manager.
       
    80  */
       
    81 function createUndoManager() {
       
    82   /**
       
    83    * @type {HistoryRecord[]}
       
    84    */
       
    85   let history = [];
       
    86   /**
       
    87    * @type {HistoryRecord}
       
    88    */
       
    89   let stagedRecord = [];
       
    90   /**
       
    91    * @type {number}
       
    92    */
       
    93   let offset = 0;
       
    94   const dropPendingRedos = () => {
       
    95     history = history.slice(0, offset || undefined);
       
    96     offset = 0;
       
    97   };
       
    98   const appendStagedRecordToLatestHistoryRecord = () => {
       
    99     var _history$index;
       
   100     const index = history.length === 0 ? 0 : history.length - 1;
       
   101     let latestRecord = (_history$index = history[index]) !== null && _history$index !== void 0 ? _history$index : [];
       
   102     stagedRecord.forEach(changes => {
       
   103       latestRecord = addHistoryChangesIntoRecord(latestRecord, changes);
       
   104     });
       
   105     stagedRecord = [];
       
   106     history[index] = latestRecord;
       
   107   };
       
   108 
       
   109   /**
       
   110    * Checks whether a record is empty.
       
   111    * A record is considered empty if it the changes keep the same values.
       
   112    * Also updates to function values are ignored.
       
   113    *
       
   114    * @param {HistoryRecord} record
       
   115    * @return {boolean} Whether the record is empty.
       
   116    */
       
   117   const isRecordEmpty = record => {
       
   118     const filteredRecord = record.filter(({
       
   119       changes
       
   120     }) => {
       
   121       return Object.values(changes).some(({
       
   122         from,
       
   123         to
       
   124       }) => typeof from !== 'function' && typeof to !== 'function' && !_wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default()(from, to));
       
   125     });
       
   126     return !filteredRecord.length;
       
   127   };
       
   128   return {
       
   129     /**
       
   130      * Record changes into the history.
       
   131      *
       
   132      * @param {HistoryRecord=} record   A record of changes to record.
       
   133      * @param {boolean}        isStaged Whether to immediately create an undo point or not.
       
   134      */
       
   135     addRecord(record, isStaged = false) {
       
   136       const isEmpty = !record || isRecordEmpty(record);
       
   137       if (isStaged) {
       
   138         if (isEmpty) {
       
   139           return;
       
   140         }
       
   141         record.forEach(changes => {
       
   142           stagedRecord = addHistoryChangesIntoRecord(stagedRecord, changes);
       
   143         });
       
   144       } else {
       
   145         dropPendingRedos();
       
   146         if (stagedRecord.length) {
       
   147           appendStagedRecordToLatestHistoryRecord();
       
   148         }
       
   149         if (isEmpty) {
       
   150           return;
       
   151         }
       
   152         history.push(record);
       
   153       }
       
   154     },
       
   155     undo() {
       
   156       if (stagedRecord.length) {
       
   157         dropPendingRedos();
       
   158         appendStagedRecordToLatestHistoryRecord();
       
   159       }
       
   160       const undoRecord = history[history.length - 1 + offset];
       
   161       if (!undoRecord) {
       
   162         return;
       
   163       }
       
   164       offset -= 1;
       
   165       return undoRecord;
       
   166     },
       
   167     redo() {
       
   168       const redoRecord = history[history.length + offset];
       
   169       if (!redoRecord) {
       
   170         return;
       
   171       }
       
   172       offset += 1;
       
   173       return redoRecord;
       
   174     },
       
   175     hasUndo() {
       
   176       return !!history[history.length - 1 + offset];
       
   177     },
       
   178     hasRedo() {
       
   179       return !!history[history.length + offset];
       
   180     }
       
   181   };
       
   182 }
       
   183 
       
   184 
       
   185 /***/ }),
       
   186 
       
   187 /***/ 3249:
       
   188 /***/ ((module) => {
       
   189 
     8 
   190 
     9 
   191 
    10 function _typeof(obj) {
   192 function _typeof(obj) {
    11   if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
   193   if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
    12     _typeof = function (obj) {
   194     _typeof = function (obj) {
   314 module.exports = EquivalentKeyMap;
   496 module.exports = EquivalentKeyMap;
   315 
   497 
   316 
   498 
   317 /***/ }),
   499 /***/ }),
   318 
   500 
   319 /***/ 9756:
   501 /***/ 7734:
   320 /***/ (function(module) {
   502 /***/ ((module) => {
   321 
   503 
   322 /**
   504 
   323  * Memize options object.
   505 
   324  *
   506 // do not edit .js files directly - edit src/index.jst
   325  * @typedef MemizeOptions
   507 
   326  *
   508 
   327  * @property {number} [maxSize] Maximum size of the cache.
   509   var envHasBigInt64Array = typeof BigInt64Array !== 'undefined';
   328  */
   510 
   329 
   511 
   330 /**
   512 module.exports = function equal(a, b) {
   331  * Internal cache entry.
   513   if (a === b) return true;
   332  *
   514 
   333  * @typedef MemizeCacheNode
   515   if (a && b && typeof a == 'object' && typeof b == 'object') {
   334  *
   516     if (a.constructor !== b.constructor) return false;
   335  * @property {?MemizeCacheNode|undefined} [prev] Previous node.
   517 
   336  * @property {?MemizeCacheNode|undefined} [next] Next node.
   518     var length, i, keys;
   337  * @property {Array<*>}                   args   Function arguments for cache
   519     if (Array.isArray(a)) {
   338  *                                               entry.
   520       length = a.length;
   339  * @property {*}                          val    Function result.
   521       if (length != b.length) return false;
   340  */
   522       for (i = length; i-- !== 0;)
   341 
   523         if (!equal(a[i], b[i])) return false;
   342 /**
   524       return true;
   343  * Properties of the enhanced function for controlling cache.
   525     }
   344  *
   526 
   345  * @typedef MemizeMemoizedFunction
   527 
   346  *
   528     if ((a instanceof Map) && (b instanceof Map)) {
   347  * @property {()=>void} clear Clear the cache.
   529       if (a.size !== b.size) return false;
   348  */
   530       for (i of a.entries())
   349 
   531         if (!b.has(i[0])) return false;
   350 /**
   532       for (i of a.entries())
   351  * Accepts a function to be memoized, and returns a new memoized function, with
   533         if (!equal(i[1], b.get(i[0]))) return false;
   352  * optional options.
   534       return true;
   353  *
   535     }
   354  * @template {Function} F
   536 
   355  *
   537     if ((a instanceof Set) && (b instanceof Set)) {
   356  * @param {F}             fn        Function to memoize.
   538       if (a.size !== b.size) return false;
   357  * @param {MemizeOptions} [options] Options object.
   539       for (i of a.entries())
   358  *
   540         if (!b.has(i[0])) return false;
   359  * @return {F & MemizeMemoizedFunction} Memoized function.
   541       return true;
   360  */
   542     }
   361 function memize( fn, options ) {
   543 
   362 	var size = 0;
   544     if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
   363 
   545       length = a.length;
   364 	/** @type {?MemizeCacheNode|undefined} */
   546       if (length != b.length) return false;
   365 	var head;
   547       for (i = length; i-- !== 0;)
   366 
   548         if (a[i] !== b[i]) return false;
   367 	/** @type {?MemizeCacheNode|undefined} */
   549       return true;
   368 	var tail;
   550     }
   369 
   551 
   370 	options = options || {};
   552 
   371 
   553     if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
   372 	function memoized( /* ...args */ ) {
   554     if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
   373 		var node = head,
   555     if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
   374 			len = arguments.length,
   556 
   375 			args, i;
   557     keys = Object.keys(a);
   376 
   558     length = keys.length;
   377 		searchCache: while ( node ) {
   559     if (length !== Object.keys(b).length) return false;
   378 			// Perform a shallow equality test to confirm that whether the node
   560 
   379 			// under test is a candidate for the arguments passed. Two arrays
   561     for (i = length; i-- !== 0;)
   380 			// are shallowly equal if their length matches and each entry is
   562       if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
   381 			// strictly equal between the two sets. Avoid abstracting to a
   563 
   382 			// function which could incur an arguments leaking deoptimization.
   564     for (i = length; i-- !== 0;) {
   383 
   565       var key = keys[i];
   384 			// Check whether node arguments match arguments length
   566 
   385 			if ( node.args.length !== arguments.length ) {
   567       if (!equal(a[key], b[key])) return false;
   386 				node = node.next;
   568     }
   387 				continue;
   569 
   388 			}
   570     return true;
   389 
   571   }
   390 			// Check whether node arguments match arguments values
   572 
   391 			for ( i = 0; i < len; i++ ) {
   573   // true if both NaN, false otherwise
   392 				if ( node.args[ i ] !== arguments[ i ] ) {
   574   return a!==a && b!==b;
   393 					node = node.next;
   575 };
   394 					continue searchCache;
   576 
   395 				}
   577 
   396 			}
   578 /***/ }),
   397 
   579 
   398 			// At this point we can assume we've found a match
   580 /***/ 923:
   399 
   581 /***/ ((module) => {
   400 			// Surface matched node to head if not already
   582 
   401 			if ( node !== head ) {
   583 module.exports = window["wp"]["isShallowEqual"];
   402 				// As tail, shift to previous. Must only shift if not also
       
   403 				// head, since if both head and tail, there is no previous.
       
   404 				if ( node === tail ) {
       
   405 					tail = node.prev;
       
   406 				}
       
   407 
       
   408 				// Adjust siblings to point to each other. If node was tail,
       
   409 				// this also handles new tail's empty `next` assignment.
       
   410 				/** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
       
   411 				if ( node.next ) {
       
   412 					node.next.prev = node.prev;
       
   413 				}
       
   414 
       
   415 				node.next = head;
       
   416 				node.prev = null;
       
   417 				/** @type {MemizeCacheNode} */ ( head ).prev = node;
       
   418 				head = node;
       
   419 			}
       
   420 
       
   421 			// Return immediately
       
   422 			return node.val;
       
   423 		}
       
   424 
       
   425 		// No cached value found. Continue to insertion phase:
       
   426 
       
   427 		// Create a copy of arguments (avoid leaking deoptimization)
       
   428 		args = new Array( len );
       
   429 		for ( i = 0; i < len; i++ ) {
       
   430 			args[ i ] = arguments[ i ];
       
   431 		}
       
   432 
       
   433 		node = {
       
   434 			args: args,
       
   435 
       
   436 			// Generate the result from original function
       
   437 			val: fn.apply( null, args ),
       
   438 		};
       
   439 
       
   440 		// Don't need to check whether node is already head, since it would
       
   441 		// have been returned above already if it was
       
   442 
       
   443 		// Shift existing head down list
       
   444 		if ( head ) {
       
   445 			head.prev = node;
       
   446 			node.next = head;
       
   447 		} else {
       
   448 			// If no head, follows that there's no tail (at initial or reset)
       
   449 			tail = node;
       
   450 		}
       
   451 
       
   452 		// Trim tail if we're reached max size and are pending cache insertion
       
   453 		if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
       
   454 			tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
       
   455 			/** @type {MemizeCacheNode} */ ( tail ).next = null;
       
   456 		} else {
       
   457 			size++;
       
   458 		}
       
   459 
       
   460 		head = node;
       
   461 
       
   462 		return node.val;
       
   463 	}
       
   464 
       
   465 	memoized.clear = function() {
       
   466 		head = null;
       
   467 		tail = null;
       
   468 		size = 0;
       
   469 	};
       
   470 
       
   471 	if ( false ) {}
       
   472 
       
   473 	// Ignore reason: There's not a clear solution to create an intersection of
       
   474 	// the function with additional properties, where the goal is to retain the
       
   475 	// function signature of the incoming argument and add control properties
       
   476 	// on the return value.
       
   477 
       
   478 	// @ts-ignore
       
   479 	return memoized;
       
   480 }
       
   481 
       
   482 module.exports = memize;
       
   483 
       
   484 
   584 
   485 /***/ })
   585 /***/ })
   486 
   586 
   487 /******/ 	});
   587 /******/ 	});
   488 /************************************************************************/
   588 /************************************************************************/
   510 /******/ 		return module.exports;
   610 /******/ 		return module.exports;
   511 /******/ 	}
   611 /******/ 	}
   512 /******/ 	
   612 /******/ 	
   513 /************************************************************************/
   613 /************************************************************************/
   514 /******/ 	/* webpack/runtime/compat get default export */
   614 /******/ 	/* webpack/runtime/compat get default export */
   515 /******/ 	!function() {
   615 /******/ 	(() => {
   516 /******/ 		// getDefaultExport function for compatibility with non-harmony modules
   616 /******/ 		// getDefaultExport function for compatibility with non-harmony modules
   517 /******/ 		__webpack_require__.n = function(module) {
   617 /******/ 		__webpack_require__.n = (module) => {
   518 /******/ 			var getter = module && module.__esModule ?
   618 /******/ 			var getter = module && module.__esModule ?
   519 /******/ 				function() { return module['default']; } :
   619 /******/ 				() => (module['default']) :
   520 /******/ 				function() { return module; };
   620 /******/ 				() => (module);
   521 /******/ 			__webpack_require__.d(getter, { a: getter });
   621 /******/ 			__webpack_require__.d(getter, { a: getter });
   522 /******/ 			return getter;
   622 /******/ 			return getter;
   523 /******/ 		};
   623 /******/ 		};
   524 /******/ 	}();
   624 /******/ 	})();
   525 /******/ 	
   625 /******/ 	
   526 /******/ 	/* webpack/runtime/define property getters */
   626 /******/ 	/* webpack/runtime/define property getters */
   527 /******/ 	!function() {
   627 /******/ 	(() => {
   528 /******/ 		// define getter functions for harmony exports
   628 /******/ 		// define getter functions for harmony exports
   529 /******/ 		__webpack_require__.d = function(exports, definition) {
   629 /******/ 		__webpack_require__.d = (exports, definition) => {
   530 /******/ 			for(var key in definition) {
   630 /******/ 			for(var key in definition) {
   531 /******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
   631 /******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
   532 /******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
   632 /******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
   533 /******/ 				}
   633 /******/ 				}
   534 /******/ 			}
   634 /******/ 			}
   535 /******/ 		};
   635 /******/ 		};
   536 /******/ 	}();
   636 /******/ 	})();
   537 /******/ 	
   637 /******/ 	
   538 /******/ 	/* webpack/runtime/hasOwnProperty shorthand */
   638 /******/ 	/* webpack/runtime/hasOwnProperty shorthand */
   539 /******/ 	!function() {
   639 /******/ 	(() => {
   540 /******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
   640 /******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
   541 /******/ 	}();
   641 /******/ 	})();
   542 /******/ 	
   642 /******/ 	
   543 /******/ 	/* webpack/runtime/make namespace object */
   643 /******/ 	/* webpack/runtime/make namespace object */
   544 /******/ 	!function() {
   644 /******/ 	(() => {
   545 /******/ 		// define __esModule on exports
   645 /******/ 		// define __esModule on exports
   546 /******/ 		__webpack_require__.r = function(exports) {
   646 /******/ 		__webpack_require__.r = (exports) => {
   547 /******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
   647 /******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
   548 /******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
   648 /******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
   549 /******/ 			}
   649 /******/ 			}
   550 /******/ 			Object.defineProperty(exports, '__esModule', { value: true });
   650 /******/ 			Object.defineProperty(exports, '__esModule', { value: true });
   551 /******/ 		};
   651 /******/ 		};
   552 /******/ 	}();
   652 /******/ 	})();
   553 /******/ 	
   653 /******/ 	
   554 /************************************************************************/
   654 /************************************************************************/
   555 var __webpack_exports__ = {};
   655 var __webpack_exports__ = {};
   556 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
   656 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
   557 !function() {
   657 (() => {
   558 "use strict";
       
   559 // ESM COMPAT FLAG
   658 // ESM COMPAT FLAG
   560 __webpack_require__.r(__webpack_exports__);
   659 __webpack_require__.r(__webpack_exports__);
   561 
   660 
   562 // EXPORTS
   661 // EXPORTS
   563 __webpack_require__.d(__webpack_exports__, {
   662 __webpack_require__.d(__webpack_exports__, {
   564   "EntityProvider": function() { return /* reexport */ EntityProvider; },
   663   EntityProvider: () => (/* reexport */ EntityProvider),
   565   "__experimentalFetchLinkSuggestions": function() { return /* reexport */ _experimental_fetch_link_suggestions; },
   664   __experimentalFetchLinkSuggestions: () => (/* reexport */ _experimental_fetch_link_suggestions),
   566   "__experimentalFetchUrlData": function() { return /* reexport */ _experimental_fetch_url_data; },
   665   __experimentalFetchUrlData: () => (/* reexport */ _experimental_fetch_url_data),
   567   "__experimentalUseEntityRecord": function() { return /* reexport */ __experimentalUseEntityRecord; },
   666   __experimentalUseEntityRecord: () => (/* reexport */ __experimentalUseEntityRecord),
   568   "__experimentalUseEntityRecords": function() { return /* reexport */ __experimentalUseEntityRecords; },
   667   __experimentalUseEntityRecords: () => (/* reexport */ __experimentalUseEntityRecords),
   569   "store": function() { return /* binding */ store; },
   668   __experimentalUseResourcePermissions: () => (/* reexport */ __experimentalUseResourcePermissions),
   570   "useEntityBlockEditor": function() { return /* reexport */ useEntityBlockEditor; },
   669   fetchBlockPatterns: () => (/* reexport */ fetchBlockPatterns),
   571   "useEntityId": function() { return /* reexport */ useEntityId; },
   670   store: () => (/* binding */ store),
   572   "useEntityProp": function() { return /* reexport */ useEntityProp; }
   671   useEntityBlockEditor: () => (/* reexport */ useEntityBlockEditor),
       
   672   useEntityId: () => (/* reexport */ useEntityId),
       
   673   useEntityProp: () => (/* reexport */ useEntityProp),
       
   674   useEntityRecord: () => (/* reexport */ useEntityRecord),
       
   675   useEntityRecords: () => (/* reexport */ useEntityRecords),
       
   676   useResourcePermissions: () => (/* reexport */ useResourcePermissions)
   573 });
   677 });
   574 
   678 
   575 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/actions.js
   679 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/actions.js
   576 var build_module_actions_namespaceObject = {};
   680 var build_module_actions_namespaceObject = {};
   577 __webpack_require__.r(build_module_actions_namespaceObject);
   681 __webpack_require__.r(build_module_actions_namespaceObject);
   578 __webpack_require__.d(build_module_actions_namespaceObject, {
   682 __webpack_require__.d(build_module_actions_namespaceObject, {
   579   "__experimentalBatch": function() { return __experimentalBatch; },
   683   __experimentalBatch: () => (__experimentalBatch),
   580   "__experimentalReceiveCurrentGlobalStylesId": function() { return __experimentalReceiveCurrentGlobalStylesId; },
   684   __experimentalReceiveCurrentGlobalStylesId: () => (__experimentalReceiveCurrentGlobalStylesId),
   581   "__experimentalReceiveThemeBaseGlobalStyles": function() { return __experimentalReceiveThemeBaseGlobalStyles; },
   685   __experimentalReceiveThemeBaseGlobalStyles: () => (__experimentalReceiveThemeBaseGlobalStyles),
   582   "__experimentalReceiveThemeGlobalStyleVariations": function() { return __experimentalReceiveThemeGlobalStyleVariations; },
   686   __experimentalReceiveThemeGlobalStyleVariations: () => (__experimentalReceiveThemeGlobalStyleVariations),
   583   "__experimentalSaveSpecifiedEntityEdits": function() { return __experimentalSaveSpecifiedEntityEdits; },
   687   __experimentalSaveSpecifiedEntityEdits: () => (__experimentalSaveSpecifiedEntityEdits),
   584   "__unstableCreateUndoLevel": function() { return __unstableCreateUndoLevel; },
   688   __unstableCreateUndoLevel: () => (__unstableCreateUndoLevel),
   585   "addEntities": function() { return addEntities; },
   689   addEntities: () => (addEntities),
   586   "deleteEntityRecord": function() { return deleteEntityRecord; },
   690   deleteEntityRecord: () => (deleteEntityRecord),
   587   "editEntityRecord": function() { return editEntityRecord; },
   691   editEntityRecord: () => (editEntityRecord),
   588   "receiveAutosaves": function() { return receiveAutosaves; },
   692   receiveAutosaves: () => (receiveAutosaves),
   589   "receiveCurrentTheme": function() { return receiveCurrentTheme; },
   693   receiveCurrentTheme: () => (receiveCurrentTheme),
   590   "receiveCurrentUser": function() { return receiveCurrentUser; },
   694   receiveCurrentUser: () => (receiveCurrentUser),
   591   "receiveEmbedPreview": function() { return receiveEmbedPreview; },
   695   receiveDefaultTemplateId: () => (receiveDefaultTemplateId),
   592   "receiveEntityRecords": function() { return receiveEntityRecords; },
   696   receiveEmbedPreview: () => (receiveEmbedPreview),
   593   "receiveThemeSupports": function() { return receiveThemeSupports; },
   697   receiveEntityRecords: () => (receiveEntityRecords),
   594   "receiveUploadPermissions": function() { return receiveUploadPermissions; },
   698   receiveNavigationFallbackId: () => (receiveNavigationFallbackId),
   595   "receiveUserPermission": function() { return receiveUserPermission; },
   699   receiveRevisions: () => (receiveRevisions),
   596   "receiveUserQuery": function() { return receiveUserQuery; },
   700   receiveThemeGlobalStyleRevisions: () => (receiveThemeGlobalStyleRevisions),
   597   "redo": function() { return redo; },
   701   receiveThemeSupports: () => (receiveThemeSupports),
   598   "saveEditedEntityRecord": function() { return saveEditedEntityRecord; },
   702   receiveUploadPermissions: () => (receiveUploadPermissions),
   599   "saveEntityRecord": function() { return saveEntityRecord; },
   703   receiveUserPermission: () => (receiveUserPermission),
   600   "undo": function() { return undo; }
   704   receiveUserQuery: () => (receiveUserQuery),
       
   705   redo: () => (redo),
       
   706   saveEditedEntityRecord: () => (saveEditedEntityRecord),
       
   707   saveEntityRecord: () => (saveEntityRecord),
       
   708   undo: () => (undo)
   601 });
   709 });
   602 
   710 
   603 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/selectors.js
   711 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/selectors.js
   604 var build_module_selectors_namespaceObject = {};
   712 var build_module_selectors_namespaceObject = {};
   605 __webpack_require__.r(build_module_selectors_namespaceObject);
   713 __webpack_require__.r(build_module_selectors_namespaceObject);
   606 __webpack_require__.d(build_module_selectors_namespaceObject, {
   714 __webpack_require__.d(build_module_selectors_namespaceObject, {
   607   "__experimentalGetCurrentGlobalStylesId": function() { return __experimentalGetCurrentGlobalStylesId; },
   715   __experimentalGetCurrentGlobalStylesId: () => (__experimentalGetCurrentGlobalStylesId),
   608   "__experimentalGetCurrentThemeBaseGlobalStyles": function() { return __experimentalGetCurrentThemeBaseGlobalStyles; },
   716   __experimentalGetCurrentThemeBaseGlobalStyles: () => (__experimentalGetCurrentThemeBaseGlobalStyles),
   609   "__experimentalGetCurrentThemeGlobalStylesVariations": function() { return __experimentalGetCurrentThemeGlobalStylesVariations; },
   717   __experimentalGetCurrentThemeGlobalStylesVariations: () => (__experimentalGetCurrentThemeGlobalStylesVariations),
   610   "__experimentalGetDirtyEntityRecords": function() { return __experimentalGetDirtyEntityRecords; },
   718   __experimentalGetDirtyEntityRecords: () => (__experimentalGetDirtyEntityRecords),
   611   "__experimentalGetEntitiesBeingSaved": function() { return __experimentalGetEntitiesBeingSaved; },
   719   __experimentalGetEntitiesBeingSaved: () => (__experimentalGetEntitiesBeingSaved),
   612   "__experimentalGetEntityRecordNoResolver": function() { return __experimentalGetEntityRecordNoResolver; },
   720   __experimentalGetEntityRecordNoResolver: () => (__experimentalGetEntityRecordNoResolver),
   613   "__experimentalGetTemplateForLink": function() { return __experimentalGetTemplateForLink; },
   721   __experimentalGetTemplateForLink: () => (__experimentalGetTemplateForLink),
   614   "canUser": function() { return canUser; },
   722   canUser: () => (canUser),
   615   "canUserEditEntityRecord": function() { return canUserEditEntityRecord; },
   723   canUserEditEntityRecord: () => (canUserEditEntityRecord),
   616   "getAuthors": function() { return getAuthors; },
   724   getAuthors: () => (getAuthors),
   617   "getAutosave": function() { return getAutosave; },
   725   getAutosave: () => (getAutosave),
   618   "getAutosaves": function() { return getAutosaves; },
   726   getAutosaves: () => (getAutosaves),
   619   "getBlockPatternCategories": function() { return getBlockPatternCategories; },
   727   getBlockPatternCategories: () => (getBlockPatternCategories),
   620   "getBlockPatterns": function() { return getBlockPatterns; },
   728   getBlockPatterns: () => (getBlockPatterns),
   621   "getCurrentTheme": function() { return getCurrentTheme; },
   729   getCurrentTheme: () => (getCurrentTheme),
   622   "getCurrentUser": function() { return getCurrentUser; },
   730   getCurrentThemeGlobalStylesRevisions: () => (getCurrentThemeGlobalStylesRevisions),
   623   "getEditedEntityRecord": function() { return getEditedEntityRecord; },
   731   getCurrentUser: () => (getCurrentUser),
   624   "getEmbedPreview": function() { return getEmbedPreview; },
   732   getDefaultTemplateId: () => (getDefaultTemplateId),
   625   "getEntitiesByKind": function() { return getEntitiesByKind; },
   733   getEditedEntityRecord: () => (getEditedEntityRecord),
   626   "getEntitiesConfig": function() { return getEntitiesConfig; },
   734   getEmbedPreview: () => (getEmbedPreview),
   627   "getEntity": function() { return getEntity; },
   735   getEntitiesByKind: () => (getEntitiesByKind),
   628   "getEntityConfig": function() { return getEntityConfig; },
   736   getEntitiesConfig: () => (getEntitiesConfig),
   629   "getEntityRecord": function() { return getEntityRecord; },
   737   getEntity: () => (getEntity),
   630   "getEntityRecordEdits": function() { return getEntityRecordEdits; },
   738   getEntityConfig: () => (getEntityConfig),
   631   "getEntityRecordNonTransientEdits": function() { return getEntityRecordNonTransientEdits; },
   739   getEntityRecord: () => (getEntityRecord),
   632   "getEntityRecords": function() { return getEntityRecords; },
   740   getEntityRecordEdits: () => (getEntityRecordEdits),
   633   "getLastEntityDeleteError": function() { return getLastEntityDeleteError; },
   741   getEntityRecordNonTransientEdits: () => (getEntityRecordNonTransientEdits),
   634   "getLastEntitySaveError": function() { return getLastEntitySaveError; },
   742   getEntityRecords: () => (getEntityRecords),
   635   "getRawEntityRecord": function() { return getRawEntityRecord; },
   743   getEntityRecordsTotalItems: () => (getEntityRecordsTotalItems),
   636   "getRedoEdit": function() { return getRedoEdit; },
   744   getEntityRecordsTotalPages: () => (getEntityRecordsTotalPages),
   637   "getReferenceByDistinctEdits": function() { return getReferenceByDistinctEdits; },
   745   getLastEntityDeleteError: () => (getLastEntityDeleteError),
   638   "getThemeSupports": function() { return getThemeSupports; },
   746   getLastEntitySaveError: () => (getLastEntitySaveError),
   639   "getUndoEdit": function() { return getUndoEdit; },
   747   getRawEntityRecord: () => (getRawEntityRecord),
   640   "getUserQueryResults": function() { return getUserQueryResults; },
   748   getRedoEdit: () => (getRedoEdit),
   641   "hasEditsForEntityRecord": function() { return hasEditsForEntityRecord; },
   749   getReferenceByDistinctEdits: () => (getReferenceByDistinctEdits),
   642   "hasEntityRecords": function() { return hasEntityRecords; },
   750   getRevision: () => (getRevision),
   643   "hasFetchedAutosaves": function() { return hasFetchedAutosaves; },
   751   getRevisions: () => (getRevisions),
   644   "hasRedo": function() { return hasRedo; },
   752   getThemeSupports: () => (getThemeSupports),
   645   "hasUndo": function() { return hasUndo; },
   753   getUndoEdit: () => (getUndoEdit),
   646   "isAutosavingEntityRecord": function() { return isAutosavingEntityRecord; },
   754   getUserPatternCategories: () => (getUserPatternCategories),
   647   "isDeletingEntityRecord": function() { return isDeletingEntityRecord; },
   755   getUserQueryResults: () => (getUserQueryResults),
   648   "isPreviewEmbedFallback": function() { return isPreviewEmbedFallback; },
   756   hasEditsForEntityRecord: () => (hasEditsForEntityRecord),
   649   "isRequestingEmbedPreview": function() { return isRequestingEmbedPreview; },
   757   hasEntityRecords: () => (hasEntityRecords),
   650   "isSavingEntityRecord": function() { return isSavingEntityRecord; }
   758   hasFetchedAutosaves: () => (hasFetchedAutosaves),
       
   759   hasRedo: () => (hasRedo),
       
   760   hasUndo: () => (hasUndo),
       
   761   isAutosavingEntityRecord: () => (isAutosavingEntityRecord),
       
   762   isDeletingEntityRecord: () => (isDeletingEntityRecord),
       
   763   isPreviewEmbedFallback: () => (isPreviewEmbedFallback),
       
   764   isRequestingEmbedPreview: () => (isRequestingEmbedPreview),
       
   765   isSavingEntityRecord: () => (isSavingEntityRecord)
       
   766 });
       
   767 
       
   768 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/private-selectors.js
       
   769 var private_selectors_namespaceObject = {};
       
   770 __webpack_require__.r(private_selectors_namespaceObject);
       
   771 __webpack_require__.d(private_selectors_namespaceObject, {
       
   772   getBlockPatternsForPostType: () => (getBlockPatternsForPostType),
       
   773   getNavigationFallbackId: () => (getNavigationFallbackId),
       
   774   getUndoManager: () => (getUndoManager)
   651 });
   775 });
   652 
   776 
   653 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/resolvers.js
   777 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/resolvers.js
   654 var resolvers_namespaceObject = {};
   778 var resolvers_namespaceObject = {};
   655 __webpack_require__.r(resolvers_namespaceObject);
   779 __webpack_require__.r(resolvers_namespaceObject);
   656 __webpack_require__.d(resolvers_namespaceObject, {
   780 __webpack_require__.d(resolvers_namespaceObject, {
   657   "__experimentalGetCurrentGlobalStylesId": function() { return resolvers_experimentalGetCurrentGlobalStylesId; },
   781   __experimentalGetCurrentGlobalStylesId: () => (resolvers_experimentalGetCurrentGlobalStylesId),
   658   "__experimentalGetCurrentThemeBaseGlobalStyles": function() { return resolvers_experimentalGetCurrentThemeBaseGlobalStyles; },
   782   __experimentalGetCurrentThemeBaseGlobalStyles: () => (resolvers_experimentalGetCurrentThemeBaseGlobalStyles),
   659   "__experimentalGetCurrentThemeGlobalStylesVariations": function() { return resolvers_experimentalGetCurrentThemeGlobalStylesVariations; },
   783   __experimentalGetCurrentThemeGlobalStylesVariations: () => (resolvers_experimentalGetCurrentThemeGlobalStylesVariations),
   660   "__experimentalGetTemplateForLink": function() { return resolvers_experimentalGetTemplateForLink; },
   784   __experimentalGetTemplateForLink: () => (resolvers_experimentalGetTemplateForLink),
   661   "canUser": function() { return resolvers_canUser; },
   785   canUser: () => (resolvers_canUser),
   662   "canUserEditEntityRecord": function() { return resolvers_canUserEditEntityRecord; },
   786   canUserEditEntityRecord: () => (resolvers_canUserEditEntityRecord),
   663   "getAuthors": function() { return resolvers_getAuthors; },
   787   getAuthors: () => (resolvers_getAuthors),
   664   "getAutosave": function() { return resolvers_getAutosave; },
   788   getAutosave: () => (resolvers_getAutosave),
   665   "getAutosaves": function() { return resolvers_getAutosaves; },
   789   getAutosaves: () => (resolvers_getAutosaves),
   666   "getBlockPatternCategories": function() { return resolvers_getBlockPatternCategories; },
   790   getBlockPatternCategories: () => (resolvers_getBlockPatternCategories),
   667   "getBlockPatterns": function() { return resolvers_getBlockPatterns; },
   791   getBlockPatterns: () => (resolvers_getBlockPatterns),
   668   "getCurrentTheme": function() { return resolvers_getCurrentTheme; },
   792   getCurrentTheme: () => (resolvers_getCurrentTheme),
   669   "getCurrentUser": function() { return resolvers_getCurrentUser; },
   793   getCurrentThemeGlobalStylesRevisions: () => (resolvers_getCurrentThemeGlobalStylesRevisions),
   670   "getEditedEntityRecord": function() { return resolvers_getEditedEntityRecord; },
   794   getCurrentUser: () => (resolvers_getCurrentUser),
   671   "getEmbedPreview": function() { return resolvers_getEmbedPreview; },
   795   getDefaultTemplateId: () => (resolvers_getDefaultTemplateId),
   672   "getEntityRecord": function() { return resolvers_getEntityRecord; },
   796   getEditedEntityRecord: () => (resolvers_getEditedEntityRecord),
   673   "getEntityRecords": function() { return resolvers_getEntityRecords; },
   797   getEmbedPreview: () => (resolvers_getEmbedPreview),
   674   "getRawEntityRecord": function() { return resolvers_getRawEntityRecord; },
   798   getEntityRecord: () => (resolvers_getEntityRecord),
   675   "getThemeSupports": function() { return resolvers_getThemeSupports; }
   799   getEntityRecords: () => (resolvers_getEntityRecords),
       
   800   getNavigationFallbackId: () => (resolvers_getNavigationFallbackId),
       
   801   getRawEntityRecord: () => (resolvers_getRawEntityRecord),
       
   802   getRevision: () => (resolvers_getRevision),
       
   803   getRevisions: () => (resolvers_getRevisions),
       
   804   getThemeSupports: () => (resolvers_getThemeSupports),
       
   805   getUserPatternCategories: () => (resolvers_getUserPatternCategories)
   676 });
   806 });
   677 
   807 
   678 ;// CONCATENATED MODULE: external ["wp","data"]
   808 ;// CONCATENATED MODULE: external ["wp","data"]
   679 var external_wp_data_namespaceObject = window["wp"]["data"];
   809 const external_wp_data_namespaceObject = window["wp"]["data"];
   680 ;// CONCATENATED MODULE: external "lodash"
   810 // EXTERNAL MODULE: ./node_modules/fast-deep-equal/es6/index.js
   681 var external_lodash_namespaceObject = window["lodash"];
   811 var es6 = __webpack_require__(7734);
   682 ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
   812 var es6_default = /*#__PURE__*/__webpack_require__.n(es6);
   683 var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
   813 ;// CONCATENATED MODULE: external ["wp","compose"]
   684 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
   814 const external_wp_compose_namespaceObject = window["wp"]["compose"];
       
   815 // EXTERNAL MODULE: ./node_modules/@wordpress/undo-manager/build-module/index.js
       
   816 var build_module = __webpack_require__(6689);
   685 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/if-matching-action.js
   817 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/if-matching-action.js
   686 /** @typedef {import('../types').AnyFunction} AnyFunction */
   818 /** @typedef {import('../types').AnyFunction} AnyFunction */
   687 
   819 
   688 /**
   820 /**
   689  * A higher-order reducer creator which invokes the original reducer only if
   821  * A higher-order reducer creator which invokes the original reducer only if
   696  */
   828  */
   697 const ifMatchingAction = isMatch => reducer => (state, action) => {
   829 const ifMatchingAction = isMatch => reducer => (state, action) => {
   698   if (state === undefined || isMatch(action)) {
   830   if (state === undefined || isMatch(action)) {
   699     return reducer(state, action);
   831     return reducer(state, action);
   700   }
   832   }
   701 
       
   702   return state;
   833   return state;
   703 };
   834 };
   704 
   835 /* harmony default export */ const if_matching_action = (ifMatchingAction);
   705 /* harmony default export */ var if_matching_action = (ifMatchingAction);
       
   706 
   836 
   707 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/replace-action.js
   837 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/replace-action.js
   708 /** @typedef {import('../types').AnyFunction} AnyFunction */
   838 /** @typedef {import('../types').AnyFunction} AnyFunction */
   709 
   839 
   710 /**
   840 /**
   716  * @return {AnyFunction} Higher-order reducer.
   846  * @return {AnyFunction} Higher-order reducer.
   717  */
   847  */
   718 const replaceAction = replacer => reducer => (state, action) => {
   848 const replaceAction = replacer => reducer => (state, action) => {
   719   return reducer(state, replacer(action));
   849   return reducer(state, replacer(action));
   720 };
   850 };
   721 
   851 /* harmony default export */ const replace_action = (replaceAction);
   722 /* harmony default export */ var replace_action = (replaceAction);
       
   723 
   852 
   724 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/conservative-map-item.js
   853 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/conservative-map-item.js
   725 /**
   854 /**
   726  * External dependencies
   855  * External dependencies
   727  */
   856  */
       
   857 
   728 
   858 
   729 /**
   859 /**
   730  * Given the current and next item entity record, returns the minimally "modified"
   860  * Given the current and next item entity record, returns the minimally "modified"
   731  * result of the next item, preferring value references from the original item
   861  * result of the next item, preferring value references from the original item
   732  * if equal. If all values match, the original item is returned.
   862  * if equal. If all values match, the original item is returned.
   734  * @param {Object} item     Original item.
   864  * @param {Object} item     Original item.
   735  * @param {Object} nextItem Next item.
   865  * @param {Object} nextItem Next item.
   736  *
   866  *
   737  * @return {Object} Minimally modified merged item.
   867  * @return {Object} Minimally modified merged item.
   738  */
   868  */
   739 
       
   740 function conservativeMapItem(item, nextItem) {
   869 function conservativeMapItem(item, nextItem) {
   741   // Return next item in its entirety if there is no original item.
   870   // Return next item in its entirety if there is no original item.
   742   if (!item) {
   871   if (!item) {
   743     return nextItem;
   872     return nextItem;
   744   }
   873   }
   745 
       
   746   let hasChanges = false;
   874   let hasChanges = false;
   747   const result = {};
   875   const result = {};
   748 
       
   749   for (const key in nextItem) {
   876   for (const key in nextItem) {
   750     if ((0,external_lodash_namespaceObject.isEqual)(item[key], nextItem[key])) {
   877     if (es6_default()(item[key], nextItem[key])) {
   751       result[key] = item[key];
   878       result[key] = item[key];
   752     } else {
   879     } else {
   753       hasChanges = true;
   880       hasChanges = true;
   754       result[key] = nextItem[key];
   881       result[key] = nextItem[key];
   755     }
   882     }
   756   }
   883   }
   757 
       
   758   if (!hasChanges) {
   884   if (!hasChanges) {
   759     return item;
   885     return item;
   760   } // Only at this point, backfill properties from the original item which
   886   }
       
   887 
       
   888   // Only at this point, backfill properties from the original item which
   761   // weren't explicitly set into the result above. This is an optimization
   889   // weren't explicitly set into the result above. This is an optimization
   762   // to allow `hasChanges` to return early.
   890   // to allow `hasChanges` to return early.
   763 
       
   764 
       
   765   for (const key in item) {
   891   for (const key in item) {
   766     if (!result.hasOwnProperty(key)) {
   892     if (!result.hasOwnProperty(key)) {
   767       result[key] = item[key];
   893       result[key] = item[key];
   768     }
   894     }
   769   }
   895   }
   770 
       
   771   return result;
   896   return result;
   772 }
   897 }
   773 
   898 
   774 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/on-sub-key.js
   899 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/on-sub-key.js
   775 /** @typedef {import('../types').AnyFunction} AnyFunction */
   900 /** @typedef {import('../types').AnyFunction} AnyFunction */
   780  *
   905  *
   781  * @param {string} actionProperty Action property by which to key object.
   906  * @param {string} actionProperty Action property by which to key object.
   782  *
   907  *
   783  * @return {AnyFunction} Higher-order reducer.
   908  * @return {AnyFunction} Higher-order reducer.
   784  */
   909  */
   785 const onSubKey = actionProperty => reducer => function () {
   910 const onSubKey = actionProperty => reducer => (state = {}, action) => {
   786   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
   787   let action = arguments.length > 1 ? arguments[1] : undefined;
       
   788   // Retrieve subkey from action. Do not track if undefined; useful for cases
   911   // Retrieve subkey from action. Do not track if undefined; useful for cases
   789   // where reducer is scoped by action shape.
   912   // where reducer is scoped by action shape.
   790   const key = action[actionProperty];
   913   const key = action[actionProperty];
   791 
       
   792   if (key === undefined) {
   914   if (key === undefined) {
   793     return state;
   915     return state;
   794   } // Avoid updating state if unchanged. Note that this also accounts for a
   916   }
       
   917 
       
   918   // Avoid updating state if unchanged. Note that this also accounts for a
   795   // reducer which returns undefined on a key which is not yet tracked.
   919   // reducer which returns undefined on a key which is not yet tracked.
   796 
       
   797 
       
   798   const nextKeyState = reducer(state[key], action);
   920   const nextKeyState = reducer(state[key], action);
   799 
       
   800   if (nextKeyState === state[key]) {
   921   if (nextKeyState === state[key]) {
   801     return state;
   922     return state;
   802   }
   923   }
   803 
   924   return {
   804   return { ...state,
   925     ...state,
   805     [key]: nextKeyState
   926     [key]: nextKeyState
   806   };
   927   };
   807 };
   928 };
   808 /* harmony default export */ var on_sub_key = (onSubKey);
   929 /* harmony default export */ const on_sub_key = (onSubKey);
       
   930 
       
   931 ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
       
   932 /******************************************************************************
       
   933 Copyright (c) Microsoft Corporation.
       
   934 
       
   935 Permission to use, copy, modify, and/or distribute this software for any
       
   936 purpose with or without fee is hereby granted.
       
   937 
       
   938 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
       
   939 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
       
   940 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
       
   941 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
       
   942 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
       
   943 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
       
   944 PERFORMANCE OF THIS SOFTWARE.
       
   945 ***************************************************************************** */
       
   946 /* global Reflect, Promise, SuppressedError, Symbol */
       
   947 
       
   948 var extendStatics = function(d, b) {
       
   949   extendStatics = Object.setPrototypeOf ||
       
   950       ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
       
   951       function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
       
   952   return extendStatics(d, b);
       
   953 };
       
   954 
       
   955 function __extends(d, b) {
       
   956   if (typeof b !== "function" && b !== null)
       
   957       throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
       
   958   extendStatics(d, b);
       
   959   function __() { this.constructor = d; }
       
   960   d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
       
   961 }
       
   962 
       
   963 var __assign = function() {
       
   964   __assign = Object.assign || function __assign(t) {
       
   965       for (var s, i = 1, n = arguments.length; i < n; i++) {
       
   966           s = arguments[i];
       
   967           for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
       
   968       }
       
   969       return t;
       
   970   }
       
   971   return __assign.apply(this, arguments);
       
   972 }
       
   973 
       
   974 function __rest(s, e) {
       
   975   var t = {};
       
   976   for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
       
   977       t[p] = s[p];
       
   978   if (s != null && typeof Object.getOwnPropertySymbols === "function")
       
   979       for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
       
   980           if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
       
   981               t[p[i]] = s[p[i]];
       
   982       }
       
   983   return t;
       
   984 }
       
   985 
       
   986 function __decorate(decorators, target, key, desc) {
       
   987   var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
       
   988   if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
       
   989   else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
       
   990   return c > 3 && r && Object.defineProperty(target, key, r), r;
       
   991 }
       
   992 
       
   993 function __param(paramIndex, decorator) {
       
   994   return function (target, key) { decorator(target, key, paramIndex); }
       
   995 }
       
   996 
       
   997 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
       
   998   function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
       
   999   var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
       
  1000   var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
       
  1001   var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
       
  1002   var _, done = false;
       
  1003   for (var i = decorators.length - 1; i >= 0; i--) {
       
  1004       var context = {};
       
  1005       for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
       
  1006       for (var p in contextIn.access) context.access[p] = contextIn.access[p];
       
  1007       context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
       
  1008       var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
       
  1009       if (kind === "accessor") {
       
  1010           if (result === void 0) continue;
       
  1011           if (result === null || typeof result !== "object") throw new TypeError("Object expected");
       
  1012           if (_ = accept(result.get)) descriptor.get = _;
       
  1013           if (_ = accept(result.set)) descriptor.set = _;
       
  1014           if (_ = accept(result.init)) initializers.unshift(_);
       
  1015       }
       
  1016       else if (_ = accept(result)) {
       
  1017           if (kind === "field") initializers.unshift(_);
       
  1018           else descriptor[key] = _;
       
  1019       }
       
  1020   }
       
  1021   if (target) Object.defineProperty(target, contextIn.name, descriptor);
       
  1022   done = true;
       
  1023 };
       
  1024 
       
  1025 function __runInitializers(thisArg, initializers, value) {
       
  1026   var useValue = arguments.length > 2;
       
  1027   for (var i = 0; i < initializers.length; i++) {
       
  1028       value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
       
  1029   }
       
  1030   return useValue ? value : void 0;
       
  1031 };
       
  1032 
       
  1033 function __propKey(x) {
       
  1034   return typeof x === "symbol" ? x : "".concat(x);
       
  1035 };
       
  1036 
       
  1037 function __setFunctionName(f, name, prefix) {
       
  1038   if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
       
  1039   return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
       
  1040 };
       
  1041 
       
  1042 function __metadata(metadataKey, metadataValue) {
       
  1043   if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
       
  1044 }
       
  1045 
       
  1046 function __awaiter(thisArg, _arguments, P, generator) {
       
  1047   function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
       
  1048   return new (P || (P = Promise))(function (resolve, reject) {
       
  1049       function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
       
  1050       function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
       
  1051       function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
       
  1052       step((generator = generator.apply(thisArg, _arguments || [])).next());
       
  1053   });
       
  1054 }
       
  1055 
       
  1056 function __generator(thisArg, body) {
       
  1057   var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
       
  1058   return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
       
  1059   function verb(n) { return function (v) { return step([n, v]); }; }
       
  1060   function step(op) {
       
  1061       if (f) throw new TypeError("Generator is already executing.");
       
  1062       while (g && (g = 0, op[0] && (_ = 0)), _) try {
       
  1063           if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
       
  1064           if (y = 0, t) op = [op[0] & 2, t.value];
       
  1065           switch (op[0]) {
       
  1066               case 0: case 1: t = op; break;
       
  1067               case 4: _.label++; return { value: op[1], done: false };
       
  1068               case 5: _.label++; y = op[1]; op = [0]; continue;
       
  1069               case 7: op = _.ops.pop(); _.trys.pop(); continue;
       
  1070               default:
       
  1071                   if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
       
  1072                   if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
       
  1073                   if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
       
  1074                   if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
       
  1075                   if (t[2]) _.ops.pop();
       
  1076                   _.trys.pop(); continue;
       
  1077           }
       
  1078           op = body.call(thisArg, _);
       
  1079       } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
       
  1080       if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
       
  1081   }
       
  1082 }
       
  1083 
       
  1084 var __createBinding = Object.create ? (function(o, m, k, k2) {
       
  1085   if (k2 === undefined) k2 = k;
       
  1086   var desc = Object.getOwnPropertyDescriptor(m, k);
       
  1087   if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
       
  1088       desc = { enumerable: true, get: function() { return m[k]; } };
       
  1089   }
       
  1090   Object.defineProperty(o, k2, desc);
       
  1091 }) : (function(o, m, k, k2) {
       
  1092   if (k2 === undefined) k2 = k;
       
  1093   o[k2] = m[k];
       
  1094 });
       
  1095 
       
  1096 function __exportStar(m, o) {
       
  1097   for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
       
  1098 }
       
  1099 
       
  1100 function __values(o) {
       
  1101   var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
       
  1102   if (m) return m.call(o);
       
  1103   if (o && typeof o.length === "number") return {
       
  1104       next: function () {
       
  1105           if (o && i >= o.length) o = void 0;
       
  1106           return { value: o && o[i++], done: !o };
       
  1107       }
       
  1108   };
       
  1109   throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
       
  1110 }
       
  1111 
       
  1112 function __read(o, n) {
       
  1113   var m = typeof Symbol === "function" && o[Symbol.iterator];
       
  1114   if (!m) return o;
       
  1115   var i = m.call(o), r, ar = [], e;
       
  1116   try {
       
  1117       while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
       
  1118   }
       
  1119   catch (error) { e = { error: error }; }
       
  1120   finally {
       
  1121       try {
       
  1122           if (r && !r.done && (m = i["return"])) m.call(i);
       
  1123       }
       
  1124       finally { if (e) throw e.error; }
       
  1125   }
       
  1126   return ar;
       
  1127 }
       
  1128 
       
  1129 /** @deprecated */
       
  1130 function __spread() {
       
  1131   for (var ar = [], i = 0; i < arguments.length; i++)
       
  1132       ar = ar.concat(__read(arguments[i]));
       
  1133   return ar;
       
  1134 }
       
  1135 
       
  1136 /** @deprecated */
       
  1137 function __spreadArrays() {
       
  1138   for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
       
  1139   for (var r = Array(s), k = 0, i = 0; i < il; i++)
       
  1140       for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
       
  1141           r[k] = a[j];
       
  1142   return r;
       
  1143 }
       
  1144 
       
  1145 function __spreadArray(to, from, pack) {
       
  1146   if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
       
  1147       if (ar || !(i in from)) {
       
  1148           if (!ar) ar = Array.prototype.slice.call(from, 0, i);
       
  1149           ar[i] = from[i];
       
  1150       }
       
  1151   }
       
  1152   return to.concat(ar || Array.prototype.slice.call(from));
       
  1153 }
       
  1154 
       
  1155 function __await(v) {
       
  1156   return this instanceof __await ? (this.v = v, this) : new __await(v);
       
  1157 }
       
  1158 
       
  1159 function __asyncGenerator(thisArg, _arguments, generator) {
       
  1160   if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
       
  1161   var g = generator.apply(thisArg, _arguments || []), i, q = [];
       
  1162   return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
       
  1163   function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
       
  1164   function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
       
  1165   function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
       
  1166   function fulfill(value) { resume("next", value); }
       
  1167   function reject(value) { resume("throw", value); }
       
  1168   function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
       
  1169 }
       
  1170 
       
  1171 function __asyncDelegator(o) {
       
  1172   var i, p;
       
  1173   return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
       
  1174   function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
       
  1175 }
       
  1176 
       
  1177 function __asyncValues(o) {
       
  1178   if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
       
  1179   var m = o[Symbol.asyncIterator], i;
       
  1180   return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
       
  1181   function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
       
  1182   function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
       
  1183 }
       
  1184 
       
  1185 function __makeTemplateObject(cooked, raw) {
       
  1186   if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
       
  1187   return cooked;
       
  1188 };
       
  1189 
       
  1190 var __setModuleDefault = Object.create ? (function(o, v) {
       
  1191   Object.defineProperty(o, "default", { enumerable: true, value: v });
       
  1192 }) : function(o, v) {
       
  1193   o["default"] = v;
       
  1194 };
       
  1195 
       
  1196 function __importStar(mod) {
       
  1197   if (mod && mod.__esModule) return mod;
       
  1198   var result = {};
       
  1199   if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
       
  1200   __setModuleDefault(result, mod);
       
  1201   return result;
       
  1202 }
       
  1203 
       
  1204 function __importDefault(mod) {
       
  1205   return (mod && mod.__esModule) ? mod : { default: mod };
       
  1206 }
       
  1207 
       
  1208 function __classPrivateFieldGet(receiver, state, kind, f) {
       
  1209   if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
       
  1210   if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
       
  1211   return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
       
  1212 }
       
  1213 
       
  1214 function __classPrivateFieldSet(receiver, state, value, kind, f) {
       
  1215   if (kind === "m") throw new TypeError("Private method is not writable");
       
  1216   if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
       
  1217   if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
       
  1218   return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
       
  1219 }
       
  1220 
       
  1221 function __classPrivateFieldIn(state, receiver) {
       
  1222   if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
       
  1223   return typeof state === "function" ? receiver === state : state.has(receiver);
       
  1224 }
       
  1225 
       
  1226 function __addDisposableResource(env, value, async) {
       
  1227   if (value !== null && value !== void 0) {
       
  1228     if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
       
  1229     var dispose;
       
  1230     if (async) {
       
  1231         if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
       
  1232         dispose = value[Symbol.asyncDispose];
       
  1233     }
       
  1234     if (dispose === void 0) {
       
  1235         if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
       
  1236         dispose = value[Symbol.dispose];
       
  1237     }
       
  1238     if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
       
  1239     env.stack.push({ value: value, dispose: dispose, async: async });
       
  1240   }
       
  1241   else if (async) {
       
  1242     env.stack.push({ async: true });
       
  1243   }
       
  1244   return value;
       
  1245 }
       
  1246 
       
  1247 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
       
  1248   var e = new Error(message);
       
  1249   return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
       
  1250 };
       
  1251 
       
  1252 function __disposeResources(env) {
       
  1253   function fail(e) {
       
  1254     env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
       
  1255     env.hasError = true;
       
  1256   }
       
  1257   function next() {
       
  1258     while (env.stack.length) {
       
  1259       var rec = env.stack.pop();
       
  1260       try {
       
  1261         var result = rec.dispose && rec.dispose.call(rec.value);
       
  1262         if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
       
  1263       }
       
  1264       catch (e) {
       
  1265           fail(e);
       
  1266       }
       
  1267     }
       
  1268     if (env.hasError) throw env.error;
       
  1269   }
       
  1270   return next();
       
  1271 }
       
  1272 
       
  1273 /* harmony default export */ const tslib_es6 = ({
       
  1274   __extends,
       
  1275   __assign,
       
  1276   __rest,
       
  1277   __decorate,
       
  1278   __param,
       
  1279   __metadata,
       
  1280   __awaiter,
       
  1281   __generator,
       
  1282   __createBinding,
       
  1283   __exportStar,
       
  1284   __values,
       
  1285   __read,
       
  1286   __spread,
       
  1287   __spreadArrays,
       
  1288   __spreadArray,
       
  1289   __await,
       
  1290   __asyncGenerator,
       
  1291   __asyncDelegator,
       
  1292   __asyncValues,
       
  1293   __makeTemplateObject,
       
  1294   __importStar,
       
  1295   __importDefault,
       
  1296   __classPrivateFieldGet,
       
  1297   __classPrivateFieldSet,
       
  1298   __classPrivateFieldIn,
       
  1299   __addDisposableResource,
       
  1300   __disposeResources,
       
  1301 });
       
  1302 
       
  1303 ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
       
  1304 /**
       
  1305  * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
       
  1306  */
       
  1307 var SUPPORTED_LOCALE = {
       
  1308     tr: {
       
  1309         regexp: /\u0130|\u0049|\u0049\u0307/g,
       
  1310         map: {
       
  1311             İ: "\u0069",
       
  1312             I: "\u0131",
       
  1313             İ: "\u0069",
       
  1314         },
       
  1315     },
       
  1316     az: {
       
  1317         regexp: /\u0130/g,
       
  1318         map: {
       
  1319             İ: "\u0069",
       
  1320             I: "\u0131",
       
  1321             İ: "\u0069",
       
  1322         },
       
  1323     },
       
  1324     lt: {
       
  1325         regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
       
  1326         map: {
       
  1327             I: "\u0069\u0307",
       
  1328             J: "\u006A\u0307",
       
  1329             Į: "\u012F\u0307",
       
  1330             Ì: "\u0069\u0307\u0300",
       
  1331             Í: "\u0069\u0307\u0301",
       
  1332             Ĩ: "\u0069\u0307\u0303",
       
  1333         },
       
  1334     },
       
  1335 };
       
  1336 /**
       
  1337  * Localized lower case.
       
  1338  */
       
  1339 function localeLowerCase(str, locale) {
       
  1340     var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
       
  1341     if (lang)
       
  1342         return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
       
  1343     return lowerCase(str);
       
  1344 }
       
  1345 /**
       
  1346  * Lower case as a function.
       
  1347  */
       
  1348 function lowerCase(str) {
       
  1349     return str.toLowerCase();
       
  1350 }
       
  1351 
       
  1352 ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
       
  1353 
       
  1354 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
       
  1355 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
       
  1356 // Remove all non-word characters.
       
  1357 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
       
  1358 /**
       
  1359  * Normalize the string into something other libraries can manipulate easier.
       
  1360  */
       
  1361 function noCase(input, options) {
       
  1362     if (options === void 0) { options = {}; }
       
  1363     var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
       
  1364     var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
       
  1365     var start = 0;
       
  1366     var end = result.length;
       
  1367     // Trim the delimiter from around the output string.
       
  1368     while (result.charAt(start) === "\0")
       
  1369         start++;
       
  1370     while (result.charAt(end - 1) === "\0")
       
  1371         end--;
       
  1372     // Transform each token independently.
       
  1373     return result.slice(start, end).split("\0").map(transform).join(delimiter);
       
  1374 }
       
  1375 /**
       
  1376  * Replace `re` in the input string with the replacement value.
       
  1377  */
       
  1378 function replace(input, re, value) {
       
  1379     if (re instanceof RegExp)
       
  1380         return input.replace(re, value);
       
  1381     return re.reduce(function (input, re) { return input.replace(re, value); }, input);
       
  1382 }
       
  1383 
       
  1384 ;// CONCATENATED MODULE: ./node_modules/upper-case-first/dist.es2015/index.js
       
  1385 /**
       
  1386  * Upper case the first character of an input string.
       
  1387  */
       
  1388 function upperCaseFirst(input) {
       
  1389     return input.charAt(0).toUpperCase() + input.substr(1);
       
  1390 }
       
  1391 
       
  1392 ;// CONCATENATED MODULE: ./node_modules/capital-case/dist.es2015/index.js
       
  1393 
       
  1394 
       
  1395 
       
  1396 function capitalCaseTransform(input) {
       
  1397     return upperCaseFirst(input.toLowerCase());
       
  1398 }
       
  1399 function capitalCase(input, options) {
       
  1400     if (options === void 0) { options = {}; }
       
  1401     return noCase(input, __assign({ delimiter: " ", transform: capitalCaseTransform }, options));
       
  1402 }
       
  1403 
       
  1404 ;// CONCATENATED MODULE: ./node_modules/pascal-case/dist.es2015/index.js
       
  1405 
       
  1406 
       
  1407 function pascalCaseTransform(input, index) {
       
  1408     var firstChar = input.charAt(0);
       
  1409     var lowerChars = input.substr(1).toLowerCase();
       
  1410     if (index > 0 && firstChar >= "0" && firstChar <= "9") {
       
  1411         return "_" + firstChar + lowerChars;
       
  1412     }
       
  1413     return "" + firstChar.toUpperCase() + lowerChars;
       
  1414 }
       
  1415 function dist_es2015_pascalCaseTransformMerge(input) {
       
  1416     return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
       
  1417 }
       
  1418 function pascalCase(input, options) {
       
  1419     if (options === void 0) { options = {}; }
       
  1420     return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
       
  1421 }
   809 
  1422 
   810 ;// CONCATENATED MODULE: external ["wp","apiFetch"]
  1423 ;// CONCATENATED MODULE: external ["wp","apiFetch"]
   811 var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
  1424 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
   812 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
  1425 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
   813 ;// CONCATENATED MODULE: external ["wp","i18n"]
  1426 ;// CONCATENATED MODULE: external ["wp","i18n"]
   814 var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  1427 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
       
  1428 ;// CONCATENATED MODULE: external ["wp","richText"]
       
  1429 const external_wp_richText_namespaceObject = window["wp"]["richText"];
       
  1430 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/native.js
       
  1431 const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
       
  1432 /* harmony default export */ const esm_browser_native = ({
       
  1433   randomUUID
       
  1434 });
   815 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
  1435 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
   816 // Unique ID creation requires a high quality random # generator. In the browser we therefore
  1436 // Unique ID creation requires a high quality random # generator. In the browser we therefore
   817 // require the crypto API and do not support built-in fallback to lower quality random number
  1437 // require the crypto API and do not support built-in fallback to lower quality random number
   818 // generators (like Math.random()).
  1438 // generators (like Math.random()).
   819 var getRandomValues;
  1439 let getRandomValues;
   820 var rnds8 = new Uint8Array(16);
  1440 const rnds8 = new Uint8Array(16);
   821 function rng() {
  1441 function rng() {
   822   // lazy load so that environments that need to polyfill have a chance to do so
  1442   // lazy load so that environments that need to polyfill have a chance to do so
   823   if (!getRandomValues) {
  1443   if (!getRandomValues) {
   824     // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
  1444     // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
   825     // find the complete implementation of crypto (msCrypto) on IE11.
  1445     getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
   826     getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
       
   827 
  1446 
   828     if (!getRandomValues) {
  1447     if (!getRandomValues) {
   829       throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
  1448       throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
   830     }
  1449     }
   831   }
  1450   }
   832 
  1451 
   833   return getRandomValues(rnds8);
  1452   return getRandomValues(rnds8);
   834 }
  1453 }
   835 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js
       
   836 /* 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);
       
   837 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js
       
   838 
       
   839 
       
   840 function validate(uuid) {
       
   841   return typeof uuid === 'string' && regex.test(uuid);
       
   842 }
       
   843 
       
   844 /* harmony default export */ var esm_browser_validate = (validate);
       
   845 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
  1454 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
   846 
  1455 
   847 /**
  1456 /**
   848  * Convert array of 16 byte values to UUID string format of the form:
  1457  * Convert array of 16 byte values to UUID string format of the form:
   849  * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  1458  * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
   850  */
  1459  */
   851 
  1460 
   852 var byteToHex = [];
  1461 const byteToHex = [];
   853 
  1462 
   854 for (var i = 0; i < 256; ++i) {
  1463 for (let i = 0; i < 256; ++i) {
   855   byteToHex.push((i + 0x100).toString(16).substr(1));
  1464   byteToHex.push((i + 0x100).toString(16).slice(1));
   856 }
  1465 }
   857 
  1466 
   858 function stringify(arr) {
  1467 function unsafeStringify(arr, offset = 0) {
   859   var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
       
   860   // Note: Be careful editing this code!  It's been tuned for performance
  1468   // Note: Be careful editing this code!  It's been tuned for performance
   861   // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
  1469   // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
   862   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
  1470   return 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]];
       
  1471 }
       
  1472 
       
  1473 function stringify(arr, offset = 0) {
       
  1474   const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID.  If this throws, it's likely due to one
   863   // of the following:
  1475   // of the following:
   864   // - One or more input array values don't map to a hex octet (leading to
  1476   // - One or more input array values don't map to a hex octet (leading to
   865   // "undefined" in the uuid)
  1477   // "undefined" in the uuid)
   866   // - Invalid input values for the RFC `version` or `variant` fields
  1478   // - Invalid input values for the RFC `version` or `variant` fields
   867 
  1479 
   868   if (!esm_browser_validate(uuid)) {
  1480   if (!validate(uuid)) {
   869     throw TypeError('Stringified UUID is invalid');
  1481     throw TypeError('Stringified UUID is invalid');
   870   }
  1482   }
   871 
  1483 
   872   return uuid;
  1484   return uuid;
   873 }
  1485 }
   874 
  1486 
   875 /* harmony default export */ var esm_browser_stringify = (stringify);
  1487 /* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify)));
   876 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
  1488 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
   877 
  1489 
   878 
  1490 
   879 
  1491 
       
  1492 
   880 function v4(options, buf, offset) {
  1493 function v4(options, buf, offset) {
       
  1494   if (esm_browser_native.randomUUID && !buf && !options) {
       
  1495     return esm_browser_native.randomUUID();
       
  1496   }
       
  1497 
   881   options = options || {};
  1498   options = options || {};
   882   var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  1499   const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
   883 
  1500 
   884   rnds[6] = rnds[6] & 0x0f | 0x40;
  1501   rnds[6] = rnds[6] & 0x0f | 0x40;
   885   rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
  1502   rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
   886 
  1503 
   887   if (buf) {
  1504   if (buf) {
   888     offset = offset || 0;
  1505     offset = offset || 0;
   889 
  1506 
   890     for (var i = 0; i < 16; ++i) {
  1507     for (let i = 0; i < 16; ++i) {
   891       buf[offset + i] = rnds[i];
  1508       buf[offset + i] = rnds[i];
   892     }
  1509     }
   893 
  1510 
   894     return buf;
  1511     return buf;
   895   }
  1512   }
   896 
  1513 
   897   return esm_browser_stringify(rnds);
  1514   return unsafeStringify(rnds);
   898 }
  1515 }
   899 
  1516 
   900 /* harmony default export */ var esm_browser_v4 = (v4);
  1517 /* harmony default export */ const esm_browser_v4 = (v4);
   901 ;// CONCATENATED MODULE: external ["wp","url"]
  1518 ;// CONCATENATED MODULE: external ["wp","url"]
   902 var external_wp_url_namespaceObject = window["wp"]["url"];
  1519 const external_wp_url_namespaceObject = window["wp"]["url"];
   903 ;// CONCATENATED MODULE: external ["wp","deprecated"]
  1520 ;// CONCATENATED MODULE: external ["wp","deprecated"]
   904 var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  1521 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
   905 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  1522 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
       
  1523 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/set-nested-value.js
       
  1524 /**
       
  1525  * Sets the value at path of object.
       
  1526  * If a portion of path doesn’t exist, it’s created.
       
  1527  * Arrays are created for missing index properties while objects are created
       
  1528  * for all other missing properties.
       
  1529  *
       
  1530  * Path is specified as either:
       
  1531  * - a string of properties, separated by dots, for example: "x.y".
       
  1532  * - an array of properties, for example `[ 'x', 'y' ]`.
       
  1533  *
       
  1534  * This function intentionally mutates the input object.
       
  1535  *
       
  1536  * Inspired by _.set().
       
  1537  *
       
  1538  * @see https://lodash.com/docs/4.17.15#set
       
  1539  *
       
  1540  * @todo Needs to be deduplicated with its copy in `@wordpress/edit-site`.
       
  1541  *
       
  1542  * @param {Object}       object Object to modify
       
  1543  * @param {Array|string} path   Path of the property to set.
       
  1544  * @param {*}            value  Value to set.
       
  1545  */
       
  1546 function setNestedValue(object, path, value) {
       
  1547   if (!object || typeof object !== 'object') {
       
  1548     return object;
       
  1549   }
       
  1550   const normalizedPath = Array.isArray(path) ? path : path.split('.');
       
  1551   normalizedPath.reduce((acc, key, idx) => {
       
  1552     if (acc[key] === undefined) {
       
  1553       if (Number.isInteger(normalizedPath[idx + 1])) {
       
  1554         acc[key] = [];
       
  1555       } else {
       
  1556         acc[key] = {};
       
  1557       }
       
  1558     }
       
  1559     if (idx === normalizedPath.length - 1) {
       
  1560       acc[key] = value;
       
  1561     }
       
  1562     return acc[key];
       
  1563   }, object);
       
  1564   return object;
       
  1565 }
       
  1566 
       
  1567 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/get-nested-value.js
       
  1568 /**
       
  1569  * Helper util to return a value from a certain path of the object.
       
  1570  * Path is specified as either:
       
  1571  * - a string of properties, separated by dots, for example: "x.y".
       
  1572  * - an array of properties, for example `[ 'x', 'y' ]`.
       
  1573  * You can also specify a default value in case the result is nullish.
       
  1574  *
       
  1575  * @param {Object}       object       Input object.
       
  1576  * @param {string|Array} path         Path to the object property.
       
  1577  * @param {*}            defaultValue Default value if the value at the specified path is undefined.
       
  1578  * @return {*} Value of the object property at the specified path.
       
  1579  */
       
  1580 function getNestedValue(object, path, defaultValue) {
       
  1581   if (!object || typeof object !== 'object' || typeof path !== 'string' && !Array.isArray(path)) {
       
  1582     return object;
       
  1583   }
       
  1584   const normalizedPath = Array.isArray(path) ? path : path.split('.');
       
  1585   let value = object;
       
  1586   normalizedPath.forEach(fieldName => {
       
  1587     value = value?.[fieldName];
       
  1588   });
       
  1589   return value !== undefined ? value : defaultValue;
       
  1590 }
       
  1591 
   906 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/actions.js
  1592 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/actions.js
   907 /**
       
   908  * External dependencies
       
   909  */
       
   910 
       
   911 /**
  1593 /**
   912  * Returns an action object used in signalling that items have been received.
  1594  * Returns an action object used in signalling that items have been received.
   913  *
  1595  *
   914  * @param {Array}   items Items received.
  1596  * @param {Array}   items Items received.
   915  * @param {?Object} edits Optional edits to reset.
  1597  * @param {?Object} edits Optional edits to reset.
       
  1598  * @param {?Object} meta  Meta information about pagination.
   916  *
  1599  *
   917  * @return {Object} Action object.
  1600  * @return {Object} Action object.
   918  */
  1601  */
   919 
  1602 function receiveItems(items, edits, meta) {
   920 function receiveItems(items, edits) {
       
   921   return {
  1603   return {
   922     type: 'RECEIVE_ITEMS',
  1604     type: 'RECEIVE_ITEMS',
   923     items: (0,external_lodash_namespaceObject.castArray)(items),
  1605     items: Array.isArray(items) ? items : [items],
   924     persistedEdits: edits
  1606     persistedEdits: edits,
       
  1607     meta
   925   };
  1608   };
   926 }
  1609 }
       
  1610 
   927 /**
  1611 /**
   928  * Returns an action object used in signalling that entity records have been
  1612  * Returns an action object used in signalling that entity records have been
   929  * deleted and they need to be removed from entities state.
  1613  * deleted and they need to be removed from entities state.
   930  *
  1614  *
   931  * @param {string}              kind            Kind of the removed entities.
  1615  * @param {string}              kind            Kind of the removed entities.
   932  * @param {string}              name            Name of the removed entities.
  1616  * @param {string}              name            Name of the removed entities.
   933  * @param {Array|number|string} records         Record IDs of the removed entities.
  1617  * @param {Array|number|string} records         Record IDs of the removed entities.
   934  * @param {boolean}             invalidateCache Controls whether we want to invalidate the cache.
  1618  * @param {boolean}             invalidateCache Controls whether we want to invalidate the cache.
   935  * @return {Object} Action object.
  1619  * @return {Object} Action object.
   936  */
  1620  */
   937 
  1621 function removeItems(kind, name, records, invalidateCache = false) {
   938 function removeItems(kind, name, records) {
       
   939   let invalidateCache = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
       
   940   return {
  1622   return {
   941     type: 'REMOVE_ITEMS',
  1623     type: 'REMOVE_ITEMS',
   942     itemIds: (0,external_lodash_namespaceObject.castArray)(records),
  1624     itemIds: Array.isArray(records) ? records : [records],
   943     kind,
  1625     kind,
   944     name,
  1626     name,
   945     invalidateCache
  1627     invalidateCache
   946   };
  1628   };
   947 }
  1629 }
       
  1630 
   948 /**
  1631 /**
   949  * Returns an action object used in signalling that queried data has been
  1632  * Returns an action object used in signalling that queried data has been
   950  * received.
  1633  * received.
   951  *
  1634  *
   952  * @param {Array}   items Queried items received.
  1635  * @param {Array}   items Queried items received.
   953  * @param {?Object} query Optional query object.
  1636  * @param {?Object} query Optional query object.
   954  * @param {?Object} edits Optional edits to reset.
  1637  * @param {?Object} edits Optional edits to reset.
       
  1638  * @param {?Object} meta  Meta information about pagination.
   955  *
  1639  *
   956  * @return {Object} Action object.
  1640  * @return {Object} Action object.
   957  */
  1641  */
   958 
  1642 function receiveQueriedItems(items, query = {}, edits, meta) {
   959 function receiveQueriedItems(items) {
  1643   return {
   960   let query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1644     ...receiveItems(items, edits, meta),
   961   let edits = arguments.length > 2 ? arguments[2] : undefined;
       
   962   return { ...receiveItems(items, edits),
       
   963     query
  1645     query
   964   };
  1646   };
   965 }
  1647 }
   966 
  1648 
   967 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/batch/default-processor.js
  1649 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/batch/default-processor.js
   968 /**
  1650 /**
   969  * External dependencies
       
   970  */
       
   971 
       
   972 /**
       
   973  * WordPress dependencies
  1651  * WordPress dependencies
   974  */
  1652  */
   975 
  1653 
   976 
  1654 
   977 /**
  1655 /**
   978  * Maximum number of requests to place in a single batch request. Obtained by
  1656  * Maximum number of requests to place in a single batch request. Obtained by
   979  * sending a preflight OPTIONS request to /batch/v1/.
  1657  * sending a preflight OPTIONS request to /batch/v1/.
   980  *
  1658  *
   981  * @type {number?}
  1659  * @type {number?}
   982  */
  1660  */
   983 
       
   984 let maxItems = null;
  1661 let maxItems = null;
       
  1662 function chunk(arr, chunkSize) {
       
  1663   const tmp = [...arr];
       
  1664   const cache = [];
       
  1665   while (tmp.length) {
       
  1666     cache.push(tmp.splice(0, chunkSize));
       
  1667   }
       
  1668   return cache;
       
  1669 }
       
  1670 
   985 /**
  1671 /**
   986  * Default batch processor. Sends its input requests to /batch/v1.
  1672  * Default batch processor. Sends its input requests to /batch/v1.
   987  *
  1673  *
   988  * @param {Array} requests List of API requests to perform at once.
  1674  * @param {Array} requests List of API requests to perform at once.
   989  *
  1675  *
   990  * @return {Promise} Promise that resolves to a list of objects containing
  1676  * @return {Promise} Promise that resolves to a list of objects containing
   991  *                   either `output` (if that request was succesful) or `error`
  1677  *                   either `output` (if that request was successful) or `error`
   992  *                   (if not ).
  1678  *                   (if not ).
   993  */
  1679  */
   994 
       
   995 async function defaultProcessor(requests) {
  1680 async function defaultProcessor(requests) {
   996   if (maxItems === null) {
  1681   if (maxItems === null) {
   997     const preflightResponse = await external_wp_apiFetch_default()({
  1682     const preflightResponse = await external_wp_apiFetch_default()({
   998       path: '/batch/v1',
  1683       path: '/batch/v1',
   999       method: 'OPTIONS'
  1684       method: 'OPTIONS'
  1000     });
  1685     });
  1001     maxItems = preflightResponse.endpoints[0].args.requests.maxItems;
  1686     maxItems = preflightResponse.endpoints[0].args.requests.maxItems;
  1002   }
  1687   }
  1003 
  1688   const results = [];
  1004   const results = []; // @ts-ignore We would have crashed or never gotten to this point if we hadn't received the maxItems count.
  1689 
  1005 
  1690   // @ts-ignore We would have crashed or never gotten to this point if we hadn't received the maxItems count.
  1006   for (const batchRequests of (0,external_lodash_namespaceObject.chunk)(requests, maxItems)) {
  1691   for (const batchRequests of chunk(requests, maxItems)) {
  1007     const batchResponse = await external_wp_apiFetch_default()({
  1692     const batchResponse = await external_wp_apiFetch_default()({
  1008       path: '/batch/v1',
  1693       path: '/batch/v1',
  1009       method: 'POST',
  1694       method: 'POST',
  1010       data: {
  1695       data: {
  1011         validation: 'require-all-validate',
  1696         validation: 'require-all-validate',
  1017           headers: request.headers
  1702           headers: request.headers
  1018         }))
  1703         }))
  1019       }
  1704       }
  1020     });
  1705     });
  1021     let batchResults;
  1706     let batchResults;
  1022 
       
  1023     if (batchResponse.failed) {
  1707     if (batchResponse.failed) {
  1024       batchResults = batchResponse.responses.map(response => ({
  1708       batchResults = batchResponse.responses.map(response => ({
  1025         error: response === null || response === void 0 ? void 0 : response.body
  1709         error: response?.body
  1026       }));
  1710       }));
  1027     } else {
  1711     } else {
  1028       batchResults = batchResponse.responses.map(response => {
  1712       batchResults = batchResponse.responses.map(response => {
  1029         const result = {};
  1713         const result = {};
  1030 
       
  1031         if (response.status >= 200 && response.status < 300) {
  1714         if (response.status >= 200 && response.status < 300) {
  1032           result.output = response.body;
  1715           result.output = response.body;
  1033         } else {
  1716         } else {
  1034           result.error = response.body;
  1717           result.error = response.body;
  1035         }
  1718         }
  1036 
       
  1037         return result;
  1719         return result;
  1038       });
  1720       });
  1039     }
  1721     }
  1040 
       
  1041     results.push(...batchResults);
  1722     results.push(...batchResults);
  1042   }
  1723   }
  1043 
       
  1044   return results;
  1724   return results;
  1045 }
  1725 }
  1046 
  1726 
  1047 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/batch/create-batch.js
  1727 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/batch/create-batch.js
  1048 /**
       
  1049  * External dependencies
       
  1050  */
       
  1051 
       
  1052 /**
  1728 /**
  1053  * Internal dependencies
  1729  * Internal dependencies
  1054  */
  1730  */
  1055 
  1731 
  1056 
  1732 
  1085  *                               request to /v1/batch. Is given an array of
  1761  *                               request to /v1/batch. Is given an array of
  1086  *                               inputs and must return a promise that
  1762  *                               inputs and must return a promise that
  1087  *                               resolves to an array of objects containing
  1763  *                               resolves to an array of objects containing
  1088  *                               either `output` or `error`.
  1764  *                               either `output` or `error`.
  1089  */
  1765  */
  1090 
  1766 function createBatch(processor = defaultProcessor) {
  1091 function createBatch() {
       
  1092   let processor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultProcessor;
       
  1093   let lastId = 0;
  1767   let lastId = 0;
  1094   /** @type {Array<{ input: any; resolve: ( value: any ) => void; reject: ( error: any ) => void }>} */
  1768   /** @type {Array<{ input: any; resolve: ( value: any ) => void; reject: ( error: any ) => void }>} */
  1095 
       
  1096   let queue = [];
  1769   let queue = [];
  1097   const pending = new ObservableSet();
  1770   const pending = new ObservableSet();
  1098   return {
  1771   return {
  1099     /**
  1772     /**
  1100      * Adds an input to the batch and returns a promise that is resolved or
  1773      * Adds an input to the batch and returns a promise that is resolved or
  1123      *                       value of that thunk.
  1796      *                       value of that thunk.
  1124      */
  1797      */
  1125     add(inputOrThunk) {
  1798     add(inputOrThunk) {
  1126       const id = ++lastId;
  1799       const id = ++lastId;
  1127       pending.add(id);
  1800       pending.add(id);
  1128 
       
  1129       const add = input => new Promise((resolve, reject) => {
  1801       const add = input => new Promise((resolve, reject) => {
  1130         queue.push({
  1802         queue.push({
  1131           input,
  1803           input,
  1132           resolve,
  1804           resolve,
  1133           reject
  1805           reject
  1134         });
  1806         });
  1135         pending.delete(id);
  1807         pending.delete(id);
  1136       });
  1808       });
  1137 
  1809       if (typeof inputOrThunk === 'function') {
  1138       if ((0,external_lodash_namespaceObject.isFunction)(inputOrThunk)) {
       
  1139         return Promise.resolve(inputOrThunk(add)).finally(() => {
  1810         return Promise.resolve(inputOrThunk(add)).finally(() => {
  1140           pending.delete(id);
  1811           pending.delete(id);
  1141         });
  1812         });
  1142       }
  1813       }
  1143 
       
  1144       return add(inputOrThunk);
  1814       return add(inputOrThunk);
  1145     },
  1815     },
  1146 
       
  1147     /**
  1816     /**
  1148      * Runs the batch. This calls `batchProcessor` and resolves or rejects
  1817      * Runs the batch. This calls `batchProcessor` and resolves or rejects
  1149      * all promises returned by `add()`.
  1818      * all promises returned by `add()`.
  1150      *
  1819      *
  1151      * @return {Promise<boolean>} A promise that resolves to a boolean that is true
  1820      * @return {Promise<boolean>} A promise that resolves to a boolean that is true
  1160               resolve(undefined);
  1829               resolve(undefined);
  1161             }
  1830             }
  1162           });
  1831           });
  1163         });
  1832         });
  1164       }
  1833       }
  1165 
       
  1166       let results;
  1834       let results;
  1167 
       
  1168       try {
  1835       try {
  1169         results = await processor(queue.map(_ref => {
  1836         results = await processor(queue.map(({
  1170           let {
  1837           input
  1171             input
  1838         }) => input));
  1172           } = _ref;
       
  1173           return input;
       
  1174         }));
       
  1175 
       
  1176         if (results.length !== queue.length) {
  1839         if (results.length !== queue.length) {
  1177           throw new Error('run: Array returned by processor must be same size as input array.');
  1840           throw new Error('run: Array returned by processor must be same size as input array.');
  1178         }
  1841         }
  1179       } catch (error) {
  1842       } catch (error) {
  1180         for (const {
  1843         for (const {
  1181           reject
  1844           reject
  1182         } of queue) {
  1845         } of queue) {
  1183           reject(error);
  1846           reject(error);
  1184         }
  1847         }
  1185 
       
  1186         throw error;
  1848         throw error;
  1187       }
  1849       }
  1188 
       
  1189       let isSuccess = true;
  1850       let isSuccess = true;
  1190 
  1851       results.forEach((result, key) => {
  1191       for (const pair of (0,external_lodash_namespaceObject.zip)(results, queue)) {
  1852         const queueItem = queue[key];
  1192         /** @type {{error?: unknown, output?: unknown}} */
  1853         if (result?.error) {
  1193         const result = pair[0];
  1854           queueItem?.reject(result.error);
  1194         /** @type {{resolve: (value: any) => void; reject: (error: any) => void} | undefined} */
       
  1195 
       
  1196         const queueItem = pair[1];
       
  1197 
       
  1198         if (result !== null && result !== void 0 && result.error) {
       
  1199           queueItem === null || queueItem === void 0 ? void 0 : queueItem.reject(result.error);
       
  1200           isSuccess = false;
  1855           isSuccess = false;
  1201         } else {
  1856         } else {
  1202           var _result$output;
  1857           var _result$output;
  1203 
  1858           queueItem?.resolve((_result$output = result?.output) !== null && _result$output !== void 0 ? _result$output : result);
  1204           queueItem === null || queueItem === void 0 ? void 0 : queueItem.resolve((_result$output = result === null || result === void 0 ? void 0 : result.output) !== null && _result$output !== void 0 ? _result$output : result);
       
  1205         }
  1859         }
  1206       }
  1860       });
  1207 
       
  1208       queue = [];
  1861       queue = [];
  1209       return isSuccess;
  1862       return isSuccess;
  1210     }
  1863     }
  1211 
       
  1212   };
  1864   };
  1213 }
  1865 }
  1214 
       
  1215 class ObservableSet {
  1866 class ObservableSet {
  1216   constructor() {
  1867   constructor(...args) {
  1217     for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
       
  1218       args[_key] = arguments[_key];
       
  1219     }
       
  1220 
       
  1221     this.set = new Set(...args);
  1868     this.set = new Set(...args);
  1222     this.subscribers = new Set();
  1869     this.subscribers = new Set();
  1223   }
  1870   }
  1224 
       
  1225   get size() {
  1871   get size() {
  1226     return this.set.size;
  1872     return this.set.size;
  1227   }
  1873   }
  1228 
       
  1229   add(value) {
  1874   add(value) {
  1230     this.set.add(value);
  1875     this.set.add(value);
  1231     this.subscribers.forEach(subscriber => subscriber());
  1876     this.subscribers.forEach(subscriber => subscriber());
  1232     return this;
  1877     return this;
  1233   }
  1878   }
  1234 
       
  1235   delete(value) {
  1879   delete(value) {
  1236     const isSuccess = this.set.delete(value);
  1880     const isSuccess = this.set.delete(value);
  1237     this.subscribers.forEach(subscriber => subscriber());
  1881     this.subscribers.forEach(subscriber => subscriber());
  1238     return isSuccess;
  1882     return isSuccess;
  1239   }
  1883   }
  1240 
       
  1241   subscribe(subscriber) {
  1884   subscribe(subscriber) {
  1242     this.subscribers.add(subscriber);
  1885     this.subscribers.add(subscriber);
  1243     return () => {
  1886     return () => {
  1244       this.subscribers.delete(subscriber);
  1887       this.subscribers.delete(subscriber);
  1245     };
  1888     };
  1246   }
  1889   }
  1247 
       
  1248 }
  1890 }
  1249 
  1891 
  1250 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/name.js
  1892 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/name.js
  1251 /**
  1893 /**
  1252  * The reducer key used by core data in store registration.
  1894  * The reducer key used by core data in store registration.
  1260 /**
  1902 /**
  1261  * External dependencies
  1903  * External dependencies
  1262  */
  1904  */
  1263 
  1905 
  1264 
  1906 
       
  1907 
  1265 /**
  1908 /**
  1266  * WordPress dependencies
  1909  * WordPress dependencies
  1267  */
  1910  */
  1268 
  1911 
  1269 
  1912 
  1275 
  1918 
  1276 
  1919 
  1277 
  1920 
  1278 
  1921 
  1279 
  1922 
       
  1923 
       
  1924 
  1280 /**
  1925 /**
  1281  * Returns an action object used in signalling that authors have been received.
  1926  * Returns an action object used in signalling that authors have been received.
       
  1927  * Ignored from documentation as it's internal to the data store.
       
  1928  *
       
  1929  * @ignore
  1282  *
  1930  *
  1283  * @param {string}       queryID Query ID.
  1931  * @param {string}       queryID Query ID.
  1284  * @param {Array|Object} users   Users received.
  1932  * @param {Array|Object} users   Users received.
  1285  *
  1933  *
  1286  * @return {Object} Action object.
  1934  * @return {Object} Action object.
  1287  */
  1935  */
  1288 
       
  1289 function receiveUserQuery(queryID, users) {
  1936 function receiveUserQuery(queryID, users) {
  1290   return {
  1937   return {
  1291     type: 'RECEIVE_USER_QUERY',
  1938     type: 'RECEIVE_USER_QUERY',
  1292     users: (0,external_lodash_namespaceObject.castArray)(users),
  1939     users: Array.isArray(users) ? users : [users],
  1293     queryID
  1940     queryID
  1294   };
  1941   };
  1295 }
  1942 }
       
  1943 
  1296 /**
  1944 /**
  1297  * Returns an action used in signalling that the current user has been received.
  1945  * Returns an action used in signalling that the current user has been received.
       
  1946  * Ignored from documentation as it's internal to the data store.
       
  1947  *
       
  1948  * @ignore
  1298  *
  1949  *
  1299  * @param {Object} currentUser Current user object.
  1950  * @param {Object} currentUser Current user object.
  1300  *
  1951  *
  1301  * @return {Object} Action object.
  1952  * @return {Object} Action object.
  1302  */
  1953  */
  1303 
       
  1304 function receiveCurrentUser(currentUser) {
  1954 function receiveCurrentUser(currentUser) {
  1305   return {
  1955   return {
  1306     type: 'RECEIVE_CURRENT_USER',
  1956     type: 'RECEIVE_CURRENT_USER',
  1307     currentUser
  1957     currentUser
  1308   };
  1958   };
  1309 }
  1959 }
       
  1960 
  1310 /**
  1961 /**
  1311  * Returns an action object used in adding new entities.
  1962  * Returns an action object used in adding new entities.
  1312  *
  1963  *
  1313  * @param {Array} entities Entities received.
  1964  * @param {Array} entities Entities received.
  1314  *
  1965  *
  1315  * @return {Object} Action object.
  1966  * @return {Object} Action object.
  1316  */
  1967  */
  1317 
       
  1318 function addEntities(entities) {
  1968 function addEntities(entities) {
  1319   return {
  1969   return {
  1320     type: 'ADD_ENTITIES',
  1970     type: 'ADD_ENTITIES',
  1321     entities
  1971     entities
  1322   };
  1972   };
  1323 }
  1973 }
       
  1974 
  1324 /**
  1975 /**
  1325  * Returns an action object used in signalling that entity records have been received.
  1976  * Returns an action object used in signalling that entity records have been received.
  1326  *
  1977  *
  1327  * @param {string}       kind            Kind of the received entity record.
  1978  * @param {string}       kind            Kind of the received entity record.
  1328  * @param {string}       name            Name of the received entity record.
  1979  * @param {string}       name            Name of the received entity record.
  1329  * @param {Array|Object} records         Records received.
  1980  * @param {Array|Object} records         Records received.
  1330  * @param {?Object}      query           Query Object.
  1981  * @param {?Object}      query           Query Object.
  1331  * @param {?boolean}     invalidateCache Should invalidate query caches.
  1982  * @param {?boolean}     invalidateCache Should invalidate query caches.
  1332  * @param {?Object}      edits           Edits to reset.
  1983  * @param {?Object}      edits           Edits to reset.
       
  1984  * @param {?Object}      meta            Meta information about pagination.
  1333  * @return {Object} Action object.
  1985  * @return {Object} Action object.
  1334  */
  1986  */
  1335 
  1987 function receiveEntityRecords(kind, name, records, query, invalidateCache = false, edits, meta) {
  1336 function receiveEntityRecords(kind, name, records, query) {
       
  1337   let invalidateCache = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
       
  1338   let edits = arguments.length > 5 ? arguments[5] : undefined;
       
  1339 
       
  1340   // Auto drafts should not have titles, but some plugins rely on them so we can't filter this
  1988   // Auto drafts should not have titles, but some plugins rely on them so we can't filter this
  1341   // on the server.
  1989   // on the server.
  1342   if (kind === 'postType') {
  1990   if (kind === 'postType') {
  1343     records = (0,external_lodash_namespaceObject.castArray)(records).map(record => record.status === 'auto-draft' ? { ...record,
  1991     records = (Array.isArray(records) ? records : [records]).map(record => record.status === 'auto-draft' ? {
       
  1992       ...record,
  1344       title: ''
  1993       title: ''
  1345     } : record);
  1994     } : record);
  1346   }
  1995   }
  1347 
       
  1348   let action;
  1996   let action;
  1349 
       
  1350   if (query) {
  1997   if (query) {
  1351     action = receiveQueriedItems(records, query, edits);
  1998     action = receiveQueriedItems(records, query, edits, meta);
  1352   } else {
  1999   } else {
  1353     action = receiveItems(records, edits);
  2000     action = receiveItems(records, edits, meta);
  1354   }
  2001   }
  1355 
  2002   return {
  1356   return { ...action,
  2003     ...action,
  1357     kind,
  2004     kind,
  1358     name,
  2005     name,
  1359     invalidateCache
  2006     invalidateCache
  1360   };
  2007   };
  1361 }
  2008 }
       
  2009 
  1362 /**
  2010 /**
  1363  * Returns an action object used in signalling that the current theme has been received.
  2011  * Returns an action object used in signalling that the current theme has been received.
       
  2012  * Ignored from documentation as it's internal to the data store.
       
  2013  *
       
  2014  * @ignore
  1364  *
  2015  *
  1365  * @param {Object} currentTheme The current theme.
  2016  * @param {Object} currentTheme The current theme.
  1366  *
  2017  *
  1367  * @return {Object} Action object.
  2018  * @return {Object} Action object.
  1368  */
  2019  */
  1369 
       
  1370 function receiveCurrentTheme(currentTheme) {
  2020 function receiveCurrentTheme(currentTheme) {
  1371   return {
  2021   return {
  1372     type: 'RECEIVE_CURRENT_THEME',
  2022     type: 'RECEIVE_CURRENT_THEME',
  1373     currentTheme
  2023     currentTheme
  1374   };
  2024   };
  1375 }
  2025 }
       
  2026 
  1376 /**
  2027 /**
  1377  * Returns an action object used in signalling that the current global styles id has been received.
  2028  * Returns an action object used in signalling that the current global styles id has been received.
       
  2029  * Ignored from documentation as it's internal to the data store.
       
  2030  *
       
  2031  * @ignore
  1378  *
  2032  *
  1379  * @param {string} currentGlobalStylesId The current global styles id.
  2033  * @param {string} currentGlobalStylesId The current global styles id.
  1380  *
  2034  *
  1381  * @return {Object} Action object.
  2035  * @return {Object} Action object.
  1382  */
  2036  */
  1383 
       
  1384 function __experimentalReceiveCurrentGlobalStylesId(currentGlobalStylesId) {
  2037 function __experimentalReceiveCurrentGlobalStylesId(currentGlobalStylesId) {
  1385   return {
  2038   return {
  1386     type: 'RECEIVE_CURRENT_GLOBAL_STYLES_ID',
  2039     type: 'RECEIVE_CURRENT_GLOBAL_STYLES_ID',
  1387     id: currentGlobalStylesId
  2040     id: currentGlobalStylesId
  1388   };
  2041   };
  1389 }
  2042 }
       
  2043 
  1390 /**
  2044 /**
  1391  * Returns an action object used in signalling that the theme base global styles have been received
  2045  * Returns an action object used in signalling that the theme base global styles have been received
       
  2046  * Ignored from documentation as it's internal to the data store.
       
  2047  *
       
  2048  * @ignore
  1392  *
  2049  *
  1393  * @param {string} stylesheet   The theme's identifier
  2050  * @param {string} stylesheet   The theme's identifier
  1394  * @param {Object} globalStyles The global styles object.
  2051  * @param {Object} globalStyles The global styles object.
  1395  *
  2052  *
  1396  * @return {Object} Action object.
  2053  * @return {Object} Action object.
  1397  */
  2054  */
  1398 
       
  1399 function __experimentalReceiveThemeBaseGlobalStyles(stylesheet, globalStyles) {
  2055 function __experimentalReceiveThemeBaseGlobalStyles(stylesheet, globalStyles) {
  1400   return {
  2056   return {
  1401     type: 'RECEIVE_THEME_GLOBAL_STYLES',
  2057     type: 'RECEIVE_THEME_GLOBAL_STYLES',
  1402     stylesheet,
  2058     stylesheet,
  1403     globalStyles
  2059     globalStyles
  1404   };
  2060   };
  1405 }
  2061 }
       
  2062 
  1406 /**
  2063 /**
  1407  * Returns an action object used in signalling that the theme global styles variations have been received.
  2064  * Returns an action object used in signalling that the theme global styles variations have been received.
       
  2065  * Ignored from documentation as it's internal to the data store.
       
  2066  *
       
  2067  * @ignore
  1408  *
  2068  *
  1409  * @param {string} stylesheet The theme's identifier
  2069  * @param {string} stylesheet The theme's identifier
  1410  * @param {Array}  variations The global styles variations.
  2070  * @param {Array}  variations The global styles variations.
  1411  *
  2071  *
  1412  * @return {Object} Action object.
  2072  * @return {Object} Action object.
  1413  */
  2073  */
  1414 
       
  1415 function __experimentalReceiveThemeGlobalStyleVariations(stylesheet, variations) {
  2074 function __experimentalReceiveThemeGlobalStyleVariations(stylesheet, variations) {
  1416   return {
  2075   return {
  1417     type: 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS',
  2076     type: 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS',
  1418     stylesheet,
  2077     stylesheet,
  1419     variations
  2078     variations
  1420   };
  2079   };
  1421 }
  2080 }
       
  2081 
  1422 /**
  2082 /**
  1423  * Returns an action object used in signalling that the index has been received.
  2083  * Returns an action object used in signalling that the index has been received.
  1424  *
  2084  *
  1425  * @deprecated since WP 5.9, this is not useful anymore, use the selector direclty.
  2085  * @deprecated since WP 5.9, this is not useful anymore, use the selector direclty.
  1426  *
  2086  *
  1427  * @return {Object} Action object.
  2087  * @return {Object} Action object.
  1428  */
  2088  */
  1429 
       
  1430 function receiveThemeSupports() {
  2089 function receiveThemeSupports() {
  1431   external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveThemeSupports", {
  2090   external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveThemeSupports", {
  1432     since: '5.9'
  2091     since: '5.9'
  1433   });
  2092   });
  1434   return {
  2093   return {
  1435     type: 'DO_NOTHING'
  2094     type: 'DO_NOTHING'
  1436   };
  2095   };
  1437 }
  2096 }
       
  2097 
       
  2098 /**
       
  2099  * Returns an action object used in signalling that the theme global styles CPT post revisions have been received.
       
  2100  * Ignored from documentation as it's internal to the data store.
       
  2101  *
       
  2102  * @deprecated since WordPress 6.5.0. Callers should use `dispatch( 'core' ).receiveRevision` instead.
       
  2103  *
       
  2104  * @ignore
       
  2105  *
       
  2106  * @param {number} currentId The post id.
       
  2107  * @param {Array}  revisions The global styles revisions.
       
  2108  *
       
  2109  * @return {Object} Action object.
       
  2110  */
       
  2111 function receiveThemeGlobalStyleRevisions(currentId, revisions) {
       
  2112   external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveThemeGlobalStyleRevisions()", {
       
  2113     since: '6.5.0',
       
  2114     alternative: "wp.data.dispatch( 'core' ).receiveRevisions"
       
  2115   });
       
  2116   return {
       
  2117     type: 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS',
       
  2118     currentId,
       
  2119     revisions
       
  2120   };
       
  2121 }
       
  2122 
  1438 /**
  2123 /**
  1439  * Returns an action object used in signalling that the preview data for
  2124  * Returns an action object used in signalling that the preview data for
  1440  * a given URl has been received.
  2125  * a given URl has been received.
       
  2126  * Ignored from documentation as it's internal to the data store.
       
  2127  *
       
  2128  * @ignore
  1441  *
  2129  *
  1442  * @param {string} url     URL to preview the embed for.
  2130  * @param {string} url     URL to preview the embed for.
  1443  * @param {*}      preview Preview data.
  2131  * @param {*}      preview Preview data.
  1444  *
  2132  *
  1445  * @return {Object} Action object.
  2133  * @return {Object} Action object.
  1446  */
  2134  */
  1447 
       
  1448 function receiveEmbedPreview(url, preview) {
  2135 function receiveEmbedPreview(url, preview) {
  1449   return {
  2136   return {
  1450     type: 'RECEIVE_EMBED_PREVIEW',
  2137     type: 'RECEIVE_EMBED_PREVIEW',
  1451     url,
  2138     url,
  1452     preview
  2139     preview
  1453   };
  2140   };
  1454 }
  2141 }
       
  2142 
  1455 /**
  2143 /**
  1456  * Action triggered to delete an entity record.
  2144  * Action triggered to delete an entity record.
  1457  *
  2145  *
  1458  * @param {string}   kind                         Kind of the deleted entity.
  2146  * @param {string}   kind                         Kind of the deleted entity.
  1459  * @param {string}   name                         Name of the deleted entity.
  2147  * @param {string}   name                         Name of the deleted entity.
  1465  *                                                call instead of `apiFetch()`.
  2153  *                                                call instead of `apiFetch()`.
  1466  *                                                Must return a promise.
  2154  *                                                Must return a promise.
  1467  * @param {boolean}  [options.throwOnError=false] If false, this action suppresses all
  2155  * @param {boolean}  [options.throwOnError=false] If false, this action suppresses all
  1468  *                                                the exceptions. Defaults to false.
  2156  *                                                the exceptions. Defaults to false.
  1469  */
  2157  */
  1470 
  2158 const deleteEntityRecord = (kind, name, recordId, query, {
  1471 const deleteEntityRecord = function (kind, name, recordId, query) {
  2159   __unstableFetch = (external_wp_apiFetch_default()),
  1472   let {
  2160   throwOnError = false
  1473     __unstableFetch = (external_wp_apiFetch_default()),
  2161 } = {}) => async ({
  1474     throwOnError = false
  2162   dispatch
  1475   } = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
  2163 }) => {
  1476   return async _ref => {
  2164   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
  1477     let {
  2165   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
  1478       dispatch
  2166   let error;
  1479     } = _ref;
  2167   let deletedRecord = false;
  1480     const configs = await dispatch(getOrLoadEntitiesConfig(kind));
  2168   if (!entityConfig || entityConfig?.__experimentalNoFetch) {
  1481     const entityConfig = (0,external_lodash_namespaceObject.find)(configs, {
  2169     return;
       
  2170   }
       
  2171   const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, recordId], {
       
  2172     exclusive: true
       
  2173   });
       
  2174   try {
       
  2175     dispatch({
       
  2176       type: 'DELETE_ENTITY_RECORD_START',
  1482       kind,
  2177       kind,
  1483       name
  2178       name,
       
  2179       recordId
  1484     });
  2180     });
  1485     let error;
  2181     let hasError = false;
  1486     let deletedRecord = false;
       
  1487 
       
  1488     if (!entityConfig || entityConfig !== null && entityConfig !== void 0 && entityConfig.__experimentalNoFetch) {
       
  1489       return;
       
  1490     }
       
  1491 
       
  1492     const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, recordId], {
       
  1493       exclusive: true
       
  1494     });
       
  1495 
       
  1496     try {
  2182     try {
  1497       dispatch({
  2183       let path = `${entityConfig.baseURL}/${recordId}`;
  1498         type: 'DELETE_ENTITY_RECORD_START',
  2184       if (query) {
  1499         kind,
  2185         path = (0,external_wp_url_namespaceObject.addQueryArgs)(path, query);
  1500         name,
  2186       }
  1501         recordId
  2187       deletedRecord = await __unstableFetch({
       
  2188         path,
       
  2189         method: 'DELETE'
  1502       });
  2190       });
  1503       let hasError = false;
  2191       await dispatch(removeItems(kind, name, recordId, true));
  1504 
  2192     } catch (_error) {
  1505       try {
  2193       hasError = true;
  1506         let path = `${entityConfig.baseURL}/${recordId}`;
  2194       error = _error;
  1507 
  2195     }
  1508         if (query) {
  2196     dispatch({
  1509           path = (0,external_wp_url_namespaceObject.addQueryArgs)(path, query);
  2197       type: 'DELETE_ENTITY_RECORD_FINISH',
  1510         }
       
  1511 
       
  1512         deletedRecord = await __unstableFetch({
       
  1513           path,
       
  1514           method: 'DELETE'
       
  1515         });
       
  1516         await dispatch(removeItems(kind, name, recordId, true));
       
  1517       } catch (_error) {
       
  1518         hasError = true;
       
  1519         error = _error;
       
  1520       }
       
  1521 
       
  1522       dispatch({
       
  1523         type: 'DELETE_ENTITY_RECORD_FINISH',
       
  1524         kind,
       
  1525         name,
       
  1526         recordId,
       
  1527         error
       
  1528       });
       
  1529 
       
  1530       if (hasError && throwOnError) {
       
  1531         throw error;
       
  1532       }
       
  1533 
       
  1534       return deletedRecord;
       
  1535     } finally {
       
  1536       dispatch.__unstableReleaseStoreLock(lock);
       
  1537     }
       
  1538   };
       
  1539 };
       
  1540 /**
       
  1541  * Returns an action object that triggers an
       
  1542  * edit to an entity record.
       
  1543  *
       
  1544  * @param {string}  kind                 Kind of the edited entity record.
       
  1545  * @param {string}  name                 Name of the edited entity record.
       
  1546  * @param {number}  recordId             Record ID of the edited entity record.
       
  1547  * @param {Object}  edits                The edits.
       
  1548  * @param {Object}  options              Options for the edit.
       
  1549  * @param {boolean} [options.undoIgnore] Whether to ignore the edit in undo history or not.
       
  1550  *
       
  1551  * @return {Object} Action object.
       
  1552  */
       
  1553 
       
  1554 const editEntityRecord = function (kind, name, recordId, edits) {
       
  1555   let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
       
  1556   return _ref2 => {
       
  1557     let {
       
  1558       select,
       
  1559       dispatch
       
  1560     } = _ref2;
       
  1561     const entityConfig = select.getEntityConfig(kind, name);
       
  1562 
       
  1563     if (!entityConfig) {
       
  1564       throw new Error(`The entity being edited (${kind}, ${name}) does not have a loaded config.`);
       
  1565     }
       
  1566 
       
  1567     const {
       
  1568       transientEdits = {},
       
  1569       mergedEdits = {}
       
  1570     } = entityConfig;
       
  1571     const record = select.getRawEntityRecord(kind, name, recordId);
       
  1572     const editedRecord = select.getEditedEntityRecord(kind, name, recordId);
       
  1573     const edit = {
       
  1574       kind,
  2198       kind,
  1575       name,
  2199       name,
  1576       recordId,
  2200       recordId,
  1577       // Clear edits when they are equal to their persisted counterparts
  2201       error
  1578       // so that the property is not considered dirty.
  2202     });
  1579       edits: Object.keys(edits).reduce((acc, key) => {
  2203     if (hasError && throwOnError) {
  1580         const recordValue = record[key];
  2204       throw error;
  1581         const editedRecordValue = editedRecord[key];
  2205     }
  1582         const value = mergedEdits[key] ? { ...editedRecordValue,
  2206     return deletedRecord;
  1583           ...edits[key]
  2207   } finally {
  1584         } : edits[key];
  2208     dispatch.__unstableReleaseStoreLock(lock);
  1585         acc[key] = (0,external_lodash_namespaceObject.isEqual)(recordValue, value) ? undefined : value;
  2209   }
  1586         return acc;
  2210 };
  1587       }, {}),
  2211 
  1588       transientEdits
  2212 /**
  1589     };
  2213  * Returns an action object that triggers an
       
  2214  * edit to an entity record.
       
  2215  *
       
  2216  * @param {string}        kind                 Kind of the edited entity record.
       
  2217  * @param {string}        name                 Name of the edited entity record.
       
  2218  * @param {number|string} recordId             Record ID of the edited entity record.
       
  2219  * @param {Object}        edits                The edits.
       
  2220  * @param {Object}        options              Options for the edit.
       
  2221  * @param {boolean}       [options.undoIgnore] Whether to ignore the edit in undo history or not.
       
  2222  *
       
  2223  * @return {Object} Action object.
       
  2224  */
       
  2225 const editEntityRecord = (kind, name, recordId, edits, options = {}) => ({
       
  2226   select,
       
  2227   dispatch
       
  2228 }) => {
       
  2229   const entityConfig = select.getEntityConfig(kind, name);
       
  2230   if (!entityConfig) {
       
  2231     throw new Error(`The entity being edited (${kind}, ${name}) does not have a loaded config.`);
       
  2232   }
       
  2233   const {
       
  2234     mergedEdits = {}
       
  2235   } = entityConfig;
       
  2236   const record = select.getRawEntityRecord(kind, name, recordId);
       
  2237   const editedRecord = select.getEditedEntityRecord(kind, name, recordId);
       
  2238   const edit = {
       
  2239     kind,
       
  2240     name,
       
  2241     recordId,
       
  2242     // Clear edits when they are equal to their persisted counterparts
       
  2243     // so that the property is not considered dirty.
       
  2244     edits: Object.keys(edits).reduce((acc, key) => {
       
  2245       const recordValue = record[key];
       
  2246       const editedRecordValue = editedRecord[key];
       
  2247       const value = mergedEdits[key] ? {
       
  2248         ...editedRecordValue,
       
  2249         ...edits[key]
       
  2250       } : edits[key];
       
  2251       acc[key] = es6_default()(recordValue, value) ? undefined : value;
       
  2252       return acc;
       
  2253     }, {})
       
  2254   };
       
  2255   if (window.__experimentalEnableSync && entityConfig.syncConfig) {
       
  2256     if (false) {}
       
  2257   } else {
       
  2258     if (!options.undoIgnore) {
       
  2259       select.getUndoManager().addRecord([{
       
  2260         id: {
       
  2261           kind,
       
  2262           name,
       
  2263           recordId
       
  2264         },
       
  2265         changes: Object.keys(edits).reduce((acc, key) => {
       
  2266           acc[key] = {
       
  2267             from: editedRecord[key],
       
  2268             to: edits[key]
       
  2269           };
       
  2270           return acc;
       
  2271         }, {})
       
  2272       }], options.isCached);
       
  2273     }
  1590     dispatch({
  2274     dispatch({
  1591       type: 'EDIT_ENTITY_RECORD',
  2275       type: 'EDIT_ENTITY_RECORD',
  1592       ...edit,
  2276       ...edit
  1593       meta: {
       
  1594         undo: !options.undoIgnore && { ...edit,
       
  1595           // Send the current values for things like the first undo stack entry.
       
  1596           edits: Object.keys(edits).reduce((acc, key) => {
       
  1597             acc[key] = editedRecord[key];
       
  1598             return acc;
       
  1599           }, {})
       
  1600         }
       
  1601       }
       
  1602     });
  2277     });
  1603   };
  2278   }
  1604 };
  2279 };
       
  2280 
  1605 /**
  2281 /**
  1606  * Action triggered to undo the last edit to
  2282  * Action triggered to undo the last edit to
  1607  * an entity record, if any.
  2283  * an entity record, if any.
  1608  */
  2284  */
  1609 
  2285 const undo = () => ({
  1610 const undo = () => _ref3 => {
  2286   select,
  1611   let {
  2287   dispatch
  1612     select,
  2288 }) => {
  1613     dispatch
  2289   const undoRecord = select.getUndoManager().undo();
  1614   } = _ref3;
  2290   if (!undoRecord) {
  1615   const undoEdit = select.getUndoEdit();
       
  1616 
       
  1617   if (!undoEdit) {
       
  1618     return;
  2291     return;
  1619   }
  2292   }
  1620 
       
  1621   dispatch({
  2293   dispatch({
  1622     type: 'EDIT_ENTITY_RECORD',
  2294     type: 'UNDO',
  1623     ...undoEdit,
  2295     record: undoRecord
  1624     meta: {
       
  1625       isUndo: true
       
  1626     }
       
  1627   });
  2296   });
  1628 };
  2297 };
       
  2298 
  1629 /**
  2299 /**
  1630  * Action triggered to redo the last undoed
  2300  * Action triggered to redo the last undoed
  1631  * edit to an entity record, if any.
  2301  * edit to an entity record, if any.
  1632  */
  2302  */
  1633 
  2303 const redo = () => ({
  1634 const redo = () => _ref4 => {
  2304   select,
  1635   let {
  2305   dispatch
  1636     select,
  2306 }) => {
  1637     dispatch
  2307   const redoRecord = select.getUndoManager().redo();
  1638   } = _ref4;
  2308   if (!redoRecord) {
  1639   const redoEdit = select.getRedoEdit();
       
  1640 
       
  1641   if (!redoEdit) {
       
  1642     return;
  2309     return;
  1643   }
  2310   }
  1644 
       
  1645   dispatch({
  2311   dispatch({
  1646     type: 'EDIT_ENTITY_RECORD',
  2312     type: 'REDO',
  1647     ...redoEdit,
  2313     record: redoRecord
  1648     meta: {
       
  1649       isRedo: true
       
  1650     }
       
  1651   });
  2314   });
  1652 };
  2315 };
       
  2316 
  1653 /**
  2317 /**
  1654  * Forces the creation of a new undo level.
  2318  * Forces the creation of a new undo level.
  1655  *
  2319  *
  1656  * @return {Object} Action object.
  2320  * @return {Object} Action object.
  1657  */
  2321  */
  1658 
  2322 const __unstableCreateUndoLevel = () => ({
  1659 function __unstableCreateUndoLevel() {
  2323   select
  1660   return {
  2324 }) => {
  1661     type: 'CREATE_UNDO_LEVEL'
  2325   select.getUndoManager().addRecord();
  1662   };
  2326 };
  1663 }
  2327 
  1664 /**
  2328 /**
  1665  * Action triggered to save an entity record.
  2329  * Action triggered to save an entity record.
  1666  *
  2330  *
  1667  * @param {string}   kind                         Kind of the received entity.
  2331  * @param {string}   kind                         Kind of the received entity.
  1668  * @param {string}   name                         Name of the received entity.
  2332  * @param {string}   name                         Name of the received entity.
  1673  *                                                call instead of `apiFetch()`.
  2337  *                                                call instead of `apiFetch()`.
  1674  *                                                Must return a promise.
  2338  *                                                Must return a promise.
  1675  * @param {boolean}  [options.throwOnError=false] If false, this action suppresses all
  2339  * @param {boolean}  [options.throwOnError=false] If false, this action suppresses all
  1676  *                                                the exceptions. Defaults to false.
  2340  *                                                the exceptions. Defaults to false.
  1677  */
  2341  */
  1678 
  2342 const saveEntityRecord = (kind, name, record, {
  1679 const saveEntityRecord = function (kind, name, record) {
  2343   isAutosave = false,
  1680   let {
  2344   __unstableFetch = (external_wp_apiFetch_default()),
  1681     isAutosave = false,
  2345   throwOnError = false
  1682     __unstableFetch = (external_wp_apiFetch_default()),
  2346 } = {}) => async ({
  1683     throwOnError = false
  2347   select,
  1684   } = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  2348   resolveSelect,
  1685   return async _ref5 => {
  2349   dispatch
  1686     let {
  2350 }) => {
  1687       select,
  2351   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
  1688       resolveSelect,
  2352   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
  1689       dispatch
  2353   if (!entityConfig || entityConfig?.__experimentalNoFetch) {
  1690     } = _ref5;
  2354     return;
  1691     const configs = await dispatch(getOrLoadEntitiesConfig(kind));
  2355   }
  1692     const entityConfig = (0,external_lodash_namespaceObject.find)(configs, {
  2356   const entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;
       
  2357   const recordId = record[entityIdKey];
       
  2358   const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, recordId || esm_browser_v4()], {
       
  2359     exclusive: true
       
  2360   });
       
  2361   try {
       
  2362     // Evaluate optimized edits.
       
  2363     // (Function edits that should be evaluated on save to avoid expensive computations on every edit.)
       
  2364     for (const [key, value] of Object.entries(record)) {
       
  2365       if (typeof value === 'function') {
       
  2366         const evaluatedValue = value(select.getEditedEntityRecord(kind, name, recordId));
       
  2367         dispatch.editEntityRecord(kind, name, recordId, {
       
  2368           [key]: evaluatedValue
       
  2369         }, {
       
  2370           undoIgnore: true
       
  2371         });
       
  2372         record[key] = evaluatedValue;
       
  2373       }
       
  2374     }
       
  2375     dispatch({
       
  2376       type: 'SAVE_ENTITY_RECORD_START',
  1693       kind,
  2377       kind,
  1694       name
  2378       name,
       
  2379       recordId,
       
  2380       isAutosave
  1695     });
  2381     });
  1696 
  2382     let updatedRecord;
  1697     if (!entityConfig || entityConfig !== null && entityConfig !== void 0 && entityConfig.__experimentalNoFetch) {
  2383     let error;
  1698       return;
  2384     let hasError = false;
  1699     }
  2385     try {
  1700 
  2386       const path = `${entityConfig.baseURL}${recordId ? '/' + recordId : ''}`;
  1701     const entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;
  2387       const persistedRecord = select.getRawEntityRecord(kind, name, recordId);
  1702     const recordId = record[entityIdKey];
  2388       if (isAutosave) {
  1703     const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, recordId || esm_browser_v4()], {
  2389         // Most of this autosave logic is very specific to posts.
  1704       exclusive: true
  2390         // This is fine for now as it is the only supported autosave,
       
  2391         // but ideally this should all be handled in the back end,
       
  2392         // so the client just sends and receives objects.
       
  2393         const currentUser = select.getCurrentUser();
       
  2394         const currentUserId = currentUser ? currentUser.id : undefined;
       
  2395         const autosavePost = await resolveSelect.getAutosave(persistedRecord.type, persistedRecord.id, currentUserId);
       
  2396         // Autosaves need all expected fields to be present.
       
  2397         // So we fallback to the previous autosave and then
       
  2398         // to the actual persisted entity if the edits don't
       
  2399         // have a value.
       
  2400         let data = {
       
  2401           ...persistedRecord,
       
  2402           ...autosavePost,
       
  2403           ...record
       
  2404         };
       
  2405         data = Object.keys(data).reduce((acc, key) => {
       
  2406           if (['title', 'excerpt', 'content', 'meta'].includes(key)) {
       
  2407             acc[key] = data[key];
       
  2408           }
       
  2409           return acc;
       
  2410         }, {
       
  2411           // Do not update the `status` if we have edited it when auto saving.
       
  2412           // It's very important to let the user explicitly save this change,
       
  2413           // because it can lead to unexpected results. An example would be to
       
  2414           // have a draft post and change the status to publish.
       
  2415           status: data.status === 'auto-draft' ? 'draft' : undefined
       
  2416         });
       
  2417         updatedRecord = await __unstableFetch({
       
  2418           path: `${path}/autosaves`,
       
  2419           method: 'POST',
       
  2420           data
       
  2421         });
       
  2422 
       
  2423         // An autosave may be processed by the server as a regular save
       
  2424         // when its update is requested by the author and the post had
       
  2425         // draft or auto-draft status.
       
  2426         if (persistedRecord.id === updatedRecord.id) {
       
  2427           let newRecord = {
       
  2428             ...persistedRecord,
       
  2429             ...data,
       
  2430             ...updatedRecord
       
  2431           };
       
  2432           newRecord = Object.keys(newRecord).reduce((acc, key) => {
       
  2433             // These properties are persisted in autosaves.
       
  2434             if (['title', 'excerpt', 'content'].includes(key)) {
       
  2435               acc[key] = newRecord[key];
       
  2436             } else if (key === 'status') {
       
  2437               // Status is only persisted in autosaves when going from
       
  2438               // "auto-draft" to "draft".
       
  2439               acc[key] = persistedRecord.status === 'auto-draft' && newRecord.status === 'draft' ? newRecord.status : persistedRecord.status;
       
  2440             } else {
       
  2441               // These properties are not persisted in autosaves.
       
  2442               acc[key] = persistedRecord[key];
       
  2443             }
       
  2444             return acc;
       
  2445           }, {});
       
  2446           dispatch.receiveEntityRecords(kind, name, newRecord, undefined, true);
       
  2447         } else {
       
  2448           dispatch.receiveAutosaves(persistedRecord.id, updatedRecord);
       
  2449         }
       
  2450       } else {
       
  2451         let edits = record;
       
  2452         if (entityConfig.__unstablePrePersist) {
       
  2453           edits = {
       
  2454             ...edits,
       
  2455             ...entityConfig.__unstablePrePersist(persistedRecord, edits)
       
  2456           };
       
  2457         }
       
  2458         updatedRecord = await __unstableFetch({
       
  2459           path,
       
  2460           method: recordId ? 'PUT' : 'POST',
       
  2461           data: edits
       
  2462         });
       
  2463         dispatch.receiveEntityRecords(kind, name, updatedRecord, undefined, true, edits);
       
  2464       }
       
  2465     } catch (_error) {
       
  2466       hasError = true;
       
  2467       error = _error;
       
  2468     }
       
  2469     dispatch({
       
  2470       type: 'SAVE_ENTITY_RECORD_FINISH',
       
  2471       kind,
       
  2472       name,
       
  2473       recordId,
       
  2474       error,
       
  2475       isAutosave
  1705     });
  2476     });
  1706 
  2477     if (hasError && throwOnError) {
  1707     try {
  2478       throw error;
  1708       // Evaluate optimized edits.
  2479     }
  1709       // (Function edits that should be evaluated on save to avoid expensive computations on every edit.)
  2480     return updatedRecord;
  1710       for (const [key, value] of Object.entries(record)) {
  2481   } finally {
  1711         if (typeof value === 'function') {
  2482     dispatch.__unstableReleaseStoreLock(lock);
  1712           const evaluatedValue = value(select.getEditedEntityRecord(kind, name, recordId));
  2483   }
  1713           dispatch.editEntityRecord(kind, name, recordId, {
       
  1714             [key]: evaluatedValue
       
  1715           }, {
       
  1716             undoIgnore: true
       
  1717           });
       
  1718           record[key] = evaluatedValue;
       
  1719         }
       
  1720       }
       
  1721 
       
  1722       dispatch({
       
  1723         type: 'SAVE_ENTITY_RECORD_START',
       
  1724         kind,
       
  1725         name,
       
  1726         recordId,
       
  1727         isAutosave
       
  1728       });
       
  1729       let updatedRecord;
       
  1730       let error;
       
  1731       let hasError = false;
       
  1732 
       
  1733       try {
       
  1734         const path = `${entityConfig.baseURL}${recordId ? '/' + recordId : ''}`;
       
  1735         const persistedRecord = select.getRawEntityRecord(kind, name, recordId);
       
  1736 
       
  1737         if (isAutosave) {
       
  1738           // Most of this autosave logic is very specific to posts.
       
  1739           // This is fine for now as it is the only supported autosave,
       
  1740           // but ideally this should all be handled in the back end,
       
  1741           // so the client just sends and receives objects.
       
  1742           const currentUser = select.getCurrentUser();
       
  1743           const currentUserId = currentUser ? currentUser.id : undefined;
       
  1744           const autosavePost = await resolveSelect.getAutosave(persistedRecord.type, persistedRecord.id, currentUserId); // Autosaves need all expected fields to be present.
       
  1745           // So we fallback to the previous autosave and then
       
  1746           // to the actual persisted entity if the edits don't
       
  1747           // have a value.
       
  1748 
       
  1749           let data = { ...persistedRecord,
       
  1750             ...autosavePost,
       
  1751             ...record
       
  1752           };
       
  1753           data = Object.keys(data).reduce((acc, key) => {
       
  1754             if (['title', 'excerpt', 'content'].includes(key)) {
       
  1755               acc[key] = data[key];
       
  1756             }
       
  1757 
       
  1758             return acc;
       
  1759           }, {
       
  1760             status: data.status === 'auto-draft' ? 'draft' : data.status
       
  1761           });
       
  1762           updatedRecord = await __unstableFetch({
       
  1763             path: `${path}/autosaves`,
       
  1764             method: 'POST',
       
  1765             data
       
  1766           }); // An autosave may be processed by the server as a regular save
       
  1767           // when its update is requested by the author and the post had
       
  1768           // draft or auto-draft status.
       
  1769 
       
  1770           if (persistedRecord.id === updatedRecord.id) {
       
  1771             let newRecord = { ...persistedRecord,
       
  1772               ...data,
       
  1773               ...updatedRecord
       
  1774             };
       
  1775             newRecord = Object.keys(newRecord).reduce((acc, key) => {
       
  1776               // These properties are persisted in autosaves.
       
  1777               if (['title', 'excerpt', 'content'].includes(key)) {
       
  1778                 acc[key] = newRecord[key];
       
  1779               } else if (key === 'status') {
       
  1780                 // Status is only persisted in autosaves when going from
       
  1781                 // "auto-draft" to "draft".
       
  1782                 acc[key] = persistedRecord.status === 'auto-draft' && newRecord.status === 'draft' ? newRecord.status : persistedRecord.status;
       
  1783               } else {
       
  1784                 // These properties are not persisted in autosaves.
       
  1785                 acc[key] = persistedRecord[key];
       
  1786               }
       
  1787 
       
  1788               return acc;
       
  1789             }, {});
       
  1790             dispatch.receiveEntityRecords(kind, name, newRecord, undefined, true);
       
  1791           } else {
       
  1792             dispatch.receiveAutosaves(persistedRecord.id, updatedRecord);
       
  1793           }
       
  1794         } else {
       
  1795           let edits = record;
       
  1796 
       
  1797           if (entityConfig.__unstablePrePersist) {
       
  1798             edits = { ...edits,
       
  1799               ...entityConfig.__unstablePrePersist(persistedRecord, edits)
       
  1800             };
       
  1801           }
       
  1802 
       
  1803           updatedRecord = await __unstableFetch({
       
  1804             path,
       
  1805             method: recordId ? 'PUT' : 'POST',
       
  1806             data: edits
       
  1807           });
       
  1808           dispatch.receiveEntityRecords(kind, name, updatedRecord, undefined, true, edits);
       
  1809         }
       
  1810       } catch (_error) {
       
  1811         hasError = true;
       
  1812         error = _error;
       
  1813       }
       
  1814 
       
  1815       dispatch({
       
  1816         type: 'SAVE_ENTITY_RECORD_FINISH',
       
  1817         kind,
       
  1818         name,
       
  1819         recordId,
       
  1820         error,
       
  1821         isAutosave
       
  1822       });
       
  1823 
       
  1824       if (hasError && throwOnError) {
       
  1825         throw error;
       
  1826       }
       
  1827 
       
  1828       return updatedRecord;
       
  1829     } finally {
       
  1830       dispatch.__unstableReleaseStoreLock(lock);
       
  1831     }
       
  1832   };
       
  1833 };
  2484 };
       
  2485 
  1834 /**
  2486 /**
  1835  * Runs multiple core-data actions at the same time using one API request.
  2487  * Runs multiple core-data actions at the same time using one API request.
  1836  *
  2488  *
  1837  * Example:
  2489  * Example:
  1838  *
  2490  *
  1851  *                         `deleteEntityRecord`.
  2503  *                         `deleteEntityRecord`.
  1852  *
  2504  *
  1853  * @return {(thunkArgs: Object) => Promise} A promise that resolves to an array containing the return
  2505  * @return {(thunkArgs: Object) => Promise} A promise that resolves to an array containing the return
  1854  *                                          values of each function given in `requests`.
  2506  *                                          values of each function given in `requests`.
  1855  */
  2507  */
  1856 
  2508 const __experimentalBatch = requests => async ({
  1857 const __experimentalBatch = requests => async _ref6 => {
  2509   dispatch
  1858   let {
  2510 }) => {
  1859     dispatch
       
  1860   } = _ref6;
       
  1861   const batch = createBatch();
  2511   const batch = createBatch();
  1862   const api = {
  2512   const api = {
  1863     saveEntityRecord(kind, name, record, options) {
  2513     saveEntityRecord(kind, name, record, options) {
  1864       return batch.add(add => dispatch.saveEntityRecord(kind, name, record, { ...options,
  2514       return batch.add(add => dispatch.saveEntityRecord(kind, name, record, {
       
  2515         ...options,
  1865         __unstableFetch: add
  2516         __unstableFetch: add
  1866       }));
  2517       }));
  1867     },
  2518     },
  1868 
       
  1869     saveEditedEntityRecord(kind, name, recordId, options) {
  2519     saveEditedEntityRecord(kind, name, recordId, options) {
  1870       return batch.add(add => dispatch.saveEditedEntityRecord(kind, name, recordId, { ...options,
  2520       return batch.add(add => dispatch.saveEditedEntityRecord(kind, name, recordId, {
       
  2521         ...options,
  1871         __unstableFetch: add
  2522         __unstableFetch: add
  1872       }));
  2523       }));
  1873     },
  2524     },
  1874 
       
  1875     deleteEntityRecord(kind, name, recordId, query, options) {
  2525     deleteEntityRecord(kind, name, recordId, query, options) {
  1876       return batch.add(add => dispatch.deleteEntityRecord(kind, name, recordId, query, { ...options,
  2526       return batch.add(add => dispatch.deleteEntityRecord(kind, name, recordId, query, {
       
  2527         ...options,
  1877         __unstableFetch: add
  2528         __unstableFetch: add
  1878       }));
  2529       }));
  1879     }
  2530     }
  1880 
       
  1881   };
  2531   };
  1882   const resultPromises = requests.map(request => request(api));
  2532   const resultPromises = requests.map(request => request(api));
  1883   const [, ...results] = await Promise.all([batch.run(), ...resultPromises]);
  2533   const [, ...results] = await Promise.all([batch.run(), ...resultPromises]);
  1884   return results;
  2534   return results;
  1885 };
  2535 };
       
  2536 
  1886 /**
  2537 /**
  1887  * Action triggered to save an entity record's edits.
  2538  * Action triggered to save an entity record's edits.
  1888  *
  2539  *
  1889  * @param {string} kind     Kind of the entity.
  2540  * @param {string} kind     Kind of the entity.
  1890  * @param {string} name     Name of the entity.
  2541  * @param {string} name     Name of the entity.
  1891  * @param {Object} recordId ID of the record.
  2542  * @param {Object} recordId ID of the record.
  1892  * @param {Object} options  Saving options.
  2543  * @param {Object} options  Saving options.
  1893  */
  2544  */
  1894 
  2545 const saveEditedEntityRecord = (kind, name, recordId, options) => async ({
  1895 const saveEditedEntityRecord = (kind, name, recordId, options) => async _ref7 => {
  2546   select,
  1896   let {
  2547   dispatch
  1897     select,
  2548 }) => {
  1898     dispatch
       
  1899   } = _ref7;
       
  1900 
       
  1901   if (!select.hasEditsForEntityRecord(kind, name, recordId)) {
  2549   if (!select.hasEditsForEntityRecord(kind, name, recordId)) {
  1902     return;
  2550     return;
  1903   }
  2551   }
  1904 
  2552   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
  1905   const configs = await dispatch(getOrLoadEntitiesConfig(kind));
  2553   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
  1906   const entityConfig = (0,external_lodash_namespaceObject.find)(configs, {
       
  1907     kind,
       
  1908     name
       
  1909   });
       
  1910 
       
  1911   if (!entityConfig) {
  2554   if (!entityConfig) {
  1912     return;
  2555     return;
  1913   }
  2556   }
  1914 
       
  1915   const entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;
  2557   const entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;
  1916   const edits = select.getEntityRecordNonTransientEdits(kind, name, recordId);
  2558   const edits = select.getEntityRecordNonTransientEdits(kind, name, recordId);
  1917   const record = {
  2559   const record = {
  1918     [entityIdKey]: recordId,
  2560     [entityIdKey]: recordId,
  1919     ...edits
  2561     ...edits
  1920   };
  2562   };
  1921   return await dispatch.saveEntityRecord(kind, name, record, options);
  2563   return await dispatch.saveEntityRecord(kind, name, record, options);
  1922 };
  2564 };
       
  2565 
  1923 /**
  2566 /**
  1924  * Action triggered to save only specified properties for the entity.
  2567  * Action triggered to save only specified properties for the entity.
  1925  *
  2568  *
  1926  * @param {string} kind        Kind of the entity.
  2569  * @param {string} kind        Kind of the entity.
  1927  * @param {string} name        Name of the entity.
  2570  * @param {string} name        Name of the entity.
  1928  * @param {Object} recordId    ID of the record.
  2571  * @param {Object} recordId    ID of the record.
  1929  * @param {Array}  itemsToSave List of entity properties to save.
  2572  * @param {Array}  itemsToSave List of entity properties or property paths to save.
  1930  * @param {Object} options     Saving options.
  2573  * @param {Object} options     Saving options.
  1931  */
  2574  */
  1932 
  2575 const __experimentalSaveSpecifiedEntityEdits = (kind, name, recordId, itemsToSave, options) => async ({
  1933 const __experimentalSaveSpecifiedEntityEdits = (kind, name, recordId, itemsToSave, options) => async _ref8 => {
  2576   select,
  1934   let {
  2577   dispatch
  1935     select,
  2578 }) => {
  1936     dispatch
       
  1937   } = _ref8;
       
  1938 
       
  1939   if (!select.hasEditsForEntityRecord(kind, name, recordId)) {
  2579   if (!select.hasEditsForEntityRecord(kind, name, recordId)) {
  1940     return;
  2580     return;
  1941   }
  2581   }
  1942 
       
  1943   const edits = select.getEntityRecordNonTransientEdits(kind, name, recordId);
  2582   const edits = select.getEntityRecordNonTransientEdits(kind, name, recordId);
  1944   const editsToSave = {};
  2583   const editsToSave = {};
  1945 
  2584   for (const item of itemsToSave) {
  1946   for (const edit in edits) {
  2585     setNestedValue(editsToSave, item, getNestedValue(edits, item));
  1947     if (itemsToSave.some(item => item === edit)) {
  2586   }
  1948       editsToSave[edit] = edits[edit];
  2587   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
  1949     }
  2588   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
  1950   }
  2589   const entityIdKey = entityConfig?.key || DEFAULT_ENTITY_KEY;
  1951 
  2590 
       
  2591   // If a record key is provided then update the existing record.
       
  2592   // This necessitates providing `recordKey` to saveEntityRecord as part of the
       
  2593   // `record` argument (here called `editsToSave`) to stop that action creating
       
  2594   // a new record and instead cause it to update the existing record.
       
  2595   if (recordId) {
       
  2596     editsToSave[entityIdKey] = recordId;
       
  2597   }
  1952   return await dispatch.saveEntityRecord(kind, name, editsToSave, options);
  2598   return await dispatch.saveEntityRecord(kind, name, editsToSave, options);
  1953 };
  2599 };
       
  2600 
  1954 /**
  2601 /**
  1955  * Returns an action object used in signalling that Upload permissions have been received.
  2602  * Returns an action object used in signalling that Upload permissions have been received.
  1956  *
  2603  *
  1957  * @deprecated since WP 5.9, use receiveUserPermission instead.
  2604  * @deprecated since WP 5.9, use receiveUserPermission instead.
  1958  *
  2605  *
  1959  * @param {boolean} hasUploadPermissions Does the user have permission to upload files?
  2606  * @param {boolean} hasUploadPermissions Does the user have permission to upload files?
  1960  *
  2607  *
  1961  * @return {Object} Action object.
  2608  * @return {Object} Action object.
  1962  */
  2609  */
  1963 
       
  1964 function receiveUploadPermissions(hasUploadPermissions) {
  2610 function receiveUploadPermissions(hasUploadPermissions) {
  1965   external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveUploadPermissions", {
  2611   external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveUploadPermissions", {
  1966     since: '5.9',
  2612     since: '5.9',
  1967     alternative: 'receiveUserPermission'
  2613     alternative: 'receiveUserPermission'
  1968   });
  2614   });
  1969   return receiveUserPermission('create/media', hasUploadPermissions);
  2615   return receiveUserPermission('create/media', hasUploadPermissions);
  1970 }
  2616 }
       
  2617 
  1971 /**
  2618 /**
  1972  * Returns an action object used in signalling that the current user has
  2619  * Returns an action object used in signalling that the current user has
  1973  * permission to perform an action on a REST resource.
  2620  * permission to perform an action on a REST resource.
       
  2621  * Ignored from documentation as it's internal to the data store.
       
  2622  *
       
  2623  * @ignore
  1974  *
  2624  *
  1975  * @param {string}  key       A key that represents the action and REST resource.
  2625  * @param {string}  key       A key that represents the action and REST resource.
  1976  * @param {boolean} isAllowed Whether or not the user can perform the action.
  2626  * @param {boolean} isAllowed Whether or not the user can perform the action.
  1977  *
  2627  *
  1978  * @return {Object} Action object.
  2628  * @return {Object} Action object.
  1979  */
  2629  */
  1980 
       
  1981 function receiveUserPermission(key, isAllowed) {
  2630 function receiveUserPermission(key, isAllowed) {
  1982   return {
  2631   return {
  1983     type: 'RECEIVE_USER_PERMISSION',
  2632     type: 'RECEIVE_USER_PERMISSION',
  1984     key,
  2633     key,
  1985     isAllowed
  2634     isAllowed
  1986   };
  2635   };
  1987 }
  2636 }
       
  2637 
  1988 /**
  2638 /**
  1989  * Returns an action object used in signalling that the autosaves for a
  2639  * Returns an action object used in signalling that the autosaves for a
  1990  * post have been received.
  2640  * post have been received.
       
  2641  * Ignored from documentation as it's internal to the data store.
       
  2642  *
       
  2643  * @ignore
  1991  *
  2644  *
  1992  * @param {number}       postId    The id of the post that is parent to the autosave.
  2645  * @param {number}       postId    The id of the post that is parent to the autosave.
  1993  * @param {Array|Object} autosaves An array of autosaves or singular autosave object.
  2646  * @param {Array|Object} autosaves An array of autosaves or singular autosave object.
  1994  *
  2647  *
  1995  * @return {Object} Action object.
  2648  * @return {Object} Action object.
  1996  */
  2649  */
  1997 
       
  1998 function receiveAutosaves(postId, autosaves) {
  2650 function receiveAutosaves(postId, autosaves) {
  1999   return {
  2651   return {
  2000     type: 'RECEIVE_AUTOSAVES',
  2652     type: 'RECEIVE_AUTOSAVES',
  2001     postId,
  2653     postId,
  2002     autosaves: (0,external_lodash_namespaceObject.castArray)(autosaves)
  2654     autosaves: Array.isArray(autosaves) ? autosaves : [autosaves]
  2003   };
  2655   };
  2004 }
  2656 }
  2005 
  2657 
       
  2658 /**
       
  2659  * Returns an action object signalling that the fallback Navigation
       
  2660  * Menu id has been received.
       
  2661  *
       
  2662  * @param {integer} fallbackId the id of the fallback Navigation Menu
       
  2663  * @return {Object} Action object.
       
  2664  */
       
  2665 function receiveNavigationFallbackId(fallbackId) {
       
  2666   return {
       
  2667     type: 'RECEIVE_NAVIGATION_FALLBACK_ID',
       
  2668     fallbackId
       
  2669   };
       
  2670 }
       
  2671 
       
  2672 /**
       
  2673  * Returns an action object used to set the template for a given query.
       
  2674  *
       
  2675  * @param {Object} query      The lookup query.
       
  2676  * @param {string} templateId The resolved template id.
       
  2677  *
       
  2678  * @return {Object} Action object.
       
  2679  */
       
  2680 function receiveDefaultTemplateId(query, templateId) {
       
  2681   return {
       
  2682     type: 'RECEIVE_DEFAULT_TEMPLATE',
       
  2683     query,
       
  2684     templateId
       
  2685   };
       
  2686 }
       
  2687 
       
  2688 /**
       
  2689  * Action triggered to receive revision items.
       
  2690  *
       
  2691  * @param {string}        kind            Kind of the received entity record revisions.
       
  2692  * @param {string}        name            Name of the received entity record revisions.
       
  2693  * @param {number|string} recordKey       The key of the entity record whose revisions you want to fetch.
       
  2694  * @param {Array|Object}  records         Revisions received.
       
  2695  * @param {?Object}       query           Query Object.
       
  2696  * @param {?boolean}      invalidateCache Should invalidate query caches.
       
  2697  * @param {?Object}       meta            Meta information about pagination.
       
  2698  */
       
  2699 const receiveRevisions = (kind, name, recordKey, records, query, invalidateCache = false, meta) => async ({
       
  2700   dispatch
       
  2701 }) => {
       
  2702   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
       
  2703   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
       
  2704   const key = entityConfig && entityConfig?.revisionKey ? entityConfig.revisionKey : DEFAULT_ENTITY_KEY;
       
  2705   dispatch({
       
  2706     type: 'RECEIVE_ITEM_REVISIONS',
       
  2707     key,
       
  2708     items: Array.isArray(records) ? records : [records],
       
  2709     recordKey,
       
  2710     meta,
       
  2711     query,
       
  2712     kind,
       
  2713     name,
       
  2714     invalidateCache
       
  2715   });
       
  2716 };
       
  2717 
  2006 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entities.js
  2718 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entities.js
  2007 /**
  2719 /**
  2008  * External dependencies
  2720  * External dependencies
  2009  */
  2721  */
  2010 
  2722 
       
  2723 
  2011 /**
  2724 /**
  2012  * WordPress dependencies
  2725  * WordPress dependencies
  2013  */
  2726  */
       
  2727 
  2014 
  2728 
  2015 
  2729 
  2016 
  2730 
  2017 /**
  2731 /**
  2018  * Internal dependencies
  2732  * Internal dependencies
  2021 
  2735 
  2022 const DEFAULT_ENTITY_KEY = 'id';
  2736 const DEFAULT_ENTITY_KEY = 'id';
  2023 const POST_RAW_ATTRIBUTES = ['title', 'excerpt', 'content'];
  2737 const POST_RAW_ATTRIBUTES = ['title', 'excerpt', 'content'];
  2024 const rootEntitiesConfig = [{
  2738 const rootEntitiesConfig = [{
  2025   label: (0,external_wp_i18n_namespaceObject.__)('Base'),
  2739   label: (0,external_wp_i18n_namespaceObject.__)('Base'),
       
  2740   kind: 'root',
  2026   name: '__unstableBase',
  2741   name: '__unstableBase',
  2027   kind: 'root',
       
  2028   baseURL: '/',
  2742   baseURL: '/',
  2029   baseURLParams: {
  2743   baseURLParams: {
  2030     _fields: ['description', 'gmt_offset', 'home', 'name', 'site_icon', 'site_icon_url', 'site_logo', 'timezone_string', 'url'].join(',')
  2744     _fields: ['description', 'gmt_offset', 'home', 'name', 'site_icon', 'site_icon_url', 'site_logo', 'timezone_string', 'url'].join(',')
  2031   }
  2745   },
  2032 }, {
  2746   // The entity doesn't support selecting multiple records.
  2033   label: (0,external_wp_i18n_namespaceObject.__)('Site'),
  2747   // The property is maintained for backward compatibility.
  2034   name: 'site',
  2748   plural: '__unstableBases',
  2035   kind: 'root',
  2749   syncConfig: {
  2036   baseURL: '/wp/v2/settings',
  2750     fetch: async () => {
  2037   getTitle: record => {
  2751       return external_wp_apiFetch_default()({
  2038     return (0,external_lodash_namespaceObject.get)(record, ['title'], (0,external_wp_i18n_namespaceObject.__)('Site Title'));
  2752         path: '/'
  2039   }
  2753       });
       
  2754     },
       
  2755     applyChangesToDoc: (doc, changes) => {
       
  2756       const document = doc.getMap('document');
       
  2757       Object.entries(changes).forEach(([key, value]) => {
       
  2758         if (document.get(key) !== value) {
       
  2759           document.set(key, value);
       
  2760         }
       
  2761       });
       
  2762     },
       
  2763     fromCRDTDoc: doc => {
       
  2764       return doc.getMap('document').toJSON();
       
  2765     }
       
  2766   },
       
  2767   syncObjectType: 'root/base',
       
  2768   getSyncObjectId: () => 'index'
  2040 }, {
  2769 }, {
  2041   label: (0,external_wp_i18n_namespaceObject.__)('Post Type'),
  2770   label: (0,external_wp_i18n_namespaceObject.__)('Post Type'),
  2042   name: 'postType',
  2771   name: 'postType',
  2043   kind: 'root',
  2772   kind: 'root',
  2044   key: 'slug',
  2773   key: 'slug',
  2045   baseURL: '/wp/v2/types',
  2774   baseURL: '/wp/v2/types',
  2046   baseURLParams: {
  2775   baseURLParams: {
  2047     context: 'edit'
  2776     context: 'edit'
  2048   },
  2777   },
  2049   rawAttributes: POST_RAW_ATTRIBUTES
  2778   plural: 'postTypes',
       
  2779   syncConfig: {
       
  2780     fetch: async id => {
       
  2781       return external_wp_apiFetch_default()({
       
  2782         path: `/wp/v2/types/${id}?context=edit`
       
  2783       });
       
  2784     },
       
  2785     applyChangesToDoc: (doc, changes) => {
       
  2786       const document = doc.getMap('document');
       
  2787       Object.entries(changes).forEach(([key, value]) => {
       
  2788         if (document.get(key) !== value) {
       
  2789           document.set(key, value);
       
  2790         }
       
  2791       });
       
  2792     },
       
  2793     fromCRDTDoc: doc => {
       
  2794       return doc.getMap('document').toJSON();
       
  2795     }
       
  2796   },
       
  2797   syncObjectType: 'root/postType',
       
  2798   getSyncObjectId: id => id
  2050 }, {
  2799 }, {
  2051   name: 'media',
  2800   name: 'media',
  2052   kind: 'root',
  2801   kind: 'root',
  2053   baseURL: '/wp/v2/media',
  2802   baseURL: '/wp/v2/media',
  2054   baseURLParams: {
  2803   baseURLParams: {
  2055     context: 'edit'
  2804     context: 'edit'
  2056   },
  2805   },
  2057   plural: 'mediaItems',
  2806   plural: 'mediaItems',
  2058   label: (0,external_wp_i18n_namespaceObject.__)('Media'),
  2807   label: (0,external_wp_i18n_namespaceObject.__)('Media'),
  2059   rawAttributes: ['caption', 'title', 'description']
  2808   rawAttributes: ['caption', 'title', 'description'],
       
  2809   supportsPagination: true
  2060 }, {
  2810 }, {
  2061   name: 'taxonomy',
  2811   name: 'taxonomy',
  2062   kind: 'root',
  2812   kind: 'root',
  2063   key: 'slug',
  2813   key: 'slug',
  2064   baseURL: '/wp/v2/taxonomies',
  2814   baseURL: '/wp/v2/taxonomies',
  2069   label: (0,external_wp_i18n_namespaceObject.__)('Taxonomy')
  2819   label: (0,external_wp_i18n_namespaceObject.__)('Taxonomy')
  2070 }, {
  2820 }, {
  2071   name: 'sidebar',
  2821   name: 'sidebar',
  2072   kind: 'root',
  2822   kind: 'root',
  2073   baseURL: '/wp/v2/sidebars',
  2823   baseURL: '/wp/v2/sidebars',
       
  2824   baseURLParams: {
       
  2825     context: 'edit'
       
  2826   },
  2074   plural: 'sidebars',
  2827   plural: 'sidebars',
  2075   transientEdits: {
  2828   transientEdits: {
  2076     blocks: true
  2829     blocks: true
  2077   },
  2830   },
  2078   label: (0,external_wp_i18n_namespaceObject.__)('Widget areas')
  2831   label: (0,external_wp_i18n_namespaceObject.__)('Widget areas')
  2131   baseURLParams: {
  2884   baseURLParams: {
  2132     context: 'edit'
  2885     context: 'edit'
  2133   },
  2886   },
  2134   plural: 'menuItems',
  2887   plural: 'menuItems',
  2135   label: (0,external_wp_i18n_namespaceObject.__)('Menu Item'),
  2888   label: (0,external_wp_i18n_namespaceObject.__)('Menu Item'),
  2136   rawAttributes: ['title', 'content']
  2889   rawAttributes: ['title']
  2137 }, {
  2890 }, {
  2138   name: 'menuLocation',
  2891   name: 'menuLocation',
  2139   kind: 'root',
  2892   kind: 'root',
  2140   baseURL: '/wp/v2/menu-locations',
  2893   baseURL: '/wp/v2/menu-locations',
  2141   baseURLParams: {
  2894   baseURLParams: {
  2151   baseURL: '/wp/v2/global-styles',
  2904   baseURL: '/wp/v2/global-styles',
  2152   baseURLParams: {
  2905   baseURLParams: {
  2153     context: 'edit'
  2906     context: 'edit'
  2154   },
  2907   },
  2155   plural: 'globalStylesVariations',
  2908   plural: 'globalStylesVariations',
  2156   // Should be different than name.
  2909   // Should be different from name.
  2157   getTitle: record => {
  2910   getTitle: record => record?.title?.rendered || record?.title,
  2158     var _record$title;
  2911   getRevisionsUrl: (parentId, revisionId) => `/wp/v2/global-styles/${parentId}/revisions${revisionId ? '/' + revisionId : ''}`,
  2159 
  2912   supportsPagination: true
  2160     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);
       
  2161   }
       
  2162 }, {
  2913 }, {
  2163   label: (0,external_wp_i18n_namespaceObject.__)('Themes'),
  2914   label: (0,external_wp_i18n_namespaceObject.__)('Themes'),
  2164   name: 'theme',
  2915   name: 'theme',
  2165   kind: 'root',
  2916   kind: 'root',
  2166   baseURL: '/wp/v2/themes',
  2917   baseURL: '/wp/v2/themes',
  2167   baseURLParams: {
  2918   baseURLParams: {
  2168     context: 'edit'
  2919     context: 'edit'
  2169   },
  2920   },
       
  2921   plural: 'themes',
  2170   key: 'stylesheet'
  2922   key: 'stylesheet'
  2171 }, {
  2923 }, {
  2172   label: (0,external_wp_i18n_namespaceObject.__)('Plugins'),
  2924   label: (0,external_wp_i18n_namespaceObject.__)('Plugins'),
  2173   name: 'plugin',
  2925   name: 'plugin',
  2174   kind: 'root',
  2926   kind: 'root',
  2175   baseURL: '/wp/v2/plugins',
  2927   baseURL: '/wp/v2/plugins',
  2176   baseURLParams: {
  2928   baseURLParams: {
  2177     context: 'edit'
  2929     context: 'edit'
  2178   },
  2930   },
       
  2931   plural: 'plugins',
  2179   key: 'plugin'
  2932   key: 'plugin'
       
  2933 }, {
       
  2934   label: (0,external_wp_i18n_namespaceObject.__)('Status'),
       
  2935   name: 'status',
       
  2936   kind: 'root',
       
  2937   baseURL: '/wp/v2/statuses',
       
  2938   baseURLParams: {
       
  2939     context: 'edit'
       
  2940   },
       
  2941   plural: 'statuses',
       
  2942   key: 'slug'
  2180 }];
  2943 }];
  2181 const additionalEntityConfigLoaders = [{
  2944 const additionalEntityConfigLoaders = [{
  2182   kind: 'postType',
  2945   kind: 'postType',
  2183   loadEntities: loadPostTypeEntities
  2946   loadEntities: loadPostTypeEntities
  2184 }, {
  2947 }, {
  2185   kind: 'taxonomy',
  2948   kind: 'taxonomy',
  2186   loadEntities: loadTaxonomyEntities
  2949   loadEntities: loadTaxonomyEntities
       
  2950 }, {
       
  2951   kind: 'root',
       
  2952   name: 'site',
       
  2953   plural: 'sites',
       
  2954   loadEntities: loadSiteEntity
  2187 }];
  2955 }];
       
  2956 
  2188 /**
  2957 /**
  2189  * Returns a function to be used to retrieve extra edits to apply before persisting a post type.
  2958  * Returns a function to be used to retrieve extra edits to apply before persisting a post type.
  2190  *
  2959  *
  2191  * @param {Object} persistedRecord Already persisted Post
  2960  * @param {Object} persistedRecord Already persisted Post
  2192  * @param {Object} edits           Edits.
  2961  * @param {Object} edits           Edits.
  2193  * @return {Object} Updated edits.
  2962  * @return {Object} Updated edits.
  2194  */
  2963  */
  2195 
       
  2196 const prePersistPostType = (persistedRecord, edits) => {
  2964 const prePersistPostType = (persistedRecord, edits) => {
  2197   const newEdits = {};
  2965   const newEdits = {};
  2198 
  2966   if (persistedRecord?.status === 'auto-draft') {
  2199   if ((persistedRecord === null || persistedRecord === void 0 ? void 0 : persistedRecord.status) === 'auto-draft') {
       
  2200     // Saving an auto-draft should create a draft by default.
  2967     // Saving an auto-draft should create a draft by default.
  2201     if (!edits.status && !newEdits.status) {
  2968     if (!edits.status && !newEdits.status) {
  2202       newEdits.status = 'draft';
  2969       newEdits.status = 'draft';
  2203     } // Fix the auto-draft default title.
  2970     }
  2204 
  2971 
  2205 
  2972     // Fix the auto-draft default title.
  2206     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')) {
  2973     if ((!edits.title || edits.title === 'Auto Draft') && !newEdits.title && (!persistedRecord?.title || persistedRecord?.title === 'Auto Draft')) {
  2207       newEdits.title = '';
  2974       newEdits.title = '';
  2208     }
  2975     }
  2209   }
  2976   }
  2210 
       
  2211   return newEdits;
  2977   return newEdits;
  2212 };
  2978 };
       
  2979 const serialisableBlocksCache = new WeakMap();
       
  2980 function makeBlockAttributesSerializable(attributes) {
       
  2981   const newAttributes = {
       
  2982     ...attributes
       
  2983   };
       
  2984   for (const [key, value] of Object.entries(attributes)) {
       
  2985     if (value instanceof external_wp_richText_namespaceObject.RichTextData) {
       
  2986       newAttributes[key] = value.valueOf();
       
  2987     }
       
  2988   }
       
  2989   return newAttributes;
       
  2990 }
       
  2991 function makeBlocksSerializable(blocks) {
       
  2992   return blocks.map(block => {
       
  2993     const {
       
  2994       innerBlocks,
       
  2995       attributes,
       
  2996       ...rest
       
  2997     } = block;
       
  2998     return {
       
  2999       ...rest,
       
  3000       attributes: makeBlockAttributesSerializable(attributes),
       
  3001       innerBlocks: makeBlocksSerializable(innerBlocks)
       
  3002     };
       
  3003   });
       
  3004 }
       
  3005 
  2213 /**
  3006 /**
  2214  * Returns the list of post type entities.
  3007  * Returns the list of post type entities.
  2215  *
  3008  *
  2216  * @return {Promise} Entities promise
  3009  * @return {Promise} Entities promise
  2217  */
  3010  */
  2218 
       
  2219 async function loadPostTypeEntities() {
  3011 async function loadPostTypeEntities() {
  2220   const postTypes = await external_wp_apiFetch_default()({
  3012   const postTypes = await external_wp_apiFetch_default()({
  2221     path: '/wp/v2/types?context=view'
  3013     path: '/wp/v2/types?context=view'
  2222   });
  3014   });
  2223   return (0,external_lodash_namespaceObject.map)(postTypes, (postType, name) => {
  3015   return Object.entries(postTypes !== null && postTypes !== void 0 ? postTypes : {}).map(([name, postType]) => {
  2224     var _postType$rest_namesp;
  3016     var _postType$rest_namesp;
  2225 
       
  2226     const isTemplate = ['wp_template', 'wp_template_part'].includes(name);
  3017     const isTemplate = ['wp_template', 'wp_template_part'].includes(name);
  2227     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';
  3018     const namespace = (_postType$rest_namesp = postType?.rest_namespace) !== null && _postType$rest_namesp !== void 0 ? _postType$rest_namesp : 'wp/v2';
  2228     return {
  3019     return {
  2229       kind: 'postType',
  3020       kind: 'postType',
  2230       baseURL: `/${namespace}/${postType.rest_base}`,
  3021       baseURL: `/${namespace}/${postType.rest_base}`,
  2231       baseURLParams: {
  3022       baseURLParams: {
  2232         context: 'edit'
  3023         context: 'edit'
  2240       mergedEdits: {
  3031       mergedEdits: {
  2241         meta: true
  3032         meta: true
  2242       },
  3033       },
  2243       rawAttributes: POST_RAW_ATTRIBUTES,
  3034       rawAttributes: POST_RAW_ATTRIBUTES,
  2244       getTitle: record => {
  3035       getTitle: record => {
  2245         var _record$title2;
  3036         var _record$slug;
  2246 
  3037         return record?.title?.rendered || record?.title || (isTemplate ? capitalCase((_record$slug = record.slug) !== null && _record$slug !== void 0 ? _record$slug : '') : String(record.id));
  2247         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));
       
  2248       },
  3038       },
  2249       __unstablePrePersist: isTemplate ? undefined : prePersistPostType,
  3039       __unstablePrePersist: isTemplate ? undefined : prePersistPostType,
  2250       __unstable_rest_base: postType.rest_base
  3040       __unstable_rest_base: postType.rest_base,
       
  3041       syncConfig: {
       
  3042         fetch: async id => {
       
  3043           return external_wp_apiFetch_default()({
       
  3044             path: `/${namespace}/${postType.rest_base}/${id}?context=edit`
       
  3045           });
       
  3046         },
       
  3047         applyChangesToDoc: (doc, changes) => {
       
  3048           const document = doc.getMap('document');
       
  3049           Object.entries(changes).forEach(([key, value]) => {
       
  3050             if (typeof value !== 'function') {
       
  3051               if (key === 'blocks') {
       
  3052                 if (!serialisableBlocksCache.has(value)) {
       
  3053                   serialisableBlocksCache.set(value, makeBlocksSerializable(value));
       
  3054                 }
       
  3055                 value = serialisableBlocksCache.get(value);
       
  3056               }
       
  3057               if (document.get(key) !== value) {
       
  3058                 document.set(key, value);
       
  3059               }
       
  3060             }
       
  3061           });
       
  3062         },
       
  3063         fromCRDTDoc: doc => {
       
  3064           return doc.getMap('document').toJSON();
       
  3065         }
       
  3066       },
       
  3067       syncObjectType: 'postType/' + postType.name,
       
  3068       getSyncObjectId: id => id,
       
  3069       supportsPagination: true,
       
  3070       getRevisionsUrl: (parentId, revisionId) => `/${namespace}/${postType.rest_base}/${parentId}/revisions${revisionId ? '/' + revisionId : ''}`,
       
  3071       revisionKey: isTemplate ? 'wp_id' : DEFAULT_ENTITY_KEY
  2251     };
  3072     };
  2252   });
  3073   });
  2253 }
  3074 }
       
  3075 
  2254 /**
  3076 /**
  2255  * Returns the list of the taxonomies entities.
  3077  * Returns the list of the taxonomies entities.
  2256  *
  3078  *
  2257  * @return {Promise} Entities promise
  3079  * @return {Promise} Entities promise
  2258  */
  3080  */
  2259 
       
  2260 
       
  2261 async function loadTaxonomyEntities() {
  3081 async function loadTaxonomyEntities() {
  2262   const taxonomies = await external_wp_apiFetch_default()({
  3082   const taxonomies = await external_wp_apiFetch_default()({
  2263     path: '/wp/v2/taxonomies?context=view'
  3083     path: '/wp/v2/taxonomies?context=view'
  2264   });
  3084   });
  2265   return (0,external_lodash_namespaceObject.map)(taxonomies, (taxonomy, name) => {
  3085   return Object.entries(taxonomies !== null && taxonomies !== void 0 ? taxonomies : {}).map(([name, taxonomy]) => {
  2266     var _taxonomy$rest_namesp;
  3086     var _taxonomy$rest_namesp;
  2267 
  3087     const namespace = (_taxonomy$rest_namesp = taxonomy?.rest_namespace) !== null && _taxonomy$rest_namesp !== void 0 ? _taxonomy$rest_namesp : 'wp/v2';
  2268     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';
       
  2269     return {
  3088     return {
  2270       kind: 'taxonomy',
  3089       kind: 'taxonomy',
  2271       baseURL: `/${namespace}/${taxonomy.rest_base}`,
  3090       baseURL: `/${namespace}/${taxonomy.rest_base}`,
  2272       baseURLParams: {
  3091       baseURLParams: {
  2273         context: 'edit'
  3092         context: 'edit'
  2275       name,
  3094       name,
  2276       label: taxonomy.name
  3095       label: taxonomy.name
  2277     };
  3096     };
  2278   });
  3097   });
  2279 }
  3098 }
  2280 /**
  3099 
  2281  * Returns the entity's getter method name given its kind and name.
  3100 /**
       
  3101  * Returns the Site entity.
       
  3102  *
       
  3103  * @return {Promise} Entity promise
       
  3104  */
       
  3105 async function loadSiteEntity() {
       
  3106   var _site$schema$properti;
       
  3107   const entity = {
       
  3108     label: (0,external_wp_i18n_namespaceObject.__)('Site'),
       
  3109     name: 'site',
       
  3110     kind: 'root',
       
  3111     baseURL: '/wp/v2/settings',
       
  3112     syncConfig: {
       
  3113       fetch: async () => {
       
  3114         return external_wp_apiFetch_default()({
       
  3115           path: '/wp/v2/settings'
       
  3116         });
       
  3117       },
       
  3118       applyChangesToDoc: (doc, changes) => {
       
  3119         const document = doc.getMap('document');
       
  3120         Object.entries(changes).forEach(([key, value]) => {
       
  3121           if (document.get(key) !== value) {
       
  3122             document.set(key, value);
       
  3123           }
       
  3124         });
       
  3125       },
       
  3126       fromCRDTDoc: doc => {
       
  3127         return doc.getMap('document').toJSON();
       
  3128       }
       
  3129     },
       
  3130     syncObjectType: 'root/site',
       
  3131     getSyncObjectId: () => 'index',
       
  3132     meta: {}
       
  3133   };
       
  3134   const site = await external_wp_apiFetch_default()({
       
  3135     path: entity.baseURL,
       
  3136     method: 'OPTIONS'
       
  3137   });
       
  3138   const labels = {};
       
  3139   Object.entries((_site$schema$properti = site?.schema?.properties) !== null && _site$schema$properti !== void 0 ? _site$schema$properti : {}).forEach(([key, value]) => {
       
  3140     // Ignore properties `title` and `type` keys.
       
  3141     if (typeof value === 'object' && value.title) {
       
  3142       labels[key] = value.title;
       
  3143     }
       
  3144   });
       
  3145   return [{
       
  3146     ...entity,
       
  3147     meta: {
       
  3148       labels
       
  3149     }
       
  3150   }];
       
  3151 }
       
  3152 
       
  3153 /**
       
  3154  * Returns the entity's getter method name given its kind and name or plural name.
  2282  *
  3155  *
  2283  * @example
  3156  * @example
  2284  * ```js
  3157  * ```js
  2285  * const nameSingular = getMethodName( 'root', 'theme', 'get' );
  3158  * const nameSingular = getMethodName( 'root', 'theme', 'get' );
  2286  * // nameSingular is getRootTheme
  3159  * // nameSingular is getRootTheme
  2287  *
  3160  *
  2288  * const namePlural = getMethodName( 'root', 'theme', 'set' );
  3161  * const namePlural = getMethodName( 'root', 'themes', 'set' );
  2289  * // namePlural is setRootThemes
  3162  * // namePlural is setRootThemes
  2290  * ```
  3163  * ```
  2291  *
  3164  *
  2292  * @param {string}  kind      Entity kind.
  3165  * @param {string} kind   Entity kind.
  2293  * @param {string}  name      Entity name.
  3166  * @param {string} name   Entity name or plural name.
  2294  * @param {string}  prefix    Function prefix.
  3167  * @param {string} prefix Function prefix.
  2295  * @param {boolean} usePlural Whether to use the plural form or not.
       
  2296  *
  3168  *
  2297  * @return {string} Method name
  3169  * @return {string} Method name
  2298  */
  3170  */
  2299 
  3171 const getMethodName = (kind, name, prefix = 'get') => {
  2300 
  3172   const kindPrefix = kind === 'root' ? '' : pascalCase(kind);
  2301 const getMethodName = function (kind, name) {
  3173   const suffix = pascalCase(name);
  2302   let prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'get';
       
  2303   let usePlural = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
       
  2304   const entityConfig = (0,external_lodash_namespaceObject.find)(rootEntitiesConfig, {
       
  2305     kind,
       
  2306     name
       
  2307   });
       
  2308   const kindPrefix = kind === 'root' ? '' : (0,external_lodash_namespaceObject.upperFirst)((0,external_lodash_namespaceObject.camelCase)(kind));
       
  2309   const nameSuffix = (0,external_lodash_namespaceObject.upperFirst)((0,external_lodash_namespaceObject.camelCase)(name)) + (usePlural ? 's' : '');
       
  2310   const suffix = usePlural && entityConfig !== null && entityConfig !== void 0 && entityConfig.plural ? (0,external_lodash_namespaceObject.upperFirst)((0,external_lodash_namespaceObject.camelCase)(entityConfig.plural)) : nameSuffix;
       
  2311   return `${prefix}${kindPrefix}${suffix}`;
  3174   return `${prefix}${kindPrefix}${suffix}`;
  2312 };
  3175 };
  2313 /**
  3176 function registerSyncConfigs(configs) {
  2314  * Loads the kind entities into the store.
  3177   configs.forEach(({
       
  3178     syncObjectType,
       
  3179     syncConfig
       
  3180   }) => {
       
  3181     getSyncProvider().register(syncObjectType, syncConfig);
       
  3182     const editSyncConfig = {
       
  3183       ...syncConfig
       
  3184     };
       
  3185     delete editSyncConfig.fetch;
       
  3186     getSyncProvider().register(syncObjectType + '--edit', editSyncConfig);
       
  3187   });
       
  3188 }
       
  3189 
       
  3190 /**
       
  3191  * Loads the entities into the store.
       
  3192  *
       
  3193  * Note: The `name` argument is used for `root` entities requiring additional server data.
  2315  *
  3194  *
  2316  * @param {string} kind Kind
  3195  * @param {string} kind Kind
  2317  *
  3196  * @param {string} name Name
  2318  * @return {(thunkArgs: object) => Promise<Array>} Entities
  3197  * @return {(thunkArgs: object) => Promise<Array>} Entities
  2319  */
  3198  */
  2320 
  3199 const getOrLoadEntitiesConfig = (kind, name) => async ({
  2321 const getOrLoadEntitiesConfig = kind => async _ref => {
  3200   select,
  2322   let {
  3201   dispatch
  2323     select,
  3202 }) => {
  2324     dispatch
       
  2325   } = _ref;
       
  2326   let configs = select.getEntitiesConfig(kind);
  3203   let configs = select.getEntitiesConfig(kind);
  2327 
  3204   const hasConfig = !!select.getEntityConfig(kind, name);
  2328   if (configs && configs.length !== 0) {
  3205   if (configs?.length > 0 && hasConfig) {
       
  3206     if (window.__experimentalEnableSync) {
       
  3207       if (false) {}
       
  3208     }
  2329     return configs;
  3209     return configs;
  2330   }
  3210   }
  2331 
  3211   const loader = additionalEntityConfigLoaders.find(l => {
  2332   const loader = (0,external_lodash_namespaceObject.find)(additionalEntityConfigLoaders, {
  3212     if (!name || !l.name) {
  2333     kind
  3213       return l.kind === kind;
       
  3214     }
       
  3215     return l.kind === kind && l.name === name;
  2334   });
  3216   });
  2335 
       
  2336   if (!loader) {
  3217   if (!loader) {
  2337     return [];
  3218     return [];
  2338   }
  3219   }
  2339 
       
  2340   configs = await loader.loadEntities();
  3220   configs = await loader.loadEntities();
       
  3221   if (window.__experimentalEnableSync) {
       
  3222     if (false) {}
       
  3223   }
  2341   dispatch(addEntities(configs));
  3224   dispatch(addEntities(configs));
  2342   return configs;
  3225   return configs;
  2343 };
  3226 };
  2344 
  3227 
  2345 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/get-normalized-comma-separable.js
  3228 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/get-normalized-comma-separable.js
  2356   if (typeof value === 'string') {
  3239   if (typeof value === 'string') {
  2357     return value.split(',');
  3240     return value.split(',');
  2358   } else if (Array.isArray(value)) {
  3241   } else if (Array.isArray(value)) {
  2359     return value;
  3242     return value;
  2360   }
  3243   }
  2361 
       
  2362   return null;
  3244   return null;
  2363 }
  3245 }
  2364 
  3246 /* harmony default export */ const get_normalized_comma_separable = (getNormalizedCommaSeparable);
  2365 /* harmony default export */ var get_normalized_comma_separable = (getNormalizedCommaSeparable);
       
  2366 
  3247 
  2367 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/with-weak-map-cache.js
  3248 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/with-weak-map-cache.js
  2368 /**
       
  2369  * External dependencies
       
  2370  */
       
  2371 
       
  2372 /**
  3249 /**
  2373  * Given a function, returns an enhanced function which caches the result and
  3250  * Given a function, returns an enhanced function which caches the result and
  2374  * tracks in WeakMap. The result is only cached if the original function is
  3251  * tracks in WeakMap. The result is only cached if the original function is
  2375  * passed a valid object-like argument (requirement for WeakMap key).
  3252  * passed a valid object-like argument (requirement for WeakMap key).
  2376  *
  3253  *
  2377  * @param {Function} fn Original function.
  3254  * @param {Function} fn Original function.
  2378  *
  3255  *
  2379  * @return {Function} Enhanced caching function.
  3256  * @return {Function} Enhanced caching function.
  2380  */
  3257  */
  2381 
       
  2382 function withWeakMapCache(fn) {
  3258 function withWeakMapCache(fn) {
  2383   const cache = new WeakMap();
  3259   const cache = new WeakMap();
  2384   return key => {
  3260   return key => {
  2385     let value;
  3261     let value;
  2386 
       
  2387     if (cache.has(key)) {
  3262     if (cache.has(key)) {
  2388       value = cache.get(key);
  3263       value = cache.get(key);
  2389     } else {
  3264     } else {
  2390       value = fn(key); // Can reach here if key is not valid for WeakMap, since `has`
  3265       value = fn(key);
       
  3266 
       
  3267       // Can reach here if key is not valid for WeakMap, since `has`
  2391       // will return false for invalid key. Since `set` will throw,
  3268       // will return false for invalid key. Since `set` will throw,
  2392       // ensure that key is valid before setting into cache.
  3269       // ensure that key is valid before setting into cache.
  2393 
  3270       if (key !== null && typeof key === 'object') {
  2394       if ((0,external_lodash_namespaceObject.isObjectLike)(key)) {
       
  2395         cache.set(key, value);
  3271         cache.set(key, value);
  2396       }
  3272       }
  2397     }
  3273     }
  2398 
       
  2399     return value;
  3274     return value;
  2400   };
  3275   };
  2401 }
  3276 }
  2402 
  3277 /* harmony default export */ const with_weak_map_cache = (withWeakMapCache);
  2403 /* harmony default export */ var with_weak_map_cache = (withWeakMapCache);
       
  2404 
  3278 
  2405 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/get-query-parts.js
  3279 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/get-query-parts.js
  2406 /**
  3280 /**
  2407  * WordPress dependencies
  3281  * WordPress dependencies
  2408  */
  3282  */
       
  3283 
  2409 
  3284 
  2410 /**
  3285 /**
  2411  * Internal dependencies
  3286  * Internal dependencies
  2412  */
  3287  */
  2413 
  3288 
  2435  *
  3310  *
  2436  * @param {Object} query Optional query object.
  3311  * @param {Object} query Optional query object.
  2437  *
  3312  *
  2438  * @return {WPQueriedDataQueryParts} Query parts.
  3313  * @return {WPQueriedDataQueryParts} Query parts.
  2439  */
  3314  */
  2440 
       
  2441 function getQueryParts(query) {
  3315 function getQueryParts(query) {
  2442   /**
  3316   /**
  2443    * @type {WPQueriedDataQueryParts}
  3317    * @type {WPQueriedDataQueryParts}
  2444    */
  3318    */
  2445   const parts = {
  3319   const parts = {
  2447     page: 1,
  3321     page: 1,
  2448     perPage: 10,
  3322     perPage: 10,
  2449     fields: null,
  3323     fields: null,
  2450     include: null,
  3324     include: null,
  2451     context: 'default'
  3325     context: 'default'
  2452   }; // Ensure stable key by sorting keys. Also more efficient for iterating.
  3326   };
  2453 
  3327 
       
  3328   // Ensure stable key by sorting keys. Also more efficient for iterating.
  2454   const keys = Object.keys(query).sort();
  3329   const keys = Object.keys(query).sort();
  2455 
       
  2456   for (let i = 0; i < keys.length; i++) {
  3330   for (let i = 0; i < keys.length; i++) {
  2457     const key = keys[i];
  3331     const key = keys[i];
  2458     let value = query[key];
  3332     let value = query[key];
  2459 
       
  2460     switch (key) {
  3333     switch (key) {
  2461       case 'page':
  3334       case 'page':
  2462         parts[key] = Number(value);
  3335         parts[key] = Number(value);
  2463         break;
  3336         break;
  2464 
       
  2465       case 'per_page':
  3337       case 'per_page':
  2466         parts.perPage = Number(value);
  3338         parts.perPage = Number(value);
  2467         break;
  3339         break;
  2468 
       
  2469       case 'context':
  3340       case 'context':
  2470         parts.context = value;
  3341         parts.context = value;
  2471         break;
  3342         break;
  2472 
       
  2473       default:
  3343       default:
  2474         // While in theory, we could exclude "_fields" from the stableKey
  3344         // While in theory, we could exclude "_fields" from the stableKey
  2475         // because two request with different fields have the same results
  3345         // because two request with different fields have the same results
  2476         // We're not able to ensure that because the server can decide to omit
  3346         // We're not able to ensure that because the server can decide to omit
  2477         // fields from the response even if we explicitly asked for it.
  3347         // fields from the response even if we explicitly asked for it.
  2478         // Example: Asking for titles in posts without title support.
  3348         // Example: Asking for titles in posts without title support.
  2479         if (key === '_fields') {
  3349         if (key === '_fields') {
  2480           var _getNormalizedCommaSe;
  3350           var _getNormalizedCommaSe;
  2481 
  3351           parts.fields = (_getNormalizedCommaSe = get_normalized_comma_separable(value)) !== null && _getNormalizedCommaSe !== void 0 ? _getNormalizedCommaSe : [];
  2482           parts.fields = (_getNormalizedCommaSe = get_normalized_comma_separable(value)) !== null && _getNormalizedCommaSe !== void 0 ? _getNormalizedCommaSe : []; // Make sure to normalize value for `stableKey`
  3352           // Make sure to normalize value for `stableKey`
  2483 
       
  2484           value = parts.fields.join();
  3353           value = parts.fields.join();
  2485         } // Two requests with different include values cannot have same results.
  3354         }
  2486 
  3355 
  2487 
  3356         // Two requests with different include values cannot have same results.
  2488         if (key === 'include') {
  3357         if (key === 'include') {
  2489           var _getNormalizedCommaSe2;
  3358           var _getNormalizedCommaSe2;
  2490 
       
  2491           if (typeof value === 'number') {
  3359           if (typeof value === 'number') {
  2492             value = value.toString();
  3360             value = value.toString();
  2493           }
  3361           }
  2494 
  3362           parts.include = ((_getNormalizedCommaSe2 = get_normalized_comma_separable(value)) !== null && _getNormalizedCommaSe2 !== void 0 ? _getNormalizedCommaSe2 : []).map(Number);
  2495           parts.include = ((_getNormalizedCommaSe2 = get_normalized_comma_separable(value)) !== null && _getNormalizedCommaSe2 !== void 0 ? _getNormalizedCommaSe2 : []).map(Number); // Normalize value for `stableKey`.
  3363           // Normalize value for `stableKey`.
  2496 
       
  2497           value = parts.include.join();
  3364           value = parts.include.join();
  2498         } // While it could be any deterministic string, for simplicity's
  3365         }
       
  3366 
       
  3367         // While it could be any deterministic string, for simplicity's
  2499         // sake mimic querystring encoding for stable key.
  3368         // sake mimic querystring encoding for stable key.
  2500         //
  3369         //
  2501         // TODO: For consistency with PHP implementation, addQueryArgs
  3370         // TODO: For consistency with PHP implementation, addQueryArgs
  2502         // should accept a key value pair, which may optimize its
  3371         // should accept a key value pair, which may optimize its
  2503         // implementation for our use here, vs. iterating an object
  3372         // implementation for our use here, vs. iterating an object
  2504         // with only a single key.
  3373         // with only a single key.
  2505 
       
  2506 
       
  2507         parts.stableKey += (parts.stableKey ? '&' : '') + (0,external_wp_url_namespaceObject.addQueryArgs)('', {
  3374         parts.stableKey += (parts.stableKey ? '&' : '') + (0,external_wp_url_namespaceObject.addQueryArgs)('', {
  2508           [key]: value
  3375           [key]: value
  2509         }).slice(1);
  3376         }).slice(1);
  2510     }
  3377     }
  2511   }
  3378   }
  2512 
       
  2513   return parts;
  3379   return parts;
  2514 }
  3380 }
  2515 /* harmony default export */ var get_query_parts = (with_weak_map_cache(getQueryParts));
  3381 /* harmony default export */ const get_query_parts = (with_weak_map_cache(getQueryParts));
  2516 
  3382 
  2517 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/reducer.js
  3383 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/reducer.js
  2518 /**
  3384 /**
  2519  * External dependencies
       
  2520  */
       
  2521 
       
  2522 /**
       
  2523  * WordPress dependencies
  3385  * WordPress dependencies
  2524  */
  3386  */
  2525 
  3387 
  2526 
  3388 
       
  3389 
  2527 /**
  3390 /**
  2528  * Internal dependencies
  3391  * Internal dependencies
  2529  */
  3392  */
  2530 
       
  2531 
       
  2532 
  3393 
  2533 
  3394 
  2534 
  3395 
  2535 function getContextFromAction(action) {
  3396 function getContextFromAction(action) {
  2536   const {
  3397   const {
  2537     query
  3398     query
  2538   } = action;
  3399   } = action;
  2539 
       
  2540   if (!query) {
  3400   if (!query) {
  2541     return 'default';
  3401     return 'default';
  2542   }
  3402   }
  2543 
       
  2544   const queryParts = get_query_parts(query);
  3403   const queryParts = get_query_parts(query);
  2545   return queryParts.context;
  3404   return queryParts.context;
  2546 }
  3405 }
       
  3406 
  2547 /**
  3407 /**
  2548  * Returns a merged array of item IDs, given details of the received paginated
  3408  * Returns a merged array of item IDs, given details of the received paginated
  2549  * items. The array is sparse-like with `undefined` entries where holes exist.
  3409  * items. The array is sparse-like with `undefined` entries where holes exist.
  2550  *
  3410  *
  2551  * @param {?Array<number>} itemIds     Original item IDs (default empty array).
  3411  * @param {?Array<number>} itemIds     Original item IDs (default empty array).
  2553  * @param {number}         page        Page of items merged.
  3413  * @param {number}         page        Page of items merged.
  2554  * @param {number}         perPage     Number of items per page.
  3414  * @param {number}         perPage     Number of items per page.
  2555  *
  3415  *
  2556  * @return {number[]} Merged array of item IDs.
  3416  * @return {number[]} Merged array of item IDs.
  2557  */
  3417  */
  2558 
       
  2559 
       
  2560 function getMergedItemIds(itemIds, nextItemIds, page, perPage) {
  3418 function getMergedItemIds(itemIds, nextItemIds, page, perPage) {
  2561   var _itemIds$length;
  3419   var _itemIds$length;
  2562 
       
  2563   const receivedAllIds = page === 1 && perPage === -1;
  3420   const receivedAllIds = page === 1 && perPage === -1;
  2564 
       
  2565   if (receivedAllIds) {
  3421   if (receivedAllIds) {
  2566     return nextItemIds;
  3422     return nextItemIds;
  2567   }
  3423   }
  2568 
  3424   const nextItemIdsStartIndex = (page - 1) * perPage;
  2569   const nextItemIdsStartIndex = (page - 1) * perPage; // If later page has already been received, default to the larger known
  3425 
       
  3426   // If later page has already been received, default to the larger known
  2570   // size of the existing array, else calculate as extending the existing.
  3427   // size of the existing array, else calculate as extending the existing.
  2571 
  3428   const size = Math.max((_itemIds$length = itemIds?.length) !== null && _itemIds$length !== void 0 ? _itemIds$length : 0, nextItemIdsStartIndex + nextItemIds.length);
  2572   const size = Math.max((_itemIds$length = itemIds === null || itemIds === void 0 ? void 0 : itemIds.length) !== null && _itemIds$length !== void 0 ? _itemIds$length : 0, nextItemIdsStartIndex + nextItemIds.length); // Preallocate array since size is known.
  3429 
  2573 
  3430   // Preallocate array since size is known.
  2574   const mergedItemIds = new Array(size);
  3431   const mergedItemIds = new Array(size);
  2575 
       
  2576   for (let i = 0; i < size; i++) {
  3432   for (let i = 0; i < size; i++) {
  2577     // Preserve existing item ID except for subset of range of next items.
  3433     // Preserve existing item ID except for subset of range of next items.
  2578     const isInNextItemsRange = i >= nextItemIdsStartIndex && i < nextItemIdsStartIndex + nextItemIds.length;
  3434     // We need to check against the possible maximum upper boundary because
  2579     mergedItemIds[i] = isInNextItemsRange ? nextItemIds[i - nextItemIdsStartIndex] : itemIds === null || itemIds === void 0 ? void 0 : itemIds[i];
  3435     // a page could receive fewer than what was previously stored.
  2580   }
  3436     const isInNextItemsRange = i >= nextItemIdsStartIndex && i < nextItemIdsStartIndex + perPage;
  2581 
  3437     mergedItemIds[i] = isInNextItemsRange ? nextItemIds[i - nextItemIdsStartIndex] : itemIds?.[i];
       
  3438   }
  2582   return mergedItemIds;
  3439   return mergedItemIds;
  2583 }
  3440 }
       
  3441 
       
  3442 /**
       
  3443  * Helper function to filter out entities with certain IDs.
       
  3444  * Entities are keyed by their ID.
       
  3445  *
       
  3446  * @param {Object} entities Entity objects, keyed by entity ID.
       
  3447  * @param {Array}  ids      Entity IDs to filter out.
       
  3448  *
       
  3449  * @return {Object} Filtered entities.
       
  3450  */
       
  3451 function removeEntitiesById(entities, ids) {
       
  3452   return Object.fromEntries(Object.entries(entities).filter(([id]) => !ids.some(itemId => {
       
  3453     if (Number.isInteger(itemId)) {
       
  3454       return itemId === +id;
       
  3455     }
       
  3456     return itemId === id;
       
  3457   })));
       
  3458 }
       
  3459 
  2584 /**
  3460 /**
  2585  * Reducer tracking items state, keyed by ID. Items are assumed to be normal,
  3461  * Reducer tracking items state, keyed by ID. Items are assumed to be normal,
  2586  * where identifiers are common across all queries.
  3462  * where identifiers are common across all queries.
  2587  *
  3463  *
  2588  * @param {Object} state  Current state.
  3464  * @param {Object} state  Current state.
  2589  * @param {Object} action Dispatched action.
  3465  * @param {Object} action Dispatched action.
  2590  *
  3466  *
  2591  * @return {Object} Next state.
  3467  * @return {Object} Next state.
  2592  */
  3468  */
  2593 
  3469 function items(state = {}, action) {
  2594 function items() {
       
  2595   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  2596   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2597 
       
  2598   switch (action.type) {
  3470   switch (action.type) {
  2599     case 'RECEIVE_ITEMS':
  3471     case 'RECEIVE_ITEMS':
  2600       {
  3472       {
  2601         const context = getContextFromAction(action);
  3473         const context = getContextFromAction(action);
  2602         const key = action.key || DEFAULT_ENTITY_KEY;
  3474         const key = action.key || DEFAULT_ENTITY_KEY;
  2603         return { ...state,
  3475         return {
  2604           [context]: { ...state[context],
  3476           ...state,
       
  3477           [context]: {
       
  3478             ...state[context],
  2605             ...action.items.reduce((accumulator, value) => {
  3479             ...action.items.reduce((accumulator, value) => {
  2606               var _state$context;
  3480               const itemId = value?.[key];
  2607 
  3481               accumulator[itemId] = conservativeMapItem(state?.[context]?.[itemId], value);
  2608               const itemId = value[key];
       
  2609               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);
       
  2610               return accumulator;
  3482               return accumulator;
  2611             }, {})
  3483             }, {})
  2612           }
  3484           }
  2613         };
  3485         };
  2614       }
  3486       }
  2615 
       
  2616     case 'REMOVE_ITEMS':
  3487     case 'REMOVE_ITEMS':
  2617       return (0,external_lodash_namespaceObject.mapValues)(state, contextState => (0,external_lodash_namespaceObject.omit)(contextState, action.itemIds));
  3488       return Object.fromEntries(Object.entries(state).map(([itemId, contextState]) => [itemId, removeEntitiesById(contextState, action.itemIds)]));
  2618   }
  3489   }
  2619 
       
  2620   return state;
  3490   return state;
  2621 }
  3491 }
       
  3492 
  2622 /**
  3493 /**
  2623  * Reducer tracking item completeness, keyed by ID. A complete item is one for
  3494  * Reducer tracking item completeness, keyed by ID. A complete item is one for
  2624  * which all fields are known. This is used in supporting `_fields` queries,
  3495  * which all fields are known. This is used in supporting `_fields` queries,
  2625  * where not all properties associated with an entity are necessarily returned.
  3496  * where not all properties associated with an entity are necessarily returned.
  2626  * In such cases, completeness is used as an indication of whether it would be
  3497  * In such cases, completeness is used as an indication of whether it would be
  2629  * @param {Object<string,Object<string,boolean>>} state  Current state.
  3500  * @param {Object<string,Object<string,boolean>>} state  Current state.
  2630  * @param {Object}                                action Dispatched action.
  3501  * @param {Object}                                action Dispatched action.
  2631  *
  3502  *
  2632  * @return {Object<string,Object<string,boolean>>} Next state.
  3503  * @return {Object<string,Object<string,boolean>>} Next state.
  2633  */
  3504  */
  2634 
  3505 function itemIsComplete(state = {}, action) {
  2635 function itemIsComplete() {
       
  2636   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  2637   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2638 
       
  2639   switch (action.type) {
  3506   switch (action.type) {
  2640     case 'RECEIVE_ITEMS':
  3507     case 'RECEIVE_ITEMS':
  2641       {
  3508       {
  2642         const context = getContextFromAction(action);
  3509         const context = getContextFromAction(action);
  2643         const {
  3510         const {
  2644           query,
  3511           query,
  2645           key = DEFAULT_ENTITY_KEY
  3512           key = DEFAULT_ENTITY_KEY
  2646         } = action; // An item is considered complete if it is received without an associated
  3513         } = action;
       
  3514 
       
  3515         // An item is considered complete if it is received without an associated
  2647         // fields query. Ideally, this would be implemented in such a way where the
  3516         // fields query. Ideally, this would be implemented in such a way where the
  2648         // complete aggregate of all fields would satisfy completeness. Since the
  3517         // complete aggregate of all fields would satisfy completeness. Since the
  2649         // fields are not consistent across all entities, this would require
  3518         // fields are not consistent across all entities, this would require
  2650         // introspection on the REST schema for each entity to know which fields
  3519         // introspection on the REST schema for each entity to know which fields
  2651         // compose a complete item for that entity.
  3520         // compose a complete item for that entity.
  2652 
       
  2653         const queryParts = query ? get_query_parts(query) : {};
  3521         const queryParts = query ? get_query_parts(query) : {};
  2654         const isCompleteQuery = !query || !Array.isArray(queryParts.fields);
  3522         const isCompleteQuery = !query || !Array.isArray(queryParts.fields);
  2655         return { ...state,
  3523         return {
  2656           [context]: { ...state[context],
  3524           ...state,
       
  3525           [context]: {
       
  3526             ...state[context],
  2657             ...action.items.reduce((result, item) => {
  3527             ...action.items.reduce((result, item) => {
  2658               var _state$context2;
  3528               const itemId = item?.[key];
  2659 
  3529 
  2660               const itemId = item[key]; // Defer to completeness if already assigned. Technically the
  3530               // Defer to completeness if already assigned. Technically the
  2661               // data may be outdated if receiving items for a field subset.
  3531               // data may be outdated if receiving items for a field subset.
  2662 
  3532               result[itemId] = state?.[context]?.[itemId] || isCompleteQuery;
  2663               result[itemId] = (state === null || state === void 0 ? void 0 : (_state$context2 = state[context]) === null || _state$context2 === void 0 ? void 0 : _state$context2[itemId]) || isCompleteQuery;
       
  2664               return result;
  3533               return result;
  2665             }, {})
  3534             }, {})
  2666           }
  3535           }
  2667         };
  3536         };
  2668       }
  3537       }
  2669 
       
  2670     case 'REMOVE_ITEMS':
  3538     case 'REMOVE_ITEMS':
  2671       return (0,external_lodash_namespaceObject.mapValues)(state, contextState => (0,external_lodash_namespaceObject.omit)(contextState, action.itemIds));
  3539       return Object.fromEntries(Object.entries(state).map(([itemId, contextState]) => [itemId, removeEntitiesById(contextState, action.itemIds)]));
  2672   }
  3540   }
  2673 
       
  2674   return state;
  3541   return state;
  2675 }
  3542 }
       
  3543 
  2676 /**
  3544 /**
  2677  * Reducer tracking queries state, keyed by stable query key. Each reducer
  3545  * Reducer tracking queries state, keyed by stable query key. Each reducer
  2678  * query object includes `itemIds` and `requestingPageByPerPage`.
  3546  * query object includes `itemIds` and `requestingPageByPerPage`.
  2679  *
  3547  *
  2680  * @param {Object} state  Current state.
  3548  * @param {Object} state  Current state.
  2681  * @param {Object} action Dispatched action.
  3549  * @param {Object} action Dispatched action.
  2682  *
  3550  *
  2683  * @return {Object} Next state.
  3551  * @return {Object} Next state.
  2684  */
  3552  */
  2685 
  3553 const receiveQueries = (0,external_wp_compose_namespaceObject.compose)([
  2686 const receiveQueries = (0,external_lodash_namespaceObject.flowRight)([// Limit to matching action type so we don't attempt to replace action on
  3554 // Limit to matching action type so we don't attempt to replace action on
  2687 // an unhandled action.
  3555 // an unhandled action.
  2688 if_matching_action(action => 'query' in action), // Inject query parts into action for use both in `onSubKey` and reducer.
  3556 if_matching_action(action => 'query' in action),
       
  3557 // Inject query parts into action for use both in `onSubKey` and reducer.
  2689 replace_action(action => {
  3558 replace_action(action => {
  2690   // `ifMatchingAction` still passes on initialization, where state is
  3559   // `ifMatchingAction` still passes on initialization, where state is
  2691   // undefined and a query is not assigned. Avoid attempting to parse
  3560   // undefined and a query is not assigned. Avoid attempting to parse
  2692   // parts. `onSubKey` will omit by lack of `stableKey`.
  3561   // parts. `onSubKey` will omit by lack of `stableKey`.
  2693   if (action.query) {
  3562   if (action.query) {
  2694     return { ...action,
  3563     return {
       
  3564       ...action,
  2695       ...get_query_parts(action.query)
  3565       ...get_query_parts(action.query)
  2696     };
  3566     };
  2697   }
  3567   }
  2698 
       
  2699   return action;
  3568   return action;
  2700 }), on_sub_key('context'), // Queries shape is shared, but keyed by query `stableKey` part. Original
  3569 }), on_sub_key('context'),
       
  3570 // Queries shape is shared, but keyed by query `stableKey` part. Original
  2701 // reducer tracks only a single query object.
  3571 // reducer tracks only a single query object.
  2702 on_sub_key('stableKey')])(function () {
  3572 on_sub_key('stableKey')])((state = {}, action) => {
  2703   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
       
  2704   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2705   const {
  3573   const {
  2706     type,
  3574     type,
  2707     page,
  3575     page,
  2708     perPage,
  3576     perPage,
  2709     key = DEFAULT_ENTITY_KEY
  3577     key = DEFAULT_ENTITY_KEY
  2710   } = action;
  3578   } = action;
  2711 
       
  2712   if (type !== 'RECEIVE_ITEMS') {
  3579   if (type !== 'RECEIVE_ITEMS') {
  2713     return state;
  3580     return state;
  2714   }
  3581   }
  2715 
  3582   return {
  2716   return getMergedItemIds(state || [], (0,external_lodash_namespaceObject.map)(action.items, key), page, perPage);
  3583     itemIds: getMergedItemIds(state?.itemIds || [], action.items.map(item => item?.[key]).filter(Boolean), page, perPage),
       
  3584     meta: action.meta
       
  3585   };
  2717 });
  3586 });
       
  3587 
  2718 /**
  3588 /**
  2719  * Reducer tracking queries state.
  3589  * Reducer tracking queries state.
  2720  *
  3590  *
  2721  * @param {Object} state  Current state.
  3591  * @param {Object} state  Current state.
  2722  * @param {Object} action Dispatched action.
  3592  * @param {Object} action Dispatched action.
  2723  *
  3593  *
  2724  * @return {Object} Next state.
  3594  * @return {Object} Next state.
  2725  */
  3595  */
  2726 
  3596 const queries = (state = {}, action) => {
  2727 const queries = function () {
       
  2728   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  2729   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2730 
       
  2731   switch (action.type) {
  3597   switch (action.type) {
  2732     case 'RECEIVE_ITEMS':
  3598     case 'RECEIVE_ITEMS':
  2733       return receiveQueries(state, action);
  3599       return receiveQueries(state, action);
  2734 
       
  2735     case 'REMOVE_ITEMS':
  3600     case 'REMOVE_ITEMS':
  2736       const removedItems = action.itemIds.reduce((result, itemId) => {
  3601       const removedItems = action.itemIds.reduce((result, itemId) => {
  2737         result[itemId] = true;
  3602         result[itemId] = true;
  2738         return result;
  3603         return result;
  2739       }, {});
  3604       }, {});
  2740       return (0,external_lodash_namespaceObject.mapValues)(state, contextQueries => {
  3605       return Object.fromEntries(Object.entries(state).map(([queryGroup, contextQueries]) => [queryGroup, Object.fromEntries(Object.entries(contextQueries).map(([query, queryItems]) => [query, {
  2741         return (0,external_lodash_namespaceObject.mapValues)(contextQueries, queryItems => {
  3606         ...queryItems,
  2742           return (0,external_lodash_namespaceObject.filter)(queryItems, queryId => {
  3607         itemIds: queryItems.itemIds.filter(queryId => !removedItems[queryId])
  2743             return !removedItems[queryId];
  3608       }]))]));
  2744           });
       
  2745         });
       
  2746       });
       
  2747 
       
  2748     default:
  3609     default:
  2749       return state;
  3610       return state;
  2750   }
  3611   }
  2751 };
  3612 };
  2752 
  3613 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  2753 /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
       
  2754   items,
  3614   items,
  2755   itemIsComplete,
  3615   itemIsComplete,
  2756   queries
  3616   queries
  2757 }));
  3617 }));
  2758 
  3618 
  2759 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/reducer.js
  3619 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/reducer.js
  2760 /**
  3620 /**
  2761  * External dependencies
  3621  * External dependencies
  2762  */
  3622  */
  2763 
  3623 
       
  3624 
  2764 /**
  3625 /**
  2765  * WordPress dependencies
  3626  * WordPress dependencies
  2766  */
  3627  */
       
  3628 
  2767 
  3629 
  2768 
  3630 
  2769 
  3631 
  2770 /**
  3632 /**
  2771  * Internal dependencies
  3633  * Internal dependencies
  2785  * @param {Object} state  Current state.
  3647  * @param {Object} state  Current state.
  2786  * @param {Object} action Dispatched action.
  3648  * @param {Object} action Dispatched action.
  2787  *
  3649  *
  2788  * @return {Object} Updated state.
  3650  * @return {Object} Updated state.
  2789  */
  3651  */
  2790 
  3652 function terms(state = {}, action) {
  2791 function terms() {
       
  2792   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  2793   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2794 
       
  2795   switch (action.type) {
  3653   switch (action.type) {
  2796     case 'RECEIVE_TERMS':
  3654     case 'RECEIVE_TERMS':
  2797       return { ...state,
  3655       return {
       
  3656         ...state,
  2798         [action.taxonomy]: action.terms
  3657         [action.taxonomy]: action.terms
  2799       };
  3658       };
  2800   }
  3659   }
  2801 
       
  2802   return state;
  3660   return state;
  2803 }
  3661 }
       
  3662 
  2804 /**
  3663 /**
  2805  * Reducer managing authors state. Keyed by id.
  3664  * Reducer managing authors state. Keyed by id.
  2806  *
  3665  *
  2807  * @param {Object} state  Current state.
  3666  * @param {Object} state  Current state.
  2808  * @param {Object} action Dispatched action.
  3667  * @param {Object} action Dispatched action.
  2809  *
  3668  *
  2810  * @return {Object} Updated state.
  3669  * @return {Object} Updated state.
  2811  */
  3670  */
  2812 
  3671 function users(state = {
  2813 function users() {
  3672   byId: {},
  2814   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  3673   queries: {}
  2815     byId: {},
  3674 }, action) {
  2816     queries: {}
       
  2817   };
       
  2818   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2819 
       
  2820   switch (action.type) {
  3675   switch (action.type) {
  2821     case 'RECEIVE_USER_QUERY':
  3676     case 'RECEIVE_USER_QUERY':
  2822       return {
  3677       return {
  2823         byId: { ...state.byId,
  3678         byId: {
  2824           ...(0,external_lodash_namespaceObject.keyBy)(action.users, 'id')
  3679           ...state.byId,
       
  3680           // Key users by their ID.
       
  3681           ...action.users.reduce((newUsers, user) => ({
       
  3682             ...newUsers,
       
  3683             [user.id]: user
       
  3684           }), {})
  2825         },
  3685         },
  2826         queries: { ...state.queries,
  3686         queries: {
  2827           [action.queryID]: (0,external_lodash_namespaceObject.map)(action.users, user => user.id)
  3687           ...state.queries,
       
  3688           [action.queryID]: action.users.map(user => user.id)
  2828         }
  3689         }
  2829       };
  3690       };
  2830   }
  3691   }
  2831 
       
  2832   return state;
  3692   return state;
  2833 }
  3693 }
       
  3694 
  2834 /**
  3695 /**
  2835  * Reducer managing current user state.
  3696  * Reducer managing current user state.
  2836  *
  3697  *
  2837  * @param {Object} state  Current state.
  3698  * @param {Object} state  Current state.
  2838  * @param {Object} action Dispatched action.
  3699  * @param {Object} action Dispatched action.
  2839  *
  3700  *
  2840  * @return {Object} Updated state.
  3701  * @return {Object} Updated state.
  2841  */
  3702  */
  2842 
  3703 function currentUser(state = {}, action) {
  2843 function currentUser() {
       
  2844   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  2845   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2846 
       
  2847   switch (action.type) {
  3704   switch (action.type) {
  2848     case 'RECEIVE_CURRENT_USER':
  3705     case 'RECEIVE_CURRENT_USER':
  2849       return action.currentUser;
  3706       return action.currentUser;
  2850   }
  3707   }
  2851 
       
  2852   return state;
  3708   return state;
  2853 }
  3709 }
       
  3710 
  2854 /**
  3711 /**
  2855  * Reducer managing taxonomies.
  3712  * Reducer managing taxonomies.
  2856  *
  3713  *
  2857  * @param {Object} state  Current state.
  3714  * @param {Object} state  Current state.
  2858  * @param {Object} action Dispatched action.
  3715  * @param {Object} action Dispatched action.
  2859  *
  3716  *
  2860  * @return {Object} Updated state.
  3717  * @return {Object} Updated state.
  2861  */
  3718  */
  2862 
  3719 function taxonomies(state = [], action) {
  2863 function taxonomies() {
       
  2864   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
       
  2865   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2866 
       
  2867   switch (action.type) {
  3720   switch (action.type) {
  2868     case 'RECEIVE_TAXONOMIES':
  3721     case 'RECEIVE_TAXONOMIES':
  2869       return action.taxonomies;
  3722       return action.taxonomies;
  2870   }
  3723   }
  2871 
       
  2872   return state;
  3724   return state;
  2873 }
  3725 }
       
  3726 
  2874 /**
  3727 /**
  2875  * Reducer managing the current theme.
  3728  * Reducer managing the current theme.
  2876  *
  3729  *
  2877  * @param {string|undefined} state  Current state.
  3730  * @param {string|undefined} state  Current state.
  2878  * @param {Object}           action Dispatched action.
  3731  * @param {Object}           action Dispatched action.
  2879  *
  3732  *
  2880  * @return {string|undefined} Updated state.
  3733  * @return {string|undefined} Updated state.
  2881  */
  3734  */
  2882 
  3735 function currentTheme(state = undefined, action) {
  2883 function currentTheme() {
       
  2884   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
       
  2885   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2886 
       
  2887   switch (action.type) {
  3736   switch (action.type) {
  2888     case 'RECEIVE_CURRENT_THEME':
  3737     case 'RECEIVE_CURRENT_THEME':
  2889       return action.currentTheme.stylesheet;
  3738       return action.currentTheme.stylesheet;
  2890   }
  3739   }
  2891 
       
  2892   return state;
  3740   return state;
  2893 }
  3741 }
       
  3742 
  2894 /**
  3743 /**
  2895  * Reducer managing the current global styles id.
  3744  * Reducer managing the current global styles id.
  2896  *
  3745  *
  2897  * @param {string|undefined} state  Current state.
  3746  * @param {string|undefined} state  Current state.
  2898  * @param {Object}           action Dispatched action.
  3747  * @param {Object}           action Dispatched action.
  2899  *
  3748  *
  2900  * @return {string|undefined} Updated state.
  3749  * @return {string|undefined} Updated state.
  2901  */
  3750  */
  2902 
  3751 function currentGlobalStylesId(state = undefined, action) {
  2903 function currentGlobalStylesId() {
       
  2904   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
       
  2905   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2906 
       
  2907   switch (action.type) {
  3752   switch (action.type) {
  2908     case 'RECEIVE_CURRENT_GLOBAL_STYLES_ID':
  3753     case 'RECEIVE_CURRENT_GLOBAL_STYLES_ID':
  2909       return action.id;
  3754       return action.id;
  2910   }
  3755   }
  2911 
       
  2912   return state;
  3756   return state;
  2913 }
  3757 }
       
  3758 
  2914 /**
  3759 /**
  2915  * Reducer managing the theme base global styles.
  3760  * Reducer managing the theme base global styles.
  2916  *
  3761  *
  2917  * @param {Record<string, object>} state  Current state.
  3762  * @param {Record<string, object>} state  Current state.
  2918  * @param {Object}                 action Dispatched action.
  3763  * @param {Object}                 action Dispatched action.
  2919  *
  3764  *
  2920  * @return {Record<string, object>} Updated state.
  3765  * @return {Record<string, object>} Updated state.
  2921  */
  3766  */
  2922 
  3767 function themeBaseGlobalStyles(state = {}, action) {
  2923 function themeBaseGlobalStyles() {
       
  2924   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  2925   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2926 
       
  2927   switch (action.type) {
  3768   switch (action.type) {
  2928     case 'RECEIVE_THEME_GLOBAL_STYLES':
  3769     case 'RECEIVE_THEME_GLOBAL_STYLES':
  2929       return { ...state,
  3770       return {
       
  3771         ...state,
  2930         [action.stylesheet]: action.globalStyles
  3772         [action.stylesheet]: action.globalStyles
  2931       };
  3773       };
  2932   }
  3774   }
  2933 
       
  2934   return state;
  3775   return state;
  2935 }
  3776 }
       
  3777 
  2936 /**
  3778 /**
  2937  * Reducer managing the theme global styles variations.
  3779  * Reducer managing the theme global styles variations.
  2938  *
  3780  *
  2939  * @param {Record<string, object>} state  Current state.
  3781  * @param {Record<string, object>} state  Current state.
  2940  * @param {Object}                 action Dispatched action.
  3782  * @param {Object}                 action Dispatched action.
  2941  *
  3783  *
  2942  * @return {Record<string, object>} Updated state.
  3784  * @return {Record<string, object>} Updated state.
  2943  */
  3785  */
  2944 
  3786 function themeGlobalStyleVariations(state = {}, action) {
  2945 function themeGlobalStyleVariations() {
       
  2946   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  2947   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2948 
       
  2949   switch (action.type) {
  3787   switch (action.type) {
  2950     case 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS':
  3788     case 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS':
  2951       return { ...state,
  3789       return {
       
  3790         ...state,
  2952         [action.stylesheet]: action.variations
  3791         [action.stylesheet]: action.variations
  2953       };
  3792       };
  2954   }
  3793   }
  2955 
       
  2956   return state;
  3794   return state;
  2957 }
  3795 }
       
  3796 const withMultiEntityRecordEdits = reducer => (state, action) => {
       
  3797   if (action.type === 'UNDO' || action.type === 'REDO') {
       
  3798     const {
       
  3799       record
       
  3800     } = action;
       
  3801     let newState = state;
       
  3802     record.forEach(({
       
  3803       id: {
       
  3804         kind,
       
  3805         name,
       
  3806         recordId
       
  3807       },
       
  3808       changes
       
  3809     }) => {
       
  3810       newState = reducer(newState, {
       
  3811         type: 'EDIT_ENTITY_RECORD',
       
  3812         kind,
       
  3813         name,
       
  3814         recordId,
       
  3815         edits: Object.entries(changes).reduce((acc, [key, value]) => {
       
  3816           acc[key] = action.type === 'UNDO' ? value.from : value.to;
       
  3817           return acc;
       
  3818         }, {})
       
  3819       });
       
  3820     });
       
  3821     return newState;
       
  3822   }
       
  3823   return reducer(state, action);
       
  3824 };
       
  3825 
  2958 /**
  3826 /**
  2959  * Higher Order Reducer for a given entity config. It supports:
  3827  * Higher Order Reducer for a given entity config. It supports:
  2960  *
  3828  *
  2961  *  - Fetching
  3829  *  - Fetching
  2962  *  - Editing
  3830  *  - Editing
  2964  *
  3832  *
  2965  * @param {Object} entityConfig Entity config.
  3833  * @param {Object} entityConfig Entity config.
  2966  *
  3834  *
  2967  * @return {AnyFunction} Reducer.
  3835  * @return {AnyFunction} Reducer.
  2968  */
  3836  */
  2969 
       
  2970 function entity(entityConfig) {
  3837 function entity(entityConfig) {
  2971   return (0,external_lodash_namespaceObject.flowRight)([// Limit to matching action type so we don't attempt to replace action on
  3838   return (0,external_wp_compose_namespaceObject.compose)([withMultiEntityRecordEdits,
       
  3839   // Limit to matching action type so we don't attempt to replace action on
  2972   // an unhandled action.
  3840   // an unhandled action.
  2973   if_matching_action(action => action.name && action.kind && action.name === entityConfig.name && action.kind === entityConfig.kind), // Inject the entity config into the action.
  3841   if_matching_action(action => action.name && action.kind && action.name === entityConfig.name && action.kind === entityConfig.kind),
       
  3842   // Inject the entity config into the action.
  2974   replace_action(action => {
  3843   replace_action(action => {
  2975     return { ...action,
  3844     return {
  2976       key: entityConfig.key || DEFAULT_ENTITY_KEY
  3845       key: entityConfig.key || DEFAULT_ENTITY_KEY,
       
  3846       ...action
  2977     };
  3847     };
  2978   })])((0,external_wp_data_namespaceObject.combineReducers)({
  3848   })])((0,external_wp_data_namespaceObject.combineReducers)({
  2979     queriedData: reducer,
  3849     queriedData: reducer,
  2980     edits: function () {
  3850     edits: (state = {}, action) => {
  2981       var _action$query$context, _action$query;
  3851       var _action$query$context;
  2982 
       
  2983       let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  2984       let action = arguments.length > 1 ? arguments[1] : undefined;
       
  2985 
       
  2986       switch (action.type) {
  3852       switch (action.type) {
  2987         case 'RECEIVE_ITEMS':
  3853         case 'RECEIVE_ITEMS':
  2988           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';
  3854           const context = (_action$query$context = action?.query?.context) !== null && _action$query$context !== void 0 ? _action$query$context : 'default';
  2989 
       
  2990           if (context !== 'default') {
  3855           if (context !== 'default') {
  2991             return state;
  3856             return state;
  2992           }
  3857           }
  2993 
  3858           const nextState = {
  2994           const nextState = { ...state
  3859             ...state
  2995           };
  3860           };
  2996 
       
  2997           for (const record of action.items) {
  3861           for (const record of action.items) {
  2998             const recordId = record[action.key];
  3862             const recordId = record?.[action.key];
  2999             const edits = nextState[recordId];
  3863             const edits = nextState[recordId];
  3000 
       
  3001             if (!edits) {
  3864             if (!edits) {
  3002               continue;
  3865               continue;
  3003             }
  3866             }
  3004 
       
  3005             const nextEdits = Object.keys(edits).reduce((acc, key) => {
  3867             const nextEdits = Object.keys(edits).reduce((acc, key) => {
       
  3868               var _record$key$raw;
  3006               // If the edited value is still different to the persisted value,
  3869               // If the edited value is still different to the persisted value,
  3007               // keep the edited value in edits.
  3870               // keep the edited value in edits.
  3008               if ( // Edits are the "raw" attribute values, but records may have
  3871               if (
       
  3872               // Edits are the "raw" attribute values, but records may have
  3009               // objects with more properties, so we use `get` here for the
  3873               // objects with more properties, so we use `get` here for the
  3010               // comparison.
  3874               // comparison.
  3011               !(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
  3875               !es6_default()(edits[key], (_record$key$raw = record[key]?.raw) !== null && _record$key$raw !== void 0 ? _record$key$raw : record[key]) && (
       
  3876               // Sometimes the server alters the sent value which means
  3012               // we need to also remove the edits before the api request.
  3877               // we need to also remove the edits before the api request.
  3013               !action.persistedEdits || !(0,external_lodash_namespaceObject.isEqual)(edits[key], action.persistedEdits[key]))) {
  3878               !action.persistedEdits || !es6_default()(edits[key], action.persistedEdits[key]))) {
  3014                 acc[key] = edits[key];
  3879                 acc[key] = edits[key];
  3015               }
  3880               }
  3016 
       
  3017               return acc;
  3881               return acc;
  3018             }, {});
  3882             }, {});
  3019 
       
  3020             if (Object.keys(nextEdits).length) {
  3883             if (Object.keys(nextEdits).length) {
  3021               nextState[recordId] = nextEdits;
  3884               nextState[recordId] = nextEdits;
  3022             } else {
  3885             } else {
  3023               delete nextState[recordId];
  3886               delete nextState[recordId];
  3024             }
  3887             }
  3025           }
  3888           }
  3026 
       
  3027           return nextState;
  3889           return nextState;
  3028 
       
  3029         case 'EDIT_ENTITY_RECORD':
  3890         case 'EDIT_ENTITY_RECORD':
  3030           const nextEdits = { ...state[action.recordId],
  3891           const nextEdits = {
       
  3892             ...state[action.recordId],
  3031             ...action.edits
  3893             ...action.edits
  3032           };
  3894           };
  3033           Object.keys(nextEdits).forEach(key => {
  3895           Object.keys(nextEdits).forEach(key => {
  3034             // Delete cleared edits so that the properties
  3896             // Delete cleared edits so that the properties
  3035             // are not considered dirty.
  3897             // are not considered dirty.
  3036             if (nextEdits[key] === undefined) {
  3898             if (nextEdits[key] === undefined) {
  3037               delete nextEdits[key];
  3899               delete nextEdits[key];
  3038             }
  3900             }
  3039           });
  3901           });
  3040           return { ...state,
  3902           return {
       
  3903             ...state,
  3041             [action.recordId]: nextEdits
  3904             [action.recordId]: nextEdits
  3042           };
  3905           };
  3043       }
  3906       }
  3044 
       
  3045       return state;
  3907       return state;
  3046     },
  3908     },
  3047     saving: function () {
  3909     saving: (state = {}, action) => {
  3048       let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  3049       let action = arguments.length > 1 ? arguments[1] : undefined;
       
  3050 
       
  3051       switch (action.type) {
  3910       switch (action.type) {
  3052         case 'SAVE_ENTITY_RECORD_START':
  3911         case 'SAVE_ENTITY_RECORD_START':
  3053         case 'SAVE_ENTITY_RECORD_FINISH':
  3912         case 'SAVE_ENTITY_RECORD_FINISH':
  3054           return { ...state,
  3913           return {
       
  3914             ...state,
  3055             [action.recordId]: {
  3915             [action.recordId]: {
  3056               pending: action.type === 'SAVE_ENTITY_RECORD_START',
  3916               pending: action.type === 'SAVE_ENTITY_RECORD_START',
  3057               error: action.error,
  3917               error: action.error,
  3058               isAutosave: action.isAutosave
  3918               isAutosave: action.isAutosave
  3059             }
  3919             }
  3060           };
  3920           };
  3061       }
  3921       }
  3062 
       
  3063       return state;
  3922       return state;
  3064     },
  3923     },
  3065     deleting: function () {
  3924     deleting: (state = {}, action) => {
  3066       let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  3067       let action = arguments.length > 1 ? arguments[1] : undefined;
       
  3068 
       
  3069       switch (action.type) {
  3925       switch (action.type) {
  3070         case 'DELETE_ENTITY_RECORD_START':
  3926         case 'DELETE_ENTITY_RECORD_START':
  3071         case 'DELETE_ENTITY_RECORD_FINISH':
  3927         case 'DELETE_ENTITY_RECORD_FINISH':
  3072           return { ...state,
  3928           return {
       
  3929             ...state,
  3073             [action.recordId]: {
  3930             [action.recordId]: {
  3074               pending: action.type === 'DELETE_ENTITY_RECORD_START',
  3931               pending: action.type === 'DELETE_ENTITY_RECORD_START',
  3075               error: action.error
  3932               error: action.error
  3076             }
  3933             }
  3077           };
  3934           };
  3078       }
  3935       }
  3079 
       
  3080       return state;
  3936       return state;
       
  3937     },
       
  3938     revisions: (state = {}, action) => {
       
  3939       // Use the same queriedDataReducer shape for revisions.
       
  3940       if (action.type === 'RECEIVE_ITEM_REVISIONS') {
       
  3941         const recordKey = action.recordKey;
       
  3942         delete action.recordKey;
       
  3943         const newState = reducer(state[recordKey], {
       
  3944           ...action,
       
  3945           type: 'RECEIVE_ITEMS'
       
  3946         });
       
  3947         return {
       
  3948           ...state,
       
  3949           [recordKey]: newState
       
  3950         };
       
  3951       }
       
  3952       if (action.type === 'REMOVE_ITEMS') {
       
  3953         return Object.fromEntries(Object.entries(state).filter(([id]) => !action.itemIds.some(itemId => {
       
  3954           if (Number.isInteger(itemId)) {
       
  3955             return itemId === +id;
       
  3956           }
       
  3957           return itemId === id;
       
  3958         })));
       
  3959       }
       
  3960       return state;
  3081     }
  3961     }
  3082   }));
  3962   }));
  3083 }
  3963 }
       
  3964 
  3084 /**
  3965 /**
  3085  * Reducer keeping track of the registered entities.
  3966  * Reducer keeping track of the registered entities.
  3086  *
  3967  *
  3087  * @param {Object} state  Current state.
  3968  * @param {Object} state  Current state.
  3088  * @param {Object} action Dispatched action.
  3969  * @param {Object} action Dispatched action.
  3089  *
  3970  *
  3090  * @return {Object} Updated state.
  3971  * @return {Object} Updated state.
  3091  */
  3972  */
  3092 
  3973 function entitiesConfig(state = rootEntitiesConfig, action) {
  3093 
       
  3094 function entitiesConfig() {
       
  3095   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : rootEntitiesConfig;
       
  3096   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  3097 
       
  3098   switch (action.type) {
  3974   switch (action.type) {
  3099     case 'ADD_ENTITIES':
  3975     case 'ADD_ENTITIES':
  3100       return [...state, ...action.entities];
  3976       return [...state, ...action.entities];
  3101   }
  3977   }
  3102 
       
  3103   return state;
  3978   return state;
  3104 }
  3979 }
       
  3980 
  3105 /**
  3981 /**
  3106  * Reducer keeping track of the registered entities config and data.
  3982  * Reducer keeping track of the registered entities config and data.
  3107  *
  3983  *
  3108  * @param {Object} state  Current state.
  3984  * @param {Object} state  Current state.
  3109  * @param {Object} action Dispatched action.
  3985  * @param {Object} action Dispatched action.
  3110  *
  3986  *
  3111  * @return {Object} Updated state.
  3987  * @return {Object} Updated state.
  3112  */
  3988  */
  3113 
  3989 const entities = (state = {}, action) => {
  3114 const entities = function () {
  3990   const newConfig = entitiesConfig(state.config, action);
  3115   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3991 
  3116   let action = arguments.length > 1 ? arguments[1] : undefined;
  3992   // Generates a dynamic reducer for the entities.
  3117   const newConfig = entitiesConfig(state.config, action); // Generates a dynamic reducer for the entities.
       
  3118 
       
  3119   let entitiesDataReducer = state.reducer;
  3993   let entitiesDataReducer = state.reducer;
  3120 
       
  3121   if (!entitiesDataReducer || newConfig !== state.config) {
  3994   if (!entitiesDataReducer || newConfig !== state.config) {
  3122     const entitiesByKind = (0,external_lodash_namespaceObject.groupBy)(newConfig, 'kind');
  3995     const entitiesByKind = newConfig.reduce((acc, record) => {
  3123     entitiesDataReducer = (0,external_wp_data_namespaceObject.combineReducers)(Object.entries(entitiesByKind).reduce((memo, _ref) => {
  3996       const {
  3124       let [kind, subEntities] = _ref;
  3997         kind
  3125       const kindReducer = (0,external_wp_data_namespaceObject.combineReducers)(subEntities.reduce((kindMemo, entityConfig) => ({ ...kindMemo,
  3998       } = record;
       
  3999       if (!acc[kind]) {
       
  4000         acc[kind] = [];
       
  4001       }
       
  4002       acc[kind].push(record);
       
  4003       return acc;
       
  4004     }, {});
       
  4005     entitiesDataReducer = (0,external_wp_data_namespaceObject.combineReducers)(Object.entries(entitiesByKind).reduce((memo, [kind, subEntities]) => {
       
  4006       const kindReducer = (0,external_wp_data_namespaceObject.combineReducers)(subEntities.reduce((kindMemo, entityConfig) => ({
       
  4007         ...kindMemo,
  3126         [entityConfig.name]: entity(entityConfig)
  4008         [entityConfig.name]: entity(entityConfig)
  3127       }), {}));
  4009       }), {}));
  3128       memo[kind] = kindReducer;
  4010       memo[kind] = kindReducer;
  3129       return memo;
  4011       return memo;
  3130     }, {}));
  4012     }, {}));
  3131   }
  4013   }
  3132 
       
  3133   const newData = entitiesDataReducer(state.records, action);
  4014   const newData = entitiesDataReducer(state.records, action);
  3134 
       
  3135   if (newData === state.records && newConfig === state.config && entitiesDataReducer === state.reducer) {
  4015   if (newData === state.records && newConfig === state.config && entitiesDataReducer === state.reducer) {
  3136     return state;
  4016     return state;
  3137   }
  4017   }
  3138 
       
  3139   return {
  4018   return {
  3140     reducer: entitiesDataReducer,
  4019     reducer: entitiesDataReducer,
  3141     records: newData,
  4020     records: newData,
  3142     config: newConfig
  4021     config: newConfig
  3143   };
  4022   };
  3144 };
  4023 };
  3145 /**
  4024 
  3146  * @typedef {Object} UndoStateMeta
  4025 /**
  3147  *
  4026  * @type {UndoManager}
  3148  * @property {number} offset          Where in the undo stack we are.
  4027  */
  3149  * @property {Object} [flattenedUndo] Flattened form of undo stack.
  4028 function undoManager(state = (0,build_module.createUndoManager)()) {
  3150  */
  4029   return state;
  3151 
  4030 }
  3152 /** @typedef {Array<Object> & UndoStateMeta} UndoState */
  4031 function editsReference(state = {}, action) {
  3153 
       
  3154 /**
       
  3155  * @type {UndoState}
       
  3156  *
       
  3157  * @todo Given how we use this we might want to make a custom class for it.
       
  3158  */
       
  3159 
       
  3160 const UNDO_INITIAL_STATE = Object.assign([], {
       
  3161   offset: 0
       
  3162 });
       
  3163 /** @type {Object} */
       
  3164 
       
  3165 let lastEditAction;
       
  3166 /**
       
  3167  * Reducer keeping track of entity edit undo history.
       
  3168  *
       
  3169  * @param {UndoState} state  Current state.
       
  3170  * @param {Object}    action Dispatched action.
       
  3171  *
       
  3172  * @return {UndoState} Updated state.
       
  3173  */
       
  3174 
       
  3175 function reducer_undo() {
       
  3176   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : UNDO_INITIAL_STATE;
       
  3177   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  3178 
       
  3179   switch (action.type) {
  4032   switch (action.type) {
  3180     case 'EDIT_ENTITY_RECORD':
  4033     case 'EDIT_ENTITY_RECORD':
  3181     case 'CREATE_UNDO_LEVEL':
  4034     case 'UNDO':
  3182       let isCreateUndoLevel = action.type === 'CREATE_UNDO_LEVEL';
  4035     case 'REDO':
  3183       const isUndoOrRedo = !isCreateUndoLevel && (action.meta.isUndo || action.meta.isRedo);
  4036       return {};
  3184 
  4037   }
  3185       if (isCreateUndoLevel) {
       
  3186         action = lastEditAction;
       
  3187       } else if (!isUndoOrRedo) {
       
  3188         // Don't lose the last edit cache if the new one only has transient edits.
       
  3189         // Transient edits don't create new levels so updating the cache would make
       
  3190         // us skip an edit later when creating levels explicitly.
       
  3191         if (Object.keys(action.edits).some(key => !action.transientEdits[key])) {
       
  3192           lastEditAction = action;
       
  3193         } else {
       
  3194           lastEditAction = { ...action,
       
  3195             edits: { ...(lastEditAction && lastEditAction.edits),
       
  3196               ...action.edits
       
  3197             }
       
  3198           };
       
  3199         }
       
  3200       }
       
  3201       /** @type {UndoState} */
       
  3202 
       
  3203 
       
  3204       let nextState;
       
  3205 
       
  3206       if (isUndoOrRedo) {
       
  3207         // @ts-ignore we might consider using Object.assign({}, state)
       
  3208         nextState = [...state];
       
  3209         nextState.offset = state.offset + (action.meta.isUndo ? -1 : 1);
       
  3210 
       
  3211         if (state.flattenedUndo) {
       
  3212           // The first undo in a sequence of undos might happen while we have
       
  3213           // flattened undos in state. If this is the case, we want execution
       
  3214           // to continue as if we were creating an explicit undo level. This
       
  3215           // will result in an extra undo level being appended with the flattened
       
  3216           // undo values.
       
  3217           // We also have to take into account if the `lastEditAction` had opted out
       
  3218           // of being tracked in undo history, like the action that persists the latest
       
  3219           // content right before saving. In that case we have to update the `lastEditAction`
       
  3220           // to avoid returning early before applying the existing flattened undos.
       
  3221           isCreateUndoLevel = true;
       
  3222 
       
  3223           if (!lastEditAction.meta.undo) {
       
  3224             lastEditAction.meta.undo = {
       
  3225               edits: {}
       
  3226             };
       
  3227           }
       
  3228 
       
  3229           action = lastEditAction;
       
  3230         } else {
       
  3231           return nextState;
       
  3232         }
       
  3233       }
       
  3234 
       
  3235       if (!action.meta.undo) {
       
  3236         return state;
       
  3237       } // Transient edits don't create an undo level, but are
       
  3238       // reachable in the next meaningful edit to which they
       
  3239       // are merged. They are defined in the entity's config.
       
  3240 
       
  3241 
       
  3242       if (!isCreateUndoLevel && !Object.keys(action.edits).some(key => !action.transientEdits[key])) {
       
  3243         // @ts-ignore we might consider using Object.assign({}, state)
       
  3244         nextState = [...state];
       
  3245         nextState.flattenedUndo = { ...state.flattenedUndo,
       
  3246           ...action.edits
       
  3247         };
       
  3248         nextState.offset = state.offset;
       
  3249         return nextState;
       
  3250       } // Clear potential redos, because this only supports linear history.
       
  3251 
       
  3252 
       
  3253       nextState = // @ts-ignore this needs additional cleanup, probably involving code-level changes
       
  3254       nextState || state.slice(0, state.offset || undefined);
       
  3255       nextState.offset = nextState.offset || 0;
       
  3256       nextState.pop();
       
  3257 
       
  3258       if (!isCreateUndoLevel) {
       
  3259         nextState.push({
       
  3260           kind: action.meta.undo.kind,
       
  3261           name: action.meta.undo.name,
       
  3262           recordId: action.meta.undo.recordId,
       
  3263           edits: { ...state.flattenedUndo,
       
  3264             ...action.meta.undo.edits
       
  3265           }
       
  3266         });
       
  3267       } // When an edit is a function it's an optimization to avoid running some expensive operation.
       
  3268       // We can't rely on the function references being the same so we opt out of comparing them here.
       
  3269 
       
  3270 
       
  3271       const comparisonUndoEdits = Object.values(action.meta.undo.edits).filter(edit => typeof edit !== 'function');
       
  3272       const comparisonEdits = Object.values(action.edits).filter(edit => typeof edit !== 'function');
       
  3273 
       
  3274       if (!external_wp_isShallowEqual_default()(comparisonUndoEdits, comparisonEdits)) {
       
  3275         nextState.push({
       
  3276           kind: action.kind,
       
  3277           name: action.name,
       
  3278           recordId: action.recordId,
       
  3279           edits: isCreateUndoLevel ? { ...state.flattenedUndo,
       
  3280             ...action.edits
       
  3281           } : action.edits
       
  3282         });
       
  3283       }
       
  3284 
       
  3285       return nextState;
       
  3286   }
       
  3287 
       
  3288   return state;
  4038   return state;
  3289 }
  4039 }
       
  4040 
  3290 /**
  4041 /**
  3291  * Reducer managing embed preview data.
  4042  * Reducer managing embed preview data.
  3292  *
  4043  *
  3293  * @param {Object} state  Current state.
  4044  * @param {Object} state  Current state.
  3294  * @param {Object} action Dispatched action.
  4045  * @param {Object} action Dispatched action.
  3295  *
  4046  *
  3296  * @return {Object} Updated state.
  4047  * @return {Object} Updated state.
  3297  */
  4048  */
  3298 
  4049 function embedPreviews(state = {}, action) {
  3299 function embedPreviews() {
       
  3300   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  3301   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  3302 
       
  3303   switch (action.type) {
  4050   switch (action.type) {
  3304     case 'RECEIVE_EMBED_PREVIEW':
  4051     case 'RECEIVE_EMBED_PREVIEW':
  3305       const {
  4052       const {
  3306         url,
  4053         url,
  3307         preview
  4054         preview
  3308       } = action;
  4055       } = action;
  3309       return { ...state,
  4056       return {
       
  4057         ...state,
  3310         [url]: preview
  4058         [url]: preview
  3311       };
  4059       };
  3312   }
  4060   }
  3313 
       
  3314   return state;
  4061   return state;
  3315 }
  4062 }
       
  4063 
  3316 /**
  4064 /**
  3317  * State which tracks whether the user can perform an action on a REST
  4065  * State which tracks whether the user can perform an action on a REST
  3318  * resource.
  4066  * resource.
  3319  *
  4067  *
  3320  * @param {Object} state  Current state.
  4068  * @param {Object} state  Current state.
  3321  * @param {Object} action Dispatched action.
  4069  * @param {Object} action Dispatched action.
  3322  *
  4070  *
  3323  * @return {Object} Updated state.
  4071  * @return {Object} Updated state.
  3324  */
  4072  */
  3325 
  4073 function userPermissions(state = {}, action) {
  3326 function userPermissions() {
       
  3327   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  3328   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  3329 
       
  3330   switch (action.type) {
  4074   switch (action.type) {
  3331     case 'RECEIVE_USER_PERMISSION':
  4075     case 'RECEIVE_USER_PERMISSION':
  3332       return { ...state,
  4076       return {
       
  4077         ...state,
  3333         [action.key]: action.isAllowed
  4078         [action.key]: action.isAllowed
  3334       };
  4079       };
  3335   }
  4080   }
  3336 
       
  3337   return state;
  4081   return state;
  3338 }
  4082 }
       
  4083 
  3339 /**
  4084 /**
  3340  * Reducer returning autosaves keyed by their parent's post id.
  4085  * Reducer returning autosaves keyed by their parent's post id.
  3341  *
  4086  *
  3342  * @param {Object} state  Current state.
  4087  * @param {Object} state  Current state.
  3343  * @param {Object} action Dispatched action.
  4088  * @param {Object} action Dispatched action.
  3344  *
  4089  *
  3345  * @return {Object} Updated state.
  4090  * @return {Object} Updated state.
  3346  */
  4091  */
  3347 
  4092 function autosaves(state = {}, action) {
  3348 function autosaves() {
       
  3349   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
  3350   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  3351 
       
  3352   switch (action.type) {
  4093   switch (action.type) {
  3353     case 'RECEIVE_AUTOSAVES':
  4094     case 'RECEIVE_AUTOSAVES':
  3354       const {
  4095       const {
  3355         postId,
  4096         postId,
  3356         autosaves: autosavesData
  4097         autosaves: autosavesData
  3357       } = action;
  4098       } = action;
  3358       return { ...state,
  4099       return {
       
  4100         ...state,
  3359         [postId]: autosavesData
  4101         [postId]: autosavesData
  3360       };
  4102       };
  3361   }
  4103   }
  3362 
       
  3363   return state;
  4104   return state;
  3364 }
  4105 }
  3365 function blockPatterns() {
  4106 function blockPatterns(state = [], action) {
  3366   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
       
  3367   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  3368 
       
  3369   switch (action.type) {
  4107   switch (action.type) {
  3370     case 'RECEIVE_BLOCK_PATTERNS':
  4108     case 'RECEIVE_BLOCK_PATTERNS':
  3371       return action.patterns;
  4109       return action.patterns;
  3372   }
  4110   }
  3373 
       
  3374   return state;
  4111   return state;
  3375 }
  4112 }
  3376 function blockPatternCategories() {
  4113 function blockPatternCategories(state = [], action) {
  3377   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
       
  3378   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  3379 
       
  3380   switch (action.type) {
  4114   switch (action.type) {
  3381     case 'RECEIVE_BLOCK_PATTERN_CATEGORIES':
  4115     case 'RECEIVE_BLOCK_PATTERN_CATEGORIES':
  3382       return action.categories;
  4116       return action.categories;
  3383   }
  4117   }
  3384 
       
  3385   return state;
  4118   return state;
  3386 }
  4119 }
  3387 /* harmony default export */ var build_module_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  4120 function userPatternCategories(state = [], action) {
       
  4121   switch (action.type) {
       
  4122     case 'RECEIVE_USER_PATTERN_CATEGORIES':
       
  4123       return action.patternCategories;
       
  4124   }
       
  4125   return state;
       
  4126 }
       
  4127 function navigationFallbackId(state = null, action) {
       
  4128   switch (action.type) {
       
  4129     case 'RECEIVE_NAVIGATION_FALLBACK_ID':
       
  4130       return action.fallbackId;
       
  4131   }
       
  4132   return state;
       
  4133 }
       
  4134 
       
  4135 /**
       
  4136  * Reducer managing the theme global styles revisions.
       
  4137  *
       
  4138  * @param {Record<string, object>} state  Current state.
       
  4139  * @param {Object}                 action Dispatched action.
       
  4140  *
       
  4141  * @return {Record<string, object>} Updated state.
       
  4142  */
       
  4143 function themeGlobalStyleRevisions(state = {}, action) {
       
  4144   switch (action.type) {
       
  4145     case 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS':
       
  4146       return {
       
  4147         ...state,
       
  4148         [action.currentId]: action.revisions
       
  4149       };
       
  4150   }
       
  4151   return state;
       
  4152 }
       
  4153 
       
  4154 /**
       
  4155  * Reducer managing the template lookup per query.
       
  4156  *
       
  4157  * @param {Record<string, string>} state  Current state.
       
  4158  * @param {Object}                 action Dispatched action.
       
  4159  *
       
  4160  * @return {Record<string, string>} Updated state.
       
  4161  */
       
  4162 function defaultTemplates(state = {}, action) {
       
  4163   switch (action.type) {
       
  4164     case 'RECEIVE_DEFAULT_TEMPLATE':
       
  4165       return {
       
  4166         ...state,
       
  4167         [JSON.stringify(action.query)]: action.templateId
       
  4168       };
       
  4169   }
       
  4170   return state;
       
  4171 }
       
  4172 /* harmony default export */ const build_module_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  3388   terms,
  4173   terms,
  3389   users,
  4174   users,
  3390   currentTheme,
  4175   currentTheme,
  3391   currentGlobalStylesId,
  4176   currentGlobalStylesId,
  3392   currentUser,
  4177   currentUser,
  3393   themeGlobalStyleVariations,
  4178   themeGlobalStyleVariations,
  3394   themeBaseGlobalStyles,
  4179   themeBaseGlobalStyles,
       
  4180   themeGlobalStyleRevisions,
  3395   taxonomies,
  4181   taxonomies,
  3396   entities,
  4182   entities,
  3397   undo: reducer_undo,
  4183   editsReference,
       
  4184   undoManager,
  3398   embedPreviews,
  4185   embedPreviews,
  3399   userPermissions,
  4186   userPermissions,
  3400   autosaves,
  4187   autosaves,
  3401   blockPatterns,
  4188   blockPatterns,
  3402   blockPatternCategories
  4189   blockPatternCategories,
       
  4190   userPatternCategories,
       
  4191   navigationFallbackId,
       
  4192   defaultTemplates
  3403 }));
  4193 }));
  3404 
  4194 
  3405 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
       
  3406 
       
  3407 
       
  3408 var LEAF_KEY, hasWeakMap;
       
  3409 
       
  3410 /**
       
  3411  * Arbitrary value used as key for referencing cache object in WeakMap tree.
       
  3412  *
       
  3413  * @type {Object}
       
  3414  */
       
  3415 LEAF_KEY = {};
       
  3416 
       
  3417 /**
       
  3418  * Whether environment supports WeakMap.
       
  3419  *
       
  3420  * @type {boolean}
       
  3421  */
       
  3422 hasWeakMap = typeof WeakMap !== 'undefined';
       
  3423 
       
  3424 /**
       
  3425  * Returns the first argument as the sole entry in an array.
       
  3426  *
       
  3427  * @param {*} value Value to return.
       
  3428  *
       
  3429  * @return {Array} Value returned as entry in array.
       
  3430  */
       
  3431 function arrayOf( value ) {
       
  3432 	return [ value ];
       
  3433 }
       
  3434 
       
  3435 /**
       
  3436  * Returns true if the value passed is object-like, or false otherwise. A value
       
  3437  * is object-like if it can support property assignment, e.g. object or array.
       
  3438  *
       
  3439  * @param {*} value Value to test.
       
  3440  *
       
  3441  * @return {boolean} Whether value is object-like.
       
  3442  */
       
  3443 function isObjectLike( value ) {
       
  3444 	return !! value && 'object' === typeof value;
       
  3445 }
       
  3446 
       
  3447 /**
       
  3448  * Creates and returns a new cache object.
       
  3449  *
       
  3450  * @return {Object} Cache object.
       
  3451  */
       
  3452 function createCache() {
       
  3453 	var cache = {
       
  3454 		clear: function() {
       
  3455 			cache.head = null;
       
  3456 		},
       
  3457 	};
       
  3458 
       
  3459 	return cache;
       
  3460 }
       
  3461 
       
  3462 /**
       
  3463  * Returns true if entries within the two arrays are strictly equal by
       
  3464  * reference from a starting index.
       
  3465  *
       
  3466  * @param {Array}  a         First array.
       
  3467  * @param {Array}  b         Second array.
       
  3468  * @param {number} fromIndex Index from which to start comparison.
       
  3469  *
       
  3470  * @return {boolean} Whether arrays are shallowly equal.
       
  3471  */
       
  3472 function isShallowEqual( a, b, fromIndex ) {
       
  3473 	var i;
       
  3474 
       
  3475 	if ( a.length !== b.length ) {
       
  3476 		return false;
       
  3477 	}
       
  3478 
       
  3479 	for ( i = fromIndex; i < a.length; i++ ) {
       
  3480 		if ( a[ i ] !== b[ i ] ) {
       
  3481 			return false;
       
  3482 		}
       
  3483 	}
       
  3484 
       
  3485 	return true;
       
  3486 }
       
  3487 
       
  3488 /**
       
  3489  * Returns a memoized selector function. The getDependants function argument is
       
  3490  * called before the memoized selector and is expected to return an immutable
       
  3491  * reference or array of references on which the selector depends for computing
       
  3492  * its own return value. The memoize cache is preserved only as long as those
       
  3493  * dependant references remain the same. If getDependants returns a different
       
  3494  * reference(s), the cache is cleared and the selector value regenerated.
       
  3495  *
       
  3496  * @param {Function} selector      Selector function.
       
  3497  * @param {Function} getDependants Dependant getter returning an immutable
       
  3498  *                                 reference or array of reference used in
       
  3499  *                                 cache bust consideration.
       
  3500  *
       
  3501  * @return {Function} Memoized selector.
       
  3502  */
       
  3503 /* harmony default export */ function rememo(selector, getDependants ) {
       
  3504 	var rootCache, getCache;
       
  3505 
       
  3506 	// Use object source as dependant if getter not provided
       
  3507 	if ( ! getDependants ) {
       
  3508 		getDependants = arrayOf;
       
  3509 	}
       
  3510 
       
  3511 	/**
       
  3512 	 * Returns the root cache. If WeakMap is supported, this is assigned to the
       
  3513 	 * root WeakMap cache set, otherwise it is a shared instance of the default
       
  3514 	 * cache object.
       
  3515 	 *
       
  3516 	 * @return {(WeakMap|Object)} Root cache object.
       
  3517 	 */
       
  3518 	function getRootCache() {
       
  3519 		return rootCache;
       
  3520 	}
       
  3521 
       
  3522 	/**
       
  3523 	 * Returns the cache for a given dependants array. When possible, a WeakMap
       
  3524 	 * will be used to create a unique cache for each set of dependants. This
       
  3525 	 * is feasible due to the nature of WeakMap in allowing garbage collection
       
  3526 	 * to occur on entries where the key object is no longer referenced. Since
       
  3527 	 * WeakMap requires the key to be an object, this is only possible when the
       
  3528 	 * dependant is object-like. The root cache is created as a hierarchy where
       
  3529 	 * each top-level key is the first entry in a dependants set, the value a
       
  3530 	 * WeakMap where each key is the next dependant, and so on. This continues
       
  3531 	 * so long as the dependants are object-like. If no dependants are object-
       
  3532 	 * like, then the cache is shared across all invocations.
       
  3533 	 *
       
  3534 	 * @see isObjectLike
       
  3535 	 *
       
  3536 	 * @param {Array} dependants Selector dependants.
       
  3537 	 *
       
  3538 	 * @return {Object} Cache object.
       
  3539 	 */
       
  3540 	function getWeakMapCache( dependants ) {
       
  3541 		var caches = rootCache,
       
  3542 			isUniqueByDependants = true,
       
  3543 			i, dependant, map, cache;
       
  3544 
       
  3545 		for ( i = 0; i < dependants.length; i++ ) {
       
  3546 			dependant = dependants[ i ];
       
  3547 
       
  3548 			// Can only compose WeakMap from object-like key.
       
  3549 			if ( ! isObjectLike( dependant ) ) {
       
  3550 				isUniqueByDependants = false;
       
  3551 				break;
       
  3552 			}
       
  3553 
       
  3554 			// Does current segment of cache already have a WeakMap?
       
  3555 			if ( caches.has( dependant ) ) {
       
  3556 				// Traverse into nested WeakMap.
       
  3557 				caches = caches.get( dependant );
       
  3558 			} else {
       
  3559 				// Create, set, and traverse into a new one.
       
  3560 				map = new WeakMap();
       
  3561 				caches.set( dependant, map );
       
  3562 				caches = map;
       
  3563 			}
       
  3564 		}
       
  3565 
       
  3566 		// We use an arbitrary (but consistent) object as key for the last item
       
  3567 		// in the WeakMap to serve as our running cache.
       
  3568 		if ( ! caches.has( LEAF_KEY ) ) {
       
  3569 			cache = createCache();
       
  3570 			cache.isUniqueByDependants = isUniqueByDependants;
       
  3571 			caches.set( LEAF_KEY, cache );
       
  3572 		}
       
  3573 
       
  3574 		return caches.get( LEAF_KEY );
       
  3575 	}
       
  3576 
       
  3577 	// Assign cache handler by availability of WeakMap
       
  3578 	getCache = hasWeakMap ? getWeakMapCache : getRootCache;
       
  3579 
       
  3580 	/**
       
  3581 	 * Resets root memoization cache.
       
  3582 	 */
       
  3583 	function clear() {
       
  3584 		rootCache = hasWeakMap ? new WeakMap() : createCache();
       
  3585 	}
       
  3586 
       
  3587 	// eslint-disable-next-line jsdoc/check-param-names
       
  3588 	/**
       
  3589 	 * The augmented selector call, considering first whether dependants have
       
  3590 	 * changed before passing it to underlying memoize function.
       
  3591 	 *
       
  3592 	 * @param {Object} source    Source object for derivation.
       
  3593 	 * @param {...*}   extraArgs Additional arguments to pass to selector.
       
  3594 	 *
       
  3595 	 * @return {*} Selector result.
       
  3596 	 */
       
  3597 	function callSelector( /* source, ...extraArgs */ ) {
       
  3598 		var len = arguments.length,
       
  3599 			cache, node, i, args, dependants;
       
  3600 
       
  3601 		// Create copy of arguments (avoid leaking deoptimization).
       
  3602 		args = new Array( len );
       
  3603 		for ( i = 0; i < len; i++ ) {
       
  3604 			args[ i ] = arguments[ i ];
       
  3605 		}
       
  3606 
       
  3607 		dependants = getDependants.apply( null, args );
       
  3608 		cache = getCache( dependants );
       
  3609 
       
  3610 		// If not guaranteed uniqueness by dependants (primitive type or lack
       
  3611 		// of WeakMap support), shallow compare against last dependants and, if
       
  3612 		// references have changed, destroy cache to recalculate result.
       
  3613 		if ( ! cache.isUniqueByDependants ) {
       
  3614 			if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
       
  3615 				cache.clear();
       
  3616 			}
       
  3617 
       
  3618 			cache.lastDependants = dependants;
       
  3619 		}
       
  3620 
       
  3621 		node = cache.head;
       
  3622 		while ( node ) {
       
  3623 			// Check whether node arguments match arguments
       
  3624 			if ( ! isShallowEqual( node.args, args, 1 ) ) {
       
  3625 				node = node.next;
       
  3626 				continue;
       
  3627 			}
       
  3628 
       
  3629 			// At this point we can assume we've found a match
       
  3630 
       
  3631 			// Surface matched node to head if not already
       
  3632 			if ( node !== cache.head ) {
       
  3633 				// Adjust siblings to point to each other.
       
  3634 				node.prev.next = node.next;
       
  3635 				if ( node.next ) {
       
  3636 					node.next.prev = node.prev;
       
  3637 				}
       
  3638 
       
  3639 				node.next = cache.head;
       
  3640 				node.prev = null;
       
  3641 				cache.head.prev = node;
       
  3642 				cache.head = node;
       
  3643 			}
       
  3644 
       
  3645 			// Return immediately
       
  3646 			return node.val;
       
  3647 		}
       
  3648 
       
  3649 		// No cached value found. Continue to insertion phase:
       
  3650 
       
  3651 		node = {
       
  3652 			// Generate the result from original function
       
  3653 			val: selector.apply( null, args ),
       
  3654 		};
       
  3655 
       
  3656 		// Avoid including the source object in the cache.
       
  3657 		args[ 0 ] = null;
       
  3658 		node.args = args;
       
  3659 
       
  3660 		// Don't need to check whether node is already head, since it would
       
  3661 		// have been returned above already if it was
       
  3662 
       
  3663 		// Shift existing head down list
       
  3664 		if ( cache.head ) {
       
  3665 			cache.head.prev = node;
       
  3666 			node.next = cache.head;
       
  3667 		}
       
  3668 
       
  3669 		cache.head = node;
       
  3670 
       
  3671 		return node.val;
       
  3672 	}
       
  3673 
       
  3674 	callSelector.getDependants = getDependants;
       
  3675 	callSelector.clear = clear;
       
  3676 	clear();
       
  3677 
       
  3678 	return callSelector;
       
  3679 }
       
  3680 
       
  3681 // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js
  4195 // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js
  3682 var equivalent_key_map = __webpack_require__(2167);
  4196 var equivalent_key_map = __webpack_require__(3249);
  3683 var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map);
  4197 var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map);
  3684 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/selectors.js
  4198 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/selectors.js
  3685 /**
  4199 /**
  3686  * External dependencies
  4200  * External dependencies
  3687  */
  4201  */
  3688 
  4202 
  3689 
  4203 
       
  4204 /**
       
  4205  * WordPress dependencies
       
  4206  */
       
  4207 
  3690 
  4208 
  3691 /**
  4209 /**
  3692  * Internal dependencies
  4210  * Internal dependencies
  3693  */
  4211  */
       
  4212 
  3694 
  4213 
  3695 
  4214 
  3696 /**
  4215 /**
  3697  * Cache of state keys to EquivalentKeyMap where the inner map tracks queries
  4216  * Cache of state keys to EquivalentKeyMap where the inner map tracks queries
  3698  * to their resulting items set. WeakMap allows garbage collection on expired
  4217  * to their resulting items set. WeakMap allows garbage collection on expired
  3699  * state references.
  4218  * state references.
  3700  *
  4219  *
  3701  * @type {WeakMap<Object,EquivalentKeyMap>}
  4220  * @type {WeakMap<Object,EquivalentKeyMap>}
  3702  */
  4221  */
  3703 
       
  3704 const queriedItemsCacheByState = new WeakMap();
  4222 const queriedItemsCacheByState = new WeakMap();
       
  4223 
  3705 /**
  4224 /**
  3706  * Returns items for a given query, or null if the items are not known.
  4225  * Returns items for a given query, or null if the items are not known.
  3707  *
  4226  *
  3708  * @param {Object}  state State object.
  4227  * @param {Object}  state State object.
  3709  * @param {?Object} query Optional query.
  4228  * @param {?Object} query Optional query.
  3710  *
  4229  *
  3711  * @return {?Array} Query items.
  4230  * @return {?Array} Query items.
  3712  */
  4231  */
  3713 
       
  3714 function getQueriedItemsUncached(state, query) {
  4232 function getQueriedItemsUncached(state, query) {
  3715   var _state$queries, _state$queries$contex;
       
  3716 
       
  3717   const {
  4233   const {
  3718     stableKey,
  4234     stableKey,
  3719     page,
  4235     page,
  3720     perPage,
  4236     perPage,
  3721     include,
  4237     include,
  3722     fields,
  4238     fields,
  3723     context
  4239     context
  3724   } = get_query_parts(query);
  4240   } = get_query_parts(query);
  3725   let itemIds;
  4241   let itemIds;
  3726 
  4242   if (state.queries?.[context]?.[stableKey]) {
  3727   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]) {
  4243     itemIds = state.queries[context][stableKey].itemIds;
  3728     itemIds = state.queries[context][stableKey];
  4244   }
  3729   }
       
  3730 
       
  3731   if (!itemIds) {
  4245   if (!itemIds) {
  3732     return null;
  4246     return null;
  3733   }
  4247   }
  3734 
       
  3735   const startOffset = perPage === -1 ? 0 : (page - 1) * perPage;
  4248   const startOffset = perPage === -1 ? 0 : (page - 1) * perPage;
  3736   const endOffset = perPage === -1 ? itemIds.length : Math.min(startOffset + perPage, itemIds.length);
  4249   const endOffset = perPage === -1 ? itemIds.length : Math.min(startOffset + perPage, itemIds.length);
  3737   const items = [];
  4250   const items = [];
  3738 
       
  3739   for (let i = startOffset; i < endOffset; i++) {
  4251   for (let i = startOffset; i < endOffset; i++) {
  3740     var _state$items$context;
       
  3741 
       
  3742     const itemId = itemIds[i];
  4252     const itemId = itemIds[i];
  3743 
       
  3744     if (Array.isArray(include) && !include.includes(itemId)) {
  4253     if (Array.isArray(include) && !include.includes(itemId)) {
  3745       continue;
  4254       continue;
  3746     } // Having a target item ID doesn't guarantee that this object has been queried.
  4255     }
  3747 
  4256     if (itemId === undefined) {
  3748 
  4257       continue;
  3749     if (!((_state$items$context = state.items[context]) !== null && _state$items$context !== void 0 && _state$items$context.hasOwnProperty(itemId))) {
  4258     }
       
  4259     // Having a target item ID doesn't guarantee that this object has been queried.
       
  4260     if (!state.items[context]?.hasOwnProperty(itemId)) {
  3750       return null;
  4261       return null;
  3751     }
  4262     }
  3752 
       
  3753     const item = state.items[context][itemId];
  4263     const item = state.items[context][itemId];
  3754     let filteredItem;
  4264     let filteredItem;
  3755 
       
  3756     if (Array.isArray(fields)) {
  4265     if (Array.isArray(fields)) {
  3757       filteredItem = {};
  4266       filteredItem = {};
  3758 
       
  3759       for (let f = 0; f < fields.length; f++) {
  4267       for (let f = 0; f < fields.length; f++) {
  3760         const field = fields[f].split('.');
  4268         const field = fields[f].split('.');
  3761         const value = (0,external_lodash_namespaceObject.get)(item, field);
  4269         let value = item;
  3762         (0,external_lodash_namespaceObject.set)(filteredItem, field, value);
  4270         field.forEach(fieldName => {
       
  4271           value = value?.[fieldName];
       
  4272         });
       
  4273         setNestedValue(filteredItem, field, value);
  3763       }
  4274       }
  3764     } else {
  4275     } else {
  3765       var _state$itemIsComplete;
       
  3766 
       
  3767       // If expecting a complete item, validate that completeness, or
  4276       // If expecting a complete item, validate that completeness, or
  3768       // otherwise abort.
  4277       // otherwise abort.
  3769       if (!((_state$itemIsComplete = state.itemIsComplete[context]) !== null && _state$itemIsComplete !== void 0 && _state$itemIsComplete[itemId])) {
  4278       if (!state.itemIsComplete[context]?.[itemId]) {
  3770         return null;
  4279         return null;
  3771       }
  4280       }
  3772 
       
  3773       filteredItem = item;
  4281       filteredItem = item;
  3774     }
  4282     }
  3775 
       
  3776     items.push(filteredItem);
  4283     items.push(filteredItem);
  3777   }
  4284   }
  3778 
       
  3779   return items;
  4285   return items;
  3780 }
  4286 }
       
  4287 
  3781 /**
  4288 /**
  3782  * Returns items for a given query, or null if the items are not known. Caches
  4289  * Returns items for a given query, or null if the items are not known. Caches
  3783  * result both per state (by reference) and per query (by deep equality).
  4290  * result both per state (by reference) and per query (by deep equality).
  3784  * The caching approach is intended to be durable to query objects which are
  4291  * The caching approach is intended to be durable to query objects which are
  3785  * deeply but not referentially equal, since otherwise:
  4292  * deeply but not referentially equal, since otherwise:
  3789  * @param {Object}  state State object.
  4296  * @param {Object}  state State object.
  3790  * @param {?Object} query Optional query.
  4297  * @param {?Object} query Optional query.
  3791  *
  4298  *
  3792  * @return {?Array} Query items.
  4299  * @return {?Array} Query items.
  3793  */
  4300  */
  3794 
  4301 const getQueriedItems = (0,external_wp_data_namespaceObject.createSelector)((state, query = {}) => {
  3795 
       
  3796 const getQueriedItems = rememo(function (state) {
       
  3797   let query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
       
  3798   let queriedItemsCache = queriedItemsCacheByState.get(state);
  4302   let queriedItemsCache = queriedItemsCacheByState.get(state);
  3799 
       
  3800   if (queriedItemsCache) {
  4303   if (queriedItemsCache) {
  3801     const queriedItems = queriedItemsCache.get(query);
  4304     const queriedItems = queriedItemsCache.get(query);
  3802 
       
  3803     if (queriedItems !== undefined) {
  4305     if (queriedItems !== undefined) {
  3804       return queriedItems;
  4306       return queriedItems;
  3805     }
  4307     }
  3806   } else {
  4308   } else {
  3807     queriedItemsCache = new (equivalent_key_map_default())();
  4309     queriedItemsCache = new (equivalent_key_map_default())();
  3808     queriedItemsCacheByState.set(state, queriedItemsCache);
  4310     queriedItemsCacheByState.set(state, queriedItemsCache);
  3809   }
  4311   }
  3810 
       
  3811   const items = getQueriedItemsUncached(state, query);
  4312   const items = getQueriedItemsUncached(state, query);
  3812   queriedItemsCache.set(query, items);
  4313   queriedItemsCache.set(query, items);
  3813   return items;
  4314   return items;
  3814 });
  4315 });
       
  4316 function getQueriedTotalItems(state, query = {}) {
       
  4317   var _state$queries$contex;
       
  4318   const {
       
  4319     stableKey,
       
  4320     context
       
  4321   } = get_query_parts(query);
       
  4322   return (_state$queries$contex = state.queries?.[context]?.[stableKey]?.meta?.totalItems) !== null && _state$queries$contex !== void 0 ? _state$queries$contex : null;
       
  4323 }
       
  4324 function getQueriedTotalPages(state, query = {}) {
       
  4325   var _state$queries$contex2;
       
  4326   const {
       
  4327     stableKey,
       
  4328     context
       
  4329   } = get_query_parts(query);
       
  4330   return (_state$queries$contex2 = state.queries?.[context]?.[stableKey]?.meta?.totalPages) !== null && _state$queries$contex2 !== void 0 ? _state$queries$contex2 : null;
       
  4331 }
       
  4332 
       
  4333 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/is-numeric-id.js
       
  4334 /**
       
  4335  * Checks argument to determine if it's a numeric ID.
       
  4336  * For example, '123' is a numeric ID, but '123abc' is not.
       
  4337  *
       
  4338  * @param {any} id the argument to determine if it's a numeric ID.
       
  4339  * @return {boolean} true if the string is a numeric ID, false otherwise.
       
  4340  */
       
  4341 function isNumericID(id) {
       
  4342   return /^\s*\d+\s*$/.test(id);
       
  4343 }
  3815 
  4344 
  3816 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/is-raw-attribute.js
  4345 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/is-raw-attribute.js
  3817 /**
  4346 /**
  3818  * Checks whether the attribute is a "raw" attribute or not.
  4347  * Checks whether the attribute is a "raw" attribute or not.
  3819  *
  4348  *
  3826   return (entity.rawAttributes || []).includes(attribute);
  4355   return (entity.rawAttributes || []).includes(attribute);
  3827 }
  4356 }
  3828 
  4357 
  3829 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/selectors.js
  4358 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/selectors.js
  3830 /**
  4359 /**
  3831  * External dependencies
       
  3832  */
       
  3833 
       
  3834 
       
  3835 /**
       
  3836  * WordPress dependencies
  4360  * WordPress dependencies
  3837  */
  4361  */
  3838 
  4362 
  3839 
  4363 
  3840 
  4364 
  3844  */
  4368  */
  3845 
  4369 
  3846 
  4370 
  3847 
  4371 
  3848 
  4372 
       
  4373 
       
  4374 // This is an incomplete, high-level approximation of the State type.
       
  4375 // It makes the selectors slightly more safe, but is intended to evolve
       
  4376 // into a more detailed representation over time.
       
  4377 // See https://github.com/WordPress/gutenberg/pull/40025#discussion_r865410589 for more context.
       
  4378 
       
  4379 /**
       
  4380  * HTTP Query parameters sent with the API request to fetch the entity records.
       
  4381  */
       
  4382 
       
  4383 /**
       
  4384  * Arguments for EntityRecord selectors.
       
  4385  */
  3849 
  4386 
  3850 /**
  4387 /**
  3851  * Shared reference to an empty object for cases where it is important to avoid
  4388  * Shared reference to an empty object for cases where it is important to avoid
  3852  * returning a new object reference on every invocation, as in a connected or
  4389  * returning a new object reference on every invocation, as in a connected or
  3853  * other pure component which performs `shouldComponentUpdate` check on props.
  4390  * other pure component which performs `shouldComponentUpdate` check on props.
  3854  * This should be used as a last resort, since the normalized data should be
  4391  * This should be used as a last resort, since the normalized data should be
  3855  * maintained by the reducer result in state.
  4392  * maintained by the reducer result in state.
  3856  */
  4393  */
  3857 
       
  3858 const EMPTY_OBJECT = {};
  4394 const EMPTY_OBJECT = {};
       
  4395 
  3859 /**
  4396 /**
  3860  * Returns true if a request is in progress for embed preview data, or false
  4397  * Returns true if a request is in progress for embed preview data, or false
  3861  * otherwise.
  4398  * otherwise.
  3862  *
  4399  *
  3863  * @param {Object} state Data state.
  4400  * @param state Data state.
  3864  * @param {string} url   URL the preview would be for.
  4401  * @param url   URL the preview would be for.
  3865  *
  4402  *
  3866  * @return {boolean} Whether a request is in progress for an embed preview.
  4403  * @return Whether a request is in progress for an embed preview.
  3867  */
  4404  */
  3868 
       
  3869 const isRequestingEmbedPreview = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, url) => {
  4405 const isRequestingEmbedPreview = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, url) => {
  3870   return select(STORE_NAME).isResolving('getEmbedPreview', [url]);
  4406   return select(STORE_NAME).isResolving('getEmbedPreview', [url]);
  3871 });
  4407 });
       
  4408 
  3872 /**
  4409 /**
  3873  * Returns all available authors.
  4410  * Returns all available authors.
  3874  *
  4411  *
  3875  * @deprecated since 11.3. Callers should use `select( 'core' ).getUsers({ who: 'authors' })` instead.
  4412  * @deprecated since 11.3. Callers should use `select( 'core' ).getUsers({ who: 'authors' })` instead.
  3876  *
  4413  *
  3877  * @param {Object}           state Data state.
  4414  * @param      state Data state.
  3878  * @param {Object|undefined} query Optional object of query parameters to
  4415  * @param      query Optional object of query parameters to
  3879  *                                 include with request.
  4416  *                   include with request. For valid query parameters see the [Users page](https://developer.wordpress.org/rest-api/reference/users/) in the REST API Handbook and see the arguments for [List Users](https://developer.wordpress.org/rest-api/reference/users/#list-users) and [Retrieve a User](https://developer.wordpress.org/rest-api/reference/users/#retrieve-a-user).
  3880  * @return {Array} Authors list.
  4417  * @return Authors list.
  3881  */
  4418  */
  3882 
       
  3883 function getAuthors(state, query) {
  4419 function getAuthors(state, query) {
  3884   external_wp_deprecated_default()("select( 'core' ).getAuthors()", {
  4420   external_wp_deprecated_default()("select( 'core' ).getAuthors()", {
  3885     since: '5.9',
  4421     since: '5.9',
  3886     alternative: "select( 'core' ).getUsers({ who: 'authors' })"
  4422     alternative: "select( 'core' ).getUsers({ who: 'authors' })"
  3887   });
  4423   });
  3888   const path = (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/users/?who=authors&per_page=100', query);
  4424   const path = (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/users/?who=authors&per_page=100', query);
  3889   return getUserQueryResults(state, path);
  4425   return getUserQueryResults(state, path);
  3890 }
  4426 }
       
  4427 
  3891 /**
  4428 /**
  3892  * Returns the current user.
  4429  * Returns the current user.
  3893  *
  4430  *
  3894  * @param {Object} state Data state.
  4431  * @param state Data state.
  3895  *
  4432  *
  3896  * @return {Object} Current user object.
  4433  * @return Current user object.
  3897  */
  4434  */
  3898 
       
  3899 function getCurrentUser(state) {
  4435 function getCurrentUser(state) {
  3900   return state.currentUser;
  4436   return state.currentUser;
  3901 }
  4437 }
       
  4438 
  3902 /**
  4439 /**
  3903  * Returns all the users returned by a query ID.
  4440  * Returns all the users returned by a query ID.
  3904  *
  4441  *
  3905  * @param {Object} state   Data state.
  4442  * @param state   Data state.
  3906  * @param {string} queryID Query ID.
  4443  * @param queryID Query ID.
  3907  *
  4444  *
  3908  * @return {Array} Users list.
  4445  * @return Users list.
  3909  */
  4446  */
  3910 
  4447 const getUserQueryResults = (0,external_wp_data_namespaceObject.createSelector)((state, queryID) => {
  3911 const getUserQueryResults = rememo((state, queryID) => {
  4448   var _state$users$queries$;
  3912   const queryResults = state.users.queries[queryID];
  4449   const queryResults = (_state$users$queries$ = state.users.queries[queryID]) !== null && _state$users$queries$ !== void 0 ? _state$users$queries$ : [];
  3913   return (0,external_lodash_namespaceObject.map)(queryResults, id => state.users.byId[id]);
  4450   return queryResults.map(id => state.users.byId[id]);
  3914 }, (state, queryID) => [state.users.queries[queryID], state.users.byId]);
  4451 }, (state, queryID) => [state.users.queries[queryID], state.users.byId]);
       
  4452 
  3915 /**
  4453 /**
  3916  * Returns the loaded entities for the given kind.
  4454  * Returns the loaded entities for the given kind.
  3917  *
  4455  *
  3918  * @deprecated since WordPress 6.0. Use getEntitiesConfig instead
  4456  * @deprecated since WordPress 6.0. Use getEntitiesConfig instead
  3919  * @param {Object} state Data state.
  4457  * @param      state Data state.
  3920  * @param {string} kind  Entity kind.
  4458  * @param      kind  Entity kind.
  3921  *
  4459  *
  3922  * @return {Array<Object>} Array of entities with config matching kind.
  4460  * @return Array of entities with config matching kind.
  3923  */
  4461  */
  3924 
       
  3925 function getEntitiesByKind(state, kind) {
  4462 function getEntitiesByKind(state, kind) {
  3926   external_wp_deprecated_default()("wp.data.select( 'core' ).getEntitiesByKind()", {
  4463   external_wp_deprecated_default()("wp.data.select( 'core' ).getEntitiesByKind()", {
  3927     since: '6.0',
  4464     since: '6.0',
  3928     alternative: "wp.data.select( 'core' ).getEntitiesConfig()"
  4465     alternative: "wp.data.select( 'core' ).getEntitiesConfig()"
  3929   });
  4466   });
  3930   return getEntitiesConfig(state, kind);
  4467   return getEntitiesConfig(state, kind);
  3931 }
  4468 }
       
  4469 
  3932 /**
  4470 /**
  3933  * Returns the loaded entities for the given kind.
  4471  * Returns the loaded entities for the given kind.
  3934  *
  4472  *
  3935  * @param {Object} state Data state.
  4473  * @param state Data state.
  3936  * @param {string} kind  Entity kind.
  4474  * @param kind  Entity kind.
  3937  *
  4475  *
  3938  * @return {Array<Object>} Array of entities with config matching kind.
  4476  * @return Array of entities with config matching kind.
  3939  */
  4477  */
  3940 
  4478 const getEntitiesConfig = (0,external_wp_data_namespaceObject.createSelector)((state, kind) => state.entities.config.filter(entity => entity.kind === kind), (state, kind) => state.entities.config);
  3941 function getEntitiesConfig(state, kind) {
       
  3942   return (0,external_lodash_namespaceObject.filter)(state.entities.config, {
       
  3943     kind
       
  3944   });
       
  3945 }
       
  3946 /**
  4479 /**
  3947  * Returns the entity config given its kind and name.
  4480  * Returns the entity config given its kind and name.
  3948  *
  4481  *
  3949  * @deprecated since WordPress 6.0. Use getEntityConfig instead
  4482  * @deprecated since WordPress 6.0. Use getEntityConfig instead
  3950  * @param {Object} state Data state.
  4483  * @param      state Data state.
  3951  * @param {string} kind  Entity kind.
  4484  * @param      kind  Entity kind.
  3952  * @param {string} name  Entity name.
  4485  * @param      name  Entity name.
  3953  *
  4486  *
  3954  * @return {Object} Entity config
  4487  * @return Entity config
  3955  */
  4488  */
  3956 
       
  3957 function getEntity(state, kind, name) {
  4489 function getEntity(state, kind, name) {
  3958   external_wp_deprecated_default()("wp.data.select( 'core' ).getEntity()", {
  4490   external_wp_deprecated_default()("wp.data.select( 'core' ).getEntity()", {
  3959     since: '6.0',
  4491     since: '6.0',
  3960     alternative: "wp.data.select( 'core' ).getEntityConfig()"
  4492     alternative: "wp.data.select( 'core' ).getEntityConfig()"
  3961   });
  4493   });
  3962   return getEntityConfig(state, kind, name);
  4494   return getEntityConfig(state, kind, name);
  3963 }
  4495 }
       
  4496 
  3964 /**
  4497 /**
  3965  * Returns the entity config given its kind and name.
  4498  * Returns the entity config given its kind and name.
  3966  *
  4499  *
  3967  * @param {Object} state Data state.
  4500  * @param state Data state.
  3968  * @param {string} kind  Entity kind.
  4501  * @param kind  Entity kind.
  3969  * @param {string} name  Entity name.
  4502  * @param name  Entity name.
  3970  *
  4503  *
  3971  * @return {Object} Entity config
  4504  * @return Entity config
  3972  */
  4505  */
  3973 
       
  3974 function getEntityConfig(state, kind, name) {
  4506 function getEntityConfig(state, kind, name) {
  3975   return (0,external_lodash_namespaceObject.find)(state.entities.config, {
  4507   return state.entities.config?.find(config => config.kind === kind && config.name === name);
  3976     kind,
  4508 }
  3977     name
  4509 
  3978   });
  4510 /**
  3979 }
  4511  * GetEntityRecord is declared as a *callable interface* with
       
  4512  * two signatures to work around the fact that TypeScript doesn't
       
  4513  * allow currying generic functions:
       
  4514  *
       
  4515  * ```ts
       
  4516  * 		type CurriedState = F extends ( state: any, ...args: infer P ) => infer R
       
  4517  * 			? ( ...args: P ) => R
       
  4518  * 			: F;
       
  4519  * 		type Selector = <K extends string | number>(
       
  4520  *         state: any,
       
  4521  *         kind: K,
       
  4522  *         key: K extends string ? 'string value' : false
       
  4523  *    ) => K;
       
  4524  * 		type BadlyInferredSignature = CurriedState< Selector >
       
  4525  *    // BadlyInferredSignature evaluates to:
       
  4526  *    // (kind: string number, key: false | "string value") => string number
       
  4527  * ```
       
  4528  *
       
  4529  * The signature without the state parameter shipped as CurriedSignature
       
  4530  * is used in the return value of `select( coreStore )`.
       
  4531  *
       
  4532  * See https://github.com/WordPress/gutenberg/pull/41578 for more details.
       
  4533  */
       
  4534 
  3980 /**
  4535 /**
  3981  * Returns the Entity's record object by key. Returns `null` if the value is not
  4536  * Returns the Entity's record object by key. Returns `null` if the value is not
  3982  * yet received, undefined if the value entity is known to not exist, or the
  4537  * yet received, undefined if the value entity is known to not exist, or the
  3983  * entity object if it exists and is received.
  4538  * entity object if it exists and is received.
  3984  *
  4539  *
  3985  * @param {Object}  state State tree
  4540  * @param state State tree
  3986  * @param {string}  kind  Entity kind.
  4541  * @param kind  Entity kind.
  3987  * @param {string}  name  Entity name.
  4542  * @param name  Entity name.
  3988  * @param {number}  key   Record's key
  4543  * @param key   Record's key
  3989  * @param {?Object} query Optional query.
  4544  * @param query Optional query. If requesting specific
  3990  *
  4545  *              fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available "Retrieve a [Entity kind]".
  3991  * @return {Object|undefined} Record.
  4546  *
  3992  */
  4547  * @return Record.
  3993 
  4548  */
  3994 const getEntityRecord = rememo((state, kind, name, key, query) => {
  4549 const getEntityRecord = (0,external_wp_data_namespaceObject.createSelector)((state, kind, name, key, query) => {
  3995   var _query$context, _queriedState$items$c;
  4550   var _query$context;
  3996 
  4551   const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
  3997   const queriedState = (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'queriedData']);
       
  3998 
       
  3999   if (!queriedState) {
  4552   if (!queriedState) {
  4000     return undefined;
  4553     return undefined;
  4001   }
  4554   }
  4002 
  4555   const context = (_query$context = query?.context) !== null && _query$context !== void 0 ? _query$context : 'default';
  4003   const context = (_query$context = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context !== void 0 ? _query$context : 'default';
       
  4004 
       
  4005   if (query === undefined) {
  4556   if (query === undefined) {
  4006     var _queriedState$itemIsC;
       
  4007 
       
  4008     // If expecting a complete item, validate that completeness.
  4557     // If expecting a complete item, validate that completeness.
  4009     if (!((_queriedState$itemIsC = queriedState.itemIsComplete[context]) !== null && _queriedState$itemIsC !== void 0 && _queriedState$itemIsC[key])) {
  4558     if (!queriedState.itemIsComplete[context]?.[key]) {
  4010       return undefined;
  4559       return undefined;
  4011     }
  4560     }
  4012 
       
  4013     return queriedState.items[context][key];
  4561     return queriedState.items[context][key];
  4014   }
  4562   }
  4015 
  4563   const item = queriedState.items[context]?.[key];
  4016   const item = (_queriedState$items$c = queriedState.items[context]) === null || _queriedState$items$c === void 0 ? void 0 : _queriedState$items$c[key];
       
  4017 
       
  4018   if (item && query._fields) {
  4564   if (item && query._fields) {
  4019     var _getNormalizedCommaSe;
  4565     var _getNormalizedCommaSe;
  4020 
       
  4021     const filteredItem = {};
  4566     const filteredItem = {};
  4022     const fields = (_getNormalizedCommaSe = get_normalized_comma_separable(query._fields)) !== null && _getNormalizedCommaSe !== void 0 ? _getNormalizedCommaSe : [];
  4567     const fields = (_getNormalizedCommaSe = get_normalized_comma_separable(query._fields)) !== null && _getNormalizedCommaSe !== void 0 ? _getNormalizedCommaSe : [];
  4023 
       
  4024     for (let f = 0; f < fields.length; f++) {
  4568     for (let f = 0; f < fields.length; f++) {
  4025       const field = fields[f].split('.');
  4569       const field = fields[f].split('.');
  4026       const value = (0,external_lodash_namespaceObject.get)(item, field);
  4570       let value = item;
  4027       (0,external_lodash_namespaceObject.set)(filteredItem, field, value);
  4571       field.forEach(fieldName => {
  4028     }
  4572         value = value?.[fieldName];
  4029 
  4573       });
       
  4574       setNestedValue(filteredItem, field, value);
       
  4575     }
  4030     return filteredItem;
  4576     return filteredItem;
  4031   }
  4577   }
  4032 
       
  4033   return item;
  4578   return item;
  4034 }, (state, kind, name, recordId, query) => {
  4579 }, (state, kind, name, recordId, query) => {
  4035   var _query$context2;
  4580   var _query$context2;
  4036 
  4581   const context = (_query$context2 = query?.context) !== null && _query$context2 !== void 0 ? _query$context2 : 'default';
  4037   const context = (_query$context2 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context2 !== void 0 ? _query$context2 : 'default';
  4582   return [state.entities.records?.[kind]?.[name]?.queriedData?.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData?.itemIsComplete[context]?.[recordId]];
  4038   return [(0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'queriedData', 'items', context, recordId]), (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'queriedData', 'itemIsComplete', context, recordId])];
       
  4039 });
  4583 });
       
  4584 
       
  4585 /**
       
  4586  * Normalizes `recordKey`s that look like numeric IDs to numbers.
       
  4587  *
       
  4588  * @param args EntityRecordArgs the selector arguments.
       
  4589  * @return EntityRecordArgs the normalized arguments.
       
  4590  */
       
  4591 getEntityRecord.__unstableNormalizeArgs = args => {
       
  4592   const newArgs = [...args];
       
  4593   const recordKey = newArgs?.[2];
       
  4594 
       
  4595   // If recordKey looks to be a numeric ID then coerce to number.
       
  4596   newArgs[2] = isNumericID(recordKey) ? Number(recordKey) : recordKey;
       
  4597   return newArgs;
       
  4598 };
       
  4599 
  4040 /**
  4600 /**
  4041  * Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.
  4601  * Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.
  4042  *
  4602  *
  4043  * @param {Object} state State tree
  4603  * @param state State tree
  4044  * @param {string} kind  Entity kind.
  4604  * @param kind  Entity kind.
  4045  * @param {string} name  Entity name.
  4605  * @param name  Entity name.
  4046  * @param {number} key   Record's key
  4606  * @param key   Record's key
  4047  *
  4607  *
  4048  * @return {Object|null} Record.
  4608  * @return Record.
  4049  */
  4609  */
  4050 
       
  4051 function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
  4610 function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
  4052   return getEntityRecord(state, kind, name, key);
  4611   return getEntityRecord(state, kind, name, key);
  4053 }
  4612 }
       
  4613 
  4054 /**
  4614 /**
  4055  * Returns the entity's record object by key,
  4615  * Returns the entity's record object by key,
  4056  * with its attributes mapped to their raw values.
  4616  * with its attributes mapped to their raw values.
  4057  *
  4617  *
  4058  * @param {Object} state State tree.
  4618  * @param state State tree.
  4059  * @param {string} kind  Entity kind.
  4619  * @param kind  Entity kind.
  4060  * @param {string} name  Entity name.
  4620  * @param name  Entity name.
  4061  * @param {number} key   Record's key.
  4621  * @param key   Record's key.
  4062  *
  4622  *
  4063  * @return {Object?} Object with the entity's raw attributes.
  4623  * @return Object with the entity's raw attributes.
  4064  */
  4624  */
  4065 
  4625 const getRawEntityRecord = (0,external_wp_data_namespaceObject.createSelector)((state, kind, name, key) => {
  4066 const getRawEntityRecord = rememo((state, kind, name, key) => {
       
  4067   const record = getEntityRecord(state, kind, name, key);
  4626   const record = getEntityRecord(state, kind, name, key);
  4068   return record && Object.keys(record).reduce((accumulator, _key) => {
  4627   return record && Object.keys(record).reduce((accumulator, _key) => {
  4069     if (isRawAttribute(getEntityConfig(state, kind, name), _key)) {
  4628     if (isRawAttribute(getEntityConfig(state, kind, name), _key)) {
       
  4629       var _record$_key$raw;
  4070       // Because edits are the "raw" attribute values,
  4630       // Because edits are the "raw" attribute values,
  4071       // we return those from record selectors to make rendering,
  4631       // we return those from record selectors to make rendering,
  4072       // comparisons, and joins with edits easier.
  4632       // comparisons, and joins with edits easier.
  4073       accumulator[_key] = (0,external_lodash_namespaceObject.get)(record[_key], 'raw', record[_key]);
  4633       accumulator[_key] = (_record$_key$raw = record[_key]?.raw) !== null && _record$_key$raw !== void 0 ? _record$_key$raw : record[_key];
  4074     } else {
  4634     } else {
  4075       accumulator[_key] = record[_key];
  4635       accumulator[_key] = record[_key];
  4076     }
  4636     }
  4077 
       
  4078     return accumulator;
  4637     return accumulator;
  4079   }, {});
  4638   }, {});
  4080 }, (state, kind, name, recordId, query) => {
  4639 }, (state, kind, name, recordId, query) => {
  4081   var _query$context3;
  4640   var _query$context3;
  4082 
  4641   const context = (_query$context3 = query?.context) !== null && _query$context3 !== void 0 ? _query$context3 : 'default';
  4083   const context = (_query$context3 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context3 !== void 0 ? _query$context3 : 'default';
  4642   return [state.entities.config, state.entities.records?.[kind]?.[name]?.queriedData?.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData?.itemIsComplete[context]?.[recordId]];
  4084   return [state.entities.config, (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'queriedData', 'items', context, recordId]), (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'queriedData', 'itemIsComplete', context, recordId])];
       
  4085 });
  4643 });
       
  4644 
  4086 /**
  4645 /**
  4087  * Returns true if records have been received for the given set of parameters,
  4646  * Returns true if records have been received for the given set of parameters,
  4088  * or false otherwise.
  4647  * or false otherwise.
  4089  *
  4648  *
  4090  * @param {Object}  state State tree
  4649  * @param state State tree
  4091  * @param {string}  kind  Entity kind.
  4650  * @param kind  Entity kind.
  4092  * @param {string}  name  Entity name.
  4651  * @param name  Entity name.
  4093  * @param {?Object} query Optional terms query.
  4652  * @param query Optional terms query. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".
  4094  *
  4653  *
  4095  * @return {boolean} Whether entity records have been received.
  4654  * @return  Whether entity records have been received.
  4096  */
  4655  */
  4097 
       
  4098 function hasEntityRecords(state, kind, name, query) {
  4656 function hasEntityRecords(state, kind, name, query) {
  4099   return Array.isArray(getEntityRecords(state, kind, name, query));
  4657   return Array.isArray(getEntityRecords(state, kind, name, query));
  4100 }
  4658 }
       
  4659 
       
  4660 /**
       
  4661  * GetEntityRecord is declared as a *callable interface* with
       
  4662  * two signatures to work around the fact that TypeScript doesn't
       
  4663  * allow currying generic functions.
       
  4664  *
       
  4665  * @see GetEntityRecord
       
  4666  * @see https://github.com/WordPress/gutenberg/pull/41578
       
  4667  */
       
  4668 
  4101 /**
  4669 /**
  4102  * Returns the Entity's records.
  4670  * Returns the Entity's records.
  4103  *
  4671  *
  4104  * @param {Object}  state State tree
  4672  * @param state State tree
  4105  * @param {string}  kind  Entity kind.
  4673  * @param kind  Entity kind.
  4106  * @param {string}  name  Entity name.
  4674  * @param name  Entity name.
  4107  * @param {?Object} query Optional terms query.
  4675  * @param query Optional terms query. If requesting specific
  4108  *
  4676  *              fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".
  4109  * @return {?Array} Records.
  4677  *
  4110  */
  4678  * @return Records.
  4111 
  4679  */
  4112 function getEntityRecords(state, kind, name, query) {
  4680 const getEntityRecords = (state, kind, name, query) => {
  4113   // Queried data state is prepopulated for all known entities. If this is not
  4681   // Queried data state is prepopulated for all known entities. If this is not
  4114   // assigned for the given parameters, then it is known to not exist.
  4682   // assigned for the given parameters, then it is known to not exist.
  4115   const queriedState = (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'queriedData']);
  4683   const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
  4116 
       
  4117   if (!queriedState) {
  4684   if (!queriedState) {
  4118     return null;
  4685     return null;
  4119   }
  4686   }
  4120 
       
  4121   return getQueriedItems(queriedState, query);
  4687   return getQueriedItems(queriedState, query);
  4122 }
  4688 };
  4123 /**
  4689 
  4124  * Returns the  list of dirty entity records.
  4690 /**
  4125  *
  4691  * Returns the Entity's total available records for a given query (ignoring pagination).
  4126  * @param {Object} state State tree.
  4692  *
  4127  *
  4693  * @param state State tree
  4128  * @return {[{ title: string, key: string, name: string, kind: string }]} The list of updated records
  4694  * @param kind  Entity kind.
  4129  */
  4695  * @param name  Entity name.
  4130 
  4696  * @param query Optional terms query. If requesting specific
  4131 const __experimentalGetDirtyEntityRecords = rememo(state => {
  4697  *              fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".
       
  4698  *
       
  4699  * @return number | null.
       
  4700  */
       
  4701 const getEntityRecordsTotalItems = (state, kind, name, query) => {
       
  4702   // Queried data state is prepopulated for all known entities. If this is not
       
  4703   // assigned for the given parameters, then it is known to not exist.
       
  4704   const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
       
  4705   if (!queriedState) {
       
  4706     return null;
       
  4707   }
       
  4708   return getQueriedTotalItems(queriedState, query);
       
  4709 };
       
  4710 
       
  4711 /**
       
  4712  * Returns the number of available pages for the given query.
       
  4713  *
       
  4714  * @param state State tree
       
  4715  * @param kind  Entity kind.
       
  4716  * @param name  Entity name.
       
  4717  * @param query Optional terms query. If requesting specific
       
  4718  *              fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".
       
  4719  *
       
  4720  * @return number | null.
       
  4721  */
       
  4722 const getEntityRecordsTotalPages = (state, kind, name, query) => {
       
  4723   // Queried data state is prepopulated for all known entities. If this is not
       
  4724   // assigned for the given parameters, then it is known to not exist.
       
  4725   const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
       
  4726   if (!queriedState) {
       
  4727     return null;
       
  4728   }
       
  4729   if (query.per_page === -1) {
       
  4730     return 1;
       
  4731   }
       
  4732   const totalItems = getQueriedTotalItems(queriedState, query);
       
  4733   if (!totalItems) {
       
  4734     return totalItems;
       
  4735   }
       
  4736   // If `per_page` is not set and the query relies on the defaults of the
       
  4737   // REST endpoint, get the info from query's meta.
       
  4738   if (!query.per_page) {
       
  4739     return getQueriedTotalPages(queriedState, query);
       
  4740   }
       
  4741   return Math.ceil(totalItems / query.per_page);
       
  4742 };
       
  4743 /**
       
  4744  * Returns the list of dirty entity records.
       
  4745  *
       
  4746  * @param state State tree.
       
  4747  *
       
  4748  * @return The list of updated records
       
  4749  */
       
  4750 const __experimentalGetDirtyEntityRecords = (0,external_wp_data_namespaceObject.createSelector)(state => {
  4132   const {
  4751   const {
  4133     entities: {
  4752     entities: {
  4134       records
  4753       records
  4135     }
  4754     }
  4136   } = state;
  4755   } = state;
  4137   const dirtyRecords = [];
  4756   const dirtyRecords = [];
  4138   Object.keys(records).forEach(kind => {
  4757   Object.keys(records).forEach(kind => {
  4139     Object.keys(records[kind]).forEach(name => {
  4758     Object.keys(records[kind]).forEach(name => {
  4140       const primaryKeys = Object.keys(records[kind][name].edits).filter(primaryKey => // The entity record must exist (not be deleted),
  4759       const primaryKeys = Object.keys(records[kind][name].edits).filter(primaryKey =>
       
  4760       // The entity record must exist (not be deleted),
  4141       // and it must have edits.
  4761       // and it must have edits.
  4142       getEntityRecord(state, kind, name, primaryKey) && hasEditsForEntityRecord(state, kind, name, primaryKey));
  4762       getEntityRecord(state, kind, name, primaryKey) && hasEditsForEntityRecord(state, kind, name, primaryKey));
  4143 
       
  4144       if (primaryKeys.length) {
  4763       if (primaryKeys.length) {
  4145         const entityConfig = getEntityConfig(state, kind, name);
  4764         const entityConfig = getEntityConfig(state, kind, name);
  4146         primaryKeys.forEach(primaryKey => {
  4765         primaryKeys.forEach(primaryKey => {
  4147           var _entityConfig$getTitl;
       
  4148 
       
  4149           const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey);
  4766           const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey);
  4150           dirtyRecords.push({
  4767           dirtyRecords.push({
  4151             // We avoid using primaryKey because it's transformed into a string
  4768             // We avoid using primaryKey because it's transformed into a string
  4152             // when it's used as an object key.
  4769             // when it's used as an object key.
  4153             key: entityRecord[entityConfig.key || DEFAULT_ENTITY_KEY],
  4770             key: entityRecord ? entityRecord[entityConfig.key || DEFAULT_ENTITY_KEY] : undefined,
  4154             title: (entityConfig === null || entityConfig === void 0 ? void 0 : (_entityConfig$getTitl = entityConfig.getTitle) === null || _entityConfig$getTitl === void 0 ? void 0 : _entityConfig$getTitl.call(entityConfig, entityRecord)) || '',
  4771             title: entityConfig?.getTitle?.(entityRecord) || '',
  4155             name,
  4772             name,
  4156             kind
  4773             kind
  4157           });
  4774           });
  4158         });
  4775         });
  4159       }
  4776       }
  4160     });
  4777     });
  4161   });
  4778   });
  4162   return dirtyRecords;
  4779   return dirtyRecords;
  4163 }, state => [state.entities.records]);
  4780 }, state => [state.entities.records]);
       
  4781 
  4164 /**
  4782 /**
  4165  * Returns the list of entities currently being saved.
  4783  * Returns the list of entities currently being saved.
  4166  *
  4784  *
  4167  * @param {Object} state State tree.
  4785  * @param state State tree.
  4168  *
  4786  *
  4169  * @return {[{ title: string, key: string, name: string, kind: string }]} The list of records being saved.
  4787  * @return The list of records being saved.
  4170  */
  4788  */
  4171 
  4789 const __experimentalGetEntitiesBeingSaved = (0,external_wp_data_namespaceObject.createSelector)(state => {
  4172 const __experimentalGetEntitiesBeingSaved = rememo(state => {
       
  4173   const {
  4790   const {
  4174     entities: {
  4791     entities: {
  4175       records
  4792       records
  4176     }
  4793     }
  4177   } = state;
  4794   } = state;
  4178   const recordsBeingSaved = [];
  4795   const recordsBeingSaved = [];
  4179   Object.keys(records).forEach(kind => {
  4796   Object.keys(records).forEach(kind => {
  4180     Object.keys(records[kind]).forEach(name => {
  4797     Object.keys(records[kind]).forEach(name => {
  4181       const primaryKeys = Object.keys(records[kind][name].saving).filter(primaryKey => isSavingEntityRecord(state, kind, name, primaryKey));
  4798       const primaryKeys = Object.keys(records[kind][name].saving).filter(primaryKey => isSavingEntityRecord(state, kind, name, primaryKey));
  4182 
       
  4183       if (primaryKeys.length) {
  4799       if (primaryKeys.length) {
  4184         const entityConfig = getEntityConfig(state, kind, name);
  4800         const entityConfig = getEntityConfig(state, kind, name);
  4185         primaryKeys.forEach(primaryKey => {
  4801         primaryKeys.forEach(primaryKey => {
  4186           var _entityConfig$getTitl2;
       
  4187 
       
  4188           const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey);
  4802           const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey);
  4189           recordsBeingSaved.push({
  4803           recordsBeingSaved.push({
  4190             // We avoid using primaryKey because it's transformed into a string
  4804             // We avoid using primaryKey because it's transformed into a string
  4191             // when it's used as an object key.
  4805             // when it's used as an object key.
  4192             key: entityRecord[entityConfig.key || DEFAULT_ENTITY_KEY],
  4806             key: entityRecord ? entityRecord[entityConfig.key || DEFAULT_ENTITY_KEY] : undefined,
  4193             title: (entityConfig === null || entityConfig === void 0 ? void 0 : (_entityConfig$getTitl2 = entityConfig.getTitle) === null || _entityConfig$getTitl2 === void 0 ? void 0 : _entityConfig$getTitl2.call(entityConfig, entityRecord)) || '',
  4807             title: entityConfig?.getTitle?.(entityRecord) || '',
  4194             name,
  4808             name,
  4195             kind
  4809             kind
  4196           });
  4810           });
  4197         });
  4811         });
  4198       }
  4812       }
  4199     });
  4813     });
  4200   });
  4814   });
  4201   return recordsBeingSaved;
  4815   return recordsBeingSaved;
  4202 }, state => [state.entities.records]);
  4816 }, state => [state.entities.records]);
       
  4817 
  4203 /**
  4818 /**
  4204  * Returns the specified entity record's edits.
  4819  * Returns the specified entity record's edits.
  4205  *
  4820  *
  4206  * @param {Object} state    State tree.
  4821  * @param state    State tree.
  4207  * @param {string} kind     Entity kind.
  4822  * @param kind     Entity kind.
  4208  * @param {string} name     Entity name.
  4823  * @param name     Entity name.
  4209  * @param {number} recordId Record ID.
  4824  * @param recordId Record ID.
  4210  *
  4825  *
  4211  * @return {Object?} The entity record's edits.
  4826  * @return The entity record's edits.
  4212  */
  4827  */
  4213 
       
  4214 function getEntityRecordEdits(state, kind, name, recordId) {
  4828 function getEntityRecordEdits(state, kind, name, recordId) {
  4215   return (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'edits', recordId]);
  4829   return state.entities.records?.[kind]?.[name]?.edits?.[recordId];
  4216 }
  4830 }
       
  4831 
  4217 /**
  4832 /**
  4218  * Returns the specified entity record's non transient edits.
  4833  * Returns the specified entity record's non transient edits.
  4219  *
  4834  *
  4220  * Transient edits don't create an undo level, and
  4835  * Transient edits don't create an undo level, and
  4221  * are not considered for change detection.
  4836  * are not considered for change detection.
  4222  * They are defined in the entity's config.
  4837  * They are defined in the entity's config.
  4223  *
  4838  *
  4224  * @param {Object} state    State tree.
  4839  * @param state    State tree.
  4225  * @param {string} kind     Entity kind.
  4840  * @param kind     Entity kind.
  4226  * @param {string} name     Entity name.
  4841  * @param name     Entity name.
  4227  * @param {number} recordId Record ID.
  4842  * @param recordId Record ID.
  4228  *
  4843  *
  4229  * @return {Object?} The entity record's non transient edits.
  4844  * @return The entity record's non transient edits.
  4230  */
  4845  */
  4231 
  4846 const getEntityRecordNonTransientEdits = (0,external_wp_data_namespaceObject.createSelector)((state, kind, name, recordId) => {
  4232 const getEntityRecordNonTransientEdits = rememo((state, kind, name, recordId) => {
       
  4233   const {
  4847   const {
  4234     transientEdits
  4848     transientEdits
  4235   } = getEntityConfig(state, kind, name) || {};
  4849   } = getEntityConfig(state, kind, name) || {};
  4236   const edits = getEntityRecordEdits(state, kind, name, recordId) || {};
  4850   const edits = getEntityRecordEdits(state, kind, name, recordId) || {};
  4237 
       
  4238   if (!transientEdits) {
  4851   if (!transientEdits) {
  4239     return edits;
  4852     return edits;
  4240   }
  4853   }
  4241 
       
  4242   return Object.keys(edits).reduce((acc, key) => {
  4854   return Object.keys(edits).reduce((acc, key) => {
  4243     if (!transientEdits[key]) {
  4855     if (!transientEdits[key]) {
  4244       acc[key] = edits[key];
  4856       acc[key] = edits[key];
  4245     }
  4857     }
  4246 
       
  4247     return acc;
  4858     return acc;
  4248   }, {});
  4859   }, {});
  4249 }, (state, kind, name, recordId) => [state.entities.config, (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'edits', recordId])]);
  4860 }, (state, kind, name, recordId) => [state.entities.config, state.entities.records?.[kind]?.[name]?.edits?.[recordId]]);
       
  4861 
  4250 /**
  4862 /**
  4251  * Returns true if the specified entity record has edits,
  4863  * Returns true if the specified entity record has edits,
  4252  * and false otherwise.
  4864  * and false otherwise.
  4253  *
  4865  *
  4254  * @param {Object}        state    State tree.
  4866  * @param state    State tree.
  4255  * @param {string}        kind     Entity kind.
  4867  * @param kind     Entity kind.
  4256  * @param {string}        name     Entity name.
  4868  * @param name     Entity name.
  4257  * @param {number|string} recordId Record ID.
  4869  * @param recordId Record ID.
  4258  *
  4870  *
  4259  * @return {boolean} Whether the entity record has edits or not.
  4871  * @return Whether the entity record has edits or not.
  4260  */
  4872  */
  4261 
       
  4262 function hasEditsForEntityRecord(state, kind, name, recordId) {
  4873 function hasEditsForEntityRecord(state, kind, name, recordId) {
  4263   return isSavingEntityRecord(state, kind, name, recordId) || Object.keys(getEntityRecordNonTransientEdits(state, kind, name, recordId)).length > 0;
  4874   return isSavingEntityRecord(state, kind, name, recordId) || Object.keys(getEntityRecordNonTransientEdits(state, kind, name, recordId)).length > 0;
  4264 }
  4875 }
       
  4876 
  4265 /**
  4877 /**
  4266  * Returns the specified entity record, merged with its edits.
  4878  * Returns the specified entity record, merged with its edits.
  4267  *
  4879  *
  4268  * @param {Object}        state    State tree.
  4880  * @param state    State tree.
  4269  * @param {string}        kind     Entity kind.
  4881  * @param kind     Entity kind.
  4270  * @param {string}        name     Entity name.
  4882  * @param name     Entity name.
  4271  * @param {number|string} recordId Record ID.
  4883  * @param recordId Record ID.
  4272  *
  4884  *
  4273  * @return {Object?} The entity record, merged with its edits.
  4885  * @return The entity record, merged with its edits.
  4274  */
  4886  */
  4275 
  4887 const getEditedEntityRecord = (0,external_wp_data_namespaceObject.createSelector)((state, kind, name, recordId) => {
  4276 const getEditedEntityRecord = rememo((state, kind, name, recordId) => ({ ...getRawEntityRecord(state, kind, name, recordId),
  4888   const raw = getRawEntityRecord(state, kind, name, recordId);
  4277   ...getEntityRecordEdits(state, kind, name, recordId)
  4889   const edited = getEntityRecordEdits(state, kind, name, recordId);
  4278 }), (state, kind, name, recordId, query) => {
  4890   // Never return a non-falsy empty object. Unfortunately we can't return
       
  4891   // undefined or null because we were previously returning an empty
       
  4892   // object, so trying to read properties from the result would throw.
       
  4893   // Using false here is a workaround to avoid breaking changes.
       
  4894   if (!raw && !edited) {
       
  4895     return false;
       
  4896   }
       
  4897   return {
       
  4898     ...raw,
       
  4899     ...edited
       
  4900   };
       
  4901 }, (state, kind, name, recordId, query) => {
  4279   var _query$context4;
  4902   var _query$context4;
  4280 
  4903   const context = (_query$context4 = query?.context) !== null && _query$context4 !== void 0 ? _query$context4 : 'default';
  4281   const context = (_query$context4 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context4 !== void 0 ? _query$context4 : 'default';
  4904   return [state.entities.config, state.entities.records?.[kind]?.[name]?.queriedData.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData.itemIsComplete[context]?.[recordId], state.entities.records?.[kind]?.[name]?.edits?.[recordId]];
  4282   return [state.entities.config, (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'queriedData', 'items', context, recordId]), (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'queriedData', 'itemIsComplete', context, recordId]), (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'edits', recordId])];
       
  4283 });
  4905 });
       
  4906 
  4284 /**
  4907 /**
  4285  * Returns true if the specified entity record is autosaving, and false otherwise.
  4908  * Returns true if the specified entity record is autosaving, and false otherwise.
  4286  *
  4909  *
  4287  * @param {Object} state    State tree.
  4910  * @param state    State tree.
  4288  * @param {string} kind     Entity kind.
  4911  * @param kind     Entity kind.
  4289  * @param {string} name     Entity name.
  4912  * @param name     Entity name.
  4290  * @param {number} recordId Record ID.
  4913  * @param recordId Record ID.
  4291  *
  4914  *
  4292  * @return {boolean} Whether the entity record is autosaving or not.
  4915  * @return Whether the entity record is autosaving or not.
  4293  */
  4916  */
  4294 
       
  4295 function isAutosavingEntityRecord(state, kind, name, recordId) {
  4917 function isAutosavingEntityRecord(state, kind, name, recordId) {
       
  4918   var _state$entities$recor;
  4296   const {
  4919   const {
  4297     pending,
  4920     pending,
  4298     isAutosave
  4921     isAutosave
  4299   } = (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'saving', recordId], {});
  4922   } = (_state$entities$recor = state.entities.records?.[kind]?.[name]?.saving?.[recordId]) !== null && _state$entities$recor !== void 0 ? _state$entities$recor : {};
  4300   return Boolean(pending && isAutosave);
  4923   return Boolean(pending && isAutosave);
  4301 }
  4924 }
       
  4925 
  4302 /**
  4926 /**
  4303  * Returns true if the specified entity record is saving, and false otherwise.
  4927  * Returns true if the specified entity record is saving, and false otherwise.
  4304  *
  4928  *
  4305  * @param {Object}        state    State tree.
  4929  * @param state    State tree.
  4306  * @param {string}        kind     Entity kind.
  4930  * @param kind     Entity kind.
  4307  * @param {string}        name     Entity name.
  4931  * @param name     Entity name.
  4308  * @param {number|string} recordId Record ID.
  4932  * @param recordId Record ID.
  4309  *
  4933  *
  4310  * @return {boolean} Whether the entity record is saving or not.
  4934  * @return Whether the entity record is saving or not.
  4311  */
  4935  */
  4312 
       
  4313 function isSavingEntityRecord(state, kind, name, recordId) {
  4936 function isSavingEntityRecord(state, kind, name, recordId) {
  4314   return (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'saving', recordId, 'pending'], false);
  4937   var _state$entities$recor2;
  4315 }
  4938   return (_state$entities$recor2 = state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.pending) !== null && _state$entities$recor2 !== void 0 ? _state$entities$recor2 : false;
       
  4939 }
       
  4940 
  4316 /**
  4941 /**
  4317  * Returns true if the specified entity record is deleting, and false otherwise.
  4942  * Returns true if the specified entity record is deleting, and false otherwise.
  4318  *
  4943  *
  4319  * @param {Object} state    State tree.
  4944  * @param state    State tree.
  4320  * @param {string} kind     Entity kind.
  4945  * @param kind     Entity kind.
  4321  * @param {string} name     Entity name.
  4946  * @param name     Entity name.
  4322  * @param {number} recordId Record ID.
  4947  * @param recordId Record ID.
  4323  *
  4948  *
  4324  * @return {boolean} Whether the entity record is deleting or not.
  4949  * @return Whether the entity record is deleting or not.
  4325  */
  4950  */
  4326 
       
  4327 function isDeletingEntityRecord(state, kind, name, recordId) {
  4951 function isDeletingEntityRecord(state, kind, name, recordId) {
  4328   return (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'deleting', recordId, 'pending'], false);
  4952   var _state$entities$recor3;
  4329 }
  4953   return (_state$entities$recor3 = state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.pending) !== null && _state$entities$recor3 !== void 0 ? _state$entities$recor3 : false;
       
  4954 }
       
  4955 
  4330 /**
  4956 /**
  4331  * Returns the specified entity record's last save error.
  4957  * Returns the specified entity record's last save error.
  4332  *
  4958  *
  4333  * @param {Object} state    State tree.
  4959  * @param state    State tree.
  4334  * @param {string} kind     Entity kind.
  4960  * @param kind     Entity kind.
  4335  * @param {string} name     Entity name.
  4961  * @param name     Entity name.
  4336  * @param {number} recordId Record ID.
  4962  * @param recordId Record ID.
  4337  *
  4963  *
  4338  * @return {Object?} The entity record's save error.
  4964  * @return The entity record's save error.
  4339  */
  4965  */
  4340 
       
  4341 function getLastEntitySaveError(state, kind, name, recordId) {
  4966 function getLastEntitySaveError(state, kind, name, recordId) {
  4342   return (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'saving', recordId, 'error']);
  4967   return state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.error;
  4343 }
  4968 }
       
  4969 
  4344 /**
  4970 /**
  4345  * Returns the specified entity record's last delete error.
  4971  * Returns the specified entity record's last delete error.
  4346  *
  4972  *
  4347  * @param {Object} state    State tree.
  4973  * @param state    State tree.
  4348  * @param {string} kind     Entity kind.
  4974  * @param kind     Entity kind.
  4349  * @param {string} name     Entity name.
  4975  * @param name     Entity name.
  4350  * @param {number} recordId Record ID.
  4976  * @param recordId Record ID.
  4351  *
  4977  *
  4352  * @return {Object?} The entity record's save error.
  4978  * @return The entity record's save error.
  4353  */
  4979  */
  4354 
       
  4355 function getLastEntityDeleteError(state, kind, name, recordId) {
  4980 function getLastEntityDeleteError(state, kind, name, recordId) {
  4356   return (0,external_lodash_namespaceObject.get)(state.entities.records, [kind, name, 'deleting', recordId, 'error']);
  4981   return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.error;
  4357 }
  4982 }
  4358 /**
  4983 
  4359  * Returns the current undo offset for the
       
  4360  * entity records edits history. The offset
       
  4361  * represents how many items from the end
       
  4362  * of the history stack we are at. 0 is the
       
  4363  * last edit, -1 is the second last, and so on.
       
  4364  *
       
  4365  * @param {Object} state State tree.
       
  4366  *
       
  4367  * @return {number} The current undo offset.
       
  4368  */
       
  4369 
       
  4370 function getCurrentUndoOffset(state) {
       
  4371   return state.undo.offset;
       
  4372 }
       
  4373 /**
  4984 /**
  4374  * Returns the previous edit from the current undo offset
  4985  * Returns the previous edit from the current undo offset
  4375  * for the entity records edits history, if any.
  4986  * for the entity records edits history, if any.
  4376  *
  4987  *
  4377  * @param {Object} state State tree.
  4988  * @deprecated since 6.3
  4378  *
  4989  *
  4379  * @return {Object?} The edit.
  4990  * @param      state State tree.
  4380  */
  4991  *
  4381 
  4992  * @return The edit.
  4382 
  4993  */
  4383 function getUndoEdit(state) {
  4994 function getUndoEdit(state) {
  4384   return state.undo[state.undo.length - 2 + getCurrentUndoOffset(state)];
  4995   external_wp_deprecated_default()("select( 'core' ).getUndoEdit()", {
  4385 }
  4996     since: '6.3'
       
  4997   });
       
  4998   return undefined;
       
  4999 }
       
  5000 
  4386 /**
  5001 /**
  4387  * Returns the next edit from the current undo offset
  5002  * Returns the next edit from the current undo offset
  4388  * for the entity records edits history, if any.
  5003  * for the entity records edits history, if any.
  4389  *
  5004  *
  4390  * @param {Object} state State tree.
  5005  * @deprecated since 6.3
  4391  *
  5006  *
  4392  * @return {Object?} The edit.
  5007  * @param      state State tree.
  4393  */
  5008  *
  4394 
  5009  * @return The edit.
       
  5010  */
  4395 function getRedoEdit(state) {
  5011 function getRedoEdit(state) {
  4396   return state.undo[state.undo.length + getCurrentUndoOffset(state)];
  5012   external_wp_deprecated_default()("select( 'core' ).getRedoEdit()", {
  4397 }
  5013     since: '6.3'
       
  5014   });
       
  5015   return undefined;
       
  5016 }
       
  5017 
  4398 /**
  5018 /**
  4399  * Returns true if there is a previous edit from the current undo offset
  5019  * Returns true if there is a previous edit from the current undo offset
  4400  * for the entity records edits history, and false otherwise.
  5020  * for the entity records edits history, and false otherwise.
  4401  *
  5021  *
  4402  * @param {Object} state State tree.
  5022  * @param state State tree.
  4403  *
  5023  *
  4404  * @return {boolean} Whether there is a previous edit or not.
  5024  * @return Whether there is a previous edit or not.
  4405  */
  5025  */
  4406 
       
  4407 function hasUndo(state) {
  5026 function hasUndo(state) {
  4408   return Boolean(getUndoEdit(state));
  5027   return state.undoManager.hasUndo();
  4409 }
  5028 }
       
  5029 
  4410 /**
  5030 /**
  4411  * Returns true if there is a next edit from the current undo offset
  5031  * Returns true if there is a next edit from the current undo offset
  4412  * for the entity records edits history, and false otherwise.
  5032  * for the entity records edits history, and false otherwise.
  4413  *
  5033  *
  4414  * @param {Object} state State tree.
  5034  * @param state State tree.
  4415  *
  5035  *
  4416  * @return {boolean} Whether there is a next edit or not.
  5036  * @return Whether there is a next edit or not.
  4417  */
  5037  */
  4418 
       
  4419 function hasRedo(state) {
  5038 function hasRedo(state) {
  4420   return Boolean(getRedoEdit(state));
  5039   return state.undoManager.hasRedo();
  4421 }
  5040 }
       
  5041 
  4422 /**
  5042 /**
  4423  * Return the current theme.
  5043  * Return the current theme.
  4424  *
  5044  *
  4425  * @param {Object} state Data state.
  5045  * @param state Data state.
  4426  *
  5046  *
  4427  * @return {Object} The current theme.
  5047  * @return The current theme.
  4428  */
  5048  */
  4429 
       
  4430 function getCurrentTheme(state) {
  5049 function getCurrentTheme(state) {
       
  5050   if (!state.currentTheme) {
       
  5051     return null;
       
  5052   }
  4431   return getEntityRecord(state, 'root', 'theme', state.currentTheme);
  5053   return getEntityRecord(state, 'root', 'theme', state.currentTheme);
  4432 }
  5054 }
       
  5055 
  4433 /**
  5056 /**
  4434  * Return the ID of the current global styles object.
  5057  * Return the ID of the current global styles object.
  4435  *
  5058  *
  4436  * @param {Object} state Data state.
  5059  * @param state Data state.
  4437  *
  5060  *
  4438  * @return {string} The current global styles ID.
  5061  * @return The current global styles ID.
  4439  */
  5062  */
  4440 
       
  4441 function __experimentalGetCurrentGlobalStylesId(state) {
  5063 function __experimentalGetCurrentGlobalStylesId(state) {
  4442   return state.currentGlobalStylesId;
  5064   return state.currentGlobalStylesId;
  4443 }
  5065 }
       
  5066 
  4444 /**
  5067 /**
  4445  * Return theme supports data in the index.
  5068  * Return theme supports data in the index.
  4446  *
  5069  *
  4447  * @param {Object} state Data state.
  5070  * @param state Data state.
  4448  *
  5071  *
  4449  * @return {*} Index data.
  5072  * @return Index data.
  4450  */
  5073  */
  4451 
       
  4452 function getThemeSupports(state) {
  5074 function getThemeSupports(state) {
  4453   var _getCurrentTheme$them, _getCurrentTheme;
  5075   var _getCurrentTheme$them;
  4454 
  5076   return (_getCurrentTheme$them = getCurrentTheme(state)?.theme_supports) !== null && _getCurrentTheme$them !== void 0 ? _getCurrentTheme$them : EMPTY_OBJECT;
  4455   return (_getCurrentTheme$them = (_getCurrentTheme = getCurrentTheme(state)) === null || _getCurrentTheme === void 0 ? void 0 : _getCurrentTheme.theme_supports) !== null && _getCurrentTheme$them !== void 0 ? _getCurrentTheme$them : EMPTY_OBJECT;
  5077 }
  4456 }
  5078 
  4457 /**
  5079 /**
  4458  * Returns the embed preview for the given URL.
  5080  * Returns the embed preview for the given URL.
  4459  *
  5081  *
  4460  * @param {Object} state Data state.
  5082  * @param state Data state.
  4461  * @param {string} url   Embedded URL.
  5083  * @param url   Embedded URL.
  4462  *
  5084  *
  4463  * @return {*} Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
  5085  * @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
  4464  */
  5086  */
  4465 
       
  4466 function getEmbedPreview(state, url) {
  5087 function getEmbedPreview(state, url) {
  4467   return state.embedPreviews[url];
  5088   return state.embedPreviews[url];
  4468 }
  5089 }
       
  5090 
  4469 /**
  5091 /**
  4470  * Determines if the returned preview is an oEmbed link fallback.
  5092  * Determines if the returned preview is an oEmbed link fallback.
  4471  *
  5093  *
  4472  * WordPress can be configured to return a simple link to a URL if it is not embeddable.
  5094  * WordPress can be configured to return a simple link to a URL if it is not embeddable.
  4473  * We need to be able to determine if a URL is embeddable or not, based on what we
  5095  * We need to be able to determine if a URL is embeddable or not, based on what we
  4474  * get back from the oEmbed preview API.
  5096  * get back from the oEmbed preview API.
  4475  *
  5097  *
  4476  * @param {Object} state Data state.
  5098  * @param state Data state.
  4477  * @param {string} url   Embedded URL.
  5099  * @param url   Embedded URL.
  4478  *
  5100  *
  4479  * @return {boolean} Is the preview for the URL an oEmbed link fallback.
  5101  * @return Is the preview for the URL an oEmbed link fallback.
  4480  */
  5102  */
  4481 
       
  4482 function isPreviewEmbedFallback(state, url) {
  5103 function isPreviewEmbedFallback(state, url) {
  4483   const preview = state.embedPreviews[url];
  5104   const preview = state.embedPreviews[url];
  4484   const oEmbedLinkCheck = '<a href="' + url + '">' + url + '</a>';
  5105   const oEmbedLinkCheck = '<a href="' + url + '">' + url + '</a>';
  4485 
       
  4486   if (!preview) {
  5106   if (!preview) {
  4487     return false;
  5107     return false;
  4488   }
  5108   }
  4489 
       
  4490   return preview.html === oEmbedLinkCheck;
  5109   return preview.html === oEmbedLinkCheck;
  4491 }
  5110 }
       
  5111 
  4492 /**
  5112 /**
  4493  * Returns whether the current user can perform the given action on the given
  5113  * Returns whether the current user can perform the given action on the given
  4494  * REST resource.
  5114  * REST resource.
  4495  *
  5115  *
  4496  * Calling this may trigger an OPTIONS request to the REST API via the
  5116  * Calling this may trigger an OPTIONS request to the REST API via the
  4497  * `canUser()` resolver.
  5117  * `canUser()` resolver.
  4498  *
  5118  *
  4499  * https://developer.wordpress.org/rest-api/reference/
  5119  * https://developer.wordpress.org/rest-api/reference/
  4500  *
  5120  *
  4501  * @param {Object}  state    Data state.
  5121  * @param state    Data state.
  4502  * @param {string}  action   Action to check. One of: 'create', 'read', 'update', 'delete'.
  5122  * @param action   Action to check. One of: 'create', 'read', 'update', 'delete'.
  4503  * @param {string}  resource REST resource to check, e.g. 'media' or 'posts'.
  5123  * @param resource REST resource to check, e.g. 'media' or 'posts'.
  4504  * @param {string=} id       Optional ID of the rest resource to check.
  5124  * @param id       Optional ID of the rest resource to check.
  4505  *
  5125  *
  4506  * @return {boolean|undefined} Whether or not the user can perform the action,
  5126  * @return Whether or not the user can perform the action,
  4507  *                             or `undefined` if the OPTIONS request is still being made.
  5127  *                             or `undefined` if the OPTIONS request is still being made.
  4508  */
  5128  */
  4509 
       
  4510 function canUser(state, action, resource, id) {
  5129 function canUser(state, action, resource, id) {
  4511   const key = (0,external_lodash_namespaceObject.compact)([action, resource, id]).join('/');
  5130   const key = [action, resource, id].filter(Boolean).join('/');
  4512   return (0,external_lodash_namespaceObject.get)(state, ['userPermissions', key]);
  5131   return state.userPermissions[key];
  4513 }
  5132 }
       
  5133 
  4514 /**
  5134 /**
  4515  * Returns whether the current user can edit the given entity.
  5135  * Returns whether the current user can edit the given entity.
  4516  *
  5136  *
  4517  * Calling this may trigger an OPTIONS request to the REST API via the
  5137  * Calling this may trigger an OPTIONS request to the REST API via the
  4518  * `canUser()` resolver.
  5138  * `canUser()` resolver.
  4519  *
  5139  *
  4520  * https://developer.wordpress.org/rest-api/reference/
  5140  * https://developer.wordpress.org/rest-api/reference/
  4521  *
  5141  *
  4522  * @param {Object} state    Data state.
  5142  * @param state    Data state.
  4523  * @param {string} kind     Entity kind.
  5143  * @param kind     Entity kind.
  4524  * @param {string} name     Entity name.
  5144  * @param name     Entity name.
  4525  * @param {string} recordId Record's id.
  5145  * @param recordId Record's id.
  4526  * @return {boolean|undefined} Whether or not the user can edit,
  5146  * @return Whether or not the user can edit,
  4527  * or `undefined` if the OPTIONS request is still being made.
  5147  * or `undefined` if the OPTIONS request is still being made.
  4528  */
  5148  */
  4529 
       
  4530 function canUserEditEntityRecord(state, kind, name, recordId) {
  5149 function canUserEditEntityRecord(state, kind, name, recordId) {
  4531   const entityConfig = getEntityConfig(state, kind, name);
  5150   const entityConfig = getEntityConfig(state, kind, name);
  4532 
       
  4533   if (!entityConfig) {
  5151   if (!entityConfig) {
  4534     return false;
  5152     return false;
  4535   }
  5153   }
  4536 
       
  4537   const resource = entityConfig.__unstable_rest_base;
  5154   const resource = entityConfig.__unstable_rest_base;
  4538   return canUser(state, 'update', resource, recordId);
  5155   return canUser(state, 'update', resource, recordId);
  4539 }
  5156 }
       
  5157 
  4540 /**
  5158 /**
  4541  * Returns the latest autosaves for the post.
  5159  * Returns the latest autosaves for the post.
  4542  *
  5160  *
  4543  * May return multiple autosaves since the backend stores one autosave per
  5161  * May return multiple autosaves since the backend stores one autosave per
  4544  * author for each post.
  5162  * author for each post.
  4545  *
  5163  *
  4546  * @param {Object} state    State tree.
  5164  * @param state    State tree.
  4547  * @param {string} postType The type of the parent post.
  5165  * @param postType The type of the parent post.
  4548  * @param {number} postId   The id of the parent post.
  5166  * @param postId   The id of the parent post.
  4549  *
  5167  *
  4550  * @return {?Array} An array of autosaves for the post, or undefined if there is none.
  5168  * @return An array of autosaves for the post, or undefined if there is none.
  4551  */
  5169  */
  4552 
       
  4553 function getAutosaves(state, postType, postId) {
  5170 function getAutosaves(state, postType, postId) {
  4554   return state.autosaves[postId];
  5171   return state.autosaves[postId];
  4555 }
  5172 }
       
  5173 
  4556 /**
  5174 /**
  4557  * Returns the autosave for the post and author.
  5175  * Returns the autosave for the post and author.
  4558  *
  5176  *
  4559  * @param {Object} state    State tree.
  5177  * @param state    State tree.
  4560  * @param {string} postType The type of the parent post.
  5178  * @param postType The type of the parent post.
  4561  * @param {number} postId   The id of the parent post.
  5179  * @param postId   The id of the parent post.
  4562  * @param {number} authorId The id of the author.
  5180  * @param authorId The id of the author.
  4563  *
  5181  *
  4564  * @return {?Object} The autosave for the post and author.
  5182  * @return The autosave for the post and author.
  4565  */
  5183  */
  4566 
       
  4567 function getAutosave(state, postType, postId, authorId) {
  5184 function getAutosave(state, postType, postId, authorId) {
  4568   if (authorId === undefined) {
  5185   if (authorId === undefined) {
  4569     return;
  5186     return;
  4570   }
  5187   }
  4571 
       
  4572   const autosaves = state.autosaves[postId];
  5188   const autosaves = state.autosaves[postId];
  4573   return (0,external_lodash_namespaceObject.find)(autosaves, {
  5189   return autosaves?.find(autosave => autosave.author === authorId);
  4574     author: authorId
  5190 }
  4575   });
  5191 
  4576 }
       
  4577 /**
  5192 /**
  4578  * Returns true if the REST request for autosaves has completed.
  5193  * Returns true if the REST request for autosaves has completed.
  4579  *
  5194  *
  4580  * @param {Object} state    State tree.
  5195  * @param state    State tree.
  4581  * @param {string} postType The type of the parent post.
  5196  * @param postType The type of the parent post.
  4582  * @param {number} postId   The id of the parent post.
  5197  * @param postId   The id of the parent post.
  4583  *
  5198  *
  4584  * @return {boolean} True if the REST request was completed. False otherwise.
  5199  * @return True if the REST request was completed. False otherwise.
  4585  */
  5200  */
  4586 
       
  4587 const hasFetchedAutosaves = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, postId) => {
  5201 const hasFetchedAutosaves = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, postId) => {
  4588   return select(STORE_NAME).hasFinishedResolution('getAutosaves', [postType, postId]);
  5202   return select(STORE_NAME).hasFinishedResolution('getAutosaves', [postType, postId]);
  4589 });
  5203 });
       
  5204 
  4590 /**
  5205 /**
  4591  * Returns a new reference when edited values have changed. This is useful in
  5206  * Returns a new reference when edited values have changed. This is useful in
  4592  * inferring where an edit has been made between states by comparison of the
  5207  * inferring where an edit has been made between states by comparison of the
  4593  * return values using strict equality.
  5208  * return values using strict equality.
  4594  *
  5209  *
  4599  *    getReferenceByDistinctEdits( beforeState ) !==
  5214  *    getReferenceByDistinctEdits( beforeState ) !==
  4600  *    getReferenceByDistinctEdits( afterState )
  5215  *    getReferenceByDistinctEdits( afterState )
  4601  * );
  5216  * );
  4602  * ```
  5217  * ```
  4603  *
  5218  *
  4604  * @param {Object} state Editor state.
  5219  * @param state Editor state.
  4605  *
  5220  *
  4606  * @return {*} A value whose reference will change only when an edit occurs.
  5221  * @return A value whose reference will change only when an edit occurs.
  4607  */
  5222  */
  4608 
  5223 function getReferenceByDistinctEdits(state) {
  4609 const getReferenceByDistinctEdits = rememo(() => [], state => [state.undo.length, state.undo.offset, state.undo.flattenedUndo]);
  5224   return state.editsReference;
       
  5225 }
       
  5226 
  4610 /**
  5227 /**
  4611  * Retrieve the frontend template used for a given link.
  5228  * Retrieve the frontend template used for a given link.
  4612  *
  5229  *
  4613  * @param {Object} state Editor state.
  5230  * @param state Editor state.
  4614  * @param {string} link  Link.
  5231  * @param link  Link.
  4615  *
  5232  *
  4616  * @return {Object?} The template record.
  5233  * @return The template record.
  4617  */
  5234  */
  4618 
       
  4619 function __experimentalGetTemplateForLink(state, link) {
  5235 function __experimentalGetTemplateForLink(state, link) {
  4620   const records = getEntityRecords(state, 'postType', 'wp_template', {
  5236   const records = getEntityRecords(state, 'postType', 'wp_template', {
  4621     'find-template': link
  5237     'find-template': link
  4622   });
  5238   });
  4623   const template = records !== null && records !== void 0 && records.length ? records[0] : null;
  5239   if (records?.length) {
  4624 
  5240     return getEditedEntityRecord(state, 'postType', 'wp_template', records[0].id);
  4625   if (template) {
  5241   }
  4626     return getEditedEntityRecord(state, 'postType', 'wp_template', template.id);
  5242   return null;
  4627   }
  5243 }
  4628 
  5244 
  4629   return template;
       
  4630 }
       
  4631 /**
  5245 /**
  4632  * Retrieve the current theme's base global styles
  5246  * Retrieve the current theme's base global styles
  4633  *
  5247  *
  4634  * @param {Object} state Editor state.
  5248  * @param state Editor state.
  4635  *
  5249  *
  4636  * @return {Object|null} The Global Styles object.
  5250  * @return The Global Styles object.
  4637  */
  5251  */
  4638 
       
  4639 function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
  5252 function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
  4640   const currentTheme = getCurrentTheme(state);
  5253   const currentTheme = getCurrentTheme(state);
  4641 
       
  4642   if (!currentTheme) {
  5254   if (!currentTheme) {
  4643     return null;
  5255     return null;
  4644   }
  5256   }
  4645 
       
  4646   return state.themeBaseGlobalStyles[currentTheme.stylesheet];
  5257   return state.themeBaseGlobalStyles[currentTheme.stylesheet];
  4647 }
  5258 }
       
  5259 
  4648 /**
  5260 /**
  4649  * Return the ID of the current global styles object.
  5261  * Return the ID of the current global styles object.
  4650  *
  5262  *
  4651  * @param {Object} state Data state.
  5263  * @param state Data state.
  4652  *
  5264  *
  4653  * @return {string|null} The current global styles ID.
  5265  * @return The current global styles ID.
  4654  */
  5266  */
  4655 
       
  4656 function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
  5267 function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
  4657   const currentTheme = getCurrentTheme(state);
  5268   const currentTheme = getCurrentTheme(state);
  4658 
       
  4659   if (!currentTheme) {
  5269   if (!currentTheme) {
  4660     return null;
  5270     return null;
  4661   }
  5271   }
  4662 
       
  4663   return state.themeGlobalStyleVariations[currentTheme.stylesheet];
  5272   return state.themeGlobalStyleVariations[currentTheme.stylesheet];
  4664 }
  5273 }
       
  5274 
  4665 /**
  5275 /**
  4666  * Retrieve the list of registered block patterns.
  5276  * Retrieve the list of registered block patterns.
  4667  *
  5277  *
  4668  * @param {Object} state Data state.
  5278  * @param state Data state.
  4669  *
  5279  *
  4670  * @return {Array} Block pattern list.
  5280  * @return Block pattern list.
  4671  */
  5281  */
  4672 
       
  4673 function getBlockPatterns(state) {
  5282 function getBlockPatterns(state) {
  4674   return state.blockPatterns;
  5283   return state.blockPatterns;
  4675 }
  5284 }
       
  5285 
  4676 /**
  5286 /**
  4677  * Retrieve the list of registered block pattern categories.
  5287  * Retrieve the list of registered block pattern categories.
  4678  *
  5288  *
  4679  * @param {Object} state Data state.
  5289  * @param state Data state.
  4680  *
  5290  *
  4681  * @return {Array} Block pattern category list.
  5291  * @return Block pattern category list.
  4682  */
  5292  */
  4683 
       
  4684 function getBlockPatternCategories(state) {
  5293 function getBlockPatternCategories(state) {
  4685   return state.blockPatternCategories;
  5294   return state.blockPatternCategories;
  4686 }
  5295 }
  4687 
  5296 
       
  5297 /**
       
  5298  * Retrieve the registered user pattern categories.
       
  5299  *
       
  5300  * @param state Data state.
       
  5301  *
       
  5302  * @return User patterns category array.
       
  5303  */
       
  5304 
       
  5305 function getUserPatternCategories(state) {
       
  5306   return state.userPatternCategories;
       
  5307 }
       
  5308 
       
  5309 /**
       
  5310  * Returns the revisions of the current global styles theme.
       
  5311  *
       
  5312  * @deprecated since WordPress 6.5.0. Callers should use `select( 'core' ).getRevisions( 'root', 'globalStyles', ${ recordKey } )` instead, where `recordKey` is the id of the global styles parent post.
       
  5313  *
       
  5314  * @param      state Data state.
       
  5315  *
       
  5316  * @return The current global styles.
       
  5317  */
       
  5318 function getCurrentThemeGlobalStylesRevisions(state) {
       
  5319   external_wp_deprecated_default()("select( 'core' ).getCurrentThemeGlobalStylesRevisions()", {
       
  5320     since: '6.5.0',
       
  5321     alternative: "select( 'core' ).getRevisions( 'root', 'globalStyles', ${ recordKey } )"
       
  5322   });
       
  5323   const currentGlobalStylesId = __experimentalGetCurrentGlobalStylesId(state);
       
  5324   if (!currentGlobalStylesId) {
       
  5325     return null;
       
  5326   }
       
  5327   return state.themeGlobalStyleRevisions[currentGlobalStylesId];
       
  5328 }
       
  5329 
       
  5330 /**
       
  5331  * Returns the default template use to render a given query.
       
  5332  *
       
  5333  * @param state Data state.
       
  5334  * @param query Query.
       
  5335  *
       
  5336  * @return The default template id for the given query.
       
  5337  */
       
  5338 function getDefaultTemplateId(state, query) {
       
  5339   return state.defaultTemplates[JSON.stringify(query)];
       
  5340 }
       
  5341 
       
  5342 /**
       
  5343  * Returns an entity's revisions.
       
  5344  *
       
  5345  * @param state     State tree
       
  5346  * @param kind      Entity kind.
       
  5347  * @param name      Entity name.
       
  5348  * @param recordKey The key of the entity record whose revisions you want to fetch.
       
  5349  * @param query     Optional query. If requesting specific
       
  5350  *                  fields, fields must always include the ID. For valid query parameters see revisions schema in [the REST API Handbook](https://developer.wordpress.org/rest-api/reference/). Then see the arguments available "Retrieve a [Entity kind]".
       
  5351  *
       
  5352  * @return Record.
       
  5353  */
       
  5354 const getRevisions = (state, kind, name, recordKey, query) => {
       
  5355   const queriedStateRevisions = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
       
  5356   if (!queriedStateRevisions) {
       
  5357     return null;
       
  5358   }
       
  5359   return getQueriedItems(queriedStateRevisions, query);
       
  5360 };
       
  5361 
       
  5362 /**
       
  5363  * Returns a single, specific revision of a parent entity.
       
  5364  *
       
  5365  * @param state       State tree
       
  5366  * @param kind        Entity kind.
       
  5367  * @param name        Entity name.
       
  5368  * @param recordKey   The key of the entity record whose revisions you want to fetch.
       
  5369  * @param revisionKey The revision's key.
       
  5370  * @param query       Optional query. If requesting specific
       
  5371  *                    fields, fields must always include the ID. For valid query parameters see revisions schema in [the REST API Handbook](https://developer.wordpress.org/rest-api/reference/). Then see the arguments available "Retrieve a [entity kind]".
       
  5372  *
       
  5373  * @return Record.
       
  5374  */
       
  5375 const getRevision = (0,external_wp_data_namespaceObject.createSelector)((state, kind, name, recordKey, revisionKey, query) => {
       
  5376   var _query$context5;
       
  5377   const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
       
  5378   if (!queriedState) {
       
  5379     return undefined;
       
  5380   }
       
  5381   const context = (_query$context5 = query?.context) !== null && _query$context5 !== void 0 ? _query$context5 : 'default';
       
  5382   if (query === undefined) {
       
  5383     // If expecting a complete item, validate that completeness.
       
  5384     if (!queriedState.itemIsComplete[context]?.[revisionKey]) {
       
  5385       return undefined;
       
  5386     }
       
  5387     return queriedState.items[context][revisionKey];
       
  5388   }
       
  5389   const item = queriedState.items[context]?.[revisionKey];
       
  5390   if (item && query._fields) {
       
  5391     var _getNormalizedCommaSe2;
       
  5392     const filteredItem = {};
       
  5393     const fields = (_getNormalizedCommaSe2 = get_normalized_comma_separable(query._fields)) !== null && _getNormalizedCommaSe2 !== void 0 ? _getNormalizedCommaSe2 : [];
       
  5394     for (let f = 0; f < fields.length; f++) {
       
  5395       const field = fields[f].split('.');
       
  5396       let value = item;
       
  5397       field.forEach(fieldName => {
       
  5398         value = value?.[fieldName];
       
  5399       });
       
  5400       setNestedValue(filteredItem, field, value);
       
  5401     }
       
  5402     return filteredItem;
       
  5403   }
       
  5404   return item;
       
  5405 }, (state, kind, name, recordKey, revisionKey, query) => {
       
  5406   var _query$context6;
       
  5407   const context = (_query$context6 = query?.context) !== null && _query$context6 !== void 0 ? _query$context6 : 'default';
       
  5408   return [state.entities.records?.[kind]?.[name]?.revisions?.[recordKey]?.items?.[context]?.[revisionKey], state.entities.records?.[kind]?.[name]?.revisions?.[recordKey]?.itemIsComplete?.[context]?.[revisionKey]];
       
  5409 });
       
  5410 
       
  5411 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/private-selectors.js
       
  5412 /**
       
  5413  * WordPress dependencies
       
  5414  */
       
  5415 
       
  5416 
       
  5417 /**
       
  5418  * Internal dependencies
       
  5419  */
       
  5420 
       
  5421 
       
  5422 /**
       
  5423  * Returns the previous edit from the current undo offset
       
  5424  * for the entity records edits history, if any.
       
  5425  *
       
  5426  * @param state State tree.
       
  5427  *
       
  5428  * @return The undo manager.
       
  5429  */
       
  5430 function getUndoManager(state) {
       
  5431   return state.undoManager;
       
  5432 }
       
  5433 
       
  5434 /**
       
  5435  * Retrieve the fallback Navigation.
       
  5436  *
       
  5437  * @param state Data state.
       
  5438  * @return The ID for the fallback Navigation post.
       
  5439  */
       
  5440 function getNavigationFallbackId(state) {
       
  5441   return state.navigationFallbackId;
       
  5442 }
       
  5443 const getBlockPatternsForPostType = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)((state, postType) => select(STORE_NAME).getBlockPatterns().filter(({
       
  5444   postTypes
       
  5445 }) => !postTypes || Array.isArray(postTypes) && postTypes.includes(postType)), () => [select(STORE_NAME).getBlockPatterns()]));
       
  5446 
       
  5447 ;// CONCATENATED MODULE: ./node_modules/camel-case/dist.es2015/index.js
       
  5448 
       
  5449 
       
  5450 function camelCaseTransform(input, index) {
       
  5451     if (index === 0)
       
  5452         return input.toLowerCase();
       
  5453     return pascalCaseTransform(input, index);
       
  5454 }
       
  5455 function camelCaseTransformMerge(input, index) {
       
  5456     if (index === 0)
       
  5457         return input.toLowerCase();
       
  5458     return pascalCaseTransformMerge(input);
       
  5459 }
       
  5460 function camelCase(input, options) {
       
  5461     if (options === void 0) { options = {}; }
       
  5462     return pascalCase(input, __assign({ transform: camelCaseTransform }, options));
       
  5463 }
       
  5464 
       
  5465 ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
       
  5466 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
  4688 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/forward-resolver.js
  5467 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/forward-resolver.js
  4689 /**
  5468 /**
  4690  * Higher-order function which forward the resolution to another resolver with the same arguments.
  5469  * Higher-order function which forward the resolution to another resolver with the same arguments.
  4691  *
  5470  *
  4692  * @param {string} resolverName forwarded resolver.
  5471  * @param {string} resolverName forwarded resolver.
  4693  *
  5472  *
  4694  * @return {Function} Enhanced resolver.
  5473  * @return {Function} Enhanced resolver.
  4695  */
  5474  */
  4696 const forwardResolver = resolverName => function () {
  5475 const forwardResolver = resolverName => (...args) => async ({
  4697   for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  5476   resolveSelect
  4698     args[_key] = arguments[_key];
  5477 }) => {
  4699   }
  5478   await resolveSelect[resolverName](...args);
  4700 
  5479 };
  4701   return async _ref => {
  5480 /* harmony default export */ const forward_resolver = (forwardResolver);
  4702     let {
  5481 
  4703       resolveSelect
  5482 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/fetch/__experimental-fetch-link-suggestions.js
  4704     } = _ref;
  5483 /**
  4705     await resolveSelect[resolverName](...args);
  5484  * WordPress dependencies
       
  5485  */
       
  5486 
       
  5487 
       
  5488 
       
  5489 
       
  5490 
       
  5491 /**
       
  5492  * Filters the search by type
       
  5493  *
       
  5494  * @typedef { 'attachment' | 'post' | 'term' | 'post-format' } WPLinkSearchType
       
  5495  */
       
  5496 
       
  5497 /**
       
  5498  * A link with an id may be of kind post-type or taxonomy
       
  5499  *
       
  5500  * @typedef { 'post-type' | 'taxonomy' } WPKind
       
  5501  */
       
  5502 
       
  5503 /**
       
  5504  * @typedef WPLinkSearchOptions
       
  5505  *
       
  5506  * @property {boolean}          [isInitialSuggestions] Displays initial search suggestions, when true.
       
  5507  * @property {WPLinkSearchType} [type]                 Filters by search type.
       
  5508  * @property {string}           [subtype]              Slug of the post-type or taxonomy.
       
  5509  * @property {number}           [page]                 Which page of results to return.
       
  5510  * @property {number}           [perPage]              Search results per page.
       
  5511  */
       
  5512 
       
  5513 /**
       
  5514  * @typedef WPLinkSearchResult
       
  5515  *
       
  5516  * @property {number} id     Post or term id.
       
  5517  * @property {string} url    Link url.
       
  5518  * @property {string} title  Title of the link.
       
  5519  * @property {string} type   The taxonomy or post type slug or type URL.
       
  5520  * @property {WPKind} [kind] Link kind of post-type or taxonomy
       
  5521  */
       
  5522 
       
  5523 /**
       
  5524  * @typedef WPLinkSearchResultAugments
       
  5525  *
       
  5526  * @property {{kind: WPKind}} [meta]    Contains kind information.
       
  5527  * @property {WPKind}         [subtype] Optional subtype if it exists.
       
  5528  */
       
  5529 
       
  5530 /**
       
  5531  * @typedef {WPLinkSearchResult & WPLinkSearchResultAugments} WPLinkSearchResultAugmented
       
  5532  */
       
  5533 
       
  5534 /**
       
  5535  * @typedef WPEditorSettings
       
  5536  *
       
  5537  * @property {boolean} [ disablePostFormats ] Disables post formats, when true.
       
  5538  */
       
  5539 
       
  5540 /**
       
  5541  * Fetches link suggestions from the API.
       
  5542  *
       
  5543  * @async
       
  5544  * @param {string}              search
       
  5545  * @param {WPLinkSearchOptions} [searchOptions]
       
  5546  * @param {WPEditorSettings}    [settings]
       
  5547  *
       
  5548  * @example
       
  5549  * ```js
       
  5550  * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';
       
  5551  *
       
  5552  * //...
       
  5553  *
       
  5554  * export function initialize( id, settings ) {
       
  5555  *
       
  5556  * settings.__experimentalFetchLinkSuggestions = (
       
  5557  *     search,
       
  5558  *     searchOptions
       
  5559  * ) => fetchLinkSuggestions( search, searchOptions, settings );
       
  5560  * ```
       
  5561  * @return {Promise< WPLinkSearchResult[] >} List of search suggestions
       
  5562  */
       
  5563 const fetchLinkSuggestions = async (search, searchOptions = {}, settings = {}) => {
       
  5564   const {
       
  5565     isInitialSuggestions = false,
       
  5566     initialSuggestionsSearchOptions = undefined
       
  5567   } = searchOptions;
       
  5568   const {
       
  5569     disablePostFormats = false
       
  5570   } = settings;
       
  5571   let {
       
  5572     type = undefined,
       
  5573     subtype = undefined,
       
  5574     page = undefined,
       
  5575     perPage = isInitialSuggestions ? 3 : 20
       
  5576   } = searchOptions;
       
  5577 
       
  5578   /** @type {Promise<WPLinkSearchResult>[]} */
       
  5579   const queries = [];
       
  5580   if (isInitialSuggestions && initialSuggestionsSearchOptions) {
       
  5581     type = initialSuggestionsSearchOptions.type || type;
       
  5582     subtype = initialSuggestionsSearchOptions.subtype || subtype;
       
  5583     page = initialSuggestionsSearchOptions.page || page;
       
  5584     perPage = initialSuggestionsSearchOptions.perPage || perPage;
       
  5585   }
       
  5586   if (!type || type === 'post') {
       
  5587     queries.push(external_wp_apiFetch_default()({
       
  5588       path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
       
  5589         search,
       
  5590         page,
       
  5591         per_page: perPage,
       
  5592         type: 'post',
       
  5593         subtype
       
  5594       })
       
  5595     }).then(results => {
       
  5596       return results.map(result => {
       
  5597         return {
       
  5598           ...result,
       
  5599           meta: {
       
  5600             kind: 'post-type',
       
  5601             subtype
       
  5602           }
       
  5603         };
       
  5604       });
       
  5605     }).catch(() => []) // Fail by returning no results.
       
  5606     );
       
  5607   }
       
  5608   if (!type || type === 'term') {
       
  5609     queries.push(external_wp_apiFetch_default()({
       
  5610       path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
       
  5611         search,
       
  5612         page,
       
  5613         per_page: perPage,
       
  5614         type: 'term',
       
  5615         subtype
       
  5616       })
       
  5617     }).then(results => {
       
  5618       return results.map(result => {
       
  5619         return {
       
  5620           ...result,
       
  5621           meta: {
       
  5622             kind: 'taxonomy',
       
  5623             subtype
       
  5624           }
       
  5625         };
       
  5626       });
       
  5627     }).catch(() => []) // Fail by returning no results.
       
  5628     );
       
  5629   }
       
  5630   if (!disablePostFormats && (!type || type === 'post-format')) {
       
  5631     queries.push(external_wp_apiFetch_default()({
       
  5632       path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
       
  5633         search,
       
  5634         page,
       
  5635         per_page: perPage,
       
  5636         type: 'post-format',
       
  5637         subtype
       
  5638       })
       
  5639     }).then(results => {
       
  5640       return results.map(result => {
       
  5641         return {
       
  5642           ...result,
       
  5643           meta: {
       
  5644             kind: 'taxonomy',
       
  5645             subtype
       
  5646           }
       
  5647         };
       
  5648       });
       
  5649     }).catch(() => []) // Fail by returning no results.
       
  5650     );
       
  5651   }
       
  5652   if (!type || type === 'attachment') {
       
  5653     queries.push(external_wp_apiFetch_default()({
       
  5654       path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/media', {
       
  5655         search,
       
  5656         page,
       
  5657         per_page: perPage
       
  5658       })
       
  5659     }).then(results => {
       
  5660       return results.map(result => {
       
  5661         return {
       
  5662           ...result,
       
  5663           meta: {
       
  5664             kind: 'media'
       
  5665           }
       
  5666         };
       
  5667       });
       
  5668     }).catch(() => []) // Fail by returning no results.
       
  5669     );
       
  5670   }
       
  5671   return Promise.all(queries).then(results => {
       
  5672     return results.reduce(( /** @type {WPLinkSearchResult[]} */accumulator, current) => accumulator.concat(current),
       
  5673     // Flatten list.
       
  5674     []).filter(
       
  5675     /**
       
  5676      * @param {{ id: number }} result
       
  5677      */
       
  5678     result => {
       
  5679       return !!result.id;
       
  5680     }).slice(0, perPage).map(( /** @type {WPLinkSearchResultAugmented} */result) => {
       
  5681       const isMedia = result.type === 'attachment';
       
  5682       return {
       
  5683         id: result.id,
       
  5684         // @ts-ignore fix when we make this a TS file
       
  5685         url: isMedia ? result.source_url : result.url,
       
  5686         title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(isMedia ?
       
  5687         // @ts-ignore fix when we make this a TS file
       
  5688         result.title.rendered : result.title || '') || (0,external_wp_i18n_namespaceObject.__)('(no title)'),
       
  5689         type: result.subtype || result.type,
       
  5690         kind: result?.meta?.kind
       
  5691       };
       
  5692     });
       
  5693   });
       
  5694 };
       
  5695 /* harmony default export */ const _experimental_fetch_link_suggestions = (fetchLinkSuggestions);
       
  5696 
       
  5697 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/fetch/__experimental-fetch-url-data.js
       
  5698 /**
       
  5699  * WordPress dependencies
       
  5700  */
       
  5701 
       
  5702 
       
  5703 
       
  5704 /**
       
  5705  * A simple in-memory cache for requests.
       
  5706  * This avoids repeat HTTP requests which may be beneficial
       
  5707  * for those wishing to preserve low-bandwidth.
       
  5708  */
       
  5709 const CACHE = new Map();
       
  5710 
       
  5711 /**
       
  5712  * @typedef WPRemoteUrlData
       
  5713  *
       
  5714  * @property {string} title contents of the remote URL's `<title>` tag.
       
  5715  */
       
  5716 
       
  5717 /**
       
  5718  * Fetches data about a remote URL.
       
  5719  * eg: <title> tag, favicon...etc.
       
  5720  *
       
  5721  * @async
       
  5722  * @param {string}  url     the URL to request details from.
       
  5723  * @param {Object?} options any options to pass to the underlying fetch.
       
  5724  * @example
       
  5725  * ```js
       
  5726  * import { __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';
       
  5727  *
       
  5728  * //...
       
  5729  *
       
  5730  * export function initialize( id, settings ) {
       
  5731  *
       
  5732  * settings.__experimentalFetchUrlData = (
       
  5733  * url
       
  5734  * ) => fetchUrlData( url );
       
  5735  * ```
       
  5736  * @return {Promise< WPRemoteUrlData[] >} Remote URL data.
       
  5737  */
       
  5738 const fetchUrlData = async (url, options = {}) => {
       
  5739   const endpoint = '/wp-block-editor/v1/url-details';
       
  5740   const args = {
       
  5741     url: (0,external_wp_url_namespaceObject.prependHTTP)(url)
  4706   };
  5742   };
       
  5743   if (!(0,external_wp_url_namespaceObject.isURL)(url)) {
       
  5744     return Promise.reject(`${url} is not a valid URL.`);
       
  5745   }
       
  5746 
       
  5747   // Test for "http" based URL as it is possible for valid
       
  5748   // yet unusable URLs such as `tel:123456` to be passed.
       
  5749   const protocol = (0,external_wp_url_namespaceObject.getProtocol)(url);
       
  5750   if (!protocol || !(0,external_wp_url_namespaceObject.isValidProtocol)(protocol) || !protocol.startsWith('http') || !/^https?:\/\/[^\/\s]/i.test(url)) {
       
  5751     return Promise.reject(`${url} does not have a valid protocol. URLs must be "http" based`);
       
  5752   }
       
  5753   if (CACHE.has(url)) {
       
  5754     return CACHE.get(url);
       
  5755   }
       
  5756   return external_wp_apiFetch_default()({
       
  5757     path: (0,external_wp_url_namespaceObject.addQueryArgs)(endpoint, args),
       
  5758     ...options
       
  5759   }).then(res => {
       
  5760     CACHE.set(url, res);
       
  5761     return res;
       
  5762   });
  4707 };
  5763 };
  4708 
  5764 /* harmony default export */ const _experimental_fetch_url_data = (fetchUrlData);
  4709 /* harmony default export */ var forward_resolver = (forwardResolver);
  5765 
       
  5766 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/fetch/index.js
       
  5767 /**
       
  5768  * External dependencies
       
  5769  */
       
  5770 
       
  5771 
       
  5772 /**
       
  5773  * WordPress dependencies
       
  5774  */
       
  5775 
       
  5776 
       
  5777 
       
  5778 async function fetchBlockPatterns() {
       
  5779   const restPatterns = await external_wp_apiFetch_default()({
       
  5780     path: '/wp/v2/block-patterns/patterns'
       
  5781   });
       
  5782   if (!restPatterns) {
       
  5783     return [];
       
  5784   }
       
  5785   return restPatterns.map(pattern => Object.fromEntries(Object.entries(pattern).map(([key, value]) => [camelCase(key), value])));
       
  5786 }
  4710 
  5787 
  4711 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/resolvers.js
  5788 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/resolvers.js
  4712 /**
  5789 /**
  4713  * External dependencies
  5790  * External dependencies
  4714  */
  5791  */
  4715 
  5792 
       
  5793 
  4716 /**
  5794 /**
  4717  * WordPress dependencies
  5795  * WordPress dependencies
  4718  */
  5796  */
  4719 
  5797 
  4720 
  5798 
  4721 
  5799 
       
  5800 
  4722 /**
  5801 /**
  4723  * Internal dependencies
  5802  * Internal dependencies
  4724  */
  5803  */
       
  5804 
       
  5805 
  4725 
  5806 
  4726 
  5807 
  4727 
  5808 
  4728 
  5809 
  4729 /**
  5810 /**
  4730  * Requests authors from the REST API.
  5811  * Requests authors from the REST API.
  4731  *
  5812  *
  4732  * @param {Object|undefined} query Optional object of query parameters to
  5813  * @param {Object|undefined} query Optional object of query parameters to
  4733  *                                 include with request.
  5814  *                                 include with request.
  4734  */
  5815  */
  4735 
  5816 const resolvers_getAuthors = query => async ({
  4736 const resolvers_getAuthors = query => async _ref => {
  5817   dispatch
  4737   let {
  5818 }) => {
  4738     dispatch
       
  4739   } = _ref;
       
  4740   const path = (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/users/?who=authors&per_page=100', query);
  5819   const path = (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/users/?who=authors&per_page=100', query);
  4741   const users = await external_wp_apiFetch_default()({
  5820   const users = await external_wp_apiFetch_default()({
  4742     path
  5821     path
  4743   });
  5822   });
  4744   dispatch.receiveUserQuery(path, users);
  5823   dispatch.receiveUserQuery(path, users);
  4745 };
  5824 };
       
  5825 
  4746 /**
  5826 /**
  4747  * Requests the current user from the REST API.
  5827  * Requests the current user from the REST API.
  4748  */
  5828  */
  4749 
  5829 const resolvers_getCurrentUser = () => async ({
  4750 const resolvers_getCurrentUser = () => async _ref2 => {
  5830   dispatch
  4751   let {
  5831 }) => {
  4752     dispatch
       
  4753   } = _ref2;
       
  4754   const currentUser = await external_wp_apiFetch_default()({
  5832   const currentUser = await external_wp_apiFetch_default()({
  4755     path: '/wp/v2/users/me'
  5833     path: '/wp/v2/users/me'
  4756   });
  5834   });
  4757   dispatch.receiveCurrentUser(currentUser);
  5835   dispatch.receiveCurrentUser(currentUser);
  4758 };
  5836 };
       
  5837 
  4759 /**
  5838 /**
  4760  * Requests an entity's record from the REST API.
  5839  * Requests an entity's record from the REST API.
  4761  *
  5840  *
  4762  * @param {string}           kind  Entity kind.
  5841  * @param {string}           kind  Entity kind.
  4763  * @param {string}           name  Entity name.
  5842  * @param {string}           name  Entity name.
  4764  * @param {number|string}    key   Record's key
  5843  * @param {number|string}    key   Record's key
  4765  * @param {Object|undefined} query Optional object of query parameters to
  5844  * @param {Object|undefined} query Optional object of query parameters to
  4766  *                                 include with request.
  5845  *                                 include with request. If requesting specific
  4767  */
  5846  *                                 fields, fields must always include the ID.
  4768 
  5847  */
  4769 const resolvers_getEntityRecord = function (kind, name) {
  5848 const resolvers_getEntityRecord = (kind, name, key = '', query) => async ({
  4770   let key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  5849   select,
  4771   let query = arguments.length > 3 ? arguments[3] : undefined;
  5850   dispatch
  4772   return async _ref3 => {
  5851 }) => {
  4773     let {
  5852   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
  4774       select,
  5853   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
  4775       dispatch
  5854   if (!entityConfig || entityConfig?.__experimentalNoFetch) {
  4776     } = _ref3;
  5855     return;
  4777     const configs = await dispatch(getOrLoadEntitiesConfig(kind));
  5856   }
  4778     const entityConfig = (0,external_lodash_namespaceObject.find)(configs, {
  5857   const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, key], {
  4779       kind,
  5858     exclusive: false
  4780       name
  5859   });
  4781     });
  5860   try {
  4782 
  5861     // Entity supports configs,
  4783     if (!entityConfig || entityConfig !== null && entityConfig !== void 0 && entityConfig.__experimentalNoFetch) {
  5862     // use the sync algorithm instead of the old fetch behavior.
  4784       return;
  5863     if (window.__experimentalEnableSync && entityConfig.syncConfig && !query) {
  4785     }
  5864       if (false) {}
  4786 
  5865     } else {
  4787     const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, key], {
       
  4788       exclusive: false
       
  4789     });
       
  4790 
       
  4791     try {
       
  4792       if (query !== undefined && query._fields) {
  5866       if (query !== undefined && query._fields) {
  4793         // If requesting specific fields, items and query association to said
  5867         // If requesting specific fields, items and query association to said
  4794         // records are stored by ID reference. Thus, fields must always include
  5868         // records are stored by ID reference. Thus, fields must always include
  4795         // the ID.
  5869         // the ID.
  4796         query = { ...query,
  5870         query = {
  4797           _fields: (0,external_lodash_namespaceObject.uniq)([...(get_normalized_comma_separable(query._fields) || []), entityConfig.key || DEFAULT_ENTITY_KEY]).join()
  5871           ...query,
       
  5872           _fields: [...new Set([...(get_normalized_comma_separable(query._fields) || []), entityConfig.key || DEFAULT_ENTITY_KEY])].join()
  4798         };
  5873         };
  4799       } // Disable reason: While true that an early return could leave `path`
  5874       }
       
  5875 
       
  5876       // Disable reason: While true that an early return could leave `path`
  4800       // unused, it's important that path is derived using the query prior to
  5877       // unused, it's important that path is derived using the query prior to
  4801       // additional query modifications in the condition below, since those
  5878       // additional query modifications in the condition below, since those
  4802       // modifications are relevant to how the data is tracked in state, and not
  5879       // modifications are relevant to how the data is tracked in state, and not
  4803       // for how the request is made to the REST API.
  5880       // for how the request is made to the REST API.
       
  5881 
  4804       // eslint-disable-next-line @wordpress/no-unused-vars-before-return
  5882       // eslint-disable-next-line @wordpress/no-unused-vars-before-return
  4805 
  5883       const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entityConfig.baseURL + (key ? '/' + key : ''), {
  4806 
  5884         ...entityConfig.baseURLParams,
  4807       const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entityConfig.baseURL + (key ? '/' + key : ''), { ...entityConfig.baseURLParams,
       
  4808         ...query
  5885         ...query
  4809       });
  5886       });
  4810 
       
  4811       if (query !== undefined) {
  5887       if (query !== undefined) {
  4812         query = { ...query,
  5888         query = {
       
  5889           ...query,
  4813           include: [key]
  5890           include: [key]
  4814         }; // The resolution cache won't consider query as reusable based on the
  5891         };
       
  5892 
       
  5893         // The resolution cache won't consider query as reusable based on the
  4815         // fields, so it's tested here, prior to initiating the REST request,
  5894         // fields, so it's tested here, prior to initiating the REST request,
  4816         // and without causing `getEntityRecords` resolution to occur.
  5895         // and without causing `getEntityRecords` resolution to occur.
  4817 
       
  4818         const hasRecords = select.hasEntityRecords(kind, name, query);
  5896         const hasRecords = select.hasEntityRecords(kind, name, query);
  4819 
       
  4820         if (hasRecords) {
  5897         if (hasRecords) {
  4821           return;
  5898           return;
  4822         }
  5899         }
  4823       }
  5900       }
  4824 
       
  4825       const record = await external_wp_apiFetch_default()({
  5901       const record = await external_wp_apiFetch_default()({
  4826         path
  5902         path
  4827       });
  5903       });
  4828       dispatch.receiveEntityRecords(kind, name, record, query);
  5904       dispatch.receiveEntityRecords(kind, name, record, query);
  4829     } finally {
  5905     }
  4830       dispatch.__unstableReleaseStoreLock(lock);
  5906   } finally {
  4831     }
  5907     dispatch.__unstableReleaseStoreLock(lock);
  4832   };
  5908   }
  4833 };
  5909 };
       
  5910 
  4834 /**
  5911 /**
  4835  * Requests an entity's record from the REST API.
  5912  * Requests an entity's record from the REST API.
  4836  */
  5913  */
  4837 
       
  4838 const resolvers_getRawEntityRecord = forward_resolver('getEntityRecord');
  5914 const resolvers_getRawEntityRecord = forward_resolver('getEntityRecord');
       
  5915 
  4839 /**
  5916 /**
  4840  * Requests an entity's record from the REST API.
  5917  * Requests an entity's record from the REST API.
  4841  */
  5918  */
  4842 
       
  4843 const resolvers_getEditedEntityRecord = forward_resolver('getEntityRecord');
  5919 const resolvers_getEditedEntityRecord = forward_resolver('getEntityRecord');
       
  5920 
  4844 /**
  5921 /**
  4845  * Requests the entity's records from the REST API.
  5922  * Requests the entity's records from the REST API.
  4846  *
  5923  *
  4847  * @param {string}  kind  Entity kind.
  5924  * @param {string}  kind  Entity kind.
  4848  * @param {string}  name  Entity name.
  5925  * @param {string}  name  Entity name.
  4849  * @param {Object?} query Query Object.
  5926  * @param {Object?} query Query Object. If requesting specific fields, fields
  4850  */
  5927  *                        must always include the ID.
  4851 
  5928  */
  4852 const resolvers_getEntityRecords = function (kind, name) {
  5929 const resolvers_getEntityRecords = (kind, name, query = {}) => async ({
  4853   let query = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  5930   dispatch,
  4854   return async _ref4 => {
  5931   registry
  4855     let {
  5932 }) => {
  4856       dispatch
  5933   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
  4857     } = _ref4;
  5934   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
  4858     const configs = await dispatch(getOrLoadEntitiesConfig(kind));
  5935   if (!entityConfig || entityConfig?.__experimentalNoFetch) {
  4859     const entityConfig = (0,external_lodash_namespaceObject.find)(configs, {
  5936     return;
  4860       kind,
  5937   }
  4861       name
  5938   const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name], {
       
  5939     exclusive: false
       
  5940   });
       
  5941   try {
       
  5942     if (query._fields) {
       
  5943       // If requesting specific fields, items and query association to said
       
  5944       // records are stored by ID reference. Thus, fields must always include
       
  5945       // the ID.
       
  5946       query = {
       
  5947         ...query,
       
  5948         _fields: [...new Set([...(get_normalized_comma_separable(query._fields) || []), entityConfig.key || DEFAULT_ENTITY_KEY])].join()
       
  5949       };
       
  5950     }
       
  5951     const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entityConfig.baseURL, {
       
  5952       ...entityConfig.baseURLParams,
       
  5953       ...query
  4862     });
  5954     });
  4863 
  5955     let records, meta;
  4864     if (!entityConfig || entityConfig !== null && entityConfig !== void 0 && entityConfig.__experimentalNoFetch) {
  5956     if (entityConfig.supportsPagination && query.per_page !== -1) {
  4865       return;
  5957       const response = await external_wp_apiFetch_default()({
  4866     }
  5958         path,
  4867 
  5959         parse: false
  4868     const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name], {
       
  4869       exclusive: false
       
  4870     });
       
  4871 
       
  4872     try {
       
  4873       var _query;
       
  4874 
       
  4875       if (query._fields) {
       
  4876         // If requesting specific fields, items and query association to said
       
  4877         // records are stored by ID reference. Thus, fields must always include
       
  4878         // the ID.
       
  4879         query = { ...query,
       
  4880           _fields: (0,external_lodash_namespaceObject.uniq)([...(get_normalized_comma_separable(query._fields) || []), entityConfig.key || DEFAULT_ENTITY_KEY]).join()
       
  4881         };
       
  4882       }
       
  4883 
       
  4884       const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entityConfig.baseURL, { ...entityConfig.baseURLParams,
       
  4885         ...query
       
  4886       });
  5960       });
  4887       let records = Object.values(await external_wp_apiFetch_default()({
  5961       records = Object.values(await response.json());
       
  5962       meta = {
       
  5963         totalItems: parseInt(response.headers.get('X-WP-Total')),
       
  5964         totalPages: parseInt(response.headers.get('X-WP-TotalPages'))
       
  5965       };
       
  5966     } else {
       
  5967       records = Object.values(await external_wp_apiFetch_default()({
  4888         path
  5968         path
  4889       })); // If we request fields but the result doesn't contain the fields,
  5969       }));
  4890       // explicitely set these fields as "undefined"
  5970     }
  4891       // that way we consider the query "fullfilled".
  5971 
  4892 
  5972     // If we request fields but the result doesn't contain the fields,
  4893       if (query._fields) {
  5973     // explicitly set these fields as "undefined"
  4894         records = records.map(record => {
  5974     // that way we consider the query "fulfilled".
  4895           query._fields.split(',').forEach(field => {
  5975     if (query._fields) {
  4896             if (!record.hasOwnProperty(field)) {
  5976       records = records.map(record => {
  4897               record[field] = undefined;
  5977         query._fields.split(',').forEach(field => {
  4898             }
  5978           if (!record.hasOwnProperty(field)) {
  4899           });
  5979             record[field] = undefined;
  4900 
  5980           }
  4901           return record;
       
  4902         });
  5981         });
  4903       }
  5982         return record;
  4904 
  5983       });
  4905       dispatch.receiveEntityRecords(kind, name, records, query); // When requesting all fields, the list of results can be used to
  5984     }
       
  5985     registry.batch(() => {
       
  5986       dispatch.receiveEntityRecords(kind, name, records, query, false, undefined, meta);
       
  5987 
       
  5988       // When requesting all fields, the list of results can be used to
  4906       // resolve the `getEntityRecord` selector in addition to `getEntityRecords`.
  5989       // resolve the `getEntityRecord` selector in addition to `getEntityRecords`.
  4907       // See https://github.com/WordPress/gutenberg/pull/26575
  5990       // See https://github.com/WordPress/gutenberg/pull/26575
  4908 
  5991       if (!query?._fields && !query.context) {
  4909       if (!((_query = query) !== null && _query !== void 0 && _query._fields) && !query.context) {
       
  4910         const key = entityConfig.key || DEFAULT_ENTITY_KEY;
  5992         const key = entityConfig.key || DEFAULT_ENTITY_KEY;
  4911         const resolutionsArgs = records.filter(record => record[key]).map(record => [kind, name, record[key]]);
  5993         const resolutionsArgs = records.filter(record => record?.[key]).map(record => [kind, name, record[key]]);
  4912         dispatch({
  5994         dispatch({
  4913           type: 'START_RESOLUTIONS',
  5995           type: 'START_RESOLUTIONS',
  4914           selectorName: 'getEntityRecord',
  5996           selectorName: 'getEntityRecord',
  4915           args: resolutionsArgs
  5997           args: resolutionsArgs
  4916         });
  5998         });
  4918           type: 'FINISH_RESOLUTIONS',
  6000           type: 'FINISH_RESOLUTIONS',
  4919           selectorName: 'getEntityRecord',
  6001           selectorName: 'getEntityRecord',
  4920           args: resolutionsArgs
  6002           args: resolutionsArgs
  4921         });
  6003         });
  4922       }
  6004       }
  4923     } finally {
       
  4924       dispatch.__unstableReleaseStoreLock(lock);
  6005       dispatch.__unstableReleaseStoreLock(lock);
  4925     }
  6006     });
  4926   };
  6007   } catch (e) {
       
  6008     dispatch.__unstableReleaseStoreLock(lock);
       
  6009   }
  4927 };
  6010 };
  4928 
       
  4929 resolvers_getEntityRecords.shouldInvalidate = (action, kind, name) => {
  6011 resolvers_getEntityRecords.shouldInvalidate = (action, kind, name) => {
  4930   return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && kind === action.kind && name === action.name;
  6012   return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && kind === action.kind && name === action.name;
  4931 };
  6013 };
       
  6014 
  4932 /**
  6015 /**
  4933  * Requests the current theme.
  6016  * Requests the current theme.
  4934  */
  6017  */
  4935 
  6018 const resolvers_getCurrentTheme = () => async ({
  4936 
  6019   dispatch,
  4937 const resolvers_getCurrentTheme = () => async _ref5 => {
  6020   resolveSelect
  4938   let {
  6021 }) => {
  4939     dispatch,
       
  4940     resolveSelect
       
  4941   } = _ref5;
       
  4942   const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
  6022   const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
  4943     status: 'active'
  6023     status: 'active'
  4944   });
  6024   });
  4945   dispatch.receiveCurrentTheme(activeThemes[0]);
  6025   dispatch.receiveCurrentTheme(activeThemes[0]);
  4946 };
  6026 };
       
  6027 
  4947 /**
  6028 /**
  4948  * Requests theme supports data from the index.
  6029  * Requests theme supports data from the index.
  4949  */
  6030  */
  4950 
       
  4951 const resolvers_getThemeSupports = forward_resolver('getCurrentTheme');
  6031 const resolvers_getThemeSupports = forward_resolver('getCurrentTheme');
  4952 /**
  6032 
  4953  * Requests a preview from the from the Embed API.
  6033 /**
       
  6034  * Requests a preview from the Embed API.
  4954  *
  6035  *
  4955  * @param {string} url URL to get the preview for.
  6036  * @param {string} url URL to get the preview for.
  4956  */
  6037  */
  4957 
  6038 const resolvers_getEmbedPreview = url => async ({
  4958 const resolvers_getEmbedPreview = url => async _ref6 => {
  6039   dispatch
  4959   let {
  6040 }) => {
  4960     dispatch
       
  4961   } = _ref6;
       
  4962 
       
  4963   try {
  6041   try {
  4964     const embedProxyResponse = await external_wp_apiFetch_default()({
  6042     const embedProxyResponse = await external_wp_apiFetch_default()({
  4965       path: (0,external_wp_url_namespaceObject.addQueryArgs)('/oembed/1.0/proxy', {
  6043       path: (0,external_wp_url_namespaceObject.addQueryArgs)('/oembed/1.0/proxy', {
  4966         url
  6044         url
  4967       })
  6045       })
  4970   } catch (error) {
  6048   } catch (error) {
  4971     // Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here.
  6049     // Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here.
  4972     dispatch.receiveEmbedPreview(url, false);
  6050     dispatch.receiveEmbedPreview(url, false);
  4973   }
  6051   }
  4974 };
  6052 };
       
  6053 
  4975 /**
  6054 /**
  4976  * Checks whether the current user can perform the given action on the given
  6055  * Checks whether the current user can perform the given action on the given
  4977  * REST resource.
  6056  * REST resource.
  4978  *
  6057  *
  4979  * @param {string}  action   Action to check. One of: 'create', 'read', 'update',
  6058  * @param {string}  requestedAction Action to check. One of: 'create', 'read', 'update',
  4980  *                           'delete'.
  6059  *                                  'delete'.
  4981  * @param {string}  resource REST resource to check, e.g. 'media' or 'posts'.
  6060  * @param {string}  resource        REST resource to check, e.g. 'media' or 'posts'.
  4982  * @param {?string} id       ID of the rest resource to check.
  6061  * @param {?string} id              ID of the rest resource to check.
  4983  */
  6062  */
  4984 
  6063 const resolvers_canUser = (requestedAction, resource, id) => async ({
  4985 const resolvers_canUser = (action, resource, id) => async _ref7 => {
  6064   dispatch,
  4986   var _response$headers;
  6065   registry
  4987 
  6066 }) => {
  4988   let {
  6067   const {
  4989     dispatch
  6068     hasStartedResolution
  4990   } = _ref7;
  6069   } = registry.select(STORE_NAME);
  4991   const methods = {
  6070   const resourcePath = id ? `${resource}/${id}` : resource;
  4992     create: 'POST',
  6071   const retrievedActions = ['create', 'read', 'update', 'delete'];
  4993     read: 'GET',
  6072   if (!retrievedActions.includes(requestedAction)) {
  4994     update: 'PUT',
  6073     throw new Error(`'${requestedAction}' is not a valid action.`);
  4995     delete: 'DELETE'
  6074   }
  4996   };
  6075 
  4997   const method = methods[action];
  6076   // Prevent resolving the same resource twice.
  4998 
  6077   for (const relatedAction of retrievedActions) {
  4999   if (!method) {
  6078     if (relatedAction === requestedAction) {
  5000     throw new Error(`'${action}' is not a valid action.`);
  6079       continue;
  5001   }
  6080     }
  5002 
  6081     const isAlreadyResolving = hasStartedResolution('canUser', [relatedAction, resource, id]);
  5003   const path = id ? `/wp/v2/${resource}/${id}` : `/wp/v2/${resource}`;
  6082     if (isAlreadyResolving) {
       
  6083       return;
       
  6084     }
       
  6085   }
  5004   let response;
  6086   let response;
  5005 
       
  5006   try {
  6087   try {
  5007     response = await external_wp_apiFetch_default()({
  6088     response = await external_wp_apiFetch_default()({
  5008       path,
  6089       path: `/wp/v2/${resourcePath}`,
  5009       method: 'OPTIONS',
  6090       method: 'OPTIONS',
  5010       parse: false
  6091       parse: false
  5011     });
  6092     });
  5012   } catch (error) {
  6093   } catch (error) {
  5013     // Do nothing if our OPTIONS request comes back with an API error (4xx or
  6094     // Do nothing if our OPTIONS request comes back with an API error (4xx or
  5014     // 5xx). The previously determined isAllowed value will remain in the store.
  6095     // 5xx). The previously determined isAllowed value will remain in the store.
  5015     return;
  6096     return;
  5016   } // Optional chaining operator is used here because the API requests don't
  6097   }
       
  6098 
       
  6099   // Optional chaining operator is used here because the API requests don't
  5017   // return the expected result in the native version. Instead, API requests
  6100   // return the expected result in the native version. Instead, API requests
  5018   // only return the result, without including response properties like the headers.
  6101   // only return the result, without including response properties like the headers.
  5019 
  6102   const allowHeader = response.headers?.get('allow');
  5020 
  6103   const allowedMethods = allowHeader?.allow || allowHeader || '';
  5021   const allowHeader = (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.get('allow');
  6104   const permissions = {};
  5022   const key = (0,external_lodash_namespaceObject.compact)([action, resource, id]).join('/');
  6105   const methods = {
  5023   const isAllowed = (0,external_lodash_namespaceObject.includes)(allowHeader, method);
  6106     create: 'POST',
  5024   dispatch.receiveUserPermission(key, isAllowed);
  6107     read: 'GET',
       
  6108     update: 'PUT',
       
  6109     delete: 'DELETE'
       
  6110   };
       
  6111   for (const [actionName, methodName] of Object.entries(methods)) {
       
  6112     permissions[actionName] = allowedMethods.includes(methodName);
       
  6113   }
       
  6114   for (const action of retrievedActions) {
       
  6115     dispatch.receiveUserPermission(`${action}/${resourcePath}`, permissions[action]);
       
  6116   }
  5025 };
  6117 };
       
  6118 
  5026 /**
  6119 /**
  5027  * Checks whether the current user can perform the given action on the given
  6120  * Checks whether the current user can perform the given action on the given
  5028  * REST resource.
  6121  * REST resource.
  5029  *
  6122  *
  5030  * @param {string} kind     Entity kind.
  6123  * @param {string} kind     Entity kind.
  5031  * @param {string} name     Entity name.
  6124  * @param {string} name     Entity name.
  5032  * @param {string} recordId Record's id.
  6125  * @param {string} recordId Record's id.
  5033  */
  6126  */
  5034 
  6127 const resolvers_canUserEditEntityRecord = (kind, name, recordId) => async ({
  5035 const resolvers_canUserEditEntityRecord = (kind, name, recordId) => async _ref8 => {
  6128   dispatch
  5036   let {
  6129 }) => {
  5037     dispatch
  6130   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
  5038   } = _ref8;
  6131   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
  5039   const configs = await dispatch(getOrLoadEntitiesConfig(kind));
       
  5040   const entityConfig = (0,external_lodash_namespaceObject.find)(configs, {
       
  5041     kind,
       
  5042     name
       
  5043   });
       
  5044 
       
  5045   if (!entityConfig) {
  6132   if (!entityConfig) {
  5046     return;
  6133     return;
  5047   }
  6134   }
  5048 
       
  5049   const resource = entityConfig.__unstable_rest_base;
  6135   const resource = entityConfig.__unstable_rest_base;
  5050   await dispatch(resolvers_canUser('update', resource, recordId));
  6136   await dispatch(resolvers_canUser('update', resource, recordId));
  5051 };
  6137 };
       
  6138 
  5052 /**
  6139 /**
  5053  * Request autosave data from the REST API.
  6140  * Request autosave data from the REST API.
  5054  *
  6141  *
  5055  * @param {string} postType The type of the parent post.
  6142  * @param {string} postType The type of the parent post.
  5056  * @param {number} postId   The id of the parent post.
  6143  * @param {number} postId   The id of the parent post.
  5057  */
  6144  */
  5058 
  6145 const resolvers_getAutosaves = (postType, postId) => async ({
  5059 const resolvers_getAutosaves = (postType, postId) => async _ref9 => {
  6146   dispatch,
  5060   let {
  6147   resolveSelect
  5061     dispatch,
  6148 }) => {
  5062     resolveSelect
       
  5063   } = _ref9;
       
  5064   const {
  6149   const {
  5065     rest_base: restBase
  6150     rest_base: restBase,
       
  6151     rest_namespace: restNamespace = 'wp/v2'
  5066   } = await resolveSelect.getPostType(postType);
  6152   } = await resolveSelect.getPostType(postType);
  5067   const autosaves = await external_wp_apiFetch_default()({
  6153   const autosaves = await external_wp_apiFetch_default()({
  5068     path: `/wp/v2/${restBase}/${postId}/autosaves?context=edit`
  6154     path: `/${restNamespace}/${restBase}/${postId}/autosaves?context=edit`
  5069   });
  6155   });
  5070 
       
  5071   if (autosaves && autosaves.length) {
  6156   if (autosaves && autosaves.length) {
  5072     dispatch.receiveAutosaves(postId, autosaves);
  6157     dispatch.receiveAutosaves(postId, autosaves);
  5073   }
  6158   }
  5074 };
  6159 };
       
  6160 
  5075 /**
  6161 /**
  5076  * Request autosave data from the REST API.
  6162  * Request autosave data from the REST API.
  5077  *
  6163  *
  5078  * This resolver exists to ensure the underlying autosaves are fetched via
  6164  * This resolver exists to ensure the underlying autosaves are fetched via
  5079  * `getAutosaves` when a call to the `getAutosave` selector is made.
  6165  * `getAutosaves` when a call to the `getAutosave` selector is made.
  5080  *
  6166  *
  5081  * @param {string} postType The type of the parent post.
  6167  * @param {string} postType The type of the parent post.
  5082  * @param {number} postId   The id of the parent post.
  6168  * @param {number} postId   The id of the parent post.
  5083  */
  6169  */
  5084 
  6170 const resolvers_getAutosave = (postType, postId) => async ({
  5085 const resolvers_getAutosave = (postType, postId) => async _ref10 => {
  6171   resolveSelect
  5086   let {
  6172 }) => {
  5087     resolveSelect
       
  5088   } = _ref10;
       
  5089   await resolveSelect.getAutosaves(postType, postId);
  6173   await resolveSelect.getAutosaves(postType, postId);
  5090 };
  6174 };
       
  6175 
  5091 /**
  6176 /**
  5092  * Retrieve the frontend template used for a given link.
  6177  * Retrieve the frontend template used for a given link.
  5093  *
  6178  *
  5094  * @param {string} link Link.
  6179  * @param {string} link Link.
  5095  */
  6180  */
  5096 
  6181 const resolvers_experimentalGetTemplateForLink = link => async ({
  5097 const resolvers_experimentalGetTemplateForLink = link => async _ref11 => {
  6182   dispatch,
  5098   let {
  6183   resolveSelect
  5099     dispatch,
  6184 }) => {
  5100     resolveSelect
       
  5101   } = _ref11;
       
  5102   // Ideally this should be using an apiFetch call
       
  5103   // We could potentially do so by adding a "filter" to the `wp_template` end point.
       
  5104   // Also it seems the returned object is not a regular REST API post type.
       
  5105   let template;
  6185   let template;
  5106 
       
  5107   try {
  6186   try {
  5108     template = await window.fetch((0,external_wp_url_namespaceObject.addQueryArgs)(link, {
  6187     // This is NOT calling a REST endpoint but rather ends up with a response from
  5109       '_wp-find-template': true
  6188     // an Ajax function which has a different shape from a WP_REST_Response.
  5110     })).then(res => res.json()).then(_ref12 => {
  6189     template = await external_wp_apiFetch_default()({
  5111       let {
  6190       url: (0,external_wp_url_namespaceObject.addQueryArgs)(link, {
  5112         data
  6191         '_wp-find-template': true
  5113       } = _ref12;
  6192       })
  5114       return data;
  6193     }).then(({
  5115     });
  6194       data
  5116   } catch (e) {// For non-FSE themes, it is possible that this request returns an error.
  6195     }) => data);
  5117   }
  6196   } catch (e) {
  5118 
  6197     // For non-FSE themes, it is possible that this request returns an error.
       
  6198   }
  5119   if (!template) {
  6199   if (!template) {
  5120     return;
  6200     return;
  5121   }
  6201   }
  5122 
       
  5123   const record = await resolveSelect.getEntityRecord('postType', 'wp_template', template.id);
  6202   const record = await resolveSelect.getEntityRecord('postType', 'wp_template', template.id);
  5124 
       
  5125   if (record) {
  6203   if (record) {
  5126     dispatch.receiveEntityRecords('postType', 'wp_template', [record], {
  6204     dispatch.receiveEntityRecords('postType', 'wp_template', [record], {
  5127       'find-template': link
  6205       'find-template': link
  5128     });
  6206     });
  5129   }
  6207   }
  5130 };
  6208 };
  5131 
       
  5132 resolvers_experimentalGetTemplateForLink.shouldInvalidate = action => {
  6209 resolvers_experimentalGetTemplateForLink.shouldInvalidate = action => {
  5133   return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && action.kind === 'postType' && action.name === 'wp_template';
  6210   return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && action.kind === 'postType' && action.name === 'wp_template';
  5134 };
  6211 };
  5135 
  6212 const resolvers_experimentalGetCurrentGlobalStylesId = () => async ({
  5136 const resolvers_experimentalGetCurrentGlobalStylesId = () => async _ref13 => {
  6213   dispatch,
  5137   let {
  6214   resolveSelect
  5138     dispatch,
  6215 }) => {
  5139     resolveSelect
       
  5140   } = _ref13;
       
  5141   const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
  6216   const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
  5142     status: 'active'
  6217     status: 'active'
  5143   });
  6218   });
  5144   const globalStylesURL = (0,external_lodash_namespaceObject.get)(activeThemes, [0, '_links', 'wp:user-global-styles', 0, 'href']);
  6219   const globalStylesURL = activeThemes?.[0]?._links?.['wp:user-global-styles']?.[0]?.href;
  5145 
  6220   if (!globalStylesURL) {
  5146   if (globalStylesURL) {
  6221     return;
  5147     const globalStylesObject = await external_wp_apiFetch_default()({
  6222   }
  5148       url: globalStylesURL
  6223 
  5149     });
  6224   // Regex matches the ID at the end of a URL or immediately before
  5150 
  6225   // the query string.
  5151     dispatch.__experimentalReceiveCurrentGlobalStylesId(globalStylesObject.id);
  6226   const matches = globalStylesURL.match(/\/(\d+)(?:\?|$)/);
       
  6227   const id = matches ? Number(matches[1]) : null;
       
  6228   if (id) {
       
  6229     dispatch.__experimentalReceiveCurrentGlobalStylesId(id);
  5152   }
  6230   }
  5153 };
  6231 };
  5154 const resolvers_experimentalGetCurrentThemeBaseGlobalStyles = () => async _ref14 => {
  6232 const resolvers_experimentalGetCurrentThemeBaseGlobalStyles = () => async ({
  5155   let {
  6233   resolveSelect,
  5156     resolveSelect,
  6234   dispatch
  5157     dispatch
  6235 }) => {
  5158   } = _ref14;
       
  5159   const currentTheme = await resolveSelect.getCurrentTheme();
  6236   const currentTheme = await resolveSelect.getCurrentTheme();
  5160   const themeGlobalStyles = await external_wp_apiFetch_default()({
  6237   const themeGlobalStyles = await external_wp_apiFetch_default()({
  5161     path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}`
  6238     path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}`
  5162   });
  6239   });
  5163 
       
  5164   dispatch.__experimentalReceiveThemeBaseGlobalStyles(currentTheme.stylesheet, themeGlobalStyles);
  6240   dispatch.__experimentalReceiveThemeBaseGlobalStyles(currentTheme.stylesheet, themeGlobalStyles);
  5165 };
  6241 };
  5166 const resolvers_experimentalGetCurrentThemeGlobalStylesVariations = () => async _ref15 => {
  6242 const resolvers_experimentalGetCurrentThemeGlobalStylesVariations = () => async ({
  5167   let {
  6243   resolveSelect,
  5168     resolveSelect,
  6244   dispatch
  5169     dispatch
  6245 }) => {
  5170   } = _ref15;
       
  5171   const currentTheme = await resolveSelect.getCurrentTheme();
  6246   const currentTheme = await resolveSelect.getCurrentTheme();
  5172   const variations = await external_wp_apiFetch_default()({
  6247   const variations = await external_wp_apiFetch_default()({
  5173     path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}/variations`
  6248     path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}/variations`
  5174   });
  6249   });
  5175 
       
  5176   dispatch.__experimentalReceiveThemeGlobalStyleVariations(currentTheme.stylesheet, variations);
  6250   dispatch.__experimentalReceiveThemeGlobalStyleVariations(currentTheme.stylesheet, variations);
  5177 };
  6251 };
  5178 const resolvers_getBlockPatterns = () => async _ref16 => {
  6252 
  5179   let {
  6253 /**
  5180     dispatch
  6254  * Fetches and returns the revisions of the current global styles theme.
  5181   } = _ref16;
  6255  */
  5182   const restPatterns = await external_wp_apiFetch_default()({
  6256 const resolvers_getCurrentThemeGlobalStylesRevisions = () => async ({
  5183     path: '/wp/v2/block-patterns/patterns'
  6257   resolveSelect,
  5184   });
  6258   dispatch
  5185   const patterns = (0,external_lodash_namespaceObject.map)(restPatterns, pattern => (0,external_lodash_namespaceObject.mapKeys)(pattern, (value, key) => {
  6259 }) => {
  5186     switch (key) {
  6260   const globalStylesId = await resolveSelect.__experimentalGetCurrentGlobalStylesId();
  5187       case 'block_types':
  6261   const record = globalStylesId ? await resolveSelect.getEntityRecord('root', 'globalStyles', globalStylesId) : undefined;
  5188         return 'blockTypes';
  6262   const revisionsURL = record?._links?.['version-history']?.[0]?.href;
  5189 
  6263   if (revisionsURL) {
  5190       case 'viewport_width':
  6264     const resetRevisions = await external_wp_apiFetch_default()({
  5191         return 'viewportWidth';
  6265       url: revisionsURL
  5192 
  6266     });
  5193       default:
  6267     const revisions = resetRevisions?.map(revision => Object.fromEntries(Object.entries(revision).map(([key, value]) => [camelCase(key), value])));
  5194         return key;
  6268     dispatch.receiveThemeGlobalStyleRevisions(globalStylesId, revisions);
  5195     }
  6269   }
  5196   }));
  6270 };
       
  6271 resolvers_getCurrentThemeGlobalStylesRevisions.shouldInvalidate = action => {
       
  6272   return action.type === 'SAVE_ENTITY_RECORD_FINISH' && action.kind === 'root' && !action.error && action.name === 'globalStyles';
       
  6273 };
       
  6274 const resolvers_getBlockPatterns = () => async ({
       
  6275   dispatch
       
  6276 }) => {
       
  6277   const patterns = await fetchBlockPatterns();
  5197   dispatch({
  6278   dispatch({
  5198     type: 'RECEIVE_BLOCK_PATTERNS',
  6279     type: 'RECEIVE_BLOCK_PATTERNS',
  5199     patterns
  6280     patterns
  5200   });
  6281   });
  5201 };
  6282 };
  5202 const resolvers_getBlockPatternCategories = () => async _ref17 => {
  6283 const resolvers_getBlockPatternCategories = () => async ({
  5203   let {
  6284   dispatch
  5204     dispatch
  6285 }) => {
  5205   } = _ref17;
       
  5206   const categories = await external_wp_apiFetch_default()({
  6286   const categories = await external_wp_apiFetch_default()({
  5207     path: '/wp/v2/block-patterns/categories'
  6287     path: '/wp/v2/block-patterns/categories'
  5208   });
  6288   });
  5209   dispatch({
  6289   dispatch({
  5210     type: 'RECEIVE_BLOCK_PATTERN_CATEGORIES',
  6290     type: 'RECEIVE_BLOCK_PATTERN_CATEGORIES',
  5211     categories
  6291     categories
  5212   });
  6292   });
  5213 };
  6293 };
       
  6294 const resolvers_getUserPatternCategories = () => async ({
       
  6295   dispatch,
       
  6296   resolveSelect
       
  6297 }) => {
       
  6298   const patternCategories = await resolveSelect.getEntityRecords('taxonomy', 'wp_pattern_category', {
       
  6299     per_page: -1,
       
  6300     _fields: 'id,name,description,slug',
       
  6301     context: 'view'
       
  6302   });
       
  6303   const mappedPatternCategories = patternCategories?.map(userCategory => ({
       
  6304     ...userCategory,
       
  6305     label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(userCategory.name),
       
  6306     name: userCategory.slug
       
  6307   })) || [];
       
  6308   dispatch({
       
  6309     type: 'RECEIVE_USER_PATTERN_CATEGORIES',
       
  6310     patternCategories: mappedPatternCategories
       
  6311   });
       
  6312 };
       
  6313 const resolvers_getNavigationFallbackId = () => async ({
       
  6314   dispatch,
       
  6315   select
       
  6316 }) => {
       
  6317   const fallback = await external_wp_apiFetch_default()({
       
  6318     path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp-block-editor/v1/navigation-fallback', {
       
  6319       _embed: true
       
  6320     })
       
  6321   });
       
  6322   const record = fallback?._embedded?.self;
       
  6323   dispatch.receiveNavigationFallbackId(fallback?.id);
       
  6324   if (record) {
       
  6325     // If the fallback is already in the store, don't invalidate navigation queries.
       
  6326     // Otherwise, invalidate the cache for the scenario where there were no Navigation
       
  6327     // posts in the state and the fallback created one.
       
  6328     const existingFallbackEntityRecord = select.getEntityRecord('postType', 'wp_navigation', fallback.id);
       
  6329     const invalidateNavigationQueries = !existingFallbackEntityRecord;
       
  6330     dispatch.receiveEntityRecords('postType', 'wp_navigation', record, undefined, invalidateNavigationQueries);
       
  6331 
       
  6332     // Resolve to avoid further network requests.
       
  6333     dispatch.finishResolution('getEntityRecord', ['postType', 'wp_navigation', fallback.id]);
       
  6334   }
       
  6335 };
       
  6336 const resolvers_getDefaultTemplateId = query => async ({
       
  6337   dispatch
       
  6338 }) => {
       
  6339   const template = await external_wp_apiFetch_default()({
       
  6340     path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/templates/lookup', query)
       
  6341   });
       
  6342   // Endpoint may return an empty object if no template is found.
       
  6343   if (template?.id) {
       
  6344     dispatch.receiveDefaultTemplateId(query, template.id);
       
  6345   }
       
  6346 };
       
  6347 
       
  6348 /**
       
  6349  * Requests an entity's revisions from the REST API.
       
  6350  *
       
  6351  * @param {string}           kind      Entity kind.
       
  6352  * @param {string}           name      Entity name.
       
  6353  * @param {number|string}    recordKey The key of the entity record whose revisions you want to fetch.
       
  6354  * @param {Object|undefined} query     Optional object of query parameters to
       
  6355  *                                     include with request. If requesting specific
       
  6356  *                                     fields, fields must always include the ID.
       
  6357  */
       
  6358 const resolvers_getRevisions = (kind, name, recordKey, query = {}) => async ({
       
  6359   dispatch
       
  6360 }) => {
       
  6361   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
       
  6362   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
       
  6363   if (!entityConfig || entityConfig?.__experimentalNoFetch) {
       
  6364     return;
       
  6365   }
       
  6366   if (query._fields) {
       
  6367     // If requesting specific fields, items and query association to said
       
  6368     // records are stored by ID reference. Thus, fields must always include
       
  6369     // the ID.
       
  6370     query = {
       
  6371       ...query,
       
  6372       _fields: [...new Set([...(get_normalized_comma_separable(query._fields) || []), entityConfig.revisionKey || DEFAULT_ENTITY_KEY])].join()
       
  6373     };
       
  6374   }
       
  6375   const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entityConfig.getRevisionsUrl(recordKey), query);
       
  6376   let records, response;
       
  6377   const meta = {};
       
  6378   const isPaginated = entityConfig.supportsPagination && query.per_page !== -1;
       
  6379   try {
       
  6380     response = await external_wp_apiFetch_default()({
       
  6381       path,
       
  6382       parse: !isPaginated
       
  6383     });
       
  6384   } catch (error) {
       
  6385     // Do nothing if our request comes back with an API error.
       
  6386     return;
       
  6387   }
       
  6388   if (response) {
       
  6389     if (isPaginated) {
       
  6390       records = Object.values(await response.json());
       
  6391       meta.totalItems = parseInt(response.headers.get('X-WP-Total'));
       
  6392     } else {
       
  6393       records = Object.values(response);
       
  6394     }
       
  6395 
       
  6396     // If we request fields but the result doesn't contain the fields,
       
  6397     // explicitly set these fields as "undefined"
       
  6398     // that way we consider the query "fulfilled".
       
  6399     if (query._fields) {
       
  6400       records = records.map(record => {
       
  6401         query._fields.split(',').forEach(field => {
       
  6402           if (!record.hasOwnProperty(field)) {
       
  6403             record[field] = undefined;
       
  6404           }
       
  6405         });
       
  6406         return record;
       
  6407       });
       
  6408     }
       
  6409     dispatch.receiveRevisions(kind, name, recordKey, records, query, false, meta);
       
  6410 
       
  6411     // When requesting all fields, the list of results can be used to
       
  6412     // resolve the `getRevision` selector in addition to `getRevisions`.
       
  6413     if (!query?._fields && !query.context) {
       
  6414       const key = entityConfig.key || DEFAULT_ENTITY_KEY;
       
  6415       const resolutionsArgs = records.filter(record => record[key]).map(record => [kind, name, recordKey, record[key]]);
       
  6416       dispatch({
       
  6417         type: 'START_RESOLUTIONS',
       
  6418         selectorName: 'getRevision',
       
  6419         args: resolutionsArgs
       
  6420       });
       
  6421       dispatch({
       
  6422         type: 'FINISH_RESOLUTIONS',
       
  6423         selectorName: 'getRevision',
       
  6424         args: resolutionsArgs
       
  6425       });
       
  6426     }
       
  6427   }
       
  6428 };
       
  6429 
       
  6430 // Invalidate cache when a new revision is created.
       
  6431 resolvers_getRevisions.shouldInvalidate = (action, kind, name, recordKey) => action.type === 'SAVE_ENTITY_RECORD_FINISH' && name === action.name && kind === action.kind && !action.error && recordKey === action.recordId;
       
  6432 
       
  6433 /**
       
  6434  * Requests a specific Entity revision from the REST API.
       
  6435  *
       
  6436  * @param {string}           kind        Entity kind.
       
  6437  * @param {string}           name        Entity name.
       
  6438  * @param {number|string}    recordKey   The key of the entity record whose revisions you want to fetch.
       
  6439  * @param {number|string}    revisionKey The revision's key.
       
  6440  * @param {Object|undefined} query       Optional object of query parameters to
       
  6441  *                                       include with request. If requesting specific
       
  6442  *                                       fields, fields must always include the ID.
       
  6443  */
       
  6444 const resolvers_getRevision = (kind, name, recordKey, revisionKey, query) => async ({
       
  6445   dispatch
       
  6446 }) => {
       
  6447   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
       
  6448   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
       
  6449   if (!entityConfig || entityConfig?.__experimentalNoFetch) {
       
  6450     return;
       
  6451   }
       
  6452   if (query !== undefined && query._fields) {
       
  6453     // If requesting specific fields, items and query association to said
       
  6454     // records are stored by ID reference. Thus, fields must always include
       
  6455     // the ID.
       
  6456     query = {
       
  6457       ...query,
       
  6458       _fields: [...new Set([...(get_normalized_comma_separable(query._fields) || []), entityConfig.revisionKey || DEFAULT_ENTITY_KEY])].join()
       
  6459     };
       
  6460   }
       
  6461   const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entityConfig.getRevisionsUrl(recordKey, revisionKey), query);
       
  6462   let record;
       
  6463   try {
       
  6464     record = await external_wp_apiFetch_default()({
       
  6465       path
       
  6466     });
       
  6467   } catch (error) {
       
  6468     // Do nothing if our request comes back with an API error.
       
  6469     return;
       
  6470   }
       
  6471   if (record) {
       
  6472     dispatch.receiveRevisions(kind, name, recordKey, record, query);
       
  6473   }
       
  6474 };
  5214 
  6475 
  5215 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/utils.js
  6476 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/utils.js
  5216 function deepCopyLocksTreePath(tree, path) {
  6477 function deepCopyLocksTreePath(tree, path) {
  5217   const newTree = { ...tree
  6478   const newTree = {
       
  6479     ...tree
  5218   };
  6480   };
  5219   let currentNode = newTree;
  6481   let currentNode = newTree;
  5220 
       
  5221   for (const branchName of path) {
  6482   for (const branchName of path) {
  5222     currentNode.children = { ...currentNode.children,
  6483     currentNode.children = {
       
  6484       ...currentNode.children,
  5223       [branchName]: {
  6485       [branchName]: {
  5224         locks: [],
  6486         locks: [],
  5225         children: {},
  6487         children: {},
  5226         ...currentNode.children[branchName]
  6488         ...currentNode.children[branchName]
  5227       }
  6489       }
  5228     };
  6490     };
  5229     currentNode = currentNode.children[branchName];
  6491     currentNode = currentNode.children[branchName];
  5230   }
  6492   }
  5231 
       
  5232   return newTree;
  6493   return newTree;
  5233 }
  6494 }
  5234 function getNode(tree, path) {
  6495 function getNode(tree, path) {
  5235   let currentNode = tree;
  6496   let currentNode = tree;
  5236 
       
  5237   for (const branchName of path) {
  6497   for (const branchName of path) {
  5238     const nextNode = currentNode.children[branchName];
  6498     const nextNode = currentNode.children[branchName];
  5239 
       
  5240     if (!nextNode) {
  6499     if (!nextNode) {
  5241       return null;
  6500       return null;
  5242     }
  6501     }
  5243 
       
  5244     currentNode = nextNode;
  6502     currentNode = nextNode;
  5245   }
  6503   }
  5246 
       
  5247   return currentNode;
  6504   return currentNode;
  5248 }
  6505 }
  5249 function* iteratePath(tree, path) {
  6506 function* iteratePath(tree, path) {
  5250   let currentNode = tree;
  6507   let currentNode = tree;
  5251   yield currentNode;
  6508   yield currentNode;
  5252 
       
  5253   for (const branchName of path) {
  6509   for (const branchName of path) {
  5254     const nextNode = currentNode.children[branchName];
  6510     const nextNode = currentNode.children[branchName];
  5255 
       
  5256     if (!nextNode) {
  6511     if (!nextNode) {
  5257       break;
  6512       break;
  5258     }
  6513     }
  5259 
       
  5260     yield nextNode;
  6514     yield nextNode;
  5261     currentNode = nextNode;
  6515     currentNode = nextNode;
  5262   }
  6516   }
  5263 }
  6517 }
  5264 function* iterateDescendants(node) {
  6518 function* iterateDescendants(node) {
  5265   const stack = Object.values(node.children);
  6519   const stack = Object.values(node.children);
  5266 
       
  5267   while (stack.length) {
  6520   while (stack.length) {
  5268     const childNode = stack.pop();
  6521     const childNode = stack.pop();
  5269     yield childNode;
  6522     yield childNode;
  5270     stack.push(...Object.values(childNode.children));
  6523     stack.push(...Object.values(childNode.children));
  5271   }
  6524   }
  5272 }
  6525 }
  5273 function hasConflictingLock(_ref, locks) {
  6526 function hasConflictingLock({
  5274   let {
  6527   exclusive
  5275     exclusive
  6528 }, locks) {
  5276   } = _ref;
       
  5277 
       
  5278   if (exclusive && locks.length) {
  6529   if (exclusive && locks.length) {
  5279     return true;
  6530     return true;
  5280   }
  6531   }
  5281 
       
  5282   if (!exclusive && locks.filter(lock => lock.exclusive).length) {
  6532   if (!exclusive && locks.filter(lock => lock.exclusive).length) {
  5283     return true;
  6533     return true;
  5284   }
  6534   }
  5285 
       
  5286   return false;
  6535   return false;
  5287 }
  6536 }
  5288 
  6537 
  5289 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/reducer.js
  6538 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/reducer.js
  5290 /**
  6539 /**
  5296   tree: {
  6545   tree: {
  5297     locks: [],
  6546     locks: [],
  5298     children: {}
  6547     children: {}
  5299   }
  6548   }
  5300 };
  6549 };
       
  6550 
  5301 /**
  6551 /**
  5302  * Reducer returning locks.
  6552  * Reducer returning locks.
  5303  *
  6553  *
  5304  * @param {Object} state  Current state.
  6554  * @param {Object} state  Current state.
  5305  * @param {Object} action Dispatched action.
  6555  * @param {Object} action Dispatched action.
  5306  *
  6556  *
  5307  * @return {Object} Updated state.
  6557  * @return {Object} Updated state.
  5308  */
  6558  */
  5309 
  6559 function locks(state = DEFAULT_STATE, action) {
  5310 function locks() {
       
  5311   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_STATE;
       
  5312   let action = arguments.length > 1 ? arguments[1] : undefined;
       
  5313 
       
  5314   switch (action.type) {
  6560   switch (action.type) {
  5315     case 'ENQUEUE_LOCK_REQUEST':
  6561     case 'ENQUEUE_LOCK_REQUEST':
  5316       {
  6562       {
  5317         const {
  6563         const {
  5318           request
  6564           request
  5319         } = action;
  6565         } = action;
  5320         return { ...state,
  6566         return {
       
  6567           ...state,
  5321           requests: [request, ...state.requests]
  6568           requests: [request, ...state.requests]
  5322         };
  6569         };
  5323       }
  6570       }
  5324 
       
  5325     case 'GRANT_LOCK_REQUEST':
  6571     case 'GRANT_LOCK_REQUEST':
  5326       {
  6572       {
  5327         const {
  6573         const {
  5328           lock,
  6574           lock,
  5329           request
  6575           request
  5334         } = request;
  6580         } = request;
  5335         const storePath = [store, ...path];
  6581         const storePath = [store, ...path];
  5336         const newTree = deepCopyLocksTreePath(state.tree, storePath);
  6582         const newTree = deepCopyLocksTreePath(state.tree, storePath);
  5337         const node = getNode(newTree, storePath);
  6583         const node = getNode(newTree, storePath);
  5338         node.locks = [...node.locks, lock];
  6584         node.locks = [...node.locks, lock];
  5339         return { ...state,
  6585         return {
       
  6586           ...state,
  5340           requests: state.requests.filter(r => r !== request),
  6587           requests: state.requests.filter(r => r !== request),
  5341           tree: newTree
  6588           tree: newTree
  5342         };
  6589         };
  5343       }
  6590       }
  5344 
       
  5345     case 'RELEASE_LOCK':
  6591     case 'RELEASE_LOCK':
  5346       {
  6592       {
  5347         const {
  6593         const {
  5348           lock
  6594           lock
  5349         } = action;
  6595         } = action;
  5350         const storePath = [lock.store, ...lock.path];
  6596         const storePath = [lock.store, ...lock.path];
  5351         const newTree = deepCopyLocksTreePath(state.tree, storePath);
  6597         const newTree = deepCopyLocksTreePath(state.tree, storePath);
  5352         const node = getNode(newTree, storePath);
  6598         const node = getNode(newTree, storePath);
  5353         node.locks = node.locks.filter(l => l !== lock);
  6599         node.locks = node.locks.filter(l => l !== lock);
  5354         return { ...state,
  6600         return {
       
  6601           ...state,
  5355           tree: newTree
  6602           tree: newTree
  5356         };
  6603         };
  5357       }
  6604       }
  5358   }
  6605   }
  5359 
       
  5360   return state;
  6606   return state;
  5361 }
  6607 }
  5362 
  6608 
  5363 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/selectors.js
  6609 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/selectors.js
  5364 /**
  6610 /**
  5366  */
  6612  */
  5367 
  6613 
  5368 function getPendingLockRequests(state) {
  6614 function getPendingLockRequests(state) {
  5369   return state.requests;
  6615   return state.requests;
  5370 }
  6616 }
  5371 function isLockAvailable(state, store, path, _ref) {
  6617 function isLockAvailable(state, store, path, {
  5372   let {
  6618   exclusive
  5373     exclusive
  6619 }) {
  5374   } = _ref;
       
  5375   const storePath = [store, ...path];
  6620   const storePath = [store, ...path];
  5376   const locks = state.tree; // Validate all parents and the node itself
  6621   const locks = state.tree;
  5377 
  6622 
       
  6623   // Validate all parents and the node itself
  5378   for (const node of iteratePath(locks, storePath)) {
  6624   for (const node of iteratePath(locks, storePath)) {
  5379     if (hasConflictingLock({
  6625     if (hasConflictingLock({
  5380       exclusive
  6626       exclusive
  5381     }, node.locks)) {
  6627     }, node.locks)) {
  5382       return false;
  6628       return false;
  5383     }
  6629     }
  5384   } // iteratePath terminates early if path is unreachable, let's
  6630   }
       
  6631 
       
  6632   // iteratePath terminates early if path is unreachable, let's
  5385   // re-fetch the node and check it exists in the tree.
  6633   // re-fetch the node and check it exists in the tree.
  5386 
       
  5387 
       
  5388   const node = getNode(locks, storePath);
  6634   const node = getNode(locks, storePath);
  5389 
       
  5390   if (!node) {
  6635   if (!node) {
  5391     return true;
  6636     return true;
  5392   } // Validate all nested nodes
  6637   }
  5393 
  6638 
  5394 
  6639   // Validate all nested nodes
  5395   for (const descendant of iterateDescendants(node)) {
  6640   for (const descendant of iterateDescendants(node)) {
  5396     if (hasConflictingLock({
  6641     if (hasConflictingLock({
  5397       exclusive
  6642       exclusive
  5398     }, descendant.locks)) {
  6643     }, descendant.locks)) {
  5399       return false;
  6644       return false;
  5400     }
  6645     }
  5401   }
  6646   }
  5402 
       
  5403   return true;
  6647   return true;
  5404 }
  6648 }
  5405 
  6649 
  5406 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/engine.js
  6650 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/engine.js
  5407 /**
  6651 /**
  5411 
  6655 
  5412 function createLocks() {
  6656 function createLocks() {
  5413   let state = locks(undefined, {
  6657   let state = locks(undefined, {
  5414     type: '@@INIT'
  6658     type: '@@INIT'
  5415   });
  6659   });
  5416 
       
  5417   function processPendingLockRequests() {
  6660   function processPendingLockRequests() {
  5418     for (const request of getPendingLockRequests(state)) {
  6661     for (const request of getPendingLockRequests(state)) {
  5419       const {
  6662       const {
  5420         store,
  6663         store,
  5421         path,
  6664         path,
  5422         exclusive,
  6665         exclusive,
  5423         notifyAcquired
  6666         notifyAcquired
  5424       } = request;
  6667       } = request;
  5425 
       
  5426       if (isLockAvailable(state, store, path, {
  6668       if (isLockAvailable(state, store, path, {
  5427         exclusive
  6669         exclusive
  5428       })) {
  6670       })) {
  5429         const lock = {
  6671         const lock = {
  5430           store,
  6672           store,
  5438         });
  6680         });
  5439         notifyAcquired(lock);
  6681         notifyAcquired(lock);
  5440       }
  6682       }
  5441     }
  6683     }
  5442   }
  6684   }
  5443 
       
  5444   function acquire(store, path, exclusive) {
  6685   function acquire(store, path, exclusive) {
  5445     return new Promise(resolve => {
  6686     return new Promise(resolve => {
  5446       state = locks(state, {
  6687       state = locks(state, {
  5447         type: 'ENQUEUE_LOCK_REQUEST',
  6688         type: 'ENQUEUE_LOCK_REQUEST',
  5448         request: {
  6689         request: {
  5453         }
  6694         }
  5454       });
  6695       });
  5455       processPendingLockRequests();
  6696       processPendingLockRequests();
  5456     });
  6697     });
  5457   }
  6698   }
  5458 
       
  5459   function release(lock) {
  6699   function release(lock) {
  5460     state = locks(state, {
  6700     state = locks(state, {
  5461       type: 'RELEASE_LOCK',
  6701       type: 'RELEASE_LOCK',
  5462       lock
  6702       lock
  5463     });
  6703     });
  5464     processPendingLockRequests();
  6704     processPendingLockRequests();
  5465   }
  6705   }
  5466 
       
  5467   return {
  6706   return {
  5468     acquire,
  6707     acquire,
  5469     release
  6708     release
  5470   };
  6709   };
  5471 }
  6710 }
  5475  * Internal dependencies
  6714  * Internal dependencies
  5476  */
  6715  */
  5477 
  6716 
  5478 function createLocksActions() {
  6717 function createLocksActions() {
  5479   const locks = createLocks();
  6718   const locks = createLocks();
  5480 
  6719   function __unstableAcquireStoreLock(store, path, {
  5481   function __unstableAcquireStoreLock(store, path, _ref) {
  6720     exclusive
  5482     let {
  6721   }) {
  5483       exclusive
       
  5484     } = _ref;
       
  5485     return () => locks.acquire(store, path, exclusive);
  6722     return () => locks.acquire(store, path, exclusive);
  5486   }
  6723   }
  5487 
       
  5488   function __unstableReleaseStoreLock(lock) {
  6724   function __unstableReleaseStoreLock(lock) {
  5489     return () => locks.release(lock);
  6725     return () => locks.release(lock);
  5490   }
  6726   }
  5491 
       
  5492   return {
  6727   return {
  5493     __unstableAcquireStoreLock,
  6728     __unstableAcquireStoreLock,
  5494     __unstableReleaseStoreLock
  6729     __unstableReleaseStoreLock
  5495   };
  6730   };
  5496 }
  6731 }
  5497 
  6732 
       
  6733 ;// CONCATENATED MODULE: external ["wp","privateApis"]
       
  6734 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
       
  6735 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/private-apis.js
       
  6736 /**
       
  6737  * WordPress dependencies
       
  6738  */
       
  6739 
       
  6740 const {
       
  6741   lock,
       
  6742   unlock
       
  6743 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/core-data');
       
  6744 
  5498 ;// CONCATENATED MODULE: external ["wp","element"]
  6745 ;// CONCATENATED MODULE: external ["wp","element"]
  5499 var external_wp_element_namespaceObject = window["wp"]["element"];
  6746 const external_wp_element_namespaceObject = window["wp"]["element"];
  5500 ;// CONCATENATED MODULE: external ["wp","blocks"]
  6747 ;// CONCATENATED MODULE: external ["wp","blocks"]
  5501 var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
  6748 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
       
  6749 ;// CONCATENATED MODULE: external ["wp","blockEditor"]
       
  6750 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
       
  6751 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/footnotes/get-rich-text-values-cached.js
       
  6752 /**
       
  6753  * WordPress dependencies
       
  6754  */
       
  6755 
       
  6756 
       
  6757 /**
       
  6758  * Internal dependencies
       
  6759  */
       
  6760 
       
  6761 
       
  6762 // TODO: The following line should have been:
       
  6763 //
       
  6764 //   const unlockedApis = unlock( blockEditorPrivateApis );
       
  6765 //
       
  6766 // But there are hidden circular dependencies in RNMobile code, specifically in
       
  6767 // certain native components in the `components` package that depend on
       
  6768 // `block-editor`. What follows is a workaround that defers the `unlock` call
       
  6769 // to prevent native code from failing.
       
  6770 //
       
  6771 // Fix once https://github.com/WordPress/gutenberg/issues/52692 is closed.
       
  6772 let unlockedApis;
       
  6773 const cache = new WeakMap();
       
  6774 function getRichTextValuesCached(block) {
       
  6775   if (!unlockedApis) {
       
  6776     unlockedApis = unlock(external_wp_blockEditor_namespaceObject.privateApis);
       
  6777   }
       
  6778   if (!cache.has(block)) {
       
  6779     const values = unlockedApis.getRichTextValues([block]);
       
  6780     cache.set(block, values);
       
  6781   }
       
  6782   return cache.get(block);
       
  6783 }
       
  6784 
       
  6785 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/footnotes/get-footnotes-order.js
       
  6786 /**
       
  6787  * Internal dependencies
       
  6788  */
       
  6789 
       
  6790 const get_footnotes_order_cache = new WeakMap();
       
  6791 function getBlockFootnotesOrder(block) {
       
  6792   if (!get_footnotes_order_cache.has(block)) {
       
  6793     const order = [];
       
  6794     for (const value of getRichTextValuesCached(block)) {
       
  6795       if (!value) {
       
  6796         continue;
       
  6797       }
       
  6798 
       
  6799       // replacements is a sparse array, use forEach to skip empty slots.
       
  6800       value.replacements.forEach(({
       
  6801         type,
       
  6802         attributes
       
  6803       }) => {
       
  6804         if (type === 'core/footnote') {
       
  6805           order.push(attributes['data-fn']);
       
  6806         }
       
  6807       });
       
  6808     }
       
  6809     get_footnotes_order_cache.set(block, order);
       
  6810   }
       
  6811   return get_footnotes_order_cache.get(block);
       
  6812 }
       
  6813 function getFootnotesOrder(blocks) {
       
  6814   // We can only separate getting order from blocks at the root level. For
       
  6815   // deeper inner blocks, this will not work since it's possible to have both
       
  6816   // inner blocks and block attributes, so order needs to be computed from the
       
  6817   // Edit functions as a whole.
       
  6818   return blocks.flatMap(getBlockFootnotesOrder);
       
  6819 }
       
  6820 
       
  6821 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/footnotes/index.js
       
  6822 /**
       
  6823  * WordPress dependencies
       
  6824  */
       
  6825 
       
  6826 
       
  6827 /**
       
  6828  * Internal dependencies
       
  6829  */
       
  6830 
       
  6831 let oldFootnotes = {};
       
  6832 function updateFootnotesFromMeta(blocks, meta) {
       
  6833   const output = {
       
  6834     blocks
       
  6835   };
       
  6836   if (!meta) {
       
  6837     return output;
       
  6838   }
       
  6839 
       
  6840   // If meta.footnotes is empty, it means the meta is not registered.
       
  6841   if (meta.footnotes === undefined) {
       
  6842     return output;
       
  6843   }
       
  6844   const newOrder = getFootnotesOrder(blocks);
       
  6845   const footnotes = meta.footnotes ? JSON.parse(meta.footnotes) : [];
       
  6846   const currentOrder = footnotes.map(fn => fn.id);
       
  6847   if (currentOrder.join('') === newOrder.join('')) {
       
  6848     return output;
       
  6849   }
       
  6850   const newFootnotes = newOrder.map(fnId => footnotes.find(fn => fn.id === fnId) || oldFootnotes[fnId] || {
       
  6851     id: fnId,
       
  6852     content: ''
       
  6853   });
       
  6854   function updateAttributes(attributes) {
       
  6855     // Only attempt to update attributes, if attributes is an object.
       
  6856     if (!attributes || Array.isArray(attributes) || typeof attributes !== 'object') {
       
  6857       return attributes;
       
  6858     }
       
  6859     attributes = {
       
  6860       ...attributes
       
  6861     };
       
  6862     for (const key in attributes) {
       
  6863       const value = attributes[key];
       
  6864       if (Array.isArray(value)) {
       
  6865         attributes[key] = value.map(updateAttributes);
       
  6866         continue;
       
  6867       }
       
  6868 
       
  6869       // To do, remove support for string values?
       
  6870       if (typeof value !== 'string' && !(value instanceof external_wp_richText_namespaceObject.RichTextData)) {
       
  6871         continue;
       
  6872       }
       
  6873       const richTextValue = typeof value === 'string' ? external_wp_richText_namespaceObject.RichTextData.fromHTMLString(value) : new external_wp_richText_namespaceObject.RichTextData(value);
       
  6874       richTextValue.replacements.forEach(replacement => {
       
  6875         if (replacement.type === 'core/footnote') {
       
  6876           const id = replacement.attributes['data-fn'];
       
  6877           const index = newOrder.indexOf(id);
       
  6878           // The innerHTML contains the count wrapped in a link.
       
  6879           const countValue = (0,external_wp_richText_namespaceObject.create)({
       
  6880             html: replacement.innerHTML
       
  6881           });
       
  6882           countValue.text = String(index + 1);
       
  6883           countValue.formats = Array.from({
       
  6884             length: countValue.text.length
       
  6885           }, () => countValue.formats[0]);
       
  6886           countValue.replacements = Array.from({
       
  6887             length: countValue.text.length
       
  6888           }, () => countValue.replacements[0]);
       
  6889           replacement.innerHTML = (0,external_wp_richText_namespaceObject.toHTMLString)({
       
  6890             value: countValue
       
  6891           });
       
  6892         }
       
  6893       });
       
  6894       attributes[key] = typeof value === 'string' ? richTextValue.toHTMLString() : richTextValue;
       
  6895     }
       
  6896     return attributes;
       
  6897   }
       
  6898   function updateBlocksAttributes(__blocks) {
       
  6899     return __blocks.map(block => {
       
  6900       return {
       
  6901         ...block,
       
  6902         attributes: updateAttributes(block.attributes),
       
  6903         innerBlocks: updateBlocksAttributes(block.innerBlocks)
       
  6904       };
       
  6905     });
       
  6906   }
       
  6907 
       
  6908   // We need to go through all block attributes deeply and update the
       
  6909   // footnote anchor numbering (textContent) to match the new order.
       
  6910   const newBlocks = updateBlocksAttributes(blocks);
       
  6911   oldFootnotes = {
       
  6912     ...oldFootnotes,
       
  6913     ...footnotes.reduce((acc, fn) => {
       
  6914       if (!newOrder.includes(fn.id)) {
       
  6915         acc[fn.id] = fn;
       
  6916       }
       
  6917       return acc;
       
  6918     }, {})
       
  6919   };
       
  6920   return {
       
  6921     meta: {
       
  6922       ...meta,
       
  6923       footnotes: JSON.stringify(newFootnotes)
       
  6924     },
       
  6925     blocks: newBlocks
       
  6926   };
       
  6927 }
       
  6928 
       
  6929 ;// CONCATENATED MODULE: external "ReactJSXRuntime"
       
  6930 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
  5502 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entity-provider.js
  6931 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entity-provider.js
  5503 
       
  5504 
       
  5505 /**
  6932 /**
  5506  * WordPress dependencies
  6933  * WordPress dependencies
  5507  */
  6934  */
  5508 
  6935 
  5509 
  6936 
  5510 
  6937 
       
  6938 
  5511 /**
  6939 /**
  5512  * Internal dependencies
  6940  * Internal dependencies
  5513  */
  6941  */
  5514 
  6942 
  5515 
  6943 
       
  6944 
  5516 /** @typedef {import('@wordpress/blocks').WPBlock} WPBlock */
  6945 /** @typedef {import('@wordpress/blocks').WPBlock} WPBlock */
  5517 
  6946 
  5518 const EMPTY_ARRAY = [];
  6947 const EMPTY_ARRAY = [];
  5519 /**
  6948 const EntityContext = (0,external_wp_element_namespaceObject.createContext)({});
  5520  * Internal dependencies
  6949 
  5521  */
       
  5522 
       
  5523 
       
  5524 const entityContexts = { ...rootEntitiesConfig.reduce((acc, loader) => {
       
  5525     if (!acc[loader.kind]) {
       
  5526       acc[loader.kind] = {};
       
  5527     }
       
  5528 
       
  5529     acc[loader.kind][loader.name] = {
       
  5530       context: (0,external_wp_element_namespaceObject.createContext)(undefined)
       
  5531     };
       
  5532     return acc;
       
  5533   }, {}),
       
  5534   ...additionalEntityConfigLoaders.reduce((acc, loader) => {
       
  5535     acc[loader.kind] = {};
       
  5536     return acc;
       
  5537   }, {})
       
  5538 };
       
  5539 
       
  5540 const getEntityContext = (kind, name) => {
       
  5541   if (!entityContexts[kind]) {
       
  5542     throw new Error(`Missing entity config for kind: ${kind}.`);
       
  5543   }
       
  5544 
       
  5545   if (!entityContexts[kind][name]) {
       
  5546     entityContexts[kind][name] = {
       
  5547       context: (0,external_wp_element_namespaceObject.createContext)(undefined)
       
  5548     };
       
  5549   }
       
  5550 
       
  5551   return entityContexts[kind][name].context;
       
  5552 };
       
  5553 /**
  6950 /**
  5554  * Context provider component for providing
  6951  * Context provider component for providing
  5555  * an entity for a specific entity.
  6952  * an entity for a specific entity.
  5556  *
  6953  *
  5557  * @param {Object} props          The component's props.
  6954  * @param {Object} props          The component's props.
  5561  * @param {*}      props.children The children to wrap.
  6958  * @param {*}      props.children The children to wrap.
  5562  *
  6959  *
  5563  * @return {Object} The provided children, wrapped with
  6960  * @return {Object} The provided children, wrapped with
  5564  *                   the entity's context provider.
  6961  *                   the entity's context provider.
  5565  */
  6962  */
  5566 
  6963 function EntityProvider({
  5567 
  6964   kind,
  5568 function EntityProvider(_ref) {
  6965   type: name,
  5569   let {
  6966   id,
  5570     kind,
  6967   children
  5571     type: name,
  6968 }) {
  5572     id,
  6969   const parent = (0,external_wp_element_namespaceObject.useContext)(EntityContext);
  5573     children
  6970   const childContext = (0,external_wp_element_namespaceObject.useMemo)(() => ({
  5574   } = _ref;
  6971     ...parent,
  5575   const Provider = getEntityContext(kind, name).Provider;
  6972     [kind]: {
  5576   return (0,external_wp_element_namespaceObject.createElement)(Provider, {
  6973       ...parent?.[kind],
  5577     value: id
  6974       [name]: id
  5578   }, children);
  6975     }
  5579 }
  6976   }), [parent, kind, name, id]);
       
  6977   return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityContext.Provider, {
       
  6978     value: childContext,
       
  6979     children: children
       
  6980   });
       
  6981 }
       
  6982 
  5580 /**
  6983 /**
  5581  * Hook that returns the ID for the nearest
  6984  * Hook that returns the ID for the nearest
  5582  * provided entity of the specified type.
  6985  * provided entity of the specified type.
  5583  *
  6986  *
  5584  * @param {string} kind The entity kind.
  6987  * @param {string} kind The entity kind.
  5585  * @param {string} name The entity name.
  6988  * @param {string} name The entity name.
  5586  */
  6989  */
  5587 
       
  5588 function useEntityId(kind, name) {
  6990 function useEntityId(kind, name) {
  5589   return (0,external_wp_element_namespaceObject.useContext)(getEntityContext(kind, name));
  6991   const context = (0,external_wp_element_namespaceObject.useContext)(EntityContext);
  5590 }
  6992   return context?.[kind]?.[name];
       
  6993 }
       
  6994 
  5591 /**
  6995 /**
  5592  * Hook that returns the value and a setter for the
  6996  * Hook that returns the value and a setter for the
  5593  * specified property of the nearest provided
  6997  * specified property of the nearest provided
  5594  * entity of the specified type.
  6998  * entity of the specified type.
  5595  *
  6999  *
  5603  *                            setter and the third is the full value
  7007  *                            setter and the third is the full value
  5604  * 							  object from REST API containing more
  7008  * 							  object from REST API containing more
  5605  * 							  information like `raw`, `rendered` and
  7009  * 							  information like `raw`, `rendered` and
  5606  * 							  `protected` props.
  7010  * 							  `protected` props.
  5607  */
  7011  */
  5608 
       
  5609 function useEntityProp(kind, name, prop, _id) {
  7012 function useEntityProp(kind, name, prop, _id) {
  5610   const providerId = useEntityId(kind, name);
  7013   const providerId = useEntityId(kind, name);
  5611   const id = _id !== null && _id !== void 0 ? _id : providerId;
  7014   const id = _id !== null && _id !== void 0 ? _id : providerId;
  5612   const {
  7015   const {
  5613     value,
  7016     value,
  5616     const {
  7019     const {
  5617       getEntityRecord,
  7020       getEntityRecord,
  5618       getEditedEntityRecord
  7021       getEditedEntityRecord
  5619     } = select(STORE_NAME);
  7022     } = select(STORE_NAME);
  5620     const record = getEntityRecord(kind, name, id); // Trigger resolver.
  7023     const record = getEntityRecord(kind, name, id); // Trigger resolver.
  5621 
       
  5622     const editedRecord = getEditedEntityRecord(kind, name, id);
  7024     const editedRecord = getEditedEntityRecord(kind, name, id);
  5623     return record && editedRecord ? {
  7025     return record && editedRecord ? {
  5624       value: editedRecord[prop],
  7026       value: editedRecord[prop],
  5625       fullValue: record[prop]
  7027       fullValue: record[prop]
  5626     } : {};
  7028     } : {};
  5630   } = (0,external_wp_data_namespaceObject.useDispatch)(STORE_NAME);
  7032   } = (0,external_wp_data_namespaceObject.useDispatch)(STORE_NAME);
  5631   const setValue = (0,external_wp_element_namespaceObject.useCallback)(newValue => {
  7033   const setValue = (0,external_wp_element_namespaceObject.useCallback)(newValue => {
  5632     editEntityRecord(kind, name, id, {
  7034     editEntityRecord(kind, name, id, {
  5633       [prop]: newValue
  7035       [prop]: newValue
  5634     });
  7036     });
  5635   }, [kind, name, id, prop]);
  7037   }, [editEntityRecord, kind, name, id, prop]);
  5636   return [value, setValue, fullValue];
  7038   return [value, setValue, fullValue];
  5637 }
  7039 }
       
  7040 const parsedBlocksCache = new WeakMap();
       
  7041 
  5638 /**
  7042 /**
  5639  * Hook that returns block content getters and setters for
  7043  * Hook that returns block content getters and setters for
  5640  * the nearest provided entity of the specified type.
  7044  * the nearest provided entity of the specified type.
  5641  *
  7045  *
  5642  * The return value has the shape `[ blocks, onInput, onChange ]`.
  7046  * The return value has the shape `[ blocks, onInput, onChange ]`.
  5643  * `onInput` is for block changes that don't create undo levels
  7047  * `onInput` is for block changes that don't create undo levels
  5644  * or dirty the post, non-persistent changes, and `onChange` is for
  7048  * or dirty the post, non-persistent changes, and `onChange` is for
  5645  * peristent changes. They map directly to the props of a
  7049  * persistent changes. They map directly to the props of a
  5646  * `BlockEditorProvider` and are intended to be used with it,
  7050  * `BlockEditorProvider` and are intended to be used with it,
  5647  * or similar components or hooks.
  7051  * or similar components or hooks.
  5648  *
  7052  *
  5649  * @param {string} kind         The entity kind.
  7053  * @param {string} kind         The entity kind.
  5650  * @param {string} name         The entity name.
  7054  * @param {string} name         The entity name.
  5651  * @param {Object} options
  7055  * @param {Object} options
  5652  * @param {string} [options.id] An entity ID to use instead of the context-provided one.
  7056  * @param {string} [options.id] An entity ID to use instead of the context-provided one.
  5653  *
  7057  *
  5654  * @return {[WPBlock[], Function, Function]} The block array and setters.
  7058  * @return {[WPBlock[], Function, Function]} The block array and setters.
  5655  */
  7059  */
  5656 
  7060 function useEntityBlockEditor(kind, name, {
  5657 function useEntityBlockEditor(kind, name) {
  7061   id: _id
  5658   let {
  7062 } = {}) {
  5659     id: _id
       
  5660   } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
       
  5661   const providerId = useEntityId(kind, name);
  7063   const providerId = useEntityId(kind, name);
  5662   const id = _id !== null && _id !== void 0 ? _id : providerId;
  7064   const id = _id !== null && _id !== void 0 ? _id : providerId;
  5663   const {
  7065   const {
       
  7066     getEntityRecord,
       
  7067     getEntityRecordEdits
       
  7068   } = (0,external_wp_data_namespaceObject.useSelect)(STORE_NAME);
       
  7069   const {
  5664     content,
  7070     content,
  5665     blocks
  7071     editedBlocks,
       
  7072     meta
  5666   } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  7073   } = (0,external_wp_data_namespaceObject.useSelect)(select => {
       
  7074     if (!id) {
       
  7075       return {};
       
  7076     }
  5667     const {
  7077     const {
  5668       getEditedEntityRecord
  7078       getEditedEntityRecord
  5669     } = select(STORE_NAME);
  7079     } = select(STORE_NAME);
  5670     const editedRecord = getEditedEntityRecord(kind, name, id);
  7080     const editedRecord = getEditedEntityRecord(kind, name, id);
  5671     return {
  7081     return {
  5672       blocks: editedRecord.blocks,
  7082       editedBlocks: editedRecord.blocks,
  5673       content: editedRecord.content
  7083       content: editedRecord.content,
       
  7084       meta: editedRecord.meta
  5674     };
  7085     };
  5675   }, [kind, name, id]);
  7086   }, [kind, name, id]);
  5676   const {
  7087   const {
  5677     __unstableCreateUndoLevel,
  7088     __unstableCreateUndoLevel,
  5678     editEntityRecord
  7089     editEntityRecord
  5679   } = (0,external_wp_data_namespaceObject.useDispatch)(STORE_NAME);
  7090   } = (0,external_wp_data_namespaceObject.useDispatch)(STORE_NAME);
  5680   (0,external_wp_element_namespaceObject.useEffect)(() => {
  7091   const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
  5681     // Load the blocks from the content if not already in state
  7092     if (!id) {
  5682     // Guard against other instances that might have
  7093       return undefined;
  5683     // set content to a function already or the blocks are already in state.
  7094     }
  5684     if (content && typeof content !== 'function' && !blocks) {
  7095     if (editedBlocks) {
  5685       const parsedContent = (0,external_wp_blocks_namespaceObject.parse)(content);
  7096       return editedBlocks;
  5686       editEntityRecord(kind, name, id, {
  7097     }
  5687         blocks: parsedContent
  7098     if (!content || typeof content !== 'string') {
  5688       }, {
  7099       return EMPTY_ARRAY;
  5689         undoIgnore: true
  7100     }
  5690       });
  7101 
  5691     }
  7102     // If there's an edit, cache the parsed blocks by the edit.
  5692   }, [content]);
  7103     // If not, cache by the original enity record.
       
  7104     const edits = getEntityRecordEdits(kind, name, id);
       
  7105     const isUnedited = !edits || !Object.keys(edits).length;
       
  7106     const cackeKey = isUnedited ? getEntityRecord(kind, name, id) : edits;
       
  7107     let _blocks = parsedBlocksCache.get(cackeKey);
       
  7108     if (!_blocks) {
       
  7109       _blocks = (0,external_wp_blocks_namespaceObject.parse)(content);
       
  7110       parsedBlocksCache.set(cackeKey, _blocks);
       
  7111     }
       
  7112     return _blocks;
       
  7113   }, [kind, name, id, editedBlocks, content, getEntityRecord, getEntityRecordEdits]);
       
  7114   const updateFootnotes = (0,external_wp_element_namespaceObject.useCallback)(_blocks => updateFootnotesFromMeta(_blocks, meta), [meta]);
  5693   const onChange = (0,external_wp_element_namespaceObject.useCallback)((newBlocks, options) => {
  7115   const onChange = (0,external_wp_element_namespaceObject.useCallback)((newBlocks, options) => {
  5694     const {
  7116     const noChange = blocks === newBlocks;
  5695       selection
       
  5696     } = options;
       
  5697     const edits = {
       
  5698       blocks: newBlocks,
       
  5699       selection
       
  5700     };
       
  5701     const noChange = blocks === edits.blocks;
       
  5702 
       
  5703     if (noChange) {
  7117     if (noChange) {
  5704       return __unstableCreateUndoLevel(kind, name, id);
  7118       return __unstableCreateUndoLevel(kind, name, id);
  5705     } // We create a new function here on every persistent edit
  7119     }
       
  7120     const {
       
  7121       selection,
       
  7122       ...rest
       
  7123     } = options;
       
  7124 
       
  7125     // We create a new function here on every persistent edit
  5706     // to make sure the edit makes the post dirty and creates
  7126     // to make sure the edit makes the post dirty and creates
  5707     // a new undo level.
  7127     // a new undo level.
  5708 
  7128     const edits = {
  5709 
  7129       selection,
  5710     edits.content = _ref2 => {
  7130       content: ({
  5711       let {
       
  5712         blocks: blocksForSerialization = []
  7131         blocks: blocksForSerialization = []
  5713       } = _ref2;
  7132       }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization),
  5714       return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
  7133       ...updateFootnotes(newBlocks)
  5715     };
  7134     };
  5716 
  7135     editEntityRecord(kind, name, id, edits, {
  5717     editEntityRecord(kind, name, id, edits);
  7136       isCached: false,
  5718   }, [kind, name, id, blocks]);
  7137       ...rest
       
  7138     });
       
  7139   }, [kind, name, id, blocks, updateFootnotes, __unstableCreateUndoLevel, editEntityRecord]);
  5719   const onInput = (0,external_wp_element_namespaceObject.useCallback)((newBlocks, options) => {
  7140   const onInput = (0,external_wp_element_namespaceObject.useCallback)((newBlocks, options) => {
  5720     const {
  7141     const {
  5721       selection
  7142       selection,
       
  7143       ...rest
  5722     } = options;
  7144     } = options;
       
  7145     const footnotesChanges = updateFootnotes(newBlocks);
  5723     const edits = {
  7146     const edits = {
  5724       blocks: newBlocks,
  7147       selection,
  5725       selection
  7148       ...footnotesChanges
  5726     };
  7149     };
  5727     editEntityRecord(kind, name, id, edits);
  7150     editEntityRecord(kind, name, id, edits, {
  5728   }, [kind, name, id]);
  7151       isCached: true,
  5729   return [blocks !== null && blocks !== void 0 ? blocks : EMPTY_ARRAY, onInput, onChange];
  7152       ...rest
  5730 }
  7153     });
  5731 
  7154   }, [kind, name, id, updateFootnotes, editEntityRecord]);
  5732 // EXTERNAL MODULE: ./node_modules/memize/index.js
  7155   return [blocks, onInput, onChange];
  5733 var memize = __webpack_require__(9756);
  7156 }
  5734 var memize_default = /*#__PURE__*/__webpack_require__.n(memize);
  7157 
       
  7158 ;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js
       
  7159 /**
       
  7160  * Memize options object.
       
  7161  *
       
  7162  * @typedef MemizeOptions
       
  7163  *
       
  7164  * @property {number} [maxSize] Maximum size of the cache.
       
  7165  */
       
  7166 
       
  7167 /**
       
  7168  * Internal cache entry.
       
  7169  *
       
  7170  * @typedef MemizeCacheNode
       
  7171  *
       
  7172  * @property {?MemizeCacheNode|undefined} [prev] Previous node.
       
  7173  * @property {?MemizeCacheNode|undefined} [next] Next node.
       
  7174  * @property {Array<*>}                   args   Function arguments for cache
       
  7175  *                                               entry.
       
  7176  * @property {*}                          val    Function result.
       
  7177  */
       
  7178 
       
  7179 /**
       
  7180  * Properties of the enhanced function for controlling cache.
       
  7181  *
       
  7182  * @typedef MemizeMemoizedFunction
       
  7183  *
       
  7184  * @property {()=>void} clear Clear the cache.
       
  7185  */
       
  7186 
       
  7187 /**
       
  7188  * Accepts a function to be memoized, and returns a new memoized function, with
       
  7189  * optional options.
       
  7190  *
       
  7191  * @template {(...args: any[]) => any} F
       
  7192  *
       
  7193  * @param {F}             fn        Function to memoize.
       
  7194  * @param {MemizeOptions} [options] Options object.
       
  7195  *
       
  7196  * @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function.
       
  7197  */
       
  7198 function memize(fn, options) {
       
  7199 	var size = 0;
       
  7200 
       
  7201 	/** @type {?MemizeCacheNode|undefined} */
       
  7202 	var head;
       
  7203 
       
  7204 	/** @type {?MemizeCacheNode|undefined} */
       
  7205 	var tail;
       
  7206 
       
  7207 	options = options || {};
       
  7208 
       
  7209 	function memoized(/* ...args */) {
       
  7210 		var node = head,
       
  7211 			len = arguments.length,
       
  7212 			args,
       
  7213 			i;
       
  7214 
       
  7215 		searchCache: while (node) {
       
  7216 			// Perform a shallow equality test to confirm that whether the node
       
  7217 			// under test is a candidate for the arguments passed. Two arrays
       
  7218 			// are shallowly equal if their length matches and each entry is
       
  7219 			// strictly equal between the two sets. Avoid abstracting to a
       
  7220 			// function which could incur an arguments leaking deoptimization.
       
  7221 
       
  7222 			// Check whether node arguments match arguments length
       
  7223 			if (node.args.length !== arguments.length) {
       
  7224 				node = node.next;
       
  7225 				continue;
       
  7226 			}
       
  7227 
       
  7228 			// Check whether node arguments match arguments values
       
  7229 			for (i = 0; i < len; i++) {
       
  7230 				if (node.args[i] !== arguments[i]) {
       
  7231 					node = node.next;
       
  7232 					continue searchCache;
       
  7233 				}
       
  7234 			}
       
  7235 
       
  7236 			// At this point we can assume we've found a match
       
  7237 
       
  7238 			// Surface matched node to head if not already
       
  7239 			if (node !== head) {
       
  7240 				// As tail, shift to previous. Must only shift if not also
       
  7241 				// head, since if both head and tail, there is no previous.
       
  7242 				if (node === tail) {
       
  7243 					tail = node.prev;
       
  7244 				}
       
  7245 
       
  7246 				// Adjust siblings to point to each other. If node was tail,
       
  7247 				// this also handles new tail's empty `next` assignment.
       
  7248 				/** @type {MemizeCacheNode} */ (node.prev).next = node.next;
       
  7249 				if (node.next) {
       
  7250 					node.next.prev = node.prev;
       
  7251 				}
       
  7252 
       
  7253 				node.next = head;
       
  7254 				node.prev = null;
       
  7255 				/** @type {MemizeCacheNode} */ (head).prev = node;
       
  7256 				head = node;
       
  7257 			}
       
  7258 
       
  7259 			// Return immediately
       
  7260 			return node.val;
       
  7261 		}
       
  7262 
       
  7263 		// No cached value found. Continue to insertion phase:
       
  7264 
       
  7265 		// Create a copy of arguments (avoid leaking deoptimization)
       
  7266 		args = new Array(len);
       
  7267 		for (i = 0; i < len; i++) {
       
  7268 			args[i] = arguments[i];
       
  7269 		}
       
  7270 
       
  7271 		node = {
       
  7272 			args: args,
       
  7273 
       
  7274 			// Generate the result from original function
       
  7275 			val: fn.apply(null, args),
       
  7276 		};
       
  7277 
       
  7278 		// Don't need to check whether node is already head, since it would
       
  7279 		// have been returned above already if it was
       
  7280 
       
  7281 		// Shift existing head down list
       
  7282 		if (head) {
       
  7283 			head.prev = node;
       
  7284 			node.next = head;
       
  7285 		} else {
       
  7286 			// If no head, follows that there's no tail (at initial or reset)
       
  7287 			tail = node;
       
  7288 		}
       
  7289 
       
  7290 		// Trim tail if we're reached max size and are pending cache insertion
       
  7291 		if (size === /** @type {MemizeOptions} */ (options).maxSize) {
       
  7292 			tail = /** @type {MemizeCacheNode} */ (tail).prev;
       
  7293 			/** @type {MemizeCacheNode} */ (tail).next = null;
       
  7294 		} else {
       
  7295 			size++;
       
  7296 		}
       
  7297 
       
  7298 		head = node;
       
  7299 
       
  7300 		return node.val;
       
  7301 	}
       
  7302 
       
  7303 	memoized.clear = function () {
       
  7304 		head = null;
       
  7305 		tail = null;
       
  7306 		size = 0;
       
  7307 	};
       
  7308 
       
  7309 	// Ignore reason: There's not a clear solution to create an intersection of
       
  7310 	// the function with additional properties, where the goal is to retain the
       
  7311 	// function signature of the incoming argument and add control properties
       
  7312 	// on the return value.
       
  7313 
       
  7314 	// @ts-ignore
       
  7315 	return memoized;
       
  7316 }
       
  7317 
       
  7318 
       
  7319 
  5735 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/memoize.js
  7320 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/memoize.js
  5736 /**
  7321 /**
  5737  * External dependencies
  7322  * External dependencies
  5738  */
  7323  */
  5739  // re-export due to restrictive esModuleInterop setting
  7324 
  5740 
  7325 
  5741 /* harmony default export */ var memoize = ((memize_default()));
  7326 // re-export due to restrictive esModuleInterop setting
       
  7327 /* harmony default export */ const memoize = (memize);
  5742 
  7328 
  5743 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/constants.js
  7329 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/constants.js
  5744 /* eslint-disable-next-line no-shadow */
  7330 let Status = /*#__PURE__*/function (Status) {
  5745 let Status;
       
  5746 
       
  5747 (function (Status) {
       
  5748   Status["Idle"] = "IDLE";
  7331   Status["Idle"] = "IDLE";
  5749   Status["Resolving"] = "RESOLVING";
  7332   Status["Resolving"] = "RESOLVING";
  5750   Status["Error"] = "ERROR";
  7333   Status["Error"] = "ERROR";
  5751   Status["Success"] = "SUCCESS";
  7334   Status["Success"] = "SUCCESS";
  5752 })(Status || (Status = {}));
  7335   return Status;
       
  7336 }({});
  5753 
  7337 
  5754 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-query-select.js
  7338 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-query-select.js
  5755 /**
  7339 /**
  5756  * WordPress dependencies
  7340  * WordPress dependencies
  5757  */
  7341  */
  5758 
  7342 
       
  7343 
  5759 /**
  7344 /**
  5760  * Internal dependencies
  7345  * Internal dependencies
  5761  */
  7346  */
  5762 
  7347 
  5763 
  7348 
  5764 
       
  5765 const META_SELECTORS = ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'];
  7349 const META_SELECTORS = ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'];
  5766 
       
  5767 /**
  7350 /**
  5768  * Like useSelect, but the selectors return objects containing
  7351  * Like useSelect, but the selectors return objects containing
  5769  * both the original data AND the resolution info.
  7352  * both the original data AND the resolution info.
       
  7353  *
       
  7354  * @since 6.1.0 Introduced in WordPress core.
       
  7355  * @private
  5770  *
  7356  *
  5771  * @param {Function} mapQuerySelect see useSelect
  7357  * @param {Function} mapQuerySelect see useSelect
  5772  * @param {Array}    deps           see useSelect
  7358  * @param {Array}    deps           see useSelect
  5773  *
  7359  *
  5774  * @example
  7360  * @example
  5802  * the id.
  7388  * the id.
  5803  * @see useSelect
  7389  * @see useSelect
  5804  *
  7390  *
  5805  * @return {QuerySelectResponse} Queried data.
  7391  * @return {QuerySelectResponse} Queried data.
  5806  */
  7392  */
  5807 function __experimentalUseQuerySelect(mapQuerySelect, deps) {
  7393 function useQuerySelect(mapQuerySelect, deps) {
  5808   return (0,external_wp_data_namespaceObject.useSelect)((select, registry) => {
  7394   return (0,external_wp_data_namespaceObject.useSelect)((select, registry) => {
  5809     const resolve = store => enrichSelectors(select(store));
  7395     const resolve = store => enrichSelectors(select(store));
  5810 
       
  5811     return mapQuerySelect(resolve, registry);
  7396     return mapQuerySelect(resolve, registry);
  5812   }, deps);
  7397   }, deps);
  5813 }
  7398 }
  5814 
       
  5815 /**
  7399 /**
  5816  * Transform simple selectors into ones that return an object with the
  7400  * Transform simple selectors into ones that return an object with the
  5817  * original return value AND the resolution info.
  7401  * original return value AND the resolution info.
  5818  *
  7402  *
  5819  * @param {Object} selectors Selectors to enrich
  7403  * @param {Object} selectors Selectors to enrich
  5820  * @return {EnrichedSelectors} Enriched selectors
  7404  * @return {EnrichedSelectors} Enriched selectors
  5821  */
  7405  */
  5822 const enrichSelectors = memoize(selectors => {
  7406 const enrichSelectors = memoize(selectors => {
  5823   const resolvers = {};
  7407   const resolvers = {};
  5824 
       
  5825   for (const selectorName in selectors) {
  7408   for (const selectorName in selectors) {
  5826     if (META_SELECTORS.includes(selectorName)) {
  7409     if (META_SELECTORS.includes(selectorName)) {
  5827       continue;
  7410       continue;
  5828     }
  7411     }
  5829 
       
  5830     Object.defineProperty(resolvers, selectorName, {
  7412     Object.defineProperty(resolvers, selectorName, {
  5831       get: () => function () {
  7413       get: () => (...args) => {
  5832         const {
  7414         const data = selectors[selectorName](...args);
  5833           getIsResolving,
  7415         const resolutionStatus = selectors.getResolutionState(selectorName, args)?.status;
  5834           hasFinishedResolution
  7416         let status;
  5835         } = selectors;
  7417         switch (resolutionStatus) {
  5836 
  7418           case 'resolving':
  5837         for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  7419             status = Status.Resolving;
  5838           args[_key] = arguments[_key];
  7420             break;
       
  7421           case 'finished':
       
  7422             status = Status.Success;
       
  7423             break;
       
  7424           case 'error':
       
  7425             status = Status.Error;
       
  7426             break;
       
  7427           case undefined:
       
  7428             status = Status.Idle;
       
  7429             break;
  5839         }
  7430         }
  5840 
       
  5841         const isResolving = !!getIsResolving(selectorName, args);
       
  5842         const hasResolved = !isResolving && hasFinishedResolution(selectorName, args);
       
  5843         const data = selectors[selectorName](...args);
       
  5844         let status;
       
  5845 
       
  5846         if (isResolving) {
       
  5847           status = Status.Resolving;
       
  5848         } else if (hasResolved) {
       
  5849           if (data) {
       
  5850             status = Status.Success;
       
  5851           } else {
       
  5852             status = Status.Error;
       
  5853           }
       
  5854         } else {
       
  5855           status = Status.Idle;
       
  5856         }
       
  5857 
       
  5858         return {
  7431         return {
  5859           data,
  7432           data,
  5860           status,
  7433           status,
  5861           isResolving,
  7434           isResolving: status === Status.Resolving,
  5862           hasResolved
  7435           hasStarted: status !== Status.Idle,
       
  7436           hasResolved: status === Status.Success || status === Status.Error
  5863         };
  7437         };
  5864       }
  7438       }
  5865     });
  7439     });
  5866   }
  7440   }
  5867 
       
  5868   return resolvers;
  7441   return resolvers;
  5869 });
  7442 });
  5870 
  7443 
  5871 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-entity-record.js
  7444 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-entity-record.js
  5872 /**
  7445 /**
       
  7446  * WordPress dependencies
       
  7447  */
       
  7448 
       
  7449 
       
  7450 
       
  7451 
       
  7452 /**
  5873  * Internal dependencies
  7453  * Internal dependencies
  5874  */
  7454  */
  5875 
  7455 
  5876 
  7456 
       
  7457 const use_entity_record_EMPTY_OBJECT = {};
  5877 
  7458 
  5878 /**
  7459 /**
  5879  * Resolves the specified entity record.
  7460  * Resolves the specified entity record.
  5880  *
  7461  *
  5881  * @param  kind                   Kind of the requested entity.
  7462  * @since 6.1.0 Introduced in WordPress core.
  5882  * @param  name                   Name of the requested  entity.
  7463  *
  5883  * @param  recordId               Record ID of the requested entity.
  7464  * @param    kind     Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.
  5884  * @param  options                Hook options.
  7465  * @param    name     Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.
  5885  * @param  [options.enabled=true] Whether to run the query or short-circuit and return null. Defaults to true.
  7466  * @param    recordId ID of the requested entity record.
       
  7467  * @param    options  Optional hook options.
  5886  * @example
  7468  * @example
  5887  * ```js
  7469  * ```js
  5888  * import { useEntityRecord } from '@wordpress/core-data';
  7470  * import { useEntityRecord } from '@wordpress/core-data';
  5889  *
  7471  *
  5890  * function PageTitleDisplay( { id } ) {
  7472  * function PageTitleDisplay( { id } ) {
  5903  *
  7485  *
  5904  * In the above example, when `PageTitleDisplay` is rendered into an
  7486  * In the above example, when `PageTitleDisplay` is rendered into an
  5905  * application, the page and the resolution details will be retrieved from
  7487  * application, the page and the resolution details will be retrieved from
  5906  * the store state using `getEntityRecord()`, or resolved if missing.
  7488  * the store state using `getEntityRecord()`, or resolved if missing.
  5907  *
  7489  *
  5908  * @return {EntityRecordResolution<RecordType>} Entity record data.
  7490  * @example
       
  7491  * ```js
       
  7492  * import { useCallback } from 'react';
       
  7493  * import { useDispatch } from '@wordpress/data';
       
  7494  * import { __ } from '@wordpress/i18n';
       
  7495  * import { TextControl } from '@wordpress/components';
       
  7496  * import { store as noticeStore } from '@wordpress/notices';
       
  7497  * import { useEntityRecord } from '@wordpress/core-data';
       
  7498  *
       
  7499  * function PageRenameForm( { id } ) {
       
  7500  * 	const page = useEntityRecord( 'postType', 'page', id );
       
  7501  * 	const { createSuccessNotice, createErrorNotice } =
       
  7502  * 		useDispatch( noticeStore );
       
  7503  *
       
  7504  * 	const setTitle = useCallback( ( title ) => {
       
  7505  * 		page.edit( { title } );
       
  7506  * 	}, [ page.edit ] );
       
  7507  *
       
  7508  * 	if ( page.isResolving ) {
       
  7509  * 		return 'Loading...';
       
  7510  * 	}
       
  7511  *
       
  7512  * 	async function onRename( event ) {
       
  7513  * 		event.preventDefault();
       
  7514  * 		try {
       
  7515  * 			await page.save();
       
  7516  * 			createSuccessNotice( __( 'Page renamed.' ), {
       
  7517  * 				type: 'snackbar',
       
  7518  * 			} );
       
  7519  * 		} catch ( error ) {
       
  7520  * 			createErrorNotice( error.message, { type: 'snackbar' } );
       
  7521  * 		}
       
  7522  * 	}
       
  7523  *
       
  7524  * 	return (
       
  7525  * 		<form onSubmit={ onRename }>
       
  7526  * 			<TextControl
       
  7527  * 				label={ __( 'Name' ) }
       
  7528  * 				value={ page.editedRecord.title }
       
  7529  * 				onChange={ setTitle }
       
  7530  * 			/>
       
  7531  * 			<button type="submit">{ __( 'Save' ) }</button>
       
  7532  * 		</form>
       
  7533  * 	);
       
  7534  * }
       
  7535  *
       
  7536  * // Rendered in the application:
       
  7537  * // <PageRenameForm id={ 1 } />
       
  7538  * ```
       
  7539  *
       
  7540  * In the above example, updating and saving the page title is handled
       
  7541  * via the `edit()` and `save()` mutation helpers provided by
       
  7542  * `useEntityRecord()`;
       
  7543  *
       
  7544  * @return Entity record data.
  5909  * @template RecordType
  7545  * @template RecordType
  5910  */
  7546  */
  5911 function __experimentalUseEntityRecord(kind, name, recordId) {
  7547 function useEntityRecord(kind, name, recordId, options = {
  5912   let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
  7548   enabled: true
  5913     enabled: true
  7549 }) {
  5914   };
  7550   const {
       
  7551     editEntityRecord,
       
  7552     saveEditedEntityRecord
       
  7553   } = (0,external_wp_data_namespaceObject.useDispatch)(store);
       
  7554   const mutations = (0,external_wp_element_namespaceObject.useMemo)(() => ({
       
  7555     edit: (record, editOptions = {}) => editEntityRecord(kind, name, recordId, record, editOptions),
       
  7556     save: (saveOptions = {}) => saveEditedEntityRecord(kind, name, recordId, {
       
  7557       throwOnError: true,
       
  7558       ...saveOptions
       
  7559     })
       
  7560   }), [editEntityRecord, kind, name, recordId, saveEditedEntityRecord]);
       
  7561   const {
       
  7562     editedRecord,
       
  7563     hasEdits,
       
  7564     edits
       
  7565   } = (0,external_wp_data_namespaceObject.useSelect)(select => {
       
  7566     if (!options.enabled) {
       
  7567       return {
       
  7568         editedRecord: use_entity_record_EMPTY_OBJECT,
       
  7569         hasEdits: false,
       
  7570         edits: use_entity_record_EMPTY_OBJECT
       
  7571       };
       
  7572     }
       
  7573     return {
       
  7574       editedRecord: select(store).getEditedEntityRecord(kind, name, recordId),
       
  7575       hasEdits: select(store).hasEditsForEntityRecord(kind, name, recordId),
       
  7576       edits: select(store).getEntityRecordNonTransientEdits(kind, name, recordId)
       
  7577     };
       
  7578   }, [kind, name, recordId, options.enabled]);
  5915   const {
  7579   const {
  5916     data: record,
  7580     data: record,
  5917     ...rest
  7581     ...querySelectRest
  5918   } = __experimentalUseQuerySelect(query => {
  7582   } = useQuerySelect(query => {
  5919     if (!options.enabled) {
  7583     if (!options.enabled) {
  5920       return null;
  7584       return {
  5921     }
  7585         data: null
  5922 
  7586       };
       
  7587     }
  5923     return query(store).getEntityRecord(kind, name, recordId);
  7588     return query(store).getEntityRecord(kind, name, recordId);
  5924   }, [kind, name, recordId, options.enabled]);
  7589   }, [kind, name, recordId, options.enabled]);
  5925   return {
  7590   return {
  5926     record,
  7591     record,
  5927     ...rest
  7592     editedRecord,
       
  7593     hasEdits,
       
  7594     edits,
       
  7595     ...querySelectRest,
       
  7596     ...mutations
  5928   };
  7597   };
  5929 }
  7598 }
       
  7599 function __experimentalUseEntityRecord(kind, name, recordId, options) {
       
  7600   external_wp_deprecated_default()(`wp.data.__experimentalUseEntityRecord`, {
       
  7601     alternative: 'wp.data.useEntityRecord',
       
  7602     since: '6.1'
       
  7603   });
       
  7604   return useEntityRecord(kind, name, recordId, options);
       
  7605 }
  5930 
  7606 
  5931 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-entity-records.js
  7607 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-entity-records.js
  5932 /**
  7608 /**
  5933  * WordPress dependencies
  7609  * WordPress dependencies
  5934  */
  7610  */
  5935 
  7611 
       
  7612 
       
  7613 
       
  7614 
  5936 /**
  7615 /**
  5937  * Internal dependencies
  7616  * Internal dependencies
  5938  */
  7617  */
  5939 
  7618 
  5940 
  7619 
  5941 
  7620 const use_entity_records_EMPTY_ARRAY = [];
  5942 
  7621 
  5943 /**
  7622 /**
  5944  * Resolves the specified entity records.
  7623  * Resolves the specified entity records.
  5945  *
  7624  *
  5946  * @param  kind      Kind of the requested entities.
  7625  * @since 6.1.0 Introduced in WordPress core.
  5947  * @param  name      Name of the requested entities.
  7626  *
  5948  * @param  queryArgs HTTP query for the requested entities.
  7627  * @param    kind      Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.
  5949  * @param  options   Hook options.
  7628  * @param    name      Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.
       
  7629  * @param    queryArgs Optional HTTP query description for how to fetch the data, passed to the requested API endpoint.
       
  7630  * @param    options   Optional hook options.
  5950  * @example
  7631  * @example
  5951  * ```js
  7632  * ```js
  5952  * import { useEntityRecord } from '@wordpress/core-data';
  7633  * import { useEntityRecords } from '@wordpress/core-data';
  5953  *
  7634  *
  5954  * function PageTitlesList() {
  7635  * function PageTitlesList() {
  5955  *   const { records, isResolving } = useEntityRecords( 'postType', 'page' );
  7636  *   const { records, isResolving } = useEntityRecords( 'postType', 'page' );
  5956  *
  7637  *
  5957  *   if ( isResolving ) {
  7638  *   if ( isResolving ) {
  5976  * the store state using `getEntityRecords()`, or resolved if missing.
  7657  * the store state using `getEntityRecords()`, or resolved if missing.
  5977  *
  7658  *
  5978  * @return Entity records data.
  7659  * @return Entity records data.
  5979  * @template RecordType
  7660  * @template RecordType
  5980  */
  7661  */
  5981 function __experimentalUseEntityRecords(kind, name) {
  7662 function useEntityRecords(kind, name, queryArgs = {}, options = {
  5982   let queryArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  7663   enabled: true
  5983   let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
  7664 }) {
  5984     enabled: true
       
  5985   };
       
  5986   // Serialize queryArgs to a string that can be safely used as a React dep.
  7665   // Serialize queryArgs to a string that can be safely used as a React dep.
  5987   // We can't just pass queryArgs as one of the deps, because if it is passed
  7666   // We can't just pass queryArgs as one of the deps, because if it is passed
  5988   // as an object literal, then it will be a different object on each call even
  7667   // as an object literal, then it will be a different object on each call even
  5989   // if the values remain the same.
  7668   // if the values remain the same.
  5990   const queryAsString = (0,external_wp_url_namespaceObject.addQueryArgs)('', queryArgs);
  7669   const queryAsString = (0,external_wp_url_namespaceObject.addQueryArgs)('', queryArgs);
  5991   const {
  7670   const {
  5992     data: records,
  7671     data: records,
  5993     ...rest
  7672     ...rest
  5994   } = __experimentalUseQuerySelect(query => {
  7673   } = useQuerySelect(query => {
  5995     if (!options.enabled) {
  7674     if (!options.enabled) {
  5996       return {
  7675       return {
  5997         data: []
  7676         // Avoiding returning a new reference on every execution.
       
  7677         data: use_entity_records_EMPTY_ARRAY
  5998       };
  7678       };
  5999     }
  7679     }
  6000 
       
  6001     return query(store).getEntityRecords(kind, name, queryArgs);
  7680     return query(store).getEntityRecords(kind, name, queryArgs);
       
  7681   }, [kind, name, queryAsString, options.enabled]);
       
  7682   const {
       
  7683     totalItems,
       
  7684     totalPages
       
  7685   } = (0,external_wp_data_namespaceObject.useSelect)(select => {
       
  7686     if (!options.enabled) {
       
  7687       return {
       
  7688         totalItems: null,
       
  7689         totalPages: null
       
  7690       };
       
  7691     }
       
  7692     return {
       
  7693       totalItems: select(store).getEntityRecordsTotalItems(kind, name, queryArgs),
       
  7694       totalPages: select(store).getEntityRecordsTotalPages(kind, name, queryArgs)
       
  7695     };
  6002   }, [kind, name, queryAsString, options.enabled]);
  7696   }, [kind, name, queryAsString, options.enabled]);
  6003   return {
  7697   return {
  6004     records,
  7698     records,
       
  7699     totalItems,
       
  7700     totalPages,
  6005     ...rest
  7701     ...rest
  6006   };
  7702   };
  6007 }
  7703 }
  6008 
  7704 function __experimentalUseEntityRecords(kind, name, queryArgs, options) {
  6009 ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
  7705   external_wp_deprecated_default()(`wp.data.__experimentalUseEntityRecords`, {
  6010 var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
  7706     alternative: 'wp.data.useEntityRecords',
  6011 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/fetch/__experimental-fetch-link-suggestions.js
  7707     since: '6.1'
       
  7708   });
       
  7709   return useEntityRecords(kind, name, queryArgs, options);
       
  7710 }
       
  7711 
       
  7712 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-resource-permissions.js
  6012 /**
  7713 /**
  6013  * WordPress dependencies
  7714  * WordPress dependencies
  6014  */
  7715  */
  6015 
  7716 
  6016 
  7717 
  6017 
  7718 /**
  6018 
  7719  * Internal dependencies
  6019 /**
  7720  */
  6020  * Filters the search by type
  7721 
  6021  *
  7722 
  6022  * @typedef { 'attachment' | 'post' | 'term' | 'post-format' } WPLinkSearchType
  7723 
  6023  */
  7724 
  6024 
  7725 /**
  6025 /**
  7726  * Is the data resolved by now?
  6026  * A link with an id may be of kind post-type or taxonomy
  7727  */
  6027  *
  7728 
  6028  * @typedef { 'post-type' | 'taxonomy' } WPKind
  7729 /**
  6029  */
  7730  * Resolves resource permissions.
  6030 
  7731  *
  6031 /**
  7732  * @since 6.1.0 Introduced in WordPress core.
  6032  * @typedef WPLinkSearchOptions
  7733  *
  6033  *
  7734  * @param    resource The resource in question, e.g. media.
  6034  * @property {boolean}          [isInitialSuggestions] Displays initial search suggestions, when true.
  7735  * @param    id       ID of a specific resource entry, if needed, e.g. 10.
  6035  * @property {WPLinkSearchType} [type]                 Filters by search type.
       
  6036  * @property {string}           [subtype]              Slug of the post-type or taxonomy.
       
  6037  * @property {number}           [page]                 Which page of results to return.
       
  6038  * @property {number}           [perPage]              Search results per page.
       
  6039  */
       
  6040 
       
  6041 /**
       
  6042  * @typedef WPLinkSearchResult
       
  6043  *
       
  6044  * @property {number} id     Post or term id.
       
  6045  * @property {string} url    Link url.
       
  6046  * @property {string} title  Title of the link.
       
  6047  * @property {string} type   The taxonomy or post type slug or type URL.
       
  6048  * @property {WPKind} [kind] Link kind of post-type or taxonomy
       
  6049  */
       
  6050 
       
  6051 /**
       
  6052  * @typedef WPLinkSearchResultAugments
       
  6053  *
       
  6054  * @property {{kind: WPKind}} [meta]    Contains kind information.
       
  6055  * @property {WPKind}         [subtype] Optional subtype if it exists.
       
  6056  */
       
  6057 
       
  6058 /**
       
  6059  * @typedef {WPLinkSearchResult & WPLinkSearchResultAugments} WPLinkSearchResultAugmented
       
  6060  */
       
  6061 
       
  6062 /**
       
  6063  * @typedef WPEditorSettings
       
  6064  *
       
  6065  * @property {boolean} [ disablePostFormats ] Disables post formats, when true.
       
  6066  */
       
  6067 
       
  6068 /**
       
  6069  * Fetches link suggestions from the API.
       
  6070  *
       
  6071  * @async
       
  6072  * @param {string}              search
       
  6073  * @param {WPLinkSearchOptions} [searchOptions]
       
  6074  * @param {WPEditorSettings}    [settings]
       
  6075  *
  7736  *
  6076  * @example
  7737  * @example
  6077  * ```js
  7738  * ```js
  6078  * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';
  7739  * import { useResourcePermissions } from '@wordpress/core-data';
  6079  *
  7740  *
  6080  * //...
  7741  * function PagesList() {
  6081  *
  7742  *   const { canCreate, isResolving } = useResourcePermissions( 'pages' );
  6082  * export function initialize( id, settings ) {
  7743  *
  6083  *
  7744  *   if ( isResolving ) {
  6084  * settings.__experimentalFetchLinkSuggestions = (
  7745  *     return 'Loading ...';
  6085  *     search,
  7746  *   }
  6086  *     searchOptions
  7747  *
  6087  * ) => fetchLinkSuggestions( search, searchOptions, settings );
  7748  *   return (
       
  7749  *     <div>
       
  7750  *       {canCreate ? (<button>+ Create a new page</button>) : false}
       
  7751  *       // ...
       
  7752  *     </div>
       
  7753  *   );
       
  7754  * }
       
  7755  *
       
  7756  * // Rendered in the application:
       
  7757  * // <PagesList />
  6088  * ```
  7758  * ```
  6089  * @return {Promise< WPLinkSearchResult[] >} List of search suggestions
  7759  *
  6090  */
       
  6091 
       
  6092 const fetchLinkSuggestions = async function (search) {
       
  6093   let searchOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
       
  6094   let settings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
       
  6095   const {
       
  6096     isInitialSuggestions = false,
       
  6097     type = undefined,
       
  6098     subtype = undefined,
       
  6099     page = undefined,
       
  6100     perPage = isInitialSuggestions ? 3 : 20
       
  6101   } = searchOptions;
       
  6102   const {
       
  6103     disablePostFormats = false
       
  6104   } = settings;
       
  6105   /** @type {Promise<WPLinkSearchResult>[]} */
       
  6106 
       
  6107   const queries = [];
       
  6108 
       
  6109   if (!type || type === 'post') {
       
  6110     queries.push(external_wp_apiFetch_default()({
       
  6111       path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
       
  6112         search,
       
  6113         page,
       
  6114         per_page: perPage,
       
  6115         type: 'post',
       
  6116         subtype
       
  6117       })
       
  6118     }).then(results => {
       
  6119       return results.map(result => {
       
  6120         return { ...result,
       
  6121           meta: {
       
  6122             kind: 'post-type',
       
  6123             subtype
       
  6124           }
       
  6125         };
       
  6126       });
       
  6127     }).catch(() => []) // Fail by returning no results.
       
  6128     );
       
  6129   }
       
  6130 
       
  6131   if (!type || type === 'term') {
       
  6132     queries.push(external_wp_apiFetch_default()({
       
  6133       path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
       
  6134         search,
       
  6135         page,
       
  6136         per_page: perPage,
       
  6137         type: 'term',
       
  6138         subtype
       
  6139       })
       
  6140     }).then(results => {
       
  6141       return results.map(result => {
       
  6142         return { ...result,
       
  6143           meta: {
       
  6144             kind: 'taxonomy',
       
  6145             subtype
       
  6146           }
       
  6147         };
       
  6148       });
       
  6149     }).catch(() => []) // Fail by returning no results.
       
  6150     );
       
  6151   }
       
  6152 
       
  6153   if (!disablePostFormats && (!type || type === 'post-format')) {
       
  6154     queries.push(external_wp_apiFetch_default()({
       
  6155       path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
       
  6156         search,
       
  6157         page,
       
  6158         per_page: perPage,
       
  6159         type: 'post-format',
       
  6160         subtype
       
  6161       })
       
  6162     }).then(results => {
       
  6163       return results.map(result => {
       
  6164         return { ...result,
       
  6165           meta: {
       
  6166             kind: 'taxonomy',
       
  6167             subtype
       
  6168           }
       
  6169         };
       
  6170       });
       
  6171     }).catch(() => []) // Fail by returning no results.
       
  6172     );
       
  6173   }
       
  6174 
       
  6175   if (!type || type === 'attachment') {
       
  6176     queries.push(external_wp_apiFetch_default()({
       
  6177       path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/media', {
       
  6178         search,
       
  6179         page,
       
  6180         per_page: perPage
       
  6181       })
       
  6182     }).then(results => {
       
  6183       return results.map(result => {
       
  6184         return { ...result,
       
  6185           meta: {
       
  6186             kind: 'media'
       
  6187           }
       
  6188         };
       
  6189       });
       
  6190     }).catch(() => []) // Fail by returning no results.
       
  6191     );
       
  6192   }
       
  6193 
       
  6194   return Promise.all(queries).then(results => {
       
  6195     return results.reduce((
       
  6196     /** @type {WPLinkSearchResult[]} */
       
  6197     accumulator, current) => accumulator.concat(current), // Flatten list.
       
  6198     []).filter(
       
  6199     /**
       
  6200      * @param {{ id: number }} result
       
  6201      */
       
  6202     result => {
       
  6203       return !!result.id;
       
  6204     }).slice(0, perPage).map((
       
  6205     /** @type {WPLinkSearchResultAugmented} */
       
  6206     result) => {
       
  6207       var _result$meta;
       
  6208 
       
  6209       const isMedia = result.type === 'attachment';
       
  6210       return {
       
  6211         id: result.id,
       
  6212         // @ts-ignore fix when we make this a TS file
       
  6213         url: isMedia ? result.source_url : result.url,
       
  6214         title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(isMedia ? // @ts-ignore fix when we make this a TS file
       
  6215         result.title.rendered : result.title || '') || (0,external_wp_i18n_namespaceObject.__)('(no title)'),
       
  6216         type: result.subtype || result.type,
       
  6217         kind: result === null || result === void 0 ? void 0 : (_result$meta = result.meta) === null || _result$meta === void 0 ? void 0 : _result$meta.kind
       
  6218       };
       
  6219     });
       
  6220   });
       
  6221 };
       
  6222 
       
  6223 /* harmony default export */ var _experimental_fetch_link_suggestions = (fetchLinkSuggestions);
       
  6224 
       
  6225 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/fetch/__experimental-fetch-url-data.js
       
  6226 /**
       
  6227  * WordPress dependencies
       
  6228  */
       
  6229 
       
  6230 
       
  6231 /**
       
  6232  * A simple in-memory cache for requests.
       
  6233  * This avoids repeat HTTP requests which may be beneficial
       
  6234  * for those wishing to preserve low-bandwidth.
       
  6235  */
       
  6236 
       
  6237 const CACHE = new Map();
       
  6238 /**
       
  6239  * @typedef WPRemoteUrlData
       
  6240  *
       
  6241  * @property {string} title contents of the remote URL's `<title>` tag.
       
  6242  */
       
  6243 
       
  6244 /**
       
  6245  * Fetches data about a remote URL.
       
  6246  * eg: <title> tag, favicon...etc.
       
  6247  *
       
  6248  * @async
       
  6249  * @param {string}  url     the URL to request details from.
       
  6250  * @param {Object?} options any options to pass to the underlying fetch.
       
  6251  * @example
  7760  * @example
  6252  * ```js
  7761  * ```js
  6253  * import { __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';
  7762  * import { useResourcePermissions } from '@wordpress/core-data';
  6254  *
  7763  *
  6255  * //...
  7764  * function Page({ pageId }) {
  6256  *
  7765  *   const {
  6257  * export function initialize( id, settings ) {
  7766  *     canCreate,
  6258  *
  7767  *     canUpdate,
  6259  * settings.__experimentalFetchUrlData = (
  7768  *     canDelete,
  6260  * url
  7769  *     isResolving
  6261  * ) => fetchUrlData( url );
  7770  *   } = useResourcePermissions( 'pages', pageId );
       
  7771  *
       
  7772  *   if ( isResolving ) {
       
  7773  *     return 'Loading ...';
       
  7774  *   }
       
  7775  *
       
  7776  *   return (
       
  7777  *     <div>
       
  7778  *       {canCreate ? (<button>+ Create a new page</button>) : false}
       
  7779  *       {canUpdate ? (<button>Edit page</button>) : false}
       
  7780  *       {canDelete ? (<button>Delete page</button>) : false}
       
  7781  *       // ...
       
  7782  *     </div>
       
  7783  *   );
       
  7784  * }
       
  7785  *
       
  7786  * // Rendered in the application:
       
  7787  * // <Page pageId={ 15 } />
  6262  * ```
  7788  * ```
  6263  * @return {Promise< WPRemoteUrlData[] >} Remote URL data.
  7789  *
  6264  */
  7790  * In the above example, when `PagesList` is rendered into an
  6265 
  7791  * application, the appropriate permissions and the resolution details will be retrieved from
  6266 const fetchUrlData = async function (url) {
  7792  * the store state using `canUser()`, or resolved if missing.
  6267   let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  7793  *
  6268   const endpoint = '/wp-block-editor/v1/url-details';
  7794  * @return Entity records data.
  6269   const args = {
  7795  * @template IdType
  6270     url: (0,external_wp_url_namespaceObject.prependHTTP)(url)
  7796  */
  6271   };
  7797 function useResourcePermissions(resource, id) {
  6272 
  7798   return useQuerySelect(resolve => {
  6273   if (!(0,external_wp_url_namespaceObject.isURL)(url)) {
  7799     const {
  6274     return Promise.reject(`${url} is not a valid URL.`);
  7800       canUser
  6275   } // Test for "http" based URL as it is possible for valid
  7801     } = resolve(store);
  6276   // yet unusable URLs such as `tel:123456` to be passed.
  7802     const create = canUser('create', resource);
  6277 
  7803     if (!id) {
  6278 
  7804       const read = canUser('read', resource);
  6279   const protocol = (0,external_wp_url_namespaceObject.getProtocol)(url);
  7805       const isResolving = create.isResolving || read.isResolving;
  6280 
  7806       const hasResolved = create.hasResolved && read.hasResolved;
  6281   if (!protocol || !(0,external_wp_url_namespaceObject.isValidProtocol)(protocol) || !protocol.startsWith('http') || !/^https?:\/\/[^\/\s]/i.test(url)) {
  7807       let status = Status.Idle;
  6282     return Promise.reject(`${url} does not have a valid protocol. URLs must be "http" based`);
  7808       if (isResolving) {
  6283   }
  7809         status = Status.Resolving;
  6284 
  7810       } else if (hasResolved) {
  6285   if (CACHE.has(url)) {
  7811         status = Status.Success;
  6286     return CACHE.get(url);
  7812       }
  6287   }
  7813       return {
  6288 
  7814         status,
  6289   return external_wp_apiFetch_default()({
  7815         isResolving,
  6290     path: (0,external_wp_url_namespaceObject.addQueryArgs)(endpoint, args),
  7816         hasResolved,
  6291     ...options
  7817         canCreate: create.hasResolved && create.data,
  6292   }).then(res => {
  7818         canRead: read.hasResolved && read.data
  6293     CACHE.set(url, res);
  7819       };
  6294     return res;
  7820     }
       
  7821     const read = canUser('read', resource, id);
       
  7822     const update = canUser('update', resource, id);
       
  7823     const _delete = canUser('delete', resource, id);
       
  7824     const isResolving = read.isResolving || create.isResolving || update.isResolving || _delete.isResolving;
       
  7825     const hasResolved = read.hasResolved && create.hasResolved && update.hasResolved && _delete.hasResolved;
       
  7826     let status = Status.Idle;
       
  7827     if (isResolving) {
       
  7828       status = Status.Resolving;
       
  7829     } else if (hasResolved) {
       
  7830       status = Status.Success;
       
  7831     }
       
  7832     return {
       
  7833       status,
       
  7834       isResolving,
       
  7835       hasResolved,
       
  7836       canRead: hasResolved && read.data,
       
  7837       canCreate: hasResolved && create.data,
       
  7838       canUpdate: hasResolved && update.data,
       
  7839       canDelete: hasResolved && _delete.data
       
  7840     };
       
  7841   }, [resource, id]);
       
  7842 }
       
  7843 function __experimentalUseResourcePermissions(resource, id) {
       
  7844   external_wp_deprecated_default()(`wp.data.__experimentalUseResourcePermissions`, {
       
  7845     alternative: 'wp.data.useResourcePermissions',
       
  7846     since: '6.1'
  6295   });
  7847   });
  6296 };
  7848   return useResourcePermissions(resource, id);
  6297 
  7849 }
  6298 /* harmony default export */ var _experimental_fetch_url_data = (fetchUrlData);
  7850 
  6299 
  7851 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/index.js
  6300 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/fetch/index.js
  7852 
  6301 
  7853 
  6302 
  7854 
  6303 
  7855 
  6304 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/index.js
  7856 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/index.js
  6305 /**
  7857 /**
  6306  * WordPress dependencies
  7858  * WordPress dependencies
  6307  */
  7859  */
  6308 
  7860 
       
  7861 
  6309 /**
  7862 /**
  6310  * Internal dependencies
  7863  * Internal dependencies
  6311  */
  7864  */
  6312 
  7865 
  6313 
  7866 
  6314 
  7867 
  6315 
  7868 
  6316 
  7869 
  6317 
  7870 
  6318 
  7871 
  6319  // The entity selectors/resolvers and actions are shortcuts to their generic equivalents
  7872 
       
  7873 
       
  7874 
       
  7875 // The entity selectors/resolvers and actions are shortcuts to their generic equivalents
  6320 // (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecords)
  7876 // (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecords)
  6321 // Instead of getEntityRecord, the consumer could use more user-friendly named selector: getPostType, getTaxonomy...
  7877 // Instead of getEntityRecord, the consumer could use more user-friendly named selector: getPostType, getTaxonomy...
  6322 // The "kind" and the "name" of the entity are combined to generate these shortcuts.
  7878 // The "kind" and the "name" of the entity are combined to generate these shortcuts.
  6323 
  7879 const build_module_entitiesConfig = [...rootEntitiesConfig, ...additionalEntityConfigLoaders.filter(config => !!config.name)];
  6324 const entitySelectors = rootEntitiesConfig.reduce((result, entity) => {
  7880 const entitySelectors = build_module_entitiesConfig.reduce((result, entity) => {
       
  7881   const {
       
  7882     kind,
       
  7883     name,
       
  7884     plural
       
  7885   } = entity;
       
  7886   result[getMethodName(kind, name)] = (state, key, query) => getEntityRecord(state, kind, name, key, query);
       
  7887   if (plural) {
       
  7888     result[getMethodName(kind, plural, 'get')] = (state, query) => getEntityRecords(state, kind, name, query);
       
  7889   }
       
  7890   return result;
       
  7891 }, {});
       
  7892 const entityResolvers = build_module_entitiesConfig.reduce((result, entity) => {
       
  7893   const {
       
  7894     kind,
       
  7895     name,
       
  7896     plural
       
  7897   } = entity;
       
  7898   result[getMethodName(kind, name)] = (key, query) => resolvers_getEntityRecord(kind, name, key, query);
       
  7899   if (plural) {
       
  7900     const pluralMethodName = getMethodName(kind, plural, 'get');
       
  7901     result[pluralMethodName] = (...args) => resolvers_getEntityRecords(kind, name, ...args);
       
  7902     result[pluralMethodName].shouldInvalidate = action => resolvers_getEntityRecords.shouldInvalidate(action, kind, name);
       
  7903   }
       
  7904   return result;
       
  7905 }, {});
       
  7906 const entityActions = build_module_entitiesConfig.reduce((result, entity) => {
  6325   const {
  7907   const {
  6326     kind,
  7908     kind,
  6327     name
  7909     name
  6328   } = entity;
  7910   } = entity;
  6329 
  7911   result[getMethodName(kind, name, 'save')] = (record, options) => saveEntityRecord(kind, name, record, options);
  6330   result[getMethodName(kind, name)] = (state, key, query) => getEntityRecord(state, kind, name, key, query);
  7912   result[getMethodName(kind, name, 'delete')] = (key, query, options) => deleteEntityRecord(kind, name, key, query, options);
  6331 
       
  6332   result[getMethodName(kind, name, 'get', true)] = (state, query) => getEntityRecords(state, kind, name, query);
       
  6333 
       
  6334   return result;
  7913   return result;
  6335 }, {});
  7914 }, {});
  6336 const entityResolvers = rootEntitiesConfig.reduce((result, entity) => {
       
  6337   const {
       
  6338     kind,
       
  6339     name
       
  6340   } = entity;
       
  6341 
       
  6342   result[getMethodName(kind, name)] = (key, query) => resolvers_getEntityRecord(kind, name, key, query);
       
  6343 
       
  6344   const pluralMethodName = getMethodName(kind, name, 'get', true);
       
  6345 
       
  6346   result[pluralMethodName] = function () {
       
  6347     for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
       
  6348       args[_key] = arguments[_key];
       
  6349     }
       
  6350 
       
  6351     return resolvers_getEntityRecords(kind, name, ...args);
       
  6352   };
       
  6353 
       
  6354   result[pluralMethodName].shouldInvalidate = action => resolvers_getEntityRecords.shouldInvalidate(action, kind, name);
       
  6355 
       
  6356   return result;
       
  6357 }, {});
       
  6358 const entityActions = rootEntitiesConfig.reduce((result, entity) => {
       
  6359   const {
       
  6360     kind,
       
  6361     name
       
  6362   } = entity;
       
  6363 
       
  6364   result[getMethodName(kind, name, 'save')] = key => saveEntityRecord(kind, name, key);
       
  6365 
       
  6366   result[getMethodName(kind, name, 'delete')] = (key, query) => deleteEntityRecord(kind, name, key, query);
       
  6367 
       
  6368   return result;
       
  6369 }, {});
       
  6370 
       
  6371 const storeConfig = () => ({
  7915 const storeConfig = () => ({
  6372   reducer: build_module_reducer,
  7916   reducer: build_module_reducer,
  6373   actions: { ...build_module_actions_namespaceObject,
  7917   actions: {
       
  7918     ...build_module_actions_namespaceObject,
  6374     ...entityActions,
  7919     ...entityActions,
  6375     ...createLocksActions()
  7920     ...createLocksActions()
  6376   },
  7921   },
  6377   selectors: { ...build_module_selectors_namespaceObject,
  7922   selectors: {
       
  7923     ...build_module_selectors_namespaceObject,
  6378     ...entitySelectors
  7924     ...entitySelectors
  6379   },
  7925   },
  6380   resolvers: { ...resolvers_namespaceObject,
  7926   resolvers: {
       
  7927     ...resolvers_namespaceObject,
  6381     ...entityResolvers
  7928     ...entityResolvers
  6382   }
  7929   }
  6383 });
  7930 });
       
  7931 
  6384 /**
  7932 /**
  6385  * Store definition for the code data namespace.
  7933  * Store definition for the code data namespace.
  6386  *
  7934  *
  6387  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  7935  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  6388  *
  7936  */
  6389  * @type {Object}
       
  6390  */
       
  6391 
       
  6392 
       
  6393 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig());
  7937 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig());
  6394 (0,external_wp_data_namespaceObject.register)(store);
  7938 unlock(store).registerPrivateSelectors(private_selectors_namespaceObject);
  6395 
  7939 (0,external_wp_data_namespaceObject.register)(store); // Register store after unlocking private selectors to allow resolvers to use them.
  6396 
  7940 
  6397 
  7941 
  6398 
  7942 
  6399 
  7943 
  6400 
  7944 
  6401 
  7945 
  6402 }();
  7946 
       
  7947 })();
       
  7948 
  6403 (window.wp = window.wp || {}).coreData = __webpack_exports__;
  7949 (window.wp = window.wp || {}).coreData = __webpack_exports__;
  6404 /******/ })()
  7950 /******/ })()
  6405 ;
  7951 ;