@flowgram.ai/form-materials 0.1.0-alpha.12 → 0.1.0-alpha.14

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 (164) hide show
  1. package/bin/index.ts +4 -29
  2. package/bin/materials.ts +56 -87
  3. package/bin/project.ts +4 -0
  4. package/bin/utils/import.ts +127 -0
  5. package/bin/utils/traverse-file.ts +60 -0
  6. package/dist/esm/chunk-727SU246.js +13 -0
  7. package/dist/esm/chunk-727SU246.js.map +1 -0
  8. package/dist/esm/chunk-DEZUEMUM.js +284 -0
  9. package/dist/esm/chunk-DEZUEMUM.js.map +1 -0
  10. package/dist/esm/chunk-DUOXDOUE.js +477 -0
  11. package/dist/esm/chunk-DUOXDOUE.js.map +1 -0
  12. package/dist/esm/editor-6UMULJYB.js +180 -0
  13. package/dist/esm/editor-6UMULJYB.js.map +1 -0
  14. package/dist/esm/editor-EYOQTGMT.js +282 -0
  15. package/dist/esm/editor-EYOQTGMT.js.map +1 -0
  16. package/dist/esm/editor-OXPGKPF5.js +167 -0
  17. package/dist/esm/editor-OXPGKPF5.js.map +1 -0
  18. package/dist/esm/editor-VO6YAXRC.js +249 -0
  19. package/dist/esm/editor-VO6YAXRC.js.map +1 -0
  20. package/dist/esm/editor-XYLKTB6L.js +365 -0
  21. package/dist/esm/editor-XYLKTB6L.js.map +1 -0
  22. package/dist/esm/index.js +1186 -2456
  23. package/dist/esm/index.js.map +1 -1
  24. package/dist/index.d.mts +363 -70
  25. package/dist/index.d.ts +363 -70
  26. package/dist/index.js +4064 -2887
  27. package/dist/index.js.map +1 -1
  28. package/package.json +9 -8
  29. package/src/components/assign-row/index.tsx +4 -4
  30. package/src/components/assign-rows/index.tsx +1 -1
  31. package/src/components/batch-outputs/index.tsx +7 -5
  32. package/src/components/batch-outputs/types.ts +1 -1
  33. package/src/components/batch-variable-selector/index.tsx +1 -1
  34. package/src/components/code-editor/editor.tsx +89 -0
  35. package/src/components/code-editor/index.tsx +5 -89
  36. package/src/components/code-editor/language-features.ts +18 -18
  37. package/src/components/code-editor/theme/dark.ts +49 -30
  38. package/src/components/code-editor/theme/light.ts +56 -32
  39. package/src/components/code-editor-mini/index.tsx +2 -2
  40. package/src/components/condition-row/constants.ts +10 -2
  41. package/src/components/condition-row/hooks/useOp.tsx +13 -9
  42. package/src/components/condition-row/hooks/useRule.ts +8 -4
  43. package/src/components/condition-row/index.tsx +31 -10
  44. package/src/components/condition-row/types.ts +5 -7
  45. package/src/components/constant-input/index.tsx +5 -2
  46. package/src/components/constant-input/types.ts +1 -1
  47. package/src/components/db-condition-row/hooks/use-left.tsx +66 -0
  48. package/src/components/db-condition-row/hooks/use-op.tsx +59 -0
  49. package/src/components/db-condition-row/index.tsx +93 -0
  50. package/src/components/db-condition-row/styles.tsx +43 -0
  51. package/src/components/db-condition-row/types.ts +34 -0
  52. package/src/components/display-flow-value/index.tsx +4 -14
  53. package/src/components/display-inputs-values/index.tsx +46 -7
  54. package/src/components/display-outputs/index.tsx +2 -1
  55. package/src/components/display-schema-tag/index.tsx +3 -2
  56. package/src/components/display-schema-tree/index.tsx +2 -1
  57. package/src/components/dynamic-value-input/hooks.ts +25 -4
  58. package/src/components/dynamic-value-input/index.tsx +33 -20
  59. package/src/components/dynamic-value-input/styles.tsx +14 -4
  60. package/src/components/index.ts +3 -0
  61. package/src/components/inputs-values/index.tsx +21 -8
  62. package/src/components/inputs-values/styles.tsx +1 -1
  63. package/src/components/inputs-values/types.ts +3 -3
  64. package/src/components/inputs-values-tree/hooks/use-child-list.tsx +76 -0
  65. package/src/components/inputs-values-tree/index.tsx +62 -0
  66. package/src/components/inputs-values-tree/row.tsx +177 -0
  67. package/src/components/inputs-values-tree/styles.tsx +128 -0
  68. package/src/components/inputs-values-tree/types.ts +21 -0
  69. package/src/components/json-editor-with-variables/editor.tsx +69 -0
  70. package/src/components/json-editor-with-variables/extensions/variable-tag.tsx +6 -5
  71. package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +1 -1
  72. package/src/components/json-editor-with-variables/index.tsx +5 -58
  73. package/src/components/json-schema-editor/default-value.tsx +12 -108
  74. package/src/components/json-schema-editor/hooks.tsx +63 -93
  75. package/src/components/json-schema-editor/index.tsx +36 -70
  76. package/src/components/json-schema-editor/styles.tsx +12 -84
  77. package/src/components/json-schema-editor/types.ts +0 -1
  78. package/src/components/prompt-editor/editor.tsx +81 -0
  79. package/src/components/prompt-editor/index.tsx +5 -62
  80. package/src/components/prompt-editor/types.tsx +1 -1
  81. package/src/components/prompt-editor-with-inputs/editor.tsx +25 -0
  82. package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +13 -1
  83. package/src/components/prompt-editor-with-inputs/index.tsx +5 -15
  84. package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +34 -17
  85. package/src/components/prompt-editor-with-variables/editor.tsx +22 -0
  86. package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +12 -20
  87. package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +14 -2
  88. package/src/components/prompt-editor-with-variables/index.tsx +5 -12
  89. package/src/components/type-selector/index.tsx +21 -9
  90. package/src/components/variable-selector/context.tsx +28 -0
  91. package/src/components/variable-selector/index.tsx +19 -6
  92. package/src/components/variable-selector/use-variable-tree.tsx +4 -4
  93. package/src/effects/auto-rename-ref/index.ts +8 -55
  94. package/src/effects/listen-ref-schema-change/index.ts +1 -1
  95. package/src/effects/listen-ref-value-change/index.ts +1 -1
  96. package/src/effects/provide-batch-input/index.ts +1 -1
  97. package/src/effects/validate-when-variable-sync/index.ts +1 -1
  98. package/src/form-plugins/batch-outputs-plugin/index.ts +1 -1
  99. package/src/form-plugins/infer-assign-plugin/index.ts +2 -2
  100. package/src/form-plugins/infer-inputs-plugin/index.ts +4 -76
  101. package/src/hooks/use-object-list/index.tsx +35 -7
  102. package/src/index.ts +1 -0
  103. package/src/plugins/json-schema-preset/manager.ts +1 -0
  104. package/src/plugins/json-schema-preset/type-definition/array.tsx +3 -1
  105. package/src/plugins/json-schema-preset/type-definition/boolean.tsx +4 -3
  106. package/src/plugins/json-schema-preset/type-definition/date-time.tsx +25 -0
  107. package/src/plugins/json-schema-preset/type-definition/index.tsx +2 -0
  108. package/src/plugins/json-schema-preset/type-definition/integer.tsx +2 -1
  109. package/src/plugins/json-schema-preset/type-definition/number.tsx +2 -1
  110. package/src/plugins/json-schema-preset/type-definition/object.tsx +3 -1
  111. package/src/plugins/json-schema-preset/type-definition/string.tsx +19 -4
  112. package/src/shared/flow-value/index.ts +6 -0
  113. package/src/shared/flow-value/schema.ts +38 -0
  114. package/src/shared/flow-value/utils.ts +201 -0
  115. package/src/shared/format-legacy-refs/index.ts +1 -1
  116. package/src/shared/index.ts +4 -0
  117. package/src/shared/inject-material/README.md +170 -0
  118. package/src/shared/inject-material/README.zh.md +174 -0
  119. package/src/shared/inject-material/index.tsx +87 -0
  120. package/src/shared/lazy-suspense/index.tsx +28 -0
  121. package/src/shared/polyfill-create-root/index.tsx +33 -0
  122. package/src/typings/flow-value/index.ts +3 -1
  123. package/src/validate/validate-flow-value/index.tsx +4 -16
  124. package/src/components/assign-row/config.json +0 -11
  125. package/src/components/assign-rows/config.json +0 -11
  126. package/src/components/batch-outputs/config.json +0 -13
  127. package/src/components/batch-variable-selector/config.json +0 -9
  128. package/src/components/code-editor/config.json +0 -10
  129. package/src/components/code-editor-mini/config.json +0 -7
  130. package/src/components/condition-row/config.json +0 -13
  131. package/src/components/constant-input/config.json +0 -9
  132. package/src/components/display-flow-value/config.json +0 -8
  133. package/src/components/display-inputs-values/config.json +0 -9
  134. package/src/components/display-outputs/config.json +0 -10
  135. package/src/components/display-schema-tag/config.json +0 -10
  136. package/src/components/display-schema-tree/config.json +0 -11
  137. package/src/components/dynamic-value-input/config.json +0 -14
  138. package/src/components/inputs-values/config.json +0 -13
  139. package/src/components/json-editor-with-variables/config.json +0 -13
  140. package/src/components/json-schema-editor/components/blur-input.tsx +0 -27
  141. package/src/components/json-schema-editor/config.json +0 -13
  142. package/src/components/json-schema-editor/utils.ts +0 -29
  143. package/src/components/prompt-editor/config.json +0 -9
  144. package/src/components/prompt-editor-with-inputs/config.json +0 -13
  145. package/src/components/prompt-editor-with-variables/config.json +0 -13
  146. package/src/components/type-selector/config.json +0 -9
  147. package/src/components/variable-selector/config.json +0 -9
  148. package/src/effects/auto-rename-ref/config.json +0 -5
  149. package/src/effects/listen-ref-schema-change/config.json +0 -10
  150. package/src/effects/listen-ref-value-change/config.json +0 -9
  151. package/src/effects/provide-batch-input/config.json +0 -5
  152. package/src/effects/provide-json-schema-outputs/config.json +0 -7
  153. package/src/effects/sync-variable-title/config.json +0 -5
  154. package/src/effects/validate-when-variable-sync/config.json +0 -5
  155. package/src/form-plugins/batch-outputs-plugin/config.json +0 -7
  156. package/src/form-plugins/infer-assign-plugin/config.json +0 -7
  157. package/src/form-plugins/infer-inputs-plugin/config.json +0 -9
  158. package/src/hooks/use-object-list/config.json +0 -8
  159. package/src/plugins/disable-declaration-plugin/config.json +0 -5
  160. package/src/plugins/json-schema-preset/config.json +0 -9
  161. package/src/shared/format-legacy-refs/config.json +0 -5
  162. package/src/typings/flow-value/config.json +0 -7
  163. package/src/validate/validate-flow-value/config.json +0 -7
  164. /package/src/components/{inputs-values/components/blur-input.tsx → blur-input/index.tsx} +0 -0
package/dist/esm/index.js CHANGED
@@ -1,750 +1,38 @@
1
- // src/components/variable-selector/index.tsx
2
- import React11, { useMemo } from "react";
3
- import { Popover } from "@douyinfe/semi-ui";
4
- import { IconChevronDownStroked, IconIssueStroked } from "@douyinfe/semi-icons";
5
-
6
- // src/components/variable-selector/use-variable-tree.tsx
7
- import React10, { useCallback } from "react";
8
- import { JsonSchemaUtils as JsonSchemaUtils2 } from "@flowgram.ai/json-schema";
9
- import { ASTMatch as ASTMatch2, useAvailableVariables } from "@flowgram.ai/editor";
10
- import { Icon } from "@douyinfe/semi-ui";
11
-
12
- // src/plugins/json-schema-preset/index.tsx
13
- import React9 from "react";
14
- import {
15
- JsonSchemaUtils,
16
- useTypeManager as useOriginTypeManager,
17
- TypePresetProvider as OriginTypePresetProvider
18
- } from "@flowgram.ai/json-schema";
19
-
20
- // src/plugins/json-schema-preset/type-definition/index.tsx
21
- import { jsonSchemaTypeManager } from "@flowgram.ai/json-schema";
22
-
23
- // src/plugins/json-schema-preset/type-definition/string.tsx
24
- import React from "react";
25
- import { Input } from "@douyinfe/semi-ui";
26
- var stringRegistry = {
27
- type: "string",
28
- ConstantRenderer: (props) => /* @__PURE__ */ React.createElement(Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
29
- };
30
-
31
- // src/plugins/json-schema-preset/type-definition/object.tsx
32
- import React4 from "react";
33
-
34
- // src/components/code-editor-mini/index.tsx
35
- import React3 from "react";
36
- import styled from "styled-components";
37
-
38
- // src/components/code-editor/index.tsx
39
- import React2, { useEffect, useRef } from "react";
40
1
  import {
41
- ActiveLinePlaceholder,
42
- createRenderer,
43
- EditorProvider
44
- } from "@coze-editor/editor/react";
45
- import preset from "@coze-editor/editor/preset-code";
46
- import { EditorView } from "@codemirror/view";
47
-
48
- // src/components/code-editor/utils.ts
49
- function getSuffixByLanguageId(languageId) {
50
- if (languageId === "python") {
51
- return ".py";
52
- }
53
- if (languageId === "typescript") {
54
- return ".ts";
55
- }
56
- if (languageId === "shell") {
57
- return ".sh";
58
- }
59
- if (languageId === "json") {
60
- return ".json";
61
- }
62
- return "";
63
- }
64
-
65
- // src/components/code-editor/language-features.ts
66
- import { languages } from "@coze-editor/editor/preset-code";
67
- import { typescript } from "@coze-editor/editor/language-typescript";
68
- import { shell } from "@coze-editor/editor/language-shell";
69
- import { python } from "@coze-editor/editor/language-python";
70
- import { json } from "@coze-editor/editor/language-json";
71
- import { mixLanguages } from "@coze-editor/editor";
72
- languages.register("python", python);
73
- languages.register("shell", shell);
74
- languages.register("typescript", typescript);
75
- languages.register("json", {
76
- // mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
77
- language: mixLanguages({
78
- outerLanguage: json.language
79
- }),
80
- languageService: json.languageService
81
- });
82
- var tsWorkerInit = false;
83
- var initTsWorker = () => {
84
- if (tsWorkerInit) {
85
- return;
86
- }
87
- tsWorkerInit = true;
88
- const tsWorker = new Worker(
89
- new URL(`@coze-editor/editor/language-typescript/worker`, import.meta.url),
90
- { type: "module" }
91
- );
92
- typescript.languageService.initialize(tsWorker, {
93
- compilerOptions: {
94
- // eliminate Promise error
95
- lib: ["es2015", "dom"],
96
- noImplicitAny: false
97
- }
98
- });
99
- };
100
-
101
- // src/components/code-editor/theme/index.ts
102
- import { themes } from "@coze-editor/editor/preset-code";
103
-
104
- // src/components/code-editor/theme/light.ts
105
- import { createTheme, tags as t } from "@coze-editor/editor/preset-code";
106
- var colors = {
107
- background: "#F7F7FC",
108
- // syntax
109
- comment: "#000A298A",
110
- key: "#00818C",
111
- string: "#D1009D",
112
- number: "#C74200",
113
- boolean: "#2B57D9",
114
- null: "#2B57D9",
115
- separator: "#0F1529D1"
116
- };
117
- var lightTheme = createTheme({
118
- variant: "light",
119
- settings: {
120
- background: "#fff",
121
- foreground: "#000",
122
- caret: "#000",
123
- selection: "#d9d9d9",
124
- gutterBackground: "#f0f0f0",
125
- gutterForeground: "#666",
126
- gutterBorderColor: "transparent",
127
- gutterBorderWidth: 0,
128
- lineHighlight: "#e1e1e180",
129
- bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
130
- tooltip: {
131
- backgroundColor: "#f0f0f0",
132
- color: "#000",
133
- border: "1px solid #ccc"
134
- },
135
- link: {
136
- color: "#007bff"
137
- },
138
- completionItemHover: {
139
- backgroundColor: "#f0f0f0"
140
- },
141
- completionItemSelected: {
142
- backgroundColor: "#e0e0e0"
143
- },
144
- completionItemIcon: {
145
- color: "#333"
146
- },
147
- completionItemLabel: {
148
- color: "#333"
149
- },
150
- completionItemInfo: {
151
- color: "#333"
152
- },
153
- completionItemDetail: {
154
- color: "#666"
155
- }
156
- },
157
- styles: [
158
- // JSON
159
- {
160
- tag: t.comment,
161
- color: colors.comment
162
- },
163
- {
164
- tag: [t.propertyName],
165
- color: colors.key
166
- },
167
- {
168
- tag: [t.string],
169
- color: colors.string
170
- },
171
- {
172
- tag: [t.number],
173
- color: colors.number
174
- },
175
- {
176
- tag: [t.bool],
177
- color: colors.boolean
178
- },
179
- {
180
- tag: [t.null],
181
- color: colors.null
182
- },
183
- {
184
- tag: [t.separator],
185
- color: colors.separator
186
- },
187
- // markdown
188
- {
189
- tag: [t.heading],
190
- color: "#3e76ef"
191
- },
192
- {
193
- tag: [t.processingInstruction],
194
- color: "#3e76ef"
195
- },
196
- // shell
197
- // curl
198
- {
199
- tag: [t.standard(t.variableName)],
200
- color: "#00804A"
201
- },
202
- // -X
203
- {
204
- tag: [t.attributeName],
205
- color: "#C74200"
206
- },
207
- // url in string (includes quotes), e.g. "https://..."
208
- {
209
- tag: [t.special(t.string)],
210
- color: "#2B57D9"
211
- }
212
- ]
213
- });
214
-
215
- // src/components/code-editor/theme/dark.ts
216
- import { createTheme as createTheme2, tags as t2 } from "@coze-editor/editor/preset-code";
217
- var colors2 = {
218
- background: "#151B27",
219
- // syntax
220
- comment: "#FFFFFF63",
221
- key: "#39E5D7",
222
- string: "#FF94D2",
223
- number: "#FF9933",
224
- boolean: "#78B0FF",
225
- null: "#78B0FF",
226
- separator: "#FFFFFFC9"
227
- };
228
- var darkTheme = createTheme2({
229
- variant: "dark",
230
- settings: {
231
- background: colors2.background,
232
- foreground: "#fff",
233
- caret: "#AEAFAD",
234
- selection: "#d9d9d942",
235
- gutterBackground: colors2.background,
236
- gutterForeground: "#FFFFFF63",
237
- gutterBorderColor: "transparent",
238
- gutterBorderWidth: 0,
239
- lineHighlight: "#272e3d36",
240
- bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
241
- tooltip: {
242
- backgroundColor: "#363D4D",
243
- color: "#fff",
244
- border: "none"
245
- },
246
- link: {
247
- color: "#4daafc"
248
- },
249
- completionItemHover: {
250
- backgroundColor: "#FFFFFF0F"
251
- },
252
- completionItemSelected: {
253
- backgroundColor: "#FFFFFF17"
254
- },
255
- completionItemIcon: {
256
- color: "#FFFFFFC9"
257
- },
258
- completionItemLabel: {
259
- color: "#FFFFFFC9"
260
- },
261
- completionItemInfo: {
262
- color: "#FFFFFFC9"
263
- },
264
- completionItemDetail: {
265
- color: "#FFFFFF63"
266
- }
267
- },
268
- styles: [
269
- // json
270
- {
271
- tag: t2.comment,
272
- color: colors2.comment
273
- },
274
- {
275
- tag: [t2.propertyName],
276
- color: colors2.key
277
- },
278
- {
279
- tag: [t2.string],
280
- color: colors2.string
281
- },
282
- {
283
- tag: [t2.number],
284
- color: colors2.number
285
- },
286
- {
287
- tag: [t2.bool],
288
- color: colors2.boolean
289
- },
290
- {
291
- tag: [t2.null],
292
- color: colors2.null
293
- },
294
- {
295
- tag: [t2.separator],
296
- color: colors2.separator
297
- },
298
- // markdown
299
- {
300
- tag: [t2.heading],
301
- color: "#6b6bff"
302
- },
303
- {
304
- tag: [t2.processingInstruction],
305
- color: "#6b6bff"
306
- },
307
- // shell
308
- // curl
309
- {
310
- tag: [t2.standard(t2.variableName)],
311
- color: "#3BEB84"
312
- },
313
- // -X
314
- {
315
- tag: [t2.attributeName],
316
- color: "#FF9933"
317
- },
318
- // url in string (includes quotes), e.g. "https://..."
319
- {
320
- tag: [t2.special(t2.string)],
321
- color: "#78B0FF"
322
- }
323
- ]
324
- });
325
-
326
- // src/components/code-editor/theme/index.ts
327
- themes.register("dark", darkTheme);
328
- themes.register("light", lightTheme);
329
-
330
- // src/components/code-editor/index.tsx
331
- var OriginCodeEditor = createRenderer(preset, [
332
- EditorView.theme({
333
- "&.cm-focused": {
334
- outline: "none"
335
- }
336
- })
337
- ]);
338
- function CodeEditor({
339
- value,
340
- onChange,
341
- languageId = "python",
342
- theme = "light",
343
- children,
344
- placeholder,
345
- activeLinePlaceholder,
346
- options,
347
- readonly
348
- }) {
349
- const editorRef = useRef(null);
350
- useEffect(() => {
351
- if (languageId === "typescript") {
352
- initTsWorker();
353
- }
354
- }, [languageId]);
355
- useEffect(() => {
356
- if (editorRef.current?.getValue() !== value) {
357
- editorRef.current?.setValue(String(value || ""));
358
- }
359
- }, [value]);
360
- return /* @__PURE__ */ React2.createElement(EditorProvider, null, /* @__PURE__ */ React2.createElement(
361
- OriginCodeEditor,
362
- {
363
- defaultValue: value,
364
- options: {
365
- uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
366
- languageId,
367
- theme,
368
- placeholder,
369
- readOnly: readonly,
370
- editable: !readonly,
371
- ...options || {}
372
- },
373
- didMount: (editor) => {
374
- editorRef.current = editor;
375
- },
376
- onChange: (e) => onChange?.(e.value)
377
- },
378
- activeLinePlaceholder && /* @__PURE__ */ React2.createElement(ActiveLinePlaceholder, null, activeLinePlaceholder),
379
- children
380
- ));
381
- }
382
-
383
- // src/components/code-editor-mini/index.tsx
384
- var UIMini = styled.div`
385
- .ͼ1 .cm-content {
386
- padding: 0;
387
- }
388
- `;
389
- function CodeEditorMini(props) {
390
- return /* @__PURE__ */ React3.createElement(UIMini, null, /* @__PURE__ */ React3.createElement(
391
- CodeEditor,
392
- {
393
- ...props,
394
- options: {
395
- lineNumbersGutter: false,
396
- foldGutter: false,
397
- ...props.options || {}
398
- }
399
- }
400
- ));
401
- }
402
-
403
- // src/plugins/json-schema-preset/type-definition/object.tsx
404
- var objectRegistry = {
405
- type: "object",
406
- ConstantRenderer: (props) => /* @__PURE__ */ React4.createElement(
407
- CodeEditorMini,
408
- {
409
- value: props.value,
410
- onChange: (v) => props.onChange?.(v),
411
- languageId: "json",
412
- placeholder: "Please Input Object",
413
- readonly: props.readonly
414
- }
415
- )
416
- };
417
-
418
- // src/plugins/json-schema-preset/type-definition/number.tsx
419
- import React5 from "react";
420
- import { InputNumber } from "@douyinfe/semi-ui";
421
- var numberRegistry = {
422
- type: "number",
423
- ConstantRenderer: (props) => /* @__PURE__ */ React5.createElement(
424
- InputNumber,
425
- {
426
- placeholder: "Please Input Number",
427
- size: "small",
428
- disabled: props.readonly,
429
- hideButtons: true,
430
- ...props
431
- }
432
- )
433
- };
434
-
435
- // src/plugins/json-schema-preset/type-definition/integer.tsx
436
- import React6 from "react";
437
- import { InputNumber as InputNumber2 } from "@douyinfe/semi-ui";
438
- var integerRegistry = {
439
- type: "integer",
440
- ConstantRenderer: (props) => /* @__PURE__ */ React6.createElement(
441
- InputNumber2,
442
- {
443
- placeholder: "Please Input Integer",
444
- size: "small",
445
- disabled: props.readonly,
446
- precision: 0,
447
- ...props
448
- }
449
- )
450
- };
451
-
452
- // src/plugins/json-schema-preset/type-definition/boolean.tsx
453
- import React7 from "react";
454
- import { Select } from "@douyinfe/semi-ui";
455
- var booleanRegistry = {
456
- type: "boolean",
457
- ConstantRenderer: (props) => {
458
- const { value, onChange, ...rest } = props;
459
- return /* @__PURE__ */ React7.createElement(
460
- Select,
461
- {
462
- placeholder: "Please Select Boolean",
463
- size: "small",
464
- disabled: props.readonly,
465
- optionList: [
466
- { label: "True", value: 1 },
467
- { label: "False", value: 0 }
468
- ],
469
- value: value ? 1 : 0,
470
- onChange: (value2) => onChange?.(!!value2),
471
- ...rest
472
- }
473
- );
474
- }
475
- };
476
-
477
- // src/plugins/json-schema-preset/type-definition/array.tsx
478
- import React8 from "react";
479
- var arrayRegistry = {
480
- type: "array",
481
- ConstantRenderer: (props) => /* @__PURE__ */ React8.createElement(
482
- CodeEditorMini,
483
- {
484
- value: props.value,
485
- languageId: "json",
486
- onChange: (v) => props.onChange?.(v),
487
- placeholder: "Please Input Array",
488
- readonly: props.readonly
489
- }
490
- )
491
- };
492
-
493
- // src/plugins/json-schema-preset/type-definition/index.tsx
494
- var jsonSchemaTypePreset = [
495
- stringRegistry,
496
- objectRegistry,
497
- numberRegistry,
498
- integerRegistry,
499
- booleanRegistry,
500
- arrayRegistry
501
- ];
502
- jsonSchemaTypePreset.forEach((_type) => jsonSchemaTypeManager.register(_type));
503
-
504
- // src/plugins/json-schema-preset/create-type-preset-plugin.tsx
2
+ PromptEditor
3
+ } from "./chunk-727SU246.js";
505
4
  import {
506
- BaseTypeManager,
507
- jsonSchemaContainerModule
508
- } from "@flowgram.ai/json-schema";
509
- import { definePluginCreator } from "@flowgram.ai/editor";
510
- var createTypePresetPlugin = definePluginCreator({
511
- onInit(ctx, opts) {
512
- const typeManager = ctx.get(BaseTypeManager);
513
- jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
514
- opts.types?.forEach((_type) => typeManager.register(_type));
515
- opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
516
- },
517
- containerModules: [jsonSchemaContainerModule]
518
- });
519
-
520
- // src/plugins/json-schema-preset/index.tsx
521
- var useTypeManager = () => useOriginTypeManager();
522
- var JsonSchemaTypePresetProvider = ({
523
- types = [],
524
- children
525
- }) => /* @__PURE__ */ React9.createElement(OriginTypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
526
-
527
- // src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
5
+ CodeEditor,
6
+ CodeEditorMini,
7
+ InjectVariableSelector,
8
+ JsonSchemaTypePresetProvider,
9
+ JsonSchemaUtils,
10
+ VariableSelector,
11
+ VariableSelectorProvider,
12
+ createDisableDeclarationPlugin,
13
+ createTypePresetPlugin,
14
+ useTypeManager,
15
+ useVariableTree
16
+ } from "./chunk-DUOXDOUE.js";
528
17
  import {
529
- ASTMatch,
530
- definePluginCreator as definePluginCreator2,
531
- VariableEngine
532
- } from "@flowgram.ai/editor";
533
- var createDisableDeclarationPlugin = definePluginCreator2({
534
- onInit(ctx) {
535
- const variableEngine = ctx.get(VariableEngine);
536
- const handleEvent = (action) => {
537
- if (ASTMatch.isVariableDeclaration(action.ast)) {
538
- if (!action.ast.meta?.disabled) {
539
- action.ast.updateMeta({
540
- ...action.ast.meta || {},
541
- disabled: true
542
- });
543
- }
544
- }
545
- };
546
- variableEngine.onGlobalEvent("NewAST", handleEvent);
547
- variableEngine.onGlobalEvent("UpdateAST", handleEvent);
548
- }
549
- });
550
-
551
- // src/components/variable-selector/use-variable-tree.tsx
552
- function useVariableTree(params) {
553
- const { includeSchema, excludeSchema, customSkip } = params;
554
- const typeManager = useTypeManager();
555
- const variables = useAvailableVariables();
556
- const getVariableTypeIcon = useCallback((variable) => {
557
- if (variable.meta?.icon) {
558
- if (typeof variable.meta.icon === "string") {
559
- return /* @__PURE__ */ React10.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
560
- }
561
- return variable.meta.icon;
562
- }
563
- const schema = JsonSchemaUtils2.astToSchema(variable.type, { drilldownObject: false });
564
- return /* @__PURE__ */ React10.createElement(Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
565
- }, []);
566
- const renderVariable = (variable, parentFields = []) => {
567
- let type = variable?.type;
568
- if (!type) {
569
- return null;
570
- }
571
- let children;
572
- if (ASTMatch2.isObject(type)) {
573
- children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
574
- }
575
- const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
576
- const key = keyPath.join(".");
577
- const isSchemaInclude = includeSchema ? JsonSchemaUtils2.isASTMatchSchema(type, includeSchema) : true;
578
- const isSchemaExclude = excludeSchema ? JsonSchemaUtils2.isASTMatchSchema(type, excludeSchema) : false;
579
- const isCustomSkip = customSkip ? customSkip(variable) : false;
580
- const isMetaDisabled = variable.meta?.disabled;
581
- const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip && !isMetaDisabled;
582
- if (!isSchemaMatch && !children?.length) {
583
- return null;
584
- }
585
- return {
586
- key,
587
- label: variable.meta?.title || variable.key,
588
- value: key,
589
- keyPath,
590
- icon: getVariableTypeIcon(variable),
591
- children,
592
- disabled: !isSchemaMatch,
593
- rootMeta: parentFields[0]?.meta || variable.meta,
594
- isRoot: !parentFields?.length
595
- };
596
- };
597
- return [...variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
598
- }
599
-
600
- // src/components/variable-selector/styles.tsx
601
- import styled2, { css } from "styled-components";
602
- import { Tag, TreeSelect } from "@douyinfe/semi-ui";
603
- var UIRootTitle = styled2.div`
604
- margin-right: 4px;
605
- min-width: 20px;
606
- overflow: hidden;
607
- text-overflow: ellipsis;
608
- white-space: nowrap;
609
- color: var(--semi-color-text-2);
610
- `;
611
- var UIVarName = styled2.div`
612
- overflow: hidden;
613
- text-overflow: ellipsis;
614
- white-space: nowrap;
615
-
616
- ${({ $inSelector }) => $inSelector && css`
617
- min-width: 50%;
618
- `}
619
- `;
620
- var UITag = styled2(Tag)`
621
- width: 100%;
622
- display: flex;
623
- align-items: center;
624
- justify-content: flex-start;
625
-
626
- & .semi-tag-content-center {
627
- justify-content: flex-start;
628
- }
629
-
630
- &.semi-tag {
631
- margin: 0;
632
- height: 22px;
633
- }
634
- `;
635
- var UITreeSelect = styled2(TreeSelect)`
636
- outline: ${({ $error }) => $error ? "1px solid red" : "none"};
637
-
638
- & .semi-tree-select-selection {
639
- padding: 0px;
640
- height: 22px;
641
- }
642
-
643
- & .semi-tree-select-selection-content {
644
- width: 100%;
645
- }
646
-
647
- & .semi-tree-select-selection-placeholder {
648
- padding-left: 10px;
649
- }
650
- `;
651
- var UIPopoverContent = styled2.div`
652
- padding: 10px;
653
- display: inline-flex;
654
- align-items: center;
655
- justify-content: flex-start;
656
- white-space: nowrap;
657
- `;
658
-
659
- // src/components/variable-selector/index.tsx
660
- var VariableSelector = ({
661
- value,
662
- config = {},
663
- onChange,
664
- style,
665
- readonly = false,
666
- includeSchema,
667
- excludeSchema,
668
- hasError,
669
- triggerRender
670
- }) => {
671
- const treeData = useVariableTree({ includeSchema, excludeSchema });
672
- const treeValue = useMemo(() => {
673
- if (typeof value === "string") {
674
- console.warn(
675
- "The Value of VariableSelector is a string, it should be an ARRAY. \n",
676
- "Please check the value of VariableSelector \n"
677
- );
678
- return value;
679
- }
680
- return value?.join(".");
681
- }, [value]);
682
- const renderIcon = (icon) => {
683
- if (typeof icon === "string") {
684
- return /* @__PURE__ */ React11.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
685
- }
686
- return icon;
687
- };
688
- return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(
689
- UITreeSelect,
690
- {
691
- dropdownMatchSelectWidth: false,
692
- disabled: readonly,
693
- treeData,
694
- size: "small",
695
- value: treeValue,
696
- clearIcon: null,
697
- $error: hasError,
698
- style,
699
- validateStatus: hasError ? "error" : void 0,
700
- onChange: (_, _config) => {
701
- onChange(_config.keyPath);
702
- },
703
- renderSelectedItem: (_option) => {
704
- if (!_option?.keyPath) {
705
- return /* @__PURE__ */ React11.createElement(
706
- UITag,
707
- {
708
- prefixIcon: /* @__PURE__ */ React11.createElement(IconIssueStroked, null),
709
- color: "amber",
710
- closable: !readonly,
711
- onClose: () => onChange(void 0)
712
- },
713
- config?.notFoundContent ?? "Undefined"
714
- );
715
- }
716
- const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
717
- const rootTitle = /* @__PURE__ */ React11.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
718
- return /* @__PURE__ */ React11.createElement("div", null, /* @__PURE__ */ React11.createElement(
719
- Popover,
720
- {
721
- content: /* @__PURE__ */ React11.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React11.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
722
- },
723
- /* @__PURE__ */ React11.createElement(
724
- UITag,
725
- {
726
- prefixIcon: rootIcon,
727
- closable: !readonly,
728
- onClose: () => onChange(void 0)
729
- },
730
- rootTitle,
731
- !_option.isRoot && /* @__PURE__ */ React11.createElement(UIVarName, { $inSelector: true }, _option.label)
732
- )
733
- ));
734
- },
735
- showClear: false,
736
- arrowIcon: /* @__PURE__ */ React11.createElement(IconChevronDownStroked, { size: "small" }),
737
- triggerRender,
738
- placeholder: config?.placeholder ?? "Select Variable"
739
- }
740
- ));
741
- };
18
+ FlowValueUtils,
19
+ createInjectMaterial,
20
+ formatLegacyRefOnInit,
21
+ formatLegacyRefOnSubmit,
22
+ formatLegacyRefToNewRef,
23
+ formatNewRefToLegacyRef,
24
+ isLegacyFlowRefValueSchema,
25
+ isNewFlowRefValueSchema,
26
+ lazySuspense,
27
+ polyfillCreateRoot,
28
+ unstableSetCreateRoot,
29
+ withSuspense
30
+ } from "./chunk-DEZUEMUM.js";
742
31
 
743
32
  // src/components/type-selector/index.tsx
744
- import React12, { useMemo as useMemo2 } from "react";
745
- import { Cascader, Icon as Icon2, IconButton } from "@douyinfe/semi-ui";
33
+ import React, { useMemo } from "react";
34
+ import { Cascader, Icon, IconButton } from "@douyinfe/semi-ui";
746
35
  var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
747
- var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
748
36
  var getTypeSelectValue = (value) => {
749
37
  if (value?.type === "array" && value?.items) {
750
38
  return [value.type, ...getTypeSelectValue(value.items) || []];
@@ -760,18 +48,18 @@ var parseTypeSelectValue = (value) => {
760
48
  };
761
49
  function TypeSelector(props) {
762
50
  const { value, onChange, readonly, disabled, style } = props;
763
- const selectValue = useMemo2(() => getTypeSelectValue(value), [value]);
51
+ const selectValue = useMemo(() => getTypeSelectValue(value), [value]);
764
52
  const typeManager = useTypeManager();
765
53
  const icon = typeManager.getDisplayIcon(value || {});
766
- const options = useMemo2(
54
+ const options = useMemo(
767
55
  () => typeManager.getTypeRegistriesWithParentType().map((_type) => {
768
- const isArray2 = _type.type === "array";
56
+ const isArray = _type.type === "array";
769
57
  return {
770
- label: /* @__PURE__ */ React12.createElement("div", { style: labelStyle }, /* @__PURE__ */ React12.createElement(Icon2, { size: "small", svg: _type.icon }), firstUppercase(_type.type)),
58
+ label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: _type.icon }), typeManager.getTypeBySchema(_type)?.label || _type.type),
771
59
  value: _type.type,
772
- children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
773
- label: /* @__PURE__ */ React12.createElement("div", { style: labelStyle }, /* @__PURE__ */ React12.createElement(
774
- Icon2,
60
+ children: isArray ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
61
+ label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(
62
+ Icon,
775
63
  {
776
64
  size: "small",
777
65
  svg: typeManager.getDisplayIcon({
@@ -779,19 +67,31 @@ function TypeSelector(props) {
779
67
  items: { type: _type2.type }
780
68
  })
781
69
  }
782
- ), firstUppercase(_type2.type)),
70
+ ), typeManager.getTypeBySchema(_type2)?.label || _type2.type),
783
71
  value: _type2.type
784
72
  })) : []
785
73
  };
786
74
  }),
787
75
  []
788
76
  );
789
- return /* @__PURE__ */ React12.createElement(
77
+ const isDisabled = readonly || disabled;
78
+ return /* @__PURE__ */ React.createElement(
790
79
  Cascader,
791
80
  {
792
- disabled: readonly || disabled,
81
+ disabled: isDisabled,
793
82
  size: "small",
794
- triggerRender: () => /* @__PURE__ */ React12.createElement(IconButton, { size: "small", style, disabled: readonly || disabled, icon }),
83
+ triggerRender: () => /* @__PURE__ */ React.createElement(
84
+ IconButton,
85
+ {
86
+ size: "small",
87
+ style: {
88
+ ...isDisabled ? { pointerEvents: "none" } : {},
89
+ ...style || {}
90
+ },
91
+ disabled: isDisabled,
92
+ icon
93
+ }
94
+ ),
795
95
  treeData: options,
796
96
  value: selectValue,
797
97
  leafOnly: true,
@@ -801,10 +101,13 @@ function TypeSelector(props) {
801
101
  }
802
102
  );
803
103
  }
104
+ TypeSelector.renderKey = "type-selector-render-key";
105
+ var InjectTypeSelector = createInjectMaterial(TypeSelector);
804
106
 
805
107
  // src/components/json-schema-editor/index.tsx
806
- import React17, { useMemo as useMemo5, useState as useState4 } from "react";
807
- import { Button, Checkbox, IconButton as IconButton3 } from "@douyinfe/semi-ui";
108
+ import React6, { useMemo as useMemo3, useState as useState3 } from "react";
109
+ import { I18n as I18n2 } from "@flowgram.ai/editor";
110
+ import { Button, Checkbox, IconButton as IconButton2 } from "@douyinfe/semi-ui";
808
111
  import {
809
112
  IconExpand,
810
113
  IconShrink,
@@ -814,62 +117,81 @@ import {
814
117
  IconMinus
815
118
  } from "@douyinfe/semi-icons";
816
119
 
817
- // src/components/json-schema-editor/styles.tsx
818
- import React13 from "react";
819
- import styled3, { css as css2 } from "styled-components";
820
- import Icon3 from "@douyinfe/semi-icons";
821
- var UIContainer = styled3.div`
120
+ // src/components/blur-input/index.tsx
121
+ import React2, { useEffect, useState } from "react";
122
+ import Input from "@douyinfe/semi-ui/lib/es/input";
123
+ function BlurInput(props) {
124
+ const [value, setValue] = useState("");
125
+ useEffect(() => {
126
+ setValue(props.value);
127
+ }, [props.value]);
128
+ return /* @__PURE__ */ React2.createElement(
129
+ Input,
130
+ {
131
+ ...props,
132
+ value,
133
+ onChange: (value2) => {
134
+ setValue(value2);
135
+ },
136
+ onBlur: (e) => props.onChange?.(value, e)
137
+ }
138
+ );
139
+ }
140
+
141
+ // src/components/json-schema-editor/styles.tsx
142
+ import React3 from "react";
143
+ import styled, { css } from "styled-components";
144
+ import Icon2 from "@douyinfe/semi-icons";
145
+ var UIContainer = styled.div`
822
146
  /* & .semi-input {
823
147
  background-color: #fff;
824
148
  border-radius: 6px;
825
149
  height: 24px;
826
150
  } */
827
151
  `;
828
- var UIRow = styled3.div`
152
+ var UIRow = styled.div`
829
153
  display: flex;
830
154
  align-items: center;
831
155
  gap: 6px;
832
156
  `;
833
- var UICollapseTrigger = styled3.div`
157
+ var UICollapseTrigger = styled.div`
834
158
  cursor: pointer;
835
159
  margin-right: 5px;
836
160
  `;
837
- var UIExpandDetail = styled3.div`
161
+ var UIExpandDetail = styled.div`
838
162
  display: flex;
839
163
  flex-direction: column;
840
164
  `;
841
- var UILabel = styled3.div`
165
+ var UILabel = styled.div`
842
166
  font-size: 12px;
843
167
  color: #999;
844
168
  font-weight: 400;
845
169
  margin-bottom: 2px;
846
170
  `;
847
- var UIProperties = styled3.div`
171
+ var UITreeItems = styled.div`
848
172
  display: grid;
849
173
  grid-template-columns: auto 1fr;
850
174
 
851
- ${({ $shrink }) => $shrink && css2`
852
- padding-left: 10px;
175
+ ${({ $shrink }) => $shrink && css`
176
+ padding-left: 3px;
853
177
  margin-top: 10px;
854
178
  `}
855
179
  `;
856
- var UIPropertyLeft = styled3.div`
180
+ var UITreeItemLeft = styled.div`
857
181
  grid-column: 1;
858
182
  position: relative;
859
183
  width: 16px;
860
184
 
861
- ${({ $showLine, $isLast, $parentType }) => {
862
- let height = "100%";
863
- if ($parentType && $isLast) {
864
- height = "24px";
865
- }
866
- return $showLine && css2`
185
+ ${({ $showLine, $isLast, $showCollapse }) => {
186
+ let height = $isLast ? "24px" : "100%";
187
+ let width = $showCollapse ? "12px" : "30px";
188
+ return $showLine && css`
867
189
  &::before {
868
190
  /* 竖线 */
869
191
  content: '';
870
192
  height: ${height};
871
193
  position: absolute;
872
- left: -22px;
194
+ left: -14px;
873
195
  top: -16px;
874
196
  width: 1px;
875
197
  background: #d9d9d9;
@@ -880,9 +202,9 @@ var UIPropertyLeft = styled3.div`
880
202
  /* 横线 */
881
203
  content: '';
882
204
  position: absolute;
883
- left: -22px; // 横线起点和竖线对齐
205
+ left: -14px; // 横线起点和竖线对齐
884
206
  top: 8px; // 跟随你的行高调整
885
- width: 18px; // 横线长度
207
+ width: ${width}; // 横线长度
886
208
  height: 1px;
887
209
  background: #d9d9d9;
888
210
  display: block;
@@ -890,7 +212,7 @@ var UIPropertyLeft = styled3.div`
890
212
  `;
891
213
  }}
892
214
  `;
893
- var UIPropertyRight = styled3.div`
215
+ var UITreeItemRight = styled.div`
894
216
  grid-column: 2;
895
217
  margin-bottom: 10px;
896
218
 
@@ -898,52 +220,28 @@ var UIPropertyRight = styled3.div`
898
220
  margin-bottom: 0px;
899
221
  }
900
222
  `;
901
- var UIPropertyMain = styled3.div`
223
+ var UITreeItemMain = styled.div`
902
224
  display: flex;
903
225
  flex-direction: column;
904
226
  gap: 10px;
905
227
  position: relative;
906
-
907
- ${({ $expand, type, $collapse, $showCollapse }) => {
908
- const beforeElement = `
909
- &::before {
910
- /* \u7AD6\u7EBF */
911
- content: '';
912
- height: 100%;
913
- position: absolute;
914
- left: -12px;
915
- top: 18px;
916
- width: 1px;
917
- background: #d9d9d9;
918
- display: block;
919
- }`;
920
- return $expand && css2`
921
- background-color: #f5f5f5;
922
- padding: 10px;
923
- border-radius: 4px;
924
-
925
- ${$showCollapse && $collapse && (type === "array" || type === "object") && css2`
926
- ${beforeElement}
927
- `}
928
- `;
929
- }}
930
228
  `;
931
- var UICollapsible = styled3.div`
229
+ var UICollapsible = styled.div`
932
230
  display: none;
933
231
 
934
- ${({ $collapse }) => $collapse && css2`
232
+ ${({ $collapse }) => $collapse && css`
935
233
  display: block;
936
234
  `}
937
235
  `;
938
- var UIName = styled3.div`
236
+ var UIName = styled.div`
939
237
  flex-grow: 1;
940
238
  `;
941
- var UIType = styled3.div``;
942
- var UIRequired = styled3.div``;
943
- var UIActions = styled3.div`
239
+ var UIType = styled.div``;
240
+ var UIRequired = styled.div``;
241
+ var UIActions = styled.div`
944
242
  white-space: nowrap;
945
243
  `;
946
- var iconAddChildrenSvg = /* @__PURE__ */ React13.createElement(
244
+ var iconAddChildrenSvg = /* @__PURE__ */ React3.createElement(
947
245
  "svg",
948
246
  {
949
247
  className: "icon-icon icon-icon-coz_add_node ",
@@ -953,7 +251,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ React13.createElement(
953
251
  fill: "currentColor",
954
252
  xmlns: "http://www.w3.org/2000/svg"
955
253
  },
956
- /* @__PURE__ */ React13.createElement(
254
+ /* @__PURE__ */ React3.createElement(
957
255
  "path",
958
256
  {
959
257
  fillRule: "evenodd",
@@ -961,38 +259,13 @@ var iconAddChildrenSvg = /* @__PURE__ */ React13.createElement(
961
259
  d: "M11 6.49988C11 8.64148 9.50397 10.4337 7.49995 10.8884V15.4998C7.49995 16.0521 7.94767 16.4998 8.49995 16.4998H11.208C11.0742 16.8061 11 17.1443 11 17.4998C11 17.8554 11.0742 18.1936 11.208 18.4998H8.49995C6.8431 18.4998 5.49995 17.1567 5.49995 15.4998V10.8884C3.49599 10.4336 2 8.64145 2 6.49988C2 4.0146 4.01472 1.99988 6.5 1.99988C8.98528 1.99988 11 4.0146 11 6.49988ZM6.5 8.99988C7.88071 8.99988 9 7.88059 9 6.49988C9 5.11917 7.88071 3.99988 6.5 3.99988C5.11929 3.99988 4 5.11917 4 6.49988C4 7.88059 5.11929 8.99988 6.5 8.99988Z"
962
260
  }
963
261
  ),
964
- /* @__PURE__ */ React13.createElement("path", { d: "M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z" })
262
+ /* @__PURE__ */ React3.createElement("path", { d: "M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z" })
965
263
  );
966
- var IconAddChildren = () => /* @__PURE__ */ React13.createElement(Icon3, { size: "small", svg: iconAddChildrenSvg });
967
- var DefaultValueWrapper = styled3.div`
264
+ var IconAddChildren = () => /* @__PURE__ */ React3.createElement(Icon2, { size: "small", svg: iconAddChildrenSvg });
265
+ var DefaultValueWrapper = styled.div`
968
266
  margin: 0;
969
267
  `;
970
- var JSONViewerWrapper = styled3.div`
971
- padding: 0 0 24px;
972
- &:first-child {
973
- margin-top: 0px;
974
- }
975
- `;
976
- var JSONHeader = styled3.div`
977
- display: flex;
978
- justify-content: space-between;
979
- align-items: center;
980
- background-color: var(--semi-color-fill-0);
981
- border-radius: 6px 6px 0 0;
982
- height: 36px;
983
- padding: 0 8px 0 12px;
984
- `;
985
- var JSONHeaderLeft = styled3.div`
986
- display: flex;
987
- align-items: center;
988
- gap: 10px;
989
- `;
990
- var JSONHeaderRight = styled3.div`
991
- display: flex;
992
- align-items: center;
993
- gap: 10px;
994
- `;
995
- var ConstantInputWrapper = styled3.div`
268
+ var ConstantInputWrapper = styled.div`
996
269
  flex-grow: 1;
997
270
 
998
271
  & .semi-tree-select,
@@ -1003,72 +276,48 @@ var ConstantInputWrapper = styled3.div`
1003
276
  `;
1004
277
 
1005
278
  // src/components/json-schema-editor/hooks.tsx
1006
- import { useEffect as useEffect2, useMemo as useMemo3, useRef as useRef2, useState } from "react";
1007
- import { omit } from "lodash";
279
+ import { useEffect as useEffect2, useRef, useState as useState2 } from "react";
280
+ import { difference, omit } from "lodash-es";
281
+ import { produce } from "immer";
282
+ import { useTypeManager as useTypeManager2 } from "@flowgram.ai/json-schema";
1008
283
  var _id = 0;
1009
284
  function genId() {
1010
285
  return _id++;
1011
286
  }
1012
- function getDrilldownSchema(value, path) {
1013
- if (!value) {
1014
- return {};
1015
- }
1016
- if (value.type === "array" && value.items) {
1017
- return getDrilldownSchema(value.items, [...path || [], "items"]);
1018
- }
1019
- return { schema: value, path };
1020
- }
1021
287
  function usePropertiesEdit(value, onChange) {
1022
- const drilldown = useMemo3(() => getDrilldownSchema(value), [value, value?.type, value?.items]);
1023
- const isDrilldownObject = drilldown.schema?.type === "object";
1024
- const initPropertyList = useMemo3(
1025
- () => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(
1026
- ([name, _value], index) => ({
1027
- key: genId(),
1028
- name,
1029
- isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
1030
- ..._value,
1031
- extra: {
1032
- ..._value.extra || {},
1033
- index
1034
- }
1035
- })
1036
- ) : [],
1037
- [isDrilldownObject]
1038
- );
1039
- const [propertyList, setPropertyList] = useState(initPropertyList);
1040
- const mountRef = useRef2(false);
288
+ const typeManager = useTypeManager2();
289
+ const drilldownSchema = typeManager.getPropertiesParent(value || {});
290
+ const canAddField = typeManager.canAddField(value || {});
291
+ const [propertyList, setPropertyList] = useState2([]);
292
+ const effectVersion = useRef(0);
293
+ const changeVersion = useRef(0);
1041
294
  useEffect2(() => {
1042
- if (mountRef.current) {
1043
- setPropertyList((_list) => {
1044
- const nameMap = /* @__PURE__ */ new Map();
1045
- for (const _property of _list) {
1046
- if (_property.name) {
1047
- nameMap.set(_property.name, _property);
1048
- }
1049
- }
1050
- return Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([name, _value]) => {
1051
- const _property = nameMap.get(name);
1052
- if (_property) {
1053
- return {
1054
- key: _property.key,
1055
- name,
1056
- isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
1057
- ..._value
1058
- };
1059
- }
1060
- return {
1061
- key: genId(),
1062
- name,
1063
- isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
1064
- ..._value
1065
- };
1066
- });
1067
- });
295
+ effectVersion.current = effectVersion.current + 1;
296
+ if (effectVersion.current === changeVersion.current) {
297
+ return;
1068
298
  }
1069
- mountRef.current = true;
1070
- }, [drilldown.schema]);
299
+ effectVersion.current = changeVersion.current;
300
+ setPropertyList((_list) => {
301
+ const newNames = Object.entries(drilldownSchema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([key]) => key);
302
+ const oldNames = _list.map((item) => item.name).filter(Boolean);
303
+ const addNames = difference(newNames, oldNames);
304
+ return _list.filter((item) => !item.name || newNames.includes(item.name)).map((item) => ({
305
+ key: item.key,
306
+ name: item.name,
307
+ isPropertyRequired: drilldownSchema?.required?.includes(item.name || "") || false,
308
+ ...drilldownSchema?.properties?.[item.name || ""] || item || {}
309
+ })).concat(
310
+ addNames.map((_name) => ({
311
+ key: genId(),
312
+ name: _name,
313
+ isPropertyRequired: drilldownSchema?.required?.includes(_name) || false,
314
+ ...drilldownSchema?.properties?.[_name] || {}
315
+ }))
316
+ );
317
+ });
318
+ }, [drilldownSchema]);
1071
319
  const updatePropertyList = (updater) => {
320
+ changeVersion.current = changeVersion.current + 1;
1072
321
  setPropertyList((_list) => {
1073
322
  const next = updater(_list);
1074
323
  const nextProperties = {};
@@ -1082,18 +331,21 @@ function usePropertiesEdit(value, onChange) {
1082
331
  nextRequired.push(_property.name);
1083
332
  }
1084
333
  }
1085
- let drilldownSchema = value || {};
1086
- if (drilldown.path) {
1087
- drilldownSchema = drilldown.path.reduce((acc, key) => acc[key], value || {});
1088
- }
1089
- drilldownSchema.properties = nextProperties;
1090
- drilldownSchema.required = nextRequired;
1091
- onChange?.(value || {});
334
+ onChange?.(
335
+ produce(value || {}, (draft) => {
336
+ const propertiesParent = typeManager.getPropertiesParent(draft);
337
+ if (propertiesParent) {
338
+ propertiesParent.properties = nextProperties;
339
+ propertiesParent.required = nextRequired;
340
+ return;
341
+ }
342
+ })
343
+ );
1092
344
  return next;
1093
345
  });
1094
346
  };
1095
347
  const onAddProperty = () => {
1096
- updatePropertyList((_list) => [
348
+ setPropertyList((_list) => [
1097
349
  ..._list,
1098
350
  { key: genId(), name: "", type: "string", extra: { index: _list.length + 1 } }
1099
351
  ]);
@@ -1107,13 +359,13 @@ function usePropertiesEdit(value, onChange) {
1107
359
  );
1108
360
  };
1109
361
  useEffect2(() => {
1110
- if (!isDrilldownObject) {
362
+ if (!canAddField) {
1111
363
  setPropertyList([]);
1112
364
  }
1113
- }, [isDrilldownObject]);
365
+ }, [canAddField]);
1114
366
  return {
1115
367
  propertyList,
1116
- isDrilldownObject,
368
+ canAddField,
1117
369
  onAddProperty,
1118
370
  onRemoveProperty,
1119
371
  onEditProperty
@@ -1121,175 +373,66 @@ function usePropertiesEdit(value, onChange) {
1121
373
  }
1122
374
 
1123
375
  // src/components/json-schema-editor/default-value.tsx
1124
- import React15, { useRef as useRef3, useState as useState2, useCallback as useCallback2 } from "react";
1125
- import { IconButton as IconButton2, JsonViewer, Tooltip } from "@douyinfe/semi-ui";
1126
- import { IconBrackets } from "@douyinfe/semi-icons";
1127
-
1128
- // src/components/json-schema-editor/utils.ts
1129
- function getValueType(value) {
1130
- const type = typeof value;
1131
- if (type === "string") {
1132
- return "string";
1133
- } else if (type === "number") {
1134
- return Number.isInteger(value) ? "integer" : "number";
1135
- } else if (type === "boolean") {
1136
- return "boolean";
1137
- } else if (type === "object") {
1138
- if (value === null) {
1139
- return "other";
1140
- }
1141
- return Array.isArray(value) ? "array" : "object";
1142
- } else {
1143
- return "other";
1144
- }
1145
- }
376
+ import React5 from "react";
377
+ import { I18n } from "@flowgram.ai/editor";
1146
378
 
1147
379
  // src/components/constant-input/index.tsx
1148
- import React14, { useMemo as useMemo4 } from "react";
380
+ import React4, { useMemo as useMemo2 } from "react";
1149
381
  import { Input as Input2 } from "@douyinfe/semi-ui";
1150
382
  function ConstantInput(props) {
1151
383
  const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
1152
384
  const typeManager = useTypeManager();
1153
- const Renderer2 = useMemo4(() => {
385
+ const Renderer = useMemo2(() => {
1154
386
  const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
1155
387
  if (!strategy) {
1156
388
  return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
1157
389
  }
1158
390
  return strategy?.Renderer;
1159
391
  }, [strategies, schema]);
1160
- if (!Renderer2) {
392
+ if (!Renderer) {
1161
393
  if (fallbackRenderer) {
1162
- return React14.createElement(fallbackRenderer, {
394
+ return React4.createElement(fallbackRenderer, {
1163
395
  value,
1164
396
  onChange,
1165
397
  readonly,
1166
398
  ...rest
1167
399
  });
1168
400
  }
1169
- return /* @__PURE__ */ React14.createElement(Input2, { size: "small", disabled: true, placeholder: "Unsupported type" });
401
+ return /* @__PURE__ */ React4.createElement(Input2, { size: "small", disabled: true, placeholder: "Unsupported type" });
1170
402
  }
1171
- return /* @__PURE__ */ React14.createElement(Renderer2, { value, onChange, readonly, ...rest });
403
+ return /* @__PURE__ */ React4.createElement(Renderer, { value, onChange, readonly, ...rest });
1172
404
  }
1173
405
 
1174
406
  // src/components/json-schema-editor/default-value.tsx
1175
407
  function DefaultValue(props) {
1176
- const { value, schema, type, onChange, placeholder, jsonFormatText } = props;
1177
- const wrapperRef = useRef3(null);
1178
- const JsonViewerRef = useRef3(null);
1179
- const [internalJsonValue, setInternalJsonValue] = useState2(
1180
- getValueType(value) === "string" ? value : ""
1181
- );
1182
- const handleJsonChange = useCallback2((val) => {
1183
- if (val !== internalJsonValue) {
1184
- setInternalJsonValue(val);
1185
- }
1186
- }, []);
1187
- const handleEditComplete = useCallback2(() => {
1188
- onChange(internalJsonValue);
1189
- requestAnimationFrame(() => {
1190
- wrapperRef.current?.blur();
1191
- });
1192
- setJsonReadOnly(true);
1193
- }, [internalJsonValue, onChange]);
1194
- const [jsonReadOnly, setJsonReadOnly] = useState2(true);
1195
- const handleFormatJson = useCallback2(() => {
1196
- try {
1197
- const parsed = JSON.parse(internalJsonValue);
1198
- const formatted = JSON.stringify(parsed, null, 4);
1199
- setInternalJsonValue(formatted);
1200
- onChange(formatted);
1201
- } catch (error) {
1202
- console.error("Invalid JSON:", error);
1203
- }
1204
- }, [internalJsonValue, onChange]);
1205
- return type === "object" ? /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(JSONHeader, null, /* @__PURE__ */ React15.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ React15.createElement(JSONHeaderRight, null, /* @__PURE__ */ React15.createElement(Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ React15.createElement(
1206
- IconButton2,
1207
- {
1208
- icon: /* @__PURE__ */ React15.createElement(IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
1209
- size: "small",
1210
- type: "tertiary",
1211
- theme: "borderless",
1212
- onClick: handleFormatJson
1213
- }
1214
- )))), /* @__PURE__ */ React15.createElement(
1215
- JSONViewerWrapper,
1216
- {
1217
- ref: wrapperRef,
1218
- tabIndex: -1,
1219
- onBlur: (e) => {
1220
- if (wrapperRef.current && !wrapperRef.current?.contains(e.relatedTarget)) {
1221
- handleEditComplete();
1222
- }
1223
- },
1224
- onClick: (e) => {
1225
- setJsonReadOnly(false);
1226
- }
1227
- },
1228
- /* @__PURE__ */ React15.createElement(
1229
- JsonViewer,
1230
- {
1231
- ref: JsonViewerRef,
1232
- value: getValueType(value) === "string" ? value : "",
1233
- height: 120,
1234
- width: "100%",
1235
- showSearch: false,
1236
- options: {
1237
- readOnly: jsonReadOnly,
1238
- formatOptions: { tabSize: 4, insertSpaces: true, eol: "\n" }
1239
- },
1240
- style: {
1241
- padding: 0
1242
- },
1243
- onChange: handleJsonChange
1244
- }
1245
- )
1246
- )) : /* @__PURE__ */ React15.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React15.createElement(
408
+ const { value, schema, onChange, placeholder } = props;
409
+ return /* @__PURE__ */ React5.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React5.createElement(
1247
410
  ConstantInput,
1248
411
  {
1249
412
  value,
1250
413
  onChange: (_v) => onChange(_v),
1251
414
  schema: schema || { type: "string" },
1252
- placeholder: placeholder ?? "Default value if parameter is not provided"
415
+ placeholder: placeholder ?? I18n.t("Default value if parameter is not provided"),
416
+ enableMultiLineStr: true
1253
417
  }
1254
418
  ));
1255
419
  }
1256
420
 
1257
- // src/components/json-schema-editor/components/blur-input.tsx
1258
- import React16, { useEffect as useEffect3, useState as useState3 } from "react";
1259
- import Input3 from "@douyinfe/semi-ui/lib/es/input";
1260
- function BlurInput(props) {
1261
- const [value, setValue] = useState3("");
1262
- useEffect3(() => {
1263
- setValue(props.value);
1264
- }, [props.value]);
1265
- return /* @__PURE__ */ React16.createElement(
1266
- Input3,
1267
- {
1268
- ...props,
1269
- value,
1270
- onChange: (value2) => {
1271
- setValue(value2);
1272
- },
1273
- onBlur: (e) => props.onChange?.(value, e)
1274
- }
1275
- );
1276
- }
1277
-
1278
421
  // src/components/json-schema-editor/index.tsx
422
+ var DEFAULT = { type: "object" };
1279
423
  function JsonSchemaEditor(props) {
1280
- const { value = { type: "object" }, config = {}, onChange: onChangeProps, readonly } = props;
424
+ const { value = DEFAULT, config = {}, onChange: onChangeProps, readonly } = props;
1281
425
  const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
1282
426
  value,
1283
427
  onChangeProps
1284
428
  );
1285
- return /* @__PURE__ */ React17.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React17.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ React17.createElement(
429
+ return /* @__PURE__ */ React6.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React6.createElement(UITreeItems, null, propertyList.map((_property) => /* @__PURE__ */ React6.createElement(
1286
430
  PropertyEdit,
1287
431
  {
1288
432
  readonly,
1289
433
  key: _property.key,
1290
434
  value: _property,
1291
435
  config,
1292
- $index: index,
1293
436
  onChange: (_v) => {
1294
437
  onEditProperty(_property.key, _v);
1295
438
  },
@@ -1297,148 +440,110 @@ function JsonSchemaEditor(props) {
1297
440
  onRemoveProperty(_property.key);
1298
441
  }
1299
442
  }
1300
- ))), /* @__PURE__ */ React17.createElement(
443
+ ))), /* @__PURE__ */ React6.createElement(
1301
444
  Button,
1302
445
  {
1303
446
  disabled: readonly,
1304
447
  size: "small",
1305
448
  style: { marginTop: 10, marginLeft: 16 },
1306
- icon: /* @__PURE__ */ React17.createElement(IconPlus, null),
449
+ icon: /* @__PURE__ */ React6.createElement(IconPlus, null),
1307
450
  onClick: onAddProperty
1308
451
  },
1309
- config?.addButtonText ?? "Add"
452
+ config?.addButtonText ?? I18n2.t("Add")
1310
453
  ));
1311
454
  }
1312
455
  function PropertyEdit(props) {
1313
- const {
1314
- value,
1315
- config,
1316
- readonly,
1317
- $level = 0,
1318
- onChange: onChangeProps,
1319
- onRemove,
1320
- $index,
1321
- $isFirst,
1322
- $isLast,
1323
- $parentExpand = false,
1324
- $parentType = "",
1325
- $showLine
1326
- } = props;
1327
- const [expand, setExpand] = useState4(false);
1328
- const [collapse, setCollapse] = useState4(false);
456
+ const { value, config, readonly, $level = 0, onChange: onChangeProps, onRemove, $isLast } = props;
457
+ const [expand, setExpand] = useState3(false);
458
+ const [collapse, setCollapse] = useState3(false);
1329
459
  const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
1330
- const typeSelectorValue = useMemo5(() => ({ type, items }), [type, items]);
1331
- const { propertyList, isDrilldownObject, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
460
+ const typeSelectorValue = useMemo3(() => ({ type, items }), [type, items]);
461
+ const { propertyList, canAddField, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
1332
462
  const onChange = (key, _value) => {
1333
463
  onChangeProps?.({
1334
464
  ...value || {},
1335
465
  [key]: _value
1336
466
  });
1337
467
  };
1338
- const showCollapse = isDrilldownObject && propertyList.length > 0;
1339
- return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(
1340
- UIPropertyLeft,
468
+ const showCollapse = canAddField && propertyList.length > 0;
469
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(UITreeItemLeft, { $isLast, $showLine: $level > 0, $showCollapse: showCollapse }, showCollapse && /* @__PURE__ */ React6.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React6.createElement(IconChevronDown, { size: "small" }) : /* @__PURE__ */ React6.createElement(IconChevronRight, { size: "small" }))), /* @__PURE__ */ React6.createElement(UITreeItemRight, null, /* @__PURE__ */ React6.createElement(UITreeItemMain, null, /* @__PURE__ */ React6.createElement(UIRow, null, /* @__PURE__ */ React6.createElement(UIName, null, /* @__PURE__ */ React6.createElement(
470
+ BlurInput,
1341
471
  {
1342
- type,
1343
- $index,
1344
- $isFirst,
1345
- $isLast,
1346
- $showLine,
1347
- $isExpand: expand,
1348
- $parentExpand,
1349
- $parentType
1350
- },
1351
- showCollapse && /* @__PURE__ */ React17.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React17.createElement(IconChevronDown, { size: "small" }) : /* @__PURE__ */ React17.createElement(IconChevronRight, { size: "small" }))
1352
- ), /* @__PURE__ */ React17.createElement(UIPropertyRight, null, /* @__PURE__ */ React17.createElement(
1353
- UIPropertyMain,
472
+ disabled: readonly,
473
+ placeholder: config?.placeholder ?? I18n2.t("Input Variable Name"),
474
+ size: "small",
475
+ value: name,
476
+ onChange: (value2) => onChange("name", value2)
477
+ }
478
+ )), /* @__PURE__ */ React6.createElement(UIType, null, /* @__PURE__ */ React6.createElement(
479
+ InjectTypeSelector,
1354
480
  {
1355
- $showCollapse: showCollapse,
1356
- $collapse: collapse,
1357
- $expand: expand,
1358
- type
1359
- },
1360
- /* @__PURE__ */ React17.createElement(UIRow, null, /* @__PURE__ */ React17.createElement(UIName, null, /* @__PURE__ */ React17.createElement(
1361
- BlurInput,
1362
- {
1363
- disabled: readonly,
1364
- placeholder: config?.placeholder ?? "Input Variable Name",
1365
- size: "small",
1366
- value: name,
1367
- onChange: (value2) => onChange("name", value2)
1368
- }
1369
- )), /* @__PURE__ */ React17.createElement(UIType, null, /* @__PURE__ */ React17.createElement(
1370
- TypeSelector,
1371
- {
1372
- value: typeSelectorValue,
1373
- readonly,
1374
- onChange: (_value) => {
1375
- onChangeProps?.({
1376
- ...value || {},
1377
- ..._value
1378
- });
1379
- }
1380
- }
1381
- )), /* @__PURE__ */ React17.createElement(UIRequired, null, /* @__PURE__ */ React17.createElement(
1382
- Checkbox,
1383
- {
1384
- disabled: readonly,
1385
- checked: isPropertyRequired,
1386
- onChange: (e) => onChange("isPropertyRequired", e.target.checked)
1387
- }
1388
- )), /* @__PURE__ */ React17.createElement(UIActions, null, /* @__PURE__ */ React17.createElement(
1389
- IconButton3,
1390
- {
1391
- disabled: readonly,
1392
- size: "small",
1393
- theme: "borderless",
1394
- icon: expand ? /* @__PURE__ */ React17.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React17.createElement(IconExpand, { size: "small" }),
1395
- onClick: () => {
1396
- setExpand((_expand) => !_expand);
1397
- }
1398
- }
1399
- ), isDrilldownObject && /* @__PURE__ */ React17.createElement(
1400
- IconButton3,
1401
- {
1402
- disabled: readonly,
1403
- size: "small",
1404
- theme: "borderless",
1405
- icon: /* @__PURE__ */ React17.createElement(IconAddChildren, null),
1406
- onClick: () => {
1407
- onAddProperty();
1408
- setCollapse(true);
1409
- }
1410
- }
1411
- ), /* @__PURE__ */ React17.createElement(
1412
- IconButton3,
1413
- {
1414
- disabled: readonly,
1415
- size: "small",
1416
- theme: "borderless",
1417
- icon: /* @__PURE__ */ React17.createElement(IconMinus, { size: "small" }),
1418
- onClick: onRemove
481
+ value: typeSelectorValue,
482
+ readonly,
483
+ onChange: (_value) => {
484
+ onChangeProps?.({
485
+ ...value || {},
486
+ ..._value
487
+ });
1419
488
  }
1420
- ))),
1421
- expand && /* @__PURE__ */ React17.createElement(UIExpandDetail, null, /* @__PURE__ */ React17.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ React17.createElement(
1422
- BlurInput,
1423
- {
1424
- disabled: readonly,
1425
- size: "small",
1426
- value: description,
1427
- onChange: (value2) => onChange("description", value2),
1428
- placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
489
+ }
490
+ )), /* @__PURE__ */ React6.createElement(UIRequired, null, /* @__PURE__ */ React6.createElement(
491
+ Checkbox,
492
+ {
493
+ disabled: readonly,
494
+ checked: isPropertyRequired,
495
+ onChange: (e) => onChange("isPropertyRequired", e.target.checked)
496
+ }
497
+ )), /* @__PURE__ */ React6.createElement(UIActions, null, /* @__PURE__ */ React6.createElement(
498
+ IconButton2,
499
+ {
500
+ disabled: readonly,
501
+ size: "small",
502
+ theme: "borderless",
503
+ icon: expand ? /* @__PURE__ */ React6.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React6.createElement(IconExpand, { size: "small" }),
504
+ onClick: () => {
505
+ setExpand((_expand) => !_expand);
1429
506
  }
1430
- ), $level === 0 && type && type !== "array" && /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? "Default Value"), /* @__PURE__ */ React17.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React17.createElement(
1431
- DefaultValue,
1432
- {
1433
- value: defaultValue,
1434
- schema: value,
1435
- type,
1436
- placeholder: config?.defaultValuePlaceholder,
1437
- jsonFormatText: config?.jsonFormatText,
1438
- onChange: (value2) => onChange("default", value2)
507
+ }
508
+ ), canAddField && /* @__PURE__ */ React6.createElement(
509
+ IconButton2,
510
+ {
511
+ disabled: readonly,
512
+ size: "small",
513
+ theme: "borderless",
514
+ icon: /* @__PURE__ */ React6.createElement(IconAddChildren, null),
515
+ onClick: () => {
516
+ onAddProperty();
517
+ setCollapse(true);
1439
518
  }
1440
- ))))
1441
- ), showCollapse && /* @__PURE__ */ React17.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React17.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React17.createElement(
519
+ }
520
+ ), /* @__PURE__ */ React6.createElement(
521
+ IconButton2,
522
+ {
523
+ disabled: readonly,
524
+ size: "small",
525
+ theme: "borderless",
526
+ icon: /* @__PURE__ */ React6.createElement(IconMinus, { size: "small" }),
527
+ onClick: onRemove
528
+ }
529
+ ))), expand && /* @__PURE__ */ React6.createElement(UIExpandDetail, null, /* @__PURE__ */ React6.createElement(UILabel, null, config?.descTitle ?? I18n2.t("Description")), /* @__PURE__ */ React6.createElement(
530
+ BlurInput,
531
+ {
532
+ disabled: readonly,
533
+ size: "small",
534
+ value: description,
535
+ onChange: (value2) => onChange("description", value2),
536
+ placeholder: config?.descPlaceholder ?? I18n2.t("Help LLM to understand the property")
537
+ }
538
+ ), $level === 0 && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? I18n2.t("Default Value")), /* @__PURE__ */ React6.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React6.createElement(
539
+ DefaultValue,
540
+ {
541
+ value: defaultValue,
542
+ schema: value,
543
+ placeholder: config?.defaultValuePlaceholder ?? I18n2.t("Default Value"),
544
+ onChange: (value2) => onChange("default", value2)
545
+ }
546
+ ))))), showCollapse && /* @__PURE__ */ React6.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React6.createElement(UITreeItems, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React6.createElement(
1442
547
  PropertyEdit,
1443
548
  {
1444
549
  readonly,
@@ -1446,42 +551,40 @@ function PropertyEdit(props) {
1446
551
  value: _property,
1447
552
  config,
1448
553
  $level: $level + 1,
1449
- $parentExpand: expand,
1450
- $parentType: type,
1451
554
  onChange: (_v) => {
1452
555
  onEditProperty(_property.key, _v);
1453
556
  },
1454
557
  onRemove: () => {
1455
558
  onRemoveProperty(_property.key);
1456
559
  },
1457
- $isLast: index === propertyList.length - 1,
1458
- $isFirst: index === 0,
1459
- $index: index,
1460
- $showLine: true
560
+ $isLast: index === propertyList.length - 1
1461
561
  }
1462
562
  ))))));
1463
563
  }
1464
564
 
1465
565
  // src/components/batch-variable-selector/index.tsx
1466
- import React18 from "react";
566
+ import React7 from "react";
1467
567
  import { PrivateScopeProvider } from "@flowgram.ai/editor";
1468
568
  var batchVariableSchema = {
1469
569
  type: "array",
1470
570
  extra: { weak: true }
1471
571
  };
1472
572
  function BatchVariableSelector(props) {
1473
- return /* @__PURE__ */ React18.createElement(PrivateScopeProvider, null, /* @__PURE__ */ React18.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
573
+ return /* @__PURE__ */ React7.createElement(PrivateScopeProvider, null, /* @__PURE__ */ React7.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
1474
574
  }
1475
575
 
1476
576
  // src/components/dynamic-value-input/index.tsx
1477
- import React19 from "react";
1478
- import { JsonSchemaUtils as JsonSchemaUtils3 } from "@flowgram.ai/json-schema";
1479
- import { IconButton as IconButton4 } from "@douyinfe/semi-ui";
577
+ import React8 from "react";
578
+ import {
579
+ JsonSchemaUtils as JsonSchemaUtils2,
580
+ useTypeManager as useTypeManager3
581
+ } from "@flowgram.ai/json-schema";
582
+ import { IconButton as IconButton3 } from "@douyinfe/semi-ui";
1480
583
  import { IconSetting } from "@douyinfe/semi-icons";
1481
584
 
1482
585
  // src/components/dynamic-value-input/styles.tsx
1483
- import styled4 from "styled-components";
1484
- var UIContainer2 = styled4.div`
586
+ import styled2 from "styled-components";
587
+ var UIContainer2 = styled2.div`
1485
588
  display: flex;
1486
589
  align-items: center;
1487
590
  border-radius: 4px;
@@ -1491,10 +594,12 @@ var UIContainer2 = styled4.div`
1491
594
 
1492
595
  background-color: var(--semi-color-fill-0);
1493
596
  `;
1494
- var UIMain = styled4.div`
597
+ var UIMain = styled2.div`
1495
598
  flex-grow: 1;
1496
599
  overflow: hidden;
1497
600
  min-width: 0;
601
+ border-left: 1px solid var(--semi-color-border);
602
+ border-right: 1px solid var(--semi-color-border);
1498
603
 
1499
604
  & .semi-tree-select,
1500
605
  & .semi-input-number,
@@ -1508,28 +613,36 @@ var UIMain = styled4.div`
1508
613
  border: none;
1509
614
  border-radius: 0;
1510
615
  }
1511
- `;
1512
- var UIType2 = styled4.div`
1513
- border-right: 1px solid #e5e5e5;
1514
616
 
617
+ & .semi-input-textarea-wrapper {
618
+ border: none;
619
+ border-radius: 0;
620
+ }
621
+
622
+ & .semi-input-textarea {
623
+ padding: 2px 6px;
624
+ border: none;
625
+ border-radius: 0;
626
+ word-break: break-all;
627
+ }
628
+ `;
629
+ var UIType2 = styled2.div`
1515
630
  & .semi-button {
1516
631
  border-radius: 0;
1517
632
  }
1518
633
  `;
1519
- var UITrigger = styled4.div`
1520
- border-left: 1px solid #e5e5e5;
1521
-
634
+ var UITrigger = styled2.div`
1522
635
  & .semi-button {
1523
636
  border-radius: 0;
1524
637
  }
1525
638
  `;
1526
639
 
1527
640
  // src/components/dynamic-value-input/hooks.ts
1528
- import { useMemo as useMemo6, useState as useState5 } from "react";
641
+ import { useEffect as useEffect3, useMemo as useMemo4, useRef as useRef2, useState as useState4 } from "react";
1529
642
  import { useScopeAvailable } from "@flowgram.ai/editor";
1530
643
  function useRefVariable(value) {
1531
644
  const available = useScopeAvailable();
1532
- const refVariable = useMemo6(() => {
645
+ const refVariable = useMemo4(() => {
1533
646
  if (value?.type === "ref") {
1534
647
  return available.getByKeyPath(value.content);
1535
648
  }
@@ -1541,23 +654,45 @@ function useSelectSchema(schemaFromProps, constantProps, value) {
1541
654
  if (value?.type === "constant") {
1542
655
  defaultSelectSchema = value?.schema || defaultSelectSchema;
1543
656
  }
1544
- const [selectSchema, setSelectSchema] = useState5(defaultSelectSchema);
1545
- return [selectSchema, setSelectSchema];
657
+ const changeVersion = useRef2(0);
658
+ const effectVersion = useRef2(0);
659
+ const [selectSchema, setSelectSchema] = useState4(defaultSelectSchema);
660
+ useEffect3(() => {
661
+ effectVersion.current += 1;
662
+ if (changeVersion.current === effectVersion.current) {
663
+ return;
664
+ }
665
+ effectVersion.current = changeVersion.current;
666
+ if (value?.type === "constant" && value?.schema) {
667
+ setSelectSchema(value?.schema);
668
+ return;
669
+ }
670
+ }, [value]);
671
+ const setSelectSchemaWithVersionUpdate = (schema) => {
672
+ setSelectSchema(schema);
673
+ changeVersion.current += 1;
674
+ };
675
+ return [selectSchema, setSelectSchemaWithVersionUpdate];
1546
676
  }
1547
677
  function useIncludeSchema(schemaFromProps) {
1548
- const includeSchema = useMemo6(() => {
678
+ const includeSchema = useMemo4(() => {
1549
679
  if (!schemaFromProps) {
1550
680
  return;
1551
681
  }
1552
682
  if (schemaFromProps?.type === "number") {
1553
683
  return [schemaFromProps, { type: "integer" }];
1554
684
  }
1555
- return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
685
+ return { ...schemaFromProps, extra: { weak: true, ...schemaFromProps?.extra } };
1556
686
  }, [schemaFromProps]);
1557
687
  return includeSchema;
1558
688
  }
1559
689
 
1560
690
  // src/components/dynamic-value-input/index.tsx
691
+ var DEFAULT_VALUE = {
692
+ type: "constant",
693
+ content: "",
694
+ schema: { type: "string" }
695
+ };
1561
696
  function DynamicValueInput({
1562
697
  value,
1563
698
  onChange,
@@ -1569,34 +704,33 @@ function DynamicValueInput({
1569
704
  const refVariable = useRefVariable(value);
1570
705
  const [selectSchema, setSelectSchema] = useSelectSchema(schemaFromProps, constantProps, value);
1571
706
  const includeSchema = useIncludeSchema(schemaFromProps);
707
+ const typeManager = useTypeManager3();
1572
708
  const renderTypeSelector = () => {
1573
709
  if (schemaFromProps) {
1574
- return /* @__PURE__ */ React19.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
710
+ return /* @__PURE__ */ React8.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
1575
711
  }
1576
712
  if (value?.type === "ref") {
1577
- const schema = refVariable?.type ? JsonSchemaUtils3.astToSchema(refVariable?.type) : void 0;
1578
- return /* @__PURE__ */ React19.createElement(TypeSelector, { value: schema, readonly: true });
713
+ const schema = refVariable?.type ? JsonSchemaUtils2.astToSchema(refVariable?.type) : void 0;
714
+ return /* @__PURE__ */ React8.createElement(TypeSelector, { value: schema, readonly: true });
1579
715
  }
1580
- return /* @__PURE__ */ React19.createElement(
716
+ return /* @__PURE__ */ React8.createElement(
1581
717
  TypeSelector,
1582
718
  {
1583
719
  value: selectSchema,
1584
720
  onChange: (_v) => {
1585
721
  setSelectSchema(_v || { type: "string" });
1586
- let content;
722
+ const schema = _v || { type: "string" };
723
+ let content = typeManager.getDefaultValue(schema);
1587
724
  if (_v?.type === "object") {
1588
725
  content = "{}";
1589
726
  }
1590
727
  if (_v?.type === "array") {
1591
728
  content = "[]";
1592
729
  }
1593
- if (_v?.type === "boolean") {
1594
- content = false;
1595
- }
1596
730
  onChange({
1597
731
  type: "constant",
1598
732
  content,
1599
- schema: _v || { type: "string" }
733
+ schema
1600
734
  });
1601
735
  },
1602
736
  readonly
@@ -1605,72 +739,75 @@ function DynamicValueInput({
1605
739
  };
1606
740
  const renderMain = () => {
1607
741
  if (value?.type === "ref") {
1608
- return /* @__PURE__ */ React19.createElement(
1609
- VariableSelector,
742
+ return /* @__PURE__ */ React8.createElement(
743
+ InjectVariableSelector,
1610
744
  {
1611
745
  style: { width: "100%" },
1612
746
  value: value?.content,
1613
- onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
747
+ onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : DEFAULT_VALUE),
1614
748
  includeSchema,
1615
749
  readonly
1616
750
  }
1617
751
  );
1618
752
  }
1619
753
  const constantSchema = schemaFromProps || selectSchema || { type: "string" };
1620
- return /* @__PURE__ */ React19.createElement(
754
+ return /* @__PURE__ */ React8.createElement(
1621
755
  ConstantInput,
1622
756
  {
1623
757
  value: value?.content,
1624
758
  onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema }),
1625
759
  schema: constantSchema || { type: "string" },
1626
760
  readonly,
1627
- strategies: [...constantProps?.strategies || []],
1628
- fallbackRenderer: () => /* @__PURE__ */ React19.createElement(
1629
- VariableSelector,
761
+ fallbackRenderer: () => /* @__PURE__ */ React8.createElement(
762
+ InjectVariableSelector,
1630
763
  {
1631
764
  style: { width: "100%" },
1632
- onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
765
+ onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : DEFAULT_VALUE),
1633
766
  includeSchema,
1634
767
  readonly
1635
768
  }
1636
769
  ),
1637
- ...constantProps
770
+ ...constantProps,
771
+ strategies: [...constantProps?.strategies || []]
1638
772
  }
1639
773
  );
1640
774
  };
1641
- const renderTrigger = () => /* @__PURE__ */ React19.createElement(
1642
- VariableSelector,
775
+ const renderTrigger = () => /* @__PURE__ */ React8.createElement(
776
+ InjectVariableSelector,
1643
777
  {
1644
778
  style: { width: "100%" },
1645
779
  value: value?.type === "ref" ? value?.content : void 0,
1646
780
  onChange: (_v) => onChange({ type: "ref", content: _v }),
1647
781
  includeSchema,
1648
782
  readonly,
1649
- triggerRender: () => /* @__PURE__ */ React19.createElement(IconButton4, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React19.createElement(IconSetting, { size: "small" }) })
783
+ triggerRender: () => /* @__PURE__ */ React8.createElement(IconButton3, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React8.createElement(IconSetting, { size: "small" }) })
1650
784
  }
1651
785
  );
1652
- return /* @__PURE__ */ React19.createElement(UIContainer2, { style }, /* @__PURE__ */ React19.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ React19.createElement(UIMain, null, renderMain()), /* @__PURE__ */ React19.createElement(UITrigger, null, renderTrigger()));
786
+ return /* @__PURE__ */ React8.createElement(UIContainer2, { style }, /* @__PURE__ */ React8.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ React8.createElement(UIMain, null, renderMain()), /* @__PURE__ */ React8.createElement(UITrigger, null, renderTrigger()));
1653
787
  }
788
+ DynamicValueInput.renderKey = "dynamic-value-input-render-key";
789
+ var InjectDynamicValueInput = createInjectMaterial(DynamicValueInput);
1654
790
 
1655
791
  // src/components/condition-row/index.tsx
1656
- import React21, { useMemo as useMemo9 } from "react";
1657
- import { Input as Input4 } from "@douyinfe/semi-ui";
792
+ import React10, { useMemo as useMemo7 } from "react";
793
+ import { I18n as I18n4 } from "@flowgram.ai/editor";
794
+ import { Input as Input3 } from "@douyinfe/semi-ui";
1658
795
 
1659
796
  // src/components/condition-row/styles.tsx
1660
- import styled5 from "styled-components";
1661
- var UIContainer3 = styled5.div`
797
+ import styled3 from "styled-components";
798
+ var UIContainer3 = styled3.div`
1662
799
  display: flex;
1663
800
  align-items: center;
1664
801
  gap: 4px;
1665
802
  `;
1666
- var UIOperator = styled5.div``;
1667
- var UILeft = styled5.div`
803
+ var UIOperator = styled3.div``;
804
+ var UILeft = styled3.div`
1668
805
  width: 100%;
1669
806
  `;
1670
- var UIRight = styled5.div`
807
+ var UIRight = styled3.div`
1671
808
  width: 100%;
1672
809
  `;
1673
- var UIValues = styled5.div`
810
+ var UIValues = styled3.div`
1674
811
  flex-grow: 1;
1675
812
  display: flex;
1676
813
  flex-direction: column;
@@ -1679,12 +816,12 @@ var UIValues = styled5.div`
1679
816
  `;
1680
817
 
1681
818
  // src/components/condition-row/hooks/useRule.ts
1682
- import { useMemo as useMemo7 } from "react";
1683
- import { JsonSchemaUtils as JsonSchemaUtils4 } from "@flowgram.ai/json-schema";
819
+ import { useMemo as useMemo5 } from "react";
820
+ import { JsonSchemaUtils as JsonSchemaUtils3 } from "@flowgram.ai/json-schema";
1684
821
  import { useScopeAvailable as useScopeAvailable2 } from "@flowgram.ai/editor";
1685
822
 
1686
823
  // src/components/condition-row/constants.ts
1687
- var rules = {
824
+ var defaultRules = {
1688
825
  string: {
1689
826
  ["eq" /* EQ */]: "string",
1690
827
  ["neq" /* NEQ */]: "string",
@@ -1738,9 +875,17 @@ var rules = {
1738
875
  map: {
1739
876
  ["is_empty" /* IS_EMPTY */]: null,
1740
877
  ["is_not_empty" /* IS_NOT_EMPTY */]: null
878
+ },
879
+ ["date-time"]: {
880
+ ["eq" /* EQ */]: "date-time",
881
+ ["neq" /* NEQ */]: "date-time",
882
+ ["gt" /* GT */]: "date-time",
883
+ ["gte" /* GTE */]: "date-time",
884
+ ["lt" /* LT */]: "date-time",
885
+ ["lte" /* LTE */]: "date-time"
1741
886
  }
1742
887
  };
1743
- var opConfigs = {
888
+ var defaultOpConfigs = {
1744
889
  ["eq" /* EQ */]: {
1745
890
  label: "Equal",
1746
891
  abbreviation: "="
@@ -1804,35 +949,39 @@ var opConfigs = {
1804
949
  };
1805
950
 
1806
951
  // src/components/condition-row/hooks/useRule.ts
1807
- function useRule(left) {
952
+ function useRule(left, userRules) {
1808
953
  const available = useScopeAvailable2();
1809
- const variable = useMemo7(() => {
954
+ const rules = useMemo5(() => ({ ...defaultRules, ...userRules || {} }), [userRules]);
955
+ const variable = useMemo5(() => {
1810
956
  if (!left) return void 0;
1811
957
  return available.getByKeyPath(left.content);
1812
958
  }, [available, left]);
1813
- const rule = useMemo7(() => {
959
+ const rule = useMemo5(() => {
1814
960
  if (!variable) return void 0;
1815
- const schema = JsonSchemaUtils4.astToSchema(variable.type, { drilldown: false });
961
+ const schema = JsonSchemaUtils3.astToSchema(variable.type, { drilldown: false });
1816
962
  return rules[schema?.type];
1817
- }, [variable?.type]);
963
+ }, [variable?.type, rules]);
1818
964
  return { rule };
1819
965
  }
1820
966
 
1821
967
  // src/components/condition-row/hooks/useOp.tsx
1822
- import React20, { useMemo as useMemo8 } from "react";
1823
- import { Button as Button2, Select as Select2 } from "@douyinfe/semi-ui";
1824
- import { IconChevronDownStroked as IconChevronDownStroked2 } from "@douyinfe/semi-icons";
1825
- function useOp({ rule, op, onChange, readonly }) {
1826
- const options = useMemo8(
968
+ import React9, { useMemo as useMemo6 } from "react";
969
+ import { I18n as I18n3 } from "@flowgram.ai/editor";
970
+ import { Button as Button2, Select } from "@douyinfe/semi-ui";
971
+ import { IconChevronDownStroked } from "@douyinfe/semi-icons";
972
+ function useOp({ rule, op, onChange, readonly, userOps }) {
973
+ const options = useMemo6(
1827
974
  () => Object.keys(rule || {}).map((_op) => ({
1828
- ...opConfigs[_op] || {},
1829
- value: _op
975
+ ...defaultOpConfigs[_op] || {},
976
+ ...userOps?.[_op] || {},
977
+ value: _op,
978
+ label: I18n3.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
1830
979
  })),
1831
- [rule]
980
+ [rule, userOps]
1832
981
  );
1833
- const opConfig = useMemo8(() => opConfigs[op], [op]);
1834
- const renderOpSelect = () => /* @__PURE__ */ React20.createElement(
1835
- Select2,
982
+ const opConfig = useMemo6(() => defaultOpConfigs[op], [op]);
983
+ const renderOpSelect = () => /* @__PURE__ */ React9.createElement(
984
+ Select,
1836
985
  {
1837
986
  style: { height: 22 },
1838
987
  disabled: readonly,
@@ -1842,28 +991,39 @@ function useOp({ rule, op, onChange, readonly }) {
1842
991
  onChange: (v) => {
1843
992
  onChange(v);
1844
993
  },
1845
- triggerRender: ({ value }) => /* @__PURE__ */ React20.createElement(Button2, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React20.createElement(IconChevronDownStroked2, { size: "small" }))
994
+ triggerRender: ({ value }) => /* @__PURE__ */ React9.createElement(Button2, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React9.createElement(IconChevronDownStroked, { size: "small" }))
1846
995
  }
1847
996
  );
1848
997
  return { renderOpSelect, opConfig };
1849
998
  }
1850
999
 
1851
1000
  // src/components/condition-row/index.tsx
1852
- function ConditionRow({ style, value, onChange, readonly }) {
1001
+ var defaultRuleConfig = {
1002
+ ops: {},
1003
+ rules: {}
1004
+ };
1005
+ function ConditionRow({
1006
+ style,
1007
+ value,
1008
+ onChange,
1009
+ readonly,
1010
+ ruleConfig = defaultRuleConfig
1011
+ }) {
1853
1012
  const { left, operator, right } = value || {};
1854
- const { rule } = useRule(left);
1013
+ const { rule } = useRule(left, ruleConfig.rules);
1855
1014
  const { renderOpSelect, opConfig } = useOp({
1856
1015
  rule,
1857
1016
  op: operator,
1858
1017
  onChange: (v) => onChange({ ...value, operator: v }),
1859
- readonly
1018
+ readonly,
1019
+ userOps: ruleConfig.ops
1860
1020
  });
1861
- const targetSchema = useMemo9(() => {
1862
- const targetType = rule?.[operator] || null;
1021
+ const targetSchema = useMemo7(() => {
1022
+ const targetType = rule?.[operator || ""] || null;
1863
1023
  return targetType ? { type: targetType, extra: { weak: true } } : null;
1864
1024
  }, [rule, opConfig]);
1865
- return /* @__PURE__ */ React21.createElement(UIContainer3, { style }, /* @__PURE__ */ React21.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ React21.createElement(UIValues, null, /* @__PURE__ */ React21.createElement(UILeft, null, /* @__PURE__ */ React21.createElement(
1866
- VariableSelector,
1025
+ return /* @__PURE__ */ React10.createElement(UIContainer3, { style }, /* @__PURE__ */ React10.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ React10.createElement(UIValues, null, /* @__PURE__ */ React10.createElement(UILeft, null, /* @__PURE__ */ React10.createElement(
1026
+ InjectVariableSelector,
1867
1027
  {
1868
1028
  readonly,
1869
1029
  style: { width: "100%" },
@@ -1876,1022 +1036,385 @@ function ConditionRow({ style, value, onChange, readonly }) {
1876
1036
  }
1877
1037
  })
1878
1038
  }
1879
- )), /* @__PURE__ */ React21.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ React21.createElement(
1880
- DynamicValueInput,
1039
+ )), /* @__PURE__ */ React10.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ React10.createElement(
1040
+ InjectDynamicValueInput,
1881
1041
  {
1882
1042
  readonly: readonly || !rule,
1883
1043
  value: right,
1884
1044
  schema: targetSchema,
1885
1045
  onChange: (v) => onChange({ ...value, right: v })
1886
1046
  }
1887
- ) : /* @__PURE__ */ React21.createElement(
1888
- Input4,
1047
+ ) : /* @__PURE__ */ React10.createElement(
1048
+ Input3,
1889
1049
  {
1890
1050
  size: "small",
1891
1051
  disabled: true,
1892
1052
  style: { pointerEvents: "none" },
1893
- value: opConfig?.rightDisplay || "Empty"
1053
+ value: opConfig?.rightDisplay || I18n4.t("Empty")
1894
1054
  }
1895
1055
  ))));
1896
1056
  }
1057
+ ConditionRow.defaultRules = defaultRules;
1058
+ ConditionRow.defaultOpConfigs = defaultOpConfigs;
1897
1059
 
1898
- // src/components/batch-outputs/index.tsx
1899
- import React22 from "react";
1900
- import { Button as Button3, Input as Input5 } from "@douyinfe/semi-ui";
1901
- import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
1060
+ // src/components/db-condition-row/index.tsx
1061
+ import React13, { useMemo as useMemo10 } from "react";
1062
+ import { I18n as I18n6 } from "@flowgram.ai/editor";
1063
+ import { Input as Input4 } from "@douyinfe/semi-ui";
1902
1064
 
1903
- // src/hooks/use-object-list/index.tsx
1904
- import { useEffect as useEffect4, useState as useState6 } from "react";
1905
- import { nanoid } from "nanoid";
1906
- import { difference, get, isObject, set } from "lodash";
1907
- function genId2() {
1908
- return nanoid();
1065
+ // src/components/db-condition-row/styles.tsx
1066
+ import styled4 from "styled-components";
1067
+ import { Select as Select2 } from "@douyinfe/semi-ui";
1068
+ var UIContainer4 = styled4.div`
1069
+ display: flex;
1070
+ align-items: center;
1071
+ gap: 4px;
1072
+ `;
1073
+ var UIOperator2 = styled4.div``;
1074
+ var UILeft2 = styled4.div`
1075
+ width: 100%;
1076
+ `;
1077
+ var UIRight2 = styled4.div`
1078
+ width: 100%;
1079
+ `;
1080
+ var UIValues2 = styled4.div`
1081
+ flex-grow: 1;
1082
+ display: flex;
1083
+ flex-direction: column;
1084
+ align-items: center;
1085
+ gap: 4px;
1086
+ `;
1087
+ var UIOptionLabel = styled4.div`
1088
+ display: flex;
1089
+ align-items: center;
1090
+ gap: 10px;
1091
+ `;
1092
+ var UISelect = styled4(Select2)`
1093
+ & .semi-select-selection {
1094
+ margin-left: 5px;
1095
+ }
1096
+ `;
1097
+
1098
+ // src/components/db-condition-row/hooks/use-op.tsx
1099
+ import React11, { useMemo as useMemo8 } from "react";
1100
+ import { I18n as I18n5 } from "@flowgram.ai/editor";
1101
+ import { Button as Button3, Select as Select3 } from "@douyinfe/semi-ui";
1102
+ import { IconChevronDownStroked as IconChevronDownStroked2 } from "@douyinfe/semi-icons";
1103
+ var defaultOpConfigs2 = ConditionRow.defaultOpConfigs;
1104
+ function useOp2({ rule, op, onChange, readonly, userOps }) {
1105
+ const options = useMemo8(
1106
+ () => Object.keys(rule || {}).map((_op) => ({
1107
+ ...defaultOpConfigs2[_op] || {},
1108
+ ...userOps?.[_op] || {},
1109
+ value: _op,
1110
+ label: I18n5.t(userOps?.[_op]?.label || defaultOpConfigs2[_op]?.label)
1111
+ })),
1112
+ [rule, userOps]
1113
+ );
1114
+ const opConfig = useMemo8(() => defaultOpConfigs2[op], [op]);
1115
+ const renderOpSelect = () => /* @__PURE__ */ React11.createElement(
1116
+ Select3,
1117
+ {
1118
+ style: { height: 22 },
1119
+ disabled: readonly,
1120
+ size: "small",
1121
+ value: op,
1122
+ optionList: options,
1123
+ onChange: (v) => {
1124
+ onChange(v);
1125
+ },
1126
+ triggerRender: ({ value }) => /* @__PURE__ */ React11.createElement(Button3, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React11.createElement(IconChevronDownStroked2, { size: "small" }))
1127
+ }
1128
+ );
1129
+ return { renderOpSelect, opConfig };
1909
1130
  }
1910
- function useObjectList({
1911
- value,
1912
- onChange,
1913
- sortIndexKey
1914
- }) {
1915
- const [list, setList] = useState6([]);
1916
- useEffect4(() => {
1917
- setList((_prevList) => {
1918
- const newKeys = Object.entries(value || {}).sort((a, b) => get(a[1], sortIndexKey || 0) - get(b[1], sortIndexKey || 0)).map(([key]) => key);
1919
- const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
1920
- const addKeys = difference(newKeys, oldKeys);
1921
- return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
1922
- id: item.id,
1923
- key: item.key,
1924
- value: item.key ? value?.[item.key] : item.value
1925
- })).concat(
1926
- addKeys.map((_key) => ({
1927
- id: genId2(),
1928
- key: _key,
1929
- value: value?.[_key]
1930
- }))
1931
- );
1932
- });
1933
- }, [value]);
1934
- const add = () => {
1935
- setList((prevList) => [
1936
- ...prevList,
1937
- {
1938
- id: genId2()
1939
- }
1940
- ]);
1941
- };
1942
- const updateValue = (itemId, value2) => {
1943
- setList((prevList) => {
1944
- const nextList = prevList.map((_item) => {
1945
- if (_item.id === itemId) {
1946
- return {
1947
- ..._item,
1948
- value: value2
1949
- };
1950
- }
1951
- return _item;
1952
- });
1953
- onChange(
1954
- Object.fromEntries(
1955
- nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
1956
- if (isObject(_res[1]) && sortIndexKey) {
1957
- set(_res[1], sortIndexKey, idx);
1958
- }
1959
- return _res;
1960
- })
1961
- )
1962
- );
1963
- return nextList;
1964
- });
1965
- };
1966
- const updateKey = (itemId, key) => {
1967
- setList((prevList) => {
1968
- const nextList = prevList.map((_item) => {
1969
- if (_item.id === itemId) {
1970
- return {
1971
- ..._item,
1972
- key
1973
- };
1974
- }
1975
- return _item;
1976
- });
1977
- onChange(
1978
- Object.fromEntries(
1979
- nextList.filter((item) => item.key).map((item) => [item.key, item.value])
1980
- )
1981
- );
1982
- return nextList;
1983
- });
1984
- };
1985
- const remove = (itemId) => {
1986
- setList((prevList) => {
1987
- const nextList = prevList.filter((_item) => _item.id !== itemId);
1988
- onChange(
1989
- Object.fromEntries(
1990
- nextList.filter((item) => item.key).map((item) => [item.key, item.value])
1991
- )
1992
- );
1993
- return nextList;
1994
- });
1995
- };
1996
- return { list, add, updateKey, updateValue, remove };
1997
- }
1998
-
1999
- // src/components/batch-outputs/styles.tsx
2000
- import styled6 from "styled-components";
2001
- var UIRows = styled6.div`
2002
- display: flex;
2003
- flex-direction: column;
2004
- gap: 10px;
2005
- margin-bottom: 10px;
2006
- `;
2007
- var UIRow2 = styled6.div`
2008
- display: flex;
2009
- align-items: center;
2010
- gap: 5px;
2011
- `;
2012
1131
 
2013
- // src/components/batch-outputs/index.tsx
2014
- function BatchOutputs(props) {
2015
- const { readonly, style } = props;
2016
- const { list, add, updateKey, updateValue, remove } = useObjectList(props);
2017
- return /* @__PURE__ */ React22.createElement("div", null, /* @__PURE__ */ React22.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ React22.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ React22.createElement(
2018
- Input5,
2019
- {
2020
- style: { width: 100 },
2021
- disabled: readonly,
2022
- size: "small",
2023
- value: item.key,
2024
- onChange: (v) => updateKey(item.id, v)
2025
- }
2026
- ), /* @__PURE__ */ React22.createElement(
2027
- VariableSelector,
2028
- {
2029
- style: { flexGrow: 1 },
2030
- readonly,
2031
- value: item.value?.content,
2032
- onChange: (v) => updateValue(item.id, { type: "ref", content: v })
1132
+ // src/components/db-condition-row/hooks/use-left.tsx
1133
+ import { useMemo as useMemo9 } from "react";
1134
+ import React12 from "react";
1135
+ import { useTypeManager as useTypeManager4 } from "@flowgram.ai/json-schema";
1136
+ import { Icon as Icon3 } from "@douyinfe/semi-ui";
1137
+ var defaultRules2 = ConditionRow.defaultRules;
1138
+ function useLeft({ left, options, userRules, readonly, onChange }) {
1139
+ const rules = useMemo9(() => ({ ...defaultRules2, ...userRules || {} }), [userRules]);
1140
+ const typeManager = useTypeManager4();
1141
+ const rule = useMemo9(() => {
1142
+ if (!left) return void 0;
1143
+ const option = options?.find((item) => item.value === left);
1144
+ if (!option?.schema?.type) {
1145
+ return void 0;
2033
1146
  }
2034
- ), /* @__PURE__ */ React22.createElement(
2035
- Button3,
1147
+ return rules[option.schema.type];
1148
+ }, [left, options, rules]);
1149
+ const renderDBOptionSelect = () => /* @__PURE__ */ React12.createElement(
1150
+ UISelect,
2036
1151
  {
2037
1152
  disabled: readonly,
2038
- icon: /* @__PURE__ */ React22.createElement(IconDelete, null),
2039
1153
  size: "small",
2040
- onClick: () => remove(item.id)
1154
+ style: { width: "100%" },
1155
+ value: left,
1156
+ onChange: (v) => onChange(v),
1157
+ optionList: options?.map((item) => ({
1158
+ label: /* @__PURE__ */ React12.createElement(UIOptionLabel, null, /* @__PURE__ */ React12.createElement(Icon3, { size: "small", svg: typeManager.getDisplayIcon(item.schema) }), item.label),
1159
+ value: item.value
1160
+ })) || []
2041
1161
  }
2042
- )))), /* @__PURE__ */ React22.createElement(Button3, { disabled: readonly, icon: /* @__PURE__ */ React22.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
2043
- }
2044
-
2045
- // src/components/prompt-editor/index.tsx
2046
- import React23, { useEffect as useEffect5, useRef as useRef4 } from "react";
2047
- import { Renderer, EditorProvider as EditorProvider2, ActiveLinePlaceholder as ActiveLinePlaceholder2 } from "@coze-editor/editor/react";
2048
- import preset2 from "@coze-editor/editor/preset-prompt";
2049
-
2050
- // src/components/prompt-editor/styles.tsx
2051
- import styled7, { css as css3 } from "styled-components";
2052
- var UIContainer4 = styled7.div`
2053
- background-color: var(--semi-color-fill-0);
2054
- padding-left: 10px;
2055
- padding-right: 6px;
2056
-
2057
- ${({ $hasError }) => $hasError && css3`
2058
- border: 1px solid var(--semi-color-danger-6);
2059
- `}
2060
- `;
2061
-
2062
- // src/components/prompt-editor/extensions/markdown.tsx
2063
- import { useLayoutEffect } from "react";
2064
- import { useInjector } from "@coze-editor/editor/react";
2065
- import { astDecorator } from "@coze-editor/editor";
2066
- import { EditorView as EditorView2 } from "@codemirror/view";
2067
- function MarkdownHighlight() {
2068
- const injector = useInjector();
2069
- useLayoutEffect(
2070
- () => injector.inject([
2071
- astDecorator.whole.of((cursor) => {
2072
- if (cursor.name.startsWith("ATXHeading")) {
2073
- return {
2074
- type: "className",
2075
- className: "heading"
2076
- };
2077
- }
2078
- if (cursor.name === "Emphasis") {
2079
- return {
2080
- type: "className",
2081
- className: "emphasis"
2082
- };
2083
- }
2084
- if (cursor.name === "StrongEmphasis") {
2085
- return {
2086
- type: "className",
2087
- className: "strong-emphasis"
2088
- };
2089
- }
2090
- if (cursor.name === "ListMark" || cursor.name === "QuoteMark") {
2091
- return {
2092
- type: "className",
2093
- className: "mark"
2094
- };
2095
- }
2096
- }),
2097
- EditorView2.theme({
2098
- ".heading": {
2099
- color: "#00818C",
2100
- fontWeight: "bold"
2101
- },
2102
- ".emphasis": {
2103
- fontStyle: "italic"
2104
- },
2105
- ".strong-emphasis": {
2106
- fontWeight: "bold"
2107
- },
2108
- ".mark": {
2109
- color: "#4E40E5"
2110
- }
2111
- })
2112
- ]),
2113
- [injector]
2114
- );
2115
- return null;
2116
- }
2117
- var markdown_default = MarkdownHighlight;
2118
-
2119
- // src/components/prompt-editor/extensions/language-support.tsx
2120
- import { useLayoutEffect as useLayoutEffect2 } from "react";
2121
- import { useInjector as useInjector2 } from "@coze-editor/editor/react";
2122
- import { languageSupport } from "@coze-editor/editor/preset-prompt";
2123
- function LanguageSupport() {
2124
- const injector = useInjector2();
2125
- useLayoutEffect2(() => injector.inject([languageSupport]), [injector]);
2126
- return null;
2127
- }
2128
- var language_support_default = LanguageSupport;
2129
-
2130
- // src/components/prompt-editor/extensions/jinja.tsx
2131
- import { useLayoutEffect as useLayoutEffect3 } from "react";
2132
- import { useInjector as useInjector3 } from "@coze-editor/editor/react";
2133
- import { astDecorator as astDecorator2 } from "@coze-editor/editor";
2134
- import { EditorView as EditorView3 } from "@codemirror/view";
2135
- function JinjaHighlight() {
2136
- const injector = useInjector3();
2137
- useLayoutEffect3(
2138
- () => injector.inject([
2139
- astDecorator2.whole.of((cursor) => {
2140
- if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
2141
- return {
2142
- type: "className",
2143
- className: "jinja-statement-bracket"
2144
- };
2145
- }
2146
- if (cursor.name === "JinjaComment") {
2147
- return {
2148
- type: "className",
2149
- className: "jinja-comment"
2150
- };
2151
- }
2152
- if (cursor.name === "JinjaExpression") {
2153
- return {
2154
- type: "className",
2155
- className: "jinja-expression"
2156
- };
2157
- }
2158
- }),
2159
- EditorView3.theme({
2160
- ".jinja-statement-bracket": {
2161
- color: "#D1009D"
2162
- },
2163
- ".jinja-comment": {
2164
- color: "#0607094D"
2165
- },
2166
- ".jinja-expression": {
2167
- color: "#4E40E5"
2168
- }
2169
- })
2170
- ]),
2171
- [injector]
2172
1162
  );
2173
- return null;
2174
- }
2175
- var jinja_default = JinjaHighlight;
2176
-
2177
- // src/components/prompt-editor/index.tsx
2178
- function PromptEditor(props) {
2179
- const {
2180
- value,
2181
- onChange,
2182
- readonly,
2183
- placeholder,
2184
- activeLinePlaceholder,
2185
- style,
2186
- hasError,
2187
- children,
2188
- disableMarkdownHighlight
2189
- } = props || {};
2190
- const editorRef = useRef4(null);
2191
- useEffect5(() => {
2192
- if (editorRef.current?.getValue() !== value?.content) {
2193
- editorRef.current?.setValue(String(value?.content || ""));
2194
- }
2195
- }, [value]);
2196
- return /* @__PURE__ */ React23.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ React23.createElement(EditorProvider2, null, /* @__PURE__ */ React23.createElement(
2197
- Renderer,
2198
- {
2199
- didMount: (editor) => {
2200
- editorRef.current = editor;
2201
- },
2202
- plugins: preset2,
2203
- defaultValue: String(value?.content),
2204
- options: {
2205
- readOnly: readonly,
2206
- editable: !readonly,
2207
- placeholder
2208
- },
2209
- onChange: (e) => {
2210
- onChange({ type: "template", content: e.value });
2211
- }
2212
- }
2213
- ), activeLinePlaceholder && /* @__PURE__ */ React23.createElement(ActiveLinePlaceholder2, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ React23.createElement(markdown_default, null), /* @__PURE__ */ React23.createElement(language_support_default, null), /* @__PURE__ */ React23.createElement(jinja_default, null), children));
2214
- }
2215
-
2216
- // src/components/prompt-editor-with-variables/index.tsx
2217
- import React26 from "react";
2218
-
2219
- // src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
2220
- import React24, { useEffect as useEffect6, useState as useState7 } from "react";
2221
- import { Popover as Popover2, Tree } from "@douyinfe/semi-ui";
2222
- import {
2223
- Mention,
2224
- getCurrentMentionReplaceRange,
2225
- useEditor,
2226
- PositionMirror
2227
- } from "@coze-editor/editor/react";
2228
- function VariableTree() {
2229
- const [posKey, setPosKey] = useState7("");
2230
- const [visible, setVisible] = useState7(false);
2231
- const [position, setPosition] = useState7(-1);
2232
- const editor = useEditor();
2233
- function insert(variablePath) {
2234
- const range = getCurrentMentionReplaceRange(editor.$view.state);
2235
- if (!range) {
2236
- return;
2237
- }
2238
- editor.replaceText({
2239
- ...range,
2240
- text: "{{" + variablePath + "}}"
2241
- });
2242
- setVisible(false);
2243
- }
2244
- function handleOpenChange(e) {
2245
- setPosition(e.state.selection.main.head);
2246
- setVisible(e.value);
2247
- }
2248
- useEffect6(() => {
2249
- if (!editor) {
2250
- return;
2251
- }
2252
- }, [editor, visible]);
2253
- const treeData = useVariableTree({});
2254
- return /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React24.createElement(
2255
- Popover2,
2256
- {
2257
- visible,
2258
- trigger: "custom",
2259
- position: "topLeft",
2260
- rePosKey: posKey,
2261
- content: /* @__PURE__ */ React24.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React24.createElement(
2262
- Tree,
2263
- {
2264
- treeData,
2265
- onSelect: (v) => {
2266
- insert(v);
2267
- }
2268
- }
2269
- ))
2270
- },
2271
- /* @__PURE__ */ React24.createElement(
2272
- PositionMirror,
2273
- {
2274
- position,
2275
- onChange: () => setPosKey(String(Math.random()))
2276
- }
2277
- )
2278
- ));
1163
+ return { rule, renderDBOptionSelect };
2279
1164
  }
2280
1165
 
2281
- // src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
2282
- import ReactDOM from "react-dom";
2283
- import React25, { useLayoutEffect as useLayoutEffect4 } from "react";
2284
- import { isEqual, last } from "lodash";
2285
- import {
2286
- Disposable,
2287
- DisposableCollection,
2288
- useCurrentScope
2289
- } from "@flowgram.ai/editor";
2290
- import { Popover as Popover3 } from "@douyinfe/semi-ui";
2291
- import { IconIssueStroked as IconIssueStroked2 } from "@douyinfe/semi-icons";
2292
- import { useInjector as useInjector4 } from "@coze-editor/editor/react";
2293
- import {
2294
- Decoration,
2295
- EditorView as EditorView4,
2296
- MatchDecorator,
2297
- ViewPlugin,
2298
- WidgetType
2299
- } from "@codemirror/view";
2300
-
2301
- // src/components/prompt-editor-with-variables/styles.tsx
2302
- import styled8 from "styled-components";
2303
- import { Tag as Tag2 } from "@douyinfe/semi-ui";
2304
- var UIRootTitle2 = styled8.div`
2305
- margin-right: 4px;
2306
- min-width: 20px;
2307
- overflow: hidden;
2308
- text-overflow: ellipsis;
2309
- white-space: nowrap;
2310
- color: var(--semi-color-text-2);
2311
- `;
2312
- var UIVarName2 = styled8.div`
2313
- overflow: hidden;
2314
- text-overflow: ellipsis;
2315
- white-space: nowrap;
2316
- `;
2317
- var UITag2 = styled8(Tag2)`
2318
- display: inline-flex;
2319
- align-items: center;
2320
- justify-content: flex-start;
2321
- max-width: 300px;
2322
-
2323
- & .semi-tag-content-center {
2324
- justify-content: flex-start;
2325
- }
2326
-
2327
- &.semi-tag {
2328
- margin: 0 5px;
2329
- }
2330
- `;
2331
- var UIPopoverContent2 = styled8.div`
2332
- padding: 10px;
2333
- display: inline-flex;
2334
- align-items: center;
2335
- justify-content: flex-start;
2336
- `;
2337
-
2338
- // src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
2339
- var VariableTagWidget = class extends WidgetType {
2340
- constructor({ keyPath, scope }) {
2341
- super();
2342
- this.toDispose = new DisposableCollection();
2343
- this.renderIcon = (icon) => {
2344
- if (typeof icon === "string") {
2345
- return /* @__PURE__ */ React25.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2346
- }
2347
- return icon;
2348
- };
2349
- this.keyPath = keyPath;
2350
- this.scope = scope;
2351
- }
2352
- renderReact(jsx) {
2353
- ReactDOM.render(jsx, this.rootDOM);
2354
- }
2355
- renderVariable(v) {
2356
- if (!v) {
2357
- this.renderReact(
2358
- /* @__PURE__ */ React25.createElement(UITag2, { prefixIcon: /* @__PURE__ */ React25.createElement(IconIssueStroked2, null), color: "amber" }, "Unknown")
2359
- );
2360
- return;
2361
- }
2362
- const rootField = last(v.parentFields) || v;
2363
- const isRoot = v.parentFields.length === 0;
2364
- const rootTitle = /* @__PURE__ */ React25.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
2365
- const rootIcon = this.renderIcon(rootField?.meta.icon);
2366
- this.renderReact(
2367
- /* @__PURE__ */ React25.createElement(
2368
- Popover3,
2369
- {
2370
- content: /* @__PURE__ */ React25.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React25.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
2371
- },
2372
- /* @__PURE__ */ React25.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ React25.createElement(UIVarName2, null, v?.key))
2373
- )
2374
- );
2375
- }
2376
- toDOM(view) {
2377
- const dom = document.createElement("span");
2378
- this.rootDOM = dom;
2379
- this.toDispose.push(
2380
- Disposable.create(() => {
2381
- ReactDOM.unmountComponentAtNode(this.rootDOM);
2382
- })
2383
- );
2384
- this.toDispose.push(
2385
- this.scope.available.trackByKeyPath(
2386
- this.keyPath,
2387
- (v) => {
2388
- this.renderVariable(v);
2389
- },
2390
- { triggerOnInit: false }
2391
- )
2392
- );
2393
- this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
2394
- return dom;
2395
- }
2396
- eq(other) {
2397
- return isEqual(this.keyPath, other.keyPath);
2398
- }
2399
- ignoreEvent() {
2400
- return false;
2401
- }
2402
- destroy(dom) {
2403
- this.toDispose.dispose();
2404
- }
1166
+ // src/components/db-condition-row/index.tsx
1167
+ var defaultRuleConfig2 = {
1168
+ ops: {},
1169
+ rules: {}
2405
1170
  };
2406
- function VariableTagInject() {
2407
- const injector = useInjector4();
2408
- const scope = useCurrentScope();
2409
- useLayoutEffect4(() => {
2410
- const atMatcher = new MatchDecorator({
2411
- regexp: /\{\{([^\}]+)\}\}/g,
2412
- decoration: (match) => Decoration.replace({
2413
- widget: new VariableTagWidget({
2414
- keyPath: match[1]?.split(".") ?? [],
2415
- scope
2416
- })
2417
- })
2418
- });
2419
- return injector.inject([
2420
- ViewPlugin.fromClass(
2421
- class {
2422
- constructor(view) {
2423
- this.view = view;
2424
- this.decorations = atMatcher.createDeco(view);
2425
- }
2426
- update() {
2427
- this.decorations = atMatcher.createDeco(this.view);
2428
- }
2429
- },
2430
- {
2431
- decorations: (p) => p.decorations,
2432
- provide(p) {
2433
- return EditorView4.atomicRanges.of(
2434
- (view) => view.plugin(p)?.decorations ?? Decoration.none
2435
- );
2436
- }
2437
- }
2438
- )
2439
- ]);
2440
- }, [injector]);
2441
- return null;
2442
- }
2443
-
2444
- // src/components/prompt-editor-with-variables/index.tsx
2445
- function PromptEditorWithVariables(props) {
2446
- return /* @__PURE__ */ React26.createElement(PromptEditor, { ...props }, /* @__PURE__ */ React26.createElement(VariableTree, null), /* @__PURE__ */ React26.createElement(VariableTagInject, null));
2447
- }
2448
-
2449
- // src/components/prompt-editor-with-inputs/index.tsx
2450
- import React29 from "react";
2451
-
2452
- // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2453
- import React28, { useEffect as useEffect7, useState as useState8 } from "react";
2454
- import { Popover as Popover4 } from "@douyinfe/semi-ui";
2455
- import {
2456
- Mention as Mention2,
2457
- getCurrentMentionReplaceRange as getCurrentMentionReplaceRange2,
2458
- useEditor as useEditor2,
2459
- PositionMirror as PositionMirror2
2460
- } from "@coze-editor/editor/react";
2461
-
2462
- // src/components/prompt-editor-with-inputs/inputs-picker.tsx
2463
- import React27, { useMemo as useMemo10 } from "react";
2464
- import { last as last2 } from "lodash";
2465
- import {
2466
- ASTMatch as ASTMatch3,
2467
- useScopeAvailable as useScopeAvailable3
2468
- } from "@flowgram.ai/editor";
2469
- import { Tree as Tree2 } from "@douyinfe/semi-ui";
2470
- function InputsPicker({
2471
- inputsValues,
2472
- onSelect
1171
+ function DBConditionRow({
1172
+ style,
1173
+ value,
1174
+ onChange,
1175
+ readonly,
1176
+ options,
1177
+ ruleConfig = defaultRuleConfig2
2473
1178
  }) {
2474
- const available = useScopeAvailable3();
2475
- const getArrayDrilldown = (type, depth = 1) => {
2476
- if (ASTMatch3.isArray(type.items)) {
2477
- return getArrayDrilldown(type.items, depth + 1);
2478
- }
2479
- return { type: type.items, depth };
2480
- };
2481
- const renderVariable = (variable, keyPath) => {
2482
- let type = variable?.type;
2483
- let children;
2484
- if (ASTMatch3.isObject(type)) {
2485
- children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
2486
- }
2487
- if (ASTMatch3.isArray(type)) {
2488
- const drilldown = getArrayDrilldown(type);
2489
- if (ASTMatch3.isObject(drilldown.type)) {
2490
- children = (drilldown.type.properties || []).map(
2491
- (_property) => renderVariable(_property, [
2492
- ...keyPath,
2493
- ...new Array(drilldown.depth).fill("[0]"),
2494
- _property.key
2495
- ])
2496
- ).filter(Boolean);
2497
- }
2498
- }
2499
- const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
2500
- return {
2501
- key,
2502
- label: last2(keyPath),
2503
- value: key,
2504
- children
2505
- };
2506
- };
2507
- const treeData = useMemo10(
2508
- () => Object.entries(inputsValues).map(([key, value]) => {
2509
- if (value?.type === "ref") {
2510
- const variable = available.getByKeyPath(value.content || []);
2511
- if (variable) {
2512
- return renderVariable(variable, [key]);
2513
- }
2514
- }
2515
- return {
2516
- key,
2517
- value: key,
2518
- label: key
2519
- };
2520
- }),
2521
- []
2522
- );
2523
- return /* @__PURE__ */ React27.createElement(Tree2, { treeData, onSelect: (v) => onSelect(v) });
2524
- }
2525
-
2526
- // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2527
- function InputsTree({ inputsValues }) {
2528
- const [posKey, setPosKey] = useState8("");
2529
- const [visible, setVisible] = useState8(false);
2530
- const [position, setPosition] = useState8(-1);
2531
- const editor = useEditor2();
2532
- function insert(variablePath) {
2533
- const range = getCurrentMentionReplaceRange2(editor.$view.state);
2534
- if (!range) {
2535
- return;
2536
- }
2537
- editor.replaceText({
2538
- ...range,
2539
- text: "{{" + variablePath + "}}"
2540
- });
2541
- setVisible(false);
2542
- }
2543
- function handleOpenChange(e) {
2544
- setPosition(e.state.selection.main.head);
2545
- setVisible(e.value);
2546
- }
2547
- useEffect7(() => {
2548
- if (!editor) {
2549
- return;
1179
+ const { left, operator, right } = value || {};
1180
+ const { rule, renderDBOptionSelect } = useLeft({
1181
+ left,
1182
+ options,
1183
+ onChange: (leftKey) => onChange({ ...value, left: leftKey }),
1184
+ readonly,
1185
+ userRules: ruleConfig.rules
1186
+ });
1187
+ const { renderOpSelect, opConfig } = useOp2({
1188
+ rule,
1189
+ op: operator,
1190
+ onChange: (v) => onChange({ ...value, operator: v }),
1191
+ readonly,
1192
+ userOps: ruleConfig.ops
1193
+ });
1194
+ const targetSchema = useMemo10(() => {
1195
+ const targetType = rule?.[operator || ""] || null;
1196
+ return targetType ? { type: targetType, extra: { weak: true } } : null;
1197
+ }, [rule, opConfig]);
1198
+ return /* @__PURE__ */ React13.createElement(UIContainer4, { style }, /* @__PURE__ */ React13.createElement(UIOperator2, null, renderOpSelect()), /* @__PURE__ */ React13.createElement(UIValues2, null, /* @__PURE__ */ React13.createElement(UILeft2, null, renderDBOptionSelect()), /* @__PURE__ */ React13.createElement(UIRight2, null, targetSchema ? /* @__PURE__ */ React13.createElement(
1199
+ InjectDynamicValueInput,
1200
+ {
1201
+ readonly: readonly || !rule,
1202
+ value: right,
1203
+ schema: targetSchema,
1204
+ onChange: (v) => onChange({ ...value, right: v })
2550
1205
  }
2551
- }, [editor, visible]);
2552
- return /* @__PURE__ */ React28.createElement(React28.Fragment, null, /* @__PURE__ */ React28.createElement(Mention2, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React28.createElement(
2553
- Popover4,
1206
+ ) : /* @__PURE__ */ React13.createElement(
1207
+ Input4,
2554
1208
  {
2555
- visible,
2556
- trigger: "custom",
2557
- position: "topLeft",
2558
- rePosKey: posKey,
2559
- content: /* @__PURE__ */ React28.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React28.createElement(
2560
- InputsPicker,
2561
- {
2562
- inputsValues,
2563
- onSelect: (v) => {
2564
- insert(v);
2565
- }
2566
- }
2567
- ))
2568
- },
2569
- /* @__PURE__ */ React28.createElement(
2570
- PositionMirror2,
2571
- {
2572
- position,
2573
- onChange: () => setPosKey(String(Math.random()))
2574
- }
2575
- )
2576
- ));
2577
- }
2578
-
2579
- // src/components/prompt-editor-with-inputs/index.tsx
2580
- function PromptEditorWithInputs({ inputsValues, ...restProps }) {
2581
- return /* @__PURE__ */ React29.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ React29.createElement(InputsTree, { inputsValues }));
1209
+ size: "small",
1210
+ disabled: true,
1211
+ style: { pointerEvents: "none" },
1212
+ value: opConfig?.rightDisplay || I18n6.t("Empty")
1213
+ }
1214
+ ))));
2582
1215
  }
2583
1216
 
2584
- // src/components/json-editor-with-variables/index.tsx
2585
- import React32 from "react";
2586
- import { transformerCreator } from "@coze-editor/editor/preset-code";
1217
+ // src/components/batch-outputs/index.tsx
1218
+ import React14 from "react";
1219
+ import { I18n as I18n7 } from "@flowgram.ai/editor";
1220
+ import { Button as Button4, Input as Input5 } from "@douyinfe/semi-ui";
1221
+ import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
2587
1222
 
2588
- // src/components/json-editor-with-variables/extensions/variable-tree.tsx
2589
- import React30, { useEffect as useEffect8, useState as useState9 } from "react";
2590
- import { Popover as Popover5, Tree as Tree3 } from "@douyinfe/semi-ui";
2591
- import {
2592
- Mention as Mention3,
2593
- getCurrentMentionReplaceRange as getCurrentMentionReplaceRange3,
2594
- useEditor as useEditor3,
2595
- PositionMirror as PositionMirror3
2596
- } from "@coze-editor/editor/react";
2597
- function VariableTree2() {
2598
- const [posKey, setPosKey] = useState9("");
2599
- const [visible, setVisible] = useState9(false);
2600
- const [position, setPosition] = useState9(-1);
2601
- const editor = useEditor3();
2602
- function insert(variablePath) {
2603
- const range = getCurrentMentionReplaceRange3(editor.$view.state);
2604
- if (!range) {
1223
+ // src/hooks/use-object-list/index.tsx
1224
+ import { useEffect as useEffect4, useRef as useRef3, useState as useState5 } from "react";
1225
+ import { nanoid } from "nanoid";
1226
+ import { difference as difference2, get, isObject, set } from "lodash-es";
1227
+ function genId2() {
1228
+ return nanoid();
1229
+ }
1230
+ function useObjectList({
1231
+ value,
1232
+ onChange,
1233
+ sortIndexKey
1234
+ }) {
1235
+ const [list, setList] = useState5([]);
1236
+ const effectVersion = useRef3(0);
1237
+ const changeVersion = useRef3(0);
1238
+ const getSortIndex = (value2) => {
1239
+ if (typeof sortIndexKey === "function") {
1240
+ return get(value2, sortIndexKey(value2)) || 0;
1241
+ }
1242
+ return get(value2, sortIndexKey || "") || 0;
1243
+ };
1244
+ useEffect4(() => {
1245
+ effectVersion.current = effectVersion.current + 1;
1246
+ if (effectVersion.current === changeVersion.current) {
2605
1247
  return;
2606
1248
  }
2607
- editor.replaceText({
2608
- ...range,
2609
- text: "{{" + variablePath + "}}"
1249
+ effectVersion.current = changeVersion.current;
1250
+ setList((_prevList) => {
1251
+ const newKeys = Object.entries(value || {}).sort((a, b) => getSortIndex(a[1]) - getSortIndex(b[1])).map(([key]) => key);
1252
+ const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
1253
+ const addKeys = difference2(newKeys, oldKeys);
1254
+ return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
1255
+ id: item.id,
1256
+ key: item.key,
1257
+ value: item.key ? value?.[item.key] : item.value
1258
+ })).concat(
1259
+ addKeys.map((_key) => ({
1260
+ id: genId2(),
1261
+ key: _key,
1262
+ value: value?.[_key]
1263
+ }))
1264
+ );
2610
1265
  });
2611
- setVisible(false);
2612
- }
2613
- function handleOpenChange(e) {
2614
- setPosition(e.state.selection.main.head);
2615
- setVisible(e.value);
2616
- }
2617
- useEffect8(() => {
2618
- if (!editor) {
2619
- return;
2620
- }
2621
- }, [editor, visible]);
2622
- const treeData = useVariableTree({});
2623
- return /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Mention3, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React30.createElement(
2624
- Popover5,
2625
- {
2626
- visible,
2627
- trigger: "custom",
2628
- position: "topLeft",
2629
- rePosKey: posKey,
2630
- content: /* @__PURE__ */ React30.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React30.createElement(
2631
- Tree3,
2632
- {
2633
- treeData,
2634
- onSelect: (v) => {
2635
- insert(v);
2636
- }
2637
- }
2638
- ))
2639
- },
2640
- /* @__PURE__ */ React30.createElement(
2641
- PositionMirror3,
1266
+ }, [value]);
1267
+ const add = (defaultValue) => {
1268
+ setList((prevList) => [
1269
+ ...prevList,
2642
1270
  {
2643
- position,
2644
- onChange: () => setPosKey(String(Math.random()))
1271
+ id: genId2(),
1272
+ value: defaultValue
2645
1273
  }
2646
- )
2647
- ));
1274
+ ]);
1275
+ };
1276
+ const updateValue = (itemId, value2) => {
1277
+ changeVersion.current = changeVersion.current + 1;
1278
+ setList((prevList) => {
1279
+ const nextList = prevList.map((_item) => {
1280
+ if (_item.id === itemId) {
1281
+ return {
1282
+ ..._item,
1283
+ value: value2
1284
+ };
1285
+ }
1286
+ return _item;
1287
+ });
1288
+ onChange(
1289
+ Object.fromEntries(
1290
+ nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
1291
+ const indexKey = typeof sortIndexKey === "function" ? sortIndexKey(_res[1]) : sortIndexKey;
1292
+ if (isObject(_res[1]) && indexKey) {
1293
+ set(_res[1], indexKey, idx);
1294
+ }
1295
+ return _res;
1296
+ })
1297
+ )
1298
+ );
1299
+ return nextList;
1300
+ });
1301
+ };
1302
+ const updateKey = (itemId, key) => {
1303
+ changeVersion.current = changeVersion.current + 1;
1304
+ setList((prevList) => {
1305
+ const nextList = prevList.map((_item) => {
1306
+ if (_item.id === itemId) {
1307
+ return {
1308
+ ..._item,
1309
+ key
1310
+ };
1311
+ }
1312
+ return _item;
1313
+ });
1314
+ onChange(
1315
+ Object.fromEntries(
1316
+ nextList.filter((item) => item.key).map((item) => [item.key, item.value])
1317
+ )
1318
+ );
1319
+ return nextList;
1320
+ });
1321
+ };
1322
+ const remove = (itemId) => {
1323
+ changeVersion.current = changeVersion.current + 1;
1324
+ setList((prevList) => {
1325
+ const nextList = prevList.filter((_item) => _item.id !== itemId);
1326
+ onChange(
1327
+ Object.fromEntries(
1328
+ nextList.filter((item) => item.key).map((item) => [item.key, item.value])
1329
+ )
1330
+ );
1331
+ return nextList;
1332
+ });
1333
+ };
1334
+ return { list, add, updateKey, updateValue, remove };
2648
1335
  }
2649
1336
 
2650
- // src/components/json-editor-with-variables/extensions/variable-tag.tsx
2651
- import React31, { useLayoutEffect as useLayoutEffect5 } from "react";
2652
- import { createRoot } from "react-dom/client";
2653
- import { isEqual as isEqual2, last as last3 } from "lodash";
2654
- import {
2655
- Disposable as Disposable2,
2656
- DisposableCollection as DisposableCollection2,
2657
- useCurrentScope as useCurrentScope2
2658
- } from "@flowgram.ai/editor";
2659
- import { Popover as Popover6 } from "@douyinfe/semi-ui";
2660
- import { IconIssueStroked as IconIssueStroked3 } from "@douyinfe/semi-icons";
2661
- import { useInjector as useInjector5 } from "@coze-editor/editor/react";
2662
- import {
2663
- Decoration as Decoration2,
2664
- EditorView as EditorView5,
2665
- MatchDecorator as MatchDecorator2,
2666
- ViewPlugin as ViewPlugin2,
2667
- WidgetType as WidgetType2
2668
- } from "@codemirror/view";
2669
-
2670
- // src/components/json-editor-with-variables/styles.tsx
2671
- import styled9 from "styled-components";
2672
- import { Tag as Tag3 } from "@douyinfe/semi-ui";
2673
- var UIRootTitle3 = styled9.div`
2674
- margin-right: 4px;
2675
- min-width: 20px;
2676
- overflow: hidden;
2677
- text-overflow: ellipsis;
2678
- white-space: nowrap;
2679
- color: var(--semi-color-text-2);
2680
- `;
2681
- var UIVarName3 = styled9.div`
2682
- overflow: hidden;
2683
- text-overflow: ellipsis;
2684
- white-space: nowrap;
2685
- `;
2686
- var UITag3 = styled9(Tag3)`
2687
- display: inline-flex;
2688
- align-items: center;
2689
- justify-content: flex-start;
2690
- max-width: 300px;
2691
-
2692
- & .semi-tag-content-center {
2693
- justify-content: flex-start;
2694
- }
2695
-
2696
- &.semi-tag {
2697
- margin: 0 5px;
2698
- }
1337
+ // src/components/batch-outputs/styles.tsx
1338
+ import styled5 from "styled-components";
1339
+ var UIRows = styled5.div`
1340
+ display: flex;
1341
+ flex-direction: column;
1342
+ gap: 10px;
1343
+ margin-bottom: 10px;
2699
1344
  `;
2700
- var UIPopoverContent3 = styled9.div`
2701
- padding: 10px;
2702
- display: inline-flex;
1345
+ var UIRow2 = styled5.div`
1346
+ display: flex;
2703
1347
  align-items: center;
2704
- justify-content: flex-start;
1348
+ gap: 5px;
2705
1349
  `;
2706
1350
 
2707
- // src/components/json-editor-with-variables/extensions/variable-tag.tsx
2708
- var VariableTagWidget2 = class extends WidgetType2 {
2709
- constructor({ keyPath, scope }) {
2710
- super();
2711
- this.toDispose = new DisposableCollection2();
2712
- this.renderIcon = (icon) => {
2713
- if (typeof icon === "string") {
2714
- return /* @__PURE__ */ React31.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2715
- }
2716
- return icon;
2717
- };
2718
- this.keyPath = keyPath;
2719
- this.scope = scope;
2720
- }
2721
- renderVariable(v) {
2722
- if (!v) {
2723
- this.root.render(
2724
- /* @__PURE__ */ React31.createElement(UITag3, { prefixIcon: /* @__PURE__ */ React31.createElement(IconIssueStroked3, null), color: "amber" }, "Unknown")
2725
- );
2726
- return;
1351
+ // src/components/batch-outputs/index.tsx
1352
+ function BatchOutputs(props) {
1353
+ const { readonly, style } = props;
1354
+ const { list, add, updateKey, updateValue, remove } = useObjectList(props);
1355
+ return /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ React14.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ React14.createElement(
1356
+ Input5,
1357
+ {
1358
+ style: { width: 100 },
1359
+ disabled: readonly,
1360
+ size: "small",
1361
+ value: item.key,
1362
+ onChange: (v) => updateKey(item.id, v)
2727
1363
  }
2728
- const rootField = last3(v.parentFields);
2729
- const rootTitle = /* @__PURE__ */ React31.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
2730
- const rootIcon = this.renderIcon(rootField?.meta.icon);
2731
- this.root.render(
2732
- /* @__PURE__ */ React31.createElement(
2733
- Popover6,
2734
- {
2735
- content: /* @__PURE__ */ React31.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ React31.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
2736
- },
2737
- /* @__PURE__ */ React31.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React31.createElement(UIVarName3, null, v?.key))
2738
- )
2739
- );
2740
- }
2741
- toDOM(view) {
2742
- const dom = document.createElement("span");
2743
- this.root = createRoot(dom);
2744
- this.toDispose.push(
2745
- Disposable2.create(() => {
2746
- this.root.unmount();
2747
- })
2748
- );
2749
- this.toDispose.push(
2750
- this.scope.available.trackByKeyPath(
2751
- this.keyPath,
2752
- (v) => {
2753
- this.renderVariable(v);
2754
- },
2755
- { triggerOnInit: false }
2756
- )
2757
- );
2758
- this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
2759
- return dom;
2760
- }
2761
- eq(other) {
2762
- return isEqual2(this.keyPath, other.keyPath);
2763
- }
2764
- ignoreEvent() {
2765
- return false;
2766
- }
2767
- destroy(dom) {
2768
- this.toDispose.dispose();
2769
- }
2770
- };
2771
- function VariableTagInject2() {
2772
- const injector = useInjector5();
2773
- const scope = useCurrentScope2();
2774
- useLayoutEffect5(() => {
2775
- const atMatcher = new MatchDecorator2({
2776
- regexp: /\{\{([^\}]+)\}\}/g,
2777
- decoration: (match) => Decoration2.replace({
2778
- widget: new VariableTagWidget2({
2779
- keyPath: match[1]?.split(".") ?? [],
2780
- scope
2781
- })
2782
- })
2783
- });
2784
- return injector.inject([
2785
- ViewPlugin2.fromClass(
2786
- class {
2787
- constructor(view) {
2788
- this.view = view;
2789
- this.decorations = atMatcher.createDeco(view);
2790
- }
2791
- update() {
2792
- this.decorations = atMatcher.createDeco(this.view);
2793
- }
2794
- },
2795
- {
2796
- decorations: (p) => p.decorations,
2797
- provide(p) {
2798
- return EditorView5.atomicRanges.of(
2799
- (view) => view.plugin(p)?.decorations ?? Decoration2.none
2800
- );
2801
- }
2802
- }
2803
- )
2804
- ]);
2805
- }, [injector]);
2806
- return null;
1364
+ ), /* @__PURE__ */ React14.createElement(
1365
+ InjectVariableSelector,
1366
+ {
1367
+ style: { flexGrow: 1 },
1368
+ readonly,
1369
+ value: item.value?.content,
1370
+ onChange: (v) => updateValue(item.id, { type: "ref", content: v })
1371
+ }
1372
+ ), /* @__PURE__ */ React14.createElement(
1373
+ Button4,
1374
+ {
1375
+ disabled: readonly,
1376
+ icon: /* @__PURE__ */ React14.createElement(IconDelete, null),
1377
+ size: "small",
1378
+ onClick: () => remove(item.id)
1379
+ }
1380
+ )))), /* @__PURE__ */ React14.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React14.createElement(IconPlus2, null), size: "small", onClick: () => add() }, I18n7.t("Add")));
2807
1381
  }
2808
1382
 
1383
+ // src/components/prompt-editor-with-variables/index.tsx
1384
+ var PromptEditorWithVariables = lazySuspense(
1385
+ () => import("./editor-VO6YAXRC.js").then((module) => ({ default: module.PromptEditorWithVariables }))
1386
+ );
1387
+
1388
+ // src/components/prompt-editor-with-inputs/index.tsx
1389
+ var PromptEditorWithInputs = lazySuspense(
1390
+ () => import("./editor-OXPGKPF5.js").then((module) => ({ default: module.PromptEditorWithInputs }))
1391
+ );
1392
+
2809
1393
  // src/components/json-editor-with-variables/index.tsx
2810
- function findAllMatches(inputString, regex) {
2811
- const globalRegex = new RegExp(
2812
- regex,
2813
- regex.flags.includes("g") ? regex.flags : regex.flags + "g"
2814
- );
2815
- let match;
2816
- const matches = [];
2817
- while ((match = globalRegex.exec(inputString)) !== null) {
2818
- if (match.index === globalRegex.lastIndex) {
2819
- globalRegex.lastIndex++;
2820
- }
2821
- matches.push({
2822
- match: match[0],
2823
- range: [match.index, match.index + match[0].length]
2824
- });
2825
- }
2826
- return matches;
2827
- }
2828
- var transformer = transformerCreator((text) => {
2829
- const originalSource = text.toString();
2830
- const matches = findAllMatches(originalSource, /\{\{([^\}]*)\}\}/g);
2831
- if (matches.length > 0) {
2832
- matches.forEach(({ range }) => {
2833
- text.replaceRange(range[0], range[1], "null");
2834
- });
2835
- }
2836
- return text;
2837
- });
2838
- function JsonEditorWithVariables(props) {
2839
- return /* @__PURE__ */ React32.createElement(
2840
- CodeEditor,
2841
- {
2842
- languageId: "json",
2843
- activeLinePlaceholder: "Press '@' to Select variable",
2844
- ...props,
2845
- options: {
2846
- transformer,
2847
- ...props.options || {}
2848
- }
2849
- },
2850
- /* @__PURE__ */ React32.createElement(VariableTree2, null),
2851
- /* @__PURE__ */ React32.createElement(VariableTagInject2, null)
2852
- );
2853
- }
1394
+ var JsonEditorWithVariables = lazySuspense(
1395
+ () => import("./editor-EYOQTGMT.js").then((module) => ({ default: module.JsonEditorWithVariables }))
1396
+ );
2854
1397
 
2855
1398
  // src/components/inputs-values/index.tsx
2856
- import React34 from "react";
2857
- import { Button as Button4, IconButton as IconButton5 } from "@douyinfe/semi-ui";
1399
+ import React15 from "react";
1400
+ import { I18n as I18n8 } from "@flowgram.ai/editor";
1401
+ import { Button as Button5, IconButton as IconButton4 } from "@douyinfe/semi-ui";
2858
1402
  import { IconDelete as IconDelete2, IconPlus as IconPlus3 } from "@douyinfe/semi-icons";
2859
1403
 
2860
1404
  // src/components/inputs-values/styles.tsx
2861
- import styled10 from "styled-components";
2862
- var UIRows2 = styled10.div`
1405
+ import styled6 from "styled-components";
1406
+ var UIRows2 = styled6.div`
2863
1407
  display: flex;
2864
1408
  flex-direction: column;
2865
1409
  gap: 10px;
2866
1410
  margin-bottom: 10px;
2867
1411
  `;
2868
- var UIRow3 = styled10.div`
1412
+ var UIRow3 = styled6.div`
2869
1413
  display: flex;
2870
- align-items: center;
1414
+ align-items: flex-start;
2871
1415
  gap: 5px;
2872
1416
  `;
2873
1417
 
2874
- // src/components/inputs-values/components/blur-input.tsx
2875
- import React33, { useEffect as useEffect9, useState as useState10 } from "react";
2876
- import Input6 from "@douyinfe/semi-ui/lib/es/input";
2877
- function BlurInput2(props) {
2878
- const [value, setValue] = useState10("");
2879
- useEffect9(() => {
2880
- setValue(props.value);
2881
- }, [props.value]);
2882
- return /* @__PURE__ */ React33.createElement(
2883
- Input6,
2884
- {
2885
- ...props,
2886
- value,
2887
- onChange: (value2) => {
2888
- setValue(value2);
2889
- },
2890
- onBlur: (e) => props.onChange?.(value, e)
2891
- }
2892
- );
2893
- }
2894
-
2895
1418
  // src/components/inputs-values/index.tsx
2896
1419
  function InputsValues({
2897
1420
  value,
@@ -2907,18 +1430,18 @@ function InputsValues({
2907
1430
  onChange,
2908
1431
  sortIndexKey: "extra.index"
2909
1432
  });
2910
- return /* @__PURE__ */ React34.createElement("div", null, /* @__PURE__ */ React34.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ React34.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ React34.createElement(
2911
- BlurInput2,
1433
+ return /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ React15.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ React15.createElement(
1434
+ BlurInput,
2912
1435
  {
2913
1436
  style: { width: 100, minWidth: 100, maxWidth: 100 },
2914
1437
  disabled: readonly,
2915
1438
  size: "small",
2916
1439
  value: item.key,
2917
1440
  onChange: (v) => updateKey(item.id, v),
2918
- placeholder: "Input Key"
1441
+ placeholder: I18n8.t("Input Key")
2919
1442
  }
2920
- ), /* @__PURE__ */ React34.createElement(
2921
- DynamicValueInput,
1443
+ ), /* @__PURE__ */ React15.createElement(
1444
+ InjectDynamicValueInput,
2922
1445
  {
2923
1446
  style: { flexGrow: 1 },
2924
1447
  readonly,
@@ -2931,24 +1454,37 @@ function InputsValues({
2931
1454
  strategies: [...constantProps?.strategies || []]
2932
1455
  }
2933
1456
  }
2934
- ), /* @__PURE__ */ React34.createElement(
2935
- IconButton5,
1457
+ ), /* @__PURE__ */ React15.createElement(
1458
+ IconButton4,
2936
1459
  {
2937
1460
  disabled: readonly,
2938
1461
  theme: "borderless",
2939
- icon: /* @__PURE__ */ React34.createElement(IconDelete2, { size: "small" }),
1462
+ icon: /* @__PURE__ */ React15.createElement(IconDelete2, { size: "small" }),
2940
1463
  size: "small",
2941
1464
  onClick: () => remove(item.id)
2942
1465
  }
2943
- )))), /* @__PURE__ */ React34.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React34.createElement(IconPlus3, null), size: "small", onClick: add }, "Add"));
1466
+ )))), /* @__PURE__ */ React15.createElement(
1467
+ Button5,
1468
+ {
1469
+ disabled: readonly,
1470
+ icon: /* @__PURE__ */ React15.createElement(IconPlus3, null),
1471
+ size: "small",
1472
+ onClick: () => add({
1473
+ type: "constant",
1474
+ content: "",
1475
+ schema: { type: "string" }
1476
+ })
1477
+ },
1478
+ I18n8.t("Add")
1479
+ ));
2944
1480
  }
2945
1481
 
2946
1482
  // src/components/display-schema-tree/index.tsx
2947
- import React35 from "react";
1483
+ import React16 from "react";
2948
1484
 
2949
1485
  // src/components/display-schema-tree/styles.tsx
2950
- import styled11, { css as css4 } from "styled-components";
2951
- var TreeRow = styled11.div`
1486
+ import styled7, { css as css2 } from "styled-components";
1487
+ var TreeRow = styled7.div`
2952
1488
  display: flex;
2953
1489
  align-items: center;
2954
1490
 
@@ -2961,7 +1497,7 @@ var TreeRow = styled11.div`
2961
1497
  height: 27px;
2962
1498
  white-space: nowrap;
2963
1499
  `;
2964
- var HorizontalLine = styled11.div`
1500
+ var HorizontalLine = styled7.div`
2965
1501
  position: relative;
2966
1502
 
2967
1503
  &::before,
@@ -2978,11 +1514,11 @@ var HorizontalLine = styled11.div`
2978
1514
  height: 1px;
2979
1515
  }
2980
1516
  `;
2981
- var TreeTitle = styled11.div`
1517
+ var TreeTitle = styled7.div`
2982
1518
  // overflow: hidden;
2983
1519
  // text-overflow: ellipsis;
2984
1520
  `;
2985
- var TreeLevel = styled11.div`
1521
+ var TreeLevel = styled7.div`
2986
1522
  padding-left: 30px;
2987
1523
  position: relative;
2988
1524
 
@@ -2996,7 +1532,7 @@ var TreeLevel = styled11.div`
2996
1532
  width: 1px;
2997
1533
  } */
2998
1534
  `;
2999
- var TreeItem = styled11.div`
1535
+ var TreeItem = styled7.div`
3000
1536
  position: relative;
3001
1537
 
3002
1538
  &::before {
@@ -3019,7 +1555,7 @@ var TreeItem = styled11.div`
3019
1555
  left: -22px;
3020
1556
  }
3021
1557
 
3022
- ${(props) => props.depth === 0 && css4`
1558
+ ${(props) => props.depth === 0 && css2`
3023
1559
  &::before {
3024
1560
  width: 0px !important;
3025
1561
  }
@@ -3028,7 +1564,7 @@ var TreeItem = styled11.div`
3028
1564
 
3029
1565
  // src/components/display-schema-tree/index.tsx
3030
1566
  function DisplaySchemaTree(props) {
3031
- return /* @__PURE__ */ React35.createElement(SchemaTree, { ...props });
1567
+ return /* @__PURE__ */ React16.createElement(SchemaTree, { ...props });
3032
1568
  }
3033
1569
  function SchemaTree(props) {
3034
1570
  const {
@@ -3044,27 +1580,27 @@ function SchemaTree(props) {
3044
1580
  const icon = typeManager?.getDisplayIcon(schema);
3045
1581
  let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
3046
1582
  const childEntries = Object.entries(properties || {});
3047
- return /* @__PURE__ */ React35.createElement(TreeItem, { depth, key: parentKey || "root" }, /* @__PURE__ */ React35.createElement(TreeRow, null, depth !== 0 && /* @__PURE__ */ React35.createElement(HorizontalLine, null), showIcon && icon && React35.cloneElement(icon, {
1583
+ return /* @__PURE__ */ React16.createElement(TreeItem, { depth, key: parentKey || "root" }, /* @__PURE__ */ React16.createElement(TreeRow, null, depth !== 0 && /* @__PURE__ */ React16.createElement(HorizontalLine, null), showIcon && icon && React16.cloneElement(icon, {
3048
1584
  className: "tree-icon"
3049
- }), /* @__PURE__ */ React35.createElement(TreeTitle, null, parentKey ? /* @__PURE__ */ React35.createElement(React35.Fragment, null, `${parentKey} (`, title, ")") : title)), childEntries?.length ? /* @__PURE__ */ React35.createElement(TreeLevel, null, childEntries.map(([key, value]) => /* @__PURE__ */ React35.createElement(SchemaTree, { key, ...props, parentKey: key, value, depth: depth + 1 }))) : null);
1585
+ }), /* @__PURE__ */ React16.createElement(TreeTitle, null, parentKey ? /* @__PURE__ */ React16.createElement(React16.Fragment, null, `${parentKey} (`, title, ")") : title)), childEntries?.length ? /* @__PURE__ */ React16.createElement(TreeLevel, null, childEntries.map(([key, value]) => /* @__PURE__ */ React16.createElement(SchemaTree, { key, ...props, parentKey: key, value, depth: depth + 1 }))) : null);
3050
1586
  }
3051
1587
 
3052
1588
  // src/components/display-outputs/index.tsx
3053
- import React37, { useEffect as useEffect10 } from "react";
3054
- import { JsonSchemaUtils as JsonSchemaUtils5 } from "@flowgram.ai/json-schema";
3055
- import { useCurrentScope as useCurrentScope3, useRefresh } from "@flowgram.ai/editor";
1589
+ import React18, { useEffect as useEffect5 } from "react";
1590
+ import { JsonSchemaUtils as JsonSchemaUtils4 } from "@flowgram.ai/json-schema";
1591
+ import { useCurrentScope, useRefresh } from "@flowgram.ai/editor";
3056
1592
 
3057
1593
  // src/components/display-schema-tag/index.tsx
3058
- import React36 from "react";
3059
- import { Popover as Popover7 } from "@douyinfe/semi-ui";
1594
+ import React17 from "react";
1595
+ import { Popover } from "@douyinfe/semi-ui";
3060
1596
 
3061
1597
  // src/components/display-schema-tag/styles.ts
3062
- import styled12 from "styled-components";
3063
- import { Tag as Tag4 } from "@douyinfe/semi-ui";
3064
- var PopoverContent = styled12.div`
1598
+ import styled8 from "styled-components";
1599
+ import { Tag } from "@douyinfe/semi-ui";
1600
+ var PopoverContent = styled8.div`
3065
1601
  padding: 10px;
3066
1602
  `;
3067
- var StyledTag = styled12(Tag4)`
1603
+ var StyledTag = styled8(Tag)`
3068
1604
  padding: 4px;
3069
1605
 
3070
1606
  .tag-icon {
@@ -3072,7 +1608,7 @@ var StyledTag = styled12(Tag4)`
3072
1608
  height: 12px;
3073
1609
  }
3074
1610
  `;
3075
- var TitleSpan = styled12.span`
1611
+ var TitleSpan = styled8.span`
3076
1612
  display: inline-block;
3077
1613
  margin-left: 4px;
3078
1614
  margin-top: -1px;
@@ -3084,20 +1620,20 @@ var TitleSpan = styled12.span`
3084
1620
  function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
3085
1621
  const typeManager = useTypeManager();
3086
1622
  const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
3087
- return /* @__PURE__ */ React36.createElement(
3088
- Popover7,
1623
+ return /* @__PURE__ */ React17.createElement(
1624
+ Popover,
3089
1625
  {
3090
- content: /* @__PURE__ */ React36.createElement(PopoverContent, null, /* @__PURE__ */ React36.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
1626
+ content: /* @__PURE__ */ React17.createElement(PopoverContent, null, /* @__PURE__ */ React17.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
3091
1627
  },
3092
- /* @__PURE__ */ React36.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && React36.cloneElement(icon, {
1628
+ /* @__PURE__ */ React17.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && React17.cloneElement(icon, {
3093
1629
  className: "tag-icon"
3094
- }), title && /* @__PURE__ */ React36.createElement(TitleSpan, null, title))
1630
+ }), title && /* @__PURE__ */ React17.createElement(TitleSpan, null, title))
3095
1631
  );
3096
1632
  }
3097
1633
 
3098
1634
  // src/components/display-outputs/styles.ts
3099
- import styled13 from "styled-components";
3100
- var DisplayOutputsWrapper = styled13.div`
1635
+ import styled9 from "styled-components";
1636
+ var DisplayOutputsWrapper = styled9.div`
3101
1637
  display: flex;
3102
1638
  gap: 5px;
3103
1639
  flex-wrap: wrap;
@@ -3105,9 +1641,9 @@ var DisplayOutputsWrapper = styled13.div`
3105
1641
 
3106
1642
  // src/components/display-outputs/index.tsx
3107
1643
  function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
3108
- const scope = useCurrentScope3();
1644
+ const scope = useCurrentScope();
3109
1645
  const refresh = useRefresh();
3110
- useEffect10(() => {
1646
+ useEffect5(() => {
3111
1647
  if (!displayFromScope) {
3112
1648
  return () => null;
3113
1649
  }
@@ -3121,12 +1657,12 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
3121
1657
  const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
3122
1658
  acm = {
3123
1659
  ...acm,
3124
- ...JsonSchemaUtils5.astToSchema(curr.type)?.properties || {}
1660
+ ...JsonSchemaUtils4.astToSchema(curr.type)?.properties || {}
3125
1661
  };
3126
1662
  return acm;
3127
1663
  }, {}) : value?.properties || {};
3128
1664
  const childEntries = Object.entries(properties || {});
3129
- return /* @__PURE__ */ React37.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ React37.createElement(
1665
+ return /* @__PURE__ */ React18.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ React18.createElement(
3130
1666
  DisplaySchemaTag,
3131
1667
  {
3132
1668
  key,
@@ -3139,36 +1675,25 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
3139
1675
  }
3140
1676
 
3141
1677
  // src/components/display-flow-value/index.tsx
3142
- import React38, { useMemo as useMemo11 } from "react";
3143
- import { JsonSchemaUtils as JsonSchemaUtils6 } from "@flowgram.ai/json-schema";
3144
- import { useScopeAvailable as useScopeAvailable4 } from "@flowgram.ai/editor";
1678
+ import React19, { useMemo as useMemo11 } from "react";
1679
+ import { JsonSchemaUtils as JsonSchemaUtils5 } from "@flowgram.ai/json-schema";
1680
+ import { useScopeAvailable as useScopeAvailable3 } from "@flowgram.ai/editor";
3145
1681
  function DisplayFlowValue({ value, title, showIconInTree }) {
3146
- const available = useScopeAvailable4();
1682
+ const available = useScopeAvailable3();
3147
1683
  const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
3148
1684
  const schema = useMemo11(() => {
3149
1685
  if (value?.type === "ref") {
3150
- return JsonSchemaUtils6.astToSchema(variable?.type);
1686
+ return JsonSchemaUtils5.astToSchema(variable?.type);
3151
1687
  }
3152
1688
  if (value?.type === "template") {
3153
1689
  return { type: "string" };
3154
1690
  }
3155
1691
  if (value?.type === "constant") {
3156
- if (value?.schema) {
3157
- return value?.schema;
3158
- }
3159
- if (typeof value?.content === "string") {
3160
- return { type: "string" };
3161
- }
3162
- if (typeof value?.content === "number") {
3163
- return { type: "number" };
3164
- }
3165
- if (typeof value?.content === "boolean") {
3166
- return { type: "boolean" };
3167
- }
1692
+ return FlowValueUtils.inferConstantJsonSchema(value);
3168
1693
  }
3169
1694
  return { type: "unknown" };
3170
1695
  }, [value, variable?.hash]);
3171
- return /* @__PURE__ */ React38.createElement(
1696
+ return /* @__PURE__ */ React19.createElement(
3172
1697
  DisplaySchemaTag,
3173
1698
  {
3174
1699
  title,
@@ -3180,11 +1705,13 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
3180
1705
  }
3181
1706
 
3182
1707
  // src/components/display-inputs-values/index.tsx
3183
- import React39 from "react";
1708
+ import React20, { useMemo as useMemo12 } from "react";
1709
+ import { isPlainObject } from "lodash-es";
1710
+ import { useScopeAvailable as useScopeAvailable4 } from "@flowgram.ai/editor";
3184
1711
 
3185
1712
  // src/components/display-inputs-values/styles.ts
3186
- import styled14 from "styled-components";
3187
- var DisplayInputsWrapper = styled14.div`
1713
+ import styled10 from "styled-components";
1714
+ var DisplayInputsWrapper = styled10.div`
3188
1715
  display: flex;
3189
1716
  gap: 5px;
3190
1717
  flex-wrap: wrap;
@@ -3193,30 +1720,58 @@ var DisplayInputsWrapper = styled14.div`
3193
1720
  // src/components/display-inputs-values/index.tsx
3194
1721
  function DisplayInputsValues({ value, showIconInTree }) {
3195
1722
  const childEntries = Object.entries(value || {});
3196
- return /* @__PURE__ */ React39.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ React39.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
1723
+ return /* @__PURE__ */ React20.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => {
1724
+ if (FlowValueUtils.isFlowValue(value2)) {
1725
+ return /* @__PURE__ */ React20.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree });
1726
+ }
1727
+ if (isPlainObject(value2)) {
1728
+ return /* @__PURE__ */ React20.createElement(
1729
+ DisplayInputsValueAllInTag,
1730
+ {
1731
+ key,
1732
+ title: key,
1733
+ value: value2,
1734
+ showIconInTree
1735
+ }
1736
+ );
1737
+ }
1738
+ return null;
1739
+ }));
1740
+ }
1741
+ function DisplayInputsValueAllInTag({
1742
+ value,
1743
+ title,
1744
+ showIconInTree
1745
+ }) {
1746
+ const available = useScopeAvailable4();
1747
+ const schema = useMemo12(
1748
+ () => FlowValueUtils.inferJsonSchema(value, available.scope),
1749
+ [available.version, value]
1750
+ );
1751
+ return /* @__PURE__ */ React20.createElement(DisplaySchemaTag, { title, value: schema, showIconInTree });
3197
1752
  }
3198
1753
 
3199
1754
  // src/components/assign-rows/index.tsx
3200
- import React42 from "react";
1755
+ import React23 from "react";
3201
1756
  import { FieldArray } from "@flowgram.ai/editor";
3202
- import { Button as Button5 } from "@douyinfe/semi-ui";
1757
+ import { Button as Button6 } from "@douyinfe/semi-ui";
3203
1758
  import { IconPlus as IconPlus4 } from "@douyinfe/semi-icons";
3204
1759
 
3205
1760
  // src/components/assign-row/index.tsx
3206
- import React41 from "react";
3207
- import { IconButton as IconButton6 } from "@douyinfe/semi-ui";
1761
+ import React22 from "react";
1762
+ import { IconButton as IconButton5 } from "@douyinfe/semi-ui";
3208
1763
  import { IconMinus as IconMinus2 } from "@douyinfe/semi-icons";
3209
1764
 
3210
1765
  // src/components/assign-row/components/blur-input.tsx
3211
- import React40, { useEffect as useEffect11, useState as useState11 } from "react";
3212
- import Input7 from "@douyinfe/semi-ui/lib/es/input";
3213
- function BlurInput3(props) {
3214
- const [value, setValue] = useState11("");
3215
- useEffect11(() => {
1766
+ import React21, { useEffect as useEffect6, useState as useState6 } from "react";
1767
+ import Input6 from "@douyinfe/semi-ui/lib/es/input";
1768
+ function BlurInput2(props) {
1769
+ const [value, setValue] = useState6("");
1770
+ useEffect6(() => {
3216
1771
  setValue(props.value);
3217
1772
  }, [props.value]);
3218
- return /* @__PURE__ */ React40.createElement(
3219
- Input7,
1773
+ return /* @__PURE__ */ React21.createElement(
1774
+ Input6,
3220
1775
  {
3221
1776
  ...props,
3222
1777
  value,
@@ -3238,8 +1793,8 @@ function AssignRow(props) {
3238
1793
  onDelete,
3239
1794
  readonly
3240
1795
  } = props;
3241
- return /* @__PURE__ */ React41.createElement("div", { style: { display: "flex", alignItems: "center", gap: 5 } }, /* @__PURE__ */ React41.createElement("div", { style: { width: 150, minWidth: 150, maxWidth: 150 } }, value?.operator === "assign" ? /* @__PURE__ */ React41.createElement(
3242
- VariableSelector,
1796
+ return /* @__PURE__ */ React22.createElement("div", { style: { display: "flex", alignItems: "center", gap: 5 } }, /* @__PURE__ */ React22.createElement("div", { style: { width: 150, minWidth: 150, maxWidth: 150 } }, value?.operator === "assign" ? /* @__PURE__ */ React22.createElement(
1797
+ InjectVariableSelector,
3243
1798
  {
3244
1799
  style: { width: "100%", height: 26 },
3245
1800
  value: value?.left?.content,
@@ -3249,8 +1804,8 @@ function AssignRow(props) {
3249
1804
  left: { type: "ref", content: v }
3250
1805
  })
3251
1806
  }
3252
- ) : /* @__PURE__ */ React41.createElement(
3253
- BlurInput3,
1807
+ ) : /* @__PURE__ */ React22.createElement(
1808
+ BlurInput2,
3254
1809
  {
3255
1810
  style: { height: 26 },
3256
1811
  size: "small",
@@ -3261,8 +1816,8 @@ function AssignRow(props) {
3261
1816
  left: v
3262
1817
  })
3263
1818
  }
3264
- )), /* @__PURE__ */ React41.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ React41.createElement(
3265
- DynamicValueInput,
1819
+ )), /* @__PURE__ */ React22.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ React22.createElement(
1820
+ InjectDynamicValueInput,
3266
1821
  {
3267
1822
  readonly,
3268
1823
  value: value?.right,
@@ -3271,12 +1826,12 @@ function AssignRow(props) {
3271
1826
  right: v
3272
1827
  })
3273
1828
  }
3274
- )), onDelete && /* @__PURE__ */ React41.createElement("div", null, /* @__PURE__ */ React41.createElement(
3275
- IconButton6,
1829
+ )), onDelete && /* @__PURE__ */ React22.createElement("div", null, /* @__PURE__ */ React22.createElement(
1830
+ IconButton5,
3276
1831
  {
3277
1832
  size: "small",
3278
1833
  theme: "borderless",
3279
- icon: /* @__PURE__ */ React41.createElement(IconMinus2, null),
1834
+ icon: /* @__PURE__ */ React22.createElement(IconMinus2, null),
3280
1835
  onClick: () => onDelete?.()
3281
1836
  }
3282
1837
  )));
@@ -3285,7 +1840,7 @@ function AssignRow(props) {
3285
1840
  // src/components/assign-rows/index.tsx
3286
1841
  function AssignRows(props) {
3287
1842
  const { name, readonly } = props;
3288
- return /* @__PURE__ */ React42.createElement(FieldArray, { name }, ({ field }) => /* @__PURE__ */ React42.createElement(React42.Fragment, null, field.map((childField, index) => /* @__PURE__ */ React42.createElement(
1843
+ return /* @__PURE__ */ React23.createElement(FieldArray, { name }, ({ field }) => /* @__PURE__ */ React23.createElement(React23.Fragment, null, field.map((childField, index) => /* @__PURE__ */ React23.createElement(
3289
1844
  AssignRow,
3290
1845
  {
3291
1846
  key: childField.key,
@@ -3296,27 +1851,341 @@ function AssignRows(props) {
3296
1851
  },
3297
1852
  onDelete: () => field.remove(index)
3298
1853
  }
3299
- )), /* @__PURE__ */ React42.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ React42.createElement(
3300
- Button5,
1854
+ )), /* @__PURE__ */ React23.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ React23.createElement(
1855
+ Button6,
3301
1856
  {
3302
1857
  size: "small",
3303
1858
  theme: "borderless",
3304
- icon: /* @__PURE__ */ React42.createElement(IconPlus4, null),
1859
+ icon: /* @__PURE__ */ React23.createElement(IconPlus4, null),
3305
1860
  onClick: () => field.append({ operator: "assign" })
3306
1861
  },
3307
1862
  "Assign"
3308
- ), /* @__PURE__ */ React42.createElement(
3309
- Button5,
1863
+ ), /* @__PURE__ */ React23.createElement(
1864
+ Button6,
3310
1865
  {
3311
1866
  size: "small",
3312
1867
  theme: "borderless",
3313
- icon: /* @__PURE__ */ React42.createElement(IconPlus4, null),
1868
+ icon: /* @__PURE__ */ React23.createElement(IconPlus4, null),
3314
1869
  onClick: () => field.append({ operator: "declare" })
3315
1870
  },
3316
1871
  "Declaration"
3317
1872
  ))));
3318
1873
  }
3319
1874
 
1875
+ // src/components/inputs-values-tree/index.tsx
1876
+ import React26 from "react";
1877
+ import { I18n as I18n10 } from "@flowgram.ai/editor";
1878
+ import { Button as Button7 } from "@douyinfe/semi-ui";
1879
+ import { IconPlus as IconPlus5 } from "@douyinfe/semi-icons";
1880
+
1881
+ // src/components/inputs-values-tree/styles.tsx
1882
+ import React24 from "react";
1883
+ import styled11, { css as css3 } from "styled-components";
1884
+ import Icon4 from "@douyinfe/semi-icons";
1885
+ var UIContainer5 = styled11.div``;
1886
+ var UIRow4 = styled11.div`
1887
+ display: flex;
1888
+ align-items: flex-start;
1889
+ gap: 5px;
1890
+ `;
1891
+ var UICollapseTrigger2 = styled11.div`
1892
+ cursor: pointer;
1893
+ margin-right: 5px;
1894
+ `;
1895
+ var UITreeItems2 = styled11.div`
1896
+ display: grid;
1897
+ grid-template-columns: auto 1fr;
1898
+
1899
+ ${({ $shrink }) => $shrink && css3`
1900
+ padding-left: 3px;
1901
+ margin-top: 10px;
1902
+ `}
1903
+ `;
1904
+ var UITreeItemLeft2 = styled11.div`
1905
+ grid-column: 1;
1906
+ position: relative;
1907
+ width: 16px;
1908
+
1909
+ ${({ $showLine, $isLast, $showCollapse }) => {
1910
+ let height = $isLast ? "24px" : "100%";
1911
+ let width = $showCollapse ? "12px" : "30px";
1912
+ return $showLine && css3`
1913
+ &::before {
1914
+ /* 竖线 */
1915
+ content: '';
1916
+ height: ${height};
1917
+ position: absolute;
1918
+ left: -14px;
1919
+ top: -16px;
1920
+ width: 1px;
1921
+ background: #d9d9d9;
1922
+ display: block;
1923
+ }
1924
+
1925
+ &::after {
1926
+ /* 横线 */
1927
+ content: '';
1928
+ position: absolute;
1929
+ left: -14px; // 横线起点和竖线对齐
1930
+ top: 8px; // 跟随你的行高调整
1931
+ width: ${width}; // 横线长度
1932
+ height: 1px;
1933
+ background: #d9d9d9;
1934
+ display: block;
1935
+ }
1936
+ `;
1937
+ }}
1938
+ `;
1939
+ var UITreeItemRight2 = styled11.div`
1940
+ grid-column: 2;
1941
+ margin-bottom: 10px;
1942
+
1943
+ &:last-child {
1944
+ margin-bottom: 0px;
1945
+ }
1946
+ `;
1947
+ var UITreeItemMain2 = styled11.div`
1948
+ display: flex;
1949
+ flex-direction: column;
1950
+ gap: 10px;
1951
+ position: relative;
1952
+ `;
1953
+ var UICollapsible2 = styled11.div`
1954
+ display: none;
1955
+
1956
+ ${({ $collapse }) => $collapse && css3`
1957
+ display: block;
1958
+ `}
1959
+ `;
1960
+ var UIActions2 = styled11.div`
1961
+ white-space: nowrap;
1962
+ `;
1963
+ var iconAddChildrenSvg2 = /* @__PURE__ */ React24.createElement(
1964
+ "svg",
1965
+ {
1966
+ className: "icon-icon icon-icon-coz_add_node ",
1967
+ width: "1em",
1968
+ height: "1em",
1969
+ viewBox: "0 0 24 24",
1970
+ fill: "currentColor",
1971
+ xmlns: "http://www.w3.org/2000/svg"
1972
+ },
1973
+ /* @__PURE__ */ React24.createElement(
1974
+ "path",
1975
+ {
1976
+ fillRule: "evenodd",
1977
+ clipRule: "evenodd",
1978
+ d: "M11 6.49988C11 8.64148 9.50397 10.4337 7.49995 10.8884V15.4998C7.49995 16.0521 7.94767 16.4998 8.49995 16.4998H11.208C11.0742 16.8061 11 17.1443 11 17.4998C11 17.8554 11.0742 18.1936 11.208 18.4998H8.49995C6.8431 18.4998 5.49995 17.1567 5.49995 15.4998V10.8884C3.49599 10.4336 2 8.64145 2 6.49988C2 4.0146 4.01472 1.99988 6.5 1.99988C8.98528 1.99988 11 4.0146 11 6.49988ZM6.5 8.99988C7.88071 8.99988 9 7.88059 9 6.49988C9 5.11917 7.88071 3.99988 6.5 3.99988C5.11929 3.99988 4 5.11917 4 6.49988C4 7.88059 5.11929 8.99988 6.5 8.99988Z"
1979
+ }
1980
+ ),
1981
+ /* @__PURE__ */ React24.createElement("path", { d: "M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z" })
1982
+ );
1983
+ var IconAddChildren2 = () => /* @__PURE__ */ React24.createElement(Icon4, { size: "small", svg: iconAddChildrenSvg2 });
1984
+
1985
+ // src/components/inputs-values-tree/row.tsx
1986
+ import React25, { useMemo as useMemo14, useState as useState7 } from "react";
1987
+ import { I18n as I18n9 } from "@flowgram.ai/editor";
1988
+ import { IconButton as IconButton6, Input as Input7 } from "@douyinfe/semi-ui";
1989
+ import { IconChevronDown as IconChevronDown2, IconChevronRight as IconChevronRight2, IconDelete as IconDelete3 } from "@douyinfe/semi-icons";
1990
+
1991
+ // src/components/inputs-values-tree/hooks/use-child-list.tsx
1992
+ import { useMemo as useMemo13 } from "react";
1993
+ import { isPlainObject as isPlainObject2 } from "lodash-es";
1994
+ function useChildList(value, onChange) {
1995
+ const canAddField = useMemo13(() => {
1996
+ if (!isPlainObject2(value)) {
1997
+ return false;
1998
+ }
1999
+ if (FlowValueUtils.isFlowValue(value)) {
2000
+ return FlowValueUtils.isConstant(value) && value?.schema?.type === "object";
2001
+ }
2002
+ return true;
2003
+ }, [value]);
2004
+ const objectListValue = useMemo13(() => {
2005
+ if (isPlainObject2(value)) {
2006
+ if (FlowValueUtils.isFlowValue(value)) {
2007
+ return void 0;
2008
+ }
2009
+ return value;
2010
+ }
2011
+ return void 0;
2012
+ }, [value]);
2013
+ const { list, add, updateKey, updateValue, remove } = useObjectList({
2014
+ value: objectListValue,
2015
+ onChange: (value2) => {
2016
+ onChange?.(value2);
2017
+ },
2018
+ sortIndexKey: (value2) => FlowValueUtils.isFlowValue(value2) ? "extra.index" : ""
2019
+ });
2020
+ const hasChildren = useMemo13(
2021
+ () => canAddField && (list.length > 0 || Object.keys(objectListValue || {}).length > 0),
2022
+ [canAddField, list.length, Object.keys(objectListValue || {}).length]
2023
+ );
2024
+ return {
2025
+ canAddField,
2026
+ hasChildren,
2027
+ list,
2028
+ add,
2029
+ updateKey,
2030
+ updateValue,
2031
+ remove
2032
+ };
2033
+ }
2034
+
2035
+ // src/components/inputs-values-tree/row.tsx
2036
+ var AddObjectChildStrategy = {
2037
+ hit: (schema) => schema.type === "object",
2038
+ Renderer: () => /* @__PURE__ */ React25.createElement(
2039
+ Input7,
2040
+ {
2041
+ size: "small",
2042
+ disabled: true,
2043
+ style: { pointerEvents: "none" },
2044
+ value: I18n9.t("Configure via child fields")
2045
+ }
2046
+ )
2047
+ };
2048
+ function InputValueRow(props) {
2049
+ const {
2050
+ keyName,
2051
+ value,
2052
+ $level = 0,
2053
+ onUpdateKey,
2054
+ onUpdateValue,
2055
+ $isLast,
2056
+ onRemove,
2057
+ constantProps,
2058
+ hasError,
2059
+ readonly
2060
+ } = props;
2061
+ const [collapse, setCollapse] = useState7(false);
2062
+ const { canAddField, hasChildren, list, add, updateKey, updateValue, remove } = useChildList(
2063
+ value,
2064
+ onUpdateValue
2065
+ );
2066
+ const strategies = useMemo14(
2067
+ () => [...hasChildren ? [AddObjectChildStrategy] : [], ...constantProps?.strategies || []],
2068
+ [hasChildren, constantProps?.strategies]
2069
+ );
2070
+ const flowDisplayValue = useMemo14(
2071
+ () => hasChildren ? {
2072
+ type: "constant",
2073
+ schema: { type: "object" }
2074
+ } : value,
2075
+ [hasChildren, value]
2076
+ );
2077
+ return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(UITreeItemLeft2, { $isLast, $showLine: $level > 0, $showCollapse: hasChildren }, hasChildren && /* @__PURE__ */ React25.createElement(UICollapseTrigger2, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React25.createElement(IconChevronDown2, { size: "small" }) : /* @__PURE__ */ React25.createElement(IconChevronRight2, { size: "small" }))), /* @__PURE__ */ React25.createElement(UITreeItemRight2, null, /* @__PURE__ */ React25.createElement(UITreeItemMain2, null, /* @__PURE__ */ React25.createElement(UIRow4, null, /* @__PURE__ */ React25.createElement(
2078
+ BlurInput,
2079
+ {
2080
+ style: { width: 100, minWidth: 100, maxWidth: 100 },
2081
+ disabled: readonly,
2082
+ size: "small",
2083
+ value: keyName,
2084
+ onChange: (v) => onUpdateKey?.(v),
2085
+ placeholder: I18n9.t("Input Key")
2086
+ }
2087
+ ), /* @__PURE__ */ React25.createElement(
2088
+ InjectDynamicValueInput,
2089
+ {
2090
+ style: { flexGrow: 1 },
2091
+ readonly,
2092
+ value: flowDisplayValue,
2093
+ onChange: (v) => onUpdateValue(v),
2094
+ hasError,
2095
+ constantProps: {
2096
+ ...constantProps,
2097
+ strategies
2098
+ }
2099
+ }
2100
+ ), /* @__PURE__ */ React25.createElement(UIActions2, null, canAddField && /* @__PURE__ */ React25.createElement(
2101
+ IconButton6,
2102
+ {
2103
+ disabled: readonly,
2104
+ size: "small",
2105
+ theme: "borderless",
2106
+ icon: /* @__PURE__ */ React25.createElement(IconAddChildren2, null),
2107
+ onClick: () => {
2108
+ add({
2109
+ type: "constant",
2110
+ content: "",
2111
+ schema: { type: "string" }
2112
+ });
2113
+ setCollapse(true);
2114
+ }
2115
+ }
2116
+ ), /* @__PURE__ */ React25.createElement(
2117
+ IconButton6,
2118
+ {
2119
+ disabled: readonly,
2120
+ theme: "borderless",
2121
+ icon: /* @__PURE__ */ React25.createElement(IconDelete3, { size: "small" }),
2122
+ size: "small",
2123
+ onClick: () => onRemove?.()
2124
+ }
2125
+ )))), hasChildren && /* @__PURE__ */ React25.createElement(UICollapsible2, { $collapse: collapse }, /* @__PURE__ */ React25.createElement(UITreeItems2, { $shrink: true }, list.map((_item, index) => /* @__PURE__ */ React25.createElement(
2126
+ InputValueRow,
2127
+ {
2128
+ readonly,
2129
+ hasError,
2130
+ constantProps,
2131
+ key: _item.id,
2132
+ keyName: _item.key,
2133
+ value: _item.value,
2134
+ $level: $level + 1,
2135
+ onUpdateValue: (_v) => {
2136
+ updateValue(_item.id, _v);
2137
+ },
2138
+ onUpdateKey: (k) => {
2139
+ updateKey(_item.id, k);
2140
+ },
2141
+ onRemove: () => {
2142
+ remove(_item.id);
2143
+ },
2144
+ $isLast: index === list.length - 1
2145
+ }
2146
+ ))))));
2147
+ }
2148
+
2149
+ // src/components/inputs-values-tree/index.tsx
2150
+ function InputsValuesTree(props) {
2151
+ const { value, onChange, readonly, hasError, constantProps } = props;
2152
+ const { list, updateKey, updateValue, remove, add } = useObjectList({
2153
+ value,
2154
+ onChange,
2155
+ sortIndexKey: (value2) => FlowValueUtils.isFlowValue(value2) ? "extra.index" : ""
2156
+ });
2157
+ return /* @__PURE__ */ React26.createElement("div", null, /* @__PURE__ */ React26.createElement(UITreeItems2, null, list.map((item) => /* @__PURE__ */ React26.createElement(
2158
+ InputValueRow,
2159
+ {
2160
+ key: item.id,
2161
+ keyName: item.key,
2162
+ value: item.value,
2163
+ onUpdateKey: (key) => updateKey(item.id, key),
2164
+ onUpdateValue: (value2) => updateValue(item.id, value2),
2165
+ onRemove: () => remove(item.id),
2166
+ readonly,
2167
+ hasError,
2168
+ constantProps
2169
+ }
2170
+ ))), /* @__PURE__ */ React26.createElement(
2171
+ Button7,
2172
+ {
2173
+ style: { marginTop: 10, marginLeft: 16 },
2174
+ disabled: readonly,
2175
+ icon: /* @__PURE__ */ React26.createElement(IconPlus5, null),
2176
+ size: "small",
2177
+ onClick: () => {
2178
+ add({
2179
+ type: "constant",
2180
+ content: "",
2181
+ schema: { type: "string" }
2182
+ });
2183
+ }
2184
+ },
2185
+ I18n10.t("Add")
2186
+ ));
2187
+ }
2188
+
3320
2189
  // src/effects/provide-batch-input/index.ts
3321
2190
  import {
3322
2191
  ASTFactory,
@@ -3353,7 +2222,6 @@ var provideBatchInputEffect = createEffectFromVariableProvider({
3353
2222
  });
3354
2223
 
3355
2224
  // src/effects/auto-rename-ref/index.ts
3356
- import { isArray, isObject as isObject2, uniq } from "lodash";
3357
2225
  import {
3358
2226
  DataEvent,
3359
2227
  VariableFieldKeyRenameService
@@ -3380,7 +2248,7 @@ var autoRenameRefEffect = [
3380
2248
  form.setValueIn(_drilldownName, _v);
3381
2249
  }
3382
2250
  } else if (_v.type === "template") {
3383
- const templateKeyPaths = getTemplateKeyPaths(_v);
2251
+ const templateKeyPaths = FlowValueUtils.getTemplateKeyPaths(_v);
3384
2252
  let hasMatch = false;
3385
2253
  templateKeyPaths.forEach((_keyPath) => {
3386
2254
  if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
@@ -3410,44 +2278,17 @@ var autoRenameRefEffect = [
3410
2278
  function isKeyPathMatch(keyPath = [], targetKeyPath) {
3411
2279
  return targetKeyPath.every((_key, index) => _key === keyPath[index]);
3412
2280
  }
3413
- function getTemplateKeyPaths(value) {
3414
- const keyPathReg = /{{(.*?)}}/g;
3415
- return uniq(value.content?.match(keyPathReg) || []).map(
3416
- (_keyPath) => _keyPath.slice(2, -2).split(".")
3417
- );
3418
- }
3419
- function isRef(value) {
3420
- return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
3421
- }
3422
- function isTemplate(value) {
3423
- return value?.type === "template" && typeof value?.content === "string";
3424
- }
3425
2281
  function traverseRef(name, value, cb) {
3426
- if (isObject2(value)) {
3427
- if (isRef(value)) {
3428
- cb(name, value);
3429
- return;
3430
- }
3431
- if (isTemplate(value)) {
3432
- cb(name, value);
3433
- return;
3434
- }
3435
- Object.entries(value).forEach(([_key, _value]) => {
3436
- traverseRef(`${name}.${_key}`, _value, cb);
3437
- });
3438
- return;
3439
- }
3440
- if (isArray(value)) {
3441
- value.forEach((_value, idx) => {
3442
- traverseRef(`${name}[${idx}]`, _value, cb);
3443
- });
3444
- return;
2282
+ for (const { value: _v, path } of FlowValueUtils.traverse(value, {
2283
+ includeTypes: ["ref", "template"],
2284
+ path: name
2285
+ })) {
2286
+ cb(path, _v);
3445
2287
  }
3446
- return;
3447
2288
  }
3448
2289
 
3449
2290
  // src/effects/provide-json-schema-outputs/index.ts
3450
- import { JsonSchemaUtils as JsonSchemaUtils7 } from "@flowgram.ai/json-schema";
2291
+ import { JsonSchemaUtils as JsonSchemaUtils6 } from "@flowgram.ai/json-schema";
3451
2292
  import {
3452
2293
  ASTFactory as ASTFactory2,
3453
2294
  createEffectFromVariableProvider as createEffectFromVariableProvider2,
@@ -3461,7 +2302,7 @@ var provideJsonSchemaOutputs = createEffectFromVariableProvider2({
3461
2302
  title: getNodeForm2(ctx.node)?.getValueIn("title") || ctx.node.id,
3462
2303
  icon: ctx.node.getNodeRegistry().info?.icon
3463
2304
  },
3464
- type: JsonSchemaUtils7.schemaToAST(value)
2305
+ type: JsonSchemaUtils6.schemaToAST(value)
3465
2306
  })
3466
2307
  ]
3467
2308
  });
@@ -3489,7 +2330,7 @@ var syncVariableTitle = [
3489
2330
  ];
3490
2331
 
3491
2332
  // src/effects/validate-when-variable-sync/index.ts
3492
- import { isEmpty } from "lodash";
2333
+ import { isEmpty } from "lodash-es";
3493
2334
  import {
3494
2335
  DataEvent as DataEvent3,
3495
2336
  getNodeScope,
@@ -3539,7 +2380,7 @@ var listenRefValueChange = (cb) => [
3539
2380
  ];
3540
2381
 
3541
2382
  // src/effects/listen-ref-schema-change/index.ts
3542
- import { JsonSchemaUtils as JsonSchemaUtils8 } from "@flowgram.ai/json-schema";
2383
+ import { JsonSchemaUtils as JsonSchemaUtils7 } from "@flowgram.ai/json-schema";
3543
2384
  import {
3544
2385
  DataEvent as DataEvent5,
3545
2386
  getNodeScope as getNodeScope3
@@ -3555,7 +2396,7 @@ var listenRefSchemaChange = (cb) => [
3555
2396
  const disposable = getNodeScope3(context.node).available.trackByKeyPath(
3556
2397
  value?.content || [],
3557
2398
  (_type) => {
3558
- cb({ ...params, schema: JsonSchemaUtils8.astToSchema(_type) });
2399
+ cb({ ...params, schema: JsonSchemaUtils7.astToSchema(_type) });
3559
2400
  },
3560
2401
  {
3561
2402
  selector: (_v) => _v?.type
@@ -3568,68 +2409,6 @@ var listenRefSchemaChange = (cb) => [
3568
2409
  }
3569
2410
  ];
3570
2411
 
3571
- // src/shared/format-legacy-refs/index.ts
3572
- import { isObject as isObject3 } from "lodash";
3573
- function formatLegacyRefOnSubmit(value) {
3574
- if (isObject3(value)) {
3575
- if (isLegacyFlowRefValueSchema(value)) {
3576
- return formatLegacyRefToNewRef(value);
3577
- }
3578
- return Object.fromEntries(
3579
- Object.entries(value).map(([key, value2]) => [
3580
- key,
3581
- formatLegacyRefOnSubmit(value2)
3582
- ])
3583
- );
3584
- }
3585
- if (Array.isArray(value)) {
3586
- return value.map(formatLegacyRefOnSubmit);
3587
- }
3588
- return value;
3589
- }
3590
- function formatLegacyRefOnInit(value) {
3591
- if (isObject3(value)) {
3592
- if (isNewFlowRefValueSchema(value)) {
3593
- return formatNewRefToLegacyRef(value);
3594
- }
3595
- return Object.fromEntries(
3596
- Object.entries(value).map(([key, value2]) => [
3597
- key,
3598
- formatLegacyRefOnInit(value2)
3599
- ])
3600
- );
3601
- }
3602
- if (Array.isArray(value)) {
3603
- return value.map(formatLegacyRefOnInit);
3604
- }
3605
- return value;
3606
- }
3607
- function isLegacyFlowRefValueSchema(value) {
3608
- return isObject3(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
3609
- }
3610
- function isNewFlowRefValueSchema(value) {
3611
- return isObject3(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
3612
- }
3613
- function formatLegacyRefToNewRef(value) {
3614
- const keyPath = value.content.split(".");
3615
- if (keyPath[1] === "outputs") {
3616
- return {
3617
- type: "ref",
3618
- content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
3619
- };
3620
- }
3621
- return {
3622
- type: "ref",
3623
- content: keyPath
3624
- };
3625
- }
3626
- function formatNewRefToLegacyRef(value) {
3627
- return {
3628
- type: "ref",
3629
- content: value.content.join(".")
3630
- };
3631
- }
3632
-
3633
2412
  // src/form-plugins/batch-outputs-plugin/index.ts
3634
2413
  import {
3635
2414
  ASTFactory as ASTFactory3,
@@ -3706,13 +2485,8 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
3706
2485
  });
3707
2486
 
3708
2487
  // src/form-plugins/infer-inputs-plugin/index.ts
3709
- import { get as get2, set as set2 } from "lodash";
3710
- import { JsonSchemaUtils as JsonSchemaUtils9 } from "@flowgram.ai/json-schema";
3711
- import {
3712
- defineFormPluginCreator as defineFormPluginCreator2,
3713
- getNodePrivateScope as getNodePrivateScope3,
3714
- getNodeScope as getNodeScope5
3715
- } from "@flowgram.ai/editor";
2488
+ import { get as get2, set as set2 } from "lodash-es";
2489
+ import { defineFormPluginCreator as defineFormPluginCreator2, getNodePrivateScope as getNodePrivateScope3, getNodeScope as getNodeScope5 } from "@flowgram.ai/editor";
3716
2490
  var createInferInputsPlugin = defineFormPluginCreator2({
3717
2491
  onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
3718
2492
  if (!sourceKey || !targetKey) {
@@ -3722,7 +2496,7 @@ var createInferInputsPlugin = defineFormPluginCreator2({
3722
2496
  set2(
3723
2497
  formData,
3724
2498
  targetKey,
3725
- infer(
2499
+ FlowValueUtils.inferJsonSchema(
3726
2500
  get2(formData, sourceKey),
3727
2501
  scope === "private" ? getNodePrivateScope3(ctx.node) : getNodeScope5(ctx.node)
3728
2502
  )
@@ -3731,63 +2505,10 @@ var createInferInputsPlugin = defineFormPluginCreator2({
3731
2505
  });
3732
2506
  }
3733
2507
  });
3734
- function isRef2(value) {
3735
- return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
3736
- }
3737
- function isTemplate2(value) {
3738
- return value?.type === "template" && typeof value?.content === "string";
3739
- }
3740
- function isConstant(value) {
3741
- return value?.type === "constant" && typeof value?.content !== "undefined";
3742
- }
3743
- var infer = (values, scope) => {
3744
- if (typeof values === "object") {
3745
- if (isConstant(values)) {
3746
- if (values?.schema) {
3747
- return values.schema;
3748
- }
3749
- if (typeof values.content === "string") {
3750
- return {
3751
- type: "string"
3752
- };
3753
- }
3754
- if (typeof values.content === "number") {
3755
- return {
3756
- type: "number"
3757
- };
3758
- }
3759
- if (typeof values.content === "boolean") {
3760
- return {
3761
- type: "boolean"
3762
- };
3763
- }
3764
- }
3765
- if (isRef2(values)) {
3766
- const variable = scope.available.getByKeyPath(values?.content);
3767
- const schema = variable?.type ? JsonSchemaUtils9.astToSchema(variable?.type) : void 0;
3768
- return schema;
3769
- }
3770
- if (isTemplate2(values)) {
3771
- return {
3772
- type: "string"
3773
- };
3774
- }
3775
- return {
3776
- type: "object",
3777
- properties: Object.keys(values).reduce((acc, key) => {
3778
- const schema = infer(values[key], scope);
3779
- if (schema) {
3780
- acc[key] = schema;
3781
- }
3782
- return acc;
3783
- }, {})
3784
- };
3785
- }
3786
- };
3787
2508
 
3788
2509
  // src/form-plugins/infer-assign-plugin/index.ts
3789
- import { set as set3, uniqBy } from "lodash";
3790
- import { JsonSchemaUtils as JsonSchemaUtils10 } from "@flowgram.ai/json-schema";
2510
+ import { set as set3, uniqBy } from "lodash-es";
2511
+ import { JsonSchemaUtils as JsonSchemaUtils8 } from "@flowgram.ai/json-schema";
3791
2512
  import {
3792
2513
  ASTFactory as ASTFactory4,
3793
2514
  createEffectFromVariableProvider as createEffectFromVariableProvider4,
@@ -3818,7 +2539,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
3818
2539
  properties: declareRows.map(
3819
2540
  (_v) => ASTFactory4.createProperty({
3820
2541
  key: _v.left,
3821
- type: _v.right?.type === "constant" ? JsonSchemaUtils10.schemaToAST(_v.right?.schema || {}) : void 0,
2542
+ type: _v.right?.type === "constant" ? JsonSchemaUtils8.schemaToAST(_v.right?.schema || {}) : void 0,
3822
2543
  initializer: _v.right?.type === "ref" ? ASTFactory4.createKeyPathExpression({
3823
2544
  keyPath: _v.right?.content || []
3824
2545
  }) : {}
@@ -3834,7 +2555,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
3834
2555
  set3(
3835
2556
  formData,
3836
2557
  outputKey,
3837
- JsonSchemaUtils10.astToSchema(getNodeScope6(ctx.node).output.variables?.[0]?.type)
2558
+ JsonSchemaUtils8.astToSchema(getNodeScope6(ctx.node).output.variables?.[0]?.type)
3838
2559
  );
3839
2560
  return formData;
3840
2561
  });
@@ -3842,7 +2563,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
3842
2563
  });
3843
2564
 
3844
2565
  // src/validate/validate-flow-value/index.tsx
3845
- import { isNil, uniq as uniq2 } from "lodash";
2566
+ import { isNil } from "lodash-es";
3846
2567
  import { FeedbackLevel, getNodeScope as getNodeScope7 } from "@flowgram.ai/editor";
3847
2568
  function validateFlowValue(value, ctx) {
3848
2569
  const { node, required, errorMessages } = ctx;
@@ -3866,7 +2587,7 @@ function validateFlowValue(value, ctx) {
3866
2587
  }
3867
2588
  }
3868
2589
  if (value?.type === "template") {
3869
- const allRefs = getTemplateKeyPaths2(value);
2590
+ const allRefs = FlowValueUtils.getTemplateKeyPaths(value);
3870
2591
  for (const ref of allRefs) {
3871
2592
  const variable = getNodeScope7(node).available.getByKeyPath(ref);
3872
2593
  if (!variable) {
@@ -3879,28 +2600,30 @@ function validateFlowValue(value, ctx) {
3879
2600
  }
3880
2601
  return void 0;
3881
2602
  }
3882
- function getTemplateKeyPaths2(value) {
3883
- const keyPathReg = /{{(.*?)}}/g;
3884
- return uniq2(value.content?.match(keyPathReg) || []).map(
3885
- (_keyPath) => _keyPath.slice(2, -2).split(".")
3886
- );
3887
- }
3888
2603
  export {
3889
2604
  AssignRow,
3890
2605
  AssignRows,
3891
2606
  BatchOutputs,
3892
2607
  BatchVariableSelector,
2608
+ BlurInput,
3893
2609
  CodeEditor,
3894
2610
  CodeEditorMini,
3895
2611
  ConditionRow,
3896
2612
  ConstantInput,
2613
+ DBConditionRow,
3897
2614
  DisplayFlowValue,
2615
+ DisplayInputsValueAllInTag,
3898
2616
  DisplayInputsValues,
3899
2617
  DisplayOutputs,
3900
2618
  DisplaySchemaTag,
3901
2619
  DisplaySchemaTree,
3902
2620
  DynamicValueInput,
2621
+ FlowValueUtils,
2622
+ InjectDynamicValueInput,
2623
+ InjectTypeSelector,
2624
+ InjectVariableSelector,
3903
2625
  InputsValues,
2626
+ InputsValuesTree,
3904
2627
  JsonEditorWithVariables,
3905
2628
  JsonSchemaEditor,
3906
2629
  JsonSchemaTypePresetProvider,
@@ -3910,11 +2633,13 @@ export {
3910
2633
  PromptEditorWithVariables,
3911
2634
  TypeSelector,
3912
2635
  VariableSelector,
2636
+ VariableSelectorProvider,
3913
2637
  autoRenameRefEffect,
3914
2638
  createBatchOutputsFormPlugin,
3915
2639
  createDisableDeclarationPlugin,
3916
2640
  createInferAssignPlugin,
3917
2641
  createInferInputsPlugin,
2642
+ createInjectMaterial,
3918
2643
  createTypePresetPlugin,
3919
2644
  formatLegacyRefOnInit,
3920
2645
  formatLegacyRefOnSubmit,
@@ -3923,16 +2648,21 @@ export {
3923
2648
  getTypeSelectValue,
3924
2649
  isLegacyFlowRefValueSchema,
3925
2650
  isNewFlowRefValueSchema,
2651
+ lazySuspense,
3926
2652
  listenRefSchemaChange,
3927
2653
  listenRefValueChange,
3928
2654
  parseTypeSelectValue,
2655
+ polyfillCreateRoot,
3929
2656
  provideBatchInputEffect,
3930
2657
  provideBatchOutputsEffect,
3931
2658
  provideJsonSchemaOutputs,
3932
2659
  syncVariableTitle,
2660
+ unstableSetCreateRoot,
2661
+ useObjectList,
3933
2662
  useTypeManager,
3934
2663
  useVariableTree,
3935
2664
  validateFlowValue,
3936
- validateWhenVariableSync
2665
+ validateWhenVariableSync,
2666
+ withSuspense
3937
2667
  };
3938
2668
  //# sourceMappingURL=index.js.map