Sin descripción

nux.js 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. this["wp"] = this["wp"] || {}; this["wp"]["nux"] =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = "51Wn");
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ "1ZqX":
  90. /***/ (function(module, exports) {
  91. (function() { module.exports = window["wp"]["data"]; }());
  92. /***/ }),
  93. /***/ "51Wn":
  94. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95. "use strict";
  96. // ESM COMPAT FLAG
  97. __webpack_require__.r(__webpack_exports__);
  98. // EXPORTS
  99. __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
  100. __webpack_require__.d(__webpack_exports__, "DotTip", function() { return /* reexport */ dot_tip; });
  101. // NAMESPACE OBJECT: ./node_modules/@wordpress/nux/build-module/store/actions.js
  102. var actions_namespaceObject = {};
  103. __webpack_require__.r(actions_namespaceObject);
  104. __webpack_require__.d(actions_namespaceObject, "triggerGuide", function() { return triggerGuide; });
  105. __webpack_require__.d(actions_namespaceObject, "dismissTip", function() { return dismissTip; });
  106. __webpack_require__.d(actions_namespaceObject, "disableTips", function() { return disableTips; });
  107. __webpack_require__.d(actions_namespaceObject, "enableTips", function() { return enableTips; });
  108. // NAMESPACE OBJECT: ./node_modules/@wordpress/nux/build-module/store/selectors.js
  109. var selectors_namespaceObject = {};
  110. __webpack_require__.r(selectors_namespaceObject);
  111. __webpack_require__.d(selectors_namespaceObject, "getAssociatedGuide", function() { return getAssociatedGuide; });
  112. __webpack_require__.d(selectors_namespaceObject, "isTipVisible", function() { return isTipVisible; });
  113. __webpack_require__.d(selectors_namespaceObject, "areTipsEnabled", function() { return selectors_areTipsEnabled; });
  114. // EXTERNAL MODULE: external ["wp","deprecated"]
  115. var external_wp_deprecated_ = __webpack_require__("NMb1");
  116. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_);
  117. // EXTERNAL MODULE: external ["wp","data"]
  118. var external_wp_data_ = __webpack_require__("1ZqX");
  119. // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/reducer.js
  120. /**
  121. * WordPress dependencies
  122. */
  123. /**
  124. * Reducer that tracks which tips are in a guide. Each guide is represented by
  125. * an array which contains the tip identifiers contained within that guide.
  126. *
  127. * @param {Array} state Current state.
  128. * @param {Object} action Dispatched action.
  129. *
  130. * @return {Array} Updated state.
  131. */
  132. function guides(state = [], action) {
  133. switch (action.type) {
  134. case 'TRIGGER_GUIDE':
  135. return [...state, action.tipIds];
  136. }
  137. return state;
  138. }
  139. /**
  140. * Reducer that tracks whether or not tips are globally enabled.
  141. *
  142. * @param {boolean} state Current state.
  143. * @param {Object} action Dispatched action.
  144. *
  145. * @return {boolean} Updated state.
  146. */
  147. function areTipsEnabled(state = true, action) {
  148. switch (action.type) {
  149. case 'DISABLE_TIPS':
  150. return false;
  151. case 'ENABLE_TIPS':
  152. return true;
  153. }
  154. return state;
  155. }
  156. /**
  157. * Reducer that tracks which tips have been dismissed. If the state object
  158. * contains a tip identifier, then that tip is dismissed.
  159. *
  160. * @param {Object} state Current state.
  161. * @param {Object} action Dispatched action.
  162. *
  163. * @return {Object} Updated state.
  164. */
  165. function dismissedTips(state = {}, action) {
  166. switch (action.type) {
  167. case 'DISMISS_TIP':
  168. return { ...state,
  169. [action.id]: true
  170. };
  171. case 'ENABLE_TIPS':
  172. return {};
  173. }
  174. return state;
  175. }
  176. const preferences = Object(external_wp_data_["combineReducers"])({
  177. areTipsEnabled,
  178. dismissedTips
  179. });
  180. /* harmony default export */ var reducer = (Object(external_wp_data_["combineReducers"])({
  181. guides,
  182. preferences
  183. }));
  184. // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/actions.js
  185. /**
  186. * Returns an action object that, when dispatched, presents a guide that takes
  187. * the user through a series of tips step by step.
  188. *
  189. * @param {string[]} tipIds Which tips to show in the guide.
  190. *
  191. * @return {Object} Action object.
  192. */
  193. function triggerGuide(tipIds) {
  194. return {
  195. type: 'TRIGGER_GUIDE',
  196. tipIds
  197. };
  198. }
  199. /**
  200. * Returns an action object that, when dispatched, dismisses the given tip. A
  201. * dismissed tip will not show again.
  202. *
  203. * @param {string} id The tip to dismiss.
  204. *
  205. * @return {Object} Action object.
  206. */
  207. function dismissTip(id) {
  208. return {
  209. type: 'DISMISS_TIP',
  210. id
  211. };
  212. }
  213. /**
  214. * Returns an action object that, when dispatched, prevents all tips from
  215. * showing again.
  216. *
  217. * @return {Object} Action object.
  218. */
  219. function disableTips() {
  220. return {
  221. type: 'DISABLE_TIPS'
  222. };
  223. }
  224. /**
  225. * Returns an action object that, when dispatched, makes all tips show again.
  226. *
  227. * @return {Object} Action object.
  228. */
  229. function enableTips() {
  230. return {
  231. type: 'ENABLE_TIPS'
  232. };
  233. }
  234. // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js
  235. var rememo = __webpack_require__("pPDe");
  236. // EXTERNAL MODULE: external "lodash"
  237. var external_lodash_ = __webpack_require__("YLtl");
  238. // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/selectors.js
  239. /**
  240. * External dependencies
  241. */
  242. /**
  243. * An object containing information about a guide.
  244. *
  245. * @typedef {Object} NUXGuideInfo
  246. * @property {string[]} tipIds Which tips the guide contains.
  247. * @property {?string} currentTipId The guide's currently showing tip.
  248. * @property {?string} nextTipId The guide's next tip to show.
  249. */
  250. /**
  251. * Returns an object describing the guide, if any, that the given tip is a part
  252. * of.
  253. *
  254. * @param {Object} state Global application state.
  255. * @param {string} tipId The tip to query.
  256. *
  257. * @return {?NUXGuideInfo} Information about the associated guide.
  258. */
  259. const getAssociatedGuide = Object(rememo["a" /* default */])((state, tipId) => {
  260. for (const tipIds of state.guides) {
  261. if (Object(external_lodash_["includes"])(tipIds, tipId)) {
  262. const nonDismissedTips = Object(external_lodash_["difference"])(tipIds, Object(external_lodash_["keys"])(state.preferences.dismissedTips));
  263. const [currentTipId = null, nextTipId = null] = nonDismissedTips;
  264. return {
  265. tipIds,
  266. currentTipId,
  267. nextTipId
  268. };
  269. }
  270. }
  271. return null;
  272. }, state => [state.guides, state.preferences.dismissedTips]);
  273. /**
  274. * Determines whether or not the given tip is showing. Tips are hidden if they
  275. * are disabled, have been dismissed, or are not the current tip in any
  276. * guide that they have been added to.
  277. *
  278. * @param {Object} state Global application state.
  279. * @param {string} tipId The tip to query.
  280. *
  281. * @return {boolean} Whether or not the given tip is showing.
  282. */
  283. function isTipVisible(state, tipId) {
  284. if (!state.preferences.areTipsEnabled) {
  285. return false;
  286. }
  287. if (Object(external_lodash_["has"])(state.preferences.dismissedTips, [tipId])) {
  288. return false;
  289. }
  290. const associatedGuide = getAssociatedGuide(state, tipId);
  291. if (associatedGuide && associatedGuide.currentTipId !== tipId) {
  292. return false;
  293. }
  294. return true;
  295. }
  296. /**
  297. * Returns whether or not tips are globally enabled.
  298. *
  299. * @param {Object} state Global application state.
  300. *
  301. * @return {boolean} Whether tips are globally enabled.
  302. */
  303. function selectors_areTipsEnabled(state) {
  304. return state.preferences.areTipsEnabled;
  305. }
  306. // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/store/index.js
  307. /**
  308. * WordPress dependencies
  309. */
  310. /**
  311. * Internal dependencies
  312. */
  313. const STORE_NAME = 'core/nux';
  314. /**
  315. * Store definition for the nux namespace.
  316. *
  317. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  318. *
  319. * @type {Object}
  320. */
  321. const store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, {
  322. reducer: reducer,
  323. actions: actions_namespaceObject,
  324. selectors: selectors_namespaceObject,
  325. persist: ['preferences']
  326. }); // Once we build a more generic persistence plugin that works across types of stores
  327. // we'd be able to replace this with a register call.
  328. Object(external_wp_data_["registerStore"])(STORE_NAME, {
  329. reducer: reducer,
  330. actions: actions_namespaceObject,
  331. selectors: selectors_namespaceObject,
  332. persist: ['preferences']
  333. });
  334. // EXTERNAL MODULE: external ["wp","element"]
  335. var external_wp_element_ = __webpack_require__("GRId");
  336. // EXTERNAL MODULE: external ["wp","compose"]
  337. var external_wp_compose_ = __webpack_require__("K9lf");
  338. // EXTERNAL MODULE: external ["wp","components"]
  339. var external_wp_components_ = __webpack_require__("tI+e");
  340. // EXTERNAL MODULE: external ["wp","i18n"]
  341. var external_wp_i18n_ = __webpack_require__("l3Sj");
  342. // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js
  343. var library_close = __webpack_require__("w95h");
  344. // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/components/dot-tip/index.js
  345. /**
  346. * WordPress dependencies
  347. */
  348. function onClick(event) {
  349. // Tips are often nested within buttons. We stop propagation so that clicking
  350. // on a tip doesn't result in the button being clicked.
  351. event.stopPropagation();
  352. }
  353. function DotTip({
  354. position = 'middle right',
  355. children,
  356. isVisible,
  357. hasNextTip,
  358. onDismiss,
  359. onDisable
  360. }) {
  361. const anchorParent = Object(external_wp_element_["useRef"])(null);
  362. const onFocusOutsideCallback = Object(external_wp_element_["useCallback"])(event => {
  363. if (!anchorParent.current) {
  364. return;
  365. }
  366. if (anchorParent.current.contains(event.relatedTarget)) {
  367. return;
  368. }
  369. onDisable();
  370. }, [onDisable, anchorParent]);
  371. if (!isVisible) {
  372. return null;
  373. }
  374. return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
  375. className: "nux-dot-tip",
  376. position: position,
  377. noArrow: true,
  378. focusOnMount: "container",
  379. shouldAnchorIncludePadding: true,
  380. role: "dialog",
  381. "aria-label": Object(external_wp_i18n_["__"])('Editor tips'),
  382. onClick: onClick,
  383. onFocusOutside: onFocusOutsideCallback
  384. }, Object(external_wp_element_["createElement"])("p", null, children), Object(external_wp_element_["createElement"])("p", null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  385. isLink: true,
  386. onClick: onDismiss
  387. }, hasNextTip ? Object(external_wp_i18n_["__"])('See next tip') : Object(external_wp_i18n_["__"])('Got it'))), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  388. className: "nux-dot-tip__disable",
  389. icon: library_close["a" /* default */],
  390. label: Object(external_wp_i18n_["__"])('Disable tips'),
  391. onClick: onDisable
  392. }));
  393. }
  394. /* harmony default export */ var dot_tip = (Object(external_wp_compose_["compose"])(Object(external_wp_data_["withSelect"])((select, {
  395. tipId
  396. }) => {
  397. const {
  398. isTipVisible,
  399. getAssociatedGuide
  400. } = select('core/nux');
  401. const associatedGuide = getAssociatedGuide(tipId);
  402. return {
  403. isVisible: isTipVisible(tipId),
  404. hasNextTip: !!(associatedGuide && associatedGuide.nextTipId)
  405. };
  406. }), Object(external_wp_data_["withDispatch"])((dispatch, {
  407. tipId
  408. }) => {
  409. const {
  410. dismissTip,
  411. disableTips
  412. } = dispatch('core/nux');
  413. return {
  414. onDismiss() {
  415. dismissTip(tipId);
  416. },
  417. onDisable() {
  418. disableTips();
  419. }
  420. };
  421. }))(DotTip));
  422. // CONCATENATED MODULE: ./node_modules/@wordpress/nux/build-module/index.js
  423. /**
  424. * WordPress dependencies
  425. */
  426. external_wp_deprecated_default()('wp.nux', {
  427. since: '5.4',
  428. hint: 'wp.components.Guide can be used to show a user guide.'
  429. });
  430. /***/ }),
  431. /***/ "GRId":
  432. /***/ (function(module, exports) {
  433. (function() { module.exports = window["wp"]["element"]; }());
  434. /***/ }),
  435. /***/ "K9lf":
  436. /***/ (function(module, exports) {
  437. (function() { module.exports = window["wp"]["compose"]; }());
  438. /***/ }),
  439. /***/ "NMb1":
  440. /***/ (function(module, exports) {
  441. (function() { module.exports = window["wp"]["deprecated"]; }());
  442. /***/ }),
  443. /***/ "Tqx9":
  444. /***/ (function(module, exports) {
  445. (function() { module.exports = window["wp"]["primitives"]; }());
  446. /***/ }),
  447. /***/ "YLtl":
  448. /***/ (function(module, exports) {
  449. (function() { module.exports = window["lodash"]; }());
  450. /***/ }),
  451. /***/ "l3Sj":
  452. /***/ (function(module, exports) {
  453. (function() { module.exports = window["wp"]["i18n"]; }());
  454. /***/ }),
  455. /***/ "pPDe":
  456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  457. "use strict";
  458. var LEAF_KEY, hasWeakMap;
  459. /**
  460. * Arbitrary value used as key for referencing cache object in WeakMap tree.
  461. *
  462. * @type {Object}
  463. */
  464. LEAF_KEY = {};
  465. /**
  466. * Whether environment supports WeakMap.
  467. *
  468. * @type {boolean}
  469. */
  470. hasWeakMap = typeof WeakMap !== 'undefined';
  471. /**
  472. * Returns the first argument as the sole entry in an array.
  473. *
  474. * @param {*} value Value to return.
  475. *
  476. * @return {Array} Value returned as entry in array.
  477. */
  478. function arrayOf( value ) {
  479. return [ value ];
  480. }
  481. /**
  482. * Returns true if the value passed is object-like, or false otherwise. A value
  483. * is object-like if it can support property assignment, e.g. object or array.
  484. *
  485. * @param {*} value Value to test.
  486. *
  487. * @return {boolean} Whether value is object-like.
  488. */
  489. function isObjectLike( value ) {
  490. return !! value && 'object' === typeof value;
  491. }
  492. /**
  493. * Creates and returns a new cache object.
  494. *
  495. * @return {Object} Cache object.
  496. */
  497. function createCache() {
  498. var cache = {
  499. clear: function() {
  500. cache.head = null;
  501. },
  502. };
  503. return cache;
  504. }
  505. /**
  506. * Returns true if entries within the two arrays are strictly equal by
  507. * reference from a starting index.
  508. *
  509. * @param {Array} a First array.
  510. * @param {Array} b Second array.
  511. * @param {number} fromIndex Index from which to start comparison.
  512. *
  513. * @return {boolean} Whether arrays are shallowly equal.
  514. */
  515. function isShallowEqual( a, b, fromIndex ) {
  516. var i;
  517. if ( a.length !== b.length ) {
  518. return false;
  519. }
  520. for ( i = fromIndex; i < a.length; i++ ) {
  521. if ( a[ i ] !== b[ i ] ) {
  522. return false;
  523. }
  524. }
  525. return true;
  526. }
  527. /**
  528. * Returns a memoized selector function. The getDependants function argument is
  529. * called before the memoized selector and is expected to return an immutable
  530. * reference or array of references on which the selector depends for computing
  531. * its own return value. The memoize cache is preserved only as long as those
  532. * dependant references remain the same. If getDependants returns a different
  533. * reference(s), the cache is cleared and the selector value regenerated.
  534. *
  535. * @param {Function} selector Selector function.
  536. * @param {Function} getDependants Dependant getter returning an immutable
  537. * reference or array of reference used in
  538. * cache bust consideration.
  539. *
  540. * @return {Function} Memoized selector.
  541. */
  542. /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) {
  543. var rootCache, getCache;
  544. // Use object source as dependant if getter not provided
  545. if ( ! getDependants ) {
  546. getDependants = arrayOf;
  547. }
  548. /**
  549. * Returns the root cache. If WeakMap is supported, this is assigned to the
  550. * root WeakMap cache set, otherwise it is a shared instance of the default
  551. * cache object.
  552. *
  553. * @return {(WeakMap|Object)} Root cache object.
  554. */
  555. function getRootCache() {
  556. return rootCache;
  557. }
  558. /**
  559. * Returns the cache for a given dependants array. When possible, a WeakMap
  560. * will be used to create a unique cache for each set of dependants. This
  561. * is feasible due to the nature of WeakMap in allowing garbage collection
  562. * to occur on entries where the key object is no longer referenced. Since
  563. * WeakMap requires the key to be an object, this is only possible when the
  564. * dependant is object-like. The root cache is created as a hierarchy where
  565. * each top-level key is the first entry in a dependants set, the value a
  566. * WeakMap where each key is the next dependant, and so on. This continues
  567. * so long as the dependants are object-like. If no dependants are object-
  568. * like, then the cache is shared across all invocations.
  569. *
  570. * @see isObjectLike
  571. *
  572. * @param {Array} dependants Selector dependants.
  573. *
  574. * @return {Object} Cache object.
  575. */
  576. function getWeakMapCache( dependants ) {
  577. var caches = rootCache,
  578. isUniqueByDependants = true,
  579. i, dependant, map, cache;
  580. for ( i = 0; i < dependants.length; i++ ) {
  581. dependant = dependants[ i ];
  582. // Can only compose WeakMap from object-like key.
  583. if ( ! isObjectLike( dependant ) ) {
  584. isUniqueByDependants = false;
  585. break;
  586. }
  587. // Does current segment of cache already have a WeakMap?
  588. if ( caches.has( dependant ) ) {
  589. // Traverse into nested WeakMap.
  590. caches = caches.get( dependant );
  591. } else {
  592. // Create, set, and traverse into a new one.
  593. map = new WeakMap();
  594. caches.set( dependant, map );
  595. caches = map;
  596. }
  597. }
  598. // We use an arbitrary (but consistent) object as key for the last item
  599. // in the WeakMap to serve as our running cache.
  600. if ( ! caches.has( LEAF_KEY ) ) {
  601. cache = createCache();
  602. cache.isUniqueByDependants = isUniqueByDependants;
  603. caches.set( LEAF_KEY, cache );
  604. }
  605. return caches.get( LEAF_KEY );
  606. }
  607. // Assign cache handler by availability of WeakMap
  608. getCache = hasWeakMap ? getWeakMapCache : getRootCache;
  609. /**
  610. * Resets root memoization cache.
  611. */
  612. function clear() {
  613. rootCache = hasWeakMap ? new WeakMap() : createCache();
  614. }
  615. // eslint-disable-next-line jsdoc/check-param-names
  616. /**
  617. * The augmented selector call, considering first whether dependants have
  618. * changed before passing it to underlying memoize function.
  619. *
  620. * @param {Object} source Source object for derivation.
  621. * @param {...*} extraArgs Additional arguments to pass to selector.
  622. *
  623. * @return {*} Selector result.
  624. */
  625. function callSelector( /* source, ...extraArgs */ ) {
  626. var len = arguments.length,
  627. cache, node, i, args, dependants;
  628. // Create copy of arguments (avoid leaking deoptimization).
  629. args = new Array( len );
  630. for ( i = 0; i < len; i++ ) {
  631. args[ i ] = arguments[ i ];
  632. }
  633. dependants = getDependants.apply( null, args );
  634. cache = getCache( dependants );
  635. // If not guaranteed uniqueness by dependants (primitive type or lack
  636. // of WeakMap support), shallow compare against last dependants and, if
  637. // references have changed, destroy cache to recalculate result.
  638. if ( ! cache.isUniqueByDependants ) {
  639. if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
  640. cache.clear();
  641. }
  642. cache.lastDependants = dependants;
  643. }
  644. node = cache.head;
  645. while ( node ) {
  646. // Check whether node arguments match arguments
  647. if ( ! isShallowEqual( node.args, args, 1 ) ) {
  648. node = node.next;
  649. continue;
  650. }
  651. // At this point we can assume we've found a match
  652. // Surface matched node to head if not already
  653. if ( node !== cache.head ) {
  654. // Adjust siblings to point to each other.
  655. node.prev.next = node.next;
  656. if ( node.next ) {
  657. node.next.prev = node.prev;
  658. }
  659. node.next = cache.head;
  660. node.prev = null;
  661. cache.head.prev = node;
  662. cache.head = node;
  663. }
  664. // Return immediately
  665. return node.val;
  666. }
  667. // No cached value found. Continue to insertion phase:
  668. node = {
  669. // Generate the result from original function
  670. val: selector.apply( null, args ),
  671. };
  672. // Avoid including the source object in the cache.
  673. args[ 0 ] = null;
  674. node.args = args;
  675. // Don't need to check whether node is already head, since it would
  676. // have been returned above already if it was
  677. // Shift existing head down list
  678. if ( cache.head ) {
  679. cache.head.prev = node;
  680. node.next = cache.head;
  681. }
  682. cache.head = node;
  683. return node.val;
  684. }
  685. callSelector.getDependants = getDependants;
  686. callSelector.clear = clear;
  687. clear();
  688. return callSelector;
  689. });
  690. /***/ }),
  691. /***/ "tI+e":
  692. /***/ (function(module, exports) {
  693. (function() { module.exports = window["wp"]["components"]; }());
  694. /***/ }),
  695. /***/ "w95h":
  696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  697. "use strict";
  698. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId");
  699. /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
  700. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9");
  701. /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
  702. /**
  703. * WordPress dependencies
  704. */
  705. const close = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
  706. xmlns: "http://www.w3.org/2000/svg",
  707. viewBox: "0 0 24 24"
  708. }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
  709. d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"
  710. }));
  711. /* harmony default export */ __webpack_exports__["a"] = (close);
  712. /***/ })
  713. /******/ });