UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

2,751 lines 71.5 kB
"use strict";

var import_immer = require("immer");
var import_vitest = require("vitest");
var import_findFocusedRoute = require("../findFocusedRoute.native.js");
var import_getPathFromState = require("../getPathFromState.native.js");
var import_getStateFromPath = require("../getStateFromPath.native.js");
var changePath = function (state, path) {
  return (0, import_immer.produce)(state, function (draftState) {
    var route = (0, import_findFocusedRoute.findFocusedRoute)(draftState);
    route.path = path;
  });
};
(0, import_vitest.test)("returns undefined for invalid path", function () {
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("//")).toBeUndefined();
});
import_vitest.test.skip("converts path string to initial state", function () {
  var path = "foo/bar/baz%20qux?author=jane%20%26%20co&valid=true";
  var state = {
    routes: [{
      name: "foo",
      state: {
        routes: [{
          name: "bar",
          state: {
            routes: [{
              name: "baz qux",
              params: {
                author: "jane & co",
                valid: "true"
              },
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state))).toEqual(changePath(state, "/foo/bar/baz%20qux?author=jane%20%26%20co&valid=true"));
});
import_vitest.test.skip("decodes encoded params in path", function () {
  var path = "/foo/bar/bar_%23_foo";
  var config = {
    screens: {
      Foo: {
        path: "foo",
        screens: {
          Bar: {
            path: "/bar/:id"
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Bar",
          params: {
            id: "bar_#_foo"
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)(path, config), config)).toEqual(path);
});
import_vitest.test.skip("decodes encoded params in path that have encoded /", function () {
  var path = "/foo/bar/bar_%2F_foo";
  var config = {
    screens: {
      Foo: {
        path: "foo",
        screens: {
          Bar: {
            path: "/bar/:id"
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Bar",
          params: {
            id: "bar_/_foo"
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)(path, config), config)).toEqual(path);
});
import_vitest.test.skip("converts path string to initial state with config", function () {
  var path = "/foo/bar/sweet/apple/baz/jane?count=10&answer=42&valid=true";
  var config = {
    screens: {
      Foo: {
        path: "foo",
        screens: {
          Bar: {
            path: "bar/:type/:fruit",
            screens: {
              Baz: {
                path: "baz/:author",
                parse: {
                  author: function (author) {
                    return author.replace(/^\w/, function (c) {
                      return c.toUpperCase();
                    });
                  },
                  count: Number,
                  valid: Boolean
                },
                stringify: {
                  author: function (author) {
                    return author.toLowerCase();
                  }
                }
              }
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Bar",
          params: {
            fruit: "apple",
            type: "sweet"
          },
          state: {
            routes: [{
              name: "Baz",
              params: {
                author: "Jane",
                count: 10,
                answer: "42",
                valid: true
              },
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
(0, import_vitest.test)("handles leading slash when converting", function () {
  var path = "/foo/bar/?count=42";
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path)).toEqual({
    routes: [{
      name: "foo",
      key: "foo-0",
      state: {
        routes: [{
          name: "bar",
          key: "bar-1",
          params: {
            count: "42"
          },
          path
        }]
      }
    }]
  });
});
(0, import_vitest.test)("handles ending slash when converting", function () {
  var path = "foo/bar/?count=42";
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path)).toEqual({
    routes: [{
      name: "foo",
      key: "foo-0",
      state: {
        routes: [{
          name: "bar",
          key: "bar-1",
          params: {
            count: "42"
          },
          path
        }]
      }
    }]
  });
});
(0, import_vitest.test)("handles route without param", function () {
  var path = "foo/bar";
  var state = {
    routes: [{
      name: "foo",
      key: "foo-0",
      state: {
        routes: [{
          name: "bar",
          key: "bar-1",
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state))).toEqual(changePath(state, "/foo/bar"));
});
import_vitest.test.skip("converts path string to initial state with config with nested screens", function () {
  var path = "/foe/bar/sweet/apple/baz/jane?count=10&answer=42&valid=true";
  var config = {
    screens: {
      Foo: {
        path: "foo",
        screens: {
          Foe: {
            path: "foe",
            exact: true,
            screens: {
              Bar: {
                path: "bar/:type/:fruit",
                screens: {
                  Baz: {
                    path: "baz/:author",
                    parse: {
                      author: function (author) {
                        return author.replace(/^\w/, function (c) {
                          return c.toUpperCase();
                        });
                      },
                      count: Number,
                      valid: Boolean
                    },
                    stringify: {
                      author: function (author) {
                        return author.toLowerCase();
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Foe",
          state: {
            routes: [{
              name: "Bar",
              params: {
                fruit: "apple",
                type: "sweet"
              },
              state: {
                routes: [{
                  name: "Baz",
                  params: {
                    author: "Jane",
                    count: 10,
                    answer: "42",
                    valid: true
                  },
                  path
                }]
              }
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("converts path string to initial state with config with nested screens and unused parse functions", function () {
  var path = "/foe/baz/jane?count=10&answer=42&valid=true";
  var config = {
    screens: {
      Foo: {
        path: "foo",
        screens: {
          Foe: {
            path: "foe",
            exact: true,
            screens: {
              Baz: {
                path: "baz/:author",
                parse: {
                  author: function (author) {
                    return author.replace(/^\w/, function (c) {
                      return c.toUpperCase();
                    });
                  },
                  count: Number,
                  valid: Boolean,
                  id: Boolean
                }
              }
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Foe",
          state: {
            routes: [{
              name: "Baz",
              params: {
                author: "Jane",
                count: 10,
                answer: "42",
                valid: true
              },
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/foe/baz/Jane?count=10&answer=42&valid=true"));
});
import_vitest.test.skip("handles nested object with unused configs and with parse in it", function () {
  var path = "/bar/sweet/apple/foe/bis/jane?count=10&answer=42&valid=true";
  var config = {
    screens: {
      Bar: {
        path: "bar/:type/:fruit",
        screens: {
          Foo: {
            screens: {
              Foe: {
                path: "foe",
                screens: {
                  Baz: {
                    screens: {
                      Bos: {
                        path: "bos",
                        exact: true
                      },
                      Bis: {
                        path: "bis/:author",
                        stringify: {
                          author: function (author) {
                            return author.replace(/^\w/, function (c) {
                              return c.toLowerCase();
                            });
                          }
                        },
                        parse: {
                          author: function (author) {
                            return author.replace(/^\w/, function (c) {
                              return c.toUpperCase();
                            });
                          },
                          count: Number,
                          valid: Boolean
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Bar",
      params: {
        fruit: "apple",
        type: "sweet"
      },
      state: {
        routes: [{
          name: "Foo",
          state: {
            routes: [{
              name: "Foe",
              state: {
                routes: [{
                  name: "Baz",
                  state: {
                    routes: [{
                      name: "Bis",
                      params: {
                        author: "Jane",
                        count: 10,
                        answer: "42",
                        valid: true
                      },
                      path
                    }]
                  }
                }]
              }
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
(0, import_vitest.test)("handles parse in nested object for second route depth", function () {
  var path = "/baz";
  var config = {
    screens: {
      Foo: {
        path: "foo",
        screens: {
          Foe: {
            path: "foe",
            exact: true
          },
          Bar: {
            path: "bar",
            exact: true,
            screens: {
              Baz: {
                path: "baz",
                exact: true
              }
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      key: "Foo-0",
      state: {
        routes: [{
          name: "Bar",
          key: "Bar-1",
          state: {
            routes: [{
              name: "Baz",
              key: "Baz-2",
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
(0, import_vitest.test)("handles parse in nested object for second route depth and and path and parse in roots", function () {
  var path = "/baz";
  var config = {
    screens: {
      Foo: {
        path: "foo/:id",
        parse: {
          id: Number
        },
        stringify: {
          id: function (id) {
            return `id=${id}`;
          }
        },
        screens: {
          Foe: "foe",
          Bar: {
            screens: {
              Baz: {
                path: "baz",
                exact: true
              }
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      key: "Foo-0",
      state: {
        routes: [{
          name: "Bar",
          key: "Bar-1",
          state: {
            routes: [{
              name: "Baz",
              key: "Baz-2",
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handles path at top level", function () {
  var path = "/foo/fruits/apple";
  var config = {
    path: "foo",
    screens: {
      Foo: {
        screens: {
          Fruits: "fruits/:fruit"
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Fruits",
          params: {
            fruit: "apple"
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
(0, import_vitest.test)("handles initialRouteName at top level", function () {
  var path = "/baz";
  var config = {
    initialRouteName: "Boo",
    screens: {
      Foo: {
        screens: {
          Foe: "foe",
          Bar: {
            screens: {
              Baz: "baz"
            }
          }
        }
      }
    }
  };
  var state = {
    index: 1,
    routes: [{
      name: "Boo",
      key: "Boo-0"
    }, {
      name: "Foo",
      key: "Foo-1",
      state: {
        routes: [{
          name: "Bar",
          key: "Bar-2",
          state: {
            routes: [{
              name: "Baz",
              key: "Baz-3",
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
(0, import_vitest.test)("handles initialRouteName inside a screen", function () {
  var path = "/baz";
  var config = {
    screens: {
      Foo: {
        initialRouteName: "Foe",
        screens: {
          Foe: "foe",
          Bar: {
            screens: {
              Baz: "baz"
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      key: "Foo-0",
      state: {
        index: 1,
        routes: [{
          name: "Foe",
          key: "Foe-1"
        }, {
          name: "Bar",
          key: "Bar-2",
          state: {
            routes: [{
              name: "Baz",
              key: "Baz-3",
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
(0, import_vitest.test)("handles initialRouteName included in path", function () {
  var path = "/baz";
  var config = {
    screens: {
      Foo: {
        initialRouteName: "Foe",
        screens: {
          Foe: {
            screens: {
              Baz: "baz"
            }
          },
          Bar: "bar"
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      key: "Foo-0",
      state: {
        routes: [{
          name: "Foe",
          key: "Foe-1",
          state: {
            routes: [{
              name: "Baz",
              key: "Baz-2",
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handles two initialRouteNames", function () {
  var path = "/bar/sweet/apple/foe/bis/jane?answer=42&count=10&valid=true";
  var config = {
    screens: {
      Bar: {
        path: "bar/:type/:fruit",
        screens: {
          Foo: {
            screens: {
              Foe: {
                path: "foe",
                screens: {
                  Baz: {
                    initialRouteName: "Bos",
                    screens: {
                      Bos: {
                        path: "bos",
                        exact: true
                      },
                      Bis: {
                        path: "bis/:author",
                        stringify: {
                          author: function (author) {
                            return author.replace(/^\w/, function (c) {
                              return c.toLowerCase();
                            });
                          }
                        },
                        parse: {
                          author: function (author) {
                            return author.replace(/^\w/, function (c) {
                              return c.toUpperCase();
                            });
                          },
                          count: Number,
                          valid: Boolean
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Bar",
      params: {
        fruit: "apple",
        type: "sweet"
      },
      state: {
        routes: [{
          name: "Foo",
          state: {
            routes: [{
              name: "Foe",
              state: {
                routes: [{
                  name: "Baz",
                  state: {
                    index: 1,
                    routes: [{
                      name: "Bos"
                    }, {
                      name: "Bis",
                      params: {
                        answer: "42",
                        author: "Jane",
                        count: 10,
                        valid: true
                      },
                      path
                    }]
                  }
                }]
              }
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("accepts initialRouteName without config for it", function () {
  var path = "/bar/sweet/apple/foe/bis/jane?answer=42&count=10&valid=true";
  var config = {
    screens: {
      Bar: {
        path: "bar/:type/:fruit",
        screens: {
          Foo: {
            screens: {
              Foe: {
                path: "foe",
                screens: {
                  Baz: {
                    initialRouteName: "Bas",
                    screens: {
                      Bos: {
                        path: "bos",
                        exact: true
                      },
                      Bis: {
                        path: "bis/:author",
                        stringify: {
                          author: function (author) {
                            return author.replace(/^\w/, function (c) {
                              return c.toLowerCase();
                            });
                          }
                        },
                        parse: {
                          author: function (author) {
                            return author.replace(/^\w/, function (c) {
                              return c.toUpperCase();
                            });
                          },
                          count: Number,
                          valid: Boolean
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Bar",
      params: {
        fruit: "apple",
        type: "sweet"
      },
      state: {
        routes: [{
          name: "Foo",
          state: {
            routes: [{
              name: "Foe",
              state: {
                routes: [{
                  name: "Baz",
                  state: {
                    index: 1,
                    routes: [{
                      name: "Bas"
                    }, {
                      name: "Bis",
                      params: {
                        answer: "42",
                        author: "Jane",
                        count: 10,
                        valid: true
                      },
                      path
                    }]
                  }
                }]
              }
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
(0, import_vitest.test)("returns undefined if no matching screen is present (top level path)", function () {
  var path = "/foo/bar";
  var config = {
    path: "qux",
    screens: {
      Foo: {
        screens: {
          Foe: "foo",
          Bar: {
            screens: {
              Baz: "bar"
            }
          }
        }
      }
    }
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toBeUndefined();
});
(0, import_vitest.test)("returns undefined if no matching screen is present", function () {
  var path = "/baz";
  var config = {
    screens: {
      Foo: {
        path: "foo",
        screens: {
          Foe: "foe",
          Bar: {
            screens: {
              Baz: "baz"
            }
          }
        }
      }
    }
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toBeUndefined();
});
(0, import_vitest.test)("returns undefined if path is empty and no matching screen is present", function () {
  var path = "";
  var config = {
    screens: {
      Foo: {
        screens: {
          Foe: "foe",
          Bar: {
            screens: {
              Baz: "baz"
            }
          }
        }
      }
    }
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toBeUndefined();
});
import_vitest.test.skip("returns matching screen if path is empty", function () {
  var path = "";
  var config = {
    screens: {
      Foo: {
        screens: {
          Foe: "foe",
          Bar: {
            screens: {
              Qux: "",
              Baz: "baz"
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Bar",
          state: {
            routes: [{
              name: "Qux",
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, ""));
});
import_vitest.test.skip("returns matching screen if path is only slash", function () {
  var path = "/";
  var config = {
    screens: {
      Foo: {
        screens: {
          Foe: "foe",
          Bar: {
            screens: {
              Qux: "",
              Baz: "baz"
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Bar",
          state: {
            routes: [{
              name: "Qux",
              path: ""
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, ""));
});
(0, import_vitest.test)("returns matching screen with params if path is empty", function () {
  var path = "?foo=42";
  var config = {
    screens: {
      Foo: {
        screens: {
          Foe: "foe",
          Bar: {
            screens: {
              Qux: {
                path: "",
                parse: {
                  foo: Number
                }
              },
              Baz: "baz"
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      key: "Foo-0",
      state: {
        routes: [{
          name: "Bar",
          key: "Bar-1",
          state: {
            routes: [{
              name: "Qux",
              key: "Qux-2",
              params: {
                foo: 42
              },
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/?foo=42"));
});
(0, import_vitest.test)("doesn't match nested screen if path is empty", function () {
  var config = {
    screens: {
      Foo: {
        screens: {
          Foe: "foe",
          Bar: {
            path: "bar",
            screens: {
              Qux: {
                path: "",
                parse: {
                  foo: Number
                }
              }
            }
          }
        }
      }
    }
  };
  var path = "";
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toBeUndefined();
});
import_vitest.test.skip("chooses more exhaustive pattern", function () {
  var path = "/foo/5";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foo/:id",
            parse: {
              id: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bis",
          params: {
            id: 5
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
(0, import_vitest.test)("handles same paths beginnings", function () {
  var path = "/foos";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foos"
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      key: "Foe-0",
      state: {
        index: 1,
        routes: [{
          name: "Foo",
          key: "Foo-1"
        }, {
          name: "Bis",
          key: "Bis-2",
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handles same paths beginnings with params", function () {
  var path = "/foos/5";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foos/:id",
            parse: {
              id: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bis",
          params: {
            id: 5
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handles not taking path with too many segments", function () {
  var path = "/foos/5";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foos/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: "foos/:id/:nip",
            parse: {
              id: Number,
              pwd: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bis",
          params: {
            id: 5
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handles differently ordered params v1", function () {
  var path = "/foos/5/res/20";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foos/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: "foos/:id/res/:pwd",
            parse: {
              id: Number,
              pwd: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            id: 5,
            pwd: 20
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handles differently ordered params v2", function () {
  var path = "/5/20/foos/res";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foos/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: ":id/:pwd/foos/res",
            parse: {
              id: Number,
              pwd: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            id: 5,
            pwd: 20
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handles differently ordered params v3", function () {
  var path = "/foos/5/20/res";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foos/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: "foos/:id/:pwd/res",
            parse: {
              id: Number,
              pwd: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            id: 5,
            pwd: 20
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handles differently ordered params v4", function () {
  var path = "5/foos/res/20";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foos/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: ":id/foos/res/:pwd",
            parse: {
              id: Number,
              pwd: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            id: 5,
            pwd: 20
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/5/foos/res/20"));
});
import_vitest.test.skip("handles simple optional params", function () {
  var path = "/foos/5";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foo/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: "foos/:id/:nip?",
            parse: {
              id: Number,
              nip: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            id: 5
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handle 2 optional params at the end v1", function () {
  var path = "/foos/5";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foo/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: "foos/:id/:nip?/:pwd?",
            parse: {
              id: Number,
              nip: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            id: 5
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handle 2 optional params at the end v2", function () {
  var path = "/foos/5/10";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foo/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: "foos/:id/:nip?/:pwd?",
            parse: {
              id: Number,
              nip: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            id: 5,
            nip: 10
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handle 2 optional params at the end v3", function () {
  var path = "/foos/5/10/15";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foo/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: "foos/:id/:nip?/:pwd?",
            parse: {
              id: Number,
              nip: Number,
              pwd: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            id: 5,
            nip: 10,
            pwd: 15
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handle optional params in the middle v1", function () {
  var path = "/foos/5/10";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foo/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: "foos/:id/:nip?/:pwd",
            parse: {
              id: Number,
              nip: Number,
              pwd: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            id: 5,
            pwd: 10
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handle optional params in the middle v2", function () {
  var path = "/foos/5/10/15";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foo/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: "foos/:id/:nip?/:pwd",
            parse: {
              id: Number,
              nip: Number,
              pwd: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            id: 5,
            nip: 10,
            pwd: 15
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handle optional params in the middle v3", function () {
  var path = "/foos/5/10/15";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foo/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: "foos/:id/:nip?/:pwd/:smh",
            parse: {
              id: Number,
              nip: Number,
              pwd: Number,
              smh: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            id: 5,
            pwd: 10,
            smh: 15
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handle optional params in the middle v4", function () {
  var path = "/foos/5/10";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foo/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: "foos/:nip?/:pwd/:smh?/:id",
            parse: {
              id: Number,
              nip: Number,
              pwd: Number,
              smh: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            pwd: 5,
            id: 10
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handle optional params in the middle v5", function () {
  var path = "/foos/5/10/15";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foo/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: "foos/:nip?/:pwd/:smh?/:id",
            parse: {
              id: Number,
              nip: Number,
              pwd: Number,
              smh: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            nip: 5,
            pwd: 10,
            id: 15
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("handle optional params in the beginning v1", function () {
  var path = "5/10/foos/15";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foo/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: ":nip?/:pwd/foos/:smh?/:id",
            parse: {
              id: Number,
              nip: Number,
              pwd: Number,
              smh: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            nip: 5,
            pwd: 10,
            id: 15
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/5/10/foos/15"));
});
import_vitest.test.skip("handle optional params in the beginning v2", function () {
  var path = "5/10/foos/15";
  var config = {
    screens: {
      Foe: {
        path: "/",
        initialRouteName: "Foo",
        screens: {
          Foo: "foo",
          Bis: {
            path: "foo/:id",
            parse: {
              id: Number
            }
          },
          Bas: {
            path: ":nip?/:smh?/:pwd/foos/:id",
            parse: {
              id: Number,
              nip: Number,
              pwd: Number,
              smh: Number
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foe",
      state: {
        index: 1,
        routes: [{
          name: "Foo"
        }, {
          name: "Bas",
          params: {
            nip: 5,
            pwd: 10,
            id: 15
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/5/10/foos/15"));
});
import_vitest.test.skip("merges parent patterns if needed", function () {
  var path = "foo/42/baz/babel";
  var config = {
    screens: {
      Foo: {
        path: "foo/:bar",
        parse: {
          bar: Number
        },
        screens: {
          Baz: "baz/:qux"
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      params: {
        bar: 42
      },
      state: {
        routes: [{
          name: "Baz",
          params: {
            qux: "babel"
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/foo/42/baz/babel"));
});
import_vitest.test.skip("ignores extra slashes in the pattern", function () {
  var path = "/bar/42";
  var config = {
    screens: {
      Foo: {
        screens: {
          Bar: {
            path: "/bar//:id/"
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Bar",
          params: {
            id: "42"
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("matches wildcard patterns at root", function () {
  var path = "/test/bar/42/whatever";
  var config = {
    screens: {
      404: "*",
      Foo: {
        screens: {
          Bar: {
            path: "/bar/:id/"
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "404",
      path
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/404"));
});
import_vitest.test.skip("matches wildcard patterns at nested level", function () {
  var path = "/bar/42/whatever/baz/initt";
  var config = {
    screens: {
      Foo: {
        screens: {
          Bar: {
            path: "/bar/:id/",
            screens: {
              404: "*"
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Bar",
          params: {
            id: "42"
          },
          state: {
            routes: [{
              name: "404",
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/bar/42/404"));
});
import_vitest.test.skip("matches wildcard patterns at nested level with exact", function () {
  var path = "/whatever";
  var config = {
    screens: {
      Foo: {
        screens: {
          Bar: {
            path: "/bar/:id/",
            screens: {
              404: {
                path: "*",
                exact: true
              }
            }
          },
          Baz: {}
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Bar",
          state: {
            routes: [{
              name: "404",
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/404"));
});
import_vitest.test.skip("tries to match wildcard patterns at the end", function () {
  var path = "/bar/42/test";
  var config = {
    screens: {
      Foo: {
        screens: {
          Bar: {
            path: "/bar/:id/",
            screens: {
              404: "*",
              UserProfile: ":userSlug",
              Test: "test"
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Bar",
          params: {
            id: "42"
          },
          state: {
            routes: [{
              name: "Test",
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("uses nearest parent wildcard match for unmatched paths", function () {
  var path = "/bar/42/baz/test";
  var config = {
    screens: {
      Foo: {
        screens: {
          Bar: {
            path: "/bar/:id/",
            screens: {
              Baz: "baz"
            }
          },
          404: "*"
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "404",
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/404"));
});
import_vitest.test.skip("matches screen with overlapping initial path and wildcard", function () {
  var path = "/bar/42/baz/test/whatever";
  var config = {
    screens: {
      Foo: {
        screens: {
          Bar: {
            path: "/bar/:id/",
            screens: {
              Baz: "baz"
            }
          },
          Baz: "/bar/:id/*"
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Baz",
          params: {
            id: "42"
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/bar/42/Baz"));
});
(0, import_vitest.test)("throws if two screens map to the same pattern", function () {
  var path = "/bar/42/baz/test";
  (0, import_vitest.expect)(function () {
    return (0, import_getStateFromPath.getStateFromPath)(path, {
      screens: {
        Foo: {
          screens: {
            Bar: {
              path: "/bar/:id/",
              screens: {
                Baz: "baz"
              }
            },
            Bax: "/bar/:id/baz"
          }
        }
      }
    });
  }).toThrow("Found conflicting screens with the same pattern. The pattern 'bar/:id/baz' resolves to both 'Foo > Bax' and 'Foo > Bar > Baz'. Patterns must be unique and cannot resolve to more than one screen.");
  (0, import_vitest.expect)(function () {
    return (0, import_getStateFromPath.getStateFromPath)(path, {
      screens: {
        Foo: {
          screens: {
            Bar: {
              path: "/bar/:id/",
              screens: {
                Baz: ""
              }
            }
          }
        }
      }
    });
  }).not.toThrow();
});
(0, import_vitest.test)("correctly applies initialRouteName for config with similar route names", function () {
  var path = "/weekly-earnings";
  var config = {
    screens: {
      RootTabs: {
        screens: {
          HomeTab: {
            screens: {
              Home: "",
              WeeklyEarnings: "weekly-earnings",
              EventDetails: "event-details/:eventId"
            }
          },
          EarningsTab: {
            initialRouteName: "Earnings",
            path: "earnings",
            screens: {
              Earnings: "",
              WeeklyEarnings: "weekly-earnings"
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "RootTabs",
      key: "RootTabs-0",
      state: {
        routes: [{
          name: "HomeTab",
          key: "HomeTab-1",
          state: {
            routes: [{
              name: "WeeklyEarnings",
              key: "WeeklyEarnings-2",
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
(0, import_vitest.test)("correctly applies initialRouteName for config with similar route names v2", function () {
  var path = "/earnings/weekly-earnings";
  var config = {
    screens: {
      RootTabs: {
        screens: {
          HomeTab: {
            initialRouteName: "Home",
            screens: {
              Home: "",
              WeeklyEarnings: "weekly-earnings"
            }
          },
          EarningsTab: {
            initialRouteName: "Earnings",
            path: "earnings",
            screens: {
              Earnings: "",
              WeeklyEarnings: "weekly-earnings"
            }
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "RootTabs",
      key: "RootTabs-0",
      state: {
        routes: [{
          name: "EarningsTab",
          key: "EarningsTab-1",
          state: {
            index: 1,
            routes: [{
              name: "Earnings",
              key: "Earnings-2"
            }, {
              name: "WeeklyEarnings",
              key: "WeeklyEarnings-3",
              path
            }]
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
});
import_vitest.test.skip("throws when invalid properties are specified in the config", function () {
  (0, import_vitest.expect)(function () {
    return (0, import_getStateFromPath.getStateFromPath)("", {
      path: 42,
      Foo: "foo",
      Bar: {
        path: "bar"
      }
    });
  }).toThrowErrorMatchingInlineSnapshot(`
    "Found invalid properties in the configuration:
    - path (expected 'string', got 'number')
    - Foo (extraneous)
    - Bar (extraneous)

    You can only specify the following properties:
    - path (string)
    - initialRouteName (string)
    - screens (object)

    If you want to specify configuration for screens, you need to specify them under a 'screens' property.

    See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration."
  `);
  (0, import_vitest.expect)(function () {
    return (0, import_getStateFromPath.getStateFromPath)("", {
      screens: {
        Foo: "foo",
        Bar: {
          path: "bar"
        },
        Baz: {
          Qux: {
            path: "qux"
          }
        }
      }
    });
  }).toThrowErrorMatchingInlineSnapshot(`
"Found invalid properties in the configuration:
- Qux (extraneous)

You can only specify the following properties:
- path (string)
- initialRouteName (string)
- screens (object)
- alias (array)
- exact (boolean)
- stringify (object)
- parse (object)

If you want to specify configuration for screens, you need to specify them under a 'screens' property.

See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration."
`);
  (0, import_vitest.expect)(function () {
    return (0, import_getStateFromPath.getStateFromPath)("", {
      path: "foo/:id"
    });
  }).toThrowErrorMatchingInlineSnapshot(`"Found invalid path 'foo/:id'. The 'path' in the top-level configuration cannot contain patterns for params."`);
});
import_vitest.test.skip("encodes special characters in params", function () {
  var paramWithValidSymbols = `User09-A_Z~!$&'()*+,;=:@__`;
  var invalidSymbols = "#?[]{}%<>||";
  var queryString = "user#email@gmail.com=2&4";
  var path = `users/id/${paramWithValidSymbols}${encodeURIComponent(invalidSymbols)}?query=${encodeURIComponent(queryString)}`;
  var config = {
    path: "users",
    screens: {
      Users: {
        screens: {
          User: "id/:id"
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Users",
      state: {
        routes: [{
          name: "User",
          params: {
            id: `${paramWithValidSymbols}${invalidSymbols}`,
            query: queryString
          }
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)(state, config)).toBe(`/${path}`);
  (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)(path, config), config)).toBe(`/${path}`);
});
import_vitest.test.skip("resolves nested path params with same name to correct screen", function () {
  var path = "/foo/42/bar/43";
  var config = {
    initialRouteName: "Foo",
    screens: {
      Foo: {
        path: "foo/:id",
        screens: {
          Bar: {
            path: "bar/:id"
          }
        }
      }
    }
  };
  var state = {
    routes: [{
      name: "Foo",
      params: {
        id: "42"
      },
      state: {
        routes: [{
          name: "Bar",
          params: {
            id: "43"
          },
          path
        }]
      }
    }]
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
});
(0, import_vitest.test)("parses / same as empty string", function () {
  var config = {
    screens: {
      Foo: {
        path: "/"
      },
      Bar: {
        path: "bar"
      }
    }
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("/", config)).toEqual((0, import_getStateFromPath.getStateFromPath)("", config));
});
import_vitest.test.skip("matches regexp patterns when provided", function () {
  var config = {
    screens: {
      Foo: {
        path: "foo/:id(\\d+)",
        parse: {
          id: Number
        }
      },
      Bar: {
        path: "foo/:id([a-z]+)"
      },
      Baz: {
        path: "foo/:id(\\d+)/:name([a-z]+)"
      },
      Qux: {
        path: "foo/:id(@[a-z]+)",
        parse: {
          id: function (id) {
            return id.slice(1);
          }
        }
      },
      Quy: {
        path: "foo/bar/:category"
      },
      Quz: {
        path: "foo/bar/:special([a-z]+)"
      },
      Quu: {
        path: "foo/bar/baz"
      },
      NotFound: {
        path: "foo/bar/*"
      }
    }
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/42", config)).toEqual({
    routes: [{
      name: "Foo",
      params: {
        id: 42
      },
      path: "foo/42"
    }]
  });
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar", config)).toEqual({
    routes: [{
      name: "Bar",
      params: {
        id: "bar"
      },
      path: "foo/bar"
    }]
  });
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/42/bar", config)).toEqual({
    routes: [{
      name: "Baz",
      params: {
        id: "42",
        name: "bar"
      },
      path: "foo/42/bar"
    }]
  });
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/@bar", config)).toEqual({
    routes: [{
      name: "Qux",
      params: {
        id: "bar"
      },
      path: "foo/@bar"
    }]
  });
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/@bar", config)).toEqual({
    routes: [{
      name: "Qux",
      params: {
        id: "bar"
      },
      path: "foo/@bar"
    }]
  });
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/42a", config)).toBeUndefined();
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/123", config)).toEqual({
    routes: [{
      name: "Quy",
      params: {
        category: "123"
      },
      path: "foo/bar/123"
    }]
  });
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/test", config)).toEqual({
    routes: [{
      name: "Quz",
      params: {
        special: "test"
      },
      path: "foo/bar/test"
    }]
  });
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/baz", config)).toEqual({
    routes: [{
      name: "Quu",
      path: "foo/bar/baz"
    }]
  });
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/hello/world", config)).toEqual({
    routes: [{
      name: "NotFound",
      path: "foo/bar/hello/world"
    }]
  });
});
(0, import_vitest.test)("regexp pattern doesn't match slash", function () {
  var config = {
    screens: {
      Foo: {
        path: "foo/:id([a-z]+\\/)"
      }
    }
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/", config)).toBeUndefined();
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/baz", config)).toBeUndefined();
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/baz/qux", config)).toBeUndefined();
});
import_vitest.test.skip("handles alias for paths", function () {
  var config = {
    screens: {
      Foo: {
        path: "foo",
        alias: ["first"],
        screens: {
          Baz: {
            path: "baz/:id?",
            parse: {
              id: function (value) {
                return value.replace(/@/, "");
              }
            },
            alias: [{
              path: "second/:id",
              exact: true
            }, "third", {
              path: "fourth/:id",
              parse: {
                id: function (value) {
                  return value.replace(/\$/, "");
                }
              }
            }]
          },
          Qux: {
            path: "qux/:id"
          }
        }
      }
    }
  };
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo", config)).toEqual({
    routes: [{
      name: "Foo",
      path: "foo"
    }]
  });
  (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("foo", config), config)).toBe("/foo");
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("first", config)).toEqual({
    routes: [{
      name: "Foo",
      path: "first"
    }]
  });
  (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("first", config), config)).toBe("/foo");
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/baz/@$test", config)).toEqual({
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Baz",
          params: {
            id: "$test"
          },
          path: "foo/baz/@$test"
        }]
      }
    }]
  });
  (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("foo/baz/@$test", config), config)).toBe("/foo/baz/$test");
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("second/42", config)).toEqual({
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Baz",
          params: {
            id: "42"
          },
          path: "second/42"
        }]
      }
    }]
  });
  (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("second/42", config), config)).toBe("/foo/baz/42");
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/third", config)).toEqual({
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Baz",
          path: "foo/third"
        }]
      }
    }]
  });
  (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("foo/third", config), config)).toBe("/foo/baz");
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/fourth/@$test", config)).toEqual({
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Baz",
          params: {
            id: "@test"
          },
          path: "foo/fourth/@$test"
        }]
      }
    }]
  });
  (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("foo/fourth/@$test", config), config)).toBe("/foo/baz/@test");
  (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/qux/42", config)).toEqual({
    routes: [{
      name: "Foo",
      state: {
        routes: [{
          name: "Qux",
          params: {
            id: "42"
          },
          path: "foo/qux/42"
        }]
      }
    }]
  });
  (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("foo/qux/42", config), config)).toBe("/foo/qux/42");
});
import_vitest.test.skip("throws if screen has alias but no path", function () {
  (0, import_vitest.expect)(function () {
    return (0, import_getStateFromPath.getStateFromPath)("", {
      screens: {
        Foo: {
          alias: ["bar"]
        }
      }
    });
  }).toThrow(`Screen 'Foo' doesn't specify a 'path'. A 'path' needs to be specified in order to use 'alias'.`);
});
//# sourceMappingURL=getStateFromPath.test.native.js.map