{"version":3,"sources":["../src/router.ts","../src/routing/specificity.ts"],"sourcesContent":["import {\n  AmbiguousRouteError,\n  assertTerminalCatchAll,\n  assertUniqueRouteParameters,\n  compareRouteSpecificity,\n  getRoutePatternShape,\n  type RouteSegmentSpecificity,\n} from \"./routing/specificity\";\n\nexport type FarmRouterPrimitiveParam = string | number | boolean;\nexport type FarmRouterPathParam =\n  | FarmRouterPrimitiveParam\n  | readonly FarmRouterPrimitiveParam[]\n  | null\n  | undefined;\nexport type FarmRouterPathParams = Record<string, FarmRouterPathParam>;\nexport type FarmRouterParams = Record<string, string>;\n\nexport interface FarmRouterRoute<TMeta = unknown> {\n  path: string;\n  name?: string;\n  meta?: TMeta;\n}\n\nexport type FarmRouterRouteInput<TMeta = unknown> = string | FarmRouterRoute<TMeta>;\n\nexport interface FarmRouterMatch<TMeta = unknown> {\n  route: FarmRouterRoute<TMeta>;\n  pathname: string;\n  params: FarmRouterParams;\n}\n\nexport type FarmRouterQueryValue =\n  | FarmRouterPrimitiveParam\n  | readonly FarmRouterPrimitiveParam[]\n  | null\n  | undefined;\n\nexport interface FarmRouterBuildOptions {\n  query?: URLSearchParams | Record<string, FarmRouterQueryValue>;\n  hash?: string;\n  trailingSlash?: boolean;\n}\n\nexport interface FarmRouterActiveOptions {\n  exact?: boolean;\n}\n\nexport interface FarmRouter<TMeta = unknown> {\n  routes: FarmRouterRoute<TMeta>[];\n  match(pathname: string): FarmRouterMatch<TMeta> | null;\n  build(pattern: string, params?: FarmRouterPathParams, options?: FarmRouterBuildOptions): string;\n  isActive(pattern: string, pathname: string, options?: FarmRouterActiveOptions): boolean;\n}\n\ntype RouterSegment =\n  | {\n      type: \"static\";\n      value: string;\n    }\n  | {\n      type: \"dynamic\";\n      name: string;\n      catchAll: boolean;\n      optional: boolean;\n    };\n\ninterface NormalizedRouterRoute<TMeta> {\n  route: FarmRouterRoute<TMeta>;\n  segments: RouterSegment[];\n  specificity: RouteSegmentSpecificity[];\n  index: number;\n}\n\nexport function createFarmRouter<TMeta = unknown>(\n  routes: FarmRouterRouteInput<TMeta>[],\n): FarmRouter<TMeta> {\n  const normalizedRoutes = routes.map(normalizeRouteInput);\n  const patternsByShape = new Map<string, string>();\n  for (const entry of normalizedRoutes) {\n    const shape = getRoutePatternShape(entry.route.path, \"router\");\n    const existingPattern = patternsByShape.get(shape);\n    if (existingPattern) {\n      throw new AmbiguousRouteError(\n        `Ambiguous route patterns \"${existingPattern}\" and \"${entry.route.path}\" match the same URLs. Keep only one route for this URL shape.`,\n      );\n    }\n    patternsByShape.set(shape, entry.route.path);\n  }\n  normalizedRoutes.sort(compareRoutes);\n\n  return {\n    routes: normalizedRoutes.map((entry) => entry.route),\n    match(pathname) {\n      const normalizedPathname = normalizePathname(pathname);\n\n      for (const entry of normalizedRoutes) {\n        const params = matchSegments(entry.segments, normalizedPathname);\n        if (params) {\n          return {\n            route: entry.route,\n            pathname: normalizedPathname,\n            params,\n          };\n        }\n      }\n\n      return null;\n    },\n    build: buildFarmRoutePath,\n    isActive: isFarmRouteActive,\n  };\n}\n\nexport function matchFarmRoute(pattern: string, pathname: string): FarmRouterParams | null {\n  return matchSegments(parseRoutePattern(pattern), normalizePathname(pathname));\n}\n\nexport function buildFarmRoutePath(\n  pattern: string,\n  params: FarmRouterPathParams = {},\n  options: FarmRouterBuildOptions = {},\n): string {\n  const parts: string[] = [];\n\n  for (const segment of parseRoutePattern(pattern)) {\n    if (segment.type === \"static\") {\n      parts.push(encodePathSegment(segment.value));\n      continue;\n    }\n\n    const value = params[segment.name];\n    const values = Array.isArray(value) ? value : value == null ? [] : [value];\n\n    if (values.length === 0) {\n      if (segment.optional) continue;\n      throw new Error(`Missing route param \"${segment.name}\" for ${pattern}.`);\n    }\n\n    if (!segment.catchAll && values.length > 1) {\n      throw new Error(`Route param \"${segment.name}\" for ${pattern} expects a single value.`);\n    }\n\n    const encodedValues = values.map((item) => {\n      const value = String(item);\n      if (!value) {\n        throw new Error(\n          `Route param \"${segment.name}\" for ${pattern} cannot contain an empty path segment.`,\n        );\n      }\n      return encodePathSegment(value);\n    });\n    parts.push(...encodedValues);\n  }\n\n  let pathname = parts.length ? `/${parts.join(\"/\")}` : \"/\";\n\n  if (options.trailingSlash && pathname !== \"/\") {\n    pathname = `${pathname}/`;\n  }\n\n  return appendQueryAndHash(pathname, options);\n}\n\nexport function isFarmRouteActive(\n  pattern: string,\n  pathname: string,\n  options: FarmRouterActiveOptions = {},\n): boolean {\n  const normalizedPathname = normalizePathname(pathname);\n  if (matchFarmRoute(pattern, normalizedPathname)) return true;\n  if (options.exact !== false) return false;\n\n  const segments = parseRoutePattern(pattern);\n  if (segments.length === 0) return normalizedPathname === \"/\";\n  return matchSegments(segments, normalizedPathname, true) !== null;\n}\n\nfunction normalizeRouteInput<TMeta>(\n  input: FarmRouterRouteInput<TMeta>,\n  index: number,\n): NormalizedRouterRoute<TMeta> {\n  const route = typeof input === \"string\" ? { path: input } : input;\n  const path = normalizeRoutePattern(route.path);\n  const segments = parseRoutePattern(path);\n\n  return {\n    route: {\n      ...route,\n      path,\n    },\n    segments,\n    specificity: segments.map(getRouterSegmentSpecificity),\n    index,\n  };\n}\n\nfunction parseRoutePattern(pattern: string): RouterSegment[] {\n  assertTerminalCatchAll(pattern, \"router\");\n  assertUniqueRouteParameters(pattern, \"router\");\n  return splitRoutePattern(pattern)\n    .filter((part) => !isRouteGroup(part))\n    .map((part) => {\n      const optionalCatchAll = part.match(/^\\[\\[\\.\\.\\.([A-Za-z0-9_$-]+)\\]\\]$/);\n      if (optionalCatchAll) {\n        return {\n          type: \"dynamic\",\n          name: optionalCatchAll[1],\n          catchAll: true,\n          optional: true,\n        };\n      }\n\n      const catchAll = part.match(/^\\[\\.\\.\\.([A-Za-z0-9_$-]+)\\]$/);\n      if (catchAll) {\n        return {\n          type: \"dynamic\",\n          name: catchAll[1],\n          catchAll: true,\n          optional: false,\n        };\n      }\n\n      const dynamic = part.match(/^\\[([A-Za-z0-9_$-]+)\\]$/) || part.match(/^:([A-Za-z0-9_$-]+)$/);\n      if (dynamic) {\n        return {\n          type: \"dynamic\",\n          name: dynamic[1],\n          catchAll: false,\n          optional: false,\n        };\n      }\n\n      const star = part.match(/^\\*([A-Za-z0-9_$-]+)(\\?)?$/);\n      if (star) {\n        return {\n          type: \"dynamic\",\n          name: star[1],\n          catchAll: true,\n          optional: !!star[2],\n        };\n      }\n\n      return {\n        type: \"static\",\n        value: decodePathSegment(part),\n      };\n    });\n}\n\nfunction matchSegments(\n  segments: RouterSegment[],\n  pathname: string,\n  allowTrailingSegments = false,\n): FarmRouterParams | null {\n  const parts = splitPathname(pathname);\n  const params: FarmRouterParams = {};\n\n  if (segments.length === 0) {\n    return parts.length === 0 ? params : null;\n  }\n\n  let pathIndex = 0;\n\n  for (const segment of segments) {\n    if (segment.type === \"static\") {\n      if (decodePathSegment(parts[pathIndex] || \"\") !== segment.value) return null;\n      pathIndex++;\n      continue;\n    }\n\n    if (segment.catchAll) {\n      const remaining = parts.slice(pathIndex).map(decodePathSegment);\n      if (remaining.length === 0 && !segment.optional) return null;\n      params[segment.name] = remaining.join(\"/\");\n      pathIndex = parts.length;\n      continue;\n    }\n\n    const value = parts[pathIndex];\n    if (!value) return null;\n    params[segment.name] = decodePathSegment(value);\n    pathIndex++;\n  }\n\n  return allowTrailingSegments || pathIndex === parts.length ? params : null;\n}\n\nfunction compareRoutes<TMeta>(\n  left: NormalizedRouterRoute<TMeta>,\n  right: NormalizedRouterRoute<TMeta>,\n) {\n  const specificity = compareRouteSpecificity(left.specificity, right.specificity);\n  if (specificity !== 0) return specificity;\n  return left.index - right.index;\n}\n\nfunction getRouterSegmentSpecificity(segment: RouterSegment): RouteSegmentSpecificity {\n  if (segment.type === \"static\") return \"static\";\n  if (!segment.catchAll) return \"dynamic\";\n  return segment.optional ? \"optional-catch-all\" : \"catch-all\";\n}\n\nfunction normalizePathname(value: string) {\n  const raw = value || \"/\";\n  let pathname = raw;\n\n  try {\n    pathname = new URL(raw, \"http://farm.local\").pathname;\n  } catch {\n    pathname = raw.split(/[?#]/, 1)[0] || \"/\";\n  }\n\n  pathname = pathname.replace(/\\\\/g, \"/\").replace(/\\/+/g, \"/\");\n  if (!pathname.startsWith(\"/\")) pathname = `/${pathname}`;\n  if (pathname.length > 1) pathname = pathname.replace(/\\/+$/, \"\");\n  return pathname || \"/\";\n}\n\nfunction splitPathname(pathname: string) {\n  return normalizePathname(pathname).split(\"/\").filter(Boolean);\n}\n\nfunction normalizeRoutePattern(value: string) {\n  let pathname = (value || \"/\").replace(/\\\\/g, \"/\").replace(/\\/+/g, \"/\");\n  if (!pathname.startsWith(\"/\")) pathname = `/${pathname}`;\n  if (pathname.length > 1) pathname = pathname.replace(/\\/+$/, \"\");\n  return pathname || \"/\";\n}\n\nfunction splitRoutePattern(pattern: string) {\n  return normalizeRoutePattern(pattern).split(\"/\").filter(Boolean);\n}\n\nfunction isRouteGroup(part: string) {\n  return part.startsWith(\"(\") && part.endsWith(\")\");\n}\n\nfunction decodePathSegment(value: string) {\n  try {\n    return decodeURIComponent(value);\n  } catch {\n    return value;\n  }\n}\n\nfunction encodePathSegment(value: string) {\n  return encodeURIComponent(value);\n}\n\nfunction appendQueryAndHash(pathname: string, options: FarmRouterBuildOptions) {\n  const search = createSearchParams(options.query);\n  const hash = options.hash ? `#${options.hash.replace(/^#/, \"\")}` : \"\";\n  const query = search.toString();\n  return `${pathname}${query ? `?${query}` : \"\"}${hash}`;\n}\n\nfunction createSearchParams(query: FarmRouterBuildOptions[\"query\"]) {\n  if (query instanceof URLSearchParams) return query;\n\n  const search = new URLSearchParams();\n  if (!query) return search;\n\n  for (const [key, value] of Object.entries(query)) {\n    const values = Array.isArray(value) ? value : [value];\n    for (const item of values) {\n      if (item == null) continue;\n      search.append(key, String(item));\n    }\n  }\n\n  return search;\n}\n","export type RouteSegmentSpecificity = \"static\" | \"dynamic\" | \"catch-all\" | \"optional-catch-all\";\n\nexport class AmbiguousRouteError extends Error {\n  constructor(message: string) {\n    super(message);\n    this.name = \"AmbiguousRouteError\";\n  }\n}\n\nexport class NonTerminalCatchAllRouteError extends TypeError {\n  constructor(message: string) {\n    super(message);\n    this.name = \"NonTerminalCatchAllRouteError\";\n  }\n}\n\nexport class DuplicateRouteParameterError extends AmbiguousRouteError {\n  constructor(message: string) {\n    super(message);\n    this.name = \"DuplicateRouteParameterError\";\n  }\n}\n\nexport class ReservedRouteParameterError extends AmbiguousRouteError {\n  constructor(message: string) {\n    super(message);\n    this.name = \"ReservedRouteParameterError\";\n  }\n}\n\nexport class BrowserUnstableRouteError extends TypeError {\n  constructor(message: string) {\n    super(message);\n    this.name = \"BrowserUnstableRouteError\";\n  }\n}\n\nconst SEGMENT_RANK: Record<RouteSegmentSpecificity, number> = {\n  static: 4,\n  dynamic: 3,\n  \"catch-all\": 1,\n  \"optional-catch-all\": 0,\n};\n\n// Ending a route is more specific than consuming the same path through a\n// catch-all, while a following static or dynamic segment remains more specific.\nconst ROUTE_END_RANK = 2;\n\n/** Sort route patterns from the most specific segment sequence to the least specific. */\nexport function compareRouteSpecificity(\n  left: readonly RouteSegmentSpecificity[],\n  right: readonly RouteSegmentSpecificity[],\n): number {\n  const length = Math.max(left.length, right.length);\n\n  for (let index = 0; index < length; index++) {\n    const leftRank = index < left.length ? SEGMENT_RANK[left[index]!] : ROUTE_END_RANK;\n    const rightRank = index < right.length ? SEGMENT_RANK[right[index]!] : ROUTE_END_RANK;\n    if (leftRank !== rightRank) return rightRank - leftRank;\n  }\n\n  return 0;\n}\n\nexport type RoutePatternSyntax = \"page\" | \"router\" | \"api\";\n\nconst ROUTER_PARAMETER_NAME = \"[A-Za-z0-9_$-]+\";\nconst PAGE_PARAMETER_PATTERN = /^(?:\\[\\[\\.\\.\\.(.+)\\]\\]|\\[\\.\\.\\.(.+)\\]|\\[(.+)\\])$/;\nconst ROUTER_PARAMETER_PATTERN =\n  /^(?:\\[\\[\\.\\.\\.([A-Za-z0-9_$-]+)\\]\\]|\\[\\.\\.\\.([A-Za-z0-9_$-]+)\\]|\\[([A-Za-z0-9_$-]+)\\]|:([A-Za-z0-9_$-]+)|\\*([A-Za-z0-9_$-]+)\\??)$/;\nconst RESERVED_PARAMETER_NAMES = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\nexport function assertBrowserStableRoutePath(pattern: string): void {\n  if (pattern.includes(\"\\\\\") || hasControlCharacter(pattern)) {\n    throw new BrowserUnstableRouteError(\n      `Route path \"${pattern}\" cannot contain backslashes or control characters.`,\n    );\n  }\n\n  for (const segment of pattern.split(\"/\").filter(Boolean)) {\n    if (\n      (segment.startsWith(\"(\") && segment.endsWith(\")\")) ||\n      (segment.startsWith(\"[\") && segment.endsWith(\"]\"))\n    ) {\n      continue;\n    }\n\n    let decoded = segment;\n    try {\n      decoded = decodeURIComponent(segment);\n    } catch {\n      // Malformed escapes stay literal in browser pathnames.\n    }\n    if (\n      decoded === \".\" ||\n      decoded === \"..\" ||\n      decoded.includes(\"/\") ||\n      decoded.includes(\"\\\\\") ||\n      hasControlCharacter(decoded)\n    ) {\n      throw new BrowserUnstableRouteError(\n        `Route path \"${pattern}\" contains browser-unstable segment \"${segment}\".`,\n      );\n    }\n  }\n}\n\nfunction hasControlCharacter(value: string): boolean {\n  return Array.from(value).some((character) => {\n    const code = character.charCodeAt(0);\n    return code <= 31 || (code >= 127 && code <= 159);\n  });\n}\n\nexport function assertUniqueRouteParameters(\n  pattern: string,\n  syntax: RoutePatternSyntax = \"page\",\n): void {\n  const parameterPattern = syntax === \"router\" ? ROUTER_PARAMETER_PATTERN : PAGE_PARAMETER_PATTERN;\n  const names = new Set<string>();\n\n  for (const segment of splitRoutePattern(pattern, syntax)) {\n    const match = parameterPattern.exec(segment);\n    const name = match?.slice(1).find(Boolean);\n    if (!name) continue;\n    if (RESERVED_PARAMETER_NAMES.has(name)) {\n      throw new ReservedRouteParameterError(\n        `Route parameter \"${name}\" in route \"${pattern}\" is reserved. Use a different parameter name.`,\n      );\n    }\n    if (names.has(name)) {\n      throw new DuplicateRouteParameterError(\n        `Duplicate route parameter \"${name}\" in route \"${pattern}\". Each dynamic segment must use a unique name.`,\n      );\n    }\n    names.add(name);\n  }\n}\n\nfunction splitRoutePattern(pattern: string, syntax: RoutePatternSyntax): string[] {\n  return pattern\n    .replace(/\\\\/g, \"/\")\n    .split(\"/\")\n    .filter(Boolean)\n    .filter((segment) =>\n      syntax === \"api\" ? true : !(segment.startsWith(\"(\") && segment.endsWith(\")\")),\n    );\n}\n\nexport function assertTerminalCatchAll(pattern: string, syntax: RoutePatternSyntax = \"page\"): void {\n  const segments = splitRoutePattern(pattern, syntax);\n  const parameterName = syntax === \"router\" ? ROUTER_PARAMETER_NAME : \".+\";\n  const catchAllPattern = new RegExp(\n    syntax === \"router\"\n      ? `^(?:\\\\[\\\\[\\\\.\\\\.\\\\.${parameterName}\\\\]\\\\]|\\\\[\\\\.\\\\.\\\\.${parameterName}\\\\]|\\\\*${parameterName}\\\\??)$`\n      : `^(?:\\\\[\\\\[\\\\.\\\\.\\\\.${parameterName}\\\\]\\\\]|\\\\[\\\\.\\\\.\\\\.${parameterName}\\\\])$`,\n  );\n  const catchAllIndex = segments.findIndex((segment) => catchAllPattern.test(segment));\n  if (catchAllIndex >= 0 && catchAllIndex !== segments.length - 1) {\n    throw new NonTerminalCatchAllRouteError(\n      `Catch-all segment \"${segments[catchAllIndex]}\" must be the final segment in route \"${pattern}\".`,\n    );\n  }\n}\n\n/** Return the URL-matching shape of a route without its parameter names. */\nexport function getRoutePatternShape(pattern: string, syntax: RoutePatternSyntax = \"page\"): string {\n  assertTerminalCatchAll(pattern, syntax);\n  const segments = splitRoutePattern(pattern, syntax).map((segment) => {\n    const specificity = getPatternSegmentSpecificity(segment, syntax);\n    if (specificity !== \"static\") return specificity;\n\n    try {\n      return `static:${decodeURIComponent(segment)}`;\n    } catch {\n      return `static:${segment}`;\n    }\n  });\n\n  return segments.length === 0 ? \"/\" : JSON.stringify(segments);\n}\n\n/** Return the specificity of every URL-consuming segment in a route pattern. */\nexport function getRoutePatternSpecificity(\n  pattern: string,\n  syntax: RoutePatternSyntax = \"page\",\n): RouteSegmentSpecificity[] {\n  assertTerminalCatchAll(pattern, syntax);\n  return splitRoutePattern(pattern, syntax).map((segment) =>\n    getPatternSegmentSpecificity(segment, syntax),\n  );\n}\n\nfunction getPatternSegmentSpecificity(\n  segment: string,\n  syntax: RoutePatternSyntax,\n): RouteSegmentSpecificity {\n  const parameterName = syntax === \"router\" ? ROUTER_PARAMETER_NAME : \".+\";\n  const supportsColonAndStar = syntax === \"router\";\n  if (\n    new RegExp(`^\\\\[\\\\[\\\\.\\\\.\\\\.${parameterName}\\\\]\\\\]$`).test(segment) ||\n    (supportsColonAndStar && new RegExp(`^\\\\*${parameterName}\\\\?$`).test(segment))\n  ) {\n    return \"optional-catch-all\";\n  }\n  if (\n    new RegExp(`^\\\\[\\\\.\\\\.\\\\.${parameterName}\\\\]$`).test(segment) ||\n    (supportsColonAndStar && new RegExp(`^\\\\*${parameterName}$`).test(segment))\n  ) {\n    return \"catch-all\";\n  }\n  if (\n    new RegExp(`^\\\\[${parameterName}\\\\]$`).test(segment) ||\n    (supportsColonAndStar && new RegExp(`^:${parameterName}$`).test(segment))\n  ) {\n    return \"dynamic\";\n  }\n\n  return \"static\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,uBAAN,MAAM,6BAA4B,MAAM;AAAA,EAC7C,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAL+C;AAAxC,IAAM,sBAAN;AAOA,IAAM,iCAAN,MAAM,uCAAsC,UAAU;AAAA,EAC3D,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAL6D;AAAtD,IAAM,gCAAN;AAOA,IAAM,gCAAN,MAAM,sCAAqC,oBAAoB;AAAA,EACpE,YAAY,SAAiB;AAC3B,UAAM,OAAO;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