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