@manyducks.co/dolla 2.0.0-alpha.35 → 2.0.0-alpha.36

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