@manyducks.co/dolla 2.0.0-alpha.41 → 2.0.0-alpha.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,51 +1,51 @@
1
1
  var zt = Object.defineProperty;
2
- var kt = (i) => {
3
- throw TypeError(i);
2
+ var $t = (a) => {
3
+ throw TypeError(a);
4
4
  };
5
- var Bt = (i, t, e) => t in i ? zt(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
6
- var w = (i, t, e) => Bt(i, typeof t != "symbol" ? t + "" : t, e), mt = (i, t, e) => t.has(i) || kt("Cannot " + e);
7
- var a = (i, t, e) => (mt(i, t, "read from private field"), e ? e.call(i) : t.get(i)), u = (i, t, e) => t.has(i) ? kt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), d = (i, t, e, s) => (mt(i, t, "write to private field"), s ? s.call(i, e) : t.set(i, e), e), f = (i, t, e) => (mt(i, t, "access private method"), e);
8
- var Rt = (i, t, e, s) => ({
9
- set _(n) {
10
- d(i, t, n, e);
5
+ var Bt = (a, t, e) => t in a ? zt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
6
+ var w = (a, t, e) => Bt(a, typeof t != "symbol" ? t + "" : t, e), mt = (a, t, e) => t.has(a) || $t("Cannot " + e);
7
+ var i = (a, t, e) => (mt(a, t, "read from private field"), e ? e.call(a) : t.get(a)), u = (a, t, e) => t.has(a) ? $t("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(a) : t.set(a, e), d = (a, t, e, s) => (mt(a, t, "write to private field"), s ? s.call(a, e) : t.set(a, e), e), f = (a, t, e) => (mt(a, t, "access private method"), e);
8
+ var Rt = (a, t, e, s) => ({
9
+ set _(r) {
10
+ d(a, t, r, e);
11
11
  },
12
12
  get _() {
13
- return a(i, t, s);
13
+ return i(a, t, s);
14
14
  }
15
15
  });
16
- import { a as Kt, b as Ft, i as z, I as Ot, c as Ut, d as U, g as E, s as _t, e as Qt, f as M, h as D, P as jt, j as Jt, t as St, k as Xt, l as Mt, m as xt, S as Yt, n as Tt, o as Nt, p as Zt, V as te, q as ee, r as se, u as re, v as ne } from "./markup-DkQI155j.js";
17
- import { w as Ue, B as je, y as Ce, A as Ie, x as Ve, z as De } from "./markup-DkQI155j.js";
18
- function Ne(i) {
16
+ import { a as Kt, b as Ft, i as H, I as Ot, c as Ut, d as O, s as _t, e as Qt, f as S, g as V, P as jt, h as Jt, t as St, j as lt, k as Xt, l as Mt, m as xt, S as Yt, n as Tt, o as Nt, p as Zt, V as te, q as ee, r as se, u as ne, v as re } from "./markup-DQdkb3ri.js";
17
+ import { w as Ue, z as je, C as Ce, y as Ie, B as Ve, x as De, A as qe } from "./markup-DQdkb3ri.js";
18
+ function Ne(a) {
19
19
  return function() {
20
20
  if (arguments.length === 1)
21
- i = arguments[0];
21
+ a = arguments[0];
22
22
  else if (arguments.length > 1)
23
23
  throw new Error(`Too many arguments. Expected 0 or 1. Got: ${arguments.length}`);
24
- return i;
24
+ return a;
25
25
  };
26
26
  }
27
- function K(i) {
28
- return Ft(i, "Expected `path` to be a string. Got type: %t, value: %v"), i.split("/").map((t) => t.trim()).filter((t) => t !== "");
27
+ function B(a) {
28
+ return Ft(a, "Expected `path` to be a string. Got type: %t, value: %v"), a.split("/").map((t) => t.trim()).filter((t) => t !== "");
29
29
  }
30
- function G(i) {
30
+ function q(a) {
31
31
  var e;
32
32
  Kt(
33
- (s) => z(s == null ? void 0 : s.toString),
34
- i,
33
+ (s) => H(s == null ? void 0 : s.toString),
34
+ a,
35
35
  "Expected `parts` to be an array of objects with a .toString() method. Got type: %t, value: %v"
36
- ), i = i.filter((s) => s).flatMap(String);
37
- let t = (e = i.shift()) == null ? void 0 : e.toString();
36
+ ), a = a.filter((s) => s).flatMap(String);
37
+ let t = (e = a.shift()) == null ? void 0 : e.toString();
38
38
  if (t) {
39
- for (const s of i.map((n) => n.toString()))
39
+ for (const s of a.map((r) => r.toString()))
40
40
  s.startsWith(".") ? t = ct(t, s) : t[t.length - 1] !== "/" ? s[0] !== "/" ? t += "/" + s : t += s : s[0] === "/" ? t += s.slice(1) : t += s;
41
41
  t && t !== "/" && t.endsWith("/") && (t = t.slice(0, t.length - 1));
42
42
  }
43
43
  return t ?? "";
44
44
  }
45
- function ct(i, t) {
46
- if (Ft(i, "Expected `base` to be a string. Got type: %t, value: %v"), t == null && (t = i, i = ""), t.startsWith("/"))
45
+ function ct(a, t) {
46
+ if (Ft(a, "Expected `base` to be a string. Got type: %t, value: %v"), t == null && (t = a, a = ""), t.startsWith("/"))
47
47
  return t;
48
- let e = i;
48
+ let e = a;
49
49
  for (; ; )
50
50
  if (t.startsWith("..")) {
51
51
  for (let s = e.length; s > 0; --s)
@@ -57,71 +57,71 @@ function ct(i, t) {
57
57
  t = t.replace(/^\.\/?/, "");
58
58
  else
59
59
  break;
60
- return G([e, t]);
60
+ return q([e, t]);
61
61
  }
62
- function ae(i) {
63
- if (!i) return {};
64
- i.startsWith("?") && (i = i.slice(1));
65
- const t = i.split("&").filter((e) => e.trim() !== "").map((e) => {
66
- const [s, n] = e.split("=").map((r) => r.trim());
67
- return n.toLowerCase() === "true" ? [s, !0] : n.toLowerCase() === "false" ? [s, !1] : isNaN(Number(n)) ? [s, n] : [s, Number(n)];
62
+ function ae(a) {
63
+ if (!a) return {};
64
+ a.startsWith("?") && (a = a.slice(1));
65
+ const t = a.split("&").filter((e) => e.trim() !== "").map((e) => {
66
+ const [s, r] = e.split("=").map((n) => n.trim());
67
+ return r.toLowerCase() === "true" ? [s, !0] : r.toLowerCase() === "false" ? [s, !1] : isNaN(Number(r)) ? [s, r] : [s, Number(r)];
68
68
  });
69
69
  return Object.fromEntries(t);
70
70
  }
71
- function Ct(i, t, e = {}) {
71
+ function Ct(a, t, e = {}) {
72
72
  var o;
73
- const [s, n] = t.split("?"), r = K(s);
74
- t: for (const c of i) {
73
+ const [s, r] = t.split("?"), n = B(s);
74
+ t: for (const c of a) {
75
75
  const { fragments: l } = c;
76
- if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !== r.length || e.willMatch && !e.willMatch(c))
76
+ if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !== n.length || e.willMatch && !e.willMatch(c))
77
77
  continue t;
78
- const v = [];
78
+ const b = [];
79
79
  e: for (let h = 0; h < l.length; h++) {
80
- const x = r[h], k = l[h];
81
- if (x == null && k.type !== 3)
80
+ const M = n[h], k = l[h];
81
+ if (M == null && k.type !== 3)
82
82
  continue t;
83
83
  switch (k.type) {
84
84
  case 1:
85
- if (k.name.toLowerCase() === x.toLowerCase()) {
86
- v.push(k);
85
+ if (k.name.toLowerCase() === M.toLowerCase()) {
86
+ b.push(k);
87
87
  break;
88
88
  } else
89
89
  continue t;
90
90
  case 2:
91
- v.push({ ...k, value: x });
91
+ b.push({ ...k, value: M });
92
92
  break;
93
93
  case 3:
94
- v.push({ ...k, value: r.slice(h).join("/") });
94
+ b.push({ ...k, value: n.slice(h).join("/") });
95
95
  break e;
96
96
  case 4:
97
- if (isNaN(Number(x)))
97
+ if (isNaN(Number(M)))
98
98
  continue t;
99
- v.push({ ...k, value: Number(x) });
99
+ b.push({ ...k, value: Number(M) });
100
100
  break;
101
101
  default:
102
102
  throw new Error(`Unknown fragment type: ${k.type}`);
103
103
  }
104
104
  }
105
- const $ = {};
106
- for (const h of v)
107
- h.type === 2 && ($[h.name] = decodeURIComponent(h.value)), h.type === 4 && ($[h.name] = h.value), h.type === 3 && ($.wildcard = "/" + decodeURIComponent(h.value));
105
+ const v = {};
106
+ for (const h of b)
107
+ h.type === 2 && (v[h.name] = decodeURIComponent(h.value)), h.type === 4 && (v[h.name] = h.value), h.type === 3 && (v.wildcard = "/" + decodeURIComponent(h.value));
108
108
  return {
109
- path: "/" + v.map((h) => h.value).join("/"),
109
+ path: "/" + b.map((h) => h.value).join("/"),
110
110
  pattern: "/" + l.map((h) => h.type === 2 ? `{${h.name}}` : h.type === 4 ? `{#${h.name}}` : h.name).join("/"),
111
- params: $,
112
- query: ae(n),
111
+ params: v,
112
+ query: ae(r),
113
113
  meta: c.meta
114
114
  };
115
115
  }
116
116
  }
117
- function ie(i) {
118
- const t = [], e = [], s = [], n = [];
119
- for (const o of i) {
117
+ function ie(a) {
118
+ const t = [], e = [], s = [], r = [];
119
+ for (const o of a) {
120
120
  const { fragments: c } = o;
121
121
  c.some(
122
122
  (l) => l.type === 3
123
123
  /* Wildcard */
124
- ) ? n.push(o) : c.some(
124
+ ) ? r.push(o) : c.some(
125
125
  (l) => l.type === 4
126
126
  /* NumericParam */
127
127
  ) ? e.push(o) : c.some(
@@ -129,121 +129,121 @@ function ie(i) {
129
129
  /* Param */
130
130
  ) ? s.push(o) : t.push(o);
131
131
  }
132
- const r = (o, c) => o.fragments.length > c.fragments.length ? -1 : 1;
133
- return t.sort(r), e.sort(r), s.sort(r), n.sort(r), [...t, ...e, ...s, ...n];
132
+ const n = (o, c) => o.fragments.length > c.fragments.length ? -1 : 1;
133
+ return t.sort(n), e.sort(n), s.sort(n), r.sort(n), [...t, ...e, ...s, ...r];
134
134
  }
135
- function oe(i) {
136
- const t = K(i), e = [];
135
+ function oe(a) {
136
+ const t = B(a), e = [];
137
137
  for (let s = 0; s < t.length; s++) {
138
- const n = t[s];
139
- if (n === "*") {
138
+ const r = t[s];
139
+ if (r === "*") {
140
140
  if (s !== t.length - 1)
141
- throw new Error(`Wildcard must be at the end of a pattern. Received: ${i}`);
141
+ throw new Error(`Wildcard must be at the end of a pattern. Received: ${a}`);
142
142
  e.push({
143
143
  type: 3,
144
144
  name: "*",
145
145
  value: null
146
146
  });
147
- } else n.at(0) === "{" && n.at(-1) === "}" ? e.push({
148
- type: n[1] === "#" ? 4 : 2,
149
- name: n[1] === "#" ? n.slice(2, -1) : n.slice(1, -1),
147
+ } else r.at(0) === "{" && r.at(-1) === "}" ? e.push({
148
+ type: r[1] === "#" ? 4 : 2,
149
+ name: r[1] === "#" ? r.slice(2, -1) : r.slice(1, -1),
150
150
  value: null
151
151
  }) : e.push({
152
152
  type: 1,
153
- name: n,
154
- value: n
153
+ name: r,
154
+ value: r
155
155
  });
156
156
  }
157
157
  return e;
158
158
  }
159
- function Pe(i) {
160
- return new he(i);
159
+ function Pe(a) {
160
+ return new he(a);
161
161
  }
162
162
  const It = Symbol.for("DollaRouterMountMethod"), Vt = Symbol.for("DollaRouterUnmountMethod");
163
- function pt(i) {
164
- return (i == null ? void 0 : i[Ot]) === !0;
163
+ function pt(a) {
164
+ return (a == null ? void 0 : a[Ot]) === !0;
165
165
  }
166
- async function le(i, t) {
167
- return i[It](t);
166
+ async function le(a, t) {
167
+ return a[It](t);
168
168
  }
169
- async function ce(i) {
170
- return i[Vt]();
169
+ async function ce(a) {
170
+ return a[Vt]();
171
171
  }
172
- var Lt, Q, S, ht, T, W, J, j, C, N, m, wt, Dt, qt, B, Gt, gt, yt;
172
+ var Lt, K, _, ht, x, G, Q, U, j, T, m, wt, Dt, qt, z, Gt, gt, yt;
173
173
  class he {
174
174
  constructor(t) {
175
175
  u(this, m);
176
176
  w(this, Lt, !0);
177
- u(this, Q);
178
- u(this, S);
177
+ u(this, K);
178
+ u(this, _);
179
179
  u(this, ht, 0);
180
- u(this, T, []);
181
- u(this, W, []);
182
- u(this, J, !1);
180
+ u(this, x, []);
181
+ u(this, G, []);
182
+ u(this, Q, !1);
183
183
  /**
184
184
  * Use hash routing when true. Configured in router options.
185
185
  */
186
- u(this, j, !1);
186
+ u(this, U, !1);
187
187
  // Callbacks that need to be called on unmount.
188
- u(this, C, []);
188
+ u(this, j, []);
189
189
  /**
190
190
  * The current match object.
191
191
  */
192
- u(this, N, Ut());
192
+ u(this, T, Ut());
193
193
  /**
194
194
  * The currently matched route pattern, if any.
195
195
  */
196
- w(this, "pattern", U(() => {
196
+ w(this, "pattern", O(() => {
197
197
  var t;
198
- return (t = E(a(this, N))) == null ? void 0 : t.pattern;
198
+ return (t = i(this, T).get()) == null ? void 0 : t.pattern;
199
199
  }));
200
200
  /**
201
201
  * The current URL path.
202
202
  */
203
- w(this, "path", U(() => {
203
+ w(this, "path", O(() => {
204
204
  var t;
205
- return ((t = E(a(this, N))) == null ? void 0 : t.path) ?? window.location.pathname;
205
+ return ((t = i(this, T).get()) == null ? void 0 : t.path) ?? window.location.pathname;
206
206
  }));
207
207
  /**
208
208
  * The current named path params.
209
209
  */
210
- w(this, "params", U(() => {
210
+ w(this, "params", O(() => {
211
211
  var t;
212
- return ((t = E(a(this, N))) == null ? void 0 : t.params) ?? {};
212
+ return ((t = i(this, T).get()) == null ? void 0 : t.params) ?? {};
213
213
  }, { equals: _t }));
214
214
  /**
215
215
  * The current query params. Changes to this object will be reflected in the URL.
216
216
  */
217
- w(this, "query", U(() => {
217
+ w(this, "query", O(() => {
218
218
  var t;
219
- return ((t = E(a(this, N))) == null ? void 0 : t.query) ?? {};
219
+ return ((t = i(this, T).get()) == null ? void 0 : t.query) ?? {};
220
220
  }, { equals: _t }));
221
- Qt(t, "Options must be an object. Got: %t"), t.hash && d(this, j, !0), d(this, W, ie(
221
+ Qt(t, "Options must be an object. Got: %t"), t.hash && d(this, U, !0), d(this, G, ie(
222
222
  t.routes.flatMap((e) => f(this, m, yt).call(this, e)).map((e) => ({
223
223
  pattern: e.pattern,
224
224
  meta: e.meta,
225
225
  fragments: oe(e.pattern)
226
226
  }))
227
- )), pe(a(this, W));
227
+ )), pe(i(this, G));
228
228
  }
229
229
  async [(Lt = Ot, It)](t) {
230
- d(this, Q, t), d(this, S, t.createLogger("Dolla.router"));
230
+ d(this, K, t), d(this, _, t.createLogger("Dolla.router"));
231
231
  const e = () => {
232
- f(this, m, B).call(this);
232
+ f(this, m, z).call(this);
233
233
  };
234
- window.addEventListener("popstate", e), a(this, C).push(() => window.removeEventListener("popstate", e));
234
+ window.addEventListener("popstate", e), i(this, j).push(() => window.removeEventListener("popstate", e));
235
235
  const s = t.getRootElement();
236
- a(this, C).push(
237
- de(s, (n) => {
238
- let r = n.getAttribute("href");
239
- a(this, S).info("intercepted click on <a> tag", n), /^https?:\/\/|^\//.test(r) || (r = G([window.location.pathname, r])), f(this, m, wt).call(this, r);
236
+ i(this, j).push(
237
+ de(s, (r) => {
238
+ let n = r.getAttribute("href");
239
+ i(this, _).info("intercepted click on <a> tag", r), /^https?:\/\/|^\//.test(n) || (n = q([window.location.pathname, n])), f(this, m, wt).call(this, n);
240
240
  })
241
- ), a(this, S).info("will intercept clicks on <a> tags within root element", s), d(this, J, !0), await f(this, m, B).call(this);
241
+ ), i(this, _).info("will intercept clicks on <a> tags within root element", s), d(this, Q, !0), await f(this, m, z).call(this);
242
242
  }
243
243
  async [Vt]() {
244
- for (const t of a(this, C))
244
+ for (const t of i(this, j))
245
245
  t();
246
- d(this, C, []);
246
+ d(this, j, []);
247
247
  }
248
248
  /**
249
249
  * Navigate backward. Pass a number of steps to hit the back button that many times.
@@ -266,71 +266,83 @@ class he {
266
266
  */
267
267
  go(t, e = {}) {
268
268
  let s;
269
- Array.isArray(t) ? s = G(t) : s = t.toString(), s = ct(window.location.pathname, s), e.preserveQuery && (s += window.location.search), e.replace ? f(this, m, Dt).call(this, s) : f(this, m, wt).call(this, s);
269
+ Array.isArray(t) ? s = q(t) : s = t.toString(), s = ct(window.location.pathname, s), e.preserveQuery && (s += window.location.search), e.replace ? f(this, m, Dt).call(this, s) : f(this, m, wt).call(this, s);
270
270
  }
271
271
  }
272
- Q = new WeakMap(), S = new WeakMap(), ht = new WeakMap(), T = new WeakMap(), W = new WeakMap(), J = new WeakMap(), j = new WeakMap(), C = new WeakMap(), N = new WeakMap(), m = new WeakSet(), wt = function(t, e) {
272
+ K = new WeakMap(), _ = new WeakMap(), ht = new WeakMap(), x = new WeakMap(), G = new WeakMap(), Q = new WeakMap(), U = new WeakMap(), j = new WeakMap(), T = new WeakMap(), m = new WeakSet(), wt = function(t, e) {
273
273
  var s;
274
- (s = a(this, S)) == null || s.info("(push)", t), window.history.pushState(e, "", a(this, j) ? "/#" + t : t), f(this, m, B).call(this, t);
274
+ (s = i(this, _)) == null || s.info("(push)", t), window.history.pushState(e, "", i(this, U) ? "/#" + t : t), f(this, m, z).call(this, t);
275
275
  }, Dt = function(t, e) {
276
276
  var s;
277
- (s = a(this, S)) == null || s.info("(replace)", t), window.history.replaceState(e, "", a(this, j) ? "/#" + t : t), f(this, m, B).call(this, t);
277
+ (s = i(this, _)) == null || s.info("(replace)", t), window.history.replaceState(e, "", i(this, U) ? "/#" + t : t), f(this, m, z).call(this, t);
278
278
  }, qt = function() {
279
- return a(this, j) ? new URL(window.location.hash.slice(1), window.location.origin) : new URL(window.location.pathname, window.location.origin);
280
- }, B = async function(t) {
279
+ return i(this, U) ? new URL(window.location.hash.slice(1), window.location.origin) : new URL(window.location.pathname, window.location.origin);
280
+ }, z = async function(t) {
281
281
  var c;
282
- const e = a(this, S), s = (c = a(this, Q)) == null ? void 0 : c.getRootView(), n = t ? new URL(t, window.location.origin) : f(this, m, qt).call(this), { match: r, journey: o } = await f(this, m, gt).call(this, n);
283
- if (r) {
284
- const l = this.pattern.value;
285
- a(this, N).value = r, s && r.pattern !== l && f(this, m, Gt).call(this, s, r);
282
+ const e = i(this, _), s = (c = i(this, K)) == null ? void 0 : c.getRootView(), r = t ? new URL(t, window.location.origin) : f(this, m, qt).call(this), { match: n, journey: o } = await f(this, m, gt).call(this, r);
283
+ for (const l of o)
284
+ switch (l.kind) {
285
+ case "match":
286
+ e == null || e.info(`📍 ${l.message}`);
287
+ break;
288
+ case "redirect":
289
+ e == null || e.info(`↩️ ${l.message}`);
290
+ break;
291
+ case "miss":
292
+ e == null || e.info(`💀 ${l.message}`);
293
+ break;
294
+ }
295
+ if (n) {
296
+ const l = this.pattern.peek();
297
+ i(this, T).set(n), s && n.pattern !== l && f(this, m, Gt).call(this, s, n);
286
298
  } else
287
- a(this, J) && e.crash(new we(`Failed to match route '${n.pathname}'`));
288
- return { match: r, journey: o };
299
+ i(this, Q) && e.crash(new we(`Failed to match route '${r.pathname}'`));
300
+ return { match: n, journey: o };
289
301
  }, /**
290
302
  * Takes a matched route and mounts it.
291
303
  */
292
304
  Gt = function(t, e) {
293
305
  const s = e.meta.layers;
294
- for (let n = 0; n < s.length; n++) {
295
- const r = s[n], o = a(this, T)[n];
296
- if ((o == null ? void 0 : o.id) !== r.id) {
297
- d(this, T, a(this, T).slice(0, n)), o == null || o.view.unmount();
298
- const c = a(this, T).at(-1), p = ((c == null ? void 0 : c.view) ?? t).setChildView(r.view);
299
- a(this, T).push({ id: r.id, view: p });
306
+ for (let r = 0; r < s.length; r++) {
307
+ const n = s[r], o = i(this, x)[r];
308
+ if ((o == null ? void 0 : o.id) !== n.id) {
309
+ d(this, x, i(this, x).slice(0, r)), o == null || o.view.unmount();
310
+ const c = i(this, x).at(-1), p = ((c == null ? void 0 : c.view) ?? t).setChildView(n.view);
311
+ i(this, x).push({ id: n.id, view: p });
300
312
  }
301
313
  }
302
314
  }, gt = async function(t, e = []) {
303
- const s = Ct(a(this, W), t.pathname);
315
+ const s = Ct(i(this, G), t.pathname);
304
316
  if (!s)
305
317
  return {
306
318
  match: null,
307
319
  journey: [...e, { kind: "miss", message: `no match for '${t.pathname}'` }]
308
320
  };
309
- let n = s.meta.redirect;
321
+ let r = s.meta.redirect;
310
322
  if (s.meta.beforeMatch && await s.meta.beforeMatch({
311
323
  // TODO: Allow setting context variables from here? Would apply to the context of the matched view.
312
- redirect: (r) => {
313
- n = r;
324
+ redirect: (n) => {
325
+ r = n;
314
326
  }
315
- }), n != null) {
316
- let r;
317
- if (M(n))
318
- r = me(n, s.params);
319
- else if (z(n)) {
327
+ }), r != null) {
328
+ let n;
329
+ if (S(r))
330
+ n = me(r, s.params);
331
+ else if (H(r)) {
320
332
  const o = {
321
333
  path: s.path,
322
334
  pattern: s.pattern,
323
335
  params: s.params,
324
336
  query: s.query
325
337
  };
326
- if (r = await n(o), !M(r))
338
+ if (n = await r(o), !S(n))
327
339
  throw new Error("Redirect function must return a path to redirect to.");
328
- r.startsWith("/") || (r = ct(s.path, r));
340
+ n.startsWith("/") || (n = ct(s.path, n));
329
341
  } else
330
342
  throw new TypeError("Redirect must either be a path string or a function.");
331
- return f(this, m, gt).call(this, new URL(r, window.location.origin), [
343
+ return f(this, m, gt).call(this, new URL(n, window.location.origin), [
332
344
  ...e,
333
- { kind: "redirect", message: `redirecting '${s.path}' -> '${r}'` }
345
+ { kind: "redirect", message: `redirecting '${s.path}' -> '${n}'` }
334
346
  ]);
335
347
  } else
336
348
  return { match: s, journey: [...e, { kind: "match", message: `matched route '${s.path}'` }] };
@@ -341,7 +353,7 @@ Gt = function(t, e) {
341
353
  * @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
342
354
  */
343
355
  yt = function(t, e = [], s = []) {
344
- if (!D(t) || !M(t.path))
356
+ if (!V(t) || !S(t.path))
345
357
  throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${t}`);
346
358
  if (t.redirect && t.routes)
347
359
  throw new Error("Route cannot have both a 'redirect' and nested 'routes'.");
@@ -349,70 +361,70 @@ yt = function(t, e = [], s = []) {
349
361
  throw new Error("Route cannot have both a 'redirect' and a 'view'.");
350
362
  if (!t.view && !t.routes && !t.redirect)
351
363
  throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
352
- let n = [];
364
+ let r = [];
353
365
  for (const l of e)
354
- n.push(...K(l.path));
355
- n.push(...K(t.path)), n[n.length - 1] === "*" && n.pop();
356
- const r = [];
366
+ r.push(...B(l.path));
367
+ r.push(...B(t.path)), r[r.length - 1] === "*" && r.pop();
368
+ const n = [];
357
369
  if (t.redirect) {
358
370
  let l = t.redirect;
359
- return M(l) && (l = ct(G(n), l), l.startsWith("/") || (l = "/" + l)), r.push({
360
- pattern: "/" + G([...n, ...K(t.path)]),
371
+ return S(l) && (l = ct(q(r), l), l.startsWith("/") || (l = "/" + l)), n.push({
372
+ pattern: "/" + q([...r, ...B(t.path)]),
361
373
  meta: {
362
374
  redirect: l
363
375
  }
364
- }), r;
376
+ }), n;
365
377
  }
366
378
  let o = jt;
367
- if (z(t.view))
379
+ if (H(t.view))
368
380
  o = t.view;
369
381
  else if (t.view)
370
382
  throw new TypeError(`Route '${t.path}' expected a view function or undefined. Got: ${t.view}`);
371
383
  const c = { id: Rt(this, ht)._++, view: o };
372
384
  if (t.routes)
373
385
  for (const l of t.routes)
374
- r.push(...f(this, m, yt).call(this, l, [...e, t], [...s, c]));
386
+ n.push(...f(this, m, yt).call(this, l, [...e, t], [...s, c]));
375
387
  else
376
- r.push({
377
- pattern: parent ? G([...e.map((l) => l.path), t.path]) : t.path,
388
+ n.push({
389
+ pattern: parent ? q([...e.map((l) => l.path), t.path]) : t.path,
378
390
  meta: {
379
391
  pattern: t.path,
380
392
  layers: [...s, c],
381
393
  beforeMatch: t.beforeMatch
382
394
  }
383
395
  });
384
- return r;
396
+ return n;
385
397
  };
386
398
  const ue = /(noopener|noreferrer) (noopener|noreferrer)/, fe = /^[\w-_]+:/;
387
- function de(i, t, e = window) {
388
- function s(r) {
389
- return !r || r === i ? null : r.localName !== "a" || r.href === void 0 ? s(r.parentNode) : r;
399
+ function de(a, t, e = window) {
400
+ function s(n) {
401
+ return !n || n === a ? null : n.localName !== "a" || n.href === void 0 ? s(n.parentNode) : n;
390
402
  }
391
- function n(r) {
392
- if (r.button && r.button !== 0 || r.ctrlKey || r.metaKey || r.altKey || r.shiftKey || r.defaultPrevented)
403
+ function r(n) {
404
+ if (n.button && n.button !== 0 || n.ctrlKey || n.metaKey || n.altKey || n.shiftKey || n.defaultPrevented)
393
405
  return;
394
- const o = s(r.target);
395
- o && (e.location.protocol !== o.protocol || e.location.hostname !== o.hostname || e.location.port !== o.port || o.hasAttribute("data-router-ignore") || o.hasAttribute("download") || o.getAttribute("target") === "_blank" && ue.test(o.getAttribute("rel")) || fe.test(o.getAttribute("href")) || (r.preventDefault(), t(o)));
406
+ const o = s(n.target);
407
+ o && (e.location.protocol !== o.protocol || e.location.hostname !== o.hostname || e.location.port !== o.port || o.hasAttribute("data-router-ignore") || o.hasAttribute("download") || o.getAttribute("target") === "_blank" && ue.test(o.getAttribute("rel")) || fe.test(o.getAttribute("href")) || (n.preventDefault(), t(o)));
396
408
  }
397
- return i.addEventListener("click", n), function() {
398
- i.removeEventListener("click", n);
409
+ return a.addEventListener("click", r), function() {
410
+ a.removeEventListener("click", r);
399
411
  };
400
412
  }
401
- function me(i, t) {
413
+ function me(a, t) {
402
414
  for (const e in t) {
403
415
  const s = t[e].toString();
404
- i = i.replace(`{${e}}`, s).replace(`{#${e}}`, s);
416
+ a = a.replace(`{${e}}`, s).replace(`{#${e}}`, s);
405
417
  }
406
- return i;
418
+ return a;
407
419
  }
408
- function pe(i) {
409
- for (const t of i)
420
+ function pe(a) {
421
+ for (const t of a)
410
422
  if (t.meta.redirect) {
411
423
  let e;
412
- if (!z(t.meta.redirect)) if (M(t.meta.redirect)) {
413
- if (e = t.meta.redirect, !Ct(i, e, {
414
- willMatch(n) {
415
- return n !== t;
424
+ if (!H(t.meta.redirect)) if (S(t.meta.redirect)) {
425
+ if (e = t.meta.redirect, !Ct(a, e, {
426
+ willMatch(r) {
427
+ return r !== t;
416
428
  }
417
429
  }))
418
430
  throw new Error(`Found a redirect to an undefined URL. From '${t.pattern}' to '${t.meta.redirect}'`);
@@ -422,11 +434,11 @@ function pe(i) {
422
434
  }
423
435
  class we extends Error {
424
436
  }
425
- var I, ut, R, _;
437
+ var C, ut, E, R;
426
438
  class ge {
427
439
  constructor() {
428
- u(this, R);
429
- u(this, I, []);
440
+ u(this, E);
441
+ u(this, C, []);
430
442
  u(this, ut, ye());
431
443
  }
432
444
  /**
@@ -436,42 +448,42 @@ class ge {
436
448
  * @param middleware - A middleware function that will intercept requests.
437
449
  */
438
450
  use(t) {
439
- return a(this, I).push(t), () => {
440
- a(this, I).splice(a(this, I).indexOf(t), 1);
451
+ return i(this, C).push(t), () => {
452
+ i(this, C).splice(i(this, C).indexOf(t), 1);
441
453
  };
442
454
  }
443
455
  async get(t, e) {
444
- return f(this, R, _).call(this, "get", t, e);
456
+ return f(this, E, R).call(this, "get", t, e);
445
457
  }
446
458
  async put(t, e) {
447
- return f(this, R, _).call(this, "put", t, e);
459
+ return f(this, E, R).call(this, "put", t, e);
448
460
  }
449
461
  async patch(t, e) {
450
- return f(this, R, _).call(this, "patch", t, e);
462
+ return f(this, E, R).call(this, "patch", t, e);
451
463
  }
452
464
  async post(t, e) {
453
- return f(this, R, _).call(this, "post", t, e);
465
+ return f(this, E, R).call(this, "post", t, e);
454
466
  }
455
467
  async delete(t, e) {
456
- return f(this, R, _).call(this, "delete", t, e);
468
+ return f(this, E, R).call(this, "delete", t, e);
457
469
  }
458
470
  async head(t, e) {
459
- return f(this, R, _).call(this, "head", t, e);
471
+ return f(this, E, R).call(this, "head", t, e);
460
472
  }
461
473
  async options(t, e) {
462
- return f(this, R, _).call(this, "options", t, e);
474
+ return f(this, E, R).call(this, "options", t, e);
463
475
  }
464
476
  async trace(t, e) {
465
- return f(this, R, _).call(this, "trace", t, e);
477
+ return f(this, E, R).call(this, "trace", t, e);
466
478
  }
467
479
  }
468
- I = new WeakMap(), ut = new WeakMap(), R = new WeakSet(), _ = async function(t, e, s) {
469
- return new Ee({
480
+ C = new WeakMap(), ut = new WeakMap(), E = new WeakSet(), R = async function(t, e, s) {
481
+ return new ke({
470
482
  ...s,
471
483
  method: t,
472
484
  uri: e,
473
- middleware: a(this, I),
474
- fetch: a(this, ut)
485
+ middleware: i(this, C),
486
+ fetch: i(this, ut)
475
487
  }).fetch();
476
488
  };
477
489
  function ye() {
@@ -483,7 +495,7 @@ function ye() {
483
495
  }
484
496
  class be extends Error {
485
497
  constructor(e) {
486
- const { status: s, statusText: n, method: r, url: o } = e, c = `${s} ${n}: Request failed (${r.toUpperCase()} ${o.toString()})`;
498
+ const { status: s, statusText: r, method: n, url: o } = e, c = `${s} ${r}: Request failed (${n.toUpperCase()} ${o.toString()})`;
487
499
  super(c);
488
500
  w(this, "response");
489
501
  this.response = e;
@@ -506,7 +518,7 @@ class ve {
506
518
  t.forEach((e, s) => {
507
519
  this.headers.set(s, e);
508
520
  });
509
- else if (D(t))
521
+ else if (V(t))
510
522
  for (const e in t) {
511
523
  const s = t[e];
512
524
  s instanceof Date ? this.headers.set(e, s.toISOString()) : s != null && this.headers.set(e, String(s));
@@ -520,7 +532,7 @@ class ve {
520
532
  t.forEach((e, s) => {
521
533
  this.url.searchParams.set(s, e);
522
534
  });
523
- else if (D(t))
535
+ else if (V(t))
524
536
  for (const e in t) {
525
537
  const s = t[e];
526
538
  s instanceof Date ? this.url.searchParams.set(e, s.toISOString()) : s != null && this.url.searchParams.set(e, String(s));
@@ -529,7 +541,7 @@ class ve {
529
541
  throw new TypeError(`Unknown query params type. Got: ${t}`);
530
542
  }
531
543
  }
532
- class Ee {
544
+ class ke {
533
545
  constructor(t) {
534
546
  w(this, "_middleware");
535
547
  w(this, "_fetch");
@@ -540,8 +552,8 @@ class Ee {
540
552
  async fetch() {
541
553
  if (this._middleware.length > 0) {
542
554
  const t = (e = 0) => {
543
- const s = this._middleware[e], n = this._middleware[e + 1] ? t(e + 1) : this._handler.bind(this);
544
- return async () => s(this._request, async () => (await n(), this._response));
555
+ const s = this._middleware[e], r = this._middleware[e + 1] ? t(e + 1) : this._handler.bind(this);
556
+ return async () => s(this._request, async () => (await r(), this._response));
545
557
  };
546
558
  await t()();
547
559
  } else
@@ -554,46 +566,46 @@ class Ee {
554
566
  async _handler() {
555
567
  let t;
556
568
  const e = this._request;
557
- !e.headers.has("content-type") && D(e.body) ? (e.headers.set("content-type", "application/json"), t = JSON.stringify(e.body)) : t = e.body;
569
+ !e.headers.has("content-type") && V(e.body) ? (e.headers.set("content-type", "application/json"), t = JSON.stringify(e.body)) : t = e.body;
558
570
  const s = await this._fetch(e.url.toString(), {
559
571
  method: e.method,
560
572
  headers: e.headers,
561
573
  body: t
562
- }), n = s.headers.get("content-type");
563
- let r;
564
- n != null && n.includes("application/json") ? r = await s.json() : n != null && n.includes("application/x-www-form-urlencoded") ? r = await s.formData() : r = await s.text(), this._response = {
574
+ }), r = s.headers.get("content-type");
575
+ let n;
576
+ r != null && r.includes("application/json") ? n = await s.json() : r != null && r.includes("application/x-www-form-urlencoded") ? n = await s.formData() : n = await s.text(), this._response = {
565
577
  method: e.method,
566
578
  url: e.url,
567
579
  status: s.status,
568
580
  statusText: s.statusText,
569
581
  headers: s.headers,
570
- body: r
582
+ body: n
571
583
  };
572
584
  }
573
585
  }
574
- var ft, A, q, bt, Wt;
575
- class $e {
586
+ var ft, W, D, bt, Wt;
587
+ class Ee {
576
588
  constructor(t, e) {
577
- u(this, q);
589
+ u(this, D);
578
590
  w(this, "dolla");
579
591
  w(this, "config");
580
592
  u(this, ft, !1);
581
- u(this, A, /* @__PURE__ */ new Map());
593
+ u(this, W, /* @__PURE__ */ new Map());
582
594
  this.config = t, this.dolla = e;
583
595
  }
584
596
  async load() {
585
597
  let t;
586
- if (!a(this, ft)) {
587
- if (D(this.config.strings))
598
+ if (!i(this, ft)) {
599
+ if (V(this.config.strings))
588
600
  t = this.config.strings;
589
- else if (z(this.config.fetch)) {
590
- if (t = await this.config.fetch(), !D(t))
601
+ else if (H(this.config.fetch)) {
602
+ if (t = await this.config.fetch(), !V(t))
591
603
  throw new Error(`Fetch function did not return an object of language strings: ${t}`);
592
- } else if (M(this.config.path)) {
604
+ } else if (S(this.config.path)) {
593
605
  const e = await fetch(this.config.path);
594
606
  if (e.ok) {
595
607
  const s = await e.json();
596
- if (D(s))
608
+ if (V(s))
597
609
  t = s;
598
610
  else
599
611
  throw new Error(
@@ -604,34 +616,34 @@ class $e {
604
616
  }
605
617
  }
606
618
  if (t) {
607
- const e = f(this, q, bt).call(this, t);
619
+ const e = f(this, D, bt).call(this, t);
608
620
  for (const s of e)
609
- a(this, A).set(s[0], s[1]);
621
+ i(this, W).set(s[0], s[1]);
610
622
  } else
611
623
  throw new Error("Language could not be loaded.");
612
624
  }
613
625
  getTemplate(t) {
614
- return a(this, A).get(t) ?? {
626
+ return i(this, W).get(t) ?? {
615
627
  segments: [{ type: 0, text: `[MISSING: ${t}]` }]
616
628
  };
617
629
  }
618
630
  hasTemplate(t) {
619
- return a(this, A).has(t);
631
+ return i(this, W).has(t);
620
632
  }
621
633
  }
622
- ft = new WeakMap(), A = new WeakMap(), q = new WeakSet(), bt = function(t, e = []) {
634
+ ft = new WeakMap(), W = new WeakMap(), D = new WeakSet(), bt = function(t, e = []) {
623
635
  const s = [];
624
- for (const n in t)
625
- switch (St(t[n])) {
636
+ for (const r in t)
637
+ switch (St(t[r])) {
626
638
  case "string":
627
- s.push([[...e, n].join("."), f(this, q, Wt).call(this, t[n])]);
639
+ s.push([[...e, r].join("."), f(this, D, Wt).call(this, t[r])]);
628
640
  break;
629
641
  case "object":
630
- s.push(...f(this, q, bt).call(this, t[n], [...e, n]));
642
+ s.push(...f(this, D, bt).call(this, t[r], [...e, r]));
631
643
  break;
632
644
  default:
633
645
  throw new Error(
634
- `Expected to find a string or object at ${[...e, n].join(".")}. Got: ${St(t[n])}`
646
+ `Expected to find a string or object at ${[...e, r].join(".")}. Got: ${St(t[r])}`
635
647
  );
636
648
  }
637
649
  return s;
@@ -643,104 +655,104 @@ ft = new WeakMap(), A = new WeakMap(), q = new WeakSet(), bt = function(t, e = [
643
655
  const s = {
644
656
  segments: []
645
657
  };
646
- let n = "", r = 0, o = 0, c, l, p;
647
- const v = () => {
658
+ let r = "", n = 0, o = 0, c, l, p;
659
+ const b = () => {
648
660
  c = {
649
661
  type: 1,
650
662
  name: "",
651
663
  formats: []
652
664
  };
653
- }, $ = () => {
665
+ }, v = () => {
654
666
  l = {
655
667
  name: "",
656
668
  options: {}
657
669
  };
658
670
  };
659
- for (; r < t.length; ) {
660
- if (o !== 0 && t[r] === " ") {
661
- r++;
671
+ for (; n < t.length; ) {
672
+ if (o !== 0 && t[n] === " ") {
673
+ n++;
662
674
  continue;
663
675
  }
664
676
  switch (o) {
665
677
  case 0:
666
- t[r] === "{" && t[r + 1] === "{" ? (o = 1, r += 2, n.length > 0 && (s.segments.push({ type: 0, text: n }), n = ""), v()) : (n += t[r], r++);
678
+ t[n] === "{" && t[n + 1] === "{" ? (o = 1, n += 2, r.length > 0 && (s.segments.push({ type: 0, text: r }), r = ""), b()) : (r += t[n], n++);
667
679
  break;
668
680
  case 1:
669
- t[r] === "|" ? (o = 2, r += 1, c.name = n, n = "", $()) : t[r] === "}" && t[r + 1] === "}" ? (o = 0, r += 2, c.name = n, n = "", s.segments.push(c)) : (n += t[r], r++);
681
+ t[n] === "|" ? (o = 2, n += 1, c.name = r, r = "", v()) : t[n] === "}" && t[n + 1] === "}" ? (o = 0, n += 2, c.name = r, r = "", s.segments.push(c)) : (r += t[n], n++);
670
682
  break;
671
683
  case 2:
672
- t[r] === "(" ? (o = 3, r += 1, l.name = n, n = "") : t[r] === "}" && t[r + 1] === "}" ? (o = 0, r += 2, c.formats.push(l), s.segments.push(c)) : (n += t[r], r++);
684
+ t[n] === "(" ? (o = 3, n += 1, l.name = r, r = "") : t[n] === "}" && t[n + 1] === "}" ? (o = 0, n += 2, c.formats.push(l), s.segments.push(c)) : (r += t[n], n++);
673
685
  break;
674
686
  case 3:
675
- t[r] === ")" || (t[r] === ":" ? (o = 4, r += 1, p = n, n = "") : t[r] === "}" && t[r + 1] === "}" || (n += t[r], r++));
687
+ t[n] === ")" || (t[n] === ":" ? (o = 4, n += 1, p = r, r = "") : t[n] === "}" && t[n + 1] === "}" || (r += t[n], n++));
676
688
  break;
677
689
  case 4:
678
- t[r] === ")" ? (o = 5, r += 1, l.options[p] = n, n = "", c.formats.push(l)) : t[r] === "," ? (o = 3, r += 1, l.options[p] = n, n = "") : t[r] === "}" && t[r + 1] === "}" || (n += t[r], r++);
690
+ t[n] === ")" ? (o = 5, n += 1, l.options[p] = r, r = "", c.formats.push(l)) : t[n] === "," ? (o = 3, n += 1, l.options[p] = r, r = "") : t[n] === "}" && t[n + 1] === "}" || (r += t[n], n++);
679
691
  break;
680
692
  case 5:
681
- t[r] === "|" ? (o = 2, r += 1, $()) : t[r] === "}" && t[r + 1] === "}" && (o = 0, r += 2, s.segments.push(c));
693
+ t[n] === "|" ? (o = 2, n += 1, v()) : t[n] === "}" && t[n + 1] === "}" && (o = 0, n += 2, s.segments.push(c));
682
694
  break;
683
695
  }
684
696
  }
685
- return o === 0 && n.length > 0 && s.segments.push({ type: 0, text: n }), s;
697
+ return o === 0 && r.length > 0 && s.segments.push({ type: 0, text: r }), s;
686
698
  };
687
- var X, P, g, Y, Z, tt, b, y, At, vt, Et, $t, Ht;
688
- class ke {
699
+ var J, N, g, X, Y, Z, $, y, At, vt, kt, Et, Ht;
700
+ class $e {
689
701
  constructor(t) {
690
702
  u(this, y);
691
- u(this, X);
692
- u(this, P);
703
+ u(this, J);
704
+ u(this, N);
693
705
  u(this, g, /* @__PURE__ */ new Map());
694
- u(this, Y, []);
695
- u(this, Z, /* @__PURE__ */ new Map());
696
- u(this, tt, "auto");
697
- u(this, b, Ut(""));
698
- d(this, X, t), d(this, P, t.createLogger("Dolla.i18n")), this.addFormat("number", (e, s, n) => f(this, y, vt).call(this, Number(s), n)), this.addFormat("datetime", (e, s, n) => f(this, y, Et).call(this, s, n)), this.addFormat("list", (e, s, n) => f(this, y, $t).call(this, s, n)), t.beforeMount(async () => {
699
- a(this, g).size > 0 && await this.setLocale(a(this, tt));
706
+ u(this, X, []);
707
+ u(this, Y, /* @__PURE__ */ new Map());
708
+ u(this, Z, "auto");
709
+ u(this, $, Ut(""));
710
+ d(this, J, t), d(this, N, t.createLogger("Dolla.i18n")), this.addFormat("number", (e, s, r) => f(this, y, vt).call(this, Number(s), r)), this.addFormat("datetime", (e, s, r) => f(this, y, kt).call(this, s, r)), this.addFormat("list", (e, s, r) => f(this, y, Et).call(this, s, r)), t.beforeMount(async () => {
711
+ i(this, g).size > 0 && await this.setLocale(i(this, Z));
700
712
  });
701
713
  }
702
714
  get locale() {
703
- return a(this, b);
715
+ return i(this, $);
704
716
  }
705
717
  get locales() {
706
- return [...a(this, g).keys()];
718
+ return [...i(this, g).keys()];
707
719
  }
708
720
  setup(t) {
709
721
  if (t.translations.forEach((e) => {
710
- a(this, g).set(e.locale, new $e(e, a(this, X)));
722
+ i(this, g).set(e.locale, new Ee(e, i(this, J)));
711
723
  }), t.locale && t.locale !== "auto") {
712
724
  if (!t.translations.some((s) => s.locale === t.locale))
713
725
  throw new Error(`Initial locale '${t.locale}' is not registered in the locales array.`);
714
- d(this, tt, t.locale);
726
+ d(this, Z, t.locale);
715
727
  }
716
- a(this, P).info(
717
- `${a(this, g).size} language${a(this, g).size === 1 ? "" : "s"} supported: '${[...a(this, g).keys()].join("', '")}'`
728
+ i(this, N).info(
729
+ `${i(this, g).size} language${i(this, g).size === 1 ? "" : "s"} supported: '${[...i(this, g).keys()].join("', '")}'`
718
730
  );
719
731
  }
720
732
  async setLocale(t) {
721
- var n;
733
+ var r;
722
734
  let e;
723
735
  if (t === "auto") {
724
- let r = [];
736
+ let n = [];
725
737
  if (typeof navigator < "u") {
726
738
  const o = navigator;
727
- ((n = o.languages) == null ? void 0 : n.length) > 0 ? r.push(...o.languages) : o.language ? r.push(o.language) : o.browserLanguage ? r.push(o.browserLanguage) : o.userLanguage && r.push(o.userLanguage);
739
+ ((r = o.languages) == null ? void 0 : r.length) > 0 ? n.push(...o.languages) : o.language ? n.push(o.language) : o.browserLanguage ? n.push(o.browserLanguage) : o.userLanguage && n.push(o.userLanguage);
728
740
  }
729
- for (const o of r)
730
- a(this, g).has(o) && (e = o);
741
+ for (const o of n)
742
+ i(this, g).has(o) && (e = o);
731
743
  } else
732
- a(this, g).has(t) && (e = t);
744
+ i(this, g).has(t) && (e = t);
733
745
  if (e == null) {
734
- const r = a(this, g).keys().next().value;
735
- r && (e = r);
746
+ const n = i(this, g).keys().next().value;
747
+ n && (e = n);
736
748
  }
737
- if (!e || !a(this, g).has(e))
749
+ if (!e || !i(this, g).has(e))
738
750
  throw new Error(`Locale '${t}' has no translation.`);
739
- const s = a(this, g).get(e);
751
+ const s = i(this, g).get(e);
740
752
  try {
741
- await s.load(), d(this, Y, []), a(this, b).value = e, a(this, P).info("set language to " + e);
742
- } catch (r) {
743
- r instanceof Error && a(this, P).crash(r);
753
+ await s.load(), d(this, X, []), i(this, $).set(e), i(this, N).info("set language to " + e);
754
+ } catch (n) {
755
+ n instanceof Error && i(this, N).crash(n);
744
756
  }
745
757
  }
746
758
  /**
@@ -757,11 +769,11 @@ class ke {
757
769
  throw new Error(
758
770
  `The 't' function cannot be destructured. If you need a standalone version you can import it like so: 'import { t } from "@manyducks.co/dolla"'`
759
771
  );
760
- return U(() => {
772
+ return O(() => {
761
773
  const s = {};
762
- for (const n in e)
763
- s[n] = E(e[n]);
764
- return f(this, y, At).call(this, E(a(this, b)), t, s);
774
+ for (const r in e)
775
+ s[r] = lt(e[r]);
776
+ return f(this, y, At).call(this, i(this, $).get(), t, s);
765
777
  });
766
778
  }
767
779
  /**
@@ -779,16 +791,16 @@ class ke {
779
791
  * t("greeting", {name: "world"}); // State<"Hello, WORLD!">
780
792
  */
781
793
  addFormat(t, e) {
782
- a(this, Z).set(t, e);
794
+ i(this, Y).set(t, e);
783
795
  }
784
796
  /**
785
797
  * Creates an `Intl.Collator` configured for the current locale.
786
- * NOTE: The Collator remains bound to the locale it was created with, even when the app's locale changes.
798
+ * NOTE: The locale is tracked if called within a signal tracking context.
787
799
  *
788
800
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#options
789
801
  */
790
802
  collator(t) {
791
- return new Intl.Collator(a(this, b).value, t);
803
+ return new Intl.Collator(i(this, $).get(), t);
792
804
  }
793
805
  /**
794
806
  * Formats a number for the current locale. Uses `Intl.NumberFormat` under the hood.
@@ -796,7 +808,7 @@ class ke {
796
808
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
797
809
  */
798
810
  number(t, e) {
799
- return U(() => (E(a(this, b)), f(this, y, vt).call(this, E(t), e)));
811
+ return O(() => f(this, y, vt).call(this, lt(t), e));
800
812
  }
801
813
  /**
802
814
  * Formats a date for the current locale. Uses `Intl.DateTimeFormat` under the hood.
@@ -808,7 +820,7 @@ class ke {
808
820
  * const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
809
821
  */
810
822
  dateTime(t, e) {
811
- return U(() => (E(a(this, b)), f(this, y, Et).call(this, E(t), e)));
823
+ return O(() => f(this, y, kt).call(this, lt(t), e));
812
824
  }
813
825
  /**
814
826
  * Formats a list for the current locale. Uses `Intl.ListFormat` under the hood.
@@ -820,67 +832,67 @@ class ke {
820
832
  * const $formatted = Dolla.i18n.list(list, { });
821
833
  */
822
834
  list(t, e) {
823
- return U(() => (E(a(this, b)), f(this, y, $t).call(this, E(t), e)));
835
+ return O(() => f(this, y, Et).call(this, lt(t), e));
824
836
  }
825
837
  }
826
- X = new WeakMap(), P = new WeakMap(), g = new WeakMap(), Y = new WeakMap(), Z = new WeakMap(), tt = new WeakMap(), b = new WeakMap(), y = new WeakSet(), At = function(t, e, s) {
838
+ J = new WeakMap(), N = new WeakMap(), g = new WeakMap(), X = new WeakMap(), Y = new WeakMap(), Z = new WeakMap(), $ = new WeakMap(), y = new WeakSet(), At = function(t, e, s) {
827
839
  var l;
828
- const n = f(this, y, Ht).call(this, e, s);
829
- if (n) return n;
830
- const r = a(this, g).get(t);
840
+ const r = f(this, y, Ht).call(this, e, s);
841
+ if (r) return r;
842
+ const n = i(this, g).get(t);
831
843
  if (s.context != null && (e += "_" + s.context), s.count != null)
832
844
  if (s.ordinal) {
833
845
  const p = `${e}_ordinal_(=${s.count})`;
834
- r.hasTemplate(p) ? e = p : e += "_ordinal_" + new Intl.PluralRules(t, { type: "ordinal" }).select(s.count);
846
+ n.hasTemplate(p) ? e = p : e += "_ordinal_" + new Intl.PluralRules(t, { type: "ordinal" }).select(s.count);
835
847
  } else {
836
848
  const p = `${e}_(=${s.count})`;
837
- r.hasTemplate(p) ? e = p : e += "_" + new Intl.PluralRules(t).select(s.count);
849
+ n.hasTemplate(p) ? e = p : e += "_" + new Intl.PluralRules(t).select(s.count);
838
850
  }
839
- const o = r.getTemplate(e);
851
+ const o = n.getTemplate(e);
840
852
  let c = "";
841
853
  for (const p of o.segments)
842
854
  if (p.type === 0)
843
855
  c += p.text;
844
856
  else if (p.type === 1) {
845
- let v = Re(s, p.name);
846
- const $ = ((l = s.formatOverrides) == null ? void 0 : l[p.name]) ?? [...p.formats];
847
- p.name === "count" && $.length === 0 && $.push({ name: "number", options: {} });
848
- for (const h of $) {
849
- const x = a(this, Z).get(h.name);
850
- if (x == null) {
857
+ let b = Re(s, p.name);
858
+ const v = ((l = s.formatOverrides) == null ? void 0 : l[p.name]) ?? [...p.formats];
859
+ p.name === "count" && v.length === 0 && v.push({ name: "number", options: {} });
860
+ for (const h of v) {
861
+ const M = i(this, Y).get(h.name);
862
+ if (M == null) {
851
863
  const k = new Error(
852
864
  `Failed to load format '${h.name}' when processing '${e}', template: ${o}`
853
865
  );
854
- throw a(this, P).crash(k), k;
866
+ throw i(this, N).crash(k), k;
855
867
  }
856
- v = x(t, v, h.options);
868
+ b = M(t, b, h.options);
857
869
  }
858
- c += v;
870
+ c += b;
859
871
  }
860
872
  return c;
861
873
  }, vt = function(t, e) {
862
- return new Intl.NumberFormat(a(this, b).value, e).format(t);
874
+ return new Intl.NumberFormat(i(this, $).get(), e).format(t);
875
+ }, kt = function(t, e) {
876
+ return new Intl.DateTimeFormat(i(this, $).get(), e).format(S(t) ? new Date(t) : t);
863
877
  }, Et = function(t, e) {
864
- return new Intl.DateTimeFormat(a(this, b).value, e).format(M(t) ? new Date(t) : t);
865
- }, $t = function(t, e) {
866
- return new Intl.ListFormat(a(this, b).value, e).format(t);
878
+ return new Intl.ListFormat(i(this, $).get(), e).format(t);
867
879
  }, // relativeTime(): State<string> {
868
880
  // }
869
881
  Ht = function(t, e) {
870
- for (const s of a(this, Y))
882
+ for (const s of i(this, X))
871
883
  if (s[0] === t && Jt(s[1], e))
872
884
  return s[2];
873
885
  };
874
- function Re(i, t) {
875
- const e = String(t).split(/[\.\[\]]/).filter((n) => n.trim() !== "");
876
- let s = i;
886
+ function Re(a, t) {
887
+ const e = String(t).split(/[\.\[\]]/).filter((r) => r.trim() !== "");
888
+ let s = a;
877
889
  for (; e.length > 0; ) {
878
- const n = e.shift();
879
- s != null ? s = s[n] : s = void 0;
890
+ const r = e.shift();
891
+ s != null ? s = s[r] : s = void 0;
880
892
  }
881
893
  return s;
882
894
  }
883
- function _e(i) {
895
+ function _e(a) {
884
896
  return Mt`
885
897
  <div
886
898
  style=${{
@@ -894,8 +906,8 @@ function _e(i) {
894
906
  >
895
907
  <h1 style=${{ marginBottom: "0.5rem" }}>The app has crashed</h1>
896
908
  <p style=${{ marginBottom: "0.25rem" }}>
897
- <span style=${{ fontFamily: "monospace" }}>${i.loggerName}</span>
898
- ${Xt(i.uid, Mt`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${i.uid}]</span>`)}
909
+ <span style=${{ fontFamily: "monospace" }}>${a.loggerName}</span>
910
+ ${Xt(a.uid, Mt`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${a.uid}]</span>`)}
899
911
  ${" "}says:
900
912
  </p>
901
913
  <blockquote
@@ -918,102 +930,102 @@ function _e(i) {
918
930
  fontWeight: "bold"
919
931
  }}
920
932
  >
921
- ${i.error.name}
933
+ ${a.error.name}
922
934
  </span>
923
- ${i.error.message}
935
+ ${a.error.message}
924
936
  </blockquote>
925
937
 
926
938
  <p>Please see the browser console for details.</p>
927
939
  </div>
928
940
  `;
929
941
  }
930
- var L, et, F, V, st, H, rt, nt, at, it, O, ot, lt, dt;
942
+ var P, tt, L, I, et, A, st, nt, rt, at, F, it, ot, dt;
931
943
  class Se {
932
944
  constructor() {
933
945
  // TODO: Take these off the global Dolla object.
934
946
  w(this, "http");
935
947
  w(this, "i18n");
936
- u(this, L, !1);
937
- u(this, et, "production");
938
- u(this, F);
939
- u(this, V);
940
- u(this, st, _e);
941
- u(this, H);
942
- u(this, rt, []);
948
+ u(this, P, !1);
949
+ u(this, tt, "production");
950
+ u(this, L);
951
+ u(this, I);
952
+ u(this, et, _e);
953
+ u(this, A);
954
+ u(this, st, []);
943
955
  u(this, nt, []);
956
+ u(this, rt, []);
944
957
  u(this, at, []);
945
- u(this, it, []);
946
- u(this, O, {
958
+ u(this, F, {
947
959
  root: this,
948
960
  stores: /* @__PURE__ */ new Map(),
949
961
  viewName: "Dolla"
950
962
  });
951
- u(this, ot, {
963
+ u(this, it, {
952
964
  info: "development",
953
965
  log: "development",
954
966
  warn: "development",
955
967
  error: !0
956
968
  });
957
- u(this, lt, xt("*,-Dolla.*"));
969
+ u(this, ot, xt("*,-Dolla.*"));
958
970
  // Registration functions for modules.
959
971
  // All modules will be registered before mount.
960
972
  u(this, dt, []);
961
- this.http = new ge(), this.i18n = new ke(this);
973
+ this.http = new ge(), this.i18n = new $e(this);
962
974
  }
963
975
  /**
964
976
  * True when the app is connected to a DOM node and displayed to the user.
965
977
  */
966
978
  get isMounted() {
967
- return a(this, L);
979
+ return i(this, P);
968
980
  }
969
981
  /**
970
982
  * Get the current environment that this app is running in.
971
983
  * Environment affects which log messages will print and how much debugging info is included in the DOM.
972
984
  */
973
985
  getEnv() {
974
- return a(this, et);
986
+ return i(this, tt);
975
987
  }
976
988
  /**
977
989
  * Sets the environment that this app is running in.
978
990
  * Environment affects which log messages will print and how much debugging info is included in the DOM.
979
991
  */
980
992
  setEnv(t) {
981
- d(this, et, t);
993
+ d(this, tt, t);
982
994
  }
983
995
  /**
984
996
  * Sets the view that will be shown when the `crash` method is called on any logger.
985
997
  * When a crash is reported the app will be unmounted and replaced with this crash page.
986
998
  */
987
999
  setCrashView(t) {
988
- d(this, st, t);
1000
+ d(this, et, t);
989
1001
  }
990
1002
  /**
991
1003
  * Returns the HTMLElement Dolla is mounted to. This will return undefined until Dolla.mount() is called.
992
1004
  */
993
1005
  getRootElement() {
994
- return a(this, F);
1006
+ return i(this, L);
995
1007
  }
996
1008
  /**
997
1009
  * Returns the top level view Dolla is rendering inside the root element. This will return undefined until Dolla.mount() is called.
998
1010
  */
999
1011
  getRootView() {
1000
- return a(this, V);
1012
+ return i(this, I);
1001
1013
  }
1002
1014
  provide(t, e) {
1003
1015
  const s = new Yt(t, e);
1004
- if (s.attach(a(this, O)))
1016
+ if (s.attach(i(this, F)))
1005
1017
  return s.value;
1006
1018
  {
1007
- let r = t.name ? `'${t.name}'` : "this store";
1008
- return console.warn(`An instance of ${r} was already attached to this context.`), this.get(t);
1019
+ let n = t.name ? `'${t.name}'` : "this store";
1020
+ return console.warn(`An instance of ${n} was already attached to this context.`), this.get(t);
1009
1021
  }
1010
1022
  }
1011
1023
  /**
1012
1024
  * Gets the nearest instance of a store. Throws an error if the store isn't provided higher in the tree.
1013
1025
  */
1014
1026
  get(t) {
1015
- if (z(t)) {
1016
- const e = a(this, O).stores.get(t);
1027
+ if (H(t)) {
1028
+ const e = i(this, F).stores.get(t);
1017
1029
  if (e == null)
1018
1030
  throw new Tt("Store not found on this context.");
1019
1031
  return e.value;
@@ -1021,26 +1033,26 @@ class Se {
1021
1033
  throw new Tt("Invalid store.");
1022
1034
  }
1023
1035
  async mount(t, e) {
1024
- if (a(this, L))
1036
+ if (i(this, P))
1025
1037
  throw new Error("Dolla is already mounted.");
1026
- if (M(t)) {
1027
- const r = document.querySelector(t);
1028
- Nt(HTMLElement, r, `Selector '${t}' did not match any element.`), d(this, F, r);
1038
+ if (S(t)) {
1039
+ const n = document.querySelector(t);
1040
+ Nt(HTMLElement, n, `Selector '${t}' did not match any element.`), d(this, L, n);
1029
1041
  } else
1030
- Nt(HTMLElement, t, "Expected an HTML element or a selector string. Got type: %t, value: %v"), d(this, F, t);
1031
- pt(e) && d(this, H, e);
1032
- const s = pt(e) ? jt : e, n = Zt(s);
1033
- d(this, V, this.constructView(n.type, n.props)), await Promise.all(a(this, dt).map((r) => r())), pt(e) && await le(e, this), await Promise.all(a(this, rt).map((r) => r())), a(this, V).mount(a(this, F)), d(this, L, !0);
1034
- for (const r of a(this, O).stores.values())
1035
- r.handleMount();
1036
- for (const r of a(this, nt))
1037
- r();
1042
+ Nt(HTMLElement, t, "Expected an HTML element or a selector string. Got type: %t, value: %v"), d(this, L, t);
1043
+ pt(e) && d(this, A, e);
1044
+ const s = pt(e) ? jt : e, r = Zt(s);
1045
+ d(this, I, this.constructView(r.type, r.props)), await Promise.all(i(this, dt).map((n) => n())), pt(e) && await le(e, this), await Promise.all(i(this, st).map((n) => n())), i(this, I).mount(i(this, L)), d(this, P, !0);
1046
+ for (const n of i(this, F).stores.values())
1047
+ n.handleMount();
1048
+ for (const n of i(this, nt))
1049
+ n();
1038
1050
  }
1039
1051
  async unmount() {
1040
1052
  var t;
1041
- if (a(this, L)) {
1042
- await Promise.all(a(this, at).map((e) => e())), (t = a(this, V)) == null || t.unmount(!1), a(this, H) && await ce(a(this, H)), d(this, L, !1);
1043
- for (const e of a(this, it))
1053
+ if (i(this, P)) {
1054
+ await Promise.all(i(this, rt).map((e) => e())), (t = i(this, I)) == null || t.unmount(!1), i(this, A) && await ce(i(this, A)), d(this, P, !1);
1055
+ for (const e of i(this, at))
1044
1056
  e();
1045
1057
  }
1046
1058
  }
@@ -1049,26 +1061,26 @@ class Se {
1049
1061
  * it will be awaited before mounting finishes. Use this to perform initial setup before the app is displayed to the user.
1050
1062
  */
1051
1063
  beforeMount(t) {
1052
- a(this, rt).push(t);
1064
+ i(this, st).push(t);
1053
1065
  }
1054
1066
  /**
1055
1067
  * Registers a `callback` to run after the app is mounted.
1056
1068
  */
1057
1069
  onMount(t) {
1058
- a(this, nt).push(t);
1070
+ i(this, nt).push(t);
1059
1071
  }
1060
1072
  /**
1061
1073
  * Registers a `callback` to run after `Dolla.unmount` is called, before the app is unmounted. If `callback` returns a Promise,
1062
1074
  * it will be awaited before unmounting finishes. Use this to perform cleanup.
1063
1075
  */
1064
1076
  beforeUnmount(t) {
1065
- a(this, at).push(t);
1077
+ i(this, rt).push(t);
1066
1078
  }
1067
1079
  /**
1068
1080
  * Registers a `callback` to run after the app is unmounted.
1069
1081
  */
1070
1082
  onUnmount(t) {
1071
- a(this, it).push(t);
1083
+ i(this, at).push(t);
1072
1084
  }
1073
1085
  /**
1074
1086
  * Update log type toggles. Values that are not passed will remain unchanged.
@@ -1076,22 +1088,22 @@ class Se {
1076
1088
  setLoggles(t) {
1077
1089
  for (const e in t) {
1078
1090
  const s = t[e];
1079
- s && (a(this, ot)[e] = s);
1091
+ s && (i(this, it)[e] = s);
1080
1092
  }
1081
1093
  }
1082
1094
  setLogFilter(t) {
1083
- d(this, lt, xt(t));
1095
+ d(this, ot, xt(t));
1084
1096
  }
1085
1097
  createLogger(t, e) {
1086
- const s = (e == null ? void 0 : e.console) ?? Me(), n = this, r = a(this, ot), o = (c) => {
1087
- if (r[c] === !1 || M(r[c]) && r[c] !== n.getEnv() || !a(this, lt).call(this, t))
1088
- return re;
1098
+ const s = (e == null ? void 0 : e.console) ?? Me(), r = this, n = i(this, it), o = (c) => {
1099
+ if (n[c] === !1 || S(n[c]) && n[c] !== r.getEnv() || !i(this, ot).call(this, t))
1100
+ return ne;
1089
1101
  {
1090
1102
  let l = `%c${t}`;
1091
1103
  return e != null && e.uid ? l += ` %c[uid: %c${e.uid}%c]` : l += "%c%c%c", s[c].bind(
1092
1104
  s,
1093
1105
  l,
1094
- `color:${ne(l)};font-weight:bold`,
1106
+ `color:${re(l)};font-weight:bold`,
1095
1107
  "color:#777",
1096
1108
  "color:#aaa",
1097
1109
  "color:#777"
@@ -1115,11 +1127,11 @@ class Se {
1115
1127
  return o("error");
1116
1128
  },
1117
1129
  crash(c) {
1118
- n.isMounted && (n.unmount(), n.constructView(a(n, st), {
1130
+ r.isMounted && (r.unmount(), r.constructView(i(r, et), {
1119
1131
  error: c,
1120
1132
  loggerName: t,
1121
1133
  uid: e == null ? void 0 : e.uid
1122
- }).mount(a(n, F)));
1134
+ }).mount(i(r, L)));
1123
1135
  }
1124
1136
  };
1125
1137
  }
@@ -1127,16 +1139,16 @@ class Se {
1127
1139
  *
1128
1140
  */
1129
1141
  constructView(t, e, s = []) {
1130
- return new te(a(this, O), t, e, s);
1142
+ return new te(i(this, F), t, e, s);
1131
1143
  }
1132
1144
  /**
1133
1145
  *
1134
1146
  */
1135
1147
  constructMarkup(t) {
1136
- return ee(se(a(this, O), t));
1148
+ return ee(se(i(this, F), t));
1137
1149
  }
1138
1150
  }
1139
- L = new WeakMap(), et = new WeakMap(), F = new WeakMap(), V = new WeakMap(), st = new WeakMap(), H = new WeakMap(), rt = new WeakMap(), nt = new WeakMap(), at = new WeakMap(), it = new WeakMap(), O = new WeakMap(), ot = new WeakMap(), lt = new WeakMap(), dt = new WeakMap();
1151
+ P = new WeakMap(), tt = new WeakMap(), L = new WeakMap(), I = new WeakMap(), et = new WeakMap(), A = new WeakMap(), st = new WeakMap(), nt = new WeakMap(), rt = new WeakMap(), at = new WeakMap(), F = new WeakMap(), it = new WeakMap(), ot = new WeakMap(), dt = new WeakMap();
1140
1152
  function Me() {
1141
1153
  if (typeof window < "u" && window.console)
1142
1154
  return window.console;
@@ -1146,22 +1158,23 @@ function Me() {
1146
1158
  const Pt = new Se(), Le = Pt.i18n.t.bind(Pt.i18n);
1147
1159
  export {
1148
1160
  Ut as atom,
1149
- U as compose,
1161
+ O as compose,
1150
1162
  Xt as cond,
1151
1163
  Zt as createMarkup,
1152
1164
  Pe as createRouter,
1153
1165
  Jt as deepEqual,
1154
1166
  Pt as default,
1155
1167
  Ue as effect,
1156
- E as get,
1168
+ lt as get,
1169
+ je as getTracked,
1157
1170
  Mt as html,
1158
- je as list,
1159
- Ce as peek,
1160
- Ie as portal,
1171
+ Ce as list,
1172
+ Ie as peek,
1173
+ Ve as portal,
1161
1174
  Ne as ref,
1162
- Ve as set,
1175
+ De as set,
1163
1176
  _t as shallowEqual,
1164
- De as strictEqual,
1177
+ qe as strictEqual,
1165
1178
  Le as t
1166
1179
  };
1167
1180
  //# sourceMappingURL=index.js.map