@nice2dev/ui-forms 1.4.12 → 1.4.14

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/studio.mjs CHANGED
@@ -1,138 +1,183 @@
1
- var ve = Object.defineProperty;
2
- var we = (e, t, n) => t in e ? ve(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var Q = (e, t, n) => we(e, typeof t != "symbol" ? t + "" : t, n);
4
- const D = () => ({
1
+ var Ke = Object.defineProperty;
2
+ var Ie = (e, t, n) => t in e ? Ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var oe = (e, t, n) => Ie(e, typeof t != "symbol" ? t + "" : t, n);
4
+ const U = () => ({
5
5
  version: 1,
6
6
  sections: [],
7
7
  folders: [],
8
8
  placement: {}
9
- }), pt = (e, t) => `${e}:${t}`, U = ".studio.json", Se = /^([^/]+?)\.(manifest|entities|views|workflows|permissions|rbac|seeds|datasources|scripts)\.json$/i, $e = (e) => !e.includes("/") && e.toLowerCase().endsWith(U);
10
- function ut(e) {
11
- const t = e.find((n) => $e(n.path));
9
+ }), It = (e, t) => `${e}:${t}`, W = ".studio.json", Ne = /^([^/]+?)\.(manifest|entities|views|workflows|permissions|rbac|seeds|datasources|scripts)\.json$/i, xe = (e) => !e.includes("/") && e.toLowerCase().endsWith(W);
10
+ function Nt(e) {
11
+ const t = e.find((n) => xe(n.path));
12
12
  if (t)
13
13
  return t.path;
14
14
  for (const n of e) {
15
- const s = Se.exec(n.path);
15
+ const s = Ne.exec(n.path);
16
16
  if (s)
17
- return `${s[1]}${U}`;
17
+ return `${s[1]}${W}`;
18
18
  }
19
- return `module${U}`;
19
+ return `module${W}`;
20
20
  }
21
- const N = (e) => typeof e == "object" && e !== null && !Array.isArray(e), b = (e) => typeof e == "string" && e ? e : void 0;
22
- function mt(e) {
21
+ const T = (e) => typeof e == "object" && e !== null && !Array.isArray(e), v = (e) => typeof e == "string" && e ? e : void 0;
22
+ function xt(e) {
23
23
  if (!e)
24
- return D();
24
+ return U();
25
25
  let t;
26
26
  try {
27
27
  t = JSON.parse(e.replace(/^\uFEFF/, ""));
28
28
  } catch {
29
- return D();
29
+ return U();
30
30
  }
31
- if (!N(t))
32
- return D();
33
- const n = (Array.isArray(t.sections) ? t.sections : []).filter(N).map((i) => ({ id: b(i.id), label: b(i.label) ?? b(i.id) })).filter((i) => !!i.id && !!i.label), s = (Array.isArray(t.folders) ? t.folders : []).filter(N).map((i) => ({
34
- id: b(i.id),
35
- label: b(i.label) ?? b(i.id),
36
- group: b(i.group),
37
- ...b(i.parent) ? { parent: b(i.parent) } : {},
38
- ...b(i.section) ? { section: b(i.section) } : {}
39
- })).filter((i) => !!i.id && !!i.label && !!i.group), r = {};
40
- if (N(t.placement))
41
- for (const [i, a] of Object.entries(t.placement)) {
42
- if (!N(a))
31
+ if (!T(t))
32
+ return U();
33
+ const n = (Array.isArray(t.sections) ? t.sections : []).filter(T).map((r) => ({ id: v(r.id), label: v(r.label) ?? v(r.id) })).filter((r) => !!r.id && !!r.label), s = (Array.isArray(t.folders) ? t.folders : []).filter(T).map((r) => ({
34
+ id: v(r.id),
35
+ label: v(r.label) ?? v(r.id),
36
+ group: v(r.group),
37
+ ...v(r.parent) ? { parent: v(r.parent) } : {},
38
+ ...v(r.section) ? { section: v(r.section) } : {}
39
+ })).filter((r) => !!r.id && !!r.label && !!r.group), i = {};
40
+ if (T(t.placement))
41
+ for (const [r, o] of Object.entries(t.placement)) {
42
+ if (!T(o))
43
43
  continue;
44
44
  const l = {};
45
- b(a.section) && (l.section = b(a.section)), b(a.folder) && (l.folder = b(a.folder)), typeof a.order == "number" && Number.isFinite(a.order) && (l.order = a.order), (l.section || l.folder || l.order !== void 0) && (r[i] = l);
45
+ v(o.section) && (l.section = v(o.section)), v(o.folder) && (l.folder = v(o.folder)), typeof o.order == "number" && Number.isFinite(o.order) && (l.order = o.order), (l.section || l.folder || l.order !== void 0) && (i[r] = l);
46
46
  }
47
- return { version: 1, sections: n, folders: s, placement: r };
47
+ return { version: 1, sections: n, folders: s, placement: i };
48
48
  }
49
- const ht = (e) => e.sections.length === 0 && e.folders.length === 0 && Object.keys(e.placement).length === 0;
50
- function yt(e, t) {
49
+ const Mt = (e) => e.sections.length === 0 && e.folders.length === 0 && Object.keys(e.placement).length === 0;
50
+ function Tt(e, t) {
51
51
  const n = JSON.stringify(e, null, 2) + `
52
52
  `;
53
53
  return t != null && t.includes(`\r
54
54
  `) ? n.replace(/\n/g, `\r
55
55
  `) : n;
56
56
  }
57
- const je = (e) => e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "item";
58
- function ie(e, t) {
59
- const n = je(e);
57
+ const Me = (e) => e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "item";
58
+ function ue(e, t) {
59
+ const n = Me(e);
60
60
  let s = n;
61
- for (let r = 2; t.has(s); r++)
62
- s = `${n}-${r}`;
61
+ for (let i = 2; t.has(s); i++)
62
+ s = `${n}-${i}`;
63
63
  return s;
64
64
  }
65
- function gt(e, t) {
66
- const n = ie(t, new Set(e.sections.map((s) => s.id)));
65
+ function Ft(e, t) {
66
+ const n = ue(t, new Set(e.sections.map((s) => s.id)));
67
67
  return { layout: { ...e, sections: [...e.sections, { id: n, label: t }] }, id: n };
68
68
  }
69
- function bt(e, t) {
70
- const n = ie(t.label, new Set(e.folders.map((r) => r.id))), s = { id: n, label: t.label, group: t.group };
69
+ function Ct(e, t) {
70
+ const n = ue(t.label, new Set(e.folders.map((i) => i.id))), s = { id: n, label: t.label, group: t.group };
71
71
  return t.parent && (s.parent = t.parent), t.section && (s.section = t.section), { layout: { ...e, folders: [...e.folders, s] }, id: n };
72
72
  }
73
- function kt(e, t, n) {
73
+ function Lt(e, t, n) {
74
74
  return t.kind === "section" ? { ...e, sections: e.sections.map((s) => s.id === t.id ? { ...s, label: n } : s) } : { ...e, folders: e.folders.map((s) => s.id === t.id ? { ...s, label: n } : s) };
75
75
  }
76
- function vt(e, t) {
76
+ function Pt(e, t) {
77
77
  const n = {};
78
78
  if (t.kind === "folder") {
79
- const s = e.folders.find((r) => r.id === t.id);
80
- for (const [r, i] of Object.entries(e.placement))
81
- n[r] = i.folder === t.id ? { ...i, folder: s == null ? void 0 : s.parent } : i, n[r].folder || delete n[r].folder;
79
+ const s = e.folders.find((i) => i.id === t.id);
80
+ for (const [i, r] of Object.entries(e.placement))
81
+ n[i] = r.folder === t.id ? { ...r, folder: s == null ? void 0 : s.parent } : r, n[i].folder || delete n[i].folder;
82
82
  return {
83
83
  ...e,
84
- folders: e.folders.filter((r) => r.id !== t.id).map((r) => r.parent === t.id ? { ...r, parent: s == null ? void 0 : s.parent } : r).map((r) => {
85
- if (!r.parent) {
86
- const { parent: i, ...a } = r;
87
- return a;
84
+ folders: e.folders.filter((i) => i.id !== t.id).map((i) => i.parent === t.id ? { ...i, parent: s == null ? void 0 : s.parent } : i).map((i) => {
85
+ if (!i.parent) {
86
+ const { parent: r, ...o } = i;
87
+ return o;
88
88
  }
89
- return r;
89
+ return i;
90
90
  }),
91
- placement: R(n)
91
+ placement: C(n)
92
92
  };
93
93
  }
94
- for (const [s, r] of Object.entries(e.placement))
95
- if (r.section === t.id) {
96
- const { section: i, ...a } = r;
97
- n[s] = a;
94
+ for (const [s, i] of Object.entries(e.placement))
95
+ if (i.section === t.id) {
96
+ const { section: r, ...o } = i;
97
+ n[s] = o;
98
98
  } else
99
- n[s] = r;
99
+ n[s] = i;
100
100
  return {
101
101
  ...e,
102
102
  sections: e.sections.filter((s) => s.id !== t.id),
103
103
  folders: e.folders.map((s) => {
104
104
  if (s.section === t.id) {
105
- const { section: r, ...i } = s;
106
- return i;
105
+ const { section: i, ...r } = s;
106
+ return r;
107
107
  }
108
108
  return s;
109
109
  }),
110
- placement: R(n)
110
+ placement: C(n)
111
111
  };
112
112
  }
113
- function R(e) {
113
+ function C(e) {
114
114
  const t = {};
115
115
  for (const [n, s] of Object.entries(e))
116
116
  (s.section || s.folder || s.order !== void 0) && (t[n] = s);
117
117
  return t;
118
118
  }
119
- function wt(e, t, n) {
120
- var i;
121
- const s = (i = e.placement[t]) == null ? void 0 : i.order, r = {};
119
+ const Te = (e) => e.slice(0, Math.max(0, e.indexOf(":")));
120
+ function Jt(e, t, n) {
121
+ var r;
122
+ const s = (r = e.placement[t]) == null ? void 0 : r.order, i = {};
122
123
  if (n.folder) {
123
- r.folder = n.folder;
124
- const a = e.folders.find((l) => l.id === n.folder);
125
- a != null && a.section && (r.section = a.section);
126
- } else n.section && (r.section = n.section);
127
- return s !== void 0 && (r.order = s), { ...e, placement: R({ ...e.placement, [t]: r }) };
124
+ const o = e.folders.find((l) => l.id === n.folder);
125
+ if (o && o.group !== Te(t))
126
+ return e;
127
+ i.folder = n.folder, o != null && o.section && (i.section = o.section);
128
+ } else n.section && (i.section = n.section);
129
+ return s !== void 0 && (i.order = s), { ...e, placement: C({ ...e.placement, [t]: i }) };
130
+ }
131
+ function qt(e, t) {
132
+ const n = { ...e.placement };
133
+ return t.forEach((s, i) => {
134
+ n[s] = { ...n[s], order: i };
135
+ }), { ...e, placement: C(n) };
136
+ }
137
+ function ae(e, t, n) {
138
+ var r;
139
+ const s = new Map(e.folders.map((o) => [o.id, o])), i = /* @__PURE__ */ new Set();
140
+ for (let o = t; o && !i.has(o); o = (r = s.get(o)) == null ? void 0 : r.parent) {
141
+ if (o === n)
142
+ return !0;
143
+ i.add(o);
144
+ }
145
+ return !1;
146
+ }
147
+ function Dt(e, t, n) {
148
+ const s = e.folders.find((d) => d.id === t);
149
+ if (!s)
150
+ return e;
151
+ let i = n.section;
152
+ if (n.parent) {
153
+ const d = e.folders.find((a) => a.id === n.parent);
154
+ if (!d || d.group !== s.group || ae(e, d.id, t))
155
+ return e;
156
+ i = d.section;
157
+ }
158
+ const r = new Set(
159
+ e.folders.filter((d) => ae(e, d.id, t)).map((d) => d.id)
160
+ ), o = e.folders.map((d) => {
161
+ if (!r.has(d.id))
162
+ return d;
163
+ const a = { id: d.id, label: d.label, group: d.group }, c = d.id === t ? n.parent : d.parent;
164
+ return c && (a.parent = c), i && (a.section = i), a;
165
+ }), l = {};
166
+ for (const [d, a] of Object.entries(e.placement))
167
+ if (a.folder && r.has(a.folder)) {
168
+ const { section: c, ...u } = a;
169
+ l[d] = i ? { ...u, section: i } : u;
170
+ } else
171
+ l[d] = a;
172
+ return { ...e, folders: o, placement: C(l) };
128
173
  }
129
- function St(e, t, n) {
174
+ function Rt(e, t, n) {
130
175
  if (t === n || !e.placement[t])
131
176
  return e;
132
177
  const s = { ...e.placement, [n]: e.placement[t] };
133
178
  return delete s[t], { ...e, placement: s };
134
179
  }
135
- const oe = "\uFEFF", ae = {
180
+ const pe = "\uFEFF", me = {
136
181
  bom: !1,
137
182
  eol: `
138
183
  `,
@@ -140,98 +185,98 @@ const oe = "\uFEFF", ae = {
140
185
  finalNewline: !0,
141
186
  colonSpace: !0
142
187
  };
143
- function Z(e) {
188
+ function Y(e) {
144
189
  const t = e.charCodeAt(0) === 65279, n = e.includes(`\r
145
190
  `) ? `\r
146
191
  ` : `
147
192
  `;
148
- let s = ae.indent;
149
- const r = e.split(/\r?\n/);
150
- for (let a = 1; a < r.length; a++) {
151
- const l = /^([ \t]+)\S/.exec(r[a]);
193
+ let s = me.indent;
194
+ const i = e.split(/\r?\n/);
195
+ for (let o = 1; o < i.length; o++) {
196
+ const l = /^([ \t]+)\S/.exec(i[o]);
152
197
  if (l) {
153
198
  s = l[1];
154
199
  break;
155
200
  }
156
201
  }
157
- const i = /"\s*:(\s?)/.exec(e);
202
+ const r = /"\s*:(\s?)/.exec(e);
158
203
  return {
159
204
  bom: t,
160
205
  eol: n,
161
206
  indent: s,
162
207
  finalNewline: /\n$/.test(e),
163
- colonSpace: i ? i[1] !== "" : !0
208
+ colonSpace: r ? r[1] !== "" : !0
164
209
  };
165
210
  }
166
- function x(e) {
167
- const t = Z(e);
211
+ function K(e) {
212
+ const t = Y(e);
168
213
  return { value: JSON.parse(t.bom ? e.slice(1) : e), format: t };
169
214
  }
170
- function S(e, t) {
171
- const n = { ...ae, ...t }, s = A(e, n, "");
172
- return (n.bom ? oe : "") + s + (n.finalNewline ? n.eol : "");
215
+ function j(e, t) {
216
+ const n = { ...me, ...t }, s = I(e, n, "");
217
+ return (n.bom ? pe : "") + s + (n.finalNewline ? n.eol : "");
173
218
  }
174
- function Oe(e, t) {
219
+ function Fe(e, t) {
175
220
  if (t === void 0)
176
221
  return e;
177
222
  let n = t.includes(`\r
178
223
  `) ? e.replace(/\r?\n/g, `\r
179
224
  `) : e;
180
- return t.charCodeAt(0) === 65279 && n.charCodeAt(0) !== 65279 && (n = oe + n), n;
225
+ return t.charCodeAt(0) === 65279 && n.charCodeAt(0) !== 65279 && (n = pe + n), n;
181
226
  }
182
- function F(e, t) {
227
+ function P(e, t) {
183
228
  if (e === t)
184
229
  return !0;
185
230
  if (typeof e != typeof t || e === null || t === null || typeof e != "object" || Array.isArray(e) !== Array.isArray(t))
186
231
  return !1;
187
232
  if (Array.isArray(e)) {
188
- const i = t;
189
- return e.length === i.length && e.every((a, l) => F(a, i[l]));
233
+ const r = t;
234
+ return e.length === r.length && e.every((o, l) => P(o, r[l]));
190
235
  }
191
- const n = e, s = t, r = Object.keys(n);
192
- return r.length !== Object.keys(s).length ? !1 : r.every(
193
- (i) => Object.prototype.hasOwnProperty.call(s, i) && F(n[i], s[i])
236
+ const n = e, s = t, i = Object.keys(n);
237
+ return i.length !== Object.keys(s).length ? !1 : i.every(
238
+ (r) => Object.prototype.hasOwnProperty.call(s, r) && P(n[r], s[r])
194
239
  );
195
240
  }
196
- function ce(e, t, n) {
197
- return Ae(e, t, n).text;
241
+ function ee(e, t, n) {
242
+ return Ce(e, t, n).text;
198
243
  }
199
- function Ae(e, t, n) {
200
- const s = Z(e), r = (o) => ({
201
- text: S(t, s),
244
+ function Ce(e, t, n) {
245
+ const s = Y(e), i = (a) => ({
246
+ text: j(t, s),
202
247
  exact: !1,
203
- reason: o
248
+ reason: a
204
249
  });
205
- let i;
250
+ let r;
206
251
  try {
207
- i = new Ee(e).parseDocument();
208
- } catch (o) {
209
- return r(o instanceof Error ? o.message : String(o));
252
+ r = new Le(e).parseDocument();
253
+ } catch (a) {
254
+ return i(a instanceof Error ? a.message : String(a));
210
255
  }
211
- if (q(i))
212
- return r("duplicate keys");
213
- const a = [], l = {
256
+ if (z(r))
257
+ return i("duplicate keys");
258
+ const o = [], l = {
214
259
  text: e,
215
260
  format: s,
216
- edits: a,
261
+ edits: o,
217
262
  options: n,
218
263
  compact: !e.trimEnd().includes(`
219
264
  `)
220
265
  };
221
- H(l, i, t, "", !1);
222
- const f = Ke(e, a);
266
+ ne(l, r, t, "", !1);
267
+ const d = Pe(e, o);
223
268
  try {
224
- const o = JSON.parse(s.bom ? f.slice(1) : f);
225
- if (!F(o, t))
226
- return r("patch did not read back");
269
+ const a = JSON.parse(s.bom ? d.slice(1) : d);
270
+ if (!P(a, t))
271
+ return i("patch did not read back");
227
272
  } catch {
228
- return r("patch was not valid JSON");
273
+ return i("patch was not valid JSON");
229
274
  }
230
- return { text: f, exact: !0 };
275
+ return { text: d, exact: !0 };
231
276
  }
232
- class Ee {
277
+ class Le {
233
278
  constructor(t) {
234
- Q(this, "pos", 0);
279
+ oe(this, "pos", 0);
235
280
  this.text = t;
236
281
  }
237
282
  parseDocument() {
@@ -287,14 +332,14 @@ class Ee {
287
332
  const s = this.pos;
288
333
  if (this.text[this.pos] !== '"')
289
334
  throw new Error(`Expected a key at ${this.pos}`);
290
- const r = JSON.parse(this.text.slice(s, this.stringEnd()));
335
+ const i = JSON.parse(this.text.slice(s, this.stringEnd()));
291
336
  if (this.ws(), this.text[this.pos] !== ":")
292
337
  throw new Error(`Expected ':' at ${this.pos}`);
293
- this.pos++, n.push({ key: r, start: s, value: this.value() }), this.ws();
294
- const i = this.text[this.pos++];
295
- if (i === "}")
338
+ this.pos++, n.push({ key: i, start: s, value: this.value() }), this.ws();
339
+ const r = this.text[this.pos++];
340
+ if (r === "}")
296
341
  return { kind: "object", start: t, end: this.pos, members: n };
297
- if (i !== ",")
342
+ if (r !== ",")
298
343
  throw new Error(`Expected ',' or '}' at ${this.pos - 1}`);
299
344
  }
300
345
  }
@@ -312,269 +357,448 @@ class Ee {
312
357
  }
313
358
  }
314
359
  }
315
- function q(e) {
360
+ function z(e) {
316
361
  if (e.kind === "object") {
317
362
  const t = /* @__PURE__ */ new Set();
318
363
  for (const n of e.members) {
319
- if (t.has(n.key) || q(n.value))
364
+ if (t.has(n.key) || z(n.value))
320
365
  return !0;
321
366
  t.add(n.key);
322
367
  }
323
368
  } else if (e.kind === "array")
324
- return e.items.some(q);
369
+ return e.items.some(z);
325
370
  return !1;
326
371
  }
327
- function C(e) {
372
+ function J(e) {
328
373
  if (e.kind === "scalar")
329
374
  return e.value;
330
375
  if (e.kind === "array")
331
- return e.items.map(C);
376
+ return e.items.map(J);
332
377
  const t = {};
333
378
  for (const n of e.members)
334
- t[n.key] = C(n.value);
379
+ t[n.key] = J(n.value);
335
380
  return t;
336
381
  }
337
- function A(e, t, n) {
382
+ function I(e, t, n) {
338
383
  if (e === null || typeof e != "object")
339
384
  return e === void 0 ? "null" : JSON.stringify(e);
340
- const s = n + t.indent, r = t.colonSpace ? ": " : ":";
385
+ const s = n + t.indent, i = t.colonSpace ? ": " : ":";
341
386
  if (Array.isArray(e))
342
- return e.length === 0 ? "[]" : `[${t.eol}${e.map((a) => s + A(a, t, s)).join(`,${t.eol}`)}${t.eol}${n}]`;
343
- const i = Object.entries(e).filter(
344
- ([, a]) => a !== void 0
387
+ return e.length === 0 ? "[]" : `[${t.eol}${e.map((o) => s + I(o, t, s)).join(`,${t.eol}`)}${t.eol}${n}]`;
388
+ const r = Object.entries(e).filter(
389
+ ([, o]) => o !== void 0
345
390
  );
346
- return i.length === 0 ? "{}" : `{${t.eol}${i.map(([a, l]) => `${s}${JSON.stringify(a)}${r}${A(l, t, s)}`).join(`,${t.eol}`)}${t.eol}${n}}`;
391
+ return r.length === 0 ? "{}" : `{${t.eol}${r.map(([o, l]) => `${s}${JSON.stringify(o)}${i}${I(l, t, s)}`).join(`,${t.eol}`)}${t.eol}${n}}`;
347
392
  }
348
- function E(e, t, n = !1) {
393
+ function N(e, t, n = !1) {
349
394
  if (e === null || typeof e != "object")
350
395
  return e === void 0 ? "null" : JSON.stringify(e);
351
- const s = t.colonSpace ? ": " : ":", r = n ? "," : ", ";
396
+ const s = t.colonSpace ? ": " : ":", i = n ? "," : ", ";
352
397
  if (Array.isArray(e))
353
- return `[${e.map((l) => E(l, t, n)).join(r)}]`;
354
- const i = Object.entries(e).filter(
398
+ return `[${e.map((l) => N(l, t, n)).join(i)}]`;
399
+ const r = Object.entries(e).filter(
355
400
  ([, l]) => l !== void 0
356
- ), a = n ? "" : " ";
357
- return i.length === 0 ? "{}" : `{${a}${i.map(([l, f]) => `${JSON.stringify(l)}${s}${E(f, t, n)}`).join(r)}${a}}`;
401
+ ), o = n ? "" : " ";
402
+ return r.length === 0 ? "{}" : `{${o}${r.map(([l, d]) => `${JSON.stringify(l)}${s}${N(d, t, n)}`).join(i)}${o}}`;
358
403
  }
359
- const le = (e) => e.compact ? "," : ", ";
360
- function Ke(e, t) {
404
+ const he = (e) => e.compact ? "," : ", ";
405
+ function Pe(e, t) {
361
406
  let n = e;
362
- for (const s of [...t].sort((r, i) => i.start - r.start))
407
+ for (const s of [...t].sort((i, r) => r.start - i.start))
363
408
  n = n.slice(0, s.start) + s.text + n.slice(s.end);
364
409
  return n;
365
410
  }
366
- function L(e, t) {
411
+ function q(e, t) {
367
412
  var s;
368
413
  const n = e.lastIndexOf(`
369
414
  `, t - 1) + 1;
370
415
  return ((s = /^[ \t]*/.exec(e.slice(n, t))) == null ? void 0 : s[0]) ?? "";
371
416
  }
372
- function de(e, t) {
417
+ function ye(e, t) {
373
418
  return !e.slice(t.start, t.end).includes(`
374
419
  `);
375
420
  }
376
- function G(e, t, n) {
377
- return e.compact ? !0 : t.kind === "scalar" || (t.kind === "object" ? t.members.length === 0 : t.items.length === 0) ? n : de(e.text, t);
421
+ function te(e, t, n) {
422
+ return e.compact ? !0 : t.kind === "scalar" || (t.kind === "object" ? t.members.length === 0 : t.items.length === 0) ? n : ye(e.text, t);
378
423
  }
379
- function T(e, t, n, s) {
380
- const r = G(e, t, s);
424
+ function L(e, t, n, s) {
425
+ const i = te(e, t, s);
381
426
  e.edits.push({
382
427
  start: t.start,
383
428
  end: t.end,
384
- text: r ? E(n, e.format, e.compact) : A(n, e.format, L(e.text, t.start))
429
+ text: i ? N(n, e.format, e.compact) : I(n, e.format, q(e.text, t.start))
385
430
  });
386
431
  }
387
- const fe = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
388
- function H(e, t, n, s, r) {
432
+ const ge = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
433
+ function ne(e, t, n, s, i) {
389
434
  if (t.kind === "scalar") {
390
435
  if (t.value === n)
391
436
  return;
392
- T(e, t, n, r);
437
+ L(e, t, n, i);
393
438
  return;
394
439
  }
395
- F(C(t), n) || (t.kind === "object" && fe(n) ? Ne(e, t, n, s, r) : t.kind === "array" && Array.isArray(n) ? Te(e, t, n, s, r) : T(e, t, n, r));
396
- }
397
- function pe(e, t, n) {
398
- return n !== void 0 ? L(e.text, n) : L(e.text, t.start) + e.format.indent;
399
- }
400
- function Ne(e, t, n, s, r) {
401
- var d;
402
- const i = G(e, t, r), a = t.members.filter(
403
- (p) => Object.prototype.hasOwnProperty.call(n, p.key) && n[p.key] !== void 0
404
- ), l = Object.keys(n).filter(
405
- (p) => n[p] !== void 0 && !t.members.some((h) => h.key === p)
440
+ P(J(t), n) || (t.kind === "object" && ge(n) ? qe(e, t, n, s, i) : t.kind === "array" && Array.isArray(n) ? _e(e, t, n, s, i) : L(e, t, n, i));
441
+ }
442
+ function be(e, t, n) {
443
+ return n !== void 0 ? q(e.text, n) : q(e.text, t.start) + e.format.indent;
444
+ }
445
+ function Je(e, t) {
446
+ for (let n = t + 1; n < e.length; n++)
447
+ if (e[n] === "\\")
448
+ n++;
449
+ else if (e[n] === '"')
450
+ return n + 1;
451
+ return e.length;
452
+ }
453
+ function qe(e, t, n, s, i) {
454
+ var p;
455
+ const r = te(e, t, i), o = (f) => Object.prototype.hasOwnProperty.call(n, f) && n[f] !== void 0, l = Object.keys(n).filter(o), d = /* @__PURE__ */ new Map();
456
+ t.members.forEach((f, y) => {
457
+ const k = l[y];
458
+ k !== void 0 && !o(f.key) && !t.members.some((g) => g.key === k) && d.set(f, k);
459
+ });
460
+ const a = (f) => d.get(f) ?? f.key, c = t.members.filter((f) => o(f.key) || d.has(f)), u = l.filter(
461
+ (f) => !t.members.some((y) => y.key === f) && ![...d.values()].includes(f)
406
462
  );
407
- if (a.length === 0 && t.members.length > 0) {
408
- T(e, t, n, r);
463
+ if (c.length === 0 && t.members.length > 0) {
464
+ L(e, t, n, i);
409
465
  return;
410
466
  }
411
- for (const p of a)
412
- H(e, p.value, n[p.key], `${s}/${Le(p.key)}`, i);
413
- if (ue(
467
+ for (const f of c) {
468
+ const y = a(f);
469
+ y !== f.key && e.edits.push({
470
+ start: f.start,
471
+ end: Je(e.text, f.start),
472
+ text: JSON.stringify(y)
473
+ }), ne(e, f.value, n[y], `${s}/${We(y)}`, r);
474
+ }
475
+ if (ke(
414
476
  e,
415
- t.members.map((p) => ({ start: p.start, end: p.value.end })),
416
- t.members.map((p) => a.includes(p))
417
- ), l.length === 0)
477
+ t.members.map((f) => ({ start: f.start, end: f.value.end })),
478
+ t.members.map((f) => c.includes(f))
479
+ ), u.length === 0)
418
480
  return;
419
- const f = e.format.colonSpace ? ": " : ":";
420
- if (i) {
421
- const p = l.map(
422
- (h) => `${JSON.stringify(h)}${f}${E(n[h], e.format, e.compact)}`
481
+ const m = e.format.colonSpace ? ": " : ":";
482
+ if (r) {
483
+ const f = u.map(
484
+ (y) => `${JSON.stringify(y)}${m}${N(n[y], e.format, e.compact)}`
423
485
  );
424
- he(e, t, a.length > 0 ? a[a.length - 1].value.end : void 0, p);
486
+ ve(e, t, c.length > 0 ? c[c.length - 1].value.end : void 0, f);
425
487
  return;
426
488
  }
427
- const o = pe(e, t, (d = t.members[0]) == null ? void 0 : d.start), c = l.map(
428
- (p) => `${o}${JSON.stringify(p)}${f}${A(n[p], e.format, o)}`
489
+ const h = be(e, t, (p = t.members[0]) == null ? void 0 : p.start), b = u.map(
490
+ (f) => `${h}${JSON.stringify(f)}${m}${I(n[f], e.format, h)}`
429
491
  );
430
- me(e, t, a.length > 0 ? a[a.length - 1].value.end : void 0, c);
492
+ we(e, t, c.length > 0 ? c[c.length - 1].value.end : void 0, b);
431
493
  }
432
- const Ie = ["name", "id", "code", "key", "slug", "state", "Id"];
433
- function xe(e, t, n, s) {
434
- var f, o;
435
- const r = [...n, ...s];
436
- if (r.length === 0 || !r.every(fe))
494
+ const De = ["name", "id", "code", "key", "slug", "state", "Id"];
495
+ function Re(e, t, n, s) {
496
+ var d, a;
497
+ const i = [...n, ...s];
498
+ if (i.length === 0 || !i.every(ge))
437
499
  return;
438
- const i = (c, d) => {
439
- const p = c.map((h) => h[d]);
440
- return p.every((h) => typeof h == "string" || typeof h == "number") && new Set(p).size === p.length;
441
- }, a = (o = (f = e.options) == null ? void 0 : f.arrayKey) == null ? void 0 : o.call(f, t);
442
- return (a ? [a] : Ie).find((c) => i(n, c) && i(s, c));
443
- }
444
- function Te(e, t, n, s, r) {
445
- var g;
446
- const i = G(e, t, r), a = t.items.map(C), l = xe(e, s, a, n), f = (u) => u[l], o = l !== void 0 ? a.map((u) => {
447
- const m = f(u);
448
- return n.findIndex((k) => f(k) === m);
449
- }) : Ce(a, n);
500
+ const r = (c, u) => {
501
+ const m = c.map((h) => h[u]);
502
+ return m.every((h) => typeof h == "string" || typeof h == "number") && new Set(m).size === m.length;
503
+ }, o = (a = (d = e.options) == null ? void 0 : d.arrayKey) == null ? void 0 : a.call(d, t);
504
+ return (o ? [o] : De).find((c) => r(n, c) && r(s, c));
505
+ }
506
+ function _e(e, t, n, s, i) {
507
+ var b;
508
+ const r = te(e, t, i), o = t.items.map(J), l = Re(e, s, o, n), d = (p) => p[l], a = l !== void 0 ? o.map((p) => {
509
+ const f = d(p);
510
+ return n.findIndex((y) => d(y) === f);
511
+ }) : Ve(o, n);
450
512
  {
451
- const u = new Set(o.filter((m) => m >= 0));
452
- for (let m = 0; m < o.length; m++) {
453
- if (o[m] >= 0)
513
+ const p = new Set(a.filter((f) => f >= 0));
514
+ for (let f = 0; f < a.length; f++) {
515
+ if (a[f] >= 0)
454
516
  continue;
455
- let k = -1;
456
- for (let y = m - 1; y >= 0; y--)
457
- if (o[y] >= 0) {
458
- k = o[y];
517
+ let y = -1;
518
+ for (let g = f - 1; g >= 0; g--)
519
+ if (a[g] >= 0) {
520
+ y = a[g];
459
521
  break;
460
522
  }
461
- let j = n.length;
462
- for (let y = m + 1; y < o.length; y++)
463
- if (o[y] >= 0) {
464
- j = o[y];
523
+ let k = n.length;
524
+ for (let g = f + 1; g < a.length; g++)
525
+ if (a[g] >= 0) {
526
+ k = a[g];
465
527
  break;
466
528
  }
467
- for (let y = k + 1; y < j; y++)
468
- if (!u.has(y)) {
469
- o[m] = y, u.add(y);
529
+ for (let g = y + 1; g < k; g++)
530
+ if (!p.has(g)) {
531
+ a[f] = g, p.add(g);
470
532
  break;
471
533
  }
472
534
  }
473
535
  }
474
- const c = o.filter((u) => u >= 0);
475
- if (c.some((u, m) => m > 0 && u < c[m - 1])) {
476
- T(e, t, n, r);
536
+ const c = a.filter((p) => p >= 0);
537
+ if (c.some((p, f) => f > 0 && p < c[f - 1])) {
538
+ L(e, t, n, i);
477
539
  return;
478
540
  }
479
541
  if (c.length === 0 && t.items.length > 0) {
480
- T(e, t, n, r);
542
+ L(e, t, n, i);
481
543
  return;
482
544
  }
483
- t.items.forEach((u, m) => {
484
- o[m] >= 0 && H(e, u, n[o[m]], `${s}/${o[m]}`, i);
485
- }), ue(
545
+ t.items.forEach((p, f) => {
546
+ a[f] >= 0 && ne(e, p, n[a[f]], `${s}/${a[f]}`, r);
547
+ }), ke(
486
548
  e,
487
- t.items.map((u) => ({ start: u.start, end: u.end })),
488
- o.map((u) => u >= 0)
549
+ t.items.map((p) => ({ start: p.start, end: p.end })),
550
+ a.map((p) => p >= 0)
489
551
  );
490
- const d = t.items.length > 0 && t.items.every((u) => u.kind !== "scalar" && de(e.text, u)), p = pe(e, t, (g = t.items[0]) == null ? void 0 : g.start), h = /* @__PURE__ */ new Map();
491
- n.forEach((u, m) => {
492
- if (o.includes(m))
552
+ const u = t.items.length > 0 && t.items.every((p) => p.kind !== "scalar" && ye(e.text, p)), m = be(e, t, (b = t.items[0]) == null ? void 0 : b.start), h = /* @__PURE__ */ new Map();
553
+ n.forEach((p, f) => {
554
+ if (a.includes(f))
493
555
  return;
494
- let k;
495
- for (let O = t.items.length - 1; O >= 0; O--)
496
- if (o[O] >= 0 && o[O] < m) {
497
- k = O;
556
+ let y;
557
+ for (let w = t.items.length - 1; w >= 0; w--)
558
+ if (a[w] >= 0 && a[w] < f) {
559
+ y = w;
498
560
  break;
499
561
  }
500
- const j = i ? E(u, e.format, e.compact) : d ? `${p}${E(u, e.format)}` : `${p}${A(u, e.format, p)}`, y = h.get(k) ?? [];
501
- y.push(j), h.set(k, y);
562
+ const k = r ? N(p, e.format, e.compact) : u ? `${m}${N(p, e.format)}` : `${m}${I(p, e.format, m)}`, g = h.get(y) ?? [];
563
+ g.push(k), h.set(y, g);
502
564
  });
503
- for (const [u, m] of h) {
504
- const k = u === void 0 ? void 0 : t.items[u].end;
505
- if (u === void 0 && c.length > 0) {
506
- const j = t.items[o.findIndex((O) => O >= 0)], y = i ? le(e) : `,${e.format.eol}`;
565
+ for (const [p, f] of h) {
566
+ const y = p === void 0 ? void 0 : t.items[p].end;
567
+ if (p === void 0 && c.length > 0) {
568
+ const k = t.items[a.findIndex((w) => w >= 0)], g = r ? he(e) : `,${e.format.eol}`;
507
569
  e.edits.push({
508
- start: j.start,
509
- end: j.start,
510
- text: i ? m.join(y) + y : m.join(y).trimStart() + y + p
570
+ start: k.start,
571
+ end: k.start,
572
+ text: r ? f.join(g) + g : f.join(g).trimStart() + g + m
511
573
  });
512
574
  continue;
513
575
  }
514
- i ? he(e, t, k, m) : me(e, t, k, m);
576
+ r ? ve(e, t, y, f) : we(e, t, y, f);
515
577
  }
516
578
  }
517
- const Fe = 4e6;
518
- function Ce(e, t) {
579
+ const Ue = 4e6;
580
+ function Ve(e, t) {
519
581
  const n = e.length, s = t.length;
520
- if (n * s > Fe)
521
- return e.map((c, d) => d < s ? d : -1);
522
- const r = e.map((c) => JSON.stringify(c)), i = t.map((c) => JSON.stringify(c)), a = Array.from({ length: n + 1 }, () => new Uint32Array(s + 1));
582
+ if (n * s > Ue)
583
+ return e.map((c, u) => u < s ? u : -1);
584
+ const i = e.map((c) => JSON.stringify(c)), r = t.map((c) => JSON.stringify(c)), o = Array.from({ length: n + 1 }, () => new Uint32Array(s + 1));
523
585
  for (let c = n - 1; c >= 0; c--)
524
- for (let d = s - 1; d >= 0; d--)
525
- a[c][d] = r[c] === i[d] ? a[c + 1][d + 1] + 1 : Math.max(a[c + 1][d], a[c][d + 1]);
586
+ for (let u = s - 1; u >= 0; u--)
587
+ o[c][u] = i[c] === r[u] ? o[c + 1][u + 1] + 1 : Math.max(o[c + 1][u], o[c][u + 1]);
526
588
  const l = new Array(n).fill(-1);
527
- let f = 0, o = 0;
528
- for (; f < n && o < s; )
529
- r[f] === i[o] ? l[f++] = o++ : a[f + 1][o] >= a[f][o + 1] ? f++ : o++;
589
+ let d = 0, a = 0;
590
+ for (; d < n && a < s; )
591
+ i[d] === r[a] ? l[d++] = a++ : o[d + 1][a] >= o[d][a + 1] ? d++ : a++;
530
592
  return l;
531
593
  }
532
- function ue(e, t, n) {
594
+ function ke(e, t, n) {
533
595
  for (let s = 0; s < t.length; s++) {
534
596
  if (n[s])
535
597
  continue;
536
- let r = s;
537
- for (; r + 1 < t.length && !n[r + 1]; )
538
- r++;
539
- r + 1 < t.length ? e.edits.push({ start: t[s].start, end: t[r + 1].start, text: "" }) : s > 0 ? e.edits.push({ start: t[s - 1].end, end: t[r].end, text: "" }) : e.edits.push({ start: t[s].start, end: t[r].end, text: "" }), s = r;
598
+ let i = s;
599
+ for (; i + 1 < t.length && !n[i + 1]; )
600
+ i++;
601
+ i + 1 < t.length ? e.edits.push({ start: t[s].start, end: t[i + 1].start, text: "" }) : s > 0 ? e.edits.push({ start: t[s - 1].end, end: t[i].end, text: "" }) : e.edits.push({ start: t[s].start, end: t[i].end, text: "" }), s = i;
540
602
  }
541
603
  }
542
- function me(e, t, n, s) {
543
- const r = e.format.eol;
604
+ function we(e, t, n, s) {
605
+ const i = e.format.eol;
544
606
  if (n !== void 0) {
545
- e.edits.push({ start: n, end: n, text: `,${r}${s.join(`,${r}`)}` });
607
+ e.edits.push({ start: n, end: n, text: `,${i}${s.join(`,${i}`)}` });
546
608
  return;
547
609
  }
548
- const i = t.end - 1;
610
+ const r = t.end - 1;
549
611
  if ((t.kind === "object" ? t.members.length : t.items.length) === 0)
550
612
  e.edits.push({
551
613
  start: t.start + 1,
552
- end: i,
553
- text: `${r}${s.join(`,${r}`)}${r}${L(e.text, t.start)}`
614
+ end: r,
615
+ text: `${i}${s.join(`,${i}`)}${i}${q(e.text, t.start)}`
554
616
  });
555
617
  else {
556
618
  const l = t.kind === "object" ? t.members[0].start : t.items[0].start;
557
- e.edits.push({ start: l, end: l, text: `${s.join(`,${r}`).trimStart()}` });
619
+ e.edits.push({ start: l, end: l, text: `${s.join(`,${i}`).trimStart()}` });
558
620
  }
559
621
  }
560
- function he(e, t, n, s) {
561
- const r = le(e);
622
+ function ve(e, t, n, s) {
623
+ const i = he(e);
562
624
  if (n !== void 0) {
563
- e.edits.push({ start: n, end: n, text: `${r}${s.join(r)}` });
625
+ e.edits.push({ start: n, end: n, text: `${i}${s.join(i)}` });
564
626
  return;
565
627
  }
566
- const i = t.kind === "object" && !e.compact ? " " : "";
628
+ const r = t.kind === "object" && !e.compact ? " " : "";
567
629
  e.edits.push({
568
630
  start: t.start + 1,
569
631
  end: t.end - 1,
570
- text: `${i}${s.join(r)}${i}`
632
+ text: `${r}${s.join(i)}${r}`
571
633
  });
572
634
  }
573
- function Le(e) {
635
+ function We(e) {
574
636
  return e.replace(/~/g, "~0").replace(/\//g, "~1");
575
637
  }
576
- const K = (e) => e.slice(e.lastIndexOf("/") + 1), Me = (e) => e.charCodeAt(0) === 65279 ? e.slice(1) : e;
577
- function M(e) {
638
+ function ze(e, t, n, s, i) {
639
+ const r = t.prefix ?? "";
640
+ if (!e.startsWith(r))
641
+ return null;
642
+ const o = e.slice(r.length), l = t.part ?? "whole";
643
+ if (!i.qualifiedOnly && o === n)
644
+ return r + s;
645
+ switch (l) {
646
+ case "head":
647
+ return !i.qualifiedOnly && o.startsWith(`${n}.`) ? r + s + o.slice(n.length) : null;
648
+ case "query":
649
+ return !i.qualifiedOnly && o.startsWith(`${n}?`) ? r + s + o.slice(n.length) : null;
650
+ case "tail":
651
+ for (const d of i.qualifiers ?? [])
652
+ for (const a of [".", "/"])
653
+ if (o === `${d}${a}${n}`)
654
+ return `${r}${d}${a}${s}`;
655
+ return null;
656
+ default:
657
+ return null;
658
+ }
659
+ }
660
+ const Be = (e, t, n) => (!e.files || e.files.test(t)) && !("table" in e && e.table && n.ownTable), Xe = (e, t) => {
661
+ const n = t.split(".");
662
+ return n.length > e.length ? !1 : n.every((s, i) => s === "*" || e[e.length - n.length + i] === s);
663
+ };
664
+ function $e(e, t, n, s, i) {
665
+ let r = 0;
666
+ const o = t.filter((f) => "prop" in f), l = t.flatMap(
667
+ (f) => "value" in f ? [[f.value.replace("{name}", n), f.value.replace("{name}", s)]] : []
668
+ ), d = t.filter(
669
+ (f) => "keysOf" in f
670
+ ), a = t.flatMap(
671
+ (f) => "keyPattern" in f ? [[f.keyPattern.replace("{name}", n), f.keyPattern.replace("{name}", s)]] : []
672
+ ), c = new Set(t.flatMap((f) => "jsonIn" in f ? [f.jsonIn] : [])), u = (f) => {
673
+ for (const [y, k] of l)
674
+ if (f === y)
675
+ return k;
676
+ return null;
677
+ }, m = (f, y, k) => {
678
+ if (y !== null) {
679
+ for (const w of o)
680
+ if (w.prop === y && (!w.within || w.within === k)) {
681
+ const A = ze(f, w, n, s, i);
682
+ if (A !== null)
683
+ return r++, A;
684
+ }
685
+ if (c.has(y))
686
+ try {
687
+ const w = $e(JSON.parse(f), t, n, s, i);
688
+ if (w.count > 0)
689
+ return r += w.count, JSON.stringify(w.value);
690
+ } catch {
691
+ }
692
+ }
693
+ const g = i.qualifiedOnly ? null : u(f);
694
+ return g !== null ? (r++, g) : f;
695
+ }, h = (f, y) => {
696
+ if (i.qualifiedOnly)
697
+ return f;
698
+ for (const k of d) {
699
+ const g = k.prefix ?? "";
700
+ if (f === g + n && Xe(y, k.keysOf))
701
+ return r++, g + s;
702
+ }
703
+ for (const [k, g] of a)
704
+ if (f.startsWith(k))
705
+ return r++, g + f.slice(k.length);
706
+ return f;
707
+ }, b = (f, y, k, g) => {
708
+ if (typeof f == "string")
709
+ return m(f, y, k);
710
+ if (Array.isArray(f)) {
711
+ let w = !1;
712
+ const A = f.map((E) => {
713
+ const M = b(E, y, y ?? k, g);
714
+ return w || (w = M !== E), M;
715
+ });
716
+ return w ? A : f;
717
+ }
718
+ if (f && typeof f == "object") {
719
+ let w = !1;
720
+ const A = {};
721
+ for (const [E, M] of Object.entries(f)) {
722
+ const ie = h(E, g), re = b(M, E, y, [...g, E]);
723
+ w || (w = ie !== E || re !== M), A[ie] = re;
724
+ }
725
+ return w ? A : f;
726
+ }
727
+ return f;
728
+ };
729
+ return { value: b(e, null, null, []), count: r };
730
+ }
731
+ function Ze(e, t, n, s, i = {}) {
732
+ const r = [];
733
+ let o = 0;
734
+ if (!n || !s || n === s)
735
+ return { files: r, count: o };
736
+ for (const l of e) {
737
+ if (!/\.json$/i.test(l.path))
738
+ continue;
739
+ const d = t.filter((u) => Be(u, l.path, i));
740
+ if (d.length === 0)
741
+ continue;
742
+ let a;
743
+ try {
744
+ a = K(l.text).value;
745
+ } catch {
746
+ continue;
747
+ }
748
+ const c = $e(a, d, n, s, i);
749
+ c.count > 0 && (o += c.count, r.push({ path: l.path, text: ee(l.text, c.value) }));
750
+ }
751
+ return { files: r, count: o };
752
+ }
753
+ function _t(e, t, n, s = {}) {
754
+ const i = `${n}\0`, r = [];
755
+ for (const o of e) {
756
+ const l = Ze([o], t, n, i, s);
757
+ l.count > 0 && r.push({ path: o.path, count: l.count });
758
+ }
759
+ return r;
760
+ }
761
+ function Ge(e, t, n = []) {
762
+ const s = t.filter((l) => "prop" in l && l.part === "tail"), i = [], r = /* @__PURE__ */ new Set(), o = (l, d, a, c) => {
763
+ if (typeof l == "string")
764
+ for (const u of s) {
765
+ if (u.prop !== d || u.within && u.within !== a)
766
+ continue;
767
+ const m = l.startsWith(u.prefix ?? "") ? l.slice((u.prefix ?? "").length) : "", h = Math.max(m.lastIndexOf("."), m.lastIndexOf("/"));
768
+ if (h > 0 && h < m.length - 1) {
769
+ const b = m.slice(0, h), p = m.slice(h + 1), f = `${b}\0${p}\0${c}`;
770
+ !n.includes(b) && !r.has(f) && (r.add(f), i.push({ qualifier: b, name: p, path: c }));
771
+ }
772
+ }
773
+ else if (Array.isArray(l))
774
+ l.forEach((u) => o(u, d, d ?? a, c));
775
+ else if (l && typeof l == "object")
776
+ for (const [u, m] of Object.entries(l))
777
+ o(m, u, d, c);
778
+ };
779
+ for (const l of e)
780
+ if (!(!/\.json$/i.test(l.path) || !s.some((d) => !d.files || d.files.test(l.path))))
781
+ try {
782
+ o(K(l.text).value, null, null, l.path);
783
+ } catch {
784
+ }
785
+ return i;
786
+ }
787
+ function He(e, t, n, s = []) {
788
+ const i = (d) => d.replace(/[\\/]/g, ".").toLowerCase(), r = e.map((d) => ({ ...d })), o = new Map(r.map((d) => [i(d.id), d])), l = new Set(s.map(i));
789
+ for (const d of Ge(t, n, s)) {
790
+ const a = i(d.qualifier);
791
+ if (l.has(a))
792
+ continue;
793
+ let c = o.get(a);
794
+ c || (c = { id: d.qualifier, via: "reference", refers: [] }, o.set(a, c), r.push(c));
795
+ const u = c.refers ?? (c.refers = []);
796
+ u.includes(d.name) || u.push(d.name);
797
+ }
798
+ return r;
799
+ }
800
+ const x = (e) => e.slice(e.lastIndexOf("/") + 1), Qe = (e) => e.charCodeAt(0) === 65279 ? e.slice(1) : e;
801
+ function D(e) {
578
802
  return {
579
803
  id: e.id,
580
804
  label: e.label,
@@ -583,19 +807,19 @@ function M(e) {
583
807
  match: e.match,
584
808
  editor: e.editor,
585
809
  decode(t, n) {
586
- return e.select(x(t[0].text).value, n);
810
+ return e.select(K(t[0].text).value, n);
587
811
  },
588
812
  encode(t, n, s) {
589
- const r = n[0].text, i = x(r).value, a = e.assign(i, t, s);
813
+ const i = n[0].text, r = K(i).value, o = e.assign(r, t, s);
590
814
  return {
591
815
  files: [
592
- { path: n[0].path, text: ce(r, a, { arrayKey: e.arrayKey }) }
816
+ { path: n[0].path, text: ee(i, o, { arrayKey: e.arrayKey }) }
593
817
  ]
594
818
  };
595
819
  }
596
820
  };
597
821
  }
598
- const z = M({
822
+ const B = D({
599
823
  id: "json",
600
824
  label: "JSON",
601
825
  labelKey: "devStudio.kind.json",
@@ -604,7 +828,7 @@ const z = M({
604
828
  editor: "json",
605
829
  select: (e) => e,
606
830
  assign: (e, t) => t
607
- }), V = {
831
+ }), X = {
608
832
  id: "text",
609
833
  label: "Text",
610
834
  labelKey: "devStudio.kind.text",
@@ -613,87 +837,87 @@ const z = M({
613
837
  editor: "text",
614
838
  decode: (e) => e[0].text,
615
839
  encode: (e, t) => ({
616
- files: [{ path: t[0].path, text: Oe(e, t[0].text) }]
840
+ files: [{ path: t[0].path, text: Fe(e, t[0].text) }]
617
841
  })
618
842
  };
619
- function Pe(e, t) {
620
- return e.find((n) => n.match(t)) ?? (z.match(t) ? z : V);
843
+ function Ye(e, t) {
844
+ return e.find((n) => n.match(t)) ?? (B.match(t) ? B : X);
621
845
  }
622
- function Je(e, t, n) {
623
- for (const s of [z, V])
846
+ function et(e, t, n) {
847
+ for (const s of [B, X])
624
848
  if (s.match(e.path))
625
849
  try {
626
- const r = s.decode([e], n);
850
+ const i = s.decode([e], n);
627
851
  return {
628
852
  key: `${s.id}:${e.path}`,
629
853
  kind: s,
630
854
  paths: [e.path],
631
- label: K(e.path),
632
- model: r,
855
+ label: x(e.path),
856
+ model: i,
633
857
  error: t
634
858
  };
635
859
  } catch {
636
860
  }
637
861
  return {
638
862
  key: `text:${e.path}`,
639
- kind: V,
863
+ kind: X,
640
864
  paths: [e.path],
641
- label: K(e.path),
865
+ label: x(e.path),
642
866
  model: e.text,
643
867
  error: t
644
868
  };
645
869
  }
646
- function De(e, t, n, s) {
647
- var l, f;
648
- const r = e.encode(t, n, s), i = new Map(n.map((o) => [o.path, o.text])), a = ((l = r.files.find((o) => i.get(o.path) !== o.text)) == null ? void 0 : l.path) ?? ((f = r.deleted) == null ? void 0 : f.find((o) => i.has(o)));
649
- if (a !== void 0)
650
- throw new Error(`${K(a)} would not be stored as it is`);
870
+ function tt(e, t, n, s) {
871
+ var l, d;
872
+ const i = e.encode(t, n, s), r = new Map(n.map((a) => [a.path, a.text])), o = ((l = i.files.find((a) => r.get(a.path) !== a.text)) == null ? void 0 : l.path) ?? ((d = i.deleted) == null ? void 0 : d.find((a) => r.has(a)));
873
+ if (o !== void 0)
874
+ throw new Error(`${x(o)} would not be stored as it is`);
651
875
  }
652
- function $t(e, t, n) {
876
+ function Ut(e, t, n) {
653
877
  const s = /* @__PURE__ */ new Map();
654
- for (const i of t) {
655
- const a = Pe(e, i.path), l = a.group ? a.group(i.path) : i.path, f = `${a.id}:${l}`, o = s.get(f) ?? { kind: a, group: l, files: [] };
656
- o.files.push(i), s.set(f, o);
878
+ for (const r of t) {
879
+ const o = Ye(e, r.path), l = o.group ? o.group(r.path) : r.path, d = `${o.id}:${l}`, a = s.get(d) ?? { kind: o, group: l, files: [] };
880
+ a.files.push(r), s.set(d, a);
657
881
  }
658
- const r = [];
659
- for (const [i, { kind: a, group: l, files: f }] of s) {
660
- const o = f.map((d) => d.path).sort(), c = K(a.group ? l : o[0]);
882
+ const i = [];
883
+ for (const [r, { kind: o, group: l, files: d }] of s) {
884
+ const a = d.map((u) => u.path).sort(), c = x(o.group ? l : a[0]);
661
885
  try {
662
- const d = a.decode(f, n);
663
- De(a, d, f, n), r.push({ key: i, kind: a, paths: o, label: c, model: d });
664
- } catch (d) {
665
- const p = d instanceof Error ? d.message : String(d);
666
- for (const h of f)
667
- r.push(Je(h, p, n));
886
+ const u = o.decode(d, n);
887
+ tt(o, u, d, n), i.push({ key: r, kind: o, paths: a, label: c, model: u });
888
+ } catch (u) {
889
+ const m = u instanceof Error ? u.message : String(u);
890
+ for (const h of d)
891
+ i.push(et(h, m, n));
668
892
  }
669
893
  }
670
- return r.sort((i, a) => i.label.localeCompare(a.label));
894
+ return i.sort((r, o) => r.label.localeCompare(o.label));
671
895
  }
672
- function jt(e, t, n, s) {
673
- const r = n.filter((f) => e.paths.includes(f.path)), i = e.kind.encode(t, r, s), a = new Map(n.map((f) => [f.path, f])), l = [];
674
- for (const f of i.files) {
675
- const o = a.get(f.path);
676
- o && o.text === f.text || l.push({ type: "write", path: f.path, text: f.text, baseVersion: o == null ? void 0 : o.version });
896
+ function Vt(e, t, n, s) {
897
+ const i = n.filter((d) => e.paths.includes(d.path)), r = e.kind.encode(t, i, s), o = new Map(n.map((d) => [d.path, d])), l = [];
898
+ for (const d of r.files) {
899
+ const a = o.get(d.path);
900
+ a && a.text === d.text || l.push({ type: "write", path: d.path, text: d.text, baseVersion: a == null ? void 0 : a.version });
677
901
  }
678
- for (const f of i.deleted ?? []) {
679
- const o = a.get(f);
680
- o && l.push({ type: "delete", path: f, baseVersion: o.version });
902
+ for (const d of r.deleted ?? []) {
903
+ const a = o.get(d);
904
+ a && l.push({ type: "delete", path: d, baseVersion: a.version });
681
905
  }
682
906
  return l;
683
907
  }
684
- function _e(e, t) {
908
+ function nt(e, t) {
685
909
  try {
686
- return JSON.parse(Me(e));
910
+ return JSON.parse(Qe(e));
687
911
  } catch {
688
912
  return t;
689
913
  }
690
914
  }
691
- const v = (e) => typeof e == "object" && e !== null && !Array.isArray(e), w = (...e) => (t) => {
915
+ const $ = (e) => typeof e == "object" && e !== null && !Array.isArray(e), S = (...e) => (t) => {
692
916
  const n = t.toLowerCase();
693
917
  return e.some((s) => n.endsWith(s.toLowerCase()));
694
918
  };
695
- function P(e) {
696
- return M({
919
+ function R(e) {
920
+ return D({
697
921
  id: e.id,
698
922
  label: e.label,
699
923
  labelKey: e.labelKey,
@@ -703,54 +927,54 @@ function P(e) {
703
927
  select: (t) => {
704
928
  if (Array.isArray(t))
705
929
  return t;
706
- const n = v(t) ? t[e.property] : void 0;
930
+ const n = $(t) ? t[e.property] : void 0;
707
931
  return Array.isArray(n) ? n : [];
708
932
  },
709
- assign: (t, n) => Array.isArray(t) ? n : v(t) && !(e.property in t) && n.length === 0 ? t : { ...v(t) ? t : {}, [e.property]: n },
933
+ assign: (t, n) => Array.isArray(t) ? n : $(t) && !(e.property in t) && n.length === 0 ? t : { ...$(t) ? t : {}, [e.property]: n },
710
934
  arrayKey: e.itemKey ? () => e.itemKey : void 0
711
935
  });
712
936
  }
713
- function ye(e) {
714
- const t = P(e);
937
+ function Se(e) {
938
+ const t = R(e);
715
939
  return {
716
940
  ...t,
717
- decode: (n, s) => t.decode(n, s).map((r, i) => e.toItem(r, i)),
718
- encode: (n, s, r) => t.encode(
719
- n.map((i) => e.fromItem(i)),
941
+ decode: (n, s) => t.decode(n, s).map((i, r) => e.toItem(i, r)),
942
+ encode: (n, s, i) => t.encode(
943
+ n.map((r) => e.fromItem(r)),
720
944
  s,
721
- r
945
+ i
722
946
  )
723
947
  };
724
948
  }
725
- function J(e) {
726
- return M({
949
+ function _(e) {
950
+ return D({
727
951
  ...e,
728
- select: (t) => v(t) ? t : {},
952
+ select: (t) => $(t) ? t : {},
729
953
  assign: (t, n) => n
730
954
  });
731
955
  }
732
- const Ue = /^(.*)\.([a-z]{2,3}(?:-[A-Za-z]{2,4})?)\.i18n\.json$/i, Re = (e) => {
733
- const t = Ue.exec(e);
956
+ const st = /^(.*)\.([a-z]{2,3}(?:-[A-Za-z]{2,4})?)\.i18n\.json$/i, it = (e) => {
957
+ const t = st.exec(e);
734
958
  return t ? { group: t[1], locale: t[2] } : null;
735
- }, W = (e) => v(e) && Object.values(e).every((t) => typeof t == "string");
736
- function qe(e) {
737
- if (v(e)) {
959
+ }, Z = (e) => $(e) && Object.values(e).every((t) => typeof t == "string");
960
+ function rt(e) {
961
+ if ($(e)) {
738
962
  for (const t of ["translations", "keys"])
739
963
  if (t in e) {
740
- if (W(e[t]))
964
+ if (Z(e[t]))
741
965
  return e[t];
742
966
  throw new Error(`"${t}" is not a flat map of texts`);
743
967
  }
744
- if (W(e))
968
+ if (Z(e))
745
969
  return e;
746
970
  }
747
971
  throw new Error("no translations in this file");
748
972
  }
749
- function ee(e, t) {
750
- return v(e) ? v(e.translations) ? { ...e, translations: t } : v(e.keys) ? { ...e, keys: t } : W(e) ? t : { ...e, translations: t } : { translations: t };
973
+ function ce(e, t) {
974
+ return $(e) ? $(e.translations) ? { ...e, translations: t } : $(e.keys) ? { ...e, keys: t } : Z(e) ? t : { ...e, translations: t } : { translations: t };
751
975
  }
752
- function ze(e = {}) {
753
- const t = e.parse ?? Re, n = e.pathFor ?? ((s, r) => `${s}.${r}.i18n.json`);
976
+ function ot(e = {}) {
977
+ const t = e.parse ?? it, n = e.pathFor ?? ((s, i) => `${s}.${i}.i18n.json`);
754
978
  return {
755
979
  id: e.id ?? "i18n",
756
980
  label: e.label ?? "Translations",
@@ -759,65 +983,65 @@ function ze(e = {}) {
759
983
  editor: "i18n",
760
984
  match: (s) => t(s) !== null,
761
985
  group: (s) => {
762
- var r;
763
- return ((r = t(s)) == null ? void 0 : r.group) ?? s;
986
+ var i;
987
+ return ((i = t(s)) == null ? void 0 : i.group) ?? s;
764
988
  },
765
989
  decode(s) {
766
- const r = {};
767
- for (const i of s) {
768
- const a = t(i.path);
769
- a && (r[a.locale] = { ...qe(x(i.text).value) });
990
+ const i = {};
991
+ for (const r of s) {
992
+ const o = t(r.path);
993
+ o && (i[o.locale] = { ...rt(K(r.text).value) });
770
994
  }
771
- return r;
995
+ return i;
772
996
  },
773
- encode(s, r) {
774
- const i = /* @__PURE__ */ new Map();
775
- let a = "";
776
- for (const c of r) {
777
- const d = t(c.path);
778
- d && (i.set(d.locale, c), a = d.group);
997
+ encode(s, i) {
998
+ const r = /* @__PURE__ */ new Map();
999
+ let o = "";
1000
+ for (const c of i) {
1001
+ const u = t(c.path);
1002
+ u && (r.set(u.locale, c), o = u.group);
779
1003
  }
780
- const l = i.get("en") ?? r[0], f = [];
781
- for (const [c, d] of Object.entries(s)) {
782
- const p = i.get(c);
783
- if (p) {
784
- const g = x(p.text).value;
785
- f.push({
786
- path: p.path,
787
- text: ce(p.text, ee(g, d))
1004
+ const l = r.get("en") ?? i[0], d = [];
1005
+ for (const [c, u] of Object.entries(s)) {
1006
+ const m = r.get(c);
1007
+ if (m) {
1008
+ const b = K(m.text).value;
1009
+ d.push({
1010
+ path: m.path,
1011
+ text: ee(m.text, ce(b, u))
788
1012
  });
789
1013
  continue;
790
1014
  }
791
- const h = n(a || K((l == null ? void 0 : l.path) ?? "module"), c);
1015
+ const h = n(o || x((l == null ? void 0 : l.path) ?? "module"), c);
792
1016
  if (l) {
793
- const g = x(l.text).value, u = v(g) && "locale" in g ? { ...g, locale: c } : g;
794
- f.push({
1017
+ const b = K(l.text).value, p = $(b) && "locale" in b ? { ...b, locale: c } : b;
1018
+ d.push({
795
1019
  path: h,
796
- text: S(
797
- ee(u, d),
798
- Z(l.text)
1020
+ text: j(
1021
+ ce(p, u),
1022
+ Y(l.text)
799
1023
  )
800
1024
  });
801
1025
  } else
802
- f.push({ path: h, text: S({ locale: c, translations: d }) });
1026
+ d.push({ path: h, text: j({ locale: c, translations: u }) });
803
1027
  }
804
- const o = [...i.entries()].filter(([c]) => !(c in s)).map(([, c]) => c.path);
805
- return { files: f, deleted: o };
1028
+ const a = [...r.entries()].filter(([c]) => !(c in s)).map(([, c]) => c.path);
1029
+ return { files: d, deleted: a };
806
1030
  }
807
1031
  };
808
1032
  }
809
- const $ = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Ve = [
1033
+ const O = (e) => typeof e == "object" && e !== null && !Array.isArray(e), at = [
810
1034
  "frontend",
811
1035
  "backend",
812
1036
  "noCode",
813
1037
  "sql"
814
- ], Ot = [
1038
+ ], Wt = [
815
1039
  "preInstall",
816
1040
  "postInstall",
817
1041
  "preUninstall",
818
1042
  "postUninstall"
819
1043
  ];
820
- function We(e) {
1044
+ function ct(e) {
821
1045
  switch (e) {
822
1046
  case "frontend":
823
1047
  return ["typescript", "javascript"];
@@ -829,7 +1053,7 @@ function We(e) {
829
1053
  return [];
830
1054
  }
831
1055
  }
832
- const Be = /* @__PURE__ */ new Set([
1056
+ const lt = /* @__PURE__ */ new Set([
833
1057
  "read",
834
1058
  "filter",
835
1059
  "map",
@@ -840,16 +1064,16 @@ const Be = /* @__PURE__ */ new Set([
840
1064
  "write",
841
1065
  "callScript",
842
1066
  "return"
843
- ]), ge = (e) => Array.isArray(e) && e.every((t) => $(t) && typeof t.id == "string" && Be.has(String(t.type)));
844
- function B(e) {
845
- if (Ve.includes(e.kind))
1067
+ ]), je = (e) => Array.isArray(e) && e.every((t) => O(t) && typeof t.id == "string" && lt.has(String(t.type)));
1068
+ function G(e) {
1069
+ if (at.includes(e.kind))
846
1070
  return e.kind;
847
- if (e.source === void 0 && ge(e.steps))
1071
+ if (e.source === void 0 && je(e.steps))
848
1072
  return "noCode";
849
1073
  const t = typeof e.language == "string" ? e.language.toLowerCase() : "";
850
1074
  return t.endsWith("sql") || e.source === void 0 && typeof e.sql == "string" ? "sql" : /^(csharp|c#|cs\b)/.test(t) ? "backend" : "frontend";
851
1075
  }
852
- const be = [
1076
+ const Oe = [
853
1077
  "id",
854
1078
  "displayName",
855
1079
  "description",
@@ -859,108 +1083,108 @@ const be = [
859
1083
  "returnType",
860
1084
  "source",
861
1085
  "sourcePath"
862
- ], Xe = (e) => Array.isArray(e) && e.every((t) => $(t) && typeof t.name == "string");
863
- function Ze(e, t) {
1086
+ ], dt = (e) => Array.isArray(e) && e.every((t) => O(t) && typeof t.name == "string");
1087
+ function ft(e, t) {
864
1088
  const n = `#${t + 1}`;
865
- if (!$(e) || typeof e.name != "string" || !e.name) {
866
- const l = $(e) && typeof e.displayName == "string" ? e.displayName : n;
1089
+ if (!O(e) || typeof e.name != "string" || !e.name) {
1090
+ const l = O(e) && typeof e.displayName == "string" ? e.displayName : n;
867
1091
  return { key: `#${t}`, label: l, rawReason: "no name", source: e };
868
1092
  }
869
- const s = e.name, r = typeof e.displayName == "string" && e.displayName ? e.displayName : s, i = (l) => ({
1093
+ const s = e.name, i = typeof e.displayName == "string" && e.displayName ? e.displayName : s, r = (l) => ({
870
1094
  key: s,
871
- label: r,
1095
+ label: i,
872
1096
  rawReason: l,
873
1097
  source: e
874
- }), a = { name: s, kind: B(e) };
875
- for (const l of be) {
876
- const f = e[l];
877
- if (f !== void 0) {
878
- if (typeof f != "string")
879
- return i(`"${l}" is not text`);
880
- a[l] = f;
1098
+ }), o = { name: s, kind: G(e) };
1099
+ for (const l of Oe) {
1100
+ const d = e[l];
1101
+ if (d !== void 0) {
1102
+ if (typeof d != "string")
1103
+ return r(`"${l}" is not text`);
1104
+ o[l] = d;
881
1105
  }
882
1106
  }
883
1107
  if (e.parameters !== void 0) {
884
- if (!Xe(e.parameters))
885
- return i('"parameters" is not a list of named parameters');
886
- a.parameters = e.parameters;
1108
+ if (!dt(e.parameters))
1109
+ return r('"parameters" is not a list of named parameters');
1110
+ o.parameters = e.parameters;
887
1111
  }
888
- if (a.kind === "noCode") {
889
- if (e.steps !== void 0 && !ge(e.steps))
890
- return i('"steps" are not no-code steps');
891
- a.steps = e.steps ?? [];
1112
+ if (o.kind === "noCode") {
1113
+ if (e.steps !== void 0 && !je(e.steps))
1114
+ return r('"steps" are not no-code steps');
1115
+ o.steps = e.steps ?? [];
892
1116
  }
893
- return { key: s, label: r, definition: a, source: e };
1117
+ return { key: s, label: i, definition: o, source: e };
894
1118
  }
895
- function Ge(e) {
1119
+ function ut(e) {
896
1120
  const t = e.definition;
897
1121
  if (!t)
898
1122
  return e.source;
899
- const n = $(e.source) ? e.source : {}, s = { ...n, name: t.name };
900
- for (const r of be)
901
- t[r] === void 0 ? delete s[r] : s[r] = t[r];
902
- return t.parameters === void 0 ? delete s.parameters : s.parameters = t.parameters, t.kind === "noCode" ? s.steps = t.steps ?? [] : B(n) === "noCode" && delete s.steps, delete s.kind, ("kind" in n || B(s) !== t.kind) && (s.kind = t.kind), s;
1123
+ const n = O(e.source) ? e.source : {}, s = { ...n, name: t.name };
1124
+ for (const i of Oe)
1125
+ t[i] === void 0 ? delete s[i] : s[i] = t[i];
1126
+ return t.parameters === void 0 ? delete s.parameters : s.parameters = t.parameters, t.kind === "noCode" ? s.steps = t.steps ?? [] : G(n) === "noCode" && delete s.steps, delete s.kind, ("kind" in n || G(s) !== t.kind) && (s.kind = t.kind), s;
903
1127
  }
904
- function _(e) {
1128
+ function V(e) {
905
1129
  const t = /* @__PURE__ */ new Set();
906
1130
  return e.map((n, s) => {
907
- const r = Ze(n, s);
908
- return t.has(r.key) && (r.key = `${r.key}#${s}`), t.add(r.key), r;
1131
+ const i = ft(n, s);
1132
+ return t.has(i.key) && (i.key = `${i.key}#${s}`), t.add(i.key), i;
909
1133
  });
910
1134
  }
911
- function te(e, t) {
912
- if (!$(e) || !Object.values(e).every((n) => Array.isArray(n) && n.every((s) => typeof s == "string")))
1135
+ function le(e, t) {
1136
+ if (!O(e) || !Object.values(e).every((n) => Array.isArray(n) && n.every((s) => typeof s == "string")))
913
1137
  throw new Error(`"${t}" is not lists of SQL statements per phase`);
914
1138
  return e;
915
1139
  }
916
- function He(e) {
917
- const t = e.property ?? "scripts", n = e.phasesProperty ?? "phases", s = t === n, r = (i) => i.scripts.map(Ge);
918
- return M({
1140
+ function pt(e) {
1141
+ const t = e.property ?? "scripts", n = e.phasesProperty ?? "phases", s = t === n, i = (r) => r.scripts.map(ut);
1142
+ return D({
919
1143
  id: e.id ?? "scripts",
920
1144
  label: e.label ?? "Scripts",
921
1145
  labelKey: e.labelKey ?? "devStudio.kind.scripts",
922
1146
  icon: e.icon ?? "code",
923
1147
  editor: "scriptList",
924
1148
  match: e.match,
925
- select: (i) => {
926
- if (Array.isArray(i))
927
- return { scripts: _(i), ...s ? { holds: "scripts" } : {} };
928
- if (!$(i) || i[t] === void 0 && i[n] === void 0)
1149
+ select: (r) => {
1150
+ if (Array.isArray(r))
1151
+ return { scripts: V(r), ...s ? { holds: "scripts" } : {} };
1152
+ if (!O(r) || r[t] === void 0 && r[n] === void 0)
929
1153
  throw new Error(`no "${t}" in this file`);
930
- const a = i[t];
1154
+ const o = r[t];
931
1155
  if (s)
932
- return Array.isArray(a) ? { scripts: _(a), holds: "scripts" } : { scripts: [], phases: te(a, t), holds: "phases" };
933
- if (a !== void 0 && !Array.isArray(a))
1156
+ return Array.isArray(o) ? { scripts: V(o), holds: "scripts" } : { scripts: [], phases: le(o, t), holds: "phases" };
1157
+ if (o !== void 0 && !Array.isArray(o))
934
1158
  throw new Error(`"${t}" is not a list`);
935
- const l = i[n];
1159
+ const l = r[n];
936
1160
  return {
937
- scripts: _(a ?? []),
938
- ...l !== void 0 ? { phases: te(l, n) } : {}
1161
+ scripts: V(o ?? []),
1162
+ ...l !== void 0 ? { phases: le(l, n) } : {}
939
1163
  };
940
1164
  },
941
- assign: (i, a) => {
942
- if (a.holds === "phases" && a.scripts.length > 0)
1165
+ assign: (r, o) => {
1166
+ if (o.holds === "phases" && o.scripts.length > 0)
943
1167
  throw new Error("This file holds database scripts only; add scripts to another file.");
944
- if (Array.isArray(i) && a.phases === void 0)
945
- return r(a);
946
- const l = $(i) ? i : {};
1168
+ if (Array.isArray(r) && o.phases === void 0)
1169
+ return i(o);
1170
+ const l = O(r) ? r : {};
947
1171
  if (s)
948
1172
  return {
949
1173
  ...l,
950
- [t]: a.holds === "phases" ? a.phases ?? {} : r(a)
1174
+ [t]: o.holds === "phases" ? o.phases ?? {} : i(o)
951
1175
  };
952
- const f = { ...l };
953
- return (t in l || a.scripts.length > 0) && (f[t] = r(a)), a.phases === void 0 ? delete f[n] : f[n] = a.phases, f;
1176
+ const d = { ...l };
1177
+ return (t in l || o.scripts.length > 0) && (d[t] = i(o)), o.phases === void 0 ? delete d[n] : d[n] = o.phases, d;
954
1178
  },
955
- arrayKey: (i) => i === `/${t}` ? "name" : void 0
1179
+ arrayKey: (r) => r === `/${t}` ? "name" : void 0
956
1180
  });
957
1181
  }
958
- function Ye(e) {
959
- const n = e.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").split(/[^A-Za-z0-9]+/).filter(Boolean).map((s, r) => r === 0 ? s[0].toLowerCase() + s.slice(1) : s[0].toUpperCase() + s.slice(1)).join("");
1182
+ function mt(e) {
1183
+ const n = e.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").split(/[^A-Za-z0-9]+/).filter(Boolean).map((s, i) => i === 0 ? s[0].toLowerCase() + s.slice(1) : s[0].toUpperCase() + s.slice(1)).join("");
960
1184
  return /^[A-Za-z_]/.test(n) ? n : `script${n}`;
961
1185
  }
962
- function At(e) {
963
- const t = Ye(e.name), n = e.language ?? We(e.kind)[0], s = {
1186
+ function zt(e) {
1187
+ const t = mt(e.name), n = e.language ?? ct(e.kind)[0], s = {
964
1188
  name: t,
965
1189
  kind: e.kind,
966
1190
  ...e.name !== t ? { displayName: e.name } : {},
@@ -968,7 +1192,7 @@ function At(e) {
968
1192
  ...e.category ? { category: e.category } : {},
969
1193
  ...e.trigger ? { trigger: e.trigger } : {},
970
1194
  parameters: []
971
- }, r = t[0].toUpperCase() + t.slice(1);
1195
+ }, i = t[0].toUpperCase() + t.slice(1);
972
1196
  switch (e.kind) {
973
1197
  case "noCode":
974
1198
  return { ...s, steps: [] };
@@ -980,7 +1204,7 @@ SELECT 1;
980
1204
  return {
981
1205
  ...s,
982
1206
  returnType: "object",
983
- source: n === "csharp" ? `public static object ${r}(IDictionary<string, object> args)
1207
+ source: n === "csharp" ? `public static object ${i}(IDictionary<string, object> args)
984
1208
  {
985
1209
  return null;
986
1210
  }
@@ -1001,27 +1225,27 @@ SELECT 1;
1001
1225
  };
1002
1226
  }
1003
1227
  }
1004
- const I = (e) => JSON.parse(JSON.stringify(e));
1005
- function Et(e) {
1228
+ const F = (e) => JSON.parse(JSON.stringify(e));
1229
+ function Bt(e) {
1006
1230
  const t = e.revisions !== !1;
1007
1231
  let n = 0;
1008
- const s = e.workspaces.map((o) => ({
1232
+ const s = e.workspaces.map((a) => ({
1009
1233
  meta: {
1010
- id: o.id,
1011
- label: o.label,
1012
- description: o.description,
1013
- icon: o.icon,
1014
- readOnly: o.readOnly
1234
+ id: a.id,
1235
+ label: a.label,
1236
+ description: a.description,
1237
+ icon: a.icon,
1238
+ readOnly: a.readOnly
1015
1239
  },
1016
- packages: new Map((o.packages ?? []).map((c) => [c.id, { ...c, workspaceId: o.id }])),
1240
+ packages: new Map((a.packages ?? []).map((c) => [c.id, { ...c, workspaceId: a.id }])),
1017
1241
  modules: new Map(
1018
- o.modules.map((c) => [
1242
+ a.modules.map((c) => [
1019
1243
  c.id,
1020
1244
  {
1021
1245
  ...c,
1022
1246
  files: new Map(
1023
1247
  Object.entries(c.files).map(
1024
- ([d, p]) => [d, { text: p, version: ++n }]
1248
+ ([u, m]) => [u, { text: m, version: ++n }]
1025
1249
  )
1026
1250
  ),
1027
1251
  revisions: []
@@ -1029,146 +1253,146 @@ function Et(e) {
1029
1253
  ])
1030
1254
  )
1031
1255
  }));
1032
- let r = (e.templates ?? []).map((o) => I(o));
1033
- const i = (o) => {
1034
- const c = s.find((d) => d.meta.id === o);
1256
+ let i = (e.templates ?? []).map((a) => F(a));
1257
+ const r = (a) => {
1258
+ const c = s.find((u) => u.meta.id === a);
1035
1259
  if (!c)
1036
- throw new Error(`Unknown workspace "${o}"`);
1260
+ throw new Error(`Unknown workspace "${a}"`);
1037
1261
  return c;
1038
- }, a = (o) => {
1039
- const c = i(o.workspaceId).modules.get(o.id);
1262
+ }, o = (a) => {
1263
+ const c = r(a.workspaceId).modules.get(a.id);
1040
1264
  if (!c)
1041
- throw new Error(`Unknown module "${o.id}"`);
1265
+ throw new Error(`Unknown module "${a.id}"`);
1042
1266
  return c;
1043
- }, l = (o, c) => ({
1044
- workspaceId: o,
1267
+ }, l = (a, c) => ({
1268
+ workspaceId: a,
1045
1269
  id: c.id,
1046
1270
  packageId: c.packageId,
1047
1271
  label: c.label ?? c.id,
1048
1272
  description: c.description,
1049
1273
  icon: c.icon,
1050
1274
  version: c.version,
1051
- readOnly: c.readOnly || i(o).meta.readOnly,
1275
+ readOnly: c.readOnly || r(a).meta.readOnly,
1052
1276
  files: [...c.files.keys()].sort()
1053
- }), f = (o, c) => ({
1054
- path: o,
1277
+ }), d = (a, c) => ({
1278
+ path: a,
1055
1279
  text: c.text,
1056
1280
  version: String(c.version)
1057
1281
  });
1058
1282
  return {
1059
1283
  async listWorkspaces() {
1060
- return s.map((o) => ({ ...o.meta }));
1284
+ return s.map((a) => ({ ...a.meta }));
1061
1285
  },
1062
- async listModules(o) {
1063
- return [...i(o).modules.values()].map((d) => l(o, d));
1286
+ async listModules(a) {
1287
+ return [...r(a).modules.values()].map((u) => l(a, u));
1064
1288
  },
1065
- async listPackages(o) {
1066
- const c = i(o), d = [...c.packages.values()], p = [...new Set([...c.modules.values()].map((h) => h.packageId).filter(Boolean))].filter((h) => !c.packages.has(h)).map((h) => ({ id: h, workspaceId: o, label: h, derived: !0 }));
1067
- return [...d, ...p];
1289
+ async listPackages(a) {
1290
+ const c = r(a), u = [...c.packages.values()], m = [...new Set([...c.modules.values()].map((h) => h.packageId).filter(Boolean))].filter((h) => !c.packages.has(h)).map((h) => ({ id: h, workspaceId: a, label: h, derived: !0 }));
1291
+ return [...u, ...m];
1068
1292
  },
1069
- async readModule(o) {
1070
- return [...a(o).files.entries()].map(([d, p]) => f(d, p));
1293
+ async readModule(a) {
1294
+ return [...o(a).files.entries()].map(([u, m]) => d(u, m));
1071
1295
  },
1072
- async writeModule(o, c) {
1073
- const d = a(o);
1074
- if (d.readOnly || i(o.workspaceId).meta.readOnly)
1075
- throw new Error(`Module "${o.id}" is read-only`);
1076
- const p = c.filter((u) => u.baseVersion !== void 0).filter((u) => {
1077
- const m = d.files.get(u.path);
1078
- return m ? String(m.version) !== u.baseVersion : !1;
1079
- }).map((u) => {
1080
- var m;
1081
- return { path: u.path, currentVersion: String((m = d.files.get(u.path)) == null ? void 0 : m.version) };
1296
+ async writeModule(a, c) {
1297
+ const u = o(a);
1298
+ if (u.readOnly || r(a.workspaceId).meta.readOnly)
1299
+ throw new Error(`Module "${a.id}" is read-only`);
1300
+ const m = c.filter((p) => p.baseVersion !== void 0).filter((p) => {
1301
+ const f = u.files.get(p.path);
1302
+ return f ? String(f.version) !== p.baseVersion : !1;
1303
+ }).map((p) => {
1304
+ var f;
1305
+ return { path: p.path, currentVersion: String((f = u.files.get(p.path)) == null ? void 0 : f.version) };
1082
1306
  });
1083
- if (p.length > 0)
1084
- return { ok: !1, conflicts: p };
1307
+ if (m.length > 0)
1308
+ return { ok: !1, conflicts: m };
1085
1309
  let h;
1086
1310
  if (t) {
1087
- const u = {};
1088
- for (const [m, k] of d.files)
1089
- u[m] = k.text;
1090
- h = `r${++n}`, d.revisions.unshift({
1311
+ const p = {};
1312
+ for (const [f, y] of u.files)
1313
+ p[f] = y.text;
1314
+ h = `r${++n}`, u.revisions.unshift({
1091
1315
  id: h,
1092
1316
  timestamp: Date.now(),
1093
1317
  label: h,
1094
- summary: c.map((m) => `${m.type} ${m.path}`).join(", "),
1095
- files: u
1318
+ summary: c.map((f) => `${f.type} ${f.path}`).join(", "),
1319
+ files: p
1096
1320
  });
1097
1321
  }
1098
- const g = {};
1099
- for (const u of c)
1100
- if (u.type === "delete")
1101
- d.files.delete(u.path);
1322
+ const b = {};
1323
+ for (const p of c)
1324
+ if (p.type === "delete")
1325
+ u.files.delete(p.path);
1102
1326
  else {
1103
- const m = ++n;
1104
- d.files.set(u.path, { text: u.text, version: m }), g[u.path] = String(m);
1327
+ const f = ++n;
1328
+ u.files.set(p.path, { text: p.text, version: f }), b[p.path] = String(f);
1105
1329
  }
1106
- return { ok: !0, versions: g, revision: h };
1330
+ return { ok: !0, versions: b, revision: h };
1107
1331
  },
1108
- async createModule(o) {
1109
- const c = i(o.workspaceId);
1332
+ async createModule(a) {
1333
+ const c = r(a.workspaceId);
1110
1334
  if (c.meta.readOnly)
1111
- throw new Error(`Workspace "${o.workspaceId}" is read-only`);
1112
- if (c.modules.has(o.id))
1113
- throw new Error(`Module "${o.id}" already exists`);
1114
- const d = {
1115
- id: o.id,
1116
- packageId: o.packageId,
1335
+ throw new Error(`Workspace "${a.workspaceId}" is read-only`);
1336
+ if (c.modules.has(a.id))
1337
+ throw new Error(`Module "${a.id}" already exists`);
1338
+ const u = {
1339
+ id: a.id,
1340
+ packageId: a.packageId,
1117
1341
  files: new Map(
1118
- o.files.map((p) => [p.path, { text: p.text, version: ++n }])
1342
+ a.files.map((m) => [m.path, { text: m.text, version: ++n }])
1119
1343
  ),
1120
1344
  revisions: []
1121
1345
  };
1122
- return c.modules.set(o.id, d), l(o.workspaceId, d);
1346
+ return c.modules.set(a.id, u), l(a.workspaceId, u);
1123
1347
  },
1124
- async deleteModule(o) {
1125
- const c = i(o.workspaceId);
1348
+ async deleteModule(a) {
1349
+ const c = r(a.workspaceId);
1126
1350
  if (c.meta.readOnly)
1127
- throw new Error(`Workspace "${o.workspaceId}" is read-only`);
1128
- c.modules.delete(o.id);
1351
+ throw new Error(`Workspace "${a.workspaceId}" is read-only`);
1352
+ c.modules.delete(a.id);
1129
1353
  },
1130
- async savePackage(o) {
1131
- return i(o.workspaceId).packages.set(o.id, { ...o, derived: !1 }), { ...o, derived: !1 };
1354
+ async savePackage(a) {
1355
+ return r(a.workspaceId).packages.set(a.id, { ...a, derived: !1 }), { ...a, derived: !1 };
1132
1356
  },
1133
- async deletePackage(o) {
1134
- i(o.workspaceId).packages.delete(o.id);
1357
+ async deletePackage(a) {
1358
+ r(a.workspaceId).packages.delete(a.id);
1135
1359
  },
1136
1360
  async listTemplates() {
1137
- return r.map((o) => I(o));
1361
+ return i.map((a) => F(a));
1138
1362
  },
1139
- async saveTemplate(o, c) {
1140
- const d = (c == null ? void 0 : c.previousId) ?? o.id, p = I(o), h = r.findIndex((g) => g.id === d);
1141
- return r = h >= 0 ? r.map((g, u) => u === h ? p : g) : [...r, p], I(p);
1363
+ async saveTemplate(a, c) {
1364
+ const u = (c == null ? void 0 : c.previousId) ?? a.id, m = F(a), h = i.findIndex((b) => b.id === u);
1365
+ return i = h >= 0 ? i.map((b, p) => p === h ? m : b) : [...i, m], F(m);
1142
1366
  },
1143
- async deleteTemplate(o) {
1144
- r = r.filter((c) => c.id !== o);
1367
+ async deleteTemplate(a) {
1368
+ i = i.filter((c) => c.id !== a);
1145
1369
  },
1146
- async listRevisions(o, c) {
1147
- return a(o).revisions.filter((d) => !c || c in d.files).map(({ files: d, ...p }) => ({ ...p, ...c ? { path: c } : {} }));
1370
+ async listRevisions(a, c) {
1371
+ return o(a).revisions.filter((u) => !c || c in u.files).map(({ files: u, ...m }) => ({ ...m, ...c ? { path: c } : {} }));
1148
1372
  },
1149
- async readRevision(o, c, d) {
1150
- const p = a(o).revisions.find((h) => h.id === c);
1151
- if (!p)
1373
+ async readRevision(a, c, u) {
1374
+ const m = o(a).revisions.find((h) => h.id === c);
1375
+ if (!m)
1152
1376
  throw new Error(`Unknown revision "${c}"`);
1153
- return d ? p.files[d] ?? "" : JSON.stringify(p.files, null, 2);
1377
+ return u ? m.files[u] ?? "" : JSON.stringify(m.files, null, 2);
1154
1378
  },
1155
- async rollback(o, c, d) {
1156
- const p = a(o), h = p.revisions.find((u) => u.id === c);
1379
+ async rollback(a, c, u) {
1380
+ const m = o(a), h = m.revisions.find((p) => p.id === c);
1157
1381
  if (!h)
1158
1382
  throw new Error(`Unknown revision "${c}"`);
1159
- const g = d ? { [d]: h.files[d] } : h.files;
1160
- if (!d)
1161
- for (const u of [...p.files.keys()])
1162
- u in g || p.files.delete(u);
1163
- for (const [u, m] of Object.entries(g))
1164
- m !== void 0 && p.files.set(u, { text: m, version: ++n });
1383
+ const b = u ? { [u]: h.files[u] } : h.files;
1384
+ if (!u)
1385
+ for (const p of [...m.files.keys()])
1386
+ p in b || m.files.delete(p);
1387
+ for (const [p, f] of Object.entries(b))
1388
+ f !== void 0 && m.files.set(p, { text: f, version: ++n });
1165
1389
  },
1166
1390
  snapshot() {
1167
1391
  return {
1168
- workspaces: s.map((o) => ({
1169
- ...o.meta,
1170
- packages: [...o.packages.values()].map(({ workspaceId: c, ...d }) => d),
1171
- modules: [...o.modules.values()].map((c) => ({
1392
+ workspaces: s.map((a) => ({
1393
+ ...a.meta,
1394
+ packages: [...a.packages.values()].map(({ workspaceId: c, ...u }) => u),
1395
+ modules: [...a.modules.values()].map((c) => ({
1172
1396
  id: c.id,
1173
1397
  packageId: c.packageId,
1174
1398
  label: c.label,
@@ -1176,19 +1400,19 @@ function Et(e) {
1176
1400
  icon: c.icon,
1177
1401
  version: c.version,
1178
1402
  readOnly: c.readOnly,
1179
- files: Object.fromEntries([...c.files.entries()].map(([d, p]) => [d, p.text]))
1403
+ files: Object.fromEntries([...c.files.entries()].map(([u, m]) => [u, m.text]))
1180
1404
  }))
1181
1405
  })),
1182
- templates: r.map((o) => I(o)),
1406
+ templates: i.map((a) => F(a)),
1183
1407
  revisions: t
1184
1408
  };
1185
1409
  }
1186
1410
  };
1187
1411
  }
1188
- function Kt(e) {
1412
+ function Xt(e) {
1189
1413
  return e;
1190
1414
  }
1191
- function X(e, t) {
1415
+ function H(e, t) {
1192
1416
  if (!t || e === void 0 || e === null)
1193
1417
  return !0;
1194
1418
  if (t.enum && !t.enum.includes(e))
@@ -1203,72 +1427,72 @@ function X(e, t) {
1203
1427
  case "boolean":
1204
1428
  return typeof e == "boolean";
1205
1429
  case "array":
1206
- return Array.isArray(e) && (!t.items || e.every((n) => X(n, t.items)));
1430
+ return Array.isArray(e) && (!t.items || e.every((n) => H(n, t.items)));
1207
1431
  case "object": {
1208
1432
  if (typeof e != "object" || Array.isArray(e))
1209
1433
  return !1;
1210
1434
  const n = t.properties;
1211
- return !n || Object.entries(e).every(([s, r]) => s in n && X(r, n[s]));
1435
+ return !n || Object.entries(e).every(([s, i]) => s in n && H(i, n[s]));
1212
1436
  }
1213
1437
  default:
1214
1438
  return !0;
1215
1439
  }
1216
1440
  }
1217
- function Nt(e, t) {
1218
- var a;
1219
- const n = (e.fields ?? []).map((l) => l.name), s = (a = e.schema) == null ? void 0 : a.properties;
1441
+ function Zt(e, t) {
1442
+ var o;
1443
+ const n = (e.fields ?? []).map((l) => l.name), s = (o = e.schema) == null ? void 0 : o.properties;
1220
1444
  if (!e.schema || !s)
1221
1445
  return { section: e, keys: n };
1222
- const r = Object.entries(s).filter(
1223
- ([l, f]) => !(l in t) || X(t[l], f)
1224
- ), i = r.map(([l]) => l);
1446
+ const i = Object.entries(s).filter(
1447
+ ([l, d]) => !(l in t) || H(t[l], d)
1448
+ ), r = i.map(([l]) => l);
1225
1449
  return {
1226
1450
  section: {
1227
1451
  ...e,
1228
1452
  schema: {
1229
1453
  ...e.schema,
1230
- properties: Object.fromEntries(r),
1231
- ...e.schema.required ? { required: e.schema.required.filter((l) => i.includes(l)) } : {}
1454
+ properties: Object.fromEntries(i),
1455
+ ...e.schema.required ? { required: e.schema.required.filter((l) => r.includes(l)) } : {}
1232
1456
  }
1233
1457
  },
1234
- keys: [...i, ...n]
1458
+ keys: [...r, ...n]
1235
1459
  };
1236
1460
  }
1237
- function It(e) {
1461
+ function Gt(e) {
1238
1462
  var n;
1239
1463
  const t = /* @__PURE__ */ new Set();
1240
1464
  for (const s of e) {
1241
- for (const r of Object.keys(((n = s.schema) == null ? void 0 : n.properties) ?? {}))
1242
- t.add(r);
1243
- for (const r of s.fields ?? [])
1244
- t.add(r.name);
1465
+ for (const i of Object.keys(((n = s.schema) == null ? void 0 : n.properties) ?? {}))
1466
+ t.add(i);
1467
+ for (const i of s.fields ?? [])
1468
+ t.add(i.name);
1245
1469
  }
1246
1470
  return t;
1247
1471
  }
1248
- function xt(e) {
1472
+ function Ht(e) {
1249
1473
  const t = (n) => {
1250
- const s = e.find((r) => r.name === n);
1474
+ const s = e.find((i) => i.name === n);
1251
1475
  return String((s == null ? void 0 : s.tableName) || (s == null ? void 0 : s.name) || n);
1252
1476
  };
1253
1477
  return e.map((n) => {
1254
- const s = n, r = String(s.tableName || s.name || "Entity");
1478
+ const s = n, i = String(s.tableName || s.name || "Entity");
1255
1479
  return {
1256
- name: r,
1480
+ name: i,
1257
1481
  // the entity, when the table goes by another name (1.4.7)
1258
- ...s.name && s.name !== r ? { entity: String(s.name) } : {},
1482
+ ...s.name && s.name !== i ? { entity: String(s.name) } : {},
1259
1483
  ...typeof s.description == "string" && s.description ? { description: s.description } : {},
1260
- columns: (Array.isArray(s.fields) ? s.fields : []).map((i) => {
1261
- const a = typeof i.referencedEntity == "string" ? i.referencedEntity : typeof i.references == "string" ? i.references : void 0;
1484
+ columns: (Array.isArray(s.fields) ? s.fields : []).map((r) => {
1485
+ const o = typeof r.referencedEntity == "string" ? r.referencedEntity : typeof r.references == "string" ? r.references : void 0;
1262
1486
  return {
1263
- name: String(i.name ?? ""),
1487
+ name: String(r.name ?? ""),
1264
1488
  // seeds spell the type both ways (OmniVerk: `dataType`, older files: `type`)
1265
- dataType: String(i.dataType ?? i.type ?? "string"),
1266
- isPrimaryKey: !!i.isPrimaryKey,
1267
- isForeignKey: !!(i.isForeignKey ?? i.foreignKey ?? a),
1268
- ...a ? {
1489
+ dataType: String(r.dataType ?? r.type ?? "string"),
1490
+ isPrimaryKey: !!r.isPrimaryKey,
1491
+ isForeignKey: !!(r.isForeignKey ?? r.foreignKey ?? o),
1492
+ ...o ? {
1269
1493
  references: {
1270
- table: t(a),
1271
- column: typeof i.referencedField == "string" ? i.referencedField : "Id"
1494
+ table: t(o),
1495
+ column: typeof r.referencedField == "string" ? r.referencedField : "Id"
1272
1496
  }
1273
1497
  } : {}
1274
1498
  };
@@ -1276,14 +1500,14 @@ function xt(e) {
1276
1500
  };
1277
1501
  });
1278
1502
  }
1279
- function Tt(e) {
1280
- const t = e.manifest ?? {}, n = String(t.displayName || t.packageName || "Module"), s = (e.views ?? []).map((i) => ({
1281
- id: `view:${i.id}`,
1282
- label: i.name,
1503
+ function Qt(e) {
1504
+ const t = e.manifest ?? {}, n = String(t.displayName || t.packageName || "Module"), s = (e.views ?? []).map((r) => ({
1505
+ id: `view:${r.id}`,
1506
+ label: r.name,
1283
1507
  type: "view"
1284
- })), r = (e.entities ?? []).map((i) => {
1285
- const a = String(i.name ?? "Entity");
1286
- return { id: `entity:${a}`, label: a, type: "entity" };
1508
+ })), i = (e.entities ?? []).map((r) => {
1509
+ const o = String(r.name ?? "Entity");
1510
+ return { id: `entity:${o}`, label: o, type: "entity" };
1287
1511
  });
1288
1512
  return {
1289
1513
  roles: [
@@ -1303,31 +1527,31 @@ function Tt(e) {
1303
1527
  type: "module",
1304
1528
  children: [
1305
1529
  ...s.length ? [{ id: "views", label: "Views", type: "group", children: s }] : [],
1306
- ...r.length ? [{ id: "entities", label: "Entities", type: "group", children: r }] : []
1530
+ ...i.length ? [{ id: "entities", label: "Entities", type: "group", children: i }] : []
1307
1531
  ]
1308
1532
  }
1309
1533
  ],
1310
1534
  grants: {}
1311
1535
  };
1312
1536
  }
1313
- const Y = J({
1537
+ const se = _({
1314
1538
  id: "manifest",
1315
1539
  label: "Manifest",
1316
1540
  labelKey: "devStudio.kind.manifest",
1317
1541
  icon: "file",
1318
1542
  editor: "manifest",
1319
- match: w(".manifest.json")
1320
- }), Qe = P({
1543
+ match: S(".manifest.json")
1544
+ }), ht = R({
1321
1545
  id: "entities",
1322
1546
  label: "Entities",
1323
1547
  labelKey: "devStudio.kind.entities",
1324
1548
  icon: "database",
1325
1549
  editor: "entities",
1326
- match: w(".entities.json"),
1550
+ match: S(".entities.json"),
1327
1551
  property: "entities",
1328
1552
  itemKey: "name"
1329
- }), et = ze();
1330
- function ke(e, t) {
1553
+ }), yt = ot();
1554
+ function Ae(e, t) {
1331
1555
  const n = e, s = typeof e == "object" && e !== null && typeof n.id == "string";
1332
1556
  return {
1333
1557
  key: s ? n.id : `#${t}`,
@@ -1336,104 +1560,150 @@ function ke(e, t) {
1336
1560
  source: e
1337
1561
  };
1338
1562
  }
1339
- const tt = ye({
1563
+ const gt = Se({
1340
1564
  id: "views",
1341
1565
  label: "Views",
1342
1566
  labelKey: "devStudio.kind.views",
1343
1567
  icon: "grid",
1344
1568
  editor: "views",
1345
- match: w(".views.json"),
1569
+ match: S(".views.json"),
1346
1570
  property: "views",
1347
1571
  itemKey: "id",
1348
- toItem: (e, t) => ke(e, t),
1572
+ toItem: (e, t) => Ae(e, t),
1349
1573
  fromItem: (e) => e.definition ?? e.source
1350
- }), nt = ye({
1574
+ }), bt = Se({
1351
1575
  id: "workflows",
1352
1576
  label: "Workflows",
1353
1577
  labelKey: "devStudio.kind.workflows",
1354
1578
  icon: "git-branch",
1355
1579
  editor: "workflows",
1356
- match: w(".workflows.json"),
1580
+ match: S(".workflows.json"),
1357
1581
  property: "workflows",
1358
1582
  itemKey: "id",
1359
- toItem: (e, t) => ke(e, t),
1583
+ toItem: (e, t) => Ae(e, t),
1360
1584
  fromItem: (e) => e.definition ?? e.source
1361
- }), st = P({
1585
+ }), kt = R({
1362
1586
  id: "dataSources",
1363
1587
  label: "Data sources",
1364
1588
  labelKey: "devStudio.kind.dataSources",
1365
1589
  icon: "database",
1366
1590
  editor: "dataSources",
1367
- match: w(".datasources.json"),
1591
+ match: S(".datasources.json"),
1368
1592
  property: "dataSources",
1369
1593
  itemKey: "key"
1370
- }), rt = J({
1594
+ }), wt = _({
1371
1595
  id: "rbac",
1372
1596
  label: "Access",
1373
1597
  labelKey: "devStudio.kind.rbac",
1374
1598
  icon: "shield",
1375
1599
  editor: "rbac",
1376
- match: w(".rbac.json")
1377
- }), it = P({
1600
+ match: S(".rbac.json")
1601
+ }), vt = R({
1378
1602
  id: "hooks",
1379
1603
  label: "Lifecycle hooks",
1380
1604
  labelKey: "devStudio.kind.hooks",
1381
1605
  icon: "zap",
1382
1606
  editor: "hooks",
1383
- match: w(".hooks.json"),
1607
+ match: S(".hooks.json"),
1384
1608
  property: "bindings",
1385
1609
  itemKey: "id"
1386
- }), ot = J({
1610
+ }), $t = _({
1387
1611
  id: "integrations",
1388
1612
  label: "Integrations",
1389
1613
  labelKey: "devStudio.kind.integrations",
1390
1614
  icon: "plug",
1391
1615
  editor: "integrations",
1392
- match: w(".integrations.json")
1393
- }), at = J({
1616
+ match: S(".integrations.json")
1617
+ }), St = _({
1394
1618
  id: "environments",
1395
1619
  label: "Environment sets",
1396
1620
  labelKey: "devStudio.kind.environments",
1397
1621
  icon: "globe",
1398
1622
  editor: "environments",
1399
- match: w(".environments.json")
1400
- }), ct = He({
1401
- match: w(".scripts.json")
1402
- }), lt = [
1403
- Y,
1404
- Qe,
1405
- et,
1406
- tt,
1407
- nt,
1408
- st,
1409
- rt,
1410
- it,
1411
- ct,
1412
- ot,
1413
- at
1623
+ match: S(".environments.json")
1624
+ }), jt = pt({
1625
+ match: S(".scripts.json")
1626
+ }), Ot = [
1627
+ se,
1628
+ ht,
1629
+ yt,
1630
+ gt,
1631
+ bt,
1632
+ kt,
1633
+ wt,
1634
+ vt,
1635
+ jt,
1636
+ $t,
1637
+ St
1414
1638
  ];
1415
- function ne(e) {
1639
+ function de(e) {
1416
1640
  return e.normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/ł/g, "l").replace(/Ł/g, "L").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "module";
1417
1641
  }
1418
- const se = (e) => {
1419
- const t = e.find((n) => Y.match(n.path));
1420
- return t ? _e(t.text, void 0) : void 0;
1642
+ const Q = (e) => {
1643
+ const t = e.find((n) => se.match(n.path));
1644
+ return t ? nt(t.text, void 0) : void 0;
1421
1645
  };
1422
- function dt(e) {
1423
- const t = e.find((n) => Y.match(n.path));
1424
- return t ? K(t.path).replace(/\.manifest\.json$/i, "") : "module";
1646
+ function At(e) {
1647
+ const t = e.find((n) => se.match(n.path));
1648
+ return t ? x(t.path).replace(/\.manifest\.json$/i, "") : "module";
1649
+ }
1650
+ const fe = (e) => Array.isArray(e.fields) ? e.fields : [], Ee = {
1651
+ entity: [
1652
+ { prop: "references", part: "tail", files: /\.entities\.json$/i },
1653
+ { prop: "entity", files: /\.views\.json$/i },
1654
+ { value: "{name}All", files: /\.(views|scripts|datasources)\.json$/i },
1655
+ { value: "{name}ById", files: /\.(views|scripts|datasources)\.json$/i },
1656
+ { prop: "entityType", files: /\.workflows\.json$/i },
1657
+ { prop: "name", within: "tables", table: !0, files: /\.datasources\.json$/i },
1658
+ { prop: "id", prefix: "entity:", within: "resources", files: /\.rbac\.json$/i },
1659
+ { prop: "id", prefix: "entity:", within: "children", files: /\.rbac\.json$/i },
1660
+ { prop: "label", within: "resources", files: /\.rbac\.json$/i },
1661
+ { keysOf: "grants", prefix: "entity:", files: /\.rbac\.json$/i },
1662
+ { keyPattern: "entity.{name}." },
1663
+ { keyPattern: "field.{name}." },
1664
+ { prop: "target", files: /\.scripts\.json$/i },
1665
+ { prop: "target", within: "operations", files: /\.integrations\.json$/i },
1666
+ { prop: "source", within: "operations", files: /\.integrations\.json$/i }
1667
+ ],
1668
+ dataSource: [
1669
+ { prop: "ref", files: /\.views\.json$/i },
1670
+ { prop: "source", files: /\.scripts\.json$/i },
1671
+ { prop: "target", files: /\.scripts\.json$/i },
1672
+ { prop: "sources", files: /\.datasources\.json$/i },
1673
+ { prop: "source", within: "operations", files: /\.integrations\.json$/i }
1674
+ ]
1675
+ };
1676
+ function Et(e, t) {
1677
+ const n = Q(t), s = [e.id, n == null ? void 0 : n.id, n == null ? void 0 : n.packageName].filter(
1678
+ (r) => typeof r == "string" && r !== ""
1679
+ ), i = [];
1680
+ for (const r of Array.isArray(n == null ? void 0 : n.dependencies) ? n.dependencies : [])
1681
+ if (typeof r == "string" && r)
1682
+ i.push({ id: r, via: "manifest" });
1683
+ else if (r && typeof r == "object" && typeof r.moduleId == "string") {
1684
+ const o = r;
1685
+ i.push({
1686
+ id: o.moduleId,
1687
+ via: "manifest",
1688
+ ...typeof o.required == "boolean" ? { required: o.required } : {},
1689
+ ...typeof o.minVersion == "string" ? { minVersion: o.minVersion } : {}
1690
+ });
1691
+ }
1692
+ return He(i, t, Ee.entity ?? [], s);
1425
1693
  }
1426
- const re = (e) => Array.isArray(e.fields) ? e.fields : [], Ft = {
1694
+ const Yt = {
1427
1695
  id: "native",
1428
- kinds: lt,
1696
+ references: Ee,
1697
+ dependencies: (e) => Et(e.key, e.files),
1698
+ kinds: Ot,
1429
1699
  locales: ["en", "pl", "de", "fr", "es", "uk"],
1430
1700
  requiredLocales: ["en"],
1431
1701
  moduleId: (e) => {
1432
- const t = se(e), n = (t == null ? void 0 : t.id) ?? (t == null ? void 0 : t.packageName);
1702
+ const t = Q(e), n = (t == null ? void 0 : t.id) ?? (t == null ? void 0 : t.packageName);
1433
1703
  return typeof n == "string" ? n : void 0;
1434
1704
  },
1435
1705
  validateModule: ({ files: e }) => {
1436
- const t = se(e);
1706
+ const t = Q(e);
1437
1707
  return t ? ["id", "name", "version"].filter((n) => typeof t[n] != "string" || !t[n]).map((n) => ({
1438
1708
  severity: "error",
1439
1709
  code: "manifest.required",
@@ -1451,7 +1721,7 @@ const re = (e) => Array.isArray(e.fields) ? e.fields : [], Ft = {
1451
1721
  ];
1452
1722
  },
1453
1723
  newFile: (e, { files: t }) => {
1454
- const n = dt(t), r = {
1724
+ const n = At(t), i = {
1455
1725
  entities: ["entities.json", { entities: [] }],
1456
1726
  views: ["views.json", { views: [] }],
1457
1727
  workflows: ["workflows.json", { workflows: [] }],
@@ -1462,16 +1732,16 @@ const re = (e) => Array.isArray(e.fields) ? e.fields : [], Ft = {
1462
1732
  integrations: ["integrations.json", { integrations: [] }],
1463
1733
  environments: ["environments.json", { variables: [], sets: [] }]
1464
1734
  }[e];
1465
- return r ? { path: `${n}.${r[0]}`, text: S(r[1]) } : void 0;
1735
+ return i ? { path: `${n}.${i[0]}`, text: j(i[1]) } : void 0;
1466
1736
  },
1467
1737
  generateModule: async (e, { existingIds: t }) => {
1468
- let n = ne(e.name);
1469
- for (let r = 2; t.has(n); r++)
1470
- n = `${ne(e.name)}-${r}`;
1738
+ let n = de(e.name);
1739
+ for (let i = 2; t.has(n); i++)
1740
+ n = `${de(e.name)}-${i}`;
1471
1741
  const s = [
1472
1742
  {
1473
1743
  path: `${n}.manifest.json`,
1474
- text: S({
1744
+ text: j({
1475
1745
  id: n,
1476
1746
  name: e.name,
1477
1747
  version: "1.0.0",
@@ -1480,31 +1750,31 @@ const re = (e) => Array.isArray(e.fields) ? e.fields : [], Ft = {
1480
1750
  ...e.packageId ? { category: e.packageId } : {}
1481
1751
  })
1482
1752
  },
1483
- { path: `${n}.entities.json`, text: S({ entities: e.entities }) }
1753
+ { path: `${n}.entities.json`, text: j({ entities: e.entities }) }
1484
1754
  ];
1485
- for (const r of e.locales) {
1486
- const i = { "module.displayName": e.name };
1487
- for (const a of e.entities) {
1488
- const l = String(a.name ?? "");
1489
- i[`entity.${l}.displayName`] = l;
1490
- for (const f of re(a))
1491
- i[`field.${l}.${String(f.name)}.label`] = String(f.name);
1755
+ for (const i of e.locales) {
1756
+ const r = { "module.displayName": e.name };
1757
+ for (const o of e.entities) {
1758
+ const l = String(o.name ?? "");
1759
+ r[`entity.${l}.displayName`] = l;
1760
+ for (const d of fe(o))
1761
+ r[`field.${l}.${String(d.name)}.label`] = String(d.name);
1492
1762
  }
1493
1763
  s.push({
1494
- path: `${n}.${r}.i18n.json`,
1495
- text: S({ locale: r, translations: i })
1764
+ path: `${n}.${i}.i18n.json`,
1765
+ text: j({ locale: i, translations: r })
1496
1766
  });
1497
1767
  }
1498
1768
  if (e.views) {
1499
- const r = e.entities.map((i) => {
1500
- const a = String(i.name ?? "Item");
1769
+ const i = e.entities.map((r) => {
1770
+ const o = String(r.name ?? "Item");
1501
1771
  return {
1502
- id: `${a}List`,
1503
- name: `${a} list`,
1772
+ id: `${o}List`,
1773
+ name: `${o} list`,
1504
1774
  kind: "grid",
1505
1775
  version: 2,
1506
1776
  columns: 12,
1507
- dataSources: [{ key: "rows", type: "entity", entity: a, autoLoad: !0 }],
1777
+ dataSources: [{ key: "rows", type: "entity", entity: o, autoLoad: !0 }],
1508
1778
  rows: [
1509
1779
  {
1510
1780
  id: "r1",
@@ -1514,7 +1784,7 @@ const re = (e) => Array.isArray(e.fields) ? e.fields : [], Ft = {
1514
1784
  controlType: "dataGrid",
1515
1785
  colSpan: 12,
1516
1786
  props: {
1517
- columns: re(i).map((l) => ({
1787
+ columns: fe(r).map((l) => ({
1518
1788
  field: String(l.name),
1519
1789
  header: String(l.name)
1520
1790
  }))
@@ -1526,10 +1796,10 @@ const re = (e) => Array.isArray(e.fields) ? e.fields : [], Ft = {
1526
1796
  ]
1527
1797
  };
1528
1798
  });
1529
- s.push({ path: `${n}.views.json`, text: S({ views: r }) });
1799
+ s.push({ path: `${n}.views.json`, text: j({ views: i }) });
1530
1800
  }
1531
1801
  if (e.permissions) {
1532
- const r = {
1802
+ const i = {
1533
1803
  roles: [
1534
1804
  { id: "viewer", label: "Viewer" },
1535
1805
  { id: "editor", label: "Editor" },
@@ -1540,83 +1810,91 @@ const re = (e) => Array.isArray(e.fields) ? e.fields : [], Ft = {
1540
1810
  { id: "edit", label: "Edit" },
1541
1811
  { id: "delete", label: "Delete" }
1542
1812
  ],
1543
- resources: e.entities.map((i) => ({
1544
- id: `entity:${String(i.name)}`,
1545
- label: String(i.name),
1813
+ resources: e.entities.map((r) => ({
1814
+ id: `entity:${String(r.name)}`,
1815
+ label: String(r.name),
1546
1816
  type: "entity"
1547
1817
  })),
1548
1818
  grants: {}
1549
1819
  };
1550
- s.push({ path: `${n}.rbac.json`, text: S(r) });
1820
+ s.push({ path: `${n}.rbac.json`, text: j(i) });
1551
1821
  }
1552
1822
  return { id: n, packageId: e.packageId, files: s };
1553
1823
  }
1554
1824
  };
1555
1825
  export {
1556
- Ve as NICE_STUDIO_SCRIPT_KINDS,
1557
- Ot as NICE_STUDIO_SCRIPT_PHASES,
1558
- bt as addStudioFolder,
1559
- gt as addStudioSection,
1560
- P as arrayFileKind,
1561
- $t as buildDocuments,
1562
- Et as createMemoryStudioProvider,
1563
- Kt as defineManifestSection,
1564
- Tt as deriveDefaultRbac,
1565
- Z as detectJsonTextFormat,
1566
- D as emptyStudioLayout,
1567
- jt as encodeDocument,
1568
- w as endsWithAny,
1569
- xt as entitiesToSchemas,
1570
- K as fileName,
1571
- Nt as fitManifestSection,
1572
- Ge as fromStudioScriptItem,
1573
- ze as i18nFileKind,
1574
- B as inferStudioScriptKind,
1575
- ht as isEmptyStudioLayout,
1576
- $e as isStudioLayoutPath,
1577
- ye as itemsFileKind,
1578
- z as jsonFallbackKind,
1579
- M as jsonFileKind,
1580
- X as jsonValueFitsSchema,
1581
- F as jsonValuesEqual,
1582
- Oe as keepTextFormat,
1583
- It as manifestSectionKeys,
1584
- dt as modulePrefix,
1585
- st as nativeDataSourcesKind,
1586
- Qe as nativeEntitiesKind,
1587
- at as nativeEnvironmentsKind,
1588
- lt as nativeFileKinds,
1589
- it as nativeHooksKind,
1590
- et as nativeI18nKind,
1591
- ot as nativeIntegrationsKind,
1592
- Y as nativeManifestKind,
1593
- rt as nativeRbacKind,
1594
- ct as nativeScriptsKind,
1595
- Ft as nativeStudioPreset,
1596
- tt as nativeViewsKind,
1597
- nt as nativeWorkflowsKind,
1598
- At as newStudioScript,
1599
- J as objectFileKind,
1600
- x as parseJsonText,
1601
- mt as parseStudioLayout,
1602
- ce as patchJsonText,
1603
- Ae as patchJsonTextDetailed,
1604
- wt as placeStudioEntry,
1605
- qe as readTranslations,
1606
- vt as removeStudioLayoutNode,
1607
- St as renameStudioEntryRef,
1608
- kt as renameStudioLayoutNode,
1609
- Pe as resolveFileKind,
1610
- _e as safeJson,
1611
- He as scriptsFileKind,
1612
- yt as serializeStudioLayout,
1613
- ne as slugifyModuleId,
1614
- S as stringifyJsonText,
1615
- pt as studioEntryRef,
1616
- ut as studioLayoutPath,
1617
- Ye as studioScriptIdentifier,
1618
- We as studioScriptLanguages,
1619
- V as textFallbackKind,
1620
- Ze as toStudioScriptItem,
1621
- ee as writeTranslations
1826
+ at as NICE_STUDIO_SCRIPT_KINDS,
1827
+ Wt as NICE_STUDIO_SCRIPT_PHASES,
1828
+ Ct as addStudioFolder,
1829
+ Ft as addStudioSection,
1830
+ R as arrayFileKind,
1831
+ Ut as buildDocuments,
1832
+ Bt as createMemoryStudioProvider,
1833
+ Xt as defineManifestSection,
1834
+ Qt as deriveDefaultRbac,
1835
+ Y as detectJsonTextFormat,
1836
+ U as emptyStudioLayout,
1837
+ Vt as encodeDocument,
1838
+ S as endsWithAny,
1839
+ Ht as entitiesToSchemas,
1840
+ x as fileName,
1841
+ _t as findStudioReferences,
1842
+ Zt as fitManifestSection,
1843
+ ut as fromStudioScriptItem,
1844
+ ot as i18nFileKind,
1845
+ G as inferStudioScriptKind,
1846
+ Mt as isEmptyStudioLayout,
1847
+ ae as isStudioFolderWithin,
1848
+ xe as isStudioLayoutPath,
1849
+ Se as itemsFileKind,
1850
+ B as jsonFallbackKind,
1851
+ D as jsonFileKind,
1852
+ H as jsonValueFitsSchema,
1853
+ P as jsonValuesEqual,
1854
+ Fe as keepTextFormat,
1855
+ Gt as manifestSectionKeys,
1856
+ At as modulePrefix,
1857
+ Dt as moveStudioFolder,
1858
+ kt as nativeDataSourcesKind,
1859
+ ht as nativeEntitiesKind,
1860
+ St as nativeEnvironmentsKind,
1861
+ Ot as nativeFileKinds,
1862
+ vt as nativeHooksKind,
1863
+ yt as nativeI18nKind,
1864
+ $t as nativeIntegrationsKind,
1865
+ se as nativeManifestKind,
1866
+ wt as nativeRbacKind,
1867
+ jt as nativeScriptsKind,
1868
+ Yt as nativeStudioPreset,
1869
+ Ee as nativeStudioReferences,
1870
+ gt as nativeViewsKind,
1871
+ bt as nativeWorkflowsKind,
1872
+ zt as newStudioScript,
1873
+ _ as objectFileKind,
1874
+ qt as orderStudioEntries,
1875
+ K as parseJsonText,
1876
+ xt as parseStudioLayout,
1877
+ ee as patchJsonText,
1878
+ Ce as patchJsonTextDetailed,
1879
+ Jt as placeStudioEntry,
1880
+ rt as readTranslations,
1881
+ Pt as removeStudioLayoutNode,
1882
+ Rt as renameStudioEntryRef,
1883
+ Lt as renameStudioLayoutNode,
1884
+ Ze as renameStudioReferences,
1885
+ Ye as resolveFileKind,
1886
+ nt as safeJson,
1887
+ pt as scriptsFileKind,
1888
+ Tt as serializeStudioLayout,
1889
+ de as slugifyModuleId,
1890
+ j as stringifyJsonText,
1891
+ He as studioDependencies,
1892
+ It as studioEntryRef,
1893
+ Nt as studioLayoutPath,
1894
+ Ge as studioQualifiedReferences,
1895
+ mt as studioScriptIdentifier,
1896
+ ct as studioScriptLanguages,
1897
+ X as textFallbackKind,
1898
+ ft as toStudioScriptItem,
1899
+ ce as writeTranslations
1622
1900
  };