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

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 (126) hide show
  1. package/bin/index.ts +11 -5
  2. package/bin/materials.ts +10 -1
  3. package/dist/esm/index.js +1996 -1361
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/index.d.mts +328 -114
  6. package/dist/index.d.ts +328 -114
  7. package/dist/index.js +2096 -1472
  8. package/dist/index.js.map +1 -1
  9. package/package.json +7 -5
  10. package/src/components/assign-row/components/blur-input.tsx +27 -0
  11. package/src/components/assign-row/config.json +11 -0
  12. package/src/components/assign-row/index.tsx +84 -0
  13. package/src/components/assign-row/types.ts +25 -0
  14. package/src/components/assign-rows/config.json +11 -0
  15. package/src/components/assign-rows/index.tsx +59 -0
  16. package/src/components/batch-outputs/config.json +2 -1
  17. package/src/components/batch-outputs/index.tsx +4 -12
  18. package/src/components/batch-variable-selector/config.json +6 -2
  19. package/src/components/batch-variable-selector/index.tsx +1 -1
  20. package/src/components/code-editor/config.json +2 -1
  21. package/src/components/code-editor/index.tsx +23 -1
  22. package/src/components/code-editor/language-features.ts +23 -3
  23. package/src/components/code-editor/theme/light.ts +2 -2
  24. package/src/components/code-editor-mini/config.json +7 -0
  25. package/src/components/code-editor-mini/index.tsx +31 -0
  26. package/src/components/condition-row/config.json +10 -2
  27. package/src/components/condition-row/constants.ts +6 -8
  28. package/src/components/condition-row/hooks/useOp.tsx +3 -1
  29. package/src/components/condition-row/hooks/useRule.ts +2 -2
  30. package/src/components/condition-row/index.tsx +2 -1
  31. package/src/components/condition-row/types.ts +3 -1
  32. package/src/components/constant-input/config.json +6 -3
  33. package/src/components/constant-input/index.tsx +18 -62
  34. package/src/components/constant-input/types.ts +6 -9
  35. package/src/components/display-flow-value/config.json +8 -0
  36. package/src/components/display-flow-value/index.tsx +59 -0
  37. package/src/components/display-inputs-values/config.json +9 -0
  38. package/src/components/display-inputs-values/index.tsx +27 -0
  39. package/src/components/display-inputs-values/styles.ts +12 -0
  40. package/src/components/display-outputs/config.json +10 -0
  41. package/src/components/display-outputs/index.tsx +64 -0
  42. package/src/components/display-outputs/styles.ts +12 -0
  43. package/src/components/display-schema-tag/config.json +10 -0
  44. package/src/components/display-schema-tag/index.tsx +44 -0
  45. package/src/components/display-schema-tag/styles.ts +28 -0
  46. package/src/components/display-schema-tree/config.json +11 -0
  47. package/src/components/display-schema-tree/index.tsx +74 -0
  48. package/src/components/display-schema-tree/styles.tsx +90 -0
  49. package/src/components/dynamic-value-input/config.json +11 -2
  50. package/src/components/dynamic-value-input/hooks.ts +53 -0
  51. package/src/components/dynamic-value-input/index.tsx +64 -13
  52. package/src/components/dynamic-value-input/styles.tsx +28 -2
  53. package/src/components/index.ts +9 -0
  54. package/src/components/inputs-values/components/blur-input.tsx +27 -0
  55. package/src/components/inputs-values/config.json +13 -0
  56. package/src/components/inputs-values/index.tsx +73 -0
  57. package/src/components/inputs-values/styles.tsx +19 -0
  58. package/src/components/inputs-values/types.ts +22 -0
  59. package/src/components/json-editor-with-variables/index.tsx +47 -1
  60. package/src/components/json-schema-editor/config.json +2 -2
  61. package/src/components/json-schema-editor/default-value.tsx +1 -1
  62. package/src/components/json-schema-editor/hooks.tsx +4 -2
  63. package/src/components/json-schema-editor/index.tsx +15 -2
  64. package/src/components/json-schema-editor/types.ts +1 -1
  65. package/src/components/prompt-editor/index.tsx +2 -1
  66. package/src/components/prompt-editor/types.tsx +1 -0
  67. package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
  68. package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +6 -3
  69. package/src/components/type-selector/config.json +6 -2
  70. package/src/components/type-selector/index.tsx +55 -12
  71. package/src/components/variable-selector/config.json +6 -2
  72. package/src/components/variable-selector/index.tsx +34 -13
  73. package/src/components/variable-selector/styles.tsx +18 -8
  74. package/src/components/variable-selector/use-variable-tree.tsx +19 -22
  75. package/src/effects/auto-rename-ref/index.ts +59 -8
  76. package/src/effects/index.ts +3 -1
  77. package/src/effects/listen-ref-schema-change/config.json +10 -0
  78. package/src/effects/listen-ref-schema-change/index.ts +56 -0
  79. package/src/effects/listen-ref-value-change/config.json +9 -0
  80. package/src/effects/listen-ref-value-change/index.ts +53 -0
  81. package/src/effects/provide-json-schema-outputs/config.json +4 -5
  82. package/src/effects/provide-json-schema-outputs/index.ts +1 -3
  83. package/src/effects/sync-variable-title/index.ts +1 -0
  84. package/src/effects/validate-when-variable-sync/config.json +5 -0
  85. package/src/effects/validate-when-variable-sync/index.ts +35 -0
  86. package/src/form-plugins/index.ts +3 -1
  87. package/src/form-plugins/infer-assign-plugin/config.json +7 -0
  88. package/src/form-plugins/infer-assign-plugin/index.ts +90 -0
  89. package/src/form-plugins/infer-inputs-plugin/config.json +9 -0
  90. package/src/form-plugins/infer-inputs-plugin/index.ts +108 -0
  91. package/src/hooks/index.tsx +6 -0
  92. package/src/hooks/use-object-list/config.json +8 -0
  93. package/src/hooks/use-object-list/index.tsx +136 -0
  94. package/src/index.ts +3 -1
  95. package/src/{typings/json-schema → plugins/disable-declaration-plugin}/config.json +1 -1
  96. package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +31 -0
  97. package/src/plugins/disable-declaration-plugin/index.tsx +6 -0
  98. package/src/plugins/index.ts +7 -0
  99. package/src/plugins/json-schema-preset/config.json +9 -0
  100. package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +28 -0
  101. package/src/plugins/json-schema-preset/index.tsx +41 -0
  102. package/src/plugins/json-schema-preset/manager.ts +18 -0
  103. package/src/plugins/json-schema-preset/type-definition/array.tsx +24 -0
  104. package/src/plugins/json-schema-preset/type-definition/boolean.tsx +32 -0
  105. package/src/plugins/json-schema-preset/type-definition/index.tsx +24 -0
  106. package/src/plugins/json-schema-preset/type-definition/integer.tsx +24 -0
  107. package/src/plugins/json-schema-preset/type-definition/number.tsx +24 -0
  108. package/src/plugins/json-schema-preset/type-definition/object.tsx +24 -0
  109. package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -0
  110. package/src/{utils → shared}/index.ts +0 -1
  111. package/src/typings/flow-value/config.json +3 -1
  112. package/src/typings/flow-value/index.ts +11 -0
  113. package/src/typings/index.ts +0 -1
  114. package/src/validate/index.tsx +6 -0
  115. package/src/validate/validate-flow-value/config.json +7 -0
  116. package/src/validate/validate-flow-value/index.tsx +73 -0
  117. package/src/components/batch-outputs/use-list.ts +0 -86
  118. package/src/components/type-selector/constants.tsx +0 -364
  119. package/src/effects/provide-batch-outputs/config.json +0 -5
  120. package/src/effects/provide-batch-outputs/index.ts +0 -38
  121. package/src/typings/json-schema/index.ts +0 -36
  122. package/src/utils/json-schema/config.json +0 -5
  123. package/src/utils/json-schema/index.ts +0 -180
  124. /package/src/{utils → shared}/format-legacy-refs/config.json +0 -0
  125. /package/src/{utils → shared}/format-legacy-refs/index.ts +0 -0
  126. /package/src/{utils → shared}/format-legacy-refs/readme.md +0 -0
package/dist/esm/index.js CHANGED
@@ -1,551 +1,567 @@
1
1
  // src/components/variable-selector/index.tsx
2
- import React3, { useMemo } from "react";
2
+ import React11, { useMemo } from "react";
3
+ import { Popover } from "@douyinfe/semi-ui";
3
4
  import { IconChevronDownStroked, IconIssueStroked } from "@douyinfe/semi-icons";
4
5
 
5
6
  // src/components/variable-selector/use-variable-tree.tsx
6
- import React2, { useCallback } from "react";
7
+ import React10, { useCallback } from "react";
8
+ import { JsonSchemaUtils as JsonSchemaUtils2 } from "@flowgram.ai/json-schema";
7
9
  import { ASTMatch as ASTMatch2, useAvailableVariables } from "@flowgram.ai/editor";
8
- import { Icon as Icon2 } from "@douyinfe/semi-ui";
10
+ import { Icon } from "@douyinfe/semi-ui";
9
11
 
10
- // src/components/type-selector/constants.tsx
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
11
24
  import React from "react";
12
- import Icon from "@douyinfe/semi-icons";
13
- var VariableTypeIcons = {
14
- custom: /* @__PURE__ */ React.createElement(
15
- "svg",
16
- {
17
- viewBox: "0 0 24 24",
18
- fill: "none",
19
- xmlns: "http://www.w3.org/2000/svg",
20
- width: "1em",
21
- height: "1em",
22
- focusable: "false",
23
- "aria-hidden": "true"
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
+ 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"
24
134
  },
25
- /* @__PURE__ */ React.createElement(
26
- "path",
27
- {
28
- fillRule: "evenodd",
29
- clipRule: "evenodd",
30
- d: "M5.1 18L4.5032 20.1702C4.24999 21.0909 4.94281 22 5.89773 22C6.54881 22 7.11964 21.565 7.29227 20.9372L8.1 18H12.1L11.5032 20.1702C11.25 21.0909 11.9428 22 12.8977 22C13.5488 22 14.1196 21.565 14.2923 20.9372L15.1 18H19.5C20.3284 18 21 17.3284 21 16.5C21 15.6716 20.3284 15 19.5 15H15.925L17.575 9H20.5C21.3284 9 22 8.32843 22 7.5C22 6.67157 21.3284 6 20.5 6H18.4L18.9968 3.8298C19.25 2.90906 18.5572 2 17.6023 2C16.9512 2 16.3804 2.43504 16.2077 3.06281L15.4 6H11.4L11.9968 3.8298C12.25 2.90906 11.5572 2 10.6023 2C9.95119 2 9.38036 2.43504 9.20773 3.06281L8.4 6H4.5C3.67157 6 3 6.67157 3 7.5C3 8.32843 3.67157 9 4.5 9H7.575L5.925 15H3.5C2.67157 15 2 15.6716 2 16.5C2 17.3284 2.67157 18 3.5 18H5.1ZM8.925 15L10.575 9H14.575L12.925 15H8.925Z",
31
- fill: "currentColor"
32
- }
33
- )
34
- ),
35
- object: /* @__PURE__ */ React.createElement(
36
- "svg",
37
- {
38
- width: "1em",
39
- height: "1em",
40
- viewBox: "0 0 16 16",
41
- fill: "none",
42
- xmlns: "http://www.w3.org/2000/svg"
135
+ link: {
136
+ color: "#007bff"
43
137
  },
44
- /* @__PURE__ */ React.createElement(
45
- "path",
46
- {
47
- d: "M5.33893 1.5835C5.66613 1.5835 5.93137 1.88142 5.93137 2.20862C5.93137 2.53582 5.66613 2.76838 5.33893 2.76838H4.9099C4.34717 2.76838 4.08062 3.07557 4.08062 3.71921V6.58633C4.08062 7.30996 3.80723 7.84734 3.26798 8.19105C3.11426 8.28902 3.10884 8.55273 3.26068 8.65359C3.80476 9.01503 4.08062 9.53994 4.08062 10.2434V13.1251C4.08062 13.7395 4.34717 14.0613 4.9099 14.0613H5.33893C5.66613 14.0613 5.93137 14.3435 5.93137 14.6707C5.93137 14.9979 5.66613 15.2462 5.33893 15.2462H4.64335C3.99177 15.2462 3.48828 15.0268 3.13287 14.6172C2.80708 14.2369 2.64419 13.7103 2.64419 13.0666V10.3165C2.64419 9.8923 2.55534 9.58511 2.37764 9.39494C2.26816 9.27135 1.80618 9.17938 1.38154 9.11602C1.02726 9.06315 0.759057 8.76744 0.765747 8.4093C0.772379 8.0543 1.03439 7.7566 1.38545 7.70346C1.80778 7.63952 2.26906 7.54968 2.37764 7.43477C2.55534 7.22997 2.64419 6.92278 2.64419 6.51319V3.77772C2.64419 3.11945 2.80708 2.59284 3.13287 2.21251C3.48828 1.78829 3.99177 1.5835 4.64335 1.5835H5.33893Z",
48
- fill: "currentColor"
49
- }
50
- ),
51
- /* @__PURE__ */ React.createElement(
52
- "path",
53
- {
54
- d: "M10.962 15.2463C10.6348 15.2463 10.3696 14.9483 10.3696 14.6211C10.3696 14.2939 10.6348 14.0614 10.962 14.0614H11.391C11.9538 14.0614 12.2203 13.7542 12.2203 13.1105V10.2434C12.2203 9.51979 12.4937 8.98241 13.033 8.6387C13.1867 8.54073 13.1921 8.27703 13.0403 8.17616C12.4962 7.81472 12.2203 7.28982 12.2203 6.58638V3.70463C12.2203 3.09024 11.9538 2.76842 11.391 2.76842L10.962 2.76842C10.6348 2.76842 10.3696 2.48627 10.3696 2.15907C10.3696 1.83188 10.6348 1.58354 10.962 1.58354L11.6576 1.58354C12.3092 1.58354 12.8127 1.80296 13.1681 2.21255C13.4939 2.59289 13.6568 3.1195 13.6568 3.76314V6.51324C13.6568 6.93745 13.7456 7.24464 13.9233 7.43481C14.03 7.5553 14.4328 7.64858 14.8186 7.71393C15.1718 7.77376 15.4401 8.06977 15.4334 8.42791C15.4268 8.78291 15.1646 9.08018 14.814 9.13633C14.4306 9.19774 14.0291 9.28303 13.9233 9.39499C13.7456 9.59978 13.6568 9.90697 13.6568 10.3166V13.052C13.6568 13.7103 13.4939 14.2369 13.1681 14.6172C12.8127 15.0415 12.3092 15.2463 11.6576 15.2463H10.962Z",
55
- fill: "currentColor"
56
- }
57
- )
58
- ),
59
- boolean: /* @__PURE__ */ React.createElement(
60
- "svg",
61
- {
62
- width: "1em",
63
- height: "1em",
64
- viewBox: "0 0 16 16",
65
- fill: "none",
66
- xmlns: "http://www.w3.org/2000/svg"
138
+ completionItemHover: {
139
+ backgroundColor: "#f0f0f0"
67
140
  },
68
- /* @__PURE__ */ React.createElement(
69
- "path",
70
- {
71
- fillRule: "evenodd",
72
- clipRule: "evenodd",
73
- d: "M10.668 4.66683H5.33463C3.49369 4.66683 2.0013 6.15921 2.0013 8.00016C2.0013 9.84111 3.49369 11.3335 5.33463 11.3335H10.668C12.5089 11.3335 14.0013 9.84111 14.0013 8.00016C14.0013 6.15921 12.5089 4.66683 10.668 4.66683ZM5.33463 3.3335C2.75731 3.3335 0.667969 5.42283 0.667969 8.00016C0.667969 10.5775 2.75731 12.6668 5.33463 12.6668H10.668C13.2453 12.6668 15.3346 10.5775 15.3346 8.00016C15.3346 5.42283 13.2453 3.3335 10.668 3.3335H5.33463Z",
74
- fill: "currentColor"
75
- }
76
- ),
77
- /* @__PURE__ */ React.createElement(
78
- "path",
79
- {
80
- fillRule: "evenodd",
81
- clipRule: "evenodd",
82
- d: "M8.66797 8.00016C8.66797 6.89559 9.5634 6.00016 10.668 6.00016C11.7725 6.00016 12.668 6.89559 12.668 8.00016C12.668 9.10473 11.7725 10.0002 10.668 10.0002C9.5634 10.0002 8.66797 9.10473 8.66797 8.00016ZM10.668 7.3335C10.2998 7.3335 10.0013 7.63197 10.0013 8.00016C10.0013 8.36835 10.2998 8.66683 10.668 8.66683C11.0362 8.66683 11.3346 8.36835 11.3346 8.00016C11.3346 7.63197 11.0362 7.3335 10.668 7.3335Z",
83
- fill: "currentColor"
84
- }
85
- )
86
- ),
87
- string: /* @__PURE__ */ React.createElement(
88
- "svg",
89
- {
90
- width: "1em",
91
- height: "1em",
92
- viewBox: "0 0 16 16",
93
- fill: "none",
94
- xmlns: "http://www.w3.org/2000/svg"
141
+ completionItemSelected: {
142
+ backgroundColor: "#e0e0e0"
95
143
  },
96
- /* @__PURE__ */ React.createElement(
97
- "path",
98
- {
99
- d: "M9.3342 3.33321C8.96601 3.33321 8.66753 3.63169 8.66753 3.99988C8.66753 4.36807 8.96601 4.66655 9.3342 4.66655H14.6675C15.0357 4.66655 15.3342 4.36807 15.3342 3.99988C15.3342 3.63169 15.0357 3.33321 14.6675 3.33321H9.3342Z",
100
- fill: "currentColor"
101
- }
102
- ),
103
- /* @__PURE__ */ React.createElement(
104
- "path",
105
- {
106
- d: "M10.0009 7.99988C10.0009 7.63169 10.2993 7.33321 10.6675 7.33321H14.6675C15.0357 7.33321 15.3342 7.63169 15.3342 7.99988C15.3342 8.36807 15.0357 8.66655 14.6675 8.66655H10.6675C10.2993 8.66655 10.0009 8.36807 10.0009 7.99988Z",
107
- fill: "currentColor"
108
- }
109
- ),
110
- /* @__PURE__ */ React.createElement(
111
- "path",
112
- {
113
- d: "M12.0009 11.3332C11.6327 11.3332 11.3342 11.6317 11.3342 11.9999C11.3342 12.3681 11.6327 12.6665 12.0009 12.6665H14.6675C15.0357 12.6665 15.3342 12.3681 15.3342 11.9999C15.3342 11.6317 15.0357 11.3332 14.6675 11.3332H12.0009Z",
114
- fill: "currentColor"
115
- }
116
- ),
117
- /* @__PURE__ */ React.createElement(
118
- "path",
119
- {
120
- d: "M9.86659 14.1482L8.23444 10.1844H3.18136C3.13868 10.1844 3.09685 10.1808 3.05616 10.1738L1.66589 14.1129C1.53049 14.4965 1.10971 14.6978 0.726058 14.5624C0.342408 14.427 0.141166 14.0062 0.276572 13.6225L4.37566 2.00848C4.71323 1.05202 6.05321 1.01763 6.4394 1.95552L11.2289 13.5872C11.3838 13.9634 11.2044 14.394 10.8282 14.5489C10.452 14.7038 10.0215 14.5244 9.86659 14.1482ZM5.44412 3.40791L3.57241 8.71109H7.62778L5.44412 3.40791Z",
121
- fill: "currentColor"
122
- }
123
- )
124
- ),
125
- integer: /* @__PURE__ */ React.createElement(
126
- "svg",
127
- {
128
- width: "1em",
129
- height: "1em",
130
- viewBox: "0 0 16 16",
131
- fill: "none",
132
- xmlns: "http://www.w3.org/2000/svg"
144
+ completionItemIcon: {
145
+ color: "#333"
133
146
  },
134
- /* @__PURE__ */ React.createElement(
135
- "path",
136
- {
137
- d: "M15.132 11.4601C15.644 11.0121 15.9 10.3921 15.9 9.60007C15.9 8.60807 15.5 7.93607 14.7 7.58407C15.412 7.23207 15.768 6.62407 15.768 5.76007C15.768 5.05607 15.536 4.48007 15.072 4.03207C14.608 3.59207 14.012 3.37207 13.284 3.37207C12.588 3.37207 12.008 3.58007 11.544 3.99607C11.064 4.42007 10.808 4.98807 10.776 5.70007H12C12.064 4.88407 12.492 4.47607 13.284 4.47607C14.124 4.47607 14.544 4.91607 14.544 5.79607C14.544 6.66007 14.112 7.09207 13.248 7.09207H13.044V8.16007H13.248C14.2 8.16007 14.676 8.62807 14.676 9.56407C14.676 10.5081 14.212 10.9801 13.284 10.9801C12.9 10.9801 12.584 10.8761 12.336 10.6681C12.064 10.4441 11.916 10.1161 11.892 9.68407H10.668C10.692 10.4761 10.964 11.0841 11.484 11.5081C11.948 11.8921 12.548 12.0841 13.284 12.0841C14.036 12.0841 14.652 11.8761 15.132 11.4601Z",
138
- fill: "currentColor"
139
- }
140
- ),
141
- /* @__PURE__ */ React.createElement(
142
- "path",
143
- {
144
- d: "M4.46875 12.0003V10.9083L7.75675 6.91228C8.06075 6.54428 8.21275 6.16428 8.21275 5.77228C8.21275 4.90828 7.79675 4.47628 6.96475 4.47628C6.60475 4.47628 6.31275 4.57628 6.08875 4.77628C5.83275 5.00828 5.70475 5.34828 5.70475 5.79628H4.48075C4.48075 5.07628 4.71275 4.49228 5.17675 4.04428C5.64075 3.60428 6.23675 3.38428 6.96475 3.38428C7.70075 3.38428 8.29675 3.60028 8.75275 4.03228C9.20875 4.47228 9.43675 5.05628 9.43675 5.78428C9.43675 6.13628 9.36875 6.45628 9.23275 6.74428C9.12075 6.97628 8.92075 7.27228 8.63275 7.63228L5.95675 10.9083H9.43675V12.0003H4.46875Z",
145
- fill: "currentColor"
146
- }
147
- ),
148
- /* @__PURE__ */ React.createElement(
149
- "path",
150
- {
151
- d: "M1.668 12.0001V4.78805L0 6.25205V4.89605L1.668 3.45605H2.892V12.0001H1.668Z",
152
- fill: "currentColor"
153
- }
154
- )
155
- ),
156
- number: /* @__PURE__ */ React.createElement(
157
- "svg",
158
- {
159
- width: "1em",
160
- height: "1em",
161
- viewBox: "0 0 16 16",
162
- fill: "none",
163
- xmlns: "http://www.w3.org/2000/svg"
147
+ completionItemLabel: {
148
+ color: "#333"
164
149
  },
165
- /* @__PURE__ */ React.createElement(
166
- "path",
167
- {
168
- d: "M3.44151 5.3068C3.44151 3.83404 4.71542 2.64014 6.18818 2.64014C7.66094 2.64014 8.93484 3.83404 8.93484 5.3068V10.6135C8.93484 12.0862 7.66094 13.2801 6.18818 13.2801C4.71542 13.2801 3.44151 12.0862 3.44151 10.6135V5.3068ZM7.60151 5.3068C7.60151 4.57042 6.92456 3.97347 6.18818 3.97347C5.4518 3.97347 4.77484 4.57042 4.77484 5.3068V10.6135C4.77484 11.3498 5.4518 11.9468 6.18818 11.9468C6.92456 11.9468 7.60151 11.3498 7.60151 10.6135V5.3068Z",
169
- fill: "currentColor"
170
- }
171
- ),
172
- /* @__PURE__ */ React.createElement(
173
- "path",
174
- {
175
- d: "M12.9882 2.64014C11.5154 2.64014 10.2415 3.83404 10.2415 5.3068V10.6135C10.2415 12.0862 11.5154 13.2801 12.9882 13.2801C14.4609 13.2801 15.7348 12.0862 15.7348 10.6135V5.3068C15.7348 3.83404 14.4609 2.64014 12.9882 2.64014ZM14.4015 10.6135C14.4015 11.3498 13.7246 11.9468 12.9882 11.9468C12.2518 11.9468 11.5748 11.3498 11.5748 10.6135V5.3068C11.5748 4.57042 12.2518 3.97347 12.9882 3.97347C13.7246 3.97347 14.4015 4.57042 14.4015 5.3068V10.6135Z",
176
- fill: "currentColor"
177
- }
178
- ),
179
- /* @__PURE__ */ React.createElement(
180
- "path",
181
- {
182
- d: "M1.21484 13.2001C1.76713 13.2001 2.21484 12.7524 2.21484 12.2001C2.21484 11.6479 1.76713 11.2001 1.21484 11.2001C0.662559 11.2001 0.214844 11.6479 0.214844 12.2001C0.214844 12.7524 0.662559 13.2001 1.21484 13.2001Z",
183
- fill: "currentColor"
184
- }
185
- )
186
- ),
187
- array: /* @__PURE__ */ React.createElement(
188
- "svg",
189
- {
190
- width: "1em",
191
- height: "1em",
192
- viewBox: "0 0 16 16",
193
- fill: "none",
194
- xmlns: "http://www.w3.org/2000/svg"
150
+ completionItemInfo: {
151
+ color: "#333"
195
152
  },
196
- /* @__PURE__ */ React.createElement(
197
- "path",
198
- {
199
- d: "M5.23759 1.00342H2.00391V14.997H5.23759V13.6251H3.35127V2.37534H5.23759V1.00342Z",
200
- fill: "currentColor"
201
- }
202
- ),
203
- /* @__PURE__ */ React.createElement(
204
- "path",
205
- {
206
- d: "M10.7624 1.00342H13.9961V14.997H10.7624V13.6251H12.6487V2.37534H10.7624V1.00342Z",
207
- fill: "currentColor"
208
- }
209
- )
210
- ),
211
- stream: /* @__PURE__ */ React.createElement(
212
- "svg",
213
- {
214
- viewBox: "0 0 1024 1024",
215
- version: "1.1",
216
- xmlns: "http://www.w3.org/2000/svg",
217
- width: "1em",
218
- height: "1em"
153
+ completionItemDetail: {
154
+ color: "#666"
155
+ }
156
+ },
157
+ styles: [
158
+ // JSON
159
+ {
160
+ tag: t.comment,
161
+ color: colors.comment
219
162
  },
220
- /* @__PURE__ */ React.createElement(
221
- "path",
222
- {
223
- d: "M879.674 544.51l-158.254-0.221c-8.534 2.287-17.305-2.776-19.588-11.307l-23.862-75.877-74.742 350.891c0 0-1.523 18.507-11.518 18.507s-26.9 0.281-26.9 0.281c-8.259 2.213-16.748-2.687-18.961-10.949l-92.741-457.648-70.305 330.634c-2.261 8.291-11.94 15.206-20.385 12.986l-24.876 0.339c-8.723 2.293-17.685-2.789-20.023-11.349L270.629 544.51 143.993 544.51c-8.831 0-15.993-7.159-15.993-15.993l0-31.986c0-8.831 7.162-15.993 15.993-15.993l157.429-0.516c9.565-0.304 17.685 0.788 20.023 9.351l24.386 76.092 68.642-358.907c0 0 3.4-10.894 14.397-10.894 10.994 0 34.107-0.448 34.107-0.448 8.262-2.213 16.751 2.687 18.965 10.949l91.912 454.126 67.948-326.182c2.213-8.262 8.707-15.161 16.965-12.948l27.316-0.333c8.531-2.287 17.301 2.776 19.588 11.31l46.665 148.4 127.337 0c8.835 0 15.993 7.162 15.993 15.993l0 31.986C895.667 537.352 888.508 544.51 879.674 544.51z",
224
- fill: "currentColor"
225
- }
226
- )
227
- ),
228
- map: /* @__PURE__ */ React.createElement(
229
- "svg",
230
- {
231
- viewBox: "0 0 1024 1024",
232
- version: "1.1",
233
- xmlns: "http://www.w3.org/2000/svg",
234
- width: "1em",
235
- height: "1em"
163
+ {
164
+ tag: [t.propertyName],
165
+ color: colors.key
236
166
  },
237
- /* @__PURE__ */ React.createElement(
238
- "path",
239
- {
240
- d: "M877.860571 938.642286h-645.851428c-27.574857 0-54.052571-11.337143-73.508572-31.744a110.957714 110.957714 0 0 1-30.500571-76.8V193.828571c0-28.745143 10.971429-56.32 30.500571-76.726857a101.888 101.888 0 0 1 73.508572-31.817143h574.171428c27.501714 0 53.979429 11.337143 73.508572 31.744 19.529143 20.333714 30.500571 48.054857 30.500571 76.8v522.020572a34.157714 34.157714 0 0 1-6.948571 22.820571c-37.156571 19.382857-57.636571 39.350857-57.636572 72.630857 0 39.716571 19.894857 50.029714 57.636572 72.777143a34.816 34.816 0 0 1-8.045714 49.298286 32.256 32.256 0 0 1-17.334858 5.193143z m-32.256-254.537143V193.828571a40.228571 40.228571 0 0 0-39.497142-41.179428H232.009143a40.301714 40.301714 0 0 0-39.497143 41.252571V699.245714c17.773714-9.874286 37.449143-14.994286 57.417143-14.921143h595.675428v-0.073142z m-595.675428 187.245714h566.198857c-22.893714-11.190857-27.940571-39.497143-28.013714-59.977143 0-20.260571 3.218286-43.885714 28.013714-59.904h-566.125714c-31.670857 0-57.417143 26.843429-57.417143 59.977143 0 33.060571 25.746286 59.904 57.344 59.904z",
241
- fill: "currentColor"
242
- }
243
- ),
244
- /* @__PURE__ */ React.createElement(
245
- "path",
246
- {
247
- d: "M320 128m32.036571 0l-0.073142 0q32.036571 0 32.036571 32.036571l0 511.926858q0 32.036571-32.036571 32.036571l0.073142 0q-32.036571 0-32.036571-32.036571l0-511.926858q0-32.036571 32.036571-32.036571Z",
248
- fill: "currentColor"
249
- }
250
- )
251
- )
252
- };
253
- var ArrayIcons = {
254
- object: /* @__PURE__ */ React.createElement(
255
- "svg",
256
- {
257
- width: "1em",
258
- height: "1em",
259
- viewBox: "0 0 16 16",
260
- fill: "none",
261
- xmlns: "http://www.w3.org/2000/svg"
167
+ {
168
+ tag: [t.string],
169
+ color: colors.string
262
170
  },
263
- /* @__PURE__ */ React.createElement(
264
- "path",
265
- {
266
- fillRule: "evenodd",
267
- clipRule: "evenodd",
268
- d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM3.82031 5.9091C3.82031 5.18535 4.40703 4.59863 5.13078 4.59863C5.85453 4.59863 6.44124 5.18535 6.44124 5.9091C6.44124 6.56485 5.9596 7.1081 5.33078 7.2044V8.70018H5.32877C5.32982 8.75093 5.33078 8.80912 5.33078 8.87034V9.72111C5.33078 10.0195 5.57268 10.2614 5.87109 10.2614H6.24124C6.55613 10.2614 6.8114 10.5167 6.8114 10.8316C6.8114 11.1465 6.55613 11.4017 6.24124 11.4017H5.87109C4.94291 11.4017 4.19047 10.6493 4.19047 9.72111V6.82186C3.96158 6.58607 3.82031 6.26397 3.82031 5.9091ZM7.33679 5.9091C7.33679 5.59421 7.59205 5.33894 7.90694 5.33894H11.6085C11.9234 5.33894 12.1786 5.59421 12.1786 5.9091C12.1786 6.22399 11.9234 6.47925 11.6085 6.47925H7.90694C7.59205 6.47925 7.33679 6.22399 7.33679 5.9091ZM7.33679 9.86846C7.33679 9.55357 7.59205 9.2983 7.90694 9.2983H11.6085C11.9234 9.2983 12.1786 9.55357 12.1786 9.86846C12.1786 10.1833 11.9234 10.4386 11.6085 10.4386H7.90694C7.59205 10.4386 7.33679 10.1833 7.33679 9.86846Z",
269
- fill: "currentColor"
270
- }
271
- )
272
- ),
273
- boolean: /* @__PURE__ */ React.createElement(
274
- "svg",
275
- {
276
- width: "1em",
277
- height: "1em",
278
- viewBox: "0 0 16 16",
279
- fill: "none",
280
- xmlns: "http://www.w3.org/2000/svg"
171
+ {
172
+ tag: [t.number],
173
+ color: colors.number
281
174
  },
282
- /* @__PURE__ */ React.createElement(
283
- "path",
284
- {
285
- fillRule: "evenodd",
286
- clipRule: "evenodd",
287
- d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM2.75 7.99993C2.75 6.14518 4.25358 4.6416 6.10833 4.6416H9.775C11.6298 4.6416 13.1333 6.14518 13.1333 7.99993C13.1333 9.85469 11.6298 11.3583 9.775 11.3583H6.10833C4.25358 11.3583 2.75 9.85469 2.75 7.99993ZM6.10833 5.85827C4.92552 5.85827 3.96667 6.81713 3.96667 7.99993C3.96667 9.18274 4.92552 10.1416 6.10833 10.1416H9.775C10.9578 10.1416 11.9167 9.18274 11.9167 7.99993C11.9167 6.81713 10.9578 5.85827 9.775 5.85827H6.10833ZM8.25 7.99993C8.25 7.1577 8.93277 6.47493 9.775 6.47493C10.6172 6.47493 11.3 7.1577 11.3 7.99993C11.3 8.84217 10.6172 9.52493 9.775 9.52493C8.93277 9.52493 8.25 8.84217 8.25 7.99993ZM9.775 7.6916C9.60471 7.6916 9.46667 7.82965 9.46667 7.99993C9.46667 8.17022 9.60471 8.30827 9.775 8.30827C9.94529 8.30827 10.0833 8.17022 10.0833 7.99993C10.0833 7.82965 9.94529 7.6916 9.775 7.6916Z",
288
- fill: "currentColor"
289
- }
290
- )
291
- ),
292
- string: /* @__PURE__ */ React.createElement(
293
- "svg",
294
- {
295
- width: "1em",
296
- height: "1em",
297
- viewBox: "0 0 16 16",
298
- fill: "none",
299
- xmlns: "http://www.w3.org/2000/svg"
175
+ {
176
+ tag: [t.bool],
177
+ color: colors.boolean
300
178
  },
301
- /* @__PURE__ */ React.createElement(
302
- "path",
303
- {
304
- fillRule: "evenodd",
305
- clipRule: "evenodd",
306
- d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM5.23701 4.07158C5.50364 3.3161 6.56205 3.28894 6.86709 4.02974L10 11.6383C10.1329 11.9609 9.979 12.3302 9.65631 12.4631C9.33363 12.596 8.96434 12.4421 8.83147 12.1194L7.8021 9.61951H4.61903L3.7474 12.0891C3.63126 12.4182 3.27034 12.5908 2.94127 12.4747C2.6122 12.3585 2.43958 11.9976 2.55573 11.6685L5.23701 4.07158ZM6.08814 5.45704L5.06505 8.35579H7.28174L6.08814 5.45704ZM8.81938 6.07534C8.81938 5.75166 9.08177 5.48926 9.40545 5.48926H12.8941C13.2178 5.48926 13.4802 5.75166 13.4802 6.07534C13.4802 6.39902 13.2178 6.66142 12.8941 6.66142H9.40545C9.08177 6.66142 8.81938 6.39902 8.81938 6.07534ZM10.2668 9.69181C10.2668 9.36812 10.5292 9.10573 10.8529 9.10573H12.8941C13.2178 9.10573 13.4802 9.36812 13.4802 9.69181C13.4802 10.0155 13.2178 10.2779 12.8941 10.2779H10.8529C10.5292 10.2779 10.2668 10.0155 10.2668 9.69181Z",
307
- fill: "currentColor"
308
- }
309
- )
310
- ),
311
- integer: /* @__PURE__ */ React.createElement(
312
- "svg",
313
- {
314
- width: "1em",
315
- height: "1em",
316
- viewBox: "0 0 16 16",
317
- fill: "none",
318
- xmlns: "http://www.w3.org/2000/svg"
179
+ {
180
+ tag: [t.null],
181
+ color: colors.null
319
182
  },
320
- /* @__PURE__ */ React.createElement(
321
- "path",
322
- {
323
- fillRule: "evenodd",
324
- clipRule: "evenodd",
325
- d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM10.3614 5.22374C10.7161 4.90585 11.1581 4.75 11.6762 4.75C12.2173 4.75 12.6723 4.91467 13.0281 5.25207L13.0291 5.253C13.3852 5.59688 13.561 6.03946 13.561 6.56767C13.561 6.89 13.4945 7.17448 13.3539 7.41445C13.2572 7.57972 13.1279 7.71948 12.9685 7.83428C13.1575 7.95643 13.3099 8.11182 13.4225 8.30109C13.5793 8.5644 13.6531 8.88311 13.6531 9.24936C13.6531 9.83787 13.4612 10.3151 13.0656 10.6612C12.6982 10.9795 12.2305 11.1341 11.6762 11.1341C11.1356 11.1341 10.6805 10.9925 10.324 10.6977C9.92124 10.3691 9.71723 9.90026 9.69942 9.31256L9.69473 9.15802H10.846L10.8539 9.2997C10.8689 9.5698 10.9591 9.75553 11.1096 9.87941L11.1106 9.88027C11.2519 9.99882 11.4365 10.0631 11.6762 10.0631C11.9765 10.0631 12.1743 9.98692 12.2984 9.86071C12.4229 9.73404 12.4984 9.53136 12.4984 9.22422C12.4984 8.92116 12.4215 8.72127 12.2939 8.59581C12.1658 8.46989 11.961 8.39373 11.6511 8.39373H11.3586V7.34788H11.6511C11.9297 7.34788 12.111 7.27834 12.2238 7.16555C12.3366 7.05276 12.4062 6.87138 12.4062 6.59281C12.4062 6.30696 12.3378 6.12041 12.2277 6.00501C12.1188 5.89092 11.9446 5.82098 11.6762 5.82098C11.4248 5.82098 11.2539 5.88537 11.1407 5.99325C11.0268 6.10185 10.9497 6.27522 10.9291 6.5375L10.9183 6.67577H9.76788L9.77492 6.51904C9.79886 5.98644 9.99237 5.54989 10.3614 5.22374ZM5.91032 5.26037C6.26612 4.92297 6.72112 4.7583 7.26219 4.7583C7.80751 4.7583 8.26297 4.91938 8.61401 5.25194L8.61501 5.25289C8.96719 5.59272 9.13852 6.04185 9.13852 6.58435C9.13852 6.84997 9.08709 7.09565 8.9817 7.31883L8.98114 7.31999C8.89563 7.49712 8.74775 7.71415 8.54418 7.96862L8.54322 7.96981L6.87446 10.0127H9.13852V11.0753H5.36909V10.1089L7.69946 7.27679C7.89456 7.04062 7.98374 6.80773 7.98374 6.57597C7.98374 6.29602 7.91626 6.11385 7.8078 6.00122C7.70036 5.88964 7.52811 5.8209 7.26219 5.8209C7.04017 5.8209 6.87439 5.88173 6.75075 5.99193C6.61227 6.11766 6.53226 6.30918 6.53226 6.59273V6.74273H5.37747V6.59273C5.37747 6.05443 5.55248 5.60586 5.90934 5.2613L5.91032 5.26037ZM3.50907 4.80865H4.56964V11.0754H3.41486V6.2201L2.25 7.24249V5.89561L3.50907 4.80865Z",
326
- fill: "currentColor"
327
- }
328
- )
329
- ),
330
- number: /* @__PURE__ */ React.createElement(
331
- "svg",
332
- {
333
- width: "1em",
334
- height: "1em",
335
- viewBox: "0 0 16 16",
336
- fill: "none",
337
- xmlns: "http://www.w3.org/2000/svg"
183
+ {
184
+ tag: [t.separator],
185
+ color: colors.separator
338
186
  },
339
- /* @__PURE__ */ React.createElement(
340
- "path",
341
- {
342
- fillRule: "evenodd",
343
- clipRule: "evenodd",
344
- d: "M3.6139 1.58154H0V14.4191H3.6139V13.1269H1.36702V2.87375H3.6139V1.58154ZM3.41656 13.3271V13.3269H1.17155V13.3271H3.41656ZM0.199219 14.2191H0.197344V1.78154H3.41656V1.78174H0.199219V14.2191ZM16 1.58154H12.3861V2.87375H14.633V13.1269H12.3861V14.4191H16V1.58154ZM12.5834 1.78154V2.67375H12.5853V1.78174H15.8027V1.78154H12.5834ZM12.5853 14.2191V13.3271H14.8322V2.67394H14.8303V13.3269H12.5834V14.2191H12.5853ZM6.86771 4.5C5.87019 4.5 5.00104 5.30767 5.00104 6.31667V9.63333C5.00104 10.6423 5.87019 11.45 6.86771 11.45C7.86523 11.45 8.73438 10.6423 8.73438 9.63333V6.31667C8.73438 5.30767 7.86523 4.5 6.86771 4.5ZM11.1177 4.5C10.1202 4.5 9.25104 5.30767 9.25104 6.31667V9.63333C9.25104 10.6423 10.1202 11.45 11.1177 11.45C12.1152 11.45 12.9844 10.6423 12.9844 9.63333V6.31667C12.9844 5.30767 12.1152 4.5 11.1177 4.5ZM6.13438 6.31667C6.13438 5.9503 6.47884 5.63333 6.86771 5.63333C7.25657 5.63333 7.60104 5.9503 7.60104 6.31667V9.63333C7.60104 9.9997 7.25657 10.3167 6.86771 10.3167C6.47884 10.3167 6.13438 9.9997 6.13438 9.63333V6.31667ZM10.3844 6.31667C10.3844 5.9503 10.7288 5.63333 11.1177 5.63333C11.5066 5.63333 11.851 5.9503 11.851 6.31667V9.63333C11.851 9.9997 11.5066 10.3167 11.1177 10.3167C10.7288 10.3167 10.3844 9.9997 10.3844 9.63333V6.31667ZM3.75938 9.85C3.33135 9.85 2.98438 10.197 2.98438 10.625C2.98438 11.053 3.33135 11.4 3.75938 11.4C4.1874 11.4 4.53438 11.053 4.53438 10.625C4.53438 10.197 4.1874 9.85 3.75938 9.85Z",
345
- fill: "currentColor"
346
- }
347
- )
348
- )
349
- };
350
- var getSchemaIcon = (value) => {
351
- if (value?.type === "array") {
352
- return ArrayIcons[value.items?.type || "object"];
353
- }
354
- return VariableTypeIcons[value?.type || "object"];
355
- };
356
- var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
357
- var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
358
- var baseOptions = [
359
- {
360
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "string" }) }), firstUppercase("string")),
361
- value: "string"
362
- },
363
- {
364
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "integer" }) }), firstUppercase("integer")),
365
- value: "integer"
366
- },
367
- {
368
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "number" }) }), firstUppercase("number")),
369
- value: "number"
370
- },
371
- {
372
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "boolean" }) }), firstUppercase("boolean")),
373
- value: "boolean"
374
- },
375
- {
376
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "object" }) }), firstUppercase("object")),
377
- value: "object"
378
- }
379
- ];
380
- var options = [
381
- ...baseOptions,
382
- {
383
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: getSchemaIcon({ type: "array" }) }), firstUppercase("array")),
384
- value: "array",
385
- children: baseOptions.map((_opt) => ({
386
- ..._opt,
387
- value: `${_opt.value}`,
388
- label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(
389
- Icon,
390
- {
391
- size: "small",
392
- svg: getSchemaIcon({ type: "array", items: { type: _opt.value } })
393
- }
394
- ), firstUppercase(_opt.value))
395
- }))
396
- }
397
- ];
398
-
399
- // src/utils/json-schema/index.ts
400
- import { get } from "lodash";
401
- import { ASTFactory, ASTKind, ASTMatch } from "@flowgram.ai/editor";
402
- var JsonSchemaUtils;
403
- ((JsonSchemaUtils2) => {
404
- function schemaToAST(jsonSchema) {
405
- const { type, extra } = jsonSchema || {};
406
- const { weak = false } = extra || {};
407
- if (!type) {
408
- return void 0;
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"
409
211
  }
410
- switch (type) {
411
- case "object":
412
- if (weak) {
413
- return { kind: ASTKind.Object, weak: true };
414
- }
415
- return ASTFactory.createObject({
416
- properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => (get(a?.[1], "extra.index") || 0) - (get(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
417
- key,
418
- type: schemaToAST(_property),
419
- meta: {
420
- title: _property.title,
421
- description: _property.description
422
- }
423
- }))
424
- });
425
- case "array":
426
- if (weak) {
427
- return { kind: ASTKind.Array, weak: true };
428
- }
429
- return ASTFactory.createArray({
430
- items: schemaToAST(jsonSchema.items)
431
- });
432
- case "map":
433
- if (weak) {
434
- return { kind: ASTKind.Map, weak: true };
435
- }
436
- return ASTFactory.createMap({
437
- valueType: schemaToAST(jsonSchema.additionalProperties)
438
- });
439
- case "string":
440
- return ASTFactory.createString();
441
- case "number":
442
- return ASTFactory.createNumber();
443
- case "boolean":
444
- return ASTFactory.createBoolean();
445
- case "integer":
446
- return ASTFactory.createInteger();
447
- default:
448
- return ASTFactory.createCustomType({ typeName: type });
449
- }
450
- }
451
- JsonSchemaUtils2.schemaToAST = schemaToAST;
452
- function astToSchema(typeAST, options2) {
453
- const { drilldown = true } = options2 || {};
454
- if (ASTMatch.isString(typeAST)) {
455
- return {
456
- type: "string"
457
- };
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"
458
266
  }
459
- if (ASTMatch.isBoolean(typeAST)) {
460
- return {
461
- type: "boolean"
462
- };
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"
463
322
  }
464
- if (ASTMatch.isNumber(typeAST)) {
465
- return {
466
- type: "number"
467
- };
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"
468
335
  }
469
- if (ASTMatch.isInteger(typeAST)) {
470
- return {
471
- type: "integer"
472
- };
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();
473
353
  }
474
- if (ASTMatch.isObject(typeAST)) {
475
- return {
476
- type: "object",
477
- properties: drilldown ? Object.fromEntries(
478
- typeAST.properties.map((property) => {
479
- const schema = astToSchema(property.type);
480
- if (property.meta?.title && schema) {
481
- schema.title = property.meta.title;
482
- }
483
- if (property.meta?.description && schema) {
484
- schema.description = property.meta.description;
485
- }
486
- return [property.key, schema];
487
- })
488
- ) : {}
489
- };
354
+ }, [languageId]);
355
+ useEffect(() => {
356
+ if (editorRef.current?.getValue() !== value) {
357
+ editorRef.current?.setValue(String(value || ""));
490
358
  }
491
- if (ASTMatch.isArray(typeAST)) {
492
- return {
493
- type: "array",
494
- items: drilldown ? astToSchema(typeAST.items) : void 0
495
- };
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
+ }
496
399
  }
497
- if (ASTMatch.isMap(typeAST)) {
498
- return {
499
- type: "map",
500
- items: drilldown ? astToSchema(typeAST.valueType) : void 0
501
- };
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
502
414
  }
503
- if (ASTMatch.isCustomType(typeAST)) {
504
- return {
505
- type: typeAST.typeName
506
- };
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
507
448
  }
508
- return void 0;
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
+ );
509
474
  }
510
- JsonSchemaUtils2.astToSchema = astToSchema;
511
- function isASTMatchSchema(typeAST, schema) {
512
- if (Array.isArray(schema)) {
513
- return typeAST.isTypeEqual(
514
- ASTFactory.createUnion({
515
- types: schema.map((_schema) => schemaToAST(_schema)).filter(Boolean)
516
- })
517
- );
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
518
489
  }
519
- return typeAST.isTypeEqual(schemaToAST(schema));
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
505
+ 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
528
+ 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);
520
548
  }
521
- JsonSchemaUtils2.isASTMatchSchema = isASTMatchSchema;
522
- })(JsonSchemaUtils || (JsonSchemaUtils = {}));
549
+ });
523
550
 
524
551
  // src/components/variable-selector/use-variable-tree.tsx
525
552
  function useVariableTree(params) {
526
- const { includeSchema, excludeSchema } = params;
553
+ const { includeSchema, excludeSchema, customSkip } = params;
554
+ const typeManager = useTypeManager();
527
555
  const variables = useAvailableVariables();
528
556
  const getVariableTypeIcon = useCallback((variable) => {
529
557
  if (variable.meta?.icon) {
530
558
  if (typeof variable.meta.icon === "string") {
531
- return /* @__PURE__ */ React2.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
559
+ return /* @__PURE__ */ React10.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
532
560
  }
533
561
  return variable.meta.icon;
534
562
  }
535
- const _type = variable.type;
536
- if (ASTMatch2.isArray(_type)) {
537
- return /* @__PURE__ */ React2.createElement(
538
- Icon2,
539
- {
540
- size: "small",
541
- svg: ArrayIcons[_type.items?.kind.toLowerCase()] || VariableTypeIcons.array
542
- }
543
- );
544
- }
545
- if (ASTMatch2.isCustomType(_type)) {
546
- return /* @__PURE__ */ React2.createElement(Icon2, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
547
- }
548
- return /* @__PURE__ */ React2.createElement(Icon2, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
563
+ const schema = JsonSchemaUtils2.astToSchema(variable.type, { drilldownObject: false });
564
+ return /* @__PURE__ */ React10.createElement(Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
549
565
  }, []);
550
566
  const renderVariable = (variable, parentFields = []) => {
551
567
  let type = variable?.type;
@@ -558,9 +574,11 @@ function useVariableTree(params) {
558
574
  }
559
575
  const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
560
576
  const key = keyPath.join(".");
561
- const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
562
- const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
563
- const isSchemaMatch = isSchemaInclude && !isSchemaExclude;
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;
564
582
  if (!isSchemaMatch && !children?.length) {
565
583
  return null;
566
584
  }
@@ -572,16 +590,17 @@ function useVariableTree(params) {
572
590
  icon: getVariableTypeIcon(variable),
573
591
  children,
574
592
  disabled: !isSchemaMatch,
575
- rootMeta: parentFields[0]?.meta
593
+ rootMeta: parentFields[0]?.meta || variable.meta,
594
+ isRoot: !parentFields?.length
576
595
  };
577
596
  };
578
597
  return [...variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
579
598
  }
580
599
 
581
600
  // src/components/variable-selector/styles.tsx
582
- import styled from "styled-components";
601
+ import styled2, { css } from "styled-components";
583
602
  import { Tag, TreeSelect } from "@douyinfe/semi-ui";
584
- var UIRootTitle = styled.div`
603
+ var UIRootTitle = styled2.div`
585
604
  margin-right: 4px;
586
605
  min-width: 20px;
587
606
  overflow: hidden;
@@ -589,13 +608,16 @@ var UIRootTitle = styled.div`
589
608
  white-space: nowrap;
590
609
  color: var(--semi-color-text-2);
591
610
  `;
592
- var UIVarName = styled.div`
611
+ var UIVarName = styled2.div`
593
612
  overflow: hidden;
594
613
  text-overflow: ellipsis;
595
614
  white-space: nowrap;
596
- min-width: 50%;
615
+
616
+ ${({ $inSelector }) => $inSelector && css`
617
+ min-width: 50%;
618
+ `}
597
619
  `;
598
- var UITag = styled(Tag)`
620
+ var UITag = styled2(Tag)`
599
621
  width: 100%;
600
622
  display: flex;
601
623
  align-items: center;
@@ -607,17 +629,14 @@ var UITag = styled(Tag)`
607
629
 
608
630
  &.semi-tag {
609
631
  margin: 0;
632
+ height: 22px;
610
633
  }
611
634
  `;
612
- var UITreeSelect = styled(TreeSelect)`
635
+ var UITreeSelect = styled2(TreeSelect)`
613
636
  outline: ${({ $error }) => $error ? "1px solid red" : "none"};
614
637
 
615
- height: 22px;
616
- min-height: 22px;
617
- line-height: 22px;
618
-
619
638
  & .semi-tree-select-selection {
620
- padding: 0 2px;
639
+ padding: 0px;
621
640
  height: 22px;
622
641
  }
623
642
 
@@ -629,6 +648,13 @@ var UITreeSelect = styled(TreeSelect)`
629
648
  padding-left: 10px;
630
649
  }
631
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
+ `;
632
658
 
633
659
  // src/components/variable-selector/index.tsx
634
660
  var VariableSelector = ({
@@ -655,11 +681,11 @@ var VariableSelector = ({
655
681
  }, [value]);
656
682
  const renderIcon = (icon) => {
657
683
  if (typeof icon === "string") {
658
- return /* @__PURE__ */ React3.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
684
+ return /* @__PURE__ */ React11.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
659
685
  }
660
686
  return icon;
661
687
  };
662
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
688
+ return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(
663
689
  UITreeSelect,
664
690
  {
665
691
  dropdownMatchSelectWidth: false,
@@ -676,10 +702,10 @@ var VariableSelector = ({
676
702
  },
677
703
  renderSelectedItem: (_option) => {
678
704
  if (!_option?.keyPath) {
679
- return /* @__PURE__ */ React3.createElement(
705
+ return /* @__PURE__ */ React11.createElement(
680
706
  UITag,
681
707
  {
682
- prefixIcon: /* @__PURE__ */ React3.createElement(IconIssueStroked, null),
708
+ prefixIcon: /* @__PURE__ */ React11.createElement(IconIssueStroked, null),
683
709
  color: "amber",
684
710
  closable: !readonly,
685
711
  onClose: () => onChange(void 0)
@@ -687,28 +713,38 @@ var VariableSelector = ({
687
713
  config?.notFoundContent ?? "Undefined"
688
714
  );
689
715
  }
690
- return /* @__PURE__ */ React3.createElement(
691
- UITag,
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,
692
720
  {
693
- prefixIcon: renderIcon(_option.rootMeta?.icon || _option?.icon),
694
- closable: !readonly,
695
- onClose: () => onChange(void 0)
721
+ content: /* @__PURE__ */ React11.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React11.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
696
722
  },
697
- /* @__PURE__ */ React3.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null),
698
- /* @__PURE__ */ React3.createElement(UIVarName, null, _option.label)
699
- );
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
+ ));
700
734
  },
701
735
  showClear: false,
702
- arrowIcon: /* @__PURE__ */ React3.createElement(IconChevronDownStroked, { size: "small" }),
736
+ arrowIcon: /* @__PURE__ */ React11.createElement(IconChevronDownStroked, { size: "small" }),
703
737
  triggerRender,
704
- placeholder: config?.placeholder ?? "Select Variable..."
738
+ placeholder: config?.placeholder ?? "Select Variable"
705
739
  }
706
740
  ));
707
741
  };
708
742
 
709
743
  // src/components/type-selector/index.tsx
710
- import React4, { useMemo as useMemo2 } from "react";
711
- import { Button, Cascader } from "@douyinfe/semi-ui";
744
+ import React12, { useMemo as useMemo2 } from "react";
745
+ import { Cascader, Icon as Icon2, IconButton } from "@douyinfe/semi-ui";
746
+ var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
747
+ var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
712
748
  var getTypeSelectValue = (value) => {
713
749
  if (value?.type === "array" && value?.items) {
714
750
  return [value.type, ...getTypeSelectValue(value.items) || []];
@@ -723,27 +759,52 @@ var parseTypeSelectValue = (value) => {
723
759
  return { type };
724
760
  };
725
761
  function TypeSelector(props) {
726
- const { value, onChange, disabled, style } = props;
762
+ const { value, onChange, readonly, disabled, style } = props;
727
763
  const selectValue = useMemo2(() => getTypeSelectValue(value), [value]);
728
- return /* @__PURE__ */ React4.createElement(
729
- Cascader,
730
- {
731
- disabled,
732
- size: "small",
733
- triggerRender: () => /* @__PURE__ */ React4.createElement(Button, { size: "small", style }, getSchemaIcon(value)),
734
- treeData: options,
735
- value: selectValue,
736
- leafOnly: true,
764
+ const typeManager = useTypeManager();
765
+ const icon = typeManager.getDisplayIcon(value || {});
766
+ const options = useMemo2(
767
+ () => typeManager.getTypeRegistriesWithParentType().map((_type) => {
768
+ const isArray2 = _type.type === "array";
769
+ return {
770
+ label: /* @__PURE__ */ React12.createElement("div", { style: labelStyle }, /* @__PURE__ */ React12.createElement(Icon2, { size: "small", svg: _type.icon }), firstUppercase(_type.type)),
771
+ value: _type.type,
772
+ children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
773
+ label: /* @__PURE__ */ React12.createElement("div", { style: labelStyle }, /* @__PURE__ */ React12.createElement(
774
+ Icon2,
775
+ {
776
+ size: "small",
777
+ svg: typeManager.getDisplayIcon({
778
+ type: "array",
779
+ items: { type: _type2.type }
780
+ })
781
+ }
782
+ ), firstUppercase(_type2.type)),
783
+ value: _type2.type
784
+ })) : []
785
+ };
786
+ }),
787
+ []
788
+ );
789
+ return /* @__PURE__ */ React12.createElement(
790
+ Cascader,
791
+ {
792
+ disabled: readonly || disabled,
793
+ size: "small",
794
+ triggerRender: () => /* @__PURE__ */ React12.createElement(IconButton, { size: "small", style, disabled: readonly || disabled, icon }),
795
+ treeData: options,
796
+ value: selectValue,
797
+ leafOnly: true,
737
798
  onChange: (value2) => {
738
- onChange(parseTypeSelectValue(value2));
799
+ onChange?.(parseTypeSelectValue(value2));
739
800
  }
740
801
  }
741
802
  );
742
803
  }
743
804
 
744
805
  // src/components/json-schema-editor/index.tsx
745
- import React9, { useMemo as useMemo5, useState as useState4 } from "react";
746
- import { Button as Button2, Checkbox, IconButton as IconButton2 } from "@douyinfe/semi-ui";
806
+ import React17, { useMemo as useMemo5, useState as useState4 } from "react";
807
+ import { Button, Checkbox, IconButton as IconButton3 } from "@douyinfe/semi-ui";
747
808
  import {
748
809
  IconExpand,
749
810
  IconShrink,
@@ -754,45 +815,45 @@ import {
754
815
  } from "@douyinfe/semi-icons";
755
816
 
756
817
  // src/components/json-schema-editor/styles.tsx
757
- import React5 from "react";
758
- import styled2, { css } from "styled-components";
818
+ import React13 from "react";
819
+ import styled3, { css as css2 } from "styled-components";
759
820
  import Icon3 from "@douyinfe/semi-icons";
760
- var UIContainer = styled2.div`
821
+ var UIContainer = styled3.div`
761
822
  /* & .semi-input {
762
823
  background-color: #fff;
763
824
  border-radius: 6px;
764
825
  height: 24px;
765
826
  } */
766
827
  `;
767
- var UIRow = styled2.div`
828
+ var UIRow = styled3.div`
768
829
  display: flex;
769
830
  align-items: center;
770
831
  gap: 6px;
771
832
  `;
772
- var UICollapseTrigger = styled2.div`
833
+ var UICollapseTrigger = styled3.div`
773
834
  cursor: pointer;
774
835
  margin-right: 5px;
775
836
  `;
776
- var UIExpandDetail = styled2.div`
837
+ var UIExpandDetail = styled3.div`
777
838
  display: flex;
778
839
  flex-direction: column;
779
840
  `;
780
- var UILabel = styled2.div`
841
+ var UILabel = styled3.div`
781
842
  font-size: 12px;
782
843
  color: #999;
783
844
  font-weight: 400;
784
845
  margin-bottom: 2px;
785
846
  `;
786
- var UIProperties = styled2.div`
847
+ var UIProperties = styled3.div`
787
848
  display: grid;
788
849
  grid-template-columns: auto 1fr;
789
850
 
790
- ${({ $shrink }) => $shrink && css`
851
+ ${({ $shrink }) => $shrink && css2`
791
852
  padding-left: 10px;
792
853
  margin-top: 10px;
793
854
  `}
794
855
  `;
795
- var UIPropertyLeft = styled2.div`
856
+ var UIPropertyLeft = styled3.div`
796
857
  grid-column: 1;
797
858
  position: relative;
798
859
  width: 16px;
@@ -802,7 +863,7 @@ var UIPropertyLeft = styled2.div`
802
863
  if ($parentType && $isLast) {
803
864
  height = "24px";
804
865
  }
805
- return $showLine && css`
866
+ return $showLine && css2`
806
867
  &::before {
807
868
  /* 竖线 */
808
869
  content: '';
@@ -829,7 +890,7 @@ var UIPropertyLeft = styled2.div`
829
890
  `;
830
891
  }}
831
892
  `;
832
- var UIPropertyRight = styled2.div`
893
+ var UIPropertyRight = styled3.div`
833
894
  grid-column: 2;
834
895
  margin-bottom: 10px;
835
896
 
@@ -837,7 +898,7 @@ var UIPropertyRight = styled2.div`
837
898
  margin-bottom: 0px;
838
899
  }
839
900
  `;
840
- var UIPropertyMain = styled2.div`
901
+ var UIPropertyMain = styled3.div`
841
902
  display: flex;
842
903
  flex-direction: column;
843
904
  gap: 10px;
@@ -856,33 +917,33 @@ var UIPropertyMain = styled2.div`
856
917
  background: #d9d9d9;
857
918
  display: block;
858
919
  }`;
859
- return $expand && css`
920
+ return $expand && css2`
860
921
  background-color: #f5f5f5;
861
922
  padding: 10px;
862
923
  border-radius: 4px;
863
924
 
864
- ${$showCollapse && $collapse && (type === "array" || type === "object") && css`
925
+ ${$showCollapse && $collapse && (type === "array" || type === "object") && css2`
865
926
  ${beforeElement}
866
927
  `}
867
928
  `;
868
929
  }}
869
930
  `;
870
- var UICollapsible = styled2.div`
931
+ var UICollapsible = styled3.div`
871
932
  display: none;
872
933
 
873
- ${({ $collapse }) => $collapse && css`
934
+ ${({ $collapse }) => $collapse && css2`
874
935
  display: block;
875
936
  `}
876
937
  `;
877
- var UIName = styled2.div`
938
+ var UIName = styled3.div`
878
939
  flex-grow: 1;
879
940
  `;
880
- var UIType = styled2.div``;
881
- var UIRequired = styled2.div``;
882
- var UIActions = styled2.div`
941
+ var UIType = styled3.div``;
942
+ var UIRequired = styled3.div``;
943
+ var UIActions = styled3.div`
883
944
  white-space: nowrap;
884
945
  `;
885
- var iconAddChildrenSvg = /* @__PURE__ */ React5.createElement(
946
+ var iconAddChildrenSvg = /* @__PURE__ */ React13.createElement(
886
947
  "svg",
887
948
  {
888
949
  className: "icon-icon icon-icon-coz_add_node ",
@@ -892,7 +953,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ React5.createElement(
892
953
  fill: "currentColor",
893
954
  xmlns: "http://www.w3.org/2000/svg"
894
955
  },
895
- /* @__PURE__ */ React5.createElement(
956
+ /* @__PURE__ */ React13.createElement(
896
957
  "path",
897
958
  {
898
959
  fillRule: "evenodd",
@@ -900,19 +961,19 @@ var iconAddChildrenSvg = /* @__PURE__ */ React5.createElement(
900
961
  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"
901
962
  }
902
963
  ),
903
- /* @__PURE__ */ React5.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" })
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" })
904
965
  );
905
- var IconAddChildren = () => /* @__PURE__ */ React5.createElement(Icon3, { size: "small", svg: iconAddChildrenSvg });
906
- var DefaultValueWrapper = styled2.div`
966
+ var IconAddChildren = () => /* @__PURE__ */ React13.createElement(Icon3, { size: "small", svg: iconAddChildrenSvg });
967
+ var DefaultValueWrapper = styled3.div`
907
968
  margin: 0;
908
969
  `;
909
- var JSONViewerWrapper = styled2.div`
970
+ var JSONViewerWrapper = styled3.div`
910
971
  padding: 0 0 24px;
911
972
  &:first-child {
912
973
  margin-top: 0px;
913
974
  }
914
975
  `;
915
- var JSONHeader = styled2.div`
976
+ var JSONHeader = styled3.div`
916
977
  display: flex;
917
978
  justify-content: space-between;
918
979
  align-items: center;
@@ -921,17 +982,17 @@ var JSONHeader = styled2.div`
921
982
  height: 36px;
922
983
  padding: 0 8px 0 12px;
923
984
  `;
924
- var JSONHeaderLeft = styled2.div`
985
+ var JSONHeaderLeft = styled3.div`
925
986
  display: flex;
926
987
  align-items: center;
927
988
  gap: 10px;
928
989
  `;
929
- var JSONHeaderRight = styled2.div`
990
+ var JSONHeaderRight = styled3.div`
930
991
  display: flex;
931
992
  align-items: center;
932
993
  gap: 10px;
933
994
  `;
934
- var ConstantInputWrapper = styled2.div`
995
+ var ConstantInputWrapper = styled3.div`
935
996
  flex-grow: 1;
936
997
 
937
998
  & .semi-tree-select,
@@ -942,7 +1003,8 @@ var ConstantInputWrapper = styled2.div`
942
1003
  `;
943
1004
 
944
1005
  // src/components/json-schema-editor/hooks.tsx
945
- import { useEffect, useMemo as useMemo3, useRef, useState } from "react";
1006
+ import { useEffect as useEffect2, useMemo as useMemo3, useRef as useRef2, useState } from "react";
1007
+ import { omit } from "lodash";
946
1008
  var _id = 0;
947
1009
  function genId() {
948
1010
  return _id++;
@@ -975,8 +1037,8 @@ function usePropertiesEdit(value, onChange) {
975
1037
  [isDrilldownObject]
976
1038
  );
977
1039
  const [propertyList, setPropertyList] = useState(initPropertyList);
978
- const mountRef = useRef(false);
979
- useEffect(() => {
1040
+ const mountRef = useRef2(false);
1041
+ useEffect2(() => {
980
1042
  if (mountRef.current) {
981
1043
  setPropertyList((_list) => {
982
1044
  const nameMap = /* @__PURE__ */ new Map();
@@ -1015,7 +1077,7 @@ function usePropertiesEdit(value, onChange) {
1015
1077
  if (!_property.name) {
1016
1078
  continue;
1017
1079
  }
1018
- nextProperties[_property.name] = _property;
1080
+ nextProperties[_property.name] = omit(_property, ["key", "name", "isPropertyRequired"]);
1019
1081
  if (_property.isPropertyRequired) {
1020
1082
  nextRequired.push(_property.name);
1021
1083
  }
@@ -1044,7 +1106,7 @@ function usePropertiesEdit(value, onChange) {
1044
1106
  (_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
1045
1107
  );
1046
1108
  };
1047
- useEffect(() => {
1109
+ useEffect2(() => {
1048
1110
  if (!isDrilldownObject) {
1049
1111
  setPropertyList([]);
1050
1112
  }
@@ -1059,8 +1121,8 @@ function usePropertiesEdit(value, onChange) {
1059
1121
  }
1060
1122
 
1061
1123
  // src/components/json-schema-editor/default-value.tsx
1062
- import React7, { useRef as useRef2, useState as useState2, useCallback as useCallback2 } from "react";
1063
- import { IconButton, JsonViewer, Tooltip } from "@douyinfe/semi-ui";
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";
1064
1126
  import { IconBrackets } from "@douyinfe/semi-icons";
1065
1127
 
1066
1128
  // src/components/json-schema-editor/utils.ts
@@ -1083,83 +1145,37 @@ function getValueType(value) {
1083
1145
  }
1084
1146
 
1085
1147
  // src/components/constant-input/index.tsx
1086
- import React6, { useMemo as useMemo4 } from "react";
1087
- import { Input, InputNumber, Select } from "@douyinfe/semi-ui";
1088
- var defaultStrategies = [
1089
- {
1090
- hit: (schema) => schema?.type === "string",
1091
- Renderer: (props) => /* @__PURE__ */ React6.createElement(Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
1092
- },
1093
- {
1094
- hit: (schema) => schema?.type === "number",
1095
- Renderer: (props) => /* @__PURE__ */ React6.createElement(
1096
- InputNumber,
1097
- {
1098
- placeholder: "Please Input Number",
1099
- size: "small",
1100
- disabled: props.readonly,
1101
- hideButtons: true,
1102
- ...props
1103
- }
1104
- )
1105
- },
1106
- {
1107
- hit: (schema) => schema?.type === "integer",
1108
- Renderer: (props) => /* @__PURE__ */ React6.createElement(
1109
- InputNumber,
1110
- {
1111
- placeholder: "Please Input Integer",
1112
- size: "small",
1113
- disabled: props.readonly,
1114
- hideButtons: true,
1115
- precision: 0,
1116
- ...props
1117
- }
1118
- )
1119
- },
1120
- {
1121
- hit: (schema) => schema?.type === "boolean",
1122
- Renderer: (props) => {
1123
- const { value, onChange, ...rest } = props;
1124
- return /* @__PURE__ */ React6.createElement(
1125
- Select,
1126
- {
1127
- placeholder: "Please Select Boolean",
1128
- size: "small",
1129
- disabled: props.readonly,
1130
- optionList: [
1131
- { label: "True", value: 1 },
1132
- { label: "False", value: 0 }
1133
- ],
1134
- value: value ? 1 : 0,
1135
- onChange: (value2) => onChange?.(!!value2),
1136
- ...rest
1137
- }
1138
- );
1139
- }
1140
- }
1141
- ];
1148
+ import React14, { useMemo as useMemo4 } from "react";
1149
+ import { Input as Input2 } from "@douyinfe/semi-ui";
1142
1150
  function ConstantInput(props) {
1143
- const { value, onChange, schema, strategies: extraStrategies, readonly, ...rest } = props;
1144
- const strategies = useMemo4(
1145
- () => [...defaultStrategies, ...extraStrategies || []],
1146
- [extraStrategies]
1147
- );
1151
+ const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
1152
+ const typeManager = useTypeManager();
1148
1153
  const Renderer2 = useMemo4(() => {
1149
- const strategy = strategies.find((_strategy) => _strategy.hit(schema));
1154
+ const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
1155
+ if (!strategy) {
1156
+ return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
1157
+ }
1150
1158
  return strategy?.Renderer;
1151
1159
  }, [strategies, schema]);
1152
1160
  if (!Renderer2) {
1153
- return /* @__PURE__ */ React6.createElement(Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
1161
+ if (fallbackRenderer) {
1162
+ return React14.createElement(fallbackRenderer, {
1163
+ value,
1164
+ onChange,
1165
+ readonly,
1166
+ ...rest
1167
+ });
1168
+ }
1169
+ return /* @__PURE__ */ React14.createElement(Input2, { size: "small", disabled: true, placeholder: "Unsupported type" });
1154
1170
  }
1155
- return /* @__PURE__ */ React6.createElement(Renderer2, { value, onChange, readonly, ...rest });
1171
+ return /* @__PURE__ */ React14.createElement(Renderer2, { value, onChange, readonly, ...rest });
1156
1172
  }
1157
1173
 
1158
1174
  // src/components/json-schema-editor/default-value.tsx
1159
1175
  function DefaultValue(props) {
1160
1176
  const { value, schema, type, onChange, placeholder, jsonFormatText } = props;
1161
- const wrapperRef = useRef2(null);
1162
- const JsonViewerRef = useRef2(null);
1177
+ const wrapperRef = useRef3(null);
1178
+ const JsonViewerRef = useRef3(null);
1163
1179
  const [internalJsonValue, setInternalJsonValue] = useState2(
1164
1180
  getValueType(value) === "string" ? value : ""
1165
1181
  );
@@ -1186,16 +1202,16 @@ function DefaultValue(props) {
1186
1202
  console.error("Invalid JSON:", error);
1187
1203
  }
1188
1204
  }, [internalJsonValue, onChange]);
1189
- return type === "object" ? /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(JSONHeader, null, /* @__PURE__ */ React7.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ React7.createElement(JSONHeaderRight, null, /* @__PURE__ */ React7.createElement(Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ React7.createElement(
1190
- IconButton,
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,
1191
1207
  {
1192
- icon: /* @__PURE__ */ React7.createElement(IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
1208
+ icon: /* @__PURE__ */ React15.createElement(IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
1193
1209
  size: "small",
1194
1210
  type: "tertiary",
1195
1211
  theme: "borderless",
1196
1212
  onClick: handleFormatJson
1197
1213
  }
1198
- )))), /* @__PURE__ */ React7.createElement(
1214
+ )))), /* @__PURE__ */ React15.createElement(
1199
1215
  JSONViewerWrapper,
1200
1216
  {
1201
1217
  ref: wrapperRef,
@@ -1209,7 +1225,7 @@ function DefaultValue(props) {
1209
1225
  setJsonReadOnly(false);
1210
1226
  }
1211
1227
  },
1212
- /* @__PURE__ */ React7.createElement(
1228
+ /* @__PURE__ */ React15.createElement(
1213
1229
  JsonViewer,
1214
1230
  {
1215
1231
  ref: JsonViewerRef,
@@ -1227,7 +1243,7 @@ function DefaultValue(props) {
1227
1243
  onChange: handleJsonChange
1228
1244
  }
1229
1245
  )
1230
- )) : /* @__PURE__ */ React7.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React7.createElement(
1246
+ )) : /* @__PURE__ */ React15.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React15.createElement(
1231
1247
  ConstantInput,
1232
1248
  {
1233
1249
  value,
@@ -1239,15 +1255,15 @@ function DefaultValue(props) {
1239
1255
  }
1240
1256
 
1241
1257
  // src/components/json-schema-editor/components/blur-input.tsx
1242
- import React8, { useEffect as useEffect2, useState as useState3 } from "react";
1243
- import Input2 from "@douyinfe/semi-ui/lib/es/input";
1258
+ import React16, { useEffect as useEffect3, useState as useState3 } from "react";
1259
+ import Input3 from "@douyinfe/semi-ui/lib/es/input";
1244
1260
  function BlurInput(props) {
1245
1261
  const [value, setValue] = useState3("");
1246
- useEffect2(() => {
1262
+ useEffect3(() => {
1247
1263
  setValue(props.value);
1248
1264
  }, [props.value]);
1249
- return /* @__PURE__ */ React8.createElement(
1250
- Input2,
1265
+ return /* @__PURE__ */ React16.createElement(
1266
+ Input3,
1251
1267
  {
1252
1268
  ...props,
1253
1269
  value,
@@ -1261,14 +1277,15 @@ function BlurInput(props) {
1261
1277
 
1262
1278
  // src/components/json-schema-editor/index.tsx
1263
1279
  function JsonSchemaEditor(props) {
1264
- const { value = { type: "object" }, config = {}, onChange: onChangeProps } = props;
1280
+ const { value = { type: "object" }, config = {}, onChange: onChangeProps, readonly } = props;
1265
1281
  const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
1266
1282
  value,
1267
1283
  onChangeProps
1268
1284
  );
1269
- return /* @__PURE__ */ React9.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React9.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ React9.createElement(
1285
+ return /* @__PURE__ */ React17.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React17.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ React17.createElement(
1270
1286
  PropertyEdit,
1271
1287
  {
1288
+ readonly,
1272
1289
  key: _property.key,
1273
1290
  value: _property,
1274
1291
  config,
@@ -1280,12 +1297,13 @@ function JsonSchemaEditor(props) {
1280
1297
  onRemoveProperty(_property.key);
1281
1298
  }
1282
1299
  }
1283
- ))), /* @__PURE__ */ React9.createElement(
1284
- Button2,
1300
+ ))), /* @__PURE__ */ React17.createElement(
1301
+ Button,
1285
1302
  {
1303
+ disabled: readonly,
1286
1304
  size: "small",
1287
1305
  style: { marginTop: 10, marginLeft: 16 },
1288
- icon: /* @__PURE__ */ React9.createElement(IconPlus, null),
1306
+ icon: /* @__PURE__ */ React17.createElement(IconPlus, null),
1289
1307
  onClick: onAddProperty
1290
1308
  },
1291
1309
  config?.addButtonText ?? "Add"
@@ -1295,6 +1313,7 @@ function PropertyEdit(props) {
1295
1313
  const {
1296
1314
  value,
1297
1315
  config,
1316
+ readonly,
1298
1317
  $level = 0,
1299
1318
  onChange: onChangeProps,
1300
1319
  onRemove,
@@ -1317,7 +1336,7 @@ function PropertyEdit(props) {
1317
1336
  });
1318
1337
  };
1319
1338
  const showCollapse = isDrilldownObject && propertyList.length > 0;
1320
- return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
1339
+ return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(
1321
1340
  UIPropertyLeft,
1322
1341
  {
1323
1342
  type,
@@ -1329,8 +1348,8 @@ function PropertyEdit(props) {
1329
1348
  $parentExpand,
1330
1349
  $parentType
1331
1350
  },
1332
- showCollapse && /* @__PURE__ */ React9.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React9.createElement(IconChevronDown, { size: "small" }) : /* @__PURE__ */ React9.createElement(IconChevronRight, { size: "small" }))
1333
- ), /* @__PURE__ */ React9.createElement(UIPropertyRight, null, /* @__PURE__ */ React9.createElement(
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(
1334
1353
  UIPropertyMain,
1335
1354
  {
1336
1355
  $showCollapse: showCollapse,
@@ -1338,18 +1357,20 @@ function PropertyEdit(props) {
1338
1357
  $expand: expand,
1339
1358
  type
1340
1359
  },
1341
- /* @__PURE__ */ React9.createElement(UIRow, null, /* @__PURE__ */ React9.createElement(UIName, null, /* @__PURE__ */ React9.createElement(
1360
+ /* @__PURE__ */ React17.createElement(UIRow, null, /* @__PURE__ */ React17.createElement(UIName, null, /* @__PURE__ */ React17.createElement(
1342
1361
  BlurInput,
1343
1362
  {
1363
+ disabled: readonly,
1344
1364
  placeholder: config?.placeholder ?? "Input Variable Name",
1345
1365
  size: "small",
1346
1366
  value: name,
1347
1367
  onChange: (value2) => onChange("name", value2)
1348
1368
  }
1349
- )), /* @__PURE__ */ React9.createElement(UIType, null, /* @__PURE__ */ React9.createElement(
1369
+ )), /* @__PURE__ */ React17.createElement(UIType, null, /* @__PURE__ */ React17.createElement(
1350
1370
  TypeSelector,
1351
1371
  {
1352
1372
  value: typeSelectorValue,
1373
+ readonly,
1353
1374
  onChange: (_value) => {
1354
1375
  onChangeProps?.({
1355
1376
  ...value || {},
@@ -1357,51 +1378,56 @@ function PropertyEdit(props) {
1357
1378
  });
1358
1379
  }
1359
1380
  }
1360
- )), /* @__PURE__ */ React9.createElement(UIRequired, null, /* @__PURE__ */ React9.createElement(
1381
+ )), /* @__PURE__ */ React17.createElement(UIRequired, null, /* @__PURE__ */ React17.createElement(
1361
1382
  Checkbox,
1362
1383
  {
1384
+ disabled: readonly,
1363
1385
  checked: isPropertyRequired,
1364
1386
  onChange: (e) => onChange("isPropertyRequired", e.target.checked)
1365
1387
  }
1366
- )), /* @__PURE__ */ React9.createElement(UIActions, null, /* @__PURE__ */ React9.createElement(
1367
- IconButton2,
1388
+ )), /* @__PURE__ */ React17.createElement(UIActions, null, /* @__PURE__ */ React17.createElement(
1389
+ IconButton3,
1368
1390
  {
1391
+ disabled: readonly,
1369
1392
  size: "small",
1370
1393
  theme: "borderless",
1371
- icon: expand ? /* @__PURE__ */ React9.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React9.createElement(IconExpand, { size: "small" }),
1394
+ icon: expand ? /* @__PURE__ */ React17.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React17.createElement(IconExpand, { size: "small" }),
1372
1395
  onClick: () => {
1373
1396
  setExpand((_expand) => !_expand);
1374
1397
  }
1375
1398
  }
1376
- ), isDrilldownObject && /* @__PURE__ */ React9.createElement(
1377
- IconButton2,
1399
+ ), isDrilldownObject && /* @__PURE__ */ React17.createElement(
1400
+ IconButton3,
1378
1401
  {
1402
+ disabled: readonly,
1379
1403
  size: "small",
1380
1404
  theme: "borderless",
1381
- icon: /* @__PURE__ */ React9.createElement(IconAddChildren, null),
1405
+ icon: /* @__PURE__ */ React17.createElement(IconAddChildren, null),
1382
1406
  onClick: () => {
1383
1407
  onAddProperty();
1384
1408
  setCollapse(true);
1385
1409
  }
1386
1410
  }
1387
- ), /* @__PURE__ */ React9.createElement(
1388
- IconButton2,
1411
+ ), /* @__PURE__ */ React17.createElement(
1412
+ IconButton3,
1389
1413
  {
1414
+ disabled: readonly,
1390
1415
  size: "small",
1391
1416
  theme: "borderless",
1392
- icon: /* @__PURE__ */ React9.createElement(IconMinus, { size: "small" }),
1417
+ icon: /* @__PURE__ */ React17.createElement(IconMinus, { size: "small" }),
1393
1418
  onClick: onRemove
1394
1419
  }
1395
1420
  ))),
1396
- expand && /* @__PURE__ */ React9.createElement(UIExpandDetail, null, /* @__PURE__ */ React9.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ React9.createElement(
1421
+ expand && /* @__PURE__ */ React17.createElement(UIExpandDetail, null, /* @__PURE__ */ React17.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ React17.createElement(
1397
1422
  BlurInput,
1398
1423
  {
1424
+ disabled: readonly,
1399
1425
  size: "small",
1400
1426
  value: description,
1401
1427
  onChange: (value2) => onChange("description", value2),
1402
1428
  placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
1403
1429
  }
1404
- ), $level === 0 && type && type !== "array" && /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? "Default Value"), /* @__PURE__ */ React9.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React9.createElement(
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(
1405
1431
  DefaultValue,
1406
1432
  {
1407
1433
  value: defaultValue,
@@ -1412,9 +1438,10 @@ function PropertyEdit(props) {
1412
1438
  onChange: (value2) => onChange("default", value2)
1413
1439
  }
1414
1440
  ))))
1415
- ), showCollapse && /* @__PURE__ */ React9.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React9.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React9.createElement(
1441
+ ), showCollapse && /* @__PURE__ */ React17.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React17.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React17.createElement(
1416
1442
  PropertyEdit,
1417
1443
  {
1444
+ readonly,
1418
1445
  key: _property.key,
1419
1446
  value: _property,
1420
1447
  config,
@@ -1436,29 +1463,35 @@ function PropertyEdit(props) {
1436
1463
  }
1437
1464
 
1438
1465
  // src/components/batch-variable-selector/index.tsx
1439
- import React10 from "react";
1466
+ import React18 from "react";
1440
1467
  import { PrivateScopeProvider } from "@flowgram.ai/editor";
1441
1468
  var batchVariableSchema = {
1442
1469
  type: "array",
1443
1470
  extra: { weak: true }
1444
1471
  };
1445
1472
  function BatchVariableSelector(props) {
1446
- return /* @__PURE__ */ React10.createElement(PrivateScopeProvider, null, /* @__PURE__ */ React10.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
1473
+ return /* @__PURE__ */ React18.createElement(PrivateScopeProvider, null, /* @__PURE__ */ React18.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
1447
1474
  }
1448
1475
 
1449
1476
  // src/components/dynamic-value-input/index.tsx
1450
- import React11, { useMemo as useMemo6 } from "react";
1451
- import { IconButton as IconButton3 } from "@douyinfe/semi-ui";
1477
+ import React19 from "react";
1478
+ import { JsonSchemaUtils as JsonSchemaUtils3 } from "@flowgram.ai/json-schema";
1479
+ import { IconButton as IconButton4 } from "@douyinfe/semi-ui";
1452
1480
  import { IconSetting } from "@douyinfe/semi-icons";
1453
1481
 
1454
1482
  // src/components/dynamic-value-input/styles.tsx
1455
- import styled3 from "styled-components";
1456
- var UIContainer2 = styled3.div`
1483
+ import styled4 from "styled-components";
1484
+ var UIContainer2 = styled4.div`
1457
1485
  display: flex;
1458
1486
  align-items: center;
1459
- gap: 5px;
1487
+ border-radius: 4px;
1488
+ border: 1px solid var(--semi-color-border);
1489
+
1490
+ overflow: hidden;
1491
+
1492
+ background-color: var(--semi-color-fill-0);
1460
1493
  `;
1461
- var UIMain = styled3.div`
1494
+ var UIMain = styled4.div`
1462
1495
  flex-grow: 1;
1463
1496
  overflow: hidden;
1464
1497
  min-width: 0;
@@ -1467,9 +1500,62 @@ var UIMain = styled3.div`
1467
1500
  & .semi-input-number,
1468
1501
  & .semi-select {
1469
1502
  width: 100%;
1503
+ border: none;
1504
+ border-radius: 0;
1505
+ }
1506
+
1507
+ & .semi-input-wrapper {
1508
+ border: none;
1509
+ border-radius: 0;
1510
+ }
1511
+ `;
1512
+ var UIType2 = styled4.div`
1513
+ border-right: 1px solid #e5e5e5;
1514
+
1515
+ & .semi-button {
1516
+ border-radius: 0;
1470
1517
  }
1471
1518
  `;
1472
- var UITrigger = styled3.div``;
1519
+ var UITrigger = styled4.div`
1520
+ border-left: 1px solid #e5e5e5;
1521
+
1522
+ & .semi-button {
1523
+ border-radius: 0;
1524
+ }
1525
+ `;
1526
+
1527
+ // src/components/dynamic-value-input/hooks.ts
1528
+ import { useMemo as useMemo6, useState as useState5 } from "react";
1529
+ import { useScopeAvailable } from "@flowgram.ai/editor";
1530
+ function useRefVariable(value) {
1531
+ const available = useScopeAvailable();
1532
+ const refVariable = useMemo6(() => {
1533
+ if (value?.type === "ref") {
1534
+ return available.getByKeyPath(value.content);
1535
+ }
1536
+ }, [value, available]);
1537
+ return refVariable;
1538
+ }
1539
+ function useSelectSchema(schemaFromProps, constantProps, value) {
1540
+ let defaultSelectSchema = schemaFromProps || constantProps?.schema || { type: "string" };
1541
+ if (value?.type === "constant") {
1542
+ defaultSelectSchema = value?.schema || defaultSelectSchema;
1543
+ }
1544
+ const [selectSchema, setSelectSchema] = useState5(defaultSelectSchema);
1545
+ return [selectSchema, setSelectSchema];
1546
+ }
1547
+ function useIncludeSchema(schemaFromProps) {
1548
+ const includeSchema = useMemo6(() => {
1549
+ if (!schemaFromProps) {
1550
+ return;
1551
+ }
1552
+ if (schemaFromProps?.type === "number") {
1553
+ return [schemaFromProps, { type: "integer" }];
1554
+ }
1555
+ return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
1556
+ }, [schemaFromProps]);
1557
+ return includeSchema;
1558
+ }
1473
1559
 
1474
1560
  // src/components/dynamic-value-input/index.tsx
1475
1561
  function DynamicValueInput({
@@ -1477,18 +1563,49 @@ function DynamicValueInput({
1477
1563
  onChange,
1478
1564
  readonly,
1479
1565
  style,
1480
- schema,
1566
+ schema: schemaFromProps,
1481
1567
  constantProps
1482
1568
  }) {
1483
- const includeSchema = useMemo6(() => {
1484
- if (schema?.type === "number") {
1485
- return [schema, { type: "integer" }];
1569
+ const refVariable = useRefVariable(value);
1570
+ const [selectSchema, setSelectSchema] = useSelectSchema(schemaFromProps, constantProps, value);
1571
+ const includeSchema = useIncludeSchema(schemaFromProps);
1572
+ const renderTypeSelector = () => {
1573
+ if (schemaFromProps) {
1574
+ return /* @__PURE__ */ React19.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
1575
+ }
1576
+ 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 });
1486
1579
  }
1487
- return schema;
1488
- }, [schema]);
1580
+ return /* @__PURE__ */ React19.createElement(
1581
+ TypeSelector,
1582
+ {
1583
+ value: selectSchema,
1584
+ onChange: (_v) => {
1585
+ setSelectSchema(_v || { type: "string" });
1586
+ let content;
1587
+ if (_v?.type === "object") {
1588
+ content = "{}";
1589
+ }
1590
+ if (_v?.type === "array") {
1591
+ content = "[]";
1592
+ }
1593
+ if (_v?.type === "boolean") {
1594
+ content = false;
1595
+ }
1596
+ onChange({
1597
+ type: "constant",
1598
+ content,
1599
+ schema: _v || { type: "string" }
1600
+ });
1601
+ },
1602
+ readonly
1603
+ }
1604
+ );
1605
+ };
1489
1606
  const renderMain = () => {
1490
1607
  if (value?.type === "ref") {
1491
- return /* @__PURE__ */ React11.createElement(
1608
+ return /* @__PURE__ */ React19.createElement(
1492
1609
  VariableSelector,
1493
1610
  {
1494
1611
  style: { width: "100%" },
@@ -1499,18 +1616,29 @@ function DynamicValueInput({
1499
1616
  }
1500
1617
  );
1501
1618
  }
1502
- return /* @__PURE__ */ React11.createElement(
1619
+ const constantSchema = schemaFromProps || selectSchema || { type: "string" };
1620
+ return /* @__PURE__ */ React19.createElement(
1503
1621
  ConstantInput,
1504
1622
  {
1505
1623
  value: value?.content,
1506
- onChange: (_v) => onChange({ type: "constant", content: _v }),
1507
- schema: schema || { type: "string" },
1624
+ onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema }),
1625
+ schema: constantSchema || { type: "string" },
1508
1626
  readonly,
1627
+ strategies: [...constantProps?.strategies || []],
1628
+ fallbackRenderer: () => /* @__PURE__ */ React19.createElement(
1629
+ VariableSelector,
1630
+ {
1631
+ style: { width: "100%" },
1632
+ onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
1633
+ includeSchema,
1634
+ readonly
1635
+ }
1636
+ ),
1509
1637
  ...constantProps
1510
1638
  }
1511
1639
  );
1512
1640
  };
1513
- const renderTrigger = () => /* @__PURE__ */ React11.createElement(
1641
+ const renderTrigger = () => /* @__PURE__ */ React19.createElement(
1514
1642
  VariableSelector,
1515
1643
  {
1516
1644
  style: { width: "100%" },
@@ -1518,31 +1646,31 @@ function DynamicValueInput({
1518
1646
  onChange: (_v) => onChange({ type: "ref", content: _v }),
1519
1647
  includeSchema,
1520
1648
  readonly,
1521
- triggerRender: () => /* @__PURE__ */ React11.createElement(IconButton3, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React11.createElement(IconSetting, { size: "small" }) })
1649
+ triggerRender: () => /* @__PURE__ */ React19.createElement(IconButton4, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React19.createElement(IconSetting, { size: "small" }) })
1522
1650
  }
1523
1651
  );
1524
- return /* @__PURE__ */ React11.createElement(UIContainer2, { style }, /* @__PURE__ */ React11.createElement(UIMain, null, renderMain()), /* @__PURE__ */ React11.createElement(UITrigger, null, renderTrigger()));
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()));
1525
1653
  }
1526
1654
 
1527
1655
  // src/components/condition-row/index.tsx
1528
- import React13, { useMemo as useMemo9 } from "react";
1529
- import { Input as Input3 } from "@douyinfe/semi-ui";
1656
+ import React21, { useMemo as useMemo9 } from "react";
1657
+ import { Input as Input4 } from "@douyinfe/semi-ui";
1530
1658
 
1531
1659
  // src/components/condition-row/styles.tsx
1532
- import styled4 from "styled-components";
1533
- var UIContainer3 = styled4.div`
1660
+ import styled5 from "styled-components";
1661
+ var UIContainer3 = styled5.div`
1534
1662
  display: flex;
1535
1663
  align-items: center;
1536
1664
  gap: 4px;
1537
1665
  `;
1538
- var UIOperator = styled4.div``;
1539
- var UILeft = styled4.div`
1666
+ var UIOperator = styled5.div``;
1667
+ var UILeft = styled5.div`
1540
1668
  width: 100%;
1541
1669
  `;
1542
- var UIRight = styled4.div`
1670
+ var UIRight = styled5.div`
1543
1671
  width: 100%;
1544
1672
  `;
1545
- var UIValues = styled4.div`
1673
+ var UIValues = styled5.div`
1546
1674
  flex-grow: 1;
1547
1675
  display: flex;
1548
1676
  flex-direction: column;
@@ -1552,7 +1680,8 @@ var UIValues = styled4.div`
1552
1680
 
1553
1681
  // src/components/condition-row/hooks/useRule.ts
1554
1682
  import { useMemo as useMemo7 } from "react";
1555
- import { useScopeAvailable } from "@flowgram.ai/editor";
1683
+ import { JsonSchemaUtils as JsonSchemaUtils4 } from "@flowgram.ai/json-schema";
1684
+ import { useScopeAvailable as useScopeAvailable2 } from "@flowgram.ai/editor";
1556
1685
 
1557
1686
  // src/components/condition-row/constants.ts
1558
1687
  var rules = {
@@ -1563,8 +1692,8 @@ var rules = {
1563
1692
  ["not_contains" /* NOT_CONTAINS */]: "string",
1564
1693
  ["in" /* IN */]: "array",
1565
1694
  ["nin" /* NIN */]: "array",
1566
- ["is_empty" /* IS_EMPTY */]: "string",
1567
- ["is_not_empty" /* IS_NOT_EMPTY */]: "string"
1695
+ ["is_empty" /* IS_EMPTY */]: null,
1696
+ ["is_not_empty" /* IS_NOT_EMPTY */]: null
1568
1697
  },
1569
1698
  number: {
1570
1699
  ["eq" /* EQ */]: "number",
@@ -1574,9 +1703,7 @@ var rules = {
1574
1703
  ["lt" /* LT */]: "number",
1575
1704
  ["lte" /* LTE */]: "number",
1576
1705
  ["in" /* IN */]: "array",
1577
- ["nin" /* NIN */]: "array",
1578
- ["is_empty" /* IS_EMPTY */]: null,
1579
- ["is_not_empty" /* IS_NOT_EMPTY */]: null
1706
+ ["nin" /* NIN */]: "array"
1580
1707
  },
1581
1708
  integer: {
1582
1709
  ["eq" /* EQ */]: "number",
@@ -1586,9 +1713,7 @@ var rules = {
1586
1713
  ["lt" /* LT */]: "number",
1587
1714
  ["lte" /* LTE */]: "number",
1588
1715
  ["in" /* IN */]: "array",
1589
- ["nin" /* NIN */]: "array",
1590
- ["is_empty" /* IS_EMPTY */]: null,
1591
- ["is_not_empty" /* IS_NOT_EMPTY */]: null
1716
+ ["nin" /* NIN */]: "array"
1592
1717
  },
1593
1718
  boolean: {
1594
1719
  ["eq" /* EQ */]: "boolean",
@@ -1596,9 +1721,7 @@ var rules = {
1596
1721
  ["is_true" /* IS_TRUE */]: null,
1597
1722
  ["is_false" /* IS_FALSE */]: null,
1598
1723
  ["in" /* IN */]: "array",
1599
- ["nin" /* NIN */]: "array",
1600
- ["is_empty" /* IS_EMPTY */]: null,
1601
- ["is_not_empty" /* IS_NOT_EMPTY */]: null
1724
+ ["nin" /* NIN */]: "array"
1602
1725
  },
1603
1726
  object: {
1604
1727
  ["is_empty" /* IS_EMPTY */]: null,
@@ -1606,7 +1729,11 @@ var rules = {
1606
1729
  },
1607
1730
  array: {
1608
1731
  ["is_empty" /* IS_EMPTY */]: null,
1609
- ["is_not_empty" /* IS_NOT_EMPTY */]: null
1732
+ ["is_not_empty" /* IS_NOT_EMPTY */]: null,
1733
+ ["contains" /* CONTAINS */]: "array",
1734
+ ["not_contains" /* NOT_CONTAINS */]: "array",
1735
+ ["eq" /* EQ */]: "array",
1736
+ ["neq" /* NEQ */]: "array"
1610
1737
  },
1611
1738
  map: {
1612
1739
  ["is_empty" /* IS_EMPTY */]: null,
@@ -1676,89 +1803,27 @@ var opConfigs = {
1676
1803
  }
1677
1804
  };
1678
1805
 
1679
- // src/utils/format-legacy-refs/index.ts
1680
- import { isObject } from "lodash";
1681
- function formatLegacyRefOnSubmit(value) {
1682
- if (isObject(value)) {
1683
- if (isLegacyFlowRefValueSchema(value)) {
1684
- return formatLegacyRefToNewRef(value);
1685
- }
1686
- return Object.fromEntries(
1687
- Object.entries(value).map(([key, value2]) => [
1688
- key,
1689
- formatLegacyRefOnSubmit(value2)
1690
- ])
1691
- );
1692
- }
1693
- if (Array.isArray(value)) {
1694
- return value.map(formatLegacyRefOnSubmit);
1695
- }
1696
- return value;
1697
- }
1698
- function formatLegacyRefOnInit(value) {
1699
- if (isObject(value)) {
1700
- if (isNewFlowRefValueSchema(value)) {
1701
- return formatNewRefToLegacyRef(value);
1702
- }
1703
- return Object.fromEntries(
1704
- Object.entries(value).map(([key, value2]) => [
1705
- key,
1706
- formatLegacyRefOnInit(value2)
1707
- ])
1708
- );
1709
- }
1710
- if (Array.isArray(value)) {
1711
- return value.map(formatLegacyRefOnInit);
1712
- }
1713
- return value;
1714
- }
1715
- function isLegacyFlowRefValueSchema(value) {
1716
- return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
1717
- }
1718
- function isNewFlowRefValueSchema(value) {
1719
- return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
1720
- }
1721
- function formatLegacyRefToNewRef(value) {
1722
- const keyPath = value.content.split(".");
1723
- if (keyPath[1] === "outputs") {
1724
- return {
1725
- type: "ref",
1726
- content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
1727
- };
1728
- }
1729
- return {
1730
- type: "ref",
1731
- content: keyPath
1732
- };
1733
- }
1734
- function formatNewRefToLegacyRef(value) {
1735
- return {
1736
- type: "ref",
1737
- content: value.content.join(".")
1738
- };
1739
- }
1740
-
1741
1806
  // src/components/condition-row/hooks/useRule.ts
1742
1807
  function useRule(left) {
1743
- const available = useScopeAvailable();
1808
+ const available = useScopeAvailable2();
1744
1809
  const variable = useMemo7(() => {
1745
1810
  if (!left) return void 0;
1746
1811
  return available.getByKeyPath(left.content);
1747
1812
  }, [available, left]);
1748
1813
  const rule = useMemo7(() => {
1749
1814
  if (!variable) return void 0;
1750
- const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
1815
+ const schema = JsonSchemaUtils4.astToSchema(variable.type, { drilldown: false });
1751
1816
  return rules[schema?.type];
1752
1817
  }, [variable?.type]);
1753
1818
  return { rule };
1754
1819
  }
1755
1820
 
1756
1821
  // src/components/condition-row/hooks/useOp.tsx
1757
- import React12, { useMemo as useMemo8 } from "react";
1758
- import { Button as Button3, Select as Select2 } from "@douyinfe/semi-ui";
1822
+ import React20, { useMemo as useMemo8 } from "react";
1823
+ import { Button as Button2, Select as Select2 } from "@douyinfe/semi-ui";
1759
1824
  import { IconChevronDownStroked as IconChevronDownStroked2 } from "@douyinfe/semi-icons";
1760
- function useOp({ rule, op, onChange }) {
1761
- const options2 = useMemo8(
1825
+ function useOp({ rule, op, onChange, readonly }) {
1826
+ const options = useMemo8(
1762
1827
  () => Object.keys(rule || {}).map((_op) => ({
1763
1828
  ...opConfigs[_op] || {},
1764
1829
  value: _op
@@ -1766,17 +1831,18 @@ function useOp({ rule, op, onChange }) {
1766
1831
  [rule]
1767
1832
  );
1768
1833
  const opConfig = useMemo8(() => opConfigs[op], [op]);
1769
- const renderOpSelect = () => /* @__PURE__ */ React12.createElement(
1834
+ const renderOpSelect = () => /* @__PURE__ */ React20.createElement(
1770
1835
  Select2,
1771
1836
  {
1772
1837
  style: { height: 22 },
1838
+ disabled: readonly,
1773
1839
  size: "small",
1774
1840
  value: op,
1775
- optionList: options2,
1841
+ optionList: options,
1776
1842
  onChange: (v) => {
1777
1843
  onChange(v);
1778
1844
  },
1779
- triggerRender: ({ value }) => /* @__PURE__ */ React12.createElement(Button3, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React12.createElement(IconChevronDownStroked2, { size: "small" }))
1845
+ triggerRender: ({ value }) => /* @__PURE__ */ React20.createElement(Button2, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React20.createElement(IconChevronDownStroked2, { size: "small" }))
1780
1846
  }
1781
1847
  );
1782
1848
  return { renderOpSelect, opConfig };
@@ -1789,13 +1855,14 @@ function ConditionRow({ style, value, onChange, readonly }) {
1789
1855
  const { renderOpSelect, opConfig } = useOp({
1790
1856
  rule,
1791
1857
  op: operator,
1792
- onChange: (v) => onChange({ ...value, operator: v })
1858
+ onChange: (v) => onChange({ ...value, operator: v }),
1859
+ readonly
1793
1860
  });
1794
1861
  const targetSchema = useMemo9(() => {
1795
1862
  const targetType = rule?.[operator] || null;
1796
1863
  return targetType ? { type: targetType, extra: { weak: true } } : null;
1797
1864
  }, [rule, opConfig]);
1798
- return /* @__PURE__ */ React13.createElement(UIContainer3, { style }, /* @__PURE__ */ React13.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ React13.createElement(UIValues, null, /* @__PURE__ */ React13.createElement(UILeft, null, /* @__PURE__ */ React13.createElement(
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(
1799
1866
  VariableSelector,
1800
1867
  {
1801
1868
  readonly,
@@ -1809,7 +1876,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
1809
1876
  }
1810
1877
  })
1811
1878
  }
1812
- )), /* @__PURE__ */ React13.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ React13.createElement(
1879
+ )), /* @__PURE__ */ React21.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ React21.createElement(
1813
1880
  DynamicValueInput,
1814
1881
  {
1815
1882
  readonly: readonly || !rule,
@@ -1817,8 +1884,8 @@ function ConditionRow({ style, value, onChange, readonly }) {
1817
1884
  schema: targetSchema,
1818
1885
  onChange: (v) => onChange({ ...value, right: v })
1819
1886
  }
1820
- ) : /* @__PURE__ */ React13.createElement(
1821
- Input3,
1887
+ ) : /* @__PURE__ */ React21.createElement(
1888
+ Input4,
1822
1889
  {
1823
1890
  size: "small",
1824
1891
  disabled: true,
@@ -1829,28 +1896,32 @@ function ConditionRow({ style, value, onChange, readonly }) {
1829
1896
  }
1830
1897
 
1831
1898
  // src/components/batch-outputs/index.tsx
1832
- import React14 from "react";
1833
- import { Button as Button4, Input as Input4 } from "@douyinfe/semi-ui";
1899
+ import React22 from "react";
1900
+ import { Button as Button3, Input as Input5 } from "@douyinfe/semi-ui";
1834
1901
  import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
1835
1902
 
1836
- // src/components/batch-outputs/use-list.ts
1837
- import { useEffect as useEffect3, useState as useState5 } from "react";
1838
- import { difference } from "lodash";
1839
- var _id2 = 0;
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";
1840
1907
  function genId2() {
1841
- return _id2++;
1908
+ return nanoid();
1842
1909
  }
1843
- function useList({ value, onChange }) {
1844
- const [list, setList] = useState5([]);
1845
- useEffect3(() => {
1910
+ function useObjectList({
1911
+ value,
1912
+ onChange,
1913
+ sortIndexKey
1914
+ }) {
1915
+ const [list, setList] = useState6([]);
1916
+ useEffect4(() => {
1846
1917
  setList((_prevList) => {
1847
- const newKeys = Object.keys(value || {});
1918
+ const newKeys = Object.entries(value || {}).sort((a, b) => get(a[1], sortIndexKey || 0) - get(b[1], sortIndexKey || 0)).map(([key]) => key);
1848
1919
  const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
1849
1920
  const addKeys = difference(newKeys, oldKeys);
1850
1921
  return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
1851
1922
  id: item.id,
1852
1923
  key: item.key,
1853
- value: item.key ? value?.[item.key] : void 0
1924
+ value: item.key ? value?.[item.key] : item.value
1854
1925
  })).concat(
1855
1926
  addKeys.map((_key) => ({
1856
1927
  id: genId2(),
@@ -1868,17 +1939,44 @@ function useList({ value, onChange }) {
1868
1939
  }
1869
1940
  ]);
1870
1941
  };
1871
- const update = (item) => {
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) => {
1872
1967
  setList((prevList) => {
1873
1968
  const nextList = prevList.map((_item) => {
1874
- if (_item.id === item.id) {
1875
- return item;
1969
+ if (_item.id === itemId) {
1970
+ return {
1971
+ ..._item,
1972
+ key
1973
+ };
1876
1974
  }
1877
1975
  return _item;
1878
1976
  });
1879
1977
  onChange(
1880
1978
  Object.fromEntries(
1881
- nextList.filter((item2) => item2.key).map((item2) => [item2.key, item2.value])
1979
+ nextList.filter((item) => item.key).map((item) => [item.key, item.value])
1882
1980
  )
1883
1981
  );
1884
1982
  return nextList;
@@ -1895,18 +1993,18 @@ function useList({ value, onChange }) {
1895
1993
  return nextList;
1896
1994
  });
1897
1995
  };
1898
- return { list, add, update, remove };
1996
+ return { list, add, updateKey, updateValue, remove };
1899
1997
  }
1900
1998
 
1901
1999
  // src/components/batch-outputs/styles.tsx
1902
- import styled5 from "styled-components";
1903
- var UIRows = styled5.div`
2000
+ import styled6 from "styled-components";
2001
+ var UIRows = styled6.div`
1904
2002
  display: flex;
1905
2003
  flex-direction: column;
1906
2004
  gap: 10px;
1907
2005
  margin-bottom: 10px;
1908
2006
  `;
1909
- var UIRow2 = styled5.div`
2007
+ var UIRow2 = styled6.div`
1910
2008
  display: flex;
1911
2009
  align-items: center;
1912
2010
  gap: 5px;
@@ -1915,54 +2013,48 @@ var UIRow2 = styled5.div`
1915
2013
  // src/components/batch-outputs/index.tsx
1916
2014
  function BatchOutputs(props) {
1917
2015
  const { readonly, style } = props;
1918
- const { list, add, update, remove } = useList(props);
1919
- return /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ React14.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ React14.createElement(
1920
- Input4,
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,
1921
2019
  {
1922
2020
  style: { width: 100 },
1923
2021
  disabled: readonly,
1924
2022
  size: "small",
1925
2023
  value: item.key,
1926
- onChange: (v) => update({ ...item, key: v })
2024
+ onChange: (v) => updateKey(item.id, v)
1927
2025
  }
1928
- ), /* @__PURE__ */ React14.createElement(
2026
+ ), /* @__PURE__ */ React22.createElement(
1929
2027
  VariableSelector,
1930
2028
  {
1931
2029
  style: { flexGrow: 1 },
1932
2030
  readonly,
1933
2031
  value: item.value?.content,
1934
- onChange: (v) => update({
1935
- ...item,
1936
- value: {
1937
- type: "ref",
1938
- content: v
1939
- }
1940
- })
2032
+ onChange: (v) => updateValue(item.id, { type: "ref", content: v })
1941
2033
  }
1942
- ), /* @__PURE__ */ React14.createElement(
1943
- Button4,
2034
+ ), /* @__PURE__ */ React22.createElement(
2035
+ Button3,
1944
2036
  {
1945
2037
  disabled: readonly,
1946
- icon: /* @__PURE__ */ React14.createElement(IconDelete, null),
2038
+ icon: /* @__PURE__ */ React22.createElement(IconDelete, null),
1947
2039
  size: "small",
1948
2040
  onClick: () => remove(item.id)
1949
2041
  }
1950
- )))), /* @__PURE__ */ React14.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React14.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
2042
+ )))), /* @__PURE__ */ React22.createElement(Button3, { disabled: readonly, icon: /* @__PURE__ */ React22.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
1951
2043
  }
1952
2044
 
1953
2045
  // src/components/prompt-editor/index.tsx
1954
- import React15, { useEffect as useEffect4, useRef as useRef3 } from "react";
1955
- import { Renderer, EditorProvider, ActiveLinePlaceholder } from "@coze-editor/editor/react";
1956
- import preset from "@coze-editor/editor/preset-prompt";
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";
1957
2049
 
1958
2050
  // src/components/prompt-editor/styles.tsx
1959
- import styled6, { css as css2 } from "styled-components";
1960
- var UIContainer4 = styled6.div`
2051
+ import styled7, { css as css3 } from "styled-components";
2052
+ var UIContainer4 = styled7.div`
1961
2053
  background-color: var(--semi-color-fill-0);
1962
2054
  padding-left: 10px;
1963
2055
  padding-right: 6px;
1964
2056
 
1965
- ${({ $hasError }) => $hasError && css2`
2057
+ ${({ $hasError }) => $hasError && css3`
1966
2058
  border: 1px solid var(--semi-color-danger-6);
1967
2059
  `}
1968
2060
  `;
@@ -1971,7 +2063,7 @@ var UIContainer4 = styled6.div`
1971
2063
  import { useLayoutEffect } from "react";
1972
2064
  import { useInjector } from "@coze-editor/editor/react";
1973
2065
  import { astDecorator } from "@coze-editor/editor";
1974
- import { EditorView } from "@codemirror/view";
2066
+ import { EditorView as EditorView2 } from "@codemirror/view";
1975
2067
  function MarkdownHighlight() {
1976
2068
  const injector = useInjector();
1977
2069
  useLayoutEffect(
@@ -2002,7 +2094,7 @@ function MarkdownHighlight() {
2002
2094
  };
2003
2095
  }
2004
2096
  }),
2005
- EditorView.theme({
2097
+ EditorView2.theme({
2006
2098
  ".heading": {
2007
2099
  color: "#00818C",
2008
2100
  fontWeight: "bold"
@@ -2039,7 +2131,7 @@ var language_support_default = LanguageSupport;
2039
2131
  import { useLayoutEffect as useLayoutEffect3 } from "react";
2040
2132
  import { useInjector as useInjector3 } from "@coze-editor/editor/react";
2041
2133
  import { astDecorator as astDecorator2 } from "@coze-editor/editor";
2042
- import { EditorView as EditorView2 } from "@codemirror/view";
2134
+ import { EditorView as EditorView3 } from "@codemirror/view";
2043
2135
  function JinjaHighlight() {
2044
2136
  const injector = useInjector3();
2045
2137
  useLayoutEffect3(
@@ -2064,7 +2156,7 @@ function JinjaHighlight() {
2064
2156
  };
2065
2157
  }
2066
2158
  }),
2067
- EditorView2.theme({
2159
+ EditorView3.theme({
2068
2160
  ".jinja-statement-bracket": {
2069
2161
  color: "#D1009D"
2070
2162
  },
@@ -2092,21 +2184,22 @@ function PromptEditor(props) {
2092
2184
  activeLinePlaceholder,
2093
2185
  style,
2094
2186
  hasError,
2095
- children
2187
+ children,
2188
+ disableMarkdownHighlight
2096
2189
  } = props || {};
2097
- const editorRef = useRef3(null);
2098
- useEffect4(() => {
2190
+ const editorRef = useRef4(null);
2191
+ useEffect5(() => {
2099
2192
  if (editorRef.current?.getValue() !== value?.content) {
2100
2193
  editorRef.current?.setValue(String(value?.content || ""));
2101
2194
  }
2102
2195
  }, [value]);
2103
- return /* @__PURE__ */ React15.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ React15.createElement(EditorProvider, null, /* @__PURE__ */ React15.createElement(
2196
+ return /* @__PURE__ */ React23.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ React23.createElement(EditorProvider2, null, /* @__PURE__ */ React23.createElement(
2104
2197
  Renderer,
2105
2198
  {
2106
2199
  didMount: (editor) => {
2107
2200
  editorRef.current = editor;
2108
2201
  },
2109
- plugins: preset,
2202
+ plugins: preset2,
2110
2203
  defaultValue: String(value?.content),
2111
2204
  options: {
2112
2205
  readOnly: readonly,
@@ -2117,15 +2210,15 @@ function PromptEditor(props) {
2117
2210
  onChange({ type: "template", content: e.value });
2118
2211
  }
2119
2212
  }
2120
- ), activeLinePlaceholder && /* @__PURE__ */ React15.createElement(ActiveLinePlaceholder, null, activeLinePlaceholder), /* @__PURE__ */ React15.createElement(markdown_default, null), /* @__PURE__ */ React15.createElement(language_support_default, null), /* @__PURE__ */ React15.createElement(jinja_default, null), children));
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));
2121
2214
  }
2122
2215
 
2123
2216
  // src/components/prompt-editor-with-variables/index.tsx
2124
- import React18 from "react";
2217
+ import React26 from "react";
2125
2218
 
2126
2219
  // src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
2127
- import React16, { useEffect as useEffect5, useState as useState6 } from "react";
2128
- import { Popover, Tree } from "@douyinfe/semi-ui";
2220
+ import React24, { useEffect as useEffect6, useState as useState7 } from "react";
2221
+ import { Popover as Popover2, Tree } from "@douyinfe/semi-ui";
2129
2222
  import {
2130
2223
  Mention,
2131
2224
  getCurrentMentionReplaceRange,
@@ -2133,9 +2226,9 @@ import {
2133
2226
  PositionMirror
2134
2227
  } from "@coze-editor/editor/react";
2135
2228
  function VariableTree() {
2136
- const [posKey, setPosKey] = useState6("");
2137
- const [visible, setVisible] = useState6(false);
2138
- const [position, setPosition] = useState6(-1);
2229
+ const [posKey, setPosKey] = useState7("");
2230
+ const [visible, setVisible] = useState7(false);
2231
+ const [position, setPosition] = useState7(-1);
2139
2232
  const editor = useEditor();
2140
2233
  function insert(variablePath) {
2141
2234
  const range = getCurrentMentionReplaceRange(editor.$view.state);
@@ -2152,20 +2245,20 @@ function VariableTree() {
2152
2245
  setPosition(e.state.selection.main.head);
2153
2246
  setVisible(e.value);
2154
2247
  }
2155
- useEffect5(() => {
2248
+ useEffect6(() => {
2156
2249
  if (!editor) {
2157
2250
  return;
2158
2251
  }
2159
2252
  }, [editor, visible]);
2160
2253
  const treeData = useVariableTree({});
2161
- return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React16.createElement(
2162
- Popover,
2254
+ return /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React24.createElement(
2255
+ Popover2,
2163
2256
  {
2164
2257
  visible,
2165
2258
  trigger: "custom",
2166
2259
  position: "topLeft",
2167
2260
  rePosKey: posKey,
2168
- content: /* @__PURE__ */ React16.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React16.createElement(
2261
+ content: /* @__PURE__ */ React24.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React24.createElement(
2169
2262
  Tree,
2170
2263
  {
2171
2264
  treeData,
@@ -2175,7 +2268,7 @@ function VariableTree() {
2175
2268
  }
2176
2269
  ))
2177
2270
  },
2178
- /* @__PURE__ */ React16.createElement(
2271
+ /* @__PURE__ */ React24.createElement(
2179
2272
  PositionMirror,
2180
2273
  {
2181
2274
  position,
@@ -2187,28 +2280,28 @@ function VariableTree() {
2187
2280
 
2188
2281
  // src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
2189
2282
  import ReactDOM from "react-dom";
2190
- import React17, { useLayoutEffect as useLayoutEffect4 } from "react";
2283
+ import React25, { useLayoutEffect as useLayoutEffect4 } from "react";
2191
2284
  import { isEqual, last } from "lodash";
2192
2285
  import {
2193
2286
  Disposable,
2194
2287
  DisposableCollection,
2195
2288
  useCurrentScope
2196
2289
  } from "@flowgram.ai/editor";
2197
- import { Popover as Popover2 } from "@douyinfe/semi-ui";
2290
+ import { Popover as Popover3 } from "@douyinfe/semi-ui";
2198
2291
  import { IconIssueStroked as IconIssueStroked2 } from "@douyinfe/semi-icons";
2199
2292
  import { useInjector as useInjector4 } from "@coze-editor/editor/react";
2200
2293
  import {
2201
2294
  Decoration,
2202
- EditorView as EditorView3,
2295
+ EditorView as EditorView4,
2203
2296
  MatchDecorator,
2204
2297
  ViewPlugin,
2205
2298
  WidgetType
2206
2299
  } from "@codemirror/view";
2207
2300
 
2208
2301
  // src/components/prompt-editor-with-variables/styles.tsx
2209
- import styled7 from "styled-components";
2302
+ import styled8 from "styled-components";
2210
2303
  import { Tag as Tag2 } from "@douyinfe/semi-ui";
2211
- var UIRootTitle2 = styled7.div`
2304
+ var UIRootTitle2 = styled8.div`
2212
2305
  margin-right: 4px;
2213
2306
  min-width: 20px;
2214
2307
  overflow: hidden;
@@ -2216,12 +2309,12 @@ var UIRootTitle2 = styled7.div`
2216
2309
  white-space: nowrap;
2217
2310
  color: var(--semi-color-text-2);
2218
2311
  `;
2219
- var UIVarName2 = styled7.div`
2312
+ var UIVarName2 = styled8.div`
2220
2313
  overflow: hidden;
2221
2314
  text-overflow: ellipsis;
2222
2315
  white-space: nowrap;
2223
2316
  `;
2224
- var UITag2 = styled7(Tag2)`
2317
+ var UITag2 = styled8(Tag2)`
2225
2318
  display: inline-flex;
2226
2319
  align-items: center;
2227
2320
  justify-content: flex-start;
@@ -2235,7 +2328,7 @@ var UITag2 = styled7(Tag2)`
2235
2328
  margin: 0 5px;
2236
2329
  }
2237
2330
  `;
2238
- var UIPopoverContent = styled7.div`
2331
+ var UIPopoverContent2 = styled8.div`
2239
2332
  padding: 10px;
2240
2333
  display: inline-flex;
2241
2334
  align-items: center;
@@ -2249,7 +2342,7 @@ var VariableTagWidget = class extends WidgetType {
2249
2342
  this.toDispose = new DisposableCollection();
2250
2343
  this.renderIcon = (icon) => {
2251
2344
  if (typeof icon === "string") {
2252
- return /* @__PURE__ */ React17.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2345
+ return /* @__PURE__ */ React25.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2253
2346
  }
2254
2347
  return icon;
2255
2348
  };
@@ -2262,20 +2355,21 @@ var VariableTagWidget = class extends WidgetType {
2262
2355
  renderVariable(v) {
2263
2356
  if (!v) {
2264
2357
  this.renderReact(
2265
- /* @__PURE__ */ React17.createElement(UITag2, { prefixIcon: /* @__PURE__ */ React17.createElement(IconIssueStroked2, null), color: "amber" }, "Unknown")
2358
+ /* @__PURE__ */ React25.createElement(UITag2, { prefixIcon: /* @__PURE__ */ React25.createElement(IconIssueStroked2, null), color: "amber" }, "Unknown")
2266
2359
  );
2267
2360
  return;
2268
2361
  }
2269
- const rootField = last(v.parentFields);
2270
- const rootTitle = /* @__PURE__ */ React17.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
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 ? "" : "-"} ` : "");
2271
2365
  const rootIcon = this.renderIcon(rootField?.meta.icon);
2272
2366
  this.renderReact(
2273
- /* @__PURE__ */ React17.createElement(
2274
- Popover2,
2367
+ /* @__PURE__ */ React25.createElement(
2368
+ Popover3,
2275
2369
  {
2276
- content: /* @__PURE__ */ React17.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React17.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
2370
+ content: /* @__PURE__ */ React25.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React25.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
2277
2371
  },
2278
- /* @__PURE__ */ React17.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React17.createElement(UIVarName2, null, v?.key))
2372
+ /* @__PURE__ */ React25.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ React25.createElement(UIVarName2, null, v?.key))
2279
2373
  )
2280
2374
  );
2281
2375
  }
@@ -2336,7 +2430,7 @@ function VariableTagInject() {
2336
2430
  {
2337
2431
  decorations: (p) => p.decorations,
2338
2432
  provide(p) {
2339
- return EditorView3.atomicRanges.of(
2433
+ return EditorView4.atomicRanges.of(
2340
2434
  (view) => view.plugin(p)?.decorations ?? Decoration.none
2341
2435
  );
2342
2436
  }
@@ -2349,15 +2443,15 @@ function VariableTagInject() {
2349
2443
 
2350
2444
  // src/components/prompt-editor-with-variables/index.tsx
2351
2445
  function PromptEditorWithVariables(props) {
2352
- return /* @__PURE__ */ React18.createElement(PromptEditor, { ...props }, /* @__PURE__ */ React18.createElement(VariableTree, null), /* @__PURE__ */ React18.createElement(VariableTagInject, null));
2446
+ return /* @__PURE__ */ React26.createElement(PromptEditor, { ...props }, /* @__PURE__ */ React26.createElement(VariableTree, null), /* @__PURE__ */ React26.createElement(VariableTagInject, null));
2353
2447
  }
2354
2448
 
2355
2449
  // src/components/prompt-editor-with-inputs/index.tsx
2356
- import React21 from "react";
2450
+ import React29 from "react";
2357
2451
 
2358
2452
  // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2359
- import React20, { useEffect as useEffect6, useState as useState7 } from "react";
2360
- import { Popover as Popover3 } from "@douyinfe/semi-ui";
2453
+ import React28, { useEffect as useEffect7, useState as useState8 } from "react";
2454
+ import { Popover as Popover4 } from "@douyinfe/semi-ui";
2361
2455
  import {
2362
2456
  Mention as Mention2,
2363
2457
  getCurrentMentionReplaceRange as getCurrentMentionReplaceRange2,
@@ -2366,18 +2460,18 @@ import {
2366
2460
  } from "@coze-editor/editor/react";
2367
2461
 
2368
2462
  // src/components/prompt-editor-with-inputs/inputs-picker.tsx
2369
- import React19, { useMemo as useMemo10 } from "react";
2463
+ import React27, { useMemo as useMemo10 } from "react";
2370
2464
  import { last as last2 } from "lodash";
2371
2465
  import {
2372
2466
  ASTMatch as ASTMatch3,
2373
- useScopeAvailable as useScopeAvailable2
2467
+ useScopeAvailable as useScopeAvailable3
2374
2468
  } from "@flowgram.ai/editor";
2375
2469
  import { Tree as Tree2 } from "@douyinfe/semi-ui";
2376
2470
  function InputsPicker({
2377
2471
  inputsValues,
2378
2472
  onSelect
2379
2473
  }) {
2380
- const available = useScopeAvailable2();
2474
+ const available = useScopeAvailable3();
2381
2475
  const getArrayDrilldown = (type, depth = 1) => {
2382
2476
  if (ASTMatch3.isArray(type.items)) {
2383
2477
  return getArrayDrilldown(type.items, depth + 1);
@@ -2412,7 +2506,7 @@ function InputsPicker({
2412
2506
  };
2413
2507
  const treeData = useMemo10(
2414
2508
  () => Object.entries(inputsValues).map(([key, value]) => {
2415
- if (value.type === "ref") {
2509
+ if (value?.type === "ref") {
2416
2510
  const variable = available.getByKeyPath(value.content || []);
2417
2511
  if (variable) {
2418
2512
  return renderVariable(variable, [key]);
@@ -2420,390 +2514,80 @@ function InputsPicker({
2420
2514
  }
2421
2515
  return {
2422
2516
  key,
2423
- value: key,
2424
- label: key
2425
- };
2426
- }),
2427
- []
2428
- );
2429
- return /* @__PURE__ */ React19.createElement(Tree2, { treeData, onSelect: (v) => onSelect(v) });
2430
- }
2431
-
2432
- // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2433
- function InputsTree({ inputsValues }) {
2434
- const [posKey, setPosKey] = useState7("");
2435
- const [visible, setVisible] = useState7(false);
2436
- const [position, setPosition] = useState7(-1);
2437
- const editor = useEditor2();
2438
- function insert(variablePath) {
2439
- const range = getCurrentMentionReplaceRange2(editor.$view.state);
2440
- if (!range) {
2441
- return;
2442
- }
2443
- editor.replaceText({
2444
- ...range,
2445
- text: "{{" + variablePath + "}}"
2446
- });
2447
- setVisible(false);
2448
- }
2449
- function handleOpenChange(e) {
2450
- setPosition(e.state.selection.main.head);
2451
- setVisible(e.value);
2452
- }
2453
- useEffect6(() => {
2454
- if (!editor) {
2455
- return;
2456
- }
2457
- }, [editor, visible]);
2458
- return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Mention2, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React20.createElement(
2459
- Popover3,
2460
- {
2461
- visible,
2462
- trigger: "custom",
2463
- position: "topLeft",
2464
- rePosKey: posKey,
2465
- content: /* @__PURE__ */ React20.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React20.createElement(
2466
- InputsPicker,
2467
- {
2468
- inputsValues,
2469
- onSelect: (v) => {
2470
- insert(v);
2471
- }
2472
- }
2473
- ))
2474
- },
2475
- /* @__PURE__ */ React20.createElement(
2476
- PositionMirror2,
2477
- {
2478
- position,
2479
- onChange: () => setPosKey(String(Math.random()))
2480
- }
2481
- )
2482
- ));
2483
- }
2484
-
2485
- // src/components/prompt-editor-with-inputs/index.tsx
2486
- function PromptEditorWithInputs({ inputsValues, ...restProps }) {
2487
- return /* @__PURE__ */ React21.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ React21.createElement(InputsTree, { inputsValues }));
2488
- }
2489
-
2490
- // src/components/code-editor/index.tsx
2491
- import React22, { useEffect as useEffect7, useRef as useRef4 } from "react";
2492
- import { ActiveLinePlaceholder as ActiveLinePlaceholder2, createRenderer, EditorProvider as EditorProvider2 } from "@coze-editor/editor/react";
2493
- import preset2 from "@coze-editor/editor/preset-code";
2494
- import { EditorView as EditorView4 } from "@codemirror/view";
2495
-
2496
- // src/components/code-editor/utils.ts
2497
- function getSuffixByLanguageId(languageId) {
2498
- if (languageId === "python") {
2499
- return ".py";
2500
- }
2501
- if (languageId === "typescript") {
2502
- return ".ts";
2503
- }
2504
- if (languageId === "shell") {
2505
- return ".sh";
2506
- }
2507
- if (languageId === "json") {
2508
- return ".json";
2509
- }
2510
- return "";
2511
- }
2512
-
2513
- // src/components/code-editor/theme/index.ts
2514
- import { themes } from "@coze-editor/editor/preset-code";
2515
-
2516
- // src/components/code-editor/theme/light.ts
2517
- import { createTheme, tags as t } from "@coze-editor/editor/preset-code";
2518
- var colors = {
2519
- background: "#F7F7FC",
2520
- // syntax
2521
- comment: "#000A298A",
2522
- key: "#00818C",
2523
- string: "#D1009D",
2524
- number: "#C74200",
2525
- boolean: "#2B57D9",
2526
- null: "#2B57D9",
2527
- separator: "#0F1529D1"
2528
- };
2529
- var lightTheme = createTheme({
2530
- variant: "light",
2531
- settings: {
2532
- background: "#fff",
2533
- foreground: "#000",
2534
- caret: "#000",
2535
- selection: "#d9d9d9",
2536
- gutterBackground: "#f0f0f0",
2537
- gutterForeground: "#666",
2538
- gutterBorderColor: "transparent",
2539
- gutterBorderWidth: 0,
2540
- lineHighlight: "#f0f0f0",
2541
- bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
2542
- tooltip: {
2543
- backgroundColor: "#f0f0f0",
2544
- color: "#000",
2545
- border: "1px solid #ccc"
2546
- },
2547
- link: {
2548
- color: "#007bff"
2549
- },
2550
- completionItemHover: {
2551
- backgroundColor: "#f0f0f0"
2552
- },
2553
- completionItemSelected: {
2554
- backgroundColor: "#e0e0e0"
2555
- },
2556
- completionItemIcon: {
2557
- color: "#333"
2558
- },
2559
- completionItemLabel: {
2560
- color: "#333"
2561
- },
2562
- completionItemInfo: {
2563
- color: "#333"
2564
- },
2565
- completionItemDetail: {
2566
- color: "#666"
2567
- }
2568
- },
2569
- styles: [
2570
- // JSON
2571
- {
2572
- tag: t.comment,
2573
- color: colors.comment
2574
- },
2575
- {
2576
- tag: [t.propertyName],
2577
- color: colors.key
2578
- },
2579
- {
2580
- tag: [t.string],
2581
- color: colors.string
2582
- },
2583
- {
2584
- tag: [t.number],
2585
- color: colors.number
2586
- },
2587
- {
2588
- tag: [t.bool],
2589
- color: colors.boolean
2590
- },
2591
- {
2592
- tag: [t.null],
2593
- color: colors.null
2594
- },
2595
- {
2596
- tag: [t.separator],
2597
- color: colors.separator
2598
- },
2599
- // markdown
2600
- {
2601
- tag: [t.heading],
2602
- color: "#3e76ef"
2603
- },
2604
- {
2605
- tag: [t.processingInstruction],
2606
- color: "#3e76ef"
2607
- },
2608
- // shell
2609
- // curl
2610
- {
2611
- tag: [t.standard(t.variableName)],
2612
- color: "#00804A"
2613
- },
2614
- // -X
2615
- {
2616
- tag: [t.attributeName],
2617
- color: "#C74200"
2618
- },
2619
- // url in string (includes quotes), e.g. "https://..."
2620
- {
2621
- tag: [t.special(t.string)],
2622
- color: "#2B57D9"
2623
- }
2624
- ]
2625
- });
2626
-
2627
- // src/components/code-editor/theme/dark.ts
2628
- import { createTheme as createTheme2, tags as t2 } from "@coze-editor/editor/preset-code";
2629
- var colors2 = {
2630
- background: "#151B27",
2631
- // syntax
2632
- comment: "#FFFFFF63",
2633
- key: "#39E5D7",
2634
- string: "#FF94D2",
2635
- number: "#FF9933",
2636
- boolean: "#78B0FF",
2637
- null: "#78B0FF",
2638
- separator: "#FFFFFFC9"
2639
- };
2640
- var darkTheme = createTheme2({
2641
- variant: "dark",
2642
- settings: {
2643
- background: colors2.background,
2644
- foreground: "#fff",
2645
- caret: "#AEAFAD",
2646
- selection: "#d9d9d942",
2647
- gutterBackground: colors2.background,
2648
- gutterForeground: "#FFFFFF63",
2649
- gutterBorderColor: "transparent",
2650
- gutterBorderWidth: 0,
2651
- lineHighlight: "#272e3d36",
2652
- bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
2653
- tooltip: {
2654
- backgroundColor: "#363D4D",
2655
- color: "#fff",
2656
- border: "none"
2657
- },
2658
- link: {
2659
- color: "#4daafc"
2660
- },
2661
- completionItemHover: {
2662
- backgroundColor: "#FFFFFF0F"
2663
- },
2664
- completionItemSelected: {
2665
- backgroundColor: "#FFFFFF17"
2666
- },
2667
- completionItemIcon: {
2668
- color: "#FFFFFFC9"
2669
- },
2670
- completionItemLabel: {
2671
- color: "#FFFFFFC9"
2672
- },
2673
- completionItemInfo: {
2674
- color: "#FFFFFFC9"
2675
- },
2676
- completionItemDetail: {
2677
- color: "#FFFFFF63"
2678
- }
2679
- },
2680
- styles: [
2681
- // json
2682
- {
2683
- tag: t2.comment,
2684
- color: colors2.comment
2685
- },
2686
- {
2687
- tag: [t2.propertyName],
2688
- color: colors2.key
2689
- },
2690
- {
2691
- tag: [t2.string],
2692
- color: colors2.string
2693
- },
2694
- {
2695
- tag: [t2.number],
2696
- color: colors2.number
2697
- },
2698
- {
2699
- tag: [t2.bool],
2700
- color: colors2.boolean
2701
- },
2702
- {
2703
- tag: [t2.null],
2704
- color: colors2.null
2705
- },
2706
- {
2707
- tag: [t2.separator],
2708
- color: colors2.separator
2709
- },
2710
- // markdown
2711
- {
2712
- tag: [t2.heading],
2713
- color: "#6b6bff"
2714
- },
2715
- {
2716
- tag: [t2.processingInstruction],
2717
- color: "#6b6bff"
2718
- },
2719
- // shell
2720
- // curl
2721
- {
2722
- tag: [t2.standard(t2.variableName)],
2723
- color: "#3BEB84"
2724
- },
2725
- // -X
2726
- {
2727
- tag: [t2.attributeName],
2728
- color: "#FF9933"
2729
- },
2730
- // url in string (includes quotes), e.g. "https://..."
2731
- {
2732
- tag: [t2.special(t2.string)],
2733
- color: "#78B0FF"
2734
- }
2735
- ]
2736
- });
2737
-
2738
- // src/components/code-editor/theme/index.ts
2739
- themes.register("dark", darkTheme);
2740
- themes.register("light", lightTheme);
2741
-
2742
- // src/components/code-editor/language-features.ts
2743
- import { languages } from "@coze-editor/editor/preset-code";
2744
- import { shell } from "@coze-editor/editor/language-shell";
2745
- import { python } from "@coze-editor/editor/language-python";
2746
- import { json } from "@coze-editor/editor/language-json";
2747
- import { mixLanguages } from "@coze-editor/editor";
2748
- languages.register("python", python);
2749
- languages.register("json", {
2750
- // mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
2751
- language: mixLanguages({
2752
- outerLanguage: json.language
2753
- }),
2754
- languageService: json.languageService
2755
- });
2756
- languages.register("shell", shell);
2517
+ value: key,
2518
+ label: key
2519
+ };
2520
+ }),
2521
+ []
2522
+ );
2523
+ return /* @__PURE__ */ React27.createElement(Tree2, { treeData, onSelect: (v) => onSelect(v) });
2524
+ }
2757
2525
 
2758
- // src/components/code-editor/index.tsx
2759
- var OriginCodeEditor = createRenderer(preset2, [
2760
- EditorView4.theme({
2761
- "&.cm-focused": {
2762
- outline: "none"
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;
2763
2536
  }
2764
- })
2765
- ]);
2766
- function CodeEditor({
2767
- value,
2768
- onChange,
2769
- languageId = "python",
2770
- theme = "light",
2771
- children,
2772
- placeholder,
2773
- activeLinePlaceholder
2774
- }) {
2775
- const editorRef = useRef4(null);
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
+ }
2776
2547
  useEffect7(() => {
2777
- if (editorRef.current?.getValue() !== value) {
2778
- editorRef.current?.setValue(String(value || ""));
2548
+ if (!editor) {
2549
+ return;
2779
2550
  }
2780
- }, [value]);
2781
- return /* @__PURE__ */ React22.createElement(EditorProvider2, null, /* @__PURE__ */ React22.createElement(
2782
- OriginCodeEditor,
2551
+ }, [editor, visible]);
2552
+ return /* @__PURE__ */ React28.createElement(React28.Fragment, null, /* @__PURE__ */ React28.createElement(Mention2, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React28.createElement(
2553
+ Popover4,
2783
2554
  {
2784
- defaultValue: value,
2785
- options: {
2786
- uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
2787
- languageId,
2788
- theme,
2789
- placeholder
2790
- },
2791
- didMount: (editor) => {
2792
- editorRef.current = editor;
2793
- },
2794
- onChange: (e) => onChange?.(e.value)
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
+ ))
2795
2568
  },
2796
- activeLinePlaceholder && /* @__PURE__ */ React22.createElement(ActiveLinePlaceholder2, null, activeLinePlaceholder),
2797
- children
2569
+ /* @__PURE__ */ React28.createElement(
2570
+ PositionMirror2,
2571
+ {
2572
+ position,
2573
+ onChange: () => setPosKey(String(Math.random()))
2574
+ }
2575
+ )
2798
2576
  ));
2799
2577
  }
2800
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 }));
2582
+ }
2583
+
2801
2584
  // src/components/json-editor-with-variables/index.tsx
2802
- import React25 from "react";
2585
+ import React32 from "react";
2586
+ import { transformerCreator } from "@coze-editor/editor/preset-code";
2803
2587
 
2804
2588
  // src/components/json-editor-with-variables/extensions/variable-tree.tsx
2805
- import React23, { useEffect as useEffect8, useState as useState8 } from "react";
2806
- import { Popover as Popover4, Tree as Tree3 } from "@douyinfe/semi-ui";
2589
+ import React30, { useEffect as useEffect8, useState as useState9 } from "react";
2590
+ import { Popover as Popover5, Tree as Tree3 } from "@douyinfe/semi-ui";
2807
2591
  import {
2808
2592
  Mention as Mention3,
2809
2593
  getCurrentMentionReplaceRange as getCurrentMentionReplaceRange3,
@@ -2811,9 +2595,9 @@ import {
2811
2595
  PositionMirror as PositionMirror3
2812
2596
  } from "@coze-editor/editor/react";
2813
2597
  function VariableTree2() {
2814
- const [posKey, setPosKey] = useState8("");
2815
- const [visible, setVisible] = useState8(false);
2816
- const [position, setPosition] = useState8(-1);
2598
+ const [posKey, setPosKey] = useState9("");
2599
+ const [visible, setVisible] = useState9(false);
2600
+ const [position, setPosition] = useState9(-1);
2817
2601
  const editor = useEditor3();
2818
2602
  function insert(variablePath) {
2819
2603
  const range = getCurrentMentionReplaceRange3(editor.$view.state);
@@ -2836,14 +2620,14 @@ function VariableTree2() {
2836
2620
  }
2837
2621
  }, [editor, visible]);
2838
2622
  const treeData = useVariableTree({});
2839
- return /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(Mention3, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React23.createElement(
2840
- Popover4,
2623
+ return /* @__PURE__ */ React30.createElement(React30.Fragment, null, /* @__PURE__ */ React30.createElement(Mention3, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React30.createElement(
2624
+ Popover5,
2841
2625
  {
2842
2626
  visible,
2843
2627
  trigger: "custom",
2844
2628
  position: "topLeft",
2845
2629
  rePosKey: posKey,
2846
- content: /* @__PURE__ */ React23.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React23.createElement(
2630
+ content: /* @__PURE__ */ React30.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React30.createElement(
2847
2631
  Tree3,
2848
2632
  {
2849
2633
  treeData,
@@ -2853,7 +2637,7 @@ function VariableTree2() {
2853
2637
  }
2854
2638
  ))
2855
2639
  },
2856
- /* @__PURE__ */ React23.createElement(
2640
+ /* @__PURE__ */ React30.createElement(
2857
2641
  PositionMirror3,
2858
2642
  {
2859
2643
  position,
@@ -2864,7 +2648,7 @@ function VariableTree2() {
2864
2648
  }
2865
2649
 
2866
2650
  // src/components/json-editor-with-variables/extensions/variable-tag.tsx
2867
- import React24, { useLayoutEffect as useLayoutEffect5 } from "react";
2651
+ import React31, { useLayoutEffect as useLayoutEffect5 } from "react";
2868
2652
  import { createRoot } from "react-dom/client";
2869
2653
  import { isEqual as isEqual2, last as last3 } from "lodash";
2870
2654
  import {
@@ -2872,7 +2656,7 @@ import {
2872
2656
  DisposableCollection as DisposableCollection2,
2873
2657
  useCurrentScope as useCurrentScope2
2874
2658
  } from "@flowgram.ai/editor";
2875
- import { Popover as Popover5 } from "@douyinfe/semi-ui";
2659
+ import { Popover as Popover6 } from "@douyinfe/semi-ui";
2876
2660
  import { IconIssueStroked as IconIssueStroked3 } from "@douyinfe/semi-icons";
2877
2661
  import { useInjector as useInjector5 } from "@coze-editor/editor/react";
2878
2662
  import {
@@ -2884,9 +2668,9 @@ import {
2884
2668
  } from "@codemirror/view";
2885
2669
 
2886
2670
  // src/components/json-editor-with-variables/styles.tsx
2887
- import styled8 from "styled-components";
2671
+ import styled9 from "styled-components";
2888
2672
  import { Tag as Tag3 } from "@douyinfe/semi-ui";
2889
- var UIRootTitle3 = styled8.div`
2673
+ var UIRootTitle3 = styled9.div`
2890
2674
  margin-right: 4px;
2891
2675
  min-width: 20px;
2892
2676
  overflow: hidden;
@@ -2894,12 +2678,12 @@ var UIRootTitle3 = styled8.div`
2894
2678
  white-space: nowrap;
2895
2679
  color: var(--semi-color-text-2);
2896
2680
  `;
2897
- var UIVarName3 = styled8.div`
2681
+ var UIVarName3 = styled9.div`
2898
2682
  overflow: hidden;
2899
2683
  text-overflow: ellipsis;
2900
2684
  white-space: nowrap;
2901
2685
  `;
2902
- var UITag3 = styled8(Tag3)`
2686
+ var UITag3 = styled9(Tag3)`
2903
2687
  display: inline-flex;
2904
2688
  align-items: center;
2905
2689
  justify-content: flex-start;
@@ -2913,7 +2697,7 @@ var UITag3 = styled8(Tag3)`
2913
2697
  margin: 0 5px;
2914
2698
  }
2915
2699
  `;
2916
- var UIPopoverContent2 = styled8.div`
2700
+ var UIPopoverContent3 = styled9.div`
2917
2701
  padding: 10px;
2918
2702
  display: inline-flex;
2919
2703
  align-items: center;
@@ -2927,7 +2711,7 @@ var VariableTagWidget2 = class extends WidgetType2 {
2927
2711
  this.toDispose = new DisposableCollection2();
2928
2712
  this.renderIcon = (icon) => {
2929
2713
  if (typeof icon === "string") {
2930
- return /* @__PURE__ */ React24.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2714
+ return /* @__PURE__ */ React31.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2931
2715
  }
2932
2716
  return icon;
2933
2717
  };
@@ -2937,20 +2721,20 @@ var VariableTagWidget2 = class extends WidgetType2 {
2937
2721
  renderVariable(v) {
2938
2722
  if (!v) {
2939
2723
  this.root.render(
2940
- /* @__PURE__ */ React24.createElement(UITag3, { prefixIcon: /* @__PURE__ */ React24.createElement(IconIssueStroked3, null), color: "amber" }, "Unknown")
2724
+ /* @__PURE__ */ React31.createElement(UITag3, { prefixIcon: /* @__PURE__ */ React31.createElement(IconIssueStroked3, null), color: "amber" }, "Unknown")
2941
2725
  );
2942
2726
  return;
2943
2727
  }
2944
2728
  const rootField = last3(v.parentFields);
2945
- const rootTitle = /* @__PURE__ */ React24.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
2729
+ const rootTitle = /* @__PURE__ */ React31.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
2946
2730
  const rootIcon = this.renderIcon(rootField?.meta.icon);
2947
2731
  this.root.render(
2948
- /* @__PURE__ */ React24.createElement(
2949
- Popover5,
2732
+ /* @__PURE__ */ React31.createElement(
2733
+ Popover6,
2950
2734
  {
2951
- content: /* @__PURE__ */ React24.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React24.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
2735
+ content: /* @__PURE__ */ React31.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ React31.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
2952
2736
  },
2953
- /* @__PURE__ */ React24.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React24.createElement(UIVarName3, null, v?.key))
2737
+ /* @__PURE__ */ React31.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React31.createElement(UIVarName3, null, v?.key))
2954
2738
  )
2955
2739
  );
2956
2740
  }
@@ -3022,39 +2806,545 @@ function VariableTagInject2() {
3022
2806
  return null;
3023
2807
  }
3024
2808
 
3025
- // src/components/json-editor-with-variables/index.tsx
3026
- function JsonEditorWithVariables(props) {
3027
- return /* @__PURE__ */ React25.createElement(CodeEditor, { languageId: "json", activeLinePlaceholder: "Press '@' to Select variable", ...props }, /* @__PURE__ */ React25.createElement(VariableTree2, null), /* @__PURE__ */ React25.createElement(VariableTagInject2, null));
2809
+ // 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
+ }
2854
+
2855
+ // src/components/inputs-values/index.tsx
2856
+ import React34 from "react";
2857
+ import { Button as Button4, IconButton as IconButton5 } from "@douyinfe/semi-ui";
2858
+ import { IconDelete as IconDelete2, IconPlus as IconPlus3 } from "@douyinfe/semi-icons";
2859
+
2860
+ // src/components/inputs-values/styles.tsx
2861
+ import styled10 from "styled-components";
2862
+ var UIRows2 = styled10.div`
2863
+ display: flex;
2864
+ flex-direction: column;
2865
+ gap: 10px;
2866
+ margin-bottom: 10px;
2867
+ `;
2868
+ var UIRow3 = styled10.div`
2869
+ display: flex;
2870
+ align-items: center;
2871
+ gap: 5px;
2872
+ `;
2873
+
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
+ // src/components/inputs-values/index.tsx
2896
+ function InputsValues({
2897
+ value,
2898
+ onChange,
2899
+ style,
2900
+ readonly,
2901
+ constantProps,
2902
+ schema,
2903
+ hasError
2904
+ }) {
2905
+ const { list, updateKey, updateValue, remove, add } = useObjectList({
2906
+ value,
2907
+ onChange,
2908
+ sortIndexKey: "extra.index"
2909
+ });
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,
2912
+ {
2913
+ style: { width: 100, minWidth: 100, maxWidth: 100 },
2914
+ disabled: readonly,
2915
+ size: "small",
2916
+ value: item.key,
2917
+ onChange: (v) => updateKey(item.id, v),
2918
+ placeholder: "Input Key"
2919
+ }
2920
+ ), /* @__PURE__ */ React34.createElement(
2921
+ DynamicValueInput,
2922
+ {
2923
+ style: { flexGrow: 1 },
2924
+ readonly,
2925
+ value: item.value,
2926
+ onChange: (v) => updateValue(item.id, v),
2927
+ schema,
2928
+ hasError,
2929
+ constantProps: {
2930
+ ...constantProps,
2931
+ strategies: [...constantProps?.strategies || []]
2932
+ }
2933
+ }
2934
+ ), /* @__PURE__ */ React34.createElement(
2935
+ IconButton5,
2936
+ {
2937
+ disabled: readonly,
2938
+ theme: "borderless",
2939
+ icon: /* @__PURE__ */ React34.createElement(IconDelete2, { size: "small" }),
2940
+ size: "small",
2941
+ onClick: () => remove(item.id)
2942
+ }
2943
+ )))), /* @__PURE__ */ React34.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React34.createElement(IconPlus3, null), size: "small", onClick: add }, "Add"));
2944
+ }
2945
+
2946
+ // src/components/display-schema-tree/index.tsx
2947
+ import React35 from "react";
2948
+
2949
+ // src/components/display-schema-tree/styles.tsx
2950
+ import styled11, { css as css4 } from "styled-components";
2951
+ var TreeRow = styled11.div`
2952
+ display: flex;
2953
+ align-items: center;
2954
+
2955
+ .tree-icon {
2956
+ margin-right: 8px;
2957
+ width: 14px;
2958
+ height: 14px;
2959
+ }
2960
+
2961
+ height: 27px;
2962
+ white-space: nowrap;
2963
+ `;
2964
+ var HorizontalLine = styled11.div`
2965
+ position: relative;
2966
+
2967
+ &::before,
2968
+ &::after {
2969
+ content: '';
2970
+ position: absolute;
2971
+ background-color: var(--semi-color-text-3);
2972
+ }
2973
+
2974
+ &::after {
2975
+ top: 0px;
2976
+ right: 6px;
2977
+ width: 15px;
2978
+ height: 1px;
2979
+ }
2980
+ `;
2981
+ var TreeTitle = styled11.div`
2982
+ // overflow: hidden;
2983
+ // text-overflow: ellipsis;
2984
+ `;
2985
+ var TreeLevel = styled11.div`
2986
+ padding-left: 30px;
2987
+ position: relative;
2988
+
2989
+ /* &::before {
2990
+ content: '';
2991
+ position: absolute;
2992
+ background-color: var(--semi-color-text-3);
2993
+ top: 0px;
2994
+ bottom: 0px;
2995
+ left: -22px;
2996
+ width: 1px;
2997
+ } */
2998
+ `;
2999
+ var TreeItem = styled11.div`
3000
+ position: relative;
3001
+
3002
+ &::before {
3003
+ content: '';
3004
+ position: absolute;
3005
+ background-color: var(--semi-color-text-3);
3006
+ }
3007
+
3008
+ &:not(:last-child)::before {
3009
+ width: 1px;
3010
+ top: 0;
3011
+ bottom: 0;
3012
+ left: -22px;
3013
+ }
3014
+
3015
+ &:last-child::before {
3016
+ width: 1px;
3017
+ top: 0;
3018
+ height: 14px;
3019
+ left: -22px;
3020
+ }
3021
+
3022
+ ${(props) => props.depth === 0 && css4`
3023
+ &::before {
3024
+ width: 0px !important;
3025
+ }
3026
+ `}
3027
+ `;
3028
+
3029
+ // src/components/display-schema-tree/index.tsx
3030
+ function DisplaySchemaTree(props) {
3031
+ return /* @__PURE__ */ React35.createElement(SchemaTree, { ...props });
3032
+ }
3033
+ function SchemaTree(props) {
3034
+ const {
3035
+ value: schema = {},
3036
+ drilldown = true,
3037
+ depth = 0,
3038
+ showIcon = true,
3039
+ parentKey = ""
3040
+ } = props || {};
3041
+ const typeManager = useTypeManager();
3042
+ const config = typeManager.getTypeBySchema(schema);
3043
+ const title = typeManager.getComplexText(schema);
3044
+ const icon = typeManager?.getDisplayIcon(schema);
3045
+ let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
3046
+ 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, {
3048
+ 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);
3050
+ }
3051
+
3052
+ // 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";
3056
+
3057
+ // src/components/display-schema-tag/index.tsx
3058
+ import React36 from "react";
3059
+ import { Popover as Popover7 } from "@douyinfe/semi-ui";
3060
+
3061
+ // 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`
3065
+ padding: 10px;
3066
+ `;
3067
+ var StyledTag = styled12(Tag4)`
3068
+ padding: 4px;
3069
+
3070
+ .tag-icon {
3071
+ width: 12px;
3072
+ height: 12px;
3073
+ }
3074
+ `;
3075
+ var TitleSpan = styled12.span`
3076
+ display: inline-block;
3077
+ margin-left: 4px;
3078
+ margin-top: -1px;
3079
+ overflow: hidden;
3080
+ text-overflow: ellipsis;
3081
+ `;
3082
+
3083
+ // src/components/display-schema-tag/index.tsx
3084
+ function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
3085
+ const typeManager = useTypeManager();
3086
+ const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
3087
+ return /* @__PURE__ */ React36.createElement(
3088
+ Popover7,
3089
+ {
3090
+ content: /* @__PURE__ */ React36.createElement(PopoverContent, null, /* @__PURE__ */ React36.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
3091
+ },
3092
+ /* @__PURE__ */ React36.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && React36.cloneElement(icon, {
3093
+ className: "tag-icon"
3094
+ }), title && /* @__PURE__ */ React36.createElement(TitleSpan, null, title))
3095
+ );
3096
+ }
3097
+
3098
+ // src/components/display-outputs/styles.ts
3099
+ import styled13 from "styled-components";
3100
+ var DisplayOutputsWrapper = styled13.div`
3101
+ display: flex;
3102
+ gap: 5px;
3103
+ flex-wrap: wrap;
3104
+ `;
3105
+
3106
+ // src/components/display-outputs/index.tsx
3107
+ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
3108
+ const scope = useCurrentScope3();
3109
+ const refresh = useRefresh();
3110
+ useEffect10(() => {
3111
+ if (!displayFromScope) {
3112
+ return () => null;
3113
+ }
3114
+ const disposable = scope.output.onListOrAnyVarChange(() => {
3115
+ refresh();
3116
+ });
3117
+ return () => {
3118
+ disposable.dispose();
3119
+ };
3120
+ }, [displayFromScope]);
3121
+ const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
3122
+ acm = {
3123
+ ...acm,
3124
+ ...JsonSchemaUtils5.astToSchema(curr.type)?.properties || {}
3125
+ };
3126
+ return acm;
3127
+ }, {}) : value?.properties || {};
3128
+ const childEntries = Object.entries(properties || {});
3129
+ return /* @__PURE__ */ React37.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ React37.createElement(
3130
+ DisplaySchemaTag,
3131
+ {
3132
+ key,
3133
+ title: key,
3134
+ value: schema,
3135
+ showIconInTree,
3136
+ warning: !schema
3137
+ }
3138
+ )));
3139
+ }
3140
+
3141
+ // 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";
3145
+ function DisplayFlowValue({ value, title, showIconInTree }) {
3146
+ const available = useScopeAvailable4();
3147
+ const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
3148
+ const schema = useMemo11(() => {
3149
+ if (value?.type === "ref") {
3150
+ return JsonSchemaUtils6.astToSchema(variable?.type);
3151
+ }
3152
+ if (value?.type === "template") {
3153
+ return { type: "string" };
3154
+ }
3155
+ 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
+ }
3168
+ }
3169
+ return { type: "unknown" };
3170
+ }, [value, variable?.hash]);
3171
+ return /* @__PURE__ */ React38.createElement(
3172
+ DisplaySchemaTag,
3173
+ {
3174
+ title,
3175
+ value: schema,
3176
+ showIconInTree,
3177
+ warning: value?.type === "ref" && !variable
3178
+ }
3179
+ );
3180
+ }
3181
+
3182
+ // src/components/display-inputs-values/index.tsx
3183
+ import React39 from "react";
3184
+
3185
+ // src/components/display-inputs-values/styles.ts
3186
+ import styled14 from "styled-components";
3187
+ var DisplayInputsWrapper = styled14.div`
3188
+ display: flex;
3189
+ gap: 5px;
3190
+ flex-wrap: wrap;
3191
+ `;
3192
+
3193
+ // src/components/display-inputs-values/index.tsx
3194
+ function DisplayInputsValues({ value, showIconInTree }) {
3195
+ 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 })));
3197
+ }
3198
+
3199
+ // src/components/assign-rows/index.tsx
3200
+ import React42 from "react";
3201
+ import { FieldArray } from "@flowgram.ai/editor";
3202
+ import { Button as Button5 } from "@douyinfe/semi-ui";
3203
+ import { IconPlus as IconPlus4 } from "@douyinfe/semi-icons";
3204
+
3205
+ // src/components/assign-row/index.tsx
3206
+ import React41 from "react";
3207
+ import { IconButton as IconButton6 } from "@douyinfe/semi-ui";
3208
+ import { IconMinus as IconMinus2 } from "@douyinfe/semi-icons";
3209
+
3210
+ // 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(() => {
3216
+ setValue(props.value);
3217
+ }, [props.value]);
3218
+ return /* @__PURE__ */ React40.createElement(
3219
+ Input7,
3220
+ {
3221
+ ...props,
3222
+ value,
3223
+ onChange: (value2) => {
3224
+ setValue(value2);
3225
+ },
3226
+ onBlur: (e) => props.onChange?.(value, e)
3227
+ }
3228
+ );
3229
+ }
3230
+
3231
+ // src/components/assign-row/index.tsx
3232
+ function AssignRow(props) {
3233
+ const {
3234
+ value = {
3235
+ operator: "assign"
3236
+ },
3237
+ onChange,
3238
+ onDelete,
3239
+ readonly
3240
+ } = 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,
3243
+ {
3244
+ style: { width: "100%", height: 26 },
3245
+ value: value?.left?.content,
3246
+ config: { placeholder: "Select Left" },
3247
+ onChange: (v) => onChange?.({
3248
+ ...value,
3249
+ left: { type: "ref", content: v }
3250
+ })
3251
+ }
3252
+ ) : /* @__PURE__ */ React41.createElement(
3253
+ BlurInput3,
3254
+ {
3255
+ style: { height: 26 },
3256
+ size: "small",
3257
+ placeholder: "Input Name",
3258
+ value: value?.left,
3259
+ onChange: (v) => onChange?.({
3260
+ ...value,
3261
+ left: v
3262
+ })
3263
+ }
3264
+ )), /* @__PURE__ */ React41.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ React41.createElement(
3265
+ DynamicValueInput,
3266
+ {
3267
+ readonly,
3268
+ value: value?.right,
3269
+ onChange: (v) => onChange?.({
3270
+ ...value,
3271
+ right: v
3272
+ })
3273
+ }
3274
+ )), onDelete && /* @__PURE__ */ React41.createElement("div", null, /* @__PURE__ */ React41.createElement(
3275
+ IconButton6,
3276
+ {
3277
+ size: "small",
3278
+ theme: "borderless",
3279
+ icon: /* @__PURE__ */ React41.createElement(IconMinus2, null),
3280
+ onClick: () => onDelete?.()
3281
+ }
3282
+ )));
3283
+ }
3284
+
3285
+ // src/components/assign-rows/index.tsx
3286
+ function AssignRows(props) {
3287
+ 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(
3289
+ AssignRow,
3290
+ {
3291
+ key: childField.key,
3292
+ readonly,
3293
+ value: childField.value,
3294
+ onChange: (value) => {
3295
+ childField.onChange(value);
3296
+ },
3297
+ onDelete: () => field.remove(index)
3298
+ }
3299
+ )), /* @__PURE__ */ React42.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ React42.createElement(
3300
+ Button5,
3301
+ {
3302
+ size: "small",
3303
+ theme: "borderless",
3304
+ icon: /* @__PURE__ */ React42.createElement(IconPlus4, null),
3305
+ onClick: () => field.append({ operator: "assign" })
3306
+ },
3307
+ "Assign"
3308
+ ), /* @__PURE__ */ React42.createElement(
3309
+ Button5,
3310
+ {
3311
+ size: "small",
3312
+ theme: "borderless",
3313
+ icon: /* @__PURE__ */ React42.createElement(IconPlus4, null),
3314
+ onClick: () => field.append({ operator: "declare" })
3315
+ },
3316
+ "Declaration"
3317
+ ))));
3028
3318
  }
3029
3319
 
3030
3320
  // src/effects/provide-batch-input/index.ts
3031
3321
  import {
3032
- ASTFactory as ASTFactory2,
3322
+ ASTFactory,
3033
3323
  createEffectFromVariableProvider,
3034
3324
  getNodeForm
3035
3325
  } from "@flowgram.ai/editor";
3036
3326
  var provideBatchInputEffect = createEffectFromVariableProvider({
3037
3327
  private: true,
3038
3328
  parse: (value, ctx) => [
3039
- ASTFactory2.createVariableDeclaration({
3329
+ ASTFactory.createVariableDeclaration({
3040
3330
  key: `${ctx.node.id}_locals`,
3041
3331
  meta: {
3042
3332
  title: getNodeForm(ctx.node)?.getValueIn("title"),
3043
3333
  icon: ctx.node.getNodeRegistry().info?.icon
3044
3334
  },
3045
- type: ASTFactory2.createObject({
3335
+ type: ASTFactory.createObject({
3046
3336
  properties: [
3047
- ASTFactory2.createProperty({
3337
+ ASTFactory.createProperty({
3048
3338
  key: "item",
3049
- initializer: ASTFactory2.createEnumerateExpression({
3050
- enumerateFor: ASTFactory2.createKeyPathExpression({
3339
+ initializer: ASTFactory.createEnumerateExpression({
3340
+ enumerateFor: ASTFactory.createKeyPathExpression({
3051
3341
  keyPath: value.content || []
3052
3342
  })
3053
3343
  })
3054
3344
  }),
3055
- ASTFactory2.createProperty({
3345
+ ASTFactory.createProperty({
3056
3346
  key: "index",
3057
- type: ASTFactory2.createNumber()
3347
+ type: ASTFactory.createNumber()
3058
3348
  })
3059
3349
  ]
3060
3350
  })
@@ -3062,38 +3352,8 @@ var provideBatchInputEffect = createEffectFromVariableProvider({
3062
3352
  ]
3063
3353
  });
3064
3354
 
3065
- // src/effects/provide-batch-outputs/index.ts
3066
- import {
3067
- ASTFactory as ASTFactory3,
3068
- createEffectFromVariableProvider as createEffectFromVariableProvider2,
3069
- getNodeForm as getNodeForm2
3070
- } from "@flowgram.ai/editor";
3071
- var provideBatchOutputsEffect = createEffectFromVariableProvider2({
3072
- parse: (value, ctx) => [
3073
- ASTFactory3.createVariableDeclaration({
3074
- key: `${ctx.node.id}`,
3075
- meta: {
3076
- title: getNodeForm2(ctx.node)?.getValueIn("title"),
3077
- icon: ctx.node.getNodeRegistry().info?.icon
3078
- },
3079
- type: ASTFactory3.createObject({
3080
- properties: Object.entries(value).map(
3081
- ([_key, value2]) => ASTFactory3.createProperty({
3082
- key: _key,
3083
- initializer: ASTFactory3.createWrapArrayExpression({
3084
- wrapFor: ASTFactory3.createKeyPathExpression({
3085
- keyPath: value2.content || []
3086
- })
3087
- })
3088
- })
3089
- )
3090
- })
3091
- })
3092
- ]
3093
- });
3094
-
3095
3355
  // src/effects/auto-rename-ref/index.ts
3096
- import { isArray, isObject as isObject2 } from "lodash";
3356
+ import { isArray, isObject as isObject2, uniq } from "lodash";
3097
3357
  import {
3098
3358
  DataEvent,
3099
3359
  VariableFieldKeyRenameService
@@ -3114,9 +3374,30 @@ var autoRenameRefEffect = [
3114
3374
  after.key
3115
3375
  ];
3116
3376
  traverseRef(name, form.getValueIn(name), (_drilldownName, _v) => {
3117
- if (isRefMatch(_v, beforeKeyPath)) {
3118
- _v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
3119
- form.setValueIn(_drilldownName, _v);
3377
+ if (_v.type === "ref") {
3378
+ if (isKeyPathMatch(_v.content, beforeKeyPath)) {
3379
+ _v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
3380
+ form.setValueIn(_drilldownName, _v);
3381
+ }
3382
+ } else if (_v.type === "template") {
3383
+ const templateKeyPaths = getTemplateKeyPaths(_v);
3384
+ let hasMatch = false;
3385
+ templateKeyPaths.forEach((_keyPath) => {
3386
+ if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
3387
+ hasMatch = true;
3388
+ const nextKeyPath = [
3389
+ ...afterKeyPath,
3390
+ ...(_keyPath || [])?.slice(beforeKeyPath.length)
3391
+ ];
3392
+ _v.content = _v.content?.replace(
3393
+ `{{${_keyPath.join(".")}}`,
3394
+ `{{${nextKeyPath.join(".")}}`
3395
+ );
3396
+ }
3397
+ });
3398
+ if (hasMatch) {
3399
+ form.setValueIn(_drilldownName, { ..._v });
3400
+ }
3120
3401
  }
3121
3402
  });
3122
3403
  });
@@ -3126,18 +3407,31 @@ var autoRenameRefEffect = [
3126
3407
  }
3127
3408
  }
3128
3409
  ];
3129
- function isRefMatch(value, targetKeyPath) {
3130
- return targetKeyPath.every((_key, index) => _key === value.content?.[index]);
3410
+ function isKeyPathMatch(keyPath = [], targetKeyPath) {
3411
+ return targetKeyPath.every((_key, index) => _key === keyPath[index]);
3412
+ }
3413
+ function getTemplateKeyPaths(value) {
3414
+ const keyPathReg = /{{(.*?)}}/g;
3415
+ return uniq(value.content?.match(keyPathReg) || []).map(
3416
+ (_keyPath) => _keyPath.slice(2, -2).split(".")
3417
+ );
3131
3418
  }
3132
3419
  function isRef(value) {
3133
3420
  return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
3134
3421
  }
3422
+ function isTemplate(value) {
3423
+ return value?.type === "template" && typeof value?.content === "string";
3424
+ }
3135
3425
  function traverseRef(name, value, cb) {
3136
3426
  if (isObject2(value)) {
3137
3427
  if (isRef(value)) {
3138
3428
  cb(name, value);
3139
3429
  return;
3140
3430
  }
3431
+ if (isTemplate(value)) {
3432
+ cb(name, value);
3433
+ return;
3434
+ }
3141
3435
  Object.entries(value).forEach(([_key, _value]) => {
3142
3436
  traverseRef(`${name}.${_key}`, _value, cb);
3143
3437
  });
@@ -3153,20 +3447,21 @@ function traverseRef(name, value, cb) {
3153
3447
  }
3154
3448
 
3155
3449
  // src/effects/provide-json-schema-outputs/index.ts
3450
+ import { JsonSchemaUtils as JsonSchemaUtils7 } from "@flowgram.ai/json-schema";
3156
3451
  import {
3157
- ASTFactory as ASTFactory4,
3158
- createEffectFromVariableProvider as createEffectFromVariableProvider3,
3159
- getNodeForm as getNodeForm3
3452
+ ASTFactory as ASTFactory2,
3453
+ createEffectFromVariableProvider as createEffectFromVariableProvider2,
3454
+ getNodeForm as getNodeForm2
3160
3455
  } from "@flowgram.ai/editor";
3161
- var provideJsonSchemaOutputs = createEffectFromVariableProvider3({
3456
+ var provideJsonSchemaOutputs = createEffectFromVariableProvider2({
3162
3457
  parse: (value, ctx) => [
3163
- ASTFactory4.createVariableDeclaration({
3458
+ ASTFactory2.createVariableDeclaration({
3164
3459
  key: `${ctx.node.id}`,
3165
3460
  meta: {
3166
- title: getNodeForm3(ctx.node)?.getValueIn("title") || ctx.node.id,
3461
+ title: getNodeForm2(ctx.node)?.getValueIn("title") || ctx.node.id,
3167
3462
  icon: ctx.node.getNodeRegistry().info?.icon
3168
3463
  },
3169
- type: JsonSchemaUtils.schemaToAST(value)
3464
+ type: JsonSchemaUtils7.schemaToAST(value)
3170
3465
  })
3171
3466
  ]
3172
3467
  });
@@ -3183,6 +3478,7 @@ var syncVariableTitle = [
3183
3478
  context.node.getData(FlowNodeVariableData).allScopes.forEach((_scope) => {
3184
3479
  _scope.output.variables.forEach((_var) => {
3185
3480
  _var.updateMeta({
3481
+ ..._var.meta || {},
3186
3482
  title: value || context.node.id,
3187
3483
  icon: context.node.getNodeRegistry().info?.icon
3188
3484
  });
@@ -3192,31 +3488,173 @@ var syncVariableTitle = [
3192
3488
  }
3193
3489
  ];
3194
3490
 
3491
+ // src/effects/validate-when-variable-sync/index.ts
3492
+ import { isEmpty } from "lodash";
3493
+ import {
3494
+ DataEvent as DataEvent3,
3495
+ getNodeScope,
3496
+ getNodePrivateScope
3497
+ } from "@flowgram.ai/editor";
3498
+ var validateWhenVariableSync = ({
3499
+ scope
3500
+ } = {}) => [
3501
+ {
3502
+ event: DataEvent3.onValueInit,
3503
+ effect: ({ context, form }) => {
3504
+ const nodeScope = scope === "private" ? getNodePrivateScope(context.node) : getNodeScope(context.node);
3505
+ const disposable = nodeScope.available.onListOrAnyVarChange(() => {
3506
+ if (!isEmpty(form.state.errors)) {
3507
+ form.validate();
3508
+ }
3509
+ });
3510
+ return () => disposable.dispose();
3511
+ }
3512
+ }
3513
+ ];
3514
+
3515
+ // src/effects/listen-ref-value-change/index.ts
3516
+ import {
3517
+ DataEvent as DataEvent4,
3518
+ getNodeScope as getNodeScope2
3519
+ } from "@flowgram.ai/editor";
3520
+ var listenRefValueChange = (cb) => [
3521
+ {
3522
+ event: DataEvent4.onValueInitOrChange,
3523
+ effect: (params) => {
3524
+ const { context, value } = params;
3525
+ if (value?.type !== "ref") {
3526
+ return () => null;
3527
+ }
3528
+ const disposable = getNodeScope2(context.node).available.trackByKeyPath(
3529
+ value?.content || [],
3530
+ (v) => {
3531
+ cb({ ...params, variable: v });
3532
+ }
3533
+ );
3534
+ return () => {
3535
+ disposable.dispose();
3536
+ };
3537
+ }
3538
+ }
3539
+ ];
3540
+
3541
+ // src/effects/listen-ref-schema-change/index.ts
3542
+ import { JsonSchemaUtils as JsonSchemaUtils8 } from "@flowgram.ai/json-schema";
3543
+ import {
3544
+ DataEvent as DataEvent5,
3545
+ getNodeScope as getNodeScope3
3546
+ } from "@flowgram.ai/editor";
3547
+ var listenRefSchemaChange = (cb) => [
3548
+ {
3549
+ event: DataEvent5.onValueInitOrChange,
3550
+ effect: (params) => {
3551
+ const { context, value } = params;
3552
+ if (value?.type !== "ref") {
3553
+ return () => null;
3554
+ }
3555
+ const disposable = getNodeScope3(context.node).available.trackByKeyPath(
3556
+ value?.content || [],
3557
+ (_type) => {
3558
+ cb({ ...params, schema: JsonSchemaUtils8.astToSchema(_type) });
3559
+ },
3560
+ {
3561
+ selector: (_v) => _v?.type
3562
+ }
3563
+ );
3564
+ return () => {
3565
+ disposable.dispose();
3566
+ };
3567
+ }
3568
+ }
3569
+ ];
3570
+
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
+
3195
3633
  // src/form-plugins/batch-outputs-plugin/index.ts
3196
3634
  import {
3197
- ASTFactory as ASTFactory5,
3198
- createEffectFromVariableProvider as createEffectFromVariableProvider4,
3635
+ ASTFactory as ASTFactory3,
3636
+ createEffectFromVariableProvider as createEffectFromVariableProvider3,
3199
3637
  defineFormPluginCreator,
3200
- getNodeForm as getNodeForm4,
3201
- getNodePrivateScope,
3202
- getNodeScope,
3638
+ getNodeForm as getNodeForm3,
3639
+ getNodePrivateScope as getNodePrivateScope2,
3640
+ getNodeScope as getNodeScope4,
3203
3641
  ScopeChainTransformService,
3204
3642
  FlowNodeScopeType
3205
3643
  } from "@flowgram.ai/editor";
3206
- var provideBatchOutputsEffect2 = createEffectFromVariableProvider4({
3644
+ var provideBatchOutputsEffect = createEffectFromVariableProvider3({
3207
3645
  parse: (value, ctx) => [
3208
- ASTFactory5.createVariableDeclaration({
3646
+ ASTFactory3.createVariableDeclaration({
3209
3647
  key: `${ctx.node.id}`,
3210
3648
  meta: {
3211
- title: getNodeForm4(ctx.node)?.getValueIn("title"),
3649
+ title: getNodeForm3(ctx.node)?.getValueIn("title"),
3212
3650
  icon: ctx.node.getNodeRegistry().info?.icon
3213
3651
  },
3214
- type: ASTFactory5.createObject({
3652
+ type: ASTFactory3.createObject({
3215
3653
  properties: Object.entries(value).map(
3216
- ([_key, value2]) => ASTFactory5.createProperty({
3654
+ ([_key, value2]) => ASTFactory3.createProperty({
3217
3655
  key: _key,
3218
- initializer: ASTFactory5.createWrapArrayExpression({
3219
- wrapFor: ASTFactory5.createKeyPathExpression({
3656
+ initializer: ASTFactory3.createWrapArrayExpression({
3657
+ wrapFor: ASTFactory3.createKeyPathExpression({
3220
3658
  keyPath: value2?.content || []
3221
3659
  })
3222
3660
  })
@@ -3230,7 +3668,7 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
3230
3668
  name: "batch-outputs-plugin",
3231
3669
  onSetupFormMeta({ mergeEffect }, { outputKey }) {
3232
3670
  mergeEffect({
3233
- [outputKey]: provideBatchOutputsEffect2
3671
+ [outputKey]: provideBatchOutputsEffect
3234
3672
  });
3235
3673
  },
3236
3674
  onInit(ctx, { outputKey }) {
@@ -3244,7 +3682,7 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
3244
3682
  transformCovers: (covers, ctx2) => {
3245
3683
  const node = ctx2.scope.meta?.node;
3246
3684
  if (node?.parent?.flowNodeType === batchNodeType) {
3247
- return [...covers, getNodeScope(node.parent)];
3685
+ return [...covers, getNodeScope4(node.parent)];
3248
3686
  }
3249
3687
  return covers;
3250
3688
  },
@@ -3257,8 +3695,8 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
3257
3695
  if (node?.flowNodeType === batchNodeType) {
3258
3696
  const childBlocks = node.blocks;
3259
3697
  return [
3260
- getNodePrivateScope(node),
3261
- ...childBlocks.map((_childBlock) => getNodeScope(_childBlock))
3698
+ getNodePrivateScope2(node),
3699
+ ...childBlocks.map((_childBlock) => getNodeScope4(_childBlock))
3262
3700
  ];
3263
3701
  }
3264
3702
  return scopes;
@@ -3266,38 +3704,235 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
3266
3704
  });
3267
3705
  }
3268
3706
  });
3707
+
3708
+ // 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";
3716
+ var createInferInputsPlugin = defineFormPluginCreator2({
3717
+ onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
3718
+ if (!sourceKey || !targetKey) {
3719
+ return;
3720
+ }
3721
+ addFormatOnSubmit((formData, ctx) => {
3722
+ set2(
3723
+ formData,
3724
+ targetKey,
3725
+ infer(
3726
+ get2(formData, sourceKey),
3727
+ scope === "private" ? getNodePrivateScope3(ctx.node) : getNodeScope5(ctx.node)
3728
+ )
3729
+ );
3730
+ return formData;
3731
+ });
3732
+ }
3733
+ });
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
+
3788
+ // 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";
3791
+ import {
3792
+ ASTFactory as ASTFactory4,
3793
+ createEffectFromVariableProvider as createEffectFromVariableProvider4,
3794
+ defineFormPluginCreator as defineFormPluginCreator3,
3795
+ getNodeForm as getNodeForm4,
3796
+ getNodeScope as getNodeScope6
3797
+ } from "@flowgram.ai/editor";
3798
+ var createInferAssignPlugin = defineFormPluginCreator3({
3799
+ onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
3800
+ if (!assignKey || !outputKey) {
3801
+ return;
3802
+ }
3803
+ mergeEffect({
3804
+ [assignKey]: createEffectFromVariableProvider4({
3805
+ parse: (value, ctx) => {
3806
+ const declareRows = uniqBy(
3807
+ value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
3808
+ "left"
3809
+ );
3810
+ return [
3811
+ ASTFactory4.createVariableDeclaration({
3812
+ key: `${ctx.node.id}`,
3813
+ meta: {
3814
+ title: getNodeForm4(ctx.node)?.getValueIn("title"),
3815
+ icon: ctx.node.getNodeRegistry().info?.icon
3816
+ },
3817
+ type: ASTFactory4.createObject({
3818
+ properties: declareRows.map(
3819
+ (_v) => ASTFactory4.createProperty({
3820
+ key: _v.left,
3821
+ type: _v.right?.type === "constant" ? JsonSchemaUtils10.schemaToAST(_v.right?.schema || {}) : void 0,
3822
+ initializer: _v.right?.type === "ref" ? ASTFactory4.createKeyPathExpression({
3823
+ keyPath: _v.right?.content || []
3824
+ }) : {}
3825
+ })
3826
+ )
3827
+ })
3828
+ })
3829
+ ];
3830
+ }
3831
+ })
3832
+ });
3833
+ addFormatOnSubmit((formData, ctx) => {
3834
+ set3(
3835
+ formData,
3836
+ outputKey,
3837
+ JsonSchemaUtils10.astToSchema(getNodeScope6(ctx.node).output.variables?.[0]?.type)
3838
+ );
3839
+ return formData;
3840
+ });
3841
+ }
3842
+ });
3843
+
3844
+ // src/validate/validate-flow-value/index.tsx
3845
+ import { isNil, uniq as uniq2 } from "lodash";
3846
+ import { FeedbackLevel, getNodeScope as getNodeScope7 } from "@flowgram.ai/editor";
3847
+ function validateFlowValue(value, ctx) {
3848
+ const { node, required, errorMessages } = ctx;
3849
+ const {
3850
+ required: requiredMessage = "Field is required",
3851
+ unknownVariable: unknownVariableMessage = "Unknown Variable"
3852
+ } = errorMessages || {};
3853
+ if (required && (isNil(value) || isNil(value?.content) || value?.content === "")) {
3854
+ return {
3855
+ level: FeedbackLevel.Error,
3856
+ message: requiredMessage
3857
+ };
3858
+ }
3859
+ if (value?.type === "ref") {
3860
+ const variable = getNodeScope7(node).available.getByKeyPath(value?.content || []);
3861
+ if (!variable) {
3862
+ return {
3863
+ level: FeedbackLevel.Error,
3864
+ message: unknownVariableMessage
3865
+ };
3866
+ }
3867
+ }
3868
+ if (value?.type === "template") {
3869
+ const allRefs = getTemplateKeyPaths2(value);
3870
+ for (const ref of allRefs) {
3871
+ const variable = getNodeScope7(node).available.getByKeyPath(ref);
3872
+ if (!variable) {
3873
+ return {
3874
+ level: FeedbackLevel.Error,
3875
+ message: unknownVariableMessage
3876
+ };
3877
+ }
3878
+ }
3879
+ }
3880
+ return void 0;
3881
+ }
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
+ }
3269
3888
  export {
3270
- ArrayIcons,
3889
+ AssignRow,
3890
+ AssignRows,
3271
3891
  BatchOutputs,
3272
3892
  BatchVariableSelector,
3273
3893
  CodeEditor,
3894
+ CodeEditorMini,
3274
3895
  ConditionRow,
3275
3896
  ConstantInput,
3897
+ DisplayFlowValue,
3898
+ DisplayInputsValues,
3899
+ DisplayOutputs,
3900
+ DisplaySchemaTag,
3901
+ DisplaySchemaTree,
3276
3902
  DynamicValueInput,
3903
+ InputsValues,
3277
3904
  JsonEditorWithVariables,
3278
3905
  JsonSchemaEditor,
3906
+ JsonSchemaTypePresetProvider,
3279
3907
  JsonSchemaUtils,
3280
3908
  PromptEditor,
3281
3909
  PromptEditorWithInputs,
3282
3910
  PromptEditorWithVariables,
3283
3911
  TypeSelector,
3284
3912
  VariableSelector,
3285
- VariableTypeIcons,
3286
3913
  autoRenameRefEffect,
3287
3914
  createBatchOutputsFormPlugin,
3915
+ createDisableDeclarationPlugin,
3916
+ createInferAssignPlugin,
3917
+ createInferInputsPlugin,
3918
+ createTypePresetPlugin,
3288
3919
  formatLegacyRefOnInit,
3289
3920
  formatLegacyRefOnSubmit,
3290
3921
  formatLegacyRefToNewRef,
3291
3922
  formatNewRefToLegacyRef,
3292
- getSchemaIcon,
3293
3923
  getTypeSelectValue,
3294
3924
  isLegacyFlowRefValueSchema,
3295
3925
  isNewFlowRefValueSchema,
3926
+ listenRefSchemaChange,
3927
+ listenRefValueChange,
3296
3928
  parseTypeSelectValue,
3297
3929
  provideBatchInputEffect,
3298
3930
  provideBatchOutputsEffect,
3299
3931
  provideJsonSchemaOutputs,
3300
3932
  syncVariableTitle,
3301
- useVariableTree
3933
+ useTypeManager,
3934
+ useVariableTree,
3935
+ validateFlowValue,
3936
+ validateWhenVariableSync
3302
3937
  };
3303
3938
  //# sourceMappingURL=index.js.map