@manyducks.co/dolla 2.0.0-alpha.21 → 2.0.0-alpha.23

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