vorma 0.85.0-pre.12 → 0.85.0-pre.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/vorma/core/_index.d.ts +6 -4
- package/.dist/vorma/core/_index.d.ts.map +1 -1
- package/.dist/vorma/core/_index.js +29 -13
- package/.dist/vorma/core/_index.js.map +1 -1
- package/.dist/vorma/tsx/preact/preact.d.ts +1 -0
- package/.dist/vorma/tsx/preact/preact.d.ts.map +1 -1
- package/.dist/vorma/tsx/react/react.d.ts +1 -0
- package/.dist/vorma/tsx/react/react.d.ts.map +1 -1
- package/.dist/vorma/tsx/remix/remix.d.ts +1 -0
- package/.dist/vorma/tsx/remix/remix.d.ts.map +1 -1
- package/.dist/vorma/tsx/solid/solid.d.ts +1 -0
- package/.dist/vorma/tsx/solid/solid.d.ts.map +1 -1
- package/package.json +1 -1
- package/vorma/core/ccc_effect_experiment_notes.md +4 -0
- package/vorma/core/create_client_core.ts +49 -14
- package/vorma/core/create_client_core_effect.ts +16 -14
- package/vorma/core/effect_runtime/client_contract.ts +4 -4
- package/vorma/core/effect_runtime/client_kernel_assembly.ts +1 -0
- package/vorma/core/effect_runtime/client_navigation_services.ts +6 -2
- package/vorma/core/effect_runtime/client_session.ts +57 -0
- package/vorma/core/effect_runtime/index.ts +1 -0
- package/vorma/core/effect_runtime/revalidation_coordinator.ts +56 -24
- package/vorma/core/effect_runtime/route_revalidator.ts +6 -3
- package/vorma/core/effect_runtime/submit_manager.ts +35 -11
- package/vorma/core/effect_runtime/work_indicator.ts +13 -6
- package/vorma/core/effect_runtime/work_state_actor.ts +25 -5
- package/vorma/core/make_link_props.ts +16 -0
- package/vorma/core/types.ts +1 -0
- package/vorma/core/ui_adapter_core.ts +1 -0
- package/vorma/create/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_index.js","names":[],"sources":["../../../vorma/core/constants.ts","../../../vorma/core/url.ts","../../../vorma/core/api_client.ts","../../../vorma/core/css.ts","../../../vorma/core/head.ts","../../../vorma/core/modules.ts","../../../vorma/core/create_client_core.ts","../../../vorma/core/make_link_props.ts","../../../vorma/core/resolve_outlet_slot.ts","../../../vorma/core/ui_adapter_core.ts"],"sourcesContent":["export const VORMA_JSON_KEY = \"vorma-json\";\nexport const DATA_SCRIPT_ID = \"vorma-data-json\";\nexport const BUILD_ID_HEADER = \"X-Vorma-Client-Build-Id\";\nexport const X_VORMA_BUILD_SKEW = \"X-Vorma-Build-Skew\";\nexport const X_CLIENT_REDIRECT = \"X-Client-Redirect\";\nexport const X_ACCEPTS_CLIENT_REDIRECT = \"X-Accepts-Client-Redirect\";\n\nexport const VERCEL_X_DEPLOYMENT_ID = \"x-deployment-id\";\nexport const VERCEL_DPL_QUERY_PARAM_KEY = \"dpl\";\n\nexport const SCROLL_STORAGE_KEY = \"vorma-scroll-state\";\nexport const SCROLL_STORAGE_RELOAD_KEY = \"vorma-scroll-state-reload\";\nexport const VORMA_ROOT_EL_ID = \"vorma-root\";\n\nexport const HISTORY_KEY_FIELD = \"vorma-history-key\";\nexport const HISTORY_USER_STATE_FIELD = \"vorma-user-state\";\n\nexport const API_IDENTITY_ARRAY_PREFIX = \"vorma-api\";\n\nexport const LINK_ACTIVE_EXACT_ATTR = \"data-vorma-active-exact\";\nexport const LINK_ACTIVE_ANCESTOR_ATTR = \"data-vorma-active-ancestor\";\nexport const LINK_PENDING_EXACT_ATTR = \"data-vorma-pending-exact\";\nexport const LINK_PENDING_ANCESTOR_ATTR = \"data-vorma-pending-ancestor\";\n\nexport const CSS_BUNDLE_ATTR = \"data-vorma-css-bundle\";\nexport const CSS_PRELOAD_ATTR = \"data-vorma-css-preload\";\nexport const CSS_PRELOAD_SETTLED_ATTR = \"data-vorma-css-settled\";\n","import { serializeToSearchParams } from \"vorma/kit/json\";\nimport type {\n\tAppConfig,\n\tToNavigateArgs,\n\tToNavigationTarget,\n\tToRouteDestination,\n\tToViewPattern,\n} from \"./types.ts\";\n\nconst DYNAMIC_RUNE = \":\";\nconst SPLAT_RUNE = \"*\";\nconst INDEX_SEGMENT = \"_index\";\n\nfunction strip_trailing_slash(path: string): string {\n\tif (path === \"/\") {\n\t\treturn path;\n\t}\n\treturn path.endsWith(\"/\") ? path.slice(0, -1) : path;\n}\n\nfunction resolve_pattern_path(\n\tpattern: string,\n\tparams?: Record<string, string>,\n\tsplat_values?: string[],\n): string {\n\tconst p = params ?? {};\n\tconst segments = pattern.split(\"/\").filter((s) => {\n\t\treturn s.length > 0;\n\t});\n\tconst splat_encoded = (splat_values ?? [])\n\t\t.map((v) => {\n\t\t\treturn encodeURIComponent(v);\n\t\t})\n\t\t.join(\"/\");\n\n\tconst path_segments = segments.flatMap((seg) => {\n\t\tif (seg === SPLAT_RUNE) {\n\t\t\treturn splat_encoded.split(\"/\").filter((s) => {\n\t\t\t\treturn s.length > 0;\n\t\t\t});\n\t\t}\n\t\tif (seg.startsWith(DYNAMIC_RUNE)) {\n\t\t\treturn [\n\t\t\t\tencodeURIComponent(p[seg.slice(DYNAMIC_RUNE.length)] as string),\n\t\t\t];\n\t\t}\n\t\treturn [seg];\n\t});\n\n\tconst result = \"/\" + path_segments.join(\"/\");\n\treturn strip_trailing_slash(result.length === 0 ? \"/\" : result);\n}\n\nexport function resolve_path(\n\ttype: \"loader\" | \"action\",\n\tpattern: string,\n\tparams?: Record<string, string>,\n\tsplat_values?: string[],\n): string {\n\tlet path = resolve_pattern_path(pattern, params, splat_values);\n\n\tif (type === \"loader\") {\n\t\tconst suffix = `/${INDEX_SEGMENT}`;\n\t\tif (path.endsWith(suffix)) {\n\t\t\tpath = path.slice(0, -suffix.length) || \"/\";\n\t\t}\n\t}\n\n\treturn path;\n}\n\nexport function to_typed_href(\n\tpattern: string,\n\tparams?: Record<string, string>,\n\tsplat_values?: string[],\n\tsearch?: unknown,\n\thash?: string,\n): string {\n\tconst base = resolve_path(\"loader\", pattern, params, splat_values);\n\tconst url = new URL(base, window.location.origin);\n\tif (search !== undefined) {\n\t\turl.search = serializeToSearchParams(search).toString();\n\t}\n\tif (hash !== undefined) {\n\t\turl.hash = hash;\n\t}\n\treturn url.href;\n}\n\nexport function build_action_url(\n\tactions_mount_root: string,\n\tpattern: string,\n\tparams?: Record<string, string>,\n\tsplat_values?: string[],\n\tinput?: unknown,\n): URL {\n\tconst pathname = resolve_path(\"action\", pattern, params, splat_values);\n\tconst full =\n\t\tstrip_trailing_slash(actions_mount_root) +\n\t\t(pathname === \"/\" ? \"\" : pathname);\n\tconst url = new URL(full, window.location.origin);\n\tif (input && typeof input === \"object\") {\n\t\turl.search = serializeToSearchParams(input).toString();\n\t}\n\treturn url;\n}\n\nexport function create_typed_to_href<A extends AppConfig>() {\n\treturn <P extends ToViewPattern<A>>(\n\t\tdestination: ToRouteDestination<A, P>,\n\t): string => {\n\t\tconst d = destination as any;\n\t\treturn to_typed_href(\n\t\t\td.pattern,\n\t\t\td.params,\n\t\t\td.splatValues,\n\t\t\td.search,\n\t\t\td.hash,\n\t\t);\n\t};\n}\n\nexport function resolve_body(input: unknown): BodyInit | null | undefined {\n\tif (\n\t\tinput === undefined ||\n\t\tinput === null ||\n\t\ttypeof input === \"string\" ||\n\t\tinput instanceof ReadableStream ||\n\t\tinput instanceof FormData ||\n\t\tinput instanceof URLSearchParams ||\n\t\tinput instanceof Blob ||\n\t\tinput instanceof ArrayBuffer\n\t) {\n\t\treturn input;\n\t}\n\tif (ArrayBuffer.isView(input)) {\n\t\treturn input as ArrayBufferView<ArrayBuffer>;\n\t}\n\treturn JSON.stringify(input);\n}\n\nexport function create_typed_navigate<A extends AppConfig>(\n\tnavigate_fn: (\n\t\thref: string | URL,\n\t\toptions?: {\n\t\t\treplace?: boolean;\n\t\t\tscrollToTop?: boolean;\n\t\t\tstate?: unknown;\n\t\t\tskipWorkIndicator?: boolean;\n\t\t},\n\t) => Promise<{ didNavigate: boolean }>,\n) {\n\tconst to_href = create_typed_to_href<A>();\n\treturn async <P extends ToViewPattern<A>>(\n\t\targs: ToNavigateArgs<A, P>,\n\t): Promise<{ didNavigate: boolean }> => {\n\t\tconst href = args.href ?? to_href(args as any);\n\t\treturn navigate_fn(href, {\n\t\t\treplace: args.replace,\n\t\t\tscrollToTop: args.scrollToTop,\n\t\t\tstate: args.state,\n\t\t\tskipWorkIndicator: args.skipWorkIndicator,\n\t\t});\n\t};\n}\n\nexport function create_typed_prefetch<A extends AppConfig>(\n\tprefetch_fn: (href: string) => void,\n) {\n\tconst to_href = create_typed_to_href<A>();\n\treturn <P extends ToViewPattern<A>>(\n\t\ttarget: ToNavigationTarget<A, P>,\n\t): void => {\n\t\tprefetch_fn(target.href ?? to_href(target as any));\n\t};\n}\n","import { jsonStringifyStable } from \"vorma/kit/json\";\nimport { API_IDENTITY_ARRAY_PREFIX } from \"./constants.ts\";\nimport type {\n\tAPIRouteKind,\n\tAppConfig,\n\tMutationResult,\n\tQueryResult,\n\tToAPIClient,\n\tToAPIDecorator,\n\tToAPIDecoratorContext,\n\tToMutationArgs,\n\tToQueryArgs,\n\t__APIClientOutput,\n} from \"./types.ts\";\nimport { build_action_url, resolve_body } from \"./url.ts\";\n\ntype SubmitFn = <T>(\n\turl: string | URL,\n\trequestInit?: RequestInit,\n\toptions?: {\n\t\tapiRouteKind?: APIRouteKind;\n\t\tdedupeKey?: string;\n\t\trevalidate?: boolean;\n\t\tskipWorkIndicator?: boolean;\n\t},\n) => Promise<QueryResult<T> | MutationResult<T>>;\n\nfunction normalize_api_method(raw_method: string | undefined): string {\n\treturn (raw_method ?? \"GET\").trim().toUpperCase();\n}\n\nfunction normalize_api_pattern(pattern: string): string {\n\treturn pattern.trim();\n}\n\nfunction stringify_identity_value(value: unknown): string {\n\tconst res = jsonStringifyStable(value);\n\tif (!res.ok) {\n\t\tthrow new Error(res.err);\n\t}\n\treturn res.val;\n}\n\nclass APIErrorBase<T = never> extends Error {\n\tresult: Extract<QueryResult<T> | MutationResult<T>, { success: false }>;\n\n\tconstructor(\n\t\tresult: Extract<QueryResult<T> | MutationResult<T>, { success: false }>,\n\t) {\n\t\tsuper(result.error);\n\t\tthis.result = result;\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\nexport class QueryError<T = never> extends APIErrorBase<T> {\n\tconstructor(result: Extract<QueryResult<T>, { success: false }>) {\n\t\tsuper(result);\n\t\tthis.name = \"QueryError\";\n\t}\n}\n\nexport class MutationError<T = never> extends APIErrorBase<T> {\n\tconstructor(result: Extract<MutationResult<T>, { success: false }>) {\n\t\tsuper(result);\n\t\tthis.name = \"MutationError\";\n\t}\n}\n\nexport function create_typed_api_client<A extends AppConfig>(\n\tactions_mount_root: string,\n\tsubmit_fn: SubmitFn,\n\tdecorator?: ToAPIDecorator<A>,\n): ToAPIClient<A> {\n\tasync function submit<Args extends ToQueryArgs<A> | ToMutationArgs<A>>(\n\t\targs: Args,\n\t\tapi_route_kind: APIRouteKind,\n\t): Promise<\n\t\t| QueryResult<__APIClientOutput<A, Args>>\n\t\t| MutationResult<__APIClientOutput<A, Args>>\n\t> {\n\t\tconst {\n\t\t\tdedupeKey,\n\t\t\tinput,\n\t\t\tmethod: raw_method,\n\t\t\tparams,\n\t\t\tpattern,\n\t\t\trevalidate,\n\t\t\tskipWorkIndicator,\n\t\t\tsplatValues,\n\t\t\t...request_init\n\t\t} = args as any;\n\t\tconst method = normalize_api_method(raw_method);\n\t\tconst api_pattern = normalize_api_pattern(pattern);\n\t\tconst is_get = method === \"GET\" || method === \"HEAD\";\n\t\tconst url = build_action_url(\n\t\t\tactions_mount_root,\n\t\t\tapi_pattern,\n\t\t\tparams,\n\t\t\tsplatValues,\n\t\t\tis_get ? input : undefined,\n\t\t);\n\t\tconst ctx = {\n\t\t\tinput,\n\t\t\tmethod,\n\t\t\tpattern: api_pattern,\n\t\t\trequestInit: request_init,\n\t\t} as ToAPIDecoratorContext<A>;\n\t\tconst decorated = decorator\n\t\t\t? ((await (decorator as any)(ctx)) ?? {})\n\t\t\t: {};\n\t\tconst init: RequestInit = { ...decorated, ...request_init };\n\t\tconst headers = new Headers(decorated.headers ?? undefined);\n\t\tnew Headers(request_init.headers ?? undefined).forEach((v, k) => {\n\t\t\theaders.set(k, v);\n\t\t});\n\t\tinit.headers = headers;\n\t\tinit.method = method;\n\t\tif (is_get) {\n\t\t\tdelete init.body;\n\t\t} else {\n\t\t\tinit.body = resolve_body(input);\n\t\t}\n\t\tconst options: {\n\t\t\tapiRouteKind?: APIRouteKind;\n\t\t\tdedupeKey?: string;\n\t\t\trevalidate?: boolean;\n\t\t\tskipWorkIndicator?: boolean;\n\t\t} = {\n\t\t\tapiRouteKind: api_route_kind,\n\t\t};\n\t\tif (dedupeKey !== undefined) {\n\t\t\toptions.dedupeKey = dedupeKey;\n\t\t}\n\t\tif (revalidate !== undefined) {\n\t\t\toptions.revalidate = revalidate;\n\t\t}\n\t\tif (skipWorkIndicator !== undefined) {\n\t\t\toptions.skipWorkIndicator = skipWorkIndicator;\n\t\t}\n\t\treturn submit_fn<__APIClientOutput<A, Args>>(url, init, options);\n\t}\n\n\treturn {\n\t\ttoIdentityArray: <Args extends ToQueryArgs<A> | ToMutationArgs<A>>(\n\t\t\targs: Args,\n\t\t): unknown[] => {\n\t\t\tconst {\n\t\t\t\tinput,\n\t\t\t\tmethod: raw_method,\n\t\t\t\tparams,\n\t\t\t\tpattern,\n\t\t\t\tsplatValues,\n\t\t\t} = args as any;\n\t\t\tconst method = normalize_api_method(raw_method);\n\t\t\tconst api_pattern = normalize_api_pattern(pattern);\n\t\t\treturn [\n\t\t\t\tAPI_IDENTITY_ARRAY_PREFIX,\n\t\t\t\tactions_mount_root,\n\t\t\t\tmethod,\n\t\t\t\tapi_pattern,\n\t\t\t\tstringify_identity_value(params ?? null),\n\t\t\t\tstringify_identity_value(splatValues ?? []),\n\t\t\t\tstringify_identity_value(input ?? null),\n\t\t\t];\n\t\t},\n\t\tmutate: <Args extends ToMutationArgs<A>>(\n\t\t\targs: Args,\n\t\t): Promise<MutationResult<__APIClientOutput<A, Args>>> => {\n\t\t\treturn submit(args, \"mutation\") as Promise<\n\t\t\t\tMutationResult<__APIClientOutput<A, Args>>\n\t\t\t>;\n\t\t},\n\t\tmutateOrThrow: async <Args extends ToMutationArgs<A>>(\n\t\t\targs: Args,\n\t\t): Promise<__APIClientOutput<A, Args>> => {\n\t\t\tconst result = (await submit(args, \"mutation\")) as MutationResult<\n\t\t\t\t__APIClientOutput<A, Args>\n\t\t\t>;\n\t\t\tif (!result.success) {\n\t\t\t\tthrow new MutationError(result);\n\t\t\t}\n\t\t\treturn result.data;\n\t\t},\n\t\tquery: <Args extends ToQueryArgs<A>>(\n\t\t\targs: Args,\n\t\t): Promise<QueryResult<__APIClientOutput<A, Args>>> => {\n\t\t\treturn submit(args, \"query\") as Promise<\n\t\t\t\tQueryResult<__APIClientOutput<A, Args>>\n\t\t\t>;\n\t\t},\n\t\tqueryOrThrow: async <Args extends ToQueryArgs<A>>(\n\t\t\targs: Args,\n\t\t): Promise<__APIClientOutput<A, Args>> => {\n\t\t\tconst result = (await submit(args, \"query\")) as QueryResult<\n\t\t\t\t__APIClientOutput<A, Args>\n\t\t\t>;\n\t\t\tif (!result.success) {\n\t\t\t\tthrow new QueryError(result);\n\t\t\t}\n\t\t\treturn result.data;\n\t\t},\n\t};\n}\n","import {\n\tCSS_BUNDLE_ATTR,\n\tCSS_PRELOAD_ATTR,\n\tCSS_PRELOAD_SETTLED_ATTR,\n} from \"./constants.ts\";\n\nexport function preload_css(bundles: string[]): void {\n\tfor (const path of new Set(bundles)) {\n\t\tif (find_css_bundle(path)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\tdocument.head.querySelector(`link[${CSS_PRELOAD_ATTR}=\"${path}\"]`)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst link = document.createElement(\"link\");\n\t\tlink.rel = \"preload\";\n\t\tlink.setAttribute(\"as\", \"style\");\n\t\tlink.setAttribute(CSS_PRELOAD_ATTR, path);\n\t\tlink.setAttribute(CSS_PRELOAD_SETTLED_ATTR, \"0\");\n\t\tconst mark = () => {\n\t\t\tlink.setAttribute(CSS_PRELOAD_SETTLED_ATTR, \"1\");\n\t\t};\n\t\tlink.addEventListener(\"load\", mark);\n\t\tlink.addEventListener(\"error\", mark);\n\t\tlink.href = path;\n\t\tdocument.head.appendChild(link);\n\t}\n}\n\nexport async function wait_for_css(\n\tbundles: string[],\n\tsignal: AbortSignal,\n): Promise<void> {\n\tconst promises: Promise<void>[] = [];\n\n\tfor (const path of new Set(bundles)) {\n\t\tconst node = document.head.querySelector<HTMLLinkElement>(\n\t\t\t`link[${CSS_PRELOAD_ATTR}=\"${path}\"]`,\n\t\t);\n\t\tif (!node || node.getAttribute(CSS_PRELOAD_SETTLED_ATTR) === \"1\") {\n\t\t\tcontinue;\n\t\t}\n\t\tpromises.push(\n\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\tif (signal.aborted) {\n\t\t\t\t\tresolve();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst cleanup = () => {\n\t\t\t\t\tnode.removeEventListener(\"load\", done);\n\t\t\t\t\tnode.removeEventListener(\"error\", done);\n\t\t\t\t\tsignal.removeEventListener(\"abort\", on_abort);\n\t\t\t\t};\n\t\t\t\tconst done = () => {\n\t\t\t\t\tnode.setAttribute(CSS_PRELOAD_SETTLED_ATTR, \"1\");\n\t\t\t\t\tcleanup();\n\t\t\t\t\tresolve();\n\t\t\t\t};\n\t\t\t\tconst on_abort = () => {\n\t\t\t\t\tcleanup();\n\t\t\t\t\tresolve();\n\t\t\t\t};\n\t\t\t\tnode.addEventListener(\"load\", done, { once: true });\n\t\t\t\tnode.addEventListener(\"error\", done, { once: true });\n\t\t\t\tsignal.addEventListener(\"abort\", on_abort, { once: true });\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (promises.length > 0) {\n\t\tawait Promise.all(promises);\n\t}\n}\n\nexport function apply_css_bundles(bundles: string[]): void {\n\tfor (const path of new Set(bundles)) {\n\t\tif (find_css_bundle(path)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst link = document.createElement(\"link\");\n\t\tlink.rel = \"stylesheet\";\n\t\tlink.setAttribute(CSS_BUNDLE_ATTR, path);\n\t\tlink.href = path;\n\t\tdocument.head.appendChild(link);\n\t}\n}\n\nfunction find_css_bundle(path: string): HTMLLinkElement | null {\n\treturn document.head.querySelector<HTMLLinkElement>(\n\t\t`link[${CSS_BUNDLE_ATTR}=\"${path}\"]`,\n\t);\n}\n","import { R, type Result } from \"vorma/kit/result\";\n\nexport type HeadEl = {\n\ttag: string;\n\tattributesKnownSafe: Record<string, string>;\n\tbooleanAttributes?: string[] | null;\n\tdangerousInnerHTML?: string;\n};\n\ntype HeadSection = \"meta\" | \"rest\";\n\nexport function apply_head_and_title(\n\ttitle: string | undefined,\n\tmeta_els: HeadEl[],\n\trest_els: HeadEl[],\n): Result<void> {\n\tif (title !== undefined) {\n\t\tif (title !== \"\" || document.head.querySelector(\"title\")) {\n\t\t\tdocument.title = title;\n\t\t}\n\t}\n\tconst meta_res = reconcile_section(\"meta\", meta_els);\n\tif (!meta_res.ok) {\n\t\treturn R.err(meta_res.err);\n\t}\n\tconst res_res = reconcile_section(\"rest\", rest_els);\n\tif (!res_res.ok) {\n\t\treturn R.err(res_res.err);\n\t}\n\n\treturn R.ok(undefined);\n}\n\nfunction reconcile_section(section: HeadSection, els: HeadEl[]): Result<void> {\n\tconst boundary_res = find_boundary_comments(section);\n\tif (!boundary_res.ok) {\n\t\treturn R.err(boundary_res.err);\n\t}\n\tconst { start, end } = boundary_res.val;\n\tif (!start || !end || !end.parentNode) {\n\t\treturn R.err(\n\t\t\t`Invalid head section boundaries for section \"${section}\"`,\n\t\t);\n\t}\n\tconst parent = end.parentNode;\n\n\t// Collect current elements between markers\n\tconst current_elements: Element[] = [];\n\tlet node: Node | null = start.nextSibling;\n\twhile (node && node !== end) {\n\t\tif (node.nodeType === Node.ELEMENT_NODE) {\n\t\t\tcurrent_elements.push(node as Element);\n\t\t}\n\t\tnode = node.nextSibling;\n\t}\n\n\t// Build new elements from blocks\n\tconst new_elements: Element[] = [];\n\tconst new_element_fingerprints = new Map<string, Element>();\n\n\tfor (const block of els) {\n\t\tif (!block.tag) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst el = document.createElement(block.tag);\n\t\tif (block.attributesKnownSafe) {\n\t\t\tfor (const [key, value] of Object.entries(\n\t\t\t\tblock.attributesKnownSafe,\n\t\t\t)) {\n\t\t\t\tel.setAttribute(key, value);\n\t\t\t}\n\t\t}\n\t\tif (block.booleanAttributes) {\n\t\t\tfor (const key of block.booleanAttributes) {\n\t\t\t\tel.setAttribute(key, \"\");\n\t\t\t}\n\t\t}\n\t\tif (block.dangerousInnerHTML) {\n\t\t\tel.innerHTML = block.dangerousInnerHTML;\n\t\t}\n\n\t\tconst fp = fingerprint_element(el);\n\n\t\t// Deduplicate: if a later block has the same fingerprint,\n\t\t// it replaces the earlier one.\n\t\tif (new_element_fingerprints.has(fp)) {\n\t\t\tconst prev = new_element_fingerprints.get(fp)!;\n\t\t\tconst idx = new_elements.indexOf(prev);\n\t\t\tif (idx > -1) {\n\t\t\t\tnew_elements.splice(idx, 1);\n\t\t\t}\n\t\t}\n\t\tnew_elements.push(el);\n\t\tnew_element_fingerprints.set(fp, el);\n\t}\n\n\t// Build map of current elements by fingerprint\n\tconst current_by_fp = new Map<string, Element[]>();\n\tfor (const el of current_elements) {\n\t\tconst fp = fingerprint_element(el);\n\t\tconst list = current_by_fp.get(fp);\n\t\tif (list) {\n\t\t\tlist.push(el);\n\t\t} else {\n\t\t\tcurrent_by_fp.set(fp, [el]);\n\t\t}\n\t}\n\n\t// Match new elements to existing DOM elements by exact fingerprint\n\tconst final_elements: Element[] = [];\n\tconst used = new Set<Element>();\n\n\tfor (const new_el of new_elements) {\n\t\tconst fp = fingerprint_element(new_el);\n\t\tconst candidates = current_by_fp.get(fp) ?? [];\n\t\tconst matched = candidates.find((el) => {\n\t\t\treturn !used.has(el);\n\t\t});\n\n\t\tif (matched) {\n\t\t\tused.add(matched);\n\t\t\tfinal_elements.push(matched);\n\t\t} else {\n\t\t\tfinal_elements.push(new_el);\n\t\t}\n\t}\n\n\t// Remove elements that are no longer needed\n\tconst remaining = new Set(current_elements);\n\tfor (const el of current_elements) {\n\t\tif (!used.has(el)) {\n\t\t\tparent.removeChild(el);\n\t\t\tremaining.delete(el);\n\t\t}\n\t}\n\n\t// Remove stray text/comment nodes between markers\n\tnode = start.nextSibling;\n\twhile (node && node !== end) {\n\t\tconst next = node.nextSibling;\n\t\tif (node.nodeType !== Node.ELEMENT_NODE) {\n\t\t\tparent.removeChild(node);\n\t\t}\n\t\tnode = next;\n\t}\n\n\t// Position elements in correct order with minimal DOM operations\n\tlet last_processed: Element | null = null;\n\n\tfor (const element of final_elements) {\n\t\tconst is_existing = used.has(element);\n\n\t\tif (is_existing) {\n\t\t\tconst expected_next: Element | null = last_processed\n\t\t\t\t? last_processed.nextElementSibling\n\t\t\t\t: start.nextElementSibling;\n\n\t\t\tif (expected_next !== element) {\n\t\t\t\tparent.insertBefore(element, (expected_next as Node) ?? end);\n\t\t\t}\n\t\t\tremaining.delete(element);\n\t\t} else {\n\t\t\tconst insert_before = last_processed\n\t\t\t\t? last_processed.nextSibling\n\t\t\t\t: start.nextSibling;\n\t\t\tparent.insertBefore(element, insert_before ?? end);\n\t\t}\n\n\t\tlast_processed = element;\n\t}\n\n\treturn R.ok(undefined);\n}\n\nfunction find_boundary_comments(section: HeadSection): Result<{\n\tstart: Comment | undefined;\n\tend: Comment | undefined;\n}> {\n\tconst start_text = `vorma-${section}-start`;\n\tconst end_text = `vorma-${section}-end`;\n\tlet start: Comment | undefined;\n\tfor (const node of Array.from(document.head.childNodes)) {\n\t\tif (node.nodeType !== Node.COMMENT_NODE) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst val = (node as Comment).nodeValue?.trim();\n\t\tif (val === start_text) {\n\t\t\tstart = node as Comment;\n\t\t} else if (val === end_text && start) {\n\t\t\treturn R.ok({ start, end: node as Comment });\n\t\t}\n\t}\n\treturn R.err(\n\t\t`Could not find head boundary comments for section \"${section}\"`,\n\t);\n}\n\nfunction fingerprint_element(element: Element): string {\n\tconst attrs: string[] = [];\n\tfor (let i = 0; i < element.attributes.length; i++) {\n\t\tconst attr = element.attributes[i]!;\n\t\tconst value =\n\t\t\telement.hasAttribute(attr.name) && attr.value === \"\"\n\t\t\t\t? \"\"\n\t\t\t\t: attr.value;\n\t\tattrs.push(`${attr.name}=\"${value}\"`);\n\t}\n\tattrs.sort();\n\treturn `${element.tagName.toUpperCase()}|${attrs.join(\",\")}|${(element.innerHTML || \"\").trim()}`;\n}\n","/// <reference types=\"vite/client\" />\n\nexport function preload_modules(deps: string[]): void {\n\tif (import.meta.env.DEV) {\n\t\treturn;\n\t}\n\tfor (const dep of new Set(deps)) {\n\t\tif (\n\t\t\tdocument.head.querySelector(\n\t\t\t\t`link[rel=\"modulepreload\"][href=\"${dep}\"]`,\n\t\t\t)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst link = document.createElement(\"link\");\n\t\tlink.rel = \"modulepreload\";\n\t\tlink.href = dep;\n\t\tdocument.head.appendChild(link);\n\t}\n}\n","/// <reference types=\"vite/client\" />\n\nimport { jsonDeepEquals, parseSearchParams } from \"vorma/kit/json\";\nimport { addOnWindowFocusListener } from \"vorma/kit/listeners\";\nimport {\n\tcreatePatternRegistry,\n\tfindNestedMatches,\n\tregisterPattern,\n} from \"vorma/kit/matcher\";\nimport { R, type Result } from \"vorma/kit/result\";\nimport {\n\tBUILD_ID_HEADER,\n\tDATA_SCRIPT_ID,\n\tHISTORY_KEY_FIELD,\n\tHISTORY_USER_STATE_FIELD,\n\tSCROLL_STORAGE_KEY,\n\tSCROLL_STORAGE_RELOAD_KEY,\n\tVERCEL_DPL_QUERY_PARAM_KEY,\n\tVERCEL_X_DEPLOYMENT_ID,\n\tVORMA_JSON_KEY,\n\tVORMA_ROOT_EL_ID,\n\tX_ACCEPTS_CLIENT_REDIRECT,\n\tX_CLIENT_REDIRECT,\n\tX_VORMA_BUILD_SKEW,\n} from \"./constants.ts\";\nimport { apply_css_bundles, preload_css, wait_for_css } from \"./css.ts\";\nimport { apply_head_and_title, type HeadEl } from \"./head.ts\";\nimport { preload_modules } from \"./modules.ts\";\nimport type {\n\tAPIRouteKind,\n\tAppConfig,\n\tBeforeRouteCommitFn,\n\tBeforeRouteYieldFn,\n\tRevalidationResult,\n\tRouteErrorState,\n\tRouteState,\n\tRouteUpdateReason,\n} from \"./types.ts\";\n\n/////////////////////////////////////////////////////////////////////\n/////// Public Types\n/////////////////////////////////////////////////////////////////////\n\nexport type ScrollState = { x: number; y: number } | { hash: string };\n\nexport type ScrollIntent = {\n\tscroll: ScrollState;\n\ttarget_route_id: string;\n};\n\nexport type RouteRenderEntry = {\n\tpattern: string;\n\tinput: unknown;\n\tmodule_url: string;\n\tmodule: Record<string, unknown>;\n\tloader_data: unknown;\n\tclient_loader_data: unknown;\n};\n\nexport type RouteRenderState = {\n\tentries: RouteRenderEntry[];\n\terror: RouteErrorState | null;\n\tparams: Record<string, string>;\n\tsplat_values: string[];\n\tclient_build_id: string;\n\thistory_state: unknown;\n};\n\nexport type WorkState = {\n\tnavigation: null | {\n\t\thref: string;\n\t\treplace: boolean;\n\t\tsource: \"navigate\" | \"popstate\" | \"redirect\";\n\t};\n\trevalidation: null | {\n\t\tstatus: \"debouncing\" | \"running\" | \"retrying\";\n\t\tattempt: number;\n\t};\n\tprefetch: null | {\n\t\thref: string;\n\t};\n\tapiRequests: Array<{\n\t\tkey: string;\n\t\tmethod: string;\n\t\thref: string;\n\t}>;\n};\n\nexport type RevalidationReason =\n\t| \"manual\"\n\t| \"retry\"\n\t| \"apiRequest\"\n\t| \"windowFocus\";\n\nexport type BuildSkewDetectedEvent = {\n\tactiveClientBuildID: string;\n\tserverBuildID: string;\n\ttriggeringResponse:\n\t\t| {\n\t\t\t\tkind: \"route\";\n\t\t\t\ttrigger: \"navigation\" | \"popstate\" | \"prefetch\";\n\t\t\t\trequestedHref: string;\n\t\t\t\tstatus: number;\n\t\t\t\tok: boolean;\n\t\t }\n\t\t| {\n\t\t\t\tkind: \"route\";\n\t\t\t\ttrigger: \"revalidation\";\n\t\t\t\trevalidationReason: RevalidationReason;\n\t\t\t\trequestedHref: string;\n\t\t\t\tstatus: number;\n\t\t\t\tok: boolean;\n\t\t }\n\t\t| {\n\t\t\t\tkind: \"apiRoute\";\n\t\t\t\tapiRouteKind: APIRouteKind;\n\t\t\t\trequestedHref: string;\n\t\t\t\tmethod: string;\n\t\t\t\tstatus: number;\n\t\t\t\tok: boolean;\n\t\t };\n\tcurrentRouteState: RouteState;\n\tcurrentWorkState: WorkState;\n\tdefaultBehavior: \"dropResponse\" | \"hardReload\" | \"notifyOnly\";\n};\n\nexport type WorkIndicator = {\n\ttrack: <T>(promise: PromiseLike<T>) => Promise<T>;\n\tisActive: () => boolean;\n};\n\nexport type WorkIndicatorOptions = {\n\tshow: () => void;\n\thide: () => void;\n\tshowDelayMS?: number;\n\thideDelayMS?: number;\n\tskipNavigations?: boolean;\n\tskipAPIRequests?: boolean;\n\tskipRevalidations?: boolean;\n};\n\nexport type ClientOptions = {\n\trender?: () => void | Promise<void>;\n\tworkIndicator?: WorkIndicatorOptions;\n\trevalidateOnWindowFocus?: boolean | { staleTimeMS: number };\n\tdefaultErrorBoundary?: (props: { error: unknown }) => any;\n\tuseViewTransitions?: boolean;\n\tonRouteUpdate?: (\n\t\troute: RouteState,\n\t\tpreviousRoute: RouteState | null,\n\t\treason: RouteUpdateReason,\n\t) => void;\n\tonWorkUpdate?: (work: WorkState) => void;\n\tonBuildSkewDetected?: (event: BuildSkewDetectedEvent) => void;\n};\n\nexport type ClientCommit = {\n\troute_render?: {\n\t\tstate: RouteRenderState;\n\t\tscroll_intent?: ScrollIntent;\n\t};\n\troute_update?: {\n\t\tprevious_route: RouteState | null;\n\t\treason: RouteUpdateReason;\n\t\troute: RouteState;\n\t};\n\twork?: WorkState;\n};\n\nexport type CommitFn = (commit: ClientCommit) => void;\n\nexport type ViewDefinition = {\n\tpattern: string;\n\tcomponent: (props: any) => any;\n\terror_boundary?: (props: { error: unknown }) => any;\n\tclient_loader?: ClientLoaderFn;\n\tbefore_route_commit?: BeforeRouteCommitFn;\n\tbefore_route_yield?: BeforeRouteYieldFn;\n};\n\ntype ClientLoaderFn = (args: {\n\ttrigger: \"boot\" | \"navigation\" | \"revalidation\" | \"prefetch\";\n\thref: string;\n\thistoryState: unknown;\n\tpattern: string;\n\tparams: Record<string, string>;\n\tsplatValues: string[];\n\tinput: unknown;\n\tknownMatches: ClientLoaderKnownMatch[];\n\tserverPromise: Promise<ClientLoaderServerState>;\n\tsignal: AbortSignal;\n}) => Promise<unknown>;\n\ntype ClientLoaderKnownMatch = {\n\tpattern: string;\n\tinput: unknown;\n};\n\ntype ClientLoaderServerState = {\n\tclientBuildID: string;\n\tmatches: Array<{\n\t\tpattern: string;\n\t\tinput: unknown;\n\t\tloaderData: unknown;\n\t}>;\n\toutermostServerError: null | {\n\t\tidx: number;\n\t\terror: unknown;\n\t};\n\tloaderData: unknown;\n};\n\ntype APIResult<T> =\n\t| {\n\t\t\tsuccess: true;\n\t\t\tdata: T;\n\t\t\tresponse: Response;\n\t\t\trevalidationPromise: Promise<RevalidationResult>;\n\t }\n\t| {\n\t\t\tsuccess: false;\n\t\t\terror: string;\n\t\t\tresponse?: Response;\n\t\t\trevalidationPromise: Promise<RevalidationResult>;\n\t };\n\nexport type ClientCore = {\n\tboot: (options: ClientOptions) => Promise<Result<void>>;\n\tworkIndicator: WorkIndicator;\n\tnavigate: (\n\t\thref: string | URL,\n\t\toptions?: {\n\t\t\treplace?: boolean;\n\t\t\tscrollToTop?: boolean;\n\t\t\tstate?: unknown;\n\t\t\tskipWorkIndicator?: boolean;\n\t\t},\n\t) => Promise<{ didNavigate: boolean }>;\n\trevalidate: () => Promise<RevalidationResult>;\n\tsubmit_inner: <T = unknown>(\n\t\turl: string | URL,\n\t\trequestInit?: RequestInit,\n\t\toptions?: {\n\t\t\tapiRouteKind?: APIRouteKind;\n\t\t\tdedupeKey?: string;\n\t\t\trevalidate?: boolean;\n\t\t\tskipWorkIndicator?: boolean;\n\t\t},\n\t) => Promise<APIResult<T>>;\n\tgetRouteState: () => RouteState;\n\tgetWorkState: () => WorkState;\n\tgetClientBuildID: () => string;\n\tgetRootEl: () => HTMLElement;\n\tdefineView: <T = any>(input: {\n\t\tpattern: string;\n\t\tcomponent: (props: any) => any;\n\t\terrorBoundary?: (props: { error: unknown }) => any;\n\t\tclientLoader?: (props: any) => Promise<T>;\n\t\tbeforeRouteCommit?: BeforeRouteCommitFn;\n\t\tbeforeRouteYield?: BeforeRouteYieldFn;\n\t\trunClientLoaderOnHMR?: boolean;\n\t}) => ViewDefinition & { __phantom_client_loader_data?: T };\n\tstart_prefetch: (href: string) => void;\n\tstop_prefetch: (href: string) => void;\n\tsave_current_scroll: () => void;\n\tget_default_error_boundary: () =>\n\t\t| ((props: { error: unknown }) => any)\n\t\t| undefined;\n};\n\n/////////////////////////////////////////////////////////////////////\n/////// Constants\n/////////////////////////////////////////////////////////////////////\n\nexport const MAX_SCROLL_ENTRIES = 50;\nexport const REFRESH_MAX_AGE_MS = 3333;\nexport const MAX_REDIRECTS = 10;\nexport const REVALIDATION_DEBOUNCE_MS = 8;\nexport const MAX_REVALIDATION_RETRIES = 8;\nexport const REVALIDATION_BACKOFF_BASE_MS = 500;\nexport const REVALIDATION_BACKOFF_CAP_MS = 30000;\n\nconst REVALIDATION_OK: RevalidationResult = { ok: true };\nconst REVALIDATION_BUILD_SKEW: RevalidationResult = {\n\tok: false,\n\treason: \"build_skew\",\n};\nconst REVALIDATION_EXHAUSTED: RevalidationResult = {\n\tok: false,\n\treason: \"max_retries_exhausted\",\n};\nlet focus_revalidation_cleanup: (() => void) | null = null;\n\n/////////////////////////////////////////////////////////////////////\n/////// Module-Level Utilities\n/////////////////////////////////////////////////////////////////////\n\ntype TestOptions = {\n\treload?: () => void;\n\thard_redirect?: (url: string) => void;\n\tscroll_to?: (x: number, y: number) => void;\n};\n\nexport function apply_scroll(\n\tscroll: ScrollState | undefined,\n\ttest_options?: TestOptions,\n): void {\n\tif (!scroll) {\n\t\treturn;\n\t}\n\tif (\"hash\" in scroll) {\n\t\tconst raw = scroll.hash.startsWith(\"#\")\n\t\t\t? scroll.hash.slice(1)\n\t\t\t: scroll.hash;\n\t\tlet id: string;\n\t\ttry {\n\t\t\tid = decodeURIComponent(raw);\n\t\t} catch {\n\t\t\tid = raw;\n\t\t}\n\t\tdocument.getElementById(id)?.scrollIntoView();\n\t\treturn;\n\t}\n\tconst scroll_to =\n\t\ttest_options?.scroll_to ??\n\t\t((x: number, y: number) => {\n\t\t\twindow.scrollTo(x, y);\n\t\t});\n\tscroll_to(scroll.x, scroll.y);\n}\n\nexport function make_route_id(idx: number, pattern: string): string {\n\treturn `${idx}:${pattern}`;\n}\n\nfunction is_abort_error(e: unknown): boolean {\n\treturn e instanceof DOMException && e.name === \"AbortError\";\n}\n\nfunction new_abort_error(): DOMException {\n\treturn new DOMException(\"Aborted\", \"AbortError\");\n}\n\nfunction to_error_string(err: unknown): string {\n\treturn err instanceof Error ? err.message : String(err);\n}\n\nfunction normalize_module_url(url: string): string {\n\treturn new URL(url, window.location.href).pathname;\n}\n\ntype Deferred<T> = {\n\tpromise: Promise<T>;\n\tresolve: (value: T) => void;\n};\n\nfunction make_deferred<T>(): Deferred<T> {\n\tlet resolve!: (v: T) => void;\n\tconst promise = new Promise<T>((r) => {\n\t\tresolve = r;\n\t});\n\treturn { promise, resolve };\n}\n\ntype WorkIndicatorController = {\n\tindicator: WorkIndicator;\n\tconfigure: (options: WorkIndicatorOptions | undefined) => void;\n\tset_vorma_active: (active: boolean) => void;\n};\n\nfunction create_work_indicator(): WorkIndicatorController {\n\tlet options: WorkIndicatorOptions | undefined;\n\tlet visible = false;\n\tlet show_timer: number | undefined;\n\tlet hide_timer: number | undefined;\n\tconst active_tokens = new Set<symbol>();\n\tlet release_vorma_work: (() => void) | undefined;\n\n\tfunction clear_show_timer(): void {\n\t\tif (show_timer === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tclearTimeout(show_timer);\n\t\tshow_timer = undefined;\n\t}\n\n\tfunction clear_hide_timer(): void {\n\t\tif (hide_timer === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tclearTimeout(hide_timer);\n\t\thide_timer = undefined;\n\t}\n\n\tfunction sync(): void {\n\t\tconst current_options = options;\n\t\tif (!current_options) {\n\t\t\tclear_show_timer();\n\t\t\tclear_hide_timer();\n\t\t\treturn;\n\t\t}\n\n\t\tif (active_tokens.size > 0) {\n\t\t\tclear_hide_timer();\n\t\t\tif (visible || show_timer !== undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tshow_timer = window.setTimeout(() => {\n\t\t\t\tshow_timer = undefined;\n\t\t\t\tconst latest_options = options;\n\t\t\t\tif (!latest_options || active_tokens.size === 0 || visible) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlatest_options.show();\n\t\t\t\tvisible = true;\n\t\t\t}, current_options.showDelayMS ?? 12);\n\t\t\treturn;\n\t\t}\n\n\t\tclear_show_timer();\n\t\tif (hide_timer !== undefined) {\n\t\t\treturn;\n\t\t}\n\t\thide_timer = window.setTimeout(() => {\n\t\t\thide_timer = undefined;\n\t\t\tconst latest_options = options;\n\t\t\tif (!latest_options || active_tokens.size > 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlatest_options.hide();\n\t\t\tvisible = false;\n\t\t}, current_options.hideDelayMS ?? 12);\n\t}\n\n\tfunction begin(): () => void {\n\t\tconst token = Symbol(\"v-work-indicator\");\n\t\tlet released = false;\n\t\tactive_tokens.add(token);\n\t\tsync();\n\t\treturn () => {\n\t\t\tif (released) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treleased = true;\n\t\t\tactive_tokens.delete(token);\n\t\t\tsync();\n\t\t};\n\t}\n\n\tfunction configure(next_options: WorkIndicatorOptions | undefined): void {\n\t\tconst previous_options = options;\n\t\tclear_show_timer();\n\t\tclear_hide_timer();\n\t\tif (visible && previous_options && previous_options !== next_options) {\n\t\t\tprevious_options.hide();\n\t\t\tvisible = false;\n\t\t}\n\t\toptions = next_options;\n\t\tsync();\n\t}\n\n\tfunction set_vorma_active(active: boolean): void {\n\t\tif (active) {\n\t\t\tif (!release_vorma_work) {\n\t\t\t\trelease_vorma_work = begin();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (!release_vorma_work) {\n\t\t\tsync();\n\t\t\treturn;\n\t\t}\n\t\trelease_vorma_work();\n\t\trelease_vorma_work = undefined;\n\t}\n\n\treturn {\n\t\tindicator: {\n\t\t\ttrack: <T>(promise: PromiseLike<T>): Promise<T> => {\n\t\t\t\tconst release = begin();\n\t\t\t\treturn Promise.resolve(promise).finally(() => {\n\t\t\t\t\trelease();\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (): boolean => {\n\t\t\t\treturn active_tokens.size > 0;\n\t\t\t},\n\t\t},\n\t\tconfigure,\n\t\tset_vorma_active,\n\t};\n}\n\n/////////////////////////////////////////////////////////////////////\n/////// Client Core\n/////////////////////////////////////////////////////////////////////\n\nexport function create_client_core(\n\t_: Omit<AppConfig, \"__vormaViews\" | \"__vormaAPIRoutes\">,\n\tcommit: CommitFn,\n\ttest_options?: TestOptions,\n): Result<ClientCore> {\n\t/////// Pattern Registry\n\tconst registry_res = createPatternRegistry({\n\t\tdynamicParamPrefixRune: \":\",\n\t\tsplatSegmentRune: \"*\",\n\t\texplicitIndexSegment: \"_index\",\n\t});\n\tif (!registry_res.ok) {\n\t\treturn R.err(`Failed to create pattern registry: ${registry_res.err}`);\n\t}\n\tconst pattern_registry = registry_res.val;\n\n\t/////// Internal Types\n\n\ttype HistoryPosition = {\n\t\thref: string;\n\t\tkey: string;\n\t\tstate: unknown;\n\t};\n\n\ttype RouteSnapshot = {\n\t\tposition: HistoryPosition;\n\t\troute: RouteRecord;\n\t};\n\n\ttype RouteRecord = {\n\t\tparams: Record<string, string>;\n\t\tsplat_values: string[];\n\t\tmatches: RouteMatchRecord[];\n\t\terror: RouteErrorState | null;\n\t\tclient_build_id: string;\n\t};\n\n\ttype RouteMatchRecord = {\n\t\tpattern: string;\n\t\tinput: unknown;\n\t\tmodule_url: string;\n\t\tmodule: Record<string, unknown>;\n\t\tloader_data: unknown;\n\t\tclient_loader_data: unknown;\n\t};\n\n\ttype RouteRenderCommitReason =\n\t\t| \"initial\"\n\t\t| \"navigation\"\n\t\t| \"popstate\"\n\t\t| \"revalidation\"\n\t\t| \"hmr\";\n\n\ttype WorkProjection =\n\t\t| {\n\t\t\t\tkind: \"navigation\";\n\t\t\t\tskip_work_indicator?: boolean;\n\t\t }\n\t\t| {\n\t\t\t\tkind: \"revalidation\";\n\t\t }\n\t\t| {\n\t\t\t\tkind: \"apiRequest\";\n\t\t\t\tskip_work_indicator?: boolean;\n\t\t }\n\t\t| {\n\t\t\t\tkind: \"prefetch\";\n\t\t };\n\n\ttype NavOptions = {\n\t\treplace?: boolean;\n\t\tscroll_to_top?: boolean;\n\t\tstate?: unknown;\n\t\tis_popstate?: boolean;\n\t\tpopstate_scroll?: ScrollState;\n\t\tskip_work_indicator?: boolean;\n\t};\n\n\ttype NavResult = { didNavigate: boolean };\n\n\ttype RedirectResult = \"settled\" | \"transferred\";\n\n\ttype NavigationSource = \"navigate\" | \"popstate\" | \"redirect\";\n\n\ttype NavFetchIntent = {\n\t\tkind: \"nav\";\n\t\turl: URL;\n\t\toptions: NavOptions;\n\t\tsource: NavigationSource;\n\t\tredirect_count: number;\n\t\tdeferred: Deferred<NavResult>;\n\t};\n\n\ttype RevalidationFetchIntent = {\n\t\tkind: \"reval\";\n\t\tattempt: number;\n\t\treason: RevalidationReason;\n\t};\n\n\ttype ActiveFetchIntent = NavFetchIntent | RevalidationFetchIntent;\n\n\ttype PrefetchFetchIntent = { kind: \"prefetch\" };\n\n\ttype FetchIntent = ActiveFetchIntent | PrefetchFetchIntent;\n\n\ttype FetchBase = {\n\t\turl: URL; // what we asked the server for (minus hash sensitivity)\n\t\tac: AbortController;\n\t\tseq: number;\n\t\tdata_promise: Promise<FetchResult>;\n\t\tcl_prefetches: ClientLoaderPrefetch[];\n\t};\n\n\ttype ActiveFetch = FetchBase & {\n\t\t// Resolves when prefetch-phase preparation (modules, client-loader\n\t\t// prefetch seeding) is done after a prefetch is promoted.\n\t\tprepare_ready: Promise<void>;\n\t\tintent: ActiveFetchIntent;\n\t};\n\n\ttype PrefetchFetch = FetchBase & {\n\t\tis_pending: boolean;\n\t\tprepare_ready: Promise<void>;\n\t\tintent: PrefetchFetchIntent;\n\t};\n\n\ttype FetchResult =\n\t\t| { kind: \"data\"; data: unknown; response: Response }\n\t\t| { kind: \"build_skew\"; response: Response }\n\t\t| { kind: \"redirect\"; href: string; hard: boolean; response: Response }\n\t\t| {\n\t\t\t\tkind: \"error\";\n\t\t\t\tstatus: number;\n\t\t\t\tstatus_text: string;\n\t\t\t\tresponse?: Response;\n\t\t };\n\n\ttype ClientLoaderPrefetch = {\n\t\tpattern: string;\n\t\tresolve_server_state: (data: ClientLoaderServerState) => void;\n\t\tabort: () => void;\n\t\tresult_promise: Promise<unknown>;\n\t};\n\n\ttype DecodedRoute = {\n\t\tpattern: string;\n\t\tinput: unknown;\n\t\tmodule_url: string;\n\t\tloader_data: unknown;\n\t\tserver_error: unknown;\n\t};\n\n\ttype DecodedPayload = {\n\t\troutes: DecodedRoute[];\n\t\tparams: Record<string, string>;\n\t\tsplat_values: string[];\n\t\ttitle: string | undefined;\n\t\tmeta_head_els: HeadEl[];\n\t\trest_head_els: HeadEl[];\n\t\tcss_bundles: string[];\n\t\tdeps: string[];\n\t};\n\n\ttype PreparedRoute = {\n\t\troute: RouteRecord;\n\t\tapply_dom_side_effects: () => void;\n\t};\n\n\ttype Submission = {\n\t\tac: AbortController;\n\t\tkey: string;\n\t\tmethod: string;\n\t\thref: string;\n\t\tskip_work_indicator?: boolean;\n\t};\n\n\ttype RefreshWaiter = Deferred<RevalidationResult>;\n\n\ttype RefreshDemand = {\n\t\t// A fetch with seq > this value satisfies the demand.\n\t\tafter_seq: number;\n\t\treason: RevalidationReason;\n\t\twaiters: RefreshWaiter[];\n\t};\n\n\ttype RefreshState =\n\t\t| { kind: \"idle\" }\n\t\t| { kind: \"pending\"; demand: RefreshDemand; attempt: number }\n\t\t| {\n\t\t\t\tkind: \"debouncing\";\n\t\t\t\tdemand: RefreshDemand;\n\t\t\t\ttimer: ReturnType<typeof setTimeout>;\n\t\t }\n\t\t| {\n\t\t\t\tkind: \"retrying\";\n\t\t\t\tdemand: RefreshDemand;\n\t\t\t\tattempt: number;\n\t\t\t\ttimer: ReturnType<typeof setTimeout>;\n\t\t };\n\n\ttype StoredScrollEntry = [string, { x: number; y: number }];\n\n\t/*\n\tNine base facts:\n\n\t 1. phase: router lifecycle ('booting' | 'ready')\n\t 2. browser: the browser's current history entry\n\t 3. route_snapshot: current route data available to Vorma APIs\n\t 4. active: the one in-flight nav or revalidation (at most one, ever)\n\t 5. prefetch: the at-most-one in-flight prefetch\n\t 6. refresh: outstanding route data demand and its retry timing\n\t 7. apiRequests: concurrent action requests (independent of routes)\n\t 8. deferred_submit_redirect: submit redirect waiting for boot completion\n\t 9. seq: monotonic counter; refresh is ordered by seq, never wall clock\n\n\tAborting a fetch and publishing a route are each single operations.\n\n\tWorkProjection and WorkState are derived from these facts. RouteRenderState\n\tis derived only at the adapter commit boundary.\n\t*/\n\n\t/////// Base Facts\n\n\tlet phase: \"booting\" | \"ready\" = \"booting\";\n\tlet browser: HistoryPosition = { href: \"\", key: \"\", state: undefined };\n\tlet route_snapshot: RouteSnapshot | null = null;\n\tlet active: ActiveFetch | null = null;\n\tlet prefetch: PrefetchFetch | null = null;\n\tlet refresh: RefreshState = { kind: \"idle\" };\n\tconst submissions = new Map<string, Submission>();\n\tlet seq = 0;\n\n\t/////// Config And Listeners\n\n\tlet client_build_id = \"\";\n\tlet deployment_id = \"\";\n\tlet use_view_transitions = false;\n\tlet default_error_boundary:\n\t\t| ((props: { error: unknown }) => any)\n\t\t| undefined;\n\tlet user_on_route_update:\n\t\t| ((\n\t\t\t\troute: RouteState,\n\t\t\t\tpreviousRoute: RouteState | null,\n\t\t\t\treason: RouteUpdateReason,\n\t\t ) => void)\n\t\t| undefined;\n\tlet user_on_work_update: ((work: WorkState) => void) | undefined;\n\tlet user_on_build_skew_detected:\n\t\t| ((event: BuildSkewDetectedEvent) => void)\n\t\t| undefined;\n\tlet deferred_submit_redirect: URL | null = null;\n\tlet last_activity_ts = Date.now();\n\tlet last_work_state: WorkState = empty_work_state();\n\n\tconst work_indicator = create_work_indicator();\n\tlet work_indicator_options: WorkIndicatorOptions | undefined;\n\tlet work_indicator_sync_registered = false;\n\tconst work_update_listeners = new Set<(work: WorkState) => void>();\n\tconst module_map: Record<string, ClientLoaderFn> = {};\n\tconst search_schema_map: Record<string, unknown> = {};\n\tconst hmr_rerun_patterns = new Set<string>();\n\tconst module_cache = new Map<string, Record<string, unknown>>();\n\n\tconst reload_page =\n\t\ttest_options?.reload ??\n\t\t(() => {\n\t\t\twindow.location.reload();\n\t\t});\n\tconst hard_redirect =\n\t\ttest_options?.hard_redirect ??\n\t\t((url: string) => {\n\t\t\twindow.location.assign(url);\n\t\t});\n\n\t/////// URL And History\n\n\tfunction current_url(): URL {\n\t\treturn new URL(window.location.href);\n\t}\n\n\tfunction next_seq(): number {\n\t\tseq++;\n\t\treturn seq;\n\t}\n\n\tfunction is_http(href: string): boolean {\n\t\ttry {\n\t\t\tconst p = new URL(href).protocol;\n\t\t\treturn p === \"http:\" || p === \"https:\";\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction is_same_origin(url: URL): boolean {\n\t\treturn url.origin === current_url().origin;\n\t}\n\n\tfunction is_same_origin_href(href: string): boolean {\n\t\ttry {\n\t\t\treturn new URL(href).origin === current_url().origin;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction matches_without_hash(a: URL, b: URL): boolean {\n\t\tconst x = new URL(a.href);\n\t\tx.hash = \"\";\n\t\tconst y = new URL(b.href);\n\t\ty.hash = \"\";\n\t\treturn x.href === y.href;\n\t}\n\n\tfunction route_snapshot_matches(url: URL): boolean {\n\t\treturn (\n\t\t\troute_snapshot !== null &&\n\t\t\tmatches_without_hash(url, new URL(route_snapshot.position.href))\n\t\t);\n\t}\n\n\tfunction normalize_hash(hash: string): string {\n\t\tconst s = hash.startsWith(\"#\") ? hash.slice(1) : hash;\n\t\tif (s.length === 0) {\n\t\t\treturn s;\n\t\t}\n\t\ttry {\n\t\t\treturn decodeURIComponent(s);\n\t\t} catch {\n\t\t\treturn s;\n\t\t}\n\t}\n\n\tfunction make_history_key(): string {\n\t\treturn Math.random().toString(36).slice(2, 10);\n\t}\n\n\tfunction read_browser_position(): HistoryPosition {\n\t\tconst state = window.history.state;\n\t\tconst key =\n\t\t\tstate && typeof state === \"object\" && HISTORY_KEY_FIELD in state\n\t\t\t\t? (state as Record<string, string>)[HISTORY_KEY_FIELD]!\n\t\t\t\t: \"\";\n\t\treturn {\n\t\t\thref: current_url().href,\n\t\t\tkey,\n\t\t\tstate: state?.[HISTORY_USER_STATE_FIELD],\n\t\t};\n\t}\n\n\tfunction commit_history(\n\t\turl: string,\n\t\treplace: boolean | undefined,\n\t\tuser_state: unknown,\n\t): HistoryPosition {\n\t\tconst key = make_history_key();\n\t\tconst next_state: Record<string, unknown> = {\n\t\t\t[HISTORY_KEY_FIELD]: key,\n\t\t\t[HISTORY_USER_STATE_FIELD]: user_state,\n\t\t};\n\n\t\tif (replace) {\n\t\t\tconst existing = window.history.state;\n\t\t\tconst base =\n\t\t\t\texisting && typeof existing === \"object\" ? existing : {};\n\t\t\twindow.history.replaceState(\n\t\t\t\t{ ...(base as object), ...next_state },\n\t\t\t\t\"\",\n\t\t\t\turl,\n\t\t\t);\n\t\t} else {\n\t\t\twindow.history.pushState(next_state, \"\", url);\n\t\t}\n\n\t\tbrowser = { href: url, key, state: user_state };\n\t\treturn browser;\n\t}\n\n\tfunction route_snapshot_matches_browser(): boolean {\n\t\treturn (\n\t\t\troute_snapshot !== null &&\n\t\t\troute_snapshot.position.href === browser.href &&\n\t\t\troute_snapshot.position.key === browser.key\n\t\t);\n\t}\n\n\t/////// Scroll Storage\n\n\tfunction get_scroll_pos(): { x: number; y: number } {\n\t\treturn { x: window.scrollX, y: window.scrollY };\n\t}\n\n\tfunction read_scroll_entries(): StoredScrollEntry[] {\n\t\ttry {\n\t\t\tconst raw = sessionStorage.getItem(SCROLL_STORAGE_KEY);\n\t\t\tif (!raw) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst parsed = JSON.parse(raw);\n\t\t\tif (!Array.isArray(parsed)) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\treturn parsed.filter((e: unknown): e is StoredScrollEntry => {\n\t\t\t\treturn (\n\t\t\t\t\tArray.isArray(e) &&\n\t\t\t\t\te.length === 2 &&\n\t\t\t\t\ttypeof e[0] === \"string\" &&\n\t\t\t\t\t!!e[1] &&\n\t\t\t\t\ttypeof e[1] === \"object\" &&\n\t\t\t\t\tNumber.isFinite((e[1] as any).x) &&\n\t\t\t\t\tNumber.isFinite((e[1] as any).y)\n\t\t\t\t);\n\t\t\t});\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\n\tfunction save_scroll_for_key(\n\t\tkey: string,\n\t\tpos: { x: number; y: number },\n\t): void {\n\t\tconst entries = read_scroll_entries().filter((e) => e[0] !== key);\n\t\tentries.push([key, pos]);\n\t\tif (entries.length > MAX_SCROLL_ENTRIES) {\n\t\t\tentries.splice(0, entries.length - MAX_SCROLL_ENTRIES);\n\t\t}\n\t\ttry {\n\t\t\tsessionStorage.setItem(SCROLL_STORAGE_KEY, JSON.stringify(entries));\n\t\t} catch {}\n\t}\n\n\tfunction get_scroll_for_key(\n\t\tkey: string,\n\t): { x: number; y: number } | undefined {\n\t\tfor (const [k, v] of read_scroll_entries()) {\n\t\t\tif (k === key) {\n\t\t\t\treturn v;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tfunction save_current_scroll(): void {\n\t\tif (browser.key) {\n\t\t\tsave_scroll_for_key(browser.key, get_scroll_pos());\n\t\t}\n\t}\n\n\t/////// Payload Decoding\n\n\tfunction decode_payload(raw: unknown, url: URL): DecodedPayload {\n\t\tconst p = raw as Record<string, any>;\n\t\tconst patterns: string[] = p.MatchedPatterns ?? [];\n\t\tconst schemas: unknown[] = Array.isArray(p.SearchSchemas)\n\t\t\t? p.SearchSchemas\n\t\t\t: [];\n\t\tconst loaders_data: unknown[] = p.LoadersData ?? [];\n\t\tconst import_urls: string[] = p.ImportURLs ?? [];\n\t\tconst err_idx: number | null = p.OutermostServerErrIdx ?? null;\n\t\tconst err_msg: string = p.OutermostServerErr ?? \"\";\n\t\tconst search_params = url.searchParams;\n\n\t\tconst routes: DecodedRoute[] = patterns.map((pattern, i) => {\n\t\t\tconst schema = schemas[i];\n\t\t\tsearch_schema_map[pattern] = schema;\n\t\t\treturn {\n\t\t\t\tpattern,\n\t\t\t\tinput: parseSearchParams(schema, search_params),\n\t\t\t\tmodule_url: import_urls[i] ?? \"\",\n\t\t\t\tloader_data: loaders_data[i],\n\t\t\t\tserver_error:\n\t\t\t\t\terr_idx !== null && i === err_idx ? err_msg : undefined,\n\t\t\t};\n\t\t});\n\n\t\tlet title: string | undefined;\n\t\tif (p.Title?.dangerousInnerHTML !== undefined) {\n\t\t\tconst el = document.createElement(\"textarea\");\n\t\t\tel.innerHTML = p.Title.dangerousInnerHTML;\n\t\t\ttitle = el.value;\n\t\t}\n\n\t\treturn {\n\t\t\troutes,\n\t\t\tparams: p.Params ?? {},\n\t\t\tsplat_values: p.SplatValues ?? [],\n\t\t\ttitle,\n\t\t\tmeta_head_els: p.MetaHeadEls ?? [],\n\t\t\trest_head_els: p.RestHeadEls ?? [],\n\t\t\tcss_bundles: p.CSSBundles ?? [],\n\t\t\tdeps: p.Deps ?? [],\n\t\t};\n\t}\n\n\t/////// Modules And Client Loader Prefetches\n\n\tfunction make_cl_prefetch(input: {\n\t\thref: string;\n\t\thistory_state: unknown;\n\t\tknown_matches: ClientLoaderKnownMatch[];\n\t\tloader: ClientLoaderFn;\n\t\tparams: Record<string, string>;\n\t\tpattern: string;\n\t\troute_input: unknown;\n\t\tsignal: AbortSignal;\n\t\tsplat_values: string[];\n\t\ttrigger: \"navigation\" | \"revalidation\" | \"prefetch\";\n\t}): ClientLoaderPrefetch {\n\t\tlet resolve_server_state!: (v: ClientLoaderServerState) => void;\n\t\tlet reject_server_state!: (err: unknown) => void;\n\t\tconst server_promise = new Promise<ClientLoaderServerState>(\n\t\t\t(res, rej) => {\n\t\t\t\tresolve_server_state = res;\n\t\t\t\treject_server_state = rej;\n\t\t\t},\n\t\t);\n\t\tserver_promise.catch(() => {});\n\n\t\tconst ac = new AbortController();\n\t\tif (input.signal.aborted) {\n\t\t\tac.abort();\n\t\t\treject_server_state(new_abort_error());\n\t\t} else {\n\t\t\tinput.signal.addEventListener(\n\t\t\t\t\"abort\",\n\t\t\t\t() => {\n\t\t\t\t\tac.abort();\n\t\t\t\t\treject_server_state(new_abort_error());\n\t\t\t\t},\n\t\t\t\t{ once: true },\n\t\t\t);\n\t\t}\n\n\t\tconst result_promise = input.loader({\n\t\t\ttrigger: input.trigger,\n\t\t\thref: input.href,\n\t\t\thistoryState: input.history_state,\n\t\t\tpattern: input.pattern,\n\t\t\tparams: input.params,\n\t\t\tsplatValues: input.splat_values,\n\t\t\tinput: input.route_input,\n\t\t\tknownMatches: input.known_matches,\n\t\t\tserverPromise: server_promise,\n\t\t\tsignal: ac.signal,\n\t\t});\n\t\tresult_promise.catch(() => {});\n\n\t\treturn {\n\t\t\tpattern: input.pattern,\n\t\t\tresolve_server_state,\n\t\t\tabort: () => {\n\t\t\t\tac.abort();\n\t\t\t\treject_server_state(new_abort_error());\n\t\t\t},\n\t\t\tresult_promise,\n\t\t};\n\t}\n\n\tfunction routes_to_known_matches(\n\t\troutes: DecodedRoute[],\n\t): ClientLoaderKnownMatch[] {\n\t\treturn routes.map((r) => {\n\t\t\treturn {\n\t\t\t\tpattern: r.pattern,\n\t\t\t\tinput: r.input,\n\t\t\t};\n\t\t});\n\t}\n\n\tfunction build_server_state(\n\t\troutes: DecodedRoute[],\n\t\tidx: number,\n\t): ClientLoaderServerState {\n\t\tconst err_idx = routes.findIndex((r) => {\n\t\t\treturn r.server_error !== undefined;\n\t\t});\n\t\treturn {\n\t\t\tclientBuildID: client_build_id,\n\t\t\tmatches: routes.map((r) => {\n\t\t\t\treturn {\n\t\t\t\t\tpattern: r.pattern,\n\t\t\t\t\tinput: r.input,\n\t\t\t\t\tloaderData: r.loader_data,\n\t\t\t\t};\n\t\t\t}),\n\t\t\toutermostServerError:\n\t\t\t\terr_idx === -1\n\t\t\t\t\t? null\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tidx: err_idx,\n\t\t\t\t\t\t\terror: routes[err_idx]!.server_error,\n\t\t\t\t\t\t},\n\t\t\tloaderData: routes[idx]?.loader_data,\n\t\t};\n\t}\n\n\tasync function run_client_loaders(\n\t\troutes: DecodedRoute[],\n\t\tpayload: DecodedPayload,\n\t\tcl_prefetches: ClientLoaderPrefetch[],\n\t\ttrigger: \"boot\" | \"navigation\" | \"revalidation\",\n\t\thref: string,\n\t\thistory_state: unknown,\n\t\tsignal: AbortSignal,\n\t): Promise<Array<{ data: unknown } | { error: unknown } | undefined>> {\n\t\tconst by_pattern = new Map<string, ClientLoaderPrefetch>();\n\t\tfor (const p of cl_prefetches) {\n\t\t\tby_pattern.set(p.pattern, p);\n\t\t}\n\t\tconst err_idx = routes.findIndex((r) => r.server_error !== undefined);\n\t\tconst known_matches = routes_to_known_matches(routes);\n\n\t\tconst abort_later: Array<(() => void) | null> = [];\n\t\tconst promises: Array<Promise<unknown>> = [];\n\t\tconst retained_prefetches = new Set<ClientLoaderPrefetch>();\n\n\t\tfor (let i = 0; i < routes.length; i++) {\n\t\t\tconst route = routes[i]!;\n\t\t\tconst existing = by_pattern.get(route.pattern);\n\t\t\tif (err_idx !== -1 && i >= err_idx) {\n\t\t\t\texisting?.abort();\n\t\t\t\tpromises.push(Promise.resolve(undefined));\n\t\t\t\tabort_later.push(null);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (existing) {\n\t\t\t\texisting.resolve_server_state(build_server_state(routes, i));\n\t\t\t\tretained_prefetches.add(existing);\n\t\t\t\tabort_later.push(existing.abort);\n\t\t\t\tpromises.push(existing.result_promise);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst loader = module_map[route.pattern];\n\t\t\tif (!loader) {\n\t\t\t\tpromises.push(Promise.resolve(undefined));\n\t\t\t\tabort_later.push(null);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst ac = new AbortController();\n\t\t\tabort_later.push(() => {\n\t\t\t\tac.abort();\n\t\t\t});\n\t\t\tif (signal.aborted) {\n\t\t\t\tac.abort();\n\t\t\t} else {\n\t\t\t\tsignal.addEventListener(\"abort\", () => ac.abort(), {\n\t\t\t\t\tonce: true,\n\t\t\t\t});\n\t\t\t}\n\t\t\tpromises.push(\n\t\t\t\tloader({\n\t\t\t\t\ttrigger,\n\t\t\t\t\thref,\n\t\t\t\t\thistoryState: history_state,\n\t\t\t\t\tpattern: route.pattern,\n\t\t\t\t\tparams: payload.params,\n\t\t\t\t\tsplatValues: payload.splat_values,\n\t\t\t\t\tinput: route.input,\n\t\t\t\t\tknownMatches: known_matches,\n\t\t\t\t\tserverPromise: Promise.resolve(\n\t\t\t\t\t\tbuild_server_state(routes, i),\n\t\t\t\t\t),\n\t\t\t\t\tsignal: ac.signal,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tfor (const p of cl_prefetches) {\n\t\t\tif (!retained_prefetches.has(p)) {\n\t\t\t\tp.abort();\n\t\t\t}\n\t\t}\n\n\t\tconst wrapped = promises.map(async (p, i) => {\n\t\t\treturn p.catch((err) => {\n\t\t\t\t// On non-abort failure, cascade abort to later routes to avoid\n\t\t\t\t// running loaders that can never be used.\n\t\t\t\tif (!is_abort_error(err)) {\n\t\t\t\t\tfor (let j = i + 1; j < abort_later.length; j++) {\n\t\t\t\t\t\tabort_later[j]?.();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow err;\n\t\t\t});\n\t\t});\n\n\t\tconst settled = await Promise.allSettled(wrapped);\n\t\tconst out: Array<{ data: unknown } | { error: unknown } | undefined> =\n\t\t\t[];\n\t\tfor (const r of settled) {\n\t\t\tif (r.status === \"fulfilled\") {\n\t\t\t\tout.push(r.value !== undefined ? { data: r.value } : undefined);\n\t\t\t} else if (!is_abort_error(r.reason)) {\n\t\t\t\tout.push({ error: to_error_string(r.reason) });\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tout.push(undefined);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\n\t/////// Route Preparation\n\n\tasync function prepare_modules(\n\t\tpayload: DecodedPayload,\n\t\tsignal: AbortSignal,\n\t): Promise<Map<string, Record<string, unknown>> | null> {\n\t\tpreload_css(payload.css_bundles);\n\t\tconst urls = payload.routes.map((r) => {\n\t\t\treturn r.module_url;\n\t\t});\n\t\tconst unique = [...new Set(urls.filter(Boolean))];\n\t\tconst pairs = await Promise.all(\n\t\t\tunique.map(async (url) => {\n\t\t\t\tif (import.meta.env.DEV) {\n\t\t\t\t\tconst key = normalize_module_url(url);\n\t\t\t\t\tconst cached = module_cache.get(key);\n\t\t\t\t\tif (cached) {\n\t\t\t\t\t\treturn [url, cached] as const;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst mod = (await import(/* @vite-ignore */ url)) as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\tunknown\n\t\t\t\t>;\n\t\t\t\tif (import.meta.env.DEV) {\n\t\t\t\t\tmodule_cache.set(normalize_module_url(url), mod);\n\t\t\t\t}\n\t\t\t\treturn [url, mod] as const;\n\t\t\t}),\n\t\t);\n\t\tconst modules = new Map(pairs);\n\t\tif (signal.aborted) {\n\t\t\treturn null;\n\t\t}\n\t\tfor (const route of payload.routes) {\n\t\t\tconst mod = modules.get(route.module_url);\n\t\t\tif (!mod) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst def = mod.default as ViewDefinition | undefined;\n\t\t\tif (def?.client_loader) {\n\t\t\t\tmodule_map[route.pattern] = def.client_loader;\n\t\t\t\tregisterPattern(pattern_registry, route.pattern);\n\t\t\t}\n\t\t}\n\t\treturn modules;\n\t}\n\n\tfunction build_route_record(\n\t\tpayload: DecodedPayload,\n\t\tmodules: Map<string, Record<string, unknown>>,\n\t\tcl_results: Array<{ data: unknown } | { error: unknown } | undefined>,\n\t): RouteRecord {\n\t\tconst matches: RouteMatchRecord[] = payload.routes.map((route, i) => {\n\t\t\tconst cl = cl_results[i];\n\t\t\treturn {\n\t\t\t\tpattern: route.pattern,\n\t\t\t\tinput: route.input,\n\t\t\t\tmodule_url: route.module_url,\n\t\t\t\tmodule: modules.get(route.module_url) ?? {},\n\t\t\t\tloader_data: route.loader_data,\n\t\t\t\tclient_loader_data: cl && \"data\" in cl ? cl.data : undefined,\n\t\t\t};\n\t\t});\n\t\tlet error: RouteErrorState | null = null;\n\t\tconst server_error_idx = payload.routes.findIndex((route) => {\n\t\t\treturn route.server_error !== undefined;\n\t\t});\n\t\tif (server_error_idx !== -1) {\n\t\t\terror = {\n\t\t\t\tidx: server_error_idx,\n\t\t\t\terror: payload.routes[server_error_idx]!.server_error,\n\t\t\t\tsource: \"server\",\n\t\t\t};\n\t\t} else {\n\t\t\tconst client_loader_error_idx = cl_results.findIndex((cl) => {\n\t\t\t\treturn cl !== undefined && \"error\" in cl;\n\t\t\t});\n\t\t\tif (client_loader_error_idx !== -1) {\n\t\t\t\terror = {\n\t\t\t\t\tidx: client_loader_error_idx,\n\t\t\t\t\terror: (\n\t\t\t\t\t\tcl_results[client_loader_error_idx] as {\n\t\t\t\t\t\t\terror: unknown;\n\t\t\t\t\t\t}\n\t\t\t\t\t).error,\n\t\t\t\t\tsource: \"clientLoader\",\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tparams: payload.params,\n\t\t\tsplat_values: payload.splat_values,\n\t\t\tmatches,\n\t\t\terror,\n\t\t\tclient_build_id,\n\t\t};\n\t}\n\n\tasync function prepare_route(\n\t\tpayload: DecodedPayload,\n\t\tcl_prefetches: ClientLoaderPrefetch[],\n\t\ttrigger: \"navigation\" | \"revalidation\",\n\t\thref: string,\n\t\thistory_state: unknown,\n\t\tsignal: AbortSignal,\n\t): Promise<PreparedRoute | null> {\n\t\tconst modules = await prepare_modules(payload, signal);\n\t\tif (!modules) {\n\t\t\treturn null;\n\t\t}\n\t\tconst cl_results = await run_client_loaders(\n\t\t\tpayload.routes,\n\t\t\tpayload,\n\t\t\tcl_prefetches,\n\t\t\ttrigger,\n\t\t\thref,\n\t\t\thistory_state,\n\t\t\tsignal,\n\t\t);\n\t\tif (signal.aborted) {\n\t\t\treturn null;\n\t\t}\n\t\tawait wait_for_css(payload.css_bundles, signal);\n\t\tif (signal.aborted) {\n\t\t\treturn null;\n\t\t}\n\t\treturn {\n\t\t\troute: build_route_record(payload, modules, cl_results),\n\t\t\tapply_dom_side_effects: () => {\n\t\t\t\tapply_head_and_title(\n\t\t\t\t\tpayload.title,\n\t\t\t\t\tpayload.meta_head_els,\n\t\t\t\t\tpayload.rest_head_els,\n\t\t\t\t);\n\t\t\t\tapply_css_bundles(payload.css_bundles);\n\t\t\t\tpreload_modules(payload.deps);\n\t\t\t},\n\t\t};\n\t}\n\n\t/////// Fetch\n\n\tfunction detect_redirect(\n\t\tres: Response,\n\t\tbase: URL,\n\t): { href: string; hard: boolean } | null {\n\t\tconst soft = res.headers.get(X_CLIENT_REDIRECT);\n\t\tif (soft) {\n\t\t\treturn { href: new URL(soft, base).href, hard: false };\n\t\t}\n\t\tif (res.redirected && res.url && res.url !== base.href) {\n\t\t\treturn { href: new URL(res.url, base).href, hard: false };\n\t\t}\n\t\treturn null;\n\t}\n\n\tfunction report_build_skew(\n\t\tevent: Omit<\n\t\t\tBuildSkewDetectedEvent,\n\t\t\t| \"activeClientBuildID\"\n\t\t\t| \"currentRouteState\"\n\t\t\t| \"currentWorkState\"\n\t\t\t| \"serverBuildID\"\n\t\t> & {\n\t\t\tresponse: Response;\n\t\t},\n\t): boolean {\n\t\tconst server_build_id =\n\t\t\tevent.response.headers.get(BUILD_ID_HEADER) ?? \"\";\n\t\tif (!server_build_id || server_build_id === client_build_id) {\n\t\t\treturn false;\n\t\t}\n\t\tif (!route_snapshot) {\n\t\t\treturn false;\n\t\t}\n\t\tuser_on_build_skew_detected?.({\n\t\t\tactiveClientBuildID: client_build_id,\n\t\t\tserverBuildID: server_build_id,\n\t\t\ttriggeringResponse: event.triggeringResponse,\n\t\t\tcurrentRouteState: route_snapshot_to_state(route_snapshot),\n\t\t\tcurrentWorkState: derive_work_state(),\n\t\t\tdefaultBehavior: event.defaultBehavior,\n\t\t});\n\t\treturn true;\n\t}\n\n\tfunction report_route_build_skew(\n\t\tf: FetchBase & { intent: FetchIntent },\n\t\tresponse: Response,\n\t\tdefault_behavior: BuildSkewDetectedEvent[\"defaultBehavior\"],\n\t): boolean {\n\t\tconst base = {\n\t\t\tkind: \"route\" as const,\n\t\t\trequestedHref: f.url.href,\n\t\t\tstatus: response.status,\n\t\t\tok: response.ok,\n\t\t};\n\t\tlet triggeringResponse: BuildSkewDetectedEvent[\"triggeringResponse\"];\n\t\tif (f.intent.kind === \"reval\") {\n\t\t\ttriggeringResponse = {\n\t\t\t\t...base,\n\t\t\t\ttrigger: \"revalidation\",\n\t\t\t\trevalidationReason: f.intent.reason,\n\t\t\t};\n\t\t} else if (f.intent.kind === \"prefetch\") {\n\t\t\ttriggeringResponse = {\n\t\t\t\t...base,\n\t\t\t\ttrigger: \"prefetch\",\n\t\t\t};\n\t\t} else {\n\t\t\ttriggeringResponse = {\n\t\t\t\t...base,\n\t\t\t\ttrigger:\n\t\t\t\t\tf.intent.source === \"popstate\" ? \"popstate\" : \"navigation\",\n\t\t\t};\n\t\t}\n\n\t\treturn report_build_skew({\n\t\t\tresponse,\n\t\t\ttriggeringResponse,\n\t\t\tdefaultBehavior: default_behavior,\n\t\t});\n\t}\n\n\tfunction history_state_for_fetch(intent: FetchIntent): unknown {\n\t\tif (intent.kind === \"nav\") {\n\t\t\treturn intent.options.is_popstate\n\t\t\t\t? browser.state\n\t\t\t\t: intent.options.state;\n\t\t}\n\t\tif (intent.kind === \"reval\") {\n\t\t\treturn browser.state;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/////// Fetch Lifecycle\n\n\tfunction start_fetch<T extends FetchIntent>(\n\t\turl: URL,\n\t\tintent: T,\n\t\tis_revalidation: boolean,\n\t\tprepare_ready?: Promise<void>,\n\t): FetchBase & { prepare_ready: Promise<void>; intent: T } {\n\t\tconst ac = new AbortController();\n\t\tconst cl_prefetches: ClientLoaderPrefetch[] = [];\n\t\tlet match = findNestedMatches(pattern_registry, url.pathname);\n\t\tif (!match) {\n\t\t\tconst segments = url.pathname.split(\"/\").filter(Boolean);\n\t\t\tfor (let i = segments.length; i >= 0; i--) {\n\t\t\t\tconst partial =\n\t\t\t\t\ti === 0 ? \"/\" : \"/\" + segments.slice(0, i).join(\"/\");\n\t\t\t\tmatch = findNestedMatches(pattern_registry, partial);\n\t\t\t\tif (match) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (match) {\n\t\t\tconst known_matches = match.matches.map((m) => {\n\t\t\t\tconst pattern = m.registeredPattern.originalPattern;\n\t\t\t\treturn {\n\t\t\t\t\tpattern,\n\t\t\t\t\tinput: parseSearchParams(\n\t\t\t\t\t\tsearch_schema_map[pattern],\n\t\t\t\t\t\turl.searchParams,\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t});\n\t\t\tconst input_by_pattern = new Map(\n\t\t\t\tknown_matches.map((m) => {\n\t\t\t\t\treturn [m.pattern, m.input] as const;\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst history_state = history_state_for_fetch(intent);\n\t\t\tfor (const m of match.matches) {\n\t\t\t\tconst pattern = m.registeredPattern.originalPattern;\n\t\t\t\tconst loader = module_map[pattern];\n\t\t\t\tif (loader) {\n\t\t\t\t\tcl_prefetches.push(\n\t\t\t\t\t\tmake_cl_prefetch({\n\t\t\t\t\t\t\thref: url.href,\n\t\t\t\t\t\t\thistory_state,\n\t\t\t\t\t\t\tknown_matches,\n\t\t\t\t\t\t\tloader,\n\t\t\t\t\t\t\tparams: match.params,\n\t\t\t\t\t\t\tpattern,\n\t\t\t\t\t\t\troute_input: input_by_pattern.get(pattern),\n\t\t\t\t\t\t\tsignal: ac.signal,\n\t\t\t\t\t\t\tsplat_values: match.splatValues,\n\t\t\t\t\t\t\ttrigger:\n\t\t\t\t\t\t\t\tintent.kind === \"prefetch\"\n\t\t\t\t\t\t\t\t\t? \"prefetch\"\n\t\t\t\t\t\t\t\t\t: intent.kind === \"reval\"\n\t\t\t\t\t\t\t\t\t\t? \"revalidation\"\n\t\t\t\t\t\t\t\t\t\t: \"navigation\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\turl,\n\t\t\tac,\n\t\t\tseq: next_seq(),\n\t\t\tdata_promise: (async () => {\n\t\t\t\tconst modified = new URL(url.href);\n\t\t\t\tmodified.searchParams.set(VORMA_JSON_KEY, client_build_id);\n\t\t\t\tif (is_revalidation && deployment_id) {\n\t\t\t\t\tmodified.searchParams.set(\n\t\t\t\t\t\tVERCEL_DPL_QUERY_PARAM_KEY,\n\t\t\t\t\t\tdeployment_id,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst res = await fetch(modified, {\n\t\t\t\t\tsignal: ac.signal,\n\t\t\t\t\theaders: { [X_ACCEPTS_CLIENT_REDIRECT]: \"1\" },\n\t\t\t\t});\n\n\t\t\t\tif (res.headers.get(X_VORMA_BUILD_SKEW) === \"1\") {\n\t\t\t\t\treturn { kind: \"build_skew\", response: res };\n\t\t\t\t}\n\t\t\t\tconst redirect = detect_redirect(res, modified);\n\t\t\t\tif (redirect) {\n\t\t\t\t\treturn { kind: \"redirect\", ...redirect, response: res };\n\t\t\t\t}\n\t\t\t\tif (!res.ok) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkind: \"error\",\n\t\t\t\t\t\tstatus: res.status,\n\t\t\t\t\t\tstatus_text: res.statusText,\n\t\t\t\t\t\tresponse: res,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst data = await res.json();\n\t\t\t\t\treturn { kind: \"data\", data, response: res };\n\t\t\t\t} catch {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkind: \"error\",\n\t\t\t\t\t\tstatus: res.status,\n\t\t\t\t\t\tstatus_text: res.statusText,\n\t\t\t\t\t\tresponse: res,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t})(),\n\t\t\tcl_prefetches,\n\t\t\tprepare_ready: prepare_ready ?? Promise.resolve(),\n\t\t\tintent,\n\t\t};\n\t}\n\n\tfunction resolve_nav(f: ActiveFetch, result: NavResult): void {\n\t\tif (f.intent.kind === \"nav\") {\n\t\t\tf.intent.deferred.resolve(result);\n\t\t}\n\t}\n\n\tfunction can_commit(f: ActiveFetch): boolean {\n\t\treturn active === f && !f.ac.signal.aborted;\n\t}\n\n\t// Core lifecycle for any fetch intent. The only place that drives\n\t// fetch-to-publish: resolve response, follow redirects, prepare, publish.\n\tasync function run_active(f: ActiveFetch): Promise<void> {\n\t\tactive = f;\n\t\tnotify_work_update();\n\n\t\tlet published = false;\n\t\tlet nav_transferred = false;\n\t\ttry {\n\t\t\tconst result = await f.data_promise;\n\t\t\tif (!can_commit(f)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (result.kind === \"build_skew\") {\n\t\t\t\treport_route_build_skew(\n\t\t\t\t\tf,\n\t\t\t\t\tresult.response,\n\t\t\t\t\tf.intent.kind === \"reval\" ? \"dropResponse\" : \"hardReload\",\n\t\t\t\t);\n\t\t\t\tif (f.intent.kind === \"reval\") {\n\t\t\t\t\tmark_refresh_build_skew();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thard_redirect(f.url.href);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (result.response) {\n\t\t\t\tconst default_behavior =\n\t\t\t\t\tresult.kind === \"redirect\" &&\n\t\t\t\t\tresult.hard &&\n\t\t\t\t\tis_http(result.href)\n\t\t\t\t\t\t? f.intent.kind === \"reval\"\n\t\t\t\t\t\t\t? \"dropResponse\"\n\t\t\t\t\t\t\t: \"hardReload\"\n\t\t\t\t\t\t: \"notifyOnly\";\n\t\t\t\tconst did_detect_skew = report_route_build_skew(\n\t\t\t\t\tf,\n\t\t\t\t\tresult.response,\n\t\t\t\t\tdefault_behavior,\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tdid_detect_skew &&\n\t\t\t\t\tresult.kind === \"redirect\" &&\n\t\t\t\t\tresult.hard &&\n\t\t\t\t\tf.intent.kind === \"reval\"\n\t\t\t\t) {\n\t\t\t\t\tmark_refresh_build_skew();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (result.kind === \"error\") {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (result.kind === \"redirect\") {\n\t\t\t\tnav_transferred = handle_redirect(f, result) === \"transferred\";\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst payload = decode_payload(result.data, f.url);\n\t\t\tpreload_modules(payload.deps);\n\n\t\t\tawait f.prepare_ready;\n\t\t\tif (!can_commit(f)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prepared = await prepare_route(\n\t\t\t\tpayload,\n\t\t\t\tf.cl_prefetches,\n\t\t\t\tf.intent.kind === \"reval\" ? \"revalidation\" : \"navigation\",\n\t\t\t\tf.url.href,\n\t\t\t\thistory_state_for_fetch(f.intent),\n\t\t\t\tf.ac.signal,\n\t\t\t);\n\t\t\tif (!prepared || !can_commit(f)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst was_published = await publish(f, prepared);\n\t\t\tif (was_published) {\n\t\t\t\tpublished = true;\n\t\t\t\tlast_activity_ts = Date.now();\n\t\t\t\tmark_fresh(f);\n\t\t\t}\n\t\t} catch {\n\t\t\t// swallow\n\t\t} finally {\n\t\t\tif (f.intent.kind === \"nav\" && !nav_transferred) {\n\t\t\t\tresolve_nav(f, { didNavigate: published });\n\t\t\t}\n\t\t\tif (active === f) {\n\t\t\t\tactive = null;\n\t\t\t}\n\t\t\tnotify_work_update();\n\t\t\tmaybe_revalidate();\n\t\t}\n\t}\n\n\t// Publish a prepared route. Clears `active` as soon as the commit lands\n\t// inside the view transition so subsequent same-page navs can fire\n\t// while the transition animation is still running. Returns true if the\n\t// commit actually happened (it may be superseded mid-callback).\n\tasync function publish(\n\t\tf: ActiveFetch,\n\t\tprepared: PreparedRoute,\n\t): Promise<boolean> {\n\t\tconst commit_reason: Exclude<RouteUpdateReason, \"boot\"> =\n\t\t\tf.intent.kind === \"reval\"\n\t\t\t\t? \"revalidation\"\n\t\t\t\t: f.intent.options.is_popstate\n\t\t\t\t\t? \"popstate\"\n\t\t\t\t\t: \"navigation\";\n\n\t\tconst prev_snapshot = route_snapshot;\n\t\tif (!prev_snapshot) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst next_href =\n\t\t\tf.intent.kind === \"nav\"\n\t\t\t\t? f.intent.url.href\n\t\t\t\t: prev_snapshot.position.href;\n\t\tconst next_history_state =\n\t\t\tf.intent.kind === \"nav\"\n\t\t\t\t? f.intent.options.is_popstate\n\t\t\t\t\t? browser.state\n\t\t\t\t\t: f.intent.options.state\n\t\t\t\t: prev_snapshot.position.state;\n\t\tconst yield_hooks = prev_snapshot.route.matches\n\t\t\t.map((m) => {\n\t\t\t\treturn (m.module.default as ViewDefinition | undefined)\n\t\t\t\t\t?.before_route_yield;\n\t\t\t})\n\t\t\t.filter((h): h is BeforeRouteYieldFn => {\n\t\t\t\treturn typeof h === \"function\";\n\t\t\t});\n\t\tconst commit_hooks = prepared.route.matches\n\t\t\t.map((m) => {\n\t\t\t\treturn (m.module.default as ViewDefinition | undefined)\n\t\t\t\t\t?.before_route_commit;\n\t\t\t})\n\t\t\t.filter((h): h is BeforeRouteCommitFn => {\n\t\t\t\treturn typeof h === \"function\";\n\t\t\t});\n\t\tif (yield_hooks.length > 0 || commit_hooks.length > 0) {\n\t\t\tconst current = route_snapshot_to_state(prev_snapshot);\n\t\t\tconst next = route_record_to_state(\n\t\t\t\tprepared.route,\n\t\t\t\tnext_href,\n\t\t\t\tnext_history_state,\n\t\t\t);\n\t\t\tawait Promise.all(\n\t\t\t\tyield_hooks\n\t\t\t\t\t.map((h) => {\n\t\t\t\t\t\treturn h({\n\t\t\t\t\t\t\ttrigger: commit_reason,\n\t\t\t\t\t\t\tsignal: f.ac.signal,\n\t\t\t\t\t\t\tcurrent,\n\t\t\t\t\t\t\tnext,\n\t\t\t\t\t\t});\n\t\t\t\t\t})\n\t\t\t\t\t.concat(\n\t\t\t\t\t\tcommit_hooks.map((h) => {\n\t\t\t\t\t\t\treturn h({\n\t\t\t\t\t\t\t\ttrigger: commit_reason,\n\t\t\t\t\t\t\t\tsignal: f.ac.signal,\n\t\t\t\t\t\t\t\tcurrent,\n\t\t\t\t\t\t\t\tnext,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (!can_commit(f)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tlet did_publish = false;\n\n\t\tconst do_publish = () => {\n\t\t\tif (!can_commit(f)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet position: HistoryPosition;\n\t\t\tif (f.intent.kind === \"nav\" && !f.intent.options.is_popstate) {\n\t\t\t\tsave_current_scroll();\n\t\t\t\tposition = commit_history(\n\t\t\t\t\tf.intent.url.href,\n\t\t\t\t\tf.intent.options.replace,\n\t\t\t\t\tf.intent.options.state,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// popstate: browser already at the new URL; revalidation: URL unchanged\n\t\t\t\tposition = browser;\n\t\t\t}\n\n\t\t\tconst prev = route_snapshot;\n\t\t\tprepared.apply_dom_side_effects();\n\t\t\troute_snapshot = { position, route: prepared.route };\n\n\t\t\tlet scroll_intent: ScrollIntent | undefined;\n\t\t\tif (f.intent.kind === \"nav\") {\n\t\t\t\tlet ss: ScrollState | undefined;\n\t\t\t\tif (f.intent.options.is_popstate) {\n\t\t\t\t\tif (normalize_hash(f.intent.url.hash).length > 0) {\n\t\t\t\t\t\tss = { hash: f.intent.url.hash };\n\t\t\t\t\t} else {\n\t\t\t\t\t\tss = f.intent.options.popstate_scroll ?? { x: 0, y: 0 };\n\t\t\t\t\t}\n\t\t\t\t} else if (normalize_hash(f.intent.url.hash).length > 0) {\n\t\t\t\t\tss = { hash: f.intent.url.hash };\n\t\t\t\t} else if (f.intent.options.scroll_to_top !== false) {\n\t\t\t\t\tss = { x: 0, y: 0 };\n\t\t\t\t}\n\t\t\t\tif (ss) {\n\t\t\t\t\tscroll_intent = {\n\t\t\t\t\t\tscroll: ss,\n\t\t\t\t\t\ttarget_route_id: make_route_id(\n\t\t\t\t\t\t\tprepared.route.matches.length - 1,\n\t\t\t\t\t\t\tprepared.route.matches[\n\t\t\t\t\t\t\t\tprepared.route.matches.length - 1\n\t\t\t\t\t\t\t]?.pattern ?? \"\",\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tactive = null;\n\t\t\tcommit_route_snapshot(\n\t\t\t\tcommit_reason,\n\t\t\t\tprev,\n\t\t\t\troute_snapshot,\n\t\t\t\tscroll_intent,\n\t\t\t\ttake_work_update(),\n\t\t\t);\n\t\t\tdid_publish = true;\n\t\t};\n\n\t\tconst vt = (document as any).startViewTransition;\n\t\tif (\n\t\t\tf.intent.kind === \"nav\" &&\n\t\t\tuse_view_transitions &&\n\t\t\ttypeof vt === \"function\"\n\t\t) {\n\t\t\tconst transition = vt.call(document, do_publish);\n\t\t\t// Prefer updateCallbackDone (modern API); fall back to finished.\n\t\t\tawait (transition.updateCallbackDone ?? transition.finished);\n\t\t\tif (transition.finished) {\n\t\t\t\tawait transition.finished;\n\t\t\t}\n\t\t} else {\n\t\t\tdo_publish();\n\t\t}\n\t\treturn did_publish;\n\t}\n\n\tfunction route_to_render_state(\n\t\troute: RouteRecord,\n\t\thistory_state: unknown,\n\t): RouteRenderState {\n\t\treturn {\n\t\t\tentries: route.matches.map((m) => {\n\t\t\t\treturn {\n\t\t\t\t\tpattern: m.pattern,\n\t\t\t\t\tinput: m.input,\n\t\t\t\t\tmodule_url: m.module_url,\n\t\t\t\t\tmodule: m.module,\n\t\t\t\t\tloader_data: m.loader_data,\n\t\t\t\t\tclient_loader_data: m.client_loader_data,\n\t\t\t\t};\n\t\t\t}),\n\t\t\terror: route.error,\n\t\t\tparams: route.params,\n\t\t\tsplat_values: route.splat_values,\n\t\t\tclient_build_id: route.client_build_id,\n\t\t\thistory_state,\n\t\t};\n\t}\n\n\tfunction route_snapshot_to_state(snapshot: RouteSnapshot): RouteState {\n\t\treturn route_record_to_state(\n\t\t\tsnapshot.route,\n\t\t\tsnapshot.position.href,\n\t\t\tsnapshot.position.state,\n\t\t);\n\t}\n\n\tfunction route_record_to_state(\n\t\troute: RouteRecord,\n\t\thref: string,\n\t\thistory_state: unknown,\n\t): RouteState {\n\t\treturn {\n\t\t\thref,\n\t\t\thistoryState: history_state,\n\t\t\tclientBuildID: route.client_build_id,\n\t\t\tparams: route.params,\n\t\t\tsplatValues: route.splat_values,\n\t\t\tmatches: route.matches.map((m) => {\n\t\t\t\treturn {\n\t\t\t\t\tpattern: m.pattern,\n\t\t\t\t\tinput: m.input,\n\t\t\t\t\tloaderData: m.loader_data,\n\t\t\t\t\tclientLoaderData: m.client_loader_data,\n\t\t\t\t};\n\t\t\t}),\n\t\t\terror: route.error,\n\t\t};\n\t}\n\n\tfunction to_route_update_reason(\n\t\treason: RouteRenderCommitReason,\n\t): RouteUpdateReason {\n\t\tif (reason === \"initial\") {\n\t\t\treturn \"boot\";\n\t\t}\n\t\tif (reason === \"hmr\") {\n\t\t\treturn \"revalidation\";\n\t\t}\n\t\treturn reason;\n\t}\n\n\tfunction commit_route_snapshot(\n\t\treason: RouteRenderCommitReason,\n\t\tprev: RouteSnapshot | null,\n\t\tnext: RouteSnapshot,\n\t\tscroll_intent?: ScrollIntent,\n\t\twork?: WorkState,\n\t): void {\n\t\tconst previous_route = prev ? route_snapshot_to_state(prev) : null;\n\t\tconst route = route_snapshot_to_state(next);\n\t\tconst client_commit: ClientCommit = {\n\t\t\troute_render: {\n\t\t\t\tstate: route_to_render_state(next.route, next.position.state),\n\t\t\t\tscroll_intent,\n\t\t\t},\n\t\t\twork,\n\t\t};\n\t\tif (!previous_route || !jsonDeepEquals(previous_route, route)) {\n\t\t\tclient_commit.route_update = {\n\t\t\t\tprevious_route,\n\t\t\t\treason: to_route_update_reason(reason),\n\t\t\t\troute,\n\t\t\t};\n\t\t}\n\t\temit_client_commit(client_commit);\n\t}\n\n\tfunction handle_redirect(\n\t\tf: ActiveFetch,\n\t\tredirect: Extract<FetchResult, { kind: \"redirect\" }>,\n\t): RedirectResult {\n\t\tconst nav_intent = f.intent.kind === \"nav\" ? f.intent : null;\n\n\t\t// Invalid scheme: treat as failure for nav, no-op otherwise.\n\t\tif (!is_http(redirect.href)) {\n\t\t\tif (nav_intent) {\n\t\t\t\tnav_intent.deferred.resolve({ didNavigate: false });\n\t\t\t}\n\t\t\tactive = null;\n\t\t\treturn \"settled\";\n\t\t}\n\n\t\t// Hard redirect or cross-origin: leave the page.\n\t\tif (redirect.hard || !is_same_origin_href(redirect.href)) {\n\t\t\thard_redirect(redirect.href);\n\t\t\tif (nav_intent) {\n\t\t\t\tnav_intent.deferred.resolve({ didNavigate: false });\n\t\t\t}\n\t\t\tactive = null;\n\t\t\treturn \"settled\";\n\t\t}\n\n\t\t// Redirect loop guard (only meaningful for nav, which tracks count).\n\t\tif (nav_intent && nav_intent.redirect_count >= MAX_REDIRECTS) {\n\t\t\tnav_intent.deferred.resolve({ didNavigate: false });\n\t\t\tactive = null;\n\t\t\treturn \"settled\";\n\t\t}\n\n\t\tconst target = new URL(redirect.href);\n\t\tactive = null;\n\n\t\t// Same-page redirect (same path, maybe different hash): no re-fetch,\n\t\t// just handle as same-page nav.\n\t\tif (route_snapshot_matches(target)) {\n\t\t\tconst result = handle_same_page_nav(\n\t\t\t\ttarget,\n\t\t\t\tnav_intent?.options ?? {},\n\t\t\t);\n\t\t\tif (nav_intent) {\n\t\t\t\tnav_intent.deferred.resolve(result);\n\t\t\t}\n\t\t\treturn \"settled\";\n\t\t}\n\n\t\t// Continue nav chain at redirect target.\n\t\tif (nav_intent) {\n\t\t\tvoid start_nav_inner(\n\t\t\t\ttarget,\n\t\t\t\tnav_intent.options,\n\t\t\t\tnav_intent.redirect_count + 1,\n\t\t\t\t{\n\t\t\t\t\treuse_deferred: nav_intent.deferred,\n\t\t\t\t\tsource: \"redirect\",\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn \"transferred\";\n\t\t} else {\n\t\t\t// Revalidation redirect becomes a replace navigation.\n\t\t\tvoid start_nav_inner(target, { replace: true }, 0, {\n\t\t\t\tsource: \"redirect\",\n\t\t\t});\n\t\t\treturn \"settled\";\n\t\t}\n\t}\n\n\t/////// Navigation Entry\n\n\tfunction try_merge_active_nav(\n\t\turl: URL,\n\t\toptions: NavOptions,\n\t\tsource: NavigationSource,\n\t\tdeferred: Deferred<NavResult>,\n\t): boolean {\n\t\tif (\n\t\t\t!active ||\n\t\t\tactive.intent.kind !== \"nav\" ||\n\t\t\t!matches_without_hash(active.url, url)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Identical intent: share the result promise.\n\t\tconst cur = active.intent;\n\t\tif (\n\t\t\tcur.url.href === url.href &&\n\t\t\tcur.options.replace === options.replace &&\n\t\t\tcur.options.scroll_to_top === options.scroll_to_top &&\n\t\t\tcur.options.state === options.state &&\n\t\t\tcur.options.is_popstate === options.is_popstate &&\n\t\t\tcur.options.popstate_scroll === options.popstate_scroll &&\n\t\t\tcur.options.skip_work_indicator === options.skip_work_indicator &&\n\t\t\tcur.source === source\n\t\t) {\n\t\t\tcur.deferred.promise.then(deferred.resolve, () =>\n\t\t\t\tdeferred.resolve({ didNavigate: false }),\n\t\t\t);\n\t\t\treturn true;\n\t\t}\n\n\t\t// Same path, different hash or options: swap the request.\n\t\tcur.deferred.resolve({ didNavigate: false });\n\t\tactive.intent = {\n\t\t\tkind: \"nav\",\n\t\t\turl,\n\t\t\toptions,\n\t\t\tsource,\n\t\t\tredirect_count: cur.redirect_count,\n\t\t\tdeferred,\n\t\t};\n\t\tnotify_work_update();\n\t\treturn true;\n\t}\n\n\tfunction cancel_prefetch(): void {\n\t\tif (prefetch) {\n\t\t\tconst p = prefetch;\n\t\t\tprefetch = null;\n\t\t\tp.ac.abort();\n\t\t\tnotify_work_update();\n\t\t}\n\t}\n\n\tfunction handle_same_page_nav(url: URL, options: NavOptions): NavResult {\n\t\tif (!route_snapshot) {\n\t\t\treturn { didNavigate: false };\n\t\t}\n\t\tconst cur_url = new URL(route_snapshot.position.href);\n\t\tconst target_hash = normalize_hash(url.hash);\n\t\tconst current_hash = normalize_hash(cur_url.hash);\n\n\t\tif (target_hash !== current_hash) {\n\t\t\tsave_current_scroll();\n\t\t\tconst position = commit_history(\n\t\t\t\turl.href,\n\t\t\t\toptions.replace,\n\t\t\t\toptions.state,\n\t\t\t);\n\t\t\tconst prev = route_snapshot;\n\t\t\troute_snapshot = { position, route: route_snapshot.route };\n\t\t\tcommit_route_snapshot(\"navigation\", prev, route_snapshot);\n\t\t\tapply_scroll(\n\t\t\t\ttarget_hash.length > 0 ? { hash: url.hash } : { x: 0, y: 0 },\n\t\t\t\ttest_options,\n\t\t\t);\n\t\t\treturn { didNavigate: true };\n\t\t}\n\n\t\tif (options.replace) {\n\t\t\tconst position = commit_history(url.href, true, options.state);\n\t\t\tconst prev = route_snapshot;\n\t\t\troute_snapshot = { position, route: route_snapshot.route };\n\t\t\tcommit_route_snapshot(\"navigation\", prev, route_snapshot);\n\t\t}\n\t\tapply_scroll({ x: 0, y: 0 }, test_options);\n\t\treturn { didNavigate: false };\n\t}\n\n\tfunction start_nav_inner(\n\t\turl: URL,\n\t\toptions: NavOptions,\n\t\tredirect_count: number,\n\t\treuse?: {\n\t\t\treuse_deferred?: Deferred<NavResult>;\n\t\t\tsource?: NavigationSource;\n\t\t},\n\t): Promise<NavResult> {\n\t\tconst deferred = reuse?.reuse_deferred ?? make_deferred<NavResult>();\n\t\tconst source =\n\t\t\treuse?.source ?? (options.is_popstate ? \"popstate\" : \"navigate\");\n\n\t\t// Same-page short-circuit (not for popstate, which always owns the commit).\n\t\tif (!options.is_popstate && route_snapshot_matches(url)) {\n\t\t\tconst result = handle_same_page_nav(url, options);\n\t\t\tdeferred.resolve(result);\n\t\t\treturn deferred.promise;\n\t\t}\n\n\t\t// Merge into active nav if URLs match by path.\n\t\tif (try_merge_active_nav(url, options, source, deferred)) {\n\t\t\treturn deferred.promise;\n\t\t}\n\n\t\t// Supersede any other active work.\n\t\tif (active) {\n\t\t\tconst prev = active;\n\t\t\tactive = null;\n\t\t\tresolve_nav(prev, { didNavigate: false });\n\t\t\tprev.ac.abort();\n\t\t}\n\n\t\t// Promote matching prefetch if present.\n\t\tlet promoted: PrefetchFetch | null = null;\n\t\tif (prefetch && matches_without_hash(prefetch.url, url)) {\n\t\t\tpromoted = prefetch;\n\t\t\tprefetch = null;\n\t\t}\n\t\tconst fetch_record: ActiveFetch = promoted\n\t\t\t? {\n\t\t\t\t\t...promoted,\n\t\t\t\t\tintent: {\n\t\t\t\t\t\tkind: \"nav\",\n\t\t\t\t\t\turl,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tredirect_count,\n\t\t\t\t\t\tdeferred,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: (cancel_prefetch(),\n\t\t\t\tstart_fetch(\n\t\t\t\t\turl,\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"nav\",\n\t\t\t\t\t\turl,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tredirect_count,\n\t\t\t\t\t\tdeferred,\n\t\t\t\t\t},\n\t\t\t\t\tfalse,\n\t\t\t\t));\n\n\t\tvoid run_active(fetch_record);\n\t\treturn deferred.promise;\n\t}\n\n\t/////// Refresh\n\n\tfunction mark_fresh(f: ActiveFetch): void {\n\t\tconst demand = refresh_demand();\n\t\tif (!demand) {\n\t\t\treturn;\n\t\t}\n\t\tif (f.seq <= demand.after_seq) {\n\t\t\treturn;\n\t\t}\n\t\tconst waiters = demand.waiters;\n\t\tclear_refresh();\n\t\tfor (const w of waiters) {\n\t\t\tw.resolve(REVALIDATION_OK);\n\t\t}\n\t}\n\n\tfunction mark_refresh_build_skew(): void {\n\t\tconst demand = refresh_demand();\n\t\tif (!demand) {\n\t\t\treturn;\n\t\t}\n\t\tconst waiters = demand.waiters;\n\t\tclear_refresh();\n\t\tfor (const w of waiters) {\n\t\t\tw.resolve(REVALIDATION_BUILD_SKEW);\n\t\t}\n\t}\n\n\tfunction refresh_demand(): RefreshDemand | null {\n\t\tif (refresh.kind === \"idle\") {\n\t\t\treturn null;\n\t\t}\n\t\treturn refresh.demand;\n\t}\n\n\tfunction clear_refresh(): void {\n\t\tif (refresh.kind === \"debouncing\" || refresh.kind === \"retrying\") {\n\t\t\tclearTimeout(refresh.timer);\n\t\t}\n\t\trefresh = { kind: \"idle\" };\n\t}\n\n\tfunction require_refresh(\n\t\treason: RevalidationReason,\n\t\twaiter?: RefreshWaiter,\n\t\tdebounce?: boolean,\n\t): void {\n\t\tconst waiters = refresh_demand()?.waiters ?? [];\n\t\tclear_refresh();\n\t\tif (waiter) {\n\t\t\twaiters.push(waiter);\n\t\t}\n\t\tconst demand: RefreshDemand = {\n\t\t\tafter_seq: next_seq(),\n\t\t\treason,\n\t\t\twaiters,\n\t\t};\n\n\t\tif (debounce) {\n\t\t\tlet next_refresh!: Extract<RefreshState, { kind: \"debouncing\" }>;\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tif (refresh !== next_refresh) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\trefresh = { kind: \"pending\", demand, attempt: 0 };\n\t\t\t\tmaybe_revalidate();\n\t\t\t}, REVALIDATION_DEBOUNCE_MS);\n\t\t\tnext_refresh = { kind: \"debouncing\", demand, timer };\n\t\t\trefresh = next_refresh;\n\t\t} else {\n\t\t\trefresh = { kind: \"pending\", demand, attempt: 0 };\n\t\t}\n\t}\n\n\tfunction active_will_refresh(): boolean {\n\t\tconst demand = refresh_demand();\n\t\treturn (\n\t\t\tactive !== null && demand !== null && active.seq > demand.after_seq\n\t\t);\n\t}\n\n\tfunction maybe_revalidate(): void {\n\t\tif (phase !== \"ready\") {\n\t\t\treturn;\n\t\t}\n\t\tif (refresh.kind === \"idle\") {\n\t\t\treturn;\n\t\t}\n\t\tif (refresh.kind === \"debouncing\") {\n\t\t\treturn;\n\t\t}\n\t\tif (active_will_refresh() || active) {\n\t\t\treturn;\n\t\t}\n\t\tif (refresh.kind === \"retrying\") {\n\t\t\treturn;\n\t\t}\n\n\t\tconst demand = refresh.demand;\n\t\tconst attempt = refresh.attempt;\n\t\tif (attempt >= MAX_REVALIDATION_RETRIES) {\n\t\t\tclear_refresh();\n\t\t\tfor (const w of demand.waiters) {\n\t\t\t\tw.resolve(REVALIDATION_EXHAUSTED);\n\t\t\t}\n\t\t\tnotify_work_update();\n\t\t\treturn;\n\t\t}\n\n\t\tconst delay =\n\t\t\tattempt === 0\n\t\t\t\t? 0\n\t\t\t\t: Math.min(\n\t\t\t\t\t\tREVALIDATION_BACKOFF_BASE_MS * Math.pow(2, attempt - 1),\n\t\t\t\t\t\tREVALIDATION_BACKOFF_CAP_MS,\n\t\t\t\t\t);\n\n\t\tif (delay === 0) {\n\t\t\trefresh = { kind: \"pending\", demand, attempt: attempt + 1 };\n\t\t\tvoid run_revalidation().catch(() => {});\n\t\t} else {\n\t\t\tconst retry_demand: RefreshDemand = {\n\t\t\t\t...demand,\n\t\t\t\treason: \"retry\",\n\t\t\t};\n\t\t\tlet next_refresh!: Extract<RefreshState, { kind: \"retrying\" }>;\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tif (refresh !== next_refresh) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\trefresh = {\n\t\t\t\t\tkind: \"pending\",\n\t\t\t\t\tdemand: retry_demand,\n\t\t\t\t\tattempt: attempt + 1,\n\t\t\t\t};\n\t\t\t\tif (active) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tvoid run_revalidation().catch(() => {});\n\t\t\t}, delay);\n\t\t\tnext_refresh = {\n\t\t\t\tkind: \"retrying\",\n\t\t\t\tdemand: retry_demand,\n\t\t\t\tattempt: attempt + 1,\n\t\t\t\ttimer,\n\t\t\t};\n\t\t\trefresh = next_refresh;\n\t\t\tnotify_work_update();\n\t\t}\n\t}\n\n\tasync function run_revalidation(): Promise<void> {\n\t\tconst url = new URL(browser.href || window.location.href);\n\t\tconst attempt = refresh.kind === \"pending\" ? refresh.attempt : 0;\n\t\tconst reason =\n\t\t\trefresh.kind === \"pending\" ? refresh.demand.reason : \"manual\";\n\t\tconst f = start_fetch(url, { kind: \"reval\", attempt, reason }, true);\n\n\t\t// Guard: discard if URL path changes during flight (hash-only changes\n\t\t// are OK; matches_without_hash on publish time handles it).\n\t\tawait run_active_with_url_guard(f, url);\n\t}\n\n\tasync function run_active_with_url_guard(\n\t\tf: ActiveFetch,\n\t\texpected: URL,\n\t): Promise<void> {\n\t\tactive = f;\n\t\tnotify_work_update();\n\n\t\ttry {\n\t\t\tconst result = await f.data_promise;\n\t\t\tif (!can_commit(f)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!matches_without_hash(new URL(browser.href), expected)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (result.kind === \"build_skew\") {\n\t\t\t\treport_route_build_skew(f, result.response, \"dropResponse\");\n\t\t\t\tmark_refresh_build_skew();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (result.response) {\n\t\t\t\tconst default_behavior =\n\t\t\t\t\tresult.kind === \"redirect\" &&\n\t\t\t\t\tresult.hard &&\n\t\t\t\t\tis_http(result.href)\n\t\t\t\t\t\t? \"dropResponse\"\n\t\t\t\t\t\t: \"notifyOnly\";\n\t\t\t\tconst did_detect_skew = report_route_build_skew(\n\t\t\t\t\tf,\n\t\t\t\t\tresult.response,\n\t\t\t\t\tdefault_behavior,\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tdid_detect_skew &&\n\t\t\t\t\tresult.kind === \"redirect\" &&\n\t\t\t\t\tresult.hard\n\t\t\t\t) {\n\t\t\t\t\tmark_refresh_build_skew();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (result.kind === \"error\") {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (result.kind === \"redirect\") {\n\t\t\t\thandle_redirect(f, result);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst payload = decode_payload(result.data, f.url);\n\t\t\tpreload_modules(payload.deps);\n\n\t\t\tconst prepared = await prepare_route(\n\t\t\t\tpayload,\n\t\t\t\tf.cl_prefetches,\n\t\t\t\t\"revalidation\",\n\t\t\t\tf.url.href,\n\t\t\t\thistory_state_for_fetch(f.intent),\n\t\t\t\tf.ac.signal,\n\t\t\t);\n\t\t\tif (!prepared || !can_commit(f)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!matches_without_hash(new URL(browser.href), expected)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst did_publish = await publish(f, prepared);\n\t\t\tif (did_publish) {\n\t\t\t\tlast_activity_ts = Date.now();\n\t\t\t\tmark_fresh(f);\n\t\t\t}\n\t\t} catch {\n\t\t\t// swallow\n\t\t} finally {\n\t\t\tif (active === f) {\n\t\t\t\tactive = null;\n\t\t\t}\n\t\t\tnotify_work_update();\n\t\t\tmaybe_revalidate();\n\t\t}\n\t}\n\n\t/////// Prefetch\n\n\tasync function prepare_prefetch(f: PrefetchFetch): Promise<void> {\n\t\ttry {\n\t\t\tconst result = await f.data_promise;\n\t\t\tif (result.response) {\n\t\t\t\treport_route_build_skew(\n\t\t\t\t\tf,\n\t\t\t\t\tresult.response,\n\t\t\t\t\tresult.kind === \"data\" ? \"notifyOnly\" : \"dropResponse\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (f.ac.signal.aborted || result.kind !== \"data\") {\n\t\t\t\tif (prefetch === f) {\n\t\t\t\t\tprefetch = null;\n\t\t\t\t\tnotify_work_update();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst payload = decode_payload(result.data, f.url);\n\t\t\tpreload_modules(payload.deps);\n\t\t\tconst modules = await prepare_modules(payload, f.ac.signal);\n\t\t\tif (!modules || f.ac.signal.aborted) {\n\t\t\t\tif (prefetch === f) {\n\t\t\t\t\tprefetch = null;\n\t\t\t\t\tnotify_work_update();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst by_pattern = new Map<string, ClientLoaderPrefetch>();\n\t\t\tfor (const p of f.cl_prefetches) {\n\t\t\t\tby_pattern.set(p.pattern, p);\n\t\t\t}\n\t\t\tconst err_idx = payload.routes.findIndex((r) => {\n\t\t\t\treturn r.server_error !== undefined;\n\t\t\t});\n\t\t\tconst known_matches = routes_to_known_matches(payload.routes);\n\t\t\tconst next_cl_prefetches: ClientLoaderPrefetch[] = [];\n\t\t\tconst retained_prefetches = new Set<ClientLoaderPrefetch>();\n\t\t\tfor (let i = 0; i < payload.routes.length; i++) {\n\t\t\t\tconst route = payload.routes[i]!;\n\t\t\t\tconst existing = by_pattern.get(route.pattern);\n\t\t\t\tif (err_idx !== -1 && i >= err_idx) {\n\t\t\t\t\texisting?.abort();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (existing) {\n\t\t\t\t\texisting.resolve_server_state(\n\t\t\t\t\t\tbuild_server_state(payload.routes, i),\n\t\t\t\t\t);\n\t\t\t\t\tnext_cl_prefetches.push(existing);\n\t\t\t\t\tretained_prefetches.add(existing);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst loader = module_map[route.pattern];\n\t\t\t\tif (!loader) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst p = make_cl_prefetch({\n\t\t\t\t\thref: f.url.href,\n\t\t\t\t\thistory_state: undefined,\n\t\t\t\t\tknown_matches,\n\t\t\t\t\tloader,\n\t\t\t\t\tparams: payload.params,\n\t\t\t\t\tpattern: route.pattern,\n\t\t\t\t\troute_input: route.input,\n\t\t\t\t\tsignal: f.ac.signal,\n\t\t\t\t\tsplat_values: payload.splat_values,\n\t\t\t\t\ttrigger: \"prefetch\",\n\t\t\t\t});\n\t\t\t\tp.resolve_server_state(build_server_state(payload.routes, i));\n\t\t\t\tnext_cl_prefetches.push(p);\n\t\t\t\tretained_prefetches.add(p);\n\t\t\t}\n\t\t\tfor (const p of f.cl_prefetches) {\n\t\t\t\tif (!retained_prefetches.has(p)) {\n\t\t\t\t\tp.abort();\n\t\t\t\t}\n\t\t\t}\n\t\t\tf.cl_prefetches = next_cl_prefetches;\n\t\t} catch {\n\t\t\tif (prefetch === f) {\n\t\t\t\tprefetch = null;\n\t\t\t\tnotify_work_update();\n\t\t\t}\n\t\t} finally {\n\t\t\tif (f.is_pending) {\n\t\t\t\tf.is_pending = false;\n\t\t\t\tnotify_work_update();\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction start_prefetch(href: string): void {\n\t\tif (phase !== \"ready\") {\n\t\t\treturn;\n\t\t}\n\t\tconst url = new URL(href, window.location.href);\n\t\tif (!is_same_origin(url) || route_snapshot_matches(url)) {\n\t\t\treturn;\n\t\t}\n\t\tif (\n\t\t\tactive?.intent.kind === \"nav\" &&\n\t\t\tmatches_without_hash(active.url, url)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tif (prefetch && matches_without_hash(prefetch.url, url)) {\n\t\t\treturn;\n\t\t}\n\t\tcancel_prefetch();\n\n\t\t// Prefetch's prepare_ready resolves when modules + CL seeding are done.\n\t\tlet resolve_prepare!: () => void;\n\t\tconst prepare_ready = new Promise<void>((r) => {\n\t\t\tresolve_prepare = r;\n\t\t});\n\n\t\tconst f: PrefetchFetch = {\n\t\t\t...start_fetch(url, { kind: \"prefetch\" }, false, prepare_ready),\n\t\t\tis_pending: true,\n\t\t};\n\t\tprefetch = f;\n\t\tnotify_work_update();\n\t\tvoid prepare_prefetch(f).finally(() => resolve_prepare());\n\t}\n\n\tfunction stop_prefetch(href: string): void {\n\t\tconst url = new URL(href, window.location.href);\n\t\tif (prefetch && matches_without_hash(prefetch.url, url)) {\n\t\t\tcancel_prefetch();\n\t\t}\n\t}\n\n\t/////// Submit\n\n\tasync function submit_inner<T = unknown>(\n\t\turl: string | URL,\n\t\trequest_init?: RequestInit,\n\t\toptions?: {\n\t\t\tapiRouteKind?: APIRouteKind;\n\t\t\tdedupeKey?: string;\n\t\t\trevalidate?: boolean;\n\t\t\tskipWorkIndicator?: boolean;\n\t\t},\n\t): Promise<APIResult<T>> {\n\t\tif (!route_snapshot) {\n\t\t\tthrow new Error(\"Vorma not booted\");\n\t\t}\n\t\tconst resolved = new URL(String(url), window.location.href);\n\n\t\tif (!is_same_origin(resolved)) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: `submit only supports same-origin targets. Received: \"${resolved.href}\".`,\n\t\t\t\trevalidationPromise: Promise.resolve(REVALIDATION_OK),\n\t\t\t};\n\t\t}\n\n\t\tconst method = request_init?.method\n\t\t\t? request_init.method.toUpperCase().trim()\n\t\t\t: \"GET\";\n\t\tconst api_route_kind =\n\t\t\toptions?.apiRouteKind ??\n\t\t\t(method === \"GET\" || method === \"HEAD\" ? \"query\" : \"mutation\");\n\t\tlet should_revalidate = api_route_kind === \"mutation\";\n\t\tif (options?.revalidate !== undefined) {\n\t\t\tshould_revalidate = options.revalidate;\n\t\t}\n\n\t\tlet dedupe_key = options?.dedupeKey;\n\t\tif (dedupe_key) {\n\t\t\tsubmissions.get(dedupe_key)?.ac.abort();\n\t\t} else {\n\t\t\tdedupe_key = crypto.randomUUID();\n\t\t}\n\n\t\tconst ac = new AbortController();\n\t\tconst sub: Submission = {\n\t\t\tac,\n\t\t\tkey: dedupe_key,\n\t\t\tmethod,\n\t\t\thref: resolved.href,\n\t\t\tskip_work_indicator: options?.skipWorkIndicator,\n\t\t};\n\t\tsubmissions.set(dedupe_key, sub);\n\t\tnotify_work_update();\n\n\t\tlet revalidation_promise: Promise<RevalidationResult> =\n\t\t\tPromise.resolve(REVALIDATION_OK);\n\t\tlet did_dispatch = false;\n\n\t\tfunction schedule_revalidation(): void {\n\t\t\tif (!should_revalidate) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (phase === \"ready\") {\n\t\t\t\tconst waiter = make_deferred<RevalidationResult>();\n\t\t\t\trevalidation_promise = waiter.promise;\n\t\t\t\trequire_refresh(\"apiRequest\", waiter);\n\t\t\t\tmaybe_revalidate();\n\t\t\t} else {\n\t\t\t\t// During boot, register refresh demand so post-boot\n\t\t\t\t// maybe_revalidate will fire. Do not attach a waiter;\n\t\t\t\t// the returned revalidationPromise stays resolved so initial\n\t\t\t\t// client loaders awaiting it do not deadlock.\n\t\t\t\trequire_refresh(\"apiRequest\");\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tconst is_get = method === \"GET\" || method === \"HEAD\";\n\n\t\t\tconst headers = new Headers();\n\t\t\tif (deployment_id) {\n\t\t\t\theaders.set(VERCEL_X_DEPLOYMENT_ID, deployment_id);\n\t\t\t}\n\t\t\tnew Headers(request_init?.headers ?? undefined).forEach((v, k) => {\n\t\t\t\theaders.set(k, v);\n\t\t\t});\n\t\t\theaders.set(X_ACCEPTS_CLIENT_REDIRECT, \"1\");\n\n\t\t\tconst body = request_init?.body;\n\t\t\tconst should_json =\n\t\t\t\t!is_get &&\n\t\t\t\tbody &&\n\t\t\t\ttypeof body === \"object\" &&\n\t\t\t\t!(body instanceof ReadableStream) &&\n\t\t\t\t!(body instanceof FormData) &&\n\t\t\t\t!(body instanceof URLSearchParams) &&\n\t\t\t\t!(body instanceof Blob) &&\n\t\t\t\t!(body instanceof ArrayBuffer) &&\n\t\t\t\t!ArrayBuffer.isView(body);\n\n\t\t\tconst final_init: RequestInit = {\n\t\t\t\t...request_init,\n\t\t\t\tmethod,\n\t\t\t\theaders,\n\t\t\t\tsignal: ac.signal,\n\t\t\t};\n\t\t\tif (is_get) {\n\t\t\t\tdelete final_init.body;\n\t\t\t} else if (should_json) {\n\t\t\t\tfinal_init.body = JSON.stringify(body);\n\t\t\t\tif (!headers.has(\"Content-Type\")) {\n\t\t\t\t\theaders.set(\"Content-Type\", \"application/json\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdid_dispatch = true;\n\t\t\tconst res = await fetch(resolved, final_init);\n\n\t\t\tconst redirect = detect_redirect(res, resolved);\n\t\t\treport_build_skew({\n\t\t\t\tresponse: res,\n\t\t\t\ttriggeringResponse: {\n\t\t\t\t\tkind: \"apiRoute\",\n\t\t\t\t\tapiRouteKind: api_route_kind,\n\t\t\t\t\trequestedHref: resolved.href,\n\t\t\t\t\tmethod,\n\t\t\t\t\tstatus: res.status,\n\t\t\t\t\tok: res.ok,\n\t\t\t\t},\n\t\t\t\tdefaultBehavior:\n\t\t\t\t\tredirect &&\n\t\t\t\t\tis_http(redirect.href) &&\n\t\t\t\t\t(redirect.hard || !is_same_origin_href(redirect.href))\n\t\t\t\t\t\t? \"hardReload\"\n\t\t\t\t\t\t: \"notifyOnly\",\n\t\t\t});\n\n\t\t\tif (redirect && !ac.signal.aborted) {\n\t\t\t\tif (!is_http(redirect.href)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\terror: `Redirect target must use an HTTP(S) scheme. Received: \"${redirect.href}\".`,\n\t\t\t\t\t\tresponse: res,\n\t\t\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (redirect.hard || !is_same_origin_href(redirect.href)) {\n\t\t\t\t\thard_redirect(redirect.href);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tdata: undefined as T,\n\t\t\t\t\t\tresponse: res,\n\t\t\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (phase !== \"ready\") {\n\t\t\t\t\tdeferred_submit_redirect = new URL(redirect.href);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tdata: undefined as T,\n\t\t\t\t\t\tresponse: res,\n\t\t\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tvoid start_nav_inner(\n\t\t\t\t\tnew URL(redirect.href),\n\t\t\t\t\t{ replace: true },\n\t\t\t\t\t0,\n\t\t\t\t\t{ source: \"redirect\" },\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tdata: undefined as T,\n\t\t\t\t\tresponse: res,\n\t\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (!res.ok) {\n\t\t\t\tschedule_revalidation();\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: res.statusText,\n\t\t\t\t\tresponse: res,\n\t\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet data: unknown;\n\t\t\tif (res.status !== 204) {\n\t\t\t\tconst ct = res.headers.get(\"Content-Type\");\n\t\t\t\tif (ct?.toLowerCase().includes(\"json\")) {\n\t\t\t\t\tdata = await res.json();\n\t\t\t\t} else {\n\t\t\t\t\tconst t = await res.text();\n\t\t\t\t\tdata = t.length > 0 ? t : undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tschedule_revalidation();\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: data as T,\n\t\t\t\tresponse: res,\n\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t};\n\t\t} catch (e) {\n\t\t\tif (is_abort_error(e)) {\n\t\t\t\tif (did_dispatch) {\n\t\t\t\t\tschedule_revalidation();\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: \"Aborted\",\n\t\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (did_dispatch) {\n\t\t\t\tschedule_revalidation();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: String(e instanceof Error ? e.message : e),\n\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t};\n\t\t} finally {\n\t\t\tif (submissions.get(dedupe_key)?.ac === ac) {\n\t\t\t\tsubmissions.delete(dedupe_key);\n\t\t\t}\n\t\t\tnotify_work_update();\n\t\t}\n\t}\n\n\t/////// Popstate\n\n\tasync function handle_popstate(): Promise<void> {\n\t\tconst prev = browser;\n\t\tconst next = read_browser_position();\n\t\tif (next.key === prev.key && next.href === prev.href) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (prev.key && prev.key !== next.key) {\n\t\t\tsave_scroll_for_key(prev.key, get_scroll_pos());\n\t\t}\n\t\tbrowser = next;\n\n\t\tconst prev_url = new URL(prev.href);\n\t\tconst next_url = new URL(next.href);\n\n\t\t// Hash-only popstate on same path: scroll, no fetch.\n\t\tif (matches_without_hash(prev_url, next_url)) {\n\t\t\tif (route_snapshot) {\n\t\t\t\tconst prev_snapshot = route_snapshot;\n\t\t\t\troute_snapshot = {\n\t\t\t\t\tposition: browser,\n\t\t\t\t\troute: route_snapshot.route,\n\t\t\t\t};\n\t\t\t\tcommit_route_snapshot(\n\t\t\t\t\t\"popstate\",\n\t\t\t\t\tprev_snapshot,\n\t\t\t\t\troute_snapshot,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst hash = normalize_hash(next_url.hash);\n\t\t\tapply_scroll(\n\t\t\t\thash.length > 0\n\t\t\t\t\t? { hash: next_url.hash }\n\t\t\t\t\t: (get_scroll_for_key(next.key) ?? { x: 0, y: 0 }),\n\t\t\t\ttest_options,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst restored_scroll = get_scroll_for_key(next.key);\n\n\t\ttry {\n\t\t\tconst result = await start_nav_inner(\n\t\t\t\tnext_url,\n\t\t\t\t{ is_popstate: true, popstate_scroll: restored_scroll },\n\t\t\t\t0,\n\t\t\t);\n\t\t\tif (\n\t\t\t\t!result.didNavigate &&\n\t\t\t\t!active &&\n\t\t\t\t!route_snapshot_matches_browser()\n\t\t\t) {\n\t\t\t\treload_page();\n\t\t\t}\n\t\t} catch {\n\t\t\tif (!active && !route_snapshot_matches_browser()) {\n\t\t\t\treload_page();\n\t\t\t}\n\t\t}\n\t}\n\n\t/////// Status\n\n\tfunction derive_work_projection(): WorkProjection[] {\n\t\tconst work: WorkProjection[] = [];\n\n\t\tconst active_fetch = active;\n\t\tif (active_fetch?.intent.kind === \"nav\") {\n\t\t\twork.push({\n\t\t\t\tkind: \"navigation\",\n\t\t\t\tskip_work_indicator:\n\t\t\t\t\tactive_fetch.intent.options.skip_work_indicator,\n\t\t\t});\n\t\t}\n\n\t\tconst pending_revalidation =\n\t\t\trefresh.kind !== \"idle\" &&\n\t\t\t(refresh.kind === \"debouncing\" ||\n\t\t\t\trefresh.kind === \"retrying\" ||\n\t\t\t\t(!active_will_refresh() && !active));\n\t\tif (active_fetch?.intent.kind === \"reval\" || pending_revalidation) {\n\t\t\twork.push({\n\t\t\t\tkind: \"revalidation\",\n\t\t\t});\n\t\t}\n\n\t\tfor (const s of submissions.values()) {\n\t\t\twork.push({\n\t\t\t\tkind: \"apiRequest\",\n\t\t\t\tskip_work_indicator: s.skip_work_indicator,\n\t\t\t});\n\t\t}\n\n\t\tif (prefetch?.is_pending) {\n\t\t\twork.push({\n\t\t\t\tkind: \"prefetch\",\n\t\t\t});\n\t\t}\n\n\t\treturn work;\n\t}\n\n\tfunction empty_work_state(): WorkState {\n\t\treturn {\n\t\t\tnavigation: null,\n\t\t\trevalidation: null,\n\t\t\tprefetch: null,\n\t\t\tapiRequests: [],\n\t\t};\n\t}\n\n\tfunction derive_work_state(): WorkState {\n\t\tconst active_fetch = active;\n\t\tlet revalidation: WorkState[\"revalidation\"] = null;\n\t\tif (active_fetch?.intent.kind === \"reval\") {\n\t\t\trevalidation = {\n\t\t\t\tstatus: \"running\",\n\t\t\t\tattempt: active_fetch.intent.attempt,\n\t\t\t};\n\t\t} else if (refresh.kind === \"debouncing\") {\n\t\t\trevalidation = { status: \"debouncing\", attempt: 0 };\n\t\t} else if (refresh.kind === \"retrying\") {\n\t\t\trevalidation = {\n\t\t\t\tstatus: \"retrying\",\n\t\t\t\tattempt: refresh.attempt,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tnavigation:\n\t\t\t\tactive_fetch?.intent.kind === \"nav\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\thref: active_fetch.intent.url.href,\n\t\t\t\t\t\t\treplace:\n\t\t\t\t\t\t\t\tactive_fetch.intent.options.replace === true,\n\t\t\t\t\t\t\tsource: active_fetch.intent.source,\n\t\t\t\t\t\t}\n\t\t\t\t\t: null,\n\t\t\trevalidation,\n\t\t\tprefetch: prefetch?.is_pending ? { href: prefetch.url.href } : null,\n\t\t\tapiRequests: Array.from(submissions.values(), (s) => {\n\t\t\t\treturn {\n\t\t\t\t\tkey: s.key,\n\t\t\t\t\tmethod: s.method,\n\t\t\t\t\thref: s.href,\n\t\t\t\t};\n\t\t\t}),\n\t\t};\n\t}\n\n\tfunction take_work_update(): WorkState | undefined {\n\t\tconst next = derive_work_state();\n\t\tif (jsonDeepEquals(last_work_state, next)) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlast_work_state = next;\n\t\treturn next;\n\t}\n\n\tfunction emit_client_commit(client_commit: ClientCommit): void {\n\t\tcommit(client_commit);\n\t\tif (client_commit.route_update && user_on_route_update) {\n\t\t\tuser_on_route_update(\n\t\t\t\tclient_commit.route_update.route,\n\t\t\t\tclient_commit.route_update.previous_route,\n\t\t\t\tclient_commit.route_update.reason,\n\t\t\t);\n\t\t}\n\t\tif (client_commit.work) {\n\t\t\tfor (const fn of work_update_listeners) {\n\t\t\t\tfn(client_commit.work);\n\t\t\t}\n\t\t\tuser_on_work_update?.(client_commit.work);\n\t\t}\n\t}\n\n\tfunction notify_work_update(): void {\n\t\tconst work = take_work_update();\n\t\tif (!work) {\n\t\t\tsync_work_indicator();\n\t\t\treturn;\n\t\t}\n\t\temit_client_commit({ work });\n\t}\n\n\t/////// HMR\n\n\tfunction register_hmr(): void {\n\t\tif (!import.meta.env.DEV || !import.meta.hot) {\n\t\t\treturn;\n\t\t}\n\t\twindow.__vorma_hmr_route_update = async (raw_url, mod) => {\n\t\t\tif (!route_snapshot) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst url = normalize_module_url(raw_url);\n\t\t\tmodule_cache.set(url, mod);\n\t\t\tconst idx = route_snapshot.route.matches.findIndex(\n\t\t\t\t(m) => normalize_module_url(m.module_url) === url,\n\t\t\t);\n\t\t\tif (idx === -1) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst match = route_snapshot.route.matches[idx]!;\n\t\t\tconst def = mod.default as ViewDefinition | undefined;\n\t\t\tif (def?.client_loader) {\n\t\t\t\tmodule_map[match.pattern] = def.client_loader;\n\t\t\t\tregisterPattern(pattern_registry, match.pattern);\n\t\t\t} else {\n\t\t\t\tdelete module_map[match.pattern];\n\t\t\t}\n\n\t\t\tlet client_loader_data = match.client_loader_data;\n\t\t\tif (hmr_rerun_patterns.has(match.pattern)) {\n\t\t\t\tconst loader = module_map[match.pattern];\n\t\t\t\tif (loader) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst current_route = route_snapshot.route;\n\t\t\t\t\t\tconst routes = current_route.matches.map((m, i) => {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tpattern: m.pattern,\n\t\t\t\t\t\t\t\tinput: m.input,\n\t\t\t\t\t\t\t\tmodule_url: m.module_url,\n\t\t\t\t\t\t\t\tloader_data: m.loader_data,\n\t\t\t\t\t\t\t\tserver_error:\n\t\t\t\t\t\t\t\t\tcurrent_route.error?.source === \"server\" &&\n\t\t\t\t\t\t\t\t\tcurrent_route.error.idx === i\n\t\t\t\t\t\t\t\t\t\t? current_route.error.error\n\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t\tclient_loader_data = await loader({\n\t\t\t\t\t\t\ttrigger: \"revalidation\",\n\t\t\t\t\t\t\thref: route_snapshot.position.href,\n\t\t\t\t\t\t\thistoryState: route_snapshot.position.state,\n\t\t\t\t\t\t\tpattern: match.pattern,\n\t\t\t\t\t\t\tparams: route_snapshot.route.params,\n\t\t\t\t\t\t\tsplatValues: route_snapshot.route.splat_values,\n\t\t\t\t\t\t\tinput: match.input,\n\t\t\t\t\t\t\tknownMatches: routes_to_known_matches(routes),\n\t\t\t\t\t\t\tserverPromise: Promise.resolve(\n\t\t\t\t\t\t\t\tbuild_server_state(routes, idx),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsignal: new AbortController().signal,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\"Vorma: HMR client loader re-run failed\",\n\t\t\t\t\t\t\terr,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!route_snapshot) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prev = route_snapshot;\n\t\t\tconst matches = route_snapshot.route.matches.map((m, i) =>\n\t\t\t\ti === idx ? { ...m, module: mod, client_loader_data } : m,\n\t\t\t);\n\t\t\troute_snapshot = {\n\t\t\t\tposition: route_snapshot.position,\n\t\t\t\troute: { ...route_snapshot.route, matches },\n\t\t\t};\n\t\t\tcommit_route_snapshot(\"hmr\", prev, route_snapshot);\n\t\t};\n\t}\n\n\t/////// Work Indicator\n\n\tfunction setup_work_indicator(\n\t\toptions: WorkIndicatorOptions | undefined,\n\t): void {\n\t\twork_indicator_options = options;\n\t\twork_indicator.configure(options);\n\t\tif (!work_indicator_sync_registered) {\n\t\t\twork_update_listeners.add(sync_work_indicator);\n\t\t\twork_indicator_sync_registered = true;\n\t\t}\n\t\tsync_work_indicator();\n\t}\n\n\tfunction sync_work_indicator(_work?: WorkState): void {\n\t\tconst options = work_indicator_options;\n\t\tif (!options) {\n\t\t\twork_indicator.set_vorma_active(false);\n\t\t\treturn;\n\t\t}\n\n\t\tlet active_for_vorma = false;\n\t\tfor (const work of derive_work_projection()) {\n\t\t\tif (\n\t\t\t\twork.kind === \"navigation\" &&\n\t\t\t\toptions.skipNavigations !== true &&\n\t\t\t\t!work.skip_work_indicator\n\t\t\t) {\n\t\t\t\tactive_for_vorma = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (\n\t\t\t\twork.kind === \"revalidation\" &&\n\t\t\t\toptions.skipRevalidations !== true\n\t\t\t) {\n\t\t\t\tactive_for_vorma = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (\n\t\t\t\twork.kind === \"apiRequest\" &&\n\t\t\t\toptions.skipAPIRequests !== true &&\n\t\t\t\t!work.skip_work_indicator\n\t\t\t) {\n\t\t\t\tactive_for_vorma = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\twork_indicator.set_vorma_active(active_for_vorma);\n\t}\n\n\t/////// Boot\n\n\tasync function boot(options: ClientOptions): Promise<Result<void>> {\n\t\tconst payload_el = document.getElementById(DATA_SCRIPT_ID);\n\t\tif (!payload_el) {\n\t\t\treturn R.err(`Missing element: #${DATA_SCRIPT_ID}`);\n\t\t}\n\t\tlet raw_payload: Record<string, any>;\n\t\ttry {\n\t\t\traw_payload = JSON.parse(payload_el.textContent ?? \"{}\");\n\t\t} catch (err) {\n\t\t\treturn R.err(\n\t\t\t\t`Failed to parse #${DATA_SCRIPT_ID}: ${to_error_string(err)}`,\n\t\t\t);\n\t\t}\n\t\tif (raw_payload.ClientBuildID) {\n\t\t\tclient_build_id = raw_payload.ClientBuildID;\n\t\t}\n\t\tif (raw_payload.DeploymentID) {\n\t\t\tdeployment_id = raw_payload.DeploymentID;\n\t\t}\n\t\tconst payload = decode_payload(raw_payload, current_url());\n\n\t\tuser_on_route_update = options.onRouteUpdate;\n\t\tuser_on_work_update = options.onWorkUpdate;\n\t\tuser_on_build_skew_detected = options.onBuildSkewDetected;\n\t\tdefault_error_boundary = options.defaultErrorBoundary;\n\t\tuse_view_transitions = options.useViewTransitions ?? false;\n\n\t\tconst history_state = window.history.state;\n\t\tconst has_history_key =\n\t\t\thistory_state &&\n\t\t\ttypeof history_state === \"object\" &&\n\t\t\tHISTORY_KEY_FIELD in (history_state as Record<string, unknown>);\n\t\tif (!has_history_key) {\n\t\t\tconst base =\n\t\t\t\thistory_state && typeof history_state === \"object\"\n\t\t\t\t\t? history_state\n\t\t\t\t\t: {};\n\t\t\twindow.history.replaceState(\n\t\t\t\t{\n\t\t\t\t\t...(base as object),\n\t\t\t\t\t[HISTORY_KEY_FIELD]: make_history_key(),\n\t\t\t\t},\n\t\t\t\t\"\",\n\t\t\t\tcurrent_url().href,\n\t\t\t);\n\t\t}\n\t\tbrowser = read_browser_position();\n\t\ttry {\n\t\t\twindow.history.scrollRestoration = \"manual\";\n\t\t} catch {}\n\n\t\tconst initial_ac = new AbortController();\n\t\tconst modules = await prepare_modules(payload, initial_ac.signal);\n\t\tif (!modules) {\n\t\t\treturn R.err(\"Initial navigation produced no state\");\n\t\t}\n\n\t\t// Install a provisional snapshot so router APIs (getRouteState, submit)\n\t\t// work during initial client-loader execution.\n\t\troute_snapshot = {\n\t\t\tposition: browser,\n\t\t\troute: build_route_record(payload, modules, []),\n\t\t};\n\n\t\tconst cl_results = await run_client_loaders(\n\t\t\tpayload.routes,\n\t\t\tpayload,\n\t\t\t[],\n\t\t\t\"boot\",\n\t\t\tbrowser.href,\n\t\t\tbrowser.state,\n\t\t\tinitial_ac.signal,\n\t\t);\n\t\tif (initial_ac.signal.aborted) {\n\t\t\treturn R.err(\"Initial navigation produced no state\");\n\t\t}\n\n\t\tawait wait_for_css(payload.css_bundles, initial_ac.signal);\n\t\tif (initial_ac.signal.aborted) {\n\t\t\treturn R.err(\"Initial navigation produced no state\");\n\t\t}\n\n\t\tconst route = build_route_record(payload, modules, cl_results);\n\t\troute_snapshot = { position: browser, route };\n\n\t\tapply_head_and_title(\n\t\t\tpayload.title,\n\t\t\tpayload.meta_head_els,\n\t\t\tpayload.rest_head_els,\n\t\t);\n\t\tapply_css_bundles(payload.css_bundles);\n\t\tpreload_modules(payload.deps);\n\n\t\tlet scroll_intent: ScrollIntent | undefined;\n\t\tconst make_scroll_intent = (scroll: ScrollState): ScrollIntent => {\n\t\t\treturn {\n\t\t\t\tscroll,\n\t\t\t\ttarget_route_id: make_route_id(\n\t\t\t\t\troute.matches.length - 1,\n\t\t\t\t\troute.matches[route.matches.length - 1]?.pattern ?? \"\",\n\t\t\t\t),\n\t\t\t};\n\t\t};\n\t\tlet refresh_scroll_raw: string | null;\n\t\ttry {\n\t\t\trefresh_scroll_raw = sessionStorage.getItem(\n\t\t\t\tSCROLL_STORAGE_RELOAD_KEY,\n\t\t\t);\n\t\t} catch {\n\t\t\trefresh_scroll_raw = null;\n\t\t}\n\t\tif (refresh_scroll_raw) {\n\t\t\ttry {\n\t\t\t\tsessionStorage.removeItem(SCROLL_STORAGE_RELOAD_KEY);\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tconst s = JSON.parse(refresh_scroll_raw);\n\t\t\t\tif (\n\t\t\t\t\ttypeof s?.x === \"number\" &&\n\t\t\t\t\ttypeof s?.y === \"number\" &&\n\t\t\t\t\ttypeof s?.unix === \"number\" &&\n\t\t\t\t\ttypeof s?.href === \"string\" &&\n\t\t\t\t\tDate.now() - s.unix <= REFRESH_MAX_AGE_MS &&\n\t\t\t\t\tmatches_without_hash(new URL(s.href), current_url())\n\t\t\t\t) {\n\t\t\t\t\tscroll_intent = make_scroll_intent({ x: s.x, y: s.y });\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\t\tif (!scroll_intent) {\n\t\t\tconst hash = normalize_hash(current_url().hash);\n\t\t\tif (hash.length > 0) {\n\t\t\t\tscroll_intent = make_scroll_intent({\n\t\t\t\t\thash: current_url().hash,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tcommit_route_snapshot(\"initial\", null, route_snapshot, scroll_intent);\n\n\t\tsetup_work_indicator(options.workIndicator);\n\t\tif (focus_revalidation_cleanup) {\n\t\t\tfocus_revalidation_cleanup();\n\t\t\tfocus_revalidation_cleanup = null;\n\t\t}\n\t\tif (options.revalidateOnWindowFocus) {\n\t\t\tconst stale_ms =\n\t\t\t\ttypeof options.revalidateOnWindowFocus === \"object\"\n\t\t\t\t\t? options.revalidateOnWindowFocus.staleTimeMS\n\t\t\t\t\t: 5_000;\n\t\t\tfocus_revalidation_cleanup = addOnWindowFocusListener(() => {\n\t\t\t\tconst work = derive_work_state();\n\t\t\t\tif (\n\t\t\t\t\twork.navigation ||\n\t\t\t\t\twork.revalidation ||\n\t\t\t\t\twork.apiRequests.length > 0\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (Date.now() - last_activity_ts >= stale_ms) {\n\t\t\t\t\trequire_refresh(\"windowFocus\", undefined, true);\n\t\t\t\t\tnotify_work_update();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (options.render) {\n\t\t\tawait options.render();\n\t\t}\n\n\t\twindow.addEventListener(\"popstate\", () => {\n\t\t\tvoid handle_popstate();\n\t\t});\n\t\twindow.addEventListener(\"beforeunload\", () => {\n\t\t\ttry {\n\t\t\t\tsessionStorage.setItem(\n\t\t\t\t\tSCROLL_STORAGE_RELOAD_KEY,\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\t...get_scroll_pos(),\n\t\t\t\t\t\tunix: Date.now(),\n\t\t\t\t\t\thref: current_url().href,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} catch {}\n\t\t});\n\t\tregister_hmr();\n\n\t\tphase = \"ready\";\n\t\tif (deferred_submit_redirect) {\n\t\t\tconst redirect = deferred_submit_redirect;\n\t\t\tdeferred_submit_redirect = null;\n\t\t\tvoid start_nav_inner(redirect, { replace: true }, 0, {\n\t\t\t\tsource: \"redirect\",\n\t\t\t});\n\t\t}\n\t\tmaybe_revalidate();\n\t\treturn R.ok(undefined);\n\t}\n\n\t/////// Public API\n\n\tasync function navigate(\n\t\thref: string | URL,\n\t\toptions?: {\n\t\t\treplace?: boolean;\n\t\t\tscrollToTop?: boolean;\n\t\t\tstate?: unknown;\n\t\t\tskipWorkIndicator?: boolean;\n\t\t},\n\t): Promise<NavResult> {\n\t\tif (phase !== \"ready\") {\n\t\t\tthrow new Error(\"Vorma not booted\");\n\t\t}\n\t\tconst url = new URL(String(href), window.location.href);\n\t\tif (!is_same_origin(url)) {\n\t\t\thard_redirect(url.href);\n\t\t\treturn { didNavigate: false };\n\t\t}\n\t\treturn start_nav_inner(\n\t\t\turl,\n\t\t\t{\n\t\t\t\treplace: options?.replace,\n\t\t\t\tscroll_to_top: options?.scrollToTop,\n\t\t\t\tstate: options?.state,\n\t\t\t\tskip_work_indicator: options?.skipWorkIndicator,\n\t\t\t},\n\t\t\t0,\n\t\t);\n\t}\n\n\tasync function revalidate(): Promise<RevalidationResult> {\n\t\tif (phase !== \"ready\") {\n\t\t\tthrow new Error(\"Vorma not booted\");\n\t\t}\n\t\tconst waiter = make_deferred<RevalidationResult>();\n\t\trequire_refresh(\"manual\", waiter, true);\n\t\tnotify_work_update();\n\t\treturn waiter.promise;\n\t}\n\n\tfunction getRouteState(): RouteState {\n\t\tconst snapshot = route_snapshot;\n\t\tif (!snapshot) {\n\t\t\tthrow new Error(\"Vorma not booted\");\n\t\t}\n\t\treturn route_snapshot_to_state(snapshot);\n\t}\n\n\tfunction getWorkState(): WorkState {\n\t\tif (!route_snapshot) {\n\t\t\tthrow new Error(\"Vorma not booted\");\n\t\t}\n\t\treturn derive_work_state();\n\t}\n\n\tfunction getRootEl(): HTMLElement {\n\t\tconst el = document.getElementById(VORMA_ROOT_EL_ID);\n\t\tif (el) {\n\t\t\treturn el;\n\t\t}\n\t\tconst fresh = document.createElement(\"div\");\n\t\tfresh.id = VORMA_ROOT_EL_ID;\n\t\tdocument.body.insertBefore(fresh, document.body.firstChild);\n\t\treturn fresh;\n\t}\n\n\tfunction defineView<T = any>(input: {\n\t\tpattern: string;\n\t\tcomponent: (props: any) => any;\n\t\terrorBoundary?: (props: { error: unknown }) => any;\n\t\tclientLoader?: (props: any) => Promise<T>;\n\t\tbeforeRouteCommit?: BeforeRouteCommitFn;\n\t\tbeforeRouteYield?: BeforeRouteYieldFn;\n\t\trunClientLoaderOnHMR?: boolean;\n\t}): ViewDefinition & { __phantom_client_loader_data?: T } {\n\t\tif (import.meta.env.DEV) {\n\t\t\tif (input.runClientLoaderOnHMR) {\n\t\t\t\thmr_rerun_patterns.add(input.pattern);\n\t\t\t} else {\n\t\t\t\thmr_rerun_patterns.delete(input.pattern);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tpattern: input.pattern,\n\t\t\tcomponent: input.component,\n\t\t\terror_boundary: input.errorBoundary,\n\t\t\tclient_loader: input.clientLoader,\n\t\t\tbefore_route_commit: input.beforeRouteCommit,\n\t\t\tbefore_route_yield: input.beforeRouteYield,\n\t\t};\n\t}\n\n\t(window as any)[Symbol.for(\"vorma-data-revalidate-fn\")] = revalidate;\n\n\treturn R.ok({\n\t\tboot,\n\t\tworkIndicator: work_indicator.indicator,\n\t\tnavigate,\n\t\trevalidate,\n\t\tsubmit_inner,\n\t\tgetRouteState,\n\t\tgetWorkState,\n\t\tgetClientBuildID: () => client_build_id,\n\t\tgetRootEl,\n\t\tdefineView,\n\t\tstart_prefetch,\n\t\tstop_prefetch,\n\t\tsave_current_scroll,\n\t\tget_default_error_boundary: () => default_error_boundary,\n\t});\n}\n\ndeclare global {\n\tinterface Window {\n\t\t__vorma_hmr_route_update?: (\n\t\t\traw_url: string,\n\t\t\tmod: Record<string, unknown>,\n\t\t) => Promise<void>;\n\t}\n}\n","import {\n\tgetHrefDetails,\n\tgetIsModifiedNavigationClick,\n\tgetIsPrimaryNavigationClick,\n} from \"vorma/kit/url\";\nimport {\n\tLINK_ACTIVE_ANCESTOR_ATTR,\n\tLINK_ACTIVE_EXACT_ATTR,\n\tLINK_PENDING_ANCESTOR_ATTR,\n\tLINK_PENDING_EXACT_ATTR,\n} from \"./constants.ts\";\nimport type { WorkState } from \"./create_client_core.ts\";\nimport type { LinkPropsBase, RouteState } from \"./types.ts\";\n\nexport type LinkRouteState = {\n\thref: string;\n\tmatchedPatterns: string[];\n};\n\nexport type LinkWorkState = {\n\tnavigationHref: string | null;\n};\n\nexport type LinkPropsResult = {\n\tis_external: boolean;\n\tanchor_props: Record<string, unknown>;\n\tonClick?: (e: unknown) => void;\n\tonPointerDown?: (e: unknown) => void;\n\tonPointerEnter?: (e: unknown) => void;\n\tonFocus?: (e: unknown) => void;\n\tonPointerLeave?: (e: unknown) => void;\n\tonBlur?: (e: unknown) => void;\n\tonTouchCancel?: (e: unknown) => void;\n};\n\nexport type LinkNavFns = {\n\tnavigate: (args: {\n\t\thref: string;\n\t\treplace?: boolean;\n\t\tscrollToTop?: boolean;\n\t\tstate?: unknown;\n\t}) => Promise<{ didNavigate: boolean }>;\n\tstart_prefetch: (href: string) => void;\n\tstop_prefetch: (href: string) => void;\n\tsave_current_scroll: () => void;\n\tregister_link_pattern: (pattern: string) => void;\n\tget_link_attribute_state: (\n\t\thref: string,\n\t\tmatch_rules: LinkPropsBase[\"attributeMatchRules\"],\n\t\troute_state: LinkRouteState | null,\n\t\twork_state: LinkWorkState,\n\t) => {\n\t\tactive_exact: boolean;\n\t\tactive_ancestor: boolean;\n\t\tpending_exact: boolean;\n\t\tpending_ancestor: boolean;\n\t};\n};\n\nconst VORMA_KEYS = new Set([\n\t\"attributeMatchRules\",\n\t\"pattern\",\n\t\"prefetch\",\n\t\"prefetchDelayMs\",\n\t\"replace\",\n\t\"scrollToTop\",\n\t\"state\",\n\t\"visitOnPointerDown\",\n]);\n\nconst COMPOSED_EVENT_KEYS = new Set([\n\t\"onClick\",\n\t\"onPointerDown\",\n\t\"onPointerEnter\",\n\t\"onFocus\",\n\t\"onPointerLeave\",\n\t\"onBlur\",\n\t\"onTouchCancel\",\n]);\n\nlet is_touch_active = false;\nlet input_modality_registered = false;\n\nfunction register_input_modality(): void {\n\tif (input_modality_registered) {\n\t\treturn;\n\t}\n\tinput_modality_registered = true;\n\n\twindow.addEventListener(\"touchstart\", () => {\n\t\tis_touch_active = true;\n\t});\n\n\tconst on_pointer = (e: PointerEvent) => {\n\t\tconst pt = e.pointerType;\n\t\tif (pt === \"touch\") {\n\t\t\tis_touch_active = true;\n\t\t} else if (pt === \"mouse\" || pt === \"pen\") {\n\t\t\tis_touch_active = false;\n\t\t}\n\t};\n\n\twindow.addEventListener(\"pointerdown\", on_pointer);\n\twindow.addEventListener(\"pointermove\", on_pointer);\n}\n\nexport function select_link_route_state(route: RouteState): LinkRouteState {\n\treturn {\n\t\thref: route.href,\n\t\tmatchedPatterns: route.matches.map((m) => {\n\t\t\treturn m.pattern;\n\t\t}),\n\t};\n}\n\nexport function select_link_work_state(work: WorkState): LinkWorkState {\n\treturn {\n\t\tnavigationHref: work.navigation?.href ?? null,\n\t};\n}\n\nfunction strip_keys(\n\tprops: Record<string, unknown>,\n\tkeys: Set<string>,\n): Record<string, unknown> {\n\tconst out: Record<string, unknown> = {};\n\tfor (const [k, v] of Object.entries(props)) {\n\t\tif (!keys.has(k)) {\n\t\t\tout[k] = v;\n\t\t}\n\t}\n\treturn out;\n}\n\nexport function make_link_props(\n\tprops: Record<string, unknown>,\n\tnav: LinkNavFns,\n\troute_state: LinkRouteState | null = null,\n\twork_state?: LinkWorkState,\n): LinkPropsResult {\n\tregister_input_modality();\n\n\tconst href = (props.href as string) ?? \"\";\n\tconst pattern = props.pattern as string | undefined;\n\tif (pattern) {\n\t\tnav.register_link_pattern(pattern);\n\t}\n\n\tconst details = getHrefDetails(href);\n\tconst is_external = details.isHTTP ? details.isExternal : true;\n\tconst consumer_click = props.onClick as ((e: unknown) => void) | undefined;\n\n\tif (is_external) {\n\t\treturn {\n\t\t\tis_external: true,\n\t\t\tanchor_props: strip_keys(props, VORMA_KEYS),\n\t\t\tonClick: consumer_click,\n\t\t};\n\t}\n\n\tconst anchor_props = strip_keys(\n\t\tstrip_keys(props, VORMA_KEYS),\n\t\tCOMPOSED_EVENT_KEYS,\n\t);\n\tconst attribute_match_rules =\n\t\tprops.attributeMatchRules as LinkPropsBase[\"attributeMatchRules\"];\n\tconst link_state =\n\t\tattribute_match_rules?.skip === true || !route_state || !work_state\n\t\t\t? null\n\t\t\t: nav.get_link_attribute_state(\n\t\t\t\t\thref,\n\t\t\t\t\tattribute_match_rules,\n\t\t\t\t\troute_state,\n\t\t\t\t\twork_state,\n\t\t\t\t);\n\tif (link_state?.active_exact) {\n\t\tanchor_props[LINK_ACTIVE_EXACT_ATTR] = \"\";\n\t}\n\tif (link_state?.active_ancestor) {\n\t\tanchor_props[LINK_ACTIVE_ANCESTOR_ATTR] = \"\";\n\t}\n\tif (link_state?.pending_exact) {\n\t\tanchor_props[LINK_PENDING_EXACT_ATTR] = \"\";\n\t}\n\tif (link_state?.pending_ancestor) {\n\t\tanchor_props[LINK_PENDING_ANCESTOR_ATTR] = \"\";\n\t}\n\tif (\n\t\tlink_state?.active_exact &&\n\t\tanchor_props[\"aria-current\"] === undefined\n\t) {\n\t\tanchor_props[\"aria-current\"] = \"page\";\n\t}\n\n\tconst prefetch_mode = props.prefetch as string | undefined;\n\tconst prefetch_delay = (props.prefetchDelayMs as number | undefined) ?? 100;\n\tconst replace = props.replace as boolean | undefined;\n\tconst scroll_to_top = props.scrollToTop as boolean | undefined;\n\tconst state = props.state as unknown;\n\tconst target_attr = props.target as string | undefined;\n\tconst visit_on_pointer_down = props.visitOnPointerDown as\n\t\t| boolean\n\t\t| undefined;\n\tconst consumer_pointer_down = props.onPointerDown as\n\t\t| ((e: unknown) => void)\n\t\t| undefined;\n\tconst consumer_pointer_enter = props.onPointerEnter as\n\t\t| ((e: unknown) => void)\n\t\t| undefined;\n\tconst consumer_focus = props.onFocus as ((e: unknown) => void) | undefined;\n\tconst consumer_pointer_leave = props.onPointerLeave as\n\t\t| ((e: unknown) => void)\n\t\t| undefined;\n\tconst consumer_blur = props.onBlur as ((e: unknown) => void) | undefined;\n\tconst consumer_touch_cancel = props.onTouchCancel as\n\t\t| ((e: unknown) => void)\n\t\t| undefined;\n\n\tlet prefetch_timer: number | undefined;\n\tconst wants_prefetch = prefetch_mode === \"intent\";\n\n\tconst start_pf = () => {\n\t\tif (prefetch_timer !== undefined) {\n\t\t\tclearTimeout(prefetch_timer);\n\t\t}\n\t\tprefetch_timer = window.setTimeout(() => {\n\t\t\tprefetch_timer = undefined;\n\t\t\tnav.start_prefetch(href);\n\t\t}, prefetch_delay);\n\t};\n\n\tconst stop_pf = () => {\n\t\tif (prefetch_timer !== undefined) {\n\t\t\tclearTimeout(prefetch_timer);\n\t\t\tprefetch_timer = undefined;\n\t\t}\n\t\tnav.stop_prefetch(href);\n\t};\n\n\treturn {\n\t\tis_external: false,\n\t\tanchor_props,\n\n\t\tonClick: async (e: unknown) => {\n\t\t\tconst ev = e as any;\n\t\t\tconsumer_click?.(e);\n\n\t\t\tif (ev.defaultPrevented) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (getIsModifiedNavigationClick(ev)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!getIsPrimaryNavigationClick(ev)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (target_attr && target_attr !== \"\" && target_attr !== \"_self\") {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tev.preventDefault?.();\n\n\t\t\ttry {\n\t\t\t\tawait nav.navigate({\n\t\t\t\t\thref,\n\t\t\t\t\treplace,\n\t\t\t\t\tscrollToTop: scroll_to_top,\n\t\t\t\t\tstate,\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(\"Vorma: Link click failed\", err);\n\t\t\t}\n\t\t},\n\n\t\tonPointerDown:\n\t\t\tvisit_on_pointer_down || consumer_pointer_down\n\t\t\t\t? async (e: unknown) => {\n\t\t\t\t\t\tconst ev = e as any;\n\t\t\t\t\t\tconsumer_pointer_down?.(e);\n\t\t\t\t\t\tif (!visit_on_pointer_down) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (ev.defaultPrevented) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst pt = ev.pointerType;\n\t\t\t\t\t\tif (pt !== \"mouse\" && pt !== \"pen\") {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (getIsModifiedNavigationClick(ev)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!getIsPrimaryNavigationClick(ev)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\ttarget_attr &&\n\t\t\t\t\t\t\ttarget_attr !== \"\" &&\n\t\t\t\t\t\t\ttarget_attr !== \"_self\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tev.preventDefault?.();\n\n\t\t\t\t\t\tconst el = ev.currentTarget as HTMLElement;\n\t\t\t\t\t\tel.addEventListener(\n\t\t\t\t\t\t\t\"click\",\n\t\t\t\t\t\t\t(ce: Event) => {\n\t\t\t\t\t\t\t\tce.preventDefault();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ once: true },\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait nav.navigate({\n\t\t\t\t\t\t\t\thref,\n\t\t\t\t\t\t\t\treplace,\n\t\t\t\t\t\t\t\tscrollToTop: scroll_to_top,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t\"Vorma: Link pointerdown navigation failed\",\n\t\t\t\t\t\t\t\terr,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\n\t\tonPointerEnter:\n\t\t\twants_prefetch || consumer_pointer_enter\n\t\t\t\t? (e: unknown) => {\n\t\t\t\t\t\tif (wants_prefetch) {\n\t\t\t\t\t\t\tstart_pf();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconsumer_pointer_enter?.(e);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\n\t\tonFocus:\n\t\t\twants_prefetch || consumer_focus\n\t\t\t\t? (e: unknown) => {\n\t\t\t\t\t\tif (wants_prefetch) {\n\t\t\t\t\t\t\tstart_pf();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconsumer_focus?.(e);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\n\t\tonPointerLeave:\n\t\t\twants_prefetch || consumer_pointer_leave\n\t\t\t\t? (e: unknown) => {\n\t\t\t\t\t\tif (wants_prefetch && !is_touch_active) {\n\t\t\t\t\t\t\tstop_pf();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconsumer_pointer_leave?.(e);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\n\t\tonBlur:\n\t\t\twants_prefetch || consumer_blur\n\t\t\t\t? (e: unknown) => {\n\t\t\t\t\t\tif (wants_prefetch) {\n\t\t\t\t\t\t\tstop_pf();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconsumer_blur?.(e);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\n\t\tonTouchCancel:\n\t\t\twants_prefetch || consumer_touch_cancel\n\t\t\t\t? (e: unknown) => {\n\t\t\t\t\t\tif (wants_prefetch) {\n\t\t\t\t\t\t\tstop_pf();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconsumer_touch_cancel?.(e);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t};\n}\n","import type { ViewDefinition, RouteRenderEntry } from \"./create_client_core.ts\";\nimport type { RouteErrorState } from \"./types.ts\";\n\nexport type OutletSlot =\n\t| { kind: \"component\"; component: (props: any) => any }\n\t| {\n\t\t\tkind: \"error\";\n\t\t\terror: unknown;\n\t\t\tboundary: (props: { error: unknown }) => any;\n\t }\n\t| { kind: \"pass_through\" }\n\t| { kind: \"empty\" };\n\nconst component_refs = new Map<\n\tstring,\n\t{\n\t\timpl: (props: any) => any;\n\t\twrapper: (props: any) => any;\n\t\tholder: { current: (props: any) => any };\n\t}\n>();\n\nconst error_refs = new Map<\n\tstring,\n\t{\n\t\timpl: (props: { error: unknown }) => any;\n\t\twrapper: (props: { error: unknown }) => any;\n\t\tholder: { current: (props: { error: unknown }) => any };\n\t}\n>();\n\nfunction get_stable_component(\n\tkey: string,\n\timpl: (props: any) => any,\n): (props: any) => any {\n\tlet entry = component_refs.get(key);\n\tif (!entry) {\n\t\tconst holder = { current: impl };\n\t\tconst wrapper = (props: any) => {\n\t\t\treturn holder.current(props);\n\t\t};\n\t\tentry = { impl, wrapper, holder };\n\t\tcomponent_refs.set(key, entry);\n\t}\n\tentry.holder.current = impl;\n\treturn entry.wrapper;\n}\n\nfunction get_stable_error_boundary(\n\tkey: string,\n\timpl: (props: { error: unknown }) => any,\n): (props: { error: unknown }) => any {\n\tlet entry = error_refs.get(key);\n\tif (!entry) {\n\t\tconst holder = { current: impl };\n\t\tconst wrapper = (props: { error: unknown }) => {\n\t\t\treturn holder.current(props);\n\t\t};\n\t\tentry = { impl, wrapper, holder };\n\t\terror_refs.set(key, entry);\n\t}\n\tentry.holder.current = impl;\n\treturn entry.wrapper;\n}\n\nexport function resolve_outlet_slot(\n\tentries: RouteRenderEntry[],\n\terror: RouteErrorState | null,\n\tidx: number,\n\tdefault_error_boundary: ((props: { error: unknown }) => any) | undefined,\n): OutletSlot {\n\tif (idx >= entries.length) {\n\t\treturn { kind: \"empty\" };\n\t}\n\n\tif (error !== null && idx >= error.idx) {\n\t\tconst error_entry = entries[error.idx]!;\n\t\tconst def = error_entry.module.default as ViewDefinition | undefined;\n\t\tconst raw_boundary =\n\t\t\tdef?.error_boundary ??\n\t\t\tdefault_error_boundary ??\n\t\t\tfallback_error_boundary;\n\t\tconst boundary = get_stable_error_boundary(\n\t\t\terror_entry.pattern,\n\t\t\traw_boundary,\n\t\t);\n\t\treturn { kind: \"error\", error: error.error, boundary };\n\t}\n\n\tconst entry = entries[idx]!;\n\tconst def = entry.module.default as ViewDefinition | undefined;\n\n\tif (!def?.component) {\n\t\tif (idx + 1 < entries.length) {\n\t\t\treturn { kind: \"pass_through\" };\n\t\t}\n\t\treturn { kind: \"empty\" };\n\t}\n\n\tconst component = get_stable_component(entry.pattern, def.component);\n\treturn { kind: \"component\", component };\n}\n\nexport function get_entry_key(entry: RouteRenderEntry): string {\n\treturn `${entry.pattern}::${entry.module_url}`;\n}\n\nfunction fallback_error_boundary(props: { error: unknown }): string {\n\tif (props.error instanceof Error) {\n\t\treturn `Error: ${props.error.message}`;\n\t}\n\tif (typeof props.error === \"string\") {\n\t\treturn `Error: ${props.error}`;\n\t}\n\treturn \"An unexpected error occurred.\";\n}\n","import type { ReadonlySignal } from \"@preact/signals\";\nimport { jsonDeepEquals } from \"vorma/kit/json\";\nimport {\n\tcreatePatternRegistry,\n\tfindNestedMatches,\n\tregisterPattern,\n} from \"vorma/kit/matcher\";\nimport { R, type Result } from \"vorma/kit/result\";\nimport { create_typed_api_client } from \"./api_client.ts\";\nimport type {\n\tClientCore,\n\tClientOptions as CoreClientOptions,\n\tViewDefinition,\n} from \"./create_client_core\";\nimport {\n\tcreate_client_core,\n\ttype ClientCommit,\n\ttype RouteRenderEntry,\n\ttype RouteRenderState,\n\ttype ScrollIntent,\n\ttype WorkState,\n} from \"./create_client_core.ts\";\nimport {\n\ttype LinkNavFns,\n\ttype LinkRouteState,\n\ttype LinkWorkState,\n} from \"./make_link_props.ts\";\nimport { get_entry_key } from \"./resolve_outlet_slot.ts\";\nimport type {\n\tAppConfig,\n\tLinkPropsBase,\n\tRouteErrorState,\n\tRouteState,\n\tRouteUpdateReason,\n\tToAPIClient,\n\tToAPIDecorator,\n\tToDefineViewArgs,\n\tToLinkProps,\n\tToLoaderOutput,\n\tToNavigateArgs,\n\tToNavigationTarget,\n\tToRouteComponentProps,\n\tToRouteDestination,\n\tToRouteSyncArgs,\n\tToViewPattern,\n} from \"./types\";\nimport {\n\tcreate_typed_navigate,\n\tcreate_typed_prefetch,\n\tcreate_typed_to_href,\n} from \"./url.ts\";\n\nexport type DecomposedState = {\n\t// Always a new reference\n\tentries: RouteRenderEntry[];\n\terror: RouteErrorState | null;\n\n\t// Stable per channel\n\tloaders_data: unknown[];\n\tclient_loaders_data: unknown[];\n\tmatched_patterns: string[];\n\timport_urls: string[];\n\tentry_keys: string[];\n\tparams: Record<string, string>;\n\tsplat_values: string[];\n\tclient_build_id: string;\n\thistory_state: unknown;\n};\n\nexport type DecomposedCommit = {\n\troute?: RouteState;\n\troute_reason?: RouteUpdateReason;\n\tscroll_intent?: ScrollIntent;\n\tstate?: DecomposedState;\n\twork?: WorkState;\n};\n\nexport type DecomposedCommitFn = (commit: DecomposedCommit) => void;\n\ntype LinkAttributeCandidate = {\n\turl: URL;\n\tmatched_patterns: string[];\n};\n\n// __TODO why is this generic called \"App\"? Shouldn't it be \"Component\" or something?\nexport type AdapterRenderArgs<App> = {\n\tRootOutlet: App;\n\trootEl: HTMLElement;\n};\n\nexport type AdapterClientOptions<App> = Omit<CoreClientOptions, \"render\"> & {\n\trender?: (args: AdapterRenderArgs<App>) => void | Promise<void>;\n};\n\ntype AdapterBase<A extends AppConfig> = {\n\tcore: ClientCore;\n\n\tnav_fns: LinkNavFns;\n\n\tpassthrough: Pick<\n\t\tClientCore,\n\t\t\"revalidate\" | \"getRouteState\" | \"getWorkState\" | \"workIndicator\"\n\t> & {\n\t\tnavigate: <P extends ToViewPattern<A>>(\n\t\t\targs: ToNavigateArgs<A, P>,\n\t\t) => Promise<{ didNavigate: boolean }>;\n\n\t\tprefetch: <P extends ToViewPattern<A>>(\n\t\t\ttarget: ToNavigationTarget<A, P>,\n\t\t) => void;\n\n\t\tcancelPrefetch: <P extends ToViewPattern<A>>(\n\t\t\ttarget: ToNavigationTarget<A, P>,\n\t\t) => void;\n\n\t\ttoHref: <P extends ToViewPattern<A>>(\n\t\t\tdestination: ToRouteDestination<A, P>,\n\t\t) => string;\n\n\t\tapiClient: ToAPIClient<A>;\n\t};\n};\n\nexport function create_adapter_base<A extends AppConfig>(\n\tapp_config: A,\n\ton_commit: DecomposedCommitFn,\n\tapi_decorator?: ToAPIDecorator<A>,\n): Result<AdapterBase<A>> {\n\tconst attribute_registry_res = createPatternRegistry({\n\t\tdynamicParamPrefixRune: \":\",\n\t\tsplatSegmentRune: \"*\",\n\t\texplicitIndexSegment: \"_index\",\n\t});\n\tif (!attribute_registry_res.ok) {\n\t\treturn R.err(\n\t\t\t`Failed to create link attribute registry: ${attribute_registry_res.err}`,\n\t\t);\n\t}\n\tconst attribute_registry = attribute_registry_res.val;\n\n\tlet prev: DecomposedState = {\n\t\tentries: [],\n\t\terror: null,\n\t\tloaders_data: [],\n\t\tclient_loaders_data: [],\n\t\tmatched_patterns: [],\n\t\timport_urls: [],\n\t\tentry_keys: [],\n\t\tparams: {},\n\t\tsplat_values: [],\n\t\tclient_build_id: \"\",\n\t\thistory_state: undefined,\n\t};\n\n\tfunction decomposed_commit(client_commit: ClientCommit): void {\n\t\tconst adapter_commit: DecomposedCommit = {};\n\t\tconst route_render = client_commit.route_render;\n\t\tif (route_render) {\n\t\t\tadapter_commit.state = decompose_route_render_state(\n\t\t\t\troute_render.state,\n\t\t\t);\n\t\t\tadapter_commit.scroll_intent = route_render.scroll_intent;\n\t\t}\n\t\tif (client_commit.route_update) {\n\t\t\tadapter_commit.route = client_commit.route_update.route;\n\t\t\tadapter_commit.route_reason = client_commit.route_update.reason;\n\t\t}\n\t\tif (client_commit.work) {\n\t\t\tadapter_commit.work = client_commit.work;\n\t\t}\n\t\ton_commit(adapter_commit);\n\t}\n\n\tfunction decompose_route_render_state(\n\t\troute_state: RouteRenderState,\n\t): DecomposedState {\n\t\tfor (const entry of route_state.entries) {\n\t\t\tregister_link_pattern(entry.pattern);\n\t\t}\n\n\t\tconst next: DecomposedState = {\n\t\t\tentries: route_state.entries,\n\t\t\terror: route_state.error,\n\t\t\tloaders_data: stable(\n\t\t\t\tprev.loaders_data,\n\t\t\t\troute_state.entries.map((e) => {\n\t\t\t\t\treturn e.loader_data;\n\t\t\t\t}),\n\t\t\t),\n\t\t\tclient_loaders_data: stable(\n\t\t\t\tprev.client_loaders_data,\n\t\t\t\troute_state.entries.map((e) => {\n\t\t\t\t\treturn e.client_loader_data;\n\t\t\t\t}),\n\t\t\t),\n\t\t\tmatched_patterns: stable(\n\t\t\t\tprev.matched_patterns,\n\t\t\t\troute_state.entries.map((e) => {\n\t\t\t\t\treturn e.pattern;\n\t\t\t\t}),\n\t\t\t),\n\t\t\timport_urls: stable(\n\t\t\t\tprev.import_urls,\n\t\t\t\troute_state.entries.map((e) => {\n\t\t\t\t\treturn e.module_url;\n\t\t\t\t}),\n\t\t\t),\n\t\t\tentry_keys: stable(\n\t\t\t\tprev.entry_keys,\n\t\t\t\troute_state.entries.map((e) => {\n\t\t\t\t\treturn get_entry_key(e);\n\t\t\t\t}),\n\t\t\t),\n\t\t\tparams: stable(prev.params, route_state.params),\n\t\t\tsplat_values: stable(prev.splat_values, route_state.splat_values),\n\t\t\tclient_build_id: stable(\n\t\t\t\tprev.client_build_id,\n\t\t\t\troute_state.client_build_id,\n\t\t\t),\n\t\t\thistory_state: stable(\n\t\t\t\tprev.history_state,\n\t\t\t\troute_state.history_state,\n\t\t\t),\n\t\t};\n\n\t\tprev = next;\n\t\treturn next;\n\t}\n\n\tconst core_res = create_client_core(app_config, decomposed_commit);\n\tif (!core_res.ok) {\n\t\treturn R.err(core_res.err);\n\t}\n\tconst core = core_res.val;\n\n\tconst nav_fns: LinkNavFns = {\n\t\tnavigate: (args) => {\n\t\t\treturn core.navigate(args.href, {\n\t\t\t\treplace: args.replace,\n\t\t\t\tscrollToTop: args.scrollToTop,\n\t\t\t\tstate: args.state,\n\t\t\t});\n\t\t},\n\t\tstart_prefetch: core.start_prefetch,\n\t\tstop_prefetch: core.stop_prefetch,\n\t\tsave_current_scroll: core.save_current_scroll,\n\t\tregister_link_pattern,\n\t\tget_link_attribute_state,\n\t};\n\n\tconst navigate = create_typed_navigate<A>(core.navigate);\n\tconst prefetch = create_typed_prefetch<A>(core.start_prefetch);\n\tconst cancel_prefetch = create_typed_prefetch<A>(core.stop_prefetch);\n\tconst to_href = create_typed_to_href<A>();\n\n\tconst api_client = create_typed_api_client<A>(\n\t\tapp_config.apiMountRoot,\n\t\tcore.submit_inner,\n\t\tapi_decorator,\n\t);\n\n\treturn R.ok({\n\t\tcore,\n\t\tnav_fns,\n\t\tpassthrough: {\n\t\t\tnavigate,\n\t\t\tprefetch,\n\t\t\tcancelPrefetch: cancel_prefetch,\n\t\t\ttoHref: to_href,\n\t\t\trevalidate: core.revalidate,\n\t\t\tgetRouteState: core.getRouteState,\n\t\t\tgetWorkState: core.getWorkState,\n\t\t\tworkIndicator: core.workIndicator,\n\t\t\tapiClient: api_client,\n\t\t},\n\t});\n\n\tfunction register_link_pattern(pattern: string): void {\n\t\tregisterPattern(attribute_registry, pattern);\n\t}\n\n\tfunction href_to_link_candidate(href: string): LinkAttributeCandidate {\n\t\tconst url = new URL(href, window.location.href);\n\t\tconst match = findNestedMatches(attribute_registry, url.pathname);\n\t\treturn {\n\t\t\turl,\n\t\t\tmatched_patterns:\n\t\t\t\tmatch?.matches.map((m) => {\n\t\t\t\t\treturn m.registeredPattern.originalPattern;\n\t\t\t\t}) ?? [],\n\t\t};\n\t}\n\n\tfunction exact_link_match(\n\t\ttarget: LinkAttributeCandidate,\n\t\tcandidate: LinkAttributeCandidate,\n\t\tmatch_rules: LinkPropsBase[\"attributeMatchRules\"],\n\t): boolean {\n\t\treturn (\n\t\t\ttarget.url.pathname === candidate.url.pathname &&\n\t\t\t(target.matched_patterns.length === 0 ||\n\t\t\t\tcandidate.matched_patterns.length === 0 ||\n\t\t\t\tjsonDeepEquals(\n\t\t\t\t\ttarget.matched_patterns,\n\t\t\t\t\tcandidate.matched_patterns,\n\t\t\t\t)) &&\n\t\t\t(match_rules?.includeSearch !== true ||\n\t\t\t\ttarget.url.search === candidate.url.search) &&\n\t\t\t(match_rules?.includeHash !== true ||\n\t\t\t\ttarget.url.hash === candidate.url.hash)\n\t\t);\n\t}\n\n\tfunction ancestor_link_match(\n\t\ttarget: LinkAttributeCandidate,\n\t\tcandidate: LinkAttributeCandidate,\n\t): boolean {\n\t\tconst target_path =\n\t\t\ttarget.url.pathname === \"/\" ? \"/\" : `${target.url.pathname}/`;\n\t\treturn (\n\t\t\ttarget.matched_patterns.length > 0 &&\n\t\t\tcandidate.matched_patterns.length >\n\t\t\t\ttarget.matched_patterns.length &&\n\t\t\t(target_path === \"/\" ||\n\t\t\t\tcandidate.url.pathname.startsWith(target_path)) &&\n\t\t\ttarget.matched_patterns.every((pattern, i) => {\n\t\t\t\treturn candidate.matched_patterns[i] === pattern;\n\t\t\t})\n\t\t);\n\t}\n\n\tfunction get_link_attribute_state(\n\t\thref: string,\n\t\tmatch_rules: LinkPropsBase[\"attributeMatchRules\"],\n\t\troute_state: LinkRouteState | null,\n\t\twork_state: LinkWorkState,\n\t) {\n\t\tif (match_rules?.skip === true || !route_state) {\n\t\t\treturn {\n\t\t\t\tactive_exact: false,\n\t\t\t\tactive_ancestor: false,\n\t\t\t\tpending_exact: false,\n\t\t\t\tpending_ancestor: false,\n\t\t\t};\n\t\t}\n\n\t\tconst target = href_to_link_candidate(href);\n\t\tconst route_url = new URL(route_state.href, window.location.href);\n\t\tconst route = {\n\t\t\turl: route_url,\n\t\t\tmatched_patterns: route_state.matchedPatterns,\n\t\t};\n\t\tconst pending = work_state.navigationHref\n\t\t\t? href_to_link_candidate(work_state.navigationHref)\n\t\t\t: null;\n\n\t\treturn {\n\t\t\tactive_exact: exact_link_match(target, route, match_rules),\n\t\t\tactive_ancestor: ancestor_link_match(target, route),\n\t\t\tpending_exact: pending\n\t\t\t\t? exact_link_match(target, pending, match_rules)\n\t\t\t\t: false,\n\t\t\tpending_ancestor: pending\n\t\t\t\t? ancestor_link_match(target, pending)\n\t\t\t\t: false,\n\t\t};\n\t}\n}\n\nfunction stable<T>(prev: T, next: T): T {\n\treturn jsonDeepEquals(prev, next) ? prev : next;\n}\n\ntype HookReturn<\n\tT,\n\tMode extends \"value\" | \"accessor\" | \"signal\",\n> = Mode extends \"accessor\"\n\t? () => T\n\t: Mode extends \"signal\"\n\t\t? ReadonlySignal<T>\n\t\t: T;\n\ntype StateSelector<State, Selected> = (state: State) => Selected;\n\nexport type VormaClient<\n\tA extends AppConfig,\n\tElement,\n\tAnchorProps extends object,\n\tHookReturnMode extends \"value\" | \"accessor\" | \"signal\" = \"value\",\n> = AdapterBase<A>[\"passthrough\"] & {\n\tboot: () => Promise<Result<void>>;\n\n\tdefineView: <P extends ToViewPattern<A>, T = any>(\n\t\tinput: ToDefineViewArgs<A, P, T, Element>,\n\t) => ViewDefinition;\n\n\tRootOutlet: (\n\t\tprops: { idx?: number } & Record<string, unknown>,\n\t) => Element | null;\n\n\tLink: <P extends ToViewPattern<A>>(\n\t\tprops: Omit<AnchorProps, \"href\"> & ToLinkProps<A, P>,\n\t) => Element;\n\n\tuseRouteSync: <P extends ToViewPattern<A>>(\n\t\targs: ToRouteSyncArgs<A, P>,\n\t) => void;\n\n\tuseRouteState: {\n\t\t(): HookReturn<RouteState, HookReturnMode>;\n\t\t<T>(\n\t\t\tselector: StateSelector<RouteState, T>,\n\t\t): HookReturn<T, HookReturnMode>;\n\t};\n\n\tuseWorkState: {\n\t\t(): HookReturn<WorkState, HookReturnMode>;\n\t\t<T>(\n\t\t\tselector: StateSelector<WorkState, T>,\n\t\t): HookReturn<T, HookReturnMode>;\n\t};\n\n\tuseLoaderData: <P extends ToViewPattern<A>>(\n\t\targs: ToRouteComponentProps<A, P>,\n\t) => HookReturn<ToLoaderOutput<A, P>, HookReturnMode>;\n\n\tusePatternLoaderData: <P extends ToViewPattern<A>>(\n\t\tpattern: P,\n\t) => HookReturn<ToLoaderOutput<A, P> | undefined, HookReturnMode>;\n\n\tuseClientLoaderData: <P extends ToViewPattern<A>, T>(\n\t\targs: ToRouteComponentProps<A, P, T>,\n\t) => HookReturn<T, HookReturnMode>;\n\n\tusePatternClientLoaderData: <T>(\n\t\tpattern: ToViewPattern<A>,\n\t) => HookReturn<T | undefined, HookReturnMode>;\n};\n"],"mappings":";;;;;;AAAA,MAAa,iBAAiB;AAC9B,MAAa,iBAAiB;AAC9B,MAAa,kBAAkB;AAE/B,MAAa,oBAAoB;AACjC,MAAa,4BAA4B;AAEzC,MAAa,yBAAyB;AAGtC,MAAa,qBAAqB;AAClC,MAAa,4BAA4B;AACzC,MAAa,mBAAmB;AAEhC,MAAa,oBAAoB;AACjC,MAAa,2BAA2B;AAExC,MAAa,4BAA4B;AAEzC,MAAa,yBAAyB;AACt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
+
{"version":3,"file":"_index.js","names":[],"sources":["../../../vorma/core/constants.ts","../../../vorma/core/url.ts","../../../vorma/core/api_client.ts","../../../vorma/core/css.ts","../../../vorma/core/head.ts","../../../vorma/core/modules.ts","../../../vorma/core/create_client_core.ts","../../../vorma/core/make_link_props.ts","../../../vorma/core/resolve_outlet_slot.ts","../../../vorma/core/ui_adapter_core.ts"],"sourcesContent":["export const VORMA_JSON_KEY = \"vorma-json\";\nexport const DATA_SCRIPT_ID = \"vorma-data-json\";\nexport const BUILD_ID_HEADER = \"X-Vorma-Client-Build-Id\";\nexport const X_VORMA_BUILD_SKEW = \"X-Vorma-Build-Skew\";\nexport const X_CLIENT_REDIRECT = \"X-Client-Redirect\";\nexport const X_ACCEPTS_CLIENT_REDIRECT = \"X-Accepts-Client-Redirect\";\n\nexport const VERCEL_X_DEPLOYMENT_ID = \"x-deployment-id\";\nexport const VERCEL_DPL_QUERY_PARAM_KEY = \"dpl\";\n\nexport const SCROLL_STORAGE_KEY = \"vorma-scroll-state\";\nexport const SCROLL_STORAGE_RELOAD_KEY = \"vorma-scroll-state-reload\";\nexport const VORMA_ROOT_EL_ID = \"vorma-root\";\n\nexport const HISTORY_KEY_FIELD = \"vorma-history-key\";\nexport const HISTORY_USER_STATE_FIELD = \"vorma-user-state\";\n\nexport const API_IDENTITY_ARRAY_PREFIX = \"vorma-api\";\n\nexport const LINK_ACTIVE_EXACT_ATTR = \"data-vorma-active-exact\";\nexport const LINK_ACTIVE_ANCESTOR_ATTR = \"data-vorma-active-ancestor\";\nexport const LINK_PENDING_EXACT_ATTR = \"data-vorma-pending-exact\";\nexport const LINK_PENDING_ANCESTOR_ATTR = \"data-vorma-pending-ancestor\";\n\nexport const CSS_BUNDLE_ATTR = \"data-vorma-css-bundle\";\nexport const CSS_PRELOAD_ATTR = \"data-vorma-css-preload\";\nexport const CSS_PRELOAD_SETTLED_ATTR = \"data-vorma-css-settled\";\n","import { serializeToSearchParams } from \"vorma/kit/json\";\nimport type {\n\tAppConfig,\n\tToNavigateArgs,\n\tToNavigationTarget,\n\tToRouteDestination,\n\tToViewPattern,\n} from \"./types.ts\";\n\nconst DYNAMIC_RUNE = \":\";\nconst SPLAT_RUNE = \"*\";\nconst INDEX_SEGMENT = \"_index\";\n\nfunction strip_trailing_slash(path: string): string {\n\tif (path === \"/\") {\n\t\treturn path;\n\t}\n\treturn path.endsWith(\"/\") ? path.slice(0, -1) : path;\n}\n\nfunction resolve_pattern_path(\n\tpattern: string,\n\tparams?: Record<string, string>,\n\tsplat_values?: string[],\n): string {\n\tconst p = params ?? {};\n\tconst segments = pattern.split(\"/\").filter((s) => {\n\t\treturn s.length > 0;\n\t});\n\tconst splat_encoded = (splat_values ?? [])\n\t\t.map((v) => {\n\t\t\treturn encodeURIComponent(v);\n\t\t})\n\t\t.join(\"/\");\n\n\tconst path_segments = segments.flatMap((seg) => {\n\t\tif (seg === SPLAT_RUNE) {\n\t\t\treturn splat_encoded.split(\"/\").filter((s) => {\n\t\t\t\treturn s.length > 0;\n\t\t\t});\n\t\t}\n\t\tif (seg.startsWith(DYNAMIC_RUNE)) {\n\t\t\treturn [\n\t\t\t\tencodeURIComponent(p[seg.slice(DYNAMIC_RUNE.length)] as string),\n\t\t\t];\n\t\t}\n\t\treturn [seg];\n\t});\n\n\tconst result = \"/\" + path_segments.join(\"/\");\n\treturn strip_trailing_slash(result.length === 0 ? \"/\" : result);\n}\n\nexport function resolve_path(\n\ttype: \"loader\" | \"action\",\n\tpattern: string,\n\tparams?: Record<string, string>,\n\tsplat_values?: string[],\n): string {\n\tlet path = resolve_pattern_path(pattern, params, splat_values);\n\n\tif (type === \"loader\") {\n\t\tconst suffix = `/${INDEX_SEGMENT}`;\n\t\tif (path.endsWith(suffix)) {\n\t\t\tpath = path.slice(0, -suffix.length) || \"/\";\n\t\t}\n\t}\n\n\treturn path;\n}\n\nexport function to_typed_href(\n\tpattern: string,\n\tparams?: Record<string, string>,\n\tsplat_values?: string[],\n\tsearch?: unknown,\n\thash?: string,\n): string {\n\tconst base = resolve_path(\"loader\", pattern, params, splat_values);\n\tconst url = new URL(base, window.location.origin);\n\tif (search !== undefined) {\n\t\turl.search = serializeToSearchParams(search).toString();\n\t}\n\tif (hash !== undefined) {\n\t\turl.hash = hash;\n\t}\n\treturn url.href;\n}\n\nexport function build_action_url(\n\tactions_mount_root: string,\n\tpattern: string,\n\tparams?: Record<string, string>,\n\tsplat_values?: string[],\n\tinput?: unknown,\n): URL {\n\tconst pathname = resolve_path(\"action\", pattern, params, splat_values);\n\tconst full =\n\t\tstrip_trailing_slash(actions_mount_root) +\n\t\t(pathname === \"/\" ? \"\" : pathname);\n\tconst url = new URL(full, window.location.origin);\n\tif (input && typeof input === \"object\") {\n\t\turl.search = serializeToSearchParams(input).toString();\n\t}\n\treturn url;\n}\n\nexport function create_typed_to_href<A extends AppConfig>() {\n\treturn <P extends ToViewPattern<A>>(\n\t\tdestination: ToRouteDestination<A, P>,\n\t): string => {\n\t\tconst d = destination as any;\n\t\treturn to_typed_href(\n\t\t\td.pattern,\n\t\t\td.params,\n\t\t\td.splatValues,\n\t\t\td.search,\n\t\t\td.hash,\n\t\t);\n\t};\n}\n\nexport function resolve_body(input: unknown): BodyInit | null | undefined {\n\tif (\n\t\tinput === undefined ||\n\t\tinput === null ||\n\t\ttypeof input === \"string\" ||\n\t\tinput instanceof ReadableStream ||\n\t\tinput instanceof FormData ||\n\t\tinput instanceof URLSearchParams ||\n\t\tinput instanceof Blob ||\n\t\tinput instanceof ArrayBuffer\n\t) {\n\t\treturn input;\n\t}\n\tif (ArrayBuffer.isView(input)) {\n\t\treturn input as ArrayBufferView<ArrayBuffer>;\n\t}\n\treturn JSON.stringify(input);\n}\n\nexport function create_typed_navigate<A extends AppConfig>(\n\tnavigate_fn: (\n\t\thref: string | URL,\n\t\toptions?: {\n\t\t\treplace?: boolean;\n\t\t\tscrollToTop?: boolean;\n\t\t\tstate?: unknown;\n\t\t\tskipWorkIndicator?: boolean;\n\t\t},\n\t) => Promise<{ didNavigate: boolean }>,\n) {\n\tconst to_href = create_typed_to_href<A>();\n\treturn async <P extends ToViewPattern<A>>(\n\t\targs: ToNavigateArgs<A, P>,\n\t): Promise<{ didNavigate: boolean }> => {\n\t\tconst href = args.href ?? to_href(args as any);\n\t\treturn navigate_fn(href, {\n\t\t\treplace: args.replace,\n\t\t\tscrollToTop: args.scrollToTop,\n\t\t\tstate: args.state,\n\t\t\tskipWorkIndicator: args.skipWorkIndicator,\n\t\t});\n\t};\n}\n\nexport function create_typed_prefetch<A extends AppConfig>(\n\tprefetch_fn: (href: string) => void,\n) {\n\tconst to_href = create_typed_to_href<A>();\n\treturn <P extends ToViewPattern<A>>(\n\t\ttarget: ToNavigationTarget<A, P>,\n\t): void => {\n\t\tprefetch_fn(target.href ?? to_href(target as any));\n\t};\n}\n","import { jsonStringifyStable } from \"vorma/kit/json\";\nimport { API_IDENTITY_ARRAY_PREFIX } from \"./constants.ts\";\nimport type {\n\tAPIRouteKind,\n\tAppConfig,\n\tMutationResult,\n\tQueryResult,\n\tToAPIClient,\n\tToAPIDecorator,\n\tToAPIDecoratorContext,\n\tToMutationArgs,\n\tToQueryArgs,\n\t__APIClientOutput,\n} from \"./types.ts\";\nimport { build_action_url, resolve_body } from \"./url.ts\";\n\ntype SubmitFn = <T>(\n\turl: string | URL,\n\trequestInit?: RequestInit,\n\toptions?: {\n\t\tapiRouteKind?: APIRouteKind;\n\t\tdedupeKey?: string;\n\t\trevalidate?: boolean;\n\t\tskipWorkIndicator?: boolean;\n\t},\n) => Promise<QueryResult<T> | MutationResult<T>>;\n\nfunction normalize_api_method(raw_method: string | undefined): string {\n\treturn (raw_method ?? \"GET\").trim().toUpperCase();\n}\n\nfunction normalize_api_pattern(pattern: string): string {\n\treturn pattern.trim();\n}\n\nfunction stringify_identity_value(value: unknown): string {\n\tconst res = jsonStringifyStable(value);\n\tif (!res.ok) {\n\t\tthrow new Error(res.err);\n\t}\n\treturn res.val;\n}\n\nclass APIErrorBase<T = never> extends Error {\n\tresult: Extract<QueryResult<T> | MutationResult<T>, { success: false }>;\n\n\tconstructor(\n\t\tresult: Extract<QueryResult<T> | MutationResult<T>, { success: false }>,\n\t) {\n\t\tsuper(result.error);\n\t\tthis.result = result;\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\nexport class QueryError<T = never> extends APIErrorBase<T> {\n\tconstructor(result: Extract<QueryResult<T>, { success: false }>) {\n\t\tsuper(result);\n\t\tthis.name = \"QueryError\";\n\t}\n}\n\nexport class MutationError<T = never> extends APIErrorBase<T> {\n\tconstructor(result: Extract<MutationResult<T>, { success: false }>) {\n\t\tsuper(result);\n\t\tthis.name = \"MutationError\";\n\t}\n}\n\nexport function create_typed_api_client<A extends AppConfig>(\n\tactions_mount_root: string,\n\tsubmit_fn: SubmitFn,\n\tdecorator?: ToAPIDecorator<A>,\n): ToAPIClient<A> {\n\tasync function submit<Args extends ToQueryArgs<A> | ToMutationArgs<A>>(\n\t\targs: Args,\n\t\tapi_route_kind: APIRouteKind,\n\t): Promise<\n\t\t| QueryResult<__APIClientOutput<A, Args>>\n\t\t| MutationResult<__APIClientOutput<A, Args>>\n\t> {\n\t\tconst {\n\t\t\tdedupeKey,\n\t\t\tinput,\n\t\t\tmethod: raw_method,\n\t\t\tparams,\n\t\t\tpattern,\n\t\t\trevalidate,\n\t\t\tskipWorkIndicator,\n\t\t\tsplatValues,\n\t\t\t...request_init\n\t\t} = args as any;\n\t\tconst method = normalize_api_method(raw_method);\n\t\tconst api_pattern = normalize_api_pattern(pattern);\n\t\tconst is_get = method === \"GET\" || method === \"HEAD\";\n\t\tconst url = build_action_url(\n\t\t\tactions_mount_root,\n\t\t\tapi_pattern,\n\t\t\tparams,\n\t\t\tsplatValues,\n\t\t\tis_get ? input : undefined,\n\t\t);\n\t\tconst ctx = {\n\t\t\tinput,\n\t\t\tmethod,\n\t\t\tpattern: api_pattern,\n\t\t\trequestInit: request_init,\n\t\t} as ToAPIDecoratorContext<A>;\n\t\tconst decorated = decorator\n\t\t\t? ((await (decorator as any)(ctx)) ?? {})\n\t\t\t: {};\n\t\tconst init: RequestInit = { ...decorated, ...request_init };\n\t\tconst headers = new Headers(decorated.headers ?? undefined);\n\t\tnew Headers(request_init.headers ?? undefined).forEach((v, k) => {\n\t\t\theaders.set(k, v);\n\t\t});\n\t\tinit.headers = headers;\n\t\tinit.method = method;\n\t\tif (is_get) {\n\t\t\tdelete init.body;\n\t\t} else {\n\t\t\tinit.body = resolve_body(input);\n\t\t}\n\t\tconst options: {\n\t\t\tapiRouteKind?: APIRouteKind;\n\t\t\tdedupeKey?: string;\n\t\t\trevalidate?: boolean;\n\t\t\tskipWorkIndicator?: boolean;\n\t\t} = {\n\t\t\tapiRouteKind: api_route_kind,\n\t\t};\n\t\tif (dedupeKey !== undefined) {\n\t\t\toptions.dedupeKey = dedupeKey;\n\t\t}\n\t\tif (revalidate !== undefined) {\n\t\t\toptions.revalidate = revalidate;\n\t\t}\n\t\tif (skipWorkIndicator !== undefined) {\n\t\t\toptions.skipWorkIndicator = skipWorkIndicator;\n\t\t}\n\t\treturn submit_fn<__APIClientOutput<A, Args>>(url, init, options);\n\t}\n\n\treturn {\n\t\ttoIdentityArray: <Args extends ToQueryArgs<A> | ToMutationArgs<A>>(\n\t\t\targs: Args,\n\t\t): unknown[] => {\n\t\t\tconst {\n\t\t\t\tinput,\n\t\t\t\tmethod: raw_method,\n\t\t\t\tparams,\n\t\t\t\tpattern,\n\t\t\t\tsplatValues,\n\t\t\t} = args as any;\n\t\t\tconst method = normalize_api_method(raw_method);\n\t\t\tconst api_pattern = normalize_api_pattern(pattern);\n\t\t\treturn [\n\t\t\t\tAPI_IDENTITY_ARRAY_PREFIX,\n\t\t\t\tactions_mount_root,\n\t\t\t\tmethod,\n\t\t\t\tapi_pattern,\n\t\t\t\tstringify_identity_value(params ?? null),\n\t\t\t\tstringify_identity_value(splatValues ?? []),\n\t\t\t\tstringify_identity_value(input ?? null),\n\t\t\t];\n\t\t},\n\t\tmutate: <Args extends ToMutationArgs<A>>(\n\t\t\targs: Args,\n\t\t): Promise<MutationResult<__APIClientOutput<A, Args>>> => {\n\t\t\treturn submit(args, \"mutation\") as Promise<\n\t\t\t\tMutationResult<__APIClientOutput<A, Args>>\n\t\t\t>;\n\t\t},\n\t\tmutateOrThrow: async <Args extends ToMutationArgs<A>>(\n\t\t\targs: Args,\n\t\t): Promise<__APIClientOutput<A, Args>> => {\n\t\t\tconst result = (await submit(args, \"mutation\")) as MutationResult<\n\t\t\t\t__APIClientOutput<A, Args>\n\t\t\t>;\n\t\t\tif (!result.success) {\n\t\t\t\tthrow new MutationError(result);\n\t\t\t}\n\t\t\treturn result.data;\n\t\t},\n\t\tquery: <Args extends ToQueryArgs<A>>(\n\t\t\targs: Args,\n\t\t): Promise<QueryResult<__APIClientOutput<A, Args>>> => {\n\t\t\treturn submit(args, \"query\") as Promise<\n\t\t\t\tQueryResult<__APIClientOutput<A, Args>>\n\t\t\t>;\n\t\t},\n\t\tqueryOrThrow: async <Args extends ToQueryArgs<A>>(\n\t\t\targs: Args,\n\t\t): Promise<__APIClientOutput<A, Args>> => {\n\t\t\tconst result = (await submit(args, \"query\")) as QueryResult<\n\t\t\t\t__APIClientOutput<A, Args>\n\t\t\t>;\n\t\t\tif (!result.success) {\n\t\t\t\tthrow new QueryError(result);\n\t\t\t}\n\t\t\treturn result.data;\n\t\t},\n\t};\n}\n","import {\n\tCSS_BUNDLE_ATTR,\n\tCSS_PRELOAD_ATTR,\n\tCSS_PRELOAD_SETTLED_ATTR,\n} from \"./constants.ts\";\n\nexport function preload_css(bundles: string[]): void {\n\tfor (const path of new Set(bundles)) {\n\t\tif (find_css_bundle(path)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\tdocument.head.querySelector(`link[${CSS_PRELOAD_ATTR}=\"${path}\"]`)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst link = document.createElement(\"link\");\n\t\tlink.rel = \"preload\";\n\t\tlink.setAttribute(\"as\", \"style\");\n\t\tlink.setAttribute(CSS_PRELOAD_ATTR, path);\n\t\tlink.setAttribute(CSS_PRELOAD_SETTLED_ATTR, \"0\");\n\t\tconst mark = () => {\n\t\t\tlink.setAttribute(CSS_PRELOAD_SETTLED_ATTR, \"1\");\n\t\t};\n\t\tlink.addEventListener(\"load\", mark);\n\t\tlink.addEventListener(\"error\", mark);\n\t\tlink.href = path;\n\t\tdocument.head.appendChild(link);\n\t}\n}\n\nexport async function wait_for_css(\n\tbundles: string[],\n\tsignal: AbortSignal,\n): Promise<void> {\n\tconst promises: Promise<void>[] = [];\n\n\tfor (const path of new Set(bundles)) {\n\t\tconst node = document.head.querySelector<HTMLLinkElement>(\n\t\t\t`link[${CSS_PRELOAD_ATTR}=\"${path}\"]`,\n\t\t);\n\t\tif (!node || node.getAttribute(CSS_PRELOAD_SETTLED_ATTR) === \"1\") {\n\t\t\tcontinue;\n\t\t}\n\t\tpromises.push(\n\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\tif (signal.aborted) {\n\t\t\t\t\tresolve();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst cleanup = () => {\n\t\t\t\t\tnode.removeEventListener(\"load\", done);\n\t\t\t\t\tnode.removeEventListener(\"error\", done);\n\t\t\t\t\tsignal.removeEventListener(\"abort\", on_abort);\n\t\t\t\t};\n\t\t\t\tconst done = () => {\n\t\t\t\t\tnode.setAttribute(CSS_PRELOAD_SETTLED_ATTR, \"1\");\n\t\t\t\t\tcleanup();\n\t\t\t\t\tresolve();\n\t\t\t\t};\n\t\t\t\tconst on_abort = () => {\n\t\t\t\t\tcleanup();\n\t\t\t\t\tresolve();\n\t\t\t\t};\n\t\t\t\tnode.addEventListener(\"load\", done, { once: true });\n\t\t\t\tnode.addEventListener(\"error\", done, { once: true });\n\t\t\t\tsignal.addEventListener(\"abort\", on_abort, { once: true });\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (promises.length > 0) {\n\t\tawait Promise.all(promises);\n\t}\n}\n\nexport function apply_css_bundles(bundles: string[]): void {\n\tfor (const path of new Set(bundles)) {\n\t\tif (find_css_bundle(path)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst link = document.createElement(\"link\");\n\t\tlink.rel = \"stylesheet\";\n\t\tlink.setAttribute(CSS_BUNDLE_ATTR, path);\n\t\tlink.href = path;\n\t\tdocument.head.appendChild(link);\n\t}\n}\n\nfunction find_css_bundle(path: string): HTMLLinkElement | null {\n\treturn document.head.querySelector<HTMLLinkElement>(\n\t\t`link[${CSS_BUNDLE_ATTR}=\"${path}\"]`,\n\t);\n}\n","import { R, type Result } from \"vorma/kit/result\";\n\nexport type HeadEl = {\n\ttag: string;\n\tattributesKnownSafe: Record<string, string>;\n\tbooleanAttributes?: string[] | null;\n\tdangerousInnerHTML?: string;\n};\n\ntype HeadSection = \"meta\" | \"rest\";\n\nexport function apply_head_and_title(\n\ttitle: string | undefined,\n\tmeta_els: HeadEl[],\n\trest_els: HeadEl[],\n): Result<void> {\n\tif (title !== undefined) {\n\t\tif (title !== \"\" || document.head.querySelector(\"title\")) {\n\t\t\tdocument.title = title;\n\t\t}\n\t}\n\tconst meta_res = reconcile_section(\"meta\", meta_els);\n\tif (!meta_res.ok) {\n\t\treturn R.err(meta_res.err);\n\t}\n\tconst res_res = reconcile_section(\"rest\", rest_els);\n\tif (!res_res.ok) {\n\t\treturn R.err(res_res.err);\n\t}\n\n\treturn R.ok(undefined);\n}\n\nfunction reconcile_section(section: HeadSection, els: HeadEl[]): Result<void> {\n\tconst boundary_res = find_boundary_comments(section);\n\tif (!boundary_res.ok) {\n\t\treturn R.err(boundary_res.err);\n\t}\n\tconst { start, end } = boundary_res.val;\n\tif (!start || !end || !end.parentNode) {\n\t\treturn R.err(\n\t\t\t`Invalid head section boundaries for section \"${section}\"`,\n\t\t);\n\t}\n\tconst parent = end.parentNode;\n\n\t// Collect current elements between markers\n\tconst current_elements: Element[] = [];\n\tlet node: Node | null = start.nextSibling;\n\twhile (node && node !== end) {\n\t\tif (node.nodeType === Node.ELEMENT_NODE) {\n\t\t\tcurrent_elements.push(node as Element);\n\t\t}\n\t\tnode = node.nextSibling;\n\t}\n\n\t// Build new elements from blocks\n\tconst new_elements: Element[] = [];\n\tconst new_element_fingerprints = new Map<string, Element>();\n\n\tfor (const block of els) {\n\t\tif (!block.tag) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst el = document.createElement(block.tag);\n\t\tif (block.attributesKnownSafe) {\n\t\t\tfor (const [key, value] of Object.entries(\n\t\t\t\tblock.attributesKnownSafe,\n\t\t\t)) {\n\t\t\t\tel.setAttribute(key, value);\n\t\t\t}\n\t\t}\n\t\tif (block.booleanAttributes) {\n\t\t\tfor (const key of block.booleanAttributes) {\n\t\t\t\tel.setAttribute(key, \"\");\n\t\t\t}\n\t\t}\n\t\tif (block.dangerousInnerHTML) {\n\t\t\tel.innerHTML = block.dangerousInnerHTML;\n\t\t}\n\n\t\tconst fp = fingerprint_element(el);\n\n\t\t// Deduplicate: if a later block has the same fingerprint,\n\t\t// it replaces the earlier one.\n\t\tif (new_element_fingerprints.has(fp)) {\n\t\t\tconst prev = new_element_fingerprints.get(fp)!;\n\t\t\tconst idx = new_elements.indexOf(prev);\n\t\t\tif (idx > -1) {\n\t\t\t\tnew_elements.splice(idx, 1);\n\t\t\t}\n\t\t}\n\t\tnew_elements.push(el);\n\t\tnew_element_fingerprints.set(fp, el);\n\t}\n\n\t// Build map of current elements by fingerprint\n\tconst current_by_fp = new Map<string, Element[]>();\n\tfor (const el of current_elements) {\n\t\tconst fp = fingerprint_element(el);\n\t\tconst list = current_by_fp.get(fp);\n\t\tif (list) {\n\t\t\tlist.push(el);\n\t\t} else {\n\t\t\tcurrent_by_fp.set(fp, [el]);\n\t\t}\n\t}\n\n\t// Match new elements to existing DOM elements by exact fingerprint\n\tconst final_elements: Element[] = [];\n\tconst used = new Set<Element>();\n\n\tfor (const new_el of new_elements) {\n\t\tconst fp = fingerprint_element(new_el);\n\t\tconst candidates = current_by_fp.get(fp) ?? [];\n\t\tconst matched = candidates.find((el) => {\n\t\t\treturn !used.has(el);\n\t\t});\n\n\t\tif (matched) {\n\t\t\tused.add(matched);\n\t\t\tfinal_elements.push(matched);\n\t\t} else {\n\t\t\tfinal_elements.push(new_el);\n\t\t}\n\t}\n\n\t// Remove elements that are no longer needed\n\tconst remaining = new Set(current_elements);\n\tfor (const el of current_elements) {\n\t\tif (!used.has(el)) {\n\t\t\tparent.removeChild(el);\n\t\t\tremaining.delete(el);\n\t\t}\n\t}\n\n\t// Remove stray text/comment nodes between markers\n\tnode = start.nextSibling;\n\twhile (node && node !== end) {\n\t\tconst next = node.nextSibling;\n\t\tif (node.nodeType !== Node.ELEMENT_NODE) {\n\t\t\tparent.removeChild(node);\n\t\t}\n\t\tnode = next;\n\t}\n\n\t// Position elements in correct order with minimal DOM operations\n\tlet last_processed: Element | null = null;\n\n\tfor (const element of final_elements) {\n\t\tconst is_existing = used.has(element);\n\n\t\tif (is_existing) {\n\t\t\tconst expected_next: Element | null = last_processed\n\t\t\t\t? last_processed.nextElementSibling\n\t\t\t\t: start.nextElementSibling;\n\n\t\t\tif (expected_next !== element) {\n\t\t\t\tparent.insertBefore(element, (expected_next as Node) ?? end);\n\t\t\t}\n\t\t\tremaining.delete(element);\n\t\t} else {\n\t\t\tconst insert_before = last_processed\n\t\t\t\t? last_processed.nextSibling\n\t\t\t\t: start.nextSibling;\n\t\t\tparent.insertBefore(element, insert_before ?? end);\n\t\t}\n\n\t\tlast_processed = element;\n\t}\n\n\treturn R.ok(undefined);\n}\n\nfunction find_boundary_comments(section: HeadSection): Result<{\n\tstart: Comment | undefined;\n\tend: Comment | undefined;\n}> {\n\tconst start_text = `vorma-${section}-start`;\n\tconst end_text = `vorma-${section}-end`;\n\tlet start: Comment | undefined;\n\tfor (const node of Array.from(document.head.childNodes)) {\n\t\tif (node.nodeType !== Node.COMMENT_NODE) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst val = (node as Comment).nodeValue?.trim();\n\t\tif (val === start_text) {\n\t\t\tstart = node as Comment;\n\t\t} else if (val === end_text && start) {\n\t\t\treturn R.ok({ start, end: node as Comment });\n\t\t}\n\t}\n\treturn R.err(\n\t\t`Could not find head boundary comments for section \"${section}\"`,\n\t);\n}\n\nfunction fingerprint_element(element: Element): string {\n\tconst attrs: string[] = [];\n\tfor (let i = 0; i < element.attributes.length; i++) {\n\t\tconst attr = element.attributes[i]!;\n\t\tconst value =\n\t\t\telement.hasAttribute(attr.name) && attr.value === \"\"\n\t\t\t\t? \"\"\n\t\t\t\t: attr.value;\n\t\tattrs.push(`${attr.name}=\"${value}\"`);\n\t}\n\tattrs.sort();\n\treturn `${element.tagName.toUpperCase()}|${attrs.join(\",\")}|${(element.innerHTML || \"\").trim()}`;\n}\n","/// <reference types=\"vite/client\" />\n\nexport function preload_modules(deps: string[]): void {\n\tif (import.meta.env.DEV) {\n\t\treturn;\n\t}\n\tfor (const dep of new Set(deps)) {\n\t\tif (\n\t\t\tdocument.head.querySelector(\n\t\t\t\t`link[rel=\"modulepreload\"][href=\"${dep}\"]`,\n\t\t\t)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst link = document.createElement(\"link\");\n\t\tlink.rel = \"modulepreload\";\n\t\tlink.href = dep;\n\t\tdocument.head.appendChild(link);\n\t}\n}\n","/// <reference types=\"vite/client\" />\n\nimport { jsonDeepEquals, parseSearchParams } from \"vorma/kit/json\";\nimport { addOnWindowFocusListener } from \"vorma/kit/listeners\";\nimport {\n\tcreatePatternRegistry,\n\tfindNestedMatches,\n\tregisterPattern,\n} from \"vorma/kit/matcher\";\nimport { R, type Result } from \"vorma/kit/result\";\nimport {\n\tBUILD_ID_HEADER,\n\tDATA_SCRIPT_ID,\n\tHISTORY_KEY_FIELD,\n\tHISTORY_USER_STATE_FIELD,\n\tSCROLL_STORAGE_KEY,\n\tSCROLL_STORAGE_RELOAD_KEY,\n\tVERCEL_DPL_QUERY_PARAM_KEY,\n\tVERCEL_X_DEPLOYMENT_ID,\n\tVORMA_JSON_KEY,\n\tVORMA_ROOT_EL_ID,\n\tX_ACCEPTS_CLIENT_REDIRECT,\n\tX_CLIENT_REDIRECT,\n\tX_VORMA_BUILD_SKEW,\n} from \"./constants.ts\";\nimport { apply_css_bundles, preload_css, wait_for_css } from \"./css.ts\";\nimport { apply_head_and_title, type HeadEl } from \"./head.ts\";\nimport { preload_modules } from \"./modules.ts\";\nimport type {\n\tAPIRouteKind,\n\tAppConfig,\n\tBeforeRouteCommitFn,\n\tBeforeRouteYieldFn,\n\tRevalidationResult,\n\tRouteErrorState,\n\tRouteState,\n\tRouteUpdateReason,\n} from \"./types.ts\";\n\n/////////////////////////////////////////////////////////////////////\n/////// Public Types\n/////////////////////////////////////////////////////////////////////\n\nexport type ScrollState = { x: number; y: number } | { hash: string };\n\nexport type ScrollIntent = {\n\tscroll: ScrollState;\n\ttarget_route_id: string;\n};\n\nexport type RouteRenderEntry = {\n\tpattern: string;\n\tinput: unknown;\n\tmodule_url: string;\n\tmodule: Record<string, unknown>;\n\tloader_data: unknown;\n\tclient_loader_data: unknown;\n};\n\nexport type RouteRenderState = {\n\tentries: RouteRenderEntry[];\n\terror: RouteErrorState | null;\n\tparams: Record<string, string>;\n\tsplat_values: string[];\n\tclient_build_id: string;\n\thistory_state: unknown;\n};\n\nexport type WorkState = {\n\tnavigation: null | {\n\t\thref: string;\n\t\treplace: boolean;\n\t\tsource: \"navigate\" | \"popstate\" | \"redirect\";\n\t};\n\trevalidation: null | {\n\t\tstatus: \"debouncing\" | \"running\" | \"retrying\";\n\t\tattempt: number;\n\t};\n\tprefetch: null | {\n\t\thref: string;\n\t};\n\tapiRequests: Array<{\n\t\tkey: string;\n\t\tmethod: string;\n\t\thref: string;\n\t}>;\n};\n\nexport type RevalidationReason =\n\t| \"manual\"\n\t| \"retry\"\n\t| \"apiRequest\"\n\t| \"windowFocus\";\n\nexport type BuildSkewDetectedEvent = {\n\tactiveClientBuildID: string;\n\tserverBuildID: string;\n\ttriggeringResponse:\n\t\t| {\n\t\t\t\tkind: \"route\";\n\t\t\t\ttrigger: \"navigation\" | \"popstate\" | \"prefetch\";\n\t\t\t\trequestedHref: string;\n\t\t\t\tstatus: number;\n\t\t\t\tok: boolean;\n\t\t }\n\t\t| {\n\t\t\t\tkind: \"route\";\n\t\t\t\ttrigger: \"revalidation\";\n\t\t\t\trevalidationReason: RevalidationReason;\n\t\t\t\trequestedHref: string;\n\t\t\t\tstatus: number;\n\t\t\t\tok: boolean;\n\t\t }\n\t\t| {\n\t\t\t\tkind: \"apiRoute\";\n\t\t\t\tapiRouteKind: APIRouteKind;\n\t\t\t\trequestedHref: string;\n\t\t\t\tmethod: string;\n\t\t\t\tstatus: number;\n\t\t\t\tok: boolean;\n\t\t };\n\tcurrentRouteState: RouteState;\n\tcurrentWorkState: WorkState;\n\tdefaultBehavior: \"dropResponse\" | \"hardReload\" | \"notifyOnly\";\n};\n\nexport type WorkIndicator = {\n\ttrack: <T>(promise: PromiseLike<T>) => Promise<T>;\n\tisActive: () => boolean;\n};\n\nexport type WorkIndicatorOptions = {\n\tstart: () => void;\n\tstop: () => void;\n\tstartDelayMS?: number;\n\tstopDelayMS?: number;\n\tskipNavigations?: boolean;\n\tskipAPIRequests?: boolean;\n\tskipRevalidations?: boolean;\n};\n\nexport type ClientOptions = {\n\trender?: () => void | Promise<void>;\n\tworkIndicator?: WorkIndicatorOptions;\n\trevalidateOnWindowFocus?: boolean | { staleTimeMS: number };\n\tdefaultErrorBoundary?: (props: { error: unknown }) => any;\n\tuseViewTransitions?: boolean;\n\tonRouteUpdate?: (\n\t\troute: RouteState,\n\t\tpreviousRoute: RouteState | null,\n\t\treason: RouteUpdateReason,\n\t) => void;\n\tonWorkUpdate?: (work: WorkState) => void;\n\tonBuildSkewDetected?: (event: BuildSkewDetectedEvent) => void;\n};\n\nexport type ClientCommit = {\n\troute_render?: {\n\t\tstate: RouteRenderState;\n\t\tscroll_intent?: ScrollIntent;\n\t};\n\troute_update?: {\n\t\tprevious_route: RouteState | null;\n\t\treason: RouteUpdateReason;\n\t\troute: RouteState;\n\t};\n\twork?: WorkState;\n};\n\nexport type CommitFn = (commit: ClientCommit) => void;\n\nexport type ViewDefinition = {\n\tpattern: string;\n\tcomponent: (props: any) => any;\n\terror_boundary?: (props: { error: unknown }) => any;\n\tclient_loader?: ClientLoaderFn;\n\tbefore_route_commit?: BeforeRouteCommitFn;\n\tbefore_route_yield?: BeforeRouteYieldFn;\n};\n\ntype ClientLoaderFn = (args: {\n\ttrigger: \"boot\" | \"navigation\" | \"revalidation\" | \"prefetch\";\n\thref: string;\n\thistoryState: unknown;\n\tpattern: string;\n\tparams: Record<string, string>;\n\tsplatValues: string[];\n\tinput: unknown;\n\tknownMatches: ClientLoaderKnownMatch[];\n\tserverPromise: Promise<ClientLoaderServerState>;\n\tsignal: AbortSignal;\n}) => Promise<unknown>;\n\ntype ClientLoaderKnownMatch = {\n\tpattern: string;\n\tinput: unknown;\n};\n\ntype ClientLoaderServerState = {\n\tclientBuildID: string;\n\tmatches: Array<{\n\t\tpattern: string;\n\t\tinput: unknown;\n\t\tloaderData: unknown;\n\t}>;\n\toutermostServerError: null | {\n\t\tidx: number;\n\t\terror: unknown;\n\t};\n\tloaderData: unknown;\n};\n\ntype APIResult<T> =\n\t| {\n\t\t\tsuccess: true;\n\t\t\tdata: T;\n\t\t\tresponse: Response;\n\t\t\trevalidationPromise: Promise<RevalidationResult>;\n\t }\n\t| {\n\t\t\tsuccess: false;\n\t\t\terror: string;\n\t\t\tresponse?: Response;\n\t\t\trevalidationPromise: Promise<RevalidationResult>;\n\t };\n\nexport type ClientCore = {\n\tboot: (options: ClientOptions) => Promise<Result<void>>;\n\tworkIndicator: WorkIndicator;\n\tnavigate: (\n\t\thref: string | URL,\n\t\toptions?: {\n\t\t\treplace?: boolean;\n\t\t\tscrollToTop?: boolean;\n\t\t\tstate?: unknown;\n\t\t\tskipWorkIndicator?: boolean;\n\t\t},\n\t) => Promise<{ didNavigate: boolean }>;\n\trevalidate: () => Promise<RevalidationResult>;\n\tsubmit_inner: <T = unknown>(\n\t\turl: string | URL,\n\t\trequestInit?: RequestInit,\n\t\toptions?: {\n\t\t\tapiRouteKind?: APIRouteKind;\n\t\t\tdedupeKey?: string;\n\t\t\trevalidate?: boolean;\n\t\t\tskipWorkIndicator?: boolean;\n\t\t},\n\t) => Promise<APIResult<T>>;\n\tgetRouteState: () => RouteState;\n\tgetWorkState: () => WorkState;\n\tgetClientBuildID: () => string;\n\tgetRootEl: () => HTMLElement;\n\tdefineView: <T = any>(input: {\n\t\tpattern: string;\n\t\tcomponent: (props: any) => any;\n\t\terrorBoundary?: (props: { error: unknown }) => any;\n\t\tclientLoader?: (props: any) => Promise<T>;\n\t\tbeforeRouteCommit?: BeforeRouteCommitFn;\n\t\tbeforeRouteYield?: BeforeRouteYieldFn;\n\t\trunClientLoaderOnHMR?: boolean;\n\t}) => ViewDefinition & { __phantom_client_loader_data?: T };\n\tstart_prefetch: (href: string) => void;\n\tstop_prefetch: (href: string) => void;\n\tsave_current_scroll: () => void;\n\tget_default_error_boundary: () =>\n\t\t| ((props: { error: unknown }) => any)\n\t\t| undefined;\n};\n\n/////////////////////////////////////////////////////////////////////\n/////// Constants\n/////////////////////////////////////////////////////////////////////\n\nexport const MAX_SCROLL_ENTRIES = 50;\nexport const REFRESH_MAX_AGE_MS = 3333;\nexport const MAX_REDIRECTS = 10;\nexport const REVALIDATION_DEBOUNCE_MS = 8;\nexport const MAX_REVALIDATION_RETRIES = 8;\nexport const REVALIDATION_BACKOFF_BASE_MS = 500;\nexport const REVALIDATION_BACKOFF_CAP_MS = 30000;\n\nconst REVALIDATION_OK: RevalidationResult = { ok: true };\nconst REVALIDATION_BUILD_SKEW: RevalidationResult = {\n\tok: false,\n\treason: \"build_skew\",\n};\nconst REVALIDATION_EXHAUSTED: RevalidationResult = {\n\tok: false,\n\treason: \"max_retries_exhausted\",\n};\nlet focus_revalidation_cleanup: (() => void) | null = null;\n\n/////////////////////////////////////////////////////////////////////\n/////// Module-Level Utilities\n/////////////////////////////////////////////////////////////////////\n\ntype TestOptions = {\n\treload?: () => void;\n\thard_redirect?: (url: string) => void;\n\tscroll_to?: (x: number, y: number) => void;\n};\n\nexport function apply_scroll(\n\tscroll: ScrollState | undefined,\n\ttest_options?: TestOptions,\n): void {\n\tif (!scroll) {\n\t\treturn;\n\t}\n\tif (\"hash\" in scroll) {\n\t\tconst raw = scroll.hash.startsWith(\"#\")\n\t\t\t? scroll.hash.slice(1)\n\t\t\t: scroll.hash;\n\t\tlet id: string;\n\t\ttry {\n\t\t\tid = decodeURIComponent(raw);\n\t\t} catch {\n\t\t\tid = raw;\n\t\t}\n\t\tdocument.getElementById(id)?.scrollIntoView();\n\t\treturn;\n\t}\n\tconst scroll_to =\n\t\ttest_options?.scroll_to ??\n\t\t((x: number, y: number) => {\n\t\t\twindow.scrollTo(x, y);\n\t\t});\n\tscroll_to(scroll.x, scroll.y);\n}\n\nexport function make_route_id(idx: number, pattern: string): string {\n\treturn `${idx}:${pattern}`;\n}\n\nfunction is_abort_error(e: unknown): boolean {\n\treturn e instanceof DOMException && e.name === \"AbortError\";\n}\n\nfunction new_abort_error(): DOMException {\n\treturn new DOMException(\"Aborted\", \"AbortError\");\n}\n\nfunction to_error_string(err: unknown): string {\n\treturn err instanceof Error ? err.message : String(err);\n}\n\nfunction normalize_module_url(url: string): string {\n\treturn new URL(url, window.location.href).pathname;\n}\n\ntype Deferred<T> = {\n\tpromise: Promise<T>;\n\tresolve: (value: T) => void;\n};\n\nfunction make_deferred<T>(): Deferred<T> {\n\tlet resolve!: (v: T) => void;\n\tconst promise = new Promise<T>((r) => {\n\t\tresolve = r;\n\t});\n\treturn { promise, resolve };\n}\n\ntype WorkIndicatorController = {\n\tindicator: WorkIndicator;\n\tconfigure: (options: WorkIndicatorOptions | undefined) => void;\n\tset_vorma_active: (active: boolean) => void;\n};\n\nfunction create_work_indicator(): WorkIndicatorController {\n\tlet options: WorkIndicatorOptions | undefined;\n\tlet visible = false;\n\tlet show_timer: number | undefined;\n\tlet hide_timer: number | undefined;\n\tconst active_tokens = new Set<symbol>();\n\tlet release_vorma_work: (() => void) | undefined;\n\n\tfunction clear_show_timer(): void {\n\t\tif (show_timer === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tclearTimeout(show_timer);\n\t\tshow_timer = undefined;\n\t}\n\n\tfunction clear_hide_timer(): void {\n\t\tif (hide_timer === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tclearTimeout(hide_timer);\n\t\thide_timer = undefined;\n\t}\n\n\tfunction sync(): void {\n\t\tconst current_options = options;\n\t\tif (!current_options) {\n\t\t\tclear_show_timer();\n\t\t\tclear_hide_timer();\n\t\t\treturn;\n\t\t}\n\n\t\tif (active_tokens.size > 0) {\n\t\t\tclear_hide_timer();\n\t\t\tif (visible || show_timer !== undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tshow_timer = window.setTimeout(() => {\n\t\t\t\tshow_timer = undefined;\n\t\t\t\tconst latest_options = options;\n\t\t\t\tif (!latest_options || active_tokens.size === 0 || visible) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlatest_options.start();\n\t\t\t\tvisible = true;\n\t\t\t}, current_options.startDelayMS ?? 12);\n\t\t\treturn;\n\t\t}\n\n\t\tclear_show_timer();\n\t\tif (!visible) {\n\t\t\treturn;\n\t\t}\n\t\tif (hide_timer !== undefined) {\n\t\t\treturn;\n\t\t}\n\t\thide_timer = window.setTimeout(() => {\n\t\t\thide_timer = undefined;\n\t\t\tconst latest_options = options;\n\t\t\tif (!latest_options || active_tokens.size > 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlatest_options.stop();\n\t\t\tvisible = false;\n\t\t}, current_options.stopDelayMS ?? 12);\n\t}\n\n\tfunction begin(): () => void {\n\t\tconst token = Symbol(\"v-work-indicator\");\n\t\tlet released = false;\n\t\tactive_tokens.add(token);\n\t\tsync();\n\t\treturn () => {\n\t\t\tif (released) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treleased = true;\n\t\t\tactive_tokens.delete(token);\n\t\t\tsync();\n\t\t};\n\t}\n\n\tfunction configure(next_options: WorkIndicatorOptions | undefined): void {\n\t\tconst previous_options = options;\n\t\tclear_show_timer();\n\t\tclear_hide_timer();\n\t\tif (visible && previous_options && previous_options !== next_options) {\n\t\t\tprevious_options.stop();\n\t\t\tvisible = false;\n\t\t}\n\t\toptions = next_options;\n\t\tsync();\n\t}\n\n\tfunction set_vorma_active(active: boolean): void {\n\t\tif (active) {\n\t\t\tif (!release_vorma_work) {\n\t\t\t\trelease_vorma_work = begin();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (!release_vorma_work) {\n\t\t\tsync();\n\t\t\treturn;\n\t\t}\n\t\trelease_vorma_work();\n\t\trelease_vorma_work = undefined;\n\t}\n\n\treturn {\n\t\tindicator: {\n\t\t\ttrack: <T>(promise: PromiseLike<T>): Promise<T> => {\n\t\t\t\tconst release = begin();\n\t\t\t\treturn Promise.resolve(promise).finally(() => {\n\t\t\t\t\trelease();\n\t\t\t\t});\n\t\t\t},\n\t\t\tisActive: (): boolean => {\n\t\t\t\treturn active_tokens.size > 0;\n\t\t\t},\n\t\t},\n\t\tconfigure,\n\t\tset_vorma_active,\n\t};\n}\n\n/////////////////////////////////////////////////////////////////////\n/////// Client Core\n/////////////////////////////////////////////////////////////////////\n\nexport function create_client_core(\n\t_: Omit<AppConfig, \"__vormaViews\" | \"__vormaAPIRoutes\">,\n\tcommit: CommitFn,\n\ttest_options?: TestOptions,\n): Result<ClientCore> {\n\t/////// Pattern Registry\n\tconst registry_res = createPatternRegistry({\n\t\tdynamicParamPrefixRune: \":\",\n\t\tsplatSegmentRune: \"*\",\n\t\texplicitIndexSegment: \"_index\",\n\t});\n\tif (!registry_res.ok) {\n\t\treturn R.err(`Failed to create pattern registry: ${registry_res.err}`);\n\t}\n\tconst pattern_registry = registry_res.val;\n\n\t/////// Internal Types\n\n\ttype HistoryPosition = {\n\t\thref: string;\n\t\tkey: string;\n\t\tstate: unknown;\n\t};\n\n\ttype RouteSnapshot = {\n\t\tposition: HistoryPosition;\n\t\troute: RouteRecord;\n\t};\n\n\ttype RouteRecord = {\n\t\tparams: Record<string, string>;\n\t\tsplat_values: string[];\n\t\tmatches: RouteMatchRecord[];\n\t\terror: RouteErrorState | null;\n\t\tclient_build_id: string;\n\t};\n\n\ttype RouteMatchRecord = {\n\t\tpattern: string;\n\t\tinput: unknown;\n\t\tmodule_url: string;\n\t\tmodule: Record<string, unknown>;\n\t\tloader_data: unknown;\n\t\tclient_loader_data: unknown;\n\t};\n\n\ttype RouteRenderCommitReason =\n\t\t| \"initial\"\n\t\t| \"navigation\"\n\t\t| \"popstate\"\n\t\t| \"revalidation\"\n\t\t| \"hmr\";\n\n\ttype WorkProjection =\n\t\t| {\n\t\t\t\tkind: \"navigation\";\n\t\t\t\tskip_work_indicator?: boolean;\n\t\t }\n\t\t| {\n\t\t\t\tkind: \"revalidation\";\n\t\t\t\tskip_work_indicator?: boolean;\n\t\t }\n\t\t| {\n\t\t\t\tkind: \"apiRequest\";\n\t\t\t\tskip_work_indicator?: boolean;\n\t\t }\n\t\t| {\n\t\t\t\tkind: \"prefetch\";\n\t\t };\n\n\ttype NavOptions = {\n\t\treplace?: boolean;\n\t\tscroll_to_top?: boolean;\n\t\tstate?: unknown;\n\t\tis_popstate?: boolean;\n\t\tpopstate_scroll?: ScrollState;\n\t\tskip_work_indicator?: boolean;\n\t};\n\n\ttype NavResult = { didNavigate: boolean };\n\n\ttype RedirectResult = \"settled\" | \"transferred\";\n\n\ttype NavigationSource = \"navigate\" | \"popstate\" | \"redirect\";\n\n\ttype NavFetchIntent = {\n\t\tkind: \"nav\";\n\t\turl: URL;\n\t\toptions: NavOptions;\n\t\tsource: NavigationSource;\n\t\tredirect_count: number;\n\t\tdeferred: Deferred<NavResult>;\n\t};\n\n\ttype RevalidationFetchIntent = {\n\t\tkind: \"reval\";\n\t\tattempt: number;\n\t\treason: RevalidationReason;\n\t\tskip_work_indicator?: boolean;\n\t};\n\n\ttype ActiveFetchIntent = NavFetchIntent | RevalidationFetchIntent;\n\n\ttype PrefetchFetchIntent = { kind: \"prefetch\" };\n\n\ttype FetchIntent = ActiveFetchIntent | PrefetchFetchIntent;\n\n\ttype FetchBase = {\n\t\turl: URL; // what we asked the server for (minus hash sensitivity)\n\t\tac: AbortController;\n\t\tseq: number;\n\t\tdata_promise: Promise<FetchResult>;\n\t\tcl_prefetches: ClientLoaderPrefetch[];\n\t};\n\n\ttype ActiveFetch = FetchBase & {\n\t\t// Resolves when prefetch-phase preparation (modules, client-loader\n\t\t// prefetch seeding) is done after a prefetch is promoted.\n\t\tprepare_ready: Promise<void>;\n\t\tintent: ActiveFetchIntent;\n\t};\n\n\ttype PrefetchFetch = FetchBase & {\n\t\tis_pending: boolean;\n\t\tprepare_ready: Promise<void>;\n\t\tintent: PrefetchFetchIntent;\n\t};\n\n\ttype FetchResult =\n\t\t| { kind: \"data\"; data: unknown; response: Response }\n\t\t| { kind: \"build_skew\"; response: Response }\n\t\t| { kind: \"redirect\"; href: string; hard: boolean; response: Response }\n\t\t| {\n\t\t\t\tkind: \"error\";\n\t\t\t\tstatus: number;\n\t\t\t\tstatus_text: string;\n\t\t\t\tresponse?: Response;\n\t\t };\n\n\ttype ClientLoaderPrefetch = {\n\t\tpattern: string;\n\t\tresolve_server_state: (data: ClientLoaderServerState) => void;\n\t\tabort: () => void;\n\t\tresult_promise: Promise<unknown>;\n\t};\n\n\ttype DecodedRoute = {\n\t\tpattern: string;\n\t\tinput: unknown;\n\t\tmodule_url: string;\n\t\tloader_data: unknown;\n\t\tserver_error: unknown;\n\t};\n\n\ttype DecodedPayload = {\n\t\troutes: DecodedRoute[];\n\t\tparams: Record<string, string>;\n\t\tsplat_values: string[];\n\t\ttitle: string | undefined;\n\t\tmeta_head_els: HeadEl[];\n\t\trest_head_els: HeadEl[];\n\t\tcss_bundles: string[];\n\t\tdeps: string[];\n\t};\n\n\ttype PreparedRoute = {\n\t\troute: RouteRecord;\n\t\tapply_dom_side_effects: () => void;\n\t};\n\n\ttype Submission = {\n\t\tac: AbortController;\n\t\tkey: string;\n\t\tmethod: string;\n\t\thref: string;\n\t\tskip_work_indicator?: boolean;\n\t};\n\n\ttype RefreshWaiter = Deferred<RevalidationResult>;\n\n\ttype RefreshDemand = {\n\t\t// A fetch with seq > this value satisfies the demand.\n\t\tafter_seq: number;\n\t\treason: RevalidationReason;\n\t\tskip_work_indicator?: boolean;\n\t\twaiters: RefreshWaiter[];\n\t};\n\n\ttype RefreshState =\n\t\t| { kind: \"idle\" }\n\t\t| { kind: \"pending\"; demand: RefreshDemand; attempt: number }\n\t\t| {\n\t\t\t\tkind: \"debouncing\";\n\t\t\t\tdemand: RefreshDemand;\n\t\t\t\ttimer: ReturnType<typeof setTimeout>;\n\t\t }\n\t\t| {\n\t\t\t\tkind: \"retrying\";\n\t\t\t\tdemand: RefreshDemand;\n\t\t\t\tattempt: number;\n\t\t\t\ttimer: ReturnType<typeof setTimeout>;\n\t\t };\n\n\ttype StoredScrollEntry = [string, { x: number; y: number }];\n\n\t/*\n\tNine base facts:\n\n\t 1. phase: router lifecycle ('booting' | 'ready')\n\t 2. browser: the browser's current history entry\n\t 3. route_snapshot: current route data available to Vorma APIs\n\t 4. active: the one in-flight nav or revalidation (at most one, ever)\n\t 5. prefetch: the at-most-one in-flight prefetch\n\t 6. refresh: outstanding route data demand and its retry timing\n\t 7. apiRequests: concurrent action requests (independent of routes)\n\t 8. deferred_submit_redirect: submit redirect waiting for boot completion\n\t 9. seq: monotonic counter; refresh is ordered by seq, never wall clock\n\n\tAborting a fetch and publishing a route are each single operations.\n\n\tWorkProjection and WorkState are derived from these facts. RouteRenderState\n\tis derived only at the adapter commit boundary.\n\t*/\n\n\t/////// Base Facts\n\n\tlet phase: \"booting\" | \"ready\" = \"booting\";\n\tlet browser: HistoryPosition = { href: \"\", key: \"\", state: undefined };\n\tlet route_snapshot: RouteSnapshot | null = null;\n\tlet active: ActiveFetch | null = null;\n\tlet prefetch: PrefetchFetch | null = null;\n\tlet refresh: RefreshState = { kind: \"idle\" };\n\tconst submissions = new Map<string, Submission>();\n\tlet seq = 0;\n\n\t/////// Config And Listeners\n\n\tlet client_build_id = \"\";\n\tlet deployment_id = \"\";\n\tlet use_view_transitions = false;\n\tlet default_error_boundary:\n\t\t| ((props: { error: unknown }) => any)\n\t\t| undefined;\n\tlet user_on_route_update:\n\t\t| ((\n\t\t\t\troute: RouteState,\n\t\t\t\tpreviousRoute: RouteState | null,\n\t\t\t\treason: RouteUpdateReason,\n\t\t ) => void)\n\t\t| undefined;\n\tlet user_on_work_update: ((work: WorkState) => void) | undefined;\n\tlet user_on_build_skew_detected:\n\t\t| ((event: BuildSkewDetectedEvent) => void)\n\t\t| undefined;\n\tlet deferred_submit_redirect: URL | null = null;\n\tlet last_activity_ts = Date.now();\n\tlet last_work_state: WorkState = empty_work_state();\n\n\tconst work_indicator = create_work_indicator();\n\tlet work_indicator_options: WorkIndicatorOptions | undefined;\n\tlet work_indicator_sync_registered = false;\n\tconst work_update_listeners = new Set<(work: WorkState) => void>();\n\tconst module_map: Record<string, ClientLoaderFn> = {};\n\tconst search_schema_map: Record<string, unknown> = {};\n\tconst hmr_rerun_patterns = new Set<string>();\n\tconst module_cache = new Map<string, Record<string, unknown>>();\n\n\tconst reload_page =\n\t\ttest_options?.reload ??\n\t\t(() => {\n\t\t\twindow.location.reload();\n\t\t});\n\tconst hard_redirect =\n\t\ttest_options?.hard_redirect ??\n\t\t((url: string) => {\n\t\t\twindow.location.assign(url);\n\t\t});\n\n\t/////// URL And History\n\n\tfunction current_url(): URL {\n\t\treturn new URL(window.location.href);\n\t}\n\n\tfunction next_seq(): number {\n\t\tseq++;\n\t\treturn seq;\n\t}\n\n\tfunction is_http(href: string): boolean {\n\t\ttry {\n\t\t\tconst p = new URL(href).protocol;\n\t\t\treturn p === \"http:\" || p === \"https:\";\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction is_same_origin(url: URL): boolean {\n\t\treturn url.origin === current_url().origin;\n\t}\n\n\tfunction is_same_origin_href(href: string): boolean {\n\t\ttry {\n\t\t\treturn new URL(href).origin === current_url().origin;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction matches_without_hash(a: URL, b: URL): boolean {\n\t\tconst x = new URL(a.href);\n\t\tx.hash = \"\";\n\t\tconst y = new URL(b.href);\n\t\ty.hash = \"\";\n\t\treturn x.href === y.href;\n\t}\n\n\tfunction route_snapshot_matches(url: URL): boolean {\n\t\treturn (\n\t\t\troute_snapshot !== null &&\n\t\t\tmatches_without_hash(url, new URL(route_snapshot.position.href))\n\t\t);\n\t}\n\n\tfunction normalize_hash(hash: string): string {\n\t\tconst s = hash.startsWith(\"#\") ? hash.slice(1) : hash;\n\t\tif (s.length === 0) {\n\t\t\treturn s;\n\t\t}\n\t\ttry {\n\t\t\treturn decodeURIComponent(s);\n\t\t} catch {\n\t\t\treturn s;\n\t\t}\n\t}\n\n\tfunction make_history_key(): string {\n\t\treturn Math.random().toString(36).slice(2, 10);\n\t}\n\n\tfunction read_browser_position(): HistoryPosition {\n\t\tconst state = window.history.state;\n\t\tconst key =\n\t\t\tstate && typeof state === \"object\" && HISTORY_KEY_FIELD in state\n\t\t\t\t? (state as Record<string, string>)[HISTORY_KEY_FIELD]!\n\t\t\t\t: \"\";\n\t\treturn {\n\t\t\thref: current_url().href,\n\t\t\tkey,\n\t\t\tstate: state?.[HISTORY_USER_STATE_FIELD],\n\t\t};\n\t}\n\n\tfunction commit_history(\n\t\turl: string,\n\t\treplace: boolean | undefined,\n\t\tuser_state: unknown,\n\t): HistoryPosition {\n\t\tconst key = make_history_key();\n\t\tconst next_state: Record<string, unknown> = {\n\t\t\t[HISTORY_KEY_FIELD]: key,\n\t\t\t[HISTORY_USER_STATE_FIELD]: user_state,\n\t\t};\n\n\t\tif (replace) {\n\t\t\tconst existing = window.history.state;\n\t\t\tconst base =\n\t\t\t\texisting && typeof existing === \"object\" ? existing : {};\n\t\t\twindow.history.replaceState(\n\t\t\t\t{ ...(base as object), ...next_state },\n\t\t\t\t\"\",\n\t\t\t\turl,\n\t\t\t);\n\t\t} else {\n\t\t\twindow.history.pushState(next_state, \"\", url);\n\t\t}\n\n\t\tbrowser = { href: url, key, state: user_state };\n\t\treturn browser;\n\t}\n\n\tfunction route_snapshot_matches_browser(): boolean {\n\t\treturn (\n\t\t\troute_snapshot !== null &&\n\t\t\troute_snapshot.position.href === browser.href &&\n\t\t\troute_snapshot.position.key === browser.key\n\t\t);\n\t}\n\n\t/////// Scroll Storage\n\n\tfunction get_scroll_pos(): { x: number; y: number } {\n\t\treturn { x: window.scrollX, y: window.scrollY };\n\t}\n\n\tfunction read_scroll_entries(): StoredScrollEntry[] {\n\t\ttry {\n\t\t\tconst raw = sessionStorage.getItem(SCROLL_STORAGE_KEY);\n\t\t\tif (!raw) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst parsed = JSON.parse(raw);\n\t\t\tif (!Array.isArray(parsed)) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\treturn parsed.filter((e: unknown): e is StoredScrollEntry => {\n\t\t\t\treturn (\n\t\t\t\t\tArray.isArray(e) &&\n\t\t\t\t\te.length === 2 &&\n\t\t\t\t\ttypeof e[0] === \"string\" &&\n\t\t\t\t\t!!e[1] &&\n\t\t\t\t\ttypeof e[1] === \"object\" &&\n\t\t\t\t\tNumber.isFinite((e[1] as any).x) &&\n\t\t\t\t\tNumber.isFinite((e[1] as any).y)\n\t\t\t\t);\n\t\t\t});\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\n\tfunction save_scroll_for_key(\n\t\tkey: string,\n\t\tpos: { x: number; y: number },\n\t): void {\n\t\tconst entries = read_scroll_entries().filter((e) => e[0] !== key);\n\t\tentries.push([key, pos]);\n\t\tif (entries.length > MAX_SCROLL_ENTRIES) {\n\t\t\tentries.splice(0, entries.length - MAX_SCROLL_ENTRIES);\n\t\t}\n\t\ttry {\n\t\t\tsessionStorage.setItem(SCROLL_STORAGE_KEY, JSON.stringify(entries));\n\t\t} catch {}\n\t}\n\n\tfunction get_scroll_for_key(\n\t\tkey: string,\n\t): { x: number; y: number } | undefined {\n\t\tfor (const [k, v] of read_scroll_entries()) {\n\t\t\tif (k === key) {\n\t\t\t\treturn v;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tfunction save_current_scroll(): void {\n\t\tif (browser.key) {\n\t\t\tsave_scroll_for_key(browser.key, get_scroll_pos());\n\t\t}\n\t}\n\n\t/////// Payload Decoding\n\n\tfunction decode_payload(raw: unknown, url: URL): DecodedPayload {\n\t\tconst p = raw as Record<string, any>;\n\t\tconst patterns: string[] = p.MatchedPatterns ?? [];\n\t\tconst schemas: unknown[] = Array.isArray(p.SearchSchemas)\n\t\t\t? p.SearchSchemas\n\t\t\t: [];\n\t\tconst loaders_data: unknown[] = p.LoadersData ?? [];\n\t\tconst import_urls: string[] = p.ImportURLs ?? [];\n\t\tconst err_idx: number | null = p.OutermostServerErrIdx ?? null;\n\t\tconst err_msg: string = p.OutermostServerErr ?? \"\";\n\t\tconst search_params = url.searchParams;\n\n\t\tconst routes: DecodedRoute[] = patterns.map((pattern, i) => {\n\t\t\tconst schema = schemas[i];\n\t\t\tsearch_schema_map[pattern] = schema;\n\t\t\treturn {\n\t\t\t\tpattern,\n\t\t\t\tinput: parseSearchParams(schema, search_params),\n\t\t\t\tmodule_url: import_urls[i] ?? \"\",\n\t\t\t\tloader_data: loaders_data[i],\n\t\t\t\tserver_error:\n\t\t\t\t\terr_idx !== null && i === err_idx ? err_msg : undefined,\n\t\t\t};\n\t\t});\n\n\t\tlet title: string | undefined;\n\t\tif (p.Title?.dangerousInnerHTML !== undefined) {\n\t\t\tconst el = document.createElement(\"textarea\");\n\t\t\tel.innerHTML = p.Title.dangerousInnerHTML;\n\t\t\ttitle = el.value;\n\t\t}\n\n\t\treturn {\n\t\t\troutes,\n\t\t\tparams: p.Params ?? {},\n\t\t\tsplat_values: p.SplatValues ?? [],\n\t\t\ttitle,\n\t\t\tmeta_head_els: p.MetaHeadEls ?? [],\n\t\t\trest_head_els: p.RestHeadEls ?? [],\n\t\t\tcss_bundles: p.CSSBundles ?? [],\n\t\t\tdeps: p.Deps ?? [],\n\t\t};\n\t}\n\n\t/////// Modules And Client Loader Prefetches\n\n\tfunction make_cl_prefetch(input: {\n\t\thref: string;\n\t\thistory_state: unknown;\n\t\tknown_matches: ClientLoaderKnownMatch[];\n\t\tloader: ClientLoaderFn;\n\t\tparams: Record<string, string>;\n\t\tpattern: string;\n\t\troute_input: unknown;\n\t\tsignal: AbortSignal;\n\t\tsplat_values: string[];\n\t\ttrigger: \"navigation\" | \"revalidation\" | \"prefetch\";\n\t}): ClientLoaderPrefetch {\n\t\tlet resolve_server_state!: (v: ClientLoaderServerState) => void;\n\t\tlet reject_server_state!: (err: unknown) => void;\n\t\tconst server_promise = new Promise<ClientLoaderServerState>(\n\t\t\t(res, rej) => {\n\t\t\t\tresolve_server_state = res;\n\t\t\t\treject_server_state = rej;\n\t\t\t},\n\t\t);\n\t\tserver_promise.catch(() => {});\n\n\t\tconst ac = new AbortController();\n\t\tif (input.signal.aborted) {\n\t\t\tac.abort();\n\t\t\treject_server_state(new_abort_error());\n\t\t} else {\n\t\t\tinput.signal.addEventListener(\n\t\t\t\t\"abort\",\n\t\t\t\t() => {\n\t\t\t\t\tac.abort();\n\t\t\t\t\treject_server_state(new_abort_error());\n\t\t\t\t},\n\t\t\t\t{ once: true },\n\t\t\t);\n\t\t}\n\n\t\tconst result_promise = input.loader({\n\t\t\ttrigger: input.trigger,\n\t\t\thref: input.href,\n\t\t\thistoryState: input.history_state,\n\t\t\tpattern: input.pattern,\n\t\t\tparams: input.params,\n\t\t\tsplatValues: input.splat_values,\n\t\t\tinput: input.route_input,\n\t\t\tknownMatches: input.known_matches,\n\t\t\tserverPromise: server_promise,\n\t\t\tsignal: ac.signal,\n\t\t});\n\t\tresult_promise.catch(() => {});\n\n\t\treturn {\n\t\t\tpattern: input.pattern,\n\t\t\tresolve_server_state,\n\t\t\tabort: () => {\n\t\t\t\tac.abort();\n\t\t\t\treject_server_state(new_abort_error());\n\t\t\t},\n\t\t\tresult_promise,\n\t\t};\n\t}\n\n\tfunction routes_to_known_matches(\n\t\troutes: DecodedRoute[],\n\t): ClientLoaderKnownMatch[] {\n\t\treturn routes.map((r) => {\n\t\t\treturn {\n\t\t\t\tpattern: r.pattern,\n\t\t\t\tinput: r.input,\n\t\t\t};\n\t\t});\n\t}\n\n\tfunction build_server_state(\n\t\troutes: DecodedRoute[],\n\t\tidx: number,\n\t): ClientLoaderServerState {\n\t\tconst err_idx = routes.findIndex((r) => {\n\t\t\treturn r.server_error !== undefined;\n\t\t});\n\t\treturn {\n\t\t\tclientBuildID: client_build_id,\n\t\t\tmatches: routes.map((r) => {\n\t\t\t\treturn {\n\t\t\t\t\tpattern: r.pattern,\n\t\t\t\t\tinput: r.input,\n\t\t\t\t\tloaderData: r.loader_data,\n\t\t\t\t};\n\t\t\t}),\n\t\t\toutermostServerError:\n\t\t\t\terr_idx === -1\n\t\t\t\t\t? null\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tidx: err_idx,\n\t\t\t\t\t\t\terror: routes[err_idx]!.server_error,\n\t\t\t\t\t\t},\n\t\t\tloaderData: routes[idx]?.loader_data,\n\t\t};\n\t}\n\n\tasync function run_client_loaders(\n\t\troutes: DecodedRoute[],\n\t\tpayload: DecodedPayload,\n\t\tcl_prefetches: ClientLoaderPrefetch[],\n\t\ttrigger: \"boot\" | \"navigation\" | \"revalidation\",\n\t\thref: string,\n\t\thistory_state: unknown,\n\t\tsignal: AbortSignal,\n\t): Promise<Array<{ data: unknown } | { error: unknown } | undefined>> {\n\t\tconst by_pattern = new Map<string, ClientLoaderPrefetch>();\n\t\tfor (const p of cl_prefetches) {\n\t\t\tby_pattern.set(p.pattern, p);\n\t\t}\n\t\tconst err_idx = routes.findIndex((r) => r.server_error !== undefined);\n\t\tconst known_matches = routes_to_known_matches(routes);\n\n\t\tconst abort_later: Array<(() => void) | null> = [];\n\t\tconst promises: Array<Promise<unknown>> = [];\n\t\tconst retained_prefetches = new Set<ClientLoaderPrefetch>();\n\n\t\tfor (let i = 0; i < routes.length; i++) {\n\t\t\tconst route = routes[i]!;\n\t\t\tconst existing = by_pattern.get(route.pattern);\n\t\t\tif (err_idx !== -1 && i >= err_idx) {\n\t\t\t\texisting?.abort();\n\t\t\t\tpromises.push(Promise.resolve(undefined));\n\t\t\t\tabort_later.push(null);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (existing) {\n\t\t\t\texisting.resolve_server_state(build_server_state(routes, i));\n\t\t\t\tretained_prefetches.add(existing);\n\t\t\t\tabort_later.push(existing.abort);\n\t\t\t\tpromises.push(existing.result_promise);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst loader = module_map[route.pattern];\n\t\t\tif (!loader) {\n\t\t\t\tpromises.push(Promise.resolve(undefined));\n\t\t\t\tabort_later.push(null);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst ac = new AbortController();\n\t\t\tabort_later.push(() => {\n\t\t\t\tac.abort();\n\t\t\t});\n\t\t\tif (signal.aborted) {\n\t\t\t\tac.abort();\n\t\t\t} else {\n\t\t\t\tsignal.addEventListener(\"abort\", () => ac.abort(), {\n\t\t\t\t\tonce: true,\n\t\t\t\t});\n\t\t\t}\n\t\t\tpromises.push(\n\t\t\t\tloader({\n\t\t\t\t\ttrigger,\n\t\t\t\t\thref,\n\t\t\t\t\thistoryState: history_state,\n\t\t\t\t\tpattern: route.pattern,\n\t\t\t\t\tparams: payload.params,\n\t\t\t\t\tsplatValues: payload.splat_values,\n\t\t\t\t\tinput: route.input,\n\t\t\t\t\tknownMatches: known_matches,\n\t\t\t\t\tserverPromise: Promise.resolve(\n\t\t\t\t\t\tbuild_server_state(routes, i),\n\t\t\t\t\t),\n\t\t\t\t\tsignal: ac.signal,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tfor (const p of cl_prefetches) {\n\t\t\tif (!retained_prefetches.has(p)) {\n\t\t\t\tp.abort();\n\t\t\t}\n\t\t}\n\n\t\tconst wrapped = promises.map(async (p, i) => {\n\t\t\treturn p.catch((err) => {\n\t\t\t\t// On non-abort failure, cascade abort to later routes to avoid\n\t\t\t\t// running loaders that can never be used.\n\t\t\t\tif (!is_abort_error(err)) {\n\t\t\t\t\tfor (let j = i + 1; j < abort_later.length; j++) {\n\t\t\t\t\t\tabort_later[j]?.();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow err;\n\t\t\t});\n\t\t});\n\n\t\tconst settled = await Promise.allSettled(wrapped);\n\t\tconst out: Array<{ data: unknown } | { error: unknown } | undefined> =\n\t\t\t[];\n\t\tfor (const r of settled) {\n\t\t\tif (r.status === \"fulfilled\") {\n\t\t\t\tout.push(r.value !== undefined ? { data: r.value } : undefined);\n\t\t\t} else if (!is_abort_error(r.reason)) {\n\t\t\t\tout.push({ error: to_error_string(r.reason) });\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tout.push(undefined);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\n\t/////// Route Preparation\n\n\tasync function prepare_modules(\n\t\tpayload: DecodedPayload,\n\t\tsignal: AbortSignal,\n\t): Promise<Map<string, Record<string, unknown>> | null> {\n\t\tpreload_css(payload.css_bundles);\n\t\tconst urls = payload.routes.map((r) => {\n\t\t\treturn r.module_url;\n\t\t});\n\t\tconst unique = [...new Set(urls.filter(Boolean))];\n\t\tconst pairs = await Promise.all(\n\t\t\tunique.map(async (url) => {\n\t\t\t\tif (import.meta.env.DEV) {\n\t\t\t\t\tconst key = normalize_module_url(url);\n\t\t\t\t\tconst cached = module_cache.get(key);\n\t\t\t\t\tif (cached) {\n\t\t\t\t\t\treturn [url, cached] as const;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst mod = (await import(/* @vite-ignore */ url)) as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\tunknown\n\t\t\t\t>;\n\t\t\t\tif (import.meta.env.DEV) {\n\t\t\t\t\tmodule_cache.set(normalize_module_url(url), mod);\n\t\t\t\t}\n\t\t\t\treturn [url, mod] as const;\n\t\t\t}),\n\t\t);\n\t\tconst modules = new Map(pairs);\n\t\tif (signal.aborted) {\n\t\t\treturn null;\n\t\t}\n\t\tfor (const route of payload.routes) {\n\t\t\tconst mod = modules.get(route.module_url);\n\t\t\tif (!mod) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst def = mod.default as ViewDefinition | undefined;\n\t\t\tif (def?.client_loader) {\n\t\t\t\tmodule_map[route.pattern] = def.client_loader;\n\t\t\t\tregisterPattern(pattern_registry, route.pattern);\n\t\t\t}\n\t\t}\n\t\treturn modules;\n\t}\n\n\tfunction build_route_record(\n\t\tpayload: DecodedPayload,\n\t\tmodules: Map<string, Record<string, unknown>>,\n\t\tcl_results: Array<{ data: unknown } | { error: unknown } | undefined>,\n\t): RouteRecord {\n\t\tconst matches: RouteMatchRecord[] = payload.routes.map((route, i) => {\n\t\t\tconst cl = cl_results[i];\n\t\t\treturn {\n\t\t\t\tpattern: route.pattern,\n\t\t\t\tinput: route.input,\n\t\t\t\tmodule_url: route.module_url,\n\t\t\t\tmodule: modules.get(route.module_url) ?? {},\n\t\t\t\tloader_data: route.loader_data,\n\t\t\t\tclient_loader_data: cl && \"data\" in cl ? cl.data : undefined,\n\t\t\t};\n\t\t});\n\t\tlet error: RouteErrorState | null = null;\n\t\tconst server_error_idx = payload.routes.findIndex((route) => {\n\t\t\treturn route.server_error !== undefined;\n\t\t});\n\t\tif (server_error_idx !== -1) {\n\t\t\terror = {\n\t\t\t\tidx: server_error_idx,\n\t\t\t\terror: payload.routes[server_error_idx]!.server_error,\n\t\t\t\tsource: \"server\",\n\t\t\t};\n\t\t} else {\n\t\t\tconst client_loader_error_idx = cl_results.findIndex((cl) => {\n\t\t\t\treturn cl !== undefined && \"error\" in cl;\n\t\t\t});\n\t\t\tif (client_loader_error_idx !== -1) {\n\t\t\t\terror = {\n\t\t\t\t\tidx: client_loader_error_idx,\n\t\t\t\t\terror: (\n\t\t\t\t\t\tcl_results[client_loader_error_idx] as {\n\t\t\t\t\t\t\terror: unknown;\n\t\t\t\t\t\t}\n\t\t\t\t\t).error,\n\t\t\t\t\tsource: \"clientLoader\",\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tparams: payload.params,\n\t\t\tsplat_values: payload.splat_values,\n\t\t\tmatches,\n\t\t\terror,\n\t\t\tclient_build_id,\n\t\t};\n\t}\n\n\tasync function prepare_route(\n\t\tpayload: DecodedPayload,\n\t\tcl_prefetches: ClientLoaderPrefetch[],\n\t\ttrigger: \"navigation\" | \"revalidation\",\n\t\thref: string,\n\t\thistory_state: unknown,\n\t\tsignal: AbortSignal,\n\t): Promise<PreparedRoute | null> {\n\t\tconst modules = await prepare_modules(payload, signal);\n\t\tif (!modules) {\n\t\t\treturn null;\n\t\t}\n\t\tconst cl_results = await run_client_loaders(\n\t\t\tpayload.routes,\n\t\t\tpayload,\n\t\t\tcl_prefetches,\n\t\t\ttrigger,\n\t\t\thref,\n\t\t\thistory_state,\n\t\t\tsignal,\n\t\t);\n\t\tif (signal.aborted) {\n\t\t\treturn null;\n\t\t}\n\t\tawait wait_for_css(payload.css_bundles, signal);\n\t\tif (signal.aborted) {\n\t\t\treturn null;\n\t\t}\n\t\treturn {\n\t\t\troute: build_route_record(payload, modules, cl_results),\n\t\t\tapply_dom_side_effects: () => {\n\t\t\t\tapply_head_and_title(\n\t\t\t\t\tpayload.title,\n\t\t\t\t\tpayload.meta_head_els,\n\t\t\t\t\tpayload.rest_head_els,\n\t\t\t\t);\n\t\t\t\tapply_css_bundles(payload.css_bundles);\n\t\t\t\tpreload_modules(payload.deps);\n\t\t\t},\n\t\t};\n\t}\n\n\t/////// Fetch\n\n\tfunction detect_redirect(\n\t\tres: Response,\n\t\tbase: URL,\n\t): { href: string; hard: boolean } | null {\n\t\tconst soft = res.headers.get(X_CLIENT_REDIRECT);\n\t\tif (soft) {\n\t\t\treturn { href: new URL(soft, base).href, hard: false };\n\t\t}\n\t\tif (res.redirected && res.url && res.url !== base.href) {\n\t\t\treturn { href: new URL(res.url, base).href, hard: false };\n\t\t}\n\t\treturn null;\n\t}\n\n\tfunction report_build_skew(\n\t\tevent: Omit<\n\t\t\tBuildSkewDetectedEvent,\n\t\t\t| \"activeClientBuildID\"\n\t\t\t| \"currentRouteState\"\n\t\t\t| \"currentWorkState\"\n\t\t\t| \"serverBuildID\"\n\t\t> & {\n\t\t\tresponse: Response;\n\t\t},\n\t): boolean {\n\t\tconst server_build_id =\n\t\t\tevent.response.headers.get(BUILD_ID_HEADER) ?? \"\";\n\t\tif (!server_build_id || server_build_id === client_build_id) {\n\t\t\treturn false;\n\t\t}\n\t\tif (!route_snapshot) {\n\t\t\treturn false;\n\t\t}\n\t\tuser_on_build_skew_detected?.({\n\t\t\tactiveClientBuildID: client_build_id,\n\t\t\tserverBuildID: server_build_id,\n\t\t\ttriggeringResponse: event.triggeringResponse,\n\t\t\tcurrentRouteState: route_snapshot_to_state(route_snapshot),\n\t\t\tcurrentWorkState: derive_work_state(),\n\t\t\tdefaultBehavior: event.defaultBehavior,\n\t\t});\n\t\treturn true;\n\t}\n\n\tfunction report_route_build_skew(\n\t\tf: FetchBase & { intent: FetchIntent },\n\t\tresponse: Response,\n\t\tdefault_behavior: BuildSkewDetectedEvent[\"defaultBehavior\"],\n\t): boolean {\n\t\tconst base = {\n\t\t\tkind: \"route\" as const,\n\t\t\trequestedHref: f.url.href,\n\t\t\tstatus: response.status,\n\t\t\tok: response.ok,\n\t\t};\n\t\tlet triggeringResponse: BuildSkewDetectedEvent[\"triggeringResponse\"];\n\t\tif (f.intent.kind === \"reval\") {\n\t\t\ttriggeringResponse = {\n\t\t\t\t...base,\n\t\t\t\ttrigger: \"revalidation\",\n\t\t\t\trevalidationReason: f.intent.reason,\n\t\t\t};\n\t\t} else if (f.intent.kind === \"prefetch\") {\n\t\t\ttriggeringResponse = {\n\t\t\t\t...base,\n\t\t\t\ttrigger: \"prefetch\",\n\t\t\t};\n\t\t} else {\n\t\t\ttriggeringResponse = {\n\t\t\t\t...base,\n\t\t\t\ttrigger:\n\t\t\t\t\tf.intent.source === \"popstate\" ? \"popstate\" : \"navigation\",\n\t\t\t};\n\t\t}\n\n\t\treturn report_build_skew({\n\t\t\tresponse,\n\t\t\ttriggeringResponse,\n\t\t\tdefaultBehavior: default_behavior,\n\t\t});\n\t}\n\n\tfunction history_state_for_fetch(intent: FetchIntent): unknown {\n\t\tif (intent.kind === \"nav\") {\n\t\t\treturn intent.options.is_popstate\n\t\t\t\t? browser.state\n\t\t\t\t: intent.options.state;\n\t\t}\n\t\tif (intent.kind === \"reval\") {\n\t\t\treturn browser.state;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/////// Fetch Lifecycle\n\n\tfunction start_fetch<T extends FetchIntent>(\n\t\turl: URL,\n\t\tintent: T,\n\t\tis_revalidation: boolean,\n\t\tprepare_ready?: Promise<void>,\n\t): FetchBase & { prepare_ready: Promise<void>; intent: T } {\n\t\tconst ac = new AbortController();\n\t\tconst cl_prefetches: ClientLoaderPrefetch[] = [];\n\t\tlet match = findNestedMatches(pattern_registry, url.pathname);\n\t\tif (!match) {\n\t\t\tconst segments = url.pathname.split(\"/\").filter(Boolean);\n\t\t\tfor (let i = segments.length; i >= 0; i--) {\n\t\t\t\tconst partial =\n\t\t\t\t\ti === 0 ? \"/\" : \"/\" + segments.slice(0, i).join(\"/\");\n\t\t\t\tmatch = findNestedMatches(pattern_registry, partial);\n\t\t\t\tif (match) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (match) {\n\t\t\tconst known_matches = match.matches.map((m) => {\n\t\t\t\tconst pattern = m.registeredPattern.originalPattern;\n\t\t\t\treturn {\n\t\t\t\t\tpattern,\n\t\t\t\t\tinput: parseSearchParams(\n\t\t\t\t\t\tsearch_schema_map[pattern],\n\t\t\t\t\t\turl.searchParams,\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t});\n\t\t\tconst input_by_pattern = new Map(\n\t\t\t\tknown_matches.map((m) => {\n\t\t\t\t\treturn [m.pattern, m.input] as const;\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst history_state = history_state_for_fetch(intent);\n\t\t\tfor (const m of match.matches) {\n\t\t\t\tconst pattern = m.registeredPattern.originalPattern;\n\t\t\t\tconst loader = module_map[pattern];\n\t\t\t\tif (loader) {\n\t\t\t\t\tcl_prefetches.push(\n\t\t\t\t\t\tmake_cl_prefetch({\n\t\t\t\t\t\t\thref: url.href,\n\t\t\t\t\t\t\thistory_state,\n\t\t\t\t\t\t\tknown_matches,\n\t\t\t\t\t\t\tloader,\n\t\t\t\t\t\t\tparams: match.params,\n\t\t\t\t\t\t\tpattern,\n\t\t\t\t\t\t\troute_input: input_by_pattern.get(pattern),\n\t\t\t\t\t\t\tsignal: ac.signal,\n\t\t\t\t\t\t\tsplat_values: match.splatValues,\n\t\t\t\t\t\t\ttrigger:\n\t\t\t\t\t\t\t\tintent.kind === \"prefetch\"\n\t\t\t\t\t\t\t\t\t? \"prefetch\"\n\t\t\t\t\t\t\t\t\t: intent.kind === \"reval\"\n\t\t\t\t\t\t\t\t\t\t? \"revalidation\"\n\t\t\t\t\t\t\t\t\t\t: \"navigation\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\turl,\n\t\t\tac,\n\t\t\tseq: next_seq(),\n\t\t\tdata_promise: (async () => {\n\t\t\t\tconst modified = new URL(url.href);\n\t\t\t\tmodified.searchParams.set(VORMA_JSON_KEY, client_build_id);\n\t\t\t\tif (is_revalidation && deployment_id) {\n\t\t\t\t\tmodified.searchParams.set(\n\t\t\t\t\t\tVERCEL_DPL_QUERY_PARAM_KEY,\n\t\t\t\t\t\tdeployment_id,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst res = await fetch(modified, {\n\t\t\t\t\tsignal: ac.signal,\n\t\t\t\t\theaders: { [X_ACCEPTS_CLIENT_REDIRECT]: \"1\" },\n\t\t\t\t});\n\n\t\t\t\tif (res.headers.get(X_VORMA_BUILD_SKEW) === \"1\") {\n\t\t\t\t\treturn { kind: \"build_skew\", response: res };\n\t\t\t\t}\n\t\t\t\tconst redirect = detect_redirect(res, modified);\n\t\t\t\tif (redirect) {\n\t\t\t\t\treturn { kind: \"redirect\", ...redirect, response: res };\n\t\t\t\t}\n\t\t\t\tif (!res.ok) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkind: \"error\",\n\t\t\t\t\t\tstatus: res.status,\n\t\t\t\t\t\tstatus_text: res.statusText,\n\t\t\t\t\t\tresponse: res,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst data = await res.json();\n\t\t\t\t\treturn { kind: \"data\", data, response: res };\n\t\t\t\t} catch {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkind: \"error\",\n\t\t\t\t\t\tstatus: res.status,\n\t\t\t\t\t\tstatus_text: res.statusText,\n\t\t\t\t\t\tresponse: res,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t})(),\n\t\t\tcl_prefetches,\n\t\t\tprepare_ready: prepare_ready ?? Promise.resolve(),\n\t\t\tintent,\n\t\t};\n\t}\n\n\tfunction resolve_nav(f: ActiveFetch, result: NavResult): void {\n\t\tif (f.intent.kind === \"nav\") {\n\t\t\tf.intent.deferred.resolve(result);\n\t\t}\n\t}\n\n\tfunction can_commit(f: ActiveFetch): boolean {\n\t\treturn active === f && !f.ac.signal.aborted;\n\t}\n\n\t// Core lifecycle for any fetch intent. The only place that drives\n\t// fetch-to-publish: resolve response, follow redirects, prepare, publish.\n\tasync function run_active(f: ActiveFetch): Promise<void> {\n\t\tactive = f;\n\t\tnotify_work_update();\n\n\t\tlet published = false;\n\t\tlet nav_transferred = false;\n\t\ttry {\n\t\t\tconst result = await f.data_promise;\n\t\t\tif (!can_commit(f)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (result.kind === \"build_skew\") {\n\t\t\t\treport_route_build_skew(\n\t\t\t\t\tf,\n\t\t\t\t\tresult.response,\n\t\t\t\t\tf.intent.kind === \"reval\" ? \"dropResponse\" : \"hardReload\",\n\t\t\t\t);\n\t\t\t\tif (f.intent.kind === \"reval\") {\n\t\t\t\t\tmark_refresh_build_skew();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thard_redirect(f.url.href);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (result.response) {\n\t\t\t\tconst default_behavior =\n\t\t\t\t\tresult.kind === \"redirect\" &&\n\t\t\t\t\tresult.hard &&\n\t\t\t\t\tis_http(result.href)\n\t\t\t\t\t\t? f.intent.kind === \"reval\"\n\t\t\t\t\t\t\t? \"dropResponse\"\n\t\t\t\t\t\t\t: \"hardReload\"\n\t\t\t\t\t\t: \"notifyOnly\";\n\t\t\t\tconst did_detect_skew = report_route_build_skew(\n\t\t\t\t\tf,\n\t\t\t\t\tresult.response,\n\t\t\t\t\tdefault_behavior,\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tdid_detect_skew &&\n\t\t\t\t\tresult.kind === \"redirect\" &&\n\t\t\t\t\tresult.hard &&\n\t\t\t\t\tf.intent.kind === \"reval\"\n\t\t\t\t) {\n\t\t\t\t\tmark_refresh_build_skew();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (result.kind === \"error\") {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (result.kind === \"redirect\") {\n\t\t\t\tnav_transferred = handle_redirect(f, result) === \"transferred\";\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst payload = decode_payload(result.data, f.url);\n\t\t\tpreload_modules(payload.deps);\n\n\t\t\tawait f.prepare_ready;\n\t\t\tif (!can_commit(f)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prepared = await prepare_route(\n\t\t\t\tpayload,\n\t\t\t\tf.cl_prefetches,\n\t\t\t\tf.intent.kind === \"reval\" ? \"revalidation\" : \"navigation\",\n\t\t\t\tf.url.href,\n\t\t\t\thistory_state_for_fetch(f.intent),\n\t\t\t\tf.ac.signal,\n\t\t\t);\n\t\t\tif (!prepared || !can_commit(f)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst was_published = await publish(f, prepared);\n\t\t\tif (was_published) {\n\t\t\t\tpublished = true;\n\t\t\t\tlast_activity_ts = Date.now();\n\t\t\t\tmark_fresh(f);\n\t\t\t}\n\t\t} catch {\n\t\t\t// swallow\n\t\t} finally {\n\t\t\tif (f.intent.kind === \"nav\" && !nav_transferred) {\n\t\t\t\tresolve_nav(f, { didNavigate: published });\n\t\t\t}\n\t\t\tif (active === f) {\n\t\t\t\tactive = null;\n\t\t\t}\n\t\t\tnotify_work_update();\n\t\t\tmaybe_revalidate();\n\t\t}\n\t}\n\n\t// Publish a prepared route. Clears `active` as soon as the commit lands\n\t// inside the view transition so subsequent same-page navs can fire\n\t// while the transition animation is still running. Returns true if the\n\t// commit actually happened (it may be superseded mid-callback).\n\tasync function publish(\n\t\tf: ActiveFetch,\n\t\tprepared: PreparedRoute,\n\t): Promise<boolean> {\n\t\tconst commit_reason: Exclude<RouteUpdateReason, \"boot\"> =\n\t\t\tf.intent.kind === \"reval\"\n\t\t\t\t? \"revalidation\"\n\t\t\t\t: f.intent.options.is_popstate\n\t\t\t\t\t? \"popstate\"\n\t\t\t\t\t: \"navigation\";\n\n\t\tconst prev_snapshot = route_snapshot;\n\t\tif (!prev_snapshot) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst next_href =\n\t\t\tf.intent.kind === \"nav\"\n\t\t\t\t? f.intent.url.href\n\t\t\t\t: prev_snapshot.position.href;\n\t\tconst next_history_state =\n\t\t\tf.intent.kind === \"nav\"\n\t\t\t\t? f.intent.options.is_popstate\n\t\t\t\t\t? browser.state\n\t\t\t\t\t: f.intent.options.state\n\t\t\t\t: prev_snapshot.position.state;\n\t\tconst yield_hooks = prev_snapshot.route.matches\n\t\t\t.map((m) => {\n\t\t\t\treturn (m.module.default as ViewDefinition | undefined)\n\t\t\t\t\t?.before_route_yield;\n\t\t\t})\n\t\t\t.filter((h): h is BeforeRouteYieldFn => {\n\t\t\t\treturn typeof h === \"function\";\n\t\t\t});\n\t\tconst commit_hooks = prepared.route.matches\n\t\t\t.map((m) => {\n\t\t\t\treturn (m.module.default as ViewDefinition | undefined)\n\t\t\t\t\t?.before_route_commit;\n\t\t\t})\n\t\t\t.filter((h): h is BeforeRouteCommitFn => {\n\t\t\t\treturn typeof h === \"function\";\n\t\t\t});\n\t\tif (yield_hooks.length > 0 || commit_hooks.length > 0) {\n\t\t\tconst current = route_snapshot_to_state(prev_snapshot);\n\t\t\tconst next = route_record_to_state(\n\t\t\t\tprepared.route,\n\t\t\t\tnext_href,\n\t\t\t\tnext_history_state,\n\t\t\t);\n\t\t\tawait Promise.all(\n\t\t\t\tyield_hooks\n\t\t\t\t\t.map((h) => {\n\t\t\t\t\t\treturn h({\n\t\t\t\t\t\t\ttrigger: commit_reason,\n\t\t\t\t\t\t\tsignal: f.ac.signal,\n\t\t\t\t\t\t\tcurrent,\n\t\t\t\t\t\t\tnext,\n\t\t\t\t\t\t});\n\t\t\t\t\t})\n\t\t\t\t\t.concat(\n\t\t\t\t\t\tcommit_hooks.map((h) => {\n\t\t\t\t\t\t\treturn h({\n\t\t\t\t\t\t\t\ttrigger: commit_reason,\n\t\t\t\t\t\t\t\tsignal: f.ac.signal,\n\t\t\t\t\t\t\t\tcurrent,\n\t\t\t\t\t\t\t\tnext,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (!can_commit(f)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tlet did_publish = false;\n\n\t\tconst do_publish = () => {\n\t\t\tif (!can_commit(f)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet position: HistoryPosition;\n\t\t\tif (f.intent.kind === \"nav\" && !f.intent.options.is_popstate) {\n\t\t\t\tsave_current_scroll();\n\t\t\t\tposition = commit_history(\n\t\t\t\t\tf.intent.url.href,\n\t\t\t\t\tf.intent.options.replace,\n\t\t\t\t\tf.intent.options.state,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// popstate: browser already at the new URL; revalidation: URL unchanged\n\t\t\t\tposition = browser;\n\t\t\t}\n\n\t\t\tconst prev = route_snapshot;\n\t\t\tprepared.apply_dom_side_effects();\n\t\t\troute_snapshot = { position, route: prepared.route };\n\n\t\t\tlet scroll_intent: ScrollIntent | undefined;\n\t\t\tif (f.intent.kind === \"nav\") {\n\t\t\t\tlet ss: ScrollState | undefined;\n\t\t\t\tif (f.intent.options.is_popstate) {\n\t\t\t\t\tif (normalize_hash(f.intent.url.hash).length > 0) {\n\t\t\t\t\t\tss = { hash: f.intent.url.hash };\n\t\t\t\t\t} else {\n\t\t\t\t\t\tss = f.intent.options.popstate_scroll ?? { x: 0, y: 0 };\n\t\t\t\t\t}\n\t\t\t\t} else if (normalize_hash(f.intent.url.hash).length > 0) {\n\t\t\t\t\tss = { hash: f.intent.url.hash };\n\t\t\t\t} else if (f.intent.options.scroll_to_top !== false) {\n\t\t\t\t\tss = { x: 0, y: 0 };\n\t\t\t\t}\n\t\t\t\tif (ss) {\n\t\t\t\t\tscroll_intent = {\n\t\t\t\t\t\tscroll: ss,\n\t\t\t\t\t\ttarget_route_id: make_route_id(\n\t\t\t\t\t\t\tprepared.route.matches.length - 1,\n\t\t\t\t\t\t\tprepared.route.matches[\n\t\t\t\t\t\t\t\tprepared.route.matches.length - 1\n\t\t\t\t\t\t\t]?.pattern ?? \"\",\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tactive = null;\n\t\t\tcommit_route_snapshot(\n\t\t\t\tcommit_reason,\n\t\t\t\tprev,\n\t\t\t\troute_snapshot,\n\t\t\t\tscroll_intent,\n\t\t\t\ttake_work_update(),\n\t\t\t);\n\t\t\tdid_publish = true;\n\t\t};\n\n\t\tconst vt = (document as any).startViewTransition;\n\t\tif (\n\t\t\tf.intent.kind === \"nav\" &&\n\t\t\tuse_view_transitions &&\n\t\t\ttypeof vt === \"function\"\n\t\t) {\n\t\t\tconst transition = vt.call(document, do_publish);\n\t\t\t// Prefer updateCallbackDone (modern API); fall back to finished.\n\t\t\tawait (transition.updateCallbackDone ?? transition.finished);\n\t\t\tif (transition.finished) {\n\t\t\t\tawait transition.finished;\n\t\t\t}\n\t\t} else {\n\t\t\tdo_publish();\n\t\t}\n\t\treturn did_publish;\n\t}\n\n\tfunction route_to_render_state(\n\t\troute: RouteRecord,\n\t\thistory_state: unknown,\n\t): RouteRenderState {\n\t\treturn {\n\t\t\tentries: route.matches.map((m) => {\n\t\t\t\treturn {\n\t\t\t\t\tpattern: m.pattern,\n\t\t\t\t\tinput: m.input,\n\t\t\t\t\tmodule_url: m.module_url,\n\t\t\t\t\tmodule: m.module,\n\t\t\t\t\tloader_data: m.loader_data,\n\t\t\t\t\tclient_loader_data: m.client_loader_data,\n\t\t\t\t};\n\t\t\t}),\n\t\t\terror: route.error,\n\t\t\tparams: route.params,\n\t\t\tsplat_values: route.splat_values,\n\t\t\tclient_build_id: route.client_build_id,\n\t\t\thistory_state,\n\t\t};\n\t}\n\n\tfunction route_snapshot_to_state(snapshot: RouteSnapshot): RouteState {\n\t\treturn route_record_to_state(\n\t\t\tsnapshot.route,\n\t\t\tsnapshot.position.href,\n\t\t\tsnapshot.position.state,\n\t\t);\n\t}\n\n\tfunction route_record_to_state(\n\t\troute: RouteRecord,\n\t\thref: string,\n\t\thistory_state: unknown,\n\t): RouteState {\n\t\treturn {\n\t\t\thref,\n\t\t\thistoryState: history_state,\n\t\t\tclientBuildID: route.client_build_id,\n\t\t\tparams: route.params,\n\t\t\tsplatValues: route.splat_values,\n\t\t\tmatches: route.matches.map((m) => {\n\t\t\t\treturn {\n\t\t\t\t\tpattern: m.pattern,\n\t\t\t\t\tinput: m.input,\n\t\t\t\t\tloaderData: m.loader_data,\n\t\t\t\t\tclientLoaderData: m.client_loader_data,\n\t\t\t\t};\n\t\t\t}),\n\t\t\terror: route.error,\n\t\t};\n\t}\n\n\tfunction to_route_update_reason(\n\t\treason: RouteRenderCommitReason,\n\t): RouteUpdateReason {\n\t\tif (reason === \"initial\") {\n\t\t\treturn \"boot\";\n\t\t}\n\t\tif (reason === \"hmr\") {\n\t\t\treturn \"revalidation\";\n\t\t}\n\t\treturn reason;\n\t}\n\n\tfunction commit_route_snapshot(\n\t\treason: RouteRenderCommitReason,\n\t\tprev: RouteSnapshot | null,\n\t\tnext: RouteSnapshot,\n\t\tscroll_intent?: ScrollIntent,\n\t\twork?: WorkState,\n\t): void {\n\t\tconst previous_route = prev ? route_snapshot_to_state(prev) : null;\n\t\tconst route = route_snapshot_to_state(next);\n\t\tconst client_commit: ClientCommit = {\n\t\t\troute_render: {\n\t\t\t\tstate: route_to_render_state(next.route, next.position.state),\n\t\t\t\tscroll_intent,\n\t\t\t},\n\t\t\twork,\n\t\t};\n\t\tif (!previous_route || !jsonDeepEquals(previous_route, route)) {\n\t\t\tclient_commit.route_update = {\n\t\t\t\tprevious_route,\n\t\t\t\treason: to_route_update_reason(reason),\n\t\t\t\troute,\n\t\t\t};\n\t\t}\n\t\temit_client_commit(client_commit);\n\t}\n\n\tfunction handle_redirect(\n\t\tf: ActiveFetch,\n\t\tredirect: Extract<FetchResult, { kind: \"redirect\" }>,\n\t): RedirectResult {\n\t\tconst nav_intent = f.intent.kind === \"nav\" ? f.intent : null;\n\n\t\t// Invalid scheme: treat as failure for nav, no-op otherwise.\n\t\tif (!is_http(redirect.href)) {\n\t\t\tif (nav_intent) {\n\t\t\t\tnav_intent.deferred.resolve({ didNavigate: false });\n\t\t\t}\n\t\t\tactive = null;\n\t\t\treturn \"settled\";\n\t\t}\n\n\t\t// Hard redirect or cross-origin: leave the page.\n\t\tif (redirect.hard || !is_same_origin_href(redirect.href)) {\n\t\t\thard_redirect(redirect.href);\n\t\t\tif (nav_intent) {\n\t\t\t\tnav_intent.deferred.resolve({ didNavigate: false });\n\t\t\t}\n\t\t\tactive = null;\n\t\t\treturn \"settled\";\n\t\t}\n\n\t\t// Redirect loop guard (only meaningful for nav, which tracks count).\n\t\tif (nav_intent && nav_intent.redirect_count >= MAX_REDIRECTS) {\n\t\t\tnav_intent.deferred.resolve({ didNavigate: false });\n\t\t\tactive = null;\n\t\t\treturn \"settled\";\n\t\t}\n\n\t\tconst target = new URL(redirect.href);\n\t\tactive = null;\n\n\t\t// Same-page redirect (same path, maybe different hash): no re-fetch,\n\t\t// just handle as same-page nav.\n\t\tif (route_snapshot_matches(target)) {\n\t\t\tconst result = handle_same_page_nav(\n\t\t\t\ttarget,\n\t\t\t\tnav_intent?.options ?? {},\n\t\t\t);\n\t\t\tif (nav_intent) {\n\t\t\t\tnav_intent.deferred.resolve(result);\n\t\t\t}\n\t\t\treturn \"settled\";\n\t\t}\n\n\t\t// Continue nav chain at redirect target.\n\t\tif (nav_intent) {\n\t\t\tvoid start_nav_inner(\n\t\t\t\ttarget,\n\t\t\t\tnav_intent.options,\n\t\t\t\tnav_intent.redirect_count + 1,\n\t\t\t\t{\n\t\t\t\t\treuse_deferred: nav_intent.deferred,\n\t\t\t\t\tsource: \"redirect\",\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn \"transferred\";\n\t\t} else {\n\t\t\t// Revalidation redirect becomes a replace navigation.\n\t\t\tvoid start_nav_inner(target, { replace: true }, 0, {\n\t\t\t\tsource: \"redirect\",\n\t\t\t});\n\t\t\treturn \"settled\";\n\t\t}\n\t}\n\n\t/////// Navigation Entry\n\n\tfunction try_merge_active_nav(\n\t\turl: URL,\n\t\toptions: NavOptions,\n\t\tsource: NavigationSource,\n\t\tdeferred: Deferred<NavResult>,\n\t): boolean {\n\t\tif (\n\t\t\t!active ||\n\t\t\tactive.intent.kind !== \"nav\" ||\n\t\t\t!matches_without_hash(active.url, url)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Identical intent: share the result promise.\n\t\tconst cur = active.intent;\n\t\tif (\n\t\t\tcur.url.href === url.href &&\n\t\t\tcur.options.replace === options.replace &&\n\t\t\tcur.options.scroll_to_top === options.scroll_to_top &&\n\t\t\tcur.options.state === options.state &&\n\t\t\tcur.options.is_popstate === options.is_popstate &&\n\t\t\tcur.options.popstate_scroll === options.popstate_scroll &&\n\t\t\tcur.options.skip_work_indicator === options.skip_work_indicator &&\n\t\t\tcur.source === source\n\t\t) {\n\t\t\tcur.deferred.promise.then(deferred.resolve, () =>\n\t\t\t\tdeferred.resolve({ didNavigate: false }),\n\t\t\t);\n\t\t\treturn true;\n\t\t}\n\n\t\t// Same path, different hash or options: swap the request.\n\t\tcur.deferred.resolve({ didNavigate: false });\n\t\tactive.intent = {\n\t\t\tkind: \"nav\",\n\t\t\turl,\n\t\t\toptions,\n\t\t\tsource,\n\t\t\tredirect_count: cur.redirect_count,\n\t\t\tdeferred,\n\t\t};\n\t\tnotify_work_update();\n\t\treturn true;\n\t}\n\n\tfunction cancel_prefetch(): void {\n\t\tif (prefetch) {\n\t\t\tconst p = prefetch;\n\t\t\tprefetch = null;\n\t\t\tp.ac.abort();\n\t\t\tnotify_work_update();\n\t\t}\n\t}\n\n\tfunction handle_same_page_nav(url: URL, options: NavOptions): NavResult {\n\t\tif (!route_snapshot) {\n\t\t\treturn { didNavigate: false };\n\t\t}\n\t\tconst cur_url = new URL(route_snapshot.position.href);\n\t\tconst target_hash = normalize_hash(url.hash);\n\t\tconst current_hash = normalize_hash(cur_url.hash);\n\n\t\tif (target_hash !== current_hash) {\n\t\t\tsave_current_scroll();\n\t\t\tconst position = commit_history(\n\t\t\t\turl.href,\n\t\t\t\toptions.replace,\n\t\t\t\toptions.state,\n\t\t\t);\n\t\t\tconst prev = route_snapshot;\n\t\t\troute_snapshot = { position, route: route_snapshot.route };\n\t\t\tcommit_route_snapshot(\"navigation\", prev, route_snapshot);\n\t\t\tapply_scroll(\n\t\t\t\ttarget_hash.length > 0 ? { hash: url.hash } : { x: 0, y: 0 },\n\t\t\t\ttest_options,\n\t\t\t);\n\t\t\treturn { didNavigate: true };\n\t\t}\n\n\t\tif (options.replace) {\n\t\t\tconst position = commit_history(url.href, true, options.state);\n\t\t\tconst prev = route_snapshot;\n\t\t\troute_snapshot = { position, route: route_snapshot.route };\n\t\t\tcommit_route_snapshot(\"navigation\", prev, route_snapshot);\n\t\t}\n\t\tapply_scroll({ x: 0, y: 0 }, test_options);\n\t\treturn { didNavigate: false };\n\t}\n\n\tfunction start_nav_inner(\n\t\turl: URL,\n\t\toptions: NavOptions,\n\t\tredirect_count: number,\n\t\treuse?: {\n\t\t\treuse_deferred?: Deferred<NavResult>;\n\t\t\tsource?: NavigationSource;\n\t\t},\n\t): Promise<NavResult> {\n\t\tconst deferred = reuse?.reuse_deferred ?? make_deferred<NavResult>();\n\t\tconst source =\n\t\t\treuse?.source ?? (options.is_popstate ? \"popstate\" : \"navigate\");\n\n\t\t// Same-page short-circuit (not for popstate, which always owns the commit).\n\t\tif (!options.is_popstate && route_snapshot_matches(url)) {\n\t\t\tconst result = handle_same_page_nav(url, options);\n\t\t\tdeferred.resolve(result);\n\t\t\treturn deferred.promise;\n\t\t}\n\n\t\t// Merge into active nav if URLs match by path.\n\t\tif (try_merge_active_nav(url, options, source, deferred)) {\n\t\t\treturn deferred.promise;\n\t\t}\n\n\t\t// Supersede any other active work.\n\t\tif (active) {\n\t\t\tconst prev = active;\n\t\t\tactive = null;\n\t\t\tresolve_nav(prev, { didNavigate: false });\n\t\t\tprev.ac.abort();\n\t\t}\n\n\t\t// Promote matching prefetch if present.\n\t\tlet promoted: PrefetchFetch | null = null;\n\t\tif (prefetch && matches_without_hash(prefetch.url, url)) {\n\t\t\tpromoted = prefetch;\n\t\t\tprefetch = null;\n\t\t}\n\t\tconst fetch_record: ActiveFetch = promoted\n\t\t\t? {\n\t\t\t\t\t...promoted,\n\t\t\t\t\tintent: {\n\t\t\t\t\t\tkind: \"nav\",\n\t\t\t\t\t\turl,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tredirect_count,\n\t\t\t\t\t\tdeferred,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: (cancel_prefetch(),\n\t\t\t\tstart_fetch(\n\t\t\t\t\turl,\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"nav\",\n\t\t\t\t\t\turl,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tredirect_count,\n\t\t\t\t\t\tdeferred,\n\t\t\t\t\t},\n\t\t\t\t\tfalse,\n\t\t\t\t));\n\n\t\tvoid run_active(fetch_record);\n\t\treturn deferred.promise;\n\t}\n\n\t/////// Refresh\n\n\tfunction mark_fresh(f: ActiveFetch): void {\n\t\tconst demand = refresh_demand();\n\t\tif (!demand) {\n\t\t\treturn;\n\t\t}\n\t\tif (f.seq <= demand.after_seq) {\n\t\t\treturn;\n\t\t}\n\t\tconst waiters = demand.waiters;\n\t\tclear_refresh();\n\t\tfor (const w of waiters) {\n\t\t\tw.resolve(REVALIDATION_OK);\n\t\t}\n\t}\n\n\tfunction mark_refresh_build_skew(): void {\n\t\tconst demand = refresh_demand();\n\t\tif (!demand) {\n\t\t\treturn;\n\t\t}\n\t\tconst waiters = demand.waiters;\n\t\tclear_refresh();\n\t\tfor (const w of waiters) {\n\t\t\tw.resolve(REVALIDATION_BUILD_SKEW);\n\t\t}\n\t}\n\n\tfunction refresh_demand(): RefreshDemand | null {\n\t\tif (refresh.kind === \"idle\") {\n\t\t\treturn null;\n\t\t}\n\t\treturn refresh.demand;\n\t}\n\n\tfunction clear_refresh(): void {\n\t\tif (refresh.kind === \"debouncing\" || refresh.kind === \"retrying\") {\n\t\t\tclearTimeout(refresh.timer);\n\t\t}\n\t\trefresh = { kind: \"idle\" };\n\t}\n\n\tfunction require_refresh(\n\t\treason: RevalidationReason,\n\t\twaiter?: RefreshWaiter,\n\t\tdebounce?: boolean,\n\t\tskip_work_indicator?: boolean,\n\t): void {\n\t\tconst previous_demand = refresh_demand();\n\t\tconst waiters = previous_demand?.waiters ?? [];\n\t\tclear_refresh();\n\t\tif (waiter) {\n\t\t\twaiters.push(waiter);\n\t\t}\n\t\tconst demand: RefreshDemand = {\n\t\t\tafter_seq: next_seq(),\n\t\t\treason,\n\t\t\tskip_work_indicator:\n\t\t\t\t(previous_demand?.skip_work_indicator ?? true) &&\n\t\t\t\tskip_work_indicator === true,\n\t\t\twaiters,\n\t\t};\n\n\t\tif (debounce) {\n\t\t\tlet next_refresh!: Extract<RefreshState, { kind: \"debouncing\" }>;\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tif (refresh !== next_refresh) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\trefresh = { kind: \"pending\", demand, attempt: 0 };\n\t\t\t\tmaybe_revalidate();\n\t\t\t}, REVALIDATION_DEBOUNCE_MS);\n\t\t\tnext_refresh = { kind: \"debouncing\", demand, timer };\n\t\t\trefresh = next_refresh;\n\t\t} else {\n\t\t\trefresh = { kind: \"pending\", demand, attempt: 0 };\n\t\t}\n\t}\n\n\tfunction active_will_refresh(): boolean {\n\t\tconst demand = refresh_demand();\n\t\treturn (\n\t\t\tactive !== null && demand !== null && active.seq > demand.after_seq\n\t\t);\n\t}\n\n\tfunction maybe_revalidate(): void {\n\t\tif (phase !== \"ready\") {\n\t\t\treturn;\n\t\t}\n\t\tif (refresh.kind === \"idle\") {\n\t\t\treturn;\n\t\t}\n\t\tif (refresh.kind === \"debouncing\") {\n\t\t\treturn;\n\t\t}\n\t\tif (active_will_refresh() || active) {\n\t\t\treturn;\n\t\t}\n\t\tif (refresh.kind === \"retrying\") {\n\t\t\treturn;\n\t\t}\n\n\t\tconst demand = refresh.demand;\n\t\tconst attempt = refresh.attempt;\n\t\tif (attempt >= MAX_REVALIDATION_RETRIES) {\n\t\t\tclear_refresh();\n\t\t\tfor (const w of demand.waiters) {\n\t\t\t\tw.resolve(REVALIDATION_EXHAUSTED);\n\t\t\t}\n\t\t\tnotify_work_update();\n\t\t\treturn;\n\t\t}\n\n\t\tconst delay =\n\t\t\tattempt === 0\n\t\t\t\t? 0\n\t\t\t\t: Math.min(\n\t\t\t\t\t\tREVALIDATION_BACKOFF_BASE_MS * Math.pow(2, attempt - 1),\n\t\t\t\t\t\tREVALIDATION_BACKOFF_CAP_MS,\n\t\t\t\t\t);\n\n\t\tif (delay === 0) {\n\t\t\trefresh = { kind: \"pending\", demand, attempt: attempt + 1 };\n\t\t\tvoid run_revalidation().catch(() => {});\n\t\t} else {\n\t\t\tconst retry_demand: RefreshDemand = {\n\t\t\t\t...demand,\n\t\t\t\treason: \"retry\",\n\t\t\t};\n\t\t\tlet next_refresh!: Extract<RefreshState, { kind: \"retrying\" }>;\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tif (refresh !== next_refresh) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\trefresh = {\n\t\t\t\t\tkind: \"pending\",\n\t\t\t\t\tdemand: retry_demand,\n\t\t\t\t\tattempt: attempt + 1,\n\t\t\t\t};\n\t\t\t\tif (active) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tvoid run_revalidation().catch(() => {});\n\t\t\t}, delay);\n\t\t\tnext_refresh = {\n\t\t\t\tkind: \"retrying\",\n\t\t\t\tdemand: retry_demand,\n\t\t\t\tattempt: attempt + 1,\n\t\t\t\ttimer,\n\t\t\t};\n\t\t\trefresh = next_refresh;\n\t\t\tnotify_work_update();\n\t\t}\n\t}\n\n\tasync function run_revalidation(): Promise<void> {\n\t\tconst url = new URL(browser.href || window.location.href);\n\t\tconst attempt = refresh.kind === \"pending\" ? refresh.attempt : 0;\n\t\tconst reason =\n\t\t\trefresh.kind === \"pending\" ? refresh.demand.reason : \"manual\";\n\t\tconst skip_work_indicator =\n\t\t\trefresh.kind === \"pending\"\n\t\t\t\t? refresh.demand.skip_work_indicator\n\t\t\t\t: undefined;\n\t\tconst f = start_fetch(\n\t\t\turl,\n\t\t\t{ kind: \"reval\", attempt, reason, skip_work_indicator },\n\t\t\ttrue,\n\t\t);\n\n\t\t// Guard: discard if URL path changes during flight (hash-only changes\n\t\t// are OK; matches_without_hash on publish time handles it).\n\t\tawait run_active_with_url_guard(f, url);\n\t}\n\n\tasync function run_active_with_url_guard(\n\t\tf: ActiveFetch,\n\t\texpected: URL,\n\t): Promise<void> {\n\t\tactive = f;\n\t\tnotify_work_update();\n\n\t\ttry {\n\t\t\tconst result = await f.data_promise;\n\t\t\tif (!can_commit(f)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!matches_without_hash(new URL(browser.href), expected)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (result.kind === \"build_skew\") {\n\t\t\t\treport_route_build_skew(f, result.response, \"dropResponse\");\n\t\t\t\tmark_refresh_build_skew();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (result.response) {\n\t\t\t\tconst default_behavior =\n\t\t\t\t\tresult.kind === \"redirect\" &&\n\t\t\t\t\tresult.hard &&\n\t\t\t\t\tis_http(result.href)\n\t\t\t\t\t\t? \"dropResponse\"\n\t\t\t\t\t\t: \"notifyOnly\";\n\t\t\t\tconst did_detect_skew = report_route_build_skew(\n\t\t\t\t\tf,\n\t\t\t\t\tresult.response,\n\t\t\t\t\tdefault_behavior,\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tdid_detect_skew &&\n\t\t\t\t\tresult.kind === \"redirect\" &&\n\t\t\t\t\tresult.hard\n\t\t\t\t) {\n\t\t\t\t\tmark_refresh_build_skew();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (result.kind === \"error\") {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (result.kind === \"redirect\") {\n\t\t\t\thandle_redirect(f, result);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst payload = decode_payload(result.data, f.url);\n\t\t\tpreload_modules(payload.deps);\n\n\t\t\tconst prepared = await prepare_route(\n\t\t\t\tpayload,\n\t\t\t\tf.cl_prefetches,\n\t\t\t\t\"revalidation\",\n\t\t\t\tf.url.href,\n\t\t\t\thistory_state_for_fetch(f.intent),\n\t\t\t\tf.ac.signal,\n\t\t\t);\n\t\t\tif (!prepared || !can_commit(f)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!matches_without_hash(new URL(browser.href), expected)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst did_publish = await publish(f, prepared);\n\t\t\tif (did_publish) {\n\t\t\t\tlast_activity_ts = Date.now();\n\t\t\t\tmark_fresh(f);\n\t\t\t}\n\t\t} catch {\n\t\t\t// swallow\n\t\t} finally {\n\t\t\tif (active === f) {\n\t\t\t\tactive = null;\n\t\t\t}\n\t\t\tnotify_work_update();\n\t\t\tmaybe_revalidate();\n\t\t}\n\t}\n\n\t/////// Prefetch\n\n\tasync function prepare_prefetch(f: PrefetchFetch): Promise<void> {\n\t\ttry {\n\t\t\tconst result = await f.data_promise;\n\t\t\tif (result.response) {\n\t\t\t\treport_route_build_skew(\n\t\t\t\t\tf,\n\t\t\t\t\tresult.response,\n\t\t\t\t\tresult.kind === \"data\" ? \"notifyOnly\" : \"dropResponse\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (f.ac.signal.aborted || result.kind !== \"data\") {\n\t\t\t\tif (prefetch === f) {\n\t\t\t\t\tprefetch = null;\n\t\t\t\t\tnotify_work_update();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst payload = decode_payload(result.data, f.url);\n\t\t\tpreload_modules(payload.deps);\n\t\t\tconst modules = await prepare_modules(payload, f.ac.signal);\n\t\t\tif (!modules || f.ac.signal.aborted) {\n\t\t\t\tif (prefetch === f) {\n\t\t\t\t\tprefetch = null;\n\t\t\t\t\tnotify_work_update();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst by_pattern = new Map<string, ClientLoaderPrefetch>();\n\t\t\tfor (const p of f.cl_prefetches) {\n\t\t\t\tby_pattern.set(p.pattern, p);\n\t\t\t}\n\t\t\tconst err_idx = payload.routes.findIndex((r) => {\n\t\t\t\treturn r.server_error !== undefined;\n\t\t\t});\n\t\t\tconst known_matches = routes_to_known_matches(payload.routes);\n\t\t\tconst next_cl_prefetches: ClientLoaderPrefetch[] = [];\n\t\t\tconst retained_prefetches = new Set<ClientLoaderPrefetch>();\n\t\t\tfor (let i = 0; i < payload.routes.length; i++) {\n\t\t\t\tconst route = payload.routes[i]!;\n\t\t\t\tconst existing = by_pattern.get(route.pattern);\n\t\t\t\tif (err_idx !== -1 && i >= err_idx) {\n\t\t\t\t\texisting?.abort();\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (existing) {\n\t\t\t\t\texisting.resolve_server_state(\n\t\t\t\t\t\tbuild_server_state(payload.routes, i),\n\t\t\t\t\t);\n\t\t\t\t\tnext_cl_prefetches.push(existing);\n\t\t\t\t\tretained_prefetches.add(existing);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst loader = module_map[route.pattern];\n\t\t\t\tif (!loader) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst p = make_cl_prefetch({\n\t\t\t\t\thref: f.url.href,\n\t\t\t\t\thistory_state: undefined,\n\t\t\t\t\tknown_matches,\n\t\t\t\t\tloader,\n\t\t\t\t\tparams: payload.params,\n\t\t\t\t\tpattern: route.pattern,\n\t\t\t\t\troute_input: route.input,\n\t\t\t\t\tsignal: f.ac.signal,\n\t\t\t\t\tsplat_values: payload.splat_values,\n\t\t\t\t\ttrigger: \"prefetch\",\n\t\t\t\t});\n\t\t\t\tp.resolve_server_state(build_server_state(payload.routes, i));\n\t\t\t\tnext_cl_prefetches.push(p);\n\t\t\t\tretained_prefetches.add(p);\n\t\t\t}\n\t\t\tfor (const p of f.cl_prefetches) {\n\t\t\t\tif (!retained_prefetches.has(p)) {\n\t\t\t\t\tp.abort();\n\t\t\t\t}\n\t\t\t}\n\t\t\tf.cl_prefetches = next_cl_prefetches;\n\t\t} catch {\n\t\t\tif (prefetch === f) {\n\t\t\t\tprefetch = null;\n\t\t\t\tnotify_work_update();\n\t\t\t}\n\t\t} finally {\n\t\t\tif (f.is_pending) {\n\t\t\t\tf.is_pending = false;\n\t\t\t\tnotify_work_update();\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction start_prefetch(href: string): void {\n\t\tif (phase !== \"ready\") {\n\t\t\treturn;\n\t\t}\n\t\tconst url = new URL(href, window.location.href);\n\t\tif (!is_same_origin(url) || route_snapshot_matches(url)) {\n\t\t\treturn;\n\t\t}\n\t\tif (\n\t\t\tactive?.intent.kind === \"nav\" &&\n\t\t\tmatches_without_hash(active.url, url)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tif (prefetch && matches_without_hash(prefetch.url, url)) {\n\t\t\treturn;\n\t\t}\n\t\tcancel_prefetch();\n\n\t\t// Prefetch's prepare_ready resolves when modules + CL seeding are done.\n\t\tlet resolve_prepare!: () => void;\n\t\tconst prepare_ready = new Promise<void>((r) => {\n\t\t\tresolve_prepare = r;\n\t\t});\n\n\t\tconst f: PrefetchFetch = {\n\t\t\t...start_fetch(url, { kind: \"prefetch\" }, false, prepare_ready),\n\t\t\tis_pending: true,\n\t\t};\n\t\tprefetch = f;\n\t\tnotify_work_update();\n\t\tvoid prepare_prefetch(f).finally(() => resolve_prepare());\n\t}\n\n\tfunction stop_prefetch(href: string): void {\n\t\tconst url = new URL(href, window.location.href);\n\t\tif (prefetch && matches_without_hash(prefetch.url, url)) {\n\t\t\tcancel_prefetch();\n\t\t}\n\t}\n\n\t/////// Submit\n\n\tasync function submit_inner<T = unknown>(\n\t\turl: string | URL,\n\t\trequest_init?: RequestInit,\n\t\toptions?: {\n\t\t\tapiRouteKind?: APIRouteKind;\n\t\t\tdedupeKey?: string;\n\t\t\trevalidate?: boolean;\n\t\t\tskipWorkIndicator?: boolean;\n\t\t},\n\t): Promise<APIResult<T>> {\n\t\tif (!route_snapshot) {\n\t\t\tthrow new Error(\"Vorma not booted\");\n\t\t}\n\t\tconst resolved = new URL(String(url), window.location.href);\n\n\t\tif (!is_same_origin(resolved)) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: `submit only supports same-origin targets. Received: \"${resolved.href}\".`,\n\t\t\t\trevalidationPromise: Promise.resolve(REVALIDATION_OK),\n\t\t\t};\n\t\t}\n\n\t\tconst method = request_init?.method\n\t\t\t? request_init.method.toUpperCase().trim()\n\t\t\t: \"GET\";\n\t\tconst api_route_kind =\n\t\t\toptions?.apiRouteKind ??\n\t\t\t(method === \"GET\" || method === \"HEAD\" ? \"query\" : \"mutation\");\n\t\tlet should_revalidate = api_route_kind === \"mutation\";\n\t\tif (options?.revalidate !== undefined) {\n\t\t\tshould_revalidate = options.revalidate;\n\t\t}\n\n\t\tlet dedupe_key = options?.dedupeKey;\n\t\tif (dedupe_key) {\n\t\t\tsubmissions.get(dedupe_key)?.ac.abort();\n\t\t} else {\n\t\t\tdedupe_key = crypto.randomUUID();\n\t\t}\n\n\t\tconst ac = new AbortController();\n\t\tconst sub: Submission = {\n\t\t\tac,\n\t\t\tkey: dedupe_key,\n\t\t\tmethod,\n\t\t\thref: resolved.href,\n\t\t\tskip_work_indicator: options?.skipWorkIndicator,\n\t\t};\n\t\tsubmissions.set(dedupe_key, sub);\n\t\tnotify_work_update();\n\n\t\tlet revalidation_promise: Promise<RevalidationResult> =\n\t\t\tPromise.resolve(REVALIDATION_OK);\n\t\tlet did_dispatch = false;\n\n\t\tfunction schedule_revalidation(): void {\n\t\t\tif (!should_revalidate) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (phase === \"ready\") {\n\t\t\t\tconst waiter = make_deferred<RevalidationResult>();\n\t\t\t\trevalidation_promise = waiter.promise;\n\t\t\t\trequire_refresh(\n\t\t\t\t\t\"apiRequest\",\n\t\t\t\t\twaiter,\n\t\t\t\t\tundefined,\n\t\t\t\t\toptions?.skipWorkIndicator,\n\t\t\t\t);\n\t\t\t\tmaybe_revalidate();\n\t\t\t} else {\n\t\t\t\t// During boot, register refresh demand so post-boot\n\t\t\t\t// maybe_revalidate will fire. Do not attach a waiter;\n\t\t\t\t// the returned revalidationPromise stays resolved so initial\n\t\t\t\t// client loaders awaiting it do not deadlock.\n\t\t\t\trequire_refresh(\n\t\t\t\t\t\"apiRequest\",\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t\toptions?.skipWorkIndicator,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tconst is_get = method === \"GET\" || method === \"HEAD\";\n\n\t\t\tconst headers = new Headers();\n\t\t\tif (deployment_id) {\n\t\t\t\theaders.set(VERCEL_X_DEPLOYMENT_ID, deployment_id);\n\t\t\t}\n\t\t\tnew Headers(request_init?.headers ?? undefined).forEach((v, k) => {\n\t\t\t\theaders.set(k, v);\n\t\t\t});\n\t\t\theaders.set(X_ACCEPTS_CLIENT_REDIRECT, \"1\");\n\n\t\t\tconst body = request_init?.body;\n\t\t\tconst should_json =\n\t\t\t\t!is_get &&\n\t\t\t\tbody &&\n\t\t\t\ttypeof body === \"object\" &&\n\t\t\t\t!(body instanceof ReadableStream) &&\n\t\t\t\t!(body instanceof FormData) &&\n\t\t\t\t!(body instanceof URLSearchParams) &&\n\t\t\t\t!(body instanceof Blob) &&\n\t\t\t\t!(body instanceof ArrayBuffer) &&\n\t\t\t\t!ArrayBuffer.isView(body);\n\n\t\t\tconst final_init: RequestInit = {\n\t\t\t\t...request_init,\n\t\t\t\tmethod,\n\t\t\t\theaders,\n\t\t\t\tsignal: ac.signal,\n\t\t\t};\n\t\t\tif (is_get) {\n\t\t\t\tdelete final_init.body;\n\t\t\t} else if (should_json) {\n\t\t\t\tfinal_init.body = JSON.stringify(body);\n\t\t\t\tif (!headers.has(\"Content-Type\")) {\n\t\t\t\t\theaders.set(\"Content-Type\", \"application/json\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdid_dispatch = true;\n\t\t\tconst res = await fetch(resolved, final_init);\n\n\t\t\tconst redirect = detect_redirect(res, resolved);\n\t\t\treport_build_skew({\n\t\t\t\tresponse: res,\n\t\t\t\ttriggeringResponse: {\n\t\t\t\t\tkind: \"apiRoute\",\n\t\t\t\t\tapiRouteKind: api_route_kind,\n\t\t\t\t\trequestedHref: resolved.href,\n\t\t\t\t\tmethod,\n\t\t\t\t\tstatus: res.status,\n\t\t\t\t\tok: res.ok,\n\t\t\t\t},\n\t\t\t\tdefaultBehavior:\n\t\t\t\t\tredirect &&\n\t\t\t\t\tis_http(redirect.href) &&\n\t\t\t\t\t(redirect.hard || !is_same_origin_href(redirect.href))\n\t\t\t\t\t\t? \"hardReload\"\n\t\t\t\t\t\t: \"notifyOnly\",\n\t\t\t});\n\n\t\t\tif (redirect && !ac.signal.aborted) {\n\t\t\t\tif (!is_http(redirect.href)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\terror: `Redirect target must use an HTTP(S) scheme. Received: \"${redirect.href}\".`,\n\t\t\t\t\t\tresponse: res,\n\t\t\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (redirect.hard || !is_same_origin_href(redirect.href)) {\n\t\t\t\t\thard_redirect(redirect.href);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tdata: undefined as T,\n\t\t\t\t\t\tresponse: res,\n\t\t\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (phase !== \"ready\") {\n\t\t\t\t\tdeferred_submit_redirect = new URL(redirect.href);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tdata: undefined as T,\n\t\t\t\t\t\tresponse: res,\n\t\t\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tvoid start_nav_inner(\n\t\t\t\t\tnew URL(redirect.href),\n\t\t\t\t\t{ replace: true },\n\t\t\t\t\t0,\n\t\t\t\t\t{ source: \"redirect\" },\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tdata: undefined as T,\n\t\t\t\t\tresponse: res,\n\t\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (!res.ok) {\n\t\t\t\tschedule_revalidation();\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: res.statusText,\n\t\t\t\t\tresponse: res,\n\t\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet data: unknown;\n\t\t\tif (res.status !== 204) {\n\t\t\t\tconst ct = res.headers.get(\"Content-Type\");\n\t\t\t\tif (ct?.toLowerCase().includes(\"json\")) {\n\t\t\t\t\tdata = await res.json();\n\t\t\t\t} else {\n\t\t\t\t\tconst t = await res.text();\n\t\t\t\t\tdata = t.length > 0 ? t : undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tschedule_revalidation();\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: data as T,\n\t\t\t\tresponse: res,\n\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t};\n\t\t} catch (e) {\n\t\t\tif (is_abort_error(e)) {\n\t\t\t\tif (did_dispatch) {\n\t\t\t\t\tschedule_revalidation();\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: \"Aborted\",\n\t\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (did_dispatch) {\n\t\t\t\tschedule_revalidation();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: String(e instanceof Error ? e.message : e),\n\t\t\t\trevalidationPromise: revalidation_promise,\n\t\t\t};\n\t\t} finally {\n\t\t\tif (submissions.get(dedupe_key)?.ac === ac) {\n\t\t\t\tsubmissions.delete(dedupe_key);\n\t\t\t}\n\t\t\tnotify_work_update();\n\t\t}\n\t}\n\n\t/////// Popstate\n\n\tasync function handle_popstate(): Promise<void> {\n\t\tconst prev = browser;\n\t\tconst next = read_browser_position();\n\t\tif (next.key === prev.key && next.href === prev.href) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (prev.key && prev.key !== next.key) {\n\t\t\tsave_scroll_for_key(prev.key, get_scroll_pos());\n\t\t}\n\t\tbrowser = next;\n\n\t\tconst prev_url = new URL(prev.href);\n\t\tconst next_url = new URL(next.href);\n\n\t\t// Hash-only popstate on same path: scroll, no fetch.\n\t\tif (matches_without_hash(prev_url, next_url)) {\n\t\t\tif (route_snapshot) {\n\t\t\t\tconst prev_snapshot = route_snapshot;\n\t\t\t\troute_snapshot = {\n\t\t\t\t\tposition: browser,\n\t\t\t\t\troute: route_snapshot.route,\n\t\t\t\t};\n\t\t\t\tcommit_route_snapshot(\n\t\t\t\t\t\"popstate\",\n\t\t\t\t\tprev_snapshot,\n\t\t\t\t\troute_snapshot,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst hash = normalize_hash(next_url.hash);\n\t\t\tapply_scroll(\n\t\t\t\thash.length > 0\n\t\t\t\t\t? { hash: next_url.hash }\n\t\t\t\t\t: (get_scroll_for_key(next.key) ?? { x: 0, y: 0 }),\n\t\t\t\ttest_options,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst restored_scroll = get_scroll_for_key(next.key);\n\n\t\ttry {\n\t\t\tconst result = await start_nav_inner(\n\t\t\t\tnext_url,\n\t\t\t\t{ is_popstate: true, popstate_scroll: restored_scroll },\n\t\t\t\t0,\n\t\t\t);\n\t\t\tif (\n\t\t\t\t!result.didNavigate &&\n\t\t\t\t!active &&\n\t\t\t\t!route_snapshot_matches_browser()\n\t\t\t) {\n\t\t\t\treload_page();\n\t\t\t}\n\t\t} catch {\n\t\t\tif (!active && !route_snapshot_matches_browser()) {\n\t\t\t\treload_page();\n\t\t\t}\n\t\t}\n\t}\n\n\t/////// Status\n\n\tfunction derive_work_projection(): WorkProjection[] {\n\t\tconst work: WorkProjection[] = [];\n\n\t\tconst active_fetch = active;\n\t\tif (active_fetch?.intent.kind === \"nav\") {\n\t\t\twork.push({\n\t\t\t\tkind: \"navigation\",\n\t\t\t\tskip_work_indicator:\n\t\t\t\t\tactive_fetch.intent.options.skip_work_indicator,\n\t\t\t});\n\t\t}\n\n\t\tconst pending_revalidation =\n\t\t\trefresh.kind !== \"idle\" &&\n\t\t\t(refresh.kind === \"debouncing\" ||\n\t\t\t\trefresh.kind === \"retrying\" ||\n\t\t\t\t(!active_will_refresh() && !active));\n\t\tif (active_fetch?.intent.kind === \"reval\" || pending_revalidation) {\n\t\t\tconst revalidation_demand = refresh_demand();\n\t\t\twork.push({\n\t\t\t\tkind: \"revalidation\",\n\t\t\t\tskip_work_indicator:\n\t\t\t\t\tactive_fetch?.intent.kind === \"reval\"\n\t\t\t\t\t\t? active_fetch.intent.skip_work_indicator\n\t\t\t\t\t\t: revalidation_demand?.skip_work_indicator,\n\t\t\t});\n\t\t}\n\n\t\tfor (const s of submissions.values()) {\n\t\t\twork.push({\n\t\t\t\tkind: \"apiRequest\",\n\t\t\t\tskip_work_indicator: s.skip_work_indicator,\n\t\t\t});\n\t\t}\n\n\t\tif (prefetch?.is_pending) {\n\t\t\twork.push({\n\t\t\t\tkind: \"prefetch\",\n\t\t\t});\n\t\t}\n\n\t\treturn work;\n\t}\n\n\tfunction empty_work_state(): WorkState {\n\t\treturn {\n\t\t\tnavigation: null,\n\t\t\trevalidation: null,\n\t\t\tprefetch: null,\n\t\t\tapiRequests: [],\n\t\t};\n\t}\n\n\tfunction derive_work_state(): WorkState {\n\t\tconst active_fetch = active;\n\t\tlet revalidation: WorkState[\"revalidation\"] = null;\n\t\tif (active_fetch?.intent.kind === \"reval\") {\n\t\t\trevalidation = {\n\t\t\t\tstatus: \"running\",\n\t\t\t\tattempt: active_fetch.intent.attempt,\n\t\t\t};\n\t\t} else if (refresh.kind === \"debouncing\") {\n\t\t\trevalidation = { status: \"debouncing\", attempt: 0 };\n\t\t} else if (refresh.kind === \"retrying\") {\n\t\t\trevalidation = {\n\t\t\t\tstatus: \"retrying\",\n\t\t\t\tattempt: refresh.attempt,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tnavigation:\n\t\t\t\tactive_fetch?.intent.kind === \"nav\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\thref: active_fetch.intent.url.href,\n\t\t\t\t\t\t\treplace:\n\t\t\t\t\t\t\t\tactive_fetch.intent.options.replace === true,\n\t\t\t\t\t\t\tsource: active_fetch.intent.source,\n\t\t\t\t\t\t}\n\t\t\t\t\t: null,\n\t\t\trevalidation,\n\t\t\tprefetch: prefetch?.is_pending ? { href: prefetch.url.href } : null,\n\t\t\tapiRequests: Array.from(submissions.values(), (s) => {\n\t\t\t\treturn {\n\t\t\t\t\tkey: s.key,\n\t\t\t\t\tmethod: s.method,\n\t\t\t\t\thref: s.href,\n\t\t\t\t};\n\t\t\t}),\n\t\t};\n\t}\n\n\tfunction take_work_update(): WorkState | undefined {\n\t\tconst next = derive_work_state();\n\t\tif (jsonDeepEquals(last_work_state, next)) {\n\t\t\treturn undefined;\n\t\t}\n\t\tlast_work_state = next;\n\t\treturn next;\n\t}\n\n\tfunction emit_client_commit(client_commit: ClientCommit): void {\n\t\tcommit(client_commit);\n\t\tif (client_commit.route_update && user_on_route_update) {\n\t\t\tuser_on_route_update(\n\t\t\t\tclient_commit.route_update.route,\n\t\t\t\tclient_commit.route_update.previous_route,\n\t\t\t\tclient_commit.route_update.reason,\n\t\t\t);\n\t\t}\n\t\tif (client_commit.work) {\n\t\t\tfor (const fn of work_update_listeners) {\n\t\t\t\tfn(client_commit.work);\n\t\t\t}\n\t\t\tuser_on_work_update?.(client_commit.work);\n\t\t}\n\t}\n\n\tfunction notify_work_update(): void {\n\t\tconst work = take_work_update();\n\t\tif (!work) {\n\t\t\tsync_work_indicator();\n\t\t\treturn;\n\t\t}\n\t\temit_client_commit({ work });\n\t}\n\n\t/////// HMR\n\n\tfunction register_hmr(): void {\n\t\tif (!import.meta.env.DEV || !import.meta.hot) {\n\t\t\treturn;\n\t\t}\n\t\twindow.__vorma_hmr_route_update = async (raw_url, mod) => {\n\t\t\tif (!route_snapshot) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst url = normalize_module_url(raw_url);\n\t\t\tmodule_cache.set(url, mod);\n\t\t\tconst idx = route_snapshot.route.matches.findIndex(\n\t\t\t\t(m) => normalize_module_url(m.module_url) === url,\n\t\t\t);\n\t\t\tif (idx === -1) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst match = route_snapshot.route.matches[idx]!;\n\t\t\tconst def = mod.default as ViewDefinition | undefined;\n\t\t\tif (def?.client_loader) {\n\t\t\t\tmodule_map[match.pattern] = def.client_loader;\n\t\t\t\tregisterPattern(pattern_registry, match.pattern);\n\t\t\t} else {\n\t\t\t\tdelete module_map[match.pattern];\n\t\t\t}\n\n\t\t\tlet client_loader_data = match.client_loader_data;\n\t\t\tif (hmr_rerun_patterns.has(match.pattern)) {\n\t\t\t\tconst loader = module_map[match.pattern];\n\t\t\t\tif (loader) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst current_route = route_snapshot.route;\n\t\t\t\t\t\tconst routes = current_route.matches.map((m, i) => {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tpattern: m.pattern,\n\t\t\t\t\t\t\t\tinput: m.input,\n\t\t\t\t\t\t\t\tmodule_url: m.module_url,\n\t\t\t\t\t\t\t\tloader_data: m.loader_data,\n\t\t\t\t\t\t\t\tserver_error:\n\t\t\t\t\t\t\t\t\tcurrent_route.error?.source === \"server\" &&\n\t\t\t\t\t\t\t\t\tcurrent_route.error.idx === i\n\t\t\t\t\t\t\t\t\t\t? current_route.error.error\n\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t\tclient_loader_data = await loader({\n\t\t\t\t\t\t\ttrigger: \"revalidation\",\n\t\t\t\t\t\t\thref: route_snapshot.position.href,\n\t\t\t\t\t\t\thistoryState: route_snapshot.position.state,\n\t\t\t\t\t\t\tpattern: match.pattern,\n\t\t\t\t\t\t\tparams: route_snapshot.route.params,\n\t\t\t\t\t\t\tsplatValues: route_snapshot.route.splat_values,\n\t\t\t\t\t\t\tinput: match.input,\n\t\t\t\t\t\t\tknownMatches: routes_to_known_matches(routes),\n\t\t\t\t\t\t\tserverPromise: Promise.resolve(\n\t\t\t\t\t\t\t\tbuild_server_state(routes, idx),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsignal: new AbortController().signal,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\"Vorma: HMR client loader re-run failed\",\n\t\t\t\t\t\t\terr,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!route_snapshot) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prev = route_snapshot;\n\t\t\tconst matches = route_snapshot.route.matches.map((m, i) =>\n\t\t\t\ti === idx ? { ...m, module: mod, client_loader_data } : m,\n\t\t\t);\n\t\t\troute_snapshot = {\n\t\t\t\tposition: route_snapshot.position,\n\t\t\t\troute: { ...route_snapshot.route, matches },\n\t\t\t};\n\t\t\tcommit_route_snapshot(\"hmr\", prev, route_snapshot);\n\t\t};\n\t}\n\n\t/////// Work Indicator\n\n\tfunction setup_work_indicator(\n\t\toptions: WorkIndicatorOptions | undefined,\n\t): void {\n\t\twork_indicator_options = options;\n\t\twork_indicator.configure(options);\n\t\tif (!work_indicator_sync_registered) {\n\t\t\twork_update_listeners.add(sync_work_indicator);\n\t\t\twork_indicator_sync_registered = true;\n\t\t}\n\t\tsync_work_indicator();\n\t}\n\n\tfunction sync_work_indicator(_work?: WorkState): void {\n\t\tconst options = work_indicator_options;\n\t\tif (!options) {\n\t\t\twork_indicator.set_vorma_active(false);\n\t\t\treturn;\n\t\t}\n\n\t\tlet active_for_vorma = false;\n\t\tfor (const work of derive_work_projection()) {\n\t\t\tif (\n\t\t\t\twork.kind === \"navigation\" &&\n\t\t\t\toptions.skipNavigations !== true &&\n\t\t\t\t!work.skip_work_indicator\n\t\t\t) {\n\t\t\t\tactive_for_vorma = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (\n\t\t\t\twork.kind === \"revalidation\" &&\n\t\t\t\toptions.skipRevalidations !== true &&\n\t\t\t\t!work.skip_work_indicator\n\t\t\t) {\n\t\t\t\tactive_for_vorma = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (\n\t\t\t\twork.kind === \"apiRequest\" &&\n\t\t\t\toptions.skipAPIRequests !== true &&\n\t\t\t\t!work.skip_work_indicator\n\t\t\t) {\n\t\t\t\tactive_for_vorma = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\twork_indicator.set_vorma_active(active_for_vorma);\n\t}\n\n\t/////// Boot\n\n\tasync function boot(options: ClientOptions): Promise<Result<void>> {\n\t\tconst payload_el = document.getElementById(DATA_SCRIPT_ID);\n\t\tif (!payload_el) {\n\t\t\treturn R.err(`Missing element: #${DATA_SCRIPT_ID}`);\n\t\t}\n\t\tlet raw_payload: Record<string, any>;\n\t\ttry {\n\t\t\traw_payload = JSON.parse(payload_el.textContent ?? \"{}\");\n\t\t} catch (err) {\n\t\t\treturn R.err(\n\t\t\t\t`Failed to parse #${DATA_SCRIPT_ID}: ${to_error_string(err)}`,\n\t\t\t);\n\t\t}\n\t\tif (raw_payload.ClientBuildID) {\n\t\t\tclient_build_id = raw_payload.ClientBuildID;\n\t\t}\n\t\tif (raw_payload.DeploymentID) {\n\t\t\tdeployment_id = raw_payload.DeploymentID;\n\t\t}\n\t\tconst payload = decode_payload(raw_payload, current_url());\n\n\t\tuser_on_route_update = options.onRouteUpdate;\n\t\tuser_on_work_update = options.onWorkUpdate;\n\t\tuser_on_build_skew_detected = options.onBuildSkewDetected;\n\t\tdefault_error_boundary = options.defaultErrorBoundary;\n\t\tuse_view_transitions = options.useViewTransitions ?? false;\n\n\t\tconst history_state = window.history.state;\n\t\tconst has_history_key =\n\t\t\thistory_state &&\n\t\t\ttypeof history_state === \"object\" &&\n\t\t\tHISTORY_KEY_FIELD in (history_state as Record<string, unknown>);\n\t\tif (!has_history_key) {\n\t\t\tconst base =\n\t\t\t\thistory_state && typeof history_state === \"object\"\n\t\t\t\t\t? history_state\n\t\t\t\t\t: {};\n\t\t\twindow.history.replaceState(\n\t\t\t\t{\n\t\t\t\t\t...(base as object),\n\t\t\t\t\t[HISTORY_KEY_FIELD]: make_history_key(),\n\t\t\t\t},\n\t\t\t\t\"\",\n\t\t\t\tcurrent_url().href,\n\t\t\t);\n\t\t}\n\t\tbrowser = read_browser_position();\n\t\ttry {\n\t\t\twindow.history.scrollRestoration = \"manual\";\n\t\t} catch {}\n\n\t\tconst initial_ac = new AbortController();\n\t\tconst modules = await prepare_modules(payload, initial_ac.signal);\n\t\tif (!modules) {\n\t\t\treturn R.err(\"Initial navigation produced no state\");\n\t\t}\n\n\t\t// Install a provisional snapshot so router APIs (getRouteState, submit)\n\t\t// work during initial client-loader execution.\n\t\troute_snapshot = {\n\t\t\tposition: browser,\n\t\t\troute: build_route_record(payload, modules, []),\n\t\t};\n\n\t\tconst cl_results = await run_client_loaders(\n\t\t\tpayload.routes,\n\t\t\tpayload,\n\t\t\t[],\n\t\t\t\"boot\",\n\t\t\tbrowser.href,\n\t\t\tbrowser.state,\n\t\t\tinitial_ac.signal,\n\t\t);\n\t\tif (initial_ac.signal.aborted) {\n\t\t\treturn R.err(\"Initial navigation produced no state\");\n\t\t}\n\n\t\tawait wait_for_css(payload.css_bundles, initial_ac.signal);\n\t\tif (initial_ac.signal.aborted) {\n\t\t\treturn R.err(\"Initial navigation produced no state\");\n\t\t}\n\n\t\tconst route = build_route_record(payload, modules, cl_results);\n\t\troute_snapshot = { position: browser, route };\n\n\t\tapply_head_and_title(\n\t\t\tpayload.title,\n\t\t\tpayload.meta_head_els,\n\t\t\tpayload.rest_head_els,\n\t\t);\n\t\tapply_css_bundles(payload.css_bundles);\n\t\tpreload_modules(payload.deps);\n\n\t\tlet scroll_intent: ScrollIntent | undefined;\n\t\tconst make_scroll_intent = (scroll: ScrollState): ScrollIntent => {\n\t\t\treturn {\n\t\t\t\tscroll,\n\t\t\t\ttarget_route_id: make_route_id(\n\t\t\t\t\troute.matches.length - 1,\n\t\t\t\t\troute.matches[route.matches.length - 1]?.pattern ?? \"\",\n\t\t\t\t),\n\t\t\t};\n\t\t};\n\t\tlet refresh_scroll_raw: string | null;\n\t\ttry {\n\t\t\trefresh_scroll_raw = sessionStorage.getItem(\n\t\t\t\tSCROLL_STORAGE_RELOAD_KEY,\n\t\t\t);\n\t\t} catch {\n\t\t\trefresh_scroll_raw = null;\n\t\t}\n\t\tif (refresh_scroll_raw) {\n\t\t\ttry {\n\t\t\t\tsessionStorage.removeItem(SCROLL_STORAGE_RELOAD_KEY);\n\t\t\t} catch {}\n\t\t\ttry {\n\t\t\t\tconst s = JSON.parse(refresh_scroll_raw);\n\t\t\t\tif (\n\t\t\t\t\ttypeof s?.x === \"number\" &&\n\t\t\t\t\ttypeof s?.y === \"number\" &&\n\t\t\t\t\ttypeof s?.unix === \"number\" &&\n\t\t\t\t\ttypeof s?.href === \"string\" &&\n\t\t\t\t\tDate.now() - s.unix <= REFRESH_MAX_AGE_MS &&\n\t\t\t\t\tmatches_without_hash(new URL(s.href), current_url())\n\t\t\t\t) {\n\t\t\t\t\tscroll_intent = make_scroll_intent({ x: s.x, y: s.y });\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\t\tif (!scroll_intent) {\n\t\t\tconst hash = normalize_hash(current_url().hash);\n\t\t\tif (hash.length > 0) {\n\t\t\t\tscroll_intent = make_scroll_intent({\n\t\t\t\t\thash: current_url().hash,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tcommit_route_snapshot(\"initial\", null, route_snapshot, scroll_intent);\n\n\t\tsetup_work_indicator(options.workIndicator);\n\t\tif (focus_revalidation_cleanup) {\n\t\t\tfocus_revalidation_cleanup();\n\t\t\tfocus_revalidation_cleanup = null;\n\t\t}\n\t\tif (options.revalidateOnWindowFocus) {\n\t\t\tconst stale_ms =\n\t\t\t\ttypeof options.revalidateOnWindowFocus === \"object\"\n\t\t\t\t\t? options.revalidateOnWindowFocus.staleTimeMS\n\t\t\t\t\t: 5_000;\n\t\t\tfocus_revalidation_cleanup = addOnWindowFocusListener(() => {\n\t\t\t\tconst work = derive_work_state();\n\t\t\t\tif (\n\t\t\t\t\twork.navigation ||\n\t\t\t\t\twork.revalidation ||\n\t\t\t\t\twork.apiRequests.length > 0\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (Date.now() - last_activity_ts >= stale_ms) {\n\t\t\t\t\trequire_refresh(\"windowFocus\", undefined, true);\n\t\t\t\t\tnotify_work_update();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (options.render) {\n\t\t\tawait options.render();\n\t\t}\n\n\t\twindow.addEventListener(\"popstate\", () => {\n\t\t\tvoid handle_popstate();\n\t\t});\n\t\twindow.addEventListener(\"beforeunload\", () => {\n\t\t\ttry {\n\t\t\t\tsessionStorage.setItem(\n\t\t\t\t\tSCROLL_STORAGE_RELOAD_KEY,\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\t...get_scroll_pos(),\n\t\t\t\t\t\tunix: Date.now(),\n\t\t\t\t\t\thref: current_url().href,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} catch {}\n\t\t});\n\t\tregister_hmr();\n\n\t\tphase = \"ready\";\n\t\tif (deferred_submit_redirect) {\n\t\t\tconst redirect = deferred_submit_redirect;\n\t\t\tdeferred_submit_redirect = null;\n\t\t\tvoid start_nav_inner(redirect, { replace: true }, 0, {\n\t\t\t\tsource: \"redirect\",\n\t\t\t});\n\t\t}\n\t\tmaybe_revalidate();\n\t\treturn R.ok(undefined);\n\t}\n\n\t/////// Public API\n\n\tasync function navigate(\n\t\thref: string | URL,\n\t\toptions?: {\n\t\t\treplace?: boolean;\n\t\t\tscrollToTop?: boolean;\n\t\t\tstate?: unknown;\n\t\t\tskipWorkIndicator?: boolean;\n\t\t},\n\t): Promise<NavResult> {\n\t\tif (phase !== \"ready\") {\n\t\t\tthrow new Error(\"Vorma not booted\");\n\t\t}\n\t\tconst url = new URL(String(href), window.location.href);\n\t\tif (!is_same_origin(url)) {\n\t\t\thard_redirect(url.href);\n\t\t\treturn { didNavigate: false };\n\t\t}\n\t\treturn start_nav_inner(\n\t\t\turl,\n\t\t\t{\n\t\t\t\treplace: options?.replace,\n\t\t\t\tscroll_to_top: options?.scrollToTop,\n\t\t\t\tstate: options?.state,\n\t\t\t\tskip_work_indicator: options?.skipWorkIndicator,\n\t\t\t},\n\t\t\t0,\n\t\t);\n\t}\n\n\tasync function revalidate(): Promise<RevalidationResult> {\n\t\tif (phase !== \"ready\") {\n\t\t\tthrow new Error(\"Vorma not booted\");\n\t\t}\n\t\tconst waiter = make_deferred<RevalidationResult>();\n\t\trequire_refresh(\"manual\", waiter, true);\n\t\tnotify_work_update();\n\t\treturn waiter.promise;\n\t}\n\n\tfunction getRouteState(): RouteState {\n\t\tconst snapshot = route_snapshot;\n\t\tif (!snapshot) {\n\t\t\tthrow new Error(\"Vorma not booted\");\n\t\t}\n\t\treturn route_snapshot_to_state(snapshot);\n\t}\n\n\tfunction getWorkState(): WorkState {\n\t\tif (!route_snapshot) {\n\t\t\tthrow new Error(\"Vorma not booted\");\n\t\t}\n\t\treturn derive_work_state();\n\t}\n\n\tfunction getRootEl(): HTMLElement {\n\t\tconst el = document.getElementById(VORMA_ROOT_EL_ID);\n\t\tif (el) {\n\t\t\treturn el;\n\t\t}\n\t\tconst fresh = document.createElement(\"div\");\n\t\tfresh.id = VORMA_ROOT_EL_ID;\n\t\tdocument.body.insertBefore(fresh, document.body.firstChild);\n\t\treturn fresh;\n\t}\n\n\tfunction defineView<T = any>(input: {\n\t\tpattern: string;\n\t\tcomponent: (props: any) => any;\n\t\terrorBoundary?: (props: { error: unknown }) => any;\n\t\tclientLoader?: (props: any) => Promise<T>;\n\t\tbeforeRouteCommit?: BeforeRouteCommitFn;\n\t\tbeforeRouteYield?: BeforeRouteYieldFn;\n\t\trunClientLoaderOnHMR?: boolean;\n\t}): ViewDefinition & { __phantom_client_loader_data?: T } {\n\t\tif (import.meta.env.DEV) {\n\t\t\tif (input.runClientLoaderOnHMR) {\n\t\t\t\thmr_rerun_patterns.add(input.pattern);\n\t\t\t} else {\n\t\t\t\thmr_rerun_patterns.delete(input.pattern);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tpattern: input.pattern,\n\t\t\tcomponent: input.component,\n\t\t\terror_boundary: input.errorBoundary,\n\t\t\tclient_loader: input.clientLoader,\n\t\t\tbefore_route_commit: input.beforeRouteCommit,\n\t\t\tbefore_route_yield: input.beforeRouteYield,\n\t\t};\n\t}\n\n\t(window as any)[Symbol.for(\"vorma-data-revalidate-fn\")] = revalidate;\n\n\treturn R.ok({\n\t\tboot,\n\t\tworkIndicator: work_indicator.indicator,\n\t\tnavigate,\n\t\trevalidate,\n\t\tsubmit_inner,\n\t\tgetRouteState,\n\t\tgetWorkState,\n\t\tgetClientBuildID: () => client_build_id,\n\t\tgetRootEl,\n\t\tdefineView,\n\t\tstart_prefetch,\n\t\tstop_prefetch,\n\t\tsave_current_scroll,\n\t\tget_default_error_boundary: () => default_error_boundary,\n\t});\n}\n\ndeclare global {\n\tinterface Window {\n\t\t__vorma_hmr_route_update?: (\n\t\t\traw_url: string,\n\t\t\tmod: Record<string, unknown>,\n\t\t) => Promise<void>;\n\t}\n}\n","import {\n\tgetHrefDetails,\n\tgetIsModifiedNavigationClick,\n\tgetIsPrimaryNavigationClick,\n} from \"vorma/kit/url\";\nimport {\n\tLINK_ACTIVE_ANCESTOR_ATTR,\n\tLINK_ACTIVE_EXACT_ATTR,\n\tLINK_PENDING_ANCESTOR_ATTR,\n\tLINK_PENDING_EXACT_ATTR,\n} from \"./constants.ts\";\nimport type { WorkState } from \"./create_client_core.ts\";\nimport type { LinkPropsBase, RouteState } from \"./types.ts\";\n\nexport type LinkRouteState = {\n\thref: string;\n\tmatchedPatterns: string[];\n};\n\nexport type LinkWorkState = {\n\tnavigationHref: string | null;\n};\n\nexport type LinkPropsResult = {\n\tis_external: boolean;\n\tanchor_props: Record<string, unknown>;\n\tonClick?: (e: unknown) => void;\n\tonPointerDown?: (e: unknown) => void;\n\tonPointerEnter?: (e: unknown) => void;\n\tonFocus?: (e: unknown) => void;\n\tonPointerLeave?: (e: unknown) => void;\n\tonBlur?: (e: unknown) => void;\n\tonTouchCancel?: (e: unknown) => void;\n};\n\nexport type LinkNavFns = {\n\tnavigate: (args: {\n\t\thref: string;\n\t\treplace?: boolean;\n\t\tscrollToTop?: boolean;\n\t\tskipWorkIndicator?: boolean;\n\t\tstate?: unknown;\n\t}) => Promise<{ didNavigate: boolean }>;\n\tstart_prefetch: (href: string) => void;\n\tstop_prefetch: (href: string) => void;\n\tsave_current_scroll: () => void;\n\tregister_link_pattern: (pattern: string) => void;\n\tget_link_attribute_state: (\n\t\thref: string,\n\t\tmatch_rules: LinkPropsBase[\"attributeMatchRules\"],\n\t\troute_state: LinkRouteState | null,\n\t\twork_state: LinkWorkState,\n\t) => {\n\t\tactive_exact: boolean;\n\t\tactive_ancestor: boolean;\n\t\tpending_exact: boolean;\n\t\tpending_ancestor: boolean;\n\t};\n};\n\nexport const skip_work_indicator_link_prop = \"skipWorkIndicator\";\n\nconst VORMA_KEYS = new Set([\n\t\"attributeMatchRules\",\n\t\"pattern\",\n\t\"prefetch\",\n\t\"prefetchDelayMs\",\n\t\"replace\",\n\t\"scrollToTop\",\n\tskip_work_indicator_link_prop,\n\t\"state\",\n\t\"visitOnPointerDown\",\n]);\n\nconst COMPOSED_EVENT_KEYS = new Set([\n\t\"onClick\",\n\t\"onPointerDown\",\n\t\"onPointerEnter\",\n\t\"onFocus\",\n\t\"onPointerLeave\",\n\t\"onBlur\",\n\t\"onTouchCancel\",\n]);\n\nlet is_touch_active = false;\nlet input_modality_registered = false;\n\nfunction register_input_modality(): void {\n\tif (input_modality_registered) {\n\t\treturn;\n\t}\n\tinput_modality_registered = true;\n\n\twindow.addEventListener(\"touchstart\", () => {\n\t\tis_touch_active = true;\n\t});\n\n\tconst on_pointer = (e: PointerEvent) => {\n\t\tconst pt = e.pointerType;\n\t\tif (pt === \"touch\") {\n\t\t\tis_touch_active = true;\n\t\t} else if (pt === \"mouse\" || pt === \"pen\") {\n\t\t\tis_touch_active = false;\n\t\t}\n\t};\n\n\twindow.addEventListener(\"pointerdown\", on_pointer);\n\twindow.addEventListener(\"pointermove\", on_pointer);\n}\n\nexport function select_link_route_state(route: RouteState): LinkRouteState {\n\treturn {\n\t\thref: route.href,\n\t\tmatchedPatterns: route.matches.map((m) => {\n\t\t\treturn m.pattern;\n\t\t}),\n\t};\n}\n\nexport function select_link_work_state(work: WorkState): LinkWorkState {\n\treturn {\n\t\tnavigationHref: work.navigation?.href ?? null,\n\t};\n}\n\nfunction strip_keys(\n\tprops: Record<string, unknown>,\n\tkeys: Set<string>,\n): Record<string, unknown> {\n\tconst out: Record<string, unknown> = {};\n\tfor (const [k, v] of Object.entries(props)) {\n\t\tif (!keys.has(k)) {\n\t\t\tout[k] = v;\n\t\t}\n\t}\n\treturn out;\n}\n\nexport function make_link_props(\n\tprops: Record<string, unknown>,\n\tnav: LinkNavFns,\n\troute_state: LinkRouteState | null = null,\n\twork_state?: LinkWorkState,\n): LinkPropsResult {\n\tregister_input_modality();\n\n\tconst href = (props.href as string) ?? \"\";\n\tconst pattern = props.pattern as string | undefined;\n\tif (pattern) {\n\t\tnav.register_link_pattern(pattern);\n\t}\n\n\tconst details = getHrefDetails(href);\n\tconst is_external = details.isHTTP ? details.isExternal : true;\n\tconst consumer_click = props.onClick as ((e: unknown) => void) | undefined;\n\n\tif (is_external) {\n\t\treturn {\n\t\t\tis_external: true,\n\t\t\tanchor_props: strip_keys(props, VORMA_KEYS),\n\t\t\tonClick: consumer_click,\n\t\t};\n\t}\n\n\tconst anchor_props = strip_keys(\n\t\tstrip_keys(props, VORMA_KEYS),\n\t\tCOMPOSED_EVENT_KEYS,\n\t);\n\tconst attribute_match_rules =\n\t\tprops.attributeMatchRules as LinkPropsBase[\"attributeMatchRules\"];\n\tconst link_state =\n\t\tattribute_match_rules?.skip === true || !route_state || !work_state\n\t\t\t? null\n\t\t\t: nav.get_link_attribute_state(\n\t\t\t\t\thref,\n\t\t\t\t\tattribute_match_rules,\n\t\t\t\t\troute_state,\n\t\t\t\t\twork_state,\n\t\t\t\t);\n\tif (link_state?.active_exact) {\n\t\tanchor_props[LINK_ACTIVE_EXACT_ATTR] = \"\";\n\t}\n\tif (link_state?.active_ancestor) {\n\t\tanchor_props[LINK_ACTIVE_ANCESTOR_ATTR] = \"\";\n\t}\n\tif (link_state?.pending_exact) {\n\t\tanchor_props[LINK_PENDING_EXACT_ATTR] = \"\";\n\t}\n\tif (link_state?.pending_ancestor) {\n\t\tanchor_props[LINK_PENDING_ANCESTOR_ATTR] = \"\";\n\t}\n\tif (\n\t\tlink_state?.active_exact &&\n\t\tanchor_props[\"aria-current\"] === undefined\n\t) {\n\t\tanchor_props[\"aria-current\"] = \"page\";\n\t}\n\n\tconst prefetch_mode = props.prefetch as string | undefined;\n\tconst prefetch_delay = (props.prefetchDelayMs as number | undefined) ?? 100;\n\tconst replace = props.replace as boolean | undefined;\n\tconst scroll_to_top = props.scrollToTop as boolean | undefined;\n\tconst skip_work_indicator = props[skip_work_indicator_link_prop] as\n\t\t| boolean\n\t\t| undefined;\n\tconst state = props.state as unknown;\n\tconst target_attr = props.target as string | undefined;\n\tconst visit_on_pointer_down = props.visitOnPointerDown as\n\t\t| boolean\n\t\t| undefined;\n\tconst consumer_pointer_down = props.onPointerDown as\n\t\t| ((e: unknown) => void)\n\t\t| undefined;\n\tconst consumer_pointer_enter = props.onPointerEnter as\n\t\t| ((e: unknown) => void)\n\t\t| undefined;\n\tconst consumer_focus = props.onFocus as ((e: unknown) => void) | undefined;\n\tconst consumer_pointer_leave = props.onPointerLeave as\n\t\t| ((e: unknown) => void)\n\t\t| undefined;\n\tconst consumer_blur = props.onBlur as ((e: unknown) => void) | undefined;\n\tconst consumer_touch_cancel = props.onTouchCancel as\n\t\t| ((e: unknown) => void)\n\t\t| undefined;\n\n\tlet prefetch_timer: number | undefined;\n\tconst wants_prefetch = prefetch_mode === \"intent\";\n\n\tconst start_pf = () => {\n\t\tif (prefetch_timer !== undefined) {\n\t\t\tclearTimeout(prefetch_timer);\n\t\t}\n\t\tprefetch_timer = window.setTimeout(() => {\n\t\t\tprefetch_timer = undefined;\n\t\t\tnav.start_prefetch(href);\n\t\t}, prefetch_delay);\n\t};\n\n\tconst stop_pf = () => {\n\t\tif (prefetch_timer !== undefined) {\n\t\t\tclearTimeout(prefetch_timer);\n\t\t\tprefetch_timer = undefined;\n\t\t}\n\t\tnav.stop_prefetch(href);\n\t};\n\n\treturn {\n\t\tis_external: false,\n\t\tanchor_props,\n\n\t\tonClick: async (e: unknown) => {\n\t\t\tconst ev = e as any;\n\t\t\tconsumer_click?.(e);\n\n\t\t\tif (ev.defaultPrevented) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (getIsModifiedNavigationClick(ev)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!getIsPrimaryNavigationClick(ev)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (target_attr && target_attr !== \"\" && target_attr !== \"_self\") {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tev.preventDefault?.();\n\n\t\t\ttry {\n\t\t\t\tawait nav.navigate({\n\t\t\t\t\thref,\n\t\t\t\t\treplace,\n\t\t\t\t\tscrollToTop: scroll_to_top,\n\t\t\t\t\t...(skip_work_indicator === undefined\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { skipWorkIndicator: skip_work_indicator }),\n\t\t\t\t\tstate,\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\tconsole.error(\"Vorma: Link click failed\", err);\n\t\t\t}\n\t\t},\n\n\t\tonPointerDown:\n\t\t\tvisit_on_pointer_down || consumer_pointer_down\n\t\t\t\t? async (e: unknown) => {\n\t\t\t\t\t\tconst ev = e as any;\n\t\t\t\t\t\tconsumer_pointer_down?.(e);\n\t\t\t\t\t\tif (!visit_on_pointer_down) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (ev.defaultPrevented) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst pt = ev.pointerType;\n\t\t\t\t\t\tif (pt !== \"mouse\" && pt !== \"pen\") {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (getIsModifiedNavigationClick(ev)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!getIsPrimaryNavigationClick(ev)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\ttarget_attr &&\n\t\t\t\t\t\t\ttarget_attr !== \"\" &&\n\t\t\t\t\t\t\ttarget_attr !== \"_self\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tev.preventDefault?.();\n\n\t\t\t\t\t\tconst el = ev.currentTarget as HTMLElement;\n\t\t\t\t\t\tel.addEventListener(\n\t\t\t\t\t\t\t\"click\",\n\t\t\t\t\t\t\t(ce: Event) => {\n\t\t\t\t\t\t\t\tce.preventDefault();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ once: true },\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait nav.navigate({\n\t\t\t\t\t\t\t\thref,\n\t\t\t\t\t\t\t\treplace,\n\t\t\t\t\t\t\t\tscrollToTop: scroll_to_top,\n\t\t\t\t\t\t\t\t...(skip_work_indicator === undefined\n\t\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\t\tskipWorkIndicator:\n\t\t\t\t\t\t\t\t\t\t\t\tskip_work_indicator,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t\"Vorma: Link pointerdown navigation failed\",\n\t\t\t\t\t\t\t\terr,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\n\t\tonPointerEnter:\n\t\t\twants_prefetch || consumer_pointer_enter\n\t\t\t\t? (e: unknown) => {\n\t\t\t\t\t\tif (wants_prefetch) {\n\t\t\t\t\t\t\tstart_pf();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconsumer_pointer_enter?.(e);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\n\t\tonFocus:\n\t\t\twants_prefetch || consumer_focus\n\t\t\t\t? (e: unknown) => {\n\t\t\t\t\t\tif (wants_prefetch) {\n\t\t\t\t\t\t\tstart_pf();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconsumer_focus?.(e);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\n\t\tonPointerLeave:\n\t\t\twants_prefetch || consumer_pointer_leave\n\t\t\t\t? (e: unknown) => {\n\t\t\t\t\t\tif (wants_prefetch && !is_touch_active) {\n\t\t\t\t\t\t\tstop_pf();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconsumer_pointer_leave?.(e);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\n\t\tonBlur:\n\t\t\twants_prefetch || consumer_blur\n\t\t\t\t? (e: unknown) => {\n\t\t\t\t\t\tif (wants_prefetch) {\n\t\t\t\t\t\t\tstop_pf();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconsumer_blur?.(e);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\n\t\tonTouchCancel:\n\t\t\twants_prefetch || consumer_touch_cancel\n\t\t\t\t? (e: unknown) => {\n\t\t\t\t\t\tif (wants_prefetch) {\n\t\t\t\t\t\t\tstop_pf();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconsumer_touch_cancel?.(e);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t};\n}\n","import type { ViewDefinition, RouteRenderEntry } from \"./create_client_core.ts\";\nimport type { RouteErrorState } from \"./types.ts\";\n\nexport type OutletSlot =\n\t| { kind: \"component\"; component: (props: any) => any }\n\t| {\n\t\t\tkind: \"error\";\n\t\t\terror: unknown;\n\t\t\tboundary: (props: { error: unknown }) => any;\n\t }\n\t| { kind: \"pass_through\" }\n\t| { kind: \"empty\" };\n\nconst component_refs = new Map<\n\tstring,\n\t{\n\t\timpl: (props: any) => any;\n\t\twrapper: (props: any) => any;\n\t\tholder: { current: (props: any) => any };\n\t}\n>();\n\nconst error_refs = new Map<\n\tstring,\n\t{\n\t\timpl: (props: { error: unknown }) => any;\n\t\twrapper: (props: { error: unknown }) => any;\n\t\tholder: { current: (props: { error: unknown }) => any };\n\t}\n>();\n\nfunction get_stable_component(\n\tkey: string,\n\timpl: (props: any) => any,\n): (props: any) => any {\n\tlet entry = component_refs.get(key);\n\tif (!entry) {\n\t\tconst holder = { current: impl };\n\t\tconst wrapper = (props: any) => {\n\t\t\treturn holder.current(props);\n\t\t};\n\t\tentry = { impl, wrapper, holder };\n\t\tcomponent_refs.set(key, entry);\n\t}\n\tentry.holder.current = impl;\n\treturn entry.wrapper;\n}\n\nfunction get_stable_error_boundary(\n\tkey: string,\n\timpl: (props: { error: unknown }) => any,\n): (props: { error: unknown }) => any {\n\tlet entry = error_refs.get(key);\n\tif (!entry) {\n\t\tconst holder = { current: impl };\n\t\tconst wrapper = (props: { error: unknown }) => {\n\t\t\treturn holder.current(props);\n\t\t};\n\t\tentry = { impl, wrapper, holder };\n\t\terror_refs.set(key, entry);\n\t}\n\tentry.holder.current = impl;\n\treturn entry.wrapper;\n}\n\nexport function resolve_outlet_slot(\n\tentries: RouteRenderEntry[],\n\terror: RouteErrorState | null,\n\tidx: number,\n\tdefault_error_boundary: ((props: { error: unknown }) => any) | undefined,\n): OutletSlot {\n\tif (idx >= entries.length) {\n\t\treturn { kind: \"empty\" };\n\t}\n\n\tif (error !== null && idx >= error.idx) {\n\t\tconst error_entry = entries[error.idx]!;\n\t\tconst def = error_entry.module.default as ViewDefinition | undefined;\n\t\tconst raw_boundary =\n\t\t\tdef?.error_boundary ??\n\t\t\tdefault_error_boundary ??\n\t\t\tfallback_error_boundary;\n\t\tconst boundary = get_stable_error_boundary(\n\t\t\terror_entry.pattern,\n\t\t\traw_boundary,\n\t\t);\n\t\treturn { kind: \"error\", error: error.error, boundary };\n\t}\n\n\tconst entry = entries[idx]!;\n\tconst def = entry.module.default as ViewDefinition | undefined;\n\n\tif (!def?.component) {\n\t\tif (idx + 1 < entries.length) {\n\t\t\treturn { kind: \"pass_through\" };\n\t\t}\n\t\treturn { kind: \"empty\" };\n\t}\n\n\tconst component = get_stable_component(entry.pattern, def.component);\n\treturn { kind: \"component\", component };\n}\n\nexport function get_entry_key(entry: RouteRenderEntry): string {\n\treturn `${entry.pattern}::${entry.module_url}`;\n}\n\nfunction fallback_error_boundary(props: { error: unknown }): string {\n\tif (props.error instanceof Error) {\n\t\treturn `Error: ${props.error.message}`;\n\t}\n\tif (typeof props.error === \"string\") {\n\t\treturn `Error: ${props.error}`;\n\t}\n\treturn \"An unexpected error occurred.\";\n}\n","import type { ReadonlySignal } from \"@preact/signals\";\nimport { jsonDeepEquals } from \"vorma/kit/json\";\nimport {\n\tcreatePatternRegistry,\n\tfindNestedMatches,\n\tregisterPattern,\n} from \"vorma/kit/matcher\";\nimport { R, type Result } from \"vorma/kit/result\";\nimport { create_typed_api_client } from \"./api_client.ts\";\nimport type {\n\tClientCore,\n\tClientOptions as CoreClientOptions,\n\tViewDefinition,\n} from \"./create_client_core\";\nimport {\n\tcreate_client_core,\n\ttype ClientCommit,\n\ttype RouteRenderEntry,\n\ttype RouteRenderState,\n\ttype ScrollIntent,\n\ttype WorkState,\n} from \"./create_client_core.ts\";\nimport {\n\ttype LinkNavFns,\n\ttype LinkRouteState,\n\ttype LinkWorkState,\n} from \"./make_link_props.ts\";\nimport { get_entry_key } from \"./resolve_outlet_slot.ts\";\nimport type {\n\tAppConfig,\n\tLinkPropsBase,\n\tRouteErrorState,\n\tRouteState,\n\tRouteUpdateReason,\n\tToAPIClient,\n\tToAPIDecorator,\n\tToDefineViewArgs,\n\tToLinkProps,\n\tToLoaderOutput,\n\tToNavigateArgs,\n\tToNavigationTarget,\n\tToRouteComponentProps,\n\tToRouteDestination,\n\tToRouteSyncArgs,\n\tToViewPattern,\n} from \"./types\";\nimport {\n\tcreate_typed_navigate,\n\tcreate_typed_prefetch,\n\tcreate_typed_to_href,\n} from \"./url.ts\";\n\nexport type DecomposedState = {\n\t// Always a new reference\n\tentries: RouteRenderEntry[];\n\terror: RouteErrorState | null;\n\n\t// Stable per channel\n\tloaders_data: unknown[];\n\tclient_loaders_data: unknown[];\n\tmatched_patterns: string[];\n\timport_urls: string[];\n\tentry_keys: string[];\n\tparams: Record<string, string>;\n\tsplat_values: string[];\n\tclient_build_id: string;\n\thistory_state: unknown;\n};\n\nexport type DecomposedCommit = {\n\troute?: RouteState;\n\troute_reason?: RouteUpdateReason;\n\tscroll_intent?: ScrollIntent;\n\tstate?: DecomposedState;\n\twork?: WorkState;\n};\n\nexport type DecomposedCommitFn = (commit: DecomposedCommit) => void;\n\ntype LinkAttributeCandidate = {\n\turl: URL;\n\tmatched_patterns: string[];\n};\n\n// __TODO why is this generic called \"App\"? Shouldn't it be \"Component\" or something?\nexport type AdapterRenderArgs<App> = {\n\tRootOutlet: App;\n\trootEl: HTMLElement;\n};\n\nexport type AdapterClientOptions<App> = Omit<CoreClientOptions, \"render\"> & {\n\trender?: (args: AdapterRenderArgs<App>) => void | Promise<void>;\n};\n\ntype AdapterBase<A extends AppConfig> = {\n\tcore: ClientCore;\n\n\tnav_fns: LinkNavFns;\n\n\tpassthrough: Pick<\n\t\tClientCore,\n\t\t\"revalidate\" | \"getRouteState\" | \"getWorkState\" | \"workIndicator\"\n\t> & {\n\t\tnavigate: <P extends ToViewPattern<A>>(\n\t\t\targs: ToNavigateArgs<A, P>,\n\t\t) => Promise<{ didNavigate: boolean }>;\n\n\t\tprefetch: <P extends ToViewPattern<A>>(\n\t\t\ttarget: ToNavigationTarget<A, P>,\n\t\t) => void;\n\n\t\tcancelPrefetch: <P extends ToViewPattern<A>>(\n\t\t\ttarget: ToNavigationTarget<A, P>,\n\t\t) => void;\n\n\t\ttoHref: <P extends ToViewPattern<A>>(\n\t\t\tdestination: ToRouteDestination<A, P>,\n\t\t) => string;\n\n\t\tapiClient: ToAPIClient<A>;\n\t};\n};\n\nexport function create_adapter_base<A extends AppConfig>(\n\tapp_config: A,\n\ton_commit: DecomposedCommitFn,\n\tapi_decorator?: ToAPIDecorator<A>,\n): Result<AdapterBase<A>> {\n\tconst attribute_registry_res = createPatternRegistry({\n\t\tdynamicParamPrefixRune: \":\",\n\t\tsplatSegmentRune: \"*\",\n\t\texplicitIndexSegment: \"_index\",\n\t});\n\tif (!attribute_registry_res.ok) {\n\t\treturn R.err(\n\t\t\t`Failed to create link attribute registry: ${attribute_registry_res.err}`,\n\t\t);\n\t}\n\tconst attribute_registry = attribute_registry_res.val;\n\n\tlet prev: DecomposedState = {\n\t\tentries: [],\n\t\terror: null,\n\t\tloaders_data: [],\n\t\tclient_loaders_data: [],\n\t\tmatched_patterns: [],\n\t\timport_urls: [],\n\t\tentry_keys: [],\n\t\tparams: {},\n\t\tsplat_values: [],\n\t\tclient_build_id: \"\",\n\t\thistory_state: undefined,\n\t};\n\n\tfunction decomposed_commit(client_commit: ClientCommit): void {\n\t\tconst adapter_commit: DecomposedCommit = {};\n\t\tconst route_render = client_commit.route_render;\n\t\tif (route_render) {\n\t\t\tadapter_commit.state = decompose_route_render_state(\n\t\t\t\troute_render.state,\n\t\t\t);\n\t\t\tadapter_commit.scroll_intent = route_render.scroll_intent;\n\t\t}\n\t\tif (client_commit.route_update) {\n\t\t\tadapter_commit.route = client_commit.route_update.route;\n\t\t\tadapter_commit.route_reason = client_commit.route_update.reason;\n\t\t}\n\t\tif (client_commit.work) {\n\t\t\tadapter_commit.work = client_commit.work;\n\t\t}\n\t\ton_commit(adapter_commit);\n\t}\n\n\tfunction decompose_route_render_state(\n\t\troute_state: RouteRenderState,\n\t): DecomposedState {\n\t\tfor (const entry of route_state.entries) {\n\t\t\tregister_link_pattern(entry.pattern);\n\t\t}\n\n\t\tconst next: DecomposedState = {\n\t\t\tentries: route_state.entries,\n\t\t\terror: route_state.error,\n\t\t\tloaders_data: stable(\n\t\t\t\tprev.loaders_data,\n\t\t\t\troute_state.entries.map((e) => {\n\t\t\t\t\treturn e.loader_data;\n\t\t\t\t}),\n\t\t\t),\n\t\t\tclient_loaders_data: stable(\n\t\t\t\tprev.client_loaders_data,\n\t\t\t\troute_state.entries.map((e) => {\n\t\t\t\t\treturn e.client_loader_data;\n\t\t\t\t}),\n\t\t\t),\n\t\t\tmatched_patterns: stable(\n\t\t\t\tprev.matched_patterns,\n\t\t\t\troute_state.entries.map((e) => {\n\t\t\t\t\treturn e.pattern;\n\t\t\t\t}),\n\t\t\t),\n\t\t\timport_urls: stable(\n\t\t\t\tprev.import_urls,\n\t\t\t\troute_state.entries.map((e) => {\n\t\t\t\t\treturn e.module_url;\n\t\t\t\t}),\n\t\t\t),\n\t\t\tentry_keys: stable(\n\t\t\t\tprev.entry_keys,\n\t\t\t\troute_state.entries.map((e) => {\n\t\t\t\t\treturn get_entry_key(e);\n\t\t\t\t}),\n\t\t\t),\n\t\t\tparams: stable(prev.params, route_state.params),\n\t\t\tsplat_values: stable(prev.splat_values, route_state.splat_values),\n\t\t\tclient_build_id: stable(\n\t\t\t\tprev.client_build_id,\n\t\t\t\troute_state.client_build_id,\n\t\t\t),\n\t\t\thistory_state: stable(\n\t\t\t\tprev.history_state,\n\t\t\t\troute_state.history_state,\n\t\t\t),\n\t\t};\n\n\t\tprev = next;\n\t\treturn next;\n\t}\n\n\tconst core_res = create_client_core(app_config, decomposed_commit);\n\tif (!core_res.ok) {\n\t\treturn R.err(core_res.err);\n\t}\n\tconst core = core_res.val;\n\n\tconst nav_fns: LinkNavFns = {\n\t\tnavigate: (args) => {\n\t\t\treturn core.navigate(args.href, {\n\t\t\t\treplace: args.replace,\n\t\t\t\tscrollToTop: args.scrollToTop,\n\t\t\t\tskipWorkIndicator: args.skipWorkIndicator,\n\t\t\t\tstate: args.state,\n\t\t\t});\n\t\t},\n\t\tstart_prefetch: core.start_prefetch,\n\t\tstop_prefetch: core.stop_prefetch,\n\t\tsave_current_scroll: core.save_current_scroll,\n\t\tregister_link_pattern,\n\t\tget_link_attribute_state,\n\t};\n\n\tconst navigate = create_typed_navigate<A>(core.navigate);\n\tconst prefetch = create_typed_prefetch<A>(core.start_prefetch);\n\tconst cancel_prefetch = create_typed_prefetch<A>(core.stop_prefetch);\n\tconst to_href = create_typed_to_href<A>();\n\n\tconst api_client = create_typed_api_client<A>(\n\t\tapp_config.apiMountRoot,\n\t\tcore.submit_inner,\n\t\tapi_decorator,\n\t);\n\n\treturn R.ok({\n\t\tcore,\n\t\tnav_fns,\n\t\tpassthrough: {\n\t\t\tnavigate,\n\t\t\tprefetch,\n\t\t\tcancelPrefetch: cancel_prefetch,\n\t\t\ttoHref: to_href,\n\t\t\trevalidate: core.revalidate,\n\t\t\tgetRouteState: core.getRouteState,\n\t\t\tgetWorkState: core.getWorkState,\n\t\t\tworkIndicator: core.workIndicator,\n\t\t\tapiClient: api_client,\n\t\t},\n\t});\n\n\tfunction register_link_pattern(pattern: string): void {\n\t\tregisterPattern(attribute_registry, pattern);\n\t}\n\n\tfunction href_to_link_candidate(href: string): LinkAttributeCandidate {\n\t\tconst url = new URL(href, window.location.href);\n\t\tconst match = findNestedMatches(attribute_registry, url.pathname);\n\t\treturn {\n\t\t\turl,\n\t\t\tmatched_patterns:\n\t\t\t\tmatch?.matches.map((m) => {\n\t\t\t\t\treturn m.registeredPattern.originalPattern;\n\t\t\t\t}) ?? [],\n\t\t};\n\t}\n\n\tfunction exact_link_match(\n\t\ttarget: LinkAttributeCandidate,\n\t\tcandidate: LinkAttributeCandidate,\n\t\tmatch_rules: LinkPropsBase[\"attributeMatchRules\"],\n\t): boolean {\n\t\treturn (\n\t\t\ttarget.url.pathname === candidate.url.pathname &&\n\t\t\t(target.matched_patterns.length === 0 ||\n\t\t\t\tcandidate.matched_patterns.length === 0 ||\n\t\t\t\tjsonDeepEquals(\n\t\t\t\t\ttarget.matched_patterns,\n\t\t\t\t\tcandidate.matched_patterns,\n\t\t\t\t)) &&\n\t\t\t(match_rules?.includeSearch !== true ||\n\t\t\t\ttarget.url.search === candidate.url.search) &&\n\t\t\t(match_rules?.includeHash !== true ||\n\t\t\t\ttarget.url.hash === candidate.url.hash)\n\t\t);\n\t}\n\n\tfunction ancestor_link_match(\n\t\ttarget: LinkAttributeCandidate,\n\t\tcandidate: LinkAttributeCandidate,\n\t): boolean {\n\t\tconst target_path =\n\t\t\ttarget.url.pathname === \"/\" ? \"/\" : `${target.url.pathname}/`;\n\t\treturn (\n\t\t\ttarget.matched_patterns.length > 0 &&\n\t\t\tcandidate.matched_patterns.length >\n\t\t\t\ttarget.matched_patterns.length &&\n\t\t\t(target_path === \"/\" ||\n\t\t\t\tcandidate.url.pathname.startsWith(target_path)) &&\n\t\t\ttarget.matched_patterns.every((pattern, i) => {\n\t\t\t\treturn candidate.matched_patterns[i] === pattern;\n\t\t\t})\n\t\t);\n\t}\n\n\tfunction get_link_attribute_state(\n\t\thref: string,\n\t\tmatch_rules: LinkPropsBase[\"attributeMatchRules\"],\n\t\troute_state: LinkRouteState | null,\n\t\twork_state: LinkWorkState,\n\t) {\n\t\tif (match_rules?.skip === true || !route_state) {\n\t\t\treturn {\n\t\t\t\tactive_exact: false,\n\t\t\t\tactive_ancestor: false,\n\t\t\t\tpending_exact: false,\n\t\t\t\tpending_ancestor: false,\n\t\t\t};\n\t\t}\n\n\t\tconst target = href_to_link_candidate(href);\n\t\tconst route_url = new URL(route_state.href, window.location.href);\n\t\tconst route = {\n\t\t\turl: route_url,\n\t\t\tmatched_patterns: route_state.matchedPatterns,\n\t\t};\n\t\tconst pending = work_state.navigationHref\n\t\t\t? href_to_link_candidate(work_state.navigationHref)\n\t\t\t: null;\n\n\t\treturn {\n\t\t\tactive_exact: exact_link_match(target, route, match_rules),\n\t\t\tactive_ancestor: ancestor_link_match(target, route),\n\t\t\tpending_exact: pending\n\t\t\t\t? exact_link_match(target, pending, match_rules)\n\t\t\t\t: false,\n\t\t\tpending_ancestor: pending\n\t\t\t\t? ancestor_link_match(target, pending)\n\t\t\t\t: false,\n\t\t};\n\t}\n}\n\nfunction stable<T>(prev: T, next: T): T {\n\treturn jsonDeepEquals(prev, next) ? prev : next;\n}\n\ntype HookReturn<\n\tT,\n\tMode extends \"value\" | \"accessor\" | \"signal\",\n> = Mode extends \"accessor\"\n\t? () => T\n\t: Mode extends \"signal\"\n\t\t? ReadonlySignal<T>\n\t\t: T;\n\ntype StateSelector<State, Selected> = (state: State) => Selected;\n\nexport type VormaClient<\n\tA extends AppConfig,\n\tElement,\n\tAnchorProps extends object,\n\tHookReturnMode extends \"value\" | \"accessor\" | \"signal\" = \"value\",\n> = AdapterBase<A>[\"passthrough\"] & {\n\tboot: () => Promise<Result<void>>;\n\n\tdefineView: <P extends ToViewPattern<A>, T = any>(\n\t\tinput: ToDefineViewArgs<A, P, T, Element>,\n\t) => ViewDefinition;\n\n\tRootOutlet: (\n\t\tprops: { idx?: number } & Record<string, unknown>,\n\t) => Element | null;\n\n\tLink: <P extends ToViewPattern<A>>(\n\t\tprops: Omit<AnchorProps, \"href\"> & ToLinkProps<A, P>,\n\t) => Element;\n\n\tuseRouteSync: <P extends ToViewPattern<A>>(\n\t\targs: ToRouteSyncArgs<A, P>,\n\t) => void;\n\n\tuseRouteState: {\n\t\t(): HookReturn<RouteState, HookReturnMode>;\n\t\t<T>(\n\t\t\tselector: StateSelector<RouteState, T>,\n\t\t): HookReturn<T, HookReturnMode>;\n\t};\n\n\tuseWorkState: {\n\t\t(): HookReturn<WorkState, HookReturnMode>;\n\t\t<T>(\n\t\t\tselector: StateSelector<WorkState, T>,\n\t\t): HookReturn<T, HookReturnMode>;\n\t};\n\n\tuseLoaderData: <P extends ToViewPattern<A>>(\n\t\targs: ToRouteComponentProps<A, P>,\n\t) => HookReturn<ToLoaderOutput<A, P>, HookReturnMode>;\n\n\tusePatternLoaderData: <P extends ToViewPattern<A>>(\n\t\tpattern: P,\n\t) => HookReturn<ToLoaderOutput<A, P> | undefined, HookReturnMode>;\n\n\tuseClientLoaderData: <P extends ToViewPattern<A>, T>(\n\t\targs: ToRouteComponentProps<A, P, T>,\n\t) => HookReturn<T, HookReturnMode>;\n\n\tusePatternClientLoaderData: <T>(\n\t\tpattern: ToViewPattern<A>,\n\t) => HookReturn<T | undefined, HookReturnMode>;\n};\n"],"mappings":";;;;;;AAAA,MAAa,iBAAiB;AAC9B,MAAa,iBAAiB;AAC9B,MAAa,kBAAkB;AAE/B,MAAa,oBAAoB;AACjC,MAAa,4BAA4B;AAEzC,MAAa,yBAAyB;AAGtC,MAAa,qBAAqB;AAClC,M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