uni-answer-sheet 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +83 -8
- package/REFERENCE_ASSETS.md +7 -0
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/dist/browser.js +57 -55
- package/dist/chunks/index-CDvIw14k.js +2256 -0
- package/dist/chunks/runtime-C-fdAw2T.js +24380 -0
- package/dist/index.d.ts +79 -4
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +4 -2
- package/dist/chunks/index-D612hHe6.js +0 -1081
- package/dist/chunks/runtime-DFHaUhsH.js +0 -24041
|
@@ -0,0 +1,2256 @@
|
|
|
1
|
+
var Ut = Object.defineProperty;
|
|
2
|
+
var Ft = (t, e, r) => e in t ? Ut(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var wt = (t, e, r) => Ft(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
const Kt = ["pagination", "content-identity", "choice-fill", "answer-regions", "html-codec", "status"];
|
|
5
|
+
function vt(t) {
|
|
6
|
+
const e = t.filter((n) => n?.kind === "answer-sheet-editor");
|
|
7
|
+
if (e.length !== 1) throw new Error("请显式注册一个富文本插件:plugins: [createEditorPlugin()]");
|
|
8
|
+
const r = e[0];
|
|
9
|
+
if (r.apiVersion !== 1 || r.documentVersion !== 1 || Kt.some((n) => !r.capabilities?.includes(n)) || typeof r.prepare != "function" || typeof r.create != "function" || typeof r.validateDocument != "function" || typeof r.html?.parse != "function" || typeof r.html?.serialize != "function") throw new Error("富文本插件协议不兼容,需要支持制卡协议 v1 的 uni-editor/plugin");
|
|
10
|
+
return r;
|
|
11
|
+
}
|
|
12
|
+
function xt(t) {
|
|
13
|
+
const e = [], r = (n) => {
|
|
14
|
+
if (n.type === "choiceGroup") {
|
|
15
|
+
typeof n.attrs?.id == "string" && e.push({
|
|
16
|
+
id: n.attrs.id,
|
|
17
|
+
label: n.attrs.label || String(e.length + 1),
|
|
18
|
+
options: (n.content || []).map((o, s) => ({ id: o.attrs?.id, label: String.fromCharCode(65 + s) })).filter((o) => typeof o.id == "string")
|
|
19
|
+
});
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
n.content?.forEach(r);
|
|
23
|
+
};
|
|
24
|
+
return r(t.content), e;
|
|
25
|
+
}
|
|
26
|
+
class mt extends Error {
|
|
27
|
+
constructor(e, r) {
|
|
28
|
+
super(r), this.path = e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const B = (t, e) => {
|
|
32
|
+
throw new mt(t, e);
|
|
33
|
+
}, ot = {
|
|
34
|
+
语文: "CHINESE",
|
|
35
|
+
数学: "MATHS",
|
|
36
|
+
英语: "ENGLISH",
|
|
37
|
+
科学: "SCIENCE",
|
|
38
|
+
物理: "PHYSICAL",
|
|
39
|
+
化学: "CHEMICAL",
|
|
40
|
+
生物: "BIOLOGICAL",
|
|
41
|
+
地理: "GEOGRAPHIC",
|
|
42
|
+
历史: "HISTORY",
|
|
43
|
+
政治: "POLITICAL",
|
|
44
|
+
思想政治: "POLITICAL",
|
|
45
|
+
道德与法治: "POLITICAL",
|
|
46
|
+
信息科技: "IT",
|
|
47
|
+
信息技术: "IT",
|
|
48
|
+
日语: "JAPANESE"
|
|
49
|
+
}, zt = {
|
|
50
|
+
P: ["语文", "数学", "英语", "科学", "道德与法治"],
|
|
51
|
+
J: ["语文", "数学", "英语", "物理", "化学", "生物", "地理", "历史", "道德与法治", "信息科技"],
|
|
52
|
+
S: ["语文", "数学", "英语", "物理", "化学", "生物", "政治", "历史", "地理", "信息技术", "日语"]
|
|
53
|
+
}, Wt = ["一年级", "二年级", "三年级", "四年级", "五年级", "六年级", "初一", "初二", "初三", "高一", "高二", "高三"], Vt = Wt.map((t, e) => {
|
|
54
|
+
const r = e < 6 ? "P" : e < 9 ? "J" : "S";
|
|
55
|
+
return { label: t, value: `${r}0${e < 6 ? e + 1 : (e - 6) % 3 + 1}`, classify: r };
|
|
56
|
+
}), z = (t, e) => typeof t == "string" && t.trim() ? t.trim() : B(e, "字典编码和名称必须是非空字符串"), tt = (t, e) => t && typeof t == "object" && !Array.isArray(t) ? t : B(e, "字典必须是对象"), $t = (t) => t.classify || (/^[PJS]/.test(t.value) ? t.value[0] : void 0);
|
|
57
|
+
function Lt(t = {}) {
|
|
58
|
+
const e = tt(t, "dictionaries"), r = (l, u) => {
|
|
59
|
+
if (!Array.isArray(l)) return B(u, "字典选项必须是数组");
|
|
60
|
+
const g = /* @__PURE__ */ new Set();
|
|
61
|
+
return l.map((A, C) => {
|
|
62
|
+
const x = tt(A, `${u}.${C}`), M = z(x.value, `${u}.${C}.value`), w = z(x.label, `${u}.${C}.label`);
|
|
63
|
+
return g.has(M) && B(`${u}.${C}.value`, "字典编码重复"), g.add(M), { ...x, value: M, label: w };
|
|
64
|
+
});
|
|
65
|
+
}, n = r(e.grades === void 0 ? Vt : e.grades, "dictionaries.grades").map((l, u) => (l.classify !== void 0 && !["P", "J", "S"].includes(String(l.classify)) && B(`dictionaries.grades.${u}.classify`, "学段为 P、J 或 S"), { value: l.value, label: l.label, classify: l.classify })), o = e.gradeCourseMap === void 0 ? void 0 : tt(e.gradeCourseMap, "dictionaries.gradeCourseMap"), s = e.courseCodeToSubjectCode === void 0 ? {} : tt(e.courseCodeToSubjectCode, "dictionaries.courseCodeToSubjectCode");
|
|
66
|
+
for (const [l, u] of Object.entries(s)) z(u, `dictionaries.courseCodeToSubjectCode.${l}`);
|
|
67
|
+
const c = /* @__PURE__ */ new Map(), i = Object.fromEntries(n.map((l) => {
|
|
68
|
+
const u = $t(l), g = (u ? zt[u] : []).map((x) => ({ value: ot[x], label: x, subjectCode: ot[x] })), A = `dictionaries.gradeCourseMap.${l.value}`, C = r(o ? o[l.value] ?? [] : g, A).map((x, M) => {
|
|
69
|
+
const w = s[x.value];
|
|
70
|
+
x.subjectCode !== void 0 && w !== void 0 && x.subjectCode !== w && B(`${A}.${M}.subjectCode`, "课程对应的学科编码冲突");
|
|
71
|
+
const O = z(x.subjectCode ?? w ?? (Object.values(ot).includes(x.value) ? x.value : void 0), `${A}.${M}.subjectCode`);
|
|
72
|
+
return c.has(x.value) && c.get(x.value) !== O && B(`${A}.${M}.subjectCode`, "同一课程不能对应不同学科"), c.set(x.value, O), x.custom !== void 0 && typeof x.custom != "boolean" && B(`${A}.${M}.custom`, "custom 必须是布尔值"), { value: x.value, label: x.label, subjectCode: O, ...x.custom === void 0 ? {} : { custom: x.custom } };
|
|
73
|
+
});
|
|
74
|
+
return [l.value, C];
|
|
75
|
+
})), a = n.filter((l) => i[l.value].length), y = e.defaultGradeCode === void 0 ? void 0 : z(e.defaultGradeCode, "dictionaries.defaultGradeCode"), T = a.find((l) => l.value === y)?.value || a[0]?.value || "", m = e.defaultCourseCode === void 0 ? void 0 : z(e.defaultCourseCode, "dictionaries.defaultCourseCode"), f = i[T] || [], p = f.find((l) => l.value === m)?.value || f[0]?.value || "";
|
|
76
|
+
return { grades: a, gradeCourseMap: i, defaultGradeCode: T, defaultCourseCode: p };
|
|
77
|
+
}
|
|
78
|
+
function dt(t, e, r) {
|
|
79
|
+
const n = t.grades.find((s) => s.value === e);
|
|
80
|
+
if (!n) return B("initialization.gradeCode", "年级不在可用字典中");
|
|
81
|
+
const o = t.gradeCourseMap[e]?.find((s) => s.value === r);
|
|
82
|
+
return o ? { grade: n.label, subject: o.label, gradeCode: e, courseCode: r, subjectCode: o.subjectCode, phaseCode: $t(n) } : B("initialization.courseCode", "当前年级没有此课程");
|
|
83
|
+
}
|
|
84
|
+
function He(t, e = {}) {
|
|
85
|
+
const n = t.grades.find((c) => c.value === e.gradeCode || !e.gradeCode && c.label === e.grade)?.value || t.defaultGradeCode, o = t.gradeCourseMap[n] || [], s = o.find((c) => c.value === e.courseCode || !e.courseCode && c.label === e.subject)?.value || (n === t.defaultGradeCode ? t.defaultCourseCode : o[0]?.value) || "";
|
|
86
|
+
return n && s ? dt(t, n, s) : { grade: "", subject: "", gradeCode: "", courseCode: "" };
|
|
87
|
+
}
|
|
88
|
+
function _t(t) {
|
|
89
|
+
return t?.subjectCode || ot[t?.subject || ""];
|
|
90
|
+
}
|
|
91
|
+
const W = { questions: 200, options: 12, score: 15 }, Be = (t) => t.multiple ? t.indefinite ? "indefinite" : "multiple" : "single", v = (t) => Number.isFinite(t) && Number.isInteger(t * 2), ht = (t) => !!(_t(t) === "MATHS" && (t?.phaseCode ? t.phaseCode === "S" : t?.gradeCode ? t.gradeCode.startsWith("S") : /^高[一二三]/.test(t?.grade || "")));
|
|
92
|
+
function Qt(t) {
|
|
93
|
+
const e = typeof t.score == "number" && v(t.score) && t.score >= 0.5 && t.score <= W.score ? t.score : null, r = [...new Set(t.correctIds)].filter((n) => t.options.some((o) => o.id === n));
|
|
94
|
+
return {
|
|
95
|
+
...t,
|
|
96
|
+
indefinite: !!(t.multiple && t.indefinite),
|
|
97
|
+
score: e,
|
|
98
|
+
scoreType: t.multiple && t.scoreType === "ITEM_SCORE" ? "ITEM_SCORE" : "LESS_SCORE",
|
|
99
|
+
lessScore: t.multiple && e !== null && v(t.lessScore ?? 0) ? Math.max(0, Math.min(e, t.lessScore ?? 0)) : 0,
|
|
100
|
+
correctIds: t.multiple ? r : r.slice(0, 1)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function Tt(t, e, r) {
|
|
104
|
+
let n = { ...t };
|
|
105
|
+
if (e.kind !== void 0) {
|
|
106
|
+
const o = e.kind !== "single";
|
|
107
|
+
o && !t.multiple && (n.scoreType = ht(r) ? "ITEM_SCORE" : "LESS_SCORE", typeof n.score != "number" && ht(r) && (n.score = 6)), n.multiple = o, n.indefinite = e.kind === "indefinite";
|
|
108
|
+
}
|
|
109
|
+
if (e.optionCount !== void 0) {
|
|
110
|
+
const o = Math.max(2, Math.min(W.options, Math.round(e.optionCount)));
|
|
111
|
+
n.options = Array.from({ length: o }, (s, c) => t.options[c] || { id: crypto.randomUUID(), label: String.fromCharCode(65 + c) });
|
|
112
|
+
}
|
|
113
|
+
return e.score !== void 0 && (n.score = e.score), e.scoreType !== void 0 && (n.scoreType = e.scoreType), e.lessScore !== void 0 && (n.lessScore = e.lessScore), Qt(n);
|
|
114
|
+
}
|
|
115
|
+
function Dt(t) {
|
|
116
|
+
return typeof t.score == "number" && (!v(t.score) || t.score < 0.5 || t.score > W.score) ? "每题分值须为 0.5–15 分,按 0.5 分递增" : t.multiple && t.scoreType === "LESS_SCORE" && typeof t.score == "number" && (!v(t.lessScore ?? 0) || (t.lessScore ?? 0) < 0 || (t.lessScore ?? 0) > t.score) ? "少选得分须为 0.5 的倍数,且不能超过本题分值" : t.multiple && t.scoreType === "ITEM_SCORE" && typeof t.score == "number" && t.correctIds.length && !v(t.score / t.correctIds.length) ? "答案个数与分值不匹配,每个正确选项的得分须为 0.5 的倍数" : null;
|
|
117
|
+
}
|
|
118
|
+
function je(t) {
|
|
119
|
+
return t.multiple && t.scoreType === "ITEM_SCORE" && typeof t.score == "number" && t.correctIds.length && !Dt(t) ? t.score / t.correctIds.length : null;
|
|
120
|
+
}
|
|
121
|
+
function Ge(t) {
|
|
122
|
+
const e = t.map((o) => Number(o.label)).filter((o) => Number.isSafeInteger(o) && o > 0 && o < 1e5);
|
|
123
|
+
let r = String(Math.max(0, ...e) + 1);
|
|
124
|
+
const n = new Set(t.map((o) => o.label));
|
|
125
|
+
for (; n.has(r); ) r = String(Number(r) + 1);
|
|
126
|
+
return r;
|
|
127
|
+
}
|
|
128
|
+
function Ue(t, e) {
|
|
129
|
+
const r = new Map(t.options.map((n) => [n.id, crypto.randomUUID()]));
|
|
130
|
+
return {
|
|
131
|
+
...t,
|
|
132
|
+
id: crypto.randomUUID(),
|
|
133
|
+
label: e,
|
|
134
|
+
breakBefore: !1,
|
|
135
|
+
contentTarget: null,
|
|
136
|
+
options: t.options.map((n) => ({ ...n, id: r.get(n.id) })),
|
|
137
|
+
correctIds: t.correctIds.map((n) => r.get(n)).filter(Boolean)
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function Jt(t, e, r) {
|
|
141
|
+
return r.trim() ? t.some((n) => n.id !== e && n.label.trim() === r.trim()) ? "题组内题号不能重复" : null : "题号不能为空";
|
|
142
|
+
}
|
|
143
|
+
function Fe(t, e, r, n) {
|
|
144
|
+
const o = t.questions.filter((a) => e.includes(a.id));
|
|
145
|
+
if (!o.length) return { error: "请选择要修改的题目" };
|
|
146
|
+
let s;
|
|
147
|
+
if (r.type === "settings") {
|
|
148
|
+
if (!Object.keys(r.patch).length) return { error: "请设置需要修改的属性" };
|
|
149
|
+
const { optionCount: a, score: y, lessScore: T } = r.patch;
|
|
150
|
+
if (a !== void 0 && (!Number.isInteger(a) || a < 2 || a > W.options)) return { error: "选项个数须为 2–12 的整数" };
|
|
151
|
+
if (typeof y == "number" && (!v(y) || y < 0.5 || y > W.score)) return { error: "每题分值须为 0.5–15 分,按 0.5 分递增" };
|
|
152
|
+
if (T !== void 0 && (!v(T) || T < 0)) return { error: "少选得分须为非负的 0.5 倍数" };
|
|
153
|
+
if (s = o.map((m) => Tt(m, r.patch, n)), T !== void 0 && s.some((m) => m.multiple && m.scoreType !== "ITEM_SCORE" && T > (m.score ?? 0))) return { error: "少选得分不能超过所选题目的分值" };
|
|
154
|
+
} else if (r.type === "numbering") {
|
|
155
|
+
if (!Number.isInteger(r.start) || r.start < 1 || r.start + o.length - 1 > 1e3) return { error: "连续题号须在 1–1000 内" };
|
|
156
|
+
s = o.map((a, y) => ({ ...a, label: String(r.start + y) }));
|
|
157
|
+
} else if (r.type === "average") {
|
|
158
|
+
const a = r.total / o.length;
|
|
159
|
+
if (!v(a) || a < 0.5 || a > W.score) return { error: "总分无法平均分配,每题须为 0.5–15 分且为 0.5 的倍数" };
|
|
160
|
+
s = o.map((y) => Tt(y, { score: a }));
|
|
161
|
+
} else {
|
|
162
|
+
const a = r.text.toUpperCase().trim().split(/[\s,,;;]+/).filter(Boolean);
|
|
163
|
+
if (a.length !== o.length) return { error: `需要 ${o.length} 组答案,当前为 ${a.length} 组` };
|
|
164
|
+
s = [];
|
|
165
|
+
for (let y = 0; y < o.length; y++) {
|
|
166
|
+
const T = o[y], m = a[y];
|
|
167
|
+
if (m !== "-" && (!/^[A-T]+$/.test(m) || new Set(m).size !== m.length || [...m].some((p) => !T.options.some((l) => l.label === p)))) return { error: `第 ${T.label} 题包含无效或重复选项` };
|
|
168
|
+
const f = m === "-" ? [] : [...m].map((p) => T.options.find((l) => l.label === p).id);
|
|
169
|
+
if (!T.multiple && f.length > 1) return { error: `第 ${T.label} 题为单选,只能设置一个答案` };
|
|
170
|
+
s.push({ ...T, correctIds: f });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const c = new Map(s.map((a) => [a.id, a])), i = t.questions.map((a) => c.get(a.id) || a);
|
|
174
|
+
for (const a of s) {
|
|
175
|
+
const y = Jt(i, a.id, a.label) || Dt(a);
|
|
176
|
+
if (y) return { error: `第 ${a.label} 题:${y}` };
|
|
177
|
+
}
|
|
178
|
+
return { value: { ...t, questions: i } };
|
|
179
|
+
}
|
|
180
|
+
const Xt = { layout: "natural", columns: 2, indent: !1, rowGap: 0, columnGap: 32, marker: "letter" }, St = (t) => `question:${t}`, Yt = (t) => t.presentation === "stem" ? "stem" : ["option", "distributed"].includes(t.presentation) ? "option" : "concentrated";
|
|
181
|
+
function Ke(t, e, r) {
|
|
182
|
+
const n = xt(e), o = /* @__PURE__ */ new Map(), s = (i, a) => {
|
|
183
|
+
const y = i.attrs?.contentId || a;
|
|
184
|
+
i.type === "choiceGroup" && y && o.set(i.attrs.id, y), i.content?.forEach((T) => s(T, y));
|
|
185
|
+
};
|
|
186
|
+
s(e.content);
|
|
187
|
+
const c = new Set(t.questions.map((i) => i.contentTarget?.groupId));
|
|
188
|
+
return { ...t, presentation: r, questions: t.questions.map((i, a) => {
|
|
189
|
+
const y = n.find((T) => o.get(T.id) === i.id) || (o.size ? void 0 : n[a]);
|
|
190
|
+
return r === "concentrated" || i.contentTarget !== void 0 || !y || c.has(y.id) ? i : (c.add(y.id), { ...i, contentTarget: { groupId: y.id, optionIds: y.options.map((T) => T.id) } });
|
|
191
|
+
}) };
|
|
192
|
+
}
|
|
193
|
+
function Zt(t, e, r) {
|
|
194
|
+
const n = Yt(t), o = new Map(xt(e).map((f) => [f.id, f])), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = (f, p) => {
|
|
195
|
+
const l = f.attrs?.contentId || p;
|
|
196
|
+
f.type === "choiceGroup" && l && (c.set(l, [...c.get(l) || [], f.attrs.id]), i.set(f.attrs.id, l)), f.type === "choiceStemAnchor" && typeof f.attrs?.groupId == "string" && s.add(f.attrs.groupId), f.content?.forEach((u) => a(u, l));
|
|
197
|
+
};
|
|
198
|
+
a(e.content);
|
|
199
|
+
const y = [], T = /* @__PURE__ */ new Set(), m = t.questions.filter((f) => {
|
|
200
|
+
if (!r || n === "concentrated") return !0;
|
|
201
|
+
if (n === "stem" && s.has(St(f.id)))
|
|
202
|
+
return y.push({ groupId: St(f.id), questionId: f.id, options: f.options.map((C) => ({ ...C, contentOptionId: C.id })) }), !1;
|
|
203
|
+
const p = c.get(f.id), l = p?.length === 1 ? o.get(p[0]) : void 0, u = l ? { groupId: l.id, optionIds: l.options.map((C) => C.id) } : f.contentTarget, g = u && o.get(u.groupId);
|
|
204
|
+
if (!u || !g || T.has(g.id) || n === "stem" && !s.has(g.id) || i.has(g.id) && i.get(g.id) !== f.id) return !0;
|
|
205
|
+
const A = u.optionIds.slice(0, f.options.length);
|
|
206
|
+
return A.length !== f.options.length || new Set(A).size !== A.length || A.some((C) => !g.options.some((x) => x.id === C)) ? !0 : (T.add(g.id), y.push({ groupId: g.id, questionId: f.id, options: f.options.map((C, x) => ({ ...C, contentOptionId: A[x] })) }), !1);
|
|
207
|
+
});
|
|
208
|
+
return { position: n === "concentrated" ? void 0 : n, bindings: y, concentrated: { ...t, questions: m } };
|
|
209
|
+
}
|
|
210
|
+
function at(t, e = 4) {
|
|
211
|
+
return {
|
|
212
|
+
id: crypto.randomUUID(),
|
|
213
|
+
label: String(t + 1),
|
|
214
|
+
multiple: !1,
|
|
215
|
+
indefinite: !1,
|
|
216
|
+
score: null,
|
|
217
|
+
scoreType: "LESS_SCORE",
|
|
218
|
+
lessScore: 0,
|
|
219
|
+
correctIds: [],
|
|
220
|
+
breakBefore: !1,
|
|
221
|
+
options: Array.from({ length: e }, (r, n) => ({ id: crypto.randomUUID(), label: String.fromCharCode(65 + n) }))
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function qt(t = 8) {
|
|
225
|
+
return {
|
|
226
|
+
source: "manual",
|
|
227
|
+
presentation: "concentrated",
|
|
228
|
+
direction: "row",
|
|
229
|
+
rowsPerColumn: 5,
|
|
230
|
+
marker: "box",
|
|
231
|
+
rowGap: 0,
|
|
232
|
+
columnGap: 0,
|
|
233
|
+
questions: Array.from({ length: t }, (e, r) => at(r))
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function ve(t) {
|
|
237
|
+
return new Set(t.questions.map((e) => e.options.length)).size > 1 ? "column" : t.direction;
|
|
238
|
+
}
|
|
239
|
+
function te(t) {
|
|
240
|
+
const e = [];
|
|
241
|
+
for (const r of t.questions) {
|
|
242
|
+
const n = e.at(-1);
|
|
243
|
+
(!n || n.length >= t.rowsPerColumn || r.breakBefore || n[0].options.length !== r.options.length) && e.push([]), e[e.length - 1].push(r);
|
|
244
|
+
}
|
|
245
|
+
return e;
|
|
246
|
+
}
|
|
247
|
+
function ze(t) {
|
|
248
|
+
const e = [];
|
|
249
|
+
for (const r of te(t))
|
|
250
|
+
(!e.length || r[0].breakBefore) && e.push([]), e[e.length - 1].push(r);
|
|
251
|
+
return e;
|
|
252
|
+
}
|
|
253
|
+
const ee = {
|
|
254
|
+
judge: "判断题",
|
|
255
|
+
fill: "填空题",
|
|
256
|
+
answer: "解答题",
|
|
257
|
+
calculation: "计算/证明",
|
|
258
|
+
matching: "信息匹配/连线",
|
|
259
|
+
ordering: "排序/分类",
|
|
260
|
+
correction: "改错题",
|
|
261
|
+
drawing: "作图题",
|
|
262
|
+
table: "表格填答",
|
|
263
|
+
writing: "语文作文",
|
|
264
|
+
english: "外语写作",
|
|
265
|
+
reading: "阅读理解",
|
|
266
|
+
cloze: "完形填空",
|
|
267
|
+
completion: "语法填空",
|
|
268
|
+
chunk: "断句题",
|
|
269
|
+
composite: "材料/复合题",
|
|
270
|
+
optional: "选做题组",
|
|
271
|
+
practice: "实践评价"
|
|
272
|
+
}, We = { choice: "选择", judge: "判断", fill: "填空", answer: "简答", calculation: "计算/证明", correction: "改错", drawing: "作图", table: "表格", writing: "作文", english: "外语写作" }, Ve = ["reading", "cloze", "completion", "composite", "optional"], j = () => ({ version: 1, content: { type: "doc", content: [{ type: "paragraph" }] } }), Qe = { symbols: ["√", "×"], letters: ["T", "F"], words: ["正确", "错误"] }, ne = (t) => ["writing", "english"].includes(t) ? 70 : ["answer", "calculation", "drawing", "table", "correction"].includes(t) ? 60 : 15, Je = (t) => t === "judge" ? 200 : t === "fill" ? 50 : ["reading", "cloze", "completion"].includes(t) ? 20 : t === "matching" ? 9 : 100;
|
|
273
|
+
function oe(t = 0) {
|
|
274
|
+
return { id: crypto.randomUUID(), label: String(t + 1), width: 50, style: "line", characters: 6, score: null, answers: [], prefix: "", suffix: "", breakAfter: !1 };
|
|
275
|
+
}
|
|
276
|
+
function re(t, e = "1") {
|
|
277
|
+
const r = crypto.randomUUID();
|
|
278
|
+
return {
|
|
279
|
+
id: r,
|
|
280
|
+
label: e,
|
|
281
|
+
kind: t,
|
|
282
|
+
document: j(),
|
|
283
|
+
reference: j(),
|
|
284
|
+
explanation: j(),
|
|
285
|
+
score: null,
|
|
286
|
+
choice: { ...at(0, t === "judge" ? 2 : 4), id: r, label: e },
|
|
287
|
+
presentation: "concentrated",
|
|
288
|
+
blanks: [oe()],
|
|
289
|
+
steps: [],
|
|
290
|
+
needsReason: !1,
|
|
291
|
+
judgment: null,
|
|
292
|
+
targets: [],
|
|
293
|
+
area: { style: t === "writing" ? "characters" : t === "english" ? "lines" : t === "drawing" ? "grid" : "blank", rows: t === "writing" ? 20 : 6, columns: 20, rowHeight: t === "writing" ? 40 : 28, wordMark: 100, title: !1, backgroundUrl: "" }
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function ie(t) {
|
|
297
|
+
return ["reading", "cloze", "chunk"].includes(t) ? "choice" : ["matching", "completion"].includes(t) ? "fill" : ["ordering", "composite", "optional", "practice"].includes(t) ? "answer" : t;
|
|
298
|
+
}
|
|
299
|
+
function Xe(t) {
|
|
300
|
+
return {
|
|
301
|
+
items: [re(ie(t))],
|
|
302
|
+
judgeLabels: "symbols",
|
|
303
|
+
fillNewLine: !0,
|
|
304
|
+
pool: [],
|
|
305
|
+
relation: "one",
|
|
306
|
+
reuseOptions: !0,
|
|
307
|
+
matchingDisplay: "letters",
|
|
308
|
+
ordering: "sequence",
|
|
309
|
+
sequence: [],
|
|
310
|
+
categories: [],
|
|
311
|
+
assignments: {},
|
|
312
|
+
chooseCount: 1,
|
|
313
|
+
groupScore: null,
|
|
314
|
+
chunkText: "",
|
|
315
|
+
chunkPoints: [],
|
|
316
|
+
chunkCorrect: [],
|
|
317
|
+
chunkMax: 3,
|
|
318
|
+
chunkScore: null,
|
|
319
|
+
attachmentUrl: ""
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
function Ye(t) {
|
|
323
|
+
return String(Math.max(0, ...t.map((e) => /^\d+$/.test(e.label) ? Number(e.label) : 0)) + 1);
|
|
324
|
+
}
|
|
325
|
+
function kt(t) {
|
|
326
|
+
const e = structuredClone(t), r = /* @__PURE__ */ new Map(), n = (s) => {
|
|
327
|
+
!s || typeof s != "object" || Object.entries(s).forEach(([c, i]) => {
|
|
328
|
+
["id", "answerId"].includes(c) && typeof i == "string" ? r.set(i, crypto.randomUUID()) : n(i);
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
n(e);
|
|
332
|
+
const o = (s) => typeof s == "string" ? r.get(s) || s : Array.isArray(s) ? s.map(o) : s && typeof s == "object" ? Object.fromEntries(Object.entries(s).map(([c, i]) => [r.get(c) || c, o(i)])) : s;
|
|
333
|
+
return o(e);
|
|
334
|
+
}
|
|
335
|
+
function Ze(t, e) {
|
|
336
|
+
const r = kt(t);
|
|
337
|
+
return { ...r, label: e, choice: { ...r.choice, label: e } };
|
|
338
|
+
}
|
|
339
|
+
function qe(t, e, r) {
|
|
340
|
+
const n = t.findIndex((c) => c.id === e), o = n + r;
|
|
341
|
+
if (n < 0 || o < 0 || o >= t.length) return t;
|
|
342
|
+
const s = [...t];
|
|
343
|
+
return s.splice(o, 0, ...s.splice(n, 1)), s;
|
|
344
|
+
}
|
|
345
|
+
function tn(t, e) {
|
|
346
|
+
return { ...t, pool: t.pool.filter((r) => r.id !== e), sequence: t.sequence.filter((r) => r !== e), assignments: Object.fromEntries(Object.entries(t.assignments).filter(([r]) => r !== e)), items: t.items.map((r) => ({ ...r, targets: r.targets.filter((n) => n !== e) })) };
|
|
347
|
+
}
|
|
348
|
+
function en(t, e, r) {
|
|
349
|
+
const n = [...new Set(r)].filter((s) => t.pool.some((c) => c.id === s)), o = t.relation === "one" ? n.slice(-1) : n;
|
|
350
|
+
return { ...t, items: t.items.map((s) => s.id === e ? { ...s, targets: o } : t.reuseOptions ? s : { ...s, targets: s.targets.filter((c) => !o.includes(c)) }) };
|
|
351
|
+
}
|
|
352
|
+
function nn(t, e) {
|
|
353
|
+
let r = 0;
|
|
354
|
+
for (; r < e.length && r < t.chunkText.length && e[r] === t.chunkText[r]; ) r++;
|
|
355
|
+
let n = 0;
|
|
356
|
+
for (; n < e.length - r && n < t.chunkText.length - r && e[e.length - 1 - n] === t.chunkText[t.chunkText.length - 1 - n]; ) n++;
|
|
357
|
+
const o = t.chunkText.length - n, s = /* @__PURE__ */ new Set(), c = t.chunkPoints.filter((i) => i.offset <= r || i.offset >= o).map((i) => ({ ...i, offset: i.offset <= r ? i.offset : i.offset + e.length - t.chunkText.length })).filter((i) => i.offset <= 0 || i.offset >= e.length || s.has(i.offset) ? !1 : (s.add(i.offset), !0));
|
|
358
|
+
return { ...t, chunkText: e, chunkPoints: c, chunkCorrect: t.chunkCorrect.filter((i) => c.some((a) => a.id === i)) };
|
|
359
|
+
}
|
|
360
|
+
function on(t, e) {
|
|
361
|
+
const r = [], n = t.items.map((o) => o.label.trim());
|
|
362
|
+
(n.some((o) => !o) || new Set(n).size !== n.length) && r.push("题号不能为空或重复");
|
|
363
|
+
for (const o of t.items) {
|
|
364
|
+
o.score !== null && (!Number.isFinite(o.score) || o.score < 0.5 || o.score > ne(o.kind) || !Number.isInteger(o.score * 2)) && r.push(`${o.label} 题分值超出范围或不是 0.5 的倍数`);
|
|
365
|
+
const c = (o.kind === "fill" ? o.blanks : o.steps).map((i) => i.score);
|
|
366
|
+
c.length && o.score !== null && c.every((i) => i !== null) && c.reduce((i, a) => i + (a || 0), 0) !== o.score && r.push(`${o.label} 题分项分值之和与题分不一致`);
|
|
367
|
+
}
|
|
368
|
+
if (["matching", "ordering"].includes(e)) {
|
|
369
|
+
const o = t.pool.map((s) => s.label.trim());
|
|
370
|
+
(o.some((s) => !s) || new Set(o).size !== o.length) && r.push("共享选项编号不能为空或重复");
|
|
371
|
+
}
|
|
372
|
+
return e === "optional" && t.chooseCount > t.items.length && r.push("选做数量不能超过题目数量"), e === "chunk" && t.chunkCorrect.length > t.chunkMax && r.push("正确断点数不能超过最多选择数"), r;
|
|
373
|
+
}
|
|
374
|
+
function rn(t = 3, e = 3) {
|
|
375
|
+
return { version: 1, content: { type: "doc", content: [{ type: "table", content: Array.from({ length: t }, () => ({ type: "tableRow", content: Array.from({ length: e }, () => ({ type: "tableCell", content: [{ type: "paragraph" }] })) })) }] } };
|
|
376
|
+
}
|
|
377
|
+
function J(t) {
|
|
378
|
+
const e = (r) => !!(r.text || r.type && !["doc", "paragraph", "choiceStemAnchor"].includes(r.type) || r.content?.some(e));
|
|
379
|
+
return !e(t.content);
|
|
380
|
+
}
|
|
381
|
+
const sn = { choice: "选择题", area: "空白区域", ...ee };
|
|
382
|
+
function cn(t) {
|
|
383
|
+
return {
|
|
384
|
+
id: crypto.randomUUID(),
|
|
385
|
+
kind: "area",
|
|
386
|
+
areaType: t,
|
|
387
|
+
title: t === "forbiden" ? "禁止答题区" : "空白答题区",
|
|
388
|
+
answerHeight: t === "forbiden" ? 100 : 200,
|
|
389
|
+
document: { version: 1, content: { type: "doc", content: t === "forbiden" ? ["请勿在此区域作答", "或者做任何标记"].map((e) => ({ type: "paragraph", attrs: { textAlign: "center", lineSpacing: 0 }, content: [{ type: "text", text: e }] })) : [{ type: "paragraph" }] } }
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
function se() {
|
|
393
|
+
return { version: 1, title: "", questionCard: !1, preset: "a3-two", margin: 15, gap: 10, blocks: [] };
|
|
394
|
+
}
|
|
395
|
+
function ce(t = "") {
|
|
396
|
+
return {
|
|
397
|
+
// 22px title + the configured 9mm line spacing + 10px bottom inset.
|
|
398
|
+
id: crypto.randomUUID(),
|
|
399
|
+
height: 70,
|
|
400
|
+
document: { version: 1, content: { type: "doc", content: [{
|
|
401
|
+
type: "paragraph",
|
|
402
|
+
attrs: { textAlign: "center", lineSpacing: 9 },
|
|
403
|
+
...t ? { content: [{ type: "text", text: t, marks: [{ type: "textStyle", attrs: { fontFamily: "SimSun, 宋体, serif", fontSize: "22px" } }] }] } : {}
|
|
404
|
+
}] } }
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
function ae(t) {
|
|
408
|
+
return {
|
|
409
|
+
...se(),
|
|
410
|
+
title: t.name,
|
|
411
|
+
creation: t,
|
|
412
|
+
paperTitle: ce(t.name),
|
|
413
|
+
header: { focusText: !0, writeKaohao: !1, missExam: !1, mifeng: !1, kaohao: "school", weishu: 8 }
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
function Q(t, e = 96) {
|
|
417
|
+
return t * e / 25.4;
|
|
418
|
+
}
|
|
419
|
+
const le = {
|
|
420
|
+
a4: { label: "A4 单栏", width: 210, height: 297, columns: 1 },
|
|
421
|
+
"a3-two": { label: "A3 双栏", width: 420, height: 297, columns: 2 },
|
|
422
|
+
"a3-three": { label: "A3 三栏", width: 420, height: 297, columns: 3 }
|
|
423
|
+
}, et = 44, it = 16;
|
|
424
|
+
function Ct(t, e) {
|
|
425
|
+
const r = le[t.preset], n = Q(r.width), o = Q(r.height), s = Q(t.margin), c = Q(t.gap), i = t.usage !== "homework" && t.header?.mifeng ? Q(t.header.kaohao === "code" ? 26 : 14) : 0, a = n - s * 2 - i, y = (a - c * (r.columns - 1)) / r.columns, T = Math.max(s, t.header ? t.recognition?.examQrCode ? 64 : 39 : 0), m = Math.max(s, t.header ? 56 : 0), f = o - T - m, p = f - it, l = t.header ? y : a, u = e && e.id === t.paperTitle?.id && Math.abs(e.width - l) < 1 ? e : void 0, g = t.paperTitle ? Math.min(f, u?.height ?? t.paperTitle.height + (t.header ? 260 : it)) : 0, A = (w, O = 0) => !!t.paperTitle && (t.header ? w % 2 === 0 && O === 0 : w === 0), C = (w, O = 0) => A(w, O) ? g : 0;
|
|
426
|
+
return { ...r, width: n, height: o, margin: s, topInset: T, bottomInset: m, gap: c, sealWidth: i, contentWidth: a, contentHeight: f, columnWidth: y, columnX: (w, O) => s + (w % 2 === 0 ? i : 0) + O * (y + c), titleWidth: l, titleMaxHeight: p, hasHeader: A, headerHeight: C, capacity: (w, O = 0) => f - C(w, O) };
|
|
427
|
+
}
|
|
428
|
+
function an(t, e, r) {
|
|
429
|
+
const n = Ct(t, r);
|
|
430
|
+
let o = 0, s = 0, c = 0;
|
|
431
|
+
const i = () => {
|
|
432
|
+
s++, s === n.columns && (s = 0, o++), c = 0;
|
|
433
|
+
}, a = t.blocks.map((T) => {
|
|
434
|
+
const m = e[T.id], f = m && Math.abs(m.width - n.columnWidth) < 1 ? m.height : 100 + T.answerHeight, p = m && Math.abs(m.width - n.columnWidth) < 1 ? [...new Set([...m.breaks || [], f].filter((M) => Number.isFinite(M) && M > 0 && M <= f))].sort((M, w) => M - w) : [], l = T.reference?.type === "CCOMPOSITION", u = (M) => l && M > 0 ? Math.max(0, 6 - Math.max(0, (m?.compositionStart || 0) - M)) : 0;
|
|
435
|
+
if (p.length > 1 && p.every((M, w) => {
|
|
436
|
+
const O = p[w - 1] || 0;
|
|
437
|
+
return M - O + u(O) <= n.capacity(1) + 0.5;
|
|
438
|
+
})) {
|
|
439
|
+
const M = [];
|
|
440
|
+
let w = 0;
|
|
441
|
+
for (; w < f - 0.5; ) {
|
|
442
|
+
const h = n.capacity(o, s) - c, I = w, d = u(w), b = (N) => m?.markingFrames?.some((L) => L.from >= I - 0.5 && L.from < N - 0.5 && L.to > N + 0.5) ? 22 : 0, E = p.filter((N) => N > I + 0.5 && N + b(N) <= I + h - d + 0.5).at(-1);
|
|
443
|
+
if (E === void 0) {
|
|
444
|
+
i();
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
const S = l && E < f - 0.5 ? Math.max(b(E), h - d - (E - w)) : b(E);
|
|
448
|
+
M.push({ page: o, column: s, x: n.columnX(o, s), y: o * (n.height + et) + n.topInset + n.headerHeight(o, s) + c, from: w, to: E, ...d ? { topPadding: d } : {}, ...S ? { bottomPadding: S } : {} }), c += E - w + d, w = E, w < f - 0.5 && i();
|
|
449
|
+
}
|
|
450
|
+
c += it;
|
|
451
|
+
const O = M[0];
|
|
452
|
+
return { id: T.id, ...O, height: f, available: n.capacity(O.page, O.column), overflowing: !1, fragments: M };
|
|
453
|
+
}
|
|
454
|
+
for (; c + f > n.capacity(o, s) + 0.5 && (c > 0 || n.headerHeight(o, s) > 0); ) i();
|
|
455
|
+
const A = n.capacity(o, s), C = f > A + 0.5, x = {
|
|
456
|
+
id: T.id,
|
|
457
|
+
page: o,
|
|
458
|
+
column: s,
|
|
459
|
+
x: n.columnX(o, s),
|
|
460
|
+
y: o * (n.height + et) + n.topInset + n.headerHeight(o, s) + c,
|
|
461
|
+
height: f,
|
|
462
|
+
available: A,
|
|
463
|
+
overflowing: C,
|
|
464
|
+
fragments: [{ page: o, column: s, x: n.columnX(o, s), y: o * (n.height + et) + n.topInset + n.headerHeight(o, s) + c, from: 0, to: Math.min(f, A) }]
|
|
465
|
+
};
|
|
466
|
+
return c += Math.min(f, A) + it, x;
|
|
467
|
+
}), y = /* @__PURE__ */ new Map();
|
|
468
|
+
return a.forEach((T, m) => T.fragments.forEach((f) => {
|
|
469
|
+
const p = `${f.page}/${f.column}`, l = y.get(p) || [];
|
|
470
|
+
l.push({ fragment: f, placement: T, blockIndex: m }), y.set(p, l);
|
|
471
|
+
})), y.forEach((T) => {
|
|
472
|
+
const m = T.filter((u) => ["answer", "writing", "english", "composite", "area"].includes(t.blocks[u.blockIndex].kind)).at(-1);
|
|
473
|
+
if (!m || t.blocks[m.blockIndex].reference?.type !== "CCOMPOSITION" && t.blocks[m.blockIndex].kind !== "area") return;
|
|
474
|
+
const f = T.at(-1).fragment, l = f.page * (n.height + et) + n.height - n.bottomInset - f.y - (f.to - f.from) - (f.topPadding || 0) - (f.bottomPadding || 0);
|
|
475
|
+
l <= 0 || l > 30 || (m.fragment.bottomPadding = (m.fragment.bottomPadding || 0) + l, T.slice(T.indexOf(m) + 1).forEach(({ fragment: u, placement: g }) => {
|
|
476
|
+
u.y += l, g.fragments[0] === u && (g.y = u.y);
|
|
477
|
+
}));
|
|
478
|
+
}), { geometry: n, placements: a, pageCount: o + 1 };
|
|
479
|
+
}
|
|
480
|
+
function pt(t, e) {
|
|
481
|
+
return { version: 1, content: { type: "doc", content: [{ type: "paragraph", content: [
|
|
482
|
+
{ type: "text", text: `${t}.`, marks: [{ type: "documentLabel", attrs: { kind: "number" } }] },
|
|
483
|
+
...e ? [{ type: "text", text: `(${e}分)`, marks: [{ type: "documentLabel", attrs: { kind: "score" } }] }] : []
|
|
484
|
+
] }] } };
|
|
485
|
+
}
|
|
486
|
+
function st(t, e, r) {
|
|
487
|
+
const n = (o) => {
|
|
488
|
+
if (!o.content) return o;
|
|
489
|
+
let s;
|
|
490
|
+
const c = o.content.flatMap((a) => {
|
|
491
|
+
const y = a.type === "text" && a.marks?.find((f) => f.type === "documentLabel")?.attrs?.kind, T = y && y === s;
|
|
492
|
+
if (s = y, T) return [];
|
|
493
|
+
if (!y) return [n(a)];
|
|
494
|
+
const m = y === "number" ? `${e}.` : r ? `(${r}分)` : "";
|
|
495
|
+
return m ? [{ ...a, text: m }] : [];
|
|
496
|
+
}), i = c.findIndex((a) => a.marks?.some((y) => y.type === "documentLabel" && y.attrs?.kind === "number"));
|
|
497
|
+
return r && i >= 0 && !c.some((a) => a.marks?.some((y) => y.type === "documentLabel" && y.attrs?.kind === "score")) && c.splice(i + 1, 0, { type: "text", text: `(${r}分)`, marks: [{ type: "documentLabel", attrs: { kind: "score" } }] }), { ...o, content: c };
|
|
498
|
+
};
|
|
499
|
+
return { ...t, content: n(t.content) };
|
|
500
|
+
}
|
|
501
|
+
const It = {
|
|
502
|
+
SCHOICE: "单选题",
|
|
503
|
+
MCHOICE: "多选题",
|
|
504
|
+
JUDGE: "判断题",
|
|
505
|
+
FILLBLANK: "填空题",
|
|
506
|
+
SHORTANSWER: "解答题",
|
|
507
|
+
MIXED: "复合题",
|
|
508
|
+
CLOZE: "完形填空",
|
|
509
|
+
READTHENANSWER: "阅读理解",
|
|
510
|
+
INFO_MATCHING: "信息匹配",
|
|
511
|
+
TEXT_COMPLETION: "语法填空",
|
|
512
|
+
ECOMPOSITION: "英语作文",
|
|
513
|
+
CCOMPOSITION: "语文作文",
|
|
514
|
+
CHUNK_CHOICE: "断句题"
|
|
515
|
+
}, At = ["SCHOICE", "MCHOICE", "JUDGE", "FILLBLANK", "SHORTANSWER", "MIXED"];
|
|
516
|
+
function ln(t, e = !1) {
|
|
517
|
+
const r = _t(t), n = e ? At.filter((o) => o !== "MIXED") : At;
|
|
518
|
+
return e ? ["CHINESE", "JAPANESE"].includes(r || "") ? [...n, "CHUNK_CHOICE"] : n : r === "CHINESE" ? [...n, "CCOMPOSITION", "CHUNK_CHOICE"] : r === "ENGLISH" ? [...n, "CLOZE", "READTHENANSWER", "INFO_MATCHING", "TEXT_COMPLETION", "ECOMPOSITION"] : r === "JAPANESE" ? Object.keys(It) : ["POLITICAL", "HISTORY"].includes(r || "") ? [...n, "CCOMPOSITION"] : n;
|
|
519
|
+
}
|
|
520
|
+
const ue = (t) => ["CLOZE", "READTHENANSWER", "INFO_MATCHING", "TEXT_COMPLETION"].includes(t), fe = (t) => ["SCHOICE", "MCHOICE", "CLOZE", "READTHENANSWER", "INFO_MATCHING", "JUDGE"].includes(t), Z = (t) => ({ version: 1, content: { type: "doc", content: t.length ? t : [{ type: "paragraph" }] } });
|
|
521
|
+
function Pt(t, e, r = !1) {
|
|
522
|
+
return {
|
|
523
|
+
content: j(),
|
|
524
|
+
numbered: !r,
|
|
525
|
+
groupId: `options:${e.id}`,
|
|
526
|
+
layout: { ...Xt, columns: t === "CLOZE" ? 4 : 2, ...t === "READTHENANSWER" ? { layout: "fixed", columnGap: 0 } : {} },
|
|
527
|
+
itemsContent: !r && fe(t) ? e.options.map((n) => ({ id: n.id, key: n.label, content: j() })) : []
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
const ct = (t) => {
|
|
531
|
+
if (t.type === "choiceStemAnchor" || t.type === "text" && t.marks?.some((n) => n.type === "documentLabel" && n.attrs?.kind === "number")) return null;
|
|
532
|
+
const { contentId: e, ...r } = t.attrs || {};
|
|
533
|
+
return { ...t, ...t.attrs ? { attrs: r } : {}, ...t.content ? { content: t.content.map(ct).filter((n) => n !== null) } : {} };
|
|
534
|
+
};
|
|
535
|
+
function Ot(t, e, r) {
|
|
536
|
+
const o = (t.content.content.content || [{ type: "paragraph" }]).map((s) => ({ ...s, attrs: { ...s.attrs, contentId: e } }));
|
|
537
|
+
if (t.numbered) {
|
|
538
|
+
const s = { type: "text", text: `${r}.`, marks: [{ type: "documentLabel", attrs: { kind: "number" } }] };
|
|
539
|
+
["paragraph", "heading"].includes(o[0]?.type || "") || o.unshift({ type: "paragraph", attrs: { contentId: e }, content: [] }), o[0] = { ...o[0], content: [s, ...o[0].content || []] };
|
|
540
|
+
}
|
|
541
|
+
return t.itemsContent.length && o.push({ type: "choiceGroup", attrs: { id: t.groupId, contentId: e, ...t.layout }, content: t.itemsContent.map((s) => ({
|
|
542
|
+
type: "choiceOption",
|
|
543
|
+
attrs: { id: s.id, label: s.key, sourceKey: s.key, marker: "letter" },
|
|
544
|
+
content: s.content.content.content || [{ type: "paragraph" }]
|
|
545
|
+
})) }), o;
|
|
546
|
+
}
|
|
547
|
+
function de(t, e) {
|
|
548
|
+
const r = e.filter((i) => i.type === "choiceGroup"), n = r.find((i) => i.attrs?.id === t.groupId) || (r.length === 1 ? r[0] : void 0), o = e.filter((i) => i !== n);
|
|
549
|
+
let s = !1;
|
|
550
|
+
const c = (i) => {
|
|
551
|
+
i.marks?.some((a) => a.type === "documentLabel" && a.attrs?.kind === "number") && (s = !0), i.content?.forEach(c);
|
|
552
|
+
};
|
|
553
|
+
return o.forEach(c), {
|
|
554
|
+
...t,
|
|
555
|
+
numbered: s,
|
|
556
|
+
content: Z(o.map(ct).filter((i) => i !== null)),
|
|
557
|
+
groupId: n?.attrs?.id || t.groupId,
|
|
558
|
+
layout: n ? Object.fromEntries(Object.entries(t.layout).map(([i, a]) => [i, n.attrs?.[i] ?? a])) : t.layout,
|
|
559
|
+
itemsContent: (n?.content || []).map((i, a) => ({ id: i.attrs?.id || t.itemsContent[a]?.id || crypto.randomUUID(), key: i.attrs?.label || String.fromCharCode(65 + a), content: Z((i.content || []).map(ct).filter((y) => y !== null)) }))
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
function he(t, e, r, n) {
|
|
563
|
+
const o = /* @__PURE__ */ new Map();
|
|
564
|
+
e.content.content?.forEach((i) => {
|
|
565
|
+
i.attrs?.contentId && o.set(i.attrs.contentId, [...o.get(i.attrs.contentId) || [], i]);
|
|
566
|
+
});
|
|
567
|
+
const s = new Set(n?.content.content?.map((i) => i.attrs?.contentId).filter(Boolean)), c = (i, a) => a && (o.has(i) || s.has(i)) ? de(a, o.get(i) || []) : a;
|
|
568
|
+
return {
|
|
569
|
+
...t,
|
|
570
|
+
...o.has(r) ? { material: Z(o.get(r).map((i) => ct(i))) } : {},
|
|
571
|
+
questions: t.questions.map((i) => ({ ...i, text: c(i.id, i.text), parts: i.parts.map((a) => ({ ...a, text: c(a.id, a.text) })) }))
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function pe(t) {
|
|
575
|
+
const e = t.reference, r = [];
|
|
576
|
+
e.type === "MIXED" && r.push(...(e.material || j()).content.content.map((o) => ({ ...o, attrs: { ...o.attrs, contentId: t.id } }))), e.questions.forEach((o) => {
|
|
577
|
+
o.text && r.push(...Ot(o.text, o.id, o.label)), ue(o.type) && o.parts.forEach((s) => {
|
|
578
|
+
s.text && r.push(...Ot(s.text, s.id, s.label));
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
const n = (t.document.content.content || []).filter((o) => !o.attrs?.contentId);
|
|
582
|
+
return J(Z(n)) || r.push(...n), Z(r);
|
|
583
|
+
}
|
|
584
|
+
function ge(t, e) {
|
|
585
|
+
const r = (n, o, s) => !n || !s || o.options.map((c) => c.id).join() === s.options.map((c) => c.id).join() ? n : { ...n, itemsContent: o.options.map((c) => ({ ...n.itemsContent.find((i) => i.id === c.id), id: c.id, key: c.label, content: n.itemsContent.find((i) => i.id === c.id)?.content || j() })) };
|
|
586
|
+
return { ...t, questions: t.questions.map((n) => {
|
|
587
|
+
const o = e.questions.find((s) => s.id === n.id);
|
|
588
|
+
return { ...n, text: r(n.text, n.choice, o?.choice), parts: n.parts.map((s) => ({ ...s, text: r(s.text, s.choice, o?.parts.find((c) => c.id === s.id)?.choice) })) };
|
|
589
|
+
}) };
|
|
590
|
+
}
|
|
591
|
+
function un(t, e, r) {
|
|
592
|
+
if (t.reference?.textVersion !== 1) return t;
|
|
593
|
+
let n = t.reference;
|
|
594
|
+
if (!e && !J(t.document) && !t.document.content.content?.some((s) => s.attrs?.contentId)) return { ...t, reference: { ...n, textVersion: void 0 } };
|
|
595
|
+
if (e?.reference === n && e.document === t.document && !J(t.document)) return t;
|
|
596
|
+
if (t.document !== e?.document && (!J(t.document) || e) && (n = he(n, t.document, t.id, e?.document), e && t.reference === e.reference))
|
|
597
|
+
return { ...t, reference: n };
|
|
598
|
+
e?.reference && t.reference !== e.reference && (n = ge(n, e.reference));
|
|
599
|
+
const o = { ...t, reference: n };
|
|
600
|
+
return r || !J(t.document) ? { ...o, document: pe(o) } : o;
|
|
601
|
+
}
|
|
602
|
+
const lt = {
|
|
603
|
+
SCHOICE: { count: 200, options: [2, 12], parts: 1, score: 15 },
|
|
604
|
+
MCHOICE: { count: 200, options: [2, 12], parts: 1, score: 15 },
|
|
605
|
+
JUDGE: { count: 200, options: [2, 2], parts: 1, score: 15 },
|
|
606
|
+
CHUNK_CHOICE: { count: 100, options: [2, 26], parts: 1, score: 10 },
|
|
607
|
+
FILLBLANK: { count: 50, options: [0, 0], parts: 20, score: 15 },
|
|
608
|
+
SHORTANSWER: { count: 100, options: [0, 0], parts: 10, score: 60 },
|
|
609
|
+
CLOZE: { count: 20, options: [4, 4], parts: 20, score: 15 },
|
|
610
|
+
READTHENANSWER: { count: 20, options: [2, 12], parts: 20, score: 15 },
|
|
611
|
+
INFO_MATCHING: { count: 20, options: [1, 9], parts: 9, score: 15 },
|
|
612
|
+
TEXT_COMPLETION: { count: 20, options: [0, 0], parts: 20, score: 15 },
|
|
613
|
+
CCOMPOSITION: { count: 1, options: [0, 0], parts: 1, score: 70 },
|
|
614
|
+
ECOMPOSITION: { count: 1, options: [0, 0], parts: 1, score: 70 }
|
|
615
|
+
}, Y = (t) => ["SCHOICE", "MCHOICE", "JUDGE", "CHUNK_CHOICE", "CLOZE", "READTHENANSWER", "INFO_MATCHING"].includes(t), R = (t) => ["CLOZE", "READTHENANSWER", "INFO_MATCHING", "TEXT_COMPLETION"].includes(t), fn = (t) => t === "FILLBLANK" || t === "TEXT_COMPLETION", Rt = (t) => t === "CCOMPOSITION" || t === "ECOMPOSITION", me = { SCHOICE: "choice", MCHOICE: "choice", JUDGE: "judge", FILLBLANK: "fill", SHORTANSWER: "answer", MIXED: "composite", CLOZE: "cloze", READTHENANSWER: "reading", INFO_MATCHING: "matching", TEXT_COMPLETION: "completion", ECOMPOSITION: "english", CCOMPOSITION: "writing", CHUNK_CHOICE: "chunk" };
|
|
616
|
+
function Ce(t) {
|
|
617
|
+
return { type: t, textVersion: 1, questions: [], layout: qt(0), fillNewLine: !1, optional: !1, choose: 1, optionalHeight: 200, scoreType: "LESS_SCORE" };
|
|
618
|
+
}
|
|
619
|
+
function dn(t) {
|
|
620
|
+
return { id: crypto.randomUUID(), kind: me[t], title: It[t], answerHeight: 0, document: j(), reference: Ce(t) };
|
|
621
|
+
}
|
|
622
|
+
function hn(t, e = 1, r) {
|
|
623
|
+
const n = t === "MCHOICE" && ht(r);
|
|
624
|
+
return {
|
|
625
|
+
type: t,
|
|
626
|
+
start: e,
|
|
627
|
+
end: e,
|
|
628
|
+
optionCount: t === "INFO_MATCHING" ? null : t === "CHUNK_CHOICE" ? 12 : t === "JUDGE" ? 2 : 4,
|
|
629
|
+
partCount: R(t) ? null : 1,
|
|
630
|
+
score: n ? 6 : null,
|
|
631
|
+
scoreType: n ? "ITEM_SCORE" : "LESS_SCORE",
|
|
632
|
+
lessScore: 0,
|
|
633
|
+
characters: 1e3,
|
|
634
|
+
lines: 10,
|
|
635
|
+
rightAnswers: null,
|
|
636
|
+
singleScore: 1
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
function Ht(t, e, r) {
|
|
640
|
+
const n = Array.from({ length: r }, (o, s) => ({ ...t.options[s] || { id: crypto.randomUUID() }, label: e === "JUDGE" ? ["T", "F"][s] : String.fromCharCode(65 + s) }));
|
|
641
|
+
return { ...t, options: n, multiple: e === "MCHOICE" || e === "CHUNK_CHOICE", indefinite: !1, correctIds: t.correctIds.filter((o) => n.some((s) => s.id === o)).slice(0, e === "MCHOICE" || e === "CHUNK_CHOICE" ? r : 1) };
|
|
642
|
+
}
|
|
643
|
+
function Ie(t, e, r, n = 4) {
|
|
644
|
+
const o = crypto.randomUUID(), s = { ...Ht(at(0), r, n), id: o, label: t, score: e };
|
|
645
|
+
return {
|
|
646
|
+
id: o,
|
|
647
|
+
label: t,
|
|
648
|
+
score: e,
|
|
649
|
+
width: 25,
|
|
650
|
+
breakAfter: !1,
|
|
651
|
+
height: 100,
|
|
652
|
+
document: r === "SHORTANSWER" ? pt(t, e) : j(),
|
|
653
|
+
choice: s,
|
|
654
|
+
...R(r) && r !== "TEXT_COMPLETION" ? { text: Pt(r, s) } : {}
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
function ye(t, e) {
|
|
658
|
+
const r = crypto.randomUUID(), { type: n, score: o } = t, s = String(e), c = t.partCount || 1, i = Array.from({ length: R(n) || ["FILLBLANK", "SHORTANSWER"].includes(n) ? c : 0 }, (y, T) => Ie(R(n) ? String(e + T) : c === 1 ? s : `${s}.${T + 1}`, o, n, t.optionCount || 4)), a = { ...Ht(at(0), n, t.optionCount || 4), id: r, label: s, score: o, scoreType: t.scoreType, lessScore: t.lessScore };
|
|
659
|
+
return {
|
|
660
|
+
id: r,
|
|
661
|
+
type: n,
|
|
662
|
+
label: s,
|
|
663
|
+
score: i.length ? Bt(i) : o,
|
|
664
|
+
choice: a,
|
|
665
|
+
text: Pt(n, a, R(n)),
|
|
666
|
+
parts: i,
|
|
667
|
+
document: n === "ECOMPOSITION" ? { version: 1, content: { type: "doc", content: [...pt(s, o).content.content, ...be(t.lines, t.paperWidth || 600).content.content] } } : n === "CCOMPOSITION" ? pt(s, o) : j(),
|
|
668
|
+
height: n === "ECOMPOSITION" ? 50 * t.lines + 40 : 100,
|
|
669
|
+
contentHeight: 38,
|
|
670
|
+
characters: t.characters,
|
|
671
|
+
lines: t.lines,
|
|
672
|
+
halfPoint: !1,
|
|
673
|
+
rightAnswers: t.rightAnswers,
|
|
674
|
+
singleScore: t.singleScore
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
const Bt = (t) => t.some((e) => e.score === null) ? null : t.reduce((e, r) => e + (r.score || 0), 0);
|
|
678
|
+
function yt(t) {
|
|
679
|
+
return t.questions.flatMap((e) => R(e.type) ? e.parts.map((r) => r.label) : [e.label]);
|
|
680
|
+
}
|
|
681
|
+
function pn(t) {
|
|
682
|
+
return Math.max(0, ...yt(t).map(Number).filter(Number.isFinite)) + 1;
|
|
683
|
+
}
|
|
684
|
+
function gn(t, e, r = !1, n = !1) {
|
|
685
|
+
const o = lt[e.type], s = Rt(e.type) ? 1 : e.end - e.start + 1;
|
|
686
|
+
if (!Number.isInteger(e.start) || e.start < 1 || e.end > 1e3 || !Number.isInteger(s) || s < 1 || s > o.count) return `题号须为 1–1000,单次题数为 1–${o.count}`;
|
|
687
|
+
if (t.type === "CCOMPOSITION" && t.questions.length) return "语文作文每组只能有一道题";
|
|
688
|
+
if (t.optional) return "选做题组不能追加题目";
|
|
689
|
+
const c = yt(t);
|
|
690
|
+
if (Array.from({ length: s }, (i, a) => String(e.start + a)).some((i) => c.includes(i))) return "同一分组内,题号不能重复";
|
|
691
|
+
if (Y(e.type) && (e.optionCount === null || !Number.isInteger(e.optionCount) || e.optionCount < o.options[0] || e.optionCount > o.options[1])) return `选项个数须为 ${o.options[0]}–${o.options[1]}`;
|
|
692
|
+
if ((R(e.type) || ["FILLBLANK", "SHORTANSWER"].includes(e.type)) && (!e.partCount || !Number.isInteger(e.partCount) || e.partCount < 1 || e.partCount > o.parts)) return `子题/空数须为 1–${o.parts}`;
|
|
693
|
+
if (R(e.type) && s % e.partCount !== 0) return "题目数量无法按子题数量均分,请重新设置";
|
|
694
|
+
if (e.type === "INFO_MATCHING" && e.partCount > e.optionCount) return "选项个数需大于等于子题数量";
|
|
695
|
+
if (e.type === "SHORTANSWER" && (r || t.optional) && e.partCount !== 1) return "网阅或选做题不支持小题";
|
|
696
|
+
if (e.score !== null && (!Number.isFinite(e.score) || e.score < (n ? 0 : 0.5) || e.score > o.score || !Number.isInteger(e.score * 2))) return `分值须为 ${n ? 0 : 0.5}–${o.score} 分,按 0.5 分递增`;
|
|
697
|
+
if (e.type === "MCHOICE" && (e.lessScore < 0 || !Number.isInteger(e.lessScore * 2) || e.lessScore > (e.score || 0))) return "少选得分不能超过本题分值";
|
|
698
|
+
if (e.type === "CHUNK_CHOICE") {
|
|
699
|
+
if (!e.rightAnswers || !Number.isInteger(e.rightAnswers) || e.rightAnswers >= e.optionCount) return "正确答案个数需小于选项个数";
|
|
700
|
+
if (e.singleScore === null || e.singleScore < 0.5 || !Number.isInteger(e.singleScore * 2) || e.score !== null && e.score !== 0 && e.singleScore * e.rightAnswers > e.score) return "每处得分乘以正确答案个数不可大于每题分数";
|
|
701
|
+
}
|
|
702
|
+
return e.type === "CCOMPOSITION" && (!Number.isInteger(e.characters) || e.characters < 1 || e.characters > 1200) ? "作文格数须为 1–1200" : e.type === "ECOMPOSITION" && (!Number.isInteger(e.lines) || e.lines < 1 || e.lines > 100) ? "作文行数须为 1–100" : e.score === null ? "请输入分值" : null;
|
|
703
|
+
}
|
|
704
|
+
function mn(t, e, r) {
|
|
705
|
+
const n = R(e.type) ? e.partCount : 1, o = [];
|
|
706
|
+
for (let i = e.start; i <= (Rt(e.type) ? e.start : e.end); i += n) o.push(ye(e, i));
|
|
707
|
+
const s = [...t.questions], c = s.findIndex((i) => i.id === r || i.parts.some((a) => a.id === r));
|
|
708
|
+
return s.splice(c < 0 ? s.length : c + 1, 0, ...o), { ...t, questions: s };
|
|
709
|
+
}
|
|
710
|
+
function Cn(t) {
|
|
711
|
+
return t.questions.flatMap((e) => [e, ...e.parts]);
|
|
712
|
+
}
|
|
713
|
+
function In(t) {
|
|
714
|
+
return t.questions.filter((e) => Y(e.type)).flatMap((e) => R(e.type) ? e.parts.map((r) => ({ ...r.choice, label: r.label, score: r.score })) : [{ ...e.choice, label: e.label, score: e.score }]);
|
|
715
|
+
}
|
|
716
|
+
function yn(t, e) {
|
|
717
|
+
const r = kt(t);
|
|
718
|
+
return r.referenceData && (r.referenceData = { ...r.referenceData, questionId: r.id }), r.text && (r.text.groupId = `options:${r.id}`), r.label = String(e), r.choice.label = r.label, r.choice.contentTarget = null, r.choice.breakBefore = !1, r.parts.forEach((n, o) => {
|
|
719
|
+
n.label = R(r.type) ? String(e + o) : r.parts.length === 1 ? r.label : `${e}.${o + 1}`, n.choice.label = n.label, n.choice.contentTarget = null, n.choice.breakBefore = !1;
|
|
720
|
+
}), r.parts.forEach((n) => {
|
|
721
|
+
n.text && (n.text.groupId = `options:${n.id}`), n.referenceData && (n.referenceData = { ...n.referenceData, questionId: n.id, questionPid: r.id });
|
|
722
|
+
}), r.document = st(r.document, r.label, r.score), r.parts = r.parts.map((n) => ({ ...n, document: st(n.document, n.label, n.score) })), r;
|
|
723
|
+
}
|
|
724
|
+
function bn(t) {
|
|
725
|
+
return Math.max(1, Math.floor((t - 6) / 31));
|
|
726
|
+
}
|
|
727
|
+
function be(t, e) {
|
|
728
|
+
return { version: 1, content: { type: "doc", content: Array.from({ length: t }, () => ({ type: "paragraph", attrs: { fixedLineHeight: 1152 / 25.4 }, content: [{ type: "text", text: " ".repeat(Math.max(1, Math.floor((e - 24) / 3))), marks: [{ type: "underline" }, { type: "textStyle", attrs: { fontFamily: "Times New Roman, serif", fontSize: "12px" } }] }] })) } };
|
|
729
|
+
}
|
|
730
|
+
function En(t, e, r = !1) {
|
|
731
|
+
const n = t.questions.reduce((s, c) => s + (c.parts.length || 1), 0), o = e / n;
|
|
732
|
+
return !n || !Number.isFinite(o) || o < (r ? 0 : 0.5) || !Number.isInteger(o * 2) || t.questions.some((s) => o > lt[s.type].score || o !== 0 && s.type === "CHUNK_CHOICE" && (s.rightAnswers || 0) * (s.singleScore || 0) > o) ? null : { ...t, questions: t.questions.map((s) => ({ ...s, score: o * (s.parts.length || 1), document: st(s.document, s.label, o * (s.parts.length || 1)), choice: { ...s.choice, score: o, lessScore: Math.min(s.choice.lessScore || 0, o) }, parts: s.parts.map((c) => ({ ...c, score: o, document: st(c.document, c.label, o), choice: { ...c.choice, score: o } })) })) };
|
|
733
|
+
}
|
|
734
|
+
function wn(t, e) {
|
|
735
|
+
return [...t <= 17 ? Array.from({ length: 18 }, (r, n) => 17 - n <= t ? String(17 - n) : "") : [...Array.from({ length: 7 }, (r, n) => 7 - n <= Math.floor(t / 10) ? `${7 - n}0` : ""), "", ...Array.from({ length: 10 }, (r, n) => String(9 - n))], e ? "0.5" : ""];
|
|
736
|
+
}
|
|
737
|
+
const Ee = ["000", "100", "110", "111", "101", "010", "011", "001"], Tn = (t) => Ee[t - 1], jt = {
|
|
738
|
+
CHINESE: [1],
|
|
739
|
+
MATHS: [2],
|
|
740
|
+
ENGLISH: [3],
|
|
741
|
+
PHYSICAL: [4],
|
|
742
|
+
CHEMICAL: [1, 2],
|
|
743
|
+
POLITICAL: [1, 3],
|
|
744
|
+
BIOLOGICAL: [1, 4],
|
|
745
|
+
GEOGRAPHIC: [2, 3],
|
|
746
|
+
JAPANESE: [2, 4],
|
|
747
|
+
IT: [3, 4],
|
|
748
|
+
GYM: [1, 2, 3],
|
|
749
|
+
MUSIC: [1, 2, 4],
|
|
750
|
+
ART: [1, 3, 4],
|
|
751
|
+
SCIENCE: [2, 3, 4],
|
|
752
|
+
HISTORY: [1, 2, 3, 4]
|
|
753
|
+
}, we = {
|
|
754
|
+
语文: "CHINESE",
|
|
755
|
+
数学: "MATHS",
|
|
756
|
+
英语: "ENGLISH",
|
|
757
|
+
物理: "PHYSICAL",
|
|
758
|
+
化学: "CHEMICAL",
|
|
759
|
+
政治: "POLITICAL",
|
|
760
|
+
思想政治: "POLITICAL",
|
|
761
|
+
道德与法治: "POLITICAL",
|
|
762
|
+
生物: "BIOLOGICAL",
|
|
763
|
+
地理: "GEOGRAPHIC",
|
|
764
|
+
日语: "JAPANESE",
|
|
765
|
+
信息科技: "IT",
|
|
766
|
+
信息技术: "IT",
|
|
767
|
+
体育: "GYM",
|
|
768
|
+
音乐: "MUSIC",
|
|
769
|
+
美术: "ART",
|
|
770
|
+
科学: "SCIENCE",
|
|
771
|
+
历史: "HISTORY"
|
|
772
|
+
};
|
|
773
|
+
function Te(t) {
|
|
774
|
+
return t?.subjectCode || (t?.courseCode && jt[t.courseCode] ? t.courseCode : we[t?.subject || ""]);
|
|
775
|
+
}
|
|
776
|
+
const nt = (t) => Math.round(t * 1e3) / 1e3, Sn = (t) => ({ x: nt(t.x), y: nt(t.y), width: nt(t.width), height: nt(t.height) });
|
|
777
|
+
function An(t, e) {
|
|
778
|
+
const r = Math.max(t.x, e.x), n = Math.max(t.y, e.y), o = Math.min(t.x + t.width, e.x + e.width) - r, s = Math.min(t.y + t.height, e.y + e.height) - n;
|
|
779
|
+
return o > 0.01 && s > 0.01 ? { x: r, y: n, width: o, height: s } : void 0;
|
|
780
|
+
}
|
|
781
|
+
const V = function(t, e) {
|
|
782
|
+
let o = t;
|
|
783
|
+
const s = X[e];
|
|
784
|
+
let c = null, i = 0, a = null;
|
|
785
|
+
const y = [], T = {}, m = function(h, I) {
|
|
786
|
+
i = o * 4 + 17, c = (function(d) {
|
|
787
|
+
const b = new Array(d);
|
|
788
|
+
for (let E = 0; E < d; E += 1) {
|
|
789
|
+
b[E] = new Array(d);
|
|
790
|
+
for (let S = 0; S < d; S += 1)
|
|
791
|
+
b[E][S] = null;
|
|
792
|
+
}
|
|
793
|
+
return b;
|
|
794
|
+
})(i), f(0, 0), f(i - 7, 0), f(0, i - 7), u(), l(), A(h, I), o >= 7 && g(h), a == null && (a = M(o, s, y)), C(a, I);
|
|
795
|
+
}, f = function(h, I) {
|
|
796
|
+
for (let d = -1; d <= 7; d += 1)
|
|
797
|
+
if (!(h + d <= -1 || i <= h + d))
|
|
798
|
+
for (let b = -1; b <= 7; b += 1)
|
|
799
|
+
I + b <= -1 || i <= I + b || (0 <= d && d <= 6 && (b == 0 || b == 6) || 0 <= b && b <= 6 && (d == 0 || d == 6) || 2 <= d && d <= 4 && 2 <= b && b <= 4 ? c[h + d][I + b] = !0 : c[h + d][I + b] = !1);
|
|
800
|
+
}, p = function() {
|
|
801
|
+
let h = 0, I = 0;
|
|
802
|
+
for (let d = 0; d < 8; d += 1) {
|
|
803
|
+
m(!0, d);
|
|
804
|
+
const b = F.getLostPoint(T);
|
|
805
|
+
(d == 0 || h > b) && (h = b, I = d);
|
|
806
|
+
}
|
|
807
|
+
return I;
|
|
808
|
+
}, l = function() {
|
|
809
|
+
for (let h = 8; h < i - 8; h += 1)
|
|
810
|
+
c[h][6] == null && (c[h][6] = h % 2 == 0);
|
|
811
|
+
for (let h = 8; h < i - 8; h += 1)
|
|
812
|
+
c[6][h] == null && (c[6][h] = h % 2 == 0);
|
|
813
|
+
}, u = function() {
|
|
814
|
+
const h = F.getPatternPosition(o);
|
|
815
|
+
for (let I = 0; I < h.length; I += 1)
|
|
816
|
+
for (let d = 0; d < h.length; d += 1) {
|
|
817
|
+
const b = h[I], E = h[d];
|
|
818
|
+
if (c[b][E] == null)
|
|
819
|
+
for (let S = -2; S <= 2; S += 1)
|
|
820
|
+
for (let N = -2; N <= 2; N += 1)
|
|
821
|
+
S == -2 || S == 2 || N == -2 || N == 2 || S == 0 && N == 0 ? c[b + S][E + N] = !0 : c[b + S][E + N] = !1;
|
|
822
|
+
}
|
|
823
|
+
}, g = function(h) {
|
|
824
|
+
const I = F.getBCHTypeNumber(o);
|
|
825
|
+
for (let d = 0; d < 18; d += 1) {
|
|
826
|
+
const b = !h && (I >> d & 1) == 1;
|
|
827
|
+
c[Math.floor(d / 3)][d % 3 + i - 8 - 3] = b;
|
|
828
|
+
}
|
|
829
|
+
for (let d = 0; d < 18; d += 1) {
|
|
830
|
+
const b = !h && (I >> d & 1) == 1;
|
|
831
|
+
c[d % 3 + i - 8 - 3][Math.floor(d / 3)] = b;
|
|
832
|
+
}
|
|
833
|
+
}, A = function(h, I) {
|
|
834
|
+
const d = s << 3 | I, b = F.getBCHTypeInfo(d);
|
|
835
|
+
for (let E = 0; E < 15; E += 1) {
|
|
836
|
+
const S = !h && (b >> E & 1) == 1;
|
|
837
|
+
E < 6 ? c[E][8] = S : E < 8 ? c[E + 1][8] = S : c[i - 15 + E][8] = S;
|
|
838
|
+
}
|
|
839
|
+
for (let E = 0; E < 15; E += 1) {
|
|
840
|
+
const S = !h && (b >> E & 1) == 1;
|
|
841
|
+
E < 8 ? c[8][i - E - 1] = S : E < 9 ? c[8][15 - E - 1 + 1] = S : c[8][15 - E - 1] = S;
|
|
842
|
+
}
|
|
843
|
+
c[i - 8][8] = !h;
|
|
844
|
+
}, C = function(h, I) {
|
|
845
|
+
let d = -1, b = i - 1, E = 7, S = 0;
|
|
846
|
+
const N = F.getMaskFunction(I);
|
|
847
|
+
for (let L = i - 1; L > 0; L -= 2)
|
|
848
|
+
for (L == 6 && (L -= 1); ; ) {
|
|
849
|
+
for (let _ = 0; _ < 2; _ += 1)
|
|
850
|
+
if (c[b][L - _] == null) {
|
|
851
|
+
let k = !1;
|
|
852
|
+
S < h.length && (k = (h[S] >>> E & 1) == 1), N(b, L - _) && (k = !k), c[b][L - _] = k, E -= 1, E == -1 && (S += 1, E = 7);
|
|
853
|
+
}
|
|
854
|
+
if (b += d, b < 0 || i <= b) {
|
|
855
|
+
b -= d, d = -d;
|
|
856
|
+
break;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}, x = function(h, I) {
|
|
860
|
+
let d = 0, b = 0, E = 0;
|
|
861
|
+
const S = new Array(I.length), N = new Array(I.length);
|
|
862
|
+
for (let $ = 0; $ < I.length; $ += 1) {
|
|
863
|
+
const D = I[$].dataCount, H = I[$].totalCount - D;
|
|
864
|
+
b = Math.max(b, D), E = Math.max(E, H), S[$] = new Array(D);
|
|
865
|
+
for (let G = 0; G < S[$].length; G += 1)
|
|
866
|
+
S[$][G] = 255 & h.getBuffer()[G + d];
|
|
867
|
+
d += D;
|
|
868
|
+
const ft = F.getErrorCorrectPolynomial(H), bt = q(S[$], ft.getLength() - 1).mod(ft);
|
|
869
|
+
N[$] = new Array(ft.getLength() - 1);
|
|
870
|
+
for (let G = 0; G < N[$].length; G += 1) {
|
|
871
|
+
const Et = G + bt.getLength() - N[$].length;
|
|
872
|
+
N[$][G] = Et >= 0 ? bt.getAt(Et) : 0;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
let L = 0;
|
|
876
|
+
for (let $ = 0; $ < I.length; $ += 1)
|
|
877
|
+
L += I[$].totalCount;
|
|
878
|
+
const _ = new Array(L);
|
|
879
|
+
let k = 0;
|
|
880
|
+
for (let $ = 0; $ < b; $ += 1)
|
|
881
|
+
for (let D = 0; D < I.length; D += 1)
|
|
882
|
+
$ < S[D].length && (_[k] = S[D][$], k += 1);
|
|
883
|
+
for (let $ = 0; $ < E; $ += 1)
|
|
884
|
+
for (let D = 0; D < I.length; D += 1)
|
|
885
|
+
$ < N[D].length && (_[k] = N[D][$], k += 1);
|
|
886
|
+
return _;
|
|
887
|
+
}, M = function(h, I, d) {
|
|
888
|
+
const b = Nt.getRSBlocks(h, I), E = Mt();
|
|
889
|
+
for (let N = 0; N < d.length; N += 1) {
|
|
890
|
+
const L = d[N];
|
|
891
|
+
E.put(L.getMode(), 4), E.put(L.getLength(), F.getLengthInBits(L.getMode(), h)), L.write(E);
|
|
892
|
+
}
|
|
893
|
+
let S = 0;
|
|
894
|
+
for (let N = 0; N < b.length; N += 1)
|
|
895
|
+
S += b[N].dataCount;
|
|
896
|
+
if (E.getLengthInBits() > S * 8)
|
|
897
|
+
throw "code length overflow. (" + E.getLengthInBits() + ">" + S * 8 + ")";
|
|
898
|
+
for (E.getLengthInBits() + 4 <= S * 8 && E.put(0, 4); E.getLengthInBits() % 8 != 0; )
|
|
899
|
+
E.putBit(!1);
|
|
900
|
+
for (; !(E.getLengthInBits() >= S * 8 || (E.put(236, 8), E.getLengthInBits() >= S * 8)); )
|
|
901
|
+
E.put(17, 8);
|
|
902
|
+
return x(E, b);
|
|
903
|
+
};
|
|
904
|
+
T.addData = function(h, I) {
|
|
905
|
+
I = I || "Byte";
|
|
906
|
+
let d = null;
|
|
907
|
+
switch (I) {
|
|
908
|
+
case "Numeric":
|
|
909
|
+
d = Se(h);
|
|
910
|
+
break;
|
|
911
|
+
case "Alphanumeric":
|
|
912
|
+
d = Ae(h);
|
|
913
|
+
break;
|
|
914
|
+
case "Byte":
|
|
915
|
+
d = Oe(h);
|
|
916
|
+
break;
|
|
917
|
+
case "Kanji":
|
|
918
|
+
d = Ne(h);
|
|
919
|
+
break;
|
|
920
|
+
default:
|
|
921
|
+
throw "mode:" + I;
|
|
922
|
+
}
|
|
923
|
+
y.push(d), a = null;
|
|
924
|
+
}, T.isDark = function(h, I) {
|
|
925
|
+
if (h < 0 || i <= h || I < 0 || i <= I)
|
|
926
|
+
throw h + "," + I;
|
|
927
|
+
return c[h][I];
|
|
928
|
+
}, T.getModuleCount = function() {
|
|
929
|
+
return i;
|
|
930
|
+
}, T.make = function() {
|
|
931
|
+
if (o < 1) {
|
|
932
|
+
let h = 1;
|
|
933
|
+
for (; h < 40; h++) {
|
|
934
|
+
const I = Nt.getRSBlocks(h, s), d = Mt();
|
|
935
|
+
for (let E = 0; E < y.length; E++) {
|
|
936
|
+
const S = y[E];
|
|
937
|
+
d.put(S.getMode(), 4), d.put(S.getLength(), F.getLengthInBits(S.getMode(), h)), S.write(d);
|
|
938
|
+
}
|
|
939
|
+
let b = 0;
|
|
940
|
+
for (let E = 0; E < I.length; E++)
|
|
941
|
+
b += I[E].dataCount;
|
|
942
|
+
if (d.getLengthInBits() <= b * 8)
|
|
943
|
+
break;
|
|
944
|
+
}
|
|
945
|
+
o = h;
|
|
946
|
+
}
|
|
947
|
+
m(!1, p());
|
|
948
|
+
}, T.createTableTag = function(h, I) {
|
|
949
|
+
h = h || 2, I = typeof I > "u" ? h * 4 : I;
|
|
950
|
+
let d = "";
|
|
951
|
+
d += '<table style="', d += " border-width: 0px; border-style: none;", d += " border-collapse: collapse;", d += " padding: 0px; margin: " + I + "px;", d += '">', d += "<tbody>";
|
|
952
|
+
for (let b = 0; b < T.getModuleCount(); b += 1) {
|
|
953
|
+
d += "<tr>";
|
|
954
|
+
for (let E = 0; E < T.getModuleCount(); E += 1)
|
|
955
|
+
d += '<td style="', d += " border-width: 0px; border-style: none;", d += " border-collapse: collapse;", d += " padding: 0px; margin: 0px;", d += " width: " + h + "px;", d += " height: " + h + "px;", d += " background-color: ", d += T.isDark(b, E) ? "#000000" : "#ffffff", d += ";", d += '"/>';
|
|
956
|
+
d += "</tr>";
|
|
957
|
+
}
|
|
958
|
+
return d += "</tbody>", d += "</table>", d;
|
|
959
|
+
}, T.createSvgTag = function(h, I, d, b) {
|
|
960
|
+
let E = {};
|
|
961
|
+
typeof arguments[0] == "object" && (E = arguments[0], h = E.cellSize, I = E.margin, d = E.alt, b = E.title), h = h || 2, I = typeof I > "u" ? h * 4 : I, d = typeof d == "string" ? { text: d } : d || {}, d.text = d.text || null, d.id = d.text ? d.id || "qrcode-description" : null, b = typeof b == "string" ? { text: b } : b || {}, b.text = b.text || null, b.id = b.text ? b.id || "qrcode-title" : null;
|
|
962
|
+
const S = T.getModuleCount() * h + I * 2;
|
|
963
|
+
let N, L, _, k, $ = "", D;
|
|
964
|
+
for (D = "l" + h + ",0 0," + h + " -" + h + ",0 0,-" + h + "z ", $ += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"', $ += E.scalable ? "" : ' width="' + S + 'px" height="' + S + 'px"', $ += ' viewBox="0 0 ' + S + " " + S + '" ', $ += ' preserveAspectRatio="xMinYMin meet"', $ += b.text || d.text ? ' role="img" aria-labelledby="' + w([b.id, d.id].join(" ").trim()) + '"' : "", $ += ">", $ += b.text ? '<title id="' + w(b.id) + '">' + w(b.text) + "</title>" : "", $ += d.text ? '<description id="' + w(d.id) + '">' + w(d.text) + "</description>" : "", $ += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>', $ += '<path d="', _ = 0; _ < T.getModuleCount(); _ += 1)
|
|
965
|
+
for (k = _ * h + I, N = 0; N < T.getModuleCount(); N += 1)
|
|
966
|
+
T.isDark(_, N) && (L = N * h + I, $ += "M" + L + "," + k + D);
|
|
967
|
+
return $ += '" stroke="transparent" fill="black"/>', $ += "</svg>", $;
|
|
968
|
+
}, T.createDataURL = function(h, I) {
|
|
969
|
+
h = h || 2, I = typeof I > "u" ? h * 4 : I;
|
|
970
|
+
const d = T.getModuleCount() * h + I * 2, b = I, E = d - I;
|
|
971
|
+
return Le(d, d, function(S, N) {
|
|
972
|
+
if (b <= S && S < E && b <= N && N < E) {
|
|
973
|
+
const L = Math.floor((S - b) / h), _ = Math.floor((N - b) / h);
|
|
974
|
+
return T.isDark(_, L) ? 0 : 1;
|
|
975
|
+
} else
|
|
976
|
+
return 1;
|
|
977
|
+
});
|
|
978
|
+
}, T.createImgTag = function(h, I, d) {
|
|
979
|
+
h = h || 2, I = typeof I > "u" ? h * 4 : I;
|
|
980
|
+
const b = T.getModuleCount() * h + I * 2;
|
|
981
|
+
let E = "";
|
|
982
|
+
return E += "<img", E += ' src="', E += T.createDataURL(h, I), E += '"', E += ' width="', E += b, E += '"', E += ' height="', E += b, E += '"', d && (E += ' alt="', E += w(d), E += '"'), E += "/>", E;
|
|
983
|
+
};
|
|
984
|
+
const w = function(h) {
|
|
985
|
+
let I = "";
|
|
986
|
+
for (let d = 0; d < h.length; d += 1) {
|
|
987
|
+
const b = h.charAt(d);
|
|
988
|
+
switch (b) {
|
|
989
|
+
case "<":
|
|
990
|
+
I += "<";
|
|
991
|
+
break;
|
|
992
|
+
case ">":
|
|
993
|
+
I += ">";
|
|
994
|
+
break;
|
|
995
|
+
case "&":
|
|
996
|
+
I += "&";
|
|
997
|
+
break;
|
|
998
|
+
case '"':
|
|
999
|
+
I += """;
|
|
1000
|
+
break;
|
|
1001
|
+
default:
|
|
1002
|
+
I += b;
|
|
1003
|
+
break;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
return I;
|
|
1007
|
+
}, O = function(h) {
|
|
1008
|
+
h = typeof h > "u" ? 2 : h;
|
|
1009
|
+
const d = T.getModuleCount() * 1 + h * 2, b = h, E = d - h;
|
|
1010
|
+
let S, N, L, _, k;
|
|
1011
|
+
const $ = {
|
|
1012
|
+
"██": "█",
|
|
1013
|
+
"█ ": "▀",
|
|
1014
|
+
" █": "▄",
|
|
1015
|
+
" ": " "
|
|
1016
|
+
}, D = {
|
|
1017
|
+
"██": "▀",
|
|
1018
|
+
"█ ": "▀",
|
|
1019
|
+
" █": " ",
|
|
1020
|
+
" ": " "
|
|
1021
|
+
};
|
|
1022
|
+
let H = "";
|
|
1023
|
+
for (S = 0; S < d; S += 2) {
|
|
1024
|
+
for (L = Math.floor((S - b) / 1), _ = Math.floor((S + 1 - b) / 1), N = 0; N < d; N += 1)
|
|
1025
|
+
k = "█", b <= N && N < E && b <= S && S < E && T.isDark(L, Math.floor((N - b) / 1)) && (k = " "), b <= N && N < E && b <= S + 1 && S + 1 < E && T.isDark(_, Math.floor((N - b) / 1)) ? k += " " : k += "█", H += h < 1 && S + 1 >= E ? D[k] : $[k];
|
|
1026
|
+
H += `
|
|
1027
|
+
`;
|
|
1028
|
+
}
|
|
1029
|
+
return d % 2 && h > 0 ? H.substring(0, H.length - d - 1) + Array(d + 1).join("▀") : H.substring(0, H.length - 1);
|
|
1030
|
+
};
|
|
1031
|
+
return T.createASCII = function(h, I) {
|
|
1032
|
+
if (h = h || 1, h < 2)
|
|
1033
|
+
return O(I);
|
|
1034
|
+
h -= 1, I = typeof I > "u" ? h * 2 : I;
|
|
1035
|
+
const d = T.getModuleCount() * h + I * 2, b = I, E = d - I;
|
|
1036
|
+
let S, N, L, _;
|
|
1037
|
+
const k = Array(h + 1).join("██"), $ = Array(h + 1).join(" ");
|
|
1038
|
+
let D = "", H = "";
|
|
1039
|
+
for (S = 0; S < d; S += 1) {
|
|
1040
|
+
for (L = Math.floor((S - b) / h), H = "", N = 0; N < d; N += 1)
|
|
1041
|
+
_ = 1, b <= N && N < E && b <= S && S < E && T.isDark(L, Math.floor((N - b) / h)) && (_ = 0), H += _ ? k : $;
|
|
1042
|
+
for (L = 0; L < h; L += 1)
|
|
1043
|
+
D += H + `
|
|
1044
|
+
`;
|
|
1045
|
+
}
|
|
1046
|
+
return D.substring(0, D.length - 1);
|
|
1047
|
+
}, T.renderTo2dContext = function(h, I) {
|
|
1048
|
+
I = I || 2;
|
|
1049
|
+
const d = T.getModuleCount();
|
|
1050
|
+
for (let b = 0; b < d; b++)
|
|
1051
|
+
for (let E = 0; E < d; E++)
|
|
1052
|
+
h.fillStyle = T.isDark(b, E) ? "black" : "white", h.fillRect(E * I, b * I, I, I);
|
|
1053
|
+
}, T;
|
|
1054
|
+
};
|
|
1055
|
+
V.stringToBytes = function(t) {
|
|
1056
|
+
const e = [];
|
|
1057
|
+
for (let r = 0; r < t.length; r += 1) {
|
|
1058
|
+
const n = t.charCodeAt(r);
|
|
1059
|
+
e.push(n & 255);
|
|
1060
|
+
}
|
|
1061
|
+
return e;
|
|
1062
|
+
};
|
|
1063
|
+
V.createStringToBytes = function(t, e) {
|
|
1064
|
+
const r = (function() {
|
|
1065
|
+
const o = xe(t), s = function() {
|
|
1066
|
+
const a = o.read();
|
|
1067
|
+
if (a == -1) throw "eof";
|
|
1068
|
+
return a;
|
|
1069
|
+
};
|
|
1070
|
+
let c = 0;
|
|
1071
|
+
const i = {};
|
|
1072
|
+
for (; ; ) {
|
|
1073
|
+
const a = o.read();
|
|
1074
|
+
if (a == -1) break;
|
|
1075
|
+
const y = s(), T = s(), m = s(), f = String.fromCharCode(a << 8 | y), p = T << 8 | m;
|
|
1076
|
+
i[f] = p, c += 1;
|
|
1077
|
+
}
|
|
1078
|
+
if (c != e)
|
|
1079
|
+
throw c + " != " + e;
|
|
1080
|
+
return i;
|
|
1081
|
+
})(), n = 63;
|
|
1082
|
+
return function(o) {
|
|
1083
|
+
const s = [];
|
|
1084
|
+
for (let c = 0; c < o.length; c += 1) {
|
|
1085
|
+
const i = o.charCodeAt(c);
|
|
1086
|
+
if (i < 128)
|
|
1087
|
+
s.push(i);
|
|
1088
|
+
else {
|
|
1089
|
+
const a = r[o.charAt(c)];
|
|
1090
|
+
typeof a == "number" ? (a & 255) == a ? s.push(a) : (s.push(a >>> 8), s.push(a & 255)) : s.push(n);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
return s;
|
|
1094
|
+
};
|
|
1095
|
+
};
|
|
1096
|
+
const P = {
|
|
1097
|
+
MODE_NUMBER: 1,
|
|
1098
|
+
MODE_ALPHA_NUM: 2,
|
|
1099
|
+
MODE_8BIT_BYTE: 4,
|
|
1100
|
+
MODE_KANJI: 8
|
|
1101
|
+
}, X = {
|
|
1102
|
+
L: 1,
|
|
1103
|
+
M: 0,
|
|
1104
|
+
Q: 3,
|
|
1105
|
+
H: 2
|
|
1106
|
+
}, U = {
|
|
1107
|
+
PATTERN000: 0,
|
|
1108
|
+
PATTERN001: 1,
|
|
1109
|
+
PATTERN010: 2,
|
|
1110
|
+
PATTERN011: 3,
|
|
1111
|
+
PATTERN100: 4,
|
|
1112
|
+
PATTERN101: 5,
|
|
1113
|
+
PATTERN110: 6,
|
|
1114
|
+
PATTERN111: 7
|
|
1115
|
+
}, F = (function() {
|
|
1116
|
+
const t = [
|
|
1117
|
+
[],
|
|
1118
|
+
[6, 18],
|
|
1119
|
+
[6, 22],
|
|
1120
|
+
[6, 26],
|
|
1121
|
+
[6, 30],
|
|
1122
|
+
[6, 34],
|
|
1123
|
+
[6, 22, 38],
|
|
1124
|
+
[6, 24, 42],
|
|
1125
|
+
[6, 26, 46],
|
|
1126
|
+
[6, 28, 50],
|
|
1127
|
+
[6, 30, 54],
|
|
1128
|
+
[6, 32, 58],
|
|
1129
|
+
[6, 34, 62],
|
|
1130
|
+
[6, 26, 46, 66],
|
|
1131
|
+
[6, 26, 48, 70],
|
|
1132
|
+
[6, 26, 50, 74],
|
|
1133
|
+
[6, 30, 54, 78],
|
|
1134
|
+
[6, 30, 56, 82],
|
|
1135
|
+
[6, 30, 58, 86],
|
|
1136
|
+
[6, 34, 62, 90],
|
|
1137
|
+
[6, 28, 50, 72, 94],
|
|
1138
|
+
[6, 26, 50, 74, 98],
|
|
1139
|
+
[6, 30, 54, 78, 102],
|
|
1140
|
+
[6, 28, 54, 80, 106],
|
|
1141
|
+
[6, 32, 58, 84, 110],
|
|
1142
|
+
[6, 30, 58, 86, 114],
|
|
1143
|
+
[6, 34, 62, 90, 118],
|
|
1144
|
+
[6, 26, 50, 74, 98, 122],
|
|
1145
|
+
[6, 30, 54, 78, 102, 126],
|
|
1146
|
+
[6, 26, 52, 78, 104, 130],
|
|
1147
|
+
[6, 30, 56, 82, 108, 134],
|
|
1148
|
+
[6, 34, 60, 86, 112, 138],
|
|
1149
|
+
[6, 30, 58, 86, 114, 142],
|
|
1150
|
+
[6, 34, 62, 90, 118, 146],
|
|
1151
|
+
[6, 30, 54, 78, 102, 126, 150],
|
|
1152
|
+
[6, 24, 50, 76, 102, 128, 154],
|
|
1153
|
+
[6, 28, 54, 80, 106, 132, 158],
|
|
1154
|
+
[6, 32, 58, 84, 110, 136, 162],
|
|
1155
|
+
[6, 26, 54, 82, 110, 138, 166],
|
|
1156
|
+
[6, 30, 58, 86, 114, 142, 170]
|
|
1157
|
+
], e = 1335, r = 7973, n = 21522, o = {}, s = function(c) {
|
|
1158
|
+
let i = 0;
|
|
1159
|
+
for (; c != 0; )
|
|
1160
|
+
i += 1, c >>>= 1;
|
|
1161
|
+
return i;
|
|
1162
|
+
};
|
|
1163
|
+
return o.getBCHTypeInfo = function(c) {
|
|
1164
|
+
let i = c << 10;
|
|
1165
|
+
for (; s(i) - s(e) >= 0; )
|
|
1166
|
+
i ^= e << s(i) - s(e);
|
|
1167
|
+
return (c << 10 | i) ^ n;
|
|
1168
|
+
}, o.getBCHTypeNumber = function(c) {
|
|
1169
|
+
let i = c << 12;
|
|
1170
|
+
for (; s(i) - s(r) >= 0; )
|
|
1171
|
+
i ^= r << s(i) - s(r);
|
|
1172
|
+
return c << 12 | i;
|
|
1173
|
+
}, o.getPatternPosition = function(c) {
|
|
1174
|
+
return t[c - 1];
|
|
1175
|
+
}, o.getMaskFunction = function(c) {
|
|
1176
|
+
switch (c) {
|
|
1177
|
+
case U.PATTERN000:
|
|
1178
|
+
return function(i, a) {
|
|
1179
|
+
return (i + a) % 2 == 0;
|
|
1180
|
+
};
|
|
1181
|
+
case U.PATTERN001:
|
|
1182
|
+
return function(i, a) {
|
|
1183
|
+
return i % 2 == 0;
|
|
1184
|
+
};
|
|
1185
|
+
case U.PATTERN010:
|
|
1186
|
+
return function(i, a) {
|
|
1187
|
+
return a % 3 == 0;
|
|
1188
|
+
};
|
|
1189
|
+
case U.PATTERN011:
|
|
1190
|
+
return function(i, a) {
|
|
1191
|
+
return (i + a) % 3 == 0;
|
|
1192
|
+
};
|
|
1193
|
+
case U.PATTERN100:
|
|
1194
|
+
return function(i, a) {
|
|
1195
|
+
return (Math.floor(i / 2) + Math.floor(a / 3)) % 2 == 0;
|
|
1196
|
+
};
|
|
1197
|
+
case U.PATTERN101:
|
|
1198
|
+
return function(i, a) {
|
|
1199
|
+
return i * a % 2 + i * a % 3 == 0;
|
|
1200
|
+
};
|
|
1201
|
+
case U.PATTERN110:
|
|
1202
|
+
return function(i, a) {
|
|
1203
|
+
return (i * a % 2 + i * a % 3) % 2 == 0;
|
|
1204
|
+
};
|
|
1205
|
+
case U.PATTERN111:
|
|
1206
|
+
return function(i, a) {
|
|
1207
|
+
return (i * a % 3 + (i + a) % 2) % 2 == 0;
|
|
1208
|
+
};
|
|
1209
|
+
default:
|
|
1210
|
+
throw "bad maskPattern:" + c;
|
|
1211
|
+
}
|
|
1212
|
+
}, o.getErrorCorrectPolynomial = function(c) {
|
|
1213
|
+
let i = q([1], 0);
|
|
1214
|
+
for (let a = 0; a < c; a += 1)
|
|
1215
|
+
i = i.multiply(q([1, K.gexp(a)], 0));
|
|
1216
|
+
return i;
|
|
1217
|
+
}, o.getLengthInBits = function(c, i) {
|
|
1218
|
+
if (1 <= i && i < 10)
|
|
1219
|
+
switch (c) {
|
|
1220
|
+
case P.MODE_NUMBER:
|
|
1221
|
+
return 10;
|
|
1222
|
+
case P.MODE_ALPHA_NUM:
|
|
1223
|
+
return 9;
|
|
1224
|
+
case P.MODE_8BIT_BYTE:
|
|
1225
|
+
return 8;
|
|
1226
|
+
case P.MODE_KANJI:
|
|
1227
|
+
return 8;
|
|
1228
|
+
default:
|
|
1229
|
+
throw "mode:" + c;
|
|
1230
|
+
}
|
|
1231
|
+
else if (i < 27)
|
|
1232
|
+
switch (c) {
|
|
1233
|
+
case P.MODE_NUMBER:
|
|
1234
|
+
return 12;
|
|
1235
|
+
case P.MODE_ALPHA_NUM:
|
|
1236
|
+
return 11;
|
|
1237
|
+
case P.MODE_8BIT_BYTE:
|
|
1238
|
+
return 16;
|
|
1239
|
+
case P.MODE_KANJI:
|
|
1240
|
+
return 10;
|
|
1241
|
+
default:
|
|
1242
|
+
throw "mode:" + c;
|
|
1243
|
+
}
|
|
1244
|
+
else if (i < 41)
|
|
1245
|
+
switch (c) {
|
|
1246
|
+
case P.MODE_NUMBER:
|
|
1247
|
+
return 14;
|
|
1248
|
+
case P.MODE_ALPHA_NUM:
|
|
1249
|
+
return 13;
|
|
1250
|
+
case P.MODE_8BIT_BYTE:
|
|
1251
|
+
return 16;
|
|
1252
|
+
case P.MODE_KANJI:
|
|
1253
|
+
return 12;
|
|
1254
|
+
default:
|
|
1255
|
+
throw "mode:" + c;
|
|
1256
|
+
}
|
|
1257
|
+
else
|
|
1258
|
+
throw "type:" + i;
|
|
1259
|
+
}, o.getLostPoint = function(c) {
|
|
1260
|
+
const i = c.getModuleCount();
|
|
1261
|
+
let a = 0;
|
|
1262
|
+
for (let m = 0; m < i; m += 1)
|
|
1263
|
+
for (let f = 0; f < i; f += 1) {
|
|
1264
|
+
let p = 0;
|
|
1265
|
+
const l = c.isDark(m, f);
|
|
1266
|
+
for (let u = -1; u <= 1; u += 1)
|
|
1267
|
+
if (!(m + u < 0 || i <= m + u))
|
|
1268
|
+
for (let g = -1; g <= 1; g += 1)
|
|
1269
|
+
f + g < 0 || i <= f + g || u == 0 && g == 0 || l == c.isDark(m + u, f + g) && (p += 1);
|
|
1270
|
+
p > 5 && (a += 3 + p - 5);
|
|
1271
|
+
}
|
|
1272
|
+
for (let m = 0; m < i - 1; m += 1)
|
|
1273
|
+
for (let f = 0; f < i - 1; f += 1) {
|
|
1274
|
+
let p = 0;
|
|
1275
|
+
c.isDark(m, f) && (p += 1), c.isDark(m + 1, f) && (p += 1), c.isDark(m, f + 1) && (p += 1), c.isDark(m + 1, f + 1) && (p += 1), (p == 0 || p == 4) && (a += 3);
|
|
1276
|
+
}
|
|
1277
|
+
for (let m = 0; m < i; m += 1)
|
|
1278
|
+
for (let f = 0; f < i - 6; f += 1)
|
|
1279
|
+
c.isDark(m, f) && !c.isDark(m, f + 1) && c.isDark(m, f + 2) && c.isDark(m, f + 3) && c.isDark(m, f + 4) && !c.isDark(m, f + 5) && c.isDark(m, f + 6) && (a += 40);
|
|
1280
|
+
for (let m = 0; m < i; m += 1)
|
|
1281
|
+
for (let f = 0; f < i - 6; f += 1)
|
|
1282
|
+
c.isDark(f, m) && !c.isDark(f + 1, m) && c.isDark(f + 2, m) && c.isDark(f + 3, m) && c.isDark(f + 4, m) && !c.isDark(f + 5, m) && c.isDark(f + 6, m) && (a += 40);
|
|
1283
|
+
let y = 0;
|
|
1284
|
+
for (let m = 0; m < i; m += 1)
|
|
1285
|
+
for (let f = 0; f < i; f += 1)
|
|
1286
|
+
c.isDark(f, m) && (y += 1);
|
|
1287
|
+
const T = Math.abs(100 * y / i / i - 50) / 5;
|
|
1288
|
+
return a += T * 10, a;
|
|
1289
|
+
}, o;
|
|
1290
|
+
})(), K = (function() {
|
|
1291
|
+
const t = new Array(256), e = new Array(256);
|
|
1292
|
+
for (let n = 0; n < 8; n += 1)
|
|
1293
|
+
t[n] = 1 << n;
|
|
1294
|
+
for (let n = 8; n < 256; n += 1)
|
|
1295
|
+
t[n] = t[n - 4] ^ t[n - 5] ^ t[n - 6] ^ t[n - 8];
|
|
1296
|
+
for (let n = 0; n < 255; n += 1)
|
|
1297
|
+
e[t[n]] = n;
|
|
1298
|
+
const r = {};
|
|
1299
|
+
return r.glog = function(n) {
|
|
1300
|
+
if (n < 1)
|
|
1301
|
+
throw "glog(" + n + ")";
|
|
1302
|
+
return e[n];
|
|
1303
|
+
}, r.gexp = function(n) {
|
|
1304
|
+
for (; n < 0; )
|
|
1305
|
+
n += 255;
|
|
1306
|
+
for (; n >= 256; )
|
|
1307
|
+
n -= 255;
|
|
1308
|
+
return t[n];
|
|
1309
|
+
}, r;
|
|
1310
|
+
})(), q = function(t, e) {
|
|
1311
|
+
if (typeof t.length > "u")
|
|
1312
|
+
throw t.length + "/" + e;
|
|
1313
|
+
const r = (function() {
|
|
1314
|
+
let o = 0;
|
|
1315
|
+
for (; o < t.length && t[o] == 0; )
|
|
1316
|
+
o += 1;
|
|
1317
|
+
const s = new Array(t.length - o + e);
|
|
1318
|
+
for (let c = 0; c < t.length - o; c += 1)
|
|
1319
|
+
s[c] = t[c + o];
|
|
1320
|
+
return s;
|
|
1321
|
+
})(), n = {};
|
|
1322
|
+
return n.getAt = function(o) {
|
|
1323
|
+
return r[o];
|
|
1324
|
+
}, n.getLength = function() {
|
|
1325
|
+
return r.length;
|
|
1326
|
+
}, n.multiply = function(o) {
|
|
1327
|
+
const s = new Array(n.getLength() + o.getLength() - 1);
|
|
1328
|
+
for (let c = 0; c < n.getLength(); c += 1)
|
|
1329
|
+
for (let i = 0; i < o.getLength(); i += 1)
|
|
1330
|
+
s[c + i] ^= K.gexp(K.glog(n.getAt(c)) + K.glog(o.getAt(i)));
|
|
1331
|
+
return q(s, 0);
|
|
1332
|
+
}, n.mod = function(o) {
|
|
1333
|
+
if (n.getLength() - o.getLength() < 0)
|
|
1334
|
+
return n;
|
|
1335
|
+
const s = K.glog(n.getAt(0)) - K.glog(o.getAt(0)), c = new Array(n.getLength());
|
|
1336
|
+
for (let i = 0; i < n.getLength(); i += 1)
|
|
1337
|
+
c[i] = n.getAt(i);
|
|
1338
|
+
for (let i = 0; i < o.getLength(); i += 1)
|
|
1339
|
+
c[i] ^= K.gexp(K.glog(o.getAt(i)) + s);
|
|
1340
|
+
return q(c, 0).mod(o);
|
|
1341
|
+
}, n;
|
|
1342
|
+
}, Nt = (function() {
|
|
1343
|
+
const t = [
|
|
1344
|
+
// L
|
|
1345
|
+
// M
|
|
1346
|
+
// Q
|
|
1347
|
+
// H
|
|
1348
|
+
// 1
|
|
1349
|
+
[1, 26, 19],
|
|
1350
|
+
[1, 26, 16],
|
|
1351
|
+
[1, 26, 13],
|
|
1352
|
+
[1, 26, 9],
|
|
1353
|
+
// 2
|
|
1354
|
+
[1, 44, 34],
|
|
1355
|
+
[1, 44, 28],
|
|
1356
|
+
[1, 44, 22],
|
|
1357
|
+
[1, 44, 16],
|
|
1358
|
+
// 3
|
|
1359
|
+
[1, 70, 55],
|
|
1360
|
+
[1, 70, 44],
|
|
1361
|
+
[2, 35, 17],
|
|
1362
|
+
[2, 35, 13],
|
|
1363
|
+
// 4
|
|
1364
|
+
[1, 100, 80],
|
|
1365
|
+
[2, 50, 32],
|
|
1366
|
+
[2, 50, 24],
|
|
1367
|
+
[4, 25, 9],
|
|
1368
|
+
// 5
|
|
1369
|
+
[1, 134, 108],
|
|
1370
|
+
[2, 67, 43],
|
|
1371
|
+
[2, 33, 15, 2, 34, 16],
|
|
1372
|
+
[2, 33, 11, 2, 34, 12],
|
|
1373
|
+
// 6
|
|
1374
|
+
[2, 86, 68],
|
|
1375
|
+
[4, 43, 27],
|
|
1376
|
+
[4, 43, 19],
|
|
1377
|
+
[4, 43, 15],
|
|
1378
|
+
// 7
|
|
1379
|
+
[2, 98, 78],
|
|
1380
|
+
[4, 49, 31],
|
|
1381
|
+
[2, 32, 14, 4, 33, 15],
|
|
1382
|
+
[4, 39, 13, 1, 40, 14],
|
|
1383
|
+
// 8
|
|
1384
|
+
[2, 121, 97],
|
|
1385
|
+
[2, 60, 38, 2, 61, 39],
|
|
1386
|
+
[4, 40, 18, 2, 41, 19],
|
|
1387
|
+
[4, 40, 14, 2, 41, 15],
|
|
1388
|
+
// 9
|
|
1389
|
+
[2, 146, 116],
|
|
1390
|
+
[3, 58, 36, 2, 59, 37],
|
|
1391
|
+
[4, 36, 16, 4, 37, 17],
|
|
1392
|
+
[4, 36, 12, 4, 37, 13],
|
|
1393
|
+
// 10
|
|
1394
|
+
[2, 86, 68, 2, 87, 69],
|
|
1395
|
+
[4, 69, 43, 1, 70, 44],
|
|
1396
|
+
[6, 43, 19, 2, 44, 20],
|
|
1397
|
+
[6, 43, 15, 2, 44, 16],
|
|
1398
|
+
// 11
|
|
1399
|
+
[4, 101, 81],
|
|
1400
|
+
[1, 80, 50, 4, 81, 51],
|
|
1401
|
+
[4, 50, 22, 4, 51, 23],
|
|
1402
|
+
[3, 36, 12, 8, 37, 13],
|
|
1403
|
+
// 12
|
|
1404
|
+
[2, 116, 92, 2, 117, 93],
|
|
1405
|
+
[6, 58, 36, 2, 59, 37],
|
|
1406
|
+
[4, 46, 20, 6, 47, 21],
|
|
1407
|
+
[7, 42, 14, 4, 43, 15],
|
|
1408
|
+
// 13
|
|
1409
|
+
[4, 133, 107],
|
|
1410
|
+
[8, 59, 37, 1, 60, 38],
|
|
1411
|
+
[8, 44, 20, 4, 45, 21],
|
|
1412
|
+
[12, 33, 11, 4, 34, 12],
|
|
1413
|
+
// 14
|
|
1414
|
+
[3, 145, 115, 1, 146, 116],
|
|
1415
|
+
[4, 64, 40, 5, 65, 41],
|
|
1416
|
+
[11, 36, 16, 5, 37, 17],
|
|
1417
|
+
[11, 36, 12, 5, 37, 13],
|
|
1418
|
+
// 15
|
|
1419
|
+
[5, 109, 87, 1, 110, 88],
|
|
1420
|
+
[5, 65, 41, 5, 66, 42],
|
|
1421
|
+
[5, 54, 24, 7, 55, 25],
|
|
1422
|
+
[11, 36, 12, 7, 37, 13],
|
|
1423
|
+
// 16
|
|
1424
|
+
[5, 122, 98, 1, 123, 99],
|
|
1425
|
+
[7, 73, 45, 3, 74, 46],
|
|
1426
|
+
[15, 43, 19, 2, 44, 20],
|
|
1427
|
+
[3, 45, 15, 13, 46, 16],
|
|
1428
|
+
// 17
|
|
1429
|
+
[1, 135, 107, 5, 136, 108],
|
|
1430
|
+
[10, 74, 46, 1, 75, 47],
|
|
1431
|
+
[1, 50, 22, 15, 51, 23],
|
|
1432
|
+
[2, 42, 14, 17, 43, 15],
|
|
1433
|
+
// 18
|
|
1434
|
+
[5, 150, 120, 1, 151, 121],
|
|
1435
|
+
[9, 69, 43, 4, 70, 44],
|
|
1436
|
+
[17, 50, 22, 1, 51, 23],
|
|
1437
|
+
[2, 42, 14, 19, 43, 15],
|
|
1438
|
+
// 19
|
|
1439
|
+
[3, 141, 113, 4, 142, 114],
|
|
1440
|
+
[3, 70, 44, 11, 71, 45],
|
|
1441
|
+
[17, 47, 21, 4, 48, 22],
|
|
1442
|
+
[9, 39, 13, 16, 40, 14],
|
|
1443
|
+
// 20
|
|
1444
|
+
[3, 135, 107, 5, 136, 108],
|
|
1445
|
+
[3, 67, 41, 13, 68, 42],
|
|
1446
|
+
[15, 54, 24, 5, 55, 25],
|
|
1447
|
+
[15, 43, 15, 10, 44, 16],
|
|
1448
|
+
// 21
|
|
1449
|
+
[4, 144, 116, 4, 145, 117],
|
|
1450
|
+
[17, 68, 42],
|
|
1451
|
+
[17, 50, 22, 6, 51, 23],
|
|
1452
|
+
[19, 46, 16, 6, 47, 17],
|
|
1453
|
+
// 22
|
|
1454
|
+
[2, 139, 111, 7, 140, 112],
|
|
1455
|
+
[17, 74, 46],
|
|
1456
|
+
[7, 54, 24, 16, 55, 25],
|
|
1457
|
+
[34, 37, 13],
|
|
1458
|
+
// 23
|
|
1459
|
+
[4, 151, 121, 5, 152, 122],
|
|
1460
|
+
[4, 75, 47, 14, 76, 48],
|
|
1461
|
+
[11, 54, 24, 14, 55, 25],
|
|
1462
|
+
[16, 45, 15, 14, 46, 16],
|
|
1463
|
+
// 24
|
|
1464
|
+
[6, 147, 117, 4, 148, 118],
|
|
1465
|
+
[6, 73, 45, 14, 74, 46],
|
|
1466
|
+
[11, 54, 24, 16, 55, 25],
|
|
1467
|
+
[30, 46, 16, 2, 47, 17],
|
|
1468
|
+
// 25
|
|
1469
|
+
[8, 132, 106, 4, 133, 107],
|
|
1470
|
+
[8, 75, 47, 13, 76, 48],
|
|
1471
|
+
[7, 54, 24, 22, 55, 25],
|
|
1472
|
+
[22, 45, 15, 13, 46, 16],
|
|
1473
|
+
// 26
|
|
1474
|
+
[10, 142, 114, 2, 143, 115],
|
|
1475
|
+
[19, 74, 46, 4, 75, 47],
|
|
1476
|
+
[28, 50, 22, 6, 51, 23],
|
|
1477
|
+
[33, 46, 16, 4, 47, 17],
|
|
1478
|
+
// 27
|
|
1479
|
+
[8, 152, 122, 4, 153, 123],
|
|
1480
|
+
[22, 73, 45, 3, 74, 46],
|
|
1481
|
+
[8, 53, 23, 26, 54, 24],
|
|
1482
|
+
[12, 45, 15, 28, 46, 16],
|
|
1483
|
+
// 28
|
|
1484
|
+
[3, 147, 117, 10, 148, 118],
|
|
1485
|
+
[3, 73, 45, 23, 74, 46],
|
|
1486
|
+
[4, 54, 24, 31, 55, 25],
|
|
1487
|
+
[11, 45, 15, 31, 46, 16],
|
|
1488
|
+
// 29
|
|
1489
|
+
[7, 146, 116, 7, 147, 117],
|
|
1490
|
+
[21, 73, 45, 7, 74, 46],
|
|
1491
|
+
[1, 53, 23, 37, 54, 24],
|
|
1492
|
+
[19, 45, 15, 26, 46, 16],
|
|
1493
|
+
// 30
|
|
1494
|
+
[5, 145, 115, 10, 146, 116],
|
|
1495
|
+
[19, 75, 47, 10, 76, 48],
|
|
1496
|
+
[15, 54, 24, 25, 55, 25],
|
|
1497
|
+
[23, 45, 15, 25, 46, 16],
|
|
1498
|
+
// 31
|
|
1499
|
+
[13, 145, 115, 3, 146, 116],
|
|
1500
|
+
[2, 74, 46, 29, 75, 47],
|
|
1501
|
+
[42, 54, 24, 1, 55, 25],
|
|
1502
|
+
[23, 45, 15, 28, 46, 16],
|
|
1503
|
+
// 32
|
|
1504
|
+
[17, 145, 115],
|
|
1505
|
+
[10, 74, 46, 23, 75, 47],
|
|
1506
|
+
[10, 54, 24, 35, 55, 25],
|
|
1507
|
+
[19, 45, 15, 35, 46, 16],
|
|
1508
|
+
// 33
|
|
1509
|
+
[17, 145, 115, 1, 146, 116],
|
|
1510
|
+
[14, 74, 46, 21, 75, 47],
|
|
1511
|
+
[29, 54, 24, 19, 55, 25],
|
|
1512
|
+
[11, 45, 15, 46, 46, 16],
|
|
1513
|
+
// 34
|
|
1514
|
+
[13, 145, 115, 6, 146, 116],
|
|
1515
|
+
[14, 74, 46, 23, 75, 47],
|
|
1516
|
+
[44, 54, 24, 7, 55, 25],
|
|
1517
|
+
[59, 46, 16, 1, 47, 17],
|
|
1518
|
+
// 35
|
|
1519
|
+
[12, 151, 121, 7, 152, 122],
|
|
1520
|
+
[12, 75, 47, 26, 76, 48],
|
|
1521
|
+
[39, 54, 24, 14, 55, 25],
|
|
1522
|
+
[22, 45, 15, 41, 46, 16],
|
|
1523
|
+
// 36
|
|
1524
|
+
[6, 151, 121, 14, 152, 122],
|
|
1525
|
+
[6, 75, 47, 34, 76, 48],
|
|
1526
|
+
[46, 54, 24, 10, 55, 25],
|
|
1527
|
+
[2, 45, 15, 64, 46, 16],
|
|
1528
|
+
// 37
|
|
1529
|
+
[17, 152, 122, 4, 153, 123],
|
|
1530
|
+
[29, 74, 46, 14, 75, 47],
|
|
1531
|
+
[49, 54, 24, 10, 55, 25],
|
|
1532
|
+
[24, 45, 15, 46, 46, 16],
|
|
1533
|
+
// 38
|
|
1534
|
+
[4, 152, 122, 18, 153, 123],
|
|
1535
|
+
[13, 74, 46, 32, 75, 47],
|
|
1536
|
+
[48, 54, 24, 14, 55, 25],
|
|
1537
|
+
[42, 45, 15, 32, 46, 16],
|
|
1538
|
+
// 39
|
|
1539
|
+
[20, 147, 117, 4, 148, 118],
|
|
1540
|
+
[40, 75, 47, 7, 76, 48],
|
|
1541
|
+
[43, 54, 24, 22, 55, 25],
|
|
1542
|
+
[10, 45, 15, 67, 46, 16],
|
|
1543
|
+
// 40
|
|
1544
|
+
[19, 148, 118, 6, 149, 119],
|
|
1545
|
+
[18, 75, 47, 31, 76, 48],
|
|
1546
|
+
[34, 54, 24, 34, 55, 25],
|
|
1547
|
+
[20, 45, 15, 61, 46, 16]
|
|
1548
|
+
], e = function(o, s) {
|
|
1549
|
+
const c = {};
|
|
1550
|
+
return c.totalCount = o, c.dataCount = s, c;
|
|
1551
|
+
}, r = {}, n = function(o, s) {
|
|
1552
|
+
switch (s) {
|
|
1553
|
+
case X.L:
|
|
1554
|
+
return t[(o - 1) * 4 + 0];
|
|
1555
|
+
case X.M:
|
|
1556
|
+
return t[(o - 1) * 4 + 1];
|
|
1557
|
+
case X.Q:
|
|
1558
|
+
return t[(o - 1) * 4 + 2];
|
|
1559
|
+
case X.H:
|
|
1560
|
+
return t[(o - 1) * 4 + 3];
|
|
1561
|
+
default:
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1564
|
+
};
|
|
1565
|
+
return r.getRSBlocks = function(o, s) {
|
|
1566
|
+
const c = n(o, s);
|
|
1567
|
+
if (typeof c > "u")
|
|
1568
|
+
throw "bad rs block @ typeNumber:" + o + "/errorCorrectionLevel:" + s;
|
|
1569
|
+
const i = c.length / 3, a = [];
|
|
1570
|
+
for (let y = 0; y < i; y += 1) {
|
|
1571
|
+
const T = c[y * 3 + 0], m = c[y * 3 + 1], f = c[y * 3 + 2];
|
|
1572
|
+
for (let p = 0; p < T; p += 1)
|
|
1573
|
+
a.push(e(m, f));
|
|
1574
|
+
}
|
|
1575
|
+
return a;
|
|
1576
|
+
}, r;
|
|
1577
|
+
})(), Mt = function() {
|
|
1578
|
+
const t = [];
|
|
1579
|
+
let e = 0;
|
|
1580
|
+
const r = {};
|
|
1581
|
+
return r.getBuffer = function() {
|
|
1582
|
+
return t;
|
|
1583
|
+
}, r.getAt = function(n) {
|
|
1584
|
+
const o = Math.floor(n / 8);
|
|
1585
|
+
return (t[o] >>> 7 - n % 8 & 1) == 1;
|
|
1586
|
+
}, r.put = function(n, o) {
|
|
1587
|
+
for (let s = 0; s < o; s += 1)
|
|
1588
|
+
r.putBit((n >>> o - s - 1 & 1) == 1);
|
|
1589
|
+
}, r.getLengthInBits = function() {
|
|
1590
|
+
return e;
|
|
1591
|
+
}, r.putBit = function(n) {
|
|
1592
|
+
const o = Math.floor(e / 8);
|
|
1593
|
+
t.length <= o && t.push(0), n && (t[o] |= 128 >>> e % 8), e += 1;
|
|
1594
|
+
}, r;
|
|
1595
|
+
}, Se = function(t) {
|
|
1596
|
+
const e = P.MODE_NUMBER, r = t, n = {};
|
|
1597
|
+
n.getMode = function() {
|
|
1598
|
+
return e;
|
|
1599
|
+
}, n.getLength = function(c) {
|
|
1600
|
+
return r.length;
|
|
1601
|
+
}, n.write = function(c) {
|
|
1602
|
+
const i = r;
|
|
1603
|
+
let a = 0;
|
|
1604
|
+
for (; a + 2 < i.length; )
|
|
1605
|
+
c.put(o(i.substring(a, a + 3)), 10), a += 3;
|
|
1606
|
+
a < i.length && (i.length - a == 1 ? c.put(o(i.substring(a, a + 1)), 4) : i.length - a == 2 && c.put(o(i.substring(a, a + 2)), 7));
|
|
1607
|
+
};
|
|
1608
|
+
const o = function(c) {
|
|
1609
|
+
let i = 0;
|
|
1610
|
+
for (let a = 0; a < c.length; a += 1)
|
|
1611
|
+
i = i * 10 + s(c.charAt(a));
|
|
1612
|
+
return i;
|
|
1613
|
+
}, s = function(c) {
|
|
1614
|
+
if ("0" <= c && c <= "9")
|
|
1615
|
+
return c.charCodeAt(0) - 48;
|
|
1616
|
+
throw "illegal char :" + c;
|
|
1617
|
+
};
|
|
1618
|
+
return n;
|
|
1619
|
+
}, Ae = function(t) {
|
|
1620
|
+
const e = P.MODE_ALPHA_NUM, r = t, n = {};
|
|
1621
|
+
n.getMode = function() {
|
|
1622
|
+
return e;
|
|
1623
|
+
}, n.getLength = function(s) {
|
|
1624
|
+
return r.length;
|
|
1625
|
+
}, n.write = function(s) {
|
|
1626
|
+
const c = r;
|
|
1627
|
+
let i = 0;
|
|
1628
|
+
for (; i + 1 < c.length; )
|
|
1629
|
+
s.put(
|
|
1630
|
+
o(c.charAt(i)) * 45 + o(c.charAt(i + 1)),
|
|
1631
|
+
11
|
|
1632
|
+
), i += 2;
|
|
1633
|
+
i < c.length && s.put(o(c.charAt(i)), 6);
|
|
1634
|
+
};
|
|
1635
|
+
const o = function(s) {
|
|
1636
|
+
if ("0" <= s && s <= "9")
|
|
1637
|
+
return s.charCodeAt(0) - 48;
|
|
1638
|
+
if ("A" <= s && s <= "Z")
|
|
1639
|
+
return s.charCodeAt(0) - 65 + 10;
|
|
1640
|
+
switch (s) {
|
|
1641
|
+
case " ":
|
|
1642
|
+
return 36;
|
|
1643
|
+
case "$":
|
|
1644
|
+
return 37;
|
|
1645
|
+
case "%":
|
|
1646
|
+
return 38;
|
|
1647
|
+
case "*":
|
|
1648
|
+
return 39;
|
|
1649
|
+
case "+":
|
|
1650
|
+
return 40;
|
|
1651
|
+
case "-":
|
|
1652
|
+
return 41;
|
|
1653
|
+
case ".":
|
|
1654
|
+
return 42;
|
|
1655
|
+
case "/":
|
|
1656
|
+
return 43;
|
|
1657
|
+
case ":":
|
|
1658
|
+
return 44;
|
|
1659
|
+
default:
|
|
1660
|
+
throw "illegal char :" + s;
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
return n;
|
|
1664
|
+
}, Oe = function(t) {
|
|
1665
|
+
const e = P.MODE_8BIT_BYTE, r = V.stringToBytes(t), n = {};
|
|
1666
|
+
return n.getMode = function() {
|
|
1667
|
+
return e;
|
|
1668
|
+
}, n.getLength = function(o) {
|
|
1669
|
+
return r.length;
|
|
1670
|
+
}, n.write = function(o) {
|
|
1671
|
+
for (let s = 0; s < r.length; s += 1)
|
|
1672
|
+
o.put(r[s], 8);
|
|
1673
|
+
}, n;
|
|
1674
|
+
}, Ne = function(t) {
|
|
1675
|
+
const e = P.MODE_KANJI, r = V.stringToBytes;
|
|
1676
|
+
(function(s, c) {
|
|
1677
|
+
const i = r(s);
|
|
1678
|
+
if (i.length != 2 || (i[0] << 8 | i[1]) != c)
|
|
1679
|
+
throw "sjis not supported.";
|
|
1680
|
+
})("友", 38726);
|
|
1681
|
+
const n = r(t), o = {};
|
|
1682
|
+
return o.getMode = function() {
|
|
1683
|
+
return e;
|
|
1684
|
+
}, o.getLength = function(s) {
|
|
1685
|
+
return ~~(n.length / 2);
|
|
1686
|
+
}, o.write = function(s) {
|
|
1687
|
+
const c = n;
|
|
1688
|
+
let i = 0;
|
|
1689
|
+
for (; i + 1 < c.length; ) {
|
|
1690
|
+
let a = (255 & c[i]) << 8 | 255 & c[i + 1];
|
|
1691
|
+
if (33088 <= a && a <= 40956)
|
|
1692
|
+
a -= 33088;
|
|
1693
|
+
else if (57408 <= a && a <= 60351)
|
|
1694
|
+
a -= 49472;
|
|
1695
|
+
else
|
|
1696
|
+
throw "illegal char at " + (i + 1) + "/" + a;
|
|
1697
|
+
a = (a >>> 8 & 255) * 192 + (a & 255), s.put(a, 13), i += 2;
|
|
1698
|
+
}
|
|
1699
|
+
if (i < c.length)
|
|
1700
|
+
throw "illegal char at " + (i + 1);
|
|
1701
|
+
}, o;
|
|
1702
|
+
}, Gt = function() {
|
|
1703
|
+
const t = [], e = {};
|
|
1704
|
+
return e.writeByte = function(r) {
|
|
1705
|
+
t.push(r & 255);
|
|
1706
|
+
}, e.writeShort = function(r) {
|
|
1707
|
+
e.writeByte(r), e.writeByte(r >>> 8);
|
|
1708
|
+
}, e.writeBytes = function(r, n, o) {
|
|
1709
|
+
n = n || 0, o = o || r.length;
|
|
1710
|
+
for (let s = 0; s < o; s += 1)
|
|
1711
|
+
e.writeByte(r[s + n]);
|
|
1712
|
+
}, e.writeString = function(r) {
|
|
1713
|
+
for (let n = 0; n < r.length; n += 1)
|
|
1714
|
+
e.writeByte(r.charCodeAt(n));
|
|
1715
|
+
}, e.toByteArray = function() {
|
|
1716
|
+
return t;
|
|
1717
|
+
}, e.toString = function() {
|
|
1718
|
+
let r = "";
|
|
1719
|
+
r += "[";
|
|
1720
|
+
for (let n = 0; n < t.length; n += 1)
|
|
1721
|
+
n > 0 && (r += ","), r += t[n];
|
|
1722
|
+
return r += "]", r;
|
|
1723
|
+
}, e;
|
|
1724
|
+
}, Me = function() {
|
|
1725
|
+
let t = 0, e = 0, r = 0, n = "";
|
|
1726
|
+
const o = {}, s = function(i) {
|
|
1727
|
+
n += String.fromCharCode(c(i & 63));
|
|
1728
|
+
}, c = function(i) {
|
|
1729
|
+
if (i < 0)
|
|
1730
|
+
throw "n:" + i;
|
|
1731
|
+
if (i < 26)
|
|
1732
|
+
return 65 + i;
|
|
1733
|
+
if (i < 52)
|
|
1734
|
+
return 97 + (i - 26);
|
|
1735
|
+
if (i < 62)
|
|
1736
|
+
return 48 + (i - 52);
|
|
1737
|
+
if (i == 62)
|
|
1738
|
+
return 43;
|
|
1739
|
+
if (i == 63)
|
|
1740
|
+
return 47;
|
|
1741
|
+
throw "n:" + i;
|
|
1742
|
+
};
|
|
1743
|
+
return o.writeByte = function(i) {
|
|
1744
|
+
for (t = t << 8 | i & 255, e += 8, r += 1; e >= 6; )
|
|
1745
|
+
s(t >>> e - 6), e -= 6;
|
|
1746
|
+
}, o.flush = function() {
|
|
1747
|
+
if (e > 0 && (s(t << 6 - e), t = 0, e = 0), r % 3 != 0) {
|
|
1748
|
+
const i = 3 - r % 3;
|
|
1749
|
+
for (let a = 0; a < i; a += 1)
|
|
1750
|
+
n += "=";
|
|
1751
|
+
}
|
|
1752
|
+
}, o.toString = function() {
|
|
1753
|
+
return n;
|
|
1754
|
+
}, o;
|
|
1755
|
+
}, xe = function(t) {
|
|
1756
|
+
const e = t;
|
|
1757
|
+
let r = 0, n = 0, o = 0;
|
|
1758
|
+
const s = {};
|
|
1759
|
+
s.read = function() {
|
|
1760
|
+
for (; o < 8; ) {
|
|
1761
|
+
if (r >= e.length) {
|
|
1762
|
+
if (o == 0)
|
|
1763
|
+
return -1;
|
|
1764
|
+
throw "unexpected end of file./" + o;
|
|
1765
|
+
}
|
|
1766
|
+
const a = e.charAt(r);
|
|
1767
|
+
if (r += 1, a == "=")
|
|
1768
|
+
return o = 0, -1;
|
|
1769
|
+
if (a.match(/^\s$/))
|
|
1770
|
+
continue;
|
|
1771
|
+
n = n << 6 | c(a.charCodeAt(0)), o += 6;
|
|
1772
|
+
}
|
|
1773
|
+
const i = n >>> o - 8 & 255;
|
|
1774
|
+
return o -= 8, i;
|
|
1775
|
+
};
|
|
1776
|
+
const c = function(i) {
|
|
1777
|
+
if (65 <= i && i <= 90)
|
|
1778
|
+
return i - 65;
|
|
1779
|
+
if (97 <= i && i <= 122)
|
|
1780
|
+
return i - 97 + 26;
|
|
1781
|
+
if (48 <= i && i <= 57)
|
|
1782
|
+
return i - 48 + 52;
|
|
1783
|
+
if (i == 43)
|
|
1784
|
+
return 62;
|
|
1785
|
+
if (i == 47)
|
|
1786
|
+
return 63;
|
|
1787
|
+
throw "c:" + i;
|
|
1788
|
+
};
|
|
1789
|
+
return s;
|
|
1790
|
+
}, $e = function(t, e) {
|
|
1791
|
+
const r = t, n = e, o = new Array(t * e), s = {};
|
|
1792
|
+
s.setPixel = function(y, T, m) {
|
|
1793
|
+
o[T * r + y] = m;
|
|
1794
|
+
}, s.write = function(y) {
|
|
1795
|
+
y.writeString("GIF87a"), y.writeShort(r), y.writeShort(n), y.writeByte(128), y.writeByte(0), y.writeByte(0), y.writeByte(0), y.writeByte(0), y.writeByte(0), y.writeByte(255), y.writeByte(255), y.writeByte(255), y.writeString(","), y.writeShort(0), y.writeShort(0), y.writeShort(r), y.writeShort(n), y.writeByte(0);
|
|
1796
|
+
const T = 2, m = i(T);
|
|
1797
|
+
y.writeByte(T);
|
|
1798
|
+
let f = 0;
|
|
1799
|
+
for (; m.length - f > 255; )
|
|
1800
|
+
y.writeByte(255), y.writeBytes(m, f, 255), f += 255;
|
|
1801
|
+
y.writeByte(m.length - f), y.writeBytes(m, f, m.length - f), y.writeByte(0), y.writeString(";");
|
|
1802
|
+
};
|
|
1803
|
+
const c = function(y) {
|
|
1804
|
+
const T = y;
|
|
1805
|
+
let m = 0, f = 0;
|
|
1806
|
+
const p = {};
|
|
1807
|
+
return p.write = function(l, u) {
|
|
1808
|
+
if (l >>> u)
|
|
1809
|
+
throw "length over";
|
|
1810
|
+
for (; m + u >= 8; )
|
|
1811
|
+
T.writeByte(255 & (l << m | f)), u -= 8 - m, l >>>= 8 - m, f = 0, m = 0;
|
|
1812
|
+
f = l << m | f, m = m + u;
|
|
1813
|
+
}, p.flush = function() {
|
|
1814
|
+
m > 0 && T.writeByte(f);
|
|
1815
|
+
}, p;
|
|
1816
|
+
}, i = function(y) {
|
|
1817
|
+
const T = 1 << y, m = (1 << y) + 1;
|
|
1818
|
+
let f = y + 1;
|
|
1819
|
+
const p = a();
|
|
1820
|
+
for (let C = 0; C < T; C += 1)
|
|
1821
|
+
p.add(String.fromCharCode(C));
|
|
1822
|
+
p.add(String.fromCharCode(T)), p.add(String.fromCharCode(m));
|
|
1823
|
+
const l = Gt(), u = c(l);
|
|
1824
|
+
u.write(T, f);
|
|
1825
|
+
let g = 0, A = String.fromCharCode(o[g]);
|
|
1826
|
+
for (g += 1; g < o.length; ) {
|
|
1827
|
+
const C = String.fromCharCode(o[g]);
|
|
1828
|
+
g += 1, p.contains(A + C) ? A = A + C : (u.write(p.indexOf(A), f), p.size() < 4095 && (p.size() == 1 << f && (f += 1), p.add(A + C)), A = C);
|
|
1829
|
+
}
|
|
1830
|
+
return u.write(p.indexOf(A), f), u.write(m, f), u.flush(), l.toByteArray();
|
|
1831
|
+
}, a = function() {
|
|
1832
|
+
const y = {};
|
|
1833
|
+
let T = 0;
|
|
1834
|
+
const m = {};
|
|
1835
|
+
return m.add = function(f) {
|
|
1836
|
+
if (m.contains(f))
|
|
1837
|
+
throw "dup key:" + f;
|
|
1838
|
+
y[f] = T, T += 1;
|
|
1839
|
+
}, m.size = function() {
|
|
1840
|
+
return T;
|
|
1841
|
+
}, m.indexOf = function(f) {
|
|
1842
|
+
return y[f];
|
|
1843
|
+
}, m.contains = function(f) {
|
|
1844
|
+
return typeof y[f] < "u";
|
|
1845
|
+
}, m;
|
|
1846
|
+
};
|
|
1847
|
+
return s;
|
|
1848
|
+
}, Le = function(t, e, r) {
|
|
1849
|
+
const n = $e(t, e);
|
|
1850
|
+
for (let i = 0; i < e; i += 1)
|
|
1851
|
+
for (let a = 0; a < t; a += 1)
|
|
1852
|
+
n.setPixel(a, i, r(a, i));
|
|
1853
|
+
const o = Gt();
|
|
1854
|
+
n.write(o);
|
|
1855
|
+
const s = Me(), c = o.toByteArray();
|
|
1856
|
+
for (let i = 0; i < c.length; i += 1)
|
|
1857
|
+
s.writeByte(c[i]);
|
|
1858
|
+
return s.flush(), "data:image/gif;base64," + s;
|
|
1859
|
+
};
|
|
1860
|
+
V.stringToBytes;
|
|
1861
|
+
function _e(t) {
|
|
1862
|
+
const e = V(0, "M"), r = Array.from(new TextEncoder().encode(t), (s) => String.fromCharCode(s)).join("");
|
|
1863
|
+
e.addData(r, /^\d+$/.test(t) ? "Numeric" : "Byte"), e.make();
|
|
1864
|
+
const n = e.getModuleCount();
|
|
1865
|
+
let o = "";
|
|
1866
|
+
for (let s = 0; s < n; s++) for (let c = 0; c < n; c++) e.isDark(s, c) && (o += `M${c} ${s}h1v1h-1z`);
|
|
1867
|
+
return { count: n, path: o };
|
|
1868
|
+
}
|
|
1869
|
+
class ut extends Error {
|
|
1870
|
+
constructor(r) {
|
|
1871
|
+
super(r[0]?.message || "题卡数据无效");
|
|
1872
|
+
wt(this, "issues");
|
|
1873
|
+
this.name = "AnswerSheetDataError", this.issues = r;
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
function De(t, e) {
|
|
1877
|
+
const r = (l, u = "题卡数据结构无效") => {
|
|
1878
|
+
throw new ut([{ code: "INVALID_DATA", path: l, message: u }]);
|
|
1879
|
+
}, n = (l, u) => !l || typeof l != "object" || Array.isArray(l) ? r(u) : l, o = (l, u) => Array.isArray(l) ? l : r(u), s = (l, u) => {
|
|
1880
|
+
typeof l != "string" && r(u);
|
|
1881
|
+
}, c = (l, u, g = 0, A = 1e5) => {
|
|
1882
|
+
(typeof l != "number" || !Number.isFinite(l) || l < g || l > A) && r(u);
|
|
1883
|
+
}, i = (l, u) => {
|
|
1884
|
+
n(l, u);
|
|
1885
|
+
const g = e.validateDocument(l);
|
|
1886
|
+
g.length && r(u, g[0]);
|
|
1887
|
+
}, a = (l, u) => {
|
|
1888
|
+
const g = n(l, u);
|
|
1889
|
+
if (s(g.id, `${u}.id`), s(g.label, `${u}.label`), (typeof g.multiple != "boolean" || typeof g.breakBefore != "boolean") && r(u), g.contentTarget !== void 0 && g.contentTarget !== null) {
|
|
1890
|
+
const A = n(g.contentTarget, `${u}.contentTarget`);
|
|
1891
|
+
s(A.groupId, `${u}.contentTarget.groupId`), o(A.optionIds, `${u}.contentTarget.optionIds`).forEach((C, x) => s(C, `${u}.contentTarget.optionIds.${x}`));
|
|
1892
|
+
}
|
|
1893
|
+
o(g.options, `${u}.options`).forEach((A, C) => {
|
|
1894
|
+
const x = n(A, `${u}.options.${C}`);
|
|
1895
|
+
s(x.id, `${u}.options.${C}.id`), s(x.label, `${u}.options.${C}.label`);
|
|
1896
|
+
}), o(g.correctIds, `${u}.correctIds`).forEach((A, C) => s(A, `${u}.correctIds.${C}`));
|
|
1897
|
+
}, y = (l, u) => {
|
|
1898
|
+
const g = n(l, u);
|
|
1899
|
+
(!["row", "column"].includes(String(g.direction)) || !["concentrated", "distributed", "stem", "option"].includes(String(g.presentation)) || !["box", "check", "bubble"].includes(String(g.marker))) && r(u), c(g.rowsPerColumn, `${u}.rowsPerColumn`, 1, 5), c(g.rowGap, `${u}.rowGap`, 0, 64), c(g.columnGap, `${u}.columnGap`, 0, 64), o(g.questions, `${u}.questions`).forEach((A, C) => a(A, `${u}.questions.${C}`));
|
|
1900
|
+
}, T = /* @__PURE__ */ new WeakSet(), m = (l, u) => {
|
|
1901
|
+
if (!(!l || typeof l != "object")) {
|
|
1902
|
+
if (T.has(l)) return r(u, "题卡必须是无循环引用的 JSON 数据");
|
|
1903
|
+
T.add(l), Object.entries(l).forEach(([g, A]) => m(A, `${u}.${g}`)), T.delete(l);
|
|
1904
|
+
}
|
|
1905
|
+
}, f = n(t, "");
|
|
1906
|
+
if (f.version !== 1 && r("version", "不支持的题卡数据版本"), s(f.title, "title"), f.usage !== void 0 && !["exam", "homework"].includes(String(f.usage)) && r("usage"), ["questionCard", "scanMarking", "halfPoint", "mergeObjective"].forEach((l) => {
|
|
1907
|
+
f[l] !== void 0 && typeof f[l] != "boolean" && r(l);
|
|
1908
|
+
}), ["a4", "a3-two", "a3-three"].includes(String(f.preset)) || r("preset"), c(f.margin, "margin", 0, 100), c(f.gap, "gap", 0, 100), f.creation) {
|
|
1909
|
+
const l = n(f.creation, "creation");
|
|
1910
|
+
["template", "exam"].includes(String(l.mode)) || r("creation.mode"), ["name", "grade", "subject"].forEach((u) => s(l[u], `creation.${u}`));
|
|
1911
|
+
for (const u of ["gradeCode", "courseCode", "subjectCode"]) l[u] !== void 0 && (typeof l[u] != "string" || !l[u].trim()) && r(`creation.${u}`);
|
|
1912
|
+
l.phaseCode !== void 0 && !["P", "J", "S"].includes(String(l.phaseCode)) && r("creation.phaseCode"), l.createMode !== void 0 && !["MANUALLY", "IMPORTED", "THIRD"].includes(String(l.createMode)) && r("creation.createMode");
|
|
1913
|
+
for (const u of ["id", "exampaperId"]) if (l[u] !== void 0) {
|
|
1914
|
+
const g = l[u];
|
|
1915
|
+
typeof g == "string" && g.trim() || typeof g == "number" && Number.isSafeInteger(g) && g >= 0 || r(`creation.${u}`);
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
if (f.paperTitle) {
|
|
1919
|
+
const l = n(f.paperTitle, "paperTitle");
|
|
1920
|
+
s(l.id, "paperTitle.id"), c(l.height, "paperTitle.height", 1, 1e3), i(l.document, "paperTitle.document");
|
|
1921
|
+
}
|
|
1922
|
+
if (f.header) {
|
|
1923
|
+
const l = n(f.header, "header");
|
|
1924
|
+
["code", "school"].includes(String(l.kaohao)) || r("header.kaohao"), c(l.weishu, "header.weishu", 1, 20), l.tiaomaStyle !== void 0 && ![1, 2].includes(l.tiaomaStyle) && r("header.tiaomaStyle"), l.classText !== void 0 && typeof l.classText != "boolean" && r("header.classText");
|
|
1925
|
+
}
|
|
1926
|
+
if (f.recognition !== void 0) {
|
|
1927
|
+
const l = n(f.recognition, "recognition");
|
|
1928
|
+
for (const u of ["examQrCode", "subjectMarkers", "pointBlack"]) l[u] !== void 0 && typeof l[u] != "boolean" && r(`recognition.${u}`);
|
|
1929
|
+
}
|
|
1930
|
+
o(f.blocks, "blocks").forEach((l, u) => {
|
|
1931
|
+
const g = `blocks.${u}`, A = n(l, g);
|
|
1932
|
+
if (s(A.id, `${g}.id`), s(A.title, `${g}.title`), c(A.answerHeight, `${g}.answerHeight`), i(A.document, `${g}.document`), A.kind === "area") {
|
|
1933
|
+
(!["forbiden", "editArea"].includes(String(A.areaType)) || A.reference || A.choices || A.exercise) && r(`${g}.areaType`), c(A.answerHeight, `${g}.answerHeight`, 100, 4e3);
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
if (!A.reference) {
|
|
1937
|
+
if (A.choices) {
|
|
1938
|
+
y(A.choices, `${g}.choices`);
|
|
1939
|
+
return;
|
|
1940
|
+
}
|
|
1941
|
+
r(`${g}.reference`, "请使用包含 reference 题目结构的制卡数据");
|
|
1942
|
+
}
|
|
1943
|
+
const C = n(A.reference, `${g}.reference`);
|
|
1944
|
+
C.material !== void 0 && i(C.material, `${g}.reference.material`), C.textVersion !== void 0 && C.textVersion !== 1 && r(`${g}.reference.textVersion`), Object.hasOwn(It, String(C.type)) || r(`${g}.reference.type`), y(C.layout, `${g}.reference.layout`), c(C.optionalHeight, `${g}.reference.optionalHeight`), o(C.questions, `${g}.reference.questions`).forEach((x, M) => {
|
|
1945
|
+
const w = `${g}.reference.questions.${M}`, O = n(x, w);
|
|
1946
|
+
Object.hasOwn(lt, String(O.type)) || r(`${w}.type`), s(O.id, `${w}.id`), s(O.label, `${w}.label`), a(O.choice, `${w}.choice`), ["height", "contentHeight", "characters", "lines"].forEach((I) => c(O[I], `${w}.${I}`)), i(O.document, `${w}.document`);
|
|
1947
|
+
const h = (I, d) => {
|
|
1948
|
+
if (!I) return;
|
|
1949
|
+
const b = n(I, d);
|
|
1950
|
+
i(b.content, `${d}.content`), n(b.layout, `${d}.layout`), s(b.groupId, `${d}.groupId`), o(b.itemsContent, `${d}.itemsContent`).forEach((E, S) => {
|
|
1951
|
+
const N = n(E, `${d}.itemsContent.${S}`);
|
|
1952
|
+
s(N.id, `${d}.itemsContent.${S}.id`), s(N.key, `${d}.itemsContent.${S}.key`), i(N.content, `${d}.itemsContent.${S}.content`);
|
|
1953
|
+
});
|
|
1954
|
+
};
|
|
1955
|
+
h(O.text, `${w}.text`), o(O.parts, `${w}.parts`).forEach((I, d) => {
|
|
1956
|
+
const b = `${w}.parts.${d}`, E = n(I, b);
|
|
1957
|
+
s(E.id, `${b}.id`), s(E.label, `${b}.label`), c(E.width, `${b}.width`), c(E.height, `${b}.height`), i(E.document, `${b}.document`), a(E.choice, `${b}.choice`), h(E.text, `${b}.text`);
|
|
1958
|
+
});
|
|
1959
|
+
});
|
|
1960
|
+
}), m(t, "");
|
|
1961
|
+
const p = Ct(t);
|
|
1962
|
+
(p.columnWidth < 100 || p.contentHeight < 100) && r("margin", "边距或栏间距过大,纸张没有足够的作答区域");
|
|
1963
|
+
}
|
|
1964
|
+
function rt(t) {
|
|
1965
|
+
return !t || t.marks?.some((e) => e.type === "documentLabel") ? !1 : t.type === "text" ? !!t.text?.trim() : t.type === "image" ? !!t.attrs?.src : t.type === "formula" || t.type === "blockFormula" ? !!t.attrs?.latex?.trim() : !!t.content?.some(rt);
|
|
1966
|
+
}
|
|
1967
|
+
function On(t, e) {
|
|
1968
|
+
try {
|
|
1969
|
+
De(t, e);
|
|
1970
|
+
} catch (p) {
|
|
1971
|
+
return { valid: !1, issues: p instanceof ut ? p.issues : [{ code: "INVALID_DATA", path: "", message: "题卡数据无法读取" }] };
|
|
1972
|
+
}
|
|
1973
|
+
const r = [];
|
|
1974
|
+
let n = {};
|
|
1975
|
+
const o = (p, l, u) => r.push({ code: p, path: l, message: u, ...n }), s = /* @__PURE__ */ new Set(), c = (p, l) => {
|
|
1976
|
+
(!p.trim() || s.has(p)) && o("DUPLICATE_ID", l, "题块、题目和选项 ID 必须非空且唯一"), s.add(p);
|
|
1977
|
+
}, i = (p, l, u) => {
|
|
1978
|
+
(p === null || !Number.isFinite(p) || p < (t.usage === "homework" ? 0 : 0.5) || p > l || !Number.isInteger(p * 2)) && o("INVALID_SCORE", u, `分值须为 ${t.usage === "homework" ? 0 : 0.5}–${l} 分,按 0.5 分递增`);
|
|
1979
|
+
}, a = (p, l, u) => {
|
|
1980
|
+
(p.options.length < l[0] || p.options.length > l[1]) && o("INVALID_OPTIONS", `${u}.options`, `选项个数须为 ${l[0]}–${l[1]}`), p.options.forEach((g, A) => c(g.id, `${u}.options.${A}.id`)), (new Set(p.correctIds).size !== p.correctIds.length || p.correctIds.some((g) => !p.options.some((A) => A.id === g))) && o("INVALID_ANSWER_REFERENCE", `${u}.correctIds`, "答案引用了不存在或重复的选项");
|
|
1981
|
+
}, y = (p, l, u, g = 0, A = !0) => {
|
|
1982
|
+
A && !rt(p?.content.content) && o("MISSING_CONTENT", `${l}.content`, "请填写题干或材料"), u && (p?.itemsContent.length !== g || p.itemsContent.some((C) => !rt(C.content.content))) && o("MISSING_OPTION_CONTENT", `${l}.itemsContent`, "请补全每个选项的内容");
|
|
1983
|
+
};
|
|
1984
|
+
if (t.title.trim() || o("MISSING_TITLE", "title", "请填写题卡名称"), t.recognition?.examQrCode) {
|
|
1985
|
+
const p = String(t.creation?.exampaperId ?? "").trim();
|
|
1986
|
+
if (!p) o("MISSING_EXAM_ID", "creation.exampaperId", "显示试卷二维码需要填写试卷 ID");
|
|
1987
|
+
else
|
|
1988
|
+
try {
|
|
1989
|
+
_e(p);
|
|
1990
|
+
} catch {
|
|
1991
|
+
o("INVALID_QR_PAYLOAD", "creation.exampaperId", "试卷 ID 太长,无法生成二维码");
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
t.header && t.recognition?.subjectMarkers !== !1 && !jt[Te(t.creation) || ""] && o("UNKNOWN_SUBJECT_MARK", "creation.subjectCode", "当前学科没有参考识别编码,请配置标准学科或关闭学科标记"), (!t.creation?.grade.trim() || !t.creation.subject.trim()) && o("MISSING_CREATION", "creation", "请选择年级和学科"), (!t.paperTitle || !rt(t.paperTitle.document.content)) && o("MISSING_PAPER_TITLE", "paperTitle", "请填写纸面标题"), t.blocks.some((p) => p.kind !== "area") || o("EMPTY_CARD", "blocks", "请至少添加一个题块和一道题目"), t.paperTitle && c(t.paperTitle.id, "paperTitle.id"), t.blocks.forEach((p, l) => {
|
|
1995
|
+
n = { blockId: p.id };
|
|
1996
|
+
const u = `blocks.${l}`;
|
|
1997
|
+
if (c(p.id, `${u}.id`), p.kind === "area") {
|
|
1998
|
+
p.areaType === (t.questionCard ? "forbiden" : "editArea") && o("INVALID_AREA_MODE", `${u}.areaType`, "题卡合一使用空白答题区,独立答题卡使用禁止答题区");
|
|
1999
|
+
return;
|
|
2000
|
+
}
|
|
2001
|
+
p.title.trim() || o("MISSING_BLOCK_TITLE", `${u}.title`, "请填写题块标题"), p.id === "reference-merged-objective" && o("RESERVED_ID", `${u}.id`, "题块使用了系统保留 ID");
|
|
2002
|
+
const g = p.reference;
|
|
2003
|
+
if (!g) {
|
|
2004
|
+
p.choices?.questions.length || o("EMPTY_BLOCK", u, "题块中没有题目"), p.choices?.questions.forEach((C, x) => {
|
|
2005
|
+
n = { blockId: p.id, questionId: C.id }, c(C.id, `${u}.choices.questions.${x}.id`), a(C, [2, 12], `${u}.choices.questions.${x}`), i(C.score ?? null, 15, `${u}.choices.questions.${x}.score`);
|
|
2006
|
+
});
|
|
2007
|
+
return;
|
|
2008
|
+
}
|
|
2009
|
+
g.questions.length || o("EMPTY_BLOCK", `${u}.reference.questions`, "题块中没有题目");
|
|
2010
|
+
const A = yt(g);
|
|
2011
|
+
if ((A.some((C) => !C.trim()) || new Set(A).size !== A.length) && o("INVALID_QUESTION_NUMBER", `${u}.reference.questions`, "同一题块内的题号须非空且不能重复"), g.optional && (g.type !== "SHORTANSWER" || !Number.isInteger(g.choose) || g.choose < 1 || g.choose >= g.questions.length) && o("INVALID_OPTIONAL", `${u}.reference.choose`, "选做题须为解答题,且选做数量小于总题数"), g.type === "CCOMPOSITION" && g.questions.length > 1 && o("INVALID_COUNT", `${u}.reference.questions`, "语文作文每组只能有一道题"), g.questions.forEach((C, x) => {
|
|
2012
|
+
n = { blockId: p.id, questionId: C.id };
|
|
2013
|
+
const M = `${u}.reference.questions.${x}`, w = lt[C.type];
|
|
2014
|
+
c(C.id, `${M}.id`), g.type !== "MIXED" && g.type !== C.type && o("TYPE_MISMATCH", `${M}.type`, "题目类型与题块不一致"), C.choice.id !== C.id && o("INVALID_BINDING", `${M}.choice.id`, "题目与填涂项 ID 不一致");
|
|
2015
|
+
const O = R(C.type) || ["FILLBLANK", "SHORTANSWER"].includes(C.type);
|
|
2016
|
+
(O && (C.parts.length < 1 || C.parts.length > w.parts) || !O && C.parts.length) && o("INVALID_PARTS", `${M}.parts`, `子题/空数须为 ${O ? `1–${w.parts}` : "0"}`), C.parts.length ? C.score !== Bt(C.parts) && o("SCORE_MISMATCH", `${M}.score`, "总分与子题分值之和不一致") : i(C.score, w.score, `${M}.score`), Y(C.type) && !R(C.type) && a(C.choice, w.options, `${M}.choice`), C.type === "INFO_MATCHING" && (a(C.choice, w.options, `${M}.choice`), C.parts.length > C.choice.options.length && o("INVALID_OPTIONS", `${M}.choice.options`, "信息匹配的选项数不能少于子题数")), C.type === "MCHOICE" && (!Number.isFinite(C.choice.lessScore) || C.choice.lessScore < 0 || C.choice.lessScore > (C.score || 0) || !Number.isInteger(C.choice.lessScore * 2)) && o("INVALID_LESS_SCORE", `${M}.choice.lessScore`, "少选得分须按 0.5 分递增且不能超过本题分值"), C.type === "CHUNK_CHOICE" && (!C.rightAnswers || !Number.isInteger(C.rightAnswers) || C.rightAnswers >= C.choice.options.length || !C.singleScore || C.singleScore < 0.5 || !Number.isInteger(C.singleScore * 2) || C.score !== 0 && C.singleScore * C.rightAnswers > (C.score || 0)) && o("INVALID_CHUNK_SCORE", M, "请检查正确答案个数及每处得分"), C.type === "CCOMPOSITION" && (!Number.isInteger(C.characters) || C.characters < 1 || C.characters > 1200) && o("INVALID_GRID_COUNT", `${M}.characters`, "作文格数须为 1–1200"), C.type === "ECOMPOSITION" && (!Number.isInteger(C.lines) || C.lines < 1 || C.lines > 100) && o("INVALID_LINE_COUNT", `${M}.lines`, "作文行数须为 1–100"), t.questionCard && y(C.text, `${M}.text`, ["SCHOICE", "MCHOICE"].includes(C.type), C.choice.options.length), C.parts.forEach((h, I) => {
|
|
2017
|
+
const d = `${M}.parts.${I}`;
|
|
2018
|
+
n = { blockId: p.id, questionId: h.id }, c(h.id, `${d}.id`), i(h.score, w.score, `${d}.score`), R(C.type) && Y(C.type) && (a(h.choice, w.options, `${d}.choice`), h.choice.id !== h.id && o("INVALID_BINDING", `${d}.choice.id`, "子题与填涂项 ID 不一致")), t.questionCard && ["CLOZE", "READTHENANSWER"].includes(C.type) && y(h.text, `${d}.text`, !0, h.choice.options.length, C.type === "READTHENANSWER");
|
|
2019
|
+
});
|
|
2020
|
+
}), n = { blockId: p.id }, t.questionCard && g.layout.presentation !== "concentrated") {
|
|
2021
|
+
const C = g.questions.filter((M) => Y(M.type)).flatMap((M) => R(M.type) ? M.parts.map((w) => w.choice) : [M.choice]);
|
|
2022
|
+
Zt({ ...g.layout, questions: C }, p.document, !0).concentrated.questions.length && o("MISSING_FILL_TARGET", `${u}.reference.layout.presentation`, "部分填涂框没有对应的题干或选项位置");
|
|
2023
|
+
}
|
|
2024
|
+
}), n = {};
|
|
2025
|
+
const T = (p, l) => {
|
|
2026
|
+
p.type === "image" && (!p.attrs?.src || /^blob:/i.test(p.attrs.src)) && o("INVALID_IMAGE_URL", l, "图片缺少可保存的地址,请上传后使用持久 URL 或内嵌图片"), ["formula", "blockFormula"].includes(p.type || "") && !String(p.attrs?.latex || "").trim() && o("EMPTY_FORMULA", l, "请填写公式或删除空公式"), p.content?.forEach((u, g) => T(u, `${l}.content.${g}`));
|
|
2027
|
+
}, m = (p, l) => {
|
|
2028
|
+
p && T(p.content, `${l}.content`);
|
|
2029
|
+
}, f = (p, l) => {
|
|
2030
|
+
m(p?.content, `${l}.content`), p?.itemsContent.forEach((u, g) => m(u.content, `${l}.itemsContent.${g}.content`));
|
|
2031
|
+
};
|
|
2032
|
+
return m(t.paperTitle?.document, "paperTitle.document"), t.blocks.forEach((p, l) => {
|
|
2033
|
+
n = { blockId: p.id };
|
|
2034
|
+
const u = `blocks.${l}`;
|
|
2035
|
+
m(p.document, `${u}.document`), m(p.reference?.material, `${u}.reference.material`), p.reference?.questions.forEach((g, A) => {
|
|
2036
|
+
n = { blockId: p.id, questionId: g.id };
|
|
2037
|
+
const C = `blocks.${l}.reference.questions.${A}`;
|
|
2038
|
+
m(g.document, `${C}.document`), f(g.text, `${C}.text`), g.parts.forEach((x, M) => {
|
|
2039
|
+
n = { blockId: p.id, questionId: x.id }, m(x.document, `${C}.parts.${M}.document`), f(x.text, `${C}.parts.${M}.text`);
|
|
2040
|
+
});
|
|
2041
|
+
});
|
|
2042
|
+
}), { valid: r.length === 0, issues: r };
|
|
2043
|
+
}
|
|
2044
|
+
function gt(t) {
|
|
2045
|
+
if (t !== void 0)
|
|
2046
|
+
try {
|
|
2047
|
+
const e = Lt(t);
|
|
2048
|
+
return { grades: e.grades, gradeCourseMap: e.gradeCourseMap, defaultGradeCode: e.defaultGradeCode || void 0, defaultCourseCode: e.defaultCourseCode || void 0 };
|
|
2049
|
+
} catch (e) {
|
|
2050
|
+
throw e instanceof mt ? new ut([{ code: "INVALID_DICTIONARIES", path: e.path, message: e.message }]) : e;
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
function ke(t, e) {
|
|
2054
|
+
const r = (w, O) => {
|
|
2055
|
+
throw new ut([{ code: "INVALID_INITIALIZATION", path: w, message: O }]);
|
|
2056
|
+
}, n = (w, O, h) => {
|
|
2057
|
+
if (!w || typeof w != "object" || Array.isArray(w)) return r(O, "初始化配置必须是对象");
|
|
2058
|
+
const I = Object.entries(w);
|
|
2059
|
+
for (const [d] of I) h.includes(d) || r(`${O}.${d}`, "不支持的初始化字段");
|
|
2060
|
+
return Object.fromEntries(I.filter(([, d]) => d !== void 0));
|
|
2061
|
+
}, o = (w, O) => typeof w != "string" || !w.trim() ? r(O, "请提供非空的试卷名称、年级和学科") : w.trim(), s = (w, O, h) => {
|
|
2062
|
+
w !== void 0 && !h.includes(w) && r(O, `可选值为 ${h.join("、")}`);
|
|
2063
|
+
}, c = (w, O) => {
|
|
2064
|
+
w !== void 0 && typeof w != "boolean" && r(O, "请使用布尔值");
|
|
2065
|
+
}, i = (w, O, h, I) => {
|
|
2066
|
+
w !== void 0 && (typeof w != "number" || !Number.isFinite(w) || w < h || w > I) && r(O, `数值必须在 ${h}–${I} 之间`);
|
|
2067
|
+
}, a = n(t, "initialization", ["name", "grade", "subject", "gradeCode", "courseCode", "subjectCode", "mode", "id", "exampaperId", "createMode", "layout", "header", "recognition"]), y = o(a.name, "initialization.name");
|
|
2068
|
+
y.length > 30 && r("initialization.name", "试卷名称最多 30 个字符");
|
|
2069
|
+
const T = Lt(gt(e)), m = a.gradeCode !== void 0 || a.courseCode !== void 0 || a.subjectCode !== void 0;
|
|
2070
|
+
let f;
|
|
2071
|
+
if (m) {
|
|
2072
|
+
try {
|
|
2073
|
+
f = dt(T, o(a.gradeCode, "initialization.gradeCode"), o(a.courseCode, "initialization.courseCode"));
|
|
2074
|
+
} catch (w) {
|
|
2075
|
+
if (w instanceof mt) return r(w.path, w.message);
|
|
2076
|
+
throw w;
|
|
2077
|
+
}
|
|
2078
|
+
for (const w of ["grade", "subject", "subjectCode"]) a[w] !== void 0 && o(a[w], `initialization.${w}`) !== f[w] && r(`initialization.${w}`, "名称或学科编码与课程字典不一致");
|
|
2079
|
+
} else {
|
|
2080
|
+
const w = o(a.grade, "initialization.grade"), O = o(a.subject, "initialization.subject"), h = T.grades.filter((b) => b.label === w);
|
|
2081
|
+
h.length > 1 && r("initialization.grade", "同名年级不唯一,请使用 gradeCode");
|
|
2082
|
+
const I = h[0], d = I ? T.gradeCourseMap[I.value].filter((b) => b.label === O) : [];
|
|
2083
|
+
d.length > 1 && r("initialization.subject", "同名课程不唯一,请使用 courseCode"), e && (!I || !d.length) && r(I ? "initialization.subject" : "initialization.grade", "名称不在可用字典中,请使用年级和课程编码"), f = I && d.length ? dt(T, I.value, d[0].value) : { grade: w, subject: O };
|
|
2084
|
+
}
|
|
2085
|
+
s(a.mode, "initialization.mode", ["template", "exam"]), s(a.createMode, "initialization.createMode", ["MANUALLY", "IMPORTED", "THIRD"]);
|
|
2086
|
+
const p = {};
|
|
2087
|
+
for (const w of ["id", "exampaperId"]) if (a[w] !== void 0) {
|
|
2088
|
+
const O = a[w];
|
|
2089
|
+
typeof O == "string" ? p[w] = o(O, `initialization.${w}`) : typeof O == "number" && Number.isSafeInteger(O) && O >= 0 ? p[w] = O : r(`initialization.${w}`, "ID 必须是非空字符串或非负安全整数");
|
|
2090
|
+
}
|
|
2091
|
+
a.createMode !== void 0 && (p.createMode = a.createMode);
|
|
2092
|
+
const l = a.layout === void 0 ? {} : n(a.layout, "initialization.layout", ["usage", "preset", "margin", "gap", "questionCard", "scanMarking", "halfPoint", "choiceDirection", "mergeObjective", "pageNum", "quesCard", "scoreType", "choiceType", "mixOb"]), u = (w, O, h) => {
|
|
2093
|
+
l[w] !== void 0 && (l[O] !== void 0 && l[O] !== h && r(`initialization.layout.${w}`, `与 ${O} 设置冲突`), l[O] = h, delete l[w]);
|
|
2094
|
+
};
|
|
2095
|
+
l.pageNum !== void 0 && ![1, 2, 3].includes(l.pageNum) && r("initialization.layout.pageNum", "分栏数为 1、2 或 3"), u("pageNum", "preset", { 1: "a4", 2: "a3-two", 3: "a3-three" }[l.pageNum]);
|
|
2096
|
+
for (const [w, O] of [["quesCard", "questionCard"], ["scoreType", "halfPoint"], ["mixOb", "mergeObjective"], ["choiceType", "choiceDirection"]])
|
|
2097
|
+
c(l[w], `initialization.layout.${w}`), u(w, O, w === "choiceType" ? l[w] ? "column" : "row" : l[w]);
|
|
2098
|
+
s(l.preset, "initialization.layout.preset", ["a4", "a3-two", "a3-three"]), s(l.usage, "initialization.layout.usage", ["exam", "homework"]), s(l.choiceDirection, "initialization.layout.choiceDirection", ["row", "column"]), i(l.margin, "initialization.layout.margin", 0, 100), i(l.gap, "initialization.layout.gap", 0, 100);
|
|
2099
|
+
for (const w of ["questionCard", "scanMarking", "halfPoint", "mergeObjective"]) c(l[w], `initialization.layout.${w}`);
|
|
2100
|
+
const g = a.header === void 0 ? {} : n(a.header, "initialization.header", ["focusText", "writeKaohao", "missExam", "mifeng", "kaohao", "weishu", "tiaomaStyle", "classText"]);
|
|
2101
|
+
for (const w of ["focusText", "writeKaohao", "missExam", "mifeng", "classText"]) c(g[w], `initialization.header.${w}`);
|
|
2102
|
+
g.tiaomaStyle !== void 0 && ![1, 2].includes(g.tiaomaStyle) && r("initialization.header.tiaomaStyle", "考号版式为 1(填涂)或 2(条形码)"), s(g.kaohao, "initialization.header.kaohao", ["school", "code"]), i(g.weishu, "initialization.header.weishu", 4, 12), g.weishu !== void 0 && !Number.isInteger(g.weishu) && r("initialization.header.weishu", "考号位数必须是整数");
|
|
2103
|
+
const A = ae({ name: y, ...f, ...p, mode: a.mode ?? "template" }), C = a.recognition === void 0 ? void 0 : n(a.recognition, "initialization.recognition", ["examQrCode", "subjectMarkers", "pointBlack"]);
|
|
2104
|
+
if (C) for (const w of ["examQrCode", "subjectMarkers", "pointBlack"]) c(C[w], `initialization.recognition.${w}`);
|
|
2105
|
+
const x = { ...A, ...l, header: { ...A.header, ...g }, ...C ? { recognition: C } : {} }, M = Ct(x);
|
|
2106
|
+
return (M.columnWidth < 100 || M.contentHeight < 100) && r("initialization.layout", "边距或栏间距过大,纸张没有足够的作答区域"), x;
|
|
2107
|
+
}
|
|
2108
|
+
function Nn(t, e) {
|
|
2109
|
+
if (typeof document > "u") throw new Error("请在浏览器挂载后创建制卡实例");
|
|
2110
|
+
const r = vt(e?.plugins || []), n = gt(e.dictionaries), o = typeof t == "string" ? document.querySelector(t) : t;
|
|
2111
|
+
if (!(o instanceof HTMLElement) || o.ownerDocument !== document || /^(INPUT|TEXTAREA|SELECT|BUTTON|IMG|CANVAS|IFRAME)$/.test(o.tagName)) throw new Error("制卡需要一个空的 HTML 容器,例如 div");
|
|
2112
|
+
if (document.querySelector("[data-uni-answer-sheet-mount], #uni-answer-sheet")) throw new Error("当前文档已挂载制卡工作区;切换容器前请先 destroy()");
|
|
2113
|
+
if (o.textContent?.trim() || o.children.length) throw new Error("请提供空容器,已有题卡请通过 initialValue 传入");
|
|
2114
|
+
const s = document.createElement("div");
|
|
2115
|
+
s.className = "uni-answer-sheet-host", s.dataset.uniAnswerSheetMount = "", s.style.height = "100%", o.append(s);
|
|
2116
|
+
let c = !1, i = { ...e, dictionaries: n }, a, y, T;
|
|
2117
|
+
const m = new Promise((u, g) => {
|
|
2118
|
+
y = u, T = g;
|
|
2119
|
+
});
|
|
2120
|
+
m.catch(() => {
|
|
2121
|
+
});
|
|
2122
|
+
const f = () => {
|
|
2123
|
+
if (c) throw new Error("制卡实例已销毁");
|
|
2124
|
+
if (!a?.isReady()) throw new Error("请先等待 sheet.ready");
|
|
2125
|
+
return a;
|
|
2126
|
+
}, p = async () => (await m, f()), l = {
|
|
2127
|
+
ready: m,
|
|
2128
|
+
async initialize(u) {
|
|
2129
|
+
if (c) throw new Error("制卡实例已销毁");
|
|
2130
|
+
const g = ke(u, i.dictionaries);
|
|
2131
|
+
a || (i = { ...i, initialValue: g }), await (await p()).setDocument(g);
|
|
2132
|
+
},
|
|
2133
|
+
getDocument: () => f().getDocument(),
|
|
2134
|
+
load: async (u) => (await p()).setDocument(u),
|
|
2135
|
+
setDocument: async (u) => (await p()).setDocument(u),
|
|
2136
|
+
newDocument: async (u) => (await p()).newDocument(u),
|
|
2137
|
+
getReferenceData: () => f().getReferenceData(),
|
|
2138
|
+
setReferenceData: async (u) => (await p()).setReferenceData(u),
|
|
2139
|
+
validate: async () => (await p()).validate(),
|
|
2140
|
+
save: async () => (await p()).save(),
|
|
2141
|
+
getRecognitionData: async () => (await p()).getRecognitionData(),
|
|
2142
|
+
focusIssue: (u) => f().focusIssue(u),
|
|
2143
|
+
setOptions(u) {
|
|
2144
|
+
if (c) throw new Error("制卡实例已销毁");
|
|
2145
|
+
const g = Object.hasOwn(u, "dictionaries") ? gt(u.dictionaries) : i.dictionaries;
|
|
2146
|
+
i = { ...i, ...u, dictionaries: g }, a?.update(i);
|
|
2147
|
+
},
|
|
2148
|
+
destroy() {
|
|
2149
|
+
c || (c = !0, a?.destroy(), s.remove(), T(new DOMException("制卡实例已销毁", "AbortError")));
|
|
2150
|
+
}
|
|
2151
|
+
};
|
|
2152
|
+
return Promise.all([r.prepare(), import("./runtime-C-fdAw2T.js")]).then(([, { mountAnswerSheet: u }]) => {
|
|
2153
|
+
c || (a = u(s, r, i, y, (g) => {
|
|
2154
|
+
T(g), l.destroy(), i.onError?.(g instanceof Error ? g : new Error(String(g)));
|
|
2155
|
+
}));
|
|
2156
|
+
}).catch((u) => {
|
|
2157
|
+
T(u), l.destroy(), i.onError?.(u instanceof Error ? u : new Error(String(u)));
|
|
2158
|
+
}), l;
|
|
2159
|
+
}
|
|
2160
|
+
export {
|
|
2161
|
+
oe as $,
|
|
2162
|
+
An as A,
|
|
2163
|
+
Sn as B,
|
|
2164
|
+
Lt as C,
|
|
2165
|
+
se as D,
|
|
2166
|
+
un as E,
|
|
2167
|
+
an as F,
|
|
2168
|
+
et as G,
|
|
2169
|
+
Cn as H,
|
|
2170
|
+
ae as I,
|
|
2171
|
+
ln as J,
|
|
2172
|
+
v as K,
|
|
2173
|
+
W as L,
|
|
2174
|
+
Fe as M,
|
|
2175
|
+
ve as N,
|
|
2176
|
+
Yt as O,
|
|
2177
|
+
xt as P,
|
|
2178
|
+
Jt as Q,
|
|
2179
|
+
Dt as R,
|
|
2180
|
+
Ke as S,
|
|
2181
|
+
Ge as T,
|
|
2182
|
+
at as U,
|
|
2183
|
+
Be as V,
|
|
2184
|
+
je as W,
|
|
2185
|
+
Tt as X,
|
|
2186
|
+
Ue as Y,
|
|
2187
|
+
qe as Z,
|
|
2188
|
+
Ye as _,
|
|
2189
|
+
ye as a,
|
|
2190
|
+
nn as a0,
|
|
2191
|
+
tn as a1,
|
|
2192
|
+
en as a2,
|
|
2193
|
+
on as a3,
|
|
2194
|
+
Je as a4,
|
|
2195
|
+
ne as a5,
|
|
2196
|
+
re as a6,
|
|
2197
|
+
ie as a7,
|
|
2198
|
+
We as a8,
|
|
2199
|
+
Qe as a9,
|
|
2200
|
+
_e as aA,
|
|
2201
|
+
De as aB,
|
|
2202
|
+
ut as aC,
|
|
2203
|
+
On as aD,
|
|
2204
|
+
Nn as aE,
|
|
2205
|
+
qt as aa,
|
|
2206
|
+
rn as ab,
|
|
2207
|
+
Ze as ac,
|
|
2208
|
+
Ve as ad,
|
|
2209
|
+
lt as ae,
|
|
2210
|
+
Rt as af,
|
|
2211
|
+
gn as ag,
|
|
2212
|
+
yn as ah,
|
|
2213
|
+
pn as ai,
|
|
2214
|
+
mn as aj,
|
|
2215
|
+
En as ak,
|
|
2216
|
+
ht as al,
|
|
2217
|
+
sn as am,
|
|
2218
|
+
Xe as an,
|
|
2219
|
+
He as ao,
|
|
2220
|
+
dt as ap,
|
|
2221
|
+
le as aq,
|
|
2222
|
+
cn as ar,
|
|
2223
|
+
ze as as,
|
|
2224
|
+
de as at,
|
|
2225
|
+
bn as au,
|
|
2226
|
+
wn as av,
|
|
2227
|
+
it as aw,
|
|
2228
|
+
Te as ax,
|
|
2229
|
+
jt as ay,
|
|
2230
|
+
Tn as az,
|
|
2231
|
+
hn as b,
|
|
2232
|
+
Ce as c,
|
|
2233
|
+
Ht as d,
|
|
2234
|
+
Ie as e,
|
|
2235
|
+
pt as f,
|
|
2236
|
+
Y as g,
|
|
2237
|
+
In as h,
|
|
2238
|
+
R as i,
|
|
2239
|
+
j,
|
|
2240
|
+
fn as k,
|
|
2241
|
+
kt as l,
|
|
2242
|
+
Q as m,
|
|
2243
|
+
St as n,
|
|
2244
|
+
dn as o,
|
|
2245
|
+
pe as p,
|
|
2246
|
+
It as q,
|
|
2247
|
+
Zt as r,
|
|
2248
|
+
Bt as s,
|
|
2249
|
+
J as t,
|
|
2250
|
+
st as u,
|
|
2251
|
+
Pt as v,
|
|
2252
|
+
he as w,
|
|
2253
|
+
Ot as x,
|
|
2254
|
+
Z as y,
|
|
2255
|
+
nt as z
|
|
2256
|
+
};
|