@voltro/web 0.33.0 → 0.34.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.
@@ -11,25 +11,25 @@ var h = {
11
11
  }, g = /* @__PURE__ */ new Set(), ee = (e) => {
12
12
  h = e;
13
13
  for (let e of g) e();
14
- }, te = () => h, _ = (e) => (g.add(e), () => {
14
+ }, _ = () => h, v = (e) => (g.add(e), () => {
15
15
  g.delete(e);
16
- }), v = class extends Error {
16
+ }), y = class extends Error {
17
17
  _voltroControl = "not-found";
18
18
  constructor(e) {
19
19
  super(e ? `Not found: ${e}` : "Not found"), this.name = "NotFoundError";
20
20
  }
21
- }, y = class extends Error {
21
+ }, b = class extends Error {
22
22
  _voltroControl = "redirect";
23
23
  location;
24
24
  status;
25
25
  constructor(e, t) {
26
26
  super(`Redirect: ${e}`), this.name = "RedirectError", this.location = e, this.status = t?.status ?? 303;
27
27
  }
28
- }, b = (e) => {
29
- throw new v(e);
30
- }, x = (e, t) => {
31
- throw new y(e, t);
32
- }, ne = (e) => e instanceof Error && e._voltroControl === "not-found", S = (e) => e instanceof Error && e._voltroControl === "redirect" && typeof e.location == "string", C = [
28
+ }, x = (e) => {
29
+ throw new y(e);
30
+ }, S = (e, t) => {
31
+ throw new b(e, t);
32
+ }, te = (e) => e instanceof Error && e._voltroControl === "not-found", C = (e) => e instanceof Error && e._voltroControl === "redirect" && typeof e.location == "string", ne = [
33
33
  "static",
34
34
  "spa",
35
35
  "ssr",
@@ -85,23 +85,23 @@ var h = {
85
85
  }
86
86
  }
87
87
  return null;
88
- }, oe = (e, t, n) => k(`${e}__seg${t}`, n), k = (e, t) => `${e}\u0000${Object.entries(t).sort(([e], [t]) => e < t ? -1 : 1).map(([e, t]) => `${e}=${t}`).join("")}`, A = (e, t) => {
88
+ }, oe = (e, t, n) => k(`${e}__seg${t}`, n), k = (e, t) => `${e}\u0000${Object.entries(t).sort(([e], [t]) => e < t ? -1 : 1).map(([e, t]) => `${e}=${t}`).join("")}`, se = (e, t) => {
89
89
  let n = e(t);
90
90
  return n instanceof Promise ? n.then(i) : i(n);
91
- }, se = (e, t, n, r) => e === void 0 ? null : typeof e == "function" ? e({
91
+ }, ce = (e, t, n, r) => e === void 0 ? null : typeof e == "function" ? e({
92
92
  params: t,
93
93
  loaderData: n,
94
94
  locale: r ?? "en"
95
- }) : e, ce = (e, t) => {
95
+ }) : e, le = (e, t) => {
96
96
  let n = null, r = -1;
97
97
  for (let i of e) (i.prefix === "" || t === i.prefix || t.startsWith(`${i.prefix}/`)) && i.prefix.length > r && (n = i, r = i.prefix.length);
98
98
  return n;
99
- }, le = (e, t, n) => {
99
+ }, ue = (e, t, n) => {
100
100
  if (e) for (let r = n; r >= 0; r--) {
101
101
  let n = e[r]?.[t];
102
102
  if (n !== void 0) return n;
103
103
  }
104
- }, ue = class {
104
+ }, de = class {
105
105
  entries = /* @__PURE__ */ new Map();
106
106
  get(e) {
107
107
  return this.entries.get(e);
@@ -149,63 +149,63 @@ var h = {
149
149
  clear() {
150
150
  this.entries.clear();
151
151
  }
152
- }, j = { kind: "native" }, de = (e, t) => {
153
- if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return j;
152
+ }, A = { kind: "native" }, fe = (e, t) => {
153
+ if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return A;
154
154
  let n = e.target, r = n instanceof Element ? n.closest("a") : null;
155
- if (!r) return j;
155
+ if (!r) return A;
156
156
  let i = r.getAttribute("href");
157
- if (i === null) return j;
157
+ if (i === null) return A;
158
158
  let a = r.getAttribute("target");
159
- if (a && a !== "_self" || r.hasAttribute("download") || r.hasAttribute("data-no-spa")) return j;
159
+ if (a && a !== "_self" || r.hasAttribute("download") || r.hasAttribute("data-no-spa")) return A;
160
160
  let o = r.getAttribute("rel");
161
- if (o && /(^|\s)external(\s|$)/i.test(o)) return j;
161
+ if (o && /(^|\s)external(\s|$)/i.test(o)) return A;
162
162
  let s, c;
163
163
  try {
164
164
  c = new URL(t), s = new URL(i, c);
165
165
  } catch {
166
- return j;
166
+ return A;
167
167
  }
168
- return s.origin !== c.origin || s.pathname === c.pathname && s.search === c.search && s.hash !== "" ? j : {
168
+ return s.origin !== c.origin || s.pathname === c.pathname && s.search === c.search && s.hash !== "" ? A : {
169
169
  kind: "spa",
170
170
  to: s.pathname + s.search + s.hash
171
171
  };
172
- }, M = (e) => {
172
+ }, j = (e) => {
173
173
  let t = e.replace(/^#/, "");
174
174
  try {
175
175
  return decodeURIComponent(t);
176
176
  } catch {
177
177
  return t;
178
178
  }
179
- }, N = (e) => {
180
- let t = M(e);
179
+ }, M = (e) => {
180
+ let t = j(e);
181
181
  return t ? document.getElementById(t) ?? document.getElementsByName(t)[0] ?? null : null;
182
- }, fe = (e) => {
182
+ }, pe = (e) => {
183
183
  if (typeof window.requestAnimationFrame == "function") {
184
184
  window.requestAnimationFrame(e);
185
185
  return;
186
186
  }
187
187
  window.setTimeout(e, 0);
188
- }, pe = (e) => {
188
+ }, me = (e) => {
189
189
  if (!e.hash) {
190
190
  window.scrollTo(0, 0);
191
191
  return;
192
192
  }
193
- fe(() => {
194
- let t = N(e.hash);
193
+ pe(() => {
194
+ let t = M(e.hash);
195
195
  if (t) {
196
196
  t.scrollIntoView();
197
197
  return;
198
198
  }
199
199
  window.scrollTo(0, 0);
200
200
  });
201
- }, P = 0, me = () => {
201
+ }, N = 0, he = () => {
202
202
  let e = typeof crypto < "u" ? crypto : void 0;
203
- return e && typeof e.randomUUID == "function" ? e.randomUUID() : (P += 1, `k${Date.now().toString(36)}-${P}`);
204
- }, F = e("router", null), I = () => {
205
- let e = c(F);
203
+ return e && typeof e.randomUUID == "function" ? e.randomUUID() : (N += 1, `k${Date.now().toString(36)}-${N}`);
204
+ }, P = e("router", null), F = () => {
205
+ let e = c(P);
206
206
  if (!e) throw Error("Router hooks must be used inside <Router>.");
207
207
  return e;
208
- }, L = Symbol.for("@voltro/web/loaderData:absent"), R = e("loaderData", L), he = (e, t) => {
208
+ }, I = Symbol.for("@voltro/web/loaderData:absent"), L = e("loaderData", I), ge = (e, t) => {
209
209
  if (!e || e.pathname !== t) return;
210
210
  let n = {};
211
211
  for (let [t, r] of e.segments) n[t] = r;
@@ -213,16 +213,16 @@ var h = {
213
213
  page: e.page,
214
214
  segments: n
215
215
  };
216
- }, ge = (e, t) => {
216
+ }, _e = (e, t) => {
217
217
  if (e === t) return !0;
218
218
  if (!e || !t || !Object.is(e.page, t.page)) return !1;
219
219
  let n = Object.keys(e.segments), r = Object.keys(t.segments);
220
220
  return n.length === r.length && n.every((n) => Object.is(e.segments[Number(n)], t.segments[Number(n)]));
221
- }, _e = () => {
221
+ }, ve = () => {
222
222
  if (typeof document > "u") return;
223
223
  let e = document.cookie.match(/(?:^|;\s*)voltro:locale=([^;]*)/);
224
224
  return e ? decodeURIComponent(e[1]) : void 0;
225
- }, ve = (e) => {
225
+ }, ye = (e) => {
226
226
  if (e === null || typeof document > "u") return () => {};
227
227
  let t = document.title, n = [], r = [], i = [], a = [], o = [];
228
228
  typeof e.title == "string" && (document.title = e.title);
@@ -257,7 +257,7 @@ var h = {
257
257
  }
258
258
  if (e.jsonLd) for (let t of e.jsonLd) {
259
259
  let e = document.createElement("script");
260
- e.type = "application/ld+json", e.setAttribute("data-voltro-page-jsonld", ""), e.textContent = ye(t), document.head.appendChild(e), o.push(e);
260
+ e.type = "application/ld+json", e.setAttribute("data-voltro-page-jsonld", ""), e.textContent = be(t), document.head.appendChild(e), o.push(e);
261
261
  }
262
262
  return () => {
263
263
  document.title = t;
@@ -267,7 +267,7 @@ var h = {
267
267
  for (let { el: e, previous: t } of r) e.content = t;
268
268
  for (let { el: e, previous: t } of a) e.href = t;
269
269
  };
270
- }, ye = (e) => JSON.stringify(e).replace(/<\/(script)/gi, "<\\/$1").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"), z = class extends o {
270
+ }, be = (e) => JSON.stringify(e).replace(/<\/(script)/gi, "<\\/$1").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"), xe = class extends o {
271
271
  state = { error: null };
272
272
  static getDerivedStateFromError(e) {
273
273
  return { error: e };
@@ -291,9 +291,9 @@ var h = {
291
291
  }
292
292
  return this.props.children;
293
293
  }
294
- }, B = "data-voltro-page-slot", be = () => /* @__PURE__ */ p("div", { [B]: "" }), V = ({ routes: e, notFounds: i = [], notFound: o = n, errorFallback: c = r }) => {
295
- let [m, h] = f(() => window.location.pathname), [g, te] = f(() => window.location.pathname), [_, v] = f(() => window.location.search + window.location.hash), y = _.split("#")[0] ?? "", b = d(new ue()), x = d(/* @__PURE__ */ new Map()), [C, w] = f(null), re = s((e, t) => (x.current.set(e, t), () => {
296
- x.current.delete(e);
294
+ }, R = "data-voltro-page-slot", Se = () => /* @__PURE__ */ p("div", { [R]: "" }), Ce = ({ routes: e, notFounds: i = [], notFound: o = n, errorFallback: c = r }) => {
295
+ let [m, h] = f(() => window.location.pathname), [g, _] = f(() => window.location.pathname), [v, y] = f(() => window.location.search + window.location.hash), b = v.split("#")[0] ?? "", x = d(new de()), S = d(/* @__PURE__ */ new Map()), [ne, w] = f(null), re = s((e, t) => (S.current.set(e, t), () => {
296
+ S.current.delete(e);
297
297
  }), []), T = d(/* @__PURE__ */ new Map()), E = d(null), D = u(() => ae(e.map(ie)), [e]);
298
298
  l(() => {
299
299
  if (typeof window > "u") return;
@@ -303,35 +303,35 @@ var h = {
303
303
  } catch {}
304
304
  return window.history.state?.__vwebKey || window.history.replaceState({
305
305
  ...window.history.state,
306
- __vwebKey: me()
306
+ __vwebKey: he()
307
307
  }, ""), () => {
308
308
  try {
309
309
  window.history.scrollRestoration = e;
310
310
  } catch {}
311
311
  };
312
312
  }, []);
313
- let j = () => window.history.state?.__vwebKey ?? "initial";
313
+ let A = () => window.history.state?.__vwebKey ?? "initial";
314
314
  l(() => {
315
315
  let e = () => {
316
- let e = T.current.get(j());
316
+ let e = T.current.get(A());
317
317
  E.current = e ?? {
318
318
  x: 0,
319
319
  y: 0
320
- }, h(window.location.pathname), v(window.location.search + window.location.hash);
320
+ }, h(window.location.pathname), y(window.location.search + window.location.hash);
321
321
  };
322
322
  return window.addEventListener("popstate", e), () => window.removeEventListener("popstate", e);
323
323
  }, []);
324
- let M = s((e, t, n) => {
325
- T.current.set(j(), {
324
+ let j = s((e, t, n) => {
325
+ T.current.set(A(), {
326
326
  x: window.scrollX,
327
327
  y: window.scrollY
328
328
  });
329
- let r = { __vwebKey: me() };
330
- n?.replace ? window.history.replaceState(r, "", e) : window.history.pushState(r, "", e), h(t.pathname), v(t.search + t.hash), n?.scroll !== !1 && pe(t);
331
- }, []), N = s((e, t) => {
329
+ let r = { __vwebKey: he() };
330
+ n?.replace ? window.history.replaceState(r, "", e) : window.history.pushState(r, "", e), h(t.pathname), y(t.search + t.hash), n?.scroll !== !1 && me(t);
331
+ }, []), M = s((e, t) => {
332
332
  let n = new URL(window.location.href), r = new URL(e, n);
333
333
  if (!(r.pathname === n.pathname && r.search === n.search && r.hash === n.hash)) {
334
- for (let n of x.current.values()) if (n({
334
+ for (let n of S.current.values()) if (n({
335
335
  to: e,
336
336
  ...t ? { opts: t } : {}
337
337
  })) {
@@ -339,108 +339,115 @@ var h = {
339
339
  to: e,
340
340
  ...t ? { opts: t } : {},
341
341
  retry: () => {
342
- w(null), M(e, r, t);
342
+ w(null), j(e, r, t);
343
343
  },
344
344
  reset: () => w(null)
345
345
  });
346
346
  return;
347
347
  }
348
- M(e, r, t);
348
+ j(e, r, t);
349
349
  }
350
- }, [M]);
350
+ }, [j]);
351
351
  l(() => {
352
352
  if (typeof document > "u") return;
353
353
  let e = (e) => {
354
- let t = de(e, window.location.href);
355
- t.kind === "spa" && (e.preventDefault(), N(t.to));
354
+ let t = fe(e, window.location.href);
355
+ t.kind === "spa" && (e.preventDefault(), M(t.to));
356
356
  };
357
357
  return document.addEventListener("click", e), () => document.removeEventListener("click", e);
358
- }, [N]);
359
- let P = u(() => O(D, m), [D, m]), F = d(/* @__PURE__ */ new Map()), [I, ye] = f(0);
358
+ }, [M]);
359
+ let N = u(() => O(D, m), [D, m]), P = d(/* @__PURE__ */ new Map()), [F, be] = f(0);
360
360
  l(() => {
361
- let e = P?.route;
362
- if (!e?.load || F.current.has(e.pattern)) return;
361
+ let e = N?.route;
362
+ if (!e?.load || P.current.has(e.pattern)) return;
363
363
  let t = !1;
364
364
  return e.load().then((n) => {
365
- t || (F.current.set(e.pattern, n), ye((e) => e + 1));
365
+ t || (P.current.set(e.pattern, n), be((e) => e + 1));
366
366
  }).catch(() => {}), () => {
367
367
  t = !0;
368
368
  };
369
- }, [P?.route.load ? P.route.pattern : null]);
370
- let B = u(() => {
371
- if (!P) return null;
372
- let e = P.route;
369
+ }, [N?.route.load ? N.route.pattern : null]);
370
+ let R = d(/* @__PURE__ */ new Set()), Ce = s((e) => {
371
+ let t = e.load;
372
+ t && (P.current.has(e.pattern) || R.current.has(e.pattern) || (R.current.add(e.pattern), t().then((t) => {
373
+ P.current.set(e.pattern, t);
374
+ }).catch(() => {
375
+ R.current.delete(e.pattern);
376
+ })));
377
+ }, []), z = u(() => {
378
+ if (!N) return null;
379
+ let e = N.route;
373
380
  if (!e.load) return e;
374
- let t = F.current.get(e.pattern);
381
+ let t = P.current.get(e.pattern);
375
382
  return t ? {
376
383
  ...e,
377
- ...Z(t),
384
+ ...Ne(t),
378
385
  load: void 0
379
386
  } : null;
380
- }, [P, I]), V = u(() => O(D, g), [D, g]), H = u(() => {
381
- if (!V) return null;
382
- let e = V.route;
387
+ }, [N, F]), B = u(() => O(D, g), [D, g]), V = u(() => {
388
+ if (!B) return null;
389
+ let e = B.route;
383
390
  if (!e.load) return e;
384
- let t = F.current.get(e.pattern);
391
+ let t = P.current.get(e.pattern);
385
392
  return t ? {
386
393
  ...e,
387
- ...Z(t),
394
+ ...Ne(t),
388
395
  load: void 0
389
396
  } : null;
390
- }, [V, I]), Se = s((e) => {
397
+ }, [B, F]), H = s((e) => {
391
398
  let t = new URL(e, window.location.origin), n = O(D, t.pathname);
392
399
  if (!n) return;
393
400
  let r = (e, r) => {
394
- b.current.start(e, (e) => A(r, {
401
+ x.current.start(e, (e) => se(r, {
395
402
  params: n.params,
396
403
  pathname: t.pathname,
397
404
  search: t.search,
398
405
  signal: e
399
406
  }));
400
407
  };
401
- n.route.loader && r(k(n.route.pattern, n.params), n.route.loader), n.route.chain?.forEach((e, t) => {
408
+ Ce(n.route), n.route.loader && r(k(n.route.pattern, n.params), n.route.loader), n.route.chain?.forEach((e, t) => {
402
409
  e.loader && r(oe(n.route.pattern, t, n.params), e.loader);
403
410
  });
404
- }, [D]), [U, W] = f({ status: "idle" }), G = d(void 0);
411
+ }, [D, Ce]), [U, W] = f({ status: "idle" }), G = d(void 0);
405
412
  G.current === void 0 && (G.current = a());
406
- let Te = d(!1), [Ee, De] = f(() => G.current?.pageClientOnly === !0 && G.current.pathname === m);
413
+ let K = d(!1), [De, Oe] = f(() => G.current?.pageClientOnly === !0 && G.current.pathname === m);
407
414
  l(() => {
408
- De(!1);
415
+ Oe(!1);
409
416
  }, []);
410
- let [K, Oe] = f(() => ({
417
+ let [q, ke] = f(() => ({
411
418
  pathname: m,
412
- data: he(G.current ?? null, m),
413
- chain: P?.route.chain
419
+ data: ge(G.current ?? null, m),
420
+ chain: N?.route.chain
414
421
  }));
415
422
  l(() => {
416
423
  let e = (e) => {
417
- te(m), Oe((t) => t.pathname === m && ge(t.data, e) ? t : {
424
+ _(m), ke((t) => t.pathname === m && _e(t.data, e) ? t : {
418
425
  pathname: m,
419
426
  data: e,
420
- chain: P?.route.chain
427
+ chain: N?.route.chain
421
428
  });
422
429
  };
423
- if (!P) {
430
+ if (!N) {
424
431
  W({ status: "idle" }), e(void 0);
425
432
  return;
426
433
  }
427
- if (!B) {
434
+ if (!z) {
428
435
  W({
429
436
  status: "pending",
430
- key: k(P.route.pattern, P.params)
437
+ key: k(N.route.pattern, N.params)
431
438
  });
432
439
  return;
433
440
  }
434
- let t = B, { params: n } = P, r = t.chain, i = (t.Pending ?? le(r, "Pending", r ? r.length - 1 : -1)) !== void 0, a = [];
441
+ let t = z, { params: n } = N, r = t.chain, i = (t.Pending ?? ue(r, "Pending", r ? r.length - 1 : -1)) !== void 0, a = [];
435
442
  if (t.loader) {
436
443
  let e = t.loader;
437
444
  a.push({
438
445
  cacheKey: k(t.pattern, n),
439
446
  target: "page",
440
- run: (t) => A(e, {
447
+ run: (t) => se(e, {
441
448
  params: n,
442
449
  pathname: m,
443
- search: y,
450
+ search: b,
444
451
  signal: t
445
452
  })
446
453
  });
@@ -451,10 +458,10 @@ var h = {
451
458
  a.push({
452
459
  cacheKey: oe(t.pattern, r, n),
453
460
  target: r,
454
- run: (e) => A(i, {
461
+ run: (e) => se(i, {
455
462
  params: n,
456
463
  pathname: m,
457
- search: y,
464
+ search: b,
458
465
  signal: e
459
466
  })
460
467
  });
@@ -464,17 +471,17 @@ var h = {
464
471
  return;
465
472
  }
466
473
  let o = k(t.pattern, n), s = G.current;
467
- if (s && !Te.current && m === s.pathname) {
468
- Te.current = !0;
469
- for (let e of a) e.target === "page" ? s.pageRan && b.current.seed(e.cacheKey, s.page) : s.segments.has(e.target) && b.current.seed(e.cacheKey, s.segments.get(e.target));
474
+ if (s && !K.current && m === s.pathname) {
475
+ K.current = !0;
476
+ for (let e of a) e.target === "page" ? s.pageRan && x.current.seed(e.cacheKey, s.page) : s.segments.has(e.target) && x.current.seed(e.cacheKey, s.segments.get(e.target));
470
477
  }
471
478
  let c = a.map((e) => ({
472
479
  spec: e,
473
- entry: b.current.start(e.cacheKey, e.run)
480
+ entry: x.current.start(e.cacheKey, e.run)
474
481
  })), l = () => {
475
482
  let e = {}, t;
476
483
  for (let { spec: n } of c) {
477
- let r = b.current.get(n.cacheKey);
484
+ let r = x.current.get(n.cacheKey);
478
485
  if (!r || r.status === "pending") return null;
479
486
  if (r.status === "error") return {
480
487
  ok: !1,
@@ -499,13 +506,13 @@ var h = {
499
506
  status: "error",
500
507
  key: o,
501
508
  error: u.error
502
- }), S(u.error) || e(void 0));
509
+ }), C(u.error) || e(void 0));
503
510
  return;
504
511
  }
505
512
  W({
506
513
  status: "pending",
507
514
  key: o
508
- }), i && te(m);
515
+ }), i && _(m);
509
516
  let d = !1, f = c.map(({ entry: e }) => e.status === "pending" ? e.promise : Promise.resolve());
510
517
  return Promise.all(f).then(() => {
511
518
  if (d) return;
@@ -518,62 +525,62 @@ var h = {
518
525
  status: "error",
519
526
  key: o,
520
527
  error: t.error
521
- }), S(t.error) || e(void 0)));
528
+ }), C(t.error) || e(void 0)));
522
529
  }), () => {
523
530
  d = !0;
524
531
  };
525
532
  }, [
526
- P,
527
- B,
533
+ N,
534
+ z,
528
535
  m
529
536
  ]);
530
- let q = K.data?.page, J = g === m, ke = K.pathname === g, Ae = ke ? K.data?.page : void 0, je = H?.loader === void 0 ? L : Ae, Y = _e(), X = u(() => {
531
- if (!V) return null;
532
- let e = V.params.locale ?? Y;
533
- return se(H?.meta, V.params, q, e);
537
+ let J = q.data?.page, Y = g === m, Ae = q.pathname === g, je = Ae ? q.data?.page : void 0, Me = V?.loader === void 0 ? I : je, Pe = ve(), X = u(() => {
538
+ if (!B) return null;
539
+ let e = B.params.locale ?? Pe;
540
+ return ce(V?.meta, B.params, J, e);
534
541
  }, [
542
+ B,
535
543
  V,
536
- H,
537
- q,
538
- Y
544
+ J,
545
+ Pe
539
546
  ]);
540
- l(() => ve(X), [X]);
541
- let [Me, Ne] = f(""), Pe = d(!1), [Q, Fe] = f(!1);
547
+ l(() => ye(X), [X]);
548
+ let [Fe, Z] = f(""), Q = d(!1), [Ie, Le] = f(!1);
542
549
  l(() => {
543
- if (!Pe.current) {
544
- Pe.current = !0, Fe(!0);
550
+ if (!Q.current) {
551
+ Q.current = !0, Le(!0);
545
552
  return;
546
553
  }
547
554
  let e = X?.title ?? (typeof document < "u" ? document.title : "");
548
- Ne(e && e.length > 0 ? e : g);
555
+ Z(e && e.length > 0 ? e : g);
549
556
  }, [g, X]), l(() => {
550
557
  let e = E.current;
551
- e && (E.current = null, fe(() => window.scrollTo(e.x, e.y)));
558
+ e && (E.current = null, pe(() => window.scrollTo(e.x, e.y)));
552
559
  }, [g]);
553
- let Ie = u(() => ({
560
+ let Re = u(() => ({
554
561
  pathname: g,
555
- search: _,
556
- navigate: N,
557
- params: V?.params ?? {},
558
- prefetch: Se,
559
- loaderData: q,
562
+ search: v,
563
+ navigate: M,
564
+ params: B?.params ?? {},
565
+ prefetch: H,
566
+ loaderData: J,
560
567
  registerBlocker: re,
561
- blocked: C
568
+ blocked: ne
562
569
  }), [
563
570
  g,
564
- _,
565
- N,
566
- V,
567
- Se,
568
- q,
571
+ v,
572
+ M,
573
+ B,
574
+ H,
575
+ J,
569
576
  re,
570
- C
577
+ ne
571
578
  ]);
572
579
  l(() => {
573
580
  if (typeof window > "u") return;
574
581
  let e = (e) => {
575
582
  let t = !1;
576
- for (let e of x.current.values()) if (e({ to: window.location.pathname })) {
583
+ for (let e of S.current.values()) if (e({ to: window.location.pathname })) {
577
584
  t = !0;
578
585
  break;
579
586
  }
@@ -583,13 +590,13 @@ var h = {
583
590
  }, []), l(() => {
584
591
  ee({
585
592
  pathname: g,
586
- params: V?.params ?? {},
587
- loaderData: q
593
+ params: B?.params ?? {},
594
+ loaderData: J
588
595
  });
589
596
  }, [
590
597
  g,
591
- V,
592
- q
598
+ B,
599
+ J
593
600
  ]), l(() => {
594
601
  if (U.status === "pending") return t({
595
602
  id: "voltro:router:loader",
@@ -603,71 +610,71 @@ var h = {
603
610
  label: "Loader failed"
604
611
  });
605
612
  }, [U.status]), l(() => {
606
- U.status === "error" && S(U.error) && N(U.error.location, { replace: !0 });
607
- }, [U, N]);
608
- let Le = () => {
609
- let e = ce(i, g);
613
+ U.status === "error" && C(U.error) && M(U.error.location, { replace: !0 });
614
+ }, [U, M]);
615
+ let ze = () => {
616
+ let e = le(i, g);
610
617
  if (e) {
611
618
  let { Component: t, chain: n } = e;
612
- return we(n, /* @__PURE__ */ p(t, {}), g, c);
619
+ return Ee(n, /* @__PURE__ */ p(t, {}), g, c);
613
620
  }
614
621
  return /* @__PURE__ */ p(o, {});
615
- }, Re = J && V && U.status === "error" ? U.error : void 0, $;
616
- if (!V) $ = Le();
617
- else if (ne(Re)) $ = Le();
622
+ }, Be = Y && B && U.status === "error" ? U.error : void 0, $;
623
+ if (!B) $ = ze();
624
+ else if (te(Be)) $ = ze();
618
625
  else {
619
- let e = V.route.chain, t = e ? e.length - 1 : -1, n = H?.ErrorBoundary ?? le(e, "Error", t) ?? c, r;
620
- if (Ee) r = /* @__PURE__ */ p(be, {});
621
- else if (J && U.status === "error" && !S(U.error)) r = /* @__PURE__ */ p(n, {
626
+ let e = B.route.chain, t = e ? e.length - 1 : -1, n = V?.ErrorBoundary ?? ue(e, "Error", t) ?? c, r;
627
+ if (De) r = /* @__PURE__ */ p(Se, {});
628
+ else if (Y && U.status === "error" && !C(U.error)) r = /* @__PURE__ */ p(n, {
622
629
  error: U.error,
623
630
  reset: () => {
624
- b.current.invalidate(V.route.pattern), h((e) => e), W({ status: "idle" });
631
+ x.current.invalidate(B.route.pattern), h((e) => e), W({ status: "idle" });
625
632
  }
626
633
  });
627
- else if (J && U.status === "pending") {
628
- let i = H?.Pending ?? le(e, "Pending", t);
634
+ else if (Y && U.status === "pending") {
635
+ let i = V?.Pending ?? ue(e, "Pending", t);
629
636
  if (i) r = /* @__PURE__ */ p(i, {});
630
- else if (H?.Component) {
631
- let e = H.Component;
632
- r = /* @__PURE__ */ p(z, {
637
+ else if (V?.Component) {
638
+ let e = V.Component;
639
+ r = /* @__PURE__ */ p(xe, {
633
640
  resetKey: g,
634
641
  Fallback: n,
635
- children: /* @__PURE__ */ p(R.Provider, {
636
- value: je,
642
+ children: /* @__PURE__ */ p(L.Provider, {
643
+ value: Me,
637
644
  children: /* @__PURE__ */ p(e, {})
638
645
  })
639
646
  });
640
647
  } else r = null;
641
648
  } else {
642
- let e = H?.Component;
643
- r = e ? /* @__PURE__ */ p(z, {
649
+ let e = V?.Component;
650
+ r = e ? /* @__PURE__ */ p(xe, {
644
651
  resetKey: g,
645
652
  Fallback: n,
646
- children: /* @__PURE__ */ p(R.Provider, {
647
- value: je,
653
+ children: /* @__PURE__ */ p(L.Provider, {
654
+ value: Me,
648
655
  children: /* @__PURE__ */ p(e, {})
649
656
  })
650
657
  }) : null;
651
658
  }
652
- $ = we(e, r, g, c, (t) => {
653
- if (ke) return K.data?.segments[t];
659
+ $ = Ee(e, r, g, c, (t) => {
660
+ if (Ae) return q.data?.segments[t];
654
661
  let n = e?.[t]?.Layout;
655
- return n !== void 0 && n === K.chain?.[t]?.Layout ? K.data?.segments[t] : void 0;
662
+ return n !== void 0 && n === q.chain?.[t]?.Layout ? q.data?.segments[t] : void 0;
656
663
  });
657
664
  }
658
- return /* @__PURE__ */ p(xe, {
659
- value: Ie,
660
- announcer: Q ? /* @__PURE__ */ p(Ce, { message: Me }) : null,
665
+ return /* @__PURE__ */ p(we, {
666
+ value: Re,
667
+ announcer: Ie ? /* @__PURE__ */ p(Te, { message: Fe }) : null,
661
668
  children: $
662
669
  });
663
- }, xe = ({ value: e, announcer: t, children: n }) => /* @__PURE__ */ m(F.Provider, {
670
+ }, we = ({ value: e, announcer: t, children: n }) => /* @__PURE__ */ m(P.Provider, {
664
671
  value: e,
665
672
  children: [n, t]
666
- }), H = (e, t) => /* @__PURE__ */ p(xe, {
673
+ }), z = (e, t) => /* @__PURE__ */ p(we, {
667
674
  value: e,
668
675
  announcer: null,
669
676
  children: t
670
- }), Se = {
677
+ }), B = {
671
678
  position: "absolute",
672
679
  width: 1,
673
680
  height: 1,
@@ -677,28 +684,28 @@ var h = {
677
684
  clip: "rect(0, 0, 0, 0)",
678
685
  whiteSpace: "nowrap",
679
686
  border: 0
680
- }, Ce = ({ message: e }) => /* @__PURE__ */ p("div", {
687
+ }, Te = ({ message: e }) => /* @__PURE__ */ p("div", {
681
688
  "data-vweb-route-announcer": "",
682
689
  role: "status",
683
690
  "aria-live": "assertive",
684
691
  "aria-atomic": "true",
685
- style: Se,
692
+ style: B,
686
693
  children: e
687
- }), we = (e, t, n, r, i) => {
694
+ }), Ee = (e, t, n, r, i) => {
688
695
  if (!e || e.length === 0) return t;
689
696
  let a = t;
690
697
  for (let t = e.length - 1; t >= 0; t--) {
691
698
  let r = e[t];
692
699
  if (r.Layout) {
693
700
  let e = r.Layout;
694
- a = /* @__PURE__ */ p(R.Provider, {
695
- value: r.loader === void 0 ? L : i?.(t),
701
+ a = /* @__PURE__ */ p(L.Provider, {
702
+ value: r.loader === void 0 ? I : i?.(t),
696
703
  children: /* @__PURE__ */ p(e, { children: a })
697
704
  });
698
705
  }
699
706
  if (r.Error) {
700
707
  let e = r.Error;
701
- a = /* @__PURE__ */ p(z, {
708
+ a = /* @__PURE__ */ p(xe, {
702
709
  resetKey: n,
703
710
  Fallback: e,
704
711
  children: a
@@ -706,15 +713,15 @@ var h = {
706
713
  }
707
714
  }
708
715
  return a;
709
- }, U = () => I().pathname, W = () => I().navigate, G = () => I().params, Te = () => {
710
- let e = c(R);
711
- if (e === L) throw Error("useLoaderData() was called at a level that declares no `loader`. Export `loader` from this page/layout, or — if this component is shared between routes that have one and routes that do not — read it with `useOptionalLoaderData()`, which returns `undefined` here instead of throwing. The React component stack below names the component.");
716
+ }, V = () => F().pathname, H = () => F().navigate, U = () => F().params, W = () => {
717
+ let e = c(L);
718
+ if (e === I) throw Error("useLoaderData() was called at a level that declares no `loader`. Export `loader` from this page/layout, or — if this component is shared between routes that have one and routes that do not — read it with `useOptionalLoaderData()`, which returns `undefined` here instead of throwing. The React component stack below names the component.");
712
719
  return e;
713
- }, Ee = () => {
714
- let e = c(R);
715
- return e === L ? void 0 : e;
716
- }, De = () => I().prefetch, K = (e) => {
717
- let { registerBlocker: t, blocked: n } = I(), r = d(Symbol("voltro:blocker")), i = d(e);
720
+ }, G = () => {
721
+ let e = c(L);
722
+ return e === I ? void 0 : e;
723
+ }, K = () => F().prefetch, De = (e) => {
724
+ let { registerBlocker: t, blocked: n } = F(), r = d(Symbol("voltro:blocker")), i = d(e);
718
725
  return i.current = e, l(() => {
719
726
  let e = r.current;
720
727
  return t(e, (e) => {
@@ -728,7 +735,7 @@ var h = {
728
735
  reset: n.reset
729
736
  } : { blocked: !1 };
730
737
  }, Oe = (e) => e instanceof URLSearchParams ? e : new URLSearchParams(e), q = () => {
731
- let { navigate: e } = I();
738
+ let { navigate: e } = F();
732
739
  return s((t, n) => {
733
740
  let r = new URLSearchParams(typeof window < "u" ? window.location.search : ""), i = Oe(typeof t == "function" ? t(r) : t).toString(), a = typeof window < "u" ? window.location.pathname : "/", o = i ? `${a}?${i}` : a;
734
741
  e(o, {
@@ -736,31 +743,49 @@ var h = {
736
743
  ...n?.scroll === void 0 ? {} : { scroll: n.scroll }
737
744
  });
738
745
  }, [e]);
739
- }, J = (e) => e, ke = (e, t) => {
746
+ }, ke = (e) => e, J = (e, t) => {
740
747
  let n = new URLSearchParams();
741
748
  for (let [e, r] of Object.entries(t)) r !== void 0 && n.append(e, String(r));
742
749
  let r = n.toString();
743
750
  return r ? `${e}?${r}` : e;
744
- }, Ae = (e, t) => `${e}#${t.replace(/^#/, "")}`, je = (e) => /^([a-z][a-z0-9+.-]*:|\/\/|#)/i.test(e), Y = ({ to: e, children: t, onClick: n, prefetch: r = !1, replace: i = !1, onMouseEnter: a, onFocus: o, ...s }) => {
745
- let c = W(), l = De(), u = je(e), d = (t) => {
746
- u || t.metaKey || t.ctrlKey || t.shiftKey || t.altKey || t.button !== 0 || (t.preventDefault(), n?.(t), c(e, i ? { replace: i } : void 0));
747
- }, f = (t) => {
748
- r && !u && l(e), a?.(t);
749
- }, m = (t) => {
750
- r && !u && l(e), o?.(t);
751
+ }, Y = (e, t) => `${e}#${t.replace(/^#/, "")}`, Ae = (e) => /^([a-z][a-z0-9+.-]*:|\/\/|#)/i.test(e), je = ({ to: e, children: t, onClick: n, prefetch: r = !1, replace: i = !1, onMouseEnter: a, onFocus: o, ref: c, ...u }) => {
752
+ let f = H(), m = K(), h = Ae(e), g = d(null), ee = s((e) => {
753
+ g.current = e, typeof c == "function" ? c(e) : c && (c.current = e);
754
+ }, [c]);
755
+ l(() => {
756
+ if (r !== "visible" || h) return;
757
+ let t = g.current;
758
+ if (!t || typeof IntersectionObserver > "u") return;
759
+ let n = new IntersectionObserver((t) => {
760
+ t.some((e) => e.isIntersecting) && (n.disconnect(), m(e));
761
+ }, { rootMargin: "128px" });
762
+ return n.observe(t), () => n.disconnect();
763
+ }, [
764
+ r,
765
+ h,
766
+ e,
767
+ m
768
+ ]);
769
+ let _ = (t) => {
770
+ h || t.metaKey || t.ctrlKey || t.shiftKey || t.altKey || t.button !== 0 || (t.preventDefault(), n?.(t), f(e, i ? { replace: i } : void 0));
771
+ }, v = (t) => {
772
+ r && !h && m(e), a?.(t);
773
+ }, y = (t) => {
774
+ r && !h && m(e), o?.(t);
751
775
  };
752
776
  return /* @__PURE__ */ p("a", {
753
- ...s,
777
+ ...u,
778
+ ref: ee,
754
779
  href: e,
755
- onClick: d,
756
- onMouseEnter: f,
757
- onFocus: m,
780
+ onClick: _,
781
+ onMouseEnter: v,
782
+ onFocus: y,
758
783
  children: t
759
784
  });
760
- }, X = (e) => Y({
785
+ }, Me = (e) => je({
761
786
  ...e,
762
787
  to: e.to
763
- }), Z = (e) => ({
788
+ }), Ne = (e) => ({
764
789
  Component: e.default,
765
790
  meta: e.meta,
766
791
  loader: e.loader,
@@ -768,27 +793,27 @@ var h = {
768
793
  Pending: e.Pending,
769
794
  renderMode: e.renderMode,
770
795
  interactive: e.interactive
771
- }), Me = (e, t, n = {}) => ({
796
+ }), Pe = (e, t, n = {}) => ({
772
797
  pattern: e,
773
- ...Z(t),
798
+ ...Ne(t),
774
799
  chain: n.chain
775
- }), Ne = (e, t, n = {}) => ({
800
+ }), X = (e, t, n = {}) => ({
776
801
  pattern: e,
777
802
  load: t,
778
803
  chain: n.chain
779
- }), Pe = async (e, t) => {
804
+ }), Fe = async (e, t) => {
780
805
  let n = O(e.map(ie), t)?.route.load;
781
806
  if (n) try {
782
807
  await n();
783
808
  } catch {}
784
- }, Q = e("serverRequest", null), Fe = () => c(Q), Ie = () => {
785
- let e = Fe();
809
+ }, Z = e("serverRequest", null), Q = () => c(Z), Ie = () => {
810
+ let e = Q();
786
811
  if (e !== null) {
787
812
  let t = e.url.indexOf("?");
788
813
  return new URLSearchParams(t >= 0 ? e.url.slice(t + 1) : "");
789
814
  }
790
815
  return typeof window < "u" ? new URLSearchParams(window.location.search) : new URLSearchParams();
791
- }, Le = ({ value: e, children: t }) => /* @__PURE__ */ p(Q.Provider, {
816
+ }, Le = ({ value: e, children: t }) => /* @__PURE__ */ p(Z.Provider, {
792
817
  value: e,
793
818
  children: t
794
819
  }), Re = (e) => {
@@ -809,4 +834,4 @@ var h = {
809
834
  return t;
810
835
  };
811
836
  //#endregion
812
- export { Te as A, y as B, Pe as C, oe as D, se as E, De as F, te as G, S as H, q as I, ee as K, Ae as L, W as M, Ee as N, ae as O, G as P, ke as R, Me as S, de as T, b as U, ne as V, x as W, J as _, Fe as a, k as b, R as c, be as d, X as f, ie as g, F as h, Ie as i, U as j, K as k, L as l, V as m, Le as n, Y as o, C as p, _ as q, Re as r, ue as s, Q as t, B as u, ce as v, H as w, O as x, Ne as y, v as z };
837
+ export { W as A, b as B, Fe as C, oe as D, ce as E, K as F, _ as G, C as H, q as I, ee as K, Y as L, H as M, G as N, ae as O, U as P, J as R, Pe as S, fe as T, x as U, te as V, S as W, ke as _, Q as a, k as b, L as c, Se as d, Me as f, ie as g, P as h, Ie as i, V as j, De as k, I as l, Ce as m, Le as n, je as o, ne as p, v as q, Re as r, de as s, Z as t, R as u, le as v, z as w, O as x, X as y, y as z };