You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

956 lines
26 KiB

1 year ago
  1. /******/ (function() { // webpackBootstrap
  2. /******/ "use strict";
  3. /******/ // The require scope
  4. /******/ var __webpack_require__ = {};
  5. /******/
  6. /************************************************************************/
  7. /******/ /* webpack/runtime/define property getters */
  8. /******/ !function() {
  9. /******/ // define getter functions for harmony exports
  10. /******/ __webpack_require__.d = function(exports, definition) {
  11. /******/ for(var key in definition) {
  12. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  13. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  14. /******/ }
  15. /******/ }
  16. /******/ };
  17. /******/ }();
  18. /******/
  19. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  20. /******/ !function() {
  21. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  22. /******/ }();
  23. /******/
  24. /******/ /* webpack/runtime/make namespace object */
  25. /******/ !function() {
  26. /******/ // define __esModule on exports
  27. /******/ __webpack_require__.r = function(exports) {
  28. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  29. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  30. /******/ }
  31. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  32. /******/ };
  33. /******/ }();
  34. /******/
  35. /************************************************************************/
  36. var __webpack_exports__ = {};
  37. // ESM COMPAT FLAG
  38. __webpack_require__.r(__webpack_exports__);
  39. // EXPORTS
  40. __webpack_require__.d(__webpack_exports__, {
  41. privateApis: function() { return /* reexport */ privateApis; }
  42. });
  43. ;// CONCATENATED MODULE: external ["wp","element"]
  44. var external_wp_element_namespaceObject = window["wp"]["element"];
  45. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  46. function extends_extends() {
  47. extends_extends = Object.assign ? Object.assign.bind() : function (target) {
  48. for (var i = 1; i < arguments.length; i++) {
  49. var source = arguments[i];
  50. for (var key in source) {
  51. if (Object.prototype.hasOwnProperty.call(source, key)) {
  52. target[key] = source[key];
  53. }
  54. }
  55. }
  56. return target;
  57. };
  58. return extends_extends.apply(this, arguments);
  59. }
  60. ;// CONCATENATED MODULE: ./node_modules/history/index.js
  61. /**
  62. * Actions represent the type of change to a location value.
  63. *
  64. * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#action
  65. */
  66. var Action;
  67. (function (Action) {
  68. /**
  69. * A POP indicates a change to an arbitrary index in the history stack, such
  70. * as a back or forward navigation. It does not describe the direction of the
  71. * navigation, only that the current index changed.
  72. *
  73. * Note: This is the default action for newly created history objects.
  74. */
  75. Action["Pop"] = "POP";
  76. /**
  77. * A PUSH indicates a new entry being added to the history stack, such as when
  78. * a link is clicked and a new page loads. When this happens, all subsequent
  79. * entries in the stack are lost.
  80. */
  81. Action["Push"] = "PUSH";
  82. /**
  83. * A REPLACE indicates the entry at the current index in the history stack
  84. * being replaced by a new one.
  85. */
  86. Action["Replace"] = "REPLACE";
  87. })(Action || (Action = {}));
  88. var readOnly = false ? 0 : function (obj) {
  89. return obj;
  90. };
  91. function warning(cond, message) {
  92. if (!cond) {
  93. // eslint-disable-next-line no-console
  94. if (typeof console !== 'undefined') console.warn(message);
  95. try {
  96. // Welcome to debugging history!
  97. //
  98. // This error is thrown as a convenience so you can more easily
  99. // find the source for a warning that appears in the console by
  100. // enabling "pause on exceptions" in your JavaScript debugger.
  101. throw new Error(message); // eslint-disable-next-line no-empty
  102. } catch (e) {}
  103. }
  104. }
  105. var BeforeUnloadEventType = 'beforeunload';
  106. var HashChangeEventType = 'hashchange';
  107. var PopStateEventType = 'popstate';
  108. /**
  109. * Browser history stores the location in regular URLs. This is the standard for
  110. * most web apps, but it requires some configuration on the server to ensure you
  111. * serve the same app at multiple URLs.
  112. *
  113. * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
  114. */
  115. function createBrowserHistory(options) {
  116. if (options === void 0) {
  117. options = {};
  118. }
  119. var _options = options,
  120. _options$window = _options.window,
  121. window = _options$window === void 0 ? document.defaultView : _options$window;
  122. var globalHistory = window.history;
  123. function getIndexAndLocation() {
  124. var _window$location = window.location,
  125. pathname = _window$location.pathname,
  126. search = _window$location.search,
  127. hash = _window$location.hash;
  128. var state = globalHistory.state || {};
  129. return [state.idx, readOnly({
  130. pathname: pathname,
  131. search: search,
  132. hash: hash,
  133. state: state.usr || null,
  134. key: state.key || 'default'
  135. })];
  136. }
  137. var blockedPopTx = null;
  138. function handlePop() {
  139. if (blockedPopTx) {
  140. blockers.call(blockedPopTx);
  141. blockedPopTx = null;
  142. } else {
  143. var nextAction = Action.Pop;
  144. var _getIndexAndLocation = getIndexAndLocation(),
  145. nextIndex = _getIndexAndLocation[0],
  146. nextLocation = _getIndexAndLocation[1];
  147. if (blockers.length) {
  148. if (nextIndex != null) {
  149. var delta = index - nextIndex;
  150. if (delta) {
  151. // Revert the POP
  152. blockedPopTx = {
  153. action: nextAction,
  154. location: nextLocation,
  155. retry: function retry() {
  156. go(delta * -1);
  157. }
  158. };
  159. go(delta);
  160. }
  161. } else {
  162. // Trying to POP to a location with no index. We did not create
  163. // this location, so we can't effectively block the navigation.
  164. false ? 0 : void 0;
  165. }
  166. } else {
  167. applyTx(nextAction);
  168. }
  169. }
  170. }
  171. window.addEventListener(PopStateEventType, handlePop);
  172. var action = Action.Pop;
  173. var _getIndexAndLocation2 = getIndexAndLocation(),
  174. index = _getIndexAndLocation2[0],
  175. location = _getIndexAndLocation2[1];
  176. var listeners = createEvents();
  177. var blockers = createEvents();
  178. if (index == null) {
  179. index = 0;
  180. globalHistory.replaceState(extends_extends({}, globalHistory.state, {
  181. idx: index
  182. }), '');
  183. }
  184. function createHref(to) {
  185. return typeof to === 'string' ? to : createPath(to);
  186. } // state defaults to `null` because `window.history.state` does
  187. function getNextLocation(to, state) {
  188. if (state === void 0) {
  189. state = null;
  190. }
  191. return readOnly(extends_extends({
  192. pathname: location.pathname,
  193. hash: '',
  194. search: ''
  195. }, typeof to === 'string' ? parsePath(to) : to, {
  196. state: state,
  197. key: createKey()
  198. }));
  199. }
  200. function getHistoryStateAndUrl(nextLocation, index) {
  201. return [{
  202. usr: nextLocation.state,
  203. key: nextLocation.key,
  204. idx: index
  205. }, createHref(nextLocation)];
  206. }
  207. function allowTx(action, location, retry) {
  208. return !blockers.length || (blockers.call({
  209. action: action,
  210. location: location,
  211. retry: retry
  212. }), false);
  213. }
  214. function applyTx(nextAction) {
  215. action = nextAction;
  216. var _getIndexAndLocation3 = getIndexAndLocation();
  217. index = _getIndexAndLocation3[0];
  218. location = _getIndexAndLocation3[1];
  219. listeners.call({
  220. action: action,
  221. location: location
  222. });
  223. }
  224. function push(to, state) {
  225. var nextAction = Action.Push;
  226. var nextLocation = getNextLocation(to, state);
  227. function retry() {
  228. push(to, state);
  229. }
  230. if (allowTx(nextAction, nextLocation, retry)) {
  231. var _getHistoryStateAndUr = getHistoryStateAndUrl(nextLocation, index + 1),
  232. historyState = _getHistoryStateAndUr[0],
  233. url = _getHistoryStateAndUr[1]; // TODO: Support forced reloading
  234. // try...catch because iOS limits us to 100 pushState calls :/
  235. try {
  236. globalHistory.pushState(historyState, '', url);
  237. } catch (error) {
  238. // They are going to lose state here, but there is no real
  239. // way to warn them about it since the page will refresh...
  240. window.location.assign(url);
  241. }
  242. applyTx(nextAction);
  243. }
  244. }
  245. function replace(to, state) {
  246. var nextAction = Action.Replace;
  247. var nextLocation = getNextLocation(to, state);
  248. function retry() {
  249. replace(to, state);
  250. }
  251. if (allowTx(nextAction, nextLocation, retry)) {
  252. var _getHistoryStateAndUr2 = getHistoryStateAndUrl(nextLocation, index),
  253. historyState = _getHistoryStateAndUr2[0],
  254. url = _getHistoryStateAndUr2[1]; // TODO: Support forced reloading
  255. globalHistory.replaceState(historyState, '', url);
  256. applyTx(nextAction);
  257. }
  258. }
  259. function go(delta) {
  260. globalHistory.go(delta);
  261. }
  262. var history = {
  263. get action() {
  264. return action;
  265. },
  266. get location() {
  267. return location;
  268. },
  269. createHref: createHref,
  270. push: push,
  271. replace: replace,
  272. go: go,
  273. back: function back() {
  274. go(-1);
  275. },
  276. forward: function forward() {
  277. go(1);
  278. },
  279. listen: function listen(listener) {
  280. return listeners.push(listener);
  281. },
  282. block: function block(blocker) {
  283. var unblock = blockers.push(blocker);
  284. if (blockers.length === 1) {
  285. window.addEventListener(BeforeUnloadEventType, promptBeforeUnload);
  286. }
  287. return function () {
  288. unblock(); // Remove the beforeunload listener so the document may
  289. // still be salvageable in the pagehide event.
  290. // See https://html.spec.whatwg.org/#unloading-documents
  291. if (!blockers.length) {
  292. window.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);
  293. }
  294. };
  295. }
  296. };
  297. return history;
  298. }
  299. /**
  300. * Hash history stores the location in window.location.hash. This makes it ideal
  301. * for situations where you don't want to send the location to the server for
  302. * some reason, either because you do cannot configure it or the URL space is
  303. * reserved for something else.
  304. *
  305. * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory
  306. */
  307. function createHashHistory(options) {
  308. if (options === void 0) {
  309. options = {};
  310. }
  311. var _options2 = options,
  312. _options2$window = _options2.window,
  313. window = _options2$window === void 0 ? document.defaultView : _options2$window;
  314. var globalHistory = window.history;
  315. function getIndexAndLocation() {
  316. var _parsePath = parsePath(window.location.hash.substr(1)),
  317. _parsePath$pathname = _parsePath.pathname,
  318. pathname = _parsePath$pathname === void 0 ? '/' : _parsePath$pathname,
  319. _parsePath$search = _parsePath.search,
  320. search = _parsePath$search === void 0 ? '' : _parsePath$search,
  321. _parsePath$hash = _parsePath.hash,
  322. hash = _parsePath$hash === void 0 ? '' : _parsePath$hash;
  323. var state = globalHistory.state || {};
  324. return [state.idx, readOnly({
  325. pathname: pathname,
  326. search: search,
  327. hash: hash,
  328. state: state.usr || null,
  329. key: state.key || 'default'
  330. })];
  331. }
  332. var blockedPopTx = null;
  333. function handlePop() {
  334. if (blockedPopTx) {
  335. blockers.call(blockedPopTx);
  336. blockedPopTx = null;
  337. } else {
  338. var nextAction = Action.Pop;
  339. var _getIndexAndLocation4 = getIndexAndLocation(),
  340. nextIndex = _getIndexAndLocation4[0],
  341. nextLocation = _getIndexAndLocation4[1];
  342. if (blockers.length) {
  343. if (nextIndex != null) {
  344. var delta = index - nextIndex;
  345. if (delta) {
  346. // Revert the POP
  347. blockedPopTx = {
  348. action: nextAction,
  349. location: nextLocation,
  350. retry: function retry() {
  351. go(delta * -1);
  352. }
  353. };
  354. go(delta);
  355. }
  356. } else {
  357. // Trying to POP to a location with no index. We did not create
  358. // this location, so we can't effectively block the navigation.
  359. false ? 0 : void 0;
  360. }
  361. } else {
  362. applyTx(nextAction);
  363. }
  364. }
  365. }
  366. window.addEventListener(PopStateEventType, handlePop); // popstate does not fire on hashchange in IE 11 and old (trident) Edge
  367. // https://developer.mozilla.org/de/docs/Web/API/Window/popstate_event
  368. window.addEventListener(HashChangeEventType, function () {
  369. var _getIndexAndLocation5 = getIndexAndLocation(),
  370. nextLocation = _getIndexAndLocation5[1]; // Ignore extraneous hashchange events.
  371. if (createPath(nextLocation) !== createPath(location)) {
  372. handlePop();
  373. }
  374. });
  375. var action = Action.Pop;
  376. var _getIndexAndLocation6 = getIndexAndLocation(),
  377. index = _getIndexAndLocation6[0],
  378. location = _getIndexAndLocation6[1];
  379. var listeners = createEvents();
  380. var blockers = createEvents();
  381. if (index == null) {
  382. index = 0;
  383. globalHistory.replaceState(_extends({}, globalHistory.state, {
  384. idx: index
  385. }), '');
  386. }
  387. function getBaseHref() {
  388. var base = document.querySelector('base');
  389. var href = '';
  390. if (base && base.getAttribute('href')) {
  391. var url = window.location.href;
  392. var hashIndex = url.indexOf('#');
  393. href = hashIndex === -1 ? url : url.slice(0, hashIndex);
  394. }
  395. return href;
  396. }
  397. function createHref(to) {
  398. return getBaseHref() + '#' + (typeof to === 'string' ? to : createPath(to));
  399. }
  400. function getNextLocation(to, state) {
  401. if (state === void 0) {
  402. state = null;
  403. }
  404. return readOnly(_extends({
  405. pathname: location.pathname,
  406. hash: '',
  407. search: ''
  408. }, typeof to === 'string' ? parsePath(to) : to, {
  409. state: state,
  410. key: createKey()
  411. }));
  412. }
  413. function getHistoryStateAndUrl(nextLocation, index) {
  414. return [{
  415. usr: nextLocation.state,
  416. key: nextLocation.key,
  417. idx: index
  418. }, createHref(nextLocation)];
  419. }
  420. function allowTx(action, location, retry) {
  421. return !blockers.length || (blockers.call({
  422. action: action,
  423. location: location,
  424. retry: retry
  425. }), false);
  426. }
  427. function applyTx(nextAction) {
  428. action = nextAction;
  429. var _getIndexAndLocation7 = getIndexAndLocation();
  430. index = _getIndexAndLocation7[0];
  431. location = _getIndexAndLocation7[1];
  432. listeners.call({
  433. action: action,
  434. location: location
  435. });
  436. }
  437. function push(to, state) {
  438. var nextAction = Action.Push;
  439. var nextLocation = getNextLocation(to, state);
  440. function retry() {
  441. push(to, state);
  442. }
  443. false ? 0 : void 0;
  444. if (allowTx(nextAction, nextLocation, retry)) {
  445. var _getHistoryStateAndUr3 = getHistoryStateAndUrl(nextLocation, index + 1),
  446. historyState = _getHistoryStateAndUr3[0],
  447. url = _getHistoryStateAndUr3[1]; // TODO: Support forced reloading
  448. // try...catch because iOS limits us to 100 pushState calls :/
  449. try {
  450. globalHistory.pushState(historyState, '', url);
  451. } catch (error) {
  452. // They are going to lose state here, but there is no real
  453. // way to warn them about it since the page will refresh...
  454. window.location.assign(url);
  455. }
  456. applyTx(nextAction);
  457. }
  458. }
  459. function replace(to, state) {
  460. var nextAction = Action.Replace;
  461. var nextLocation = getNextLocation(to, state);
  462. function retry() {
  463. replace(to, state);
  464. }
  465. false ? 0 : void 0;
  466. if (allowTx(nextAction, nextLocation, retry)) {
  467. var _getHistoryStateAndUr4 = getHistoryStateAndUrl(nextLocation, index),
  468. historyState = _getHistoryStateAndUr4[0],
  469. url = _getHistoryStateAndUr4[1]; // TODO: Support forced reloading
  470. globalHistory.replaceState(historyState, '', url);
  471. applyTx(nextAction);
  472. }
  473. }
  474. function go(delta) {
  475. globalHistory.go(delta);
  476. }
  477. var history = {
  478. get action() {
  479. return action;
  480. },
  481. get location() {
  482. return location;
  483. },
  484. createHref: createHref,
  485. push: push,
  486. replace: replace,
  487. go: go,
  488. back: function back() {
  489. go(-1);
  490. },
  491. forward: function forward() {
  492. go(1);
  493. },
  494. listen: function listen(listener) {
  495. return listeners.push(listener);
  496. },
  497. block: function block(blocker) {
  498. var unblock = blockers.push(blocker);
  499. if (blockers.length === 1) {
  500. window.addEventListener(BeforeUnloadEventType, promptBeforeUnload);
  501. }
  502. return function () {
  503. unblock(); // Remove the beforeunload listener so the document may
  504. // still be salvageable in the pagehide event.
  505. // See https://html.spec.whatwg.org/#unloading-documents
  506. if (!blockers.length) {
  507. window.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);
  508. }
  509. };
  510. }
  511. };
  512. return history;
  513. }
  514. /**
  515. * Memory history stores the current location in memory. It is designed for use
  516. * in stateful non-browser environments like tests and React Native.
  517. *
  518. * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#creatememoryhistory
  519. */
  520. function createMemoryHistory(options) {
  521. if (options === void 0) {
  522. options = {};
  523. }
  524. var _options3 = options,
  525. _options3$initialEntr = _options3.initialEntries,
  526. initialEntries = _options3$initialEntr === void 0 ? ['/'] : _options3$initialEntr,
  527. initialIndex = _options3.initialIndex;
  528. var entries = initialEntries.map(function (entry) {
  529. var location = readOnly(_extends({
  530. pathname: '/',
  531. search: '',
  532. hash: '',
  533. state: null,
  534. key: createKey()
  535. }, typeof entry === 'string' ? parsePath(entry) : entry));
  536. false ? 0 : void 0;
  537. return location;
  538. });
  539. var index = clamp(initialIndex == null ? entries.length - 1 : initialIndex, 0, entries.length - 1);
  540. var action = Action.Pop;
  541. var location = entries[index];
  542. var listeners = createEvents();
  543. var blockers = createEvents();
  544. function createHref(to) {
  545. return typeof to === 'string' ? to : createPath(to);
  546. }
  547. function getNextLocation(to, state) {
  548. if (state === void 0) {
  549. state = null;
  550. }
  551. return readOnly(_extends({
  552. pathname: location.pathname,
  553. search: '',
  554. hash: ''
  555. }, typeof to === 'string' ? parsePath(to) : to, {
  556. state: state,
  557. key: createKey()
  558. }));
  559. }
  560. function allowTx(action, location, retry) {
  561. return !blockers.length || (blockers.call({
  562. action: action,
  563. location: location,
  564. retry: retry
  565. }), false);
  566. }
  567. function applyTx(nextAction, nextLocation) {
  568. action = nextAction;
  569. location = nextLocation;
  570. listeners.call({
  571. action: action,
  572. location: location
  573. });
  574. }
  575. function push(to, state) {
  576. var nextAction = Action.Push;
  577. var nextLocation = getNextLocation(to, state);
  578. function retry() {
  579. push(to, state);
  580. }
  581. false ? 0 : void 0;
  582. if (allowTx(nextAction, nextLocation, retry)) {
  583. index += 1;
  584. entries.splice(index, entries.length, nextLocation);
  585. applyTx(nextAction, nextLocation);
  586. }
  587. }
  588. function replace(to, state) {
  589. var nextAction = Action.Replace;
  590. var nextLocation = getNextLocation(to, state);
  591. function retry() {
  592. replace(to, state);
  593. }
  594. false ? 0 : void 0;
  595. if (allowTx(nextAction, nextLocation, retry)) {
  596. entries[index] = nextLocation;
  597. applyTx(nextAction, nextLocation);
  598. }
  599. }
  600. function go(delta) {
  601. var nextIndex = clamp(index + delta, 0, entries.length - 1);
  602. var nextAction = Action.Pop;
  603. var nextLocation = entries[nextIndex];
  604. function retry() {
  605. go(delta);
  606. }
  607. if (allowTx(nextAction, nextLocation, retry)) {
  608. index = nextIndex;
  609. applyTx(nextAction, nextLocation);
  610. }
  611. }
  612. var history = {
  613. get index() {
  614. return index;
  615. },
  616. get action() {
  617. return action;
  618. },
  619. get location() {
  620. return location;
  621. },
  622. createHref: createHref,
  623. push: push,
  624. replace: replace,
  625. go: go,
  626. back: function back() {
  627. go(-1);
  628. },
  629. forward: function forward() {
  630. go(1);
  631. },
  632. listen: function listen(listener) {
  633. return listeners.push(listener);
  634. },
  635. block: function block(blocker) {
  636. return blockers.push(blocker);
  637. }
  638. };
  639. return history;
  640. } ////////////////////////////////////////////////////////////////////////////////
  641. // UTILS
  642. ////////////////////////////////////////////////////////////////////////////////
  643. function clamp(n, lowerBound, upperBound) {
  644. return Math.min(Math.max(n, lowerBound), upperBound);
  645. }
  646. function promptBeforeUnload(event) {
  647. // Cancel the event.
  648. event.preventDefault(); // Chrome (and legacy IE) requires returnValue to be set.
  649. event.returnValue = '';
  650. }
  651. function createEvents() {
  652. var handlers = [];
  653. return {
  654. get length() {
  655. return handlers.length;
  656. },
  657. push: function push(fn) {
  658. handlers.push(fn);
  659. return function () {
  660. handlers = handlers.filter(function (handler) {
  661. return handler !== fn;
  662. });
  663. };
  664. },
  665. call: function call(arg) {
  666. handlers.forEach(function (fn) {
  667. return fn && fn(arg);
  668. });
  669. }
  670. };
  671. }
  672. function createKey() {
  673. return Math.random().toString(36).substr(2, 8);
  674. }
  675. /**
  676. * Creates a string URL path from the given pathname, search, and hash components.
  677. *
  678. * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createpath
  679. */
  680. function createPath(_ref) {
  681. var _ref$pathname = _ref.pathname,
  682. pathname = _ref$pathname === void 0 ? '/' : _ref$pathname,
  683. _ref$search = _ref.search,
  684. search = _ref$search === void 0 ? '' : _ref$search,
  685. _ref$hash = _ref.hash,
  686. hash = _ref$hash === void 0 ? '' : _ref$hash;
  687. if (search && search !== '?') pathname += search.charAt(0) === '?' ? search : '?' + search;
  688. if (hash && hash !== '#') pathname += hash.charAt(0) === '#' ? hash : '#' + hash;
  689. return pathname;
  690. }
  691. /**
  692. * Parses a string URL path into its separate pathname, search, and hash components.
  693. *
  694. * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#parsepath
  695. */
  696. function parsePath(path) {
  697. var parsedPath = {};
  698. if (path) {
  699. var hashIndex = path.indexOf('#');
  700. if (hashIndex >= 0) {
  701. parsedPath.hash = path.substr(hashIndex);
  702. path = path.substr(0, hashIndex);
  703. }
  704. var searchIndex = path.indexOf('?');
  705. if (searchIndex >= 0) {
  706. parsedPath.search = path.substr(searchIndex);
  707. path = path.substr(0, searchIndex);
  708. }
  709. if (path) {
  710. parsedPath.pathname = path;
  711. }
  712. }
  713. return parsedPath;
  714. }
  715. ;// CONCATENATED MODULE: external ["wp","url"]
  716. var external_wp_url_namespaceObject = window["wp"]["url"];
  717. ;// CONCATENATED MODULE: ./node_modules/@wordpress/router/build-module/history.js
  718. /**
  719. * External dependencies
  720. */
  721. /**
  722. * WordPress dependencies
  723. */
  724. const history_history = createBrowserHistory();
  725. const originalHistoryPush = history_history.push;
  726. const originalHistoryReplace = history_history.replace;
  727. function push(params, state) {
  728. const currentArgs = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href);
  729. const currentUrlWithoutArgs = (0,external_wp_url_namespaceObject.removeQueryArgs)(window.location.href, ...Object.keys(currentArgs));
  730. const newUrl = (0,external_wp_url_namespaceObject.addQueryArgs)(currentUrlWithoutArgs, params);
  731. return originalHistoryPush.call(history_history, newUrl, state);
  732. }
  733. function replace(params, state) {
  734. const currentArgs = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href);
  735. const currentUrlWithoutArgs = (0,external_wp_url_namespaceObject.removeQueryArgs)(window.location.href, ...Object.keys(currentArgs));
  736. const newUrl = (0,external_wp_url_namespaceObject.addQueryArgs)(currentUrlWithoutArgs, params);
  737. return originalHistoryReplace.call(history_history, newUrl, state);
  738. }
  739. history_history.push = push;
  740. history_history.replace = replace;
  741. /* harmony default export */ var build_module_history = (history_history);
  742. ;// CONCATENATED MODULE: ./node_modules/@wordpress/router/build-module/router.js
  743. /**
  744. * WordPress dependencies
  745. */
  746. /**
  747. * Internal dependencies
  748. */
  749. const RoutesContext = (0,external_wp_element_namespaceObject.createContext)();
  750. const HistoryContext = (0,external_wp_element_namespaceObject.createContext)();
  751. function useLocation() {
  752. return (0,external_wp_element_namespaceObject.useContext)(RoutesContext);
  753. }
  754. function useHistory() {
  755. return (0,external_wp_element_namespaceObject.useContext)(HistoryContext);
  756. }
  757. function getLocationWithParams(location) {
  758. const searchParams = new URLSearchParams(location.search);
  759. return {
  760. ...location,
  761. params: Object.fromEntries(searchParams.entries())
  762. };
  763. }
  764. function RouterProvider({
  765. children
  766. }) {
  767. const [location, setLocation] = (0,external_wp_element_namespaceObject.useState)(() => getLocationWithParams(build_module_history.location));
  768. (0,external_wp_element_namespaceObject.useEffect)(() => {
  769. return build_module_history.listen(({
  770. location: updatedLocation
  771. }) => {
  772. setLocation(getLocationWithParams(updatedLocation));
  773. });
  774. }, []);
  775. return (0,external_wp_element_namespaceObject.createElement)(HistoryContext.Provider, {
  776. value: build_module_history
  777. }, (0,external_wp_element_namespaceObject.createElement)(RoutesContext.Provider, {
  778. value: location
  779. }, children));
  780. }
  781. ;// CONCATENATED MODULE: external ["wp","privateApis"]
  782. var external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
  783. ;// CONCATENATED MODULE: ./node_modules/@wordpress/router/build-module/lock-unlock.js
  784. /**
  785. * WordPress dependencies
  786. */
  787. const {
  788. lock,
  789. unlock
  790. } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/router');
  791. ;// CONCATENATED MODULE: ./node_modules/@wordpress/router/build-module/private-apis.js
  792. /**
  793. * Internal dependencies
  794. */
  795. const privateApis = {};
  796. lock(privateApis, {
  797. useHistory: useHistory,
  798. useLocation: useLocation,
  799. RouterProvider: RouterProvider
  800. });
  801. ;// CONCATENATED MODULE: ./node_modules/@wordpress/router/build-module/index.js
  802. (window.wp = window.wp || {}).router = __webpack_exports__;
  803. /******/ })()
  804. ;