wp/wp-includes/js/dist/keyboard-shortcuts.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 /******/ 	"use strict";
     3 /******/ 	// The require scope
     3 /******/ 	// The require scope
     4 /******/ 	var __webpack_require__ = {};
     4 /******/ 	var __webpack_require__ = {};
     5 /******/ 	
     5 /******/ 	
     6 /************************************************************************/
     6 /************************************************************************/
     7 /******/ 	/* webpack/runtime/define property getters */
     7 /******/ 	/* webpack/runtime/define property getters */
     8 /******/ 	!function() {
     8 /******/ 	(() => {
     9 /******/ 		// define getter functions for harmony exports
     9 /******/ 		// define getter functions for harmony exports
    10 /******/ 		__webpack_require__.d = function(exports, definition) {
    10 /******/ 		__webpack_require__.d = (exports, definition) => {
    11 /******/ 			for(var key in definition) {
    11 /******/ 			for(var key in definition) {
    12 /******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
    12 /******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
    13 /******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
    13 /******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
    14 /******/ 				}
    14 /******/ 				}
    15 /******/ 			}
    15 /******/ 			}
    16 /******/ 		};
    16 /******/ 		};
    17 /******/ 	}();
    17 /******/ 	})();
    18 /******/ 	
    18 /******/ 	
    19 /******/ 	/* webpack/runtime/hasOwnProperty shorthand */
    19 /******/ 	/* webpack/runtime/hasOwnProperty shorthand */
    20 /******/ 	!function() {
    20 /******/ 	(() => {
    21 /******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
    21 /******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
    22 /******/ 	}();
    22 /******/ 	})();
    23 /******/ 	
    23 /******/ 	
    24 /******/ 	/* webpack/runtime/make namespace object */
    24 /******/ 	/* webpack/runtime/make namespace object */
    25 /******/ 	!function() {
    25 /******/ 	(() => {
    26 /******/ 		// define __esModule on exports
    26 /******/ 		// define __esModule on exports
    27 /******/ 		__webpack_require__.r = function(exports) {
    27 /******/ 		__webpack_require__.r = (exports) => {
    28 /******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
    28 /******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
    29 /******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
    29 /******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
    30 /******/ 			}
    30 /******/ 			}
    31 /******/ 			Object.defineProperty(exports, '__esModule', { value: true });
    31 /******/ 			Object.defineProperty(exports, '__esModule', { value: true });
    32 /******/ 		};
    32 /******/ 		};
    33 /******/ 	}();
    33 /******/ 	})();
    34 /******/ 	
    34 /******/ 	
    35 /************************************************************************/
    35 /************************************************************************/
    36 var __webpack_exports__ = {};
    36 var __webpack_exports__ = {};
    37 // ESM COMPAT FLAG
    37 // ESM COMPAT FLAG
    38 __webpack_require__.r(__webpack_exports__);
    38 __webpack_require__.r(__webpack_exports__);
    39 
    39 
    40 // EXPORTS
    40 // EXPORTS
    41 __webpack_require__.d(__webpack_exports__, {
    41 __webpack_require__.d(__webpack_exports__, {
    42   "ShortcutProvider": function() { return /* reexport */ ShortcutProvider; },
    42   ShortcutProvider: () => (/* reexport */ ShortcutProvider),
    43   "__unstableUseShortcutEventMatch": function() { return /* reexport */ useShortcutEventMatch; },
    43   __unstableUseShortcutEventMatch: () => (/* reexport */ useShortcutEventMatch),
    44   "store": function() { return /* reexport */ store; },
    44   store: () => (/* reexport */ store),
    45   "useShortcut": function() { return /* reexport */ useShortcut; }
    45   useShortcut: () => (/* reexport */ useShortcut)
    46 });
    46 });
    47 
    47 
    48 // NAMESPACE OBJECT: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/actions.js
    48 // NAMESPACE OBJECT: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/actions.js
    49 var actions_namespaceObject = {};
    49 var actions_namespaceObject = {};
    50 __webpack_require__.r(actions_namespaceObject);
    50 __webpack_require__.r(actions_namespaceObject);
    51 __webpack_require__.d(actions_namespaceObject, {
    51 __webpack_require__.d(actions_namespaceObject, {
    52   "registerShortcut": function() { return registerShortcut; },
    52   registerShortcut: () => (registerShortcut),
    53   "unregisterShortcut": function() { return unregisterShortcut; }
    53   unregisterShortcut: () => (unregisterShortcut)
    54 });
    54 });
    55 
    55 
    56 // NAMESPACE OBJECT: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/selectors.js
    56 // NAMESPACE OBJECT: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/selectors.js
    57 var selectors_namespaceObject = {};
    57 var selectors_namespaceObject = {};
    58 __webpack_require__.r(selectors_namespaceObject);
    58 __webpack_require__.r(selectors_namespaceObject);
    59 __webpack_require__.d(selectors_namespaceObject, {
    59 __webpack_require__.d(selectors_namespaceObject, {
    60   "getAllShortcutKeyCombinations": function() { return getAllShortcutKeyCombinations; },
    60   getAllShortcutKeyCombinations: () => (getAllShortcutKeyCombinations),
    61   "getAllShortcutRawKeyCombinations": function() { return getAllShortcutRawKeyCombinations; },
    61   getAllShortcutRawKeyCombinations: () => (getAllShortcutRawKeyCombinations),
    62   "getCategoryShortcuts": function() { return getCategoryShortcuts; },
    62   getCategoryShortcuts: () => (getCategoryShortcuts),
    63   "getShortcutAliases": function() { return getShortcutAliases; },
    63   getShortcutAliases: () => (getShortcutAliases),
    64   "getShortcutDescription": function() { return getShortcutDescription; },
    64   getShortcutDescription: () => (getShortcutDescription),
    65   "getShortcutKeyCombination": function() { return getShortcutKeyCombination; },
    65   getShortcutKeyCombination: () => (getShortcutKeyCombination),
    66   "getShortcutRepresentation": function() { return getShortcutRepresentation; }
    66   getShortcutRepresentation: () => (getShortcutRepresentation)
    67 });
    67 });
    68 
    68 
    69 ;// CONCATENATED MODULE: external ["wp","data"]
    69 ;// CONCATENATED MODULE: external ["wp","data"]
    70 var external_wp_data_namespaceObject = window["wp"]["data"];
    70 const external_wp_data_namespaceObject = window["wp"]["data"];
    71 ;// CONCATENATED MODULE: external "lodash"
       
    72 var external_lodash_namespaceObject = window["lodash"];
       
    73 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/reducer.js
    71 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/reducer.js
    74 /**
       
    75  * External dependencies
       
    76  */
       
    77 
       
    78 /**
    72 /**
    79  * Reducer returning the registered shortcuts
    73  * Reducer returning the registered shortcuts
    80  *
    74  *
    81  * @param {Object} state  Current state.
    75  * @param {Object} state  Current state.
    82  * @param {Object} action Dispatched action.
    76  * @param {Object} action Dispatched action.
    83  *
    77  *
    84  * @return {Object} Updated state.
    78  * @return {Object} Updated state.
    85  */
    79  */
    86 
    80 function reducer(state = {}, action) {
    87 function reducer() {
       
    88   let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
       
    89   let action = arguments.length > 1 ? arguments[1] : undefined;
       
    90 
       
    91   switch (action.type) {
    81   switch (action.type) {
    92     case 'REGISTER_SHORTCUT':
    82     case 'REGISTER_SHORTCUT':
    93       return { ...state,
    83       return {
       
    84         ...state,
    94         [action.name]: {
    85         [action.name]: {
    95           category: action.category,
    86           category: action.category,
    96           keyCombination: action.keyCombination,
    87           keyCombination: action.keyCombination,
    97           aliases: action.aliases,
    88           aliases: action.aliases,
    98           description: action.description
    89           description: action.description
    99         }
    90         }
   100       };
    91       };
   101 
       
   102     case 'UNREGISTER_SHORTCUT':
    92     case 'UNREGISTER_SHORTCUT':
   103       return (0,external_lodash_namespaceObject.omit)(state, action.name);
    93       const {
       
    94         [action.name]: actionName,
       
    95         ...remainingState
       
    96       } = state;
       
    97       return remainingState;
   104   }
    98   }
   105 
       
   106   return state;
    99   return state;
   107 }
   100 }
   108 
   101 /* harmony default export */ const store_reducer = (reducer);
   109 /* harmony default export */ var store_reducer = (reducer);
       
   110 
   102 
   111 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/actions.js
   103 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/actions.js
   112 /** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */
   104 /** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */
   113 
   105 
   114 /**
   106 /**
   135 /**
   127 /**
   136  * Returns an action object used to register a new keyboard shortcut.
   128  * Returns an action object used to register a new keyboard shortcut.
   137  *
   129  *
   138  * @param {WPShortcutConfig} config Shortcut config.
   130  * @param {WPShortcutConfig} config Shortcut config.
   139  *
   131  *
       
   132  * @example
       
   133  *
       
   134  *```js
       
   135  * import { useEffect } from 'react';
       
   136  * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
       
   137  * import { useSelect, useDispatch } from '@wordpress/data';
       
   138  * import { __ } from '@wordpress/i18n';
       
   139  *
       
   140  * const ExampleComponent = () => {
       
   141  *     const { registerShortcut } = useDispatch( keyboardShortcutsStore );
       
   142  *
       
   143  *     useEffect( () => {
       
   144  *         registerShortcut( {
       
   145  *             name: 'custom/my-custom-shortcut',
       
   146  *             category: 'my-category',
       
   147  *             description: __( 'My custom shortcut' ),
       
   148  *             keyCombination: {
       
   149  *                 modifier: 'primary',
       
   150  *                 character: 'j',
       
   151  *             },
       
   152  *         } );
       
   153  *     }, [] );
       
   154  *
       
   155  *     const shortcut = useSelect(
       
   156  *         ( select ) =>
       
   157  *             select( keyboardShortcutsStore ).getShortcutKeyCombination(
       
   158  *                 'custom/my-custom-shortcut'
       
   159  *             ),
       
   160  *         []
       
   161  *     );
       
   162  *
       
   163  *     return shortcut ? (
       
   164  *         <p>{ __( 'Shortcut is registered.' ) }</p>
       
   165  *     ) : (
       
   166  *         <p>{ __( 'Shortcut is not registered.' ) }</p>
       
   167  *     );
       
   168  * };
       
   169  *```
   140  * @return {Object} action.
   170  * @return {Object} action.
   141  */
   171  */
   142 function registerShortcut(_ref) {
   172 function registerShortcut({
   143   let {
   173   name,
   144     name,
   174   category,
   145     category,
   175   description,
   146     description,
   176   keyCombination,
   147     keyCombination,
   177   aliases
   148     aliases
   178 }) {
   149   } = _ref;
       
   150   return {
   179   return {
   151     type: 'REGISTER_SHORTCUT',
   180     type: 'REGISTER_SHORTCUT',
   152     name,
   181     name,
   153     category,
   182     category,
   154     keyCombination,
   183     keyCombination,
   155     aliases,
   184     aliases,
   156     description
   185     description
   157   };
   186   };
   158 }
   187 }
       
   188 
   159 /**
   189 /**
   160  * Returns an action object used to unregister a keyboard shortcut.
   190  * Returns an action object used to unregister a keyboard shortcut.
   161  *
   191  *
   162  * @param {string} name Shortcut name.
   192  * @param {string} name Shortcut name.
   163  *
   193  *
       
   194  * @example
       
   195  *
       
   196  *```js
       
   197  * import { useEffect } from 'react';
       
   198  * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
       
   199  * import { useSelect, useDispatch } from '@wordpress/data';
       
   200  * import { __ } from '@wordpress/i18n';
       
   201  *
       
   202  * const ExampleComponent = () => {
       
   203  *     const { unregisterShortcut } = useDispatch( keyboardShortcutsStore );
       
   204  *
       
   205  *     useEffect( () => {
       
   206  *         unregisterShortcut( 'core/editor/next-region' );
       
   207  *     }, [] );
       
   208  *
       
   209  *     const shortcut = useSelect(
       
   210  *         ( select ) =>
       
   211  *             select( keyboardShortcutsStore ).getShortcutKeyCombination(
       
   212  *                 'core/editor/next-region'
       
   213  *             ),
       
   214  *         []
       
   215  *     );
       
   216  *
       
   217  *     return shortcut ? (
       
   218  *         <p>{ __( 'Shortcut is not unregistered.' ) }</p>
       
   219  *     ) : (
       
   220  *         <p>{ __( 'Shortcut is unregistered.' ) }</p>
       
   221  *     );
       
   222  * };
       
   223  *```
   164  * @return {Object} action.
   224  * @return {Object} action.
   165  */
   225  */
   166 
       
   167 function unregisterShortcut(name) {
   226 function unregisterShortcut(name) {
   168   return {
   227   return {
   169     type: 'UNREGISTER_SHORTCUT',
   228     type: 'UNREGISTER_SHORTCUT',
   170     name
   229     name
   171   };
   230   };
   172 }
   231 }
   173 
   232 
   174 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
       
   175 
       
   176 
       
   177 var LEAF_KEY, hasWeakMap;
       
   178 
       
   179 /**
       
   180  * Arbitrary value used as key for referencing cache object in WeakMap tree.
       
   181  *
       
   182  * @type {Object}
       
   183  */
       
   184 LEAF_KEY = {};
       
   185 
       
   186 /**
       
   187  * Whether environment supports WeakMap.
       
   188  *
       
   189  * @type {boolean}
       
   190  */
       
   191 hasWeakMap = typeof WeakMap !== 'undefined';
       
   192 
       
   193 /**
       
   194  * Returns the first argument as the sole entry in an array.
       
   195  *
       
   196  * @param {*} value Value to return.
       
   197  *
       
   198  * @return {Array} Value returned as entry in array.
       
   199  */
       
   200 function arrayOf( value ) {
       
   201 	return [ value ];
       
   202 }
       
   203 
       
   204 /**
       
   205  * Returns true if the value passed is object-like, or false otherwise. A value
       
   206  * is object-like if it can support property assignment, e.g. object or array.
       
   207  *
       
   208  * @param {*} value Value to test.
       
   209  *
       
   210  * @return {boolean} Whether value is object-like.
       
   211  */
       
   212 function isObjectLike( value ) {
       
   213 	return !! value && 'object' === typeof value;
       
   214 }
       
   215 
       
   216 /**
       
   217  * Creates and returns a new cache object.
       
   218  *
       
   219  * @return {Object} Cache object.
       
   220  */
       
   221 function createCache() {
       
   222 	var cache = {
       
   223 		clear: function() {
       
   224 			cache.head = null;
       
   225 		},
       
   226 	};
       
   227 
       
   228 	return cache;
       
   229 }
       
   230 
       
   231 /**
       
   232  * Returns true if entries within the two arrays are strictly equal by
       
   233  * reference from a starting index.
       
   234  *
       
   235  * @param {Array}  a         First array.
       
   236  * @param {Array}  b         Second array.
       
   237  * @param {number} fromIndex Index from which to start comparison.
       
   238  *
       
   239  * @return {boolean} Whether arrays are shallowly equal.
       
   240  */
       
   241 function isShallowEqual( a, b, fromIndex ) {
       
   242 	var i;
       
   243 
       
   244 	if ( a.length !== b.length ) {
       
   245 		return false;
       
   246 	}
       
   247 
       
   248 	for ( i = fromIndex; i < a.length; i++ ) {
       
   249 		if ( a[ i ] !== b[ i ] ) {
       
   250 			return false;
       
   251 		}
       
   252 	}
       
   253 
       
   254 	return true;
       
   255 }
       
   256 
       
   257 /**
       
   258  * Returns a memoized selector function. The getDependants function argument is
       
   259  * called before the memoized selector and is expected to return an immutable
       
   260  * reference or array of references on which the selector depends for computing
       
   261  * its own return value. The memoize cache is preserved only as long as those
       
   262  * dependant references remain the same. If getDependants returns a different
       
   263  * reference(s), the cache is cleared and the selector value regenerated.
       
   264  *
       
   265  * @param {Function} selector      Selector function.
       
   266  * @param {Function} getDependants Dependant getter returning an immutable
       
   267  *                                 reference or array of reference used in
       
   268  *                                 cache bust consideration.
       
   269  *
       
   270  * @return {Function} Memoized selector.
       
   271  */
       
   272 /* harmony default export */ function rememo(selector, getDependants ) {
       
   273 	var rootCache, getCache;
       
   274 
       
   275 	// Use object source as dependant if getter not provided
       
   276 	if ( ! getDependants ) {
       
   277 		getDependants = arrayOf;
       
   278 	}
       
   279 
       
   280 	/**
       
   281 	 * Returns the root cache. If WeakMap is supported, this is assigned to the
       
   282 	 * root WeakMap cache set, otherwise it is a shared instance of the default
       
   283 	 * cache object.
       
   284 	 *
       
   285 	 * @return {(WeakMap|Object)} Root cache object.
       
   286 	 */
       
   287 	function getRootCache() {
       
   288 		return rootCache;
       
   289 	}
       
   290 
       
   291 	/**
       
   292 	 * Returns the cache for a given dependants array. When possible, a WeakMap
       
   293 	 * will be used to create a unique cache for each set of dependants. This
       
   294 	 * is feasible due to the nature of WeakMap in allowing garbage collection
       
   295 	 * to occur on entries where the key object is no longer referenced. Since
       
   296 	 * WeakMap requires the key to be an object, this is only possible when the
       
   297 	 * dependant is object-like. The root cache is created as a hierarchy where
       
   298 	 * each top-level key is the first entry in a dependants set, the value a
       
   299 	 * WeakMap where each key is the next dependant, and so on. This continues
       
   300 	 * so long as the dependants are object-like. If no dependants are object-
       
   301 	 * like, then the cache is shared across all invocations.
       
   302 	 *
       
   303 	 * @see isObjectLike
       
   304 	 *
       
   305 	 * @param {Array} dependants Selector dependants.
       
   306 	 *
       
   307 	 * @return {Object} Cache object.
       
   308 	 */
       
   309 	function getWeakMapCache( dependants ) {
       
   310 		var caches = rootCache,
       
   311 			isUniqueByDependants = true,
       
   312 			i, dependant, map, cache;
       
   313 
       
   314 		for ( i = 0; i < dependants.length; i++ ) {
       
   315 			dependant = dependants[ i ];
       
   316 
       
   317 			// Can only compose WeakMap from object-like key.
       
   318 			if ( ! isObjectLike( dependant ) ) {
       
   319 				isUniqueByDependants = false;
       
   320 				break;
       
   321 			}
       
   322 
       
   323 			// Does current segment of cache already have a WeakMap?
       
   324 			if ( caches.has( dependant ) ) {
       
   325 				// Traverse into nested WeakMap.
       
   326 				caches = caches.get( dependant );
       
   327 			} else {
       
   328 				// Create, set, and traverse into a new one.
       
   329 				map = new WeakMap();
       
   330 				caches.set( dependant, map );
       
   331 				caches = map;
       
   332 			}
       
   333 		}
       
   334 
       
   335 		// We use an arbitrary (but consistent) object as key for the last item
       
   336 		// in the WeakMap to serve as our running cache.
       
   337 		if ( ! caches.has( LEAF_KEY ) ) {
       
   338 			cache = createCache();
       
   339 			cache.isUniqueByDependants = isUniqueByDependants;
       
   340 			caches.set( LEAF_KEY, cache );
       
   341 		}
       
   342 
       
   343 		return caches.get( LEAF_KEY );
       
   344 	}
       
   345 
       
   346 	// Assign cache handler by availability of WeakMap
       
   347 	getCache = hasWeakMap ? getWeakMapCache : getRootCache;
       
   348 
       
   349 	/**
       
   350 	 * Resets root memoization cache.
       
   351 	 */
       
   352 	function clear() {
       
   353 		rootCache = hasWeakMap ? new WeakMap() : createCache();
       
   354 	}
       
   355 
       
   356 	// eslint-disable-next-line jsdoc/check-param-names
       
   357 	/**
       
   358 	 * The augmented selector call, considering first whether dependants have
       
   359 	 * changed before passing it to underlying memoize function.
       
   360 	 *
       
   361 	 * @param {Object} source    Source object for derivation.
       
   362 	 * @param {...*}   extraArgs Additional arguments to pass to selector.
       
   363 	 *
       
   364 	 * @return {*} Selector result.
       
   365 	 */
       
   366 	function callSelector( /* source, ...extraArgs */ ) {
       
   367 		var len = arguments.length,
       
   368 			cache, node, i, args, dependants;
       
   369 
       
   370 		// Create copy of arguments (avoid leaking deoptimization).
       
   371 		args = new Array( len );
       
   372 		for ( i = 0; i < len; i++ ) {
       
   373 			args[ i ] = arguments[ i ];
       
   374 		}
       
   375 
       
   376 		dependants = getDependants.apply( null, args );
       
   377 		cache = getCache( dependants );
       
   378 
       
   379 		// If not guaranteed uniqueness by dependants (primitive type or lack
       
   380 		// of WeakMap support), shallow compare against last dependants and, if
       
   381 		// references have changed, destroy cache to recalculate result.
       
   382 		if ( ! cache.isUniqueByDependants ) {
       
   383 			if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
       
   384 				cache.clear();
       
   385 			}
       
   386 
       
   387 			cache.lastDependants = dependants;
       
   388 		}
       
   389 
       
   390 		node = cache.head;
       
   391 		while ( node ) {
       
   392 			// Check whether node arguments match arguments
       
   393 			if ( ! isShallowEqual( node.args, args, 1 ) ) {
       
   394 				node = node.next;
       
   395 				continue;
       
   396 			}
       
   397 
       
   398 			// At this point we can assume we've found a match
       
   399 
       
   400 			// Surface matched node to head if not already
       
   401 			if ( node !== cache.head ) {
       
   402 				// Adjust siblings to point to each other.
       
   403 				node.prev.next = node.next;
       
   404 				if ( node.next ) {
       
   405 					node.next.prev = node.prev;
       
   406 				}
       
   407 
       
   408 				node.next = cache.head;
       
   409 				node.prev = null;
       
   410 				cache.head.prev = node;
       
   411 				cache.head = node;
       
   412 			}
       
   413 
       
   414 			// Return immediately
       
   415 			return node.val;
       
   416 		}
       
   417 
       
   418 		// No cached value found. Continue to insertion phase:
       
   419 
       
   420 		node = {
       
   421 			// Generate the result from original function
       
   422 			val: selector.apply( null, args ),
       
   423 		};
       
   424 
       
   425 		// Avoid including the source object in the cache.
       
   426 		args[ 0 ] = null;
       
   427 		node.args = args;
       
   428 
       
   429 		// Don't need to check whether node is already head, since it would
       
   430 		// have been returned above already if it was
       
   431 
       
   432 		// Shift existing head down list
       
   433 		if ( cache.head ) {
       
   434 			cache.head.prev = node;
       
   435 			node.next = cache.head;
       
   436 		}
       
   437 
       
   438 		cache.head = node;
       
   439 
       
   440 		return node.val;
       
   441 	}
       
   442 
       
   443 	callSelector.getDependants = getDependants;
       
   444 	callSelector.clear = clear;
       
   445 	clear();
       
   446 
       
   447 	return callSelector;
       
   448 }
       
   449 
       
   450 ;// CONCATENATED MODULE: external ["wp","keycodes"]
   233 ;// CONCATENATED MODULE: external ["wp","keycodes"]
   451 var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
   234 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
   452 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/selectors.js
   235 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/selectors.js
   453 /**
   236 /**
   454  * External dependencies
       
   455  */
       
   456 
       
   457 
       
   458 /**
       
   459  * WordPress dependencies
   237  * WordPress dependencies
   460  */
   238  */
       
   239 
   461 
   240 
   462 
   241 
   463 /** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */
   242 /** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */
   464 
   243 
   465 /** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */
   244 /** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */
   468  * Shared reference to an empty array for cases where it is important to avoid
   247  * Shared reference to an empty array for cases where it is important to avoid
   469  * returning a new array reference on every invocation.
   248  * returning a new array reference on every invocation.
   470  *
   249  *
   471  * @type {Array<any>}
   250  * @type {Array<any>}
   472  */
   251  */
   473 
       
   474 const EMPTY_ARRAY = [];
   252 const EMPTY_ARRAY = [];
       
   253 
   475 /**
   254 /**
   476  * Shortcut formatting methods.
   255  * Shortcut formatting methods.
   477  *
   256  *
   478  * @property {WPKeycodeHandlerByModifier} display     Display formatting.
   257  * @property {WPKeycodeHandlerByModifier} display     Display formatting.
   479  * @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.
   258  * @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.
   480  * @property {WPKeycodeHandlerByModifier} ariaLabel   ARIA label formatting.
   259  * @property {WPKeycodeHandlerByModifier} ariaLabel   ARIA label formatting.
   481  */
   260  */
   482 
       
   483 const FORMATTING_METHODS = {
   261 const FORMATTING_METHODS = {
   484   display: external_wp_keycodes_namespaceObject.displayShortcut,
   262   display: external_wp_keycodes_namespaceObject.displayShortcut,
   485   raw: external_wp_keycodes_namespaceObject.rawShortcut,
   263   raw: external_wp_keycodes_namespaceObject.rawShortcut,
   486   ariaLabel: external_wp_keycodes_namespaceObject.shortcutAriaLabel
   264   ariaLabel: external_wp_keycodes_namespaceObject.shortcutAriaLabel
   487 };
   265 };
       
   266 
   488 /**
   267 /**
   489  * Returns a string representing the key combination.
   268  * Returns a string representing the key combination.
   490  *
   269  *
   491  * @param {?WPShortcutKeyCombination} shortcut       Key combination.
   270  * @param {?WPShortcutKeyCombination} shortcut       Key combination.
   492  * @param {keyof FORMATTING_METHODS}  representation Type of representation
   271  * @param {keyof FORMATTING_METHODS}  representation Type of representation
   493  *                                                   (display, raw, ariaLabel).
   272  *                                                   (display, raw, ariaLabel).
   494  *
   273  *
   495  * @return {string?} Shortcut representation.
   274  * @return {string?} Shortcut representation.
   496  */
   275  */
   497 
       
   498 function getKeyCombinationRepresentation(shortcut, representation) {
   276 function getKeyCombinationRepresentation(shortcut, representation) {
   499   if (!shortcut) {
   277   if (!shortcut) {
   500     return null;
   278     return null;
   501   }
   279   }
   502 
       
   503   return shortcut.modifier ? FORMATTING_METHODS[representation][shortcut.modifier](shortcut.character) : shortcut.character;
   280   return shortcut.modifier ? FORMATTING_METHODS[representation][shortcut.modifier](shortcut.character) : shortcut.character;
   504 }
   281 }
       
   282 
   505 /**
   283 /**
   506  * Returns the main key combination for a given shortcut name.
   284  * Returns the main key combination for a given shortcut name.
   507  *
   285  *
   508  * @param {Object} state Global state.
   286  * @param {Object} state Global state.
   509  * @param {string} name  Shortcut name.
   287  * @param {string} name  Shortcut name.
   510  *
   288  *
       
   289  * @example
       
   290  *
       
   291  *```js
       
   292  * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
       
   293  * import { useSelect } from '@wordpress/data';
       
   294  * import { createInterpolateElement } from '@wordpress/element';
       
   295  * import { sprintf } from '@wordpress/i18n';
       
   296  * const ExampleComponent = () => {
       
   297  *     const {character, modifier} = useSelect(
       
   298  *         ( select ) =>
       
   299  *             select( keyboardShortcutsStore ).getShortcutKeyCombination(
       
   300  *                 'core/editor/next-region'
       
   301  *             ),
       
   302  *         []
       
   303  *     );
       
   304  *
       
   305  *     return (
       
   306  *         <div>
       
   307  *             { createInterpolateElement(
       
   308  *                 sprintf(
       
   309  *                     'Character: <code>%s</code> / Modifier: <code>%s</code>',
       
   310  *                     character,
       
   311  *                     modifier
       
   312  *                 ),
       
   313  *                 {
       
   314  *                     code: <code />,
       
   315  *                 }
       
   316  *             ) }
       
   317  *         </div>
       
   318  *     );
       
   319  * };
       
   320  *```
       
   321  *
   511  * @return {WPShortcutKeyCombination?} Key combination.
   322  * @return {WPShortcutKeyCombination?} Key combination.
   512  */
   323  */
   513 
       
   514 
       
   515 function getShortcutKeyCombination(state, name) {
   324 function getShortcutKeyCombination(state, name) {
   516   return state[name] ? state[name].keyCombination : null;
   325   return state[name] ? state[name].keyCombination : null;
   517 }
   326 }
       
   327 
   518 /**
   328 /**
   519  * Returns a string representing the main key combination for a given shortcut name.
   329  * Returns a string representing the main key combination for a given shortcut name.
   520  *
   330  *
   521  * @param {Object}                   state          Global state.
   331  * @param {Object}                   state          Global state.
   522  * @param {string}                   name           Shortcut name.
   332  * @param {string}                   name           Shortcut name.
   523  * @param {keyof FORMATTING_METHODS} representation Type of representation
   333  * @param {keyof FORMATTING_METHODS} representation Type of representation
   524  *                                                  (display, raw, ariaLabel).
   334  *                                                  (display, raw, ariaLabel).
       
   335  * @example
       
   336  *
       
   337  *```js
       
   338  * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
       
   339  * import { useSelect } from '@wordpress/data';
       
   340  * import { sprintf } from '@wordpress/i18n';
       
   341  *
       
   342  * const ExampleComponent = () => {
       
   343  *     const {display, raw, ariaLabel} = useSelect(
       
   344  *         ( select ) =>{
       
   345  *             return {
       
   346  *                 display: select( keyboardShortcutsStore ).getShortcutRepresentation('core/editor/next-region' ),
       
   347  *                 raw: select( keyboardShortcutsStore ).getShortcutRepresentation('core/editor/next-region','raw' ),
       
   348  *                 ariaLabel: select( keyboardShortcutsStore ).getShortcutRepresentation('core/editor/next-region', 'ariaLabel')
       
   349  *             }
       
   350  *         },
       
   351  *         []
       
   352  *     );
       
   353  *
       
   354  *     return (
       
   355  *         <ul>
       
   356  *             <li>{ sprintf( 'display string: %s', display ) }</li>
       
   357  *             <li>{ sprintf( 'raw string: %s', raw ) }</li>
       
   358  *             <li>{ sprintf( 'ariaLabel string: %s', ariaLabel ) }</li>
       
   359  *         </ul>
       
   360  *     );
       
   361  * };
       
   362  *```
   525  *
   363  *
   526  * @return {string?} Shortcut representation.
   364  * @return {string?} Shortcut representation.
   527  */
   365  */
   528 
   366 function getShortcutRepresentation(state, name, representation = 'display') {
   529 function getShortcutRepresentation(state, name) {
       
   530   let representation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'display';
       
   531   const shortcut = getShortcutKeyCombination(state, name);
   367   const shortcut = getShortcutKeyCombination(state, name);
   532   return getKeyCombinationRepresentation(shortcut, representation);
   368   return getKeyCombinationRepresentation(shortcut, representation);
   533 }
   369 }
       
   370 
   534 /**
   371 /**
   535  * Returns the shortcut description given its name.
   372  * Returns the shortcut description given its name.
   536  *
   373  *
   537  * @param {Object} state Global state.
   374  * @param {Object} state Global state.
   538  * @param {string} name  Shortcut name.
   375  * @param {string} name  Shortcut name.
   539  *
   376  *
       
   377  * @example
       
   378  *
       
   379  *```js
       
   380  * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
       
   381  * import { useSelect } from '@wordpress/data';
       
   382  * import { __ } from '@wordpress/i18n';
       
   383  * const ExampleComponent = () => {
       
   384  *     const shortcutDescription = useSelect(
       
   385  *         ( select ) =>
       
   386  *             select( keyboardShortcutsStore ).getShortcutDescription( 'core/editor/next-region' ),
       
   387  *         []
       
   388  *     );
       
   389  *
       
   390  *     return shortcutDescription ? (
       
   391  *         <div>{ shortcutDescription }</div>
       
   392  *     ) : (
       
   393  *         <div>{ __( 'No description.' ) }</div>
       
   394  *     );
       
   395  * };
       
   396  *```
   540  * @return {string?} Shortcut description.
   397  * @return {string?} Shortcut description.
   541  */
   398  */
   542 
       
   543 function getShortcutDescription(state, name) {
   399 function getShortcutDescription(state, name) {
   544   return state[name] ? state[name].description : null;
   400   return state[name] ? state[name].description : null;
   545 }
   401 }
       
   402 
   546 /**
   403 /**
   547  * Returns the aliases for a given shortcut name.
   404  * Returns the aliases for a given shortcut name.
   548  *
   405  *
   549  * @param {Object} state Global state.
   406  * @param {Object} state Global state.
   550  * @param {string} name  Shortcut name.
   407  * @param {string} name  Shortcut name.
       
   408  * @example
       
   409  *
       
   410  *```js
       
   411  * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
       
   412  * import { useSelect } from '@wordpress/data';
       
   413  * import { createInterpolateElement } from '@wordpress/element';
       
   414  * import { sprintf } from '@wordpress/i18n';
       
   415  * const ExampleComponent = () => {
       
   416  *     const shortcutAliases = useSelect(
       
   417  *         ( select ) =>
       
   418  *             select( keyboardShortcutsStore ).getShortcutAliases(
       
   419  *                 'core/editor/next-region'
       
   420  *             ),
       
   421  *         []
       
   422  *     );
       
   423  *
       
   424  *     return (
       
   425  *         shortcutAliases.length > 0 && (
       
   426  *             <ul>
       
   427  *                 { shortcutAliases.map( ( { character, modifier }, index ) => (
       
   428  *                     <li key={ index }>
       
   429  *                         { createInterpolateElement(
       
   430  *                             sprintf(
       
   431  *                                 'Character: <code>%s</code> / Modifier: <code>%s</code>',
       
   432  *                                 character,
       
   433  *                                 modifier
       
   434  *                             ),
       
   435  *                             {
       
   436  *                                 code: <code />,
       
   437  *                             }
       
   438  *                         ) }
       
   439  *                     </li>
       
   440  *                 ) ) }
       
   441  *             </ul>
       
   442  *         )
       
   443  *     );
       
   444  * };
       
   445  *```
   551  *
   446  *
   552  * @return {WPShortcutKeyCombination[]} Key combinations.
   447  * @return {WPShortcutKeyCombination[]} Key combinations.
   553  */
   448  */
   554 
       
   555 function getShortcutAliases(state, name) {
   449 function getShortcutAliases(state, name) {
   556   return state[name] && state[name].aliases ? state[name].aliases : EMPTY_ARRAY;
   450   return state[name] && state[name].aliases ? state[name].aliases : EMPTY_ARRAY;
   557 }
   451 }
   558 const getAllShortcutKeyCombinations = rememo((state, name) => {
   452 
   559   return (0,external_lodash_namespaceObject.compact)([getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)]);
   453 /**
   560 }, (state, name) => [state[name]]);
   454  * Returns the shortcuts that include aliases for a given shortcut name.
   561 /**
       
   562  * Returns the raw representation of all the keyboard combinations of a given shortcut name.
       
   563  *
   455  *
   564  * @param {Object} state Global state.
   456  * @param {Object} state Global state.
   565  * @param {string} name  Shortcut name.
   457  * @param {string} name  Shortcut name.
       
   458  * @example
       
   459  *
       
   460  *```js
       
   461  * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
       
   462  * import { useSelect } from '@wordpress/data';
       
   463  * import { createInterpolateElement } from '@wordpress/element';
       
   464  * import { sprintf } from '@wordpress/i18n';
       
   465  *
       
   466  * const ExampleComponent = () => {
       
   467  *     const allShortcutKeyCombinations = useSelect(
       
   468  *         ( select ) =>
       
   469  *             select( keyboardShortcutsStore ).getAllShortcutKeyCombinations(
       
   470  *                 'core/editor/next-region'
       
   471  *             ),
       
   472  *         []
       
   473  *     );
       
   474  *
       
   475  *     return (
       
   476  *         allShortcutKeyCombinations.length > 0 && (
       
   477  *             <ul>
       
   478  *                 { allShortcutKeyCombinations.map(
       
   479  *                     ( { character, modifier }, index ) => (
       
   480  *                         <li key={ index }>
       
   481  *                             { createInterpolateElement(
       
   482  *                                 sprintf(
       
   483  *                                     'Character: <code>%s</code> / Modifier: <code>%s</code>',
       
   484  *                                     character,
       
   485  *                                     modifier
       
   486  *                                 ),
       
   487  *                                 {
       
   488  *                                     code: <code />,
       
   489  *                                 }
       
   490  *                             ) }
       
   491  *                         </li>
       
   492  *                     )
       
   493  *                 ) }
       
   494  *             </ul>
       
   495  *         )
       
   496  *     );
       
   497  * };
       
   498  *```
       
   499  *
       
   500  * @return {WPShortcutKeyCombination[]} Key combinations.
       
   501  */
       
   502 const getAllShortcutKeyCombinations = (0,external_wp_data_namespaceObject.createSelector)((state, name) => {
       
   503   return [getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)].filter(Boolean);
       
   504 }, (state, name) => [state[name]]);
       
   505 
       
   506 /**
       
   507  * Returns the raw representation of all the keyboard combinations of a given shortcut name.
       
   508  *
       
   509  * @param {Object} state Global state.
       
   510  * @param {string} name  Shortcut name.
       
   511  *
       
   512  * @example
       
   513  *
       
   514  *```js
       
   515  * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
       
   516  * import { useSelect } from '@wordpress/data';
       
   517  * import { createInterpolateElement } from '@wordpress/element';
       
   518  * import { sprintf } from '@wordpress/i18n';
       
   519  *
       
   520  * const ExampleComponent = () => {
       
   521  *     const allShortcutRawKeyCombinations = useSelect(
       
   522  *         ( select ) =>
       
   523  *             select( keyboardShortcutsStore ).getAllShortcutRawKeyCombinations(
       
   524  *                 'core/editor/next-region'
       
   525  *             ),
       
   526  *         []
       
   527  *     );
       
   528  *
       
   529  *     return (
       
   530  *         allShortcutRawKeyCombinations.length > 0 && (
       
   531  *             <ul>
       
   532  *                 { allShortcutRawKeyCombinations.map(
       
   533  *                     ( shortcutRawKeyCombination, index ) => (
       
   534  *                         <li key={ index }>
       
   535  *                             { createInterpolateElement(
       
   536  *                                 sprintf(
       
   537  *                                     ' <code>%s</code>',
       
   538  *                                     shortcutRawKeyCombination
       
   539  *                                 ),
       
   540  *                                 {
       
   541  *                                     code: <code />,
       
   542  *                                 }
       
   543  *                             ) }
       
   544  *                         </li>
       
   545  *                     )
       
   546  *                 ) }
       
   547  *             </ul>
       
   548  *         )
       
   549  *     );
       
   550  * };
       
   551  *```
   566  *
   552  *
   567  * @return {string[]} Shortcuts.
   553  * @return {string[]} Shortcuts.
   568  */
   554  */
   569 
   555 const getAllShortcutRawKeyCombinations = (0,external_wp_data_namespaceObject.createSelector)((state, name) => {
   570 const getAllShortcutRawKeyCombinations = rememo((state, name) => {
       
   571   return getAllShortcutKeyCombinations(state, name).map(combination => getKeyCombinationRepresentation(combination, 'raw'));
   556   return getAllShortcutKeyCombinations(state, name).map(combination => getKeyCombinationRepresentation(combination, 'raw'));
   572 }, (state, name) => [state[name]]);
   557 }, (state, name) => [state[name]]);
       
   558 
   573 /**
   559 /**
   574  * Returns the shortcut names list for a given category name.
   560  * Returns the shortcut names list for a given category name.
   575  *
   561  *
   576  * @param {Object} state Global state.
   562  * @param {Object} state Global state.
   577  * @param {string} name  Category name.
   563  * @param {string} name  Category name.
   578  *
   564  * @example
       
   565  *
       
   566  *```js
       
   567  * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
       
   568  * import { useSelect } from '@wordpress/data';
       
   569  *
       
   570  * const ExampleComponent = () => {
       
   571  *     const categoryShortcuts = useSelect(
       
   572  *         ( select ) =>
       
   573  *             select( keyboardShortcutsStore ).getCategoryShortcuts(
       
   574  *                 'block'
       
   575  *             ),
       
   576  *         []
       
   577  *     );
       
   578  *
       
   579  *     return (
       
   580  *         categoryShortcuts.length > 0 && (
       
   581  *             <ul>
       
   582  *                 { categoryShortcuts.map( ( categoryShortcut ) => (
       
   583  *                     <li key={ categoryShortcut }>{ categoryShortcut }</li>
       
   584  *                 ) ) }
       
   585  *             </ul>
       
   586  *         )
       
   587  *     );
       
   588  * };
       
   589  *```
   579  * @return {string[]} Shortcut names.
   590  * @return {string[]} Shortcut names.
   580  */
   591  */
   581 
   592 const getCategoryShortcuts = (0,external_wp_data_namespaceObject.createSelector)((state, categoryName) => {
   582 const getCategoryShortcuts = rememo((state, categoryName) => {
   593   return Object.entries(state).filter(([, shortcut]) => shortcut.category === categoryName).map(([name]) => name);
   583   return Object.entries(state).filter(_ref => {
       
   584     let [, shortcut] = _ref;
       
   585     return shortcut.category === categoryName;
       
   586   }).map(_ref2 => {
       
   587     let [name] = _ref2;
       
   588     return name;
       
   589   });
       
   590 }, state => [state]);
   594 }, state => [state]);
   591 
   595 
   592 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/index.js
   596 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/index.js
   593 /**
   597 /**
   594  * WordPress dependencies
   598  * WordPress dependencies
   595  */
   599  */
   596 
   600 
       
   601 
   597 /**
   602 /**
   598  * Internal dependencies
   603  * Internal dependencies
   599  */
   604  */
   600 
   605 
   601 
   606 
   602 
   607 
   603 
       
   604 const STORE_NAME = 'core/keyboard-shortcuts';
   608 const STORE_NAME = 'core/keyboard-shortcuts';
       
   609 
   605 /**
   610 /**
   606  * Store definition for the keyboard shortcuts namespace.
   611  * Store definition for the keyboard shortcuts namespace.
   607  *
   612  *
   608  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
   613  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
   609  *
   614  *
   610  * @type {Object}
   615  * @type {Object}
   611  */
   616  */
   612 
       
   613 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
   617 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
   614   reducer: store_reducer,
   618   reducer: store_reducer,
   615   actions: actions_namespaceObject,
   619   actions: actions_namespaceObject,
   616   selectors: selectors_namespaceObject
   620   selectors: selectors_namespaceObject
   617 });
   621 });
   618 (0,external_wp_data_namespaceObject.register)(store);
   622 (0,external_wp_data_namespaceObject.register)(store);
   619 
   623 
   620 ;// CONCATENATED MODULE: external ["wp","element"]
   624 ;// CONCATENATED MODULE: external ["wp","element"]
   621 var external_wp_element_namespaceObject = window["wp"]["element"];
   625 const external_wp_element_namespaceObject = window["wp"]["element"];
   622 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/hooks/use-shortcut-event-match.js
   626 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/hooks/use-shortcut-event-match.js
   623 /**
   627 /**
   624  * WordPress dependencies
   628  * WordPress dependencies
   625  */
   629  */
   626 
   630 
   627 
   631 
       
   632 
   628 /**
   633 /**
   629  * Internal dependencies
   634  * Internal dependencies
   630  */
   635  */
   631 
   636 
   632 
   637 
   633 /**
   638 /**
   634  * Returns a function to check if a keyboard event matches a shortcut name.
   639  * Returns a function to check if a keyboard event matches a shortcut name.
   635  *
   640  *
   636  * @return {Function} A function to to check if a keyboard event matches a
   641  * @return {Function} A function to check if a keyboard event matches a
   637  *                    predefined shortcut combination.
   642  *                    predefined shortcut combination.
   638  */
   643  */
   639 
       
   640 function useShortcutEventMatch() {
   644 function useShortcutEventMatch() {
   641   const {
   645   const {
   642     getAllShortcutKeyCombinations
   646     getAllShortcutKeyCombinations
   643   } = (0,external_wp_data_namespaceObject.useSelect)(store);
   647   } = (0,external_wp_data_namespaceObject.useSelect)(store);
       
   648 
   644   /**
   649   /**
   645    * A function to check if a keyboard event matches a predefined shortcut
   650    * A function to check if a keyboard event matches a predefined shortcut
   646    * combination.
   651    * combination.
   647    *
   652    *
   648    * @param {string}        name  Shortcut name.
   653    * @param {string}        name  Shortcut name.
   649    * @param {KeyboardEvent} event Event to check.
   654    * @param {KeyboardEvent} event Event to check.
   650    *
   655    *
   651    * @return {boolean} True if the event matches any shortcuts, false if not.
   656    * @return {boolean} True if the event matches any shortcuts, false if not.
   652    */
   657    */
   653 
       
   654   function isMatch(name, event) {
   658   function isMatch(name, event) {
   655     return getAllShortcutKeyCombinations(name).some(_ref => {
   659     return getAllShortcutKeyCombinations(name).some(({
   656       let {
   660       modifier,
   657         modifier,
   661       character
   658         character
   662     }) => {
   659       } = _ref;
       
   660       return external_wp_keycodes_namespaceObject.isKeyboardEvent[modifier](event, character);
   663       return external_wp_keycodes_namespaceObject.isKeyboardEvent[modifier](event, character);
   661     });
   664     });
   662   }
   665   }
   663 
       
   664   return isMatch;
   666   return isMatch;
   665 }
   667 }
   666 
   668 
   667 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/context.js
   669 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/context.js
   668 /**
   670 /**
   669  * WordPress dependencies
   671  * WordPress dependencies
   670  */
   672  */
   671 
   673 
   672 const context = (0,external_wp_element_namespaceObject.createContext)();
   674 const globalShortcuts = new Set();
       
   675 const globalListener = event => {
       
   676   for (const keyboardShortcut of globalShortcuts) {
       
   677     keyboardShortcut(event);
       
   678   }
       
   679 };
       
   680 const context = (0,external_wp_element_namespaceObject.createContext)({
       
   681   add: shortcut => {
       
   682     if (globalShortcuts.size === 0) {
       
   683       document.addEventListener('keydown', globalListener);
       
   684     }
       
   685     globalShortcuts.add(shortcut);
       
   686   },
       
   687   delete: shortcut => {
       
   688     globalShortcuts.delete(shortcut);
       
   689     if (globalShortcuts.size === 0) {
       
   690       document.removeEventListener('keydown', globalListener);
       
   691     }
       
   692   }
       
   693 });
   673 
   694 
   674 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/hooks/use-shortcut.js
   695 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/hooks/use-shortcut.js
   675 /**
   696 /**
   676  * WordPress dependencies
   697  * WordPress dependencies
   677  */
   698  */
       
   699 
   678 
   700 
   679 /**
   701 /**
   680  * Internal dependencies
   702  * Internal dependencies
   681  */
   703  */
   682 
   704 
   688  * @param {string}   name               Shortcut name.
   710  * @param {string}   name               Shortcut name.
   689  * @param {Function} callback           Shortcut callback.
   711  * @param {Function} callback           Shortcut callback.
   690  * @param {Object}   options            Shortcut options.
   712  * @param {Object}   options            Shortcut options.
   691  * @param {boolean}  options.isDisabled Whether to disable to shortut.
   713  * @param {boolean}  options.isDisabled Whether to disable to shortut.
   692  */
   714  */
   693 
   715 function useShortcut(name, callback, {
   694 function useShortcut(name, callback) {
   716   isDisabled = false
   695   let {
   717 } = {}) {
   696     isDisabled
       
   697   } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
       
   698   const shortcuts = (0,external_wp_element_namespaceObject.useContext)(context);
   718   const shortcuts = (0,external_wp_element_namespaceObject.useContext)(context);
   699   const isMatch = useShortcutEventMatch();
   719   const isMatch = useShortcutEventMatch();
   700   const callbackRef = (0,external_wp_element_namespaceObject.useRef)();
   720   const callbackRef = (0,external_wp_element_namespaceObject.useRef)();
   701   callbackRef.current = callback;
   721   (0,external_wp_element_namespaceObject.useEffect)(() => {
       
   722     callbackRef.current = callback;
       
   723   }, [callback]);
   702   (0,external_wp_element_namespaceObject.useEffect)(() => {
   724   (0,external_wp_element_namespaceObject.useEffect)(() => {
   703     if (isDisabled) {
   725     if (isDisabled) {
   704       return;
   726       return;
   705     }
   727     }
   706 
       
   707     function _callback(event) {
   728     function _callback(event) {
   708       if (isMatch(name, event)) {
   729       if (isMatch(name, event)) {
   709         callbackRef.current(event);
   730         callbackRef.current(event);
   710       }
   731       }
   711     }
   732     }
   712 
   733     shortcuts.add(_callback);
   713     shortcuts.current.add(_callback);
       
   714     return () => {
   734     return () => {
   715       shortcuts.current.delete(_callback);
   735       shortcuts.delete(_callback);
   716     };
   736     };
   717   }, [name, isDisabled]);
   737   }, [name, isDisabled, shortcuts]);
   718 }
   738 }
   719 
   739 
   720 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
   740 ;// CONCATENATED MODULE: external "ReactJSXRuntime"
   721 function _extends() {
   741 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
   722   _extends = Object.assign ? Object.assign.bind() : function (target) {
       
   723     for (var i = 1; i < arguments.length; i++) {
       
   724       var source = arguments[i];
       
   725 
       
   726       for (var key in source) {
       
   727         if (Object.prototype.hasOwnProperty.call(source, key)) {
       
   728           target[key] = source[key];
       
   729         }
       
   730       }
       
   731     }
       
   732 
       
   733     return target;
       
   734   };
       
   735   return _extends.apply(this, arguments);
       
   736 }
       
   737 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/components/shortcut-provider.js
   742 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/components/shortcut-provider.js
   738 
       
   739 
       
   740 
       
   741 /**
   743 /**
   742  * WordPress dependencies
   744  * WordPress dependencies
   743  */
   745  */
       
   746 
   744 
   747 
   745 /**
   748 /**
   746  * Internal dependencies
   749  * Internal dependencies
   747  */
   750  */
   748 
   751 
   749 
   752 
   750 const {
   753 const {
   751   Provider
   754   Provider
   752 } = context;
   755 } = context;
       
   756 
   753 /**
   757 /**
   754  * Handles callbacks added to context by `useShortcut`.
   758  * Handles callbacks added to context by `useShortcut`.
       
   759  * Adding a provider allows to register contextual shortcuts
       
   760  * that are only active when a certain part of the UI is focused.
   755  *
   761  *
   756  * @param {Object} props Props to pass to `div`.
   762  * @param {Object} props Props to pass to `div`.
   757  *
   763  *
   758  * @return {import('@wordpress/element').WPElement} Component.
   764  * @return {Element} Component.
   759  */
   765  */
   760 
       
   761 function ShortcutProvider(props) {
   766 function ShortcutProvider(props) {
   762   const keyboardShortcuts = (0,external_wp_element_namespaceObject.useRef)(new Set());
   767   const [keyboardShortcuts] = (0,external_wp_element_namespaceObject.useState)(() => new Set());
   763 
       
   764   function onKeyDown(event) {
   768   function onKeyDown(event) {
   765     if (props.onKeyDown) props.onKeyDown(event);
   769     if (props.onKeyDown) {
   766 
   770       props.onKeyDown(event);
   767     for (const keyboardShortcut of keyboardShortcuts.current) {
   771     }
       
   772     for (const keyboardShortcut of keyboardShortcuts) {
   768       keyboardShortcut(event);
   773       keyboardShortcut(event);
   769     }
   774     }
   770   }
   775   }
       
   776 
   771   /* eslint-disable jsx-a11y/no-static-element-interactions */
   777   /* eslint-disable jsx-a11y/no-static-element-interactions */
   772 
   778   return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Provider, {
   773 
   779     value: keyboardShortcuts,
   774   return (0,external_wp_element_namespaceObject.createElement)(Provider, {
   780     children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
   775     value: keyboardShortcuts
   781       ...props,
   776   }, (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, props, {
   782       onKeyDown: onKeyDown
   777     onKeyDown: onKeyDown
   783     })
   778   })));
   784   });
   779   /* eslint-enable jsx-a11y/no-static-element-interactions */
   785   /* eslint-enable jsx-a11y/no-static-element-interactions */
   780 }
   786 }
   781 
   787 
   782 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/index.js
   788 ;// CONCATENATED MODULE: ./node_modules/@wordpress/keyboard-shortcuts/build-module/index.js
   783 
   789