@nice2dev/ui-forms 1.4.5 → 1.4.6

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,138 @@
1
- var me = Object.defineProperty;
2
- var he = (e, t, n) => t in e ? me(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var G = (e, t, n) => he(e, typeof t != "symbol" ? t + "" : t, n);
4
- const T = () => ({
1
+ var we = Object.defineProperty;
2
+ var ve = (e, t, n) => t in e ? we(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var Y = (e, t, n) => ve(e, typeof t != "symbol" ? t + "" : t, n);
4
+ const J = () => ({
5
5
  version: 1,
6
6
  sections: [],
7
7
  folders: [],
8
8
  placement: {}
9
- }), Ge = (e, t) => `${e}:${t}`, P = ".studio.json", ye = /^([^/]+?)\.(manifest|entities|views|workflows|permissions|rbac|seeds|datasources|scripts)\.json$/i, ge = (e) => !e.includes("/") && e.toLowerCase().endsWith(P);
10
- function Ye(e) {
11
- const t = e.find((n) => ge(n.path));
9
+ }), dt = (e, t) => `${e}:${t}`, _ = ".studio.json", Se = /^([^/]+?)\.(manifest|entities|views|workflows|permissions|rbac|seeds|datasources|scripts)\.json$/i, $e = (e) => !e.includes("/") && e.toLowerCase().endsWith(_);
10
+ function ft(e) {
11
+ const t = e.find((n) => $e(n.path));
12
12
  if (t)
13
13
  return t.path;
14
14
  for (const n of e) {
15
- const s = ye.exec(n.path);
15
+ const s = Se.exec(n.path);
16
16
  if (s)
17
- return `${s[1]}${P}`;
17
+ return `${s[1]}${_}`;
18
18
  }
19
- return `module${P}`;
19
+ return `module${_}`;
20
20
  }
21
- const E = (e) => typeof e == "object" && e !== null && !Array.isArray(e), b = (e) => typeof e == "string" && e ? e : void 0;
22
- function He(e) {
21
+ const N = (e) => typeof e == "object" && e !== null && !Array.isArray(e), b = (e) => typeof e == "string" && e ? e : void 0;
22
+ function pt(e) {
23
23
  if (!e)
24
- return T();
24
+ return J();
25
25
  let t;
26
26
  try {
27
27
  t = JSON.parse(e.replace(/^\uFEFF/, ""));
28
28
  } catch {
29
- return T();
29
+ return J();
30
30
  }
31
- if (!E(t))
32
- return T();
33
- const n = (Array.isArray(t.sections) ? t.sections : []).filter(E).map((o) => ({ id: b(o.id), label: b(o.label) ?? b(o.id) })).filter((o) => !!o.id && !!o.label), s = (Array.isArray(t.folders) ? t.folders : []).filter(E).map((o) => ({
34
- id: b(o.id),
35
- label: b(o.label) ?? b(o.id),
36
- group: b(o.group),
37
- ...b(o.parent) ? { parent: b(o.parent) } : {},
38
- ...b(o.section) ? { section: b(o.section) } : {}
39
- })).filter((o) => !!o.id && !!o.label && !!o.group), i = {};
40
- if (E(t.placement))
41
- for (const [o, c] of Object.entries(t.placement)) {
42
- if (!E(c))
31
+ if (!N(t))
32
+ return J();
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))
43
43
  continue;
44
44
  const l = {};
45
- b(c.section) && (l.section = b(c.section)), b(c.folder) && (l.folder = b(c.folder)), typeof c.order == "number" && Number.isFinite(c.order) && (l.order = c.order), (l.section || l.folder || l.order !== void 0) && (i[o] = 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);
46
46
  }
47
- return { version: 1, sections: n, folders: s, placement: i };
47
+ return { version: 1, sections: n, folders: s, placement: r };
48
48
  }
49
- const Ze = (e) => e.sections.length === 0 && e.folders.length === 0 && Object.keys(e.placement).length === 0;
50
- function Qe(e, t) {
49
+ const ut = (e) => e.sections.length === 0 && e.folders.length === 0 && Object.keys(e.placement).length === 0;
50
+ function mt(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 be = (e) => e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "item";
58
- function ee(e, t) {
59
- const n = be(e);
57
+ const je = (e) => e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "item";
58
+ function re(e, t) {
59
+ const n = je(e);
60
60
  let s = n;
61
- for (let i = 2; t.has(s); i++)
62
- s = `${n}-${i}`;
61
+ for (let r = 2; t.has(s); r++)
62
+ s = `${n}-${r}`;
63
63
  return s;
64
64
  }
65
- function et(e, t) {
66
- const n = ee(t, new Set(e.sections.map((s) => s.id)));
65
+ function ht(e, t) {
66
+ const n = re(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 tt(e, t) {
70
- const n = ee(t.label, new Set(e.folders.map((i) => i.id))), s = { id: n, label: t.label, group: t.group };
69
+ function yt(e, t) {
70
+ const n = re(t.label, new Set(e.folders.map((r) => r.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 nt(e, t, n) {
73
+ function gt(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 st(e, t) {
76
+ function bt(e, t) {
77
77
  const n = {};
78
78
  if (t.kind === "folder") {
79
- const s = e.folders.find((i) => i.id === t.id);
80
- for (const [i, o] of Object.entries(e.placement))
81
- n[i] = o.folder === t.id ? { ...o, folder: s == null ? void 0 : s.parent } : o, n[i].folder || delete n[i].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;
82
82
  return {
83
83
  ...e,
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: o, ...c } = i;
87
- return c;
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;
88
88
  }
89
- return i;
89
+ return r;
90
90
  }),
91
- placement: D(n)
91
+ placement: U(n)
92
92
  };
93
93
  }
94
- for (const [s, i] of Object.entries(e.placement))
95
- if (i.section === t.id) {
96
- const { section: o, ...c } = i;
97
- n[s] = c;
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;
98
98
  } else
99
- n[s] = i;
99
+ n[s] = r;
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: i, ...o } = s;
106
- return o;
105
+ const { section: r, ...i } = s;
106
+ return i;
107
107
  }
108
108
  return s;
109
109
  }),
110
- placement: D(n)
110
+ placement: U(n)
111
111
  };
112
112
  }
113
- function D(e) {
113
+ function U(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 it(e, t, n) {
120
- var o;
121
- const s = (o = e.placement[t]) == null ? void 0 : o.order, i = {};
119
+ function kt(e, t, n) {
120
+ var i;
121
+ const s = (i = e.placement[t]) == null ? void 0 : i.order, r = {};
122
122
  if (n.folder) {
123
- i.folder = n.folder;
124
- const c = e.folders.find((l) => l.id === n.folder);
125
- c != null && c.section && (i.section = c.section);
126
- } else n.section && (i.section = n.section);
127
- return s !== void 0 && (i.order = s), { ...e, placement: D({ ...e.placement, [t]: i }) };
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: U({ ...e.placement, [t]: r }) };
128
128
  }
129
- function rt(e, t, n) {
129
+ function wt(e, t, n) {
130
130
  if (t === n || !e.placement[t])
131
131
  return e;
132
132
  const s = { ...e.placement, [n]: e.placement[t] };
133
133
  return delete s[t], { ...e, placement: s };
134
134
  }
135
- const te = "\uFEFF", ne = {
135
+ const ie = "\uFEFF", oe = {
136
136
  bom: !1,
137
137
  eol: `
138
138
  `,
@@ -140,98 +140,98 @@ const te = "\uFEFF", ne = {
140
140
  finalNewline: !0,
141
141
  colonSpace: !0
142
142
  };
143
- function z(e) {
143
+ function X(e) {
144
144
  const t = e.charCodeAt(0) === 65279, n = e.includes(`\r
145
145
  `) ? `\r
146
146
  ` : `
147
147
  `;
148
- let s = ne.indent;
149
- const i = e.split(/\r?\n/);
150
- for (let c = 1; c < i.length; c++) {
151
- const l = /^([ \t]+)\S/.exec(i[c]);
148
+ let s = oe.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]);
152
152
  if (l) {
153
153
  s = l[1];
154
154
  break;
155
155
  }
156
156
  }
157
- const o = /"\s*:(\s?)/.exec(e);
157
+ const i = /"\s*:(\s?)/.exec(e);
158
158
  return {
159
159
  bom: t,
160
160
  eol: n,
161
161
  indent: s,
162
162
  finalNewline: /\n$/.test(e),
163
- colonSpace: o ? o[1] !== "" : !0
163
+ colonSpace: i ? i[1] !== "" : !0
164
164
  };
165
165
  }
166
- function I(e) {
167
- const t = z(e);
166
+ function x(e) {
167
+ const t = X(e);
168
168
  return { value: JSON.parse(t.bom ? e.slice(1) : e), format: t };
169
169
  }
170
170
  function v(e, t) {
171
- const n = { ...ne, ...t }, s = O(e, n, "");
172
- return (n.bom ? te : "") + s + (n.finalNewline ? n.eol : "");
171
+ const n = { ...oe, ...t }, s = A(e, n, "");
172
+ return (n.bom ? ie : "") + s + (n.finalNewline ? n.eol : "");
173
173
  }
174
- function we(e, t) {
174
+ function Oe(e, t) {
175
175
  if (t === void 0)
176
176
  return e;
177
177
  let n = t.includes(`\r
178
178
  `) ? e.replace(/\r?\n/g, `\r
179
179
  `) : e;
180
- return t.charCodeAt(0) === 65279 && n.charCodeAt(0) !== 65279 && (n = te + n), n;
180
+ return t.charCodeAt(0) === 65279 && n.charCodeAt(0) !== 65279 && (n = ie + n), n;
181
181
  }
182
- function M(e, t) {
182
+ function C(e, t) {
183
183
  if (e === t)
184
184
  return !0;
185
185
  if (typeof e != typeof t || e === null || t === null || typeof e != "object" || Array.isArray(e) !== Array.isArray(t))
186
186
  return !1;
187
187
  if (Array.isArray(e)) {
188
- const o = t;
189
- return e.length === o.length && e.every((c, l) => M(c, o[l]));
188
+ const i = t;
189
+ return e.length === i.length && e.every((a, l) => C(a, i[l]));
190
190
  }
191
- const n = e, s = t, i = Object.keys(n);
192
- return i.length !== Object.keys(s).length ? !1 : i.every(
193
- (o) => Object.prototype.hasOwnProperty.call(s, o) && M(n[o], s[o])
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) && C(n[i], s[i])
194
194
  );
195
195
  }
196
- function se(e, t, n) {
197
- return ke(e, t, n).text;
196
+ function ae(e, t, n) {
197
+ return Ae(e, t, n).text;
198
198
  }
199
- function ke(e, t, n) {
200
- const s = z(e), i = (r) => ({
199
+ function Ae(e, t, n) {
200
+ const s = X(e), r = (o) => ({
201
201
  text: v(t, s),
202
202
  exact: !1,
203
- reason: r
203
+ reason: o
204
204
  });
205
- let o;
205
+ let i;
206
206
  try {
207
- o = new ve(e).parseDocument();
208
- } catch (r) {
209
- return i(r instanceof Error ? r.message : String(r));
207
+ i = new Ee(e).parseDocument();
208
+ } catch (o) {
209
+ return r(o instanceof Error ? o.message : String(o));
210
210
  }
211
- if (C(o))
212
- return i("duplicate keys");
213
- const c = [], l = {
211
+ if (R(i))
212
+ return r("duplicate keys");
213
+ const a = [], l = {
214
214
  text: e,
215
215
  format: s,
216
- edits: c,
216
+ edits: a,
217
217
  options: n,
218
218
  compact: !e.trimEnd().includes(`
219
219
  `)
220
220
  };
221
- q(l, o, t, "", !1);
222
- const u = $e(e, c);
221
+ G(l, i, t, "", !1);
222
+ const f = Ke(e, a);
223
223
  try {
224
- const r = JSON.parse(s.bom ? u.slice(1) : u);
225
- if (!M(r, t))
226
- return i("patch did not read back");
224
+ const o = JSON.parse(s.bom ? f.slice(1) : f);
225
+ if (!C(o, t))
226
+ return r("patch did not read back");
227
227
  } catch {
228
- return i("patch was not valid JSON");
228
+ return r("patch was not valid JSON");
229
229
  }
230
- return { text: u, exact: !0 };
230
+ return { text: f, exact: !0 };
231
231
  }
232
- class ve {
232
+ class Ee {
233
233
  constructor(t) {
234
- G(this, "pos", 0);
234
+ Y(this, "pos", 0);
235
235
  this.text = t;
236
236
  }
237
237
  parseDocument() {
@@ -287,14 +287,14 @@ class ve {
287
287
  const s = this.pos;
288
288
  if (this.text[this.pos] !== '"')
289
289
  throw new Error(`Expected a key at ${this.pos}`);
290
- const i = JSON.parse(this.text.slice(s, this.stringEnd()));
290
+ const r = JSON.parse(this.text.slice(s, this.stringEnd()));
291
291
  if (this.ws(), this.text[this.pos] !== ":")
292
292
  throw new Error(`Expected ':' at ${this.pos}`);
293
- this.pos++, n.push({ key: i, start: s, value: this.value() }), this.ws();
294
- const o = this.text[this.pos++];
295
- if (o === "}")
293
+ this.pos++, n.push({ key: r, start: s, value: this.value() }), this.ws();
294
+ const i = this.text[this.pos++];
295
+ if (i === "}")
296
296
  return { kind: "object", start: t, end: this.pos, members: n };
297
- if (o !== ",")
297
+ if (i !== ",")
298
298
  throw new Error(`Expected ',' or '}' at ${this.pos - 1}`);
299
299
  }
300
300
  }
@@ -312,16 +312,16 @@ class ve {
312
312
  }
313
313
  }
314
314
  }
315
- function C(e) {
315
+ function R(e) {
316
316
  if (e.kind === "object") {
317
317
  const t = /* @__PURE__ */ new Set();
318
318
  for (const n of e.members) {
319
- if (t.has(n.key) || C(n.value))
319
+ if (t.has(n.key) || R(n.value))
320
320
  return !0;
321
321
  t.add(n.key);
322
322
  }
323
323
  } else if (e.kind === "array")
324
- return e.items.some(C);
324
+ return e.items.some(R);
325
325
  return !1;
326
326
  }
327
327
  function F(e) {
@@ -334,247 +334,247 @@ function F(e) {
334
334
  t[n.key] = F(n.value);
335
335
  return t;
336
336
  }
337
- function O(e, t, n) {
337
+ function A(e, t, n) {
338
338
  if (e === null || typeof e != "object")
339
339
  return e === void 0 ? "null" : JSON.stringify(e);
340
- const s = n + t.indent, i = t.colonSpace ? ": " : ":";
340
+ const s = n + t.indent, r = t.colonSpace ? ": " : ":";
341
341
  if (Array.isArray(e))
342
- return e.length === 0 ? "[]" : `[${t.eol}${e.map((c) => s + O(c, t, s)).join(`,${t.eol}`)}${t.eol}${n}]`;
343
- const o = Object.entries(e).filter(
344
- ([, c]) => c !== void 0
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
345
345
  );
346
- return o.length === 0 ? "{}" : `{${t.eol}${o.map(([c, l]) => `${s}${JSON.stringify(c)}${i}${O(l, t, s)}`).join(`,${t.eol}`)}${t.eol}${n}}`;
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}}`;
347
347
  }
348
- function A(e, t, n = !1) {
348
+ function E(e, t, n = !1) {
349
349
  if (e === null || typeof e != "object")
350
350
  return e === void 0 ? "null" : JSON.stringify(e);
351
- const s = t.colonSpace ? ": " : ":", i = n ? "," : ", ";
351
+ const s = t.colonSpace ? ": " : ":", r = n ? "," : ", ";
352
352
  if (Array.isArray(e))
353
- return `[${e.map((l) => A(l, t, n)).join(i)}]`;
354
- const o = Object.entries(e).filter(
353
+ return `[${e.map((l) => E(l, t, n)).join(r)}]`;
354
+ const i = Object.entries(e).filter(
355
355
  ([, l]) => l !== void 0
356
- ), c = n ? "" : " ";
357
- return o.length === 0 ? "{}" : `{${c}${o.map(([l, u]) => `${JSON.stringify(l)}${s}${A(u, t, n)}`).join(i)}${c}}`;
356
+ ), a = n ? "" : " ";
357
+ return i.length === 0 ? "{}" : `{${a}${i.map(([l, f]) => `${JSON.stringify(l)}${s}${E(f, t, n)}`).join(r)}${a}}`;
358
358
  }
359
- const ie = (e) => e.compact ? "," : ", ";
360
- function $e(e, t) {
359
+ const ce = (e) => e.compact ? "," : ", ";
360
+ function Ke(e, t) {
361
361
  let n = e;
362
- for (const s of [...t].sort((i, o) => o.start - i.start))
362
+ for (const s of [...t].sort((r, i) => i.start - r.start))
363
363
  n = n.slice(0, s.start) + s.text + n.slice(s.end);
364
364
  return n;
365
365
  }
366
- function J(e, t) {
366
+ function L(e, t) {
367
367
  var s;
368
368
  const n = e.lastIndexOf(`
369
369
  `, t - 1) + 1;
370
370
  return ((s = /^[ \t]*/.exec(e.slice(n, t))) == null ? void 0 : s[0]) ?? "";
371
371
  }
372
- function re(e, t) {
372
+ function le(e, t) {
373
373
  return !e.slice(t.start, t.end).includes(`
374
374
  `);
375
375
  }
376
- function W(e, t, n) {
377
- return e.compact ? !0 : t.kind === "scalar" || (t.kind === "object" ? t.members.length === 0 : t.items.length === 0) ? n : re(e.text, t);
376
+ function Z(e, t, n) {
377
+ return e.compact ? !0 : t.kind === "scalar" || (t.kind === "object" ? t.members.length === 0 : t.items.length === 0) ? n : le(e.text, t);
378
378
  }
379
- function x(e, t, n, s) {
380
- const i = W(e, t, s);
379
+ function T(e, t, n, s) {
380
+ const r = Z(e, t, s);
381
381
  e.edits.push({
382
382
  start: t.start,
383
383
  end: t.end,
384
- text: i ? A(n, e.format, e.compact) : O(n, e.format, J(e.text, t.start))
384
+ text: r ? E(n, e.format, e.compact) : A(n, e.format, L(e.text, t.start))
385
385
  });
386
386
  }
387
- const oe = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
388
- function q(e, t, n, s, i) {
387
+ const de = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
388
+ function G(e, t, n, s, r) {
389
389
  if (t.kind === "scalar") {
390
390
  if (t.value === n)
391
391
  return;
392
- x(e, t, n, i);
392
+ T(e, t, n, r);
393
393
  return;
394
394
  }
395
- M(F(t), n) || (t.kind === "object" && oe(n) ? Se(e, t, n, s, i) : t.kind === "array" && Array.isArray(n) ? Ae(e, t, n, s, i) : x(e, t, n, i));
395
+ C(F(t), n) || (t.kind === "object" && de(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
396
  }
397
- function ae(e, t, n) {
398
- return n !== void 0 ? J(e.text, n) : J(e.text, t.start) + e.format.indent;
397
+ function fe(e, t, n) {
398
+ return n !== void 0 ? L(e.text, n) : L(e.text, t.start) + e.format.indent;
399
399
  }
400
- function Se(e, t, n, s, i) {
400
+ function Ne(e, t, n, s, r) {
401
401
  var d;
402
- const o = W(e, t, i), c = t.members.filter(
403
- (f) => Object.prototype.hasOwnProperty.call(n, f.key) && n[f.key] !== void 0
402
+ const i = Z(e, t, r), a = t.members.filter(
403
+ (p) => Object.prototype.hasOwnProperty.call(n, p.key) && n[p.key] !== void 0
404
404
  ), l = Object.keys(n).filter(
405
- (f) => n[f] !== void 0 && !t.members.some((h) => h.key === f)
405
+ (p) => n[p] !== void 0 && !t.members.some((h) => h.key === p)
406
406
  );
407
- if (c.length === 0 && t.members.length > 0) {
408
- x(e, t, n, i);
407
+ if (a.length === 0 && t.members.length > 0) {
408
+ T(e, t, n, r);
409
409
  return;
410
410
  }
411
- for (const f of c)
412
- q(e, f.value, n[f.key], `${s}/${Ne(f.key)}`, o);
413
- if (ce(
411
+ for (const p of a)
412
+ G(e, p.value, n[p.key], `${s}/${Le(p.key)}`, i);
413
+ if (pe(
414
414
  e,
415
- t.members.map((f) => ({ start: f.start, end: f.value.end })),
416
- t.members.map((f) => c.includes(f))
415
+ t.members.map((p) => ({ start: p.start, end: p.value.end })),
416
+ t.members.map((p) => a.includes(p))
417
417
  ), l.length === 0)
418
418
  return;
419
- const u = e.format.colonSpace ? ": " : ":";
420
- if (o) {
421
- const f = l.map(
422
- (h) => `${JSON.stringify(h)}${u}${A(n[h], e.format, e.compact)}`
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)}`
423
423
  );
424
- de(e, t, c.length > 0 ? c[c.length - 1].value.end : void 0, f);
424
+ me(e, t, a.length > 0 ? a[a.length - 1].value.end : void 0, p);
425
425
  return;
426
426
  }
427
- const r = ae(e, t, (d = t.members[0]) == null ? void 0 : d.start), a = l.map(
428
- (f) => `${r}${JSON.stringify(f)}${u}${O(n[f], e.format, r)}`
427
+ const o = fe(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)}`
429
429
  );
430
- le(e, t, c.length > 0 ? c[c.length - 1].value.end : void 0, a);
430
+ ue(e, t, a.length > 0 ? a[a.length - 1].value.end : void 0, c);
431
431
  }
432
- const je = ["name", "id", "code", "key", "slug", "state", "Id"];
433
- function Oe(e, t, n, s) {
434
- var u, r;
435
- const i = [...n, ...s];
436
- if (i.length === 0 || !i.every(oe))
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(de))
437
437
  return;
438
- const o = (a, d) => {
439
- const f = a.map((h) => h[d]);
440
- return f.every((h) => typeof h == "string" || typeof h == "number") && new Set(f).size === f.length;
441
- }, c = (r = (u = e.options) == null ? void 0 : u.arrayKey) == null ? void 0 : r.call(u, t);
442
- return (c ? [c] : je).find((a) => o(n, a) && o(s, a));
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
443
  }
444
- function Ae(e, t, n, s, i) {
444
+ function Te(e, t, n, s, r) {
445
445
  var g;
446
- const o = W(e, t, i), c = t.items.map(F), l = Oe(e, s, c, n), u = (p) => p[l], r = l !== void 0 ? c.map((p) => {
447
- const m = u(p);
448
- return n.findIndex((w) => u(w) === m);
449
- }) : Ee(c, n);
446
+ const i = Z(e, t, r), a = t.items.map(F), 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
+ }) : Fe(a, n);
450
450
  {
451
- const p = new Set(r.filter((m) => m >= 0));
452
- for (let m = 0; m < r.length; m++) {
453
- if (r[m] >= 0)
451
+ const u = new Set(o.filter((m) => m >= 0));
452
+ for (let m = 0; m < o.length; m++) {
453
+ if (o[m] >= 0)
454
454
  continue;
455
- let w = -1;
455
+ let k = -1;
456
456
  for (let y = m - 1; y >= 0; y--)
457
- if (r[y] >= 0) {
458
- w = r[y];
457
+ if (o[y] >= 0) {
458
+ k = o[y];
459
459
  break;
460
460
  }
461
- let $ = n.length;
462
- for (let y = m + 1; y < r.length; y++)
463
- if (r[y] >= 0) {
464
- $ = r[y];
461
+ let j = n.length;
462
+ for (let y = m + 1; y < o.length; y++)
463
+ if (o[y] >= 0) {
464
+ j = o[y];
465
465
  break;
466
466
  }
467
- for (let y = w + 1; y < $; y++)
468
- if (!p.has(y)) {
469
- r[m] = y, p.add(y);
467
+ for (let y = k + 1; y < j; y++)
468
+ if (!u.has(y)) {
469
+ o[m] = y, u.add(y);
470
470
  break;
471
471
  }
472
472
  }
473
473
  }
474
- const a = r.filter((p) => p >= 0);
475
- if (a.some((p, m) => m > 0 && p < a[m - 1])) {
476
- x(e, t, n, i);
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);
477
477
  return;
478
478
  }
479
- if (a.length === 0 && t.items.length > 0) {
480
- x(e, t, n, i);
479
+ if (c.length === 0 && t.items.length > 0) {
480
+ T(e, t, n, r);
481
481
  return;
482
482
  }
483
- t.items.forEach((p, m) => {
484
- r[m] >= 0 && q(e, p, n[r[m]], `${s}/${r[m]}`, o);
485
- }), ce(
483
+ t.items.forEach((u, m) => {
484
+ o[m] >= 0 && G(e, u, n[o[m]], `${s}/${o[m]}`, i);
485
+ }), pe(
486
486
  e,
487
- t.items.map((p) => ({ start: p.start, end: p.end })),
488
- r.map((p) => p >= 0)
487
+ t.items.map((u) => ({ start: u.start, end: u.end })),
488
+ o.map((u) => u >= 0)
489
489
  );
490
- const d = t.items.length > 0 && t.items.every((p) => p.kind !== "scalar" && re(e.text, p)), f = ae(e, t, (g = t.items[0]) == null ? void 0 : g.start), h = /* @__PURE__ */ new Map();
491
- n.forEach((p, m) => {
492
- if (r.includes(m))
490
+ const d = t.items.length > 0 && t.items.every((u) => u.kind !== "scalar" && le(e.text, u)), p = fe(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))
493
493
  return;
494
- let w;
495
- for (let S = t.items.length - 1; S >= 0; S--)
496
- if (r[S] >= 0 && r[S] < m) {
497
- w = S;
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;
498
498
  break;
499
499
  }
500
- const $ = o ? A(p, e.format, e.compact) : d ? `${f}${A(p, e.format)}` : `${f}${O(p, e.format, f)}`, y = h.get(w) ?? [];
501
- y.push($), h.set(w, y);
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);
502
502
  });
503
- for (const [p, m] of h) {
504
- const w = p === void 0 ? void 0 : t.items[p].end;
505
- if (p === void 0 && a.length > 0) {
506
- const $ = t.items[r.findIndex((S) => S >= 0)], y = o ? ie(e) : `,${e.format.eol}`;
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 ? ce(e) : `,${e.format.eol}`;
507
507
  e.edits.push({
508
- start: $.start,
509
- end: $.start,
510
- text: o ? m.join(y) + y : m.join(y).trimStart() + y + f
508
+ start: j.start,
509
+ end: j.start,
510
+ text: i ? m.join(y) + y : m.join(y).trimStart() + y + p
511
511
  });
512
512
  continue;
513
513
  }
514
- o ? de(e, t, w, m) : le(e, t, w, m);
514
+ i ? me(e, t, k, m) : ue(e, t, k, m);
515
515
  }
516
516
  }
517
- const Ke = 4e6;
518
- function Ee(e, t) {
517
+ const Ce = 4e6;
518
+ function Fe(e, t) {
519
519
  const n = e.length, s = t.length;
520
- if (n * s > Ke)
521
- return e.map((a, d) => d < s ? d : -1);
522
- const i = e.map((a) => JSON.stringify(a)), o = t.map((a) => JSON.stringify(a)), c = Array.from({ length: n + 1 }, () => new Uint32Array(s + 1));
523
- for (let a = n - 1; a >= 0; a--)
520
+ if (n * s > Ce)
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));
523
+ for (let c = n - 1; c >= 0; c--)
524
524
  for (let d = s - 1; d >= 0; d--)
525
- c[a][d] = i[a] === o[d] ? c[a + 1][d + 1] + 1 : Math.max(c[a + 1][d], c[a][d + 1]);
525
+ a[c][d] = r[c] === i[d] ? a[c + 1][d + 1] + 1 : Math.max(a[c + 1][d], a[c][d + 1]);
526
526
  const l = new Array(n).fill(-1);
527
- let u = 0, r = 0;
528
- for (; u < n && r < s; )
529
- i[u] === o[r] ? l[u++] = r++ : c[u + 1][r] >= c[u][r + 1] ? u++ : r++;
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++;
530
530
  return l;
531
531
  }
532
- function ce(e, t, n) {
532
+ function pe(e, t, n) {
533
533
  for (let s = 0; s < t.length; s++) {
534
534
  if (n[s])
535
535
  continue;
536
- let i = s;
537
- for (; i + 1 < t.length && !n[i + 1]; )
538
- i++;
539
- 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;
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;
540
540
  }
541
541
  }
542
- function le(e, t, n, s) {
543
- const i = e.format.eol;
542
+ function ue(e, t, n, s) {
543
+ const r = e.format.eol;
544
544
  if (n !== void 0) {
545
- e.edits.push({ start: n, end: n, text: `,${i}${s.join(`,${i}`)}` });
545
+ e.edits.push({ start: n, end: n, text: `,${r}${s.join(`,${r}`)}` });
546
546
  return;
547
547
  }
548
- const o = t.end - 1;
548
+ const i = t.end - 1;
549
549
  if ((t.kind === "object" ? t.members.length : t.items.length) === 0)
550
550
  e.edits.push({
551
551
  start: t.start + 1,
552
- end: o,
553
- text: `${i}${s.join(`,${i}`)}${i}${J(e.text, t.start)}`
552
+ end: i,
553
+ text: `${r}${s.join(`,${r}`)}${r}${L(e.text, t.start)}`
554
554
  });
555
555
  else {
556
556
  const l = t.kind === "object" ? t.members[0].start : t.items[0].start;
557
- e.edits.push({ start: l, end: l, text: `${s.join(`,${i}`).trimStart()}` });
557
+ e.edits.push({ start: l, end: l, text: `${s.join(`,${r}`).trimStart()}` });
558
558
  }
559
559
  }
560
- function de(e, t, n, s) {
561
- const i = ie(e);
560
+ function me(e, t, n, s) {
561
+ const r = ce(e);
562
562
  if (n !== void 0) {
563
- e.edits.push({ start: n, end: n, text: `${i}${s.join(i)}` });
563
+ e.edits.push({ start: n, end: n, text: `${r}${s.join(r)}` });
564
564
  return;
565
565
  }
566
- const o = t.kind === "object" && !e.compact ? " " : "";
566
+ const i = t.kind === "object" && !e.compact ? " " : "";
567
567
  e.edits.push({
568
568
  start: t.start + 1,
569
569
  end: t.end - 1,
570
- text: `${o}${s.join(i)}${o}`
570
+ text: `${i}${s.join(r)}${i}`
571
571
  });
572
572
  }
573
- function Ne(e) {
573
+ function Le(e) {
574
574
  return e.replace(/~/g, "~0").replace(/\//g, "~1");
575
575
  }
576
- const K = (e) => e.slice(e.lastIndexOf("/") + 1), Ie = (e) => e.charCodeAt(0) === 65279 ? e.slice(1) : e;
577
- function B(e) {
576
+ const K = (e) => e.slice(e.lastIndexOf("/") + 1), Me = (e) => e.charCodeAt(0) === 65279 ? e.slice(1) : e;
577
+ function M(e) {
578
578
  return {
579
579
  id: e.id,
580
580
  label: e.label,
@@ -583,19 +583,19 @@ function B(e) {
583
583
  match: e.match,
584
584
  editor: e.editor,
585
585
  decode(t, n) {
586
- return e.select(I(t[0].text).value, n);
586
+ return e.select(x(t[0].text).value, n);
587
587
  },
588
588
  encode(t, n, s) {
589
- const i = n[0].text, o = I(i).value, c = e.assign(o, t, s);
589
+ const r = n[0].text, i = x(r).value, a = e.assign(i, t, s);
590
590
  return {
591
591
  files: [
592
- { path: n[0].path, text: se(i, c, { arrayKey: e.arrayKey }) }
592
+ { path: n[0].path, text: ae(r, a, { arrayKey: e.arrayKey }) }
593
593
  ]
594
594
  };
595
595
  }
596
596
  };
597
597
  }
598
- const R = B({
598
+ const q = M({
599
599
  id: "json",
600
600
  label: "JSON",
601
601
  labelKey: "devStudio.kind.json",
@@ -604,7 +604,7 @@ const R = B({
604
604
  editor: "json",
605
605
  select: (e) => e,
606
606
  assign: (e, t) => t
607
- }), U = {
607
+ }), z = {
608
608
  id: "text",
609
609
  label: "Text",
610
610
  labelKey: "devStudio.kind.text",
@@ -613,87 +613,87 @@ const R = B({
613
613
  editor: "text",
614
614
  decode: (e) => e[0].text,
615
615
  encode: (e, t) => ({
616
- files: [{ path: t[0].path, text: we(e, t[0].text) }]
616
+ files: [{ path: t[0].path, text: Oe(e, t[0].text) }]
617
617
  })
618
618
  };
619
- function xe(e, t) {
620
- return e.find((n) => n.match(t)) ?? (R.match(t) ? R : U);
619
+ function Pe(e, t) {
620
+ return e.find((n) => n.match(t)) ?? (q.match(t) ? q : z);
621
621
  }
622
- function Me(e, t, n) {
623
- for (const s of [R, U])
622
+ function Je(e, t, n) {
623
+ for (const s of [q, z])
624
624
  if (s.match(e.path))
625
625
  try {
626
- const i = s.decode([e], n);
626
+ const r = s.decode([e], n);
627
627
  return {
628
628
  key: `${s.id}:${e.path}`,
629
629
  kind: s,
630
630
  paths: [e.path],
631
631
  label: K(e.path),
632
- model: i,
632
+ model: r,
633
633
  error: t
634
634
  };
635
635
  } catch {
636
636
  }
637
637
  return {
638
638
  key: `text:${e.path}`,
639
- kind: U,
639
+ kind: z,
640
640
  paths: [e.path],
641
641
  label: K(e.path),
642
642
  model: e.text,
643
643
  error: t
644
644
  };
645
645
  }
646
- function Fe(e, t, n, s) {
647
- var l, u;
648
- const i = e.encode(t, n, s), o = new Map(n.map((r) => [r.path, r.text])), c = ((l = i.files.find((r) => o.get(r.path) !== r.text)) == null ? void 0 : l.path) ?? ((u = i.deleted) == null ? void 0 : u.find((r) => o.has(r)));
649
- if (c !== void 0)
650
- throw new Error(`${K(c)} would not be stored as it is`);
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`);
651
651
  }
652
- function ot(e, t, n) {
652
+ function vt(e, t, n) {
653
653
  const s = /* @__PURE__ */ new Map();
654
- for (const o of t) {
655
- const c = xe(e, o.path), l = c.group ? c.group(o.path) : o.path, u = `${c.id}:${l}`, r = s.get(u) ?? { kind: c, group: l, files: [] };
656
- r.files.push(o), s.set(u, r);
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);
657
657
  }
658
- const i = [];
659
- for (const [o, { kind: c, group: l, files: u }] of s) {
660
- const r = u.map((d) => d.path).sort(), a = K(c.group ? l : r[0]);
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]);
661
661
  try {
662
- const d = c.decode(u, n);
663
- Fe(c, d, u, n), i.push({ key: o, kind: c, paths: r, label: a, model: d });
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
664
  } catch (d) {
665
- const f = d instanceof Error ? d.message : String(d);
666
- for (const h of u)
667
- i.push(Me(h, f, n));
665
+ const p = d instanceof Error ? d.message : String(d);
666
+ for (const h of f)
667
+ r.push(Je(h, p, n));
668
668
  }
669
669
  }
670
- return i.sort((o, c) => o.label.localeCompare(c.label));
670
+ return r.sort((i, a) => i.label.localeCompare(a.label));
671
671
  }
672
- function at(e, t, n, s) {
673
- const i = n.filter((u) => e.paths.includes(u.path)), o = e.kind.encode(t, i, s), c = new Map(n.map((u) => [u.path, u])), l = [];
674
- for (const u of o.files) {
675
- const r = c.get(u.path);
676
- r && r.text === u.text || l.push({ type: "write", path: u.path, text: u.text, baseVersion: r == null ? void 0 : r.version });
672
+ function St(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 });
677
677
  }
678
- for (const u of o.deleted ?? []) {
679
- const r = c.get(u);
680
- r && l.push({ type: "delete", path: u, baseVersion: r.version });
678
+ for (const f of i.deleted ?? []) {
679
+ const o = a.get(f);
680
+ o && l.push({ type: "delete", path: f, baseVersion: o.version });
681
681
  }
682
682
  return l;
683
683
  }
684
- function Je(e, t) {
684
+ function _e(e, t) {
685
685
  try {
686
- return JSON.parse(Ie(e));
686
+ return JSON.parse(Me(e));
687
687
  } catch {
688
688
  return t;
689
689
  }
690
690
  }
691
- const k = (e) => typeof e == "object" && e !== null && !Array.isArray(e), j = (...e) => (t) => {
691
+ const w = (e) => typeof e == "object" && e !== null && !Array.isArray(e), $ = (...e) => (t) => {
692
692
  const n = t.toLowerCase();
693
693
  return e.some((s) => n.endsWith(s.toLowerCase()));
694
694
  };
695
- function L(e) {
696
- return B({
695
+ function P(e) {
696
+ return M({
697
697
  id: e.id,
698
698
  label: e.label,
699
699
  labelKey: e.labelKey,
@@ -703,38 +703,38 @@ function L(e) {
703
703
  select: (t) => {
704
704
  if (Array.isArray(t))
705
705
  return t;
706
- const n = k(t) ? t[e.property] : void 0;
706
+ const n = w(t) ? t[e.property] : void 0;
707
707
  return Array.isArray(n) ? n : [];
708
708
  },
709
- assign: (t, n) => Array.isArray(t) ? n : k(t) && !(e.property in t) && n.length === 0 ? t : { ...k(t) ? t : {}, [e.property]: n },
709
+ assign: (t, n) => Array.isArray(t) ? n : w(t) && !(e.property in t) && n.length === 0 ? t : { ...w(t) ? t : {}, [e.property]: n },
710
710
  arrayKey: e.itemKey ? () => e.itemKey : void 0
711
711
  });
712
712
  }
713
- function fe(e) {
714
- const t = L(e);
713
+ function he(e) {
714
+ const t = P(e);
715
715
  return {
716
716
  ...t,
717
- decode: (n, s) => t.decode(n, s).map((i, o) => e.toItem(i, o)),
718
- encode: (n, s, i) => t.encode(
719
- n.map((o) => e.fromItem(o)),
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)),
720
720
  s,
721
- i
721
+ r
722
722
  )
723
723
  };
724
724
  }
725
- function ue(e) {
726
- return B({
725
+ function ye(e) {
726
+ return M({
727
727
  ...e,
728
- select: (t) => k(t) ? t : {},
728
+ select: (t) => w(t) ? t : {},
729
729
  assign: (t, n) => n
730
730
  });
731
731
  }
732
- const Le = /^(.*)\.([a-z]{2,3}(?:-[A-Za-z]{2,4})?)\.i18n\.json$/i, Te = (e) => {
733
- const t = Le.exec(e);
732
+ const Ue = /^(.*)\.([a-z]{2,3}(?:-[A-Za-z]{2,4})?)\.i18n\.json$/i, Re = (e) => {
733
+ const t = Ue.exec(e);
734
734
  return t ? { group: t[1], locale: t[2] } : null;
735
- }, V = (e) => k(e) && Object.values(e).every((t) => typeof t == "string");
736
- function Pe(e) {
737
- if (k(e)) {
735
+ }, V = (e) => w(e) && Object.values(e).every((t) => typeof t == "string");
736
+ function qe(e) {
737
+ if (w(e)) {
738
738
  for (const t of ["translations", "keys"])
739
739
  if (t in e) {
740
740
  if (V(e[t]))
@@ -746,11 +746,11 @@ function Pe(e) {
746
746
  }
747
747
  throw new Error("no translations in this file");
748
748
  }
749
- function Y(e, t) {
750
- return k(e) ? k(e.translations) ? { ...e, translations: t } : k(e.keys) ? { ...e, keys: t } : V(e) ? t : { ...e, translations: t } : { translations: t };
749
+ function Q(e, t) {
750
+ return w(e) ? w(e.translations) ? { ...e, translations: t } : w(e.keys) ? { ...e, keys: t } : V(e) ? t : { ...e, translations: t } : { translations: t };
751
751
  }
752
- function De(e = {}) {
753
- const t = e.parse ?? Te, n = e.pathFor ?? ((s, i) => `${s}.${i}.i18n.json`);
752
+ function ze(e = {}) {
753
+ const t = e.parse ?? Re, n = e.pathFor ?? ((s, r) => `${s}.${r}.i18n.json`);
754
754
  return {
755
755
  id: e.id ?? "i18n",
756
756
  label: e.label ?? "Translations",
@@ -759,74 +759,269 @@ function De(e = {}) {
759
759
  editor: "i18n",
760
760
  match: (s) => t(s) !== null,
761
761
  group: (s) => {
762
- var i;
763
- return ((i = t(s)) == null ? void 0 : i.group) ?? s;
762
+ var r;
763
+ return ((r = t(s)) == null ? void 0 : r.group) ?? s;
764
764
  },
765
765
  decode(s) {
766
- const i = {};
767
- for (const o of s) {
768
- const c = t(o.path);
769
- c && (i[c.locale] = { ...Pe(I(o.text).value) });
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) });
770
770
  }
771
- return i;
771
+ return r;
772
772
  },
773
- encode(s, i) {
774
- const o = /* @__PURE__ */ new Map();
775
- let c = "";
776
- for (const a of i) {
777
- const d = t(a.path);
778
- d && (o.set(d.locale, a), c = d.group);
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);
779
779
  }
780
- const l = o.get("en") ?? i[0], u = [];
781
- for (const [a, d] of Object.entries(s)) {
782
- const f = o.get(a);
783
- if (f) {
784
- const g = I(f.text).value;
785
- u.push({
786
- path: f.path,
787
- text: se(f.text, Y(g, d))
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: ae(p.text, Q(g, d))
788
788
  });
789
789
  continue;
790
790
  }
791
- const h = n(c || K((l == null ? void 0 : l.path) ?? "module"), a);
791
+ const h = n(a || K((l == null ? void 0 : l.path) ?? "module"), c);
792
792
  if (l) {
793
- const g = I(l.text).value, p = k(g) && "locale" in g ? { ...g, locale: a } : g;
794
- u.push({
793
+ const g = x(l.text).value, u = w(g) && "locale" in g ? { ...g, locale: c } : g;
794
+ f.push({
795
795
  path: h,
796
796
  text: v(
797
- Y(p, d),
798
- z(l.text)
797
+ Q(u, d),
798
+ X(l.text)
799
799
  )
800
800
  });
801
801
  } else
802
- u.push({ path: h, text: v({ locale: a, translations: d }) });
802
+ f.push({ path: h, text: v({ locale: c, translations: d }) });
803
803
  }
804
- const r = [...o.entries()].filter(([a]) => !(a in s)).map(([, a]) => a.path);
805
- return { files: u, deleted: r };
804
+ const o = [...i.entries()].filter(([c]) => !(c in s)).map(([, c]) => c.path);
805
+ return { files: f, deleted: o };
806
806
  }
807
807
  };
808
808
  }
809
- const N = (e) => JSON.parse(JSON.stringify(e));
810
- function ct(e) {
809
+ const S = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Ve = [
810
+ "frontend",
811
+ "backend",
812
+ "noCode",
813
+ "sql"
814
+ ], $t = [
815
+ "preInstall",
816
+ "postInstall",
817
+ "preUninstall",
818
+ "postUninstall"
819
+ ];
820
+ function We(e) {
821
+ switch (e) {
822
+ case "frontend":
823
+ return ["typescript", "javascript"];
824
+ case "backend":
825
+ return ["csharp", "javascript"];
826
+ case "sql":
827
+ return ["sql"];
828
+ case "noCode":
829
+ return [];
830
+ }
831
+ }
832
+ const Be = /* @__PURE__ */ new Set([
833
+ "read",
834
+ "filter",
835
+ "map",
836
+ "aggregate",
837
+ "set",
838
+ "if",
839
+ "forEach",
840
+ "write",
841
+ "callScript",
842
+ "return"
843
+ ]), ge = (e) => Array.isArray(e) && e.every((t) => S(t) && typeof t.id == "string" && Be.has(String(t.type)));
844
+ function W(e) {
845
+ if (Ve.includes(e.kind))
846
+ return e.kind;
847
+ if (e.source === void 0 && ge(e.steps))
848
+ return "noCode";
849
+ const t = typeof e.language == "string" ? e.language.toLowerCase() : "";
850
+ return t.endsWith("sql") || e.source === void 0 && typeof e.sql == "string" ? "sql" : /^(csharp|c#|cs\b)/.test(t) ? "backend" : "frontend";
851
+ }
852
+ const be = [
853
+ "id",
854
+ "displayName",
855
+ "description",
856
+ "language",
857
+ "category",
858
+ "trigger",
859
+ "returnType",
860
+ "source",
861
+ "sourcePath"
862
+ ], Xe = (e) => Array.isArray(e) && e.every((t) => S(t) && typeof t.name == "string");
863
+ function Ze(e, t) {
864
+ const n = `#${t + 1}`;
865
+ if (!S(e) || typeof e.name != "string" || !e.name) {
866
+ const l = S(e) && typeof e.displayName == "string" ? e.displayName : n;
867
+ return { key: `#${t}`, label: l, rawReason: "no name", source: e };
868
+ }
869
+ const s = e.name, r = typeof e.displayName == "string" && e.displayName ? e.displayName : s, i = (l) => ({
870
+ key: s,
871
+ label: r,
872
+ rawReason: l,
873
+ source: e
874
+ }), a = { name: s, kind: W(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;
881
+ }
882
+ }
883
+ 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;
887
+ }
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 ?? [];
892
+ }
893
+ return { key: s, label: r, definition: a, source: e };
894
+ }
895
+ function Ge(e) {
896
+ const t = e.definition;
897
+ if (!t)
898
+ return e.source;
899
+ const n = S(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 ?? [] : W(n) === "noCode" && delete s.steps, delete s.kind, ("kind" in n || W(s) !== t.kind) && (s.kind = t.kind), s;
903
+ }
904
+ function D(e) {
905
+ const t = /* @__PURE__ */ new Set();
906
+ 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;
909
+ });
910
+ }
911
+ function ee(e, t) {
912
+ if (!S(e) || !Object.values(e).every((n) => Array.isArray(n) && n.every((s) => typeof s == "string")))
913
+ throw new Error(`"${t}" is not lists of SQL statements per phase`);
914
+ return e;
915
+ }
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({
919
+ id: e.id ?? "scripts",
920
+ label: e.label ?? "Scripts",
921
+ labelKey: e.labelKey ?? "devStudio.kind.scripts",
922
+ icon: e.icon ?? "code",
923
+ editor: "scriptList",
924
+ match: e.match,
925
+ select: (i) => {
926
+ if (Array.isArray(i))
927
+ return { scripts: D(i), ...s ? { holds: "scripts" } : {} };
928
+ if (!S(i) || i[t] === void 0 && i[n] === void 0)
929
+ throw new Error(`no "${t}" in this file`);
930
+ const a = i[t];
931
+ if (s)
932
+ return Array.isArray(a) ? { scripts: D(a), holds: "scripts" } : { scripts: [], phases: ee(a, t), holds: "phases" };
933
+ if (a !== void 0 && !Array.isArray(a))
934
+ throw new Error(`"${t}" is not a list`);
935
+ const l = i[n];
936
+ return {
937
+ scripts: D(a ?? []),
938
+ ...l !== void 0 ? { phases: ee(l, n) } : {}
939
+ };
940
+ },
941
+ assign: (i, a) => {
942
+ if (a.holds === "phases" && a.scripts.length > 0)
943
+ 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 = S(i) ? i : {};
947
+ if (s)
948
+ return {
949
+ ...l,
950
+ [t]: a.holds === "phases" ? a.phases ?? {} : r(a)
951
+ };
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;
954
+ },
955
+ arrayKey: (i) => i === `/${t}` ? "name" : void 0
956
+ });
957
+ }
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("");
960
+ return /^[A-Za-z_]/.test(n) ? n : `script${n}`;
961
+ }
962
+ function jt(e) {
963
+ const t = Ye(e.name), n = e.language ?? We(e.kind)[0], s = {
964
+ name: t,
965
+ kind: e.kind,
966
+ ...e.name !== t ? { displayName: e.name } : {},
967
+ ...n ? { language: n } : {},
968
+ ...e.category ? { category: e.category } : {},
969
+ ...e.trigger ? { trigger: e.trigger } : {},
970
+ parameters: []
971
+ }, r = t[0].toUpperCase() + t.slice(1);
972
+ switch (e.kind) {
973
+ case "noCode":
974
+ return { ...s, steps: [] };
975
+ case "sql":
976
+ return { ...s, source: `-- ${e.name}
977
+ SELECT 1;
978
+ ` };
979
+ case "backend":
980
+ return {
981
+ ...s,
982
+ returnType: "object",
983
+ source: n === "csharp" ? `public static object ${r}(IDictionary<string, object> args)
984
+ {
985
+ return null;
986
+ }
987
+ ` : `function ${t}(args) {
988
+ return null;
989
+ }
990
+ `
991
+ };
992
+ case "frontend":
993
+ return {
994
+ ...s,
995
+ returnType: "void",
996
+ source: n === "typescript" ? `export function ${t}(): void {
997
+ }
998
+ ` : `export function ${t}() {
999
+ }
1000
+ `
1001
+ };
1002
+ }
1003
+ }
1004
+ const I = (e) => JSON.parse(JSON.stringify(e));
1005
+ function Ot(e) {
811
1006
  const t = e.revisions !== !1;
812
1007
  let n = 0;
813
- const s = e.workspaces.map((r) => ({
1008
+ const s = e.workspaces.map((o) => ({
814
1009
  meta: {
815
- id: r.id,
816
- label: r.label,
817
- description: r.description,
818
- icon: r.icon,
819
- readOnly: r.readOnly
1010
+ id: o.id,
1011
+ label: o.label,
1012
+ description: o.description,
1013
+ icon: o.icon,
1014
+ readOnly: o.readOnly
820
1015
  },
821
- packages: new Map((r.packages ?? []).map((a) => [a.id, { ...a, workspaceId: r.id }])),
1016
+ packages: new Map((o.packages ?? []).map((c) => [c.id, { ...c, workspaceId: o.id }])),
822
1017
  modules: new Map(
823
- r.modules.map((a) => [
824
- a.id,
1018
+ o.modules.map((c) => [
1019
+ c.id,
825
1020
  {
826
- ...a,
1021
+ ...c,
827
1022
  files: new Map(
828
- Object.entries(a.files).map(
829
- ([d, f]) => [d, { text: f, version: ++n }]
1023
+ Object.entries(c.files).map(
1024
+ ([d, p]) => [d, { text: p, version: ++n }]
830
1025
  )
831
1026
  ),
832
1027
  revisions: []
@@ -834,166 +1029,166 @@ function ct(e) {
834
1029
  ])
835
1030
  )
836
1031
  }));
837
- let i = (e.templates ?? []).map((r) => N(r));
838
- const o = (r) => {
839
- const a = s.find((d) => d.meta.id === r);
840
- if (!a)
841
- throw new Error(`Unknown workspace "${r}"`);
842
- return a;
843
- }, c = (r) => {
844
- const a = o(r.workspaceId).modules.get(r.id);
845
- if (!a)
846
- throw new Error(`Unknown module "${r.id}"`);
847
- return a;
848
- }, l = (r, a) => ({
849
- workspaceId: r,
850
- id: a.id,
851
- packageId: a.packageId,
852
- label: a.label ?? a.id,
853
- description: a.description,
854
- icon: a.icon,
855
- version: a.version,
856
- readOnly: a.readOnly || o(r).meta.readOnly,
857
- files: [...a.files.keys()].sort()
858
- }), u = (r, a) => ({
859
- path: r,
860
- text: a.text,
861
- version: String(a.version)
1032
+ let r = (e.templates ?? []).map((o) => I(o));
1033
+ const i = (o) => {
1034
+ const c = s.find((d) => d.meta.id === o);
1035
+ if (!c)
1036
+ throw new Error(`Unknown workspace "${o}"`);
1037
+ return c;
1038
+ }, a = (o) => {
1039
+ const c = i(o.workspaceId).modules.get(o.id);
1040
+ if (!c)
1041
+ throw new Error(`Unknown module "${o.id}"`);
1042
+ return c;
1043
+ }, l = (o, c) => ({
1044
+ workspaceId: o,
1045
+ id: c.id,
1046
+ packageId: c.packageId,
1047
+ label: c.label ?? c.id,
1048
+ description: c.description,
1049
+ icon: c.icon,
1050
+ version: c.version,
1051
+ readOnly: c.readOnly || i(o).meta.readOnly,
1052
+ files: [...c.files.keys()].sort()
1053
+ }), f = (o, c) => ({
1054
+ path: o,
1055
+ text: c.text,
1056
+ version: String(c.version)
862
1057
  });
863
1058
  return {
864
1059
  async listWorkspaces() {
865
- return s.map((r) => ({ ...r.meta }));
1060
+ return s.map((o) => ({ ...o.meta }));
866
1061
  },
867
- async listModules(r) {
868
- return [...o(r).modules.values()].map((d) => l(r, d));
1062
+ async listModules(o) {
1063
+ return [...i(o).modules.values()].map((d) => l(o, d));
869
1064
  },
870
- async listPackages(r) {
871
- const a = o(r), d = [...a.packages.values()], f = [...new Set([...a.modules.values()].map((h) => h.packageId).filter(Boolean))].filter((h) => !a.packages.has(h)).map((h) => ({ id: h, workspaceId: r, label: h, derived: !0 }));
872
- return [...d, ...f];
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];
873
1068
  },
874
- async readModule(r) {
875
- return [...c(r).files.entries()].map(([d, f]) => u(d, f));
1069
+ async readModule(o) {
1070
+ return [...a(o).files.entries()].map(([d, p]) => f(d, p));
876
1071
  },
877
- async writeModule(r, a) {
878
- const d = c(r);
879
- if (d.readOnly || o(r.workspaceId).meta.readOnly)
880
- throw new Error(`Module "${r.id}" is read-only`);
881
- const f = a.filter((p) => p.baseVersion !== void 0).filter((p) => {
882
- const m = d.files.get(p.path);
883
- return m ? String(m.version) !== p.baseVersion : !1;
884
- }).map((p) => {
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) => {
885
1080
  var m;
886
- return { path: p.path, currentVersion: String((m = d.files.get(p.path)) == null ? void 0 : m.version) };
1081
+ return { path: u.path, currentVersion: String((m = d.files.get(u.path)) == null ? void 0 : m.version) };
887
1082
  });
888
- if (f.length > 0)
889
- return { ok: !1, conflicts: f };
1083
+ if (p.length > 0)
1084
+ return { ok: !1, conflicts: p };
890
1085
  let h;
891
1086
  if (t) {
892
- const p = {};
893
- for (const [m, w] of d.files)
894
- p[m] = w.text;
1087
+ const u = {};
1088
+ for (const [m, k] of d.files)
1089
+ u[m] = k.text;
895
1090
  h = `r${++n}`, d.revisions.unshift({
896
1091
  id: h,
897
1092
  timestamp: Date.now(),
898
1093
  label: h,
899
- summary: a.map((m) => `${m.type} ${m.path}`).join(", "),
900
- files: p
1094
+ summary: c.map((m) => `${m.type} ${m.path}`).join(", "),
1095
+ files: u
901
1096
  });
902
1097
  }
903
1098
  const g = {};
904
- for (const p of a)
905
- if (p.type === "delete")
906
- d.files.delete(p.path);
1099
+ for (const u of c)
1100
+ if (u.type === "delete")
1101
+ d.files.delete(u.path);
907
1102
  else {
908
1103
  const m = ++n;
909
- d.files.set(p.path, { text: p.text, version: m }), g[p.path] = String(m);
1104
+ d.files.set(u.path, { text: u.text, version: m }), g[u.path] = String(m);
910
1105
  }
911
1106
  return { ok: !0, versions: g, revision: h };
912
1107
  },
913
- async createModule(r) {
914
- const a = o(r.workspaceId);
915
- if (a.meta.readOnly)
916
- throw new Error(`Workspace "${r.workspaceId}" is read-only`);
917
- if (a.modules.has(r.id))
918
- throw new Error(`Module "${r.id}" already exists`);
1108
+ async createModule(o) {
1109
+ const c = i(o.workspaceId);
1110
+ 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`);
919
1114
  const d = {
920
- id: r.id,
921
- packageId: r.packageId,
1115
+ id: o.id,
1116
+ packageId: o.packageId,
922
1117
  files: new Map(
923
- r.files.map((f) => [f.path, { text: f.text, version: ++n }])
1118
+ o.files.map((p) => [p.path, { text: p.text, version: ++n }])
924
1119
  ),
925
1120
  revisions: []
926
1121
  };
927
- return a.modules.set(r.id, d), l(r.workspaceId, d);
1122
+ return c.modules.set(o.id, d), l(o.workspaceId, d);
928
1123
  },
929
- async deleteModule(r) {
930
- const a = o(r.workspaceId);
931
- if (a.meta.readOnly)
932
- throw new Error(`Workspace "${r.workspaceId}" is read-only`);
933
- a.modules.delete(r.id);
1124
+ async deleteModule(o) {
1125
+ const c = i(o.workspaceId);
1126
+ if (c.meta.readOnly)
1127
+ throw new Error(`Workspace "${o.workspaceId}" is read-only`);
1128
+ c.modules.delete(o.id);
934
1129
  },
935
- async savePackage(r) {
936
- return o(r.workspaceId).packages.set(r.id, { ...r, derived: !1 }), { ...r, derived: !1 };
1130
+ async savePackage(o) {
1131
+ return i(o.workspaceId).packages.set(o.id, { ...o, derived: !1 }), { ...o, derived: !1 };
937
1132
  },
938
- async deletePackage(r) {
939
- o(r.workspaceId).packages.delete(r.id);
1133
+ async deletePackage(o) {
1134
+ i(o.workspaceId).packages.delete(o.id);
940
1135
  },
941
1136
  async listTemplates() {
942
- return i.map((r) => N(r));
1137
+ return r.map((o) => I(o));
943
1138
  },
944
- async saveTemplate(r, a) {
945
- const d = (a == null ? void 0 : a.previousId) ?? r.id, f = N(r), h = i.findIndex((g) => g.id === d);
946
- return i = h >= 0 ? i.map((g, p) => p === h ? f : g) : [...i, f], N(f);
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);
947
1142
  },
948
- async deleteTemplate(r) {
949
- i = i.filter((a) => a.id !== r);
1143
+ async deleteTemplate(o) {
1144
+ r = r.filter((c) => c.id !== o);
950
1145
  },
951
- async listRevisions(r, a) {
952
- return c(r).revisions.filter((d) => !a || a in d.files).map(({ files: d, ...f }) => ({ ...f, ...a ? { path: a } : {} }));
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 } : {} }));
953
1148
  },
954
- async readRevision(r, a, d) {
955
- const f = c(r).revisions.find((h) => h.id === a);
956
- if (!f)
957
- throw new Error(`Unknown revision "${a}"`);
958
- return d ? f.files[d] ?? "" : JSON.stringify(f.files, null, 2);
1149
+ async readRevision(o, c, d) {
1150
+ const p = a(o).revisions.find((h) => h.id === c);
1151
+ if (!p)
1152
+ throw new Error(`Unknown revision "${c}"`);
1153
+ return d ? p.files[d] ?? "" : JSON.stringify(p.files, null, 2);
959
1154
  },
960
- async rollback(r, a, d) {
961
- const f = c(r), h = f.revisions.find((p) => p.id === a);
1155
+ async rollback(o, c, d) {
1156
+ const p = a(o), h = p.revisions.find((u) => u.id === c);
962
1157
  if (!h)
963
- throw new Error(`Unknown revision "${a}"`);
1158
+ throw new Error(`Unknown revision "${c}"`);
964
1159
  const g = d ? { [d]: h.files[d] } : h.files;
965
1160
  if (!d)
966
- for (const p of [...f.files.keys()])
967
- p in g || f.files.delete(p);
968
- for (const [p, m] of Object.entries(g))
969
- m !== void 0 && f.files.set(p, { text: m, version: ++n });
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 });
970
1165
  },
971
1166
  snapshot() {
972
1167
  return {
973
- workspaces: s.map((r) => ({
974
- ...r.meta,
975
- packages: [...r.packages.values()].map(({ workspaceId: a, ...d }) => d),
976
- modules: [...r.modules.values()].map((a) => ({
977
- id: a.id,
978
- packageId: a.packageId,
979
- label: a.label,
980
- description: a.description,
981
- icon: a.icon,
982
- version: a.version,
983
- readOnly: a.readOnly,
984
- files: Object.fromEntries([...a.files.entries()].map(([d, f]) => [d, f.text]))
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) => ({
1172
+ id: c.id,
1173
+ packageId: c.packageId,
1174
+ label: c.label,
1175
+ description: c.description,
1176
+ icon: c.icon,
1177
+ version: c.version,
1178
+ readOnly: c.readOnly,
1179
+ files: Object.fromEntries([...c.files.entries()].map(([d, p]) => [d, p.text]))
985
1180
  }))
986
1181
  })),
987
- templates: i.map((r) => N(r)),
1182
+ templates: r.map((o) => I(o)),
988
1183
  revisions: t
989
1184
  };
990
1185
  }
991
1186
  };
992
1187
  }
993
- function lt(e) {
1188
+ function At(e) {
994
1189
  return e;
995
1190
  }
996
- function _(e, t) {
1191
+ function B(e, t) {
997
1192
  if (!t || e === void 0 || e === null)
998
1193
  return !0;
999
1194
  if (t.enum && !t.enum.includes(e))
@@ -1008,49 +1203,49 @@ function _(e, t) {
1008
1203
  case "boolean":
1009
1204
  return typeof e == "boolean";
1010
1205
  case "array":
1011
- return Array.isArray(e) && (!t.items || e.every((n) => _(n, t.items)));
1206
+ return Array.isArray(e) && (!t.items || e.every((n) => B(n, t.items)));
1012
1207
  case "object": {
1013
1208
  if (typeof e != "object" || Array.isArray(e))
1014
1209
  return !1;
1015
1210
  const n = t.properties;
1016
- return !n || Object.entries(e).every(([s, i]) => s in n && _(i, n[s]));
1211
+ return !n || Object.entries(e).every(([s, r]) => s in n && B(r, n[s]));
1017
1212
  }
1018
1213
  default:
1019
1214
  return !0;
1020
1215
  }
1021
1216
  }
1022
- function dt(e, t) {
1023
- var c;
1024
- const n = (e.fields ?? []).map((l) => l.name), s = (c = e.schema) == null ? void 0 : c.properties;
1217
+ function Et(e, t) {
1218
+ var a;
1219
+ const n = (e.fields ?? []).map((l) => l.name), s = (a = e.schema) == null ? void 0 : a.properties;
1025
1220
  if (!e.schema || !s)
1026
1221
  return { section: e, keys: n };
1027
- const i = Object.entries(s).filter(
1028
- ([l, u]) => !(l in t) || _(t[l], u)
1029
- ), o = i.map(([l]) => l);
1222
+ const r = Object.entries(s).filter(
1223
+ ([l, f]) => !(l in t) || B(t[l], f)
1224
+ ), i = r.map(([l]) => l);
1030
1225
  return {
1031
1226
  section: {
1032
1227
  ...e,
1033
1228
  schema: {
1034
1229
  ...e.schema,
1035
- properties: Object.fromEntries(i),
1036
- ...e.schema.required ? { required: e.schema.required.filter((l) => o.includes(l)) } : {}
1230
+ properties: Object.fromEntries(r),
1231
+ ...e.schema.required ? { required: e.schema.required.filter((l) => i.includes(l)) } : {}
1037
1232
  }
1038
1233
  },
1039
- keys: [...o, ...n]
1234
+ keys: [...i, ...n]
1040
1235
  };
1041
1236
  }
1042
- function ft(e) {
1237
+ function Kt(e) {
1043
1238
  var n;
1044
1239
  const t = /* @__PURE__ */ new Set();
1045
1240
  for (const s of e) {
1046
- for (const i of Object.keys(((n = s.schema) == null ? void 0 : n.properties) ?? {}))
1047
- t.add(i);
1048
- for (const i of s.fields ?? [])
1049
- t.add(i.name);
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);
1050
1245
  }
1051
1246
  return t;
1052
1247
  }
1053
- function ut(e) {
1248
+ function Nt(e) {
1054
1249
  return e.map((t) => {
1055
1250
  const n = t;
1056
1251
  return {
@@ -1065,14 +1260,14 @@ function ut(e) {
1065
1260
  };
1066
1261
  });
1067
1262
  }
1068
- function pt(e) {
1069
- const t = e.manifest ?? {}, n = String(t.displayName || t.packageName || "Module"), s = (e.views ?? []).map((o) => ({
1070
- id: `view:${o.id}`,
1071
- label: o.name,
1263
+ function It(e) {
1264
+ const t = e.manifest ?? {}, n = String(t.displayName || t.packageName || "Module"), s = (e.views ?? []).map((i) => ({
1265
+ id: `view:${i.id}`,
1266
+ label: i.name,
1072
1267
  type: "view"
1073
- })), i = (e.entities ?? []).map((o) => {
1074
- const c = String(o.name ?? "Entity");
1075
- return { id: `entity:${c}`, label: c, type: "entity" };
1268
+ })), r = (e.entities ?? []).map((i) => {
1269
+ const a = String(i.name ?? "Entity");
1270
+ return { id: `entity:${a}`, label: a, type: "entity" };
1076
1271
  });
1077
1272
  return {
1078
1273
  roles: [
@@ -1092,31 +1287,31 @@ function pt(e) {
1092
1287
  type: "module",
1093
1288
  children: [
1094
1289
  ...s.length ? [{ id: "views", label: "Views", type: "group", children: s }] : [],
1095
- ...i.length ? [{ id: "entities", label: "Entities", type: "group", children: i }] : []
1290
+ ...r.length ? [{ id: "entities", label: "Entities", type: "group", children: r }] : []
1096
1291
  ]
1097
1292
  }
1098
1293
  ],
1099
1294
  grants: {}
1100
1295
  };
1101
1296
  }
1102
- const X = ue({
1297
+ const H = ye({
1103
1298
  id: "manifest",
1104
1299
  label: "Manifest",
1105
1300
  labelKey: "devStudio.kind.manifest",
1106
1301
  icon: "file",
1107
1302
  editor: "manifest",
1108
- match: j(".manifest.json")
1109
- }), Ce = L({
1303
+ match: $(".manifest.json")
1304
+ }), Qe = P({
1110
1305
  id: "entities",
1111
1306
  label: "Entities",
1112
1307
  labelKey: "devStudio.kind.entities",
1113
1308
  icon: "database",
1114
1309
  editor: "entities",
1115
- match: j(".entities.json"),
1310
+ match: $(".entities.json"),
1116
1311
  property: "entities",
1117
1312
  itemKey: "name"
1118
- }), Re = De();
1119
- function pe(e, t) {
1313
+ }), et = ze();
1314
+ function ke(e, t) {
1120
1315
  const n = e, s = typeof e == "object" && e !== null && typeof n.id == "string";
1121
1316
  return {
1122
1317
  key: s ? n.id : `#${t}`,
@@ -1125,85 +1320,88 @@ function pe(e, t) {
1125
1320
  source: e
1126
1321
  };
1127
1322
  }
1128
- const Ue = fe({
1323
+ const tt = he({
1129
1324
  id: "views",
1130
1325
  label: "Views",
1131
1326
  labelKey: "devStudio.kind.views",
1132
1327
  icon: "grid",
1133
1328
  editor: "views",
1134
- match: j(".views.json"),
1329
+ match: $(".views.json"),
1135
1330
  property: "views",
1136
1331
  itemKey: "id",
1137
- toItem: (e, t) => pe(e, t),
1332
+ toItem: (e, t) => ke(e, t),
1138
1333
  fromItem: (e) => e.definition ?? e.source
1139
- }), Ve = fe({
1334
+ }), nt = he({
1140
1335
  id: "workflows",
1141
1336
  label: "Workflows",
1142
1337
  labelKey: "devStudio.kind.workflows",
1143
1338
  icon: "git-branch",
1144
1339
  editor: "workflows",
1145
- match: j(".workflows.json"),
1340
+ match: $(".workflows.json"),
1146
1341
  property: "workflows",
1147
1342
  itemKey: "id",
1148
- toItem: (e, t) => pe(e, t),
1343
+ toItem: (e, t) => ke(e, t),
1149
1344
  fromItem: (e) => e.definition ?? e.source
1150
- }), _e = L({
1345
+ }), st = P({
1151
1346
  id: "dataSources",
1152
1347
  label: "Data sources",
1153
1348
  labelKey: "devStudio.kind.dataSources",
1154
1349
  icon: "database",
1155
1350
  editor: "dataSources",
1156
- match: j(".datasources.json"),
1351
+ match: $(".datasources.json"),
1157
1352
  property: "dataSources",
1158
1353
  itemKey: "key"
1159
- }), ze = ue({
1354
+ }), rt = ye({
1160
1355
  id: "rbac",
1161
1356
  label: "Access",
1162
1357
  labelKey: "devStudio.kind.rbac",
1163
1358
  icon: "shield",
1164
1359
  editor: "rbac",
1165
- match: j(".rbac.json")
1166
- }), We = L({
1360
+ match: $(".rbac.json")
1361
+ }), it = P({
1167
1362
  id: "hooks",
1168
1363
  label: "Lifecycle hooks",
1169
1364
  labelKey: "devStudio.kind.hooks",
1170
1365
  icon: "zap",
1171
1366
  editor: "hooks",
1172
- match: j(".hooks.json"),
1367
+ match: $(".hooks.json"),
1173
1368
  property: "bindings",
1174
1369
  itemKey: "id"
1175
- }), qe = [
1176
- X,
1177
- Ce,
1178
- Re,
1179
- Ue,
1180
- Ve,
1181
- _e,
1182
- ze,
1183
- We
1370
+ }), ot = He({
1371
+ match: $(".scripts.json")
1372
+ }), at = [
1373
+ H,
1374
+ Qe,
1375
+ et,
1376
+ tt,
1377
+ nt,
1378
+ st,
1379
+ rt,
1380
+ it,
1381
+ ot
1184
1382
  ];
1185
- function H(e) {
1383
+ function te(e) {
1186
1384
  return e.normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/ł/g, "l").replace(/Ł/g, "L").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "module";
1187
1385
  }
1188
- const Z = (e) => {
1189
- const t = e.find((n) => X.match(n.path));
1190
- return t ? Je(t.text, void 0) : void 0;
1386
+ const ne = (e) => {
1387
+ const t = e.find((n) => H.match(n.path));
1388
+ return t ? _e(t.text, void 0) : void 0;
1191
1389
  };
1192
- function Be(e) {
1193
- const t = e.find((n) => X.match(n.path));
1390
+ function ct(e) {
1391
+ const t = e.find((n) => H.match(n.path));
1194
1392
  return t ? K(t.path).replace(/\.manifest\.json$/i, "") : "module";
1195
1393
  }
1196
- const Q = (e) => Array.isArray(e.fields) ? e.fields : [], mt = {
1394
+ const se = (e) => Array.isArray(e.fields) ? e.fields : [], xt = {
1197
1395
  id: "native",
1198
- kinds: qe,
1396
+ kinds: at,
1199
1397
  locales: ["en", "pl", "de", "fr", "es", "uk"],
1200
1398
  requiredLocales: ["en"],
1201
1399
  moduleId: (e) => {
1202
- const t = Z(e), n = (t == null ? void 0 : t.id) ?? (t == null ? void 0 : t.packageName);
1400
+ const t = ne(e), n = (t == null ? void 0 : t.id) ?? (t == null ? void 0 : t.packageName);
1203
1401
  return typeof n == "string" ? n : void 0;
1204
1402
  },
1205
1403
  validateModule: ({ files: e }) => {
1206
- const t = Z(e);
1404
+ const t = ne(e);
1207
1405
  return t ? ["id", "name", "version"].filter((n) => typeof t[n] != "string" || !t[n]).map((n) => ({
1208
1406
  severity: "error",
1209
1407
  code: "manifest.required",
@@ -1221,20 +1419,21 @@ const Q = (e) => Array.isArray(e.fields) ? e.fields : [], mt = {
1221
1419
  ];
1222
1420
  },
1223
1421
  newFile: (e, { files: t }) => {
1224
- const n = Be(t), i = {
1422
+ const n = ct(t), r = {
1225
1423
  entities: ["entities.json", { entities: [] }],
1226
1424
  views: ["views.json", { views: [] }],
1227
1425
  workflows: ["workflows.json", { workflows: [] }],
1228
1426
  dataSources: ["datasources.json", { dataSources: [] }],
1229
1427
  rbac: ["rbac.json", { roles: [], actions: [], resources: [], grants: {} }],
1230
- hooks: ["hooks.json", { bindings: [] }]
1428
+ hooks: ["hooks.json", { bindings: [] }],
1429
+ scripts: ["scripts.json", { scripts: [] }]
1231
1430
  }[e];
1232
- return i ? { path: `${n}.${i[0]}`, text: v(i[1]) } : void 0;
1431
+ return r ? { path: `${n}.${r[0]}`, text: v(r[1]) } : void 0;
1233
1432
  },
1234
1433
  generateModule: async (e, { existingIds: t }) => {
1235
- let n = H(e.name);
1236
- for (let i = 2; t.has(n); i++)
1237
- n = `${H(e.name)}-${i}`;
1434
+ let n = te(e.name);
1435
+ for (let r = 2; t.has(n); r++)
1436
+ n = `${te(e.name)}-${r}`;
1238
1437
  const s = [
1239
1438
  {
1240
1439
  path: `${n}.manifest.json`,
@@ -1249,29 +1448,29 @@ const Q = (e) => Array.isArray(e.fields) ? e.fields : [], mt = {
1249
1448
  },
1250
1449
  { path: `${n}.entities.json`, text: v({ entities: e.entities }) }
1251
1450
  ];
1252
- for (const i of e.locales) {
1253
- const o = { "module.displayName": e.name };
1254
- for (const c of e.entities) {
1255
- const l = String(c.name ?? "");
1256
- o[`entity.${l}.displayName`] = l;
1257
- for (const u of Q(c))
1258
- o[`field.${l}.${String(u.name)}.label`] = String(u.name);
1451
+ for (const r of e.locales) {
1452
+ const i = { "module.displayName": e.name };
1453
+ for (const a of e.entities) {
1454
+ const l = String(a.name ?? "");
1455
+ i[`entity.${l}.displayName`] = l;
1456
+ for (const f of se(a))
1457
+ i[`field.${l}.${String(f.name)}.label`] = String(f.name);
1259
1458
  }
1260
1459
  s.push({
1261
- path: `${n}.${i}.i18n.json`,
1262
- text: v({ locale: i, translations: o })
1460
+ path: `${n}.${r}.i18n.json`,
1461
+ text: v({ locale: r, translations: i })
1263
1462
  });
1264
1463
  }
1265
1464
  if (e.views) {
1266
- const i = e.entities.map((o) => {
1267
- const c = String(o.name ?? "Item");
1465
+ const r = e.entities.map((i) => {
1466
+ const a = String(i.name ?? "Item");
1268
1467
  return {
1269
- id: `${c}List`,
1270
- name: `${c} list`,
1468
+ id: `${a}List`,
1469
+ name: `${a} list`,
1271
1470
  kind: "grid",
1272
1471
  version: 2,
1273
1472
  columns: 12,
1274
- dataSources: [{ key: "rows", type: "entity", entity: c, autoLoad: !0 }],
1473
+ dataSources: [{ key: "rows", type: "entity", entity: a, autoLoad: !0 }],
1275
1474
  rows: [
1276
1475
  {
1277
1476
  id: "r1",
@@ -1281,7 +1480,7 @@ const Q = (e) => Array.isArray(e.fields) ? e.fields : [], mt = {
1281
1480
  controlType: "dataGrid",
1282
1481
  colSpan: 12,
1283
1482
  props: {
1284
- columns: Q(o).map((l) => ({
1483
+ columns: se(i).map((l) => ({
1285
1484
  field: String(l.name),
1286
1485
  header: String(l.name)
1287
1486
  }))
@@ -1293,10 +1492,10 @@ const Q = (e) => Array.isArray(e.fields) ? e.fields : [], mt = {
1293
1492
  ]
1294
1493
  };
1295
1494
  });
1296
- s.push({ path: `${n}.views.json`, text: v({ views: i }) });
1495
+ s.push({ path: `${n}.views.json`, text: v({ views: r }) });
1297
1496
  }
1298
1497
  if (e.permissions) {
1299
- const i = {
1498
+ const r = {
1300
1499
  roles: [
1301
1500
  { id: "viewer", label: "Viewer" },
1302
1501
  { id: "editor", label: "Editor" },
@@ -1307,71 +1506,81 @@ const Q = (e) => Array.isArray(e.fields) ? e.fields : [], mt = {
1307
1506
  { id: "edit", label: "Edit" },
1308
1507
  { id: "delete", label: "Delete" }
1309
1508
  ],
1310
- resources: e.entities.map((o) => ({
1311
- id: `entity:${String(o.name)}`,
1312
- label: String(o.name),
1509
+ resources: e.entities.map((i) => ({
1510
+ id: `entity:${String(i.name)}`,
1511
+ label: String(i.name),
1313
1512
  type: "entity"
1314
1513
  })),
1315
1514
  grants: {}
1316
1515
  };
1317
- s.push({ path: `${n}.rbac.json`, text: v(i) });
1516
+ s.push({ path: `${n}.rbac.json`, text: v(r) });
1318
1517
  }
1319
1518
  return { id: n, packageId: e.packageId, files: s };
1320
1519
  }
1321
1520
  };
1322
1521
  export {
1323
- tt as addStudioFolder,
1324
- et as addStudioSection,
1325
- L as arrayFileKind,
1326
- ot as buildDocuments,
1327
- ct as createMemoryStudioProvider,
1328
- lt as defineManifestSection,
1329
- pt as deriveDefaultRbac,
1330
- z as detectJsonTextFormat,
1331
- T as emptyStudioLayout,
1332
- at as encodeDocument,
1333
- j as endsWithAny,
1334
- ut as entitiesToSchemas,
1522
+ Ve as NICE_STUDIO_SCRIPT_KINDS,
1523
+ $t as NICE_STUDIO_SCRIPT_PHASES,
1524
+ yt as addStudioFolder,
1525
+ ht as addStudioSection,
1526
+ P as arrayFileKind,
1527
+ vt as buildDocuments,
1528
+ Ot as createMemoryStudioProvider,
1529
+ At as defineManifestSection,
1530
+ It as deriveDefaultRbac,
1531
+ X as detectJsonTextFormat,
1532
+ J as emptyStudioLayout,
1533
+ St as encodeDocument,
1534
+ $ as endsWithAny,
1535
+ Nt as entitiesToSchemas,
1335
1536
  K as fileName,
1336
- dt as fitManifestSection,
1337
- De as i18nFileKind,
1338
- Ze as isEmptyStudioLayout,
1339
- ge as isStudioLayoutPath,
1340
- fe as itemsFileKind,
1341
- R as jsonFallbackKind,
1342
- B as jsonFileKind,
1343
- _ as jsonValueFitsSchema,
1344
- M as jsonValuesEqual,
1345
- we as keepTextFormat,
1346
- ft as manifestSectionKeys,
1347
- Be as modulePrefix,
1348
- _e as nativeDataSourcesKind,
1349
- Ce as nativeEntitiesKind,
1350
- qe as nativeFileKinds,
1351
- We as nativeHooksKind,
1352
- Re as nativeI18nKind,
1353
- X as nativeManifestKind,
1354
- ze as nativeRbacKind,
1355
- mt as nativeStudioPreset,
1356
- Ue as nativeViewsKind,
1357
- Ve as nativeWorkflowsKind,
1358
- ue as objectFileKind,
1359
- I as parseJsonText,
1360
- He as parseStudioLayout,
1361
- se as patchJsonText,
1362
- ke as patchJsonTextDetailed,
1363
- it as placeStudioEntry,
1364
- Pe as readTranslations,
1365
- st as removeStudioLayoutNode,
1366
- rt as renameStudioEntryRef,
1367
- nt as renameStudioLayoutNode,
1368
- xe as resolveFileKind,
1369
- Je as safeJson,
1370
- Qe as serializeStudioLayout,
1371
- H as slugifyModuleId,
1537
+ Et as fitManifestSection,
1538
+ Ge as fromStudioScriptItem,
1539
+ ze as i18nFileKind,
1540
+ W as inferStudioScriptKind,
1541
+ ut as isEmptyStudioLayout,
1542
+ $e as isStudioLayoutPath,
1543
+ he as itemsFileKind,
1544
+ q as jsonFallbackKind,
1545
+ M as jsonFileKind,
1546
+ B as jsonValueFitsSchema,
1547
+ C as jsonValuesEqual,
1548
+ Oe as keepTextFormat,
1549
+ Kt as manifestSectionKeys,
1550
+ ct as modulePrefix,
1551
+ st as nativeDataSourcesKind,
1552
+ Qe as nativeEntitiesKind,
1553
+ at as nativeFileKinds,
1554
+ it as nativeHooksKind,
1555
+ et as nativeI18nKind,
1556
+ H as nativeManifestKind,
1557
+ rt as nativeRbacKind,
1558
+ ot as nativeScriptsKind,
1559
+ xt as nativeStudioPreset,
1560
+ tt as nativeViewsKind,
1561
+ nt as nativeWorkflowsKind,
1562
+ jt as newStudioScript,
1563
+ ye as objectFileKind,
1564
+ x as parseJsonText,
1565
+ pt as parseStudioLayout,
1566
+ ae as patchJsonText,
1567
+ Ae as patchJsonTextDetailed,
1568
+ kt as placeStudioEntry,
1569
+ qe as readTranslations,
1570
+ bt as removeStudioLayoutNode,
1571
+ wt as renameStudioEntryRef,
1572
+ gt as renameStudioLayoutNode,
1573
+ Pe as resolveFileKind,
1574
+ _e as safeJson,
1575
+ He as scriptsFileKind,
1576
+ mt as serializeStudioLayout,
1577
+ te as slugifyModuleId,
1372
1578
  v as stringifyJsonText,
1373
- Ge as studioEntryRef,
1374
- Ye as studioLayoutPath,
1375
- U as textFallbackKind,
1376
- Y as writeTranslations
1579
+ dt as studioEntryRef,
1580
+ ft as studioLayoutPath,
1581
+ Ye as studioScriptIdentifier,
1582
+ We as studioScriptLanguages,
1583
+ z as textFallbackKind,
1584
+ Ze as toStudioScriptItem,
1585
+ Q as writeTranslations
1377
1586
  };