@airalogy/aimd-editor 1.13.1 → 1.14.1

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.
@@ -1,2277 +0,0 @@
1
- import { defineComponent as ie, computed as U, openBlock as h, createElementBlock as b, createElementVNode as i, createTextVNode as D, toDisplayString as v, Fragment as P, renderList as Y, unref as X, createCommentVNode as B, ref as C, watch as Z, createBlock as ue, Teleport as Ze, withModifiers as se, normalizeStyle as _e, normalizeClass as ae, withDirectives as A, vModelText as E, createVNode as te, vModelSelect as me, vModelRadio as ft, vModelCheckbox as ut, nextTick as Ee, inject as pt, h as Qe, onMounted as gt, onBeforeUnmount as ht, resolveDynamicComponent as Ge, withKeys as yt, shallowRef as je, vShow as et } from "vue";
2
- import { callCommand as bt, insert as Oe, replaceAll as Ve, getMarkdown as tt } from "@milkdown/kit/utils";
3
- import "@milkdown/theme-nord/style.css";
4
- import { j as rt, m as we, k as kt, h as lt, o as wt, i as Mt, l as _t, _ as Tt, n as Ct } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-8nbo78nG.js";
5
- import { u as Me, g as Xe, f as dt, i as Je, a as We, h as xt, c as $t, b as st, p as It } from "./lexer-Dj-IVtCT.js";
6
- import { a as ve, c as fe, A as ct, b as Ft, u as zt, d as At } from "./fields-DZsN-S-N.js";
7
- import { _ as Vt } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-m07PHAyw.js";
8
- import { protectAimdInlineTemplates as Et, restoreAimdInlineTemplates as St } from "@airalogy/aimd-core";
9
- import { parseAndExtract as Bt } from "@airalogy/aimd-renderer";
10
- import { insertTableCommand as Dt } from "@milkdown/kit/preset/gfm";
11
- var re = 1e6, it = 1e6, Te = "[big.js] ", Ce = Te + "Invalid ", Se = Ce + "decimal places", qt = Ce + "rounding mode", mt = Te + "Division by zero", S = {}, le = void 0;
12
- function de(e, n, t, o) {
13
- var a = e.c;
14
- if (t === le && (t = e.constructor.RM), t !== 0 && t !== 1 && t !== 2 && t !== 3)
15
- throw Error(qt);
16
- if (n < 1)
17
- o = t === 3 && (o || !!a[0]) || n === 0 && (t === 1 && a[0] >= 5 || t === 2 && (a[0] > 5 || a[0] === 5 && (o || a[1] !== le))), a.length = 1, o ? (e.e = e.e - n + 1, a[0] = 1) : a[0] = e.e = 0;
18
- else if (n < a.length) {
19
- if (o = t === 1 && a[n] >= 5 || t === 2 && (a[n] > 5 || a[n] === 5 && (o || a[n + 1] !== le || a[n - 1] & 1)) || t === 3 && (o || !!a[0]), a.length = n, o) {
20
- for (; ++a[--n] > 9; )
21
- if (a[n] = 0, n === 0) {
22
- ++e.e, a.unshift(1);
23
- break;
24
- }
25
- }
26
- for (n = a.length; !a[--n]; ) a.pop();
27
- }
28
- return e;
29
- }
30
- function ce(e, n, t) {
31
- var o = e.e, a = e.c.join(""), d = a.length;
32
- if (n)
33
- a = a.charAt(0) + (d > 1 ? "." + a.slice(1) : "") + (o < 0 ? "e" : "e+") + o;
34
- else if (o < 0) {
35
- for (; ++o; ) a = "0" + a;
36
- a = "0." + a;
37
- } else if (o > 0)
38
- if (++o > d)
39
- for (o -= d; o--; ) a += "0";
40
- else o < d && (a = a.slice(0, o) + "." + a.slice(o));
41
- else d > 1 && (a = a.charAt(0) + "." + a.slice(1));
42
- return e.s < 0 && t ? "-" + a : a;
43
- }
44
- S.abs = function() {
45
- var e = new this.constructor(this);
46
- return e.s = 1, e;
47
- };
48
- S.cmp = function(e) {
49
- var n, t = this, o = t.c, a = (e = new t.constructor(e)).c, d = t.s, f = e.s, u = t.e, l = e.e;
50
- if (!o[0] || !a[0]) return o[0] ? d : a[0] ? -f : 0;
51
- if (d != f) return d;
52
- if (n = d < 0, u != l) return u > l ^ n ? 1 : -1;
53
- for (f = (u = o.length) < (l = a.length) ? u : l, d = -1; ++d < f; )
54
- if (o[d] != a[d]) return o[d] > a[d] ^ n ? 1 : -1;
55
- return u == l ? 0 : u > l ^ n ? 1 : -1;
56
- };
57
- S.div = function(e) {
58
- var n = this, t = n.constructor, o = n.c, a = (e = new t(e)).c, d = n.s == e.s ? 1 : -1, f = t.DP;
59
- if (f !== ~~f || f < 0 || f > re)
60
- throw Error(Se);
61
- if (!a[0])
62
- throw Error(mt);
63
- if (!o[0])
64
- return e.s = d, e.c = [e.e = 0], e;
65
- var u, l, c, M, m, y = a.slice(), I = u = a.length, _ = o.length, x = o.slice(0, u), F = x.length, j = e, H = j.c = [], w = 0, g = f + (j.e = n.e - e.e) + 1;
66
- for (j.s = d, d = g < 0 ? 0 : g, y.unshift(0); F++ < u; ) x.push(0);
67
- do {
68
- for (c = 0; c < 10; c++) {
69
- if (u != (F = x.length))
70
- M = u > F ? 1 : -1;
71
- else
72
- for (m = -1, M = 0; ++m < u; )
73
- if (a[m] != x[m]) {
74
- M = a[m] > x[m] ? 1 : -1;
75
- break;
76
- }
77
- if (M < 0) {
78
- for (l = F == u ? a : y; F; ) {
79
- if (x[--F] < l[F]) {
80
- for (m = F; m && !x[--m]; ) x[m] = 9;
81
- --x[m], x[F] += 10;
82
- }
83
- x[F] -= l[F];
84
- }
85
- for (; !x[0]; ) x.shift();
86
- } else
87
- break;
88
- }
89
- H[w++] = M ? c : ++c, x[0] && M ? x[F] = o[I] || 0 : x = [o[I]];
90
- } while ((I++ < _ || x[0] !== le) && d--);
91
- return !H[0] && w != 1 && (H.shift(), j.e--, g--), w > g && de(j, g, t.RM, x[0] !== le), j;
92
- };
93
- S.eq = function(e) {
94
- return this.cmp(e) === 0;
95
- };
96
- S.gt = function(e) {
97
- return this.cmp(e) > 0;
98
- };
99
- S.gte = function(e) {
100
- return this.cmp(e) > -1;
101
- };
102
- S.lt = function(e) {
103
- return this.cmp(e) < 0;
104
- };
105
- S.lte = function(e) {
106
- return this.cmp(e) < 1;
107
- };
108
- S.minus = S.sub = function(e) {
109
- var n, t, o, a, d = this, f = d.constructor, u = d.s, l = (e = new f(e)).s;
110
- if (u != l)
111
- return e.s = -l, d.plus(e);
112
- var c = d.c.slice(), M = d.e, m = e.c, y = e.e;
113
- if (!c[0] || !m[0])
114
- return m[0] ? e.s = -l : c[0] ? e = new f(d) : e.s = 1, e;
115
- if (u = M - y) {
116
- for ((a = u < 0) ? (u = -u, o = c) : (y = M, o = m), o.reverse(), l = u; l--; ) o.push(0);
117
- o.reverse();
118
- } else
119
- for (t = ((a = c.length < m.length) ? c : m).length, u = l = 0; l < t; l++)
120
- if (c[l] != m[l]) {
121
- a = c[l] < m[l];
122
- break;
123
- }
124
- if (a && (o = c, c = m, m = o, e.s = -e.s), (l = (t = m.length) - (n = c.length)) > 0) for (; l--; ) c[n++] = 0;
125
- for (l = n; t > u; ) {
126
- if (c[--t] < m[t]) {
127
- for (n = t; n && !c[--n]; ) c[n] = 9;
128
- --c[n], c[t] += 10;
129
- }
130
- c[t] -= m[t];
131
- }
132
- for (; c[--l] === 0; ) c.pop();
133
- for (; c[0] === 0; )
134
- c.shift(), --y;
135
- return c[0] || (e.s = 1, c = [y = 0]), e.c = c, e.e = y, e;
136
- };
137
- S.mod = function(e) {
138
- var n, t = this, o = t.constructor, a = t.s, d = (e = new o(e)).s;
139
- if (!e.c[0])
140
- throw Error(mt);
141
- return t.s = e.s = 1, n = e.cmp(t) == 1, t.s = a, e.s = d, n ? new o(t) : (a = o.DP, d = o.RM, o.DP = o.RM = 0, t = t.div(e), o.DP = a, o.RM = d, this.minus(t.times(e)));
142
- };
143
- S.neg = function() {
144
- var e = new this.constructor(this);
145
- return e.s = -e.s, e;
146
- };
147
- S.plus = S.add = function(e) {
148
- var n, t, o, a = this, d = a.constructor;
149
- if (e = new d(e), a.s != e.s)
150
- return e.s = -e.s, a.minus(e);
151
- var f = a.e, u = a.c, l = e.e, c = e.c;
152
- if (!u[0] || !c[0])
153
- return c[0] || (u[0] ? e = new d(a) : e.s = a.s), e;
154
- if (u = u.slice(), n = f - l) {
155
- for (n > 0 ? (l = f, o = c) : (n = -n, o = u), o.reverse(); n--; ) o.push(0);
156
- o.reverse();
157
- }
158
- for (u.length - c.length < 0 && (o = c, c = u, u = o), n = c.length, t = 0; n; u[n] %= 10) t = (u[--n] = u[n] + c[n] + t) / 10 | 0;
159
- for (t && (u.unshift(t), ++l), n = u.length; u[--n] === 0; ) u.pop();
160
- return e.c = u, e.e = l, e;
161
- };
162
- S.pow = function(e) {
163
- var n = this, t = new n.constructor("1"), o = t, a = e < 0;
164
- if (e !== ~~e || e < -it || e > it)
165
- throw Error(Ce + "exponent");
166
- for (a && (e = -e); e & 1 && (o = o.times(n)), e >>= 1, !!e; )
167
- n = n.times(n);
168
- return a ? t.div(o) : o;
169
- };
170
- S.prec = function(e, n) {
171
- if (e !== ~~e || e < 1 || e > re)
172
- throw Error(Ce + "precision");
173
- return de(new this.constructor(this), e, n);
174
- };
175
- S.round = function(e, n) {
176
- if (e === le) e = 0;
177
- else if (e !== ~~e || e < -re || e > re)
178
- throw Error(Se);
179
- return de(new this.constructor(this), e + this.e + 1, n);
180
- };
181
- S.sqrt = function() {
182
- var e, n, t, o = this, a = o.constructor, d = o.s, f = o.e, u = new a("0.5");
183
- if (!o.c[0]) return new a(o);
184
- if (d < 0)
185
- throw Error(Te + "No square root");
186
- d = Math.sqrt(+ce(o, !0, !0)), d === 0 || d === 1 / 0 ? (n = o.c.join(""), n.length + f & 1 || (n += "0"), d = Math.sqrt(n), f = ((f + 1) / 2 | 0) - (f < 0 || f & 1), e = new a((d == 1 / 0 ? "5e" : (d = d.toExponential()).slice(0, d.indexOf("e") + 1)) + f)) : e = new a(d + ""), f = e.e + (a.DP += 4);
187
- do
188
- t = e, e = u.times(t.plus(o.div(t)));
189
- while (t.c.slice(0, f).join("") !== e.c.slice(0, f).join(""));
190
- return de(e, (a.DP -= 4) + e.e + 1, a.RM);
191
- };
192
- S.times = S.mul = function(e) {
193
- var n, t = this, o = t.constructor, a = t.c, d = (e = new o(e)).c, f = a.length, u = d.length, l = t.e, c = e.e;
194
- if (e.s = t.s == e.s ? 1 : -1, !a[0] || !d[0])
195
- return e.c = [e.e = 0], e;
196
- for (e.e = l + c, f < u && (n = a, a = d, d = n, c = f, f = u, u = c), n = new Array(c = f + u); c--; ) n[c] = 0;
197
- for (l = u; l--; ) {
198
- for (u = 0, c = f + l; c > l; )
199
- u = n[c] + d[l] * a[c - l - 1] + u, n[c--] = u % 10, u = u / 10 | 0;
200
- n[c] = u;
201
- }
202
- for (u ? ++e.e : n.shift(), l = n.length; !n[--l]; ) n.pop();
203
- return e.c = n, e;
204
- };
205
- S.toExponential = function(e, n) {
206
- var t = this, o = t.c[0];
207
- if (e !== le) {
208
- if (e !== ~~e || e < 0 || e > re)
209
- throw Error(Se);
210
- for (t = de(new t.constructor(t), ++e, n); t.c.length < e; ) t.c.push(0);
211
- }
212
- return ce(t, !0, !!o);
213
- };
214
- S.toFixed = function(e, n) {
215
- var t = this, o = t.c[0];
216
- if (e !== le) {
217
- if (e !== ~~e || e < 0 || e > re)
218
- throw Error(Se);
219
- for (t = de(new t.constructor(t), e + t.e + 1, n), e = e + t.e + 1; t.c.length < e; ) t.c.push(0);
220
- }
221
- return ce(t, !1, !!o);
222
- };
223
- S[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = S.toJSON = S.toString = function() {
224
- var e = this, n = e.constructor;
225
- return ce(e, e.e <= n.NE || e.e >= n.PE, !!e.c[0]);
226
- };
227
- S.toNumber = function() {
228
- var e = +ce(this, !0, !0);
229
- if (this.constructor.strict === !0 && !this.eq(e.toString()))
230
- throw Error(Te + "Imprecise conversion");
231
- return e;
232
- };
233
- S.toPrecision = function(e, n) {
234
- var t = this, o = t.constructor, a = t.c[0];
235
- if (e !== le) {
236
- if (e !== ~~e || e < 1 || e > re)
237
- throw Error(Ce + "precision");
238
- for (t = de(new o(t), e, n); t.c.length < e; ) t.c.push(0);
239
- }
240
- return ce(t, e <= t.e || t.e <= o.NE || t.e >= o.PE, !!a);
241
- };
242
- S.valueOf = function() {
243
- var e = this, n = e.constructor;
244
- if (n.strict === !0)
245
- throw Error(Te + "valueOf disallowed");
246
- return ce(e, e.e <= n.NE || e.e >= n.PE, !0);
247
- };
248
- const Pt = { class: "aimd-type-picker" }, Ut = ["value"], Lt = { value: "" }, Nt = ["label"], Rt = ["value"], Ht = ["label"], jt = ["value"], Ot = ["value", "placeholder"], Wt = /* @__PURE__ */ ie({
249
- __name: "AimdTypePicker",
250
- props: {
251
- modelValue: {},
252
- messages: {},
253
- varTypePlugins: {}
254
- },
255
- emits: ["update:modelValue"],
256
- setup(e, { emit: n }) {
257
- const t = e, o = n, a = dt();
258
- function d(c) {
259
- const M = Xe(c)?.title;
260
- return M && M !== c ? `${M} (${c})` : c;
261
- }
262
- const f = U(() => [...new Map((t.varTypePlugins ?? []).map((c) => [c.value, c])).values()].filter((c) => !a.includes(c.value))), u = U(() => {
263
- const c = Me(t.modelValue);
264
- return Xe(c)?.type_name ?? (f.value.some((M) => M.value === c) ? c : "");
265
- });
266
- function l(c) {
267
- const M = c.target.value;
268
- M && o("update:modelValue", M + (Je(t.modelValue) ? " | None" : ""));
269
- }
270
- return (c, M) => (h(), b("div", Pt, [
271
- i("label", null, [
272
- D(v(e.messages.inputField.knownTypes) + " ", 1),
273
- i("select", {
274
- name: "knownType",
275
- value: u.value,
276
- onChange: l
277
- }, [
278
- i("option", Lt, v(e.messages.inputField.customExpression), 1),
279
- i("optgroup", {
280
- label: e.messages.inputField.builtInTypes
281
- }, [
282
- (h(!0), b(P, null, Y(X(a), (m) => (h(), b("option", {
283
- key: m,
284
- value: m
285
- }, v(d(m)), 9, Rt))), 128))
286
- ], 8, Nt),
287
- f.value.length ? (h(), b("optgroup", {
288
- key: 0,
289
- label: e.messages.inputField.pluginTypes
290
- }, [
291
- (h(!0), b(P, null, Y(f.value, (m) => (h(), b("option", {
292
- key: m.value,
293
- value: m.value
294
- }, v(m.label) + " (" + v(m.value) + ")", 9, jt))), 128))
295
- ], 8, Ht)) : B("", !0)
296
- ], 40, Ut)
297
- ]),
298
- i("label", null, [
299
- D(v(e.messages.dialog.customType), 1),
300
- i("input", {
301
- name: "type",
302
- value: e.modelValue,
303
- placeholder: e.messages.placeholders.type,
304
- spellcheck: "false",
305
- onInput: M[0] || (M[0] = (m) => o("update:modelValue", m.target.value))
306
- }, null, 40, Ot)
307
- ])
308
- ]));
309
- }
310
- }), Be = (e, n) => {
311
- const t = e.__vccOpts || e;
312
- for (const [o, a] of n)
313
- t[o] = a;
314
- return t;
315
- }, vt = /* @__PURE__ */ Be(Wt, [["__scopeId", "data-v-be127780"]]), Kt = { class: "aimd-dialog" }, Qt = { class: "aimd-dialog-header" }, Xt = { class: "aimd-dialog-title" }, Jt = ["innerHTML"], Zt = { class: "aimd-dialog-type-tabs" }, Yt = ["onClick"], Gt = ["innerHTML"], el = { class: "aimd-dialog-body" }, tl = { class: "aimd-field-row" }, ll = { class: "aimd-field-label" }, sl = ["placeholder"], il = { class: "aimd-field-row" }, nl = { class: "aimd-field-label" }, ol = { class: "aimd-field-hint" }, al = { class: "aimd-var-type-grid" }, ul = ["onClick"], rl = { class: "aimd-var-type-card-title" }, dl = { class: "aimd-var-type-card-desc" }, cl = { class: "aimd-field-row" }, ml = { class: "aimd-field-label" }, vl = ["placeholder"], fl = { class: "aimd-field-row" }, pl = { class: "aimd-field-label" }, gl = ["placeholder"], hl = { class: "aimd-field-row" }, yl = { class: "aimd-field-label" }, bl = ["placeholder"], kl = { class: "aimd-field-row" }, wl = { class: "aimd-field-label" }, Ml = ["placeholder"], _l = { class: "aimd-field-hint" }, Tl = { class: "aimd-field-row" }, Cl = { class: "aimd-field-label" }, xl = { class: "aimd-field-row" }, $l = { class: "aimd-field-label" }, Il = ["placeholder"], Fl = { class: "aimd-field-row" }, zl = { class: "aimd-field-label" }, Al = { value: "1" }, Vl = { value: "2" }, El = { value: "3" }, Sl = { class: "aimd-field-row" }, Bl = { class: "aimd-field-label" }, Dl = ["placeholder"], ql = { class: "aimd-field-row" }, Pl = { class: "aimd-field-label" }, Ul = { value: "choice" }, Ll = { value: "blank" }, Nl = { value: "open" }, Rl = { class: "aimd-field-row" }, Hl = { class: "aimd-field-label" }, jl = ["placeholder"], Ol = { class: "aimd-field-row" }, Wl = { class: "aimd-field-label" }, Kl = ["placeholder"], Ql = {
316
- key: 0,
317
- class: "aimd-field-hint"
318
- }, Xl = { class: "aimd-field-row" }, Jl = { class: "aimd-field-label" }, Zl = { value: "single" }, Yl = { value: "multiple" }, Gl = { class: "aimd-field-row" }, es = { class: "aimd-field-label" }, ts = { class: "aimd-collection-editor" }, ls = ["onDragover", "onDrop"], ss = ["title", "onDragstart"], is = ["onUpdate:modelValue", "placeholder"], ns = ["onUpdate:modelValue", "placeholder"], os = { class: "aimd-option-answer-toggle" }, as = ["value", "disabled"], us = ["value", "disabled"], rs = ["disabled", "onClick"], ds = { class: "aimd-field-hint" }, cs = {
319
- key: 1,
320
- class: "aimd-field-row"
321
- }, ms = { class: "aimd-field-label" }, vs = { class: "aimd-collection-editor" }, fs = ["onUpdate:modelValue", "placeholder"], ps = ["onUpdate:modelValue", "placeholder"], gs = ["disabled", "onClick"], hs = { class: "aimd-field-hint" }, ys = {
322
- key: 2,
323
- class: "aimd-field-row"
324
- }, bs = { class: "aimd-field-label" }, ks = ["placeholder"], ws = { class: "aimd-field-row" }, Ms = { class: "aimd-field-label" }, _s = { class: "aimd-field-row" }, Ts = { class: "aimd-field-label" }, Cs = ["placeholder"], xs = { class: "aimd-field-row" }, $s = { class: "aimd-field-label" }, Is = {
325
- key: 5,
326
- class: "aimd-field-row"
327
- }, Fs = { class: "aimd-field-label" }, zs = ["placeholder"], As = { id: "aimd-ref-suggestions" }, Vs = ["value"], Es = {
328
- key: 0,
329
- class: "aimd-field-hint"
330
- }, Ss = {
331
- key: 6,
332
- class: "aimd-field-row"
333
- }, Bs = { class: "aimd-field-label" }, Ds = ["placeholder"], qs = { class: "aimd-field-hint" }, Ps = { class: "aimd-dialog-preview" }, Us = { class: "aimd-preview-header" }, Ls = { class: "aimd-preview-panel" }, Ns = { class: "aimd-preview-code" }, Rs = {
334
- key: 7,
335
- class: "aimd-dialog-error"
336
- }, Hs = { class: "aimd-dialog-footer" }, js = /* @__PURE__ */ ie({
337
- __name: "AimdFieldDialog",
338
- props: {
339
- visible: { type: Boolean },
340
- initialType: {},
341
- messages: {},
342
- refSuggestions: {},
343
- varTypePlugins: {},
344
- allowedTypes: {},
345
- existingQuizIds: {}
346
- },
347
- emits: ["update:visible", "insert"],
348
- setup(e, { emit: n }) {
349
- const t = e, o = n, a = U(() => {
350
- const p = rt(t.messages);
351
- if (!t.allowedTypes || t.allowedTypes.length === 0)
352
- return p;
353
- const r = new Set(t.allowedTypes);
354
- return p.filter((s) => r.has(s.type));
355
- });
356
- function d(p) {
357
- return p && a.value.some((r) => r.type === p) ? p : a.value[0]?.type ?? p ?? "var";
358
- }
359
- const f = U(() => new Set(t.existingQuizIds || [])), u = C(d(t.initialType)), l = C(we(u.value, t.messages, f.value)), c = C([]), M = C([]), m = C([]), y = C(null), I = C(null), _ = C(""), x = U(
360
- () => kt(t.messages, t.varTypePlugins ?? [])
361
- );
362
- function F(p) {
363
- return (p || "").trim().toLowerCase().replace(/[\s_-]/g, "");
364
- }
365
- function j(p) {
366
- return F(l.value.type) === F(p);
367
- }
368
- function H(p) {
369
- l.value.type = p;
370
- }
371
- function w(p, r) {
372
- const s = `quiz_${p}`;
373
- let k = 1;
374
- for (; r.has(`${s}_${k}`); )
375
- k += 1;
376
- return `${s}_${k}`;
377
- }
378
- function g(p) {
379
- const r = p.split(",").map((s) => s.trim()).filter(Boolean);
380
- return r.length === 0 ? [
381
- { key: "A", text: "" },
382
- { key: "B", text: "" }
383
- ] : r.map((s, k) => {
384
- const V = s.indexOf(":");
385
- if (V > 0) {
386
- const ne = s.slice(0, V).trim() || String.fromCharCode(65 + k), ze = s.slice(V + 1).trim() || t.messages.defaults.optionText(ne);
387
- return { key: ne, text: ze };
388
- }
389
- return { key: String.fromCharCode(65 + k), text: s };
390
- });
391
- }
392
- function z(p) {
393
- const r = p.map((s) => ({ key: s.key.trim(), text: s.text.trim() })).filter((s) => s.key && s.text);
394
- return r.length === 0 ? "A:, B:" : r.map((s) => `${s.key}:${s.text}`).join(", ");
395
- }
396
- function O(p) {
397
- const r = p.split(",").map((s) => s.trim()).filter(Boolean);
398
- return r.length === 0 ? [{ key: "b1", answer: "" }] : r.map((s, k) => {
399
- const V = s.indexOf(":");
400
- if (V > 0) {
401
- const be = s.slice(0, V).trim() || `b${k + 1}`, ne = s.slice(V + 1).trim() || "";
402
- return { key: be, answer: ne };
403
- }
404
- return { key: `b${k + 1}`, answer: s };
405
- });
406
- }
407
- function q(p) {
408
- const r = p.map((s) => ({ key: s.key.trim(), answer: s.answer.trim() })).filter((s) => s.key);
409
- return r.length === 0 ? "b1:" : r.map((s) => `${s.key}:${s.answer}`).join(", ");
410
- }
411
- function L(p) {
412
- return p.split(",").map((r) => r.trim()).filter(Boolean);
413
- }
414
- function R() {
415
- u.value === "quiz" && (l.value.quizType === "choice" ? (c.value = g(l.value.options || ""), m.value = L(l.value.answer || "")) : l.value.quizType === "blank" && (M.value = O(l.value.blanks || "")));
416
- }
417
- function K() {
418
- if (u.value !== "quiz" || l.value.quizType !== "choice") return;
419
- const p = new Set(
420
- c.value.map((r) => r.key.trim()).filter(Boolean)
421
- );
422
- if (l.value.mode === "multiple") {
423
- const r = m.value.map((s) => s.trim()).filter((s) => s && p.has(s));
424
- r.length !== m.value.length && (m.value = r);
425
- } else {
426
- const r = (l.value.answer || "").trim();
427
- r && !p.has(r) && (l.value.answer = "");
428
- }
429
- }
430
- function J() {
431
- const p = new Set(
432
- c.value.map((r) => r.key.trim().toUpperCase()).filter(Boolean)
433
- );
434
- for (let r = 0; r < 26; r++) {
435
- const s = String.fromCharCode(65 + r);
436
- if (!p.has(s)) return s;
437
- }
438
- return `K${c.value.length + 1}`;
439
- }
440
- function T() {
441
- const p = J();
442
- c.value.push({ key: p, text: "" });
443
- }
444
- function $(p) {
445
- c.value.length <= 1 || c.value.splice(p, 1);
446
- }
447
- function N(p) {
448
- y.value = p, I.value = p;
449
- }
450
- function Q(p) {
451
- y.value !== null && (I.value = p);
452
- }
453
- function W(p) {
454
- const r = y.value;
455
- if (r === null || r === p) {
456
- y.value = null, I.value = null;
457
- return;
458
- }
459
- const s = c.value.splice(r, 1)[0];
460
- c.value.splice(p, 0, s), y.value = null, I.value = null;
461
- }
462
- function ee() {
463
- y.value = null, I.value = null;
464
- }
465
- function xe() {
466
- const p = new Set(
467
- M.value.map((s) => s.key.trim().toLowerCase()).filter(Boolean)
468
- );
469
- let r = 1;
470
- for (; p.has(`b${r}`); )
471
- r += 1;
472
- return `b${r}`;
473
- }
474
- function pe() {
475
- M.value.push({ key: xe(), answer: "" });
476
- }
477
- function De(p) {
478
- M.value.length <= 1 || M.value.splice(p, 1);
479
- }
480
- function $e(p) {
481
- const r = /* @__PURE__ */ new Set(), s = [];
482
- for (const k of p)
483
- r.has(k) && !s.includes(k) && s.push(k), r.add(k);
484
- return s;
485
- }
486
- function qe(p) {
487
- const r = [], s = /\[\[([^\[\]\s]+)\]\]/g;
488
- for (const k of p.matchAll(s))
489
- r.push(k[1]);
490
- return r;
491
- }
492
- function Pe() {
493
- const p = M.value.map((ke) => ke.key.trim()).filter(Boolean);
494
- if (p.length === 0)
495
- return t.messages.errors.blankQuizRequiresBlankKey;
496
- const r = $e(p);
497
- if (r.length > 0)
498
- return t.messages.errors.blankKeysMustBeUnique(r);
499
- const s = l.value.stem || "", k = qe(s);
500
- if (k.length === 0)
501
- return t.messages.errors.blankStemRequiresPlaceholders;
502
- const V = $e(k);
503
- if (V.length > 0)
504
- return t.messages.errors.duplicatePlaceholders(V);
505
- const be = new Set(p), ne = new Set(k), ze = [...ne].filter((ke) => !be.has(ke));
506
- if (ze.length > 0)
507
- return t.messages.errors.undefinedPlaceholders(ze);
508
- const Ye = [...be].filter((ke) => !ne.has(ke));
509
- return Ye.length > 0 ? t.messages.errors.missingPlaceholders(Ye) : null;
510
- }
511
- function Ie() {
512
- return u.value !== "quiz" || l.value.quizType !== "blank" ? null : Pe();
513
- }
514
- Z(() => t.initialType, (p) => {
515
- const r = d(p);
516
- u.value = r, l.value = we(r, t.messages, f.value), R(), _.value = "";
517
- }), Z(a, () => {
518
- const p = d(u.value);
519
- p !== u.value && (u.value = p, l.value = we(p, t.messages, f.value), R(), _.value = "");
520
- }), Z(() => t.visible, (p) => {
521
- p && (l.value = we(u.value, t.messages, f.value), R(), _.value = "");
522
- });
523
- function Fe(p) {
524
- const r = d(p);
525
- u.value = r, l.value = we(r, t.messages, f.value), R(), _.value = "";
526
- }
527
- const Ue = U(() => lt(u.value, l.value, t.messages));
528
- function Le(p) {
529
- return a.value.find((r) => r.type === p) || { type: p, label: p, icon: "?", svgIcon: "", desc: "", color: "#666" };
530
- }
531
- const ge = U(() => Le(u.value)), he = U(() => t.refSuggestions ? t.refSuggestions : []), Ne = U(() => u.value === "ref_step" ? t.messages.dialog.referencedStepId : u.value === "ref_var" ? t.messages.dialog.referencedVariableId : t.messages.dialog.referencedFigureId), Re = U(() => u.value === "ref_step" ? "step_id" : u.value === "ref_var" ? "var_id" : "fig_id");
532
- Z(() => [u.value, l.value.quizType], ([p, r], [s, k]) => {
533
- p === "quiz" && (p !== s || r !== k) && (r !== k && k && (l.value.id = w(r, f.value), r === "choice" ? (l.value.stem = t.messages.defaults.questionStem, l.value.mode = "single", l.value.options = "A:, B:", l.value.answer = "A", l.value.blanks = "", l.value.rubric = "") : r === "blank" ? (l.value.stem = t.messages.defaults.fillQuestionStem, l.value.blanks = "b1:", l.value.options = "", l.value.answer = "", l.value.mode = "", l.value.rubric = "", M.value = [{ key: "b1", answer: "" }]) : r === "open" && (l.value.stem = t.messages.defaults.fillQuestionStem, l.value.rubric = "", l.value.options = "", l.value.answer = "", l.value.blanks = "", l.value.mode = "")), R());
534
- }), Z(() => l.value.mode, () => {
535
- K();
536
- }), Z(c, (p) => {
537
- u.value === "quiz" && l.value.quizType === "choice" && (l.value.options = z(p), K());
538
- }, { deep: !0 }), Z(M, (p) => {
539
- u.value === "quiz" && l.value.quizType === "blank" && (l.value.blanks = q(p));
540
- }, { deep: !0 }), Z(m, (p) => {
541
- u.value === "quiz" && l.value.quizType === "choice" && l.value.mode === "multiple" && (l.value.answer = p.join(", "));
542
- }, { deep: !0 }), Z(l, () => {
543
- _.value && (_.value = "");
544
- }, { deep: !0 }), Z(M, () => {
545
- _.value && (_.value = "");
546
- }, { deep: !0 });
547
- function He() {
548
- const p = Ie();
549
- if (p) {
550
- _.value = p;
551
- return;
552
- }
553
- _.value = "", o("insert", lt(u.value, l.value, t.messages)), o("update:visible", !1);
554
- }
555
- function ye() {
556
- o("update:visible", !1);
557
- }
558
- return (p, r) => (h(), ue(Ze, { to: "body" }, [
559
- e.visible ? (h(), b("div", {
560
- key: 0,
561
- class: "aimd-dialog-overlay",
562
- onClick: se(ye, ["self"])
563
- }, [
564
- i("div", Kt, [
565
- i("div", Qt, [
566
- i("span", Xt, [
567
- i("span", {
568
- class: "aimd-dialog-icon",
569
- style: _e({ color: ge.value.color }),
570
- innerHTML: ge.value.svgIcon
571
- }, null, 12, Jt),
572
- D(" " + v(t.messages.dialog.title(ge.value.label)), 1)
573
- ]),
574
- i("button", {
575
- class: "aimd-dialog-close",
576
- onClick: ye
577
- }, "×")
578
- ]),
579
- i("div", Zt, [
580
- (h(!0), b(P, null, Y(a.value, (s) => (h(), b("button", {
581
- key: s.type,
582
- class: ae(["aimd-type-tab", { active: u.value === s.type }]),
583
- style: _e(u.value === s.type ? { borderColor: s.color, color: s.color, background: `${s.color}14` } : {}),
584
- onClick: (k) => Fe(s.type)
585
- }, [
586
- i("span", {
587
- innerHTML: s.svgIcon,
588
- class: "aimd-type-tab-icon"
589
- }, null, 8, Gt),
590
- D(" " + v(s.label), 1)
591
- ], 14, Yt))), 128))
592
- ]),
593
- i("div", el, [
594
- u.value === "var" ? (h(), b(P, { key: 0 }, [
595
- i("label", tl, [
596
- i("span", ll, [
597
- D(v(t.messages.dialog.variableId) + " ", 1),
598
- r[22] || (r[22] = i("em", null, "*", -1))
599
- ]),
600
- A(i("input", {
601
- "onUpdate:modelValue": r[0] || (r[0] = (s) => l.value.name = s),
602
- placeholder: t.messages.placeholders.variableId,
603
- class: "aimd-field-input"
604
- }, null, 8, sl), [
605
- [E, l.value.name]
606
- ])
607
- ]),
608
- i("div", il, [
609
- i("span", nl, v(t.messages.dialog.typePresetLabel), 1),
610
- i("span", ol, v(t.messages.dialog.typeHint), 1),
611
- i("div", al, [
612
- (h(!0), b(P, null, Y(x.value, (s) => (h(), b("button", {
613
- key: s.key,
614
- type: "button",
615
- class: ae(["aimd-var-type-card", { active: j(s.value) }]),
616
- onClick: (k) => H(s.value)
617
- }, [
618
- i("span", rl, v(s.label), 1),
619
- i("span", dl, v(s.desc), 1)
620
- ], 10, ul))), 128))
621
- ])
622
- ]),
623
- te(vt, {
624
- modelValue: l.value.type,
625
- "onUpdate:modelValue": r[1] || (r[1] = (s) => l.value.type = s),
626
- messages: e.messages,
627
- "var-type-plugins": e.varTypePlugins
628
- }, null, 8, ["modelValue", "messages", "var-type-plugins"]),
629
- i("label", cl, [
630
- i("span", ml, v(t.messages.dialog.defaultValue), 1),
631
- A(i("input", {
632
- "onUpdate:modelValue": r[2] || (r[2] = (s) => l.value.default = s),
633
- placeholder: t.messages.placeholders.defaultValue,
634
- class: "aimd-field-input"
635
- }, null, 8, vl), [
636
- [E, l.value.default]
637
- ])
638
- ]),
639
- i("label", fl, [
640
- i("span", pl, v(t.messages.dialog.titleLabel), 1),
641
- A(i("input", {
642
- "onUpdate:modelValue": r[3] || (r[3] = (s) => l.value.title = s),
643
- placeholder: t.messages.placeholders.title,
644
- class: "aimd-field-input"
645
- }, null, 8, gl), [
646
- [E, l.value.title]
647
- ])
648
- ])
649
- ], 64)) : B("", !0),
650
- u.value === "var_table" ? (h(), b(P, { key: 1 }, [
651
- i("label", hl, [
652
- i("span", yl, [
653
- D(v(t.messages.dialog.tableId) + " ", 1),
654
- r[23] || (r[23] = i("em", null, "*", -1))
655
- ]),
656
- A(i("input", {
657
- "onUpdate:modelValue": r[4] || (r[4] = (s) => l.value.name = s),
658
- placeholder: t.messages.placeholders.tableId,
659
- class: "aimd-field-input"
660
- }, null, 8, bl), [
661
- [E, l.value.name]
662
- ])
663
- ]),
664
- i("label", kl, [
665
- i("span", wl, v(t.messages.dialog.subVariableColumns), 1),
666
- A(i("input", {
667
- "onUpdate:modelValue": r[5] || (r[5] = (s) => l.value.subvars = s),
668
- placeholder: t.messages.placeholders.subVariableColumns,
669
- class: "aimd-field-input"
670
- }, null, 8, Ml), [
671
- [E, l.value.subvars]
672
- ]),
673
- i("span", _l, v(t.messages.dialog.subVariableColumnsHint), 1)
674
- ])
675
- ], 64)) : B("", !0),
676
- u.value === "step" ? (h(), b(P, { key: 2 }, [
677
- i("label", Tl, [
678
- i("span", Cl, v(t.messages.stepField.name), 1),
679
- A(i("input", {
680
- "onUpdate:modelValue": r[6] || (r[6] = (s) => l.value.title = s),
681
- class: "aimd-field-input"
682
- }, null, 512), [
683
- [E, l.value.title]
684
- ])
685
- ]),
686
- i("label", xl, [
687
- i("span", $l, [
688
- D(v(t.messages.dialog.stepId) + " ", 1),
689
- r[24] || (r[24] = i("em", null, "*", -1))
690
- ]),
691
- A(i("input", {
692
- "onUpdate:modelValue": r[7] || (r[7] = (s) => l.value.name = s),
693
- placeholder: t.messages.placeholders.stepId,
694
- class: "aimd-field-input"
695
- }, null, 8, Il), [
696
- [E, l.value.name]
697
- ])
698
- ]),
699
- i("label", Fl, [
700
- i("span", zl, v(t.messages.dialog.level), 1),
701
- A(i("select", {
702
- "onUpdate:modelValue": r[8] || (r[8] = (s) => l.value.level = s),
703
- class: "aimd-field-input"
704
- }, [
705
- i("option", Al, v(t.messages.dialog.level1), 1),
706
- i("option", Vl, v(t.messages.dialog.level2), 1),
707
- i("option", El, v(t.messages.dialog.level3), 1)
708
- ], 512), [
709
- [me, l.value.level]
710
- ])
711
- ])
712
- ], 64)) : B("", !0),
713
- u.value === "quiz" ? (h(), b(P, { key: 3 }, [
714
- i("label", Sl, [
715
- i("span", Bl, [
716
- D(v(t.messages.dialog.quizId) + " ", 1),
717
- r[25] || (r[25] = i("em", null, "*", -1))
718
- ]),
719
- A(i("input", {
720
- "onUpdate:modelValue": r[9] || (r[9] = (s) => l.value.id = s),
721
- placeholder: t.messages.placeholders.quizId,
722
- class: "aimd-field-input"
723
- }, null, 8, Dl), [
724
- [E, l.value.id]
725
- ])
726
- ]),
727
- i("label", ql, [
728
- i("span", Pl, v(t.messages.dialog.questionType), 1),
729
- A(i("select", {
730
- "onUpdate:modelValue": r[10] || (r[10] = (s) => l.value.quizType = s),
731
- class: "aimd-field-input"
732
- }, [
733
- i("option", Ul, v(t.messages.quiz.types.choice), 1),
734
- i("option", Ll, v(t.messages.quiz.types.blank), 1),
735
- i("option", Nl, v(t.messages.quiz.types.open), 1)
736
- ], 512), [
737
- [me, l.value.quizType]
738
- ])
739
- ]),
740
- i("label", Rl, [
741
- i("span", Hl, v(t.messages.dialog.score), 1),
742
- A(i("input", {
743
- "onUpdate:modelValue": r[11] || (r[11] = (s) => l.value.score = s),
744
- placeholder: t.messages.placeholders.score,
745
- class: "aimd-field-input"
746
- }, null, 8, jl), [
747
- [E, l.value.score]
748
- ])
749
- ]),
750
- i("label", Ol, [
751
- i("span", Wl, [
752
- D(v(t.messages.dialog.stem) + " ", 1),
753
- r[26] || (r[26] = i("em", null, "*", -1))
754
- ]),
755
- A(i("textarea", {
756
- "onUpdate:modelValue": r[12] || (r[12] = (s) => l.value.stem = s),
757
- placeholder: t.messages.placeholders.stem,
758
- class: "aimd-field-input aimd-field-textarea"
759
- }, null, 8, Kl), [
760
- [E, l.value.stem]
761
- ]),
762
- l.value.quizType === "blank" ? (h(), b("span", Ql, v(t.messages.dialog.blankStemHint), 1)) : B("", !0)
763
- ]),
764
- l.value.quizType === "choice" ? (h(), b(P, { key: 0 }, [
765
- i("label", Xl, [
766
- i("span", Jl, v(t.messages.dialog.mode), 1),
767
- A(i("select", {
768
- "onUpdate:modelValue": r[13] || (r[13] = (s) => l.value.mode = s),
769
- class: "aimd-field-input"
770
- }, [
771
- i("option", Zl, v(t.messages.quiz.modes.single), 1),
772
- i("option", Yl, v(t.messages.quiz.modes.multiple), 1)
773
- ], 512), [
774
- [me, l.value.mode]
775
- ])
776
- ]),
777
- i("div", Gl, [
778
- i("span", es, v(t.messages.dialog.options), 1),
779
- i("div", ts, [
780
- (h(!0), b(P, null, Y(c.value, (s, k) => (h(), b("div", {
781
- key: `choice-option-${k}`,
782
- class: ae(["aimd-collection-row aimd-option-row", { "aimd-option-row-dragover": I.value === k && y.value !== null && y.value !== k }]),
783
- onDragover: se((V) => Q(k), ["prevent"]),
784
- onDrop: se((V) => W(k), ["prevent"])
785
- }, [
786
- i("span", {
787
- class: "aimd-drag-handle",
788
- title: t.messages.dialog.dragToReorder,
789
- draggable: "true",
790
- onDragstart: (V) => N(k),
791
- onDragend: ee
792
- }, " ⋮⋮ ", 40, ss),
793
- A(i("input", {
794
- "onUpdate:modelValue": (V) => s.key = V,
795
- placeholder: t.messages.placeholders.optionKey,
796
- class: "aimd-field-input"
797
- }, null, 8, is), [
798
- [E, s.key]
799
- ]),
800
- A(i("input", {
801
- "onUpdate:modelValue": (V) => s.text = V,
802
- placeholder: t.messages.placeholders.optionText,
803
- class: "aimd-field-input"
804
- }, null, 8, ns), [
805
- [E, s.text]
806
- ]),
807
- i("label", os, [
808
- l.value.mode === "single" ? A((h(), b("input", {
809
- key: 0,
810
- "onUpdate:modelValue": r[14] || (r[14] = (V) => l.value.answer = V),
811
- type: "radio",
812
- name: "aimd-quiz-choice-answer",
813
- value: s.key.trim(),
814
- disabled: !s.key.trim()
815
- }, null, 8, as)), [
816
- [ft, l.value.answer]
817
- ]) : A((h(), b("input", {
818
- key: 1,
819
- "onUpdate:modelValue": r[15] || (r[15] = (V) => m.value = V),
820
- type: "checkbox",
821
- value: s.key.trim(),
822
- disabled: !s.key.trim()
823
- }, null, 8, us)), [
824
- [ut, m.value]
825
- ]),
826
- i("span", null, v(t.messages.dialog.correctAnswer), 1)
827
- ]),
828
- i("button", {
829
- type: "button",
830
- class: "aimd-mini-btn",
831
- disabled: c.value.length <= 1,
832
- onClick: (V) => $(k)
833
- }, v(t.messages.common.remove), 9, rs)
834
- ], 42, ls))), 128)),
835
- i("button", {
836
- type: "button",
837
- class: "aimd-mini-btn aimd-mini-btn-add",
838
- onClick: T
839
- }, v(t.messages.actions.addOption), 1)
840
- ]),
841
- i("span", ds, v(t.messages.dialog.optionsHint), 1)
842
- ])
843
- ], 64)) : l.value.quizType === "blank" ? (h(), b("div", cs, [
844
- i("span", ms, v(t.messages.dialog.blanks), 1),
845
- i("div", vs, [
846
- (h(!0), b(P, null, Y(M.value, (s, k) => (h(), b("div", {
847
- key: `blank-item-${k}`,
848
- class: "aimd-collection-row"
849
- }, [
850
- A(i("input", {
851
- "onUpdate:modelValue": (V) => s.key = V,
852
- placeholder: t.messages.placeholders.blankKey,
853
- class: "aimd-field-input"
854
- }, null, 8, fs), [
855
- [E, s.key]
856
- ]),
857
- A(i("input", {
858
- "onUpdate:modelValue": (V) => s.answer = V,
859
- placeholder: t.messages.placeholders.blankAnswer,
860
- class: "aimd-field-input"
861
- }, null, 8, ps), [
862
- [E, s.answer]
863
- ]),
864
- i("button", {
865
- type: "button",
866
- class: "aimd-mini-btn",
867
- disabled: M.value.length <= 1,
868
- onClick: (V) => De(k)
869
- }, v(t.messages.common.remove), 9, gs)
870
- ]))), 128)),
871
- i("button", {
872
- type: "button",
873
- class: "aimd-mini-btn aimd-mini-btn-add",
874
- onClick: pe
875
- }, v(t.messages.actions.addBlank), 1)
876
- ]),
877
- i("span", hs, v(t.messages.dialog.blanksHint), 1)
878
- ])) : (h(), b("label", ys, [
879
- i("span", bs, v(t.messages.dialog.rubric), 1),
880
- A(i("textarea", {
881
- "onUpdate:modelValue": r[16] || (r[16] = (s) => l.value.rubric = s),
882
- placeholder: t.messages.placeholders.rubric,
883
- class: "aimd-field-input aimd-field-textarea"
884
- }, null, 8, ks), [
885
- [E, l.value.rubric]
886
- ])
887
- ]))
888
- ], 64)) : B("", !0),
889
- u.value === "check" ? (h(), b(P, { key: 4 }, [
890
- i("label", ws, [
891
- i("span", Ms, v(t.messages.checkField.name), 1),
892
- A(i("input", {
893
- "onUpdate:modelValue": r[17] || (r[17] = (s) => l.value.title = s),
894
- class: "aimd-field-input"
895
- }, null, 512), [
896
- [E, l.value.title]
897
- ])
898
- ]),
899
- i("label", _s, [
900
- i("span", Ts, [
901
- D(v(t.messages.dialog.checkpointId) + " ", 1),
902
- r[27] || (r[27] = i("em", null, "*", -1))
903
- ]),
904
- A(i("input", {
905
- "onUpdate:modelValue": r[18] || (r[18] = (s) => l.value.name = s),
906
- placeholder: t.messages.placeholders.checkpointId,
907
- class: "aimd-field-input"
908
- }, null, 8, Cs), [
909
- [E, l.value.name]
910
- ])
911
- ]),
912
- i("label", xs, [
913
- i("span", $s, v(t.messages.checkField.checkedMessage), 1),
914
- A(i("input", {
915
- "onUpdate:modelValue": r[19] || (r[19] = (s) => l.value.checkedMessage = s),
916
- class: "aimd-field-input"
917
- }, null, 512), [
918
- [E, l.value.checkedMessage]
919
- ])
920
- ])
921
- ], 64)) : B("", !0),
922
- ["ref_step", "ref_var", "ref_fig"].includes(u.value) ? (h(), b("label", Is, [
923
- i("span", Fs, [
924
- D(v(Ne.value) + " ", 1),
925
- r[28] || (r[28] = i("em", null, "*", -1))
926
- ]),
927
- A(i("input", {
928
- "onUpdate:modelValue": r[20] || (r[20] = (s) => l.value.name = s),
929
- placeholder: Re.value,
930
- class: "aimd-field-input",
931
- list: "aimd-ref-suggestions"
932
- }, null, 8, zs), [
933
- [E, l.value.name]
934
- ]),
935
- i("datalist", As, [
936
- (h(!0), b(P, null, Y(he.value, (s) => (h(), b("option", {
937
- key: s,
938
- value: s
939
- }, null, 8, Vs))), 128))
940
- ]),
941
- he.value.length ? (h(), b("span", Es, v(t.messages.common.available) + ": " + v(he.value.join(", ")), 1)) : B("", !0)
942
- ])) : B("", !0),
943
- u.value === "cite" ? (h(), b("label", Ss, [
944
- i("span", Bs, [
945
- D(v(t.messages.dialog.citationId) + " ", 1),
946
- r[29] || (r[29] = i("em", null, "*", -1))
947
- ]),
948
- A(i("input", {
949
- "onUpdate:modelValue": r[21] || (r[21] = (s) => l.value.refs = s),
950
- placeholder: t.messages.placeholders.citationIds,
951
- class: "aimd-field-input"
952
- }, null, 8, Ds), [
953
- [E, l.value.refs]
954
- ]),
955
- i("span", qs, v(t.messages.dialog.citationHint), 1)
956
- ])) : B("", !0),
957
- i("div", Ps, [
958
- i("div", Us, v(t.messages.common.preview), 1),
959
- i("pre", Ls, [
960
- i("code", Ns, v(Ue.value), 1)
961
- ])
962
- ]),
963
- _.value ? (h(), b("div", Rs, v(_.value), 1)) : B("", !0)
964
- ]),
965
- i("div", Hs, [
966
- i("button", {
967
- class: "aimd-btn aimd-btn-cancel",
968
- onClick: ye
969
- }, v(t.messages.common.cancel), 1),
970
- i("button", {
971
- class: "aimd-btn aimd-btn-primary",
972
- onClick: He
973
- }, v(t.messages.common.insert), 1)
974
- ])
975
- ])
976
- ])) : B("", !0)
977
- ]));
978
- }
979
- }), Os = ["aria-label"], Ws = ["value"], Ks = { key: 0 }, Qs = { key: 1 }, Xs = ["value"], Js = ["value"], Zs = ["open"], Ys = {
980
- key: 2,
981
- class: "aimd-input-dialog__error",
982
- role: "alert"
983
- }, Gs = {
984
- type: "submit",
985
- class: "aimd-input-dialog__save"
986
- }, ei = /* @__PURE__ */ ie({
987
- __name: "AimdInputFieldDialog",
988
- props: {
989
- visible: { type: Boolean },
990
- content: {},
991
- fieldContent: {},
992
- messages: {},
993
- varTypePlugins: {},
994
- reservedIds: {},
995
- initialPreset: {}
996
- },
997
- emits: ["update:visible", "save"],
998
- setup(e, { emit: n }) {
999
- const t = e, o = n, a = C(), d = C(), f = C(""), u = C(""), l = C("str"), c = C(""), M = C(""), m = C("str"), y = C(""), I = C(!1), _ = dt().filter((w) => Xe(w)?.storage_kind === "file-id"), x = U(() => [
1000
- ["str", t.messages.inputField.text],
1001
- ["int", t.messages.inputField.integer],
1002
- ["float", t.messages.inputField.number],
1003
- ["choice", t.messages.inputField.choice],
1004
- ["multiple-choice", t.messages.inputField.multipleChoice],
1005
- ["bool | None", t.messages.inputField.boolean],
1006
- ["bool", t.messages.inputField.checkbox],
1007
- ["date", t.messages.inputField.date],
1008
- ["time", t.messages.inputField.time],
1009
- ["datetime", t.messages.inputField.datetime],
1010
- ["file", t.messages.inputField.file],
1011
- ["list[str]", t.messages.inputField.list],
1012
- ...(t.varTypePlugins ?? []).map((w) => [w.value, w.label]),
1013
- ["custom", t.messages.inputField.custom]
1014
- ]);
1015
- Z(() => t.visible, async (w) => {
1016
- if (!w) {
1017
- a.value?.close();
1018
- return;
1019
- }
1020
- const g = t.fieldContent ? We(t.fieldContent) : void 0;
1021
- f.value = g?.id ?? ve([...fe(t.content), ...t.reservedIds ?? []]), u.value = typeof g?.kwargs?.title == "string" ? g.kwargs.title : "", l.value = g?.type ?? (t.initialPreset === "file" ? "FileIdPDF" : ["choice", "multiple-choice", "custom"].includes(t.initialPreset ?? "") ? "str" : t.initialPreset ?? "str"), c.value = g?.defaultRaw ?? "", m.value = x.value.some(([R]) => R === l.value) ? l.value : "custom";
1022
- const z = xt(l.value), O = z.length ? z : g?.enum, L = (Array.isArray(g?.kwargs?.enum) || /^(?:(?:typing|typing_extensions)\.)?(?:(?:list|List)\s*\[\s*(?:(?:typing|typing_extensions)\.)?)?Literal\s*\[/.test(Me(l.value))) && Array.isArray(O) && O.every((R) => typeof R == "string" && !R.includes(`
1023
- `));
1024
- L && (m.value = z.length ? "multiple-choice" : "choice"), _.includes(Me(l.value)) && (m.value = "file"), !g && t.initialPreset && (m.value = t.initialPreset), M.value = L ? O.join(`
1025
- `) : "", I.value = m.value === "custom", y.value = "", await Ee(), a.value?.showModal(), d.value?.focus();
1026
- }, { immediate: !0 });
1027
- function F() {
1028
- ["custom", "choice", "multiple-choice", "file"].includes(m.value) || (l.value = m.value), m.value === "file" && !_.includes(Me(l.value)) && (l.value = "FileIdPDF"), m.value === "custom" && (I.value = !0);
1029
- }
1030
- function j(w) {
1031
- l.value = w.target.value + (Je(l.value) ? " | None" : "");
1032
- }
1033
- function H() {
1034
- const w = /* @__PURE__ */ new Set([...fe(t.content), ...t.reservedIds ?? []]), g = t.fieldContent ? We(t.fieldContent) : void 0, z = g?.id, O = f.value.trim() || ve(w);
1035
- if (!ct.test(O)) {
1036
- y.value = t.messages.inputField.invalidId, I.value = !0;
1037
- return;
1038
- }
1039
- if (O !== z && w.has(O)) {
1040
- y.value = t.messages.inputField.duplicateId, I.value = !0;
1041
- return;
1042
- }
1043
- let q = l.value;
1044
- if (m.value === "choice" || m.value === "multiple-choice") {
1045
- const K = M.value.split(/\r?\n/).map((J) => J.trim()).filter(Boolean);
1046
- if (!K.length || new Set(K).size !== K.length) {
1047
- y.value = t.messages.inputField.invalidOptions;
1048
- return;
1049
- }
1050
- q = `Literal[${K.map((J) => JSON.stringify(J)).join(", ")}]`, m.value === "multiple-choice" && (q = `list[${q}]`), Je(l.value) && (q += " | None");
1051
- }
1052
- const L = Ft(t.fieldContent, {
1053
- id: O,
1054
- type: q,
1055
- title: u.value,
1056
- defaultRaw: c.value,
1057
- clearEnum: m.value === "choice" || m.value === "multiple-choice" || q !== g?.type
1058
- }), R = $t(We(L));
1059
- if (R.length) {
1060
- y.value = R.join(" "), I.value = !0;
1061
- return;
1062
- }
1063
- o("save", L), o("update:visible", !1);
1064
- }
1065
- return (w, g) => (h(), ue(Ze, { to: "body" }, [
1066
- i("dialog", {
1067
- ref_key: "dialog",
1068
- ref: a,
1069
- class: "aimd-input-dialog",
1070
- "aria-label": e.fieldContent ? e.messages.inputField.edit : e.messages.inputField.insert,
1071
- onClose: g[9] || (g[9] = (z) => o("update:visible", !1)),
1072
- onCancel: g[10] || (g[10] = (z) => o("update:visible", !1))
1073
- }, [
1074
- i("form", {
1075
- onSubmit: se(H, ["prevent"])
1076
- }, [
1077
- i("h2", null, v(e.fieldContent ? e.messages.inputField.edit : e.messages.inputField.insert), 1),
1078
- i("label", null, [
1079
- D(v(e.messages.inputField.name), 1),
1080
- A(i("input", {
1081
- ref_key: "nameInput",
1082
- ref: d,
1083
- "onUpdate:modelValue": g[0] || (g[0] = (z) => u.value = z),
1084
- name: "title",
1085
- autocomplete: "off"
1086
- }, null, 512), [
1087
- [E, u.value]
1088
- ])
1089
- ]),
1090
- i("label", null, [
1091
- D(v(e.messages.dialog.type) + " ", 1),
1092
- A(i("select", {
1093
- "onUpdate:modelValue": g[1] || (g[1] = (z) => m.value = z),
1094
- name: "preset",
1095
- onChange: F
1096
- }, [
1097
- (h(!0), b(P, null, Y(x.value, ([z, O]) => (h(), b("option", {
1098
- key: z,
1099
- value: z
1100
- }, v(O), 9, Ws))), 128))
1101
- ], 544), [
1102
- [me, m.value]
1103
- ])
1104
- ]),
1105
- m.value === "choice" || m.value === "multiple-choice" ? (h(), b("label", Ks, [
1106
- D(v(e.messages.inputField.options), 1),
1107
- A(i("textarea", {
1108
- "onUpdate:modelValue": g[2] || (g[2] = (z) => M.value = z),
1109
- name: "options",
1110
- rows: "4"
1111
- }, null, 512), [
1112
- [E, M.value]
1113
- ])
1114
- ])) : B("", !0),
1115
- m.value === "file" ? (h(), b("label", Qs, [
1116
- D(v(e.messages.inputField.fileFormat), 1),
1117
- i("select", {
1118
- name: "fileType",
1119
- value: X(Me)(l.value),
1120
- onChange: j
1121
- }, [
1122
- (h(!0), b(P, null, Y(X(_), (z) => (h(), b("option", {
1123
- key: z,
1124
- value: z
1125
- }, v(z.replace(/^FileId/, "")), 9, Js))), 128))
1126
- ], 40, Xs)
1127
- ])) : B("", !0),
1128
- i("details", {
1129
- open: I.value,
1130
- onToggle: g[7] || (g[7] = (z) => I.value = z.target.open)
1131
- }, [
1132
- i("summary", null, v(e.messages.inputField.advanced), 1),
1133
- i("label", null, [
1134
- D(v(e.messages.inputField.id), 1),
1135
- A(i("input", {
1136
- "onUpdate:modelValue": g[3] || (g[3] = (z) => f.value = z),
1137
- name: "id",
1138
- autocomplete: "off",
1139
- spellcheck: "false"
1140
- }, null, 512), [
1141
- [E, f.value]
1142
- ])
1143
- ]),
1144
- te(vt, {
1145
- modelValue: l.value,
1146
- "onUpdate:modelValue": [
1147
- g[4] || (g[4] = (z) => l.value = z),
1148
- g[5] || (g[5] = (z) => m.value = "custom")
1149
- ],
1150
- messages: e.messages,
1151
- "var-type-plugins": e.varTypePlugins
1152
- }, null, 8, ["modelValue", "messages", "var-type-plugins"]),
1153
- i("label", null, [
1154
- D(v(e.messages.dialog.defaultValue), 1),
1155
- A(i("input", {
1156
- "onUpdate:modelValue": g[6] || (g[6] = (z) => c.value = z),
1157
- name: "default"
1158
- }, null, 512), [
1159
- [E, c.value]
1160
- ])
1161
- ])
1162
- ], 40, Zs),
1163
- y.value ? (h(), b("p", Ys, v(y.value), 1)) : B("", !0),
1164
- i("footer", null, [
1165
- i("button", {
1166
- type: "button",
1167
- onClick: g[8] || (g[8] = (z) => o("update:visible", !1))
1168
- }, v(e.messages.common.cancel), 1),
1169
- i("button", Gs, v(e.fieldContent ? e.messages.inputField.save : e.messages.common.insert), 1)
1170
- ])
1171
- ], 32)
1172
- ], 40, Os)
1173
- ]));
1174
- }
1175
- }), ti = /* @__PURE__ */ Be(ei, [["__scopeId", "data-v-590f21dc"]]), li = ["aria-label"], si = {
1176
- key: 0,
1177
- class: "aimd-step-dialog__check"
1178
- }, ii = ["open"], ni = ["readonly"], oi = { key: 0 }, ai = ["value"], ui = { value: "elapsed" }, ri = { value: "countdown" }, di = { value: "both" }, ci = {
1179
- key: 1,
1180
- role: "alert"
1181
- }, mi = {
1182
- type: "submit",
1183
- class: "aimd-step-dialog__save"
1184
- }, vi = /* @__PURE__ */ ie({
1185
- __name: "AimdStepFieldDialog",
1186
- props: {
1187
- visible: { type: Boolean },
1188
- content: {},
1189
- fieldContent: {},
1190
- fieldType: {},
1191
- reservedIds: {},
1192
- messages: {}
1193
- },
1194
- emits: ["update:visible", "save"],
1195
- setup(e, { emit: n }) {
1196
- const t = e, o = n, a = C(), d = C(), f = C(""), u = C(""), l = C(1), c = C(!0), M = C(""), m = C("elapsed"), y = C(""), I = C(!1), _ = C(""), x = U(() => t.fieldType === "check"), F = U(() => x.value ? t.messages.checkField : t.messages.stepField);
1197
- Z(() => t.visible, async (H) => {
1198
- if (!H) {
1199
- a.value?.close();
1200
- return;
1201
- }
1202
- const w = t.fieldContent && !x.value ? st(t.fieldContent) : void 0, g = t.fieldContent && x.value ? It(t.fieldContent) : void 0;
1203
- f.value = (g ?? w)?.id ?? ve([...fe(t.content), ...t.reservedIds ?? []], x.value ? "check" : "step"), u.value = (g ?? w)?.title ?? "", _.value = g?.checked_message ?? "", l.value = w?.level ?? 1, c.value = w?.check ?? !0, M.value = String(w?.props.duration ?? ""), m.value = w?.timer_mode ?? "elapsed", y.value = "", I.value = !1, await Ee(), a.value?.showModal(), d.value?.focus();
1204
- }, { immediate: !0 });
1205
- function j() {
1206
- const H = /* @__PURE__ */ new Set([...fe(t.content), ...t.reservedIds ?? []]), w = f.value.trim() || ve(H, x.value ? "check" : "step");
1207
- if (!ct.test(w)) {
1208
- y.value = t.messages.inputField.invalidId, I.value = !0;
1209
- return;
1210
- }
1211
- if (!t.fieldContent && H.has(w)) {
1212
- y.value = t.messages.inputField.duplicateId, I.value = !0;
1213
- return;
1214
- }
1215
- if (x.value) {
1216
- o("save", zt(t.fieldContent, { id: w, title: u.value, checkedMessage: _.value })), o("update:visible", !1);
1217
- return;
1218
- }
1219
- const g = At(t.fieldContent, { id: w, title: u.value, level: l.value, check: c.value, duration: M.value, timer: m.value }), z = st(g);
1220
- if (M.value.trim() && z.estimated_duration_ms === void 0 || m.value !== "elapsed" && !z.estimated_duration_ms) {
1221
- y.value = t.messages.stepField.invalidDuration, I.value = !0;
1222
- return;
1223
- }
1224
- o("save", g), o("update:visible", !1);
1225
- }
1226
- return (H, w) => (h(), ue(Ze, { to: "body" }, [
1227
- i("dialog", {
1228
- ref_key: "dialog",
1229
- ref: a,
1230
- class: "aimd-step-dialog",
1231
- "aria-label": e.fieldContent ? F.value.edit : F.value.insert,
1232
- onClose: w[9] || (w[9] = (g) => o("update:visible", !1)),
1233
- onCancel: w[10] || (w[10] = (g) => o("update:visible", !1))
1234
- }, [
1235
- i("form", {
1236
- onSubmit: se(j, ["prevent"])
1237
- }, [
1238
- i("h2", null, v(e.fieldContent ? F.value.edit : F.value.insert), 1),
1239
- i("label", null, [
1240
- D(v(F.value.name), 1),
1241
- A(i("input", {
1242
- ref_key: "nameInput",
1243
- ref: d,
1244
- "onUpdate:modelValue": w[0] || (w[0] = (g) => u.value = g),
1245
- name: "title",
1246
- autocomplete: "off"
1247
- }, null, 512), [
1248
- [E, u.value]
1249
- ])
1250
- ]),
1251
- x.value ? B("", !0) : (h(), b("label", si, [
1252
- A(i("input", {
1253
- "onUpdate:modelValue": w[1] || (w[1] = (g) => c.value = g),
1254
- name: "check",
1255
- type: "checkbox"
1256
- }, null, 512), [
1257
- [ut, c.value]
1258
- ]),
1259
- D(v(e.messages.stepField.check), 1)
1260
- ])),
1261
- i("details", {
1262
- open: I.value,
1263
- onToggle: w[7] || (w[7] = (g) => I.value = g.target.open)
1264
- }, [
1265
- i("summary", null, v(e.messages.inputField.advanced), 1),
1266
- i("label", null, [
1267
- D(v(F.value.id), 1),
1268
- A(i("input", {
1269
- "onUpdate:modelValue": w[2] || (w[2] = (g) => f.value = g),
1270
- name: "id",
1271
- readonly: !!e.fieldContent,
1272
- autocomplete: "off",
1273
- spellcheck: "false"
1274
- }, null, 8, ni), [
1275
- [E, f.value]
1276
- ])
1277
- ]),
1278
- x.value ? (h(), b("label", oi, [
1279
- D(v(e.messages.checkField.checkedMessage), 1),
1280
- A(i("input", {
1281
- "onUpdate:modelValue": w[3] || (w[3] = (g) => _.value = g),
1282
- name: "checkedMessage"
1283
- }, null, 512), [
1284
- [E, _.value]
1285
- ])
1286
- ])) : (h(), b(P, { key: 1 }, [
1287
- i("label", null, [
1288
- D(v(e.messages.dialog.level), 1),
1289
- A(i("select", {
1290
- "onUpdate:modelValue": w[4] || (w[4] = (g) => l.value = g),
1291
- name: "level"
1292
- }, [
1293
- (h(), b(P, null, Y(3, (g) => i("option", {
1294
- key: g,
1295
- value: g
1296
- }, v(g), 9, ai)), 64))
1297
- ], 512), [
1298
- [me, l.value]
1299
- ])
1300
- ]),
1301
- i("label", null, [
1302
- D(v(e.messages.stepField.duration), 1),
1303
- A(i("input", {
1304
- "onUpdate:modelValue": w[5] || (w[5] = (g) => M.value = g),
1305
- name: "duration",
1306
- placeholder: "2m"
1307
- }, null, 512), [
1308
- [E, M.value]
1309
- ])
1310
- ]),
1311
- i("label", null, [
1312
- D(v(e.messages.stepField.timer), 1),
1313
- A(i("select", {
1314
- "onUpdate:modelValue": w[6] || (w[6] = (g) => m.value = g),
1315
- name: "timer"
1316
- }, [
1317
- i("option", ui, v(e.messages.stepField.elapsed), 1),
1318
- i("option", ri, v(e.messages.stepField.countdown), 1),
1319
- i("option", di, v(e.messages.stepField.both), 1)
1320
- ], 512), [
1321
- [me, m.value]
1322
- ])
1323
- ])
1324
- ], 64))
1325
- ], 40, ii),
1326
- y.value ? (h(), b("p", ci, v(y.value), 1)) : B("", !0),
1327
- i("footer", null, [
1328
- i("button", {
1329
- type: "button",
1330
- onClick: w[8] || (w[8] = (g) => o("update:visible", !1))
1331
- }, v(e.messages.common.cancel), 1),
1332
- i("button", mi, v(e.fieldContent ? e.messages.inputField.save : e.messages.common.insert), 1)
1333
- ])
1334
- ], 32)
1335
- ], 40, li)
1336
- ]));
1337
- }
1338
- }), fi = /* @__PURE__ */ Be(vi, [["__scopeId", "data-v-fc5a778d"]]);
1339
- const oe = {
1340
- xmlns: "http://www.w3.org/2000/svg",
1341
- width: 24,
1342
- height: 24,
1343
- viewBox: "0 0 24 24",
1344
- fill: "none",
1345
- stroke: "currentColor",
1346
- "stroke-width": 2,
1347
- "stroke-linecap": "round",
1348
- "stroke-linejoin": "round"
1349
- };
1350
- const nt = (...e) => e.filter((n, t, o) => !!n && n.trim() !== "" && o.indexOf(n) === t).join(" ").trim();
1351
- function Ke(e) {
1352
- return e != null;
1353
- }
1354
- function pi(e, n = {}) {
1355
- const t = n.attributeNames ?? {}, o = (y) => t[y] ?? y, a = e.size ?? e.width ?? oe.width, d = e.size ?? e.height ?? oe.height, f = e.aliases?.filter((y) => typeof y == "string" && y.trim() !== "").map((y) => `lucide-${y}`) ?? [], u = [...e.name ? [`lucide-${e.name}`] : [], ...f], l = n.className?.split(" ").filter(Boolean) ?? [], c = n.includeDefaultClasses === !1 ? nt(...l) : nt("lucide", ...u, ...l), M = n.absoluteStrokeWidth ? Number(n.strokeWidth ?? oe["stroke-width"]) * Number(e.size ?? e.width ?? oe.width) / Number(n.size ?? n.width ?? oe.width) : n.strokeWidth ?? oe["stroke-width"];
1356
- return [
1357
- "svg",
1358
- {
1359
- ...Object.entries(oe).reduce((y, [I, _]) => (y[o(I)] = _, y), {}),
1360
- ..."color" in n && n.color && {
1361
- [o("stroke")]: n.color
1362
- },
1363
- ..."size" in n && Ke(n.size) && {
1364
- [o("width")]: n.size,
1365
- [o("height")]: n.size
1366
- },
1367
- ..."width" in n && Ke(n.width) && {
1368
- [o("width")]: n.width
1369
- },
1370
- ..."height" in n && Ke(n.height) && {
1371
- [o("height")]: n.height
1372
- },
1373
- [o("stroke-width")]: M,
1374
- ...c && {
1375
- [o("class")]: c
1376
- },
1377
- [o("viewBox")]: `0 0 ${a} ${d}`,
1378
- ...n.hasA11yProp === !1 ? {
1379
- [o("aria-hidden")]: "true"
1380
- } : {},
1381
- ..."attributes" in n && n.attributes
1382
- },
1383
- e.node.map((y) => {
1384
- const [I, _, x] = y, F = n.nonScalingStroke ? { [o("vector-effect")]: "non-scaling-stroke", ..._ } : _;
1385
- return x ? [I, F, x] : [I, F];
1386
- })
1387
- ];
1388
- }
1389
- const gi = (e) => {
1390
- for (const n in e)
1391
- if (n.startsWith("aria-") || n === "role" || n === "title")
1392
- return !0;
1393
- return !1;
1394
- };
1395
- const Ae = (e) => e === "";
1396
- const hi = (e) => e?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1397
- const yi = /* @__PURE__ */ Symbol("lucide-icons");
1398
- function bi() {
1399
- return pt(yi, {});
1400
- }
1401
- const ki = ({
1402
- name: e,
1403
- iconNode: n,
1404
- "icon-node": t,
1405
- icon: o = {
1406
- name: e && hi(e),
1407
- node: n ?? t ?? [],
1408
- size: 24,
1409
- aliases: []
1410
- },
1411
- absoluteStrokeWidth: a,
1412
- "absolute-stroke-width": d,
1413
- nonScalingStroke: f,
1414
- "non-scaling-stroke": u,
1415
- strokeWidth: l,
1416
- "stroke-width": c,
1417
- size: M,
1418
- width: m = M,
1419
- height: y = M,
1420
- color: I,
1421
- ..._
1422
- }, { slots: x }) => {
1423
- const {
1424
- size: F,
1425
- color: j,
1426
- strokeWidth: H = 2,
1427
- absoluteStrokeWidth: w = !1,
1428
- nonScalingStroke: g = !1,
1429
- class: z = ""
1430
- } = bi(), O = Ae(a) || Ae(d) || a === !0 || d === !0 || w === !0, q = Ae(f) || Ae(u) || f === !0 || u === !0 || g === !0;
1431
- delete _.class;
1432
- const L = x.default?.(), [, R, K = []] = pi(o, {
1433
- color: I ?? j,
1434
- width: m ?? M ?? F,
1435
- height: y ?? M ?? F,
1436
- strokeWidth: l ?? c ?? H,
1437
- absoluteStrokeWidth: O,
1438
- nonScalingStroke: q,
1439
- className: z,
1440
- hasA11yProp: L != null && L.length > 0 || gi(_),
1441
- attributes: _
1442
- });
1443
- return Qe("svg", R, [
1444
- ...K.map(([J, T]) => Qe(J, T)),
1445
- ...L ?? []
1446
- ]);
1447
- };
1448
- function G(e, n = []) {
1449
- const t = typeof e == "string" ? {
1450
- name: e,
1451
- node: n
1452
- } : e;
1453
- return (o, { slots: a }) => Qe(
1454
- ki,
1455
- {
1456
- ...o,
1457
- icon: t
1458
- },
1459
- a.default ? { default: a.default } : void 0
1460
- );
1461
- }
1462
- const wi = {
1463
- name: "calendar-days",
1464
- size: 24,
1465
- node: [
1466
- ["path", { d: "M8 2v3", key: "1ioesn" }],
1467
- ["path", { d: "M16 2v3", key: "otl347" }],
1468
- ["rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", key: "h1oib" }],
1469
- ["path", { d: "M3 9h18", key: "1pudct" }],
1470
- ["path", { d: "M8 13h.01", key: "1sbv64" }],
1471
- ["path", { d: "M12 13h.01", key: "y0uutt" }],
1472
- ["path", { d: "M16 13h.01", key: "wip0gl" }],
1473
- ["path", { d: "M8 17h.01", key: "p3bg7i" }],
1474
- ["path", { d: "M12 17h.01", key: "p32p05" }],
1475
- ["path", { d: "M16 17h.01", key: "ql8jdd" }]
1476
- ]
1477
- }, ot = G(wi);
1478
- const Mi = {
1479
- name: "chevron-down",
1480
- size: 24,
1481
- node: [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]]
1482
- }, _i = G(Mi);
1483
- const Ti = {
1484
- name: "circle-dot",
1485
- size: 24,
1486
- node: [
1487
- ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
1488
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]
1489
- ]
1490
- }, Ci = G(Ti);
1491
- const xi = {
1492
- name: "clock",
1493
- size: 24,
1494
- node: [
1495
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
1496
- ["path", { d: "M12 6v6l4 2", key: "mmk7yg" }]
1497
- ]
1498
- }, $i = G(xi);
1499
- const Ii = {
1500
- name: "hash",
1501
- size: 24,
1502
- node: [
1503
- ["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
1504
- ["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
1505
- ["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
1506
- ["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
1507
- ]
1508
- }, at = G(Ii);
1509
- const Fi = {
1510
- name: "list-checks",
1511
- size: 24,
1512
- node: [
1513
- ["path", { d: "M13 5h8", key: "a7qcls" }],
1514
- ["path", { d: "M13 12h8", key: "h98zly" }],
1515
- ["path", { d: "M13 19h8", key: "c3s6r1" }],
1516
- ["path", { d: "m3 17 2 2 4-4", key: "1jhpwq" }],
1517
- ["path", { d: "m3 7 2 2 4-4", key: "1obspn" }]
1518
- ]
1519
- }, zi = G(Fi);
1520
- const Ai = {
1521
- name: "list-ordered",
1522
- size: 24,
1523
- node: [
1524
- ["path", { d: "M11 5h10", key: "1cz7ny" }],
1525
- ["path", { d: "M11 12h10", key: "1438ji" }],
1526
- ["path", { d: "M11 19h10", key: "11t30w" }],
1527
- ["path", { d: "M4 4h1v5", key: "10yrso" }],
1528
- ["path", { d: "M4 9h2", key: "r1h2o0" }],
1529
- ["path", { d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02", key: "xtkcd5" }]
1530
- ]
1531
- }, Vi = G(Ai);
1532
- const Ei = {
1533
- name: "paperclip",
1534
- size: 24,
1535
- node: [
1536
- [
1537
- "path",
1538
- {
1539
- d: "m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",
1540
- key: "1miecu"
1541
- }
1542
- ]
1543
- ]
1544
- }, Si = G(Ei);
1545
- const Bi = {
1546
- name: "settings-2",
1547
- size: 24,
1548
- node: [
1549
- ["path", { d: "M14 17H5", key: "gfn3mx" }],
1550
- ["path", { d: "M19 7h-9", key: "6i9tg" }],
1551
- ["circle", { cx: "17", cy: "17", r: "3", key: "18b49y" }],
1552
- ["circle", { cx: "7", cy: "7", r: "3", key: "dfmy0x" }]
1553
- ]
1554
- }, Di = G(Bi);
1555
- const qi = {
1556
- name: "square-check",
1557
- size: 24,
1558
- node: [
1559
- ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
1560
- ["path", { d: "m16 9-5.5 5.5L8 12", key: "xofnsj" }]
1561
- ],
1562
- aliases: ["check-square-2"]
1563
- }, Pi = G(qi);
1564
- const Ui = {
1565
- name: "text-cursor-input",
1566
- size: 24,
1567
- node: [
1568
- ["path", { d: "M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6", key: "1528k5" }],
1569
- ["path", { d: "M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7", key: "13ksps" }],
1570
- ["path", { d: "M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1", key: "1n9rhb" }],
1571
- ["path", { d: "M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1", key: "1mj8rg" }],
1572
- ["path", { d: "M9 6v12", key: "velyjx" }]
1573
- ]
1574
- }, Li = G(Ui);
1575
- const Ni = {
1576
- name: "toggle-left",
1577
- size: 24,
1578
- node: [
1579
- ["circle", { cx: "9", cy: "12", r: "3", key: "u3jwor" }],
1580
- ["rect", { width: "20", height: "14", x: "2", y: "5", rx: "7", key: "g7kal2" }]
1581
- ]
1582
- }, Ri = G(Ni), Hi = ["aria-label"], ji = ["title", "aria-label", "onClick"], Oi = ["aria-label"], Wi = ["title", "onClick"], Ki = /* @__PURE__ */ ie({
1583
- __name: "AimdInputToolbar",
1584
- props: {
1585
- messages: {}
1586
- },
1587
- emits: ["insert"],
1588
- setup(e, { emit: n }) {
1589
- const t = e, o = n, a = C(), d = C(0), f = U(() => [
1590
- { preset: "str", label: t.messages.inputField.text, icon: Li },
1591
- { preset: "int", label: t.messages.inputField.integer, icon: at },
1592
- { preset: "float", label: t.messages.inputField.number, icon: at },
1593
- { preset: "choice", label: t.messages.inputField.choice, icon: Ci },
1594
- { preset: "multiple-choice", label: t.messages.inputField.multipleChoice, icon: Pi },
1595
- { preset: "bool | None", label: t.messages.inputField.boolean, icon: Ri }
1596
- ]), u = U(() => [
1597
- { preset: "date", label: t.messages.inputField.date, icon: ot },
1598
- { preset: "time", label: t.messages.inputField.time, icon: $i },
1599
- { preset: "datetime", label: t.messages.inputField.datetime, icon: ot },
1600
- { preset: "list[str]", label: t.messages.inputField.list, icon: Vi },
1601
- { preset: "file", label: t.messages.inputField.file, icon: Si },
1602
- { preset: "custom", label: t.messages.inputField.custom, icon: Di }
1603
- ]);
1604
- function l(y = !1) {
1605
- a.value?.open && (a.value.open = !1, y && a.value.querySelector("summary")?.focus());
1606
- }
1607
- function c(y) {
1608
- l(), o("insert", y);
1609
- }
1610
- function M(y) {
1611
- y.target instanceof Node && !a.value?.contains(y.target) && l();
1612
- }
1613
- function m() {
1614
- if (!a.value?.open) return;
1615
- const y = a.value.getBoundingClientRect().left;
1616
- d.value = Math.max(8 - y, Math.min(0, window.innerWidth - y - 198));
1617
- }
1618
- return gt(() => document.addEventListener("click", M)), ht(() => document.removeEventListener("click", M)), (y, I) => (h(), b("div", {
1619
- class: "aimd-input-tools",
1620
- role: "group",
1621
- "aria-label": e.messages.inputField.insert
1622
- }, [
1623
- (h(!0), b(P, null, Y(f.value, (_) => (h(), b("button", {
1624
- key: _.preset,
1625
- type: "button",
1626
- title: e.messages.inputField.insertType(_.label),
1627
- "aria-label": e.messages.inputField.insertType(_.label),
1628
- onMousedown: I[0] || (I[0] = se(() => {
1629
- }, ["prevent"])),
1630
- onClick: (x) => c(_.preset)
1631
- }, [
1632
- (h(), ue(Ge(_.icon), {
1633
- size: 16,
1634
- "aria-hidden": "true"
1635
- })),
1636
- i("span", null, v(_.label), 1)
1637
- ], 40, ji))), 128)),
1638
- i("details", {
1639
- ref_key: "more",
1640
- ref: a,
1641
- class: "aimd-input-tools__more",
1642
- onToggle: m,
1643
- onKeydown: I[1] || (I[1] = yt(se((_) => l(!0), ["stop", "prevent"]), ["esc"]))
1644
- }, [
1645
- i("summary", null, [
1646
- te(X(zi), {
1647
- size: 16,
1648
- "aria-hidden": "true"
1649
- }),
1650
- i("span", null, v(e.messages.inputField.more), 1),
1651
- te(X(_i), {
1652
- size: 14,
1653
- "aria-hidden": "true"
1654
- })
1655
- ]),
1656
- i("div", {
1657
- class: "aimd-input-tools__menu",
1658
- style: _e({ left: `${d.value}px` }),
1659
- role: "group",
1660
- "aria-label": e.messages.inputField.more
1661
- }, [
1662
- (h(!0), b(P, null, Y(u.value, (_) => (h(), b("button", {
1663
- key: _.preset,
1664
- type: "button",
1665
- title: e.messages.inputField.insertType(_.label),
1666
- onClick: (x) => c(_.preset)
1667
- }, [
1668
- (h(), ue(Ge(_.icon), {
1669
- size: 16,
1670
- "aria-hidden": "true"
1671
- })),
1672
- i("span", null, v(_.label), 1)
1673
- ], 8, Wi))), 128))
1674
- ], 12, Oi)
1675
- ], 544)
1676
- ], 8, Hi));
1677
- }
1678
- }), Qi = /* @__PURE__ */ Be(Ki, [["__scopeId", "data-v-36cefb3e"]]), Xi = { class: "aimd-editor-toolbar" }, Ji = {
1679
- key: 0,
1680
- class: "aimd-editor-mode-switch"
1681
- }, Zi = ["title"], Yi = ["title"], Gi = {
1682
- key: 1,
1683
- class: "aimd-editor-toolbar-sep"
1684
- }, en = {
1685
- key: 0,
1686
- class: "aimd-editor-toolbar-sep"
1687
- }, tn = ["title", "onClick", "innerHTML"], ln = {
1688
- key: 3,
1689
- class: "aimd-editor-toolbar-divider"
1690
- }, sn = ["title", "onClick", "onMouseup"], nn = ["innerHTML"], on = { class: "aimd-editor-aimd-btn-label" }, an = /* @__PURE__ */ ie({
1691
- __name: "AimdEditorToolbar",
1692
- props: {
1693
- showTopBar: { type: Boolean },
1694
- showMdToolbar: { type: Boolean },
1695
- showAimdToolbar: { type: Boolean },
1696
- editorMode: {},
1697
- resolvedMessages: {},
1698
- localizedFieldTypes: {},
1699
- localizedMdToolbarItems: {}
1700
- },
1701
- emits: ["switch-mode", "md-action", "open-aimd-dialog", "quick-insert-aimd", "insert-input"],
1702
- setup(e, { emit: n }) {
1703
- const t = n;
1704
- return (o, a) => (h(), b("div", Xi, [
1705
- e.showTopBar ? (h(), b("div", Ji, [
1706
- i("button", {
1707
- type: "button",
1708
- class: ae(["aimd-editor-mode-btn", { active: e.editorMode === "source" }]),
1709
- onClick: a[0] || (a[0] = (d) => t("switch-mode", "source")),
1710
- title: e.resolvedMessages.mode.sourceTitle
1711
- }, [
1712
- a[3] || (a[3] = i("span", {
1713
- class: "aimd-editor-mode-icon",
1714
- innerHTML: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>'
1715
- }, null, -1)),
1716
- i("span", null, v(e.resolvedMessages.mode.source), 1)
1717
- ], 10, Zi),
1718
- i("button", {
1719
- type: "button",
1720
- class: ae(["aimd-editor-mode-btn", { active: e.editorMode === "wysiwyg" }]),
1721
- onClick: a[1] || (a[1] = (d) => t("switch-mode", "wysiwyg")),
1722
- title: e.resolvedMessages.mode.wysiwygTitle
1723
- }, [
1724
- a[4] || (a[4] = i("span", {
1725
- class: "aimd-editor-mode-icon",
1726
- innerHTML: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'
1727
- }, null, -1)),
1728
- i("span", null, v(e.resolvedMessages.mode.wysiwyg), 1)
1729
- ], 10, Yi)
1730
- ])) : B("", !0),
1731
- e.showTopBar && e.showMdToolbar ? (h(), b("div", Gi)) : B("", !0),
1732
- e.showMdToolbar ? (h(!0), b(P, { key: 2 }, Y(e.localizedMdToolbarItems, (d) => (h(), b(P, {
1733
- key: d.action
1734
- }, [
1735
- d.action.startsWith("sep") ? (h(), b("div", en)) : (h(), b("button", {
1736
- key: 1,
1737
- type: "button",
1738
- class: "aimd-editor-fmt-btn",
1739
- title: d.title,
1740
- onClick: (f) => t("md-action", d.action, f),
1741
- innerHTML: d.svgIcon
1742
- }, null, 8, tn))
1743
- ], 64))), 128)) : B("", !0),
1744
- e.showMdToolbar && e.showAimdToolbar ? (h(), b("div", ln)) : B("", !0),
1745
- e.showAimdToolbar ? (h(), b(P, { key: 4 }, [
1746
- (h(!0), b(P, null, Y(e.localizedFieldTypes.filter((d) => d.type !== "var"), (d) => (h(), b("button", {
1747
- key: d.type,
1748
- type: "button",
1749
- class: "aimd-editor-fmt-btn aimd-editor-aimd-btn",
1750
- title: d.desc,
1751
- style: _e({ "--aimd-color": d.color }),
1752
- onClick: (f) => t("open-aimd-dialog", d.type),
1753
- onMouseup: se((f) => t("quick-insert-aimd", d.type), ["middle", "prevent"])
1754
- }, [
1755
- i("span", {
1756
- class: "aimd-editor-aimd-btn-icon",
1757
- innerHTML: d.svgIcon
1758
- }, null, 8, nn),
1759
- i("span", on, v(d.label), 1)
1760
- ], 44, sn))), 128)),
1761
- e.localizedFieldTypes.some((d) => d.type === "var") ? (h(), ue(Qi, {
1762
- key: 0,
1763
- messages: e.resolvedMessages,
1764
- onInsert: a[2] || (a[2] = (d) => t("insert-input", d))
1765
- }, null, 8, ["messages"])) : B("", !0)
1766
- ], 64)) : B("", !0)
1767
- ]));
1768
- }
1769
- });
1770
- function un(e) {
1771
- const { initialContent: n, initialMode: t, resolvedMessages: o, emitModelValue: a, emitMode: d } = e, f = C(t), u = C(n), l = je(null), c = je(null), M = C(!0), m = je(null);
1772
- let y = !1;
1773
- function I(T) {
1774
- T !== u.value && (u.value = T, a(T));
1775
- }
1776
- function _(T) {
1777
- return Et(T).content;
1778
- }
1779
- function x(T) {
1780
- return /class="ProseMirror milkdown-editor-content editor"/.test(T) || /<div class="milkdown">/.test(T) || /<\/?[a-z][^>]*>/i.test(T) && /AIMDINLINETEMPLATE[0-9a-f]+TOKEN/.test(T);
1781
- }
1782
- function F(T, $) {
1783
- const N = wt(St(T));
1784
- return x(N) ? $ : N;
1785
- }
1786
- function j(T) {
1787
- return /\{\{(?:var_table|var|quiz|step|check|ref_step|ref_var|ref_fig|cite|fig)\|/.test(T) || /```(?:quiz|fig|assigner|connectors)\b/.test(T);
1788
- }
1789
- function H() {
1790
- if (m.value)
1791
- try {
1792
- const T = m.value.action(tt());
1793
- if (typeof T != "string")
1794
- return;
1795
- const $ = F(T, u.value);
1796
- m.value.action(Ve(_($)));
1797
- } catch {
1798
- }
1799
- }
1800
- const w = U(() => {
1801
- try {
1802
- return Bt(u.value);
1803
- } catch {
1804
- return null;
1805
- }
1806
- });
1807
- async function g(T) {
1808
- if (T !== f.value) {
1809
- if (f.value === "source" && l.value && (u.value = l.value.getValue()), f.value === "wysiwyg" && m.value)
1810
- try {
1811
- const $ = m.value.action(tt());
1812
- typeof $ == "string" && (u.value = F($, u.value));
1813
- } catch {
1814
- }
1815
- if (f.value = T, d(T), T === "source")
1816
- await Ee(), l.value && (y = !0, l.value.setValue(u.value), y = !1);
1817
- else if (T === "wysiwyg" && (await Ee(), m.value))
1818
- try {
1819
- y = !0, m.value.action(Ve(_(u.value))), y = !1;
1820
- } catch {
1821
- y = !1;
1822
- }
1823
- }
1824
- }
1825
- function z(T) {
1826
- if (T !== u.value) {
1827
- if (y = !0, u.value = T, f.value === "source" && l.value)
1828
- l.value.setValue(T);
1829
- else if (f.value === "wysiwyg" && m.value)
1830
- try {
1831
- m.value.action(Ve(_(T)));
1832
- } catch {
1833
- }
1834
- y = !1;
1835
- }
1836
- }
1837
- function O(T) {
1838
- if (f.value === "source" && l.value) {
1839
- const $ = l.value.getSelection(), N = l.value.getModel(), Q = l.value.getPosition(), pe = N.getLineContent(Q.lineNumber).substring(0, Q.column - 1).trim() !== "" && !T.startsWith(`
1840
- `) ? `
1841
- ` + T : T;
1842
- l.value.executeEdits("toolbar", [{
1843
- range: $,
1844
- text: pe,
1845
- forceMoveMarkers: !0
1846
- }]), l.value.focus();
1847
- } else if (f.value === "wysiwyg" && m.value)
1848
- try {
1849
- m.value.action(Oe(T)), j(T) && H();
1850
- } catch {
1851
- }
1852
- }
1853
- function q(T, $ = "", N = "") {
1854
- if (f.value === "source" && l.value) {
1855
- const Q = l.value.getSelection(), W = l.value.getModel().getValueInRange(Q) || N, ee = T + W + $;
1856
- l.value.executeEdits("toolbar", [{
1857
- range: Q,
1858
- text: ee,
1859
- forceMoveMarkers: !0
1860
- }]), l.value.focus();
1861
- } else if (f.value === "wysiwyg" && m.value)
1862
- try {
1863
- m.value.action(Oe(T + N + $));
1864
- } catch {
1865
- }
1866
- }
1867
- function L(T, $ = "") {
1868
- if (f.value === "source" && l.value) {
1869
- const N = l.value.getPosition(), W = l.value.getModel().getLineContent(N.lineNumber);
1870
- if (W.trim() === "") {
1871
- const ee = { startLineNumber: N.lineNumber, startColumn: 1, endLineNumber: N.lineNumber, endColumn: W.length + 1 };
1872
- l.value.executeEdits("toolbar", [{ range: ee, text: T + $, forceMoveMarkers: !0 }]);
1873
- } else {
1874
- const ee = { startLineNumber: N.lineNumber, startColumn: W.length + 1, endLineNumber: N.lineNumber, endColumn: W.length + 1 };
1875
- l.value.executeEdits("toolbar", [{ range: ee, text: `
1876
- ` + T + $, forceMoveMarkers: !0 }]);
1877
- }
1878
- l.value.focus();
1879
- } else if (f.value === "wysiwyg" && m.value)
1880
- try {
1881
- m.value.action(Oe(`
1882
- ` + T + $));
1883
- } catch {
1884
- }
1885
- }
1886
- function R(T) {
1887
- const $ = o.value.snippets;
1888
- switch (T) {
1889
- case "h1":
1890
- L("# ", $.heading);
1891
- break;
1892
- case "h2":
1893
- L("## ", $.heading);
1894
- break;
1895
- case "h3":
1896
- L("### ", $.heading);
1897
- break;
1898
- case "bold":
1899
- q("**", "**", $.boldText);
1900
- break;
1901
- case "italic":
1902
- q("*", "*", $.italicText);
1903
- break;
1904
- case "strikethrough":
1905
- q("~~", "~~", $.strikethrough);
1906
- break;
1907
- case "ul":
1908
- L("- ", $.listItem);
1909
- break;
1910
- case "ol":
1911
- L("1. ", $.listItem);
1912
- break;
1913
- case "blockquote":
1914
- L("> ", $.quote);
1915
- break;
1916
- case "code":
1917
- q("`", "`", $.code);
1918
- break;
1919
- case "codeblock":
1920
- q("```\n", "\n```", $.codeBlock);
1921
- break;
1922
- case "link":
1923
- q("[", "](url)", $.linkText);
1924
- break;
1925
- case "image":
1926
- q("![", "](url)", $.altText);
1927
- break;
1928
- case "hr":
1929
- L("---");
1930
- break;
1931
- case "math":
1932
- q("$", "$", $.mathFormula);
1933
- break;
1934
- case "table":
1935
- if (f.value === "wysiwyg" && m.value)
1936
- try {
1937
- m.value.action(bt(Dt.key, { row: 3, col: 3 }));
1938
- } catch {
1939
- }
1940
- else
1941
- L(
1942
- `| ${$.tableColumnA} | ${$.tableColumnB} | ${$.tableColumnC} |
1943
- |-------|-------|-------|
1944
- | `,
1945
- " | | |"
1946
- );
1947
- break;
1948
- }
1949
- }
1950
- function K(T, $, N) {
1951
- y || I(F($, u.value));
1952
- }
1953
- function J(T) {
1954
- m.value = T;
1955
- }
1956
- return {
1957
- editorMode: f,
1958
- content: u,
1959
- commitUserContent: I,
1960
- monacoEditor: l,
1961
- monacoInstance: c,
1962
- monacoLoading: M,
1963
- milkdownEditorRef: m,
1964
- extractedFields: w,
1965
- toMilkdownMarkdown: _,
1966
- switchMode: g,
1967
- syncFromProp: z,
1968
- insertTextIntoActiveEditor: O,
1969
- handleMdAction: R,
1970
- onMilkdownMarkdownUpdated: K,
1971
- onMilkdownReady: J
1972
- };
1973
- }
1974
- const rn = { class: "aimd-editor" }, dn = {
1975
- key: 0,
1976
- class: "aimd-editor-mode-host"
1977
- }, cn = {
1978
- key: 1,
1979
- class: "aimd-editor-mode-host"
1980
- }, $n = /* @__PURE__ */ ie({
1981
- __name: "AimdEditor",
1982
- props: {
1983
- modelValue: { default: "" },
1984
- locale: {},
1985
- messages: { default: () => ({}) },
1986
- mode: { default: "source" },
1987
- fieldDisplay: { default: "detailed" },
1988
- theme: { default: "aimd-light" },
1989
- showTopBar: { type: Boolean, default: !0 },
1990
- showToolbar: { type: Boolean, default: !0 },
1991
- showAimdToolbar: { type: Boolean, default: !0 },
1992
- showMdToolbar: { type: Boolean, default: !0 },
1993
- imageToolbarAction: { default: "markdown" },
1994
- enableBlockHandle: { type: Boolean, default: !0 },
1995
- enableSlashMenu: { type: Boolean, default: !0 },
1996
- keepInactiveEditorsMounted: { type: Boolean, default: !0 },
1997
- minHeight: { default: 500 },
1998
- readonly: { type: Boolean, default: !1 },
1999
- monacoOptions: { default: () => ({}) },
2000
- varTypePlugins: {}
2001
- },
2002
- emits: ["update:modelValue", "update:mode", "ready", "request-image"],
2003
- setup(e, { expose: n, emit: t }) {
2004
- const o = e, a = t, d = U(() => Mt(o.locale, o.messages)), {
2005
- editorMode: f,
2006
- content: u,
2007
- commitUserContent: l,
2008
- monacoEditor: c,
2009
- monacoInstance: M,
2010
- milkdownEditorRef: m,
2011
- extractedFields: y,
2012
- toMilkdownMarkdown: I,
2013
- switchMode: _,
2014
- syncFromProp: x,
2015
- insertTextIntoActiveEditor: F,
2016
- handleMdAction: j,
2017
- onMilkdownMarkdownUpdated: H,
2018
- onMilkdownReady: w
2019
- } = un({
2020
- initialContent: o.modelValue,
2021
- initialMode: o.mode,
2022
- resolvedMessages: d,
2023
- emitModelValue: (s) => a("update:modelValue", s),
2024
- emitMode: (s) => a("update:mode", s)
2025
- });
2026
- Z(() => o.modelValue, (s) => x(s)), Z(() => o.mode, (s) => {
2027
- s !== f.value && _(s);
2028
- });
2029
- const g = C(o.theme), z = U(() => o.keepInactiveEditorsMounted || f.value === "source"), O = U(() => o.keepInactiveEditorsMounted || f.value === "wysiwyg"), q = U(() => rt(d.value)), L = U(() => _t(d.value)), R = C(!1), K = C("var"), J = C(!1), T = C("str"), $ = C(), N = C(!1), Q = C("step"), W = C();
2030
- function ee(s) {
2031
- o.readonly || (Q.value = "step", W.value = s, N.value = !0);
2032
- }
2033
- function xe(s) {
2034
- o.readonly || (Q.value = "check", W.value = s, N.value = !0);
2035
- }
2036
- function pe(s) {
2037
- o.readonly || (W.value ? W.value.apply(s) : F(`{{${Q.value}|${s}}}${Q.value === "step" ? `
2038
-
2039
- ` : " "}`));
2040
- }
2041
- function De(s) {
2042
- o.readonly || ($.value = s, J.value = !0);
2043
- }
2044
- function $e(s) {
2045
- o.readonly || ($.value ? $.value.apply(s) : F(`{{var|${s}}}`));
2046
- }
2047
- const qe = U(() => {
2048
- const s = y.value;
2049
- if (!s) return [];
2050
- const k = K.value;
2051
- return k === "ref_step" ? s.step || [] : k === "ref_var" ? s.var || [] : k === "ref_fig" ? s.ref_fig || [] : [];
2052
- }), Pe = U(() => {
2053
- const s = y.value;
2054
- return s?.quiz ? s.quiz.map((k) => k.id) : [];
2055
- });
2056
- function Ie(s) {
2057
- if (!o.readonly) {
2058
- if (s === "step" || s === "check") {
2059
- Q.value = s, W.value = void 0, N.value = !0;
2060
- return;
2061
- }
2062
- if (s === "var") {
2063
- Fe("str");
2064
- return;
2065
- }
2066
- K.value = s, R.value = !0;
2067
- }
2068
- }
2069
- function Fe(s) {
2070
- o.readonly || ($.value = void 0, T.value = s, J.value = !0);
2071
- }
2072
- function Ue(s) {
2073
- if (!o.readonly) {
2074
- if (s === "step") {
2075
- F(`{{step|${ve(fe(u.value), "step")}, check=True}}
2076
-
2077
- `);
2078
- return;
2079
- }
2080
- if (s === "var") {
2081
- const k = ve(fe(u.value));
2082
- F(`{{var|${k}: str}}`);
2083
- return;
2084
- }
2085
- F(Ct(s, d.value));
2086
- }
2087
- }
2088
- function Le(s) {
2089
- F(s);
2090
- }
2091
- function ge(s) {
2092
- if (!(s instanceof HTMLElement)) return;
2093
- const k = s.getBoundingClientRect();
2094
- return {
2095
- top: k.top,
2096
- right: k.right,
2097
- bottom: k.bottom,
2098
- left: k.left,
2099
- width: k.width,
2100
- height: k.height
2101
- };
2102
- }
2103
- function he(s, k) {
2104
- if (s === "image" && o.imageToolbarAction === "custom") {
2105
- a("request-image", { buttonRect: ge(k.currentTarget) });
2106
- return;
2107
- }
2108
- j(s);
2109
- }
2110
- const Ne = C(null), Re = C(null);
2111
- function He(s) {
2112
- l(s);
2113
- }
2114
- function ye(s) {
2115
- a("ready", { monaco: s });
2116
- }
2117
- function p(s, k) {
2118
- M.value = s, c.value = k;
2119
- }
2120
- function r(s) {
2121
- w(s), a("ready", { milkdown: s });
2122
- }
2123
- return n({
2124
- getContent: () => u.value,
2125
- setContent: (s) => {
2126
- if (u.value = s, f.value === "source" && c.value)
2127
- c.value.setValue(s);
2128
- else if (m.value)
2129
- try {
2130
- m.value.action(Ve(I(s)));
2131
- } catch {
2132
- }
2133
- },
2134
- getMode: () => f.value,
2135
- setMode: (s) => _(s),
2136
- getMonacoEditor: () => c.value,
2137
- getMilkdownEditor: () => m.value,
2138
- insertText: F
2139
- }), (s, k) => (h(), b("div", rn, [
2140
- e.showToolbar ? (h(), ue(an, {
2141
- key: 0,
2142
- "show-top-bar": e.showTopBar,
2143
- "show-md-toolbar": e.showMdToolbar,
2144
- "show-aimd-toolbar": e.showAimdToolbar,
2145
- "editor-mode": X(f),
2146
- "resolved-messages": d.value,
2147
- "localized-field-types": q.value,
2148
- "localized-md-toolbar-items": L.value,
2149
- onSwitchMode: X(_),
2150
- onMdAction: he,
2151
- onOpenAimdDialog: Ie,
2152
- onQuickInsertAimd: Ue,
2153
- onInsertInput: Fe
2154
- }, null, 8, ["show-top-bar", "show-md-toolbar", "show-aimd-toolbar", "editor-mode", "resolved-messages", "localized-field-types", "localized-md-toolbar-items", "onSwitchMode"])) : B("", !0),
2155
- i("div", {
2156
- class: "aimd-editor-panel",
2157
- style: _e({ minHeight: e.minHeight + "px" })
2158
- }, [
2159
- z.value ? A((h(), b("div", dn, [
2160
- te(Vt, {
2161
- ref_key: "sourceEditorRef",
2162
- ref: Ne,
2163
- content: X(u),
2164
- theme: g.value,
2165
- "min-height": e.minHeight,
2166
- readonly: e.readonly,
2167
- "monaco-options": e.monacoOptions,
2168
- "resolved-messages": d.value,
2169
- onContentChange: He,
2170
- onReady: ye,
2171
- onMonacoLoaded: p
2172
- }, null, 8, ["content", "theme", "min-height", "readonly", "monaco-options", "resolved-messages"])
2173
- ], 512)), [
2174
- [et, X(f) === "source"]
2175
- ]) : B("", !0),
2176
- O.value ? A((h(), b("div", cn, [
2177
- te(Tt, {
2178
- ref_key: "wysiwygEditorRef",
2179
- ref: Re,
2180
- content: X(u),
2181
- "min-height": e.minHeight,
2182
- "enable-block-handle": e.enableBlockHandle,
2183
- active: X(f) === "wysiwyg",
2184
- "resolved-messages": d.value,
2185
- "localized-field-types": q.value,
2186
- "field-display": e.fieldDisplay,
2187
- "edit-input-fields": !0,
2188
- readonly: e.readonly,
2189
- onMarkdownUpdated: X(H),
2190
- onReady: r,
2191
- onOpenAimdDialog: Ie,
2192
- onEditInput: De,
2193
- onEditStep: ee,
2194
- onEditCheck: xe
2195
- }, null, 8, ["content", "min-height", "enable-block-handle", "active", "resolved-messages", "localized-field-types", "field-display", "readonly", "onMarkdownUpdated"])
2196
- ], 512)), [
2197
- [et, X(f) === "wysiwyg"]
2198
- ]) : B("", !0)
2199
- ], 4),
2200
- te(fi, {
2201
- visible: N.value,
2202
- "onUpdate:visible": k[0] || (k[0] = (V) => N.value = V),
2203
- "field-type": Q.value,
2204
- content: X(u),
2205
- "field-content": W.value?.content,
2206
- messages: d.value,
2207
- onSave: pe
2208
- }, null, 8, ["visible", "field-type", "content", "field-content", "messages"]),
2209
- te(ti, {
2210
- visible: J.value,
2211
- "onUpdate:visible": k[1] || (k[1] = (V) => J.value = V),
2212
- content: X(u),
2213
- "field-content": $.value?.content,
2214
- "initial-preset": T.value,
2215
- "var-type-plugins": e.varTypePlugins,
2216
- messages: d.value,
2217
- onSave: $e
2218
- }, null, 8, ["visible", "content", "field-content", "initial-preset", "var-type-plugins", "messages"]),
2219
- te(js, {
2220
- visible: R.value,
2221
- "initial-type": K.value,
2222
- messages: d.value,
2223
- "ref-suggestions": qe.value,
2224
- "var-type-plugins": e.varTypePlugins,
2225
- "existing-quiz-ids": Pe.value,
2226
- "onUpdate:visible": k[2] || (k[2] = (V) => R.value = V),
2227
- onInsert: Le
2228
- }, null, 8, ["visible", "initial-type", "messages", "ref-suggestions", "var-type-plugins", "existing-quiz-ids"])
2229
- ]));
2230
- }
2231
- }), mn = { class: "aimd-editor-mode-switch" }, vn = ["title"], fn = ["innerHTML"], pn = ["title"], gn = ["innerHTML"], In = /* @__PURE__ */ ie({
2232
- __name: "AimdEditorTopBar",
2233
- props: {
2234
- editorMode: {},
2235
- resolvedMessages: {}
2236
- },
2237
- emits: ["switch-mode"],
2238
- setup(e, { emit: n }) {
2239
- const t = n, o = {
2240
- source: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',
2241
- wysiwyg: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'
2242
- };
2243
- return (a, d) => (h(), b("div", mn, [
2244
- i("button", {
2245
- class: ae(["aimd-editor-mode-btn", { active: e.editorMode === "source" }]),
2246
- onClick: d[0] || (d[0] = (f) => t("switch-mode", "source")),
2247
- title: e.resolvedMessages.mode.sourceTitle
2248
- }, [
2249
- i("span", {
2250
- class: "aimd-editor-mode-icon",
2251
- innerHTML: o.source
2252
- }, null, 8, fn),
2253
- i("span", null, v(e.resolvedMessages.mode.source), 1)
2254
- ], 10, vn),
2255
- i("button", {
2256
- class: ae(["aimd-editor-mode-btn", { active: e.editorMode === "wysiwyg" }]),
2257
- onClick: d[1] || (d[1] = (f) => t("switch-mode", "wysiwyg")),
2258
- title: e.resolvedMessages.mode.wysiwygTitle
2259
- }, [
2260
- i("span", {
2261
- class: "aimd-editor-mode-icon",
2262
- innerHTML: o.wysiwyg
2263
- }, null, 8, gn),
2264
- i("span", null, v(e.resolvedMessages.mode.wysiwyg), 1)
2265
- ], 10, pn)
2266
- ]));
2267
- }
2268
- });
2269
- export {
2270
- ti as A,
2271
- $n as _,
2272
- an as a,
2273
- In as b,
2274
- js as c,
2275
- fi as d,
2276
- un as u
2277
- };