[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> router.js (source)

   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  ;// ./node_modules/route-recognizer/dist/route-recognizer.es.js
  46  var createObject = Object.create;
  47  function createMap() {
  48      var map = createObject(null);
  49      map["__"] = undefined;
  50      delete map["__"];
  51      return map;
  52  }
  53  
  54  var Target = function Target(path, matcher, delegate) {
  55      this.path = path;
  56      this.matcher = matcher;
  57      this.delegate = delegate;
  58  };
  59  Target.prototype.to = function to (target, callback) {
  60      var delegate = this.delegate;
  61      if (delegate && delegate.willAddRoute) {
  62          target = delegate.willAddRoute(this.matcher.target, target);
  63      }
  64      this.matcher.add(this.path, target);
  65      if (callback) {
  66          if (callback.length === 0) {
  67              throw new Error("You must have an argument in the function passed to `to`");
  68          }
  69          this.matcher.addChild(this.path, target, callback, this.delegate);
  70      }
  71  };
  72  var Matcher = function Matcher(target) {
  73      this.routes = createMap();
  74      this.children = createMap();
  75      this.target = target;
  76  };
  77  Matcher.prototype.add = function add (path, target) {
  78      this.routes[path] = target;
  79  };
  80  Matcher.prototype.addChild = function addChild (path, target, callback, delegate) {
  81      var matcher = new Matcher(target);
  82      this.children[path] = matcher;
  83      var match = generateMatch(path, matcher, delegate);
  84      if (delegate && delegate.contextEntered) {
  85          delegate.contextEntered(target, match);
  86      }
  87      callback(match);
  88  };
  89  function generateMatch(startingPath, matcher, delegate) {
  90      function match(path, callback) {
  91          var fullPath = startingPath + path;
  92          if (callback) {
  93              callback(generateMatch(fullPath, matcher, delegate));
  94          }
  95          else {
  96              return new Target(fullPath, matcher, delegate);
  97          }
  98      }
  99      
 100      return match;
 101  }
 102  function addRoute(routeArray, path, handler) {
 103      var len = 0;
 104      for (var i = 0; i < routeArray.length; i++) {
 105          len += routeArray[i].path.length;
 106      }
 107      path = path.substr(len);
 108      var route = { path: path, handler: handler };
 109      routeArray.push(route);
 110  }
 111  function eachRoute(baseRoute, matcher, callback, binding) {
 112      var routes = matcher.routes;
 113      var paths = Object.keys(routes);
 114      for (var i = 0; i < paths.length; i++) {
 115          var path = paths[i];
 116          var routeArray = baseRoute.slice();
 117          addRoute(routeArray, path, routes[path]);
 118          var nested = matcher.children[path];
 119          if (nested) {
 120              eachRoute(routeArray, nested, callback, binding);
 121          }
 122          else {
 123              callback.call(binding, routeArray);
 124          }
 125      }
 126  }
 127  var map = function (callback, addRouteCallback) {
 128      var matcher = new Matcher();
 129      callback(generateMatch("", matcher, this.delegate));
 130      eachRoute([], matcher, function (routes) {
 131          if (addRouteCallback) {
 132              addRouteCallback(this, routes);
 133          }
 134          else {
 135              this.add(routes);
 136          }
 137      }, this);
 138  };
 139  
 140  // Normalizes percent-encoded values in `path` to upper-case and decodes percent-encoded
 141  // values that are not reserved (i.e., unicode characters, emoji, etc). The reserved
 142  // chars are "/" and "%".
 143  // Safe to call multiple times on the same path.
 144  // Normalizes percent-encoded values in `path` to upper-case and decodes percent-encoded
 145  function normalizePath(path) {
 146      return path.split("/")
 147          .map(normalizeSegment)
 148          .join("/");
 149  }
 150  // We want to ensure the characters "%" and "/" remain in percent-encoded
 151  // form when normalizing paths, so replace them with their encoded form after
 152  // decoding the rest of the path
 153  var SEGMENT_RESERVED_CHARS = /%|\//g;
 154  function normalizeSegment(segment) {
 155      if (segment.length < 3 || segment.indexOf("%") === -1)
 156          { return segment; }
 157      return decodeURIComponent(segment).replace(SEGMENT_RESERVED_CHARS, encodeURIComponent);
 158  }
 159  // We do not want to encode these characters when generating dynamic path segments
 160  // See https://tools.ietf.org/html/rfc3986#section-3.3
 161  // sub-delims: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="
 162  // others allowed by RFC 3986: ":", "@"
 163  //
 164  // First encode the entire path segment, then decode any of the encoded special chars.
 165  //
 166  // The chars "!", "'", "(", ")", "*" do not get changed by `encodeURIComponent`,
 167  // so the possible encoded chars are:
 168  // ['%24', '%26', '%2B', '%2C', '%3B', '%3D', '%3A', '%40'].
 169  var PATH_SEGMENT_ENCODINGS = /%(?:2(?:4|6|B|C)|3(?:B|D|A)|40)/g;
 170  function encodePathSegment(str) {
 171      return encodeURIComponent(str).replace(PATH_SEGMENT_ENCODINGS, decodeURIComponent);
 172  }
 173  
 174  var escapeRegex = /(\/|\.|\*|\+|\?|\||\(|\)|\[|\]|\{|\}|\\)/g;
 175  var isArray = Array.isArray;
 176  var route_recognizer_es_hasOwnProperty = Object.prototype.hasOwnProperty;
 177  function getParam(params, key) {
 178      if (typeof params !== "object" || params === null) {
 179          throw new Error("You must pass an object as the second argument to `generate`.");
 180      }
 181      if (!route_recognizer_es_hasOwnProperty.call(params, key)) {
 182          throw new Error("You must provide param `" + key + "` to `generate`.");
 183      }
 184      var value = params[key];
 185      var str = typeof value === "string" ? value : "" + value;
 186      if (str.length === 0) {
 187          throw new Error("You must provide a param `" + key + "`.");
 188      }
 189      return str;
 190  }
 191  var eachChar = [];
 192  eachChar[0 /* Static */] = function (segment, currentState) {
 193      var state = currentState;
 194      var value = segment.value;
 195      for (var i = 0; i < value.length; i++) {
 196          var ch = value.charCodeAt(i);
 197          state = state.put(ch, false, false);
 198      }
 199      return state;
 200  };
 201  eachChar[1 /* Dynamic */] = function (_, currentState) {
 202      return currentState.put(47 /* SLASH */, true, true);
 203  };
 204  eachChar[2 /* Star */] = function (_, currentState) {
 205      return currentState.put(-1 /* ANY */, false, true);
 206  };
 207  eachChar[4 /* Epsilon */] = function (_, currentState) {
 208      return currentState;
 209  };
 210  var regex = [];
 211  regex[0 /* Static */] = function (segment) {
 212      return segment.value.replace(escapeRegex, "\\$1");
 213  };
 214  regex[1 /* Dynamic */] = function () {
 215      return "([^/]+)";
 216  };
 217  regex[2 /* Star */] = function () {
 218      return "(.+)";
 219  };
 220  regex[4 /* Epsilon */] = function () {
 221      return "";
 222  };
 223  var generate = [];
 224  generate[0 /* Static */] = function (segment) {
 225      return segment.value;
 226  };
 227  generate[1 /* Dynamic */] = function (segment, params) {
 228      var value = getParam(params, segment.value);
 229      if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS) {
 230          return encodePathSegment(value);
 231      }
 232      else {
 233          return value;
 234      }
 235  };
 236  generate[2 /* Star */] = function (segment, params) {
 237      return getParam(params, segment.value);
 238  };
 239  generate[4 /* Epsilon */] = function () {
 240      return "";
 241  };
 242  var EmptyObject = Object.freeze({});
 243  var EmptyArray = Object.freeze([]);
 244  // The `names` will be populated with the paramter name for each dynamic/star
 245  // segment. `shouldDecodes` will be populated with a boolean for each dyanamic/star
 246  // segment, indicating whether it should be decoded during recognition.
 247  function parse(segments, route, types) {
 248      // normalize route as not starting with a "/". Recognition will
 249      // also normalize.
 250      if (route.length > 0 && route.charCodeAt(0) === 47 /* SLASH */) {
 251          route = route.substr(1);
 252      }
 253      var parts = route.split("/");
 254      var names = undefined;
 255      var shouldDecodes = undefined;
 256      for (var i = 0; i < parts.length; i++) {
 257          var part = parts[i];
 258          var flags = 0;
 259          var type = 0;
 260          if (part === "") {
 261              type = 4 /* Epsilon */;
 262          }
 263          else if (part.charCodeAt(0) === 58 /* COLON */) {
 264              type = 1 /* Dynamic */;
 265          }
 266          else if (part.charCodeAt(0) === 42 /* STAR */) {
 267              type = 2 /* Star */;
 268          }
 269          else {
 270              type = 0 /* Static */;
 271          }
 272          flags = 2 << type;
 273          if (flags & 12 /* Named */) {
 274              part = part.slice(1);
 275              names = names || [];
 276              names.push(part);
 277              shouldDecodes = shouldDecodes || [];
 278              shouldDecodes.push((flags & 4 /* Decoded */) !== 0);
 279          }
 280          if (flags & 14 /* Counted */) {
 281              types[type]++;
 282          }
 283          segments.push({
 284              type: type,
 285              value: normalizeSegment(part)
 286          });
 287      }
 288      return {
 289          names: names || EmptyArray,
 290          shouldDecodes: shouldDecodes || EmptyArray,
 291      };
 292  }
 293  function isEqualCharSpec(spec, char, negate) {
 294      return spec.char === char && spec.negate === negate;
 295  }
 296  // A State has a character specification and (`charSpec`) and a list of possible
 297  // subsequent states (`nextStates`).
 298  //
 299  // If a State is an accepting state, it will also have several additional
 300  // properties:
 301  //
 302  // * `regex`: A regular expression that is used to extract parameters from paths
 303  //   that reached this accepting state.
 304  // * `handlers`: Information on how to convert the list of captures into calls
 305  //   to registered handlers with the specified parameters
 306  // * `types`: How many static, dynamic or star segments in this route. Used to
 307  //   decide which route to use if multiple registered routes match a path.
 308  //
 309  // Currently, State is implemented naively by looping over `nextStates` and
 310  // comparing a character specification against a character. A more efficient
 311  // implementation would use a hash of keys pointing at one or more next states.
 312  var State = function State(states, id, char, negate, repeat) {
 313      this.states = states;
 314      this.id = id;
 315      this.char = char;
 316      this.negate = negate;
 317      this.nextStates = repeat ? id : null;
 318      this.pattern = "";
 319      this._regex = undefined;
 320      this.handlers = undefined;
 321      this.types = undefined;
 322  };
 323  State.prototype.regex = function regex$1 () {
 324      if (!this._regex) {
 325          this._regex = new RegExp(this.pattern);
 326      }
 327      return this._regex;
 328  };
 329  State.prototype.get = function get (char, negate) {
 330          var this$1 = this;
 331  
 332      var nextStates = this.nextStates;
 333      if (nextStates === null)
 334          { return; }
 335      if (isArray(nextStates)) {
 336          for (var i = 0; i < nextStates.length; i++) {
 337              var child = this$1.states[nextStates[i]];
 338              if (isEqualCharSpec(child, char, negate)) {
 339                  return child;
 340              }
 341          }
 342      }
 343      else {
 344          var child$1 = this.states[nextStates];
 345          if (isEqualCharSpec(child$1, char, negate)) {
 346              return child$1;
 347          }
 348      }
 349  };
 350  State.prototype.put = function put (char, negate, repeat) {
 351      var state;
 352      // If the character specification already exists in a child of the current
 353      // state, just return that state.
 354      if (state = this.get(char, negate)) {
 355          return state;
 356      }
 357      // Make a new state for the character spec
 358      var states = this.states;
 359      state = new State(states, states.length, char, negate, repeat);
 360      states[states.length] = state;
 361      // Insert the new state as a child of the current state
 362      if (this.nextStates == null) {
 363          this.nextStates = state.id;
 364      }
 365      else if (isArray(this.nextStates)) {
 366          this.nextStates.push(state.id);
 367      }
 368      else {
 369          this.nextStates = [this.nextStates, state.id];
 370      }
 371      // Return the new state
 372      return state;
 373  };
 374  // Find a list of child states matching the next character
 375  State.prototype.match = function match (ch) {
 376          var this$1 = this;
 377  
 378      var nextStates = this.nextStates;
 379      if (!nextStates)
 380          { return []; }
 381      var returned = [];
 382      if (isArray(nextStates)) {
 383          for (var i = 0; i < nextStates.length; i++) {
 384              var child = this$1.states[nextStates[i]];
 385              if (isMatch(child, ch)) {
 386                  returned.push(child);
 387              }
 388          }
 389      }
 390      else {
 391          var child$1 = this.states[nextStates];
 392          if (isMatch(child$1, ch)) {
 393              returned.push(child$1);
 394          }
 395      }
 396      return returned;
 397  };
 398  function isMatch(spec, char) {
 399      return spec.negate ? spec.char !== char && spec.char !== -1 /* ANY */ : spec.char === char || spec.char === -1 /* ANY */;
 400  }
 401  // This is a somewhat naive strategy, but should work in a lot of cases
 402  // A better strategy would properly resolve /posts/:id/new and /posts/edit/:id.
 403  //
 404  // This strategy generally prefers more static and less dynamic matching.
 405  // Specifically, it
 406  //
 407  //  * prefers fewer stars to more, then
 408  //  * prefers using stars for less of the match to more, then
 409  //  * prefers fewer dynamic segments to more, then
 410  //  * prefers more static segments to more
 411  function sortSolutions(states) {
 412      return states.sort(function (a, b) {
 413          var ref = a.types || [0, 0, 0];
 414          var astatics = ref[0];
 415          var adynamics = ref[1];
 416          var astars = ref[2];
 417          var ref$1 = b.types || [0, 0, 0];
 418          var bstatics = ref$1[0];
 419          var bdynamics = ref$1[1];
 420          var bstars = ref$1[2];
 421          if (astars !== bstars) {
 422              return astars - bstars;
 423          }
 424          if (astars) {
 425              if (astatics !== bstatics) {
 426                  return bstatics - astatics;
 427              }
 428              if (adynamics !== bdynamics) {
 429                  return bdynamics - adynamics;
 430              }
 431          }
 432          if (adynamics !== bdynamics) {
 433              return adynamics - bdynamics;
 434          }
 435          if (astatics !== bstatics) {
 436              return bstatics - astatics;
 437          }
 438          return 0;
 439      });
 440  }
 441  function recognizeChar(states, ch) {
 442      var nextStates = [];
 443      for (var i = 0, l = states.length; i < l; i++) {
 444          var state = states[i];
 445          nextStates = nextStates.concat(state.match(ch));
 446      }
 447      return nextStates;
 448  }
 449  var RecognizeResults = function RecognizeResults(queryParams) {
 450      this.length = 0;
 451      this.queryParams = queryParams || {};
 452  };
 453  
 454  RecognizeResults.prototype.splice = Array.prototype.splice;
 455  RecognizeResults.prototype.slice = Array.prototype.slice;
 456  RecognizeResults.prototype.push = Array.prototype.push;
 457  function findHandler(state, originalPath, queryParams) {
 458      var handlers = state.handlers;
 459      var regex = state.regex();
 460      if (!regex || !handlers)
 461          { throw new Error("state not initialized"); }
 462      var captures = originalPath.match(regex);
 463      var currentCapture = 1;
 464      var result = new RecognizeResults(queryParams);
 465      result.length = handlers.length;
 466      for (var i = 0; i < handlers.length; i++) {
 467          var handler = handlers[i];
 468          var names = handler.names;
 469          var shouldDecodes = handler.shouldDecodes;
 470          var params = EmptyObject;
 471          var isDynamic = false;
 472          if (names !== EmptyArray && shouldDecodes !== EmptyArray) {
 473              for (var j = 0; j < names.length; j++) {
 474                  isDynamic = true;
 475                  var name = names[j];
 476                  var capture = captures && captures[currentCapture++];
 477                  if (params === EmptyObject) {
 478                      params = {};
 479                  }
 480                  if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS && shouldDecodes[j]) {
 481                      params[name] = capture && decodeURIComponent(capture);
 482                  }
 483                  else {
 484                      params[name] = capture;
 485                  }
 486              }
 487          }
 488          result[i] = {
 489              handler: handler.handler,
 490              params: params,
 491              isDynamic: isDynamic
 492          };
 493      }
 494      return result;
 495  }
 496  function decodeQueryParamPart(part) {
 497      // http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
 498      part = part.replace(/\+/gm, "%20");
 499      var result;
 500      try {
 501          result = decodeURIComponent(part);
 502      }
 503      catch (error) {
 504          result = "";
 505      }
 506      return result;
 507  }
 508  var RouteRecognizer = function RouteRecognizer() {
 509      this.names = createMap();
 510      var states = [];
 511      var state = new State(states, 0, -1 /* ANY */, true, false);
 512      states[0] = state;
 513      this.states = states;
 514      this.rootState = state;
 515  };
 516  RouteRecognizer.prototype.add = function add (routes, options) {
 517      var currentState = this.rootState;
 518      var pattern = "^";
 519      var types = [0, 0, 0];
 520      var handlers = new Array(routes.length);
 521      var allSegments = [];
 522      var isEmpty = true;
 523      var j = 0;
 524      for (var i = 0; i < routes.length; i++) {
 525          var route = routes[i];
 526          var ref = parse(allSegments, route.path, types);
 527              var names = ref.names;
 528              var shouldDecodes = ref.shouldDecodes;
 529          // preserve j so it points to the start of newly added segments
 530          for (; j < allSegments.length; j++) {
 531              var segment = allSegments[j];
 532              if (segment.type === 4 /* Epsilon */) {
 533                  continue;
 534              }
 535              isEmpty = false;
 536              // Add a "/" for the new segment
 537              currentState = currentState.put(47 /* SLASH */, false, false);
 538              pattern += "/";
 539              // Add a representation of the segment to the NFA and regex
 540              currentState = eachChar[segment.type](segment, currentState);
 541              pattern += regex[segment.type](segment);
 542          }
 543          handlers[i] = {
 544              handler: route.handler,
 545              names: names,
 546              shouldDecodes: shouldDecodes
 547          };
 548      }
 549      if (isEmpty) {
 550          currentState = currentState.put(47 /* SLASH */, false, false);
 551          pattern += "/";
 552      }
 553      currentState.handlers = handlers;
 554      currentState.pattern = pattern + "$";
 555      currentState.types = types;
 556      var name;
 557      if (typeof options === "object" && options !== null && options.as) {
 558          name = options.as;
 559      }
 560      if (name) {
 561          // if (this.names[name]) {
 562          //   throw new Error("You may not add a duplicate route named `" + name + "`.");
 563          // }
 564          this.names[name] = {
 565              segments: allSegments,
 566              handlers: handlers
 567          };
 568      }
 569  };
 570  RouteRecognizer.prototype.handlersFor = function handlersFor (name) {
 571      var route = this.names[name];
 572      if (!route) {
 573          throw new Error("There is no route named " + name);
 574      }
 575      var result = new Array(route.handlers.length);
 576      for (var i = 0; i < route.handlers.length; i++) {
 577          var handler = route.handlers[i];
 578          result[i] = handler;
 579      }
 580      return result;
 581  };
 582  RouteRecognizer.prototype.hasRoute = function hasRoute (name) {
 583      return !!this.names[name];
 584  };
 585  RouteRecognizer.prototype.generate = function generate$1 (name, params) {
 586      var route = this.names[name];
 587      var output = "";
 588      if (!route) {
 589          throw new Error("There is no route named " + name);
 590      }
 591      var segments = route.segments;
 592      for (var i = 0; i < segments.length; i++) {
 593          var segment = segments[i];
 594          if (segment.type === 4 /* Epsilon */) {
 595              continue;
 596          }
 597          output += "/";
 598          output += generate[segment.type](segment, params);
 599      }
 600      if (output.charAt(0) !== "/") {
 601          output = "/" + output;
 602      }
 603      if (params && params.queryParams) {
 604          output += this.generateQueryString(params.queryParams);
 605      }
 606      return output;
 607  };
 608  RouteRecognizer.prototype.generateQueryString = function generateQueryString (params) {
 609      var pairs = [];
 610      var keys = Object.keys(params);
 611      keys.sort();
 612      for (var i = 0; i < keys.length; i++) {
 613          var key = keys[i];
 614          var value = params[key];
 615          if (value == null) {
 616              continue;
 617          }
 618          var pair = encodeURIComponent(key);
 619          if (isArray(value)) {
 620              for (var j = 0; j < value.length; j++) {
 621                  var arrayPair = key + "[]" + "=" + encodeURIComponent(value[j]);
 622                  pairs.push(arrayPair);
 623              }
 624          }
 625          else {
 626              pair += "=" + encodeURIComponent(value);
 627              pairs.push(pair);
 628          }
 629      }
 630      if (pairs.length === 0) {
 631          return "";
 632      }
 633      return "?" + pairs.join("&");
 634  };
 635  RouteRecognizer.prototype.parseQueryString = function parseQueryString (queryString) {
 636      var pairs = queryString.split("&");
 637      var queryParams = {};
 638      for (var i = 0; i < pairs.length; i++) {
 639          var pair = pairs[i].split("="), key = decodeQueryParamPart(pair[0]), keyLength = key.length, isArray = false, value = (void 0);
 640          if (pair.length === 1) {
 641              value = "true";
 642          }
 643          else {
 644              // Handle arrays
 645              if (keyLength > 2 && key.slice(keyLength - 2) === "[]") {
 646                  isArray = true;
 647                  key = key.slice(0, keyLength - 2);
 648                  if (!queryParams[key]) {
 649                      queryParams[key] = [];
 650                  }
 651              }
 652              value = pair[1] ? decodeQueryParamPart(pair[1]) : "";
 653          }
 654          if (isArray) {
 655              queryParams[key].push(value);
 656          }
 657          else {
 658              queryParams[key] = value;
 659          }
 660      }
 661      return queryParams;
 662  };
 663  RouteRecognizer.prototype.recognize = function recognize (path) {
 664      var results;
 665      var states = [this.rootState];
 666      var queryParams = {};
 667      var isSlashDropped = false;
 668      var hashStart = path.indexOf("#");
 669      if (hashStart !== -1) {
 670          path = path.substr(0, hashStart);
 671      }
 672      var queryStart = path.indexOf("?");
 673      if (queryStart !== -1) {
 674          var queryString = path.substr(queryStart + 1, path.length);
 675          path = path.substr(0, queryStart);
 676          queryParams = this.parseQueryString(queryString);
 677      }
 678      if (path.charAt(0) !== "/") {
 679          path = "/" + path;
 680      }
 681      var originalPath = path;
 682      if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS) {
 683          path = normalizePath(path);
 684      }
 685      else {
 686          path = decodeURI(path);
 687          originalPath = decodeURI(originalPath);
 688      }
 689      var pathLen = path.length;
 690      if (pathLen > 1 && path.charAt(pathLen - 1) === "/") {
 691          path = path.substr(0, pathLen - 1);
 692          originalPath = originalPath.substr(0, originalPath.length - 1);
 693          isSlashDropped = true;
 694      }
 695      for (var i = 0; i < path.length; i++) {
 696          states = recognizeChar(states, path.charCodeAt(i));
 697          if (!states.length) {
 698              break;
 699          }
 700      }
 701      var solutions = [];
 702      for (var i$1 = 0; i$1 < states.length; i$1++) {
 703          if (states[i$1].handlers) {
 704              solutions.push(states[i$1]);
 705          }
 706      }
 707      states = sortSolutions(solutions);
 708      var state = solutions[0];
 709      if (state && state.handlers) {
 710          // if a trailing slash was dropped and a star segment is the last segment
 711          // specified, put the trailing slash back
 712          if (isSlashDropped && state.pattern && state.pattern.slice(-5) === "(.+)$") {
 713              originalPath = originalPath + "/";
 714          }
 715          results = findHandler(state, originalPath, queryParams);
 716      }
 717      return results;
 718  };
 719  RouteRecognizer.VERSION = "0.3.4";
 720  // Set to false to opt-out of encoding and decoding path segments.
 721  // See https://github.com/tildeio/route-recognizer/pull/55
 722  RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS = true;
 723  RouteRecognizer.Normalizer = {
 724      normalizeSegment: normalizeSegment, normalizePath: normalizePath, encodePathSegment: encodePathSegment
 725  };
 726  RouteRecognizer.prototype.map = map;
 727  
 728  /* harmony default export */ const route_recognizer_es = (RouteRecognizer);
 729  
 730  
 731  ;// ./node_modules/@babel/runtime/helpers/esm/extends.js
 732  function extends_extends() {
 733    return extends_extends = Object.assign ? Object.assign.bind() : function (n) {
 734      for (var e = 1; e < arguments.length; e++) {
 735        var t = arguments[e];
 736        for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
 737      }
 738      return n;
 739    }, extends_extends.apply(null, arguments);
 740  }
 741  
 742  ;// ./node_modules/history/index.js
 743  
 744  
 745  /**

 746   * Actions represent the type of change to a location value.

 747   *

 748   * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#action

 749   */
 750  var Action;
 751  
 752  (function (Action) {
 753    /**

 754     * A POP indicates a change to an arbitrary index in the history stack, such

 755     * as a back or forward navigation. It does not describe the direction of the

 756     * navigation, only that the current index changed.

 757     *

 758     * Note: This is the default action for newly created history objects.

 759     */
 760    Action["Pop"] = "POP";
 761    /**

 762     * A PUSH indicates a new entry being added to the history stack, such as when

 763     * a link is clicked and a new page loads. When this happens, all subsequent

 764     * entries in the stack are lost.

 765     */
 766  
 767    Action["Push"] = "PUSH";
 768    /**

 769     * A REPLACE indicates the entry at the current index in the history stack

 770     * being replaced by a new one.

 771     */
 772  
 773    Action["Replace"] = "REPLACE";
 774  })(Action || (Action = {}));
 775  
 776  var readOnly =  false ? 0 : function (obj) {
 777    return obj;
 778  };
 779  
 780  function warning(cond, message) {
 781    if (!cond) {
 782      // eslint-disable-next-line no-console
 783      if (typeof console !== 'undefined') console.warn(message);
 784  
 785      try {
 786        // Welcome to debugging history!
 787        //
 788        // This error is thrown as a convenience so you can more easily
 789        // find the source for a warning that appears in the console by
 790        // enabling "pause on exceptions" in your JavaScript debugger.
 791        throw new Error(message); // eslint-disable-next-line no-empty
 792      } catch (e) {}
 793    }
 794  }
 795  
 796  var BeforeUnloadEventType = 'beforeunload';
 797  var HashChangeEventType = 'hashchange';
 798  var PopStateEventType = 'popstate';
 799  /**

 800   * Browser history stores the location in regular URLs. This is the standard for

 801   * most web apps, but it requires some configuration on the server to ensure you

 802   * serve the same app at multiple URLs.

 803   *

 804   * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory

 805   */
 806  
 807  function createBrowserHistory(options) {
 808    if (options === void 0) {
 809      options = {};
 810    }
 811  
 812    var _options = options,
 813        _options$window = _options.window,
 814        window = _options$window === void 0 ? document.defaultView : _options$window;
 815    var globalHistory = window.history;
 816  
 817    function getIndexAndLocation() {
 818      var _window$location = window.location,
 819          pathname = _window$location.pathname,
 820          search = _window$location.search,
 821          hash = _window$location.hash;
 822      var state = globalHistory.state || {};
 823      return [state.idx, readOnly({
 824        pathname: pathname,
 825        search: search,
 826        hash: hash,
 827        state: state.usr || null,
 828        key: state.key || 'default'
 829      })];
 830    }
 831  
 832    var blockedPopTx = null;
 833  
 834    function handlePop() {
 835      if (blockedPopTx) {
 836        blockers.call(blockedPopTx);
 837        blockedPopTx = null;
 838      } else {
 839        var nextAction = Action.Pop;
 840  
 841        var _getIndexAndLocation = getIndexAndLocation(),
 842            nextIndex = _getIndexAndLocation[0],
 843            nextLocation = _getIndexAndLocation[1];
 844  
 845        if (blockers.length) {
 846          if (nextIndex != null) {
 847            var delta = index - nextIndex;
 848  
 849            if (delta) {
 850              // Revert the POP
 851              blockedPopTx = {
 852                action: nextAction,
 853                location: nextLocation,
 854                retry: function retry() {
 855                  go(delta * -1);
 856                }
 857              };
 858              go(delta);
 859            }
 860          } else {
 861            // Trying to POP to a location with no index. We did not create
 862            // this location, so we can't effectively block the navigation.
 863             false ? 0 : void 0;
 864          }
 865        } else {
 866          applyTx(nextAction);
 867        }
 868      }
 869    }
 870  
 871    window.addEventListener(PopStateEventType, handlePop);
 872    var action = Action.Pop;
 873  
 874    var _getIndexAndLocation2 = getIndexAndLocation(),
 875        index = _getIndexAndLocation2[0],
 876        location = _getIndexAndLocation2[1];
 877  
 878    var listeners = createEvents();
 879    var blockers = createEvents();
 880  
 881    if (index == null) {
 882      index = 0;
 883      globalHistory.replaceState(extends_extends({}, globalHistory.state, {
 884        idx: index
 885      }), '');
 886    }
 887  
 888    function createHref(to) {
 889      return typeof to === 'string' ? to : createPath(to);
 890    } // state defaults to `null` because `window.history.state` does
 891  
 892  
 893    function getNextLocation(to, state) {
 894      if (state === void 0) {
 895        state = null;
 896      }
 897  
 898      return readOnly(extends_extends({
 899        pathname: location.pathname,
 900        hash: '',
 901        search: ''
 902      }, typeof to === 'string' ? parsePath(to) : to, {
 903        state: state,
 904        key: createKey()
 905      }));
 906    }
 907  
 908    function getHistoryStateAndUrl(nextLocation, index) {
 909      return [{
 910        usr: nextLocation.state,
 911        key: nextLocation.key,
 912        idx: index
 913      }, createHref(nextLocation)];
 914    }
 915  
 916    function allowTx(action, location, retry) {
 917      return !blockers.length || (blockers.call({
 918        action: action,
 919        location: location,
 920        retry: retry
 921      }), false);
 922    }
 923  
 924    function applyTx(nextAction) {
 925      action = nextAction;
 926  
 927      var _getIndexAndLocation3 = getIndexAndLocation();
 928  
 929      index = _getIndexAndLocation3[0];
 930      location = _getIndexAndLocation3[1];
 931      listeners.call({
 932        action: action,
 933        location: location
 934      });
 935    }
 936  
 937    function push(to, state) {
 938      var nextAction = Action.Push;
 939      var nextLocation = getNextLocation(to, state);
 940  
 941      function retry() {
 942        push(to, state);
 943      }
 944  
 945      if (allowTx(nextAction, nextLocation, retry)) {
 946        var _getHistoryStateAndUr = getHistoryStateAndUrl(nextLocation, index + 1),
 947            historyState = _getHistoryStateAndUr[0],
 948            url = _getHistoryStateAndUr[1]; // TODO: Support forced reloading
 949        // try...catch because iOS limits us to 100 pushState calls :/
 950  
 951  
 952        try {
 953          globalHistory.pushState(historyState, '', url);
 954        } catch (error) {
 955          // They are going to lose state here, but there is no real
 956          // way to warn them about it since the page will refresh...
 957          window.location.assign(url);
 958        }
 959  
 960        applyTx(nextAction);
 961      }
 962    }
 963  
 964    function replace(to, state) {
 965      var nextAction = Action.Replace;
 966      var nextLocation = getNextLocation(to, state);
 967  
 968      function retry() {
 969        replace(to, state);
 970      }
 971  
 972      if (allowTx(nextAction, nextLocation, retry)) {
 973        var _getHistoryStateAndUr2 = getHistoryStateAndUrl(nextLocation, index),
 974            historyState = _getHistoryStateAndUr2[0],
 975            url = _getHistoryStateAndUr2[1]; // TODO: Support forced reloading
 976  
 977  
 978        globalHistory.replaceState(historyState, '', url);
 979        applyTx(nextAction);
 980      }
 981    }
 982  
 983    function go(delta) {
 984      globalHistory.go(delta);
 985    }
 986  
 987    var history = {
 988      get action() {
 989        return action;
 990      },
 991  
 992      get location() {
 993        return location;
 994      },
 995  
 996      createHref: createHref,
 997      push: push,
 998      replace: replace,
 999      go: go,
1000      back: function back() {
1001        go(-1);
1002      },
1003      forward: function forward() {
1004        go(1);
1005      },
1006      listen: function listen(listener) {
1007        return listeners.push(listener);
1008      },
1009      block: function block(blocker) {
1010        var unblock = blockers.push(blocker);
1011  
1012        if (blockers.length === 1) {
1013          window.addEventListener(BeforeUnloadEventType, promptBeforeUnload);
1014        }
1015  
1016        return function () {
1017          unblock(); // Remove the beforeunload listener so the document may
1018          // still be salvageable in the pagehide event.
1019          // See https://html.spec.whatwg.org/#unloading-documents
1020  
1021          if (!blockers.length) {
1022            window.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);
1023          }
1024        };
1025      }
1026    };
1027    return history;
1028  }
1029  /**

1030   * Hash history stores the location in window.location.hash. This makes it ideal

1031   * for situations where you don't want to send the location to the server for

1032   * some reason, either because you do cannot configure it or the URL space is

1033   * reserved for something else.

1034   *

1035   * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory

1036   */
1037  
1038  function createHashHistory(options) {
1039    if (options === void 0) {
1040      options = {};
1041    }
1042  
1043    var _options2 = options,
1044        _options2$window = _options2.window,
1045        window = _options2$window === void 0 ? document.defaultView : _options2$window;
1046    var globalHistory = window.history;
1047  
1048    function getIndexAndLocation() {
1049      var _parsePath = parsePath(window.location.hash.substr(1)),
1050          _parsePath$pathname = _parsePath.pathname,
1051          pathname = _parsePath$pathname === void 0 ? '/' : _parsePath$pathname,
1052          _parsePath$search = _parsePath.search,
1053          search = _parsePath$search === void 0 ? '' : _parsePath$search,
1054          _parsePath$hash = _parsePath.hash,
1055          hash = _parsePath$hash === void 0 ? '' : _parsePath$hash;
1056  
1057      var state = globalHistory.state || {};
1058      return [state.idx, readOnly({
1059        pathname: pathname,
1060        search: search,
1061        hash: hash,
1062        state: state.usr || null,
1063        key: state.key || 'default'
1064      })];
1065    }
1066  
1067    var blockedPopTx = null;
1068  
1069    function handlePop() {
1070      if (blockedPopTx) {
1071        blockers.call(blockedPopTx);
1072        blockedPopTx = null;
1073      } else {
1074        var nextAction = Action.Pop;
1075  
1076        var _getIndexAndLocation4 = getIndexAndLocation(),
1077            nextIndex = _getIndexAndLocation4[0],
1078            nextLocation = _getIndexAndLocation4[1];
1079  
1080        if (blockers.length) {
1081          if (nextIndex != null) {
1082            var delta = index - nextIndex;
1083  
1084            if (delta) {
1085              // Revert the POP
1086              blockedPopTx = {
1087                action: nextAction,
1088                location: nextLocation,
1089                retry: function retry() {
1090                  go(delta * -1);
1091                }
1092              };
1093              go(delta);
1094            }
1095          } else {
1096            // Trying to POP to a location with no index. We did not create
1097            // this location, so we can't effectively block the navigation.
1098             false ? 0 : void 0;
1099          }
1100        } else {
1101          applyTx(nextAction);
1102        }
1103      }
1104    }
1105  
1106    window.addEventListener(PopStateEventType, handlePop); // popstate does not fire on hashchange in IE 11 and old (trident) Edge
1107    // https://developer.mozilla.org/de/docs/Web/API/Window/popstate_event
1108  
1109    window.addEventListener(HashChangeEventType, function () {
1110      var _getIndexAndLocation5 = getIndexAndLocation(),
1111          nextLocation = _getIndexAndLocation5[1]; // Ignore extraneous hashchange events.
1112  
1113  
1114      if (createPath(nextLocation) !== createPath(location)) {
1115        handlePop();
1116      }
1117    });
1118    var action = Action.Pop;
1119  
1120    var _getIndexAndLocation6 = getIndexAndLocation(),
1121        index = _getIndexAndLocation6[0],
1122        location = _getIndexAndLocation6[1];
1123  
1124    var listeners = createEvents();
1125    var blockers = createEvents();
1126  
1127    if (index == null) {
1128      index = 0;
1129      globalHistory.replaceState(_extends({}, globalHistory.state, {
1130        idx: index
1131      }), '');
1132    }
1133  
1134    function getBaseHref() {
1135      var base = document.querySelector('base');
1136      var href = '';
1137  
1138      if (base && base.getAttribute('href')) {
1139        var url = window.location.href;
1140        var hashIndex = url.indexOf('#');
1141        href = hashIndex === -1 ? url : url.slice(0, hashIndex);
1142      }
1143  
1144      return href;
1145    }
1146  
1147    function createHref(to) {
1148      return getBaseHref() + '#' + (typeof to === 'string' ? to : createPath(to));
1149    }
1150  
1151    function getNextLocation(to, state) {
1152      if (state === void 0) {
1153        state = null;
1154      }
1155  
1156      return readOnly(_extends({
1157        pathname: location.pathname,
1158        hash: '',
1159        search: ''
1160      }, typeof to === 'string' ? parsePath(to) : to, {
1161        state: state,
1162        key: createKey()
1163      }));
1164    }
1165  
1166    function getHistoryStateAndUrl(nextLocation, index) {
1167      return [{
1168        usr: nextLocation.state,
1169        key: nextLocation.key,
1170        idx: index
1171      }, createHref(nextLocation)];
1172    }
1173  
1174    function allowTx(action, location, retry) {
1175      return !blockers.length || (blockers.call({
1176        action: action,
1177        location: location,
1178        retry: retry
1179      }), false);
1180    }
1181  
1182    function applyTx(nextAction) {
1183      action = nextAction;
1184  
1185      var _getIndexAndLocation7 = getIndexAndLocation();
1186  
1187      index = _getIndexAndLocation7[0];
1188      location = _getIndexAndLocation7[1];
1189      listeners.call({
1190        action: action,
1191        location: location
1192      });
1193    }
1194  
1195    function push(to, state) {
1196      var nextAction = Action.Push;
1197      var nextLocation = getNextLocation(to, state);
1198  
1199      function retry() {
1200        push(to, state);
1201      }
1202  
1203       false ? 0 : void 0;
1204  
1205      if (allowTx(nextAction, nextLocation, retry)) {
1206        var _getHistoryStateAndUr3 = getHistoryStateAndUrl(nextLocation, index + 1),
1207            historyState = _getHistoryStateAndUr3[0],
1208            url = _getHistoryStateAndUr3[1]; // TODO: Support forced reloading
1209        // try...catch because iOS limits us to 100 pushState calls :/
1210  
1211  
1212        try {
1213          globalHistory.pushState(historyState, '', url);
1214        } catch (error) {
1215          // They are going to lose state here, but there is no real
1216          // way to warn them about it since the page will refresh...
1217          window.location.assign(url);
1218        }
1219  
1220        applyTx(nextAction);
1221      }
1222    }
1223  
1224    function replace(to, state) {
1225      var nextAction = Action.Replace;
1226      var nextLocation = getNextLocation(to, state);
1227  
1228      function retry() {
1229        replace(to, state);
1230      }
1231  
1232       false ? 0 : void 0;
1233  
1234      if (allowTx(nextAction, nextLocation, retry)) {
1235        var _getHistoryStateAndUr4 = getHistoryStateAndUrl(nextLocation, index),
1236            historyState = _getHistoryStateAndUr4[0],
1237            url = _getHistoryStateAndUr4[1]; // TODO: Support forced reloading
1238  
1239  
1240        globalHistory.replaceState(historyState, '', url);
1241        applyTx(nextAction);
1242      }
1243    }
1244  
1245    function go(delta) {
1246      globalHistory.go(delta);
1247    }
1248  
1249    var history = {
1250      get action() {
1251        return action;
1252      },
1253  
1254      get location() {
1255        return location;
1256      },
1257  
1258      createHref: createHref,
1259      push: push,
1260      replace: replace,
1261      go: go,
1262      back: function back() {
1263        go(-1);
1264      },
1265      forward: function forward() {
1266        go(1);
1267      },
1268      listen: function listen(listener) {
1269        return listeners.push(listener);
1270      },
1271      block: function block(blocker) {
1272        var unblock = blockers.push(blocker);
1273  
1274        if (blockers.length === 1) {
1275          window.addEventListener(BeforeUnloadEventType, promptBeforeUnload);
1276        }
1277  
1278        return function () {
1279          unblock(); // Remove the beforeunload listener so the document may
1280          // still be salvageable in the pagehide event.
1281          // See https://html.spec.whatwg.org/#unloading-documents
1282  
1283          if (!blockers.length) {
1284            window.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);
1285          }
1286        };
1287      }
1288    };
1289    return history;
1290  }
1291  /**

1292   * Memory history stores the current location in memory. It is designed for use

1293   * in stateful non-browser environments like tests and React Native.

1294   *

1295   * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#creatememoryhistory

1296   */
1297  
1298  function createMemoryHistory(options) {
1299    if (options === void 0) {
1300      options = {};
1301    }
1302  
1303    var _options3 = options,
1304        _options3$initialEntr = _options3.initialEntries,
1305        initialEntries = _options3$initialEntr === void 0 ? ['/'] : _options3$initialEntr,
1306        initialIndex = _options3.initialIndex;
1307    var entries = initialEntries.map(function (entry) {
1308      var location = readOnly(_extends({
1309        pathname: '/',
1310        search: '',
1311        hash: '',
1312        state: null,
1313        key: createKey()
1314      }, typeof entry === 'string' ? parsePath(entry) : entry));
1315       false ? 0 : void 0;
1316      return location;
1317    });
1318    var index = clamp(initialIndex == null ? entries.length - 1 : initialIndex, 0, entries.length - 1);
1319    var action = Action.Pop;
1320    var location = entries[index];
1321    var listeners = createEvents();
1322    var blockers = createEvents();
1323  
1324    function createHref(to) {
1325      return typeof to === 'string' ? to : createPath(to);
1326    }
1327  
1328    function getNextLocation(to, state) {
1329      if (state === void 0) {
1330        state = null;
1331      }
1332  
1333      return readOnly(_extends({
1334        pathname: location.pathname,
1335        search: '',
1336        hash: ''
1337      }, typeof to === 'string' ? parsePath(to) : to, {
1338        state: state,
1339        key: createKey()
1340      }));
1341    }
1342  
1343    function allowTx(action, location, retry) {
1344      return !blockers.length || (blockers.call({
1345        action: action,
1346        location: location,
1347        retry: retry
1348      }), false);
1349    }
1350  
1351    function applyTx(nextAction, nextLocation) {
1352      action = nextAction;
1353      location = nextLocation;
1354      listeners.call({
1355        action: action,
1356        location: location
1357      });
1358    }
1359  
1360    function push(to, state) {
1361      var nextAction = Action.Push;
1362      var nextLocation = getNextLocation(to, state);
1363  
1364      function retry() {
1365        push(to, state);
1366      }
1367  
1368       false ? 0 : void 0;
1369  
1370      if (allowTx(nextAction, nextLocation, retry)) {
1371        index += 1;
1372        entries.splice(index, entries.length, nextLocation);
1373        applyTx(nextAction, nextLocation);
1374      }
1375    }
1376  
1377    function replace(to, state) {
1378      var nextAction = Action.Replace;
1379      var nextLocation = getNextLocation(to, state);
1380  
1381      function retry() {
1382        replace(to, state);
1383      }
1384  
1385       false ? 0 : void 0;
1386  
1387      if (allowTx(nextAction, nextLocation, retry)) {
1388        entries[index] = nextLocation;
1389        applyTx(nextAction, nextLocation);
1390      }
1391    }
1392  
1393    function go(delta) {
1394      var nextIndex = clamp(index + delta, 0, entries.length - 1);
1395      var nextAction = Action.Pop;
1396      var nextLocation = entries[nextIndex];
1397  
1398      function retry() {
1399        go(delta);
1400      }
1401  
1402      if (allowTx(nextAction, nextLocation, retry)) {
1403        index = nextIndex;
1404        applyTx(nextAction, nextLocation);
1405      }
1406    }
1407  
1408    var history = {
1409      get index() {
1410        return index;
1411      },
1412  
1413      get action() {
1414        return action;
1415      },
1416  
1417      get location() {
1418        return location;
1419      },
1420  
1421      createHref: createHref,
1422      push: push,
1423      replace: replace,
1424      go: go,
1425      back: function back() {
1426        go(-1);
1427      },
1428      forward: function forward() {
1429        go(1);
1430      },
1431      listen: function listen(listener) {
1432        return listeners.push(listener);
1433      },
1434      block: function block(blocker) {
1435        return blockers.push(blocker);
1436      }
1437    };
1438    return history;
1439  } ////////////////////////////////////////////////////////////////////////////////
1440  // UTILS
1441  ////////////////////////////////////////////////////////////////////////////////
1442  
1443  function clamp(n, lowerBound, upperBound) {
1444    return Math.min(Math.max(n, lowerBound), upperBound);
1445  }
1446  
1447  function promptBeforeUnload(event) {
1448    // Cancel the event.
1449    event.preventDefault(); // Chrome (and legacy IE) requires returnValue to be set.
1450  
1451    event.returnValue = '';
1452  }
1453  
1454  function createEvents() {
1455    var handlers = [];
1456    return {
1457      get length() {
1458        return handlers.length;
1459      },
1460  
1461      push: function push(fn) {
1462        handlers.push(fn);
1463        return function () {
1464          handlers = handlers.filter(function (handler) {
1465            return handler !== fn;
1466          });
1467        };
1468      },
1469      call: function call(arg) {
1470        handlers.forEach(function (fn) {
1471          return fn && fn(arg);
1472        });
1473      }
1474    };
1475  }
1476  
1477  function createKey() {
1478    return Math.random().toString(36).substr(2, 8);
1479  }
1480  /**

1481   * Creates a string URL path from the given pathname, search, and hash components.

1482   *

1483   * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createpath

1484   */
1485  
1486  
1487  function createPath(_ref) {
1488    var _ref$pathname = _ref.pathname,
1489        pathname = _ref$pathname === void 0 ? '/' : _ref$pathname,
1490        _ref$search = _ref.search,
1491        search = _ref$search === void 0 ? '' : _ref$search,
1492        _ref$hash = _ref.hash,
1493        hash = _ref$hash === void 0 ? '' : _ref$hash;
1494    if (search && search !== '?') pathname += search.charAt(0) === '?' ? search : '?' + search;
1495    if (hash && hash !== '#') pathname += hash.charAt(0) === '#' ? hash : '#' + hash;
1496    return pathname;
1497  }
1498  /**

1499   * Parses a string URL path into its separate pathname, search, and hash components.

1500   *

1501   * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#parsepath

1502   */
1503  
1504  function parsePath(path) {
1505    var parsedPath = {};
1506  
1507    if (path) {
1508      var hashIndex = path.indexOf('#');
1509  
1510      if (hashIndex >= 0) {
1511        parsedPath.hash = path.substr(hashIndex);
1512        path = path.substr(0, hashIndex);
1513      }
1514  
1515      var searchIndex = path.indexOf('?');
1516  
1517      if (searchIndex >= 0) {
1518        parsedPath.search = path.substr(searchIndex);
1519        path = path.substr(0, searchIndex);
1520      }
1521  
1522      if (path) {
1523        parsedPath.pathname = path;
1524      }
1525    }
1526  
1527    return parsedPath;
1528  }
1529  
1530  
1531  
1532  ;// external ["wp","element"]
1533  const external_wp_element_namespaceObject = window["wp"]["element"];
1534  ;// external ["wp","url"]
1535  const external_wp_url_namespaceObject = window["wp"]["url"];
1536  ;// external ["wp","compose"]
1537  const external_wp_compose_namespaceObject = window["wp"]["compose"];
1538  ;// external "ReactJSXRuntime"
1539  const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
1540  ;// ./node_modules/@wordpress/router/build-module/router.js
1541  /* wp:polyfill */
1542  /**
1543   * External dependencies
1544   */
1545  
1546  
1547  
1548  /**
1549   * WordPress dependencies
1550   */
1551  
1552  
1553  
1554  
1555  /**
1556   * Internal dependencies
1557   */
1558  
1559  const router_history = createBrowserHistory();
1560  const RoutesContext = (0,external_wp_element_namespaceObject.createContext)(null);
1561  const ConfigContext = (0,external_wp_element_namespaceObject.createContext)({
1562    pathArg: 'p'
1563  });
1564  const locationMemo = new WeakMap();
1565  function getLocationWithQuery() {
1566    const location = router_history.location;
1567    let locationWithQuery = locationMemo.get(location);
1568    if (!locationWithQuery) {
1569      locationWithQuery = {
1570        ...location,
1571        query: Object.fromEntries(new URLSearchParams(location.search))
1572      };
1573      locationMemo.set(location, locationWithQuery);
1574    }
1575    return locationWithQuery;
1576  }
1577  function useLocation() {
1578    const context = (0,external_wp_element_namespaceObject.useContext)(RoutesContext);
1579    if (!context) {
1580      throw new Error('useLocation must be used within a RouterProvider');
1581    }
1582    return context;
1583  }
1584  function useHistory() {
1585    const {
1586      pathArg,
1587      beforeNavigate
1588    } = (0,external_wp_element_namespaceObject.useContext)(ConfigContext);
1589    const navigate = (0,external_wp_compose_namespaceObject.useEvent)(async (rawPath, options = {}) => {
1590      var _getPath;
1591      const query = (0,external_wp_url_namespaceObject.getQueryArgs)(rawPath);
1592      const path = (_getPath = (0,external_wp_url_namespaceObject.getPath)('http://domain.com/' + rawPath)) !== null && _getPath !== void 0 ? _getPath : '';
1593      const performPush = () => {
1594        const result = beforeNavigate ? beforeNavigate({
1595          path,
1596          query
1597        }) : {
1598          path,
1599          query
1600        };
1601        return router_history.push({
1602          search: (0,external_wp_url_namespaceObject.buildQueryString)({
1603            [pathArg]: result.path,
1604            ...result.query
1605          })
1606        }, options.state);
1607      };
1608  
1609      /*
1610       * Skip transition in mobile, otherwise it crashes the browser.
1611       * See: https://github.com/WordPress/gutenberg/pull/63002.
1612       */
1613      const isMediumOrBigger = window.matchMedia('(min-width: 782px)').matches;
1614      if (!isMediumOrBigger || !document.startViewTransition || !options.transition) {
1615        performPush();
1616        return;
1617      }
1618      await new Promise(resolve => {
1619        var _options$transition;
1620        const classname = (_options$transition = options.transition) !== null && _options$transition !== void 0 ? _options$transition : '';
1621        document.documentElement.classList.add(classname);
1622        const transition = document.startViewTransition(() => performPush());
1623        transition.finished.finally(() => {
1624          document.documentElement.classList.remove(classname);
1625          resolve();
1626        });
1627      });
1628    });
1629    return (0,external_wp_element_namespaceObject.useMemo)(() => ({
1630      navigate,
1631      back: router_history.back
1632    }), [navigate]);
1633  }
1634  function useMatch(location, matcher, pathArg) {
1635    const {
1636      query: rawQuery = {}
1637    } = location;
1638    return (0,external_wp_element_namespaceObject.useMemo)(() => {
1639      const {
1640        [pathArg]: path = '/',
1641        ...query
1642      } = rawQuery;
1643      const result = matcher.recognize(path)?.[0];
1644      if (!result) {
1645        return {
1646          name: '404',
1647          path: (0,external_wp_url_namespaceObject.addQueryArgs)(path, query),
1648          areas: {},
1649          widths: {},
1650          query,
1651          params: {}
1652        };
1653      }
1654      const matchedRoute = result.handler;
1655      const resolveFunctions = (record = {}) => {
1656        return Object.fromEntries(Object.entries(record).map(([key, value]) => {
1657          if (typeof value === 'function') {
1658            return [key, value({
1659              query,
1660              params: result.params
1661            })];
1662          }
1663          return [key, value];
1664        }));
1665      };
1666      return {
1667        name: matchedRoute.name,
1668        areas: resolveFunctions(matchedRoute.areas),
1669        widths: resolveFunctions(matchedRoute.widths),
1670        params: result.params,
1671        query,
1672        path: (0,external_wp_url_namespaceObject.addQueryArgs)(path, query)
1673      };
1674    }, [matcher, rawQuery, pathArg]);
1675  }
1676  function RouterProvider({
1677    routes,
1678    pathArg,
1679    beforeNavigate,
1680    children
1681  }) {
1682    const location = (0,external_wp_element_namespaceObject.useSyncExternalStore)(router_history.listen, getLocationWithQuery, getLocationWithQuery);
1683    const matcher = (0,external_wp_element_namespaceObject.useMemo)(() => {
1684      const ret = new route_recognizer_es();
1685      routes.forEach(route => {
1686        ret.add([{
1687          path: route.path,
1688          handler: route
1689        }], {
1690          as: route.name
1691        });
1692      });
1693      return ret;
1694    }, [routes]);
1695    const match = useMatch(location, matcher, pathArg);
1696    const config = (0,external_wp_element_namespaceObject.useMemo)(() => ({
1697      beforeNavigate,
1698      pathArg
1699    }), [beforeNavigate, pathArg]);
1700    return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ConfigContext.Provider, {
1701      value: config,
1702      children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RoutesContext.Provider, {
1703        value: match,
1704        children: children
1705      })
1706    });
1707  }
1708  
1709  ;// ./node_modules/@wordpress/router/build-module/link.js
1710  /**
1711   * WordPress dependencies
1712   */
1713  
1714  
1715  
1716  /**
1717   * Internal dependencies
1718   */
1719  
1720  
1721  function useLink(to, options = {}) {
1722    var _getPath;
1723    const history = useHistory();
1724    const {
1725      pathArg,
1726      beforeNavigate
1727    } = (0,external_wp_element_namespaceObject.useContext)(ConfigContext);
1728    function onClick(event) {
1729      event?.preventDefault();
1730      history.navigate(to, options);
1731    }
1732    const query = (0,external_wp_url_namespaceObject.getQueryArgs)(to);
1733    const path = (_getPath = (0,external_wp_url_namespaceObject.getPath)('http://domain.com/' + to)) !== null && _getPath !== void 0 ? _getPath : '';
1734    const link = (0,external_wp_element_namespaceObject.useMemo)(() => {
1735      return beforeNavigate ? beforeNavigate({
1736        path,
1737        query
1738      }) : {
1739        path,
1740        query
1741      };
1742    }, [path, query, beforeNavigate]);
1743    const [before] = window.location.href.split('?');
1744    return {
1745      href: `$before}?${(0,external_wp_url_namespaceObject.buildQueryString)({
1746        [pathArg]: link.path,
1747        ...link.query
1748      })}`,
1749      onClick
1750    };
1751  }
1752  function Link({
1753    to,
1754    options,
1755    children,
1756    ...props
1757  }) {
1758    const {
1759      href,
1760      onClick
1761    } = useLink(to, options);
1762    return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("a", {
1763      href: href,
1764      onClick: onClick,
1765      ...props,
1766      children: children
1767    });
1768  }
1769  
1770  ;// external ["wp","privateApis"]
1771  const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
1772  ;// ./node_modules/@wordpress/router/build-module/lock-unlock.js
1773  /**
1774   * WordPress dependencies
1775   */
1776  
1777  const {
1778    lock,
1779    unlock
1780  } = (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');
1781  
1782  ;// ./node_modules/@wordpress/router/build-module/private-apis.js
1783  /**
1784   * Internal dependencies
1785   */
1786  
1787  
1788  
1789  const privateApis = {};
1790  lock(privateApis, {
1791    useHistory: useHistory,
1792    useLocation: useLocation,
1793    RouterProvider: RouterProvider,
1794    useLink: useLink,
1795    Link: Link
1796  });
1797  
1798  ;// ./node_modules/@wordpress/router/build-module/index.js
1799  
1800  
1801  (window.wp = window.wp || {}).router = __webpack_exports__;
1802  /******/ })()
1803  ;


Generated : Sun Mar 9 08:20:01 2025 Cross-referenced by PHPXref