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

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 St = Object.defineProperty;
2
+ var lt = (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 Lt = (i, e, t) => e in i ? St(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
6
+ var S = (i, e, t) => Lt(i, typeof e != "symbol" ? e + "" : e, t), Je = (i, e, t) => e.has(i) || lt("Cannot " + t);
7
+ var s = (i, e, t) => (Je(i, e, "read from private field"), t ? t.call(i) : e.get(i)), f = (i, e, t) => e.has(i) ? lt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), b = (i, e, t, r) => (Je(i, e, "write to private field"), r ? r.call(i, t) : e.set(i, t), t), E = (i, e, t) => (Je(i, e, "access private method"), t);
8
+ var ct = (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 ut, c as xt, i as Ye, a as ie, d as ye, b as Rt, e as ot, f as V, t as ht, g as yt, j as Ot, k as Xe, P as bt, l as ft, m as Nt, n as Mt, o as dt, v as Tt, p as Dt, q as At, r as pt, s as mt, u as _t, w as Ce, x as Fe, y as jt, z as Ct, A as Ft } from "./passthrough-CBbog_A9.js";
17
+ import { B as dr, C as pr, D as mr } from "./passthrough-CBbog_A9.js";
18
+ function Vt(i) {
19
+ return ut`
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
+ ${xt(i.uid, ut`<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 J, ze, T, j;
66
+ class qt {
67
67
  constructor() {
68
68
  f(this, T);
69
- f(this, Y, []);
70
- f(this, Ge, Vt());
69
+ f(this, J, []);
70
+ f(this, ze, Ut());
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, J).push(e), () => {
80
+ s(this, J).splice(s(this, J).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
+ J = new WeakMap(), ze = new WeakMap(), T = new WeakSet(), j = async function(e, t, r) {
109
+ return It({
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, J),
114
+ fetch: s(this, ze)
115
115
  });
116
116
  };
117
- function Vt() {
117
+ function Ut() {
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 Ht 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 It(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") && Ye(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 Ht(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 Ke, oe, re, Ze, vt;
200
+ class Wt {
202
201
  constructor(e, t) {
203
202
  f(this, re);
204
- P(this, "dolla");
205
- P(this, "config");
206
- f(this, We, !1);
203
+ S(this, "dolla");
204
+ S(this, "config");
205
+ f(this, Ke, !1);
207
206
  f(this, oe, /* @__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, Ke)) {
212
+ if (ot(this.config.fetch)) {
213
+ if (e = await this.config.fetch(), !Ye(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 (Ye(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, re, Ze).call(this, e);
233
230
  for (const r of t)
234
231
  s(this, oe).set(r[0], r[1]);
235
- }
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, oe).get(e) ?? {
237
+ segments: [{ type: 0, text: `[MISSING: ${e}]` }]
238
+ };
239
239
  }
240
240
  hasTemplate(e) {
241
241
  return s(this, oe).has(e);
242
242
  }
243
243
  }
244
- We = new WeakMap(), oe = new WeakMap(), re = new WeakSet(), Je = function(e, t = []) {
244
+ Ke = new WeakMap(), oe = new WeakMap(), re = new WeakSet(), Ze = function(e, t = []) {
245
245
  const r = [];
246
246
  for (const a in e)
247
- switch (lt(e[a])) {
247
+ switch (ht(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, re, vt).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, re, Ze).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: ${ht(e[a])}`
257
257
  );
258
258
  }
259
259
  return r;
260
- }, wt = function(e) {
260
+ }, vt = 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 ve, q, R, $e, Ee, ke, Pe, O, $t, et, tt, rt, Et;
310
+ class Gt {
311
311
  constructor(e) {
312
- f(this, N);
312
+ f(this, O);
313
313
  f(this, ve);
314
314
  f(this, q);
315
- f(this, L, /* @__PURE__ */ new Map());
315
+ f(this, R, /* @__PURE__ */ new Map());
316
316
  f(this, $e, []);
317
- f(this, U, /* @__PURE__ */ new Map());
317
+ f(this, Ee, /* @__PURE__ */ new Map());
318
318
  f(this, ke, "auto");
319
- P(this, "$locale");
320
- f(this, Ee);
319
+ S(this, "$locale");
320
+ f(this, Pe);
321
321
  b(this, ve, e), b(this, q, e.createLogger("dolla/i18n"));
322
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));
323
+ this.$locale = t, b(this, Pe, r), this.addFormat("number", (a, n, o) => E(this, O, et).call(this, Number(n), o)), this.addFormat("datetime", (a, n, o) => E(this, O, tt).call(this, n, o)), this.addFormat("list", (a, n, o) => E(this, O, rt).call(this, n, o)), e.beforeMount(async () => {
324
+ s(this, R).size > 0 && await this.setLocale(s(this, ke));
325
325
  });
326
326
  }
327
327
  get locales() {
328
- return [...s(this, L).keys()];
328
+ return [...s(this, R).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, R).set(t.locale, new Wt(t, s(this, ve)));
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
336
  b(this, ke, 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, R).size} language${s(this, R).size === 1 ? "" : "s"} supported: '${[...s(this, R).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, R).has(o) && (t = o);
353
353
  } else
354
- s(this, L).has(e) && (t = e);
354
+ s(this, R).has(e) && (t = e);
355
355
  if (t == null) {
356
- const n = s(this, L).keys().next().value;
356
+ const n = s(this, R).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, R).has(t))
360
+ throw new Error(`Locale '${e}' has no translation.`);
361
+ const r = s(this, R).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, $e, []), s(this, Pe).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
385
  return ye([this.$locale, ...a], (n, ...o) => {
388
- const u = {};
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, $t).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, Ee).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 ye([this.$locale, e], (r, a) => E(this, O, et).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 ye([this.$locale, e], (r, a) => E(this, O, tt).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,61 +447,60 @@ 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 ye([this.$locale, e], (r, a) => E(this, O, rt).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
+ ve = new WeakMap(), q = new WeakMap(), R = new WeakMap(), $e = new WeakMap(), Ee = new WeakMap(), ke = new WeakMap(), Pe = new WeakMap(), O = new WeakSet(), $t = function(e, t, r) {
454
+ var l;
455
+ const a = E(this, O, Et).call(this, t, r);
455
456
  if (a) return a;
456
- const n = s(this, L).get(e);
457
+ const n = s(this, R).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 = Bt(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, Ee).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
+ }, et = function(e, t) {
490
489
  return new Intl.NumberFormat(this.$locale.get(), t).format(e);
491
- }, Xe = function(e, t) {
490
+ }, tt = 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
+ }, rt = 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) {
498
+ Et = function(e, t) {
500
499
  for (const r of s(this, $e))
501
- if (r[0] === e && St(r[1], t))
500
+ if (r[0] === e && Rt(r[1], t))
502
501
  return r[2];
503
502
  };
504
- function Gt(i, e) {
503
+ function Bt(i, e) {
505
504
  const t = String(e).split(/[\.\[\]]/).filter((a) => a.trim() !== "");
506
505
  let r = i;
507
506
  for (; t.length > 0; ) {
@@ -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 Y, Se, U, H, le, C, ce, Ve;
513
+ class zt {
515
514
  constructor(e) {
516
515
  f(this, ce);
517
- f(this, X);
518
- f(this, Pe);
516
+ f(this, Y);
517
+ f(this, Se);
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
524
  f(this, le, []);
526
525
  f(this, C, !1);
527
- b(this, X, e), b(this, Pe, e.createLogger("dolla/render"));
526
+ b(this, Y, e), b(this, Se, 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, C) && s(this, Y).isMounted && (b(this, C, !0), E(this, ce, Ve).call(this));
541
540
  });
542
541
  }
543
542
  /**
@@ -549,26 +548,26 @@ class Wt {
549
548
  return new Promise((t) => {
550
549
  s(this, le).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, C) && s(this, Y).isMounted && (b(this, C, !0), E(this, ce, Ve).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)) {
555
+ Y = new WeakMap(), Se = new WeakMap(), U = new WeakMap(), H = new WeakMap(), le = new WeakMap(), C = new WeakMap(), ce = new WeakSet(), Ve = function() {
556
+ const e = s(this, U).size + s(this, H).length;
557
+ if ((!s(this, Y).isMounted || e === 0) && b(this, C, !1), !s(this, C)) {
559
558
  for (const t of s(this, le))
560
559
  t();
561
560
  b(this, le, []);
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, Se).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, ce, Ve).call(this);
572
571
  });
573
572
  };
574
573
  function de() {
@@ -584,12 +583,12 @@ var A;
584
583
  (function(i) {
585
584
  i.Pop = "POP", i.Push = "PUSH", i.Replace = "REPLACE";
586
585
  })(A || (A = {}));
587
- var qe = process.env.NODE_ENV !== "production" ? function(i) {
586
+ var Ie = 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 qe(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 We = "beforeunload", Kt = "hashchange", kt = "popstate";
601
+ function Qt(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, Ie({
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 = A.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
+ F($ * -1);
629
628
  }
630
- }, V($));
629
+ }, F($));
631
630
  } else
632
- process.env.NODE_ENV !== "production" && Ce(
631
+ process.env.NODE_ENV !== "production" && qe(
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
@@ -640,134 +639,134 @@ function Bt(i) {
640
639
  ne(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(kt, h);
643
+ var l = A.Pop, d = n(), g = d[0], m = d[1], u = Be(), y = Be();
644
+ g == null && (g = 0, a.replaceState(de({}, 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 : Ue(w);
650
649
  }
651
650
  function pe(w, c) {
652
- return c === void 0 && (c = null), qe(de({
653
- pathname: p.pathname,
651
+ return c === void 0 && (c = null), Ie(de({
652
+ pathname: m.pathname,
654
653
  hash: "",
655
654
  search: ""
656
- }, typeof w == "string" ? et(w) : w, {
655
+ }, typeof w == "string" ? nt(w) : w, {
657
656
  state: c,
658
- key: $t()
657
+ key: Pt()
659
658
  }));
660
659
  }
661
- function ge(w, c) {
660
+ function me(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 ge(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
674
  function ne(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
682
  function ae(w, c) {
684
- var d = A.Push, v = pe(w, c);
683
+ var p = A.Push, v = pe(w, c);
685
684
  function $() {
686
685
  ae(w, c);
687
686
  }
688
- if (me(d, v, $)) {
689
- var R = ge(v, m + 1), O = R[0], j = R[1];
687
+ if (ge(p, v, $)) {
688
+ var L = me(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
+ ne(p);
696
695
  }
697
696
  }
698
697
  function we(w, c) {
699
- var d = A.Replace, v = pe(w, c);
698
+ var p = A.Replace, v = pe(w, c);
700
699
  function $() {
701
700
  we(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 (ge(p, v, $)) {
703
+ var L = me(v, g), N = L[0], D = L[1];
704
+ a.replaceState(N, "", D), ne(p);
706
705
  }
707
706
  }
708
- function V(w) {
707
+ function F(w) {
709
708
  a.go(w);
710
709
  }
711
- var J = {
710
+ var Q = {
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,
717
+ createHref: k,
719
718
  push: ae,
720
719
  replace: we,
721
- go: V,
720
+ go: F,
722
721
  back: function() {
723
- V(-1);
722
+ F(-1);
724
723
  },
725
724
  forward: function() {
726
- V(1);
725
+ F(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(We, Ge), function() {
733
+ p(), y.length || r.removeEventListener(We, Ge);
735
734
  };
736
735
  }
737
736
  };
738
- return J;
737
+ return Q;
739
738
  }
740
- function Kt(i) {
739
+ function Jt(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 = nt(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.state || {};
744
+ return [_.idx, Ie({
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: _.usr || null,
749
+ key: _.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 = A.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
+ Q(L * -1);
767
766
  }
768
- }, J(R));
767
+ }, Q(L));
769
768
  } else
770
- process.env.NODE_ENV !== "production" && Ce(
769
+ process.env.NODE_ENV !== "production" && qe(
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
@@ -778,83 +777,83 @@ function Kt(i) {
778
777
  ae(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(kt, h), r.addEventListener(Kt, function() {
781
+ var c = n(), p = c[1];
782
+ Ue(p) !== Ue(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 = A.Pop, d = n(), g = d[0], m = d[1], u = Be(), y = Be();
785
+ g == null && (g = 0, a.replaceState(de({}, 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
796
  function pe(c) {
798
- return S() + "#" + (typeof c == "string" ? c : Ve(c));
797
+ return k() + "#" + (typeof c == "string" ? c : Ue(c));
799
798
  }
800
- function ge(c, d) {
801
- return d === void 0 && (d = null), qe(de({
802
- pathname: p.pathname,
799
+ function me(c, p) {
800
+ return p === void 0 && (p = null), Ie(de({
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" ? nt(c) : c, {
805
+ state: p,
806
+ key: Pt()
808
807
  }));
809
808
  }
810
- function me(c, d) {
809
+ function ge(c, p) {
811
810
  return [{
812
811
  usr: c.state,
813
812
  key: c.key,
814
- idx: d
813
+ idx: p
815
814
  }, pe(c)];
816
815
  }
817
- function ne(c, d, v) {
816
+ function ne(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
823
  function ae(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 we(c, p) {
832
+ var v = A.Push, $ = me(c, p);
833
+ function L() {
834
+ we(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" && qe($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.push(" + JSON.stringify(c) + ")"), ne(v, $, L)) {
837
+ var N = ge($, g + 1), D = N[0], _ = N[1];
839
838
  try {
840
- a.pushState(j, "", D);
839
+ a.pushState(D, "", _);
841
840
  } catch {
842
- r.location.assign(D);
841
+ r.location.assign(_);
843
842
  }
844
843
  ae(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 F(c, p) {
847
+ var v = A.Replace, $ = me(c, p);
848
+ function L() {
849
+ F(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" && qe($.pathname.charAt(0) === "/", "Relative pathnames are not supported in hash history.replace(" + JSON.stringify(c) + ")"), ne(v, $, L)) {
852
+ var N = ge($, g), D = N[0], _ = N[1];
853
+ a.replaceState(D, "", _), ae(v);
855
854
  }
856
855
  }
857
- function J(c) {
856
+ function Q(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
866
  createHref: pe,
868
867
  push: we,
869
- replace: V,
870
- go: J,
868
+ replace: F,
869
+ go: Q,
871
870
  back: function() {
872
- J(-1);
871
+ Q(-1);
873
872
  },
874
873
  forward: function() {
875
- J(1);
874
+ Q(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(We, Ge), function() {
882
+ v(), y.length || r.removeEventListener(We, Ge);
884
883
  };
885
884
  }
886
885
  };
887
886
  return w;
888
887
  }
889
- function He(i) {
888
+ function Ge(i) {
890
889
  i.preventDefault(), i.returnValue = "";
891
890
  }
892
- function Ie() {
891
+ function Be() {
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 Pt() {
913
912
  return Math.random().toString(36).substr(2, 8);
914
913
  }
915
- function Ve(i) {
914
+ function Ue(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 nt(i) {
920
919
  var e = {};
921
920
  if (i) {
922
921
  var t = i.indexOf("#");
@@ -927,25 +926,25 @@ function et(i) {
927
926
  return e;
928
927
  }
929
928
  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 !== "");
929
+ return yt(i, "Expected `path` to be a string. Got type: %t, value: %v"), i.split("/").map((e) => e.trim()).filter((e) => e !== "");
931
930
  }
932
931
  function se(i) {
933
932
  var t;
934
- Rt(
935
- (r) => at(r == null ? void 0 : r.toString),
933
+ Ot(
934
+ (r) => ot(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 = He(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 He(i, e) {
947
+ if (yt(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 (; ; )
@@ -961,7 +960,7 @@ function Fe(i, e) {
961
960
  break;
962
961
  return se([t, e]);
963
962
  }
964
- function tt(i) {
963
+ function at(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,71 +969,71 @@ function tt(i) {
970
969
  });
971
970
  return Object.fromEntries(e);
972
971
  }
973
- function ft(i, e, t = {}) {
972
+ function gt(i, e, t = {}) {
974
973
  var o;
975
974
  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))
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 = {};
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: at(a),
1014
+ meta: h.meta
1016
1015
  };
1017
1016
  }
1018
1017
  }
1019
- function Qt(i) {
1018
+ function Yt(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) {
1036
+ function Xt(i) {
1038
1037
  const e = be(i), t = [];
1039
1038
  for (let r = 0; r < e.length; r++) {
1040
1039
  const a = e[r];
@@ -1058,86 +1057,86 @@ 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 Le, M, X, xe, P, Qe, I, Re, Z, ee, ue, he, fe, Oe, K, st, it;
1061
+ class Zt {
1063
1062
  constructor(e, t) {
1064
- f(this, Q);
1065
- f(this, Se);
1063
+ f(this, K);
1064
+ f(this, Le);
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, X);
1067
+ f(this, xe, Xe());
1068
+ f(this, P);
1069
+ f(this, Qe, 0);
1070
+ f(this, I, []);
1071
1071
  f(this, Re);
1072
- f(this, ee, []);
1072
+ f(this, Z, []);
1073
1073
  // Callbacks that need to be called on unmount.
1074
- f(this, W, []);
1074
+ f(this, ee, []);
1075
1075
  /**
1076
1076
  * The currently matched route pattern, if any.
1077
1077
  */
1078
- P(this, "$pattern");
1078
+ S(this, "$pattern");
1079
1079
  f(this, ue);
1080
1080
  /**
1081
1081
  * The current URL path.
1082
1082
  */
1083
- P(this, "$path");
1083
+ S(this, "$path");
1084
1084
  f(this, he);
1085
1085
  /**
1086
1086
  * The current named path params.
1087
1087
  */
1088
- P(this, "$params");
1088
+ S(this, "$params");
1089
1089
  f(this, fe);
1090
1090
  /**
1091
1091
  * The current query params. Changes to this object will be reflected in the URL.
1092
1092
  */
1093
- P(this, "$query");
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 ?? "")
1093
+ S(this, "$query");
1094
+ f(this, Oe);
1095
+ b(this, Le, e), b(this, M, e.createLogger("dolla/router")), b(this, X, t);
1096
+ const [r, a] = ie(null), [n, o] = ie(""), [h, l] = ie({}), [d, g] = ie(
1097
+ at(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, ue, a), this.$path = n, b(this, he, o), this.$params = h, b(this, fe, l), this.$query = d, b(this, Oe, g), e.beforeMount(() => {
1100
+ s(this, P) != null && (s(this, xe).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, ee).push(s(this, P).listen(E(this, K, it).bind(this))), E(this, K, it).call(this, s(this, P)), s(this, ee).push(
1110
+ rr(s(this, X).rootElement, (m) => {
1111
+ let u = m.getAttribute("href");
1112
+ s(this, M).info("Intercepted link click", m, u), /^https?:\/\/|^\//.test(u) || (u = se([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, X).rootElement));
1117
1115
  }), e.onUnmount(() => {
1118
- for (; s(this, W).length > 0; )
1119
- s(this, W).pop()();
1116
+ for (; s(this, ee).length > 0; )
1117
+ s(this, ee).pop()();
1118
+ s(this, xe).stopAll();
1120
1119
  });
1121
1120
  }
1122
1121
  setup(e) {
1123
- if (s(this, Se).isMounted) {
1122
+ if (s(this, Le).isMounted) {
1124
1123
  s(this, M).crash(
1125
1124
  new Error("Dolla is already mounted. Router setup must be called before Dolla.mount is called.")
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, Jt()) : b(this, P, Qt()), b(this, Z, Yt(
1129
+ e.routes.flatMap((t) => E(this, K, st).call(this, t)).map((t) => ({
1131
1130
  pattern: t.pattern,
1132
1131
  meta: t.meta,
1133
- fragments: Jt(t.pattern)
1132
+ fragments: Xt(t.pattern)
1134
1133
  }))
1135
1134
  ));
1136
- for (const t of s(this, ee))
1135
+ for (const t of s(this, Z))
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 (!ot(t.meta.redirect)) if (V(t.meta.redirect)) {
1139
+ if (r = t.meta.redirect, !gt(s(this, Z), 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 = se(e) : r = e.toString(), r = He(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
+ Le = new WeakMap(), M = new WeakMap(), X = new WeakMap(), xe = new WeakMap(), P = new WeakMap(), Qe = new WeakMap(), I = new WeakMap(), Re = new WeakMap(), Z = new WeakMap(), ee = new WeakMap(), ue = new WeakMap(), he = new WeakMap(), fe = new WeakMap(), Oe = new WeakMap(), K = 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
+ st = 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)
@@ -1219,35 +1218,35 @@ rt = function(e, t = [], r = []) {
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({
1221
+ return V(l) && (l = He(se(a), l), l.startsWith("/") || (l = "/" + l)), n.push({
1223
1222
  pattern: "/" + se([...a, ...be(e.path)]),
1224
1223
  meta: {
1225
1224
  redirect: l
1226
1225
  }
1227
1226
  }), n;
1228
1227
  }
1229
- let o = mt;
1228
+ let o = bt;
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: ct(this, Qe)._++, 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, K, st).call(this, l, [...t, e], [...r, h]));
1238
1237
  else
1239
1238
  n.push({
1240
1239
  pattern: parent ? se([...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
+ }, it = async function({ location: e }) {
1248
+ e.search !== s(this, Re) && (b(this, Re, e.search), s(this, Oe).call(this, at(e.search)));
1249
+ const t = gt(s(this, Z), e.pathname);
1251
1250
  if (!t) {
1252
1251
  s(this, ue).call(this, null), s(this, he).call(this, e.pathname), s(this, fe).call(this, {
1253
1252
  wildcard: e.pathname
@@ -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 = nr(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 = He(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
1278
  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
1279
  s(this, ue).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, X).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 er = /(noopener|noreferrer) (noopener|noreferrer)/, tr = /^[\w-_]+:/;
1294
+ function rr(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,55 +1299,61 @@ 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" && er.test(o.getAttribute("rel")) || tr.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 nr(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, Ne, G, te, Me, Te, De, Ae, _e, je, B, x, z;
1316
+ class ar {
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);
1318
+ S(this, "http");
1319
+ S(this, "i18n");
1320
+ S(this, "render");
1321
+ S(this, "router");
1322
+ f(this, W, !1);
1323
+ f(this, Ne, "production");
1324
+ f(this, G);
1326
1325
  f(this, te);
1327
- f(this, Ne, _t);
1328
- f(this, Oe, []);
1329
- f(this, Me, []);
1330
- f(this, Te, []);
1326
+ f(this, Me, Vt);
1327
+ f(this, Te, Xe());
1328
+ f(this, De, []);
1329
+ f(this, Ae, []);
1330
+ f(this, _e, []);
1331
1331
  f(this, je, []);
1332
+ f(this, B, {
1333
+ root: this,
1334
+ data: {}
1335
+ });
1332
1336
  f(this, x, {
1333
1337
  info: "development",
1334
1338
  log: "development",
1335
1339
  warn: "development",
1336
1340
  error: !0
1337
1341
  });
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);
1342
+ f(this, z, ft("*,-dolla/*"));
1343
+ S(this, "watch", s(this, Te).watch);
1344
+ S(this, "createState", ie);
1345
+ S(this, "createSettableState", Nt);
1346
+ S(this, "toSettableState", Mt);
1347
+ S(this, "toState", dt);
1348
+ S(this, "valueOf", Tt);
1349
+ S(this, "derive", ye);
1350
+ S(this, "createWatcher", Xe);
1351
+ S(this, "createRef", Dt);
1352
+ S(this, "isRef", At);
1348
1353
  const e = this;
1349
- this.http = new Ct(), this.i18n = new It(this), this.render = new Wt(this), this.router = new Yt(this, {
1354
+ this.http = new qt(), this.i18n = new Gt(this), this.render = new zt(this), this.router = new Zt(this, {
1350
1355
  get rootElement() {
1351
- return s(e, B);
1356
+ return s(e, G);
1352
1357
  },
1353
1358
  get rootView() {
1354
1359
  return s(e, te);
@@ -1359,46 +1364,64 @@ class rr {
1359
1364
  * True when the app is connected to a DOM node and displayed to the user.
1360
1365
  */
1361
1366
  get isMounted() {
1362
- return s(this, z);
1367
+ return s(this, W);
1363
1368
  }
1364
1369
  /**
1365
1370
  * Get the current environment that this app is running in.
1366
1371
  * Environment affects which log messages will print and how much debugging info is included in the DOM.
1367
1372
  */
1368
1373
  getEnv() {
1369
- return s(this, Le);
1374
+ return s(this, Ne);
1370
1375
  }
1371
1376
  /**
1372
1377
  * Sets the environment that this app is running in.
1373
1378
  * Environment affects which log messages will print and how much debugging info is included in the DOM.
1374
1379
  */
1375
1380
  setEnv(e) {
1376
- b(this, Le, e);
1381
+ b(this, Ne, e);
1377
1382
  }
1378
1383
  /**
1379
1384
  * Sets the view that will be shown when the `crash` method is called on any logger.
1380
1385
  * When a crash is reported the app will be unmounted and replaced with this crash page.
1381
1386
  */
1382
1387
  setCrashView(e) {
1383
- b(this, Ne, e);
1388
+ b(this, Me, e);
1389
+ }
1390
+ /**
1391
+ * Sets a context variable and returns its value. Context variables are accessible on the app and in child views.
1392
+ */
1393
+ set(e, t) {
1394
+ return s(this, B).data[e] = t, t;
1395
+ }
1396
+ /**
1397
+ * Gets the value of a context variable. Returns null if the variable is not set.
1398
+ */
1399
+ get(e) {
1400
+ return s(this, B).data[e] ?? null;
1401
+ }
1402
+ /**
1403
+ * Returns an object of all context variables stored at the app level.
1404
+ */
1405
+ getAll() {
1406
+ return { ...s(this, B).data };
1384
1407
  }
1385
1408
  async mount(e, t) {
1386
- if (s(this, z))
1409
+ if (s(this, W))
1387
1410
  throw new Error("Dolla is already mounted.");
1388
- if (F(e)) {
1411
+ if (V(e)) {
1389
1412
  const a = document.querySelector(e);
1390
- ut(HTMLElement, a, `Selector '${e}' did not match any element.`), b(this, B, a);
1413
+ pt(HTMLElement, a, `Selector '${e}' did not match any element.`), b(this, G, a);
1391
1414
  } else
1392
- ut(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), b(this, B, e);
1415
+ pt(HTMLElement, e, "Expected an HTML element or a selector string. Got type: %t, value: %v"), b(this, G, e);
1393
1416
  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))
1417
+ t ? r = mt(t) : r = mt(bt), b(this, te, this.constructView(r.type, r.props)), await Promise.all(s(this, De).map((a) => a())), s(this, te).mount(s(this, G)), b(this, W, !0);
1418
+ for (const a of s(this, Ae))
1396
1419
  a();
1397
1420
  }
1398
1421
  async unmount() {
1399
1422
  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);
1423
+ if (s(this, W)) {
1424
+ await Promise.all(s(this, _e).map((t) => t())), (e = s(this, te)) == null || e.unmount(), s(this, Te).stopAll(), b(this, W, !1);
1402
1425
  for (const t of s(this, je))
1403
1426
  t();
1404
1427
  }
@@ -1408,20 +1431,20 @@ class rr {
1408
1431
  * it will be awaited before mounting finishes. Use this to perform initial setup before the app is displayed to the user.
1409
1432
  */
1410
1433
  beforeMount(e) {
1411
- s(this, Oe).push(e);
1434
+ s(this, De).push(e);
1412
1435
  }
1413
1436
  /**
1414
1437
  * Registers a `callback` to run after the app is mounted.
1415
1438
  */
1416
1439
  onMount(e) {
1417
- s(this, Me).push(e);
1440
+ s(this, Ae).push(e);
1418
1441
  }
1419
1442
  /**
1420
1443
  * Registers a `callback` to run after `Dolla.unmount` is called, before the app is unmounted. If `callback` returns a Promise,
1421
1444
  * it will be awaited before unmounting finishes. Use this to perform cleanup.
1422
1445
  */
1423
1446
  beforeUnmount(e) {
1424
- s(this, Te).push(e);
1447
+ s(this, _e).push(e);
1425
1448
  }
1426
1449
  /**
1427
1450
  * Registers a `callback` to run after the app is unmounted.
@@ -1439,22 +1462,22 @@ class rr {
1439
1462
  }
1440
1463
  }
1441
1464
  setLogFilter(e) {
1442
- b(this, K, ct(e));
1465
+ b(this, z, ft(e));
1443
1466
  }
1444
1467
  createLogger(e, t) {
1445
- const r = Qe(e), a = (t == null ? void 0 : t.console) ?? Tt(), n = this;
1468
+ const r = dt(e), a = (t == null ? void 0 : t.console) ?? _t(), n = this;
1446
1469
  return {
1447
1470
  get info() {
1448
- var u;
1471
+ var h;
1449
1472
  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;
1473
+ if (s(n, x).info === !1 || V(s(n, x).info) && s(n, x).info !== n.getEnv() || !s(h = n, z).call(h, o))
1474
+ return Ce;
1452
1475
  {
1453
1476
  let l = `%c${o}`;
1454
1477
  return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.info.bind(
1455
1478
  a,
1456
1479
  l,
1457
- `color:${De(l)};font-weight:bold`,
1480
+ `color:${Fe(l)};font-weight:bold`,
1458
1481
  "color:#777",
1459
1482
  "color:#aaa",
1460
1483
  "color:#777"
@@ -1462,16 +1485,16 @@ class rr {
1462
1485
  }
1463
1486
  },
1464
1487
  get log() {
1465
- var u;
1488
+ var h;
1466
1489
  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;
1490
+ if (s(n, x).log === !1 || V(s(n, x).log) && s(n, x).log !== n.getEnv() || !s(h = n, z).call(h, o))
1491
+ return Ce;
1469
1492
  {
1470
1493
  let l = `%c${o}`;
1471
1494
  return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.log.bind(
1472
1495
  a,
1473
1496
  l,
1474
- `color:${De(l)};font-weight:bold`,
1497
+ `color:${Fe(l)};font-weight:bold`,
1475
1498
  "color:#777",
1476
1499
  "color:#aaa",
1477
1500
  "color:#777"
@@ -1479,16 +1502,16 @@ class rr {
1479
1502
  }
1480
1503
  },
1481
1504
  get warn() {
1482
- var u;
1505
+ var h;
1483
1506
  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;
1507
+ if (s(n, x).warn === !1 || V(s(n, x).warn) && s(n, x).warn !== n.getEnv() || !s(h = n, z).call(h, o))
1508
+ return Ce;
1486
1509
  {
1487
1510
  let l = `%c${o}`;
1488
1511
  return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.warn.bind(
1489
1512
  a,
1490
1513
  l,
1491
- `color:${De(l)};font-weight:bold`,
1514
+ `color:${Fe(l)};font-weight:bold`,
1492
1515
  "color:#777",
1493
1516
  "color:#aaa",
1494
1517
  "color:#777"
@@ -1496,16 +1519,16 @@ class rr {
1496
1519
  }
1497
1520
  },
1498
1521
  get error() {
1499
- var u;
1522
+ var h;
1500
1523
  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;
1524
+ if (s(n, x).error === !1 || V(s(n, x).error) && s(n, x).error !== n.getEnv() || !s(h = n, z).call(h, o))
1525
+ return Ce;
1503
1526
  {
1504
1527
  let l = `%c${o}`;
1505
1528
  return t != null && t.uid ? l += ` %c[uid: %c${t.uid}%c]` : l += "%c%c%c", a.error.bind(
1506
1529
  a,
1507
1530
  l,
1508
- `color:${De(l)};font-weight:bold`,
1531
+ `color:${Fe(l)};font-weight:bold`,
1509
1532
  "color:#777",
1510
1533
  "color:#aaa",
1511
1534
  "color:#777"
@@ -1513,11 +1536,11 @@ class rr {
1513
1536
  }
1514
1537
  },
1515
1538
  crash(o) {
1516
- throw n.isMounted && (n.unmount(), n.constructView(s(n, Ne), {
1539
+ throw n.isMounted && (n.unmount(), n.constructView(s(n, Me), {
1517
1540
  error: o,
1518
1541
  loggerName: r.get(),
1519
1542
  uid: t == null ? void 0 : t.uid
1520
- }).mount(s(n, B))), o;
1543
+ }).mount(s(n, G))), o;
1521
1544
  }
1522
1545
  };
1523
1546
  }
@@ -1525,33 +1548,41 @@ class rr {
1525
1548
  *
1526
1549
  */
1527
1550
  constructView(e, t, r = []) {
1528
- return jt({ root: this, data: {} }, e, t, r);
1551
+ return jt(s(this, B), e, t, r);
1529
1552
  }
1530
1553
  /**
1531
1554
  *
1532
1555
  */
1533
1556
  constructMarkup(e) {
1534
- return At(Dt({ root: this, data: {} }, e));
1557
+ return Ct(Ft(s(this, B), e));
1535
1558
  }
1536
1559
  }
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);
1560
+ W = new WeakMap(), Ne = new WeakMap(), G = new WeakMap(), te = new WeakMap(), Me = new WeakMap(), Te = new WeakMap(), De = new WeakMap(), Ae = new WeakMap(), _e = new WeakMap(), je = new WeakMap(), B = new WeakMap(), x = new WeakMap(), z = new WeakMap();
1561
+ const wt = new ar(), lr = wt.i18n.t.bind(wt.i18n);
1562
+ function cr(i) {
1563
+ typeof window < "u" && (window.DOLLA_DEV_DEBUG = i);
1564
+ }
1565
+ function ur() {
1566
+ return typeof window < "u" ? window.DOLLA_DEV_DEBUG === !0 : !1;
1567
+ }
1539
1568
  export {
1540
- Pt as cond,
1541
- ht as createMarkup,
1542
- Ot as createRef,
1543
- xt as createSettableState,
1544
- cr as createSetter,
1569
+ xt as cond,
1570
+ mt as createMarkup,
1571
+ Dt as createRef,
1572
+ Nt as createSettableState,
1573
+ dr as createSetter,
1545
1574
  ie as createState,
1546
- dt as default,
1575
+ wt as default,
1547
1576
  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
1577
+ ur as getDevDebug,
1578
+ ut as html,
1579
+ At as isRef,
1580
+ pr as portal,
1581
+ mr as repeat,
1582
+ cr as setDevDebug,
1583
+ lr as t,
1584
+ Mt as toSettableState,
1585
+ dt as toState,
1586
+ Tt as valueOf
1556
1587
  };
1557
1588
  //# sourceMappingURL=index.js.map