@manyducks.co/dolla 2.0.0-alpha.13 → 2.0.0-alpha.14

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,11 +1,11 @@
1
- var kt = Object.defineProperty;
2
- var st = (i) => {
1
+ var Pt = Object.defineProperty;
2
+ var ot = (i) => {
3
3
  throw TypeError(i);
4
4
  };
5
- var Et = (i, e, t) => e in i ? kt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
6
- var P = (i, e, t) => Et(i, typeof e != "symbol" ? e + "" : e, t), Be = (i, e, t) => e.has(i) || st("Cannot " + t);
7
- var s = (i, e, t) => (Be(i, e, "read from private field"), t ? t.call(i) : e.get(i)), f = (i, e, t) => e.has(i) ? st("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), b = (i, e, t, r) => (Be(i, e, "write to private field"), r ? r.call(i, t) : e.set(i, t), t), k = (i, e, t) => (Be(i, e, "access private method"), t);
8
- var it = (i, e, t, r) => ({
5
+ var St = (i, e, t) => e in i ? Pt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
6
+ var S = (i, e, t) => St(i, typeof e != "symbol" ? e + "" : e, t), Qe = (i, e, t) => e.has(i) || ot("Cannot " + t);
7
+ var s = (i, e, t) => (Qe(i, e, "read from private field"), t ? t.call(i) : e.get(i)), f = (i, e, t) => e.has(i) ? ot("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), b = (i, e, t, r) => (Qe(i, e, "write to private field"), r ? r.call(i, t) : e.set(i, t), t), E = (i, e, t) => (Qe(i, e, "access private method"), t);
8
+ var lt = (i, e, t, r) => ({
9
9
  set _(a) {
10
10
  b(i, e, a, t);
11
11
  },
@@ -13,10 +13,10 @@ var it = (i, e, t, r) => ({
13
13
  return s(i, e, r);
14
14
  }
15
15
  });
16
- import { h as ot, c as Pt, i as Ke, t as Qe, d as ye, a as St, b as at, e as F, f as lt, g as ie, j as pt, k as Rt, w as gt, P as mt, l as ct, m as xt, n as Lt, v as Nt, o as Ot, p as Mt, q as ut, r as ht, s as Tt, u as Ae, x as De, y as jt, z as At, A as Dt } from "./passthrough-Bz5ZF4jn.js";
17
- import { B as cr, C as ur, D as hr } from "./passthrough-Bz5ZF4jn.js";
18
- function _t(i) {
19
- return ot`
16
+ import { h as ct, c as Lt, i as Je, d as we, a as Rt, b as it, e as V, t as ut, f as se, g as wt, j as xt, k as Ye, P as yt, l as ht, m as Ot, n as Nt, o as ft, v as Mt, p as Tt, q as Dt, r as dt, s as pt, u as _t, w as je, x as Fe, y as At, z as jt, A as Ft } from "./passthrough-MfPKbG0F.js";
17
+ import { B as fr, C as dr, D as pr } from "./passthrough-MfPKbG0F.js";
18
+ function Ct(i) {
19
+ return ct`
20
20
  <div
21
21
  style=${{
22
22
  backgroundColor: "#880000",
@@ -30,7 +30,7 @@ function _t(i) {
30
30
  <h1 style=${{ marginBottom: "0.5rem" }}>The app has crashed</h1>
31
31
  <p style=${{ marginBottom: "0.25rem" }}>
32
32
  <span style=${{ fontFamily: "monospace" }}>${i.loggerName}</span>
33
- ${Pt(i.uid, ot`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${i.uid}]</span>`)}
33
+ ${Lt(i.uid, ct`<span style=${{ fontFamily: "monospace", opacity: 0.5 }}> [uid: ${i.uid}]</span>`)}
34
34
  ${" "}says:
35
35
  </p>
36
36
  <blockquote
@@ -62,12 +62,12 @@ function _t(i) {
62
62
  </div>
63
63
  `;
64
64
  }
65
- var Y, Ge, T, _;
66
- class Ct {
65
+ var Q, Be, T, j;
66
+ class Vt {
67
67
  constructor() {
68
68
  f(this, T);
69
- f(this, Y, []);
70
- f(this, Ge, Vt());
69
+ f(this, Q, []);
70
+ f(this, Be, qt());
71
71
  }
72
72
  /**
73
73
  * Adds a new middleware that will apply to subsequent requests.
@@ -76,60 +76,60 @@ class Ct {
76
76
  * @param middleware - A middleware function that will intercept requests.
77
77
  */
78
78
  use(e) {
79
- return s(this, Y).push(e), () => {
80
- s(this, Y).splice(s(this, Y).indexOf(e), 1);
79
+ return s(this, Q).push(e), () => {
80
+ s(this, Q).splice(s(this, Q).indexOf(e), 1);
81
81
  };
82
82
  }
83
83
  async get(e, t) {
84
- return k(this, T, _).call(this, "get", e, t);
84
+ return E(this, T, j).call(this, "get", e, t);
85
85
  }
86
86
  async put(e, t) {
87
- return k(this, T, _).call(this, "put", e, t);
87
+ return E(this, T, j).call(this, "put", e, t);
88
88
  }
89
89
  async patch(e, t) {
90
- return k(this, T, _).call(this, "patch", e, t);
90
+ return E(this, T, j).call(this, "patch", e, t);
91
91
  }
92
92
  async post(e, t) {
93
- return k(this, T, _).call(this, "post", e, t);
93
+ return E(this, T, j).call(this, "post", e, t);
94
94
  }
95
95
  async delete(e, t) {
96
- return k(this, T, _).call(this, "delete", e, t);
96
+ return E(this, T, j).call(this, "delete", e, t);
97
97
  }
98
98
  async head(e, t) {
99
- return k(this, T, _).call(this, "head", e, t);
99
+ return E(this, T, j).call(this, "head", e, t);
100
100
  }
101
101
  async options(e, t) {
102
- return k(this, T, _).call(this, "options", e, t);
102
+ return E(this, T, j).call(this, "options", e, t);
103
103
  }
104
104
  async trace(e, t) {
105
- return k(this, T, _).call(this, "trace", e, t);
105
+ return E(this, T, j).call(this, "trace", e, t);
106
106
  }
107
107
  }
108
- Y = new WeakMap(), Ge = new WeakMap(), T = new WeakSet(), _ = async function(e, t, r) {
109
- return qt({
108
+ Q = new WeakMap(), Be = new WeakMap(), T = new WeakSet(), j = async function(e, t, r) {
109
+ return Ht({
110
110
  ...r,
111
111
  method: e,
112
112
  uri: t,
113
- middleware: s(this, Y),
114
- fetch: s(this, Ge)
113
+ middleware: s(this, Q),
114
+ fetch: s(this, Be)
115
115
  });
116
116
  };
117
- function Vt() {
117
+ function qt() {
118
118
  if (typeof window < "u" && window.fetch)
119
119
  return window.fetch.bind(window);
120
120
  if (typeof global < "u" && global.fetch)
121
121
  return global.fetch.bind(global);
122
122
  throw new Error("Running in neither browser nor node. Please run this app in one of the supported environments.");
123
123
  }
124
- class Ft extends Error {
124
+ class Ut extends Error {
125
125
  constructor(t) {
126
- const { status: r, statusText: a, method: n, uri: o } = t, u = `${r} ${a}: Request failed (${n.toUpperCase()} ${o})`;
127
- super(u);
128
- P(this, "response");
126
+ const { status: r, statusText: a, method: n, uri: o } = t, h = `${r} ${a}: Request failed (${n.toUpperCase()} ${o})`;
127
+ super(h);
128
+ S(this, "response");
129
129
  this.response = t;
130
130
  }
131
131
  }
132
- async function qt(i) {
132
+ async function Ht(i) {
133
133
  const { headers: e, query: t, fetch: r, middleware: a } = i, n = {
134
134
  method: i.method,
135
135
  uri: i.uri,
@@ -142,81 +142,80 @@ async function qt(i) {
142
142
  };
143
143
  if (e)
144
144
  if (e instanceof Map || e instanceof Headers)
145
- e.forEach((l, g) => {
146
- n.headers.set(g, l);
145
+ e.forEach((l, d) => {
146
+ n.headers.set(d, l);
147
147
  });
148
148
  else if (e != null && typeof e == "object" && !Array.isArray(e))
149
149
  for (const l in e) {
150
- const g = e[l];
151
- g instanceof Date ? n.headers.set(l, g.toISOString()) : g != null && n.headers.set(l, String(g));
150
+ const d = e[l];
151
+ d instanceof Date ? n.headers.set(l, d.toISOString()) : d != null && n.headers.set(l, String(d));
152
152
  }
153
153
  else
154
154
  throw new TypeError(`Unknown headers type. Got: ${e}`);
155
155
  if (t)
156
156
  if (t instanceof Map || t instanceof URLSearchParams)
157
- t.forEach((l, g) => {
158
- n.query.set(g, l);
157
+ t.forEach((l, d) => {
158
+ n.query.set(d, l);
159
159
  });
160
160
  else if (t != null && typeof t == "object" && !Array.isArray(t))
161
161
  for (const l in t) {
162
- const g = t[l];
163
- g instanceof Date ? n.query.set(l, g.toISOString()) : g != null && n.query.set(l, String(g));
162
+ const d = t[l];
163
+ d instanceof Date ? n.query.set(l, d.toISOString()) : d != null && n.query.set(l, String(d));
164
164
  }
165
165
  else
166
166
  throw new TypeError(`Unknown query params type. Got: ${t}`);
167
167
  let o;
168
- const u = async () => {
169
- const l = n.query.toString(), g = l.length > 0 ? n.uri + "?" + l : n.uri;
170
- let m;
171
- !n.headers.has("content-type") && Ke(n.body) ? (n.headers.set("content-type", "application/json"), m = JSON.stringify(n.body)) : m = n.body;
172
- const p = await r(g, {
168
+ const h = async () => {
169
+ const l = n.query.toString(), d = l.length > 0 ? n.uri + "?" + l : n.uri;
170
+ let g;
171
+ !n.headers.has("content-type") && Je(n.body) ? (n.headers.set("content-type", "application/json"), g = JSON.stringify(n.body)) : g = n.body;
172
+ const m = await r(d, {
173
173
  method: n.method,
174
174
  headers: n.headers,
175
- body: m
176
- }), h = Object.fromEntries(p.headers.entries()), y = h["content-type"];
177
- let S;
178
- y != null && y.includes("application/json") ? S = await p.json() : y != null && y.includes("application/x-www-form-urlencoded") ? S = await p.formData() : S = await p.text(), o = {
175
+ body: g
176
+ }), u = Object.fromEntries(m.headers.entries()), y = u["content-type"];
177
+ let k;
178
+ y != null && y.includes("application/json") ? k = await m.json() : y != null && y.includes("application/x-www-form-urlencoded") ? k = await m.formData() : k = await m.text(), o = {
179
179
  method: n.method,
180
180
  uri: n.uri,
181
- status: p.status,
182
- statusText: p.statusText,
183
- headers: h,
184
- body: S
181
+ status: m.status,
182
+ statusText: m.statusText,
183
+ headers: u,
184
+ body: k
185
185
  };
186
186
  };
187
187
  if (a.length > 0) {
188
- const l = (g = 0) => {
189
- const m = a[g], p = a[g + 1] ? l(g + 1) : u;
190
- return async () => m(n, async () => (await p(), o));
188
+ const l = (d = 0) => {
189
+ const g = a[d], m = a[d + 1] ? l(d + 1) : h;
190
+ return async () => g(n, async () => (await m(), o));
191
191
  };
192
192
  await l()();
193
193
  } else
194
- await u();
194
+ await h();
195
195
  if (o.status < 200 || o.status >= 400)
196
- throw new Ft(o);
196
+ throw new Ut(o);
197
197
  return o;
198
198
  }
199
- const Ut = Qe("[NO LANGUAGE SET]");
200
- var We, oe, re, Je, wt;
201
- class Ht {
199
+ var ze, ie, te, Xe, bt;
200
+ class It {
202
201
  constructor(e, t) {
203
- f(this, re);
204
- P(this, "dolla");
205
- P(this, "config");
206
- f(this, We, !1);
207
- f(this, oe, /* @__PURE__ */ new Map());
202
+ f(this, te);
203
+ S(this, "dolla");
204
+ S(this, "config");
205
+ f(this, ze, !1);
206
+ f(this, ie, /* @__PURE__ */ new Map());
208
207
  this.config = e, this.dolla = t;
209
208
  }
210
209
  async load() {
211
210
  let e;
212
- if (!s(this, We)) {
213
- if (at(this.config.fetch)) {
214
- if (e = await this.config.fetch(), !Ke(e))
211
+ if (!s(this, ze)) {
212
+ if (it(this.config.fetch)) {
213
+ if (e = await this.config.fetch(), !Je(e))
215
214
  throw new Error(`Fetch function did not return an object of language strings: ${e}`);
216
- } else if (F(this.config.path)) {
215
+ } else if (V(this.config.path)) {
217
216
  const t = await this.dolla.http.get(this.config.path);
218
217
  if (t.status >= 200 && t.status < 300)
219
- if (Ke(t.body))
218
+ if (Je(t.body))
220
219
  e = t.body;
221
220
  else
222
221
  throw new Error(
@@ -226,53 +225,54 @@ class Ht {
226
225
  throw new Error("HTTP request failed.");
227
226
  }
228
227
  }
229
- if (e == null)
230
- throw new Error("Language could not be loaded.");
231
- {
232
- const t = k(this, re, Je).call(this, e);
228
+ if (e) {
229
+ const t = E(this, te, Xe).call(this, e);
233
230
  for (const r of t)
234
- s(this, oe).set(r[0], r[1]);
235
- }
231
+ s(this, ie).set(r[0], r[1]);
232
+ } else
233
+ throw new Error("Language could not be loaded.");
236
234
  }
237
235
  getTemplate(e) {
238
- return s(this, oe).get(e) ?? null;
236
+ return s(this, ie).get(e) ?? {
237
+ segments: [{ type: 0, text: `[MISSING: ${e}]` }]
238
+ };
239
239
  }
240
240
  hasTemplate(e) {
241
- return s(this, oe).has(e);
241
+ return s(this, ie).has(e);
242
242
  }
243
243
  }
244
- We = new WeakMap(), oe = new WeakMap(), re = new WeakSet(), Je = function(e, t = []) {
244
+ ze = new WeakMap(), ie = new WeakMap(), te = new WeakSet(), Xe = function(e, t = []) {
245
245
  const r = [];
246
246
  for (const a in e)
247
- switch (lt(e[a])) {
247
+ switch (ut(e[a])) {
248
248
  case "string":
249
- r.push([[...t, a].join("."), k(this, re, wt).call(this, e[a])]);
249
+ r.push([[...t, a].join("."), E(this, te, bt).call(this, e[a])]);
250
250
  break;
251
251
  case "object":
252
- r.push(...k(this, re, Je).call(this, e[a], [...t, a]));
252
+ r.push(...E(this, te, Xe).call(this, e[a], [...t, a]));
253
253
  break;
254
254
  default:
255
255
  throw new Error(
256
- `Expected to find a string or object at ${[...t, a].join(".")}. Got: ${lt(e[a])}`
256
+ `Expected to find a string or object at ${[...t, a].join(".")}. Got: ${ut(e[a])}`
257
257
  );
258
258
  }
259
259
  return r;
260
- }, wt = function(e) {
260
+ }, bt = function(e) {
261
261
  let t;
262
- ((h) => {
263
- 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";
262
+ ((u) => {
263
+ u[u.Static = 0] = "Static", u[u.ValueName = 1] = "ValueName", u[u.FormatName = 2] = "FormatName", u[u.FormatOptionName = 3] = "FormatOptionName", u[u.FormatOptionValue = 4] = "FormatOptionValue", u[u.FormatOptionEnd = 5] = "FormatOptionEnd";
264
264
  })(t || (t = {}));
265
265
  const r = {
266
266
  segments: []
267
267
  };
268
- let a = "", n = 0, o = 0, u, l, g;
269
- const m = () => {
270
- u = {
268
+ let a = "", n = 0, o = 0, h, l, d;
269
+ const g = () => {
270
+ h = {
271
271
  type: 1,
272
272
  name: "",
273
273
  formats: []
274
274
  };
275
- }, p = () => {
275
+ }, m = () => {
276
276
  l = {
277
277
  name: "",
278
278
  options: {}
@@ -285,58 +285,58 @@ We = new WeakMap(), oe = new WeakMap(), re = new WeakSet(), Je = function(e, t =
285
285
  }
286
286
  switch (o) {
287
287
  case 0:
288
- e[n] === "{" && e[n + 1] === "{" ? (o = 1, n += 2, a.length > 0 && (r.segments.push({ type: 0, text: a }), a = ""), m()) : (a += e[n], n++);
288
+ e[n] === "{" && e[n + 1] === "{" ? (o = 1, n += 2, a.length > 0 && (r.segments.push({ type: 0, text: a }), a = ""), g()) : (a += e[n], n++);
289
289
  break;
290
290
  case 1:
291
- e[n] === "|" ? (o = 2, n += 1, u.name = a, a = "", p()) : e[n] === "}" && e[n + 1] === "}" ? (o = 0, n += 2, u.name = a, a = "", r.segments.push(u)) : (a += e[n], n++);
291
+ e[n] === "|" ? (o = 2, n += 1, h.name = a, a = "", m()) : e[n] === "}" && e[n + 1] === "}" ? (o = 0, n += 2, h.name = a, a = "", r.segments.push(h)) : (a += e[n], n++);
292
292
  break;
293
293
  case 2:
294
- e[n] === "(" ? (o = 3, n += 1, l.name = a, a = "") : e[n] === "}" && e[n + 1] === "}" ? (o = 0, n += 2, u.formats.push(l), r.segments.push(u)) : (a += e[n], n++);
294
+ e[n] === "(" ? (o = 3, n += 1, l.name = a, a = "") : e[n] === "}" && e[n + 1] === "}" ? (o = 0, n += 2, h.formats.push(l), r.segments.push(h)) : (a += e[n], n++);
295
295
  break;
296
296
  case 3:
297
- e[n] === ")" || (e[n] === ":" ? (o = 4, n += 1, g = a, a = "") : e[n] === "}" && e[n + 1] === "}" || (a += e[n], n++));
297
+ e[n] === ")" || (e[n] === ":" ? (o = 4, n += 1, d = a, a = "") : e[n] === "}" && e[n + 1] === "}" || (a += e[n], n++));
298
298
  break;
299
299
  case 4:
300
- e[n] === ")" ? (o = 5, n += 1, l.options[g] = a, a = "", u.formats.push(l)) : e[n] === "," ? (o = 3, n += 1, l.options[g] = a, a = "") : e[n] === "}" && e[n + 1] === "}" || (a += e[n], n++);
300
+ e[n] === ")" ? (o = 5, n += 1, l.options[d] = a, a = "", h.formats.push(l)) : e[n] === "," ? (o = 3, n += 1, l.options[d] = a, a = "") : e[n] === "}" && e[n + 1] === "}" || (a += e[n], n++);
301
301
  break;
302
302
  case 5:
303
- e[n] === "|" ? (o = 2, n += 1, p()) : e[n] === "}" && e[n + 1] === "}" && (o = 0, n += 2, r.segments.push(u));
303
+ e[n] === "|" ? (o = 2, n += 1, m()) : e[n] === "}" && e[n + 1] === "}" && (o = 0, n += 2, r.segments.push(h));
304
304
  break;
305
305
  }
306
306
  }
307
307
  return o === 0 && a.length > 0 && r.segments.push({ type: 0, text: a }), r;
308
308
  };
309
- var ve, q, L, $e, U, ke, Ee, N, yt, Ye, Xe, Ze, bt;
310
- class It {
309
+ var be, q, x, ve, $e, Ee, ke, O, vt, Ze, et, tt, $t;
310
+ class Wt {
311
311
  constructor(e) {
312
- f(this, N);
313
- f(this, ve);
312
+ f(this, O);
313
+ f(this, be);
314
314
  f(this, q);
315
- f(this, L, /* @__PURE__ */ new Map());
316
- f(this, $e, []);
317
- f(this, U, /* @__PURE__ */ new Map());
318
- f(this, ke, "auto");
319
- P(this, "$locale");
320
- f(this, Ee);
321
- b(this, ve, e), b(this, q, e.createLogger("dolla/i18n"));
322
- const [t, r] = ie();
323
- this.$locale = t, b(this, Ee, r), s(this, U).set("number", (a, n, o) => k(this, N, Ye).call(this, Number(n), o)), s(this, U).set("datetime", (a, n, o) => k(this, N, Xe).call(this, n, o)), s(this, U).set("list", (a, n, o) => k(this, N, Ze).call(this, n, o)), e.beforeMount(async () => {
324
- s(this, L).size > 0 && await this.setLocale(s(this, ke));
315
+ f(this, x, /* @__PURE__ */ new Map());
316
+ f(this, ve, []);
317
+ f(this, $e, /* @__PURE__ */ new Map());
318
+ f(this, Ee, "auto");
319
+ S(this, "$locale");
320
+ f(this, ke);
321
+ b(this, be, e), b(this, q, e.createLogger("dolla/i18n"));
322
+ const [t, r] = se();
323
+ this.$locale = t, b(this, ke, r), this.addFormat("number", (a, n, o) => E(this, O, Ze).call(this, Number(n), o)), this.addFormat("datetime", (a, n, o) => E(this, O, et).call(this, n, o)), this.addFormat("list", (a, n, o) => E(this, O, tt).call(this, n, o)), e.beforeMount(async () => {
324
+ s(this, x).size > 0 && await this.setLocale(s(this, Ee));
325
325
  });
326
326
  }
327
327
  get locales() {
328
- return [...s(this, L).keys()];
328
+ return [...s(this, x).keys()];
329
329
  }
330
330
  setup(e) {
331
331
  if (e.translations.forEach((t) => {
332
- s(this, L).set(t.locale, new Ht(t, s(this, ve)));
332
+ s(this, x).set(t.locale, new It(t, s(this, be)));
333
333
  }), e.locale && e.locale !== "auto") {
334
334
  if (!e.translations.some((r) => r.locale === e.locale))
335
335
  throw new Error(`Initial locale '${e.locale}' is not registered in the locales array.`);
336
- b(this, ke, e.locale);
336
+ b(this, Ee, e.locale);
337
337
  }
338
338
  s(this, q).info(
339
- `${s(this, L).size} language${s(this, L).size === 1 ? "" : "s"} supported: '${[...s(this, L).keys()].join("', '")}'`
339
+ `${s(this, x).size} language${s(this, x).size === 1 ? "" : "s"} supported: '${[...s(this, x).keys()].join("', '")}'`
340
340
  );
341
341
  }
342
342
  async setLocale(e) {
@@ -349,18 +349,18 @@ class It {
349
349
  ((a = o.languages) == null ? void 0 : a.length) > 0 ? n.push(...o.languages) : o.language ? n.push(o.language) : o.browserLanguage ? n.push(o.browserLanguage) : o.userLanguage && n.push(o.userLanguage);
350
350
  }
351
351
  for (const o of n)
352
- s(this, L).has(o) && (t = o);
352
+ s(this, x).has(o) && (t = o);
353
353
  } else
354
- s(this, L).has(e) && (t = e);
354
+ s(this, x).has(e) && (t = e);
355
355
  if (t == null) {
356
- const n = s(this, L).keys().next().value;
356
+ const n = s(this, x).keys().next().value;
357
357
  n && (t = n);
358
358
  }
359
- if (!t || !s(this, L).has(t))
360
- throw new Error(`Language '${e}' is not configured for this app.`);
361
- const r = s(this, L).get(t);
359
+ if (!t || !s(this, x).has(t))
360
+ throw new Error(`Locale '${e}' has no translation.`);
361
+ const r = s(this, x).get(t);
362
362
  try {
363
- await r.load(), b(this, $e, []), s(this, Ee).call(this, t), s(this, q).info("set language to " + t);
363
+ await r.load(), b(this, ve, []), s(this, ke).call(this, t), s(this, q).info("set language to " + t);
364
364
  } catch (n) {
365
365
  n instanceof Error && s(this, q).crash(n);
366
366
  }
@@ -379,16 +379,16 @@ class It {
379
379
  throw new Error(
380
380
  `The 't' function cannot be destructured. If you need a standalone version you can import it like so: 'import { t } from "@manyducks.co/dolla"'`
381
381
  );
382
- if (!this.$locale.get())
383
- return Ut;
384
382
  let r = [], a = [];
385
383
  for (const n in t)
386
384
  r.push(n), a.push(t[n]);
387
- return ye([this.$locale, ...a], (n, ...o) => {
388
- const u = {};
385
+ return we([this.$locale, ...a], (n, ...o) => {
386
+ if (n == null)
387
+ return "[NO LOCALE SET]";
388
+ const h = {};
389
389
  for (let l = 0; l < o.length; l++)
390
- u[r[l]] = o[l];
391
- return k(this, N, yt).call(this, n, e, u);
390
+ h[r[l]] = o[l];
391
+ return E(this, O, vt).call(this, n, e, h);
392
392
  });
393
393
  }
394
394
  /**
@@ -406,7 +406,7 @@ class It {
406
406
  * t("greeting", {name: "world"}); // State<"Hello, WORLD!">
407
407
  */
408
408
  addFormat(e, t) {
409
- s(this, U).set(e, t);
409
+ s(this, $e).set(e, t);
410
410
  }
411
411
  /**
412
412
  * Creates an `Intl.Collator` configured for the current locale.
@@ -423,7 +423,7 @@ class It {
423
423
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
424
424
  */
425
425
  number(e, t) {
426
- return ye([this.$locale, e], (r, a) => k(this, N, Ye).call(this, a, t));
426
+ return we([this.$locale, e], (r, a) => E(this, O, Ze).call(this, a, t));
427
427
  }
428
428
  /**
429
429
  * Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
@@ -435,7 +435,7 @@ class It {
435
435
  * const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
436
436
  */
437
437
  dateTime(e, t) {
438
- return ye([this.$locale, e], (r, a) => k(this, N, Xe).call(this, a, t));
438
+ return we([this.$locale, e], (r, a) => E(this, O, et).call(this, a, t));
439
439
  }
440
440
  /**
441
441
  * Returns a State containing the date formatted for the current locale. Uses `Intl.DateTimeFormat` under the hood.
@@ -447,58 +447,57 @@ class It {
447
447
  * const $formatted = Dolla.i18n.list(list, { });
448
448
  */
449
449
  list(e, t) {
450
- return ye([this.$locale, e], (r, a) => k(this, N, Ze).call(this, a, t));
450
+ return we([this.$locale, e], (r, a) => E(this, O, tt).call(this, a, t));
451
451
  }
452
452
  }
453
- ve = new WeakMap(), q = new WeakMap(), L = new WeakMap(), $e = new WeakMap(), U = new WeakMap(), ke = new WeakMap(), Ee = new WeakMap(), N = new WeakSet(), yt = function(e, t, r) {
454
- const a = k(this, N, bt).call(this, t, r);
453
+ be = new WeakMap(), q = new WeakMap(), x = new WeakMap(), ve = new WeakMap(), $e = new WeakMap(), Ee = new WeakMap(), ke = new WeakMap(), O = new WeakSet(), vt = function(e, t, r) {
454
+ var l;
455
+ const a = E(this, O, $t).call(this, t, r);
455
456
  if (a) return a;
456
- const n = s(this, L).get(e);
457
+ const n = s(this, x).get(e);
457
458
  if (r.context != null && (t += "_" + r.context), r.count != null)
458
459
  if (r.ordinal) {
459
- const l = `${t}_ordinal_(=${r.count})`;
460
- n.hasTemplate(l) ? t = l : t += "_ordinal_" + new Intl.PluralRules(e, { type: "ordinal" }).select(r.count);
460
+ const d = `${t}_ordinal_(=${r.count})`;
461
+ n.hasTemplate(d) ? t = d : t += "_ordinal_" + new Intl.PluralRules(e, { type: "ordinal" }).select(r.count);
461
462
  } else {
462
- const l = `${t}_(=${r.count})`;
463
- n.hasTemplate(l) ? t = l : t += "_" + new Intl.PluralRules(e).select(r.count);
463
+ const d = `${t}_(=${r.count})`;
464
+ n.hasTemplate(d) ? t = d : t += "_" + new Intl.PluralRules(e).select(r.count);
464
465
  }
465
- const o = n.getTemplate(t) || {
466
- segments: [{ type: 0, text: `[MISSING: ${t}]` }]
467
- };
468
- let u = "";
469
- for (const l of o.segments)
470
- if (l.type === 0)
471
- u += l.text;
472
- else if (l.type === 1) {
473
- const g = [...l.formats];
474
- let m = Gt(r, l.name);
475
- l.name === "count" && g.length === 0 && g.push({ name: "number", options: {} });
476
- for (const p of g) {
477
- const h = s(this, U).get(p.name);
478
- if (h == null) {
479
- const y = new Error(
480
- `Failed to load format '${p.name}' when processing '${t}', template: ${o}`
466
+ const o = n.getTemplate(t);
467
+ let h = "";
468
+ for (const d of o.segments)
469
+ if (d.type === 0)
470
+ h += d.text;
471
+ else if (d.type === 1) {
472
+ let g = Gt(r, d.name);
473
+ const m = ((l = r.formatOverrides) == null ? void 0 : l[d.name]) ?? [...d.formats];
474
+ d.name === "count" && m.length === 0 && m.push({ name: "number", options: {} });
475
+ for (const u of m) {
476
+ const y = s(this, $e).get(u.name);
477
+ if (y == null) {
478
+ const k = new Error(
479
+ `Failed to load format '${u.name}' when processing '${t}', template: ${o}`
481
480
  );
482
- throw s(this, q).crash(y), y;
481
+ throw s(this, q).crash(k), k;
483
482
  }
484
- m = h(e, m, p.options);
483
+ g = y(e, g, u.options);
485
484
  }
486
- u += m;
485
+ h += g;
487
486
  }
488
- return u;
489
- }, Ye = function(e, t) {
487
+ return h;
488
+ }, Ze = function(e, t) {
490
489
  return new Intl.NumberFormat(this.$locale.get(), t).format(e);
491
- }, Xe = function(e, t) {
490
+ }, et = function(e, t) {
492
491
  return new Intl.DateTimeFormat(this.$locale.get(), t).format(
493
492
  typeof e == "string" ? new Date(e) : e
494
493
  );
495
- }, Ze = function(e, t) {
494
+ }, tt = function(e, t) {
496
495
  return new Intl.ListFormat(this.$locale.get(), t).format(e);
497
496
  }, // relativeTime(): State<string> {
498
497
  // }
499
- bt = function(e, t) {
500
- for (const r of s(this, $e))
501
- if (r[0] === e && St(r[1], t))
498
+ $t = function(e, t) {
499
+ for (const r of s(this, ve))
500
+ if (r[0] === e && Rt(r[1], t))
502
501
  return r[2];
503
502
  };
504
503
  function Gt(i, e) {
@@ -510,21 +509,21 @@ function Gt(i, e) {
510
509
  }
511
510
  return r;
512
511
  }
513
- var X, Pe, H, I, le, C, ce, _e;
514
- class Wt {
512
+ var J, Pe, U, H, oe, F, le, Ce;
513
+ class Bt {
515
514
  constructor(e) {
516
- f(this, ce);
517
- f(this, X);
515
+ f(this, le);
516
+ f(this, J);
518
517
  f(this, Pe);
519
518
  // Keyed updates ensure only the most recent callback queued with a certain key
520
519
  // will be called, keeping DOM operations to a minimum.
521
- f(this, H, /* @__PURE__ */ new Map());
520
+ f(this, U, /* @__PURE__ */ new Map());
522
521
  // All unkeyed updates are run on every batch.
523
- f(this, I, []);
522
+ f(this, H, []);
524
523
  // All read callbacks are run before updates on every batch.
525
- f(this, le, []);
526
- f(this, C, !1);
527
- b(this, X, e), b(this, Pe, e.createLogger("dolla/render"));
524
+ f(this, oe, []);
525
+ f(this, F, !1);
526
+ b(this, J, e), b(this, Pe, e.createLogger("dolla/render"));
528
527
  }
529
528
  /**
530
529
  * Queues a callback to run in the next render batch.
@@ -533,11 +532,11 @@ class Wt {
533
532
  */
534
533
  update(e, t) {
535
534
  return new Promise((r) => {
536
- t ? s(this, H).set(t, () => {
535
+ t ? s(this, U).set(t, () => {
537
536
  e(), r();
538
- }) : s(this, I).push(() => {
537
+ }) : s(this, H).push(() => {
539
538
  e(), r();
540
- }), !s(this, C) && s(this, X).isMounted && (b(this, C, !0), k(this, ce, _e).call(this));
539
+ }), !s(this, F) && s(this, J).isMounted && (b(this, F, !0), E(this, le, Ce).call(this));
541
540
  });
542
541
  }
543
542
  /**
@@ -547,49 +546,49 @@ class Wt {
547
546
  */
548
547
  read(e) {
549
548
  return new Promise((t) => {
550
- s(this, le).push(() => {
549
+ s(this, oe).push(() => {
551
550
  e(), t();
552
- }), !s(this, C) && s(this, X).isMounted && (b(this, C, !0), k(this, ce, _e).call(this));
551
+ }), !s(this, F) && s(this, J).isMounted && (b(this, F, !0), E(this, le, Ce).call(this));
553
552
  });
554
553
  }
555
554
  }
556
- X = new WeakMap(), Pe = new WeakMap(), H = new WeakMap(), I = new WeakMap(), le = new WeakMap(), C = new WeakMap(), ce = new WeakSet(), _e = function() {
557
- const e = s(this, H).size + s(this, I).length;
558
- if ((!s(this, X).isMounted || e === 0) && b(this, C, !1), !s(this, C)) {
559
- for (const t of s(this, le))
555
+ J = new WeakMap(), Pe = new WeakMap(), U = new WeakMap(), H = new WeakMap(), oe = new WeakMap(), F = new WeakMap(), le = new WeakSet(), Ce = function() {
556
+ const e = s(this, U).size + s(this, H).length;
557
+ if ((!s(this, J).isMounted || e === 0) && b(this, F, !1), !s(this, F)) {
558
+ for (const t of s(this, oe))
560
559
  t();
561
- b(this, le, []);
560
+ b(this, oe, []);
562
561
  return;
563
562
  }
564
563
  requestAnimationFrame(() => {
565
- s(this, Pe).info(`Batching ${s(this, H).size + s(this, I).length} queued DOM update(s).`);
566
- for (const t of s(this, H).values())
564
+ s(this, Pe).info(`Batching ${s(this, U).size + s(this, H).length} queued DOM update(s).`);
565
+ for (const t of s(this, U).values())
567
566
  t();
568
- s(this, H).clear();
569
- for (const t of s(this, I))
567
+ s(this, U).clear();
568
+ for (const t of s(this, H))
570
569
  t();
571
- b(this, I, []), k(this, ce, _e).call(this);
570
+ b(this, H, []), E(this, le, Ce).call(this);
572
571
  });
573
572
  };
574
- function de() {
575
- return de = Object.assign ? Object.assign.bind() : function(i) {
573
+ function fe() {
574
+ return fe = Object.assign ? Object.assign.bind() : function(i) {
576
575
  for (var e = 1; e < arguments.length; e++) {
577
576
  var t = arguments[e];
578
577
  for (var r in t) ({}).hasOwnProperty.call(t, r) && (i[r] = t[r]);
579
578
  }
580
579
  return i;
581
- }, de.apply(null, arguments);
580
+ }, fe.apply(null, arguments);
582
581
  }
583
- var A;
582
+ var _;
584
583
  (function(i) {
585
584
  i.Pop = "POP", i.Push = "PUSH", i.Replace = "REPLACE";
586
- })(A || (A = {}));
587
- var qe = process.env.NODE_ENV !== "production" ? function(i) {
585
+ })(_ || (_ = {}));
586
+ var He = process.env.NODE_ENV !== "production" ? function(i) {
588
587
  return Object.freeze(i);
589
588
  } : function(i) {
590
589
  return i;
591
590
  };
592
- function Ce(i, e) {
591
+ function Ve(i, e) {
593
592
  if (!i) {
594
593
  typeof console < "u" && console.warn(e);
595
594
  try {
@@ -598,38 +597,38 @@ function Ce(i, e) {
598
597
  }
599
598
  }
600
599
  }
601
- var Ue = "beforeunload", zt = "hashchange", vt = "popstate";
602
- function Bt(i) {
600
+ var Ie = "beforeunload", zt = "hashchange", Et = "popstate";
601
+ function Kt(i) {
603
602
  i === void 0 && (i = {});
604
603
  var e = i, t = e.window, r = t === void 0 ? document.defaultView : t, a = r.history;
605
604
  function n() {
606
- var w = r.location, c = w.pathname, d = w.search, v = w.hash, $ = a.state || {};
607
- return [$.idx, qe({
605
+ var w = r.location, c = w.pathname, p = w.search, v = w.hash, $ = a.state || {};
606
+ return [$.idx, He({
608
607
  pathname: c,
609
- search: d,
608
+ search: p,
610
609
  hash: v,
611
610
  state: $.usr || null,
612
611
  key: $.key || "default"
613
612
  })];
614
613
  }
615
614
  var o = null;
616
- function u() {
615
+ function h() {
617
616
  if (o)
618
617
  y.call(o), o = null;
619
618
  else {
620
- var w = A.Pop, c = n(), d = c[0], v = c[1];
619
+ var w = _.Pop, c = n(), p = c[0], v = c[1];
621
620
  if (y.length)
622
- if (d != null) {
623
- var $ = m - d;
621
+ if (p != null) {
622
+ var $ = g - p;
624
623
  $ && (o = {
625
624
  action: w,
626
625
  location: v,
627
626
  retry: function() {
628
- V($ * -1);
627
+ C($ * -1);
629
628
  }
630
- }, V($));
629
+ }, C($));
631
630
  } else
632
- process.env.NODE_ENV !== "production" && Ce(
631
+ process.env.NODE_ENV !== "production" && Ve(
633
632
  !1,
634
633
  // TODO: Write up a doc that explains our blocking strategy in
635
634
  // detail and link to it here so people can understand better what
@@ -637,137 +636,137 @@ function Bt(i) {
637
636
  "You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation."
638
637
  );
639
638
  else
640
- ne(w);
639
+ re(w);
641
640
  }
642
641
  }
643
- r.addEventListener(vt, u);
644
- var l = A.Pop, g = n(), m = g[0], p = g[1], h = Ie(), y = Ie();
645
- m == null && (m = 0, a.replaceState(de({}, a.state, {
646
- idx: m
642
+ r.addEventListener(Et, h);
643
+ var l = _.Pop, d = n(), g = d[0], m = d[1], u = Ge(), y = Ge();
644
+ g == null && (g = 0, a.replaceState(fe({}, a.state, {
645
+ idx: g
647
646
  }), ""));
648
- function S(w) {
649
- return typeof w == "string" ? w : Ve(w);
647
+ function k(w) {
648
+ return typeof w == "string" ? w : qe(w);
650
649
  }
651
- function pe(w, c) {
652
- return c === void 0 && (c = null), qe(de({
653
- pathname: p.pathname,
650
+ function de(w, c) {
651
+ return c === void 0 && (c = null), He(fe({
652
+ pathname: m.pathname,
654
653
  hash: "",
655
654
  search: ""
656
- }, typeof w == "string" ? et(w) : w, {
655
+ }, typeof w == "string" ? rt(w) : w, {
657
656
  state: c,
658
- key: $t()
657
+ key: kt()
659
658
  }));
660
659
  }
661
- function ge(w, c) {
660
+ function pe(w, c) {
662
661
  return [{
663
662
  usr: w.state,
664
663
  key: w.key,
665
664
  idx: c
666
- }, S(w)];
665
+ }, k(w)];
667
666
  }
668
- function me(w, c, d) {
667
+ function me(w, c, p) {
669
668
  return !y.length || (y.call({
670
669
  action: w,
671
670
  location: c,
672
- retry: d
671
+ retry: p
673
672
  }), !1);
674
673
  }
675
- function ne(w) {
674
+ function re(w) {
676
675
  l = w;
677
676
  var c = n();
678
- m = c[0], p = c[1], h.call({
677
+ g = c[0], m = c[1], u.call({
679
678
  action: l,
680
- location: p
679
+ location: m
681
680
  });
682
681
  }
683
- function ae(w, c) {
684
- var d = A.Push, v = pe(w, c);
682
+ function ne(w, c) {
683
+ var p = _.Push, v = de(w, c);
685
684
  function $() {
686
- ae(w, c);
685
+ ne(w, c);
687
686
  }
688
- if (me(d, v, $)) {
689
- var R = ge(v, m + 1), O = R[0], j = R[1];
687
+ if (me(p, v, $)) {
688
+ var L = pe(v, g + 1), N = L[0], D = L[1];
690
689
  try {
691
- a.pushState(O, "", j);
690
+ a.pushState(N, "", D);
692
691
  } catch {
693
- r.location.assign(j);
692
+ r.location.assign(D);
694
693
  }
695
- ne(d);
694
+ re(p);
696
695
  }
697
696
  }
698
- function we(w, c) {
699
- var d = A.Replace, v = pe(w, c);
697
+ function ge(w, c) {
698
+ var p = _.Replace, v = de(w, c);
700
699
  function $() {
701
- we(w, c);
700
+ ge(w, c);
702
701
  }
703
- if (me(d, v, $)) {
704
- var R = ge(v, m), O = R[0], j = R[1];
705
- a.replaceState(O, "", j), ne(d);
702
+ if (me(p, v, $)) {
703
+ var L = pe(v, g), N = L[0], D = L[1];
704
+ a.replaceState(N, "", D), re(p);
706
705
  }
707
706
  }
708
- function V(w) {
707
+ function C(w) {
709
708
  a.go(w);
710
709
  }
711
- var J = {
710
+ var K = {
712
711
  get action() {
713
712
  return l;
714
713
  },
715
714
  get location() {
716
- return p;
715
+ return m;
717
716
  },
718
- createHref: S,
719
- push: ae,
720
- replace: we,
721
- go: V,
717
+ createHref: k,
718
+ push: ne,
719
+ replace: ge,
720
+ go: C,
722
721
  back: function() {
723
- V(-1);
722
+ C(-1);
724
723
  },
725
724
  forward: function() {
726
- V(1);
725
+ C(1);
727
726
  },
728
727
  listen: function(c) {
729
- return h.push(c);
728
+ return u.push(c);
730
729
  },
731
730
  block: function(c) {
732
- var d = y.push(c);
733
- return y.length === 1 && r.addEventListener(Ue, He), function() {
734
- d(), y.length || r.removeEventListener(Ue, He);
731
+ var p = y.push(c);
732
+ return y.length === 1 && r.addEventListener(Ie, We), function() {
733
+ p(), y.length || r.removeEventListener(Ie, We);
735
734
  };
736
735
  }
737
736
  };
738
- return J;
737
+ return K;
739
738
  }
740
- function Kt(i) {
739
+ function Qt(i) {
741
740
  i === void 0 && (i = {});
742
741
  var e = i, t = e.window, r = t === void 0 ? document.defaultView : t, a = r.history;
743
742
  function n() {
744
- var c = et(r.location.hash.substr(1)), d = c.pathname, v = d === void 0 ? "/" : d, $ = c.search, R = $ === void 0 ? "" : $, O = c.hash, j = O === void 0 ? "" : O, D = a.state || {};
745
- return [D.idx, qe({
743
+ var c = rt(r.location.hash.substr(1)), p = c.pathname, v = p === void 0 ? "/" : p, $ = c.search, L = $ === void 0 ? "" : $, N = c.hash, D = N === void 0 ? "" : N, A = a.state || {};
744
+ return [A.idx, He({
746
745
  pathname: v,
747
- search: R,
748
- hash: j,
749
- state: D.usr || null,
750
- key: D.key || "default"
746
+ search: L,
747
+ hash: D,
748
+ state: A.usr || null,
749
+ key: A.key || "default"
751
750
  })];
752
751
  }
753
752
  var o = null;
754
- function u() {
753
+ function h() {
755
754
  if (o)
756
755
  y.call(o), o = null;
757
756
  else {
758
- var c = A.Pop, d = n(), v = d[0], $ = d[1];
757
+ var c = _.Pop, p = n(), v = p[0], $ = p[1];
759
758
  if (y.length)
760
759
  if (v != null) {
761
- var R = m - v;
762
- R && (o = {
760
+ var L = g - v;
761
+ L && (o = {
763
762
  action: c,
764
763
  location: $,
765
764
  retry: function() {
766
- J(R * -1);
765
+ K(L * -1);
767
766
  }
768
- }, J(R));
767
+ }, K(L));
769
768
  } else
770
- process.env.NODE_ENV !== "production" && Ce(
769
+ process.env.NODE_ENV !== "production" && Ve(
771
770
  !1,
772
771
  // TODO: Write up a doc that explains our blocking strategy in
773
772
  // detail and link to it here so people can understand better
@@ -775,86 +774,86 @@ function Kt(i) {
775
774
  "You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation."
776
775
  );
777
776
  else
778
- ae(c);
777
+ ne(c);
779
778
  }
780
779
  }
781
- r.addEventListener(vt, u), r.addEventListener(zt, function() {
782
- var c = n(), d = c[1];
783
- Ve(d) !== Ve(p) && u();
780
+ r.addEventListener(Et, h), r.addEventListener(zt, function() {
781
+ var c = n(), p = c[1];
782
+ qe(p) !== qe(m) && h();
784
783
  });
785
- var l = A.Pop, g = n(), m = g[0], p = g[1], h = Ie(), y = Ie();
786
- m == null && (m = 0, a.replaceState(de({}, a.state, {
787
- idx: m
784
+ var l = _.Pop, d = n(), g = d[0], m = d[1], u = Ge(), y = Ge();
785
+ g == null && (g = 0, a.replaceState(fe({}, a.state, {
786
+ idx: g
788
787
  }), ""));
789
- function S() {
790
- var c = document.querySelector("base"), d = "";
788
+ function k() {
789
+ var c = document.querySelector("base"), p = "";
791
790
  if (c && c.getAttribute("href")) {
792
791
  var v = r.location.href, $ = v.indexOf("#");
793
- d = $ === -1 ? v : v.slice(0, $);
792
+ p = $ === -1 ? v : v.slice(0, $);
794
793
  }
795
- return d;
794
+ return p;
796
795
  }
797
- function pe(c) {
798
- return S() + "#" + (typeof c == "string" ? c : Ve(c));
796
+ function de(c) {
797
+ return k() + "#" + (typeof c == "string" ? c : qe(c));
799
798
  }
800
- function ge(c, d) {
801
- return d === void 0 && (d = null), qe(de({
802
- pathname: p.pathname,
799
+ function pe(c, p) {
800
+ return p === void 0 && (p = null), He(fe({
801
+ pathname: m.pathname,
803
802
  hash: "",
804
803
  search: ""
805
- }, typeof c == "string" ? et(c) : c, {
806
- state: d,
807
- key: $t()
804
+ }, typeof c == "string" ? rt(c) : c, {
805
+ state: p,
806
+ key: kt()
808
807
  }));
809
808
  }
810
- function me(c, d) {
809
+ function me(c, p) {
811
810
  return [{
812
811
  usr: c.state,
813
812
  key: c.key,
814
- idx: d
815
- }, pe(c)];
813
+ idx: p
814
+ }, de(c)];
816
815
  }
817
- function ne(c, d, v) {
816
+ function re(c, p, v) {
818
817
  return !y.length || (y.call({
819
818
  action: c,
820
- location: d,
819
+ location: p,
821
820
  retry: v
822
821
  }), !1);
823
822
  }
824
- function ae(c) {
823
+ function ne(c) {
825
824
  l = c;
826
- var d = n();
827
- m = d[0], p = d[1], h.call({
825
+ var p = n();
826
+ g = p[0], m = p[1], u.call({
828
827
  action: l,
829
- location: p
828
+ location: m
830
829
  });
831
830
  }
832
- function we(c, d) {
833
- var v = A.Push, $ = ge(c, d);
834
- function R() {
835
- we(c, d);
831
+ function ge(c, p) {
832
+ var v = _.Push, $ = pe(c, p);
833
+ function L() {
834
+ ge(c, p);
836
835
  }
837
- if (process.env.NODE_ENV !== "production" && Ce($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(c) + ")"), ne(v, $, R)) {
838
- var O = me($, m + 1), j = O[0], D = O[1];
836
+ if (process.env.NODE_ENV !== "production" && Ve($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(c) + ")"), re(v, $, L)) {
837
+ var N = me($, g + 1), D = N[0], A = N[1];
839
838
  try {
840
- a.pushState(j, "", D);
839
+ a.pushState(D, "", A);
841
840
  } catch {
842
- r.location.assign(D);
841
+ r.location.assign(A);
843
842
  }
844
- ae(v);
843
+ ne(v);
845
844
  }
846
845
  }
847
- function V(c, d) {
848
- var v = A.Replace, $ = ge(c, d);
849
- function R() {
850
- V(c, d);
846
+ function C(c, p) {
847
+ var v = _.Replace, $ = pe(c, p);
848
+ function L() {
849
+ C(c, p);
851
850
  }
852
- if (process.env.NODE_ENV !== "production" && Ce($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(c) + ")"), ne(v, $, R)) {
853
- var O = me($, m), j = O[0], D = O[1];
854
- a.replaceState(j, "", D), ae(v);
851
+ if (process.env.NODE_ENV !== "production" && Ve($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(c) + ")"), re(v, $, L)) {
852
+ var N = me($, g), D = N[0], A = N[1];
853
+ a.replaceState(D, "", A), ne(v);
855
854
  }
856
855
  }
857
- function J(c) {
856
+ function K(c) {
858
857
  a.go(c);
859
858
  }
860
859
  var w = {
@@ -862,34 +861,34 @@ function Kt(i) {
862
861
  return l;
863
862
  },
864
863
  get location() {
865
- return p;
864
+ return m;
866
865
  },
867
- createHref: pe,
868
- push: we,
869
- replace: V,
870
- go: J,
866
+ createHref: de,
867
+ push: ge,
868
+ replace: C,
869
+ go: K,
871
870
  back: function() {
872
- J(-1);
871
+ K(-1);
873
872
  },
874
873
  forward: function() {
875
- J(1);
874
+ K(1);
876
875
  },
877
- listen: function(d) {
878
- return h.push(d);
876
+ listen: function(p) {
877
+ return u.push(p);
879
878
  },
880
- block: function(d) {
881
- var v = y.push(d);
882
- return y.length === 1 && r.addEventListener(Ue, He), function() {
883
- v(), y.length || r.removeEventListener(Ue, He);
879
+ block: function(p) {
880
+ var v = y.push(p);
881
+ return y.length === 1 && r.addEventListener(Ie, We), function() {
882
+ v(), y.length || r.removeEventListener(Ie, We);
884
883
  };
885
884
  }
886
885
  };
887
886
  return w;
888
887
  }
889
- function He(i) {
888
+ function We(i) {
890
889
  i.preventDefault(), i.returnValue = "";
891
890
  }
892
- function Ie() {
891
+ function Ge() {
893
892
  var i = [];
894
893
  return {
895
894
  get length() {
@@ -909,14 +908,14 @@ function Ie() {
909
908
  }
910
909
  };
911
910
  }
912
- function $t() {
911
+ function kt() {
913
912
  return Math.random().toString(36).substr(2, 8);
914
913
  }
915
- function Ve(i) {
914
+ function qe(i) {
916
915
  var e = i.pathname, t = e === void 0 ? "/" : e, r = i.search, a = r === void 0 ? "" : r, n = i.hash, o = n === void 0 ? "" : n;
917
916
  return a && a !== "?" && (t += a.charAt(0) === "?" ? a : "?" + a), o && o !== "#" && (t += o.charAt(0) === "#" ? o : "#" + o), t;
918
917
  }
919
- function et(i) {
918
+ function rt(i) {
920
919
  var e = {};
921
920
  if (i) {
922
921
  var t = i.indexOf("#");
@@ -926,26 +925,26 @@ function et(i) {
926
925
  }
927
926
  return e;
928
927
  }
929
- function be(i) {
930
- return pt(i, "Expected `path` to be a string. Got type: %t, value: %v"), i.split("/").map((e) => e.trim()).filter((e) => e !== "");
928
+ function ye(i) {
929
+ return wt(i, "Expected `path` to be a string. Got type: %t, value: %v"), i.split("/").map((e) => e.trim()).filter((e) => e !== "");
931
930
  }
932
- function se(i) {
931
+ function ae(i) {
933
932
  var t;
934
- Rt(
935
- (r) => at(r == null ? void 0 : r.toString),
933
+ xt(
934
+ (r) => it(r == null ? void 0 : r.toString),
936
935
  i,
937
936
  "Expected `parts` to be an array of objects with a .toString() method. Got type: %t, value: %v"
938
937
  ), i = i.filter((r) => r).flatMap(String);
939
938
  let e = (t = i.shift()) == null ? void 0 : t.toString();
940
939
  if (e) {
941
940
  for (const r of i.map((a) => a.toString()))
942
- r.startsWith(".") ? e = Fe(e, r) : e[e.length - 1] !== "/" ? r[0] !== "/" ? e += "/" + r : e += r : r[0] === "/" ? e += r.slice(1) : e += r;
941
+ r.startsWith(".") ? e = Ue(e, r) : e[e.length - 1] !== "/" ? r[0] !== "/" ? e += "/" + r : e += r : r[0] === "/" ? e += r.slice(1) : e += r;
943
942
  e && e !== "/" && e.endsWith("/") && (e = e.slice(0, e.length - 1));
944
943
  }
945
944
  return e ?? "";
946
945
  }
947
- function Fe(i, e) {
948
- if (pt(i, "Expected `base` to be a string. Got type: %t, value: %v"), e == null && (e = i, i = ""), e.startsWith("/"))
946
+ function Ue(i, e) {
947
+ if (wt(i, "Expected `base` to be a string. Got type: %t, value: %v"), e == null && (e = i, i = ""), e.startsWith("/"))
949
948
  return e;
950
949
  let t = i;
951
950
  for (; ; )
@@ -959,9 +958,9 @@ function Fe(i, e) {
959
958
  e = e.replace(/^\.\/?/, "");
960
959
  else
961
960
  break;
962
- return se([t, e]);
961
+ return ae([t, e]);
963
962
  }
964
- function tt(i) {
963
+ function nt(i) {
965
964
  if (!i) return {};
966
965
  i.startsWith("?") && (i = i.slice(1));
967
966
  const e = i.split("&").filter((t) => t.trim() !== "").map((t) => {
@@ -970,72 +969,72 @@ function tt(i) {
970
969
  });
971
970
  return Object.fromEntries(e);
972
971
  }
973
- function ft(i, e, t = {}) {
972
+ function mt(i, e, t = {}) {
974
973
  var o;
975
- const [r, a] = e.split("?"), n = be(r);
976
- e: for (const u of i) {
977
- const { fragments: l } = u;
978
- if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !== n.length || t.willMatch && !t.willMatch(u))
974
+ const [r, a] = e.split("?"), n = ye(r);
975
+ e: for (const h of i) {
976
+ const { fragments: l } = h;
977
+ if (!(((o = l[l.length - 1]) == null ? void 0 : o.type) === 3) && l.length !== n.length || t.willMatch && !t.willMatch(h))
979
978
  continue e;
980
- const m = [];
981
- t: for (let h = 0; h < l.length; h++) {
982
- const y = n[h], S = l[h];
983
- if (y == null && S.type !== 3)
979
+ const g = [];
980
+ t: for (let u = 0; u < l.length; u++) {
981
+ const y = n[u], k = l[u];
982
+ if (y == null && k.type !== 3)
984
983
  continue e;
985
- switch (S.type) {
984
+ switch (k.type) {
986
985
  case 1:
987
- if (S.name.toLowerCase() === y.toLowerCase()) {
988
- m.push(S);
986
+ if (k.name.toLowerCase() === y.toLowerCase()) {
987
+ g.push(k);
989
988
  break;
990
989
  } else
991
990
  continue e;
992
991
  case 2:
993
- m.push({ ...S, value: y });
992
+ g.push({ ...k, value: y });
994
993
  break;
995
994
  case 3:
996
- m.push({ ...S, value: n.slice(h).join("/") });
995
+ g.push({ ...k, value: n.slice(u).join("/") });
997
996
  break t;
998
997
  case 4:
999
998
  if (isNaN(Number(y)))
1000
999
  continue e;
1001
- m.push({ ...S, value: Number(y) });
1000
+ g.push({ ...k, value: Number(y) });
1002
1001
  break;
1003
1002
  default:
1004
- throw new Error(`Unknown fragment type: ${S.type}`);
1003
+ throw new Error(`Unknown fragment type: ${k.type}`);
1005
1004
  }
1006
1005
  }
1007
- const p = /* @__PURE__ */ Object.create(null);
1008
- for (const h of m)
1009
- h.type === 2 && (p[h.name] = decodeURIComponent(h.value)), h.type === 4 && (p[h.name] = h.value), h.type === 3 && (p.wildcard = "/" + decodeURIComponent(h.value));
1006
+ const m = /* @__PURE__ */ Object.create(null);
1007
+ for (const u of g)
1008
+ u.type === 2 && (m[u.name] = decodeURIComponent(u.value)), u.type === 4 && (m[u.name] = u.value), u.type === 3 && (m.wildcard = "/" + decodeURIComponent(u.value));
1010
1009
  return {
1011
- path: "/" + m.map((h) => h.value).join("/"),
1012
- pattern: "/" + l.map((h) => h.type === 2 ? `{${h.name}}` : h.type === 4 ? `{#${h.name}}` : h.name).join("/"),
1013
- params: p,
1014
- query: tt(a),
1015
- meta: u.meta
1010
+ path: "/" + g.map((u) => u.value).join("/"),
1011
+ pattern: "/" + l.map((u) => u.type === 2 ? `{${u.name}}` : u.type === 4 ? `{#${u.name}}` : u.name).join("/"),
1012
+ params: m,
1013
+ query: nt(a),
1014
+ meta: h.meta
1016
1015
  };
1017
1016
  }
1018
1017
  }
1019
- function Qt(i) {
1018
+ function Jt(i) {
1020
1019
  const e = [], t = [], r = [], a = [];
1021
1020
  for (const o of i) {
1022
- const { fragments: u } = o;
1023
- u.some(
1021
+ const { fragments: h } = o;
1022
+ h.some(
1024
1023
  (l) => l.type === 3
1025
1024
  /* Wildcard */
1026
- ) ? a.push(o) : u.some(
1025
+ ) ? a.push(o) : h.some(
1027
1026
  (l) => l.type === 4
1028
1027
  /* NumericParam */
1029
- ) ? t.push(o) : u.some(
1028
+ ) ? t.push(o) : h.some(
1030
1029
  (l) => l.type === 2
1031
1030
  /* Param */
1032
1031
  ) ? r.push(o) : e.push(o);
1033
1032
  }
1034
- const n = (o, u) => o.fragments.length > u.fragments.length ? -1 : 1;
1033
+ const n = (o, h) => o.fragments.length > h.fragments.length ? -1 : 1;
1035
1034
  return e.sort(n), t.sort(n), r.sort(n), a.sort(n), [...e, ...t, ...r, ...a];
1036
1035
  }
1037
- function Jt(i) {
1038
- const e = be(i), t = [];
1036
+ function Yt(i) {
1037
+ const e = ye(i), t = [];
1039
1038
  for (let r = 0; r < e.length; r++) {
1040
1039
  const a = e[r];
1041
1040
  if (a === "*") {
@@ -1058,65 +1057,65 @@ function Jt(i) {
1058
1057
  }
1059
1058
  return t;
1060
1059
  }
1061
- var Se, M, Z, E, ze, G, Re, ee, W, ue, he, fe, xe, Q, rt, nt;
1062
- class Yt {
1060
+ var Se, M, Y, Le, P, Ke, I, Re, X, Z, ce, ue, he, xe, z, at, st;
1061
+ class Xt {
1063
1062
  constructor(e, t) {
1064
- f(this, Q);
1063
+ f(this, z);
1065
1064
  f(this, Se);
1066
1065
  f(this, M);
1067
- f(this, Z);
1068
- f(this, E);
1069
- f(this, ze, 0);
1070
- f(this, G, []);
1066
+ f(this, Y);
1067
+ f(this, Le, Ye());
1068
+ f(this, P);
1069
+ f(this, Ke, 0);
1070
+ f(this, I, []);
1071
1071
  f(this, Re);
1072
- f(this, ee, []);
1072
+ f(this, X, []);
1073
1073
  // Callbacks that need to be called on unmount.
1074
- f(this, W, []);
1074
+ f(this, Z, []);
1075
1075
  /**
1076
1076
  * The currently matched route pattern, if any.
1077
1077
  */
1078
- P(this, "$pattern");
1079
- f(this, ue);
1078
+ S(this, "$pattern");
1079
+ f(this, ce);
1080
1080
  /**
1081
1081
  * The current URL path.
1082
1082
  */
1083
- P(this, "$path");
1084
- f(this, he);
1083
+ S(this, "$path");
1084
+ f(this, ue);
1085
1085
  /**
1086
1086
  * The current named path params.
1087
1087
  */
1088
- P(this, "$params");
1089
- f(this, fe);
1088
+ S(this, "$params");
1089
+ f(this, he);
1090
1090
  /**
1091
1091
  * The current query params. Changes to this object will be reflected in the URL.
1092
1092
  */
1093
- P(this, "$query");
1093
+ S(this, "$query");
1094
1094
  f(this, xe);
1095
- b(this, Se, e), b(this, M, e.createLogger("dolla/router")), b(this, Z, t);
1096
- const [r, a] = ie(null), [n, o] = ie(""), [u, l] = ie({}), [g, m] = ie(
1097
- tt(typeof window > "u" ? "" : window.location.search ?? "")
1095
+ b(this, Se, e), b(this, M, e.createLogger("dolla/router")), b(this, Y, t);
1096
+ const [r, a] = se(null), [n, o] = se(""), [h, l] = se({}), [d, g] = se(
1097
+ nt(typeof window > "u" ? "" : window.location.search ?? "")
1098
1098
  );
1099
- this.$pattern = r, b(this, ue, a), this.$path = n, b(this, he, o), this.$params = u, b(this, fe, l), this.$query = g, b(this, xe, m), e.beforeMount(() => {
1100
- s(this, E) != null && (s(this, W).push(
1101
- gt([g], (p) => {
1102
- const h = new URLSearchParams();
1103
- for (const S in p)
1104
- h.set(S, String(p[S]));
1105
- const y = "?" + h.toString();
1106
- y != s(this, E).location.search && s(this, E).replace({
1107
- pathname: s(this, E).location.pathname,
1108
- search: y
1109
- });
1110
- })
1111
- ), s(this, W).push(s(this, E).listen(k(this, Q, nt).bind(this))), k(this, Q, nt).call(this, s(this, E)), s(this, W).push(
1112
- er(s(this, Z).rootElement, (p) => {
1113
- let h = p.getAttribute("href");
1114
- s(this, M).info("Intercepted link click", p, h), /^https?:\/\/|^\//.test(h) || (h = se([s(this, E).location.pathname, h])), s(this, E).push(h);
1099
+ this.$pattern = r, b(this, ce, a), this.$path = n, b(this, ue, o), this.$params = h, b(this, he, l), this.$query = d, b(this, xe, g), e.beforeMount(() => {
1100
+ s(this, P) != null && (s(this, Le).watch([d], (m) => {
1101
+ const u = new URLSearchParams();
1102
+ for (const k in m)
1103
+ u.set(k, String(m[k]));
1104
+ const y = "?" + u.toString();
1105
+ y != s(this, P).location.search && s(this, P).replace({
1106
+ pathname: s(this, P).location.pathname,
1107
+ search: y
1108
+ });
1109
+ }), s(this, Z).push(s(this, P).listen(E(this, z, st).bind(this))), E(this, z, st).call(this, s(this, P)), s(this, Z).push(
1110
+ tr(s(this, Y).rootElement, (m) => {
1111
+ let u = m.getAttribute("href");
1112
+ s(this, M).info("Intercepted link click", m, u), /^https?:\/\/|^\//.test(u) || (u = ae([s(this, P).location.pathname, u])), s(this, P).push(u);
1115
1113
  })
1116
- ), s(this, M).info("Intercepting <a> clicks within root element:", s(this, Z).rootElement));
1114
+ ), s(this, M).info("Intercepting <a> clicks within root element:", s(this, Y).rootElement));
1117
1115
  }), e.onUnmount(() => {
1118
- for (; s(this, W).length > 0; )
1119
- s(this, W).pop()();
1116
+ for (; s(this, Z).length > 0; )
1117
+ s(this, Z).pop()();
1118
+ s(this, Le).stopAll();
1120
1119
  });
1121
1120
  }
1122
1121
  setup(e) {
@@ -1126,18 +1125,18 @@ class Yt {
1126
1125
  );
1127
1126
  return;
1128
1127
  }
1129
- e.style === "hash" ? b(this, E, Kt()) : b(this, E, Bt()), b(this, ee, Qt(
1130
- e.routes.flatMap((t) => k(this, Q, rt).call(this, t)).map((t) => ({
1128
+ e.style === "hash" ? b(this, P, Qt()) : b(this, P, Kt()), b(this, X, Jt(
1129
+ e.routes.flatMap((t) => E(this, z, at).call(this, t)).map((t) => ({
1131
1130
  pattern: t.pattern,
1132
1131
  meta: t.meta,
1133
- fragments: Jt(t.pattern)
1132
+ fragments: Yt(t.pattern)
1134
1133
  }))
1135
1134
  ));
1136
- for (const t of s(this, ee))
1135
+ for (const t of s(this, X))
1137
1136
  if (t.meta.redirect) {
1138
1137
  let r;
1139
- if (!at(t.meta.redirect)) if (F(t.meta.redirect)) {
1140
- if (r = t.meta.redirect, !ft(s(this, ee), r, {
1138
+ if (!it(t.meta.redirect)) if (V(t.meta.redirect)) {
1139
+ if (r = t.meta.redirect, !mt(s(this, X), r, {
1141
1140
  willMatch(n) {
1142
1141
  return n !== t;
1143
1142
  }
@@ -1157,7 +1156,7 @@ class Yt {
1157
1156
  * Dolla.router.go["/users", 215], { replace: true }); // replace current history entry with `/users/215`
1158
1157
  */
1159
1158
  go(e, t = {}) {
1160
- if (s(this, E) == null) {
1159
+ if (s(this, P) == null) {
1161
1160
  s(this, M).crash(
1162
1161
  new Error(
1163
1162
  "Router.go was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
@@ -1166,13 +1165,13 @@ class Yt {
1166
1165
  return;
1167
1166
  }
1168
1167
  let r;
1169
- Array.isArray(e) ? r = se(e) : r = e.toString(), r = Fe(s(this, E).location.pathname, r), t.preserveQuery && (r += s(this, E).location.search), t.replace ? s(this, E).replace(r) : s(this, E).push(r);
1168
+ Array.isArray(e) ? r = ae(e) : r = e.toString(), r = Ue(s(this, P).location.pathname, r), t.preserveQuery && (r += s(this, P).location.search), t.replace ? s(this, P).replace(r) : s(this, P).push(r);
1170
1169
  }
1171
1170
  /**
1172
1171
  * Navigate backward. Pass a number of steps to hit the back button that many times.
1173
1172
  */
1174
1173
  back(e = 1) {
1175
- if (s(this, E) == null) {
1174
+ if (s(this, P) == null) {
1176
1175
  s(this, M).crash(
1177
1176
  new Error(
1178
1177
  "Router.back was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
@@ -1180,13 +1179,13 @@ class Yt {
1180
1179
  );
1181
1180
  return;
1182
1181
  }
1183
- s(this, E).go(-e);
1182
+ s(this, P).go(-e);
1184
1183
  }
1185
1184
  /**
1186
1185
  * Navigate forward. Pass a number of steps to hit the forward button that many times.
1187
1186
  */
1188
1187
  forward(e = 1) {
1189
- if (s(this, E) == null) {
1188
+ if (s(this, P) == null) {
1190
1189
  s(this, M).crash(
1191
1190
  new Error(
1192
1191
  "Router.forward was called, but the router was never configured! Run 'Dolla.router.setup' before 'Dolla.mount' to configure routes."
@@ -1194,16 +1193,16 @@ class Yt {
1194
1193
  );
1195
1194
  return;
1196
1195
  }
1197
- s(this, E).go(e);
1196
+ s(this, P).go(e);
1198
1197
  }
1199
1198
  }
1200
- Se = new WeakMap(), M = new WeakMap(), Z = new WeakMap(), E = new WeakMap(), ze = new WeakMap(), G = new WeakMap(), Re = new WeakMap(), ee = new WeakMap(), W = new WeakMap(), ue = new WeakMap(), he = new WeakMap(), fe = new WeakMap(), xe = new WeakMap(), Q = new WeakSet(), /**
1199
+ Se = new WeakMap(), M = new WeakMap(), Y = new WeakMap(), Le = new WeakMap(), P = new WeakMap(), Ke = new WeakMap(), I = new WeakMap(), Re = new WeakMap(), X = new WeakMap(), Z = new WeakMap(), ce = new WeakMap(), ue = new WeakMap(), he = new WeakMap(), xe = new WeakMap(), z = new WeakSet(), /**
1201
1200
  * Parses a route definition object into a set of matchable routes.
1202
1201
  *
1203
1202
  * @param route - Route config object.
1204
1203
  * @param layers - Array of parent layers. Passed when this function calls itself on nested routes.
1205
1204
  */
1206
- rt = function(e, t = [], r = []) {
1205
+ at = function(e, t = [], r = []) {
1207
1206
  if (!(typeof e == "object" && !Array.isArray(e)) || typeof e.path != "string")
1208
1207
  throw new TypeError(`Route configs must be objects with a 'path' string property. Got: ${e}`);
1209
1208
  if (e.redirect && e.routes)
@@ -1214,42 +1213,42 @@ rt = function(e, t = [], r = []) {
1214
1213
  throw new Error("Route must have a 'view', a 'redirect', or a set of nested 'routes'.");
1215
1214
  let a = [];
1216
1215
  for (const l of t)
1217
- a.push(...be(l.path));
1218
- a.push(...be(e.path)), a[a.length - 1] === "*" && a.pop();
1216
+ a.push(...ye(l.path));
1217
+ a.push(...ye(e.path)), a[a.length - 1] === "*" && a.pop();
1219
1218
  const n = [];
1220
1219
  if (e.redirect) {
1221
1220
  let l = e.redirect;
1222
- return F(l) && (l = Fe(se(a), l), l.startsWith("/") || (l = "/" + l)), n.push({
1223
- pattern: "/" + se([...a, ...be(e.path)]),
1221
+ return V(l) && (l = Ue(ae(a), l), l.startsWith("/") || (l = "/" + l)), n.push({
1222
+ pattern: "/" + ae([...a, ...ye(e.path)]),
1224
1223
  meta: {
1225
1224
  redirect: l
1226
1225
  }
1227
1226
  }), n;
1228
1227
  }
1229
- let o = mt;
1228
+ let o = yt;
1230
1229
  if (typeof e.view == "function")
1231
1230
  o = e.view;
1232
1231
  else if (e.view)
1233
1232
  throw new TypeError(`Route '${e.path}' expected a view function or undefined. Got: ${e.view}`);
1234
- const u = { id: it(this, ze)._++, view: o };
1233
+ const h = { id: lt(this, Ke)._++, view: o };
1235
1234
  if (e.routes)
1236
1235
  for (const l of e.routes)
1237
- n.push(...k(this, Q, rt).call(this, l, [...t, e], [...r, u]));
1236
+ n.push(...E(this, z, at).call(this, l, [...t, e], [...r, h]));
1238
1237
  else
1239
1238
  n.push({
1240
- pattern: parent ? se([...t.map((l) => l.path), e.path]) : e.path,
1239
+ pattern: parent ? ae([...t.map((l) => l.path), e.path]) : e.path,
1241
1240
  meta: {
1242
1241
  pattern: e.path,
1243
- layers: [...r, u],
1242
+ layers: [...r, h],
1244
1243
  beforeMatch: e.beforeMatch
1245
1244
  }
1246
1245
  });
1247
1246
  return n;
1248
- }, nt = async function({ location: e }) {
1249
- e.search !== s(this, Re) && (b(this, Re, e.search), s(this, xe).call(this, tt(e.search)));
1250
- const t = ft(s(this, ee), e.pathname);
1247
+ }, st = async function({ location: e }) {
1248
+ e.search !== s(this, Re) && (b(this, Re, e.search), s(this, xe).call(this, nt(e.search)));
1249
+ const t = mt(s(this, X), e.pathname);
1251
1250
  if (!t) {
1252
- s(this, ue).call(this, null), s(this, he).call(this, e.pathname), s(this, fe).call(this, {
1251
+ s(this, ce).call(this, null), s(this, ue).call(this, e.pathname), s(this, he).call(this, {
1253
1252
  wildcard: e.pathname
1254
1253
  });
1255
1254
  return;
@@ -1261,8 +1260,8 @@ rt = function(e, t = [], r = []) {
1261
1260
  }
1262
1261
  }), t.meta.redirect != null)
1263
1262
  if (typeof t.meta.redirect == "string") {
1264
- const r = tr(t.meta.redirect, t.params);
1265
- s(this, M).info(`↩️ redirecting from '${t.path}' to '${r}'`), s(this, E).replace(r);
1263
+ const r = rr(t.meta.redirect, t.params);
1264
+ s(this, M).info(`↩️ redirecting from '${t.path}' to '${r}'`), s(this, P).replace(r);
1266
1265
  } else if (typeof t.meta.redirect == "function") {
1267
1266
  const r = {
1268
1267
  path: t.path,
@@ -1273,26 +1272,26 @@ rt = function(e, t = [], r = []) {
1273
1272
  let a = await t.meta.redirect(r);
1274
1273
  if (typeof a != "string")
1275
1274
  throw new Error("Redirect function must return a path to redirect to.");
1276
- a.startsWith("/") || (a = Fe(t.path, a)), s(this, M).info(`Redirecting to: '${a}'`), s(this, E).replace(a);
1275
+ a.startsWith("/") || (a = Ue(t.path, a)), s(this, M).info(`Redirecting to: '${a}'`), s(this, P).replace(a);
1277
1276
  } else
1278
1277
  throw new TypeError("Redirect must either be a path string or a function.");
1279
- else if (s(this, M).info(`📍 navigating to '${t.path}'`), s(this, he).call(this, t.path), s(this, fe).call(this, t.params), t.pattern !== this.$pattern.get()) {
1280
- s(this, ue).call(this, t.pattern);
1278
+ else if (s(this, M).info(`📍 navigating to '${t.path}'`), s(this, ue).call(this, t.path), s(this, he).call(this, t.params), t.pattern !== this.$pattern.get()) {
1279
+ s(this, ce).call(this, t.pattern);
1281
1280
  const r = t.meta.layers;
1282
1281
  for (let a = 0; a < r.length; a++) {
1283
- const n = r[a], o = s(this, G)[a];
1282
+ const n = r[a], o = s(this, I)[a];
1284
1283
  if ((o == null ? void 0 : o.id) !== n.id) {
1285
- b(this, G, s(this, G).slice(0, a));
1286
- const u = s(this, G).at(-1);
1284
+ b(this, I, s(this, I).slice(0, a));
1285
+ const h = s(this, I).at(-1);
1287
1286
  o && o.node.isMounted && o.node.unmount();
1288
1287
  let l;
1289
- u ? l = u.node.setChildView(n.view) : l = s(this, Z).rootView.setChildView(n.view), s(this, G).push({ id: n.id, node: l });
1288
+ h ? l = h.node.setChildView(n.view) : l = s(this, Y).rootView.setChildView(n.view), s(this, I).push({ id: n.id, node: l });
1290
1289
  }
1291
1290
  }
1292
1291
  }
1293
1292
  };
1294
- const Xt = /(noopener|noreferrer) (noopener|noreferrer)/, Zt = /^[\w-_]+:/;
1295
- function er(i, e, t = window) {
1293
+ const Zt = /(noopener|noreferrer) (noopener|noreferrer)/, er = /^[\w-_]+:/;
1294
+ function tr(i, e, t = window) {
1296
1295
  function r(n) {
1297
1296
  return !n || n === i ? null : n.localName !== "a" || n.href === void 0 ? r(n.parentNode) : n;
1298
1297
  }
@@ -1300,58 +1299,60 @@ function er(i, e, t = window) {
1300
1299
  if (n.button && n.button !== 0 || n.ctrlKey || n.metaKey || n.altKey || n.shiftKey || n.defaultPrevented)
1301
1300
  return;
1302
1301
  const o = r(n.target);
1303
- 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" && Xt.test(o.getAttribute("rel")) || Zt.test(o.getAttribute("href")) || (n.preventDefault(), e(o)));
1302
+ 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" && Zt.test(o.getAttribute("rel")) || er.test(o.getAttribute("href")) || (n.preventDefault(), e(o)));
1304
1303
  }
1305
1304
  return i.addEventListener("click", a), function() {
1306
1305
  i.removeEventListener("click", a);
1307
1306
  };
1308
1307
  }
1309
- function tr(i, e) {
1308
+ function rr(i, e) {
1310
1309
  for (const t in e) {
1311
1310
  const r = e[t].toString();
1312
1311
  i = i.replace(`{${t}}`, r).replace(`{#${t}}`, r);
1313
1312
  }
1314
1313
  return i;
1315
1314
  }
1316
- var z, Le, B, te, Ne, Oe, Me, Te, je, x, K;
1317
- class rr {
1315
+ var W, Oe, G, ee, Ne, Me, Te, De, _e, Ae, R, B;
1316
+ class nr {
1318
1317
  constructor() {
1319
- P(this, "http");
1320
- P(this, "i18n");
1321
- P(this, "render");
1322
- P(this, "router");
1323
- f(this, z, !1);
1324
- f(this, Le, "production");
1325
- f(this, B);
1326
- f(this, te);
1327
- f(this, Ne, _t);
1328
- f(this, Oe, []);
1329
- f(this, Me, []);
1318
+ S(this, "http");
1319
+ S(this, "i18n");
1320
+ S(this, "render");
1321
+ S(this, "router");
1322
+ f(this, W, !1);
1323
+ f(this, Oe, "production");
1324
+ f(this, G);
1325
+ f(this, ee);
1326
+ f(this, Ne, Ct);
1327
+ f(this, Me, Ye());
1330
1328
  f(this, Te, []);
1331
- f(this, je, []);
1332
- f(this, x, {
1329
+ f(this, De, []);
1330
+ f(this, _e, []);
1331
+ f(this, Ae, []);
1332
+ f(this, R, {
1333
1333
  info: "development",
1334
1334
  log: "development",
1335
1335
  warn: "development",
1336
1336
  error: !0
1337
1337
  });
1338
- f(this, K, ct("*,-dolla/*"));
1339
- P(this, "createState", ie);
1340
- P(this, "createSettableState", xt);
1341
- P(this, "toSettableState", Lt);
1342
- P(this, "toState", Qe);
1343
- P(this, "valueOf", Nt);
1344
- P(this, "derive", ye);
1345
- P(this, "watch", gt);
1346
- P(this, "createRef", Ot);
1347
- P(this, "isRef", Mt);
1338
+ f(this, B, ht("*,-dolla/*"));
1339
+ S(this, "watch", s(this, Me).watch);
1340
+ S(this, "createState", se);
1341
+ S(this, "createSettableState", Ot);
1342
+ S(this, "toSettableState", Nt);
1343
+ S(this, "toState", ft);
1344
+ S(this, "valueOf", Mt);
1345
+ S(this, "derive", we);
1346
+ S(this, "createWatcher", Ye);
1347
+ S(this, "createRef", Tt);
1348
+ S(this, "isRef", Dt);
1348
1349
  const e = this;
1349
- this.http = new Ct(), this.i18n = new It(this), this.render = new Wt(this), this.router = new Yt(this, {
1350
+ this.http = new Vt(), this.i18n = new Wt(this), this.render = new Bt(this), this.router = new Xt(this, {
1350
1351
  get rootElement() {
1351
- return s(e, B);
1352
+ return s(e, G);
1352
1353
  },
1353
1354
  get rootView() {
1354
- return s(e, te);
1355
+ return s(e, ee);
1355
1356
  }
1356
1357
  });
1357
1358
  }
@@ -1359,21 +1360,21 @@ class rr {
1359
1360
  * True when the app is connected to a DOM node and displayed to the user.
1360
1361
  */
1361
1362
  get isMounted() {
1362
- return s(this, z);
1363
+ return s(this, W);
1363
1364
  }
1364
1365
  /**
1365
1366
  * Get the current environment that this app is running in.
1366
1367
  * Environment affects which log messages will print and how much debugging info is included in the DOM.
1367
1368
  */
1368
1369
  getEnv() {
1369
- return s(this, Le);
1370
+ return s(this, Oe);
1370
1371
  }
1371
1372
  /**
1372
1373
  * Sets the environment that this app is running in.
1373
1374
  * Environment affects which log messages will print and how much debugging info is included in the DOM.
1374
1375
  */
1375
1376
  setEnv(e) {
1376
- b(this, Le, e);
1377
+ b(this, Oe, e);
1377
1378
  }
1378
1379
  /**
1379
1380
  * Sets the view that will be shown when the `crash` method is called on any logger.
@@ -1383,23 +1384,23 @@ class rr {
1383
1384
  b(this, Ne, e);
1384
1385
  }
1385
1386
  async mount(e, t) {
1386
- if (s(this, z))
1387
+ if (s(this, W))
1387
1388
  throw new Error("Dolla is already mounted.");
1388
- if (F(e)) {
1389
+ if (V(e)) {
1389
1390
  const a = document.querySelector(e);
1390
- ut(HTMLElement, a, `Selector '${e}' did not match any element.`), b(this, B, a);
1391
+ dt(HTMLElement, a, `Selector '${e}' did not match any element.`), b(this, G, a);
1391
1392
  } else
1392
- ut(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), b(this, B, e);
1393
+ dt(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), b(this, G, e);
1393
1394
  let r;
1394
- t ? r = ht(t) : r = ht(mt), b(this, te, this.constructView(r.type, r.props)), await Promise.all(s(this, Oe).map((a) => a())), s(this, te).mount(s(this, B)), b(this, z, !0);
1395
- for (const a of s(this, Me))
1395
+ t ? r = pt(t) : r = pt(yt), b(this, ee, this.constructView(r.type, r.props)), await Promise.all(s(this, Te).map((a) => a())), s(this, ee).mount(s(this, G)), b(this, W, !0);
1396
+ for (const a of s(this, De))
1396
1397
  a();
1397
1398
  }
1398
1399
  async unmount() {
1399
1400
  var e;
1400
- if (s(this, z)) {
1401
- await Promise.all(s(this, Te).map((t) => t())), (e = s(this, te)) == null || e.unmount(), b(this, z, !1);
1402
- for (const t of s(this, je))
1401
+ if (s(this, W)) {
1402
+ await Promise.all(s(this, _e).map((t) => t())), (e = s(this, ee)) == null || e.unmount(), s(this, Me).stopAll(), b(this, W, !1);
1403
+ for (const t of s(this, Ae))
1403
1404
  t();
1404
1405
  }
1405
1406
  }
@@ -1408,26 +1409,26 @@ class rr {
1408
1409
  * it will be awaited before mounting finishes. Use this to perform initial setup before the app is displayed to the user.
1409
1410
  */
1410
1411
  beforeMount(e) {
1411
- s(this, Oe).push(e);
1412
+ s(this, Te).push(e);
1412
1413
  }
1413
1414
  /**
1414
1415
  * Registers a `callback` to run after the app is mounted.
1415
1416
  */
1416
1417
  onMount(e) {
1417
- s(this, Me).push(e);
1418
+ s(this, De).push(e);
1418
1419
  }
1419
1420
  /**
1420
1421
  * Registers a `callback` to run after `Dolla.unmount` is called, before the app is unmounted. If `callback` returns a Promise,
1421
1422
  * it will be awaited before unmounting finishes. Use this to perform cleanup.
1422
1423
  */
1423
1424
  beforeUnmount(e) {
1424
- s(this, Te).push(e);
1425
+ s(this, _e).push(e);
1425
1426
  }
1426
1427
  /**
1427
1428
  * Registers a `callback` to run after the app is unmounted.
1428
1429
  */
1429
1430
  onUnmount(e) {
1430
- s(this, je).push(e);
1431
+ s(this, Ae).push(e);
1431
1432
  }
1432
1433
  /**
1433
1434
  * Update log type toggles. Values that are not passed will remain unchanged.
@@ -1435,26 +1436,26 @@ class rr {
1435
1436
  setLoggles(e) {
1436
1437
  for (const t in e) {
1437
1438
  const r = e[t];
1438
- r && (s(this, x)[t] = r);
1439
+ r && (s(this, R)[t] = r);
1439
1440
  }
1440
1441
  }
1441
1442
  setLogFilter(e) {
1442
- b(this, K, ct(e));
1443
+ b(this, B, ht(e));
1443
1444
  }
1444
1445
  createLogger(e, t) {
1445
- const r = Qe(e), a = (t == null ? void 0 : t.console) ?? Tt(), n = this;
1446
+ const r = ft(e), a = (t == null ? void 0 : t.console) ?? _t(), n = this;
1446
1447
  return {
1447
1448
  get info() {
1448
- var u;
1449
+ var h;
1449
1450
  const o = r.get();
1450
- if (s(n, x).info === !1 || F(s(n, x).info) && s(n, x).info !== n.getEnv() || !s(u = n, K).call(u, o))
1451
- return Ae;
1451
+ if (s(n, R).info === !1 || V(s(n, R).info) && s(n, R).info !== n.getEnv() || !s(h = n, B).call(h, o))
1452
+ return je;
1452
1453
  {
1453
1454
  let l = `%c${o}`;
1454
1455
  return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.info.bind(
1455
1456
  a,
1456
1457
  l,
1457
- `color:${De(l)};font-weight:bold`,
1458
+ `color:${Fe(l)};font-weight:bold`,
1458
1459
  "color:#777",
1459
1460
  "color:#aaa",
1460
1461
  "color:#777"
@@ -1462,16 +1463,16 @@ class rr {
1462
1463
  }
1463
1464
  },
1464
1465
  get log() {
1465
- var u;
1466
+ var h;
1466
1467
  const o = r.get();
1467
- if (s(n, x).log === !1 || F(s(n, x).log) && s(n, x).log !== n.getEnv() || !s(u = n, K).call(u, o))
1468
- return Ae;
1468
+ if (s(n, R).log === !1 || V(s(n, R).log) && s(n, R).log !== n.getEnv() || !s(h = n, B).call(h, o))
1469
+ return je;
1469
1470
  {
1470
1471
  let l = `%c${o}`;
1471
1472
  return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.log.bind(
1472
1473
  a,
1473
1474
  l,
1474
- `color:${De(l)};font-weight:bold`,
1475
+ `color:${Fe(l)};font-weight:bold`,
1475
1476
  "color:#777",
1476
1477
  "color:#aaa",
1477
1478
  "color:#777"
@@ -1479,16 +1480,16 @@ class rr {
1479
1480
  }
1480
1481
  },
1481
1482
  get warn() {
1482
- var u;
1483
+ var h;
1483
1484
  const o = r.get();
1484
- if (s(n, x).warn === !1 || F(s(n, x).warn) && s(n, x).warn !== n.getEnv() || !s(u = n, K).call(u, o))
1485
- return Ae;
1485
+ if (s(n, R).warn === !1 || V(s(n, R).warn) && s(n, R).warn !== n.getEnv() || !s(h = n, B).call(h, o))
1486
+ return je;
1486
1487
  {
1487
1488
  let l = `%c${o}`;
1488
1489
  return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.warn.bind(
1489
1490
  a,
1490
1491
  l,
1491
- `color:${De(l)};font-weight:bold`,
1492
+ `color:${Fe(l)};font-weight:bold`,
1492
1493
  "color:#777",
1493
1494
  "color:#aaa",
1494
1495
  "color:#777"
@@ -1496,16 +1497,16 @@ class rr {
1496
1497
  }
1497
1498
  },
1498
1499
  get error() {
1499
- var u;
1500
+ var h;
1500
1501
  const o = r.get();
1501
- if (s(n, x).error === !1 || F(s(n, x).error) && s(n, x).error !== n.getEnv() || !s(u = n, K).call(u, o))
1502
- return Ae;
1502
+ if (s(n, R).error === !1 || V(s(n, R).error) && s(n, R).error !== n.getEnv() || !s(h = n, B).call(h, o))
1503
+ return je;
1503
1504
  {
1504
1505
  let l = `%c${o}`;
1505
1506
  return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.error.bind(
1506
1507
  a,
1507
1508
  l,
1508
- `color:${De(l)};font-weight:bold`,
1509
+ `color:${Fe(l)};font-weight:bold`,
1509
1510
  "color:#777",
1510
1511
  "color:#aaa",
1511
1512
  "color:#777"
@@ -1517,7 +1518,7 @@ class rr {
1517
1518
  error: o,
1518
1519
  loggerName: r.get(),
1519
1520
  uid: t == null ? void 0 : t.uid
1520
- }).mount(s(n, B))), o;
1521
+ }).mount(s(n, G))), o;
1521
1522
  }
1522
1523
  };
1523
1524
  }
@@ -1525,33 +1526,41 @@ class rr {
1525
1526
  *
1526
1527
  */
1527
1528
  constructView(e, t, r = []) {
1528
- return jt({ root: this, data: {} }, e, t, r);
1529
+ return At({ root: this, data: {} }, e, t, r);
1529
1530
  }
1530
1531
  /**
1531
1532
  *
1532
1533
  */
1533
1534
  constructMarkup(e) {
1534
- return At(Dt({ root: this, data: {} }, e));
1535
+ return jt(Ft({ root: this, data: {} }, e));
1535
1536
  }
1536
1537
  }
1537
- z = new WeakMap(), Le = new WeakMap(), B = new WeakMap(), te = new WeakMap(), Ne = new WeakMap(), Oe = new WeakMap(), Me = new WeakMap(), Te = new WeakMap(), je = new WeakMap(), x = new WeakMap(), K = new WeakMap();
1538
- const dt = new rr(), ir = dt.i18n.t.bind(dt.i18n);
1538
+ W = new WeakMap(), Oe = new WeakMap(), G = new WeakMap(), ee = new WeakMap(), Ne = new WeakMap(), Me = new WeakMap(), Te = new WeakMap(), De = new WeakMap(), _e = new WeakMap(), Ae = new WeakMap(), R = new WeakMap(), B = new WeakMap();
1539
+ const gt = new nr(), or = gt.i18n.t.bind(gt.i18n);
1540
+ function lr(i) {
1541
+ typeof window < "u" && (window.DOLLA_DEV_DEBUG = i);
1542
+ }
1543
+ function cr() {
1544
+ return typeof window < "u" ? window.DOLLA_DEV_DEBUG === !0 : !1;
1545
+ }
1539
1546
  export {
1540
- Pt as cond,
1541
- ht as createMarkup,
1542
- Ot as createRef,
1543
- xt as createSettableState,
1544
- cr as createSetter,
1545
- ie as createState,
1546
- dt as default,
1547
- ye as derive,
1548
- ot as html,
1549
- Mt as isRef,
1550
- ur as portal,
1551
- hr as repeat,
1552
- ir as t,
1553
- Lt as toSettableState,
1554
- Qe as toState,
1555
- Nt as valueOf
1547
+ Lt as cond,
1548
+ pt as createMarkup,
1549
+ Tt as createRef,
1550
+ Ot as createSettableState,
1551
+ fr as createSetter,
1552
+ se as createState,
1553
+ gt as default,
1554
+ we as derive,
1555
+ cr as getDevDebug,
1556
+ ct as html,
1557
+ Dt as isRef,
1558
+ dr as portal,
1559
+ pr as repeat,
1560
+ lr as setDevDebug,
1561
+ or as t,
1562
+ Nt as toSettableState,
1563
+ ft as toState,
1564
+ Mt as valueOf
1556
1565
  };
1557
1566
  //# sourceMappingURL=index.js.map