@skopon-cool/form-sdk 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +52 -12
  2. package/dist/adapter/a2uiAdapter.d.ts.map +1 -1
  3. package/dist/adapter/formFileAccept.d.ts.map +1 -1
  4. package/dist/adapter/formSchema.d.ts +1 -0
  5. package/dist/adapter/formSchema.d.ts.map +1 -1
  6. package/dist/catalog/a2uiCustomCatalog.d.ts.map +1 -1
  7. package/dist/catalog/textFieldPreview.test.d.ts +2 -0
  8. package/dist/catalog/textFieldPreview.test.d.ts.map +1 -0
  9. package/dist/catalog/useSkoponBoundField.d.ts +2 -0
  10. package/dist/catalog/useSkoponBoundField.d.ts.map +1 -1
  11. package/dist/client/formClient.d.ts.map +1 -1
  12. package/dist/components/AskUserFormCard.d.ts +3 -1
  13. package/dist/components/AskUserFormCard.d.ts.map +1 -1
  14. package/dist/components/SkoponA2uiStreamRenderer.d.ts.map +1 -1
  15. package/dist/components/SkoponA2uiStreamRenderer.test.d.ts +2 -0
  16. package/dist/components/SkoponA2uiStreamRenderer.test.d.ts.map +1 -0
  17. package/dist/components/SkoponFormRenderer.d.ts.map +1 -1
  18. package/dist/form-sdk.css +1 -1
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +998 -667
  22. package/dist/submit/buildCurlStatement.d.ts +8 -0
  23. package/dist/submit/buildCurlStatement.d.ts.map +1 -1
  24. package/dist/submit/intersectPayloadBlocksWithForm.d.ts +26 -0
  25. package/dist/submit/intersectPayloadBlocksWithForm.d.ts.map +1 -0
  26. package/dist/submit/submitFormJson.d.ts.map +1 -1
  27. package/package.json +16 -5
  28. package/src/adapter/a2uiAdapter.test.ts +91 -0
  29. package/src/adapter/a2uiAdapter.ts +36 -7
  30. package/src/adapter/formFileAccept.test.ts +53 -0
  31. package/src/adapter/formFileAccept.ts +11 -2
  32. package/src/adapter/formSchema.test.ts +35 -0
  33. package/src/adapter/formSchema.ts +5 -1
  34. package/src/catalog/a2uiCustomCatalog.tsx +154 -5
  35. package/src/catalog/textFieldPreview.test.tsx +88 -0
  36. package/src/catalog/useSkoponBoundField.test.ts +62 -0
  37. package/src/catalog/useSkoponBoundField.ts +10 -1
  38. package/src/client/formClient.test.ts +83 -0
  39. package/src/client/formClient.ts +10 -2
  40. package/src/components/AskUserFormCard.tsx +136 -58
  41. package/src/components/SkoponA2uiStreamRenderer.test.ts +62 -0
  42. package/src/components/SkoponA2uiStreamRenderer.test.tsx +79 -0
  43. package/src/components/SkoponA2uiStreamRenderer.tsx +96 -15
  44. package/src/components/SkoponFormRenderer.tsx +10 -7
  45. package/src/index.ts +11 -2
  46. package/src/styles/index.css +5 -0
  47. package/src/submit/buildCurlStatement.ts +49 -0
  48. package/src/submit/intersectPayloadBlocksWithForm.ts +175 -0
  49. package/src/submit/submit.test.ts +170 -10
  50. package/src/submit/submitFormJson.ts +20 -1
  51. package/dist/submit/intersectPayloadWithForm.d.ts +0 -17
  52. package/dist/submit/intersectPayloadWithForm.d.ts.map +0 -1
  53. package/src/submit/intersectPayloadWithForm.ts +0 -54
package/dist/index.js CHANGED
@@ -1,36 +1,37 @@
1
- import { jsx as u, jsxs as b, Fragment as ae } from "react/jsx-runtime";
2
- import { createContext as Fe, useContext as we, useCallback as N, useSyncExternalStore as Oe, forwardRef as De, useEffect as C, useRef as M, useMemo as k, useImperativeHandle as je, useState as w } from "react";
3
- import { Catalog as Ve, MessageProcessor as le } from "@a2ui/web_core/v0_9";
4
- import { injectBasicCatalogStyles as ce } from "@a2ui/web_core/v0_9/basic_catalog";
5
- import { createBinderlessComponentImplementation as S, basicCatalog as O, A2uiSurface as se } from "@a2ui/react/v0_9";
6
- import { injectStyles as ue } from "@a2ui/react/styles";
1
+ import './form-sdk.css';
2
+ import { jsx as s, jsxs as M, Fragment as Ie } from "react/jsx-runtime";
3
+ import { createContext as We, useContext as Ze, useCallback as ie, useSyncExternalStore as Qe, forwardRef as et, useEffect as _, useRef as w, useMemo as N, useImperativeHandle as tt, useState as O } from "react";
4
+ import { Catalog as rt, MessageProcessor as Pe } from "@a2ui/web_core/v0_9";
5
+ import { injectBasicCatalogStyles as we } from "@a2ui/web_core/v0_9/basic_catalog";
6
+ import { basicCatalog as Z, createBinderlessComponentImplementation as E, A2uiSurface as Ne } from "@a2ui/react/v0_9";
7
+ import { injectStyles as _e } from "@a2ui/react/styles";
7
8
  import { z as m } from "zod";
8
- import { Typography as J, Select as H, Checkbox as ze, Radio as Le, Switch as Re, TimePicker as Ue, DatePicker as Be, Upload as ee, Tooltip as Y, Tag as te, Button as pe, Spin as Ne } from "antd";
9
- import ne from "dayjs";
10
- import { FileTextOutlined as $e, FileExcelOutlined as He, FileOutlined as me, PictureOutlined as Ye, SoundOutlined as Ge, VideoCameraOutlined as Xe } from "@ant-design/icons";
11
- const bn = "v0.9", Ke = [
9
+ import { Typography as R, Select as ue, Checkbox as nt, Radio as ot, Switch as at, TimePicker as it, DatePicker as lt, Upload as le, Input as ce, InputNumber as ct, Tooltip as Q, Tag as pe, Button as Fe, Spin as st } from "antd";
10
+ import Te from "dayjs";
11
+ import { FileTextOutlined as ut, FileExcelOutlined as pt, FileOutlined as Oe, PictureOutlined as dt, SoundOutlined as mt, VideoCameraOutlined as ft } from "@ant-design/icons";
12
+ const en = "v0.9", ht = [
12
13
  "huge",
13
14
  "large",
14
15
  "medium",
15
16
  "small",
16
17
  "icon"
17
18
  ];
18
- function G(e) {
19
+ function de(e) {
19
20
  return e === "image" || e === "video" || e === "audio";
20
21
  }
21
- function qe(e) {
22
+ function ve(e) {
22
23
  return e === "heading" || e === "paragraph";
23
24
  }
24
- function re(e) {
25
- return !qe(e) && !G(e);
25
+ function F(e) {
26
+ return !ve(e) && !de(e);
26
27
  }
27
- function Je() {
28
+ function vt() {
28
29
  if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
29
30
  return crypto.randomUUID();
30
31
  if (typeof crypto < "u" && typeof crypto.getRandomValues == "function") {
31
32
  const e = new Uint8Array(16);
32
33
  crypto.getRandomValues(e), e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
33
- const t = Array.from(e, (n) => n.toString(16).padStart(2, "0")).join("");
34
+ const t = Array.from(e, (r) => r.toString(16).padStart(2, "0")).join("");
34
35
  return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
35
36
  }
36
37
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
@@ -38,30 +39,11 @@ function Je() {
38
39
  return (e === "x" ? t : t & 3 | 8).toString(16);
39
40
  });
40
41
  }
41
- function P(e) {
42
- const t = Je().replace(/-/g, "").slice(0, 8);
42
+ function H(e) {
43
+ const t = vt().replace(/-/g, "").slice(0, 8);
43
44
  return `${e}${t}`;
44
45
  }
45
- function I(e) {
46
- return typeof e == "string" && Ke.includes(e) ? e : "medium";
47
- }
48
- function We(e, t) {
49
- var o;
50
- const n = Math.max(1, t);
51
- let r = [];
52
- return Array.isArray(e.mediaUrls) ? r = e.mediaUrls.map((a) => String(a).trim()) : (o = e.mediaUrl) != null && o.trim() && (r = [e.mediaUrl.trim()]), r.length === 0 ? [""] : r.slice(0, n);
53
- }
54
- function Ze(e) {
55
- var t;
56
- return Array.isArray(e.mediaUrls) ? e.mediaUrls.map((n) => n.trim()).filter(Boolean) : (t = e.mediaUrl) != null && t.trim() ? [e.mediaUrl.trim()] : [];
57
- }
58
- function Qe(e) {
59
- return `form-media-size-${I(e)}`;
60
- }
61
- function et(e) {
62
- return `form-media-preview form-media-list ${Qe(e)}`;
63
- }
64
- const de = [
46
+ const Ve = [
65
47
  { value: "image/*", label: "图片" },
66
48
  { value: "video/*", label: "视频" },
67
49
  { value: "audio/*", label: "音频" },
@@ -72,7 +54,7 @@ const de = [
72
54
  { value: "text/plain", label: "纯文本" },
73
55
  { value: "application/zip", label: "ZIP 压缩包" },
74
56
  { value: "application/x-rar-compressed", label: "RAR 压缩包" }
75
- ], tt = {
57
+ ], yt = {
76
58
  "image/*": ["image/*"],
77
59
  "video/*": ["video/*"],
78
60
  "audio/*": ["audio/*"],
@@ -92,7 +74,7 @@ const de = [
92
74
  "text/plain": ["text/plain"],
93
75
  "application/zip": ["application/zip"],
94
76
  "application/x-rar-compressed": ["application/x-rar-compressed"]
95
- }, nt = {
77
+ }, gt = {
96
78
  "image/*": [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg"],
97
79
  "video/*": [".mp4", ".mov", ".avi", ".webm"],
98
80
  "audio/*": [".mp3", ".wav", ".ogg", ".m4a"],
@@ -103,14 +85,14 @@ const de = [
103
85
  "text/plain": [".txt"],
104
86
  "application/zip": [".zip", ".7z"],
105
87
  "application/x-rar-compressed": [".rar"]
106
- }, rt = {
88
+ }, bt = {
107
89
  "application/msword": "office/word",
108
90
  "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "office/word",
109
91
  "application/vnd.ms-excel": "office/excel",
110
92
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "office/excel",
111
93
  "application/vnd.ms-powerpoint": "office/ppt",
112
94
  "application/vnd.openxmlformats-officedocument.presentationml.presentation": "office/ppt"
113
- }, fe = [
95
+ }, ye = [
114
96
  { value: ".jpg", label: ".jpg" },
115
97
  { value: ".jpeg", label: ".jpeg" },
116
98
  { value: ".png", label: ".png" },
@@ -136,117 +118,144 @@ const de = [
136
118
  { value: ".zip", label: ".zip" },
137
119
  { value: ".rar", label: ".rar" },
138
120
  { value: ".7z", label: ".7z" }
139
- ], ot = Object.fromEntries(
140
- de.map((e) => [e.value, e.label])
141
- ), it = Object.fromEntries(
142
- fe.map((e) => [e.value, e.label])
143
- ), at = new Set(de.map((e) => e.value));
144
- function lt(e) {
121
+ ], xt = Object.fromEntries(
122
+ Ve.map((e) => [e.value, e.label])
123
+ ), St = Object.fromEntries(
124
+ ye.map((e) => [e.value, e.label])
125
+ ), kt = new Set(Ve.map((e) => e.value)), At = new Set(
126
+ ye.map((e) => e.value)
127
+ );
128
+ function Tt(e) {
145
129
  const t = e.trim();
146
- return t ? at.has(t) ? t : rt[t] ?? null : null;
130
+ return t ? kt.has(t) ? t : bt[t] ?? null : null;
147
131
  }
148
- function ct(e) {
132
+ function Ct(e) {
149
133
  return Array.isArray(e) ? e.map((t) => {
150
- const n = t.trim().toLowerCase();
151
- return n ? n.startsWith(".") ? n : `.${n}` : "";
134
+ const r = t.trim().toLowerCase();
135
+ return r ? r.startsWith(".") ? r : `.${r}` : "";
152
136
  }).filter(Boolean) : [];
153
137
  }
154
- function L(e) {
138
+ function Y(e) {
155
139
  if (!Array.isArray(e)) return [];
156
- const t = [], n = /* @__PURE__ */ new Set();
157
- for (const r of e) {
158
- const o = lt(r);
159
- o && !n.has(o) && (n.add(o), t.push(o));
140
+ const t = [], r = /* @__PURE__ */ new Set();
141
+ for (const n of e) {
142
+ const o = Tt(n);
143
+ o && !r.has(o) && (r.add(o), t.push(o));
160
144
  }
161
145
  return t;
162
146
  }
163
- function st(e) {
164
- const t = L(e), n = [];
165
- for (const r of t)
166
- n.push(...tt[r] ?? [r]);
167
- return n;
147
+ function Mt(e) {
148
+ const t = Y(e), r = [];
149
+ for (const n of t)
150
+ r.push(...yt[n] ?? [n]);
151
+ return r;
168
152
  }
169
- function ut(e) {
170
- const t = L(e);
153
+ function Et(e) {
154
+ const t = Y(e);
171
155
  if (t.length === 0) return [];
172
- const n = /* @__PURE__ */ new Set();
173
- for (const r of t)
174
- for (const o of nt[r] ?? [])
175
- n.add(o);
176
- return fe.filter((r) => n.has(r.value));
177
- }
178
- function W(e, t) {
179
- const n = new Set(
180
- ut(e).map((r) => r.value)
156
+ const r = /* @__PURE__ */ new Set();
157
+ for (const n of t)
158
+ for (const o of gt[n] ?? [])
159
+ r.add(o);
160
+ return ye.filter((n) => r.has(n.value));
161
+ }
162
+ function ge(e, t) {
163
+ const r = Ct(t), n = Y(e);
164
+ if (n.length === 0)
165
+ return r.filter((i) => At.has(i));
166
+ const o = new Set(
167
+ Et(n).map((i) => i.value)
181
168
  );
182
- return ct(t).filter((r) => n.has(r));
169
+ return r.filter((i) => o.has(i));
183
170
  }
184
- function pt(e, t) {
185
- const n = st(e), r = W(e, t), o = [...n, ...r];
171
+ function It(e, t) {
172
+ const r = Mt(e), n = ge(e, t), o = [...r, ...n];
186
173
  return o.length > 0 ? o.join(",") : void 0;
187
174
  }
188
- function mt(e, t) {
189
- const n = L(e), r = W(
190
- n,
175
+ function Pt(e, t) {
176
+ const r = Y(e), n = ge(
177
+ r,
191
178
  t
192
179
  ), o = [
193
- ...n.map((a) => ot[a] ?? a),
194
- ...r.map((a) => it[a] ?? a)
180
+ ...r.map((i) => xt[i] ?? i),
181
+ ...n.map((i) => St[i] ?? i)
195
182
  ];
196
183
  return o.length === 0 ? null : o.join("、");
197
184
  }
198
- const dt = [
185
+ const wt = [
199
186
  "video",
200
187
  "audio",
201
188
  "image",
202
189
  "file",
203
190
  "spreadsheet",
204
191
  "document"
205
- ], ft = new Set(dt);
206
- function ht(e) {
207
- return e && ft.has(e) ? e : "file";
192
+ ], Nt = new Set(wt);
193
+ function _t(e) {
194
+ return e && Nt.has(e) ? e : "file";
208
195
  }
209
- const vt = 10;
210
- function oe(e, t = 1) {
211
- const n = typeof e == "number" ? e : Number(e);
212
- return Number.isFinite(n) ? Math.max(0, Math.floor(n)) : t;
196
+ function J(e) {
197
+ return typeof e == "string" && ht.includes(e) ? e : "medium";
198
+ }
199
+ function Ft(e, t) {
200
+ var o;
201
+ const r = Math.max(1, t);
202
+ let n = [];
203
+ return Array.isArray(e.mediaUrls) ? n = e.mediaUrls.map((i) => String(i).trim()) : (o = e.mediaUrl) != null && o.trim() && (n = [e.mediaUrl.trim()]), n.length === 0 ? [""] : n.slice(0, r);
213
204
  }
214
- function yt(e, t) {
205
+ function Ot(e) {
206
+ var t;
207
+ return Array.isArray(e.mediaUrls) ? e.mediaUrls.map((r) => r.trim()).filter(Boolean) : (t = e.mediaUrl) != null && t.trim() ? [e.mediaUrl.trim()] : [];
208
+ }
209
+ function Vt(e) {
210
+ return `form-media-size-${J(e)}`;
211
+ }
212
+ function Bt(e) {
213
+ return `form-media-preview form-media-list ${Vt(e)}`;
214
+ }
215
+ const jt = 10;
216
+ function be(e) {
217
+ return e === !0 || e === "true";
218
+ }
219
+ function Ce(e, t = 1) {
220
+ const r = typeof e == "number" ? e : Number(e);
221
+ return Number.isFinite(r) ? Math.max(0, Math.floor(r)) : t;
222
+ }
223
+ function Lt(e, t) {
215
224
  if (t !== void 0)
216
- return e === "toggle" ? t === !0 : e === "multiselect" || e === "checkbox" ? Array.isArray(t) ? t.map(String) : typeof t == "string" && t ? [t] : [] : typeof t == "boolean" ? t ? "true" : "false" : Array.isArray(t) ? t.map(String) : String(t);
225
+ return e === "toggle" ? be(t) : e === "multiselect" || e === "checkbox" ? Array.isArray(t) ? t.map(String) : typeof t == "string" && t ? [t] : [] : typeof t == "boolean" ? t ? "true" : "false" : Array.isArray(t) ? t.map(String) : String(t);
217
226
  }
218
- function bt(e) {
219
- var r, o;
220
- const t = L(e.fileAcceptTypes), n = e.type;
227
+ function zt(e) {
228
+ var n, o;
229
+ const t = Y(e.fileAcceptTypes), r = e.type;
221
230
  return {
222
- id: ((r = e.id) == null ? void 0 : r.trim()) || P("block-"),
223
- type: n,
231
+ id: ((n = e.id) == null ? void 0 : n.trim()) || H("block-"),
232
+ type: r,
224
233
  name: ((o = e.name) == null ? void 0 : o.trim()) || void 0,
225
234
  label: e.label ?? "",
226
235
  placeholder: e.placeholder ?? "",
227
236
  help: e.help ?? "",
228
237
  required: e.required === !0,
229
- mediaUrls: G(n) ? We(e, vt) : void 0,
230
- mediaSize: G(n) ? I(e.mediaSize) : void 0,
238
+ mediaUrls: de(r) ? Ft(e, jt) : void 0,
239
+ mediaSize: de(r) ? J(e.mediaSize) : void 0,
231
240
  fileAcceptTypes: t,
232
- fileAcceptExtensions: W(
241
+ fileAcceptExtensions: ge(
233
242
  t,
234
243
  e.fileAcceptExtensions
235
244
  ),
236
- filePlaceholderIcon: ht(e.filePlaceholderIcon),
237
- fileMinCount: n === "file" ? oe(e.fileMinCount, 1) : void 0,
238
- fileMaxCount: n === "file" ? oe(e.fileMaxCount, 1) : void 0,
239
- defaultValue: yt(n, e.defaultValue),
240
- options: Array.isArray(e.options) ? e.options.map((a, i) => {
245
+ filePlaceholderIcon: _t(e.filePlaceholderIcon),
246
+ fileMinCount: r === "file" ? Ce(e.fileMinCount, 1) : void 0,
247
+ fileMaxCount: r === "file" ? Ce(e.fileMaxCount, 1) : void 0,
248
+ defaultValue: Lt(r, e.defaultValue),
249
+ options: Array.isArray(e.options) ? e.options.map((i, a) => {
241
250
  var l, c;
242
251
  return {
243
- value: ((l = a.value) == null ? void 0 : l.trim()) || `option_${i + 1}`,
244
- label: ((c = a.label) == null ? void 0 : c.trim()) || `选项 ${i + 1}`
252
+ value: ((l = i.value) == null ? void 0 : l.trim()) || `option_${a + 1}`,
253
+ label: ((c = i.label) == null ? void 0 : c.trim()) || `选项 ${a + 1}`
245
254
  };
246
255
  }) : void 0
247
256
  };
248
257
  }
249
- function D(e) {
258
+ function ee(e) {
250
259
  return {
251
260
  title: e.title ?? "",
252
261
  description: e.description ?? "",
@@ -254,153 +263,176 @@ function D(e) {
254
263
  jsonSchema: e.jsonSchema ?? {}
255
264
  };
256
265
  }
257
- function he(e) {
266
+ function B(e) {
258
267
  if (!e || !Array.isArray(e.blocks))
259
- return D({ title: "", description: "", blocks: [], jsonSchema: {} });
260
- const t = e.blocks.map(bt);
261
- return D({
268
+ return ee({ title: "", description: "", blocks: [], jsonSchema: {} });
269
+ const t = e.blocks.map(zt);
270
+ return ee({
262
271
  title: typeof e.title == "string" ? e.title : "",
263
272
  description: typeof e.description == "string" ? e.description : "",
264
273
  blocks: t,
265
274
  jsonSchema: {}
266
275
  });
267
276
  }
268
- const j = "root", X = "__title__", K = "__desc__", ve = "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$";
269
- function gt(e) {
277
+ const te = "root", me = "__title__", fe = "__desc__", Be = "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$";
278
+ function Ut(e) {
270
279
  return `/${e}`;
271
280
  }
272
- function xt(e) {
281
+ function $t(e) {
273
282
  return e && typeof e == "object" && "path" in e ? String(e.path ?? "").replace(/^\//, "") : "";
274
283
  }
275
- function y(e) {
284
+ function S(e) {
276
285
  if (typeof e == "string") return e;
277
286
  }
278
- function St(e) {
279
- const t = e.id || P("a2-"), n = e.type === "video" ? "video" : e.type === "audio" ? "audio" : "image";
287
+ function Rt(e) {
288
+ const t = e.id || H("a2-"), r = e.type === "video" ? "video" : e.type === "audio" ? "audio" : "image";
280
289
  return {
281
290
  id: t,
282
291
  component: "SkoponMedia",
283
- mediaType: n,
284
- urls: Ze(e),
285
- mediaSize: I(e.mediaSize),
292
+ mediaType: r,
293
+ urls: Ot(e),
294
+ mediaSize: J(e.mediaSize),
286
295
  label: e.label ?? "",
287
296
  help: e.help ?? "",
288
297
  placeholder: e.placeholder ?? ""
289
298
  };
290
299
  }
291
- function At(e) {
300
+ function Dt(e) {
292
301
  if (Array.isArray(e.urls))
293
- return e.urls.map((n) => String(n).trim()).filter(Boolean);
294
- const t = y(e.url);
302
+ return e.urls.map((r) => String(r).trim()).filter(Boolean);
303
+ const t = S(e.url);
295
304
  return t != null && t.trim() ? [t.trim()] : [];
296
305
  }
297
- function F(e, t, n) {
298
- const r = typeof e.id == "string" ? e.id : P("block-"), o = At(e), a = y(e.label) ?? y(e.description) ?? n, i = y(e.help), l = y(e.placeholder), c = I(e.mediaSize);
306
+ function K(e, t, r) {
307
+ const n = typeof e.id == "string" ? e.id : H("block-"), o = Dt(e), i = S(e.label) ?? S(e.description) ?? r, a = S(e.help), l = S(e.placeholder), c = J(e.mediaSize);
299
308
  return {
300
- id: r,
309
+ id: n,
301
310
  type: t,
302
- label: a,
303
- ...i ? { help: i } : {},
311
+ label: i,
312
+ ...a ? { help: a } : {},
304
313
  ...l ? { placeholder: l } : {},
305
314
  mediaSize: c,
306
315
  mediaUrls: o.length > 0 ? o : [""]
307
316
  };
308
317
  }
309
- function kt(e) {
318
+ function Ht(e) {
310
319
  switch (e.type) {
311
320
  case "toggle":
312
- return typeof e.defaultValue == "boolean" ? e.defaultValue : !1;
321
+ return be(e.defaultValue);
313
322
  case "multiselect":
314
323
  case "checkbox":
324
+ return Array.isArray(e.defaultValue) ? e.defaultValue : typeof e.defaultValue == "string" && e.defaultValue ? [e.defaultValue] : [];
315
325
  case "select":
316
326
  case "radio":
317
- return Array.isArray(e.defaultValue) ? e.defaultValue : typeof e.defaultValue == "string" && e.defaultValue ? [e.defaultValue] : [];
327
+ return Array.isArray(e.defaultValue) ? e.defaultValue[0] ?? "" : typeof e.defaultValue == "string" ? e.defaultValue : "";
318
328
  default:
319
329
  return typeof e.defaultValue == "string" ? e.defaultValue : "";
320
330
  }
321
331
  }
322
- function Tt(e) {
332
+ function Yt(e) {
323
333
  var l;
324
- const t = e.id || P("a2-"), n = e.label ?? "", r = ((l = e.name) == null ? void 0 : l.trim()) || "", o = r ? gt(r) : void 0, a = (e.options ?? []).map((c) => ({ label: c.label, value: c.value })), i = (c) => r ? { node: c, dataKey: r, dataValue: kt(e) } : { node: c };
334
+ const t = e.id || H("a2-"), r = e.label ?? "", n = ((l = e.name) == null ? void 0 : l.trim()) || "", o = n ? Ut(n) : void 0, i = (e.options ?? []).map((c) => ({ label: c.label, value: c.value })), a = (c) => n ? { node: c, dataKey: n, dataValue: Ht(e) } : { node: c };
325
335
  switch (e.type) {
326
336
  case "heading":
327
- return { node: { id: t, component: "Text", text: n, variant: "h3" } };
337
+ return { node: { id: t, component: "Text", text: r, variant: "h3" } };
328
338
  case "paragraph":
329
- return { node: { id: t, component: "Text", text: n, variant: "body" } };
339
+ return { node: { id: t, component: "Text", text: r, variant: "body" } };
330
340
  case "text":
331
341
  case "tel":
332
342
  case "url":
333
- return i({ id: t, component: "TextField", label: n, variant: "shortText", value: { path: o } });
343
+ return a({
344
+ id: t,
345
+ component: "TextField",
346
+ label: r,
347
+ variant: "shortText",
348
+ ...e.placeholder ? { placeholder: e.placeholder } : {},
349
+ value: { path: o }
350
+ });
334
351
  case "email":
335
- return i({
352
+ return a({
336
353
  id: t,
337
354
  component: "TextField",
338
- label: n,
355
+ label: r,
339
356
  variant: "shortText",
340
- validationRegexp: ve,
357
+ validationRegexp: Be,
358
+ ...e.placeholder ? { placeholder: e.placeholder } : {},
341
359
  value: { path: o }
342
360
  });
343
361
  case "textarea":
344
- return i({ id: t, component: "TextField", label: n, variant: "longText", value: { path: o } });
362
+ return a({
363
+ id: t,
364
+ component: "TextField",
365
+ label: r,
366
+ variant: "longText",
367
+ ...e.placeholder ? { placeholder: e.placeholder } : {},
368
+ value: { path: o }
369
+ });
345
370
  case "number":
346
- return i({ id: t, component: "TextField", label: n, variant: "number", value: { path: o } });
371
+ return a({
372
+ id: t,
373
+ component: "TextField",
374
+ label: r,
375
+ variant: "number",
376
+ ...e.placeholder ? { placeholder: e.placeholder } : {},
377
+ value: { path: o }
378
+ });
347
379
  case "select":
348
- return i({
380
+ return a({
349
381
  id: t,
350
382
  component: "SkoponSelect",
351
- label: n,
383
+ label: r,
352
384
  mode: "single",
353
385
  placeholder: e.placeholder ?? "",
354
- options: a,
386
+ options: i,
355
387
  value: { path: o }
356
388
  });
357
389
  case "radio":
358
- return i({
390
+ return a({
359
391
  id: t,
360
392
  component: "ChoicePicker",
361
- label: n,
393
+ label: r,
362
394
  variant: "mutuallyExclusive",
363
395
  skoponPickerType: "radio",
364
- options: a,
396
+ options: i,
365
397
  value: { path: o }
366
398
  });
367
399
  case "multiselect":
368
- return i({
400
+ return a({
369
401
  id: t,
370
402
  component: "SkoponSelect",
371
- label: n,
403
+ label: r,
372
404
  mode: "multiple",
373
405
  placeholder: e.placeholder ?? "",
374
- options: a,
406
+ options: i,
375
407
  value: { path: o }
376
408
  });
377
409
  case "checkbox":
378
- return i({
410
+ return a({
379
411
  id: t,
380
412
  component: "ChoicePicker",
381
- label: n,
413
+ label: r,
382
414
  variant: "multipleSelection",
383
415
  skoponPickerType: "checkbox",
384
- options: a,
416
+ options: i,
385
417
  value: { path: o }
386
418
  });
387
419
  case "toggle":
388
- return i({ id: t, component: "CheckBox", label: n, value: { path: o } });
420
+ return a({ id: t, component: "CheckBox", label: r, value: { path: o } });
389
421
  case "datetime":
390
- return i({
422
+ return a({
391
423
  id: t,
392
424
  component: "DateTimeInput",
393
- label: n,
425
+ label: r,
394
426
  enableDate: !0,
395
427
  enableTime: !0,
396
428
  placeholder: e.placeholder ?? "",
397
429
  value: { path: o }
398
430
  });
399
431
  case "time":
400
- return i({
432
+ return a({
401
433
  id: t,
402
434
  component: "DateTimeInput",
403
- label: n,
435
+ label: r,
404
436
  enableTime: !0,
405
437
  placeholder: e.placeholder ?? "",
406
438
  value: { path: o }
@@ -408,12 +440,12 @@ function Tt(e) {
408
440
  case "image":
409
441
  case "video":
410
442
  case "audio":
411
- return { node: St(e) };
443
+ return { node: Rt(e) };
412
444
  case "file":
413
- return i({
445
+ return a({
414
446
  id: t,
415
447
  component: "FileUpload",
416
- label: n,
448
+ label: r,
417
449
  accept: (e.fileAcceptExtensions ?? []).join(","),
418
450
  fileAcceptTypes: e.fileAcceptTypes ?? [],
419
451
  filePlaceholderIcon: e.filePlaceholderIcon ?? "document",
@@ -425,347 +457,491 @@ function Tt(e) {
425
457
  return { node: null };
426
458
  }
427
459
  }
428
- function q(e) {
460
+ function he(e) {
429
461
  if (!e || !Array.isArray(e.components) || e.components.length === 0) return !0;
430
- const t = e.components.find((r) => r.id === j);
462
+ const t = e.components.find((n) => n.id === te);
431
463
  if (!t) return e.components.length === 0;
432
- const n = t.children;
433
- return !Array.isArray(n) || n.length === 0;
434
- }
435
- function ye(e, t) {
436
- const n = [], r = [], o = {}, a = (t == null ? void 0 : t.includeHeader) !== !1, i = (e.title ?? "").trim(), l = (e.description ?? "").trim();
437
- a && i && (n.push({ id: X, component: "Text", text: i, variant: "h2" }), r.push(X)), a && l && (n.push({ id: K, component: "Text", text: l, variant: "body" }), r.push(K));
438
- for (const p of e.blocks ?? []) {
439
- const { node: d, dataKey: f, dataValue: h } = Tt(p);
440
- d && (n.push(d), r.push(d.id), f && (o[f] = h));
464
+ const r = t.children;
465
+ return !Array.isArray(r) || r.length === 0;
466
+ }
467
+ function je(e, t) {
468
+ const r = [], n = [], o = {}, i = (t == null ? void 0 : t.includeHeader) !== !1, a = (e.title ?? "").trim(), l = (e.description ?? "").trim();
469
+ i && a && (r.push({ id: me, component: "Text", text: a, variant: "h2" }), n.push(me)), i && l && (r.push({ id: fe, component: "Text", text: l, variant: "body" }), n.push(fe));
470
+ for (const f of e.blocks ?? []) {
471
+ const { node: d, dataKey: p, dataValue: y } = Yt(f);
472
+ d && (r.push(d), n.push(d.id), p && (o[p] = y));
441
473
  }
442
- n.unshift({ id: j, component: "Column", children: r });
443
- const c = { root: j, components: n, dataModel: o }, s = t == null ? void 0 : t.styleId;
444
- return s !== void 0 && (c.surfaceProperties = { styleId: s ?? null }), c;
474
+ r.unshift({ id: te, component: "Column", children: n });
475
+ const c = { root: te, components: r, dataModel: o }, u = t == null ? void 0 : t.styleId;
476
+ return u !== void 0 && (c.surfaceProperties = { styleId: u ?? null }), c;
445
477
  }
446
- function Ct(e) {
478
+ function Jt(e) {
447
479
  const t = /* @__PURE__ */ new Map();
448
- for (const n of e.components ?? [])
449
- n && typeof n.id == "string" && t.set(n.id, n);
480
+ for (const r of e.components ?? [])
481
+ r && typeof r.id == "string" && t.set(r.id, r);
450
482
  return t;
451
483
  }
452
- function $(e) {
484
+ function se(e) {
453
485
  const t = e.options;
454
- return Array.isArray(t) ? t.map((n) => {
455
- if (!n || typeof n != "object") return null;
456
- const r = n;
486
+ return Array.isArray(t) ? t.map((r) => {
487
+ if (!r || typeof r != "object") return null;
488
+ const n = r;
457
489
  return {
458
- value: String(r.value ?? r.label ?? ""),
459
- label: String(r.label ?? r.value ?? "")
490
+ value: String(n.value ?? n.label ?? ""),
491
+ label: String(n.label ?? n.value ?? "")
460
492
  };
461
- }).filter((n) => !!n) : [];
493
+ }).filter((r) => !!r) : [];
462
494
  }
463
- function Mt(e) {
464
- const t = typeof e.id == "string" ? e.id : P("block-"), n = String(e.component ?? ""), r = y(e.label) ?? y(e.text) ?? "", o = xt(e.value), a = (i) => ({ id: t, type: i, label: r });
465
- switch (n) {
495
+ function Gt(e) {
496
+ const t = typeof e.id == "string" ? e.id : H("block-"), r = String(e.component ?? ""), n = S(e.label) ?? S(e.text) ?? "", o = $t(e.value), i = (a) => ({ id: t, type: a, label: n });
497
+ switch (r) {
466
498
  case "Text": {
467
- const i = String(e.variant ?? "body"), l = /^h[1-6]$/i.test(i) || i === "title" || i === "subtitle";
468
- return { id: t, type: l ? "heading" : "paragraph", label: r };
499
+ const a = String(e.variant ?? "body"), l = /^h[1-6]$/i.test(a) || a === "title" || a === "subtitle";
500
+ return { id: t, type: l ? "heading" : "paragraph", label: n };
469
501
  }
470
502
  case "TextField": {
471
- const i = String(e.variant ?? "shortText");
503
+ const a = String(e.variant ?? "shortText");
472
504
  let l = "text";
473
- return i === "longText" ? l = "textarea" : i === "number" ? l = "number" : y(e.validationRegexp) === ve && (l = "email"), { ...a(l), name: o };
505
+ a === "longText" ? l = "textarea" : a === "number" ? l = "number" : S(e.validationRegexp) === Be && (l = "email");
506
+ const c = { ...i(l), name: o }, u = S(e.placeholder);
507
+ return u && (c.placeholder = u), c;
474
508
  }
475
509
  case "CheckBox":
476
- return { ...a("toggle"), name: o };
510
+ return { ...i("toggle"), name: o };
477
511
  case "SkoponSelect": {
478
512
  const l = String(e.mode ?? "single") === "multiple" ? "multiselect" : "select", c = {
479
- ...a(l),
513
+ ...i(l),
480
514
  name: o,
481
- options: $(e)
482
- }, s = y(e.placeholder);
483
- return s && (c.placeholder = s), c;
515
+ options: se(e)
516
+ }, u = S(e.placeholder);
517
+ return u && (c.placeholder = u), c;
484
518
  }
485
519
  case "ChoicePicker": {
486
- const i = y(e.skoponPickerType);
487
- if (i === "select" || i === "multiselect" || i === "radio" || i === "checkbox") {
488
- const s = {
489
- ...a(i),
520
+ const a = S(e.skoponPickerType);
521
+ if (a === "select" || a === "multiselect" || a === "radio" || a === "checkbox") {
522
+ const u = {
523
+ ...i(a),
490
524
  name: o,
491
- options: $(e)
492
- }, p = y(e.placeholder);
493
- return p && (s.placeholder = p), s;
525
+ options: se(e)
526
+ }, f = S(e.placeholder);
527
+ return f && (u.placeholder = f), u;
494
528
  }
495
529
  const c = String(e.variant ?? "mutuallyExclusive") === "multipleSelection" ? "checkbox" : "radio";
496
- return { ...a(c), name: o, options: $(e) };
530
+ return { ...i(c), name: o, options: se(e) };
497
531
  }
498
532
  case "DateTimeInput": {
499
- const i = e.enableDate === !0, l = e.enableTime === !0, s = { ...a(!i && l ? "time" : "datetime"), name: o }, p = y(e.placeholder);
500
- return p && (s.placeholder = p), s;
533
+ const a = e.enableDate === !0, l = e.enableTime === !0, u = { ...i(!a && l ? "time" : "datetime"), name: o }, f = S(e.placeholder);
534
+ return f && (u.placeholder = f), u;
501
535
  }
502
536
  case "SkoponMedia": {
503
- const i = String(e.mediaType ?? "image");
504
- return F(e, i === "video" ? "video" : i === "audio" ? "audio" : "image", r);
537
+ const a = String(e.mediaType ?? "image");
538
+ return K(e, a === "video" ? "video" : a === "audio" ? "audio" : "image", n);
505
539
  }
506
540
  case "Image":
507
- return F(e, "image", r);
541
+ return K(e, "image", n);
508
542
  case "Video":
509
- return F(e, "video", r);
543
+ return K(e, "video", n);
510
544
  case "AudioPlayer":
511
- return F(e, "audio", r);
545
+ return K(e, "audio", n);
512
546
  case "FileUpload": {
513
- const i = y(e.accept) ?? "", l = { ...a("file"), name: o };
514
- return i && (l.fileAcceptExtensions = i.split(",").map((c) => c.trim()).filter(Boolean)), Array.isArray(e.fileAcceptTypes) && (l.fileAcceptTypes = e.fileAcceptTypes.map(String)), typeof e.filePlaceholderIcon == "string" && (l.filePlaceholderIcon = e.filePlaceholderIcon), typeof e.minCount == "number" && (l.fileMinCount = e.minCount), typeof e.maxCount == "number" && (l.fileMaxCount = e.maxCount), l;
547
+ const a = S(e.accept) ?? "", l = { ...i("file"), name: o };
548
+ return a && (l.fileAcceptExtensions = a.split(",").map((c) => c.trim()).filter(Boolean)), Array.isArray(e.fileAcceptTypes) && (l.fileAcceptTypes = e.fileAcceptTypes.map(String)), typeof e.filePlaceholderIcon == "string" && (l.filePlaceholderIcon = e.filePlaceholderIcon), typeof e.minCount == "number" && (l.fileMinCount = e.minCount), typeof e.maxCount == "number" && (l.fileMaxCount = e.maxCount), l;
515
549
  }
516
550
  default:
517
551
  return null;
518
552
  }
519
553
  }
520
- function be(e, t, n, r) {
521
- if (n.has(e)) return;
522
- n.add(e);
554
+ function Le(e, t, r, n) {
555
+ if (r.has(e)) return;
556
+ r.add(e);
523
557
  const o = t.get(e);
524
558
  if (!o) return;
525
- const a = String(o.component ?? "");
526
- if ((a === "Column" || a === "Row") && Array.isArray(o.children)) {
527
- for (const i of o.children)
528
- typeof i == "string" && be(i, t, n, r);
559
+ const i = String(o.component ?? "");
560
+ if ((i === "Column" || i === "Row") && Array.isArray(o.children)) {
561
+ for (const a of o.children)
562
+ typeof a == "string" && Le(a, t, r, n);
529
563
  return;
530
564
  }
531
- r.push(o);
565
+ n.push(o);
532
566
  }
533
- function Pt(e) {
567
+ function Xt(e) {
534
568
  if (!e || !Array.isArray(e.components))
535
- return D({ title: "", description: "", blocks: [], jsonSchema: {} });
536
- const t = Ct(e), n = [];
537
- be(e.root ?? j, t, /* @__PURE__ */ new Set(), n);
538
- let r = "", o = "";
539
- const a = [];
540
- for (const i of n) {
541
- if (i.id === X) {
542
- r = y(i.text) ?? r;
569
+ return ee({ title: "", description: "", blocks: [], jsonSchema: {} });
570
+ const t = Jt(e), r = [];
571
+ Le(e.root ?? te, t, /* @__PURE__ */ new Set(), r);
572
+ let n = "", o = "";
573
+ const i = [];
574
+ for (const a of r) {
575
+ if (a.id === me) {
576
+ n = S(a.text) ?? n;
543
577
  continue;
544
578
  }
545
- if (i.id === K) {
546
- o = y(i.text) ?? o;
579
+ if (a.id === fe) {
580
+ o = S(a.text) ?? o;
547
581
  continue;
548
582
  }
549
- const l = Mt(i);
550
- l && a.push(l);
583
+ const l = Gt(a);
584
+ l && i.push(l);
551
585
  }
552
- return D({ title: r, description: o, blocks: a, jsonSchema: {} });
586
+ return ee({ title: n, description: o, blocks: i, jsonSchema: {} });
553
587
  }
554
- function It(e, t) {
555
- const { surfaceId: n, catalogId: r } = t, o = [
556
- { version: "v0.9", createSurface: { surfaceId: n, catalogId: r } },
588
+ function qt(e, t) {
589
+ const { surfaceId: r, catalogId: n } = t, o = [
590
+ { version: "v0.9", createSurface: { surfaceId: r, catalogId: n } },
557
591
  {
558
592
  version: "v0.9",
559
- updateComponents: { surfaceId: n, components: e.components }
593
+ updateComponents: { surfaceId: r, components: e.components }
560
594
  }
561
595
  ];
562
596
  return e.dataModel && Object.keys(e.dataModel).length > 0 && o.push({
563
597
  version: "v0.9",
564
- updateDataModel: { surfaceId: n, path: "/", value: e.dataModel }
598
+ updateDataModel: { surfaceId: r, path: "/", value: e.dataModel }
565
599
  }), o;
566
600
  }
567
- function ge(e) {
601
+ function ze(e) {
568
602
  return !!e && typeof e == "object" && !Array.isArray(e) && Array.isArray(e.components);
569
603
  }
570
- function Et(e, t) {
604
+ function Kt(e, t) {
571
605
  if (!e || typeof e != "object") return null;
572
- const n = e, r = ge(n.a2ui) ? n.a2ui : void 0;
573
- if (r && !q(r)) return r;
574
- const o = Array.isArray(n.blocks) ? n.blocks : [];
606
+ const r = e, n = ze(r.a2ui) ? r.a2ui : void 0;
607
+ if (n && !he(n)) return n;
608
+ const o = Array.isArray(r.blocks) ? r.blocks : [];
575
609
  if (o.length === 0) return null;
576
- const a = he({
577
- title: typeof n.title == "string" ? n.title : "",
578
- description: typeof n.description == "string" ? n.description : "",
610
+ const i = B({
611
+ title: typeof r.title == "string" ? r.title : "",
612
+ description: typeof r.description == "string" ? r.description : "",
579
613
  blocks: o
580
- }), i = ye(a, t);
581
- return q(i) ? null : i;
614
+ }), a = je(i, t);
615
+ return he(a) ? null : a;
582
616
  }
583
- function _t(e, t, n) {
584
- return ye(
617
+ function Wt(e, t, r) {
618
+ return je(
585
619
  {
586
620
  title: e.title,
587
621
  description: e.description,
588
622
  blocks: t
589
623
  },
590
- n
624
+ r
591
625
  );
592
626
  }
593
- function Ft(e) {
627
+ function Zt(e) {
594
628
  if (!e || typeof e != "object" || Array.isArray(e))
595
629
  return;
596
630
  const t = e;
597
- return !(Array.isArray(t.blocks) && t.blocks.length > 0) && ge(t.a2ui) ? Pt(t.a2ui) : he({
631
+ return !(Array.isArray(t.blocks) && t.blocks.length > 0) && ze(t.a2ui) ? Xt(t.a2ui) : B({
598
632
  title: typeof t.title == "string" ? t.title : "",
599
633
  description: typeof t.description == "string" ? t.description : "",
600
634
  blocks: Array.isArray(t.blocks) ? t.blocks : []
601
635
  });
602
636
  }
603
- function wt(e, t, n) {
604
- const r = e.model.surfacesMap.get(t);
605
- if (!r) return {};
637
+ function Qt(e, t, r) {
638
+ const n = e.model.surfacesMap.get(t);
639
+ if (!n) return {};
606
640
  const o = {};
607
- for (const a of n) {
608
- const i = a.trim();
609
- i && (o[i] = r.dataModel.get(`/${i}`));
641
+ for (const i of r) {
642
+ const a = i.trim();
643
+ a && (o[a] = n.dataModel.get(`/${a}`));
610
644
  }
611
645
  return o;
612
646
  }
613
- function Ot(e) {
647
+ function Ue(e) {
614
648
  return e.replace(/'/g, "'\\''");
615
649
  }
616
- function xe(e, t) {
617
- const n = (t ?? "").trim() || "<callback_url>", r = JSON.stringify(e ?? {}, null, 2);
650
+ function er(e, t) {
651
+ const r = (t ?? "").trim() || "<callback_url>", n = JSON.stringify(e ?? {}, null, 2);
652
+ return [
653
+ `curl -X POST '${r}' \\`,
654
+ " -H 'Content-Type: application/json' \\",
655
+ ` -d '${Ue(n)}'`
656
+ ].join(`
657
+ `);
658
+ }
659
+ function Me(e, t, r) {
660
+ return ` ${JSON.stringify(e)}: ${JSON.stringify(t)}${r ? "," : ""}`;
661
+ }
662
+ function tr(e, t) {
663
+ const r = ["{"], n = Object.entries(e), o = Object.entries(t);
664
+ return n.forEach(([i, a], l) => {
665
+ const c = l < n.length - 1 || o.length > 0;
666
+ r.push(Me(i, a, c));
667
+ }), o.length > 0 && (r.push(" // 额外字段(未在卡片展示)"), o.forEach(([i, a], l) => {
668
+ r.push(Me(i, a, l < o.length - 1));
669
+ })), r.push("}"), r.join(`
670
+ `);
671
+ }
672
+ function rr({
673
+ cardValues: e,
674
+ extraValues: t = {},
675
+ callbackUrl: r
676
+ }) {
677
+ const n = (r ?? "").trim() || "<callback_url>", o = tr(e, t);
618
678
  return [
619
679
  `curl -X POST '${n}' \\`,
620
680
  " -H 'Content-Type: application/json' \\",
621
- ` -d '${Ot(r)}'`
681
+ ` -d '${Ue(o)}'`
622
682
  ].join(`
623
683
  `);
624
684
  }
625
- function Dt(e) {
626
- return !e || typeof e != "object" || Array.isArray(e) ? [] : Object.keys(e);
627
- }
628
- function jt(e, t) {
629
- const n = Dt(e), r = e ?? {}, o = (t == null ? void 0 : t.blocks) ?? [], a = new Set(
630
- o.filter((c) => {
631
- var s;
632
- return re(c.type) && ((s = c.name) == null ? void 0 : s.trim());
633
- }).map((c) => c.name.trim())
634
- ), i = o.filter(
635
- (c) => {
636
- var s;
637
- return re(c.type) && ((s = c.name) == null ? void 0 : s.trim()) && n.includes(c.name.trim());
685
+ function nr(e) {
686
+ return B({
687
+ title: "",
688
+ description: "",
689
+ blocks: [e]
690
+ }).blocks[0];
691
+ }
692
+ function or(e, t) {
693
+ var o, i;
694
+ const r = /* @__PURE__ */ new Map();
695
+ for (const a of t) {
696
+ const l = (o = a.name) == null ? void 0 : o.trim();
697
+ l && r.set(l, a);
698
+ }
699
+ const n = [];
700
+ for (const a of e.blocks) {
701
+ if (ve(a.type)) {
702
+ n.push(nr(a));
703
+ continue;
638
704
  }
639
- ), l = {};
640
- for (const c of n)
641
- a.has(c) || (l[c] = r[c]);
642
- return { matchedBlocks: i, remainderPayload: l };
643
- }
644
- async function Vt(e, t, n) {
645
- const r = e.trim();
646
- if (!r)
705
+ if (!F(a.type)) continue;
706
+ const l = (i = a.name) == null ? void 0 : i.trim();
707
+ if (!l) continue;
708
+ const c = r.get(l);
709
+ c && n.push(c);
710
+ }
711
+ return n;
712
+ }
713
+ function ar(e, t) {
714
+ var n;
715
+ const r = {
716
+ ...e,
717
+ name: ((n = e.name) == null ? void 0 : n.trim()) || t.name
718
+ };
719
+ return t.defaultValue !== void 0 && (r.defaultValue = t.defaultValue), B({
720
+ title: "",
721
+ description: "",
722
+ blocks: [r]
723
+ }).blocks[0];
724
+ }
725
+ function ir(e) {
726
+ if (!e || typeof e != "object" || Array.isArray(e)) return null;
727
+ const t = e;
728
+ return Array.isArray(t.blocks) ? B({
729
+ title: typeof t.title == "string" ? t.title : "",
730
+ description: typeof t.description == "string" ? t.description : "",
731
+ blocks: t.blocks
732
+ }) : null;
733
+ }
734
+ function lr(e, t) {
735
+ var i, a, l, c, u, f;
736
+ const r = /* @__PURE__ */ new Map();
737
+ for (const d of (t == null ? void 0 : t.blocks) ?? [])
738
+ F(d.type) && ((i = d.name) != null && i.trim()) && r.set(d.name.trim(), d);
739
+ const n = [], o = [];
740
+ for (const d of e.blocks) {
741
+ if (!F(d.type)) continue;
742
+ const p = (a = d.name) == null ? void 0 : a.trim();
743
+ if (!p) continue;
744
+ const y = r.get(p);
745
+ y ? n.push(ar(y, d)) : o.push(
746
+ B({
747
+ title: "",
748
+ description: "",
749
+ blocks: [d]
750
+ }).blocks[0]
751
+ );
752
+ }
753
+ return {
754
+ matchedBlocks: n,
755
+ extraBlocks: o,
756
+ renderBlocks: or(e, n),
757
+ title: ((l = e.title) == null ? void 0 : l.trim()) || ((c = t == null ? void 0 : t.title) == null ? void 0 : c.trim()) || "",
758
+ description: ((u = e.description) == null ? void 0 : u.trim()) || ((f = t == null ? void 0 : t.description) == null ? void 0 : f.trim()) || ""
759
+ };
760
+ }
761
+ function cr(e) {
762
+ const { type: t, defaultValue: r } = e;
763
+ return r !== void 0 ? t === "toggle" ? r === !0 || r === "true" : t === "multiselect" || t === "checkbox" ? Array.isArray(r) ? r.map(String) : typeof r == "string" && r ? [r] : [] : r : t === "toggle" ? !1 : t === "multiselect" || t === "checkbox" ? [] : t === "number" ? null : "";
764
+ }
765
+ function sr(e) {
766
+ var r;
767
+ const t = {};
768
+ for (const n of e) {
769
+ if (!F(n.type)) continue;
770
+ const o = (r = n.name) == null ? void 0 : r.trim();
771
+ o && (t[o] = cr(n));
772
+ }
773
+ return t;
774
+ }
775
+ function ur(e) {
776
+ return e.blocks.some(
777
+ (t) => {
778
+ var r;
779
+ return F(t.type) && !!((r = t.name) != null && r.trim());
780
+ }
781
+ );
782
+ }
783
+ function pr(e) {
784
+ return e.blocks.filter((t) => {
785
+ var r;
786
+ return ve(t.type) ? !0 : F(t.type) && !!((r = t.name) != null && r.trim());
787
+ });
788
+ }
789
+ function dr(e) {
790
+ return e.blocks.filter((t) => {
791
+ var r;
792
+ return F(t.type) && ((r = t.name) == null ? void 0 : r.trim());
793
+ }).map((t) => t.name.trim());
794
+ }
795
+ async function mr(e, t, r) {
796
+ const n = e.trim();
797
+ if (!n)
647
798
  throw new Error("callback_url 为空");
648
- const a = await ((n == null ? void 0 : n.fetch) ?? fetch)(r, {
799
+ const i = await ((r == null ? void 0 : r.fetch) ?? fetch)(n, {
649
800
  method: "POST",
650
801
  headers: {
651
802
  "Content-Type": "application/json",
652
- ...(n == null ? void 0 : n.headers) ?? {}
803
+ ...(r == null ? void 0 : r.headers) ?? {}
653
804
  },
654
805
  body: JSON.stringify(t ?? {})
655
806
  });
656
- let i;
657
- if ((a.headers.get("content-type") ?? "").includes("application/json"))
807
+ let a;
808
+ if ((i.headers.get("content-type") ?? "").includes("application/json"))
658
809
  try {
659
- i = await a.json();
810
+ a = await i.json();
660
811
  } catch {
661
- i = void 0;
812
+ a = void 0;
662
813
  }
663
814
  else
664
815
  try {
665
- i = await a.text();
816
+ a = await i.text();
666
817
  } catch {
667
- i = void 0;
818
+ a = void 0;
668
819
  }
669
- return { ok: a.ok, status: a.status, body: i };
820
+ return { ok: i.ok, status: i.status, body: a };
670
821
  }
671
- async function Se(e) {
672
- await navigator.clipboard.writeText(e);
822
+ async function $e(e) {
823
+ var r;
824
+ if (typeof navigator < "u" && ((r = navigator.clipboard) != null && r.writeText)) {
825
+ await navigator.clipboard.writeText(e);
826
+ return;
827
+ }
828
+ if (typeof document > "u")
829
+ throw new Error("clipboard unavailable");
830
+ const t = document.createElement("textarea");
831
+ t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.left = "-9999px", document.body.appendChild(t), t.select();
832
+ try {
833
+ if (!document.execCommand("copy")) throw new Error("execCommand copy failed");
834
+ } finally {
835
+ document.body.removeChild(t);
836
+ }
673
837
  }
674
- async function zt(e) {
675
- const t = await e.json();
838
+ async function fr(e) {
839
+ let t;
840
+ try {
841
+ t = await e.json();
842
+ } catch {
843
+ throw new Error(`响应非 JSON (${e.status})`);
844
+ }
676
845
  if (!e.ok || t.success === !1)
677
846
  throw new Error(t.message || `请求失败 (${e.status})`);
847
+ if (t.data === void 0 || t.data === null)
848
+ throw new Error(t.message || `响应缺少 data (${e.status})`);
678
849
  return t.data;
679
850
  }
680
- function gn(e = {}) {
681
- const t = (e.baseUrl ?? "/api/v1").replace(/\/$/, ""), n = e.detailPath ?? "/dev/form/detail", r = e.fetch ?? fetch;
682
- async function o(a) {
851
+ function tn(e = {}) {
852
+ const t = (e.baseUrl ?? "/api/v1").replace(/\/$/, ""), r = e.detailPath ?? "/dev/form/detail", n = e.fetch ?? fetch;
853
+ async function o(i) {
683
854
  var d;
684
- const i = new URLSearchParams();
685
- if (a.formId !== void 0)
686
- i.set("form_id", String(a.formId));
687
- else if (a.formUniqueId)
688
- i.set("form_unique_id", a.formUniqueId);
855
+ const a = new URLSearchParams();
856
+ if (i.formId !== void 0)
857
+ a.set("form_id", String(i.formId));
858
+ else if (i.formUniqueId)
859
+ a.set("form_unique_id", i.formUniqueId);
689
860
  else
690
861
  throw new Error("form_id 或 form_unique_id 至少传一个");
691
- const l = await ((d = e.getHeaders) == null ? void 0 : d.call(e)) ?? {}, c = await r(`${t}${n}?${i.toString()}`, {
862
+ const l = await ((d = e.getHeaders) == null ? void 0 : d.call(e)) ?? {}, c = await n(`${t}${r}?${a.toString()}`, {
692
863
  method: "GET",
693
864
  headers: l
694
- }), s = await zt(c), p = Ft(s.form_definition);
865
+ }), u = await fr(c), f = Zt(u.form_definition);
695
866
  return {
696
- formUniqueId: s.form_unique_id,
697
- formId: s.form_id,
698
- disabled: s.disabled === 1,
699
- formDefinition: p,
700
- a2ui: Et(s.form_definition) ?? void 0
867
+ formUniqueId: u.form_unique_id,
868
+ formId: u.form_id,
869
+ disabled: u.disabled === 1,
870
+ formDefinition: f,
871
+ a2ui: Kt(u.form_definition) ?? void 0
701
872
  };
702
873
  }
703
874
  return { fetchDetail: o };
704
875
  }
705
- const Lt = {
706
- video: Xe,
707
- audio: Ge,
708
- image: Ye,
709
- file: me,
710
- spreadsheet: He,
711
- document: $e
876
+ const hr = {
877
+ video: ft,
878
+ audio: mt,
879
+ image: dt,
880
+ file: Oe,
881
+ spreadsheet: pt,
882
+ document: ut
712
883
  };
713
- function Rt({
884
+ function vr({
714
885
  type: e,
715
886
  size: t = 40,
716
- className: n
887
+ className: r
717
888
  }) {
718
- const r = Lt[e] ?? me;
719
- return /* @__PURE__ */ u(
720
- r,
889
+ const n = hr[e] ?? Oe;
890
+ return /* @__PURE__ */ s(
891
+ n,
721
892
  {
722
- className: n ?? "skopon-form-file-placeholder-icon",
893
+ className: r ?? "skopon-form-file-placeholder-icon",
723
894
  style: { fontSize: t, color: "var(--color-primary, #1677ff)" },
724
895
  "aria-hidden": !0
725
896
  }
726
897
  );
727
898
  }
728
- const Ae = Fe({ interactive: !0 });
729
- function ke({
899
+ const Re = We({ interactive: !0 });
900
+ function De({
730
901
  interactive: e,
731
902
  children: t
732
903
  }) {
733
- return /* @__PURE__ */ u(Ae.Provider, { value: { interactive: e }, children: t });
904
+ return /* @__PURE__ */ s(Re.Provider, { value: { interactive: e }, children: t });
734
905
  }
735
- function E() {
736
- return we(Ae);
906
+ function j() {
907
+ return Ze(Re);
737
908
  }
738
- function Ut(e) {
909
+ function He(e) {
739
910
  return e && typeof e == "object" && "path" in e && String(e.path ?? "").trim() || null;
740
911
  }
741
- function _(e, t = "value") {
742
- const r = e.componentModel.properties[t], o = Ut(r), a = N(
743
- (s) => {
744
- if (!o || r === void 0) return () => {
912
+ function Ee(e, t = "value") {
913
+ const n = e.componentModel.properties[t];
914
+ if (!(!He(n) || n === void 0))
915
+ return e.dataContext.resolveDynamicValue(n);
916
+ }
917
+ function L(e, t = "value") {
918
+ const n = e.componentModel.properties[t], o = He(n), i = ie(
919
+ (u) => {
920
+ if (!o || n === void 0) return () => {
745
921
  };
746
- const p = e.dataContext.subscribeDynamicValue(r, () => s());
747
- return () => p.unsubscribe();
922
+ const f = e.dataContext.subscribeDynamicValue(n, () => u());
923
+ return () => f.unsubscribe();
748
924
  },
749
- [e, r, o]
750
- ), i = N(() => {
751
- if (!(!o || r === void 0))
752
- return e.dataContext.resolveDynamicValue(r);
753
- }, [e, r, o]), l = o ? Oe(a, i, i) : void 0, c = N(
754
- (s) => {
755
- !o || !r || typeof r != "object" || !("path" in r) || e.dataContext.set(String(r.path), s);
925
+ [e, n, o]
926
+ ), a = ie(() => {
927
+ if (!(!o || n === void 0))
928
+ return e.dataContext.resolveDynamicValue(n);
929
+ }, [e, n, o]), l = Qe(i, a, a), c = ie(
930
+ (u) => {
931
+ !o || !n || typeof n != "object" || !("path" in n) || e.dataContext.set(String(n.path), u);
756
932
  },
757
- [e, r, o]
933
+ [e, n, o]
758
934
  );
759
935
  return { value: l, setValue: c, hasBinding: !!o };
760
936
  }
761
- function V(e) {
937
+ function D(e) {
762
938
  if (typeof e == "string") return e || void 0;
763
939
  if (typeof e == "number") return String(e);
764
940
  }
765
- function z(e) {
941
+ function V(e) {
766
942
  return Array.isArray(e) ? e.map(String) : typeof e == "string" && e ? [e] : [];
767
943
  }
768
- const Te = "skopon-form-v0_9", Bt = /* @__PURE__ */ new Set([
944
+ const Ye = "skopon-form-v0_9", yr = /* @__PURE__ */ new Set([
769
945
  "SkoponMedia",
770
946
  "SkoponSelect",
771
947
  "Image",
@@ -774,74 +950,76 @@ const Te = "skopon-form-v0_9", Bt = /* @__PURE__ */ new Set([
774
950
  "ChoicePicker",
775
951
  "CheckBox",
776
952
  "DateTimeInput",
777
- "FileUpload"
778
- ]);
779
- function R(e) {
780
- const t = [...O.components.values()].find((n) => n.name === e);
953
+ "FileUpload",
954
+ "TextField",
955
+ "Text"
956
+ ]), gr = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "caption"]);
957
+ function G(e) {
958
+ const t = [...Z.components.values()].find((r) => r.name === e);
781
959
  if (!t) throw new Error(`Missing basic catalog component: ${e}`);
782
960
  return t.schema;
783
961
  }
784
- function v(e) {
962
+ function g(e) {
785
963
  return typeof e == "string" ? e : "";
786
964
  }
787
- function Ce(e) {
965
+ function Je(e) {
788
966
  return Array.isArray(e) ? e.map((t) => {
789
967
  if (!t || typeof t != "object") return null;
790
- const n = t, r = String(n.value ?? n.label ?? ""), o = String(n.label ?? n.value ?? "");
791
- return { value: r, label: o };
968
+ const r = t, n = String(r.value ?? r.label ?? ""), o = String(r.label ?? r.value ?? "");
969
+ return { value: n, label: o };
792
970
  }).filter((t) => !!t) : [];
793
971
  }
794
- function U({
972
+ function re({
795
973
  mediaType: e,
796
974
  urls: t,
797
- mediaSize: n,
798
- label: r,
975
+ mediaSize: r,
976
+ label: n,
799
977
  help: o,
800
- placeholder: a
978
+ placeholder: i
801
979
  }) {
802
- const i = r == null ? void 0 : r.trim(), l = o == null ? void 0 : o.trim(), c = et(n), s = (a == null ? void 0 : a.trim()) || (e === "image" ? "未设置图片 URL" : e === "video" ? "未设置视频 URL" : "未设置音频 URL");
803
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
804
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
805
- t.length === 0 ? /* @__PURE__ */ u("div", { className: "form-media-preview form-media-preview--empty", children: s }) : /* @__PURE__ */ u("div", { className: c, children: t.map((p, d) => e === "image" ? /* @__PURE__ */ u(
980
+ const a = n == null ? void 0 : n.trim(), l = o == null ? void 0 : o.trim(), c = Bt(r), u = (i == null ? void 0 : i.trim()) || (e === "image" ? "未设置图片 URL" : e === "video" ? "未设置视频 URL" : "未设置音频 URL");
981
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
982
+ a ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: a }) : null,
983
+ t.length === 0 ? /* @__PURE__ */ s("div", { className: "form-media-preview form-media-preview--empty", children: u }) : /* @__PURE__ */ s("div", { className: c, children: t.map((f, d) => e === "image" ? /* @__PURE__ */ s(
806
984
  "img",
807
985
  {
808
- src: p,
809
- alt: i || "图片",
986
+ src: f,
987
+ alt: a || "图片",
810
988
  className: "form-media-item"
811
989
  },
812
990
  `media-${d}`
813
- ) : e === "video" ? /* @__PURE__ */ u(
991
+ ) : e === "video" ? /* @__PURE__ */ s(
814
992
  "video",
815
993
  {
816
- src: p,
994
+ src: f,
817
995
  controls: !0,
818
996
  className: "form-media-item"
819
997
  },
820
998
  `media-${d}`
821
- ) : /* @__PURE__ */ u(
999
+ ) : /* @__PURE__ */ s(
822
1000
  "audio",
823
1001
  {
824
- src: p,
1002
+ src: f,
825
1003
  controls: !0,
826
1004
  className: "form-media-item form-media-item--audio"
827
1005
  },
828
1006
  `media-${d}`
829
1007
  )) }),
830
- l ? /* @__PURE__ */ u(J.Text, { type: "secondary", className: "form-block-preview-help", children: l }) : null
1008
+ l ? /* @__PURE__ */ s(R.Text, { type: "secondary", className: "form-block-preview-help", children: l }) : null
831
1009
  ] });
832
1010
  }
833
- function B(e, t) {
834
- const n = Array.isArray(e.urls) ? e.urls.map((r) => String(r).trim()).filter(Boolean) : v(e.url).trim() ? [v(e.url).trim()] : [];
1011
+ function ne(e, t) {
1012
+ const r = Array.isArray(e.urls) ? e.urls.map((n) => String(n).trim()).filter(Boolean) : g(e.url).trim() ? [g(e.url).trim()] : [];
835
1013
  return {
836
1014
  mediaType: t,
837
- urls: n,
838
- mediaSize: I(e.mediaSize),
839
- label: v(e.label) || v(e.description),
840
- help: v(e.help),
841
- placeholder: v(e.placeholder)
1015
+ urls: r,
1016
+ mediaSize: J(e.mediaSize),
1017
+ label: g(e.label) || g(e.description),
1018
+ help: g(e.help),
1019
+ placeholder: g(e.placeholder)
842
1020
  };
843
1021
  }
844
- const Nt = {
1022
+ const br = {
845
1023
  name: "SkoponMedia",
846
1024
  schema: m.object({
847
1025
  mediaType: m.any().optional(),
@@ -851,19 +1029,19 @@ const Nt = {
851
1029
  help: m.any().optional(),
852
1030
  placeholder: m.any().optional()
853
1031
  }).passthrough()
854
- }, $t = S(Nt, ({ context: e }) => {
855
- const t = e.componentModel.properties, n = v(t.mediaType);
856
- return /* @__PURE__ */ u(U, { ...B(t, n === "video" ? "video" : n === "audio" ? "audio" : "image") });
857
- }), Ht = S(
858
- { name: "Image", schema: R("Image") },
859
- ({ context: e }) => /* @__PURE__ */ u(U, { ...B(e.componentModel.properties, "image") })
860
- ), Yt = S(
861
- { name: "Video", schema: R("Video") },
862
- ({ context: e }) => /* @__PURE__ */ u(U, { ...B(e.componentModel.properties, "video") })
863
- ), Gt = S(
864
- { name: "AudioPlayer", schema: R("AudioPlayer") },
865
- ({ context: e }) => /* @__PURE__ */ u(U, { ...B(e.componentModel.properties, "audio") })
866
- ), Xt = {
1032
+ }, xr = E(br, ({ context: e }) => {
1033
+ const t = e.componentModel.properties, r = g(t.mediaType);
1034
+ return /* @__PURE__ */ s(re, { ...ne(t, r === "video" ? "video" : r === "audio" ? "audio" : "image") });
1035
+ }), Sr = E(
1036
+ { name: "Image", schema: G("Image") },
1037
+ ({ context: e }) => /* @__PURE__ */ s(re, { ...ne(e.componentModel.properties, "image") })
1038
+ ), kr = E(
1039
+ { name: "Video", schema: G("Video") },
1040
+ ({ context: e }) => /* @__PURE__ */ s(re, { ...ne(e.componentModel.properties, "video") })
1041
+ ), Ar = E(
1042
+ { name: "AudioPlayer", schema: G("AudioPlayer") },
1043
+ ({ context: e }) => /* @__PURE__ */ s(re, { ...ne(e.componentModel.properties, "audio") })
1044
+ ), Tr = {
867
1045
  name: "SkoponSelect",
868
1046
  schema: m.object({
869
1047
  label: m.any().optional(),
@@ -873,48 +1051,48 @@ const Nt = {
873
1051
  value: m.any().optional()
874
1052
  }).passthrough()
875
1053
  };
876
- function Kt({ context: e }) {
877
- const { interactive: t } = E(), { value: n, setValue: r } = _(e), o = e.componentModel.properties, a = v(o.label), i = v(o.placeholder), l = Ce(o.options), c = v(o.mode) === "multiple";
878
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
879
- a ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: a }) : null,
880
- /* @__PURE__ */ u(
881
- H,
1054
+ function Cr({ context: e }) {
1055
+ const { interactive: t } = j(), { value: r, setValue: n } = L(e), o = e.componentModel.properties, i = g(o.label), a = g(o.placeholder), l = Je(o.options), c = g(o.mode) === "multiple";
1056
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
1057
+ i ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: i }) : null,
1058
+ /* @__PURE__ */ s(
1059
+ ue,
882
1060
  {
883
1061
  mode: c ? "multiple" : void 0,
884
1062
  disabled: !t,
885
1063
  allowClear: !0,
886
1064
  className: "form-block-preview-control",
887
1065
  style: { width: "100%" },
888
- placeholder: i || (c ? "请选择多项" : "请选择"),
1066
+ placeholder: a || (c ? "请选择多项" : "请选择"),
889
1067
  options: l,
890
- value: c ? z(n) : V(n),
891
- onChange: (s) => r(c ? s ?? [] : s ?? "")
1068
+ value: c ? V(r) : D(r),
1069
+ onChange: (u) => n(c ? u ?? [] : u ?? "")
892
1070
  }
893
1071
  )
894
1072
  ] });
895
1073
  }
896
- const qt = S(
897
- Xt,
898
- Kt
1074
+ const Mr = E(
1075
+ Tr,
1076
+ Cr
899
1077
  );
900
- function Jt({ context: e }) {
901
- const { interactive: t } = E(), { value: n, setValue: r } = _(e), o = e.componentModel.properties, a = v(o.label), i = v(o.variant) || "mutuallyExclusive", l = v(o.skoponPickerType), c = v(o.placeholder), s = Ce(o.options), d = l === "select" || l === "multiselect" || l === "radio" || l === "checkbox" ? l : i === "multipleSelection" ? "checkbox" : "radio";
902
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
903
- a ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: a }) : null,
904
- d === "select" ? /* @__PURE__ */ u(
905
- H,
1078
+ function Er({ context: e }) {
1079
+ const { interactive: t } = j(), { value: r, setValue: n } = L(e), o = e.componentModel.properties, i = g(o.label), a = g(o.variant) || "mutuallyExclusive", l = g(o.skoponPickerType), c = g(o.placeholder), u = Je(o.options), d = l === "select" || l === "multiselect" || l === "radio" || l === "checkbox" ? l : a === "multipleSelection" ? "checkbox" : "radio";
1080
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
1081
+ i ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: i }) : null,
1082
+ d === "select" ? /* @__PURE__ */ s(
1083
+ ue,
906
1084
  {
907
1085
  disabled: !t,
908
1086
  allowClear: !0,
909
1087
  className: "form-block-preview-control",
910
1088
  style: { width: "100%" },
911
1089
  placeholder: c || "请选择",
912
- options: s,
913
- value: V(n),
914
- onChange: (f) => r(f ?? "")
1090
+ options: u,
1091
+ value: D(r),
1092
+ onChange: (p) => n(p ?? "")
915
1093
  }
916
- ) : d === "multiselect" ? /* @__PURE__ */ u(
917
- H,
1094
+ ) : d === "multiselect" ? /* @__PURE__ */ s(
1095
+ ue,
918
1096
  {
919
1097
  mode: "multiple",
920
1098
  disabled: !t,
@@ -922,32 +1100,32 @@ function Jt({ context: e }) {
922
1100
  className: "form-block-preview-control",
923
1101
  style: { width: "100%" },
924
1102
  placeholder: c || "请选择多项",
925
- options: s,
926
- value: z(n),
927
- onChange: (f) => r(f ?? [])
1103
+ options: u,
1104
+ value: V(r),
1105
+ onChange: (p) => n(p ?? [])
928
1106
  }
929
- ) : d === "checkbox" ? /* @__PURE__ */ u(
930
- ze.Group,
1107
+ ) : d === "checkbox" ? /* @__PURE__ */ s(
1108
+ nt.Group,
931
1109
  {
932
1110
  disabled: !t,
933
1111
  className: "form-block-preview-control",
934
- options: s,
935
- value: z(n),
936
- onChange: (f) => r(f)
1112
+ options: u,
1113
+ value: V(r),
1114
+ onChange: (p) => n(p)
937
1115
  }
938
- ) : /* @__PURE__ */ u(
939
- Le.Group,
1116
+ ) : /* @__PURE__ */ s(
1117
+ ot.Group,
940
1118
  {
941
1119
  disabled: !t,
942
1120
  className: "form-block-preview-control",
943
- options: s,
944
- value: V(n),
945
- onChange: (f) => r(f.target.value)
1121
+ options: u,
1122
+ value: D(r),
1123
+ onChange: (p) => n(p.target.value)
946
1124
  }
947
1125
  )
948
1126
  ] });
949
1127
  }
950
- const Wt = S(
1128
+ const Ir = E(
951
1129
  {
952
1130
  name: "ChoicePicker",
953
1131
  schema: m.object({
@@ -959,80 +1137,80 @@ const Wt = S(
959
1137
  placeholder: m.any().optional()
960
1138
  }).passthrough()
961
1139
  },
962
- Jt
1140
+ Er
963
1141
  );
964
- function Zt({ context: e }) {
965
- const { interactive: t } = E(), { value: n, setValue: r } = _(e), o = e.componentModel.properties, a = v(o.label);
966
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
967
- a ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: a }) : null,
968
- /* @__PURE__ */ u(
969
- Re,
1142
+ function Pr({ context: e }) {
1143
+ const { interactive: t } = j(), { value: r, setValue: n } = L(e), o = e.componentModel.properties, i = g(o.label);
1144
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
1145
+ i ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: i }) : null,
1146
+ /* @__PURE__ */ s(
1147
+ at,
970
1148
  {
971
1149
  disabled: !t,
972
1150
  className: "form-block-preview-control",
973
- checked: n === !0,
974
- onChange: (i) => r(i)
1151
+ checked: be(r),
1152
+ onChange: (a) => n(a)
975
1153
  }
976
1154
  )
977
1155
  ] });
978
1156
  }
979
- const Qt = S(
980
- { name: "CheckBox", schema: R("CheckBox") },
981
- Zt
1157
+ const wr = E(
1158
+ { name: "CheckBox", schema: G("CheckBox") },
1159
+ Pr
982
1160
  );
983
- function en(e, t, n) {
984
- const r = V(e);
985
- if (!r) return;
986
- if (!t && n) {
987
- const a = ne(r, "HH:mm", !0);
988
- return a.isValid() ? a : void 0;
1161
+ function Nr(e, t, r) {
1162
+ const n = D(e);
1163
+ if (!n) return;
1164
+ if (!t && r) {
1165
+ const i = Te(n, "HH:mm", !0);
1166
+ return i.isValid() ? i : void 0;
989
1167
  }
990
- const o = ne(r);
1168
+ const o = Te(n);
991
1169
  return o.isValid() ? o : void 0;
992
1170
  }
993
- function tn({ context: e }) {
994
- const { interactive: t } = E(), { value: n, setValue: r } = _(e), o = e.componentModel.properties, a = v(o.label), i = v(o.placeholder), l = o.enableDate === !0, c = o.enableTime === !0, s = en(n, l, c), p = (d) => {
1171
+ function _r({ context: e }) {
1172
+ const { interactive: t } = j(), { value: r, setValue: n } = L(e), o = e.componentModel.properties, i = g(o.label), a = g(o.placeholder), l = o.enableDate === !0, c = o.enableTime === !0, u = Nr(r, l, c), f = (d) => {
995
1173
  if (!d) {
996
- r("");
1174
+ n("");
997
1175
  return;
998
1176
  }
999
1177
  if (!l && c) {
1000
- r(d.format("HH:mm"));
1178
+ n(d.format("HH:mm"));
1001
1179
  return;
1002
1180
  }
1003
1181
  if (l && c) {
1004
- r(d.format("YYYY-MM-DDTHH:mm"));
1182
+ n(d.format("YYYY-MM-DDTHH:mm"));
1005
1183
  return;
1006
1184
  }
1007
- r(d.format("YYYY-MM-DD"));
1185
+ n(d.format("YYYY-MM-DD"));
1008
1186
  };
1009
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
1010
- a ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: a }) : null,
1011
- !l && c ? /* @__PURE__ */ u(
1012
- Ue,
1187
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
1188
+ i ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: i }) : null,
1189
+ !l && c ? /* @__PURE__ */ s(
1190
+ it,
1013
1191
  {
1014
1192
  disabled: !t,
1015
1193
  className: "form-block-preview-control",
1016
1194
  style: { width: "100%" },
1017
- placeholder: i || "选择时间",
1018
- value: s,
1019
- onChange: p
1195
+ placeholder: a || "选择时间",
1196
+ value: u,
1197
+ onChange: f
1020
1198
  }
1021
- ) : /* @__PURE__ */ u(
1022
- Be,
1199
+ ) : /* @__PURE__ */ s(
1200
+ lt,
1023
1201
  {
1024
1202
  showTime: l && c,
1025
1203
  disabled: !t,
1026
1204
  className: "form-block-preview-control",
1027
1205
  style: { width: "100%" },
1028
- placeholder: i || (l && c ? "选择日期时间" : "选择日期"),
1029
- value: s,
1030
- onChange: p
1206
+ placeholder: a || (l && c ? "选择日期时间" : "选择日期"),
1207
+ value: u,
1208
+ onChange: f
1031
1209
  }
1032
1210
  )
1033
1211
  ] });
1034
1212
  }
1035
- const nn = S(
1213
+ const Fr = E(
1036
1214
  {
1037
1215
  name: "DateTimeInput",
1038
1216
  schema: m.object({
@@ -1045,8 +1223,8 @@ const nn = S(
1045
1223
  max: m.any().optional()
1046
1224
  }).passthrough()
1047
1225
  },
1048
- tn
1049
- ), rn = {
1226
+ _r
1227
+ ), Or = {
1050
1228
  name: "FileUpload",
1051
1229
  schema: m.object({
1052
1230
  label: m.any().optional(),
@@ -1058,275 +1236,428 @@ const nn = S(
1058
1236
  value: m.any().optional()
1059
1237
  }).passthrough()
1060
1238
  };
1061
- function on({ context: e }) {
1062
- const { interactive: t } = E(), { value: n, setValue: r } = _(e), o = e.componentModel.properties, a = v(o.label), i = v(o.accept), l = Array.isArray(o.fileAcceptTypes) ? o.fileAcceptTypes.map(String) : void 0, c = i ? i.split(",").map((h) => h.trim()).filter(Boolean) : void 0, s = mt(l, c), p = typeof o.filePlaceholderIcon == "string" && ["video", "audio", "image", "file", "spreadsheet", "document"].includes(
1239
+ function Vr({ context: e }) {
1240
+ const { interactive: t } = j(), { value: r, setValue: n } = L(e), o = e.componentModel.properties, i = g(o.label), a = g(o.accept), l = Array.isArray(o.fileAcceptTypes) ? o.fileAcceptTypes.map(String) : void 0, c = a ? a.split(",").map((x) => x.trim()).filter(Boolean) : void 0, u = Pt(l, c), f = typeof o.filePlaceholderIcon == "string" && ["video", "audio", "image", "file", "spreadsheet", "document"].includes(
1063
1241
  o.filePlaceholderIcon
1064
- ) ? o.filePlaceholderIcon : "document", d = typeof o.maxCount == "number" ? o.maxCount : 1, f = z(n);
1065
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
1066
- a ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: a }) : null,
1067
- /* @__PURE__ */ b(
1068
- ee.Dragger,
1242
+ ) ? o.filePlaceholderIcon : "document", d = typeof o.minCount == "number" ? Math.max(0, o.minCount) : 0, p = typeof o.maxCount == "number" ? o.maxCount : 1, y = p > 0, k = V(r), T = y && k.length >= p, h = k.length < d;
1243
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
1244
+ i ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: i }) : null,
1245
+ /* @__PURE__ */ M(
1246
+ le.Dragger,
1069
1247
  {
1070
- disabled: !t,
1071
- accept: pt(l, c),
1248
+ disabled: !t || T,
1249
+ accept: It(l, c),
1072
1250
  className: "form-file-upload-preview",
1073
- showUploadList: t && f.length > 0,
1074
- fileList: t ? f.map((h, A) => ({
1075
- uid: `${A}-${h}`,
1076
- name: h,
1251
+ showUploadList: t && k.length > 0,
1252
+ fileList: t ? k.map((x, v) => ({
1253
+ uid: `${v}-${x}`,
1254
+ name: x,
1077
1255
  status: "done"
1078
1256
  })) : [],
1079
- beforeUpload: (h) => {
1080
- if (!t) return ee.LIST_IGNORE;
1081
- const A = [...f, h.name].slice(0, Math.max(1, d));
1082
- return r(A), !1;
1257
+ beforeUpload: (x) => {
1258
+ if (!t) return le.LIST_IGNORE;
1259
+ const v = V(Ee(e));
1260
+ if (y && v.length >= p) return le.LIST_IGNORE;
1261
+ const b = y ? [...v, x.name].slice(0, p) : [...v, x.name];
1262
+ return n(b), !1;
1083
1263
  },
1084
- onRemove: (h) => {
1085
- r(f.filter((A) => A !== h.name));
1264
+ onRemove: (x) => {
1265
+ const v = V(Ee(e)), b = /^(\d+)-/.exec(x.uid ?? ""), z = b ? Number(b[1]) : -1, I = z >= 0 && z < v.length ? v.filter((P, X) => X !== z) : v.filter((P) => P !== x.name);
1266
+ if (I.length < d) return !1;
1267
+ n(I);
1086
1268
  },
1087
1269
  children: [
1088
- /* @__PURE__ */ u("p", { className: "form-file-upload-preview-icon", children: /* @__PURE__ */ u(Rt, { type: p, size: 40 }) }),
1089
- /* @__PURE__ */ u("p", { className: "form-file-upload-preview-text", children: "点击或拖拽文件到此处上传" })
1270
+ /* @__PURE__ */ s("p", { className: "form-file-upload-preview-icon", children: /* @__PURE__ */ s(vr, { type: f, size: 40 }) }),
1271
+ /* @__PURE__ */ s("p", { className: "form-file-upload-preview-text", children: "点击或拖拽文件到此处上传" })
1090
1272
  ]
1091
1273
  }
1092
1274
  ),
1093
- /* @__PURE__ */ b(J.Text, { type: "secondary", className: "form-block-preview-help", children: [
1275
+ /* @__PURE__ */ M(R.Text, { type: "secondary", className: "form-block-preview-help", children: [
1094
1276
  "允许:",
1095
- s ?? "全部类型"
1277
+ u ?? "全部类型",
1278
+ d > 0 ? `;至少 ${d} 个文件` : "",
1279
+ y ? `;最多 ${p} 个文件` : "",
1280
+ h && t ? `(当前 ${k.length} 个,未达下限)` : ""
1096
1281
  ] })
1097
1282
  ] });
1098
1283
  }
1099
- const an = S(
1100
- rn,
1101
- on
1284
+ const Br = E(
1285
+ Or,
1286
+ Vr
1102
1287
  );
1103
- function Me() {
1288
+ function jr({ context: e }) {
1289
+ const { interactive: t } = j(), { value: r, setValue: n } = L(e), o = e.componentModel.properties, i = g(o.label), a = g(o.placeholder), l = g(o.variant) || "shortText", c = D(r) ?? "", u = !t, f = "form-block-preview-control";
1290
+ let d;
1291
+ if (l === "longText")
1292
+ d = /* @__PURE__ */ s(
1293
+ ce.TextArea,
1294
+ {
1295
+ disabled: u,
1296
+ className: f,
1297
+ placeholder: a || "长文本回答...",
1298
+ autoSize: { minRows: 2, maxRows: 6 },
1299
+ value: c,
1300
+ onChange: (p) => n(p.target.value)
1301
+ }
1302
+ );
1303
+ else if (l === "number") {
1304
+ const p = c && Number.isFinite(Number(c)) ? Number(c) : void 0;
1305
+ d = /* @__PURE__ */ s(
1306
+ ct,
1307
+ {
1308
+ disabled: u,
1309
+ className: f,
1310
+ style: { width: "100%" },
1311
+ placeholder: a || "数字",
1312
+ value: p,
1313
+ onChange: (y) => n(y == null ? "" : String(y))
1314
+ }
1315
+ );
1316
+ } else l === "obscured" ? d = /* @__PURE__ */ s(
1317
+ ce.Password,
1318
+ {
1319
+ disabled: u,
1320
+ className: f,
1321
+ placeholder: a,
1322
+ value: c,
1323
+ onChange: (p) => n(p.target.value)
1324
+ }
1325
+ ) : d = /* @__PURE__ */ s(
1326
+ ce,
1327
+ {
1328
+ disabled: u,
1329
+ className: f,
1330
+ placeholder: a,
1331
+ value: c,
1332
+ onChange: (p) => n(p.target.value)
1333
+ }
1334
+ );
1335
+ return /* @__PURE__ */ M("div", { className: "form-block-preview", children: [
1336
+ i ? /* @__PURE__ */ s("div", { className: "form-block-preview-label", children: i }) : null,
1337
+ d
1338
+ ] });
1339
+ }
1340
+ const Lr = E(
1341
+ {
1342
+ name: "TextField",
1343
+ schema: m.object({
1344
+ label: m.any().optional(),
1345
+ variant: m.any().optional(),
1346
+ placeholder: m.any().optional(),
1347
+ validationRegexp: m.any().optional(),
1348
+ value: m.any().optional()
1349
+ }).passthrough()
1350
+ },
1351
+ jr
1352
+ );
1353
+ function zr({ context: e }) {
1354
+ const t = e.componentModel.properties, r = g(t.text), n = g(t.variant) || "body";
1355
+ return gr.has(n) ? n === "caption" ? /* @__PURE__ */ s(R.Text, { type: "secondary", className: "form-block-preview-paragraph", children: /* @__PURE__ */ s("em", { children: r }) }) : /* @__PURE__ */ s(n, { className: "form-block-preview-heading", children: r }) : /* @__PURE__ */ s(R.Paragraph, { className: "form-block-preview-paragraph", children: r });
1356
+ }
1357
+ const Ur = E(
1358
+ { name: "Text", schema: G("Text") },
1359
+ zr
1360
+ );
1361
+ function Ge() {
1104
1362
  const t = [
1105
- ...[...O.components.values()].filter(
1106
- (r) => !Bt.has(r.name)
1363
+ ...[...Z.components.values()].filter(
1364
+ (n) => !yr.has(n.name)
1107
1365
  ),
1108
- $t,
1109
- qt,
1110
- Ht,
1111
- Yt,
1112
- Gt,
1113
- Wt,
1114
- Qt,
1115
- nn,
1116
- an
1117
- ], n = [...O.functions.values()];
1118
- return new Ve(Te, t, n, O.themeSchema);
1119
- }
1120
- const ln = De(
1366
+ xr,
1367
+ Mr,
1368
+ Sr,
1369
+ kr,
1370
+ Ar,
1371
+ Ir,
1372
+ wr,
1373
+ Fr,
1374
+ Br,
1375
+ Lr,
1376
+ Ur
1377
+ ], r = [...Z.functions.values()];
1378
+ return new rt(Ye, t, r, Z.themeSchema);
1379
+ }
1380
+ const $r = et(
1121
1381
  function({
1122
1382
  doc: t,
1123
- surfaceId: n = "skopon-form",
1124
- emptyHint: r = null,
1383
+ surfaceId: r = "skopon-form",
1384
+ emptyHint: n = null,
1125
1385
  interactive: o = !0,
1126
- fieldNames: a = []
1127
- }, i) {
1128
- C(() => {
1129
- ue(), ce();
1386
+ fieldNames: i = []
1387
+ }, a) {
1388
+ _(() => {
1389
+ _e(), we();
1130
1390
  }, []);
1131
- const l = M(null), c = M(a);
1132
- c.current = a;
1133
- const s = k(() => {
1134
- if (q(t))
1135
- return l.current = null, [];
1391
+ const l = w(null), c = w(i);
1392
+ c.current = i;
1393
+ const u = N(() => {
1394
+ if (he(t))
1395
+ return { surfaces: [], processor: null };
1136
1396
  try {
1137
- const p = new le([Me()]), d = It(t, {
1138
- surfaceId: n,
1139
- catalogId: Te
1397
+ const p = new Pe([Ge()]), y = qt(t, {
1398
+ surfaceId: r,
1399
+ catalogId: Ye
1140
1400
  });
1141
- return p.processMessages(d), l.current = p, Array.from(p.model.surfacesMap.values());
1401
+ return p.processMessages(y), {
1402
+ surfaces: Array.from(p.model.surfacesMap.values()),
1403
+ processor: p
1404
+ };
1142
1405
  } catch (p) {
1143
- return console.error("[SkoponFormRenderer] 渲染 A2UI surface 失败", p), l.current = null, [];
1406
+ return console.error("[SkoponFormRenderer] 渲染 A2UI surface 失败", p), { surfaces: [], processor: null };
1144
1407
  }
1145
- }, [t, n]);
1146
- return je(
1147
- i,
1408
+ }, [t, r]), { surfaces: f, processor: d } = u;
1409
+ return l.current = d, tt(
1410
+ a,
1148
1411
  () => ({
1149
1412
  getValues(p) {
1150
- const d = l.current;
1151
- if (!d) return {};
1152
- const f = (p ?? c.current).map((h) => h.trim()).filter(Boolean);
1153
- return wt(d, n, f);
1413
+ const y = l.current;
1414
+ if (!y) return {};
1415
+ const k = (p ?? c.current).map((T) => T.trim()).filter(Boolean);
1416
+ return Qt(y, r, k);
1154
1417
  }
1155
1418
  }),
1156
- [n]
1157
- ), s.length === 0 ? /* @__PURE__ */ u(ae, { children: r }) : /* @__PURE__ */ u(ke, { interactive: o, children: /* @__PURE__ */ u("div", { className: "a2ui-surface a2ui-container", children: s.map((p) => /* @__PURE__ */ u(se, { surface: p }, p.id)) }) });
1419
+ [r]
1420
+ ), f.length === 0 ? /* @__PURE__ */ s(Ie, { children: n }) : /* @__PURE__ */ s(De, { interactive: o, children: /* @__PURE__ */ s("div", { className: "a2ui-surface a2ui-container", children: f.map((p) => /* @__PURE__ */ s(Ne, { surface: p }, p.id)) }) });
1158
1421
  }
1159
1422
  );
1160
- function xn({
1423
+ function W() {
1424
+ return new Pe([Ge()]);
1425
+ }
1426
+ function rn({
1161
1427
  messages: e,
1162
1428
  surfaceId: t = "skopon-form-stream",
1163
- emptyHint: n = null,
1164
- interactive: r = !0
1429
+ emptyHint: r = null,
1430
+ interactive: n = !0
1165
1431
  }) {
1166
- C(() => {
1167
- ue(), ce();
1432
+ _(() => {
1433
+ _e(), we();
1168
1434
  }, []);
1169
- const o = M(null), a = M(0), i = k(() => {
1170
- const s = new le([Me()]);
1171
- return o.current = s, a.current = 0, s;
1172
- }, [t]), [l, c] = w(() => Array.from(i.model.surfacesMap.values()));
1173
- return C(() => {
1174
- const s = () => c(Array.from(i.model.surfacesMap.values())), p = i.onSurfaceCreated(s), d = i.onSurfaceDeleted(s);
1435
+ const o = w(W()), i = w(0), a = w(!0), l = w(t), [c, u] = O(() => o.current), [f, d] = O(
1436
+ () => Array.from(o.current.model.surfacesMap.values())
1437
+ );
1438
+ return _(() => (a.current = !0, () => {
1439
+ a.current = !1;
1440
+ }), []), _(() => {
1441
+ o.current = c;
1442
+ }, [c]), _(() => {
1443
+ const p = () => {
1444
+ a.current && d(Array.from(c.model.surfacesMap.values()));
1445
+ }, y = c.onSurfaceCreated(p), k = c.onSurfaceDeleted(p);
1175
1446
  return () => {
1176
- p.unsubscribe(), d.unsubscribe();
1447
+ y.unsubscribe(), k.unsubscribe();
1177
1448
  };
1178
- }, [i]), C(() => {
1179
- if (!Array.isArray(e) || e.length === 0) return;
1180
- const s = e.slice(a.current);
1181
- s.length !== 0 && (i.processMessages(s), a.current = e.length, c(Array.from(i.model.surfacesMap.values())));
1182
- }, [e, i]), l.length === 0 ? /* @__PURE__ */ u(ae, { children: n }) : /* @__PURE__ */ u(ke, { interactive: r, children: /* @__PURE__ */ u("div", { className: "a2ui-surface a2ui-container", children: l.map((s) => /* @__PURE__ */ u(se, { surface: s }, s.id)) }) });
1183
- }
1184
- function ie({
1449
+ }, [c]), _(() => {
1450
+ let p = !1;
1451
+ const y = l.current !== t;
1452
+ if (l.current = t, y) {
1453
+ const h = W();
1454
+ return o.current = h, i.current = 0, Array.isArray(e) && e.length > 0 ? (h.processMessages(e), i.current = e.length, p || (u(h), d(Array.from(h.model.surfacesMap.values())))) : p || (u(h), d([])), () => {
1455
+ p = !0;
1456
+ };
1457
+ }
1458
+ if (!Array.isArray(e) || e.length === 0) {
1459
+ if (i.current > 0) {
1460
+ const h = W();
1461
+ o.current = h, i.current = 0, p || (u(h), d([]));
1462
+ }
1463
+ return () => {
1464
+ p = !0;
1465
+ };
1466
+ }
1467
+ const k = o.current;
1468
+ if (e.length < i.current) {
1469
+ const h = W();
1470
+ return o.current = h, i.current = 0, h.processMessages(e), i.current = e.length, p || (u(h), d(Array.from(h.model.surfacesMap.values()))), () => {
1471
+ p = !0;
1472
+ };
1473
+ }
1474
+ const T = e.slice(i.current);
1475
+ return T.length === 0 ? () => {
1476
+ p = !0;
1477
+ } : (k.processMessages(T), i.current = e.length, p || d(Array.from(k.model.surfacesMap.values())), () => {
1478
+ p = !0;
1479
+ });
1480
+ }, [e, t]), f.length === 0 ? /* @__PURE__ */ s(Ie, { children: r }) : /* @__PURE__ */ s(De, { interactive: n, children: /* @__PURE__ */ s("div", { className: "a2ui-surface a2ui-container", children: f.map((p) => /* @__PURE__ */ s(Ne, { surface: p }, p.id)) }) });
1481
+ }
1482
+ function Rr({
1185
1483
  payload: e,
1186
1484
  callbackUrl: t,
1187
- title: n,
1188
- unpublishedFormId: r,
1485
+ title: r,
1486
+ unpublishedFormId: n,
1189
1487
  incompleteFormId: o,
1190
- onNotify: a
1488
+ onNotify: i
1191
1489
  }) {
1192
- const i = k(
1193
- () => xe(e, t),
1490
+ const a = N(
1491
+ () => er(e, t),
1194
1492
  [e, t]
1195
1493
  );
1196
1494
  async function l() {
1197
1495
  try {
1198
- await Se(i), a == null || a("success", "已复制到剪贴板");
1496
+ await $e(a), i == null || i("success", "已复制到剪贴板");
1199
1497
  } catch {
1200
- a == null || a("error", "复制失败");
1498
+ i == null || i("error", "复制失败");
1201
1499
  }
1202
1500
  }
1203
- return /* @__PURE__ */ b("div", { className: "ask-user-curl-card", children: [
1204
- /* @__PURE__ */ b("div", { className: "ask-user-curl-card-header", children: [
1205
- /* @__PURE__ */ b("div", { className: "ask-user-curl-card-header-title", children: [
1206
- /* @__PURE__ */ u(J.Text, { type: "secondary", children: n ?? "curl 命令" }),
1207
- r ? /* @__PURE__ */ u(Y, { title: r, children: /* @__PURE__ */ u(te, { className: "ask-user-curl-unpublished-tag", children: "卡片 ID 未发布" }) }) : null,
1208
- o ? /* @__PURE__ */ u(Y, { title: o, children: /* @__PURE__ */ u(te, { className: "ask-user-curl-incomplete-tag", children: "卡片 ID 待补足" }) }) : null
1501
+ return /* @__PURE__ */ M("div", { className: "ask-user-curl-card", children: [
1502
+ /* @__PURE__ */ M("div", { className: "ask-user-curl-card-header", children: [
1503
+ /* @__PURE__ */ M("div", { className: "ask-user-curl-card-header-title", children: [
1504
+ /* @__PURE__ */ s(R.Text, { type: "secondary", children: r ?? "curl 命令" }),
1505
+ n ? /* @__PURE__ */ s(Q, { title: n, children: /* @__PURE__ */ s(pe, { className: "ask-user-curl-unpublished-tag", children: "卡片 ID 未发布" }) }) : null,
1506
+ o ? /* @__PURE__ */ s(Q, { title: o, children: /* @__PURE__ */ s(pe, { className: "ask-user-curl-incomplete-tag", children: "卡片 ID 待补足" }) }) : null
1209
1507
  ] }),
1210
- /* @__PURE__ */ u(pe, { size: "small", type: "text", onClick: () => void l(), children: "复制" })
1508
+ /* @__PURE__ */ s(Fe, { size: "small", type: "text", onClick: () => void l(), children: "复制" })
1211
1509
  ] }),
1212
- /* @__PURE__ */ u("pre", { className: "skopon-form-curl-json", children: i })
1510
+ /* @__PURE__ */ s("pre", { className: "skopon-form-curl-json", children: a })
1213
1511
  ] });
1214
1512
  }
1215
- function Sn({
1513
+ function Dr(e, t) {
1514
+ if (t && typeof t == "object" && t !== null && "message" in t) {
1515
+ const r = t.message;
1516
+ if (typeof r == "string" && r.trim())
1517
+ return `提交失败 (${e}): ${r.trim()}`;
1518
+ }
1519
+ return typeof t == "string" && t.trim() ? `提交失败 (${e}): ${t.trim()}` : `提交失败 (${e})`;
1520
+ }
1521
+ function nn({
1216
1522
  payload: e,
1217
1523
  formUniqueId: t,
1218
- callbackUrl: n,
1219
- submitMode: r = "curl",
1524
+ callbackUrl: r,
1525
+ submitMode: n = "curl",
1220
1526
  fetchFormDetail: o,
1221
- onNotify: a
1527
+ onNotify: i
1222
1528
  }) {
1223
- const [i, l] = w(null), [c, s] = w(!1), [p, d] = w(!0), f = M(null);
1224
- C(() => {
1225
- let g = !1;
1226
- return d(!0), s(!1), o({ formUniqueId: t }).then((x) => {
1227
- g || (s(!!x.disabled), l(x.disabled ? null : x.formDefinition ?? null));
1228
- }).catch(() => {
1229
- g || (s(!1), l(null));
1529
+ const [a, l] = O(null), [c, u] = O(!1), [f, d] = O(!0), [p, y] = O(!1), k = w(null), T = w(!0), h = w(i);
1530
+ h.current = i;
1531
+ const x = (t == null ? void 0 : t.trim()) ?? "";
1532
+ _(() => (T.current = !0, () => {
1533
+ T.current = !1;
1534
+ }), []), _(() => {
1535
+ let A = !1;
1536
+ return x ? (d(!0), u(!1), o({ formUniqueId: x }).then((C) => {
1537
+ A || (u(!!C.disabled), l(C.formDefinition ?? null));
1538
+ }).catch((C) => {
1539
+ var U;
1540
+ if (!A) {
1541
+ u(!1), l(null);
1542
+ const q = C instanceof Error ? C.message : "获取表单定义失败";
1543
+ (U = h.current) == null || U.call(h, "error", q);
1544
+ }
1230
1545
  }).finally(() => {
1231
- g || d(!1);
1546
+ A || d(!1);
1232
1547
  }), () => {
1233
- g = !0;
1234
- };
1235
- }, [t, o]);
1236
- const { matchedBlocks: h, remainderPayload: A } = k(
1237
- () => jt(e, i ?? void 0),
1238
- [e, i]
1239
- ), Z = k(
1240
- () => h.map((g) => {
1241
- var x;
1242
- return (x = g.name) == null ? void 0 : x.trim();
1243
- }).filter((g) => !!g),
1244
- [h]
1245
- ), Pe = k(() => !i || h.length === 0 ? null : _t(i, h), [i, h]);
1246
- if (p)
1247
- return /* @__PURE__ */ u("div", { className: "ask-user-form-card", children: /* @__PURE__ */ u(Ne, { size: "small" }) });
1248
- if (h.length === 0)
1249
- return /* @__PURE__ */ u(
1250
- ie,
1548
+ A = !0;
1549
+ }) : (d(!1), u(!1), l(null), () => {
1550
+ A = !0;
1551
+ });
1552
+ }, [x, o]);
1553
+ const v = N(() => ir(e), [e]), b = N(() => v ? lr(v, a ?? void 0) : null, [v, a]), z = (b == null ? void 0 : b.matchedBlocks) ?? [], I = !!(v && ur(v) && z.length === 0), P = N(() => b && b.renderBlocks.length > 0 ? b.renderBlocks : I && v ? pr(v) : [], [b, I, v]), X = N(
1554
+ () => I ? {} : sr((b == null ? void 0 : b.extraBlocks) ?? []),
1555
+ [I, b]
1556
+ ), xe = N(() => I && v ? dr(v) : P.filter((A) => {
1557
+ var C;
1558
+ return (C = A.name) == null ? void 0 : C.trim();
1559
+ }).map((A) => A.name.trim()), [I, v, P]), Xe = N(() => {
1560
+ if (P.length === 0) return null;
1561
+ const A = (b == null ? void 0 : b.title) ?? (v == null ? void 0 : v.title) ?? "", C = (b == null ? void 0 : b.description) ?? (v == null ? void 0 : v.description) ?? "";
1562
+ return Wt({ title: A, description: C }, P);
1563
+ }, [b, v, P]), qe = x ? `ask-user-${x}` : "ask-user-payload";
1564
+ if (f)
1565
+ return /* @__PURE__ */ s("div", { className: "ask-user-form-card", children: /* @__PURE__ */ s(st, { size: "small" }) });
1566
+ if (!v || P.length === 0)
1567
+ return /* @__PURE__ */ s(
1568
+ Rr,
1251
1569
  {
1252
1570
  payload: e,
1253
- callbackUrl: n,
1254
- unpublishedFormId: c ? t : void 0,
1255
- onNotify: a
1571
+ callbackUrl: r,
1572
+ unpublishedFormId: c && x ? x : void 0,
1573
+ onNotify: i
1256
1574
  }
1257
1575
  );
1258
- const Ie = Object.keys(A).length > 0;
1259
- async function Ee() {
1260
- var x;
1261
- const g = ((x = f.current) == null ? void 0 : x.getValues(Z)) ?? {};
1262
- if (r === "post") {
1263
- const Q = (n ?? "").trim();
1264
- if (!Q) {
1265
- a == null || a("error", "callback_url 为空,无法提交");
1266
- return;
1267
- }
1576
+ async function Ke() {
1577
+ var A, C, U, q, Se, ke;
1578
+ if (!p) {
1579
+ y(!0);
1268
1580
  try {
1269
- const T = await Vt(Q, g);
1270
- T.ok ? a == null || a("success", "提交成功") : a == null || a("error", `提交失败 (${T.status})`);
1271
- } catch (T) {
1272
- const _e = T instanceof Error ? T.message : "提交失败";
1273
- a == null || a("error", _e);
1581
+ const $ = ((A = k.current) == null ? void 0 : A.getValues(xe)) ?? {}, oe = { ...$, ...X };
1582
+ if (n === "post") {
1583
+ const Ae = (r ?? "").trim();
1584
+ if (!Ae) {
1585
+ (C = h.current) == null || C.call(h, "error", "callback_url 为空,无法提交");
1586
+ return;
1587
+ }
1588
+ const ae = await mr(Ae, oe);
1589
+ if (!T.current) return;
1590
+ ae.ok ? (U = h.current) == null || U.call(h, "success", "提交成功") : (q = h.current) == null || q.call(h, "error", Dr(ae.status, ae.body));
1591
+ return;
1592
+ }
1593
+ if (await $e(
1594
+ rr({ cardValues: $, extraValues: X, callbackUrl: r })
1595
+ ), !T.current) return;
1596
+ (Se = h.current) == null || Se.call(h, "success", "已复制 curl 到剪贴板");
1597
+ } catch ($) {
1598
+ if (!T.current) return;
1599
+ const oe = $ instanceof Error ? $.message : "复制失败";
1600
+ (ke = h.current) == null || ke.call(h, "error", oe);
1601
+ } finally {
1602
+ T.current && y(!1);
1274
1603
  }
1275
- return;
1276
- }
1277
- try {
1278
- await Se(xe(g, n)), a == null || a("success", "已复制 curl 到剪贴板");
1279
- } catch {
1280
- a == null || a("error", "复制失败");
1281
1604
  }
1282
1605
  }
1283
- return /* @__PURE__ */ b("div", { className: "ask-user-form-card", children: [
1284
- /* @__PURE__ */ u(
1285
- ln,
1606
+ return /* @__PURE__ */ M("div", { className: "ask-user-form-card", children: [
1607
+ c && x ? /* @__PURE__ */ s("div", { className: "ask-user-form-card-status", children: /* @__PURE__ */ s(Q, { title: x, children: /* @__PURE__ */ s(pe, { className: "ask-user-curl-unpublished-tag", children: "卡片 ID 未发布" }) }) }) : null,
1608
+ /* @__PURE__ */ s(
1609
+ $r,
1286
1610
  {
1287
- ref: f,
1288
- doc: Pe,
1289
- surfaceId: `ask-user-${t}`,
1290
- fieldNames: Z,
1611
+ ref: k,
1612
+ doc: Xe,
1613
+ surfaceId: qe,
1614
+ fieldNames: xe,
1291
1615
  interactive: !0
1292
1616
  }
1293
1617
  ),
1294
- /* @__PURE__ */ u("div", { className: "ask-user-form-actions", children: /* @__PURE__ */ u(Y, { title: r === "curl" ? "点击复制 curl" : "提交 JSON 到 callback_url", children: /* @__PURE__ */ u(pe, { type: "primary", size: "small", onClick: () => void Ee(), children: "提交" }) }) }),
1295
- Ie ? /* @__PURE__ */ u(
1296
- ie,
1618
+ /* @__PURE__ */ s("div", { className: "ask-user-form-actions", children: /* @__PURE__ */ s(Q, { title: n === "curl" ? "点击复制 curl" : "提交 JSON 到 callback_url", children: /* @__PURE__ */ s(
1619
+ Fe,
1297
1620
  {
1298
- payload: A,
1299
- callbackUrl: n,
1300
- title: "以下字段不在表单中,请使用 curl 提交",
1301
- incompleteFormId: t,
1302
- onNotify: a
1621
+ type: "primary",
1622
+ size: "small",
1623
+ loading: p,
1624
+ disabled: p,
1625
+ onClick: () => void Ke(),
1626
+ children: "提交"
1303
1627
  }
1304
- ) : null
1628
+ ) }) })
1305
1629
  ] });
1306
1630
  }
1307
1631
  export {
1308
- bn as A2UI_PROTOCOL_VERSION,
1309
- Sn as AskUserFormCard,
1310
- ie as CurlSubmitBlock,
1311
- Ke as FORM_MEDIA_SIZES,
1312
- xn as SkoponA2uiStreamRenderer,
1313
- ln as SkoponFormRenderer,
1314
- Pt as a2uiToBlocks,
1315
- ye as blocksToA2ui,
1316
- _t as buildAskUserSurface,
1317
- xe as buildCurlStatement,
1318
- Se as copyTextToClipboard,
1319
- gn as createFormClient,
1320
- wt as extractSurfaceValues,
1321
- jt as intersectPayloadWithForm,
1322
- q as isA2uiSurfaceEmpty,
1323
- re as isInputBlockType,
1324
- qe as isLayoutBlockType,
1325
- G as isMediaBlockType,
1326
- Ft as mapFormDefinitionFromDto,
1327
- he as normalizeFormDefinition,
1328
- Et as resolveSurfaceFromFormDefinition,
1329
- Vt as submitFormJson,
1330
- It as surfaceDocToMessages,
1331
- D as syncFormDefinition
1632
+ en as A2UI_PROTOCOL_VERSION,
1633
+ nn as AskUserFormCard,
1634
+ Rr as CurlSubmitBlock,
1635
+ ht as FORM_MEDIA_SIZES,
1636
+ rn as SkoponA2uiStreamRenderer,
1637
+ $r as SkoponFormRenderer,
1638
+ Xt as a2uiToBlocks,
1639
+ je as blocksToA2ui,
1640
+ tr as buildAskUserCurlBodyJson,
1641
+ rr as buildAskUserCurlStatement,
1642
+ Wt as buildAskUserSurface,
1643
+ er as buildCurlStatement,
1644
+ $e as copyTextToClipboard,
1645
+ tn as createFormClient,
1646
+ sr as extractExtraBlockValues,
1647
+ Qt as extractSurfaceValues,
1648
+ dr as getPayloadInputFieldNames,
1649
+ pr as getPayloadRenderableBlocks,
1650
+ lr as intersectPayloadBlocksWithForm,
1651
+ he as isA2uiSurfaceEmpty,
1652
+ F as isInputBlockType,
1653
+ ve as isLayoutBlockType,
1654
+ de as isMediaBlockType,
1655
+ Zt as mapFormDefinitionFromDto,
1656
+ B as normalizeFormDefinition,
1657
+ ir as parsePayloadBlocksJson,
1658
+ ur as payloadHasInputBlocks,
1659
+ Kt as resolveSurfaceFromFormDefinition,
1660
+ mr as submitFormJson,
1661
+ qt as surfaceDocToMessages,
1662
+ ee as syncFormDefinition
1332
1663
  };