@skopon-cool/form-sdk 0.1.1 → 0.1.4

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 (93) hide show
  1. package/README.md +49 -11
  2. package/dist/adapter/a2uiAdapter.d.ts +0 -1
  3. package/dist/adapter/a2uiAdapter.d.ts.map +1 -1
  4. package/dist/adapter/formFileAccept.d.ts.map +1 -1
  5. package/dist/adapter/formSchema.d.ts +1 -0
  6. package/dist/adapter/formSchema.d.ts.map +1 -1
  7. package/dist/blocks/case_singleselect/adapter.d.ts +10 -0
  8. package/dist/blocks/case_singleselect/adapter.d.ts.map +1 -0
  9. package/dist/blocks/case_singleselect/catalog.d.ts +2 -0
  10. package/dist/blocks/case_singleselect/catalog.d.ts.map +1 -0
  11. package/dist/blocks/case_singleselect/index.d.ts +3 -0
  12. package/dist/blocks/case_singleselect/index.d.ts.map +1 -0
  13. package/dist/blocks/registry.d.ts +8 -0
  14. package/dist/blocks/registry.d.ts.map +1 -0
  15. package/dist/blocks/resume_multiselect/adapter.d.ts +10 -0
  16. package/dist/blocks/resume_multiselect/adapter.d.ts.map +1 -0
  17. package/dist/blocks/resume_multiselect/catalog.d.ts +2 -0
  18. package/dist/blocks/resume_multiselect/catalog.d.ts.map +1 -0
  19. package/dist/blocks/resume_multiselect/index.d.ts +3 -0
  20. package/dist/blocks/resume_multiselect/index.d.ts.map +1 -0
  21. package/dist/blocks/types.d.ts +27 -0
  22. package/dist/blocks/types.d.ts.map +1 -0
  23. package/dist/catalog/a2uiCustomCatalog.d.ts.map +1 -1
  24. package/dist/catalog/caseSearchContext.d.ts +28 -0
  25. package/dist/catalog/caseSearchContext.d.ts.map +1 -0
  26. package/dist/catalog/resumeSearchContext.d.ts +30 -0
  27. package/dist/catalog/resumeSearchContext.d.ts.map +1 -0
  28. package/dist/catalog/skoponCaseSelect.d.ts +2 -0
  29. package/dist/catalog/skoponCaseSelect.d.ts.map +1 -0
  30. package/dist/catalog/skoponResumeSelect.d.ts +2 -0
  31. package/dist/catalog/skoponResumeSelect.d.ts.map +1 -0
  32. package/dist/catalog/useSkoponBoundField.d.ts +2 -0
  33. package/dist/catalog/useSkoponBoundField.d.ts.map +1 -1
  34. package/dist/client/formClient.d.ts.map +1 -1
  35. package/dist/components/AskUserFormCard.d.ts +10 -2
  36. package/dist/components/AskUserFormCard.d.ts.map +1 -1
  37. package/dist/components/SkoponA2uiStreamRenderer.d.ts +7 -1
  38. package/dist/components/SkoponA2uiStreamRenderer.d.ts.map +1 -1
  39. package/dist/components/SkoponA2uiStreamRenderer.test.d.ts +2 -0
  40. package/dist/components/SkoponA2uiStreamRenderer.test.d.ts.map +1 -0
  41. package/dist/components/SkoponFormRenderer.d.ts +6 -0
  42. package/dist/components/SkoponFormRenderer.d.ts.map +1 -1
  43. package/dist/form-sdk.css +1 -1
  44. package/dist/index.d.ts +7 -2
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +1390 -710
  47. package/dist/submit/buildCurlStatement.d.ts +8 -0
  48. package/dist/submit/buildCurlStatement.d.ts.map +1 -1
  49. package/dist/submit/intersectPayloadBlocksWithForm.d.ts +26 -0
  50. package/dist/submit/intersectPayloadBlocksWithForm.d.ts.map +1 -0
  51. package/dist/submit/submitFormJson.d.ts.map +1 -1
  52. package/dist/types/index.d.ts +26 -2
  53. package/dist/types/index.d.ts.map +1 -1
  54. package/package.json +11 -6
  55. package/src/adapter/a2uiAdapter.test.ts +116 -0
  56. package/src/adapter/a2uiAdapter.ts +48 -4
  57. package/src/adapter/formFileAccept.test.ts +53 -0
  58. package/src/adapter/formFileAccept.ts +11 -2
  59. package/src/adapter/formSchema.test.ts +35 -0
  60. package/src/adapter/formSchema.ts +70 -3
  61. package/src/blocks/case_singleselect/adapter.ts +74 -0
  62. package/src/blocks/case_singleselect/catalog.ts +1 -0
  63. package/src/blocks/case_singleselect/index.ts +14 -0
  64. package/src/blocks/registry.ts +34 -0
  65. package/src/blocks/resume_multiselect/adapter.ts +57 -0
  66. package/src/blocks/resume_multiselect/catalog.ts +1 -0
  67. package/src/blocks/resume_multiselect/index.ts +14 -0
  68. package/src/blocks/types.ts +34 -0
  69. package/src/catalog/a2uiCustomCatalog.tsx +34 -5
  70. package/src/catalog/caseSearchContext.tsx +46 -0
  71. package/src/catalog/resumeSearchContext.tsx +48 -0
  72. package/src/catalog/skoponCaseSelect.tsx +215 -0
  73. package/src/catalog/skoponResumeSelect.tsx +227 -0
  74. package/src/catalog/textFieldPreview.test.tsx +1 -1
  75. package/src/catalog/useSkoponBoundField.test.ts +62 -0
  76. package/src/catalog/useSkoponBoundField.ts +10 -1
  77. package/src/client/formClient.test.ts +83 -0
  78. package/src/client/formClient.ts +10 -2
  79. package/src/components/AskUserFormCard.tsx +146 -58
  80. package/src/components/SkoponA2uiStreamRenderer.test.ts +78 -0
  81. package/src/components/SkoponA2uiStreamRenderer.test.tsx +103 -0
  82. package/src/components/SkoponA2uiStreamRenderer.tsx +141 -23
  83. package/src/components/SkoponFormRenderer.tsx +42 -17
  84. package/src/index.ts +34 -2
  85. package/src/styles/index.css +65 -0
  86. package/src/submit/buildCurlStatement.ts +49 -0
  87. package/src/submit/intersectPayloadBlocksWithForm.ts +175 -0
  88. package/src/submit/submit.test.ts +170 -10
  89. package/src/submit/submitFormJson.ts +20 -1
  90. package/src/types/index.ts +30 -0
  91. package/dist/submit/intersectPayloadWithForm.d.ts +0 -17
  92. package/dist/submit/intersectPayloadWithForm.d.ts.map +0 -1
  93. package/src/submit/intersectPayloadWithForm.ts +0 -54
package/dist/index.js CHANGED
@@ -1,31 +1,31 @@
1
1
  import './form-sdk.css';
2
- import { jsx as u, jsxs as b, Fragment as le } from "react/jsx-runtime";
3
- import { createContext as Fe, useContext as Oe, useCallback as $, useSyncExternalStore as De, forwardRef as je, useEffect as P, useRef as M, useMemo as A, useImperativeHandle as Ne, useState as j } from "react";
4
- import { Catalog as Re, MessageProcessor as ce } from "@a2ui/web_core/v0_9";
5
- import { injectBasicCatalogStyles as se } from "@a2ui/web_core/v0_9/basic_catalog";
6
- import { basicCatalog as N, createBinderlessComponentImplementation as x, A2uiSurface as ue } from "@a2ui/react/v0_9";
7
- import { injectStyles as pe } from "@a2ui/react/styles";
8
- import { z as p } from "zod";
9
- import { Typography as E, Select as G, Checkbox as Ve, Radio as ze, Switch as Le, TimePicker as Ue, DatePicker as Be, Upload as te, Input as H, InputNumber as $e, Tooltip as X, Tag as ne, Button as de, Spin as He } from "antd";
10
- import re from "dayjs";
11
- import { FileTextOutlined as Ye, FileExcelOutlined as Ge, FileOutlined as me, PictureOutlined as Xe, SoundOutlined as Ke, VideoCameraOutlined as qe } from "@ant-design/icons";
12
- const Cn = "v0.9", Je = [
2
+ import { jsx as c, jsxs as N, Fragment as qe } from "react/jsx-runtime";
3
+ import { createContext as Fe, useContext as Me, useCallback as Z, useSyncExternalStore as ft, useMemo as O, useState as E, useRef as V, useEffect as w, forwardRef as ht, useImperativeHandle as gt } from "react";
4
+ import { Spin as Pe, Button as ce, Typography as $, Avatar as yt, Select as ke, Checkbox as vt, Radio as bt, Switch as St, TimePicker as xt, DatePicker as kt, Upload as he, Input as ge, InputNumber as At, Tooltip as ie, Tag as Ae } from "antd";
5
+ import { ReloadOutlined as De, FileTextOutlined as Je, UserOutlined as It, FileExcelOutlined as Ct, FileOutlined as Ke, PictureOutlined as Tt, SoundOutlined as Nt, VideoCameraOutlined as Ft } from "@ant-design/icons";
6
+ import { createBinderlessComponentImplementation as R, basicCatalog as ae, A2uiSurface as He } from "@a2ui/react/v0_9";
7
+ import { z as m } from "zod";
8
+ import { Catalog as Mt, MessageProcessor as Ye } from "@a2ui/web_core/v0_9";
9
+ import { injectBasicCatalogStyles as Ge } from "@a2ui/web_core/v0_9/basic_catalog";
10
+ import { injectStyles as Xe } from "@a2ui/react/styles";
11
+ import Be from "dayjs";
12
+ const Lr = "v0.9", Pt = [
13
13
  "huge",
14
14
  "large",
15
15
  "medium",
16
16
  "small",
17
17
  "icon"
18
18
  ];
19
- function K(e) {
19
+ function Ie(e) {
20
20
  return e === "image" || e === "video" || e === "audio";
21
21
  }
22
- function We(e) {
22
+ function Ee(e) {
23
23
  return e === "heading" || e === "paragraph";
24
24
  }
25
- function oe(e) {
26
- return !We(e) && !K(e);
25
+ function K(e) {
26
+ return !Ee(e) && !Ie(e);
27
27
  }
28
- function Ze() {
28
+ function Et() {
29
29
  if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
30
30
  return crypto.randomUUID();
31
31
  if (typeof crypto < "u" && typeof crypto.getRandomValues == "function") {
@@ -39,30 +39,11 @@ function Ze() {
39
39
  return (e === "x" ? t : t & 3 | 8).toString(16);
40
40
  });
41
41
  }
42
- function w(e) {
43
- const t = Ze().replace(/-/g, "").slice(0, 8);
42
+ function Q(e) {
43
+ const t = Et().replace(/-/g, "").slice(0, 8);
44
44
  return `${e}${t}`;
45
45
  }
46
- function F(e) {
47
- return typeof e == "string" && Je.includes(e) ? e : "medium";
48
- }
49
- function Qe(e, t) {
50
- var o;
51
- const n = Math.max(1, t);
52
- let r = [];
53
- return Array.isArray(e.mediaUrls) ? r = e.mediaUrls.map((i) => String(i).trim()) : (o = e.mediaUrl) != null && o.trim() && (r = [e.mediaUrl.trim()]), r.length === 0 ? [""] : r.slice(0, n);
54
- }
55
- function et(e) {
56
- var t;
57
- return Array.isArray(e.mediaUrls) ? e.mediaUrls.map((n) => n.trim()).filter(Boolean) : (t = e.mediaUrl) != null && t.trim() ? [e.mediaUrl.trim()] : [];
58
- }
59
- function tt(e) {
60
- return `form-media-size-${F(e)}`;
61
- }
62
- function nt(e) {
63
- return `form-media-preview form-media-list ${tt(e)}`;
64
- }
65
- const fe = [
46
+ const We = [
66
47
  { value: "image/*", label: "图片" },
67
48
  { value: "video/*", label: "视频" },
68
49
  { value: "audio/*", label: "音频" },
@@ -73,7 +54,7 @@ const fe = [
73
54
  { value: "text/plain", label: "纯文本" },
74
55
  { value: "application/zip", label: "ZIP 压缩包" },
75
56
  { value: "application/x-rar-compressed", label: "RAR 压缩包" }
76
- ], rt = {
57
+ ], zt = {
77
58
  "image/*": ["image/*"],
78
59
  "video/*": ["video/*"],
79
60
  "audio/*": ["audio/*"],
@@ -93,7 +74,7 @@ const fe = [
93
74
  "text/plain": ["text/plain"],
94
75
  "application/zip": ["application/zip"],
95
76
  "application/x-rar-compressed": ["application/x-rar-compressed"]
96
- }, ot = {
77
+ }, _t = {
97
78
  "image/*": [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg"],
98
79
  "video/*": [".mp4", ".mov", ".avi", ".webm"],
99
80
  "audio/*": [".mp3", ".wav", ".ogg", ".m4a"],
@@ -104,14 +85,14 @@ const fe = [
104
85
  "text/plain": [".txt"],
105
86
  "application/zip": [".zip", ".7z"],
106
87
  "application/x-rar-compressed": [".rar"]
107
- }, at = {
88
+ }, Rt = {
108
89
  "application/msword": "office/word",
109
90
  "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "office/word",
110
91
  "application/vnd.ms-excel": "office/excel",
111
92
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "office/excel",
112
93
  "application/vnd.ms-powerpoint": "office/ppt",
113
94
  "application/vnd.openxmlformats-officedocument.presentationml.presentation": "office/ppt"
114
- }, he = [
95
+ }, ze = [
115
96
  { value: ".jpg", label: ".jpg" },
116
97
  { value: ".jpeg", label: ".jpeg" },
117
98
  { value: ".png", label: ".png" },
@@ -137,117 +118,161 @@ const fe = [
137
118
  { value: ".zip", label: ".zip" },
138
119
  { value: ".rar", label: ".rar" },
139
120
  { value: ".7z", label: ".7z" }
140
- ], it = Object.fromEntries(
141
- fe.map((e) => [e.value, e.label])
142
- ), lt = Object.fromEntries(
143
- he.map((e) => [e.value, e.label])
144
- ), ct = new Set(fe.map((e) => e.value));
145
- function st(e) {
121
+ ], Ut = Object.fromEntries(
122
+ We.map((e) => [e.value, e.label])
123
+ ), Ot = Object.fromEntries(
124
+ ze.map((e) => [e.value, e.label])
125
+ ), Vt = new Set(We.map((e) => e.value)), Bt = new Set(
126
+ ze.map((e) => e.value)
127
+ );
128
+ function wt(e) {
146
129
  const t = e.trim();
147
- return t ? ct.has(t) ? t : at[t] ?? null : null;
130
+ return t ? Vt.has(t) ? t : Rt[t] ?? null : null;
148
131
  }
149
- function ut(e) {
132
+ function jt(e) {
150
133
  return Array.isArray(e) ? e.map((t) => {
151
134
  const n = t.trim().toLowerCase();
152
135
  return n ? n.startsWith(".") ? n : `.${n}` : "";
153
136
  }).filter(Boolean) : [];
154
137
  }
155
- function L(e) {
138
+ function ee(e) {
156
139
  if (!Array.isArray(e)) return [];
157
140
  const t = [], n = /* @__PURE__ */ new Set();
158
141
  for (const r of e) {
159
- const o = st(r);
142
+ const o = wt(r);
160
143
  o && !n.has(o) && (n.add(o), t.push(o));
161
144
  }
162
145
  return t;
163
146
  }
164
- function pt(e) {
165
- const t = L(e), n = [];
147
+ function $t(e) {
148
+ const t = ee(e), n = [];
166
149
  for (const r of t)
167
- n.push(...rt[r] ?? [r]);
150
+ n.push(...zt[r] ?? [r]);
168
151
  return n;
169
152
  }
170
- function dt(e) {
171
- const t = L(e);
153
+ function Lt(e) {
154
+ const t = ee(e);
172
155
  if (t.length === 0) return [];
173
156
  const n = /* @__PURE__ */ new Set();
174
157
  for (const r of t)
175
- for (const o of ot[r] ?? [])
158
+ for (const o of _t[r] ?? [])
176
159
  n.add(o);
177
- return he.filter((r) => n.has(r.value));
178
- }
179
- function Z(e, t) {
180
- const n = new Set(
181
- dt(e).map((r) => r.value)
160
+ return ze.filter((r) => n.has(r.value));
161
+ }
162
+ function _e(e, t) {
163
+ const n = jt(t), r = ee(e);
164
+ if (r.length === 0)
165
+ return n.filter((a) => Bt.has(a));
166
+ const o = new Set(
167
+ Lt(r).map((a) => a.value)
182
168
  );
183
- return ut(t).filter((r) => n.has(r));
169
+ return n.filter((a) => o.has(a));
184
170
  }
185
- function mt(e, t) {
186
- const n = pt(e), r = Z(e, t), o = [...n, ...r];
171
+ function qt(e, t) {
172
+ const n = $t(e), r = _e(e, t), o = [...n, ...r];
187
173
  return o.length > 0 ? o.join(",") : void 0;
188
174
  }
189
- function ft(e, t) {
190
- const n = L(e), r = Z(
175
+ function Dt(e, t) {
176
+ const n = ee(e), r = _e(
191
177
  n,
192
178
  t
193
179
  ), o = [
194
- ...n.map((i) => it[i] ?? i),
195
- ...r.map((i) => lt[i] ?? i)
180
+ ...n.map((a) => Ut[a] ?? a),
181
+ ...r.map((a) => Ot[a] ?? a)
196
182
  ];
197
183
  return o.length === 0 ? null : o.join("、");
198
184
  }
199
- const ht = [
185
+ const Jt = [
200
186
  "video",
201
187
  "audio",
202
188
  "image",
203
189
  "file",
204
190
  "spreadsheet",
205
191
  "document"
206
- ], vt = new Set(ht);
207
- function yt(e) {
208
- return e && vt.has(e) ? e : "file";
192
+ ], Kt = new Set(Jt);
193
+ function Ht(e) {
194
+ return e && Kt.has(e) ? e : "file";
195
+ }
196
+ function te(e) {
197
+ return typeof e == "string" && Pt.includes(e) ? e : "medium";
209
198
  }
210
- const bt = 10;
211
- function ae(e, t = 1) {
199
+ function Yt(e, t) {
200
+ var o;
201
+ const n = Math.max(1, t);
202
+ let r = [];
203
+ 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);
204
+ }
205
+ function Gt(e) {
206
+ var t;
207
+ return Array.isArray(e.mediaUrls) ? e.mediaUrls.map((n) => n.trim()).filter(Boolean) : (t = e.mediaUrl) != null && t.trim() ? [e.mediaUrl.trim()] : [];
208
+ }
209
+ function Xt(e) {
210
+ return `form-media-size-${te(e)}`;
211
+ }
212
+ function Wt(e) {
213
+ return `form-media-preview form-media-list ${Xt(e)}`;
214
+ }
215
+ const Zt = 10;
216
+ function Re(e) {
217
+ return e === !0 || e === "true";
218
+ }
219
+ function we(e, t = 1) {
212
220
  const n = typeof e == "number" ? e : Number(e);
213
221
  return Number.isFinite(n) ? Math.max(0, Math.floor(n)) : t;
214
222
  }
215
- function gt(e, t) {
223
+ function Qt(e, t) {
216
224
  if (t !== void 0)
217
- 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" ? Re(t) : e === "multiselect" || e === "checkbox" || e === "resume_multiselect" ? 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);
226
+ }
227
+ function en(e) {
228
+ const t = typeof (e == null ? void 0 : e.pageSize) == "number" ? e.pageSize : Number(e == null ? void 0 : e.pageSize), n = Number.isFinite(t) && t >= 1 && t <= 100 ? Math.floor(t) : 20, r = typeof (e == null ? void 0 : e.flowId) == "number" ? e.flowId : Number(e == null ? void 0 : e.flowId), o = Number.isFinite(r) && r > 0 ? Math.floor(r) : void 0, a = typeof (e == null ? void 0 : e.agentKind) == "string" && e.agentKind.trim() ? e.agentKind.trim() : void 0, i = typeof (e == null ? void 0 : e.agentUniqueId) == "string" && e.agentUniqueId.trim() ? e.agentUniqueId.trim() : void 0;
229
+ return { agentKind: a, agentUniqueId: i, flowId: o, pageSize: n };
230
+ }
231
+ function tn(e) {
232
+ const t = typeof (e == null ? void 0 : e.pageSize) == "number" ? e.pageSize : Number(e == null ? void 0 : e.pageSize), n = Number.isFinite(t) && t >= 1 && t <= 100 ? Math.floor(t) : 20;
233
+ return {
234
+ names: Array.isArray(e == null ? void 0 : e.names) ? e.names.map(String).filter(Boolean) : [],
235
+ agentUniqueIds: Array.isArray(e == null ? void 0 : e.agentUniqueIds) ? e.agentUniqueIds.map(String).filter(Boolean) : [],
236
+ resumeUniqueIds: Array.isArray(e == null ? void 0 : e.resumeUniqueIds) ? e.resumeUniqueIds.map(String).filter(Boolean) : [],
237
+ pageSize: n
238
+ };
218
239
  }
219
- function xt(e) {
240
+ function nn(e) {
220
241
  var r, o;
221
- const t = L(e.fileAcceptTypes), n = e.type;
242
+ const t = ee(e.fileAcceptTypes), n = e.type;
222
243
  return {
223
- id: ((r = e.id) == null ? void 0 : r.trim()) || w("block-"),
244
+ id: ((r = e.id) == null ? void 0 : r.trim()) || Q("block-"),
224
245
  type: n,
225
246
  name: ((o = e.name) == null ? void 0 : o.trim()) || void 0,
226
247
  label: e.label ?? "",
227
248
  placeholder: e.placeholder ?? "",
228
249
  help: e.help ?? "",
229
250
  required: e.required === !0,
230
- mediaUrls: K(n) ? Qe(e, bt) : void 0,
231
- mediaSize: K(n) ? F(e.mediaSize) : void 0,
251
+ mediaUrls: Ie(n) ? Yt(e, Zt) : void 0,
252
+ mediaSize: Ie(n) ? te(e.mediaSize) : void 0,
232
253
  fileAcceptTypes: t,
233
- fileAcceptExtensions: Z(
254
+ fileAcceptExtensions: _e(
234
255
  t,
235
256
  e.fileAcceptExtensions
236
257
  ),
237
- filePlaceholderIcon: yt(e.filePlaceholderIcon),
238
- fileMinCount: n === "file" ? ae(e.fileMinCount, 1) : void 0,
239
- fileMaxCount: n === "file" ? ae(e.fileMaxCount, 1) : void 0,
240
- defaultValue: gt(n, e.defaultValue),
241
- options: Array.isArray(e.options) ? e.options.map((i, a) => {
242
- var l, c;
258
+ filePlaceholderIcon: Ht(e.filePlaceholderIcon),
259
+ fileMinCount: n === "file" ? we(e.fileMinCount, 1) : void 0,
260
+ fileMaxCount: n === "file" ? we(e.fileMaxCount, 1) : void 0,
261
+ defaultValue: Qt(n, e.defaultValue),
262
+ options: Array.isArray(e.options) ? e.options.map((a, i) => {
263
+ var l, s;
243
264
  return {
244
- value: ((l = i.value) == null ? void 0 : l.trim()) || `option_${a + 1}`,
245
- label: ((c = i.label) == null ? void 0 : c.trim()) || `选项 ${a + 1}`
265
+ value: ((l = a.value) == null ? void 0 : l.trim()) || `option_${i + 1}`,
266
+ label: ((s = a.label) == null ? void 0 : s.trim()) || `选项 ${i + 1}`
246
267
  };
247
- }) : void 0
268
+ }) : void 0,
269
+ resumeEnableRefresh: n === "resume_multiselect" ? e.resumeEnableRefresh !== !1 : void 0,
270
+ resumeFilter: n === "resume_multiselect" ? tn(e.resumeFilter) : void 0,
271
+ caseEnableRefresh: n === "case_singleselect" ? e.caseEnableRefresh !== !1 : void 0,
272
+ caseFilter: n === "case_singleselect" ? en(e.caseFilter) : void 0
248
273
  };
249
274
  }
250
- function R(e) {
275
+ function le(e) {
251
276
  return {
252
277
  title: e.title ?? "",
253
278
  description: e.description ?? "",
@@ -255,74 +280,496 @@ function R(e) {
255
280
  jsonSchema: e.jsonSchema ?? {}
256
281
  };
257
282
  }
258
- function ve(e) {
283
+ function Y(e) {
259
284
  if (!e || !Array.isArray(e.blocks))
260
- return R({ title: "", description: "", blocks: [], jsonSchema: {} });
261
- const t = e.blocks.map(xt);
262
- return R({
285
+ return le({ title: "", description: "", blocks: [], jsonSchema: {} });
286
+ const t = e.blocks.map(nn);
287
+ return le({
263
288
  title: typeof e.title == "string" ? e.title : "",
264
289
  description: typeof e.description == "string" ? e.description : "",
265
290
  blocks: t,
266
291
  jsonSchema: {}
267
292
  });
268
293
  }
269
- const V = "root", q = "__title__", J = "__desc__", ye = "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$";
270
- function St(e) {
294
+ function rn(e, t) {
295
+ var i, l, s, u;
296
+ const { id: n, label: r, path: o, withData: a } = t;
297
+ return a({
298
+ id: n,
299
+ component: "SkoponCaseSelect",
300
+ label: r,
301
+ placeholder: e.placeholder ?? "",
302
+ help: e.help ?? "",
303
+ enableRefresh: e.caseEnableRefresh !== !1,
304
+ caseFilter: {
305
+ agentKind: (i = e.caseFilter) == null ? void 0 : i.agentKind,
306
+ agentUniqueId: (l = e.caseFilter) == null ? void 0 : l.agentUniqueId,
307
+ flowId: (s = e.caseFilter) == null ? void 0 : s.flowId,
308
+ pageSize: ((u = e.caseFilter) == null ? void 0 : u.pageSize) ?? 20
309
+ },
310
+ value: { path: o }
311
+ });
312
+ }
313
+ function on(e, t, n) {
314
+ const r = n.nameFromValue(e.value), o = {
315
+ ...t("case_singleselect"),
316
+ name: r,
317
+ caseEnableRefresh: e.enableRefresh !== !1
318
+ }, a = n.asLiteral(e.placeholder);
319
+ a && (o.placeholder = a);
320
+ const i = n.asLiteral(e.help);
321
+ if (i && (o.help = i), e.caseFilter && typeof e.caseFilter == "object") {
322
+ const l = e.caseFilter, s = typeof l.flowId == "number" ? l.flowId : Number(l.flowId), u = typeof l.pageSize == "number" ? l.pageSize : Number(l.pageSize), d = typeof l.agentKind == "string" && l.agentKind.trim() ? l.agentKind.trim() : void 0, p = typeof l.agentUniqueId == "string" && l.agentUniqueId.trim() ? l.agentUniqueId.trim() : void 0;
323
+ o.caseFilter = {
324
+ agentKind: d,
325
+ agentUniqueId: p,
326
+ flowId: Number.isFinite(s) && s > 0 ? Math.floor(s) : void 0,
327
+ pageSize: Number.isFinite(u) && u >= 1 && u <= 100 ? Math.floor(u) : 20
328
+ };
329
+ }
330
+ return o;
331
+ }
332
+ const Ze = Fe({ interactive: !0 });
333
+ function Qe({
334
+ interactive: e,
335
+ children: t
336
+ }) {
337
+ return /* @__PURE__ */ c(Ze.Provider, { value: { interactive: e }, children: t });
338
+ }
339
+ function L() {
340
+ return Me(Ze);
341
+ }
342
+ function et(e) {
343
+ return e && typeof e == "object" && "path" in e && String(e.path ?? "").trim() || null;
344
+ }
345
+ function je(e, t = "value") {
346
+ const r = e.componentModel.properties[t];
347
+ if (!(!et(r) || r === void 0))
348
+ return e.dataContext.resolveDynamicValue(r);
349
+ }
350
+ function q(e, t = "value") {
351
+ const r = e.componentModel.properties[t], o = et(r), a = Z(
352
+ (u) => {
353
+ if (!o || r === void 0) return () => {
354
+ };
355
+ const d = e.dataContext.subscribeDynamicValue(r, () => u());
356
+ return () => d.unsubscribe();
357
+ },
358
+ [e, r, o]
359
+ ), i = Z(() => {
360
+ if (!(!o || r === void 0))
361
+ return e.dataContext.resolveDynamicValue(r);
362
+ }, [e, r, o]), l = ft(a, i, i), s = Z(
363
+ (u) => {
364
+ !o || !r || typeof r != "object" || !("path" in r) || e.dataContext.set(String(r.path), u);
365
+ },
366
+ [e, r, o]
367
+ );
368
+ return { value: l, setValue: s, hasBinding: !!o };
369
+ }
370
+ function H(e) {
371
+ if (typeof e == "string") return e || void 0;
372
+ if (typeof e == "number") return String(e);
373
+ }
374
+ function J(e) {
375
+ return Array.isArray(e) ? e.map(String) : typeof e == "string" && e ? [e] : [];
376
+ }
377
+ const tt = Fe(null);
378
+ function nt({
379
+ caseSearch: e,
380
+ children: t
381
+ }) {
382
+ return /* @__PURE__ */ c(tt.Provider, { value: e ?? null, children: t });
383
+ }
384
+ function an() {
385
+ return Me(tt);
386
+ }
387
+ function ye(e) {
388
+ return typeof e == "string" ? e : "";
389
+ }
390
+ function ve(e) {
391
+ if (!e || typeof e != "object")
392
+ return { pageSize: 20 };
393
+ const t = e, n = typeof t.flowId == "number" ? t.flowId : Number(t.flowId), r = Number.isFinite(n) && n > 0 ? Math.floor(n) : void 0, o = typeof t.pageSize == "number" ? t.pageSize : Number(t.pageSize), a = Number.isFinite(o) && o >= 1 && o <= 100 ? Math.floor(o) : 20;
394
+ return { flowId: r, pageSize: a };
395
+ }
396
+ function ln(e) {
397
+ return JSON.stringify(e);
398
+ }
399
+ const sn = {
400
+ name: "SkoponCaseSelect",
401
+ schema: m.object({
402
+ label: m.any().optional(),
403
+ placeholder: m.any().optional(),
404
+ help: m.any().optional(),
405
+ enableRefresh: m.any().optional(),
406
+ caseFilter: m.any().optional(),
407
+ value: m.any().optional()
408
+ }).passthrough()
409
+ };
410
+ function cn({
411
+ item: e,
412
+ selected: t,
413
+ disabled: n,
414
+ onToggle: r
415
+ }) {
416
+ return /* @__PURE__ */ N(
417
+ "button",
418
+ {
419
+ type: "button",
420
+ className: `skopon-resume-select-card${t ? " skopon-resume-select-card--selected" : ""}`,
421
+ disabled: n,
422
+ onClick: r,
423
+ children: [
424
+ /* @__PURE__ */ c("div", { className: "skopon-resume-select-card-avatar", children: /* @__PURE__ */ c(Je, { style: { fontSize: 24, color: "var(--color-primary, #1677ff)" } }) }),
425
+ /* @__PURE__ */ N("div", { className: "skopon-resume-select-card-body", children: [
426
+ /* @__PURE__ */ c("div", { className: "skopon-resume-select-card-name", children: e.name }),
427
+ e.description ? /* @__PURE__ */ c("div", { className: "skopon-resume-select-card-desc", children: e.description }) : null,
428
+ /* @__PURE__ */ N("div", { className: "skopon-resume-select-card-meta", children: [
429
+ e.caseUniqueId,
430
+ e.platform ? ` · ${e.platform}` : "",
431
+ e.link ? ` · ${e.link}` : ""
432
+ ] })
433
+ ] })
434
+ ]
435
+ }
436
+ );
437
+ }
438
+ function un({ context: e }) {
439
+ const { interactive: t } = L(), n = an(), { value: r, setValue: o } = q(e), a = e.componentModel.properties, i = ye(a.label), l = ye(a.placeholder), s = ye(a.help), u = a.enableRefresh !== !1, d = O(() => ve(a.caseFilter), [a.caseFilter]), p = ln(d), [g, S] = E(1), [A, F] = E(!1), [k, f] = E(""), [h, x] = E([]), [v, b] = E(0), [M, U] = E(d.pageSize ?? 20), _ = V(0), B = H(r) ?? "", j = O(() => n ? d.flowId ? k || l || "暂无匹配的案例" : "未配置 Flow 筛选条件" : "未配置案例搜索服务", [n, d.flowId, k, l]), D = Z(
440
+ async (y) => {
441
+ const I = ve(JSON.parse(p)), P = ++_.current;
442
+ if (!n || !I.flowId) {
443
+ x([]), b(0), f("");
444
+ return;
445
+ }
446
+ F(!0), f("");
447
+ try {
448
+ const C = await n({ filter: I, page: y });
449
+ if (P !== _.current) return;
450
+ x(C.list), b(C.total), S(C.page), U(C.pageSize);
451
+ } catch (C) {
452
+ if (P !== _.current) return;
453
+ x([]), b(0), f(C instanceof Error ? C.message : "加载案例列表失败");
454
+ } finally {
455
+ P === _.current && F(!1);
456
+ }
457
+ },
458
+ [n, p]
459
+ );
460
+ w(() => {
461
+ S(1), D(1);
462
+ }, [p, D]);
463
+ const G = (y) => {
464
+ t && o(B === y ? "" : y);
465
+ }, X = () => {
466
+ const y = ve(JSON.parse(p)), I = M || y.pageSize || 20, P = Math.max(1, Math.ceil(v / I)), C = g >= P ? 1 : g + 1;
467
+ D(C);
468
+ };
469
+ return /* @__PURE__ */ N("div", { className: "form-block-preview skopon-resume-select", children: [
470
+ i ? /* @__PURE__ */ c("div", { className: "form-block-preview-label", children: i }) : null,
471
+ A && h.length === 0 ? /* @__PURE__ */ N("div", { className: "skopon-resume-select-status", children: [
472
+ /* @__PURE__ */ c(Pe, { size: "small" }),
473
+ " 加载案例…"
474
+ ] }) : null,
475
+ !A && h.length === 0 ? /* @__PURE__ */ c("div", { className: "skopon-resume-select-empty", children: j }) : null,
476
+ h.length > 0 ? /* @__PURE__ */ c("div", { className: "skopon-resume-select-list", children: h.map((y) => /* @__PURE__ */ c(
477
+ cn,
478
+ {
479
+ item: y,
480
+ selected: B === y.caseUniqueId,
481
+ disabled: !t,
482
+ onToggle: () => G(y.caseUniqueId)
483
+ },
484
+ y.caseUniqueId
485
+ )) }) : null,
486
+ u && n && d.flowId ? /* @__PURE__ */ c("div", { className: "skopon-resume-select-actions", children: /* @__PURE__ */ c(
487
+ ce,
488
+ {
489
+ type: "default",
490
+ size: "small",
491
+ icon: /* @__PURE__ */ c(De, {}),
492
+ loading: A,
493
+ disabled: !t,
494
+ onClick: X,
495
+ children: "换一批"
496
+ }
497
+ ) }) : null,
498
+ s ? /* @__PURE__ */ c($.Text, { type: "secondary", className: "form-block-preview-help", children: s }) : null
499
+ ] });
500
+ }
501
+ const pn = R(
502
+ sn,
503
+ un
504
+ ), dn = {
505
+ type: "case_singleselect",
506
+ componentName: "SkoponCaseSelect",
507
+ toComponent: rn,
508
+ fromComponent: on,
509
+ catalogComponents: [pn]
510
+ };
511
+ function mn(e, t) {
512
+ var i, l, s, u;
513
+ const { id: n, label: r, path: o, withData: a } = t;
514
+ return a({
515
+ id: n,
516
+ component: "SkoponResumeSelect",
517
+ label: r,
518
+ placeholder: e.placeholder ?? "",
519
+ help: e.help ?? "",
520
+ enableRefresh: e.resumeEnableRefresh !== !1,
521
+ resumeFilter: {
522
+ names: ((i = e.resumeFilter) == null ? void 0 : i.names) ?? [],
523
+ agentUniqueIds: ((l = e.resumeFilter) == null ? void 0 : l.agentUniqueIds) ?? [],
524
+ resumeUniqueIds: ((s = e.resumeFilter) == null ? void 0 : s.resumeUniqueIds) ?? [],
525
+ pageSize: ((u = e.resumeFilter) == null ? void 0 : u.pageSize) ?? 20
526
+ },
527
+ value: { path: o }
528
+ });
529
+ }
530
+ function fn(e, t, n) {
531
+ const r = n.nameFromValue(e.value), o = {
532
+ ...t("resume_multiselect"),
533
+ name: r,
534
+ resumeEnableRefresh: e.enableRefresh !== !1
535
+ }, a = n.asLiteral(e.placeholder);
536
+ a && (o.placeholder = a);
537
+ const i = n.asLiteral(e.help);
538
+ if (i && (o.help = i), e.resumeFilter && typeof e.resumeFilter == "object") {
539
+ const l = e.resumeFilter;
540
+ o.resumeFilter = {
541
+ names: Array.isArray(l.names) ? l.names.map(String) : [],
542
+ agentUniqueIds: Array.isArray(l.agentUniqueIds) ? l.agentUniqueIds.map(String) : [],
543
+ resumeUniqueIds: Array.isArray(l.resumeUniqueIds) ? l.resumeUniqueIds.map(String) : [],
544
+ pageSize: typeof l.pageSize == "number" ? l.pageSize : 20
545
+ };
546
+ }
547
+ return o;
548
+ }
549
+ const rt = Fe(null);
550
+ function ot({
551
+ resumeSearch: e,
552
+ children: t
553
+ }) {
554
+ return /* @__PURE__ */ c(rt.Provider, { value: e ?? null, children: t });
555
+ }
556
+ function hn() {
557
+ return Me(rt);
558
+ }
559
+ function be(e) {
560
+ return typeof e == "string" ? e : "";
561
+ }
562
+ function Se(e) {
563
+ if (!e || typeof e != "object")
564
+ return { names: [], agentUniqueIds: [], resumeUniqueIds: [], pageSize: 20 };
565
+ const t = e, n = Array.isArray(t.names) ? t.names.map(String).filter(Boolean) : [], r = Array.isArray(t.agentUniqueIds) ? t.agentUniqueIds.map(String).filter(Boolean) : [], o = Array.isArray(t.resumeUniqueIds) ? t.resumeUniqueIds.map(String).filter(Boolean) : [], a = typeof t.pageSize == "number" ? t.pageSize : Number(t.pageSize), i = Number.isFinite(a) && a >= 1 && a <= 100 ? Math.floor(a) : 20;
566
+ return { names: n, agentUniqueIds: r, resumeUniqueIds: o, pageSize: i };
567
+ }
568
+ function gn(e) {
569
+ return JSON.stringify(e);
570
+ }
571
+ const yn = {
572
+ name: "SkoponResumeSelect",
573
+ schema: m.object({
574
+ label: m.any().optional(),
575
+ placeholder: m.any().optional(),
576
+ help: m.any().optional(),
577
+ enableRefresh: m.any().optional(),
578
+ resumeFilter: m.any().optional(),
579
+ value: m.any().optional()
580
+ }).passthrough()
581
+ };
582
+ function vn({
583
+ item: e,
584
+ selected: t,
585
+ disabled: n,
586
+ onToggle: r
587
+ }) {
588
+ return /* @__PURE__ */ N(
589
+ "button",
590
+ {
591
+ type: "button",
592
+ className: `skopon-resume-select-card${t ? " skopon-resume-select-card--selected" : ""}`,
593
+ disabled: n,
594
+ onClick: r,
595
+ children: [
596
+ /* @__PURE__ */ c(
597
+ yt,
598
+ {
599
+ size: 48,
600
+ src: e.avatarUrl || void 0,
601
+ icon: e.avatarUrl ? void 0 : /* @__PURE__ */ c(It, {}),
602
+ className: "skopon-resume-select-card-avatar"
603
+ }
604
+ ),
605
+ /* @__PURE__ */ N("div", { className: "skopon-resume-select-card-body", children: [
606
+ /* @__PURE__ */ c("div", { className: "skopon-resume-select-card-name", children: e.name }),
607
+ e.description ? /* @__PURE__ */ c("div", { className: "skopon-resume-select-card-desc", children: e.description }) : null,
608
+ /* @__PURE__ */ N("div", { className: "skopon-resume-select-card-meta", children: [
609
+ e.resumeUniqueId,
610
+ typeof e.satisfaction == "number" ? ` · 满意度 ${e.satisfaction}%` : ""
611
+ ] })
612
+ ] })
613
+ ]
614
+ }
615
+ );
616
+ }
617
+ function bn({ context: e }) {
618
+ const { interactive: t } = L(), n = hn(), { value: r, setValue: o } = q(e), a = e.componentModel.properties, i = be(a.label), l = be(a.placeholder), s = be(a.help), u = a.enableRefresh !== !1, d = O(() => Se(a.resumeFilter), [a.resumeFilter]), p = gn(d), [g, S] = E(1), [A, F] = E(!1), [k, f] = E(""), [h, x] = E([]), [v, b] = E(0), [M, U] = E(d.pageSize ?? 20), _ = V(0), B = J(r), j = Z(
619
+ async (y) => {
620
+ const I = Se(JSON.parse(p)), P = ++_.current;
621
+ if (!n) {
622
+ x([]), b(0), f("未配置简历搜索服务");
623
+ return;
624
+ }
625
+ F(!0), f("");
626
+ try {
627
+ const C = await n({ filter: I, page: y });
628
+ if (P !== _.current) return;
629
+ x(C.list), b(C.total), S(C.page), U(C.pageSize);
630
+ } catch (C) {
631
+ if (P !== _.current) return;
632
+ x([]), b(0), f(C instanceof Error ? C.message : "加载简历列表失败");
633
+ } finally {
634
+ P === _.current && F(!1);
635
+ }
636
+ },
637
+ [n, p]
638
+ );
639
+ w(() => {
640
+ S(1), j(1);
641
+ }, [p, j]);
642
+ const D = (y) => {
643
+ if (!t) return;
644
+ const I = B.includes(y) ? B.filter((P) => P !== y) : [...B, y];
645
+ o(I);
646
+ }, G = () => {
647
+ const y = Se(JSON.parse(p)), I = M || y.pageSize || 20, P = Math.max(1, Math.ceil(v / I)), C = g >= P ? 1 : g + 1;
648
+ j(C);
649
+ }, X = l || "暂无匹配的简历";
650
+ return /* @__PURE__ */ N("div", { className: "form-block-preview skopon-resume-select", children: [
651
+ i ? /* @__PURE__ */ c("div", { className: "form-block-preview-label", children: i }) : null,
652
+ A && h.length === 0 ? /* @__PURE__ */ N("div", { className: "skopon-resume-select-status", children: [
653
+ /* @__PURE__ */ c(Pe, { size: "small" }),
654
+ " 加载简历…"
655
+ ] }) : null,
656
+ !A && k ? /* @__PURE__ */ c($.Text, { type: "danger", className: "skopon-resume-select-status", children: k }) : null,
657
+ !A && !k && h.length === 0 ? /* @__PURE__ */ c("div", { className: "skopon-resume-select-empty", children: X }) : null,
658
+ h.length > 0 ? /* @__PURE__ */ c("div", { className: "skopon-resume-select-list", children: h.map((y) => /* @__PURE__ */ c(
659
+ vn,
660
+ {
661
+ item: y,
662
+ selected: B.includes(y.resumeUniqueId),
663
+ disabled: !t,
664
+ onToggle: () => D(y.resumeUniqueId)
665
+ },
666
+ y.resumeUniqueId
667
+ )) }) : null,
668
+ u && n ? /* @__PURE__ */ c("div", { className: "skopon-resume-select-actions", children: /* @__PURE__ */ c(
669
+ ce,
670
+ {
671
+ type: "default",
672
+ size: "small",
673
+ icon: /* @__PURE__ */ c(De, {}),
674
+ loading: A,
675
+ disabled: !t,
676
+ onClick: G,
677
+ children: "换一批"
678
+ }
679
+ ) }) : null,
680
+ s ? /* @__PURE__ */ c($.Text, { type: "secondary", className: "form-block-preview-help", children: s }) : null
681
+ ] });
682
+ }
683
+ const Sn = R(
684
+ yn,
685
+ bn
686
+ ), xn = {
687
+ type: "resume_multiselect",
688
+ componentName: "SkoponResumeSelect",
689
+ toComponent: mn,
690
+ fromComponent: fn,
691
+ catalogComponents: [Sn]
692
+ }, ue = [xn, dn], kn = new Map(
693
+ ue.map((e) => [e.type, e])
694
+ ), An = new Map(
695
+ ue.map((e) => [e.componentName, e])
696
+ );
697
+ function In(e) {
698
+ return kn.get(e);
699
+ }
700
+ function Cn(e) {
701
+ return An.get(e);
702
+ }
703
+ function Tn() {
704
+ return ue.flatMap((e) => e.catalogComponents);
705
+ }
706
+ function Nn() {
707
+ return ue.map((e) => e.componentName);
708
+ }
709
+ const se = "root", Ce = "__title__", Te = "__desc__", at = "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$";
710
+ function Fn(e) {
271
711
  return `/${e}`;
272
712
  }
273
- function Tt(e) {
713
+ function $e(e) {
274
714
  return e && typeof e == "object" && "path" in e ? String(e.path ?? "").replace(/^\//, "") : "";
275
715
  }
276
- function y(e) {
716
+ function z(e) {
277
717
  if (typeof e == "string") return e;
278
718
  }
279
- function At(e) {
280
- const t = e.id || w("a2-"), n = e.type === "video" ? "video" : e.type === "audio" ? "audio" : "image";
719
+ function Mn(e) {
720
+ const t = e.id || Q("a2-"), n = e.type === "video" ? "video" : e.type === "audio" ? "audio" : "image";
281
721
  return {
282
722
  id: t,
283
723
  component: "SkoponMedia",
284
724
  mediaType: n,
285
- urls: et(e),
286
- mediaSize: F(e.mediaSize),
725
+ urls: Gt(e),
726
+ mediaSize: te(e.mediaSize),
287
727
  label: e.label ?? "",
288
728
  help: e.help ?? "",
289
729
  placeholder: e.placeholder ?? ""
290
730
  };
291
731
  }
292
- function kt(e) {
732
+ function Pn(e) {
293
733
  if (Array.isArray(e.urls))
294
734
  return e.urls.map((n) => String(n).trim()).filter(Boolean);
295
- const t = y(e.url);
735
+ const t = z(e.url);
296
736
  return t != null && t.trim() ? [t.trim()] : [];
297
737
  }
298
- function D(e, t, n) {
299
- const r = typeof e.id == "string" ? e.id : w("block-"), o = kt(e), i = y(e.label) ?? y(e.description) ?? n, a = y(e.help), l = y(e.placeholder), c = F(e.mediaSize);
738
+ function re(e, t, n) {
739
+ const r = typeof e.id == "string" ? e.id : Q("block-"), o = Pn(e), a = z(e.label) ?? z(e.description) ?? n, i = z(e.help), l = z(e.placeholder), s = te(e.mediaSize);
300
740
  return {
301
741
  id: r,
302
742
  type: t,
303
- label: i,
304
- ...a ? { help: a } : {},
743
+ label: a,
744
+ ...i ? { help: i } : {},
305
745
  ...l ? { placeholder: l } : {},
306
- mediaSize: c,
746
+ mediaSize: s,
307
747
  mediaUrls: o.length > 0 ? o : [""]
308
748
  };
309
749
  }
310
- function Ct(e) {
750
+ function En(e) {
311
751
  switch (e.type) {
312
752
  case "toggle":
313
- return typeof e.defaultValue == "boolean" ? e.defaultValue : !1;
753
+ return Re(e.defaultValue);
314
754
  case "multiselect":
315
755
  case "checkbox":
756
+ case "resume_multiselect":
757
+ return Array.isArray(e.defaultValue) ? e.defaultValue : typeof e.defaultValue == "string" && e.defaultValue ? [e.defaultValue] : [];
316
758
  case "select":
317
759
  case "radio":
318
- return Array.isArray(e.defaultValue) ? e.defaultValue : typeof e.defaultValue == "string" && e.defaultValue ? [e.defaultValue] : [];
760
+ case "case_singleselect":
761
+ return Array.isArray(e.defaultValue) ? e.defaultValue[0] ?? "" : typeof e.defaultValue == "string" ? e.defaultValue : "";
762
+ case "number":
763
+ return typeof e.defaultValue == "number" || typeof e.defaultValue == "string" && e.defaultValue ? e.defaultValue : null;
319
764
  default:
320
765
  return typeof e.defaultValue == "string" ? e.defaultValue : "";
321
766
  }
322
767
  }
323
- function It(e) {
324
- var l;
325
- const t = e.id || w("a2-"), n = e.label ?? "", r = ((l = e.name) == null ? void 0 : l.trim()) || "", o = r ? St(r) : void 0, i = (e.options ?? []).map((c) => ({ label: c.label, value: c.value })), a = (c) => r ? { node: c, dataKey: r, dataValue: Ct(e) } : { node: c };
768
+ function zn(e) {
769
+ var u;
770
+ const t = e.id || Q("a2-"), n = e.label ?? "", r = ((u = e.name) == null ? void 0 : u.trim()) || "", o = r ? Fn(r) : void 0, a = (e.options ?? []).map((d) => ({ label: d.label, value: d.value })), i = (d) => r ? { node: d, dataKey: r, dataValue: En(e) } : { node: d }, l = { id: t, label: n, name: r, path: o, withData: i }, s = In(e.type);
771
+ if (s)
772
+ return s.toComponent(e, l);
326
773
  switch (e.type) {
327
774
  case "heading":
328
775
  return { node: { id: t, component: "Text", text: n, variant: "h3" } };
@@ -331,7 +778,7 @@ function It(e) {
331
778
  case "text":
332
779
  case "tel":
333
780
  case "url":
334
- return a({
781
+ return i({
335
782
  id: t,
336
783
  component: "TextField",
337
784
  label: n,
@@ -340,17 +787,17 @@ function It(e) {
340
787
  value: { path: o }
341
788
  });
342
789
  case "email":
343
- return a({
790
+ return i({
344
791
  id: t,
345
792
  component: "TextField",
346
793
  label: n,
347
794
  variant: "shortText",
348
- validationRegexp: ye,
795
+ validationRegexp: at,
349
796
  ...e.placeholder ? { placeholder: e.placeholder } : {},
350
797
  value: { path: o }
351
798
  });
352
799
  case "textarea":
353
- return a({
800
+ return i({
354
801
  id: t,
355
802
  component: "TextField",
356
803
  label: n,
@@ -359,7 +806,7 @@ function It(e) {
359
806
  value: { path: o }
360
807
  });
361
808
  case "number":
362
- return a({
809
+ return i({
363
810
  id: t,
364
811
  component: "TextField",
365
812
  label: n,
@@ -368,49 +815,49 @@ function It(e) {
368
815
  value: { path: o }
369
816
  });
370
817
  case "select":
371
- return a({
818
+ return i({
372
819
  id: t,
373
820
  component: "SkoponSelect",
374
821
  label: n,
375
822
  mode: "single",
376
823
  placeholder: e.placeholder ?? "",
377
- options: i,
824
+ options: a,
378
825
  value: { path: o }
379
826
  });
380
827
  case "radio":
381
- return a({
828
+ return i({
382
829
  id: t,
383
830
  component: "ChoicePicker",
384
831
  label: n,
385
832
  variant: "mutuallyExclusive",
386
833
  skoponPickerType: "radio",
387
- options: i,
834
+ options: a,
388
835
  value: { path: o }
389
836
  });
390
837
  case "multiselect":
391
- return a({
838
+ return i({
392
839
  id: t,
393
840
  component: "SkoponSelect",
394
841
  label: n,
395
842
  mode: "multiple",
396
843
  placeholder: e.placeholder ?? "",
397
- options: i,
844
+ options: a,
398
845
  value: { path: o }
399
846
  });
400
847
  case "checkbox":
401
- return a({
848
+ return i({
402
849
  id: t,
403
850
  component: "ChoicePicker",
404
851
  label: n,
405
852
  variant: "multipleSelection",
406
853
  skoponPickerType: "checkbox",
407
- options: i,
854
+ options: a,
408
855
  value: { path: o }
409
856
  });
410
857
  case "toggle":
411
- return a({ id: t, component: "CheckBox", label: n, value: { path: o } });
858
+ return i({ id: t, component: "CheckBox", label: n, value: { path: o } });
412
859
  case "datetime":
413
- return a({
860
+ return i({
414
861
  id: t,
415
862
  component: "DateTimeInput",
416
863
  label: n,
@@ -420,7 +867,7 @@ function It(e) {
420
867
  value: { path: o }
421
868
  });
422
869
  case "time":
423
- return a({
870
+ return i({
424
871
  id: t,
425
872
  component: "DateTimeInput",
426
873
  label: n,
@@ -431,9 +878,9 @@ function It(e) {
431
878
  case "image":
432
879
  case "video":
433
880
  case "audio":
434
- return { node: At(e) };
881
+ return { node: Mn(e) };
435
882
  case "file":
436
- return a({
883
+ return i({
437
884
  id: t,
438
885
  component: "FileUpload",
439
886
  label: n,
@@ -448,31 +895,31 @@ function It(e) {
448
895
  return { node: null };
449
896
  }
450
897
  }
451
- function W(e) {
898
+ function Ne(e) {
452
899
  if (!e || !Array.isArray(e.components) || e.components.length === 0) return !0;
453
- const t = e.components.find((r) => r.id === V);
900
+ const t = e.components.find((r) => r.id === se);
454
901
  if (!t) return e.components.length === 0;
455
902
  const n = t.children;
456
903
  return !Array.isArray(n) || n.length === 0;
457
904
  }
458
- function be(e, t) {
459
- const n = [], r = [], o = {}, i = (t == null ? void 0 : t.includeHeader) !== !1, a = (e.title ?? "").trim(), l = (e.description ?? "").trim();
460
- i && a && (n.push({ id: q, component: "Text", text: a, variant: "h2" }), r.push(q)), i && l && (n.push({ id: J, component: "Text", text: l, variant: "body" }), r.push(J));
905
+ function it(e, t) {
906
+ const n = [], r = [], o = {}, a = (t == null ? void 0 : t.includeHeader) !== !1, i = (e.title ?? "").trim(), l = (e.description ?? "").trim();
907
+ a && i && (n.push({ id: Ce, component: "Text", text: i, variant: "h2" }), r.push(Ce)), a && l && (n.push({ id: Te, component: "Text", text: l, variant: "body" }), r.push(Te));
461
908
  for (const d of e.blocks ?? []) {
462
- const { node: m, dataKey: f, dataValue: v } = It(d);
463
- m && (n.push(m), r.push(m.id), f && (o[f] = v));
909
+ const { node: p, dataKey: g, dataValue: S } = zn(d);
910
+ p && (n.push(p), r.push(p.id), g && (o[g] = S));
464
911
  }
465
- n.unshift({ id: V, component: "Column", children: r });
466
- const c = { root: V, components: n, dataModel: o }, s = t == null ? void 0 : t.styleId;
467
- return s !== void 0 && (c.surfaceProperties = { styleId: s ?? null }), c;
912
+ n.unshift({ id: se, component: "Column", children: r });
913
+ const s = { root: se, components: n, dataModel: o }, u = t == null ? void 0 : t.styleId;
914
+ return u !== void 0 && (s.surfaceProperties = { styleId: u ?? null }), s;
468
915
  }
469
- function Pt(e) {
916
+ function _n(e) {
470
917
  const t = /* @__PURE__ */ new Map();
471
918
  for (const n of e.components ?? [])
472
919
  n && typeof n.id == "string" && t.set(n.id, n);
473
920
  return t;
474
921
  }
475
- function Y(e) {
922
+ function xe(e) {
476
923
  const t = e.options;
477
924
  return Array.isArray(t) ? t.map((n) => {
478
925
  if (!n || typeof n != "object") return null;
@@ -483,100 +930,116 @@ function Y(e) {
483
930
  };
484
931
  }).filter((n) => !!n) : [];
485
932
  }
486
- function Mt(e) {
487
- const t = typeof e.id == "string" ? e.id : w("block-"), n = String(e.component ?? ""), r = y(e.label) ?? y(e.text) ?? "", o = Tt(e.value), i = (a) => ({ id: t, type: a, label: r });
933
+ function Rn(e) {
934
+ const t = typeof e.id == "string" ? e.id : Q("block-"), n = String(e.component ?? ""), r = z(e.label) ?? z(e.text) ?? "", o = $e(e.value), a = (l) => ({ id: t, type: l, label: r }), i = Cn(n);
935
+ if (i)
936
+ return i.fromComponent(e, a, { asLiteral: z, nameFromValue: $e });
488
937
  switch (n) {
489
938
  case "Text": {
490
- const a = String(e.variant ?? "body"), l = /^h[1-6]$/i.test(a) || a === "title" || a === "subtitle";
491
- return { id: t, type: l ? "heading" : "paragraph", label: r };
939
+ const l = String(e.variant ?? "body"), s = /^h[1-6]$/i.test(l) || l === "title" || l === "subtitle";
940
+ return { id: t, type: s ? "heading" : "paragraph", label: r };
492
941
  }
493
942
  case "TextField": {
494
- const a = String(e.variant ?? "shortText");
495
- let l = "text";
496
- a === "longText" ? l = "textarea" : a === "number" ? l = "number" : y(e.validationRegexp) === ye && (l = "email");
497
- const c = { ...i(l), name: o }, s = y(e.placeholder);
498
- return s && (c.placeholder = s), c;
943
+ const l = String(e.variant ?? "shortText");
944
+ let s = "text";
945
+ l === "longText" ? s = "textarea" : l === "number" ? s = "number" : z(e.validationRegexp) === at && (s = "email");
946
+ const u = { ...a(s), name: o }, d = z(e.placeholder);
947
+ return d && (u.placeholder = d), u;
499
948
  }
500
949
  case "CheckBox":
501
- return { ...i("toggle"), name: o };
950
+ return { ...a("toggle"), name: o };
502
951
  case "SkoponSelect": {
503
- const l = String(e.mode ?? "single") === "multiple" ? "multiselect" : "select", c = {
504
- ...i(l),
952
+ const s = String(e.mode ?? "single") === "multiple" ? "multiselect" : "select", u = {
953
+ ...a(s),
505
954
  name: o,
506
- options: Y(e)
507
- }, s = y(e.placeholder);
508
- return s && (c.placeholder = s), c;
955
+ options: xe(e)
956
+ }, d = z(e.placeholder);
957
+ return d && (u.placeholder = d), u;
509
958
  }
510
959
  case "ChoicePicker": {
511
- const a = y(e.skoponPickerType);
512
- if (a === "select" || a === "multiselect" || a === "radio" || a === "checkbox") {
513
- const s = {
514
- ...i(a),
960
+ const l = z(e.skoponPickerType);
961
+ if (l === "select" || l === "multiselect" || l === "radio" || l === "checkbox") {
962
+ const d = {
963
+ ...a(l),
515
964
  name: o,
516
- options: Y(e)
517
- }, d = y(e.placeholder);
518
- return d && (s.placeholder = d), s;
965
+ options: xe(e)
966
+ }, p = z(e.placeholder);
967
+ return p && (d.placeholder = p), d;
519
968
  }
520
- const c = String(e.variant ?? "mutuallyExclusive") === "multipleSelection" ? "checkbox" : "radio";
521
- return { ...i(c), name: o, options: Y(e) };
969
+ const u = String(e.variant ?? "mutuallyExclusive") === "multipleSelection" ? "checkbox" : "radio";
970
+ return { ...a(u), name: o, options: xe(e) };
522
971
  }
523
972
  case "DateTimeInput": {
524
- const a = e.enableDate === !0, l = e.enableTime === !0, s = { ...i(!a && l ? "time" : "datetime"), name: o }, d = y(e.placeholder);
525
- return d && (s.placeholder = d), s;
973
+ const l = e.enableDate === !0, s = e.enableTime === !0, d = { ...a(!l && s ? "time" : "datetime"), name: o }, p = z(e.placeholder);
974
+ return p && (d.placeholder = p), d;
526
975
  }
527
976
  case "SkoponMedia": {
528
- const a = String(e.mediaType ?? "image");
529
- return D(e, a === "video" ? "video" : a === "audio" ? "audio" : "image", r);
977
+ const l = String(e.mediaType ?? "image");
978
+ return re(e, l === "video" ? "video" : l === "audio" ? "audio" : "image", r);
530
979
  }
531
980
  case "Image":
532
- return D(e, "image", r);
981
+ return re(e, "image", r);
533
982
  case "Video":
534
- return D(e, "video", r);
983
+ return re(e, "video", r);
535
984
  case "AudioPlayer":
536
- return D(e, "audio", r);
985
+ return re(e, "audio", r);
537
986
  case "FileUpload": {
538
- const a = y(e.accept) ?? "", l = { ...i("file"), name: o };
539
- 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;
987
+ const l = z(e.accept) ?? "", s = { ...a("file"), name: o };
988
+ return l && (s.fileAcceptExtensions = l.split(",").map((u) => u.trim()).filter(Boolean)), Array.isArray(e.fileAcceptTypes) && (s.fileAcceptTypes = e.fileAcceptTypes.map(String)), typeof e.filePlaceholderIcon == "string" && (s.filePlaceholderIcon = e.filePlaceholderIcon), typeof e.minCount == "number" && (s.fileMinCount = e.minCount), typeof e.maxCount == "number" && (s.fileMaxCount = e.maxCount), s;
540
989
  }
541
990
  default:
542
991
  return null;
543
992
  }
544
993
  }
545
- function ge(e, t, n, r) {
994
+ function lt(e, t, n, r) {
546
995
  if (n.has(e)) return;
547
996
  n.add(e);
548
997
  const o = t.get(e);
549
998
  if (!o) return;
550
- const i = String(o.component ?? "");
551
- if ((i === "Column" || i === "Row") && Array.isArray(o.children)) {
552
- for (const a of o.children)
553
- typeof a == "string" && ge(a, t, n, r);
999
+ const a = String(o.component ?? "");
1000
+ if ((a === "Column" || a === "Row") && Array.isArray(o.children)) {
1001
+ for (const i of o.children)
1002
+ typeof i == "string" && lt(i, t, n, r);
554
1003
  return;
555
1004
  }
556
1005
  r.push(o);
557
1006
  }
558
- function Et(e) {
1007
+ function Un(e, t) {
1008
+ return t ? e.map((n) => {
1009
+ var a;
1010
+ const r = (a = n.name) == null ? void 0 : a.trim();
1011
+ if (!r || !(r in t)) return n;
1012
+ const o = t[r];
1013
+ return o === void 0 ? n : n.type === "toggle" ? { ...n, defaultValue: o === !0 || o === "true" } : { ...n, defaultValue: o };
1014
+ }) : e;
1015
+ }
1016
+ function On(e) {
559
1017
  if (!e || !Array.isArray(e.components))
560
- return R({ title: "", description: "", blocks: [], jsonSchema: {} });
561
- const t = Pt(e), n = [];
562
- ge(e.root ?? V, t, /* @__PURE__ */ new Set(), n);
1018
+ return le({ title: "", description: "", blocks: [], jsonSchema: {} });
1019
+ const t = _n(e), n = [];
1020
+ lt(e.root ?? se, t, /* @__PURE__ */ new Set(), n);
563
1021
  let r = "", o = "";
564
- const i = [];
565
- for (const a of n) {
566
- if (a.id === q) {
567
- r = y(a.text) ?? r;
1022
+ const a = [];
1023
+ for (const i of n) {
1024
+ if (i.id === Ce) {
1025
+ r = z(i.text) ?? r;
568
1026
  continue;
569
1027
  }
570
- if (a.id === J) {
571
- o = y(a.text) ?? o;
1028
+ if (i.id === Te) {
1029
+ o = z(i.text) ?? o;
572
1030
  continue;
573
1031
  }
574
- const l = Mt(a);
575
- l && i.push(l);
1032
+ const l = Rn(i);
1033
+ l && a.push(l);
576
1034
  }
577
- return R({ title: r, description: o, blocks: i, jsonSchema: {} });
1035
+ return le({
1036
+ title: r,
1037
+ description: o,
1038
+ blocks: Un(a, e.dataModel),
1039
+ jsonSchema: {}
1040
+ });
578
1041
  }
579
- function _t(e, t) {
1042
+ function Vn(e, t) {
580
1043
  const { surfaceId: n, catalogId: r } = t, o = [
581
1044
  { version: "v0.9", createSurface: { surfaceId: n, catalogId: r } },
582
1045
  {
@@ -589,24 +1052,24 @@ function _t(e, t) {
589
1052
  updateDataModel: { surfaceId: n, path: "/", value: e.dataModel }
590
1053
  }), o;
591
1054
  }
592
- function xe(e) {
1055
+ function st(e) {
593
1056
  return !!e && typeof e == "object" && !Array.isArray(e) && Array.isArray(e.components);
594
1057
  }
595
- function wt(e, t) {
1058
+ function Bn(e, t) {
596
1059
  if (!e || typeof e != "object") return null;
597
- const n = e, r = xe(n.a2ui) ? n.a2ui : void 0;
598
- if (r && !W(r)) return r;
1060
+ const n = e, r = st(n.a2ui) ? n.a2ui : void 0;
1061
+ if (r && !Ne(r)) return r;
599
1062
  const o = Array.isArray(n.blocks) ? n.blocks : [];
600
1063
  if (o.length === 0) return null;
601
- const i = ve({
1064
+ const a = Y({
602
1065
  title: typeof n.title == "string" ? n.title : "",
603
1066
  description: typeof n.description == "string" ? n.description : "",
604
1067
  blocks: o
605
- }), a = be(i, t);
606
- return W(a) ? null : a;
1068
+ }), i = it(a, t);
1069
+ return Ne(i) ? null : i;
607
1070
  }
608
- function Ft(e, t, n) {
609
- return be(
1071
+ function wn(e, t, n) {
1072
+ return it(
610
1073
  {
611
1074
  title: e.title,
612
1075
  description: e.description,
@@ -615,62 +1078,179 @@ function Ft(e, t, n) {
615
1078
  n
616
1079
  );
617
1080
  }
618
- function Ot(e) {
1081
+ function jn(e) {
619
1082
  if (!e || typeof e != "object" || Array.isArray(e))
620
1083
  return;
621
1084
  const t = e;
622
- return !(Array.isArray(t.blocks) && t.blocks.length > 0) && xe(t.a2ui) ? Et(t.a2ui) : ve({
1085
+ return !(Array.isArray(t.blocks) && t.blocks.length > 0) && st(t.a2ui) ? On(t.a2ui) : Y({
623
1086
  title: typeof t.title == "string" ? t.title : "",
624
1087
  description: typeof t.description == "string" ? t.description : "",
625
1088
  blocks: Array.isArray(t.blocks) ? t.blocks : []
626
1089
  });
627
1090
  }
628
- function Dt(e, t, n) {
1091
+ function $n(e, t, n) {
629
1092
  const r = e.model.surfacesMap.get(t);
630
1093
  if (!r) return {};
631
1094
  const o = {};
632
- for (const i of n) {
633
- const a = i.trim();
634
- a && (o[a] = r.dataModel.get(`/${a}`));
1095
+ for (const a of n) {
1096
+ const i = a.trim();
1097
+ i && (o[i] = r.dataModel.get(`/${i}`));
635
1098
  }
636
1099
  return o;
637
1100
  }
638
- function jt(e) {
1101
+ function ct(e) {
639
1102
  return e.replace(/'/g, "'\\''");
640
1103
  }
641
- function Se(e, t) {
1104
+ function Ln(e, t) {
642
1105
  const n = (t ?? "").trim() || "<callback_url>", r = JSON.stringify(e ?? {}, null, 2);
643
1106
  return [
644
1107
  `curl -X POST '${n}' \\`,
645
1108
  " -H 'Content-Type: application/json' \\",
646
- ` -d '${jt(r)}'`
1109
+ ` -d '${ct(r)}'`
647
1110
  ].join(`
648
1111
  `);
649
1112
  }
650
- function Nt(e) {
651
- return !e || typeof e != "object" || Array.isArray(e) ? [] : Object.keys(e);
652
- }
653
- function Rt(e, t) {
654
- const n = Nt(e), r = e ?? {}, o = (t == null ? void 0 : t.blocks) ?? [], i = new Set(
655
- o.filter((c) => {
656
- var s;
657
- return oe(c.type) && ((s = c.name) == null ? void 0 : s.trim());
658
- }).map((c) => c.name.trim())
659
- ), a = o.filter(
660
- (c) => {
661
- var s;
662
- return oe(c.type) && ((s = c.name) == null ? void 0 : s.trim()) && n.includes(c.name.trim());
1113
+ function Le(e, t, n) {
1114
+ return ` ${JSON.stringify(e)}: ${JSON.stringify(t)}${n ? "," : ""}`;
1115
+ }
1116
+ function qn(e, t) {
1117
+ const n = ["{"], r = Object.entries(e), o = Object.entries(t);
1118
+ return r.forEach(([a, i], l) => {
1119
+ const s = l < r.length - 1 || o.length > 0;
1120
+ n.push(Le(a, i, s));
1121
+ }), o.length > 0 && (n.push(" // 额外字段(未在卡片展示)"), o.forEach(([a, i], l) => {
1122
+ n.push(Le(a, i, l < o.length - 1));
1123
+ })), n.push("}"), n.join(`
1124
+ `);
1125
+ }
1126
+ function Dn({
1127
+ cardValues: e,
1128
+ extraValues: t = {},
1129
+ callbackUrl: n
1130
+ }) {
1131
+ const r = (n ?? "").trim() || "<callback_url>", o = qn(e, t);
1132
+ return [
1133
+ `curl -X POST '${r}' \\`,
1134
+ " -H 'Content-Type: application/json' \\",
1135
+ ` -d '${ct(o)}'`
1136
+ ].join(`
1137
+ `);
1138
+ }
1139
+ function Jn(e) {
1140
+ return Y({
1141
+ title: "",
1142
+ description: "",
1143
+ blocks: [e]
1144
+ }).blocks[0];
1145
+ }
1146
+ function Kn(e, t) {
1147
+ var o, a;
1148
+ const n = /* @__PURE__ */ new Map();
1149
+ for (const i of t) {
1150
+ const l = (o = i.name) == null ? void 0 : o.trim();
1151
+ l && n.set(l, i);
1152
+ }
1153
+ const r = [];
1154
+ for (const i of e.blocks) {
1155
+ if (Ee(i.type)) {
1156
+ r.push(Jn(i));
1157
+ continue;
663
1158
  }
664
- ), l = {};
665
- for (const c of n)
666
- i.has(c) || (l[c] = r[c]);
667
- return { matchedBlocks: a, remainderPayload: l };
1159
+ if (!K(i.type)) continue;
1160
+ const l = (a = i.name) == null ? void 0 : a.trim();
1161
+ if (!l) continue;
1162
+ const s = n.get(l);
1163
+ s && r.push(s);
1164
+ }
1165
+ return r;
668
1166
  }
669
- async function Vt(e, t, n) {
1167
+ function Hn(e, t) {
1168
+ var r;
1169
+ const n = {
1170
+ ...e,
1171
+ name: ((r = e.name) == null ? void 0 : r.trim()) || t.name
1172
+ };
1173
+ return t.defaultValue !== void 0 && (n.defaultValue = t.defaultValue), Y({
1174
+ title: "",
1175
+ description: "",
1176
+ blocks: [n]
1177
+ }).blocks[0];
1178
+ }
1179
+ function Yn(e) {
1180
+ if (!e || typeof e != "object" || Array.isArray(e)) return null;
1181
+ const t = e;
1182
+ return Array.isArray(t.blocks) ? Y({
1183
+ title: typeof t.title == "string" ? t.title : "",
1184
+ description: typeof t.description == "string" ? t.description : "",
1185
+ blocks: t.blocks
1186
+ }) : null;
1187
+ }
1188
+ function Gn(e, t) {
1189
+ var a, i, l, s, u, d;
1190
+ const n = /* @__PURE__ */ new Map();
1191
+ for (const p of (t == null ? void 0 : t.blocks) ?? [])
1192
+ K(p.type) && ((a = p.name) != null && a.trim()) && n.set(p.name.trim(), p);
1193
+ const r = [], o = [];
1194
+ for (const p of e.blocks) {
1195
+ if (!K(p.type)) continue;
1196
+ const g = (i = p.name) == null ? void 0 : i.trim();
1197
+ if (!g) continue;
1198
+ const S = n.get(g);
1199
+ S ? r.push(Hn(S, p)) : o.push(
1200
+ Y({
1201
+ title: "",
1202
+ description: "",
1203
+ blocks: [p]
1204
+ }).blocks[0]
1205
+ );
1206
+ }
1207
+ return {
1208
+ matchedBlocks: r,
1209
+ extraBlocks: o,
1210
+ renderBlocks: Kn(e, r),
1211
+ title: ((l = e.title) == null ? void 0 : l.trim()) || ((s = t == null ? void 0 : t.title) == null ? void 0 : s.trim()) || "",
1212
+ description: ((u = e.description) == null ? void 0 : u.trim()) || ((d = t == null ? void 0 : t.description) == null ? void 0 : d.trim()) || ""
1213
+ };
1214
+ }
1215
+ function Xn(e) {
1216
+ const { type: t, defaultValue: n } = e;
1217
+ return n !== void 0 ? t === "toggle" ? n === !0 || n === "true" : t === "multiselect" || t === "checkbox" ? Array.isArray(n) ? n.map(String) : typeof n == "string" && n ? [n] : [] : n : t === "toggle" ? !1 : t === "multiselect" || t === "checkbox" ? [] : t === "number" ? null : "";
1218
+ }
1219
+ function Wn(e) {
1220
+ var n;
1221
+ const t = {};
1222
+ for (const r of e) {
1223
+ if (!K(r.type)) continue;
1224
+ const o = (n = r.name) == null ? void 0 : n.trim();
1225
+ o && (t[o] = Xn(r));
1226
+ }
1227
+ return t;
1228
+ }
1229
+ function Zn(e) {
1230
+ return e.blocks.some(
1231
+ (t) => {
1232
+ var n;
1233
+ return K(t.type) && !!((n = t.name) != null && n.trim());
1234
+ }
1235
+ );
1236
+ }
1237
+ function Qn(e) {
1238
+ return e.blocks.filter((t) => {
1239
+ var n;
1240
+ return Ee(t.type) ? !0 : K(t.type) && !!((n = t.name) != null && n.trim());
1241
+ });
1242
+ }
1243
+ function er(e) {
1244
+ return e.blocks.filter((t) => {
1245
+ var n;
1246
+ return K(t.type) && ((n = t.name) == null ? void 0 : n.trim());
1247
+ }).map((t) => t.name.trim());
1248
+ }
1249
+ async function tr(e, t, n) {
670
1250
  const r = e.trim();
671
1251
  if (!r)
672
1252
  throw new Error("callback_url 为空");
673
- const i = await ((n == null ? void 0 : n.fetch) ?? fetch)(r, {
1253
+ const a = await ((n == null ? void 0 : n.fetch) ?? fetch)(r, {
674
1254
  method: "POST",
675
1255
  headers: {
676
1256
  "Content-Type": "application/json",
@@ -678,70 +1258,90 @@ async function Vt(e, t, n) {
678
1258
  },
679
1259
  body: JSON.stringify(t ?? {})
680
1260
  });
681
- let a;
682
- if ((i.headers.get("content-type") ?? "").includes("application/json"))
1261
+ let i;
1262
+ if ((a.headers.get("content-type") ?? "").includes("application/json"))
683
1263
  try {
684
- a = await i.json();
1264
+ i = await a.json();
685
1265
  } catch {
686
- a = void 0;
1266
+ i = void 0;
687
1267
  }
688
1268
  else
689
1269
  try {
690
- a = await i.text();
1270
+ i = await a.text();
691
1271
  } catch {
692
- a = void 0;
1272
+ i = void 0;
693
1273
  }
694
- return { ok: i.ok, status: i.status, body: a };
1274
+ return { ok: a.ok, status: a.status, body: i };
695
1275
  }
696
- async function Te(e) {
697
- await navigator.clipboard.writeText(e);
1276
+ async function ut(e) {
1277
+ var n;
1278
+ if (typeof navigator < "u" && ((n = navigator.clipboard) != null && n.writeText)) {
1279
+ await navigator.clipboard.writeText(e);
1280
+ return;
1281
+ }
1282
+ if (typeof document > "u")
1283
+ throw new Error("clipboard unavailable");
1284
+ const t = document.createElement("textarea");
1285
+ t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.left = "-9999px", document.body.appendChild(t), t.select();
1286
+ try {
1287
+ if (!document.execCommand("copy")) throw new Error("execCommand copy failed");
1288
+ } finally {
1289
+ document.body.removeChild(t);
1290
+ }
698
1291
  }
699
- async function zt(e) {
700
- const t = await e.json();
1292
+ async function nr(e) {
1293
+ let t;
1294
+ try {
1295
+ t = await e.json();
1296
+ } catch {
1297
+ throw new Error(`响应非 JSON (${e.status})`);
1298
+ }
701
1299
  if (!e.ok || t.success === !1)
702
1300
  throw new Error(t.message || `请求失败 (${e.status})`);
1301
+ if (t.data === void 0 || t.data === null)
1302
+ throw new Error(t.message || `响应缺少 data (${e.status})`);
703
1303
  return t.data;
704
1304
  }
705
- function In(e = {}) {
1305
+ function qr(e = {}) {
706
1306
  const t = (e.baseUrl ?? "/api/v1").replace(/\/$/, ""), n = e.detailPath ?? "/dev/form/detail", r = e.fetch ?? fetch;
707
- async function o(i) {
708
- var m;
709
- const a = new URLSearchParams();
710
- if (i.formId !== void 0)
711
- a.set("form_id", String(i.formId));
712
- else if (i.formUniqueId)
713
- a.set("form_unique_id", i.formUniqueId);
1307
+ async function o(a) {
1308
+ var p;
1309
+ const i = new URLSearchParams();
1310
+ if (a.formId !== void 0)
1311
+ i.set("form_id", String(a.formId));
1312
+ else if (a.formUniqueId)
1313
+ i.set("form_unique_id", a.formUniqueId);
714
1314
  else
715
1315
  throw new Error("form_id 或 form_unique_id 至少传一个");
716
- const l = await ((m = e.getHeaders) == null ? void 0 : m.call(e)) ?? {}, c = await r(`${t}${n}?${a.toString()}`, {
1316
+ const l = await ((p = e.getHeaders) == null ? void 0 : p.call(e)) ?? {}, s = await r(`${t}${n}?${i.toString()}`, {
717
1317
  method: "GET",
718
1318
  headers: l
719
- }), s = await zt(c), d = Ot(s.form_definition);
1319
+ }), u = await nr(s), d = jn(u.form_definition);
720
1320
  return {
721
- formUniqueId: s.form_unique_id,
722
- formId: s.form_id,
723
- disabled: s.disabled === 1,
1321
+ formUniqueId: u.form_unique_id,
1322
+ formId: u.form_id,
1323
+ disabled: u.disabled === 1,
724
1324
  formDefinition: d,
725
- a2ui: wt(s.form_definition) ?? void 0
1325
+ a2ui: Bn(u.form_definition) ?? void 0
726
1326
  };
727
1327
  }
728
1328
  return { fetchDetail: o };
729
1329
  }
730
- const Lt = {
731
- video: qe,
732
- audio: Ke,
733
- image: Xe,
734
- file: me,
735
- spreadsheet: Ge,
736
- document: Ye
1330
+ const rr = {
1331
+ video: Ft,
1332
+ audio: Nt,
1333
+ image: Tt,
1334
+ file: Ke,
1335
+ spreadsheet: Ct,
1336
+ document: Je
737
1337
  };
738
- function Ut({
1338
+ function or({
739
1339
  type: e,
740
1340
  size: t = 40,
741
1341
  className: n
742
1342
  }) {
743
- const r = Lt[e] ?? me;
744
- return /* @__PURE__ */ u(
1343
+ const r = rr[e] ?? Ke;
1344
+ return /* @__PURE__ */ c(
745
1345
  r,
746
1346
  {
747
1347
  className: n ?? "skopon-form-file-placeholder-icon",
@@ -750,47 +1350,7 @@ function Ut({
750
1350
  }
751
1351
  );
752
1352
  }
753
- const Ae = Fe({ interactive: !0 });
754
- function ke({
755
- interactive: e,
756
- children: t
757
- }) {
758
- return /* @__PURE__ */ u(Ae.Provider, { value: { interactive: e }, children: t });
759
- }
760
- function k() {
761
- return Oe(Ae);
762
- }
763
- function Bt(e) {
764
- return e && typeof e == "object" && "path" in e && String(e.path ?? "").trim() || null;
765
- }
766
- function C(e, t = "value") {
767
- const r = e.componentModel.properties[t], o = Bt(r), i = $(
768
- (s) => {
769
- if (!o || r === void 0) return () => {
770
- };
771
- const d = e.dataContext.subscribeDynamicValue(r, () => s());
772
- return () => d.unsubscribe();
773
- },
774
- [e, r, o]
775
- ), a = $(() => {
776
- if (!(!o || r === void 0))
777
- return e.dataContext.resolveDynamicValue(r);
778
- }, [e, r, o]), l = o ? De(i, a, a) : void 0, c = $(
779
- (s) => {
780
- !o || !r || typeof r != "object" || !("path" in r) || e.dataContext.set(String(r.path), s);
781
- },
782
- [e, r, o]
783
- );
784
- return { value: l, setValue: c, hasBinding: !!o };
785
- }
786
- function _(e) {
787
- if (typeof e == "string") return e || void 0;
788
- if (typeof e == "number") return String(e);
789
- }
790
- function z(e) {
791
- return Array.isArray(e) ? e.map(String) : typeof e == "string" && e ? [e] : [];
792
- }
793
- const Ce = "skopon-form-v0_9", $t = /* @__PURE__ */ new Set([
1353
+ const pt = "skopon-form-v0_9", ar = /* @__PURE__ */ new Set([
794
1354
  "SkoponMedia",
795
1355
  "SkoponSelect",
796
1356
  "Image",
@@ -801,628 +1361,748 @@ const Ce = "skopon-form-v0_9", $t = /* @__PURE__ */ new Set([
801
1361
  "DateTimeInput",
802
1362
  "FileUpload",
803
1363
  "TextField",
804
- "Text"
805
- ]), Ht = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "caption"]);
806
- function O(e) {
807
- const t = [...N.components.values()].find((n) => n.name === e);
1364
+ "Text",
1365
+ ...Nn()
1366
+ ]), ir = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "caption"]);
1367
+ function ne(e) {
1368
+ const t = [...ae.components.values()].find((n) => n.name === e);
808
1369
  if (!t) throw new Error(`Missing basic catalog component: ${e}`);
809
1370
  return t.schema;
810
1371
  }
811
- function h(e) {
1372
+ function T(e) {
812
1373
  return typeof e == "string" ? e : "";
813
1374
  }
814
- function Ie(e) {
1375
+ function dt(e) {
815
1376
  return Array.isArray(e) ? e.map((t) => {
816
1377
  if (!t || typeof t != "object") return null;
817
1378
  const n = t, r = String(n.value ?? n.label ?? ""), o = String(n.label ?? n.value ?? "");
818
1379
  return { value: r, label: o };
819
1380
  }).filter((t) => !!t) : [];
820
1381
  }
821
- function U({
1382
+ function pe({
822
1383
  mediaType: e,
823
1384
  urls: t,
824
1385
  mediaSize: n,
825
1386
  label: r,
826
1387
  help: o,
827
- placeholder: i
1388
+ placeholder: a
828
1389
  }) {
829
- const a = r == null ? void 0 : r.trim(), l = o == null ? void 0 : o.trim(), c = nt(n), s = (i == null ? void 0 : i.trim()) || (e === "image" ? "未设置图片 URL" : e === "video" ? "未设置视频 URL" : "未设置音频 URL");
830
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
831
- a ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: a }) : null,
832
- t.length === 0 ? /* @__PURE__ */ u("div", { className: "form-media-preview form-media-preview--empty", children: s }) : /* @__PURE__ */ u("div", { className: c, children: t.map((d, m) => e === "image" ? /* @__PURE__ */ u(
1390
+ const i = r == null ? void 0 : r.trim(), l = o == null ? void 0 : o.trim(), s = Wt(n), u = (a == null ? void 0 : a.trim()) || (e === "image" ? "未设置图片 URL" : e === "video" ? "未设置视频 URL" : "未设置音频 URL");
1391
+ return /* @__PURE__ */ N("div", { className: "form-block-preview", children: [
1392
+ i ? /* @__PURE__ */ c("div", { className: "form-block-preview-label", children: i }) : null,
1393
+ t.length === 0 ? /* @__PURE__ */ c("div", { className: "form-media-preview form-media-preview--empty", children: u }) : /* @__PURE__ */ c("div", { className: s, children: t.map((d, p) => e === "image" ? /* @__PURE__ */ c(
833
1394
  "img",
834
1395
  {
835
1396
  src: d,
836
- alt: a || "图片",
1397
+ alt: i || "图片",
837
1398
  className: "form-media-item"
838
1399
  },
839
- `media-${m}`
840
- ) : e === "video" ? /* @__PURE__ */ u(
1400
+ `media-${p}`
1401
+ ) : e === "video" ? /* @__PURE__ */ c(
841
1402
  "video",
842
1403
  {
843
1404
  src: d,
844
1405
  controls: !0,
845
1406
  className: "form-media-item"
846
1407
  },
847
- `media-${m}`
848
- ) : /* @__PURE__ */ u(
1408
+ `media-${p}`
1409
+ ) : /* @__PURE__ */ c(
849
1410
  "audio",
850
1411
  {
851
1412
  src: d,
852
1413
  controls: !0,
853
1414
  className: "form-media-item form-media-item--audio"
854
1415
  },
855
- `media-${m}`
1416
+ `media-${p}`
856
1417
  )) }),
857
- l ? /* @__PURE__ */ u(E.Text, { type: "secondary", className: "form-block-preview-help", children: l }) : null
1418
+ l ? /* @__PURE__ */ c($.Text, { type: "secondary", className: "form-block-preview-help", children: l }) : null
858
1419
  ] });
859
1420
  }
860
- function B(e, t) {
861
- const n = Array.isArray(e.urls) ? e.urls.map((r) => String(r).trim()).filter(Boolean) : h(e.url).trim() ? [h(e.url).trim()] : [];
1421
+ function de(e, t) {
1422
+ const n = Array.isArray(e.urls) ? e.urls.map((r) => String(r).trim()).filter(Boolean) : T(e.url).trim() ? [T(e.url).trim()] : [];
862
1423
  return {
863
1424
  mediaType: t,
864
1425
  urls: n,
865
- mediaSize: F(e.mediaSize),
866
- label: h(e.label) || h(e.description),
867
- help: h(e.help),
868
- placeholder: h(e.placeholder)
1426
+ mediaSize: te(e.mediaSize),
1427
+ label: T(e.label) || T(e.description),
1428
+ help: T(e.help),
1429
+ placeholder: T(e.placeholder)
869
1430
  };
870
1431
  }
871
- const Yt = {
1432
+ const lr = {
872
1433
  name: "SkoponMedia",
873
- schema: p.object({
874
- mediaType: p.any().optional(),
875
- urls: p.any().optional(),
876
- mediaSize: p.any().optional(),
877
- label: p.any().optional(),
878
- help: p.any().optional(),
879
- placeholder: p.any().optional()
1434
+ schema: m.object({
1435
+ mediaType: m.any().optional(),
1436
+ urls: m.any().optional(),
1437
+ mediaSize: m.any().optional(),
1438
+ label: m.any().optional(),
1439
+ help: m.any().optional(),
1440
+ placeholder: m.any().optional()
880
1441
  }).passthrough()
881
- }, Gt = x(Yt, ({ context: e }) => {
882
- const t = e.componentModel.properties, n = h(t.mediaType);
883
- return /* @__PURE__ */ u(U, { ...B(t, n === "video" ? "video" : n === "audio" ? "audio" : "image") });
884
- }), Xt = x(
885
- { name: "Image", schema: O("Image") },
886
- ({ context: e }) => /* @__PURE__ */ u(U, { ...B(e.componentModel.properties, "image") })
887
- ), Kt = x(
888
- { name: "Video", schema: O("Video") },
889
- ({ context: e }) => /* @__PURE__ */ u(U, { ...B(e.componentModel.properties, "video") })
890
- ), qt = x(
891
- { name: "AudioPlayer", schema: O("AudioPlayer") },
892
- ({ context: e }) => /* @__PURE__ */ u(U, { ...B(e.componentModel.properties, "audio") })
893
- ), Jt = {
1442
+ }, sr = R(lr, ({ context: e }) => {
1443
+ const t = e.componentModel.properties, n = T(t.mediaType);
1444
+ return /* @__PURE__ */ c(pe, { ...de(t, n === "video" ? "video" : n === "audio" ? "audio" : "image") });
1445
+ }), cr = R(
1446
+ { name: "Image", schema: ne("Image") },
1447
+ ({ context: e }) => /* @__PURE__ */ c(pe, { ...de(e.componentModel.properties, "image") })
1448
+ ), ur = R(
1449
+ { name: "Video", schema: ne("Video") },
1450
+ ({ context: e }) => /* @__PURE__ */ c(pe, { ...de(e.componentModel.properties, "video") })
1451
+ ), pr = R(
1452
+ { name: "AudioPlayer", schema: ne("AudioPlayer") },
1453
+ ({ context: e }) => /* @__PURE__ */ c(pe, { ...de(e.componentModel.properties, "audio") })
1454
+ ), dr = {
894
1455
  name: "SkoponSelect",
895
- schema: p.object({
896
- label: p.any().optional(),
897
- mode: p.any().optional(),
898
- placeholder: p.any().optional(),
899
- options: p.any().optional(),
900
- value: p.any().optional()
1456
+ schema: m.object({
1457
+ label: m.any().optional(),
1458
+ mode: m.any().optional(),
1459
+ placeholder: m.any().optional(),
1460
+ options: m.any().optional(),
1461
+ value: m.any().optional()
901
1462
  }).passthrough()
902
1463
  };
903
- function Wt({ context: e }) {
904
- const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.placeholder), l = Ie(o.options), c = h(o.mode) === "multiple";
905
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
906
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
907
- /* @__PURE__ */ u(
908
- G,
1464
+ function mr({ context: e }) {
1465
+ const { interactive: t } = L(), { value: n, setValue: r } = q(e), o = e.componentModel.properties, a = T(o.label), i = T(o.placeholder), l = dt(o.options), s = T(o.mode) === "multiple";
1466
+ return /* @__PURE__ */ N("div", { className: "form-block-preview", children: [
1467
+ a ? /* @__PURE__ */ c("div", { className: "form-block-preview-label", children: a }) : null,
1468
+ /* @__PURE__ */ c(
1469
+ ke,
909
1470
  {
910
- mode: c ? "multiple" : void 0,
1471
+ mode: s ? "multiple" : void 0,
911
1472
  disabled: !t,
912
1473
  allowClear: !0,
913
1474
  className: "form-block-preview-control",
914
1475
  style: { width: "100%" },
915
- placeholder: a || (c ? "请选择多项" : "请选择"),
1476
+ placeholder: i || (s ? "请选择多项" : "请选择"),
916
1477
  options: l,
917
- value: c ? z(n) : _(n),
918
- onChange: (s) => r(c ? s ?? [] : s ?? "")
1478
+ value: s ? J(n) : H(n),
1479
+ onChange: (u) => r(s ? u ?? [] : u ?? "")
919
1480
  }
920
1481
  )
921
1482
  ] });
922
1483
  }
923
- const Zt = x(
924
- Jt,
925
- Wt
1484
+ const fr = R(
1485
+ dr,
1486
+ mr
926
1487
  );
927
- function Qt({ context: e }) {
928
- const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.variant) || "mutuallyExclusive", l = h(o.skoponPickerType), c = h(o.placeholder), s = Ie(o.options), m = l === "select" || l === "multiselect" || l === "radio" || l === "checkbox" ? l : a === "multipleSelection" ? "checkbox" : "radio";
929
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
930
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
931
- m === "select" ? /* @__PURE__ */ u(
932
- G,
1488
+ function hr({ context: e }) {
1489
+ const { interactive: t } = L(), { value: n, setValue: r } = q(e), o = e.componentModel.properties, a = T(o.label), i = T(o.variant) || "mutuallyExclusive", l = T(o.skoponPickerType), s = T(o.placeholder), u = dt(o.options), p = l === "select" || l === "multiselect" || l === "radio" || l === "checkbox" ? l : i === "multipleSelection" ? "checkbox" : "radio";
1490
+ return /* @__PURE__ */ N("div", { className: "form-block-preview", children: [
1491
+ a ? /* @__PURE__ */ c("div", { className: "form-block-preview-label", children: a }) : null,
1492
+ p === "select" ? /* @__PURE__ */ c(
1493
+ ke,
933
1494
  {
934
1495
  disabled: !t,
935
1496
  allowClear: !0,
936
1497
  className: "form-block-preview-control",
937
1498
  style: { width: "100%" },
938
- placeholder: c || "请选择",
939
- options: s,
940
- value: _(n),
941
- onChange: (f) => r(f ?? "")
1499
+ placeholder: s || "请选择",
1500
+ options: u,
1501
+ value: H(n),
1502
+ onChange: (g) => r(g ?? "")
942
1503
  }
943
- ) : m === "multiselect" ? /* @__PURE__ */ u(
944
- G,
1504
+ ) : p === "multiselect" ? /* @__PURE__ */ c(
1505
+ ke,
945
1506
  {
946
1507
  mode: "multiple",
947
1508
  disabled: !t,
948
1509
  allowClear: !0,
949
1510
  className: "form-block-preview-control",
950
1511
  style: { width: "100%" },
951
- placeholder: c || "请选择多项",
952
- options: s,
953
- value: z(n),
954
- onChange: (f) => r(f ?? [])
1512
+ placeholder: s || "请选择多项",
1513
+ options: u,
1514
+ value: J(n),
1515
+ onChange: (g) => r(g ?? [])
955
1516
  }
956
- ) : m === "checkbox" ? /* @__PURE__ */ u(
957
- Ve.Group,
1517
+ ) : p === "checkbox" ? /* @__PURE__ */ c(
1518
+ vt.Group,
958
1519
  {
959
1520
  disabled: !t,
960
1521
  className: "form-block-preview-control",
961
- options: s,
962
- value: z(n),
963
- onChange: (f) => r(f)
1522
+ options: u,
1523
+ value: J(n),
1524
+ onChange: (g) => r(g)
964
1525
  }
965
- ) : /* @__PURE__ */ u(
966
- ze.Group,
1526
+ ) : /* @__PURE__ */ c(
1527
+ bt.Group,
967
1528
  {
968
1529
  disabled: !t,
969
1530
  className: "form-block-preview-control",
970
- options: s,
971
- value: _(n),
972
- onChange: (f) => r(f.target.value)
1531
+ options: u,
1532
+ value: H(n),
1533
+ onChange: (g) => r(g.target.value)
973
1534
  }
974
1535
  )
975
1536
  ] });
976
1537
  }
977
- const en = x(
1538
+ const gr = R(
978
1539
  {
979
1540
  name: "ChoicePicker",
980
- schema: p.object({
981
- label: p.any().optional(),
982
- variant: p.any().optional(),
983
- options: p.any().optional(),
984
- value: p.any().optional(),
985
- skoponPickerType: p.any().optional(),
986
- placeholder: p.any().optional()
1541
+ schema: m.object({
1542
+ label: m.any().optional(),
1543
+ variant: m.any().optional(),
1544
+ options: m.any().optional(),
1545
+ value: m.any().optional(),
1546
+ skoponPickerType: m.any().optional(),
1547
+ placeholder: m.any().optional()
987
1548
  }).passthrough()
988
1549
  },
989
- Qt
1550
+ hr
990
1551
  );
991
- function tn({ context: e }) {
992
- const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label);
993
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
994
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
995
- /* @__PURE__ */ u(
996
- Le,
1552
+ function yr({ context: e }) {
1553
+ const { interactive: t } = L(), { value: n, setValue: r } = q(e), o = e.componentModel.properties, a = T(o.label);
1554
+ return /* @__PURE__ */ N("div", { className: "form-block-preview", children: [
1555
+ a ? /* @__PURE__ */ c("div", { className: "form-block-preview-label", children: a }) : null,
1556
+ /* @__PURE__ */ c(
1557
+ St,
997
1558
  {
998
1559
  disabled: !t,
999
1560
  className: "form-block-preview-control",
1000
- checked: n === !0,
1001
- onChange: (a) => r(a)
1561
+ checked: Re(n),
1562
+ onChange: (i) => r(i)
1002
1563
  }
1003
1564
  )
1004
1565
  ] });
1005
1566
  }
1006
- const nn = x(
1007
- { name: "CheckBox", schema: O("CheckBox") },
1008
- tn
1567
+ const vr = R(
1568
+ { name: "CheckBox", schema: ne("CheckBox") },
1569
+ yr
1009
1570
  );
1010
- function rn(e, t, n) {
1011
- const r = _(e);
1571
+ function br(e, t, n) {
1572
+ const r = H(e);
1012
1573
  if (!r) return;
1013
1574
  if (!t && n) {
1014
- const i = re(r, "HH:mm", !0);
1015
- return i.isValid() ? i : void 0;
1575
+ const a = Be(r, "HH:mm", !0);
1576
+ return a.isValid() ? a : void 0;
1016
1577
  }
1017
- const o = re(r);
1578
+ const o = Be(r);
1018
1579
  return o.isValid() ? o : void 0;
1019
1580
  }
1020
- function on({ context: e }) {
1021
- const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.placeholder), l = o.enableDate === !0, c = o.enableTime === !0, s = rn(n, l, c), d = (m) => {
1022
- if (!m) {
1581
+ function Sr({ context: e }) {
1582
+ const { interactive: t } = L(), { value: n, setValue: r } = q(e), o = e.componentModel.properties, a = T(o.label), i = T(o.placeholder), l = o.enableDate === !0, s = o.enableTime === !0, u = br(n, l, s), d = (p) => {
1583
+ if (!p) {
1023
1584
  r("");
1024
1585
  return;
1025
1586
  }
1026
- if (!l && c) {
1027
- r(m.format("HH:mm"));
1587
+ if (!l && s) {
1588
+ r(p.format("HH:mm"));
1028
1589
  return;
1029
1590
  }
1030
- if (l && c) {
1031
- r(m.format("YYYY-MM-DDTHH:mm"));
1591
+ if (l && s) {
1592
+ r(p.format("YYYY-MM-DDTHH:mm"));
1032
1593
  return;
1033
1594
  }
1034
- r(m.format("YYYY-MM-DD"));
1595
+ r(p.format("YYYY-MM-DD"));
1035
1596
  };
1036
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
1037
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
1038
- !l && c ? /* @__PURE__ */ u(
1039
- Ue,
1597
+ return /* @__PURE__ */ N("div", { className: "form-block-preview", children: [
1598
+ a ? /* @__PURE__ */ c("div", { className: "form-block-preview-label", children: a }) : null,
1599
+ !l && s ? /* @__PURE__ */ c(
1600
+ xt,
1040
1601
  {
1041
1602
  disabled: !t,
1042
1603
  className: "form-block-preview-control",
1043
1604
  style: { width: "100%" },
1044
- placeholder: a || "选择时间",
1045
- value: s,
1605
+ placeholder: i || "选择时间",
1606
+ value: u,
1046
1607
  onChange: d
1047
1608
  }
1048
- ) : /* @__PURE__ */ u(
1049
- Be,
1609
+ ) : /* @__PURE__ */ c(
1610
+ kt,
1050
1611
  {
1051
- showTime: l && c,
1612
+ showTime: l && s,
1052
1613
  disabled: !t,
1053
1614
  className: "form-block-preview-control",
1054
1615
  style: { width: "100%" },
1055
- placeholder: a || (l && c ? "选择日期时间" : "选择日期"),
1056
- value: s,
1616
+ placeholder: i || (l && s ? "选择日期时间" : "选择日期"),
1617
+ value: u,
1057
1618
  onChange: d
1058
1619
  }
1059
1620
  )
1060
1621
  ] });
1061
1622
  }
1062
- const an = x(
1623
+ const xr = R(
1063
1624
  {
1064
1625
  name: "DateTimeInput",
1065
- schema: p.object({
1066
- label: p.any().optional(),
1067
- enableDate: p.any().optional(),
1068
- enableTime: p.any().optional(),
1069
- placeholder: p.any().optional(),
1070
- value: p.any().optional(),
1071
- min: p.any().optional(),
1072
- max: p.any().optional()
1626
+ schema: m.object({
1627
+ label: m.any().optional(),
1628
+ enableDate: m.any().optional(),
1629
+ enableTime: m.any().optional(),
1630
+ placeholder: m.any().optional(),
1631
+ value: m.any().optional(),
1632
+ min: m.any().optional(),
1633
+ max: m.any().optional()
1073
1634
  }).passthrough()
1074
1635
  },
1075
- on
1076
- ), ln = {
1636
+ Sr
1637
+ ), kr = {
1077
1638
  name: "FileUpload",
1078
- schema: p.object({
1079
- label: p.any().optional(),
1080
- accept: p.any().optional(),
1081
- fileAcceptTypes: p.any().optional(),
1082
- filePlaceholderIcon: p.any().optional(),
1083
- minCount: p.any().optional(),
1084
- maxCount: p.any().optional(),
1085
- value: p.any().optional()
1639
+ schema: m.object({
1640
+ label: m.any().optional(),
1641
+ accept: m.any().optional(),
1642
+ fileAcceptTypes: m.any().optional(),
1643
+ filePlaceholderIcon: m.any().optional(),
1644
+ minCount: m.any().optional(),
1645
+ maxCount: m.any().optional(),
1646
+ value: m.any().optional()
1086
1647
  }).passthrough()
1087
1648
  };
1088
- function cn({ context: e }) {
1089
- const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.accept), l = Array.isArray(o.fileAcceptTypes) ? o.fileAcceptTypes.map(String) : void 0, c = a ? a.split(",").map((v) => v.trim()).filter(Boolean) : void 0, s = ft(l, c), d = typeof o.filePlaceholderIcon == "string" && ["video", "audio", "image", "file", "spreadsheet", "document"].includes(
1649
+ function Ar({ context: e }) {
1650
+ const { interactive: t } = L(), { value: n, setValue: r } = q(e), o = e.componentModel.properties, a = T(o.label), i = T(o.accept), l = Array.isArray(o.fileAcceptTypes) ? o.fileAcceptTypes.map(String) : void 0, s = i ? i.split(",").map((f) => f.trim()).filter(Boolean) : void 0, u = Dt(l, s), d = typeof o.filePlaceholderIcon == "string" && ["video", "audio", "image", "file", "spreadsheet", "document"].includes(
1090
1651
  o.filePlaceholderIcon
1091
- ) ? o.filePlaceholderIcon : "document", m = typeof o.maxCount == "number" ? o.maxCount : 1, f = z(n);
1092
- return /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
1093
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
1094
- /* @__PURE__ */ b(
1095
- te.Dragger,
1652
+ ) ? o.filePlaceholderIcon : "document", p = typeof o.minCount == "number" ? Math.max(0, o.minCount) : 0, g = typeof o.maxCount == "number" ? o.maxCount : 1, S = g > 0, A = J(n), F = S && A.length >= g, k = A.length < p;
1653
+ return /* @__PURE__ */ N("div", { className: "form-block-preview", children: [
1654
+ a ? /* @__PURE__ */ c("div", { className: "form-block-preview-label", children: a }) : null,
1655
+ /* @__PURE__ */ N(
1656
+ he.Dragger,
1096
1657
  {
1097
- disabled: !t,
1098
- accept: mt(l, c),
1658
+ disabled: !t || F,
1659
+ accept: qt(l, s),
1099
1660
  className: "form-file-upload-preview",
1100
- showUploadList: t && f.length > 0,
1101
- fileList: t ? f.map((v, T) => ({
1102
- uid: `${T}-${v}`,
1103
- name: v,
1661
+ showUploadList: t && A.length > 0,
1662
+ fileList: t ? A.map((f, h) => ({
1663
+ uid: `${h}-${f}`,
1664
+ name: f,
1104
1665
  status: "done"
1105
1666
  })) : [],
1106
- beforeUpload: (v) => {
1107
- if (!t) return te.LIST_IGNORE;
1108
- const T = [...f, v.name].slice(0, Math.max(1, m));
1109
- return r(T), !1;
1667
+ beforeUpload: (f) => {
1668
+ if (!t) return he.LIST_IGNORE;
1669
+ const h = J(je(e));
1670
+ if (S && h.length >= g) return he.LIST_IGNORE;
1671
+ const x = S ? [...h, f.name].slice(0, g) : [...h, f.name];
1672
+ return r(x), !1;
1110
1673
  },
1111
- onRemove: (v) => {
1112
- r(f.filter((T) => T !== v.name));
1674
+ onRemove: (f) => {
1675
+ const h = J(je(e)), x = /^(\d+)-/.exec(f.uid ?? ""), v = x ? Number(x[1]) : -1, b = v >= 0 && v < h.length ? h.filter((M, U) => U !== v) : h.filter((M) => M !== f.name);
1676
+ if (b.length < p) return !1;
1677
+ r(b);
1113
1678
  },
1114
1679
  children: [
1115
- /* @__PURE__ */ u("p", { className: "form-file-upload-preview-icon", children: /* @__PURE__ */ u(Ut, { type: d, size: 40 }) }),
1116
- /* @__PURE__ */ u("p", { className: "form-file-upload-preview-text", children: "点击或拖拽文件到此处上传" })
1680
+ /* @__PURE__ */ c("p", { className: "form-file-upload-preview-icon", children: /* @__PURE__ */ c(or, { type: d, size: 40 }) }),
1681
+ /* @__PURE__ */ c("p", { className: "form-file-upload-preview-text", children: "点击或拖拽文件到此处上传" })
1117
1682
  ]
1118
1683
  }
1119
1684
  ),
1120
- /* @__PURE__ */ b(E.Text, { type: "secondary", className: "form-block-preview-help", children: [
1685
+ /* @__PURE__ */ N($.Text, { type: "secondary", className: "form-block-preview-help", children: [
1121
1686
  "允许:",
1122
- s ?? "全部类型"
1687
+ u ?? "全部类型",
1688
+ p > 0 ? `;至少 ${p} 个文件` : "",
1689
+ S ? `;最多 ${g} 个文件` : "",
1690
+ k && t ? `(当前 ${A.length} 个,未达下限)` : ""
1123
1691
  ] })
1124
1692
  ] });
1125
1693
  }
1126
- const sn = x(
1127
- ln,
1128
- cn
1694
+ const Ir = R(
1695
+ kr,
1696
+ Ar
1129
1697
  );
1130
- function un({ context: e }) {
1131
- const { interactive: t } = k(), { value: n, setValue: r } = C(e), o = e.componentModel.properties, i = h(o.label), a = h(o.placeholder), l = h(o.variant) || "shortText", c = _(n) ?? "", s = !t, d = "form-block-preview-control";
1132
- let m;
1133
- return l === "longText" ? m = /* @__PURE__ */ u(
1134
- H.TextArea,
1135
- {
1136
- disabled: s,
1137
- className: d,
1138
- placeholder: a || "长文本回答...",
1139
- autoSize: { minRows: 2, maxRows: 6 },
1140
- value: c,
1141
- onChange: (f) => r(f.target.value)
1142
- }
1143
- ) : l === "number" ? m = /* @__PURE__ */ u(
1144
- $e,
1145
- {
1146
- disabled: s,
1147
- className: d,
1148
- style: { width: "100%" },
1149
- placeholder: a || "数字",
1150
- value: c ? Number(c) : void 0,
1151
- onChange: (f) => r(f == null ? "" : String(f))
1152
- }
1153
- ) : l === "obscured" ? m = /* @__PURE__ */ u(
1154
- H.Password,
1698
+ function Cr({ context: e }) {
1699
+ const { interactive: t } = L(), { value: n, setValue: r } = q(e), o = e.componentModel.properties, a = T(o.label), i = T(o.placeholder), l = T(o.variant) || "shortText", s = H(n) ?? "", u = !t, d = "form-block-preview-control";
1700
+ let p;
1701
+ if (l === "longText")
1702
+ p = /* @__PURE__ */ c(
1703
+ ge.TextArea,
1704
+ {
1705
+ disabled: u,
1706
+ className: d,
1707
+ placeholder: i || "长文本回答...",
1708
+ autoSize: { minRows: 2, maxRows: 6 },
1709
+ value: s,
1710
+ onChange: (g) => r(g.target.value)
1711
+ }
1712
+ );
1713
+ else if (l === "number") {
1714
+ const g = s && Number.isFinite(Number(s)) ? Number(s) : void 0;
1715
+ p = /* @__PURE__ */ c(
1716
+ At,
1717
+ {
1718
+ disabled: u,
1719
+ className: d,
1720
+ style: { width: "100%" },
1721
+ placeholder: i || "数字",
1722
+ value: g,
1723
+ onChange: (S) => r(S == null ? "" : String(S))
1724
+ }
1725
+ );
1726
+ } else l === "obscured" ? p = /* @__PURE__ */ c(
1727
+ ge.Password,
1155
1728
  {
1156
- disabled: s,
1729
+ disabled: u,
1157
1730
  className: d,
1158
- placeholder: a,
1159
- value: c,
1160
- onChange: (f) => r(f.target.value)
1731
+ placeholder: i,
1732
+ value: s,
1733
+ onChange: (g) => r(g.target.value)
1161
1734
  }
1162
- ) : m = /* @__PURE__ */ u(
1163
- H,
1735
+ ) : p = /* @__PURE__ */ c(
1736
+ ge,
1164
1737
  {
1165
- disabled: s,
1738
+ disabled: u,
1166
1739
  className: d,
1167
- placeholder: a,
1168
- value: c,
1169
- onChange: (f) => r(f.target.value)
1740
+ placeholder: i,
1741
+ value: s,
1742
+ onChange: (g) => r(g.target.value)
1170
1743
  }
1171
- ), /* @__PURE__ */ b("div", { className: "form-block-preview", children: [
1172
- i ? /* @__PURE__ */ u("div", { className: "form-block-preview-label", children: i }) : null,
1173
- m
1744
+ );
1745
+ return /* @__PURE__ */ N("div", { className: "form-block-preview", children: [
1746
+ a ? /* @__PURE__ */ c("div", { className: "form-block-preview-label", children: a }) : null,
1747
+ p
1174
1748
  ] });
1175
1749
  }
1176
- const pn = x(
1750
+ const Tr = R(
1177
1751
  {
1178
1752
  name: "TextField",
1179
- schema: p.object({
1180
- label: p.any().optional(),
1181
- variant: p.any().optional(),
1182
- placeholder: p.any().optional(),
1183
- validationRegexp: p.any().optional(),
1184
- value: p.any().optional()
1753
+ schema: m.object({
1754
+ label: m.any().optional(),
1755
+ variant: m.any().optional(),
1756
+ placeholder: m.any().optional(),
1757
+ validationRegexp: m.any().optional(),
1758
+ value: m.any().optional()
1185
1759
  }).passthrough()
1186
1760
  },
1187
- un
1761
+ Cr
1188
1762
  );
1189
- function dn({ context: e }) {
1190
- const t = e.componentModel.properties, n = h(t.text), r = h(t.variant) || "body";
1191
- return Ht.has(r) ? r === "caption" ? /* @__PURE__ */ u(E.Text, { type: "secondary", className: "form-block-preview-paragraph", children: /* @__PURE__ */ u("em", { children: n }) }) : /* @__PURE__ */ u(r, { className: "form-block-preview-heading", children: n }) : /* @__PURE__ */ u(E.Paragraph, { className: "form-block-preview-paragraph", children: n });
1763
+ function Nr({ context: e }) {
1764
+ const t = e.componentModel.properties, n = T(t.text), r = T(t.variant) || "body";
1765
+ return ir.has(r) ? r === "caption" ? /* @__PURE__ */ c($.Text, { type: "secondary", className: "form-block-preview-paragraph", children: /* @__PURE__ */ c("em", { children: n }) }) : /* @__PURE__ */ c(r, { className: "form-block-preview-heading", children: n }) : /* @__PURE__ */ c($.Paragraph, { className: "form-block-preview-paragraph", children: n });
1192
1766
  }
1193
- const mn = x(
1194
- { name: "Text", schema: O("Text") },
1195
- dn
1767
+ const Fr = R(
1768
+ { name: "Text", schema: ne("Text") },
1769
+ Nr
1196
1770
  );
1197
- function Pe() {
1771
+ function mt() {
1198
1772
  const t = [
1199
- ...[...N.components.values()].filter(
1200
- (r) => !$t.has(r.name)
1773
+ ...[...ae.components.values()].filter(
1774
+ (r) => !ar.has(r.name)
1201
1775
  ),
1202
- Gt,
1203
- Zt,
1204
- Xt,
1205
- Kt,
1206
- qt,
1207
- en,
1208
- nn,
1209
- an,
1210
- sn,
1211
- pn,
1212
- mn
1213
- ], n = [...N.functions.values()];
1214
- return new Re(Ce, t, n, N.themeSchema);
1215
- }
1216
- const fn = je(
1776
+ sr,
1777
+ fr,
1778
+ cr,
1779
+ ur,
1780
+ pr,
1781
+ gr,
1782
+ vr,
1783
+ xr,
1784
+ Ir,
1785
+ Tr,
1786
+ Fr,
1787
+ ...Tn()
1788
+ ], n = [...ae.functions.values()];
1789
+ return new Mt(pt, t, n, ae.themeSchema);
1790
+ }
1791
+ const Mr = ht(
1217
1792
  function({
1218
1793
  doc: t,
1219
1794
  surfaceId: n = "skopon-form",
1220
1795
  emptyHint: r = null,
1221
1796
  interactive: o = !0,
1222
- fieldNames: i = []
1223
- }, a) {
1224
- P(() => {
1225
- pe(), se();
1797
+ fieldNames: a = [],
1798
+ resumeSearch: i = null,
1799
+ caseSearch: l = null
1800
+ }, s) {
1801
+ w(() => {
1802
+ Xe(), Ge();
1226
1803
  }, []);
1227
- const l = M(null), c = M(i);
1228
- c.current = i;
1229
- const s = A(() => {
1230
- if (W(t))
1231
- return l.current = null, [];
1804
+ const u = V(null), d = V(a);
1805
+ d.current = a;
1806
+ const p = O(() => {
1807
+ if (Ne(t)) return "";
1232
1808
  try {
1233
- const d = new ce([Pe()]), m = _t(t, {
1809
+ return JSON.stringify(t);
1810
+ } catch {
1811
+ return String(t);
1812
+ }
1813
+ }, [t]), g = O(() => {
1814
+ if (!p)
1815
+ return { surfaces: [], processor: null };
1816
+ try {
1817
+ const F = JSON.parse(p), k = new Ye([mt()]), f = Vn(F, {
1234
1818
  surfaceId: n,
1235
- catalogId: Ce
1819
+ catalogId: pt
1236
1820
  });
1237
- return d.processMessages(m), l.current = d, Array.from(d.model.surfacesMap.values());
1238
- } catch (d) {
1239
- return console.error("[SkoponFormRenderer] 渲染 A2UI surface 失败", d), l.current = null, [];
1821
+ return k.processMessages(f), {
1822
+ surfaces: Array.from(k.model.surfacesMap.values()),
1823
+ processor: k
1824
+ };
1825
+ } catch (F) {
1826
+ return console.error("[SkoponFormRenderer] 渲染 A2UI surface 失败", F), { surfaces: [], processor: null };
1240
1827
  }
1241
- }, [t, n]);
1242
- return Ne(
1243
- a,
1828
+ }, [p, n]), { surfaces: S, processor: A } = g;
1829
+ return u.current = A, gt(
1830
+ s,
1244
1831
  () => ({
1245
- getValues(d) {
1246
- const m = l.current;
1247
- if (!m) return {};
1248
- const f = (d ?? c.current).map((v) => v.trim()).filter(Boolean);
1249
- return Dt(m, n, f);
1832
+ getValues(F) {
1833
+ const k = u.current;
1834
+ if (!k) return {};
1835
+ const f = (F ?? d.current).map((h) => h.trim()).filter(Boolean);
1836
+ return $n(k, n, f);
1250
1837
  }
1251
1838
  }),
1252
1839
  [n]
1253
- ), s.length === 0 ? /* @__PURE__ */ u(le, { children: r }) : /* @__PURE__ */ u(ke, { interactive: o, children: /* @__PURE__ */ u("div", { className: "a2ui-surface a2ui-container", children: s.map((d) => /* @__PURE__ */ u(ue, { surface: d }, d.id)) }) });
1840
+ ), S.length === 0 ? /* @__PURE__ */ c(qe, { children: r }) : /* @__PURE__ */ c(ot, { resumeSearch: i, children: /* @__PURE__ */ c(nt, { caseSearch: l, children: /* @__PURE__ */ c(Qe, { interactive: o, children: /* @__PURE__ */ c("div", { className: "a2ui-surface a2ui-container", children: S.map((F) => /* @__PURE__ */ c(He, { surface: F }, F.id)) }) }) }) });
1254
1841
  }
1255
1842
  );
1256
- function Pn({
1843
+ function oe() {
1844
+ return new Ye([mt()]);
1845
+ }
1846
+ function Dr({
1257
1847
  messages: e,
1258
1848
  surfaceId: t = "skopon-form-stream",
1259
1849
  emptyHint: n = null,
1260
- interactive: r = !0
1850
+ interactive: r = !0,
1851
+ resumeSearch: o = null,
1852
+ caseSearch: a = null
1261
1853
  }) {
1262
- P(() => {
1263
- pe(), se();
1854
+ w(() => {
1855
+ Xe(), Ge();
1264
1856
  }, []);
1265
- const o = M(null), i = M(0), a = A(() => {
1266
- const s = new ce([Pe()]);
1267
- return o.current = s, i.current = 0, s;
1268
- }, [t]), [l, c] = j(() => Array.from(a.model.surfacesMap.values()));
1269
- return P(() => {
1270
- const s = () => c(Array.from(a.model.surfacesMap.values())), d = a.onSurfaceCreated(s), m = a.onSurfaceDeleted(s);
1857
+ const i = V(oe()), l = V(0), s = V(""), u = V(!0), d = V(t);
1858
+ function p(f, h) {
1859
+ i.current = f, l.current = h.length, s.current = JSON.stringify(h), u.current && (A(f), k(Array.from(f.model.surfacesMap.values())));
1860
+ }
1861
+ function g(f, h) {
1862
+ if (h <= 0) return !1;
1863
+ const x = JSON.stringify(f.slice(0, h)), v = s.current;
1864
+ if (!v) return !0;
1865
+ try {
1866
+ const b = JSON.parse(v);
1867
+ return JSON.stringify(b.slice(0, h)) !== x;
1868
+ } catch {
1869
+ return !0;
1870
+ }
1871
+ }
1872
+ const [S, A] = E(() => i.current), [F, k] = E(
1873
+ () => Array.from(i.current.model.surfacesMap.values())
1874
+ );
1875
+ return w(() => (u.current = !0, () => {
1876
+ u.current = !1;
1877
+ }), []), w(() => {
1878
+ i.current = S;
1879
+ }, [S]), w(() => {
1880
+ const f = () => {
1881
+ u.current && k(Array.from(S.model.surfacesMap.values()));
1882
+ }, h = S.onSurfaceCreated(f), x = S.onSurfaceDeleted(f);
1271
1883
  return () => {
1272
- d.unsubscribe(), m.unsubscribe();
1884
+ h.unsubscribe(), x.unsubscribe();
1273
1885
  };
1274
- }, [a]), P(() => {
1275
- if (!Array.isArray(e) || e.length === 0) return;
1276
- const s = e.slice(i.current);
1277
- s.length !== 0 && (a.processMessages(s), i.current = e.length, c(Array.from(a.model.surfacesMap.values())));
1278
- }, [e, a]), l.length === 0 ? /* @__PURE__ */ u(le, { children: n }) : /* @__PURE__ */ u(ke, { interactive: r, children: /* @__PURE__ */ u("div", { className: "a2ui-surface a2ui-container", children: l.map((s) => /* @__PURE__ */ u(ue, { surface: s }, s.id)) }) });
1279
- }
1280
- function ie({
1886
+ }, [S]), w(() => {
1887
+ let f = !1;
1888
+ const h = d.current !== t;
1889
+ if (d.current = t, h) {
1890
+ const M = oe();
1891
+ return Array.isArray(e) && e.length > 0 ? (M.processMessages(e), f || p(M, e)) : (i.current = M, l.current = 0, s.current = "", f || (A(M), k([]))), () => {
1892
+ f = !0;
1893
+ };
1894
+ }
1895
+ if (!Array.isArray(e) || e.length === 0) {
1896
+ if (l.current > 0) {
1897
+ const M = oe();
1898
+ i.current = M, l.current = 0, s.current = "", f || (A(M), k([]));
1899
+ }
1900
+ return () => {
1901
+ f = !0;
1902
+ };
1903
+ }
1904
+ const x = i.current, v = l.current;
1905
+ if (e.length < v || g(e, v)) {
1906
+ const M = oe();
1907
+ return M.processMessages(e), f || p(M, e), () => {
1908
+ f = !0;
1909
+ };
1910
+ }
1911
+ const b = e.slice(v);
1912
+ return b.length === 0 ? () => {
1913
+ f = !0;
1914
+ } : (x.processMessages(b), l.current = e.length, s.current = JSON.stringify(e), f || k(Array.from(x.model.surfacesMap.values())), () => {
1915
+ f = !0;
1916
+ });
1917
+ }, [e, t]), F.length === 0 ? /* @__PURE__ */ c(qe, { children: n }) : /* @__PURE__ */ c(ot, { resumeSearch: o, children: /* @__PURE__ */ c(nt, { caseSearch: a, children: /* @__PURE__ */ c(Qe, { interactive: r, children: /* @__PURE__ */ c("div", { className: "a2ui-surface a2ui-container", children: F.map((f) => /* @__PURE__ */ c(He, { surface: f }, f.id)) }) }) }) });
1918
+ }
1919
+ function Pr({
1281
1920
  payload: e,
1282
1921
  callbackUrl: t,
1283
1922
  title: n,
1284
1923
  unpublishedFormId: r,
1285
1924
  incompleteFormId: o,
1286
- onNotify: i
1925
+ onNotify: a
1287
1926
  }) {
1288
- const a = A(
1289
- () => Se(e, t),
1927
+ const i = O(
1928
+ () => Ln(e, t),
1290
1929
  [e, t]
1291
1930
  );
1292
1931
  async function l() {
1293
1932
  try {
1294
- await Te(a), i == null || i("success", "已复制到剪贴板");
1933
+ await ut(i), a == null || a("success", "已复制到剪贴板");
1295
1934
  } catch {
1296
- i == null || i("error", "复制失败");
1935
+ a == null || a("error", "复制失败");
1297
1936
  }
1298
1937
  }
1299
- return /* @__PURE__ */ b("div", { className: "ask-user-curl-card", children: [
1300
- /* @__PURE__ */ b("div", { className: "ask-user-curl-card-header", children: [
1301
- /* @__PURE__ */ b("div", { className: "ask-user-curl-card-header-title", children: [
1302
- /* @__PURE__ */ u(E.Text, { type: "secondary", children: n ?? "curl 命令" }),
1303
- r ? /* @__PURE__ */ u(X, { title: r, children: /* @__PURE__ */ u(ne, { className: "ask-user-curl-unpublished-tag", children: "卡片 ID 未发布" }) }) : null,
1304
- o ? /* @__PURE__ */ u(X, { title: o, children: /* @__PURE__ */ u(ne, { className: "ask-user-curl-incomplete-tag", children: "卡片 ID 待补足" }) }) : null
1938
+ return /* @__PURE__ */ N("div", { className: "ask-user-curl-card", children: [
1939
+ /* @__PURE__ */ N("div", { className: "ask-user-curl-card-header", children: [
1940
+ /* @__PURE__ */ N("div", { className: "ask-user-curl-card-header-title", children: [
1941
+ /* @__PURE__ */ c($.Text, { type: "secondary", children: n ?? "curl 命令" }),
1942
+ r ? /* @__PURE__ */ c(ie, { title: r, children: /* @__PURE__ */ c(Ae, { className: "ask-user-curl-unpublished-tag", children: "卡片 ID 未发布" }) }) : null,
1943
+ o ? /* @__PURE__ */ c(ie, { title: o, children: /* @__PURE__ */ c(Ae, { className: "ask-user-curl-incomplete-tag", children: "卡片 ID 待补足" }) }) : null
1305
1944
  ] }),
1306
- /* @__PURE__ */ u(de, { size: "small", type: "text", onClick: () => void l(), children: "复制" })
1945
+ /* @__PURE__ */ c(ce, { size: "small", type: "text", onClick: () => void l(), children: "复制" })
1307
1946
  ] }),
1308
- /* @__PURE__ */ u("pre", { className: "skopon-form-curl-json", children: a })
1947
+ /* @__PURE__ */ c("pre", { className: "skopon-form-curl-json", children: i })
1309
1948
  ] });
1310
1949
  }
1311
- function Mn({
1950
+ function Er(e, t) {
1951
+ if (t && typeof t == "object" && t !== null && "message" in t) {
1952
+ const n = t.message;
1953
+ if (typeof n == "string" && n.trim())
1954
+ return `提交失败 (${e}): ${n.trim()}`;
1955
+ }
1956
+ return typeof t == "string" && t.trim() ? `提交失败 (${e}): ${t.trim()}` : `提交失败 (${e})`;
1957
+ }
1958
+ function Jr({
1312
1959
  payload: e,
1313
1960
  formUniqueId: t,
1314
1961
  callbackUrl: n,
1315
1962
  submitMode: r = "curl",
1316
1963
  fetchFormDetail: o,
1317
- onNotify: i
1964
+ onNotify: a,
1965
+ resumeSearch: i = null,
1966
+ caseSearch: l = null
1318
1967
  }) {
1319
- const [a, l] = j(null), [c, s] = j(!1), [d, m] = j(!0), f = M(null);
1320
- P(() => {
1321
- let g = !1;
1322
- return m(!0), s(!1), o({ formUniqueId: t }).then((S) => {
1323
- g || (s(!!S.disabled), l(S.disabled ? null : S.formDefinition ?? null));
1324
- }).catch(() => {
1325
- g || (s(!1), l(null));
1968
+ const [s, u] = E(null), [d, p] = E(!1), [g, S] = E(!0), [A, F] = E(!1), k = V(null), f = V(!0), h = V(a);
1969
+ h.current = a;
1970
+ const x = (t == null ? void 0 : t.trim()) ?? "";
1971
+ w(() => (f.current = !0, () => {
1972
+ f.current = !1;
1973
+ }), []), w(() => {
1974
+ let y = !1;
1975
+ return x ? (S(!0), p(!1), o({ formUniqueId: x }).then((I) => {
1976
+ y || (p(!!I.disabled), u(I.formDefinition ?? null));
1977
+ }).catch((I) => {
1978
+ var P;
1979
+ if (!y) {
1980
+ p(!1), u(null);
1981
+ const C = I instanceof Error ? I.message : "获取表单定义失败";
1982
+ (P = h.current) == null || P.call(h, "error", C);
1983
+ }
1326
1984
  }).finally(() => {
1327
- g || m(!1);
1985
+ y || S(!1);
1328
1986
  }), () => {
1329
- g = !0;
1330
- };
1331
- }, [t, o]);
1332
- const { matchedBlocks: v, remainderPayload: T } = A(
1333
- () => Rt(e, a ?? void 0),
1334
- [e, a]
1335
- ), Q = A(
1336
- () => v.map((g) => {
1337
- var S;
1338
- return (S = g.name) == null ? void 0 : S.trim();
1339
- }).filter((g) => !!g),
1340
- [v]
1341
- ), Me = A(() => !a || v.length === 0 ? null : Ft(a, v), [a, v]);
1342
- if (d)
1343
- return /* @__PURE__ */ u("div", { className: "ask-user-form-card", children: /* @__PURE__ */ u(He, { size: "small" }) });
1344
- if (v.length === 0)
1345
- return /* @__PURE__ */ u(
1346
- ie,
1987
+ y = !0;
1988
+ }) : (S(!1), p(!1), u(null), () => {
1989
+ y = !0;
1990
+ });
1991
+ }, [x, o]);
1992
+ const v = O(() => Yn(e), [e]), b = O(() => v ? Gn(v, s ?? void 0) : null, [v, s]), M = (b == null ? void 0 : b.matchedBlocks) ?? [], U = !!(v && Zn(v) && M.length === 0), _ = O(() => b && b.renderBlocks.length > 0 ? b.renderBlocks : U && v ? Qn(v) : [], [b, U, v]), B = O(
1993
+ () => U ? {} : Wn((b == null ? void 0 : b.extraBlocks) ?? []),
1994
+ [U, b]
1995
+ ), j = O(() => U && v ? er(v) : _.filter((y) => {
1996
+ var I;
1997
+ return (I = y.name) == null ? void 0 : I.trim();
1998
+ }).map((y) => y.name.trim()), [U, v, _]), D = O(() => {
1999
+ if (_.length === 0) return null;
2000
+ const y = (b == null ? void 0 : b.title) ?? (v == null ? void 0 : v.title) ?? "", I = (b == null ? void 0 : b.description) ?? (v == null ? void 0 : v.description) ?? "";
2001
+ return wn({ title: y, description: I }, _);
2002
+ }, [b, v, _]), G = x ? `ask-user-${x}` : "ask-user-payload";
2003
+ if (g)
2004
+ return /* @__PURE__ */ c("div", { className: "ask-user-form-card", children: /* @__PURE__ */ c(Pe, { size: "small" }) });
2005
+ if (!v || _.length === 0)
2006
+ return /* @__PURE__ */ c(
2007
+ Pr,
1347
2008
  {
1348
2009
  payload: e,
1349
2010
  callbackUrl: n,
1350
- unpublishedFormId: c ? t : void 0,
1351
- onNotify: i
2011
+ unpublishedFormId: d && x ? x : void 0,
2012
+ onNotify: a
1352
2013
  }
1353
2014
  );
1354
- const Ee = Object.keys(T).length > 0;
1355
- async function _e() {
1356
- var S;
1357
- const g = ((S = f.current) == null ? void 0 : S.getValues(Q)) ?? {};
1358
- if (r === "post") {
1359
- const ee = (n ?? "").trim();
1360
- if (!ee) {
1361
- i == null || i("error", "callback_url 为空,无法提交");
1362
- return;
1363
- }
2015
+ async function X() {
2016
+ var y, I, P, C, Ue, Oe;
2017
+ if (!A) {
2018
+ F(!0);
1364
2019
  try {
1365
- const I = await Vt(ee, g);
1366
- I.ok ? i == null || i("success", "提交成功") : i == null || i("error", `提交失败 (${I.status})`);
1367
- } catch (I) {
1368
- const we = I instanceof Error ? I.message : "提交失败";
1369
- i == null || i("error", we);
2020
+ const W = ((y = k.current) == null ? void 0 : y.getValues(j)) ?? {}, me = { ...W, ...B };
2021
+ if (r === "post") {
2022
+ const Ve = (n ?? "").trim();
2023
+ if (!Ve) {
2024
+ (I = h.current) == null || I.call(h, "error", "callback_url 为空,无法提交");
2025
+ return;
2026
+ }
2027
+ const fe = await tr(Ve, me);
2028
+ if (!f.current) return;
2029
+ fe.ok ? (P = h.current) == null || P.call(h, "success", "提交成功") : (C = h.current) == null || C.call(h, "error", Er(fe.status, fe.body));
2030
+ return;
2031
+ }
2032
+ if (await ut(
2033
+ Dn({ cardValues: W, extraValues: B, callbackUrl: n })
2034
+ ), !f.current) return;
2035
+ (Ue = h.current) == null || Ue.call(h, "success", "已复制 curl 到剪贴板");
2036
+ } catch (W) {
2037
+ if (!f.current) return;
2038
+ const me = W instanceof Error ? W.message : "复制失败";
2039
+ (Oe = h.current) == null || Oe.call(h, "error", me);
2040
+ } finally {
2041
+ f.current && F(!1);
1370
2042
  }
1371
- return;
1372
- }
1373
- try {
1374
- await Te(Se(g, n)), i == null || i("success", "已复制 curl 到剪贴板");
1375
- } catch {
1376
- i == null || i("error", "复制失败");
1377
2043
  }
1378
2044
  }
1379
- return /* @__PURE__ */ b("div", { className: "ask-user-form-card", children: [
1380
- /* @__PURE__ */ u(
1381
- fn,
2045
+ return /* @__PURE__ */ N("div", { className: "ask-user-form-card", children: [
2046
+ d && x ? /* @__PURE__ */ c("div", { className: "ask-user-form-card-status", children: /* @__PURE__ */ c(ie, { title: x, children: /* @__PURE__ */ c(Ae, { className: "ask-user-curl-unpublished-tag", children: "卡片 ID 未发布" }) }) }) : null,
2047
+ /* @__PURE__ */ c(
2048
+ Mr,
1382
2049
  {
1383
- ref: f,
1384
- doc: Me,
1385
- surfaceId: `ask-user-${t}`,
1386
- fieldNames: Q,
1387
- interactive: !0
2050
+ ref: k,
2051
+ doc: D,
2052
+ surfaceId: G,
2053
+ fieldNames: j,
2054
+ interactive: !0,
2055
+ resumeSearch: i,
2056
+ caseSearch: l
1388
2057
  }
1389
2058
  ),
1390
- /* @__PURE__ */ u("div", { className: "ask-user-form-actions", children: /* @__PURE__ */ u(X, { title: r === "curl" ? "点击复制 curl" : "提交 JSON 到 callback_url", children: /* @__PURE__ */ u(de, { type: "primary", size: "small", onClick: () => void _e(), children: "提交" }) }) }),
1391
- Ee ? /* @__PURE__ */ u(
1392
- ie,
2059
+ /* @__PURE__ */ c("div", { className: "ask-user-form-actions", children: /* @__PURE__ */ c(ie, { title: r === "curl" ? "点击复制 curl" : "提交 JSON 到 callback_url", children: /* @__PURE__ */ c(
2060
+ ce,
1393
2061
  {
1394
- payload: T,
1395
- callbackUrl: n,
1396
- title: "以下字段不在表单中,请使用 curl 提交",
1397
- incompleteFormId: t,
1398
- onNotify: i
2062
+ type: "primary",
2063
+ size: "small",
2064
+ loading: A,
2065
+ disabled: A,
2066
+ onClick: () => void X(),
2067
+ children: "提交"
1399
2068
  }
1400
- ) : null
2069
+ ) }) })
1401
2070
  ] });
1402
2071
  }
1403
2072
  export {
1404
- Cn as A2UI_PROTOCOL_VERSION,
1405
- Mn as AskUserFormCard,
1406
- ie as CurlSubmitBlock,
1407
- Je as FORM_MEDIA_SIZES,
1408
- Pn as SkoponA2uiStreamRenderer,
1409
- fn as SkoponFormRenderer,
1410
- Et as a2uiToBlocks,
1411
- be as blocksToA2ui,
1412
- Ft as buildAskUserSurface,
1413
- Se as buildCurlStatement,
1414
- Te as copyTextToClipboard,
1415
- In as createFormClient,
1416
- Dt as extractSurfaceValues,
1417
- Rt as intersectPayloadWithForm,
1418
- W as isA2uiSurfaceEmpty,
1419
- oe as isInputBlockType,
1420
- We as isLayoutBlockType,
1421
- K as isMediaBlockType,
1422
- Ot as mapFormDefinitionFromDto,
1423
- ve as normalizeFormDefinition,
1424
- wt as resolveSurfaceFromFormDefinition,
1425
- Vt as submitFormJson,
1426
- _t as surfaceDocToMessages,
1427
- R as syncFormDefinition
2073
+ Lr as A2UI_PROTOCOL_VERSION,
2074
+ Jr as AskUserFormCard,
2075
+ nt as CaseSearchProvider,
2076
+ Pr as CurlSubmitBlock,
2077
+ Pt as FORM_MEDIA_SIZES,
2078
+ ot as ResumeSearchProvider,
2079
+ Dr as SkoponA2uiStreamRenderer,
2080
+ Mr as SkoponFormRenderer,
2081
+ On as a2uiToBlocks,
2082
+ it as blocksToA2ui,
2083
+ qn as buildAskUserCurlBodyJson,
2084
+ Dn as buildAskUserCurlStatement,
2085
+ wn as buildAskUserSurface,
2086
+ Ln as buildCurlStatement,
2087
+ ut as copyTextToClipboard,
2088
+ qr as createFormClient,
2089
+ Wn as extractExtraBlockValues,
2090
+ $n as extractSurfaceValues,
2091
+ er as getPayloadInputFieldNames,
2092
+ Qn as getPayloadRenderableBlocks,
2093
+ Gn as intersectPayloadBlocksWithForm,
2094
+ Ne as isA2uiSurfaceEmpty,
2095
+ K as isInputBlockType,
2096
+ Ee as isLayoutBlockType,
2097
+ Ie as isMediaBlockType,
2098
+ jn as mapFormDefinitionFromDto,
2099
+ Y as normalizeFormDefinition,
2100
+ Yn as parsePayloadBlocksJson,
2101
+ Zn as payloadHasInputBlocks,
2102
+ Bn as resolveSurfaceFromFormDefinition,
2103
+ tr as submitFormJson,
2104
+ Vn as surfaceDocToMessages,
2105
+ le as syncFormDefinition,
2106
+ an as useCaseSearch,
2107
+ hn as useResumeSearch
1428
2108
  };