@async/framework 0.10.2 → 0.11.0
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/CHANGELOG.md +20 -0
- package/README.md +23 -7
- package/browser.d.ts +4 -7
- package/browser.js +17 -66
- package/browser.min.js +1 -1
- package/browser.ts +17 -66
- package/browser.umd.js +17 -66
- package/browser.umd.min.js +1 -1
- package/{server.d.ts → framework.d.ts} +4 -7
- package/framework.ts +5946 -0
- package/package.json +25 -17
- package/server.js +5945 -0
- package/examples/cache/index.html +0 -16
- package/examples/cache/main.js +0 -47
- package/examples/components/index.html +0 -11
- package/examples/components/main.js +0 -26
- package/examples/counter/index.html +0 -15
- package/examples/counter/main.js +0 -17
- package/examples/partials/index.html +0 -15
- package/examples/partials/main.js +0 -43
- package/examples/product/index.html +0 -32
- package/examples/product/main.js +0 -24
- package/examples/router/index.html +0 -18
- package/examples/router/main.js +0 -52
- package/examples/server-call/index.html +0 -21
- package/examples/server-call/main.js +0 -22
- package/examples/ssr/index.html +0 -12
- package/examples/ssr/main.js +0 -89
- package/examples/streaming/index.html +0 -16
- package/examples/streaming/main.js +0 -30
- package/src/app.js +0 -802
- package/src/async-signal.js +0 -277
- package/src/attributes.js +0 -52
- package/src/boundary-receiver.js +0 -302
- package/src/browser.js +0 -18
- package/src/cache.js +0 -193
- package/src/component.js +0 -373
- package/src/delay.js +0 -30
- package/src/elements.js +0 -63
- package/src/handlers.js +0 -219
- package/src/html.js +0 -158
- package/src/index.js +0 -20
- package/src/lazy-registry.js +0 -218
- package/src/loader.js +0 -772
- package/src/partials.js +0 -133
- package/src/registry-store.js +0 -267
- package/src/request-context.js +0 -40
- package/src/router.js +0 -617
- package/src/scheduler.js +0 -300
- package/src/server-entry.js +0 -20
- package/src/server-registry.js +0 -97
- package/src/server.js +0 -362
- package/src/signals.js +0 -592
package/browser.umd.js
CHANGED
|
@@ -2176,7 +2176,7 @@
|
|
|
2176
2176
|
|
|
2177
2177
|
function createServerProxy({
|
|
2178
2178
|
endpoint = "/__async/server",
|
|
2179
|
-
|
|
2179
|
+
transport,
|
|
2180
2180
|
signals,
|
|
2181
2181
|
loader,
|
|
2182
2182
|
router,
|
|
@@ -2184,8 +2184,8 @@
|
|
|
2184
2184
|
scheduler,
|
|
2185
2185
|
headers = {}
|
|
2186
2186
|
} = {}) {
|
|
2187
|
-
if (typeof
|
|
2188
|
-
throw new TypeError("createServerProxy(...) requires
|
|
2187
|
+
if (typeof transport !== "function") {
|
|
2188
|
+
throw new TypeError("createServerProxy(...) requires a transport function.");
|
|
2189
2189
|
}
|
|
2190
2190
|
|
|
2191
2191
|
const defaults = { signals, loader, router, cache, scheduler };
|
|
@@ -2200,7 +2200,7 @@
|
|
|
2200
2200
|
};
|
|
2201
2201
|
assertJsonTransportable(body);
|
|
2202
2202
|
|
|
2203
|
-
const response = await
|
|
2203
|
+
const response = await transport(joinEndpoint(endpoint, id), {
|
|
2204
2204
|
method: "POST",
|
|
2205
2205
|
headers: {
|
|
2206
2206
|
"content-type": "application/json",
|
|
@@ -3984,6 +3984,8 @@
|
|
|
3984
3984
|
|
|
3985
3985
|
const route = defineRoute;
|
|
3986
3986
|
|
|
3987
|
+
const routerModes = new Set(["csr", "spa", "ssr", "mpa"]);
|
|
3988
|
+
|
|
3987
3989
|
function createRouteRegistry(initialMap = {}, options = {}) {
|
|
3988
3990
|
const registryStore = options.registry ?? createRegistryStore();
|
|
3989
3991
|
const type = options.type ?? "route";
|
|
@@ -4079,7 +4081,7 @@
|
|
|
4079
4081
|
}
|
|
4080
4082
|
|
|
4081
4083
|
function createRouter({
|
|
4082
|
-
mode = "ssr
|
|
4084
|
+
mode = "ssr",
|
|
4083
4085
|
root,
|
|
4084
4086
|
boundary = "route",
|
|
4085
4087
|
routes = createRouteRegistry(),
|
|
@@ -4089,11 +4091,10 @@
|
|
|
4089
4091
|
server,
|
|
4090
4092
|
cache,
|
|
4091
4093
|
partials,
|
|
4092
|
-
fetch: fetchImpl = globalThis.fetch?.bind(globalThis),
|
|
4093
|
-
routeEndpoint = "/__async/route",
|
|
4094
4094
|
attributes,
|
|
4095
4095
|
scheduler
|
|
4096
4096
|
} = {}) {
|
|
4097
|
+
assertRouterMode(mode);
|
|
4097
4098
|
const documentRef = root?.ownerDocument ?? root ?? globalThis.document;
|
|
4098
4099
|
const rootNode = root ?? documentRef;
|
|
4099
4100
|
const signalRegistry = signals ?? loader?.signals ?? createSignalRegistry();
|
|
@@ -4162,16 +4163,13 @@
|
|
|
4162
4163
|
|
|
4163
4164
|
prefetch(url) {
|
|
4164
4165
|
assertActive();
|
|
4165
|
-
if (mode === "
|
|
4166
|
-
return
|
|
4166
|
+
if (mode === "mpa" || mode === "ssr") {
|
|
4167
|
+
return Promise.resolve(null);
|
|
4167
4168
|
}
|
|
4168
4169
|
const matched = api.match(url);
|
|
4169
4170
|
if (matched?.route?.partial && partials?.resolve?.(matched.route.partial)) {
|
|
4170
4171
|
return partials.render(matched.route.partial, matched.params, contextFor(matched));
|
|
4171
4172
|
}
|
|
4172
|
-
if (typeof fetchImpl === "function") {
|
|
4173
|
-
return fetchRoute(url, { prefetch: true });
|
|
4174
|
-
}
|
|
4175
4173
|
return Promise.resolve(null);
|
|
4176
4174
|
},
|
|
4177
4175
|
|
|
@@ -4183,9 +4181,6 @@
|
|
|
4183
4181
|
}
|
|
4184
4182
|
|
|
4185
4183
|
const target = resolveUrl(url);
|
|
4186
|
-
if (mode === "ssr-spa") {
|
|
4187
|
-
return fetchRoutePartial(target, options);
|
|
4188
|
-
}
|
|
4189
4184
|
return renderLocalRoutePartial(target, options);
|
|
4190
4185
|
},
|
|
4191
4186
|
|
|
@@ -4273,31 +4268,6 @@
|
|
|
4273
4268
|
}
|
|
4274
4269
|
}
|
|
4275
4270
|
|
|
4276
|
-
async function fetchRoutePartial(target, options = {}) {
|
|
4277
|
-
const matched = api.match(target);
|
|
4278
|
-
const navigation = beginNavigation(target, matched);
|
|
4279
|
-
setMatchedRouterState(target, matched, { pending: true, error: null });
|
|
4280
|
-
|
|
4281
|
-
try {
|
|
4282
|
-
const result = await fetchRoute(target.href, { signal: navigation.abort });
|
|
4283
|
-
if (!isActiveNavigation(navigation)) {
|
|
4284
|
-
return null;
|
|
4285
|
-
}
|
|
4286
|
-
await applyNavigationResult(result, target, options, navigation);
|
|
4287
|
-
if (!isActiveNavigation(navigation)) {
|
|
4288
|
-
return null;
|
|
4289
|
-
}
|
|
4290
|
-
setRouterState({ pending: false, error: null });
|
|
4291
|
-
return result;
|
|
4292
|
-
} catch (error) {
|
|
4293
|
-
if (!isActiveNavigation(navigation)) {
|
|
4294
|
-
return null;
|
|
4295
|
-
}
|
|
4296
|
-
setRouterState({ pending: false, error });
|
|
4297
|
-
throw error;
|
|
4298
|
-
}
|
|
4299
|
-
}
|
|
4300
|
-
|
|
4301
4271
|
async function applyNavigationResult(result, target, options, navigation) {
|
|
4302
4272
|
if (!isActiveNavigation(navigation)) {
|
|
4303
4273
|
return;
|
|
@@ -4328,29 +4298,6 @@
|
|
|
4328
4298
|
documentRef.defaultView?.history?.pushState?.({}, "", target.href);
|
|
4329
4299
|
}
|
|
4330
4300
|
|
|
4331
|
-
async function fetchRoute(url, { prefetch = false, signal } = {}) {
|
|
4332
|
-
if (typeof fetchImpl !== "function") {
|
|
4333
|
-
throw new Error("Router navigation requires a partial registry or fetch.");
|
|
4334
|
-
}
|
|
4335
|
-
const response = await fetchImpl(`${routeEndpoint}?to=${encodeURIComponent(String(url))}`, {
|
|
4336
|
-
headers: {
|
|
4337
|
-
accept: "application/json, text/html"
|
|
4338
|
-
},
|
|
4339
|
-
signal
|
|
4340
|
-
});
|
|
4341
|
-
if (!response.ok) {
|
|
4342
|
-
throw new Error(`Route "${url}" failed with ${response.status}.`);
|
|
4343
|
-
}
|
|
4344
|
-
if (prefetch) {
|
|
4345
|
-
return response;
|
|
4346
|
-
}
|
|
4347
|
-
const type = response.headers.get("content-type") ?? "";
|
|
4348
|
-
if (type.includes("application/json")) {
|
|
4349
|
-
return response.json();
|
|
4350
|
-
}
|
|
4351
|
-
return { boundary, html: await response.text() };
|
|
4352
|
-
}
|
|
4353
|
-
|
|
4354
4301
|
function contextFor(matched, navigation) {
|
|
4355
4302
|
return {
|
|
4356
4303
|
params: matched.params,
|
|
@@ -4540,6 +4487,12 @@
|
|
|
4540
4487
|
return target.hash !== current.hash || anchor.getAttribute?.("href")?.startsWith("#") === true;
|
|
4541
4488
|
}
|
|
4542
4489
|
|
|
4490
|
+
function assertRouterMode(mode) {
|
|
4491
|
+
if (!routerModes.has(mode)) {
|
|
4492
|
+
throw new TypeError(`Unknown router mode "${mode}".`);
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
4495
|
+
|
|
4543
4496
|
function dispatchAsyncError(element, error) {
|
|
4544
4497
|
const EventCtor = element.ownerDocument?.defaultView?.CustomEvent ?? globalThis.CustomEvent;
|
|
4545
4498
|
if (typeof EventCtor !== "function") {
|
|
@@ -4938,7 +4891,7 @@
|
|
|
4938
4891
|
return;
|
|
4939
4892
|
}
|
|
4940
4893
|
router = router ?? createRouter({
|
|
4941
|
-
mode: options.mode ?? "ssr
|
|
4894
|
+
mode: options.mode ?? "ssr",
|
|
4942
4895
|
root,
|
|
4943
4896
|
boundary: options.boundary ?? "route",
|
|
4944
4897
|
routes,
|
|
@@ -4949,8 +4902,6 @@
|
|
|
4949
4902
|
cache: browserCache,
|
|
4950
4903
|
partials,
|
|
4951
4904
|
scheduler,
|
|
4952
|
-
fetch: options.fetch,
|
|
4953
|
-
routeEndpoint: options.routeEndpoint,
|
|
4954
4905
|
attributes
|
|
4955
4906
|
});
|
|
4956
4907
|
runtime.router = router;
|
package/browser.umd.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e){const t=function(){"use strict";const e=(()=>{const e=Symbol.for("@async/framework.asyncSignal");return{asyncSignal:function(t,r){if("string"!=typeof t||0===t.length)throw new TypeError("asyncSignal(id, fn) requires a non-empty string id.");if("function"!=typeof r)throw new TypeError("asyncSignal(id, fn) requires a function.");let n,o,s,a,i=!1,c=null,u="idle",l=0,f=t;const p=new Set,h=new Set,d={[e]:!0,kind:"async-signal",get id(){return f},get value(){return n},get loading(){return i},get error(){return c},get status(){return u},get version(){return l},set:e=>(n=e,i=!1,c=null,u="ready",m(),n),refresh(){if(!o)throw new Error(`Async signal "${f}" is not registered.`);a&&!a.aborted&&a.cancel(new Error(`Async signal "${f}" refreshed.`));const e=l+1;l=e,i=!0,c=null,u="loading";const t=new AbortController;s=t,a=t.signal,function(e,t){Object.defineProperty(e,"cancel",{configurable:!0,enumerable:!1,value(e){t.abort(e)}})}(a,t),m();const p={signals:o,id:f,get server(){const e=o._context?.()??{},t=e.server;return"function"==typeof t?._withContext?t._withContext({signals:o,router:e.router,loader:e.loader,cache:e.cache,abort:a,scheduler:e.scheduler}):t},get router(){return o._context?.().router},get loader(){return o._context?.().loader},get cache(){return o._context?.().cache},get scheduler(){return o._context?.().scheduler},get version(){return e},get abort(){return a},refresh:()=>d.refresh()};let b;try{b=o._collectDependencies(()=>r.call(p))}catch(t){return y(e,t),Promise.reject(t)}return function(e){for(const e of h)e();h.clear();for(const t of e){const e=String(t).split(".")[0];e&&e!==f&&h.add(o.subscribe(t,()=>w()))}}(b.dependencies),Promise.resolve(b.value).then(t=>g(e)?(n=t,i=!1,c=null,u="ready",m(),n):n,t=>g(e)?a?.aborted?(i=!1,u=void 0===n?"idle":"ready",m(),n):(y(e,t),n):n)},cancel(e){a&&!a.aborted&&a.cancel(e)},subscribe(e){if("function"!=typeof e)throw new TypeError("subscribe(fn) requires a function.");return p.add(e),()=>p.delete(e)},snapshot:()=>({value:n,loading:i,error:c,status:u,version:l}),_bindRegistry(e,t){o=e,f=t;const r=()=>{o===e&&"idle"===u&&d.refresh()},n=o._context?.().scheduler;n?n.enqueue("async",r,{scope:f,key:`asyncSignal:${f}:initial`}):queueMicrotask(r)},_dispose(){d.cancel(new Error(`Async signal "${f}" disposed.`));for(const e of h)e();h.clear(),p.clear()}};function y(e,t){g(e)&&(i=!1,c=t,u="error",m())}function g(e){return e===l&&s?.signal===a}function w(){a&&!a.aborted&&a.cancel(new Error(`Async signal "${f}" dependency changed.`));const e=o?._context?.().scheduler;e?e.enqueue("async",()=>d.refresh(),{scope:f,key:`asyncSignal:${f}:refresh`}):d.refresh()}function m(){for(const e of[...p])e(d)}return d},isAsyncSignal:function(t){return Boolean(t?.[e])}}})(),t=(()=>{const e=new Set(["handler","component","asyncSignal","partial","route"]);function t(t={}){const r=function(e){if("string"!=typeof e||0===e.length)throw new TypeError("registryAssets.baseUrl must be a non-empty string.");return i(e)||e.startsWith("/")||e.startsWith("./")||e.startsWith("../")?a(e):`/${s(e)}`}(t.baseUrl??"_async"),n={component:"component",handler:"handler",asyncSignal:"asyncSignal",partial:"partial",route:"route",...t.paths??{}};for(const[t,r]of Object.entries(n))if(e.has(t)&&("string"!=typeof r||0===r.length))throw new TypeError(`Registry asset path for "${t}" must be a non-empty string.`);return{baseUrl:r,paths:n}}function r(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.url)}function n(t,n,c,u){if(!e.has(t))throw new Error(`Registry type "${t}" does not support lazy descriptors.`);if(!r(c))throw new TypeError(`Registry descriptor for "${t}:${n}" requires a url.`);const{path:l,hash:f}=function(e){const t=e.indexOf("#");return-1===t?{path:e,hash:""}:{path:e.slice(0,t),hash:e.slice(t+1)}}(c.url),p=function(e,t,r){if(i(t)||t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))return t;const n=r.paths[e]??e;return function(...e){const[t,...r]=e;return[a(t),...r.map(s)].filter(Boolean).join("/")}(r.baseUrl,n,t)}(t,l,u);return{moduleUrl:p,exportNames:f?[f]:o(n,l),url:f?`${p}#${f}`:p}}function o(e,t){const r=[],n=e.split(".").filter(Boolean).at(-1),o=t.split("/").filter(Boolean).at(-1)?.replace(/\.[^.]+$/,"");for(const e of[n,o,"default"])e&&!r.includes(e)&&r.push(e);return r}function s(e){return String(e).replace(/^\/+|\/+$/g,"")}function a(e){return String(e).replace(/\/+$/g,"")}function i(e){return/^[A-Za-z][A-Za-z\d+.-]*:/.test(e)}function c(e){return!e||"object"!=typeof e||Array.isArray(e)?JSON.stringify(e):JSON.stringify(Object.keys(e).sort().map(t=>[t,e[t]]))}return{defineRegistrySnapshot:function(e={}){if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("defineRegistrySnapshot(snapshot) requires an object.");return e},createLazyRegistry:function(e={}){const o=t(e.registryAssets??e.assets),s=e.importModule??(e=>import(e)),a=new Map,i=new Map;return{registryAssets:o,resolveUrl:(e,t,r)=>n(e,t,r,o),async resolve(e,t,c){if(!r(c))return c;const u=`${e}:${t}`;if(i.has(u))return i.get(u);const l=n(e,t,c,o);let f,p=a.get(l.moduleUrl);p||(p=Promise.resolve().then(()=>s(l.moduleUrl)),a.set(l.moduleUrl,p));try{f=await p}catch(r){throw a.get(l.moduleUrl)===p&&a.delete(l.moduleUrl),new Error(`Lazy ${e} "${t}" failed to import ${l.moduleUrl}: ${h=r,h instanceof Error?h.message:String(h)}`,{cause:r})}var h;const d=function(e,t,r,n){for(const r of t)if(r in e)return e[r];throw new Error(`Lazy ${r} "${n}" did not export ${t.map(e=>`"${e}"`).join(", ")}.`)}(f,l.exportNames,e,t);return i.set(u,d),d},inspect:()=>({registryAssets:o,modules:[...a.keys()],exports:[...i.keys()]})}},normalizeRegistryAssets:t,isLazyDescriptor:r,sameRegistryValue:function(e,t){return e===t||!(!r(e)||!r(t))&&c(e)===c(t)},publicRegistryValue:function(e,t){return r(e)?{...e}:{id:t}}}})(),r=(()=>{const{publicRegistryValue:e}=t,r=new Set(["signal","handler","server","partial","route","component","asyncSignal"]),n=new Set(["cache.browser","cache.server"]),o=new Set(["cache.browser.entries","cache.server.entries"]),s=new Set([...r,...n,...o]);function a(e){if(!s.has(e))throw new Error(`Unknown Async registry type "${e}".`);return e}function i(e,t){if("string"!=typeof t||0===t.length)throw new TypeError(`${e} id must be a non-empty string.`)}function c(t,r,n,s){return"server"===t&&"browser"===s.target?e(n,r):o.has(t)?n?.value:n}function u(e,t){return"cache.server.entries"===e&&"browser"===t}function l(e){const t={};for(const[r,n]of e)t[r]="function"==typeof n?.snapshot?n.snapshot():n?.value??n;return t}function f(t){const r={};for(const[n,o]of t)r[n]=e(o,n);return r}function p(e){return Object.fromEntries(e)}function h(e){const t={};for(const[r,n]of e)t[r]=n?.value;return t}function d(e){return e&&"object"==typeof e&&Object.hasOwn(e,"value")?e:{value:e}}return{createRegistryStore:function e(t={},n={}){const o=n.backing??{signal:new Map,handler:new Map,server:new Map,partial:new Map,route:new Map,component:new Map,asyncSignal:new Map,cache:{browser:new Map,server:new Map},cacheEntries:{browser:new Map,server:new Map}},s=n.target??"server",y={target:s,register(e,t,r){const n=y._map(e);if(i(e,t),n.has(t))throw new Error(`${e} "${t}" is already registered.`);return n.set(t,r),t},registerMany(e,t={}){for(const[r,n]of Object.entries(t??{}))y.register(e,r,n);return y},set(e,t,r){const n=y._map(e);return i(e,t),n.set(t,r),r},unregister:(e,t)=>y.delete(e,t),delete:(e,t)=>y._map(e).delete(t),keys:e=>u(e,s)?[]:[...y._map(e).keys()],entries(e,t={}){const r=a(e);return u(r,t.target??s)?[]:[...y._map(r)].map(([e,n])=>[e,c(r,e,n,{target:s,...t})])},has:(e,t)=>(i(e,t),!u(e,s)&&y._map(e).has(t)),get(e,t,r={}){i(e,t);const n=a(e);if(u(n,r.target??s))return;const o=y._map(n).get(t);return void 0!==o?c(n,t,o,{target:s,...r}):void 0},snapshot(e={}){const t=e.target??s;return{signal:l(o.signal),handler:f(o.handler),server:f(o.server),partial:f(o.partial),route:p(o.route),component:f(o.component),asyncSignal:f(o.asyncSignal),cache:{browser:p(o.cache.browser),server:p(o.cache.server)},entries:{browser:h(o.cacheEntries.browser),server:"browser"===t?{}:h(o.cacheEntries.server)}}},rawSnapshot:()=>({signal:Object.fromEntries(o.signal),handler:Object.fromEntries(o.handler),server:Object.fromEntries(o.server),partial:Object.fromEntries(o.partial),route:Object.fromEntries(o.route),component:Object.fromEntries(o.component),asyncSignal:Object.fromEntries(o.asyncSignal),cache:{browser:Object.fromEntries(o.cache.browser),server:Object.fromEntries(o.cache.server)}}),view:(t={})=>e(void 0,{backing:o,target:t.target??s}),_map(e){const t=a(e);if(r.has(t))return o[t];if("cache.browser"===t)return o.cache.browser;if("cache.server"===t)return o.cache.server;if("cache.browser.entries"===t)return o.cacheEntries.browser;if("cache.server.entries"===t)return o.cacheEntries.server;throw new Error(`Unknown Async registry type "${e}".`)}};return function(e,t={}){e.registerMany("signal",t.signal),e.registerMany("handler",t.handler),e.registerMany("server",t.server),e.registerMany("partial",t.partial),e.registerMany("route",t.route),e.registerMany("component",t.component),e.registerMany("asyncSignal",t.asyncSignal),e.registerMany("cache.browser",t.cache?.browser),e.registerMany("cache.server",t.cache?.server);const r=t.entries??{};for(const[t,n]of Object.entries(r.browser??{}))e.set("cache.browser.entries",t,d(n));for(const[t,n]of Object.entries(r.server??{}))e.set("cache.server.entries",t,d(n))}(y,t),y},attachRegistryInspection:function(e,t,r){return Object.defineProperty(e,"registry",{configurable:!0,enumerable:!0,value:t}),e.keys=()=>t.keys(r),e.entries=()=>t.entries(r),e.inspect=()=>t.entries(r),e}}})(),n=(()=>{const{attachRegistryInspection:e,createRegistryStore:t}=r,n=Symbol.for("@async/framework.cacheDefinition");function o(e={}){return{[n]:!0,kind:"cache-definition",store:e.store??"memory",ttl:e.ttl}}function s(e){if("string"!=typeof e||0===e.length)throw new TypeError("Cache id must be a non-empty string.")}function a(e){if("string"!=typeof e||0===e.length)throw new TypeError("Cache key must be a non-empty string.")}return{defineCache:o,createCacheRegistry:function(r={},{now:i=()=>Date.now(),registry:c,type:u="cache.browser"}={}){const l=c??t(),f=l._map(u),p=l._map(`${u}.entries`),h=new Map,d=e({register(e,t=o()){s(e);const r=function(e){return e?.[n]?e:o(e)}(t);if(f.has(e))throw new Error(`Cache "${e}" is already registered.`);return f.set(e,r),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))d.register(t,r);return d},unregister:e=>(s(e),f.delete(e)),resolve:e=>(s(e),f.get(e)),get:e=>(a(e),y(e).value),set(e,t,r={}){a(e);const n=r.ttl??function(e,t){if(void 0!==t)return f.get(t);if(f.has(e))return f.get(e);const r=e.split(":")[0];return f.get(r)}(e,r.cache)?.ttl;return p.set(e,{value:t,expiresAt:void 0===n?void 0:i()+n}),t},async getOrSet(e,t,r={}){if(a(e),"function"!=typeof t)throw new TypeError("cache.getOrSet(key, fn) requires a function.");const n=y(e);if(n.found)return n.value;if(h.has(e))return h.get(e);let o;return o=Promise.resolve().then(t).then(t=>(h.get(e)===o&&d.set(e,t,r),t)).finally(()=>{h.get(e)===o&&h.delete(e)}),h.set(e,o),o},delete:e=>(a(e),h.delete(e),p.delete(e)),clear(e){if(void 0===e)return p.clear(),h.clear(),d;for(const t of[...p.keys()])t.startsWith(e)&&p.delete(t);for(const t of[...h.keys()])t.startsWith(e)&&h.delete(t);return d},snapshot(){const e={};for(const[t]of p){const{found:r,value:n}=y(t);r&&void 0!==n&&(e[t]=n)}return e},restore(e={}){for(const[t,r]of Object.entries(e??{}))d.set(t,r);return d},entryKeys:()=>[...p.keys()],entryEntries:()=>l.entries(`${u}.entries`),_adoptMany:()=>d},l,u);return d.registerMany(r),d;function y(e){const t=p.get(e);return t?void 0!==t.expiresAt&&t.expiresAt<=i()?(p.delete(e),{found:!1,value:void 0}):{found:!0,value:t.value}:{found:!1,value:void 0}}}}})(),o=(()=>{const e=Object.freeze({async:["async:"],class:["class:"],signal:["signal:"],on:["on:"]});function t(t={}){return{async:r(t.async,e.async),class:r(t.class,e.class),signal:r(t.signal,e.signal),on:r(t.on,e.on)}}function r(e,t){return(null==e?t:Array.isArray(e)?e:[e]).map(e=>{if("string"!=typeof e||0===e.length)throw new TypeError("Attribute prefixes must be non-empty strings.");return e})}return{defineAttributeConfig:function(e={}){return t(e)},normalizeAttributeConfig:t,attributeName:function(e,r,n){return t(e)[r][0]+n},readAttribute:function(e,r,n,o){for(const s of t(r)[n]){const t=`${s}${o}`;if(e.hasAttribute?.(t))return e.getAttribute(t)}return null},matchAttribute:function(e,r,n){for(const o of t(r)[n])if(e.startsWith(o))return e.slice(o.length);return null}}})(),s=(()=>{const{asyncSignal:n,isAsyncSignal:o}=e,{attachRegistryInspection:s,createRegistryStore:a}=r,{createLazyRegistry:i,isLazyDescriptor:c}=t,u=Symbol.for("@async/framework.signal"),l=Symbol.for("@async/framework.computed"),f=Symbol.for("@async/framework.effect"),p=Symbol.for("@async/framework.signalRef"),h=[];function d(e){let t=e;const r=new Set;return{[u]:!0,kind:"signal",get value(){return t},set value(e){this.set(e)},set:e=>(Object.is(t,e)||(t=e,function(){for(const e of[...r])e(t)}()),t),update(e){return this.set(e(t))},subscribe(e){if("function"!=typeof e)throw new TypeError("subscribe(fn) requires a function.");return r.add(e),()=>r.delete(e)},snapshot:()=>t}}function y(e,t){let r=e;for(const e of t){if(null==r)return;r=r[e]}return r}function g(e,t){return Array.isArray(e)?[...e]:e&&"object"==typeof e?{...e}:(r=t,String(Number(r))===String(r)?[]:{});var r}function w(e,t){const r=e.get(t);if(!r)throw new Error(`Signal "${t}" is not registered.`);return r}function m(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal id must be a non-empty string.")}return{createSignal:d,computed:function(e){if("function"!=typeof e)throw new TypeError("computed(fn) requires a function.");const t=d(void 0);return{[l]:!0,kind:"computed",get value(){return t.value},set:e=>t.set(e),update:e=>t.update(e),subscribe:e=>t.subscribe(e),snapshot:()=>t.snapshot(),_bindRegistry:(r,n)=>r.effect(()=>{t.set(e.call({signals:r,id:n,server:r._context?.().server,router:r._context?.().router,loader:r._context?.().loader,cache:r._context?.().cache,scheduler:r._context?.().scheduler}))})}},effect:function(e){if("function"!=typeof e)throw new TypeError("effect(fn) requires a function.");return{[f]:!0,kind:"effect",fn:e,_bindRegistry:t=>t.effect(e)}},createSignalRegistry:function(e={},t={}){const r=t.registry??a(),u=t.type??"signal",l=r._map(u),f=r._map("asyncSignal"),b=t.lazyRegistry??i(t),v=new Map,S={},E=new Set;let $=0,A=0;const R=s({register(e,t){if(m(e),l.has(e))throw new Error(`Signal "${e}" is already registered.`);const r=function(e){return t=e,Boolean(t&&"object"==typeof t&&"function"==typeof t.subscribe)?e:d(e);var t}(t);return l.set(e,r),j(e,r),R.ref(e)},registerMany(e){for(const[t,r]of Object.entries(e??{}))R.register(t,r);return R},unregister:e=>(m(e),!!l.has(e)&&(v.get(e)?.(),v.delete(e),l.get(e)?._dispose?.(),l.delete(e),E.delete(e),!0)),ensure:(e,t)=>(m(e),k(e),l.has(e)||R.register(e,d(t)),R.ref(e)),has:e=>l.has(e)||f.has(e),get(e){const t=O(e);return function(e){const t=h.at(-1);t&&t.add(e)}(t.path),function(e,t){if(o(e)&&t[0]?.startsWith("$"))return y(function(e,t){switch(t){case"$value":return e.value;case"$loading":return e.loading;case"$error":return e.error;case"$status":return e.status;case"$version":return e.version;default:return}}(e,t[0]),t.slice(1));return y(e.value,t)}(w(l,t.id),t.parts)},set(e,t){const r=O(e),n=w(l,r.id);if(0===r.parts.length)return n.set(t);const o=function(e,t,r){const n=g(e,t[0]);let o=n;for(let e=0;e<t.length-1;e+=1){const r=t[e],n=t[e+1];o[r]=g(o[r],n),o=o[r]}return o[t.at(-1)]=r,n}(n.value,r.parts,t);return n.set(o),t},update(e,t){if("function"!=typeof t)throw new TypeError("update(path, fn) requires a function.");return R.set(e,t(R.get(e)))},ref:e=>(m(e),k(e),function(e,t){return{[p]:!0,kind:"signal-ref",id:t,get value(){return e.get(t)},set value(r){e.set(t,r)},get loading(){return e._entry(t).loading??!1},get error(){return e._entry(t).error??null},get status(){return e._entry(t).status??"ready"},get version(){return e._entry(t).version??0},get:()=>e.get(t),set:r=>e.set(t,r),update:r=>e.update(t,r),subscribe:r=>e.subscribe(t,r),refresh(){const r=e._entry(t);if("function"!=typeof r.refresh)throw new Error(`Signal "${t}" cannot refresh.`);return r.refresh()},cancel(r){const n=e._entry(t);if("function"!=typeof n.cancel)throw new Error(`Signal "${t}" cannot cancel.`);return n.cancel(r)},toString:()=>t,[Symbol.toPrimitive]:()=>t}}(R,e)),subscribe(e,t,r={}){if("function"!=typeof t)throw new TypeError("subscribe(path, fn) requires a function.");const n=O(e),o=w(l,n.id),s=++$;return o.subscribe(()=>{!function(e,t={}){const r=t.scheduler;r&&"sync"!==t.phase?r.enqueue(t.phase??"effect",e,{scope:t.scope,key:t.key}):e()}(()=>t(R.get(n.path),{id:n.id,path:n.path,signal:o}),{...r,key:r.key??`signal:${n.path}:${s}`})})},snapshot(){const e={};for(const[t,r]of l)e[t]="function"==typeof r.snapshot?r.snapshot():r.value;return e},asyncSignal:(e,t)=>(R.register(e,n(e,t)),R.ref(e)),effect(e,t={}){let r,n=[],o=!1;const s=t.scheduler,a=++A,i=()=>{if(o)return;"function"==typeof r&&r();for(const e of n)e();n=[];const t=R._collectDependencies(()=>e.call({signals:R,server:S.server,router:S.router,loader:S.loader,cache:S.cache,scheduler:S.scheduler}));r=t.value,n=t.dependencies.map(e=>R.subscribe(e,c))},c=()=>{s?s.enqueue(t.phase??"effect",i,{scope:t.scope,key:t.key??`effect:${a}`}):i()};return i(),()=>{o=!0,"function"==typeof r&&r();for(const e of n)e()}},destroy(){for(const e of v.values())e();v.clear();for(const e of l.values())e._dispose?.();l.clear()},_collectDependencies(e){const t=new Set;h.push(t);try{return{value:e(),dependencies:[...t]}}finally{h.pop()}},_entry:e=>(k(e),w(l,e)),_setContext:(e={})=>(Object.assign(S,e),R),_context:()=>S,_adoptMany(e={}){for(const t of Object.keys(e??{}))l.has(t)&&j(t,l.get(t));return R}},r,u);for(const[e,t]of l)j(e,t);return R.registerMany(e),R;function j(e,t){if(E.has(e)||"function"!=typeof t?._bindRegistry)return;E.add(e);const r=t._bindRegistry(R,e);"function"==typeof r&&v.set(e,r)}function O(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal path must be a non-empty string.");const t=e.split(".");for(let r=t.length;r>0;r-=1){const n=t.slice(0,r).join(".");if(l.has(n)||f.has(n))return k(n),{id:n,parts:t.slice(r),path:e}}const[r,...n]=t;return{id:r,parts:n,path:e}}function k(e){if(l.has(e)||!f.has(e))return;const t=f.get(e);if(!c(t)&&"function"!=typeof t)throw new TypeError(`Async signal "${e}" must be a function or lazy descriptor.`);const r=n(e,async function(...r){const n=await b.resolve("asyncSignal",e,t);if("function"!=typeof n)throw new TypeError(`Async signal "${e}" did not resolve to a function.`);return n.apply(this,r)});l.set(e,r),j(e,r)}},isSignalRef:function(e){return Boolean(e?.[p])},signal:d}})(),a=(()=>{const{isSignalRef:e}=s,{attributeName:t,matchAttribute:r,normalizeAttributeConfig:n}=o,a=Symbol.for("@async/framework.template"),i=Symbol.for("@async/framework.rawHtml");function c(e){return Boolean(e?.[a])}function u(e,t={}){if(c(e)){const r=p(t);let n="";for(let t=0;t<e.strings.length;t+=1)n+=e.strings[t],t<e.values.length&&(n+=l(e.values[t],{...r,attribute:h(e.strings[t])}));return n}return l(e,p(t))}function l(n,o=p()){return n?.[i]?n.html:c(n)?u(n,o):o.attribute?function(n,o){const s=r(o.attribute.name,o.attributes,"signal"),a=r(o.attribute.name,o.attributes,"class"),i=function(t,r){return e(t)?t.id:"string"==typeof t&&r.signals?.has?.(t)?t:null}(n,o);if("value"===o.attribute.name&&i){const r=function(t,r){return e(t)?t.value:"string"==typeof t&&r.signals?.has?.(t)?r.signals.get(t):t}(n,o),s=t(o.attributes,"signal","value");return`${d(r)}${o.attribute.quote} ${s}=${o.attribute.quote}${d(i)}`}if(null!=s||null!=a){if(i)return d(i);if(function(e){return Boolean(e&&"object"==typeof e)}(n))return d(function(e,t){return"function"!=typeof t.bind?e:t.bind(e)}(n,o))}return f(n,o)}(n,o):Array.isArray(n)?n.map(e=>l(e,o)).join(""):e(n)?d(n.value):null==n||!1===n?"":d(n)}function f(t,r){return Array.isArray(t)?t.map(e=>f(e,r)).join(""):e(t)?d(t.value):null==t||!1===t?"":d(t)}function p(e={}){return{...e,attributes:n(e.attributes)}}function h(e){const t=e.match(/(?:^|[\s<])([^\s"'=<>`]+)\s*=\s*(["'])$/);return t?{name:t[1],quote:t[2]}:null}function d(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}return{html:function(e,...t){return{[a]:!0,strings:e,values:t}},isTemplateResult:c,rawHtml:function(e){return{[i]:!0,html:String(e??"")}},renderTemplate:u,escapeHtml:d}})(),i=(()=>{const{attributeName:e}=o,{escapeHtml:n,rawHtml:s,renderTemplate:i}=a,{attachRegistryInspection:c,createRegistryStore:u}=r,{createLazyRegistry:l,isLazyDescriptor:f}=t,p=Symbol.for("@async/framework.component");let h=0;function d(e){if("function"!=typeof e)throw new TypeError("defineComponent(fn) requires a function.");return Object.defineProperty(e,p,{configurable:!0,value:!0}),e}function y(e){return Boolean(e?.[p])}function g(t,r={},o,a="component"){if(!y(t)&&"function"!=typeof t)throw new TypeError("renderComponent(Component) requires a component function.");const c=`${a}.${function(e){return e.displayName||e.name||"anonymous"}(t)}.${++h}`,u=[],l=[],f=[],p=[],d=[],m={attributes:o.attributes,signals:o.signals,bind(e){const t=o.loader?._registerBinding?.(e);if(!t)throw new Error("Inline template bindings require a Loader.");return d.push(t),t}},b=e=>i(e,m),v=function({runtime:t,scope:r,cleanups:o,attachHooks:a,visibleHooks:i,destroyHooks:c,renderScopedTemplate:u}){const{signals:l,handlers:f,loader:p,server:h,router:d,cache:y,scheduler:m}=t,b=new WeakMap;let v=0,S=0;const E={scope:r,signals:l,handlers:f,loader:p,server:h,router:d,cache:y,scheduler:m,signal(e,t){if(1===arguments.length){const t=w(r,"signal."+ ++S),n=l.ensure(t,e);return o.push(()=>l.unregister?.(t)),n}const n=w(r,e),s=!l.has(n),a=l.ensure(n,t);return s&&o.push(()=>l.unregister?.(n)),a},computed(e,t){const n=w(r,e),s=!l.has(n),a=l.ensure(n,void 0);s&&o.push(()=>l.unregister?.(n));const i=l.effect(()=>{l.set(n,t.call(E))});return o.push(i),a},asyncSignal(e,t){const n=w(r,e),s=!l.has(n);return l.has(n)||l.asyncSignal(n,t),s&&o.push(()=>l.unregister?.(n)),l.ref(n)},effect(e){const t=l.effect(()=>e.call(E),{scheduler:m,phase:"effect",scope:r});return o.push(t),t},handler(e,t){if("function"==typeof e&&void 0===t){const t=e;if(b.has(t))return b.get(t);const r=$("handler."+ ++v,t);return b.set(t,r),r}if("function"!=typeof t)throw new TypeError("this.handler(name, fn) or this.handler(fn) requires a function.");return $(e,t)},render(e,n={}){const c=g(e,n,t,r);return o.push(c.cleanup),a.push(e=>c.attach(e)),i.push(e=>c.visible(e,p._observeVisible)),s(c.html)},suspense(r,o){const a=r?.id;if(!a)throw new TypeError("this.suspense(signalRef, views) requires a signal ref.");const i=function(e){const t="function"==typeof e?{ready:e}:e;if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("this.suspense(signalRef, views) requires views to be a function or object.");for(const e of["loading","ready","error"])if(Object.hasOwn(t,e)&&void 0!==t[e]&&"function"!=typeof t[e])throw new TypeError(`this.suspense(signalRef, views) view "${e}" must be a function.`);return t}(o),c=[];for(const o of["loading","ready","error"]){const s=i[o];if(!s)continue;const l=e(t.attributes,"async",o),f=u(s.call(E,r));c.push(`<template ${l}="${n(a)}">${f}</template>`)}return s(c.join(""))},on(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Component lifecycle event must be a non-empty string.");if("function"!=typeof t)throw new TypeError(`Component lifecycle "${e}" requires a function.`);const r="mount"===e?"attach":e;if("attach"!==r)if("visible"!==r){if("destroy"!==r)throw new Error(`Unsupported component lifecycle event "${e}".`);c.push(()=>t.call(E))}else i.push(e=>t.call(E,e));else a.push(e=>t.call(E,e))},onMount(e){E.on("attach",e)},onVisible(e){E.on("visible",e)}};return E;function $(e,t){const n=w(r,e);return f.register(n,e=>t.call({...E,...e},e)),o.push(()=>f.unregister?.(n)),n}}({runtime:o,scope:c,cleanups:u,attachHooks:l,visibleHooks:f,destroyHooks:p,renderScopedTemplate:b});return{html:b(t.call(v,r)),attach(e){for(const t of l)o.scheduler?.enqueue("lifecycle",()=>{const r=t(e);"function"==typeof r&&u.push(r)},{scope:c,key:`attach:${l.indexOf(t)}`})??S(t,e)},mount(e){this.attach(e)},visible(e,t){for(const r of f){const n=t(e,()=>{o.scheduler?.enqueue("lifecycle",()=>{const t=r(e);"function"==typeof t&&u.push(t)},{scope:c,key:`visible:${f.indexOf(r)}`})??E(r,e)});"function"==typeof n&&u.push(n)}},cleanup(){for(;p.length>0;)p.pop()?.();for(o.scheduler?.markScopeDestroyed(c);u.length>0;)u.pop()?.();for(;d.length>0;)o.loader?._releaseBinding?.(d.pop())}};function S(e,t){const r=e(t);"function"==typeof r&&u.push(r)}function E(e,t){const r=e(t);"function"==typeof r&&u.push(r)}}function w(e,t){if("string"!=typeof t||0===t.length)throw new TypeError("Scoped signal or handler name must be a non-empty string.");return`${e}.${t}`}return{defineComponent:d,createComponentRegistry:function(e={},t={}){const r=t.registry??u(),n=t.type??"component",o=r._map(n),s=t.lazyRegistry??l(t),a=new Map,i=c({register(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");if(!y(t)&&"function"!=typeof t&&!f(t))throw new TypeError(`Component "${e}" must be a component function.`);if(o.has(e))throw new Error(`Component "${e}" is already registered.`);return o.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))i.register(t,r);return i},unregister(e){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");return a.delete(e),o.delete(e)},resolve(e){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");const t=o.get(e);return f(t)?(a.has(e)||a.set(e,async function(...r){const o=await s.resolve(n,e,t);if("function"!=typeof o)throw new TypeError(`Component "${e}" did not resolve to a function.`);return o.apply(this,r)}),a.get(e)):t},_adoptMany:()=>i},r,n);return i.registerMany(e),i},isComponent:y,renderComponent:g,component:d}})(),c=(()=>{const e=new Set(["value","signals","boundary","html","redirect","error"]),t=Symbol.for("@async/framework.appliedServerResult"),r=new WeakSet;async function n(e,n={}){if(!h(e))return e;if(e[t]||r.has(e))return e;if(e.signals&&n.signals)for(const[t,r]of Object.entries(e.signals))n.signals.set?.(t,r);if(e.cache?.browser&&n.cache?.restore&&n.cache.restore(e.cache.browser),e.boundary&&Object.hasOwn(e,"html")&&n.loader?.swap?.(e.boundary,e.html),e.redirect&&await(n.router?.navigate?.(e.redirect)),e.error)throw(o=e.error)instanceof Error?o:o&&"object"==typeof o&&"string"==typeof o.message?Object.assign(new Error(o.message),o):new Error(String(o));var o;return Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:!0}),e}function o(e){return h(e)&&Object.hasOwn(e,"value")?e.value:e}function s(e={}){const t=l(e);if(t)return f(new t.ownerDocument.defaultView.FormData(t));const r=e.element??e.el??e.event?.target;return r?{value:"value"in r?r.value:void 0,checked:"checked"in r?r.checked:void 0,dataset:r.dataset?{...r.dataset}:{}}:{}}function a(e,t={},r=()=>({})){const s=new Map;return function i(c){const u=c.join(".");if(s.has(u))return s.get(u);const l=new Proxy(async(...t)=>{if(0===c.length)throw new Error("Server namespace is not directly callable.");const s=r()??{},a=await e(c.join("."),t,s);return await n(a,s),o(a)},{get(n,o){if("then"!==o)return o in n?n[o]:0===c.length&&"_withContext"===o?(n={})=>a(e,t,()=>({...r()??{},...n})):0===c.length&&"run"===o&&"function"==typeof t.run?(e,n=[],o={})=>t.run(e,n,{...r()??{},...o}):0===c.length&&Object.hasOwn(t,o)?t[o]:o===Symbol.toStringTag?"AsyncServerNamespace":"toString"===o?()=>0===c.length?"server":`server.${c.join(".")}`:i([...c,String(o)])}});return s.set(u,l),l}([])}function i(e=[],t){const r={};for(const n of e)r[n]=c(t,n);return r}function c(e,t){if(!e||"function"!=typeof e.get)throw new Error(`Signal "${t}" cannot be read without a signal registry.`);return e.get(t)}function u(e,t,{forServer:r}={}){if(("$event"===e||"$el"===e)&&r)throw new Error(`${e} cannot be passed to a server command.`);if("$event"===e)return t.event;if("$el"===e)return t.element??t.el;if("$value"===e){const e=t.element??t.el??t.event?.target;return e?.value}if("$checked"===e){const e=t.element??t.el??t.event?.target;return e?.checked}if("$form"===e){const e=l(t);return e?f(new e.ownerDocument.defaultView.FormData(e)):{}}if("$dataset"===e){const e=t.element??t.el??t.event?.target;return e?.dataset?{...e.dataset}:{}}throw new Error(`Event local "${e}" is not supported.`)}function l(e){const t=e.event,r=e.element??e.el??t?.target;return"FORM"===r?.tagName?r:"submit"===t?.type&&"FORM"===t.target?.tagName?t.target:"submit"===t?.type&&r?.form?r.form:null}function f(e){const t={};for(const[r,n]of e.entries())Object.hasOwn(t,r)?t[r]=Array.isArray(t[r])?[...t[r],n]:[t[r],n]:t[r]=n;return t}function p(e,t=new Set){if("bigint"==typeof e)throw new Error("Server proxy JSON transport does not support BigInt values.");if(null==e||"object"!=typeof e)return;if(t.has(e))throw new Error("Server proxy JSON transport does not support circular values.");t.add(e);const r=Object.prototype.toString.call(e);if("[object File]"===r||"[object Blob]"===r||"[object FormData]"===r)throw new Error("Server proxy JSON transport does not support File, Blob, or FormData values yet.");if(Array.isArray(e)){for(const r of e)p(r,t);t.delete(e)}else{for(const r of Object.values(e))p(r,t);t.delete(e)}}function h(t){return!(!t||"object"!=typeof t||Array.isArray(t))&&Object.keys(t).some(t=>e.has(t))}function d(e){if("string"!=typeof e||0===e.length)throw new TypeError("Server function id must be a non-empty string.")}return{createServerProxy:function({endpoint:e="/__async/server",fetch:t=globalThis.fetch?.bind(globalThis),signals:c,loader:u,router:l,cache:f,scheduler:h,headers:y={}}={}){if("function"!=typeof t)throw new TypeError("createServerProxy(...) requires fetch to be available.");const g={signals:c,loader:u,router:l,cache:f,scheduler:h};async function w(a,c=[],u={}){d(a);const l={...g,...u},f={args:c,input:u.input??s(l),signals:u.signalValues??i(u.signalPaths,l.signals)};p(f);const h=await t(function(e,t){return`${String(e).replace(/\/$/,"")}/${encodeURIComponent(t)}`}(e,a),{method:"POST",headers:{"content-type":"application/json",...y},body:JSON.stringify(f),signal:u.abort});if(!h.ok)throw new Error(`Server function "${a}" failed with ${h.status}.`);const w=await async function(e){return(e.headers.get("content-type")??"").includes("application/json")?e.json():{value:await e.text()}}(h);return await n(w,l),(m=o(w))&&"object"==typeof m&&r.add(m),m;var m}return a(w,{run:w,_setContext(e={}){Object.assign(g,e)}},()=>g)},resolveServerCommandArguments:function(e,t={}){const r=[],n={},o=[];for(const s of e){if("local"===s.type){r.push(u(s.name,t,{forServer:!0}));continue}const e=c(t.signals,s.path);r.push(e),n[s.path]=e,o.push(s.path)}return{args:r,signalValues:n,signalPaths:o}},applyServerResult:n,unwrapServerResult:o,defaultInput:s,createServerNamespace:a,createSignalReader:function(e){return e&&"function"!=typeof e.get?{get:t=>function(e,t){return String(t).split(".").reduce((e,t)=>e?.[t],e)}(e,t),snapshot:()=>({...e})}:e},assertServerId:d}})(),u=(()=>{const{applyServerResult:e,defaultInput:n,resolveServerCommandArguments:o,unwrapServerResult:s}=c,{attachRegistryInspection:a,createRegistryStore:i}=r,{createLazyRegistry:u,isLazyDescriptor:l}=t,f=new Set(["prevent","preventDefault","stopPropagation","stopImmediatePropagation"]),p={prevent:h,preventDefault:h,stopPropagation(){this.event?.stopPropagation?.()},stopImmediatePropagation(){this.event?.stopImmediatePropagation?.()}};function h(){this.event?.preventDefault?.()}function d(e){if("string"!=typeof e||0===e.trim().length)throw new TypeError("Handler ref must be a non-empty string.");return e.split(";").map(e=>e.trim()).filter(Boolean).map(g)}function y(e){if("string"!=typeof e||0===e.length)throw new TypeError("Handler id must be a non-empty string.")}function g(e){if(e.startsWith("server."))return function(e){const t=e.indexOf("(");if(-1===t||!e.endsWith(")"))throw new Error(`Server command "${e}" must be called with parentheses.`);const r=e.slice(7,t).trim();if(!function(e){return/^[^.\s();]+(?:\.[^.\s();]+)*$/.test(e)}(r))throw new Error(`Server command "${e}" has an invalid function id.`);return{type:"server",id:r,args:w(e.slice(t+1,-1))}}(e);if(e.includes("(")||e.includes(")"))throw new Error(`Command "${e}" is not supported.`);return{type:"handler",id:e}}function w(e){return 0===e.trim().length?[]:e.split(",").map(e=>e.trim()).filter(Boolean).map(m)}function m(e){if(!/^[^\s,();]+$/.test(e))throw new Error(`Argument "${e}" is not supported.`);return e.startsWith("$")?{type:"local",name:e}:{type:"signal",path:e}}return{createHandlerRegistry:function(t={},r={}){const c=r.registry??i(),h=r.type??"handler",g=c._map(h),w=r.lazyRegistry??u(r),m=new Map,b=a({register(e,t){if(y(e),"function"!=typeof t&&!l(t))throw new TypeError(`Handler "${e}" must be a function.`);if(g.has(e))throw new Error(`Handler "${e}" is already registered.`);return g.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))b.register(t,r);return b},unregister:e=>(y(e),m.delete(e),g.delete(e)),resolve(e){y(e);const t=g.get(e);return l(t)?(m.has(e)||m.set(e,async function(...r){const n=await w.resolve(h,e,t);if("function"!=typeof n)throw new TypeError(`Handler "${e}" did not resolve to a function.`);return n.apply(this,r)}),m.get(e)):t},async run(t,r={}){const a=d(t),i=[];let c=!1;const u={...r,handlers:b,input:r.input??n(r),stop(){c=!0}};for(const t of a){if(c)break;if("server"===t.type){if(!u.server||"function"!=typeof u.server.run)throw new Error(`Server command "${t.id}" cannot run without a server registry.`);const r=o(t.args,u),n=await u.server.run(t.id,r.args,{...u,signalPaths:r.signalPaths,signalValues:r.signalValues});await e(n,u),i.push(s(n));continue}const r=b.resolve(t.id);if(!r)throw new Error(`Handler "${t.id}" is not registered.`);const n=await r.call(u,u);f.has(t.id)&&r===p[t.id]||i.push(n)}return i},_adoptMany:()=>b},c,h);return function(e,t){for(const[r,n]of Object.entries(p))if(t.has(r)){if(t.get(r)!==n)throw new Error(`Handler "${r}" is already registered.`)}else e.register(r,n)}(b,g),b.registerMany(t),b},parseHandlerRef:d,isHandlerToken:function(e){return f.has(e)}}})(),l=(()=>{const e=["binding","lifecycle","effect","async","post"];function t(){}return{createScheduler:function(r={}){const n=[...r.phases??e],o=new Map(n.map(e=>[e,[]])),s=new Map,a=new Set,i=new WeakMap,c="function"==typeof r.onError?r.onError:void 0,u=r.maxDepth??100,l=r.strategy??"microtask";let f=!1,p=!1,h=!1,d=0,y=0,g=0;const w={strategy:l,phases:n,batch(e){if("function"!=typeof e)throw new TypeError("scheduler.batch(fn) requires a function.");E(),d+=1;let t=!1;try{const r=e();return r&&"function"==typeof r.then?(t=!0,r.finally(()=>{d-=1,m()})):r}finally{!t&&d>0&&(d-=1,m())}},enqueue(e,r,n={}){if(E(),function(e){if(!o.has(e))throw new Error(`Unknown scheduler phase "${e}".`)}(e),"function"!=typeof r)throw new TypeError("scheduler.enqueue(phase, fn) requires a function.");const c=n.scope;if(void 0!==c&&a.has(c))return t;const u=void 0===n.key?void 0:`${e}:${function(e){return void 0===e?"global":"object"==typeof e&&null!==e||"function"==typeof e?(i.has(e)||i.set(e,"scope:"+ ++g),i.get(e)):String(e)}(c)}:${String(n.key)}`;if(u&&s.has(u))return s.get(u).cancel;const l={id:++y,phase:e,fn:r,scope:c,boundary:n.boundary,key:u,canceled:!1,cancel(){l.canceled=!0,l.key&&s.delete(l.key)}};return o.get(e).push(l),l.key&&s.set(l.key,l),m(),l.cancel},afterFlush:(e,t={})=>w.enqueue("post",e,t),async flush(){if(E(),p)return;h=!1,p=!0;let e=0;try{for(;v();){if(e+=1,e>u)throw new Error(`Scheduler exceeded maxDepth ${u}.`);for(const e of n)await b(e)}}finally{p=!1,v()&&m()}},async flushScope(e){if(E(),p)return;h=!1,p=!0;let t=0;try{for(;S(e);){if(t+=1,t>u)throw new Error(`Scheduler exceeded maxDepth ${u}.`);for(const t of n)await b(t,e)}}finally{p=!1,v()&&m()}},cancelScope(e){if(void 0===e)return w;for(const t of o.values())for(const r of t)r.scope===e&&r.cancel();return w},markScopeDestroyed:e=>(void 0!==e&&(a.add(e),w.cancelScope(e)),w),isScopeDestroyed:e=>void 0!==e&&a.has(e),inspect(){const e={};for(const[t,r]of o)e[t]=r.filter(e=>!e.canceled).length;return{strategy:l,phases:[...n],pending:e,scopesDestroyed:a.size,flushing:p,scheduled:h}},destroy(){f=!0;for(const e of o.values()){for(const t of e)t.cancel();e.length=0}s.clear(),a.clear()}};return w;function m(){var e;"manual"===l||f||p||d>0||h||(h=!0,e=()=>{f||w.flush()},"function"!=typeof queueMicrotask?Promise.resolve().then(e):queueMicrotask(e))}async function b(e,t){const r=o.get(e),n=[],i=[];for(const e of r.splice(0))e.canceled||(void 0===t||e.scope===t?i.push(e):n.push(e));r.push(...n);for(const e of i)if(e.key&&s.delete(e.key),!(e.canceled||void 0!==e.scope&&a.has(e.scope)))try{await e.fn()}catch(t){if(!c)throw t;c(t,e)}}function v(){for(const e of o.values())if(e.some(e=>!e.canceled))return!0;return!1}function S(e){for(const t of o.values())if(t.some(t=>!t.canceled&&t.scope===e))return!0;return!1}function E(){if(f)throw new Error("Scheduler has been destroyed.")}}}})(),f=(()=>{const{renderComponent:e}=i,{createHandlerRegistry:t}=u,{createScheduler:r}=l,{createSignalRegistry:n,isSignalRef:a}=s,{matchAttribute:c,normalizeAttributeConfig:f,readAttribute:p}=o,h="__async:inline:";function d({root:o,signals:s,handlers:i,server:u,router:l,cache:d,attributes:E,scheduler:O}={}){const T=o?.ownerDocument??o??globalThis.document,q=o??T,C=s??n(),M=i??t(),x=O??r(),L=!O,D=f(E),B=new Set,P=new WeakMap,N=new WeakMap,z=new WeakSet,H=new WeakSet,W=new WeakMap,U=new WeakSet,I=new Map,V=new WeakMap;let F=0,J=!1;const K={root:q,signals:C,handlers:M,server:u,router:l,cache:d,scheduler:x,attributes:D,start:()=>(ne(),K.scan(q),K),scan:(e=q)=>(ne(),function(e){for(const t of R(e))for(const e of t.getAttributeNames?.()??[]){const r=c(e,D,"signal");if(r){if("text"===r){const r=t.getAttribute(e);G(t,`text:${r}`,r,e=>{t.textContent=e??""});continue}if("value"===r){const r=t.getAttribute(e);G(t,`value:${r}`,r,e=>{"value"in t&&t.value!==String(e??"")?t.value=e??"":"value"in t||t.setAttribute("value",e??"")}),Q(t,r);continue}if(r.startsWith("attr:")){const n=r.slice(5),o=t.getAttribute(e);G(t,`attr:${n}:${o}`,o,e=>$(t,n,e));continue}if(r.startsWith("prop:")){const n=r.slice(5),o=t.getAttribute(e);G(t,`prop:${n}:${o}`,o,e=>A(t,n,e));continue}if(r.startsWith("class:")){const n=r.slice(6),o=t.getAttribute(e);""===n||"{}"===n?Y(t,n,o):G(t,`class:${n}:${o}`,o,e=>{t.classList.toggle(n,Boolean(e))});continue}if("class"===r){const r=t.getAttribute(e);Y(t,"{}",r)}}}}(e),function(e){for(const t of R(e))for(const e of t.getAttributeNames?.()??[]){const r=c(e,D,"class");null!=r&&Y(t,r,t.getAttribute(e))}}(e),function(e){for(const t of R(e))if("function"==typeof t.getAttributeNames)for(const e of t.getAttributeNames()){const r=c(e,D,"on");r&&"attach"!==r&&"mount"!==r&&"visible"!==r&&Z(t,r,t.getAttribute(e))}}(e),function(e){for(const t of R(e)){if(U.has(t))continue;const e=j(t,D);if(null!=e){if(!W.has(t)){const r=S(t,e,D);if(0===Object.keys(r).length||!C.has(e))continue;const n={id:e,templates:r,cleanup:C.subscribe(`${e}.$status`,()=>{x.enqueue("binding",()=>X(t),{scope:t,key:`boundary:${e}`})})};W.set(t,n),oe(n.cleanup,t)}X(t)}}}(e),function(e){for(const t of R(e)){const e=ee(t,["attach","mount"]);if(0!==e.length&&!z.has(t)){z.add(t);for(const r of e)ue(t,()=>te(t,r),`attach:${r}`)}}for(const t of R(e)){const e=p(t,D,"on","visible");null!=e&&(H.has(t)||(H.add(t),oe(re(t,()=>ue(t,()=>te(t,e),`visible:${e}`)),t)))}}(e),K),swap(e,t){ne();const r=function(e,t,r){for(const n of R(e))if(j(n,r)===String(t))return n;return null}(q,e,D);if(!r)throw new Error(`Boundary "${e}" was not found.`);return ae(r),r.replaceChildren(k(t,T)),K.scan(r),r},mount(t,r,n={}){ne();const o=e(r,n,{signals:C,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,attributes:D});return ae(t),t.replaceChildren(k(o.html,t.ownerDocument)),K.scan(t),o.mount(t),o.visible(t,K._observeVisible),oe(o.cleanup,t,"children"),o},destroy(){if(!J){J=!0,function(e){for(const t of R(e))x.markScopeDestroyed(t)}(q);for(const e of[...B])se(e);B.clear(),L&&x.destroy()}},_observeVisible:(e,t)=>re(e,t),_registerBinding(e){const t=`${h}${++F}`;return I.set(t,e),t},_releaseBinding(e){I.delete(e)}};function Z(e,t,r){const n=`${t}:${r}`,o=P.get(e)??new Set;if(o.has(n))return;o.add(n),P.set(e,o);const s=async t=>{try{await x.batch(()=>M.run(r,{signals:C,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,event:t,element:e,el:e,root:q}))}catch(t){_(e,t)}};e.addEventListener(t,s),oe(()=>e.removeEventListener(t,s),e)}function Y(e,t,r){if(""===t||"{}"===t){const t=b(e);let n=new Set;return void G(e,`class:{}:${r}`,r,r=>{const o=y(r),s=b(e);for(const e of n)o.has(e)||t.has(e)||s.delete(e);for(const e of o)s.add(e);v(e,s),n=o},{rawInline:!0})}G(e,`class:${t}:${r}`,r,r=>{!function(e,t,r){const n=b(e);for(const e of y(t))r?n.add(e):n.delete(e);v(e,n)}(e,t,Boolean(r))})}function G(e,t,r,n,o={}){const s=N.get(e)??new Set;if(s.has(t))return;s.add(t),N.set(e,s);const a=()=>function(e,t={}){if(m(e)){const r=I.get(e);return t.rawInline?r:g(r)}return C.get(e)}(r,o);n(a()),oe(function(e,t){if(!m(e))return C.subscribe(e,t);const r=w(I.get(e)).map(e=>e.subscribe(t));return()=>{for(const e of r)e()}}(r,()=>{x.enqueue("binding",()=>n(a()),{scope:e,key:t})}),e)}function Q(e,t){Z(e,"input",`__async:set:${t}`),Z(e,"change",`__async:set:${t}`),M.resolve(`__async:set:${t}`)||M.register(`__async:set:${t}`,({element:e})=>{!function(e,t){if(!m(e))return C.set(e,t);const r=I.get(e);if(a(r))return r.set(t);throw new Error(`Inline binding "${e}" is not writable.`)}(t,e.value)})}function X(e){const t=W.get(e);if(!t)return;const r=C.get(`${t.id}.$status`),n=function(e,t){return"ready"===t?e.ready??e.loading??e.error:"error"===t?e.error??e.ready??e.loading:e.loading??e.ready??e.error}(t.templates,r);if(n){ae(e),e.replaceChildren(n.content.cloneNode(!0)),U.add(e);try{K.scan(e)}finally{U.delete(e)}}}function ee(e,t){const r=[];for(const n of t){const t=p(e,D,"on",n);null!=t&&r.push(t)}return r}async function te(e,t){try{const r=await M.run(t,{signals:C,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,element:e,el:e,root:q});for(const t of r)"function"==typeof t&&oe(t,e)}catch(t){_(e,t)}}function re(e,t){const r=(e.ownerDocument?.defaultView??globalThis).IntersectionObserver??globalThis.IntersectionObserver;if(!r)return x.enqueue("lifecycle",()=>{J||t(e)},{scope:e,key:"visible:fallback"}),()=>{};const n=new r(r=>{r.some(e=>e.isIntersecting)&&(n.disconnect(),t(e))});return n.observe(e),()=>n.disconnect()}function ne(){if(J)throw new Error("Loader has been destroyed.")}function oe(e,t,r="self"){if("function"!=typeof e)return e;if(B.add(e),t){const n=V.get(t)??[];n.push({cleanup:e,mode:r}),V.set(t,n)}return e}function se(e){"function"==typeof e&&B.has(e)&&(B.delete(e),e())}function ae(e){ce(e,"children");for(const t of[...e.childNodes??[]])ie(t)}function ie(e){if(1===e.nodeType)for(const t of R(e))ce(t),x.markScopeDestroyed(t)}function ce(e,t){const r=V.get(e);if(!r)return;const n=[];for(const e of r)t&&e.mode!==t?n.push(e):se(e.cleanup);n.length>0?V.set(e,n):V.delete(e)}function ue(e,t,r){x.enqueue("lifecycle",t,{scope:e,key:r})}return C._setContext?.({server:K.server,router:K.router,loader:K,cache:K.cache,scheduler:x}),K.server?._setContext?.({signals:C,handlers:M,loader:K,router:K.router,cache:K.cache,scheduler:x}),K}function y(e,t=new Set){if(null==e||!1===e)return t;if(a(e)){const r=e.value;return!0===r?(t.add(e.id.split(".").at(-1)),t):y(r,t)}if("string"==typeof e){for(const r of e.split(/\s+/).filter(Boolean))t.add(r);return t}if(Array.isArray(e)){for(const r of e)y(r,t);return t}if("object"==typeof e){for(const[r,n]of Object.entries(e))(a(n)?n.value:n)&&y(r,t);return t}return!0!==e&&t.add(String(e)),t}function g(e){return a(e)?e.value:Array.isArray(e)?e.map(g):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,g(t)])):e}function w(e,t=new Map){if(a(e))return t.set(e.id,e),[...t.values()];if(Array.isArray(e)){for(const r of e)w(r,t);return[...t.values()]}if(e&&"object"==typeof e)for(const r of Object.values(e))w(r,t);return[...t.values()]}function m(e){return"string"==typeof e&&e.startsWith(h)}function b(e){return y(e.getAttribute("class")??"")}function v(e,t){const r=[...t].join(" ");0!==r.length?e.setAttribute("class",r):e.removeAttribute("class")}function S(e,t,r){const n={};for(const o of[...e.children].filter(e=>"TEMPLATE"===e.tagName))E(o,"loading",t,e,r)&&(n.loading=o),E(o,"ready",t,e,r)&&(n.ready=o),E(o,"error",t,e,r)&&(n.error=o);return n}function E(e,t,r,n,o){return p(e,o,"async",t)===r||O(n)&&e.hasAttribute?.(t)}function $(e,t,r){if(!1===r||null==r)return e.removeAttribute(t),void(t in e&&(e[t]=!1));e.setAttribute(t,!0===r?"":String(r)),t in e&&(e[t]=r)}function A(e,t,r){e[t]=null!=r?r:""}function R(e){return function(e,t){const r=[];return 1===e?.nodeType&&e.matches?.(t)&&r.push(e),r.push(...e?.querySelectorAll?.(t)??[]),r}(e,"*")}function j(e,t){return O(e)&&e.hasAttribute?.("for")?e.getAttribute("for"):p(e,t,"async","boundary")}function O(e){return"ASYNC-SUSPENSE"===e?.tagName}function k(e,t){if(11===e?.nodeType)return e;if("TEMPLATE"===e?.tagName)return e.content.cloneNode(!0);if(e?.nodeType){const r=t.createDocumentFragment();return r.append(e),r}const r=t.createElement("template");return r.innerHTML=String(e??""),r.content.cloneNode(!0)}function _(e,t){const r=e.ownerDocument?.defaultView?.CustomEvent??globalThis.CustomEvent;e.dispatchEvent(new r("async:error",{bubbles:!0,detail:{error:t}}))}return{Loader:d,AsyncLoader:d}})(),p=(()=>{const{isTemplateResult:e,renderTemplate:n}=a,{attachRegistryInspection:o,createRegistryStore:s}=r,{createLazyRegistry:i,isLazyDescriptor:c}=t;function u(e,t={}){return r=e,Boolean(r&&"object"==typeof r&&!Array.isArray(r)&&(Object.hasOwn(r,"html")||Object.hasOwn(r,"signals")||Object.hasOwn(r,"boundary")||Object.hasOwn(r,"redirect")||Object.hasOwn(r,"status")||Object.hasOwn(r,"cache")))?{...e,html:Object.hasOwn(e,"html")?l(e.html,t):e.html}:{html:l(e,t)};var r}function l(t,r){return t?.nodeType||"string"==typeof t?t:(e(t),n(t,function(e){return{attributes:e.loader?.attributes,signals:e.signals,bind:e.loader?._registerBinding?.bind(e.loader)}}(r)))}function f(e){if("string"!=typeof e||0===e.length)throw new TypeError("Partial id must be a non-empty string.")}return{createPartialRegistry:function(e={},t={}){const r=t.registry??s(),n=t.type??"partial",a=r._map(n),l=t.lazyRegistry??i(t),p=new Map,h=o({register(e,t){if(f(e),"function"!=typeof t&&!c(t))throw new TypeError(`Partial "${e}" must be a function.`);if(a.has(e))throw new Error(`Partial "${e}" is already registered.`);return a.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))h.register(t,r);return h},unregister:e=>(f(e),p.delete(e),a.delete(e)),resolve(e){f(e);const t=a.get(e);return c(t)?(p.has(e)||p.set(e,async function(...r){const o=await l.resolve(n,e,t);if("function"!=typeof o)throw new TypeError(`Partial "${e}" did not resolve to a function.`);return o.apply(this,r)}),p.get(e)):t},async render(e,t={},r={}){f(e);const n=h.resolve(e);if(!n)throw new Error(`Partial "${e}" is not registered.`);const o={...r,id:e,props:t,cache:r.cache,partials:h};return u(await n.call(o,t),o)},_adoptMany:()=>h},r,n);return h.registerMany(e),h},normalizePartialResult:u}})(),h=(()=>{const{Loader:e}=f,{createHandlerRegistry:t}=u,{createScheduler:n}=l,{createSignalRegistry:a}=s,{applyServerResult:i}=c,{createRegistryStore:p}=r,{normalizeAttributeConfig:h}=o;function d(e,t={}){return{...t,partial:e}}function y(e={},t={}){const r=t.registry??p(),n=t.type??"route",o=r._map(n),s=[],a={registry:r,register(e,t){if(E(e),s.some(t=>t.pattern===e))throw new Error(`Route "${e}" is already registered.`);const r=g(e,t);return o.set(e,r.definition),s.push(r),v(s),r},registerMany(e){for(const[t,r]of Object.entries(e??{}))a.register(t,r);return a},unregister(e){E(e);const t=s.findIndex(t=>t.pattern===e);return-1!==t&&s.splice(t,1),o.delete(e)},match(e){const t=function(e){return e instanceof URL?e:new URL(String(e),globalThis.location?.href??"http://localhost/")}(e).pathname;for(const e of s){const r=e.regex.exec(t);if(!r)continue;const n={};return e.keys.forEach((e,t)=>{n[e]=b(r[t+1]??"")}),{pattern:e.pattern,params:n,route:e.definition}}return null},entries:()=>s.map(({pattern:e,definition:t})=>({pattern:e,route:t})),keys:()=>[...o.keys()],inspect:()=>r.entries(n),_adoptMany(e={}){for(const t of Object.keys(e??{}))i(t,o.get(t));return a}};for(const[e,t]of o)i(e,t);return a.registerMany(e),a;function i(e,t){if(s.some(t=>t.pattern===e))return;const r=g(e,t);o.set(e,r.definition),s.push(r),v(s)}}function g(e,t){const r="string"==typeof t?d(t):t,{regex:n,keys:o}=function(e){const t=[];if("*"===e)return{regex:/^.*$/,keys:t};if("/"===e)return{regex:/^\/$/,keys:t};const r=e.split("/").map(e=>e.startsWith(":")?(t.push(e.slice(1)),"([^/]+)"):String(e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/");return{regex:new RegExp(`^${r}$`),keys:t}}(e);return{pattern:e,regex:n,keys:o,score:S(e),definition:r}}function w(e,t){return e?.closest?.(t)}function m(e){return Object.fromEntries(e.searchParams.entries())}function b(e){try{return decodeURIComponent(e)}catch{return e}}function v(e){e.sort((e,t)=>t.score-e.score||t.pattern.length-e.pattern.length)}function S(e){return"*"===e?-1:e.split("/").filter(Boolean).reduce((e,t)=>"*"===t?e:t.startsWith(":")?e+2:e+4,"/"===e?3:0)}function E(e){if("string"!=typeof e||"*"!==e&&!e.startsWith("/"))throw new TypeError('Route pattern must be a path string or "*".')}return{defineRoute:d,createRouteRegistry:y,createRouter:function({mode:r="ssr-spa",root:o,boundary:s="route",routes:c=y(),loader:u,signals:l,handlers:f,server:p,cache:d,partials:g,fetch:b=globalThis.fetch?.bind(globalThis),routeEndpoint:v="/__async/route",attributes:S,scheduler:E}={}){const $=o?.ownerDocument??o??globalThis.document,A=o??$,R=l??u?.signals??a(),j=f??u?.handlers??t(),O=E??u?.scheduler??n(),k=!E&&!u?.scheduler,_=h(S??u?.attributes),T=u??e({root:A,signals:R,handlers:j,server:p,cache:d,scheduler:O,attributes:_}),q=!u,C=new Set;let M,x=!1,L=0;const D={mode:r,root:A,boundary:s,routes:c,loader:T,signals:R,handlers:j,server:p,cache:d,partials:g,scheduler:O,attributes:_,start:()=>(K(),T.router=D,R._setContext?.({router:D,loader:T,server:p,cache:d,scheduler:O}),q&&T.start(),"mpa"===r||"ssr"===r?(W(),D):(function(){const e=e=>{const t=w(e.target,"a[href]");t&&!function(e,t){if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!0;if(t.target||t.hasAttribute("download"))return!0;const r=J(t.href),n=F();return r.origin!==n.origin||function(e,t,r){return e.origin===t.origin&&e.pathname===t.pathname&&e.search===t.search&&(e.hash!==t.hash||!0===r.getAttribute?.("href")?.startsWith("#"))}(r,n,t)}(e,t)&&(e.preventDefault(),V(D.navigate(t.href)))},t=e=>{const t=w(e.target,"form");t&&!function(e){return"get"!==String(e.method||"get").toLowerCase()||J(e.action).origin!==F().origin}(t)&&(e.preventDefault(),V(D.navigate(function(e){const t=J(e.action||e.ownerDocument.defaultView.location.href),r=new e.ownerDocument.defaultView.FormData(e);return t.search=new URLSearchParams(r).toString(),t.href}(t))))},r=()=>V(D.navigate(F(),{history:!1}));A.addEventListener?.("click",e),A.addEventListener?.("submit",t),$.defaultView?.addEventListener?.("popstate",r),C.add(()=>A.removeEventListener?.("click",e)),C.add(()=>A.removeEventListener?.("submit",t)),C.add(()=>$.defaultView?.removeEventListener?.("popstate",r))}(),"csr"===r?(V(D.navigate(F(),{replace:!0,initial:!0,source:"client"})),D):(W(),D))),match:e=>c.match(J(e)),prefetch(e){if(K(),"ssr-spa"===r&&"function"==typeof b)return P(e,{prefetch:!0});const t=D.match(e);return t?.route?.partial&&g?.resolve?.(t.route.partial)?g.render(t.route.partial,t.params,N(t)):"function"==typeof b?P(e,{prefetch:!0}):Promise.resolve(null)},async navigate(e,t={}){if(K(),"mpa"===r||"ssr"===r)return $.defaultView?.location?.assign?.(e),null;const n=J(e);return"ssr-spa"===r?async function(e,t={}){const r=D.match(e),n=z(e,r);U(e,r,{pending:!0,error:null});try{const r=await P(e.href,{signal:n.abort});return H(n)?(await B(r,e,t,n),H(n)?(I({pending:!1,error:null}),r):null):null}catch(e){if(!H(n))return null;throw I({pending:!1,error:e}),e}}(n,t):async function(e,t={}){const r=D.match(e);if(!r)return z(e,null),function(e){U(e,null,{pending:!1,error:new Error(`No route matched ${e.pathname}${e.search}`)})}(e),null;const n=z(e,r);U(e,r,{pending:!0,error:null});try{if(!r.route?.partial||!g?.resolve?.(r.route.partial)){const t=new Error(`Route "${e.pathname}" does not have a registered partial.`);return H(n)&&I({pending:!1,error:t}),null}const o=await g.render(r.route.partial,r.params,N(r,n));return H(n)?(await B(o,e,t,n),H(n)?(I({pending:!1,error:null}),o):null):null}catch(e){if(!H(n))return null;throw I({pending:!1,error:e}),e}}(n,t)},destroy(){if(!x){x=!0,M?.controller.abort(new Error("Router has been destroyed."));for(const e of C)e();C.clear(),k&&O.destroy()}}};return D;async function B(e,t,r,n){H(n)&&(await i(e,{signals:R,loader:T,router:D,cache:d,scheduler:O,abort:n?.abort}),await O.flush(),H(n)&&(null==e?.html||e.boundary||e.redirect||(T.swap(s,e.html),await O.flush()),e?.redirect||!1===r.history||(r.replace?$.defaultView?.history?.replaceState?.({},"",t.href):$.defaultView?.history?.pushState?.({},"",t.href))))}async function P(e,{prefetch:t=!1,signal:r}={}){if("function"!=typeof b)throw new Error("Router navigation requires a partial registry or fetch.");const n=await b(`${v}?to=${encodeURIComponent(String(e))}`,{headers:{accept:"application/json, text/html"},signal:r});if(!n.ok)throw new Error(`Route "${e}" failed with ${n.status}.`);return t?n:(n.headers.get("content-type")??"").includes("application/json")?n.json():{boundary:s,html:await n.text()}}function N(e,t){return{params:e.params,route:e.route,router:D,signals:R,handlers:j,loader:T,server:p,cache:d,scheduler:O,abort:t?.abort}}function z(e,t){M?.controller.abort(new Error(`Router navigation superseded by ${e.pathname}${e.search}.`));const r=new AbortController,n={id:++L,controller:r,abort:r.signal,target:e,matched:t};return M=n,n}function H(e){return!x&&e&&M?.id===e.id&&!e.abort.aborted}function W(){const e=F();U(e,D.match(e),{pending:!1,error:null})}function U(e,t,r={}){R.ensure("router",{}),I({url:e.href,path:e.pathname,query:m(e),params:t?.params??{},route:t?.route??null,...r})}function I(e){R.ensure("router",{});for(const[t,r]of Object.entries(e))R.set(`router.${t}`,r)}function V(e){e.catch(e=>{x||(I({pending:!1,error:e}),function(e,t){const r=e.ownerDocument?.defaultView?.CustomEvent??globalThis.CustomEvent;"function"==typeof r&&e.dispatchEvent?.(new r("async:error",{bubbles:!0,detail:{error:t}}))}(A,e))})}function F(){return J($.defaultView?.location?.href??"http://localhost/")}function J(e){return e instanceof URL?e:new URL(String(e),$.defaultView?.location?.href??"http://localhost/")}function K(){if(x)throw new Error("Router has been destroyed.")}},route:d}})(),d=(()=>{const{createCacheRegistry:e}=n,{createComponentRegistry:a}=i,{createHandlerRegistry:d}=u,{Loader:y}=f,{createPartialRegistry:g}=p,{createRouteRegistry:w,createRouter:m}=h,{createScheduler:b}=l,{createServerNamespace:v}=c,{createSignal:S,createSignalRegistry:E}=s,{createRegistryStore:$}=r,{attributeName:A,normalizeAttributeConfig:R}=o,{createLazyRegistry:j,defineRegistrySnapshot:O,sameRegistryValue:k}=t,_=new Set(["signal","handler","server","partial","route","component","asyncSignal"]);function T(e,t={}){const r=$(void 0,{target:"browser"}),n=new Set,o=t.createRuntime??q,s={registry:r,use(e,t){const o=function(e,t){const r={signal:{},handler:{},server:{},partial:{},route:{},component:{},asyncSignal:{},cache:{browser:{},server:{}}};if("string"==typeof e){if(!_.has(e))throw new Error(`Unknown Async registry type "${e}".`);return r[e]=U(e,t),r}if(!e||"object"!=typeof e)throw new TypeError("Async.use(...) requires a registry type or module object.");for(const[t,n]of Object.entries(e))if("cache"!==t){if(!_.has(t))throw new Error(`Unknown Async registry type "${t}".`);r[t]=U(t,n)}else r.cache.browser={...n?.browser??{}},r.cache.server={...n?.server??{}};return r}(e,t);!function(e,t){for(const r of _)L(e,r,t[r]);L(e,"cache.browser",t.cache.browser),L(e,"cache.server",t.cache.server)}(r,o);for(const e of n)e._applyUse(o);return s},snapshot:()=>r.rawSnapshot(),start(e={}){const t=o(s,e).start();return s.runtime=t,t},attachRoot:e=>function(e){return e.runtime||e.start(),e.runtime}(s).attachRoot(e),detachRoot:e=>s.runtime?.detachRoot(e)??s,applySnapshot:(e,t={})=>s.runtime?(s.runtime.applySnapshot(e,t),s):(function(e,t={},r={}){const n=P(t);for(const[t,o]of Object.entries(n.signal))B(e,"signal",t,S(o),r);for(const t of["handler","server","partial","route","component","asyncSignal"])for(const[o,s]of Object.entries(n[t]))B(e,t,o,s,r)}(r,e,t),s),inspectRoots:()=>s.runtime?.inspectRoots()??{count:0,roots:[]},_attach:e=>(n.add(e),()=>s._detach(e)),_detach(e){n.delete(e)}};return e&&s.use(e),s}function q(t=C,r={}){const n=(q=t,Boolean(q&&"function"==typeof q.use&&"function"==typeof q.snapshot&&q.registry)?t:T(t??{})),o=r.target??"browser",s=r.scheduler??r.loader?.scheduler??b({strategy:"server"===o?"manual":"microtask"}),i=!r.scheduler&&!r.loader?.scheduler,c=R(r.attributes),u=r.lazyRegistry??j({registryAssets:r.registryAssets,importModule:r.importModule}),l=r.registry??n.registry.view({target:o}),f=r.signals??E(void 0,{registry:l,type:"signal",lazyRegistry:u}),p=r.handlers??d(void 0,{registry:l,type:"handler",lazyRegistry:u}),h=e(void 0,{registry:l,type:"cache.server"}),v=e(void 0,{registry:l,type:"cache.browser"}),S=r.serverFactory??W,$=r.server??S(void 0,{registry:l,type:"server"}),A=r.partials??g(void 0,{registry:l,type:"partial",lazyRegistry:u}),O=r.routes??w(void 0,{registry:l,type:"route"}),k=r.components??a(void 0,{registry:l,type:"component",lazyRegistry:u}),_=r.loader||Object.hasOwn(r,"root")?r.root:null;var q;let L=r.loader,B=r.router,N=!1,z=()=>{},U=!1,I=!1;const F=new Map,J=_??globalThis.document,K=r.snapshot??("browser"===o?M(J,{attributes:c}):void 0);!function(e,t){try{e.cache=t}catch{}}($,h);const Z={app:n,registry:l,target:o,signals:f,handlers:p,server:$,partials:A,routes:O,components:k,browser:{cache:v},loader:L,router:B,scheduler:s,attributes:c,start:()=>(ee(),U||(U=!0,"server"!==o?(Q({cache:v}),f._setContext?.({server:$,loader:L,cache:v,scheduler:s}),L?(Y(L.root,L),L.start(),G(L.root)):null!=_&&Z.attachRoot(_)):(Q({cache:h}),f._setContext?.({server:$,cache:h,scheduler:s}))),Z),use:(e,t)=>(n.use(e,t),Z),attachRoot(e){if(ee(),"server"===o)throw new Error("Server runtimes cannot attach DOM roots.");if(!e)throw new TypeError("runtime.attachRoot(root) requires a root.");if(F.has(e))return Z;const t=0===F.size&&L?L:y({root:e,signals:f,handlers:p,server:$,cache:v,scheduler:s,attributes:c});return Y(e,t),t.start(),Q({cache:v}),f._setContext?.({server:$,loader:Z.loader,cache:v,scheduler:s}),G(e),Z},detachRoot(e){if(ee(),"server"===o)return Z;if(null==e){for(const e of new Set(F.values()))e.destroy?.();return F.clear(),B?.destroy?.(),B=void 0,N=!1,L=void 0,Z.loader=void 0,Z.router=void 0,Z}const t=F.get(e);if(!t)return Z;if(t.destroy?.(),F.delete(e),L===t){B?.destroy?.(),B=void 0,N=!1;const e=F.values().next().value;L=e,Z.loader=e,Z.router=void 0,e&&G(e.root)}return Z},inspectRoots:()=>({count:F.size,roots:[...F].map(([e,t])=>({root:e,loader:t,primary:t===L}))}),applySnapshot:(e,t={})=>(function(e,t={},r={}){const n=P(t);for(const[t,r]of Object.entries(n.signal))H(e.signals,t,r);e.browser.cache.restore(n.cache.browser),D(e,"handler",n.handler,e.handlers,r),D(e,"server",n.server,e.server,r),D(e,"partial",n.partial,e.partials,r),D(e,"route",n.route,e.routes,r),D(e,"component",n.component,e.components,r),D(e,"asyncSignal",n.asyncSignal,null,r)}(Z,e,t),Z),async render(e){ee(),Q({cache:h}),f._setContext?.({server:$,cache:h,scheduler:s});const t=O.match(e);if(!t)return await s.flush(),{html:V("",{status:404,signals:f,browserCache:v,boundary:r.boundary??"route",attributes:c}),status:404,signals:f.snapshot(),cache:{browser:v.snapshot()}};const n=t.route.partial,o=n&&A.resolve(n)?await A.render(n,t.params,{params:t.params,route:t.route,signals:f,handlers:p,server:$,cache:h,browserCache:v,partials:A,scheduler:s,...X()}):{html:""};if(o.signals)for(const[e,t]of Object.entries(o.signals))H(f,e,t);o.cache?.browser&&v.restore(o.cache.browser),await s.flush();const a=o.status??200;return{html:V(o.html,{status:a,signals:f,browserCache:v,boundary:o.boundary??r.boundary??"route",attributes:c}),status:a,signals:f.snapshot(),cache:{browser:v.snapshot()}}},destroy(){if(I)return;I=!0,z(),B?.destroy?.();const e=new Set(F.values());for(const t of e)t.destroy?.();F.clear(),L&&!e.has(L)&&L?.destroy?.(),f.destroy?.(),i&&s.destroy()},_applyUse(e){!function(e,t){x(e.signals,e.registry,t.signal),x(e.handlers,e.registry,t.handler),x(e.server,e.registry,t.server),x(e.partials,e.registry,t.partial),x(e.routes,e.registry,t.route),x(e.components,e.registry,t.component),function(e,t,r){if(r&&0!==Object.keys(r).length)for(const[n,o]of Object.entries(r))e.has(t,n)||e.register(t,n,o)}(e.registry,"asyncSignal",t.asyncSignal),x(e.browser.cache,e.registry,t.cache.browser),x(e.server.cache,e.registry,t.cache.server)}(Z,e)}};return $.cache=h,Z.server.cache=h,Z.applySnapshot(K,{strict:r.strictSnapshots??!0}),z=n._attach(Z),Z;function Y(e,t){F.set(e,t),L||(L=t,Z.loader=t),t.server=$,t.cache=v,t.scheduler=s}function G(e){!1!==B&&!N&&(B||function(e,t){return Boolean(t.routerOptions||t.mode||e.entries().length>0)}(O,r))&&Z.loader&&(B=B??m({mode:r.mode??"ssr-spa",root:e,boundary:r.boundary??"route",routes:O,loader:Z.loader,signals:f,handlers:p,server:$,cache:v,partials:A,scheduler:s,fetch:r.fetch,routeEndpoint:r.routeEndpoint,attributes:c}),Z.router=B,Z.loader.router=B,Q({cache:v,router:B}),B.start(),N=!0)}function Q(e={}){const t=function(e){return"function"==typeof e?.registerMany}($)?h:e.cache;$._setContext?.({signals:f,loader:L,router:B,cache:t,scheduler:s,requestContext:r.requestContext,...X()})}function X(){const e=(t=r.requestContext)?"function"==typeof t.get?t.get()??{}:"function"==typeof t.getStore?t.getStore()??{}:{}:{};var t;return{requestContext:e,request:e.request??r.request,headers:e.headers??r.headers,cookies:e.cookies??r.cookies,locals:e.locals??r.locals}}function ee(){if(I)throw new Error("Async app runtime has been destroyed.")}}const C=T();function M(e=globalThis.document,{attributes:t}={}){const r=R(t),n=A(r,"async","snapshot"),o=e?.ownerDocument??e??globalThis.document,s=e??o;if(!s?.querySelectorAll&&!o?.querySelectorAll)return{};const a={};for(const e of new Set([s,o]))if(e?.querySelectorAll)for(const t of e.querySelectorAll("script[type='application/json'], script")){if(!t.hasAttribute?.(n))continue;const e=t.textContent?.trim()??"";if(!e)continue;let r;try{r=JSON.parse(e)}catch(e){throw new Error(`Could not parse Async snapshot: ${e instanceof Error?e.message:String(e)}`)}N(a,r,{strict:!0})}return a}function x(e,t,r){r&&0!==Object.keys(r).length&&(e?.registry!==t?e?.registerMany?.(r):e._adoptMany?.(r))}function L(e,t,r){for(const[n,o]of Object.entries(r??{}))e.register(t,n,o)}function D(e,t,r,n,o={}){if(r&&0!==Object.keys(r).length){for(const[n,s]of Object.entries(r))B(e.registry,t,n,s,o);n?._adoptMany?.(r)}}function B(e,t,r,n,o={}){const s=o.strict??!0,a=e._map(t);if(a.has(r)){if(k(a.get(r),n)||z(a.get(r),n))return;if(s)throw new Error(`${t} "${r}" is already registered with a different value.`)}else e.set(t,r,n)}function P(e={}){return{signal:{...e.signals??{},...e.signal??{}},handler:{...e.handler??{}},server:{...e.server??{}},partial:{...e.partial??{}},route:{...e.route??{}},component:{...e.component??{}},asyncSignal:{...e.asyncSignal??{}},cache:{browser:{...e.entries?.browser??{},...e.cache?.browser??{}}}}}function N(e,t,r={}){const n=P(O(t));e.signal={...e.signal??e.signals??{},...n.signal},e.signals=e.signal,e.cache={...e.cache??{},browser:{...e.cache?.browser??{},...n.cache.browser}};for(const t of["handler","server","partial","route","component","asyncSignal"]){e[t]=e[t]??{};for(const[o,s]of Object.entries(n[t]))if(Object.hasOwn(e[t],o)){if(k(e[t][o],s)||z(e[t][o],s))continue;if(r.strict??1)throw new Error(`${t} "${o}" is already declared with a different value.`)}else e[t][o]=s}return e}function z(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function H(e,t,r){const n=String(t).split(".")[0];e.has?.(n)?e.set(t,r):(e.register(n,S(t===n?r:{})),t!==n&&e.set(t,r))}function W(e={},t={}){const r=t.registry??$(),n=t.type??"server",o={},s={registry:r,register:(e,t)=>(r.register(n,e,t),e),registerMany(e){for(const[t,r]of Object.entries(e??{}))s.register(t,r);return s},unregister:e=>r.unregister(n,e),resolve(){},async run(e){throw new Error(`Server command "${e}" cannot run without a server proxy or server registry.`)},keys:()=>r.keys(n),entries:()=>r.entries(n),inspect:()=>r.entries(n),_setContext:(e={})=>(Object.assign(o,e),s),_adoptMany:()=>s};return s.registerMany(e),v((e,t,r)=>s.run(e,t,r),s,()=>o)}function U(e,t={}){if("signal"!==e)return{...t??{}};const r={};for(const[e,n]of Object.entries(t??{}))r[e]=I(n);return r}function I(e){return e&&"object"==typeof e&&"function"==typeof e.subscribe?e:S(e)}function V(e,{signals:t,browserCache:r,boundary:n,attributes:o}){const s={signals:t.snapshot(),cache:{browser:r.snapshot()}},a=A(o,"async","boundary"),i=A(o,"async","snapshot");return`<section ${a}="${c=n,String(c).replaceAll("&","&").replaceAll('"',""").replaceAll("<","<")}">${e??""}</section><script type="application/json" ${i}>${function(e){return JSON.stringify(e).replaceAll("<","\\u003c")}(s)}<\/script>`;var c}return{defineApp:T,createApp:q,readSnapshot:M,Async:C}})(),y=(()=>{function e(e){if("string"!=typeof e||0===e.length)throw new TypeError("Boundary patch boundary must be a non-empty string.")}function t(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))}return{createBoundaryReceiver:function(r={}){const n=r.loader,o=r.signals??n?.signals,s=r.cache??n?.cache,a=r.scheduler??n?.scheduler,i=r.router??n?.router,c=r.recentLimit??50,u=!0===r.throwOnError,l="function"==typeof r.onApply?r.onApply:void 0,f="function"==typeof r.onIgnore?r.onIgnore:void 0,p="function"==typeof r.onError?r.onError:void 0,h="function"==typeof r.isScopeDestroyed?r.isScopeDestroyed:e=>a?.isScopeDestroyed?.(e)??a?.inspectDestroyed?.(e)??!1;if(!n||"function"!=typeof n.swap)throw new TypeError("createBoundaryReceiver(...) requires a loader with swap(boundary, html).");if(!Number.isInteger(c)||c<0)throw new TypeError("createBoundaryReceiver(...) recentLimit must be a non-negative integer.");const d=new Map,y=[];let g=!1;const w={async apply(r){if(g)throw new Error("Boundary receiver has been destroyed.");const c=function(r){if(!r||"object"!=typeof r||Array.isArray(r))throw new TypeError("receiver.apply(patch) requires a boundary patch object.");if(e(r.boundary),"number"!=typeof r.seq||!Number.isFinite(r.seq))throw new TypeError("Boundary patch seq must be a finite number.");if(void 0!==r.signals&&!t(r.signals))throw new TypeError("Boundary patch signals must be an object.");if(void 0!==r.cache&&!t(r.cache))throw new TypeError("Boundary patch cache must be an object.");if(void 0!==r.cache?.browser&&!t(r.cache.browser))throw new TypeError("Boundary patch cache.browser must be an object.");if(void 0!==r.redirect&&("string"!=typeof r.redirect||0===r.redirect.length))throw new TypeError("Boundary patch redirect must be a non-empty string.");if(void 0!==r.parentScope&&"string"!=typeof r.parentScope)throw new TypeError("Boundary patch parentScope must be a string.");if(void 0!==r.scope&&"string"!=typeof r.scope)throw new TypeError("Boundary patch scope must be a string.");const n=Object.hasOwn(r,"html")&&null!=r.html,o=r.signals&&Object.keys(r.signals).length>0,s=r.cache?.browser&&Object.keys(r.cache.browser).length>0,a=Boolean(r.redirect),i=Object.hasOwn(r,"error");if(!(n||o||s||a||i))throw new TypeError("Boundary patch must include html, signals, cache.browser, redirect, or error.");return r}(r),y=(w=c.boundary,d.has(w)||d.set(w,{lastSeq:-1/0,applied:0,ignored:0,errored:0,lastStatus:void 0}),d.get(w));var w,b;if(c.seq<=y.lastSeq){const e={status:"ignored-stale",boundary:c.boundary,seq:c.seq,lastSeq:y.lastSeq};return y.ignored+=1,y.lastStatus=e.status,m(e),f?.(e,r),e}if(void 0!==c.parentScope&&h(c.parentScope)){const e={status:"ignored-destroyed",boundary:c.boundary,seq:c.seq,parentScope:c.parentScope};return y.ignored+=1,y.lastStatus=e.status,m(e),f?.(e,r),e}if(y.lastSeq=c.seq,Object.hasOwn(c,"error")){const e=(b=c.error)instanceof Error?b:b&&"object"==typeof b&&"string"==typeof b.message?Object.assign(new Error(b.message),b):new Error(String(b)),t={status:"errored",boundary:c.boundary,seq:c.seq,error:e};if(y.errored+=1,y.lastStatus=t.status,m(t),p?.(e,t,r),u)throw e;return t}if(c.signals){if(!o||"function"!=typeof o.set)throw new Error("Boundary patch includes signals, but no signal registry is available.");for(const[e,t]of Object.entries(c.signals))o.set(e,t)}if(c.cache?.browser){if(!s||"function"!=typeof s.restore)throw new Error("Boundary patch includes browser cache, but no cache registry is available.");s.restore(c.cache.browser)}if(null!=c.html&&n.swap(c.boundary,c.html),await async function(e,t){e&&(void 0===t||"function"!=typeof e.flushScope?"function"==typeof e.flush&&await e.flush():await e.flushScope(t))}(a,c.scope),c.redirect){await async function(e,t,r){if(t&&"function"==typeof t.navigate)return void await t.navigate(e);const n=r?.root?.ownerDocument?.defaultView?.location??globalThis.location;n?.assign?.(e)}(c.redirect,i,n);const e={status:"redirected",boundary:c.boundary,seq:c.seq,redirect:c.redirect};return y.applied+=1,y.lastStatus=e.status,m(e),l?.(e,r),e}const v={status:"applied",boundary:c.boundary,seq:c.seq};return y.applied+=1,y.lastStatus=v.status,m(v),l?.(v,r),v},inspect(){const e={};for(const[t,r]of d)e[t]={lastSeq:r.lastSeq,applied:r.applied,ignored:r.ignored,lastStatus:r.lastStatus},r.errored>0&&(e[t].errored=r.errored);return{destroyed:g,boundaries:e,recent:y.map(e=>({...e}))}},reset(t){if(void 0===t)return d.clear(),y.length=0,w;e(t),d.delete(t);for(let e=y.length-1;e>=0;e-=1)y[e].boundary===t&&y.splice(e,1);return w},destroy(){g=!0,d.clear(),y.length=0}};return w;function m(e){if(0!==c)for(y.push(function(e){const t={boundary:e.boundary,seq:e.seq,status:e.status};return"ignored-stale"===e.status&&(t.lastSeq=e.lastSeq),"ignored-destroyed"===e.status&&void 0!==e.parentScope&&(t.parentScope=e.parentScope),"redirected"===e.status&&(t.redirect=e.redirect),t}(e));y.length>c;)y.shift()}}}})(),g=(()=>{function e(e){return e?.reason??new Error("Operation aborted")}return{delay:function(t,r){return r?.aborted?Promise.reject(e(r)):new Promise((n,o)=>{let s=setTimeout(function(){s=void 0,r?.removeEventListener?.("abort",a),n()},t);function a(){void 0!==s&&clearTimeout(s),s=void 0,r?.removeEventListener?.("abort",a),o(e(r))}r?.addEventListener?.("abort",a,{once:!0})})}}})(),w=(()=>{const{Async:e}=d;return{defineAsyncContainerElement:function(t={}){const r=t.tagName??"async-container",n=t.customElements??globalThis.customElements;if(!n)throw new Error("defineAsyncContainerElement(...) requires customElements.");const o=n.get(r);if(o)return o;const s=t.app??t.Async??e,a=t.HTMLElement??t.window?.HTMLElement??globalThis.HTMLElement;if(!a)throw new Error("defineAsyncContainerElement(...) requires HTMLElement.");class i extends a{connectedCallback(){if(this.__asyncAttached)return;const e=s.runtime??s.start?.();e?.attachRoot?.(this),this.__asyncRuntime=e,this.__asyncAttached=!0}disconnectedCallback(){this.__asyncAttached&&(this.__asyncRuntime?.detachRoot?.(this),this.__asyncRuntime=void 0,this.__asyncAttached=!1)}}return n.define(r,i),i},defineAsyncSuspenseElement:function(e={}){const t=e.tagName??"async-suspense",r=e.customElements??globalThis.customElements;if(!r)throw new Error("defineAsyncSuspenseElement(...) requires customElements.");const n=r.get(t);if(n)return n;const o=e.HTMLElement??e.window?.HTMLElement??globalThis.HTMLElement;if(!o)throw new Error("defineAsyncSuspenseElement(...) requires HTMLElement.");class s extends o{}return r.define(t,s),s}}})(),{asyncSignal:m}=e,{Async:b}=d,{createApp:v}=d,{defineApp:S}=d,{readSnapshot:E}=d,{attributeName:$}=o,{defineAttributeConfig:A}=o,{createBoundaryReceiver:R}=y,{createCacheRegistry:j}=n,{defineCache:O}=n,{component:k}=i,{createComponentRegistry:_}=i,{defineComponent:T}=i,{delay:q}=g,{defineAsyncContainerElement:C}=w,{defineAsyncSuspenseElement:M}=w,{createHandlerRegistry:x}=u,{html:L}=a,{createLazyRegistry:D}=t,{defineRegistrySnapshot:B}=t,{Loader:P}=f,{AsyncLoader:N}=f,{createPartialRegistry:z}=p,{createRegistryStore:H}=r,{createRouteRegistry:W}=h,{createRouter:U}=h,{defineRoute:I}=h,{route:V}=h,{createScheduler:F}=l,{applyServerResult:J}=c,{createServerProxy:K}=c,{resolveServerCommandArguments:Z}=c,{unwrapServerResult:Y}=c,{computed:G}=s,{createSignal:Q}=s,{createSignalRegistry:X}=s,{effect:ee}=s,{signal:te}=s,re={asyncSignal:m,Async:b,createApp:v,defineApp:S,readSnapshot:E,attributeName:$,defineAttributeConfig:A,createBoundaryReceiver:R,createCacheRegistry:j,defineCache:O,component:k,createComponentRegistry:_,defineComponent:T,delay:q,defineAsyncContainerElement:C,defineAsyncSuspenseElement:M,createHandlerRegistry:x,html:L,createLazyRegistry:D,defineRegistrySnapshot:B,Loader:P,AsyncLoader:N,createPartialRegistry:z,createRegistryStore:H,createRouteRegistry:W,createRouter:U,defineRoute:I,route:V,createScheduler:F,applyServerResult:J,createServerProxy:K,resolveServerCommandArguments:Z,unwrapServerResult:Y,computed:G,createSignal:Q,createSignalRegistry:X,effect:ee,signal:te};return function(e,t){const r=Object.keys(e).filter(e=>"Async"!==e&&Object.prototype.hasOwnProperty.call(t,e));if(r.length>0)throw new Error(`UMD Async namespace export conflict: ${r.join(", ")}.`)}(re,b),Object.assign(b,re),b.Async=b,b}();"function"==typeof define&&define.amd?define([],()=>t):"object"==typeof module&&module.exports?module.exports=t:(e.AsyncFramework=t,e.Async=t)}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this);
|
|
1
|
+
!function(e){const t=function(){"use strict";const e=(()=>{const e=Symbol.for("@async/framework.asyncSignal");return{asyncSignal:function(t,r){if("string"!=typeof t||0===t.length)throw new TypeError("asyncSignal(id, fn) requires a non-empty string id.");if("function"!=typeof r)throw new TypeError("asyncSignal(id, fn) requires a function.");let n,o,s,a,i=!1,c=null,u="idle",l=0,f=t;const p=new Set,d=new Set,h={[e]:!0,kind:"async-signal",get id(){return f},get value(){return n},get loading(){return i},get error(){return c},get status(){return u},get version(){return l},set:e=>(n=e,i=!1,c=null,u="ready",w(),n),refresh(){if(!o)throw new Error(`Async signal "${f}" is not registered.`);a&&!a.aborted&&a.cancel(new Error(`Async signal "${f}" refreshed.`));const e=l+1;l=e,i=!0,c=null,u="loading";const t=new AbortController;s=t,a=t.signal,function(e,t){Object.defineProperty(e,"cancel",{configurable:!0,enumerable:!1,value(e){t.abort(e)}})}(a,t),w();const p={signals:o,id:f,get server(){const e=o._context?.()??{},t=e.server;return"function"==typeof t?._withContext?t._withContext({signals:o,router:e.router,loader:e.loader,cache:e.cache,abort:a,scheduler:e.scheduler}):t},get router(){return o._context?.().router},get loader(){return o._context?.().loader},get cache(){return o._context?.().cache},get scheduler(){return o._context?.().scheduler},get version(){return e},get abort(){return a},refresh:()=>h.refresh()};let b;try{b=o._collectDependencies(()=>r.call(p))}catch(t){return y(e,t),Promise.reject(t)}return function(e){for(const e of d)e();d.clear();for(const t of e){const e=String(t).split(".")[0];e&&e!==f&&d.add(o.subscribe(t,()=>m()))}}(b.dependencies),Promise.resolve(b.value).then(t=>g(e)?(n=t,i=!1,c=null,u="ready",w(),n):n,t=>g(e)?a?.aborted?(i=!1,u=void 0===n?"idle":"ready",w(),n):(y(e,t),n):n)},cancel(e){a&&!a.aborted&&a.cancel(e)},subscribe(e){if("function"!=typeof e)throw new TypeError("subscribe(fn) requires a function.");return p.add(e),()=>p.delete(e)},snapshot:()=>({value:n,loading:i,error:c,status:u,version:l}),_bindRegistry(e,t){o=e,f=t;const r=()=>{o===e&&"idle"===u&&h.refresh()},n=o._context?.().scheduler;n?n.enqueue("async",r,{scope:f,key:`asyncSignal:${f}:initial`}):queueMicrotask(r)},_dispose(){h.cancel(new Error(`Async signal "${f}" disposed.`));for(const e of d)e();d.clear(),p.clear()}};function y(e,t){g(e)&&(i=!1,c=t,u="error",w())}function g(e){return e===l&&s?.signal===a}function m(){a&&!a.aborted&&a.cancel(new Error(`Async signal "${f}" dependency changed.`));const e=o?._context?.().scheduler;e?e.enqueue("async",()=>h.refresh(),{scope:f,key:`asyncSignal:${f}:refresh`}):h.refresh()}function w(){for(const e of[...p])e(h)}return h},isAsyncSignal:function(t){return Boolean(t?.[e])}}})(),t=(()=>{const e=new Set(["handler","component","asyncSignal","partial","route"]);function t(t={}){const r=function(e){if("string"!=typeof e||0===e.length)throw new TypeError("registryAssets.baseUrl must be a non-empty string.");return i(e)||e.startsWith("/")||e.startsWith("./")||e.startsWith("../")?a(e):`/${s(e)}`}(t.baseUrl??"_async"),n={component:"component",handler:"handler",asyncSignal:"asyncSignal",partial:"partial",route:"route",...t.paths??{}};for(const[t,r]of Object.entries(n))if(e.has(t)&&("string"!=typeof r||0===r.length))throw new TypeError(`Registry asset path for "${t}" must be a non-empty string.`);return{baseUrl:r,paths:n}}function r(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.url)}function n(t,n,c,u){if(!e.has(t))throw new Error(`Registry type "${t}" does not support lazy descriptors.`);if(!r(c))throw new TypeError(`Registry descriptor for "${t}:${n}" requires a url.`);const{path:l,hash:f}=function(e){const t=e.indexOf("#");return-1===t?{path:e,hash:""}:{path:e.slice(0,t),hash:e.slice(t+1)}}(c.url),p=function(e,t,r){if(i(t)||t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))return t;const n=r.paths[e]??e;return function(...e){const[t,...r]=e;return[a(t),...r.map(s)].filter(Boolean).join("/")}(r.baseUrl,n,t)}(t,l,u);return{moduleUrl:p,exportNames:f?[f]:o(n,l),url:f?`${p}#${f}`:p}}function o(e,t){const r=[],n=e.split(".").filter(Boolean).at(-1),o=t.split("/").filter(Boolean).at(-1)?.replace(/\.[^.]+$/,"");for(const e of[n,o,"default"])e&&!r.includes(e)&&r.push(e);return r}function s(e){return String(e).replace(/^\/+|\/+$/g,"")}function a(e){return String(e).replace(/\/+$/g,"")}function i(e){return/^[A-Za-z][A-Za-z\d+.-]*:/.test(e)}function c(e){return!e||"object"!=typeof e||Array.isArray(e)?JSON.stringify(e):JSON.stringify(Object.keys(e).sort().map(t=>[t,e[t]]))}return{defineRegistrySnapshot:function(e={}){if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("defineRegistrySnapshot(snapshot) requires an object.");return e},createLazyRegistry:function(e={}){const o=t(e.registryAssets??e.assets),s=e.importModule??(e=>import(e)),a=new Map,i=new Map;return{registryAssets:o,resolveUrl:(e,t,r)=>n(e,t,r,o),async resolve(e,t,c){if(!r(c))return c;const u=`${e}:${t}`;if(i.has(u))return i.get(u);const l=n(e,t,c,o);let f,p=a.get(l.moduleUrl);p||(p=Promise.resolve().then(()=>s(l.moduleUrl)),a.set(l.moduleUrl,p));try{f=await p}catch(r){throw a.get(l.moduleUrl)===p&&a.delete(l.moduleUrl),new Error(`Lazy ${e} "${t}" failed to import ${l.moduleUrl}: ${d=r,d instanceof Error?d.message:String(d)}`,{cause:r})}var d;const h=function(e,t,r,n){for(const r of t)if(r in e)return e[r];throw new Error(`Lazy ${r} "${n}" did not export ${t.map(e=>`"${e}"`).join(", ")}.`)}(f,l.exportNames,e,t);return i.set(u,h),h},inspect:()=>({registryAssets:o,modules:[...a.keys()],exports:[...i.keys()]})}},normalizeRegistryAssets:t,isLazyDescriptor:r,sameRegistryValue:function(e,t){return e===t||!(!r(e)||!r(t))&&c(e)===c(t)},publicRegistryValue:function(e,t){return r(e)?{...e}:{id:t}}}})(),r=(()=>{const{publicRegistryValue:e}=t,r=new Set(["signal","handler","server","partial","route","component","asyncSignal"]),n=new Set(["cache.browser","cache.server"]),o=new Set(["cache.browser.entries","cache.server.entries"]),s=new Set([...r,...n,...o]);function a(e){if(!s.has(e))throw new Error(`Unknown Async registry type "${e}".`);return e}function i(e,t){if("string"!=typeof t||0===t.length)throw new TypeError(`${e} id must be a non-empty string.`)}function c(t,r,n,s){return"server"===t&&"browser"===s.target?e(n,r):o.has(t)?n?.value:n}function u(e,t){return"cache.server.entries"===e&&"browser"===t}function l(e){const t={};for(const[r,n]of e)t[r]="function"==typeof n?.snapshot?n.snapshot():n?.value??n;return t}function f(t){const r={};for(const[n,o]of t)r[n]=e(o,n);return r}function p(e){return Object.fromEntries(e)}function d(e){const t={};for(const[r,n]of e)t[r]=n?.value;return t}function h(e){return e&&"object"==typeof e&&Object.hasOwn(e,"value")?e:{value:e}}return{createRegistryStore:function e(t={},n={}){const o=n.backing??{signal:new Map,handler:new Map,server:new Map,partial:new Map,route:new Map,component:new Map,asyncSignal:new Map,cache:{browser:new Map,server:new Map},cacheEntries:{browser:new Map,server:new Map}},s=n.target??"server",y={target:s,register(e,t,r){const n=y._map(e);if(i(e,t),n.has(t))throw new Error(`${e} "${t}" is already registered.`);return n.set(t,r),t},registerMany(e,t={}){for(const[r,n]of Object.entries(t??{}))y.register(e,r,n);return y},set(e,t,r){const n=y._map(e);return i(e,t),n.set(t,r),r},unregister:(e,t)=>y.delete(e,t),delete:(e,t)=>y._map(e).delete(t),keys:e=>u(e,s)?[]:[...y._map(e).keys()],entries(e,t={}){const r=a(e);return u(r,t.target??s)?[]:[...y._map(r)].map(([e,n])=>[e,c(r,e,n,{target:s,...t})])},has:(e,t)=>(i(e,t),!u(e,s)&&y._map(e).has(t)),get(e,t,r={}){i(e,t);const n=a(e);if(u(n,r.target??s))return;const o=y._map(n).get(t);return void 0!==o?c(n,t,o,{target:s,...r}):void 0},snapshot(e={}){const t=e.target??s;return{signal:l(o.signal),handler:f(o.handler),server:f(o.server),partial:f(o.partial),route:p(o.route),component:f(o.component),asyncSignal:f(o.asyncSignal),cache:{browser:p(o.cache.browser),server:p(o.cache.server)},entries:{browser:d(o.cacheEntries.browser),server:"browser"===t?{}:d(o.cacheEntries.server)}}},rawSnapshot:()=>({signal:Object.fromEntries(o.signal),handler:Object.fromEntries(o.handler),server:Object.fromEntries(o.server),partial:Object.fromEntries(o.partial),route:Object.fromEntries(o.route),component:Object.fromEntries(o.component),asyncSignal:Object.fromEntries(o.asyncSignal),cache:{browser:Object.fromEntries(o.cache.browser),server:Object.fromEntries(o.cache.server)}}),view:(t={})=>e(void 0,{backing:o,target:t.target??s}),_map(e){const t=a(e);if(r.has(t))return o[t];if("cache.browser"===t)return o.cache.browser;if("cache.server"===t)return o.cache.server;if("cache.browser.entries"===t)return o.cacheEntries.browser;if("cache.server.entries"===t)return o.cacheEntries.server;throw new Error(`Unknown Async registry type "${e}".`)}};return function(e,t={}){e.registerMany("signal",t.signal),e.registerMany("handler",t.handler),e.registerMany("server",t.server),e.registerMany("partial",t.partial),e.registerMany("route",t.route),e.registerMany("component",t.component),e.registerMany("asyncSignal",t.asyncSignal),e.registerMany("cache.browser",t.cache?.browser),e.registerMany("cache.server",t.cache?.server);const r=t.entries??{};for(const[t,n]of Object.entries(r.browser??{}))e.set("cache.browser.entries",t,h(n));for(const[t,n]of Object.entries(r.server??{}))e.set("cache.server.entries",t,h(n))}(y,t),y},attachRegistryInspection:function(e,t,r){return Object.defineProperty(e,"registry",{configurable:!0,enumerable:!0,value:t}),e.keys=()=>t.keys(r),e.entries=()=>t.entries(r),e.inspect=()=>t.entries(r),e}}})(),n=(()=>{const{attachRegistryInspection:e,createRegistryStore:t}=r,n=Symbol.for("@async/framework.cacheDefinition");function o(e={}){return{[n]:!0,kind:"cache-definition",store:e.store??"memory",ttl:e.ttl}}function s(e){if("string"!=typeof e||0===e.length)throw new TypeError("Cache id must be a non-empty string.")}function a(e){if("string"!=typeof e||0===e.length)throw new TypeError("Cache key must be a non-empty string.")}return{defineCache:o,createCacheRegistry:function(r={},{now:i=()=>Date.now(),registry:c,type:u="cache.browser"}={}){const l=c??t(),f=l._map(u),p=l._map(`${u}.entries`),d=new Map,h=e({register(e,t=o()){s(e);const r=function(e){return e?.[n]?e:o(e)}(t);if(f.has(e))throw new Error(`Cache "${e}" is already registered.`);return f.set(e,r),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))h.register(t,r);return h},unregister:e=>(s(e),f.delete(e)),resolve:e=>(s(e),f.get(e)),get:e=>(a(e),y(e).value),set(e,t,r={}){a(e);const n=r.ttl??function(e,t){if(void 0!==t)return f.get(t);if(f.has(e))return f.get(e);const r=e.split(":")[0];return f.get(r)}(e,r.cache)?.ttl;return p.set(e,{value:t,expiresAt:void 0===n?void 0:i()+n}),t},async getOrSet(e,t,r={}){if(a(e),"function"!=typeof t)throw new TypeError("cache.getOrSet(key, fn) requires a function.");const n=y(e);if(n.found)return n.value;if(d.has(e))return d.get(e);let o;return o=Promise.resolve().then(t).then(t=>(d.get(e)===o&&h.set(e,t,r),t)).finally(()=>{d.get(e)===o&&d.delete(e)}),d.set(e,o),o},delete:e=>(a(e),d.delete(e),p.delete(e)),clear(e){if(void 0===e)return p.clear(),d.clear(),h;for(const t of[...p.keys()])t.startsWith(e)&&p.delete(t);for(const t of[...d.keys()])t.startsWith(e)&&d.delete(t);return h},snapshot(){const e={};for(const[t]of p){const{found:r,value:n}=y(t);r&&void 0!==n&&(e[t]=n)}return e},restore(e={}){for(const[t,r]of Object.entries(e??{}))h.set(t,r);return h},entryKeys:()=>[...p.keys()],entryEntries:()=>l.entries(`${u}.entries`),_adoptMany:()=>h},l,u);return h.registerMany(r),h;function y(e){const t=p.get(e);return t?void 0!==t.expiresAt&&t.expiresAt<=i()?(p.delete(e),{found:!1,value:void 0}):{found:!0,value:t.value}:{found:!1,value:void 0}}}}})(),o=(()=>{const e=Object.freeze({async:["async:"],class:["class:"],signal:["signal:"],on:["on:"]});function t(t={}){return{async:r(t.async,e.async),class:r(t.class,e.class),signal:r(t.signal,e.signal),on:r(t.on,e.on)}}function r(e,t){return(null==e?t:Array.isArray(e)?e:[e]).map(e=>{if("string"!=typeof e||0===e.length)throw new TypeError("Attribute prefixes must be non-empty strings.");return e})}return{defineAttributeConfig:function(e={}){return t(e)},normalizeAttributeConfig:t,attributeName:function(e,r,n){return t(e)[r][0]+n},readAttribute:function(e,r,n,o){for(const s of t(r)[n]){const t=`${s}${o}`;if(e.hasAttribute?.(t))return e.getAttribute(t)}return null},matchAttribute:function(e,r,n){for(const o of t(r)[n])if(e.startsWith(o))return e.slice(o.length);return null}}})(),s=(()=>{const{asyncSignal:n,isAsyncSignal:o}=e,{attachRegistryInspection:s,createRegistryStore:a}=r,{createLazyRegistry:i,isLazyDescriptor:c}=t,u=Symbol.for("@async/framework.signal"),l=Symbol.for("@async/framework.computed"),f=Symbol.for("@async/framework.effect"),p=Symbol.for("@async/framework.signalRef"),d=[];function h(e){let t=e;const r=new Set;return{[u]:!0,kind:"signal",get value(){return t},set value(e){this.set(e)},set:e=>(Object.is(t,e)||(t=e,function(){for(const e of[...r])e(t)}()),t),update(e){return this.set(e(t))},subscribe(e){if("function"!=typeof e)throw new TypeError("subscribe(fn) requires a function.");return r.add(e),()=>r.delete(e)},snapshot:()=>t}}function y(e,t){let r=e;for(const e of t){if(null==r)return;r=r[e]}return r}function g(e,t){return Array.isArray(e)?[...e]:e&&"object"==typeof e?{...e}:(r=t,String(Number(r))===String(r)?[]:{});var r}function m(e,t){const r=e.get(t);if(!r)throw new Error(`Signal "${t}" is not registered.`);return r}function w(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal id must be a non-empty string.")}return{createSignal:h,computed:function(e){if("function"!=typeof e)throw new TypeError("computed(fn) requires a function.");const t=h(void 0);return{[l]:!0,kind:"computed",get value(){return t.value},set:e=>t.set(e),update:e=>t.update(e),subscribe:e=>t.subscribe(e),snapshot:()=>t.snapshot(),_bindRegistry:(r,n)=>r.effect(()=>{t.set(e.call({signals:r,id:n,server:r._context?.().server,router:r._context?.().router,loader:r._context?.().loader,cache:r._context?.().cache,scheduler:r._context?.().scheduler}))})}},effect:function(e){if("function"!=typeof e)throw new TypeError("effect(fn) requires a function.");return{[f]:!0,kind:"effect",fn:e,_bindRegistry:t=>t.effect(e)}},createSignalRegistry:function(e={},t={}){const r=t.registry??a(),u=t.type??"signal",l=r._map(u),f=r._map("asyncSignal"),b=t.lazyRegistry??i(t),v=new Map,S={},E=new Set;let $=0,A=0;const R=s({register(e,t){if(w(e),l.has(e))throw new Error(`Signal "${e}" is already registered.`);const r=function(e){return t=e,Boolean(t&&"object"==typeof t&&"function"==typeof t.subscribe)?e:h(e);var t}(t);return l.set(e,r),j(e,r),R.ref(e)},registerMany(e){for(const[t,r]of Object.entries(e??{}))R.register(t,r);return R},unregister:e=>(w(e),!!l.has(e)&&(v.get(e)?.(),v.delete(e),l.get(e)?._dispose?.(),l.delete(e),E.delete(e),!0)),ensure:(e,t)=>(w(e),k(e),l.has(e)||R.register(e,h(t)),R.ref(e)),has:e=>l.has(e)||f.has(e),get(e){const t=O(e);return function(e){const t=d.at(-1);t&&t.add(e)}(t.path),function(e,t){if(o(e)&&t[0]?.startsWith("$"))return y(function(e,t){switch(t){case"$value":return e.value;case"$loading":return e.loading;case"$error":return e.error;case"$status":return e.status;case"$version":return e.version;default:return}}(e,t[0]),t.slice(1));return y(e.value,t)}(m(l,t.id),t.parts)},set(e,t){const r=O(e),n=m(l,r.id);if(0===r.parts.length)return n.set(t);const o=function(e,t,r){const n=g(e,t[0]);let o=n;for(let e=0;e<t.length-1;e+=1){const r=t[e],n=t[e+1];o[r]=g(o[r],n),o=o[r]}return o[t.at(-1)]=r,n}(n.value,r.parts,t);return n.set(o),t},update(e,t){if("function"!=typeof t)throw new TypeError("update(path, fn) requires a function.");return R.set(e,t(R.get(e)))},ref:e=>(w(e),k(e),function(e,t){return{[p]:!0,kind:"signal-ref",id:t,get value(){return e.get(t)},set value(r){e.set(t,r)},get loading(){return e._entry(t).loading??!1},get error(){return e._entry(t).error??null},get status(){return e._entry(t).status??"ready"},get version(){return e._entry(t).version??0},get:()=>e.get(t),set:r=>e.set(t,r),update:r=>e.update(t,r),subscribe:r=>e.subscribe(t,r),refresh(){const r=e._entry(t);if("function"!=typeof r.refresh)throw new Error(`Signal "${t}" cannot refresh.`);return r.refresh()},cancel(r){const n=e._entry(t);if("function"!=typeof n.cancel)throw new Error(`Signal "${t}" cannot cancel.`);return n.cancel(r)},toString:()=>t,[Symbol.toPrimitive]:()=>t}}(R,e)),subscribe(e,t,r={}){if("function"!=typeof t)throw new TypeError("subscribe(path, fn) requires a function.");const n=O(e),o=m(l,n.id),s=++$;return o.subscribe(()=>{!function(e,t={}){const r=t.scheduler;r&&"sync"!==t.phase?r.enqueue(t.phase??"effect",e,{scope:t.scope,key:t.key}):e()}(()=>t(R.get(n.path),{id:n.id,path:n.path,signal:o}),{...r,key:r.key??`signal:${n.path}:${s}`})})},snapshot(){const e={};for(const[t,r]of l)e[t]="function"==typeof r.snapshot?r.snapshot():r.value;return e},asyncSignal:(e,t)=>(R.register(e,n(e,t)),R.ref(e)),effect(e,t={}){let r,n=[],o=!1;const s=t.scheduler,a=++A,i=()=>{if(o)return;"function"==typeof r&&r();for(const e of n)e();n=[];const t=R._collectDependencies(()=>e.call({signals:R,server:S.server,router:S.router,loader:S.loader,cache:S.cache,scheduler:S.scheduler}));r=t.value,n=t.dependencies.map(e=>R.subscribe(e,c))},c=()=>{s?s.enqueue(t.phase??"effect",i,{scope:t.scope,key:t.key??`effect:${a}`}):i()};return i(),()=>{o=!0,"function"==typeof r&&r();for(const e of n)e()}},destroy(){for(const e of v.values())e();v.clear();for(const e of l.values())e._dispose?.();l.clear()},_collectDependencies(e){const t=new Set;d.push(t);try{return{value:e(),dependencies:[...t]}}finally{d.pop()}},_entry:e=>(k(e),m(l,e)),_setContext:(e={})=>(Object.assign(S,e),R),_context:()=>S,_adoptMany(e={}){for(const t of Object.keys(e??{}))l.has(t)&&j(t,l.get(t));return R}},r,u);for(const[e,t]of l)j(e,t);return R.registerMany(e),R;function j(e,t){if(E.has(e)||"function"!=typeof t?._bindRegistry)return;E.add(e);const r=t._bindRegistry(R,e);"function"==typeof r&&v.set(e,r)}function O(e){if("string"!=typeof e||0===e.length)throw new TypeError("Signal path must be a non-empty string.");const t=e.split(".");for(let r=t.length;r>0;r-=1){const n=t.slice(0,r).join(".");if(l.has(n)||f.has(n))return k(n),{id:n,parts:t.slice(r),path:e}}const[r,...n]=t;return{id:r,parts:n,path:e}}function k(e){if(l.has(e)||!f.has(e))return;const t=f.get(e);if(!c(t)&&"function"!=typeof t)throw new TypeError(`Async signal "${e}" must be a function or lazy descriptor.`);const r=n(e,async function(...r){const n=await b.resolve("asyncSignal",e,t);if("function"!=typeof n)throw new TypeError(`Async signal "${e}" did not resolve to a function.`);return n.apply(this,r)});l.set(e,r),j(e,r)}},isSignalRef:function(e){return Boolean(e?.[p])},signal:h}})(),a=(()=>{const{isSignalRef:e}=s,{attributeName:t,matchAttribute:r,normalizeAttributeConfig:n}=o,a=Symbol.for("@async/framework.template"),i=Symbol.for("@async/framework.rawHtml");function c(e){return Boolean(e?.[a])}function u(e,t={}){if(c(e)){const r=p(t);let n="";for(let t=0;t<e.strings.length;t+=1)n+=e.strings[t],t<e.values.length&&(n+=l(e.values[t],{...r,attribute:d(e.strings[t])}));return n}return l(e,p(t))}function l(n,o=p()){return n?.[i]?n.html:c(n)?u(n,o):o.attribute?function(n,o){const s=r(o.attribute.name,o.attributes,"signal"),a=r(o.attribute.name,o.attributes,"class"),i=function(t,r){return e(t)?t.id:"string"==typeof t&&r.signals?.has?.(t)?t:null}(n,o);if("value"===o.attribute.name&&i){const r=function(t,r){return e(t)?t.value:"string"==typeof t&&r.signals?.has?.(t)?r.signals.get(t):t}(n,o),s=t(o.attributes,"signal","value");return`${h(r)}${o.attribute.quote} ${s}=${o.attribute.quote}${h(i)}`}if(null!=s||null!=a){if(i)return h(i);if(function(e){return Boolean(e&&"object"==typeof e)}(n))return h(function(e,t){return"function"!=typeof t.bind?e:t.bind(e)}(n,o))}return f(n,o)}(n,o):Array.isArray(n)?n.map(e=>l(e,o)).join(""):e(n)?h(n.value):null==n||!1===n?"":h(n)}function f(t,r){return Array.isArray(t)?t.map(e=>f(e,r)).join(""):e(t)?h(t.value):null==t||!1===t?"":h(t)}function p(e={}){return{...e,attributes:n(e.attributes)}}function d(e){const t=e.match(/(?:^|[\s<])([^\s"'=<>`]+)\s*=\s*(["'])$/);return t?{name:t[1],quote:t[2]}:null}function h(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}return{html:function(e,...t){return{[a]:!0,strings:e,values:t}},isTemplateResult:c,rawHtml:function(e){return{[i]:!0,html:String(e??"")}},renderTemplate:u,escapeHtml:h}})(),i=(()=>{const{attributeName:e}=o,{escapeHtml:n,rawHtml:s,renderTemplate:i}=a,{attachRegistryInspection:c,createRegistryStore:u}=r,{createLazyRegistry:l,isLazyDescriptor:f}=t,p=Symbol.for("@async/framework.component");let d=0;function h(e){if("function"!=typeof e)throw new TypeError("defineComponent(fn) requires a function.");return Object.defineProperty(e,p,{configurable:!0,value:!0}),e}function y(e){return Boolean(e?.[p])}function g(t,r={},o,a="component"){if(!y(t)&&"function"!=typeof t)throw new TypeError("renderComponent(Component) requires a component function.");const c=`${a}.${function(e){return e.displayName||e.name||"anonymous"}(t)}.${++d}`,u=[],l=[],f=[],p=[],h=[],w={attributes:o.attributes,signals:o.signals,bind(e){const t=o.loader?._registerBinding?.(e);if(!t)throw new Error("Inline template bindings require a Loader.");return h.push(t),t}},b=e=>i(e,w),v=function({runtime:t,scope:r,cleanups:o,attachHooks:a,visibleHooks:i,destroyHooks:c,renderScopedTemplate:u}){const{signals:l,handlers:f,loader:p,server:d,router:h,cache:y,scheduler:w}=t,b=new WeakMap;let v=0,S=0;const E={scope:r,signals:l,handlers:f,loader:p,server:d,router:h,cache:y,scheduler:w,signal(e,t){if(1===arguments.length){const t=m(r,"signal."+ ++S),n=l.ensure(t,e);return o.push(()=>l.unregister?.(t)),n}const n=m(r,e),s=!l.has(n),a=l.ensure(n,t);return s&&o.push(()=>l.unregister?.(n)),a},computed(e,t){const n=m(r,e),s=!l.has(n),a=l.ensure(n,void 0);s&&o.push(()=>l.unregister?.(n));const i=l.effect(()=>{l.set(n,t.call(E))});return o.push(i),a},asyncSignal(e,t){const n=m(r,e),s=!l.has(n);return l.has(n)||l.asyncSignal(n,t),s&&o.push(()=>l.unregister?.(n)),l.ref(n)},effect(e){const t=l.effect(()=>e.call(E),{scheduler:w,phase:"effect",scope:r});return o.push(t),t},handler(e,t){if("function"==typeof e&&void 0===t){const t=e;if(b.has(t))return b.get(t);const r=$("handler."+ ++v,t);return b.set(t,r),r}if("function"!=typeof t)throw new TypeError("this.handler(name, fn) or this.handler(fn) requires a function.");return $(e,t)},render(e,n={}){const c=g(e,n,t,r);return o.push(c.cleanup),a.push(e=>c.attach(e)),i.push(e=>c.visible(e,p._observeVisible)),s(c.html)},suspense(r,o){const a=r?.id;if(!a)throw new TypeError("this.suspense(signalRef, views) requires a signal ref.");const i=function(e){const t="function"==typeof e?{ready:e}:e;if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("this.suspense(signalRef, views) requires views to be a function or object.");for(const e of["loading","ready","error"])if(Object.hasOwn(t,e)&&void 0!==t[e]&&"function"!=typeof t[e])throw new TypeError(`this.suspense(signalRef, views) view "${e}" must be a function.`);return t}(o),c=[];for(const o of["loading","ready","error"]){const s=i[o];if(!s)continue;const l=e(t.attributes,"async",o),f=u(s.call(E,r));c.push(`<template ${l}="${n(a)}">${f}</template>`)}return s(c.join(""))},on(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Component lifecycle event must be a non-empty string.");if("function"!=typeof t)throw new TypeError(`Component lifecycle "${e}" requires a function.`);const r="mount"===e?"attach":e;if("attach"!==r)if("visible"!==r){if("destroy"!==r)throw new Error(`Unsupported component lifecycle event "${e}".`);c.push(()=>t.call(E))}else i.push(e=>t.call(E,e));else a.push(e=>t.call(E,e))},onMount(e){E.on("attach",e)},onVisible(e){E.on("visible",e)}};return E;function $(e,t){const n=m(r,e);return f.register(n,e=>t.call({...E,...e},e)),o.push(()=>f.unregister?.(n)),n}}({runtime:o,scope:c,cleanups:u,attachHooks:l,visibleHooks:f,destroyHooks:p,renderScopedTemplate:b});return{html:b(t.call(v,r)),attach(e){for(const t of l)o.scheduler?.enqueue("lifecycle",()=>{const r=t(e);"function"==typeof r&&u.push(r)},{scope:c,key:`attach:${l.indexOf(t)}`})??S(t,e)},mount(e){this.attach(e)},visible(e,t){for(const r of f){const n=t(e,()=>{o.scheduler?.enqueue("lifecycle",()=>{const t=r(e);"function"==typeof t&&u.push(t)},{scope:c,key:`visible:${f.indexOf(r)}`})??E(r,e)});"function"==typeof n&&u.push(n)}},cleanup(){for(;p.length>0;)p.pop()?.();for(o.scheduler?.markScopeDestroyed(c);u.length>0;)u.pop()?.();for(;h.length>0;)o.loader?._releaseBinding?.(h.pop())}};function S(e,t){const r=e(t);"function"==typeof r&&u.push(r)}function E(e,t){const r=e(t);"function"==typeof r&&u.push(r)}}function m(e,t){if("string"!=typeof t||0===t.length)throw new TypeError("Scoped signal or handler name must be a non-empty string.");return`${e}.${t}`}return{defineComponent:h,createComponentRegistry:function(e={},t={}){const r=t.registry??u(),n=t.type??"component",o=r._map(n),s=t.lazyRegistry??l(t),a=new Map,i=c({register(e,t){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");if(!y(t)&&"function"!=typeof t&&!f(t))throw new TypeError(`Component "${e}" must be a component function.`);if(o.has(e))throw new Error(`Component "${e}" is already registered.`);return o.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))i.register(t,r);return i},unregister(e){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");return a.delete(e),o.delete(e)},resolve(e){if("string"!=typeof e||0===e.length)throw new TypeError("Component id must be a non-empty string.");const t=o.get(e);return f(t)?(a.has(e)||a.set(e,async function(...r){const o=await s.resolve(n,e,t);if("function"!=typeof o)throw new TypeError(`Component "${e}" did not resolve to a function.`);return o.apply(this,r)}),a.get(e)):t},_adoptMany:()=>i},r,n);return i.registerMany(e),i},isComponent:y,renderComponent:g,component:h}})(),c=(()=>{const e=new Set(["value","signals","boundary","html","redirect","error"]),t=Symbol.for("@async/framework.appliedServerResult"),r=new WeakSet;async function n(e,n={}){if(!d(e))return e;if(e[t]||r.has(e))return e;if(e.signals&&n.signals)for(const[t,r]of Object.entries(e.signals))n.signals.set?.(t,r);if(e.cache?.browser&&n.cache?.restore&&n.cache.restore(e.cache.browser),e.boundary&&Object.hasOwn(e,"html")&&n.loader?.swap?.(e.boundary,e.html),e.redirect&&await(n.router?.navigate?.(e.redirect)),e.error)throw(o=e.error)instanceof Error?o:o&&"object"==typeof o&&"string"==typeof o.message?Object.assign(new Error(o.message),o):new Error(String(o));var o;return Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:!0}),e}function o(e){return d(e)&&Object.hasOwn(e,"value")?e.value:e}function s(e={}){const t=l(e);if(t)return f(new t.ownerDocument.defaultView.FormData(t));const r=e.element??e.el??e.event?.target;return r?{value:"value"in r?r.value:void 0,checked:"checked"in r?r.checked:void 0,dataset:r.dataset?{...r.dataset}:{}}:{}}function a(e,t={},r=()=>({})){const s=new Map;return function i(c){const u=c.join(".");if(s.has(u))return s.get(u);const l=new Proxy(async(...t)=>{if(0===c.length)throw new Error("Server namespace is not directly callable.");const s=r()??{},a=await e(c.join("."),t,s);return await n(a,s),o(a)},{get(n,o){if("then"!==o)return o in n?n[o]:0===c.length&&"_withContext"===o?(n={})=>a(e,t,()=>({...r()??{},...n})):0===c.length&&"run"===o&&"function"==typeof t.run?(e,n=[],o={})=>t.run(e,n,{...r()??{},...o}):0===c.length&&Object.hasOwn(t,o)?t[o]:o===Symbol.toStringTag?"AsyncServerNamespace":"toString"===o?()=>0===c.length?"server":`server.${c.join(".")}`:i([...c,String(o)])}});return s.set(u,l),l}([])}function i(e=[],t){const r={};for(const n of e)r[n]=c(t,n);return r}function c(e,t){if(!e||"function"!=typeof e.get)throw new Error(`Signal "${t}" cannot be read without a signal registry.`);return e.get(t)}function u(e,t,{forServer:r}={}){if(("$event"===e||"$el"===e)&&r)throw new Error(`${e} cannot be passed to a server command.`);if("$event"===e)return t.event;if("$el"===e)return t.element??t.el;if("$value"===e){const e=t.element??t.el??t.event?.target;return e?.value}if("$checked"===e){const e=t.element??t.el??t.event?.target;return e?.checked}if("$form"===e){const e=l(t);return e?f(new e.ownerDocument.defaultView.FormData(e)):{}}if("$dataset"===e){const e=t.element??t.el??t.event?.target;return e?.dataset?{...e.dataset}:{}}throw new Error(`Event local "${e}" is not supported.`)}function l(e){const t=e.event,r=e.element??e.el??t?.target;return"FORM"===r?.tagName?r:"submit"===t?.type&&"FORM"===t.target?.tagName?t.target:"submit"===t?.type&&r?.form?r.form:null}function f(e){const t={};for(const[r,n]of e.entries())Object.hasOwn(t,r)?t[r]=Array.isArray(t[r])?[...t[r],n]:[t[r],n]:t[r]=n;return t}function p(e,t=new Set){if("bigint"==typeof e)throw new Error("Server proxy JSON transport does not support BigInt values.");if(null==e||"object"!=typeof e)return;if(t.has(e))throw new Error("Server proxy JSON transport does not support circular values.");t.add(e);const r=Object.prototype.toString.call(e);if("[object File]"===r||"[object Blob]"===r||"[object FormData]"===r)throw new Error("Server proxy JSON transport does not support File, Blob, or FormData values yet.");if(Array.isArray(e)){for(const r of e)p(r,t);t.delete(e)}else{for(const r of Object.values(e))p(r,t);t.delete(e)}}function d(t){return!(!t||"object"!=typeof t||Array.isArray(t))&&Object.keys(t).some(t=>e.has(t))}function h(e){if("string"!=typeof e||0===e.length)throw new TypeError("Server function id must be a non-empty string.")}return{createServerProxy:function({endpoint:e="/__async/server",transport:t,signals:c,loader:u,router:l,cache:f,scheduler:d,headers:y={}}={}){if("function"!=typeof t)throw new TypeError("createServerProxy(...) requires a transport function.");const g={signals:c,loader:u,router:l,cache:f,scheduler:d};async function m(a,c=[],u={}){h(a);const l={...g,...u},f={args:c,input:u.input??s(l),signals:u.signalValues??i(u.signalPaths,l.signals)};p(f);const d=await t(function(e,t){return`${String(e).replace(/\/$/,"")}/${encodeURIComponent(t)}`}(e,a),{method:"POST",headers:{"content-type":"application/json",...y},body:JSON.stringify(f),signal:u.abort});if(!d.ok)throw new Error(`Server function "${a}" failed with ${d.status}.`);const m=await async function(e){return(e.headers.get("content-type")??"").includes("application/json")?e.json():{value:await e.text()}}(d);return await n(m,l),(w=o(m))&&"object"==typeof w&&r.add(w),w;var w}return a(m,{run:m,_setContext(e={}){Object.assign(g,e)}},()=>g)},resolveServerCommandArguments:function(e,t={}){const r=[],n={},o=[];for(const s of e){if("local"===s.type){r.push(u(s.name,t,{forServer:!0}));continue}const e=c(t.signals,s.path);r.push(e),n[s.path]=e,o.push(s.path)}return{args:r,signalValues:n,signalPaths:o}},applyServerResult:n,unwrapServerResult:o,defaultInput:s,createServerNamespace:a,createSignalReader:function(e){return e&&"function"!=typeof e.get?{get:t=>function(e,t){return String(t).split(".").reduce((e,t)=>e?.[t],e)}(e,t),snapshot:()=>({...e})}:e},assertServerId:h}})(),u=(()=>{const{applyServerResult:e,defaultInput:n,resolveServerCommandArguments:o,unwrapServerResult:s}=c,{attachRegistryInspection:a,createRegistryStore:i}=r,{createLazyRegistry:u,isLazyDescriptor:l}=t,f=new Set(["prevent","preventDefault","stopPropagation","stopImmediatePropagation"]),p={prevent:d,preventDefault:d,stopPropagation(){this.event?.stopPropagation?.()},stopImmediatePropagation(){this.event?.stopImmediatePropagation?.()}};function d(){this.event?.preventDefault?.()}function h(e){if("string"!=typeof e||0===e.trim().length)throw new TypeError("Handler ref must be a non-empty string.");return e.split(";").map(e=>e.trim()).filter(Boolean).map(g)}function y(e){if("string"!=typeof e||0===e.length)throw new TypeError("Handler id must be a non-empty string.")}function g(e){if(e.startsWith("server."))return function(e){const t=e.indexOf("(");if(-1===t||!e.endsWith(")"))throw new Error(`Server command "${e}" must be called with parentheses.`);const r=e.slice(7,t).trim();if(!function(e){return/^[^.\s();]+(?:\.[^.\s();]+)*$/.test(e)}(r))throw new Error(`Server command "${e}" has an invalid function id.`);return{type:"server",id:r,args:m(e.slice(t+1,-1))}}(e);if(e.includes("(")||e.includes(")"))throw new Error(`Command "${e}" is not supported.`);return{type:"handler",id:e}}function m(e){return 0===e.trim().length?[]:e.split(",").map(e=>e.trim()).filter(Boolean).map(w)}function w(e){if(!/^[^\s,();]+$/.test(e))throw new Error(`Argument "${e}" is not supported.`);return e.startsWith("$")?{type:"local",name:e}:{type:"signal",path:e}}return{createHandlerRegistry:function(t={},r={}){const c=r.registry??i(),d=r.type??"handler",g=c._map(d),m=r.lazyRegistry??u(r),w=new Map,b=a({register(e,t){if(y(e),"function"!=typeof t&&!l(t))throw new TypeError(`Handler "${e}" must be a function.`);if(g.has(e))throw new Error(`Handler "${e}" is already registered.`);return g.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))b.register(t,r);return b},unregister:e=>(y(e),w.delete(e),g.delete(e)),resolve(e){y(e);const t=g.get(e);return l(t)?(w.has(e)||w.set(e,async function(...r){const n=await m.resolve(d,e,t);if("function"!=typeof n)throw new TypeError(`Handler "${e}" did not resolve to a function.`);return n.apply(this,r)}),w.get(e)):t},async run(t,r={}){const a=h(t),i=[];let c=!1;const u={...r,handlers:b,input:r.input??n(r),stop(){c=!0}};for(const t of a){if(c)break;if("server"===t.type){if(!u.server||"function"!=typeof u.server.run)throw new Error(`Server command "${t.id}" cannot run without a server registry.`);const r=o(t.args,u),n=await u.server.run(t.id,r.args,{...u,signalPaths:r.signalPaths,signalValues:r.signalValues});await e(n,u),i.push(s(n));continue}const r=b.resolve(t.id);if(!r)throw new Error(`Handler "${t.id}" is not registered.`);const n=await r.call(u,u);f.has(t.id)&&r===p[t.id]||i.push(n)}return i},_adoptMany:()=>b},c,d);return function(e,t){for(const[r,n]of Object.entries(p))if(t.has(r)){if(t.get(r)!==n)throw new Error(`Handler "${r}" is already registered.`)}else e.register(r,n)}(b,g),b.registerMany(t),b},parseHandlerRef:h,isHandlerToken:function(e){return f.has(e)}}})(),l=(()=>{const e=["binding","lifecycle","effect","async","post"];function t(){}return{createScheduler:function(r={}){const n=[...r.phases??e],o=new Map(n.map(e=>[e,[]])),s=new Map,a=new Set,i=new WeakMap,c="function"==typeof r.onError?r.onError:void 0,u=r.maxDepth??100,l=r.strategy??"microtask";let f=!1,p=!1,d=!1,h=0,y=0,g=0;const m={strategy:l,phases:n,batch(e){if("function"!=typeof e)throw new TypeError("scheduler.batch(fn) requires a function.");E(),h+=1;let t=!1;try{const r=e();return r&&"function"==typeof r.then?(t=!0,r.finally(()=>{h-=1,w()})):r}finally{!t&&h>0&&(h-=1,w())}},enqueue(e,r,n={}){if(E(),function(e){if(!o.has(e))throw new Error(`Unknown scheduler phase "${e}".`)}(e),"function"!=typeof r)throw new TypeError("scheduler.enqueue(phase, fn) requires a function.");const c=n.scope;if(void 0!==c&&a.has(c))return t;const u=void 0===n.key?void 0:`${e}:${function(e){return void 0===e?"global":"object"==typeof e&&null!==e||"function"==typeof e?(i.has(e)||i.set(e,"scope:"+ ++g),i.get(e)):String(e)}(c)}:${String(n.key)}`;if(u&&s.has(u))return s.get(u).cancel;const l={id:++y,phase:e,fn:r,scope:c,boundary:n.boundary,key:u,canceled:!1,cancel(){l.canceled=!0,l.key&&s.delete(l.key)}};return o.get(e).push(l),l.key&&s.set(l.key,l),w(),l.cancel},afterFlush:(e,t={})=>m.enqueue("post",e,t),async flush(){if(E(),p)return;d=!1,p=!0;let e=0;try{for(;v();){if(e+=1,e>u)throw new Error(`Scheduler exceeded maxDepth ${u}.`);for(const e of n)await b(e)}}finally{p=!1,v()&&w()}},async flushScope(e){if(E(),p)return;d=!1,p=!0;let t=0;try{for(;S(e);){if(t+=1,t>u)throw new Error(`Scheduler exceeded maxDepth ${u}.`);for(const t of n)await b(t,e)}}finally{p=!1,v()&&w()}},cancelScope(e){if(void 0===e)return m;for(const t of o.values())for(const r of t)r.scope===e&&r.cancel();return m},markScopeDestroyed:e=>(void 0!==e&&(a.add(e),m.cancelScope(e)),m),isScopeDestroyed:e=>void 0!==e&&a.has(e),inspect(){const e={};for(const[t,r]of o)e[t]=r.filter(e=>!e.canceled).length;return{strategy:l,phases:[...n],pending:e,scopesDestroyed:a.size,flushing:p,scheduled:d}},destroy(){f=!0;for(const e of o.values()){for(const t of e)t.cancel();e.length=0}s.clear(),a.clear()}};return m;function w(){var e;"manual"===l||f||p||h>0||d||(d=!0,e=()=>{f||m.flush()},"function"!=typeof queueMicrotask?Promise.resolve().then(e):queueMicrotask(e))}async function b(e,t){const r=o.get(e),n=[],i=[];for(const e of r.splice(0))e.canceled||(void 0===t||e.scope===t?i.push(e):n.push(e));r.push(...n);for(const e of i)if(e.key&&s.delete(e.key),!(e.canceled||void 0!==e.scope&&a.has(e.scope)))try{await e.fn()}catch(t){if(!c)throw t;c(t,e)}}function v(){for(const e of o.values())if(e.some(e=>!e.canceled))return!0;return!1}function S(e){for(const t of o.values())if(t.some(t=>!t.canceled&&t.scope===e))return!0;return!1}function E(){if(f)throw new Error("Scheduler has been destroyed.")}}}})(),f=(()=>{const{renderComponent:e}=i,{createHandlerRegistry:t}=u,{createScheduler:r}=l,{createSignalRegistry:n,isSignalRef:a}=s,{matchAttribute:c,normalizeAttributeConfig:f,readAttribute:p}=o,d="__async:inline:";function h({root:o,signals:s,handlers:i,server:u,router:l,cache:h,attributes:E,scheduler:O}={}){const T=o?.ownerDocument??o??globalThis.document,q=o??T,C=s??n(),M=i??t(),x=O??r(),L=!O,D=f(E),B=new Set,P=new WeakMap,N=new WeakMap,z=new WeakSet,H=new WeakSet,W=new WeakMap,U=new WeakSet,V=new Map,I=new WeakMap;let F=0,J=!1;const K={root:q,signals:C,handlers:M,server:u,router:l,cache:h,scheduler:x,attributes:D,start:()=>(ne(),K.scan(q),K),scan:(e=q)=>(ne(),function(e){for(const t of R(e))for(const e of t.getAttributeNames?.()??[]){const r=c(e,D,"signal");if(r){if("text"===r){const r=t.getAttribute(e);G(t,`text:${r}`,r,e=>{t.textContent=e??""});continue}if("value"===r){const r=t.getAttribute(e);G(t,`value:${r}`,r,e=>{"value"in t&&t.value!==String(e??"")?t.value=e??"":"value"in t||t.setAttribute("value",e??"")}),Q(t,r);continue}if(r.startsWith("attr:")){const n=r.slice(5),o=t.getAttribute(e);G(t,`attr:${n}:${o}`,o,e=>$(t,n,e));continue}if(r.startsWith("prop:")){const n=r.slice(5),o=t.getAttribute(e);G(t,`prop:${n}:${o}`,o,e=>A(t,n,e));continue}if(r.startsWith("class:")){const n=r.slice(6),o=t.getAttribute(e);""===n||"{}"===n?Y(t,n,o):G(t,`class:${n}:${o}`,o,e=>{t.classList.toggle(n,Boolean(e))});continue}if("class"===r){const r=t.getAttribute(e);Y(t,"{}",r)}}}}(e),function(e){for(const t of R(e))for(const e of t.getAttributeNames?.()??[]){const r=c(e,D,"class");null!=r&&Y(t,r,t.getAttribute(e))}}(e),function(e){for(const t of R(e))if("function"==typeof t.getAttributeNames)for(const e of t.getAttributeNames()){const r=c(e,D,"on");r&&"attach"!==r&&"mount"!==r&&"visible"!==r&&Z(t,r,t.getAttribute(e))}}(e),function(e){for(const t of R(e)){if(U.has(t))continue;const e=j(t,D);if(null!=e){if(!W.has(t)){const r=S(t,e,D);if(0===Object.keys(r).length||!C.has(e))continue;const n={id:e,templates:r,cleanup:C.subscribe(`${e}.$status`,()=>{x.enqueue("binding",()=>X(t),{scope:t,key:`boundary:${e}`})})};W.set(t,n),oe(n.cleanup,t)}X(t)}}}(e),function(e){for(const t of R(e)){const e=ee(t,["attach","mount"]);if(0!==e.length&&!z.has(t)){z.add(t);for(const r of e)ue(t,()=>te(t,r),`attach:${r}`)}}for(const t of R(e)){const e=p(t,D,"on","visible");null!=e&&(H.has(t)||(H.add(t),oe(re(t,()=>ue(t,()=>te(t,e),`visible:${e}`)),t)))}}(e),K),swap(e,t){ne();const r=function(e,t,r){for(const n of R(e))if(j(n,r)===String(t))return n;return null}(q,e,D);if(!r)throw new Error(`Boundary "${e}" was not found.`);return ae(r),r.replaceChildren(k(t,T)),K.scan(r),r},mount(t,r,n={}){ne();const o=e(r,n,{signals:C,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,attributes:D});return ae(t),t.replaceChildren(k(o.html,t.ownerDocument)),K.scan(t),o.mount(t),o.visible(t,K._observeVisible),oe(o.cleanup,t,"children"),o},destroy(){if(!J){J=!0,function(e){for(const t of R(e))x.markScopeDestroyed(t)}(q);for(const e of[...B])se(e);B.clear(),L&&x.destroy()}},_observeVisible:(e,t)=>re(e,t),_registerBinding(e){const t=`${d}${++F}`;return V.set(t,e),t},_releaseBinding(e){V.delete(e)}};function Z(e,t,r){const n=`${t}:${r}`,o=P.get(e)??new Set;if(o.has(n))return;o.add(n),P.set(e,o);const s=async t=>{try{await x.batch(()=>M.run(r,{signals:C,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,event:t,element:e,el:e,root:q}))}catch(t){_(e,t)}};e.addEventListener(t,s),oe(()=>e.removeEventListener(t,s),e)}function Y(e,t,r){if(""===t||"{}"===t){const t=b(e);let n=new Set;return void G(e,`class:{}:${r}`,r,r=>{const o=y(r),s=b(e);for(const e of n)o.has(e)||t.has(e)||s.delete(e);for(const e of o)s.add(e);v(e,s),n=o},{rawInline:!0})}G(e,`class:${t}:${r}`,r,r=>{!function(e,t,r){const n=b(e);for(const e of y(t))r?n.add(e):n.delete(e);v(e,n)}(e,t,Boolean(r))})}function G(e,t,r,n,o={}){const s=N.get(e)??new Set;if(s.has(t))return;s.add(t),N.set(e,s);const a=()=>function(e,t={}){if(w(e)){const r=V.get(e);return t.rawInline?r:g(r)}return C.get(e)}(r,o);n(a()),oe(function(e,t){if(!w(e))return C.subscribe(e,t);const r=m(V.get(e)).map(e=>e.subscribe(t));return()=>{for(const e of r)e()}}(r,()=>{x.enqueue("binding",()=>n(a()),{scope:e,key:t})}),e)}function Q(e,t){Z(e,"input",`__async:set:${t}`),Z(e,"change",`__async:set:${t}`),M.resolve(`__async:set:${t}`)||M.register(`__async:set:${t}`,({element:e})=>{!function(e,t){if(!w(e))return C.set(e,t);const r=V.get(e);if(a(r))return r.set(t);throw new Error(`Inline binding "${e}" is not writable.`)}(t,e.value)})}function X(e){const t=W.get(e);if(!t)return;const r=C.get(`${t.id}.$status`),n=function(e,t){return"ready"===t?e.ready??e.loading??e.error:"error"===t?e.error??e.ready??e.loading:e.loading??e.ready??e.error}(t.templates,r);if(n){ae(e),e.replaceChildren(n.content.cloneNode(!0)),U.add(e);try{K.scan(e)}finally{U.delete(e)}}}function ee(e,t){const r=[];for(const n of t){const t=p(e,D,"on",n);null!=t&&r.push(t)}return r}async function te(e,t){try{const r=await M.run(t,{signals:C,handlers:M,loader:K,server:K.server,router:K.router,cache:K.cache,scheduler:x,element:e,el:e,root:q});for(const t of r)"function"==typeof t&&oe(t,e)}catch(t){_(e,t)}}function re(e,t){const r=(e.ownerDocument?.defaultView??globalThis).IntersectionObserver??globalThis.IntersectionObserver;if(!r)return x.enqueue("lifecycle",()=>{J||t(e)},{scope:e,key:"visible:fallback"}),()=>{};const n=new r(r=>{r.some(e=>e.isIntersecting)&&(n.disconnect(),t(e))});return n.observe(e),()=>n.disconnect()}function ne(){if(J)throw new Error("Loader has been destroyed.")}function oe(e,t,r="self"){if("function"!=typeof e)return e;if(B.add(e),t){const n=I.get(t)??[];n.push({cleanup:e,mode:r}),I.set(t,n)}return e}function se(e){"function"==typeof e&&B.has(e)&&(B.delete(e),e())}function ae(e){ce(e,"children");for(const t of[...e.childNodes??[]])ie(t)}function ie(e){if(1===e.nodeType)for(const t of R(e))ce(t),x.markScopeDestroyed(t)}function ce(e,t){const r=I.get(e);if(!r)return;const n=[];for(const e of r)t&&e.mode!==t?n.push(e):se(e.cleanup);n.length>0?I.set(e,n):I.delete(e)}function ue(e,t,r){x.enqueue("lifecycle",t,{scope:e,key:r})}return C._setContext?.({server:K.server,router:K.router,loader:K,cache:K.cache,scheduler:x}),K.server?._setContext?.({signals:C,handlers:M,loader:K,router:K.router,cache:K.cache,scheduler:x}),K}function y(e,t=new Set){if(null==e||!1===e)return t;if(a(e)){const r=e.value;return!0===r?(t.add(e.id.split(".").at(-1)),t):y(r,t)}if("string"==typeof e){for(const r of e.split(/\s+/).filter(Boolean))t.add(r);return t}if(Array.isArray(e)){for(const r of e)y(r,t);return t}if("object"==typeof e){for(const[r,n]of Object.entries(e))(a(n)?n.value:n)&&y(r,t);return t}return!0!==e&&t.add(String(e)),t}function g(e){return a(e)?e.value:Array.isArray(e)?e.map(g):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,g(t)])):e}function m(e,t=new Map){if(a(e))return t.set(e.id,e),[...t.values()];if(Array.isArray(e)){for(const r of e)m(r,t);return[...t.values()]}if(e&&"object"==typeof e)for(const r of Object.values(e))m(r,t);return[...t.values()]}function w(e){return"string"==typeof e&&e.startsWith(d)}function b(e){return y(e.getAttribute("class")??"")}function v(e,t){const r=[...t].join(" ");0!==r.length?e.setAttribute("class",r):e.removeAttribute("class")}function S(e,t,r){const n={};for(const o of[...e.children].filter(e=>"TEMPLATE"===e.tagName))E(o,"loading",t,e,r)&&(n.loading=o),E(o,"ready",t,e,r)&&(n.ready=o),E(o,"error",t,e,r)&&(n.error=o);return n}function E(e,t,r,n,o){return p(e,o,"async",t)===r||O(n)&&e.hasAttribute?.(t)}function $(e,t,r){if(!1===r||null==r)return e.removeAttribute(t),void(t in e&&(e[t]=!1));e.setAttribute(t,!0===r?"":String(r)),t in e&&(e[t]=r)}function A(e,t,r){e[t]=null!=r?r:""}function R(e){return function(e,t){const r=[];return 1===e?.nodeType&&e.matches?.(t)&&r.push(e),r.push(...e?.querySelectorAll?.(t)??[]),r}(e,"*")}function j(e,t){return O(e)&&e.hasAttribute?.("for")?e.getAttribute("for"):p(e,t,"async","boundary")}function O(e){return"ASYNC-SUSPENSE"===e?.tagName}function k(e,t){if(11===e?.nodeType)return e;if("TEMPLATE"===e?.tagName)return e.content.cloneNode(!0);if(e?.nodeType){const r=t.createDocumentFragment();return r.append(e),r}const r=t.createElement("template");return r.innerHTML=String(e??""),r.content.cloneNode(!0)}function _(e,t){const r=e.ownerDocument?.defaultView?.CustomEvent??globalThis.CustomEvent;e.dispatchEvent(new r("async:error",{bubbles:!0,detail:{error:t}}))}return{Loader:h,AsyncLoader:h}})(),p=(()=>{const{isTemplateResult:e,renderTemplate:n}=a,{attachRegistryInspection:o,createRegistryStore:s}=r,{createLazyRegistry:i,isLazyDescriptor:c}=t;function u(e,t={}){return r=e,Boolean(r&&"object"==typeof r&&!Array.isArray(r)&&(Object.hasOwn(r,"html")||Object.hasOwn(r,"signals")||Object.hasOwn(r,"boundary")||Object.hasOwn(r,"redirect")||Object.hasOwn(r,"status")||Object.hasOwn(r,"cache")))?{...e,html:Object.hasOwn(e,"html")?l(e.html,t):e.html}:{html:l(e,t)};var r}function l(t,r){return t?.nodeType||"string"==typeof t?t:(e(t),n(t,function(e){return{attributes:e.loader?.attributes,signals:e.signals,bind:e.loader?._registerBinding?.bind(e.loader)}}(r)))}function f(e){if("string"!=typeof e||0===e.length)throw new TypeError("Partial id must be a non-empty string.")}return{createPartialRegistry:function(e={},t={}){const r=t.registry??s(),n=t.type??"partial",a=r._map(n),l=t.lazyRegistry??i(t),p=new Map,d=o({register(e,t){if(f(e),"function"!=typeof t&&!c(t))throw new TypeError(`Partial "${e}" must be a function.`);if(a.has(e))throw new Error(`Partial "${e}" is already registered.`);return a.set(e,t),e},registerMany(e){for(const[t,r]of Object.entries(e??{}))d.register(t,r);return d},unregister:e=>(f(e),p.delete(e),a.delete(e)),resolve(e){f(e);const t=a.get(e);return c(t)?(p.has(e)||p.set(e,async function(...r){const o=await l.resolve(n,e,t);if("function"!=typeof o)throw new TypeError(`Partial "${e}" did not resolve to a function.`);return o.apply(this,r)}),p.get(e)):t},async render(e,t={},r={}){f(e);const n=d.resolve(e);if(!n)throw new Error(`Partial "${e}" is not registered.`);const o={...r,id:e,props:t,cache:r.cache,partials:d};return u(await n.call(o,t),o)},_adoptMany:()=>d},r,n);return d.registerMany(e),d},normalizePartialResult:u}})(),d=(()=>{const{Loader:e}=f,{createHandlerRegistry:t}=u,{createScheduler:n}=l,{createSignalRegistry:a}=s,{applyServerResult:i}=c,{createRegistryStore:p}=r,{normalizeAttributeConfig:d}=o;function h(e,t={}){return{...t,partial:e}}const y=h,g=new Set(["csr","spa","ssr","mpa"]);function m(e={},t={}){const r=t.registry??p(),n=t.type??"route",o=r._map(n),s=[],a={registry:r,register(e,t){if(A(e),s.some(t=>t.pattern===e))throw new Error(`Route "${e}" is already registered.`);const r=w(e,t);return o.set(e,r.definition),s.push(r),E(s),r},registerMany(e){for(const[t,r]of Object.entries(e??{}))a.register(t,r);return a},unregister(e){A(e);const t=s.findIndex(t=>t.pattern===e);return-1!==t&&s.splice(t,1),o.delete(e)},match(e){const t=function(e){return e instanceof URL?e:new URL(String(e),globalThis.location?.href??"http://localhost/")}(e).pathname;for(const e of s){const r=e.regex.exec(t);if(!r)continue;const n={};return e.keys.forEach((e,t)=>{n[e]=S(r[t+1]??"")}),{pattern:e.pattern,params:n,route:e.definition}}return null},entries:()=>s.map(({pattern:e,definition:t})=>({pattern:e,route:t})),keys:()=>[...o.keys()],inspect:()=>r.entries(n),_adoptMany(e={}){for(const t of Object.keys(e??{}))i(t,o.get(t));return a}};for(const[e,t]of o)i(e,t);return a.registerMany(e),a;function i(e,t){if(s.some(t=>t.pattern===e))return;const r=w(e,t);o.set(e,r.definition),s.push(r),E(s)}}function w(e,t){const r="string"==typeof t?h(t):t,{regex:n,keys:o}=function(e){const t=[];if("*"===e)return{regex:/^.*$/,keys:t};if("/"===e)return{regex:/^\/$/,keys:t};const r=e.split("/").map(e=>e.startsWith(":")?(t.push(e.slice(1)),"([^/]+)"):String(e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/");return{regex:new RegExp(`^${r}$`),keys:t}}(e);return{pattern:e,regex:n,keys:o,score:$(e),definition:r}}function b(e,t){return e?.closest?.(t)}function v(e){return Object.fromEntries(e.searchParams.entries())}function S(e){try{return decodeURIComponent(e)}catch{return e}}function E(e){e.sort((e,t)=>t.score-e.score||t.pattern.length-e.pattern.length)}function $(e){return"*"===e?-1:e.split("/").filter(Boolean).reduce((e,t)=>"*"===t?e:t.startsWith(":")?e+2:e+4,"/"===e?3:0)}function A(e){if("string"!=typeof e||"*"!==e&&!e.startsWith("/"))throw new TypeError('Route pattern must be a path string or "*".')}return{defineRoute:h,createRouteRegistry:m,createRouter:function({mode:r="ssr",root:o,boundary:s="route",routes:c=m(),loader:u,signals:l,handlers:f,server:p,cache:h,partials:y,attributes:w,scheduler:S}={}){!function(e){if(!g.has(e))throw new TypeError(`Unknown router mode "${e}".`)}(r);const E=o?.ownerDocument??o??globalThis.document,$=o??E,A=l??u?.signals??a(),R=f??u?.handlers??t(),j=S??u?.scheduler??n(),O=!S&&!u?.scheduler,k=d(w??u?.attributes),_=u??e({root:$,signals:A,handlers:R,server:p,cache:h,scheduler:j,attributes:k}),T=!u,q=new Set;let C,M=!1,x=0;const L={mode:r,root:$,boundary:s,routes:c,loader:_,signals:A,handlers:R,server:p,cache:h,partials:y,scheduler:j,attributes:k,start:()=>(I(),_.router=L,A._setContext?.({router:L,loader:_,server:p,cache:h,scheduler:j}),T&&_.start(),"mpa"===r||"ssr"===r?(N(),L):(function(){const e=e=>{const t=b(e.target,"a[href]");t&&!function(e,t){if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!0;if(t.target||t.hasAttribute("download"))return!0;const r=V(t.href),n=U();return r.origin!==n.origin||function(e,t,r){return e.origin===t.origin&&e.pathname===t.pathname&&e.search===t.search&&(e.hash!==t.hash||!0===r.getAttribute?.("href")?.startsWith("#"))}(r,n,t)}(e,t)&&(e.preventDefault(),W(L.navigate(t.href)))},t=e=>{const t=b(e.target,"form");t&&!function(e){return"get"!==String(e.method||"get").toLowerCase()||V(e.action).origin!==U().origin}(t)&&(e.preventDefault(),W(L.navigate(function(e){const t=V(e.action||e.ownerDocument.defaultView.location.href),r=new e.ownerDocument.defaultView.FormData(e);return t.search=new URLSearchParams(r).toString(),t.href}(t))))},r=()=>W(L.navigate(U(),{history:!1}));$.addEventListener?.("click",e),$.addEventListener?.("submit",t),E.defaultView?.addEventListener?.("popstate",r),q.add(()=>$.removeEventListener?.("click",e)),q.add(()=>$.removeEventListener?.("submit",t)),q.add(()=>E.defaultView?.removeEventListener?.("popstate",r))}(),"csr"===r?(W(L.navigate(U(),{replace:!0,initial:!0,source:"client"})),L):(N(),L))),match:e=>c.match(V(e)),prefetch(e){if(I(),"mpa"===r||"ssr"===r)return Promise.resolve(null);const t=L.match(e);return t?.route?.partial&&y?.resolve?.(t.route.partial)?y.render(t.route.partial,t.params,D(t)):Promise.resolve(null)},navigate:async(e,t={})=>(I(),"mpa"===r||"ssr"===r?(E.defaultView?.location?.assign?.(e),null):async function(e,t={}){const r=L.match(e);if(!r)return B(e,null),function(e){z(e,null,{pending:!1,error:new Error(`No route matched ${e.pathname}${e.search}`)})}(e),null;const n=B(e,r);z(e,r,{pending:!0,error:null});try{if(!r.route?.partial||!y?.resolve?.(r.route.partial)){const t=new Error(`Route "${e.pathname}" does not have a registered partial.`);return P(n)&&H({pending:!1,error:t}),null}const o=await y.render(r.route.partial,r.params,D(r,n));return P(n)?(await async function(e,t,r,n){P(n)&&(await i(e,{signals:A,loader:_,router:L,cache:h,scheduler:j,abort:n?.abort}),await j.flush(),P(n)&&(null==e?.html||e.boundary||e.redirect||(_.swap(s,e.html),await j.flush()),e?.redirect||!1===r.history||(r.replace?E.defaultView?.history?.replaceState?.({},"",t.href):E.defaultView?.history?.pushState?.({},"",t.href))))}(o,e,t,n),P(n)?(H({pending:!1,error:null}),o):null):null}catch(e){if(!P(n))return null;throw H({pending:!1,error:e}),e}}(V(e),t)),destroy(){if(!M){M=!0,C?.controller.abort(new Error("Router has been destroyed."));for(const e of q)e();q.clear(),O&&j.destroy()}}};return L;function D(e,t){return{params:e.params,route:e.route,router:L,signals:A,handlers:R,loader:_,server:p,cache:h,scheduler:j,abort:t?.abort}}function B(e,t){C?.controller.abort(new Error(`Router navigation superseded by ${e.pathname}${e.search}.`));const r=new AbortController,n={id:++x,controller:r,abort:r.signal,target:e,matched:t};return C=n,n}function P(e){return!M&&e&&C?.id===e.id&&!e.abort.aborted}function N(){const e=U();z(e,L.match(e),{pending:!1,error:null})}function z(e,t,r={}){A.ensure("router",{}),H({url:e.href,path:e.pathname,query:v(e),params:t?.params??{},route:t?.route??null,...r})}function H(e){A.ensure("router",{});for(const[t,r]of Object.entries(e))A.set(`router.${t}`,r)}function W(e){e.catch(e=>{M||(H({pending:!1,error:e}),function(e,t){const r=e.ownerDocument?.defaultView?.CustomEvent??globalThis.CustomEvent;"function"==typeof r&&e.dispatchEvent?.(new r("async:error",{bubbles:!0,detail:{error:t}}))}($,e))})}function U(){return V(E.defaultView?.location?.href??"http://localhost/")}function V(e){return e instanceof URL?e:new URL(String(e),E.defaultView?.location?.href??"http://localhost/")}function I(){if(M)throw new Error("Router has been destroyed.")}},route:y}})(),h=(()=>{const{createCacheRegistry:e}=n,{createComponentRegistry:a}=i,{createHandlerRegistry:h}=u,{Loader:y}=f,{createPartialRegistry:g}=p,{createRouteRegistry:m,createRouter:w}=d,{createScheduler:b}=l,{createServerNamespace:v}=c,{createSignal:S,createSignalRegistry:E}=s,{createRegistryStore:$}=r,{attributeName:A,normalizeAttributeConfig:R}=o,{createLazyRegistry:j,defineRegistrySnapshot:O,sameRegistryValue:k}=t,_=new Set(["signal","handler","server","partial","route","component","asyncSignal"]);function T(e,t={}){const r=$(void 0,{target:"browser"}),n=new Set,o=t.createRuntime??q,s={registry:r,use(e,t){const o=function(e,t){const r={signal:{},handler:{},server:{},partial:{},route:{},component:{},asyncSignal:{},cache:{browser:{},server:{}}};if("string"==typeof e){if(!_.has(e))throw new Error(`Unknown Async registry type "${e}".`);return r[e]=U(e,t),r}if(!e||"object"!=typeof e)throw new TypeError("Async.use(...) requires a registry type or module object.");for(const[t,n]of Object.entries(e))if("cache"!==t){if(!_.has(t))throw new Error(`Unknown Async registry type "${t}".`);r[t]=U(t,n)}else r.cache.browser={...n?.browser??{}},r.cache.server={...n?.server??{}};return r}(e,t);!function(e,t){for(const r of _)L(e,r,t[r]);L(e,"cache.browser",t.cache.browser),L(e,"cache.server",t.cache.server)}(r,o);for(const e of n)e._applyUse(o);return s},snapshot:()=>r.rawSnapshot(),start(e={}){const t=o(s,e).start();return s.runtime=t,t},attachRoot:e=>function(e){return e.runtime||e.start(),e.runtime}(s).attachRoot(e),detachRoot:e=>s.runtime?.detachRoot(e)??s,applySnapshot:(e,t={})=>s.runtime?(s.runtime.applySnapshot(e,t),s):(function(e,t={},r={}){const n=P(t);for(const[t,o]of Object.entries(n.signal))B(e,"signal",t,S(o),r);for(const t of["handler","server","partial","route","component","asyncSignal"])for(const[o,s]of Object.entries(n[t]))B(e,t,o,s,r)}(r,e,t),s),inspectRoots:()=>s.runtime?.inspectRoots()??{count:0,roots:[]},_attach:e=>(n.add(e),()=>s._detach(e)),_detach(e){n.delete(e)}};return e&&s.use(e),s}function q(t=C,r={}){const n=(q=t,Boolean(q&&"function"==typeof q.use&&"function"==typeof q.snapshot&&q.registry)?t:T(t??{})),o=r.target??"browser",s=r.scheduler??r.loader?.scheduler??b({strategy:"server"===o?"manual":"microtask"}),i=!r.scheduler&&!r.loader?.scheduler,c=R(r.attributes),u=r.lazyRegistry??j({registryAssets:r.registryAssets,importModule:r.importModule}),l=r.registry??n.registry.view({target:o}),f=r.signals??E(void 0,{registry:l,type:"signal",lazyRegistry:u}),p=r.handlers??h(void 0,{registry:l,type:"handler",lazyRegistry:u}),d=e(void 0,{registry:l,type:"cache.server"}),v=e(void 0,{registry:l,type:"cache.browser"}),S=r.serverFactory??W,$=r.server??S(void 0,{registry:l,type:"server"}),A=r.partials??g(void 0,{registry:l,type:"partial",lazyRegistry:u}),O=r.routes??m(void 0,{registry:l,type:"route"}),k=r.components??a(void 0,{registry:l,type:"component",lazyRegistry:u}),_=r.loader||Object.hasOwn(r,"root")?r.root:null;var q;let L=r.loader,B=r.router,N=!1,z=()=>{},U=!1,V=!1;const F=new Map,J=_??globalThis.document,K=r.snapshot??("browser"===o?M(J,{attributes:c}):void 0);!function(e,t){try{e.cache=t}catch{}}($,d);const Z={app:n,registry:l,target:o,signals:f,handlers:p,server:$,partials:A,routes:O,components:k,browser:{cache:v},loader:L,router:B,scheduler:s,attributes:c,start:()=>(ee(),U||(U=!0,"server"!==o?(Q({cache:v}),f._setContext?.({server:$,loader:L,cache:v,scheduler:s}),L?(Y(L.root,L),L.start(),G(L.root)):null!=_&&Z.attachRoot(_)):(Q({cache:d}),f._setContext?.({server:$,cache:d,scheduler:s}))),Z),use:(e,t)=>(n.use(e,t),Z),attachRoot(e){if(ee(),"server"===o)throw new Error("Server runtimes cannot attach DOM roots.");if(!e)throw new TypeError("runtime.attachRoot(root) requires a root.");if(F.has(e))return Z;const t=0===F.size&&L?L:y({root:e,signals:f,handlers:p,server:$,cache:v,scheduler:s,attributes:c});return Y(e,t),t.start(),Q({cache:v}),f._setContext?.({server:$,loader:Z.loader,cache:v,scheduler:s}),G(e),Z},detachRoot(e){if(ee(),"server"===o)return Z;if(null==e){for(const e of new Set(F.values()))e.destroy?.();return F.clear(),B?.destroy?.(),B=void 0,N=!1,L=void 0,Z.loader=void 0,Z.router=void 0,Z}const t=F.get(e);if(!t)return Z;if(t.destroy?.(),F.delete(e),L===t){B?.destroy?.(),B=void 0,N=!1;const e=F.values().next().value;L=e,Z.loader=e,Z.router=void 0,e&&G(e.root)}return Z},inspectRoots:()=>({count:F.size,roots:[...F].map(([e,t])=>({root:e,loader:t,primary:t===L}))}),applySnapshot:(e,t={})=>(function(e,t={},r={}){const n=P(t);for(const[t,r]of Object.entries(n.signal))H(e.signals,t,r);e.browser.cache.restore(n.cache.browser),D(e,"handler",n.handler,e.handlers,r),D(e,"server",n.server,e.server,r),D(e,"partial",n.partial,e.partials,r),D(e,"route",n.route,e.routes,r),D(e,"component",n.component,e.components,r),D(e,"asyncSignal",n.asyncSignal,null,r)}(Z,e,t),Z),async render(e){ee(),Q({cache:d}),f._setContext?.({server:$,cache:d,scheduler:s});const t=O.match(e);if(!t)return await s.flush(),{html:I("",{status:404,signals:f,browserCache:v,boundary:r.boundary??"route",attributes:c}),status:404,signals:f.snapshot(),cache:{browser:v.snapshot()}};const n=t.route.partial,o=n&&A.resolve(n)?await A.render(n,t.params,{params:t.params,route:t.route,signals:f,handlers:p,server:$,cache:d,browserCache:v,partials:A,scheduler:s,...X()}):{html:""};if(o.signals)for(const[e,t]of Object.entries(o.signals))H(f,e,t);o.cache?.browser&&v.restore(o.cache.browser),await s.flush();const a=o.status??200;return{html:I(o.html,{status:a,signals:f,browserCache:v,boundary:o.boundary??r.boundary??"route",attributes:c}),status:a,signals:f.snapshot(),cache:{browser:v.snapshot()}}},destroy(){if(V)return;V=!0,z(),B?.destroy?.();const e=new Set(F.values());for(const t of e)t.destroy?.();F.clear(),L&&!e.has(L)&&L?.destroy?.(),f.destroy?.(),i&&s.destroy()},_applyUse(e){!function(e,t){x(e.signals,e.registry,t.signal),x(e.handlers,e.registry,t.handler),x(e.server,e.registry,t.server),x(e.partials,e.registry,t.partial),x(e.routes,e.registry,t.route),x(e.components,e.registry,t.component),function(e,t,r){if(r&&0!==Object.keys(r).length)for(const[n,o]of Object.entries(r))e.has(t,n)||e.register(t,n,o)}(e.registry,"asyncSignal",t.asyncSignal),x(e.browser.cache,e.registry,t.cache.browser),x(e.server.cache,e.registry,t.cache.server)}(Z,e)}};return $.cache=d,Z.server.cache=d,Z.applySnapshot(K,{strict:r.strictSnapshots??!0}),z=n._attach(Z),Z;function Y(e,t){F.set(e,t),L||(L=t,Z.loader=t),t.server=$,t.cache=v,t.scheduler=s}function G(e){!1!==B&&!N&&(B||function(e,t){return Boolean(t.routerOptions||t.mode||e.entries().length>0)}(O,r))&&Z.loader&&(B=B??w({mode:r.mode??"ssr",root:e,boundary:r.boundary??"route",routes:O,loader:Z.loader,signals:f,handlers:p,server:$,cache:v,partials:A,scheduler:s,attributes:c}),Z.router=B,Z.loader.router=B,Q({cache:v,router:B}),B.start(),N=!0)}function Q(e={}){const t=function(e){return"function"==typeof e?.registerMany}($)?d:e.cache;$._setContext?.({signals:f,loader:L,router:B,cache:t,scheduler:s,requestContext:r.requestContext,...X()})}function X(){const e=(t=r.requestContext)?"function"==typeof t.get?t.get()??{}:"function"==typeof t.getStore?t.getStore()??{}:{}:{};var t;return{requestContext:e,request:e.request??r.request,headers:e.headers??r.headers,cookies:e.cookies??r.cookies,locals:e.locals??r.locals}}function ee(){if(V)throw new Error("Async app runtime has been destroyed.")}}const C=T();function M(e=globalThis.document,{attributes:t}={}){const r=R(t),n=A(r,"async","snapshot"),o=e?.ownerDocument??e??globalThis.document,s=e??o;if(!s?.querySelectorAll&&!o?.querySelectorAll)return{};const a={};for(const e of new Set([s,o]))if(e?.querySelectorAll)for(const t of e.querySelectorAll("script[type='application/json'], script")){if(!t.hasAttribute?.(n))continue;const e=t.textContent?.trim()??"";if(!e)continue;let r;try{r=JSON.parse(e)}catch(e){throw new Error(`Could not parse Async snapshot: ${e instanceof Error?e.message:String(e)}`)}N(a,r,{strict:!0})}return a}function x(e,t,r){r&&0!==Object.keys(r).length&&(e?.registry!==t?e?.registerMany?.(r):e._adoptMany?.(r))}function L(e,t,r){for(const[n,o]of Object.entries(r??{}))e.register(t,n,o)}function D(e,t,r,n,o={}){if(r&&0!==Object.keys(r).length){for(const[n,s]of Object.entries(r))B(e.registry,t,n,s,o);n?._adoptMany?.(r)}}function B(e,t,r,n,o={}){const s=o.strict??!0,a=e._map(t);if(a.has(r)){if(k(a.get(r),n)||z(a.get(r),n))return;if(s)throw new Error(`${t} "${r}" is already registered with a different value.`)}else e.set(t,r,n)}function P(e={}){return{signal:{...e.signals??{},...e.signal??{}},handler:{...e.handler??{}},server:{...e.server??{}},partial:{...e.partial??{}},route:{...e.route??{}},component:{...e.component??{}},asyncSignal:{...e.asyncSignal??{}},cache:{browser:{...e.entries?.browser??{},...e.cache?.browser??{}}}}}function N(e,t,r={}){const n=P(O(t));e.signal={...e.signal??e.signals??{},...n.signal},e.signals=e.signal,e.cache={...e.cache??{},browser:{...e.cache?.browser??{},...n.cache.browser}};for(const t of["handler","server","partial","route","component","asyncSignal"]){e[t]=e[t]??{};for(const[o,s]of Object.entries(n[t]))if(Object.hasOwn(e[t],o)){if(k(e[t][o],s)||z(e[t][o],s))continue;if(r.strict??1)throw new Error(`${t} "${o}" is already declared with a different value.`)}else e[t][o]=s}return e}function z(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function H(e,t,r){const n=String(t).split(".")[0];e.has?.(n)?e.set(t,r):(e.register(n,S(t===n?r:{})),t!==n&&e.set(t,r))}function W(e={},t={}){const r=t.registry??$(),n=t.type??"server",o={},s={registry:r,register:(e,t)=>(r.register(n,e,t),e),registerMany(e){for(const[t,r]of Object.entries(e??{}))s.register(t,r);return s},unregister:e=>r.unregister(n,e),resolve(){},async run(e){throw new Error(`Server command "${e}" cannot run without a server proxy or server registry.`)},keys:()=>r.keys(n),entries:()=>r.entries(n),inspect:()=>r.entries(n),_setContext:(e={})=>(Object.assign(o,e),s),_adoptMany:()=>s};return s.registerMany(e),v((e,t,r)=>s.run(e,t,r),s,()=>o)}function U(e,t={}){if("signal"!==e)return{...t??{}};const r={};for(const[e,n]of Object.entries(t??{}))r[e]=V(n);return r}function V(e){return e&&"object"==typeof e&&"function"==typeof e.subscribe?e:S(e)}function I(e,{signals:t,browserCache:r,boundary:n,attributes:o}){const s={signals:t.snapshot(),cache:{browser:r.snapshot()}},a=A(o,"async","boundary"),i=A(o,"async","snapshot");return`<section ${a}="${c=n,String(c).replaceAll("&","&").replaceAll('"',""").replaceAll("<","<")}">${e??""}</section><script type="application/json" ${i}>${function(e){return JSON.stringify(e).replaceAll("<","\\u003c")}(s)}<\/script>`;var c}return{defineApp:T,createApp:q,readSnapshot:M,Async:C}})(),y=(()=>{function e(e){if("string"!=typeof e||0===e.length)throw new TypeError("Boundary patch boundary must be a non-empty string.")}function t(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))}return{createBoundaryReceiver:function(r={}){const n=r.loader,o=r.signals??n?.signals,s=r.cache??n?.cache,a=r.scheduler??n?.scheduler,i=r.router??n?.router,c=r.recentLimit??50,u=!0===r.throwOnError,l="function"==typeof r.onApply?r.onApply:void 0,f="function"==typeof r.onIgnore?r.onIgnore:void 0,p="function"==typeof r.onError?r.onError:void 0,d="function"==typeof r.isScopeDestroyed?r.isScopeDestroyed:e=>a?.isScopeDestroyed?.(e)??a?.inspectDestroyed?.(e)??!1;if(!n||"function"!=typeof n.swap)throw new TypeError("createBoundaryReceiver(...) requires a loader with swap(boundary, html).");if(!Number.isInteger(c)||c<0)throw new TypeError("createBoundaryReceiver(...) recentLimit must be a non-negative integer.");const h=new Map,y=[];let g=!1;const m={async apply(r){if(g)throw new Error("Boundary receiver has been destroyed.");const c=function(r){if(!r||"object"!=typeof r||Array.isArray(r))throw new TypeError("receiver.apply(patch) requires a boundary patch object.");if(e(r.boundary),"number"!=typeof r.seq||!Number.isFinite(r.seq))throw new TypeError("Boundary patch seq must be a finite number.");if(void 0!==r.signals&&!t(r.signals))throw new TypeError("Boundary patch signals must be an object.");if(void 0!==r.cache&&!t(r.cache))throw new TypeError("Boundary patch cache must be an object.");if(void 0!==r.cache?.browser&&!t(r.cache.browser))throw new TypeError("Boundary patch cache.browser must be an object.");if(void 0!==r.redirect&&("string"!=typeof r.redirect||0===r.redirect.length))throw new TypeError("Boundary patch redirect must be a non-empty string.");if(void 0!==r.parentScope&&"string"!=typeof r.parentScope)throw new TypeError("Boundary patch parentScope must be a string.");if(void 0!==r.scope&&"string"!=typeof r.scope)throw new TypeError("Boundary patch scope must be a string.");const n=Object.hasOwn(r,"html")&&null!=r.html,o=r.signals&&Object.keys(r.signals).length>0,s=r.cache?.browser&&Object.keys(r.cache.browser).length>0,a=Boolean(r.redirect),i=Object.hasOwn(r,"error");if(!(n||o||s||a||i))throw new TypeError("Boundary patch must include html, signals, cache.browser, redirect, or error.");return r}(r),y=(m=c.boundary,h.has(m)||h.set(m,{lastSeq:-1/0,applied:0,ignored:0,errored:0,lastStatus:void 0}),h.get(m));var m,b;if(c.seq<=y.lastSeq){const e={status:"ignored-stale",boundary:c.boundary,seq:c.seq,lastSeq:y.lastSeq};return y.ignored+=1,y.lastStatus=e.status,w(e),f?.(e,r),e}if(void 0!==c.parentScope&&d(c.parentScope)){const e={status:"ignored-destroyed",boundary:c.boundary,seq:c.seq,parentScope:c.parentScope};return y.ignored+=1,y.lastStatus=e.status,w(e),f?.(e,r),e}if(y.lastSeq=c.seq,Object.hasOwn(c,"error")){const e=(b=c.error)instanceof Error?b:b&&"object"==typeof b&&"string"==typeof b.message?Object.assign(new Error(b.message),b):new Error(String(b)),t={status:"errored",boundary:c.boundary,seq:c.seq,error:e};if(y.errored+=1,y.lastStatus=t.status,w(t),p?.(e,t,r),u)throw e;return t}if(c.signals){if(!o||"function"!=typeof o.set)throw new Error("Boundary patch includes signals, but no signal registry is available.");for(const[e,t]of Object.entries(c.signals))o.set(e,t)}if(c.cache?.browser){if(!s||"function"!=typeof s.restore)throw new Error("Boundary patch includes browser cache, but no cache registry is available.");s.restore(c.cache.browser)}if(null!=c.html&&n.swap(c.boundary,c.html),await async function(e,t){e&&(void 0===t||"function"!=typeof e.flushScope?"function"==typeof e.flush&&await e.flush():await e.flushScope(t))}(a,c.scope),c.redirect){await async function(e,t,r){if(t&&"function"==typeof t.navigate)return void await t.navigate(e);const n=r?.root?.ownerDocument?.defaultView?.location??globalThis.location;n?.assign?.(e)}(c.redirect,i,n);const e={status:"redirected",boundary:c.boundary,seq:c.seq,redirect:c.redirect};return y.applied+=1,y.lastStatus=e.status,w(e),l?.(e,r),e}const v={status:"applied",boundary:c.boundary,seq:c.seq};return y.applied+=1,y.lastStatus=v.status,w(v),l?.(v,r),v},inspect(){const e={};for(const[t,r]of h)e[t]={lastSeq:r.lastSeq,applied:r.applied,ignored:r.ignored,lastStatus:r.lastStatus},r.errored>0&&(e[t].errored=r.errored);return{destroyed:g,boundaries:e,recent:y.map(e=>({...e}))}},reset(t){if(void 0===t)return h.clear(),y.length=0,m;e(t),h.delete(t);for(let e=y.length-1;e>=0;e-=1)y[e].boundary===t&&y.splice(e,1);return m},destroy(){g=!0,h.clear(),y.length=0}};return m;function w(e){if(0!==c)for(y.push(function(e){const t={boundary:e.boundary,seq:e.seq,status:e.status};return"ignored-stale"===e.status&&(t.lastSeq=e.lastSeq),"ignored-destroyed"===e.status&&void 0!==e.parentScope&&(t.parentScope=e.parentScope),"redirected"===e.status&&(t.redirect=e.redirect),t}(e));y.length>c;)y.shift()}}}})(),g=(()=>{function e(e){return e?.reason??new Error("Operation aborted")}return{delay:function(t,r){return r?.aborted?Promise.reject(e(r)):new Promise((n,o)=>{let s=setTimeout(function(){s=void 0,r?.removeEventListener?.("abort",a),n()},t);function a(){void 0!==s&&clearTimeout(s),s=void 0,r?.removeEventListener?.("abort",a),o(e(r))}r?.addEventListener?.("abort",a,{once:!0})})}}})(),m=(()=>{const{Async:e}=h;return{defineAsyncContainerElement:function(t={}){const r=t.tagName??"async-container",n=t.customElements??globalThis.customElements;if(!n)throw new Error("defineAsyncContainerElement(...) requires customElements.");const o=n.get(r);if(o)return o;const s=t.app??t.Async??e,a=t.HTMLElement??t.window?.HTMLElement??globalThis.HTMLElement;if(!a)throw new Error("defineAsyncContainerElement(...) requires HTMLElement.");class i extends a{connectedCallback(){if(this.__asyncAttached)return;const e=s.runtime??s.start?.();e?.attachRoot?.(this),this.__asyncRuntime=e,this.__asyncAttached=!0}disconnectedCallback(){this.__asyncAttached&&(this.__asyncRuntime?.detachRoot?.(this),this.__asyncRuntime=void 0,this.__asyncAttached=!1)}}return n.define(r,i),i},defineAsyncSuspenseElement:function(e={}){const t=e.tagName??"async-suspense",r=e.customElements??globalThis.customElements;if(!r)throw new Error("defineAsyncSuspenseElement(...) requires customElements.");const n=r.get(t);if(n)return n;const o=e.HTMLElement??e.window?.HTMLElement??globalThis.HTMLElement;if(!o)throw new Error("defineAsyncSuspenseElement(...) requires HTMLElement.");class s extends o{}return r.define(t,s),s}}})(),{asyncSignal:w}=e,{Async:b}=h,{createApp:v}=h,{defineApp:S}=h,{readSnapshot:E}=h,{attributeName:$}=o,{defineAttributeConfig:A}=o,{createBoundaryReceiver:R}=y,{createCacheRegistry:j}=n,{defineCache:O}=n,{component:k}=i,{createComponentRegistry:_}=i,{defineComponent:T}=i,{delay:q}=g,{defineAsyncContainerElement:C}=m,{defineAsyncSuspenseElement:M}=m,{createHandlerRegistry:x}=u,{html:L}=a,{createLazyRegistry:D}=t,{defineRegistrySnapshot:B}=t,{Loader:P}=f,{AsyncLoader:N}=f,{createPartialRegistry:z}=p,{createRegistryStore:H}=r,{createRouteRegistry:W}=d,{createRouter:U}=d,{defineRoute:V}=d,{route:I}=d,{createScheduler:F}=l,{applyServerResult:J}=c,{createServerProxy:K}=c,{resolveServerCommandArguments:Z}=c,{unwrapServerResult:Y}=c,{computed:G}=s,{createSignal:Q}=s,{createSignalRegistry:X}=s,{effect:ee}=s,{signal:te}=s,re={asyncSignal:w,Async:b,createApp:v,defineApp:S,readSnapshot:E,attributeName:$,defineAttributeConfig:A,createBoundaryReceiver:R,createCacheRegistry:j,defineCache:O,component:k,createComponentRegistry:_,defineComponent:T,delay:q,defineAsyncContainerElement:C,defineAsyncSuspenseElement:M,createHandlerRegistry:x,html:L,createLazyRegistry:D,defineRegistrySnapshot:B,Loader:P,AsyncLoader:N,createPartialRegistry:z,createRegistryStore:H,createRouteRegistry:W,createRouter:U,defineRoute:V,route:I,createScheduler:F,applyServerResult:J,createServerProxy:K,resolveServerCommandArguments:Z,unwrapServerResult:Y,computed:G,createSignal:Q,createSignalRegistry:X,effect:ee,signal:te};return function(e,t){const r=Object.keys(e).filter(e=>"Async"!==e&&Object.prototype.hasOwnProperty.call(t,e));if(r.length>0)throw new Error(`UMD Async namespace export conflict: ${r.join(", ")}.`)}(re,b),Object.assign(b,re),b.Async=b,b}();"function"==typeof define&&define.amd?define([],()=>t):"object"==typeof module&&module.exports?module.exports=t:(e.AsyncFramework=t,e.Async=t)}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Server-capable type declarations for @async/framework.
|
|
3
3
|
|
|
4
4
|
export type RuntimeTarget = "browser" | "server";
|
|
5
|
-
export type RouterMode = "csr" | "spa" | "ssr" | "
|
|
5
|
+
export type RouterMode = "csr" | "spa" | "ssr" | "mpa";
|
|
6
6
|
export type AsyncSignalStatus = "idle" | "loading" | "ready" | "error";
|
|
7
7
|
export type MaybePromise<T> = T | Promise<T>;
|
|
8
8
|
export type Cleanup = () => void;
|
|
@@ -261,6 +261,7 @@ export interface ServerContext {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
export type ServerFunction<T = unknown> = (this: ServerContext, ...args: unknown[]) => MaybePromise<ServerResult<T>>;
|
|
264
|
+
export type ServerProxyTransport = (url: string, init: RequestInit) => MaybePromise<Response>;
|
|
264
265
|
|
|
265
266
|
export interface ServerNamespace {
|
|
266
267
|
run<T = unknown>(id: string, args?: unknown[], context?: Partial<ServerContext>): Promise<T>;
|
|
@@ -275,7 +276,7 @@ export interface ServerNamespace {
|
|
|
275
276
|
|
|
276
277
|
export interface ServerProxyOptions {
|
|
277
278
|
endpoint?: string;
|
|
278
|
-
|
|
279
|
+
transport: ServerProxyTransport;
|
|
279
280
|
signals?: SignalRegistry;
|
|
280
281
|
loader?: LoaderInstance;
|
|
281
282
|
router?: Router;
|
|
@@ -378,8 +379,6 @@ export interface RouterOptions {
|
|
|
378
379
|
server?: ServerNamespace;
|
|
379
380
|
cache?: CacheRegistry;
|
|
380
381
|
partials?: PartialRegistry;
|
|
381
|
-
fetch?: typeof fetch;
|
|
382
|
-
routeEndpoint?: string;
|
|
383
382
|
attributes?: AttributeConfig;
|
|
384
383
|
scheduler?: Scheduler;
|
|
385
384
|
}
|
|
@@ -607,8 +606,6 @@ export interface CreateAppOptions extends LoaderOptions {
|
|
|
607
606
|
routes?: RouteRegistry;
|
|
608
607
|
partials?: PartialRegistry;
|
|
609
608
|
components?: ComponentRegistry;
|
|
610
|
-
fetch?: typeof fetch;
|
|
611
|
-
routeEndpoint?: string;
|
|
612
609
|
request?: Request;
|
|
613
610
|
locals?: unknown;
|
|
614
611
|
requestContext?: RequestContextStore;
|
|
@@ -724,7 +721,7 @@ export declare function createScheduler(options?: SchedulerOptions): Scheduler;
|
|
|
724
721
|
export declare function defineRoute(partial: string, options?: Omit<RouteDefinition, "partial">): RouteDefinition;
|
|
725
722
|
export declare const route: typeof defineRoute;
|
|
726
723
|
export declare function applyServerResult(result: unknown, context?: Record<string, unknown>): Promise<unknown>;
|
|
727
|
-
export declare function createServerProxy(options
|
|
724
|
+
export declare function createServerProxy(options: ServerProxyOptions): ServerNamespace;
|
|
728
725
|
export declare function createServerRegistry(initialMap?: Record<string, ServerFunction>, options?: { registry?: RegistryStore; type?: "server" }): ServerNamespace;
|
|
729
726
|
export declare function createRequestContextStore(): RequestContextStore;
|
|
730
727
|
export declare function resolveServerCommandArguments(args: Array<{ type: "local"; name: string } | { type: "signal"; path: string }>, context?: Record<string, unknown>): { args: unknown[]; signalValues: Record<string, unknown>; signalPaths: string[] };
|