@stonecrop/desktop 0.10.1 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/desktop.js CHANGED
@@ -1,40 +1,40 @@
1
- import { defineComponent as we, ref as C, onMounted as Ae, openBlock as P, createElementBlock as V, normalizeClass as Oe, createElementVNode as A, Fragment as de, renderList as me, toDisplayString as X, createCommentVNode as ue, withDirectives as Ne, vShow as Ue, useTemplateRef as ft, computed as I, watch as L, nextTick as ae, createBlock as Ze, Teleport as Rt, createVNode as ne, Transition as It, withCtx as ye, withModifiers as pt, vModelText as ht, renderSlot as Pe, createTextVNode as $e, toRaw as vt, isRef as fe, isReactive as xe, toRef as re, hasInjectionContext as ze, inject as be, getCurrentInstance as gt, reactive as mt, markRaw as he, effectScope as At, getCurrentScope as Qe, onScopeDispose as Xe, toRefs as tt, provide as Ge, shallowRef as Se, toValue as Q, readonly as Te, customRef as Ye, unref as De, useModel as xt, watchEffect as Tt, resolveComponent as yt, resolveDynamicComponent as Pt, mergeProps as Vt, mergeModels as ot, withKeys as pe, normalizeStyle as Ve } from "vue";
2
- const jt = { class: "action-menu-icon" }, Mt = ["disabled", "onClick"], Ft = { key: 1 }, Lt = ["onClick"], Bt = { class: "dropdown-container" }, Wt = { class: "dropdown" }, Ht = ["onClick"], Ut = ["href"], zt = { class: "dropdown-item" }, Gt = /* @__PURE__ */ we({
1
+ import { defineComponent as be, ref as $, onMounted as xe, openBlock as P, createElementBlock as j, normalizeClass as De, createElementVNode as x, Fragment as ue, renderList as ye, toDisplayString as X, createCommentVNode as ce, withDirectives as Oe, vShow as Je, useTemplateRef as pt, computed as R, watch as H, nextTick as de, createBlock as Qe, Teleport as Ot, createVNode as ne, Transition as At, withCtx as me, withModifiers as ft, vModelText as ht, renderSlot as Ve, createTextVNode as Ae, toRaw as vt, isRef as pe, isReactive as Te, toRef as re, hasInjectionContext as ze, inject as we, getCurrentInstance as gt, reactive as yt, markRaw as he, effectScope as $t, getCurrentScope as Xe, onScopeDispose as Ye, toRefs as tt, provide as Ge, shallowRef as Se, toValue as K, readonly as Pe, customRef as et, unref as Ne, useModel as It, watchEffect as Rt, resolveComponent as mt, resolveDynamicComponent as xt, mergeProps as Tt, mergeModels as ot, withKeys as fe, normalizeStyle as je } from "vue";
2
+ const Pt = { class: "action-menu-icon" }, Vt = ["disabled", "onClick"], jt = { key: 1 }, Mt = ["onClick"], Ft = { class: "dropdown-container" }, Lt = { class: "dropdown" }, Bt = ["onClick"], Wt = ["href"], Ht = { class: "dropdown-item" }, Ut = /* @__PURE__ */ be({
3
3
  __name: "ActionSet",
4
4
  props: {
5
5
  elements: { default: () => [] }
6
6
  },
7
7
  emits: ["actionClick"],
8
- setup(t, { emit: e }) {
9
- const o = e, n = C({}), r = C(!1), i = C(-1), a = C(!1), u = C(!1);
10
- Ae(() => {
11
- c();
8
+ setup(n, { emit: e }) {
9
+ const t = e, o = $({}), r = $(!1), a = $(-1), s = $(!1), c = $(!1);
10
+ xe(() => {
11
+ d();
12
12
  });
13
- const c = () => {
14
- n.value = {};
15
- }, f = () => {
16
- a.value = !0, i.value = setTimeout(() => {
17
- a.value && (r.value = !0);
13
+ const d = () => {
14
+ o.value = {};
15
+ }, u = () => {
16
+ s.value = !0, a.value = setTimeout(() => {
17
+ s.value && (r.value = !0);
18
18
  }, 500);
19
- }, p = () => {
20
- a.value = !1, u.value = !1, clearTimeout(i.value), r.value = !1;
21
- }, b = (_) => {
22
- const m = !n.value[_];
23
- c(), m && (n.value[_] = !0);
24
- }, h = (_, m) => {
25
- o("actionClick", m, _);
19
+ }, w = () => {
20
+ s.value = !1, c.value = !1, clearTimeout(a.value), r.value = !1;
21
+ }, v = (b) => {
22
+ const m = !o.value[b];
23
+ d(), m && (o.value[b] = !0);
24
+ }, h = (b, m) => {
25
+ t("actionClick", m, b);
26
26
  };
27
- return (_, m) => (P(), V("div", {
28
- class: Oe([{ "open-set": r.value, "hovered-and-closed": u.value }, "action-set collapse"]),
29
- onMouseover: f,
30
- onMouseleave: p
27
+ return (b, m) => (P(), j("div", {
28
+ class: De([{ "open-set": r.value, "hovered-and-closed": c.value }, "action-set collapse"]),
29
+ onMouseover: u,
30
+ onMouseleave: w
31
31
  }, [
32
- A("div", jt, [
33
- A("div", {
32
+ x("div", Pt, [
33
+ x("div", {
34
34
  id: "chevron",
35
- onClick: m[0] || (m[0] = (O) => u.value = !u.value)
35
+ onClick: m[0] || (m[0] = (k) => c.value = !c.value)
36
36
  }, [...m[1] || (m[1] = [
37
- A("svg", {
37
+ x("svg", {
38
38
  id: "Layer_1",
39
39
  class: "leftBar",
40
40
  version: "1.1",
@@ -47,9 +47,9 @@ const jt = { class: "action-menu-icon" }, Mt = ["disabled", "onClick"], Ft = { k
47
47
  width: "50",
48
48
  height: "50"
49
49
  }, [
50
- A("polygon", { points: "54.2,33.4 29.2,58.8 25,54.6 50,29.2 " })
50
+ x("polygon", { points: "54.2,33.4 29.2,58.8 25,54.6 50,29.2 " })
51
51
  ], -1),
52
- A("svg", {
52
+ x("svg", {
53
53
  id: "Layer_1",
54
54
  class: "rightBar",
55
55
  version: "1.1",
@@ -62,62 +62,62 @@ const jt = { class: "action-menu-icon" }, Mt = ["disabled", "onClick"], Ft = { k
62
62
  width: "50",
63
63
  height: "50"
64
64
  }, [
65
- A("polygon", { points: "70.8,58.8 45.8,33.4 50,29.2 75,54.6 " })
65
+ x("polygon", { points: "70.8,58.8 45.8,33.4 50,29.2 75,54.6 " })
66
66
  ], -1)
67
67
  ])])
68
68
  ]),
69
- m[2] || (m[2] = A("div", { style: { "margin-right": "30px" } }, null, -1)),
70
- (P(!0), V(de, null, me(t.elements, (O, R) => (P(), V("div", {
71
- key: O.label,
69
+ m[2] || (m[2] = x("div", { style: { "margin-right": "30px" } }, null, -1)),
70
+ (P(!0), j(ue, null, ye(n.elements, (k, I) => (P(), j("div", {
71
+ key: k.label,
72
72
  class: "action-element"
73
73
  }, [
74
- O.type == "button" ? (P(), V("button", {
74
+ k.type == "button" ? (P(), j("button", {
75
75
  key: 0,
76
- disabled: O.disabled,
76
+ disabled: k.disabled,
77
77
  class: "button-default",
78
- onClick: (x) => h(O.action, O.label)
79
- }, X(O.label), 9, Mt)) : ue("", !0),
80
- O.type == "dropdown" ? (P(), V("div", Ft, [
81
- A("button", {
78
+ onClick: (T) => h(k.action, k.label)
79
+ }, X(k.label), 9, Vt)) : ce("", !0),
80
+ k.type == "dropdown" ? (P(), j("div", jt, [
81
+ x("button", {
82
82
  class: "button-default",
83
- onClick: (x) => b(R)
84
- }, X(O.label), 9, Lt),
85
- Ne(A("div", Bt, [
86
- A("div", Wt, [
87
- (P(!0), V(de, null, me(O.actions, (x, H) => (P(), V("div", {
88
- key: x.label
83
+ onClick: (T) => v(I)
84
+ }, X(k.label), 9, Mt),
85
+ Oe(x("div", Ft, [
86
+ x("div", Lt, [
87
+ (P(!0), j(ue, null, ye(k.actions, (T, Z) => (P(), j("div", {
88
+ key: T.label
89
89
  }, [
90
- x.action != null ? (P(), V("button", {
90
+ T.action != null ? (P(), j("button", {
91
91
  key: 0,
92
92
  class: "dropdown-item",
93
- onClick: (U) => h(x.action, x.label)
94
- }, X(x.label), 9, Ht)) : x.link != null ? (P(), V("a", {
93
+ onClick: (U) => h(T.action, T.label)
94
+ }, X(T.label), 9, Bt)) : T.link != null ? (P(), j("a", {
95
95
  key: 1,
96
- href: x.link
96
+ href: T.link
97
97
  }, [
98
- A("button", zt, X(x.label), 1)
99
- ], 8, Ut)) : ue("", !0)
98
+ x("button", Ht, X(T.label), 1)
99
+ ], 8, Wt)) : ce("", !0)
100
100
  ]))), 128))
101
101
  ])
102
102
  ], 512), [
103
- [Ue, n.value[R]]
103
+ [Je, o.value[I]]
104
104
  ])
105
- ])) : ue("", !0)
105
+ ])) : ce("", !0)
106
106
  ]))), 128))
107
107
  ], 34));
108
108
  }
109
- }), bt = (t, e) => {
110
- const o = t.__vccOpts || t;
111
- for (const [n, r] of e)
112
- o[n] = r;
113
- return o;
114
- }, wt = /* @__PURE__ */ bt(Gt, [["__scopeId", "data-v-eb01c863"]]), Jt = { class: "command-palette-header" }, Kt = ["placeholder"], qt = {
109
+ }), wt = (n, e) => {
110
+ const t = n.__vccOpts || n;
111
+ for (const [o, r] of e)
112
+ t[o] = r;
113
+ return t;
114
+ }, bt = /* @__PURE__ */ wt(Ut, [["__scopeId", "data-v-eb01c863"]]), Jt = { class: "command-palette-header" }, zt = ["placeholder"], Gt = {
115
115
  key: 0,
116
116
  class: "command-palette-results"
117
- }, Zt = ["onClick", "onMouseover"], Qt = { class: "result-title" }, Xt = { class: "result-content" }, Yt = {
117
+ }, qt = ["onClick", "onMouseover"], Kt = { class: "result-title" }, Zt = { class: "result-content" }, Qt = {
118
118
  key: 1,
119
119
  class: "command-palette-no-results"
120
- }, St = /* @__PURE__ */ we({
120
+ }, St = /* @__PURE__ */ be({
121
121
  __name: "CommandPalette",
122
122
  props: {
123
123
  search: { type: Function },
@@ -126,913 +126,913 @@ const jt = { class: "action-menu-icon" }, Mt = ["disabled", "onClick"], Ft = { k
126
126
  maxResults: { default: 10 }
127
127
  },
128
128
  emits: ["select", "close"],
129
- setup(t, { emit: e }) {
130
- const o = e, n = C(""), r = C(0), i = ft("input"), a = I(() => n.value ? t.search(n.value).slice(0, t.maxResults) : []);
131
- L(
132
- () => t.isOpen,
133
- async (p) => {
134
- p && (n.value = "", r.value = 0, await ae(), i.value?.focus());
129
+ setup(n, { emit: e }) {
130
+ const t = e, o = $(""), r = $(0), a = pt("input"), s = R(() => o.value ? n.search(o.value).slice(0, n.maxResults) : []);
131
+ H(
132
+ () => n.isOpen,
133
+ async (w) => {
134
+ w && (o.value = "", r.value = 0, await de(), a.value?.focus());
135
135
  }
136
- ), L(a, () => {
136
+ ), H(s, () => {
137
137
  r.value = 0;
138
138
  });
139
- const u = () => {
140
- o("close");
141
- }, c = (p) => {
142
- switch (p.key) {
139
+ const c = () => {
140
+ t("close");
141
+ }, d = (w) => {
142
+ switch (w.key) {
143
143
  case "Escape":
144
- u();
144
+ c();
145
145
  break;
146
146
  case "ArrowDown":
147
- p.preventDefault(), a.value.length && (r.value = (r.value + 1) % a.value.length);
147
+ w.preventDefault(), s.value.length && (r.value = (r.value + 1) % s.value.length);
148
148
  break;
149
149
  case "ArrowUp":
150
- p.preventDefault(), a.value.length && (r.value = (r.value - 1 + a.value.length) % a.value.length);
150
+ w.preventDefault(), s.value.length && (r.value = (r.value - 1 + s.value.length) % s.value.length);
151
151
  break;
152
152
  case "Enter":
153
- a.value.length && r.value >= 0 && f(a.value[r.value]);
153
+ s.value.length && r.value >= 0 && u(s.value[r.value]);
154
154
  break;
155
155
  }
156
- }, f = (p) => {
157
- o("select", p), u();
156
+ }, u = (w) => {
157
+ t("select", w), c();
158
158
  };
159
- return (p, b) => (P(), Ze(Rt, { to: "body" }, [
160
- ne(It, { name: "fade" }, {
161
- default: ye(() => [
162
- t.isOpen ? (P(), V("div", {
159
+ return (w, v) => (P(), Qe(Ot, { to: "body" }, [
160
+ ne(At, { name: "fade" }, {
161
+ default: me(() => [
162
+ n.isOpen ? (P(), j("div", {
163
163
  key: 0,
164
164
  class: "command-palette-overlay",
165
- onClick: u
165
+ onClick: c
166
166
  }, [
167
- A("div", {
167
+ x("div", {
168
168
  class: "command-palette",
169
- onClick: b[1] || (b[1] = pt(() => {
169
+ onClick: v[1] || (v[1] = ft(() => {
170
170
  }, ["stop"]))
171
171
  }, [
172
- A("div", Jt, [
173
- Ne(A("input", {
172
+ x("div", Jt, [
173
+ Oe(x("input", {
174
174
  ref: "input",
175
- "onUpdate:modelValue": b[0] || (b[0] = (h) => n.value = h),
175
+ "onUpdate:modelValue": v[0] || (v[0] = (h) => o.value = h),
176
176
  type: "text",
177
177
  class: "command-palette-input",
178
- placeholder: t.placeholder,
178
+ placeholder: n.placeholder,
179
179
  autofocus: "",
180
- onKeydown: c
181
- }, null, 40, Kt), [
182
- [ht, n.value]
180
+ onKeydown: d
181
+ }, null, 40, zt), [
182
+ [ht, o.value]
183
183
  ])
184
184
  ]),
185
- a.value.length ? (P(), V("div", qt, [
186
- (P(!0), V(de, null, me(a.value, (h, _) => (P(), V("div", {
187
- key: _,
188
- class: Oe(["command-palette-result", { selected: _ === r.value }]),
189
- onClick: (m) => f(h),
190
- onMouseover: (m) => r.value = _
185
+ s.value.length ? (P(), j("div", Gt, [
186
+ (P(!0), j(ue, null, ye(s.value, (h, b) => (P(), j("div", {
187
+ key: b,
188
+ class: De(["command-palette-result", { selected: b === r.value }]),
189
+ onClick: (m) => u(h),
190
+ onMouseover: (m) => r.value = b
191
191
  }, [
192
- A("div", Qt, [
193
- Pe(p.$slots, "title", { result: h })
192
+ x("div", Kt, [
193
+ Ve(w.$slots, "title", { result: h })
194
194
  ]),
195
- A("div", Xt, [
196
- Pe(p.$slots, "content", { result: h })
195
+ x("div", Zt, [
196
+ Ve(w.$slots, "content", { result: h })
197
197
  ])
198
- ], 42, Zt))), 128))
199
- ])) : n.value && !a.value.length ? (P(), V("div", Yt, [
200
- Pe(p.$slots, "empty", {}, () => [
201
- $e(' No results found for "' + X(n.value) + '" ', 1)
198
+ ], 42, qt))), 128))
199
+ ])) : o.value && !s.value.length ? (P(), j("div", Qt, [
200
+ Ve(w.$slots, "empty", {}, () => [
201
+ Ae(' No results found for "' + X(o.value) + '" ', 1)
202
202
  ])
203
- ])) : ue("", !0)
203
+ ])) : ce("", !0)
204
204
  ])
205
- ])) : ue("", !0)
205
+ ])) : ce("", !0)
206
206
  ]),
207
207
  _: 3
208
208
  })
209
209
  ]));
210
210
  }
211
211
  });
212
- const le = typeof window < "u";
212
+ const ie = typeof window < "u";
213
213
  let oe;
214
- const Ce = (t) => oe = t;
214
+ const $e = (n) => oe = n;
215
215
  process.env.NODE_ENV;
216
- const Je = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia") : (
216
+ const qe = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia") : (
217
217
  /* istanbul ignore next */
218
218
  /* @__PURE__ */ Symbol()
219
219
  );
220
- function se(t) {
221
- return t && typeof t == "object" && Object.prototype.toString.call(t) === "[object Object]" && typeof t.toJSON != "function";
220
+ function ae(n) {
221
+ return n && typeof n == "object" && Object.prototype.toString.call(n) === "[object Object]" && typeof n.toJSON != "function";
222
222
  }
223
223
  var ve;
224
- (function(t) {
225
- t.direct = "direct", t.patchObject = "patch object", t.patchFunction = "patch function";
224
+ (function(n) {
225
+ n.direct = "direct", n.patchObject = "patch object", n.patchFunction = "patch function";
226
226
  })(ve || (ve = {}));
227
- function Et(t, e) {
228
- for (const o in e) {
229
- const n = e[o];
230
- if (!(o in t))
227
+ function _t(n, e) {
228
+ for (const t in e) {
229
+ const o = e[t];
230
+ if (!(t in n))
231
231
  continue;
232
- const r = t[o];
233
- se(r) && se(n) && !fe(n) && !xe(n) ? t[o] = Et(r, n) : t[o] = n;
232
+ const r = n[t];
233
+ ae(r) && ae(o) && !pe(o) && !Te(o) ? n[t] = _t(r, o) : n[t] = o;
234
234
  }
235
- return t;
235
+ return n;
236
236
  }
237
- const _t = () => {
237
+ const Et = () => {
238
238
  };
239
- function nt(t, e, o, n = _t) {
240
- t.add(e);
239
+ function nt(n, e, t, o = Et) {
240
+ n.add(e);
241
241
  const r = () => {
242
- t.delete(e) && n();
242
+ n.delete(e) && o();
243
243
  };
244
- return !o && Qe() && Xe(r), r;
244
+ return !t && Xe() && Ye(r), r;
245
245
  }
246
- function ie(t, ...e) {
247
- t.forEach((o) => {
248
- o(...e);
246
+ function se(n, ...e) {
247
+ n.forEach((t) => {
248
+ t(...e);
249
249
  });
250
250
  }
251
- const eo = (t) => t(), rt = /* @__PURE__ */ Symbol(), je = /* @__PURE__ */ Symbol();
252
- function Ke(t, e) {
253
- t instanceof Map && e instanceof Map ? e.forEach((o, n) => t.set(n, o)) : t instanceof Set && e instanceof Set && e.forEach(t.add, t);
254
- for (const o in e) {
255
- if (!e.hasOwnProperty(o))
251
+ const Xt = (n) => n(), rt = /* @__PURE__ */ Symbol(), Me = /* @__PURE__ */ Symbol();
252
+ function Ke(n, e) {
253
+ n instanceof Map && e instanceof Map ? e.forEach((t, o) => n.set(o, t)) : n instanceof Set && e instanceof Set && e.forEach(n.add, n);
254
+ for (const t in e) {
255
+ if (!e.hasOwnProperty(t))
256
256
  continue;
257
- const n = e[o], r = t[o];
258
- se(r) && se(n) && t.hasOwnProperty(o) && !fe(n) && !xe(n) ? t[o] = Ke(r, n) : t[o] = n;
257
+ const o = e[t], r = n[t];
258
+ ae(r) && ae(o) && n.hasOwnProperty(t) && !pe(o) && !Te(o) ? n[t] = Ke(r, o) : n[t] = o;
259
259
  }
260
- return t;
260
+ return n;
261
261
  }
262
- const to = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia:skipHydration") : (
262
+ const Yt = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia:skipHydration") : (
263
263
  /* istanbul ignore next */
264
264
  /* @__PURE__ */ Symbol()
265
265
  );
266
- function oo(t) {
267
- return !se(t) || !Object.prototype.hasOwnProperty.call(t, to);
266
+ function eo(n) {
267
+ return !ae(n) || !Object.prototype.hasOwnProperty.call(n, Yt);
268
268
  }
269
- const { assign: Z } = Object;
270
- function at(t) {
271
- return !!(fe(t) && t.effect);
269
+ const { assign: q } = Object;
270
+ function at(n) {
271
+ return !!(pe(n) && n.effect);
272
272
  }
273
- function st(t, e, o, n) {
274
- const { state: r, actions: i, getters: a } = e, u = o.state.value[t];
275
- let c;
276
- function f() {
277
- !u && (process.env.NODE_ENV === "production" || !n) && (o.state.value[t] = r ? r() : {});
278
- const p = process.env.NODE_ENV !== "production" && n ? (
273
+ function st(n, e, t, o) {
274
+ const { state: r, actions: a, getters: s } = e, c = t.state.value[n];
275
+ let d;
276
+ function u() {
277
+ !c && (process.env.NODE_ENV === "production" || !o) && (t.state.value[n] = r ? r() : {});
278
+ const w = process.env.NODE_ENV !== "production" && o ? (
279
279
  // use ref() to unwrap refs inside state TODO: check if this is still necessary
280
- tt(C(r ? r() : {}).value)
281
- ) : tt(o.state.value[t]);
282
- return Z(p, i, Object.keys(a || {}).reduce((b, h) => (process.env.NODE_ENV !== "production" && h in p && console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${h}" in store "${t}".`), b[h] = he(I(() => {
283
- Ce(o);
284
- const _ = o._s.get(t);
285
- return a[h].call(_, _);
286
- })), b), {}));
287
- }
288
- return c = qe(t, f, e, o, n, !0), c;
280
+ tt($(r ? r() : {}).value)
281
+ ) : tt(t.state.value[n]);
282
+ return q(w, a, Object.keys(s || {}).reduce((v, h) => (process.env.NODE_ENV !== "production" && h in w && console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${h}" in store "${n}".`), v[h] = he(R(() => {
283
+ $e(t);
284
+ const b = t._s.get(n);
285
+ return s[h].call(b, b);
286
+ })), v), {}));
287
+ }
288
+ return d = Ze(n, u, e, t, o, !0), d;
289
289
  }
290
- function qe(t, e, o = {}, n, r, i) {
291
- let a;
292
- const u = Z({ actions: {} }, o);
293
- if (process.env.NODE_ENV !== "production" && !n._e.active)
290
+ function Ze(n, e, t = {}, o, r, a) {
291
+ let s;
292
+ const c = q({ actions: {} }, t);
293
+ if (process.env.NODE_ENV !== "production" && !o._e.active)
294
294
  throw new Error("Pinia destroyed");
295
- const c = { deep: !0 };
296
- process.env.NODE_ENV !== "production" && (c.onTrigger = (v) => {
297
- f ? _ = v : f == !1 && !E._hotUpdating && (Array.isArray(_) ? _.push(v) : console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."));
295
+ const d = { deep: !0 };
296
+ process.env.NODE_ENV !== "production" && (d.onTrigger = (g) => {
297
+ u ? b = g : u == !1 && !E._hotUpdating && (Array.isArray(b) ? b.push(g) : console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."));
298
298
  });
299
- let f, p, b = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), _;
300
- const m = n.state.value[t];
301
- !i && !m && (process.env.NODE_ENV === "production" || !r) && (n.state.value[t] = {});
302
- const O = C({});
303
- let R;
304
- function x(v) {
305
- let g;
306
- f = p = !1, process.env.NODE_ENV !== "production" && (_ = []), typeof v == "function" ? (v(n.state.value[t]), g = {
299
+ let u, w, v = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), b;
300
+ const m = o.state.value[n];
301
+ !a && !m && (process.env.NODE_ENV === "production" || !r) && (o.state.value[n] = {});
302
+ const k = $({});
303
+ let I;
304
+ function T(g) {
305
+ let y;
306
+ u = w = !1, process.env.NODE_ENV !== "production" && (b = []), typeof g == "function" ? (g(o.state.value[n]), y = {
307
307
  type: ve.patchFunction,
308
- storeId: t,
309
- events: _
310
- }) : (Ke(n.state.value[t], v), g = {
308
+ storeId: n,
309
+ events: b
310
+ }) : (Ke(o.state.value[n], g), y = {
311
311
  type: ve.patchObject,
312
- payload: v,
313
- storeId: t,
314
- events: _
312
+ payload: g,
313
+ storeId: n,
314
+ events: b
315
315
  });
316
- const $ = R = /* @__PURE__ */ Symbol();
317
- ae().then(() => {
318
- R === $ && (f = !0);
319
- }), p = !0, ie(b, g, n.state.value[t]);
320
- }
321
- const H = i ? function() {
322
- const { state: g } = o, $ = g ? g() : {};
323
- this.$patch((M) => {
324
- Z(M, $);
316
+ const D = I = /* @__PURE__ */ Symbol();
317
+ de().then(() => {
318
+ I === D && (u = !0);
319
+ }), w = !0, se(v, y, o.state.value[n]);
320
+ }
321
+ const Z = a ? function() {
322
+ const { state: y } = t, D = y ? y() : {};
323
+ this.$patch((F) => {
324
+ q(F, D);
325
325
  });
326
326
  } : (
327
327
  /* istanbul ignore next */
328
328
  process.env.NODE_ENV !== "production" ? () => {
329
- throw new Error(`🍍: Store "${t}" is built using the setup syntax and does not implement $reset().`);
330
- } : _t
329
+ throw new Error(`🍍: Store "${n}" is built using the setup syntax and does not implement $reset().`);
330
+ } : Et
331
331
  );
332
332
  function U() {
333
- a.stop(), b.clear(), h.clear(), n._s.delete(t);
334
- }
335
- const K = (v, g = "") => {
336
- if (rt in v)
337
- return v[je] = g, v;
338
- const $ = function() {
339
- Ce(n);
340
- const M = Array.from(arguments), k = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Set();
341
- function F(S) {
342
- k.add(S);
333
+ s.stop(), v.clear(), h.clear(), o._s.delete(n);
334
+ }
335
+ const z = (g, y = "") => {
336
+ if (rt in g)
337
+ return g[Me] = y, g;
338
+ const D = function() {
339
+ $e(o);
340
+ const F = Array.from(arguments), N = /* @__PURE__ */ new Set(), V = /* @__PURE__ */ new Set();
341
+ function M(S) {
342
+ N.add(S);
343
343
  }
344
- function w(S) {
345
- T.add(S);
344
+ function _(S) {
345
+ V.add(S);
346
346
  }
347
- ie(h, {
348
- args: M,
349
- name: $[je],
347
+ se(h, {
348
+ args: F,
349
+ name: D[Me],
350
350
  store: E,
351
- after: F,
352
- onError: w
351
+ after: M,
352
+ onError: _
353
353
  });
354
- let D;
354
+ let C;
355
355
  try {
356
- D = v.apply(this && this.$id === t ? this : E, M);
356
+ C = g.apply(this && this.$id === n ? this : E, F);
357
357
  } catch (S) {
358
- throw ie(T, S), S;
358
+ throw se(V, S), S;
359
359
  }
360
- return D instanceof Promise ? D.then((S) => (ie(k, S), S)).catch((S) => (ie(T, S), Promise.reject(S))) : (ie(k, D), D);
360
+ return C instanceof Promise ? C.then((S) => (se(N, S), S)).catch((S) => (se(V, S), Promise.reject(S))) : (se(N, C), C);
361
361
  };
362
- return $[rt] = !0, $[je] = g, $;
363
- }, G = /* @__PURE__ */ he({
362
+ return D[rt] = !0, D[Me] = y, D;
363
+ }, L = /* @__PURE__ */ he({
364
364
  actions: {},
365
365
  getters: {},
366
366
  state: [],
367
- hotState: O
368
- }), z = {
369
- _p: n,
367
+ hotState: k
368
+ }), G = {
369
+ _p: o,
370
370
  // _s: scope,
371
- $id: t,
371
+ $id: n,
372
372
  $onAction: nt.bind(null, h),
373
- $patch: x,
374
- $reset: H,
375
- $subscribe(v, g = {}) {
376
- const $ = nt(b, v, g.detached, () => M()), M = a.run(() => L(() => n.state.value[t], (k) => {
377
- (g.flush === "sync" ? p : f) && v({
378
- storeId: t,
373
+ $patch: T,
374
+ $reset: Z,
375
+ $subscribe(g, y = {}) {
376
+ const D = nt(v, g, y.detached, () => F()), F = s.run(() => H(() => o.state.value[n], (N) => {
377
+ (y.flush === "sync" ? w : u) && g({
378
+ storeId: n,
379
379
  type: ve.direct,
380
- events: _
381
- }, k);
382
- }, Z({}, c, g)));
383
- return $;
380
+ events: b
381
+ }, N);
382
+ }, q({}, d, y)));
383
+ return D;
384
384
  },
385
385
  $dispose: U
386
- }, E = mt(process.env.NODE_ENV !== "production" || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && le ? Z(
386
+ }, E = yt(process.env.NODE_ENV !== "production" || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && ie ? q(
387
387
  {
388
- _hmrPayload: G,
388
+ _hmrPayload: L,
389
389
  _customProperties: he(/* @__PURE__ */ new Set())
390
390
  // devtools custom properties
391
391
  },
392
- z
392
+ G
393
393
  // must be added later
394
394
  // setupStore
395
- ) : z);
396
- n._s.set(t, E);
397
- const B = (n._a && n._a.runWithContext || eo)(() => n._e.run(() => (a = At()).run(() => e({ action: K }))));
398
- for (const v in B) {
399
- const g = B[v];
400
- if (fe(g) && !at(g) || xe(g))
401
- process.env.NODE_ENV !== "production" && r ? O.value[v] = re(B, v) : i || (m && oo(g) && (fe(g) ? g.value = m[v] : Ke(g, m[v])), n.state.value[t][v] = g), process.env.NODE_ENV !== "production" && G.state.push(v);
402
- else if (typeof g == "function") {
403
- const $ = process.env.NODE_ENV !== "production" && r ? g : K(g, v);
404
- B[v] = $, process.env.NODE_ENV !== "production" && (G.actions[v] = g), u.actions[v] = g;
405
- } else process.env.NODE_ENV !== "production" && at(g) && (G.getters[v] = i ? (
395
+ ) : G);
396
+ o._s.set(n, E);
397
+ const B = (o._a && o._a.runWithContext || Xt)(() => o._e.run(() => (s = $t()).run(() => e({ action: z }))));
398
+ for (const g in B) {
399
+ const y = B[g];
400
+ if (pe(y) && !at(y) || Te(y))
401
+ process.env.NODE_ENV !== "production" && r ? k.value[g] = re(B, g) : a || (m && eo(y) && (pe(y) ? y.value = m[g] : Ke(y, m[g])), o.state.value[n][g] = y), process.env.NODE_ENV !== "production" && L.state.push(g);
402
+ else if (typeof y == "function") {
403
+ const D = process.env.NODE_ENV !== "production" && r ? y : z(y, g);
404
+ B[g] = D, process.env.NODE_ENV !== "production" && (L.actions[g] = y), c.actions[g] = y;
405
+ } else process.env.NODE_ENV !== "production" && at(y) && (L.getters[g] = a ? (
406
406
  // @ts-expect-error
407
- o.getters[v]
408
- ) : g, le && (B._getters || // @ts-expect-error: same
409
- (B._getters = he([]))).push(v));
407
+ t.getters[g]
408
+ ) : y, ie && (B._getters || // @ts-expect-error: same
409
+ (B._getters = he([]))).push(g));
410
410
  }
411
- if (Z(E, B), Z(vt(E), B), Object.defineProperty(E, "$state", {
412
- get: () => process.env.NODE_ENV !== "production" && r ? O.value : n.state.value[t],
413
- set: (v) => {
411
+ if (q(E, B), q(vt(E), B), Object.defineProperty(E, "$state", {
412
+ get: () => process.env.NODE_ENV !== "production" && r ? k.value : o.state.value[n],
413
+ set: (g) => {
414
414
  if (process.env.NODE_ENV !== "production" && r)
415
415
  throw new Error("cannot set hotState");
416
- x((g) => {
417
- Z(g, v);
416
+ T((y) => {
417
+ q(y, g);
418
418
  });
419
419
  }
420
- }), process.env.NODE_ENV !== "production" && (E._hotUpdate = he((v) => {
421
- E._hotUpdating = !0, v._hmrPayload.state.forEach((g) => {
422
- if (g in E.$state) {
423
- const $ = v.$state[g], M = E.$state[g];
424
- typeof $ == "object" && se($) && se(M) ? Et($, M) : v.$state[g] = M;
420
+ }), process.env.NODE_ENV !== "production" && (E._hotUpdate = he((g) => {
421
+ E._hotUpdating = !0, g._hmrPayload.state.forEach((y) => {
422
+ if (y in E.$state) {
423
+ const D = g.$state[y], F = E.$state[y];
424
+ typeof D == "object" && ae(D) && ae(F) ? _t(D, F) : g.$state[y] = F;
425
425
  }
426
- E[g] = re(v.$state, g);
427
- }), Object.keys(E.$state).forEach((g) => {
428
- g in v.$state || delete E[g];
429
- }), f = !1, p = !1, n.state.value[t] = re(v._hmrPayload, "hotState"), p = !0, ae().then(() => {
430
- f = !0;
426
+ E[y] = re(g.$state, y);
427
+ }), Object.keys(E.$state).forEach((y) => {
428
+ y in g.$state || delete E[y];
429
+ }), u = !1, w = !1, o.state.value[n] = re(g._hmrPayload, "hotState"), w = !0, de().then(() => {
430
+ u = !0;
431
431
  });
432
- for (const g in v._hmrPayload.actions) {
433
- const $ = v[g];
434
- E[g] = //
435
- K($, g);
432
+ for (const y in g._hmrPayload.actions) {
433
+ const D = g[y];
434
+ E[y] = //
435
+ z(D, y);
436
436
  }
437
- for (const g in v._hmrPayload.getters) {
438
- const $ = v._hmrPayload.getters[g], M = i ? (
437
+ for (const y in g._hmrPayload.getters) {
438
+ const D = g._hmrPayload.getters[y], F = a ? (
439
439
  // special handling of options api
440
- I(() => (Ce(n), $.call(E, E)))
441
- ) : $;
442
- E[g] = //
443
- M;
440
+ R(() => ($e(o), D.call(E, E)))
441
+ ) : D;
442
+ E[y] = //
443
+ F;
444
444
  }
445
- Object.keys(E._hmrPayload.getters).forEach((g) => {
446
- g in v._hmrPayload.getters || delete E[g];
447
- }), Object.keys(E._hmrPayload.actions).forEach((g) => {
448
- g in v._hmrPayload.actions || delete E[g];
449
- }), E._hmrPayload = v._hmrPayload, E._getters = v._getters, E._hotUpdating = !1;
450
- })), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && le) {
451
- const v = {
445
+ Object.keys(E._hmrPayload.getters).forEach((y) => {
446
+ y in g._hmrPayload.getters || delete E[y];
447
+ }), Object.keys(E._hmrPayload.actions).forEach((y) => {
448
+ y in g._hmrPayload.actions || delete E[y];
449
+ }), E._hmrPayload = g._hmrPayload, E._getters = g._getters, E._hotUpdating = !1;
450
+ })), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && ie) {
451
+ const g = {
452
452
  writable: !0,
453
453
  configurable: !0,
454
454
  // avoid warning on devtools trying to display this property
455
455
  enumerable: !1
456
456
  };
457
- ["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((g) => {
458
- Object.defineProperty(E, g, Z({ value: E[g] }, v));
457
+ ["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((y) => {
458
+ Object.defineProperty(E, y, q({ value: E[y] }, g));
459
459
  });
460
460
  }
461
- return n._p.forEach((v) => {
462
- if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && le) {
463
- const g = a.run(() => v({
461
+ return o._p.forEach((g) => {
462
+ if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && ie) {
463
+ const y = s.run(() => g({
464
464
  store: E,
465
- app: n._a,
466
- pinia: n,
467
- options: u
465
+ app: o._a,
466
+ pinia: o,
467
+ options: c
468
468
  }));
469
- Object.keys(g || {}).forEach(($) => E._customProperties.add($)), Z(E, g);
469
+ Object.keys(y || {}).forEach((D) => E._customProperties.add(D)), q(E, y);
470
470
  } else
471
- Z(E, a.run(() => v({
471
+ q(E, s.run(() => g({
472
472
  store: E,
473
- app: n._a,
474
- pinia: n,
475
- options: u
473
+ app: o._a,
474
+ pinia: o,
475
+ options: c
476
476
  })));
477
477
  }), process.env.NODE_ENV !== "production" && E.$state && typeof E.$state == "object" && typeof E.$state.constructor == "function" && !E.$state.constructor.toString().includes("[native code]") && console.warn(`[🍍]: The "state" must be a plain object. It cannot be
478
478
  state: () => new MyClass()
479
- Found in store "${E.$id}".`), m && i && o.hydrate && o.hydrate(E.$state, m), f = !0, p = !0, E;
479
+ Found in store "${E.$id}".`), m && a && t.hydrate && t.hydrate(E.$state, m), u = !0, w = !0, E;
480
480
  }
481
481
  // @__NO_SIDE_EFFECTS__
482
- function no(t, e, o) {
483
- let n;
482
+ function to(n, e, t) {
483
+ let o;
484
484
  const r = typeof e == "function";
485
- n = r ? o : e;
486
- function i(a, u) {
487
- const c = ze();
488
- if (a = // in test mode, ignore the argument provided as we can always retrieve a
485
+ o = r ? t : e;
486
+ function a(s, c) {
487
+ const d = ze();
488
+ if (s = // in test mode, ignore the argument provided as we can always retrieve a
489
489
  // pinia instance with getActivePinia()
490
- (process.env.NODE_ENV === "test" && oe && oe._testing ? null : a) || (c ? be(Je, null) : null), a && Ce(a), process.env.NODE_ENV !== "production" && !oe)
490
+ (process.env.NODE_ENV === "test" && oe && oe._testing ? null : s) || (d ? we(qe, null) : null), s && $e(s), process.env.NODE_ENV !== "production" && !oe)
491
491
  throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
492
492
  See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
493
493
  This will fail in production.`);
494
- a = oe, a._s.has(t) || (r ? qe(t, e, n, a) : st(t, n, a), process.env.NODE_ENV !== "production" && (i._pinia = a));
495
- const f = a._s.get(t);
496
- if (process.env.NODE_ENV !== "production" && u) {
497
- const p = "__hot:" + t, b = r ? qe(p, e, n, a, !0) : st(p, Z({}, n), a, !0);
498
- u._hotUpdate(b), delete a.state.value[p], a._s.delete(p);
494
+ s = oe, s._s.has(n) || (r ? Ze(n, e, o, s) : st(n, o, s), process.env.NODE_ENV !== "production" && (a._pinia = s));
495
+ const u = s._s.get(n);
496
+ if (process.env.NODE_ENV !== "production" && c) {
497
+ const w = "__hot:" + n, v = r ? Ze(w, e, o, s, !0) : st(w, q({}, o), s, !0);
498
+ c._hotUpdate(v), delete s.state.value[w], s._s.delete(w);
499
499
  }
500
- if (process.env.NODE_ENV !== "production" && le) {
501
- const p = gt();
502
- if (p && p.proxy && // avoid adding stores that are just built for hot module replacement
503
- !u) {
504
- const b = p.proxy, h = "_pStores" in b ? b._pStores : b._pStores = {};
505
- h[t] = f;
500
+ if (process.env.NODE_ENV !== "production" && ie) {
501
+ const w = gt();
502
+ if (w && w.proxy && // avoid adding stores that are just built for hot module replacement
503
+ !c) {
504
+ const v = w.proxy, h = "_pStores" in v ? v._pStores : v._pStores = {};
505
+ h[n] = u;
506
506
  }
507
507
  }
508
- return f;
508
+ return u;
509
509
  }
510
- return i.$id = t, i;
510
+ return a.$id = n, a;
511
511
  }
512
- function ro(t) {
513
- const e = vt(t), o = {};
514
- for (const n in e) {
515
- const r = e[n];
516
- r.effect ? o[n] = // ...
517
- I({
518
- get: () => t[n],
519
- set(i) {
520
- t[n] = i;
512
+ function oo(n) {
513
+ const e = vt(n), t = {};
514
+ for (const o in e) {
515
+ const r = e[o];
516
+ r.effect ? t[o] = // ...
517
+ R({
518
+ get: () => n[o],
519
+ set(a) {
520
+ n[o] = a;
521
521
  }
522
- }) : (fe(r) || xe(r)) && (o[n] = // ---
523
- re(t, n));
522
+ }) : (pe(r) || Te(r)) && (t[o] = // ---
523
+ re(n, o));
524
524
  }
525
- return o;
525
+ return t;
526
526
  }
527
- const ao = typeof window < "u" && typeof document < "u";
527
+ const no = typeof window < "u" && typeof document < "u";
528
528
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
529
- const so = Object.prototype.toString, io = (t) => so.call(t) === "[object Object]", lo = () => {
529
+ const ro = Object.prototype.toString, ao = (n) => ro.call(n) === "[object Object]", so = () => {
530
530
  };
531
- function co(...t) {
532
- if (t.length !== 1) return re(...t);
533
- const e = t[0];
534
- return typeof e == "function" ? Te(Ye(() => ({
531
+ function io(...n) {
532
+ if (n.length !== 1) return re(...n);
533
+ const e = n[0];
534
+ return typeof e == "function" ? Pe(et(() => ({
535
535
  get: e,
536
- set: lo
537
- }))) : C(e);
536
+ set: so
537
+ }))) : $(e);
538
538
  }
539
- function uo(t, e) {
540
- function o(...n) {
541
- return new Promise((r, i) => {
542
- Promise.resolve(t(() => e.apply(this, n), {
539
+ function lo(n, e) {
540
+ function t(...o) {
541
+ return new Promise((r, a) => {
542
+ Promise.resolve(n(() => e.apply(this, o), {
543
543
  fn: e,
544
544
  thisArg: this,
545
- args: n
546
- })).then(r).catch(i);
545
+ args: o
546
+ })).then(r).catch(a);
547
547
  });
548
548
  }
549
- return o;
549
+ return t;
550
550
  }
551
- const kt = (t) => t();
552
- function fo(t = kt, e = {}) {
553
- const { initialState: o = "active" } = e, n = co(o === "active");
551
+ const kt = (n) => n();
552
+ function co(n = kt, e = {}) {
553
+ const { initialState: t = "active" } = e, o = io(t === "active");
554
554
  function r() {
555
- n.value = !1;
555
+ o.value = !1;
556
556
  }
557
- function i() {
558
- n.value = !0;
557
+ function a() {
558
+ o.value = !0;
559
559
  }
560
- const a = (...u) => {
561
- n.value && t(...u);
560
+ const s = (...c) => {
561
+ o.value && n(...c);
562
562
  };
563
563
  return {
564
- isActive: Te(n),
564
+ isActive: Pe(o),
565
565
  pause: r,
566
- resume: i,
567
- eventFilter: a
566
+ resume: a,
567
+ eventFilter: s
568
568
  };
569
569
  }
570
- function Me(t) {
571
- return Array.isArray(t) ? t : [t];
570
+ function Fe(n) {
571
+ return Array.isArray(n) ? n : [n];
572
572
  }
573
- function po(t) {
573
+ function uo(n) {
574
574
  return gt();
575
575
  }
576
- function ho(t, e, o = {}) {
577
- const { eventFilter: n = kt, ...r } = o;
578
- return L(t, uo(n, e), r);
576
+ function po(n, e, t = {}) {
577
+ const { eventFilter: o = kt, ...r } = t;
578
+ return H(n, lo(o, e), r);
579
579
  }
580
- function vo(t, e, o = {}) {
581
- const { eventFilter: n, initialState: r = "active", ...i } = o, { eventFilter: a, pause: u, resume: c, isActive: f } = fo(n, { initialState: r });
580
+ function fo(n, e, t = {}) {
581
+ const { eventFilter: o, initialState: r = "active", ...a } = t, { eventFilter: s, pause: c, resume: d, isActive: u } = co(o, { initialState: r });
582
582
  return {
583
- stop: ho(t, e, {
584
- ...i,
585
- eventFilter: a
583
+ stop: po(n, e, {
584
+ ...a,
585
+ eventFilter: s
586
586
  }),
587
- pause: u,
588
- resume: c,
589
- isActive: f
587
+ pause: c,
588
+ resume: d,
589
+ isActive: u
590
590
  };
591
591
  }
592
- function go(t, e = !0, o) {
593
- po() ? Ae(t, o) : e ? t() : ae(t);
592
+ function ho(n, e = !0, t) {
593
+ uo() ? xe(n, t) : e ? n() : de(n);
594
594
  }
595
- function mo(t, e, o) {
596
- return L(t, e, {
597
- ...o,
595
+ function vo(n, e, t) {
596
+ return H(n, e, {
597
+ ...t,
598
598
  immediate: !0
599
599
  });
600
600
  }
601
- const Re = ao ? window : void 0;
602
- function yo(t) {
601
+ const Ie = no ? window : void 0;
602
+ function go(n) {
603
603
  var e;
604
- const o = Q(t);
605
- return (e = o?.$el) !== null && e !== void 0 ? e : o;
604
+ const t = K(n);
605
+ return (e = t?.$el) !== null && e !== void 0 ? e : t;
606
606
  }
607
- function it(...t) {
608
- const e = (n, r, i, a) => (n.addEventListener(r, i, a), () => n.removeEventListener(r, i, a)), o = I(() => {
609
- const n = Me(Q(t[0])).filter((r) => r != null);
610
- return n.every((r) => typeof r != "string") ? n : void 0;
607
+ function it(...n) {
608
+ const e = (o, r, a, s) => (o.addEventListener(r, a, s), () => o.removeEventListener(r, a, s)), t = R(() => {
609
+ const o = Fe(K(n[0])).filter((r) => r != null);
610
+ return o.every((r) => typeof r != "string") ? o : void 0;
611
611
  });
612
- return mo(() => {
613
- var n, r;
612
+ return vo(() => {
613
+ var o, r;
614
614
  return [
615
- (n = (r = o.value) === null || r === void 0 ? void 0 : r.map((i) => yo(i))) !== null && n !== void 0 ? n : [Re].filter((i) => i != null),
616
- Me(Q(o.value ? t[1] : t[0])),
617
- Me(De(o.value ? t[2] : t[1])),
618
- Q(o.value ? t[3] : t[2])
615
+ (o = (r = t.value) === null || r === void 0 ? void 0 : r.map((a) => go(a))) !== null && o !== void 0 ? o : [Ie].filter((a) => a != null),
616
+ Fe(K(t.value ? n[1] : n[0])),
617
+ Fe(Ne(t.value ? n[2] : n[1])),
618
+ K(t.value ? n[3] : n[2])
619
619
  ];
620
- }, ([n, r, i, a], u, c) => {
621
- if (!n?.length || !r?.length || !i?.length) return;
622
- const f = io(a) ? { ...a } : a, p = n.flatMap((b) => r.flatMap((h) => i.map((_) => e(b, h, _, f))));
623
- c(() => {
624
- p.forEach((b) => b());
620
+ }, ([o, r, a, s], c, d) => {
621
+ if (!o?.length || !r?.length || !a?.length) return;
622
+ const u = ao(s) ? { ...s } : s, w = o.flatMap((v) => r.flatMap((h) => a.map((b) => e(v, h, b, u))));
623
+ d(() => {
624
+ w.forEach((v) => v());
625
625
  });
626
626
  }, { flush: "post" });
627
627
  }
628
- const Ee = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, _e = "__vueuse_ssr_handlers__", bo = /* @__PURE__ */ wo();
629
- function wo() {
630
- return _e in Ee || (Ee[_e] = Ee[_e] || {}), Ee[_e];
628
+ const Ee = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, ke = "__vueuse_ssr_handlers__", yo = /* @__PURE__ */ mo();
629
+ function mo() {
630
+ return ke in Ee || (Ee[ke] = Ee[ke] || {}), Ee[ke];
631
631
  }
632
- function So(t, e) {
633
- return bo[t] || e;
632
+ function wo(n, e) {
633
+ return yo[n] || e;
634
634
  }
635
- function Eo(t) {
636
- return t == null ? "any" : t instanceof Set ? "set" : t instanceof Map ? "map" : t instanceof Date ? "date" : typeof t == "boolean" ? "boolean" : typeof t == "string" ? "string" : typeof t == "object" ? "object" : Number.isNaN(t) ? "any" : "number";
635
+ function bo(n) {
636
+ return n == null ? "any" : n instanceof Set ? "set" : n instanceof Map ? "map" : n instanceof Date ? "date" : typeof n == "boolean" ? "boolean" : typeof n == "string" ? "string" : typeof n == "object" ? "object" : Number.isNaN(n) ? "any" : "number";
637
637
  }
638
- const _o = {
638
+ const So = {
639
639
  boolean: {
640
- read: (t) => t === "true",
641
- write: (t) => String(t)
640
+ read: (n) => n === "true",
641
+ write: (n) => String(n)
642
642
  },
643
643
  object: {
644
- read: (t) => JSON.parse(t),
645
- write: (t) => JSON.stringify(t)
644
+ read: (n) => JSON.parse(n),
645
+ write: (n) => JSON.stringify(n)
646
646
  },
647
647
  number: {
648
- read: (t) => Number.parseFloat(t),
649
- write: (t) => String(t)
648
+ read: (n) => Number.parseFloat(n),
649
+ write: (n) => String(n)
650
650
  },
651
651
  any: {
652
- read: (t) => t,
653
- write: (t) => String(t)
652
+ read: (n) => n,
653
+ write: (n) => String(n)
654
654
  },
655
655
  string: {
656
- read: (t) => t,
657
- write: (t) => String(t)
656
+ read: (n) => n,
657
+ write: (n) => String(n)
658
658
  },
659
659
  map: {
660
- read: (t) => new Map(JSON.parse(t)),
661
- write: (t) => JSON.stringify(Array.from(t.entries()))
660
+ read: (n) => new Map(JSON.parse(n)),
661
+ write: (n) => JSON.stringify(Array.from(n.entries()))
662
662
  },
663
663
  set: {
664
- read: (t) => new Set(JSON.parse(t)),
665
- write: (t) => JSON.stringify(Array.from(t))
664
+ read: (n) => new Set(JSON.parse(n)),
665
+ write: (n) => JSON.stringify(Array.from(n))
666
666
  },
667
667
  date: {
668
- read: (t) => new Date(t),
669
- write: (t) => t.toISOString()
668
+ read: (n) => new Date(n),
669
+ write: (n) => n.toISOString()
670
670
  }
671
671
  }, lt = "vueuse-storage";
672
- function ko(t, e, o, n = {}) {
672
+ function _o(n, e, t, o = {}) {
673
673
  var r;
674
- const { flush: i = "pre", deep: a = !0, listenToStorageChanges: u = !0, writeDefaults: c = !0, mergeDefaults: f = !1, shallow: p, window: b = Re, eventFilter: h, onError: _ = (k) => {
675
- console.error(k);
676
- }, initOnMounted: m } = n, O = (p ? Se : C)(e), R = I(() => Q(t));
677
- if (!o) try {
678
- o = So("getDefaultStorage", () => Re?.localStorage)();
679
- } catch (k) {
680
- _(k);
681
- }
682
- if (!o) return O;
683
- const x = Q(e), H = Eo(x), U = (r = n.serializer) !== null && r !== void 0 ? r : _o[H], { pause: K, resume: G } = vo(O, (k) => v(k), {
684
- flush: i,
685
- deep: a,
674
+ const { flush: a = "pre", deep: s = !0, listenToStorageChanges: c = !0, writeDefaults: d = !0, mergeDefaults: u = !1, shallow: w, window: v = Ie, eventFilter: h, onError: b = (N) => {
675
+ console.error(N);
676
+ }, initOnMounted: m } = o, k = (w ? Se : $)(e), I = R(() => K(n));
677
+ if (!t) try {
678
+ t = wo("getDefaultStorage", () => Ie?.localStorage)();
679
+ } catch (N) {
680
+ b(N);
681
+ }
682
+ if (!t) return k;
683
+ const T = K(e), Z = bo(T), U = (r = o.serializer) !== null && r !== void 0 ? r : So[Z], { pause: z, resume: L } = fo(k, (N) => g(N), {
684
+ flush: a,
685
+ deep: s,
686
686
  eventFilter: h
687
687
  });
688
- L(R, () => $(), { flush: i });
689
- let z = !1;
690
- const E = (k) => {
691
- m && !z || $(k);
692
- }, Y = (k) => {
693
- m && !z || M(k);
688
+ H(I, () => D(), { flush: a });
689
+ let G = !1;
690
+ const E = (N) => {
691
+ m && !G || D(N);
692
+ }, Y = (N) => {
693
+ m && !G || F(N);
694
694
  };
695
- b && u && (o instanceof Storage ? it(b, "storage", E, { passive: !0 }) : it(b, lt, Y)), m ? go(() => {
696
- z = !0, $();
697
- }) : $();
698
- function B(k, T) {
699
- if (b) {
700
- const F = {
701
- key: R.value,
702
- oldValue: k,
703
- newValue: T,
704
- storageArea: o
695
+ v && c && (t instanceof Storage ? it(v, "storage", E, { passive: !0 }) : it(v, lt, Y)), m ? ho(() => {
696
+ G = !0, D();
697
+ }) : D();
698
+ function B(N, V) {
699
+ if (v) {
700
+ const M = {
701
+ key: I.value,
702
+ oldValue: N,
703
+ newValue: V,
704
+ storageArea: t
705
705
  };
706
- b.dispatchEvent(o instanceof Storage ? new StorageEvent("storage", F) : new CustomEvent(lt, { detail: F }));
706
+ v.dispatchEvent(t instanceof Storage ? new StorageEvent("storage", M) : new CustomEvent(lt, { detail: M }));
707
707
  }
708
708
  }
709
- function v(k) {
709
+ function g(N) {
710
710
  try {
711
- const T = o.getItem(R.value);
712
- if (k == null)
713
- B(T, null), o.removeItem(R.value);
711
+ const V = t.getItem(I.value);
712
+ if (N == null)
713
+ B(V, null), t.removeItem(I.value);
714
714
  else {
715
- const F = U.write(k);
716
- T !== F && (o.setItem(R.value, F), B(T, F));
715
+ const M = U.write(N);
716
+ V !== M && (t.setItem(I.value, M), B(V, M));
717
717
  }
718
- } catch (T) {
719
- _(T);
718
+ } catch (V) {
719
+ b(V);
720
720
  }
721
721
  }
722
- function g(k) {
723
- const T = k ? k.newValue : o.getItem(R.value);
724
- if (T == null)
725
- return c && x != null && o.setItem(R.value, U.write(x)), x;
726
- if (!k && f) {
727
- const F = U.read(T);
728
- return typeof f == "function" ? f(F, x) : H === "object" && !Array.isArray(F) ? {
729
- ...x,
730
- ...F
731
- } : F;
732
- } else return typeof T != "string" ? T : U.read(T);
733
- }
734
- function $(k) {
735
- if (!(k && k.storageArea !== o)) {
736
- if (k && k.key == null) {
737
- O.value = x;
722
+ function y(N) {
723
+ const V = N ? N.newValue : t.getItem(I.value);
724
+ if (V == null)
725
+ return d && T != null && t.setItem(I.value, U.write(T)), T;
726
+ if (!N && u) {
727
+ const M = U.read(V);
728
+ return typeof u == "function" ? u(M, T) : Z === "object" && !Array.isArray(M) ? {
729
+ ...T,
730
+ ...M
731
+ } : M;
732
+ } else return typeof V != "string" ? V : U.read(V);
733
+ }
734
+ function D(N) {
735
+ if (!(N && N.storageArea !== t)) {
736
+ if (N && N.key == null) {
737
+ k.value = T;
738
738
  return;
739
739
  }
740
- if (!(k && k.key !== R.value)) {
741
- K();
740
+ if (!(N && N.key !== I.value)) {
741
+ z();
742
742
  try {
743
- const T = U.write(O.value);
744
- (k === void 0 || k?.newValue !== T) && (O.value = g(k));
745
- } catch (T) {
746
- _(T);
743
+ const V = U.write(k.value);
744
+ (N === void 0 || N?.newValue !== V) && (k.value = y(N));
745
+ } catch (V) {
746
+ b(V);
747
747
  } finally {
748
- k ? ae(G) : G();
748
+ N ? de(L) : L();
749
749
  }
750
750
  }
751
751
  }
752
752
  }
753
- function M(k) {
754
- $(k.detail);
753
+ function F(N) {
754
+ D(N.detail);
755
755
  }
756
- return O;
756
+ return k;
757
757
  }
758
- function Do(t, e, o = {}) {
759
- const { window: n = Re } = o;
760
- return ko(t, e, n?.localStorage, o);
758
+ function Eo(n, e, t = {}) {
759
+ const { window: o = Ie } = t;
760
+ return _o(n, e, o?.localStorage, t);
761
761
  }
762
- function Fe() {
762
+ function Le() {
763
763
  return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
764
764
  }
765
- function ke(t) {
765
+ function Ce(n) {
766
766
  const e = {
767
- type: t.type,
768
- clientId: t.clientId,
769
- timestamp: t.timestamp.toISOString()
767
+ type: n.type,
768
+ clientId: n.clientId,
769
+ timestamp: n.timestamp.toISOString()
770
770
  };
771
- return t.operation && (e.operation = {
772
- ...t.operation,
773
- timestamp: t.operation.timestamp.toISOString()
774
- }), t.operations && (e.operations = t.operations.map((o) => ({
775
- ...o,
776
- timestamp: o.timestamp.toISOString()
771
+ return n.operation && (e.operation = {
772
+ ...n.operation,
773
+ timestamp: n.operation.timestamp.toISOString()
774
+ }), n.operations && (e.operations = n.operations.map((t) => ({
775
+ ...t,
776
+ timestamp: t.timestamp.toISOString()
777
777
  }))), e;
778
778
  }
779
- function Oo(t) {
779
+ function ko(n) {
780
780
  const e = {
781
- type: t.type,
782
- clientId: t.clientId,
783
- timestamp: new Date(t.timestamp)
781
+ type: n.type,
782
+ clientId: n.clientId,
783
+ timestamp: new Date(n.timestamp)
784
784
  };
785
- return t.operation && (e.operation = {
786
- ...t.operation,
787
- timestamp: new Date(t.operation.timestamp)
788
- }), t.operations && (e.operations = t.operations.map((o) => ({
789
- ...o,
790
- timestamp: new Date(o.timestamp)
785
+ return n.operation && (e.operation = {
786
+ ...n.operation,
787
+ timestamp: new Date(n.operation.timestamp)
788
+ }), n.operations && (e.operations = n.operations.map((t) => ({
789
+ ...t,
790
+ timestamp: new Date(t.timestamp)
791
791
  }))), e;
792
792
  }
793
- const Dt = /* @__PURE__ */ no("hst-operation-log", () => {
794
- const t = C({
793
+ const Ct = /* @__PURE__ */ to("hst-operation-log", () => {
794
+ const n = $({
795
795
  maxOperations: 100,
796
796
  enableCrossTabSync: !0,
797
797
  autoSyncInterval: 3e4,
798
798
  enablePersistence: !1,
799
799
  persistenceKeyPrefix: "stonecrop-ops"
800
- }), e = C([]), o = C(-1), n = C(Fe()), r = C(!1), i = C([]), a = C(null), u = I(() => o.value < 0 ? !1 : e.value[o.value]?.reversible ?? !1), c = I(() => o.value < e.value.length - 1), f = I(() => {
801
- let d = 0;
802
- for (let s = o.value; s >= 0 && e.value[s]?.reversible; s--)
803
- d++;
804
- return d;
805
- }), p = I(() => e.value.length - 1 - o.value), b = I(() => ({
806
- canUndo: u.value,
807
- canRedo: c.value,
808
- undoCount: f.value,
809
- redoCount: p.value,
810
- currentIndex: o.value
800
+ }), e = $([]), t = $(-1), o = $(Le()), r = $(!1), a = $([]), s = $(null), c = R(() => t.value < 0 ? !1 : e.value[t.value]?.reversible ?? !1), d = R(() => t.value < e.value.length - 1), u = R(() => {
801
+ let p = 0;
802
+ for (let f = t.value; f >= 0 && e.value[f]?.reversible; f--)
803
+ p++;
804
+ return p;
805
+ }), w = R(() => e.value.length - 1 - t.value), v = R(() => ({
806
+ canUndo: c.value,
807
+ canRedo: d.value,
808
+ undoCount: u.value,
809
+ redoCount: w.value,
810
+ currentIndex: t.value
811
811
  }));
812
- function h(d) {
813
- t.value = { ...t.value, ...d }, t.value.enablePersistence && (w(), S()), t.value.enableCrossTabSync && g();
812
+ function h(p) {
813
+ n.value = { ...n.value, ...p }, n.value.enablePersistence && (_(), S()), n.value.enableCrossTabSync && y();
814
814
  }
815
- function _(d, s = "user") {
816
- const l = {
817
- ...d,
818
- id: Fe(),
815
+ function b(p, f = "user") {
816
+ const i = {
817
+ ...p,
818
+ id: Le(),
819
819
  timestamp: /* @__PURE__ */ new Date(),
820
- source: s,
821
- userId: t.value.userId
820
+ source: f,
821
+ userId: n.value.userId
822
822
  };
823
- if (t.value.operationFilter && !t.value.operationFilter(l))
824
- return l.id;
823
+ if (n.value.operationFilter && !n.value.operationFilter(i))
824
+ return i.id;
825
825
  if (r.value)
826
- return i.value.push(l), l.id;
827
- if (o.value < e.value.length - 1 && (e.value = e.value.slice(0, o.value + 1)), e.value.push(l), o.value++, t.value.maxOperations && e.value.length > t.value.maxOperations) {
828
- const y = e.value.length - t.value.maxOperations;
829
- e.value = e.value.slice(y), o.value -= y;
826
+ return a.value.push(i), i.id;
827
+ if (t.value < e.value.length - 1 && (e.value = e.value.slice(0, t.value + 1)), e.value.push(i), t.value++, n.value.maxOperations && e.value.length > n.value.maxOperations) {
828
+ const l = e.value.length - n.value.maxOperations;
829
+ e.value = e.value.slice(l), t.value -= l;
830
830
  }
831
- return t.value.enableCrossTabSync && $(l), l.id;
831
+ return n.value.enableCrossTabSync && D(i), i.id;
832
832
  }
833
833
  function m() {
834
- r.value = !0, i.value = [], a.value = Fe();
834
+ r.value = !0, a.value = [], s.value = Le();
835
835
  }
836
- function O(d) {
837
- if (!r.value || i.value.length === 0)
838
- return r.value = !1, i.value = [], a.value = null, null;
839
- const s = a.value, l = i.value.every((j) => j.reversible), y = {
840
- id: s,
836
+ function k(p) {
837
+ if (!r.value || a.value.length === 0)
838
+ return r.value = !1, a.value = [], s.value = null, null;
839
+ const f = s.value, i = a.value.every((O) => O.reversible), l = {
840
+ id: f,
841
841
  type: "batch",
842
842
  path: "",
843
843
  // Batch doesn't have a single path
844
844
  fieldname: "",
845
845
  beforeValue: null,
846
846
  afterValue: null,
847
- doctype: i.value[0]?.doctype || "",
847
+ doctype: a.value[0]?.doctype || "",
848
848
  timestamp: /* @__PURE__ */ new Date(),
849
849
  source: "user",
850
- reversible: l,
851
- irreversibleReason: l ? void 0 : "Contains irreversible operations",
852
- childOperationIds: i.value.map((j) => j.id),
853
- metadata: { description: d }
850
+ reversible: i,
851
+ irreversibleReason: i ? void 0 : "Contains irreversible operations",
852
+ childOperationIds: a.value.map((O) => O.id),
853
+ metadata: { description: p }
854
854
  };
855
- i.value.forEach((j) => {
856
- j.parentOperationId = s;
857
- }), e.value.push(...i.value, y), o.value = e.value.length - 1, t.value.enableCrossTabSync && M(i.value, y);
858
- const N = s;
859
- return r.value = !1, i.value = [], a.value = null, N;
860
- }
861
- function R() {
862
- r.value = !1, i.value = [], a.value = null;
863
- }
864
- function x(d) {
865
- if (!u.value) return !1;
866
- const s = e.value[o.value];
867
- if (!s.reversible)
868
- return typeof console < "u" && s.irreversibleReason && console.warn("Cannot undo irreversible operation:", s.irreversibleReason), !1;
855
+ a.value.forEach((O) => {
856
+ O.parentOperationId = f;
857
+ }), e.value.push(...a.value, l), t.value = e.value.length - 1, n.value.enableCrossTabSync && F(a.value, l);
858
+ const A = f;
859
+ return r.value = !1, a.value = [], s.value = null, A;
860
+ }
861
+ function I() {
862
+ r.value = !1, a.value = [], s.value = null;
863
+ }
864
+ function T(p) {
865
+ if (!c.value) return !1;
866
+ const f = e.value[t.value];
867
+ if (!f.reversible)
868
+ return typeof console < "u" && f.irreversibleReason && console.warn("Cannot undo irreversible operation:", f.irreversibleReason), !1;
869
869
  try {
870
- if (s.type === "batch" && s.childOperationIds)
871
- for (let l = s.childOperationIds.length - 1; l >= 0; l--) {
872
- const y = s.childOperationIds[l], N = e.value.find((j) => j.id === y);
873
- N && U(N, d);
870
+ if (f.type === "batch" && f.childOperationIds)
871
+ for (let i = f.childOperationIds.length - 1; i >= 0; i--) {
872
+ const l = f.childOperationIds[i], A = e.value.find((O) => O.id === l);
873
+ A && U(A, p);
874
874
  }
875
875
  else
876
- U(s, d);
877
- return o.value--, t.value.enableCrossTabSync && k(s), !0;
878
- } catch (l) {
879
- return typeof console < "u" && console.error("Undo failed:", l), !1;
876
+ U(f, p);
877
+ return t.value--, n.value.enableCrossTabSync && N(f), !0;
878
+ } catch (i) {
879
+ return typeof console < "u" && console.error("Undo failed:", i), !1;
880
880
  }
881
881
  }
882
- function H(d) {
883
- if (!c.value) return !1;
884
- const s = e.value[o.value + 1];
882
+ function Z(p) {
883
+ if (!d.value) return !1;
884
+ const f = e.value[t.value + 1];
885
885
  try {
886
- if (s.type === "batch" && s.childOperationIds)
887
- for (const l of s.childOperationIds) {
888
- const y = e.value.find((N) => N.id === l);
889
- y && K(y, d);
886
+ if (f.type === "batch" && f.childOperationIds)
887
+ for (const i of f.childOperationIds) {
888
+ const l = e.value.find((A) => A.id === i);
889
+ l && z(l, p);
890
890
  }
891
891
  else
892
- K(s, d);
893
- return o.value++, t.value.enableCrossTabSync && T(s), !0;
894
- } catch (l) {
895
- return typeof console < "u" && console.error("Redo failed:", l), !1;
892
+ z(f, p);
893
+ return t.value++, n.value.enableCrossTabSync && V(f), !0;
894
+ } catch (i) {
895
+ return typeof console < "u" && console.error("Redo failed:", i), !1;
896
896
  }
897
897
  }
898
- function U(d, s) {
899
- (d.type === "set" || d.type === "delete") && s && typeof s.set == "function" && s.set(d.path, d.beforeValue, "undo");
898
+ function U(p, f) {
899
+ (p.type === "set" || p.type === "delete") && f && typeof f.set == "function" && f.set(p.path, p.beforeValue, "undo");
900
900
  }
901
- function K(d, s) {
902
- (d.type === "set" || d.type === "delete") && s && typeof s.set == "function" && s.set(d.path, d.afterValue, "redo");
901
+ function z(p, f) {
902
+ (p.type === "set" || p.type === "delete") && f && typeof f.set == "function" && f.set(p.path, p.afterValue, "redo");
903
903
  }
904
- function G() {
905
- const d = e.value.filter((l) => l.reversible).length, s = e.value.map((l) => l.timestamp);
904
+ function L() {
905
+ const p = e.value.filter((i) => i.reversible).length, f = e.value.map((i) => i.timestamp);
906
906
  return {
907
907
  operations: [...e.value],
908
- currentIndex: o.value,
908
+ currentIndex: t.value,
909
909
  totalOperations: e.value.length,
910
- reversibleOperations: d,
911
- irreversibleOperations: e.value.length - d,
912
- oldestOperation: s.length > 0 ? new Date(Math.min(...s.map((l) => l.getTime()))) : void 0,
913
- newestOperation: s.length > 0 ? new Date(Math.max(...s.map((l) => l.getTime()))) : void 0
910
+ reversibleOperations: p,
911
+ irreversibleOperations: e.value.length - p,
912
+ oldestOperation: f.length > 0 ? new Date(Math.min(...f.map((i) => i.getTime()))) : void 0,
913
+ newestOperation: f.length > 0 ? new Date(Math.max(...f.map((i) => i.getTime()))) : void 0
914
914
  };
915
915
  }
916
- function z() {
917
- e.value = [], o.value = -1;
916
+ function G() {
917
+ e.value = [], t.value = -1;
918
918
  }
919
- function E(d, s) {
920
- return e.value.filter((l) => l.doctype === d && (s === void 0 || l.recordId === s));
919
+ function E(p, f) {
920
+ return e.value.filter((i) => i.doctype === p && (f === void 0 || i.recordId === f));
921
921
  }
922
- function Y(d, s) {
923
- const l = e.value.find((y) => y.id === d);
924
- l && (l.reversible = !1, l.irreversibleReason = s);
922
+ function Y(p, f) {
923
+ const i = e.value.find((l) => l.id === p);
924
+ i && (i.reversible = !1, i.irreversibleReason = f);
925
925
  }
926
- function B(d, s, l, y = "success", N) {
927
- const j = {
926
+ function B(p, f, i, l = "success", A) {
927
+ const O = {
928
928
  type: "action",
929
- path: l && l.length > 0 ? `${d}.${l[0]}` : d,
929
+ path: i && i.length > 0 ? `${p}.${i[0]}` : p,
930
930
  fieldname: "",
931
931
  beforeValue: null,
932
932
  afterValue: null,
933
- doctype: d,
934
- recordId: l && l.length > 0 ? l[0] : void 0,
933
+ doctype: p,
934
+ recordId: i && i.length > 0 ? i[0] : void 0,
935
935
  reversible: !1,
936
936
  // Actions are typically not reversible
937
- actionName: s,
938
- actionRecordIds: l,
939
- actionResult: y,
940
- actionError: N
937
+ actionName: f,
938
+ actionRecordIds: i,
939
+ actionResult: l,
940
+ actionError: A
941
941
  };
942
- return _(j);
943
- }
944
- let v = null;
945
- function g() {
946
- typeof window > "u" || !window.BroadcastChannel || (v = new BroadcastChannel("stonecrop-operation-log"), v.addEventListener("message", (d) => {
947
- const s = d.data;
948
- if (!s || typeof s != "object") return;
949
- const l = Oo(s);
950
- l.clientId !== n.value && (l.type === "operation" && l.operation ? (e.value.push({ ...l.operation, source: "sync" }), o.value = e.value.length - 1) : l.type === "operation" && l.operations && (e.value.push(...l.operations.map((y) => ({ ...y, source: "sync" }))), o.value = e.value.length - 1));
942
+ return b(O);
943
+ }
944
+ let g = null;
945
+ function y() {
946
+ typeof window > "u" || !window.BroadcastChannel || (g = new BroadcastChannel("stonecrop-operation-log"), g.addEventListener("message", (p) => {
947
+ const f = p.data;
948
+ if (!f || typeof f != "object") return;
949
+ const i = ko(f);
950
+ i.clientId !== o.value && (i.type === "operation" && i.operation ? (e.value.push({ ...i.operation, source: "sync" }), t.value = e.value.length - 1) : i.type === "operation" && i.operations && (e.value.push(...i.operations.map((l) => ({ ...l, source: "sync" }))), t.value = e.value.length - 1));
951
951
  }));
952
952
  }
953
- function $(d) {
954
- if (!v) return;
955
- const s = {
953
+ function D(p) {
954
+ if (!g) return;
955
+ const f = {
956
956
  type: "operation",
957
- operation: d,
958
- clientId: n.value,
957
+ operation: p,
958
+ clientId: o.value,
959
959
  timestamp: /* @__PURE__ */ new Date()
960
960
  };
961
- v.postMessage(ke(s));
961
+ g.postMessage(Ce(f));
962
962
  }
963
- function M(d, s) {
964
- if (!v) return;
965
- const l = {
963
+ function F(p, f) {
964
+ if (!g) return;
965
+ const i = {
966
966
  type: "operation",
967
- operations: [...d, s],
968
- clientId: n.value,
967
+ operations: [...p, f],
968
+ clientId: o.value,
969
969
  timestamp: /* @__PURE__ */ new Date()
970
970
  };
971
- v.postMessage(ke(l));
971
+ g.postMessage(Ce(i));
972
972
  }
973
- function k(d) {
974
- if (!v) return;
975
- const s = {
973
+ function N(p) {
974
+ if (!g) return;
975
+ const f = {
976
976
  type: "undo",
977
- operation: d,
978
- clientId: n.value,
977
+ operation: p,
978
+ clientId: o.value,
979
979
  timestamp: /* @__PURE__ */ new Date()
980
980
  };
981
- v.postMessage(ke(s));
981
+ g.postMessage(Ce(f));
982
982
  }
983
- function T(d) {
984
- if (!v) return;
985
- const s = {
983
+ function V(p) {
984
+ if (!g) return;
985
+ const f = {
986
986
  type: "redo",
987
- operation: d,
988
- clientId: n.value,
987
+ operation: p,
988
+ clientId: o.value,
989
989
  timestamp: /* @__PURE__ */ new Date()
990
990
  };
991
- v.postMessage(ke(s));
991
+ g.postMessage(Ce(f));
992
992
  }
993
- const F = Do("stonecrop-ops-operations", null, {
993
+ const M = Eo("stonecrop-ops-operations", null, {
994
994
  serializer: {
995
- read: (d) => {
995
+ read: (p) => {
996
996
  try {
997
- return JSON.parse(d);
997
+ return JSON.parse(p);
998
998
  } catch {
999
999
  return null;
1000
1000
  }
1001
1001
  },
1002
- write: (d) => d ? JSON.stringify(d) : ""
1002
+ write: (p) => p ? JSON.stringify(p) : ""
1003
1003
  }
1004
1004
  });
1005
- function w() {
1005
+ function _() {
1006
1006
  if (!(typeof window > "u"))
1007
1007
  try {
1008
- const d = F.value;
1009
- d && Array.isArray(d.operations) && (e.value = d.operations.map((s) => ({
1010
- ...s,
1011
- timestamp: new Date(s.timestamp)
1012
- })), o.value = d.currentIndex ?? -1);
1013
- } catch (d) {
1014
- typeof console < "u" && console.error("Failed to load operations from persistence:", d);
1008
+ const p = M.value;
1009
+ p && Array.isArray(p.operations) && (e.value = p.operations.map((f) => ({
1010
+ ...f,
1011
+ timestamp: new Date(f.timestamp)
1012
+ })), t.value = p.currentIndex ?? -1);
1013
+ } catch (p) {
1014
+ typeof console < "u" && console.error("Failed to load operations from persistence:", p);
1015
1015
  }
1016
1016
  }
1017
- function D() {
1017
+ function C() {
1018
1018
  if (!(typeof window > "u"))
1019
1019
  try {
1020
- F.value = {
1021
- operations: e.value.map((d) => ({
1022
- ...d,
1023
- timestamp: d.timestamp.toISOString()
1020
+ M.value = {
1021
+ operations: e.value.map((p) => ({
1022
+ ...p,
1023
+ timestamp: p.timestamp.toISOString()
1024
1024
  })),
1025
- currentIndex: o.value
1025
+ currentIndex: t.value
1026
1026
  };
1027
- } catch (d) {
1028
- typeof console < "u" && console.error("Failed to save operations to persistence:", d);
1027
+ } catch (p) {
1028
+ typeof console < "u" && console.error("Failed to save operations to persistence:", p);
1029
1029
  }
1030
1030
  }
1031
1031
  function S() {
1032
- L(
1033
- [e, o],
1032
+ H(
1033
+ [e, t],
1034
1034
  () => {
1035
- t.value.enablePersistence && D();
1035
+ n.value.enablePersistence && C();
1036
1036
  },
1037
1037
  { deep: !0 }
1038
1038
  );
@@ -1040,26 +1040,26 @@ const Dt = /* @__PURE__ */ no("hst-operation-log", () => {
1040
1040
  return {
1041
1041
  // State
1042
1042
  operations: e,
1043
- currentIndex: o,
1044
- config: t,
1045
- clientId: n,
1046
- undoRedoState: b,
1043
+ currentIndex: t,
1044
+ config: n,
1045
+ clientId: o,
1046
+ undoRedoState: v,
1047
1047
  // Computed
1048
- canUndo: u,
1049
- canRedo: c,
1050
- undoCount: f,
1051
- redoCount: p,
1048
+ canUndo: c,
1049
+ canRedo: d,
1050
+ undoCount: u,
1051
+ redoCount: w,
1052
1052
  // Methods
1053
1053
  configure: h,
1054
- addOperation: _,
1054
+ addOperation: b,
1055
1055
  startBatch: m,
1056
- commitBatch: O,
1057
- cancelBatch: R,
1058
- undo: x,
1059
- redo: H,
1060
- clear: z,
1056
+ commitBatch: k,
1057
+ cancelBatch: I,
1058
+ undo: T,
1059
+ redo: Z,
1060
+ clear: G,
1061
1061
  getOperationsFor: E,
1062
- getSnapshot: G,
1062
+ getSnapshot: L,
1063
1063
  markIrreversible: Y,
1064
1064
  logAction: B
1065
1065
  };
@@ -1099,16 +1099,16 @@ class ge {
1099
1099
  * @param name - The name of the action
1100
1100
  * @param fn - The action function
1101
1101
  */
1102
- registerAction(e, o) {
1103
- this.globalActions.set(e, o);
1102
+ registerAction(e, t) {
1103
+ this.globalActions.set(e, t);
1104
1104
  }
1105
1105
  /**
1106
1106
  * Register a global XState transition action function
1107
1107
  * @param name - The name of the transition action
1108
1108
  * @param fn - The transition action function
1109
1109
  */
1110
- registerTransitionAction(e, o) {
1111
- this.globalTransitionActions.set(e, o);
1110
+ registerTransitionAction(e, t) {
1111
+ this.globalTransitionActions.set(e, t);
1112
1112
  }
1113
1113
  /**
1114
1114
  * Configure rollback behavior for a specific field trigger
@@ -1116,14 +1116,14 @@ class ge {
1116
1116
  * @param fieldname - The field name
1117
1117
  * @param enableRollback - Whether to enable rollback
1118
1118
  */
1119
- setFieldRollback(e, o, n) {
1120
- this.fieldRollbackConfig.has(e) || this.fieldRollbackConfig.set(e, /* @__PURE__ */ new Map()), this.fieldRollbackConfig.get(e).set(o, n);
1119
+ setFieldRollback(e, t, o) {
1120
+ this.fieldRollbackConfig.has(e) || this.fieldRollbackConfig.set(e, /* @__PURE__ */ new Map()), this.fieldRollbackConfig.get(e).set(t, o);
1121
1121
  }
1122
1122
  /**
1123
1123
  * Get rollback configuration for a specific field trigger
1124
1124
  */
1125
- getFieldRollback(e, o) {
1126
- return this.fieldRollbackConfig.get(e)?.get(o);
1125
+ getFieldRollback(e, t) {
1126
+ return this.fieldRollbackConfig.get(e)?.get(t);
1127
1127
  }
1128
1128
  /**
1129
1129
  * Register actions from a doctype - both regular actions and field triggers
@@ -1131,27 +1131,27 @@ class ge {
1131
1131
  * @param doctype - The doctype name
1132
1132
  * @param actions - The actions to register (supports Immutable Map, Map, or plain object)
1133
1133
  */
1134
- registerDoctypeActions(e, o) {
1135
- if (!o) return;
1136
- const n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
1137
- if (typeof o.entrySeq == "function")
1138
- o.entrySeq().forEach(([i, a]) => {
1139
- this.categorizeAction(i, a, n, r);
1134
+ registerDoctypeActions(e, t) {
1135
+ if (!t) return;
1136
+ const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
1137
+ if (typeof t.entrySeq == "function")
1138
+ t.entrySeq().forEach(([a, s]) => {
1139
+ this.categorizeAction(a, s, o, r);
1140
1140
  });
1141
- else if (o instanceof Map)
1142
- for (const [i, a] of o)
1143
- this.categorizeAction(i, a, n, r);
1144
- else o && typeof o == "object" && Object.entries(o).forEach(([i, a]) => {
1145
- this.categorizeAction(i, a, n, r);
1141
+ else if (t instanceof Map)
1142
+ for (const [a, s] of t)
1143
+ this.categorizeAction(a, s, o, r);
1144
+ else t && typeof t == "object" && Object.entries(t).forEach(([a, s]) => {
1145
+ this.categorizeAction(a, s, o, r);
1146
1146
  });
1147
- this.doctypeActions.set(e, n), this.doctypeTransitions.set(e, r);
1147
+ this.doctypeActions.set(e, o), this.doctypeTransitions.set(e, r);
1148
1148
  }
1149
1149
  /**
1150
1150
  * Categorize an action as either a field trigger or XState transition
1151
1151
  * Uses uppercase convention: UPPERCASE = transition, lowercase/mixed = field trigger
1152
1152
  */
1153
- categorizeAction(e, o, n, r) {
1154
- this.isTransitionKey(e) ? r.set(e, o) : n.set(e, o);
1153
+ categorizeAction(e, t, o, r) {
1154
+ this.isTransitionKey(e) ? r.set(e, t) : o.set(e, t);
1155
1155
  }
1156
1156
  /**
1157
1157
  * Determine if a key represents an XState transition
@@ -1165,9 +1165,9 @@ class ge {
1165
1165
  * @param context - The field change context
1166
1166
  * @param options - Execution options (timeout and enableRollback)
1167
1167
  */
1168
- async executeFieldTriggers(e, o = {}) {
1169
- const { doctype: n, fieldname: r } = e, i = this.findFieldTriggers(n, r);
1170
- if (i.length === 0)
1168
+ async executeFieldTriggers(e, t = {}) {
1169
+ const { doctype: o, fieldname: r } = e, a = this.findFieldTriggers(o, r);
1170
+ if (a.length === 0)
1171
1171
  return {
1172
1172
  path: e.path,
1173
1173
  actionResults: [],
@@ -1176,49 +1176,49 @@ class ge {
1176
1176
  stoppedOnError: !1,
1177
1177
  rolledBack: !1
1178
1178
  };
1179
- const a = performance.now(), u = [];
1180
- let c = !1, f = !1, p;
1181
- const b = this.getFieldRollback(n, r), h = o.enableRollback ?? b ?? this.options.enableRollback;
1182
- h && e.store && (p = this.captureSnapshot(e));
1183
- for (const O of i)
1179
+ const s = performance.now(), c = [];
1180
+ let d = !1, u = !1, w;
1181
+ const v = this.getFieldRollback(o, r), h = t.enableRollback ?? v ?? this.options.enableRollback;
1182
+ h && e.store && (w = this.captureSnapshot(e));
1183
+ for (const k of a)
1184
1184
  try {
1185
- const R = await this.executeAction(O, e, o.timeout);
1186
- if (u.push(R), !R.success) {
1187
- c = !0;
1185
+ const I = await this.executeAction(k, e, t.timeout);
1186
+ if (c.push(I), !I.success) {
1187
+ d = !0;
1188
1188
  break;
1189
1189
  }
1190
- } catch (R) {
1191
- const x = {
1190
+ } catch (I) {
1191
+ const T = {
1192
1192
  success: !1,
1193
- error: R instanceof Error ? R : new Error(String(R)),
1193
+ error: I instanceof Error ? I : new Error(String(I)),
1194
1194
  executionTime: 0,
1195
- action: O
1195
+ action: k
1196
1196
  };
1197
- u.push(x), c = !0;
1197
+ c.push(T), d = !0;
1198
1198
  break;
1199
1199
  }
1200
- if (h && c && p && e.store)
1200
+ if (h && d && w && e.store)
1201
1201
  try {
1202
- this.restoreSnapshot(e, p), f = !0;
1203
- } catch (O) {
1204
- console.error("[FieldTriggers] Rollback failed:", O);
1202
+ this.restoreSnapshot(e, w), u = !0;
1203
+ } catch (k) {
1204
+ console.error("[FieldTriggers] Rollback failed:", k);
1205
1205
  }
1206
- const _ = performance.now() - a, m = u.filter((O) => !O.success);
1206
+ const b = performance.now() - s, m = c.filter((k) => !k.success);
1207
1207
  if (m.length > 0 && this.options.errorHandler)
1208
- for (const O of m)
1208
+ for (const k of m)
1209
1209
  try {
1210
- this.options.errorHandler(O.error, e, O.action);
1211
- } catch (R) {
1212
- console.error("[FieldTriggers] Error in global error handler:", R);
1210
+ this.options.errorHandler(k.error, e, k.action);
1211
+ } catch (I) {
1212
+ console.error("[FieldTriggers] Error in global error handler:", I);
1213
1213
  }
1214
1214
  return {
1215
1215
  path: e.path,
1216
- actionResults: u,
1217
- totalExecutionTime: _,
1218
- allSucceeded: u.every((O) => O.success),
1219
- stoppedOnError: c,
1220
- rolledBack: f,
1221
- snapshot: this.options.debug && h ? p : void 0
1216
+ actionResults: c,
1217
+ totalExecutionTime: b,
1218
+ allSucceeded: c.every((k) => k.success),
1219
+ stoppedOnError: d,
1220
+ rolledBack: u,
1221
+ snapshot: this.options.debug && h ? w : void 0
1222
1222
  // Only include snapshot in debug mode if rollback is enabled
1223
1223
  };
1224
1224
  }
@@ -1228,71 +1228,71 @@ class ge {
1228
1228
  * @param context - The transition change context
1229
1229
  * @param options - Execution options (timeout)
1230
1230
  */
1231
- async executeTransitionActions(e, o = {}) {
1232
- const { doctype: n, transition: r } = e, i = this.findTransitionActions(n, r);
1233
- if (i.length === 0)
1231
+ async executeTransitionActions(e, t = {}) {
1232
+ const { doctype: o, transition: r } = e, a = this.findTransitionActions(o, r);
1233
+ if (a.length === 0)
1234
1234
  return [];
1235
- const a = [];
1236
- for (const c of i)
1235
+ const s = [];
1236
+ for (const d of a)
1237
1237
  try {
1238
- const f = await this.executeTransitionAction(c, e, o.timeout);
1239
- if (a.push(f), !f.success)
1238
+ const u = await this.executeTransitionAction(d, e, t.timeout);
1239
+ if (s.push(u), !u.success)
1240
1240
  break;
1241
- } catch (f) {
1242
- const p = {
1241
+ } catch (u) {
1242
+ const w = {
1243
1243
  success: !1,
1244
- error: f instanceof Error ? f : new Error(String(f)),
1244
+ error: u instanceof Error ? u : new Error(String(u)),
1245
1245
  executionTime: 0,
1246
- action: c,
1246
+ action: d,
1247
1247
  transition: r
1248
1248
  };
1249
- a.push(p);
1249
+ s.push(w);
1250
1250
  break;
1251
1251
  }
1252
- const u = a.filter((c) => !c.success);
1253
- if (u.length > 0 && this.options.errorHandler)
1254
- for (const c of u)
1252
+ const c = s.filter((d) => !d.success);
1253
+ if (c.length > 0 && this.options.errorHandler)
1254
+ for (const d of c)
1255
1255
  try {
1256
- this.options.errorHandler(c.error, e, c.action);
1257
- } catch (f) {
1258
- console.error("[FieldTriggers] Error in global error handler:", f);
1256
+ this.options.errorHandler(d.error, e, d.action);
1257
+ } catch (u) {
1258
+ console.error("[FieldTriggers] Error in global error handler:", u);
1259
1259
  }
1260
- return a;
1260
+ return s;
1261
1261
  }
1262
1262
  /**
1263
1263
  * Find transition actions for a specific doctype and transition
1264
1264
  */
1265
- findTransitionActions(e, o) {
1266
- const n = this.doctypeTransitions.get(e);
1267
- return n ? n.get(o) || [] : [];
1265
+ findTransitionActions(e, t) {
1266
+ const o = this.doctypeTransitions.get(e);
1267
+ return o ? o.get(t) || [] : [];
1268
1268
  }
1269
1269
  /**
1270
1270
  * Execute a single transition action by name
1271
1271
  */
1272
- async executeTransitionAction(e, o, n) {
1273
- const r = performance.now(), i = n ?? this.options.defaultTimeout;
1272
+ async executeTransitionAction(e, t, o) {
1273
+ const r = performance.now(), a = o ?? this.options.defaultTimeout;
1274
1274
  try {
1275
- let a = this.globalTransitionActions.get(e);
1276
- if (!a) {
1277
- const u = this.globalActions.get(e);
1278
- u && (a = u);
1275
+ let s = this.globalTransitionActions.get(e);
1276
+ if (!s) {
1277
+ const c = this.globalActions.get(e);
1278
+ c && (s = c);
1279
1279
  }
1280
- if (!a)
1280
+ if (!s)
1281
1281
  throw new Error(`Transition action "${e}" not found in registry`);
1282
- return await this.executeWithTimeout(a, o, i), {
1282
+ return await this.executeWithTimeout(s, t, a), {
1283
1283
  success: !0,
1284
1284
  executionTime: performance.now() - r,
1285
1285
  action: e,
1286
- transition: o.transition
1286
+ transition: t.transition
1287
1287
  };
1288
- } catch (a) {
1289
- const u = performance.now() - r;
1288
+ } catch (s) {
1289
+ const c = performance.now() - r;
1290
1290
  return {
1291
1291
  success: !1,
1292
- error: a instanceof Error ? a : new Error(String(a)),
1293
- executionTime: u,
1292
+ error: s instanceof Error ? s : new Error(String(s)),
1293
+ executionTime: c,
1294
1294
  action: e,
1295
- transition: o.transition
1295
+ transition: t.transition
1296
1296
  };
1297
1297
  }
1298
1298
  }
@@ -1300,12 +1300,12 @@ class ge {
1300
1300
  * Find field triggers for a specific doctype and field
1301
1301
  * Field triggers are identified by keys that look like field paths (contain dots or match field names)
1302
1302
  */
1303
- findFieldTriggers(e, o) {
1304
- const n = this.doctypeActions.get(e);
1305
- if (!n) return [];
1303
+ findFieldTriggers(e, t) {
1304
+ const o = this.doctypeActions.get(e);
1305
+ if (!o) return [];
1306
1306
  const r = [];
1307
- for (const [i, a] of n)
1308
- this.isFieldTriggerKey(i, o) && r.push(...a);
1307
+ for (const [a, s] of o)
1308
+ this.isFieldTriggerKey(a, t) && r.push(...s);
1309
1309
  return r;
1310
1310
  }
1311
1311
  /**
@@ -1315,20 +1315,20 @@ class ge {
1315
1315
  * - Wildcard patterns: "emailAddress.*", "*.is_primary"
1316
1316
  * - Nested field paths: "address.street", "contact.email"
1317
1317
  */
1318
- isFieldTriggerKey(e, o) {
1319
- return e === o ? !0 : e.includes(".") ? this.matchFieldPattern(e, o) : e.includes("*") ? this.matchFieldPattern(e, o) : !1;
1318
+ isFieldTriggerKey(e, t) {
1319
+ return e === t ? !0 : e.includes(".") ? this.matchFieldPattern(e, t) : e.includes("*") ? this.matchFieldPattern(e, t) : !1;
1320
1320
  }
1321
1321
  /**
1322
1322
  * Match a field pattern against a field name
1323
1323
  * Supports wildcards (*) for dynamic segments
1324
1324
  */
1325
- matchFieldPattern(e, o) {
1326
- const n = e.split("."), r = o.split(".");
1327
- if (n.length !== r.length)
1325
+ matchFieldPattern(e, t) {
1326
+ const o = e.split("."), r = t.split(".");
1327
+ if (o.length !== r.length)
1328
1328
  return !1;
1329
- for (let i = 0; i < n.length; i++) {
1330
- const a = n[i], u = r[i];
1331
- if (a !== "*" && a !== u)
1329
+ for (let a = 0; a < o.length; a++) {
1330
+ const s = o[a], c = r[a];
1331
+ if (s !== "*" && s !== c)
1332
1332
  return !1;
1333
1333
  }
1334
1334
  return !0;
@@ -1336,23 +1336,23 @@ class ge {
1336
1336
  /**
1337
1337
  * Execute a single action by name
1338
1338
  */
1339
- async executeAction(e, o, n) {
1340
- const r = performance.now(), i = n ?? this.options.defaultTimeout;
1339
+ async executeAction(e, t, o) {
1340
+ const r = performance.now(), a = o ?? this.options.defaultTimeout;
1341
1341
  try {
1342
- const a = this.globalActions.get(e);
1343
- if (!a)
1342
+ const s = this.globalActions.get(e);
1343
+ if (!s)
1344
1344
  throw new Error(`Action "${e}" not found in registry`);
1345
- return await this.executeWithTimeout(a, o, i), {
1345
+ return await this.executeWithTimeout(s, t, a), {
1346
1346
  success: !0,
1347
1347
  executionTime: performance.now() - r,
1348
1348
  action: e
1349
1349
  };
1350
- } catch (a) {
1351
- const u = performance.now() - r;
1350
+ } catch (s) {
1351
+ const c = performance.now() - r;
1352
1352
  return {
1353
1353
  success: !1,
1354
- error: a instanceof Error ? a : new Error(String(a)),
1355
- executionTime: u,
1354
+ error: s instanceof Error ? s : new Error(String(s)),
1355
+ executionTime: c,
1356
1356
  action: e
1357
1357
  };
1358
1358
  }
@@ -1360,15 +1360,15 @@ class ge {
1360
1360
  /**
1361
1361
  * Execute a function with timeout
1362
1362
  */
1363
- async executeWithTimeout(e, o, n) {
1364
- return new Promise((r, i) => {
1365
- const a = setTimeout(() => {
1366
- i(new Error(`Action timeout after ${n}ms`));
1367
- }, n);
1368
- Promise.resolve(e(o)).then((u) => {
1369
- clearTimeout(a), r(u);
1370
- }).catch((u) => {
1371
- clearTimeout(a), i(u);
1363
+ async executeWithTimeout(e, t, o) {
1364
+ return new Promise((r, a) => {
1365
+ const s = setTimeout(() => {
1366
+ a(new Error(`Action timeout after ${o}ms`));
1367
+ }, o);
1368
+ Promise.resolve(e(t)).then((c) => {
1369
+ clearTimeout(s), r(c);
1370
+ }).catch((c) => {
1371
+ clearTimeout(s), a(c);
1372
1372
  });
1373
1373
  });
1374
1374
  }
@@ -1379,10 +1379,10 @@ class ge {
1379
1379
  captureSnapshot(e) {
1380
1380
  if (!(!e.store || !e.doctype || !e.recordId))
1381
1381
  try {
1382
- const o = `${e.doctype}.${e.recordId}`, n = e.store.get(o);
1383
- return !n || typeof n != "object" ? void 0 : JSON.parse(JSON.stringify(n));
1384
- } catch (o) {
1385
- this.options.debug && console.warn("[FieldTriggers] Failed to capture snapshot:", o);
1382
+ const t = `${e.doctype}.${e.recordId}`, o = e.store.get(t);
1383
+ return !o || typeof o != "object" ? void 0 : JSON.parse(JSON.stringify(o));
1384
+ } catch (t) {
1385
+ this.options.debug && console.warn("[FieldTriggers] Failed to capture snapshot:", t);
1386
1386
  return;
1387
1387
  }
1388
1388
  }
@@ -1390,34 +1390,34 @@ class ge {
1390
1390
  * Restore a previously captured snapshot
1391
1391
  * This reverts the record to its state before actions were executed
1392
1392
  */
1393
- restoreSnapshot(e, o) {
1394
- if (!(!e.store || !e.doctype || !e.recordId || !o))
1393
+ restoreSnapshot(e, t) {
1394
+ if (!(!e.store || !e.doctype || !e.recordId || !t))
1395
1395
  try {
1396
- const n = `${e.doctype}.${e.recordId}`;
1397
- e.store.set(n, o), this.options.debug && console.log(`[FieldTriggers] Rolled back ${n} to previous state`);
1398
- } catch (n) {
1399
- throw console.error("[FieldTriggers] Failed to restore snapshot:", n), n;
1396
+ const o = `${e.doctype}.${e.recordId}`;
1397
+ e.store.set(o, t), this.options.debug && console.log(`[FieldTriggers] Rolled back ${o} to previous state`);
1398
+ } catch (o) {
1399
+ throw console.error("[FieldTriggers] Failed to restore snapshot:", o), o;
1400
1400
  }
1401
1401
  }
1402
1402
  }
1403
- function ct(t) {
1404
- return new ge(t);
1403
+ function ct(n) {
1404
+ return new ge(n);
1405
1405
  }
1406
1406
  function ut() {
1407
1407
  try {
1408
- return Dt();
1408
+ return Ct();
1409
1409
  } catch {
1410
1410
  return null;
1411
1411
  }
1412
1412
  }
1413
- class ce {
1413
+ class le {
1414
1414
  static instance;
1415
1415
  /**
1416
1416
  * Gets the singleton instance of HST
1417
1417
  * @returns The HST singleton instance
1418
1418
  */
1419
1419
  static getInstance() {
1420
- return ce.instance || (ce.instance = new ce()), ce.instance;
1420
+ return le.instance || (le.instance = new le()), le.instance;
1421
1421
  }
1422
1422
  /**
1423
1423
  * Gets the global registry instance
@@ -1446,28 +1446,28 @@ class ce {
1446
1446
  * @returns The doctype metadata object or undefined if not found
1447
1447
  */
1448
1448
  getDoctypeMeta(e) {
1449
- const o = this.getRegistry();
1450
- if (o && typeof o == "object" && "registry" in o)
1451
- return o.registry[e];
1449
+ const t = this.getRegistry();
1450
+ if (t && typeof t == "object" && "registry" in t)
1451
+ return t.registry[e];
1452
1452
  }
1453
1453
  }
1454
- class Ie {
1454
+ class Re {
1455
1455
  target;
1456
1456
  parentPath;
1457
1457
  rootNode;
1458
1458
  doctype;
1459
1459
  parentDoctype;
1460
1460
  hst;
1461
- constructor(e, o, n = "", r = null, i) {
1462
- return this.target = e, this.parentPath = n, this.rootNode = r || this, this.doctype = o, this.parentDoctype = i, this.hst = ce.getInstance(), new Proxy(this, {
1463
- get(a, u) {
1464
- if (u in a) return a[u];
1465
- const c = String(u);
1466
- return a.getNode(c);
1461
+ constructor(e, t, o = "", r = null, a) {
1462
+ return this.target = e, this.parentPath = o, this.rootNode = r || this, this.doctype = t, this.parentDoctype = a, this.hst = le.getInstance(), new Proxy(this, {
1463
+ get(s, c) {
1464
+ if (c in s) return s[c];
1465
+ const d = String(c);
1466
+ return s.getNode(d);
1467
1467
  },
1468
- set(a, u, c) {
1469
- const f = String(u);
1470
- return a.set(f, c), !0;
1468
+ set(s, c, d) {
1469
+ const u = String(c);
1470
+ return s.set(u, d), !0;
1471
1471
  }
1472
1472
  });
1473
1473
  }
@@ -1476,47 +1476,47 @@ class Ie {
1476
1476
  }
1477
1477
  // Method to get a tree-wrapped node for navigation
1478
1478
  getNode(e) {
1479
- const o = this.resolvePath(e), n = this.resolveValue(e), r = o.split(".");
1480
- let i = this.doctype;
1481
- return this.doctype === "StonecropStore" && r.length >= 1 && (i = r[0]), typeof n == "object" && n !== null && !this.isPrimitive(n) ? new Ie(n, i, o, this.rootNode, this.parentDoctype) : new Ie(n, i, o, this.rootNode, this.parentDoctype);
1482
- }
1483
- set(e, o, n = "user") {
1484
- const r = this.resolvePath(e), i = this.has(e) ? this.get(e) : void 0;
1485
- if (n !== "undo" && n !== "redo") {
1486
- const a = ut();
1487
- if (a && typeof a.addOperation == "function") {
1488
- const u = r.split("."), c = this.doctype === "StonecropStore" && u.length >= 1 ? u[0] : this.doctype, f = u.length >= 2 ? u[1] : void 0, p = u.slice(2).join(".") || u[u.length - 1], b = o === void 0 && i !== void 0 ? "delete" : "set";
1489
- a.addOperation(
1479
+ const t = this.resolvePath(e), o = this.resolveValue(e), r = t.split(".");
1480
+ let a = this.doctype;
1481
+ return this.doctype === "StonecropStore" && r.length >= 1 && (a = r[0]), typeof o == "object" && o !== null && !this.isPrimitive(o) ? new Re(o, a, t, this.rootNode, this.parentDoctype) : new Re(o, a, t, this.rootNode, this.parentDoctype);
1482
+ }
1483
+ set(e, t, o = "user") {
1484
+ const r = this.resolvePath(e), a = this.has(e) ? this.get(e) : void 0;
1485
+ if (o !== "undo" && o !== "redo") {
1486
+ const s = ut();
1487
+ if (s && typeof s.addOperation == "function") {
1488
+ const c = r.split("."), d = this.doctype === "StonecropStore" && c.length >= 1 ? c[0] : this.doctype, u = c.length >= 2 ? c[1] : void 0, w = c.slice(2).join(".") || c[c.length - 1], v = t === void 0 && a !== void 0 ? "delete" : "set";
1489
+ s.addOperation(
1490
1490
  {
1491
- type: b,
1491
+ type: v,
1492
1492
  path: r,
1493
- fieldname: p,
1494
- beforeValue: i,
1495
- afterValue: o,
1496
- doctype: c,
1497
- recordId: f,
1493
+ fieldname: w,
1494
+ beforeValue: a,
1495
+ afterValue: t,
1496
+ doctype: d,
1497
+ recordId: u,
1498
1498
  reversible: !0
1499
1499
  // Default to reversible, can be changed by field triggers
1500
1500
  },
1501
- n
1501
+ o
1502
1502
  );
1503
1503
  }
1504
1504
  }
1505
- this.updateValue(e, o), this.triggerFieldActions(r, i, o);
1505
+ this.updateValue(e, t), this.triggerFieldActions(r, a, t);
1506
1506
  }
1507
1507
  has(e) {
1508
1508
  try {
1509
1509
  if (e === "")
1510
1510
  return !0;
1511
- const o = this.parsePath(e);
1512
- let n = this.target;
1513
- for (let r = 0; r < o.length; r++) {
1514
- const i = o[r];
1515
- if (n == null)
1511
+ const t = this.parsePath(e);
1512
+ let o = this.target;
1513
+ for (let r = 0; r < t.length; r++) {
1514
+ const a = t[r];
1515
+ if (o == null)
1516
1516
  return !1;
1517
- if (r === o.length - 1)
1518
- return this.isImmutable(n) ? n.has(i) : this.isPiniaStore(n) && n.$state && i in n.$state || i in n;
1519
- n = this.getProperty(n, i);
1517
+ if (r === t.length - 1)
1518
+ return this.isImmutable(o) ? o.has(a) : this.isPiniaStore(o) && o.$state && a in o.$state || a in o;
1519
+ o = this.getProperty(o, a);
1520
1520
  }
1521
1521
  return !1;
1522
1522
  } catch {
@@ -1544,46 +1544,46 @@ class Ie {
1544
1544
  /**
1545
1545
  * Trigger an XState transition with optional context data
1546
1546
  */
1547
- async triggerTransition(e, o) {
1548
- const n = ct(), r = this.parentPath.split(".");
1549
- let i = this.doctype, a;
1550
- this.doctype === "StonecropStore" && r.length >= 1 && (i = r[0]), r.length >= 2 && (a = r[1]);
1551
- const u = {
1547
+ async triggerTransition(e, t) {
1548
+ const o = ct(), r = this.parentPath.split(".");
1549
+ let a = this.doctype, s;
1550
+ this.doctype === "StonecropStore" && r.length >= 1 && (a = r[0]), r.length >= 2 && (s = r[1]);
1551
+ const c = {
1552
1552
  path: this.parentPath,
1553
1553
  fieldname: "",
1554
1554
  // No specific field for transitions
1555
1555
  beforeValue: void 0,
1556
1556
  afterValue: void 0,
1557
1557
  operation: "set",
1558
- doctype: i,
1559
- recordId: a,
1558
+ doctype: a,
1559
+ recordId: s,
1560
1560
  timestamp: /* @__PURE__ */ new Date(),
1561
1561
  store: this.rootNode || void 0,
1562
1562
  transition: e,
1563
- currentState: o?.currentState,
1564
- targetState: o?.targetState,
1565
- fsmContext: o?.fsmContext
1566
- }, c = ut();
1567
- return c && typeof c.addOperation == "function" && c.addOperation(
1563
+ currentState: t?.currentState,
1564
+ targetState: t?.targetState,
1565
+ fsmContext: t?.fsmContext
1566
+ }, d = ut();
1567
+ return d && typeof d.addOperation == "function" && d.addOperation(
1568
1568
  {
1569
1569
  type: "transition",
1570
1570
  path: this.parentPath,
1571
1571
  fieldname: e,
1572
- beforeValue: o?.currentState,
1573
- afterValue: o?.targetState,
1574
- doctype: i,
1575
- recordId: a,
1572
+ beforeValue: t?.currentState,
1573
+ afterValue: t?.targetState,
1574
+ doctype: a,
1575
+ recordId: s,
1576
1576
  reversible: !1,
1577
1577
  // FSM transitions are generally not reversible
1578
1578
  metadata: {
1579
1579
  transition: e,
1580
- currentState: o?.currentState,
1581
- targetState: o?.targetState,
1582
- fsmContext: o?.fsmContext
1580
+ currentState: t?.currentState,
1581
+ targetState: t?.targetState,
1582
+ fsmContext: t?.fsmContext
1583
1583
  }
1584
1584
  },
1585
1585
  "user"
1586
- ), await n.executeTransitionActions(u);
1586
+ ), await o.executeTransitionActions(c);
1587
1587
  }
1588
1588
  // Private helper methods
1589
1589
  resolvePath(e) {
@@ -1592,62 +1592,62 @@ class Ie {
1592
1592
  resolveValue(e) {
1593
1593
  if (e === "")
1594
1594
  return this.target;
1595
- const o = this.parsePath(e);
1596
- let n = this.target;
1597
- for (const r of o) {
1598
- if (n == null)
1595
+ const t = this.parsePath(e);
1596
+ let o = this.target;
1597
+ for (const r of t) {
1598
+ if (o == null)
1599
1599
  return;
1600
- n = this.getProperty(n, r);
1600
+ o = this.getProperty(o, r);
1601
1601
  }
1602
- return n;
1602
+ return o;
1603
1603
  }
1604
- updateValue(e, o) {
1604
+ updateValue(e, t) {
1605
1605
  if (e === "")
1606
1606
  throw new Error("Cannot set value on empty path");
1607
- const n = this.parsePath(e), r = n.pop();
1608
- let i = this.target;
1609
- for (const a of n)
1610
- if (i = this.getProperty(i, a), i == null)
1607
+ const o = this.parsePath(e), r = o.pop();
1608
+ let a = this.target;
1609
+ for (const s of o)
1610
+ if (a = this.getProperty(a, s), a == null)
1611
1611
  throw new Error(`Cannot set property on null/undefined path: ${e}`);
1612
- this.setProperty(i, r, o);
1612
+ this.setProperty(a, r, t);
1613
1613
  }
1614
- getProperty(e, o) {
1615
- return this.isImmutable(e) ? e.get(o) : this.isVueReactive(e) ? e[o] : this.isPiniaStore(e) ? e.$state?.[o] ?? e[o] : e[o];
1614
+ getProperty(e, t) {
1615
+ return this.isImmutable(e) ? e.get(t) : this.isVueReactive(e) ? e[t] : this.isPiniaStore(e) ? e.$state?.[t] ?? e[t] : e[t];
1616
1616
  }
1617
- setProperty(e, o, n) {
1617
+ setProperty(e, t, o) {
1618
1618
  if (this.isImmutable(e))
1619
1619
  throw new Error("Cannot directly mutate immutable objects. Use immutable update methods instead.");
1620
1620
  if (this.isPiniaStore(e)) {
1621
- e.$patch ? e.$patch({ [o]: n }) : e[o] = n;
1621
+ e.$patch ? e.$patch({ [t]: o }) : e[t] = o;
1622
1622
  return;
1623
1623
  }
1624
- e[o] = n;
1624
+ e[t] = o;
1625
1625
  }
1626
- async triggerFieldActions(e, o, n) {
1626
+ async triggerFieldActions(e, t, o) {
1627
1627
  try {
1628
- if (!e || typeof e != "string" || Object.is(o, n))
1628
+ if (!e || typeof e != "string" || Object.is(t, o))
1629
1629
  return;
1630
1630
  const r = e.split(".");
1631
1631
  if (r.length < 3)
1632
1632
  return;
1633
- const i = ct(), a = r.slice(2).join(".") || r[r.length - 1];
1634
- let u = this.doctype;
1635
- this.doctype === "StonecropStore" && r.length >= 1 && (u = r[0]);
1636
- let c;
1637
- r.length >= 2 && (c = r[1]);
1638
- const f = {
1633
+ const a = ct(), s = r.slice(2).join(".") || r[r.length - 1];
1634
+ let c = this.doctype;
1635
+ this.doctype === "StonecropStore" && r.length >= 1 && (c = r[0]);
1636
+ let d;
1637
+ r.length >= 2 && (d = r[1]);
1638
+ const u = {
1639
1639
  path: e,
1640
- fieldname: a,
1641
- beforeValue: o,
1642
- afterValue: n,
1640
+ fieldname: s,
1641
+ beforeValue: t,
1642
+ afterValue: o,
1643
1643
  operation: "set",
1644
- doctype: u,
1645
- recordId: c,
1644
+ doctype: c,
1645
+ recordId: d,
1646
1646
  timestamp: /* @__PURE__ */ new Date(),
1647
1647
  store: this.rootNode || void 0
1648
1648
  // Pass the root store for snapshot/rollback capabilities
1649
1649
  };
1650
- await i.executeFieldTriggers(f);
1650
+ await a.executeFieldTriggers(u);
1651
1651
  } catch (r) {
1652
1652
  r instanceof Error && console.warn("Field trigger error:", r.message);
1653
1653
  }
@@ -1661,19 +1661,19 @@ class Ie {
1661
1661
  isImmutable(e) {
1662
1662
  if (!e || typeof e != "object")
1663
1663
  return !1;
1664
- const o = "get" in e && typeof e.get == "function", n = "set" in e && typeof e.set == "function", r = "has" in e && typeof e.has == "function", i = "__ownerID" in e || "_map" in e || "_list" in e || "_origin" in e || "_capacity" in e || "_defaultValues" in e || "_tail" in e || "_root" in e || "size" in e && o && n;
1665
- let a;
1664
+ const t = "get" in e && typeof e.get == "function", o = "set" in e && typeof e.set == "function", r = "has" in e && typeof e.has == "function", a = "__ownerID" in e || "_map" in e || "_list" in e || "_origin" in e || "_capacity" in e || "_defaultValues" in e || "_tail" in e || "_root" in e || "size" in e && t && o;
1665
+ let s;
1666
1666
  try {
1667
- const c = e;
1668
- if ("constructor" in c && c.constructor && typeof c.constructor == "object" && "name" in c.constructor) {
1669
- const f = c.constructor.name;
1670
- a = typeof f == "string" ? f : void 0;
1667
+ const d = e;
1668
+ if ("constructor" in d && d.constructor && typeof d.constructor == "object" && "name" in d.constructor) {
1669
+ const u = d.constructor.name;
1670
+ s = typeof u == "string" ? u : void 0;
1671
1671
  }
1672
1672
  } catch {
1673
- a = void 0;
1673
+ s = void 0;
1674
1674
  }
1675
- const u = a && (a.includes("Map") || a.includes("List") || a.includes("Set") || a.includes("Stack") || a.includes("Seq")) && (o || n);
1676
- return !!(o && n && r && i || o && n && u);
1675
+ const c = s && (s.includes("Map") || s.includes("List") || s.includes("Set") || s.includes("Stack") || s.includes("Seq")) && (t || o);
1676
+ return !!(t && o && r && a || t && o && c);
1677
1677
  }
1678
1678
  isPrimitive(e) {
1679
1679
  return e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "function" || typeof e == "symbol" || typeof e == "bigint";
@@ -1684,49 +1684,74 @@ class Ie {
1684
1684
  * @returns Array of path segments (e.g., ['order', '456', 'line_items', '0', 'product'])
1685
1685
  */
1686
1686
  parsePath(e) {
1687
- return e ? e.replace(/\[(\d+)\]/g, ".$1").split(".").filter((o) => o.length > 0) : [];
1687
+ return e ? e.replace(/\[(\d+)\]/g, ".$1").split(".").filter((t) => t.length > 0) : [];
1688
1688
  }
1689
1689
  }
1690
- function No(t, e, o) {
1691
- return new Ie(t, e, "", null, o);
1690
+ function Co(n, e, t) {
1691
+ return new Re(n, e, "", null, t);
1692
1692
  }
1693
- class $o {
1693
+ class No {
1694
1694
  hstStore;
1695
1695
  _operationLogStore;
1696
1696
  _operationLogConfig;
1697
+ _client;
1697
1698
  /** The registry instance containing all doctype definitions */
1698
1699
  registry;
1699
1700
  /**
1700
1701
  * Creates a new Stonecrop instance with HST integration
1701
1702
  * @param registry - The Registry instance containing doctype definitions
1702
1703
  * @param operationLogConfig - Optional configuration for the operation log
1704
+ * @param options - Options including the data client (can be set later via setClient)
1703
1705
  */
1704
- constructor(e, o) {
1705
- this.registry = e, this._operationLogConfig = o, this.initializeHSTStore(), this.setupRegistrySync();
1706
+ constructor(e, t, o) {
1707
+ this.registry = e, this._operationLogConfig = t, this._client = o?.client, this.initializeHSTStore(), this.setupRegistrySync();
1708
+ }
1709
+ /**
1710
+ * Set the data client for fetching doctype metadata and records.
1711
+ * Use this for deferred configuration in Nuxt/Vue plugin setups.
1712
+ *
1713
+ * @param client - DataClient implementation (e.g., StonecropClient from \@stonecrop/graphql-client)
1714
+ *
1715
+ * @example
1716
+ * ```ts
1717
+ * const { setClient } = useStonecropRegistry()
1718
+ * const client = new StonecropClient({ endpoint: '/graphql' })
1719
+ * setClient(client)
1720
+ * ```
1721
+ */
1722
+ setClient(e) {
1723
+ this._client = e;
1724
+ }
1725
+ /**
1726
+ * Get the current data client
1727
+ * @returns The DataClient instance or undefined if not set
1728
+ */
1729
+ getClient() {
1730
+ return this._client;
1706
1731
  }
1707
1732
  /**
1708
1733
  * Get the operation log store (lazy initialization)
1709
1734
  * @internal
1710
1735
  */
1711
1736
  getOperationLogStore() {
1712
- return this._operationLogStore || (this._operationLogStore = Dt(), this._operationLogConfig && this._operationLogStore.configure(this._operationLogConfig)), this._operationLogStore;
1737
+ return this._operationLogStore || (this._operationLogStore = Ct(), this._operationLogConfig && this._operationLogStore.configure(this._operationLogConfig)), this._operationLogStore;
1713
1738
  }
1714
1739
  /**
1715
1740
  * Initialize the HST store structure
1716
1741
  */
1717
1742
  initializeHSTStore() {
1718
1743
  const e = {};
1719
- Object.keys(this.registry.registry).forEach((o) => {
1720
- e[o] = {};
1721
- }), this.hstStore = No(mt(e), "StonecropStore");
1744
+ Object.keys(this.registry.registry).forEach((t) => {
1745
+ e[t] = {};
1746
+ }), this.hstStore = Co(yt(e), "StonecropStore");
1722
1747
  }
1723
1748
  /**
1724
1749
  * Setup automatic sync with Registry when doctypes are added
1725
1750
  */
1726
1751
  setupRegistrySync() {
1727
1752
  const e = this.registry.addDoctype.bind(this.registry);
1728
- this.registry.addDoctype = (o) => {
1729
- e(o), this.hstStore.has(o.slug) || this.hstStore.set(o.slug, {});
1753
+ this.registry.addDoctype = (t) => {
1754
+ e(t), this.hstStore.has(t.slug) || this.hstStore.set(t.slug, {});
1730
1755
  };
1731
1756
  }
1732
1757
  /**
@@ -1735,8 +1760,8 @@ class $o {
1735
1760
  * @returns HST node containing records hash
1736
1761
  */
1737
1762
  records(e) {
1738
- const o = typeof e == "string" ? e : e.slug;
1739
- return this.ensureDoctypeExists(o), this.hstStore.getNode(o);
1763
+ const t = typeof e == "string" ? e : e.slug;
1764
+ return this.ensureDoctypeExists(t), this.hstStore.getNode(t);
1740
1765
  }
1741
1766
  /**
1742
1767
  * Add a record to the store
@@ -1744,9 +1769,9 @@ class $o {
1744
1769
  * @param recordId - The record ID
1745
1770
  * @param recordData - The record data
1746
1771
  */
1747
- addRecord(e, o, n) {
1772
+ addRecord(e, t, o) {
1748
1773
  const r = typeof e == "string" ? e : e.slug;
1749
- this.ensureDoctypeExists(r), this.hstStore.set(`${r}.${o}`, n);
1774
+ this.ensureDoctypeExists(r), this.hstStore.set(`${r}.${t}`, o);
1750
1775
  }
1751
1776
  /**
1752
1777
  * Get a specific record
@@ -1754,19 +1779,19 @@ class $o {
1754
1779
  * @param recordId - The record ID
1755
1780
  * @returns HST node for the record or undefined
1756
1781
  */
1757
- getRecordById(e, o) {
1758
- const n = typeof e == "string" ? e : e.slug;
1759
- if (this.ensureDoctypeExists(n), !(!this.hstStore.has(`${n}.${o}`) || this.hstStore.get(`${n}.${o}`) === void 0))
1760
- return this.hstStore.getNode(`${n}.${o}`);
1782
+ getRecordById(e, t) {
1783
+ const o = typeof e == "string" ? e : e.slug;
1784
+ if (this.ensureDoctypeExists(o), !(!this.hstStore.has(`${o}.${t}`) || this.hstStore.get(`${o}.${t}`) === void 0))
1785
+ return this.hstStore.getNode(`${o}.${t}`);
1761
1786
  }
1762
1787
  /**
1763
1788
  * Remove a record from the store
1764
1789
  * @param doctype - The doctype
1765
1790
  * @param recordId - The record ID
1766
1791
  */
1767
- removeRecord(e, o) {
1768
- const n = typeof e == "string" ? e : e.slug;
1769
- this.ensureDoctypeExists(n), this.hstStore.has(`${n}.${o}`) && this.hstStore.set(`${n}.${o}`, void 0);
1792
+ removeRecord(e, t) {
1793
+ const o = typeof e == "string" ? e : e.slug;
1794
+ this.ensureDoctypeExists(o), this.hstStore.has(`${o}.${t}`) && this.hstStore.set(`${o}.${t}`, void 0);
1770
1795
  }
1771
1796
  /**
1772
1797
  * Get all record IDs for a doctype
@@ -1774,19 +1799,19 @@ class $o {
1774
1799
  * @returns Array of record IDs
1775
1800
  */
1776
1801
  getRecordIds(e) {
1777
- const o = typeof e == "string" ? e : e.slug;
1778
- this.ensureDoctypeExists(o);
1779
- const n = this.hstStore.get(o);
1780
- return !n || typeof n != "object" ? [] : Object.keys(n).filter((r) => n[r] !== void 0);
1802
+ const t = typeof e == "string" ? e : e.slug;
1803
+ this.ensureDoctypeExists(t);
1804
+ const o = this.hstStore.get(t);
1805
+ return !o || typeof o != "object" ? [] : Object.keys(o).filter((r) => o[r] !== void 0);
1781
1806
  }
1782
1807
  /**
1783
1808
  * Clear all records for a doctype
1784
1809
  * @param doctype - The doctype
1785
1810
  */
1786
1811
  clearRecords(e) {
1787
- const o = typeof e == "string" ? e : e.slug;
1788
- this.ensureDoctypeExists(o), this.getRecordIds(o).forEach((n) => {
1789
- this.hstStore.set(`${o}.${n}`, void 0);
1812
+ const t = typeof e == "string" ? e : e.slug;
1813
+ this.ensureDoctypeExists(t), this.getRecordIds(t).forEach((o) => {
1814
+ this.hstStore.set(`${t}.${o}`, void 0);
1790
1815
  });
1791
1816
  }
1792
1817
  /**
@@ -1803,39 +1828,66 @@ class $o {
1803
1828
  * @param action - The action to run
1804
1829
  * @param args - Action arguments (typically record IDs)
1805
1830
  */
1806
- runAction(e, o, n) {
1807
- const r = this.registry.registry[e.slug]?.actions?.get(o), i = Array.isArray(n) ? n.filter((f) => typeof f == "string") : void 0, a = this.getOperationLogStore();
1808
- let u = "success", c;
1831
+ runAction(e, t, o) {
1832
+ const r = this.registry.registry[e.slug]?.actions?.get(t), a = Array.isArray(o) ? o.filter((u) => typeof u == "string") : void 0, s = this.getOperationLogStore();
1833
+ let c = "success", d;
1809
1834
  try {
1810
- r && r.length > 0 && r.forEach((f) => {
1835
+ r && r.length > 0 && r.forEach((u) => {
1811
1836
  try {
1812
- new Function("args", f)(n);
1813
- } catch (p) {
1814
- throw u = "failure", c = p instanceof Error ? p.message : "Unknown error", p;
1837
+ new Function("args", u)(o);
1838
+ } catch (w) {
1839
+ throw c = "failure", d = w instanceof Error ? w.message : "Unknown error", w;
1815
1840
  }
1816
1841
  });
1817
1842
  } catch {
1818
1843
  } finally {
1819
- a.logAction(e.doctype, o, i, u, c);
1844
+ s.logAction(e.doctype, t, a, c, d);
1820
1845
  }
1821
1846
  }
1822
1847
  /**
1823
- * Get records from server (maintains compatibility)
1848
+ * Get records from server using the configured data client.
1824
1849
  * @param doctype - The doctype
1850
+ * @throws Error if no data client has been configured
1825
1851
  */
1826
1852
  async getRecords(e) {
1827
- (await (await fetch(`/${e.slug}`)).json()).forEach((o) => {
1828
- o.id && this.addRecord(e, o.id, o);
1853
+ if (!this._client)
1854
+ throw new Error(
1855
+ "No data client configured. Call setClient() with a DataClient implementation (e.g., StonecropClient from @stonecrop/graphql-client) before fetching records."
1856
+ );
1857
+ (await this._client.getRecords(e)).forEach((t) => {
1858
+ t.id && this.addRecord(e, t.id, t);
1829
1859
  });
1830
1860
  }
1831
1861
  /**
1832
- * Get single record from server (maintains compatibility)
1862
+ * Get single record from server using the configured data client.
1833
1863
  * @param doctype - The doctype
1834
1864
  * @param recordId - The record ID
1865
+ * @throws Error if no data client has been configured
1835
1866
  */
1836
- async getRecord(e, o) {
1837
- const n = await (await fetch(`/${e.slug}/${o}`)).json();
1838
- this.addRecord(e, o, n);
1867
+ async getRecord(e, t) {
1868
+ if (!this._client)
1869
+ throw new Error(
1870
+ "No data client configured. Call setClient() with a DataClient implementation (e.g., StonecropClient from @stonecrop/graphql-client) before fetching records."
1871
+ );
1872
+ const o = await this._client.getRecord(e, t);
1873
+ o && this.addRecord(e, t, o);
1874
+ }
1875
+ /**
1876
+ * Dispatch an action to the server via the configured data client.
1877
+ * All state changes flow through this single mutation endpoint.
1878
+ *
1879
+ * @param doctype - The doctype
1880
+ * @param action - Action name to execute (e.g., 'SUBMIT', 'APPROVE', 'save')
1881
+ * @param args - Action arguments (typically record ID and/or form data)
1882
+ * @returns Action result with success status, response data, and any error
1883
+ * @throws Error if no data client has been configured
1884
+ */
1885
+ async dispatchAction(e, t, o) {
1886
+ if (!this._client)
1887
+ throw new Error(
1888
+ "No data client configured. Call setClient() with a DataClient implementation (e.g., StonecropClient from @stonecrop/graphql-client) before dispatching actions."
1889
+ );
1890
+ return this._client.runAction(e, t, o);
1839
1891
  }
1840
1892
  /**
1841
1893
  * Ensure doctype section exists in HST store
@@ -1861,252 +1913,271 @@ class $o {
1861
1913
  getStore() {
1862
1914
  return this.hstStore;
1863
1915
  }
1916
+ /**
1917
+ * Determine the current workflow state for a record.
1918
+ *
1919
+ * Reads the record's `status` field from the HST store. If the field is absent or
1920
+ * empty the doctype's declared `workflow.initial` state is used as the fallback,
1921
+ * giving callers a reliable state name without having to duplicate that logic.
1922
+ *
1923
+ * @param doctype - The doctype slug or DoctypeMeta instance
1924
+ * @param recordId - The record identifier
1925
+ * @returns The current state name, or an empty string if the doctype has no workflow
1926
+ *
1927
+ * @public
1928
+ */
1929
+ getRecordState(e, t) {
1930
+ const o = typeof e == "string" ? e : e.slug, r = this.registry.getDoctype(o);
1931
+ if (!r?.workflow) return "";
1932
+ const a = this.getRecordById(o, t)?.get("status"), s = typeof r.workflow.initial == "string" ? r.workflow.initial : Object.keys(r.workflow.states ?? {})[0] ?? "";
1933
+ return a || s;
1934
+ }
1864
1935
  }
1865
- function Co(t) {
1866
- t || (t = {});
1867
- const e = t.registry || be("$registry"), o = be("$stonecrop"), n = C(), r = C(), i = C({}), a = C(), u = C(), c = C([]);
1868
- if (t.doctype && e) {
1869
- const w = t.doctype.schema ? Array.isArray(t.doctype.schema) ? t.doctype.schema : Array.from(t.doctype.schema) : [];
1870
- c.value = e.resolveSchema(w);
1871
- }
1872
- const f = C([]), p = C(-1), b = I(() => n.value?.getOperationLogStore().canUndo ?? !1), h = I(() => n.value?.getOperationLogStore().canRedo ?? !1), _ = I(() => n.value?.getOperationLogStore().undoCount ?? 0), m = I(() => n.value?.getOperationLogStore().redoCount ?? 0), O = I(
1873
- () => n.value?.getOperationLogStore().undoRedoState ?? {
1936
+ function Do(n) {
1937
+ n || (n = {});
1938
+ const e = n.registry || we("$registry"), t = we("$stonecrop"), o = $(), r = $(), a = $({}), s = $(), c = $(), d = $([]);
1939
+ if (n.doctype && e) {
1940
+ const _ = n.doctype.schema ? Array.isArray(n.doctype.schema) ? n.doctype.schema : Array.from(n.doctype.schema) : [];
1941
+ d.value = e.resolveSchema(_);
1942
+ }
1943
+ const u = $([]), w = $(-1), v = R(() => o.value?.getOperationLogStore().canUndo ?? !1), h = R(() => o.value?.getOperationLogStore().canRedo ?? !1), b = R(() => o.value?.getOperationLogStore().undoCount ?? 0), m = R(() => o.value?.getOperationLogStore().redoCount ?? 0), k = R(
1944
+ () => o.value?.getOperationLogStore().undoRedoState ?? {
1874
1945
  canUndo: !1,
1875
1946
  canRedo: !1,
1876
1947
  undoCount: 0,
1877
1948
  redoCount: 0,
1878
1949
  currentIndex: -1
1879
1950
  }
1880
- ), R = (w) => n.value?.getOperationLogStore().undo(w) ?? !1, x = (w) => n.value?.getOperationLogStore().redo(w) ?? !1, H = () => {
1881
- n.value?.getOperationLogStore().startBatch();
1882
- }, U = (w) => n.value?.getOperationLogStore().commitBatch(w) ?? null, K = () => {
1883
- n.value?.getOperationLogStore().cancelBatch();
1884
- }, G = () => {
1885
- n.value?.getOperationLogStore().clear();
1886
- }, z = (w, D) => n.value?.getOperationLogStore().getOperationsFor(w, D) ?? [], E = () => n.value?.getOperationLogStore().getSnapshot() ?? {
1951
+ ), I = (_) => o.value?.getOperationLogStore().undo(_) ?? !1, T = (_) => o.value?.getOperationLogStore().redo(_) ?? !1, Z = () => {
1952
+ o.value?.getOperationLogStore().startBatch();
1953
+ }, U = (_) => o.value?.getOperationLogStore().commitBatch(_) ?? null, z = () => {
1954
+ o.value?.getOperationLogStore().cancelBatch();
1955
+ }, L = () => {
1956
+ o.value?.getOperationLogStore().clear();
1957
+ }, G = (_, C) => o.value?.getOperationLogStore().getOperationsFor(_, C) ?? [], E = () => o.value?.getOperationLogStore().getSnapshot() ?? {
1887
1958
  operations: [],
1888
1959
  currentIndex: -1,
1889
1960
  totalOperations: 0,
1890
1961
  reversibleOperations: 0,
1891
1962
  irreversibleOperations: 0
1892
- }, Y = (w, D) => {
1893
- n.value?.getOperationLogStore().markIrreversible(w, D);
1894
- }, B = (w, D, S, d = "success", s) => n.value?.getOperationLogStore().logAction(w, D, S, d, s) ?? "", v = (w) => {
1895
- n.value?.getOperationLogStore().configure(w);
1963
+ }, Y = (_, C) => {
1964
+ o.value?.getOperationLogStore().markIrreversible(_, C);
1965
+ }, B = (_, C, S, p = "success", f) => o.value?.getOperationLogStore().logAction(_, C, S, p, f) ?? "", g = (_) => {
1966
+ o.value?.getOperationLogStore().configure(_);
1896
1967
  };
1897
- Ae(async () => {
1968
+ xe(async () => {
1898
1969
  if (e) {
1899
- n.value = o || new $o(e);
1970
+ o.value = t || new No(e);
1900
1971
  try {
1901
- const w = n.value.getOperationLogStore(), D = ro(w);
1902
- f.value = D.operations.value, p.value = D.currentIndex.value, L(
1903
- () => D.operations.value,
1972
+ const _ = o.value.getOperationLogStore(), C = oo(_);
1973
+ u.value = C.operations.value, w.value = C.currentIndex.value, H(
1974
+ () => C.operations.value,
1904
1975
  (S) => {
1905
- f.value = S;
1976
+ u.value = S;
1906
1977
  }
1907
- ), L(
1908
- () => D.currentIndex.value,
1978
+ ), H(
1979
+ () => C.currentIndex.value,
1909
1980
  (S) => {
1910
- p.value = S;
1981
+ w.value = S;
1911
1982
  }
1912
1983
  );
1913
1984
  } catch {
1914
1985
  }
1915
- if (!t.doctype && e.router) {
1916
- const w = e.router.currentRoute.value;
1917
- if (!w.path) return;
1918
- const D = w.path.split("/").filter((d) => d.length > 0), S = D[1]?.toLowerCase();
1919
- if (D.length > 0) {
1920
- const d = {
1921
- path: w.path,
1922
- segments: D
1923
- }, s = await e.getMeta?.(d);
1924
- if (s) {
1925
- if (e.addDoctype(s), n.value.setup(s), a.value = s, u.value = S, r.value = n.value.getStore(), e) {
1926
- const l = s.schema ? Array.isArray(s.schema) ? s.schema : Array.from(s.schema) : [];
1927
- c.value = e.resolveSchema(l);
1986
+ if (!n.doctype && e.router) {
1987
+ const _ = e.router.currentRoute.value;
1988
+ if (!_.path) return;
1989
+ const C = _.path.split("/").filter((p) => p.length > 0), S = C[1]?.toLowerCase();
1990
+ if (C.length > 0) {
1991
+ const p = {
1992
+ path: _.path,
1993
+ segments: C
1994
+ }, f = await e.getMeta?.(p);
1995
+ if (f) {
1996
+ if (e.addDoctype(f), o.value.setup(f), s.value = f, c.value = S, r.value = o.value.getStore(), e) {
1997
+ const i = f.schema ? Array.isArray(f.schema) ? f.schema : Array.from(f.schema) : [];
1998
+ d.value = e.resolveSchema(i);
1928
1999
  }
1929
2000
  if (S && S !== "new") {
1930
- const l = n.value.getRecordById(s, S);
1931
- if (l)
1932
- i.value = l.get("") || {};
2001
+ const i = o.value.getRecordById(f, S);
2002
+ if (i)
2003
+ a.value = i.get("") || {};
1933
2004
  else
1934
2005
  try {
1935
- await n.value.getRecord(s, S);
1936
- const y = n.value.getRecordById(s, S);
1937
- y && (i.value = y.get("") || {});
2006
+ await o.value.getRecord(f, S);
2007
+ const l = o.value.getRecordById(f, S);
2008
+ l && (a.value = l.get("") || {});
1938
2009
  } catch {
1939
- i.value = ee(s);
2010
+ a.value = te(f);
1940
2011
  }
1941
2012
  } else
1942
- i.value = ee(s);
1943
- r.value && dt(s, S || "new", i, r.value), n.value.runAction(s, "load", S ? [S] : void 0);
2013
+ a.value = te(f);
2014
+ r.value && dt(f, S || "new", a, r.value), o.value.runAction(f, "load", S ? [S] : void 0);
1944
2015
  }
1945
2016
  }
1946
2017
  }
1947
- if (t.doctype) {
1948
- r.value = n.value.getStore();
1949
- const w = t.doctype, D = t.recordId;
1950
- if (D && D !== "new") {
1951
- const S = n.value.getRecordById(w, D);
2018
+ if (n.doctype) {
2019
+ r.value = o.value.getStore();
2020
+ const _ = n.doctype, C = n.recordId;
2021
+ if (C && C !== "new") {
2022
+ const S = o.value.getRecordById(_, C);
1952
2023
  if (S)
1953
- i.value = S.get("") || {};
2024
+ a.value = S.get("") || {};
1954
2025
  else
1955
2026
  try {
1956
- await n.value.getRecord(w, D);
1957
- const d = n.value.getRecordById(w, D);
1958
- d && (i.value = d.get("") || {});
2027
+ await o.value.getRecord(_, C);
2028
+ const p = o.value.getRecordById(_, C);
2029
+ p && (a.value = p.get("") || {});
1959
2030
  } catch {
1960
- i.value = ee(w);
2031
+ a.value = te(_);
1961
2032
  }
1962
2033
  } else
1963
- i.value = ee(w);
1964
- r.value && dt(w, D || "new", i, r.value);
2034
+ a.value = te(_);
2035
+ r.value && dt(_, C || "new", a, r.value);
1965
2036
  }
1966
2037
  }
1967
2038
  });
1968
- const g = (w, D) => {
1969
- const S = t.doctype || a.value;
2039
+ const y = (_, C) => {
2040
+ const S = n.doctype || s.value;
1970
2041
  if (!S) return "";
1971
- const d = D || t.recordId || u.value || "new";
1972
- return `${S.slug}.${d}.${w}`;
1973
- }, $ = (w) => {
1974
- const D = t.doctype || a.value;
1975
- if (!(!r.value || !n.value || !D))
2042
+ const p = C || n.recordId || c.value || "new";
2043
+ return `${S.slug}.${p}.${_}`;
2044
+ }, D = (_) => {
2045
+ const C = n.doctype || s.value;
2046
+ if (!(!r.value || !o.value || !C))
1976
2047
  try {
1977
- const S = w.path.split(".");
2048
+ const S = _.path.split(".");
1978
2049
  if (S.length >= 2) {
1979
- const l = S[0], y = S[1];
1980
- if (r.value.has(`${l}.${y}`) || n.value.addRecord(D, y, { ...i.value }), S.length > 3) {
1981
- const N = `${l}.${y}`, j = S.slice(2);
1982
- let J = N;
1983
- for (let W = 0; W < j.length - 1; W++)
1984
- if (J += `.${j[W]}`, !r.value.has(J)) {
1985
- const te = j[W + 1], q = !isNaN(Number(te));
1986
- r.value.set(J, q ? [] : {});
2050
+ const i = S[0], l = S[1];
2051
+ if (r.value.has(`${i}.${l}`) || o.value.addRecord(C, l, { ...a.value }), S.length > 3) {
2052
+ const A = `${i}.${l}`, O = S.slice(2);
2053
+ let W = A;
2054
+ for (let J = 0; J < O.length - 1; J++)
2055
+ if (W += `.${O[J]}`, !r.value.has(W)) {
2056
+ const Q = O[J + 1], _e = !isNaN(Number(Q));
2057
+ r.value.set(W, _e ? [] : {});
1987
2058
  }
1988
2059
  }
1989
2060
  }
1990
- r.value.set(w.path, w.value);
1991
- const d = w.fieldname.split("."), s = { ...i.value };
1992
- d.length === 1 ? s[d[0]] = w.value : Ro(s, d, w.value), i.value = s;
2061
+ r.value.set(_.path, _.value);
2062
+ const p = _.fieldname.split("."), f = { ...a.value };
2063
+ p.length === 1 ? f[p[0]] = _.value : Oo(f, p, _.value), a.value = f;
1993
2064
  } catch {
1994
2065
  }
1995
2066
  };
1996
- (t.doctype || e?.router) && (Ge("hstPathProvider", g), Ge("hstChangeHandler", $));
1997
- const M = (w, D, S) => {
1998
- if (!n.value)
1999
- return ee(D);
2067
+ (n.doctype || e?.router) && (Ge("hstPathProvider", y), Ge("hstChangeHandler", D));
2068
+ const F = (_, C, S) => {
2069
+ if (!o.value)
2070
+ return te(C);
2000
2071
  if (S)
2001
2072
  try {
2002
- const d = r.value?.get(w);
2003
- return d && typeof d == "object" ? d : ee(D);
2073
+ const p = r.value?.get(_);
2074
+ return p && typeof p == "object" ? p : te(C);
2004
2075
  } catch {
2005
- return ee(D);
2076
+ return te(C);
2006
2077
  }
2007
- return ee(D);
2008
- }, k = async (w, D) => {
2009
- if (!r.value || !n.value)
2078
+ return te(C);
2079
+ }, N = (_, C) => {
2080
+ if (!r.value || !o.value)
2010
2081
  throw new Error("HST store not initialized");
2011
- const S = `${w.slug}.${D}`, d = { ...r.value.get(S) || {} }, s = w.schema ? Array.isArray(w.schema) ? w.schema : Array.from(w.schema) : [], l = (e ? e.resolveSchema(s) : s).filter(
2012
- (y) => "fieldtype" in y && y.fieldtype === "Doctype" && "schema" in y && Array.isArray(y.schema)
2082
+ const S = `${_.slug}.${C}`, p = { ...r.value.get(S) || {} }, f = _.schema ? Array.isArray(_.schema) ? _.schema : Array.from(_.schema) : [], i = (e ? e.resolveSchema(f) : f).filter(
2083
+ (l) => "fieldtype" in l && l.fieldtype === "Doctype" && "schema" in l && Array.isArray(l.schema)
2013
2084
  );
2014
- for (const y of l) {
2015
- const N = y, j = `${S}.${N.fieldname}`, J = Ot(N.schema, j, r.value);
2016
- d[N.fieldname] = J;
2085
+ for (const l of i) {
2086
+ const A = l, O = `${S}.${A.fieldname}`, W = Nt(A.schema, O, r.value);
2087
+ p[A.fieldname] = W;
2017
2088
  }
2018
- return d;
2019
- }, T = (w, D) => ({
2020
- provideHSTPath: (S) => `${w}.${S}`,
2089
+ return p;
2090
+ }, V = (_, C) => ({
2091
+ provideHSTPath: (S) => `${_}.${S}`,
2021
2092
  handleHSTChange: (S) => {
2022
- const d = S.path.startsWith(w) ? S.path : `${w}.${S.fieldname}`;
2023
- $({
2093
+ const p = S.path.startsWith(_) ? S.path : `${_}.${S.fieldname}`;
2094
+ D({
2024
2095
  ...S,
2025
- path: d
2096
+ path: p
2026
2097
  });
2027
2098
  }
2028
- }), F = {
2029
- operations: f,
2030
- currentIndex: p,
2031
- undoRedoState: O,
2032
- canUndo: b,
2099
+ }), M = {
2100
+ operations: u,
2101
+ currentIndex: w,
2102
+ undoRedoState: k,
2103
+ canUndo: v,
2033
2104
  canRedo: h,
2034
- undoCount: _,
2105
+ undoCount: b,
2035
2106
  redoCount: m,
2036
- undo: R,
2037
- redo: x,
2038
- startBatch: H,
2107
+ undo: I,
2108
+ redo: T,
2109
+ startBatch: Z,
2039
2110
  commitBatch: U,
2040
- cancelBatch: K,
2041
- clear: G,
2042
- getOperationsFor: z,
2111
+ cancelBatch: z,
2112
+ clear: L,
2113
+ getOperationsFor: G,
2043
2114
  getSnapshot: E,
2044
2115
  markIrreversible: Y,
2045
2116
  logAction: B,
2046
- configure: v
2117
+ configure: g
2047
2118
  };
2048
- return t.doctype ? {
2049
- stonecrop: n,
2050
- operationLog: F,
2051
- provideHSTPath: g,
2052
- handleHSTChange: $,
2119
+ return n.doctype ? {
2120
+ stonecrop: o,
2121
+ operationLog: M,
2122
+ provideHSTPath: y,
2123
+ handleHSTChange: D,
2053
2124
  hstStore: r,
2054
- formData: i,
2055
- resolvedSchema: c,
2056
- loadNestedData: M,
2057
- saveRecursive: k,
2058
- createNestedContext: T
2059
- } : !t.doctype && e?.router ? {
2060
- stonecrop: n,
2061
- operationLog: F,
2062
- provideHSTPath: g,
2063
- handleHSTChange: $,
2125
+ formData: a,
2126
+ resolvedSchema: d,
2127
+ loadNestedData: F,
2128
+ saveRecursive: N,
2129
+ createNestedContext: V
2130
+ } : !n.doctype && e?.router ? {
2131
+ stonecrop: o,
2132
+ operationLog: M,
2133
+ provideHSTPath: y,
2134
+ handleHSTChange: D,
2064
2135
  hstStore: r,
2065
- formData: i,
2066
- resolvedSchema: c,
2067
- loadNestedData: M,
2068
- saveRecursive: k,
2069
- createNestedContext: T
2136
+ formData: a,
2137
+ resolvedSchema: d,
2138
+ loadNestedData: F,
2139
+ saveRecursive: N,
2140
+ createNestedContext: V
2070
2141
  } : {
2071
- stonecrop: n,
2072
- operationLog: F
2142
+ stonecrop: o,
2143
+ operationLog: M
2073
2144
  };
2074
2145
  }
2075
- function ee(t) {
2146
+ function te(n) {
2076
2147
  const e = {};
2077
- return t.schema && t.schema.forEach((o) => {
2078
- switch ("fieldtype" in o ? o.fieldtype : "Data") {
2148
+ return n.schema && n.schema.forEach((t) => {
2149
+ switch ("fieldtype" in t ? t.fieldtype : "Data") {
2079
2150
  case "Data":
2080
2151
  case "Text":
2081
- e[o.fieldname] = "";
2152
+ e[t.fieldname] = "";
2082
2153
  break;
2083
2154
  case "Check":
2084
- e[o.fieldname] = !1;
2155
+ e[t.fieldname] = !1;
2085
2156
  break;
2086
2157
  case "Int":
2087
2158
  case "Float":
2088
- e[o.fieldname] = 0;
2159
+ e[t.fieldname] = 0;
2089
2160
  break;
2090
2161
  case "Table":
2091
- e[o.fieldname] = [];
2162
+ e[t.fieldname] = [];
2092
2163
  break;
2093
2164
  case "JSON":
2094
- e[o.fieldname] = {};
2165
+ e[t.fieldname] = {};
2095
2166
  break;
2096
2167
  default:
2097
- e[o.fieldname] = null;
2168
+ e[t.fieldname] = null;
2098
2169
  }
2099
2170
  }), e;
2100
2171
  }
2101
- function dt(t, e, o, n) {
2102
- L(
2103
- o,
2172
+ function dt(n, e, t, o) {
2173
+ H(
2174
+ t,
2104
2175
  (r) => {
2105
- const i = `${t.slug}.${e}`;
2106
- Object.keys(r).forEach((a) => {
2107
- const u = `${i}.${a}`;
2176
+ const a = `${n.slug}.${e}`;
2177
+ Object.keys(r).forEach((s) => {
2178
+ const c = `${a}.${s}`;
2108
2179
  try {
2109
- n.set(u, r[a]);
2180
+ o.set(c, r[s]);
2110
2181
  } catch {
2111
2182
  }
2112
2183
  });
@@ -2114,152 +2185,152 @@ function dt(t, e, o, n) {
2114
2185
  { deep: !0 }
2115
2186
  );
2116
2187
  }
2117
- function Ro(t, e, o) {
2118
- let n = t;
2119
- for (let i = 0; i < e.length - 1; i++) {
2120
- const a = e[i];
2121
- (!(a in n) || typeof n[a] != "object") && (n[a] = isNaN(Number(e[i + 1])) ? {} : []), n = n[a];
2188
+ function Oo(n, e, t) {
2189
+ let o = n;
2190
+ for (let a = 0; a < e.length - 1; a++) {
2191
+ const s = e[a];
2192
+ (!(s in o) || typeof o[s] != "object") && (o[s] = isNaN(Number(e[a + 1])) ? {} : []), o = o[s];
2122
2193
  }
2123
2194
  const r = e[e.length - 1];
2124
- n[r] = o;
2195
+ o[r] = t;
2125
2196
  }
2126
- function Ot(t, e, o) {
2127
- const n = { ...o.get(e) || {} }, r = t.filter(
2128
- (i) => "fieldtype" in i && i.fieldtype === "Doctype" && "schema" in i && Array.isArray(i.schema)
2197
+ function Nt(n, e, t) {
2198
+ const o = { ...t.get(e) || {} }, r = n.filter(
2199
+ (a) => "fieldtype" in a && a.fieldtype === "Doctype" && "schema" in a && Array.isArray(a.schema)
2129
2200
  );
2130
- for (const i of r) {
2131
- const a = i, u = `${e}.${a.fieldname}`, c = Ot(a.schema, u, o);
2132
- n[a.fieldname] = c;
2201
+ for (const a of r) {
2202
+ const s = a, c = `${e}.${s.fieldname}`, d = Nt(s.schema, c, t);
2203
+ o[s.fieldname] = d;
2133
2204
  }
2134
- return n;
2205
+ return o;
2135
2206
  }
2136
2207
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
2137
- function Io(t, e) {
2138
- return Qe() ? (Xe(t, e), !0) : !1;
2208
+ function Ao(n, e) {
2209
+ return Xe() ? (Ye(n, e), !0) : !1;
2139
2210
  }
2140
2211
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
2141
- const Ao = () => {
2212
+ const $o = () => {
2142
2213
  };
2143
- function xo(...t) {
2144
- if (t.length !== 1) return re(...t);
2145
- const e = t[0];
2146
- return typeof e == "function" ? Te(Ye(() => ({
2214
+ function Io(...n) {
2215
+ if (n.length !== 1) return re(...n);
2216
+ const e = n[0];
2217
+ return typeof e == "function" ? Pe(et(() => ({
2147
2218
  get: e,
2148
- set: Ao
2149
- }))) : C(e);
2219
+ set: $o
2220
+ }))) : $(e);
2150
2221
  }
2151
- function Le(t) {
2152
- return typeof Window < "u" && t instanceof Window ? t.document.documentElement : typeof Document < "u" && t instanceof Document ? t.documentElement : t;
2222
+ function Be(n) {
2223
+ return typeof Window < "u" && n instanceof Window ? n.document.documentElement : typeof Document < "u" && n instanceof Document ? n.documentElement : n;
2153
2224
  }
2154
- const Be = /* @__PURE__ */ new WeakMap();
2155
- function To(t, e = !1) {
2156
- const o = Se(e);
2157
- let n = "";
2158
- L(xo(t), (a) => {
2159
- const u = Le(Q(a));
2160
- if (u) {
2161
- const c = u;
2162
- if (Be.get(c) || Be.set(c, c.style.overflow), c.style.overflow !== "hidden" && (n = c.style.overflow), c.style.overflow === "hidden") return o.value = !0;
2163
- if (o.value) return c.style.overflow = "hidden";
2225
+ const We = /* @__PURE__ */ new WeakMap();
2226
+ function Ro(n, e = !1) {
2227
+ const t = Se(e);
2228
+ let o = "";
2229
+ H(Io(n), (s) => {
2230
+ const c = Be(K(s));
2231
+ if (c) {
2232
+ const d = c;
2233
+ if (We.get(d) || We.set(d, d.style.overflow), d.style.overflow !== "hidden" && (o = d.style.overflow), d.style.overflow === "hidden") return t.value = !0;
2234
+ if (t.value) return d.style.overflow = "hidden";
2164
2235
  }
2165
2236
  }, { immediate: !0 });
2166
2237
  const r = () => {
2167
- const a = Le(Q(t));
2168
- !a || o.value || (a.style.overflow = "hidden", o.value = !0);
2169
- }, i = () => {
2170
- const a = Le(Q(t));
2171
- !a || !o.value || (a.style.overflow = n, Be.delete(a), o.value = !1);
2238
+ const s = Be(K(n));
2239
+ !s || t.value || (s.style.overflow = "hidden", t.value = !0);
2240
+ }, a = () => {
2241
+ const s = Be(K(n));
2242
+ !s || !t.value || (s.style.overflow = o, We.delete(s), t.value = !1);
2172
2243
  };
2173
- return Io(i), I({
2244
+ return Ao(a), R({
2174
2245
  get() {
2175
- return o.value;
2246
+ return t.value;
2176
2247
  },
2177
- set(a) {
2178
- a ? r() : i();
2248
+ set(s) {
2249
+ s ? r() : a();
2179
2250
  }
2180
2251
  });
2181
2252
  }
2182
- function Po() {
2183
- let t = !1;
2253
+ function xo() {
2254
+ let n = !1;
2184
2255
  const e = Se(!1);
2185
- return (o, n) => {
2186
- if (e.value = n.value, t) return;
2187
- t = !0;
2188
- const r = To(o, n.value);
2189
- L(e, (i) => r.value = i);
2256
+ return (t, o) => {
2257
+ if (e.value = o.value, n) return;
2258
+ n = !0;
2259
+ const r = Ro(t, o.value);
2260
+ H(e, (a) => r.value = a);
2190
2261
  };
2191
2262
  }
2192
- Po();
2193
- const Vo = (t, e) => {
2194
- const o = t.__vccOpts || t;
2195
- for (const [n, r] of e)
2196
- o[n] = r;
2197
- return o;
2263
+ xo();
2264
+ const To = (n, e) => {
2265
+ const t = n.__vccOpts || n;
2266
+ for (const [o, r] of e)
2267
+ t[o] = r;
2268
+ return t;
2198
2269
  };
2199
- function jo(t, e) {
2200
- return Qe() ? (Xe(t, e), !0) : !1;
2270
+ function Po(n, e) {
2271
+ return Xe() ? (Ye(n, e), !0) : !1;
2201
2272
  }
2202
2273
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
2203
- const Mo = () => {
2274
+ const Vo = () => {
2204
2275
  };
2205
- function Fo(...t) {
2206
- if (t.length !== 1) return re(...t);
2207
- const e = t[0];
2208
- return typeof e == "function" ? Te(Ye(() => ({
2276
+ function jo(...n) {
2277
+ if (n.length !== 1) return re(...n);
2278
+ const e = n[0];
2279
+ return typeof e == "function" ? Pe(et(() => ({
2209
2280
  get: e,
2210
- set: Mo
2211
- }))) : C(e);
2281
+ set: Vo
2282
+ }))) : $(e);
2212
2283
  }
2213
- function We(t) {
2214
- return typeof Window < "u" && t instanceof Window ? t.document.documentElement : typeof Document < "u" && t instanceof Document ? t.documentElement : t;
2284
+ function He(n) {
2285
+ return typeof Window < "u" && n instanceof Window ? n.document.documentElement : typeof Document < "u" && n instanceof Document ? n.documentElement : n;
2215
2286
  }
2216
- const He = /* @__PURE__ */ new WeakMap();
2217
- function Lo(t, e = !1) {
2218
- const o = Se(e);
2219
- let n = "";
2220
- L(Fo(t), (a) => {
2221
- const u = We(Q(a));
2222
- if (u) {
2223
- const c = u;
2224
- if (He.get(c) || He.set(c, c.style.overflow), c.style.overflow !== "hidden" && (n = c.style.overflow), c.style.overflow === "hidden") return o.value = !0;
2225
- if (o.value) return c.style.overflow = "hidden";
2287
+ const Ue = /* @__PURE__ */ new WeakMap();
2288
+ function Mo(n, e = !1) {
2289
+ const t = Se(e);
2290
+ let o = "";
2291
+ H(jo(n), (s) => {
2292
+ const c = He(K(s));
2293
+ if (c) {
2294
+ const d = c;
2295
+ if (Ue.get(d) || Ue.set(d, d.style.overflow), d.style.overflow !== "hidden" && (o = d.style.overflow), d.style.overflow === "hidden") return t.value = !0;
2296
+ if (t.value) return d.style.overflow = "hidden";
2226
2297
  }
2227
2298
  }, { immediate: !0 });
2228
2299
  const r = () => {
2229
- const a = We(Q(t));
2230
- !a || o.value || (a.style.overflow = "hidden", o.value = !0);
2231
- }, i = () => {
2232
- const a = We(Q(t));
2233
- !a || !o.value || (a.style.overflow = n, He.delete(a), o.value = !1);
2300
+ const s = He(K(n));
2301
+ !s || t.value || (s.style.overflow = "hidden", t.value = !0);
2302
+ }, a = () => {
2303
+ const s = He(K(n));
2304
+ !s || !t.value || (s.style.overflow = o, Ue.delete(s), t.value = !1);
2234
2305
  };
2235
- return jo(i), I({
2306
+ return Po(a), R({
2236
2307
  get() {
2237
- return o.value;
2308
+ return t.value;
2238
2309
  },
2239
- set(a) {
2240
- a ? r() : i();
2310
+ set(s) {
2311
+ s ? r() : a();
2241
2312
  }
2242
2313
  });
2243
2314
  }
2244
- function Bo() {
2245
- let t = !1;
2315
+ function Fo() {
2316
+ let n = !1;
2246
2317
  const e = Se(!1);
2247
- return (o, n) => {
2248
- if (e.value = n.value, t) return;
2249
- t = !0;
2250
- const r = Lo(o, n.value);
2251
- L(e, (i) => r.value = i);
2318
+ return (t, o) => {
2319
+ if (e.value = o.value, n) return;
2320
+ n = !0;
2321
+ const r = Mo(t, o.value);
2322
+ H(e, (a) => r.value = a);
2252
2323
  };
2253
2324
  }
2254
- Bo();
2325
+ Fo();
2255
2326
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
2256
- const Wo = { class: "aform" }, Ho = {
2327
+ const Lo = { class: "aform" }, Bo = {
2257
2328
  key: 0,
2258
2329
  class: "aform-nested-section"
2259
- }, Uo = {
2330
+ }, Wo = {
2260
2331
  key: 0,
2261
2332
  class: "aform-nested-label"
2262
- }, zo = /* @__PURE__ */ we({
2333
+ }, Ho = /* @__PURE__ */ be({
2263
2334
  __name: "AForm",
2264
2335
  props: /* @__PURE__ */ ot({
2265
2336
  schema: {},
@@ -2269,110 +2340,110 @@ const Wo = { class: "aform" }, Ho = {
2269
2340
  dataModifiers: {}
2270
2341
  }),
2271
2342
  emits: /* @__PURE__ */ ot(["update:schema", "update:data"], ["update:data"]),
2272
- setup(t, { emit: e }) {
2273
- const o = e, n = xt(t, "data"), r = C({});
2274
- L(
2275
- () => n.value,
2276
- (b) => {
2277
- !t.schema || !b || t.schema.forEach((h) => {
2278
- "schema" in h && Array.isArray(h.schema) && h.schema.length > 0 && (r.value[h.fieldname] = b[h.fieldname] ?? {});
2343
+ setup(n, { emit: e }) {
2344
+ const t = e, o = It(n, "data"), r = $({});
2345
+ H(
2346
+ () => o.value,
2347
+ (v) => {
2348
+ !n.schema || !v || n.schema.forEach((h) => {
2349
+ "schema" in h && Array.isArray(h.schema) && h.schema.length > 0 && (r.value[h.fieldname] = v[h.fieldname] ?? {});
2279
2350
  });
2280
2351
  },
2281
2352
  { immediate: !0 }
2282
2353
  );
2283
- const i = (b, h) => {
2284
- r.value[b] = h, n.value && (n.value[b] = h, o("update:data", { ...n.value }));
2285
- }, a = (b) => {
2354
+ const a = (v, h) => {
2355
+ r.value[v] = h, o.value && (o.value[v] = h, t("update:data", { ...o.value }));
2356
+ }, s = (v) => {
2286
2357
  const h = {};
2287
- for (const [_, m] of Object.entries(b))
2288
- ["component", "fieldtype", "mode"].includes(_) || (h[_] = m), _ === "rows" && (!m || Array.isArray(m) && m.length === 0) && (h.rows = n.value[b.fieldname] || []);
2358
+ for (const [b, m] of Object.entries(v))
2359
+ ["component", "fieldtype", "mode"].includes(b) || (h[b] = m), b === "rows" && (!m || Array.isArray(m) && m.length === 0) && (h.rows = o.value[v.fieldname] || []);
2289
2360
  return h;
2290
- }, u = I(() => t.mode ?? "edit");
2291
- function c(b) {
2292
- return b.mode || u.value;
2361
+ }, c = R(() => n.mode ?? "edit");
2362
+ function d(v) {
2363
+ return v.mode || c.value;
2293
2364
  }
2294
- const f = C([]);
2295
- Tt(() => {
2296
- t.schema && f.value.length !== t.schema.length && (f.value = t.schema.map((b, h) => I({
2365
+ const u = $([]);
2366
+ Rt(() => {
2367
+ n.schema && u.value.length !== n.schema.length && (u.value = n.schema.map((v, h) => R({
2297
2368
  get() {
2298
- return n.value?.[t.schema[h].fieldname];
2369
+ return o.value?.[n.schema[h].fieldname];
2299
2370
  },
2300
- set: (_) => {
2301
- const m = t.schema[h].fieldname;
2302
- m && n.value && (n.value[m] = _, o("update:data", { ...n.value })), o("update:schema", t.schema);
2371
+ set: (b) => {
2372
+ const m = n.schema[h].fieldname;
2373
+ m && o.value && (o.value[m] = b, t("update:data", { ...o.value })), t("update:schema", n.schema);
2303
2374
  }
2304
2375
  })));
2305
2376
  });
2306
- const p = I(() => f.value);
2307
- return (b, h) => {
2308
- const _ = yt("AForm", !0);
2309
- return P(), V("form", Wo, [
2310
- (P(!0), V(de, null, me(t.schema, (m, O) => (P(), V(de, { key: O }, [
2311
- "schema" in m && Array.isArray(m.schema) && m.schema.length > 0 ? (P(), V("div", Ho, [
2312
- m.label ? (P(), V("h4", Uo, X(m.label), 1)) : ue("", !0),
2313
- ne(_, {
2377
+ const w = R(() => u.value);
2378
+ return (v, h) => {
2379
+ const b = mt("AForm", !0);
2380
+ return P(), j("form", Lo, [
2381
+ (P(!0), j(ue, null, ye(n.schema, (m, k) => (P(), j(ue, { key: k }, [
2382
+ "schema" in m && Array.isArray(m.schema) && m.schema.length > 0 ? (P(), j("div", Bo, [
2383
+ m.label ? (P(), j("h4", Wo, X(m.label), 1)) : ce("", !0),
2384
+ ne(b, {
2314
2385
  data: r.value[m.fieldname],
2315
- mode: c(m),
2386
+ mode: d(m),
2316
2387
  schema: m.schema,
2317
- "onUpdate:data": (R) => i(m.fieldname, R)
2388
+ "onUpdate:data": (I) => a(m.fieldname, I)
2318
2389
  }, null, 8, ["data", "mode", "schema", "onUpdate:data"])
2319
- ])) : (P(), Ze(Pt(m.component), Vt({
2390
+ ])) : (P(), Qe(xt(m.component), Tt({
2320
2391
  key: 1,
2321
- modelValue: p.value[O].value,
2322
- "onUpdate:modelValue": (R) => p.value[O].value = R,
2392
+ modelValue: w.value[k].value,
2393
+ "onUpdate:modelValue": (I) => w.value[k].value = I,
2323
2394
  schema: m,
2324
- data: n.value[m.fieldname],
2325
- mode: c(m)
2326
- }, { ref_for: !0 }, a(m)), null, 16, ["modelValue", "onUpdate:modelValue", "schema", "data", "mode"]))
2395
+ data: o.value[m.fieldname],
2396
+ mode: d(m)
2397
+ }, { ref_for: !0 }, s(m)), null, 16, ["modelValue", "onUpdate:modelValue", "schema", "data", "mode"]))
2327
2398
  ], 64))), 128))
2328
2399
  ]);
2329
2400
  };
2330
2401
  }
2331
- }), Go = /* @__PURE__ */ Vo(zo, [["__scopeId", "data-v-5c01cea5"]]), Jo = { class: "tabs" }, Ko = { tabindex: "0" }, qo = { tabindex: "0" }, Zo = /* @__PURE__ */ we({
2402
+ }), Uo = /* @__PURE__ */ To(Ho, [["__scopeId", "data-v-5c01cea5"]]), Jo = { class: "tabs" }, zo = { tabindex: "0" }, Go = { tabindex: "0" }, qo = /* @__PURE__ */ be({
2332
2403
  __name: "SheetNav",
2333
2404
  props: {
2334
2405
  breadcrumbs: { default: () => [] }
2335
2406
  },
2336
- setup(t) {
2337
- const e = C(!0), o = C(!1), n = C(""), r = ft("searchinput"), i = I(() => e.value ? "unrotated" : "rotated"), a = () => {
2407
+ setup(n) {
2408
+ const e = $(!0), t = $(!1), o = $(""), r = pt("searchinput"), a = R(() => e.value ? "unrotated" : "rotated"), s = () => {
2338
2409
  e.value = !e.value;
2339
- }, u = async () => {
2340
- o.value = !o.value, await ae(() => {
2410
+ }, c = async () => {
2411
+ t.value = !t.value, await de(() => {
2341
2412
  r.value?.focus();
2342
2413
  });
2343
- }, c = (b) => {
2344
- b.preventDefault(), b.stopPropagation();
2345
- }, f = async (b) => {
2346
- b.preventDefault(), b.stopPropagation(), await u();
2347
- }, p = () => {
2414
+ }, d = (v) => {
2415
+ v.preventDefault(), v.stopPropagation();
2416
+ }, u = async (v) => {
2417
+ v.preventDefault(), v.stopPropagation(), await c();
2418
+ }, w = () => {
2348
2419
  };
2349
- return (b, h) => {
2350
- const _ = yt("router-link");
2351
- return P(), V("footer", null, [
2352
- A("ul", Jo, [
2353
- A("li", {
2420
+ return (v, h) => {
2421
+ const b = mt("router-link");
2422
+ return P(), j("footer", null, [
2423
+ x("ul", Jo, [
2424
+ x("li", {
2354
2425
  class: "hidebreadcrumbs",
2355
- onClick: a,
2356
- onKeydown: pe(a, ["enter"])
2426
+ onClick: s,
2427
+ onKeydown: fe(s, ["enter"])
2357
2428
  }, [
2358
- A("a", Ko, [
2359
- A("div", {
2360
- class: Oe(i.value)
2429
+ x("a", zo, [
2430
+ x("div", {
2431
+ class: De(a.value)
2361
2432
  }, "×", 2)
2362
2433
  ])
2363
2434
  ], 32),
2364
- A("li", {
2435
+ x("li", {
2365
2436
  class: "hometab",
2366
- style: Ve({ display: e.value ? "block" : "none" }),
2367
- onClick: p,
2368
- onKeydown: pe(p, ["enter"])
2437
+ style: je({ display: e.value ? "block" : "none" }),
2438
+ onClick: w,
2439
+ onKeydown: fe(w, ["enter"])
2369
2440
  }, [
2370
- ne(_, {
2441
+ ne(b, {
2371
2442
  to: "/",
2372
2443
  tabindex: "0"
2373
2444
  }, {
2374
- default: ye(() => [...h[5] || (h[5] = [
2375
- A("svg", {
2445
+ default: me(() => [...h[5] || (h[5] = [
2446
+ x("svg", {
2376
2447
  class: "icon",
2377
2448
  "aria-label": "Home",
2378
2449
  viewBox: "0 0 24 24",
@@ -2380,19 +2451,19 @@ const Wo = { class: "aform" }, Ho = {
2380
2451
  stroke: "currentColor",
2381
2452
  "stroke-width": "2"
2382
2453
  }, [
2383
- A("path", { d: "M3 12l9-9 9 9" }),
2384
- A("path", { d: "M9 21V12h6v9" })
2454
+ x("path", { d: "M3 12l9-9 9 9" }),
2455
+ x("path", { d: "M9 21V12h6v9" })
2385
2456
  ], -1)
2386
2457
  ])]),
2387
2458
  _: 1
2388
2459
  })
2389
2460
  ], 36),
2390
- A("li", {
2391
- class: Oe(["searchtab", { "search-active": o.value }]),
2392
- style: Ve({ display: e.value ? "block" : "none" })
2461
+ x("li", {
2462
+ class: De(["searchtab", { "search-active": t.value }]),
2463
+ style: je({ display: e.value ? "block" : "none" })
2393
2464
  }, [
2394
- A("a", qo, [
2395
- Ne((P(), V("svg", {
2465
+ x("a", Go, [
2466
+ Oe((P(), j("svg", {
2396
2467
  class: "icon search-icon",
2397
2468
  role: "button",
2398
2469
  "aria-label": "Search",
@@ -2400,47 +2471,47 @@ const Wo = { class: "aform" }, Ho = {
2400
2471
  fill: "none",
2401
2472
  stroke: "currentColor",
2402
2473
  "stroke-width": "2",
2403
- onClick: u,
2404
- onKeydown: pe(u, ["enter"])
2474
+ onClick: c,
2475
+ onKeydown: fe(c, ["enter"])
2405
2476
  }, [...h[6] || (h[6] = [
2406
- A("circle", {
2477
+ x("circle", {
2407
2478
  cx: "11",
2408
2479
  cy: "11",
2409
2480
  r: "7"
2410
2481
  }, null, -1),
2411
- A("path", { d: "M21 21l-4.35-4.35" }, null, -1)
2482
+ x("path", { d: "M21 21l-4.35-4.35" }, null, -1)
2412
2483
  ])], 544)), [
2413
- [Ue, !o.value]
2484
+ [Je, !t.value]
2414
2485
  ]),
2415
- Ne(A("input", {
2486
+ Oe(x("input", {
2416
2487
  ref: "searchinput",
2417
- "onUpdate:modelValue": h[0] || (h[0] = (m) => n.value = m),
2488
+ "onUpdate:modelValue": h[0] || (h[0] = (m) => o.value = m),
2418
2489
  type: "text",
2419
2490
  placeholder: "Search...",
2420
- onClick: h[1] || (h[1] = pt(() => {
2491
+ onClick: h[1] || (h[1] = ft(() => {
2421
2492
  }, ["stop"])),
2422
- onInput: h[2] || (h[2] = (m) => c(m)),
2423
- onBlur: h[3] || (h[3] = (m) => f(m)),
2493
+ onInput: h[2] || (h[2] = (m) => d(m)),
2494
+ onBlur: h[3] || (h[3] = (m) => u(m)),
2424
2495
  onKeydown: [
2425
- h[4] || (h[4] = pe((m) => f(m), ["enter"])),
2426
- pe(u, ["escape"])
2496
+ h[4] || (h[4] = fe((m) => u(m), ["enter"])),
2497
+ fe(c, ["escape"])
2427
2498
  ]
2428
2499
  }, null, 544), [
2429
- [Ue, o.value],
2430
- [ht, n.value]
2500
+ [Je, t.value],
2501
+ [ht, o.value]
2431
2502
  ])
2432
2503
  ])
2433
2504
  ], 6),
2434
- (P(!0), V(de, null, me(t.breadcrumbs, (m) => (P(), V("li", {
2505
+ (P(!0), j(ue, null, ye(n.breadcrumbs, (m) => (P(), j("li", {
2435
2506
  key: m.title,
2436
- style: Ve({ display: e.value ? "block" : "none" })
2507
+ style: je({ display: e.value ? "block" : "none" })
2437
2508
  }, [
2438
- ne(_, {
2509
+ ne(b, {
2439
2510
  tabindex: "0",
2440
2511
  to: m.to
2441
2512
  }, {
2442
- default: ye(() => [
2443
- $e(X(m.title), 1)
2513
+ default: me(() => [
2514
+ Ae(X(m.title), 1)
2444
2515
  ]),
2445
2516
  _: 2
2446
2517
  }, 1032, ["to"])
@@ -2449,135 +2520,117 @@ const Wo = { class: "aform" }, Ho = {
2449
2520
  ]);
2450
2521
  };
2451
2522
  }
2452
- }), Nt = /* @__PURE__ */ bt(Zo, [["__scopeId", "data-v-eb5bcbb6"]]), Qo = {
2523
+ }), Dt = /* @__PURE__ */ wt(qo, [["__scopeId", "data-v-eb5bcbb6"]]), Ko = {
2453
2524
  key: 1,
2454
2525
  class: "loading"
2455
- }, Xo = {
2526
+ }, Zo = {
2456
2527
  key: 2,
2457
2528
  class: "loading"
2458
- }, Yo = /* @__PURE__ */ we({
2529
+ }, Qo = /* @__PURE__ */ be({
2459
2530
  __name: "Desktop",
2460
2531
  props: {
2461
- availableDoctypes: { default: () => [] }
2532
+ availableDoctypes: {},
2533
+ routeAdapter: {},
2534
+ confirmFn: { type: Function }
2462
2535
  },
2463
- setup(t) {
2464
- const { stonecrop: e } = Co(), o = C(!1), n = C(!1), r = C(!1), i = I({
2536
+ emits: ["action", "navigate", "record:open"],
2537
+ setup(n, { emit: e }) {
2538
+ const t = n, o = e, { availableDoctypes: r = [] } = t, { stonecrop: a } = Do(), s = $(!1), c = $(!1), d = R({
2465
2539
  get() {
2466
- if (!e.value || !c.value || !p.value)
2540
+ if (!a.value || !v.value || !b.value)
2467
2541
  return {};
2468
2542
  try {
2469
- return { ...e.value.getRecordById(c.value, p.value)?.get("") || {} };
2543
+ return { ...a.value.getRecordById(v.value, b.value)?.get("") || {} };
2470
2544
  } catch {
2471
2545
  return {};
2472
2546
  }
2473
2547
  },
2474
- set(s) {
2475
- if (!(!e.value || !c.value || !p.value))
2548
+ set(i) {
2549
+ if (!(!a.value || !v.value || !b.value))
2476
2550
  try {
2477
- const l = e.value.getStore();
2478
- for (const [y, N] of Object.entries(s)) {
2479
- const j = `${c.value}.${p.value}.${y}`;
2480
- (l.has(j) ? l.get(j) : void 0) !== N && l.set(j, N);
2551
+ const l = a.value.getStore();
2552
+ for (const [A, O] of Object.entries(i)) {
2553
+ const W = `${v.value}.${b.value}.${A}`;
2554
+ (l.has(W) ? l.get(W) : void 0) !== O && l.set(W, O);
2481
2555
  }
2482
2556
  } catch (l) {
2483
2557
  console.warn("HST update failed:", l);
2484
2558
  }
2485
2559
  }
2486
- }), a = I(() => De(e.value?.registry.router?.currentRoute)), u = I(() => e.value?.registry.router), c = I(() => {
2487
- if (!a.value) return "";
2488
- if (a.value.meta?.actualDoctype)
2489
- return a.value.meta.actualDoctype;
2490
- if (a.value.params.doctype)
2491
- return a.value.params.doctype;
2492
- const s = a.value.params.pathMatch;
2493
- return s && s.length > 0 ? s[0] : "";
2494
- }), f = I(() => {
2495
- if (!a.value) return "";
2496
- if (a.value.meta?.doctype)
2497
- return a.value.meta.doctype;
2498
- if (a.value.params.doctype)
2499
- return a.value.params.doctype;
2500
- const s = a.value.params.pathMatch;
2501
- return s && s.length > 0 ? s[0] : "";
2502
- }), p = I(() => {
2503
- if (!a.value) return "";
2504
- if (a.value.params.recordId)
2505
- return a.value.params.recordId;
2506
- const s = a.value.params.pathMatch;
2507
- return s && s.length > 1 ? s[1] : "";
2508
- }), b = I(() => p.value?.startsWith("new-")), h = I(() => {
2509
- if (!a.value || a.value.name === "home" || a.value.path === "/")
2560
+ }), u = R(() => t.routeAdapter ? null : Ne(a.value?.registry.router?.currentRoute)), w = R(() => t.routeAdapter ? null : a.value?.registry.router), v = R(() => {
2561
+ if (t.routeAdapter) return t.routeAdapter.getCurrentDoctype();
2562
+ if (!u.value) return "";
2563
+ if (u.value.meta?.actualDoctype)
2564
+ return u.value.meta.actualDoctype;
2565
+ if (u.value.params.doctype)
2566
+ return u.value.params.doctype;
2567
+ const i = u.value.params.pathMatch;
2568
+ return i && i.length > 0 ? i[0] : "";
2569
+ }), h = R(() => {
2570
+ if (t.routeAdapter) return t.routeAdapter.getCurrentDoctype();
2571
+ if (!u.value) return "";
2572
+ if (u.value.meta?.doctype)
2573
+ return u.value.meta.doctype;
2574
+ if (u.value.params.doctype)
2575
+ return u.value.params.doctype;
2576
+ const i = u.value.params.pathMatch;
2577
+ return i && i.length > 0 ? i[0] : "";
2578
+ }), b = R(() => {
2579
+ if (t.routeAdapter) return t.routeAdapter.getCurrentRecordId();
2580
+ if (!u.value) return "";
2581
+ if (u.value.params.recordId)
2582
+ return u.value.params.recordId;
2583
+ const i = u.value.params.pathMatch;
2584
+ return i && i.length > 1 ? i[1] : "";
2585
+ }), m = R(() => b.value?.startsWith("new-")), k = R(() => {
2586
+ if (t.routeAdapter) return t.routeAdapter.getCurrentView();
2587
+ if (!u.value || u.value.name === "home" || u.value.path === "/")
2510
2588
  return "doctypes";
2511
- if (a.value.name && a.value.name !== "catch-all") {
2512
- const l = a.value.name;
2513
- if (l.includes("form") || a.value.params.recordId)
2589
+ if (u.value.name && u.value.name !== "catch-all") {
2590
+ const l = u.value.name;
2591
+ if (l.includes("form") || u.value.params.recordId)
2514
2592
  return "record";
2515
- if (l.includes("list") || a.value.params.doctype)
2593
+ if (l.includes("list") || u.value.params.doctype)
2516
2594
  return "records";
2517
2595
  }
2518
- const s = a.value.params.pathMatch;
2519
- return s && s.length > 0 ? s.length === 1 ? "records" : "record" : "doctypes";
2520
- }), _ = () => {
2521
- if (!e.value || !c.value || !p.value)
2596
+ const i = u.value.params.pathMatch;
2597
+ return i && i.length > 0 ? i.length === 1 ? "records" : "record" : "doctypes";
2598
+ }), I = () => {
2599
+ if (!a.value || !v.value || !b.value)
2522
2600
  return [];
2523
2601
  try {
2524
- const l = e.value.registry.registry[c.value];
2525
- if (!l?.workflow?.states)
2526
- return [];
2527
- const y = b.value ? "creating" : "editing", N = l.workflow.states[y];
2528
- return N?.on ? Object.keys(N.on).map((W) => {
2529
- const te = N.on?.[W], q = typeof te == "string" ? te : "unknown", $t = async () => {
2530
- const et = e.value?.getRecordById(c.value, p.value);
2531
- if (et) {
2532
- const Ct = i.value || {};
2533
- await et.triggerTransition(W, {
2534
- currentState: y,
2535
- targetState: q,
2536
- fsmContext: Ct
2537
- });
2538
- }
2539
- };
2540
- return {
2541
- label: `${W} (→ ${q})`,
2542
- action: $t
2543
- };
2544
- }) : [];
2545
- } catch (s) {
2546
- return console.warn("Error getting available transitions:", s), [];
2602
+ const i = a.value.registry.getDoctype(v.value);
2603
+ if (!i?.workflow) return [];
2604
+ const l = a.value.getRecordState(v.value, b.value), A = i.getAvailableTransitions(l), O = d.value || {};
2605
+ return A.map(({ name: W, targetState: J }) => ({
2606
+ label: `${W} ( ${J})`,
2607
+ action: () => {
2608
+ o("action", {
2609
+ name: W,
2610
+ doctype: v.value,
2611
+ recordId: b.value,
2612
+ data: O
2613
+ });
2614
+ }
2615
+ }));
2616
+ } catch (i) {
2617
+ return console.warn("Error getting available transitions:", i), [];
2547
2618
  }
2548
- }, m = I(() => {
2549
- const s = [];
2550
- switch (h.value) {
2551
- case "doctypes":
2552
- s.push({
2619
+ }, T = R(() => {
2620
+ const i = [];
2621
+ switch (k.value) {
2622
+ case "records":
2623
+ i.push({
2553
2624
  type: "button",
2554
- label: "Refresh",
2625
+ label: "New Record",
2555
2626
  action: () => {
2556
- window.location.reload();
2627
+ g();
2557
2628
  }
2558
2629
  });
2559
2630
  break;
2560
- case "records":
2561
- s.push(
2562
- {
2563
- type: "button",
2564
- label: "New Record",
2565
- action: () => {
2566
- z();
2567
- }
2568
- },
2569
- {
2570
- type: "button",
2571
- label: "Refresh",
2572
- action: () => {
2573
- window.location.reload();
2574
- }
2575
- }
2576
- );
2577
- break;
2578
2631
  case "record": {
2579
- const l = _();
2580
- l.length > 0 && s.push({
2632
+ const l = I();
2633
+ l.length > 0 && i.push({
2581
2634
  type: "dropdown",
2582
2635
  label: "Actions",
2583
2636
  actions: l
@@ -2585,77 +2638,80 @@ const Wo = { class: "aform" }, Ho = {
2585
2638
  break;
2586
2639
  }
2587
2640
  }
2588
- return s;
2589
- }), O = I(() => {
2590
- const s = [];
2591
- return h.value === "records" && f.value ? s.push(
2592
- { title: "Home", to: "/" },
2593
- { title: H(f.value), to: `/${f.value}` }
2594
- ) : h.value === "record" && f.value && s.push(
2595
- { title: "Home", to: "/" },
2596
- { title: H(f.value), to: `/${f.value}` },
2597
- { title: b.value ? "New Record" : "Edit Record", to: a.value?.fullPath || "" }
2598
- ), s;
2599
- }), R = (s) => {
2641
+ return i;
2642
+ }), Z = R(() => {
2643
+ const i = [];
2644
+ if (k.value === "records" && h.value)
2645
+ i.push(
2646
+ { title: "Home", to: "/" },
2647
+ { title: L(h.value), to: `/${h.value}` }
2648
+ );
2649
+ else if (k.value === "record" && h.value) {
2650
+ const l = b.value ? `/${h.value}/${b.value}` : u.value?.fullPath ?? "";
2651
+ i.push(
2652
+ { title: "Home", to: "/" },
2653
+ { title: L(h.value), to: `/${h.value}` },
2654
+ { title: m.value ? "New Record" : "Edit Record", to: l }
2655
+ );
2656
+ }
2657
+ return i;
2658
+ }), U = (i) => {
2600
2659
  const l = [
2601
2660
  {
2602
2661
  title: "Go Home",
2603
2662
  description: "Navigate to the home page",
2604
2663
  action: () => {
2605
- u.value?.push("/");
2664
+ E({ view: "doctypes" });
2606
2665
  }
2607
2666
  },
2608
2667
  {
2609
2668
  title: "Toggle Command Palette",
2610
2669
  description: "Open/close the command palette",
2611
- action: () => r.value = !r.value
2670
+ action: () => c.value = !c.value
2612
2671
  }
2613
2672
  ];
2614
- return f.value && (l.push({
2615
- title: `View ${H(f.value)} Records`,
2616
- description: `Navigate to ${f.value} list`,
2673
+ return h.value && (l.push({
2674
+ title: `View ${L(h.value)} Records`,
2675
+ description: `Navigate to ${h.value} list`,
2617
2676
  action: () => {
2618
- u.value?.push(`/${f.value}`);
2677
+ E({ view: "records", doctype: h.value });
2619
2678
  }
2620
2679
  }), l.push({
2621
- title: `Create New ${H(f.value)}`,
2622
- description: `Create a new ${f.value} record`,
2680
+ title: `Create New ${L(h.value)}`,
2681
+ description: `Create a new ${h.value} record`,
2623
2682
  action: () => {
2624
- z();
2683
+ g();
2625
2684
  }
2626
- })), t.availableDoctypes.forEach((y) => {
2685
+ })), r.forEach((A) => {
2627
2686
  l.push({
2628
- title: `View ${H(y)}`,
2629
- description: `Navigate to ${y} list`,
2687
+ title: `View ${L(A)}`,
2688
+ description: `Navigate to ${A} list`,
2630
2689
  action: () => {
2631
- u.value?.push(`/${y}`);
2690
+ E({ view: "records", doctype: A });
2632
2691
  }
2633
2692
  });
2634
- }), s ? l.filter(
2635
- (y) => y.title.toLowerCase().includes(s.toLowerCase()) || y.description.toLowerCase().includes(s.toLowerCase())
2693
+ }), i ? l.filter(
2694
+ (A) => A.title.toLowerCase().includes(i.toLowerCase()) || A.description.toLowerCase().includes(i.toLowerCase())
2636
2695
  ) : l;
2637
- }, x = (s) => {
2638
- s.action(), r.value = !1;
2639
- }, H = (s) => s.split("-").map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join(" "), U = (s) => e.value ? e.value.getRecordIds(s).length : 0, K = async (s) => {
2640
- await u.value?.push(`/${s}`);
2641
- }, G = async (s) => {
2642
- await u.value?.push(`/${f.value}/${s}`);
2643
- }, z = async () => {
2644
- const s = `new-${Date.now()}`;
2645
- await u.value?.push(`/${f.value}/${s}`);
2646
- }, E = (s) => {
2647
- if (e.value)
2648
- try {
2649
- e.value.records(s);
2650
- } catch {
2651
- }
2652
- }, Y = () => {
2653
- if (!t.availableDoctypes.length) return [];
2654
- const s = t.availableDoctypes.map((l) => ({
2696
+ }, z = (i) => {
2697
+ i.action(), c.value = !1;
2698
+ }, L = (i) => i.split("-").map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join(" "), G = (i) => a.value ? a.value.getRecordIds(i).length : 0, E = async (i) => {
2699
+ o("navigate", i), t.routeAdapter ? await t.routeAdapter.navigate(i) : i.view === "doctypes" ? await w.value?.push("/") : i.view === "records" && i.doctype ? await w.value?.push(`/${i.doctype}`) : i.view === "record" && i.doctype && i.recordId && await w.value?.push(`/${i.doctype}/${i.recordId}`);
2700
+ }, Y = async (i) => {
2701
+ await E({ view: "records", doctype: i });
2702
+ }, B = async (i) => {
2703
+ const l = h.value;
2704
+ o("record:open", { doctype: l, recordId: i }), await E({ view: "record", doctype: l, recordId: i });
2705
+ }, g = async () => {
2706
+ const i = `new-${Date.now()}`;
2707
+ await E({ view: "record", doctype: h.value, recordId: i });
2708
+ }, y = () => {
2709
+ if (!r.length) return [];
2710
+ const i = r.map((l) => ({
2655
2711
  id: l,
2656
2712
  doctype: l,
2657
- display_name: H(l),
2658
- record_count: U(l),
2713
+ display_name: L(l),
2714
+ record_count: G(l),
2659
2715
  actions: "View Records"
2660
2716
  }));
2661
2717
  return [
@@ -2700,19 +2756,19 @@ const Wo = { class: "aform" }, Ho = {
2700
2756
  view: "list",
2701
2757
  fullWidth: !0
2702
2758
  },
2703
- rows: s
2759
+ rows: i
2704
2760
  }
2705
2761
  ];
2706
- }, B = () => {
2707
- if (!c.value) return [];
2708
- if (!e.value) return [];
2709
- const s = g(), l = $();
2762
+ }, D = () => {
2763
+ if (!v.value) return [];
2764
+ if (!a.value) return [];
2765
+ const i = N(), l = V();
2710
2766
  if (l.length === 0)
2711
2767
  return [];
2712
- const y = s.map((N) => ({
2713
- ...N,
2768
+ const A = i.map((O) => ({
2769
+ ...O,
2714
2770
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2715
- id: N.id || "",
2771
+ id: O.id || "",
2716
2772
  actions: "Edit | Delete"
2717
2773
  }));
2718
2774
  return [
@@ -2720,10 +2776,10 @@ const Wo = { class: "aform" }, Ho = {
2720
2776
  fieldname: "records_table",
2721
2777
  component: "ATable",
2722
2778
  columns: [
2723
- ...l.map((N) => ({
2724
- label: N.label,
2725
- name: N.fieldname,
2726
- fieldtype: N.fieldtype,
2779
+ ...l.map((O) => ({
2780
+ label: O.label,
2781
+ name: O.fieldname,
2782
+ fieldtype: O.fieldtype,
2727
2783
  align: "left",
2728
2784
  edit: !1,
2729
2785
  width: "20ch"
@@ -2741,235 +2797,172 @@ const Wo = { class: "aform" }, Ho = {
2741
2797
  view: "list",
2742
2798
  fullWidth: !0
2743
2799
  },
2744
- rows: y
2800
+ rows: A
2745
2801
  }
2746
2802
  ];
2747
- }, v = () => {
2748
- if (!c.value) return [];
2749
- if (!e.value) return [];
2803
+ }, F = () => {
2804
+ if (!v.value) return [];
2805
+ if (!a.value) return [];
2750
2806
  try {
2751
- const l = e.value?.registry?.registry[c.value];
2807
+ const l = a.value?.registry?.registry[v.value];
2752
2808
  return l?.schema ? "toArray" in l.schema ? l.schema.toArray() : l.schema : [];
2753
2809
  } catch {
2754
2810
  return [];
2755
2811
  }
2756
- }, g = () => {
2757
- if (!e.value || !c.value)
2812
+ }, N = () => {
2813
+ if (!a.value || !v.value)
2758
2814
  return [];
2759
- const l = e.value.records(c.value)?.get("");
2815
+ const l = a.value.records(v.value)?.get("");
2760
2816
  return l && typeof l == "object" && !Array.isArray(l) ? Object.values(l) : [];
2761
- }, $ = () => {
2762
- if (!e.value || !c.value) return [];
2817
+ }, V = () => {
2818
+ if (!a.value || !v.value) return [];
2763
2819
  try {
2764
- const l = e.value.registry.registry[c.value];
2820
+ const l = a.value.registry.registry[v.value];
2765
2821
  if (l?.schema)
2766
- return ("toArray" in l.schema ? l.schema.toArray() : l.schema).map((N) => ({
2767
- fieldname: N.fieldname,
2768
- label: "label" in N && N.label || N.fieldname,
2769
- fieldtype: "fieldtype" in N && N.fieldtype || "Data"
2822
+ return ("toArray" in l.schema ? l.schema.toArray() : l.schema).map((O) => ({
2823
+ fieldname: O.fieldname,
2824
+ label: "label" in O && O.label || O.fieldname,
2825
+ fieldtype: "fieldtype" in O && O.fieldtype || "Data"
2770
2826
  }));
2771
2827
  } catch {
2772
2828
  }
2773
2829
  return [];
2774
- }, M = I(() => {
2775
- switch (h.value) {
2830
+ }, M = R(() => {
2831
+ switch (k.value) {
2776
2832
  case "doctypes":
2777
- return Y();
2833
+ return y();
2778
2834
  case "records":
2779
- return B();
2835
+ return D();
2780
2836
  case "record":
2781
- return v();
2837
+ return F();
2782
2838
  default:
2783
2839
  return [];
2784
2840
  }
2785
- }), k = async () => {
2786
- if (e.value) {
2787
- n.value = !0;
2788
- try {
2789
- const s = i.value || {};
2790
- if (b.value) {
2791
- const l = `record-${Date.now()}`, y = { id: l, ...s };
2792
- e.value.addRecord(c.value, l, y);
2793
- const N = e.value.getRecordById(c.value, l);
2794
- N && await N.triggerTransition("SAVE", {
2795
- currentState: "creating",
2796
- targetState: "saved",
2797
- fsmContext: y
2798
- }), await u.value?.replace(`/${f.value}/${l}`);
2799
- } else {
2800
- const l = { id: p.value, ...s };
2801
- e.value.addRecord(c.value, p.value, l);
2802
- const y = e.value.getRecordById(c.value, p.value);
2803
- y && await y.triggerTransition("SAVE", {
2804
- currentState: "editing",
2805
- targetState: "saved",
2806
- fsmContext: l
2807
- });
2808
- }
2809
- } catch {
2810
- } finally {
2811
- n.value = !1;
2812
- }
2813
- }
2814
- }, T = async () => {
2815
- if (b.value)
2816
- await u.value?.push(`/${f.value}`);
2817
- else {
2818
- if (e.value) {
2819
- const s = e.value.getRecordById(c.value, p.value);
2820
- s && await s.triggerTransition("CANCEL", {
2821
- currentState: "editing",
2822
- targetState: "cancelled"
2823
- });
2824
- }
2825
- S();
2826
- }
2827
- }, F = (s, l) => {
2841
+ }), _ = (i, l) => {
2828
2842
  l && l();
2829
- }, w = async (s) => {
2830
- if (!e.value) return;
2831
- const l = s || p.value;
2832
- if (l && confirm("Are you sure you want to delete this record?")) {
2833
- const y = e.value.getRecordById(c.value, l);
2834
- y && await y.triggerTransition("DELETE", {
2835
- currentState: "editing",
2836
- targetState: "deleted"
2837
- }), e.value.removeRecord(c.value, l), h.value === "record" && await u.value?.push(`/${f.value}`);
2838
- }
2839
- }, D = async (s) => {
2840
- const l = s.target, y = l.getAttribute("data-action");
2841
- if (y)
2842
- switch (y) {
2843
- case "create":
2844
- await z();
2845
- break;
2846
- case "save":
2847
- await k();
2848
- break;
2849
- case "cancel":
2850
- await T();
2851
- break;
2852
- case "delete":
2853
- await w();
2854
- break;
2855
- }
2856
- const N = l.closest("td, th");
2857
- if (N) {
2858
- const j = N.textContent?.trim(), J = N.closest("tr");
2859
- if (j === "View Records" && J) {
2860
- const W = J.querySelectorAll("td");
2861
- if (W.length > 0) {
2862
- const q = W[1].textContent?.trim();
2863
- q && await K(q);
2843
+ }, C = async (i) => {
2844
+ const l = i || b.value;
2845
+ if (!l) return;
2846
+ (t.confirmFn ? await t.confirmFn("Are you sure you want to delete this record?") : confirm("Are you sure you want to delete this record?")) && o("action", {
2847
+ name: "DELETE",
2848
+ doctype: v.value,
2849
+ recordId: l,
2850
+ data: d.value || {}
2851
+ });
2852
+ }, S = async (i) => {
2853
+ const l = i.target;
2854
+ l.getAttribute("data-action") === "create" && await g();
2855
+ const O = l.closest("td, th");
2856
+ if (O) {
2857
+ const W = O.textContent?.trim(), J = O.closest("tr");
2858
+ if (W === "View Records" && J) {
2859
+ const Q = J.querySelectorAll("td");
2860
+ if (Q.length > 0) {
2861
+ const ee = Q[1].textContent?.trim();
2862
+ ee && await Y(ee);
2864
2863
  }
2865
- } else if (j?.includes("Edit") && J) {
2866
- const W = J.querySelectorAll("td");
2867
- if (W.length > 0) {
2868
- const q = W[0].textContent?.trim();
2869
- q && await G(q);
2864
+ } else if (W?.includes("Edit") && J) {
2865
+ const Q = J.querySelectorAll("td");
2866
+ if (Q.length > 0) {
2867
+ const ee = Q[0].textContent?.trim();
2868
+ ee && await B(ee);
2870
2869
  }
2871
- } else if (j?.includes("Delete") && J) {
2872
- const W = J.querySelectorAll("td");
2873
- if (W.length > 0) {
2874
- const q = W[0].textContent?.trim();
2875
- q && await w(q);
2870
+ } else if (W?.includes("Delete") && J) {
2871
+ const Q = J.querySelectorAll("td");
2872
+ if (Q.length > 0) {
2873
+ const ee = Q[0].textContent?.trim();
2874
+ ee && await C(ee);
2876
2875
  }
2877
2876
  }
2878
2877
  }
2879
- };
2880
- L(
2881
- [h, c, p],
2882
- () => {
2883
- h.value === "record" && S();
2884
- },
2885
- { immediate: !0 }
2886
- ), L(
2887
- e,
2888
- (s) => {
2889
- },
2890
- { immediate: !0 }
2891
- ), L(
2892
- [h, c, e],
2893
- ([s, l, y]) => {
2894
- s === "records" && l && y && E(l);
2895
- },
2896
- { immediate: !0 }
2897
- );
2898
- const S = () => {
2899
- if (!(!e.value || !c.value)) {
2900
- o.value = !0;
2878
+ }, p = () => {
2879
+ if (!(!a.value || !v.value)) {
2880
+ s.value = !0;
2901
2881
  try {
2902
- b.value || e.value.getRecordById(c.value, p.value);
2903
- } catch (s) {
2904
- console.warn("Error loading record data:", s);
2882
+ m.value || a.value.getRecordById(v.value, b.value);
2883
+ } catch (i) {
2884
+ console.warn("Error loading record data:", i);
2905
2885
  } finally {
2906
- o.value = !1;
2886
+ s.value = !1;
2907
2887
  }
2908
2888
  }
2909
2889
  };
2910
- return Ge("desktopMethods", {
2911
- navigateToDoctype: K,
2912
- openRecord: G,
2913
- createNewRecord: z,
2914
- handleSave: k,
2915
- handleCancel: T,
2916
- handleDelete: w
2917
- }), Ae(() => {
2918
- ae(() => {
2919
- h.value === "records" && c.value && e.value && E(c.value);
2920
- });
2921
- const s = (l) => {
2922
- (l.ctrlKey || l.metaKey) && l.key === "k" && (l.preventDefault(), r.value = !0), l.key === "Escape" && r.value && (r.value = !1);
2890
+ return H(
2891
+ [k, v, b],
2892
+ () => {
2893
+ k.value === "record" && p();
2894
+ },
2895
+ { immediate: !0 }
2896
+ ), Ge("desktopMethods", {
2897
+ navigateToDoctype: Y,
2898
+ openRecord: B,
2899
+ createNewRecord: g,
2900
+ handleDelete: C,
2901
+ /**
2902
+ * Convenience wrapper so child components (e.g. slot content) can emit
2903
+ * an action event without needing a direct reference to the emit function.
2904
+ */
2905
+ emitAction: (i, l) => {
2906
+ o("action", {
2907
+ name: i,
2908
+ doctype: v.value,
2909
+ recordId: b.value,
2910
+ data: l ?? d.value ?? {}
2911
+ });
2912
+ }
2913
+ }), xe(() => {
2914
+ const i = (l) => {
2915
+ (l.ctrlKey || l.metaKey) && l.key === "k" && (l.preventDefault(), c.value = !0), l.key === "Escape" && c.value && (c.value = !1);
2923
2916
  };
2924
- return document.addEventListener("keydown", s), () => {
2925
- document.removeEventListener("keydown", s);
2917
+ return document.addEventListener("keydown", i), () => {
2918
+ document.removeEventListener("keydown", i);
2926
2919
  };
2927
- }), (s, l) => (P(), V("div", {
2920
+ }), (i, l) => (P(), j("div", {
2928
2921
  class: "desktop",
2929
- onClick: D
2922
+ onClick: S
2930
2923
  }, [
2931
- ne(wt, {
2932
- elements: m.value,
2933
- onActionClick: F
2924
+ ne(bt, {
2925
+ elements: T.value,
2926
+ onActionClick: _
2934
2927
  }, null, 8, ["elements"]),
2935
- M.value.length > 0 ? (P(), Ze(De(Go), {
2928
+ M.value.length > 0 ? (P(), Qe(Ne(Uo), {
2936
2929
  key: 0,
2937
- data: i.value,
2938
- "onUpdate:data": l[0] || (l[0] = (y) => i.value = y),
2930
+ data: d.value,
2931
+ "onUpdate:data": l[0] || (l[0] = (A) => d.value = A),
2939
2932
  schema: M.value
2940
- }, null, 8, ["data", "schema"])) : De(e) ? (P(), V("div", Xo, [
2941
- A("p", null, "Loading " + X(h.value) + " data...", 1)
2942
- ])) : (P(), V("div", Qo, [...l[2] || (l[2] = [
2943
- A("p", null, "Initializing Stonecrop...", -1)
2933
+ }, null, 8, ["data", "schema"])) : Ne(a) ? (P(), j("div", Zo, [
2934
+ x("p", null, "Loading " + X(k.value) + " data...", 1)
2935
+ ])) : (P(), j("div", Ko, [...l[2] || (l[2] = [
2936
+ x("p", null, "Initializing Stonecrop...", -1)
2944
2937
  ])])),
2945
- ne(Nt, { breadcrumbs: O.value }, null, 8, ["breadcrumbs"]),
2938
+ ne(Dt, { breadcrumbs: Z.value }, null, 8, ["breadcrumbs"]),
2946
2939
  ne(St, {
2947
- "is-open": r.value,
2948
- search: R,
2940
+ "is-open": c.value,
2941
+ search: U,
2949
2942
  placeholder: "Type a command or search...",
2950
- onSelect: x,
2951
- onClose: l[1] || (l[1] = (y) => r.value = !1)
2943
+ onSelect: z,
2944
+ onClose: l[1] || (l[1] = (A) => c.value = !1)
2952
2945
  }, {
2953
- title: ye(({ result: y }) => [
2954
- $e(X(y.title), 1)
2946
+ title: me(({ result: A }) => [
2947
+ Ae(X(A.title), 1)
2955
2948
  ]),
2956
- content: ye(({ result: y }) => [
2957
- $e(X(y.description), 1)
2949
+ content: me(({ result: A }) => [
2950
+ Ae(X(A.description), 1)
2958
2951
  ]),
2959
2952
  _: 1
2960
2953
  }, 8, ["is-open"])
2961
2954
  ]));
2962
2955
  }
2963
- }), on = {
2964
- install: (t) => {
2965
- t.component("ActionSet", wt), t.component("CommandPalette", St), t.component("Desktop", Yo), t.component("SheetNav", Nt);
2956
+ }), Yo = {
2957
+ install: (n) => {
2958
+ n.component("ActionSet", bt), n.component("CommandPalette", St), n.component("Desktop", Qo), n.component("SheetNav", Dt);
2966
2959
  }
2967
2960
  };
2968
2961
  export {
2969
- wt as ActionSet,
2962
+ bt as ActionSet,
2970
2963
  St as CommandPalette,
2971
- Yo as Desktop,
2972
- Nt as SheetNav,
2973
- on as StonecropDesktop
2964
+ Qo as Desktop,
2965
+ Dt as SheetNav,
2966
+ Yo as StonecropDesktop
2974
2967
  };
2975
2968
  //# sourceMappingURL=desktop.js.map