@airalogy/aimd-renderer 2.6.0 → 2.7.0
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/README.md +38 -0
- package/README.zh-CN.md +38 -0
- package/dist/aimd-renderer.css +1 -1
- package/dist/common/criticMarkup.d.ts +10 -0
- package/dist/common/criticMarkup.d.ts.map +1 -0
- package/dist/common/processor.d.ts.map +1 -1
- package/dist/html.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +80 -73
- package/dist/{processor-CHbNEcN8.js → processor-BOCQYqXE.js} +1899 -1573
- package/dist/readonly-record-renderer-CkzY7UvT.js +711 -0
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/readonly-record-renderer.d.ts +42 -0
- package/dist/vue/readonly-record-renderer.d.ts.map +1 -0
- package/dist/vue.js +20 -13
- package/package.json +2 -2
- package/src/__tests__/renderer.test.ts +244 -1
- package/src/common/criticMarkup.ts +97 -0
- package/src/common/processor.ts +13 -2
- package/src/index.ts +18 -0
- package/src/styles/katex.css +65 -0
- package/src/vue/index.ts +18 -0
- package/src/vue/readonly-record-renderer.ts +747 -0
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
import { s as T, t as D } from "./processor-BOCQYqXE.js";
|
|
2
|
+
import { defineComponent as B, shallowRef as G, ref as $, watch as K, h as d } from "vue";
|
|
3
|
+
const F = ["var", "var_table", "step", "check", "quiz"], Y = {
|
|
4
|
+
file: "FILE",
|
|
5
|
+
image: "IMG",
|
|
6
|
+
audio: "AUD",
|
|
7
|
+
video: "VID",
|
|
8
|
+
csv: "CSV",
|
|
9
|
+
text: "TXT",
|
|
10
|
+
document: "DOC"
|
|
11
|
+
}, N = {
|
|
12
|
+
csv: "csv",
|
|
13
|
+
png: "image",
|
|
14
|
+
jpg: "image",
|
|
15
|
+
jpeg: "image",
|
|
16
|
+
svg: "image",
|
|
17
|
+
webp: "image",
|
|
18
|
+
tif: "image",
|
|
19
|
+
tiff: "image",
|
|
20
|
+
mp3: "audio",
|
|
21
|
+
wav: "audio",
|
|
22
|
+
m4a: "audio",
|
|
23
|
+
mp4: "video",
|
|
24
|
+
mov: "video",
|
|
25
|
+
webm: "video",
|
|
26
|
+
aimd: "text",
|
|
27
|
+
md: "text",
|
|
28
|
+
txt: "text",
|
|
29
|
+
json: "text",
|
|
30
|
+
pdf: "document",
|
|
31
|
+
docx: "document",
|
|
32
|
+
xlsx: "document",
|
|
33
|
+
pptx: "document"
|
|
34
|
+
}, U = {
|
|
35
|
+
csv: "text/csv",
|
|
36
|
+
png: "image/png",
|
|
37
|
+
jpg: "image/jpeg",
|
|
38
|
+
jpeg: "image/jpeg",
|
|
39
|
+
svg: "image/svg+xml",
|
|
40
|
+
webp: "image/webp",
|
|
41
|
+
tif: "image/tiff",
|
|
42
|
+
tiff: "image/tiff",
|
|
43
|
+
mp3: "audio/mpeg",
|
|
44
|
+
wav: "audio/wav",
|
|
45
|
+
m4a: "audio/mp4",
|
|
46
|
+
mp4: "video/mp4",
|
|
47
|
+
mov: "video/quicktime",
|
|
48
|
+
webm: "video/webm",
|
|
49
|
+
md: "text/markdown",
|
|
50
|
+
txt: "text/plain",
|
|
51
|
+
aimd: "text/plain",
|
|
52
|
+
json: "application/json",
|
|
53
|
+
pdf: "application/pdf",
|
|
54
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
55
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
56
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
57
|
+
}, X = {
|
|
58
|
+
file: { kind: "file", badge: "FILE" },
|
|
59
|
+
upload: { kind: "file", badge: "FILE" },
|
|
60
|
+
csv: { kind: "csv", accept: ".csv,text/csv", badge: "CSV" },
|
|
61
|
+
fileidcsv: { kind: "csv", accept: ".csv,text/csv", badge: "CSV" },
|
|
62
|
+
image: { kind: "image", accept: "image/*", badge: "IMG" },
|
|
63
|
+
fileidpng: { kind: "image", accept: ".png,image/png", badge: "IMG" },
|
|
64
|
+
fileidjpg: { kind: "image", accept: ".jpg,.jpeg,image/jpeg", badge: "IMG" },
|
|
65
|
+
fileidjpeg: { kind: "image", accept: ".jpg,.jpeg,image/jpeg", badge: "IMG" },
|
|
66
|
+
fileidsvg: { kind: "image", accept: ".svg,image/svg+xml", badge: "IMG" },
|
|
67
|
+
fileidwebp: { kind: "image", accept: ".webp,image/webp", badge: "IMG" },
|
|
68
|
+
fileidtiff: { kind: "image", accept: ".tif,.tiff,image/tiff", badge: "IMG" },
|
|
69
|
+
audio: { kind: "audio", accept: "audio/*", badge: "AUD" },
|
|
70
|
+
fileidmp3: { kind: "audio", accept: ".mp3,audio/mpeg", badge: "AUD" },
|
|
71
|
+
video: { kind: "video", accept: "video/*", badge: "VID" },
|
|
72
|
+
fileidmp4: { kind: "video", accept: ".mp4,video/mp4", badge: "VID" },
|
|
73
|
+
fileidaimd: { kind: "text", accept: ".aimd,text/plain", badge: "AIMD" },
|
|
74
|
+
fileidmd: { kind: "text", accept: ".md,text/markdown,text/plain", badge: "MD" },
|
|
75
|
+
fileidtxt: { kind: "text", accept: ".txt,text/plain", badge: "TXT" },
|
|
76
|
+
fileidjson: { kind: "text", accept: ".json,application/json", badge: "JSON" },
|
|
77
|
+
fileiddocx: { kind: "document", accept: ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document", badge: "DOC" },
|
|
78
|
+
fileidxlsx: { kind: "document", accept: ".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", badge: "XLS" },
|
|
79
|
+
fileidpptx: { kind: "document", accept: ".pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation", badge: "PPT" },
|
|
80
|
+
fileidpdf: { kind: "document", accept: ".pdf,application/pdf", badge: "PDF" }
|
|
81
|
+
}, Q = /^airalogy\.id\.file\.[^\s]+$/i, J = ["id", "file_id", "fileId", "src"], _ = ["id", "file_id", "fileId", "blob_id", "blobId", "src", "url", "href"];
|
|
82
|
+
function s(e) {
|
|
83
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
84
|
+
}
|
|
85
|
+
function M(e, i = "str") {
|
|
86
|
+
return typeof e != "string" ? i : e.trim().toLowerCase().replace(/[^a-z0-9]/g, "") || i;
|
|
87
|
+
}
|
|
88
|
+
function f(e) {
|
|
89
|
+
return M(e, "");
|
|
90
|
+
}
|
|
91
|
+
function u(e) {
|
|
92
|
+
return typeof e == "string" && e.trim() ? e.trim() : void 0;
|
|
93
|
+
}
|
|
94
|
+
function j(e, i) {
|
|
95
|
+
if (e)
|
|
96
|
+
for (const t of i) {
|
|
97
|
+
const n = u(e[t]);
|
|
98
|
+
if (n)
|
|
99
|
+
return n;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function Z(e) {
|
|
103
|
+
return s(e) && s(e.data) ? e.data : e;
|
|
104
|
+
}
|
|
105
|
+
function k(e) {
|
|
106
|
+
return s(e) && "value" in e ? e.value : e;
|
|
107
|
+
}
|
|
108
|
+
function H(e) {
|
|
109
|
+
const i = Z(e), t = {};
|
|
110
|
+
if (!s(i))
|
|
111
|
+
return t;
|
|
112
|
+
for (const n of F) {
|
|
113
|
+
const r = i[n];
|
|
114
|
+
t[n] = s(r) ? { ...r } : {};
|
|
115
|
+
}
|
|
116
|
+
return t;
|
|
117
|
+
}
|
|
118
|
+
function y(e) {
|
|
119
|
+
return k(e);
|
|
120
|
+
}
|
|
121
|
+
function g(e) {
|
|
122
|
+
const i = y(e);
|
|
123
|
+
if (i == null)
|
|
124
|
+
return "";
|
|
125
|
+
if (typeof i == "string")
|
|
126
|
+
return i;
|
|
127
|
+
if (typeof i == "number" || typeof i == "boolean")
|
|
128
|
+
return String(i);
|
|
129
|
+
if (Array.isArray(i))
|
|
130
|
+
return i.map((t) => g(t)).filter(Boolean).join(", ");
|
|
131
|
+
try {
|
|
132
|
+
return JSON.stringify(i, null, 2);
|
|
133
|
+
} catch {
|
|
134
|
+
return String(i);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function S(e) {
|
|
138
|
+
const i = y(e);
|
|
139
|
+
if (typeof i == "boolean") return i;
|
|
140
|
+
if (typeof i == "number") return i !== 0;
|
|
141
|
+
if (typeof i == "string") {
|
|
142
|
+
const t = i.trim().toLowerCase();
|
|
143
|
+
if (t === "" || t === "false" || t === "0" || t === "no" || t === "off")
|
|
144
|
+
return !1;
|
|
145
|
+
if (t === "true" || t === "1" || t === "yes" || t === "on")
|
|
146
|
+
return !0;
|
|
147
|
+
}
|
|
148
|
+
return !!i;
|
|
149
|
+
}
|
|
150
|
+
function v(e) {
|
|
151
|
+
if (typeof e != "string")
|
|
152
|
+
return;
|
|
153
|
+
const i = e.trim().toLowerCase();
|
|
154
|
+
if (!(!i || i === "*"))
|
|
155
|
+
return i.replace(/^\./, "");
|
|
156
|
+
}
|
|
157
|
+
function O(e, i) {
|
|
158
|
+
const t = v(i?.fileExtension);
|
|
159
|
+
return t || (v(e?.file_extension) ?? v(e?.fileExtension) ?? v(e?.extension));
|
|
160
|
+
}
|
|
161
|
+
function z(e) {
|
|
162
|
+
const i = u(e);
|
|
163
|
+
if (!i)
|
|
164
|
+
return;
|
|
165
|
+
const n = (i.split(/[?#]/, 1)[0] ?? i).match(/\.([A-Za-z0-9]+)$/);
|
|
166
|
+
return v(n?.[1]);
|
|
167
|
+
}
|
|
168
|
+
function h(e) {
|
|
169
|
+
const i = v(e);
|
|
170
|
+
return i ? N[i] : void 0;
|
|
171
|
+
}
|
|
172
|
+
function ee(e) {
|
|
173
|
+
const i = f(e);
|
|
174
|
+
if (!i.startsWith("fileid") || i.length <= 6)
|
|
175
|
+
return;
|
|
176
|
+
const t = v(i.slice(6));
|
|
177
|
+
if (t)
|
|
178
|
+
return N[t] || U[t] ? t : void 0;
|
|
179
|
+
}
|
|
180
|
+
function ie(e) {
|
|
181
|
+
if (!e)
|
|
182
|
+
return;
|
|
183
|
+
const i = e.toLowerCase();
|
|
184
|
+
if (i.startsWith("image/")) return "image";
|
|
185
|
+
if (i.startsWith("audio/")) return "audio";
|
|
186
|
+
if (i.startsWith("video/")) return "video";
|
|
187
|
+
if (i.includes("csv")) return "csv";
|
|
188
|
+
if (i.startsWith("text/") || i.includes("json") || i.includes("markdown")) return "text";
|
|
189
|
+
if (i.includes("pdf") || i.includes("word") || i.includes("spreadsheet") || i.includes("presentation")) return "document";
|
|
190
|
+
}
|
|
191
|
+
function te(e, i, t) {
|
|
192
|
+
const n = f(i?.input_type ?? i?.inputType), r = f(e), a = n || r;
|
|
193
|
+
if (!a)
|
|
194
|
+
return;
|
|
195
|
+
if (a === "image" || a.startsWith("fileidpng") || a.startsWith("fileidjpg") || a.startsWith("fileidjpeg") || a.startsWith("fileidsvg") || a.startsWith("fileidwebp") || a.startsWith("fileidtiff"))
|
|
196
|
+
return "image";
|
|
197
|
+
if (a === "audio" || a.startsWith("fileidmp3"))
|
|
198
|
+
return "audio";
|
|
199
|
+
if (a === "video" || a.startsWith("fileidmp4"))
|
|
200
|
+
return "video";
|
|
201
|
+
if (a === "csv" || a.startsWith("fileidcsv"))
|
|
202
|
+
return "csv";
|
|
203
|
+
if (a.startsWith("fileidmd") || a.startsWith("fileidtxt") || a.startsWith("fileidjson") || a.startsWith("fileidaimd"))
|
|
204
|
+
return "text";
|
|
205
|
+
if (a.startsWith("fileidpdf") || a.startsWith("fileiddocx") || a.startsWith("fileidxlsx") || a.startsWith("fileidpptx"))
|
|
206
|
+
return "document";
|
|
207
|
+
const o = ee(a), l = h(o);
|
|
208
|
+
return l || (a === "file" || a === "upload" || a.startsWith("fileid") ? "file" : h(O(i, t)));
|
|
209
|
+
}
|
|
210
|
+
function V(e) {
|
|
211
|
+
return e ? !!X[e] || e.startsWith("fileid") : !1;
|
|
212
|
+
}
|
|
213
|
+
function ne(e, i, t) {
|
|
214
|
+
const n = M(e), r = f(t?.inputType);
|
|
215
|
+
return V(n) || V(r) || !!O(i, t) || !!u(t?.accept);
|
|
216
|
+
}
|
|
217
|
+
function b(e, i = J) {
|
|
218
|
+
const t = k(e);
|
|
219
|
+
if (typeof t == "string")
|
|
220
|
+
return t.trim() || void 0;
|
|
221
|
+
if (s(t))
|
|
222
|
+
return j(t, i);
|
|
223
|
+
}
|
|
224
|
+
function C(e) {
|
|
225
|
+
return typeof e == "string" && Q.test(e);
|
|
226
|
+
}
|
|
227
|
+
function re(e, i, t = {}) {
|
|
228
|
+
const n = u(i?.name ?? i?.filename ?? i?.downloadName);
|
|
229
|
+
if (n)
|
|
230
|
+
return n;
|
|
231
|
+
const r = k(e);
|
|
232
|
+
return typeof r == "string" ? t.hideAiralogyFileIds && C(r) ? "" : r : s(r) ? j(r, t.keys ?? [
|
|
233
|
+
"name",
|
|
234
|
+
"fileName",
|
|
235
|
+
"file_name",
|
|
236
|
+
"filename",
|
|
237
|
+
"originalName",
|
|
238
|
+
"original_name",
|
|
239
|
+
"id",
|
|
240
|
+
"file_id",
|
|
241
|
+
"blob_id",
|
|
242
|
+
"src",
|
|
243
|
+
"url"
|
|
244
|
+
]) ?? "" : "";
|
|
245
|
+
}
|
|
246
|
+
function ae(e, i, t, n, r) {
|
|
247
|
+
return e?.kind ?? ie(e?.mimeType) ?? te(t, n, r) ?? h(z(e?.filename ?? e?.name ?? e?.downloadName)) ?? h(z(b(i, _))) ?? "file";
|
|
248
|
+
}
|
|
249
|
+
function de(e) {
|
|
250
|
+
return !!(e && /^(blob:|data:|https?:|file:|\/|\.\/|\.\.\/)/i.test(e));
|
|
251
|
+
}
|
|
252
|
+
function I(e) {
|
|
253
|
+
return e?.url ? e.url : de(e?.href) ? e?.href : void 0;
|
|
254
|
+
}
|
|
255
|
+
function oe(e, i, t) {
|
|
256
|
+
const n = f(i?.input_type ?? i?.inputType) || f(e);
|
|
257
|
+
return n === "md" || n === "markdown" || n === "airalogymarkdown";
|
|
258
|
+
}
|
|
259
|
+
function le(e, i, t) {
|
|
260
|
+
const n = f(i?.input_type ?? i?.inputType) || f(e);
|
|
261
|
+
return n === "code" || n === "codestr" || n === "pystr" || n === "pythoncode" || n === "javascriptcode";
|
|
262
|
+
}
|
|
263
|
+
function ce(e, i, t) {
|
|
264
|
+
const n = f(i?.input_type ?? i?.inputType) || f(e);
|
|
265
|
+
return n === "dna" || n === "dnasequence";
|
|
266
|
+
}
|
|
267
|
+
function se(e, i, t) {
|
|
268
|
+
const n = f(i?.input_type ?? i?.inputType) || f(e);
|
|
269
|
+
return n === "bool" || n === "boolean" || n === "checkbox";
|
|
270
|
+
}
|
|
271
|
+
const je = F;
|
|
272
|
+
function E(e, i) {
|
|
273
|
+
return `data.${e}.${i}`;
|
|
274
|
+
}
|
|
275
|
+
function x(e) {
|
|
276
|
+
return (e.fieldType === "var" || e.fieldType === "var_table") && "definition" in e ? D(e.id, e.definition) : e.fieldType === "check" && "label" in e && typeof e.label == "string" && e.label.trim() ? e.label.trim() : e.fieldType === "quiz" && "title" in e && typeof e.title == "string" && e.title.trim() ? e.title.trim() : e.id;
|
|
277
|
+
}
|
|
278
|
+
function fe(e) {
|
|
279
|
+
const i = x(e), t = E(e.scope, e.id);
|
|
280
|
+
return i === e.id ? t : `${i} · ${t}`;
|
|
281
|
+
}
|
|
282
|
+
function m(e, i) {
|
|
283
|
+
const t = x(e);
|
|
284
|
+
return {
|
|
285
|
+
class: i,
|
|
286
|
+
title: fe(e),
|
|
287
|
+
"aria-label": t,
|
|
288
|
+
"data-aimd-type": e.fieldType,
|
|
289
|
+
"data-aimd-id": e.id,
|
|
290
|
+
"data-aimd-scope": e.scope,
|
|
291
|
+
"data-aimd-field-label": t
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
function ue(e) {
|
|
295
|
+
return {
|
|
296
|
+
type: "aimd",
|
|
297
|
+
fieldType: "fig",
|
|
298
|
+
scope: "fig",
|
|
299
|
+
id: e,
|
|
300
|
+
raw: e,
|
|
301
|
+
src: e
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function me(e, i, t, n) {
|
|
305
|
+
if (!n)
|
|
306
|
+
return;
|
|
307
|
+
const r = y(i), a = b(i, _);
|
|
308
|
+
return n({
|
|
309
|
+
fieldId: e.id,
|
|
310
|
+
fieldPath: E(e.scope, e.id),
|
|
311
|
+
scope: e.scope,
|
|
312
|
+
node: e,
|
|
313
|
+
value: i,
|
|
314
|
+
normalizedValue: r,
|
|
315
|
+
fileId: a,
|
|
316
|
+
recordValue: t
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function L(e, i, t, n) {
|
|
320
|
+
if (!t)
|
|
321
|
+
return;
|
|
322
|
+
const r = y(e), a = u(r), o = n ?? ue(a ?? "asset");
|
|
323
|
+
return t({
|
|
324
|
+
fieldId: o.id,
|
|
325
|
+
fieldPath: n ? E(n.scope, n.id) : a ?? "",
|
|
326
|
+
scope: o.scope,
|
|
327
|
+
node: o,
|
|
328
|
+
value: e,
|
|
329
|
+
normalizedValue: r,
|
|
330
|
+
fileId: a,
|
|
331
|
+
recordValue: i
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
function A(e) {
|
|
335
|
+
return d("span", m(e, "aimd-record-field aimd-record-field--empty"), [
|
|
336
|
+
d("span", { class: "aimd-record-field__missing-label" }, "Missing"),
|
|
337
|
+
d("span", { class: "aimd-record-field__missing-name" }, x(e))
|
|
338
|
+
]);
|
|
339
|
+
}
|
|
340
|
+
function W(e, i, t = "") {
|
|
341
|
+
const n = g(i);
|
|
342
|
+
return n ? d("span", m(
|
|
343
|
+
e,
|
|
344
|
+
["aimd-record-field", "aimd-record-field--scalar", t].filter(Boolean).join(" ")
|
|
345
|
+
), n) : A(e);
|
|
346
|
+
}
|
|
347
|
+
function pe(e, i) {
|
|
348
|
+
const t = S(i);
|
|
349
|
+
return d("span", m(e, "aimd-record-field aimd-record-field--boolean"), [
|
|
350
|
+
d("input", {
|
|
351
|
+
type: "checkbox",
|
|
352
|
+
checked: t,
|
|
353
|
+
disabled: !0,
|
|
354
|
+
class: "aimd-checkbox"
|
|
355
|
+
}),
|
|
356
|
+
d("span", { class: "aimd-record-field__value" }, t ? "Yes" : "No")
|
|
357
|
+
]);
|
|
358
|
+
}
|
|
359
|
+
const ge = B({
|
|
360
|
+
name: "ReadonlyRecordMarkdownValue",
|
|
361
|
+
props: {
|
|
362
|
+
content: {
|
|
363
|
+
type: String,
|
|
364
|
+
required: !0
|
|
365
|
+
},
|
|
366
|
+
fieldProps: {
|
|
367
|
+
type: Object,
|
|
368
|
+
required: !0
|
|
369
|
+
},
|
|
370
|
+
recordValue: {
|
|
371
|
+
type: Object,
|
|
372
|
+
default: void 0
|
|
373
|
+
},
|
|
374
|
+
resolveAsset: {
|
|
375
|
+
type: Function,
|
|
376
|
+
default: void 0
|
|
377
|
+
},
|
|
378
|
+
renderOptions: {
|
|
379
|
+
type: Object,
|
|
380
|
+
default: () => ({})
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
setup(e) {
|
|
384
|
+
const i = G([]), t = $("");
|
|
385
|
+
let n = 0;
|
|
386
|
+
async function r() {
|
|
387
|
+
const a = ++n;
|
|
388
|
+
t.value = "";
|
|
389
|
+
try {
|
|
390
|
+
const o = P({
|
|
391
|
+
resolveAsset: e.resolveAsset
|
|
392
|
+
}), l = await T(e.content, {
|
|
393
|
+
...e.renderOptions,
|
|
394
|
+
mode: "preview",
|
|
395
|
+
aimdRenderers: {
|
|
396
|
+
fig: q(e.resolveAsset)
|
|
397
|
+
},
|
|
398
|
+
elementRenderers: {
|
|
399
|
+
...o,
|
|
400
|
+
...e.renderOptions.elementRenderers ?? {}
|
|
401
|
+
},
|
|
402
|
+
context: {
|
|
403
|
+
mode: "preview",
|
|
404
|
+
readonly: !0,
|
|
405
|
+
value: e.recordValue,
|
|
406
|
+
quizPreview: e.renderOptions.quizPreview
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
if (a !== n)
|
|
410
|
+
return;
|
|
411
|
+
i.value = l.nodes;
|
|
412
|
+
} catch (o) {
|
|
413
|
+
if (a !== n)
|
|
414
|
+
return;
|
|
415
|
+
i.value = [], t.value = o instanceof Error ? o.message : String(o);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return K(
|
|
419
|
+
() => [e.content, e.recordValue, e.resolveAsset, e.renderOptions],
|
|
420
|
+
() => {
|
|
421
|
+
r();
|
|
422
|
+
},
|
|
423
|
+
{ immediate: !0 }
|
|
424
|
+
), () => t.value ? d("div", {
|
|
425
|
+
...e.fieldProps,
|
|
426
|
+
class: `${e.fieldProps.class ?? ""} aimd-record-field--markdown-error`,
|
|
427
|
+
"data-render-error": t.value
|
|
428
|
+
}, [
|
|
429
|
+
d("pre", { class: "aimd-record-field__markdown-fallback" }, e.content)
|
|
430
|
+
]) : d("div", e.fieldProps, i.value.length ? i.value : [d("pre", { class: "aimd-record-field__markdown-fallback" }, e.content)]);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
function ve(e, i, t, n, r) {
|
|
434
|
+
const a = g(i);
|
|
435
|
+
return a ? d(ge, {
|
|
436
|
+
content: a,
|
|
437
|
+
fieldProps: m(e, "aimd-record-field aimd-record-field--markdown"),
|
|
438
|
+
recordValue: t,
|
|
439
|
+
resolveAsset: n,
|
|
440
|
+
renderOptions: r
|
|
441
|
+
}) : A(e);
|
|
442
|
+
}
|
|
443
|
+
function ye(e, i, t) {
|
|
444
|
+
const n = u(t), r = g(i);
|
|
445
|
+
return r ? d("pre", m(e, "aimd-record-field aimd-record-field--code"), [
|
|
446
|
+
d("code", {
|
|
447
|
+
class: n ? `language-${n}` : void 0
|
|
448
|
+
}, r)
|
|
449
|
+
]) : A(e);
|
|
450
|
+
}
|
|
451
|
+
function _e(e, i) {
|
|
452
|
+
const t = y(i), n = s(t) ? u(t.sequence) ?? g(t) : g(t);
|
|
453
|
+
if (!n)
|
|
454
|
+
return A(e);
|
|
455
|
+
const r = s(t) ? u(t.name) : void 0;
|
|
456
|
+
return d("div", m(e, "aimd-record-field aimd-record-field--dna"), [
|
|
457
|
+
r ? d("div", { class: "aimd-record-field__label" }, r) : null,
|
|
458
|
+
d("pre", { class: "aimd-record-field__sequence" }, n)
|
|
459
|
+
]);
|
|
460
|
+
}
|
|
461
|
+
function be(e, i, t, n) {
|
|
462
|
+
if (!t && !b(i, _))
|
|
463
|
+
return A(e);
|
|
464
|
+
const r = I(t), a = t?.href ?? t?.url, o = re(i, t) || e.id, l = Y[n], c = {
|
|
465
|
+
...m(e, `aimd-record-field aimd-record-field--asset aimd-record-field--${n}`),
|
|
466
|
+
"data-aimd-file-id": b(i, _)
|
|
467
|
+
};
|
|
468
|
+
if (n === "image" && r)
|
|
469
|
+
return d("figure", c, [
|
|
470
|
+
d("img", {
|
|
471
|
+
src: r,
|
|
472
|
+
alt: o,
|
|
473
|
+
loading: "lazy",
|
|
474
|
+
class: "aimd-record-field__image"
|
|
475
|
+
}),
|
|
476
|
+
d("figcaption", { class: "aimd-record-field__caption" }, o)
|
|
477
|
+
]);
|
|
478
|
+
if (n === "audio" && r)
|
|
479
|
+
return d("div", c, [
|
|
480
|
+
d("audio", {
|
|
481
|
+
src: r,
|
|
482
|
+
controls: !0,
|
|
483
|
+
class: "aimd-record-field__audio"
|
|
484
|
+
}),
|
|
485
|
+
d("span", { class: "aimd-record-field__caption" }, o)
|
|
486
|
+
]);
|
|
487
|
+
if (n === "video" && r)
|
|
488
|
+
return d("figure", c, [
|
|
489
|
+
d("video", {
|
|
490
|
+
src: r,
|
|
491
|
+
controls: !0,
|
|
492
|
+
class: "aimd-record-field__video"
|
|
493
|
+
}),
|
|
494
|
+
d("figcaption", { class: "aimd-record-field__caption" }, o)
|
|
495
|
+
]);
|
|
496
|
+
const p = [
|
|
497
|
+
d("span", { class: "aimd-record-field__badge" }, l),
|
|
498
|
+
d("span", { class: "aimd-record-field__filename" }, o)
|
|
499
|
+
];
|
|
500
|
+
return a ? d("a", {
|
|
501
|
+
...c,
|
|
502
|
+
href: a,
|
|
503
|
+
download: t?.downloadName ?? t?.filename ?? t?.name ?? void 0
|
|
504
|
+
}, p) : d("span", {
|
|
505
|
+
...c,
|
|
506
|
+
class: `${c.class} aimd-record-field--asset-missing`
|
|
507
|
+
}, p);
|
|
508
|
+
}
|
|
509
|
+
function Ae() {
|
|
510
|
+
return [
|
|
511
|
+
{
|
|
512
|
+
kind: "file",
|
|
513
|
+
render: ({ node: e, definition: i, kwargs: t, value: n, asset: r, fileId: a }) => {
|
|
514
|
+
if (!ne(i?.type, t) && !r && !C(a))
|
|
515
|
+
return null;
|
|
516
|
+
const o = ae(r, n, i?.type, t);
|
|
517
|
+
return be(e, n, r, o);
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
kind: "boolean",
|
|
522
|
+
render: ({ node: e, definition: i, kwargs: t, value: n }) => se(i?.type, t) ? pe(e, n) : null
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
kind: "markdown",
|
|
526
|
+
render: ({ node: e, definition: i, kwargs: t, value: n, recordValue: r, resolveAsset: a, markdownRenderOptions: o }) => oe(i?.type, t) ? ve(e, n, r, a, o) : null
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
kind: "code",
|
|
530
|
+
render: ({ node: e, definition: i, kwargs: t, value: n }) => le(i?.type, t) ? ye(e, n, t?.language ?? t?.lang ?? t?.code_language ?? t?.codeLanguage) : null
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
kind: "dna",
|
|
534
|
+
render: ({ node: e, definition: i, kwargs: t, value: n }) => ce(i?.type, t) ? _e(e, n) : null
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
kind: "scalar",
|
|
538
|
+
render: ({ node: e, value: i }) => W(e, i)
|
|
539
|
+
}
|
|
540
|
+
];
|
|
541
|
+
}
|
|
542
|
+
const he = Ae();
|
|
543
|
+
function xe(e) {
|
|
544
|
+
for (const i of he) {
|
|
545
|
+
const t = i.render(e);
|
|
546
|
+
if (t)
|
|
547
|
+
return t;
|
|
548
|
+
}
|
|
549
|
+
return W(e.node, e.value);
|
|
550
|
+
}
|
|
551
|
+
function Re(e, i) {
|
|
552
|
+
return (t, n) => {
|
|
553
|
+
const r = t, a = r.definition, o = a?.kwargs, l = n.value?.var?.[t.id], c = me(t, l, n.value, e), p = b(l, _);
|
|
554
|
+
return xe({
|
|
555
|
+
node: t,
|
|
556
|
+
varNode: r,
|
|
557
|
+
definition: a,
|
|
558
|
+
kwargs: o,
|
|
559
|
+
value: l,
|
|
560
|
+
recordValue: n.value,
|
|
561
|
+
asset: c,
|
|
562
|
+
fileId: p,
|
|
563
|
+
resolveAsset: e,
|
|
564
|
+
markdownRenderOptions: i
|
|
565
|
+
});
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
function ke(e) {
|
|
569
|
+
const i = y(e);
|
|
570
|
+
return Array.isArray(i) ? i.filter((t) => s(t)).map((t) => ({ ...t })) : s(i) ? Object.values(i).filter((t) => s(t)).map((t) => ({ ...t })) : [];
|
|
571
|
+
}
|
|
572
|
+
function Ie() {
|
|
573
|
+
return (e, i) => {
|
|
574
|
+
const t = e, n = ke(i.value?.var?.[e.id] ?? i.value?.var_table?.[e.id]), r = t.columns.length ? t.columns : [...new Set(n.flatMap((o) => Object.keys(o)))], a = t.definition?.subvars;
|
|
575
|
+
return !r.length || !n.length ? d("div", m(e, "aimd-record-table aimd-record-table--empty"), [
|
|
576
|
+
d("span", { class: "aimd-record-field__missing-label" }, "Missing"),
|
|
577
|
+
d("span", { class: "aimd-record-field__missing-name" }, x(e))
|
|
578
|
+
]) : d("div", m(e, "aimd-record-table"), [
|
|
579
|
+
d("table", [
|
|
580
|
+
d("thead", [
|
|
581
|
+
d("tr", r.map((o) => d("th", {
|
|
582
|
+
"data-column-id": o,
|
|
583
|
+
title: o
|
|
584
|
+
}, D(o, a?.[o]))))
|
|
585
|
+
]),
|
|
586
|
+
d("tbody", n.map(
|
|
587
|
+
(o) => d("tr", r.map(
|
|
588
|
+
(l) => d("td", g(o[l]))
|
|
589
|
+
))
|
|
590
|
+
))
|
|
591
|
+
])
|
|
592
|
+
]);
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
function Ee() {
|
|
596
|
+
return (e, i, t) => {
|
|
597
|
+
const n = e, r = i.value?.check?.[e.id], a = s(r) && "checked" in r ? r.checked : r, o = S(a), l = n.label ?? e.id, c = t && t.length > 0 ? t : [l];
|
|
598
|
+
return d("label", m(e, "aimd-record-check"), [
|
|
599
|
+
d("input", {
|
|
600
|
+
type: "checkbox",
|
|
601
|
+
checked: o,
|
|
602
|
+
disabled: !0,
|
|
603
|
+
class: "aimd-checkbox"
|
|
604
|
+
}),
|
|
605
|
+
d("span", { class: "aimd-record-check__body" }, c)
|
|
606
|
+
]);
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
function we() {
|
|
610
|
+
return (e, i) => {
|
|
611
|
+
const t = e, n = i.value?.quiz?.[e.id], r = g(n);
|
|
612
|
+
return d("div", m(e, "aimd-record-quiz"), [
|
|
613
|
+
d("div", { class: "aimd-record-quiz__stem" }, t.stem || t.title || e.id),
|
|
614
|
+
r ? d("div", { class: "aimd-record-quiz__answer" }, r) : d("div", { class: "aimd-record-quiz__answer aimd-record-quiz__answer--empty" }, "No answer recorded")
|
|
615
|
+
]);
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
function ze(...e) {
|
|
619
|
+
const i = e.flatMap((t) => t ? Array.isArray(t) ? t.map((n) => String(n)).filter(Boolean) : String(t).split(/\s+/).filter(Boolean) : []);
|
|
620
|
+
return i.length ? [...new Set(i)].join(" ") : void 0;
|
|
621
|
+
}
|
|
622
|
+
function q(e) {
|
|
623
|
+
return (i, t) => {
|
|
624
|
+
const n = i, r = n.id || i.id, a = n.src || "", o = L(a, t.value, e, n), l = I(o) ?? a, c = n.title, p = n.legend, R = n.sequence, w = [
|
|
625
|
+
R !== void 0 || c ? d("div", { class: "aimd-figure__title" }, R !== void 0 ? t.messages.figure.captionTitle(R + 1, c) : c) : null,
|
|
626
|
+
p ? d("div", { class: "aimd-figure__legend" }, p) : null
|
|
627
|
+
].filter(Boolean);
|
|
628
|
+
return d("figure", {
|
|
629
|
+
class: "aimd-figure",
|
|
630
|
+
"data-aimd-type": "fig",
|
|
631
|
+
"data-aimd-fig-id": r,
|
|
632
|
+
"data-aimd-fig-src": a,
|
|
633
|
+
id: `fig-${r}`
|
|
634
|
+
}, [
|
|
635
|
+
d("img", {
|
|
636
|
+
class: "aimd-figure__image",
|
|
637
|
+
src: l,
|
|
638
|
+
alt: c || o?.name || o?.filename || r,
|
|
639
|
+
loading: "lazy"
|
|
640
|
+
}),
|
|
641
|
+
w.length ? d("figcaption", { class: "aimd-figure__caption" }, w) : null
|
|
642
|
+
]);
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
function Ve(e) {
|
|
646
|
+
return (i, t, n) => {
|
|
647
|
+
const r = i.properties ?? {}, a = u(r.src), o = L(a, n.value, e), l = I(o) ?? a, c = {
|
|
648
|
+
...r,
|
|
649
|
+
src: l,
|
|
650
|
+
alt: u(r.alt) ?? o?.name ?? o?.filename,
|
|
651
|
+
title: u(r.title),
|
|
652
|
+
loading: r.loading ?? "lazy",
|
|
653
|
+
class: ze("aimd-image", r.className, r.class)
|
|
654
|
+
};
|
|
655
|
+
return delete c.className, d("img", c);
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
function Te(e = {}) {
|
|
659
|
+
return {
|
|
660
|
+
var: Re(e.resolveAsset, e.markdownRenderOptions),
|
|
661
|
+
var_table: Ie(),
|
|
662
|
+
check: Ee(),
|
|
663
|
+
quiz: we(),
|
|
664
|
+
fig: q(e.resolveAsset)
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
function P(e = {}) {
|
|
668
|
+
return {
|
|
669
|
+
img: Ve(e.resolveAsset)
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
function De(e) {
|
|
673
|
+
return H(e);
|
|
674
|
+
}
|
|
675
|
+
function Fe(e, i) {
|
|
676
|
+
return {
|
|
677
|
+
...i ?? {},
|
|
678
|
+
mode: "edit",
|
|
679
|
+
readonly: !0,
|
|
680
|
+
value: De(e)
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
async function Se(e, i, t = {}) {
|
|
684
|
+
const { context: n, resolveAsset: r, aimdRenderers: a, elementRenderers: o, ...l } = t, c = Te({
|
|
685
|
+
resolveAsset: r,
|
|
686
|
+
markdownRenderOptions: {
|
|
687
|
+
...l,
|
|
688
|
+
elementRenderers: o
|
|
689
|
+
}
|
|
690
|
+
}), p = P({ resolveAsset: r });
|
|
691
|
+
return T(e, {
|
|
692
|
+
...l,
|
|
693
|
+
aimdRenderers: {
|
|
694
|
+
...c,
|
|
695
|
+
...a ?? {}
|
|
696
|
+
},
|
|
697
|
+
elementRenderers: {
|
|
698
|
+
...p,
|
|
699
|
+
...o ?? {}
|
|
700
|
+
},
|
|
701
|
+
context: Fe(i, n)
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
export {
|
|
705
|
+
je as A,
|
|
706
|
+
P as a,
|
|
707
|
+
Fe as b,
|
|
708
|
+
Te as c,
|
|
709
|
+
De as n,
|
|
710
|
+
Se as r
|
|
711
|
+
};
|