wherever-dev 0.2.0 → 0.4.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.
Files changed (70) hide show
  1. package/dist/index.js +217 -17
  2. package/dist/index.js.map +1 -1
  3. package/dist/protocol.d.ts +21 -1
  4. package/dist/protocol.d.ts.map +1 -1
  5. package/dist/protocol.js +5 -1
  6. package/dist/protocol.js.map +1 -1
  7. package/dist/session-pool.d.ts +92 -2
  8. package/dist/session-pool.d.ts.map +1 -1
  9. package/dist/session-pool.js +466 -14
  10. package/dist/session-pool.js.map +1 -1
  11. package/dist/session-types.d.ts +17 -0
  12. package/dist/session-types.d.ts.map +1 -1
  13. package/package.json +1 -1
  14. package/public/_app/immutable/assets/0.CgLKPJWX.css +1 -0
  15. package/public/_app/immutable/chunks/CEg8tgYI.js +2 -0
  16. package/public/_app/immutable/chunks/CEg8tgYI.js.map +1 -0
  17. package/public/_app/immutable/chunks/CTVuBuYH.js +2 -0
  18. package/public/_app/immutable/chunks/{B5WJGjcR.js.map → CTVuBuYH.js.map} +1 -1
  19. package/public/_app/immutable/chunks/DBDAFnY6.js +2 -0
  20. package/public/_app/immutable/chunks/{BqMutrfe.js.map → DBDAFnY6.js.map} +1 -1
  21. package/public/_app/immutable/chunks/MtE7VtNZ.js +2 -0
  22. package/public/_app/immutable/chunks/{DiYtJzYU.js.map → MtE7VtNZ.js.map} +1 -1
  23. package/public/_app/immutable/chunks/S778j9fy.js +2 -0
  24. package/public/_app/immutable/chunks/{_lppinj8.js.map → S778j9fy.js.map} +1 -1
  25. package/public/_app/immutable/chunks/vMsF8lo6.js +3 -0
  26. package/public/_app/immutable/chunks/{DFxBx2vA.js.map → vMsF8lo6.js.map} +1 -1
  27. package/public/_app/immutable/chunks/ylfInSZr.js +2 -0
  28. package/public/_app/immutable/chunks/{BEWoN05F.js.map → ylfInSZr.js.map} +1 -1
  29. package/public/_app/immutable/entry/app.CklFlIiC.js +3 -0
  30. package/public/_app/immutable/entry/app.CklFlIiC.js.map +1 -0
  31. package/public/_app/immutable/entry/start.sF1k4jCY.js +2 -0
  32. package/public/_app/immutable/entry/start.sF1k4jCY.js.map +1 -0
  33. package/public/_app/immutable/nodes/0.BEHRw2jv.js +4 -0
  34. package/public/_app/immutable/nodes/{0.BzvDOlXz.js.map → 0.BEHRw2jv.js.map} +1 -1
  35. package/public/_app/immutable/nodes/1.2gk2c-6t.js +2 -0
  36. package/public/_app/immutable/nodes/{1.DMtW3tA5.js.map → 1.2gk2c-6t.js.map} +1 -1
  37. package/public/_app/immutable/nodes/2.Dto-NrSs.js +82 -0
  38. package/public/_app/immutable/nodes/2.Dto-NrSs.js.map +1 -0
  39. package/public/_app/version.json +1 -1
  40. package/public/index.html +16 -16
  41. package/public/pwa/apple-touch-icon.png +0 -0
  42. package/public/pwa/favicon-192.png +0 -0
  43. package/public/pwa/favicon-512.png +0 -0
  44. package/public/pwa/favicon.ico +0 -0
  45. package/public/pwa/favicon.svg +1 -0
  46. package/public/pwa/manifest.webmanifest +31 -7
  47. package/public/pwa/maskable-192.png +0 -0
  48. package/public/pwa/maskable-512.png +0 -0
  49. package/public/pwa/screenshot-desktop.png +0 -0
  50. package/public/pwa/screenshot-mobile.png +0 -0
  51. package/public/robots.txt +5 -0
  52. package/public/service-worker.js +1 -305
  53. package/public/_app/immutable/assets/0.DvZxoQjW.css +0 -2754
  54. package/public/_app/immutable/chunks/B5WJGjcR.js +0 -23
  55. package/public/_app/immutable/chunks/BEWoN05F.js +0 -110
  56. package/public/_app/immutable/chunks/BqMutrfe.js +0 -2129
  57. package/public/_app/immutable/chunks/DFxBx2vA.js +0 -897
  58. package/public/_app/immutable/chunks/DiYtJzYU.js +0 -396
  59. package/public/_app/immutable/chunks/_lppinj8.js +0 -879
  60. package/public/_app/immutable/chunks/rMw82gDs.js +0 -3048
  61. package/public/_app/immutable/chunks/rMw82gDs.js.map +0 -1
  62. package/public/_app/immutable/entry/app.BFki2czn.js +0 -309
  63. package/public/_app/immutable/entry/app.BFki2czn.js.map +0 -1
  64. package/public/_app/immutable/entry/start.BceUuq27.js +0 -6
  65. package/public/_app/immutable/entry/start.BceUuq27.js.map +0 -1
  66. package/public/_app/immutable/nodes/0.BzvDOlXz.js +0 -546
  67. package/public/_app/immutable/nodes/1.DMtW3tA5.js +0 -24
  68. package/public/_app/immutable/nodes/2.CnZp8abw.js +0 -5152
  69. package/public/_app/immutable/nodes/2.CnZp8abw.js.map +0 -1
  70. package/public/icon.png +0 -0
@@ -1,2129 +0,0 @@
1
- import { bi as writable, aI as onMount, b6 as state, ag as get$1, aX as set$1, bc as tick, b1 as settled, bd as untrack$1 } from "./rMw82gDs.js";
2
- class HttpError {
3
- /**
4
- * @param {number} status
5
- * @param {{message: string} extends App.Error ? (App.Error | string | undefined) : App.Error} body
6
- */
7
- constructor(status, body) {
8
- this.status = status;
9
- if (typeof body === "string") {
10
- this.body = { message: body };
11
- } else if (body) {
12
- this.body = body;
13
- } else {
14
- this.body = { message: `Error: ${status}` };
15
- }
16
- }
17
- toString() {
18
- return JSON.stringify(this.body);
19
- }
20
- }
21
- class Redirect {
22
- /**
23
- * @param {300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308} status
24
- * @param {string} location
25
- */
26
- constructor(status, location2) {
27
- try {
28
- new Headers({ location: location2 });
29
- } catch {
30
- throw new Error(
31
- `Invalid redirect location ${JSON.stringify(location2)}: this string contains characters that cannot be used in HTTP headers`
32
- );
33
- }
34
- this.status = status;
35
- this.location = location2;
36
- }
37
- }
38
- class SvelteKitError extends Error {
39
- /**
40
- * @param {number} status
41
- * @param {string} text
42
- * @param {string} message
43
- */
44
- constructor(status, text, message) {
45
- super(message);
46
- this.status = status;
47
- this.text = text;
48
- }
49
- }
50
- new URL("sveltekit-internal://");
51
- function normalize_path(path, trailing_slash) {
52
- if (path === "/" || trailing_slash === "ignore") return path;
53
- if (trailing_slash === "never") {
54
- return path.endsWith("/") ? path.slice(0, -1) : path;
55
- } else if (trailing_slash === "always" && !path.endsWith("/")) {
56
- return path + "/";
57
- }
58
- return path;
59
- }
60
- function decode_pathname(pathname) {
61
- return pathname.split("%25").map(decodeURI).join("%25");
62
- }
63
- function decode_params(params) {
64
- for (const key in params) {
65
- params[key] = decodeURIComponent(params[key]);
66
- }
67
- return params;
68
- }
69
- function strip_hash({ href }) {
70
- return href.split("#")[0];
71
- }
72
- function noop() {
73
- }
74
- function hash(...values) {
75
- let hash2 = 5381;
76
- for (const value of values) {
77
- if (typeof value === "string") {
78
- let i = value.length;
79
- while (i) hash2 = hash2 * 33 ^ value.charCodeAt(--i);
80
- } else if (ArrayBuffer.isView(value)) {
81
- const buffer = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
82
- let i = buffer.length;
83
- while (i) hash2 = hash2 * 33 ^ buffer[--i];
84
- } else {
85
- throw new TypeError("value must be a string or TypedArray");
86
- }
87
- }
88
- return (hash2 >>> 0).toString(36);
89
- }
90
- new TextEncoder();
91
- function base64_decode(encoded) {
92
- const binary = atob(encoded);
93
- const bytes = new Uint8Array(binary.length);
94
- for (let i = 0; i < binary.length; i++) {
95
- bytes[i] = binary.charCodeAt(i);
96
- }
97
- return bytes;
98
- }
99
- const native_fetch = window.fetch;
100
- {
101
- window.fetch = (input, init) => {
102
- const method = input instanceof Request ? input.method : init?.method || "GET";
103
- if (method !== "GET") {
104
- cache.delete(build_selector(input));
105
- }
106
- return native_fetch(input, init);
107
- };
108
- }
109
- const cache = /* @__PURE__ */ new Map();
110
- function initial_fetch(resource, opts) {
111
- const selector = build_selector(resource, opts);
112
- const script = document.querySelector(selector);
113
- if (script?.textContent) {
114
- script.remove();
115
- let { body, ...init } = JSON.parse(script.textContent);
116
- const ttl = script.getAttribute("data-ttl");
117
- if (ttl) cache.set(selector, { body, init, ttl: 1e3 * Number(ttl) });
118
- const b64 = script.getAttribute("data-b64");
119
- if (b64 !== null) {
120
- body = base64_decode(body);
121
- }
122
- return Promise.resolve(new Response(body, init));
123
- }
124
- return window.fetch(resource, opts);
125
- }
126
- function subsequent_fetch(resource, resolved, opts) {
127
- if (cache.size > 0) {
128
- const selector = build_selector(resource, opts);
129
- const cached = cache.get(selector);
130
- if (cached) {
131
- if (performance.now() < cached.ttl && ["default", "force-cache", "only-if-cached", void 0].includes(opts?.cache)) {
132
- return new Response(cached.body, cached.init);
133
- }
134
- cache.delete(selector);
135
- }
136
- }
137
- return window.fetch(resolved, opts);
138
- }
139
- function build_selector(resource, opts) {
140
- const url = JSON.stringify(resource instanceof Request ? resource.url : resource);
141
- let selector = `script[data-sveltekit-fetched][data-url=${url}]`;
142
- if (opts?.headers || opts?.body) {
143
- const values = [];
144
- if (opts.headers) {
145
- values.push([...new Headers(opts.headers)].join(","));
146
- }
147
- if (opts.body && (typeof opts.body === "string" || ArrayBuffer.isView(opts.body))) {
148
- values.push(opts.body);
149
- }
150
- selector += `[data-hash="${hash(...values)}"]`;
151
- }
152
- return selector;
153
- }
154
- const param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
155
- function parse_route_id(id) {
156
- const params = [];
157
- const pattern = id === "/" ? /^\/$/ : new RegExp(
158
- `^${get_route_segments(id).map((segment) => {
159
- const rest_match = /^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(segment);
160
- if (rest_match) {
161
- params.push({
162
- name: rest_match[1],
163
- matcher: rest_match[2],
164
- optional: false,
165
- rest: true,
166
- chained: true
167
- });
168
- return "(?:/([^]*))?";
169
- }
170
- const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
171
- if (optional_match) {
172
- params.push({
173
- name: optional_match[1],
174
- matcher: optional_match[2],
175
- optional: true,
176
- rest: false,
177
- chained: true
178
- });
179
- return "(?:/([^/]+))?";
180
- }
181
- if (!segment) {
182
- return;
183
- }
184
- const parts = segment.split(/\[(.+?)\](?!\])/);
185
- const result = parts.map((content, i) => {
186
- if (i % 2) {
187
- if (content.startsWith("x+")) {
188
- return escape(String.fromCharCode(parseInt(content.slice(2), 16)));
189
- }
190
- if (content.startsWith("u+")) {
191
- return escape(
192
- String.fromCharCode(
193
- ...content.slice(2).split("-").map((code) => parseInt(code, 16))
194
- )
195
- );
196
- }
197
- const match = (
198
- /** @type {RegExpExecArray} */
199
- param_pattern.exec(content)
200
- );
201
- const [, is_optional, is_rest, name, matcher] = match;
202
- params.push({
203
- name,
204
- matcher,
205
- optional: !!is_optional,
206
- rest: !!is_rest,
207
- chained: is_rest ? i === 1 && parts[0] === "" : false
208
- });
209
- return is_rest ? "([^]*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
210
- }
211
- return escape(content);
212
- }).join("");
213
- return "/" + result;
214
- }).join("")}/?$`
215
- );
216
- return { pattern, params };
217
- }
218
- function affects_path(segment) {
219
- return segment !== "" && !/^\([^)]+\)$/.test(segment);
220
- }
221
- function get_route_segments(route) {
222
- return route.slice(1).split("/").filter(affects_path);
223
- }
224
- function exec(match, params, matchers) {
225
- const result = {};
226
- const values = match.slice(1);
227
- const values_needing_match = values.filter((value) => value !== void 0);
228
- let buffered = 0;
229
- for (let i = 0; i < params.length; i += 1) {
230
- const param = params[i];
231
- let value = values[i - buffered];
232
- if (param.chained && param.rest && buffered) {
233
- value = values.slice(i - buffered, i + 1).filter((s) => s).join("/");
234
- buffered = 0;
235
- }
236
- if (value === void 0) {
237
- if (param.rest) {
238
- value = "";
239
- } else {
240
- continue;
241
- }
242
- }
243
- if (!param.matcher || matchers[param.matcher](value)) {
244
- result[param.name] = value;
245
- const next_param = params[i + 1];
246
- const next_value = values[i + 1];
247
- if (next_param && !next_param.rest && next_param.optional && next_value && param.chained) {
248
- buffered = 0;
249
- }
250
- if (!next_param && !next_value && Object.keys(result).length === values_needing_match.length) {
251
- buffered = 0;
252
- }
253
- continue;
254
- }
255
- if (param.optional && param.chained) {
256
- buffered++;
257
- continue;
258
- }
259
- return;
260
- }
261
- if (buffered) return;
262
- return result;
263
- }
264
- function escape(str) {
265
- return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
266
- }
267
- const basic_param_pattern = /\[(\[)?(\.\.\.)?(\w+?)(?:=(\w+))?\]\]?/g;
268
- function resolve_route(id, params) {
269
- const segments = get_route_segments(id);
270
- const has_id_trailing_slash = id != "/" && id.endsWith("/");
271
- return "/" + segments.map(
272
- (segment) => segment.replace(basic_param_pattern, (_, optional, rest, name) => {
273
- const param_value = params[name];
274
- if (!param_value) {
275
- if (optional) return "";
276
- if (rest && param_value !== void 0) return "";
277
- throw new Error(`Missing parameter '${name}' in route ${id}`);
278
- }
279
- if (param_value.startsWith("/") || param_value.endsWith("/"))
280
- throw new Error(
281
- `Parameter '${name}' in route ${id} cannot start or end with a slash -- this would cause an invalid route like foo//bar`
282
- );
283
- return param_value;
284
- })
285
- ).filter(Boolean).join("/") + (has_id_trailing_slash ? "/" : "");
286
- }
287
- function parse({ nodes, server_loads, dictionary, matchers }) {
288
- const layouts_with_server_load = new Set(server_loads);
289
- return Object.entries(dictionary).map(([id, [leaf, layouts, errors]]) => {
290
- const { pattern, params } = parse_route_id(id);
291
- const route = {
292
- id,
293
- /** @param {string} path */
294
- exec: (path) => {
295
- const match = pattern.exec(path);
296
- if (match) return exec(match, params, matchers);
297
- },
298
- errors: [1, ...errors || []].map((n) => nodes[n]),
299
- layouts: [0, ...layouts || []].map(create_layout_loader),
300
- leaf: create_leaf_loader(leaf)
301
- };
302
- route.errors.length = route.layouts.length = Math.max(
303
- route.errors.length,
304
- route.layouts.length
305
- );
306
- return route;
307
- });
308
- function create_leaf_loader(id) {
309
- const uses_server_data = id < 0;
310
- if (uses_server_data) id = ~id;
311
- return [uses_server_data, nodes[id]];
312
- }
313
- function create_layout_loader(id) {
314
- return id === void 0 ? id : [layouts_with_server_load.has(id), nodes[id]];
315
- }
316
- }
317
- // @__NO_SIDE_EFFECTS__
318
- function get(key, parse2 = JSON.parse) {
319
- try {
320
- return parse2(sessionStorage[key]);
321
- } catch {
322
- }
323
- }
324
- function set(key, value, stringify = JSON.stringify) {
325
- const data = stringify(value);
326
- try {
327
- sessionStorage[key] = data;
328
- } catch {
329
- }
330
- }
331
- const base = globalThis.__sveltekit_pphq34?.base ?? "";
332
- const assets = globalThis.__sveltekit_pphq34?.assets ?? base ?? "";
333
- const version = "5214502";
334
- const SNAPSHOT_KEY = "sveltekit:snapshot";
335
- const SCROLL_KEY = "sveltekit:scroll";
336
- const STATES_KEY = "sveltekit:states";
337
- const PAGE_URL_KEY = "sveltekit:pageurl";
338
- const HISTORY_INDEX = "sveltekit:history";
339
- const NAVIGATION_INDEX = "sveltekit:navigation";
340
- const PRELOAD_PRIORITIES = (
341
- /** @type {const} */
342
- {
343
- tap: 1,
344
- hover: 2,
345
- viewport: 3,
346
- eager: 4,
347
- off: -1,
348
- false: -1
349
- }
350
- );
351
- const origin = location.origin;
352
- function resolve_url(url) {
353
- if (url instanceof URL) return url;
354
- let baseURI = document.baseURI;
355
- if (!baseURI) {
356
- const baseTags = document.getElementsByTagName("base");
357
- baseURI = baseTags.length ? baseTags[0].href : document.URL;
358
- }
359
- return new URL(url, baseURI);
360
- }
361
- function scroll_state() {
362
- return {
363
- x: pageXOffset,
364
- y: pageYOffset
365
- };
366
- }
367
- function link_option(element, name) {
368
- const value = (
369
- /** @type {ValidLinkOptions<T> | null} */
370
- element.getAttribute(`data-sveltekit-${name}`)
371
- );
372
- return value;
373
- }
374
- const levels = {
375
- ...PRELOAD_PRIORITIES,
376
- "": PRELOAD_PRIORITIES.hover
377
- };
378
- function parent_element(element) {
379
- let parent = element.assignedSlot ?? element.parentNode;
380
- if (parent?.nodeType === 11) parent = parent.host;
381
- return (
382
- /** @type {Element} */
383
- parent
384
- );
385
- }
386
- function find_anchor(element, target2) {
387
- while (element && element !== target2) {
388
- if (element.nodeName.toUpperCase() === "A" && element.hasAttribute("href")) {
389
- return (
390
- /** @type {HTMLAnchorElement | SVGAElement} */
391
- element
392
- );
393
- }
394
- element = /** @type {Element} */
395
- parent_element(element);
396
- }
397
- }
398
- function get_link_info(a, base2, uses_hash_router) {
399
- let url;
400
- try {
401
- url = new URL(a instanceof SVGAElement ? a.href.baseVal : a.href, document.baseURI);
402
- if (uses_hash_router && url.hash.match(/^#[^/]/)) {
403
- const route = location.hash.split("#")[1] || "/";
404
- url.hash = `#${route}${url.hash}`;
405
- }
406
- } catch {
407
- }
408
- const target2 = a instanceof SVGAElement ? a.target.baseVal : a.target;
409
- const external = !url || !!target2 || is_external_url(url, base2, uses_hash_router) || (a.getAttribute("rel") || "").split(/\s+/).includes("external");
410
- const download = url?.origin === origin && a.hasAttribute("download");
411
- return { url, external, target: target2, download };
412
- }
413
- function get_router_options(element) {
414
- let keepfocus = null;
415
- let noscroll = null;
416
- let preload_code = null;
417
- let preload_data = null;
418
- let reload = null;
419
- let replace_state = null;
420
- let el = element;
421
- while (el && el !== document.documentElement) {
422
- if (preload_code === null) preload_code = link_option(el, "preload-code");
423
- if (preload_data === null) preload_data = link_option(el, "preload-data");
424
- if (keepfocus === null) keepfocus = link_option(el, "keepfocus");
425
- if (noscroll === null) noscroll = link_option(el, "noscroll");
426
- if (reload === null) reload = link_option(el, "reload");
427
- if (replace_state === null) replace_state = link_option(el, "replacestate");
428
- el = /** @type {Element} */
429
- parent_element(el);
430
- }
431
- function get_option_state(value) {
432
- switch (value) {
433
- case "":
434
- case "true":
435
- return true;
436
- case "off":
437
- case "false":
438
- return false;
439
- default:
440
- return void 0;
441
- }
442
- }
443
- return {
444
- preload_code: levels[preload_code ?? "off"],
445
- preload_data: levels[preload_data ?? "off"],
446
- keepfocus: get_option_state(keepfocus),
447
- noscroll: get_option_state(noscroll),
448
- reload: get_option_state(reload),
449
- replace_state: get_option_state(replace_state)
450
- };
451
- }
452
- function notifiable_store(value) {
453
- const store = writable(value);
454
- let ready = true;
455
- function notify() {
456
- ready = true;
457
- store.update((val) => val);
458
- }
459
- function set2(new_value) {
460
- ready = false;
461
- store.set(new_value);
462
- }
463
- function subscribe(run) {
464
- let old_value;
465
- return store.subscribe((new_value) => {
466
- if (old_value === void 0 || ready && new_value !== old_value) {
467
- run(old_value = new_value);
468
- }
469
- });
470
- }
471
- return { notify, set: set2, subscribe };
472
- }
473
- const updated_listener = {
474
- v: noop
475
- };
476
- function create_updated_store() {
477
- const { set: set2, subscribe } = writable(false);
478
- let timeout;
479
- async function check() {
480
- clearTimeout(timeout);
481
- try {
482
- const res = await fetch(`${assets}/${"_app/version.json"}`, {
483
- headers: {
484
- pragma: "no-cache",
485
- "cache-control": "no-cache"
486
- }
487
- });
488
- if (!res.ok) {
489
- return false;
490
- }
491
- const data = await res.json();
492
- const updated2 = data.version !== version;
493
- if (updated2) {
494
- set2(true);
495
- updated_listener.v();
496
- clearTimeout(timeout);
497
- }
498
- return updated2;
499
- } catch {
500
- return false;
501
- }
502
- }
503
- return {
504
- subscribe,
505
- check
506
- };
507
- }
508
- function is_external_url(url, base2, hash_routing) {
509
- if (url.origin !== origin || !url.pathname.startsWith(base2)) {
510
- return true;
511
- }
512
- if (hash_routing) {
513
- return url.pathname !== location.pathname;
514
- }
515
- return false;
516
- }
517
- function load_css(deps) {
518
- return;
519
- }
520
- const valid_layout_exports = /* @__PURE__ */ new Set([
521
- "load",
522
- "prerender",
523
- "csr",
524
- "ssr",
525
- "trailingSlash",
526
- "config"
527
- ]);
528
- /* @__PURE__ */ new Set([...valid_layout_exports, "entries"]);
529
- const valid_layout_server_exports = /* @__PURE__ */ new Set([...valid_layout_exports]);
530
- /* @__PURE__ */ new Set([...valid_layout_server_exports, "actions", "entries"]);
531
- function compact(arr) {
532
- return arr.filter(
533
- /** @returns {val is NonNullable<T>} */
534
- (val) => val != null
535
- );
536
- }
537
- function create_remote_key(id, payload) {
538
- return id + "/" + payload;
539
- }
540
- function get_status(error) {
541
- return error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
542
- }
543
- function get_message(error) {
544
- return error instanceof SvelteKitError ? error.text : "Internal Error";
545
- }
546
- let page;
547
- let navigating;
548
- let updated;
549
- const is_legacy = onMount.toString().includes("$$") || /function \w+\(\) \{\}/.test(onMount.toString());
550
- const placeholder_url = "a:";
551
- if (is_legacy) {
552
- page = {
553
- data: {},
554
- form: null,
555
- error: null,
556
- params: {},
557
- route: { id: null },
558
- state: {},
559
- status: -1,
560
- url: new URL(placeholder_url)
561
- };
562
- navigating = { current: null };
563
- updated = { current: false };
564
- } else {
565
- page = new class Page {
566
- #data = state({});
567
- get data() {
568
- return get$1(this.#data);
569
- }
570
- set data(value) {
571
- set$1(this.#data, value);
572
- }
573
- #form = state(null);
574
- get form() {
575
- return get$1(this.#form);
576
- }
577
- set form(value) {
578
- set$1(this.#form, value);
579
- }
580
- #error = state(null);
581
- get error() {
582
- return get$1(this.#error);
583
- }
584
- set error(value) {
585
- set$1(this.#error, value);
586
- }
587
- #params = state({});
588
- get params() {
589
- return get$1(this.#params);
590
- }
591
- set params(value) {
592
- set$1(this.#params, value);
593
- }
594
- #route = state({ id: null });
595
- get route() {
596
- return get$1(this.#route);
597
- }
598
- set route(value) {
599
- set$1(this.#route, value);
600
- }
601
- #state = state({});
602
- get state() {
603
- return get$1(this.#state);
604
- }
605
- set state(value) {
606
- set$1(this.#state, value);
607
- }
608
- #status = state(-1);
609
- get status() {
610
- return get$1(this.#status);
611
- }
612
- set status(value) {
613
- set$1(this.#status, value);
614
- }
615
- #url = state(new URL(placeholder_url));
616
- get url() {
617
- return get$1(this.#url);
618
- }
619
- set url(value) {
620
- set$1(this.#url, value);
621
- }
622
- }();
623
- navigating = new class Navigating {
624
- #current = state(null);
625
- get current() {
626
- return get$1(this.#current);
627
- }
628
- set current(value) {
629
- set$1(this.#current, value);
630
- }
631
- }();
632
- updated = new class Updated {
633
- #current = state(false);
634
- get current() {
635
- return get$1(this.#current);
636
- }
637
- set current(value) {
638
- set$1(this.#current, value);
639
- }
640
- }();
641
- updated_listener.v = () => updated.current = true;
642
- }
643
- function update(new_page) {
644
- Object.assign(page, new_page);
645
- }
646
- const untrack = untrack$1 ?? ((value) => value());
647
- const ICON_REL_ATTRIBUTES = /* @__PURE__ */ new Set(["icon", "shortcut icon", "apple-touch-icon"]);
648
- let rendering_error = null;
649
- const scroll_positions = /* @__PURE__ */ get(SCROLL_KEY) ?? {};
650
- const snapshots = /* @__PURE__ */ get(SNAPSHOT_KEY) ?? {};
651
- const stores = {
652
- url: /* @__PURE__ */ notifiable_store({}),
653
- page: /* @__PURE__ */ notifiable_store({}),
654
- navigating: /* @__PURE__ */ writable(
655
- /** @type {import('@sveltejs/kit').Navigation | null} */
656
- null
657
- ),
658
- updated: /* @__PURE__ */ create_updated_store()
659
- };
660
- function update_scroll_positions(index) {
661
- scroll_positions[index] = scroll_state();
662
- }
663
- function clear_onward_history(current_history_index2, current_navigation_index2) {
664
- let i = current_history_index2 + 1;
665
- while (scroll_positions[i]) {
666
- delete scroll_positions[i];
667
- i += 1;
668
- }
669
- i = current_navigation_index2 + 1;
670
- while (snapshots[i]) {
671
- delete snapshots[i];
672
- i += 1;
673
- }
674
- }
675
- function native_navigation(url, replace = false) {
676
- if (replace) {
677
- location.replace(url.href);
678
- } else {
679
- location.href = url.href;
680
- }
681
- return new Promise(noop);
682
- }
683
- async function update_service_worker() {
684
- if ("serviceWorker" in navigator) {
685
- const registration = await navigator.serviceWorker.getRegistration(base || "/");
686
- if (registration) {
687
- await registration.update();
688
- }
689
- }
690
- }
691
- let routes;
692
- let default_layout_loader;
693
- let default_error_loader;
694
- let container;
695
- let target;
696
- let app;
697
- const invalidated = [];
698
- const components = [];
699
- let load_cache = null;
700
- function discard_load_cache() {
701
- void load_cache?.fork?.then((f) => f?.discard());
702
- load_cache = null;
703
- }
704
- const reroute_cache = /* @__PURE__ */ new Map();
705
- const before_navigate_callbacks = /* @__PURE__ */ new Set();
706
- const on_navigate_callbacks = /* @__PURE__ */ new Set();
707
- const after_navigate_callbacks = /* @__PURE__ */ new Set();
708
- let current = {
709
- branch: [],
710
- error: null,
711
- // @ts-ignore - we need the initial value to be null
712
- url: null
713
- };
714
- let hydrated = false;
715
- let started = false;
716
- let autoscroll = true;
717
- let is_navigating = false;
718
- let hash_navigating = false;
719
- let has_navigated = false;
720
- let force_invalidation = false;
721
- let root;
722
- let current_history_index;
723
- let current_navigation_index;
724
- let token;
725
- const preload_tokens = /* @__PURE__ */ new Set();
726
- const query_map = /* @__PURE__ */ new Map();
727
- const live_query_map = /* @__PURE__ */ new Map();
728
- async function start(_app, _target, hydrate) {
729
- if (globalThis.__sveltekit_pphq34) {
730
- globalThis.__sveltekit_pphq34.query ?? {};
731
- globalThis.__sveltekit_pphq34.prerender ?? {};
732
- }
733
- if (document.URL !== location.href) {
734
- location.href = location.href;
735
- }
736
- app = _app;
737
- await _app.hooks.init?.();
738
- routes = parse(_app);
739
- container = document.documentElement;
740
- target = _target;
741
- default_layout_loader = _app.nodes[0];
742
- default_error_loader = _app.nodes[1];
743
- void default_layout_loader();
744
- void default_error_loader();
745
- current_history_index = history.state?.[HISTORY_INDEX];
746
- current_navigation_index = history.state?.[NAVIGATION_INDEX];
747
- if (!current_history_index) {
748
- current_history_index = current_navigation_index = Date.now();
749
- history.replaceState(
750
- {
751
- ...history.state,
752
- [HISTORY_INDEX]: current_history_index,
753
- [NAVIGATION_INDEX]: current_navigation_index
754
- },
755
- ""
756
- );
757
- }
758
- const scroll = scroll_positions[current_history_index];
759
- function restore_scroll() {
760
- if (scroll) {
761
- history.scrollRestoration = "manual";
762
- scrollTo(scroll.x, scroll.y);
763
- }
764
- }
765
- if (hydrate) {
766
- restore_scroll();
767
- await _hydrate(target, hydrate);
768
- } else {
769
- await navigate({
770
- type: "enter",
771
- url: resolve_url(app.hash ? decode_hash(new URL(location.href)) : location.href),
772
- replace_state: true
773
- });
774
- restore_scroll();
775
- }
776
- _start_router();
777
- }
778
- function reset_invalidation() {
779
- invalidated.length = 0;
780
- force_invalidation = false;
781
- }
782
- function capture_snapshot(index) {
783
- if (components.some((c) => c?.snapshot)) {
784
- snapshots[index] = components.map((c) => c?.snapshot?.capture());
785
- }
786
- }
787
- function restore_snapshot(index) {
788
- snapshots[index]?.forEach((value, i) => {
789
- components[i]?.snapshot?.restore(value);
790
- });
791
- }
792
- function persist_state() {
793
- update_scroll_positions(current_history_index);
794
- set(SCROLL_KEY, scroll_positions);
795
- capture_snapshot(current_navigation_index);
796
- set(SNAPSHOT_KEY, snapshots);
797
- }
798
- async function _goto(url, options, redirect_count, nav_token) {
799
- let query_keys;
800
- let live_query_keys;
801
- if (options.invalidateAll) {
802
- discard_load_cache();
803
- }
804
- await navigate({
805
- type: "goto",
806
- url: resolve_url(url),
807
- keepfocus: options.keepFocus,
808
- noscroll: options.noScroll,
809
- replace_state: options.replaceState,
810
- state: options.state,
811
- redirect_count,
812
- nav_token,
813
- accept: () => {
814
- if (options.invalidateAll) {
815
- force_invalidation = true;
816
- query_keys = /* @__PURE__ */ new Set();
817
- for (const [id, entries] of query_map) {
818
- for (const payload of entries.keys()) {
819
- query_keys.add(create_remote_key(id, payload));
820
- }
821
- }
822
- live_query_keys = /* @__PURE__ */ new Set();
823
- for (const [id, entries] of live_query_map) {
824
- for (const payload of entries.keys()) {
825
- live_query_keys.add(create_remote_key(id, payload));
826
- }
827
- }
828
- }
829
- if (options.invalidate) {
830
- options.invalidate.forEach(push_invalidated);
831
- }
832
- }
833
- });
834
- if (options.invalidateAll) {
835
- void tick().then(tick).then(() => {
836
- for (const [id, entries] of query_map) {
837
- for (const [payload, { resource }] of entries) {
838
- if (query_keys?.has(create_remote_key(id, payload))) {
839
- void resource.refresh();
840
- }
841
- }
842
- }
843
- for (const [id, entries] of live_query_map) {
844
- for (const [payload, { resource }] of entries) {
845
- if (live_query_keys?.has(create_remote_key(id, payload))) {
846
- void resource.reconnect();
847
- }
848
- }
849
- }
850
- });
851
- }
852
- }
853
- async function _preload_data(intent) {
854
- if (intent.id !== load_cache?.id) {
855
- discard_load_cache();
856
- const preload = {};
857
- preload_tokens.add(preload);
858
- load_cache = {
859
- id: intent.id,
860
- token: preload,
861
- promise: load_route({ ...intent, preload }).then((result) => {
862
- preload_tokens.delete(preload);
863
- if (result.type === "loaded" && result.state.error) {
864
- discard_load_cache();
865
- }
866
- return result;
867
- }),
868
- fork: null
869
- };
870
- }
871
- return load_cache.promise;
872
- }
873
- async function _preload_code(url) {
874
- const route = (await get_navigation_intent(url, false))?.route;
875
- if (route) {
876
- await Promise.all(
877
- /** @type {[has_server_load: boolean, node_loader: import('types').CSRPageNodeLoader][]} */
878
- [...route.layouts, route.leaf].filter(Boolean).map((load) => load[1]())
879
- );
880
- }
881
- }
882
- async function initialize(result, target2, hydrate) {
883
- const nav = {
884
- params: current.params,
885
- route: { id: current.route?.id ?? null },
886
- url: new URL(location.href)
887
- };
888
- current = {
889
- ...result.state,
890
- nav
891
- };
892
- const style = document.querySelector("style[data-sveltekit]");
893
- if (style) style.remove();
894
- update(
895
- /** @type {import('@sveltejs/kit').Page} */
896
- result.props.page
897
- );
898
- root = new app.root({
899
- target: target2,
900
- props: { ...result.props, stores, components },
901
- hydrate,
902
- // @ts-ignore Svelte 5 specific: asynchronously instantiate the component, i.e. don't call flushSync
903
- sync: false,
904
- // @ts-ignore Svelte 5 specific: transformError allows to transform errors before they are passed to boundaries
905
- transformError: void 0
906
- });
907
- void await Promise.resolve();
908
- restore_snapshot(current_navigation_index);
909
- if (hydrate) {
910
- const navigation = {
911
- from: null,
912
- to: {
913
- ...nav,
914
- scroll: scroll_positions[current_history_index] ?? scroll_state()
915
- },
916
- willUnload: false,
917
- type: "enter",
918
- complete: Promise.resolve()
919
- };
920
- after_navigate_callbacks.forEach((fn) => fn(navigation));
921
- }
922
- started = true;
923
- }
924
- async function get_navigation_result_from_branch({
925
- url,
926
- params,
927
- branch,
928
- errors,
929
- status,
930
- error,
931
- route,
932
- form
933
- }) {
934
- let slash = "never";
935
- if (base && (url.pathname === base || url.pathname === base + "/")) {
936
- slash = "always";
937
- } else {
938
- for (const node of branch) {
939
- if (node?.slash !== void 0) slash = node.slash;
940
- }
941
- }
942
- url.pathname = normalize_path(url.pathname, slash);
943
- url.search = url.search;
944
- const result = {
945
- type: "loaded",
946
- state: {
947
- url,
948
- params,
949
- branch,
950
- error,
951
- route
952
- },
953
- props: {
954
- // @ts-ignore Somehow it's getting SvelteComponent and SvelteComponentDev mixed up
955
- constructors: compact(branch).map((branch_node) => branch_node.node.component),
956
- page: clone_page(page)
957
- }
958
- };
959
- if (errors && false) {
960
- let last_idx = -1;
961
- result.props.errors = await Promise.all(
962
- // eslint-disable-next-line @typescript-eslint/await-thenable
963
- branch.map((b, i) => {
964
- if (i === 0) return void 0;
965
- if (!b) return null;
966
- i--;
967
- while (i > last_idx + 1 && !errors[i]) i -= 1;
968
- last_idx = i;
969
- return errors[i]?.().then((e) => e.component).catch(() => void 0);
970
- }).filter((e) => e !== null)
971
- );
972
- }
973
- if (error && false) {
974
- result.props.error = error;
975
- }
976
- if (form !== void 0) {
977
- result.props.form = form;
978
- }
979
- let data = {};
980
- let data_changed = !page;
981
- let p = 0;
982
- for (let i = 0; i < Math.max(branch.length, current.branch.length); i += 1) {
983
- const node = branch[i];
984
- const prev = current.branch[i];
985
- if (node?.data !== prev?.data) data_changed = true;
986
- if (!node) continue;
987
- data = { ...data, ...node.data };
988
- if (data_changed) {
989
- result.props[`data_${p}`] = data;
990
- }
991
- p += 1;
992
- }
993
- const page_changed = !current.url || url.href !== current.url.href || current.error !== error || form !== void 0 && form !== page.form || data_changed;
994
- if (page_changed) {
995
- result.props.page = {
996
- error,
997
- params,
998
- route: {
999
- id: route?.id ?? null
1000
- },
1001
- state: {},
1002
- status,
1003
- url: new URL(url),
1004
- form: form ?? null,
1005
- // The whole page store is updated, but this way the object reference stays the same
1006
- data: data_changed ? data : page.data
1007
- };
1008
- }
1009
- return result;
1010
- }
1011
- async function load_node({ loader, parent, url, params, route, server_data_node }) {
1012
- let data = null;
1013
- const uses = {
1014
- dependencies: /* @__PURE__ */ new Set(),
1015
- params: /* @__PURE__ */ new Set(),
1016
- parent: false,
1017
- route: false,
1018
- url: false,
1019
- search_params: /* @__PURE__ */ new Set()
1020
- };
1021
- const node = await loader();
1022
- return {
1023
- node,
1024
- loader,
1025
- server: server_data_node,
1026
- universal: node.universal?.load ? { type: "data", data, uses } : null,
1027
- data: data ?? server_data_node?.data ?? null,
1028
- slash: node.universal?.trailingSlash ?? server_data_node?.slash
1029
- };
1030
- }
1031
- function resolve_fetch_url(input, init, url) {
1032
- let requested = input instanceof Request ? input.url : input;
1033
- const resolved = new URL(requested, url);
1034
- if (resolved.origin === url.origin) {
1035
- requested = resolved.href.slice(url.origin.length);
1036
- }
1037
- const promise = started ? subsequent_fetch(requested, resolved.href, init) : initial_fetch(requested, init);
1038
- return { resolved, promise };
1039
- }
1040
- function has_changed(parent_changed, route_changed, url_changed, search_params_changed, uses, params) {
1041
- if (force_invalidation) return true;
1042
- if (!uses) return false;
1043
- if (uses.parent && parent_changed) return true;
1044
- if (uses.route && route_changed) return true;
1045
- if (uses.url && url_changed) return true;
1046
- for (const tracked_params of uses.search_params) {
1047
- if (search_params_changed.has(tracked_params)) return true;
1048
- }
1049
- for (const param of uses.params) {
1050
- if (params[param] !== current.params[param]) return true;
1051
- }
1052
- for (const href of uses.dependencies) {
1053
- if (invalidated.some((fn) => fn(new URL(href)))) return true;
1054
- }
1055
- return false;
1056
- }
1057
- function create_data_node(node, previous) {
1058
- if (node?.type === "data") return node;
1059
- if (node?.type === "skip") return previous ?? null;
1060
- return null;
1061
- }
1062
- function diff_search_params(old_url, new_url) {
1063
- if (!old_url) return new Set(new_url.searchParams.keys());
1064
- const changed = /* @__PURE__ */ new Set([...old_url.searchParams.keys(), ...new_url.searchParams.keys()]);
1065
- for (const key of changed) {
1066
- const old_values = old_url.searchParams.getAll(key);
1067
- const new_values = new_url.searchParams.getAll(key);
1068
- if (old_values.every((value) => new_values.includes(value)) && new_values.every((value) => old_values.includes(value))) {
1069
- changed.delete(key);
1070
- }
1071
- }
1072
- return changed;
1073
- }
1074
- function preload_error({ error, url, route, params }) {
1075
- return {
1076
- type: "loaded",
1077
- state: {
1078
- error,
1079
- url,
1080
- route,
1081
- params,
1082
- branch: []
1083
- },
1084
- props: {
1085
- page: clone_page(page),
1086
- constructors: []
1087
- }
1088
- };
1089
- }
1090
- async function load_route({ id, invalidating, url, params, route, preload }) {
1091
- if (load_cache?.id === id) {
1092
- preload_tokens.delete(load_cache.token);
1093
- return load_cache.promise;
1094
- }
1095
- const { errors, layouts, leaf } = route;
1096
- const loaders = [...layouts, leaf];
1097
- errors.forEach((loader) => loader?.().catch(noop));
1098
- loaders.forEach((loader) => loader?.[1]().catch(noop));
1099
- const url_changed = current.url ? id !== get_page_key(current.url) : false;
1100
- const route_changed = current.route ? route.id !== current.route.id : false;
1101
- const search_params_changed = diff_search_params(current.url, url);
1102
- let parent_changed = false;
1103
- const branch_promises = loaders.map(async (loader, i) => {
1104
- if (!loader) return;
1105
- const previous = current.branch[i];
1106
- const valid = loader[1] === previous?.loader && !has_changed(
1107
- parent_changed,
1108
- route_changed,
1109
- url_changed,
1110
- search_params_changed,
1111
- previous.universal?.uses,
1112
- params
1113
- );
1114
- if (valid) return previous;
1115
- parent_changed = true;
1116
- return load_node({
1117
- loader: loader[1],
1118
- url,
1119
- params,
1120
- route,
1121
- parent: async () => {
1122
- const data = {};
1123
- for (let j = 0; j < i; j += 1) {
1124
- Object.assign(data, (await branch_promises[j])?.data);
1125
- }
1126
- return data;
1127
- },
1128
- server_data_node: create_data_node(
1129
- // server_data_node is undefined if it wasn't reloaded from the server;
1130
- // and if current loader uses server data, we want to reuse previous data.
1131
- loader[0] ? { type: "skip" } : null,
1132
- loader[0] ? previous?.server : void 0
1133
- )
1134
- });
1135
- });
1136
- for (const p of branch_promises) p.catch(noop);
1137
- const branch = [];
1138
- for (let i = 0; i < loaders.length; i += 1) {
1139
- if (loaders[i]) {
1140
- try {
1141
- branch.push(await branch_promises[i]);
1142
- } catch (err) {
1143
- if (err instanceof Redirect) {
1144
- return {
1145
- type: "redirect",
1146
- location: err.location
1147
- };
1148
- }
1149
- if (preload_tokens.has(preload)) {
1150
- return preload_error({
1151
- error: await handle_error(err, { params, url, route: { id: route.id } }),
1152
- url,
1153
- params,
1154
- route
1155
- });
1156
- }
1157
- let status = get_status(err);
1158
- let error;
1159
- if (err instanceof HttpError) {
1160
- error = err.body;
1161
- } else {
1162
- const updated2 = await stores.updated.check();
1163
- if (updated2) {
1164
- await update_service_worker();
1165
- return await native_navigation(url);
1166
- }
1167
- error = await handle_error(err, { params, url, route: { id: route.id } });
1168
- }
1169
- const error_load = await load_nearest_error_page(i, branch, errors);
1170
- if (error_load) {
1171
- return get_navigation_result_from_branch({
1172
- url,
1173
- params,
1174
- branch: branch.slice(0, error_load.idx).concat(error_load.node),
1175
- errors,
1176
- status,
1177
- error,
1178
- route
1179
- });
1180
- } else {
1181
- return await server_fallback(url, { id: route.id }, error, status);
1182
- }
1183
- }
1184
- } else {
1185
- branch.push(void 0);
1186
- }
1187
- }
1188
- return get_navigation_result_from_branch({
1189
- url,
1190
- params,
1191
- branch,
1192
- errors,
1193
- status: 200,
1194
- error: null,
1195
- route,
1196
- // Reset `form` on navigation, but not invalidation
1197
- form: invalidating ? void 0 : null
1198
- });
1199
- }
1200
- async function load_nearest_error_page(i, branch, errors) {
1201
- while (i--) {
1202
- if (errors[i]) {
1203
- let j = i;
1204
- while (!branch[j]) j -= 1;
1205
- try {
1206
- return {
1207
- idx: j + 1,
1208
- node: {
1209
- node: await /** @type {import('types').CSRPageNodeLoader } */
1210
- errors[i](),
1211
- loader: (
1212
- /** @type {import('types').CSRPageNodeLoader } */
1213
- errors[i]
1214
- ),
1215
- data: {},
1216
- server: null,
1217
- universal: null
1218
- }
1219
- };
1220
- } catch {
1221
- continue;
1222
- }
1223
- }
1224
- }
1225
- }
1226
- async function load_root_error_page({ status, error, url, route }) {
1227
- const params = {};
1228
- let server_data_node = null;
1229
- try {
1230
- const root_layout = await load_node({
1231
- loader: default_layout_loader,
1232
- url,
1233
- params,
1234
- route,
1235
- parent: () => Promise.resolve({}),
1236
- server_data_node: create_data_node(server_data_node)
1237
- });
1238
- const root_error = {
1239
- node: await default_error_loader(),
1240
- loader: default_error_loader,
1241
- universal: null,
1242
- server: null,
1243
- data: null
1244
- };
1245
- return get_navigation_result_from_branch({
1246
- url,
1247
- params,
1248
- branch: [root_layout, root_error],
1249
- status,
1250
- error,
1251
- errors: [],
1252
- route: null
1253
- });
1254
- } catch (error2) {
1255
- if (error2 instanceof Redirect) {
1256
- return _goto(new URL(error2.location, location.href), {}, 0);
1257
- }
1258
- throw error2;
1259
- }
1260
- }
1261
- async function get_rerouted_url(url) {
1262
- const href = url.href;
1263
- if (reroute_cache.has(href)) {
1264
- return reroute_cache.get(href);
1265
- }
1266
- let rerouted;
1267
- try {
1268
- const promise = (async () => {
1269
- let rerouted2 = await app.hooks.reroute({
1270
- url: new URL(url),
1271
- fetch: async (input, init) => {
1272
- return resolve_fetch_url(input, init, url).promise;
1273
- }
1274
- }) ?? url;
1275
- if (typeof rerouted2 === "string") {
1276
- const tmp = new URL(url);
1277
- if (app.hash) {
1278
- tmp.hash = rerouted2;
1279
- } else {
1280
- tmp.pathname = rerouted2;
1281
- }
1282
- rerouted2 = tmp;
1283
- }
1284
- return rerouted2;
1285
- })();
1286
- reroute_cache.set(href, promise);
1287
- rerouted = await promise;
1288
- } catch (e) {
1289
- reroute_cache.delete(href);
1290
- return;
1291
- }
1292
- return rerouted;
1293
- }
1294
- async function get_navigation_intent(url, invalidating) {
1295
- if (!url) return;
1296
- if (is_external_url(url, base, app.hash)) return;
1297
- {
1298
- const rerouted = await get_rerouted_url(url);
1299
- if (!rerouted) return;
1300
- const path = get_url_path(rerouted);
1301
- for (const route of routes) {
1302
- const params = route.exec(path);
1303
- if (params) {
1304
- return {
1305
- id: get_page_key(url),
1306
- invalidating,
1307
- route,
1308
- params: decode_params(params),
1309
- url
1310
- };
1311
- }
1312
- }
1313
- }
1314
- }
1315
- function get_url_path(url) {
1316
- return decode_pathname(
1317
- app.hash ? url.hash.replace(/^#/, "").replace(/[?#].+/, "") : url.pathname.slice(base.length)
1318
- ) || "/";
1319
- }
1320
- function get_page_key(url) {
1321
- return (app.hash ? url.hash.replace(/^#/, "") : url.pathname) + url.search;
1322
- }
1323
- function _before_navigate({ url, type, intent, delta, event, scroll }) {
1324
- let should_block = false;
1325
- const nav = create_navigation(current, intent, url, type, scroll ?? null);
1326
- if (delta !== void 0) {
1327
- nav.navigation.delta = delta;
1328
- }
1329
- if (event !== void 0) {
1330
- nav.navigation.event = event;
1331
- }
1332
- const cancellable = {
1333
- ...nav.navigation,
1334
- cancel: () => {
1335
- should_block = true;
1336
- nav.reject(new Error("navigation cancelled"));
1337
- }
1338
- };
1339
- if (!is_navigating) {
1340
- before_navigate_callbacks.forEach((fn) => fn(cancellable));
1341
- }
1342
- return should_block ? null : nav;
1343
- }
1344
- async function navigate({
1345
- type,
1346
- url,
1347
- popped,
1348
- keepfocus,
1349
- noscroll,
1350
- replace_state,
1351
- state: state2 = {},
1352
- redirect_count = 0,
1353
- nav_token = {},
1354
- accept = noop,
1355
- block = noop,
1356
- event
1357
- }) {
1358
- const prev_token = token;
1359
- token = nav_token;
1360
- const intent = await get_navigation_intent(url, false);
1361
- const nav = type === "enter" ? create_navigation(current, intent, url, type) : _before_navigate({
1362
- url,
1363
- type,
1364
- delta: popped?.delta,
1365
- intent,
1366
- scroll: popped?.scroll,
1367
- // @ts-ignore
1368
- event
1369
- });
1370
- if (!nav) {
1371
- block();
1372
- if (token === nav_token) token = prev_token;
1373
- return;
1374
- }
1375
- const previous_history_index = current_history_index;
1376
- const previous_navigation_index = current_navigation_index;
1377
- accept();
1378
- is_navigating = true;
1379
- if (started && nav.navigation.type !== "enter") {
1380
- stores.navigating.set(navigating.current = nav.navigation);
1381
- }
1382
- let navigation_result = intent && await load_route(intent);
1383
- if (!navigation_result) {
1384
- if (is_external_url(url, base, app.hash)) {
1385
- {
1386
- return await native_navigation(url, replace_state);
1387
- }
1388
- } else {
1389
- navigation_result = await server_fallback(
1390
- url,
1391
- { id: null },
1392
- await handle_error(new SvelteKitError(404, "Not Found", `Not found: ${url.pathname}`), {
1393
- url,
1394
- params: {},
1395
- route: { id: null }
1396
- }),
1397
- 404,
1398
- replace_state
1399
- );
1400
- }
1401
- }
1402
- url = intent?.url || url;
1403
- if (token !== nav_token) {
1404
- nav.reject(new Error("navigation aborted"));
1405
- return false;
1406
- }
1407
- if (navigation_result.type === "redirect") {
1408
- if (redirect_count < 20) {
1409
- await navigate({
1410
- type,
1411
- url: new URL(navigation_result.location, url),
1412
- popped,
1413
- keepfocus,
1414
- noscroll,
1415
- replace_state,
1416
- state: state2,
1417
- redirect_count: redirect_count + 1,
1418
- nav_token
1419
- });
1420
- nav.fulfil(void 0);
1421
- return;
1422
- }
1423
- navigation_result = await load_root_error_page({
1424
- status: 500,
1425
- error: await handle_error(new Error("Redirect loop"), {
1426
- url,
1427
- params: {},
1428
- route: { id: null }
1429
- }),
1430
- url,
1431
- route: { id: null }
1432
- });
1433
- } else if (
1434
- /** @type {number} */
1435
- navigation_result.props.page.status >= 400
1436
- ) {
1437
- const updated2 = await stores.updated.check();
1438
- if (updated2) {
1439
- await update_service_worker();
1440
- await native_navigation(url, replace_state);
1441
- }
1442
- }
1443
- reset_invalidation();
1444
- update_scroll_positions(previous_history_index);
1445
- capture_snapshot(previous_navigation_index);
1446
- if (navigation_result.props.page.url.pathname !== url.pathname) {
1447
- url.pathname = navigation_result.props.page.url.pathname;
1448
- }
1449
- state2 = popped ? popped.state : state2;
1450
- if (!popped) {
1451
- const change = replace_state ? 0 : 1;
1452
- const entry = {
1453
- [HISTORY_INDEX]: current_history_index += change,
1454
- [NAVIGATION_INDEX]: current_navigation_index += change,
1455
- [STATES_KEY]: state2
1456
- };
1457
- const fn = replace_state ? history.replaceState : history.pushState;
1458
- fn.call(history, entry, "", url);
1459
- if (!replace_state) {
1460
- clear_onward_history(current_history_index, current_navigation_index);
1461
- }
1462
- }
1463
- const load_cache_fork = intent && load_cache?.id === intent.id ? load_cache.fork : null;
1464
- if (load_cache?.fork && !load_cache_fork) {
1465
- discard_load_cache();
1466
- }
1467
- load_cache = null;
1468
- navigation_result.props.page.state = state2;
1469
- let commit_promise;
1470
- if (started) {
1471
- const after_navigate = (await Promise.all(
1472
- // eslint-disable-next-line @typescript-eslint/await-thenable -- we need to await because they can be asynchronous
1473
- Array.from(
1474
- on_navigate_callbacks,
1475
- (fn) => fn(
1476
- /** @type {import('@sveltejs/kit').OnNavigate} */
1477
- nav.navigation
1478
- )
1479
- )
1480
- )).filter(
1481
- /** @returns {value is () => void} */
1482
- (value) => typeof value === "function"
1483
- );
1484
- if (after_navigate.length > 0) {
1485
- let cleanup = function() {
1486
- after_navigate.forEach((fn) => {
1487
- after_navigate_callbacks.delete(fn);
1488
- });
1489
- };
1490
- after_navigate.push(cleanup);
1491
- after_navigate.forEach((fn) => {
1492
- after_navigate_callbacks.add(fn);
1493
- });
1494
- }
1495
- const target2 = (
1496
- /** @type {import('@sveltejs/kit').NavigationTarget} */
1497
- nav.navigation.to
1498
- );
1499
- current = {
1500
- ...navigation_result.state,
1501
- nav: {
1502
- params: (
1503
- /** @type {Record<string, any>} */
1504
- target2.params
1505
- ),
1506
- route: target2.route,
1507
- url: target2.url
1508
- }
1509
- };
1510
- if (navigation_result.props.page) {
1511
- navigation_result.props.page.url = url;
1512
- }
1513
- const fork = load_cache_fork && await load_cache_fork;
1514
- if (fork) {
1515
- commit_promise = fork.commit();
1516
- } else {
1517
- rendering_error = null;
1518
- root.$set(navigation_result.props);
1519
- if (rendering_error) {
1520
- Object.assign(navigation_result.props.page, rendering_error);
1521
- }
1522
- update(navigation_result.props.page);
1523
- commit_promise = settled?.();
1524
- }
1525
- has_navigated = true;
1526
- } else {
1527
- await initialize(navigation_result, target, false);
1528
- }
1529
- const { activeElement } = document;
1530
- await commit_promise;
1531
- await tick();
1532
- await tick();
1533
- if (token !== nav_token) {
1534
- nav.reject(new Error("navigation aborted"));
1535
- return false;
1536
- }
1537
- if (navigation_result.props.page && rendering_error) {
1538
- Object.assign(navigation_result.props.page, rendering_error);
1539
- }
1540
- let deep_linked = null;
1541
- if (autoscroll) {
1542
- const scroll = popped ? popped.scroll : noscroll ? scroll_state() : null;
1543
- if (scroll) {
1544
- scrollTo(scroll.x, scroll.y);
1545
- } else if (deep_linked = url.hash && document.getElementById(get_id(url))) {
1546
- deep_linked.scrollIntoView();
1547
- } else {
1548
- scrollTo(0, 0);
1549
- }
1550
- }
1551
- const changed_focus = (
1552
- // reset focus only if any manual focus management didn't override it
1553
- document.activeElement !== activeElement && // also refocus when activeElement is body already because the
1554
- // focus event might not have been fired on it yet
1555
- document.activeElement !== document.body
1556
- );
1557
- if (!keepfocus && !changed_focus) {
1558
- reset_focus(url, !deep_linked);
1559
- }
1560
- autoscroll = true;
1561
- is_navigating = false;
1562
- if (type === "popstate") {
1563
- restore_snapshot(current_navigation_index);
1564
- }
1565
- nav.fulfil(void 0);
1566
- if (nav.navigation.to) {
1567
- nav.navigation.to.scroll = scroll_state();
1568
- }
1569
- after_navigate_callbacks.forEach(
1570
- (fn) => fn(
1571
- /** @type {import('@sveltejs/kit').AfterNavigate} */
1572
- nav.navigation
1573
- )
1574
- );
1575
- stores.navigating.set(navigating.current = null);
1576
- }
1577
- async function server_fallback(url, route, error, status, replace_state) {
1578
- if (url.origin === origin && url.pathname === location.pathname && !hydrated) {
1579
- return await load_root_error_page({
1580
- status,
1581
- error,
1582
- url,
1583
- route
1584
- });
1585
- }
1586
- return await native_navigation(url, replace_state);
1587
- }
1588
- function setup_preload() {
1589
- let mousemove_timeout;
1590
- let current_a = { element: void 0, href: void 0 };
1591
- let current_priority;
1592
- container.addEventListener("mousemove", (event) => {
1593
- const target2 = (
1594
- /** @type {Element} */
1595
- event.target
1596
- );
1597
- clearTimeout(mousemove_timeout);
1598
- mousemove_timeout = setTimeout(() => {
1599
- void preload(target2, PRELOAD_PRIORITIES.hover);
1600
- }, 20);
1601
- });
1602
- function tap(event) {
1603
- if (event.defaultPrevented) return;
1604
- void preload(
1605
- /** @type {Element} */
1606
- event.composedPath()[0],
1607
- PRELOAD_PRIORITIES.tap
1608
- );
1609
- }
1610
- container.addEventListener("mousedown", tap);
1611
- container.addEventListener("touchstart", tap, { passive: true });
1612
- const observer = new IntersectionObserver(
1613
- (entries) => {
1614
- for (const entry of entries) {
1615
- if (entry.isIntersecting) {
1616
- void _preload_code(new URL(
1617
- /** @type {HTMLAnchorElement} */
1618
- entry.target.href
1619
- ));
1620
- observer.unobserve(entry.target);
1621
- }
1622
- }
1623
- },
1624
- { threshold: 0 }
1625
- );
1626
- async function preload(element, priority) {
1627
- const a = find_anchor(element, container);
1628
- const interacted = a === current_a.element && a?.href === current_a.href && priority >= current_priority;
1629
- if (!a || interacted) return;
1630
- const { url, external, download } = get_link_info(a, base, app.hash);
1631
- if (external || download) return;
1632
- const options = get_router_options(a);
1633
- const same_url = url && get_page_key(current.url) === get_page_key(url);
1634
- if (options.reload || same_url) return;
1635
- if (priority <= options.preload_data) {
1636
- current_a = { element: a, href: a.href };
1637
- current_priority = PRELOAD_PRIORITIES.tap;
1638
- const intent = await get_navigation_intent(url, false);
1639
- if (!intent) return;
1640
- {
1641
- void _preload_data(intent);
1642
- }
1643
- } else if (priority <= options.preload_code) {
1644
- current_a = { element: a, href: a.href };
1645
- current_priority = priority;
1646
- void _preload_code(
1647
- /** @type {URL} */
1648
- url
1649
- );
1650
- }
1651
- }
1652
- function after_navigate() {
1653
- observer.disconnect();
1654
- for (const a of container.querySelectorAll("a")) {
1655
- const { url, external, download } = get_link_info(a, base, app.hash);
1656
- if (external || download) continue;
1657
- const options = get_router_options(a);
1658
- if (options.reload) continue;
1659
- if (options.preload_code === PRELOAD_PRIORITIES.viewport) {
1660
- observer.observe(a);
1661
- }
1662
- if (options.preload_code === PRELOAD_PRIORITIES.eager) {
1663
- void _preload_code(
1664
- /** @type {URL} */
1665
- url
1666
- );
1667
- }
1668
- }
1669
- }
1670
- after_navigate_callbacks.add(after_navigate);
1671
- after_navigate();
1672
- }
1673
- function handle_error(error, event) {
1674
- if (error instanceof HttpError) {
1675
- return error.body;
1676
- }
1677
- const status = get_status(error);
1678
- const message = get_message(error);
1679
- return app.hooks.handleError({ error, event, status, message }) ?? /** @type {any} */
1680
- { message };
1681
- }
1682
- function push_invalidated(resource) {
1683
- if (typeof resource === "function") {
1684
- invalidated.push(resource);
1685
- } else {
1686
- const { href } = new URL(resource, location.href);
1687
- invalidated.push((url) => url.href === href);
1688
- }
1689
- }
1690
- function pushState(url, state2) {
1691
- update_scroll_positions(current_history_index);
1692
- const opts = {
1693
- [HISTORY_INDEX]: current_history_index += 1,
1694
- [NAVIGATION_INDEX]: current_navigation_index,
1695
- [PAGE_URL_KEY]: page.url.href,
1696
- [STATES_KEY]: state2
1697
- };
1698
- history.pushState(opts, "", resolve_url(url));
1699
- has_navigated = true;
1700
- page.state = state2;
1701
- root.$set({
1702
- // we need to assign a new page object so that subscribers are correctly notified
1703
- page: untrack(() => clone_page(page))
1704
- });
1705
- clear_onward_history(current_history_index, current_navigation_index);
1706
- }
1707
- function _start_router() {
1708
- history.scrollRestoration = "manual";
1709
- addEventListener("beforeunload", (e) => {
1710
- let should_block = false;
1711
- persist_state();
1712
- if (!is_navigating) {
1713
- const nav = create_navigation(current, void 0, null, "leave");
1714
- const navigation = {
1715
- ...nav.navigation,
1716
- cancel: () => {
1717
- should_block = true;
1718
- nav.reject(new Error("navigation cancelled"));
1719
- }
1720
- };
1721
- before_navigate_callbacks.forEach((fn) => fn(navigation));
1722
- }
1723
- if (should_block) {
1724
- e.preventDefault();
1725
- e.returnValue = "";
1726
- } else {
1727
- history.scrollRestoration = "auto";
1728
- }
1729
- });
1730
- addEventListener("visibilitychange", () => {
1731
- if (document.visibilityState === "hidden") {
1732
- persist_state();
1733
- }
1734
- });
1735
- if (!navigator.connection?.saveData) {
1736
- setup_preload();
1737
- }
1738
- container.addEventListener("click", async (event) => {
1739
- if (event.button || event.which !== 1) return;
1740
- if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
1741
- if (event.defaultPrevented) return;
1742
- const a = find_anchor(
1743
- /** @type {Element} */
1744
- event.composedPath()[0],
1745
- container
1746
- );
1747
- if (!a) return;
1748
- const { url, external, target: target2, download } = get_link_info(a, base, app.hash);
1749
- if (!url) return;
1750
- if (target2 === "_parent" || target2 === "_top") {
1751
- if (window.parent !== window) return;
1752
- } else if (target2 && target2 !== "_self") {
1753
- return;
1754
- }
1755
- const options = get_router_options(a);
1756
- const is_svg_a_element = a instanceof SVGAElement;
1757
- if (!is_svg_a_element && url.protocol !== location.protocol && !(url.protocol === "https:" || url.protocol === "http:"))
1758
- return;
1759
- if (download) return;
1760
- const [nonhash, hash2] = (app.hash ? url.hash.replace(/^#/, "") : url.href).split("#");
1761
- const same_pathname = nonhash === strip_hash(location);
1762
- if (external || options.reload && (!same_pathname || !hash2)) {
1763
- if (_before_navigate({ url, type: "link", event })) {
1764
- is_navigating = true;
1765
- } else {
1766
- event.preventDefault();
1767
- }
1768
- return;
1769
- }
1770
- if (hash2 !== void 0 && same_pathname) {
1771
- const [, current_hash] = current.url.href.split("#");
1772
- if (current_hash === hash2) {
1773
- event.preventDefault();
1774
- if (hash2 === "" || hash2 === "top" && a.ownerDocument.getElementById("top") === null) {
1775
- scrollTo({ top: 0 });
1776
- } else {
1777
- const element = a.ownerDocument.getElementById(decodeURIComponent(hash2));
1778
- if (element) {
1779
- element.scrollIntoView();
1780
- element.focus();
1781
- }
1782
- }
1783
- return;
1784
- }
1785
- hash_navigating = true;
1786
- update_scroll_positions(current_history_index);
1787
- update_url(url);
1788
- if (!options.replace_state) return;
1789
- hash_navigating = false;
1790
- }
1791
- event.preventDefault();
1792
- await new Promise((fulfil) => {
1793
- requestAnimationFrame(() => {
1794
- setTimeout(fulfil, 0);
1795
- });
1796
- setTimeout(fulfil, 100);
1797
- });
1798
- await navigate({
1799
- type: "link",
1800
- url,
1801
- keepfocus: options.keepfocus,
1802
- noscroll: options.noscroll,
1803
- replace_state: options.replace_state ?? url.href === location.href,
1804
- event
1805
- });
1806
- });
1807
- container.addEventListener("submit", (event) => {
1808
- if (event.defaultPrevented) return;
1809
- const form = (
1810
- /** @type {HTMLFormElement} */
1811
- HTMLFormElement.prototype.cloneNode.call(event.target)
1812
- );
1813
- const submitter = (
1814
- /** @type {HTMLButtonElement | HTMLInputElement | null} */
1815
- event.submitter
1816
- );
1817
- const target2 = submitter?.formTarget || form.target;
1818
- if (target2 === "_blank") return;
1819
- const method = submitter?.formMethod || form.method;
1820
- if (method !== "get") return;
1821
- const url = new URL(
1822
- submitter?.hasAttribute("formaction") && submitter?.formAction || form.action
1823
- );
1824
- if (is_external_url(url, base, false)) return;
1825
- const event_form = (
1826
- /** @type {HTMLFormElement} */
1827
- event.target
1828
- );
1829
- const options = get_router_options(event_form);
1830
- if (options.reload) return;
1831
- event.preventDefault();
1832
- event.stopPropagation();
1833
- const data = new FormData(event_form, submitter);
1834
- url.search = new URLSearchParams(data).toString();
1835
- void navigate({
1836
- type: "form",
1837
- url,
1838
- keepfocus: options.keepfocus,
1839
- noscroll: options.noscroll,
1840
- replace_state: options.replace_state ?? url.href === location.href,
1841
- event
1842
- });
1843
- });
1844
- addEventListener("popstate", async (event) => {
1845
- if (resetting_focus) return;
1846
- if (event.state?.[HISTORY_INDEX]) {
1847
- const history_index = event.state[HISTORY_INDEX];
1848
- token = {};
1849
- if (history_index === current_history_index) return;
1850
- const scroll = scroll_positions[history_index];
1851
- const state2 = event.state[STATES_KEY] ?? {};
1852
- const url = new URL(event.state[PAGE_URL_KEY] ?? location.href);
1853
- const navigation_index = event.state[NAVIGATION_INDEX];
1854
- const is_hash_change = current.url ? strip_hash(location) === strip_hash(current.url) : false;
1855
- const shallow = navigation_index === current_navigation_index && (has_navigated || is_hash_change);
1856
- if (shallow) {
1857
- if (state2 !== page.state) {
1858
- page.state = state2;
1859
- }
1860
- update_url(url);
1861
- scroll_positions[current_history_index] = scroll_state();
1862
- if (scroll) scrollTo(scroll.x, scroll.y);
1863
- current_history_index = history_index;
1864
- return;
1865
- }
1866
- const delta = history_index - current_history_index;
1867
- await navigate({
1868
- type: "popstate",
1869
- url,
1870
- popped: {
1871
- state: state2,
1872
- scroll,
1873
- delta
1874
- },
1875
- accept: () => {
1876
- current_history_index = history_index;
1877
- current_navigation_index = navigation_index;
1878
- },
1879
- block: () => {
1880
- history.go(-delta);
1881
- },
1882
- nav_token: token,
1883
- event
1884
- });
1885
- } else {
1886
- if (!hash_navigating) {
1887
- const url = new URL(location.href);
1888
- update_url(url);
1889
- if (app.hash) {
1890
- location.reload();
1891
- }
1892
- }
1893
- }
1894
- });
1895
- addEventListener("hashchange", () => {
1896
- if (hash_navigating) {
1897
- hash_navigating = false;
1898
- history.replaceState(
1899
- {
1900
- ...history.state,
1901
- [HISTORY_INDEX]: ++current_history_index,
1902
- [NAVIGATION_INDEX]: current_navigation_index
1903
- },
1904
- "",
1905
- location.href
1906
- );
1907
- }
1908
- });
1909
- for (const link of document.querySelectorAll("link")) {
1910
- if (ICON_REL_ATTRIBUTES.has(link.rel)) {
1911
- link.href = link.href;
1912
- }
1913
- }
1914
- addEventListener("pageshow", (event) => {
1915
- if (event.persisted) {
1916
- stores.navigating.set(navigating.current = null);
1917
- }
1918
- });
1919
- function update_url(url) {
1920
- current.url = page.url = url;
1921
- stores.page.set(clone_page(page));
1922
- stores.page.notify();
1923
- }
1924
- }
1925
- async function _hydrate(target2, { status = 200, error, node_ids, params, route, server_route, data: server_data_nodes, form }) {
1926
- hydrated = true;
1927
- const url = new URL(location.href);
1928
- let parsed_route;
1929
- {
1930
- {
1931
- ({ params = {}, route = { id: null } } = await get_navigation_intent(url, false) || {});
1932
- }
1933
- parsed_route = routes.find(({ id }) => id === route.id);
1934
- }
1935
- let result;
1936
- let hydrate = true;
1937
- try {
1938
- const branch_promises = node_ids.map(async (n, i) => {
1939
- const server_data_node = server_data_nodes[i];
1940
- if (server_data_node?.uses) {
1941
- server_data_node.uses = deserialize_uses(server_data_node.uses);
1942
- }
1943
- return load_node({
1944
- loader: app.nodes[n],
1945
- url,
1946
- params,
1947
- route,
1948
- parent: async () => {
1949
- const data = {};
1950
- for (let j = 0; j < i; j += 1) {
1951
- Object.assign(data, (await branch_promises[j]).data);
1952
- }
1953
- return data;
1954
- },
1955
- server_data_node: create_data_node(server_data_node)
1956
- });
1957
- });
1958
- const branch = await Promise.all(branch_promises);
1959
- if (parsed_route) {
1960
- const layouts = parsed_route.layouts;
1961
- for (let i = 0; i < layouts.length; i++) {
1962
- if (!layouts[i]) {
1963
- branch.splice(i, 0, void 0);
1964
- }
1965
- }
1966
- }
1967
- result = await get_navigation_result_from_branch({
1968
- url,
1969
- params,
1970
- branch,
1971
- status,
1972
- error,
1973
- errors: parsed_route?.errors,
1974
- // TODO load earlier?
1975
- form,
1976
- route: parsed_route ?? null
1977
- });
1978
- } catch (error2) {
1979
- if (error2 instanceof Redirect) {
1980
- await native_navigation(new URL(error2.location, location.href));
1981
- return;
1982
- }
1983
- result = await load_root_error_page({
1984
- status: get_status(error2),
1985
- error: await handle_error(error2, { url, params, route }),
1986
- url,
1987
- route
1988
- });
1989
- target2.textContent = "";
1990
- hydrate = false;
1991
- } finally {
1992
- }
1993
- if (result.props.page) {
1994
- result.props.page.state = {};
1995
- }
1996
- await initialize(result, target2, hydrate);
1997
- }
1998
- function deserialize_uses(uses) {
1999
- return {
2000
- dependencies: new Set(uses?.dependencies ?? []),
2001
- params: new Set(uses?.params ?? []),
2002
- parent: !!uses?.parent,
2003
- route: !!uses?.route,
2004
- url: !!uses?.url,
2005
- search_params: new Set(uses?.search_params ?? [])
2006
- };
2007
- }
2008
- let resetting_focus = false;
2009
- function reset_focus(url, scroll = true) {
2010
- const autofocus = document.querySelector("[autofocus]");
2011
- if (autofocus) {
2012
- autofocus.focus();
2013
- } else {
2014
- const id = get_id(url);
2015
- if (id && document.getElementById(id)) {
2016
- const { x, y } = scroll_state();
2017
- setTimeout(() => {
2018
- const history_state = history.state;
2019
- resetting_focus = true;
2020
- location.replace(new URL(`#${id}`, location.href));
2021
- history.replaceState(history_state, "", url);
2022
- if (scroll) scrollTo(x, y);
2023
- resetting_focus = false;
2024
- });
2025
- } else {
2026
- const root2 = document.body;
2027
- const tabindex = root2.getAttribute("tabindex");
2028
- root2.tabIndex = -1;
2029
- root2.focus({ preventScroll: true, focusVisible: false });
2030
- if (tabindex !== null) {
2031
- root2.setAttribute("tabindex", tabindex);
2032
- } else {
2033
- root2.removeAttribute("tabindex");
2034
- }
2035
- }
2036
- const selection = getSelection();
2037
- if (selection && selection.type !== "None") {
2038
- const ranges = [];
2039
- for (let i = 0; i < selection.rangeCount; i += 1) {
2040
- ranges.push(selection.getRangeAt(i));
2041
- }
2042
- setTimeout(() => {
2043
- if (selection.rangeCount !== ranges.length) return;
2044
- for (let i = 0; i < selection.rangeCount; i += 1) {
2045
- const a = ranges[i];
2046
- const b = selection.getRangeAt(i);
2047
- if (a.commonAncestorContainer !== b.commonAncestorContainer || a.startContainer !== b.startContainer || a.endContainer !== b.endContainer || a.startOffset !== b.startOffset || a.endOffset !== b.endOffset) {
2048
- return;
2049
- }
2050
- }
2051
- selection.removeAllRanges();
2052
- });
2053
- }
2054
- }
2055
- }
2056
- function create_navigation(current2, intent, url, type, target_scroll = null) {
2057
- let fulfil;
2058
- let reject;
2059
- const complete = new Promise((f, r) => {
2060
- fulfil = f;
2061
- reject = r;
2062
- });
2063
- complete.catch(noop);
2064
- const navigation = (
2065
- /** @type {any} */
2066
- {
2067
- from: {
2068
- params: current2.params,
2069
- route: { id: current2.route?.id ?? null },
2070
- url: current2.url,
2071
- scroll: scroll_state()
2072
- },
2073
- to: url && {
2074
- params: intent?.params ?? null,
2075
- route: { id: intent?.route?.id ?? null },
2076
- url,
2077
- scroll: target_scroll
2078
- },
2079
- willUnload: !intent,
2080
- type,
2081
- complete
2082
- }
2083
- );
2084
- return {
2085
- navigation,
2086
- // @ts-expect-error
2087
- fulfil,
2088
- // @ts-expect-error
2089
- reject
2090
- };
2091
- }
2092
- function clone_page(page2) {
2093
- return {
2094
- data: page2.data,
2095
- error: page2.error,
2096
- form: page2.form,
2097
- params: page2.params,
2098
- route: page2.route,
2099
- state: page2.state,
2100
- status: page2.status,
2101
- url: page2.url
2102
- };
2103
- }
2104
- function decode_hash(url) {
2105
- const new_url = new URL(url);
2106
- new_url.hash = decodeURIComponent(url.hash);
2107
- return new_url;
2108
- }
2109
- function get_id(url) {
2110
- let id;
2111
- if (app.hash) {
2112
- const [, , second] = url.hash.split("#", 3);
2113
- id = second ?? "";
2114
- } else {
2115
- id = url.hash.slice(1);
2116
- }
2117
- return decodeURIComponent(id);
2118
- }
2119
- export {
2120
- pushState as a,
2121
- base as b,
2122
- stores as c,
2123
- load_css as l,
2124
- page as p,
2125
- resolve_route as r,
2126
- start as s,
2127
- version as v
2128
- };
2129
- //# sourceMappingURL=BqMutrfe.js.map