@aerogel/core 0.0.0-next.d7394c3aa6aac799b0971e63819a8713d05a5123 → 0.0.0-next.eed7a057cf5b844cd9f7fc6bda2d8df49fcd6736

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 (116) hide show
  1. package/dist/aerogel-core.d.ts +2317 -667
  2. package/dist/aerogel-core.js +2789 -0
  3. package/dist/aerogel-core.js.map +1 -0
  4. package/package.json +19 -34
  5. package/src/bootstrap/bootstrap.test.ts +4 -7
  6. package/src/bootstrap/index.ts +25 -16
  7. package/src/bootstrap/options.ts +1 -1
  8. package/src/components/AGAppLayout.vue +1 -1
  9. package/src/components/AGAppModals.vue +1 -1
  10. package/src/components/AGAppOverlays.vue +1 -1
  11. package/src/components/composition.ts +1 -1
  12. package/src/components/forms/AGButton.vue +2 -2
  13. package/src/components/forms/AGCheckbox.vue +4 -3
  14. package/src/components/forms/AGForm.vue +2 -2
  15. package/src/components/forms/AGInput.vue +6 -4
  16. package/src/components/forms/AGSelect.vue +3 -3
  17. package/src/components/headless/forms/AGHeadlessButton.ts +1 -1
  18. package/src/components/headless/forms/AGHeadlessButton.vue +2 -2
  19. package/src/components/headless/forms/AGHeadlessInput.ts +11 -4
  20. package/src/components/headless/forms/AGHeadlessInput.vue +3 -3
  21. package/src/components/headless/forms/AGHeadlessInputDescription.vue +1 -1
  22. package/src/components/headless/forms/AGHeadlessInputError.vue +2 -2
  23. package/src/components/headless/forms/AGHeadlessInputInput.vue +4 -4
  24. package/src/components/headless/forms/AGHeadlessInputLabel.vue +1 -1
  25. package/src/components/headless/forms/AGHeadlessInputTextArea.vue +3 -3
  26. package/src/components/headless/forms/AGHeadlessSelect.ts +3 -3
  27. package/src/components/headless/forms/AGHeadlessSelect.vue +5 -5
  28. package/src/components/headless/forms/AGHeadlessSelectButton.vue +2 -2
  29. package/src/components/headless/forms/AGHeadlessSelectError.vue +2 -2
  30. package/src/components/headless/forms/AGHeadlessSelectLabel.vue +2 -2
  31. package/src/components/headless/forms/AGHeadlessSelectOption.vue +3 -3
  32. package/src/components/headless/forms/composition.ts +1 -1
  33. package/src/components/headless/modals/AGHeadlessModal.ts +6 -4
  34. package/src/components/headless/modals/AGHeadlessModal.vue +14 -8
  35. package/src/components/headless/modals/AGHeadlessModalPanel.vue +13 -9
  36. package/src/components/headless/modals/AGHeadlessModalTitle.vue +14 -4
  37. package/src/components/headless/snackbars/index.ts +3 -3
  38. package/src/components/lib/AGErrorMessage.vue +3 -3
  39. package/src/components/lib/AGMarkdown.vue +16 -3
  40. package/src/components/lib/AGMeasured.vue +1 -1
  41. package/src/components/lib/AGProgressBar.vue +55 -0
  42. package/src/components/lib/index.ts +1 -0
  43. package/src/components/modals/AGAlertModal.ts +6 -3
  44. package/src/components/modals/AGConfirmModal.ts +16 -7
  45. package/src/components/modals/AGConfirmModal.vue +2 -2
  46. package/src/components/modals/AGErrorReportModal.ts +8 -5
  47. package/src/components/modals/AGErrorReportModalButtons.vue +9 -9
  48. package/src/components/modals/AGErrorReportModalTitle.vue +2 -2
  49. package/src/components/modals/AGLoadingModal.ts +11 -5
  50. package/src/components/modals/AGModal.ts +1 -0
  51. package/src/components/modals/AGModal.vue +5 -2
  52. package/src/components/modals/AGModalContext.ts +1 -1
  53. package/src/components/modals/AGModalContext.vue +15 -5
  54. package/src/components/modals/AGPromptModal.ts +12 -7
  55. package/src/components/snackbars/AGSnackbar.vue +2 -2
  56. package/src/components/utils.ts +7 -4
  57. package/src/directives/index.ts +3 -5
  58. package/src/directives/measure.ts +1 -1
  59. package/src/errors/Errors.state.ts +1 -1
  60. package/src/errors/Errors.ts +12 -12
  61. package/src/errors/JobCancelledError.ts +3 -0
  62. package/src/errors/index.ts +9 -6
  63. package/src/errors/utils.ts +17 -1
  64. package/src/forms/Form.test.ts +4 -3
  65. package/src/forms/Form.ts +27 -17
  66. package/src/forms/composition.ts +2 -2
  67. package/src/forms/index.ts +2 -1
  68. package/src/forms/utils.ts +20 -4
  69. package/src/forms/validation.ts +19 -0
  70. package/src/jobs/Job.ts +144 -2
  71. package/src/jobs/index.ts +4 -1
  72. package/src/jobs/listeners.ts +3 -0
  73. package/src/jobs/status.ts +4 -0
  74. package/src/lang/DefaultLangProvider.ts +7 -4
  75. package/src/lang/Lang.state.ts +1 -1
  76. package/src/lang/Lang.ts +5 -1
  77. package/src/lang/index.ts +7 -5
  78. package/src/plugins/Plugin.ts +1 -1
  79. package/src/plugins/index.ts +10 -7
  80. package/src/services/App.state.ts +13 -4
  81. package/src/services/App.ts +8 -3
  82. package/src/services/Cache.ts +1 -1
  83. package/src/services/Events.ts +15 -5
  84. package/src/services/Service.ts +116 -53
  85. package/src/services/Storage.ts +20 -0
  86. package/src/services/index.ts +10 -4
  87. package/src/services/utils.ts +18 -0
  88. package/src/testing/index.ts +4 -3
  89. package/src/testing/setup.ts +5 -19
  90. package/src/ui/UI.state.ts +2 -2
  91. package/src/ui/UI.ts +139 -54
  92. package/src/ui/index.ts +4 -4
  93. package/src/ui/utils.ts +1 -1
  94. package/src/utils/composition/events.ts +2 -2
  95. package/src/utils/composition/persistent.test.ts +33 -0
  96. package/src/utils/composition/persistent.ts +11 -0
  97. package/src/utils/composition/state.test.ts +47 -0
  98. package/src/utils/composition/state.ts +24 -0
  99. package/src/utils/index.ts +2 -0
  100. package/src/utils/markdown.test.ts +50 -0
  101. package/src/utils/markdown.ts +19 -6
  102. package/src/utils/vue.ts +14 -4
  103. package/dist/aerogel-core.cjs.js +0 -2
  104. package/dist/aerogel-core.cjs.js.map +0 -1
  105. package/dist/aerogel-core.esm.js +0 -2
  106. package/dist/aerogel-core.esm.js.map +0 -1
  107. package/histoire.config.ts +0 -7
  108. package/noeldemartin.config.js +0 -5
  109. package/postcss.config.js +0 -6
  110. package/src/assets/histoire.css +0 -3
  111. package/src/directives/initial-focus.ts +0 -11
  112. package/src/main.histoire.ts +0 -1
  113. package/tailwind.config.js +0 -4
  114. package/tsconfig.json +0 -11
  115. package/vite.config.ts +0 -17
  116. /package/src/{main.ts → index.ts} +0 -0
@@ -0,0 +1,2789 @@
1
+ var wt = Object.defineProperty;
2
+ var $t = (r, t, e) => t in r ? wt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var v = (r, t, e) => $t(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import { ref as E, computed as d, watch as Ee, inject as ae, reactive as ce, markRaw as Te, nextTick as Ve, onUnmounted as he, useAttrs as Be, onMounted as xt, toRaw as St, defineComponent as f, toRef as ue, createBlock as _, openBlock as l, resolveDynamicComponent as j, withCtx as m, renderSlot as $, unref as c, provide as _e, normalizeProps as ze, guardReactiveProps as Fe, createElementBlock as w, createCommentVNode as L, Fragment as K, createElementVNode as b, createVNode as h, normalizeClass as q, h as kt, mergeProps as T, customRef as At, createTextVNode as D, toDisplayString as P, renderList as ge, watchEffect as de, withModifiers as Ct, readonly as Ue, useSlots as Ne, createApp as Pt, resolveDirective as Mt, withDirectives as Et, normalizeStyle as Gt } from "vue";
5
+ import { JSError as ve, tap as O, MagicObject as We, PromisedValue as N, Storage as z, objectOnly as ee, arrayFrom as Ke, isEmpty as ke, objectDeepClone as Lt, fail as W, facade as J, arrayRemove as Pe, getEnv as Ht, updateLocationQueryParameters as It, forever as Tt, toString as V, isDevelopment as X, isTesting as Ge, after as Re, uuid as pe, required as Rt, isObject as fe, objectWithoutEmpty as Oe, objectWithout as Je, noop as jt, stringMatchAll as qt, isInstanceOf as Dt, stringExcerpt as Vt, ListenersManager as Bt, toError as zt, round as Ft } from "@noeldemartin/utils";
6
+ import Q from "virtual:aerogel";
7
+ import { createPinia as Ut, setActivePinia as Nt, defineStore as Wt } from "pinia";
8
+ import { Dialog as Kt, DialogPanel as Ot, DialogTitle as Jt, Listbox as Qt, ListboxButton as Xt, ListboxLabel as Yt, ListboxOption as Zt, ListboxOptions as er } from "@headlessui/vue";
9
+ import { ListboxOptions as Go } from "@headlessui/vue";
10
+ import tr from "dompurify";
11
+ import { marked as rr, Renderer as je } from "marked";
12
+ class Me extends ve {
13
+ constructor(t, e) {
14
+ super(`Service '${t}' failed booting`, { cause: e });
15
+ }
16
+ }
17
+ let Le = null;
18
+ function Qe() {
19
+ return Le ?? sr();
20
+ }
21
+ function sr() {
22
+ return O(Ut(), (r) => {
23
+ Le = r, Nt(r);
24
+ });
25
+ }
26
+ function nr() {
27
+ return Le ?? Qe();
28
+ }
29
+ function or(r, t) {
30
+ return Qe(), Wt(r, t)();
31
+ }
32
+ function be(r) {
33
+ var t;
34
+ return t = class extends ye {
35
+ usesStore() {
36
+ return !0;
37
+ }
38
+ getName() {
39
+ return r.name ?? null;
40
+ }
41
+ getInitialState() {
42
+ return typeof r.initialState == "function" ? r.initialState() : Object.entries(r.initialState).reduce((e, [s, n]) => {
43
+ try {
44
+ n = structuredClone(n);
45
+ } catch {
46
+ console.warn(
47
+ `Could not clone '${s}' state from ${this.getName()} service, this may cause problems if you're using multiple instances of the service (for example, in unit tests).
48
+ To fix this problem, declare your initialState as a function instead.`
49
+ );
50
+ }
51
+ return e[s] = n, e;
52
+ }, {});
53
+ }
54
+ getComputedStateDefinition() {
55
+ return r.computed ?? {};
56
+ }
57
+ getStateWatchers() {
58
+ return r.watch ?? {};
59
+ }
60
+ serializePersistedState(e) {
61
+ var s;
62
+ return ((s = r.serialize) == null ? void 0 : s.call(r, e)) ?? e;
63
+ }
64
+ deserializePersistedState(e) {
65
+ var s;
66
+ return ((s = r.restore) == null ? void 0 : s.call(r, e)) ?? e;
67
+ }
68
+ }, v(t, "persist", r.persist ?? []), t;
69
+ }
70
+ var Ce;
71
+ let ye = (Ce = class extends We {
72
+ constructor() {
73
+ super();
74
+ v(this, "_name");
75
+ v(this, "_booted");
76
+ v(this, "_computedStateKeys");
77
+ v(this, "_watchers");
78
+ v(this, "_store");
79
+ const e = this.getComputedStateDefinition();
80
+ this._name = this.getName() ?? new.target.name, this._booted = new N(), this._computedStateKeys = new Set(Object.keys(e)), this._watchers = this.getStateWatchers(), this._store = this.usesStore() && or(this._name, {
81
+ state: () => this.getInitialState(),
82
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
+ getters: e
84
+ });
85
+ }
86
+ get booted() {
87
+ return this._booted;
88
+ }
89
+ static(e) {
90
+ return super.static(e);
91
+ }
92
+ launch() {
93
+ const e = (s) => this._booted.reject(new Me(this._name, s));
94
+ try {
95
+ this.frameworkBoot().then(() => this.boot()).then(() => this._booted.resolve()).catch(e);
96
+ } catch (s) {
97
+ e(s);
98
+ }
99
+ return this._booted;
100
+ }
101
+ hasPersistedState() {
102
+ return z.has(this._name);
103
+ }
104
+ hasState(e) {
105
+ return this._store ? e in this._store.$state || this._computedStateKeys.has(e) : !1;
106
+ }
107
+ getState(e) {
108
+ const s = this._store;
109
+ return e ? s ? s[e] : void 0 : s || {};
110
+ }
111
+ setState(e, s) {
112
+ if (!this._store)
113
+ return;
114
+ const n = typeof e == "string" ? { [e]: s } : e, o = ee(this._store.$state, Object.keys(n));
115
+ Object.assign(this._store.$state, n), this.onStateUpdated(n, o);
116
+ }
117
+ updatePersistedState(e) {
118
+ if (!this._store)
119
+ return;
120
+ const s = Ke(e), n = ee(this._store.$state, s);
121
+ ke(n) || this.onPersistentStateUpdated(n);
122
+ }
123
+ __get(e) {
124
+ return this.hasState(e) ? this.getState(e) : super.__get(e);
125
+ }
126
+ __set(e, s) {
127
+ this.setState({ [e]: s });
128
+ }
129
+ onStateUpdated(e, s) {
130
+ const n = ee(e, this.static("persist"));
131
+ ke(n) || this.onPersistentStateUpdated(n);
132
+ for (const o in e) {
133
+ const a = this._watchers[o];
134
+ !a || e[o] === s[o] || a.call(this, e[o], s[o]);
135
+ }
136
+ }
137
+ onPersistentStateUpdated(e) {
138
+ const s = z.get(this._name);
139
+ s && z.set(this._name, {
140
+ ...s,
141
+ ...this.serializePersistedState(Lt(e))
142
+ });
143
+ }
144
+ usesStore() {
145
+ return !1;
146
+ }
147
+ getName() {
148
+ return null;
149
+ }
150
+ getInitialState() {
151
+ return {};
152
+ }
153
+ getComputedStateDefinition() {
154
+ return {};
155
+ }
156
+ getStateWatchers() {
157
+ return {};
158
+ }
159
+ serializePersistedState(e) {
160
+ return e;
161
+ }
162
+ deserializePersistedState(e) {
163
+ return e;
164
+ }
165
+ async frameworkBoot() {
166
+ this.restorePersistedState();
167
+ }
168
+ async boot() {
169
+ }
170
+ restorePersistedState() {
171
+ if (!(!this.usesStore() || ke(this.static("persist")))) {
172
+ if (z.has(this._name)) {
173
+ const e = z.require(this._name);
174
+ this.setState(this.deserializePersistedState(e));
175
+ return;
176
+ }
177
+ z.set(this._name, ee(this.getState(), this.static("persist")));
178
+ }
179
+ }
180
+ requireStore() {
181
+ return this._store ? this._store : W(`Failed getting '${this._name}' store`);
182
+ }
183
+ }, v(Ce, "persist", []), Ce);
184
+ const Nn = {
185
+ Low: -256,
186
+ Default: 0,
187
+ High: 256
188
+ };
189
+ class ar extends ye {
190
+ constructor() {
191
+ super(...arguments);
192
+ v(this, "listeners", {});
193
+ }
194
+ async boot() {
195
+ Object.entries(globalThis.__aerogelEvents__ ?? {}).forEach(([e, s]) => this.on(e, s));
196
+ }
197
+ async emit(e, s) {
198
+ var o;
199
+ const n = this.listeners[e] ?? { priorities: [], handlers: {} };
200
+ for (const a of n.priorities)
201
+ await Promise.all(((o = n.handlers[a]) == null ? void 0 : o.map((i) => i(s))) ?? []);
202
+ }
203
+ // prettier-ignore
204
+ /* eslint-enable max-len */
205
+ on(e, s, n) {
206
+ const o = typeof s == "function" ? {} : typeof s == "number" ? { priority: s } : s, a = typeof s == "function" ? s : n;
207
+ return this.registerListener(e, o, a), () => this.off(e, a);
208
+ }
209
+ // prettier-ignore
210
+ /* eslint-enable max-len */
211
+ once(e, s, n) {
212
+ let o = null;
213
+ const a = typeof s == "function" ? {} : s, i = typeof s == "function" ? s : n;
214
+ return O(
215
+ () => o && this.off(e, o),
216
+ (u) => {
217
+ o = (...p) => (u(), i(...p)), this.registerListener(e, a, i);
218
+ }
219
+ );
220
+ }
221
+ off(e, s) {
222
+ var a;
223
+ const n = this.listeners[e];
224
+ if (!n)
225
+ return;
226
+ const o = [...n.priorities];
227
+ for (const i of o)
228
+ Pe(n.handlers[i] ?? [], s), ((a = n.handlers[i]) == null ? void 0 : a.length) === 0 && (delete n.handlers[i], Pe(n.priorities, i));
229
+ n.priorities.length === 0 && delete this.listeners[e];
230
+ }
231
+ registerListener(e, s, n) {
232
+ var u, p, k;
233
+ const o = s.priority ?? 0;
234
+ e in this.listeners || (this.listeners[e] = { priorities: [], handlers: {} });
235
+ const a = ((u = this.listeners[e]) == null ? void 0 : u.priorities) ?? W(`priorities missing for event '${e}'`), i = ((p = this.listeners[e]) == null ? void 0 : p.handlers) ?? W(`handlers missing for event '${e}'`);
236
+ a.includes(o) || (a.push(o), a.sort((y, A) => A - y), i[o] = []), (k = i[o]) == null || k.push(n);
237
+ }
238
+ }
239
+ const S = J(ar), ir = be({
240
+ name: "app",
241
+ initialState: {
242
+ plugins: {},
243
+ instance: null,
244
+ environment: Ht() ?? "development",
245
+ version: Q.version,
246
+ sourceUrl: Q.sourceUrl
247
+ },
248
+ computed: {
249
+ development: (r) => r.environment === "development",
250
+ staging: (r) => r.environment === "staging",
251
+ testing: (r) => r.environment === "test" || r.environment === "testing",
252
+ versionName(r) {
253
+ return this.development ? "dev." + Q.sourceHash.toString().substring(0, 7) : this.staging ? "staging." + Q.sourceHash.toString().substring(0, 7) : `v${r.version}`;
254
+ },
255
+ versionUrl(r) {
256
+ return r.sourceUrl + (this.development || this.staging ? `/tree/${Q.sourceHash}` : `/releases/tag/${this.versionName}`);
257
+ }
258
+ }
259
+ });
260
+ class lr extends ir {
261
+ constructor() {
262
+ super(...arguments);
263
+ v(this, "name", Q.name);
264
+ v(this, "ready", new N());
265
+ v(this, "mounted", new N());
266
+ }
267
+ isReady() {
268
+ return this.ready.isResolved();
269
+ }
270
+ isMounted() {
271
+ return this.mounted.isResolved();
272
+ }
273
+ async whenReady(e) {
274
+ return await this.ready.then(e);
275
+ }
276
+ async reload(e) {
277
+ e && It(e), location.reload(), await Tt();
278
+ }
279
+ plugin(e) {
280
+ return this.plugins[e] ?? null;
281
+ }
282
+ service(e) {
283
+ var s;
284
+ return ((s = this.instance) == null ? void 0 : s.config.globalProperties[e]) ?? null;
285
+ }
286
+ async boot() {
287
+ S.once("application-ready", () => this.ready.resolve()), S.once("application-mounted", () => this.mounted.resolve());
288
+ }
289
+ }
290
+ const F = J(lr);
291
+ function Wn(r) {
292
+ return r;
293
+ }
294
+ async function cr(r, ...t) {
295
+ F.setState(
296
+ "plugins",
297
+ r.reduce(
298
+ (e, s) => (s.name && (e[s.name] = s), e),
299
+ {}
300
+ )
301
+ ), await Promise.all(r.map((e) => e.install(...t)) ?? []);
302
+ }
303
+ function ur(r) {
304
+ return {
305
+ type: Array,
306
+ default: r ?? (() => [])
307
+ };
308
+ }
309
+ function re(r = !1) {
310
+ return {
311
+ type: Boolean,
312
+ default: r
313
+ };
314
+ }
315
+ function He() {
316
+ return E();
317
+ }
318
+ function Kn(r) {
319
+ const t = E(), e = d(r);
320
+ return Ee(e, async () => t.value = await e.value, { immediate: !0 }), t;
321
+ }
322
+ function On(r) {
323
+ return r;
324
+ }
325
+ function Y(r, t) {
326
+ const e = Object.values(r);
327
+ return {
328
+ type: String,
329
+ default: t ?? e[0] ?? null,
330
+ validator: (s) => e.includes(s)
331
+ };
332
+ }
333
+ function dr(r) {
334
+ const t = ae(r);
335
+ return t ? ce(t) : void 0;
336
+ }
337
+ function H(r, t) {
338
+ return dr(r) ?? W(t ?? `Could not resolve '${V(r)}' injection key`);
339
+ }
340
+ function Jn(r, t) {
341
+ return ae(r) ?? W(t ?? `Could not resolve '${V(r)}' injection key`);
342
+ }
343
+ function Qn() {
344
+ return {
345
+ type: Function,
346
+ default: null
347
+ };
348
+ }
349
+ function we(r, t) {
350
+ return {
351
+ type: r,
352
+ default: t ?? null
353
+ };
354
+ }
355
+ function se(r = null) {
356
+ return {
357
+ type: Number,
358
+ default: r
359
+ };
360
+ }
361
+ function U(r = null) {
362
+ return {
363
+ type: Object,
364
+ default: r
365
+ };
366
+ }
367
+ function Xe() {
368
+ return {
369
+ type: Array,
370
+ required: !0
371
+ };
372
+ }
373
+ function Xn(r) {
374
+ const t = Object.values(r);
375
+ return {
376
+ type: String,
377
+ required: !0,
378
+ validator: (e) => t.includes(e)
379
+ };
380
+ }
381
+ function pr(r) {
382
+ return {
383
+ type: r,
384
+ required: !0
385
+ };
386
+ }
387
+ function Yn() {
388
+ return {
389
+ type: Number,
390
+ required: !0
391
+ };
392
+ }
393
+ function $e() {
394
+ return {
395
+ type: Object,
396
+ required: !0
397
+ };
398
+ }
399
+ function ne() {
400
+ return {
401
+ type: String,
402
+ required: !0
403
+ };
404
+ }
405
+ function g(r = null) {
406
+ return {
407
+ type: String,
408
+ default: r
409
+ };
410
+ }
411
+ const Ae = /* @__PURE__ */ new WeakMap(), fr = {
412
+ mounted(r, { value: t }) {
413
+ const e = typeof t == "function" ? t : null, s = () => {
414
+ const n = r.getBoundingClientRect();
415
+ r.style.setProperty("--width", `${n.width}px`), r.style.setProperty("--height", `${n.height}px`), e == null || e({ width: n.width, height: n.height });
416
+ };
417
+ Ae.set(r, O(new ResizeObserver(s)).observe(r)), s();
418
+ },
419
+ unmounted(r) {
420
+ var t;
421
+ (t = Ae.get(r)) == null || t.unobserve(r), Ae.delete(r);
422
+ }
423
+ }, mr = {
424
+ measure: fr
425
+ }, hr = {
426
+ install(r, t) {
427
+ const e = {
428
+ ...mr,
429
+ ...t.directives
430
+ };
431
+ for (const [s, n] of Object.entries(e))
432
+ r.directive(s, n);
433
+ }
434
+ };
435
+ class _r extends ye {
436
+ constructor() {
437
+ super(...arguments);
438
+ v(this, "cache");
439
+ }
440
+ async get(e) {
441
+ return await (await this.open()).match(e) ?? null;
442
+ }
443
+ async store(e, s) {
444
+ await (await this.open()).put(e, s);
445
+ }
446
+ async replace(e, s) {
447
+ const n = await this.open();
448
+ (await n.keys(e)).length !== 0 && await n.put(e, s);
449
+ }
450
+ async open() {
451
+ return this.cache = this.cache ?? O(new N(), (e) => {
452
+ caches.open("app").then((s) => e.resolve(s));
453
+ });
454
+ }
455
+ }
456
+ const Zn = J(_r);
457
+ class gr extends ye {
458
+ async purge() {
459
+ await S.emit("purge-storage");
460
+ }
461
+ }
462
+ const vr = J(gr);
463
+ function eo(r, t) {
464
+ return {
465
+ ...r,
466
+ ...ee(t, Object.keys(r))
467
+ };
468
+ }
469
+ const br = {
470
+ $app: F,
471
+ $events: S,
472
+ $storage: vr
473
+ };
474
+ async function xe(r, t) {
475
+ await Promise.all(
476
+ Object.entries(t).map(async ([e, s]) => {
477
+ await s.launch().catch((n) => {
478
+ var o, a;
479
+ return (a = (o = r.config).errorHandler) == null ? void 0 : a.call(o, n, null, `Failed launching ${e}.`);
480
+ });
481
+ })
482
+ ), Object.assign(r.config.globalProperties, t), (X() || Ge()) && Object.assign(globalThis, t);
483
+ }
484
+ const yr = {
485
+ async install(r, t) {
486
+ const e = {
487
+ ...br,
488
+ ...t.services
489
+ };
490
+ r.use(nr()), await xe(r, e);
491
+ }
492
+ }, Ye = 768, me = {
493
+ Mobile: "mobile",
494
+ Desktop: "desktop"
495
+ };
496
+ function Ze() {
497
+ return globalThis.innerWidth > Ye ? me.Desktop : me.Mobile;
498
+ }
499
+ const wr = be({
500
+ name: "ui",
501
+ initialState: {
502
+ modals: [],
503
+ snackbars: [],
504
+ layout: Ze()
505
+ },
506
+ computed: {
507
+ mobile: ({ layout: r }) => r === me.Mobile,
508
+ desktop: ({ layout: r }) => r === me.Desktop
509
+ }
510
+ }), M = {
511
+ AlertModal: "alert-modal",
512
+ ConfirmModal: "confirm-modal",
513
+ ErrorReportModal: "error-report-modal",
514
+ LoadingModal: "loading-modal",
515
+ PromptModal: "prompt-modal",
516
+ Snackbar: "snackbar",
517
+ StartupCrash: "startup-crash"
518
+ };
519
+ class $r extends wr {
520
+ constructor() {
521
+ super(...arguments);
522
+ v(this, "modalCallbacks", {});
523
+ v(this, "components", {});
524
+ }
525
+ requireComponent(e) {
526
+ return this.components[e] ?? W(`UI Component '${e}' is not defined!`);
527
+ }
528
+ alert(e, s) {
529
+ const n = () => typeof s != "string" ? { message: e } : {
530
+ title: e,
531
+ message: s
532
+ };
533
+ this.openModal(this.requireComponent(M.AlertModal), n());
534
+ }
535
+ // prettier-ignore
536
+ /* eslint-enable max-len */
537
+ async confirm(e, s, n) {
538
+ const a = typeof s != "string" ? {
539
+ ...s ?? {},
540
+ message: e,
541
+ required: !!(s != null && s.required)
542
+ } : {
543
+ ...n ?? {},
544
+ title: e,
545
+ message: s,
546
+ required: !!(n != null && n.required)
547
+ }, u = await (await this.openModal(this.requireComponent(M.ConfirmModal), a)).beforeClose, p = typeof u == "object" ? u[0] : u ?? !1, k = typeof u == "object" ? u[1] : Object.entries(a.checkboxes ?? {}).reduce(
548
+ (y, [A, { default: Z }]) => ({
549
+ [A]: Z ?? !1,
550
+ ...y
551
+ }),
552
+ {}
553
+ );
554
+ for (const [y, A] of Object.entries(a.checkboxes ?? {}))
555
+ if (!(!A.required || k[y]))
556
+ return p && X() && console.warn(`Confirmed confirm modal was suppressed because required '${y}' checkbox was missing`), [!1, k];
557
+ return "checkboxes" in a ? [p, k] : p;
558
+ }
559
+ async prompt(e, s, n) {
560
+ const o = (n == null ? void 0 : n.trim) ?? !0, a = () => typeof s != "string" ? {
561
+ message: e,
562
+ ...s ?? {}
563
+ } : {
564
+ title: e,
565
+ message: s,
566
+ ...n ?? {}
567
+ }, u = await (await this.openModal(
568
+ this.requireComponent(M.PromptModal),
569
+ a()
570
+ )).beforeClose;
571
+ return (o && typeof u == "string" ? u == null ? void 0 : u.trim() : u) ?? null;
572
+ }
573
+ async loading(e, s) {
574
+ const n = (p) => typeof p == "function" ? Promise.resolve(p()) : p, o = () => typeof e == "string" ? {
575
+ props: { message: e },
576
+ operationPromise: n(s)
577
+ } : typeof e == "function" || e instanceof Promise ? { operationPromise: n(e) } : {
578
+ props: e,
579
+ operationPromise: n(s)
580
+ }, { operationPromise: a, props: i } = o(), u = await this.openModal(this.requireComponent(M.LoadingModal), i);
581
+ try {
582
+ const [p] = await Promise.all([a, Re({ seconds: 1 })]);
583
+ return p;
584
+ } finally {
585
+ await this.closeModal(u.id);
586
+ }
587
+ }
588
+ showSnackbar(e, s = {}) {
589
+ const n = {
590
+ id: pe(),
591
+ properties: { message: e, ...s },
592
+ component: Te(s.component ?? this.requireComponent(M.Snackbar))
593
+ };
594
+ this.setState("snackbars", this.snackbars.concat(n)), setTimeout(() => this.hideSnackbar(n.id), 5e3);
595
+ }
596
+ hideSnackbar(e) {
597
+ this.setState(
598
+ "snackbars",
599
+ this.snackbars.filter((s) => s.id !== e)
600
+ );
601
+ }
602
+ registerComponent(e, s) {
603
+ this.components[e] = s;
604
+ }
605
+ async openModal(e, s) {
606
+ const n = pe(), o = {}, a = {
607
+ id: n,
608
+ properties: s ?? {},
609
+ component: Te(e),
610
+ beforeClose: new Promise((p) => o.willClose = p),
611
+ afterClose: new Promise((p) => o.closed = p)
612
+ }, i = this.modals.at(-1), u = this.modals.concat(a);
613
+ return this.modalCallbacks[a.id] = o, this.setState({ modals: u }), await Ve(), await (i && S.emit("hide-modal", { id: i.id })), await Promise.all([
614
+ i || S.emit("show-overlays-backdrop"),
615
+ S.emit("show-modal", { id: a.id })
616
+ ]), a;
617
+ }
618
+ async closeModal(e, s) {
619
+ if (!F.isMounted()) {
620
+ await this.removeModal(e, s);
621
+ return;
622
+ }
623
+ await S.emit("close-modal", { id: e, result: s });
624
+ }
625
+ async closeAllModals() {
626
+ for (; this.modals.length > 0; )
627
+ await this.closeModal(Rt(this.modals[this.modals.length - 1]).id);
628
+ }
629
+ async boot() {
630
+ this.watchModalEvents(), this.watchMountedEvent(), this.watchViewportBreakpoints();
631
+ }
632
+ async removeModal(e, s) {
633
+ var o, a;
634
+ this.setState(
635
+ "modals",
636
+ this.modals.filter((i) => i.id !== e)
637
+ ), (a = (o = this.modalCallbacks[e]) == null ? void 0 : o.closed) == null || a.call(o, s), delete this.modalCallbacks[e];
638
+ const n = this.modals.at(-1);
639
+ await (n && S.emit("show-modal", { id: n.id }));
640
+ }
641
+ watchModalEvents() {
642
+ S.on("modal-will-close", ({ modal: e, result: s }) => {
643
+ var n, o;
644
+ (o = (n = this.modalCallbacks[e.id]) == null ? void 0 : n.willClose) == null || o.call(n, s), this.modals.length === 1 && S.emit("hide-overlays-backdrop");
645
+ }), S.on("modal-closed", async ({ modal: { id: e }, result: s }) => {
646
+ await this.removeModal(e, s);
647
+ });
648
+ }
649
+ watchMountedEvent() {
650
+ S.once("application-mounted", async () => {
651
+ if (!globalThis.document || !globalThis.getComputedStyle)
652
+ return;
653
+ const e = globalThis.document.getElementById("splash");
654
+ e && (globalThis.getComputedStyle(e).opacity !== "0" && (e.style.opacity = "0", await Re({ ms: 600 })), e.remove());
655
+ });
656
+ }
657
+ watchViewportBreakpoints() {
658
+ if (!globalThis.matchMedia)
659
+ return;
660
+ globalThis.matchMedia(`(min-width: ${Ye}px)`).addEventListener("change", () => this.setState({ layout: Ze() }));
661
+ }
662
+ }
663
+ const G = J($r);
664
+ class xr {
665
+ constructor(t, e) {
666
+ this.locale = t, this.fallbackLocale = e;
667
+ }
668
+ getLocale() {
669
+ return this.locale;
670
+ }
671
+ async setLocale(t) {
672
+ this.locale = t;
673
+ }
674
+ getFallbackLocale() {
675
+ return this.fallbackLocale;
676
+ }
677
+ async setFallbackLocale(t) {
678
+ this.fallbackLocale = t;
679
+ }
680
+ getLocales() {
681
+ return ["en"];
682
+ }
683
+ translate(t) {
684
+ return X() && console.warn("Lang provider is missing"), t;
685
+ }
686
+ translateWithDefault(t, e) {
687
+ return X() && console.warn("Lang provider is missing"), e;
688
+ }
689
+ }
690
+ const Sr = be({
691
+ name: "lang",
692
+ persist: ["locale", "fallbackLocale"],
693
+ initialState: {
694
+ locale: null,
695
+ locales: ["en"],
696
+ fallbackLocale: "en"
697
+ }
698
+ });
699
+ class kr extends Sr {
700
+ constructor() {
701
+ super();
702
+ v(this, "provider");
703
+ this.provider = new xr(
704
+ this.getState("locale") ?? this.getBrowserLocale(),
705
+ this.getState("fallbackLocale")
706
+ );
707
+ }
708
+ async setProvider(e) {
709
+ this.provider = e, this.locales = e.getLocales(), await e.setLocale(this.locale ?? this.getBrowserLocale()), await e.setFallbackLocale(this.fallbackLocale);
710
+ }
711
+ translate(e, s) {
712
+ return this.provider.translate(e, s) ?? e;
713
+ }
714
+ translateWithDefault(e, s, n = {}) {
715
+ return this.provider.translateWithDefault(e, s, n);
716
+ }
717
+ getBrowserLocale() {
718
+ const e = this.getState("locales");
719
+ return navigator.languages.find((s) => e.includes(s)) ?? "en";
720
+ }
721
+ async boot() {
722
+ globalThis.document && this.requireStore().$subscribe(
723
+ async () => {
724
+ var e, s;
725
+ await this.provider.setLocale(this.locale ?? this.getBrowserLocale()), await this.provider.setFallbackLocale(this.fallbackLocale), this.locale ? (e = document.querySelector("html")) == null || e.setAttribute("lang", this.locale) : (s = document.querySelector("html")) == null || s.removeAttribute("lang");
726
+ },
727
+ { immediate: !0 }
728
+ );
729
+ }
730
+ }
731
+ const oe = J(kr), et = oe.translate.bind(oe), x = oe.translateWithDefault.bind(oe), Ar = be({
732
+ name: "errors",
733
+ initialState: {
734
+ logs: [],
735
+ startupErrors: []
736
+ },
737
+ computed: {
738
+ hasErrors: ({ logs: r }) => r.length > 0,
739
+ hasNewErrors: ({ logs: r }) => r.some((t) => !t.seen),
740
+ hasStartupErrors: ({ startupErrors: r }) => r.length > 0
741
+ }
742
+ }), C = {
743
+ Primary: "primary",
744
+ Secondary: "secondary",
745
+ Danger: "danger",
746
+ Clear: "clear"
747
+ };
748
+ class Cr extends Ar {
749
+ constructor() {
750
+ super(...arguments);
751
+ v(this, "forceReporting", !1);
752
+ v(this, "enabled", !0);
753
+ }
754
+ enable() {
755
+ this.enabled = !0;
756
+ }
757
+ disable() {
758
+ this.enabled = !1;
759
+ }
760
+ async inspect(e) {
761
+ const s = Array.isArray(e) ? e : [await this.createErrorReport(e)];
762
+ if (s.length === 0) {
763
+ G.alert(x("errors.inspectEmpty", "Nothing to inspect!"));
764
+ return;
765
+ }
766
+ G.openModal(G.requireComponent(M.ErrorReportModal), {
767
+ reports: s
768
+ });
769
+ }
770
+ async report(e, s) {
771
+ if (await S.emit("error", { error: e, message: s }), Ge("unit") || (X() && this.logError(e), !this.enabled))
772
+ throw e;
773
+ if (!F.isMounted()) {
774
+ const a = await this.createStartupErrorReport(e);
775
+ a && this.setState({ startupErrors: this.startupErrors.concat(a) });
776
+ return;
777
+ }
778
+ const n = await this.createErrorReport(e), o = {
779
+ report: n,
780
+ seen: !1,
781
+ date: /* @__PURE__ */ new Date()
782
+ };
783
+ G.showSnackbar(
784
+ s ?? x("errors.notice", "Something went wrong, but it's not your fault. Try again!"),
785
+ {
786
+ color: C.Danger,
787
+ actions: [
788
+ {
789
+ text: x("errors.viewDetails", "View details"),
790
+ dismiss: !0,
791
+ handler: () => G.openModal(
792
+ G.requireComponent(M.ErrorReportModal),
793
+ { reports: [n] }
794
+ )
795
+ }
796
+ ]
797
+ }
798
+ ), this.setState({ logs: [o].concat(this.logs) });
799
+ }
800
+ see(e) {
801
+ this.setState({
802
+ logs: this.logs.map((s) => s.report !== e ? s : {
803
+ ...s,
804
+ seen: !0
805
+ })
806
+ });
807
+ }
808
+ seeAll() {
809
+ this.setState({
810
+ logs: this.logs.map((e) => ({
811
+ ...e,
812
+ seen: !0
813
+ }))
814
+ });
815
+ }
816
+ logError(e) {
817
+ console.error(e), fe(e) && e.cause && this.logError(e.cause);
818
+ }
819
+ async createErrorReport(e) {
820
+ return typeof e == "string" ? { title: e } : e instanceof Error || e instanceof ve ? this.createErrorReportFromError(e) : fe(e) ? Oe({
821
+ title: V(
822
+ e.name ?? e.title ?? x("errors.unknown", "Unknown Error")
823
+ ),
824
+ description: V(
825
+ e.message ?? e.description ?? x("errors.unknownDescription", "Unknown error object")
826
+ ),
827
+ error: e
828
+ }) : {
829
+ title: x("errors.unknown", "Unknown Error"),
830
+ error: e
831
+ };
832
+ }
833
+ async createStartupErrorReport(e) {
834
+ return e instanceof Me ? e.cause instanceof Me ? null : this.createErrorReport(e.cause) : this.createErrorReport(e);
835
+ }
836
+ createErrorReportFromError(e, s = {}) {
837
+ return {
838
+ title: e.name,
839
+ description: e.message,
840
+ details: e.stack,
841
+ error: e,
842
+ ...s
843
+ };
844
+ }
845
+ }
846
+ const tt = J(Cr), rt = [];
847
+ function to(r) {
848
+ rt.push(r);
849
+ }
850
+ function Pr(r) {
851
+ for (const t of rt) {
852
+ const e = t(r);
853
+ if (e)
854
+ return e;
855
+ }
856
+ return typeof r == "string" ? r : r instanceof Error || r instanceof ve ? r.message : fe(r) ? V(r.message ?? r.description ?? "Unknown error object") : x("errors.unknown", "Unknown Error");
857
+ }
858
+ class qe extends ve {
859
+ }
860
+ const Mr = { $errors: tt }, Er = (r) => (tt.report(r), !0);
861
+ function Gr(r, t = () => !1) {
862
+ const e = (s) => t(s) || Er(s);
863
+ r.config.errorHandler = e, globalThis.onerror = (s, n, o, a, i) => e(i ?? s), globalThis.onunhandledrejection = (s) => e(s.reason);
864
+ }
865
+ const Lr = {
866
+ async install(r, t) {
867
+ Gr(r, t.handleError), await xe(r, Mr);
868
+ }
869
+ }, Hr = { $lang: oe }, Ir = {
870
+ async install(r) {
871
+ var t;
872
+ (t = r.config.globalProperties).$t ?? (t.$t = et), r.config.globalProperties.$td = x, await xe(r, Hr);
873
+ }
874
+ }, Tr = {
875
+ async install() {
876
+ Ge() && (globalThis.testingRuntime = {
877
+ on: (...r) => S.on(...r)
878
+ });
879
+ }
880
+ };
881
+ function te(r, t) {
882
+ const e = S.on(r, t);
883
+ he(() => e());
884
+ }
885
+ function Rr() {
886
+ const r = Be(), t = d(() => r.class);
887
+ return [d(() => Je(r, "class")), t];
888
+ }
889
+ function ro(r) {
890
+ let t = jt;
891
+ xt(() => t = r()), he(() => t());
892
+ }
893
+ function so(r, t) {
894
+ const e = ce(z.get(r) ?? t);
895
+ return Ee(e, () => z.set(r, St(e))), e;
896
+ }
897
+ function jr() {
898
+ return O(new je(), (r) => {
899
+ r.link = function(t) {
900
+ return je.prototype.link.apply(this, [t]).replace("<a", '<a target="_blank"');
901
+ };
902
+ });
903
+ }
904
+ function qr(r) {
905
+ const t = qt(r, /<a[^>]*href="#action:([^"]+)"[^>]*>([^<]+)<\/a>/g);
906
+ for (const [e, s, n] of t)
907
+ r = r.replace(e, `<button type="button" data-markdown-action="${s}">${n}</button>`);
908
+ return r;
909
+ }
910
+ function Dr(r) {
911
+ let t = rr(r, { renderer: jr(), async: !1 });
912
+ return t = Vr(t), t = qr(t), t;
913
+ }
914
+ function Vr(r) {
915
+ return tr.sanitize(r, { ADD_ATTR: ["target"] });
916
+ }
917
+ function no(r) {
918
+ return r.split(/\s+/).filter((t) => !/^(hover|focus|focus-visible):/.test(t)).join(" ").trim();
919
+ }
920
+ function Ie(r, t) {
921
+ return Object.keys(t).reduce(
922
+ (e, s) => (e[s] = r[s], e),
923
+ {}
924
+ );
925
+ }
926
+ const st = {
927
+ cancellable: re(!0),
928
+ inline: re(),
929
+ title: g()
930
+ };
931
+ function nt() {
932
+ return st;
933
+ }
934
+ function oo(r) {
935
+ return Ie(r, st);
936
+ }
937
+ function Br(r) {
938
+ return {
939
+ inline: d(() => {
940
+ var t;
941
+ return !!((t = r.value) != null && t.inline);
942
+ }),
943
+ cancellable: d(() => {
944
+ var t;
945
+ return !!((t = r.value) != null && t.cancellable);
946
+ }),
947
+ close: async () => {
948
+ var t;
949
+ return (t = r.value) == null ? void 0 : t.close();
950
+ }
951
+ };
952
+ }
953
+ const zr = /* @__PURE__ */ f({
954
+ __name: "AGHeadlessModal",
955
+ props: nt(),
956
+ setup(r, { expose: t }) {
957
+ const e = r, s = E(null), n = E(!0), o = E(!1), { modal: a } = H(
958
+ "modal",
959
+ "could not obtain modal reference from <AGHeadlessModal>, did you render this component manually? Show it using $ui.openModal() instead"
960
+ ), i = d(() => a.properties.inline ? "div" : Kt);
961
+ async function u() {
962
+ var y;
963
+ (y = s.value) != null && y.$el && (n.value = !0);
964
+ }
965
+ async function p() {
966
+ var y;
967
+ (y = s.value) != null && y.$el && (n.value = !1);
968
+ }
969
+ async function k(y) {
970
+ o.value || (S.emit("modal-will-close", { modal: a, result: y }), await u(), o.value = !0, S.emit("modal-closed", { modal: a, result: y }));
971
+ }
972
+ return te("close-modal", async ({ id: y, result: A }) => {
973
+ y === a.id && await k(A);
974
+ }), te("hide-modal", async ({ id: y }) => {
975
+ y === a.id && await u();
976
+ }), te("show-modal", async ({ id: y }) => {
977
+ y === a.id && await p();
978
+ }), t({ close: k, cancellable: ue(e, "cancellable"), inline: ue(e, "inline") }), (y, A) => (l(), _(j(i.value), {
979
+ ref_key: "$root",
980
+ ref: s,
981
+ open: !0,
982
+ onClose: A[0] || (A[0] = (Z) => y.cancellable && k())
983
+ }, {
984
+ default: m(() => [
985
+ $(y.$slots, "default", { close: k })
986
+ ]),
987
+ _: 3
988
+ }, 544));
989
+ }
990
+ }), ot = /* @__PURE__ */ f({
991
+ __name: "AGModalContext",
992
+ props: {
993
+ modal: $e(),
994
+ childIndex: se(0)
995
+ },
996
+ setup(r) {
997
+ const t = r, e = d(() => {
998
+ const s = {};
999
+ for (const n in t.modal.properties)
1000
+ s[n] = c(t.modal.properties[n]);
1001
+ return s;
1002
+ });
1003
+ return _e("modal", {
1004
+ modal: ue(t, "modal"),
1005
+ childIndex: ue(t, "childIndex")
1006
+ }), (s, n) => (l(), _(j(r.modal.component), ze(Fe(e.value)), null, 16));
1007
+ }
1008
+ }), Fr = /* @__PURE__ */ f({
1009
+ __name: "AGHeadlessModalPanel",
1010
+ setup(r) {
1011
+ const { modal: t, childIndex: e } = H(
1012
+ "modal",
1013
+ "could not obtain modal reference from <AGHeadlessModalPanel>, did you render this component manually? Show it using $ui.openModal() instead"
1014
+ ), s = d(() => t.properties.inline ? "div" : Ot), n = d(() => G.modals[e] ?? null);
1015
+ return (o, a) => (l(), _(j(s.value), null, {
1016
+ default: m(() => [
1017
+ $(o.$slots, "default"),
1018
+ n.value ? (l(), w(K, { key: 0 }, [
1019
+ b("div", {
1020
+ class: q(["pointer-events-none inset-0 z-50 bg-black/30", n.value.properties.inline ? "absolute" : "fixed"])
1021
+ }, null, 2),
1022
+ h(ot, {
1023
+ "child-index": c(e) + 1,
1024
+ modal: n.value
1025
+ }, null, 8, ["child-index", "modal"])
1026
+ ], 64)) : L("", !0)
1027
+ ]),
1028
+ _: 3
1029
+ }));
1030
+ }
1031
+ }), at = /* @__PURE__ */ f({
1032
+ __name: "AGHeadlessModalTitle",
1033
+ props: { as: g("h2") },
1034
+ setup(r) {
1035
+ const t = r, { modal: e } = H(
1036
+ "modal",
1037
+ "could not obtain modal reference from <AGHeadlessModalPanel>, did you render this component manually? Show it using $ui.openModal() instead"
1038
+ ), s = d(() => e.properties.inline ? "div" : Jt), n = d(() => e.properties.inline ? {} : { as: t.as });
1039
+ return (o, a) => (l(), _(j(s.value), ze(Fe(n.value)), {
1040
+ default: m(() => [
1041
+ $(o.$slots, "default")
1042
+ ]),
1043
+ _: 3
1044
+ }, 16));
1045
+ }
1046
+ }), I = /* @__PURE__ */ f({
1047
+ __name: "AGMarkdown",
1048
+ props: {
1049
+ as: g(),
1050
+ inline: re(),
1051
+ langKey: g(),
1052
+ langParams: we(),
1053
+ text: g(),
1054
+ actions: U()
1055
+ },
1056
+ setup(r) {
1057
+ const t = r, e = Be(), s = d(() => t.text ?? (t.langKey && et(t.langKey, t.langParams ?? {}))), n = d(() => {
1058
+ if (!s.value)
1059
+ return null;
1060
+ let i = Dr(s.value);
1061
+ return t.inline && (i = i.replace("<p>", "<span>").replace("</p>", "</span>")), i;
1062
+ }), o = () => kt(t.as ?? (t.inline ? "span" : "div"), {
1063
+ innerHTML: n.value,
1064
+ onClick: a,
1065
+ ...e,
1066
+ class: `${e.class ?? ""} ${t.inline ? "" : "prose"}`
1067
+ });
1068
+ async function a(i) {
1069
+ var p, k;
1070
+ const { target: u } = i;
1071
+ if (Dt(u, HTMLElement) && u.dataset.markdownAction) {
1072
+ (k = (p = t.actions) == null ? void 0 : p[u.dataset.markdownAction]) == null || k.call(p);
1073
+ return;
1074
+ }
1075
+ }
1076
+ return (i, u) => (l(), _(o));
1077
+ }
1078
+ }), Ur = { class: "fixed inset-0 flex items-center justify-center p-8" }, ie = /* @__PURE__ */ f({
1079
+ inheritAttrs: !1,
1080
+ __name: "AGModal",
1081
+ props: nt(),
1082
+ setup(r, { expose: t }) {
1083
+ const e = r, s = E();
1084
+ return t(Br(s)), (n, o) => (l(), _(zr, T({
1085
+ ref_key: "$modal",
1086
+ ref: s
1087
+ }, e, { class: "relative z-50" }), {
1088
+ default: m(({ close: a }) => [
1089
+ b("div", Ur, [
1090
+ h(Fr, { class: "flex max-h-full max-w-full flex-col overflow-hidden bg-white p-4" }, {
1091
+ default: m(() => [
1092
+ n.title ? (l(), _(at, {
1093
+ key: 0,
1094
+ class: "mb-2 text-lg font-semibold"
1095
+ }, {
1096
+ default: m(() => [
1097
+ h(I, {
1098
+ text: n.title,
1099
+ inline: ""
1100
+ }, null, 8, ["text"])
1101
+ ]),
1102
+ _: 1
1103
+ })) : L("", !0),
1104
+ b("div", T({ class: "flex max-h-full flex-col overflow-auto" }, n.$attrs), [
1105
+ $(n.$slots, "default", { close: a })
1106
+ ], 16)
1107
+ ]),
1108
+ _: 2
1109
+ }, 1024)
1110
+ ])
1111
+ ]),
1112
+ _: 3
1113
+ }, 16));
1114
+ }
1115
+ }), Nr = {
1116
+ title: g(),
1117
+ message: ne()
1118
+ };
1119
+ function Wr() {
1120
+ return Nr;
1121
+ }
1122
+ const Kr = /* @__PURE__ */ f({
1123
+ __name: "AGAlertModal",
1124
+ props: Wr(),
1125
+ setup(r) {
1126
+ return (t, e) => (l(), _(ie, { title: t.title }, {
1127
+ default: m(() => [
1128
+ h(I, { text: t.message }, null, 8, ["text"])
1129
+ ]),
1130
+ _: 1
1131
+ }, 8, ["title"]));
1132
+ }
1133
+ }), Or = {
1134
+ title: g(),
1135
+ message: ne(),
1136
+ acceptText: g(),
1137
+ acceptColor: Y(C, C.Primary),
1138
+ cancelText: g(),
1139
+ cancelColor: Y(C, C.Clear),
1140
+ checkboxes: U(),
1141
+ actions: U(),
1142
+ required: re(!1)
1143
+ };
1144
+ function Jr() {
1145
+ return Or;
1146
+ }
1147
+ function Qr(r) {
1148
+ const t = d(() => r.acceptText ?? x("ui.accept", "Ok")), e = d(() => r.cancelText ?? x("ui.cancel", "Cancel"));
1149
+ return { renderedAcceptText: t, renderedCancelText: e };
1150
+ }
1151
+ function Xr(r) {
1152
+ if (r instanceof HTMLElement)
1153
+ return r;
1154
+ if (Yr(r))
1155
+ return r.$el;
1156
+ }
1157
+ function Yr(r) {
1158
+ return fe(r) && "$el" in r;
1159
+ }
1160
+ function Zr() {
1161
+ return At((r, t) => {
1162
+ let e;
1163
+ return {
1164
+ get() {
1165
+ return r(), e;
1166
+ },
1167
+ set(s) {
1168
+ e = Xr(s), t();
1169
+ }
1170
+ };
1171
+ });
1172
+ }
1173
+ const it = /* @__PURE__ */ f({
1174
+ __name: "AGHeadlessButton",
1175
+ props: {
1176
+ as: U(),
1177
+ href: g(),
1178
+ url: g(),
1179
+ route: g(),
1180
+ routeParams: U(() => ({})),
1181
+ routeQuery: U(() => ({})),
1182
+ submit: re()
1183
+ },
1184
+ setup(r, { expose: t }) {
1185
+ const e = r, s = Zr(), n = d(() => e.as ? { as: e.as, props: {} } : e.route ? {
1186
+ as: "router-link",
1187
+ props: {
1188
+ to: Oe({
1189
+ name: e.route,
1190
+ params: e.routeParams,
1191
+ query: e.routeQuery
1192
+ })
1193
+ }
1194
+ } : e.href || e.url ? {
1195
+ as: "a",
1196
+ props: {
1197
+ target: "_blank",
1198
+ href: e.href || e.url
1199
+ }
1200
+ } : {
1201
+ as: "button",
1202
+ props: { type: e.submit ? "submit" : "button" }
1203
+ });
1204
+ return t({ $el: s }), (o, a) => (l(), _(j(n.value.as), T({
1205
+ ref_key: "$root",
1206
+ ref: s
1207
+ }, n.value.props), {
1208
+ default: m(() => [
1209
+ $(o.$slots, "default")
1210
+ ]),
1211
+ _: 3
1212
+ }, 16));
1213
+ }
1214
+ }), R = /* @__PURE__ */ f({
1215
+ __name: "AGButton",
1216
+ props: {
1217
+ color: Y(C, C.Primary)
1218
+ },
1219
+ setup(r) {
1220
+ const t = r, e = d(() => {
1221
+ switch (t.color) {
1222
+ case C.Secondary:
1223
+ return [
1224
+ "text-white bg-gray-600",
1225
+ "hover:bg-gray-500",
1226
+ "focus-visible:outline-offset-2 focus-visible:outline-gray-600"
1227
+ ].join(" ");
1228
+ case C.Clear:
1229
+ return "hover:bg-gray-500/20 focus-visible:outline-gray-500/60";
1230
+ case C.Danger:
1231
+ return [
1232
+ "text-white bg-red-600",
1233
+ "hover:bg-red-500",
1234
+ "focus-visible:outline-offset-2 focus-visible:outline-red-600"
1235
+ ].join(" ");
1236
+ case C.Primary:
1237
+ default:
1238
+ return [
1239
+ "text-white bg-indigo-600",
1240
+ "hover:bg-indigo-500",
1241
+ "focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
1242
+ ].join(" ");
1243
+ }
1244
+ });
1245
+ return (s, n) => (l(), _(it, {
1246
+ class: q(["px-2.5 py-1.5 focus-visible:outline focus-visible:outline-2", e.value])
1247
+ }, {
1248
+ default: m(() => [
1249
+ $(s.$slots, "default")
1250
+ ]),
1251
+ _: 3
1252
+ }, 8, ["class"]));
1253
+ }
1254
+ }), es = { class: "mt-2 flex flex-row-reverse gap-2" }, ts = /* @__PURE__ */ f({
1255
+ __name: "AGConfirmModal",
1256
+ props: Jr(),
1257
+ setup(r) {
1258
+ const t = r, { renderedAcceptText: e, renderedCancelText: s } = Qr(t);
1259
+ return (n, o) => (l(), _(ie, {
1260
+ cancellable: !1,
1261
+ title: n.title
1262
+ }, {
1263
+ default: m(({ close: a }) => [
1264
+ h(I, {
1265
+ text: n.message,
1266
+ actions: n.actions
1267
+ }, null, 8, ["text", "actions"]),
1268
+ b("div", es, [
1269
+ h(R, {
1270
+ color: n.acceptColor,
1271
+ onClick: (i) => a(!0)
1272
+ }, {
1273
+ default: m(() => [
1274
+ D(P(c(e)), 1)
1275
+ ]),
1276
+ _: 2
1277
+ }, 1032, ["color", "onClick"]),
1278
+ n.required ? L("", !0) : (l(), _(R, {
1279
+ key: 0,
1280
+ color: n.cancelColor,
1281
+ onClick: (i) => a()
1282
+ }, {
1283
+ default: m(() => [
1284
+ D(P(c(s)), 1)
1285
+ ]),
1286
+ _: 2
1287
+ }, 1032, ["color", "onClick"]))
1288
+ ])
1289
+ ]),
1290
+ _: 1
1291
+ }, 8, ["title"]));
1292
+ }
1293
+ }), rs = {
1294
+ viewBox: "0 0 20 20",
1295
+ width: "1.2em",
1296
+ height: "1.2em"
1297
+ };
1298
+ function ss(r, t) {
1299
+ return l(), w("svg", rs, t[0] || (t[0] = [
1300
+ b("path", {
1301
+ fill: "currentColor",
1302
+ d: "m12.95 10.707l.707-.707L8 4.343L6.586 5.757L10.828 10l-4.242 4.243L8 15.657z"
1303
+ }, null, -1)
1304
+ ]));
1305
+ }
1306
+ const ns = { name: "zondicons-cheveron-right", render: ss }, os = {
1307
+ viewBox: "0 0 20 20",
1308
+ width: "1.2em",
1309
+ height: "1.2em"
1310
+ };
1311
+ function as(r, t) {
1312
+ return l(), w("svg", os, t[0] || (t[0] = [
1313
+ b("path", {
1314
+ fill: "currentColor",
1315
+ d: "M7.05 9.293L6.343 10L12 15.657l1.414-1.414L9.172 10l4.242-4.243L12 4.343z"
1316
+ }, null, -1)
1317
+ ]));
1318
+ }
1319
+ const is = { name: "zondicons-cheveron-left", render: as }, ls = {
1320
+ reports: Xe()
1321
+ };
1322
+ function cs() {
1323
+ return ls;
1324
+ }
1325
+ function us(r) {
1326
+ const t = E(0), e = d(() => r.reports[t.value]), s = d(
1327
+ () => {
1328
+ var a;
1329
+ return ((a = e.value.details) == null ? void 0 : a.trim()) || x("errors.detailsEmpty", "This error is missing a stacktrace.");
1330
+ }
1331
+ ), n = x("errors.previousReport", "Show previous report"), o = x("errors.nextReport", "Show next report");
1332
+ return {
1333
+ activeReportIndex: t,
1334
+ details: s,
1335
+ nextReportText: o,
1336
+ previousReportText: n,
1337
+ report: e
1338
+ };
1339
+ }
1340
+ const ds = {
1341
+ viewBox: "0 0 24 24",
1342
+ width: "1.2em",
1343
+ height: "1.2em"
1344
+ };
1345
+ function ps(r, t) {
1346
+ return l(), w("svg", ds, t[0] || (t[0] = [
1347
+ b("path", {
1348
+ fill: "currentColor",
1349
+ d: "M20 19V7H4v12zm0-16a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm-7 14v-2h5v2zm-3.42-4L5.57 9H8.4l3.3 3.3c.39.39.39 1.03 0 1.42L8.42 17H5.59z"
1350
+ }, null, -1)
1351
+ ]));
1352
+ }
1353
+ const fs = { name: "mdi-console", render: ps }, ms = {
1354
+ viewBox: "0 0 20 20",
1355
+ width: "1.2em",
1356
+ height: "1.2em"
1357
+ };
1358
+ function hs(r, t) {
1359
+ return l(), w("svg", ms, t[0] || (t[0] = [
1360
+ b("path", {
1361
+ fill: "currentColor",
1362
+ d: "M6 6V2c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-4v4a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V8c0-1.1.9-2 2-2zm2 0h4a2 2 0 0 1 2 2v4h4V2H8zM2 8v10h10V8z"
1363
+ }, null, -1)
1364
+ ]));
1365
+ }
1366
+ const _s = { name: "zondicons-copy", render: hs }, gs = {
1367
+ viewBox: "0 0 24 24",
1368
+ width: "1.2em",
1369
+ height: "1.2em"
1370
+ };
1371
+ function vs(r, t) {
1372
+ return l(), w("svg", gs, t[0] || (t[0] = [
1373
+ b("path", {
1374
+ fill: "currentColor",
1375
+ d: "M12 2A10 10 0 0 0 2 12c0 4.42 2.87 8.17 6.84 9.5c.5.08.66-.23.66-.5v-1.69c-2.77.6-3.36-1.34-3.36-1.34c-.46-1.16-1.11-1.47-1.11-1.47c-.91-.62.07-.6.07-.6c1 .07 1.53 1.03 1.53 1.03c.87 1.52 2.34 1.07 2.91.83c.09-.65.35-1.09.63-1.34c-2.22-.25-4.55-1.11-4.55-4.92c0-1.11.38-2 1.03-2.71c-.1-.25-.45-1.29.1-2.64c0 0 .84-.27 2.75 1.02c.79-.22 1.65-.33 2.5-.33s1.71.11 2.5.33c1.91-1.29 2.75-1.02 2.75-1.02c.55 1.35.2 2.39.1 2.64c.65.71 1.03 1.6 1.03 2.71c0 3.82-2.34 4.66-4.57 4.91c.36.31.69.92.69 1.85V21c0 .27.16.59.67.5C19.14 20.16 22 16.42 22 12A10 10 0 0 0 12 2"
1376
+ }, null, -1)
1377
+ ]));
1378
+ }
1379
+ const bs = { name: "mdi-github", render: vs }, ys = { class: "flex" }, ws = /* @__PURE__ */ f({
1380
+ __name: "AGErrorReportModalButtons",
1381
+ props: {
1382
+ report: $e()
1383
+ },
1384
+ setup(r) {
1385
+ const t = r, e = d(() => t.report.description ? `${t.report.title}: ${t.report.description}` : t.report.title), s = d(() => {
1386
+ if (!F.sourceUrl)
1387
+ return !1;
1388
+ const o = encodeURIComponent(e.value), a = encodeURIComponent(
1389
+ [
1390
+ "[Please, explain here what you were trying to do when this error appeared]",
1391
+ "",
1392
+ "Error details:",
1393
+ "```",
1394
+ Vt(
1395
+ t.report.details ?? "Details missing from report",
1396
+ 1800 - o.length - F.sourceUrl.length
1397
+ ).trim(),
1398
+ "```"
1399
+ ].join(`
1400
+ `)
1401
+ );
1402
+ return `${F.sourceUrl}/issues/new?title=${o}&body=${a}`;
1403
+ }), n = d(() => O(
1404
+ [
1405
+ {
1406
+ id: "clipboard",
1407
+ description: "Copy to clipboard",
1408
+ iconComponent: _s,
1409
+ async handler() {
1410
+ await navigator.clipboard.writeText(`${e.value}
1411
+
1412
+ ${t.report.details}`), G.showSnackbar(
1413
+ x("errors.copiedToClipboard", "Debug information copied to clipboard")
1414
+ );
1415
+ }
1416
+ },
1417
+ {
1418
+ id: "console",
1419
+ description: "Log to console",
1420
+ iconComponent: fs,
1421
+ handler() {
1422
+ const o = t.report.error ?? t.report;
1423
+ window.error = o, console.error(o), G.showSnackbar(
1424
+ x(
1425
+ "errors.addedToConsole",
1426
+ "You can now use the **error** variable in the console"
1427
+ )
1428
+ );
1429
+ }
1430
+ }
1431
+ ],
1432
+ (o) => {
1433
+ s.value && o.push({
1434
+ id: "github",
1435
+ description: "Report in GitHub",
1436
+ iconComponent: bs,
1437
+ url: s.value
1438
+ });
1439
+ }
1440
+ ));
1441
+ return (o, a) => (l(), w("div", ys, [
1442
+ (l(!0), w(K, null, ge(n.value, (i, u) => $(o.$slots, "default", T({ ref_for: !0 }, i, { key: u }), () => [
1443
+ h(R, {
1444
+ color: "clear",
1445
+ url: i.url,
1446
+ title: o.$td(`errors.report_${i.id}`, i.description),
1447
+ "aria-label": o.$td(`errors.report_${i.id}`, i.description),
1448
+ onClick: i.handler
1449
+ }, {
1450
+ default: m(() => [
1451
+ (l(), _(j(i.iconComponent), {
1452
+ class: "h-4 w-4",
1453
+ "aria-hidden": "true"
1454
+ }))
1455
+ ]),
1456
+ _: 2
1457
+ }, 1032, ["url", "title", "aria-label", "onClick"])
1458
+ ])), 128))
1459
+ ]));
1460
+ }
1461
+ }), $s = /* @__PURE__ */ f({
1462
+ __name: "AGErrorReportModalTitle",
1463
+ props: {
1464
+ report: $e(),
1465
+ currentReport: se(),
1466
+ totalReports: se()
1467
+ },
1468
+ setup(r) {
1469
+ const t = r, e = d(() => !t.totalReports || t.totalReports <= 1 ? t.report.title : `${t.report.title} (${t.currentReport}/${t.totalReports})`);
1470
+ return (s, n) => (l(), _(I, {
1471
+ text: e.value,
1472
+ inline: ""
1473
+ }, null, 8, ["text"]));
1474
+ }
1475
+ }), xs = { class: "flex items-center justify-between text-lg font-medium" }, Ss = { class: "flex items-center" }, ks = ["textContent"], As = /* @__PURE__ */ f({
1476
+ __name: "AGErrorReportModal",
1477
+ props: cs(),
1478
+ setup(r) {
1479
+ const t = r, { activeReportIndex: e, details: s, nextReportText: n, previousReportText: o, report: a } = us(t);
1480
+ return (i, u) => (l(), _(ie, null, {
1481
+ default: m(() => [
1482
+ b("div", null, [
1483
+ b("h2", xs, [
1484
+ b("div", Ss, [
1485
+ h($s, {
1486
+ report: c(a),
1487
+ "current-report": c(e) + 1,
1488
+ "total-reports": i.reports.length
1489
+ }, null, 8, ["report", "current-report", "total-reports"]),
1490
+ i.reports.length > 1 ? (l(), w(K, { key: 0 }, [
1491
+ h(R, {
1492
+ color: "clear",
1493
+ disabled: c(e) === 0,
1494
+ title: c(o),
1495
+ "aria-label": c(o),
1496
+ onClick: u[0] || (u[0] = (p) => e.value--)
1497
+ }, {
1498
+ default: m(() => [
1499
+ h(c(is), {
1500
+ "aria-hidden": "true",
1501
+ class: "h-4 w-4"
1502
+ })
1503
+ ]),
1504
+ _: 1
1505
+ }, 8, ["disabled", "title", "aria-label"]),
1506
+ h(R, {
1507
+ color: "clear",
1508
+ disabled: c(e) === i.reports.length - 1,
1509
+ title: c(n),
1510
+ "aria-label": c(n),
1511
+ onClick: u[1] || (u[1] = (p) => e.value++)
1512
+ }, {
1513
+ default: m(() => [
1514
+ h(c(ns), {
1515
+ "aria-hidden": "true",
1516
+ class: "h-4 w-4"
1517
+ })
1518
+ ]),
1519
+ _: 1
1520
+ }, 8, ["disabled", "title", "aria-label"])
1521
+ ], 64)) : L("", !0)
1522
+ ]),
1523
+ h(ws, { report: c(a) }, null, 8, ["report"])
1524
+ ]),
1525
+ c(a).description ? (l(), _(I, {
1526
+ key: 0,
1527
+ text: c(a).description,
1528
+ class: "mt-2"
1529
+ }, null, 8, ["text"])) : L("", !0)
1530
+ ]),
1531
+ b("pre", {
1532
+ class: "h-full overflow-auto bg-gray-200 p-4 text-xs text-red-900",
1533
+ textContent: P(c(s))
1534
+ }, null, 8, ks)
1535
+ ]),
1536
+ _: 1
1537
+ }));
1538
+ }
1539
+ }), Cs = {
1540
+ title: g(),
1541
+ message: g(),
1542
+ progress: se()
1543
+ };
1544
+ function Ps() {
1545
+ return Cs;
1546
+ }
1547
+ function Ms(r) {
1548
+ const t = d(() => r.message ?? x("ui.loading", "Loading...")), e = d(() => typeof r.progress == "number");
1549
+ return { renderedMessage: t, showProgress: e };
1550
+ }
1551
+ const Es = /* @__PURE__ */ f({
1552
+ __name: "AGLoadingModal",
1553
+ props: Ps(),
1554
+ setup(r) {
1555
+ const t = r, { renderedMessage: e } = Ms(t);
1556
+ return (s, n) => (l(), _(ie, { cancellable: !1 }, {
1557
+ default: m(() => [
1558
+ h(I, { text: c(e) }, null, 8, ["text"])
1559
+ ]),
1560
+ _: 1
1561
+ }));
1562
+ }
1563
+ }), Gs = {
1564
+ title: g(),
1565
+ message: ne(),
1566
+ label: g(),
1567
+ defaultValue: g(),
1568
+ placeholder: g(),
1569
+ acceptText: g(),
1570
+ acceptColor: Y(C, C.Primary),
1571
+ cancelText: g(),
1572
+ cancelColor: Y(C, C.Clear)
1573
+ };
1574
+ function Ls() {
1575
+ return Gs;
1576
+ }
1577
+ function Hs(r) {
1578
+ const t = d(() => r.acceptText ?? x("ui.accept", "Ok")), e = d(() => r.cancelText ?? x("ui.cancel", "Cancel"));
1579
+ return { renderedAcceptText: t, renderedCancelText: e };
1580
+ }
1581
+ const Is = /* @__PURE__ */ f({
1582
+ __name: "AGForm",
1583
+ props: { form: U() },
1584
+ emits: ["submit"],
1585
+ setup(r, { emit: t }) {
1586
+ let e;
1587
+ const s = r, n = t;
1588
+ return de((o) => {
1589
+ var a;
1590
+ e == null || e(), e = (a = s.form) == null ? void 0 : a.on("submit", () => n("submit")), o(() => e == null ? void 0 : e());
1591
+ }), _e("form", s.form), (o, a) => (l(), w("form", {
1592
+ onSubmit: a[0] || (a[0] = Ct((i) => {
1593
+ var u;
1594
+ return (u = r.form) == null ? void 0 : u.submit();
1595
+ }, ["prevent"]))
1596
+ }, [
1597
+ $(o.$slots, "default")
1598
+ ], 32));
1599
+ }
1600
+ }), lt = {
1601
+ name: g(),
1602
+ label: g(),
1603
+ description: g(),
1604
+ modelValue: we([String, Number, Boolean])
1605
+ }, Ts = ["update:modelValue"];
1606
+ function ct() {
1607
+ return [...Ts];
1608
+ }
1609
+ function ut() {
1610
+ return lt;
1611
+ }
1612
+ function ao(r) {
1613
+ return Ie(r, lt);
1614
+ }
1615
+ const dt = /* @__PURE__ */ f({
1616
+ __name: "AGHeadlessInput",
1617
+ props: {
1618
+ as: g("div"),
1619
+ ...ut()
1620
+ },
1621
+ emits: ["update:modelValue"],
1622
+ setup(r, { expose: t, emit: e }) {
1623
+ const s = e, n = r, o = E(), a = d(() => !i || !n.name ? null : i.errors[n.name] ?? null), i = ae("form", null), u = {
1624
+ $el: o,
1625
+ id: `input-${pe()}`,
1626
+ name: d(() => n.name),
1627
+ label: d(() => n.label),
1628
+ description: d(() => n.description),
1629
+ value: d(() => i && n.name ? i.getFieldValue(n.name) : n.modelValue),
1630
+ errors: Ue(a),
1631
+ required: d(() => !n.name || !i ? null : i.getFieldRules(n.name).includes("required")),
1632
+ update(p) {
1633
+ if (i && n.name) {
1634
+ i.setFieldValue(n.name, p);
1635
+ return;
1636
+ }
1637
+ s("update:modelValue", p);
1638
+ },
1639
+ __setElement(p) {
1640
+ o.value = p;
1641
+ }
1642
+ };
1643
+ return _e("input", u), t(u), (p, k) => r.as ? (l(), _(j(r.as), { key: 0 }, {
1644
+ default: m(() => [
1645
+ $(p.$slots, "default")
1646
+ ]),
1647
+ _: 3
1648
+ })) : $(p.$slots, "default", { key: 1 });
1649
+ }
1650
+ }), Rs = /* @__PURE__ */ f({
1651
+ inheritAttrs: !1,
1652
+ __name: "AGHeadlessInputDescription",
1653
+ setup(r) {
1654
+ const t = H(
1655
+ "input",
1656
+ "<AGHeadlessInputDescription> must be a child of a <AGHeadlessInput>"
1657
+ ), e = d(() => typeof t.description == "string" ? t.description : ""), s = d(() => !!t.description);
1658
+ return (n, o) => $(n.$slots, "default", {
1659
+ id: `${c(t).id}-description`
1660
+ }, () => [
1661
+ s.value ? (l(), _(I, T({ key: 0 }, n.$attrs, {
1662
+ id: `${c(t).id}-description`,
1663
+ text: e.value
1664
+ }), null, 16, ["id", "text"])) : L("", !0)
1665
+ ]);
1666
+ }
1667
+ }), js = ["id"], pt = /* @__PURE__ */ f({
1668
+ __name: "AGHeadlessInputError",
1669
+ setup(r) {
1670
+ const t = H(
1671
+ "input",
1672
+ "<AGHeadlessInputError> must be a child of a <AGHeadlessInput>"
1673
+ ), e = d(() => t.errors ? x(`errors.${t.errors[0]}`, `Error: ${t.errors[0]}`) : null);
1674
+ return (s, n) => e.value ? (l(), w("p", {
1675
+ key: 0,
1676
+ id: `${c(t).id}-error`
1677
+ }, P(e.value), 9, js)) : L("", !0);
1678
+ }
1679
+ });
1680
+ function ft(r, t) {
1681
+ const e = ae("form", null), s = e == null ? void 0 : e.on("focus", (n) => r.name === n && t());
1682
+ he(() => s == null ? void 0 : s());
1683
+ }
1684
+ const qs = ["id", "name", "type", "required", "aria-invalid", "aria-describedby", "checked"], mt = /* @__PURE__ */ f({
1685
+ __name: "AGHeadlessInputInput",
1686
+ props: {
1687
+ type: g("text")
1688
+ },
1689
+ setup(r) {
1690
+ const t = r, e = E(), s = H(
1691
+ "input",
1692
+ "<AGHeadlessInputInput> must be a child of a <AGHeadlessInput>"
1693
+ ), n = d(() => s.name ?? void 0), o = d(() => s.value), a = d(() => {
1694
+ if (t.type === "checkbox")
1695
+ return !!o.value;
1696
+ });
1697
+ function i() {
1698
+ e.value && s.update(u());
1699
+ }
1700
+ function u() {
1701
+ if (!e.value)
1702
+ return null;
1703
+ switch (t.type) {
1704
+ case "checkbox":
1705
+ return e.value.checked;
1706
+ case "date":
1707
+ return e.value.valueAsDate;
1708
+ default:
1709
+ return e.value.value;
1710
+ }
1711
+ }
1712
+ return ft(s, () => {
1713
+ var p;
1714
+ return (p = e.value) == null ? void 0 : p.focus();
1715
+ }), de(() => s.__setElement(e.value)), de(() => {
1716
+ if (e.value) {
1717
+ if (t.type === "date") {
1718
+ e.value.valueAsDate = o.value;
1719
+ return;
1720
+ }
1721
+ e.value.value = o.value;
1722
+ }
1723
+ }), (p, k) => (l(), w("input", {
1724
+ id: c(s).id,
1725
+ ref_key: "$input",
1726
+ ref: e,
1727
+ name: n.value,
1728
+ type: r.type,
1729
+ required: c(s).required ?? void 0,
1730
+ "aria-invalid": c(s).errors ? "true" : "false",
1731
+ "aria-describedby": c(s).errors ? `${c(s).id}-error` : c(s).description ? `${c(s).id}-description` : void 0,
1732
+ checked: a.value,
1733
+ onInput: i
1734
+ }, null, 40, qs));
1735
+ }
1736
+ }), Ds = ["for"], ht = /* @__PURE__ */ f({
1737
+ __name: "AGHeadlessInputLabel",
1738
+ setup(r) {
1739
+ const t = H(
1740
+ "input",
1741
+ "<AGHeadlessInputLabel> must be a child of a <AGHeadlessInput>"
1742
+ ), e = Ne(), s = d(() => !!(t.label || e.default));
1743
+ return (n, o) => s.value ? (l(), w("label", {
1744
+ key: 0,
1745
+ for: c(t).id
1746
+ }, [
1747
+ $(n.$slots, "default", {}, () => [
1748
+ D(P(c(t).label), 1)
1749
+ ])
1750
+ ], 8, Ds)) : L("", !0);
1751
+ }
1752
+ }), Vs = { class: "absolute bottom-0 left-0 translate-y-full" }, Bs = /* @__PURE__ */ f({
1753
+ inheritAttrs: !1,
1754
+ __name: "AGInput",
1755
+ props: ut(),
1756
+ emits: ct(),
1757
+ setup(r) {
1758
+ const t = r, e = He(), [s, n] = Rr();
1759
+ return (o, a) => (l(), _(dt, T({
1760
+ ref_key: "$input",
1761
+ ref: e,
1762
+ class: ["relative flex flex-col items-center", c(n)]
1763
+ }, t, {
1764
+ "onUpdate:modelValue": a[0] || (a[0] = (i) => o.$emit("update:modelValue", i))
1765
+ }), {
1766
+ default: m(() => {
1767
+ var i;
1768
+ return [
1769
+ h(ht, { class: "sr-only" }),
1770
+ h(mt, T(c(s), {
1771
+ class: ["block w-full border-0 py-1.5 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600", {
1772
+ "ring-1 ring-red-500": (i = c(e)) == null ? void 0 : i.errors
1773
+ }]
1774
+ }), null, 16, ["class"]),
1775
+ h(Rs),
1776
+ b("div", Vs, [
1777
+ h(pt, { class: "mt-1 text-sm text-red-500" })
1778
+ ])
1779
+ ];
1780
+ }),
1781
+ _: 1
1782
+ }, 16, ["class"]));
1783
+ }
1784
+ }), zs = {
1785
+ required: (r) => r ? void 0 : "required"
1786
+ }, le = { ...zs };
1787
+ function io(r, t) {
1788
+ le[r] = t;
1789
+ }
1790
+ function Fs(r, t) {
1791
+ var s;
1792
+ const e = (s = le[t]) == null ? void 0 : s.call(le, r);
1793
+ return e ? Ke(e) : [];
1794
+ }
1795
+ const B = {
1796
+ String: "string",
1797
+ Number: "number",
1798
+ Boolean: "boolean",
1799
+ Object: "object",
1800
+ Date: "date"
1801
+ }, De = /* @__PURE__ */ new WeakMap();
1802
+ class Us extends We {
1803
+ constructor(e) {
1804
+ super();
1805
+ v(this, "errors");
1806
+ v(this, "_fields");
1807
+ v(this, "_data");
1808
+ v(this, "_submitted");
1809
+ v(this, "_errors");
1810
+ v(this, "_listeners", {});
1811
+ this._fields = e, this._submitted = E(!1), this._data = this.getInitialData(e), this._errors = this.getInitialErrors(e), De.set(
1812
+ this,
1813
+ d(() => !Object.values(this._errors).some((s) => s !== null))
1814
+ ), this.errors = Ue(this._errors);
1815
+ }
1816
+ get valid() {
1817
+ var e;
1818
+ return !!((e = De.get(this)) != null && e.value);
1819
+ }
1820
+ get submitted() {
1821
+ return this._submitted.value;
1822
+ }
1823
+ setFieldValue(e, s) {
1824
+ const n = this._fields[e] ?? W(`Trying to set undefined '${V(e)}' field`);
1825
+ this._data[e] = n.type === B.String && (n.trim ?? !0) ? V(s).trim() : s, this._submitted.value && this.validate();
1826
+ }
1827
+ getFieldValue(e) {
1828
+ return this._data[e];
1829
+ }
1830
+ getFieldRules(e) {
1831
+ var s, n;
1832
+ return ((n = (s = this._fields[e]) == null ? void 0 : s.rules) == null ? void 0 : n.split("|")) ?? [];
1833
+ }
1834
+ data() {
1835
+ return { ...this._data };
1836
+ }
1837
+ validate() {
1838
+ const e = Object.entries(this._fields).reduce(
1839
+ (s, [n, o]) => (s[n] = this.getFieldErrors(n, o), s),
1840
+ {}
1841
+ );
1842
+ return this.resetErrors(e), this.valid;
1843
+ }
1844
+ reset(e = {}) {
1845
+ this._submitted.value = !1, e.keepData || this.resetData(), e.keepErrors || this.resetErrors();
1846
+ }
1847
+ submit() {
1848
+ var s;
1849
+ this._submitted.value = !0;
1850
+ const e = this.validate();
1851
+ return e && ((s = this._listeners.submit) == null || s.forEach((n) => n())), e;
1852
+ }
1853
+ on(e, s) {
1854
+ var n, o;
1855
+ return (n = this._listeners)[e] ?? (n[e] = []), (o = this._listeners[e]) == null || o.push(s), () => this.off(e, s);
1856
+ }
1857
+ off(e, s) {
1858
+ Pe(this._listeners[e] ?? [], s);
1859
+ }
1860
+ async focus(e) {
1861
+ var s;
1862
+ await Ve(), (s = this._listeners.focus) == null || s.forEach((n) => n(e));
1863
+ }
1864
+ __get(e) {
1865
+ return e in this._fields ? this.getFieldValue(e) : super.__get(e);
1866
+ }
1867
+ __set(e, s) {
1868
+ if (!(e in this._fields)) {
1869
+ super.__set(e, s);
1870
+ return;
1871
+ }
1872
+ this.setFieldValue(e, s);
1873
+ }
1874
+ getFieldErrors(e, s) {
1875
+ var i;
1876
+ const n = [], o = this._data[e], a = ((i = s.rules) == null ? void 0 : i.split("|")) ?? [];
1877
+ for (const u of a)
1878
+ u !== "required" && o == null || n.push(...Fs(o, u));
1879
+ return n.length > 0 ? n : null;
1880
+ }
1881
+ getInitialData(e) {
1882
+ if (this.static().isConjuring())
1883
+ return {};
1884
+ const s = Object.entries(e).reduce((n, [o, a]) => (n[o] = a.default ?? null, n), {});
1885
+ return ce(s);
1886
+ }
1887
+ getInitialErrors(e) {
1888
+ if (this.static().isConjuring())
1889
+ return {};
1890
+ const s = Object.keys(e).reduce((n, o) => (n[o] = null, n), {});
1891
+ return ce(s);
1892
+ }
1893
+ resetData() {
1894
+ for (const [e, s] of Object.entries(this._fields))
1895
+ this._data[e] = s.default ?? null;
1896
+ }
1897
+ resetErrors(e) {
1898
+ Object.keys(this._errors).forEach((s) => delete this._errors[s]), e && Object.assign(this._errors, e);
1899
+ }
1900
+ }
1901
+ function Ns(r) {
1902
+ return new Us(r);
1903
+ }
1904
+ function lo(r, t = {}) {
1905
+ return {
1906
+ default: r,
1907
+ type: B.Boolean,
1908
+ rules: t.rules
1909
+ };
1910
+ }
1911
+ function co(r, t = {}) {
1912
+ return {
1913
+ default: r,
1914
+ type: B.Date,
1915
+ rules: t.rules
1916
+ };
1917
+ }
1918
+ function uo(r) {
1919
+ return {
1920
+ default: r,
1921
+ type: B.Boolean,
1922
+ rules: "required"
1923
+ };
1924
+ }
1925
+ function po(r) {
1926
+ return {
1927
+ default: r,
1928
+ type: B.Date,
1929
+ rules: "required"
1930
+ };
1931
+ }
1932
+ function fo(r) {
1933
+ return {
1934
+ default: r,
1935
+ type: B.Number,
1936
+ rules: "required"
1937
+ };
1938
+ }
1939
+ function Ws(r) {
1940
+ return {
1941
+ default: r,
1942
+ type: B.String,
1943
+ rules: "required"
1944
+ };
1945
+ }
1946
+ function mo(r, t = {}) {
1947
+ return {
1948
+ default: r,
1949
+ type: B.Number,
1950
+ rules: t.rules
1951
+ };
1952
+ }
1953
+ function ho(r, t = {}) {
1954
+ return {
1955
+ default: r,
1956
+ type: B.String,
1957
+ rules: t.rules
1958
+ };
1959
+ }
1960
+ const Ks = { class: "mt-2 flex flex-row-reverse gap-2" }, Os = /* @__PURE__ */ f({
1961
+ __name: "AGPromptModal",
1962
+ props: Ls(),
1963
+ setup(r) {
1964
+ const t = r, e = Ns({ draft: Ws(t.defaultValue ?? "") }), { renderedAcceptText: s, renderedCancelText: n } = Hs(t);
1965
+ return (o, a) => (l(), _(ie, {
1966
+ cancellable: !1,
1967
+ title: o.title
1968
+ }, {
1969
+ default: m(({ close: i }) => [
1970
+ h(I, { text: o.message }, null, 8, ["text"]),
1971
+ h(Is, {
1972
+ form: c(e),
1973
+ onSubmit: (u) => i(c(e).draft)
1974
+ }, {
1975
+ default: m(() => [
1976
+ h(Bs, {
1977
+ name: "draft",
1978
+ placeholder: o.placeholder,
1979
+ label: o.label
1980
+ }, null, 8, ["placeholder", "label"]),
1981
+ b("div", Ks, [
1982
+ h(R, {
1983
+ color: o.acceptColor,
1984
+ submit: ""
1985
+ }, {
1986
+ default: m(() => [
1987
+ D(P(c(s)), 1)
1988
+ ]),
1989
+ _: 1
1990
+ }, 8, ["color"]),
1991
+ h(R, {
1992
+ color: o.cancelColor,
1993
+ onClick: (u) => i()
1994
+ }, {
1995
+ default: m(() => [
1996
+ D(P(c(n)), 1)
1997
+ ]),
1998
+ _: 2
1999
+ }, 1032, ["color", "onClick"])
2000
+ ])
2001
+ ]),
2002
+ _: 2
2003
+ }, 1032, ["form", "onSubmit"])
2004
+ ]),
2005
+ _: 1
2006
+ }, 8, ["title"]));
2007
+ }
2008
+ }), Js = { class: "pointer-events-auto" }, Qs = /* @__PURE__ */ f({
2009
+ __name: "AGHeadlessSnackbar",
2010
+ setup(r) {
2011
+ return (t, e) => (l(), w("div", Js, [
2012
+ $(t.$slots, "default")
2013
+ ]));
2014
+ }
2015
+ }), Xs = Je(C, ["Primary", "Clear"]), Ys = {
2016
+ id: ne(),
2017
+ message: ne(),
2018
+ actions: ur(() => []),
2019
+ color: Y(Xs, C.Secondary)
2020
+ };
2021
+ function Zs() {
2022
+ return Ys;
2023
+ }
2024
+ function en(r) {
2025
+ function t(e) {
2026
+ var s;
2027
+ (s = e.handler) == null || s.call(e), e.dismiss && G.hideSnackbar(r.id);
2028
+ }
2029
+ return { activate: t };
2030
+ }
2031
+ const tn = /* @__PURE__ */ f({
2032
+ __name: "AGSnackbar",
2033
+ props: Zs(),
2034
+ setup(r) {
2035
+ const t = r, { activate: e } = en(t), s = d(() => {
2036
+ switch (t.color) {
2037
+ case C.Danger:
2038
+ return "bg-red-200 text-red-900";
2039
+ default:
2040
+ case C.Secondary:
2041
+ return "bg-gray-900 text-white";
2042
+ }
2043
+ });
2044
+ return (n, o) => (l(), _(Qs, {
2045
+ class: q(["flex flex-row items-center justify-center gap-3 p-4", s.value])
2046
+ }, {
2047
+ default: m(() => [
2048
+ h(I, {
2049
+ text: n.message,
2050
+ inline: ""
2051
+ }, null, 8, ["text"]),
2052
+ (l(!0), w(K, null, ge(n.actions, (a, i) => (l(), _(R, {
2053
+ key: i,
2054
+ color: n.color,
2055
+ onClick: (u) => c(e)(a)
2056
+ }, {
2057
+ default: m(() => [
2058
+ D(P(a.text), 1)
2059
+ ]),
2060
+ _: 2
2061
+ }, 1032, ["color", "onClick"]))), 128))
2062
+ ]),
2063
+ _: 1
2064
+ }, 8, ["class"]));
2065
+ }
2066
+ }), rn = { class: "grid flex-grow place-items-center" }, sn = { class: "flex flex-col items-center space-y-6 p-8" }, nn = { class: "mt-2 text-center text-4xl font-medium text-red-600" }, on = { class: "mt-4 flex flex-col space-y-4" }, an = /* @__PURE__ */ f({
2067
+ __name: "AGStartupCrash",
2068
+ setup(r) {
2069
+ return (t, e) => (l(), w("div", rn, [
2070
+ b("div", sn, [
2071
+ b("h1", nn, P(t.$td("startupCrash.title", "Something went wrong!")), 1),
2072
+ h(I, {
2073
+ text: t.$td(
2074
+ "startupCrash.message",
2075
+ `Something failed trying to start the application.
2076
+
2077
+ Here's some things you can do:`
2078
+ ),
2079
+ class: "mt-4 text-center"
2080
+ }, null, 8, ["text"]),
2081
+ b("div", on, [
2082
+ h(R, {
2083
+ color: "danger",
2084
+ onClick: e[0] || (e[0] = (s) => t.$app.reload())
2085
+ }, {
2086
+ default: m(() => [
2087
+ D(P(t.$td("startupCrash.reload", "Try again")), 1)
2088
+ ]),
2089
+ _: 1
2090
+ }),
2091
+ h(R, {
2092
+ color: "danger",
2093
+ onClick: e[1] || (e[1] = (s) => t.$errors.inspect(t.$errors.startupErrors))
2094
+ }, {
2095
+ default: m(() => [
2096
+ D(P(t.$td("startupCrash.inspect", "View error details")), 1)
2097
+ ]),
2098
+ _: 1
2099
+ })
2100
+ ])
2101
+ ])
2102
+ ]));
2103
+ }
2104
+ }), ln = { $ui: G }, cn = {
2105
+ async install(r, t) {
2106
+ const e = {
2107
+ [M.AlertModal]: Kr,
2108
+ [M.ConfirmModal]: ts,
2109
+ [M.ErrorReportModal]: As,
2110
+ [M.LoadingModal]: Es,
2111
+ [M.PromptModal]: Os,
2112
+ [M.Snackbar]: tn,
2113
+ [M.StartupCrash]: an
2114
+ };
2115
+ Object.entries({
2116
+ ...e,
2117
+ ...t.components
2118
+ }).forEach(([s, n]) => G.registerComponent(s, n)), await xe(r, ln);
2119
+ }
2120
+ };
2121
+ async function un(r, t = {}) {
2122
+ var s;
2123
+ const e = [Tr, hr, Lr, Ir, yr, cn, ...t.plugins ?? []];
2124
+ F.instance = r, await cr(e, r, t), await ((s = t.install) == null ? void 0 : s.call(t, r)), await S.emit("application-ready");
2125
+ }
2126
+ async function _o(r, t = {}) {
2127
+ var s;
2128
+ const e = Pt(r);
2129
+ X() && (window.$aerogel = e), await un(e, t), e.mount("#app"), (s = e._container) == null || s.classList.remove("loading"), await S.emit("application-mounted");
2130
+ }
2131
+ const dn = { key: 0 }, pn = /* @__PURE__ */ f({
2132
+ __name: "AGAppModals",
2133
+ setup(r) {
2134
+ const t = d(() => G.modals[0] ?? null);
2135
+ return (e, s) => t.value ? (l(), w("aside", dn, [
2136
+ h(ot, {
2137
+ "child-index": 1,
2138
+ modal: t.value
2139
+ }, null, 8, ["modal"])
2140
+ ])) : L("", !0);
2141
+ }
2142
+ }), fn = (r, t) => {
2143
+ const e = r.__vccOpts || r;
2144
+ for (const [s, n] of t)
2145
+ e[s] = n;
2146
+ return e;
2147
+ }, mn = {}, hn = {
2148
+ "aria-live": "assertive",
2149
+ class: "pointer-events-none fixed inset-0 z-50 flex items-end px-4 py-6 sm:p-6"
2150
+ }, _n = { class: "flex w-full flex-col items-end space-y-4" };
2151
+ function gn(r, t) {
2152
+ return l(), w("div", hn, [
2153
+ b("div", _n, [
2154
+ (l(!0), w(K, null, ge(r.$ui.snackbars, (e) => (l(), _(j(e.component), T({
2155
+ id: e.id,
2156
+ key: e.id,
2157
+ ref_for: !0
2158
+ }, e.properties), null, 16, ["id"]))), 128))
2159
+ ])
2160
+ ]);
2161
+ }
2162
+ const vn = /* @__PURE__ */ fn(mn, [["render", gn]]), bn = /* @__PURE__ */ f({
2163
+ __name: "AGAppOverlays",
2164
+ setup(r) {
2165
+ const t = E(null), e = E(!0);
2166
+ return te("show-overlays-backdrop", async () => {
2167
+ !t.value || !e.value || (e.value = !1, t.value.classList.remove("opacity-0"));
2168
+ }), te("hide-overlays-backdrop", async () => {
2169
+ !t.value || e.value || (e.value = !0, t.value.classList.add("opacity-0"));
2170
+ }), (s, n) => (l(), w(K, null, [
2171
+ b("div", {
2172
+ id: "aerogel-overlays-backdrop",
2173
+ ref_key: "$backdrop",
2174
+ ref: t,
2175
+ class: "pointer-events-none fixed inset-0 z-50 bg-black/30 opacity-0"
2176
+ }, null, 512),
2177
+ h(pn),
2178
+ h(vn)
2179
+ ], 64));
2180
+ }
2181
+ }), yn = { class: "flex min-h-full flex-col text-base font-normal leading-tight text-gray-900 antialiased" }, go = /* @__PURE__ */ f({
2182
+ __name: "AGAppLayout",
2183
+ setup(r) {
2184
+ return (t, e) => (l(), w("div", yn, [
2185
+ t.$errors.hasStartupErrors ? $(t.$slots, "startup-crash", { key: 0 }, () => [
2186
+ (l(), _(j(t.$ui.requireComponent(c(M).StartupCrash))))
2187
+ ]) : $(t.$slots, "default", { key: 1 }),
2188
+ h(bn)
2189
+ ]));
2190
+ }
2191
+ }), wn = { class: "ml-2" }, vo = /* @__PURE__ */ f({
2192
+ inheritAttrs: !1,
2193
+ __name: "AGCheckbox",
2194
+ props: { name: g() },
2195
+ emits: ct(),
2196
+ setup(r) {
2197
+ const t = He();
2198
+ return (e, s) => (l(), _(dt, {
2199
+ ref_key: "$input",
2200
+ ref: t,
2201
+ name: r.name,
2202
+ class: "flex",
2203
+ "onUpdate:modelValue": s[0] || (s[0] = (n) => e.$emit("update:modelValue", n))
2204
+ }, {
2205
+ default: m(() => {
2206
+ var n, o;
2207
+ return [
2208
+ h(mt, T(e.$attrs, {
2209
+ type: "checkbox",
2210
+ class: {
2211
+ "text-indigo-600 focus:ring-indigo-600": !((n = c(t)) != null && n.errors),
2212
+ "border-red-200 text-red-600 focus:ring-red-600": (o = c(t)) == null ? void 0 : o.errors
2213
+ }
2214
+ }), null, 16, ["class"]),
2215
+ b("div", wn, [
2216
+ e.$slots.default ? (l(), _(ht, { key: 0 }, {
2217
+ default: m(() => [
2218
+ $(e.$slots, "default")
2219
+ ]),
2220
+ _: 3
2221
+ })) : L("", !0),
2222
+ h(pt, { class: "text-sm text-red-600" })
2223
+ ])
2224
+ ];
2225
+ }),
2226
+ _: 3
2227
+ }, 8, ["name"]));
2228
+ }
2229
+ }), $n = {
2230
+ viewBox: "0 0 20 20",
2231
+ width: "1.2em",
2232
+ height: "1.2em"
2233
+ };
2234
+ function xn(r, t) {
2235
+ return l(), w("svg", $n, t[0] || (t[0] = [
2236
+ b("path", {
2237
+ fill: "currentColor",
2238
+ d: "m9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828L5.757 6.586L4.343 8z"
2239
+ }, null, -1)
2240
+ ]));
2241
+ }
2242
+ const Sn = { name: "zondicons-cheveron-down", render: xn }, _t = {
2243
+ name: g(),
2244
+ label: g(),
2245
+ options: Xe(),
2246
+ noSelectionText: g(),
2247
+ optionsText: we()
2248
+ }, kn = ["update:modelValue"];
2249
+ function gt() {
2250
+ return _t;
2251
+ }
2252
+ function vt() {
2253
+ return [...kn];
2254
+ }
2255
+ function bo(r) {
2256
+ return Ie(r, _t);
2257
+ }
2258
+ const An = /* @__PURE__ */ f({
2259
+ __name: "AGHeadlessSelect",
2260
+ props: {
2261
+ modelValue: we(),
2262
+ ...gt()
2263
+ },
2264
+ emits: vt(),
2265
+ setup(r, { expose: t, emit: e }) {
2266
+ const s = e, n = r, o = d(() => typeof n.optionsText == "function" ? n.optionsText : typeof n.optionsText == "string" ? (A) => V(A[n.optionsText]) : (A) => V(A)), a = ae("form", null), i = d(() => n.noSelectionText ?? x("select.noSelection", "-")), u = d(() => a && n.name ? a.getFieldValue(n.name) : n.modelValue), p = d(() => !a || !n.name ? null : a.errors[n.name] ?? null);
2267
+ function k(A) {
2268
+ if (a && n.name) {
2269
+ a.setFieldValue(n.name, A);
2270
+ return;
2271
+ }
2272
+ s("update:modelValue", A);
2273
+ }
2274
+ const y = {
2275
+ id: `select-${pe()}`,
2276
+ noSelectionText: i,
2277
+ selectedOption: u,
2278
+ errors: p,
2279
+ options: d(() => n.options),
2280
+ label: d(() => n.label),
2281
+ buttonText: d(() => u.value === null ? i.value : o.value(u.value)),
2282
+ renderText: o,
2283
+ update: k
2284
+ };
2285
+ return _e("select", y), t(y), (A, Z) => (l(), _(c(Qt), {
2286
+ "model-value": u.value,
2287
+ "onUpdate:modelValue": Z[0] || (Z[0] = (Se) => k(Se))
2288
+ }, {
2289
+ default: m(({ value: Se, open: bt, disabled: yt }) => [
2290
+ $(A.$slots, "default", {
2291
+ value: Se,
2292
+ open: bt,
2293
+ disabled: yt
2294
+ })
2295
+ ]),
2296
+ _: 3
2297
+ }, 8, ["model-value"]));
2298
+ }
2299
+ }), Cn = /* @__PURE__ */ f({
2300
+ __name: "AGHeadlessSelectButton",
2301
+ props: { textClass: g() },
2302
+ setup(r) {
2303
+ const t = H(
2304
+ "select",
2305
+ "<AGHeadlessSelectButton> must be a child of a <AGHeadlessSelect>"
2306
+ );
2307
+ return (e, s) => (l(), _(c(Xt), null, {
2308
+ default: m(({ value: n, open: o, disabled: a }) => [
2309
+ $(e.$slots, "default", {
2310
+ value: n,
2311
+ open: o,
2312
+ disabled: a
2313
+ }, () => {
2314
+ var i;
2315
+ return [
2316
+ b("span", {
2317
+ class: q(r.textClass)
2318
+ }, P((i = c(t)) == null ? void 0 : i.buttonText), 3)
2319
+ ];
2320
+ }),
2321
+ $(e.$slots, "icon")
2322
+ ]),
2323
+ _: 3
2324
+ }));
2325
+ }
2326
+ }), Pn = ["id"], Mn = /* @__PURE__ */ f({
2327
+ __name: "AGHeadlessSelectError",
2328
+ setup(r) {
2329
+ const t = H(
2330
+ "select",
2331
+ "<AGHeadlessSelectError> must be a child of a <AGHeadlessSelect>"
2332
+ ), e = d(() => t.errors ? x(`errors.${t.errors[0]}`, `Error: ${t.errors[0]}`) : null);
2333
+ return (s, n) => e.value ? (l(), w("p", {
2334
+ key: 0,
2335
+ id: `${c(t).id}-error`
2336
+ }, P(e.value), 9, Pn)) : L("", !0);
2337
+ }
2338
+ }), En = /* @__PURE__ */ f({
2339
+ __name: "AGHeadlessSelectLabel",
2340
+ setup(r) {
2341
+ const t = H(
2342
+ "select",
2343
+ "<AGHeadlessSelectLabel> must be a child of a <AGHeadlessSelect>"
2344
+ ), e = Ne(), s = d(() => !!(t.label || e.default));
2345
+ return (n, o) => s.value ? (l(), _(c(Yt), { key: 0 }, {
2346
+ default: m(({ open: a, disabled: i }) => [
2347
+ $(n.$slots, "default", {
2348
+ open: a,
2349
+ disabled: i
2350
+ }, () => [
2351
+ D(P(c(t).label), 1)
2352
+ ])
2353
+ ]),
2354
+ _: 3
2355
+ })) : L("", !0);
2356
+ }
2357
+ }), Gn = /* @__PURE__ */ f({
2358
+ __name: "AGHeadlessSelectOption",
2359
+ props: {
2360
+ value: pr(),
2361
+ selectedClass: g(),
2362
+ unselectedClass: g(),
2363
+ activeClass: g(),
2364
+ inactiveClass: g()
2365
+ },
2366
+ setup(r) {
2367
+ const t = H(
2368
+ "select",
2369
+ "<AGHeadlessSelectOption> must be a child of a <AGHeadlessSelect>"
2370
+ );
2371
+ return (e, s) => (l(), _(c(Zt), {
2372
+ value: r.value,
2373
+ as: "template"
2374
+ }, {
2375
+ default: m(({ active: n, selected: o, disabled: a }) => [
2376
+ $(e.$slots, "default", {
2377
+ active: n,
2378
+ selected: o,
2379
+ disabled: a
2380
+ }, () => [
2381
+ b("li", {
2382
+ class: q({
2383
+ [r.activeClass ?? "active"]: n,
2384
+ [r.inactiveClass ?? "inactive"]: !n,
2385
+ [r.selectedClass ?? "selected"]: o,
2386
+ [r.unselectedClass ?? "unselected"]: !o
2387
+ })
2388
+ }, P(c(t).renderText(r.value)), 3)
2389
+ ])
2390
+ ]),
2391
+ _: 3
2392
+ }, 8, ["value"]));
2393
+ }
2394
+ }), Ln = { class: "pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2" }, yo = /* @__PURE__ */ f({
2395
+ __name: "AGSelect",
2396
+ props: gt(),
2397
+ emits: vt(),
2398
+ setup(r) {
2399
+ const t = r, e = He();
2400
+ return (s, n) => (l(), _(An, T(t, {
2401
+ ref_key: "$select",
2402
+ ref: e,
2403
+ as: "div",
2404
+ "onUpdate:modelValue": n[0] || (n[0] = (o) => s.$emit("update:modelValue", o))
2405
+ }), {
2406
+ default: m(() => {
2407
+ var o, a;
2408
+ return [
2409
+ h(En, { class: "block text-sm font-medium leading-6 text-gray-900" }),
2410
+ b("div", {
2411
+ class: q(["relative", { "mt-2": (o = c(e)) == null ? void 0 : o.label }])
2412
+ }, [
2413
+ h(Cn, {
2414
+ class: q(["relative w-full cursor-default bg-white py-1.5 pl-3 pr-10 text-left text-gray-900 ring-1 ring-inset ring-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-600", {
2415
+ "ring-1 ring-red-500": (a = c(e)) == null ? void 0 : a.errors
2416
+ }]),
2417
+ "text-class": "block truncate"
2418
+ }, {
2419
+ icon: m(() => [
2420
+ b("span", Ln, [
2421
+ h(c(Sn), { class: "h-5 w-5 text-gray-400" })
2422
+ ])
2423
+ ]),
2424
+ _: 1
2425
+ }, 8, ["class"]),
2426
+ h(c(er), { class: "absolute z-10 mt-1 max-h-60 w-full overflow-auto border bg-white py-1 text-base ring-1 ring-black ring-opacity-5 focus:outline-none" }, {
2427
+ default: m(() => {
2428
+ var i;
2429
+ return [
2430
+ (l(!0), w(K, null, ge(((i = c(e)) == null ? void 0 : i.options) ?? [], (u, p) => (l(), _(Gn, {
2431
+ key: p,
2432
+ value: u,
2433
+ class: "relative block cursor-default select-none truncate py-2 pl-3 pr-9",
2434
+ "selected-class": "font-semibold",
2435
+ "unselected-class": "font-normal",
2436
+ "active-class": "bg-indigo-600 text-white",
2437
+ "inactive-class": "text-gray-900"
2438
+ }, null, 8, ["value"]))), 128))
2439
+ ];
2440
+ }),
2441
+ _: 1
2442
+ })
2443
+ ], 2),
2444
+ h(Mn, { class: "mt-2 text-sm text-red-600" })
2445
+ ];
2446
+ }),
2447
+ _: 1
2448
+ }, 16));
2449
+ }
2450
+ }), Hn = ["id", "name", "required", "value", "aria-invalid", "aria-describedby"], wo = /* @__PURE__ */ f({
2451
+ __name: "AGHeadlessInputTextArea",
2452
+ setup(r) {
2453
+ const t = E(), e = H(
2454
+ "input",
2455
+ "<AGHeadlessInputTextArea> must be a child of a <AGHeadlessInput>"
2456
+ ), s = d(() => e.name ?? void 0), n = d(() => e.value);
2457
+ function o() {
2458
+ t.value && e.update(t.value.value);
2459
+ }
2460
+ return de(() => e.__setElement(t.value)), ft(e, () => {
2461
+ var a;
2462
+ return (a = t.value) == null ? void 0 : a.focus();
2463
+ }), (a, i) => (l(), w("textarea", {
2464
+ id: c(e).id,
2465
+ ref_key: "$textArea",
2466
+ ref: t,
2467
+ name: s.value,
2468
+ required: c(e).required ?? void 0,
2469
+ value: n.value,
2470
+ "aria-invalid": c(e).errors ? "true" : "false",
2471
+ "aria-describedby": c(e).errors ? `${c(e).id}-error` : c(e).description ? `${c(e).id}-description` : void 0,
2472
+ onInput: o
2473
+ }, null, 40, Hn));
2474
+ }
2475
+ }), $o = /* @__PURE__ */ f({
2476
+ __name: "AGErrorMessage",
2477
+ props: { error: $e() },
2478
+ setup(r) {
2479
+ const t = r, e = d(() => Pr(t.error));
2480
+ return (s, n) => (l(), _(I, {
2481
+ text: e.value,
2482
+ inline: ""
2483
+ }, null, 8, ["text"]));
2484
+ }
2485
+ }), xo = /* @__PURE__ */ f({
2486
+ __name: "AGLink",
2487
+ setup(r) {
2488
+ return (t, e) => (l(), _(it, { class: "font-medium hover:underline" }, {
2489
+ default: m(() => [
2490
+ $(t.$slots, "default")
2491
+ ]),
2492
+ _: 3
2493
+ }));
2494
+ }
2495
+ }), So = /* @__PURE__ */ f({
2496
+ __name: "AGMeasured",
2497
+ props: { as: g("span") },
2498
+ setup(r) {
2499
+ const t = E(!1);
2500
+ return (e, s) => {
2501
+ const n = Mt("measure");
2502
+ return Et((l(), _(j(r.as), {
2503
+ class: q({ "!invisible !absolute !w-auto": !t.value })
2504
+ }, {
2505
+ default: m(() => [
2506
+ $(e.$slots, "default")
2507
+ ]),
2508
+ _: 3
2509
+ }, 8, ["class"])), [
2510
+ [n, () => t.value = !0]
2511
+ ]);
2512
+ };
2513
+ }
2514
+ }), In = { class: "mt-1 h-2 w-full overflow-hidden rounded-full bg-gray-200" }, Tn = { class: "sr-only" }, ko = /* @__PURE__ */ f({
2515
+ __name: "AGProgressBar",
2516
+ props: {
2517
+ progress: se(),
2518
+ barClass: g(""),
2519
+ job: U()
2520
+ },
2521
+ setup(r) {
2522
+ const t = r;
2523
+ let e;
2524
+ const s = E(0), n = d(() => {
2525
+ const a = t.barClass ?? "";
2526
+ return `h-full w-full transition-transform duration-500 ease-linear ${a.includes("bg-") ? a : `${a} bg-gray-700`}`;
2527
+ }), o = d(() => typeof t.progress == "number" ? t.progress : s.value);
2528
+ return Ee(
2529
+ () => t.job,
2530
+ () => {
2531
+ var a, i;
2532
+ e == null || e(), s.value = ((a = t.job) == null ? void 0 : a.progress) ?? 0, e = (i = t.job) == null ? void 0 : i.listeners.add({ onUpdated: (u) => s.value = u });
2533
+ },
2534
+ { immediate: !0 }
2535
+ ), he(() => e == null ? void 0 : e()), (a, i) => (l(), w("div", In, [
2536
+ b("div", {
2537
+ class: q(n.value),
2538
+ style: Gt(`transform:translateX(-${(1 - o.value) * 100}%)`)
2539
+ }, null, 6),
2540
+ b("span", Tn, P(a.$td("ui.progress", "{progress}% complete", {
2541
+ progress: o.value * 100
2542
+ })), 1)
2543
+ ]));
2544
+ }
2545
+ }), Ao = /* @__PURE__ */ f({
2546
+ __name: "AGModalTitle",
2547
+ setup(r) {
2548
+ return (t, e) => (l(), _(at, { class: "mb-2 font-semibold" }, {
2549
+ default: m(() => [
2550
+ $(t.$slots, "default")
2551
+ ]),
2552
+ _: 3
2553
+ }));
2554
+ }
2555
+ });
2556
+ class Co {
2557
+ constructor() {
2558
+ v(this, "status");
2559
+ v(this, "_listeners");
2560
+ v(this, "_progress");
2561
+ v(this, "_cancelled");
2562
+ v(this, "_started");
2563
+ v(this, "_completed");
2564
+ this.status = this.getInitialStatus(), this._listeners = new Bt(), this._started = new N(), this._completed = new N();
2565
+ }
2566
+ async start() {
2567
+ this.beforeStart(), this._started.resolve();
2568
+ try {
2569
+ await this.updateProgress(), await this.run(), await this.updateProgress(), this._completed.resolve();
2570
+ } catch (t) {
2571
+ if (t instanceof qe)
2572
+ return;
2573
+ throw O(zt(t), (e) => {
2574
+ this._completed.reject(e);
2575
+ });
2576
+ }
2577
+ }
2578
+ async cancel() {
2579
+ this._cancelled = new N(), await this._cancelled;
2580
+ }
2581
+ serialize() {
2582
+ return this.serializeStatus(this.status);
2583
+ }
2584
+ get listeners() {
2585
+ return this._listeners;
2586
+ }
2587
+ get progress() {
2588
+ return this._progress ?? 0;
2589
+ }
2590
+ get cancelled() {
2591
+ var t;
2592
+ return !!((t = this._cancelled) != null && t.isResolved());
2593
+ }
2594
+ get started() {
2595
+ return this._started;
2596
+ }
2597
+ get completed() {
2598
+ return this._completed;
2599
+ }
2600
+ getInitialStatus() {
2601
+ return { completed: !1 };
2602
+ }
2603
+ beforeStart() {
2604
+ if (this._started.isResolved()) {
2605
+ if (this._cancelled) {
2606
+ delete this._progress, delete this._cancelled;
2607
+ return;
2608
+ }
2609
+ throw new Error("Job already started!");
2610
+ }
2611
+ }
2612
+ assertNotCancelled() {
2613
+ if (this._cancelled)
2614
+ throw this._cancelled.resolve(), new qe();
2615
+ }
2616
+ calculateCurrentProgress(t) {
2617
+ return t ?? (t = this.status), t.completed ? 1 : t.children ? Ft(
2618
+ t.children.reduce((e, s) => e + this.calculateCurrentProgress(s), 0) / t.children.length,
2619
+ 2
2620
+ ) : 0;
2621
+ }
2622
+ async updateProgress(t) {
2623
+ await (t == null ? void 0 : t(this.status));
2624
+ const e = this.calculateCurrentProgress();
2625
+ e !== this._progress && (this._progress = e, await this._listeners.emit("onUpdated", e));
2626
+ }
2627
+ serializeStatus(t) {
2628
+ return { ...t };
2629
+ }
2630
+ }
2631
+ async function Po(r) {
2632
+ await r.start();
2633
+ }
2634
+ export {
2635
+ Kr as AGAlertModal,
2636
+ go as AGAppLayout,
2637
+ bn as AGAppOverlays,
2638
+ R as AGButton,
2639
+ vo as AGCheckbox,
2640
+ ts as AGConfirmModal,
2641
+ $o as AGErrorMessage,
2642
+ ws as AGErrorReportModalButtons,
2643
+ $s as AGErrorReportModalTitle,
2644
+ Is as AGForm,
2645
+ it as AGHeadlessButton,
2646
+ dt as AGHeadlessInput,
2647
+ Rs as AGHeadlessInputDescription,
2648
+ pt as AGHeadlessInputError,
2649
+ mt as AGHeadlessInputInput,
2650
+ ht as AGHeadlessInputLabel,
2651
+ wo as AGHeadlessInputTextArea,
2652
+ zr as AGHeadlessModal,
2653
+ Fr as AGHeadlessModalPanel,
2654
+ at as AGHeadlessModalTitle,
2655
+ An as AGHeadlessSelect,
2656
+ Cn as AGHeadlessSelectButton,
2657
+ Mn as AGHeadlessSelectError,
2658
+ En as AGHeadlessSelectLabel,
2659
+ Gn as AGHeadlessSelectOption,
2660
+ Go as AGHeadlessSelectOptions,
2661
+ Qs as AGHeadlessSnackbar,
2662
+ Bs as AGInput,
2663
+ xo as AGLink,
2664
+ Es as AGLoadingModal,
2665
+ I as AGMarkdown,
2666
+ So as AGMeasured,
2667
+ ie as AGModal,
2668
+ ot as AGModalContext,
2669
+ Ao as AGModalTitle,
2670
+ ko as AGProgressBar,
2671
+ Os as AGPromptModal,
2672
+ yo as AGSelect,
2673
+ tn as AGSnackbar,
2674
+ an as AGStartupCrash,
2675
+ F as App,
2676
+ lr as AppService,
2677
+ Zn as Cache,
2678
+ _r as CacheService,
2679
+ C as Colors,
2680
+ tt as Errors,
2681
+ Nn as EventListenerPriorities,
2682
+ S as Events,
2683
+ ar as EventsService,
2684
+ Us as Form,
2685
+ B as FormFieldTypes,
2686
+ Co as Job,
2687
+ qe as JobCancelledError,
2688
+ oe as Lang,
2689
+ me as Layouts,
2690
+ Ye as MOBILE_BREAKPOINT,
2691
+ ye as Service,
2692
+ Me as ServiceBootError,
2693
+ Xs as SnackbarColors,
2694
+ vr as Storage,
2695
+ G as UI,
2696
+ M as UIComponents,
2697
+ $r as UIService,
2698
+ Nr as alertModalProps,
2699
+ ur as arrayProp,
2700
+ lo as booleanInput,
2701
+ re as booleanProp,
2702
+ xe as bootServices,
2703
+ _o as bootstrap,
2704
+ un as bootstrapApplication,
2705
+ He as componentRef,
2706
+ Kn as computedAsync,
2707
+ Or as confirmModalProps,
2708
+ co as dateInput,
2709
+ On as defineDirective,
2710
+ io as defineFormValidationRule,
2711
+ Wn as definePlugin,
2712
+ be as defineServiceState,
2713
+ or as defineServiceStore,
2714
+ Po as dispatch,
2715
+ Zr as elementRef,
2716
+ Y as enumProp,
2717
+ ls as errorReportModalProps,
2718
+ ao as extractInputProps,
2719
+ oo as extractModalProps,
2720
+ bo as extractSelectProps,
2721
+ Ze as getCurrentLayout,
2722
+ Xr as getElement,
2723
+ Pr as getErrorMessage,
2724
+ nr as getPiniaStore,
2725
+ Yr as hasElement,
2726
+ Jn as injectOrFail,
2727
+ dr as injectReactive,
2728
+ H as injectReactiveOrFail,
2729
+ Ts as inputEmits,
2730
+ lt as inputProps,
2731
+ cr as installPlugins,
2732
+ Qn as listenerProp,
2733
+ Cs as loadingModalProps,
2734
+ we as mixedProp,
2735
+ st as modalProps,
2736
+ mo as numberInput,
2737
+ se as numberProp,
2738
+ U as objectProp,
2739
+ ro as onCleanMounted,
2740
+ ft as onFormFocus,
2741
+ so as persistent,
2742
+ Gs as promptModalProps,
2743
+ to as registerErrorHandler,
2744
+ no as removeInteractiveClasses,
2745
+ Dr as renderMarkdown,
2746
+ eo as replaceExisting,
2747
+ Xe as requiredArrayProp,
2748
+ uo as requiredBooleanInput,
2749
+ po as requiredDateInput,
2750
+ Xn as requiredEnumProp,
2751
+ pr as requiredMixedProp,
2752
+ fo as requiredNumberInput,
2753
+ Yn as requiredNumberProp,
2754
+ $e as requiredObjectProp,
2755
+ Ws as requiredStringInput,
2756
+ ne as requiredStringProp,
2757
+ sr as resetPiniaStore,
2758
+ Vr as safeHtml,
2759
+ kn as selectEmits,
2760
+ _t as selectProps,
2761
+ Ys as snackbarProps,
2762
+ ho as stringInput,
2763
+ g as stringProp,
2764
+ et as translate,
2765
+ x as translateWithDefault,
2766
+ Wr as useAlertModalProps,
2767
+ Qr as useConfirmModal,
2768
+ Jr as useConfirmModalProps,
2769
+ us as useErrorReportModal,
2770
+ cs as useErrorReportModalProps,
2771
+ te as useEvent,
2772
+ Ns as useForm,
2773
+ Rr as useInputAttrs,
2774
+ ct as useInputEmits,
2775
+ ut as useInputProps,
2776
+ Ms as useLoadingModal,
2777
+ Ps as useLoadingModalProps,
2778
+ Br as useModalExpose,
2779
+ nt as useModalProps,
2780
+ Hs as usePromptModal,
2781
+ Ls as usePromptModalProps,
2782
+ vt as useSelectEmits,
2783
+ gt as useSelectProps,
2784
+ en as useSnackbar,
2785
+ Zs as useSnackbarProps,
2786
+ Fs as validate,
2787
+ le as validators
2788
+ };
2789
+ //# sourceMappingURL=aerogel-core.js.map