@airalogy/aimd-recorder 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.
Files changed (178) hide show
  1. package/README.md +240 -0
  2. package/README.zh-CN.md +224 -0
  3. package/dist/AimdCodeField-DC3DPvgc.js +172 -0
  4. package/dist/AimdDnaSequenceField-__jdnFS9.js +59466 -0
  5. package/dist/AimdEditor.vue_vue_type_style_index_0_lang-Bq79rKNw.js +28370 -0
  6. package/dist/AimdMarkdownField-98ImHGbc.js +66 -0
  7. package/dist/AimdMarkdownNoteField-CuUJZkgT.js +185 -0
  8. package/dist/_.contribution-IP0cDNhs.js +38 -0
  9. package/dist/_commonjsHelpers-CZXJ37nu.js +40 -0
  10. package/dist/abap-Bs8kvjsq.js +1398 -0
  11. package/dist/aimd-recorder.css +1 -0
  12. package/dist/apex-Dspwrl5m.js +326 -0
  13. package/dist/assets/css.worker-Dmf38jDD.js +79 -0
  14. package/dist/assets/editor.worker-CpuX8TSY.js +12 -0
  15. package/dist/assets/html.worker-DotaEs7v.js +456 -0
  16. package/dist/assets/json.worker-B4VHhH6h.js +44 -0
  17. package/dist/assets/ts.worker-sl17zBDo.js +51316 -0
  18. package/dist/azcli-k1BiOau1.js +68 -0
  19. package/dist/bat-BIP72KWc.js +100 -0
  20. package/dist/bicep-VhQeYhS3.js +102 -0
  21. package/dist/cameligo-DnuAXtHg.js +174 -0
  22. package/dist/clojure-BAuDPsal.js +761 -0
  23. package/dist/coffee-BV06qSnj.js +232 -0
  24. package/dist/components.js +3595 -0
  25. package/dist/composables.js +72 -0
  26. package/dist/cpp-Cz8Jeyrf.js +389 -0
  27. package/dist/csharp-F6hhlXFb.js +326 -0
  28. package/dist/csp-KzlEHCyI.js +53 -0
  29. package/dist/css-e4FKntZ3.js +187 -0
  30. package/dist/cssMode-uz9U6SUU.js +1571 -0
  31. package/dist/cypher-CpvDGKRr.js +263 -0
  32. package/dist/dart-DdHeFWR0.js +281 -0
  33. package/dist/dockerfile-aoNXDcio.js +130 -0
  34. package/dist/ecl-C4Q0DYuA.js +456 -0
  35. package/dist/editor.api-CgD9w0gG.js +77091 -0
  36. package/dist/editor.main-Du02abDl.js +33783 -0
  37. package/dist/elixir-C9X42b0T.js +569 -0
  38. package/dist/flow9-Bff42pfB.js +142 -0
  39. package/dist/freemarker2-DFLX4iQ-.js +989 -0
  40. package/dist/fsharp-C6vPAsHG.js +217 -0
  41. package/dist/go-DEr8zx9f.js +218 -0
  42. package/dist/graphql-BiNBBRFh.js +151 -0
  43. package/dist/handlebars-aiZbIuWY.js +419 -0
  44. package/dist/hcl-2T9lKuFg.js +183 -0
  45. package/dist/html-phzTMObN.js +308 -0
  46. package/dist/htmlMode-BF7wMi3N.js +1581 -0
  47. package/dist/index.js +89 -0
  48. package/dist/ini-CZGtssYM.js +71 -0
  49. package/dist/ini.contribution-DyWtiacL.js +8 -0
  50. package/dist/java-B260NeH3.js +232 -0
  51. package/dist/javascript-BKKOItMi.js +70 -0
  52. package/dist/jsonMode-CDYK4B5l.js +1996 -0
  53. package/dist/julia-kuNLM9c5.js +511 -0
  54. package/dist/kotlin-Bz6kAefA.js +253 -0
  55. package/dist/less-AZUtS89I.js +162 -0
  56. package/dist/lexon-BcmgnyRb.js +157 -0
  57. package/dist/liquid-B2eRz5SA.js +240 -0
  58. package/dist/lua-Dz1RbATg.js +162 -0
  59. package/dist/m3-CIMooLFn.js +210 -0
  60. package/dist/markdown-C1BsCK9P.js +229 -0
  61. package/dist/markdown.contribution-DYYk6zUU.js +7 -0
  62. package/dist/mdx-BfV1HDRG.js +165 -0
  63. package/dist/mips-BovsnfLQ.js +198 -0
  64. package/dist/monaco.contribution-C-bQhUTI.js +114 -0
  65. package/dist/monaco.contribution-CCVvl3Jx.js +72 -0
  66. package/dist/monaco.contribution-Col-f0XR.js +164 -0
  67. package/dist/monaco.contribution-b5xkgQ-s.js +112 -0
  68. package/dist/msdax-CiRB2ZB-.js +375 -0
  69. package/dist/mysql-BwdpPE19.js +878 -0
  70. package/dist/objective-c-D4nfHfso.js +183 -0
  71. package/dist/pascal--j5-PYtz.js +251 -0
  72. package/dist/pascaligo-C7TcJxNL.js +164 -0
  73. package/dist/perl-BzEWqUb5.js +626 -0
  74. package/dist/pgsql-B_KZ0mGX.js +851 -0
  75. package/dist/php-A19QHzQV.js +500 -0
  76. package/dist/pla-COeKY1hA.js +137 -0
  77. package/dist/postiats-BfMp7zJL.js +907 -0
  78. package/dist/powerquery-B0TS_5Gb.js +890 -0
  79. package/dist/powershell-5jSbKdYB.js +239 -0
  80. package/dist/protobuf-YgnOutn3.js +420 -0
  81. package/dist/pug-DLej6kn5.js +402 -0
  82. package/dist/python-CQrZx9mR.js +301 -0
  83. package/dist/python.contribution-CcKs2Ktm.js +8 -0
  84. package/dist/qsharp-AhjqtSHB.js +301 -0
  85. package/dist/r-D-F4P80w.js +243 -0
  86. package/dist/razor-DWmpHMcx.js +550 -0
  87. package/dist/redis-hwwIlMnV.js +302 -0
  88. package/dist/redshift-Bcm_kjEG.js +809 -0
  89. package/dist/restructuredtext-CrdzfPP-.js +174 -0
  90. package/dist/ruby-QC2UNm1s.js +511 -0
  91. package/dist/rust-5aqiQ3L5.js +343 -0
  92. package/dist/sb-B1g1ZfLJ.js +115 -0
  93. package/dist/scala-C2U4R5Gb.js +370 -0
  94. package/dist/scheme-DeFRbslr.js +108 -0
  95. package/dist/scss-RSTCiCmI.js +262 -0
  96. package/dist/shell-BpF-iNu8.js +221 -0
  97. package/dist/shell.contribution-B80NZ3iO.js +7 -0
  98. package/dist/solidity-C00r2mbQ.js +1367 -0
  99. package/dist/sophia-DVW5ZKDB.js +199 -0
  100. package/dist/sparql-B0nmpxeX.js +201 -0
  101. package/dist/sql-CJwKPERn.js +853 -0
  102. package/dist/sql.contribution-DQy36aE5.js +7 -0
  103. package/dist/st-DPlKG5DT.js +416 -0
  104. package/dist/swift-YZBAbVHV.js +309 -0
  105. package/dist/systemverilog-CDQSaH63.js +576 -0
  106. package/dist/tcl-Dlu8sp6Q.js +232 -0
  107. package/dist/tsMode-Bh-v12OL.js +887 -0
  108. package/dist/twig-C5TO7-kw.js +392 -0
  109. package/dist/typescript-c7y6IZVP.js +343 -0
  110. package/dist/typespec-BsmjDEu7.js +117 -0
  111. package/dist/useFieldRendering-BIqeE3qo.js +6083 -0
  112. package/dist/vb-ChHvIDrk.js +372 -0
  113. package/dist/wgsl-XEp1ju8c.js +439 -0
  114. package/dist/xml-MAEprTnF.js +95 -0
  115. package/dist/xml.contribution-XMOaon8i.js +27 -0
  116. package/dist/yaml-C1p8rXG7.js +206 -0
  117. package/dist/yaml.contribution-DRRVhJmJ.js +8 -0
  118. package/package.json +88 -0
  119. package/src/__tests__/client-assigner.test.ts +341 -0
  120. package/src/__tests__/code-types.test.ts +30 -0
  121. package/src/__tests__/markdown-field.test.ts +34 -0
  122. package/src/__tests__/markdown-note-field.test.ts +135 -0
  123. package/src/__tests__/quiz-recorder.test.ts +195 -0
  124. package/src/__tests__/recorder-editor-content-sync.test.ts +172 -0
  125. package/src/__tests__/recorder-editor.test.ts +143 -0
  126. package/src/__tests__/recorder-render.test.ts +57 -0
  127. package/src/__tests__/recorder-wysiwyg-field-host.test.ts +33 -0
  128. package/src/__tests__/step-field.test.ts +270 -0
  129. package/src/__tests__/type-plugins.test.ts +59 -0
  130. package/src/__tests__/var-field-render.test.ts +26 -0
  131. package/src/client-assigner.ts +269 -0
  132. package/src/code-types.ts +94 -0
  133. package/src/components/AimdCodeField.vue +228 -0
  134. package/src/components/AimdDnaSequenceField.vue +983 -0
  135. package/src/components/AimdMarkdownField.vue +168 -0
  136. package/src/components/AimdMarkdownNoteField.vue +457 -0
  137. package/src/components/AimdQuizRecorder.vue +792 -0
  138. package/src/components/AimdRecorder.vue +1959 -0
  139. package/src/components/AimdRecorderEditor.vue +2281 -0
  140. package/src/components/AimdRecorderWysiwygFieldHost.vue +93 -0
  141. package/src/components/AimdRecorderWysiwygSurface.vue +487 -0
  142. package/src/components/AimdSeqVizViewer.vue +122 -0
  143. package/src/components/AimdStepCheckField.vue +453 -0
  144. package/src/components/AimdVarField.vue +213 -0
  145. package/src/components/AimdVarTableField.vue +516 -0
  146. package/src/components/DnaAnnotationEditor.vue +477 -0
  147. package/src/components/DnaSequenceEditor.vue +44 -0
  148. package/src/components/DnaSequenceToolbar.vue +98 -0
  149. package/src/components/DnaSequenceViewer.vue +162 -0
  150. package/src/components/index.ts +21 -0
  151. package/src/components/recorderMilkdownPlugin.ts +632 -0
  152. package/src/composables/__tests__/useDnaSequence.test.ts +467 -0
  153. package/src/composables/__tests__/useFieldAdapters.test.ts +115 -0
  154. package/src/composables/__tests__/useFocusManagement.test.ts +66 -0
  155. package/src/composables/__tests__/useRecordState.test.ts +586 -0
  156. package/src/composables/__tests__/useStepTimers.test.ts +64 -0
  157. package/src/composables/__tests__/useVarHelpers.test.ts +424 -0
  158. package/src/composables/__tests__/workbenchFieldEditing.test.ts +97 -0
  159. package/src/composables/index.ts +94 -0
  160. package/src/composables/useClientAssignerRunner.ts +74 -0
  161. package/src/composables/useDnaSequence.ts +400 -0
  162. package/src/composables/useDnaSequenceField.ts +316 -0
  163. package/src/composables/useFieldAdapters.ts +61 -0
  164. package/src/composables/useFieldRendering.ts +269 -0
  165. package/src/composables/useFocusManagement.ts +144 -0
  166. package/src/composables/useRecordState.ts +429 -0
  167. package/src/composables/useStepTimers.ts +243 -0
  168. package/src/composables/useVarHelpers.ts +545 -0
  169. package/src/composables/useVarTableDragDrop.ts +236 -0
  170. package/src/composables/workbenchFieldEditing.ts +705 -0
  171. package/src/css.d.ts +9 -0
  172. package/src/index.ts +65 -0
  173. package/src/locales.ts +559 -0
  174. package/src/monaco-code.ts +75 -0
  175. package/src/styles/aimd.css +994 -0
  176. package/src/type-plugins.ts +132 -0
  177. package/src/type-utils.ts +3 -0
  178. package/src/types.ts +191 -0
@@ -0,0 +1,3595 @@
1
+ import { defineAsyncComponent as et, defineComponent as _e, h as d, ref as L, onMounted as Gt, nextTick as Me, onBeforeUnmount as tt, watch as re, Transition as ka, computed as w, openBlock as C, createElementBlock as T, createElementVNode as h, toDisplayString as k, unref as Ee, createCommentVNode as W, Fragment as fe, renderList as he, withDirectives as ut, vModelRadio as wa, vModelText as Yt, normalizeClass as pe, createTextVNode as Ze, reactive as mt, createVNode as Fe, render as Vt, watchEffect as Ca, getCurrentInstance as Ea, normalizeStyle as je, mergeProps as Ta, createBlock as Mt, withModifiers as dt } from "vue";
2
+ import { renderToVue as Sa, parseAndExtract as ft } from "@airalogy/aimd-renderer";
3
+ import { g as Qe, c as Zt, a as za, r as $a, P as Da, d as Ra, $ as qa, b as Aa, h as xa, e as Va, f as Ma, i as Fa, j as Ft, k as Ba, l as Bt, N as Ia, m as Pa, n as Oa, o as La, u as Na, p as Ha, q as Ka, s as Wa, t as Ua, _ as ja } from "./AimdEditor.vue_vue_type_style_index_0_lang-Bq79rKNw.js";
4
+ import { Z as Xt, aj as Qa, c as We, a9 as Ga, _ as Ya, a8 as Za, E as It, y as Xa, s as ze, a3 as Ja, G as Je, F as ei, z as ti, H as ai, ah as gt, ag as ii, v as ni, w as ri, ad as li, ak as Be, a as vt, h as Jt, g as si, ac as oi, ae as di, a4 as ci, p as ui, x as mi, j as fi, n as vi, a1 as hi, $ as pi, a7 as gi, a6 as yi, D as bi, al as _i, am as ki, C as wi, M as Ci, a2 as Ei, S as Xe, U as Ti, K as Si, T as zi, X as $i } from "./useFieldRendering-BIqeE3qo.js";
5
+ import { isScaleQuizAnswerComplete as Di, gradeScaleQuizLocally as Ri } from "@airalogy/aimd-core";
6
+ import { _ as Ge } from "./_commonjsHelpers-CZXJ37nu.js";
7
+ const qi = et(() => import("./AimdCodeField-DC3DPvgc.js")), Ai = _e({
8
+ name: "AimdVarField",
9
+ props: {
10
+ node: { type: Object, required: !0 },
11
+ value: { type: void 0, default: void 0 },
12
+ disabled: { type: Boolean, default: !1 },
13
+ extraClasses: { type: Array, default: () => [] },
14
+ messages: { type: Object, required: !0 },
15
+ fieldMeta: { type: Object, default: void 0 },
16
+ displayValue: { type: [String, Number], default: "" },
17
+ inputKind: { type: String, required: !0 },
18
+ typePlugin: { type: Object, default: void 0 },
19
+ initialized: { type: Boolean, default: !1 }
20
+ },
21
+ emits: ["change", "blur"],
22
+ setup(e, { emit: t }) {
23
+ return () => {
24
+ const i = e.node, a = i.id, n = i.definition?.type || "str", p = Xt(n), s = e.inputKind, f = p === "int" || p === "integer", u = s === "number" && !f, A = e.fieldMeta, D = e.disabled, V = e.extraClasses, P = A?.placeholder ?? xi(i), G = e.displayValue, Y = Qa(n, A) ?? "plaintext";
25
+ function F(b) {
26
+ const z = Ya(b, n, s, {
27
+ typePlugin: e.typePlugin
28
+ });
29
+ t("change", { id: a, value: z, type: n, inputKind: s });
30
+ }
31
+ function N() {
32
+ t("blur", { id: a });
33
+ }
34
+ function O(b) {
35
+ We(b, s), typeof HTMLTextAreaElement < "u" && b instanceof HTMLTextAreaElement && Za(b);
36
+ }
37
+ const H = A?.enumOptions ?? [];
38
+ if (H.length)
39
+ return d("span", {
40
+ class: ["aimd-rec-inline aimd-rec-inline--var-stacked aimd-field-wrapper", ...V]
41
+ }, [
42
+ d("span", { class: "aimd-field aimd-field--no-style aimd-field__label" }, [
43
+ d("span", { class: "aimd-field__scope aimd-field__scope--var" }, "var"),
44
+ d("span", { class: "aimd-field__id" }, a)
45
+ ]),
46
+ d("select", {
47
+ "data-rec-focus-key": `var:${a}`,
48
+ class: "aimd-rec-inline__input aimd-rec-inline__input--stacked aimd-rec-inline__select",
49
+ disabled: D,
50
+ value: e.value,
51
+ onChange: (b) => F(b.target.value),
52
+ onBlur: N
53
+ }, H.map((b) => d("option", { key: String(b.value), value: b.value }, b.label)))
54
+ ]);
55
+ const m = (b, z) => d("span", {
56
+ class: ["aimd-rec-inline aimd-rec-inline--var-stacked aimd-field-wrapper aimd-field-wrapper--inline", z, ...V]
57
+ }, [
58
+ d("span", { class: "aimd-field aimd-field--no-style aimd-field__label" }, [
59
+ d("span", { class: "aimd-field__scope aimd-field__scope--var" }, Qe("var", e.messages)),
60
+ d("span", { class: "aimd-field__id" }, a)
61
+ ]),
62
+ b
63
+ ]);
64
+ if (s === "checkbox")
65
+ return m(
66
+ d("span", { class: "aimd-rec-inline__checkbox-row" }, [
67
+ d("input", {
68
+ "data-rec-focus-key": `var:${a}`,
69
+ type: "checkbox",
70
+ disabled: D,
71
+ checked: Ga(e.value),
72
+ onVnodeMounted: (b) => We(b.el, s),
73
+ onVnodeUpdated: (b) => We(b.el, s),
74
+ onChange: (b) => {
75
+ const z = b.target.checked;
76
+ t("change", { id: a, value: z, type: n, inputKind: s });
77
+ },
78
+ onBlur: N
79
+ })
80
+ ]),
81
+ "aimd-rec-inline--var-stacked--checkbox"
82
+ );
83
+ if (s === "textarea" || s === "dna")
84
+ return m(
85
+ d("textarea", {
86
+ "data-rec-focus-key": `var:${a}`,
87
+ class: "aimd-rec-inline__textarea aimd-rec-inline__textarea--stacked",
88
+ disabled: D,
89
+ placeholder: P,
90
+ value: G,
91
+ onVnodeMounted: (b) => We(b.el, s),
92
+ onVnodeUpdated: (b) => We(b.el, s),
93
+ onInput: (b) => F(b.target.value),
94
+ onBlur: N
95
+ }),
96
+ s === "dna" ? "aimd-rec-inline--var-stacked--dna" : "aimd-rec-inline--var-stacked--textarea"
97
+ );
98
+ if (s === "code")
99
+ return m(
100
+ d(qi, {
101
+ modelValue: typeof G == "number" ? String(G) : G,
102
+ language: Y,
103
+ disabled: D,
104
+ "onUpdate:modelValue": (b) => F(b),
105
+ onBlur: N
106
+ }),
107
+ "aimd-rec-inline--var-stacked--code"
108
+ );
109
+ if (s === "text")
110
+ return m(
111
+ d("textarea", {
112
+ "data-rec-focus-key": `var:${a}`,
113
+ class: "aimd-rec-inline__textarea aimd-rec-inline__textarea--stacked aimd-rec-inline__textarea--stacked-text",
114
+ rows: 1,
115
+ disabled: D,
116
+ placeholder: P,
117
+ value: G,
118
+ onVnodeMounted: (b) => {
119
+ const z = b.el;
120
+ O(z);
121
+ },
122
+ onVnodeUpdated: (b) => {
123
+ const z = b.el;
124
+ O(z);
125
+ },
126
+ onInput: (b) => {
127
+ const z = b.target;
128
+ O(z), F(z.value);
129
+ },
130
+ onBlur: N
131
+ })
132
+ );
133
+ const M = s === "datetime" ? "datetime-local" : u ? "text" : s;
134
+ return m(
135
+ d("input", {
136
+ "data-rec-focus-key": `var:${a}`,
137
+ class: "aimd-rec-inline__input aimd-rec-inline__input--stacked",
138
+ type: M,
139
+ inputmode: s === "number" ? f ? "numeric" : "decimal" : void 0,
140
+ disabled: D,
141
+ placeholder: P,
142
+ step: s === "number" ? f ? "1" : void 0 : s === "time" ? "1" : void 0,
143
+ value: G,
144
+ onVnodeMounted: (b) => O(b.el),
145
+ onVnodeUpdated: (b) => O(b.el),
146
+ onInput: (b) => {
147
+ const z = b.target;
148
+ O(z), F(z.value);
149
+ },
150
+ onBlur: N
151
+ })
152
+ );
153
+ };
154
+ }
155
+ });
156
+ function xi(e) {
157
+ const t = e.definition?.kwargs?.title;
158
+ return typeof t == "string" && t.trim() ? t.trim() : void 0;
159
+ }
160
+ function Pt() {
161
+ return d("svg", {
162
+ viewBox: "0 0 24 24",
163
+ fill: "none",
164
+ stroke: "currentColor",
165
+ "stroke-width": "1.9",
166
+ "stroke-linecap": "round",
167
+ "stroke-linejoin": "round",
168
+ "aria-hidden": "true"
169
+ }, [
170
+ d("path", { d: "M3 6h18" }),
171
+ d("path", { d: "M8 6V4.8c0-.7.6-1.3 1.3-1.3h5.4c.7 0 1.3.6 1.3 1.3V6" }),
172
+ d("path", { d: "M18 6l-1 13.1c-.1.8-.7 1.4-1.5 1.4H8.5c-.8 0-1.4-.6-1.5-1.4L6 6" }),
173
+ d("path", { d: "M10 10.5v6" }),
174
+ d("path", { d: "M14 10.5v6" })
175
+ ]);
176
+ }
177
+ function Ot(e) {
178
+ const t = String(e ?? "");
179
+ let i = 0;
180
+ for (const a of t)
181
+ i += (a.codePointAt(0) ?? 0) > 255 ? 2 : 1;
182
+ return i;
183
+ }
184
+ function Ve(e) {
185
+ const t = e.trim().toLowerCase();
186
+ return /^(id|no|num|qty|amount|count|index|step|day|time|min|max|ph|temp|volume|mass|weight|age)$/.test(t) || /^(编号|数量|序号|步数|天数|时间|分钟|最大|最小|温度|体积|质量|重量|年龄)$/.test(e.trim()) ? "compact" : /note|remark|comment|description|summary|title|name|result|detail|observation/.test(t) || /备注|说明|描述|总结|标题|名称|结果|详情|观察/.test(e) ? "wide" : "default";
187
+ }
188
+ const Vi = _e({
189
+ name: "AimdVarTableField",
190
+ props: {
191
+ node: { type: Object, required: !0 },
192
+ rows: { type: Array, required: !0 },
193
+ columns: { type: Array, required: !0 },
194
+ disabled: { type: Boolean, default: !1 },
195
+ readonly: { type: Boolean, default: !1 },
196
+ settlingRowKey: { type: String, default: null },
197
+ messages: { type: Object, required: !0 },
198
+ fieldMeta: { type: Object, default: void 0 },
199
+ fieldState: { type: Object, default: void 0 }
200
+ },
201
+ emits: [
202
+ "cell-input",
203
+ "cell-paste",
204
+ "cell-blur",
205
+ "add-row",
206
+ "remove-row",
207
+ "drag-start",
208
+ "drag-over",
209
+ "drag-drop",
210
+ "drag-end"
211
+ ],
212
+ setup(e, { emit: t }) {
213
+ const i = L(null), a = L(!1), n = L(!1);
214
+ let p = null, s = null, f = null, u = 0;
215
+ const A = 40;
216
+ function D(m) {
217
+ return e.disabled ? !0 : !!e.fieldMeta?.[`var_table:${e.node.id}:${m}`]?.disabled;
218
+ }
219
+ function V(m, M) {
220
+ const b = M.reduce((X, U) => Math.max(X, Ot(U[m])), Ot(m)), z = Ve(m);
221
+ return z === "compact" ? Math.max(7, Math.min(12, b + 2)) : z === "wide" ? Math.max(16, Math.min(42, b + 5)) : Math.max(10, Math.min(22, b + 4));
222
+ }
223
+ function P(m, M) {
224
+ return 108 + m.reduce((j, q) => j + V(q, M) * 8.2 + 24, 0);
225
+ }
226
+ function G(m, M) {
227
+ return `${V(m, M)}ch`;
228
+ }
229
+ function Y() {
230
+ if (!i.value) return 0;
231
+ const m = i.value.closest(".aimd-protocol-recorder__content");
232
+ return m && m.clientWidth > 0 ? Math.max(0, m.clientWidth - 36) : i.value.clientWidth;
233
+ }
234
+ function F() {
235
+ if (!i.value) return;
236
+ const m = Y();
237
+ if (m <= 0) return;
238
+ const M = P(e.columns, e.rows), b = a.value ? M > m - A : M > m + A;
239
+ if (b === a.value) {
240
+ f = null, u = 0;
241
+ return;
242
+ }
243
+ f === b ? u += 1 : (f = b, u = 1), u >= 2 && (a.value = b, f = null, u = 0);
244
+ }
245
+ function N() {
246
+ s !== null && cancelAnimationFrame(s), s = requestAnimationFrame(() => {
247
+ s = null, F();
248
+ });
249
+ }
250
+ function O() {
251
+ let m = 4;
252
+ const M = () => {
253
+ if (N(), m -= 1, m > 0) {
254
+ requestAnimationFrame(M);
255
+ return;
256
+ }
257
+ n.value = !0, N();
258
+ };
259
+ requestAnimationFrame(M);
260
+ }
261
+ function H(m, M, b, z, X) {
262
+ return b.map((U, E) => {
263
+ const j = It(U), q = M[0] ?? "", te = M.slice(q ? 1 : 0);
264
+ return d("div", {
265
+ key: `${m}-card-${j}`,
266
+ class: "aimd-rec-card",
267
+ onDragover: (B) => t("drag-over", { tableName: m, rowIndex: E, event: B }),
268
+ onDrop: (B) => t("drag-drop", { tableName: m, rowIndex: E, columns: M, event: B })
269
+ }, [
270
+ d("div", { class: "aimd-rec-card__toolbar" }, [
271
+ d("span", {
272
+ class: [
273
+ "aimd-rec-inline-table__drag-handle",
274
+ e.readonly ? "aimd-rec-inline-table__drag-handle--disabled" : ""
275
+ ],
276
+ title: e.readonly ? X.table.dragDisabled : X.table.dragReorder,
277
+ draggable: !e.readonly,
278
+ onDragstart: (B) => t("drag-start", { tableName: m, rowIndex: E, event: B }),
279
+ onDragend: () => t("drag-end")
280
+ }, Array.from({ length: 6 }, (B, J) => d("span", {
281
+ key: `${j}-card-drag-dot-${J}`,
282
+ class: "aimd-rec-inline-table__drag-dot"
283
+ }))),
284
+ d("button", {
285
+ type: "button",
286
+ class: "aimd-rec-inline-table__icon-btn aimd-rec-inline-table__icon-btn--visible",
287
+ disabled: z || b.length <= 1,
288
+ "aria-label": X.table.deleteRow,
289
+ title: X.table.deleteRow,
290
+ onClick: () => t("remove-row", { tableName: m, rowIndex: E, columns: M })
291
+ }, [Pt()])
292
+ ]),
293
+ q ? d("div", { class: "aimd-rec-card__field aimd-rec-card__field--title" }, [
294
+ d("span", { class: "aimd-rec-card__label" }, q),
295
+ d("input", {
296
+ "data-rec-focus-key": `var_table:${m}:${E}:${q}`,
297
+ class: "aimd-rec-card__input",
298
+ disabled: D(q),
299
+ placeholder: q,
300
+ value: U[q] ?? "",
301
+ onInput: (B) => {
302
+ t("cell-input", {
303
+ tableName: m,
304
+ column: q,
305
+ rowIndex: E,
306
+ value: B.target.value,
307
+ row: U
308
+ });
309
+ },
310
+ onPaste: (B) => {
311
+ const J = B.clipboardData?.getData("text/plain") ?? "";
312
+ !J || !J.includes(" ") && !/[\r\n]/.test(J) || (B.preventDefault(), t("cell-paste", {
313
+ tableName: m,
314
+ column: q,
315
+ rowIndex: E,
316
+ text: J
317
+ }));
318
+ },
319
+ onBlur: () => t("cell-blur", { tableName: m, column: q })
320
+ })
321
+ ]) : null,
322
+ d("div", { class: "aimd-rec-card__body" }, te.map((B) => {
323
+ const oe = e.fieldState?.[`var_table:${m}:${B}`]?.validationError ? "aimd-rec-card__input aimd-rec-card__input--error" : "aimd-rec-card__input";
324
+ return d("div", {
325
+ key: `${m}-${j}-${B}`,
326
+ class: "aimd-rec-card__field"
327
+ }, [
328
+ d("span", { class: "aimd-rec-card__label" }, B),
329
+ d("input", {
330
+ "data-rec-focus-key": `var_table:${m}:${E}:${B}`,
331
+ class: oe,
332
+ disabled: D(B),
333
+ placeholder: B,
334
+ value: U[B] ?? "",
335
+ onInput: (ae) => {
336
+ t("cell-input", {
337
+ tableName: m,
338
+ column: B,
339
+ rowIndex: E,
340
+ value: ae.target.value,
341
+ row: U
342
+ });
343
+ },
344
+ onPaste: (ae) => {
345
+ const c = ae.clipboardData?.getData("text/plain") ?? "";
346
+ !c || !c.includes(" ") && !/[\r\n]/.test(c) || (ae.preventDefault(), t("cell-paste", {
347
+ tableName: m,
348
+ column: B,
349
+ rowIndex: E,
350
+ text: c
351
+ }));
352
+ },
353
+ onBlur: () => t("cell-blur", { tableName: m, column: B })
354
+ })
355
+ ]);
356
+ }))
357
+ ]);
358
+ });
359
+ }
360
+ return Gt(() => {
361
+ i.value && (p = new ResizeObserver(() => N()), p.observe(i.value), Me(() => O()));
362
+ }), tt(() => {
363
+ p?.disconnect(), s !== null && cancelAnimationFrame(s);
364
+ }), re(() => e.columns, () => Me(() => N())), re(() => e.rows, () => Me(() => N()), { deep: !0 }), () => {
365
+ const m = e.node.id, M = e.columns, b = e.rows, z = e.disabled, X = e.messages;
366
+ return d("div", {
367
+ ref: i,
368
+ class: "aimd-field aimd-field--var-table aimd-rec-inline-table",
369
+ "data-aimd-table-name": m,
370
+ "data-aimd-table-layout": n.value && a.value ? "cards" : "table"
371
+ }, [
372
+ d("div", { class: "aimd-field__header" }, [
373
+ d("span", { class: "aimd-field__scope" }, Qe("var_table", X)),
374
+ d("span", { class: "aimd-field__name" }, m)
375
+ ]),
376
+ d(ka, {
377
+ name: "aimd-table-layout-switch",
378
+ mode: "out-in"
379
+ }, {
380
+ default: () => n.value && a.value ? d("div", {
381
+ key: "cards",
382
+ class: "aimd-rec-card-list"
383
+ }, H(m, M, b, z, X)) : d("table", {
384
+ key: "table",
385
+ class: "aimd-field__table-preview aimd-rec-inline-table__table"
386
+ }, [
387
+ d("colgroup", [
388
+ d("col", { class: "aimd-rec-inline-table__drag-col" }),
389
+ ...M.map((U) => d("col", {
390
+ key: `${m}-col-${U}`,
391
+ style: { width: G(U, b) }
392
+ })),
393
+ d("col", { class: "aimd-rec-inline-table__action-col" })
394
+ ]),
395
+ d("thead", [
396
+ d("tr", [
397
+ d("th", { class: "aimd-rec-inline-table__drag-head" }, ""),
398
+ ...M.map((U) => d("th", {
399
+ class: [
400
+ "aimd-rec-inline-table__column-head",
401
+ `aimd-rec-inline-table__column-head--${Ve(U)}`
402
+ ],
403
+ scope: "col",
404
+ "data-column-kind": Ve(U)
405
+ }, U)),
406
+ d("th", { class: "aimd-rec-inline-table__action-head" }, X.table.actionColumn)
407
+ ])
408
+ ]),
409
+ d("tbody", b.map((U, E) => {
410
+ const j = It(U);
411
+ return d("tr", {
412
+ key: `${m}-${j}`,
413
+ class: [
414
+ "aimd-rec-inline-table__row",
415
+ E % 2 === 1 ? "aimd-rec-inline-table__row--alt" : "",
416
+ e.settlingRowKey === j ? "aimd-rec-inline-table__row--settling" : ""
417
+ ],
418
+ onDragover: (q) => t("drag-over", { tableName: m, rowIndex: E, event: q }),
419
+ onDrop: (q) => t("drag-drop", { tableName: m, rowIndex: E, columns: M, event: q })
420
+ }, [
421
+ d("td", { class: "aimd-rec-inline-table__drag-cell" }, [
422
+ d("span", {
423
+ class: [
424
+ "aimd-rec-inline-table__drag-handle",
425
+ e.readonly ? "aimd-rec-inline-table__drag-handle--disabled" : ""
426
+ ],
427
+ title: e.readonly ? X.table.dragDisabled : X.table.dragReorder,
428
+ draggable: !e.readonly,
429
+ onDragstart: (q) => t("drag-start", { tableName: m, rowIndex: E, event: q }),
430
+ onDragend: () => t("drag-end")
431
+ }, Array.from({ length: 6 }, (q, te) => d("span", {
432
+ key: `${j}-drag-dot-${te}`,
433
+ class: "aimd-rec-inline-table__drag-dot"
434
+ })))
435
+ ]),
436
+ ...M.map((q) => d("td", {
437
+ key: `${m}-${E}-${q}`,
438
+ class: [
439
+ "aimd-rec-inline-table__value-cell",
440
+ `aimd-rec-inline-table__value-cell--${Ve(q)}`
441
+ ],
442
+ "data-column-label": q,
443
+ "data-column-kind": Ve(q)
444
+ }, [
445
+ (() => {
446
+ const te = e.fieldState?.[`var_table:${m}:${q}`], B = Ve(q), J = te?.validationError ? [
447
+ "aimd-rec-table-cell-input",
448
+ `aimd-rec-table-cell-input--${B}`,
449
+ "aimd-rec-table-cell-input--error"
450
+ ] : [
451
+ "aimd-rec-table-cell-input",
452
+ `aimd-rec-table-cell-input--${B}`
453
+ ];
454
+ return d("input", {
455
+ "data-rec-focus-key": `var_table:${m}:${E}:${q}`,
456
+ class: J,
457
+ disabled: D(q),
458
+ placeholder: q,
459
+ value: U[q] ?? "",
460
+ onInput: (oe) => {
461
+ t("cell-input", {
462
+ tableName: m,
463
+ column: q,
464
+ rowIndex: E,
465
+ value: oe.target.value,
466
+ row: U
467
+ });
468
+ },
469
+ onPaste: (oe) => {
470
+ const ae = oe.clipboardData?.getData("text/plain") ?? "";
471
+ !ae || !ae.includes(" ") && !/[\r\n]/.test(ae) || (oe.preventDefault(), t("cell-paste", {
472
+ tableName: m,
473
+ column: q,
474
+ rowIndex: E,
475
+ text: ae
476
+ }));
477
+ },
478
+ onBlur: () => t("cell-blur", { tableName: m, column: q })
479
+ });
480
+ })()
481
+ ])),
482
+ d("td", { class: "aimd-rec-inline-table__action-cell" }, [
483
+ d("button", {
484
+ type: "button",
485
+ class: "aimd-rec-inline-table__icon-btn",
486
+ disabled: z || b.length <= 1,
487
+ "aria-label": X.table.deleteRow,
488
+ title: X.table.deleteRow,
489
+ onClick: () => t("remove-row", { tableName: m, rowIndex: E, columns: M })
490
+ }, [Pt()])
491
+ ])
492
+ ]);
493
+ }))
494
+ ])
495
+ }),
496
+ d("div", { class: "aimd-rec-inline-table__actions" }, [
497
+ d("button", {
498
+ type: "button",
499
+ class: "aimd-rec-inline-table__add-btn",
500
+ disabled: z,
501
+ onClick: () => t("add-row", { tableName: m, columns: M })
502
+ }, `+ ${X.table.addRow}`)
503
+ ])
504
+ ]);
505
+ };
506
+ }
507
+ }), Mi = et(() => import("./AimdMarkdownNoteField-CuUJZkgT.js")), Fi = _e({
508
+ name: "AimdStepField",
509
+ props: {
510
+ node: { type: Object, required: !0 },
511
+ state: { type: Object, required: !0 },
512
+ bodyNodes: { type: Array, default: () => [] },
513
+ disabled: { type: Boolean, default: !1 },
514
+ extraClasses: { type: Array, default: () => [] },
515
+ detailDisplay: { type: String, default: "auto" },
516
+ locale: { type: String, required: !0 },
517
+ messages: { type: Object, required: !0 }
518
+ },
519
+ emits: ["check-change", "annotation-change", "timer-start", "timer-pause", "timer-reset", "blur"],
520
+ setup(e, { emit: t }) {
521
+ const i = L(Date.now()), a = L(null), n = L(!1), p = L(!1);
522
+ let s = null, f = null;
523
+ function u() {
524
+ s && (clearInterval(s), s = null), Je(e.state) && (s = setInterval(() => {
525
+ i.value = Date.now();
526
+ }, 1e3));
527
+ }
528
+ re(() => e.state.timer_started_at_ms, () => {
529
+ i.value = Date.now(), u();
530
+ }, { immediate: !0 }), tt(() => {
531
+ s && clearInterval(s), f && clearTimeout(f);
532
+ });
533
+ const A = w(() => e.detailDisplay === "always"), D = w(() => Xa(e.state, i.value)), V = w(() => ze(D.value, e.locale)), P = w(() => typeof e.node.estimated_duration_ms == "number" ? ze(e.node.estimated_duration_ms, e.locale) : ""), G = w(() => Ja(e.node)), Y = w(() => Je(e.state)), F = w(() => ei(e.state)), N = w(() => !!e.state.annotation?.trim()), O = w(() => ti(e.state, e.node.estimated_duration_ms, i.value)), H = w(() => G.value === "countdown" || G.value === "both"), m = w(() => G.value === "elapsed" || G.value === "both"), M = w(() => (Y.value || F.value) && ai(O.value, e.node.estimated_duration_ms)), b = w(() => typeof O.value == "number" && O.value < 0), z = w(() => O.value == null ? "" : b.value ? e.messages.step.overtimeBadge(ze(Math.abs(O.value), e.locale)) : e.messages.step.remainingBadge(ze(Math.max(0, O.value), e.locale))), X = w(() => O.value == null ? "" : b.value ? e.messages.step.overtimeDuration(ze(Math.abs(O.value), e.locale)) : e.messages.step.remainingDuration(ze(Math.max(0, O.value), e.locale))), U = w(() => H.value), E = w(() => A.value || N.value || n.value), j = w(() => A.value || U.value || Y.value || F.value || p.value), q = w(() => !j.value && (Y.value || F.value)), te = w(() => E.value || j.value);
534
+ function B() {
535
+ f && (clearTimeout(f), f = null);
536
+ }
537
+ function J() {
538
+ N.value || (n.value = !1), !U.value && !Y.value && !F.value && (p.value = !1);
539
+ }
540
+ function oe() {
541
+ B();
542
+ }
543
+ function ae(R) {
544
+ const Z = R.relatedTarget;
545
+ Z instanceof Node && a.value?.contains(Z) || (B(), f = setTimeout(() => {
546
+ f = null;
547
+ const ce = typeof document < "u" ? document.activeElement : null;
548
+ ce instanceof Node && a.value?.contains(ce) || J();
549
+ }, 0));
550
+ }
551
+ function c() {
552
+ n.value = !0;
553
+ }
554
+ function x() {
555
+ p.value = !0, t("timer-start", { id: e.node.id });
556
+ }
557
+ function y(R) {
558
+ R.preventDefault();
559
+ }
560
+ return () => {
561
+ const R = e.node, Z = R.id, ce = e.state, le = R.step || "?", qe = !!R.check, ge = e.disabled, ke = e.extraClasses, Ie = F.value || Y.value, Pe = Y.value ? e.messages.step.pauseTimer : F.value ? e.messages.step.resumeTimer : e.messages.step.startTimer, Te = [], ue = [], Se = [];
562
+ if (j.value) {
563
+ const ve = [];
564
+ H.value && z.value && ve.push(
565
+ d("span", {
566
+ class: [
567
+ "aimd-step-timer__hero",
568
+ b.value ? "aimd-step-timer__hero--overtime" : M.value ? "aimd-step-timer__hero--warning" : "aimd-step-timer__hero--countdown"
569
+ ],
570
+ title: X.value
571
+ }, z.value)
572
+ ), m.value && ve.push(
573
+ d("span", {
574
+ class: [
575
+ "aimd-step-timer__pill",
576
+ "aimd-step-timer__pill--actual",
577
+ Y.value ? "aimd-step-timer__pill--running" : ""
578
+ ],
579
+ title: e.messages.step.recordedDuration(V.value)
580
+ }, e.messages.step.recordedBadge(V.value))
581
+ ), Te.push(
582
+ d("span", {
583
+ class: "aimd-step-field__detail aimd-step-field__detail--timer"
584
+ }, [
585
+ ...ve,
586
+ ge ? null : d("span", { class: "aimd-step-timer__controls" }, [
587
+ d("button", {
588
+ type: "button",
589
+ class: "aimd-step-timer__btn",
590
+ onClick: () => t(Y.value ? "timer-pause" : "timer-start", { id: Z })
591
+ }, Pe),
592
+ d("button", {
593
+ type: "button",
594
+ class: "aimd-step-timer__btn aimd-step-timer__btn--ghost",
595
+ disabled: !Ie,
596
+ onClick: () => t("timer-reset", { id: Z })
597
+ }, e.messages.step.resetTimer)
598
+ ])
599
+ ])
600
+ );
601
+ }
602
+ E.value && Te.push(
603
+ d("span", {
604
+ class: "aimd-step-field__detail aimd-step-field__detail--annotation"
605
+ }, [
606
+ d(Mi, {
607
+ class: "aimd-step-field__annotation-editor",
608
+ disabled: ge,
609
+ locale: e.locale,
610
+ minHeight: 220,
611
+ modelValue: ce.annotation || "",
612
+ "onUpdate:modelValue": (ve) => {
613
+ t("annotation-change", {
614
+ id: Z,
615
+ value: ve
616
+ });
617
+ },
618
+ onClose: () => {
619
+ n.value = !1, t("blur", { id: Z });
620
+ },
621
+ onBlur: () => t("blur", { id: Z })
622
+ })
623
+ ])
624
+ ), ue.push(
625
+ d(qe ? "label" : "span", { class: "aimd-rec-inline__check-wrap" }, [
626
+ qe ? d("input", {
627
+ "data-rec-focus-key": `step:${Z}:checked`,
628
+ type: "checkbox",
629
+ disabled: ge,
630
+ checked: !!ce.checked,
631
+ onChange: (ve) => {
632
+ t("check-change", {
633
+ id: Z,
634
+ value: ve.target.checked
635
+ });
636
+ },
637
+ onBlur: () => t("blur", { id: Z })
638
+ }) : null,
639
+ d("span", { class: "aimd-field__scope" }, Qe("step", e.messages)),
640
+ d("span", { class: "aimd-rec-inline__step-num" }, le),
641
+ d("span", { class: "aimd-field__name" }, Z)
642
+ ])
643
+ ), P.value && ue.push(
644
+ d("span", {
645
+ class: "aimd-step-timer__pill aimd-step-timer__pill--estimate",
646
+ title: e.messages.step.estimatedDuration(P.value)
647
+ }, e.messages.step.estimatedBadge(P.value))
648
+ ), q.value && ue.push(
649
+ d("span", {
650
+ class: [
651
+ "aimd-step-timer__pill",
652
+ "aimd-step-timer__pill--actual",
653
+ Y.value ? "aimd-step-timer__pill--running" : ""
654
+ ],
655
+ title: e.messages.step.recordedDuration(V.value)
656
+ }, e.messages.step.recordedBadge(V.value))
657
+ ), !ge && !E.value && Se.push(
658
+ d("button", {
659
+ type: "button",
660
+ class: "aimd-step-timer__btn aimd-step-timer__btn--ghost aimd-step-field__toggle aimd-step-field__toggle--annotation",
661
+ onMousedown: y,
662
+ onClick: c
663
+ }, e.messages.step.annotationToggle)
664
+ ), !ge && !j.value && Se.push(
665
+ d("button", {
666
+ type: "button",
667
+ class: "aimd-step-timer__btn aimd-step-timer__btn--ghost aimd-step-field__toggle aimd-step-field__toggle--timer",
668
+ onMousedown: y,
669
+ onClick: x
670
+ }, e.messages.step.timerToggle)
671
+ );
672
+ const Ae = e.bodyNodes.length > 0 ? d("div", { class: "aimd-step-field__body" }, e.bodyNodes) : null;
673
+ return d("div", {
674
+ ref: a,
675
+ class: ["aimd-rec-inline aimd-rec-inline--step aimd-field aimd-field--step", ...ke],
676
+ onFocusin: oe,
677
+ onFocusout: ae
678
+ }, [
679
+ d("div", {
680
+ class: "aimd-step-field__main"
681
+ }, [
682
+ d("div", {
683
+ class: "aimd-step-field__main-meta"
684
+ }, ue),
685
+ Se.length > 0 ? d("div", {
686
+ class: "aimd-step-field__main-actions"
687
+ }, Se) : null
688
+ ]),
689
+ Ae,
690
+ te.value ? d("div", { class: "aimd-step-field__details" }, Te) : null
691
+ ]);
692
+ };
693
+ }
694
+ }), Bi = _e({
695
+ name: "AimdCheckField",
696
+ props: {
697
+ node: { type: Object, required: !0 },
698
+ state: { type: Object, required: !0 },
699
+ bodyNodes: { type: Array, default: () => [] },
700
+ disabled: { type: Boolean, default: !1 },
701
+ extraClasses: { type: Array, default: () => [] },
702
+ messages: { type: Object, required: !0 }
703
+ },
704
+ emits: ["check-change", "annotation-change", "blur"],
705
+ setup(e, { emit: t }) {
706
+ return () => {
707
+ const i = e.node, a = i.id, n = e.state, p = e.disabled, s = e.extraClasses, f = e.bodyNodes.length > 0, u = !!(n.checked && i.checked_message), A = i.label || a;
708
+ return d("div", {
709
+ class: ["aimd-rec-inline aimd-rec-inline--check aimd-field aimd-field--check", ...s]
710
+ }, [
711
+ d("div", { class: "aimd-check-field__main" }, [
712
+ d("label", { class: "aimd-rec-inline__check-wrap aimd-check-field__toggle" }, [
713
+ d("input", {
714
+ "data-rec-focus-key": `check:${a}:checked`,
715
+ type: "checkbox",
716
+ class: "aimd-checkbox",
717
+ disabled: p,
718
+ checked: !!n.checked,
719
+ onChange: (D) => {
720
+ t("check-change", {
721
+ id: a,
722
+ value: D.target.checked
723
+ });
724
+ },
725
+ onBlur: () => t("blur", { id: a })
726
+ }),
727
+ d("span", { class: "aimd-field__scope" }, Qe("check", e.messages)),
728
+ f ? null : d("span", { class: "aimd-field__name aimd-check-field__key" }, A)
729
+ ]),
730
+ f ? d("div", {
731
+ class: [
732
+ "aimd-check-field__body",
733
+ n.checked ? "aimd-check-field__body--checked" : ""
734
+ ]
735
+ }, e.bodyNodes) : null
736
+ ]),
737
+ u ? d("div", { class: "aimd-check-field__banner" }, i.checked_message) : null,
738
+ d("input", {
739
+ "data-rec-focus-key": `check:${a}:annotation`,
740
+ class: "aimd-rec-inline__input aimd-rec-inline__input--annotation",
741
+ disabled: p,
742
+ placeholder: e.messages.check.annotationPlaceholder,
743
+ value: n.annotation || "",
744
+ onInput: (D) => {
745
+ t("annotation-change", {
746
+ id: a,
747
+ value: D.target.value
748
+ });
749
+ },
750
+ onBlur: () => t("blur", { id: a })
751
+ })
752
+ ]);
753
+ };
754
+ }
755
+ }), Ii = { class: "aimd-quiz-recorder aimd-field aimd-field--quiz" }, Pi = { class: "aimd-quiz__meta" }, Oi = { class: "aimd-field__scope" }, Li = { class: "aimd-field__name" }, Ni = { class: "aimd-field__type" }, Hi = {
756
+ key: 0,
757
+ class: "aimd-quiz__score"
758
+ }, Ki = {
759
+ key: 0,
760
+ class: "aimd-quiz__title"
761
+ }, Wi = { class: "aimd-quiz__stem" }, Ui = {
762
+ key: 0,
763
+ class: "aimd-quiz-recorder__stem-text"
764
+ }, ji = ["data-rec-focus-key", "placeholder", "readonly", "value", "onInput"], Qi = {
765
+ key: 1,
766
+ class: "aimd-quiz__description"
767
+ }, Gi = {
768
+ key: 2,
769
+ class: "aimd-quiz-recorder__options"
770
+ }, Yi = ["data-rec-focus-key", "name", "value", "disabled"], Zi = { class: "aimd-quiz-recorder__option-content" }, Xi = { class: "aimd-quiz-recorder__option-label" }, Ji = {
771
+ key: 0,
772
+ class: "aimd-quiz-recorder__option-explanation"
773
+ }, en = {
774
+ key: 3,
775
+ class: "aimd-quiz-recorder__options"
776
+ }, tn = ["data-rec-focus-key", "disabled", "checked", "onChange"], an = { class: "aimd-quiz-recorder__option-content" }, nn = { class: "aimd-quiz-recorder__option-label" }, rn = {
777
+ key: 0,
778
+ class: "aimd-quiz-recorder__option-explanation"
779
+ }, ln = ["data-rec-focus-key", "placeholder", "readonly"], sn = {
780
+ key: 5,
781
+ class: "aimd-scale"
782
+ }, on = { class: "aimd-scale__item-stem" }, dn = { class: "aimd-scale__item-options" }, cn = ["data-rec-focus-key", "name", "value", "checked", "disabled", "onChange"], un = {
783
+ key: 6,
784
+ class: "aimd-scale"
785
+ }, mn = { class: "aimd-scale__table" }, fn = {
786
+ class: "aimd-scale__item-stem",
787
+ scope: "row"
788
+ }, vn = { class: "aimd-scale__cell-label" }, hn = ["data-rec-focus-key", "name", "value", "checked", "disabled", "onChange"], pn = { class: "aimd-quiz__grade-meta" }, gn = {
789
+ key: 0,
790
+ class: "aimd-quiz__grade-band"
791
+ }, yn = {
792
+ key: 1,
793
+ class: "aimd-quiz__grade-band"
794
+ }, bn = {
795
+ key: 2,
796
+ class: "aimd-quiz__grade-review"
797
+ }, _n = {
798
+ key: 3,
799
+ class: "aimd-quiz__grade-feedback"
800
+ }, kn = {
801
+ key: 4,
802
+ class: "aimd-quiz__grade-list"
803
+ }, wn = {
804
+ key: 5,
805
+ class: "aimd-quiz__grade-list"
806
+ }, Cn = /* @__PURE__ */ _e({
807
+ __name: "AimdQuizRecorder",
808
+ props: {
809
+ quiz: {},
810
+ modelValue: {},
811
+ grade: { default: null },
812
+ submitted: { type: Boolean, default: !1 },
813
+ readonly: { type: Boolean, default: !1 },
814
+ focusKeyPrefix: { default: void 0 },
815
+ locale: { default: void 0 },
816
+ messages: { default: void 0 },
817
+ choiceOptionExplanationMode: { default: "hidden" },
818
+ scaleGradeDisplayMode: { default: "hidden" }
819
+ },
820
+ emits: ["update:modelValue"],
821
+ setup(e, { emit: t }) {
822
+ const i = e, a = t, n = /\[\[([^\[\]\s]+)\]\]/g, p = w(() => {
823
+ const c = i.quiz.stem || "";
824
+ if (i.quiz.type !== "blank")
825
+ return [{ type: "text", value: c }];
826
+ const x = [];
827
+ let y = 0;
828
+ for (const R of c.matchAll(n)) {
829
+ const Z = R.index ?? 0;
830
+ Z > y && x.push({
831
+ type: "text",
832
+ value: c.slice(y, Z)
833
+ }), x.push({
834
+ type: "blank",
835
+ key: R[1]
836
+ }), y = Z + R[0].length;
837
+ }
838
+ return y < c.length && x.push({
839
+ type: "text",
840
+ value: c.slice(y)
841
+ }), x.length > 0 ? x : [{ type: "text", value: c }];
842
+ }), s = w({
843
+ get() {
844
+ return typeof i.modelValue == "string" ? i.modelValue : "";
845
+ },
846
+ set(c) {
847
+ a("update:modelValue", c);
848
+ }
849
+ }), f = w(() => Array.isArray(i.modelValue) ? i.modelValue.filter((c) => typeof c == "string") : []), u = w(() => i.quiz.type !== "choice" ? [] : i.quiz.mode === "single" ? s.value ? [s.value] : [] : f.value);
850
+ function A(c) {
851
+ return f.value.includes(c);
852
+ }
853
+ function D(c, x) {
854
+ const y = f.value, R = x ? [.../* @__PURE__ */ new Set([...y, c])] : y.filter((Z) => Z !== c);
855
+ a("update:modelValue", R);
856
+ }
857
+ function V(c) {
858
+ if (typeof c != "object" || c === null || Array.isArray(c))
859
+ return {};
860
+ const x = {};
861
+ for (const [y, R] of Object.entries(c))
862
+ typeof R == "string" && (x[y] = R);
863
+ return x;
864
+ }
865
+ function P(c) {
866
+ return V(i.modelValue)[c] || "";
867
+ }
868
+ function G(c, x) {
869
+ const y = {
870
+ ...V(i.modelValue),
871
+ [c]: x
872
+ };
873
+ a("update:modelValue", y);
874
+ }
875
+ function Y(c) {
876
+ if (typeof c != "object" || c === null || Array.isArray(c))
877
+ return {};
878
+ const x = {};
879
+ for (const [y, R] of Object.entries(c))
880
+ typeof R == "string" && (x[y] = R);
881
+ return x;
882
+ }
883
+ function F(c) {
884
+ return Y(i.modelValue)[c] || "";
885
+ }
886
+ function N(c, x) {
887
+ const y = {
888
+ ...Y(i.modelValue),
889
+ [c]: x
890
+ };
891
+ a("update:modelValue", y);
892
+ }
893
+ const O = w({
894
+ get() {
895
+ return typeof i.modelValue == "string" ? i.modelValue : "";
896
+ },
897
+ set(c) {
898
+ a("update:modelValue", c);
899
+ }
900
+ });
901
+ function H(c) {
902
+ return typeof c.points == "number" && Number.isFinite(c.points) ? `${c.text} (${c.points})` : c.text;
903
+ }
904
+ const m = w(() => Zt(i.locale, i.messages)), M = w(() => za(i.quiz.type, m.value, i.quiz.mode)), b = w(() => i.quiz.type === "scale" && Array.isArray(i.quiz.items) ? i.quiz.items : []), z = w(() => i.quiz.type === "scale" && Array.isArray(i.quiz.options) ? i.quiz.options : []), X = w(() => i.quiz.type === "scale" && Di(i.quiz, i.modelValue)), U = w(() => i.quiz.type !== "scale" || !X.value ? null : Ri(i.quiz, i.modelValue)), E = w(() => {
905
+ if (i.grade)
906
+ return i.grade;
907
+ if (i.quiz.type !== "scale")
908
+ return null;
909
+ switch (i.scaleGradeDisplayMode) {
910
+ case "completed":
911
+ return U.value;
912
+ case "submitted":
913
+ return i.submitted ? U.value : null;
914
+ default:
915
+ return null;
916
+ }
917
+ }), j = w(() => {
918
+ switch (E.value?.status) {
919
+ case "correct":
920
+ return "correct";
921
+ case "incorrect":
922
+ return "incorrect";
923
+ case "partial":
924
+ return "partial";
925
+ case "scored":
926
+ return "scored";
927
+ case "needs_review":
928
+ return "needs-review";
929
+ case "error":
930
+ return "error";
931
+ default:
932
+ return "ungraded";
933
+ }
934
+ }), q = w(() => {
935
+ const c = E.value?.status;
936
+ if (!c)
937
+ return "";
938
+ switch (c) {
939
+ case "correct":
940
+ return m.value.quiz.status.correct;
941
+ case "incorrect":
942
+ return m.value.quiz.status.incorrect;
943
+ case "partial":
944
+ return m.value.quiz.status.partial;
945
+ case "scored":
946
+ return m.value.quiz.status.scored;
947
+ case "needs_review":
948
+ return m.value.quiz.status.needsReview;
949
+ case "error":
950
+ return m.value.quiz.status.error;
951
+ default:
952
+ return m.value.quiz.status.ungraded;
953
+ }
954
+ }), te = w(() => Array.isArray(E.value?.blank_results) ? E.value.blank_results : []), B = w(() => Array.isArray(E.value?.rubric_results) ? E.value.rubric_results : []), J = w(() => !!(E.value && E.value.status !== "ungraded")), oe = w(() => !(!E.value || E.value.status === "ungraded" && !E.value.feedback && !E.value.review_required && !E.value.band && te.value.length === 0 && B.value.length === 0));
955
+ function ae(c, x) {
956
+ return !x?.trim() || !u.value.includes(c) ? !1 : i.choiceOptionExplanationMode === "selected" ? !0 : i.choiceOptionExplanationMode === "submitted" ? i.submitted : i.choiceOptionExplanationMode === "graded" ? J.value : !1;
957
+ }
958
+ return (c, x) => (C(), T("div", Ii, [
959
+ h("div", Pi, [
960
+ h("span", Oi, k(Ee(Qe)("quiz", m.value)), 1),
961
+ h("span", Li, k(e.quiz.id), 1),
962
+ h("span", Ni, "(" + k(M.value) + ")", 1),
963
+ typeof e.quiz.score == "number" ? (C(), T("span", Hi, k(m.value.quiz.score(e.quiz.score)), 1)) : W("", !0)
964
+ ]),
965
+ e.quiz.title ? (C(), T("div", Ki, k(e.quiz.title), 1)) : W("", !0),
966
+ h("div", Wi, [
967
+ (C(!0), T(fe, null, he(p.value, (y, R) => (C(), T(fe, {
968
+ key: `${e.quiz.id}-stem-${R}`
969
+ }, [
970
+ y.type === "text" ? (C(), T("span", Ui, k(y.value), 1)) : (C(), T("input", {
971
+ key: 1,
972
+ class: "aimd-quiz-recorder__blank-input",
973
+ type: "text",
974
+ "data-rec-focus-key": `${e.focusKeyPrefix || `quiz:${e.quiz.id}`}:blank:${y.key}`,
975
+ placeholder: y.key,
976
+ readonly: e.readonly,
977
+ value: P(y.key),
978
+ onInput: (Z) => G(y.key, Z.target.value)
979
+ }, null, 40, ji))
980
+ ], 64))), 128))
981
+ ]),
982
+ e.quiz.description ? (C(), T("div", Qi, k(e.quiz.description), 1)) : W("", !0),
983
+ e.quiz.type === "choice" && e.quiz.mode === "single" && e.quiz.options?.length ? (C(), T("div", Gi, [
984
+ (C(!0), T(fe, null, he(e.quiz.options, (y) => (C(), T("label", {
985
+ key: `${e.quiz.id}-single-${y.key}`,
986
+ class: "aimd-quiz-recorder__option"
987
+ }, [
988
+ ut(h("input", {
989
+ "onUpdate:modelValue": x[0] || (x[0] = (R) => s.value = R),
990
+ type: "radio",
991
+ class: "aimd-quiz-recorder__choice-input",
992
+ "data-rec-focus-key": `${e.focusKeyPrefix || `quiz:${e.quiz.id}`}:single:${y.key}`,
993
+ name: `${e.quiz.id}-single`,
994
+ value: y.key,
995
+ disabled: e.readonly
996
+ }, null, 8, Yi), [
997
+ [wa, s.value]
998
+ ]),
999
+ h("span", Zi, [
1000
+ h("span", Xi, k(y.key) + ". " + k(y.text), 1),
1001
+ ae(y.key, y.explanation) ? (C(), T("span", Ji, k(y.explanation), 1)) : W("", !0)
1002
+ ])
1003
+ ]))), 128))
1004
+ ])) : W("", !0),
1005
+ e.quiz.type === "choice" && e.quiz.mode === "multiple" && e.quiz.options?.length ? (C(), T("div", en, [
1006
+ (C(!0), T(fe, null, he(e.quiz.options, (y) => (C(), T("label", {
1007
+ key: `${e.quiz.id}-multiple-${y.key}`,
1008
+ class: "aimd-quiz-recorder__option"
1009
+ }, [
1010
+ h("input", {
1011
+ type: "checkbox",
1012
+ class: "aimd-quiz-recorder__choice-input",
1013
+ "data-rec-focus-key": `${e.focusKeyPrefix || `quiz:${e.quiz.id}`}:multiple:${y.key}`,
1014
+ disabled: e.readonly,
1015
+ checked: A(y.key),
1016
+ onChange: (R) => D(y.key, R.target.checked)
1017
+ }, null, 40, tn),
1018
+ h("span", an, [
1019
+ h("span", nn, k(y.key) + ". " + k(y.text), 1),
1020
+ ae(y.key, y.explanation) ? (C(), T("span", rn, k(y.explanation), 1)) : W("", !0)
1021
+ ])
1022
+ ]))), 128))
1023
+ ])) : W("", !0),
1024
+ e.quiz.type === "open" ? ut((C(), T("textarea", {
1025
+ key: 4,
1026
+ "onUpdate:modelValue": x[1] || (x[1] = (y) => O.value = y),
1027
+ class: "aimd-quiz-recorder__open-input",
1028
+ "data-rec-focus-key": `${e.focusKeyPrefix || `quiz:${e.quiz.id}`}:open`,
1029
+ placeholder: m.value.quiz.openPlaceholder,
1030
+ rows: "4",
1031
+ readonly: e.readonly
1032
+ }, null, 8, ln)), [
1033
+ [Yt, O.value]
1034
+ ]) : W("", !0),
1035
+ e.quiz.type === "scale" && b.value.length && z.value.length && e.quiz.display === "list" ? (C(), T("div", sn, [
1036
+ (C(!0), T(fe, null, he(b.value, (y) => (C(), T("div", {
1037
+ key: `${e.quiz.id}-scale-list-${y.key}`,
1038
+ class: "aimd-scale__list-item"
1039
+ }, [
1040
+ h("div", on, k(y.stem), 1),
1041
+ h("div", dn, [
1042
+ (C(!0), T(fe, null, he(z.value, (R) => (C(), T("label", {
1043
+ key: `${e.quiz.id}-scale-list-${y.key}-${R.key}`,
1044
+ class: "aimd-scale__option"
1045
+ }, [
1046
+ h("input", {
1047
+ type: "radio",
1048
+ class: "aimd-quiz-recorder__choice-input",
1049
+ "data-rec-focus-key": `${e.focusKeyPrefix || `quiz:${e.quiz.id}`}:scale:${y.key}:${R.key}`,
1050
+ name: `${e.quiz.id}-scale-${y.key}`,
1051
+ value: R.key,
1052
+ checked: F(y.key) === R.key,
1053
+ disabled: e.readonly,
1054
+ onChange: (Z) => N(y.key, R.key)
1055
+ }, null, 40, cn),
1056
+ h("span", null, k(H(R)), 1)
1057
+ ]))), 128))
1058
+ ])
1059
+ ]))), 128))
1060
+ ])) : W("", !0),
1061
+ e.quiz.type === "scale" && b.value.length && z.value.length && e.quiz.display !== "list" ? (C(), T("div", un, [
1062
+ h("table", mn, [
1063
+ h("thead", null, [
1064
+ h("tr", null, [
1065
+ x[2] || (x[2] = h("th", { class: "aimd-scale__item-header" }, "Item", -1)),
1066
+ (C(!0), T(fe, null, he(z.value, (y) => (C(), T("th", {
1067
+ key: `${e.quiz.id}-scale-head-${y.key}`
1068
+ }, k(H(y)), 1))), 128))
1069
+ ])
1070
+ ]),
1071
+ h("tbody", null, [
1072
+ (C(!0), T(fe, null, he(b.value, (y) => (C(), T("tr", {
1073
+ key: `${e.quiz.id}-scale-row-${y.key}`
1074
+ }, [
1075
+ h("th", fn, k(y.stem), 1),
1076
+ (C(!0), T(fe, null, he(z.value, (R) => (C(), T("td", {
1077
+ key: `${e.quiz.id}-scale-cell-${y.key}-${R.key}`,
1078
+ class: "aimd-scale__cell"
1079
+ }, [
1080
+ h("label", vn, [
1081
+ h("input", {
1082
+ type: "radio",
1083
+ class: "aimd-quiz-recorder__choice-input",
1084
+ "data-rec-focus-key": `${e.focusKeyPrefix || `quiz:${e.quiz.id}`}:scale:${y.key}:${R.key}`,
1085
+ name: `${e.quiz.id}-scale-${y.key}`,
1086
+ value: R.key,
1087
+ checked: F(y.key) === R.key,
1088
+ disabled: e.readonly,
1089
+ onChange: (Z) => N(y.key, R.key)
1090
+ }, null, 40, hn)
1091
+ ])
1092
+ ]))), 128))
1093
+ ]))), 128))
1094
+ ])
1095
+ ])
1096
+ ])) : W("", !0),
1097
+ E.value && oe.value ? (C(), T("div", {
1098
+ key: 7,
1099
+ class: pe(["aimd-quiz__grade-panel", `aimd-quiz__grade-panel--${j.value}`])
1100
+ }, [
1101
+ h("div", pn, [
1102
+ h("span", {
1103
+ class: pe(["aimd-quiz__grade-status", `aimd-quiz__grade-status--${j.value}`])
1104
+ }, k(q.value), 3),
1105
+ h("span", {
1106
+ class: pe(["aimd-quiz__grade-score", `aimd-quiz__grade-score--${j.value}`])
1107
+ }, k(m.value.quiz.gradedScore(E.value.earned_score, E.value.max_score)), 3)
1108
+ ]),
1109
+ E.value.band ? (C(), T("div", gn, [
1110
+ h("strong", null, k(m.value.quiz.classification) + ":", 1),
1111
+ Ze(" " + k(E.value.band.label), 1)
1112
+ ])) : W("", !0),
1113
+ E.value.band?.interpretation ? (C(), T("div", yn, [
1114
+ h("strong", null, k(m.value.quiz.interpretation) + ":", 1),
1115
+ Ze(" " + k(E.value.band.interpretation), 1)
1116
+ ])) : W("", !0),
1117
+ E.value.review_required ? (C(), T("div", bn, k(m.value.quiz.reviewRequired), 1)) : W("", !0),
1118
+ E.value.feedback ? (C(), T("div", _n, [
1119
+ h("strong", null, k(m.value.quiz.feedback) + ":", 1),
1120
+ Ze(" " + k(E.value.feedback), 1)
1121
+ ])) : W("", !0),
1122
+ te.value.length ? (C(), T("ul", kn, [
1123
+ (C(!0), T(fe, null, he(te.value, (y) => (C(), T("li", {
1124
+ key: `${e.quiz.id}-grade-blank-${y.key}`
1125
+ }, k(y.key) + " · " + k(m.value.quiz.gradedScore(y.earned_score, y.max_score)), 1))), 128))
1126
+ ])) : W("", !0),
1127
+ B.value.length ? (C(), T("ul", wn, [
1128
+ (C(!0), T(fe, null, he(B.value, (y) => (C(), T("li", {
1129
+ key: `${e.quiz.id}-grade-rubric-${y.id}`
1130
+ }, k(y.id) + " · " + k(m.value.quiz.gradedScore(y.earned_score, y.max_score)), 1))), 128))
1131
+ ])) : W("", !0)
1132
+ ], 2)) : W("", !0)
1133
+ ]));
1134
+ }
1135
+ }), En = /* @__PURE__ */ Ge(Cn, [["__scopeId", "data-v-1795b6c8"]]), Tn = { class: "aimd-protocol-recorder" }, Sn = {
1136
+ key: 0,
1137
+ class: "aimd-protocol-recorder__error"
1138
+ }, zn = {
1139
+ key: 0,
1140
+ class: "aimd-protocol-recorder__timing"
1141
+ }, $n = {
1142
+ key: 0,
1143
+ class: "aimd-protocol-recorder__timing-pill aimd-protocol-recorder__timing-pill--estimate"
1144
+ }, Dn = {
1145
+ key: 1,
1146
+ class: "aimd-protocol-recorder__timing-pill"
1147
+ }, Rn = {
1148
+ key: 2,
1149
+ class: "aimd-protocol-recorder__empty"
1150
+ }, qn = /* @__PURE__ */ _e({
1151
+ __name: "AimdRecorder",
1152
+ props: {
1153
+ content: {},
1154
+ modelValue: { default: void 0 },
1155
+ readonly: { type: Boolean, default: !1 },
1156
+ currentUserName: { default: void 0 },
1157
+ now: { default: void 0 },
1158
+ locale: { default: void 0 },
1159
+ messages: { default: void 0 },
1160
+ quizGrades: { default: void 0 },
1161
+ submitted: { type: Boolean, default: !1 },
1162
+ choiceOptionExplanationMode: { default: "hidden" },
1163
+ scaleGradeDisplayMode: { default: "hidden" },
1164
+ stepDetailDisplay: { default: "auto" },
1165
+ fieldMeta: { default: void 0 },
1166
+ fieldState: { default: void 0 },
1167
+ wrapField: { type: Function, default: void 0 },
1168
+ customRenderers: { default: void 0 },
1169
+ fieldAdapters: { default: void 0 },
1170
+ resolveFile: { type: Function, default: void 0 },
1171
+ typePlugins: { default: void 0 }
1172
+ },
1173
+ emits: ["update:modelValue", "fields-change", "error", "field-change", "field-blur", "assigner-request", "assigner-cancel", "table-add-row", "table-remove-row"],
1174
+ setup(e, { expose: t, emit: i }) {
1175
+ const a = e, n = i, p = L([]), s = L(""), f = L(null), u = mt(gt());
1176
+ let A = 0, D = 0, V = !1, P = !1, G = !1, Y = null, F = null;
1177
+ const N = L(Date.now());
1178
+ let O = null;
1179
+ const H = w(() => $a(a.locale)), m = w(() => Zt(H.value, a.messages)), M = w(() => ii(a.typePlugins)), b = _e({
1180
+ name: "AimdRecorderInlineNodesOutlet",
1181
+ props: {
1182
+ nodes: {
1183
+ type: Array,
1184
+ required: !0
1185
+ }
1186
+ },
1187
+ setup(g) {
1188
+ return () => g.nodes;
1189
+ }
1190
+ });
1191
+ function z(g, _, S, I, v) {
1192
+ return Ei(g, _, S, I, v, {
1193
+ fieldAdapters: a.fieldAdapters,
1194
+ wrapField: a.wrapField,
1195
+ readonly: a.readonly,
1196
+ locale: H.value,
1197
+ messages: m.value,
1198
+ record: u,
1199
+ fieldMeta: a.fieldMeta,
1200
+ fieldState: a.fieldState
1201
+ });
1202
+ }
1203
+ const X = {
1204
+ var: [],
1205
+ var_table: [],
1206
+ client_assigner: [],
1207
+ quiz: [],
1208
+ step: [],
1209
+ check: [],
1210
+ ref_step: [],
1211
+ ref_var: [],
1212
+ ref_fig: [],
1213
+ cite: [],
1214
+ fig: []
1215
+ }, U = L(X), E = L([]), j = w(() => ni(U.value.step_hierarchy ?? [])), q = w(() => ri(u.step, N.value)), te = w(() => j.value > 0 || q.value > 0), B = w(() => ze(j.value, H.value)), J = w(() => ze(q.value, H.value)), oe = w(() => Object.values(u.step).some((g) => Je(g)));
1216
+ function ae() {
1217
+ O && (clearInterval(O), O = null), oe.value && (O = setInterval(() => {
1218
+ N.value = Date.now();
1219
+ }, 1e3));
1220
+ }
1221
+ function c(g) {
1222
+ return {
1223
+ elapsed_ms: g.elapsed_ms,
1224
+ timer_started_at_ms: g.timer_started_at_ms,
1225
+ started_at_ms: g.started_at_ms,
1226
+ ended_at_ms: g.ended_at_ms
1227
+ };
1228
+ }
1229
+ function x() {
1230
+ V || n("update:modelValue", Jt(u));
1231
+ }
1232
+ function y() {
1233
+ Y = si(f.value) ?? Y, F = ++D, !P && (P = !0, Promise.resolve().then(() => {
1234
+ P = !1;
1235
+ const g = Y, _ = F ?? D;
1236
+ Y = null, F = null, ve(void 0, g, _);
1237
+ }));
1238
+ }
1239
+ function R(g) {
1240
+ const _ = g?.runClientAssigners ? Z.applyCurrentClientAssigners() : !1;
1241
+ x(), (g?.rebuild || _) && y();
1242
+ }
1243
+ const Z = oi({
1244
+ readonly: () => a.readonly,
1245
+ clientAssigners: E,
1246
+ localRecord: u,
1247
+ onError: (g) => n("error", g),
1248
+ emitRecordUpdate: x,
1249
+ scheduleInlineRebuild: y
1250
+ }), ce = di({
1251
+ readonly: () => a.readonly,
1252
+ localRecord: u,
1253
+ markRecordChanged: R,
1254
+ scheduleInlineRebuild: y,
1255
+ emitTableAddRow: (g) => n("table-add-row", g),
1256
+ emitTableRemoveRow: (g) => n("table-remove-row", g)
1257
+ }), le = li({
1258
+ readonly: () => a.readonly,
1259
+ currentUserName: () => a.currentUserName,
1260
+ now: () => a.now,
1261
+ fieldMeta: () => a.fieldMeta,
1262
+ fieldState: () => a.fieldState,
1263
+ typePlugins: () => M.value,
1264
+ wrapField: () => a.wrapField
1265
+ });
1266
+ function qe(g) {
1267
+ const _ = g.id, S = `var:${_}`, I = a.fieldMeta?.[S];
1268
+ if (a.customRenderers?.var) {
1269
+ const de = a.customRenderers.var(g, {}, []);
1270
+ if (de) return z("var", S, g, u.var[_], de);
1271
+ }
1272
+ const v = g.definition?.type || "str", me = le.getTypePlugin(S, v), ie = wi(v, {
1273
+ inputType: I?.inputType,
1274
+ codeLanguage: I?.codeLanguage,
1275
+ typePlugin: me
1276
+ }), we = I?.placeholder ?? le.getVarPlaceholder(g);
1277
+ function $(de) {
1278
+ le.clearVarInputDisplayOverride(_), u.var[_] = de, R({ runClientAssigners: !0 }), n("field-change", { section: "var", fieldKey: _, value: de });
1279
+ }
1280
+ function Q() {
1281
+ n("field-blur", { section: "var", fieldKey: _ });
1282
+ }
1283
+ if (!(_ in u.var)) {
1284
+ u.var[_] = le.getVarInitialValue(g, v, S);
1285
+ const de = le.getVarInitialDisplayOverride(g, v, S);
1286
+ de && le.setVarInputDisplayOverride(_, de), G = !0;
1287
+ }
1288
+ if (ie === "datetime") {
1289
+ const de = Ci(u.var[_]);
1290
+ de !== u.var[_] && (u.var[_] = de, G = !0);
1291
+ }
1292
+ const se = le.normalizeVarValue(
1293
+ g,
1294
+ v,
1295
+ S,
1296
+ u.var[_],
1297
+ ie
1298
+ );
1299
+ JSON.stringify(se) !== JSON.stringify(u.var[_]) && (u.var[_] = se, G = !0);
1300
+ const Ce = le.getVarDisplayValue(
1301
+ _,
1302
+ g,
1303
+ v,
1304
+ u.var[_],
1305
+ ie,
1306
+ S
1307
+ ), ye = le.isFieldDisabled(S), Oe = le.fieldStateClasses(S);
1308
+ if (me?.renderField) {
1309
+ const de = me.renderField({
1310
+ type: v,
1311
+ normalizedType: Xt(v),
1312
+ fieldKey: S,
1313
+ node: g,
1314
+ value: u.var[_],
1315
+ inputKind: ie,
1316
+ fieldMeta: I,
1317
+ currentUserName: a.currentUserName,
1318
+ now: a.now,
1319
+ readonly: a.readonly,
1320
+ disabled: ye,
1321
+ locale: H.value,
1322
+ messages: m.value,
1323
+ record: u,
1324
+ displayValue: Ce,
1325
+ extraClasses: Oe,
1326
+ placeholder: we,
1327
+ fieldState: a.fieldState?.[S],
1328
+ emitChange: $,
1329
+ emitBlur: Q
1330
+ });
1331
+ if (de)
1332
+ return z("var", S, g, u.var[_], de);
1333
+ }
1334
+ const it = d(Ai, {
1335
+ node: g,
1336
+ value: u.var[_],
1337
+ disabled: ye,
1338
+ extraClasses: Oe,
1339
+ messages: m.value,
1340
+ fieldMeta: I,
1341
+ displayValue: Ce,
1342
+ inputKind: ie,
1343
+ typePlugin: me,
1344
+ initialized: _ in u.var,
1345
+ onChange: (de) => {
1346
+ $(de.value);
1347
+ },
1348
+ onBlur: () => Q()
1349
+ });
1350
+ return z("var", S, g, u.var[_], it);
1351
+ }
1352
+ function ge(g) {
1353
+ const _ = g.id, S = `var_table:${_}`, I = bi(g), v = ce.ensureVarTableRows(_, I), me = le.isFieldDisabled(S), ie = I.filter(($) => !!a.fieldMeta?.[`var_table:${_}:${$}`]?.disabled), we = d(Vi, {
1354
+ node: g,
1355
+ rows: v,
1356
+ columns: I,
1357
+ disabled: me,
1358
+ readonly: a.readonly,
1359
+ settlingRowKey: ce.getSettlingVarTableRowKey(),
1360
+ messages: m.value,
1361
+ fieldMeta: a.fieldMeta,
1362
+ fieldState: a.fieldState,
1363
+ onCellInput: ($) => {
1364
+ $.row[$.column] = $.value, R({ runClientAssigners: !0 }), n("field-change", {
1365
+ section: "var_table",
1366
+ fieldKey: `${$.tableName}:${$.column}`,
1367
+ value: $.value
1368
+ });
1369
+ },
1370
+ onCellPaste: ($) => {
1371
+ const Q = I.indexOf($.column);
1372
+ if (Q < 0)
1373
+ return;
1374
+ const se = _i($.text), Ce = ki(
1375
+ v,
1376
+ I,
1377
+ $.rowIndex,
1378
+ Q,
1379
+ se,
1380
+ { disabledColumns: ie }
1381
+ );
1382
+ if (!(Ce.rowsAdded === 0 && Ce.changedCells.length === 0)) {
1383
+ R({ rebuild: !0, runClientAssigners: !0 });
1384
+ for (let ye = 0; ye < Ce.rowsAdded; ye += 1)
1385
+ n("table-add-row", { tableName: $.tableName, columns: I });
1386
+ for (const ye of Ce.changedCells)
1387
+ n("field-change", {
1388
+ section: "var_table",
1389
+ fieldKey: `${$.tableName}:${ye.column}`,
1390
+ value: ye.value
1391
+ });
1392
+ }
1393
+ },
1394
+ onCellBlur: ($) => {
1395
+ n("field-blur", { section: "var_table", fieldKey: `${$.tableName}:${$.column}` });
1396
+ },
1397
+ onAddRow: ($) => {
1398
+ ce.addVarTableRow($.tableName, $.columns);
1399
+ },
1400
+ onRemoveRow: ($) => {
1401
+ ce.removeVarTableRow($.tableName, $.rowIndex, $.columns);
1402
+ },
1403
+ onDragStart: ($) => {
1404
+ ce.startVarTableRowDrag($.tableName, $.rowIndex, $.event);
1405
+ },
1406
+ onDragOver: ($) => {
1407
+ ce.handleVarTableRowDragOver($.tableName, $.rowIndex, $.event);
1408
+ },
1409
+ onDragDrop: ($) => {
1410
+ ce.handleVarTableRowDrop($.tableName, $.rowIndex, $.columns, $.event);
1411
+ },
1412
+ onDragEnd: () => {
1413
+ ce.endVarTableRowDrag();
1414
+ }
1415
+ });
1416
+ return z("var_table", S, g, v, we);
1417
+ }
1418
+ function ke(g) {
1419
+ if (!g || typeof g != "object")
1420
+ return !1;
1421
+ const _ = g.props;
1422
+ if (!_)
1423
+ return !1;
1424
+ const S = _.class, I = Array.isArray(S) ? S : typeof S == "string" ? [S] : [];
1425
+ return _["data-aimd-step-body"] === "true" || _["data-aimd-step-body"] === !0 || _.dataAimdStepBody === "true" || _.dataAimdStepBody === !0 || I.some((v) => typeof v == "string" && v.includes("aimd-step-body"));
1426
+ }
1427
+ function Ie(g = []) {
1428
+ if (g.length === 0)
1429
+ return [];
1430
+ const _ = g.find((I) => ke(I));
1431
+ if (!_ || typeof _ != "object" || _ === null)
1432
+ return g;
1433
+ const S = _.children;
1434
+ return Array.isArray(S) ? S : S == null ? [] : [S];
1435
+ }
1436
+ function Pe(g) {
1437
+ if (!g || typeof g != "object" || !("props" in g))
1438
+ return !1;
1439
+ const _ = g.props;
1440
+ if (!_)
1441
+ return !1;
1442
+ const S = _.class, I = Array.isArray(S) ? S : typeof S == "string" ? [S] : [];
1443
+ return _["data-aimd-check-body"] === "true" || _["data-aimd-check-body"] === !0 || _.dataAimdCheckBody === "true" || _.dataAimdCheckBody === !0 || I.some((v) => typeof v == "string" && v.includes("aimd-check-body"));
1444
+ }
1445
+ function Te(g = []) {
1446
+ if (g.length === 0)
1447
+ return [];
1448
+ const _ = g.find((I) => Pe(I));
1449
+ if (!_ || typeof _ != "object" || _ === null)
1450
+ return g;
1451
+ const S = _.children;
1452
+ return Array.isArray(S) ? S : S == null ? [] : [S];
1453
+ }
1454
+ function ue(g, _ = []) {
1455
+ const S = g.id, I = `step:${S}`;
1456
+ S in u.step || (u.step[S] = vi(), G = !0);
1457
+ const v = u.step[S], me = le.isFieldDisabled(I), ie = le.fieldStateClasses(I), we = Ie(_), $ = d(Fi, {
1458
+ node: g,
1459
+ state: v,
1460
+ bodyNodes: we,
1461
+ disabled: me,
1462
+ extraClasses: ie,
1463
+ detailDisplay: a.stepDetailDisplay,
1464
+ locale: H.value,
1465
+ messages: m.value,
1466
+ onCheckChange: (Q) => {
1467
+ const se = Je(v);
1468
+ yi(v, Q.value, Date.now()), N.value = Date.now(), R(), n("field-change", { section: "step", fieldKey: Q.id, value: Q.value }), se && n("field-change", { section: "step", fieldKey: `${Q.id}:timer`, value: c(v) });
1469
+ },
1470
+ onAnnotationChange: (Q) => {
1471
+ v.annotation = Q.value, R(), n("field-change", { section: "step", fieldKey: `${Q.id}:annotation`, value: Q.value });
1472
+ },
1473
+ onTimerStart: (Q) => {
1474
+ gi(v, Date.now()) && (N.value = Date.now(), R(), n("field-change", { section: "step", fieldKey: `${Q.id}:timer`, value: c(v) }));
1475
+ },
1476
+ onTimerPause: (Q) => {
1477
+ pi(v, Date.now()) && (N.value = Date.now(), R(), n("field-change", { section: "step", fieldKey: `${Q.id}:timer`, value: c(v) }));
1478
+ },
1479
+ onTimerReset: (Q) => {
1480
+ hi(v) && (N.value = Date.now(), R(), n("field-change", { section: "step", fieldKey: `${Q.id}:timer`, value: c(v) }));
1481
+ },
1482
+ onBlur: (Q) => {
1483
+ n("field-blur", { section: "step", fieldKey: Q.id });
1484
+ }
1485
+ });
1486
+ return z("step", I, g, v, $);
1487
+ }
1488
+ function Se(g, _ = []) {
1489
+ const S = g.id, I = `check:${S}`;
1490
+ S in u.check || (u.check[S] = fi(), G = !0);
1491
+ const v = u.check[S], me = le.isFieldDisabled(I), ie = le.fieldStateClasses(I), we = Te(_), $ = d(Bi, {
1492
+ node: g,
1493
+ state: v,
1494
+ bodyNodes: we,
1495
+ disabled: me,
1496
+ extraClasses: ie,
1497
+ messages: m.value,
1498
+ onCheckChange: (Q) => {
1499
+ v.checked = Q.value, R(), n("field-change", { section: "check", fieldKey: Q.id, value: Q.value });
1500
+ },
1501
+ onAnnotationChange: (Q) => {
1502
+ v.annotation = Q.value, R(), n("field-change", { section: "check", fieldKey: `${Q.id}:annotation`, value: Q.value });
1503
+ },
1504
+ onBlur: (Q) => {
1505
+ n("field-blur", { section: "check", fieldKey: Q.id });
1506
+ }
1507
+ });
1508
+ return z("check", I, g, v, $);
1509
+ }
1510
+ function Ae(g) {
1511
+ const _ = g.id, S = `quiz:${_}`, I = {
1512
+ id: _,
1513
+ type: g.quizType,
1514
+ stem: g.stem,
1515
+ title: g.title,
1516
+ description: g.description,
1517
+ mode: g.mode,
1518
+ display: g.display,
1519
+ options: g.options,
1520
+ blanks: g.blanks,
1521
+ items: g.items,
1522
+ grading: g.grading,
1523
+ default: g.default,
1524
+ rubric: g.rubric,
1525
+ score: g.score,
1526
+ extra: g.extra
1527
+ };
1528
+ _ in u.quiz || (u.quiz[_] = mi(I));
1529
+ const v = d(En, {
1530
+ class: "aimd-rec-inline aimd-rec-inline--quiz",
1531
+ quiz: I,
1532
+ modelValue: u.quiz[_],
1533
+ grade: a.quizGrades?.[_] ?? null,
1534
+ submitted: a.submitted,
1535
+ readonly: a.readonly,
1536
+ focusKeyPrefix: `quiz:${_}`,
1537
+ locale: H.value,
1538
+ messages: a.messages,
1539
+ choiceOptionExplanationMode: a.choiceOptionExplanationMode,
1540
+ scaleGradeDisplayMode: a.scaleGradeDisplayMode,
1541
+ "onUpdate:modelValue": (me) => {
1542
+ u.quiz[_] = me, R(), n("field-change", { section: "quiz", fieldKey: _, value: me });
1543
+ }
1544
+ });
1545
+ return z("quiz", S, g, u.quiz[_], v);
1546
+ }
1547
+ async function ve(g, _, S) {
1548
+ G = !1;
1549
+ const I = await Sa(a.content || "", {
1550
+ locale: H.value,
1551
+ groupStepBodies: !0,
1552
+ groupCheckBodies: !0,
1553
+ context: {
1554
+ mode: "edit",
1555
+ readonly: a.readonly,
1556
+ value: u
1557
+ },
1558
+ blockVarTypes: ["AiralogyMarkdown"],
1559
+ aimdRenderers: {
1560
+ var: (v) => qe(v),
1561
+ var_table: (v) => ge(v),
1562
+ step: (v, me, ie) => ue(v, ie),
1563
+ check: (v, me, ie) => Se(v, ie),
1564
+ quiz: (v) => Ae(v)
1565
+ }
1566
+ });
1567
+ g !== void 0 && g !== A || S !== void 0 && S !== D || (p.value = I.nodes, await Me(), ci(f.value, _ ?? null), G && x());
1568
+ }
1569
+ async function at() {
1570
+ const g = ++A, _ = ++D;
1571
+ try {
1572
+ s.value = "";
1573
+ const S = ft(a.content || "");
1574
+ if (g !== A) return;
1575
+ U.value = S, E.value = S.client_assigner || [], n("fields-change", S);
1576
+ const I = ui(u, S), v = Z.applyCurrentClientAssigners();
1577
+ (I || v) && x(), await ve(g, void 0, _);
1578
+ } catch (S) {
1579
+ if (g !== A)
1580
+ return;
1581
+ const I = S instanceof Error ? S.message : String(S);
1582
+ s.value = I, p.value = [], U.value = X, E.value = [], n("fields-change", X), n("error", I);
1583
+ }
1584
+ }
1585
+ return re(
1586
+ () => a.modelValue,
1587
+ (g) => {
1588
+ const _ = Be(g) !== Be(u);
1589
+ if (!_)
1590
+ return;
1591
+ V = !0, vt(u, g), V = !1;
1592
+ const S = Z.applyCurrentClientAssigners();
1593
+ S && x(), (_ || S) && y();
1594
+ },
1595
+ { deep: !0, immediate: !0 }
1596
+ ), re(oe, () => {
1597
+ N.value = Date.now(), ae();
1598
+ }, { immediate: !0 }), re(
1599
+ () => ({
1600
+ content: a.content,
1601
+ locale: a.locale,
1602
+ messages: a.messages
1603
+ }),
1604
+ () => {
1605
+ at();
1606
+ },
1607
+ { immediate: !0, deep: !0 }
1608
+ ), re(
1609
+ () => a.quizGrades,
1610
+ () => {
1611
+ y();
1612
+ },
1613
+ { deep: !0 }
1614
+ ), re(
1615
+ () => a.choiceOptionExplanationMode,
1616
+ () => {
1617
+ y();
1618
+ }
1619
+ ), re(
1620
+ () => a.scaleGradeDisplayMode,
1621
+ () => {
1622
+ y();
1623
+ }
1624
+ ), re(
1625
+ () => a.submitted,
1626
+ () => {
1627
+ y();
1628
+ }
1629
+ ), tt(() => {
1630
+ O && clearInterval(O);
1631
+ }), t({
1632
+ runClientAssigner: Z.triggerClientAssigner,
1633
+ runManualClientAssigners: Z.triggerManualClientAssigners
1634
+ }), (g, _) => (C(), T("div", Tn, [
1635
+ s.value ? (C(), T("div", Sn, k(s.value), 1)) : (C(), T(fe, { key: 1 }, [
1636
+ te.value ? (C(), T("div", zn, [
1637
+ j.value > 0 ? (C(), T("span", $n, k(m.value.step.protocolEstimatedTotal(B.value)), 1)) : W("", !0),
1638
+ q.value > 0 ? (C(), T("span", Dn, k(m.value.step.protocolRecordedTotal(J.value)), 1)) : W("", !0)
1639
+ ])) : W("", !0),
1640
+ p.value.length ? (C(), T("div", {
1641
+ key: 1,
1642
+ ref_key: "contentRoot",
1643
+ ref: f,
1644
+ class: "aimd-protocol-recorder__content"
1645
+ }, [
1646
+ Fe(Ee(b), { nodes: p.value }, null, 8, ["nodes"])
1647
+ ], 512)) : (C(), T("div", Rn, k(m.value.common.emptyContent), 1))
1648
+ ], 64))
1649
+ ]));
1650
+ }
1651
+ }), yt = /* @__PURE__ */ Ge(qn, [["__scopeId", "data-v-4f4e01d6"]]), An = /\{\{(var_table|var|step|check)\s*\|\s*([^}]+)\}\}/g, xn = /```quiz[^\n]*\n[\s\S]*?\n```/g;
1652
+ function Lt(e) {
1653
+ const t = e.trim();
1654
+ return t.startsWith('"') && t.endsWith('"') || t.startsWith("'") && t.endsWith("'") ? t.slice(1, -1) : t;
1655
+ }
1656
+ function Nt(e, t) {
1657
+ const i = e.lastIndexOf(`
1658
+ `, Math.max(0, t - 1));
1659
+ return i === -1 ? 0 : i + 1;
1660
+ }
1661
+ function Ht(e, t) {
1662
+ const i = e.indexOf(`
1663
+ `, t);
1664
+ return i === -1 ? e.length : i + 1;
1665
+ }
1666
+ function Kt(e, t, i, a) {
1667
+ if (a === "block") {
1668
+ const u = Nt(e, t);
1669
+ let A = Ht(e, i);
1670
+ for (; A < e.length && e.slice(A, A + 1) === `
1671
+ `; )
1672
+ A += 1;
1673
+ return { segmentStart: u, segmentEnd: A };
1674
+ }
1675
+ const n = Nt(e, t), p = Ht(e, i), s = e.slice(n, p).replace(/\r?\n$/, ""), f = e.slice(t, i);
1676
+ if (s.trim() === f.trim()) {
1677
+ let u = p;
1678
+ for (; u < e.length && e.slice(u, u + 1) === `
1679
+ `; )
1680
+ u += 1;
1681
+ return {
1682
+ segmentStart: n,
1683
+ segmentEnd: u
1684
+ };
1685
+ }
1686
+ return { segmentStart: t, segmentEnd: i };
1687
+ }
1688
+ function bt(e) {
1689
+ const t = e.search(/,\s*(?=\w+\s*=)/), i = t >= 0 ? e.slice(0, t) : e, a = t >= 0 ? e.slice(t) : "", n = i.trim();
1690
+ if (!n.includes(":")) {
1691
+ const A = n.indexOf("=");
1692
+ return A >= 0 ? {
1693
+ id: n.slice(0, A).trim(),
1694
+ valueType: "",
1695
+ defaultPart: n.slice(A + 1).trim(),
1696
+ suffixRaw: a
1697
+ } : {
1698
+ id: n.trim(),
1699
+ valueType: "",
1700
+ defaultPart: "",
1701
+ suffixRaw: a
1702
+ };
1703
+ }
1704
+ const p = n.indexOf(":"), s = n.slice(0, p).trim(), f = n.slice(p + 1).trim(), u = f.indexOf("=");
1705
+ return u >= 0 ? {
1706
+ id: s,
1707
+ valueType: f.slice(0, u).trim(),
1708
+ defaultPart: f.slice(u + 1).trim(),
1709
+ suffixRaw: a
1710
+ } : {
1711
+ id: s,
1712
+ valueType: f.trim(),
1713
+ defaultPart: "",
1714
+ suffixRaw: a
1715
+ };
1716
+ }
1717
+ function ea(e) {
1718
+ let t = (e.id || "my_var").trim() || "my_var";
1719
+ const i = (e.valueType || "").trim(), a = (e.defaultPart || "").trim();
1720
+ return i && (t += `: ${i}`), a && (t += ` = ${a}`), t + (e.suffixRaw || "");
1721
+ }
1722
+ function Vn(e) {
1723
+ return /subvars\s*=\s*\[/.test(e) ? !0 : /^[A-Za-z_][\w-]*\s*\([^)]*\)\s*$/.test(e.trim());
1724
+ }
1725
+ function Mn(e) {
1726
+ const t = e.trim();
1727
+ if (!t)
1728
+ return "";
1729
+ if (t.startsWith("var(") && t.endsWith(")")) {
1730
+ const a = t.slice(4, -1).trim(), n = a.search(/[:=,\s]/);
1731
+ return (n === -1 ? a : a.slice(0, n)).trim();
1732
+ }
1733
+ const i = t.indexOf(":");
1734
+ return i >= 0 ? t.slice(0, i).trim() : t;
1735
+ }
1736
+ function Fn(e) {
1737
+ const t = e.trim(), i = t.match(/^([A-Za-z_][\w-]*)\s*\(([^)]*)\)\s*$/);
1738
+ if (i) {
1739
+ const s = i[2].split(",").map((f) => f.trim()).filter(Boolean).join(", ");
1740
+ return {
1741
+ id: i[1],
1742
+ subvarsText: s || "col1, col2"
1743
+ };
1744
+ }
1745
+ const a = t.split(",")[0]?.trim() || "my_table", p = t.match(/subvars\s*=\s*\[([\s\S]*?)\]/)?.[1]?.split(",").map((s) => Mn(s)).filter(Boolean).join(", ");
1746
+ return {
1747
+ id: a,
1748
+ subvarsText: p || "col1, col2"
1749
+ };
1750
+ }
1751
+ function Bn(e) {
1752
+ return {
1753
+ id: e.trim().split(/,\s*/)[0]?.trim() || "my_step"
1754
+ };
1755
+ }
1756
+ function In(e) {
1757
+ return {
1758
+ id: e.trim().split(/,\s*/)[0]?.trim() || "my_check"
1759
+ };
1760
+ }
1761
+ function Pn(e) {
1762
+ const t = e.match(/^\s*id:\s*(.+)\s*$/m), i = e.match(/^\s*type:\s*(.+)\s*$/m);
1763
+ return {
1764
+ id: Lt(t?.[1] || "quiz_choice_1"),
1765
+ quizType: Lt(i?.[1] || "choice")
1766
+ };
1767
+ }
1768
+ function ht(e, t) {
1769
+ return e.replace(/^(\{\{(?:var_table|var|step|check)\s*\|\s*)([\s\S]*?)(\}\})$/, `$1${t}$3`);
1770
+ }
1771
+ function On(e, t) {
1772
+ return e.replace(/^(\s*)([A-Za-z_][\w-]*)/, `$1${t}`);
1773
+ }
1774
+ function Ln(e, t, i) {
1775
+ const a = e.match(/^\{\{(?:var_table|var|step|check)\s*\|\s*([\s\S]*?)\}\}$/);
1776
+ if (!a)
1777
+ return e;
1778
+ const n = a[1];
1779
+ if (t === "var") {
1780
+ const p = bt(n);
1781
+ return ht(e, ea({
1782
+ ...p,
1783
+ id: i
1784
+ }));
1785
+ }
1786
+ return ht(e, On(n, i));
1787
+ }
1788
+ function Nn(e, t) {
1789
+ const i = e.match(/^\{\{var\s*\|\s*([\s\S]*?)\}\}$/);
1790
+ if (!i)
1791
+ return e;
1792
+ const a = bt(i[1]);
1793
+ return ht(e, ea({
1794
+ ...a,
1795
+ valueType: t
1796
+ }));
1797
+ }
1798
+ function Hn(e, t) {
1799
+ return /^\s*id:\s*.+$/m.test(e) ? e.replace(/^\s*id:\s*.+$/m, `id: ${t}`) : e.replace(/^```quiz[^\n]*\n/, (i) => `${i}id: ${t}
1800
+ `);
1801
+ }
1802
+ function Ue(e, t) {
1803
+ switch (e) {
1804
+ case "var": {
1805
+ let i = (t.name || "").trim() || "my_var";
1806
+ const a = (t.type || "").trim();
1807
+ return a && (i += `: ${a}`), `{{var|${i}}}`;
1808
+ }
1809
+ case "var_table": {
1810
+ const i = (t.name || "").trim() || "my_table", a = (t.subvars || "").split(",").map((n) => n.trim()).filter(Boolean);
1811
+ return `{{var_table|${i}, subvars=[${(a.length > 0 ? a : ["col1", "col2"]).join(", ")}]}}`;
1812
+ }
1813
+ case "step":
1814
+ return `{{step|${(t.name || "").trim() || "my_step"}}}`;
1815
+ case "check":
1816
+ return `{{check|${(t.name || "").trim() || "my_check"}}}`;
1817
+ case "quiz": {
1818
+ const i = (t.id || "").trim() || "quiz_choice_1", a = (t.quizType || "").trim() || "choice", n = t.stem || "Fill the question stem";
1819
+ return a === "open" ? [
1820
+ "```quiz",
1821
+ `id: ${i}`,
1822
+ "type: open",
1823
+ "stem: |",
1824
+ ` ${n}`,
1825
+ "```"
1826
+ ].join(`
1827
+ `) : a === "scale" ? [
1828
+ "```quiz",
1829
+ `id: ${i}`,
1830
+ "type: scale",
1831
+ "title: Scale title",
1832
+ "stem: |",
1833
+ ` ${n}`,
1834
+ "display: matrix",
1835
+ "items:",
1836
+ " - key: item_1",
1837
+ " stem: First item",
1838
+ " - key: item_2",
1839
+ " stem: Second item",
1840
+ "options:",
1841
+ " - key: never",
1842
+ " text: Never",
1843
+ " points: 0",
1844
+ " - key: sometimes",
1845
+ " text: Sometimes",
1846
+ " points: 1",
1847
+ " - key: often",
1848
+ " text: Often",
1849
+ " points: 2",
1850
+ "grading:",
1851
+ " strategy: sum",
1852
+ "```"
1853
+ ].join(`
1854
+ `) : [
1855
+ "```quiz",
1856
+ `id: ${i}`,
1857
+ `type: ${a}`,
1858
+ "stem: |",
1859
+ ` ${n}`,
1860
+ a === "blank" ? `blanks:
1861
+ - key: blank_1
1862
+ answer: answer` : `mode: single
1863
+ options:
1864
+ - key: A
1865
+ text: Option A
1866
+ - key: B
1867
+ text: Option B`,
1868
+ "```"
1869
+ ].join(`
1870
+ `);
1871
+ }
1872
+ }
1873
+ }
1874
+ function _t(e, t) {
1875
+ const i = t?.id?.trim();
1876
+ switch (e) {
1877
+ case "var":
1878
+ return Ue("var", {
1879
+ name: i || "my_var",
1880
+ type: t?.valueType?.trim() || "str"
1881
+ });
1882
+ case "var_table":
1883
+ return Ue("var_table", {
1884
+ name: i || "my_table",
1885
+ subvars: t?.subvarsText?.trim() || "col1, col2"
1886
+ });
1887
+ case "step":
1888
+ return Ue("step", {
1889
+ name: i || "my_step"
1890
+ });
1891
+ case "check":
1892
+ return Ue("check", {
1893
+ name: i || "my_check"
1894
+ });
1895
+ case "quiz":
1896
+ return Ue("quiz", {
1897
+ id: i || "quiz_choice_1",
1898
+ quizType: t?.quizType?.trim() || "choice"
1899
+ });
1900
+ }
1901
+ }
1902
+ function $e(e, t, i, a) {
1903
+ return e.slice(0, t) + a + e.slice(i);
1904
+ }
1905
+ function Kn(e, t, i) {
1906
+ const a = t > 0 ? e[t - 1] : "", n = t < e.length ? e[t] : "", p = !!a && !/\s/.test(a), s = !!n && !/\s/.test(n);
1907
+ return `${p ? " " : ""}${i}${s ? " " : ""}`;
1908
+ }
1909
+ function Wn(e, t, i) {
1910
+ const a = e.slice(0, t), n = e.slice(t), p = a.match(/\n*$/)?.[0].length ?? 0, s = n.match(/^\n*/)?.[0].length ?? 0, f = a.length === 0 || p >= 2 ? "" : `
1911
+ `.repeat(2 - p), u = n.length === 0 || s >= 2 ? "" : `
1912
+ `.repeat(2 - s);
1913
+ return `${f}${i}${u}`;
1914
+ }
1915
+ function pt(e) {
1916
+ const t = [];
1917
+ for (const i of e.matchAll(An)) {
1918
+ const a = i[0], n = i[1], p = i[2], s = i.index ?? 0, f = s + a.length, u = Kt(e, s, f, "inline");
1919
+ if (n === "var" && !Vn(p)) {
1920
+ const D = bt(p);
1921
+ t.push({
1922
+ uid: `inline:${s}:${f}`,
1923
+ fieldType: "var",
1924
+ sourceKind: "inline",
1925
+ id: D.id || "my_var",
1926
+ valueType: D.valueType || "str",
1927
+ raw: a,
1928
+ start: s,
1929
+ end: f,
1930
+ segmentStart: u.segmentStart,
1931
+ segmentEnd: u.segmentEnd
1932
+ });
1933
+ continue;
1934
+ }
1935
+ if (n === "var" || n === "var_table") {
1936
+ const D = Fn(p);
1937
+ t.push({
1938
+ uid: `inline:${s}:${f}`,
1939
+ fieldType: "var_table",
1940
+ sourceKind: "inline",
1941
+ id: D.id,
1942
+ subvarsText: D.subvarsText,
1943
+ raw: a,
1944
+ start: s,
1945
+ end: f,
1946
+ segmentStart: u.segmentStart,
1947
+ segmentEnd: u.segmentEnd
1948
+ });
1949
+ continue;
1950
+ }
1951
+ if (n === "step") {
1952
+ const D = Bn(p);
1953
+ t.push({
1954
+ uid: `inline:${s}:${f}`,
1955
+ fieldType: "step",
1956
+ sourceKind: "inline",
1957
+ id: D.id,
1958
+ raw: a,
1959
+ start: s,
1960
+ end: f,
1961
+ segmentStart: u.segmentStart,
1962
+ segmentEnd: u.segmentEnd
1963
+ });
1964
+ continue;
1965
+ }
1966
+ const A = In(p);
1967
+ t.push({
1968
+ uid: `inline:${s}:${f}`,
1969
+ fieldType: "check",
1970
+ sourceKind: "inline",
1971
+ id: A.id,
1972
+ raw: a,
1973
+ start: s,
1974
+ end: f,
1975
+ segmentStart: u.segmentStart,
1976
+ segmentEnd: u.segmentEnd
1977
+ });
1978
+ }
1979
+ for (const i of e.matchAll(xn)) {
1980
+ const a = i[0], n = i.index ?? 0, p = n + a.length, s = Kt(e, n, p, "block"), f = Pn(a);
1981
+ t.push({
1982
+ uid: `block:${n}:${p}`,
1983
+ fieldType: "quiz",
1984
+ sourceKind: "block",
1985
+ id: f.id,
1986
+ quizType: f.quizType,
1987
+ raw: a,
1988
+ start: n,
1989
+ end: p,
1990
+ segmentStart: s.segmentStart,
1991
+ segmentEnd: s.segmentEnd
1992
+ });
1993
+ }
1994
+ return t.sort((i, a) => i.start - a.start);
1995
+ }
1996
+ function Wt(e, t) {
1997
+ const i = new Set(e.map((p) => p.id)), a = t === "var" ? "new_var" : t === "var_table" ? "new_table" : t === "step" ? "new_step" : t === "check" ? "new_check" : "quiz_choice";
1998
+ if (!i.has(a))
1999
+ return a;
2000
+ let n = 2;
2001
+ for (; i.has(`${a}_${n}`); )
2002
+ n += 1;
2003
+ return `${a}_${n}`;
2004
+ }
2005
+ function ta(e, t, i) {
2006
+ const a = _t(t, i), n = e.replace(/\s+$/, "");
2007
+ return n ? `${n}
2008
+
2009
+ ${a}` : a;
2010
+ }
2011
+ function Un(e, t, i, a, n) {
2012
+ if (t.length === 0)
2013
+ return ta(e, a, n);
2014
+ const p = _t(a, n), s = Math.max(0, Math.min(i, t.length)), f = s >= t.length ? t[t.length - 1].segmentEnd : t[s].segmentStart, A = (a === "quiz" ? "block" : "inline") === "block" ? Wn(e, f, p) : Kn(e, f, p);
2015
+ return $e(e, f, f, A);
2016
+ }
2017
+ function jn(e, t) {
2018
+ return $e(e, t.segmentStart, t.segmentEnd, "");
2019
+ }
2020
+ function Qn(e, t, i) {
2021
+ const a = i.trim();
2022
+ if (!a || a === t.id)
2023
+ return e;
2024
+ const n = t.fieldType === "quiz" ? Hn(t.raw, a) : Ln(t.raw, t.fieldType, a);
2025
+ return $e(e, t.start, t.end, n);
2026
+ }
2027
+ function Gn(e, t, i) {
2028
+ if (i === t.fieldType)
2029
+ return e;
2030
+ const a = _t(i, {
2031
+ id: t.id,
2032
+ valueType: t.valueType,
2033
+ subvarsText: t.subvarsText,
2034
+ quizType: t.quizType
2035
+ });
2036
+ return $e(e, t.start, t.end, a);
2037
+ }
2038
+ function Yn(e, t, i) {
2039
+ if (t.fieldType !== "var")
2040
+ return e;
2041
+ const a = i.trim();
2042
+ if (a === (t.valueType || "").trim())
2043
+ return e;
2044
+ const n = Nn(t.raw, a);
2045
+ return $e(e, t.start, t.end, n);
2046
+ }
2047
+ function Zn(e, t, i) {
2048
+ const a = (t.sourceKind === "block" ? i.trimEnd() : i.trim()).replace(/\r\n?/g, `
2049
+ `);
2050
+ return !a || a === t.raw ? e : $e(e, t.start, t.end, a);
2051
+ }
2052
+ function Xn(e, t, i, a) {
2053
+ const n = t.find((P) => P.uid === i);
2054
+ if (!n)
2055
+ return e;
2056
+ const p = t.filter((P) => P.uid !== i), s = Math.max(0, Math.min(a, p.length)), f = e.slice(n.segmentStart, n.segmentEnd), u = $e(e, n.segmentStart, n.segmentEnd, ""), A = n.segmentEnd - n.segmentStart, D = p.map((P) => ({
2057
+ ...P,
2058
+ segmentStart: P.segmentStart > n.segmentStart ? P.segmentStart - A : P.segmentStart,
2059
+ segmentEnd: P.segmentEnd > n.segmentStart ? P.segmentEnd - A : P.segmentEnd
2060
+ })), V = s >= D.length ? D.length === 0 ? u.length : D[D.length - 1].segmentEnd : D[s].segmentStart;
2061
+ return $e(u, V, V, f);
2062
+ }
2063
+ function Jn(e = {}) {
2064
+ return new Da({
2065
+ view(t) {
2066
+ return new er(t, e);
2067
+ }
2068
+ });
2069
+ }
2070
+ class er {
2071
+ constructor(t, i) {
2072
+ var a;
2073
+ this.editorView = t, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (a = i.width) !== null && a !== void 0 ? a : 1, this.color = i.color === !1 ? void 0 : i.color || "black", this.class = i.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((n) => {
2074
+ let p = (s) => {
2075
+ this[n](s);
2076
+ };
2077
+ return t.dom.addEventListener(n, p), { name: n, handler: p };
2078
+ });
2079
+ }
2080
+ destroy() {
2081
+ this.handlers.forEach(({ name: t, handler: i }) => this.editorView.dom.removeEventListener(t, i));
2082
+ }
2083
+ update(t, i) {
2084
+ this.cursorPos != null && i.doc != t.state.doc && (this.cursorPos > t.state.doc.content.size ? this.setCursor(null) : this.updateOverlay());
2085
+ }
2086
+ setCursor(t) {
2087
+ t != this.cursorPos && (this.cursorPos = t, t == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
2088
+ }
2089
+ updateOverlay() {
2090
+ let t = this.editorView.state.doc.resolve(this.cursorPos), i = !t.parent.inlineContent, a, n = this.editorView.dom, p = n.getBoundingClientRect(), s = p.width / n.offsetWidth, f = p.height / n.offsetHeight;
2091
+ if (i) {
2092
+ let V = t.nodeBefore, P = t.nodeAfter;
2093
+ if (V || P) {
2094
+ let G = this.editorView.nodeDOM(this.cursorPos - (V ? V.nodeSize : 0));
2095
+ if (G) {
2096
+ let Y = G.getBoundingClientRect(), F = V ? Y.bottom : Y.top;
2097
+ V && P && (F = (F + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
2098
+ let N = this.width / 2 * f;
2099
+ a = { left: Y.left, right: Y.right, top: F - N, bottom: F + N };
2100
+ }
2101
+ }
2102
+ }
2103
+ if (!a) {
2104
+ let V = this.editorView.coordsAtPos(this.cursorPos), P = this.width / 2 * s;
2105
+ a = { left: V.left - P, right: V.left + P, top: V.top, bottom: V.bottom };
2106
+ }
2107
+ let u = this.editorView.dom.offsetParent;
2108
+ this.element || (this.element = u.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", i), this.element.classList.toggle("prosemirror-dropcursor-inline", !i);
2109
+ let A, D;
2110
+ if (!u || u == document.body && getComputedStyle(u).position == "static")
2111
+ A = -pageXOffset, D = -pageYOffset;
2112
+ else {
2113
+ let V = u.getBoundingClientRect(), P = V.width / u.offsetWidth, G = V.height / u.offsetHeight;
2114
+ A = V.left - u.scrollLeft * P, D = V.top - u.scrollTop * G;
2115
+ }
2116
+ this.element.style.left = (a.left - A) / s + "px", this.element.style.top = (a.top - D) / f + "px", this.element.style.width = (a.right - a.left) / s + "px", this.element.style.height = (a.bottom - a.top) / f + "px";
2117
+ }
2118
+ scheduleRemoval(t) {
2119
+ clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), t);
2120
+ }
2121
+ dragover(t) {
2122
+ if (!this.editorView.editable)
2123
+ return;
2124
+ let i = this.editorView.posAtCoords({ left: t.clientX, top: t.clientY }), a = i && i.inside >= 0 && this.editorView.state.doc.nodeAt(i.inside), n = a && a.type.spec.disableDropCursor, p = typeof n == "function" ? n(this.editorView, i, t) : n;
2125
+ if (i && !p) {
2126
+ let s = i.pos;
2127
+ if (this.editorView.dragging && this.editorView.dragging.slice) {
2128
+ let f = Ra(this.editorView.state.doc, s, this.editorView.dragging.slice);
2129
+ f != null && (s = f);
2130
+ }
2131
+ this.setCursor(s), this.scheduleRemoval(5e3);
2132
+ }
2133
+ }
2134
+ dragend() {
2135
+ this.scheduleRemoval(20);
2136
+ }
2137
+ drop() {
2138
+ this.scheduleRemoval(20);
2139
+ }
2140
+ dragleave(t) {
2141
+ this.editorView.dom.contains(t.relatedTarget) || this.setCursor(null);
2142
+ }
2143
+ }
2144
+ const tr = /* @__PURE__ */ _e({
2145
+ __name: "AimdRecorderWysiwygFieldHost",
2146
+ props: {
2147
+ surfaceState: {},
2148
+ rawContent: {},
2149
+ displayMode: {}
2150
+ },
2151
+ setup(e) {
2152
+ const t = e, i = w(() => t.displayMode === "inline" ? `<span class="aimd-recorder-wysiwyg-field-host__anchor" aria-hidden="true"></span>${t.rawContent}` : t.rawContent);
2153
+ return (a, n) => (C(), T("div", {
2154
+ class: pe(["aimd-recorder-wysiwyg-field-host", `aimd-recorder-wysiwyg-field-host--${e.displayMode}`])
2155
+ }, [
2156
+ Fe(yt, {
2157
+ content: i.value,
2158
+ "model-value": e.surfaceState.record,
2159
+ readonly: e.surfaceState.readonly,
2160
+ "current-user-name": e.surfaceState.currentUserName,
2161
+ now: e.surfaceState.now,
2162
+ locale: e.surfaceState.locale,
2163
+ messages: e.surfaceState.messages,
2164
+ "step-detail-display": e.surfaceState.stepDetailDisplay,
2165
+ "field-meta": e.surfaceState.fieldMeta,
2166
+ "field-state": e.surfaceState.fieldState,
2167
+ "wrap-field": e.surfaceState.wrapField,
2168
+ "custom-renderers": e.surfaceState.customRenderers,
2169
+ "field-adapters": e.surfaceState.fieldAdapters,
2170
+ "resolve-file": e.surfaceState.resolveFile,
2171
+ "type-plugins": e.surfaceState.typePlugins,
2172
+ "onUpdate:modelValue": e.surfaceState.onUpdateRecord,
2173
+ onFieldsChange: n[0] || (n[0] = (p) => e.surfaceState.onFieldsChange?.(p)),
2174
+ onError: n[1] || (n[1] = (p) => e.surfaceState.onError?.(p)),
2175
+ onFieldChange: n[2] || (n[2] = (p) => e.surfaceState.onFieldChange?.(p)),
2176
+ onFieldBlur: n[3] || (n[3] = (p) => e.surfaceState.onFieldBlur?.(p)),
2177
+ onAssignerRequest: n[4] || (n[4] = (p) => e.surfaceState.onAssignerRequest?.(p)),
2178
+ onAssignerCancel: n[5] || (n[5] = (p) => e.surfaceState.onAssignerCancel?.(p)),
2179
+ onTableAddRow: n[6] || (n[6] = (p) => e.surfaceState.onTableAddRow?.(p)),
2180
+ onTableRemoveRow: n[7] || (n[7] = (p) => e.surfaceState.onTableRemoveRow?.(p))
2181
+ }, null, 8, ["content", "model-value", "readonly", "current-user-name", "now", "locale", "messages", "step-detail-display", "field-meta", "field-state", "wrap-field", "custom-renderers", "field-adapters", "resolve-file", "type-plugins", "onUpdate:modelValue"])
2182
+ ], 2));
2183
+ }
2184
+ }), ar = /* @__PURE__ */ Ge(tr, [["__scopeId", "data-v-1cdbe158"]]), aa = "aimdRecorderQuizBlock", ir = /* @__PURE__ */ new Set(["var", "var_table", "step", "check"]), nr = {
2185
+ var: "#2563eb",
2186
+ var_table: "#059669",
2187
+ step: "#d97706",
2188
+ check: "#dc2626",
2189
+ ref_step: "#0891b2",
2190
+ ref_var: "#0891b2",
2191
+ ref_fig: "#0891b2",
2192
+ cite: "#6d28d9"
2193
+ }, Ut = {
2194
+ var: "var",
2195
+ var_table: "var_table",
2196
+ step: "step",
2197
+ check: "check",
2198
+ ref_step: "ref_step",
2199
+ ref_var: "ref_var",
2200
+ ref_fig: "ref_fig",
2201
+ cite: "cite"
2202
+ };
2203
+ function rr(e) {
2204
+ return (e || "").toLowerCase().startsWith("zh");
2205
+ }
2206
+ function lr(e) {
2207
+ const t = rr(e);
2208
+ return {
2209
+ edit: t ? "编辑" : "Edit",
2210
+ editTitle: t ? "编辑字段" : "Edit field",
2211
+ delete: t ? "删除" : "Delete",
2212
+ deleteTitle: t ? "删除字段" : "Delete field",
2213
+ dragTitle: t ? "拖动字段" : "Drag field"
2214
+ };
2215
+ }
2216
+ function sr(e, t) {
2217
+ return `{{${e}|${t}}}`;
2218
+ }
2219
+ function or(e) {
2220
+ return `\`\`\`quiz
2221
+ ${e.replace(/\r\n?/g, `
2222
+ `).replace(/\n+$/, "")}
2223
+ \`\`\``;
2224
+ }
2225
+ function dr(e, t) {
2226
+ const i = pt(e)[0];
2227
+ return i ? {
2228
+ fieldType: i.fieldType,
2229
+ id: i.id,
2230
+ raw: i.raw
2231
+ } : {
2232
+ fieldType: t,
2233
+ id: "",
2234
+ raw: e
2235
+ };
2236
+ }
2237
+ function ct(e) {
2238
+ return nr[e] || "#6b7280";
2239
+ }
2240
+ function cr() {
2241
+ function e(i) {
2242
+ t(i);
2243
+ }
2244
+ function t(i) {
2245
+ if (i.type === "code" && i.lang === "quiz") {
2246
+ i.type = aa, i.fieldContent = i.value || "", i.data = {
2247
+ hName: "aimd-recorder-quiz",
2248
+ hProperties: { fieldContent: i.fieldContent }
2249
+ };
2250
+ return;
2251
+ }
2252
+ if (i.children) {
2253
+ const a = [];
2254
+ for (const n of i.children) {
2255
+ if (t(n), n._aimdChildren) {
2256
+ a.push(...n._aimdChildren), delete n._aimdChildren;
2257
+ continue;
2258
+ }
2259
+ a.push(n);
2260
+ }
2261
+ i.children = a;
2262
+ }
2263
+ }
2264
+ return e;
2265
+ }
2266
+ const ur = qa("aimdRecorderQuizBlock", () => cr()), jt = Aa("aimd_recorder_quiz", () => ({
2267
+ group: "block",
2268
+ atom: !0,
2269
+ draggable: !0,
2270
+ attrs: {
2271
+ fieldContent: { default: "" }
2272
+ },
2273
+ parseDOM: [{
2274
+ tag: "aimd-recorder-quiz",
2275
+ getAttrs: (e) => ({
2276
+ fieldContent: e.getAttribute("data-field-content") || ""
2277
+ })
2278
+ }],
2279
+ toDOM: (e) => ["aimd-recorder-quiz", {
2280
+ "data-field-content": e.attrs.fieldContent,
2281
+ class: "aimd-recorder-wysiwyg-field aimd-recorder-wysiwyg-field--block"
2282
+ }],
2283
+ parseMarkdown: {
2284
+ match: (e) => e.type === aa,
2285
+ runner: (e, t, i) => {
2286
+ e.addNode(i, {
2287
+ fieldContent: t.fieldContent || ""
2288
+ });
2289
+ }
2290
+ },
2291
+ toMarkdown: {
2292
+ match: (e) => e.type.name === "aimd_recorder_quiz",
2293
+ runner: (e, t) => {
2294
+ e.addNode("code", void 0, String(t.attrs.fieldContent || ""), { lang: "quiz" });
2295
+ }
2296
+ }
2297
+ }));
2298
+ class Qt {
2299
+ constructor(t, i, a, n, p) {
2300
+ this.node = t, this.view = i, this.getPos = a, this.options = n, this.block = p, this.editButtonEl = null, this.deleteButtonEl = null, this.dragHandleEl = null;
2301
+ const s = p ? "div" : "span", f = lr(this.options.surfaceState.locale);
2302
+ this.dom = document.createElement(s), this.dom.className = [
2303
+ "aimd-recorder-wysiwyg-node",
2304
+ p ? "aimd-recorder-wysiwyg-node--block" : "aimd-recorder-wysiwyg-node--inline"
2305
+ ].join(" "), this.dom.contentEditable = "false", this.dom.draggable = !this.options.surfaceState.readonly;
2306
+ const u = document.createElement(p ? "div" : "span");
2307
+ u.className = [
2308
+ "aimd-recorder-wysiwyg-node__chrome",
2309
+ p ? "aimd-recorder-wysiwyg-node__chrome--block" : "aimd-recorder-wysiwyg-node__chrome--inline"
2310
+ ].join(" "), this.summaryEl = document.createElement("span"), this.summaryEl.className = "aimd-recorder-wysiwyg-node__summary", u.appendChild(this.summaryEl);
2311
+ const A = document.createElement("span");
2312
+ A.className = "aimd-recorder-wysiwyg-node__actions", this.editButtonEl = document.createElement("button"), this.editButtonEl.type = "button", this.editButtonEl.className = "aimd-recorder-wysiwyg-node__action aimd-recorder-wysiwyg-node__action--edit", this.editButtonEl.textContent = f.edit, this.editButtonEl.title = f.editTitle, this.editButtonEl.setAttribute("aria-label", f.editTitle), this.editButtonEl.addEventListener("click", (D) => {
2313
+ if (D.preventDefault(), D.stopPropagation(), this.options.surfaceState.readonly)
2314
+ return;
2315
+ const V = this.resolveIdentity();
2316
+ V && this.options.onEditField?.(V);
2317
+ }), A.appendChild(this.editButtonEl), this.deleteButtonEl = document.createElement("button"), this.deleteButtonEl.type = "button", this.deleteButtonEl.className = "aimd-recorder-wysiwyg-node__action aimd-recorder-wysiwyg-node__action--danger", this.deleteButtonEl.textContent = f.delete, this.deleteButtonEl.title = f.deleteTitle, this.deleteButtonEl.setAttribute("aria-label", f.deleteTitle), this.deleteButtonEl.addEventListener("click", (D) => {
2318
+ if (D.preventDefault(), D.stopPropagation(), this.options.surfaceState.readonly)
2319
+ return;
2320
+ const V = this.resolveIdentity();
2321
+ V && this.options.onDeleteField?.(V);
2322
+ }), A.appendChild(this.deleteButtonEl), this.dragHandleEl = document.createElement("span"), this.dragHandleEl.className = "aimd-recorder-wysiwyg-node__drag", this.dragHandleEl.textContent = "::", this.dragHandleEl.title = f.dragTitle, this.dragHandleEl.setAttribute("data-drag-handle", "true"), this.dragHandleEl.draggable = !this.options.surfaceState.readonly, this.dragHandleEl.addEventListener("mousedown", (D) => {
2323
+ this.selectThisNode();
2324
+ }), this.dragHandleEl.addEventListener("dragstart", () => {
2325
+ this.selectThisNode();
2326
+ }), A.appendChild(this.dragHandleEl), u.appendChild(A), this.dom.appendChild(u), this.bodyEl = document.createElement(s), this.bodyEl.className = "aimd-recorder-wysiwyg-node__body", this.dom.appendChild(this.bodyEl), this.renderField();
2327
+ }
2328
+ selectThisNode() {
2329
+ const t = this.getPos();
2330
+ if (typeof t != "number")
2331
+ return;
2332
+ const i = this.view.state.tr.setSelection(Ia.create(this.view.state.doc, t));
2333
+ this.view.dispatch(i);
2334
+ }
2335
+ resolveIdentity() {
2336
+ return dr(this.resolveRaw(), this.resolveFieldType());
2337
+ }
2338
+ resolveFieldType() {
2339
+ return this.block ? "quiz" : this.node.attrs.fieldType || "var";
2340
+ }
2341
+ resolveRaw() {
2342
+ return this.block ? or(String(this.node.attrs.fieldContent || "")) : sr(
2343
+ String(this.node.attrs.fieldType || "var"),
2344
+ String(this.node.attrs.fieldContent || "")
2345
+ );
2346
+ }
2347
+ renderField() {
2348
+ const t = this.resolveIdentity(), i = t?.id ? `${t.fieldType} ${t.id}` : this.resolveFieldType();
2349
+ this.summaryEl.textContent = i, this.summaryEl.title = i, this.dom.setAttribute("data-field-type", this.resolveFieldType()), this.dom.draggable = !this.options.surfaceState.readonly, this.dragHandleEl && (this.dragHandleEl.draggable = !this.options.surfaceState.readonly), this.editButtonEl && (this.editButtonEl.disabled = this.options.surfaceState.readonly), this.deleteButtonEl && (this.deleteButtonEl.disabled = this.options.surfaceState.readonly);
2350
+ const a = d(ar, {
2351
+ surfaceState: this.options.surfaceState,
2352
+ rawContent: this.resolveRaw(),
2353
+ displayMode: this.block ? "block" : "inline"
2354
+ });
2355
+ a.appContext = this.options.appContext ?? null, Vt(a, this.bodyEl);
2356
+ }
2357
+ update(t) {
2358
+ return t.type.name !== this.node.type.name ? !1 : (this.node = t, this.renderField(), !0);
2359
+ }
2360
+ selectNode() {
2361
+ this.dom.classList.add("aimd-recorder-wysiwyg-node--selected");
2362
+ }
2363
+ deselectNode() {
2364
+ this.dom.classList.remove("aimd-recorder-wysiwyg-node--selected");
2365
+ }
2366
+ stopEvent(t) {
2367
+ const i = t.target;
2368
+ return !(i instanceof Node) || this.dragHandleEl?.contains(i) ? !1 : !!this.dom.contains(i);
2369
+ }
2370
+ ignoreMutation() {
2371
+ return !0;
2372
+ }
2373
+ destroy() {
2374
+ Vt(null, this.bodyEl);
2375
+ }
2376
+ }
2377
+ class mr {
2378
+ constructor(t, i, a) {
2379
+ this.editing = !1, this.node = t, this.view = i, this.getPos = a;
2380
+ const n = String(t.attrs.fieldType || "var"), p = String(t.attrs.fieldContent || ""), s = ct(n);
2381
+ this.dom = document.createElement("span"), this.dom.className = "aimd-field-chip", this.dom.setAttribute("data-field-type", n), this.dom.contentEditable = "false", this.dom.style.cssText = `
2382
+ display: inline-flex;
2383
+ align-items: center;
2384
+ gap: 3px;
2385
+ padding: 1px 8px 1px 6px;
2386
+ border-radius: 4px;
2387
+ font-size: 13px;
2388
+ font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
2389
+ line-height: 1.6;
2390
+ cursor: pointer;
2391
+ user-select: none;
2392
+ vertical-align: baseline;
2393
+ border: 1px solid ${s}33;
2394
+ background: ${s}0d;
2395
+ color: ${s};
2396
+ transition: all 0.15s;
2397
+ `, this.labelEl = document.createElement("span"), this.labelEl.className = "aimd-field-chip-label", this.labelEl.textContent = Ut[n] || n, this.labelEl.style.cssText = `
2398
+ font-weight: 600;
2399
+ font-size: 11px;
2400
+ opacity: 0.7;
2401
+ margin-right: 2px;
2402
+ `, this.contentEl = document.createElement("span"), this.contentEl.className = "aimd-field-chip-content", this.contentEl.textContent = p, this.contentEl.style.cssText = "font-weight: 500;", this.dom.appendChild(this.labelEl), this.dom.appendChild(this.contentEl), this.dom.addEventListener("mouseenter", () => {
2403
+ this.dom.style.background = `${s}1a`, this.dom.style.borderColor = `${s}66`;
2404
+ }), this.dom.addEventListener("mouseleave", () => {
2405
+ this.editing || (this.dom.style.background = `${s}0d`, this.dom.style.borderColor = `${s}33`);
2406
+ }), this.dom.addEventListener("click", (f) => {
2407
+ f.preventDefault(), f.stopPropagation(), this.startEditing();
2408
+ });
2409
+ }
2410
+ startEditing() {
2411
+ if (this.editing)
2412
+ return;
2413
+ this.editing = !0;
2414
+ const t = String(this.node.attrs.fieldType || "var"), i = String(this.node.attrs.fieldContent || ""), a = ct(t);
2415
+ this.contentEl.contentEditable = "true", this.contentEl.style.outline = "none", this.contentEl.style.minWidth = "30px", this.contentEl.style.borderBottom = `1px dashed ${a}`, this.dom.style.background = `${a}1a`, this.dom.style.borderColor = `${a}66`, this.contentEl.focus();
2416
+ const n = document.createRange();
2417
+ n.selectNodeContents(this.contentEl);
2418
+ const p = window.getSelection();
2419
+ p?.removeAllRanges(), p?.addRange(n);
2420
+ const s = () => {
2421
+ this.editing = !1;
2422
+ const f = this.contentEl.textContent || "";
2423
+ if (this.contentEl.contentEditable = "false", this.contentEl.style.borderBottom = "none", this.dom.style.background = `${a}0d`, this.dom.style.borderColor = `${a}33`, f !== i) {
2424
+ const u = this.getPos();
2425
+ u !== void 0 && this.view.dispatch(this.view.state.tr.setNodeMarkup(u, void 0, {
2426
+ ...this.node.attrs,
2427
+ fieldContent: f
2428
+ }));
2429
+ }
2430
+ };
2431
+ this.contentEl.addEventListener("blur", s, { once: !0 }), this.contentEl.addEventListener("keydown", (f) => {
2432
+ f.key === "Enter" && (f.preventDefault(), this.contentEl.blur()), f.key === "Escape" && (f.preventDefault(), this.contentEl.textContent = i, this.contentEl.blur());
2433
+ });
2434
+ }
2435
+ update(t) {
2436
+ if (t.type.name !== "aimd_field")
2437
+ return !1;
2438
+ this.node = t;
2439
+ const i = String(t.attrs.fieldType || "var"), a = String(t.attrs.fieldContent || ""), n = ct(i);
2440
+ return this.labelEl.textContent = Ut[i] || i, this.editing || (this.contentEl.textContent = a), this.dom.setAttribute("data-field-type", i), this.dom.style.borderColor = `${n}33`, this.dom.style.background = `${n}0d`, this.dom.style.color = n, !0;
2441
+ }
2442
+ stopEvent(t) {
2443
+ return this.editing ? !0 : t.type === "click";
2444
+ }
2445
+ ignoreMutation() {
2446
+ return !0;
2447
+ }
2448
+ destroy() {
2449
+ }
2450
+ }
2451
+ const fr = xa.extendSchema((e) => (t) => ({
2452
+ ...e(t),
2453
+ toDOM: (a) => ["br", t.get(Va.key)(a)]
2454
+ })), vr = Ma(() => Jn({
2455
+ class: "aimd-recorder-dropcursor",
2456
+ color: !1,
2457
+ width: 4
2458
+ }));
2459
+ function hr(e) {
2460
+ const t = Bt(Ft, () => (a, n, p) => {
2461
+ const s = String(a.attrs.fieldType || "var");
2462
+ return ir.has(s) ? new Qt(a, n, p, e, !1) : new mr(a, n, p);
2463
+ }), i = Bt(jt, () => (a, n, p) => new Qt(a, n, p, e, !0));
2464
+ return [
2465
+ Fa,
2466
+ ur,
2467
+ Ft,
2468
+ jt,
2469
+ t,
2470
+ i,
2471
+ fr,
2472
+ vr,
2473
+ Ba
2474
+ ].flat();
2475
+ }
2476
+ const pr = /* @__PURE__ */ _e({
2477
+ __name: "AimdRecorderWysiwygSurface",
2478
+ props: {
2479
+ content: {},
2480
+ modelValue: { default: void 0 },
2481
+ minHeight: { default: 560 },
2482
+ locale: { default: void 0 },
2483
+ readonly: { type: Boolean, default: !1 },
2484
+ currentUserName: { default: void 0 },
2485
+ now: { default: void 0 },
2486
+ messages: { default: void 0 },
2487
+ stepDetailDisplay: { default: "auto" },
2488
+ fieldMeta: { default: void 0 },
2489
+ fieldState: { default: void 0 },
2490
+ wrapField: { type: Function, default: void 0 },
2491
+ customRenderers: { default: void 0 },
2492
+ fieldAdapters: { default: void 0 },
2493
+ resolveFile: { type: Function, default: void 0 },
2494
+ typePlugins: { default: void 0 },
2495
+ enableBlockHandle: { type: Boolean, default: !0 }
2496
+ },
2497
+ emits: ["update:content", "update:modelValue", "ready", "fields-change", "error", "field-change", "field-blur", "assigner-request", "assigner-cancel", "table-add-row", "table-remove-row", "edit-field", "delete-field"],
2498
+ setup(e, { expose: t, emit: i }) {
2499
+ const a = ["var", "var_table", "quiz", "step", "check"], n = new Set(a), p = [...a], s = e, f = i, u = w(() => Pa(s.locale)), A = w(() => Oa(u.value).filter((c) => n.has(c.type))), D = w(() => La(u.value)), V = w(() => (s.locale || "").toLowerCase().startsWith("zh") ? "拖到这里" : "Drop here"), P = w(() => ({
2500
+ "--aimd-recorder-drop-label": JSON.stringify(V.value)
2501
+ })), G = w(() => (s.typePlugins ?? []).map((c) => ({
2502
+ key: c.type,
2503
+ value: c.type,
2504
+ label: c.type,
2505
+ desc: ""
2506
+ }))), {
2507
+ content: Y,
2508
+ syncFromProp: F,
2509
+ insertTextIntoActiveEditor: N,
2510
+ handleMdAction: O,
2511
+ onMilkdownMarkdownUpdated: H,
2512
+ onMilkdownReady: m
2513
+ } = Na({
2514
+ initialContent: s.content,
2515
+ initialMode: "wysiwyg",
2516
+ resolvedMessages: u,
2517
+ emitModelValue: (c) => f("update:content", c),
2518
+ emitMode: () => {
2519
+ }
2520
+ });
2521
+ re(() => s.content, (c) => {
2522
+ F(c);
2523
+ }), re(Y, (c) => {
2524
+ try {
2525
+ f("fields-change", ft(c));
2526
+ } catch (x) {
2527
+ f("error", x instanceof Error ? x.message : String(x));
2528
+ }
2529
+ }, { immediate: !0 });
2530
+ const M = mt(gt());
2531
+ re(() => s.modelValue, (c) => {
2532
+ const x = Xe(c);
2533
+ Be(x) !== Be(M) && vt(M, x);
2534
+ }, { deep: !0, immediate: !0 });
2535
+ function b(c) {
2536
+ vt(M, c), f("update:modelValue", Jt(M));
2537
+ }
2538
+ const z = mt({
2539
+ record: M,
2540
+ readonly: s.readonly,
2541
+ currentUserName: s.currentUserName,
2542
+ now: s.now,
2543
+ locale: s.locale,
2544
+ messages: s.messages,
2545
+ stepDetailDisplay: s.stepDetailDisplay,
2546
+ fieldMeta: s.fieldMeta,
2547
+ fieldState: s.fieldState,
2548
+ wrapField: s.wrapField,
2549
+ customRenderers: s.customRenderers,
2550
+ fieldAdapters: s.fieldAdapters,
2551
+ resolveFile: s.resolveFile,
2552
+ typePlugins: s.typePlugins,
2553
+ onUpdateRecord: b,
2554
+ onError: (c) => f("error", c),
2555
+ onFieldChange: (c) => f("field-change", c),
2556
+ onFieldBlur: (c) => f("field-blur", c),
2557
+ onAssignerRequest: (c) => f("assigner-request", c),
2558
+ onAssignerCancel: (c) => f("assigner-cancel", c),
2559
+ onTableAddRow: (c) => f("table-add-row", c),
2560
+ onTableRemoveRow: (c) => f("table-remove-row", c)
2561
+ });
2562
+ Ca(() => {
2563
+ z.readonly = s.readonly, z.currentUserName = s.currentUserName, z.now = s.now, z.locale = s.locale, z.messages = s.messages, z.stepDetailDisplay = s.stepDetailDisplay, z.fieldMeta = s.fieldMeta, z.fieldState = s.fieldState, z.wrapField = s.wrapField, z.customRenderers = s.customRenderers, z.fieldAdapters = s.fieldAdapters, z.resolveFile = s.resolveFile, z.typePlugins = s.typePlugins;
2564
+ });
2565
+ const X = Ea(), U = [
2566
+ ...hr({
2567
+ appContext: X?.appContext ?? null,
2568
+ surfaceState: z,
2569
+ onEditField: (c) => f("edit-field", c),
2570
+ onDeleteField: (c) => f("delete-field", c)
2571
+ })
2572
+ ], E = w(() => {
2573
+ try {
2574
+ const c = ft(Y.value);
2575
+ return [...c.step || [], ...c.var || []];
2576
+ } catch {
2577
+ return [];
2578
+ }
2579
+ }), j = L(!1), q = L("var");
2580
+ function te(c) {
2581
+ q.value = n.has(c) ? c : "var", j.value = !0;
2582
+ }
2583
+ function B(c) {
2584
+ n.has(c) && N(Ua(c, u.value));
2585
+ }
2586
+ function J(c) {
2587
+ N(c);
2588
+ }
2589
+ function oe(c) {
2590
+ m(c), f("ready", { milkdown: c });
2591
+ }
2592
+ const ae = L(null);
2593
+ return t({
2594
+ getEditor: () => ae.value?.getEditor?.()
2595
+ }), (c, x) => (C(), T("div", {
2596
+ class: "aimd-recorder-wysiwyg-surface",
2597
+ style: je(P.value)
2598
+ }, [
2599
+ Fe(Ee(Ha), {
2600
+ "show-top-bar": !1,
2601
+ "show-md-toolbar": !0,
2602
+ "show-aimd-toolbar": !0,
2603
+ "editor-mode": "wysiwyg",
2604
+ "resolved-messages": u.value,
2605
+ "localized-field-types": A.value,
2606
+ "localized-md-toolbar-items": D.value,
2607
+ onMdAction: Ee(O),
2608
+ onOpenAimdDialog: te,
2609
+ onQuickInsertAimd: B
2610
+ }, null, 8, ["resolved-messages", "localized-field-types", "localized-md-toolbar-items", "onMdAction"]),
2611
+ Fe(Ee(Ka), {
2612
+ ref_key: "wysiwygEditorRef",
2613
+ ref: ae,
2614
+ content: Ee(Y),
2615
+ "min-height": e.minHeight,
2616
+ "enable-block-handle": e.enableBlockHandle,
2617
+ active: !0,
2618
+ readonly: e.readonly,
2619
+ "resolved-messages": u.value,
2620
+ "localized-field-types": A.value,
2621
+ "milkdown-plugins": U,
2622
+ onMarkdownUpdated: Ee(H),
2623
+ onReady: oe,
2624
+ onOpenAimdDialog: te
2625
+ }, null, 8, ["content", "min-height", "enable-block-handle", "readonly", "resolved-messages", "localized-field-types", "onMarkdownUpdated"]),
2626
+ Fe(Ee(Wa), {
2627
+ visible: j.value,
2628
+ "initial-type": q.value,
2629
+ messages: u.value,
2630
+ "ref-suggestions": E.value,
2631
+ "var-type-plugins": G.value,
2632
+ "allowed-types": p,
2633
+ "onUpdate:visible": x[0] || (x[0] = (y) => j.value = y),
2634
+ onInsert: J
2635
+ }, null, 8, ["visible", "initial-type", "messages", "ref-suggestions", "var-type-plugins"])
2636
+ ], 4));
2637
+ }
2638
+ }), gr = /* @__PURE__ */ Ge(pr, [["__scopeId", "data-v-95d821f3"]]), yr = { class: "aimd-recorder-workbench__main" }, br = { class: "aimd-recorder-workbench__panel" }, _r = { class: "aimd-recorder-workbench__panel-title" }, kr = { class: "aimd-recorder-workbench__panel-head-row" }, wr = { class: "aimd-recorder-workbench__panel-head-copy" }, Cr = { class: "aimd-recorder-workbench__panel-title" }, Er = {
2639
+ key: 0,
2640
+ class: "aimd-recorder-workbench__panel-title-count"
2641
+ }, Tr = {
2642
+ key: 0,
2643
+ class: "aimd-recorder-workbench__panel-head-note"
2644
+ }, Sr = {
2645
+ key: 0,
2646
+ class: "aimd-recorder-workbench__visual-toggle-wrap"
2647
+ }, zr = ["aria-label"], $r = ["onClick"], Dr = {
2648
+ key: 0,
2649
+ class: "aimd-recorder-workbench__side-tab-badge"
2650
+ }, Rr = { class: "aimd-recorder-workbench__recorder-toolbar-note" }, qr = { class: "aimd-recorder-workbench__structure" }, Ar = { class: "aimd-recorder-workbench__structure-description" }, xr = { class: "aimd-recorder-workbench__structure-toolbar" }, Vr = ["disabled"], Mr = ["disabled"], Fr = ["disabled"], Br = ["disabled"], Ir = ["disabled"], Pr = {
2651
+ key: 0,
2652
+ class: "aimd-recorder-workbench__field-list"
2653
+ }, Or = {
2654
+ key: 0,
2655
+ class: "aimd-recorder-workbench__drop-zone-label"
2656
+ }, Lr = ["draggable", "onDragstart"], Nr = { class: "aimd-recorder-workbench__field-item-top" }, Hr = ["title"], Kr = { class: "aimd-recorder-workbench__field-badge" }, Wr = ["disabled", "onClick"], Ur = { class: "aimd-recorder-workbench__field-grid" }, jr = { class: "aimd-recorder-workbench__field-label" }, Qr = ["value", "disabled", "onChange"], Gr = { value: "var" }, Yr = { value: "var_table" }, Zr = { value: "step" }, Xr = { value: "check" }, Jr = { value: "quiz" }, el = { class: "aimd-recorder-workbench__field-label" }, tl = ["value", "disabled", "onChange"], al = {
2657
+ key: 0,
2658
+ class: "aimd-recorder-workbench__field-label"
2659
+ }, il = ["value", "disabled", "onChange"], nl = ["onDrop"], rl = {
2660
+ key: 0,
2661
+ class: "aimd-recorder-workbench__drop-zone-label"
2662
+ }, ll = {
2663
+ key: 1,
2664
+ class: "aimd-recorder-workbench__structure-empty"
2665
+ }, sl = { class: "aimd-recorder-workbench__code" }, ol = { class: "aimd-recorder-workbench__detached-description" }, dl = { class: "aimd-recorder-workbench__code aimd-recorder-workbench__code--detached" }, cl = ["aria-label"], ul = { class: "aimd-recorder-workbench__dialog-head" }, ml = { class: "aimd-recorder-workbench__dialog-title" }, fl = { class: "aimd-recorder-workbench__dialog-summary" }, vl = { class: "aimd-recorder-workbench__dialog-body" }, hl = { class: "aimd-recorder-workbench__dialog-label" }, pl = ["value", "disabled"], gl = { value: "var" }, yl = { value: "var_table" }, bl = { value: "step" }, _l = { value: "check" }, kl = { value: "quiz" }, wl = { class: "aimd-recorder-workbench__dialog-label" }, Cl = ["value", "disabled"], El = {
2666
+ key: 0,
2667
+ class: "aimd-recorder-workbench__dialog-label"
2668
+ }, Tl = ["value", "disabled"], Sl = {
2669
+ key: 1,
2670
+ class: "aimd-recorder-workbench__dialog-label aimd-recorder-workbench__dialog-label--wide"
2671
+ }, zl = ["disabled"], $l = { class: "aimd-recorder-workbench__dialog-foot" }, Dl = {
2672
+ key: 0,
2673
+ class: "aimd-recorder-workbench__dialog-hint"
2674
+ }, Rl = { class: "aimd-recorder-workbench__dialog-actions" }, ql = ["disabled"], Al = ["disabled"], xl = 120, Vl = 1600, Ml = 2e3, Fl = /* @__PURE__ */ _e({
2675
+ __name: "AimdRecorderEditor",
2676
+ props: {
2677
+ content: { default: "" },
2678
+ modelValue: { default: void 0 },
2679
+ locale: { default: void 0 },
2680
+ readonly: { type: Boolean, default: !1 },
2681
+ currentUserName: { default: void 0 },
2682
+ now: { default: void 0 },
2683
+ messages: { default: void 0 },
2684
+ stepDetailDisplay: { default: "auto" },
2685
+ fieldMeta: { default: void 0 },
2686
+ fieldState: { default: void 0 },
2687
+ wrapField: { type: Function, default: void 0 },
2688
+ customRenderers: { default: void 0 },
2689
+ fieldAdapters: { default: void 0 },
2690
+ resolveFile: { type: Function, default: void 0 },
2691
+ typePlugins: { default: void 0 },
2692
+ editorMode: { default: "source" },
2693
+ editorProps: { default: void 0 },
2694
+ editorTitle: { default: void 0 },
2695
+ recorderTitle: { default: void 0 },
2696
+ recordDataTitle: { default: void 0 },
2697
+ detachedDataTitle: { default: void 0 },
2698
+ detachedDataDescription: { default: void 0 },
2699
+ fieldStructureTitle: { default: void 0 },
2700
+ fieldStructureDescription: { default: void 0 },
2701
+ showFieldStructure: { type: Boolean, default: !1 },
2702
+ showVisualEditToggle: { type: Boolean, default: !0 },
2703
+ initialVisualEditMode: { type: Boolean, default: !1 },
2704
+ allowRawFieldSourceEditing: { type: Boolean, default: !0 },
2705
+ showRecordData: { type: Boolean, default: !1 },
2706
+ showDetachedData: { type: Boolean, default: !0 },
2707
+ fitViewport: { type: Boolean, default: !0 },
2708
+ viewportOffset: { default: 24 },
2709
+ editorMinHeight: { default: 560 },
2710
+ recorderMinHeight: { default: 560 }
2711
+ },
2712
+ emits: ["update:content", "update:modelValue", "update:editorMode", "editor-ready", "fields-change", "error", "field-change", "field-blur", "assigner-request", "assigner-cancel", "table-add-row", "table-remove-row"],
2713
+ setup(e, { expose: t, emit: i }) {
2714
+ const a = e, n = i, p = {
2715
+ var: [],
2716
+ var_table: [],
2717
+ client_assigner: [],
2718
+ quiz: [],
2719
+ step: [],
2720
+ check: [],
2721
+ ref_step: [],
2722
+ ref_var: [],
2723
+ ref_fig: [],
2724
+ cite: [],
2725
+ fig: []
2726
+ }, s = L(null), f = L(null), u = L(null), A = L(null), D = L(null), V = L(null), P = L(null), G = L(null), Y = L(p), F = L(a.content || ""), N = L(a.content || ""), O = L(Xe(a.modelValue)), H = L(null), m = L(a.initialVisualEditMode), M = L(null), b = L("recorder"), z = L(a.editorMinHeight), X = L(a.recorderMinHeight), U = L(Math.max(320, a.recorderMinHeight)), E = L(null), j = L(""), q = L(null);
2727
+ let te = 0, B = null, J = [], oe = /* @__PURE__ */ new Map(), ae = /* @__PURE__ */ new Map();
2728
+ const c = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Set();
2729
+ function y(r) {
2730
+ return r ?? "";
2731
+ }
2732
+ function R(r) {
2733
+ J[J.length - 1] !== r && (J.push(r), J.length > 16 && (J = J.slice(-16)));
2734
+ }
2735
+ function Z() {
2736
+ B !== null && (clearTimeout(B), B = null);
2737
+ }
2738
+ function ce(r, l, o, K) {
2739
+ r.add(o);
2740
+ const ee = l.get(o);
2741
+ ee && clearTimeout(ee), l.set(o, setTimeout(() => {
2742
+ r.delete(o), l.delete(o);
2743
+ }, K));
2744
+ }
2745
+ function le(r, l) {
2746
+ for (const o of l.values())
2747
+ clearTimeout(o);
2748
+ r.clear(), l.clear();
2749
+ }
2750
+ function qe(r) {
2751
+ ce(
2752
+ c,
2753
+ oe,
2754
+ r,
2755
+ Vl
2756
+ );
2757
+ }
2758
+ function ge(r) {
2759
+ ce(
2760
+ x,
2761
+ ae,
2762
+ r,
2763
+ Ml
2764
+ );
2765
+ }
2766
+ function ke(r) {
2767
+ Z(), ge(r), N.value = r;
2768
+ }
2769
+ function Ie(r) {
2770
+ Z(), B = setTimeout(() => {
2771
+ B = null, ge(r), N.value = r;
2772
+ }, xl);
2773
+ }
2774
+ function Pe(r) {
2775
+ const l = y(r), o = J.indexOf(l);
2776
+ if (o !== -1) {
2777
+ J = J.slice(o + 1);
2778
+ return;
2779
+ }
2780
+ if (l === F.value) {
2781
+ ke(l);
2782
+ return;
2783
+ }
2784
+ J = [], F.value = l, ke(l);
2785
+ }
2786
+ function Te(r) {
2787
+ return r === F.value ? !1 : (F.value = r, R(r), !0);
2788
+ }
2789
+ re(() => a.initialVisualEditMode, (r) => {
2790
+ m.value = r;
2791
+ }), re(() => a.content, (r) => {
2792
+ Pe(r);
2793
+ }, { immediate: !0 }), re(m, (r) => {
2794
+ r && ke(F.value);
2795
+ }), re(() => a.modelValue, (r) => {
2796
+ const l = Xe(r);
2797
+ Be(l) !== Be(O.value) && (O.value = l);
2798
+ }, { deep: !0, immediate: !0 });
2799
+ const ue = w(() => `${a.editorProps?.locale ?? a.locale ?? ""}`.trim().toLowerCase().startsWith("zh")), Se = w(() => a.editorTitle ?? (ue.value ? "Protocol 源码" : "Protocol Source")), Ae = w(() => a.recorderTitle ?? (ue.value ? "Recorder 录入" : "Recorder")), ve = w(() => a.recordDataTitle ?? (ue.value ? "Record 数据" : "Record Data")), at = w(() => a.detachedDataTitle ?? (ue.value ? "脱离当前 Protocol 的旧数据" : "Detached Data")), g = w(() => a.detachedDataDescription ?? (ue.value ? "这些值对应的字段 id 已不在当前 protocol 结构里。改结构、重命名或删字段之后,可以从这里把旧值搬到新 field。" : "These values belong to field ids that are no longer present in the current protocol. After restructuring, renaming, or removing fields, copy them into newly created fields here.")), _ = w(() => a.fieldStructureTitle ?? (ue.value ? "Field 结构编辑" : "Field Structure")), S = w(() => a.fieldStructureDescription ?? (ue.value ? "这里可以直接改 recorder field 的 kind、id 和顺序,也可以新增或删除 field。按住每个字段顶部的“拖动排序”即可重排。拖拽当前是按源码片段重排;如果 field 嵌在句子里,周围 prose 仍可在左侧源码里继续微调。" : "Edit recorder field kind, id, and order here, and add or remove fields without leaving the editor. Grab the “Drag to reorder” handle at the top of each field to move it. Dragging currently reorders source fragments; if a field is embedded inside prose, you can fine-tune the surrounding text in the source editor.")), I = w(() => ue.value ? "右侧切到 recorder-aware 所见即所得编辑器,字段会直接显示为可交互 recorder widget" : "Switch the right side into a recorder-aware WYSIWYG editor with real recorder widgets and full caret-based Markdown editing"), v = w(() => ue.value ? {
2800
+ visualEditOn: "可视化编辑开",
2801
+ visualEditOff: "可视化编辑关",
2802
+ kind: "字段类型",
2803
+ id: "字段 ID",
2804
+ valueType: "值类型",
2805
+ empty: "当前 protocol 里还没有可录入 field。可以先从下面新增一个。",
2806
+ delete: "删除",
2807
+ edit: "编辑字段",
2808
+ close: "关闭",
2809
+ drag: "拖动排序",
2810
+ dropHere: "拖到这里",
2811
+ source: "Field AIMD 片段",
2812
+ sourceHint: "高级:如果这个 field 还有更复杂的内容,可以直接改它的 AIMD 片段。",
2813
+ applySource: "应用片段",
2814
+ visualDialogTitle: "编辑字段",
2815
+ visualDialogSummary: "直接在 recorder 主界面里修改字段结构。",
2816
+ addVar: "新增 Var",
2817
+ addTable: "新增 Table",
2818
+ addStep: "新增 Step",
2819
+ addCheck: "新增 Check",
2820
+ addQuiz: "新增 Quiz",
2821
+ addEndHint: "可视化编辑开启后,右侧会切到 recorder-aware 所见即所得编辑器,可以在任意光标位置补充标题、Markdown,并直接编辑真实的 recorder field widget。",
2822
+ typeLabels: {
2823
+ var: "Var",
2824
+ var_table: "Var Table",
2825
+ step: "Step",
2826
+ check: "Check",
2827
+ quiz: "Quiz"
2828
+ }
2829
+ } : {
2830
+ visualEditOn: "Visual Edit On",
2831
+ visualEditOff: "Visual Edit Off",
2832
+ kind: "Field Kind",
2833
+ id: "Field ID",
2834
+ valueType: "Value Type",
2835
+ empty: "There are no recorder-editable fields in the current protocol yet. Add one below to start filling data immediately.",
2836
+ delete: "Delete",
2837
+ edit: "Edit Field",
2838
+ close: "Close",
2839
+ drag: "Drag to reorder",
2840
+ dropHere: "Drop here",
2841
+ source: "Field AIMD",
2842
+ sourceHint: "Advanced: edit the raw AIMD snippet when this field needs more than the basic controls.",
2843
+ applySource: "Apply Snippet",
2844
+ visualDialogTitle: "Edit Field",
2845
+ visualDialogSummary: "Adjust the field structure directly inside the recorder.",
2846
+ addVar: "Add Var",
2847
+ addTable: "Add Table",
2848
+ addStep: "Add Step",
2849
+ addCheck: "Add Check",
2850
+ addQuiz: "Add Quiz",
2851
+ addEndHint: "When visual editing is on, the right side becomes a recorder-aware WYSIWYG editor so users can add headings, Markdown, and real recorder field widgets anywhere the caret can land.",
2852
+ typeLabels: {
2853
+ var: "Var",
2854
+ var_table: "Var Table",
2855
+ step: "Step",
2856
+ check: "Check",
2857
+ quiz: "Quiz"
2858
+ }
2859
+ });
2860
+ function me() {
2861
+ return typeof window > "u" ? 0 : window.visualViewport?.height ?? window.innerHeight;
2862
+ }
2863
+ function ie(r) {
2864
+ return r?.getBoundingClientRect().height ?? 0;
2865
+ }
2866
+ function we() {
2867
+ if (!a.fitViewport || typeof window > "u") {
2868
+ z.value = a.editorMinHeight, X.value = a.recorderMinHeight;
2869
+ return;
2870
+ }
2871
+ const r = Math.max(u.value?.getBoundingClientRect().top ?? 0, 0), l = Math.max(0, Math.floor(me() - r - a.viewportOffset)), o = ie(V.value?.querySelector(".aimd-editor-toolbar")), K = ie(A.value), ee = ie(D.value), be = Math.max(
2872
+ a.recorderMinHeight,
2873
+ Math.floor(l - ee)
2874
+ ), Ke = ie(G.value), ne = ie(P.value?.querySelector(".aimd-editor-toolbar"));
2875
+ z.value = Math.max(
2876
+ a.editorMinHeight,
2877
+ Math.floor(l - K - o)
2878
+ ), X.value = be, U.value = Math.max(
2879
+ 320,
2880
+ Math.floor(be - Ke - ne)
2881
+ );
2882
+ }
2883
+ function $() {
2884
+ typeof window > "u" || (te && window.cancelAnimationFrame(te), te = window.requestAnimationFrame(() => {
2885
+ te = 0, we();
2886
+ }));
2887
+ }
2888
+ const Q = w(() => {
2889
+ const r = a.editorProps ?? {};
2890
+ return {
2891
+ ...r,
2892
+ modelValue: F.value,
2893
+ mode: a.editorMode,
2894
+ locale: r.locale ?? a.locale,
2895
+ minHeight: r.minHeight ?? z.value,
2896
+ readonly: a.readonly || r.readonly === !0
2897
+ };
2898
+ }), se = w(() => pt(F.value)), Ce = w(() => {
2899
+ const r = /* @__PURE__ */ new Map();
2900
+ for (const l of se.value)
2901
+ r.set(`${l.fieldType}:${l.id}`, l);
2902
+ return r;
2903
+ }), ye = w(() => {
2904
+ const r = /* @__PURE__ */ new Map();
2905
+ return se.value.forEach((l, o) => {
2906
+ r.set(l.uid, o);
2907
+ }), r;
2908
+ });
2909
+ function Oe(r, l, o) {
2910
+ if (o) {
2911
+ const K = r.find((ee) => ee.fieldType === o.fieldType && ee.id === o.id);
2912
+ if (K)
2913
+ return K;
2914
+ }
2915
+ return r.find((K) => K.start === l.start) ?? r.find((K) => K.uid === l.uid) ?? r.find((K) => K.fieldType === l.fieldType && K.id === l.id) ?? null;
2916
+ }
2917
+ function it(r, l) {
2918
+ const o = gt(), K = new Set(l.var), ee = new Set(Ti(l.step).map((ne) => ne.name)), be = new Set(Si(l.check).map((ne) => ne.name)), Ke = new Set(zi(l.quiz).map((ne) => ne.id));
2919
+ for (const ne of $i(l.var_table))
2920
+ K.add(ne.id);
2921
+ for (const [ne, Re] of Object.entries(r.var))
2922
+ K.has(ne) || (o.var[ne] = Re);
2923
+ for (const [ne, Re] of Object.entries(r.step))
2924
+ ee.has(ne) || (o.step[ne] = Re);
2925
+ for (const [ne, Re] of Object.entries(r.check))
2926
+ be.has(ne) || (o.check[ne] = Re);
2927
+ for (const [ne, Re] of Object.entries(r.quiz))
2928
+ Ke.has(ne) || (o.quiz[ne] = Re);
2929
+ return o;
2930
+ }
2931
+ function de(r) {
2932
+ return Object.keys(r.var).length + Object.keys(r.step).length + Object.keys(r.check).length + Object.keys(r.quiz).length;
2933
+ }
2934
+ const kt = w(() => it(O.value, Y.value)), nt = w(() => de(kt.value)), wt = w(() => nt.value > 0), ia = w(() => JSON.stringify(O.value, null, 2)), na = w(() => JSON.stringify(kt.value, null, 2)), Ye = w(() => ({
2935
+ height: `${X.value}px`
2936
+ })), Le = w(() => {
2937
+ const r = [
2938
+ { key: "recorder", label: Ae.value }
2939
+ ];
2940
+ return a.showFieldStructure && r.push({ key: "structure", label: _.value }), a.showRecordData && r.push({ key: "record", label: ve.value }), a.showDetachedData && wt.value && r.push({
2941
+ key: "detached",
2942
+ label: at.value,
2943
+ badge: nt.value
2944
+ }), r;
2945
+ }), ra = w(() => Le.value.length > 1), la = w(() => Le.value.find((r) => r.key === b.value) ?? Le.value[0]), sa = w(() => la.value?.label ?? Ae.value);
2946
+ re(Le, (r) => {
2947
+ r.some((l) => l.key === b.value) || (b.value = "recorder");
2948
+ }, { immediate: !0 }), re([m, b], ([r, l]) => {
2949
+ (!r || l !== "recorder") && (xe(), q.value = null);
2950
+ }), re(se, (r) => {
2951
+ if (!E.value)
2952
+ return;
2953
+ const l = Oe(r, E.value);
2954
+ if (!l) {
2955
+ xe();
2956
+ return;
2957
+ }
2958
+ E.value = l, j.value = l.raw;
2959
+ }), re(
2960
+ [
2961
+ b,
2962
+ m,
2963
+ wt,
2964
+ () => a.fitViewport,
2965
+ () => a.viewportOffset,
2966
+ () => a.editorMinHeight,
2967
+ () => a.recorderMinHeight,
2968
+ () => a.editorMode
2969
+ ],
2970
+ async () => {
2971
+ await Me(), $();
2972
+ },
2973
+ { immediate: !0 }
2974
+ ), Gt(async () => {
2975
+ await Me(), $(), typeof window < "u" && (window.addEventListener("resize", $, { passive: !0 }), window.addEventListener("scroll", $, { passive: !0 }), window.visualViewport?.addEventListener("resize", $), window.visualViewport?.addEventListener("scroll", $));
2976
+ }), tt(() => {
2977
+ typeof window < "u" && (window.removeEventListener("resize", $), window.removeEventListener("scroll", $), window.visualViewport?.removeEventListener("resize", $), window.visualViewport?.removeEventListener("scroll", $), te && (window.cancelAnimationFrame(te), te = 0)), Z(), le(c, oe), le(x, ae);
2978
+ });
2979
+ function rt(r, l = "immediate") {
2980
+ Te(r) && (l === "debounced" ? Ie(r) : ke(r), n("update:content", r));
2981
+ }
2982
+ function De(r, l, o) {
2983
+ if (Te(r)) {
2984
+ if (ke(r), l || o) {
2985
+ const K = pt(r), ee = l ? Oe(K, l, o) : K.find((be) => be.fieldType === o?.fieldType && be.id === o?.id) ?? null;
2986
+ ee ? (E.value = ee, j.value = ee.raw) : l && E.value?.uid === l.uid && xe();
2987
+ }
2988
+ n("update:content", r);
2989
+ }
2990
+ }
2991
+ function oa(r) {
2992
+ M.value = "source", qe(r), rt(r, "debounced");
2993
+ }
2994
+ function da(r) {
2995
+ x.has(r) || M.value === "source" && c.has(r) || (M.value = "visual", rt(r, "immediate"));
2996
+ }
2997
+ function ca() {
2998
+ M.value = "source";
2999
+ }
3000
+ function ua() {
3001
+ M.value = "visual";
3002
+ }
3003
+ function Ct(r, l) {
3004
+ const o = l.currentTarget, K = l.relatedTarget;
3005
+ o instanceof Node && K instanceof Node && o.contains(K) || M.value === r && (M.value = null);
3006
+ }
3007
+ function Et(r) {
3008
+ O.value = Xe(r), n("update:modelValue", r);
3009
+ }
3010
+ function Tt(r) {
3011
+ Y.value = r, n("fields-change", r);
3012
+ }
3013
+ function Ne(r) {
3014
+ const l = Wt(se.value, r);
3015
+ De(ta(F.value, r, {
3016
+ id: l,
3017
+ valueType: r === "var" ? "str" : void 0
3018
+ }), void 0, {
3019
+ fieldType: r,
3020
+ id: l
3021
+ });
3022
+ }
3023
+ function lt(r) {
3024
+ E.value?.uid === r.uid && xe(), rt(jn(F.value, r));
3025
+ }
3026
+ function ma(r, l) {
3027
+ const o = l.trim();
3028
+ o && De(Qn(F.value, r, o), r, {
3029
+ fieldType: r.fieldType,
3030
+ id: o
3031
+ });
3032
+ }
3033
+ function St(r, l) {
3034
+ ma(r, l.target.value);
3035
+ }
3036
+ function fa(r, l) {
3037
+ De(Gn(F.value, r, l), r, {
3038
+ fieldType: l,
3039
+ id: r.id
3040
+ });
3041
+ }
3042
+ function zt(r, l) {
3043
+ fa(r, l.target.value);
3044
+ }
3045
+ function va(r, l) {
3046
+ De(Yn(F.value, r, l), r);
3047
+ }
3048
+ function $t(r, l) {
3049
+ va(r, l.target.value);
3050
+ }
3051
+ function Dt(r) {
3052
+ E.value = r, j.value = r.raw, q.value = null;
3053
+ }
3054
+ function xe() {
3055
+ E.value = null, j.value = "";
3056
+ }
3057
+ function ha(r) {
3058
+ a.readonly || (q.value = q.value === r ? null : r);
3059
+ }
3060
+ function He(r, l) {
3061
+ const o = Wt(se.value, r);
3062
+ q.value = null, De(Un(
3063
+ F.value,
3064
+ se.value,
3065
+ l,
3066
+ r,
3067
+ {
3068
+ id: o,
3069
+ valueType: r === "var" ? "str" : void 0
3070
+ }
3071
+ ), void 0, {
3072
+ fieldType: r,
3073
+ id: o
3074
+ });
3075
+ }
3076
+ function pa() {
3077
+ !a.allowRawFieldSourceEditing || !E.value || De(Zn(
3078
+ F.value,
3079
+ E.value,
3080
+ j.value
3081
+ ), E.value);
3082
+ }
3083
+ function Rt(r) {
3084
+ return se.value.find((l) => l.fieldType === r.fieldType && l.id === r.id) ?? se.value.find((l) => l.raw === r.raw) ?? null;
3085
+ }
3086
+ function ga(r) {
3087
+ const l = Rt(r);
3088
+ l && Dt(l);
3089
+ }
3090
+ function ya(r) {
3091
+ const l = Rt(r);
3092
+ l && lt(l);
3093
+ }
3094
+ function qt(r, l) {
3095
+ if (a.readonly) {
3096
+ l.preventDefault();
3097
+ return;
3098
+ }
3099
+ H.value = r.uid, q.value = null, l.dataTransfer?.setData("text/plain", r.uid), l.dataTransfer && (l.dataTransfer.effectAllowed = "move");
3100
+ }
3101
+ function At() {
3102
+ H.value = null;
3103
+ }
3104
+ function st(r) {
3105
+ a.readonly || (r.preventDefault(), r.dataTransfer && (r.dataTransfer.dropEffect = "move"));
3106
+ }
3107
+ function ot(r) {
3108
+ if (a.readonly || !H.value)
3109
+ return;
3110
+ const l = se.value.find((K) => K.uid === H.value), o = Xn(
3111
+ F.value,
3112
+ se.value,
3113
+ H.value,
3114
+ r
3115
+ );
3116
+ H.value = null, De(o, l);
3117
+ }
3118
+ function ba(r) {
3119
+ if (H.value)
3120
+ return [
3121
+ d("span", { class: "aimd-recorder-workbench__drop-zone-label" }, v.value.dropHere)
3122
+ ];
3123
+ if (a.readonly)
3124
+ return;
3125
+ const l = q.value === r;
3126
+ return [
3127
+ d("span", { class: "aimd-recorder-workbench__visual-insert-wrap" }, [
3128
+ d("button", {
3129
+ type: "button",
3130
+ class: [
3131
+ "aimd-recorder-workbench__visual-insert-trigger",
3132
+ l ? "aimd-recorder-workbench__visual-insert-trigger--active" : ""
3133
+ ],
3134
+ onClick: (o) => {
3135
+ o.preventDefault(), o.stopPropagation(), ha(r);
3136
+ }
3137
+ }, "+"),
3138
+ l ? d("span", { class: "aimd-recorder-workbench__visual-insert-menu" }, [
3139
+ d("button", {
3140
+ type: "button",
3141
+ class: "aimd-recorder-workbench__visual-insert-option",
3142
+ onClick: () => He("var", r)
3143
+ }, v.value.addVar),
3144
+ d("button", {
3145
+ type: "button",
3146
+ class: "aimd-recorder-workbench__visual-insert-option",
3147
+ onClick: () => He("var_table", r)
3148
+ }, v.value.addTable),
3149
+ d("button", {
3150
+ type: "button",
3151
+ class: "aimd-recorder-workbench__visual-insert-option",
3152
+ onClick: () => He("step", r)
3153
+ }, v.value.addStep),
3154
+ d("button", {
3155
+ type: "button",
3156
+ class: "aimd-recorder-workbench__visual-insert-option",
3157
+ onClick: () => He("check", r)
3158
+ }, v.value.addCheck),
3159
+ d("button", {
3160
+ type: "button",
3161
+ class: "aimd-recorder-workbench__visual-insert-option",
3162
+ onClick: () => He("quiz", r)
3163
+ }, v.value.addQuiz)
3164
+ ]) : null
3165
+ ])
3166
+ ];
3167
+ }
3168
+ function xt(r) {
3169
+ return d("span", {
3170
+ class: [
3171
+ "aimd-recorder-workbench__visual-drop-zone",
3172
+ H.value ? "aimd-recorder-workbench__visual-drop-zone--active" : ""
3173
+ ],
3174
+ onDragover: st,
3175
+ onDrop: (l) => {
3176
+ l.preventDefault(), ot(r);
3177
+ }
3178
+ }, ba(r));
3179
+ }
3180
+ function _a(r, l, o) {
3181
+ if (!m.value)
3182
+ return a.wrapField ? a.wrapField(r, l, o) : o;
3183
+ const K = Ce.value.get(r);
3184
+ if (!K)
3185
+ return a.wrapField ? a.wrapField(r, l, o) : o;
3186
+ const ee = ye.value.get(K.uid) ?? 0, be = d("span", {
3187
+ class: [
3188
+ "aimd-recorder-workbench__visual-field",
3189
+ K.sourceKind === "block" ? "aimd-recorder-workbench__visual-field--block" : "aimd-recorder-workbench__visual-field--inline",
3190
+ H.value === K.uid ? "aimd-recorder-workbench__visual-field--dragging" : ""
3191
+ ]
3192
+ }, [
3193
+ xt(ee),
3194
+ d("span", { class: "aimd-recorder-workbench__visual-header" }, [
3195
+ d("span", { class: "aimd-recorder-workbench__visual-summary" }, [
3196
+ d("span", { class: "aimd-recorder-workbench__visual-badge" }, v.value.typeLabels[K.fieldType]),
3197
+ d("span", { class: "aimd-recorder-workbench__visual-field-id" }, K.id)
3198
+ ]),
3199
+ d("span", { class: "aimd-recorder-workbench__visual-actions" }, [
3200
+ d("button", {
3201
+ type: "button",
3202
+ class: "aimd-recorder-workbench__visual-open-dialog",
3203
+ disabled: a.readonly,
3204
+ onClick: () => Dt(K)
3205
+ }, v.value.edit),
3206
+ d("span", {
3207
+ class: "aimd-recorder-workbench__visual-drag-handle",
3208
+ draggable: !a.readonly,
3209
+ title: v.value.drag,
3210
+ onDragstart: (Ke) => qt(K, Ke),
3211
+ onDragend: At
3212
+ }, `:: ${v.value.drag}`)
3213
+ ])
3214
+ ]),
3215
+ d("span", { class: "aimd-recorder-workbench__visual-body" }, [o]),
3216
+ xt(ee + 1)
3217
+ ]);
3218
+ return a.wrapField ? a.wrapField(r, l, be) : be;
3219
+ }
3220
+ return t({
3221
+ getEditor: () => s.value,
3222
+ getRecorder: () => f.value,
3223
+ runClientAssigner: (r) => f.value?.runClientAssigner(r),
3224
+ runManualClientAssigners: () => f.value?.runManualClientAssigners()
3225
+ }), (r, l) => (C(), T("div", {
3226
+ ref_key: "workbenchRef",
3227
+ ref: u,
3228
+ class: "aimd-recorder-workbench"
3229
+ }, [
3230
+ h("div", yr, [
3231
+ h("section", br, [
3232
+ h("header", {
3233
+ ref_key: "editorPanelHeadRef",
3234
+ ref: A,
3235
+ class: "aimd-recorder-workbench__panel-head"
3236
+ }, [
3237
+ h("h3", _r, k(Se.value), 1)
3238
+ ], 512),
3239
+ h("div", {
3240
+ ref_key: "editorPanelBodyRef",
3241
+ ref: V,
3242
+ class: "aimd-recorder-workbench__panel-body aimd-recorder-workbench__panel-body--editor",
3243
+ onFocusinCapture: ca,
3244
+ onFocusoutCapture: l[2] || (l[2] = (o) => Ct("source", o))
3245
+ }, [
3246
+ Fe(Ee(ja), Ta({
3247
+ ref_key: "editorRef",
3248
+ ref: s
3249
+ }, Q.value, {
3250
+ class: "aimd-recorder-workbench__editor",
3251
+ "onUpdate:modelValue": oa,
3252
+ "onUpdate:mode": l[0] || (l[0] = (o) => n("update:editorMode", o)),
3253
+ onReady: l[1] || (l[1] = (o) => n("editor-ready", o))
3254
+ }), null, 16)
3255
+ ], 544)
3256
+ ]),
3257
+ h("section", {
3258
+ class: pe(["aimd-recorder-workbench__panel", {
3259
+ "aimd-recorder-workbench__panel--structure": b.value === "structure",
3260
+ "aimd-recorder-workbench__panel--detached": b.value === "detached"
3261
+ }])
3262
+ }, [
3263
+ h("header", {
3264
+ ref_key: "sidePanelHeadRef",
3265
+ ref: D,
3266
+ class: "aimd-recorder-workbench__panel-head"
3267
+ }, [
3268
+ h("div", kr, [
3269
+ h("div", wr, [
3270
+ h("h3", Cr, [
3271
+ Ze(k(sa.value) + " ", 1),
3272
+ b.value === "detached" ? (C(), T("span", Er, " (" + k(nt.value) + ") ", 1)) : W("", !0)
3273
+ ]),
3274
+ e.showVisualEditToggle && b.value === "recorder" ? (C(), T("p", Tr, k(I.value), 1)) : W("", !0)
3275
+ ]),
3276
+ e.showVisualEditToggle && b.value === "recorder" ? (C(), T("div", Sr, [
3277
+ h("button", {
3278
+ class: pe(["aimd-recorder-workbench__visual-toggle", { "aimd-recorder-workbench__visual-toggle--active": m.value }]),
3279
+ type: "button",
3280
+ onClick: l[3] || (l[3] = (o) => m.value = !m.value)
3281
+ }, k(m.value ? v.value.visualEditOn : v.value.visualEditOff), 3)
3282
+ ])) : W("", !0)
3283
+ ]),
3284
+ ra.value ? (C(), T("nav", {
3285
+ key: 0,
3286
+ class: "aimd-recorder-workbench__side-tabs",
3287
+ "aria-label": ue.value ? "编辑器面板切换" : "Editor panels"
3288
+ }, [
3289
+ (C(!0), T(fe, null, he(Le.value, (o) => (C(), T("button", {
3290
+ key: o.key,
3291
+ class: pe(["aimd-recorder-workbench__side-tab", { "aimd-recorder-workbench__side-tab--active": b.value === o.key }]),
3292
+ type: "button",
3293
+ onClick: (K) => b.value = o.key
3294
+ }, [
3295
+ h("span", null, k(o.label), 1),
3296
+ typeof o.badge == "number" ? (C(), T("span", Dr, k(o.badge), 1)) : W("", !0)
3297
+ ], 10, $r))), 128))
3298
+ ], 8, zr)) : W("", !0)
3299
+ ], 512),
3300
+ b.value === "recorder" ? (C(), T("div", {
3301
+ key: 0,
3302
+ ref_key: "sidePanelBodyRef",
3303
+ ref: P,
3304
+ class: pe(["aimd-recorder-workbench__panel-body", m.value ? "aimd-recorder-workbench__panel-body--visual-editor" : "aimd-recorder-workbench__panel-body--recorder"]),
3305
+ style: je(Ye.value),
3306
+ onFocusinCapture: l[18] || (l[18] = (o) => m.value && ua()),
3307
+ onFocusoutCapture: l[19] || (l[19] = (o) => m.value && Ct("visual", o))
3308
+ }, [
3309
+ m.value ? (C(), T("div", {
3310
+ key: 0,
3311
+ ref_key: "recorderToolbarRef",
3312
+ ref: G,
3313
+ class: "aimd-recorder-workbench__recorder-toolbar"
3314
+ }, [
3315
+ h("p", Rr, k(v.value.addEndHint), 1)
3316
+ ], 512)) : W("", !0),
3317
+ m.value ? (C(), Mt(gr, {
3318
+ key: 1,
3319
+ content: N.value,
3320
+ "model-value": O.value,
3321
+ "min-height": U.value,
3322
+ locale: e.locale,
3323
+ readonly: e.readonly,
3324
+ "current-user-name": e.currentUserName,
3325
+ now: e.now,
3326
+ messages: e.messages,
3327
+ "step-detail-display": e.stepDetailDisplay,
3328
+ "field-meta": e.fieldMeta,
3329
+ "field-state": e.fieldState,
3330
+ "wrap-field": e.wrapField,
3331
+ "custom-renderers": e.customRenderers,
3332
+ "field-adapters": e.fieldAdapters,
3333
+ "resolve-file": e.resolveFile,
3334
+ "type-plugins": e.typePlugins,
3335
+ "enable-block-handle": e.editorProps?.enableBlockHandle ?? !0,
3336
+ class: "aimd-recorder-workbench__visual-editor",
3337
+ "onUpdate:content": da,
3338
+ "onUpdate:modelValue": Et,
3339
+ onFieldsChange: Tt,
3340
+ onError: l[4] || (l[4] = (o) => n("error", o)),
3341
+ onFieldChange: l[5] || (l[5] = (o) => n("field-change", o)),
3342
+ onFieldBlur: l[6] || (l[6] = (o) => n("field-blur", o)),
3343
+ onAssignerRequest: l[7] || (l[7] = (o) => n("assigner-request", o)),
3344
+ onAssignerCancel: l[8] || (l[8] = (o) => n("assigner-cancel", o)),
3345
+ onTableAddRow: l[9] || (l[9] = (o) => n("table-add-row", o)),
3346
+ onTableRemoveRow: l[10] || (l[10] = (o) => n("table-remove-row", o)),
3347
+ onEditField: ga,
3348
+ onDeleteField: ya
3349
+ }, null, 8, ["content", "model-value", "min-height", "locale", "readonly", "current-user-name", "now", "messages", "step-detail-display", "field-meta", "field-state", "wrap-field", "custom-renderers", "field-adapters", "resolve-file", "type-plugins", "enable-block-handle"])) : (C(), Mt(yt, {
3350
+ key: 2,
3351
+ ref_key: "recorderRef",
3352
+ ref: f,
3353
+ content: F.value,
3354
+ "model-value": O.value,
3355
+ readonly: e.readonly,
3356
+ "current-user-name": e.currentUserName,
3357
+ now: e.now,
3358
+ locale: e.locale,
3359
+ messages: e.messages,
3360
+ "step-detail-display": e.stepDetailDisplay,
3361
+ "field-meta": e.fieldMeta,
3362
+ "field-state": e.fieldState,
3363
+ "wrap-field": _a,
3364
+ "custom-renderers": e.customRenderers,
3365
+ "field-adapters": e.fieldAdapters,
3366
+ "resolve-file": e.resolveFile,
3367
+ "type-plugins": e.typePlugins,
3368
+ "onUpdate:modelValue": Et,
3369
+ onFieldsChange: Tt,
3370
+ onError: l[11] || (l[11] = (o) => n("error", o)),
3371
+ onFieldChange: l[12] || (l[12] = (o) => n("field-change", o)),
3372
+ onFieldBlur: l[13] || (l[13] = (o) => n("field-blur", o)),
3373
+ onAssignerRequest: l[14] || (l[14] = (o) => n("assigner-request", o)),
3374
+ onAssignerCancel: l[15] || (l[15] = (o) => n("assigner-cancel", o)),
3375
+ onTableAddRow: l[16] || (l[16] = (o) => n("table-add-row", o)),
3376
+ onTableRemoveRow: l[17] || (l[17] = (o) => n("table-remove-row", o))
3377
+ }, null, 8, ["content", "model-value", "readonly", "current-user-name", "now", "locale", "messages", "step-detail-display", "field-meta", "field-state", "custom-renderers", "field-adapters", "resolve-file", "type-plugins"]))
3378
+ ], 38)) : b.value === "structure" ? (C(), T("div", {
3379
+ key: 1,
3380
+ class: "aimd-recorder-workbench__panel-body aimd-recorder-workbench__panel-body--side",
3381
+ style: je(Ye.value)
3382
+ }, [
3383
+ h("div", qr, [
3384
+ h("p", Ar, k(S.value), 1),
3385
+ h("div", xr, [
3386
+ h("button", {
3387
+ class: "aimd-recorder-workbench__add-btn",
3388
+ disabled: e.readonly,
3389
+ onClick: l[20] || (l[20] = (o) => Ne("var"))
3390
+ }, k(v.value.addVar), 9, Vr),
3391
+ h("button", {
3392
+ class: "aimd-recorder-workbench__add-btn",
3393
+ disabled: e.readonly,
3394
+ onClick: l[21] || (l[21] = (o) => Ne("var_table"))
3395
+ }, k(v.value.addTable), 9, Mr),
3396
+ h("button", {
3397
+ class: "aimd-recorder-workbench__add-btn",
3398
+ disabled: e.readonly,
3399
+ onClick: l[22] || (l[22] = (o) => Ne("step"))
3400
+ }, k(v.value.addStep), 9, Fr),
3401
+ h("button", {
3402
+ class: "aimd-recorder-workbench__add-btn",
3403
+ disabled: e.readonly,
3404
+ onClick: l[23] || (l[23] = (o) => Ne("check"))
3405
+ }, k(v.value.addCheck), 9, Br),
3406
+ h("button", {
3407
+ class: "aimd-recorder-workbench__add-btn",
3408
+ disabled: e.readonly,
3409
+ onClick: l[24] || (l[24] = (o) => Ne("quiz"))
3410
+ }, k(v.value.addQuiz), 9, Ir)
3411
+ ]),
3412
+ se.value.length ? (C(), T("div", Pr, [
3413
+ h("div", {
3414
+ class: pe(["aimd-recorder-workbench__drop-zone", { "aimd-recorder-workbench__drop-zone--active": !!H.value }]),
3415
+ onDragover: st,
3416
+ onDrop: l[25] || (l[25] = dt((o) => ot(0), ["prevent"]))
3417
+ }, [
3418
+ H.value ? (C(), T("span", Or, k(v.value.dropHere), 1)) : W("", !0)
3419
+ ], 34),
3420
+ (C(!0), T(fe, null, he(se.value, (o, K) => (C(), T(fe, {
3421
+ key: o.uid
3422
+ }, [
3423
+ h("article", {
3424
+ class: pe(["aimd-recorder-workbench__field-item", { "aimd-recorder-workbench__field-item--dragging": H.value === o.uid }]),
3425
+ draggable: !e.readonly,
3426
+ onDragstart: (ee) => qt(o, ee),
3427
+ onDragend: At
3428
+ }, [
3429
+ h("div", Nr, [
3430
+ h("span", {
3431
+ class: "aimd-recorder-workbench__drag-handle",
3432
+ title: v.value.drag
3433
+ }, " :: " + k(v.value.drag), 9, Hr),
3434
+ h("span", Kr, k(v.value.typeLabels[o.fieldType]), 1),
3435
+ h("button", {
3436
+ class: "aimd-recorder-workbench__delete-btn",
3437
+ disabled: e.readonly,
3438
+ onClick: (ee) => lt(o)
3439
+ }, k(v.value.delete), 9, Wr)
3440
+ ]),
3441
+ h("div", Ur, [
3442
+ h("label", jr, [
3443
+ h("span", null, k(v.value.kind), 1),
3444
+ h("select", {
3445
+ value: o.fieldType,
3446
+ disabled: e.readonly,
3447
+ onChange: (ee) => zt(o, ee)
3448
+ }, [
3449
+ h("option", Gr, k(v.value.typeLabels.var), 1),
3450
+ h("option", Yr, k(v.value.typeLabels.var_table), 1),
3451
+ h("option", Zr, k(v.value.typeLabels.step), 1),
3452
+ h("option", Xr, k(v.value.typeLabels.check), 1),
3453
+ h("option", Jr, k(v.value.typeLabels.quiz), 1)
3454
+ ], 40, Qr)
3455
+ ]),
3456
+ h("label", el, [
3457
+ h("span", null, k(v.value.id), 1),
3458
+ h("input", {
3459
+ value: o.id,
3460
+ disabled: e.readonly,
3461
+ onChange: (ee) => St(o, ee)
3462
+ }, null, 40, tl)
3463
+ ]),
3464
+ o.fieldType === "var" ? (C(), T("label", al, [
3465
+ h("span", null, k(v.value.valueType), 1),
3466
+ h("input", {
3467
+ value: o.valueType || "str",
3468
+ disabled: e.readonly,
3469
+ onChange: (ee) => $t(o, ee)
3470
+ }, null, 40, il)
3471
+ ])) : W("", !0)
3472
+ ])
3473
+ ], 42, Lr),
3474
+ h("div", {
3475
+ class: pe(["aimd-recorder-workbench__drop-zone", { "aimd-recorder-workbench__drop-zone--active": !!H.value }]),
3476
+ onDragover: st,
3477
+ onDrop: dt((ee) => ot(K + 1), ["prevent"])
3478
+ }, [
3479
+ H.value ? (C(), T("span", rl, k(v.value.dropHere), 1)) : W("", !0)
3480
+ ], 42, nl)
3481
+ ], 64))), 128))
3482
+ ])) : (C(), T("p", ll, k(v.value.empty), 1))
3483
+ ])
3484
+ ], 4)) : b.value === "record" ? (C(), T("div", {
3485
+ key: 2,
3486
+ class: "aimd-recorder-workbench__panel-body aimd-recorder-workbench__panel-body--code",
3487
+ style: je(Ye.value)
3488
+ }, [
3489
+ h("pre", sl, k(ia.value), 1)
3490
+ ], 4)) : b.value === "detached" ? (C(), T("div", {
3491
+ key: 3,
3492
+ class: "aimd-recorder-workbench__panel-body aimd-recorder-workbench__panel-body--code",
3493
+ style: je(Ye.value)
3494
+ }, [
3495
+ h("p", ol, k(g.value), 1),
3496
+ h("pre", dl, " " + k(na.value) + `
3497
+ `, 1)
3498
+ ], 4)) : W("", !0)
3499
+ ], 2)
3500
+ ]),
3501
+ E.value ? (C(), T("div", {
3502
+ key: 0,
3503
+ class: "aimd-recorder-workbench__dialog-backdrop",
3504
+ onClick: dt(xe, ["self"])
3505
+ }, [
3506
+ h("section", {
3507
+ class: "aimd-recorder-workbench__dialog",
3508
+ "aria-label": v.value.visualDialogTitle,
3509
+ role: "dialog",
3510
+ "aria-modal": "true"
3511
+ }, [
3512
+ h("header", ul, [
3513
+ h("div", null, [
3514
+ h("h4", ml, k(v.value.visualDialogTitle), 1),
3515
+ h("p", fl, k(v.value.visualDialogSummary), 1)
3516
+ ]),
3517
+ h("button", {
3518
+ class: "aimd-recorder-workbench__dialog-close",
3519
+ type: "button",
3520
+ onClick: xe
3521
+ }, k(v.value.close), 1)
3522
+ ]),
3523
+ h("div", vl, [
3524
+ h("label", hl, [
3525
+ h("span", null, k(v.value.kind), 1),
3526
+ h("select", {
3527
+ value: E.value.fieldType,
3528
+ disabled: e.readonly,
3529
+ onChange: l[26] || (l[26] = (o) => zt(E.value, o))
3530
+ }, [
3531
+ h("option", gl, k(v.value.typeLabels.var), 1),
3532
+ h("option", yl, k(v.value.typeLabels.var_table), 1),
3533
+ h("option", bl, k(v.value.typeLabels.step), 1),
3534
+ h("option", _l, k(v.value.typeLabels.check), 1),
3535
+ h("option", kl, k(v.value.typeLabels.quiz), 1)
3536
+ ], 40, pl)
3537
+ ]),
3538
+ h("label", wl, [
3539
+ h("span", null, k(v.value.id), 1),
3540
+ h("input", {
3541
+ value: E.value.id,
3542
+ disabled: e.readonly,
3543
+ onChange: l[27] || (l[27] = (o) => St(E.value, o))
3544
+ }, null, 40, Cl)
3545
+ ]),
3546
+ E.value.fieldType === "var" ? (C(), T("label", El, [
3547
+ h("span", null, k(v.value.valueType), 1),
3548
+ h("input", {
3549
+ value: E.value.valueType || "str",
3550
+ disabled: e.readonly,
3551
+ onChange: l[28] || (l[28] = (o) => $t(E.value, o))
3552
+ }, null, 40, Tl)
3553
+ ])) : W("", !0),
3554
+ e.allowRawFieldSourceEditing ? (C(), T("label", Sl, [
3555
+ h("span", null, k(v.value.source), 1),
3556
+ ut(h("textarea", {
3557
+ "onUpdate:modelValue": l[29] || (l[29] = (o) => j.value = o),
3558
+ class: "aimd-recorder-workbench__dialog-textarea",
3559
+ disabled: e.readonly
3560
+ }, null, 8, zl), [
3561
+ [Yt, j.value]
3562
+ ])
3563
+ ])) : W("", !0)
3564
+ ]),
3565
+ h("footer", $l, [
3566
+ e.allowRawFieldSourceEditing ? (C(), T("p", Dl, k(v.value.sourceHint), 1)) : W("", !0),
3567
+ h("div", Rl, [
3568
+ h("button", {
3569
+ class: "aimd-recorder-workbench__dialog-delete",
3570
+ type: "button",
3571
+ disabled: e.readonly,
3572
+ onClick: l[30] || (l[30] = (o) => lt(E.value))
3573
+ }, k(v.value.delete), 9, ql),
3574
+ e.allowRawFieldSourceEditing ? (C(), T("button", {
3575
+ key: 0,
3576
+ class: "aimd-recorder-workbench__dialog-apply",
3577
+ type: "button",
3578
+ disabled: e.readonly,
3579
+ onClick: pa
3580
+ }, k(v.value.applySource), 9, Al)) : W("", !0)
3581
+ ])
3582
+ ])
3583
+ ], 8, cl)
3584
+ ])) : W("", !0)
3585
+ ], 512));
3586
+ }
3587
+ }), Hl = /* @__PURE__ */ Ge(Fl, [["__scopeId", "data-v-b7388655"]]), Kl = et(() => import("./AimdDnaSequenceField-__jdnFS9.js")), Wl = et(() => import("./AimdMarkdownField-98ImHGbc.js")), Ul = yt;
3588
+ export {
3589
+ Kl as AimdDnaSequenceField,
3590
+ Wl as AimdMarkdownField,
3591
+ Ul as AimdProtocolRecorder,
3592
+ En as AimdQuizRecorder,
3593
+ yt as AimdRecorder,
3594
+ Hl as AimdRecorderEditor
3595
+ };