@manyducks.co/dolla 2.0.0-alpha.16 → 2.0.0-alpha.17

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